From 873c1df74b7c7dcba59eaccc1bb4bd4b0da18a35 Mon Sep 17 00:00:00 2001 From: Mohamed Hegazy Date: Sat, 11 Oct 2014 12:52:42 -0700 Subject: [PATCH] Add es6 target --- src/compiler/commandLineParser.ts | 6 +- .../diagnosticInformationMap.generated.ts | 4 +- src/compiler/diagnosticMessages.json | 4 +- src/compiler/types.ts | 2 + src/harness/fourslash.ts | 2 +- src/harness/harness.ts | 4 +- src/harness/harnessLanguageService.ts | 2 +- src/services/compiler/precompile.ts | 2 +- src/services/services.ts | 12 +- src/services/shims.ts | 3 + src/services/syntax/scanner.ts | 2 +- src/services/syntax/unicode.ts | 4 +- tests/baselines/reference/es6-amd.js | 31 +++++ tests/baselines/reference/es6-amd.js.map | 2 + .../baselines/reference/es6-amd.sourcemap.txt | 128 ++++++++++++++++++ tests/baselines/reference/es6-amd.types | 16 +++ .../reference/es6-declaration-amd.js | 31 +++++ .../reference/es6-declaration-amd.js.map | 2 + .../es6-declaration-amd.sourcemap.txt | 128 ++++++++++++++++++ .../reference/es6-declaration-amd.types | 16 +++ .../baselines/reference/es6-sourcemap-amd.js | 25 ++++ .../reference/es6-sourcemap-amd.js.map | 2 + .../reference/es6-sourcemap-amd.sourcemap.txt | 128 ++++++++++++++++++ .../reference/es6-sourcemap-amd.types | 16 +++ tests/cases/compiler/es6-amd.ts | 17 +++ tests/cases/compiler/es6-declaration-amd.ts | 17 +++ tests/cases/compiler/es6-sourcemap-amd.ts | 16 +++ 27 files changed, 602 insertions(+), 20 deletions(-) create mode 100644 tests/baselines/reference/es6-amd.js create mode 100644 tests/baselines/reference/es6-amd.js.map create mode 100644 tests/baselines/reference/es6-amd.sourcemap.txt create mode 100644 tests/baselines/reference/es6-amd.types create mode 100644 tests/baselines/reference/es6-declaration-amd.js create mode 100644 tests/baselines/reference/es6-declaration-amd.js.map create mode 100644 tests/baselines/reference/es6-declaration-amd.sourcemap.txt create mode 100644 tests/baselines/reference/es6-declaration-amd.types create mode 100644 tests/baselines/reference/es6-sourcemap-amd.js create mode 100644 tests/baselines/reference/es6-sourcemap-amd.js.map create mode 100644 tests/baselines/reference/es6-sourcemap-amd.sourcemap.txt create mode 100644 tests/baselines/reference/es6-sourcemap-amd.types create mode 100644 tests/cases/compiler/es6-amd.ts create mode 100644 tests/cases/compiler/es6-declaration-amd.ts create mode 100644 tests/cases/compiler/es6-sourcemap-amd.ts diff --git a/src/compiler/commandLineParser.ts b/src/compiler/commandLineParser.ts index 0e48953eaa7d5..a7993484c647d 100644 --- a/src/compiler/commandLineParser.ts +++ b/src/compiler/commandLineParser.ts @@ -102,10 +102,10 @@ module ts { { name: "target", shortName: "t", - type: { "es3": ScriptTarget.ES3, "es5": ScriptTarget.ES5 }, - description: Diagnostics.Specify_ECMAScript_target_version_Colon_ES3_default_or_ES5, + type: { "es3": ScriptTarget.ES3, "es5": ScriptTarget.ES5 , "es6": ScriptTarget.ES6 }, + description: Diagnostics.Specify_ECMAScript_target_version_Colon_ES3_default_ES5_or_ES6_experimental, paramType: Diagnostics.VERSION, - error: Diagnostics.Argument_for_target_option_must_be_es3_or_es5 + error: Diagnostics.Argument_for_target_option_must_be_es3_es5_or_es6 }, { name: "version", diff --git a/src/compiler/diagnosticInformationMap.generated.ts b/src/compiler/diagnosticInformationMap.generated.ts index f6e8275786d29..627fb202c18aa 100644 --- a/src/compiler/diagnosticInformationMap.generated.ts +++ b/src/compiler/diagnosticInformationMap.generated.ts @@ -357,7 +357,7 @@ module ts { Watch_input_files: { code: 6005, category: DiagnosticCategory.Message, key: "Watch input files." }, Redirect_output_structure_to_the_directory: { code: 6006, category: DiagnosticCategory.Message, key: "Redirect output structure to the directory." }, Do_not_emit_comments_to_output: { code: 6009, category: DiagnosticCategory.Message, key: "Do not emit comments to output." }, - Specify_ECMAScript_target_version_Colon_ES3_default_or_ES5: { code: 6015, category: DiagnosticCategory.Message, key: "Specify ECMAScript target version: 'ES3' (default), or 'ES5'" }, + Specify_ECMAScript_target_version_Colon_ES3_default_ES5_or_ES6_experimental: { code: 6015, category: DiagnosticCategory.Message, key: "Specify ECMAScript target version: 'ES3' (default), 'ES5', or 'ES6' (experimental)" }, Specify_module_code_generation_Colon_commonjs_or_amd: { code: 6016, category: DiagnosticCategory.Message, key: "Specify module code generation: 'commonjs' or 'amd'" }, Print_this_message: { code: 6017, category: DiagnosticCategory.Message, key: "Print this message." }, Print_the_compiler_s_version: { code: 6019, category: DiagnosticCategory.Message, key: "Print the compiler's version." }, @@ -379,7 +379,7 @@ module ts { Compiler_option_0_expects_an_argument: { code: 6044, category: DiagnosticCategory.Error, key: "Compiler option '{0}' expects an argument." }, Unterminated_quoted_string_in_response_file_0: { code: 6045, category: DiagnosticCategory.Error, key: "Unterminated quoted string in response file '{0}'." }, Argument_for_module_option_must_be_commonjs_or_amd: { code: 6046, category: DiagnosticCategory.Error, key: "Argument for '--module' option must be 'commonjs' or 'amd'." }, - Argument_for_target_option_must_be_es3_or_es5: { code: 6047, category: DiagnosticCategory.Error, key: "Argument for '--target' option must be 'es3' or 'es5'." }, + Argument_for_target_option_must_be_es3_es5_or_es6: { code: 6047, category: DiagnosticCategory.Error, key: "Argument for '--target' option must be 'es3', 'es5', or 'es6'." }, Locale_must_be_of_the_form_language_or_language_territory_For_example_0_or_1: { code: 6048, category: DiagnosticCategory.Error, key: "Locale must be of the form or -. For example '{0}' or '{1}'." }, Unsupported_locale_0: { code: 6049, category: DiagnosticCategory.Error, key: "Unsupported locale '{0}'." }, Unable_to_open_file_0: { code: 6050, category: DiagnosticCategory.Error, key: "Unable to open file '{0}'." }, diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index 97c82a0a71869..26a8c51cccc0b 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -1424,7 +1424,7 @@ "category": "Message", "code": 6009 }, - "Specify ECMAScript target version: 'ES3' (default), or 'ES5'": { + "Specify ECMAScript target version: 'ES3' (default), 'ES5', or 'ES6' (experimental)": { "category": "Message", "code": 6015 }, @@ -1512,7 +1512,7 @@ "category": "Error", "code": 6046 }, - "Argument for '--target' option must be 'es3' or 'es5'.": { + "Argument for '--target' option must be 'es3', 'es5', or 'es6'.": { "category": "Error", "code": 6047 }, diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 2a291c828cdab..38b69e23dee10 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -1062,6 +1062,8 @@ module ts { export enum ScriptTarget { ES3, ES5, + ES6, + Latest = ES6, } export interface ParsedCommandLine { diff --git a/src/harness/fourslash.ts b/src/harness/fourslash.ts index 6a4e13b22e33f..0e605a854e2df 100644 --- a/src/harness/fourslash.ts +++ b/src/harness/fourslash.ts @@ -2139,7 +2139,7 @@ module FourSlash { var host = Harness.Compiler.createCompilerHost([{ unitName: Harness.Compiler.fourslashFilename, content: undefined }, { unitName: fileName, content: content }], (fn, contents) => result = contents, - ts.ScriptTarget.ES5, + ts.ScriptTarget.Latest, sys.useCaseSensitiveFileNames); var program = ts.createProgram([Harness.Compiler.fourslashFilename, fileName], { out: "fourslashTestOutput.js" }, host); var checker = ts.createTypeChecker(program, /*fullTypeCheckMode*/ true); diff --git a/src/harness/harness.ts b/src/harness/harness.ts index e35fe83f9b265..728c4cc08e0ab 100644 --- a/src/harness/harness.ts +++ b/src/harness/harness.ts @@ -532,7 +532,7 @@ module Harness { } export var defaultLibFileName = 'lib.d.ts'; - export var defaultLibSourceFile = ts.createSourceFile(defaultLibFileName, IO.readFile(libFolder + 'lib.core.d.ts'), /*languageVersion*/ ts.ScriptTarget.ES5, /*version:*/ "0"); + export var defaultLibSourceFile = ts.createSourceFile(defaultLibFileName, IO.readFile(libFolder + 'lib.core.d.ts'), /*languageVersion*/ ts.ScriptTarget.Latest, /*version:*/ "0"); // Cache these between executions so we don't have to re-parse them for every test export var fourslashFilename = 'fourslash.ts'; @@ -685,6 +685,8 @@ module Harness { options.target = ts.ScriptTarget.ES3; } else if (setting.value.toLowerCase() === 'es5') { options.target = ts.ScriptTarget.ES5; + } else if (setting.value.toLowerCase() === 'es6') { + options.target = ts.ScriptTarget.ES6; } else { throw new Error('Unknown compile target ' + setting.value); } diff --git a/src/harness/harnessLanguageService.ts b/src/harness/harnessLanguageService.ts index 647d0729cbb5f..6307c4d1e78ff 100644 --- a/src/harness/harnessLanguageService.ts +++ b/src/harness/harnessLanguageService.ts @@ -260,7 +260,7 @@ module Harness.LanguageService { /** Parse file given its source text */ public parseSourceText(fileName: string, sourceText: TypeScript.IScriptSnapshot): TypeScript.SourceUnitSyntax { - return TypeScript.Parser.parse(fileName, TypeScript.SimpleText.fromScriptSnapshot(sourceText), ts.ScriptTarget.ES5, TypeScript.isDTSFile(fileName)).sourceUnit(); + return TypeScript.Parser.parse(fileName, TypeScript.SimpleText.fromScriptSnapshot(sourceText), ts.ScriptTarget.Latest, TypeScript.isDTSFile(fileName)).sourceUnit(); } /** Parse a file on disk given its fileName */ diff --git a/src/services/compiler/precompile.ts b/src/services/compiler/precompile.ts index 3ff23d85bea1c..08a919a65b58a 100644 --- a/src/services/compiler/precompile.ts +++ b/src/services/compiler/precompile.ts @@ -184,7 +184,7 @@ module TypeScript { export function preProcessFile(fileName: string, sourceText: IScriptSnapshot, readImportFiles = true): IPreProcessedFileInfo { var text = SimpleText.fromScriptSnapshot(sourceText); - var scanner = Scanner.createScanner(ts.ScriptTarget.ES5, text, reportDiagnostic); + var scanner = Scanner.createScanner(ts.ScriptTarget.Latest, text, reportDiagnostic); var firstToken = scanner.scan(/*allowRegularExpression:*/ false); diff --git a/src/services/services.ts b/src/services/services.ts index 42f6160bd3e4b..d7c5dc2d897cc 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -77,7 +77,7 @@ module ts { update(scriptSnapshot: TypeScript.IScriptSnapshot, version: string, isOpen: boolean, textChangeRange: TypeScript.TextChangeRange): SourceFile; } - var scanner: Scanner = createScanner(ScriptTarget.ES5, /*skipTrivia*/ true); + var scanner: Scanner = createScanner(ScriptTarget.Latest, /*skipTrivia*/ true); var emptyArray: any[] = []; @@ -1456,9 +1456,9 @@ module ts { } export function getDefaultCompilerOptions(): CompilerOptions { - // Set "ES5" target by default for language service + // Set "ScriptTarget.Latest" target by default for language service return { - target: ScriptTarget.ES5, + target: ScriptTarget.Latest, module: ModuleKind.None, }; } @@ -3794,8 +3794,8 @@ module ts { // before and after it have to be a non-identifier char). var endPosition = position + symbolNameLength; - if ((position === 0 || !isIdentifierPart(text.charCodeAt(position - 1), ScriptTarget.ES5)) && - (endPosition === sourceLength || !isIdentifierPart(text.charCodeAt(endPosition), ScriptTarget.ES5))) { + if ((position === 0 || !isIdentifierPart(text.charCodeAt(position - 1), ScriptTarget.Latest)) && + (endPosition === sourceLength || !isIdentifierPart(text.charCodeAt(endPosition), ScriptTarget.Latest))) { // Found a real match. Keep searching. positions.push(position); } @@ -5217,7 +5217,7 @@ module ts { /// Classifier export function createClassifier(host: Logger): Classifier { - var scanner = createScanner(ScriptTarget.ES5, /*skipTrivia*/ false); + var scanner = createScanner(ScriptTarget.Latest, /*skipTrivia*/ false); /// We do not have a full parser support to know when we should parse a regex or not /// If we consider every slash token to be a regex, we could be missing cases like "1/2/3", where diff --git a/src/services/shims.ts b/src/services/shims.ts index fdea0202323fb..a6bf421b09566 100644 --- a/src/services/shims.ts +++ b/src/services/shims.ts @@ -174,6 +174,7 @@ module ts { export enum LanguageVersion { EcmaScript3 = 0, EcmaScript5 = 1, + EcmaScript6 = 2, } export enum ModuleGenTarget { @@ -213,6 +214,7 @@ module ts { switch (languageVersion) { case LanguageVersion.EcmaScript3: return ScriptTarget.ES3 case LanguageVersion.EcmaScript5: return ScriptTarget.ES5; + case LanguageVersion.EcmaScript6: return ScriptTarget.ES6; default: throw Error("unsupported LanguageVersion value: " + languageVersion); } } @@ -234,6 +236,7 @@ module ts { switch (scriptTarget) { case ScriptTarget.ES3: return LanguageVersion.EcmaScript3; case ScriptTarget.ES5: return LanguageVersion.EcmaScript5; + case ScriptTarget.ES6: return LanguageVersion.EcmaScript6; default: throw Error("unsupported ScriptTarget value: " + scriptTarget); } } diff --git a/src/services/syntax/scanner.ts b/src/services/syntax/scanner.ts index 45cc151e2d5ba..29ced029f1cca 100644 --- a/src/services/syntax/scanner.ts +++ b/src/services/syntax/scanner.ts @@ -186,7 +186,7 @@ module TypeScript.Scanner { var lastTokenInfo = { leadingTriviaWidth: -1, width: -1 }; var lastTokenInfoTokenID: number = -1; - var triviaScanner = createScannerInternal(ts.ScriptTarget.ES5, SimpleText.fromString(""), () => { }); + var triviaScanner = createScannerInternal(ts.ScriptTarget.Latest, SimpleText.fromString(""), () => { }); interface IScannerToken extends ISyntaxToken { } diff --git a/src/services/syntax/unicode.ts b/src/services/syntax/unicode.ts index df2f88b74c576..b1e94090de743 100644 --- a/src/services/syntax/unicode.ts +++ b/src/services/syntax/unicode.ts @@ -84,7 +84,7 @@ module TypeScript { if (languageVersion === ts.ScriptTarget.ES3) { return Unicode.lookupInUnicodeMap(code, Unicode.unicodeES3IdentifierStart); } - else if (languageVersion === ts.ScriptTarget.ES5) { + else if (languageVersion >= ts.ScriptTarget.ES5) { return Unicode.lookupInUnicodeMap(code, Unicode.unicodeES5IdentifierStart); } else { @@ -96,7 +96,7 @@ module TypeScript { if (languageVersion === ts.ScriptTarget.ES3) { return Unicode.lookupInUnicodeMap(code, Unicode.unicodeES3IdentifierPart); } - else if (languageVersion === ts.ScriptTarget.ES5) { + else if (languageVersion >= ts.ScriptTarget.ES5) { return Unicode.lookupInUnicodeMap(code, Unicode.unicodeES5IdentifierPart); } else { diff --git a/tests/baselines/reference/es6-amd.js b/tests/baselines/reference/es6-amd.js new file mode 100644 index 0000000000000..0cce3af04463a --- /dev/null +++ b/tests/baselines/reference/es6-amd.js @@ -0,0 +1,31 @@ +//// [es6-amd.ts] + +class A +{ + constructor () + { + + } + + public B() + { + return 42; + } +} + +//// [es6-amd.js] +var A = (function () { + function A() { + } + A.prototype.B = function () { + return 42; + }; + return A; +})(); +//# sourceMappingURL=es6-amd.js.map + +//// [es6-amd.d.ts] +declare class A { + constructor(); + B(): number; +} diff --git a/tests/baselines/reference/es6-amd.js.map b/tests/baselines/reference/es6-amd.js.map new file mode 100644 index 0000000000000..7371ba578bd1d --- /dev/null +++ b/tests/baselines/reference/es6-amd.js.map @@ -0,0 +1,2 @@ +//// [es6-amd.js.map] +{"version":3,"file":"es6-amd.js","sourceRoot":"","sources":["es6-amd.ts"],"names":["A","A.constructor","A.B"],"mappings":"AACA,IAAM,CAAC;IAEHA,SAFEA,CAACA;IAKHC,CAACA;IAEMD,aAACA,GAARA;QAEIE,MAAMA,CAACA,EAAEA,CAACA;IACdA,CAACA;IACLF,QAACA;AAADA,CAACA,AAXD,IAWC"} \ No newline at end of file diff --git a/tests/baselines/reference/es6-amd.sourcemap.txt b/tests/baselines/reference/es6-amd.sourcemap.txt new file mode 100644 index 0000000000000..070a35703e173 --- /dev/null +++ b/tests/baselines/reference/es6-amd.sourcemap.txt @@ -0,0 +1,128 @@ +=================================================================== +JsFile: es6-amd.js +mapUrl: es6-amd.js.map +sourceRoot: +sources: es6-amd.ts +=================================================================== +------------------------------------------------------------------- +emittedFile:tests/cases/compiler/es6-amd.js +sourceFile:es6-amd.ts +------------------------------------------------------------------- +>>>var A = (function () { +1 > +2 >^^^^ +3 > ^ +4 > ^^^^^^^^^^^^^^-> +1 > + > +2 >class +3 > A +1 >Emitted(1, 1) Source(2, 1) + SourceIndex(0) +2 >Emitted(1, 5) Source(2, 7) + SourceIndex(0) +3 >Emitted(1, 6) Source(2, 8) + SourceIndex(0) +--- +>>> function A() { +1->^^^^ +2 > ^^^^^^^^^ +3 > ^ +1-> + >{ + > +2 > +3 > A +1->Emitted(2, 5) Source(4, 5) + SourceIndex(0) name (A) +2 >Emitted(2, 14) Source(2, 7) + SourceIndex(0) name (A) +3 >Emitted(2, 15) Source(2, 8) + SourceIndex(0) name (A) +--- +>>> } +1 >^^^^ +2 > ^ +3 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> +1 > + >{ + > constructor () + > { + > + > +2 > } +1 >Emitted(3, 5) Source(7, 5) + SourceIndex(0) name (A.constructor) +2 >Emitted(3, 6) Source(7, 6) + SourceIndex(0) name (A.constructor) +--- +>>> A.prototype.B = function () { +1->^^^^ +2 > ^^^^^^^^^^^^^ +3 > ^^^ +1-> + > + > public +2 > B +3 > +1->Emitted(4, 5) Source(9, 12) + SourceIndex(0) name (A) +2 >Emitted(4, 18) Source(9, 13) + SourceIndex(0) name (A) +3 >Emitted(4, 21) Source(9, 5) + SourceIndex(0) name (A) +--- +>>> return 42; +1 >^^^^^^^^ +2 > ^^^^^^ +3 > ^ +4 > ^^ +5 > ^ +1 >public B() + > { + > +2 > return +3 > +4 > 42 +5 > ; +1 >Emitted(5, 9) Source(11, 9) + SourceIndex(0) name (A.B) +2 >Emitted(5, 15) Source(11, 15) + SourceIndex(0) name (A.B) +3 >Emitted(5, 16) Source(11, 16) + SourceIndex(0) name (A.B) +4 >Emitted(5, 18) Source(11, 18) + SourceIndex(0) name (A.B) +5 >Emitted(5, 19) Source(11, 19) + SourceIndex(0) name (A.B) +--- +>>> }; +1 >^^^^ +2 > ^ +3 > ^^^^^^^^^-> +1 > + > +2 > } +1 >Emitted(6, 5) Source(12, 5) + SourceIndex(0) name (A.B) +2 >Emitted(6, 6) Source(12, 6) + SourceIndex(0) name (A.B) +--- +>>> return A; +1->^^^^ +2 > ^^^^^^^^ +1-> + > +2 > } +1->Emitted(7, 5) Source(13, 1) + SourceIndex(0) name (A) +2 >Emitted(7, 13) Source(13, 2) + SourceIndex(0) name (A) +--- +>>>})(); +1 > +2 >^ +3 > +4 > ^^^^ +5 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> +1 > +2 >} +3 > +4 > class A + > { + > constructor () + > { + > + > } + > + > public B() + > { + > return 42; + > } + > } +1 >Emitted(8, 1) Source(13, 1) + SourceIndex(0) name (A) +2 >Emitted(8, 2) Source(13, 2) + SourceIndex(0) name (A) +3 >Emitted(8, 2) Source(2, 1) + SourceIndex(0) +4 >Emitted(8, 6) Source(13, 2) + SourceIndex(0) +--- +>>>//# sourceMappingURL=es6-amd.js.map \ No newline at end of file diff --git a/tests/baselines/reference/es6-amd.types b/tests/baselines/reference/es6-amd.types new file mode 100644 index 0000000000000..62815911f7f97 --- /dev/null +++ b/tests/baselines/reference/es6-amd.types @@ -0,0 +1,16 @@ +=== tests/cases/compiler/es6-amd.ts === + +class A +>A : A +{ + constructor () + { + + } + + public B() +>B : () => number + { + return 42; + } +} diff --git a/tests/baselines/reference/es6-declaration-amd.js b/tests/baselines/reference/es6-declaration-amd.js new file mode 100644 index 0000000000000..471f96b223d1a --- /dev/null +++ b/tests/baselines/reference/es6-declaration-amd.js @@ -0,0 +1,31 @@ +//// [es6-declaration-amd.ts] + +class A +{ + constructor () + { + + } + + public B() + { + return 42; + } +} + +//// [es6-declaration-amd.js] +var A = (function () { + function A() { + } + A.prototype.B = function () { + return 42; + }; + return A; +})(); +//# sourceMappingURL=es6-declaration-amd.js.map + +//// [es6-declaration-amd.d.ts] +declare class A { + constructor(); + B(): number; +} diff --git a/tests/baselines/reference/es6-declaration-amd.js.map b/tests/baselines/reference/es6-declaration-amd.js.map new file mode 100644 index 0000000000000..0987f9478e99e --- /dev/null +++ b/tests/baselines/reference/es6-declaration-amd.js.map @@ -0,0 +1,2 @@ +//// [es6-declaration-amd.js.map] +{"version":3,"file":"es6-declaration-amd.js","sourceRoot":"","sources":["es6-declaration-amd.ts"],"names":["A","A.constructor","A.B"],"mappings":"AACA,IAAM,CAAC;IAEHA,SAFEA,CAACA;IAKHC,CAACA;IAEMD,aAACA,GAARA;QAEIE,MAAMA,CAACA,EAAEA,CAACA;IACdA,CAACA;IACLF,QAACA;AAADA,CAACA,AAXD,IAWC"} \ No newline at end of file diff --git a/tests/baselines/reference/es6-declaration-amd.sourcemap.txt b/tests/baselines/reference/es6-declaration-amd.sourcemap.txt new file mode 100644 index 0000000000000..1fc0b5f05fead --- /dev/null +++ b/tests/baselines/reference/es6-declaration-amd.sourcemap.txt @@ -0,0 +1,128 @@ +=================================================================== +JsFile: es6-declaration-amd.js +mapUrl: es6-declaration-amd.js.map +sourceRoot: +sources: es6-declaration-amd.ts +=================================================================== +------------------------------------------------------------------- +emittedFile:tests/cases/compiler/es6-declaration-amd.js +sourceFile:es6-declaration-amd.ts +------------------------------------------------------------------- +>>>var A = (function () { +1 > +2 >^^^^ +3 > ^ +4 > ^^^^^^^^^^^^^^-> +1 > + > +2 >class +3 > A +1 >Emitted(1, 1) Source(2, 1) + SourceIndex(0) +2 >Emitted(1, 5) Source(2, 7) + SourceIndex(0) +3 >Emitted(1, 6) Source(2, 8) + SourceIndex(0) +--- +>>> function A() { +1->^^^^ +2 > ^^^^^^^^^ +3 > ^ +1-> + >{ + > +2 > +3 > A +1->Emitted(2, 5) Source(4, 5) + SourceIndex(0) name (A) +2 >Emitted(2, 14) Source(2, 7) + SourceIndex(0) name (A) +3 >Emitted(2, 15) Source(2, 8) + SourceIndex(0) name (A) +--- +>>> } +1 >^^^^ +2 > ^ +3 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> +1 > + >{ + > constructor () + > { + > + > +2 > } +1 >Emitted(3, 5) Source(7, 5) + SourceIndex(0) name (A.constructor) +2 >Emitted(3, 6) Source(7, 6) + SourceIndex(0) name (A.constructor) +--- +>>> A.prototype.B = function () { +1->^^^^ +2 > ^^^^^^^^^^^^^ +3 > ^^^ +1-> + > + > public +2 > B +3 > +1->Emitted(4, 5) Source(9, 12) + SourceIndex(0) name (A) +2 >Emitted(4, 18) Source(9, 13) + SourceIndex(0) name (A) +3 >Emitted(4, 21) Source(9, 5) + SourceIndex(0) name (A) +--- +>>> return 42; +1 >^^^^^^^^ +2 > ^^^^^^ +3 > ^ +4 > ^^ +5 > ^ +1 >public B() + > { + > +2 > return +3 > +4 > 42 +5 > ; +1 >Emitted(5, 9) Source(11, 9) + SourceIndex(0) name (A.B) +2 >Emitted(5, 15) Source(11, 15) + SourceIndex(0) name (A.B) +3 >Emitted(5, 16) Source(11, 16) + SourceIndex(0) name (A.B) +4 >Emitted(5, 18) Source(11, 18) + SourceIndex(0) name (A.B) +5 >Emitted(5, 19) Source(11, 19) + SourceIndex(0) name (A.B) +--- +>>> }; +1 >^^^^ +2 > ^ +3 > ^^^^^^^^^-> +1 > + > +2 > } +1 >Emitted(6, 5) Source(12, 5) + SourceIndex(0) name (A.B) +2 >Emitted(6, 6) Source(12, 6) + SourceIndex(0) name (A.B) +--- +>>> return A; +1->^^^^ +2 > ^^^^^^^^ +1-> + > +2 > } +1->Emitted(7, 5) Source(13, 1) + SourceIndex(0) name (A) +2 >Emitted(7, 13) Source(13, 2) + SourceIndex(0) name (A) +--- +>>>})(); +1 > +2 >^ +3 > +4 > ^^^^ +5 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> +1 > +2 >} +3 > +4 > class A + > { + > constructor () + > { + > + > } + > + > public B() + > { + > return 42; + > } + > } +1 >Emitted(8, 1) Source(13, 1) + SourceIndex(0) name (A) +2 >Emitted(8, 2) Source(13, 2) + SourceIndex(0) name (A) +3 >Emitted(8, 2) Source(2, 1) + SourceIndex(0) +4 >Emitted(8, 6) Source(13, 2) + SourceIndex(0) +--- +>>>//# sourceMappingURL=es6-declaration-amd.js.map \ No newline at end of file diff --git a/tests/baselines/reference/es6-declaration-amd.types b/tests/baselines/reference/es6-declaration-amd.types new file mode 100644 index 0000000000000..e275fc5243961 --- /dev/null +++ b/tests/baselines/reference/es6-declaration-amd.types @@ -0,0 +1,16 @@ +=== tests/cases/compiler/es6-declaration-amd.ts === + +class A +>A : A +{ + constructor () + { + + } + + public B() +>B : () => number + { + return 42; + } +} diff --git a/tests/baselines/reference/es6-sourcemap-amd.js b/tests/baselines/reference/es6-sourcemap-amd.js new file mode 100644 index 0000000000000..805e56cf830d0 --- /dev/null +++ b/tests/baselines/reference/es6-sourcemap-amd.js @@ -0,0 +1,25 @@ +//// [es6-sourcemap-amd.ts] + +class A +{ + constructor () + { + + } + + public B() + { + return 42; + } +} + +//// [es6-sourcemap-amd.js] +var A = (function () { + function A() { + } + A.prototype.B = function () { + return 42; + }; + return A; +})(); +//# sourceMappingURL=es6-sourcemap-amd.js.map \ No newline at end of file diff --git a/tests/baselines/reference/es6-sourcemap-amd.js.map b/tests/baselines/reference/es6-sourcemap-amd.js.map new file mode 100644 index 0000000000000..689f0447fa8db --- /dev/null +++ b/tests/baselines/reference/es6-sourcemap-amd.js.map @@ -0,0 +1,2 @@ +//// [es6-sourcemap-amd.js.map] +{"version":3,"file":"es6-sourcemap-amd.js","sourceRoot":"","sources":["es6-sourcemap-amd.ts"],"names":["A","A.constructor","A.B"],"mappings":"AACA,IAAM,CAAC;IAEHA,SAFEA,CAACA;IAKHC,CAACA;IAEMD,aAACA,GAARA;QAEIE,MAAMA,CAACA,EAAEA,CAACA;IACdA,CAACA;IACLF,QAACA;AAADA,CAACA,AAXD,IAWC"} \ No newline at end of file diff --git a/tests/baselines/reference/es6-sourcemap-amd.sourcemap.txt b/tests/baselines/reference/es6-sourcemap-amd.sourcemap.txt new file mode 100644 index 0000000000000..09abb195987c1 --- /dev/null +++ b/tests/baselines/reference/es6-sourcemap-amd.sourcemap.txt @@ -0,0 +1,128 @@ +=================================================================== +JsFile: es6-sourcemap-amd.js +mapUrl: es6-sourcemap-amd.js.map +sourceRoot: +sources: es6-sourcemap-amd.ts +=================================================================== +------------------------------------------------------------------- +emittedFile:tests/cases/compiler/es6-sourcemap-amd.js +sourceFile:es6-sourcemap-amd.ts +------------------------------------------------------------------- +>>>var A = (function () { +1 > +2 >^^^^ +3 > ^ +4 > ^^^^^^^^^^^^^^-> +1 > + > +2 >class +3 > A +1 >Emitted(1, 1) Source(2, 1) + SourceIndex(0) +2 >Emitted(1, 5) Source(2, 7) + SourceIndex(0) +3 >Emitted(1, 6) Source(2, 8) + SourceIndex(0) +--- +>>> function A() { +1->^^^^ +2 > ^^^^^^^^^ +3 > ^ +1-> + >{ + > +2 > +3 > A +1->Emitted(2, 5) Source(4, 5) + SourceIndex(0) name (A) +2 >Emitted(2, 14) Source(2, 7) + SourceIndex(0) name (A) +3 >Emitted(2, 15) Source(2, 8) + SourceIndex(0) name (A) +--- +>>> } +1 >^^^^ +2 > ^ +3 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> +1 > + >{ + > constructor () + > { + > + > +2 > } +1 >Emitted(3, 5) Source(7, 5) + SourceIndex(0) name (A.constructor) +2 >Emitted(3, 6) Source(7, 6) + SourceIndex(0) name (A.constructor) +--- +>>> A.prototype.B = function () { +1->^^^^ +2 > ^^^^^^^^^^^^^ +3 > ^^^ +1-> + > + > public +2 > B +3 > +1->Emitted(4, 5) Source(9, 12) + SourceIndex(0) name (A) +2 >Emitted(4, 18) Source(9, 13) + SourceIndex(0) name (A) +3 >Emitted(4, 21) Source(9, 5) + SourceIndex(0) name (A) +--- +>>> return 42; +1 >^^^^^^^^ +2 > ^^^^^^ +3 > ^ +4 > ^^ +5 > ^ +1 >public B() + > { + > +2 > return +3 > +4 > 42 +5 > ; +1 >Emitted(5, 9) Source(11, 9) + SourceIndex(0) name (A.B) +2 >Emitted(5, 15) Source(11, 15) + SourceIndex(0) name (A.B) +3 >Emitted(5, 16) Source(11, 16) + SourceIndex(0) name (A.B) +4 >Emitted(5, 18) Source(11, 18) + SourceIndex(0) name (A.B) +5 >Emitted(5, 19) Source(11, 19) + SourceIndex(0) name (A.B) +--- +>>> }; +1 >^^^^ +2 > ^ +3 > ^^^^^^^^^-> +1 > + > +2 > } +1 >Emitted(6, 5) Source(12, 5) + SourceIndex(0) name (A.B) +2 >Emitted(6, 6) Source(12, 6) + SourceIndex(0) name (A.B) +--- +>>> return A; +1->^^^^ +2 > ^^^^^^^^ +1-> + > +2 > } +1->Emitted(7, 5) Source(13, 1) + SourceIndex(0) name (A) +2 >Emitted(7, 13) Source(13, 2) + SourceIndex(0) name (A) +--- +>>>})(); +1 > +2 >^ +3 > +4 > ^^^^ +5 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> +1 > +2 >} +3 > +4 > class A + > { + > constructor () + > { + > + > } + > + > public B() + > { + > return 42; + > } + > } +1 >Emitted(8, 1) Source(13, 1) + SourceIndex(0) name (A) +2 >Emitted(8, 2) Source(13, 2) + SourceIndex(0) name (A) +3 >Emitted(8, 2) Source(2, 1) + SourceIndex(0) +4 >Emitted(8, 6) Source(13, 2) + SourceIndex(0) +--- +>>>//# sourceMappingURL=es6-sourcemap-amd.js.map \ No newline at end of file diff --git a/tests/baselines/reference/es6-sourcemap-amd.types b/tests/baselines/reference/es6-sourcemap-amd.types new file mode 100644 index 0000000000000..661ab2e7cddfc --- /dev/null +++ b/tests/baselines/reference/es6-sourcemap-amd.types @@ -0,0 +1,16 @@ +=== tests/cases/compiler/es6-sourcemap-amd.ts === + +class A +>A : A +{ + constructor () + { + + } + + public B() +>B : () => number + { + return 42; + } +} diff --git a/tests/cases/compiler/es6-amd.ts b/tests/cases/compiler/es6-amd.ts new file mode 100644 index 0000000000000..a5fb99a86051d --- /dev/null +++ b/tests/cases/compiler/es6-amd.ts @@ -0,0 +1,17 @@ +// @target: ES6 +// @sourcemap: false +// @declaration: false +// @module: amd + +class A +{ + constructor () + { + + } + + public B() + { + return 42; + } +} \ No newline at end of file diff --git a/tests/cases/compiler/es6-declaration-amd.ts b/tests/cases/compiler/es6-declaration-amd.ts new file mode 100644 index 0000000000000..1dcfeca84979e --- /dev/null +++ b/tests/cases/compiler/es6-declaration-amd.ts @@ -0,0 +1,17 @@ +// @target: ES6 +// @sourcemap: false +// @declaration: true +// @module: amd + +class A +{ + constructor () + { + + } + + public B() + { + return 42; + } +} \ No newline at end of file diff --git a/tests/cases/compiler/es6-sourcemap-amd.ts b/tests/cases/compiler/es6-sourcemap-amd.ts new file mode 100644 index 0000000000000..c00a697de940b --- /dev/null +++ b/tests/cases/compiler/es6-sourcemap-amd.ts @@ -0,0 +1,16 @@ +// @target: ES6 +// @sourcemap: true +// @module: amd + +class A +{ + constructor () + { + + } + + public B() + { + return 42; + } +} \ No newline at end of file