From 53f6755907f04a116cba5e691fc8ac15d89e36e2 Mon Sep 17 00:00:00 2001 From: Mohamed Hegazy Date: Tue, 17 May 2016 17:14:51 -0700 Subject: [PATCH 1/7] Add error message if module is not specified and a file contains a module indicator --- src/compiler/diagnosticMessages.json | 7 +- src/compiler/program.ts | 10 ++- ...duleConcatUnspecifiedModuleKind.errors.txt | 11 +++ .../outModuleConcatUnspecifiedModuleKind.js | 11 +++ .../typeReferenceDirectives11.errors.txt | 18 +++++ .../typeReferenceDirectives11.symbols | 23 ------ .../reference/typeReferenceDirectives11.types | 26 ------- .../typeReferenceDirectives12.errors.txt | 37 ++++++++++ .../typeReferenceDirectives12.symbols | 68 ----------------- .../reference/typeReferenceDirectives12.types | 73 ------------------- .../outModuleConcatUnspecifiedModuleKind.ts | 8 ++ 11 files changed, 99 insertions(+), 193 deletions(-) create mode 100644 tests/baselines/reference/outModuleConcatUnspecifiedModuleKind.errors.txt create mode 100644 tests/baselines/reference/outModuleConcatUnspecifiedModuleKind.js create mode 100644 tests/baselines/reference/typeReferenceDirectives11.errors.txt delete mode 100644 tests/baselines/reference/typeReferenceDirectives11.symbols delete mode 100644 tests/baselines/reference/typeReferenceDirectives11.types create mode 100644 tests/baselines/reference/typeReferenceDirectives12.errors.txt delete mode 100644 tests/baselines/reference/typeReferenceDirectives12.symbols delete mode 100644 tests/baselines/reference/typeReferenceDirectives12.types create mode 100644 tests/cases/compiler/outModuleConcatUnspecifiedModuleKind.ts diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index 899b4292f04..710981fc196 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -2751,7 +2751,12 @@ "Resolving real path for '{0}', result '{1}'": { "category": "Message", "code": 6130 - }, + }, + "Cannot compile modules using option '{0}' unless the '--module' flag is provided with a valid module type.": { + "category": "Error", + "code": 6131 + }, + "Variable '{0}' implicitly has an '{1}' type.": { "category": "Error", "code": 7005 diff --git a/src/compiler/program.ts b/src/compiler/program.ts index 52547cb165d..4f9b82c9c6d 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -2089,8 +2089,14 @@ namespace ts { } // Cannot specify module gen that isn't amd or system with --out - if (outFile && options.module && !(options.module === ModuleKind.AMD || options.module === ModuleKind.System)) { - programDiagnostics.add(createCompilerDiagnostic(Diagnostics.Only_amd_and_system_modules_are_supported_alongside_0, options.out ? "out" : "outFile")); + if (outFile) { + if (options.module && !(options.module === ModuleKind.AMD || options.module === ModuleKind.System)) { + programDiagnostics.add(createCompilerDiagnostic(Diagnostics.Only_amd_and_system_modules_are_supported_alongside_0, options.out ? "out" : "outFile")); + } + else if (options.module === undefined && firstExternalModuleSourceFile) { + const span = getErrorSpanForNode(firstExternalModuleSourceFile, firstExternalModuleSourceFile.externalModuleIndicator); + programDiagnostics.add(createFileDiagnostic(firstExternalModuleSourceFile, span.start, span.length, Diagnostics.Cannot_compile_modules_using_option_0_unless_the_module_flag_is_provided_with_a_valid_module_type, options.out ? "out" : "outFile")); + } } // there has to be common source directory if user specified --outdir || --sourceRoot diff --git a/tests/baselines/reference/outModuleConcatUnspecifiedModuleKind.errors.txt b/tests/baselines/reference/outModuleConcatUnspecifiedModuleKind.errors.txt new file mode 100644 index 00000000000..f0613367140 --- /dev/null +++ b/tests/baselines/reference/outModuleConcatUnspecifiedModuleKind.errors.txt @@ -0,0 +1,11 @@ +tests/cases/compiler/a.ts(2,14): error TS6131: Cannot compile modules using option 'outFile' unless the '--module' flag is provided with a valid module type. + + +==== tests/cases/compiler/a.ts (1 errors) ==== + + export class A { } // module + ~ +!!! error TS6131: Cannot compile modules using option 'outFile' unless the '--module' flag is provided with a valid module type. + +==== tests/cases/compiler/b.ts (0 errors) ==== + var x = 0; // global \ No newline at end of file diff --git a/tests/baselines/reference/outModuleConcatUnspecifiedModuleKind.js b/tests/baselines/reference/outModuleConcatUnspecifiedModuleKind.js new file mode 100644 index 00000000000..48548400f7f --- /dev/null +++ b/tests/baselines/reference/outModuleConcatUnspecifiedModuleKind.js @@ -0,0 +1,11 @@ +//// [tests/cases/compiler/outModuleConcatUnspecifiedModuleKind.ts] //// + +//// [a.ts] + +export class A { } // module + +//// [b.ts] +var x = 0; // global + +//// [out.js] +var x = 0; // global diff --git a/tests/baselines/reference/typeReferenceDirectives11.errors.txt b/tests/baselines/reference/typeReferenceDirectives11.errors.txt new file mode 100644 index 00000000000..b19efcebb90 --- /dev/null +++ b/tests/baselines/reference/typeReferenceDirectives11.errors.txt @@ -0,0 +1,18 @@ +/mod1.ts(2,17): error TS6131: Cannot compile modules using option 'out' unless the '--module' flag is provided with a valid module type. + + +==== /mod2.ts (0 errors) ==== + + import {foo} from "./mod1"; + export const bar = foo(); +==== /types/lib/index.d.ts (0 errors) ==== + + + interface Lib { x } + +==== /mod1.ts (1 errors) ==== + + export function foo(): Lib { return {x: 1} } + ~~~ +!!! error TS6131: Cannot compile modules using option 'out' unless the '--module' flag is provided with a valid module type. + \ No newline at end of file diff --git a/tests/baselines/reference/typeReferenceDirectives11.symbols b/tests/baselines/reference/typeReferenceDirectives11.symbols deleted file mode 100644 index 875bb2a0900..00000000000 --- a/tests/baselines/reference/typeReferenceDirectives11.symbols +++ /dev/null @@ -1,23 +0,0 @@ -=== /mod2.ts === - -import {foo} from "./mod1"; ->foo : Symbol(foo, Decl(mod2.ts, 1, 8)) - -export const bar = foo(); ->bar : Symbol(bar, Decl(mod2.ts, 2, 12)) ->foo : Symbol(foo, Decl(mod2.ts, 1, 8)) - -=== /types/lib/index.d.ts === - - -interface Lib { x } ->Lib : Symbol(Lib, Decl(index.d.ts, 0, 0)) ->x : Symbol(Lib.x, Decl(index.d.ts, 2, 15)) - -=== /mod1.ts === - -export function foo(): Lib { return {x: 1} } ->foo : Symbol(foo, Decl(mod1.ts, 0, 0)) ->Lib : Symbol(Lib, Decl(index.d.ts, 0, 0)) ->x : Symbol(x, Decl(mod1.ts, 1, 37)) - diff --git a/tests/baselines/reference/typeReferenceDirectives11.types b/tests/baselines/reference/typeReferenceDirectives11.types deleted file mode 100644 index 93d80b7988a..00000000000 --- a/tests/baselines/reference/typeReferenceDirectives11.types +++ /dev/null @@ -1,26 +0,0 @@ -=== /mod2.ts === - -import {foo} from "./mod1"; ->foo : () => Lib - -export const bar = foo(); ->bar : Lib ->foo() : Lib ->foo : () => Lib - -=== /types/lib/index.d.ts === - - -interface Lib { x } ->Lib : Lib ->x : any - -=== /mod1.ts === - -export function foo(): Lib { return {x: 1} } ->foo : () => Lib ->Lib : Lib ->{x: 1} : { x: number; } ->x : number ->1 : number - diff --git a/tests/baselines/reference/typeReferenceDirectives12.errors.txt b/tests/baselines/reference/typeReferenceDirectives12.errors.txt new file mode 100644 index 00000000000..8eee7c04ee3 --- /dev/null +++ b/tests/baselines/reference/typeReferenceDirectives12.errors.txt @@ -0,0 +1,37 @@ +/main.ts(1,14): error TS6131: Cannot compile modules using option 'out' unless the '--module' flag is provided with a valid module type. + + +==== /mod2.ts (0 errors) ==== + import { Cls } from "./main"; + import "./mod1"; + + export const cls = Cls; + export const foo = new Cls().foo(); + export const bar = Cls.bar(); +==== /types/lib/index.d.ts (0 errors) ==== + + + interface Lib { x } + +==== /main.ts (1 errors) ==== + export class Cls { + ~~~ +!!! error TS6131: Cannot compile modules using option 'out' unless the '--module' flag is provided with a valid module type. + x + } + +==== /mod1.ts (0 errors) ==== + /// + + import {Cls} from "./main"; + Cls.prototype.foo = function() { return undefined; } + + declare module "./main" { + interface Cls { + foo(): Lib; + } + namespace Cls { + function bar(): Lib; + } + } + \ No newline at end of file diff --git a/tests/baselines/reference/typeReferenceDirectives12.symbols b/tests/baselines/reference/typeReferenceDirectives12.symbols deleted file mode 100644 index 30b24c39284..00000000000 --- a/tests/baselines/reference/typeReferenceDirectives12.symbols +++ /dev/null @@ -1,68 +0,0 @@ -=== /mod2.ts === -import { Cls } from "./main"; ->Cls : Symbol(Cls, Decl(mod2.ts, 0, 8)) - -import "./mod1"; - -export const cls = Cls; ->cls : Symbol(cls, Decl(mod2.ts, 3, 12)) ->Cls : Symbol(Cls, Decl(mod2.ts, 0, 8)) - -export const foo = new Cls().foo(); ->foo : Symbol(foo, Decl(mod2.ts, 4, 12)) ->new Cls().foo : Symbol(Cls.foo, Decl(mod1.ts, 6, 19)) ->Cls : Symbol(Cls, Decl(mod2.ts, 0, 8)) ->foo : Symbol(Cls.foo, Decl(mod1.ts, 6, 19)) - -export const bar = Cls.bar(); ->bar : Symbol(bar, Decl(mod2.ts, 5, 12)) ->Cls.bar : Symbol(Cls.bar, Decl(mod1.ts, 9, 19)) ->Cls : Symbol(Cls, Decl(mod2.ts, 0, 8)) ->bar : Symbol(Cls.bar, Decl(mod1.ts, 9, 19)) - -=== /types/lib/index.d.ts === - - -interface Lib { x } ->Lib : Symbol(Lib, Decl(index.d.ts, 0, 0)) ->x : Symbol(Lib.x, Decl(index.d.ts, 2, 15)) - -=== /main.ts === -export class Cls { ->Cls : Symbol(Cls, Decl(main.ts, 0, 0), Decl(mod1.ts, 5, 25), Decl(mod1.ts, 8, 5)) - - x ->x : Symbol(Cls.x, Decl(main.ts, 0, 18)) -} - -=== /mod1.ts === -/// - -import {Cls} from "./main"; ->Cls : Symbol(Cls, Decl(mod1.ts, 2, 8)) - -Cls.prototype.foo = function() { return undefined; } ->Cls.prototype.foo : Symbol(Cls.foo, Decl(mod1.ts, 6, 19)) ->Cls.prototype : Symbol(Cls.prototype) ->Cls : Symbol(Cls, Decl(mod1.ts, 2, 8)) ->prototype : Symbol(Cls.prototype) ->foo : Symbol(Cls.foo, Decl(mod1.ts, 6, 19)) ->undefined : Symbol(undefined) - -declare module "./main" { - interface Cls { ->Cls : Symbol(Cls, Decl(main.ts, 0, 0), Decl(mod1.ts, 5, 25), Decl(mod1.ts, 8, 5)) - - foo(): Lib; ->foo : Symbol(Cls.foo, Decl(mod1.ts, 6, 19)) ->Lib : Symbol(Lib, Decl(index.d.ts, 0, 0)) - } - namespace Cls { ->Cls : Symbol(Cls, Decl(main.ts, 0, 0), Decl(mod1.ts, 5, 25), Decl(mod1.ts, 8, 5)) - - function bar(): Lib; ->bar : Symbol(bar, Decl(mod1.ts, 9, 19)) ->Lib : Symbol(Lib, Decl(index.d.ts, 0, 0)) - } -} - diff --git a/tests/baselines/reference/typeReferenceDirectives12.types b/tests/baselines/reference/typeReferenceDirectives12.types deleted file mode 100644 index bd429b91f1c..00000000000 --- a/tests/baselines/reference/typeReferenceDirectives12.types +++ /dev/null @@ -1,73 +0,0 @@ -=== /mod2.ts === -import { Cls } from "./main"; ->Cls : typeof Cls - -import "./mod1"; - -export const cls = Cls; ->cls : typeof Cls ->Cls : typeof Cls - -export const foo = new Cls().foo(); ->foo : Lib ->new Cls().foo() : Lib ->new Cls().foo : () => Lib ->new Cls() : Cls ->Cls : typeof Cls ->foo : () => Lib - -export const bar = Cls.bar(); ->bar : Lib ->Cls.bar() : Lib ->Cls.bar : () => Lib ->Cls : typeof Cls ->bar : () => Lib - -=== /types/lib/index.d.ts === - - -interface Lib { x } ->Lib : Lib ->x : any - -=== /main.ts === -export class Cls { ->Cls : Cls - - x ->x : any -} - -=== /mod1.ts === -/// - -import {Cls} from "./main"; ->Cls : typeof Cls - -Cls.prototype.foo = function() { return undefined; } ->Cls.prototype.foo = function() { return undefined; } : () => any ->Cls.prototype.foo : () => Lib ->Cls.prototype : Cls ->Cls : typeof Cls ->prototype : Cls ->foo : () => Lib ->function() { return undefined; } : () => any ->undefined : undefined - -declare module "./main" { - interface Cls { ->Cls : Cls - - foo(): Lib; ->foo : () => Lib ->Lib : Lib - } - namespace Cls { ->Cls : typeof Cls - - function bar(): Lib; ->bar : () => Lib ->Lib : Lib - } -} - diff --git a/tests/cases/compiler/outModuleConcatUnspecifiedModuleKind.ts b/tests/cases/compiler/outModuleConcatUnspecifiedModuleKind.ts new file mode 100644 index 00000000000..976a47e2f78 --- /dev/null +++ b/tests/cases/compiler/outModuleConcatUnspecifiedModuleKind.ts @@ -0,0 +1,8 @@ +// @target: ES5 +// @outFile: out.js + +// @Filename: a.ts +export class A { } // module + +// @Filename: b.ts +var x = 0; // global \ No newline at end of file From 02f0065c956e78cbfabfec5f30a2e2b6e9e77951 Mon Sep 17 00:00:00 2001 From: Mohamed Hegazy Date: Tue, 17 May 2016 17:15:06 -0700 Subject: [PATCH 2/7] Update error message --- src/compiler/diagnosticMessages.json | 2 +- src/compiler/program.ts | 2 +- tests/baselines/reference/isolatedModulesOut.errors.txt | 5 ++++- tests/baselines/reference/moduleNoneErrors.errors.txt | 4 ++-- 4 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index 710981fc196..8e1ff8a5d6d 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -447,7 +447,7 @@ "category": "Error", "code": 1147 }, - "Cannot compile modules unless the '--module' flag is provided with a valid module type. Consider setting the 'module' compiler option in a 'tsconfig.json' file.": { + "Cannot use 'import', 'export' or module augmentation when compiling with '--module' is 'none'.": { "category": "Error", "code": 1148 }, diff --git a/src/compiler/program.ts b/src/compiler/program.ts index 4f9b82c9c6d..68f2663e51f 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -2080,7 +2080,7 @@ namespace ts { else if (firstExternalModuleSourceFile && languageVersion < ScriptTarget.ES6 && options.module === ModuleKind.None) { // We cannot use createDiagnosticFromNode because nodes do not have parents yet const span = getErrorSpanForNode(firstExternalModuleSourceFile, firstExternalModuleSourceFile.externalModuleIndicator); - programDiagnostics.add(createFileDiagnostic(firstExternalModuleSourceFile, span.start, span.length, Diagnostics.Cannot_compile_modules_unless_the_module_flag_is_provided_with_a_valid_module_type_Consider_setting_the_module_compiler_option_in_a_tsconfig_json_file)); + programDiagnostics.add(createFileDiagnostic(firstExternalModuleSourceFile, span.start, span.length, Diagnostics.Cannot_use_import_export_or_module_augmentation_when_compiling_with_module_is_none)); } // Cannot specify module gen target of es6 when below es6 diff --git a/tests/baselines/reference/isolatedModulesOut.errors.txt b/tests/baselines/reference/isolatedModulesOut.errors.txt index 7d16ac94666..9453c00a83c 100644 --- a/tests/baselines/reference/isolatedModulesOut.errors.txt +++ b/tests/baselines/reference/isolatedModulesOut.errors.txt @@ -1,11 +1,14 @@ error TS5053: Option 'out' cannot be specified with option 'isolatedModules'. +tests/cases/compiler/file1.ts(2,1): error TS6131: Cannot compile modules using option 'out' unless the '--module' flag is provided with a valid module type. tests/cases/compiler/file2.ts(1,1): error TS1208: Cannot compile namespaces when the '--isolatedModules' flag is provided. !!! error TS5053: Option 'out' cannot be specified with option 'isolatedModules'. -==== tests/cases/compiler/file1.ts (0 errors) ==== +==== tests/cases/compiler/file1.ts (1 errors) ==== export var x; + ~~~~~~~~~~~~~ +!!! error TS6131: Cannot compile modules using option 'out' unless the '--module' flag is provided with a valid module type. ==== tests/cases/compiler/file2.ts (1 errors) ==== var y; ~~~ diff --git a/tests/baselines/reference/moduleNoneErrors.errors.txt b/tests/baselines/reference/moduleNoneErrors.errors.txt index cb943050fa8..1f1118c9916 100644 --- a/tests/baselines/reference/moduleNoneErrors.errors.txt +++ b/tests/baselines/reference/moduleNoneErrors.errors.txt @@ -1,10 +1,10 @@ -tests/cases/compiler/a.ts(1,14): error TS1148: Cannot compile modules unless the '--module' flag is provided with a valid module type. Consider setting the 'module' compiler option in a 'tsconfig.json' file. +tests/cases/compiler/a.ts(1,14): error TS1148: Cannot use 'import', 'export' or module augmentation when compiling with '--module' is 'none'. ==== tests/cases/compiler/a.ts (1 errors) ==== export class Foo { ~~~ -!!! error TS1148: Cannot compile modules unless the '--module' flag is provided with a valid module type. Consider setting the 'module' compiler option in a 'tsconfig.json' file. +!!! error TS1148: Cannot use 'import', 'export' or module augmentation when compiling with '--module' is 'none'. foo: string; } \ No newline at end of file From 08fed17053d490e7a7990cd84e1ed3070d68bc4c Mon Sep 17 00:00:00 2001 From: Mohamed Hegazy Date: Tue, 17 May 2016 17:15:31 -0700 Subject: [PATCH 3/7] Fix getOccurances not picking up hte right file because of casing --- src/services/services.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/services/services.ts b/src/services/services.ts index e089f6e1764..dde5df7cd73 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -4942,8 +4942,7 @@ namespace ts { function getDocumentHighlights(fileName: string, position: number, filesToSearch: string[]): DocumentHighlights[] { synchronizeHostData(); - filesToSearch = map(filesToSearch, normalizeSlashes); - const sourceFilesToSearch = filter(program.getSourceFiles(), f => contains(filesToSearch, f.fileName)); + const sourceFilesToSearch = map(filesToSearch, f => program.getSourceFile(f)); const sourceFile = getValidSourceFile(fileName); const node = getTouchingWord(sourceFile, position); From d73dd06e4bbfa697830e3fa253fbe512c3a2fd58 Mon Sep 17 00:00:00 2001 From: Mohamed Hegazy Date: Wed, 18 May 2016 16:37:14 -0700 Subject: [PATCH 4/7] Respond to code review comments --- src/compiler/diagnosticMessages.json | 4 ++-- src/compiler/program.ts | 4 ++-- tests/baselines/reference/isolatedModulesOut.errors.txt | 4 ++-- tests/baselines/reference/moduleNoneErrors.errors.txt | 4 ++-- .../reference/outModuleConcatUnspecifiedModuleKind.errors.txt | 4 ++-- .../baselines/reference/typeReferenceDirectives11.errors.txt | 4 ++-- .../baselines/reference/typeReferenceDirectives12.errors.txt | 4 ++-- 7 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index 8e1ff8a5d6d..c3ef03a9f34 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -447,7 +447,7 @@ "category": "Error", "code": 1147 }, - "Cannot use 'import', 'export' or module augmentation when compiling with '--module' is 'none'.": { + "Cannot use imports, exports or module augmentations when '--module' is 'none'.": { "category": "Error", "code": 1148 }, @@ -2752,7 +2752,7 @@ "category": "Message", "code": 6130 }, - "Cannot compile modules using option '{0}' unless the '--module' flag is provided with a valid module type.": { + "Cannot compile modules using option '{0}' unless the '--module' flag is 'amd' or 'system'.": { "category": "Error", "code": 6131 }, diff --git a/src/compiler/program.ts b/src/compiler/program.ts index 68f2663e51f..92e79936a0f 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -2080,7 +2080,7 @@ namespace ts { else if (firstExternalModuleSourceFile && languageVersion < ScriptTarget.ES6 && options.module === ModuleKind.None) { // We cannot use createDiagnosticFromNode because nodes do not have parents yet const span = getErrorSpanForNode(firstExternalModuleSourceFile, firstExternalModuleSourceFile.externalModuleIndicator); - programDiagnostics.add(createFileDiagnostic(firstExternalModuleSourceFile, span.start, span.length, Diagnostics.Cannot_use_import_export_or_module_augmentation_when_compiling_with_module_is_none)); + programDiagnostics.add(createFileDiagnostic(firstExternalModuleSourceFile, span.start, span.length, Diagnostics.Cannot_use_imports_exports_or_module_augmentations_when_module_is_none)); } // Cannot specify module gen target of es6 when below es6 @@ -2095,7 +2095,7 @@ namespace ts { } else if (options.module === undefined && firstExternalModuleSourceFile) { const span = getErrorSpanForNode(firstExternalModuleSourceFile, firstExternalModuleSourceFile.externalModuleIndicator); - programDiagnostics.add(createFileDiagnostic(firstExternalModuleSourceFile, span.start, span.length, Diagnostics.Cannot_compile_modules_using_option_0_unless_the_module_flag_is_provided_with_a_valid_module_type, options.out ? "out" : "outFile")); + programDiagnostics.add(createFileDiagnostic(firstExternalModuleSourceFile, span.start, span.length, Diagnostics.Cannot_compile_modules_using_option_0_unless_the_module_flag_is_amd_or_system, options.out ? "out" : "outFile")); } } diff --git a/tests/baselines/reference/isolatedModulesOut.errors.txt b/tests/baselines/reference/isolatedModulesOut.errors.txt index 9453c00a83c..157ae98fcb3 100644 --- a/tests/baselines/reference/isolatedModulesOut.errors.txt +++ b/tests/baselines/reference/isolatedModulesOut.errors.txt @@ -1,5 +1,5 @@ error TS5053: Option 'out' cannot be specified with option 'isolatedModules'. -tests/cases/compiler/file1.ts(2,1): error TS6131: Cannot compile modules using option 'out' unless the '--module' flag is provided with a valid module type. +tests/cases/compiler/file1.ts(2,1): error TS6131: Cannot compile modules using option 'out' unless the '--module' flag is 'amd' or 'system'. tests/cases/compiler/file2.ts(1,1): error TS1208: Cannot compile namespaces when the '--isolatedModules' flag is provided. @@ -8,7 +8,7 @@ tests/cases/compiler/file2.ts(1,1): error TS1208: Cannot compile namespaces when export var x; ~~~~~~~~~~~~~ -!!! error TS6131: Cannot compile modules using option 'out' unless the '--module' flag is provided with a valid module type. +!!! error TS6131: Cannot compile modules using option 'out' unless the '--module' flag is 'amd' or 'system'. ==== tests/cases/compiler/file2.ts (1 errors) ==== var y; ~~~ diff --git a/tests/baselines/reference/moduleNoneErrors.errors.txt b/tests/baselines/reference/moduleNoneErrors.errors.txt index 1f1118c9916..903ea9bf037 100644 --- a/tests/baselines/reference/moduleNoneErrors.errors.txt +++ b/tests/baselines/reference/moduleNoneErrors.errors.txt @@ -1,10 +1,10 @@ -tests/cases/compiler/a.ts(1,14): error TS1148: Cannot use 'import', 'export' or module augmentation when compiling with '--module' is 'none'. +tests/cases/compiler/a.ts(1,14): error TS1148: Cannot use imports, exports or module augmentations when '--module' is 'none'. ==== tests/cases/compiler/a.ts (1 errors) ==== export class Foo { ~~~ -!!! error TS1148: Cannot use 'import', 'export' or module augmentation when compiling with '--module' is 'none'. +!!! error TS1148: Cannot use imports, exports or module augmentations when '--module' is 'none'. foo: string; } \ No newline at end of file diff --git a/tests/baselines/reference/outModuleConcatUnspecifiedModuleKind.errors.txt b/tests/baselines/reference/outModuleConcatUnspecifiedModuleKind.errors.txt index f0613367140..07282cd1350 100644 --- a/tests/baselines/reference/outModuleConcatUnspecifiedModuleKind.errors.txt +++ b/tests/baselines/reference/outModuleConcatUnspecifiedModuleKind.errors.txt @@ -1,11 +1,11 @@ -tests/cases/compiler/a.ts(2,14): error TS6131: Cannot compile modules using option 'outFile' unless the '--module' flag is provided with a valid module type. +tests/cases/compiler/a.ts(2,14): error TS6131: Cannot compile modules using option 'outFile' unless the '--module' flag is 'amd' or 'system'. ==== tests/cases/compiler/a.ts (1 errors) ==== export class A { } // module ~ -!!! error TS6131: Cannot compile modules using option 'outFile' unless the '--module' flag is provided with a valid module type. +!!! error TS6131: Cannot compile modules using option 'outFile' unless the '--module' flag is 'amd' or 'system'. ==== tests/cases/compiler/b.ts (0 errors) ==== var x = 0; // global \ No newline at end of file diff --git a/tests/baselines/reference/typeReferenceDirectives11.errors.txt b/tests/baselines/reference/typeReferenceDirectives11.errors.txt index b19efcebb90..45433bf3b83 100644 --- a/tests/baselines/reference/typeReferenceDirectives11.errors.txt +++ b/tests/baselines/reference/typeReferenceDirectives11.errors.txt @@ -1,4 +1,4 @@ -/mod1.ts(2,17): error TS6131: Cannot compile modules using option 'out' unless the '--module' flag is provided with a valid module type. +/mod1.ts(2,17): error TS6131: Cannot compile modules using option 'out' unless the '--module' flag is 'amd' or 'system'. ==== /mod2.ts (0 errors) ==== @@ -14,5 +14,5 @@ export function foo(): Lib { return {x: 1} } ~~~ -!!! error TS6131: Cannot compile modules using option 'out' unless the '--module' flag is provided with a valid module type. +!!! error TS6131: Cannot compile modules using option 'out' unless the '--module' flag is 'amd' or 'system'. \ No newline at end of file diff --git a/tests/baselines/reference/typeReferenceDirectives12.errors.txt b/tests/baselines/reference/typeReferenceDirectives12.errors.txt index 8eee7c04ee3..c1b3a6126b2 100644 --- a/tests/baselines/reference/typeReferenceDirectives12.errors.txt +++ b/tests/baselines/reference/typeReferenceDirectives12.errors.txt @@ -1,4 +1,4 @@ -/main.ts(1,14): error TS6131: Cannot compile modules using option 'out' unless the '--module' flag is provided with a valid module type. +/main.ts(1,14): error TS6131: Cannot compile modules using option 'out' unless the '--module' flag is 'amd' or 'system'. ==== /mod2.ts (0 errors) ==== @@ -16,7 +16,7 @@ ==== /main.ts (1 errors) ==== export class Cls { ~~~ -!!! error TS6131: Cannot compile modules using option 'out' unless the '--module' flag is provided with a valid module type. +!!! error TS6131: Cannot compile modules using option 'out' unless the '--module' flag is 'amd' or 'system'. x } From 167c3fbc640f531540127647f55f627b7dab370c Mon Sep 17 00:00:00 2001 From: Mohamed Hegazy Date: Wed, 18 May 2016 17:12:59 -0700 Subject: [PATCH 5/7] Fix typo --- src/compiler/diagnosticMessages.json | 2 +- src/compiler/program.ts | 2 +- tests/baselines/reference/pathsValidation1.errors.txt | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index c3ef03a9f34..0925f299215 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -2296,7 +2296,7 @@ "category": "Error", "code": 5062 }, - "Substututions for pattern '{0}' should be an array.": { + "Substitutions for pattern '{0}' should be an array.": { "category": "Error", "code": 5063 }, diff --git a/src/compiler/program.ts b/src/compiler/program.ts index 92e79936a0f..6b2a5c0def4 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -2021,7 +2021,7 @@ namespace ts { } } else { - programDiagnostics.add(createCompilerDiagnostic(Diagnostics.Substututions_for_pattern_0_should_be_an_array, key)); + programDiagnostics.add(createCompilerDiagnostic(Diagnostics.Substitutions_for_pattern_0_should_be_an_array, key)); } } } diff --git a/tests/baselines/reference/pathsValidation1.errors.txt b/tests/baselines/reference/pathsValidation1.errors.txt index c6193be67ac..a2d7be5f355 100644 --- a/tests/baselines/reference/pathsValidation1.errors.txt +++ b/tests/baselines/reference/pathsValidation1.errors.txt @@ -1,6 +1,6 @@ -error TS5063: Substututions for pattern '*' should be an array. +error TS5063: Substitutions for pattern '*' should be an array. -!!! error TS5063: Substututions for pattern '*' should be an array. +!!! error TS5063: Substitutions for pattern '*' should be an array. ==== tests/cases/compiler/a.ts (0 errors) ==== let x = 1; \ No newline at end of file From 55475acdc1aa701c6a27778bbc199f170e1e1ae0 Mon Sep 17 00:00:00 2001 From: Basarat Ali Syed Date: Mon, 23 May 2016 19:27:27 +1000 Subject: [PATCH 6/7] chore comments to jsdoc --- src/services/services.ts | 52 ++++++++++++++++++++++------------------ 1 file changed, 29 insertions(+), 23 deletions(-) diff --git a/src/services/services.ts b/src/services/services.ts index ef25fae7bba..995e27c02ca 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -1542,68 +1542,74 @@ namespace ts { export const unknown = ""; export const warning = "warning"; - // predefined type (void) or keyword (class) + /** predefined type (void) or keyword (class) */ export const keyword = "keyword"; - // top level script node + /** top level script node */ export const scriptElement = "script"; - // module foo {} + /** module foo {} */ export const moduleElement = "module"; - // class X {} + /** class X {} */ export const classElement = "class"; - // var x = class X {} + /** var x = class X {} */ export const localClassElement = "local class"; - // interface Y {} + /** interface Y {} */ export const interfaceElement = "interface"; - // type T = ... + /** type T = ... */ export const typeElement = "type"; - // enum E + /** enum E */ export const enumElement = "enum"; - // Inside module and script only - // const v = .. + /** + * Inside module and script only + * const v = .. + */ export const variableElement = "var"; - // Inside function + /** Inside function */ export const localVariableElement = "local var"; - // Inside module and script only - // function f() { } + /** + * Inside module and script only + * function f() { } + */ export const functionElement = "function"; - // Inside function + /** Inside function */ export const localFunctionElement = "local function"; - // class X { [public|private]* foo() {} } + /** class X { [public|private]* foo() {} } */ export const memberFunctionElement = "method"; - // class X { [public|private]* [get|set] foo:number; } + /** class X { [public|private]* [get|set] foo:number; } */ export const memberGetAccessorElement = "getter"; export const memberSetAccessorElement = "setter"; - // class X { [public|private]* foo:number; } - // interface Y { foo:number; } + /** + * class X { [public|private]* foo:number; } + * interface Y { foo:number; } + */ export const memberVariableElement = "property"; - // class X { constructor() { } } + /** class X { constructor() { } } */ export const constructorImplementationElement = "constructor"; - // interface Y { ():number; } + /** interface Y { ():number; } */ export const callSignatureElement = "call"; - // interface Y { []:number; } + /** interface Y { []:number; } */ export const indexSignatureElement = "index"; - // interface Y { new():Y; } + /** interface Y { new():Y; } */ export const constructSignatureElement = "construct"; - // function foo(*Y*: string) + /** function foo(*Y*: string) */ export const parameterElement = "parameter"; export const typeParameterElement = "type parameter"; From 8dfc2a1ab8e4d65a71c0230297cc6539ead21545 Mon Sep 17 00:00:00 2001 From: Mohamed Hegazy Date: Mon, 23 May 2016 10:13:33 -0700 Subject: [PATCH 7/7] Add comma --- src/compiler/diagnosticMessages.json | 2 +- tests/baselines/reference/moduleNoneErrors.errors.txt | 4 ++-- .../staticAnonymousTypeNotReferencingTypeParameter.symbols | 4 ++-- .../staticAnonymousTypeNotReferencingTypeParameter.types | 4 ++-- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index c88949db599..6e892c46dca 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -443,7 +443,7 @@ "category": "Error", "code": 1147 }, - "Cannot use imports, exports or module augmentations when '--module' is 'none'.": { + "Cannot use imports, exports, or module augmentations when '--module' is 'none'.": { "category": "Error", "code": 1148 }, diff --git a/tests/baselines/reference/moduleNoneErrors.errors.txt b/tests/baselines/reference/moduleNoneErrors.errors.txt index 903ea9bf037..4838b99f85b 100644 --- a/tests/baselines/reference/moduleNoneErrors.errors.txt +++ b/tests/baselines/reference/moduleNoneErrors.errors.txt @@ -1,10 +1,10 @@ -tests/cases/compiler/a.ts(1,14): error TS1148: Cannot use imports, exports or module augmentations when '--module' is 'none'. +tests/cases/compiler/a.ts(1,14): error TS1148: Cannot use imports, exports, or module augmentations when '--module' is 'none'. ==== tests/cases/compiler/a.ts (1 errors) ==== export class Foo { ~~~ -!!! error TS1148: Cannot use imports, exports or module augmentations when '--module' is 'none'. +!!! error TS1148: Cannot use imports, exports, or module augmentations when '--module' is 'none'. foo: string; } \ No newline at end of file diff --git a/tests/baselines/reference/staticAnonymousTypeNotReferencingTypeParameter.symbols b/tests/baselines/reference/staticAnonymousTypeNotReferencingTypeParameter.symbols index a6aa91e3a56..2596959de9e 100644 --- a/tests/baselines/reference/staticAnonymousTypeNotReferencingTypeParameter.symbols +++ b/tests/baselines/reference/staticAnonymousTypeNotReferencingTypeParameter.symbols @@ -562,9 +562,9 @@ class ListWrapper { >ListWrapper : Symbol(ListWrapper, Decl(staticAnonymousTypeNotReferencingTypeParameter.ts, 38, 1)) >l : Symbol(l, Decl(staticAnonymousTypeNotReferencingTypeParameter.ts, 113, 43)) >T : Symbol(T, Decl(staticAnonymousTypeNotReferencingTypeParameter.ts, 113, 16)) ->JSON.stringify : Symbol(JSON.stringify, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>JSON.stringify : Symbol(JSON.stringify, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) >JSON : Symbol(JSON, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) ->stringify : Symbol(JSON.stringify, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>stringify : Symbol(JSON.stringify, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) >l : Symbol(l, Decl(staticAnonymousTypeNotReferencingTypeParameter.ts, 113, 43)) static maximum(dit: typeof ListWrapper, list: T[], predicate: (t: T) => number): T { diff --git a/tests/baselines/reference/staticAnonymousTypeNotReferencingTypeParameter.types b/tests/baselines/reference/staticAnonymousTypeNotReferencingTypeParameter.types index 90148bdbb19..8d35f32707a 100644 --- a/tests/baselines/reference/staticAnonymousTypeNotReferencingTypeParameter.types +++ b/tests/baselines/reference/staticAnonymousTypeNotReferencingTypeParameter.types @@ -662,9 +662,9 @@ class ListWrapper { >l : T[] >T : T >JSON.stringify(l) : string ->JSON.stringify : { (value: any): string; (value: any, replacer: (key: string, value: any) => any): string; (value: any, replacer: any[]): string; (value: any, replacer: (key: string, value: any) => any, space: string | number): string; (value: any, replacer: any[], space: string | number): string; } +>JSON.stringify : { (value: any, replacer?: (key: string, value: any) => any, space?: string | number): string; (value: any, replacer?: (number | string)[], space?: string | number): string; } >JSON : JSON ->stringify : { (value: any): string; (value: any, replacer: (key: string, value: any) => any): string; (value: any, replacer: any[]): string; (value: any, replacer: (key: string, value: any) => any, space: string | number): string; (value: any, replacer: any[], space: string | number): string; } +>stringify : { (value: any, replacer?: (key: string, value: any) => any, space?: string | number): string; (value: any, replacer?: (number | string)[], space?: string | number): string; } >l : T[] static maximum(dit: typeof ListWrapper, list: T[], predicate: (t: T) => number): T {