From 1500f5cd029e849de938a93ce8bc5690fe7179fd Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Wed, 16 Sep 2015 17:28:30 -0700 Subject: [PATCH 01/23] Moved importDefinitelyTypedTests.ts to its own folder. --- .../importDefinitelyTypedTests.ts | 3 --- 1 file changed, 3 deletions(-) rename scripts/{ => importDefinitelyTypedTests}/importDefinitelyTypedTests.ts (95%) diff --git a/scripts/importDefinitelyTypedTests.ts b/scripts/importDefinitelyTypedTests/importDefinitelyTypedTests.ts similarity index 95% rename from scripts/importDefinitelyTypedTests.ts rename to scripts/importDefinitelyTypedTests/importDefinitelyTypedTests.ts index f33ba1dd525..518fbed87b8 100644 --- a/scripts/importDefinitelyTypedTests.ts +++ b/scripts/importDefinitelyTypedTests/importDefinitelyTypedTests.ts @@ -1,6 +1,3 @@ -declare var require: any, process: any; -declare var __dirname: any; - var fs = require("fs"); var path = require("path"); var child_process = require('child_process'); From 9696e5777253e397b151816c31d8a780776027d5 Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Wed, 16 Sep 2015 17:34:31 -0700 Subject: [PATCH 02/23] Added tsd.json file with 'node.d.ts'. --- scripts/tsd.json | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 scripts/tsd.json 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" + } + } +} From a47b7b8f1764afeed1a520e6bdab25a4e29788e3 Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Wed, 16 Sep 2015 17:35:18 -0700 Subject: [PATCH 03/23] Added 'tsconfig.json' for 'importDefinitelyTypedTests' script. --- scripts/importDefinitelyTypedTests/tsconfig.json | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 scripts/importDefinitelyTypedTests/tsconfig.json diff --git a/scripts/importDefinitelyTypedTests/tsconfig.json b/scripts/importDefinitelyTypedTests/tsconfig.json new file mode 100644 index 00000000000..3bf148ffa5c --- /dev/null +++ b/scripts/importDefinitelyTypedTests/tsconfig.json @@ -0,0 +1,16 @@ +{ + "compilerOptions": { + "module": "commonjs", + "target": "es3", + "noImplicitAny": true, + "outDir": "./", + "rootDir": ".", + "sourceMap": false + }, + "files": [ + "../typings/node/node.d.ts", + "importDefinitelyTypedTests.ts" + ], + "exclude": [ + ] +} \ No newline at end of file From 8bb6313b22b9b7a0c1d5b0d04156589d181e64e3 Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Wed, 16 Sep 2015 17:42:32 -0700 Subject: [PATCH 04/23] Use explicit types, var -> let/const, misspellings, style. --- .../importDefinitelyTypedTests.ts | 70 ++++++++++++------- 1 file changed, 43 insertions(+), 27 deletions(-) diff --git a/scripts/importDefinitelyTypedTests/importDefinitelyTypedTests.ts b/scripts/importDefinitelyTypedTests/importDefinitelyTypedTests.ts index 518fbed87b8..fa935c2fa31 100644 --- a/scripts/importDefinitelyTypedTests/importDefinitelyTypedTests.ts +++ b/scripts/importDefinitelyTypedTests/importDefinitelyTypedTests.ts @@ -1,29 +1,41 @@ -var fs = require("fs"); -var path = require("path"); -var child_process = require('child_process'); +import * as fs from "fs"; +import * as path from "path"; +import * as child_process from "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]; +interface Map { + [key: string]: T; +} + +declare const __dirname: string; +declare const process: { + argv: string[]; + env: Map +} + +const tscRoot = path.join(__dirname, "..\\"); +const tscPath = path.join(tscRoot, "built", "instrumented", "tsc.js"); +const rwcTestPath = path.join(tscRoot, "tests", "cases", "rwc", "dt"); +const definitelyTypedRoot = process.argv[2]; function fileExtensionIs(path: string, extension: string): boolean { - var pathLen = path.length; - var extLen = extension.length; + const pathLen = path.length; + const extLen = extension.length; return pathLen > extLen && path.substr(pathLen - extLen, extLen).toLocaleLowerCase() === extension.toLocaleLowerCase(); } -function copyFileSync(source, destination) { - var text = fs.readFileSync(source); +function copyFileSync(source: string, destination: string) { + let 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; + let 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); + 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"); } @@ -47,8 +59,8 @@ function importDefinitelyTypedTest(testCaseName: string, testFiles: string[], re } // copy generated file to output location - var outputFilePath = path.join(testDirectoryPath, "iocapture0.json"); - var testCasePath = path.join(rwcTestPath, "DefinitelyTyped_" + testCaseName + ".json"); + let outputFilePath = path.join(testDirectoryPath, "iocapture0.json"); + let testCasePath = path.join(rwcTestPath, "DefinitelyTyped_" + testCaseName + ".json"); copyFileSync(outputFilePath, testCasePath); //console.log("output generated at: " + outputFilePath); @@ -65,28 +77,32 @@ function importDefinitelyTypedTest(testCaseName: string, testFiles: string[], re //console.log("\r\n"); }) - .on('error', function (error) { + .on('error', (error: any) => { console.log("==> error " + JSON.stringify(error)); console.log("\r\n"); }); } function importDefinitelyTypedTests(definitelyTypedRoot: string): void { - fs.readdir(definitelyTypedRoot, (err, subDirectorys) => { - if (err) throw err; + fs.readdir(definitelyTypedRoot, (err, subDirectories) => { + if (err) { + throw err; + } - subDirectorys + subDirectories .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); + let directoryPath = path.join(definitelyTypedRoot, d); fs.readdir(directoryPath, function (err, files) { - if (err) throw err; + if (err) { + throw err; + } - var tsFiles = []; - var testFiles = []; - var paramFile; + let tsFiles: string[] = []; + let testFiles: string[] = []; + let paramFile: string; files .map(f => path.join(directoryPath, f)) @@ -99,7 +115,7 @@ function importDefinitelyTypedTests(definitelyTypedRoot: string): void { if (testFiles.length === 0) { // no test files but multiple d.ts's, e.g. winjs - var regexp = new RegExp(d + "(([-][0-9])|([\.]d[\.]ts))"); + let 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); From 1ab10adbdcda1c6c0d7c15e932a7f89ce14cbcb8 Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Thu, 17 Sep 2015 00:53:17 -0700 Subject: [PATCH 05/23] Added tests. --- ...TypedClassExpressionMethodDeclaration01.ts | 47 +++++++++++++++++ ...TypedClassExpressionMethodDeclaration02.ts | 51 +++++++++++++++++++ ...lyTypedObjectLiteralMethodDeclaration01.ts | 47 +++++++++++++++++ 3 files changed, 145 insertions(+) create mode 100644 tests/cases/conformance/types/contextualTypes/methodDeclarations/contextuallyTypedClassExpressionMethodDeclaration01.ts create mode 100644 tests/cases/conformance/types/contextualTypes/methodDeclarations/contextuallyTypedClassExpressionMethodDeclaration02.ts create mode 100644 tests/cases/conformance/types/contextualTypes/methodDeclarations/contextuallyTypedObjectLiteralMethodDeclaration01.ts 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 From 22eef28cbdfc9a39851d456b619869ee2a908a3a Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Thu, 17 Sep 2015 14:17:23 -0700 Subject: [PATCH 06/23] forEach -> for-of, and other changes. --- .../importDefinitelyTypedTests.ts | 46 ++++++++++--------- 1 file changed, 25 insertions(+), 21 deletions(-) diff --git a/scripts/importDefinitelyTypedTests/importDefinitelyTypedTests.ts b/scripts/importDefinitelyTypedTests/importDefinitelyTypedTests.ts index fa935c2fa31..9e3f3183bc8 100644 --- a/scripts/importDefinitelyTypedTests/importDefinitelyTypedTests.ts +++ b/scripts/importDefinitelyTypedTests/importDefinitelyTypedTests.ts @@ -17,10 +17,12 @@ const tscPath = path.join(tscRoot, "built", "instrumented", "tsc.js"); const rwcTestPath = path.join(tscRoot, "tests", "cases", "rwc", "dt"); const definitelyTypedRoot = process.argv[2]; -function fileExtensionIs(path: string, extension: string): boolean { +importDefinitelyTypedTests(definitelyTypedRoot); + +function filePathEndsWith(path: string, endingString: string): boolean { const pathLen = path.length; - const extLen = extension.length; - return pathLen > extLen && path.substr(pathLen - extLen, extLen).toLocaleLowerCase() === extension.toLocaleLowerCase(); + const extLen = endingString.length; + return pathLen > extLen && path.substr(pathLen - extLen, extLen).toLocaleLowerCase() === endingString.toLocaleLowerCase(); } function copyFileSync(source: string, destination: string) { @@ -94,7 +96,7 @@ function importDefinitelyTypedTests(definitelyTypedRoot: string): void { .filter(i => i.indexOf("sipml") >=0 ) .filter(i => fs.statSync(path.join(definitelyTypedRoot, i)).isDirectory()) .forEach(d => { - let directoryPath = path.join(definitelyTypedRoot, d); + const directoryPath = path.join(definitelyTypedRoot, d); fs.readdir(directoryPath, function (err, files) { if (err) { throw err; @@ -104,35 +106,37 @@ function importDefinitelyTypedTests(definitelyTypedRoot: string): void { let testFiles: string[] = []; let paramFile: string; - files - .map(f => path.join(directoryPath, f)) - .forEach(f => { - if (fileExtensionIs(f, ".ts")) tsFiles.push(f); - else if (fileExtensionIs(f, ".tscparams")) paramFile = f; + for (const filePath of files.map(f => path.join(directoryPath, f))) { + if (filePathEndsWith(filePath, ".ts")) { + tsFiles.push(filePath); - if (fileExtensionIs(f, "-tests.ts")) testFiles.push(f); - }); + 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 let 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); - }); + if (tsFiles.length > 1 && tsFiles.every(t => filePathEndsWith(t, ".d.ts") && regexp.test(t))) { + for (const fileName of tsFiles) { + 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); - }); + for (const fileName of tsFiles) { + importDefinitelyTypedTest(path.basename(fileName, "-tests.ts"), [fileName], paramFile); + } } }); }) }); -} - -importDefinitelyTypedTests(definitelyTypedRoot); \ No newline at end of file +} \ No newline at end of file From 23af2a71639cd642422f4d2309a5ed7853675caa Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Thu, 17 Sep 2015 16:37:03 -0700 Subject: [PATCH 07/23] Improved command line interaction for 'importDefinitelyTypedTests' script. --- .../importDefinitelyTypedTests.ts | 43 +++++++++++++------ 1 file changed, 29 insertions(+), 14 deletions(-) diff --git a/scripts/importDefinitelyTypedTests/importDefinitelyTypedTests.ts b/scripts/importDefinitelyTypedTests/importDefinitelyTypedTests.ts index 9e3f3183bc8..5a9eb885b38 100644 --- a/scripts/importDefinitelyTypedTests/importDefinitelyTypedTests.ts +++ b/scripts/importDefinitelyTypedTests/importDefinitelyTypedTests.ts @@ -2,22 +2,37 @@ import * as fs from "fs"; import * as path from "path"; import * as child_process from "child_process"; + interface Map { [key: string]: T; } -declare const __dirname: string; -declare const process: { +declare var process: { argv: string[]; - env: Map + env: Map; + exit(exitCode?: number): void; } -const tscRoot = path.join(__dirname, "..\\"); -const tscPath = path.join(tscRoot, "built", "instrumented", "tsc.js"); -const rwcTestPath = path.join(tscRoot, "tests", "cases", "rwc", "dt"); -const definitelyTypedRoot = process.argv[2]; +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; + } -importDefinitelyTypedTests(definitelyTypedRoot); + const tscPath = path.resolve(tscRoot, "built", "local", "tsc.js"); + const rwcTestPath = path.resolve(tscRoot, "tests", "cases", "rwc", "dt"); + const resolvedDefinitelyTypedRoot = path.resolve(definitelyTypedRoot); + + console.log(`Resolved TypeScript Repo Root: '${tscRoot}'.`); + console.log(`Resolved DefinitelyTyped Repo Root: '${definitelyTypedRoot}'.`); + importDefinitelyTypedTests(tscPath, rwcTestPath, resolvedDefinitelyTypedRoot); +} function filePathEndsWith(path: string, endingString: string): boolean { const pathLen = path.length; @@ -27,10 +42,10 @@ function filePathEndsWith(path: string, endingString: string): boolean { function copyFileSync(source: string, destination: string) { let text = fs.readFileSync(source); - fs.writeFileSync(destination, text); + fs.writeFileSync(destination, text, {}); } -function importDefinitelyTypedTest(testCaseName: string, testFiles: string[], responseFile: string ) { +function importDefinitelyTypedTest(tscPath: string, rwcTestPath: string, testCaseName: string, testFiles: string[], responseFile: string ) { let cmd = "node " + tscPath + " --module commonjs " + testFiles.join(" "); if (responseFile) { cmd += " @" + responseFile; @@ -85,7 +100,7 @@ function importDefinitelyTypedTest(testCaseName: string, testFiles: string[], re }); } -function importDefinitelyTypedTests(definitelyTypedRoot: string): void { +function importDefinitelyTypedTests(tscPath: string, rwcTestPath: string, definitelyTypedRoot: string): void { fs.readdir(definitelyTypedRoot, (err, subDirectories) => { if (err) { throw err; @@ -124,16 +139,16 @@ function importDefinitelyTypedTests(definitelyTypedRoot: string): void { let 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(path.basename(fileName, ".d.ts"), [fileName], paramFile); + importDefinitelyTypedTest(tscPath, rwcTestPath, path.basename(fileName, ".d.ts"), [fileName], paramFile); } } else { - importDefinitelyTypedTest(d, tsFiles, paramFile); + importDefinitelyTypedTest(tscPath, rwcTestPath, d, tsFiles, paramFile); } } else { for (const fileName of tsFiles) { - importDefinitelyTypedTest(path.basename(fileName, "-tests.ts"), [fileName], paramFile); + importDefinitelyTypedTest(tscPath, rwcTestPath, path.basename(fileName, "-tests.ts"), [fileName], paramFile); } } }); From bf989aa56572663742626477f1bb463af07a74f6 Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Thu, 17 Sep 2015 17:26:10 -0700 Subject: [PATCH 08/23] Final touches on the script. --- .../importDefinitelyTypedTests.ts | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/scripts/importDefinitelyTypedTests/importDefinitelyTypedTests.ts b/scripts/importDefinitelyTypedTests/importDefinitelyTypedTests.ts index 5a9eb885b38..1e673c34d32 100644 --- a/scripts/importDefinitelyTypedTests/importDefinitelyTypedTests.ts +++ b/scripts/importDefinitelyTypedTests/importDefinitelyTypedTests.ts @@ -26,11 +26,12 @@ function main() { } const tscPath = path.resolve(tscRoot, "built", "local", "tsc.js"); - const rwcTestPath = path.resolve(tscRoot, "tests", "cases", "rwc", "dt"); + const rwcTestPath = path.resolve(tscRoot, "internal", "cases", "rwc"); const resolvedDefinitelyTypedRoot = path.resolve(definitelyTypedRoot); - console.log(`Resolved TypeScript Repo Root: '${tscRoot}'.`); - console.log(`Resolved DefinitelyTyped Repo Root: '${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); } @@ -42,7 +43,7 @@ function filePathEndsWith(path: string, endingString: string): boolean { function copyFileSync(source: string, destination: string) { let text = fs.readFileSync(source); - fs.writeFileSync(destination, text, {}); + fs.writeFileSync(destination, text); } function importDefinitelyTypedTest(tscPath: string, rwcTestPath: string, testCaseName: string, testFiles: string[], responseFile: string ) { @@ -108,7 +109,7 @@ function importDefinitelyTypedTests(tscPath: string, rwcTestPath: string, defini subDirectories .filter(d => ["_infrastructure", "node_modules", ".git"].indexOf(d) < 0) - .filter(i => i.indexOf("sipml") >=0 ) + // .filter(i => i.indexOf("sipml") >= 0 ) // Uncomment when you want to test :) .filter(i => fs.statSync(path.join(definitelyTypedRoot, i)).isDirectory()) .forEach(d => { const directoryPath = path.join(definitelyTypedRoot, d); From 925f0843d90956ea27fd3775bf3d1935ea5cf6d4 Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Thu, 17 Sep 2015 17:55:07 -0700 Subject: [PATCH 09/23] Add a jake task, .gitignore entry, and add tsd as a dev dependency. --- .gitignore | 3 ++- Jakefile.js | 21 +++++++++++++++++++++ package.json | 3 ++- 3 files changed, 25 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 58a45545939..9a513646e9c 100644 --- a/.gitignore +++ b/.gitignore @@ -28,7 +28,7 @@ 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 rwc-report.html *.swp @@ -45,6 +45,7 @@ scripts/run.bat scripts/word2md.js scripts/ior.js scripts/*.js.map +scripts/typings/ coverage/ internal/ **/.DS_Store diff --git a/Jakefile.js b/Jakefile.js index 77d81071e66..cdb03d7f778 100644 --- a/Jakefile.js +++ b/Jakefile.js @@ -386,6 +386,27 @@ 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(importDefinitelyTypedTestsJs); +file(importDefinitelyTypedTestsTs, ["tsd-scripts", importDefinitelyTypedTestsJs]) +task("importDefinitelyTyped", importDefinitelyTypedTestsTs, function () { + var cmd = "node " + 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); diff --git a/package.json b/package.json index b743b04838d..ba8edd188e4 100644 --- a/package.json +++ b/package.json @@ -35,7 +35,8 @@ "browserify": "latest", "istanbul": "latest", "mocha-fivemat-progress-reporter": "latest", - "tslint": "latest" + "tslint": "latest", + "tsd": "latest" }, "scripts": { "pretest": "jake tests", From 37ee17d40d5d04865963fb82ccfb809523d9e1b8 Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Thu, 17 Sep 2015 17:56:39 -0700 Subject: [PATCH 10/23] es3 -> es5. --- scripts/importDefinitelyTypedTests/tsconfig.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/importDefinitelyTypedTests/tsconfig.json b/scripts/importDefinitelyTypedTests/tsconfig.json index 3bf148ffa5c..dede4572531 100644 --- a/scripts/importDefinitelyTypedTests/tsconfig.json +++ b/scripts/importDefinitelyTypedTests/tsconfig.json @@ -1,7 +1,7 @@ { "compilerOptions": { "module": "commonjs", - "target": "es3", + "target": "ES5", "noImplicitAny": true, "outDir": "./", "rootDir": ".", From 55218d64a58a9964229daa0a38bdfb0a6be717e5 Mon Sep 17 00:00:00 2001 From: Punya Biswal Date: Fri, 18 Sep 2015 08:42:42 -0400 Subject: [PATCH 11/23] Fix capitalization of minimumintegerDigits --- lib/lib.d.ts | 4 ++-- lib/lib.dom.d.ts | 6 +++--- lib/lib.es6.d.ts | 4 ++-- lib/lib.webworker.d.ts | 6 +++--- src/lib/intl.d.ts | 4 ++-- 5 files changed, 12 insertions(+), 12 deletions(-) diff --git a/lib/lib.d.ts b/lib/lib.d.ts index d25e29bddb4..a65fc96e43f 100644 --- a/lib/lib.d.ts +++ b/lib/lib.d.ts @@ -3881,7 +3881,7 @@ declare module Intl { currency?: string; currencyDisplay?: string; useGrouping?: boolean; - minimumintegerDigits?: number; + minimumIntegerDigits?: number; minimumFractionDigits?: number; maximumFractionDigits?: number; minimumSignificantDigits?: number; @@ -3894,7 +3894,7 @@ declare module Intl { style: string; currency?: string; currencyDisplay?: string; - minimumintegerDigits: number; + minimumIntegerDigits: number; minimumFractionDigits: number; maximumFractionDigits: number; minimumSignificantDigits?: number; diff --git a/lib/lib.dom.d.ts b/lib/lib.dom.d.ts index 76e5f1b20a1..ac031db886b 100644 --- a/lib/lib.dom.d.ts +++ b/lib/lib.dom.d.ts @@ -57,7 +57,7 @@ declare module Intl { currency?: string; currencyDisplay?: string; useGrouping?: boolean; - minimumintegerDigits?: number; + minimumIntegerDigits?: number; minimumFractionDigits?: number; maximumFractionDigits?: number; minimumSignificantDigits?: number; @@ -70,7 +70,7 @@ declare module Intl { style: string; currency?: string; currencyDisplay?: string; - minimumintegerDigits: number; + minimumIntegerDigits: number; minimumFractionDigits: number; maximumFractionDigits: number; minimumSignificantDigits?: number; @@ -13192,4 +13192,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; \ No newline at end of file +declare function addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; diff --git a/lib/lib.es6.d.ts b/lib/lib.es6.d.ts index 507f0da5004..abced59c41a 100644 --- a/lib/lib.es6.d.ts +++ b/lib/lib.es6.d.ts @@ -5169,7 +5169,7 @@ declare module Intl { currency?: string; currencyDisplay?: string; useGrouping?: boolean; - minimumintegerDigits?: number; + minimumIntegerDigits?: number; minimumFractionDigits?: number; maximumFractionDigits?: number; minimumSignificantDigits?: number; @@ -5182,7 +5182,7 @@ declare module Intl { style: string; currency?: string; currencyDisplay?: string; - minimumintegerDigits: number; + minimumIntegerDigits: number; minimumFractionDigits: number; maximumFractionDigits: number; minimumSignificantDigits?: number; diff --git a/lib/lib.webworker.d.ts b/lib/lib.webworker.d.ts index 56e08ff6efc..b560065ef39 100644 --- a/lib/lib.webworker.d.ts +++ b/lib/lib.webworker.d.ts @@ -57,7 +57,7 @@ declare module Intl { currency?: string; currencyDisplay?: string; useGrouping?: boolean; - minimumintegerDigits?: number; + minimumIntegerDigits?: number; minimumFractionDigits?: number; maximumFractionDigits?: number; minimumSignificantDigits?: number; @@ -70,7 +70,7 @@ declare module Intl { style: string; currency?: string; currencyDisplay?: string; - minimumintegerDigits: number; + minimumIntegerDigits: number; minimumFractionDigits: number; maximumFractionDigits: number; minimumSignificantDigits?: number; @@ -1199,4 +1199,4 @@ declare function postMessage(data: any): void; declare var console: Console; declare function addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; declare function addEventListener(type: "message", listener: (ev: MessageEvent) => any, useCapture?: boolean): void; -declare function addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; \ No newline at end of file +declare function addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; diff --git a/src/lib/intl.d.ts b/src/lib/intl.d.ts index b5291306b87..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; From 3fa6b6de3aa9c656b7f9cd6edae933aa90e9a26a Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Thu, 17 Sep 2015 10:59:19 -0700 Subject: [PATCH 12/23] Accepted baselines, issue not apparent in compiler tests. --- ...ssExpressionMethodDeclaration01.errors.txt | 67 +++++++++ ...TypedClassExpressionMethodDeclaration01.js | 88 ++++++++++++ ...ssExpressionMethodDeclaration02.errors.txt | 71 ++++++++++ ...TypedClassExpressionMethodDeclaration02.js | 92 ++++++++++++ ...lyTypedObjectLiteralMethodDeclaration01.js | 79 +++++++++++ ...edObjectLiteralMethodDeclaration01.symbols | 110 +++++++++++++++ ...ypedObjectLiteralMethodDeclaration01.types | 132 ++++++++++++++++++ 7 files changed, 639 insertions(+) create mode 100644 tests/baselines/reference/contextuallyTypedClassExpressionMethodDeclaration01.errors.txt create mode 100644 tests/baselines/reference/contextuallyTypedClassExpressionMethodDeclaration01.js create mode 100644 tests/baselines/reference/contextuallyTypedClassExpressionMethodDeclaration02.errors.txt create mode 100644 tests/baselines/reference/contextuallyTypedClassExpressionMethodDeclaration02.js create mode 100644 tests/baselines/reference/contextuallyTypedObjectLiteralMethodDeclaration01.js create mode 100644 tests/baselines/reference/contextuallyTypedObjectLiteralMethodDeclaration01.symbols create mode 100644 tests/baselines/reference/contextuallyTypedObjectLiteralMethodDeclaration01.types 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 + } + } +} From 76da69c6c6d6b72f0a5f3949434a1474a593c781 Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Fri, 18 Sep 2015 10:56:40 -0700 Subject: [PATCH 13/23] Added failing fourslash test. --- ...edObjectLiteralMethodDeclarationParam01.ts | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 tests/cases/fourslash/contextuallyTypedObjectLiteralMethodDeclarationParam01.ts diff --git a/tests/cases/fourslash/contextuallyTypedObjectLiteralMethodDeclarationParam01.ts b/tests/cases/fourslash/contextuallyTypedObjectLiteralMethodDeclarationParam01.ts new file mode 100644 index 00000000000..6aabbbdbdce --- /dev/null +++ b/tests/cases/fourslash/contextuallyTypedObjectLiteralMethodDeclarationParam01.ts @@ -0,0 +1,32 @@ +/// + +// @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") From 2aa97bd1b94bcd1b655bbf3d063804961cb5c1d9 Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Fri, 18 Sep 2015 10:58:17 -0700 Subject: [PATCH 14/23] Use custom type guard. --- src/compiler/checker.ts | 8 ++++---- src/compiler/utilities.ts | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 80a04129eed..db6f2377a36 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -6907,7 +6907,7 @@ namespace ts { } } - function isFunctionExpressionOrArrowFunction(node: Node): boolean { + function isFunctionExpressionOrArrowFunction(node: Node): node is FunctionExpression { return node.kind === SyntaxKind.FunctionExpression || node.kind === SyntaxKind.ArrowFunction; } @@ -6926,8 +6926,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; } @@ -13656,7 +13656,7 @@ namespace ts { forEach(node.decorators, checkFunctionAndClassExpressionBodies); forEach((node).parameters, checkFunctionAndClassExpressionBodies); if (isObjectLiteralMethod(node)) { - checkFunctionExpressionOrObjectLiteralMethodBody(node); + checkFunctionExpressionOrObjectLiteralMethodBody(node); } break; case SyntaxKind.Constructor: diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index ed8b516b7f3..a1f2b53ecff 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -660,7 +660,7 @@ namespace ts { 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; } From 254af55204ebc18a8ea3576085350615c9adb0c8 Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Fri, 18 Sep 2015 12:19:29 -0700 Subject: [PATCH 15/23] Added missing predicate for contextual types of parameters. --- src/compiler/checker.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index db6f2377a36..2aee597092d 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -6574,8 +6574,8 @@ namespace ts { // 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) { From 5a2a7021fa8d9a72881c88c3b8128ab24a67a049 Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Fri, 18 Sep 2015 13:13:26 -0700 Subject: [PATCH 16/23] Fix jake task, style/const in script. --- Jakefile.js | 26 ++++++++++++------- .../importDefinitelyTypedTests.ts | 7 +++-- 2 files changed, 22 insertions(+), 11 deletions(-) diff --git a/Jakefile.js b/Jakefile.js index cdb03d7f778..72844e01cf0 100644 --- a/Jakefile.js +++ b/Jakefile.js @@ -206,6 +206,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 @@ -220,7 +223,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 @@ -257,7 +260,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"); @@ -328,7 +331,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 @@ -374,7 +377,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 }); @@ -399,13 +402,18 @@ var importDefinitelyTypedTestsDirectory = path.join(scriptsDirectory, "importDef var importDefinitelyTypedTestsJs = path.join(importDefinitelyTypedTestsDirectory, "importDefinitelyTypedTests.js"); var importDefinitelyTypedTestsTs = path.join(importDefinitelyTypedTestsDirectory, "importDefinitelyTypedTests.ts"); -file(importDefinitelyTypedTestsJs); -file(importDefinitelyTypedTestsTs, ["tsd-scripts", importDefinitelyTypedTestsJs]) -task("importDefinitelyTyped", importDefinitelyTypedTestsTs, function () { - var cmd = "node " + importDefinitelyTypedTestsJs + " ./ ../DefinitelyTyped"; +file(importDefinitelyTypedTestsTs); +file(importDefinitelyTypedTestsJs, ["tsd-scripts", importDefinitelyTypedTestsTs], function () { + var cmd = host + " " + LKGCompiler + " -p " + importDefinitelyTypedTestsDirectory; console.log(cmd); exec(cmd); -}, { async: true }) +}, { 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); diff --git a/scripts/importDefinitelyTypedTests/importDefinitelyTypedTests.ts b/scripts/importDefinitelyTypedTests/importDefinitelyTypedTests.ts index 1e673c34d32..1ae3725fff2 100644 --- a/scripts/importDefinitelyTypedTests/importDefinitelyTypedTests.ts +++ b/scripts/importDefinitelyTypedTests/importDefinitelyTypedTests.ts @@ -107,9 +107,12 @@ function importDefinitelyTypedTests(tscPath: string, rwcTestPath: string, defini 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 => i.indexOf("sipml") >= 0 ) // Uncomment when you want to test :) .filter(i => fs.statSync(path.join(definitelyTypedRoot, i)).isDirectory()) .forEach(d => { const directoryPath = path.join(definitelyTypedRoot, d); @@ -137,7 +140,7 @@ function importDefinitelyTypedTests(tscPath: string, rwcTestPath: string, defini if (testFiles.length === 0) { // no test files but multiple d.ts's, e.g. winjs - let regexp = new RegExp(d + "(([-][0-9])|([\.]d[\.]ts))"); + 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); From e4f0ebbb3ef354fbd156aa5f1663133b01149bc7 Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Sat, 19 Sep 2015 00:53:15 -0700 Subject: [PATCH 17/23] Fixed links to spec in the README. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index c474f62fb4c..e27e7a99fa7 100644 --- a/README.md +++ b/README.md @@ -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 From 921adc89e8f1e7aba506700d341e5b9580107889 Mon Sep 17 00:00:00 2001 From: jbondc Date: Sat, 19 Sep 2015 11:43:15 -0400 Subject: [PATCH 18/23] Utilities typos + missing reference --- src/compiler/utilities.ts | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index ed8b516b7f3..a92701f5b24 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -1,4 +1,5 @@ /// +/// /* @internal */ namespace ts { @@ -164,16 +165,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) { From 2e5b6fec7c0dcf39fdf31846787fdb50d957555a Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Sun, 20 Sep 2015 12:14:56 -0700 Subject: [PATCH 19/23] Add funcitonality to warn on duplicate codes. --- scripts/processDiagnosticMessages.ts | 41 ++++++++++++++++++++-------- 1 file changed, 29 insertions(+), 12 deletions(-) diff --git a/scripts/processDiagnosticMessages.ts b/scripts/processDiagnosticMessages.ts index 0a81b993616..e40f119b382 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,42 @@ 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[] = []; + + for (const currentMessage of messages) { + const code = diagnosticTable[currentMessage].code; + + if (code in originalMessageForCode) { + const originalMessage = originalMessageForCode[code]; + ts.sys.write("\x1b[93m"); // High intensity yellow. + ts.sys.write("Warning"); + 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); + } + else { + originalMessageForCode[code] = currentMessage; + } + } +} + +function buildUniqueNameMap(names: string[]): ts.Map { + var nameMap: ts.Map = {}; var uniqueNames = NameGenerator.ensureUniqueness(names, /* isCaseSensitive */ false, /* isFixed */ undefined); @@ -50,7 +67,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 +189,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) { From 942ca46637e069f1fa59a6cfdf1247b41cf1a310 Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Sun, 20 Sep 2015 12:16:56 -0700 Subject: [PATCH 20/23] Fixed duplicate diagnostic codes. --- .../diagnosticInformationMap.generated.ts | 12 ++--- src/compiler/diagnosticMessages.json | 47 +++++++++---------- 2 files changed, 29 insertions(+), 30 deletions(-) diff --git a/src/compiler/diagnosticInformationMap.generated.ts b/src/compiler/diagnosticInformationMap.generated.ts index 37989c3433a..e083acd4338 100644 --- a/src/compiler/diagnosticInformationMap.generated.ts +++ b/src/compiler/diagnosticInformationMap.generated.ts @@ -140,7 +140,7 @@ namespace ts { 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." }, + An_implementation_cannot_be_declared_in_ambient_contexts: { code: 1183, 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." }, @@ -190,10 +190,6 @@ namespace ts { 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." }, @@ -204,6 +200,10 @@ namespace ts { _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." }, + Experimental_support_for_async_functions_is_a_feature_that_is_subject_to_change_in_a_future_release_Specify_experimentalAsyncFunctions_to_remove_this_warning: { code: 1246, 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." }, 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." }, @@ -516,7 +516,7 @@ namespace ts { 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." }, Option_0_cannot_be_specified_without_specifying_option_1: { code: 5052, category: DiagnosticCategory.Error, key: "Option '{0}' cannot be specified without specifying option '{1}'." }, Option_0_cannot_be_specified_with_option_1: { code: 5053, category: DiagnosticCategory.Error, key: "Option '{0}' cannot be specified with option '{1}'." }, - A_tsconfig_json_file_is_already_defined_at_Colon_0: { code: 5053, category: DiagnosticCategory.Error, key: "A 'tsconfig.json' file is already defined at: '{0}'." }, + A_tsconfig_json_file_is_already_defined_at_Colon_0: { code: 5054, category: DiagnosticCategory.Error, key: "A 'tsconfig.json' file is already defined at: '{0}'." }, 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." }, diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index c1657a81bab..e6ece87b5a9 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -549,7 +549,7 @@ }, "An implementation cannot be declared in ambient contexts.": { "category": "Error", - "code": 1184 + "code": 1183 }, "Modifiers cannot appear here.": { "category": "Error", @@ -747,24 +747,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 +787,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 @@ -1700,11 +1699,11 @@ "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 @@ -1712,11 +1711,11 @@ "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 @@ -2055,7 +2054,7 @@ }, "A 'tsconfig.json' file is already defined at: '{0}'.": { "category": "Error", - "code": 5053 + "code": 5054 }, "Concatenate and emit output to single file.": { From b265467ce7974b575d7825492b8712a714129d50 Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Sun, 20 Sep 2015 12:26:28 -0700 Subject: [PATCH 21/23] Accepted baselines. --- .../reference/ambientErrors.errors.txt | 20 +- .../classAbstractDeclarations.d.errors.txt | 4 +- .../constructorOverloads6.errors.txt | 4 +- .../reference/exportDeclareClass1.errors.txt | 8 +- .../reference/externSyntax.errors.txt | 4 +- ...functionsWithModifiersInBlocks1.errors.txt | 8 +- tests/baselines/reference/giant.errors.txt | 216 +++++++++--------- .../initializersInDeclarations.errors.txt | 4 +- .../methodInAmbientClass1.errors.txt | 4 +- .../parserClassDeclaration18.errors.txt | 4 +- .../parserConstructorDeclaration4.errors.txt | 4 +- .../parserFunctionDeclaration2.d.errors.txt | 4 +- .../parserFunctionDeclaration2.errors.txt | 4 +- ...arserMemberFunctionDeclaration5.errors.txt | 4 +- 14 files changed, 146 insertions(+), 146 deletions(-) diff --git a/tests/baselines/reference/ambientErrors.errors.txt b/tests/baselines/reference/ambientErrors.errors.txt index 16ce79a05dd..578bd44c8ec 100644 --- a/tests/baselines/reference/ambientErrors.errors.txt +++ b/tests/baselines/reference/ambientErrors.errors.txt @@ -1,16 +1,16 @@ 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(20,24): error TS1183: 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(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(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. 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. @@ -44,7 +44,7 @@ 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 { @@ -67,7 +67,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 +77,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. } } 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/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/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/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/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/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/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/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/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/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/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 From 962ba8288bc44a59cdc99c5f67093353b0d8cc9b Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Sun, 20 Sep 2015 12:41:28 -0700 Subject: [PATCH 22/23] Conflicts should cause errors instead of warnings. --- scripts/processDiagnosticMessages.ts | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/scripts/processDiagnosticMessages.ts b/scripts/processDiagnosticMessages.ts index e40f119b382..1eead82d9fe 100644 --- a/scripts/processDiagnosticMessages.ts +++ b/scripts/processDiagnosticMessages.ts @@ -37,22 +37,29 @@ function main(): void { 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[93m"); // High intensity yellow. - ts.sys.write("Warning"); + 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 { From c5a85c761f873c5b3a1890e51f52d960a78fc906 Mon Sep 17 00:00:00 2001 From: Mohamed Hegazy Date: Mon, 21 Sep 2015 02:06:36 -0700 Subject: [PATCH 23/23] Update LKG --- lib/lib.core.es6.d.ts | 29 +++++++- lib/lib.dom.d.ts | 2 +- lib/lib.es6.d.ts | 29 +++++++- lib/lib.webworker.d.ts | 2 +- lib/tsc.js | 149 +++----------------------------------- lib/tsserver.js | 15 +++- lib/typescript.js | 26 ++++--- lib/typescriptServices.js | 26 ++++--- 8 files changed, 114 insertions(+), 164 deletions(-) diff --git a/lib/lib.core.es6.d.ts b/lib/lib.core.es6.d.ts index fd115497f8a..6d6a68559f8 100644 --- a/lib/lib.core.es6.d.ts +++ b/lib/lib.core.es6.d.ts @@ -3965,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; diff --git a/lib/lib.dom.d.ts b/lib/lib.dom.d.ts index ac031db886b..849560ac0d2 100644 --- a/lib/lib.dom.d.ts +++ b/lib/lib.dom.d.ts @@ -13192,4 +13192,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/lib/lib.es6.d.ts b/lib/lib.es6.d.ts index abced59c41a..75ba647a128 100644 --- a/lib/lib.es6.d.ts +++ b/lib/lib.es6.d.ts @@ -3965,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; diff --git a/lib/lib.webworker.d.ts b/lib/lib.webworker.d.ts index b560065ef39..85bcfb1498e 100644 --- a/lib/lib.webworker.d.ts +++ b/lib/lib.webworker.d.ts @@ -1199,4 +1199,4 @@ declare function postMessage(data: any): void; declare var console: Console; declare function addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; declare function addEventListener(type: "message", listener: (ev: MessageEvent) => any, useCapture?: boolean): void; -declare function addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +declare function addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; \ No newline at end of file diff --git a/lib/tsc.js b/lib/tsc.js index 3983b8c1e1b..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) { @@ -569,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) { @@ -731,7 +727,6 @@ var ts; Debug.fail = fail; })(Debug = ts.Debug || (ts.Debug = {})); })(ts || (ts = {})); -/// var ts; (function (ts) { ts.sys = (function () { @@ -1003,7 +998,6 @@ var ts; } })(); })(ts || (ts = {})); -/// var ts; (function (ts) { ts.Diagnostics = { @@ -1624,8 +1618,6 @@ var ts; 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) { @@ -1879,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 || @@ -2990,7 +2972,6 @@ var ts; } ts.createScanner = createScanner; })(ts || (ts = {})); -/// var ts; (function (ts) { ts.bindTime = 0; @@ -3704,7 +3685,6 @@ var ts; } } })(ts || (ts = {})); -/// var ts; (function (ts) { function getDeclarationOfKind(symbol, kind) { @@ -5653,8 +5633,6 @@ var ts; } ts.getTypeParameterOwner = getTypeParameterOwner; })(ts || (ts = {})); -/// -/// var ts; (function (ts) { var nodeConstructors = new Array(270); @@ -6145,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; @@ -7480,9 +7454,6 @@ var ts; return allowInAnd(parseExpression); } function parseExpression() { - // Expression[in]: - // AssignmentExpression[in] - // Expression[in] , AssignmentExpression[in] var saveDecoratorContext = inDecoratorContext(); if (saveDecoratorContext) { setDecoratorContext(false); @@ -7507,15 +7478,6 @@ var ts; 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(); } @@ -8484,8 +8446,6 @@ var ts; return finishNode(node); } function parseThrowStatement() { - // ThrowStatement[Yield] : - // throw [no LineTerminator here]Expression[In, ?Yield]; var node = createNode(206); parseExpected(96); node.expression = scanner.hasPrecedingLineBreak() ? undefined : allowInAnd(parseExpression); @@ -9097,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); } @@ -9265,12 +9223,6 @@ var ts; return finishNode(importDeclaration); } function parseImportClause(identifier, fullStart) { - // ImportClause: - // ImportedDefaultBinding - // NameSpaceImport - // NamedImports - // ImportedDefaultBinding, NameSpaceImport - // ImportedDefaultBinding, NamedImports var importClause = createNode(221, fullStart); if (identifier) { importClause.name = identifier; @@ -10227,7 +10179,6 @@ var ts; } })(IncrementalParser || (IncrementalParser = {})); })(ts || (ts = {})); -/// var ts; (function (ts) { var nextSymbolId = 1; @@ -15562,8 +15513,8 @@ var ts; } } 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) { @@ -18126,10 +18077,6 @@ 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); @@ -18772,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; } @@ -19123,9 +19061,6 @@ var ts; } } 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; } @@ -19801,19 +19736,6 @@ var ts; 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]; @@ -22347,7 +22269,6 @@ var ts; } ts.createTypeChecker = createTypeChecker; })(ts || (ts = {})); -/// var ts; (function (ts) { function getDeclarationDiagnostics(host, resolver, targetSourceFile) { @@ -23675,8 +23596,6 @@ var ts; } ts.writeDeclarationFile = writeDeclarationFile; })(ts || (ts = {})); -/// -/// var ts; (function (ts) { function isExternalModuleOrDeclarationFile(sourceFile) { @@ -24416,19 +24335,6 @@ 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; } @@ -24775,8 +24681,15 @@ var ts; } 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; } } @@ -25769,26 +25682,6 @@ var ts; 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(84, node.pos); write(" "); endPos = emitToken(17, endPos); @@ -28519,17 +28412,6 @@ var ts; 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 = []; @@ -29441,9 +29323,6 @@ var ts; "diams": 0x2666 }; })(ts || (ts = {})); -/// -/// -/// var ts; (function (ts) { ts.programTime = 0; @@ -30288,10 +30167,6 @@ var ts; } ts.createProgram = createProgram; })(ts || (ts = {})); -/// -/// -/// -/// var ts; (function (ts) { ts.optionDeclarations = [ @@ -30750,8 +30625,6 @@ var ts; } ts.parseConfigFile = parseConfigFile; })(ts || (ts = {})); -/// -/// var ts; (function (ts) { function validateLocaleAndSetLanguage(locale, errors) { diff --git a/lib/tsserver.js b/lib/tsserver.js index 875e63028b2..82199e1222d 100644 --- a/lib/tsserver.js +++ b/lib/tsserver.js @@ -15971,8 +15971,8 @@ var ts; } } 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) { @@ -25139,8 +25139,15 @@ var ts; } 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; } } diff --git a/lib/typescript.js b/lib/typescript.js index 2c70f56d0a6..a1f9651570e 100644 --- a/lib/typescript.js +++ b/lib/typescript.js @@ -4954,6 +4954,7 @@ var ts; } })(ts || (ts = {})); /// +/// /* @internal */ var ts; (function (ts) { @@ -5083,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) { @@ -18922,8 +18923,8 @@ var ts; } // 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) { @@ -29868,8 +29869,15 @@ var ts; 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; } } diff --git a/lib/typescriptServices.js b/lib/typescriptServices.js index 2c70f56d0a6..a1f9651570e 100644 --- a/lib/typescriptServices.js +++ b/lib/typescriptServices.js @@ -4954,6 +4954,7 @@ var ts; } })(ts || (ts = {})); /// +/// /* @internal */ var ts; (function (ts) { @@ -5083,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) { @@ -18922,8 +18923,8 @@ var ts; } // 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) { @@ -29868,8 +29869,15 @@ var ts; 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; } }