From 6fd267c574057c42571c2ae798506db79f8079ed Mon Sep 17 00:00:00 2001 From: Yui T Date: Tue, 14 Jul 2015 18:15:30 -0700 Subject: [PATCH 001/117] Fix CRLF --- src/compiler/commandLineParser.ts | 2 +- src/compiler/program.ts | 4 ++-- src/compiler/scanner.ts | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/compiler/commandLineParser.ts b/src/compiler/commandLineParser.ts index ba7d8ca9ce3..4bcc37e0ecc 100644 --- a/src/compiler/commandLineParser.ts +++ b/src/compiler/commandLineParser.ts @@ -425,7 +425,7 @@ namespace ts { } else { let exclude = json["exclude"] instanceof Array ? map(json["exclude"], normalizeSlashes) : undefined; - let sysFiles = host.readDirectory(basePath, ".ts", exclude).concat(host.readDirectory(basePath, ".tsx", exclude)); + let sysFiles = host.readDirectory(basePath, ".ts", exclude).concat(host.readDirectory(basePath, ".tsx", exclude)); for (let i = 0; i < sysFiles.length; i++) { let name = sysFiles[i]; if (fileExtensionIs(name, ".d.ts")) { diff --git a/src/compiler/program.ts b/src/compiler/program.ts index 5ce4846b43b..ca12f6de03d 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -341,7 +341,7 @@ namespace ts { }); } - function getDeclarationDiagnosticsForFile(sourceFile: SourceFile, cancellationToken: CancellationToken): Diagnostic[] { + function getDeclarationDiagnosticsForFile(sourceFile: SourceFile, cancellationToken: CancellationToken): Diagnostic[] { return runWithCancellationToken(() => { if (!isDeclarationFile(sourceFile)) { let resolver = getDiagnosticsProducingTypeChecker().getEmitResolver(sourceFile, cancellationToken); @@ -350,7 +350,7 @@ namespace ts { return ts.getDeclarationDiagnostics(getEmitHost(writeFile), resolver, sourceFile); } }); - } + } function getOptionsDiagnostics(): Diagnostic[] { let allDiagnostics: Diagnostic[] = []; diff --git a/src/compiler/scanner.ts b/src/compiler/scanner.ts index d52f96c912b..a30e23f6170 100644 --- a/src/compiler/scanner.ts +++ b/src/compiler/scanner.ts @@ -629,9 +629,9 @@ namespace ts { ch >= CharacterCodes._0 && ch <= CharacterCodes._9 || ch === CharacterCodes.$ || ch === CharacterCodes._ || ch > CharacterCodes.maxAsciiCharacter && isUnicodeIdentifierPart(ch, languageVersion); } - + /* @internal */ - // Creates a scanner over a (possibly unspecified) range of a piece of text. + // Creates a scanner over a (possibly unspecified) range of a piece of text. export function createScanner(languageVersion: ScriptTarget, skipTrivia: boolean, languageVariant = LanguageVariant.Standard, From 24eea0349defa34c90590153860b2cf0906369aa Mon Sep 17 00:00:00 2001 From: Yui T Date: Wed, 15 Jul 2015 11:49:00 -0700 Subject: [PATCH 002/117] Add tests --- ...mitTripleSlashCommentsEvenInAmbientDeclaration.ts | 8 ++++++++ tests/cases/compiler/doNotEmitTripleSlashComments.ts | 7 +++++++ ...tTripleSlashCommentsButPreserveDetachComments1.ts | 11 +++++++++++ ...tTripleSlashCommentsButPreserveDetachComments2.ts | 12 ++++++++++++ ...tTripleSlashCommentsButPreserveDetachComments3.ts | 10 ++++++++++ ...mitTripleSlashCommentsEvenInAmbientDeclaration.ts | 8 ++++++++ 6 files changed, 56 insertions(+) create mode 100644 doNotEmitTripleSlashCommentsEvenInAmbientDeclaration.ts create mode 100644 tests/cases/compiler/doNotEmitTripleSlashComments.ts create mode 100644 tests/cases/compiler/doNotEmitTripleSlashCommentsButPreserveDetachComments1.ts create mode 100644 tests/cases/compiler/doNotEmitTripleSlashCommentsButPreserveDetachComments2.ts create mode 100644 tests/cases/compiler/doNotEmitTripleSlashCommentsButPreserveDetachComments3.ts create mode 100644 tests/cases/compiler/doNotEmitTripleSlashCommentsEvenInAmbientDeclaration.ts diff --git a/doNotEmitTripleSlashCommentsEvenInAmbientDeclaration.ts b/doNotEmitTripleSlashCommentsEvenInAmbientDeclaration.ts new file mode 100644 index 00000000000..3a89b600c66 --- /dev/null +++ b/doNotEmitTripleSlashCommentsEvenInAmbientDeclaration.ts @@ -0,0 +1,8 @@ +// @comments: false + +// @Filename: file0.ts + +// @Fileame: file1.ts + +/// +declare var OData: any; \ No newline at end of file diff --git a/tests/cases/compiler/doNotEmitTripleSlashComments.ts b/tests/cases/compiler/doNotEmitTripleSlashComments.ts new file mode 100644 index 00000000000..11e7dee5796 --- /dev/null +++ b/tests/cases/compiler/doNotEmitTripleSlashComments.ts @@ -0,0 +1,7 @@ +// @comments: false + +// @Filename: file0.ts + +// @Filename: file1.ts +/// +var OData: any; \ No newline at end of file diff --git a/tests/cases/compiler/doNotEmitTripleSlashCommentsButPreserveDetachComments1.ts b/tests/cases/compiler/doNotEmitTripleSlashCommentsButPreserveDetachComments1.ts new file mode 100644 index 00000000000..f511e75085b --- /dev/null +++ b/tests/cases/compiler/doNotEmitTripleSlashCommentsButPreserveDetachComments1.ts @@ -0,0 +1,11 @@ +// @comments: false + +// @Filename: file0.ts + +// @Filename: file1.ts + +// +// Copy Right comment +// + +/// diff --git a/tests/cases/compiler/doNotEmitTripleSlashCommentsButPreserveDetachComments2.ts b/tests/cases/compiler/doNotEmitTripleSlashCommentsButPreserveDetachComments2.ts new file mode 100644 index 00000000000..424c7374717 --- /dev/null +++ b/tests/cases/compiler/doNotEmitTripleSlashCommentsButPreserveDetachComments2.ts @@ -0,0 +1,12 @@ +// @comments: false + +// @Filename: file0.ts + +// @Filename: file1.ts + +// +// Copy Right comment +// + +/// +var x = 10; \ No newline at end of file diff --git a/tests/cases/compiler/doNotEmitTripleSlashCommentsButPreserveDetachComments3.ts b/tests/cases/compiler/doNotEmitTripleSlashCommentsButPreserveDetachComments3.ts new file mode 100644 index 00000000000..95f1bb4cbbb --- /dev/null +++ b/tests/cases/compiler/doNotEmitTripleSlashCommentsButPreserveDetachComments3.ts @@ -0,0 +1,10 @@ +// @comments: false + +// @Filename: file0.ts + +// @Filename: file1.ts + +// +// Copy Right comment +// +/// diff --git a/tests/cases/compiler/doNotEmitTripleSlashCommentsEvenInAmbientDeclaration.ts b/tests/cases/compiler/doNotEmitTripleSlashCommentsEvenInAmbientDeclaration.ts new file mode 100644 index 00000000000..99f6a292342 --- /dev/null +++ b/tests/cases/compiler/doNotEmitTripleSlashCommentsEvenInAmbientDeclaration.ts @@ -0,0 +1,8 @@ +// @comments: false + +// @Filename: file0.ts + +// @Filename: file1.ts + +/// +declare var OData: any; \ No newline at end of file From 87c1c6573c8489b0965155b611dc0323eef2bf1d Mon Sep 17 00:00:00 2001 From: Yui T Date: Wed, 15 Jul 2015 11:49:27 -0700 Subject: [PATCH 003/117] Only remove triple-slash when compilerOptions.removecomments is true --- src/compiler/emitter.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index fd0d4ad796e..ba781f4b060 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -6891,12 +6891,13 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi if (currentSourceFile.text.charCodeAt(comment.pos + 1) === CharacterCodes.asterisk) { return currentSourceFile.text.charCodeAt(comment.pos + 2) === CharacterCodes.exclamation; } + // Omit /// comment if compilerOptions.removeComments is true. // Verify this is /// comment, but do the regexp match only when we first can find /// in the comment text // so that we don't end up computing comment string and doing match for all // comments - else if (currentSourceFile.text.charCodeAt(comment.pos + 1) === CharacterCodes.slash && + if (!compilerOptions.removeComments && (currentSourceFile.text.charCodeAt(comment.pos + 1) === CharacterCodes.slash && comment.pos + 2 < comment.end && currentSourceFile.text.charCodeAt(comment.pos + 2) === CharacterCodes.slash && - currentSourceFile.text.substring(comment.pos, comment.end).match(fullTripleSlashReferencePathRegEx)) { + currentSourceFile.text.substring(comment.pos, comment.end).match(fullTripleSlashReferencePathRegEx))) { return true; } } From 675aa0242f1c45b7f65b250f3287ee8469d97af5 Mon Sep 17 00:00:00 2001 From: Yui T Date: Wed, 15 Jul 2015 15:02:18 -0700 Subject: [PATCH 004/117] Add more tests and update baselines --- .../reference/doNotEmitTripleSlashComments.js | 17 ++++++++++++++++ .../doNotEmitTripleSlashComments.symbols | 13 ++++++++++++ .../doNotEmitTripleSlashComments.types | 13 ++++++++++++ ...SlashCommentsButPreserveDetachComments1.js | 19 ++++++++++++++++++ ...CommentsButPreserveDetachComments1.symbols | 12 +++++++++++ ...shCommentsButPreserveDetachComments1.types | 12 +++++++++++ ...SlashCommentsButPreserveDetachComments2.js | 20 +++++++++++++++++++ ...CommentsButPreserveDetachComments2.symbols | 14 +++++++++++++ ...shCommentsButPreserveDetachComments2.types | 15 ++++++++++++++ ...SlashCommentsButPreserveDetachComments3.js | 15 ++++++++++++++ ...CommentsButPreserveDetachComments3.symbols | 11 ++++++++++ ...shCommentsButPreserveDetachComments3.types | 11 ++++++++++ ...leSlashCommentsEvenInAmbientDeclaration.js | 12 +++++++++++ ...shCommentsEvenInAmbientDeclaration.symbols | 10 ++++++++++ ...lashCommentsEvenInAmbientDeclaration.types | 10 ++++++++++ ...tEmitTripleSlashCommentsEvenInEmptyFile.js | 15 ++++++++++++++ ...TripleSlashCommentsEvenInEmptyFile.symbols | 10 ++++++++++ ...itTripleSlashCommentsEvenInEmptyFile.types | 10 ++++++++++ .../compiler/doNotEmitTripleSlashComments.ts | 4 ++++ ...tEmitTripleSlashCommentsEvenInEmptyFile.ts | 10 ++++++++++ 20 files changed, 253 insertions(+) create mode 100644 tests/baselines/reference/doNotEmitTripleSlashComments.js create mode 100644 tests/baselines/reference/doNotEmitTripleSlashComments.symbols create mode 100644 tests/baselines/reference/doNotEmitTripleSlashComments.types create mode 100644 tests/baselines/reference/doNotEmitTripleSlashCommentsButPreserveDetachComments1.js create mode 100644 tests/baselines/reference/doNotEmitTripleSlashCommentsButPreserveDetachComments1.symbols create mode 100644 tests/baselines/reference/doNotEmitTripleSlashCommentsButPreserveDetachComments1.types create mode 100644 tests/baselines/reference/doNotEmitTripleSlashCommentsButPreserveDetachComments2.js create mode 100644 tests/baselines/reference/doNotEmitTripleSlashCommentsButPreserveDetachComments2.symbols create mode 100644 tests/baselines/reference/doNotEmitTripleSlashCommentsButPreserveDetachComments2.types create mode 100644 tests/baselines/reference/doNotEmitTripleSlashCommentsButPreserveDetachComments3.js create mode 100644 tests/baselines/reference/doNotEmitTripleSlashCommentsButPreserveDetachComments3.symbols create mode 100644 tests/baselines/reference/doNotEmitTripleSlashCommentsButPreserveDetachComments3.types create mode 100644 tests/baselines/reference/doNotEmitTripleSlashCommentsEvenInAmbientDeclaration.js create mode 100644 tests/baselines/reference/doNotEmitTripleSlashCommentsEvenInAmbientDeclaration.symbols create mode 100644 tests/baselines/reference/doNotEmitTripleSlashCommentsEvenInAmbientDeclaration.types create mode 100644 tests/baselines/reference/doNotEmitTripleSlashCommentsEvenInEmptyFile.js create mode 100644 tests/baselines/reference/doNotEmitTripleSlashCommentsEvenInEmptyFile.symbols create mode 100644 tests/baselines/reference/doNotEmitTripleSlashCommentsEvenInEmptyFile.types create mode 100644 tests/cases/compiler/doNotEmitTripleSlashCommentsEvenInEmptyFile.ts diff --git a/tests/baselines/reference/doNotEmitTripleSlashComments.js b/tests/baselines/reference/doNotEmitTripleSlashComments.js new file mode 100644 index 00000000000..42d48f62b23 --- /dev/null +++ b/tests/baselines/reference/doNotEmitTripleSlashComments.js @@ -0,0 +1,17 @@ +//// [tests/cases/compiler/doNotEmitTripleSlashComments.ts] //// + +//// [file0.ts] + + +//// [file2.ts] + +//// [file1.ts] +/// +/// +/// +var OData: any; + +//// [file0.js] +//// [file2.js] +//// [file1.js] +var OData; diff --git a/tests/baselines/reference/doNotEmitTripleSlashComments.symbols b/tests/baselines/reference/doNotEmitTripleSlashComments.symbols new file mode 100644 index 00000000000..7dfcc026914 --- /dev/null +++ b/tests/baselines/reference/doNotEmitTripleSlashComments.symbols @@ -0,0 +1,13 @@ +=== tests/cases/compiler/file1.ts === +/// +/// +/// +var OData: any; +>OData : Symbol(OData, Decl(file1.ts, 3, 3)) + +=== tests/cases/compiler/file0.ts === + +No type information for this code. +No type information for this code.=== tests/cases/compiler/file2.ts === + +No type information for this code. \ No newline at end of file diff --git a/tests/baselines/reference/doNotEmitTripleSlashComments.types b/tests/baselines/reference/doNotEmitTripleSlashComments.types new file mode 100644 index 00000000000..51316501655 --- /dev/null +++ b/tests/baselines/reference/doNotEmitTripleSlashComments.types @@ -0,0 +1,13 @@ +=== tests/cases/compiler/file1.ts === +/// +/// +/// +var OData: any; +>OData : any + +=== tests/cases/compiler/file0.ts === + +No type information for this code. +No type information for this code.=== tests/cases/compiler/file2.ts === + +No type information for this code. \ No newline at end of file diff --git a/tests/baselines/reference/doNotEmitTripleSlashCommentsButPreserveDetachComments1.js b/tests/baselines/reference/doNotEmitTripleSlashCommentsButPreserveDetachComments1.js new file mode 100644 index 00000000000..1319052ee92 --- /dev/null +++ b/tests/baselines/reference/doNotEmitTripleSlashCommentsButPreserveDetachComments1.js @@ -0,0 +1,19 @@ +//// [tests/cases/compiler/doNotEmitTripleSlashCommentsButPreserveDetachComments1.ts] //// + +//// [file0.ts] + + +//// [file1.ts] + +// +// Copy Right comment +// + +/// + + +//// [file0.js] +//// [file1.js] +// +// Copy Right comment +// diff --git a/tests/baselines/reference/doNotEmitTripleSlashCommentsButPreserveDetachComments1.symbols b/tests/baselines/reference/doNotEmitTripleSlashCommentsButPreserveDetachComments1.symbols new file mode 100644 index 00000000000..2928e218121 --- /dev/null +++ b/tests/baselines/reference/doNotEmitTripleSlashCommentsButPreserveDetachComments1.symbols @@ -0,0 +1,12 @@ +=== tests/cases/compiler/file1.ts === + +No type information for this code.// +No type information for this code.// Copy Right comment +No type information for this code.// +No type information for this code. +No type information for this code./// +No type information for this code. +No type information for this code.=== tests/cases/compiler/file0.ts === + +No type information for this code. +No type information for this code. \ No newline at end of file diff --git a/tests/baselines/reference/doNotEmitTripleSlashCommentsButPreserveDetachComments1.types b/tests/baselines/reference/doNotEmitTripleSlashCommentsButPreserveDetachComments1.types new file mode 100644 index 00000000000..2928e218121 --- /dev/null +++ b/tests/baselines/reference/doNotEmitTripleSlashCommentsButPreserveDetachComments1.types @@ -0,0 +1,12 @@ +=== tests/cases/compiler/file1.ts === + +No type information for this code.// +No type information for this code.// Copy Right comment +No type information for this code.// +No type information for this code. +No type information for this code./// +No type information for this code. +No type information for this code.=== tests/cases/compiler/file0.ts === + +No type information for this code. +No type information for this code. \ No newline at end of file diff --git a/tests/baselines/reference/doNotEmitTripleSlashCommentsButPreserveDetachComments2.js b/tests/baselines/reference/doNotEmitTripleSlashCommentsButPreserveDetachComments2.js new file mode 100644 index 00000000000..753abd0e3b0 --- /dev/null +++ b/tests/baselines/reference/doNotEmitTripleSlashCommentsButPreserveDetachComments2.js @@ -0,0 +1,20 @@ +//// [tests/cases/compiler/doNotEmitTripleSlashCommentsButPreserveDetachComments2.ts] //// + +//// [file0.ts] + + +//// [file1.ts] + +// +// Copy Right comment +// + +/// +var x = 10; + +//// [file0.js] +//// [file1.js] +// +// Copy Right comment +// +var x = 10; diff --git a/tests/baselines/reference/doNotEmitTripleSlashCommentsButPreserveDetachComments2.symbols b/tests/baselines/reference/doNotEmitTripleSlashCommentsButPreserveDetachComments2.symbols new file mode 100644 index 00000000000..6df1bcf1b7c --- /dev/null +++ b/tests/baselines/reference/doNotEmitTripleSlashCommentsButPreserveDetachComments2.symbols @@ -0,0 +1,14 @@ +=== tests/cases/compiler/file1.ts === + +// +// Copy Right comment +// + +/// +var x = 10; +>x : Symbol(x, Decl(file1.ts, 6, 3)) + +=== tests/cases/compiler/file0.ts === + +No type information for this code. +No type information for this code. \ No newline at end of file diff --git a/tests/baselines/reference/doNotEmitTripleSlashCommentsButPreserveDetachComments2.types b/tests/baselines/reference/doNotEmitTripleSlashCommentsButPreserveDetachComments2.types new file mode 100644 index 00000000000..0058d1a4028 --- /dev/null +++ b/tests/baselines/reference/doNotEmitTripleSlashCommentsButPreserveDetachComments2.types @@ -0,0 +1,15 @@ +=== tests/cases/compiler/file1.ts === + +// +// Copy Right comment +// + +/// +var x = 10; +>x : number +>10 : number + +=== tests/cases/compiler/file0.ts === + +No type information for this code. +No type information for this code. \ No newline at end of file diff --git a/tests/baselines/reference/doNotEmitTripleSlashCommentsButPreserveDetachComments3.js b/tests/baselines/reference/doNotEmitTripleSlashCommentsButPreserveDetachComments3.js new file mode 100644 index 00000000000..b1353fa92b2 --- /dev/null +++ b/tests/baselines/reference/doNotEmitTripleSlashCommentsButPreserveDetachComments3.js @@ -0,0 +1,15 @@ +//// [tests/cases/compiler/doNotEmitTripleSlashCommentsButPreserveDetachComments3.ts] //// + +//// [file0.ts] + + +//// [file1.ts] + +// +// Copy Right comment +// +/// + + +//// [file0.js] +//// [file1.js] diff --git a/tests/baselines/reference/doNotEmitTripleSlashCommentsButPreserveDetachComments3.symbols b/tests/baselines/reference/doNotEmitTripleSlashCommentsButPreserveDetachComments3.symbols new file mode 100644 index 00000000000..b5f22abf23b --- /dev/null +++ b/tests/baselines/reference/doNotEmitTripleSlashCommentsButPreserveDetachComments3.symbols @@ -0,0 +1,11 @@ +=== tests/cases/compiler/file1.ts === + +No type information for this code.// +No type information for this code.// Copy Right comment +No type information for this code.// +No type information for this code./// +No type information for this code. +No type information for this code.=== tests/cases/compiler/file0.ts === + +No type information for this code. +No type information for this code. \ No newline at end of file diff --git a/tests/baselines/reference/doNotEmitTripleSlashCommentsButPreserveDetachComments3.types b/tests/baselines/reference/doNotEmitTripleSlashCommentsButPreserveDetachComments3.types new file mode 100644 index 00000000000..b5f22abf23b --- /dev/null +++ b/tests/baselines/reference/doNotEmitTripleSlashCommentsButPreserveDetachComments3.types @@ -0,0 +1,11 @@ +=== tests/cases/compiler/file1.ts === + +No type information for this code.// +No type information for this code.// Copy Right comment +No type information for this code.// +No type information for this code./// +No type information for this code. +No type information for this code.=== tests/cases/compiler/file0.ts === + +No type information for this code. +No type information for this code. \ No newline at end of file diff --git a/tests/baselines/reference/doNotEmitTripleSlashCommentsEvenInAmbientDeclaration.js b/tests/baselines/reference/doNotEmitTripleSlashCommentsEvenInAmbientDeclaration.js new file mode 100644 index 00000000000..bf69047bce0 --- /dev/null +++ b/tests/baselines/reference/doNotEmitTripleSlashCommentsEvenInAmbientDeclaration.js @@ -0,0 +1,12 @@ +//// [tests/cases/compiler/doNotEmitTripleSlashCommentsEvenInAmbientDeclaration.ts] //// + +//// [file0.ts] + + +//// [file1.ts] + +/// +declare var OData: any; + +//// [file0.js] +//// [file1.js] diff --git a/tests/baselines/reference/doNotEmitTripleSlashCommentsEvenInAmbientDeclaration.symbols b/tests/baselines/reference/doNotEmitTripleSlashCommentsEvenInAmbientDeclaration.symbols new file mode 100644 index 00000000000..f3566dc7e33 --- /dev/null +++ b/tests/baselines/reference/doNotEmitTripleSlashCommentsEvenInAmbientDeclaration.symbols @@ -0,0 +1,10 @@ +=== tests/cases/compiler/file1.ts === + +/// +declare var OData: any; +>OData : Symbol(OData, Decl(file1.ts, 2, 11)) + +=== tests/cases/compiler/file0.ts === + +No type information for this code. +No type information for this code. \ No newline at end of file diff --git a/tests/baselines/reference/doNotEmitTripleSlashCommentsEvenInAmbientDeclaration.types b/tests/baselines/reference/doNotEmitTripleSlashCommentsEvenInAmbientDeclaration.types new file mode 100644 index 00000000000..37ae645a302 --- /dev/null +++ b/tests/baselines/reference/doNotEmitTripleSlashCommentsEvenInAmbientDeclaration.types @@ -0,0 +1,10 @@ +=== tests/cases/compiler/file1.ts === + +/// +declare var OData: any; +>OData : any + +=== tests/cases/compiler/file0.ts === + +No type information for this code. +No type information for this code. \ No newline at end of file diff --git a/tests/baselines/reference/doNotEmitTripleSlashCommentsEvenInEmptyFile.js b/tests/baselines/reference/doNotEmitTripleSlashCommentsEvenInEmptyFile.js new file mode 100644 index 00000000000..55dd71c6f09 --- /dev/null +++ b/tests/baselines/reference/doNotEmitTripleSlashCommentsEvenInEmptyFile.js @@ -0,0 +1,15 @@ +//// [tests/cases/compiler/doNotEmitTripleSlashCommentsEvenInEmptyFile.ts] //// + +//// [file0.ts] + + +//// [file2.ts] + +//// [file1.ts] +/// +/// +/// + +//// [file0.js] +//// [file2.js] +//// [file1.js] diff --git a/tests/baselines/reference/doNotEmitTripleSlashCommentsEvenInEmptyFile.symbols b/tests/baselines/reference/doNotEmitTripleSlashCommentsEvenInEmptyFile.symbols new file mode 100644 index 00000000000..7993a31b91e --- /dev/null +++ b/tests/baselines/reference/doNotEmitTripleSlashCommentsEvenInEmptyFile.symbols @@ -0,0 +1,10 @@ +=== tests/cases/compiler/file1.ts === +/// +No type information for this code./// +No type information for this code./// +No type information for this code.=== tests/cases/compiler/file0.ts === + +No type information for this code. +No type information for this code.=== tests/cases/compiler/file2.ts === + +No type information for this code. \ No newline at end of file diff --git a/tests/baselines/reference/doNotEmitTripleSlashCommentsEvenInEmptyFile.types b/tests/baselines/reference/doNotEmitTripleSlashCommentsEvenInEmptyFile.types new file mode 100644 index 00000000000..7993a31b91e --- /dev/null +++ b/tests/baselines/reference/doNotEmitTripleSlashCommentsEvenInEmptyFile.types @@ -0,0 +1,10 @@ +=== tests/cases/compiler/file1.ts === +/// +No type information for this code./// +No type information for this code./// +No type information for this code.=== tests/cases/compiler/file0.ts === + +No type information for this code. +No type information for this code.=== tests/cases/compiler/file2.ts === + +No type information for this code. \ No newline at end of file diff --git a/tests/cases/compiler/doNotEmitTripleSlashComments.ts b/tests/cases/compiler/doNotEmitTripleSlashComments.ts index 11e7dee5796..e89586acfa0 100644 --- a/tests/cases/compiler/doNotEmitTripleSlashComments.ts +++ b/tests/cases/compiler/doNotEmitTripleSlashComments.ts @@ -2,6 +2,10 @@ // @Filename: file0.ts +// @Filename: file2.ts + // @Filename: file1.ts /// +/// +/// var OData: any; \ No newline at end of file diff --git a/tests/cases/compiler/doNotEmitTripleSlashCommentsEvenInEmptyFile.ts b/tests/cases/compiler/doNotEmitTripleSlashCommentsEvenInEmptyFile.ts new file mode 100644 index 00000000000..41ca8dcab22 --- /dev/null +++ b/tests/cases/compiler/doNotEmitTripleSlashCommentsEvenInEmptyFile.ts @@ -0,0 +1,10 @@ +// @comments: false + +// @Filename: file0.ts + +// @Filename: file2.ts + +// @Filename: file1.ts +/// +/// +/// \ No newline at end of file From d11fc480665ada08f13767c2d5e8939a570feb88 Mon Sep 17 00:00:00 2001 From: Yui T Date: Mon, 20 Jul 2015 09:55:04 -0700 Subject: [PATCH 005/117] Only remove triple-slash if it is not at top of file --- src/compiler/emitter.ts | 80 +++++++++++++++++++++++---------------- src/compiler/scanner.ts | 8 ++-- src/compiler/utilities.ts | 1 + 3 files changed, 54 insertions(+), 35 deletions(-) diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index ba781f4b060..16ad4e2e206 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -6759,17 +6759,48 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi return leadingComments; } - function filterComments(ranges: CommentRange[], onlyPinnedOrTripleSlashComments: boolean): CommentRange[] { - // If we're removing comments, then we want to strip out all but the pinned or - // triple slash comments. - if (ranges && onlyPinnedOrTripleSlashComments) { - ranges = filter(ranges, isPinnedOrTripleSlashComment); - if (ranges.length === 0) { - return undefined; - } - } + function filterComments(ranges: CommentRange[], removeComments: boolean, isTopOfFileComments: boolean): CommentRange[] { + // If removeComments flag is false, then do not filter out any comment + if (!removeComments || !ranges) return ranges; - return ranges; + // IF removeComments flag is true, then filter out comment by following: + // - Pinned comments : keep all + // - /// comments : keep it if the comments are at the top of the file otherwise remove + // - normal comments: remove all + if (removeComments) { + if (isTopOfFileComments) { + ranges = filter(ranges, isTripleSlashOrPinnedComments); + } + else { + ranges = filter(ranges, isPinnedComments); + } + return ranges.length === 0 ? undefined : ranges; + } + } + + function isPinnedComments(comment: CommentRange) { + if (currentSourceFile.text.charCodeAt(comment.pos + 1) === CharacterCodes.asterisk) { + return currentSourceFile.text.charCodeAt(comment.pos + 2) === CharacterCodes.exclamation; + } + } + + /** + * Determine if the given comment is a triple-slash or pinned comment + * + * @return true if the comment is a triple-slash comment at the top of the file or a pinned comment else false + **/ + function isTripleSlashOrPinnedComments(comment: CommentRange) { + // Verify this is /// comment, but do the regexp match only when we first can find /// in the comment text + // so that we don't end up computing comment string and doing match for all // comments + if (currentSourceFile.text.charCodeAt(comment.pos + 1) === CharacterCodes.slash && + comment.pos + 2 < comment.end && + currentSourceFile.text.charCodeAt(comment.pos + 2) === CharacterCodes.slash) { + let textSubStr = currentSourceFile.text.substring(comment.pos, comment.end); + return textSubStr.match(fullTripleSlashReferencePathRegEx) || + textSubStr.match(fullTripleSlashAMDReferencePathRegEx) ? + true : false; + } + return isPinnedComments(comment); } function getLeadingCommentsToEmit(node: Node) { @@ -6798,27 +6829,27 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi } function emitOnlyPinnedOrTripleSlashComments(node: Node) { - emitLeadingCommentsWorker(node, /*onlyPinnedOrTripleSlashComments:*/ true); + emitLeadingCommentsWorker(node, /*removeComments:*/ true); } function emitLeadingComments(node: Node) { - return emitLeadingCommentsWorker(node, /*onlyPinnedOrTripleSlashComments:*/ compilerOptions.removeComments); + return emitLeadingCommentsWorker(node, compilerOptions.removeComments); } - function emitLeadingCommentsWorker(node: Node, onlyPinnedOrTripleSlashComments: boolean) { + function emitLeadingCommentsWorker(node: Node, removeComments: boolean) { // If the caller only wants pinned or triple slash comments, then always filter // down to that set. Otherwise, filter based on the current compiler options. - let leadingComments = filterComments(getLeadingCommentsToEmit(node), onlyPinnedOrTripleSlashComments); + let leadingComments = filterComments(getLeadingCommentsToEmit(node), /*removeComments:*/ removeComments, /*isTopOfFileComments:*/ node.pos === 0); emitNewLineBeforeLeadingComments(currentSourceFile, writer, node, leadingComments); // Leading comments are emitted at /*leading comment1 */space/*leading comment*/space - emitComments(currentSourceFile, writer, leadingComments, /*trailingSeparator*/ true, newLine, writeComment); + emitComments(currentSourceFile, writer, leadingComments, /*trailingSeparator:*/ true, newLine, writeComment); } function emitTrailingComments(node: Node) { // Emit the trailing comments only if the parent's end doesn't match - let trailingComments = filterComments(getTrailingCommentsToEmit(node), /*onlyPinnedOrTripleSlashComments:*/ compilerOptions.removeComments); + let trailingComments = filterComments(getTrailingCommentsToEmit(node), /*removeComments*/ compilerOptions.removeComments, /*isTopOfFileComments:*/ node.pos === 0); // trailing comments are emitted at space/*trailing comment1 */space/*trailing comment*/ emitComments(currentSourceFile, writer, trailingComments, /*trailingSeparator*/ false, newLine, writeComment); @@ -6835,7 +6866,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi leadingComments = getLeadingCommentRanges(currentSourceFile.text, pos); } - leadingComments = filterComments(leadingComments, compilerOptions.removeComments); + leadingComments = filterComments(leadingComments, /*removeComments:*/ compilerOptions.removeComments, pos === 0); emitNewLineBeforeLeadingComments(currentSourceFile, writer, { pos: pos, end: pos }, leadingComments); // Leading comments are emitted at /*leading comment1 */space/*leading comment*/space @@ -6886,21 +6917,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi } } } - - function isPinnedOrTripleSlashComment(comment: CommentRange) { - if (currentSourceFile.text.charCodeAt(comment.pos + 1) === CharacterCodes.asterisk) { - return currentSourceFile.text.charCodeAt(comment.pos + 2) === CharacterCodes.exclamation; - } - // Omit /// comment if compilerOptions.removeComments is true. - // Verify this is /// comment, but do the regexp match only when we first can find /// in the comment text - // so that we don't end up computing comment string and doing match for all // comments - if (!compilerOptions.removeComments && (currentSourceFile.text.charCodeAt(comment.pos + 1) === CharacterCodes.slash && - comment.pos + 2 < comment.end && - currentSourceFile.text.charCodeAt(comment.pos + 2) === CharacterCodes.slash && - currentSourceFile.text.substring(comment.pos, comment.end).match(fullTripleSlashReferencePathRegEx))) { - return true; - } - } } function emitFile(jsFilePath: string, sourceFile?: SourceFile) { diff --git a/src/compiler/scanner.ts b/src/compiler/scanner.ts index a30e23f6170..69090f7bf7f 100644 --- a/src/compiler/scanner.ts +++ b/src/compiler/scanner.ts @@ -532,9 +532,11 @@ namespace ts { // false, whitespace is skipped until the first line break and comments between that location // and the next token are returned.If trailing is true, comments occurring between the given // position and the next line break are returned.The return value is an array containing a - // TextRange for each comment. Single-line comment ranges include the beginning '//' characters - // but not the ending line break. Multi - line comment ranges include the beginning '/* and - // ending '*/' characters.The return value is undefined if no comments were found. + // TextRange for each comment. + // + // Single - line comment ranges include the beginning '//' characters but not the ending line break. + // Multi - line comment ranges include the beginning '/* and ending '*/' characters. + // The return value is undefined if no comments were found. function getCommentRanges(text: string, pos: number, trailing: boolean): CommentRange[] { let result: CommentRange[]; let collecting = trailing || pos === 0; diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index 5174589cdcf..437b6ecaf81 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -409,6 +409,7 @@ namespace ts { } export let fullTripleSlashReferencePathRegEx = /^(\/\/\/\s*/; + export let fullTripleSlashAMDReferencePathRegEx = /^(\/\/\/\s*/; export function isTypeNode(node: Node): boolean { if (SyntaxKind.FirstTypeNode <= node.kind && node.kind <= SyntaxKind.LastTypeNode) { From ed5bc319cbdab912fd388baaa331ccc0218d9930 Mon Sep 17 00:00:00 2001 From: Yui T Date: Mon, 20 Jul 2015 09:55:28 -0700 Subject: [PATCH 006/117] Update tests and baselines --- ...SlashCommentsButPreserveDetachComments1.js | 19 ------------------ ...CommentsButPreserveDetachComments1.symbols | 12 ----------- ...shCommentsButPreserveDetachComments1.types | 12 ----------- ...SlashCommentsButPreserveDetachComments2.js | 20 ------------------- ...CommentsButPreserveDetachComments2.symbols | 14 ------------- ...shCommentsButPreserveDetachComments2.types | 15 -------------- ...SlashCommentsButPreserveDetachComments3.js | 15 -------------- ...CommentsButPreserveDetachComments3.symbols | 11 ---------- ...shCommentsButPreserveDetachComments3.types | 11 ---------- ...leSlashCommentsEvenInAmbientDeclaration.js | 12 ----------- ...doNotEmitTripleSlashCommentsInTheMiddle.js | 16 +++++++++++++++ ...EmitTripleSlashCommentsInTheMiddle.symbols | 13 ++++++++++++ ...otEmitTripleSlashCommentsInTheMiddle.types | 15 ++++++++++++++ ...Comments.js => emitTripleSlashComments.js} | 5 ++++- ...ymbols => emitTripleSlashComments.symbols} | 0 ...ts.types => emitTripleSlashComments.types} | 0 ...leSlashCommentsEvenInAmbientDeclaration.js | 13 ++++++++++++ ...hCommentsEvenInAmbientDeclaration.symbols} | 0 ...ashCommentsEvenInAmbientDeclaration.types} | 0 ...emitTripleSlashCommentsEvenInEmptyFile.js} | 5 ++++- ...ripleSlashCommentsEvenInEmptyFile.symbols} | 0 ...tTripleSlashCommentsEvenInEmptyFile.types} | 0 ...SlashCommentsButPreserveDetachComments1.ts | 11 ---------- ...SlashCommentsButPreserveDetachComments2.ts | 12 ----------- ...SlashCommentsButPreserveDetachComments3.ts | 10 ---------- ...doNotEmitTripleSlashCommentsInTheMiddle.ts | 9 +++++++++ ...Comments.ts => emitTripleSlashComments.ts} | 0 ...eSlashCommentsEvenInAmbientDeclaration.ts} | 0 ...emitTripleSlashCommentsEvenInEmptyFile.ts} | 0 29 files changed, 74 insertions(+), 176 deletions(-) delete mode 100644 tests/baselines/reference/doNotEmitTripleSlashCommentsButPreserveDetachComments1.js delete mode 100644 tests/baselines/reference/doNotEmitTripleSlashCommentsButPreserveDetachComments1.symbols delete mode 100644 tests/baselines/reference/doNotEmitTripleSlashCommentsButPreserveDetachComments1.types delete mode 100644 tests/baselines/reference/doNotEmitTripleSlashCommentsButPreserveDetachComments2.js delete mode 100644 tests/baselines/reference/doNotEmitTripleSlashCommentsButPreserveDetachComments2.symbols delete mode 100644 tests/baselines/reference/doNotEmitTripleSlashCommentsButPreserveDetachComments2.types delete mode 100644 tests/baselines/reference/doNotEmitTripleSlashCommentsButPreserveDetachComments3.js delete mode 100644 tests/baselines/reference/doNotEmitTripleSlashCommentsButPreserveDetachComments3.symbols delete mode 100644 tests/baselines/reference/doNotEmitTripleSlashCommentsButPreserveDetachComments3.types delete mode 100644 tests/baselines/reference/doNotEmitTripleSlashCommentsEvenInAmbientDeclaration.js create mode 100644 tests/baselines/reference/doNotEmitTripleSlashCommentsInTheMiddle.js create mode 100644 tests/baselines/reference/doNotEmitTripleSlashCommentsInTheMiddle.symbols create mode 100644 tests/baselines/reference/doNotEmitTripleSlashCommentsInTheMiddle.types rename tests/baselines/reference/{doNotEmitTripleSlashComments.js => emitTripleSlashComments.js} (55%) rename tests/baselines/reference/{doNotEmitTripleSlashComments.symbols => emitTripleSlashComments.symbols} (100%) rename tests/baselines/reference/{doNotEmitTripleSlashComments.types => emitTripleSlashComments.types} (100%) create mode 100644 tests/baselines/reference/emitTripleSlashCommentsEvenInAmbientDeclaration.js rename tests/baselines/reference/{doNotEmitTripleSlashCommentsEvenInAmbientDeclaration.symbols => emitTripleSlashCommentsEvenInAmbientDeclaration.symbols} (100%) rename tests/baselines/reference/{doNotEmitTripleSlashCommentsEvenInAmbientDeclaration.types => emitTripleSlashCommentsEvenInAmbientDeclaration.types} (100%) rename tests/baselines/reference/{doNotEmitTripleSlashCommentsEvenInEmptyFile.js => emitTripleSlashCommentsEvenInEmptyFile.js} (51%) rename tests/baselines/reference/{doNotEmitTripleSlashCommentsEvenInEmptyFile.symbols => emitTripleSlashCommentsEvenInEmptyFile.symbols} (100%) rename tests/baselines/reference/{doNotEmitTripleSlashCommentsEvenInEmptyFile.types => emitTripleSlashCommentsEvenInEmptyFile.types} (100%) delete mode 100644 tests/cases/compiler/doNotEmitTripleSlashCommentsButPreserveDetachComments1.ts delete mode 100644 tests/cases/compiler/doNotEmitTripleSlashCommentsButPreserveDetachComments2.ts delete mode 100644 tests/cases/compiler/doNotEmitTripleSlashCommentsButPreserveDetachComments3.ts create mode 100644 tests/cases/compiler/doNotEmitTripleSlashCommentsInTheMiddle.ts rename tests/cases/compiler/{doNotEmitTripleSlashComments.ts => emitTripleSlashComments.ts} (100%) rename tests/cases/compiler/{doNotEmitTripleSlashCommentsEvenInAmbientDeclaration.ts => emitTripleSlashCommentsEvenInAmbientDeclaration.ts} (100%) rename tests/cases/compiler/{doNotEmitTripleSlashCommentsEvenInEmptyFile.ts => emitTripleSlashCommentsEvenInEmptyFile.ts} (100%) diff --git a/tests/baselines/reference/doNotEmitTripleSlashCommentsButPreserveDetachComments1.js b/tests/baselines/reference/doNotEmitTripleSlashCommentsButPreserveDetachComments1.js deleted file mode 100644 index 1319052ee92..00000000000 --- a/tests/baselines/reference/doNotEmitTripleSlashCommentsButPreserveDetachComments1.js +++ /dev/null @@ -1,19 +0,0 @@ -//// [tests/cases/compiler/doNotEmitTripleSlashCommentsButPreserveDetachComments1.ts] //// - -//// [file0.ts] - - -//// [file1.ts] - -// -// Copy Right comment -// - -/// - - -//// [file0.js] -//// [file1.js] -// -// Copy Right comment -// diff --git a/tests/baselines/reference/doNotEmitTripleSlashCommentsButPreserveDetachComments1.symbols b/tests/baselines/reference/doNotEmitTripleSlashCommentsButPreserveDetachComments1.symbols deleted file mode 100644 index 2928e218121..00000000000 --- a/tests/baselines/reference/doNotEmitTripleSlashCommentsButPreserveDetachComments1.symbols +++ /dev/null @@ -1,12 +0,0 @@ -=== tests/cases/compiler/file1.ts === - -No type information for this code.// -No type information for this code.// Copy Right comment -No type information for this code.// -No type information for this code. -No type information for this code./// -No type information for this code. -No type information for this code.=== tests/cases/compiler/file0.ts === - -No type information for this code. -No type information for this code. \ No newline at end of file diff --git a/tests/baselines/reference/doNotEmitTripleSlashCommentsButPreserveDetachComments1.types b/tests/baselines/reference/doNotEmitTripleSlashCommentsButPreserveDetachComments1.types deleted file mode 100644 index 2928e218121..00000000000 --- a/tests/baselines/reference/doNotEmitTripleSlashCommentsButPreserveDetachComments1.types +++ /dev/null @@ -1,12 +0,0 @@ -=== tests/cases/compiler/file1.ts === - -No type information for this code.// -No type information for this code.// Copy Right comment -No type information for this code.// -No type information for this code. -No type information for this code./// -No type information for this code. -No type information for this code.=== tests/cases/compiler/file0.ts === - -No type information for this code. -No type information for this code. \ No newline at end of file diff --git a/tests/baselines/reference/doNotEmitTripleSlashCommentsButPreserveDetachComments2.js b/tests/baselines/reference/doNotEmitTripleSlashCommentsButPreserveDetachComments2.js deleted file mode 100644 index 753abd0e3b0..00000000000 --- a/tests/baselines/reference/doNotEmitTripleSlashCommentsButPreserveDetachComments2.js +++ /dev/null @@ -1,20 +0,0 @@ -//// [tests/cases/compiler/doNotEmitTripleSlashCommentsButPreserveDetachComments2.ts] //// - -//// [file0.ts] - - -//// [file1.ts] - -// -// Copy Right comment -// - -/// -var x = 10; - -//// [file0.js] -//// [file1.js] -// -// Copy Right comment -// -var x = 10; diff --git a/tests/baselines/reference/doNotEmitTripleSlashCommentsButPreserveDetachComments2.symbols b/tests/baselines/reference/doNotEmitTripleSlashCommentsButPreserveDetachComments2.symbols deleted file mode 100644 index 6df1bcf1b7c..00000000000 --- a/tests/baselines/reference/doNotEmitTripleSlashCommentsButPreserveDetachComments2.symbols +++ /dev/null @@ -1,14 +0,0 @@ -=== tests/cases/compiler/file1.ts === - -// -// Copy Right comment -// - -/// -var x = 10; ->x : Symbol(x, Decl(file1.ts, 6, 3)) - -=== tests/cases/compiler/file0.ts === - -No type information for this code. -No type information for this code. \ No newline at end of file diff --git a/tests/baselines/reference/doNotEmitTripleSlashCommentsButPreserveDetachComments2.types b/tests/baselines/reference/doNotEmitTripleSlashCommentsButPreserveDetachComments2.types deleted file mode 100644 index 0058d1a4028..00000000000 --- a/tests/baselines/reference/doNotEmitTripleSlashCommentsButPreserveDetachComments2.types +++ /dev/null @@ -1,15 +0,0 @@ -=== tests/cases/compiler/file1.ts === - -// -// Copy Right comment -// - -/// -var x = 10; ->x : number ->10 : number - -=== tests/cases/compiler/file0.ts === - -No type information for this code. -No type information for this code. \ No newline at end of file diff --git a/tests/baselines/reference/doNotEmitTripleSlashCommentsButPreserveDetachComments3.js b/tests/baselines/reference/doNotEmitTripleSlashCommentsButPreserveDetachComments3.js deleted file mode 100644 index b1353fa92b2..00000000000 --- a/tests/baselines/reference/doNotEmitTripleSlashCommentsButPreserveDetachComments3.js +++ /dev/null @@ -1,15 +0,0 @@ -//// [tests/cases/compiler/doNotEmitTripleSlashCommentsButPreserveDetachComments3.ts] //// - -//// [file0.ts] - - -//// [file1.ts] - -// -// Copy Right comment -// -/// - - -//// [file0.js] -//// [file1.js] diff --git a/tests/baselines/reference/doNotEmitTripleSlashCommentsButPreserveDetachComments3.symbols b/tests/baselines/reference/doNotEmitTripleSlashCommentsButPreserveDetachComments3.symbols deleted file mode 100644 index b5f22abf23b..00000000000 --- a/tests/baselines/reference/doNotEmitTripleSlashCommentsButPreserveDetachComments3.symbols +++ /dev/null @@ -1,11 +0,0 @@ -=== tests/cases/compiler/file1.ts === - -No type information for this code.// -No type information for this code.// Copy Right comment -No type information for this code.// -No type information for this code./// -No type information for this code. -No type information for this code.=== tests/cases/compiler/file0.ts === - -No type information for this code. -No type information for this code. \ No newline at end of file diff --git a/tests/baselines/reference/doNotEmitTripleSlashCommentsButPreserveDetachComments3.types b/tests/baselines/reference/doNotEmitTripleSlashCommentsButPreserveDetachComments3.types deleted file mode 100644 index b5f22abf23b..00000000000 --- a/tests/baselines/reference/doNotEmitTripleSlashCommentsButPreserveDetachComments3.types +++ /dev/null @@ -1,11 +0,0 @@ -=== tests/cases/compiler/file1.ts === - -No type information for this code.// -No type information for this code.// Copy Right comment -No type information for this code.// -No type information for this code./// -No type information for this code. -No type information for this code.=== tests/cases/compiler/file0.ts === - -No type information for this code. -No type information for this code. \ No newline at end of file diff --git a/tests/baselines/reference/doNotEmitTripleSlashCommentsEvenInAmbientDeclaration.js b/tests/baselines/reference/doNotEmitTripleSlashCommentsEvenInAmbientDeclaration.js deleted file mode 100644 index bf69047bce0..00000000000 --- a/tests/baselines/reference/doNotEmitTripleSlashCommentsEvenInAmbientDeclaration.js +++ /dev/null @@ -1,12 +0,0 @@ -//// [tests/cases/compiler/doNotEmitTripleSlashCommentsEvenInAmbientDeclaration.ts] //// - -//// [file0.ts] - - -//// [file1.ts] - -/// -declare var OData: any; - -//// [file0.js] -//// [file1.js] diff --git a/tests/baselines/reference/doNotEmitTripleSlashCommentsInTheMiddle.js b/tests/baselines/reference/doNotEmitTripleSlashCommentsInTheMiddle.js new file mode 100644 index 00000000000..58a9e2caf66 --- /dev/null +++ b/tests/baselines/reference/doNotEmitTripleSlashCommentsInTheMiddle.js @@ -0,0 +1,16 @@ +//// [tests/cases/compiler/doNotEmitTripleSlashCommentsInTheMiddle.ts] //// + +//// [0.ts] + + +//// [1.ts] +/// +var x = 10; +/// +var y = 1000; + +//// [0.js] +//// [1.js] +/// +var x = 10; +var y = 1000; diff --git a/tests/baselines/reference/doNotEmitTripleSlashCommentsInTheMiddle.symbols b/tests/baselines/reference/doNotEmitTripleSlashCommentsInTheMiddle.symbols new file mode 100644 index 00000000000..353b90f3812 --- /dev/null +++ b/tests/baselines/reference/doNotEmitTripleSlashCommentsInTheMiddle.symbols @@ -0,0 +1,13 @@ +=== tests/cases/compiler/1.ts === +/// +var x = 10; +>x : Symbol(x, Decl(1.ts, 1, 3)) + +/// +var y = 1000; +>y : Symbol(y, Decl(1.ts, 3, 3)) + +=== tests/cases/compiler/0.ts === + +No type information for this code. +No type information for this code. \ No newline at end of file diff --git a/tests/baselines/reference/doNotEmitTripleSlashCommentsInTheMiddle.types b/tests/baselines/reference/doNotEmitTripleSlashCommentsInTheMiddle.types new file mode 100644 index 00000000000..e26f99fa1a7 --- /dev/null +++ b/tests/baselines/reference/doNotEmitTripleSlashCommentsInTheMiddle.types @@ -0,0 +1,15 @@ +=== tests/cases/compiler/1.ts === +/// +var x = 10; +>x : number +>10 : number + +/// +var y = 1000; +>y : number +>1000 : number + +=== tests/cases/compiler/0.ts === + +No type information for this code. +No type information for this code. \ No newline at end of file diff --git a/tests/baselines/reference/doNotEmitTripleSlashComments.js b/tests/baselines/reference/emitTripleSlashComments.js similarity index 55% rename from tests/baselines/reference/doNotEmitTripleSlashComments.js rename to tests/baselines/reference/emitTripleSlashComments.js index 42d48f62b23..ac86bc880f1 100644 --- a/tests/baselines/reference/doNotEmitTripleSlashComments.js +++ b/tests/baselines/reference/emitTripleSlashComments.js @@ -1,4 +1,4 @@ -//// [tests/cases/compiler/doNotEmitTripleSlashComments.ts] //// +//// [tests/cases/compiler/emitTripleSlashComments.ts] //// //// [file0.ts] @@ -14,4 +14,7 @@ var OData: any; //// [file0.js] //// [file2.js] //// [file1.js] +/// +/// +/// var OData; diff --git a/tests/baselines/reference/doNotEmitTripleSlashComments.symbols b/tests/baselines/reference/emitTripleSlashComments.symbols similarity index 100% rename from tests/baselines/reference/doNotEmitTripleSlashComments.symbols rename to tests/baselines/reference/emitTripleSlashComments.symbols diff --git a/tests/baselines/reference/doNotEmitTripleSlashComments.types b/tests/baselines/reference/emitTripleSlashComments.types similarity index 100% rename from tests/baselines/reference/doNotEmitTripleSlashComments.types rename to tests/baselines/reference/emitTripleSlashComments.types diff --git a/tests/baselines/reference/emitTripleSlashCommentsEvenInAmbientDeclaration.js b/tests/baselines/reference/emitTripleSlashCommentsEvenInAmbientDeclaration.js new file mode 100644 index 00000000000..2cc952a8f3a --- /dev/null +++ b/tests/baselines/reference/emitTripleSlashCommentsEvenInAmbientDeclaration.js @@ -0,0 +1,13 @@ +//// [tests/cases/compiler/emitTripleSlashCommentsEvenInAmbientDeclaration.ts] //// + +//// [file0.ts] + + +//// [file1.ts] + +/// +declare var OData: any; + +//// [file0.js] +//// [file1.js] +/// diff --git a/tests/baselines/reference/doNotEmitTripleSlashCommentsEvenInAmbientDeclaration.symbols b/tests/baselines/reference/emitTripleSlashCommentsEvenInAmbientDeclaration.symbols similarity index 100% rename from tests/baselines/reference/doNotEmitTripleSlashCommentsEvenInAmbientDeclaration.symbols rename to tests/baselines/reference/emitTripleSlashCommentsEvenInAmbientDeclaration.symbols diff --git a/tests/baselines/reference/doNotEmitTripleSlashCommentsEvenInAmbientDeclaration.types b/tests/baselines/reference/emitTripleSlashCommentsEvenInAmbientDeclaration.types similarity index 100% rename from tests/baselines/reference/doNotEmitTripleSlashCommentsEvenInAmbientDeclaration.types rename to tests/baselines/reference/emitTripleSlashCommentsEvenInAmbientDeclaration.types diff --git a/tests/baselines/reference/doNotEmitTripleSlashCommentsEvenInEmptyFile.js b/tests/baselines/reference/emitTripleSlashCommentsEvenInEmptyFile.js similarity index 51% rename from tests/baselines/reference/doNotEmitTripleSlashCommentsEvenInEmptyFile.js rename to tests/baselines/reference/emitTripleSlashCommentsEvenInEmptyFile.js index 55dd71c6f09..6a827528bec 100644 --- a/tests/baselines/reference/doNotEmitTripleSlashCommentsEvenInEmptyFile.js +++ b/tests/baselines/reference/emitTripleSlashCommentsEvenInEmptyFile.js @@ -1,4 +1,4 @@ -//// [tests/cases/compiler/doNotEmitTripleSlashCommentsEvenInEmptyFile.ts] //// +//// [tests/cases/compiler/emitTripleSlashCommentsEvenInEmptyFile.ts] //// //// [file0.ts] @@ -13,3 +13,6 @@ //// [file0.js] //// [file2.js] //// [file1.js] +/// +/// +/// diff --git a/tests/baselines/reference/doNotEmitTripleSlashCommentsEvenInEmptyFile.symbols b/tests/baselines/reference/emitTripleSlashCommentsEvenInEmptyFile.symbols similarity index 100% rename from tests/baselines/reference/doNotEmitTripleSlashCommentsEvenInEmptyFile.symbols rename to tests/baselines/reference/emitTripleSlashCommentsEvenInEmptyFile.symbols diff --git a/tests/baselines/reference/doNotEmitTripleSlashCommentsEvenInEmptyFile.types b/tests/baselines/reference/emitTripleSlashCommentsEvenInEmptyFile.types similarity index 100% rename from tests/baselines/reference/doNotEmitTripleSlashCommentsEvenInEmptyFile.types rename to tests/baselines/reference/emitTripleSlashCommentsEvenInEmptyFile.types diff --git a/tests/cases/compiler/doNotEmitTripleSlashCommentsButPreserveDetachComments1.ts b/tests/cases/compiler/doNotEmitTripleSlashCommentsButPreserveDetachComments1.ts deleted file mode 100644 index f511e75085b..00000000000 --- a/tests/cases/compiler/doNotEmitTripleSlashCommentsButPreserveDetachComments1.ts +++ /dev/null @@ -1,11 +0,0 @@ -// @comments: false - -// @Filename: file0.ts - -// @Filename: file1.ts - -// -// Copy Right comment -// - -/// diff --git a/tests/cases/compiler/doNotEmitTripleSlashCommentsButPreserveDetachComments2.ts b/tests/cases/compiler/doNotEmitTripleSlashCommentsButPreserveDetachComments2.ts deleted file mode 100644 index 424c7374717..00000000000 --- a/tests/cases/compiler/doNotEmitTripleSlashCommentsButPreserveDetachComments2.ts +++ /dev/null @@ -1,12 +0,0 @@ -// @comments: false - -// @Filename: file0.ts - -// @Filename: file1.ts - -// -// Copy Right comment -// - -/// -var x = 10; \ No newline at end of file diff --git a/tests/cases/compiler/doNotEmitTripleSlashCommentsButPreserveDetachComments3.ts b/tests/cases/compiler/doNotEmitTripleSlashCommentsButPreserveDetachComments3.ts deleted file mode 100644 index 95f1bb4cbbb..00000000000 --- a/tests/cases/compiler/doNotEmitTripleSlashCommentsButPreserveDetachComments3.ts +++ /dev/null @@ -1,10 +0,0 @@ -// @comments: false - -// @Filename: file0.ts - -// @Filename: file1.ts - -// -// Copy Right comment -// -/// diff --git a/tests/cases/compiler/doNotEmitTripleSlashCommentsInTheMiddle.ts b/tests/cases/compiler/doNotEmitTripleSlashCommentsInTheMiddle.ts new file mode 100644 index 00000000000..a0aeecd07f5 --- /dev/null +++ b/tests/cases/compiler/doNotEmitTripleSlashCommentsInTheMiddle.ts @@ -0,0 +1,9 @@ +// @comments: false + +// @Filename: 0.ts + +// @filename: 1.ts +/// +var x = 10; +/// +var y = 1000; \ No newline at end of file diff --git a/tests/cases/compiler/doNotEmitTripleSlashComments.ts b/tests/cases/compiler/emitTripleSlashComments.ts similarity index 100% rename from tests/cases/compiler/doNotEmitTripleSlashComments.ts rename to tests/cases/compiler/emitTripleSlashComments.ts diff --git a/tests/cases/compiler/doNotEmitTripleSlashCommentsEvenInAmbientDeclaration.ts b/tests/cases/compiler/emitTripleSlashCommentsEvenInAmbientDeclaration.ts similarity index 100% rename from tests/cases/compiler/doNotEmitTripleSlashCommentsEvenInAmbientDeclaration.ts rename to tests/cases/compiler/emitTripleSlashCommentsEvenInAmbientDeclaration.ts diff --git a/tests/cases/compiler/doNotEmitTripleSlashCommentsEvenInEmptyFile.ts b/tests/cases/compiler/emitTripleSlashCommentsEvenInEmptyFile.ts similarity index 100% rename from tests/cases/compiler/doNotEmitTripleSlashCommentsEvenInEmptyFile.ts rename to tests/cases/compiler/emitTripleSlashCommentsEvenInEmptyFile.ts From 880202d9828fefe49dd458a5cb67f341133dcf0a Mon Sep 17 00:00:00 2001 From: Yui T Date: Tue, 21 Jul 2015 09:05:56 -0700 Subject: [PATCH 007/117] Clean up some code --- src/compiler/emitter.ts | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index 16ad4e2e206..2e2eaabd9cc 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -6763,17 +6763,12 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi // If removeComments flag is false, then do not filter out any comment if (!removeComments || !ranges) return ranges; - // IF removeComments flag is true, then filter out comment by following: + // If removeComments flag is true, then filter out comment by following: // - Pinned comments : keep all // - /// comments : keep it if the comments are at the top of the file otherwise remove // - normal comments: remove all if (removeComments) { - if (isTopOfFileComments) { - ranges = filter(ranges, isTripleSlashOrPinnedComments); - } - else { - ranges = filter(ranges, isPinnedComments); - } + ranges = isTopOfFileComments ? filter(ranges, isTripleSlashOrPinnedComments) : filter(ranges, isPinnedComments); return ranges.length === 0 ? undefined : ranges; } } From deb6eeebe1dd29be1a3a4afcc0ef1fa83131b710 Mon Sep 17 00:00:00 2001 From: Yui T Date: Tue, 21 Jul 2015 09:06:17 -0700 Subject: [PATCH 008/117] Add tests --- .../doNotEmitTripleSlashCommentsInTheMiddle2.js | 14 ++++++++++++++ ...oNotEmitTripleSlashCommentsInTheMiddle2.symbols | 11 +++++++++++ .../doNotEmitTripleSlashCommentsInTheMiddle2.types | 11 +++++++++++ .../doNotEmitTripleSlashCommentsInTheMiddle2.ts | 9 +++++++++ 4 files changed, 45 insertions(+) create mode 100644 tests/baselines/reference/doNotEmitTripleSlashCommentsInTheMiddle2.js create mode 100644 tests/baselines/reference/doNotEmitTripleSlashCommentsInTheMiddle2.symbols create mode 100644 tests/baselines/reference/doNotEmitTripleSlashCommentsInTheMiddle2.types create mode 100644 tests/cases/compiler/doNotEmitTripleSlashCommentsInTheMiddle2.ts diff --git a/tests/baselines/reference/doNotEmitTripleSlashCommentsInTheMiddle2.js b/tests/baselines/reference/doNotEmitTripleSlashCommentsInTheMiddle2.js new file mode 100644 index 00000000000..520a08983fe --- /dev/null +++ b/tests/baselines/reference/doNotEmitTripleSlashCommentsInTheMiddle2.js @@ -0,0 +1,14 @@ +//// [tests/cases/compiler/doNotEmitTripleSlashCommentsInTheMiddle2.ts] //// + +//// [file0.ts] + + +//// [file1.ts] + +/// +declare var OData: any; +/// + +//// [file0.js] +//// [file1.js] +/// diff --git a/tests/baselines/reference/doNotEmitTripleSlashCommentsInTheMiddle2.symbols b/tests/baselines/reference/doNotEmitTripleSlashCommentsInTheMiddle2.symbols new file mode 100644 index 00000000000..f3a41855553 --- /dev/null +++ b/tests/baselines/reference/doNotEmitTripleSlashCommentsInTheMiddle2.symbols @@ -0,0 +1,11 @@ +=== tests/cases/compiler/file1.ts === + +/// +declare var OData: any; +>OData : Symbol(OData, Decl(file1.ts, 2, 11)) + +/// +=== tests/cases/compiler/file0.ts === + +No type information for this code. +No type information for this code. \ No newline at end of file diff --git a/tests/baselines/reference/doNotEmitTripleSlashCommentsInTheMiddle2.types b/tests/baselines/reference/doNotEmitTripleSlashCommentsInTheMiddle2.types new file mode 100644 index 00000000000..ec6f6e5a2cc --- /dev/null +++ b/tests/baselines/reference/doNotEmitTripleSlashCommentsInTheMiddle2.types @@ -0,0 +1,11 @@ +=== tests/cases/compiler/file1.ts === + +/// +declare var OData: any; +>OData : any + +/// +=== tests/cases/compiler/file0.ts === + +No type information for this code. +No type information for this code. \ No newline at end of file diff --git a/tests/cases/compiler/doNotEmitTripleSlashCommentsInTheMiddle2.ts b/tests/cases/compiler/doNotEmitTripleSlashCommentsInTheMiddle2.ts new file mode 100644 index 00000000000..c06ab1abf76 --- /dev/null +++ b/tests/cases/compiler/doNotEmitTripleSlashCommentsInTheMiddle2.ts @@ -0,0 +1,9 @@ +// @comments: false + +// @Filename: file0.ts + +// @Filename: file1.ts + +/// +declare var OData: any; +/// \ No newline at end of file From 248d85720c80dde9dc6ddfe1a01f97d47ca99d04 Mon Sep 17 00:00:00 2001 From: Yui T Date: Wed, 19 Aug 2015 16:12:33 -0700 Subject: [PATCH 009/117] Update tests to remove /// if removeComment is true --- ...tEmitTripleSlashCommentsInAmbientDeclaration.js | 12 ++++++++++++ ...ripleSlashCommentsInAmbientDeclaration.symbols} | 0 ...tTripleSlashCommentsInAmbientDeclaration.types} | 0 ... => doNotEmitTripleSlashCommentsInEmptyFile.js} | 5 +---- ...oNotEmitTripleSlashCommentsInEmptyFile.symbols} | 0 ... doNotEmitTripleSlashCommentsInEmptyFile.types} | 0 .../doNotEmitTripleSlashCommentsInTheMiddle.js | 1 - .../doNotEmitTripleSlashCommentsInTheMiddle2.js | 14 -------------- ...oNotEmitTripleSlashCommentsInTheMiddle2.symbols | 11 ----------- .../doNotEmitTripleSlashCommentsInTheMiddle2.types | 11 ----------- ...Comments.js => doNotemitTripleSlashComments.js} | 5 +---- ...ymbols => doNotemitTripleSlashComments.symbols} | 0 ...ts.types => doNotemitTripleSlashComments.types} | 0 ...tTripleSlashCommentsEvenInAmbientDeclaration.js | 13 ------------- ...EmitTripleSlashCommentsInAmbientDeclaration.ts} | 0 ... => doNotEmitTripleSlashCommentsInEmptyFile.ts} | 0 .../doNotEmitTripleSlashCommentsInTheMiddle2.ts | 9 --------- ...Comments.ts => doNotemitTripleSlashComments.ts} | 0 18 files changed, 14 insertions(+), 67 deletions(-) create mode 100644 tests/baselines/reference/doNotEmitTripleSlashCommentsInAmbientDeclaration.js rename tests/baselines/reference/{emitTripleSlashCommentsEvenInAmbientDeclaration.symbols => doNotEmitTripleSlashCommentsInAmbientDeclaration.symbols} (100%) rename tests/baselines/reference/{emitTripleSlashCommentsEvenInAmbientDeclaration.types => doNotEmitTripleSlashCommentsInAmbientDeclaration.types} (100%) rename tests/baselines/reference/{emitTripleSlashCommentsEvenInEmptyFile.js => doNotEmitTripleSlashCommentsInEmptyFile.js} (51%) rename tests/baselines/reference/{emitTripleSlashCommentsEvenInEmptyFile.symbols => doNotEmitTripleSlashCommentsInEmptyFile.symbols} (100%) rename tests/baselines/reference/{emitTripleSlashCommentsEvenInEmptyFile.types => doNotEmitTripleSlashCommentsInEmptyFile.types} (100%) delete mode 100644 tests/baselines/reference/doNotEmitTripleSlashCommentsInTheMiddle2.js delete mode 100644 tests/baselines/reference/doNotEmitTripleSlashCommentsInTheMiddle2.symbols delete mode 100644 tests/baselines/reference/doNotEmitTripleSlashCommentsInTheMiddle2.types rename tests/baselines/reference/{emitTripleSlashComments.js => doNotemitTripleSlashComments.js} (55%) rename tests/baselines/reference/{emitTripleSlashComments.symbols => doNotemitTripleSlashComments.symbols} (100%) rename tests/baselines/reference/{emitTripleSlashComments.types => doNotemitTripleSlashComments.types} (100%) delete mode 100644 tests/baselines/reference/emitTripleSlashCommentsEvenInAmbientDeclaration.js rename tests/cases/compiler/{emitTripleSlashCommentsEvenInAmbientDeclaration.ts => doNotEmitTripleSlashCommentsInAmbientDeclaration.ts} (100%) rename tests/cases/compiler/{emitTripleSlashCommentsEvenInEmptyFile.ts => doNotEmitTripleSlashCommentsInEmptyFile.ts} (100%) delete mode 100644 tests/cases/compiler/doNotEmitTripleSlashCommentsInTheMiddle2.ts rename tests/cases/compiler/{emitTripleSlashComments.ts => doNotemitTripleSlashComments.ts} (100%) diff --git a/tests/baselines/reference/doNotEmitTripleSlashCommentsInAmbientDeclaration.js b/tests/baselines/reference/doNotEmitTripleSlashCommentsInAmbientDeclaration.js new file mode 100644 index 00000000000..d3c461fe8c2 --- /dev/null +++ b/tests/baselines/reference/doNotEmitTripleSlashCommentsInAmbientDeclaration.js @@ -0,0 +1,12 @@ +//// [tests/cases/compiler/doNotEmitTripleSlashCommentsInAmbientDeclaration.ts] //// + +//// [file0.ts] + + +//// [file1.ts] + +/// +declare var OData: any; + +//// [file0.js] +//// [file1.js] diff --git a/tests/baselines/reference/emitTripleSlashCommentsEvenInAmbientDeclaration.symbols b/tests/baselines/reference/doNotEmitTripleSlashCommentsInAmbientDeclaration.symbols similarity index 100% rename from tests/baselines/reference/emitTripleSlashCommentsEvenInAmbientDeclaration.symbols rename to tests/baselines/reference/doNotEmitTripleSlashCommentsInAmbientDeclaration.symbols diff --git a/tests/baselines/reference/emitTripleSlashCommentsEvenInAmbientDeclaration.types b/tests/baselines/reference/doNotEmitTripleSlashCommentsInAmbientDeclaration.types similarity index 100% rename from tests/baselines/reference/emitTripleSlashCommentsEvenInAmbientDeclaration.types rename to tests/baselines/reference/doNotEmitTripleSlashCommentsInAmbientDeclaration.types diff --git a/tests/baselines/reference/emitTripleSlashCommentsEvenInEmptyFile.js b/tests/baselines/reference/doNotEmitTripleSlashCommentsInEmptyFile.js similarity index 51% rename from tests/baselines/reference/emitTripleSlashCommentsEvenInEmptyFile.js rename to tests/baselines/reference/doNotEmitTripleSlashCommentsInEmptyFile.js index 6a827528bec..38f6980e5c7 100644 --- a/tests/baselines/reference/emitTripleSlashCommentsEvenInEmptyFile.js +++ b/tests/baselines/reference/doNotEmitTripleSlashCommentsInEmptyFile.js @@ -1,4 +1,4 @@ -//// [tests/cases/compiler/emitTripleSlashCommentsEvenInEmptyFile.ts] //// +//// [tests/cases/compiler/doNotEmitTripleSlashCommentsInEmptyFile.ts] //// //// [file0.ts] @@ -13,6 +13,3 @@ //// [file0.js] //// [file2.js] //// [file1.js] -/// -/// -/// diff --git a/tests/baselines/reference/emitTripleSlashCommentsEvenInEmptyFile.symbols b/tests/baselines/reference/doNotEmitTripleSlashCommentsInEmptyFile.symbols similarity index 100% rename from tests/baselines/reference/emitTripleSlashCommentsEvenInEmptyFile.symbols rename to tests/baselines/reference/doNotEmitTripleSlashCommentsInEmptyFile.symbols diff --git a/tests/baselines/reference/emitTripleSlashCommentsEvenInEmptyFile.types b/tests/baselines/reference/doNotEmitTripleSlashCommentsInEmptyFile.types similarity index 100% rename from tests/baselines/reference/emitTripleSlashCommentsEvenInEmptyFile.types rename to tests/baselines/reference/doNotEmitTripleSlashCommentsInEmptyFile.types diff --git a/tests/baselines/reference/doNotEmitTripleSlashCommentsInTheMiddle.js b/tests/baselines/reference/doNotEmitTripleSlashCommentsInTheMiddle.js index 58a9e2caf66..5a1c65a2b6b 100644 --- a/tests/baselines/reference/doNotEmitTripleSlashCommentsInTheMiddle.js +++ b/tests/baselines/reference/doNotEmitTripleSlashCommentsInTheMiddle.js @@ -11,6 +11,5 @@ var y = 1000; //// [0.js] //// [1.js] -/// var x = 10; var y = 1000; diff --git a/tests/baselines/reference/doNotEmitTripleSlashCommentsInTheMiddle2.js b/tests/baselines/reference/doNotEmitTripleSlashCommentsInTheMiddle2.js deleted file mode 100644 index 520a08983fe..00000000000 --- a/tests/baselines/reference/doNotEmitTripleSlashCommentsInTheMiddle2.js +++ /dev/null @@ -1,14 +0,0 @@ -//// [tests/cases/compiler/doNotEmitTripleSlashCommentsInTheMiddle2.ts] //// - -//// [file0.ts] - - -//// [file1.ts] - -/// -declare var OData: any; -/// - -//// [file0.js] -//// [file1.js] -/// diff --git a/tests/baselines/reference/doNotEmitTripleSlashCommentsInTheMiddle2.symbols b/tests/baselines/reference/doNotEmitTripleSlashCommentsInTheMiddle2.symbols deleted file mode 100644 index f3a41855553..00000000000 --- a/tests/baselines/reference/doNotEmitTripleSlashCommentsInTheMiddle2.symbols +++ /dev/null @@ -1,11 +0,0 @@ -=== tests/cases/compiler/file1.ts === - -/// -declare var OData: any; ->OData : Symbol(OData, Decl(file1.ts, 2, 11)) - -/// -=== tests/cases/compiler/file0.ts === - -No type information for this code. -No type information for this code. \ No newline at end of file diff --git a/tests/baselines/reference/doNotEmitTripleSlashCommentsInTheMiddle2.types b/tests/baselines/reference/doNotEmitTripleSlashCommentsInTheMiddle2.types deleted file mode 100644 index ec6f6e5a2cc..00000000000 --- a/tests/baselines/reference/doNotEmitTripleSlashCommentsInTheMiddle2.types +++ /dev/null @@ -1,11 +0,0 @@ -=== tests/cases/compiler/file1.ts === - -/// -declare var OData: any; ->OData : any - -/// -=== tests/cases/compiler/file0.ts === - -No type information for this code. -No type information for this code. \ No newline at end of file diff --git a/tests/baselines/reference/emitTripleSlashComments.js b/tests/baselines/reference/doNotemitTripleSlashComments.js similarity index 55% rename from tests/baselines/reference/emitTripleSlashComments.js rename to tests/baselines/reference/doNotemitTripleSlashComments.js index ac86bc880f1..a2ae1666498 100644 --- a/tests/baselines/reference/emitTripleSlashComments.js +++ b/tests/baselines/reference/doNotemitTripleSlashComments.js @@ -1,4 +1,4 @@ -//// [tests/cases/compiler/emitTripleSlashComments.ts] //// +//// [tests/cases/compiler/doNotemitTripleSlashComments.ts] //// //// [file0.ts] @@ -14,7 +14,4 @@ var OData: any; //// [file0.js] //// [file2.js] //// [file1.js] -/// -/// -/// var OData; diff --git a/tests/baselines/reference/emitTripleSlashComments.symbols b/tests/baselines/reference/doNotemitTripleSlashComments.symbols similarity index 100% rename from tests/baselines/reference/emitTripleSlashComments.symbols rename to tests/baselines/reference/doNotemitTripleSlashComments.symbols diff --git a/tests/baselines/reference/emitTripleSlashComments.types b/tests/baselines/reference/doNotemitTripleSlashComments.types similarity index 100% rename from tests/baselines/reference/emitTripleSlashComments.types rename to tests/baselines/reference/doNotemitTripleSlashComments.types diff --git a/tests/baselines/reference/emitTripleSlashCommentsEvenInAmbientDeclaration.js b/tests/baselines/reference/emitTripleSlashCommentsEvenInAmbientDeclaration.js deleted file mode 100644 index 2cc952a8f3a..00000000000 --- a/tests/baselines/reference/emitTripleSlashCommentsEvenInAmbientDeclaration.js +++ /dev/null @@ -1,13 +0,0 @@ -//// [tests/cases/compiler/emitTripleSlashCommentsEvenInAmbientDeclaration.ts] //// - -//// [file0.ts] - - -//// [file1.ts] - -/// -declare var OData: any; - -//// [file0.js] -//// [file1.js] -/// diff --git a/tests/cases/compiler/emitTripleSlashCommentsEvenInAmbientDeclaration.ts b/tests/cases/compiler/doNotEmitTripleSlashCommentsInAmbientDeclaration.ts similarity index 100% rename from tests/cases/compiler/emitTripleSlashCommentsEvenInAmbientDeclaration.ts rename to tests/cases/compiler/doNotEmitTripleSlashCommentsInAmbientDeclaration.ts diff --git a/tests/cases/compiler/emitTripleSlashCommentsEvenInEmptyFile.ts b/tests/cases/compiler/doNotEmitTripleSlashCommentsInEmptyFile.ts similarity index 100% rename from tests/cases/compiler/emitTripleSlashCommentsEvenInEmptyFile.ts rename to tests/cases/compiler/doNotEmitTripleSlashCommentsInEmptyFile.ts diff --git a/tests/cases/compiler/doNotEmitTripleSlashCommentsInTheMiddle2.ts b/tests/cases/compiler/doNotEmitTripleSlashCommentsInTheMiddle2.ts deleted file mode 100644 index c06ab1abf76..00000000000 --- a/tests/cases/compiler/doNotEmitTripleSlashCommentsInTheMiddle2.ts +++ /dev/null @@ -1,9 +0,0 @@ -// @comments: false - -// @Filename: file0.ts - -// @Filename: file1.ts - -/// -declare var OData: any; -/// \ No newline at end of file diff --git a/tests/cases/compiler/emitTripleSlashComments.ts b/tests/cases/compiler/doNotemitTripleSlashComments.ts similarity index 100% rename from tests/cases/compiler/emitTripleSlashComments.ts rename to tests/cases/compiler/doNotemitTripleSlashComments.ts From 5d15218cbe5458a766db8d7ed46b40470563a207 Mon Sep 17 00:00:00 2001 From: Yui T Date: Wed, 19 Aug 2015 16:19:17 -0700 Subject: [PATCH 010/117] Remove /// comment when removeComment is true --- src/compiler/emitter.ts | 69 +++++++++++++++++------------------------ 1 file changed, 28 insertions(+), 41 deletions(-) diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index 0d0e968e5b7..0363122f11f 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -3651,7 +3651,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi function emitFunctionDeclaration(node: FunctionLikeDeclaration) { if (nodeIsMissing(node.body)) { - return emitOnlyPinnedOrTripleSlashComments(node); + return emitCommentsOnNotEmittedNode(node); } // TODO (yuisu) : we should not have special cases to condition emitting comments @@ -4123,7 +4123,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi } else if (member.kind === SyntaxKind.MethodDeclaration || node.kind === SyntaxKind.MethodSignature) { if (!(member).body) { - return emitOnlyPinnedOrTripleSlashComments(member); + return emitCommentsOnNotEmittedNode(member); } writeLine(); @@ -4192,7 +4192,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi function emitMemberFunctionsForES6AndHigher(node: ClassLikeDeclaration) { for (let member of node.members) { if ((member.kind === SyntaxKind.MethodDeclaration || node.kind === SyntaxKind.MethodSignature) && !(member).body) { - emitOnlyPinnedOrTripleSlashComments(member); + emitCommentsOnNotEmittedNode(member); } else if (member.kind === SyntaxKind.MethodDeclaration || member.kind === SyntaxKind.GetAccessor || @@ -4249,7 +4249,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi // Emit the constructor overload pinned comments forEach(node.members, member => { if (member.kind === SyntaxKind.Constructor && !(member).body) { - emitOnlyPinnedOrTripleSlashComments(member); + emitCommentsOnNotEmittedNode(member); } // Check if there is any non-static property assignment if (member.kind === SyntaxKind.PropertyDeclaration && (member).initializer && (member.flags & NodeFlags.Static) === 0) { @@ -5151,7 +5151,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi } function emitInterfaceDeclaration(node: InterfaceDeclaration) { - emitOnlyPinnedOrTripleSlashComments(node); + emitCommentsOnNotEmittedNode(node); } function shouldEmitEnumDeclaration(node: EnumDeclaration) { @@ -5273,7 +5273,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi let shouldEmit = shouldEmitModuleDeclaration(node); if (!shouldEmit) { - return emitOnlyPinnedOrTripleSlashComments(node); + return emitCommentsOnNotEmittedNode(node); } let hoistedInDeclarationScope = shouldHoistDeclarationInSystemJsModule(node); let emitVarForModule = !hoistedInDeclarationScope && !isModuleMergedWithES6Class(node); @@ -6675,7 +6675,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi } if (node.flags & NodeFlags.Ambient) { - return emitOnlyPinnedOrTripleSlashComments(node); + return emitCommentsOnNotEmittedNode(node); } let emitComments = shouldEmitLeadingAndTrailingComments(node); @@ -6922,18 +6922,18 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi return leadingComments; } - function filterComments(ranges: CommentRange[], removeComments: boolean, isTopOfFileComments: boolean): CommentRange[] { - // If removeComments flag is false, then do not filter out any comment - if (!removeComments || !ranges) return ranges; - - // If removeComments flag is true, then filter out comment by following: - // - Pinned comments : keep all - // - /// comments : keep it if the comments are at the top of the file otherwise remove - // - normal comments: remove all - if (removeComments) { - ranges = isTopOfFileComments ? filter(ranges, isTripleSlashOrPinnedComments) : filter(ranges, isPinnedComments); - return ranges.length === 0 ? undefined : ranges; + function filterComments(ranges: CommentRange[], isTopOfFileComments: boolean, isEmittedNode=true): CommentRange[] { + if (compilerOptions.removeComments) { + ranges = filter(ranges, isPinnedComments); } + else { + // TODO (yuisu): comment + if (!isEmittedNode) { + ranges = isTopOfFileComments ? filter(ranges, isTripleSlashOrPinnedComments) : filter(ranges, isPinnedComments); + } + } + + return ranges; } function isPinnedComments(comment: CommentRange) { @@ -6945,7 +6945,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi /** * Determine if the given comment is a triple-slash or pinned comment * - * @return true if the comment is a triple-slash comment at the top of the file or a pinned comment else false + * @return true if the comment is a triple-slash comment or a pinned comment else false **/ function isTripleSlashOrPinnedComments(comment: CommentRange) { // Verify this is /// comment, but do the regexp match only when we first can find /// in the comment text @@ -6986,18 +6986,19 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi } } - function emitOnlyPinnedOrTripleSlashComments(node: Node) { - emitLeadingCommentsWorker(node, /*removeComments:*/ true); + function emitCommentsOnNotEmittedNode(node: Node) { + /// TODO (yuisu): comments + emitLeadingCommentsWorker(node, /*isEmittedNode:*/ false); } function emitLeadingComments(node: Node) { - return emitLeadingCommentsWorker(node, compilerOptions.removeComments); + return emitLeadingCommentsWorker(node, /*isEmittedNode:*/ true); } - function emitLeadingCommentsWorker(node: Node, removeComments: boolean) { + function emitLeadingCommentsWorker(node: Node, isEmittedNode: boolean) { // If the caller only wants pinned or triple slash comments, then always filter // down to that set. Otherwise, filter based on the current compiler options. - let leadingComments = filterComments(getLeadingCommentsToEmit(node), /*removeComments:*/ removeComments, /*isTopOfFileComments:*/ node.pos === 0); + let leadingComments = filterComments(getLeadingCommentsToEmit(node), /*isTopOfFileComments:*/ node.pos === 0, isEmittedNode); emitNewLineBeforeLeadingComments(currentSourceFile, writer, node, leadingComments); @@ -7007,7 +7008,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi function emitTrailingComments(node: Node) { // Emit the trailing comments only if the parent's end doesn't match - let trailingComments = filterComments(getTrailingCommentsToEmit(node), /*removeComments*/ compilerOptions.removeComments, /*isTopOfFileComments:*/ node.pos === 0); + let trailingComments = filterComments(getTrailingCommentsToEmit(node), /*isTopOfFileComments:*/ node.pos === 0); // trailing comments are emitted at space/*trailing comment1 */space/*trailing comment*/ emitComments(currentSourceFile, writer, trailingComments, /*trailingSeparator*/ false, newLine, writeComment); @@ -7019,7 +7020,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi * ^ => pos; the function will emit "comment1" in the emitJS */ function emitTrailingCommentsOfPosition(pos: number) { - let trailingComments = filterComments(getTrailingCommentRanges(currentSourceFile.text, pos), /*onlyPinnedOrTripleSlashComments:*/ compilerOptions.removeComments, pos === 0); + let trailingComments = filterComments(getTrailingCommentRanges(currentSourceFile.text, pos), /*isTopOfFileComments*/ pos === 0); // trailing comments are emitted at space/*trailing comment1 */space/*trailing comment*/ emitComments(currentSourceFile, writer, trailingComments, /*trailingSeparator*/ true, newLine, writeComment); @@ -7036,7 +7037,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi leadingComments = getLeadingCommentRanges(currentSourceFile.text, pos); } - leadingComments = filterComments(leadingComments, /*removeComments:*/ compilerOptions.removeComments, pos === 0); + leadingComments = filterComments(leadingComments, /*isTopOfFileComments*/ pos === 0); emitNewLineBeforeLeadingComments(currentSourceFile, writer, { pos: pos, end: pos }, leadingComments); // Leading comments are emitted at /*leading comment1 */space/*leading comment*/space @@ -7094,20 +7095,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi write(shebang); } } - - function isPinnedOrTripleSlashComment(comment: CommentRange) { - if (currentSourceFile.text.charCodeAt(comment.pos + 1) === CharacterCodes.asterisk) { - return currentSourceFile.text.charCodeAt(comment.pos + 2) === CharacterCodes.exclamation; - } - // Verify this is /// comment, but do the regexp match only when we first can find /// in the comment text - // so that we don't end up computing comment string and doing match for all // comments - else if (currentSourceFile.text.charCodeAt(comment.pos + 1) === CharacterCodes.slash && - comment.pos + 2 < comment.end && - currentSourceFile.text.charCodeAt(comment.pos + 2) === CharacterCodes.slash && - currentSourceFile.text.substring(comment.pos, comment.end).match(fullTripleSlashReferencePathRegEx)) { - return true; - } - } } function emitFile(jsFilePath: string, sourceFile?: SourceFile) { From 3da6de205cc224204a6c6d71cc06ae5d27efc047 Mon Sep 17 00:00:00 2001 From: Mohamed Hegazy Date: Wed, 19 Aug 2015 23:12:25 -0700 Subject: [PATCH 011/117] remove unused list of supported switchs --- src/harness/harness.ts | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/src/harness/harness.ts b/src/harness/harness.ts index a0366c0c40b..b1560d78a7a 100644 --- a/src/harness/harness.ts +++ b/src/harness/harness.ts @@ -1519,16 +1519,6 @@ module Harness { // Regex for parsing options in the format "@Alpha: Value of any sort" let optionRegex = /^[\/]{2}\s*@(\w+)\s*:\s*(\S*)/gm; // multiple matches on multiple lines - // List of allowed metadata names - let fileMetadataNames = ["filename", "comments", "declaration", "module", - "nolib", "sourcemap", "target", "out", "outdir", "noemithelpers", "noemitonerror", - "noimplicitany", "noresolve", "newline", "normalizenewline", "emitbom", - "errortruncation", "usecasesensitivefilenames", "preserveconstenums", - "includebuiltfile", "suppressimplicitanyindexerrors", "stripinternal", - "isolatedmodules", "inlinesourcemap", "maproot", "sourceroot", - "inlinesources", "emitdecoratormetadata", "experimentaldecorators", - "skipdefaultlibcheck", "jsx"]; - function extractCompilerSettings(content: string): CompilerSetting[] { let opts: CompilerSetting[] = []; From eef8f04e5d39f00bb80e819c7837610008d464d0 Mon Sep 17 00:00:00 2001 From: Mohamed Hegazy Date: Wed, 19 Aug 2015 23:15:40 -0700 Subject: [PATCH 012/117] remove unused flag aliases --- src/harness/harness.ts | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/harness/harness.ts b/src/harness/harness.ts index b1560d78a7a..618a3b20ec2 100644 --- a/src/harness/harness.ts +++ b/src/harness/harness.ts @@ -1017,7 +1017,6 @@ module Harness { switch (setting.flag.toLowerCase()) { // "fileName", "comments", "declaration", "module", "nolib", "sourcemap", "target", "out", "outdir", "noimplicitany", "noresolve" case "module": - case "modulegentarget": if (typeof setting.value === "string") { if (setting.value.toLowerCase() === "amd") { options.module = ts.ModuleKind.AMD; @@ -1038,7 +1037,6 @@ module Harness { break; case "target": - case "codegentarget": if (typeof setting.value === "string") { if (setting.value.toLowerCase() === "es3") { options.target = ts.ScriptTarget.ES3; @@ -1087,11 +1085,9 @@ module Harness { break; case "out": - case "outfileoption": options.out = setting.value; break; - case "outdiroption": case "outdir": options.outDir = setting.value; break; From b2ac33da9e99255d11efb963ac95a21109db698e Mon Sep 17 00:00:00 2001 From: Mohamed Hegazy Date: Wed, 19 Aug 2015 23:16:58 -0700 Subject: [PATCH 013/117] Export setCompilerOptionForSetting --- src/harness/harness.ts | 340 ++++++++++++++++++++--------------------- 1 file changed, 170 insertions(+), 170 deletions(-) diff --git a/src/harness/harness.ts b/src/harness/harness.ts index 618a3b20ec2..317171daeb9 100644 --- a/src/harness/harness.ts +++ b/src/harness/harness.ts @@ -910,6 +910,175 @@ module Harness { }; } + export function setCompilerOptionForSetting(setting: Harness.TestCaseParser.CompilerSetting, options: ts.CompilerOptions): void { + switch (setting.flag.toLowerCase()) { + case "module": + if (typeof setting.value === "string") { + if (setting.value.toLowerCase() === "amd") { + options.module = ts.ModuleKind.AMD; + } else if (setting.value.toLowerCase() === "umd") { + options.module = ts.ModuleKind.UMD; + } else if (setting.value.toLowerCase() === "commonjs") { + options.module = ts.ModuleKind.CommonJS; + } else if (setting.value.toLowerCase() === "system") { + options.module = ts.ModuleKind.System; + } else if (setting.value.toLowerCase() === "unspecified") { + options.module = ts.ModuleKind.None; + } else { + throw new Error("Unknown module type " + setting.value); + } + } else { + options.module = setting.value; + } + break; + + case "target": + if (typeof setting.value === "string") { + if (setting.value.toLowerCase() === "es3") { + options.target = ts.ScriptTarget.ES3; + } else if (setting.value.toLowerCase() === "es5") { + options.target = ts.ScriptTarget.ES5; + } else if (setting.value.toLowerCase() === "es6") { + options.target = ts.ScriptTarget.ES6; + } else { + throw new Error("Unknown compile target " + setting.value); + } + } else { + options.target = setting.value; + } + break; + + case "experimentaldecorators": + options.experimentalDecorators = setting.value === "true"; + break; + + case "emitdecoratormetadata": + options.emitDecoratorMetadata = setting.value === "true"; + break; + + case "experimentalasyncfunctions": + options.experimentalAsyncFunctions = setting.value === "true"; + break; + + case "noemithelpers": + options.noEmitHelpers = setting.value === "true"; + break; + + case "noemitonerror": + options.noEmitOnError = setting.value === "true"; + break; + + case "noresolve": + options.noResolve = setting.value === "true"; + break; + + case "noimplicitany": + options.noImplicitAny = setting.value === "true"; + break; + + case "nolib": + options.noLib = setting.value === "true"; + break; + + case "out": + options.out = setting.value; + break; + + case "outdir": + options.outDir = setting.value; + break; + + case "skipdefaultlibcheck": + options.skipDefaultLibCheck = setting.value === "true"; + break; + + case "sourceroot": + options.sourceRoot = setting.value; + break; + + case "maproot": + options.mapRoot = setting.value; + break; + + case "sourcemap": + options.sourceMap = setting.value === "true"; + break; + + case "declaration": + options.declaration = setting.value === "true"; + break; + + case "newline": + if (setting.value.toLowerCase() === "crlf") { + options.newLine = ts.NewLineKind.CarriageReturnLineFeed; + } + else if (setting.value.toLowerCase() === "lf") { + options.newLine = ts.NewLineKind.LineFeed; + } + else { + throw new Error("Unknown option for newLine: " + setting.value); + } + break; + + case "comments": + options.removeComments = setting.value === "false"; + break; + + case "stripinternal": + options.stripInternal = setting.value === "true"; + + case "usecasesensitivefilenames": + useCaseSensitiveFileNames = setting.value === "true"; + break; + + case "filename": + // Not supported yet + break; + + case "emitbom": + options.emitBOM = setting.value === "true"; + break; + + case "errortruncation": + options.noErrorTruncation = setting.value === "false"; + break; + + case "preserveconstenums": + options.preserveConstEnums = setting.value === "true"; + break; + + case "isolatedmodules": + options.isolatedModules = setting.value === "true"; + break; + + case "suppressimplicitanyindexerrors": + options.suppressImplicitAnyIndexErrors = setting.value === "true"; + break; + + case "includebuiltfile": + let builtFileName = libFolder + setting.value; + includeBuiltFiles.push({ unitName: builtFileName, content: normalizeLineEndings(IO.readFile(builtFileName), newLine) }); + break; + + case "inlinesourcemap": + options.inlineSourceMap = setting.value === "true"; + break; + + case "inlinesources": + options.inlineSources = setting.value === "true"; + break; + + case "jsx": + options.jsx = setting.value.toLowerCase() === "react" ? ts.JsxEmit.React : + setting.value.toLowerCase() === "preserve" ? ts.JsxEmit.Preserve : + ts.JsxEmit.None; + break; + + default: + throw new Error("Unsupported compiler setting " + setting.flag); + } + } + export class HarnessCompiler { private inputFiles: { unitName: string; content: string }[] = []; private compileOptions: ts.CompilerOptions; @@ -989,7 +1158,7 @@ module Harness { let includeBuiltFiles: { unitName: string; content: string }[] = []; let useCaseSensitiveFileNames = ts.sys.useCaseSensitiveFileNames; - this.settings.forEach(setCompilerOptionForSetting); + this.settings.forEach(setting => setCompilerOptionForSetting(setting, options)); let fileOutputs: GeneratedFile[] = []; @@ -1013,175 +1182,6 @@ module Harness { ts.sys.newLine = newLine; return options; - function setCompilerOptionForSetting(setting: Harness.TestCaseParser.CompilerSetting) { - switch (setting.flag.toLowerCase()) { - // "fileName", "comments", "declaration", "module", "nolib", "sourcemap", "target", "out", "outdir", "noimplicitany", "noresolve" - case "module": - if (typeof setting.value === "string") { - if (setting.value.toLowerCase() === "amd") { - options.module = ts.ModuleKind.AMD; - } else if (setting.value.toLowerCase() === "umd") { - options.module = ts.ModuleKind.UMD; - } else if (setting.value.toLowerCase() === "commonjs") { - options.module = ts.ModuleKind.CommonJS; - } else if (setting.value.toLowerCase() === "system") { - options.module = ts.ModuleKind.System; - } else if (setting.value.toLowerCase() === "unspecified") { - options.module = ts.ModuleKind.None; - } else { - throw new Error("Unknown module type " + setting.value); - } - } else { - options.module = setting.value; - } - break; - - case "target": - if (typeof setting.value === "string") { - if (setting.value.toLowerCase() === "es3") { - options.target = ts.ScriptTarget.ES3; - } else if (setting.value.toLowerCase() === "es5") { - options.target = ts.ScriptTarget.ES5; - } else if (setting.value.toLowerCase() === "es6") { - options.target = ts.ScriptTarget.ES6; - } else { - throw new Error("Unknown compile target " + setting.value); - } - } else { - options.target = setting.value; - } - break; - - case "experimentaldecorators": - options.experimentalDecorators = setting.value === "true"; - break; - - case "emitdecoratormetadata": - options.emitDecoratorMetadata = setting.value === "true"; - break; - - case "experimentalasyncfunctions": - options.experimentalAsyncFunctions = setting.value === "true"; - break; - - case "noemithelpers": - options.noEmitHelpers = setting.value === "true"; - break; - - case "noemitonerror": - options.noEmitOnError = setting.value === "true"; - break; - - case "noresolve": - options.noResolve = setting.value === "true"; - break; - - case "noimplicitany": - options.noImplicitAny = setting.value === "true"; - break; - - case "nolib": - options.noLib = setting.value === "true"; - break; - - case "out": - options.out = setting.value; - break; - - case "outdir": - options.outDir = setting.value; - break; - - case "skipdefaultlibcheck": - options.skipDefaultLibCheck = setting.value === "true"; - break; - - case "sourceroot": - options.sourceRoot = setting.value; - break; - - case "maproot": - options.mapRoot = setting.value; - break; - - case "sourcemap": - options.sourceMap = setting.value === "true"; - break; - - case "declaration": - options.declaration = setting.value === "true"; - break; - - case "newline": - if (setting.value.toLowerCase() === "crlf") { - options.newLine = ts.NewLineKind.CarriageReturnLineFeed; - } - else if (setting.value.toLowerCase() === "lf") { - options.newLine = ts.NewLineKind.LineFeed; - } - else { - throw new Error("Unknown option for newLine: " + setting.value); - } - break; - - case "comments": - options.removeComments = setting.value === "false"; - break; - - case "stripinternal": - options.stripInternal = setting.value === "true"; - - case "usecasesensitivefilenames": - useCaseSensitiveFileNames = setting.value === "true"; - break; - - case "filename": - // Not supported yet - break; - - case "emitbom": - options.emitBOM = setting.value === "true"; - break; - - case "errortruncation": - options.noErrorTruncation = setting.value === "false"; - break; - - case "preserveconstenums": - options.preserveConstEnums = setting.value === "true"; - break; - - case "isolatedmodules": - options.isolatedModules = setting.value === "true"; - break; - - case "suppressimplicitanyindexerrors": - options.suppressImplicitAnyIndexErrors = setting.value === "true"; - break; - - case "includebuiltfile": - let builtFileName = libFolder + setting.value; - includeBuiltFiles.push({ unitName: builtFileName, content: normalizeLineEndings(IO.readFile(builtFileName), newLine) }); - break; - - case "inlinesourcemap": - options.inlineSourceMap = setting.value === "true"; - break; - - case "inlinesources": - options.inlineSources = setting.value === "true"; - break; - - case "jsx": - options.jsx = setting.value.toLowerCase() === "react" ? ts.JsxEmit.React : - setting.value.toLowerCase() === "preserve" ? ts.JsxEmit.Preserve : - ts.JsxEmit.None; - break; - - default: - throw new Error("Unsupported compiler setting " + setting.flag); - } - } } public compileDeclarationFiles(inputFiles: { unitName: string; content: string; }[], From b28befdc1e0a0d58b262ab379a172ecea98d76d6 Mon Sep 17 00:00:00 2001 From: Mohamed Hegazy Date: Wed, 19 Aug 2015 23:53:19 -0700 Subject: [PATCH 014/117] Handel additional properties --- src/harness/harness.ts | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/src/harness/harness.ts b/src/harness/harness.ts index 317171daeb9..c17c00bcfc4 100644 --- a/src/harness/harness.ts +++ b/src/harness/harness.ts @@ -910,7 +910,12 @@ module Harness { }; } - export function setCompilerOptionForSetting(setting: Harness.TestCaseParser.CompilerSetting, options: ts.CompilerOptions): void { + interface HarnesOptions { + useCaseSensitiveFileNames?: boolean; + includeBuiltFileNames?: string[]; + } + + export function setCompilerOptionForSetting(setting: Harness.TestCaseParser.CompilerSetting, options: ts.CompilerOptions & HarnesOptions): void { switch (setting.flag.toLowerCase()) { case "module": if (typeof setting.value === "string") { @@ -1028,7 +1033,7 @@ module Harness { options.stripInternal = setting.value === "true"; case "usecasesensitivefilenames": - useCaseSensitiveFileNames = setting.value === "true"; + options.useCaseSensitiveFileNames = setting.value === "true"; break; case "filename": @@ -1056,8 +1061,10 @@ module Harness { break; case "includebuiltfile": - let builtFileName = libFolder + setting.value; - includeBuiltFiles.push({ unitName: builtFileName, content: normalizeLineEndings(IO.readFile(builtFileName), newLine) }); + if (!options.includeBuiltFileNames) { + options.includeBuiltFileNames = []; + } + options.includeBuiltFileNames.push(setting.value); break; case "inlinesourcemap": @@ -1136,7 +1143,7 @@ module Harness { otherFiles: { unitName: string; content: string }[], onComplete: (result: CompilerResult, program: ts.Program) => void, settingsCallback?: (settings: ts.CompilerOptions) => void, - options?: ts.CompilerOptions, + options?: ts.CompilerOptions & HarnesOptions, // Current directory is needed for rwcRunner to be able to use currentDirectory defined in json file currentDirectory?: string) { @@ -1153,12 +1160,18 @@ module Harness { let newLine = "\r\n"; options.skipDefaultLibCheck = true; + // Parse settings + this.settings.forEach(setting => setCompilerOptionForSetting(setting, options)); + // Files from built\local that are requested by test "@includeBuiltFiles" to be in the context. // Treat them as library files, so include them in build, but not in baselines. let includeBuiltFiles: { unitName: string; content: string }[] = []; + ts.forEach(options.includeBuiltFileNames, fileName => { + let builtFileName = libFolder + fileName; + includeBuiltFiles.push({ unitName: builtFileName, content: normalizeLineEndings(IO.readFile(builtFileName), newLine) }); + }); - let useCaseSensitiveFileNames = ts.sys.useCaseSensitiveFileNames; - this.settings.forEach(setting => setCompilerOptionForSetting(setting, options)); + let useCaseSensitiveFileNames = options.useCaseSensitiveFileNames !== undefined ? options.useCaseSensitiveFileNames : ts.sys.useCaseSensitiveFileNames; let fileOutputs: GeneratedFile[] = []; From 527f197a4ef32278aac29a54d89e760d63968ada Mon Sep 17 00:00:00 2001 From: Mohamed Hegazy Date: Thu, 20 Aug 2015 00:40:45 -0700 Subject: [PATCH 015/117] consolidate toLower call --- src/harness/harness.ts | 121 +++++++++++++++++++++-------------------- 1 file changed, 62 insertions(+), 59 deletions(-) diff --git a/src/harness/harness.ts b/src/harness/harness.ts index c17c00bcfc4..6304c6f2c9e 100644 --- a/src/harness/harness.ts +++ b/src/harness/harness.ts @@ -916,124 +916,118 @@ module Harness { } export function setCompilerOptionForSetting(setting: Harness.TestCaseParser.CompilerSetting, options: ts.CompilerOptions & HarnesOptions): void { - switch (setting.flag.toLowerCase()) { + let name = setting.flag.toLowerCase(); + let value = setting.value ? setting.value.toLowerCase() : setting.value; + switch (name) { case "module": - if (typeof setting.value === "string") { - if (setting.value.toLowerCase() === "amd") { - options.module = ts.ModuleKind.AMD; - } else if (setting.value.toLowerCase() === "umd") { - options.module = ts.ModuleKind.UMD; - } else if (setting.value.toLowerCase() === "commonjs") { - options.module = ts.ModuleKind.CommonJS; - } else if (setting.value.toLowerCase() === "system") { - options.module = ts.ModuleKind.System; - } else if (setting.value.toLowerCase() === "unspecified") { - options.module = ts.ModuleKind.None; - } else { - throw new Error("Unknown module type " + setting.value); - } + if (value === "amd") { + options.module = ts.ModuleKind.AMD; + } else if (value === "umd") { + options.module = ts.ModuleKind.UMD; + } else if (value === "commonjs") { + options.module = ts.ModuleKind.CommonJS; + } else if (value === "system") { + options.module = ts.ModuleKind.System; + } else if (value === "unspecified") { + options.module = ts.ModuleKind.None; } else { - options.module = setting.value; + throw new Error("Unknown module type " + value); } break; case "target": - if (typeof setting.value === "string") { - if (setting.value.toLowerCase() === "es3") { - options.target = ts.ScriptTarget.ES3; - } else if (setting.value.toLowerCase() === "es5") { - options.target = ts.ScriptTarget.ES5; - } else if (setting.value.toLowerCase() === "es6") { - options.target = ts.ScriptTarget.ES6; - } else { - throw new Error("Unknown compile target " + setting.value); - } + if (value === "es3") { + options.target = ts.ScriptTarget.ES3; + } else if (value === "es5") { + options.target = ts.ScriptTarget.ES5; + } else if (value === "es6") { + options.target = ts.ScriptTarget.ES6; } else { - options.target = setting.value; + throw new Error("Unknown compile target " + value); } break; case "experimentaldecorators": - options.experimentalDecorators = setting.value === "true"; + options.experimentalDecorators = value === "true"; break; case "emitdecoratormetadata": - options.emitDecoratorMetadata = setting.value === "true"; + options.emitDecoratorMetadata = value === "true"; break; case "experimentalasyncfunctions": - options.experimentalAsyncFunctions = setting.value === "true"; + options.experimentalAsyncFunctions = value === "true"; break; case "noemithelpers": - options.noEmitHelpers = setting.value === "true"; + options.noEmitHelpers = value === "true"; break; case "noemitonerror": - options.noEmitOnError = setting.value === "true"; + options.noEmitOnError = value === "true"; break; case "noresolve": - options.noResolve = setting.value === "true"; + options.noResolve = value === "true"; break; case "noimplicitany": - options.noImplicitAny = setting.value === "true"; + options.noImplicitAny = value === "true"; break; case "nolib": - options.noLib = setting.value === "true"; + options.noLib = value === "true"; break; case "out": - options.out = setting.value; + options.out = value; break; case "outdir": - options.outDir = setting.value; + options.outDir = value; break; case "skipdefaultlibcheck": - options.skipDefaultLibCheck = setting.value === "true"; + options.skipDefaultLibCheck = value === "true"; break; case "sourceroot": - options.sourceRoot = setting.value; + options.sourceRoot = value; break; case "maproot": - options.mapRoot = setting.value; + options.mapRoot = value; break; case "sourcemap": - options.sourceMap = setting.value === "true"; + options.sourceMap = value === "true"; break; case "declaration": - options.declaration = setting.value === "true"; + options.declaration = value === "true"; break; case "newline": - if (setting.value.toLowerCase() === "crlf") { + if (value === "crlf") { options.newLine = ts.NewLineKind.CarriageReturnLineFeed; } - else if (setting.value.toLowerCase() === "lf") { + else if (value === "lf") { options.newLine = ts.NewLineKind.LineFeed; } else { - throw new Error("Unknown option for newLine: " + setting.value); + throw new Error("Unknown option for newLine: " + value); } break; case "comments": - options.removeComments = setting.value === "false"; + options.removeComments = value === "false"; break; case "stripinternal": - options.stripInternal = setting.value === "true"; + options.stripInternal = value === "true"; case "usecasesensitivefilenames": - options.useCaseSensitiveFileNames = setting.value === "true"; + options.useCaseSensitiveFileNames = value === "true"; break; case "filename": @@ -1041,44 +1035,53 @@ module Harness { break; case "emitbom": - options.emitBOM = setting.value === "true"; + options.emitBOM = value === "true"; break; case "errortruncation": - options.noErrorTruncation = setting.value === "false"; + options.noErrorTruncation = value === "false"; break; case "preserveconstenums": - options.preserveConstEnums = setting.value === "true"; + options.preserveConstEnums = value === "true"; break; case "isolatedmodules": - options.isolatedModules = setting.value === "true"; + options.isolatedModules = value === "true"; break; case "suppressimplicitanyindexerrors": - options.suppressImplicitAnyIndexErrors = setting.value === "true"; + options.suppressImplicitAnyIndexErrors = value === "true"; break; case "includebuiltfile": if (!options.includeBuiltFileNames) { options.includeBuiltFileNames = []; } - options.includeBuiltFileNames.push(setting.value); + options.includeBuiltFileNames.push(value); break; case "inlinesourcemap": - options.inlineSourceMap = setting.value === "true"; + options.inlineSourceMap = value === "true"; break; case "inlinesources": - options.inlineSources = setting.value === "true"; + options.inlineSources = value === "true"; break; case "jsx": - options.jsx = setting.value.toLowerCase() === "react" ? ts.JsxEmit.React : - setting.value.toLowerCase() === "preserve" ? ts.JsxEmit.Preserve : - ts.JsxEmit.None; + if (value === "react") { + options.jsx = ts.JsxEmit.React; + } + else if (value === "preserve") { + options.jsx = ts.JsxEmit.Preserve; + } + else if (value === "none") { + options.jsx = ts.JsxEmit.None; + } + else { + throw new Error("Unknown option for jsx: " + value); + } break; default: From b1f90e677582ead794af0cbc575bcb0bd34b5d30 Mon Sep 17 00:00:00 2001 From: Mohamed Hegazy Date: Thu, 20 Aug 2015 00:41:14 -0700 Subject: [PATCH 016/117] change to use map instead of flag, value tuple. --- src/harness/harness.ts | 369 ++++++++++++++++++++--------------------- 1 file changed, 184 insertions(+), 185 deletions(-) diff --git a/src/harness/harness.ts b/src/harness/harness.ts index 6304c6f2c9e..f5a348a23c9 100644 --- a/src/harness/harness.ts +++ b/src/harness/harness.ts @@ -915,190 +915,194 @@ module Harness { includeBuiltFileNames?: string[]; } - export function setCompilerOptionForSetting(setting: Harness.TestCaseParser.CompilerSetting, options: ts.CompilerOptions & HarnesOptions): void { - let name = setting.flag.toLowerCase(); - let value = setting.value ? setting.value.toLowerCase() : setting.value; - switch (name) { - case "module": - if (value === "amd") { - options.module = ts.ModuleKind.AMD; - } else if (value === "umd") { - options.module = ts.ModuleKind.UMD; - } else if (value === "commonjs") { - options.module = ts.ModuleKind.CommonJS; - } else if (value === "system") { - options.module = ts.ModuleKind.System; - } else if (value === "unspecified") { - options.module = ts.ModuleKind.None; - } else { - throw new Error("Unknown module type " + value); + export function setCompilerOptionForSetting(settings: Harness.TestCaseParser.CompilerSettings, options: ts.CompilerOptions & HarnesOptions): void { + for (let name in settings) { + if (settings.hasOwnProperty(name)) { + let value = settings[name] ? settings[name].toLowerCase() : settings[name]; + switch (name.toLowerCase()) { + case "module": + if (value === "amd") { + options.module = ts.ModuleKind.AMD; + } else if (value === "umd") { + options.module = ts.ModuleKind.UMD; + } else if (value === "commonjs") { + options.module = ts.ModuleKind.CommonJS; + } else if (value === "system") { + options.module = ts.ModuleKind.System; + } else if (value === "unspecified") { + options.module = ts.ModuleKind.None; + } else { + throw new Error("Unknown module type " + value); + } + break; + + case "target": + if (value === "es3") { + options.target = ts.ScriptTarget.ES3; + } else if (value === "es5") { + options.target = ts.ScriptTarget.ES5; + } else if (value === "es6") { + options.target = ts.ScriptTarget.ES6; + } else { + throw new Error("Unknown compile target " + value); + } + break; + + case "experimentaldecorators": + options.experimentalDecorators = value === "true"; + break; + + case "emitdecoratormetadata": + options.emitDecoratorMetadata = value === "true"; + break; + + case "experimentalasyncfunctions": + options.experimentalAsyncFunctions = value === "true"; + break; + + case "noemithelpers": + options.noEmitHelpers = value === "true"; + break; + + case "noemitonerror": + options.noEmitOnError = value === "true"; + break; + + case "noresolve": + options.noResolve = value === "true"; + break; + + case "noimplicitany": + options.noImplicitAny = value === "true"; + break; + + case "nolib": + options.noLib = value === "true"; + break; + + case "out": + options.out = settings[name]; + break; + + case "outdir": + options.outDir = settings[name]; + break; + + case "skipdefaultlibcheck": + options.skipDefaultLibCheck = value === "true"; + break; + + case "sourceroot": + options.sourceRoot = settings[name]; + break; + + case "maproot": + options.mapRoot = settings[name]; + break; + + case "sourcemap": + options.sourceMap = value === "true"; + break; + + case "declaration": + options.declaration = value === "true"; + break; + + case "newline": + if (value === "crlf") { + options.newLine = ts.NewLineKind.CarriageReturnLineFeed; + } + else if (value === "lf") { + options.newLine = ts.NewLineKind.LineFeed; + } + else { + throw new Error("Unknown option for newLine: " + value); + } + break; + + case "comments": + options.removeComments = value === "false"; + break; + + case "stripinternal": + options.stripInternal = value === "true"; + break; + + case "usecasesensitivefilenames": + options.useCaseSensitiveFileNames = value === "true"; + break; + + case "filename": + // Not supported yet + break; + + case "emitbom": + options.emitBOM = value === "true"; + break; + + case "errortruncation": + options.noErrorTruncation = value === "false"; + break; + + case "preserveconstenums": + options.preserveConstEnums = value === "true"; + break; + + case "isolatedmodules": + options.isolatedModules = value === "true"; + break; + + case "suppressimplicitanyindexerrors": + options.suppressImplicitAnyIndexErrors = value === "true"; + break; + + case "includebuiltfile": + if (!options.includeBuiltFileNames) { + options.includeBuiltFileNames = []; + } + options.includeBuiltFileNames.push(settings[name]); + break; + + case "inlinesourcemap": + options.inlineSourceMap = value === "true"; + break; + + case "inlinesources": + options.inlineSources = value === "true"; + break; + + case "jsx": + if (value === "react") { + options.jsx = ts.JsxEmit.React; + } + else if (value === "preserve") { + options.jsx = ts.JsxEmit.Preserve; + } + else if (value === "none") { + options.jsx = ts.JsxEmit.None; + } + else { + throw new Error("Unknown option for jsx: " + value); + } + break; + + default: + throw new Error("Unsupported compiler setting " + value); } - break; - - case "target": - if (value === "es3") { - options.target = ts.ScriptTarget.ES3; - } else if (value === "es5") { - options.target = ts.ScriptTarget.ES5; - } else if (value === "es6") { - options.target = ts.ScriptTarget.ES6; - } else { - throw new Error("Unknown compile target " + value); - } - break; - - case "experimentaldecorators": - options.experimentalDecorators = value === "true"; - break; - - case "emitdecoratormetadata": - options.emitDecoratorMetadata = value === "true"; - break; - - case "experimentalasyncfunctions": - options.experimentalAsyncFunctions = value === "true"; - break; - - case "noemithelpers": - options.noEmitHelpers = value === "true"; - break; - - case "noemitonerror": - options.noEmitOnError = value === "true"; - break; - - case "noresolve": - options.noResolve = value === "true"; - break; - - case "noimplicitany": - options.noImplicitAny = value === "true"; - break; - - case "nolib": - options.noLib = value === "true"; - break; - - case "out": - options.out = value; - break; - - case "outdir": - options.outDir = value; - break; - - case "skipdefaultlibcheck": - options.skipDefaultLibCheck = value === "true"; - break; - - case "sourceroot": - options.sourceRoot = value; - break; - - case "maproot": - options.mapRoot = value; - break; - - case "sourcemap": - options.sourceMap = value === "true"; - break; - - case "declaration": - options.declaration = value === "true"; - break; - - case "newline": - if (value === "crlf") { - options.newLine = ts.NewLineKind.CarriageReturnLineFeed; - } - else if (value === "lf") { - options.newLine = ts.NewLineKind.LineFeed; - } - else { - throw new Error("Unknown option for newLine: " + value); - } - break; - - case "comments": - options.removeComments = value === "false"; - break; - - case "stripinternal": - options.stripInternal = value === "true"; - - case "usecasesensitivefilenames": - options.useCaseSensitiveFileNames = value === "true"; - break; - - case "filename": - // Not supported yet - break; - - case "emitbom": - options.emitBOM = value === "true"; - break; - - case "errortruncation": - options.noErrorTruncation = value === "false"; - break; - - case "preserveconstenums": - options.preserveConstEnums = value === "true"; - break; - - case "isolatedmodules": - options.isolatedModules = value === "true"; - break; - - case "suppressimplicitanyindexerrors": - options.suppressImplicitAnyIndexErrors = value === "true"; - break; - - case "includebuiltfile": - if (!options.includeBuiltFileNames) { - options.includeBuiltFileNames = []; - } - options.includeBuiltFileNames.push(value); - break; - - case "inlinesourcemap": - options.inlineSourceMap = value === "true"; - break; - - case "inlinesources": - options.inlineSources = value === "true"; - break; - - case "jsx": - if (value === "react") { - options.jsx = ts.JsxEmit.React; - } - else if (value === "preserve") { - options.jsx = ts.JsxEmit.Preserve; - } - else if (value === "none") { - options.jsx = ts.JsxEmit.None; - } - else { - throw new Error("Unknown option for jsx: " + value); - } - break; - - default: - throw new Error("Unsupported compiler setting " + setting.flag); + } } } export class HarnessCompiler { private inputFiles: { unitName: string; content: string }[] = []; private compileOptions: ts.CompilerOptions; - private settings: Harness.TestCaseParser.CompilerSetting[] = []; + private settings: Harness.TestCaseParser.CompilerSettings = {}; private lastErrors: ts.Diagnostic[]; public reset() { this.inputFiles = []; - this.settings = []; + this.settings = {}; this.lastErrors = []; } @@ -1106,11 +1110,7 @@ module Harness { return this.lastErrors; } - public setCompilerSettingsFromOptions(tcSettings: ts.CompilerOptions) { - this.settings = Object.keys(tcSettings).map(k => ({ flag: k, value: (tcSettings)[k] })); - } - - public setCompilerSettings(tcSettings: Harness.TestCaseParser.CompilerSetting[]) { + public setCompilerSettings(tcSettings: Harness.TestCaseParser.CompilerSettings) { this.settings = tcSettings; } @@ -1164,7 +1164,7 @@ module Harness { options.skipDefaultLibCheck = true; // Parse settings - this.settings.forEach(setting => setCompilerOptionForSetting(setting, options)); + setCompilerOptionForSetting(this.settings, options); // Files from built\local that are requested by test "@includeBuiltFiles" to be in the context. // Treat them as library files, so include them in build, but not in baselines. @@ -1514,9 +1514,8 @@ module Harness { export module TestCaseParser { /** all the necessary information to set the right compiler settings */ - export interface CompilerSetting { - flag: string; - value: string; + export interface CompilerSettings { + [name: string]: string; } /** All the necessary information to turn a multi file test into useful units for later compilation */ @@ -1531,20 +1530,20 @@ module Harness { // Regex for parsing options in the format "@Alpha: Value of any sort" let optionRegex = /^[\/]{2}\s*@(\w+)\s*:\s*(\S*)/gm; // multiple matches on multiple lines - function extractCompilerSettings(content: string): CompilerSetting[] { + function extractCompilerSettings(content: string): CompilerSettings { - let opts: CompilerSetting[] = []; + let opts: CompilerSettings = {}; let match: RegExpExecArray; while ((match = optionRegex.exec(content)) != null) { - opts.push({ flag: match[1], value: match[2] }); + opts[match[1]] = match[2]; } return opts; } /** Given a test file containing // @FileName directives, return an array of named units of code to be added to an existing compiler instance */ - export function makeUnitsFromTest(code: string, fileName: string): { settings: CompilerSetting[]; testUnitData: TestUnitData[]; } { + export function makeUnitsFromTest(code: string, fileName: string): { settings: CompilerSettings; testUnitData: TestUnitData[]; } { let settings = extractCompilerSettings(code); // List of all the subfiles we've parsed out From 014137b544388bc06a25674d0284640260705672 Mon Sep 17 00:00:00 2001 From: Mohamed Hegazy Date: Thu, 20 Aug 2015 00:41:35 -0700 Subject: [PATCH 017/117] remove unused createNewInstance support --- src/harness/compilerRunner.ts | 32 ++------------------------------ 1 file changed, 2 insertions(+), 30 deletions(-) diff --git a/src/harness/compilerRunner.ts b/src/harness/compilerRunner.ts index 87e22e08cfa..a24ed30ae14 100644 --- a/src/harness/compilerRunner.ts +++ b/src/harness/compilerRunner.ts @@ -44,10 +44,10 @@ class CompilerBaselineRunner extends RunnerBase { // Everything declared here should be cleared out in the "after" callback. let justName: string; let content: string; - let testCaseContent: { settings: Harness.TestCaseParser.CompilerSetting[]; testUnitData: Harness.TestCaseParser.TestUnitData[]; }; + let testCaseContent: { settings: Harness.TestCaseParser.CompilerSettings; testUnitData: Harness.TestCaseParser.TestUnitData[]; }; let units: Harness.TestCaseParser.TestUnitData[]; - let tcSettings: Harness.TestCaseParser.CompilerSetting[]; + let tcSettings: Harness.TestCaseParser.CompilerSettings; let lastUnit: Harness.TestCaseParser.TestUnitData; let rootDir: string; @@ -61,15 +61,12 @@ class CompilerBaselineRunner extends RunnerBase { let otherFiles: { unitName: string; content: string }[]; let harnessCompiler: Harness.Compiler.HarnessCompiler; - let createNewInstance = false; - before(() => { justName = fileName.replace(/^.*[\\\/]/, ""); // strips the fileName from the path. content = Harness.IO.readFile(fileName); testCaseContent = Harness.TestCaseParser.makeUnitsFromTest(content, fileName); units = testCaseContent.testUnitData; tcSettings = testCaseContent.settings; - createNewInstance = false; lastUnit = units[units.length - 1]; rootDir = lastUnit.originalFilePath.indexOf("conformance") === -1 ? "tests/cases/compiler/" : lastUnit.originalFilePath.substring(0, lastUnit.originalFilePath.lastIndexOf("/")) + "/"; harnessCompiler = Harness.Compiler.getCompiler(); @@ -100,27 +97,6 @@ class CompilerBaselineRunner extends RunnerBase { }); }); - beforeEach(() => { - /* The compiler doesn't handle certain flags flipping during a single compilation setting. Tests on these flags will need - a fresh compiler instance for themselves and then create a fresh one for the next test. Would be nice to get dev fixes - eventually to remove this limitation. */ - for (let i = 0; i < tcSettings.length; ++i) { - // noImplicitAny is passed to getCompiler, but target is just passed in the settings blob to setCompilerSettings - if (!createNewInstance && (tcSettings[i].flag == "noimplicitany" || tcSettings[i].flag === "target")) { - harnessCompiler = Harness.Compiler.getCompiler(); - harnessCompiler.setCompilerSettings(tcSettings); - createNewInstance = true; - } - } - }); - - afterEach(() => { - if (createNewInstance) { - harnessCompiler = Harness.Compiler.getCompiler(); - createNewInstance = false; - } - }); - after(() => { // Mocha holds onto the closure environment of the describe callback even after the test is done. // Therefore we have to clean out large objects after the test is done. @@ -402,10 +378,6 @@ class CompilerBaselineRunner extends RunnerBase { else { this.tests.forEach(test => this.checkTestCodeOutput(test)); } - - describe("Cleanup after compiler baselines", () => { - let harnessCompiler = Harness.Compiler.getCompiler(); - }); }); } From 21ebc7132583bf306b5b3b27f0478dc6afa84289 Mon Sep 17 00:00:00 2001 From: Yui T Date: Thu, 20 Aug 2015 09:47:45 -0700 Subject: [PATCH 018/117] Don't emit detached comment if removeComment is true --- src/compiler/emitter.ts | 2 +- ...NotEmitdetachedCommentAtStartOfFunctionBody.js | 15 +++++++++++++++ ...itdetachedCommentAtStartOfFunctionBody.symbols | 12 ++++++++++++ ...EmitdetachedCommentAtStartOfFunctionBody.types | 13 +++++++++++++ ...NotEmitdetachedCommentAtStartOfFunctionBody.ts | 10 ++++++++++ 5 files changed, 51 insertions(+), 1 deletion(-) create mode 100644 tests/baselines/reference/doNotEmitdetachedCommentAtStartOfFunctionBody.js create mode 100644 tests/baselines/reference/doNotEmitdetachedCommentAtStartOfFunctionBody.symbols create mode 100644 tests/baselines/reference/doNotEmitdetachedCommentAtStartOfFunctionBody.types create mode 100644 tests/cases/compiler/doNotEmitdetachedCommentAtStartOfFunctionBody.ts diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index 0363122f11f..4ab47346f16 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -7045,7 +7045,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi } function emitDetachedComments(node: TextRange) { - let leadingComments = getLeadingCommentRanges(currentSourceFile.text, node.pos); + let leadingComments = filterComments(getLeadingCommentRanges(currentSourceFile.text, node.pos), node.pos === 0); if (leadingComments) { let detachedComments: CommentRange[] = []; let lastComment: CommentRange; diff --git a/tests/baselines/reference/doNotEmitdetachedCommentAtStartOfFunctionBody.js b/tests/baselines/reference/doNotEmitdetachedCommentAtStartOfFunctionBody.js new file mode 100644 index 00000000000..7dd9c7ce679 --- /dev/null +++ b/tests/baselines/reference/doNotEmitdetachedCommentAtStartOfFunctionBody.js @@ -0,0 +1,15 @@ +//// [doNotEmitdetachedCommentAtStartOfFunctionBody.ts] +function foo() { + /* + + multi line + comment + */ + + return 42; +} + +//// [doNotEmitdetachedCommentAtStartOfFunctionBody.js] +function foo() { + return 42; +} diff --git a/tests/baselines/reference/doNotEmitdetachedCommentAtStartOfFunctionBody.symbols b/tests/baselines/reference/doNotEmitdetachedCommentAtStartOfFunctionBody.symbols new file mode 100644 index 00000000000..a6f8e1514b5 --- /dev/null +++ b/tests/baselines/reference/doNotEmitdetachedCommentAtStartOfFunctionBody.symbols @@ -0,0 +1,12 @@ +=== tests/cases/compiler/doNotEmitdetachedCommentAtStartOfFunctionBody.ts === +function foo() { +>foo : Symbol(foo, Decl(doNotEmitdetachedCommentAtStartOfFunctionBody.ts, 0, 0)) + + /* + + multi line + comment + */ + + return 42; +} diff --git a/tests/baselines/reference/doNotEmitdetachedCommentAtStartOfFunctionBody.types b/tests/baselines/reference/doNotEmitdetachedCommentAtStartOfFunctionBody.types new file mode 100644 index 00000000000..4271584ecbe --- /dev/null +++ b/tests/baselines/reference/doNotEmitdetachedCommentAtStartOfFunctionBody.types @@ -0,0 +1,13 @@ +=== tests/cases/compiler/doNotEmitdetachedCommentAtStartOfFunctionBody.ts === +function foo() { +>foo : () => number + + /* + + multi line + comment + */ + + return 42; +>42 : number +} diff --git a/tests/cases/compiler/doNotEmitdetachedCommentAtStartOfFunctionBody.ts b/tests/cases/compiler/doNotEmitdetachedCommentAtStartOfFunctionBody.ts new file mode 100644 index 00000000000..3d99de36d0a --- /dev/null +++ b/tests/cases/compiler/doNotEmitdetachedCommentAtStartOfFunctionBody.ts @@ -0,0 +1,10 @@ +// @comments: false +function foo() { + /* + + multi line + comment + */ + + return 42; +} \ No newline at end of file From 4b7e2b31398781c3cf5676f1294f80ed1d643853 Mon Sep 17 00:00:00 2001 From: Yui T Date: Thu, 20 Aug 2015 11:31:51 -0700 Subject: [PATCH 019/117] Update tests file for /// and detached comments --- ...leSlashCommentsEvenInAmbientDeclaration.ts | 8 --- .../reference/doNotEmitDetachedComments.js | 33 ++++++++++ .../doNotEmitDetachedComments.symbols | 31 +++++++++ .../reference/doNotEmitDetachedComments.types | 32 ++++++++++ ...mitDetachedCommentsAtStartOfConstructor.js | 64 +++++++++++++++++++ ...tachedCommentsAtStartOfConstructor.symbols | 50 +++++++++++++++ ...DetachedCommentsAtStartOfConstructor.types | 54 ++++++++++++++++ ...itDetachedCommentsAtStartOfFunctionBody.js | 48 ++++++++++++++ ...achedCommentsAtStartOfFunctionBody.symbols | 42 ++++++++++++ ...etachedCommentsAtStartOfFunctionBody.types | 46 +++++++++++++ ...DetachedCommentsAtStartOfLambdaFunction.js | 45 +++++++++++++ ...hedCommentsAtStartOfLambdaFunction.symbols | 32 ++++++++++ ...achedCommentsAtStartOfLambdaFunction.types | 43 +++++++++++++ ...TripleSlashCommentsInAmbientDeclaration.js | 9 ++- ...eSlashCommentsInAmbientDeclaration.symbols | 8 +-- ...pleSlashCommentsInAmbientDeclaration.types | 7 +- ...doNotEmitTripleSlashCommentsInEmptyFile.js | 8 +-- ...EmitTripleSlashCommentsInEmptyFile.symbols | 6 +- ...otEmitTripleSlashCommentsInEmptyFile.types | 6 +- ...doNotEmitTripleSlashCommentsInTheMiddle.js | 15 ----- ...EmitTripleSlashCommentsInTheMiddle.symbols | 13 ---- ...otEmitTripleSlashCommentsInTheMiddle.types | 15 ----- ...mitdetachedCommentAtStartOfFunctionBody.js | 15 ----- ...tachedCommentAtStartOfFunctionBody.symbols | 12 ---- ...detachedCommentAtStartOfFunctionBody.types | 13 ---- .../reference/doNotemitTripleSlashComments.js | 43 +++++++++++-- .../doNotemitTripleSlashComments.symbols | 45 ++++++++++--- .../doNotemitTripleSlashComments.types | 48 +++++++++++--- .../emitPinnedCommentsOnTopOfFile.js | 16 +++++ .../emitPinnedCommentsOnTopOfFile.symbols | 10 +++ .../emitPinnedCommentsOnTopOfFile.types | 11 ++++ .../compiler/doNotEmitDetachedComments.ts | 27 ++++++++ ...mitDetachedCommentsAtStartOfConstructor.ts | 38 +++++++++++ ...itDetachedCommentsAtStartOfFunctionBody.ts | 33 ++++++++++ ...DetachedCommentsAtStartOfLambdaFunction.ts | 30 +++++++++ ...TripleSlashCommentsInAmbientDeclaration.ts | 7 ++ ...doNotEmitTripleSlashCommentsInEmptyFile.ts | 6 +- ...doNotEmitTripleSlashCommentsInTheMiddle.ts | 9 --- ...mitdetachedCommentAtStartOfFunctionBody.ts | 10 --- .../compiler/doNotemitTripleSlashComments.ts | 32 ++++++++-- .../compiler/emitPinnedCommentsOnTopOfFile.ts | 8 +++ 41 files changed, 866 insertions(+), 162 deletions(-) delete mode 100644 doNotEmitTripleSlashCommentsEvenInAmbientDeclaration.ts create mode 100644 tests/baselines/reference/doNotEmitDetachedComments.js create mode 100644 tests/baselines/reference/doNotEmitDetachedComments.symbols create mode 100644 tests/baselines/reference/doNotEmitDetachedComments.types create mode 100644 tests/baselines/reference/doNotEmitDetachedCommentsAtStartOfConstructor.js create mode 100644 tests/baselines/reference/doNotEmitDetachedCommentsAtStartOfConstructor.symbols create mode 100644 tests/baselines/reference/doNotEmitDetachedCommentsAtStartOfConstructor.types create mode 100644 tests/baselines/reference/doNotEmitDetachedCommentsAtStartOfFunctionBody.js create mode 100644 tests/baselines/reference/doNotEmitDetachedCommentsAtStartOfFunctionBody.symbols create mode 100644 tests/baselines/reference/doNotEmitDetachedCommentsAtStartOfFunctionBody.types create mode 100644 tests/baselines/reference/doNotEmitDetachedCommentsAtStartOfLambdaFunction.js create mode 100644 tests/baselines/reference/doNotEmitDetachedCommentsAtStartOfLambdaFunction.symbols create mode 100644 tests/baselines/reference/doNotEmitDetachedCommentsAtStartOfLambdaFunction.types delete mode 100644 tests/baselines/reference/doNotEmitTripleSlashCommentsInTheMiddle.js delete mode 100644 tests/baselines/reference/doNotEmitTripleSlashCommentsInTheMiddle.symbols delete mode 100644 tests/baselines/reference/doNotEmitTripleSlashCommentsInTheMiddle.types delete mode 100644 tests/baselines/reference/doNotEmitdetachedCommentAtStartOfFunctionBody.js delete mode 100644 tests/baselines/reference/doNotEmitdetachedCommentAtStartOfFunctionBody.symbols delete mode 100644 tests/baselines/reference/doNotEmitdetachedCommentAtStartOfFunctionBody.types create mode 100644 tests/baselines/reference/emitPinnedCommentsOnTopOfFile.js create mode 100644 tests/baselines/reference/emitPinnedCommentsOnTopOfFile.symbols create mode 100644 tests/baselines/reference/emitPinnedCommentsOnTopOfFile.types create mode 100644 tests/cases/compiler/doNotEmitDetachedComments.ts create mode 100644 tests/cases/compiler/doNotEmitDetachedCommentsAtStartOfConstructor.ts create mode 100644 tests/cases/compiler/doNotEmitDetachedCommentsAtStartOfFunctionBody.ts create mode 100644 tests/cases/compiler/doNotEmitDetachedCommentsAtStartOfLambdaFunction.ts delete mode 100644 tests/cases/compiler/doNotEmitTripleSlashCommentsInTheMiddle.ts delete mode 100644 tests/cases/compiler/doNotEmitdetachedCommentAtStartOfFunctionBody.ts create mode 100644 tests/cases/compiler/emitPinnedCommentsOnTopOfFile.ts diff --git a/doNotEmitTripleSlashCommentsEvenInAmbientDeclaration.ts b/doNotEmitTripleSlashCommentsEvenInAmbientDeclaration.ts deleted file mode 100644 index 3a89b600c66..00000000000 --- a/doNotEmitTripleSlashCommentsEvenInAmbientDeclaration.ts +++ /dev/null @@ -1,8 +0,0 @@ -// @comments: false - -// @Filename: file0.ts - -// @Fileame: file1.ts - -/// -declare var OData: any; \ No newline at end of file diff --git a/tests/baselines/reference/doNotEmitDetachedComments.js b/tests/baselines/reference/doNotEmitDetachedComments.js new file mode 100644 index 00000000000..74acb537fa8 --- /dev/null +++ b/tests/baselines/reference/doNotEmitDetachedComments.js @@ -0,0 +1,33 @@ +//// [doNotEmitDetachedComments.ts] +/* + + multi line + comment +*/ + +var x = 10; + +// Single Line comment + +function foo() { } + + +/* + multi-line comment + +*/ + + +//======================== + + +function bar() { } + + +//======================== + + +//// [doNotEmitDetachedComments.js] +var x = 10; +function foo() { } +function bar() { } diff --git a/tests/baselines/reference/doNotEmitDetachedComments.symbols b/tests/baselines/reference/doNotEmitDetachedComments.symbols new file mode 100644 index 00000000000..c718da7bb9a --- /dev/null +++ b/tests/baselines/reference/doNotEmitDetachedComments.symbols @@ -0,0 +1,31 @@ +=== tests/cases/compiler/doNotEmitDetachedComments.ts === +/* + + multi line + comment +*/ + +var x = 10; +>x : Symbol(x, Decl(doNotEmitDetachedComments.ts, 6, 3)) + +// Single Line comment + +function foo() { } +>foo : Symbol(foo, Decl(doNotEmitDetachedComments.ts, 6, 11)) + + +/* + multi-line comment + +*/ + + +//======================== + + +function bar() { } +>bar : Symbol(bar, Decl(doNotEmitDetachedComments.ts, 10, 18)) + + +//======================== + diff --git a/tests/baselines/reference/doNotEmitDetachedComments.types b/tests/baselines/reference/doNotEmitDetachedComments.types new file mode 100644 index 00000000000..d9b5f0634c2 --- /dev/null +++ b/tests/baselines/reference/doNotEmitDetachedComments.types @@ -0,0 +1,32 @@ +=== tests/cases/compiler/doNotEmitDetachedComments.ts === +/* + + multi line + comment +*/ + +var x = 10; +>x : number +>10 : number + +// Single Line comment + +function foo() { } +>foo : () => void + + +/* + multi-line comment + +*/ + + +//======================== + + +function bar() { } +>bar : () => void + + +//======================== + diff --git a/tests/baselines/reference/doNotEmitDetachedCommentsAtStartOfConstructor.js b/tests/baselines/reference/doNotEmitDetachedCommentsAtStartOfConstructor.js new file mode 100644 index 00000000000..ba6dbf8b743 --- /dev/null +++ b/tests/baselines/reference/doNotEmitDetachedCommentsAtStartOfConstructor.js @@ -0,0 +1,64 @@ +//// [doNotEmitDetachedCommentsAtStartOfConstructor.ts] +class A { + constructor() { + // Single Line Comment + + var x = 10; + } +} + +class B { + constructor() { + /* + Multi-line comment + */ + + var y = 10; + } +} + +class C { + constructor() { + // Single Line Comment with more than one blank line + + + var x = 10; + } +} + +class D { + constructor() { + /* + Multi-line comment with more than one blank line + */ + + + var y = 10; + } +} + +//// [doNotEmitDetachedCommentsAtStartOfConstructor.js] +var A = (function () { + function A() { + var x = 10; + } + return A; +})(); +var B = (function () { + function B() { + var y = 10; + } + return B; +})(); +var C = (function () { + function C() { + var x = 10; + } + return C; +})(); +var D = (function () { + function D() { + var y = 10; + } + return D; +})(); diff --git a/tests/baselines/reference/doNotEmitDetachedCommentsAtStartOfConstructor.symbols b/tests/baselines/reference/doNotEmitDetachedCommentsAtStartOfConstructor.symbols new file mode 100644 index 00000000000..d7c4f5b2ca9 --- /dev/null +++ b/tests/baselines/reference/doNotEmitDetachedCommentsAtStartOfConstructor.symbols @@ -0,0 +1,50 @@ +=== tests/cases/compiler/doNotEmitDetachedCommentsAtStartOfConstructor.ts === +class A { +>A : Symbol(A, Decl(doNotEmitDetachedCommentsAtStartOfConstructor.ts, 0, 0)) + + constructor() { + // Single Line Comment + + var x = 10; +>x : Symbol(x, Decl(doNotEmitDetachedCommentsAtStartOfConstructor.ts, 4, 11)) + } +} + +class B { +>B : Symbol(B, Decl(doNotEmitDetachedCommentsAtStartOfConstructor.ts, 6, 1)) + + constructor() { + /* + Multi-line comment + */ + + var y = 10; +>y : Symbol(y, Decl(doNotEmitDetachedCommentsAtStartOfConstructor.ts, 14, 11)) + } +} + +class C { +>C : Symbol(C, Decl(doNotEmitDetachedCommentsAtStartOfConstructor.ts, 16, 1)) + + constructor() { + // Single Line Comment with more than one blank line + + + var x = 10; +>x : Symbol(x, Decl(doNotEmitDetachedCommentsAtStartOfConstructor.ts, 23, 11)) + } +} + +class D { +>D : Symbol(D, Decl(doNotEmitDetachedCommentsAtStartOfConstructor.ts, 25, 1)) + + constructor() { + /* + Multi-line comment with more than one blank line + */ + + + var y = 10; +>y : Symbol(y, Decl(doNotEmitDetachedCommentsAtStartOfConstructor.ts, 34, 11)) + } +} diff --git a/tests/baselines/reference/doNotEmitDetachedCommentsAtStartOfConstructor.types b/tests/baselines/reference/doNotEmitDetachedCommentsAtStartOfConstructor.types new file mode 100644 index 00000000000..c316c6403c0 --- /dev/null +++ b/tests/baselines/reference/doNotEmitDetachedCommentsAtStartOfConstructor.types @@ -0,0 +1,54 @@ +=== tests/cases/compiler/doNotEmitDetachedCommentsAtStartOfConstructor.ts === +class A { +>A : A + + constructor() { + // Single Line Comment + + var x = 10; +>x : number +>10 : number + } +} + +class B { +>B : B + + constructor() { + /* + Multi-line comment + */ + + var y = 10; +>y : number +>10 : number + } +} + +class C { +>C : C + + constructor() { + // Single Line Comment with more than one blank line + + + var x = 10; +>x : number +>10 : number + } +} + +class D { +>D : D + + constructor() { + /* + Multi-line comment with more than one blank line + */ + + + var y = 10; +>y : number +>10 : number + } +} diff --git a/tests/baselines/reference/doNotEmitDetachedCommentsAtStartOfFunctionBody.js b/tests/baselines/reference/doNotEmitDetachedCommentsAtStartOfFunctionBody.js new file mode 100644 index 00000000000..dbd0f0be783 --- /dev/null +++ b/tests/baselines/reference/doNotEmitDetachedCommentsAtStartOfFunctionBody.js @@ -0,0 +1,48 @@ +//// [doNotEmitDetachedCommentsAtStartOfFunctionBody.ts] +function foo1() { + // Single line comment + + return 42; +} + +function foo2() { + /* + + multi line + comment + */ + + return 42; +} + +function foo3() { + // Single line comment with more than one blank line + + + return 42; +} + +function foo4() { + /* + + multi line comment with more than one blank line + */ + + return 42; +} + + + +//// [doNotEmitDetachedCommentsAtStartOfFunctionBody.js] +function foo1() { + return 42; +} +function foo2() { + return 42; +} +function foo3() { + return 42; +} +function foo4() { + return 42; +} diff --git a/tests/baselines/reference/doNotEmitDetachedCommentsAtStartOfFunctionBody.symbols b/tests/baselines/reference/doNotEmitDetachedCommentsAtStartOfFunctionBody.symbols new file mode 100644 index 00000000000..c1680100369 --- /dev/null +++ b/tests/baselines/reference/doNotEmitDetachedCommentsAtStartOfFunctionBody.symbols @@ -0,0 +1,42 @@ +=== tests/cases/compiler/doNotEmitDetachedCommentsAtStartOfFunctionBody.ts === +function foo1() { +>foo1 : Symbol(foo1, Decl(doNotEmitDetachedCommentsAtStartOfFunctionBody.ts, 0, 0)) + + // Single line comment + + return 42; +} + +function foo2() { +>foo2 : Symbol(foo2, Decl(doNotEmitDetachedCommentsAtStartOfFunctionBody.ts, 4, 1)) + + /* + + multi line + comment + */ + + return 42; +} + +function foo3() { +>foo3 : Symbol(foo3, Decl(doNotEmitDetachedCommentsAtStartOfFunctionBody.ts, 14, 1)) + + // Single line comment with more than one blank line + + + return 42; +} + +function foo4() { +>foo4 : Symbol(foo4, Decl(doNotEmitDetachedCommentsAtStartOfFunctionBody.ts, 21, 1)) + + /* + + multi line comment with more than one blank line + */ + + return 42; +} + + diff --git a/tests/baselines/reference/doNotEmitDetachedCommentsAtStartOfFunctionBody.types b/tests/baselines/reference/doNotEmitDetachedCommentsAtStartOfFunctionBody.types new file mode 100644 index 00000000000..3b4814bbbb2 --- /dev/null +++ b/tests/baselines/reference/doNotEmitDetachedCommentsAtStartOfFunctionBody.types @@ -0,0 +1,46 @@ +=== tests/cases/compiler/doNotEmitDetachedCommentsAtStartOfFunctionBody.ts === +function foo1() { +>foo1 : () => number + + // Single line comment + + return 42; +>42 : number +} + +function foo2() { +>foo2 : () => number + + /* + + multi line + comment + */ + + return 42; +>42 : number +} + +function foo3() { +>foo3 : () => number + + // Single line comment with more than one blank line + + + return 42; +>42 : number +} + +function foo4() { +>foo4 : () => number + + /* + + multi line comment with more than one blank line + */ + + return 42; +>42 : number +} + + diff --git a/tests/baselines/reference/doNotEmitDetachedCommentsAtStartOfLambdaFunction.js b/tests/baselines/reference/doNotEmitDetachedCommentsAtStartOfLambdaFunction.js new file mode 100644 index 00000000000..7fd5c2b8f8e --- /dev/null +++ b/tests/baselines/reference/doNotEmitDetachedCommentsAtStartOfLambdaFunction.js @@ -0,0 +1,45 @@ +//// [doNotEmitDetachedCommentsAtStartOfLambdaFunction.ts] +() => { + // Single line comment + + return 0; +} + +() => { + /* + multi-line comment + */ + + return 0; +} + +() => { + // Single line comment with more than one blank line + + + return 0; +} + +() => { + /* + multi-line comment with more than one blank line + */ + + + return 0; +} + + +//// [doNotEmitDetachedCommentsAtStartOfLambdaFunction.js] +(function () { + return 0; +}); +(function () { + return 0; +}); +(function () { + return 0; +}); +(function () { + return 0; +}); diff --git a/tests/baselines/reference/doNotEmitDetachedCommentsAtStartOfLambdaFunction.symbols b/tests/baselines/reference/doNotEmitDetachedCommentsAtStartOfLambdaFunction.symbols new file mode 100644 index 00000000000..e57fc793920 --- /dev/null +++ b/tests/baselines/reference/doNotEmitDetachedCommentsAtStartOfLambdaFunction.symbols @@ -0,0 +1,32 @@ +=== tests/cases/compiler/doNotEmitDetachedCommentsAtStartOfLambdaFunction.ts === +() => { +No type information for this code. // Single line comment +No type information for this code. +No type information for this code. return 0; +No type information for this code.} +No type information for this code. +No type information for this code.() => { +No type information for this code. /* +No type information for this code. multi-line comment +No type information for this code. */ +No type information for this code. +No type information for this code. return 0; +No type information for this code.} +No type information for this code. +No type information for this code.() => { +No type information for this code. // Single line comment with more than one blank line +No type information for this code. +No type information for this code. +No type information for this code. return 0; +No type information for this code.} +No type information for this code. +No type information for this code.() => { +No type information for this code. /* +No type information for this code. multi-line comment with more than one blank line +No type information for this code. */ +No type information for this code. +No type information for this code. +No type information for this code. return 0; +No type information for this code.} +No type information for this code. +No type information for this code. \ No newline at end of file diff --git a/tests/baselines/reference/doNotEmitDetachedCommentsAtStartOfLambdaFunction.types b/tests/baselines/reference/doNotEmitDetachedCommentsAtStartOfLambdaFunction.types new file mode 100644 index 00000000000..d90e93d84c5 --- /dev/null +++ b/tests/baselines/reference/doNotEmitDetachedCommentsAtStartOfLambdaFunction.types @@ -0,0 +1,43 @@ +=== tests/cases/compiler/doNotEmitDetachedCommentsAtStartOfLambdaFunction.ts === +() => { +>() => { // Single line comment return 0;} : () => number + + // Single line comment + + return 0; +>0 : number +} + +() => { +>() => { /* multi-line comment */ return 0;} : () => number + + /* + multi-line comment + */ + + return 0; +>0 : number +} + +() => { +>() => { // Single line comment with more than one blank line return 0;} : () => number + + // Single line comment with more than one blank line + + + return 0; +>0 : number +} + +() => { +>() => { /* multi-line comment with more than one blank line */ return 0;} : () => number + + /* + multi-line comment with more than one blank line + */ + + + return 0; +>0 : number +} + diff --git a/tests/baselines/reference/doNotEmitTripleSlashCommentsInAmbientDeclaration.js b/tests/baselines/reference/doNotEmitTripleSlashCommentsInAmbientDeclaration.js index d3c461fe8c2..065c08afefb 100644 --- a/tests/baselines/reference/doNotEmitTripleSlashCommentsInAmbientDeclaration.js +++ b/tests/baselines/reference/doNotEmitTripleSlashCommentsInAmbientDeclaration.js @@ -2,11 +2,18 @@ //// [file0.ts] +/// +class C { + /// + public foo(x: string, y: any) + public foo(x: string, y: number) { } +} //// [file1.ts] +var x = 10; /// declare var OData: any; -//// [file0.js] //// [file1.js] +var x = 10; diff --git a/tests/baselines/reference/doNotEmitTripleSlashCommentsInAmbientDeclaration.symbols b/tests/baselines/reference/doNotEmitTripleSlashCommentsInAmbientDeclaration.symbols index f3566dc7e33..c41f7ed5822 100644 --- a/tests/baselines/reference/doNotEmitTripleSlashCommentsInAmbientDeclaration.symbols +++ b/tests/baselines/reference/doNotEmitTripleSlashCommentsInAmbientDeclaration.symbols @@ -1,10 +1,8 @@ === tests/cases/compiler/file1.ts === +var x = 10; +>x : Symbol(x, Decl(file1.ts, 0, 3)) /// declare var OData: any; ->OData : Symbol(OData, Decl(file1.ts, 2, 11)) +>OData : Symbol(OData, Decl(file1.ts, 3, 11)) -=== tests/cases/compiler/file0.ts === - -No type information for this code. -No type information for this code. \ No newline at end of file diff --git a/tests/baselines/reference/doNotEmitTripleSlashCommentsInAmbientDeclaration.types b/tests/baselines/reference/doNotEmitTripleSlashCommentsInAmbientDeclaration.types index 37ae645a302..f4bb0bbc964 100644 --- a/tests/baselines/reference/doNotEmitTripleSlashCommentsInAmbientDeclaration.types +++ b/tests/baselines/reference/doNotEmitTripleSlashCommentsInAmbientDeclaration.types @@ -1,10 +1,9 @@ === tests/cases/compiler/file1.ts === +var x = 10; +>x : number +>10 : number /// declare var OData: any; >OData : any -=== tests/cases/compiler/file0.ts === - -No type information for this code. -No type information for this code. \ No newline at end of file diff --git a/tests/baselines/reference/doNotEmitTripleSlashCommentsInEmptyFile.js b/tests/baselines/reference/doNotEmitTripleSlashCommentsInEmptyFile.js index 38f6980e5c7..f3b0888a78f 100644 --- a/tests/baselines/reference/doNotEmitTripleSlashCommentsInEmptyFile.js +++ b/tests/baselines/reference/doNotEmitTripleSlashCommentsInEmptyFile.js @@ -3,13 +3,13 @@ //// [file0.ts] -//// [file2.ts] - //// [file1.ts] + +//// [file2.ts] /// -/// +/// /// //// [file0.js] -//// [file2.js] //// [file1.js] +//// [file2.js] diff --git a/tests/baselines/reference/doNotEmitTripleSlashCommentsInEmptyFile.symbols b/tests/baselines/reference/doNotEmitTripleSlashCommentsInEmptyFile.symbols index 7993a31b91e..d18810db280 100644 --- a/tests/baselines/reference/doNotEmitTripleSlashCommentsInEmptyFile.symbols +++ b/tests/baselines/reference/doNotEmitTripleSlashCommentsInEmptyFile.symbols @@ -1,10 +1,10 @@ -=== tests/cases/compiler/file1.ts === +=== tests/cases/compiler/file2.ts === /// -No type information for this code./// +No type information for this code./// No type information for this code./// No type information for this code.=== tests/cases/compiler/file0.ts === No type information for this code. -No type information for this code.=== tests/cases/compiler/file2.ts === +No type information for this code.=== tests/cases/compiler/file1.ts === No type information for this code. \ No newline at end of file diff --git a/tests/baselines/reference/doNotEmitTripleSlashCommentsInEmptyFile.types b/tests/baselines/reference/doNotEmitTripleSlashCommentsInEmptyFile.types index 7993a31b91e..d18810db280 100644 --- a/tests/baselines/reference/doNotEmitTripleSlashCommentsInEmptyFile.types +++ b/tests/baselines/reference/doNotEmitTripleSlashCommentsInEmptyFile.types @@ -1,10 +1,10 @@ -=== tests/cases/compiler/file1.ts === +=== tests/cases/compiler/file2.ts === /// -No type information for this code./// +No type information for this code./// No type information for this code./// No type information for this code.=== tests/cases/compiler/file0.ts === No type information for this code. -No type information for this code.=== tests/cases/compiler/file2.ts === +No type information for this code.=== tests/cases/compiler/file1.ts === No type information for this code. \ No newline at end of file diff --git a/tests/baselines/reference/doNotEmitTripleSlashCommentsInTheMiddle.js b/tests/baselines/reference/doNotEmitTripleSlashCommentsInTheMiddle.js deleted file mode 100644 index 5a1c65a2b6b..00000000000 --- a/tests/baselines/reference/doNotEmitTripleSlashCommentsInTheMiddle.js +++ /dev/null @@ -1,15 +0,0 @@ -//// [tests/cases/compiler/doNotEmitTripleSlashCommentsInTheMiddle.ts] //// - -//// [0.ts] - - -//// [1.ts] -/// -var x = 10; -/// -var y = 1000; - -//// [0.js] -//// [1.js] -var x = 10; -var y = 1000; diff --git a/tests/baselines/reference/doNotEmitTripleSlashCommentsInTheMiddle.symbols b/tests/baselines/reference/doNotEmitTripleSlashCommentsInTheMiddle.symbols deleted file mode 100644 index 353b90f3812..00000000000 --- a/tests/baselines/reference/doNotEmitTripleSlashCommentsInTheMiddle.symbols +++ /dev/null @@ -1,13 +0,0 @@ -=== tests/cases/compiler/1.ts === -/// -var x = 10; ->x : Symbol(x, Decl(1.ts, 1, 3)) - -/// -var y = 1000; ->y : Symbol(y, Decl(1.ts, 3, 3)) - -=== tests/cases/compiler/0.ts === - -No type information for this code. -No type information for this code. \ No newline at end of file diff --git a/tests/baselines/reference/doNotEmitTripleSlashCommentsInTheMiddle.types b/tests/baselines/reference/doNotEmitTripleSlashCommentsInTheMiddle.types deleted file mode 100644 index e26f99fa1a7..00000000000 --- a/tests/baselines/reference/doNotEmitTripleSlashCommentsInTheMiddle.types +++ /dev/null @@ -1,15 +0,0 @@ -=== tests/cases/compiler/1.ts === -/// -var x = 10; ->x : number ->10 : number - -/// -var y = 1000; ->y : number ->1000 : number - -=== tests/cases/compiler/0.ts === - -No type information for this code. -No type information for this code. \ No newline at end of file diff --git a/tests/baselines/reference/doNotEmitdetachedCommentAtStartOfFunctionBody.js b/tests/baselines/reference/doNotEmitdetachedCommentAtStartOfFunctionBody.js deleted file mode 100644 index 7dd9c7ce679..00000000000 --- a/tests/baselines/reference/doNotEmitdetachedCommentAtStartOfFunctionBody.js +++ /dev/null @@ -1,15 +0,0 @@ -//// [doNotEmitdetachedCommentAtStartOfFunctionBody.ts] -function foo() { - /* - - multi line - comment - */ - - return 42; -} - -//// [doNotEmitdetachedCommentAtStartOfFunctionBody.js] -function foo() { - return 42; -} diff --git a/tests/baselines/reference/doNotEmitdetachedCommentAtStartOfFunctionBody.symbols b/tests/baselines/reference/doNotEmitdetachedCommentAtStartOfFunctionBody.symbols deleted file mode 100644 index a6f8e1514b5..00000000000 --- a/tests/baselines/reference/doNotEmitdetachedCommentAtStartOfFunctionBody.symbols +++ /dev/null @@ -1,12 +0,0 @@ -=== tests/cases/compiler/doNotEmitdetachedCommentAtStartOfFunctionBody.ts === -function foo() { ->foo : Symbol(foo, Decl(doNotEmitdetachedCommentAtStartOfFunctionBody.ts, 0, 0)) - - /* - - multi line - comment - */ - - return 42; -} diff --git a/tests/baselines/reference/doNotEmitdetachedCommentAtStartOfFunctionBody.types b/tests/baselines/reference/doNotEmitdetachedCommentAtStartOfFunctionBody.types deleted file mode 100644 index 4271584ecbe..00000000000 --- a/tests/baselines/reference/doNotEmitdetachedCommentAtStartOfFunctionBody.types +++ /dev/null @@ -1,13 +0,0 @@ -=== tests/cases/compiler/doNotEmitdetachedCommentAtStartOfFunctionBody.ts === -function foo() { ->foo : () => number - - /* - - multi line - comment - */ - - return 42; ->42 : number -} diff --git a/tests/baselines/reference/doNotemitTripleSlashComments.js b/tests/baselines/reference/doNotemitTripleSlashComments.js index a2ae1666498..fe17db54cb1 100644 --- a/tests/baselines/reference/doNotemitTripleSlashComments.js +++ b/tests/baselines/reference/doNotemitTripleSlashComments.js @@ -2,16 +2,45 @@ //// [file0.ts] - -//// [file2.ts] +/// +/// +/// +var x = 10; + +/// +var y = "hello"; + + +/// //// [file1.ts] /// -/// -/// -var OData: any; + +function foo() { } + + +/// + + +var z = "world"; + +//// [file2.ts] +/// + + +/// ==================================== + + +function bar() { } + + + //// [file0.js] -//// [file2.js] +var x = 10; +var y = "hello"; //// [file1.js] -var OData; +function foo() { } +var z = "world"; +//// [file2.js] +function bar() { } diff --git a/tests/baselines/reference/doNotemitTripleSlashComments.symbols b/tests/baselines/reference/doNotemitTripleSlashComments.symbols index 7dfcc026914..36b31842f8b 100644 --- a/tests/baselines/reference/doNotemitTripleSlashComments.symbols +++ b/tests/baselines/reference/doNotemitTripleSlashComments.symbols @@ -1,13 +1,40 @@ -=== tests/cases/compiler/file1.ts === -/// -/// -/// -var OData: any; ->OData : Symbol(OData, Decl(file1.ts, 3, 3)) +=== tests/cases/compiler/file2.ts === +/// + + +/// ==================================== + + +function bar() { } +>bar : Symbol(bar, Decl(file2.ts, 0, 0)) + + === tests/cases/compiler/file0.ts === -No type information for this code. -No type information for this code.=== tests/cases/compiler/file2.ts === +/// +/// +/// +var x = 10; +>x : Symbol(x, Decl(file0.ts, 4, 3)) + +/// +var y = "hello"; +>y : Symbol(y, Decl(file0.ts, 7, 3)) + + +/// + +=== tests/cases/compiler/file1.ts === +/// + +function foo() { } +>foo : Symbol(foo, Decl(file1.ts, 0, 0)) + + +/// + + +var z = "world"; +>z : Symbol(z, Decl(file1.ts, 8, 3)) -No type information for this code. \ No newline at end of file diff --git a/tests/baselines/reference/doNotemitTripleSlashComments.types b/tests/baselines/reference/doNotemitTripleSlashComments.types index 51316501655..edebe5687f6 100644 --- a/tests/baselines/reference/doNotemitTripleSlashComments.types +++ b/tests/baselines/reference/doNotemitTripleSlashComments.types @@ -1,13 +1,43 @@ -=== tests/cases/compiler/file1.ts === -/// -/// -/// -var OData: any; ->OData : any +=== tests/cases/compiler/file2.ts === +/// + + +/// ==================================== + + +function bar() { } +>bar : () => void + + === tests/cases/compiler/file0.ts === -No type information for this code. -No type information for this code.=== tests/cases/compiler/file2.ts === +/// +/// +/// +var x = 10; +>x : number +>10 : number + +/// +var y = "hello"; +>y : string +>"hello" : string + + +/// + +=== tests/cases/compiler/file1.ts === +/// + +function foo() { } +>foo : () => void + + +/// + + +var z = "world"; +>z : string +>"world" : string -No type information for this code. \ No newline at end of file diff --git a/tests/baselines/reference/emitPinnedCommentsOnTopOfFile.js b/tests/baselines/reference/emitPinnedCommentsOnTopOfFile.js new file mode 100644 index 00000000000..a30fcbf045d --- /dev/null +++ b/tests/baselines/reference/emitPinnedCommentsOnTopOfFile.js @@ -0,0 +1,16 @@ +//// [emitPinnedCommentsOnTopOfFile.ts] +/*! + + multi line + comment +*/ + +var x = 10; + +//// [emitPinnedCommentsOnTopOfFile.js] +/*! + + multi line + comment +*/ +var x = 10; diff --git a/tests/baselines/reference/emitPinnedCommentsOnTopOfFile.symbols b/tests/baselines/reference/emitPinnedCommentsOnTopOfFile.symbols new file mode 100644 index 00000000000..c9eb5905303 --- /dev/null +++ b/tests/baselines/reference/emitPinnedCommentsOnTopOfFile.symbols @@ -0,0 +1,10 @@ +=== tests/cases/compiler/emitPinnedCommentsOnTopOfFile.ts === +/*! + + multi line + comment +*/ + +var x = 10; +>x : Symbol(x, Decl(emitPinnedCommentsOnTopOfFile.ts, 6, 3)) + diff --git a/tests/baselines/reference/emitPinnedCommentsOnTopOfFile.types b/tests/baselines/reference/emitPinnedCommentsOnTopOfFile.types new file mode 100644 index 00000000000..0ada89e2802 --- /dev/null +++ b/tests/baselines/reference/emitPinnedCommentsOnTopOfFile.types @@ -0,0 +1,11 @@ +=== tests/cases/compiler/emitPinnedCommentsOnTopOfFile.ts === +/*! + + multi line + comment +*/ + +var x = 10; +>x : number +>10 : number + diff --git a/tests/cases/compiler/doNotEmitDetachedComments.ts b/tests/cases/compiler/doNotEmitDetachedComments.ts new file mode 100644 index 00000000000..412dbeac19b --- /dev/null +++ b/tests/cases/compiler/doNotEmitDetachedComments.ts @@ -0,0 +1,27 @@ +// @comments: false +/* + + multi line + comment +*/ + +var x = 10; + +// Single Line comment + +function foo() { } + + +/* + multi-line comment + +*/ + + +//======================== + + +function bar() { } + + +//======================== diff --git a/tests/cases/compiler/doNotEmitDetachedCommentsAtStartOfConstructor.ts b/tests/cases/compiler/doNotEmitDetachedCommentsAtStartOfConstructor.ts new file mode 100644 index 00000000000..1ea96993a5e --- /dev/null +++ b/tests/cases/compiler/doNotEmitDetachedCommentsAtStartOfConstructor.ts @@ -0,0 +1,38 @@ +// @comments: false +class A { + constructor() { + // Single Line Comment + + var x = 10; + } +} + +class B { + constructor() { + /* + Multi-line comment + */ + + var y = 10; + } +} + +class C { + constructor() { + // Single Line Comment with more than one blank line + + + var x = 10; + } +} + +class D { + constructor() { + /* + Multi-line comment with more than one blank line + */ + + + var y = 10; + } +} \ No newline at end of file diff --git a/tests/cases/compiler/doNotEmitDetachedCommentsAtStartOfFunctionBody.ts b/tests/cases/compiler/doNotEmitDetachedCommentsAtStartOfFunctionBody.ts new file mode 100644 index 00000000000..31adbc18de8 --- /dev/null +++ b/tests/cases/compiler/doNotEmitDetachedCommentsAtStartOfFunctionBody.ts @@ -0,0 +1,33 @@ +// @comments: false +function foo1() { + // Single line comment + + return 42; +} + +function foo2() { + /* + + multi line + comment + */ + + return 42; +} + +function foo3() { + // Single line comment with more than one blank line + + + return 42; +} + +function foo4() { + /* + + multi line comment with more than one blank line + */ + + return 42; +} + diff --git a/tests/cases/compiler/doNotEmitDetachedCommentsAtStartOfLambdaFunction.ts b/tests/cases/compiler/doNotEmitDetachedCommentsAtStartOfLambdaFunction.ts new file mode 100644 index 00000000000..c6a9cfc9e25 --- /dev/null +++ b/tests/cases/compiler/doNotEmitDetachedCommentsAtStartOfLambdaFunction.ts @@ -0,0 +1,30 @@ +// @comments: false +() => { + // Single line comment + + return 0; +} + +() => { + /* + multi-line comment + */ + + return 0; +} + +() => { + // Single line comment with more than one blank line + + + return 0; +} + +() => { + /* + multi-line comment with more than one blank line + */ + + + return 0; +} diff --git a/tests/cases/compiler/doNotEmitTripleSlashCommentsInAmbientDeclaration.ts b/tests/cases/compiler/doNotEmitTripleSlashCommentsInAmbientDeclaration.ts index 99f6a292342..7075c9e3b30 100644 --- a/tests/cases/compiler/doNotEmitTripleSlashCommentsInAmbientDeclaration.ts +++ b/tests/cases/compiler/doNotEmitTripleSlashCommentsInAmbientDeclaration.ts @@ -1,8 +1,15 @@ // @comments: false // @Filename: file0.ts +/// +class C { + /// + public foo(x: string, y: any) + public foo(x: string, y: number) { } +} // @Filename: file1.ts +var x = 10; /// declare var OData: any; \ No newline at end of file diff --git a/tests/cases/compiler/doNotEmitTripleSlashCommentsInEmptyFile.ts b/tests/cases/compiler/doNotEmitTripleSlashCommentsInEmptyFile.ts index 41ca8dcab22..047510e2ec9 100644 --- a/tests/cases/compiler/doNotEmitTripleSlashCommentsInEmptyFile.ts +++ b/tests/cases/compiler/doNotEmitTripleSlashCommentsInEmptyFile.ts @@ -2,9 +2,9 @@ // @Filename: file0.ts -// @Filename: file2.ts - // @Filename: file1.ts + +// @Filename: file2.ts /// -/// +/// /// \ No newline at end of file diff --git a/tests/cases/compiler/doNotEmitTripleSlashCommentsInTheMiddle.ts b/tests/cases/compiler/doNotEmitTripleSlashCommentsInTheMiddle.ts deleted file mode 100644 index a0aeecd07f5..00000000000 --- a/tests/cases/compiler/doNotEmitTripleSlashCommentsInTheMiddle.ts +++ /dev/null @@ -1,9 +0,0 @@ -// @comments: false - -// @Filename: 0.ts - -// @filename: 1.ts -/// -var x = 10; -/// -var y = 1000; \ No newline at end of file diff --git a/tests/cases/compiler/doNotEmitdetachedCommentAtStartOfFunctionBody.ts b/tests/cases/compiler/doNotEmitdetachedCommentAtStartOfFunctionBody.ts deleted file mode 100644 index 3d99de36d0a..00000000000 --- a/tests/cases/compiler/doNotEmitdetachedCommentAtStartOfFunctionBody.ts +++ /dev/null @@ -1,10 +0,0 @@ -// @comments: false -function foo() { - /* - - multi line - comment - */ - - return 42; -} \ No newline at end of file diff --git a/tests/cases/compiler/doNotemitTripleSlashComments.ts b/tests/cases/compiler/doNotemitTripleSlashComments.ts index e89586acfa0..f3b90662159 100644 --- a/tests/cases/compiler/doNotemitTripleSlashComments.ts +++ b/tests/cases/compiler/doNotemitTripleSlashComments.ts @@ -1,11 +1,35 @@ // @comments: false // @Filename: file0.ts +/// +/// +/// +var x = 10; -// @Filename: file2.ts +/// +var y = "hello"; + + +/// // @Filename: file1.ts /// -/// -/// -var OData: any; \ No newline at end of file + +function foo() { } + + +/// + + +var z = "world"; + +// @Filename: file2.ts +/// + + +/// ==================================== + + +function bar() { } + + diff --git a/tests/cases/compiler/emitPinnedCommentsOnTopOfFile.ts b/tests/cases/compiler/emitPinnedCommentsOnTopOfFile.ts new file mode 100644 index 00000000000..bbe6c400601 --- /dev/null +++ b/tests/cases/compiler/emitPinnedCommentsOnTopOfFile.ts @@ -0,0 +1,8 @@ +// @comments: false +/*! + + multi line + comment +*/ + +var x = 10; \ No newline at end of file From 539d94502c125d1783456131e00a3e3b8e7ed250 Mon Sep 17 00:00:00 2001 From: Mohamed Hegazy Date: Thu, 20 Aug 2015 14:21:19 -0700 Subject: [PATCH 020/117] Use same parsing function for fourslash tests --- src/harness/fourslash.ts | 80 +++++++--------------------------------- src/harness/harness.ts | 9 +++++ 2 files changed, 22 insertions(+), 67 deletions(-) diff --git a/src/harness/fourslash.ts b/src/harness/fourslash.ts index 1d2ad83d98a..bb2edd52cce 100644 --- a/src/harness/fourslash.ts +++ b/src/harness/fourslash.ts @@ -29,13 +29,13 @@ module FourSlash { fileName: string; version: number; // File-specific options (name/value pairs) - fileOptions: { [index: string]: string; }; + fileOptions: Harness.TestCaseParser.CompilerSettings; } // Represents a set of parsed source files and options export interface FourSlashData { // Global options (name/value pairs) - globalOptions: { [index: string]: string; }; + globalOptions: Harness.TestCaseParser.CompilerSettings; files: FourSlashFile[]; @@ -117,70 +117,18 @@ module FourSlash { // Add cases into convertGlobalOptionsToCompilationsSettings function for the compiler to acknowledge such option from meta data let metadataOptionNames = { baselineFile: "BaselineFile", - declaration: "declaration", emitThisFile: "emitThisFile", // This flag is used for testing getEmitOutput feature. It allows test-cases to indicate what file to be output in multiple files project fileName: "Filename", - mapRoot: "mapRoot", - module: "module", - out: "out", - outDir: "outDir", - sourceMap: "sourceMap", - sourceRoot: "sourceRoot", - allowNonTsExtensions: "allowNonTsExtensions", resolveReference: "ResolveReference", // This flag is used to specify entry file for resolve file references. The flag is only allow once per test file }; // List of allowed metadata names let fileMetadataNames = [metadataOptionNames.fileName, metadataOptionNames.emitThisFile, metadataOptionNames.resolveReference]; - let globalMetadataNames = [metadataOptionNames.allowNonTsExtensions, metadataOptionNames.baselineFile, metadataOptionNames.declaration, - metadataOptionNames.mapRoot, metadataOptionNames.module, metadataOptionNames.out, - metadataOptionNames.outDir, metadataOptionNames.sourceMap, metadataOptionNames.sourceRoot]; function convertGlobalOptionsToCompilerOptions(globalOptions: { [idx: string]: string }): ts.CompilerOptions { let settings: ts.CompilerOptions = { target: ts.ScriptTarget.ES5 }; - // Convert all property in globalOptions into ts.CompilationSettings - for (let prop in globalOptions) { - if (globalOptions.hasOwnProperty(prop)) { - switch (prop) { - case metadataOptionNames.allowNonTsExtensions: - settings.allowNonTsExtensions = globalOptions[prop] === "true"; - break; - case metadataOptionNames.declaration: - settings.declaration = globalOptions[prop] === "true"; - break; - case metadataOptionNames.mapRoot: - settings.mapRoot = globalOptions[prop]; - break; - case metadataOptionNames.module: - // create appropriate external module target for CompilationSettings - switch (globalOptions[prop]) { - case "AMD": - settings.module = ts.ModuleKind.AMD; - break; - case "CommonJS": - settings.module = ts.ModuleKind.CommonJS; - break; - default: - ts.Debug.assert(globalOptions[prop] === undefined || globalOptions[prop] === "None"); - settings.module = ts.ModuleKind.None; - break; - } - break; - case metadataOptionNames.out: - settings.out = globalOptions[prop]; - break; - case metadataOptionNames.outDir: - settings.outDir = globalOptions[prop]; - break; - case metadataOptionNames.sourceMap: - settings.sourceMap = globalOptions[prop] === "true"; - break; - case metadataOptionNames.sourceRoot: - settings.sourceRoot = globalOptions[prop]; - break; - } - } - } + + Harness.Compiler.setCompilerOptionForSetting(globalOptions, settings); return settings; } @@ -2495,12 +2443,16 @@ module FourSlash { // Comment line, check for global/file @options and record them let match = optionRegex.exec(line.substr(2)); if (match) { - let globalMetadataNamesIndex = globalMetadataNames.indexOf(match[1]); let fileMetadataNamesIndex = fileMetadataNames.indexOf(match[1]); - if (globalMetadataNamesIndex === -1) { - if (fileMetadataNamesIndex === -1) { - throw new Error(`Unrecognized metadata name "${match[1]}". Available global metadata names are: ${globalMetadataNames.join(", ")}; file metadata names are: ${fileMetadataNames.join(", ")}`); - } else if (fileMetadataNamesIndex === fileMetadataNames.indexOf(metadataOptionNames.fileName)) { + if (fileMetadataNamesIndex === -1) { + // Check if the match is already existed in the global options + if (globalOptions[match[1]] !== undefined) { + throw new Error("Global Option : '" + match[1] + "' is already existed"); + } + globalOptions[match[1]] = match[2]; + } + else { + if (fileMetadataNamesIndex === fileMetadataNames.indexOf(metadataOptionNames.fileName)) { // Found an @FileName directive, if this is not the first then create a new subfile if (currentFileContent) { let file = parseFileContent(currentFileContent, currentFileName, markerPositions, markers, ranges); @@ -2521,12 +2473,6 @@ module FourSlash { // Add other fileMetadata flag currentFileOptions[match[1]] = match[2]; } - } else { - // Check if the match is already existed in the global options - if (globalOptions[match[1]] !== undefined) { - throw new Error("Global Option : '" + match[1] + "' is already existed"); - } - globalOptions[match[1]] = match[2]; } } // TODO: should be '==='? diff --git a/src/harness/harness.ts b/src/harness/harness.ts index f5a348a23c9..75e497d4706 100644 --- a/src/harness/harness.ts +++ b/src/harness/harness.ts @@ -913,6 +913,7 @@ module Harness { interface HarnesOptions { useCaseSensitiveFileNames?: boolean; includeBuiltFileNames?: string[]; + baselineFile?: string; } export function setCompilerOptionForSetting(settings: Harness.TestCaseParser.CompilerSettings, options: ts.CompilerOptions & HarnesOptions): void { @@ -1086,6 +1087,14 @@ module Harness { } break; + case "allownontsextensions": + options.allowNonTsExtensions = value === "true"; + break; + + case "baselinefile": + options.baselineFile = settings[name]; + break; + default: throw new Error("Unsupported compiler setting " + value); } From 3f66968776915aab765f769368ea254a2d159bd0 Mon Sep 17 00:00:00 2001 From: Yui T Date: Thu, 20 Aug 2015 15:01:59 -0700 Subject: [PATCH 021/117] Only preseve pinned comment at the top of file --- src/compiler/emitter.ts | 4 +- .../doNotEmitPinnedCommentNotOnTopOfFile.js | 14 +++++++ ...NotEmitPinnedCommentNotOnTopOfFile.symbols | 13 ++++++ ...doNotEmitPinnedCommentNotOnTopOfFile.types | 15 +++++++ .../doNotEmitPinnedCommentOnNotEmittedNode.js | 21 ++++++++++ ...tEmitPinnedCommentOnNotEmittedNode.symbols | 24 +++++++++++ ...NotEmitPinnedCommentOnNotEmittedNode.types | 25 +++++++++++ ...oNotEmitPinnedCommentOnNotEmittedNodets.js | 18 ++++++++ ...mitPinnedCommentOnNotEmittedNodets.symbols | 21 ++++++++++ ...tEmitPinnedCommentOnNotEmittedNodets.types | 21 ++++++++++ .../doNotEmitPinnedDetachedComments.js | 42 +++++++++++++++++++ .../doNotEmitPinnedDetachedComments.symbols | 39 +++++++++++++++++ .../doNotEmitPinnedDetachedComments.types | 41 ++++++++++++++++++ .../doNotEmitPinnedCommentNotOnTopOfFile.ts | 10 +++++ .../doNotEmitPinnedCommentOnNotEmittedNode.ts | 13 ++++++ ...oNotEmitPinnedCommentOnNotEmittedNodets.ts | 10 +++++ .../doNotEmitPinnedDetachedComments.ts | 32 ++++++++++++++ 17 files changed, 361 insertions(+), 2 deletions(-) create mode 100644 tests/baselines/reference/doNotEmitPinnedCommentNotOnTopOfFile.js create mode 100644 tests/baselines/reference/doNotEmitPinnedCommentNotOnTopOfFile.symbols create mode 100644 tests/baselines/reference/doNotEmitPinnedCommentNotOnTopOfFile.types create mode 100644 tests/baselines/reference/doNotEmitPinnedCommentOnNotEmittedNode.js create mode 100644 tests/baselines/reference/doNotEmitPinnedCommentOnNotEmittedNode.symbols create mode 100644 tests/baselines/reference/doNotEmitPinnedCommentOnNotEmittedNode.types create mode 100644 tests/baselines/reference/doNotEmitPinnedCommentOnNotEmittedNodets.js create mode 100644 tests/baselines/reference/doNotEmitPinnedCommentOnNotEmittedNodets.symbols create mode 100644 tests/baselines/reference/doNotEmitPinnedCommentOnNotEmittedNodets.types create mode 100644 tests/baselines/reference/doNotEmitPinnedDetachedComments.js create mode 100644 tests/baselines/reference/doNotEmitPinnedDetachedComments.symbols create mode 100644 tests/baselines/reference/doNotEmitPinnedDetachedComments.types create mode 100644 tests/cases/compiler/doNotEmitPinnedCommentNotOnTopOfFile.ts create mode 100644 tests/cases/compiler/doNotEmitPinnedCommentOnNotEmittedNode.ts create mode 100644 tests/cases/compiler/doNotEmitPinnedCommentOnNotEmittedNodets.ts create mode 100644 tests/cases/compiler/doNotEmitPinnedDetachedComments.ts diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index 4ab47346f16..b524f37d47e 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -6923,11 +6923,11 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi } function filterComments(ranges: CommentRange[], isTopOfFileComments: boolean, isEmittedNode=true): CommentRange[] { + // TODO (yuisu): comment if (compilerOptions.removeComments) { - ranges = filter(ranges, isPinnedComments); + ranges = isTopOfFileComments ? filter(ranges, isPinnedComments) : []; } else { - // TODO (yuisu): comment if (!isEmittedNode) { ranges = isTopOfFileComments ? filter(ranges, isTripleSlashOrPinnedComments) : filter(ranges, isPinnedComments); } diff --git a/tests/baselines/reference/doNotEmitPinnedCommentNotOnTopOfFile.js b/tests/baselines/reference/doNotEmitPinnedCommentNotOnTopOfFile.js new file mode 100644 index 00000000000..8232ad66ef5 --- /dev/null +++ b/tests/baselines/reference/doNotEmitPinnedCommentNotOnTopOfFile.js @@ -0,0 +1,14 @@ +//// [doNotEmitPinnedCommentNotOnTopOfFile.ts] +var x = 10; + +/*! + + multi line + comment +*/ + +var x = 10; + +//// [doNotEmitPinnedCommentNotOnTopOfFile.js] +var x = 10; +var x = 10; diff --git a/tests/baselines/reference/doNotEmitPinnedCommentNotOnTopOfFile.symbols b/tests/baselines/reference/doNotEmitPinnedCommentNotOnTopOfFile.symbols new file mode 100644 index 00000000000..97cfb5df214 --- /dev/null +++ b/tests/baselines/reference/doNotEmitPinnedCommentNotOnTopOfFile.symbols @@ -0,0 +1,13 @@ +=== tests/cases/compiler/doNotEmitPinnedCommentNotOnTopOfFile.ts === +var x = 10; +>x : Symbol(x, Decl(doNotEmitPinnedCommentNotOnTopOfFile.ts, 0, 3), Decl(doNotEmitPinnedCommentNotOnTopOfFile.ts, 8, 3)) + +/*! + + multi line + comment +*/ + +var x = 10; +>x : Symbol(x, Decl(doNotEmitPinnedCommentNotOnTopOfFile.ts, 0, 3), Decl(doNotEmitPinnedCommentNotOnTopOfFile.ts, 8, 3)) + diff --git a/tests/baselines/reference/doNotEmitPinnedCommentNotOnTopOfFile.types b/tests/baselines/reference/doNotEmitPinnedCommentNotOnTopOfFile.types new file mode 100644 index 00000000000..3426c70dfb9 --- /dev/null +++ b/tests/baselines/reference/doNotEmitPinnedCommentNotOnTopOfFile.types @@ -0,0 +1,15 @@ +=== tests/cases/compiler/doNotEmitPinnedCommentNotOnTopOfFile.ts === +var x = 10; +>x : number +>10 : number + +/*! + + multi line + comment +*/ + +var x = 10; +>x : number +>10 : number + diff --git a/tests/baselines/reference/doNotEmitPinnedCommentOnNotEmittedNode.js b/tests/baselines/reference/doNotEmitPinnedCommentOnNotEmittedNode.js new file mode 100644 index 00000000000..99e50801d50 --- /dev/null +++ b/tests/baselines/reference/doNotEmitPinnedCommentOnNotEmittedNode.js @@ -0,0 +1,21 @@ +//// [doNotEmitPinnedCommentOnNotEmittedNode.ts] + +class C { + /*! remove pinned comment anywhere else */ + public foo(x: string, y: any) + public foo(x: string, y: number) { } +} + +var x = 10; + +/*! remove pinned comment anywhere else */ +declare var OData: any; + +//// [doNotEmitPinnedCommentOnNotEmittedNode.js] +var C = (function () { + function C() { + } + C.prototype.foo = function (x, y) { }; + return C; +})(); +var x = 10; diff --git a/tests/baselines/reference/doNotEmitPinnedCommentOnNotEmittedNode.symbols b/tests/baselines/reference/doNotEmitPinnedCommentOnNotEmittedNode.symbols new file mode 100644 index 00000000000..64609266044 --- /dev/null +++ b/tests/baselines/reference/doNotEmitPinnedCommentOnNotEmittedNode.symbols @@ -0,0 +1,24 @@ +=== tests/cases/compiler/doNotEmitPinnedCommentOnNotEmittedNode.ts === + +class C { +>C : Symbol(C, Decl(doNotEmitPinnedCommentOnNotEmittedNode.ts, 0, 0)) + + /*! remove pinned comment anywhere else */ + public foo(x: string, y: any) +>foo : Symbol(foo, Decl(doNotEmitPinnedCommentOnNotEmittedNode.ts, 1, 9), Decl(doNotEmitPinnedCommentOnNotEmittedNode.ts, 3, 33)) +>x : Symbol(x, Decl(doNotEmitPinnedCommentOnNotEmittedNode.ts, 3, 15)) +>y : Symbol(y, Decl(doNotEmitPinnedCommentOnNotEmittedNode.ts, 3, 25)) + + public foo(x: string, y: number) { } +>foo : Symbol(foo, Decl(doNotEmitPinnedCommentOnNotEmittedNode.ts, 1, 9), Decl(doNotEmitPinnedCommentOnNotEmittedNode.ts, 3, 33)) +>x : Symbol(x, Decl(doNotEmitPinnedCommentOnNotEmittedNode.ts, 4, 15)) +>y : Symbol(y, Decl(doNotEmitPinnedCommentOnNotEmittedNode.ts, 4, 25)) +} + +var x = 10; +>x : Symbol(x, Decl(doNotEmitPinnedCommentOnNotEmittedNode.ts, 7, 3)) + +/*! remove pinned comment anywhere else */ +declare var OData: any; +>OData : Symbol(OData, Decl(doNotEmitPinnedCommentOnNotEmittedNode.ts, 10, 11)) + diff --git a/tests/baselines/reference/doNotEmitPinnedCommentOnNotEmittedNode.types b/tests/baselines/reference/doNotEmitPinnedCommentOnNotEmittedNode.types new file mode 100644 index 00000000000..b0f71137c2d --- /dev/null +++ b/tests/baselines/reference/doNotEmitPinnedCommentOnNotEmittedNode.types @@ -0,0 +1,25 @@ +=== tests/cases/compiler/doNotEmitPinnedCommentOnNotEmittedNode.ts === + +class C { +>C : C + + /*! remove pinned comment anywhere else */ + public foo(x: string, y: any) +>foo : (x: string, y: any) => any +>x : string +>y : any + + public foo(x: string, y: number) { } +>foo : (x: string, y: any) => any +>x : string +>y : number +} + +var x = 10; +>x : number +>10 : number + +/*! remove pinned comment anywhere else */ +declare var OData: any; +>OData : any + diff --git a/tests/baselines/reference/doNotEmitPinnedCommentOnNotEmittedNodets.js b/tests/baselines/reference/doNotEmitPinnedCommentOnNotEmittedNodets.js new file mode 100644 index 00000000000..66896350e6d --- /dev/null +++ b/tests/baselines/reference/doNotEmitPinnedCommentOnNotEmittedNodets.js @@ -0,0 +1,18 @@ +//// [doNotEmitPinnedCommentOnNotEmittedNodets.ts] + +class C { + /*! remove pinned comment anywhere else */ + public foo(x: string, y: any) + public foo(x: string, y: number) { } +} + +/*! remove pinned comment anywhere else */ +declare var OData: any; + +//// [doNotEmitPinnedCommentOnNotEmittedNodets.js] +var C = (function () { + function C() { + } + C.prototype.foo = function (x, y) { }; + return C; +})(); diff --git a/tests/baselines/reference/doNotEmitPinnedCommentOnNotEmittedNodets.symbols b/tests/baselines/reference/doNotEmitPinnedCommentOnNotEmittedNodets.symbols new file mode 100644 index 00000000000..dcd27478115 --- /dev/null +++ b/tests/baselines/reference/doNotEmitPinnedCommentOnNotEmittedNodets.symbols @@ -0,0 +1,21 @@ +=== tests/cases/compiler/doNotEmitPinnedCommentOnNotEmittedNodets.ts === + +class C { +>C : Symbol(C, Decl(doNotEmitPinnedCommentOnNotEmittedNodets.ts, 0, 0)) + + /*! remove pinned comment anywhere else */ + public foo(x: string, y: any) +>foo : Symbol(foo, Decl(doNotEmitPinnedCommentOnNotEmittedNodets.ts, 1, 9), Decl(doNotEmitPinnedCommentOnNotEmittedNodets.ts, 3, 33)) +>x : Symbol(x, Decl(doNotEmitPinnedCommentOnNotEmittedNodets.ts, 3, 15)) +>y : Symbol(y, Decl(doNotEmitPinnedCommentOnNotEmittedNodets.ts, 3, 25)) + + public foo(x: string, y: number) { } +>foo : Symbol(foo, Decl(doNotEmitPinnedCommentOnNotEmittedNodets.ts, 1, 9), Decl(doNotEmitPinnedCommentOnNotEmittedNodets.ts, 3, 33)) +>x : Symbol(x, Decl(doNotEmitPinnedCommentOnNotEmittedNodets.ts, 4, 15)) +>y : Symbol(y, Decl(doNotEmitPinnedCommentOnNotEmittedNodets.ts, 4, 25)) +} + +/*! remove pinned comment anywhere else */ +declare var OData: any; +>OData : Symbol(OData, Decl(doNotEmitPinnedCommentOnNotEmittedNodets.ts, 8, 11)) + diff --git a/tests/baselines/reference/doNotEmitPinnedCommentOnNotEmittedNodets.types b/tests/baselines/reference/doNotEmitPinnedCommentOnNotEmittedNodets.types new file mode 100644 index 00000000000..4369af63f53 --- /dev/null +++ b/tests/baselines/reference/doNotEmitPinnedCommentOnNotEmittedNodets.types @@ -0,0 +1,21 @@ +=== tests/cases/compiler/doNotEmitPinnedCommentOnNotEmittedNodets.ts === + +class C { +>C : C + + /*! remove pinned comment anywhere else */ + public foo(x: string, y: any) +>foo : (x: string, y: any) => any +>x : string +>y : any + + public foo(x: string, y: number) { } +>foo : (x: string, y: any) => any +>x : string +>y : number +} + +/*! remove pinned comment anywhere else */ +declare var OData: any; +>OData : any + diff --git a/tests/baselines/reference/doNotEmitPinnedDetachedComments.js b/tests/baselines/reference/doNotEmitPinnedDetachedComments.js new file mode 100644 index 00000000000..5f5a3b19aaa --- /dev/null +++ b/tests/baselines/reference/doNotEmitPinnedDetachedComments.js @@ -0,0 +1,42 @@ +//// [doNotEmitPinnedDetachedComments.ts] +var x = 10; + +/*! Single Line comment */ + +function baz() { } + + +/*! + multi-line comment + +*/ + + +//======================== + + +function bar() { + /*! + Remove this comment + */ + +} + +function foo() { + /*! Remove this */ + + return 0; +} + + +//======================== + + +//// [doNotEmitPinnedDetachedComments.js] +var x = 10; +function baz() { } +function bar() { +} +function foo() { + return 0; +} diff --git a/tests/baselines/reference/doNotEmitPinnedDetachedComments.symbols b/tests/baselines/reference/doNotEmitPinnedDetachedComments.symbols new file mode 100644 index 00000000000..2be35804b38 --- /dev/null +++ b/tests/baselines/reference/doNotEmitPinnedDetachedComments.symbols @@ -0,0 +1,39 @@ +=== tests/cases/compiler/doNotEmitPinnedDetachedComments.ts === +var x = 10; +>x : Symbol(x, Decl(doNotEmitPinnedDetachedComments.ts, 0, 3)) + +/*! Single Line comment */ + +function baz() { } +>baz : Symbol(baz, Decl(doNotEmitPinnedDetachedComments.ts, 0, 11)) + + +/*! + multi-line comment + +*/ + + +//======================== + + +function bar() { +>bar : Symbol(bar, Decl(doNotEmitPinnedDetachedComments.ts, 4, 18)) + + /*! + Remove this comment + */ + +} + +function foo() { +>foo : Symbol(foo, Decl(doNotEmitPinnedDetachedComments.ts, 21, 1)) + + /*! Remove this */ + + return 0; +} + + +//======================== + diff --git a/tests/baselines/reference/doNotEmitPinnedDetachedComments.types b/tests/baselines/reference/doNotEmitPinnedDetachedComments.types new file mode 100644 index 00000000000..d9e78e2f980 --- /dev/null +++ b/tests/baselines/reference/doNotEmitPinnedDetachedComments.types @@ -0,0 +1,41 @@ +=== tests/cases/compiler/doNotEmitPinnedDetachedComments.ts === +var x = 10; +>x : number +>10 : number + +/*! Single Line comment */ + +function baz() { } +>baz : () => void + + +/*! + multi-line comment + +*/ + + +//======================== + + +function bar() { +>bar : () => void + + /*! + Remove this comment + */ + +} + +function foo() { +>foo : () => number + + /*! Remove this */ + + return 0; +>0 : number +} + + +//======================== + diff --git a/tests/cases/compiler/doNotEmitPinnedCommentNotOnTopOfFile.ts b/tests/cases/compiler/doNotEmitPinnedCommentNotOnTopOfFile.ts new file mode 100644 index 00000000000..0fbb1fddd81 --- /dev/null +++ b/tests/cases/compiler/doNotEmitPinnedCommentNotOnTopOfFile.ts @@ -0,0 +1,10 @@ +// @comments: false +var x = 10; + +/*! + + multi line + comment +*/ + +var x = 10; \ No newline at end of file diff --git a/tests/cases/compiler/doNotEmitPinnedCommentOnNotEmittedNode.ts b/tests/cases/compiler/doNotEmitPinnedCommentOnNotEmittedNode.ts new file mode 100644 index 00000000000..48e02a372f7 --- /dev/null +++ b/tests/cases/compiler/doNotEmitPinnedCommentOnNotEmittedNode.ts @@ -0,0 +1,13 @@ +// @comments: false + +class C { + /*! remove pinned comment anywhere else */ + public foo(x: string, y: any) + public foo(x: string, y: number) { } +} + +// @Filename: file1.ts +var x = 10; + +/*! remove pinned comment anywhere else */ +declare var OData: any; \ No newline at end of file diff --git a/tests/cases/compiler/doNotEmitPinnedCommentOnNotEmittedNodets.ts b/tests/cases/compiler/doNotEmitPinnedCommentOnNotEmittedNodets.ts new file mode 100644 index 00000000000..a59e13df55c --- /dev/null +++ b/tests/cases/compiler/doNotEmitPinnedCommentOnNotEmittedNodets.ts @@ -0,0 +1,10 @@ +// @comments: false + +class C { + /*! remove pinned comment anywhere else */ + public foo(x: string, y: any) + public foo(x: string, y: number) { } +} + +/*! remove pinned comment anywhere else */ +declare var OData: any; \ No newline at end of file diff --git a/tests/cases/compiler/doNotEmitPinnedDetachedComments.ts b/tests/cases/compiler/doNotEmitPinnedDetachedComments.ts new file mode 100644 index 00000000000..534963cf4b7 --- /dev/null +++ b/tests/cases/compiler/doNotEmitPinnedDetachedComments.ts @@ -0,0 +1,32 @@ +// @comments: false +var x = 10; + +/*! Single Line comment */ + +function baz() { } + + +/*! + multi-line comment + +*/ + + +//======================== + + +function bar() { + /*! + Remove this comment + */ + +} + +function foo() { + /*! Remove this */ + + return 0; +} + + +//======================== From 8eff741961d7ffff748cd4ac251da9c24e56c47c Mon Sep 17 00:00:00 2001 From: Yui T Date: Thu, 20 Aug 2015 15:02:46 -0700 Subject: [PATCH 022/117] Add test in case of remove /// on node that will not be emitted when removeComment is true --- ...TripleSlashCommentsInAmbientDeclaration.js | 19 ------------------- ...eSlashCommentsInAmbientDeclaration.symbols | 8 -------- ...EmitTripleSlashCommentsOnNotEmittedNode.js | 15 +++++++++++++++ ...ripleSlashCommentsOnNotEmittedNode.symbols | 12 ++++++++++++ ...TripleSlashCommentsOnNotEmittedNode.types} | 11 +++++++---- ...TripleSlashCommentsInAmbientDeclaration.ts | 15 --------------- ...EmitTripleSlashCommentsOnNotEmittedNode.ts | 10 ++++++++++ 7 files changed, 44 insertions(+), 46 deletions(-) delete mode 100644 tests/baselines/reference/doNotEmitTripleSlashCommentsInAmbientDeclaration.js delete mode 100644 tests/baselines/reference/doNotEmitTripleSlashCommentsInAmbientDeclaration.symbols create mode 100644 tests/baselines/reference/doNotEmitTripleSlashCommentsOnNotEmittedNode.js create mode 100644 tests/baselines/reference/doNotEmitTripleSlashCommentsOnNotEmittedNode.symbols rename tests/baselines/reference/{doNotEmitTripleSlashCommentsInAmbientDeclaration.types => doNotEmitTripleSlashCommentsOnNotEmittedNode.types} (50%) delete mode 100644 tests/cases/compiler/doNotEmitTripleSlashCommentsInAmbientDeclaration.ts create mode 100644 tests/cases/compiler/doNotEmitTripleSlashCommentsOnNotEmittedNode.ts diff --git a/tests/baselines/reference/doNotEmitTripleSlashCommentsInAmbientDeclaration.js b/tests/baselines/reference/doNotEmitTripleSlashCommentsInAmbientDeclaration.js deleted file mode 100644 index 065c08afefb..00000000000 --- a/tests/baselines/reference/doNotEmitTripleSlashCommentsInAmbientDeclaration.js +++ /dev/null @@ -1,19 +0,0 @@ -//// [tests/cases/compiler/doNotEmitTripleSlashCommentsInAmbientDeclaration.ts] //// - -//// [file0.ts] - -/// -class C { - /// - public foo(x: string, y: any) - public foo(x: string, y: number) { } -} - -//// [file1.ts] -var x = 10; - -/// -declare var OData: any; - -//// [file1.js] -var x = 10; diff --git a/tests/baselines/reference/doNotEmitTripleSlashCommentsInAmbientDeclaration.symbols b/tests/baselines/reference/doNotEmitTripleSlashCommentsInAmbientDeclaration.symbols deleted file mode 100644 index c41f7ed5822..00000000000 --- a/tests/baselines/reference/doNotEmitTripleSlashCommentsInAmbientDeclaration.symbols +++ /dev/null @@ -1,8 +0,0 @@ -=== tests/cases/compiler/file1.ts === -var x = 10; ->x : Symbol(x, Decl(file1.ts, 0, 3)) - -/// -declare var OData: any; ->OData : Symbol(OData, Decl(file1.ts, 3, 11)) - diff --git a/tests/baselines/reference/doNotEmitTripleSlashCommentsOnNotEmittedNode.js b/tests/baselines/reference/doNotEmitTripleSlashCommentsOnNotEmittedNode.js new file mode 100644 index 00000000000..9067b5b80a9 --- /dev/null +++ b/tests/baselines/reference/doNotEmitTripleSlashCommentsOnNotEmittedNode.js @@ -0,0 +1,15 @@ +//// [tests/cases/compiler/doNotEmitTripleSlashCommentsOnNotEmittedNode.ts] //// + +//// [file0.ts] + +/// +declare var OData: any; + +//// [file1.ts] +/// +interface F { } + + + +//// [file0.js] +//// [file1.js] diff --git a/tests/baselines/reference/doNotEmitTripleSlashCommentsOnNotEmittedNode.symbols b/tests/baselines/reference/doNotEmitTripleSlashCommentsOnNotEmittedNode.symbols new file mode 100644 index 00000000000..bb920d2ee1c --- /dev/null +++ b/tests/baselines/reference/doNotEmitTripleSlashCommentsOnNotEmittedNode.symbols @@ -0,0 +1,12 @@ +=== tests/cases/compiler/file1.ts === +/// +interface F { } +>F : Symbol(F, Decl(file1.ts, 0, 0)) + + +=== tests/cases/compiler/file0.ts === + +/// +declare var OData: any; +>OData : Symbol(OData, Decl(file0.ts, 2, 11)) + diff --git a/tests/baselines/reference/doNotEmitTripleSlashCommentsInAmbientDeclaration.types b/tests/baselines/reference/doNotEmitTripleSlashCommentsOnNotEmittedNode.types similarity index 50% rename from tests/baselines/reference/doNotEmitTripleSlashCommentsInAmbientDeclaration.types rename to tests/baselines/reference/doNotEmitTripleSlashCommentsOnNotEmittedNode.types index f4bb0bbc964..59b63ea1a2f 100644 --- a/tests/baselines/reference/doNotEmitTripleSlashCommentsInAmbientDeclaration.types +++ b/tests/baselines/reference/doNotEmitTripleSlashCommentsOnNotEmittedNode.types @@ -1,9 +1,12 @@ === tests/cases/compiler/file1.ts === -var x = 10; ->x : number ->10 : number - /// +interface F { } +>F : F + + +=== tests/cases/compiler/file0.ts === + +/// declare var OData: any; >OData : any diff --git a/tests/cases/compiler/doNotEmitTripleSlashCommentsInAmbientDeclaration.ts b/tests/cases/compiler/doNotEmitTripleSlashCommentsInAmbientDeclaration.ts deleted file mode 100644 index 7075c9e3b30..00000000000 --- a/tests/cases/compiler/doNotEmitTripleSlashCommentsInAmbientDeclaration.ts +++ /dev/null @@ -1,15 +0,0 @@ -// @comments: false - -// @Filename: file0.ts -/// -class C { - /// - public foo(x: string, y: any) - public foo(x: string, y: number) { } -} - -// @Filename: file1.ts -var x = 10; - -/// -declare var OData: any; \ No newline at end of file diff --git a/tests/cases/compiler/doNotEmitTripleSlashCommentsOnNotEmittedNode.ts b/tests/cases/compiler/doNotEmitTripleSlashCommentsOnNotEmittedNode.ts new file mode 100644 index 00000000000..91941a6cf81 --- /dev/null +++ b/tests/cases/compiler/doNotEmitTripleSlashCommentsOnNotEmittedNode.ts @@ -0,0 +1,10 @@ +// @comments: false + +// @Filename: file0.ts +/// +declare var OData: any; + +// @Filename: file1.ts +/// +interface F { } + From c851a60ed9447791e3f6fe4abf199ffb845c8639 Mon Sep 17 00:00:00 2001 From: Yui T Date: Thu, 20 Aug 2015 16:16:17 -0700 Subject: [PATCH 023/117] Add test to make sure /// is preserved when removeComments is false --- ...OnNotEmittedNodeIfRemoveCommentsIsFalse.js | 20 +++++++++++++++++++ ...EmittedNodeIfRemoveCommentsIsFalse.symbols | 16 +++++++++++++++ ...otEmittedNodeIfRemoveCommentsIsFalse.types | 17 ++++++++++++++++ ...OnNotEmittedNodeIfRemoveCommentsIsFalse.ts | 13 ++++++++++++ 4 files changed, 66 insertions(+) create mode 100644 tests/baselines/reference/emitTopOfFileTripleSlashCommentOnNotEmittedNodeIfRemoveCommentsIsFalse.js create mode 100644 tests/baselines/reference/emitTopOfFileTripleSlashCommentOnNotEmittedNodeIfRemoveCommentsIsFalse.symbols create mode 100644 tests/baselines/reference/emitTopOfFileTripleSlashCommentOnNotEmittedNodeIfRemoveCommentsIsFalse.types create mode 100644 tests/cases/compiler/emitTopOfFileTripleSlashCommentOnNotEmittedNodeIfRemoveCommentsIsFalse.ts diff --git a/tests/baselines/reference/emitTopOfFileTripleSlashCommentOnNotEmittedNodeIfRemoveCommentsIsFalse.js b/tests/baselines/reference/emitTopOfFileTripleSlashCommentOnNotEmittedNodeIfRemoveCommentsIsFalse.js new file mode 100644 index 00000000000..ff358518568 --- /dev/null +++ b/tests/baselines/reference/emitTopOfFileTripleSlashCommentOnNotEmittedNodeIfRemoveCommentsIsFalse.js @@ -0,0 +1,20 @@ +//// [tests/cases/compiler/emitTopOfFileTripleSlashCommentOnNotEmittedNodeIfRemoveCommentsIsFalse.ts] //// + +//// [file0.ts] + +var x = 10 + +//// [file1.ts] +/// +declare var OData: any; + +/// +interface F { } + + + + +//// [file0.js] +var x = 10; +//// [file1.js] +/// diff --git a/tests/baselines/reference/emitTopOfFileTripleSlashCommentOnNotEmittedNodeIfRemoveCommentsIsFalse.symbols b/tests/baselines/reference/emitTopOfFileTripleSlashCommentOnNotEmittedNodeIfRemoveCommentsIsFalse.symbols new file mode 100644 index 00000000000..1c0e48e00f2 --- /dev/null +++ b/tests/baselines/reference/emitTopOfFileTripleSlashCommentOnNotEmittedNodeIfRemoveCommentsIsFalse.symbols @@ -0,0 +1,16 @@ +=== tests/cases/compiler/file1.ts === +/// +declare var OData: any; +>OData : Symbol(OData, Decl(file1.ts, 1, 11)) + +/// +interface F { } +>F : Symbol(F, Decl(file1.ts, 1, 23)) + + + +=== tests/cases/compiler/file0.ts === + +var x = 10 +>x : Symbol(x, Decl(file0.ts, 1, 3)) + diff --git a/tests/baselines/reference/emitTopOfFileTripleSlashCommentOnNotEmittedNodeIfRemoveCommentsIsFalse.types b/tests/baselines/reference/emitTopOfFileTripleSlashCommentOnNotEmittedNodeIfRemoveCommentsIsFalse.types new file mode 100644 index 00000000000..637196fdc22 --- /dev/null +++ b/tests/baselines/reference/emitTopOfFileTripleSlashCommentOnNotEmittedNodeIfRemoveCommentsIsFalse.types @@ -0,0 +1,17 @@ +=== tests/cases/compiler/file1.ts === +/// +declare var OData: any; +>OData : any + +/// +interface F { } +>F : F + + + +=== tests/cases/compiler/file0.ts === + +var x = 10 +>x : number +>10 : number + diff --git a/tests/cases/compiler/emitTopOfFileTripleSlashCommentOnNotEmittedNodeIfRemoveCommentsIsFalse.ts b/tests/cases/compiler/emitTopOfFileTripleSlashCommentOnNotEmittedNodeIfRemoveCommentsIsFalse.ts new file mode 100644 index 00000000000..20c04702544 --- /dev/null +++ b/tests/cases/compiler/emitTopOfFileTripleSlashCommentOnNotEmittedNodeIfRemoveCommentsIsFalse.ts @@ -0,0 +1,13 @@ +// @comments: true + +// @Filename: file0.ts +var x = 10 + +// @Filename: file1.ts +/// +declare var OData: any; + +/// +interface F { } + + From eda9aead1149abc0c12fd33f5f9ab03e8b89d469 Mon Sep 17 00:00:00 2001 From: Yui T Date: Thu, 20 Aug 2015 16:21:58 -0700 Subject: [PATCH 024/117] Add comments --- src/compiler/emitter.ts | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index b524f37d47e..4b85f22e7ca 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -6922,13 +6922,30 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi return leadingComments; } + /** + * Filter comment when removeComments is true according to following rules: + * - Pinned Comments - remove all but the top of the file one + * - Normal Comments - remove all + * - // Comments - remove all + * @param isTopOfFileComments boolean indicating whether comments are at the top of file + * @param isEmittedNode boolean indicating whether node associated with the comments will be + * emitted in javascript file + */ function filterComments(ranges: CommentRange[], isTopOfFileComments: boolean, isEmittedNode=true): CommentRange[] { - // TODO (yuisu): comment if (compilerOptions.removeComments) { + // Only preserve pinned comments at the top of the file ranges = isTopOfFileComments ? filter(ranges, isPinnedComments) : []; } else { if (!isEmittedNode) { + // If the node will not be emitted in JS, remove all the comments(normal, pinned and ///) associated with the node, + // unless it is a triple slash comment at the top of the file. + // For Example: + // /// + // declare var x; + // /// + // interface F {} + // The first /// will NOT be removed while the second one will be removed eventhough both node will not be emitted ranges = isTopOfFileComments ? filter(ranges, isTripleSlashOrPinnedComments) : filter(ranges, isPinnedComments); } } From c88908e30097a757bfb2c7d7c73b678eb52a7d07 Mon Sep 17 00:00:00 2001 From: Yui T Date: Thu, 20 Aug 2015 16:29:55 -0700 Subject: [PATCH 025/117] Add comments --- src/compiler/emitter.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index 4b85f22e7ca..d07373613ac 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -7003,8 +7003,10 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi } } + /** + * Emit comments associated with node that will not be emitted into JS file + */ function emitCommentsOnNotEmittedNode(node: Node) { - /// TODO (yuisu): comments emitLeadingCommentsWorker(node, /*isEmittedNode:*/ false); } From 55d7edf89f3b32cdaf400709b3a47c7407d964d6 Mon Sep 17 00:00:00 2001 From: Mohamed Hegazy Date: Fri, 21 Aug 2015 15:50:31 -0700 Subject: [PATCH 026/117] Rename setCompilerOptionsFromSetting to setCompilerOptionsFromHarnessSetting --- src/harness/fourslash.ts | 2 +- src/harness/harness.ts | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/harness/fourslash.ts b/src/harness/fourslash.ts index c2961f60ab6..ae131b8390f 100644 --- a/src/harness/fourslash.ts +++ b/src/harness/fourslash.ts @@ -127,7 +127,7 @@ module FourSlash { function convertGlobalOptionsToCompilerOptions(globalOptions: { [idx: string]: string }): ts.CompilerOptions { let settings: ts.CompilerOptions = { target: ts.ScriptTarget.ES5 }; - Harness.Compiler.setCompilerOptionForSetting(globalOptions, settings); + Harness.Compiler.setCompilerOptionsFromHarnessSetting(globalOptions, settings); return settings; } diff --git a/src/harness/harness.ts b/src/harness/harness.ts index 741a9e700a0..1e4d1174d90 100644 --- a/src/harness/harness.ts +++ b/src/harness/harness.ts @@ -942,7 +942,7 @@ module Harness { baselineFile?: string; } - export function setCompilerOptionForSetting(settings: Harness.TestCaseParser.CompilerSettings, options: ts.CompilerOptions & HarnesOptions): void { + export function setCompilerOptionsFromHarnessSetting(settings: Harness.TestCaseParser.CompilerSettings, options: ts.CompilerOptions & HarnesOptions): void { for (let name in settings) { if (settings.hasOwnProperty(name)) { let value = settings[name] ? settings[name].toLowerCase() : settings[name]; @@ -1203,7 +1203,7 @@ module Harness { options.skipDefaultLibCheck = true; // Parse settings - setCompilerOptionForSetting(this.settings, options); + setCompilerOptionsFromHarnessSetting(this.settings, options); // Files from built\local that are requested by test "@includeBuiltFiles" to be in the context. // Treat them as library files, so include them in build, but not in baselines. From b911dc3faf7ebbcd9ce5df2ef7d4a78a9c35e8cc Mon Sep 17 00:00:00 2001 From: Mohamed Hegazy Date: Fri, 21 Aug 2015 17:17:16 -0700 Subject: [PATCH 027/117] git fix wrong merge --- src/harness/harness.ts | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/harness/harness.ts b/src/harness/harness.ts index 1e4d1174d90..e168c9419d5 100644 --- a/src/harness/harness.ts +++ b/src/harness/harness.ts @@ -1213,8 +1213,8 @@ module Harness { includeBuiltFiles.push({ unitName: builtFileName, content: normalizeLineEndings(IO.readFile(builtFileName), newLine) }); }); - let useCaseSensitiveFileNames = options.useCaseSensitiveFileNames !== undefined ? options.useCaseSensitiveFileNames : ts.sys.useCaseSensitiveFileNames; - + let useCaseSensitiveFileNames = options.useCaseSensitiveFileNames !== undefined ? options.useCaseSensitiveFileNames : Harness.IO.useCaseSensitiveFileNames(); + let fileOutputs: GeneratedFile[] = []; let programFiles = inputFiles.concat(includeBuiltFiles).map(file => file.unitName); @@ -1230,13 +1230,10 @@ module Harness { let errors = ts.getPreEmitDiagnostics(program).concat(emitResult.diagnostics); this.lastErrors = errors; - let result = new CompilerResult(fileOutputs, errors, program, ts.sys.getCurrentDirectory(), emitResult.sourceMaps); + let result = new CompilerResult(fileOutputs, errors, program, Harness.IO.getCurrentDirectory(), emitResult.sourceMaps); onComplete(result, program); - // reset what newline means in case the last test changed it - ts.sys.newLine = newLine; return options; - } public compileDeclarationFiles(inputFiles: { unitName: string; content: string; }[], From 60e25a7e1d60c47d71a50fa1ed64dac954c8748a Mon Sep 17 00:00:00 2001 From: Mohamed Hegazy Date: Fri, 21 Aug 2015 19:17:09 -0700 Subject: [PATCH 028/117] use commandlineParser's optionDeclarations to parse compiler options instead of doing it explicitlly --- src/harness/harness.ts | 262 +++++------------- .../compiler/commentInEmptyParameterList1.ts | 2 +- tests/cases/compiler/commentOnClassMethod1.ts | 2 +- .../compiler/commentOnExpressionStatement1.ts | 2 +- tests/cases/compiler/commentOnIfStatement1.ts | 2 +- .../compiler/commentOnImportStatement1.ts | 4 +- .../compiler/commentOnImportStatement2.ts | 4 +- .../compiler/commentOnImportStatement3.ts | 4 +- .../commentOnSimpleArrowFunctionBody1.ts | 2 +- .../commentsBeforeFunctionExpression1.ts | 2 +- .../commentsBeforeVariableStatement1.ts | 4 +- tests/cases/compiler/commentsClass.ts | 2 +- tests/cases/compiler/commentsClassMembers.ts | 2 +- .../cases/compiler/commentsCommentParsing.ts | 2 +- .../compiler/commentsDottedModuleName.ts | 4 +- tests/cases/compiler/commentsEnums.ts | 2 +- .../cases/compiler/commentsExternalModules.ts | 4 +- .../compiler/commentsExternalModules2.ts | 4 +- .../compiler/commentsExternalModules3.ts | 4 +- tests/cases/compiler/commentsFormatting.ts | 2 +- tests/cases/compiler/commentsFunction.ts | 2 +- tests/cases/compiler/commentsInheritance.ts | 2 +- tests/cases/compiler/commentsInterface.ts | 2 +- tests/cases/compiler/commentsModules.ts | 2 +- .../compiler/commentsMultiModuleMultiFile.ts | 4 +- .../compiler/commentsMultiModuleSingleFile.ts | 2 +- .../compiler/commentsOnObjectLiteral1.ts | 2 +- .../compiler/commentsOnObjectLiteral2.ts | 2 +- .../compiler/commentsOnObjectLiteral3.ts | 2 +- .../compiler/commentsOnObjectLiteral4.ts | 2 +- .../compiler/commentsOnReturnStatement1.ts | 2 +- .../cases/compiler/commentsOnStaticMembers.ts | 2 +- tests/cases/compiler/commentsOverloads.ts | 2 +- .../compiler/commentsPropertySignature1.ts | 2 +- .../cases/compiler/commentsTypeParameters.ts | 2 +- tests/cases/compiler/commentsVarDecl.ts | 2 +- .../compiler/commentsVariableStatement1.ts | 2 +- .../compiler/commentsdoNotEmitComments.ts | 2 +- tests/cases/compiler/commentsemitComments.ts | 2 +- .../compiler/constEnumToStringNoComments.ts | 2 +- .../compiler/constEnumToStringWithComments.ts | 2 +- tests/cases/compiler/declFileAccessors.ts | 2 +- .../cases/compiler/declFileCallSignatures.ts | 2 +- .../compiler/declFileConstructSignatures.ts | 2 +- tests/cases/compiler/declFileConstructors.ts | 2 +- tests/cases/compiler/declFileFunctions.ts | 2 +- .../cases/compiler/declFileIndexSignatures.ts | 2 +- tests/cases/compiler/declFileMethods.ts | 2 +- tests/cases/compiler/emitCommentsOnlyFile.ts | 2 +- tests/cases/compiler/emitPostComments.ts | 2 +- tests/cases/compiler/emitPreComments.ts | 2 +- .../cases/compiler/errorWithTruncatedType.ts | 2 +- .../externalModuleWithoutCompilerFlag1.ts | 1 - tests/cases/compiler/lambdaASIEmit.ts | 2 +- tests/cases/compiler/out-flag.ts | 2 +- tests/cases/compiler/pinnedComments1.ts | 2 +- .../compiler/sourceMap-FileWithComments.ts | 2 +- 57 files changed, 127 insertions(+), 264 deletions(-) diff --git a/src/harness/harness.ts b/src/harness/harness.ts index e168c9419d5..213faf365a1 100644 --- a/src/harness/harness.ts +++ b/src/harness/harness.ts @@ -838,9 +838,9 @@ module Harness { } export function createSourceFileAndAssertInvariants( - fileName: string, - sourceText: string, - languageVersion: ts.ScriptTarget) { + fileName: string, + sourceText: string, + languageVersion: ts.ScriptTarget) { // We'll only assert inletiants outside of light mode. const shouldAssertInvariants = !Harness.lightMode; @@ -870,13 +870,13 @@ module Harness { } export function createCompilerHost( - inputFiles: { unitName: string; content: string; }[], - writeFile: (fn: string, contents: string, writeByteOrderMark: boolean) => void, - scriptTarget: ts.ScriptTarget, - useCaseSensitiveFileNames: boolean, - // the currentDirectory is needed for rwcRunner to passed in specified current directory to compiler host - currentDirectory?: string, - newLineKind?: ts.NewLineKind): ts.CompilerHost { + inputFiles: { unitName: string; content: string; }[], + writeFile: (fn: string, contents: string, writeByteOrderMark: boolean) => void, + scriptTarget: ts.ScriptTarget, + useCaseSensitiveFileNames: boolean, + // the currentDirectory is needed for rwcRunner to passed in specified current directory to compiler host + currentDirectory?: string, + newLineKind?: ts.NewLineKind): ts.CompilerHost { // Local get canonical file name function, that depends on passed in parameter for useCaseSensitiveFileNames function getCanonicalFileName(fileName: string): string { @@ -894,7 +894,7 @@ module Harness { } }; inputFiles.forEach(register); - + function getSourceFile(fn: string, languageVersion: ts.ScriptTarget) { fn = ts.normalizePath(fn); if (Object.prototype.hasOwnProperty.call(filemap, getCanonicalFileName(fn))) { @@ -938,200 +938,64 @@ module Harness { interface HarnesOptions { useCaseSensitiveFileNames?: boolean; - includeBuiltFileNames?: string[]; + includeBuiltFile?: string; baselineFile?: string; } + // Additional options not already in ts.optionDeclarations + const harnessOptionDeclarations: ts.CommandLineOption[] = [ + { name: "allowNonTsExtensions", type: "boolean" }, + { name: "useCaseSensitiveFileNames", type: "boolean" }, + { name: "baselineFile", type: "string" }, + { name: "includeBuiltFile", type: "string" }, + { name: "fileName", type: "string" }, + { name: "noErrorTruncation", type: "boolean" } + ]; + + let optionsIndex: ts.Map; + function getCommandLineOption(name: string): ts.CommandLineOption { + if (!optionsIndex) { + optionsIndex = {}; + let optionDeclarations = harnessOptionDeclarations.concat(ts.optionDeclarations); + for (let option of optionDeclarations) { + optionsIndex[option.name.toLowerCase()] = option; + } + } + return ts.lookUp(optionsIndex, name.toLowerCase()); + } + export function setCompilerOptionsFromHarnessSetting(settings: Harness.TestCaseParser.CompilerSettings, options: ts.CompilerOptions & HarnesOptions): void { for (let name in settings) { if (settings.hasOwnProperty(name)) { - let value = settings[name] ? settings[name].toLowerCase() : settings[name]; - switch (name.toLowerCase()) { - case "module": - if (value === "amd") { - options.module = ts.ModuleKind.AMD; - } else if (value === "umd") { - options.module = ts.ModuleKind.UMD; - } else if (value === "commonjs") { - options.module = ts.ModuleKind.CommonJS; - } else if (value === "system") { - options.module = ts.ModuleKind.System; - } else if (value === "unspecified") { - options.module = ts.ModuleKind.None; - } else { - throw new Error("Unknown module type " + value); - } - break; - - case "target": - if (value === "es3") { - options.target = ts.ScriptTarget.ES3; - } else if (value === "es5") { - options.target = ts.ScriptTarget.ES5; - } else if (value === "es6") { - options.target = ts.ScriptTarget.ES6; - } else { - throw new Error("Unknown compile target " + value); - } - break; - - case "experimentaldecorators": - options.experimentalDecorators = value === "true"; - break; - - case "emitdecoratormetadata": - options.emitDecoratorMetadata = value === "true"; - break; - - case "experimentalasyncfunctions": - options.experimentalAsyncFunctions = value === "true"; - break; - - case "noemithelpers": - options.noEmitHelpers = value === "true"; - break; - - case "noemitonerror": - options.noEmitOnError = value === "true"; - break; - - case "noresolve": - options.noResolve = value === "true"; - break; - - case "noimplicitany": - options.noImplicitAny = value === "true"; - break; - - case "nolib": - options.noLib = value === "true"; - break; - - case "out": - options.out = settings[name]; - break; - - case "outfile": - options.outFile = settings[name]; - break; - - case "outdir": - options.outDir = settings[name]; - break; - - case "skipdefaultlibcheck": - options.skipDefaultLibCheck = value === "true"; - break; - - case "sourceroot": - options.sourceRoot = settings[name]; - break; - - case "maproot": - options.mapRoot = settings[name]; - break; - - case "sourcemap": - options.sourceMap = value === "true"; - break; - - case "declaration": - options.declaration = value === "true"; - break; - - case "newline": - if (value === "crlf") { - options.newLine = ts.NewLineKind.CarriageReturnLineFeed; - } - else if (value === "lf") { - options.newLine = ts.NewLineKind.LineFeed; - } - else { - throw new Error("Unknown option for newLine: " + value); - } - break; - - case "comments": - options.removeComments = value === "false"; - break; - - case "stripinternal": - options.stripInternal = value === "true"; - break; - - case "usecasesensitivefilenames": - options.useCaseSensitiveFileNames = value === "true"; - break; - - case "filename": - // Not supported yet - break; - - case "emitbom": - options.emitBOM = value === "true"; - break; - - case "errortruncation": - options.noErrorTruncation = value === "false"; - break; - - case "preserveconstenums": - options.preserveConstEnums = value === "true"; - break; - - case "isolatedmodules": - options.isolatedModules = value === "true"; - break; - - case "suppressimplicitanyindexerrors": - options.suppressImplicitAnyIndexErrors = value === "true"; - break; - - case "includebuiltfile": - if (!options.includeBuiltFileNames) { - options.includeBuiltFileNames = []; - } - options.includeBuiltFileNames.push(settings[name]); - break; - - case "inlinesourcemap": - options.inlineSourceMap = value === "true"; - break; - - case "inlinesources": - options.inlineSources = value === "true"; - break; - - case "jsx": - if (value === "react") { - options.jsx = ts.JsxEmit.React; - } - else if (value === "preserve") { - options.jsx = ts.JsxEmit.Preserve; - } - else if (value === "none") { - options.jsx = ts.JsxEmit.None; - } - else { - throw new Error("Unknown option for jsx: " + value); - } - break; - - case "allownontsextensions": - options.allowNonTsExtensions = value === "true"; - break; - - case "baselinefile": - options.baselineFile = settings[name]; - break; - - default: - throw new Error("Unsupported compiler setting " + value); + let value = settings[name]; + let option = getCommandLineOption(name); + if (option) { + switch (option.type) { + case "boolean": + options[option.name] = value.toLowerCase() === "true"; + break; + case "string": + options[option.name] = value; + break; + // If not a primitive, the possible types are specified in what is effectively a map of options. + default: + let map = >option.type; + let key = (value).toLowerCase(); + if (ts.hasProperty(map, key)) { + options[option.name] = map[key]; + } + else { + throw new Error(`Unkown value '${value}' for compiler option '${name}'.`); + } + } + } + else { + throw new Error(`Unkown compiler option '${name}'.`); } } } } - + export class HarnessCompiler { private inputFiles: { unitName: string; content: string }[] = []; private compileOptions: ts.CompilerOptions; @@ -1194,13 +1058,13 @@ module Harness { options.module = options.module || ts.ModuleKind.None; options.newLine = options.newLine || ts.NewLineKind.CarriageReturnLineFeed; options.noErrorTruncation = true; + options.skipDefaultLibCheck = true; if (settingsCallback) { settingsCallback(null); } let newLine = "\r\n"; - options.skipDefaultLibCheck = true; // Parse settings setCompilerOptionsFromHarnessSetting(this.settings, options); @@ -1208,10 +1072,10 @@ module Harness { // Files from built\local that are requested by test "@includeBuiltFiles" to be in the context. // Treat them as library files, so include them in build, but not in baselines. let includeBuiltFiles: { unitName: string; content: string }[] = []; - ts.forEach(options.includeBuiltFileNames, fileName => { - let builtFileName = libFolder + fileName; + if (options.includeBuiltFile) { + let builtFileName = libFolder + options.includeBuiltFile; includeBuiltFiles.push({ unitName: builtFileName, content: normalizeLineEndings(IO.readFile(builtFileName), newLine) }); - }); + } let useCaseSensitiveFileNames = options.useCaseSensitiveFileNames !== undefined ? options.useCaseSensitiveFileNames : Harness.IO.useCaseSensitiveFileNames(); diff --git a/tests/cases/compiler/commentInEmptyParameterList1.ts b/tests/cases/compiler/commentInEmptyParameterList1.ts index cae197735d5..65ddbca16dd 100644 --- a/tests/cases/compiler/commentInEmptyParameterList1.ts +++ b/tests/cases/compiler/commentInEmptyParameterList1.ts @@ -1,3 +1,3 @@ -// @comments:true +// @removeComments: false function foo(/** nothing */) { } \ No newline at end of file diff --git a/tests/cases/compiler/commentOnClassMethod1.ts b/tests/cases/compiler/commentOnClassMethod1.ts index 048e0de984c..a4cca2be8a2 100644 --- a/tests/cases/compiler/commentOnClassMethod1.ts +++ b/tests/cases/compiler/commentOnClassMethod1.ts @@ -1,4 +1,4 @@ -// @comments:true +// @removeComments: false class WebControls { /** * Render a control diff --git a/tests/cases/compiler/commentOnExpressionStatement1.ts b/tests/cases/compiler/commentOnExpressionStatement1.ts index 430d226ff70..2f64fbcc08d 100644 --- a/tests/cases/compiler/commentOnExpressionStatement1.ts +++ b/tests/cases/compiler/commentOnExpressionStatement1.ts @@ -1,3 +1,3 @@ -// @comments: true +// @removeComments: false 1 + 1; // Comment. \ No newline at end of file diff --git a/tests/cases/compiler/commentOnIfStatement1.ts b/tests/cases/compiler/commentOnIfStatement1.ts index afff0000c86..295a0f513f7 100644 --- a/tests/cases/compiler/commentOnIfStatement1.ts +++ b/tests/cases/compiler/commentOnIfStatement1.ts @@ -1,4 +1,4 @@ -// @comments: true +// @removeComments: false // Test if (true) { diff --git a/tests/cases/compiler/commentOnImportStatement1.ts b/tests/cases/compiler/commentOnImportStatement1.ts index e26faf21fb6..597509075b3 100644 --- a/tests/cases/compiler/commentOnImportStatement1.ts +++ b/tests/cases/compiler/commentOnImportStatement1.ts @@ -1,5 +1,5 @@ -//@module: amd -// @comments: true +// @module: amd +// @removeComments: false /* Copyright */ import foo = require('./foo'); diff --git a/tests/cases/compiler/commentOnImportStatement2.ts b/tests/cases/compiler/commentOnImportStatement2.ts index 096041f3f5b..ccb5b57887a 100644 --- a/tests/cases/compiler/commentOnImportStatement2.ts +++ b/tests/cases/compiler/commentOnImportStatement2.ts @@ -1,4 +1,4 @@ -//@module: commonjs -// @comments: true +// @module: commonjs +// @removeComments: false /* not copyright */ import foo = require('./foo'); \ No newline at end of file diff --git a/tests/cases/compiler/commentOnImportStatement3.ts b/tests/cases/compiler/commentOnImportStatement3.ts index 0cfef3feeff..d60756ecf7e 100644 --- a/tests/cases/compiler/commentOnImportStatement3.ts +++ b/tests/cases/compiler/commentOnImportStatement3.ts @@ -1,5 +1,5 @@ -//@module: commonjs -// @comments: true +// @module: commonjs +// @removeComments: false /* copyright */ /* not copyright */ diff --git a/tests/cases/compiler/commentOnSimpleArrowFunctionBody1.ts b/tests/cases/compiler/commentOnSimpleArrowFunctionBody1.ts index 548548de3d6..b1edc61cb82 100644 --- a/tests/cases/compiler/commentOnSimpleArrowFunctionBody1.ts +++ b/tests/cases/compiler/commentOnSimpleArrowFunctionBody1.ts @@ -1,4 +1,4 @@ -// @comments: true +// @removeComments: false function Foo(x: any) { } diff --git a/tests/cases/compiler/commentsBeforeFunctionExpression1.ts b/tests/cases/compiler/commentsBeforeFunctionExpression1.ts index 64fe3b7b6ec..d3b21c18475 100644 --- a/tests/cases/compiler/commentsBeforeFunctionExpression1.ts +++ b/tests/cases/compiler/commentsBeforeFunctionExpression1.ts @@ -1,4 +1,4 @@ -// @comments:true +// @removeComments: false var v = { f: /**own f*/ (a) => 0 } diff --git a/tests/cases/compiler/commentsBeforeVariableStatement1.ts b/tests/cases/compiler/commentsBeforeVariableStatement1.ts index e6c49f17d7f..e4e019cef5e 100644 --- a/tests/cases/compiler/commentsBeforeVariableStatement1.ts +++ b/tests/cases/compiler/commentsBeforeVariableStatement1.ts @@ -1,4 +1,4 @@ -//@module: amd -// @comments: true +// @module: amd +// @removeComments: false /** b's comment*/ export var b: number; diff --git a/tests/cases/compiler/commentsClass.ts b/tests/cases/compiler/commentsClass.ts index e9a8f3cee1d..8823f5db6d2 100644 --- a/tests/cases/compiler/commentsClass.ts +++ b/tests/cases/compiler/commentsClass.ts @@ -1,6 +1,6 @@ // @target: ES5 // @declaration: true -// @comments: true +// @removeComments: false /** This is class c2 without constuctor*/ class c2 { diff --git a/tests/cases/compiler/commentsClassMembers.ts b/tests/cases/compiler/commentsClassMembers.ts index 92a3a1356f2..414f560c2a7 100644 --- a/tests/cases/compiler/commentsClassMembers.ts +++ b/tests/cases/compiler/commentsClassMembers.ts @@ -1,6 +1,6 @@ // @target: ES5 // @declaration: true -// @comments: true +// @removeComments: false /** This is comment for c1*/ class c1 { diff --git a/tests/cases/compiler/commentsCommentParsing.ts b/tests/cases/compiler/commentsCommentParsing.ts index 7bfc9de4fd2..a1fbf50c61f 100644 --- a/tests/cases/compiler/commentsCommentParsing.ts +++ b/tests/cases/compiler/commentsCommentParsing.ts @@ -1,6 +1,6 @@ // @target: ES5 // @declaration: true -// @comments: true +// @removeComments: false /// This is simple /// comments function simple() { diff --git a/tests/cases/compiler/commentsDottedModuleName.ts b/tests/cases/compiler/commentsDottedModuleName.ts index 136d189d1ac..55266931036 100644 --- a/tests/cases/compiler/commentsDottedModuleName.ts +++ b/tests/cases/compiler/commentsDottedModuleName.ts @@ -1,7 +1,7 @@ -//@module: amd +// @module: amd // @target: ES5 // @declaration: true -// @comments: true +// @removeComments: false /** this is multi declare module*/ export module outerModule.InnerModule { diff --git a/tests/cases/compiler/commentsEnums.ts b/tests/cases/compiler/commentsEnums.ts index 2d69c863f2d..d7d654c1e72 100644 --- a/tests/cases/compiler/commentsEnums.ts +++ b/tests/cases/compiler/commentsEnums.ts @@ -1,6 +1,6 @@ // @target: ES5 // @declaration: true -// @comments: true +// @removeComments: false /** Enum of colors*/ enum Colors { diff --git a/tests/cases/compiler/commentsExternalModules.ts b/tests/cases/compiler/commentsExternalModules.ts index 86c6b2be8d3..04489611427 100644 --- a/tests/cases/compiler/commentsExternalModules.ts +++ b/tests/cases/compiler/commentsExternalModules.ts @@ -1,7 +1,7 @@ -//@module: amd +// @module: amd // @target: ES5 // @declaration: true -// @comments: true +// @removeComments: false // @Filename: commentsExternalModules_0.ts /** Module comment*/ diff --git a/tests/cases/compiler/commentsExternalModules2.ts b/tests/cases/compiler/commentsExternalModules2.ts index 354e74738be..b1dfb04902b 100644 --- a/tests/cases/compiler/commentsExternalModules2.ts +++ b/tests/cases/compiler/commentsExternalModules2.ts @@ -1,7 +1,7 @@ -//@module: amd +// @module: amd // @target: ES5 // @declaration: true -// @comments: true +// @removeComments: false // @Filename: commentsExternalModules2_0.ts /** Module comment*/ diff --git a/tests/cases/compiler/commentsExternalModules3.ts b/tests/cases/compiler/commentsExternalModules3.ts index 2f214c5d28c..e6979939ac8 100644 --- a/tests/cases/compiler/commentsExternalModules3.ts +++ b/tests/cases/compiler/commentsExternalModules3.ts @@ -1,7 +1,7 @@ -//@module: commonjs +// @module: commonjs // @target: ES5 // @declaration: true -// @comments: true +// @removeComments: false // @Filename: commentsExternalModules2_0.ts /** Module comment*/ diff --git a/tests/cases/compiler/commentsFormatting.ts b/tests/cases/compiler/commentsFormatting.ts index b413f0f92ea..c0f2d3093f9 100644 --- a/tests/cases/compiler/commentsFormatting.ts +++ b/tests/cases/compiler/commentsFormatting.ts @@ -1,6 +1,6 @@ // @target: ES5 // @declaration: true -// @comments: true +// @removeComments: false module m { /** this is first line - aligned to class declaration diff --git a/tests/cases/compiler/commentsFunction.ts b/tests/cases/compiler/commentsFunction.ts index b71da4ae085..1b379fd15c6 100644 --- a/tests/cases/compiler/commentsFunction.ts +++ b/tests/cases/compiler/commentsFunction.ts @@ -1,6 +1,6 @@ // @target: ES5 // @declaration: true -// @comments: true +// @removeComments: false /** This comment should appear for foo*/ function foo() { diff --git a/tests/cases/compiler/commentsInheritance.ts b/tests/cases/compiler/commentsInheritance.ts index aa4c54ee128..40924851766 100644 --- a/tests/cases/compiler/commentsInheritance.ts +++ b/tests/cases/compiler/commentsInheritance.ts @@ -1,6 +1,6 @@ // @target: ES5 // @declaration: true -// @comments: true +// @removeComments: false /** i1 is interface with properties*/ interface i1 { diff --git a/tests/cases/compiler/commentsInterface.ts b/tests/cases/compiler/commentsInterface.ts index b6455e9235d..2e35a95f207 100644 --- a/tests/cases/compiler/commentsInterface.ts +++ b/tests/cases/compiler/commentsInterface.ts @@ -1,6 +1,6 @@ // @target: ES5 // @declaration: true -// @comments: true +// @removeComments: false /** this is interface 1*/ interface i1 { } diff --git a/tests/cases/compiler/commentsModules.ts b/tests/cases/compiler/commentsModules.ts index 29ac0c22373..943ef640545 100644 --- a/tests/cases/compiler/commentsModules.ts +++ b/tests/cases/compiler/commentsModules.ts @@ -1,6 +1,6 @@ // @target: ES5 // @declaration: true -// @comments: true +// @removeComments: false /** Module comment*/ module m1 { /** b's comment*/ diff --git a/tests/cases/compiler/commentsMultiModuleMultiFile.ts b/tests/cases/compiler/commentsMultiModuleMultiFile.ts index 2d19f775bda..04066b975ab 100644 --- a/tests/cases/compiler/commentsMultiModuleMultiFile.ts +++ b/tests/cases/compiler/commentsMultiModuleMultiFile.ts @@ -1,7 +1,7 @@ -//@module: amd +// @module: amd // @target: ES5 // @declaration: true -// @comments: true +// @removeComments: false // @Filename: commentsMultiModuleMultiFile_0.ts /** this is multi declare module*/ diff --git a/tests/cases/compiler/commentsMultiModuleSingleFile.ts b/tests/cases/compiler/commentsMultiModuleSingleFile.ts index a9871d31dbe..651a3cb07ba 100644 --- a/tests/cases/compiler/commentsMultiModuleSingleFile.ts +++ b/tests/cases/compiler/commentsMultiModuleSingleFile.ts @@ -1,6 +1,6 @@ // @target: ES5 // @declaration: true -// @comments: true +// @removeComments: false /** this is multi declare module*/ module multiM { diff --git a/tests/cases/compiler/commentsOnObjectLiteral1.ts b/tests/cases/compiler/commentsOnObjectLiteral1.ts index 7bc92e8664e..79e5aa81205 100644 --- a/tests/cases/compiler/commentsOnObjectLiteral1.ts +++ b/tests/cases/compiler/commentsOnObjectLiteral1.ts @@ -1,4 +1,4 @@ -// @comments: true +// @removeComments: false var Person = makeClass( /** @scope Person diff --git a/tests/cases/compiler/commentsOnObjectLiteral2.ts b/tests/cases/compiler/commentsOnObjectLiteral2.ts index da2ee14b730..952df7ed969 100644 --- a/tests/cases/compiler/commentsOnObjectLiteral2.ts +++ b/tests/cases/compiler/commentsOnObjectLiteral2.ts @@ -1,4 +1,4 @@ -// @comments: true +// @removeComments: false var Person = makeClass( { /** diff --git a/tests/cases/compiler/commentsOnObjectLiteral3.ts b/tests/cases/compiler/commentsOnObjectLiteral3.ts index 6650b21e167..b983364bf1f 100644 --- a/tests/cases/compiler/commentsOnObjectLiteral3.ts +++ b/tests/cases/compiler/commentsOnObjectLiteral3.ts @@ -1,4 +1,4 @@ -// @comments: true +// @removeComments: false // @target: ES5 var v = { diff --git a/tests/cases/compiler/commentsOnObjectLiteral4.ts b/tests/cases/compiler/commentsOnObjectLiteral4.ts index e13668530c7..d685304f31e 100644 --- a/tests/cases/compiler/commentsOnObjectLiteral4.ts +++ b/tests/cases/compiler/commentsOnObjectLiteral4.ts @@ -1,4 +1,4 @@ -// @comments: true +// @removeComments: false // @target: ES5 var v = { diff --git a/tests/cases/compiler/commentsOnReturnStatement1.ts b/tests/cases/compiler/commentsOnReturnStatement1.ts index 966d66511b3..0f689fb4681 100644 --- a/tests/cases/compiler/commentsOnReturnStatement1.ts +++ b/tests/cases/compiler/commentsOnReturnStatement1.ts @@ -1,4 +1,4 @@ -// @comments: true +// @removeComments: false class DebugClass { public static debugFunc() { // Start Debugger Test Code diff --git a/tests/cases/compiler/commentsOnStaticMembers.ts b/tests/cases/compiler/commentsOnStaticMembers.ts index 7dc1a41c953..dd5169a972a 100644 --- a/tests/cases/compiler/commentsOnStaticMembers.ts +++ b/tests/cases/compiler/commentsOnStaticMembers.ts @@ -1,4 +1,4 @@ -// @comments: true +// @removeComments: false class test { /** diff --git a/tests/cases/compiler/commentsOverloads.ts b/tests/cases/compiler/commentsOverloads.ts index 85a1a9d8064..efb5d73df8f 100644 --- a/tests/cases/compiler/commentsOverloads.ts +++ b/tests/cases/compiler/commentsOverloads.ts @@ -1,6 +1,6 @@ // @target: ES5 // @declaration: true -// @comments: true +// @removeComments: false /** this is signature 1*/ function f1(/**param a*/a: number): number; function f1(b: string): number; diff --git a/tests/cases/compiler/commentsPropertySignature1.ts b/tests/cases/compiler/commentsPropertySignature1.ts index b92b9c6ded7..48ba5c3fda1 100644 --- a/tests/cases/compiler/commentsPropertySignature1.ts +++ b/tests/cases/compiler/commentsPropertySignature1.ts @@ -1,4 +1,4 @@ -// @comments: true +// @removeComments: false var a = { /** own x*/ x: 0 diff --git a/tests/cases/compiler/commentsTypeParameters.ts b/tests/cases/compiler/commentsTypeParameters.ts index 4fc3a30a192..c1e49280ed0 100644 --- a/tests/cases/compiler/commentsTypeParameters.ts +++ b/tests/cases/compiler/commentsTypeParameters.ts @@ -1,5 +1,5 @@ // @declaration: true -// @comments: true +// @removeComments: false class C { method(a: U) { } diff --git a/tests/cases/compiler/commentsVarDecl.ts b/tests/cases/compiler/commentsVarDecl.ts index 3b7d56e4078..cb244e94365 100644 --- a/tests/cases/compiler/commentsVarDecl.ts +++ b/tests/cases/compiler/commentsVarDecl.ts @@ -1,6 +1,6 @@ // @target: ES5 // @declaration: true -// @comments: true +// @removeComments: false /** Variable comments*/ var myVariable = 10; // This trailing Comment1 diff --git a/tests/cases/compiler/commentsVariableStatement1.ts b/tests/cases/compiler/commentsVariableStatement1.ts index 368115af17c..e9c9ca28a08 100644 --- a/tests/cases/compiler/commentsVariableStatement1.ts +++ b/tests/cases/compiler/commentsVariableStatement1.ts @@ -1,5 +1,5 @@ // @declaration: true -// @comments: true +// @removeComments: false /** Comment */ var v = 1; \ No newline at end of file diff --git a/tests/cases/compiler/commentsdoNotEmitComments.ts b/tests/cases/compiler/commentsdoNotEmitComments.ts index 6895f67b6b0..e2aaa269e1f 100644 --- a/tests/cases/compiler/commentsdoNotEmitComments.ts +++ b/tests/cases/compiler/commentsdoNotEmitComments.ts @@ -1,6 +1,6 @@ // @target: ES5 // @declaration: true -// @comments: false +// @removeComments: true /** Variable comments*/ var myVariable = 10; diff --git a/tests/cases/compiler/commentsemitComments.ts b/tests/cases/compiler/commentsemitComments.ts index fdedb787739..b20fbb9641a 100644 --- a/tests/cases/compiler/commentsemitComments.ts +++ b/tests/cases/compiler/commentsemitComments.ts @@ -1,6 +1,6 @@ // @target: ES5 // @declaration: true -// @comments: true +// @removeComments: false /** Variable comments*/ var myVariable = 10; diff --git a/tests/cases/compiler/constEnumToStringNoComments.ts b/tests/cases/compiler/constEnumToStringNoComments.ts index 802ee9068bb..f98ae8d509e 100644 --- a/tests/cases/compiler/constEnumToStringNoComments.ts +++ b/tests/cases/compiler/constEnumToStringNoComments.ts @@ -1,4 +1,4 @@ -// @comments: false +// @removeComments: true const enum Foo { X = 100, Y = 0.5, diff --git a/tests/cases/compiler/constEnumToStringWithComments.ts b/tests/cases/compiler/constEnumToStringWithComments.ts index e10c3591131..ce85d8b256f 100644 --- a/tests/cases/compiler/constEnumToStringWithComments.ts +++ b/tests/cases/compiler/constEnumToStringWithComments.ts @@ -1,4 +1,4 @@ -// @comments: true +// @removeComments: false const enum Foo { X = 100, Y = 0.5, diff --git a/tests/cases/compiler/declFileAccessors.ts b/tests/cases/compiler/declFileAccessors.ts index ea9b05f2fef..bc41722f77d 100644 --- a/tests/cases/compiler/declFileAccessors.ts +++ b/tests/cases/compiler/declFileAccessors.ts @@ -1,6 +1,6 @@ // @target: ES5 // @declaration: true -// @comments: true +// @removeComments: false // @module: commonjs // @Filename: declFileAccessors_0.ts diff --git a/tests/cases/compiler/declFileCallSignatures.ts b/tests/cases/compiler/declFileCallSignatures.ts index 9ff74730fbf..4225c580755 100644 --- a/tests/cases/compiler/declFileCallSignatures.ts +++ b/tests/cases/compiler/declFileCallSignatures.ts @@ -1,6 +1,6 @@ // @target: ES5 // @declaration: true -// @comments: true +// @removeComments: false // @module: commonjs // @Filename: declFileCallSignatures_0.ts diff --git a/tests/cases/compiler/declFileConstructSignatures.ts b/tests/cases/compiler/declFileConstructSignatures.ts index b81e4f831ea..717619e8b2f 100644 --- a/tests/cases/compiler/declFileConstructSignatures.ts +++ b/tests/cases/compiler/declFileConstructSignatures.ts @@ -1,6 +1,6 @@ // @target: ES5 // @declaration: true -// @comments: true +// @removeComments: false // @module: commonjs // @Filename: declFileConstructSignatures_0.ts diff --git a/tests/cases/compiler/declFileConstructors.ts b/tests/cases/compiler/declFileConstructors.ts index c1f4862e44c..8a6a8a6c473 100644 --- a/tests/cases/compiler/declFileConstructors.ts +++ b/tests/cases/compiler/declFileConstructors.ts @@ -1,6 +1,6 @@ // @target: ES5 // @declaration: true -// @comments: true +// @removeComments: false // @module: commonjs // @Filename: declFileConstructors_0.ts diff --git a/tests/cases/compiler/declFileFunctions.ts b/tests/cases/compiler/declFileFunctions.ts index 7b9c55e9214..4217fdf6e95 100644 --- a/tests/cases/compiler/declFileFunctions.ts +++ b/tests/cases/compiler/declFileFunctions.ts @@ -1,6 +1,6 @@ // @target: ES5 // @declaration: true -// @comments: true +// @removeComments: false // @module: commonjs // @Filename: declFileFunctions_0.ts diff --git a/tests/cases/compiler/declFileIndexSignatures.ts b/tests/cases/compiler/declFileIndexSignatures.ts index 3c9aaf34bfc..efc43f80e1f 100644 --- a/tests/cases/compiler/declFileIndexSignatures.ts +++ b/tests/cases/compiler/declFileIndexSignatures.ts @@ -1,6 +1,6 @@ // @target: ES5 // @declaration: true -// @comments: true +// @removeComments: false // @module: commonjs // @Filename: declFileIndexSignatures_0.ts diff --git a/tests/cases/compiler/declFileMethods.ts b/tests/cases/compiler/declFileMethods.ts index a5c31728ccd..50add66d97c 100644 --- a/tests/cases/compiler/declFileMethods.ts +++ b/tests/cases/compiler/declFileMethods.ts @@ -1,6 +1,6 @@ // @target: ES5 // @declaration: true -// @comments: true +// @removeComments: false // @module: commonjs // @Filename: declFileMethods_0.ts diff --git a/tests/cases/compiler/emitCommentsOnlyFile.ts b/tests/cases/compiler/emitCommentsOnlyFile.ts index 9ded82be8e9..bcdf34c57b8 100644 --- a/tests/cases/compiler/emitCommentsOnlyFile.ts +++ b/tests/cases/compiler/emitCommentsOnlyFile.ts @@ -1,4 +1,4 @@ -// @comments: true +// @removeComments: false /** * @name Foo diff --git a/tests/cases/compiler/emitPostComments.ts b/tests/cases/compiler/emitPostComments.ts index b76f8dcb2bb..767bf033295 100644 --- a/tests/cases/compiler/emitPostComments.ts +++ b/tests/cases/compiler/emitPostComments.ts @@ -1,4 +1,4 @@ -// @comments: true +// @removeComments: false var y = 10; /** diff --git a/tests/cases/compiler/emitPreComments.ts b/tests/cases/compiler/emitPreComments.ts index e43c4baaa3b..2d98231e000 100644 --- a/tests/cases/compiler/emitPreComments.ts +++ b/tests/cases/compiler/emitPreComments.ts @@ -1,4 +1,4 @@ -// @comments: true +// @removeComments: false // This is pre comment var y = 10; diff --git a/tests/cases/compiler/errorWithTruncatedType.ts b/tests/cases/compiler/errorWithTruncatedType.ts index 307ff642ed9..c615ff928e4 100644 --- a/tests/cases/compiler/errorWithTruncatedType.ts +++ b/tests/cases/compiler/errorWithTruncatedType.ts @@ -1,4 +1,4 @@ -// @errortruncation: true +// @noErrorTruncation: false var x: { propertyWithAnExceedinglyLongName1: string; diff --git a/tests/cases/compiler/externalModuleWithoutCompilerFlag1.ts b/tests/cases/compiler/externalModuleWithoutCompilerFlag1.ts index 4283e3d32a9..875e3205407 100644 --- a/tests/cases/compiler/externalModuleWithoutCompilerFlag1.ts +++ b/tests/cases/compiler/externalModuleWithoutCompilerFlag1.ts @@ -1,4 +1,3 @@ -// @module: unspecified // Not on line 0 because we want to verify the error is placed in the appropriate location. export module M { diff --git a/tests/cases/compiler/lambdaASIEmit.ts b/tests/cases/compiler/lambdaASIEmit.ts index 44ee992ff47..c803b87411d 100644 --- a/tests/cases/compiler/lambdaASIEmit.ts +++ b/tests/cases/compiler/lambdaASIEmit.ts @@ -1,4 +1,4 @@ -// @comments: true +// @removeComments: false function Foo(x: any) { diff --git a/tests/cases/compiler/out-flag.ts b/tests/cases/compiler/out-flag.ts index 45a8d92805c..07cd55224a5 100644 --- a/tests/cases/compiler/out-flag.ts +++ b/tests/cases/compiler/out-flag.ts @@ -3,7 +3,7 @@ // @declaration: true // @module: commonjs //// @out: bin\ -// @comments: true +// @removeComments: false // my class comments class MyClass diff --git a/tests/cases/compiler/pinnedComments1.ts b/tests/cases/compiler/pinnedComments1.ts index 474769e9b20..613efc3aef5 100644 --- a/tests/cases/compiler/pinnedComments1.ts +++ b/tests/cases/compiler/pinnedComments1.ts @@ -1,4 +1,4 @@ -// @comments: false +// @removeComments: true /* unpinned comment */ /*! pinned comment */ diff --git a/tests/cases/compiler/sourceMap-FileWithComments.ts b/tests/cases/compiler/sourceMap-FileWithComments.ts index a3e5930d7c1..5dcf602c3de 100644 --- a/tests/cases/compiler/sourceMap-FileWithComments.ts +++ b/tests/cases/compiler/sourceMap-FileWithComments.ts @@ -1,5 +1,5 @@ // @sourcemap: true -// @comments: true +// @removeComments: false // Interface interface IPoint { From e36285c82c3a8458508a78df9fc4d0279a1df6d3 Mon Sep 17 00:00:00 2001 From: Yui T Date: Tue, 25 Aug 2015 13:47:02 -0700 Subject: [PATCH 029/117] Optimize removing comment when removeComment flag is true --- src/compiler/emitter.ts | 83 ++++++++++++++++++++--------------------- 1 file changed, 41 insertions(+), 42 deletions(-) diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index d07373613ac..9a5e0b9f700 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -6922,37 +6922,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi return leadingComments; } - /** - * Filter comment when removeComments is true according to following rules: - * - Pinned Comments - remove all but the top of the file one - * - Normal Comments - remove all - * - // Comments - remove all - * @param isTopOfFileComments boolean indicating whether comments are at the top of file - * @param isEmittedNode boolean indicating whether node associated with the comments will be - * emitted in javascript file - */ - function filterComments(ranges: CommentRange[], isTopOfFileComments: boolean, isEmittedNode=true): CommentRange[] { - if (compilerOptions.removeComments) { - // Only preserve pinned comments at the top of the file - ranges = isTopOfFileComments ? filter(ranges, isPinnedComments) : []; - } - else { - if (!isEmittedNode) { - // If the node will not be emitted in JS, remove all the comments(normal, pinned and ///) associated with the node, - // unless it is a triple slash comment at the top of the file. - // For Example: - // /// - // declare var x; - // /// - // interface F {} - // The first /// will NOT be removed while the second one will be removed eventhough both node will not be emitted - ranges = isTopOfFileComments ? filter(ranges, isTripleSlashOrPinnedComments) : filter(ranges, isPinnedComments); - } - } - - return ranges; - } - function isPinnedComments(comment: CommentRange) { if (currentSourceFile.text.charCodeAt(comment.pos + 1) === CharacterCodes.asterisk) { return currentSourceFile.text.charCodeAt(comment.pos + 2) === CharacterCodes.exclamation; @@ -6960,11 +6929,11 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi } /** - * Determine if the given comment is a triple-slash or pinned comment + * Determine if the given comment is a triple-slash * - * @return true if the comment is a triple-slash comment or a pinned comment else false + * @return true if the comment is a triple-slash comment else false **/ - function isTripleSlashOrPinnedComments(comment: CommentRange) { + function isTripleSlashComments(comment: CommentRange) { // Verify this is /// comment, but do the regexp match only when we first can find /// in the comment text // so that we don't end up computing comment string and doing match for all // comments if (currentSourceFile.text.charCodeAt(comment.pos + 1) === CharacterCodes.slash && @@ -6975,7 +6944,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi textSubStr.match(fullTripleSlashAMDReferencePathRegEx) ? true : false; } - return isPinnedComments(comment); + return false; } function getLeadingCommentsToEmit(node: Node) { @@ -7015,9 +6984,23 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi } function emitLeadingCommentsWorker(node: Node, isEmittedNode: boolean) { - // If the caller only wants pinned or triple slash comments, then always filter - // down to that set. Otherwise, filter based on the current compiler options. - let leadingComments = filterComments(getLeadingCommentsToEmit(node), /*isTopOfFileComments:*/ node.pos === 0, isEmittedNode); + if (compilerOptions.removeComments) return; + let leadingComments: CommentRange[]; + + if (isEmittedNode) { + leadingComments = getLeadingCommentsToEmit(node); + } + else { + // If the node will not be emitted in JS, remove all the comments(normal, pinned and ///) associated with the node, + // unless it is a triple slash comment at the top of the file. + // For Example: + // /// + // declare var x; + // /// + // interface F {} + // The first /// will NOT be removed while the second one will be removed eventhough both node will not be emitted + leadingComments = node.pos === 0 ? filter(getLeadingCommentsToEmit(node), isTripleSlashComments) : []; + } emitNewLineBeforeLeadingComments(currentSourceFile, writer, node, leadingComments); @@ -7026,8 +7009,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi } function emitTrailingComments(node: Node) { + if (compilerOptions.removeComments) return; // Emit the trailing comments only if the parent's end doesn't match - let trailingComments = filterComments(getTrailingCommentsToEmit(node), /*isTopOfFileComments:*/ node.pos === 0); + let trailingComments = getTrailingCommentsToEmit(node); // trailing comments are emitted at space/*trailing comment1 */space/*trailing comment*/ emitComments(currentSourceFile, writer, trailingComments, /*trailingSeparator*/ false, newLine, writeComment); @@ -7039,13 +7023,15 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi * ^ => pos; the function will emit "comment1" in the emitJS */ function emitTrailingCommentsOfPosition(pos: number) { - let trailingComments = filterComments(getTrailingCommentRanges(currentSourceFile.text, pos), /*isTopOfFileComments*/ pos === 0); + if (compilerOptions.removeComments) return; + let trailingComments = getTrailingCommentRanges(currentSourceFile.text, pos); // trailing comments are emitted at space/*trailing comment1 */space/*trailing comment*/ emitComments(currentSourceFile, writer, trailingComments, /*trailingSeparator*/ true, newLine, writeComment); } function emitLeadingCommentsOfPosition(pos: number) { + if (compilerOptions.removeComments) return; let leadingComments: CommentRange[]; if (hasDetachedComments(pos)) { // get comments without detached comments @@ -7056,7 +7042,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi leadingComments = getLeadingCommentRanges(currentSourceFile.text, pos); } - leadingComments = filterComments(leadingComments, /*isTopOfFileComments*/ pos === 0); emitNewLineBeforeLeadingComments(currentSourceFile, writer, { pos: pos, end: pos }, leadingComments); // Leading comments are emitted at /*leading comment1 */space/*leading comment*/space @@ -7064,7 +7049,21 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi } function emitDetachedComments(node: TextRange) { - let leadingComments = filterComments(getLeadingCommentRanges(currentSourceFile.text, node.pos), node.pos === 0); + let leadingComments: CommentRange[]; + if (compilerOptions.removeComments) { + // removeComments is true, only reserve pinned comment at the top of file + // For example: + // /*! Pinned Comment */ + // + // var x = 10; + leadingComments = node.pos === 0 ? + filter(getLeadingCommentRanges(currentSourceFile.text, node.pos), isPinnedComments) : []; + } + else { + // removeComments is false, just get detached as normal and bypass the process to filter comment + leadingComments = getLeadingCommentRanges(currentSourceFile.text, node.pos); + } + if (leadingComments) { let detachedComments: CommentRange[] = []; let lastComment: CommentRange; From 40cbd33e65b8f97d96892d99b0287e5b3506e232 Mon Sep 17 00:00:00 2001 From: Yui T Date: Tue, 25 Aug 2015 13:47:45 -0700 Subject: [PATCH 030/117] Update testcase only preserve pinned comment at the top of the file --- .../reference/commentOnAmbientClass1.js | 12 +++++- .../reference/commentOnAmbientClass1.symbols | 9 ++++- .../reference/commentOnAmbientClass1.types | 7 +++- .../reference/commentOnAmbientEnum.js | 12 +++++- .../reference/commentOnAmbientEnum.symbols | 15 ++++--- .../reference/commentOnAmbientEnum.types | 7 +++- .../reference/commentOnAmbientModule.js | 12 +++++- .../reference/commentOnAmbientModule.symbols | 19 +++++---- .../reference/commentOnAmbientModule.types | 7 +++- .../reference/commentOnAmbientVariable1.js | 12 +++++- .../commentOnAmbientVariable1.symbols | 11 ++++-- .../reference/commentOnAmbientVariable1.types | 7 +++- .../reference/commentOnAmbientfunction.js | 12 +++++- .../commentOnAmbientfunction.symbols | 11 ++++-- .../reference/commentOnAmbientfunction.types | 7 +++- .../reference/commentOnElidedModule1.js | 12 +++++- .../reference/commentOnElidedModule1.symbols | 9 ++++- .../reference/commentOnElidedModule1.types | 7 +++- .../reference/commentOnInterface1.js | 12 +++++- .../reference/commentOnInterface1.symbols | 9 ++++- .../reference/commentOnInterface1.types | 7 +++- .../reference/commentOnSignature1.js | 14 +++++-- .../reference/commentOnSignature1.symbols | 39 +++++++++++-------- .../reference/commentOnSignature1.types | 7 +++- tests/baselines/reference/pinnedComments1.js | 11 +++++- .../reference/pinnedComments1.symbols | 6 ++- .../baselines/reference/pinnedComments1.types | 6 ++- .../cases/compiler/commentOnAmbientClass1.ts | 7 +++- tests/cases/compiler/commentOnAmbientEnum.ts | 7 +++- .../cases/compiler/commentOnAmbientModule.ts | 7 +++- .../compiler/commentOnAmbientVariable1.ts | 7 +++- .../compiler/commentOnAmbientfunction.ts | 7 +++- .../cases/compiler/commentOnElidedModule1.ts | 7 +++- tests/cases/compiler/commentOnInterface1.ts | 7 +++- tests/cases/compiler/commentOnSignature1.ts | 7 +++- tests/cases/compiler/pinnedComments1.ts | 6 ++- 36 files changed, 281 insertions(+), 80 deletions(-) diff --git a/tests/baselines/reference/commentOnAmbientClass1.js b/tests/baselines/reference/commentOnAmbientClass1.js index beacc71335c..9837da4c371 100644 --- a/tests/baselines/reference/commentOnAmbientClass1.js +++ b/tests/baselines/reference/commentOnAmbientClass1.js @@ -1,7 +1,12 @@ //// [tests/cases/compiler/commentOnAmbientClass1.ts] //// //// [a.ts] -/*! Keep this pinned comment */ +/*!========= + Keep this pinned comment + ========= +*/ + +/*! Don't keep this pinned comment */ declare class C { } @@ -15,6 +20,9 @@ declare class E extends C { } //// [a.js] -/*! Keep this pinned comment */ +/*!========= + Keep this pinned comment + ========= +*/ //// [b.js] /// diff --git a/tests/baselines/reference/commentOnAmbientClass1.symbols b/tests/baselines/reference/commentOnAmbientClass1.symbols index 899c5f19a24..a08bb744df4 100644 --- a/tests/baselines/reference/commentOnAmbientClass1.symbols +++ b/tests/baselines/reference/commentOnAmbientClass1.symbols @@ -5,13 +5,18 @@ declare class E extends C { >C : Symbol(C, Decl(a.ts, 0, 0)) } === tests/cases/compiler/a.ts === -/*! Keep this pinned comment */ +/*!========= + Keep this pinned comment + ========= +*/ + +/*! Don't keep this pinned comment */ declare class C { >C : Symbol(C, Decl(a.ts, 0, 0)) } // Don't keep this comment. declare class D { ->D : Symbol(D, Decl(a.ts, 2, 1)) +>D : Symbol(D, Decl(a.ts, 7, 1)) } diff --git a/tests/baselines/reference/commentOnAmbientClass1.types b/tests/baselines/reference/commentOnAmbientClass1.types index 44c0334ef6c..b0212056505 100644 --- a/tests/baselines/reference/commentOnAmbientClass1.types +++ b/tests/baselines/reference/commentOnAmbientClass1.types @@ -5,7 +5,12 @@ declare class E extends C { >C : C } === tests/cases/compiler/a.ts === -/*! Keep this pinned comment */ +/*!========= + Keep this pinned comment + ========= +*/ + +/*! Don't keep this pinned comment */ declare class C { >C : C } diff --git a/tests/baselines/reference/commentOnAmbientEnum.js b/tests/baselines/reference/commentOnAmbientEnum.js index d602c68a0e5..f6c9d92ebff 100644 --- a/tests/baselines/reference/commentOnAmbientEnum.js +++ b/tests/baselines/reference/commentOnAmbientEnum.js @@ -1,7 +1,12 @@ //// [tests/cases/compiler/commentOnAmbientEnum.ts] //// //// [a.ts] -/*! Keep this pinned comment */ +/*!========= + Keep this pinned comment + ========= +*/ + +/*! Don't keep this pinned comment */ declare enum C { a, b, @@ -18,6 +23,9 @@ declare enum E { } //// [a.js] -/*! Keep this pinned comment */ +/*!========= + Keep this pinned comment + ========= +*/ //// [b.js] /// diff --git a/tests/baselines/reference/commentOnAmbientEnum.symbols b/tests/baselines/reference/commentOnAmbientEnum.symbols index d86d490113d..3a6e8089d4b 100644 --- a/tests/baselines/reference/commentOnAmbientEnum.symbols +++ b/tests/baselines/reference/commentOnAmbientEnum.symbols @@ -4,22 +4,27 @@ declare enum E { >E : Symbol(E, Decl(b.ts, 0, 0)) } === tests/cases/compiler/a.ts === -/*! Keep this pinned comment */ +/*!========= + Keep this pinned comment + ========= +*/ + +/*! Don't keep this pinned comment */ declare enum C { >C : Symbol(C, Decl(a.ts, 0, 0)) a, ->a : Symbol(C.a, Decl(a.ts, 1, 16)) +>a : Symbol(C.a, Decl(a.ts, 6, 16)) b, ->b : Symbol(C.b, Decl(a.ts, 2, 6)) +>b : Symbol(C.b, Decl(a.ts, 7, 6)) c ->c : Symbol(C.c, Decl(a.ts, 3, 6)) +>c : Symbol(C.c, Decl(a.ts, 8, 6)) } // Don't keep this comment. declare enum D { ->D : Symbol(D, Decl(a.ts, 5, 1)) +>D : Symbol(D, Decl(a.ts, 10, 1)) } diff --git a/tests/baselines/reference/commentOnAmbientEnum.types b/tests/baselines/reference/commentOnAmbientEnum.types index 4a0193b7937..95f3d61b75f 100644 --- a/tests/baselines/reference/commentOnAmbientEnum.types +++ b/tests/baselines/reference/commentOnAmbientEnum.types @@ -4,7 +4,12 @@ declare enum E { >E : E } === tests/cases/compiler/a.ts === -/*! Keep this pinned comment */ +/*!========= + Keep this pinned comment + ========= +*/ + +/*! Don't keep this pinned comment */ declare enum C { >C : C diff --git a/tests/baselines/reference/commentOnAmbientModule.js b/tests/baselines/reference/commentOnAmbientModule.js index d5a536302b5..2d43b502f29 100644 --- a/tests/baselines/reference/commentOnAmbientModule.js +++ b/tests/baselines/reference/commentOnAmbientModule.js @@ -1,7 +1,12 @@ //// [tests/cases/compiler/commentOnAmbientModule.ts] //// //// [a.ts] -/*! Keep this pinned comment */ +/*!========= + Keep this pinned comment + ========= +*/ + +/*! Don't keep this pinned comment */ declare module C { function foo(); } @@ -20,6 +25,9 @@ declare module E { } //// [a.js] -/*! Keep this pinned comment */ +/*!========= + Keep this pinned comment + ========= +*/ //// [b.js] /// diff --git a/tests/baselines/reference/commentOnAmbientModule.symbols b/tests/baselines/reference/commentOnAmbientModule.symbols index c1412c17880..e7525e6306f 100644 --- a/tests/baselines/reference/commentOnAmbientModule.symbols +++ b/tests/baselines/reference/commentOnAmbientModule.symbols @@ -5,28 +5,33 @@ declare module E { class foobar extends D.bar { >foobar : Symbol(foobar, Decl(b.ts, 1, 18)) ->D.bar : Symbol(D.bar, Decl(a.ts, 6, 18)) ->D : Symbol(D, Decl(a.ts, 3, 1)) ->bar : Symbol(D.bar, Decl(a.ts, 6, 18)) +>D.bar : Symbol(D.bar, Decl(a.ts, 11, 18)) +>D : Symbol(D, Decl(a.ts, 8, 1)) +>bar : Symbol(D.bar, Decl(a.ts, 11, 18)) foo(); >foo : Symbol(foo, Decl(b.ts, 2, 32)) } } === tests/cases/compiler/a.ts === -/*! Keep this pinned comment */ +/*!========= + Keep this pinned comment + ========= +*/ + +/*! Don't keep this pinned comment */ declare module C { >C : Symbol(C, Decl(a.ts, 0, 0)) function foo(); ->foo : Symbol(foo, Decl(a.ts, 1, 18)) +>foo : Symbol(foo, Decl(a.ts, 6, 18)) } // Don't keep this comment. declare module D { ->D : Symbol(D, Decl(a.ts, 3, 1)) +>D : Symbol(D, Decl(a.ts, 8, 1)) class bar { } ->bar : Symbol(bar, Decl(a.ts, 6, 18)) +>bar : Symbol(bar, Decl(a.ts, 11, 18)) } diff --git a/tests/baselines/reference/commentOnAmbientModule.types b/tests/baselines/reference/commentOnAmbientModule.types index 629395a4e80..f54d248b461 100644 --- a/tests/baselines/reference/commentOnAmbientModule.types +++ b/tests/baselines/reference/commentOnAmbientModule.types @@ -14,7 +14,12 @@ declare module E { } } === tests/cases/compiler/a.ts === -/*! Keep this pinned comment */ +/*!========= + Keep this pinned comment + ========= +*/ + +/*! Don't keep this pinned comment */ declare module C { >C : typeof C diff --git a/tests/baselines/reference/commentOnAmbientVariable1.js b/tests/baselines/reference/commentOnAmbientVariable1.js index b76fd3345b5..79c5dc85f23 100644 --- a/tests/baselines/reference/commentOnAmbientVariable1.js +++ b/tests/baselines/reference/commentOnAmbientVariable1.js @@ -1,9 +1,17 @@ //// [commentOnAmbientVariable1.ts] -/*! Keep this pinned comment */ +/*!========= + Keep this pinned comment + ========= +*/ + +/*! Don't keep this pinned comment */ declare var v: number; // Don't keep this comment. declare var y: number; //// [commentOnAmbientVariable1.js] -/*! Keep this pinned comment */ +/*!========= + Keep this pinned comment + ========= +*/ diff --git a/tests/baselines/reference/commentOnAmbientVariable1.symbols b/tests/baselines/reference/commentOnAmbientVariable1.symbols index 153653e7827..7847b4b85ad 100644 --- a/tests/baselines/reference/commentOnAmbientVariable1.symbols +++ b/tests/baselines/reference/commentOnAmbientVariable1.symbols @@ -1,9 +1,14 @@ === tests/cases/compiler/commentOnAmbientVariable1.ts === -/*! Keep this pinned comment */ +/*!========= + Keep this pinned comment + ========= +*/ + +/*! Don't keep this pinned comment */ declare var v: number; ->v : Symbol(v, Decl(commentOnAmbientVariable1.ts, 1, 11)) +>v : Symbol(v, Decl(commentOnAmbientVariable1.ts, 6, 11)) // Don't keep this comment. declare var y: number; ->y : Symbol(y, Decl(commentOnAmbientVariable1.ts, 4, 11)) +>y : Symbol(y, Decl(commentOnAmbientVariable1.ts, 9, 11)) diff --git a/tests/baselines/reference/commentOnAmbientVariable1.types b/tests/baselines/reference/commentOnAmbientVariable1.types index feff50f4293..645e1f099d4 100644 --- a/tests/baselines/reference/commentOnAmbientVariable1.types +++ b/tests/baselines/reference/commentOnAmbientVariable1.types @@ -1,5 +1,10 @@ === tests/cases/compiler/commentOnAmbientVariable1.ts === -/*! Keep this pinned comment */ +/*!========= + Keep this pinned comment + ========= +*/ + +/*! Don't keep this pinned comment */ declare var v: number; >v : number diff --git a/tests/baselines/reference/commentOnAmbientfunction.js b/tests/baselines/reference/commentOnAmbientfunction.js index 6290d407727..22613236941 100644 --- a/tests/baselines/reference/commentOnAmbientfunction.js +++ b/tests/baselines/reference/commentOnAmbientfunction.js @@ -1,7 +1,12 @@ //// [tests/cases/compiler/commentOnAmbientfunction.ts] //// //// [a.ts] -/*! Keep this pinned comment */ +/*!========= + Keep this pinned comment + ========= +*/ + +/*! Don't keep this pinned comment */ declare function foo(); // Don't keep this comment. @@ -12,6 +17,9 @@ declare function bar(); declare function foobar(a: typeof foo): typeof bar; //// [a.js] -/*! Keep this pinned comment */ +/*!========= + Keep this pinned comment + ========= +*/ //// [b.js] /// diff --git a/tests/baselines/reference/commentOnAmbientfunction.symbols b/tests/baselines/reference/commentOnAmbientfunction.symbols index c6afb72eb9c..4d83d2794a0 100644 --- a/tests/baselines/reference/commentOnAmbientfunction.symbols +++ b/tests/baselines/reference/commentOnAmbientfunction.symbols @@ -4,14 +4,19 @@ declare function foobar(a: typeof foo): typeof bar; >foobar : Symbol(foobar, Decl(b.ts, 0, 0)) >a : Symbol(a, Decl(b.ts, 1, 24)) >foo : Symbol(foo, Decl(a.ts, 0, 0)) ->bar : Symbol(bar, Decl(a.ts, 1, 23)) +>bar : Symbol(bar, Decl(a.ts, 6, 23)) === tests/cases/compiler/a.ts === -/*! Keep this pinned comment */ +/*!========= + Keep this pinned comment + ========= +*/ + +/*! Don't keep this pinned comment */ declare function foo(); >foo : Symbol(foo, Decl(a.ts, 0, 0)) // Don't keep this comment. declare function bar(); ->bar : Symbol(bar, Decl(a.ts, 1, 23)) +>bar : Symbol(bar, Decl(a.ts, 6, 23)) diff --git a/tests/baselines/reference/commentOnAmbientfunction.types b/tests/baselines/reference/commentOnAmbientfunction.types index f75f7b377fb..3347a55bf68 100644 --- a/tests/baselines/reference/commentOnAmbientfunction.types +++ b/tests/baselines/reference/commentOnAmbientfunction.types @@ -7,7 +7,12 @@ declare function foobar(a: typeof foo): typeof bar; >bar : () => any === tests/cases/compiler/a.ts === -/*! Keep this pinned comment */ +/*!========= + Keep this pinned comment + ========= +*/ + +/*! Don't keep this pinned comment */ declare function foo(); >foo : () => any diff --git a/tests/baselines/reference/commentOnElidedModule1.js b/tests/baselines/reference/commentOnElidedModule1.js index 8a7b8d91b4c..72585e6a9e8 100644 --- a/tests/baselines/reference/commentOnElidedModule1.js +++ b/tests/baselines/reference/commentOnElidedModule1.js @@ -1,7 +1,12 @@ //// [tests/cases/compiler/commentOnElidedModule1.ts] //// //// [a.ts] -/*! Keep this pinned comment */ +/*!================= + Keep this pinned + ================= +*/ + +/*! Don't keep this pinned comment */ module ElidedModule { } @@ -15,6 +20,9 @@ module ElidedModule3 { } //// [a.js] -/*! Keep this pinned comment */ +/*!================= + Keep this pinned + ================= +*/ //// [b.js] /// diff --git a/tests/baselines/reference/commentOnElidedModule1.symbols b/tests/baselines/reference/commentOnElidedModule1.symbols index 63ce4dadf97..57b55adeee4 100644 --- a/tests/baselines/reference/commentOnElidedModule1.symbols +++ b/tests/baselines/reference/commentOnElidedModule1.symbols @@ -4,13 +4,18 @@ module ElidedModule3 { >ElidedModule3 : Symbol(ElidedModule3, Decl(b.ts, 0, 0)) } === tests/cases/compiler/a.ts === -/*! Keep this pinned comment */ +/*!================= + Keep this pinned + ================= +*/ + +/*! Don't keep this pinned comment */ module ElidedModule { >ElidedModule : Symbol(ElidedModule, Decl(a.ts, 0, 0)) } // Don't keep this comment. module ElidedModule2 { ->ElidedModule2 : Symbol(ElidedModule2, Decl(a.ts, 2, 1)) +>ElidedModule2 : Symbol(ElidedModule2, Decl(a.ts, 7, 1)) } diff --git a/tests/baselines/reference/commentOnElidedModule1.types b/tests/baselines/reference/commentOnElidedModule1.types index 8e095b8102f..d028b62519a 100644 --- a/tests/baselines/reference/commentOnElidedModule1.types +++ b/tests/baselines/reference/commentOnElidedModule1.types @@ -4,7 +4,12 @@ module ElidedModule3 { >ElidedModule3 : any } === tests/cases/compiler/a.ts === -/*! Keep this pinned comment */ +/*!================= + Keep this pinned + ================= +*/ + +/*! Don't keep this pinned comment */ module ElidedModule { >ElidedModule : any } diff --git a/tests/baselines/reference/commentOnInterface1.js b/tests/baselines/reference/commentOnInterface1.js index bde6202f03f..c51658e2dfa 100644 --- a/tests/baselines/reference/commentOnInterface1.js +++ b/tests/baselines/reference/commentOnInterface1.js @@ -1,7 +1,12 @@ //// [tests/cases/compiler/commentOnInterface1.ts] //// //// [a.ts] -/*! Keep this pinned comment */ +/*!================= + Keep this pinned + ================= +*/ + +/*! Don't keep this pinned comment */ interface I { } @@ -15,6 +20,9 @@ interface I3 { } //// [a.js] -/*! Keep this pinned comment */ +/*!================= + Keep this pinned + ================= +*/ //// [b.js] /// diff --git a/tests/baselines/reference/commentOnInterface1.symbols b/tests/baselines/reference/commentOnInterface1.symbols index 9564d9b4cfa..8ed7e020712 100644 --- a/tests/baselines/reference/commentOnInterface1.symbols +++ b/tests/baselines/reference/commentOnInterface1.symbols @@ -4,13 +4,18 @@ interface I3 { >I3 : Symbol(I3, Decl(b.ts, 0, 0)) } === tests/cases/compiler/a.ts === -/*! Keep this pinned comment */ +/*!================= + Keep this pinned + ================= +*/ + +/*! Don't keep this pinned comment */ interface I { >I : Symbol(I, Decl(a.ts, 0, 0)) } // Don't keep this comment. interface I2 { ->I2 : Symbol(I2, Decl(a.ts, 2, 1)) +>I2 : Symbol(I2, Decl(a.ts, 7, 1)) } diff --git a/tests/baselines/reference/commentOnInterface1.types b/tests/baselines/reference/commentOnInterface1.types index d03b1939026..34b0e0ce14f 100644 --- a/tests/baselines/reference/commentOnInterface1.types +++ b/tests/baselines/reference/commentOnInterface1.types @@ -4,7 +4,12 @@ interface I3 { >I3 : I3 } === tests/cases/compiler/a.ts === -/*! Keep this pinned comment */ +/*!================= + Keep this pinned + ================= +*/ + +/*! Don't keep this pinned comment */ interface I { >I : I } diff --git a/tests/baselines/reference/commentOnSignature1.js b/tests/baselines/reference/commentOnSignature1.js index 1b2327f9861..d29710c631c 100644 --- a/tests/baselines/reference/commentOnSignature1.js +++ b/tests/baselines/reference/commentOnSignature1.js @@ -1,7 +1,12 @@ //// [tests/cases/compiler/commentOnSignature1.ts] //// //// [a.ts] -/*! Keep this pinned comment */ +/*!================= + Keep this pinned + ================= +*/ + +/*! Don't keep this pinned comment */ function foo(n: number): void; // Don't keep this comment. function foo(s: string): void; @@ -33,14 +38,15 @@ function foo2(a: any): void { } //// [a.js] -/*! Keep this pinned comment */ +/*!================= + Keep this pinned + ================= +*/ function foo(a) { } var c = (function () { - /*! keep this pinned comment */ function c(a) { } - /*! keep this pinned comment */ c.prototype.foo = function (a) { }; return c; diff --git a/tests/baselines/reference/commentOnSignature1.symbols b/tests/baselines/reference/commentOnSignature1.symbols index 0d39565fb61..7f0d48401cd 100644 --- a/tests/baselines/reference/commentOnSignature1.symbols +++ b/tests/baselines/reference/commentOnSignature1.symbols @@ -14,49 +14,54 @@ function foo2(a: any): void { >a : Symbol(a, Decl(b.ts, 4, 14)) } === tests/cases/compiler/a.ts === -/*! Keep this pinned comment */ +/*!================= + Keep this pinned + ================= +*/ + +/*! Don't keep this pinned comment */ function foo(n: number): void; ->foo : Symbol(foo, Decl(a.ts, 0, 0), Decl(a.ts, 1, 30), Decl(a.ts, 3, 30)) ->n : Symbol(n, Decl(a.ts, 1, 13)) +>foo : Symbol(foo, Decl(a.ts, 0, 0), Decl(a.ts, 6, 30), Decl(a.ts, 8, 30)) +>n : Symbol(n, Decl(a.ts, 6, 13)) // Don't keep this comment. function foo(s: string): void; ->foo : Symbol(foo, Decl(a.ts, 0, 0), Decl(a.ts, 1, 30), Decl(a.ts, 3, 30)) ->s : Symbol(s, Decl(a.ts, 3, 13)) +>foo : Symbol(foo, Decl(a.ts, 0, 0), Decl(a.ts, 6, 30), Decl(a.ts, 8, 30)) +>s : Symbol(s, Decl(a.ts, 8, 13)) function foo(a: any): void { ->foo : Symbol(foo, Decl(a.ts, 0, 0), Decl(a.ts, 1, 30), Decl(a.ts, 3, 30)) ->a : Symbol(a, Decl(a.ts, 4, 13)) +>foo : Symbol(foo, Decl(a.ts, 0, 0), Decl(a.ts, 6, 30), Decl(a.ts, 8, 30)) +>a : Symbol(a, Decl(a.ts, 9, 13)) } class c { ->c : Symbol(c, Decl(a.ts, 5, 1)) +>c : Symbol(c, Decl(a.ts, 10, 1)) // dont keep this comment constructor(a: string); ->a : Symbol(a, Decl(a.ts, 9, 16)) +>a : Symbol(a, Decl(a.ts, 14, 16)) /*! keep this pinned comment */ constructor(a: number); ->a : Symbol(a, Decl(a.ts, 11, 16)) +>a : Symbol(a, Decl(a.ts, 16, 16)) constructor(a: any) { ->a : Symbol(a, Decl(a.ts, 12, 16)) +>a : Symbol(a, Decl(a.ts, 17, 16)) } // dont keep this comment foo(a: string); ->foo : Symbol(foo, Decl(a.ts, 13, 5), Decl(a.ts, 16, 19), Decl(a.ts, 18, 19)) ->a : Symbol(a, Decl(a.ts, 16, 8)) +>foo : Symbol(foo, Decl(a.ts, 18, 5), Decl(a.ts, 21, 19), Decl(a.ts, 23, 19)) +>a : Symbol(a, Decl(a.ts, 21, 8)) /*! keep this pinned comment */ foo(a: number); ->foo : Symbol(foo, Decl(a.ts, 13, 5), Decl(a.ts, 16, 19), Decl(a.ts, 18, 19)) ->a : Symbol(a, Decl(a.ts, 18, 8)) +>foo : Symbol(foo, Decl(a.ts, 18, 5), Decl(a.ts, 21, 19), Decl(a.ts, 23, 19)) +>a : Symbol(a, Decl(a.ts, 23, 8)) foo(a: any) { ->foo : Symbol(foo, Decl(a.ts, 13, 5), Decl(a.ts, 16, 19), Decl(a.ts, 18, 19)) ->a : Symbol(a, Decl(a.ts, 19, 8)) +>foo : Symbol(foo, Decl(a.ts, 18, 5), Decl(a.ts, 21, 19), Decl(a.ts, 23, 19)) +>a : Symbol(a, Decl(a.ts, 24, 8)) } } diff --git a/tests/baselines/reference/commentOnSignature1.types b/tests/baselines/reference/commentOnSignature1.types index 790aaaf7523..30898e22851 100644 --- a/tests/baselines/reference/commentOnSignature1.types +++ b/tests/baselines/reference/commentOnSignature1.types @@ -14,7 +14,12 @@ function foo2(a: any): void { >a : any } === tests/cases/compiler/a.ts === -/*! Keep this pinned comment */ +/*!================= + Keep this pinned + ================= +*/ + +/*! Don't keep this pinned comment */ function foo(n: number): void; >foo : { (n: number): void; (s: string): void; } >n : number diff --git a/tests/baselines/reference/pinnedComments1.js b/tests/baselines/reference/pinnedComments1.js index c4b8b41fbd7..9ab2a147e6a 100644 --- a/tests/baselines/reference/pinnedComments1.js +++ b/tests/baselines/reference/pinnedComments1.js @@ -1,12 +1,19 @@ //// [pinnedComments1.ts] +/*!========= + Keep this pinned comment + ========= +*/ /* unpinned comment */ -/*! pinned comment */ +/*! pinned comment that need to be removed */ class C { } //// [pinnedComments1.js] -/*! pinned comment */ +/*!========= + Keep this pinned comment + ========= +*/ var C = (function () { function C() { } diff --git a/tests/baselines/reference/pinnedComments1.symbols b/tests/baselines/reference/pinnedComments1.symbols index 53d46ecbaf6..6ee37435dfa 100644 --- a/tests/baselines/reference/pinnedComments1.symbols +++ b/tests/baselines/reference/pinnedComments1.symbols @@ -1,7 +1,11 @@ === tests/cases/compiler/pinnedComments1.ts === +/*!========= + Keep this pinned comment + ========= +*/ /* unpinned comment */ -/*! pinned comment */ +/*! pinned comment that need to be removed */ class C { >C : Symbol(C, Decl(pinnedComments1.ts, 0, 0)) } diff --git a/tests/baselines/reference/pinnedComments1.types b/tests/baselines/reference/pinnedComments1.types index d55feb67659..df97cbdbec9 100644 --- a/tests/baselines/reference/pinnedComments1.types +++ b/tests/baselines/reference/pinnedComments1.types @@ -1,7 +1,11 @@ === tests/cases/compiler/pinnedComments1.ts === +/*!========= + Keep this pinned comment + ========= +*/ /* unpinned comment */ -/*! pinned comment */ +/*! pinned comment that need to be removed */ class C { >C : C } diff --git a/tests/cases/compiler/commentOnAmbientClass1.ts b/tests/cases/compiler/commentOnAmbientClass1.ts index c13e4193512..1c153e86bf2 100644 --- a/tests/cases/compiler/commentOnAmbientClass1.ts +++ b/tests/cases/compiler/commentOnAmbientClass1.ts @@ -1,5 +1,10 @@ //@filename: a.ts -/*! Keep this pinned comment */ +/*!========= + Keep this pinned comment + ========= +*/ + +/*! Don't keep this pinned comment */ declare class C { } diff --git a/tests/cases/compiler/commentOnAmbientEnum.ts b/tests/cases/compiler/commentOnAmbientEnum.ts index a9ebe107c98..20d89c1b70d 100644 --- a/tests/cases/compiler/commentOnAmbientEnum.ts +++ b/tests/cases/compiler/commentOnAmbientEnum.ts @@ -1,5 +1,10 @@ //@filename: a.ts -/*! Keep this pinned comment */ +/*!========= + Keep this pinned comment + ========= +*/ + +/*! Don't keep this pinned comment */ declare enum C { a, b, diff --git a/tests/cases/compiler/commentOnAmbientModule.ts b/tests/cases/compiler/commentOnAmbientModule.ts index 41e12a61902..a8aeab7efba 100644 --- a/tests/cases/compiler/commentOnAmbientModule.ts +++ b/tests/cases/compiler/commentOnAmbientModule.ts @@ -1,5 +1,10 @@ //@filename: a.ts -/*! Keep this pinned comment */ +/*!========= + Keep this pinned comment + ========= +*/ + +/*! Don't keep this pinned comment */ declare module C { function foo(); } diff --git a/tests/cases/compiler/commentOnAmbientVariable1.ts b/tests/cases/compiler/commentOnAmbientVariable1.ts index 0124be05053..ef539441bd2 100644 --- a/tests/cases/compiler/commentOnAmbientVariable1.ts +++ b/tests/cases/compiler/commentOnAmbientVariable1.ts @@ -1,4 +1,9 @@ -/*! Keep this pinned comment */ +/*!========= + Keep this pinned comment + ========= +*/ + +/*! Don't keep this pinned comment */ declare var v: number; // Don't keep this comment. diff --git a/tests/cases/compiler/commentOnAmbientfunction.ts b/tests/cases/compiler/commentOnAmbientfunction.ts index d549303fc4f..51f3b6194b5 100644 --- a/tests/cases/compiler/commentOnAmbientfunction.ts +++ b/tests/cases/compiler/commentOnAmbientfunction.ts @@ -1,5 +1,10 @@ //@filename: a.ts -/*! Keep this pinned comment */ +/*!========= + Keep this pinned comment + ========= +*/ + +/*! Don't keep this pinned comment */ declare function foo(); // Don't keep this comment. diff --git a/tests/cases/compiler/commentOnElidedModule1.ts b/tests/cases/compiler/commentOnElidedModule1.ts index 22014a86f5b..0cdb7694273 100644 --- a/tests/cases/compiler/commentOnElidedModule1.ts +++ b/tests/cases/compiler/commentOnElidedModule1.ts @@ -1,5 +1,10 @@ //@filename: a.ts -/*! Keep this pinned comment */ +/*!================= + Keep this pinned + ================= +*/ + +/*! Don't keep this pinned comment */ module ElidedModule { } diff --git a/tests/cases/compiler/commentOnInterface1.ts b/tests/cases/compiler/commentOnInterface1.ts index a394da0dd2c..c22229b7ccf 100644 --- a/tests/cases/compiler/commentOnInterface1.ts +++ b/tests/cases/compiler/commentOnInterface1.ts @@ -1,5 +1,10 @@ //@filename: a.ts -/*! Keep this pinned comment */ +/*!================= + Keep this pinned + ================= +*/ + +/*! Don't keep this pinned comment */ interface I { } diff --git a/tests/cases/compiler/commentOnSignature1.ts b/tests/cases/compiler/commentOnSignature1.ts index 770c103a9fc..e8d2d831e8b 100644 --- a/tests/cases/compiler/commentOnSignature1.ts +++ b/tests/cases/compiler/commentOnSignature1.ts @@ -1,5 +1,10 @@ // @filename: a.ts -/*! Keep this pinned comment */ +/*!================= + Keep this pinned + ================= +*/ + +/*! Don't keep this pinned comment */ function foo(n: number): void; // Don't keep this comment. function foo(s: string): void; diff --git a/tests/cases/compiler/pinnedComments1.ts b/tests/cases/compiler/pinnedComments1.ts index 474769e9b20..4de91b33e56 100644 --- a/tests/cases/compiler/pinnedComments1.ts +++ b/tests/cases/compiler/pinnedComments1.ts @@ -1,6 +1,10 @@ // @comments: false +/*!========= + Keep this pinned comment + ========= +*/ /* unpinned comment */ -/*! pinned comment */ +/*! pinned comment that need to be removed */ class C { } \ No newline at end of file From 421990ed8199caa1b3edcd7ef0b98acb6fc18611 Mon Sep 17 00:00:00 2001 From: Vladimir Matveev Date: Wed, 26 Aug 2015 18:14:38 -0700 Subject: [PATCH 031/117] Revert "Address CR" This reverts commit 8a4c56bb761256906ec7b2af4f342d7eb8c2a094. --- src/harness/harness.ts | 10 +++++++++- src/harness/rwcRunner.ts | 11 +++++------ 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/src/harness/harness.ts b/src/harness/harness.ts index 5cde3ad3647..097340082e3 100644 --- a/src/harness/harness.ts +++ b/src/harness/harness.ts @@ -1415,7 +1415,15 @@ module Harness { assert.equal(markedErrorCount, fileErrors.length, "count of errors in " + inputFile.unitName); }); - assert.equal(totalErrorsReported, diagnostics.length, "total number of errors"); + let numLibraryDiagnostics = ts.countWhere(diagnostics, diagnostic => { + return diagnostic.file && (isLibraryFile(diagnostic.file.fileName) || isBuiltFile(diagnostic.file.fileName)); + }); + + let numTest262HarnessDiagnostics = ts.countWhere(diagnostics, diagnostic => { + // Count an error generated from tests262-harness folder.This should only apply for test262 + return diagnostic.file && diagnostic.file.fileName.indexOf("test262-harness") >= 0; + }); + return minimalDiagnosticsToString(diagnostics) + Harness.IO.newLine() + Harness.IO.newLine() + outputLines.join("\r\n"); } diff --git a/src/harness/rwcRunner.ts b/src/harness/rwcRunner.ts index cf748c3070b..ea6f7b7ebb1 100644 --- a/src/harness/rwcRunner.ts +++ b/src/harness/rwcRunner.ts @@ -19,12 +19,6 @@ module RWC { } } - let defaultLibPath = ts.sys.resolvePath("built/local/lib.d.ts"); - let defaultLib = { - unitName: ts.normalizePath(defaultLibPath), - content: Harness.IO.readFile(defaultLibPath) - }; - export function runRWCTest(jsonPath: string) { describe("Testing a RWC project: " + jsonPath, () => { let inputFiles: { unitName: string; content: string; }[] = []; @@ -72,6 +66,11 @@ module RWC { }); if (!useCustomLibraryFile) { + let defaultLibPath = ts.sys.resolvePath("built/local/lib.d.ts"); + let defaultLib = { + unitName: ts.normalizePath(defaultLibPath), + content: Harness.IO.readFile(defaultLibPath) + }; inputFiles.push(defaultLib); } From 1d9465379819a32505e0a82448bee42652a2000d Mon Sep 17 00:00:00 2001 From: Vladimir Matveev Date: Wed, 26 Aug 2015 18:14:52 -0700 Subject: [PATCH 032/117] Revert "Read default lib from the local file system instead of log-array when do Not use custom library file" This reverts commit 735efee7ce8a5cd594c6b2e647aaf11ae2ddbc51. --- src/harness/harness.ts | 3 +++ src/harness/rwcRunner.ts | 12 +++--------- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/src/harness/harness.ts b/src/harness/harness.ts index 097340082e3..de675948851 100644 --- a/src/harness/harness.ts +++ b/src/harness/harness.ts @@ -1424,6 +1424,9 @@ module Harness { return diagnostic.file && diagnostic.file.fileName.indexOf("test262-harness") >= 0; }); + // Verify we didn't miss any errors in total + assert.equal(totalErrorsReported + numLibraryDiagnostics + numTest262HarnessDiagnostics, diagnostics.length, "total number of errors"); + return minimalDiagnosticsToString(diagnostics) + Harness.IO.newLine() + Harness.IO.newLine() + outputLines.join("\r\n"); } diff --git a/src/harness/rwcRunner.ts b/src/harness/rwcRunner.ts index ea6f7b7ebb1..d8b52ec2e39 100644 --- a/src/harness/rwcRunner.ts +++ b/src/harness/rwcRunner.ts @@ -65,15 +65,6 @@ module RWC { opts.options.noEmitOnError = false; }); - if (!useCustomLibraryFile) { - let defaultLibPath = ts.sys.resolvePath("built/local/lib.d.ts"); - let defaultLib = { - unitName: ts.normalizePath(defaultLibPath), - content: Harness.IO.readFile(defaultLibPath) - }; - inputFiles.push(defaultLib); - } - runWithIOLog(ioLog, () => { harnessCompiler.reset(); @@ -105,6 +96,9 @@ module RWC { if (useCustomLibraryFile) { inputFiles.push(getHarnessCompilerInputUnit(fileRead.path)); } + else { + inputFiles.push(Harness.getDefaultLibraryFile()); + } } } } From af2a49992fa1d22a93766b8932829c9900a8075c Mon Sep 17 00:00:00 2001 From: Vladimir Matveev Date: Wed, 26 Aug 2015 18:54:25 -0700 Subject: [PATCH 033/117] Move RWC runner to use Harness.IO --- src/compiler/commandLineParser.ts | 6 +++--- src/harness/harness.ts | 17 +++++++++++++-- src/harness/loggedIO.ts | 34 +++++++++++++++++------------ src/harness/rwcRunner.ts | 36 +++++++++++++++++++------------ 4 files changed, 60 insertions(+), 33 deletions(-) diff --git a/src/compiler/commandLineParser.ts b/src/compiler/commandLineParser.ts index 7a7ba34da87..cfad85d1e33 100644 --- a/src/compiler/commandLineParser.ts +++ b/src/compiler/commandLineParser.ts @@ -237,13 +237,13 @@ namespace ts { } ]; - export function parseCommandLine(commandLine: string[]): ParsedCommandLine { + export function parseCommandLine(commandLine: string[], readFile?: (fileName: string) => string): ParsedCommandLine { let options: CompilerOptions = {}; let fileNames: string[] = []; let errors: Diagnostic[] = []; let shortOptionNames: Map = {}; let optionNameMap: Map = {}; - + forEach(optionDeclarations, option => { optionNameMap[option.name.toLowerCase()] = option; if (option.shortName) { @@ -313,7 +313,7 @@ namespace ts { } function parseResponseFile(fileName: string) { - let text = sys.readFile(fileName); + let text = readFile ? readFile(fileName): sys.readFile(fileName); if (!text) { errors.push(createCompilerDiagnostic(Diagnostics.File_0_not_found, fileName)); diff --git a/src/harness/harness.ts b/src/harness/harness.ts index de675948851..78546f81c73 100644 --- a/src/harness/harness.ts +++ b/src/harness/harness.ts @@ -425,6 +425,9 @@ module Harness { listFiles(path: string, filter: RegExp, options?: { recursive?: boolean }): string[]; log(text: string): void; getMemoryUsage?(): number; + args(): string[]; + getExecutingFilePath(): string; + exit(exitCode?: number): void; } export var IO: IO; @@ -446,7 +449,10 @@ module Harness { } else { fso = {}; } - + + export const args = () => ts.sys.args; + export const getExecutingFilePath = () => ts.sys.getExecutingFilePath(); + export const exit = (exitCode: number) => ts.sys.exit(exitCode); export const resolvePath = (path: string) => ts.sys.resolvePath(path); export const getCurrentDirectory = () => ts.sys.getCurrentDirectory(); export const newLine = () => harnessNewLine; @@ -517,6 +523,9 @@ module Harness { export const getCurrentDirectory = () => ts.sys.getCurrentDirectory(); export const newLine = () => harnessNewLine; export const useCaseSensitiveFileNames = () => ts.sys.useCaseSensitiveFileNames; + export const args = () => ts.sys.args; + export const getExecutingFilePath = () => ts.sys.getExecutingFilePath(); + export const exit = (exitCode: number) => ts.sys.exit(exitCode); export const readFile: typeof IO.readFile = path => ts.sys.readFile(path); export const writeFile: typeof IO.writeFile = (path, content) => ts.sys.writeFile(path, content); @@ -589,6 +598,10 @@ module Harness { export const newLine = () => harnessNewLine; export const useCaseSensitiveFileNames = () => false; export const getCurrentDirectory = () => ""; + export const args = () => []; + export const getExecutingFilePath = () => ""; + export const exit = (exitCode: number) => {}; + let supportsCodePage = () => false; module Http { @@ -1804,7 +1817,7 @@ module Harness { } export function getDefaultLibraryFile(): { unitName: string, content: string } { - let libFile = Harness.userSpecifiedRoot + Harness.libFolder + "/" + "lib.d.ts"; + let libFile = Harness.userSpecifiedRoot + Harness.libFolder + "lib.d.ts"; return { unitName: libFile, content: IO.readFile(libFile) diff --git a/src/harness/loggedIO.ts b/src/harness/loggedIO.ts index db82a47d362..5a572e220b3 100644 --- a/src/harness/loggedIO.ts +++ b/src/harness/loggedIO.ts @@ -93,7 +93,7 @@ module Playback { return run; } - export interface PlaybackSystem extends ts.System, PlaybackControl { } + export interface PlaybackIO extends Harness.IO, PlaybackControl { } function createEmptyLog(): IOLog { return { @@ -223,8 +223,8 @@ module Playback { // console.log("Swallowed write operation during replay: " + name); } - export function wrapSystem(underlying: ts.System): PlaybackSystem { - let wrapper: PlaybackSystem = {}; + export function wrapIO(underlying: Harness.IO): PlaybackIO { + let wrapper: PlaybackIO = {}; initWrapper(wrapper, underlying); wrapper.startReplayFromFile = logFn => { @@ -239,18 +239,24 @@ module Playback { recordLog = undefined; } }; - - Object.defineProperty(wrapper, "args", { - get() { - if (replayLog !== undefined) { - return replayLog.arguments; - } else if (recordLog !== undefined) { - recordLog.arguments = underlying.args; - } - return underlying.args; + + wrapper.args = () => { + if (replayLog !== undefined) { + return replayLog.arguments; + } else if (recordLog !== undefined) { + recordLog.arguments = underlying.args(); } - }); - + return underlying.args(); + } + + wrapper.newLine = () => underlying.newLine(); + wrapper.useCaseSensitiveFileNames = () => underlying.useCaseSensitiveFileNames(); + wrapper.directoryName = (path): string => { throw new Error("NotSupported"); }; + wrapper.createDirectory = path => { throw new Error("NotSupported"); }; + wrapper.directoryExists = (path): boolean => { throw new Error("NotSupported"); }; + wrapper.deleteFile = path => { throw new Error("NotSupported"); }; + wrapper.listFiles = (path, filter, options): string[] => { throw new Error("NotSupported"); }; + wrapper.log = text => underlying.log(text); wrapper.fileExists = recordReplay(wrapper.fileExists, underlying)( (path) => callAndRecord(underlying.fileExists(path), recordLog.fileExists, { path: path }), diff --git a/src/harness/rwcRunner.ts b/src/harness/rwcRunner.ts index d8b52ec2e39..c89a8b1d910 100644 --- a/src/harness/rwcRunner.ts +++ b/src/harness/rwcRunner.ts @@ -5,17 +5,17 @@ module RWC { function runWithIOLog(ioLog: IOLog, fn: () => void) { - let oldSys = ts.sys; + let oldIO = Harness.IO; - let wrappedSys = Playback.wrapSystem(ts.sys); - wrappedSys.startReplayFromData(ioLog); - ts.sys = wrappedSys; + let wrappedIO = Playback.wrapIO(oldIO); + wrappedIO.startReplayFromData(ioLog); + Harness.IO = wrappedIO; try { fn(); } finally { - wrappedSys.endReplay(); - ts.sys = oldSys; + wrappedIO.endReplay(); + Harness.IO = oldIO; } } @@ -32,7 +32,9 @@ module RWC { let baseName = /(.*)\/(.*).json/.exec(ts.normalizeSlashes(jsonPath))[2]; let currentDirectory: string; let useCustomLibraryFile: boolean; - + + const defaultLibraryFile = Harness.getDefaultLibraryFile(); + after(() => { // Mocha holds onto the closure environment of the describe callback even after the test is done. // Therefore we have to clean out large objects after the test is done. @@ -57,7 +59,7 @@ module RWC { currentDirectory = ioLog.currentDirectory; useCustomLibraryFile = ioLog.useCustomLibraryFile; runWithIOLog(ioLog, () => { - opts = ts.parseCommandLine(ioLog.arguments); + opts = ts.parseCommandLine(ioLog.arguments, fileName => Harness.IO.readFile(fileName)); assert.equal(opts.errors.length, 0); // To provide test coverage of output javascript file, @@ -75,9 +77,10 @@ module RWC { // Add files to compilation let isInInputList = (resolvedPath: string) => (inputFile: { unitName: string; content: string; }) => inputFile.unitName === resolvedPath; + let prependDefaultLib = false; for (let fileRead of ioLog.filesRead) { // Check if the file is already added into the set of input files. - const resolvedPath = ts.normalizeSlashes(ts.sys.resolvePath(fileRead.path)); + const resolvedPath = ts.normalizeSlashes(Harness.IO.resolvePath(fileRead.path)); let inInputList = ts.forEach(inputFiles, isInInputList(resolvedPath)); if (!Harness.isLibraryFile(fileRead.path)) { @@ -97,11 +100,16 @@ module RWC { inputFiles.push(getHarnessCompilerInputUnit(fileRead.path)); } else { - inputFiles.push(Harness.getDefaultLibraryFile()); + // set the flag to put default library to the beginning of the list + prependDefaultLib = true; } } } } + + if (prependDefaultLib) { + inputFiles.unshift(defaultLibraryFile); + } // do not use lib since we already read it in above opts.options.noLib = true; @@ -118,13 +126,13 @@ module RWC { }); function getHarnessCompilerInputUnit(fileName: string) { - let unitName = ts.normalizeSlashes(ts.sys.resolvePath(fileName)); + let unitName = ts.normalizeSlashes(Harness.IO.resolvePath(fileName)); let content: string = null; try { - content = ts.sys.readFile(unitName); + content = Harness.IO.readFile(unitName); } catch (e) { - content = ts.sys.readFile(fileName); + content = Harness.IO.readFile(fileName); } return { unitName, content }; } @@ -187,7 +195,7 @@ module RWC { } return Harness.Compiler.minimalDiagnosticsToString(declFileCompilationResult.declResult.errors) + - ts.sys.newLine + ts.sys.newLine + + Harness.IO.newLine() + Harness.IO.newLine() + Harness.Compiler.getErrorBaseline(declFileCompilationResult.declInputFiles.concat(declFileCompilationResult.declOtherFiles), declFileCompilationResult.declResult.errors); }, false, baselineOpts); } From 3598b906e344b5a2971a65cedb99536df3847292 Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Thu, 27 Aug 2015 11:40:21 -0700 Subject: [PATCH 034/117] Add optional argument to readConfigFile Which allows the caller to specify the `System` used to read the file. --- src/compiler/commandLineParser.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/compiler/commandLineParser.ts b/src/compiler/commandLineParser.ts index 1f57c142113..ece6471ee2f 100644 --- a/src/compiler/commandLineParser.ts +++ b/src/compiler/commandLineParser.ts @@ -374,10 +374,10 @@ namespace ts { * Read tsconfig.json file * @param fileName The path to the config file */ - export function readConfigFile(fileName: string): { config?: any; error?: Diagnostic } { + export function readConfigFile(fileName: string, system: System = sys): { config?: any; error?: Diagnostic } { let text = ""; try { - text = sys.readFile(fileName); + text = system.readFile(fileName); } catch (e) { return { error: createCompilerDiagnostic(Diagnostics.Cannot_read_file_0_Colon_1, fileName, e.message) }; From d29964ac741cb85aeb8f4cc980711f0373062f52 Mon Sep 17 00:00:00 2001 From: Vladimir Matveev Date: Wed, 26 Aug 2015 13:12:29 -0700 Subject: [PATCH 035/117] fix error message for forward references in enums --- src/compiler/checker.ts | 2 +- .../diagnosticInformationMap.generated.ts | 2 +- src/compiler/diagnosticMessages.json | 2 +- .../reference/constEnumErrors.errors.txt | 4 +-- .../reference/forwardRefInEnum.errors.txt | 29 +++++++++++++++++ tests/baselines/reference/forwardRefInEnum.js | 31 +++++++++++++++++++ tests/cases/compiler/forwardRefInEnum.ts | 13 ++++++++ 7 files changed, 78 insertions(+), 5 deletions(-) create mode 100644 tests/baselines/reference/forwardRefInEnum.errors.txt create mode 100644 tests/baselines/reference/forwardRefInEnum.js create mode 100644 tests/cases/compiler/forwardRefInEnum.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index ae388c5b832..33761e2b2e6 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -13053,7 +13053,7 @@ namespace ts { // illegal case: forward reference if (!isDefinedBefore(propertyDecl, member)) { reportError = false; - error(e, Diagnostics.A_member_initializer_in_a_const_enum_declaration_cannot_reference_members_declared_after_it_including_members_defined_in_other_const_enums); + error(e, Diagnostics.A_member_initializer_in_a_enum_declaration_cannot_reference_members_declared_after_it_including_members_defined_in_other_enums); return undefined; } diff --git a/src/compiler/diagnosticInformationMap.generated.ts b/src/compiler/diagnosticInformationMap.generated.ts index 76c68b4c3b4..5c4400b4fe4 100644 --- a/src/compiler/diagnosticInformationMap.generated.ts +++ b/src/compiler/diagnosticInformationMap.generated.ts @@ -425,7 +425,7 @@ namespace ts { JSX_element_class_does_not_support_attributes_because_it_does_not_have_a_0_property: { code: 2607, category: DiagnosticCategory.Error, key: "JSX element class does not support attributes because it does not have a '{0}' property" }, The_global_type_JSX_0_may_not_have_more_than_one_property: { code: 2608, category: DiagnosticCategory.Error, key: "The global type 'JSX.{0}' may not have more than one property" }, Cannot_emit_namespaced_JSX_elements_in_React: { code: 2650, category: DiagnosticCategory.Error, key: "Cannot emit namespaced JSX elements in React" }, - A_member_initializer_in_a_const_enum_declaration_cannot_reference_members_declared_after_it_including_members_defined_in_other_const_enums: { code: 2651, category: DiagnosticCategory.Error, key: "A member initializer in a 'const' enum declaration cannot reference members declared after it, including members defined in other 'const' enums." }, + A_member_initializer_in_a_enum_declaration_cannot_reference_members_declared_after_it_including_members_defined_in_other_enums: { code: 2651, category: DiagnosticCategory.Error, key: "A member initializer in a enum declaration cannot reference members declared after it, including members defined in other enums." }, Merged_declaration_0_cannot_include_a_default_export_declaration_Consider_adding_a_separate_export_default_0_declaration_instead: { code: 2652, category: DiagnosticCategory.Error, key: "Merged declaration '{0}' cannot include a default export declaration. Consider adding a separate 'export default {0}' declaration instead." }, Import_declaration_0_is_using_private_name_1: { code: 4000, category: DiagnosticCategory.Error, key: "Import declaration '{0}' is using private name '{1}'." }, Type_parameter_0_of_exported_class_has_or_is_using_private_name_1: { code: 4002, category: DiagnosticCategory.Error, key: "Type parameter '{0}' of exported class has or is using private name '{1}'." }, diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index 8113722ff3c..6c1fe01f724 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -1689,7 +1689,7 @@ "category": "Error", "code": 2650 }, - "A member initializer in a 'const' enum declaration cannot reference members declared after it, including members defined in other 'const' enums.": { + "A member initializer in a enum declaration cannot reference members declared after it, including members defined in other enums.": { "category": "Error", "code": 2651 }, diff --git a/tests/baselines/reference/constEnumErrors.errors.txt b/tests/baselines/reference/constEnumErrors.errors.txt index 4236544defa..586652d41eb 100644 --- a/tests/baselines/reference/constEnumErrors.errors.txt +++ b/tests/baselines/reference/constEnumErrors.errors.txt @@ -1,6 +1,6 @@ tests/cases/compiler/constEnumErrors.ts(1,12): error TS2300: Duplicate identifier 'E'. tests/cases/compiler/constEnumErrors.ts(5,8): error TS2300: Duplicate identifier 'E'. -tests/cases/compiler/constEnumErrors.ts(12,9): error TS2651: A member initializer in a 'const' enum declaration cannot reference members declared after it, including members defined in other 'const' enums. +tests/cases/compiler/constEnumErrors.ts(12,9): error TS2651: A member initializer in a enum declaration cannot reference members declared after it, including members defined in other enums. tests/cases/compiler/constEnumErrors.ts(14,9): error TS2474: In 'const' enum declarations member initializer must be constant expression. tests/cases/compiler/constEnumErrors.ts(15,10): error TS2474: In 'const' enum declarations member initializer must be constant expression. tests/cases/compiler/constEnumErrors.ts(22,13): error TS2476: A const enum member can only be accessed using a string literal. @@ -31,7 +31,7 @@ tests/cases/compiler/constEnumErrors.ts(42,9): error TS2478: 'const' enum member // forward reference to the element of the same enum X = Y, ~ -!!! error TS2651: A member initializer in a 'const' enum declaration cannot reference members declared after it, including members defined in other 'const' enums. +!!! error TS2651: A member initializer in a enum declaration cannot reference members declared after it, including members defined in other enums. // forward reference to the element of the same enum Y = E1.Z, ~~~~ diff --git a/tests/baselines/reference/forwardRefInEnum.errors.txt b/tests/baselines/reference/forwardRefInEnum.errors.txt new file mode 100644 index 00000000000..0f2c359402f --- /dev/null +++ b/tests/baselines/reference/forwardRefInEnum.errors.txt @@ -0,0 +1,29 @@ +tests/cases/compiler/forwardRefInEnum.ts(4,9): error TS2651: A member initializer in a enum declaration cannot reference members declared after it, including members defined in other enums. +tests/cases/compiler/forwardRefInEnum.ts(5,10): error TS2651: A member initializer in a enum declaration cannot reference members declared after it, including members defined in other enums. +tests/cases/compiler/forwardRefInEnum.ts(7,9): error TS2651: A member initializer in a enum declaration cannot reference members declared after it, including members defined in other enums. +tests/cases/compiler/forwardRefInEnum.ts(8,10): error TS2651: A member initializer in a enum declaration cannot reference members declared after it, including members defined in other enums. + + +==== tests/cases/compiler/forwardRefInEnum.ts (4 errors) ==== + enum E1 { + // illegal case + // forward reference to the element of the same enum + X = Y, + ~ +!!! error TS2651: A member initializer in a enum declaration cannot reference members declared after it, including members defined in other enums. + X1 = E1["Y"], + ~~~~~~~ +!!! error TS2651: A member initializer in a enum declaration cannot reference members declared after it, including members defined in other enums. + // forward reference to the element of the same enum + Y = E1.Z, + ~~~~ +!!! error TS2651: A member initializer in a enum declaration cannot reference members declared after it, including members defined in other enums. + Y1 = E1["Z"] + ~~~~~~~ +!!! error TS2651: A member initializer in a enum declaration cannot reference members declared after it, including members defined in other enums. + } + + enum E1 { + Z = 4 + } + \ No newline at end of file diff --git a/tests/baselines/reference/forwardRefInEnum.js b/tests/baselines/reference/forwardRefInEnum.js new file mode 100644 index 00000000000..76e2575ec8d --- /dev/null +++ b/tests/baselines/reference/forwardRefInEnum.js @@ -0,0 +1,31 @@ +//// [forwardRefInEnum.ts] +enum E1 { + // illegal case + // forward reference to the element of the same enum + X = Y, + X1 = E1["Y"], + // forward reference to the element of the same enum + Y = E1.Z, + Y1 = E1["Z"] +} + +enum E1 { + Z = 4 +} + + +//// [forwardRefInEnum.js] +var E1; +(function (E1) { + // illegal case + // forward reference to the element of the same enum + E1[E1["X"] = E1.Y] = "X"; + E1[E1["X1"] = E1["Y"]] = "X1"; + // forward reference to the element of the same enum + E1[E1["Y"] = E1.Z] = "Y"; + E1[E1["Y1"] = E1["Z"]] = "Y1"; +})(E1 || (E1 = {})); +var E1; +(function (E1) { + E1[E1["Z"] = 4] = "Z"; +})(E1 || (E1 = {})); diff --git a/tests/cases/compiler/forwardRefInEnum.ts b/tests/cases/compiler/forwardRefInEnum.ts new file mode 100644 index 00000000000..97bc1819d7b --- /dev/null +++ b/tests/cases/compiler/forwardRefInEnum.ts @@ -0,0 +1,13 @@ +enum E1 { + // illegal case + // forward reference to the element of the same enum + X = Y, + X1 = E1["Y"], + // forward reference to the element of the same enum + Y = E1.Z, + Y1 = E1["Z"] +} + +enum E1 { + Z = 4 +} From 155a8870f3e1560f760c082bd4dd81d7526cf6d1 Mon Sep 17 00:00:00 2001 From: Mohamed Hegazy Date: Thu, 27 Aug 2015 15:49:50 -0700 Subject: [PATCH 036/117] Revert "Update version to 1.7" This reverts commit 6fbf4494b532080889daabaea3f2e189bfa16d67. --- src/compiler/program.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/compiler/program.ts b/src/compiler/program.ts index 402b413dd9c..a1861f6b462 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -12,7 +12,7 @@ namespace ts { let emptyArray: any[] = []; - export const version = "1.7.0"; + export const version = "1.6.0"; export function findConfigFile(searchPath: string): string { let fileName = "tsconfig.json"; From 2fe37c02b337808a8aa72164b68da47ec008345e Mon Sep 17 00:00:00 2001 From: Mohamed Hegazy Date: Thu, 27 Aug 2015 15:51:37 -0700 Subject: [PATCH 037/117] Revert "Update version to 1.7 in 'master'." This reverts commit 13815442fe2027191dc816963ddbbc5b7eda8291. --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index b743b04838d..abd81e12f47 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "typescript", "author": "Microsoft Corp.", "homepage": "http://typescriptlang.org/", - "version": "1.7.0", + "version": "1.6.0", "license": "Apache-2.0", "description": "TypeScript is a language for application scale JavaScript development", "keywords": [ From e4af02bb8b27b409a8e600454967b335cbada459 Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Thu, 27 Aug 2015 16:35:02 -0700 Subject: [PATCH 038/117] Toss the option out the window --- src/compiler/commandLineParser.ts | 2 +- src/compiler/tsc.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/compiler/commandLineParser.ts b/src/compiler/commandLineParser.ts index ece6471ee2f..6696045be94 100644 --- a/src/compiler/commandLineParser.ts +++ b/src/compiler/commandLineParser.ts @@ -374,7 +374,7 @@ namespace ts { * Read tsconfig.json file * @param fileName The path to the config file */ - export function readConfigFile(fileName: string, system: System = sys): { config?: any; error?: Diagnostic } { + export function readConfigFile(fileName: string, system: System): { config?: any; error?: Diagnostic } { let text = ""; try { text = system.readFile(fileName); diff --git a/src/compiler/tsc.ts b/src/compiler/tsc.ts index 8c0a6d4e8c4..1c883eb37dd 100644 --- a/src/compiler/tsc.ts +++ b/src/compiler/tsc.ts @@ -216,7 +216,7 @@ namespace ts { if (!cachedProgram) { if (configFileName) { - let result = readConfigFile(configFileName); + let result = readConfigFile(configFileName, sys); if (result.error) { reportDiagnostic(result.error); return sys.exit(ExitStatus.DiagnosticsPresent_OutputsSkipped); From e047025ff9b63d33c5f37559a47823070dc7399c Mon Sep 17 00:00:00 2001 From: Mohamed Hegazy Date: Thu, 27 Aug 2015 16:50:34 -0700 Subject: [PATCH 039/117] Update LKG --- lib/tsc.js | 17 ++++++++++++++--- lib/tsserver.js | 17 ++++++++++++++--- lib/typescript.d.ts | 1 + lib/typescript.js | 17 ++++++++++++++--- lib/typescriptServices.d.ts | 1 + lib/typescriptServices.js | 17 ++++++++++++++--- 6 files changed, 58 insertions(+), 12 deletions(-) diff --git a/lib/tsc.js b/lib/tsc.js index 0ccb839c2ef..39fd0e10a7e 100644 --- a/lib/tsc.js +++ b/lib/tsc.js @@ -1573,6 +1573,7 @@ var ts; Specifies_module_resolution_strategy_Colon_node_Node_or_classic_TypeScript_pre_1_6: { code: 6069, category: ts.DiagnosticCategory.Message, key: "Specifies module resolution strategy: 'node' (Node) or 'classic' (TypeScript pre 1.6) ." }, Initializes_a_TypeScript_project_and_creates_a_tsconfig_json_file: { code: 6070, category: ts.DiagnosticCategory.Message, key: "Initializes a TypeScript project and creates a tsconfig.json file." }, Successfully_created_a_tsconfig_json_file: { code: 6071, category: ts.DiagnosticCategory.Message, key: "Successfully created a tsconfig.json file." }, + Suppress_excess_property_checks_for_object_literals: { code: 6072, category: ts.DiagnosticCategory.Message, key: "Suppress excess property checks for object literals." }, Variable_0_implicitly_has_an_1_type: { code: 7005, category: ts.DiagnosticCategory.Error, key: "Variable '{0}' implicitly has an '{1}' type." }, Parameter_0_implicitly_has_an_1_type: { code: 7006, category: ts.DiagnosticCategory.Error, key: "Parameter '{0}' implicitly has an '{1}' type." }, Member_0_implicitly_has_an_1_type: { code: 7008, category: ts.DiagnosticCategory.Error, key: "Member '{0}' implicitly has an '{1}' type." }, @@ -12680,7 +12681,7 @@ var ts; return members; } function resolveTupleTypeMembers(type) { - var arrayType = resolveStructuredTypeMembers(createArrayType(getUnionType(type.elementTypes))); + var arrayType = resolveStructuredTypeMembers(createArrayType(getUnionType(type.elementTypes, true))); var members = createTupleTypeMemberSymbols(type.elementTypes); addInheritedMembers(members, arrayType.properties); setObjectTypeMembers(type, members, arrayType.callSignatures, arrayType.constructSignatures, arrayType.stringIndexType, arrayType.numberIndexType); @@ -15973,7 +15974,7 @@ var ts; var propertiesTable = {}; var propertiesArray = []; var contextualType = getContextualType(node); - var typeFlags; + var typeFlags = 0; for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var memberDecl = _a[_i]; var member = memberDecl.symbol; @@ -16014,7 +16015,8 @@ var ts; var stringIndexType = getIndexType(0); var numberIndexType = getIndexType(1); var result = createAnonymousType(node.symbol, propertiesTable, emptyArray, emptyArray, stringIndexType, numberIndexType); - result.flags |= 524288 | 1048576 | 4194304 | (typeFlags & 14680064); + var freshObjectLiteralFlag = compilerOptions.suppressExcessPropertyErrors ? 0 : 1048576; + result.flags |= 524288 | 4194304 | freshObjectLiteralFlag | (typeFlags & 14680064); return result; function getIndexType(kind) { if (contextualType && contextualTypeHasIndexSignature(contextualType, kind)) { @@ -19714,6 +19716,7 @@ var ts; if (baseTypes.length && produceDiagnostics) { var baseType = baseTypes[0]; var staticBaseType = getBaseConstructorTypeOfClass(type); + checkSourceElement(baseTypeNode.expression); if (baseTypeNode.typeArguments) { ts.forEach(baseTypeNode.typeArguments, checkSourceElement); for (var _i = 0, _a = getConstructorsForTypeArguments(staticBaseType, baseTypeNode.typeArguments); _i < _a.length; _i++) { @@ -20613,6 +20616,8 @@ var ts; case 209: case 210: case 212: + case 241: + case 186: case 215: case 245: case 225: @@ -30376,6 +30381,12 @@ var ts; description: ts.Diagnostics.Specifies_the_location_where_debugger_should_locate_TypeScript_files_instead_of_source_locations, paramType: ts.Diagnostics.LOCATION }, + { + name: "suppressExcessPropertyErrors", + type: "boolean", + description: ts.Diagnostics.Suppress_excess_property_checks_for_object_literals, + experimental: true + }, { name: "suppressImplicitAnyIndexErrors", type: "boolean", diff --git a/lib/tsserver.js b/lib/tsserver.js index 3c339e6d661..bfc84fd1a92 100644 --- a/lib/tsserver.js +++ b/lib/tsserver.js @@ -1573,6 +1573,7 @@ var ts; Specifies_module_resolution_strategy_Colon_node_Node_or_classic_TypeScript_pre_1_6: { code: 6069, category: ts.DiagnosticCategory.Message, key: "Specifies module resolution strategy: 'node' (Node) or 'classic' (TypeScript pre 1.6) ." }, Initializes_a_TypeScript_project_and_creates_a_tsconfig_json_file: { code: 6070, category: ts.DiagnosticCategory.Message, key: "Initializes a TypeScript project and creates a tsconfig.json file." }, Successfully_created_a_tsconfig_json_file: { code: 6071, category: ts.DiagnosticCategory.Message, key: "Successfully created a tsconfig.json file." }, + Suppress_excess_property_checks_for_object_literals: { code: 6072, category: ts.DiagnosticCategory.Message, key: "Suppress excess property checks for object literals." }, Variable_0_implicitly_has_an_1_type: { code: 7005, category: ts.DiagnosticCategory.Error, key: "Variable '{0}' implicitly has an '{1}' type." }, Parameter_0_implicitly_has_an_1_type: { code: 7006, category: ts.DiagnosticCategory.Error, key: "Parameter '{0}' implicitly has an '{1}' type." }, Member_0_implicitly_has_an_1_type: { code: 7008, category: ts.DiagnosticCategory.Error, key: "Member '{0}' implicitly has an '{1}' type." }, @@ -3163,6 +3164,12 @@ var ts; description: ts.Diagnostics.Specifies_the_location_where_debugger_should_locate_TypeScript_files_instead_of_source_locations, paramType: ts.Diagnostics.LOCATION }, + { + name: "suppressExcessPropertyErrors", + type: "boolean", + description: ts.Diagnostics.Suppress_excess_property_checks_for_object_literals, + experimental: true + }, { name: "suppressImplicitAnyIndexErrors", type: "boolean", @@ -13136,7 +13143,7 @@ var ts; return members; } function resolveTupleTypeMembers(type) { - var arrayType = resolveStructuredTypeMembers(createArrayType(getUnionType(type.elementTypes))); + var arrayType = resolveStructuredTypeMembers(createArrayType(getUnionType(type.elementTypes, true))); var members = createTupleTypeMemberSymbols(type.elementTypes); addInheritedMembers(members, arrayType.properties); setObjectTypeMembers(type, members, arrayType.callSignatures, arrayType.constructSignatures, arrayType.stringIndexType, arrayType.numberIndexType); @@ -16429,7 +16436,7 @@ var ts; var propertiesTable = {}; var propertiesArray = []; var contextualType = getContextualType(node); - var typeFlags; + var typeFlags = 0; for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var memberDecl = _a[_i]; var member = memberDecl.symbol; @@ -16470,7 +16477,8 @@ var ts; var stringIndexType = getIndexType(0); var numberIndexType = getIndexType(1); var result = createAnonymousType(node.symbol, propertiesTable, emptyArray, emptyArray, stringIndexType, numberIndexType); - result.flags |= 524288 | 1048576 | 4194304 | (typeFlags & 14680064); + var freshObjectLiteralFlag = compilerOptions.suppressExcessPropertyErrors ? 0 : 1048576; + result.flags |= 524288 | 4194304 | freshObjectLiteralFlag | (typeFlags & 14680064); return result; function getIndexType(kind) { if (contextualType && contextualTypeHasIndexSignature(contextualType, kind)) { @@ -20170,6 +20178,7 @@ var ts; if (baseTypes.length && produceDiagnostics) { var baseType = baseTypes[0]; var staticBaseType = getBaseConstructorTypeOfClass(type); + checkSourceElement(baseTypeNode.expression); if (baseTypeNode.typeArguments) { ts.forEach(baseTypeNode.typeArguments, checkSourceElement); for (var _i = 0, _a = getConstructorsForTypeArguments(staticBaseType, baseTypeNode.typeArguments); _i < _a.length; _i++) { @@ -21069,6 +21078,8 @@ var ts; case 209: case 210: case 212: + case 241: + case 186: case 215: case 245: case 225: diff --git a/lib/typescript.d.ts b/lib/typescript.d.ts index f94d24269f1..72fca78224e 100644 --- a/lib/typescript.d.ts +++ b/lib/typescript.d.ts @@ -1329,6 +1329,7 @@ declare module "typescript" { rootDir?: string; sourceMap?: boolean; sourceRoot?: string; + suppressExcessPropertyErrors?: boolean; suppressImplicitAnyIndexErrors?: boolean; target?: ScriptTarget; version?: boolean; diff --git a/lib/typescript.js b/lib/typescript.js index c1105bb262a..ccbef3d8d87 100644 --- a/lib/typescript.js +++ b/lib/typescript.js @@ -2442,6 +2442,7 @@ var ts; Specifies_module_resolution_strategy_Colon_node_Node_or_classic_TypeScript_pre_1_6: { code: 6069, category: ts.DiagnosticCategory.Message, key: "Specifies module resolution strategy: 'node' (Node) or 'classic' (TypeScript pre 1.6) ." }, Initializes_a_TypeScript_project_and_creates_a_tsconfig_json_file: { code: 6070, category: ts.DiagnosticCategory.Message, key: "Initializes a TypeScript project and creates a tsconfig.json file." }, Successfully_created_a_tsconfig_json_file: { code: 6071, category: ts.DiagnosticCategory.Message, key: "Successfully created a tsconfig.json file." }, + Suppress_excess_property_checks_for_object_literals: { code: 6072, category: ts.DiagnosticCategory.Message, key: "Suppress excess property checks for object literals." }, Variable_0_implicitly_has_an_1_type: { code: 7005, category: ts.DiagnosticCategory.Error, key: "Variable '{0}' implicitly has an '{1}' type." }, Parameter_0_implicitly_has_an_1_type: { code: 7006, category: ts.DiagnosticCategory.Error, key: "Parameter '{0}' implicitly has an '{1}' type." }, Member_0_implicitly_has_an_1_type: { code: 7008, category: ts.DiagnosticCategory.Error, key: "Member '{0}' implicitly has an '{1}' type." }, @@ -15702,7 +15703,7 @@ var ts; return members; } function resolveTupleTypeMembers(type) { - var arrayType = resolveStructuredTypeMembers(createArrayType(getUnionType(type.elementTypes))); + var arrayType = resolveStructuredTypeMembers(createArrayType(getUnionType(type.elementTypes, /*noDeduplication*/ true))); var members = createTupleTypeMemberSymbols(type.elementTypes); addInheritedMembers(members, arrayType.properties); setObjectTypeMembers(type, members, arrayType.callSignatures, arrayType.constructSignatures, arrayType.stringIndexType, arrayType.numberIndexType); @@ -19438,7 +19439,7 @@ var ts; var propertiesTable = {}; var propertiesArray = []; var contextualType = getContextualType(node); - var typeFlags; + var typeFlags = 0; for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var memberDecl = _a[_i]; var member = memberDecl.symbol; @@ -19484,7 +19485,8 @@ var ts; var stringIndexType = getIndexType(0 /* String */); var numberIndexType = getIndexType(1 /* Number */); var result = createAnonymousType(node.symbol, propertiesTable, emptyArray, emptyArray, stringIndexType, numberIndexType); - result.flags |= 524288 /* ObjectLiteral */ | 1048576 /* FreshObjectLiteral */ | 4194304 /* ContainsObjectLiteral */ | (typeFlags & 14680064 /* PropagatingFlags */); + var freshObjectLiteralFlag = compilerOptions.suppressExcessPropertyErrors ? 0 : 1048576 /* FreshObjectLiteral */; + result.flags |= 524288 /* ObjectLiteral */ | 4194304 /* ContainsObjectLiteral */ | freshObjectLiteralFlag | (typeFlags & 14680064 /* PropagatingFlags */); return result; function getIndexType(kind) { if (contextualType && contextualTypeHasIndexSignature(contextualType, kind)) { @@ -24248,6 +24250,7 @@ var ts; if (baseTypes.length && produceDiagnostics) { var baseType = baseTypes[0]; var staticBaseType = getBaseConstructorTypeOfClass(type); + checkSourceElement(baseTypeNode.expression); if (baseTypeNode.typeArguments) { ts.forEach(baseTypeNode.typeArguments, checkSourceElement); for (var _i = 0, _a = getConstructorsForTypeArguments(staticBaseType, baseTypeNode.typeArguments); _i < _a.length; _i++) { @@ -25227,6 +25230,8 @@ var ts; case 209 /* VariableDeclaration */: case 210 /* VariableDeclarationList */: case 212 /* ClassDeclaration */: + case 241 /* HeritageClause */: + case 186 /* ExpressionWithTypeArguments */: case 215 /* EnumDeclaration */: case 245 /* EnumMember */: case 225 /* ExportAssignment */: @@ -36231,6 +36236,12 @@ var ts; description: ts.Diagnostics.Specifies_the_location_where_debugger_should_locate_TypeScript_files_instead_of_source_locations, paramType: ts.Diagnostics.LOCATION }, + { + name: "suppressExcessPropertyErrors", + type: "boolean", + description: ts.Diagnostics.Suppress_excess_property_checks_for_object_literals, + experimental: true + }, { name: "suppressImplicitAnyIndexErrors", type: "boolean", diff --git a/lib/typescriptServices.d.ts b/lib/typescriptServices.d.ts index 812305c8a68..339be4b1195 100644 --- a/lib/typescriptServices.d.ts +++ b/lib/typescriptServices.d.ts @@ -1329,6 +1329,7 @@ declare namespace ts { rootDir?: string; sourceMap?: boolean; sourceRoot?: string; + suppressExcessPropertyErrors?: boolean; suppressImplicitAnyIndexErrors?: boolean; target?: ScriptTarget; version?: boolean; diff --git a/lib/typescriptServices.js b/lib/typescriptServices.js index c1105bb262a..ccbef3d8d87 100644 --- a/lib/typescriptServices.js +++ b/lib/typescriptServices.js @@ -2442,6 +2442,7 @@ var ts; Specifies_module_resolution_strategy_Colon_node_Node_or_classic_TypeScript_pre_1_6: { code: 6069, category: ts.DiagnosticCategory.Message, key: "Specifies module resolution strategy: 'node' (Node) or 'classic' (TypeScript pre 1.6) ." }, Initializes_a_TypeScript_project_and_creates_a_tsconfig_json_file: { code: 6070, category: ts.DiagnosticCategory.Message, key: "Initializes a TypeScript project and creates a tsconfig.json file." }, Successfully_created_a_tsconfig_json_file: { code: 6071, category: ts.DiagnosticCategory.Message, key: "Successfully created a tsconfig.json file." }, + Suppress_excess_property_checks_for_object_literals: { code: 6072, category: ts.DiagnosticCategory.Message, key: "Suppress excess property checks for object literals." }, Variable_0_implicitly_has_an_1_type: { code: 7005, category: ts.DiagnosticCategory.Error, key: "Variable '{0}' implicitly has an '{1}' type." }, Parameter_0_implicitly_has_an_1_type: { code: 7006, category: ts.DiagnosticCategory.Error, key: "Parameter '{0}' implicitly has an '{1}' type." }, Member_0_implicitly_has_an_1_type: { code: 7008, category: ts.DiagnosticCategory.Error, key: "Member '{0}' implicitly has an '{1}' type." }, @@ -15702,7 +15703,7 @@ var ts; return members; } function resolveTupleTypeMembers(type) { - var arrayType = resolveStructuredTypeMembers(createArrayType(getUnionType(type.elementTypes))); + var arrayType = resolveStructuredTypeMembers(createArrayType(getUnionType(type.elementTypes, /*noDeduplication*/ true))); var members = createTupleTypeMemberSymbols(type.elementTypes); addInheritedMembers(members, arrayType.properties); setObjectTypeMembers(type, members, arrayType.callSignatures, arrayType.constructSignatures, arrayType.stringIndexType, arrayType.numberIndexType); @@ -19438,7 +19439,7 @@ var ts; var propertiesTable = {}; var propertiesArray = []; var contextualType = getContextualType(node); - var typeFlags; + var typeFlags = 0; for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var memberDecl = _a[_i]; var member = memberDecl.symbol; @@ -19484,7 +19485,8 @@ var ts; var stringIndexType = getIndexType(0 /* String */); var numberIndexType = getIndexType(1 /* Number */); var result = createAnonymousType(node.symbol, propertiesTable, emptyArray, emptyArray, stringIndexType, numberIndexType); - result.flags |= 524288 /* ObjectLiteral */ | 1048576 /* FreshObjectLiteral */ | 4194304 /* ContainsObjectLiteral */ | (typeFlags & 14680064 /* PropagatingFlags */); + var freshObjectLiteralFlag = compilerOptions.suppressExcessPropertyErrors ? 0 : 1048576 /* FreshObjectLiteral */; + result.flags |= 524288 /* ObjectLiteral */ | 4194304 /* ContainsObjectLiteral */ | freshObjectLiteralFlag | (typeFlags & 14680064 /* PropagatingFlags */); return result; function getIndexType(kind) { if (contextualType && contextualTypeHasIndexSignature(contextualType, kind)) { @@ -24248,6 +24250,7 @@ var ts; if (baseTypes.length && produceDiagnostics) { var baseType = baseTypes[0]; var staticBaseType = getBaseConstructorTypeOfClass(type); + checkSourceElement(baseTypeNode.expression); if (baseTypeNode.typeArguments) { ts.forEach(baseTypeNode.typeArguments, checkSourceElement); for (var _i = 0, _a = getConstructorsForTypeArguments(staticBaseType, baseTypeNode.typeArguments); _i < _a.length; _i++) { @@ -25227,6 +25230,8 @@ var ts; case 209 /* VariableDeclaration */: case 210 /* VariableDeclarationList */: case 212 /* ClassDeclaration */: + case 241 /* HeritageClause */: + case 186 /* ExpressionWithTypeArguments */: case 215 /* EnumDeclaration */: case 245 /* EnumMember */: case 225 /* ExportAssignment */: @@ -36231,6 +36236,12 @@ var ts; description: ts.Diagnostics.Specifies_the_location_where_debugger_should_locate_TypeScript_files_instead_of_source_locations, paramType: ts.Diagnostics.LOCATION }, + { + name: "suppressExcessPropertyErrors", + type: "boolean", + description: ts.Diagnostics.Suppress_excess_property_checks_for_object_literals, + experimental: true + }, { name: "suppressImplicitAnyIndexErrors", type: "boolean", From f1dbf904a773f7133a7db3a1d13d4a940d033b8e Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Thu, 27 Aug 2015 16:52:49 -0700 Subject: [PATCH 040/117] Toss the System out --- src/compiler/commandLineParser.ts | 4 ++-- src/compiler/tsc.ts | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/compiler/commandLineParser.ts b/src/compiler/commandLineParser.ts index 6696045be94..938777b42d2 100644 --- a/src/compiler/commandLineParser.ts +++ b/src/compiler/commandLineParser.ts @@ -374,10 +374,10 @@ namespace ts { * Read tsconfig.json file * @param fileName The path to the config file */ - export function readConfigFile(fileName: string, system: System): { config?: any; error?: Diagnostic } { + export function readConfigFile(fileName: string, readFile: (path: string) => string): { config?: any; error?: Diagnostic } { let text = ""; try { - text = system.readFile(fileName); + text = readFile(fileName); } catch (e) { return { error: createCompilerDiagnostic(Diagnostics.Cannot_read_file_0_Colon_1, fileName, e.message) }; diff --git a/src/compiler/tsc.ts b/src/compiler/tsc.ts index 1c883eb37dd..96759b68250 100644 --- a/src/compiler/tsc.ts +++ b/src/compiler/tsc.ts @@ -216,7 +216,7 @@ namespace ts { if (!cachedProgram) { if (configFileName) { - let result = readConfigFile(configFileName, sys); + let result = readConfigFile(configFileName, sys.readFile); if (result.error) { reportDiagnostic(result.error); return sys.exit(ExitStatus.DiagnosticsPresent_OutputsSkipped); From 8df7cbb515a67c091d07f4c741e45901a75cc7a4 Mon Sep 17 00:00:00 2001 From: Vladimir Matveev Date: Thu, 27 Aug 2015 15:27:12 -0700 Subject: [PATCH 041/117] pass IO when getting default library instead of reading it to prevent memory leaks, do not count errors in library files twice --- src/harness/harness.ts | 21 ++++++++++++++------- src/harness/rwcRunner.ts | 16 ++++------------ 2 files changed, 18 insertions(+), 19 deletions(-) diff --git a/src/harness/harness.ts b/src/harness/harness.ts index 78546f81c73..10a87108d43 100644 --- a/src/harness/harness.ts +++ b/src/harness/harness.ts @@ -1340,8 +1340,8 @@ module Harness { export function getErrorBaseline(inputFiles: { unitName: string; content: string }[], diagnostics: ts.Diagnostic[]) { diagnostics.sort(ts.compareDiagnostics); let outputLines: string[] = []; - // Count up all the errors we find so we don't miss any - let totalErrorsReported = 0; + // Count up all errors that were found in files other than lib.d.ts so we don't miss any + let totalErrorsReportedInNonLibraryFiles = 0; function outputErrorText(error: ts.Diagnostic) { let message = ts.flattenDiagnosticMessageText(error.messageText, Harness.IO.newLine()); @@ -1352,8 +1352,15 @@ module Harness { .filter(s => s.length > 0) .map(s => "!!! " + ts.DiagnosticCategory[error.category].toLowerCase() + " TS" + error.code + ": " + s); errLines.forEach(e => outputLines.push(e)); - - totalErrorsReported++; + + // do not count errors from lib.d.ts here, they are computed separately as numLibraryDiagnostics + // if lib.d.ts is explicitly included in input files and there are some errors in it (i.e. because of duplicate identifiers) + // then they will be added twice thus triggering 'total errors' assertion with condition + // 'totalErrorsReportedInNonLibraryFiles + numLibraryDiagnostics + numTest262HarnessDiagnostics, diagnostics.length + + if (!error.file || !isLibraryFile(error.file.fileName)) { + totalErrorsReportedInNonLibraryFiles++; + } } // Report global errors @@ -1438,7 +1445,7 @@ module Harness { }); // Verify we didn't miss any errors in total - assert.equal(totalErrorsReported + numLibraryDiagnostics + numTest262HarnessDiagnostics, diagnostics.length, "total number of errors"); + assert.equal(totalErrorsReportedInNonLibraryFiles + numLibraryDiagnostics + numTest262HarnessDiagnostics, diagnostics.length, "total number of errors"); return minimalDiagnosticsToString(diagnostics) + Harness.IO.newLine() + Harness.IO.newLine() + outputLines.join("\r\n"); @@ -1816,11 +1823,11 @@ module Harness { return filePath.indexOf(Harness.libFolder) === 0; } - export function getDefaultLibraryFile(): { unitName: string, content: string } { + export function getDefaultLibraryFile(io: Harness.IO): { unitName: string, content: string } { let libFile = Harness.userSpecifiedRoot + Harness.libFolder + "lib.d.ts"; return { unitName: libFile, - content: IO.readFile(libFile) + content: io.readFile(libFile) }; } diff --git a/src/harness/rwcRunner.ts b/src/harness/rwcRunner.ts index c89a8b1d910..a1aaeed3d55 100644 --- a/src/harness/rwcRunner.ts +++ b/src/harness/rwcRunner.ts @@ -4,7 +4,7 @@ /// module RWC { - function runWithIOLog(ioLog: IOLog, fn: () => void) { + function runWithIOLog(ioLog: IOLog, fn: (oldIO: Harness.IO) => void) { let oldIO = Harness.IO; let wrappedIO = Playback.wrapIO(oldIO); @@ -12,7 +12,7 @@ module RWC { Harness.IO = wrappedIO; try { - fn(); + fn(oldIO); } finally { wrappedIO.endReplay(); Harness.IO = oldIO; @@ -32,9 +32,6 @@ module RWC { let baseName = /(.*)\/(.*).json/.exec(ts.normalizeSlashes(jsonPath))[2]; let currentDirectory: string; let useCustomLibraryFile: boolean; - - const defaultLibraryFile = Harness.getDefaultLibraryFile(); - after(() => { // Mocha holds onto the closure environment of the describe callback even after the test is done. // Therefore we have to clean out large objects after the test is done. @@ -67,7 +64,7 @@ module RWC { opts.options.noEmitOnError = false; }); - runWithIOLog(ioLog, () => { + runWithIOLog(ioLog, oldIO => { harnessCompiler.reset(); // Load the files @@ -77,7 +74,6 @@ module RWC { // Add files to compilation let isInInputList = (resolvedPath: string) => (inputFile: { unitName: string; content: string; }) => inputFile.unitName === resolvedPath; - let prependDefaultLib = false; for (let fileRead of ioLog.filesRead) { // Check if the file is already added into the set of input files. const resolvedPath = ts.normalizeSlashes(Harness.IO.resolvePath(fileRead.path)); @@ -101,15 +97,11 @@ module RWC { } else { // set the flag to put default library to the beginning of the list - prependDefaultLib = true; + inputFiles.unshift(Harness.getDefaultLibraryFile(oldIO)); } } } } - - if (prependDefaultLib) { - inputFiles.unshift(defaultLibraryFile); - } // do not use lib since we already read it in above opts.options.noLib = true; From 6b476b2b5f51fdd49b13cddf145afa5ae24e8515 Mon Sep 17 00:00:00 2001 From: Ryan Cavanaugh Date: Wed, 26 Aug 2015 15:28:21 -0700 Subject: [PATCH 042/117] CR feedback --- tests/baselines/reference/tsxReactEmit5.js | 29 +++++++++++++++ .../baselines/reference/tsxReactEmit5.symbols | 35 ++++++++++++++++++ tests/baselines/reference/tsxReactEmit5.types | 37 +++++++++++++++++++ tests/cases/conformance/jsx/tsxReactEmit5.tsx | 20 ++++++++++ 4 files changed, 121 insertions(+) create mode 100644 tests/baselines/reference/tsxReactEmit5.js create mode 100644 tests/baselines/reference/tsxReactEmit5.symbols create mode 100644 tests/baselines/reference/tsxReactEmit5.types create mode 100644 tests/cases/conformance/jsx/tsxReactEmit5.tsx diff --git a/tests/baselines/reference/tsxReactEmit5.js b/tests/baselines/reference/tsxReactEmit5.js new file mode 100644 index 00000000000..f6a7eeb72a1 --- /dev/null +++ b/tests/baselines/reference/tsxReactEmit5.js @@ -0,0 +1,29 @@ +//// [tests/cases/conformance/jsx/tsxReactEmit5.tsx] //// + +//// [file.tsx] + +declare module JSX { + interface Element { } + interface IntrinsicElements { + [s: string]: any; + } +} + +//// [test.d.ts] +export var React; + +//// [react-consumer.tsx] +import {React} from "./test"; +// Should emit test_1.React.createElement +// and React.__spread +var foo; +var spread1 =
; + + +//// [file.js] +//// [react-consumer.js] +var test_1 = require("./test"); +// Should emit test_1.React.createElement +// and React.__spread +var foo; +var spread1 = test_1.React.createElement("div", test_1.React.__spread({x: ''}, foo, {y: ''})); diff --git a/tests/baselines/reference/tsxReactEmit5.symbols b/tests/baselines/reference/tsxReactEmit5.symbols new file mode 100644 index 00000000000..388e717957f --- /dev/null +++ b/tests/baselines/reference/tsxReactEmit5.symbols @@ -0,0 +1,35 @@ +=== tests/cases/conformance/jsx/file.tsx === + +declare module JSX { +>JSX : Symbol(JSX, Decl(file.tsx, 0, 0)) + + interface Element { } +>Element : Symbol(Element, Decl(file.tsx, 1, 20)) + + interface IntrinsicElements { +>IntrinsicElements : Symbol(IntrinsicElements, Decl(file.tsx, 2, 22)) + + [s: string]: any; +>s : Symbol(s, Decl(file.tsx, 4, 3)) + } +} + +=== tests/cases/conformance/jsx/test.d.ts === +export var React; +>React : Symbol(React, Decl(test.d.ts, 0, 10)) + +=== tests/cases/conformance/jsx/react-consumer.tsx === +import {React} from "./test"; +>React : Symbol(React, Decl(react-consumer.tsx, 0, 8)) + +// Should emit test_1.React.createElement +// and React.__spread +var foo; +>foo : Symbol(foo, Decl(react-consumer.tsx, 3, 3)) + +var spread1 =
; +>spread1 : Symbol(spread1, Decl(react-consumer.tsx, 4, 3)) +>div : Symbol(JSX.IntrinsicElements, Decl(file.tsx, 2, 22)) +>x : Symbol(unknown) +>y : Symbol(unknown) + diff --git a/tests/baselines/reference/tsxReactEmit5.types b/tests/baselines/reference/tsxReactEmit5.types new file mode 100644 index 00000000000..fb1c6594f30 --- /dev/null +++ b/tests/baselines/reference/tsxReactEmit5.types @@ -0,0 +1,37 @@ +=== tests/cases/conformance/jsx/file.tsx === + +declare module JSX { +>JSX : any + + interface Element { } +>Element : Element + + interface IntrinsicElements { +>IntrinsicElements : IntrinsicElements + + [s: string]: any; +>s : string + } +} + +=== tests/cases/conformance/jsx/test.d.ts === +export var React; +>React : any + +=== tests/cases/conformance/jsx/react-consumer.tsx === +import {React} from "./test"; +>React : any + +// Should emit test_1.React.createElement +// and React.__spread +var foo; +>foo : any + +var spread1 =
; +>spread1 : JSX.Element +>
: JSX.Element +>div : any +>x : any +>foo : any +>y : any + diff --git a/tests/cases/conformance/jsx/tsxReactEmit5.tsx b/tests/cases/conformance/jsx/tsxReactEmit5.tsx new file mode 100644 index 00000000000..c961a23ecfc --- /dev/null +++ b/tests/cases/conformance/jsx/tsxReactEmit5.tsx @@ -0,0 +1,20 @@ +//@jsx: react +//@module: commonjs + +//@filename: file.tsx +declare module JSX { + interface Element { } + interface IntrinsicElements { + [s: string]: any; + } +} + +//@filename: test.d.ts +export var React; + +//@filename: react-consumer.tsx +import {React} from "./test"; +// Should emit test_1.React.createElement +// and React.__spread +var foo; +var spread1 =
; From 90aff0c654b9c57c664099acb7849810b93f2198 Mon Sep 17 00:00:00 2001 From: Ryan Cavanaugh Date: Wed, 26 Aug 2015 16:12:50 -0700 Subject: [PATCH 043/117] Use synthetic identifier during emit instead --- src/compiler/emitter.ts | 10 ++++- tests/baselines/reference/tsxReactEmit6.js | 36 ++++++++++++++++ .../baselines/reference/tsxReactEmit6.symbols | 39 ++++++++++++++++++ tests/baselines/reference/tsxReactEmit6.types | 41 +++++++++++++++++++ tests/cases/conformance/jsx/tsxReactEmit6.tsx | 22 ++++++++++ 5 files changed, 146 insertions(+), 2 deletions(-) create mode 100644 tests/baselines/reference/tsxReactEmit6.js create mode 100644 tests/baselines/reference/tsxReactEmit6.symbols create mode 100644 tests/baselines/reference/tsxReactEmit6.types create mode 100644 tests/cases/conformance/jsx/tsxReactEmit6.tsx diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index cdaa57aa981..eeaab6d2123 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -1177,9 +1177,14 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi } function emitJsxElement(openingNode: JsxOpeningLikeElement, children?: JsxChild[]) { + let syntheticReactRef = createSynthesizedNode(SyntaxKind.Identifier); + syntheticReactRef.text = 'React'; + syntheticReactRef.parent = openingNode; + // Call React.createElement(tag, ... emitLeadingComments(openingNode); - write("React.createElement("); + emitExpressionIdentifier(syntheticReactRef); + write(".createElement("); emitTagName(openingNode.tagName); write(", "); @@ -1193,7 +1198,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi // a call to React.__spread let attrs = openingNode.attributes; if (forEach(attrs, attr => attr.kind === SyntaxKind.JsxSpreadAttribute)) { - write("React.__spread("); + emitExpressionIdentifier(syntheticReactRef); + write(".__spread("); let haveOpenedObjectLiteral = false; for (let i = 0; i < attrs.length; i++) { diff --git a/tests/baselines/reference/tsxReactEmit6.js b/tests/baselines/reference/tsxReactEmit6.js new file mode 100644 index 00000000000..d20ef7051e0 --- /dev/null +++ b/tests/baselines/reference/tsxReactEmit6.js @@ -0,0 +1,36 @@ +//// [tests/cases/conformance/jsx/tsxReactEmit6.tsx] //// + +//// [file.tsx] + +declare module JSX { + interface Element { } + interface IntrinsicElements { + [s: string]: any; + } +} + +//// [react-consumer.tsx] +namespace M { + export var React: any; +} + +namespace M { + // Should emit M.React.createElement + // and M.React.__spread + var foo; + var spread1 =
; +} + + +//// [file.js] +//// [react-consumer.js] +var M; +(function (M) { +})(M || (M = {})); +var M; +(function (M) { + // Should emit M.React.createElement + // and M.React.__spread + var foo; + var spread1 = M.React.createElement("div", M.React.__spread({x: ''}, foo, {y: ''})); +})(M || (M = {})); diff --git a/tests/baselines/reference/tsxReactEmit6.symbols b/tests/baselines/reference/tsxReactEmit6.symbols new file mode 100644 index 00000000000..0302cef3e8d --- /dev/null +++ b/tests/baselines/reference/tsxReactEmit6.symbols @@ -0,0 +1,39 @@ +=== tests/cases/conformance/jsx/file.tsx === + +declare module JSX { +>JSX : Symbol(JSX, Decl(file.tsx, 0, 0)) + + interface Element { } +>Element : Symbol(Element, Decl(file.tsx, 1, 20)) + + interface IntrinsicElements { +>IntrinsicElements : Symbol(IntrinsicElements, Decl(file.tsx, 2, 22)) + + [s: string]: any; +>s : Symbol(s, Decl(file.tsx, 4, 3)) + } +} + +=== tests/cases/conformance/jsx/react-consumer.tsx === +namespace M { +>M : Symbol(M, Decl(react-consumer.tsx, 0, 0), Decl(react-consumer.tsx, 2, 1)) + + export var React: any; +>React : Symbol(React, Decl(react-consumer.tsx, 1, 11)) +} + +namespace M { +>M : Symbol(M, Decl(react-consumer.tsx, 0, 0), Decl(react-consumer.tsx, 2, 1)) + + // Should emit M.React.createElement + // and M.React.__spread + var foo; +>foo : Symbol(foo, Decl(react-consumer.tsx, 7, 4)) + + var spread1 =
; +>spread1 : Symbol(spread1, Decl(react-consumer.tsx, 8, 4)) +>div : Symbol(JSX.IntrinsicElements, Decl(file.tsx, 2, 22)) +>x : Symbol(unknown) +>y : Symbol(unknown) +} + diff --git a/tests/baselines/reference/tsxReactEmit6.types b/tests/baselines/reference/tsxReactEmit6.types new file mode 100644 index 00000000000..1b16b84fcc7 --- /dev/null +++ b/tests/baselines/reference/tsxReactEmit6.types @@ -0,0 +1,41 @@ +=== tests/cases/conformance/jsx/file.tsx === + +declare module JSX { +>JSX : any + + interface Element { } +>Element : Element + + interface IntrinsicElements { +>IntrinsicElements : IntrinsicElements + + [s: string]: any; +>s : string + } +} + +=== tests/cases/conformance/jsx/react-consumer.tsx === +namespace M { +>M : typeof M + + export var React: any; +>React : any +} + +namespace M { +>M : typeof M + + // Should emit M.React.createElement + // and M.React.__spread + var foo; +>foo : any + + var spread1 =
; +>spread1 : JSX.Element +>
: JSX.Element +>div : any +>x : any +>foo : any +>y : any +} + diff --git a/tests/cases/conformance/jsx/tsxReactEmit6.tsx b/tests/cases/conformance/jsx/tsxReactEmit6.tsx new file mode 100644 index 00000000000..2782f90e503 --- /dev/null +++ b/tests/cases/conformance/jsx/tsxReactEmit6.tsx @@ -0,0 +1,22 @@ +//@jsx: react +//@module: commonjs + +//@filename: file.tsx +declare module JSX { + interface Element { } + interface IntrinsicElements { + [s: string]: any; + } +} + +//@filename: react-consumer.tsx +namespace M { + export var React: any; +} + +namespace M { + // Should emit M.React.createElement + // and M.React.__spread + var foo; + var spread1 =
; +} From 1ea378859c2ac04d40974d838fd37f125490a007 Mon Sep 17 00:00:00 2001 From: Ron Buckton Date: Fri, 28 Aug 2015 15:13:32 -0700 Subject: [PATCH 044/117] Fixes fallback checks that cause an exception during call resolution for an async function --- src/compiler/checker.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 35c12dedc37..8c6002af516 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -4036,7 +4036,7 @@ namespace ts { */ function createTypedPropertyDescriptorType(propertyType: Type): Type { let globalTypedPropertyDescriptorType = getGlobalTypedPropertyDescriptorType(); - return globalTypedPropertyDescriptorType !== emptyObjectType + return globalTypedPropertyDescriptorType !== emptyGenericType ? createTypeReference(globalTypedPropertyDescriptorType, [propertyType]) : emptyObjectType; } @@ -9176,7 +9176,7 @@ namespace ts { function createPromiseType(promisedType: Type): Type { // creates a `Promise` type where `T` is the promisedType argument let globalPromiseType = getGlobalPromiseType(); - if (globalPromiseType !== emptyObjectType) { + if (globalPromiseType !== emptyGenericType) { // if the promised type is itself a promise, get the underlying type; otherwise, fallback to the promised type promisedType = getAwaitedType(promisedType); return createTypeReference(globalPromiseType, [promisedType]); @@ -14633,7 +14633,7 @@ namespace ts { function createInstantiatedPromiseLikeType(): ObjectType { let promiseLikeType = getGlobalPromiseLikeType(); - if (promiseLikeType !== emptyObjectType) { + if (promiseLikeType !== emptyGenericType) { return createTypeReference(promiseLikeType, [anyType]); } From 0e52555d4ceab4090ad71762f75e13b512bdaa90 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Fri, 28 Aug 2015 14:50:58 -0700 Subject: [PATCH 045/117] Restoring union type subtype reduction --- src/compiler/checker.ts | 138 +++++++++++++--------------------------- 1 file changed, 44 insertions(+), 94 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 8c6002af516..936f8dcd397 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -3119,7 +3119,7 @@ namespace ts { } function resolveTupleTypeMembers(type: TupleType) { - let arrayType = resolveStructuredTypeMembers(createArrayType(getUnionType(type.elementTypes, /*noDeduplication*/ true))); + let arrayType = resolveStructuredTypeMembers(createArrayType(getUnionType(type.elementTypes, /*noSubtypeReduction*/ true))); let members = createTupleTypeMemberSymbols(type.elementTypes); addInheritedMembers(members, arrayType.properties); setObjectTypeMembers(type, members, arrayType.callSignatures, arrayType.constructSignatures, arrayType.stringIndexType, arrayType.numberIndexType); @@ -3451,29 +3451,6 @@ namespace ts { return undefined; } - // Check if a property with the given name is known anywhere in the given type. In an object - // type, a property is considered known if the object type is empty, if it has any index - // signatures, or if the property is actually declared in the type. In a union or intersection - // type, a property is considered known if it is known in any constituent type. - function isKnownProperty(type: Type, name: string): boolean { - if (type.flags & TypeFlags.ObjectType && type !== globalObjectType) { - const resolved = resolveStructuredTypeMembers(type); - return !!(resolved.properties.length === 0 || - resolved.stringIndexType || - resolved.numberIndexType || - getPropertyOfType(type, name)); - } - if (type.flags & TypeFlags.UnionOrIntersection) { - for (let t of (type).types) { - if (isKnownProperty(t, name)) { - return true; - } - } - return false; - } - return true; - } - function getSignaturesOfStructuredType(type: Type, kind: SignatureKind): Signature[] { if (type.flags & TypeFlags.StructuredType) { let resolved = resolveStructuredTypeMembers(type); @@ -4103,73 +4080,20 @@ namespace ts { } } - function isObjectLiteralTypeDuplicateOf(source: ObjectType, target: ObjectType): boolean { - let sourceProperties = getPropertiesOfObjectType(source); - let targetProperties = getPropertiesOfObjectType(target); - if (sourceProperties.length !== targetProperties.length) { - return false; - } - for (let sourceProp of sourceProperties) { - let targetProp = getPropertyOfObjectType(target, sourceProp.name); - if (!targetProp || - getDeclarationFlagsFromSymbol(targetProp) & (NodeFlags.Private | NodeFlags.Protected) || - !isTypeDuplicateOf(getTypeOfSymbol(sourceProp), getTypeOfSymbol(targetProp))) { - return false; - } - } - return true; - } - - function isTupleTypeDuplicateOf(source: TupleType, target: TupleType): boolean { - let sourceTypes = source.elementTypes; - let targetTypes = target.elementTypes; - if (sourceTypes.length !== targetTypes.length) { - return false; - } - for (var i = 0; i < sourceTypes.length; i++) { - if (!isTypeDuplicateOf(sourceTypes[i], targetTypes[i])) { - return false; - } - } - return true; - } - - // Returns true if the source type is a duplicate of the target type. A source type is a duplicate of - // a target type if the the two are identical, with the exception that the source type may have null or - // undefined in places where the target type doesn't. This is by design an asymmetric relationship. - function isTypeDuplicateOf(source: Type, target: Type): boolean { - if (source === target) { - return true; - } - if (source.flags & TypeFlags.Undefined || source.flags & TypeFlags.Null && !(target.flags & TypeFlags.Undefined)) { - return true; - } - if (source.flags & TypeFlags.ObjectLiteral && target.flags & TypeFlags.ObjectType) { - return isObjectLiteralTypeDuplicateOf(source, target); - } - if (isArrayType(source) && isArrayType(target)) { - return isTypeDuplicateOf((source).typeArguments[0], (target).typeArguments[0]); - } - if (isTupleType(source) && isTupleType(target)) { - return isTupleTypeDuplicateOf(source, target); - } - return isTypeIdenticalTo(source, target); - } - - function isTypeDuplicateOfSomeType(candidate: Type, types: Type[]): boolean { - for (let type of types) { - if (candidate !== type && isTypeDuplicateOf(candidate, type)) { + function isSubtypeOfAny(candidate: Type, types: Type[]): boolean { + for (var i = 0, len = types.length; i < len; i++) { + if (candidate !== types[i] && isTypeSubtypeOf(candidate, types[i])) { return true; } } return false; } - function removeDuplicateTypes(types: Type[]) { - let i = types.length; + function removeSubtypes(types: Type[]) { + var i = types.length; while (i > 0) { i--; - if (isTypeDuplicateOfSomeType(types[i], types)) { + if (isSubtypeOfAny(types[i], types)) { types.splice(i, 1); } } @@ -4194,12 +4118,14 @@ namespace ts { } } - // We always deduplicate the constituent type set based on object identity, but we'll also deduplicate - // based on the structure of the types unless the noDeduplication flag is true, which is the case when - // creating a union type from a type node and when instantiating a union type. In both of those cases, - // structural deduplication has to be deferred to properly support recursive union types. For example, - // a type of the form "type Item = string | (() => Item)" cannot be deduplicated during its declaration. - function getUnionType(types: Type[], noDeduplication?: boolean): Type { + // We reduce the constituent type set to only include types that aren't subtypes of other types, unless + // the noSubtypeReduction flag is specified, in which case we perform a simple deduplication based on + // object identity. Subtype reduction is possible only when union types are known not to circularly + // reference themselves (as is the case with union types created by expression constructs such as array + // literals and the || and ?: operators). Named types can circularly reference themselves and therefore + // cannot be deduplicated during their declaration. For example, "type Item = string | (() => Item" is + // a named type that circularly references itself. + function getUnionType(types: Type[], noSubtypeReduction?: boolean): Type { if (types.length === 0) { return emptyObjectType; } @@ -4208,12 +4134,12 @@ namespace ts { if (containsTypeAny(typeSet)) { return anyType; } - if (noDeduplication) { + if (noSubtypeReduction) { removeAllButLast(typeSet, undefinedType); removeAllButLast(typeSet, nullType); } else { - removeDuplicateTypes(typeSet); + removeSubtypes(typeSet); } if (typeSet.length === 1) { return typeSet[0]; @@ -4230,7 +4156,7 @@ namespace ts { function getTypeFromUnionTypeNode(node: UnionTypeNode): Type { let links = getNodeLinks(node); if (!links.resolvedType) { - links.resolvedType = getUnionType(map(node.types, getTypeFromTypeNode), /*noDeduplication*/ true); + links.resolvedType = getUnionType(map(node.types, getTypeFromTypeNode), /*noSubtypeReduction*/ true); } return links.resolvedType; } @@ -4526,7 +4452,7 @@ namespace ts { return createTupleType(instantiateList((type).elementTypes, mapper, instantiateType)); } if (type.flags & TypeFlags.Union) { - return getUnionType(instantiateList((type).types, mapper, instantiateType), /*noDeduplication*/ true); + return getUnionType(instantiateList((type).types, mapper, instantiateType), /*noSubtypeReduction*/ true); } if (type.flags & TypeFlags.Intersection) { return getIntersectionType(instantiateList((type).types, mapper, instantiateType)); @@ -4813,6 +4739,30 @@ namespace ts { return Ternary.False; } + // Check if a property with the given name is known anywhere in the given type. In an object type, a property + // is considered known if the object type is empty and the check is for assignability, if the object type has + // index signatures, or if the property is actually declared in the object type. In a union or intersection + // type, a property is considered known if it is known in any constituent type. + function isKnownProperty(type: Type, name: string): boolean { + if (type.flags & TypeFlags.ObjectType) { + const resolved = resolveStructuredTypeMembers(type); + if (relation === assignableRelation && (type === globalObjectType || resolved.properties.length === 0) || + resolved.stringIndexType || resolved.numberIndexType || getPropertyOfType(type, name)) { + return true; + } + return false; + } + if (type.flags & TypeFlags.UnionOrIntersection) { + for (let t of (type).types) { + if (isKnownProperty(t, name)) { + return true; + } + } + return false; + } + return true; + } + function hasExcessProperties(source: FreshObjectLiteralType, target: Type, reportErrors: boolean): boolean { for (let prop of getPropertiesOfObjectType(source)) { if (!isKnownProperty(target, prop.name)) { @@ -5594,7 +5544,7 @@ namespace ts { return getWidenedTypeOfObjectLiteral(type); } if (type.flags & TypeFlags.Union) { - return getUnionType(map((type).types, getWidenedType)); + return getUnionType(map((type).types, getWidenedType), /*noSubtypeReduction*/ true); } if (isArrayType(type)) { return createArrayType(getWidenedType((type).typeArguments[0])); From d63a4f164333b8eca97a7023e0166702dbabac3b Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Fri, 28 Aug 2015 15:59:37 -0700 Subject: [PATCH 046/117] Fixing fourslash tests --- .../cases/fourslash/bestCommonTypeObjectLiterals1.ts | 2 +- .../fourslash/completionEntryForUnionProperty2.ts | 6 +++--- .../fourslash/contextualTypingOfArrayLiterals1.ts | 12 ++---------- 3 files changed, 6 insertions(+), 14 deletions(-) diff --git a/tests/cases/fourslash/bestCommonTypeObjectLiterals1.ts b/tests/cases/fourslash/bestCommonTypeObjectLiterals1.ts index d7ccbe73f33..5a8f661789c 100644 --- a/tests/cases/fourslash/bestCommonTypeObjectLiterals1.ts +++ b/tests/cases/fourslash/bestCommonTypeObjectLiterals1.ts @@ -24,7 +24,7 @@ goTo.marker('1'); verify.quickInfoIs('var c: {\n name: string;\n age: number;\n}[]'); goTo.marker('2'); -verify.quickInfoIs('var c1: ({\n name: string;\n age: number;\n} | {\n name: string;\n age: number;\n dob: Date;\n})[]'); +verify.quickInfoIs('var c1: {\n name: string;\n age: number;\n}[]'); goTo.marker('3'); verify.quickInfoIs('var c2: ({\n\ diff --git a/tests/cases/fourslash/completionEntryForUnionProperty2.ts b/tests/cases/fourslash/completionEntryForUnionProperty2.ts index aa5bc40b5e3..c2d7bc406a5 100644 --- a/tests/cases/fourslash/completionEntryForUnionProperty2.ts +++ b/tests/cases/fourslash/completionEntryForUnionProperty2.ts @@ -1,12 +1,12 @@ /// ////interface One { -//// commonProperty: number; +//// commonProperty: string; //// commonFunction(): number; ////} //// ////interface Two { -//// commonProperty: string +//// commonProperty: number; //// commonFunction(): number; ////} //// @@ -16,5 +16,5 @@ goTo.marker(); verify.memberListContains("toString", "(method) toString(): string"); -verify.memberListContains("valueOf", "(method) valueOf(): number | string"); +verify.memberListContains("valueOf", "(method) valueOf(): string | number"); verify.memberListCount(2); \ No newline at end of file diff --git a/tests/cases/fourslash/contextualTypingOfArrayLiterals1.ts b/tests/cases/fourslash/contextualTypingOfArrayLiterals1.ts index fb77ecdce65..dbd7aeb5f01 100644 --- a/tests/cases/fourslash/contextualTypingOfArrayLiterals1.ts +++ b/tests/cases/fourslash/contextualTypingOfArrayLiterals1.ts @@ -43,21 +43,13 @@ goTo.marker('4'); verify.quickInfoIs('var r4: C'); goTo.marker('5'); -verify.quickInfoIs('var x5: ({\n\ +verify.quickInfoIs('var x5: {\n\ name: string;\n\ age: number;\n\ -} | {\n\ - name: string;\n\ - age: number;\n\ - dob: Date;\n\ -})[]'); +}[]'); goTo.marker('6'); verify.quickInfoIs('var r5: {\n\ name: string;\n\ age: number;\n\ -} | {\n\ - name: string;\n\ - age: number;\n\ - dob: Date;\n\ }'); From 2ee80f1f106586dbf5ce3c5bde5db14df4be7b87 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Fri, 28 Aug 2015 16:00:14 -0700 Subject: [PATCH 047/117] Accepting new baselines --- .../reference/arrayBestCommonTypes.types | 44 +++---- ...ayLiteralWithMultipleBestCommonTypes.types | 8 +- .../arrayLiteralsWithRecursiveGenerics.types | 4 +- .../arrayOfFunctionTypes3.errors.txt | 35 ------ .../reference/arrayOfFunctionTypes3.symbols | 93 ++++++++++++++ .../reference/arrayOfFunctionTypes3.types | 116 ++++++++++++++++++ ...stCommonTypeOfConditionalExpressions.types | 18 +-- ...bestCommonTypeWithOptionalProperties.types | 24 ++-- .../conditionalOperatorWithIdenticalBCT.types | 32 ++--- .../contextualTypingArrayOfLambdas.types | 4 +- ...orStatementsMultipleInvalidDecl.errors.txt | 4 +- .../reference/functionImplementations.types | 4 +- .../reference/generatedContextualTyping.types | 32 ++--- .../heterogeneousArrayLiterals.types | 88 ++++++------- ...lidMultipleVariableDeclarations.errors.txt | 4 +- .../logicalOrOperatorWithEveryType.types | 8 +- .../logicalOrOperatorWithTypeParameters.types | 4 +- ...ConstrainsPropertyDeclarations2.errors.txt | 8 +- .../objectLiteralIndexerErrors.errors.txt | 4 +- .../reference/objectLiteralIndexers.types | 2 +- .../parenthesizedContexualTyping1.types | 18 +-- .../parenthesizedContexualTyping2.types | 18 +-- ...rConstrainsPropertyDeclarations.errors.txt | 8 +- ...ConstrainsPropertyDeclarations2.errors.txt | 14 +-- .../subtypingWithCallSignatures2.types | 112 ++++++++--------- .../subtypingWithCallSignatures3.types | 56 ++++----- .../subtypingWithCallSignatures4.types | 32 ++--- .../subtypingWithConstructSignatures2.types | 104 ++++++++-------- .../subtypingWithConstructSignatures3.types | 56 ++++----- .../subtypingWithConstructSignatures4.types | 32 ++--- ...ubtypingWithObjectMembersOptionality.types | 8 +- tests/baselines/reference/symbolType11.types | 2 +- .../typeGuardsInConditionalExpression.types | 4 +- .../reference/typeGuardsInIfStatement.types | 12 +- ...GuardsInRightOperandOfAndAndOperator.types | 8 +- ...peGuardsInRightOperandOfOrOrOperator.types | 8 +- .../baselines/reference/underscoreTest1.types | 4 +- .../reference/unionTypeFromArrayLiteral.types | 8 +- .../reference/unionTypeReduction.types | 6 +- ...onTypeWithRecursiveSubtypeReduction1.types | 4 +- 40 files changed, 611 insertions(+), 439 deletions(-) delete mode 100644 tests/baselines/reference/arrayOfFunctionTypes3.errors.txt create mode 100644 tests/baselines/reference/arrayOfFunctionTypes3.symbols create mode 100644 tests/baselines/reference/arrayOfFunctionTypes3.types diff --git a/tests/baselines/reference/arrayBestCommonTypes.types b/tests/baselines/reference/arrayBestCommonTypes.types index 9b05aff5ac6..20f36e5c459 100644 --- a/tests/baselines/reference/arrayBestCommonTypes.types +++ b/tests/baselines/reference/arrayBestCommonTypes.types @@ -294,8 +294,8 @@ module EmptyTypes { // Order matters here so test all the variants var a1 = [{ x: 0, y: 'a' }, { x: 'a', y: 'a' }, { x: anyObj, y: 'a' }]; ->a1 : ({ x: number; y: string; } | { x: string; y: string; } | { x: any; y: string; })[] ->[{ x: 0, y: 'a' }, { x: 'a', y: 'a' }, { x: anyObj, y: 'a' }] : ({ x: number; y: string; } | { x: string; y: string; } | { x: any; y: string; })[] +>a1 : { x: any; y: string; }[] +>[{ x: 0, y: 'a' }, { x: 'a', y: 'a' }, { x: anyObj, y: 'a' }] : { x: any; y: string; }[] >{ x: 0, y: 'a' } : { x: number; y: string; } >x : number >0 : number @@ -313,8 +313,8 @@ module EmptyTypes { >'a' : string var a2 = [{ x: anyObj, y: 'a' }, { x: 0, y: 'a' }, { x: 'a', y: 'a' }]; ->a2 : ({ x: any; y: string; } | { x: number; y: string; } | { x: string; y: string; })[] ->[{ x: anyObj, y: 'a' }, { x: 0, y: 'a' }, { x: 'a', y: 'a' }] : ({ x: any; y: string; } | { x: number; y: string; } | { x: string; y: string; })[] +>a2 : { x: any; y: string; }[] +>[{ x: anyObj, y: 'a' }, { x: 0, y: 'a' }, { x: 'a', y: 'a' }] : { x: any; y: string; }[] >{ x: anyObj, y: 'a' } : { x: any; y: string; } >x : any >anyObj : any @@ -332,8 +332,8 @@ module EmptyTypes { >'a' : string var a3 = [{ x: 0, y: 'a' }, { x: anyObj, y: 'a' }, { x: 'a', y: 'a' }]; ->a3 : ({ x: number; y: string; } | { x: any; y: string; } | { x: string; y: string; })[] ->[{ x: 0, y: 'a' }, { x: anyObj, y: 'a' }, { x: 'a', y: 'a' }] : ({ x: number; y: string; } | { x: any; y: string; } | { x: string; y: string; })[] +>a3 : { x: any; y: string; }[] +>[{ x: 0, y: 'a' }, { x: anyObj, y: 'a' }, { x: 'a', y: 'a' }] : { x: any; y: string; }[] >{ x: 0, y: 'a' } : { x: number; y: string; } >x : number >0 : number @@ -639,7 +639,7 @@ module NonEmptyTypes { >x : number >y : base >base : base ->[{ x: 7, y: new derived() }, { x: 5, y: new base() }] : ({ x: number; y: derived; } | { x: number; y: base; })[] +>[{ x: 7, y: new derived() }, { x: 5, y: new base() }] : { x: number; y: base; }[] >{ x: 7, y: new derived() } : { x: number; y: derived; } >x : number >7 : number @@ -658,7 +658,7 @@ module NonEmptyTypes { >x : boolean >y : base >base : base ->[{ x: true, y: new derived() }, { x: false, y: new base() }] : ({ x: boolean; y: derived; } | { x: boolean; y: base; })[] +>[{ x: true, y: new derived() }, { x: false, y: new base() }] : { x: boolean; y: base; }[] >{ x: true, y: new derived() } : { x: boolean; y: derived; } >x : boolean >true : boolean @@ -697,8 +697,8 @@ module NonEmptyTypes { // Order matters here so test all the variants var a1 = [{ x: 0, y: 'a' }, { x: 'a', y: 'a' }, { x: anyObj, y: 'a' }]; ->a1 : ({ x: number; y: string; } | { x: string; y: string; } | { x: any; y: string; })[] ->[{ x: 0, y: 'a' }, { x: 'a', y: 'a' }, { x: anyObj, y: 'a' }] : ({ x: number; y: string; } | { x: string; y: string; } | { x: any; y: string; })[] +>a1 : { x: any; y: string; }[] +>[{ x: 0, y: 'a' }, { x: 'a', y: 'a' }, { x: anyObj, y: 'a' }] : { x: any; y: string; }[] >{ x: 0, y: 'a' } : { x: number; y: string; } >x : number >0 : number @@ -716,8 +716,8 @@ module NonEmptyTypes { >'a' : string var a2 = [{ x: anyObj, y: 'a' }, { x: 0, y: 'a' }, { x: 'a', y: 'a' }]; ->a2 : ({ x: any; y: string; } | { x: number; y: string; } | { x: string; y: string; })[] ->[{ x: anyObj, y: 'a' }, { x: 0, y: 'a' }, { x: 'a', y: 'a' }] : ({ x: any; y: string; } | { x: number; y: string; } | { x: string; y: string; })[] +>a2 : { x: any; y: string; }[] +>[{ x: anyObj, y: 'a' }, { x: 0, y: 'a' }, { x: 'a', y: 'a' }] : { x: any; y: string; }[] >{ x: anyObj, y: 'a' } : { x: any; y: string; } >x : any >anyObj : any @@ -735,8 +735,8 @@ module NonEmptyTypes { >'a' : string var a3 = [{ x: 0, y: 'a' }, { x: anyObj, y: 'a' }, { x: 'a', y: 'a' }]; ->a3 : ({ x: number; y: string; } | { x: any; y: string; } | { x: string; y: string; })[] ->[{ x: 0, y: 'a' }, { x: anyObj, y: 'a' }, { x: 'a', y: 'a' }] : ({ x: number; y: string; } | { x: any; y: string; } | { x: string; y: string; })[] +>a3 : { x: any; y: string; }[] +>[{ x: 0, y: 'a' }, { x: anyObj, y: 'a' }, { x: 'a', y: 'a' }] : { x: any; y: string; }[] >{ x: 0, y: 'a' } : { x: number; y: string; } >x : number >0 : number @@ -769,29 +769,29 @@ module NonEmptyTypes { >base2 : typeof base2 var b1 = [baseObj, base2Obj, ifaceObj]; ->b1 : (base | base2 | iface)[] ->[baseObj, base2Obj, ifaceObj] : (base | base2 | iface)[] +>b1 : iface[] +>[baseObj, base2Obj, ifaceObj] : iface[] >baseObj : base >base2Obj : base2 >ifaceObj : iface var b2 = [base2Obj, baseObj, ifaceObj]; ->b2 : (base2 | base | iface)[] ->[base2Obj, baseObj, ifaceObj] : (base2 | base | iface)[] +>b2 : iface[] +>[base2Obj, baseObj, ifaceObj] : iface[] >base2Obj : base2 >baseObj : base >ifaceObj : iface var b3 = [baseObj, ifaceObj, base2Obj]; ->b3 : (base | iface | base2)[] ->[baseObj, ifaceObj, base2Obj] : (base | iface | base2)[] +>b3 : iface[] +>[baseObj, ifaceObj, base2Obj] : iface[] >baseObj : base >ifaceObj : iface >base2Obj : base2 var b4 = [ifaceObj, baseObj, base2Obj]; ->b4 : (iface | base | base2)[] ->[ifaceObj, baseObj, base2Obj] : (iface | base | base2)[] +>b4 : iface[] +>[ifaceObj, baseObj, base2Obj] : iface[] >ifaceObj : iface >baseObj : base >base2Obj : base2 diff --git a/tests/baselines/reference/arrayLiteralWithMultipleBestCommonTypes.types b/tests/baselines/reference/arrayLiteralWithMultipleBestCommonTypes.types index 5b5a1be6b8a..1bbb6c41e8a 100644 --- a/tests/baselines/reference/arrayLiteralWithMultipleBestCommonTypes.types +++ b/tests/baselines/reference/arrayLiteralWithMultipleBestCommonTypes.types @@ -36,8 +36,8 @@ var cs = [a, b, c]; // { x: number; y?: number };[] >c : { x: number; a?: number; } var ds = [(x: Object) => 1, (x: string) => 2]; // { (x:Object) => number }[] ->ds : (((x: Object) => number) | ((x: string) => number))[] ->[(x: Object) => 1, (x: string) => 2] : (((x: Object) => number) | ((x: string) => number))[] +>ds : ((x: Object) => number)[] +>[(x: Object) => 1, (x: string) => 2] : ((x: Object) => number)[] >(x: Object) => 1 : (x: Object) => number >x : Object >Object : Object @@ -47,8 +47,8 @@ var ds = [(x: Object) => 1, (x: string) => 2]; // { (x:Object) => number }[] >2 : number var es = [(x: string) => 2, (x: Object) => 1]; // { (x:string) => number }[] ->es : (((x: string) => number) | ((x: Object) => number))[] ->[(x: string) => 2, (x: Object) => 1] : (((x: string) => number) | ((x: Object) => number))[] +>es : ((x: string) => number)[] +>[(x: string) => 2, (x: Object) => 1] : ((x: string) => number)[] >(x: string) => 2 : (x: string) => number >x : string >2 : number diff --git a/tests/baselines/reference/arrayLiteralsWithRecursiveGenerics.types b/tests/baselines/reference/arrayLiteralsWithRecursiveGenerics.types index b7224fe91c4..9cdbe0a0a61 100644 --- a/tests/baselines/reference/arrayLiteralsWithRecursiveGenerics.types +++ b/tests/baselines/reference/arrayLiteralsWithRecursiveGenerics.types @@ -77,8 +77,8 @@ var myDerivedList: DerivedList; >DerivedList : DerivedList var as = [list, myDerivedList]; // List[] ->as : (List | DerivedList)[] ->[list, myDerivedList] : (List | DerivedList)[] +>as : List[] +>[list, myDerivedList] : List[] >list : List >myDerivedList : DerivedList diff --git a/tests/baselines/reference/arrayOfFunctionTypes3.errors.txt b/tests/baselines/reference/arrayOfFunctionTypes3.errors.txt deleted file mode 100644 index 499d6bca387..00000000000 --- a/tests/baselines/reference/arrayOfFunctionTypes3.errors.txt +++ /dev/null @@ -1,35 +0,0 @@ -tests/cases/conformance/types/specifyingTypes/typeLiterals/arrayOfFunctionTypes3.ts(17,13): error TS2345: Argument of type 'string' is not assignable to parameter of type 'number'. -tests/cases/conformance/types/specifyingTypes/typeLiterals/arrayOfFunctionTypes3.ts(26,10): error TS2349: Cannot invoke an expression whose type lacks a call signature. - - -==== tests/cases/conformance/types/specifyingTypes/typeLiterals/arrayOfFunctionTypes3.ts (2 errors) ==== - // valid uses of arrays of function types - - var x = [() => 1, () => { }]; - var r2 = x[0](); - - class C { - foo: string; - } - var y = [C, C]; - var r3 = new y[0](); - - var a: { (x: number): number; (x: string): string; }; - var b: { (x: number): number; (x: string): string; }; - var c: { (x: number): number; (x: any): any; }; - var z = [a, b, c]; - var r4 = z[0]; - var r5 = r4(''); // any not string - ~~ -!!! error TS2345: Argument of type 'string' is not assignable to parameter of type 'number'. - var r5b = r4(1); - - var a2: { (x: T): number; (x: string): string;}; - var b2: { (x: T): number; (x: string): string; }; - var c2: { (x: number): number; (x: T): any; }; - - var z2 = [a2, b2, c2]; - var r6 = z2[0]; - var r7 = r6(''); // any not string - ~~~~~~ -!!! error TS2349: Cannot invoke an expression whose type lacks a call signature. \ No newline at end of file diff --git a/tests/baselines/reference/arrayOfFunctionTypes3.symbols b/tests/baselines/reference/arrayOfFunctionTypes3.symbols new file mode 100644 index 00000000000..d26effeb5b7 --- /dev/null +++ b/tests/baselines/reference/arrayOfFunctionTypes3.symbols @@ -0,0 +1,93 @@ +=== tests/cases/conformance/types/specifyingTypes/typeLiterals/arrayOfFunctionTypes3.ts === +// valid uses of arrays of function types + +var x = [() => 1, () => { }]; +>x : Symbol(x, Decl(arrayOfFunctionTypes3.ts, 2, 3)) + +var r2 = x[0](); +>r2 : Symbol(r2, Decl(arrayOfFunctionTypes3.ts, 3, 3)) +>x : Symbol(x, Decl(arrayOfFunctionTypes3.ts, 2, 3)) + +class C { +>C : Symbol(C, Decl(arrayOfFunctionTypes3.ts, 3, 16)) + + foo: string; +>foo : Symbol(foo, Decl(arrayOfFunctionTypes3.ts, 5, 9)) +} +var y = [C, C]; +>y : Symbol(y, Decl(arrayOfFunctionTypes3.ts, 8, 3)) +>C : Symbol(C, Decl(arrayOfFunctionTypes3.ts, 3, 16)) +>C : Symbol(C, Decl(arrayOfFunctionTypes3.ts, 3, 16)) + +var r3 = new y[0](); +>r3 : Symbol(r3, Decl(arrayOfFunctionTypes3.ts, 9, 3)) +>y : Symbol(y, Decl(arrayOfFunctionTypes3.ts, 8, 3)) + +var a: { (x: number): number; (x: string): string; }; +>a : Symbol(a, Decl(arrayOfFunctionTypes3.ts, 11, 3)) +>x : Symbol(x, Decl(arrayOfFunctionTypes3.ts, 11, 10)) +>x : Symbol(x, Decl(arrayOfFunctionTypes3.ts, 11, 31)) + +var b: { (x: number): number; (x: string): string; }; +>b : Symbol(b, Decl(arrayOfFunctionTypes3.ts, 12, 3)) +>x : Symbol(x, Decl(arrayOfFunctionTypes3.ts, 12, 10)) +>x : Symbol(x, Decl(arrayOfFunctionTypes3.ts, 12, 31)) + +var c: { (x: number): number; (x: any): any; }; +>c : Symbol(c, Decl(arrayOfFunctionTypes3.ts, 13, 3)) +>x : Symbol(x, Decl(arrayOfFunctionTypes3.ts, 13, 10)) +>x : Symbol(x, Decl(arrayOfFunctionTypes3.ts, 13, 31)) + +var z = [a, b, c]; +>z : Symbol(z, Decl(arrayOfFunctionTypes3.ts, 14, 3)) +>a : Symbol(a, Decl(arrayOfFunctionTypes3.ts, 11, 3)) +>b : Symbol(b, Decl(arrayOfFunctionTypes3.ts, 12, 3)) +>c : Symbol(c, Decl(arrayOfFunctionTypes3.ts, 13, 3)) + +var r4 = z[0]; +>r4 : Symbol(r4, Decl(arrayOfFunctionTypes3.ts, 15, 3)) +>z : Symbol(z, Decl(arrayOfFunctionTypes3.ts, 14, 3)) + +var r5 = r4(''); // any not string +>r5 : Symbol(r5, Decl(arrayOfFunctionTypes3.ts, 16, 3)) +>r4 : Symbol(r4, Decl(arrayOfFunctionTypes3.ts, 15, 3)) + +var r5b = r4(1); +>r5b : Symbol(r5b, Decl(arrayOfFunctionTypes3.ts, 17, 3)) +>r4 : Symbol(r4, Decl(arrayOfFunctionTypes3.ts, 15, 3)) + +var a2: { (x: T): number; (x: string): string;}; +>a2 : Symbol(a2, Decl(arrayOfFunctionTypes3.ts, 19, 3)) +>T : Symbol(T, Decl(arrayOfFunctionTypes3.ts, 19, 11)) +>x : Symbol(x, Decl(arrayOfFunctionTypes3.ts, 19, 14)) +>T : Symbol(T, Decl(arrayOfFunctionTypes3.ts, 19, 11)) +>x : Symbol(x, Decl(arrayOfFunctionTypes3.ts, 19, 30)) + +var b2: { (x: T): number; (x: string): string; }; +>b2 : Symbol(b2, Decl(arrayOfFunctionTypes3.ts, 20, 3)) +>T : Symbol(T, Decl(arrayOfFunctionTypes3.ts, 20, 11)) +>x : Symbol(x, Decl(arrayOfFunctionTypes3.ts, 20, 14)) +>T : Symbol(T, Decl(arrayOfFunctionTypes3.ts, 20, 11)) +>x : Symbol(x, Decl(arrayOfFunctionTypes3.ts, 20, 30)) + +var c2: { (x: number): number; (x: T): any; }; +>c2 : Symbol(c2, Decl(arrayOfFunctionTypes3.ts, 21, 3)) +>x : Symbol(x, Decl(arrayOfFunctionTypes3.ts, 21, 11)) +>T : Symbol(T, Decl(arrayOfFunctionTypes3.ts, 21, 32)) +>x : Symbol(x, Decl(arrayOfFunctionTypes3.ts, 21, 35)) +>T : Symbol(T, Decl(arrayOfFunctionTypes3.ts, 21, 32)) + +var z2 = [a2, b2, c2]; +>z2 : Symbol(z2, Decl(arrayOfFunctionTypes3.ts, 23, 3)) +>a2 : Symbol(a2, Decl(arrayOfFunctionTypes3.ts, 19, 3)) +>b2 : Symbol(b2, Decl(arrayOfFunctionTypes3.ts, 20, 3)) +>c2 : Symbol(c2, Decl(arrayOfFunctionTypes3.ts, 21, 3)) + +var r6 = z2[0]; +>r6 : Symbol(r6, Decl(arrayOfFunctionTypes3.ts, 24, 3)) +>z2 : Symbol(z2, Decl(arrayOfFunctionTypes3.ts, 23, 3)) + +var r7 = r6(''); // any not string +>r7 : Symbol(r7, Decl(arrayOfFunctionTypes3.ts, 25, 3)) +>r6 : Symbol(r6, Decl(arrayOfFunctionTypes3.ts, 24, 3)) + diff --git a/tests/baselines/reference/arrayOfFunctionTypes3.types b/tests/baselines/reference/arrayOfFunctionTypes3.types new file mode 100644 index 00000000000..0ed92991ed0 --- /dev/null +++ b/tests/baselines/reference/arrayOfFunctionTypes3.types @@ -0,0 +1,116 @@ +=== tests/cases/conformance/types/specifyingTypes/typeLiterals/arrayOfFunctionTypes3.ts === +// valid uses of arrays of function types + +var x = [() => 1, () => { }]; +>x : (() => void)[] +>[() => 1, () => { }] : (() => void)[] +>() => 1 : () => number +>1 : number +>() => { } : () => void + +var r2 = x[0](); +>r2 : void +>x[0]() : void +>x[0] : () => void +>x : (() => void)[] +>0 : number + +class C { +>C : C + + foo: string; +>foo : string +} +var y = [C, C]; +>y : typeof C[] +>[C, C] : typeof C[] +>C : typeof C +>C : typeof C + +var r3 = new y[0](); +>r3 : C +>new y[0]() : C +>y[0] : typeof C +>y : typeof C[] +>0 : number + +var a: { (x: number): number; (x: string): string; }; +>a : { (x: number): number; (x: string): string; } +>x : number +>x : string + +var b: { (x: number): number; (x: string): string; }; +>b : { (x: number): number; (x: string): string; } +>x : number +>x : string + +var c: { (x: number): number; (x: any): any; }; +>c : { (x: number): number; (x: any): any; } +>x : number +>x : any + +var z = [a, b, c]; +>z : { (x: number): number; (x: any): any; }[] +>[a, b, c] : { (x: number): number; (x: any): any; }[] +>a : { (x: number): number; (x: string): string; } +>b : { (x: number): number; (x: string): string; } +>c : { (x: number): number; (x: any): any; } + +var r4 = z[0]; +>r4 : { (x: number): number; (x: any): any; } +>z[0] : { (x: number): number; (x: any): any; } +>z : { (x: number): number; (x: any): any; }[] +>0 : number + +var r5 = r4(''); // any not string +>r5 : any +>r4('') : any +>r4 : { (x: number): number; (x: any): any; } +>'' : string + +var r5b = r4(1); +>r5b : number +>r4(1) : number +>r4 : { (x: number): number; (x: any): any; } +>1 : number + +var a2: { (x: T): number; (x: string): string;}; +>a2 : { (x: T): number; (x: string): string; } +>T : T +>x : T +>T : T +>x : string + +var b2: { (x: T): number; (x: string): string; }; +>b2 : { (x: T): number; (x: string): string; } +>T : T +>x : T +>T : T +>x : string + +var c2: { (x: number): number; (x: T): any; }; +>c2 : { (x: number): number; (x: T): any; } +>x : number +>T : T +>x : T +>T : T + +var z2 = [a2, b2, c2]; +>z2 : { (x: number): number; (x: T): any; }[] +>[a2, b2, c2] : { (x: number): number; (x: T): any; }[] +>a2 : { (x: T): number; (x: string): string; } +>b2 : { (x: T): number; (x: string): string; } +>c2 : { (x: number): number; (x: T): any; } + +var r6 = z2[0]; +>r6 : { (x: number): number; (x: T): any; } +>z2[0] : { (x: number): number; (x: T): any; } +>z2 : { (x: number): number; (x: T): any; }[] +>0 : number + +var r7 = r6(''); // any not string +>r7 : any +>r6('') : any +>r6 : { (x: number): number; (x: T): any; } +>'' : string + diff --git a/tests/baselines/reference/bestCommonTypeOfConditionalExpressions.types b/tests/baselines/reference/bestCommonTypeOfConditionalExpressions.types index 933d46cc802..1191004a32b 100644 --- a/tests/baselines/reference/bestCommonTypeOfConditionalExpressions.types +++ b/tests/baselines/reference/bestCommonTypeOfConditionalExpressions.types @@ -46,8 +46,8 @@ var r = true ? 1 : 2; >2 : number var r3 = true ? 1 : {}; ->r3 : number | {} ->true ? 1 : {} : number | {} +>r3 : {} +>true ? 1 : {} : {} >true : boolean >1 : number >{} : {} @@ -67,8 +67,8 @@ var r5 = true ? b : a; // typeof b >a : { x: number; y?: number; } var r6 = true ? (x: number) => { } : (x: Object) => { }; // returns number => void ->r6 : ((x: number) => void) | ((x: Object) => void) ->true ? (x: number) => { } : (x: Object) => { } : ((x: number) => void) | ((x: Object) => void) +>r6 : (x: number) => void +>true ? (x: number) => { } : (x: Object) => { } : (x: number) => void >true : boolean >(x: number) => { } : (x: number) => void >x : number @@ -80,7 +80,7 @@ var r7: (x: Object) => void = true ? (x: number) => { } : (x: Object) => { }; >r7 : (x: Object) => void >x : Object >Object : Object ->true ? (x: number) => { } : (x: Object) => { } : ((x: number) => void) | ((x: Object) => void) +>true ? (x: number) => { } : (x: Object) => { } : (x: number) => void >true : boolean >(x: number) => { } : (x: number) => void >x : number @@ -89,8 +89,8 @@ var r7: (x: Object) => void = true ? (x: number) => { } : (x: Object) => { }; >Object : Object var r8 = true ? (x: Object) => { } : (x: number) => { }; // returns Object => void ->r8 : ((x: Object) => void) | ((x: number) => void) ->true ? (x: Object) => { } : (x: number) => { } : ((x: Object) => void) | ((x: number) => void) +>r8 : (x: Object) => void +>true ? (x: Object) => { } : (x: number) => { } : (x: Object) => void >true : boolean >(x: Object) => { } : (x: Object) => void >x : Object @@ -107,8 +107,8 @@ var r10: Base = true ? derived : derived2; // no error since we use the contextu >derived2 : Derived2 var r11 = true ? base : derived2; ->r11 : Base | Derived2 ->true ? base : derived2 : Base | Derived2 +>r11 : Base +>true ? base : derived2 : Base >true : boolean >base : Base >derived2 : Derived2 diff --git a/tests/baselines/reference/bestCommonTypeWithOptionalProperties.types b/tests/baselines/reference/bestCommonTypeWithOptionalProperties.types index 4c47753a90d..df40291b0e5 100644 --- a/tests/baselines/reference/bestCommonTypeWithOptionalProperties.types +++ b/tests/baselines/reference/bestCommonTypeWithOptionalProperties.types @@ -27,43 +27,43 @@ var z: Z; // All these arrays should be X[] var b1 = [x, y, z]; ->b1 : (X | Y | Z)[] ->[x, y, z] : (X | Y | Z)[] +>b1 : X[] +>[x, y, z] : X[] >x : X >y : Y >z : Z var b2 = [x, z, y]; ->b2 : (X | Z | Y)[] ->[x, z, y] : (X | Z | Y)[] +>b2 : X[] +>[x, z, y] : X[] >x : X >z : Z >y : Y var b3 = [y, x, z]; ->b3 : (Y | X | Z)[] ->[y, x, z] : (Y | X | Z)[] +>b3 : X[] +>[y, x, z] : X[] >y : Y >x : X >z : Z var b4 = [y, z, x]; ->b4 : (Y | Z | X)[] ->[y, z, x] : (Y | Z | X)[] +>b4 : X[] +>[y, z, x] : X[] >y : Y >z : Z >x : X var b5 = [z, x, y]; ->b5 : (Z | X | Y)[] ->[z, x, y] : (Z | X | Y)[] +>b5 : X[] +>[z, x, y] : X[] >z : Z >x : X >y : Y var b6 = [z, y, x]; ->b6 : (Z | Y | X)[] ->[z, y, x] : (Z | Y | X)[] +>b6 : X[] +>[z, y, x] : X[] >z : Z >y : Y >x : X diff --git a/tests/baselines/reference/conditionalOperatorWithIdenticalBCT.types b/tests/baselines/reference/conditionalOperatorWithIdenticalBCT.types index d5530f98fe8..026c8f42272 100644 --- a/tests/baselines/reference/conditionalOperatorWithIdenticalBCT.types +++ b/tests/baselines/reference/conditionalOperatorWithIdenticalBCT.types @@ -31,21 +31,21 @@ var b: B; //Cond ? Expr1 : Expr2, Expr1 is supertype //Be Not contextually typed true ? x : a; ->true ? x : a : X | A +>true ? x : a : X >true : boolean >x : X >a : A var result1 = true ? x : a; ->result1 : X | A ->true ? x : a : X | A +>result1 : X +>true ? x : a : X >true : boolean >x : X >a : A //Expr1 and Expr2 are literals true ? {} : 1; ->true ? {} : 1 : {} | number +>true ? {} : 1 : {} >true : boolean >{} : {} >1 : number @@ -63,8 +63,8 @@ true ? { a: 1 } : { a: 2, b: 'string' }; >'string' : string var result2 = true ? {} : 1; ->result2 : {} | number ->true ? {} : 1 : {} | number +>result2 : {} +>true ? {} : 1 : {} >true : boolean >{} : {} >1 : number @@ -86,7 +86,7 @@ var result3 = true ? { a: 1 } : { a: 2, b: 'string' }; var resultIsX1: X = true ? x : a; >resultIsX1 : X >X : X ->true ? x : a : X | A +>true ? x : a : X >true : boolean >x : X >a : A @@ -95,7 +95,7 @@ var result4: (t: A) => any = true ? (m) => m.propertyX : (n) => n.propertyA; >result4 : (t: A) => any >t : A >A : A ->true ? (m) => m.propertyX : (n) => n.propertyA : ((m: A) => any) | ((n: A) => number) +>true ? (m) => m.propertyX : (n) => n.propertyA : (m: A) => any >true : boolean >(m) => m.propertyX : (m: A) => any >m : A @@ -111,21 +111,21 @@ var result4: (t: A) => any = true ? (m) => m.propertyX : (n) => n.propertyA; //Cond ? Expr1 : Expr2, Expr2 is supertype //Be Not contextually typed true ? a : x; ->true ? a : x : A | X +>true ? a : x : X >true : boolean >a : A >x : X var result5 = true ? a : x; ->result5 : A | X ->true ? a : x : A | X +>result5 : X +>true ? a : x : X >true : boolean >a : A >x : X //Expr1 and Expr2 are literals true ? 1 : {}; ->true ? 1 : {} : number | {} +>true ? 1 : {} : {} >true : boolean >1 : number >{} : {} @@ -143,8 +143,8 @@ true ? { a: 2, b: 'string' } : { a: 1 }; >1 : number var result6 = true ? 1 : {}; ->result6 : number | {} ->true ? 1 : {} : number | {} +>result6 : {} +>true ? 1 : {} : {} >true : boolean >1 : number >{} : {} @@ -166,7 +166,7 @@ var result7 = true ? { a: 2, b: 'string' } : { a: 1 }; var resultIsX2: X = true ? x : a; >resultIsX2 : X >X : X ->true ? x : a : X | A +>true ? x : a : X >true : boolean >x : X >a : A @@ -175,7 +175,7 @@ var result8: (t: A) => any = true ? (m) => m.propertyA : (n) => n.propertyX; >result8 : (t: A) => any >t : A >A : A ->true ? (m) => m.propertyA : (n) => n.propertyX : ((m: A) => number) | ((n: A) => any) +>true ? (m) => m.propertyA : (n) => n.propertyX : (n: A) => any >true : boolean >(m) => m.propertyA : (m: A) => number >m : A diff --git a/tests/baselines/reference/contextualTypingArrayOfLambdas.types b/tests/baselines/reference/contextualTypingArrayOfLambdas.types index 0bb61604336..d3e5b9942e3 100644 --- a/tests/baselines/reference/contextualTypingArrayOfLambdas.types +++ b/tests/baselines/reference/contextualTypingArrayOfLambdas.types @@ -23,8 +23,8 @@ class C extends A { } var xs = [(x: A) => { }, (x: B) => { }, (x: C) => { }]; ->xs : (((x: A) => void) | ((x: B) => void) | ((x: C) => void))[] ->[(x: A) => { }, (x: B) => { }, (x: C) => { }] : (((x: A) => void) | ((x: B) => void) | ((x: C) => void))[] +>xs : ((x: A) => void)[] +>[(x: A) => { }, (x: B) => { }, (x: C) => { }] : ((x: A) => void)[] >(x: A) => { } : (x: A) => void >x : A >A : A diff --git a/tests/baselines/reference/forStatementsMultipleInvalidDecl.errors.txt b/tests/baselines/reference/forStatementsMultipleInvalidDecl.errors.txt index 098afe94b47..53ecb88363d 100644 --- a/tests/baselines/reference/forStatementsMultipleInvalidDecl.errors.txt +++ b/tests/baselines/reference/forStatementsMultipleInvalidDecl.errors.txt @@ -7,7 +7,7 @@ tests/cases/conformance/statements/forStatements/forStatementsMultipleInvalidDec tests/cases/conformance/statements/forStatements/forStatementsMultipleInvalidDecl.ts(40,10): error TS2403: Subsequent variable declarations must have the same type. Variable 'b' must be of type 'I', but here has type 'C2'. tests/cases/conformance/statements/forStatements/forStatementsMultipleInvalidDecl.ts(43,10): error TS2403: Subsequent variable declarations must have the same type. Variable 'f' must be of type '(x: string) => number', but here has type '(x: number) => string'. tests/cases/conformance/statements/forStatements/forStatementsMultipleInvalidDecl.ts(46,10): error TS2403: Subsequent variable declarations must have the same type. Variable 'arr' must be of type 'string[]', but here has type 'number[]'. -tests/cases/conformance/statements/forStatements/forStatementsMultipleInvalidDecl.ts(47,10): error TS2403: Subsequent variable declarations must have the same type. Variable 'arr' must be of type 'string[]', but here has type '(C | C2 | D)[]'. +tests/cases/conformance/statements/forStatements/forStatementsMultipleInvalidDecl.ts(47,10): error TS2403: Subsequent variable declarations must have the same type. Variable 'arr' must be of type 'string[]', but here has type '(C | D)[]'. tests/cases/conformance/statements/forStatements/forStatementsMultipleInvalidDecl.ts(50,10): error TS2403: Subsequent variable declarations must have the same type. Variable 'arr2' must be of type 'D[]', but here has type 'D[]'. tests/cases/conformance/statements/forStatements/forStatementsMultipleInvalidDecl.ts(53,10): error TS2403: Subsequent variable declarations must have the same type. Variable 'm' must be of type 'typeof M', but here has type 'typeof A'. @@ -79,7 +79,7 @@ tests/cases/conformance/statements/forStatements/forStatementsMultipleInvalidDec !!! error TS2403: Subsequent variable declarations must have the same type. Variable 'arr' must be of type 'string[]', but here has type 'number[]'. for( var arr = [new C(), new C2(), new D()];;){} ~~~ -!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'arr' must be of type 'string[]', but here has type '(C | C2 | D)[]'. +!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'arr' must be of type 'string[]', but here has type '(C | D)[]'. for(var arr2 = [new D()];;){} for( var arr2 = new Array>();;){} diff --git a/tests/baselines/reference/functionImplementations.types b/tests/baselines/reference/functionImplementations.types index 4facd65bda7..1398e2974f0 100644 --- a/tests/baselines/reference/functionImplementations.types +++ b/tests/baselines/reference/functionImplementations.types @@ -342,7 +342,7 @@ var f7: (x: number) => string | number = x => { // should be (x: number) => numb var f8: (x: number) => any = x => { // should be (x: number) => Base >f8 : (x: number) => any >x : number ->x => { // should be (x: number) => Base return new Base(); return new Derived2();} : (x: number) => Base | Derived2 +>x => { // should be (x: number) => Base return new Base(); return new Derived2();} : (x: number) => Base >x : number return new Base(); @@ -356,7 +356,7 @@ var f8: (x: number) => any = x => { // should be (x: number) => Base var f9: (x: number) => any = x => { // should be (x: number) => Base >f9 : (x: number) => any >x : number ->x => { // should be (x: number) => Base return new Base(); return new Derived(); return new Derived2();} : (x: number) => Base | Derived | Derived2 +>x => { // should be (x: number) => Base return new Base(); return new Derived(); return new Derived2();} : (x: number) => Base >x : number return new Base(); diff --git a/tests/baselines/reference/generatedContextualTyping.types b/tests/baselines/reference/generatedContextualTyping.types index 06745d0d7aa..e8f434d31a8 100644 --- a/tests/baselines/reference/generatedContextualTyping.types +++ b/tests/baselines/reference/generatedContextualTyping.types @@ -2125,8 +2125,8 @@ var x216 = >{ func: n => { return [d1, d2]; } }; >d2 : Derived2 var x217 = (<() => Base[]>undefined) || function() { return [d1, d2] }; ->x217 : (() => Base[]) | (() => (Derived1 | Derived2)[]) ->(<() => Base[]>undefined) || function() { return [d1, d2] } : (() => Base[]) | (() => (Derived1 | Derived2)[]) +>x217 : () => Base[] +>(<() => Base[]>undefined) || function() { return [d1, d2] } : () => Base[] >(<() => Base[]>undefined) : () => Base[] ><() => Base[]>undefined : () => Base[] >Base : Base @@ -2137,8 +2137,8 @@ var x217 = (<() => Base[]>undefined) || function() { return [d1, d2] }; >d2 : Derived2 var x218 = (<() => Base[]>undefined) || function named() { return [d1, d2] }; ->x218 : (() => Base[]) | (() => (Derived1 | Derived2)[]) ->(<() => Base[]>undefined) || function named() { return [d1, d2] } : (() => Base[]) | (() => (Derived1 | Derived2)[]) +>x218 : () => Base[] +>(<() => Base[]>undefined) || function named() { return [d1, d2] } : () => Base[] >(<() => Base[]>undefined) : () => Base[] ><() => Base[]>undefined : () => Base[] >Base : Base @@ -2150,8 +2150,8 @@ var x218 = (<() => Base[]>undefined) || function named() { return [d1, d2] }; >d2 : Derived2 var x219 = (<{ (): Base[]; }>undefined) || function() { return [d1, d2] }; ->x219 : (() => Base[]) | (() => (Derived1 | Derived2)[]) ->(<{ (): Base[]; }>undefined) || function() { return [d1, d2] } : (() => Base[]) | (() => (Derived1 | Derived2)[]) +>x219 : () => Base[] +>(<{ (): Base[]; }>undefined) || function() { return [d1, d2] } : () => Base[] >(<{ (): Base[]; }>undefined) : () => Base[] ><{ (): Base[]; }>undefined : () => Base[] >Base : Base @@ -2162,8 +2162,8 @@ var x219 = (<{ (): Base[]; }>undefined) || function() { return [d1, d2] }; >d2 : Derived2 var x220 = (<{ (): Base[]; }>undefined) || function named() { return [d1, d2] }; ->x220 : (() => Base[]) | (() => (Derived1 | Derived2)[]) ->(<{ (): Base[]; }>undefined) || function named() { return [d1, d2] } : (() => Base[]) | (() => (Derived1 | Derived2)[]) +>x220 : () => Base[] +>(<{ (): Base[]; }>undefined) || function named() { return [d1, d2] } : () => Base[] >(<{ (): Base[]; }>undefined) : () => Base[] ><{ (): Base[]; }>undefined : () => Base[] >Base : Base @@ -2175,8 +2175,8 @@ var x220 = (<{ (): Base[]; }>undefined) || function named() { return [d1, d2] }; >d2 : Derived2 var x221 = (undefined) || [d1, d2]; ->x221 : Base[] | (Derived1 | Derived2)[] ->(undefined) || [d1, d2] : Base[] | (Derived1 | Derived2)[] +>x221 : Base[] +>(undefined) || [d1, d2] : Base[] >(undefined) : Base[] >undefined : Base[] >Base : Base @@ -2186,8 +2186,8 @@ var x221 = (undefined) || [d1, d2]; >d2 : Derived2 var x222 = (>undefined) || [d1, d2]; ->x222 : Base[] | (Derived1 | Derived2)[] ->(>undefined) || [d1, d2] : Base[] | (Derived1 | Derived2)[] +>x222 : Base[] +>(>undefined) || [d1, d2] : Base[] >(>undefined) : Base[] >>undefined : Base[] >Array : T[] @@ -2198,8 +2198,8 @@ var x222 = (>undefined) || [d1, d2]; >d2 : Derived2 var x223 = (<{ [n: number]: Base; }>undefined) || [d1, d2]; ->x223 : { [n: number]: Base; } | (Derived1 | Derived2)[] ->(<{ [n: number]: Base; }>undefined) || [d1, d2] : { [n: number]: Base; } | (Derived1 | Derived2)[] +>x223 : { [n: number]: Base; } +>(<{ [n: number]: Base; }>undefined) || [d1, d2] : { [n: number]: Base; } >(<{ [n: number]: Base; }>undefined) : { [n: number]: Base; } ><{ [n: number]: Base; }>undefined : { [n: number]: Base; } >n : number @@ -2210,8 +2210,8 @@ var x223 = (<{ [n: number]: Base; }>undefined) || [d1, d2]; >d2 : Derived2 var x224 = (<{n: Base[]; } >undefined) || { n: [d1, d2] }; ->x224 : { n: Base[]; } | { n: (Derived1 | Derived2)[]; } ->(<{n: Base[]; } >undefined) || { n: [d1, d2] } : { n: Base[]; } | { n: (Derived1 | Derived2)[]; } +>x224 : { n: Base[]; } +>(<{n: Base[]; } >undefined) || { n: [d1, d2] } : { n: Base[]; } >(<{n: Base[]; } >undefined) : { n: Base[]; } ><{n: Base[]; } >undefined : { n: Base[]; } >n : Base[] diff --git a/tests/baselines/reference/heterogeneousArrayLiterals.types b/tests/baselines/reference/heterogeneousArrayLiterals.types index 952200d74f8..c760e5a566f 100644 --- a/tests/baselines/reference/heterogeneousArrayLiterals.types +++ b/tests/baselines/reference/heterogeneousArrayLiterals.types @@ -21,14 +21,14 @@ var c = [1, '', null]; // {}[] >null : null var d = [{}, 1]; // {}[] ->d : ({} | number)[] ->[{}, 1] : ({} | number)[] +>d : {}[] +>[{}, 1] : {}[] >{} : {} >1 : number var e = [{}, Object]; // {}[] ->e : ({} | ObjectConstructor)[] ->[{}, Object] : ({} | ObjectConstructor)[] +>e : {}[] +>[{}, Object] : {}[] >{} : {} >Object : ObjectConstructor @@ -88,16 +88,16 @@ var k = [() => 1, () => 1]; // { (): number }[] >1 : number var l = [() => 1, () => null]; // { (): any }[] ->l : ((() => number) | (() => any))[] ->[() => 1, () => null] : ((() => number) | (() => any))[] +>l : (() => any)[] +>[() => 1, () => null] : (() => any)[] >() => 1 : () => number >1 : number >() => null : () => any >null : null var m = [() => 1, () => '', () => null]; // { (): any }[] ->m : ((() => number) | (() => string) | (() => any))[] ->[() => 1, () => '', () => null] : ((() => number) | (() => string) | (() => any))[] +>m : (() => any)[] +>[() => 1, () => '', () => null] : (() => any)[] >() => 1 : () => number >1 : number >() => '' : () => string @@ -169,8 +169,8 @@ module Derived { >derived : Derived var j = [() => base, () => derived]; // { {}: Base } ->j : ((() => Base) | (() => Derived))[] ->[() => base, () => derived] : ((() => Base) | (() => Derived))[] +>j : (() => Base)[] +>[() => base, () => derived] : (() => Base)[] >() => base : () => Base >base : Base >() => derived : () => Derived @@ -185,16 +185,16 @@ module Derived { >1 : number var l = [() => base, () => null]; // { (): any }[] ->l : ((() => Base) | (() => any))[] ->[() => base, () => null] : ((() => Base) | (() => any))[] +>l : (() => any)[] +>[() => base, () => null] : (() => any)[] >() => base : () => Base >base : Base >() => null : () => any >null : null var m = [() => base, () => derived, () => null]; // { (): any }[] ->m : ((() => Base) | (() => Derived) | (() => any))[] ->[() => base, () => derived, () => null] : ((() => Base) | (() => Derived) | (() => any))[] +>m : (() => any)[] +>[() => base, () => derived, () => null] : (() => any)[] >() => base : () => Base >base : Base >() => derived : () => Derived @@ -203,8 +203,8 @@ module Derived { >null : null var n = [[() => base], [() => derived]]; // { (): Base }[] ->n : ((() => Base)[] | (() => Derived)[])[] ->[[() => base], [() => derived]] : ((() => Base)[] | (() => Derived)[])[] +>n : (() => Base)[][] +>[[() => base], [() => derived]] : (() => Base)[][] >[() => base] : (() => Base)[] >() => base : () => Base >base : Base @@ -219,8 +219,8 @@ module Derived { >derived2 : Derived2 var p = [derived, derived2, base]; // Base[] ->p : (Derived | Derived2 | Base)[] ->[derived, derived2, base] : (Derived | Derived2 | Base)[] +>p : Base[] +>[derived, derived2, base] : Base[] >derived : Derived >derived2 : Derived2 >base : Base @@ -310,8 +310,8 @@ function foo(t: T, u: U) { >u : U var f = [() => t, () => u, () => null]; // { (): any }[] ->f : ((() => T) | (() => U) | (() => any))[] ->[() => t, () => u, () => null] : ((() => T) | (() => U) | (() => any))[] +>f : (() => any)[] +>[() => t, () => u, () => null] : (() => any)[] >() => t : () => T >t : T >() => u : () => U @@ -364,8 +364,8 @@ function foo2(t: T, u: U) { >u : U var f = [() => t, () => u, () => null]; // { (): any }[] ->f : ((() => T) | (() => U) | (() => any))[] ->[() => t, () => u, () => null] : ((() => T) | (() => U) | (() => any))[] +>f : (() => any)[] +>[() => t, () => u, () => null] : (() => any)[] >() => t : () => T >t : T >() => u : () => U @@ -374,8 +374,8 @@ function foo2(t: T, u: U) { >null : null var g = [t, base]; // Base[] ->g : (T | Base)[] ->[t, base] : (T | Base)[] +>g : Base[] +>[t, base] : Base[] >t : T >base : Base @@ -386,14 +386,14 @@ function foo2(t: T, u: U) { >derived : Derived var i = [u, base]; // Base[] ->i : (U | Base)[] ->[u, base] : (U | Base)[] +>i : Base[] +>[u, base] : Base[] >u : U >base : Base var j = [u, derived]; // Derived[] ->j : (U | Derived)[] ->[u, derived] : (U | Derived)[] +>j : Derived[] +>[u, derived] : Derived[] >u : U >derived : Derived } @@ -442,8 +442,8 @@ function foo3(t: T, u: U) { >u : U var f = [() => t, () => u, () => null]; // { (): any }[] ->f : ((() => T) | (() => U) | (() => any))[] ->[() => t, () => u, () => null] : ((() => T) | (() => U) | (() => any))[] +>f : (() => any)[] +>[() => t, () => u, () => null] : (() => any)[] >() => t : () => T >t : T >() => u : () => U @@ -452,26 +452,26 @@ function foo3(t: T, u: U) { >null : null var g = [t, base]; // Base[] ->g : (T | Base)[] ->[t, base] : (T | Base)[] +>g : Base[] +>[t, base] : Base[] >t : T >base : Base var h = [t, derived]; // Derived[] ->h : (T | Derived)[] ->[t, derived] : (T | Derived)[] +>h : Derived[] +>[t, derived] : Derived[] >t : T >derived : Derived var i = [u, base]; // Base[] ->i : (U | Base)[] ->[u, base] : (U | Base)[] +>i : Base[] +>[u, base] : Base[] >u : U >base : Base var j = [u, derived]; // Derived[] ->j : (U | Derived)[] ->[u, derived] : (U | Derived)[] +>j : Derived[] +>[u, derived] : Derived[] >u : U >derived : Derived } @@ -520,8 +520,8 @@ function foo4(t: T, u: U) { >u : U var f = [() => t, () => u, () => null]; // { (): any }[] ->f : ((() => T) | (() => U) | (() => any))[] ->[() => t, () => u, () => null] : ((() => T) | (() => U) | (() => any))[] +>f : (() => any)[] +>[() => t, () => u, () => null] : (() => any)[] >() => t : () => T >t : T >() => u : () => U @@ -530,8 +530,8 @@ function foo4(t: T, u: U) { >null : null var g = [t, base]; // Base[] ->g : (T | Base)[] ->[t, base] : (T | Base)[] +>g : Base[] +>[t, base] : Base[] >t : T >base : Base @@ -542,8 +542,8 @@ function foo4(t: T, u: U) { >derived : Derived var i = [u, base]; // Base[] ->i : (U | Base)[] ->[u, base] : (U | Base)[] +>i : Base[] +>[u, base] : Base[] >u : U >base : Base diff --git a/tests/baselines/reference/invalidMultipleVariableDeclarations.errors.txt b/tests/baselines/reference/invalidMultipleVariableDeclarations.errors.txt index 0c4b95214b0..3ec718f3b25 100644 --- a/tests/baselines/reference/invalidMultipleVariableDeclarations.errors.txt +++ b/tests/baselines/reference/invalidMultipleVariableDeclarations.errors.txt @@ -7,7 +7,7 @@ tests/cases/conformance/statements/VariableStatements/invalidMultipleVariableDec tests/cases/conformance/statements/VariableStatements/invalidMultipleVariableDeclarations.ts(40,5): error TS2403: Subsequent variable declarations must have the same type. Variable 'b' must be of type 'I', but here has type 'C2'. tests/cases/conformance/statements/VariableStatements/invalidMultipleVariableDeclarations.ts(43,5): error TS2403: Subsequent variable declarations must have the same type. Variable 'f' must be of type '(x: string) => number', but here has type '(x: number) => string'. tests/cases/conformance/statements/VariableStatements/invalidMultipleVariableDeclarations.ts(46,5): error TS2403: Subsequent variable declarations must have the same type. Variable 'arr' must be of type 'string[]', but here has type 'number[]'. -tests/cases/conformance/statements/VariableStatements/invalidMultipleVariableDeclarations.ts(47,5): error TS2403: Subsequent variable declarations must have the same type. Variable 'arr' must be of type 'string[]', but here has type '(C | C2 | D)[]'. +tests/cases/conformance/statements/VariableStatements/invalidMultipleVariableDeclarations.ts(47,5): error TS2403: Subsequent variable declarations must have the same type. Variable 'arr' must be of type 'string[]', but here has type '(C | D)[]'. tests/cases/conformance/statements/VariableStatements/invalidMultipleVariableDeclarations.ts(50,5): error TS2403: Subsequent variable declarations must have the same type. Variable 'arr2' must be of type 'D[]', but here has type 'D[]'. tests/cases/conformance/statements/VariableStatements/invalidMultipleVariableDeclarations.ts(53,5): error TS2403: Subsequent variable declarations must have the same type. Variable 'm' must be of type 'typeof M', but here has type 'typeof A'. @@ -79,7 +79,7 @@ tests/cases/conformance/statements/VariableStatements/invalidMultipleVariableDec !!! error TS2403: Subsequent variable declarations must have the same type. Variable 'arr' must be of type 'string[]', but here has type 'number[]'. var arr = [new C(), new C2(), new D()]; ~~~ -!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'arr' must be of type 'string[]', but here has type '(C | C2 | D)[]'. +!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'arr' must be of type 'string[]', but here has type '(C | D)[]'. var arr2 = [new D()]; var arr2 = new Array>(); diff --git a/tests/baselines/reference/logicalOrOperatorWithEveryType.types b/tests/baselines/reference/logicalOrOperatorWithEveryType.types index 04bc188e308..4540e35aaf4 100644 --- a/tests/baselines/reference/logicalOrOperatorWithEveryType.types +++ b/tests/baselines/reference/logicalOrOperatorWithEveryType.types @@ -187,8 +187,8 @@ var rc5 = a5 || a3; // void || number is void | number >a3 : number var rc6 = a6 || a3; // enum || number is number ->rc6 : E | number ->a6 || a3 : E | number +>rc6 : number +>a6 || a3 : number >a6 : E >a3 : number @@ -349,8 +349,8 @@ var rg2 = a2 || a6; // boolean || enum is boolean | enum >a6 : E var rg3 = a3 || a6; // number || enum is number ->rg3 : number | E ->a3 || a6 : number | E +>rg3 : number +>a3 || a6 : number >a3 : number >a6 : E diff --git a/tests/baselines/reference/logicalOrOperatorWithTypeParameters.types b/tests/baselines/reference/logicalOrOperatorWithTypeParameters.types index df8f6cac6db..f887ad7ae14 100644 --- a/tests/baselines/reference/logicalOrOperatorWithTypeParameters.types +++ b/tests/baselines/reference/logicalOrOperatorWithTypeParameters.types @@ -107,8 +107,8 @@ function fn3u : U var r3 = t || { a: '' }; ->r3 : T | { a: string; } ->t || { a: '' } : T | { a: string; } +>r3 : { a: string; } +>t || { a: '' } : { a: string; } >t : T >{ a: '' } : { a: string; } >a : string diff --git a/tests/baselines/reference/numericIndexerConstrainsPropertyDeclarations2.errors.txt b/tests/baselines/reference/numericIndexerConstrainsPropertyDeclarations2.errors.txt index 71e164d5d62..ff18160e9a5 100644 --- a/tests/baselines/reference/numericIndexerConstrainsPropertyDeclarations2.errors.txt +++ b/tests/baselines/reference/numericIndexerConstrainsPropertyDeclarations2.errors.txt @@ -1,9 +1,9 @@ tests/cases/conformance/types/objectTypeLiteral/indexSignatures/numericIndexerConstrainsPropertyDeclarations2.ts(16,5): error TS2412: Property '3.0' of type 'number' is not assignable to numeric index type 'A'. tests/cases/conformance/types/objectTypeLiteral/indexSignatures/numericIndexerConstrainsPropertyDeclarations2.ts(25,5): error TS2412: Property '3.0' of type 'number' is not assignable to numeric index type 'A'. tests/cases/conformance/types/objectTypeLiteral/indexSignatures/numericIndexerConstrainsPropertyDeclarations2.ts(34,5): error TS2412: Property '3.0' of type 'number' is not assignable to numeric index type 'A'. -tests/cases/conformance/types/objectTypeLiteral/indexSignatures/numericIndexerConstrainsPropertyDeclarations2.ts(39,5): error TS2322: Type '{ [x: number]: A | B | number; 1.0: A; 2.0: B; 3.0: number; "2.5": B; "4.0": string; }' is not assignable to type '{ [x: number]: A; }'. +tests/cases/conformance/types/objectTypeLiteral/indexSignatures/numericIndexerConstrainsPropertyDeclarations2.ts(39,5): error TS2322: Type '{ [x: number]: A | number; 1.0: A; 2.0: B; 3.0: number; "2.5": B; "4.0": string; }' is not assignable to type '{ [x: number]: A; }'. Index signatures are incompatible. - Type 'A | B | number' is not assignable to type 'A'. + Type 'A | number' is not assignable to type 'A'. Type 'number' is not assignable to type 'A'. @@ -54,9 +54,9 @@ tests/cases/conformance/types/objectTypeLiteral/indexSignatures/numericIndexerCo // error var b: { [x: number]: A } = { ~ -!!! error TS2322: Type '{ [x: number]: A | B | number; 1.0: A; 2.0: B; 3.0: number; "2.5": B; "4.0": string; }' is not assignable to type '{ [x: number]: A; }'. +!!! error TS2322: Type '{ [x: number]: A | number; 1.0: A; 2.0: B; 3.0: number; "2.5": B; "4.0": string; }' is not assignable to type '{ [x: number]: A; }'. !!! error TS2322: Index signatures are incompatible. -!!! error TS2322: Type 'A | B | number' is not assignable to type 'A'. +!!! error TS2322: Type 'A | number' is not assignable to type 'A'. !!! error TS2322: Type 'number' is not assignable to type 'A'. 1.0: new A(), 2.0: new B(), diff --git a/tests/baselines/reference/objectLiteralIndexerErrors.errors.txt b/tests/baselines/reference/objectLiteralIndexerErrors.errors.txt index edb6d031b1f..c35e49f02a3 100644 --- a/tests/baselines/reference/objectLiteralIndexerErrors.errors.txt +++ b/tests/baselines/reference/objectLiteralIndexerErrors.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/objectLiteralIndexerErrors.ts(13,5): error TS2322: Type '{ [x: string]: B | A; [x: number]: A; 0: A; x: B; }' is not assignable to type '{ [s: string]: A; [n: number]: B; }'. +tests/cases/compiler/objectLiteralIndexerErrors.ts(13,5): error TS2322: Type '{ [x: string]: A; [x: number]: A; 0: A; x: B; }' is not assignable to type '{ [s: string]: A; [n: number]: B; }'. Index signatures are incompatible. Type 'A' is not assignable to type 'B'. @@ -18,7 +18,7 @@ tests/cases/compiler/objectLiteralIndexerErrors.ts(13,5): error TS2322: Type '{ var o1: { [s: string]: A;[n: number]: B; } = { x: b, 0: a }; // both indexers are A ~~ -!!! error TS2322: Type '{ [x: string]: B | A; [x: number]: A; 0: A; x: B; }' is not assignable to type '{ [s: string]: A; [n: number]: B; }'. +!!! error TS2322: Type '{ [x: string]: A; [x: number]: A; 0: A; x: B; }' is not assignable to type '{ [s: string]: A; [n: number]: B; }'. !!! error TS2322: Index signatures are incompatible. !!! error TS2322: Type 'A' is not assignable to type 'B'. o1 = { x: c, 0: a }; // string indexer is any, number indexer is A \ No newline at end of file diff --git a/tests/baselines/reference/objectLiteralIndexers.types b/tests/baselines/reference/objectLiteralIndexers.types index 55cec857c70..d5add00ebaf 100644 --- a/tests/baselines/reference/objectLiteralIndexers.types +++ b/tests/baselines/reference/objectLiteralIndexers.types @@ -31,7 +31,7 @@ var o1: { [s: string]: A;[n: number]: B; } = { x: a, 0: b }; // string indexer i >A : A >n : number >B : B ->{ x: a, 0: b } : { [x: string]: A | B; [x: number]: B; 0: B; x: A; } +>{ x: a, 0: b } : { [x: string]: A; [x: number]: B; 0: B; x: A; } >x : A >a : A >b : B diff --git a/tests/baselines/reference/parenthesizedContexualTyping1.types b/tests/baselines/reference/parenthesizedContexualTyping1.types index 1423901a28f..61ec1a24ec5 100644 --- a/tests/baselines/reference/parenthesizedContexualTyping1.types +++ b/tests/baselines/reference/parenthesizedContexualTyping1.types @@ -149,8 +149,8 @@ var i = fun((Math.random() < 0.5 ? x => x : x => undefined), 10); >i : number >fun((Math.random() < 0.5 ? x => x : x => undefined), 10) : number >fun : { (g: (x: T) => T, x: T): T; (g: (x: T) => T, h: (y: T) => T, x: T): T; } ->(Math.random() < 0.5 ? x => x : x => undefined) : ((x: number) => number) | ((x: number) => any) ->Math.random() < 0.5 ? x => x : x => undefined : ((x: number) => number) | ((x: number) => any) +>(Math.random() < 0.5 ? x => x : x => undefined) : (x: number) => any +>Math.random() < 0.5 ? x => x : x => undefined : (x: number) => any >Math.random() < 0.5 : boolean >Math.random() : number >Math.random : () => number @@ -169,8 +169,8 @@ var j = fun((Math.random() < 0.5 ? (x => x) : (x => undefined)), 10); >j : number >fun((Math.random() < 0.5 ? (x => x) : (x => undefined)), 10) : number >fun : { (g: (x: T) => T, x: T): T; (g: (x: T) => T, h: (y: T) => T, x: T): T; } ->(Math.random() < 0.5 ? (x => x) : (x => undefined)) : ((x: number) => number) | ((x: number) => any) ->Math.random() < 0.5 ? (x => x) : (x => undefined) : ((x: number) => number) | ((x: number) => any) +>(Math.random() < 0.5 ? (x => x) : (x => undefined)) : (x: number) => any +>Math.random() < 0.5 ? (x => x) : (x => undefined) : (x: number) => any >Math.random() < 0.5 : boolean >Math.random() : number >Math.random : () => number @@ -191,8 +191,8 @@ var k = fun((Math.random() < 0.5 ? (x => x) : (x => undefined)), x => x, 10); >k : number >fun((Math.random() < 0.5 ? (x => x) : (x => undefined)), x => x, 10) : number >fun : { (g: (x: T) => T, x: T): T; (g: (x: T) => T, h: (y: T) => T, x: T): T; } ->(Math.random() < 0.5 ? (x => x) : (x => undefined)) : ((x: number) => number) | ((x: number) => any) ->Math.random() < 0.5 ? (x => x) : (x => undefined) : ((x: number) => number) | ((x: number) => any) +>(Math.random() < 0.5 ? (x => x) : (x => undefined)) : (x: number) => any +>Math.random() < 0.5 ? (x => x) : (x => undefined) : (x: number) => any >Math.random() < 0.5 : boolean >Math.random() : number >Math.random : () => number @@ -216,9 +216,9 @@ var l = fun(((Math.random() < 0.5 ? ((x => x)) : ((x => undefined)))), ((x => x) >l : number >fun(((Math.random() < 0.5 ? ((x => x)) : ((x => undefined)))), ((x => x)), 10) : number >fun : { (g: (x: T) => T, x: T): T; (g: (x: T) => T, h: (y: T) => T, x: T): T; } ->((Math.random() < 0.5 ? ((x => x)) : ((x => undefined)))) : ((x: number) => number) | ((x: number) => any) ->(Math.random() < 0.5 ? ((x => x)) : ((x => undefined))) : ((x: number) => number) | ((x: number) => any) ->Math.random() < 0.5 ? ((x => x)) : ((x => undefined)) : ((x: number) => number) | ((x: number) => any) +>((Math.random() < 0.5 ? ((x => x)) : ((x => undefined)))) : (x: number) => any +>(Math.random() < 0.5 ? ((x => x)) : ((x => undefined))) : (x: number) => any +>Math.random() < 0.5 ? ((x => x)) : ((x => undefined)) : (x: number) => any >Math.random() < 0.5 : boolean >Math.random() : number >Math.random : () => number diff --git a/tests/baselines/reference/parenthesizedContexualTyping2.types b/tests/baselines/reference/parenthesizedContexualTyping2.types index 344933ea1fc..a055f2f1bbd 100644 --- a/tests/baselines/reference/parenthesizedContexualTyping2.types +++ b/tests/baselines/reference/parenthesizedContexualTyping2.types @@ -186,8 +186,8 @@ var i = fun((Math.random() < 0.5 ? x => { x(undefined); return x; } : x >i : number >fun((Math.random() < 0.5 ? x => { x(undefined); return x; } : x => undefined), 10) : number >fun : { (f: (x: (p: T) => T) => (p: T) => T, x: T): T; (f: (x: (p: T) => T) => (p: T) => T, g: (x: (p: T) => T) => (p: T) => T, x: T): T; } ->(Math.random() < 0.5 ? x => { x(undefined); return x; } : x => undefined) : ((x: (p: T) => T) => (p: T) => T) | ((x: (p: T) => T) => any) ->Math.random() < 0.5 ? x => { x(undefined); return x; } : x => undefined : ((x: (p: T) => T) => (p: T) => T) | ((x: (p: T) => T) => any) +>(Math.random() < 0.5 ? x => { x(undefined); return x; } : x => undefined) : (x: (p: T) => T) => any +>Math.random() < 0.5 ? x => { x(undefined); return x; } : x => undefined : (x: (p: T) => T) => any >Math.random() < 0.5 : boolean >Math.random() : number >Math.random : () => number @@ -209,8 +209,8 @@ var j = fun((Math.random() < 0.5 ? (x => { x(undefined); return x; }) : >j : number >fun((Math.random() < 0.5 ? (x => { x(undefined); return x; }) : (x => undefined)), 10) : number >fun : { (f: (x: (p: T) => T) => (p: T) => T, x: T): T; (f: (x: (p: T) => T) => (p: T) => T, g: (x: (p: T) => T) => (p: T) => T, x: T): T; } ->(Math.random() < 0.5 ? (x => { x(undefined); return x; }) : (x => undefined)) : ((x: (p: T) => T) => (p: T) => T) | ((x: (p: T) => T) => any) ->Math.random() < 0.5 ? (x => { x(undefined); return x; }) : (x => undefined) : ((x: (p: T) => T) => (p: T) => T) | ((x: (p: T) => T) => any) +>(Math.random() < 0.5 ? (x => { x(undefined); return x; }) : (x => undefined)) : (x: (p: T) => T) => any +>Math.random() < 0.5 ? (x => { x(undefined); return x; }) : (x => undefined) : (x: (p: T) => T) => any >Math.random() < 0.5 : boolean >Math.random() : number >Math.random : () => number @@ -234,8 +234,8 @@ var k = fun((Math.random() < 0.5 ? (x => { x(undefined); return x; }) : >k : number >fun((Math.random() < 0.5 ? (x => { x(undefined); return x; }) : (x => undefined)), x => { x(undefined); return x; }, 10) : number >fun : { (f: (x: (p: T) => T) => (p: T) => T, x: T): T; (f: (x: (p: T) => T) => (p: T) => T, g: (x: (p: T) => T) => (p: T) => T, x: T): T; } ->(Math.random() < 0.5 ? (x => { x(undefined); return x; }) : (x => undefined)) : ((x: (p: T) => T) => (p: T) => T) | ((x: (p: T) => T) => any) ->Math.random() < 0.5 ? (x => { x(undefined); return x; }) : (x => undefined) : ((x: (p: T) => T) => (p: T) => T) | ((x: (p: T) => T) => any) +>(Math.random() < 0.5 ? (x => { x(undefined); return x; }) : (x => undefined)) : (x: (p: T) => T) => any +>Math.random() < 0.5 ? (x => { x(undefined); return x; }) : (x => undefined) : (x: (p: T) => T) => any >Math.random() < 0.5 : boolean >Math.random() : number >Math.random : () => number @@ -265,9 +265,9 @@ var l = fun(((Math.random() < 0.5 ? ((x => { x(undefined); return x; })) >l : number >fun(((Math.random() < 0.5 ? ((x => { x(undefined); return x; })) : ((x => undefined)))),((x => { x(undefined); return x; })), 10) : number >fun : { (f: (x: (p: T) => T) => (p: T) => T, x: T): T; (f: (x: (p: T) => T) => (p: T) => T, g: (x: (p: T) => T) => (p: T) => T, x: T): T; } ->((Math.random() < 0.5 ? ((x => { x(undefined); return x; })) : ((x => undefined)))) : ((x: (p: T) => T) => (p: T) => T) | ((x: (p: T) => T) => any) ->(Math.random() < 0.5 ? ((x => { x(undefined); return x; })) : ((x => undefined))) : ((x: (p: T) => T) => (p: T) => T) | ((x: (p: T) => T) => any) ->Math.random() < 0.5 ? ((x => { x(undefined); return x; })) : ((x => undefined)) : ((x: (p: T) => T) => (p: T) => T) | ((x: (p: T) => T) => any) +>((Math.random() < 0.5 ? ((x => { x(undefined); return x; })) : ((x => undefined)))) : (x: (p: T) => T) => any +>(Math.random() < 0.5 ? ((x => { x(undefined); return x; })) : ((x => undefined))) : (x: (p: T) => T) => any +>Math.random() < 0.5 ? ((x => { x(undefined); return x; })) : ((x => undefined)) : (x: (p: T) => T) => any >Math.random() < 0.5 : boolean >Math.random() : number >Math.random : () => number diff --git a/tests/baselines/reference/stringIndexerConstrainsPropertyDeclarations.errors.txt b/tests/baselines/reference/stringIndexerConstrainsPropertyDeclarations.errors.txt index e6cba35be25..1f4ee3debed 100644 --- a/tests/baselines/reference/stringIndexerConstrainsPropertyDeclarations.errors.txt +++ b/tests/baselines/reference/stringIndexerConstrainsPropertyDeclarations.errors.txt @@ -22,9 +22,9 @@ tests/cases/conformance/types/objectTypeLiteral/indexSignatures/stringIndexerCon tests/cases/conformance/types/objectTypeLiteral/indexSignatures/stringIndexerConstrainsPropertyDeclarations.ts(71,5): error TS2411: Property 'foo' of type '() => string' is not assignable to string index type 'string'. tests/cases/conformance/types/objectTypeLiteral/indexSignatures/stringIndexerConstrainsPropertyDeclarations.ts(73,5): error TS2411: Property '"4.0"' of type 'number' is not assignable to string index type 'string'. tests/cases/conformance/types/objectTypeLiteral/indexSignatures/stringIndexerConstrainsPropertyDeclarations.ts(74,5): error TS2411: Property 'f' of type 'MyString' is not assignable to string index type 'string'. -tests/cases/conformance/types/objectTypeLiteral/indexSignatures/stringIndexerConstrainsPropertyDeclarations.ts(78,5): error TS2322: Type '{ [x: string]: string | number | (() => void) | MyString | (() => string); 1.0: string; 2.0: number; a: string; b: number; c: () => void; "d": string; "e": number; "3.0": string; "4.0": number; f: MyString; X: string; foo(): string; }' is not assignable to type '{ [x: string]: string; }'. +tests/cases/conformance/types/objectTypeLiteral/indexSignatures/stringIndexerConstrainsPropertyDeclarations.ts(78,5): error TS2322: Type '{ [x: string]: string | number | (() => void) | MyString; 1.0: string; 2.0: number; a: string; b: number; c: () => void; "d": string; "e": number; "3.0": string; "4.0": number; f: MyString; X: string; foo(): string; }' is not assignable to type '{ [x: string]: string; }'. Index signatures are incompatible. - Type 'string | number | (() => void) | MyString | (() => string)' is not assignable to type 'string'. + Type 'string | number | (() => void) | MyString' is not assignable to type 'string'. Type 'number' is not assignable to type 'string'. tests/cases/conformance/types/objectTypeLiteral/indexSignatures/stringIndexerConstrainsPropertyDeclarations.ts(90,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/conformance/types/objectTypeLiteral/indexSignatures/stringIndexerConstrainsPropertyDeclarations.ts(93,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. @@ -160,9 +160,9 @@ tests/cases/conformance/types/objectTypeLiteral/indexSignatures/stringIndexerCon // error var b: { [x: string]: string; } = { ~ -!!! error TS2322: Type '{ [x: string]: string | number | (() => void) | MyString | (() => string); 1.0: string; 2.0: number; a: string; b: number; c: () => void; "d": string; "e": number; "3.0": string; "4.0": number; f: MyString; X: string; foo(): string; }' is not assignable to type '{ [x: string]: string; }'. +!!! error TS2322: Type '{ [x: string]: string | number | (() => void) | MyString; 1.0: string; 2.0: number; a: string; b: number; c: () => void; "d": string; "e": number; "3.0": string; "4.0": number; f: MyString; X: string; foo(): string; }' is not assignable to type '{ [x: string]: string; }'. !!! error TS2322: Index signatures are incompatible. -!!! error TS2322: Type 'string | number | (() => void) | MyString | (() => string)' is not assignable to type 'string'. +!!! error TS2322: Type 'string | number | (() => void) | MyString' is not assignable to type 'string'. !!! error TS2322: Type 'number' is not assignable to type 'string'. a: '', b: 1, diff --git a/tests/baselines/reference/stringIndexerConstrainsPropertyDeclarations2.errors.txt b/tests/baselines/reference/stringIndexerConstrainsPropertyDeclarations2.errors.txt index 13d5adcf1f5..faef7905453 100644 --- a/tests/baselines/reference/stringIndexerConstrainsPropertyDeclarations2.errors.txt +++ b/tests/baselines/reference/stringIndexerConstrainsPropertyDeclarations2.errors.txt @@ -4,11 +4,10 @@ tests/cases/conformance/types/objectTypeLiteral/indexSignatures/stringIndexerCon tests/cases/conformance/types/objectTypeLiteral/indexSignatures/stringIndexerConstrainsPropertyDeclarations2.ts(24,5): error TS2411: Property 'd' of type 'string' is not assignable to string index type 'A'. tests/cases/conformance/types/objectTypeLiteral/indexSignatures/stringIndexerConstrainsPropertyDeclarations2.ts(31,5): error TS2411: Property 'c' of type 'number' is not assignable to string index type 'A'. tests/cases/conformance/types/objectTypeLiteral/indexSignatures/stringIndexerConstrainsPropertyDeclarations2.ts(32,5): error TS2411: Property 'd' of type 'string' is not assignable to string index type 'A'. -tests/cases/conformance/types/objectTypeLiteral/indexSignatures/stringIndexerConstrainsPropertyDeclarations2.ts(36,5): error TS2322: Type '{ [x: string]: typeof A | typeof B; a: typeof A; b: typeof B; }' is not assignable to type '{ [x: string]: A; }'. +tests/cases/conformance/types/objectTypeLiteral/indexSignatures/stringIndexerConstrainsPropertyDeclarations2.ts(36,5): error TS2322: Type '{ [x: string]: typeof A; a: typeof A; b: typeof B; }' is not assignable to type '{ [x: string]: A; }'. Index signatures are incompatible. - Type 'typeof A | typeof B' is not assignable to type 'A'. - Type 'typeof A' is not assignable to type 'A'. - Property 'foo' is missing in type 'typeof A'. + Type 'typeof A' is not assignable to type 'A'. + Property 'foo' is missing in type 'typeof A'. ==== tests/cases/conformance/types/objectTypeLiteral/indexSignatures/stringIndexerConstrainsPropertyDeclarations2.ts (7 errors) ==== @@ -61,11 +60,10 @@ tests/cases/conformance/types/objectTypeLiteral/indexSignatures/stringIndexerCon // error var b: { [x: string]: A } = { ~ -!!! error TS2322: Type '{ [x: string]: typeof A | typeof B; a: typeof A; b: typeof B; }' is not assignable to type '{ [x: string]: A; }'. +!!! error TS2322: Type '{ [x: string]: typeof A; a: typeof A; b: typeof B; }' is not assignable to type '{ [x: string]: A; }'. !!! error TS2322: Index signatures are incompatible. -!!! error TS2322: Type 'typeof A | typeof B' is not assignable to type 'A'. -!!! error TS2322: Type 'typeof A' is not assignable to type 'A'. -!!! error TS2322: Property 'foo' is missing in type 'typeof A'. +!!! error TS2322: Type 'typeof A' is not assignable to type 'A'. +!!! error TS2322: Property 'foo' is missing in type 'typeof A'. a: A, b: B } \ No newline at end of file diff --git a/tests/baselines/reference/subtypingWithCallSignatures2.types b/tests/baselines/reference/subtypingWithCallSignatures2.types index e43382766ac..b72993e7bea 100644 --- a/tests/baselines/reference/subtypingWithCallSignatures2.types +++ b/tests/baselines/reference/subtypingWithCallSignatures2.types @@ -331,14 +331,14 @@ var r1 = foo1(r1arg1); // any, return types are not subtype of first overload >r1arg1 : (x: T) => T[] var r1a = [r1arg2, r1arg1]; // generic signature, subtype in both directions ->r1a : (((x: number) => number[]) | ((x: T) => T[]))[] ->[r1arg2, r1arg1] : (((x: number) => number[]) | ((x: T) => T[]))[] +>r1a : ((x: T) => T[])[] +>[r1arg2, r1arg1] : ((x: T) => T[])[] >r1arg2 : (x: number) => number[] >r1arg1 : (x: T) => T[] var r1b = [r1arg1, r1arg2]; // generic signature, subtype in both directions ->r1b : (((x: T) => T[]) | ((x: number) => number[]))[] ->[r1arg1, r1arg2] : (((x: T) => T[]) | ((x: number) => number[]))[] +>r1b : ((x: T) => T[])[] +>[r1arg1, r1arg2] : ((x: T) => T[])[] >r1arg1 : (x: T) => T[] >r1arg2 : (x: number) => number[] @@ -365,14 +365,14 @@ var r2 = foo2(r2arg1); >r2arg1 : (x: T) => string[] var r2a = [r2arg1, r2arg2]; ->r2a : (((x: T) => string[]) | ((x: number) => string[]))[] ->[r2arg1, r2arg2] : (((x: T) => string[]) | ((x: number) => string[]))[] +>r2a : ((x: T) => string[])[] +>[r2arg1, r2arg2] : ((x: T) => string[])[] >r2arg1 : (x: T) => string[] >r2arg2 : (x: number) => string[] var r2b = [r2arg2, r2arg1]; ->r2b : (((x: number) => string[]) | ((x: T) => string[]))[] ->[r2arg2, r2arg1] : (((x: number) => string[]) | ((x: T) => string[]))[] +>r2b : ((x: number) => string[])[] +>[r2arg2, r2arg1] : ((x: number) => string[])[] >r2arg2 : (x: number) => string[] >r2arg1 : (x: T) => string[] @@ -396,14 +396,14 @@ var r3 = foo3(r3arg1); >r3arg1 : (x: T) => T var r3a = [r3arg1, r3arg2]; ->r3a : (((x: T) => T) | ((x: number) => void))[] ->[r3arg1, r3arg2] : (((x: T) => T) | ((x: number) => void))[] +>r3a : ((x: T) => T)[] +>[r3arg1, r3arg2] : ((x: T) => T)[] >r3arg1 : (x: T) => T >r3arg2 : (x: number) => void var r3b = [r3arg2, r3arg1]; ->r3b : (((x: number) => void) | ((x: T) => T))[] ->[r3arg2, r3arg1] : (((x: number) => void) | ((x: T) => T))[] +>r3b : ((x: number) => void)[] +>[r3arg2, r3arg1] : ((x: number) => void)[] >r3arg2 : (x: number) => void >r3arg1 : (x: T) => T @@ -432,14 +432,14 @@ var r4 = foo4(r4arg1); // any >r4arg1 : (x: T, y: U) => T var r4a = [r4arg1, r4arg2]; ->r4a : (((x: T, y: U) => T) | ((x: string, y: number) => string))[] ->[r4arg1, r4arg2] : (((x: T, y: U) => T) | ((x: string, y: number) => string))[] +>r4a : ((x: T, y: U) => T)[] +>[r4arg1, r4arg2] : ((x: T, y: U) => T)[] >r4arg1 : (x: T, y: U) => T >r4arg2 : (x: string, y: number) => string var r4b = [r4arg2, r4arg1]; ->r4b : (((x: string, y: number) => string) | ((x: T, y: U) => T))[] ->[r4arg2, r4arg1] : (((x: string, y: number) => string) | ((x: T, y: U) => T))[] +>r4b : ((x: T, y: U) => T)[] +>[r4arg2, r4arg1] : ((x: T, y: U) => T)[] >r4arg2 : (x: string, y: number) => string >r4arg1 : (x: T, y: U) => T @@ -470,14 +470,14 @@ var r5 = foo5(r5arg1); // any >r5arg1 : (x: (arg: T) => U) => T var r5a = [r5arg1, r5arg2]; ->r5a : (((x: (arg: T) => U) => T) | ((x: (arg: string) => number) => string))[] ->[r5arg1, r5arg2] : (((x: (arg: T) => U) => T) | ((x: (arg: string) => number) => string))[] +>r5a : ((x: (arg: T) => U) => T)[] +>[r5arg1, r5arg2] : ((x: (arg: T) => U) => T)[] >r5arg1 : (x: (arg: T) => U) => T >r5arg2 : (x: (arg: string) => number) => string var r5b = [r5arg2, r5arg1]; ->r5b : (((x: (arg: string) => number) => string) | ((x: (arg: T) => U) => T))[] ->[r5arg2, r5arg1] : (((x: (arg: string) => number) => string) | ((x: (arg: T) => U) => T))[] +>r5b : ((x: (arg: T) => U) => T)[] +>[r5arg2, r5arg1] : ((x: (arg: T) => U) => T)[] >r5arg2 : (x: (arg: string) => number) => string >r5arg1 : (x: (arg: T) => U) => T @@ -514,14 +514,14 @@ var r6 = foo6(r6arg1); // any >r6arg1 : (x: (arg: T) => U) => T var r6a = [r6arg1, r6arg2]; ->r6a : (((x: (arg: T) => U) => T) | ((x: (arg: Base) => Derived) => Base))[] ->[r6arg1, r6arg2] : (((x: (arg: T) => U) => T) | ((x: (arg: Base) => Derived) => Base))[] +>r6a : ((x: (arg: T) => U) => T)[] +>[r6arg1, r6arg2] : ((x: (arg: T) => U) => T)[] >r6arg1 : (x: (arg: T) => U) => T >r6arg2 : (x: (arg: Base) => Derived) => Base var r6b = [r6arg2, r6arg1]; ->r6b : (((x: (arg: Base) => Derived) => Base) | ((x: (arg: T) => U) => T))[] ->[r6arg2, r6arg1] : (((x: (arg: Base) => Derived) => Base) | ((x: (arg: T) => U) => T))[] +>r6b : ((x: (arg: T) => U) => T)[] +>[r6arg2, r6arg1] : ((x: (arg: T) => U) => T)[] >r6arg2 : (x: (arg: Base) => Derived) => Base >r6arg1 : (x: (arg: T) => U) => T @@ -564,14 +564,14 @@ var r7 = foo7(r7arg1); // any >r7arg1 : (x: (arg: T) => U) => (r: T) => U var r7a = [r7arg1, r7arg2]; ->r7a : (((x: (arg: T) => U) => (r: T) => U) | ((x: (arg: Base) => Derived) => (r: Base) => Derived))[] ->[r7arg1, r7arg2] : (((x: (arg: T) => U) => (r: T) => U) | ((x: (arg: Base) => Derived) => (r: Base) => Derived))[] +>r7a : ((x: (arg: T) => U) => (r: T) => U)[] +>[r7arg1, r7arg2] : ((x: (arg: T) => U) => (r: T) => U)[] >r7arg1 : (x: (arg: T) => U) => (r: T) => U >r7arg2 : (x: (arg: Base) => Derived) => (r: Base) => Derived var r7b = [r7arg2, r7arg1]; ->r7b : (((x: (arg: Base) => Derived) => (r: Base) => Derived) | ((x: (arg: T) => U) => (r: T) => U))[] ->[r7arg2, r7arg1] : (((x: (arg: Base) => Derived) => (r: Base) => Derived) | ((x: (arg: T) => U) => (r: T) => U))[] +>r7b : ((x: (arg: T) => U) => (r: T) => U)[] +>[r7arg2, r7arg1] : ((x: (arg: T) => U) => (r: T) => U)[] >r7arg2 : (x: (arg: Base) => Derived) => (r: Base) => Derived >r7arg1 : (x: (arg: T) => U) => (r: T) => U @@ -622,14 +622,14 @@ var r8 = foo8(r8arg1); // any >r8arg1 : (x: (arg: T) => U, y: (arg2: T) => U) => (r: T) => U var r8a = [r8arg1, r8arg2]; ->r8a : (((x: (arg: T) => U, y: (arg2: T) => U) => (r: T) => U) | ((x: (arg: Base) => Derived, y: (arg2: Base) => Derived) => (r: Base) => Derived))[] ->[r8arg1, r8arg2] : (((x: (arg: T) => U, y: (arg2: T) => U) => (r: T) => U) | ((x: (arg: Base) => Derived, y: (arg2: Base) => Derived) => (r: Base) => Derived))[] +>r8a : ((x: (arg: T) => U, y: (arg2: T) => U) => (r: T) => U)[] +>[r8arg1, r8arg2] : ((x: (arg: T) => U, y: (arg2: T) => U) => (r: T) => U)[] >r8arg1 : (x: (arg: T) => U, y: (arg2: T) => U) => (r: T) => U >r8arg2 : (x: (arg: Base) => Derived, y: (arg2: Base) => Derived) => (r: Base) => Derived var r8b = [r8arg2, r8arg1]; ->r8b : (((x: (arg: Base) => Derived, y: (arg2: Base) => Derived) => (r: Base) => Derived) | ((x: (arg: T) => U, y: (arg2: T) => U) => (r: T) => U))[] ->[r8arg2, r8arg1] : (((x: (arg: Base) => Derived, y: (arg2: Base) => Derived) => (r: Base) => Derived) | ((x: (arg: T) => U, y: (arg2: T) => U) => (r: T) => U))[] +>r8b : ((x: (arg: T) => U, y: (arg2: T) => U) => (r: T) => U)[] +>[r8arg2, r8arg1] : ((x: (arg: T) => U, y: (arg2: T) => U) => (r: T) => U)[] >r8arg2 : (x: (arg: Base) => Derived, y: (arg2: Base) => Derived) => (r: Base) => Derived >r8arg1 : (x: (arg: T) => U, y: (arg2: T) => U) => (r: T) => U @@ -681,14 +681,14 @@ var r9 = foo9(r9arg1); // any >r9arg1 : (x: (arg: T) => U, y: (arg2: { foo: string; bing: number; }) => U) => (r: T) => U var r9a = [r9arg1, r9arg2]; ->r9a : (((x: (arg: T) => U, y: (arg2: { foo: string; bing: number; }) => U) => (r: T) => U) | ((x: (arg: Base) => Derived, y: (arg2: Base) => Derived) => (r: Base) => Derived))[] ->[r9arg1, r9arg2] : (((x: (arg: T) => U, y: (arg2: { foo: string; bing: number; }) => U) => (r: T) => U) | ((x: (arg: Base) => Derived, y: (arg2: Base) => Derived) => (r: Base) => Derived))[] +>r9a : ((x: (arg: T) => U, y: (arg2: { foo: string; bing: number; }) => U) => (r: T) => U)[] +>[r9arg1, r9arg2] : ((x: (arg: T) => U, y: (arg2: { foo: string; bing: number; }) => U) => (r: T) => U)[] >r9arg1 : (x: (arg: T) => U, y: (arg2: { foo: string; bing: number; }) => U) => (r: T) => U >r9arg2 : (x: (arg: Base) => Derived, y: (arg2: Base) => Derived) => (r: Base) => Derived var r9b = [r9arg2, r9arg1]; ->r9b : (((x: (arg: Base) => Derived, y: (arg2: Base) => Derived) => (r: Base) => Derived) | ((x: (arg: T) => U, y: (arg2: { foo: string; bing: number; }) => U) => (r: T) => U))[] ->[r9arg2, r9arg1] : (((x: (arg: Base) => Derived, y: (arg2: Base) => Derived) => (r: Base) => Derived) | ((x: (arg: T) => U, y: (arg2: { foo: string; bing: number; }) => U) => (r: T) => U))[] +>r9b : ((x: (arg: T) => U, y: (arg2: { foo: string; bing: number; }) => U) => (r: T) => U)[] +>[r9arg2, r9arg1] : ((x: (arg: T) => U, y: (arg2: { foo: string; bing: number; }) => U) => (r: T) => U)[] >r9arg2 : (x: (arg: Base) => Derived, y: (arg2: Base) => Derived) => (r: Base) => Derived >r9arg1 : (x: (arg: T) => U, y: (arg2: { foo: string; bing: number; }) => U) => (r: T) => U @@ -719,14 +719,14 @@ var r10 = foo10(r10arg1); // any >r10arg1 : (...x: T[]) => T var r10a = [r10arg1, r10arg2]; ->r10a : (((...x: T[]) => T) | ((...x: Derived[]) => Derived))[] ->[r10arg1, r10arg2] : (((...x: T[]) => T) | ((...x: Derived[]) => Derived))[] +>r10a : ((...x: T[]) => T)[] +>[r10arg1, r10arg2] : ((...x: T[]) => T)[] >r10arg1 : (...x: T[]) => T >r10arg2 : (...x: Derived[]) => Derived var r10b = [r10arg2, r10arg1]; ->r10b : (((...x: Derived[]) => Derived) | ((...x: T[]) => T))[] ->[r10arg2, r10arg1] : (((...x: Derived[]) => Derived) | ((...x: T[]) => T))[] +>r10b : ((...x: T[]) => T)[] +>[r10arg2, r10arg1] : ((...x: T[]) => T)[] >r10arg2 : (...x: Derived[]) => Derived >r10arg1 : (...x: T[]) => T @@ -760,14 +760,14 @@ var r11 = foo11(r11arg1); // any >r11arg1 : (x: T, y: T) => T var r11a = [r11arg1, r11arg2]; ->r11a : (((x: T, y: T) => T) | ((x: { foo: string; }, y: { foo: string; bar: string; }) => Base))[] ->[r11arg1, r11arg2] : (((x: T, y: T) => T) | ((x: { foo: string; }, y: { foo: string; bar: string; }) => Base))[] +>r11a : ((x: T, y: T) => T)[] +>[r11arg1, r11arg2] : ((x: T, y: T) => T)[] >r11arg1 : (x: T, y: T) => T >r11arg2 : (x: { foo: string; }, y: { foo: string; bar: string; }) => Base var r11b = [r11arg2, r11arg1]; ->r11b : (((x: { foo: string; }, y: { foo: string; bar: string; }) => Base) | ((x: T, y: T) => T))[] ->[r11arg2, r11arg1] : (((x: { foo: string; }, y: { foo: string; bar: string; }) => Base) | ((x: T, y: T) => T))[] +>r11b : ((x: T, y: T) => T)[] +>[r11arg2, r11arg1] : ((x: T, y: T) => T)[] >r11arg2 : (x: { foo: string; }, y: { foo: string; bar: string; }) => Base >r11arg1 : (x: T, y: T) => T @@ -808,14 +808,14 @@ var r12 = foo12(r12arg1); // any >r12arg1 : (x: Base[], y: T) => Derived[] var r12a = [r12arg1, r12arg2]; ->r12a : (((x: Base[], y: T) => Derived[]) | ((x: Base[], y: Derived2[]) => Derived[]))[] ->[r12arg1, r12arg2] : (((x: Base[], y: T) => Derived[]) | ((x: Base[], y: Derived2[]) => Derived[]))[] +>r12a : ((x: Base[], y: T) => Derived[])[] +>[r12arg1, r12arg2] : ((x: Base[], y: T) => Derived[])[] >r12arg1 : (x: Base[], y: T) => Derived[] >r12arg2 : (x: Base[], y: Derived2[]) => Derived[] var r12b = [r12arg2, r12arg1]; ->r12b : (((x: Base[], y: Derived2[]) => Derived[]) | ((x: Base[], y: T) => Derived[]))[] ->[r12arg2, r12arg1] : (((x: Base[], y: Derived2[]) => Derived[]) | ((x: Base[], y: T) => Derived[]))[] +>r12b : ((x: Base[], y: Derived2[]) => Derived[])[] +>[r12arg2, r12arg1] : ((x: Base[], y: Derived2[]) => Derived[])[] >r12arg2 : (x: Base[], y: Derived2[]) => Derived[] >r12arg1 : (x: Base[], y: T) => Derived[] @@ -853,14 +853,14 @@ var r13 = foo13(r13arg1); // any >r13arg1 : (x: Base[], y: T) => T var r13a = [r13arg1, r13arg2]; ->r13a : (((x: Base[], y: T) => T) | ((x: Base[], y: Derived[]) => Derived[]))[] ->[r13arg1, r13arg2] : (((x: Base[], y: T) => T) | ((x: Base[], y: Derived[]) => Derived[]))[] +>r13a : ((x: Base[], y: T) => T)[] +>[r13arg1, r13arg2] : ((x: Base[], y: T) => T)[] >r13arg1 : (x: Base[], y: T) => T >r13arg2 : (x: Base[], y: Derived[]) => Derived[] var r13b = [r13arg2, r13arg1]; ->r13b : (((x: Base[], y: Derived[]) => Derived[]) | ((x: Base[], y: T) => T))[] ->[r13arg2, r13arg1] : (((x: Base[], y: Derived[]) => Derived[]) | ((x: Base[], y: T) => T))[] +>r13b : ((x: Base[], y: T) => T)[] +>[r13arg2, r13arg1] : ((x: Base[], y: T) => T)[] >r13arg2 : (x: Base[], y: Derived[]) => Derived[] >r13arg1 : (x: Base[], y: T) => T @@ -894,14 +894,14 @@ var r14 = foo14(r14arg1); // any >r14arg1 : (x: { a: T; b: T; }) => T var r14a = [r14arg1, r14arg2]; ->r14a : (((x: { a: T; b: T; }) => T) | ((x: { a: string; b: number; }) => Object))[] ->[r14arg1, r14arg2] : (((x: { a: T; b: T; }) => T) | ((x: { a: string; b: number; }) => Object))[] +>r14a : ((x: { a: T; b: T; }) => T)[] +>[r14arg1, r14arg2] : ((x: { a: T; b: T; }) => T)[] >r14arg1 : (x: { a: T; b: T; }) => T >r14arg2 : (x: { a: string; b: number; }) => Object var r14b = [r14arg2, r14arg1]; ->r14b : (((x: { a: string; b: number; }) => Object) | ((x: { a: T; b: T; }) => T))[] ->[r14arg2, r14arg1] : (((x: { a: string; b: number; }) => Object) | ((x: { a: T; b: T; }) => T))[] +>r14b : ((x: { a: T; b: T; }) => T)[] +>[r14arg2, r14arg1] : ((x: { a: T; b: T; }) => T)[] >r14arg2 : (x: { a: string; b: number; }) => Object >r14arg1 : (x: { a: T; b: T; }) => T diff --git a/tests/baselines/reference/subtypingWithCallSignatures3.types b/tests/baselines/reference/subtypingWithCallSignatures3.types index 0d3a84ac99c..2d4c6e9fda5 100644 --- a/tests/baselines/reference/subtypingWithCallSignatures3.types +++ b/tests/baselines/reference/subtypingWithCallSignatures3.types @@ -219,8 +219,8 @@ module Errors { >null : null var r1a = [(x: number) => [''], (x: T) => null]; ->r1a : (((x: number) => string[]) | ((x: T) => U[]))[] ->[(x: number) => [''], (x: T) => null] : (((x: number) => string[]) | ((x: T) => U[]))[] +>r1a : ((x: T) => U[])[] +>[(x: number) => [''], (x: T) => null] : ((x: T) => U[])[] >(x: number) => [''] : (x: number) => string[] >x : number >[''] : string[] @@ -235,8 +235,8 @@ module Errors { >null : null var r1b = [(x: T) => null, (x: number) => ['']]; ->r1b : (((x: T) => U[]) | ((x: number) => string[]))[] ->[(x: T) => null, (x: number) => ['']] : (((x: T) => U[]) | ((x: number) => string[]))[] +>r1b : ((x: T) => U[])[] +>[(x: T) => null, (x: number) => ['']] : ((x: T) => U[])[] >(x: T) => null : (x: T) => U[] >T : T >U : U @@ -291,14 +291,14 @@ module Errors { >r2arg : (x: (arg: T) => U) => (r: T) => V var r2a = [r2arg2, r2arg]; ->r2a : (((x: (arg: Base) => Derived) => (r: Base) => Derived2) | ((x: (arg: T) => U) => (r: T) => V))[] ->[r2arg2, r2arg] : (((x: (arg: Base) => Derived) => (r: Base) => Derived2) | ((x: (arg: T) => U) => (r: T) => V))[] +>r2a : ((x: (arg: T) => U) => (r: T) => V)[] +>[r2arg2, r2arg] : ((x: (arg: T) => U) => (r: T) => V)[] >r2arg2 : (x: (arg: Base) => Derived) => (r: Base) => Derived2 >r2arg : (x: (arg: T) => U) => (r: T) => V var r2b = [r2arg, r2arg2]; ->r2b : (((x: (arg: T) => U) => (r: T) => V) | ((x: (arg: Base) => Derived) => (r: Base) => Derived2))[] ->[r2arg, r2arg2] : (((x: (arg: T) => U) => (r: T) => V) | ((x: (arg: Base) => Derived) => (r: Base) => Derived2))[] +>r2b : ((x: (arg: T) => U) => (r: T) => V)[] +>[r2arg, r2arg2] : ((x: (arg: T) => U) => (r: T) => V)[] >r2arg : (x: (arg: T) => U) => (r: T) => V >r2arg2 : (x: (arg: Base) => Derived) => (r: Base) => Derived2 @@ -387,14 +387,14 @@ module Errors { >r4arg : (...x: T[]) => T var r4a = [r4arg2, r4arg]; ->r4a : (((...x: Base[]) => Base) | ((...x: T[]) => T))[] ->[r4arg2, r4arg] : (((...x: Base[]) => Base) | ((...x: T[]) => T))[] +>r4a : ((...x: T[]) => T)[] +>[r4arg2, r4arg] : ((...x: T[]) => T)[] >r4arg2 : (...x: Base[]) => Base >r4arg : (...x: T[]) => T var r4b = [r4arg, r4arg2]; ->r4b : (((...x: T[]) => T) | ((...x: Base[]) => Base))[] ->[r4arg, r4arg2] : (((...x: T[]) => T) | ((...x: Base[]) => Base))[] +>r4b : ((...x: T[]) => T)[] +>[r4arg, r4arg2] : ((...x: T[]) => T)[] >r4arg : (...x: T[]) => T >r4arg2 : (...x: Base[]) => Base @@ -430,14 +430,14 @@ module Errors { >r5arg : (x: T, y: T) => T var r5a = [r5arg2, r5arg]; ->r5a : (((x: { foo: string; }, y: { foo: string; bar: string; }) => Base) | ((x: T, y: T) => T))[] ->[r5arg2, r5arg] : (((x: { foo: string; }, y: { foo: string; bar: string; }) => Base) | ((x: T, y: T) => T))[] +>r5a : ((x: T, y: T) => T)[] +>[r5arg2, r5arg] : ((x: T, y: T) => T)[] >r5arg2 : (x: { foo: string; }, y: { foo: string; bar: string; }) => Base >r5arg : (x: T, y: T) => T var r5b = [r5arg, r5arg2]; ->r5b : (((x: T, y: T) => T) | ((x: { foo: string; }, y: { foo: string; bar: string; }) => Base))[] ->[r5arg, r5arg2] : (((x: T, y: T) => T) | ((x: { foo: string; }, y: { foo: string; bar: string; }) => Base))[] +>r5b : ((x: T, y: T) => T)[] +>[r5arg, r5arg2] : ((x: T, y: T) => T)[] >r5arg : (x: T, y: T) => T >r5arg2 : (x: { foo: string; }, y: { foo: string; bar: string; }) => Base @@ -478,14 +478,14 @@ module Errors { >r6arg : (x: Base[], y: Derived2[]) => Derived[] var r6a = [r6arg2, r6arg]; ->r6a : (((x: Base[], y: Base[]) => T) | ((x: Base[], y: Derived2[]) => Derived[]))[] ->[r6arg2, r6arg] : (((x: Base[], y: Base[]) => T) | ((x: Base[], y: Derived2[]) => Derived[]))[] +>r6a : ((x: Base[], y: Base[]) => T)[] +>[r6arg2, r6arg] : ((x: Base[], y: Base[]) => T)[] >r6arg2 : (x: Base[], y: Base[]) => T >r6arg : (x: Base[], y: Derived2[]) => Derived[] var r6b = [r6arg, r6arg2]; ->r6b : (((x: Base[], y: Derived2[]) => Derived[]) | ((x: Base[], y: Base[]) => T))[] ->[r6arg, r6arg2] : (((x: Base[], y: Derived2[]) => Derived[]) | ((x: Base[], y: Base[]) => T))[] +>r6b : ((x: Base[], y: Base[]) => T)[] +>[r6arg, r6arg2] : ((x: Base[], y: Base[]) => T)[] >r6arg : (x: Base[], y: Derived2[]) => Derived[] >r6arg2 : (x: Base[], y: Base[]) => T @@ -517,14 +517,14 @@ module Errors { >r7arg : (x: { a: T; b: T; }) => T var r7a = [r7arg2, r7arg]; ->r7a : (((x: { a: string; b: number; }) => number) | ((x: { a: T; b: T; }) => T))[] ->[r7arg2, r7arg] : (((x: { a: string; b: number; }) => number) | ((x: { a: T; b: T; }) => T))[] +>r7a : ((x: { a: T; b: T; }) => T)[] +>[r7arg2, r7arg] : ((x: { a: T; b: T; }) => T)[] >r7arg2 : (x: { a: string; b: number; }) => number >r7arg : (x: { a: T; b: T; }) => T var r7b = [r7arg, r7arg2]; ->r7b : (((x: { a: T; b: T; }) => T) | ((x: { a: string; b: number; }) => number))[] ->[r7arg, r7arg2] : (((x: { a: T; b: T; }) => T) | ((x: { a: string; b: number; }) => number))[] +>r7b : ((x: { a: T; b: T; }) => T)[] +>[r7arg, r7arg2] : ((x: { a: T; b: T; }) => T)[] >r7arg : (x: { a: T; b: T; }) => T >r7arg2 : (x: { a: string; b: number; }) => number @@ -547,14 +547,14 @@ module Errors { >r7arg3 : (x: { a: T; b: T; }) => number var r7d = [r7arg2, r7arg3]; ->r7d : (((x: { a: string; b: number; }) => number) | ((x: { a: T; b: T; }) => number))[] ->[r7arg2, r7arg3] : (((x: { a: string; b: number; }) => number) | ((x: { a: T; b: T; }) => number))[] +>r7d : ((x: { a: string; b: number; }) => number)[] +>[r7arg2, r7arg3] : ((x: { a: string; b: number; }) => number)[] >r7arg2 : (x: { a: string; b: number; }) => number >r7arg3 : (x: { a: T; b: T; }) => number var r7e = [r7arg3, r7arg2]; ->r7e : (((x: { a: T; b: T; }) => number) | ((x: { a: string; b: number; }) => number))[] ->[r7arg3, r7arg2] : (((x: { a: T; b: T; }) => number) | ((x: { a: string; b: number; }) => number))[] +>r7e : ((x: { a: T; b: T; }) => number)[] +>[r7arg3, r7arg2] : ((x: { a: T; b: T; }) => number)[] >r7arg3 : (x: { a: T; b: T; }) => number >r7arg2 : (x: { a: string; b: number; }) => number diff --git a/tests/baselines/reference/subtypingWithCallSignatures4.types b/tests/baselines/reference/subtypingWithCallSignatures4.types index 830f065f556..f490f787878 100644 --- a/tests/baselines/reference/subtypingWithCallSignatures4.types +++ b/tests/baselines/reference/subtypingWithCallSignatures4.types @@ -317,14 +317,14 @@ var r3 = foo3(r3arg); >r3arg : (x: T) => T var r3a = [r3arg, r3arg2]; ->r3a : (((x: T) => T) | ((x: T) => void))[] ->[r3arg, r3arg2] : (((x: T) => T) | ((x: T) => void))[] +>r3a : ((x: T) => T)[] +>[r3arg, r3arg2] : ((x: T) => T)[] >r3arg : (x: T) => T >r3arg2 : (x: T) => void var r3b = [r3arg2, r3arg]; ->r3b : (((x: T) => void) | ((x: T) => T))[] ->[r3arg2, r3arg] : (((x: T) => void) | ((x: T) => T))[] +>r3b : ((x: T) => void)[] +>[r3arg2, r3arg] : ((x: T) => void)[] >r3arg2 : (x: T) => void >r3arg : (x: T) => T @@ -447,14 +447,14 @@ var r6 = foo6(r6arg); >r6arg : (x: (arg: T) => U) => T var r6a = [r6arg, r6arg2]; ->r6a : (((x: (arg: T) => U) => T) | ((x: (arg: T) => Derived) => T))[] ->[r6arg, r6arg2] : (((x: (arg: T) => U) => T) | ((x: (arg: T) => Derived) => T))[] +>r6a : ((x: (arg: T) => U) => T)[] +>[r6arg, r6arg2] : ((x: (arg: T) => U) => T)[] >r6arg : (x: (arg: T) => U) => T >r6arg2 : (x: (arg: T) => Derived) => T var r6b = [r6arg2, r6arg]; ->r6b : (((x: (arg: T) => Derived) => T) | ((x: (arg: T) => U) => T))[] ->[r6arg2, r6arg] : (((x: (arg: T) => Derived) => T) | ((x: (arg: T) => U) => T))[] +>r6b : ((x: (arg: T) => Derived) => T)[] +>[r6arg2, r6arg] : ((x: (arg: T) => Derived) => T)[] >r6arg2 : (x: (arg: T) => Derived) => T >r6arg : (x: (arg: T) => U) => T @@ -498,14 +498,14 @@ var r11 = foo11(r11arg); >r11arg : (x: { foo: T; }, y: { foo: U; bar: U; }) => Base var r11a = [r11arg, r11arg2]; ->r11a : (((x: { foo: T; }, y: { foo: U; bar: U; }) => Base) | ((x: { foo: T; }, y: { foo: T; bar: T; }) => Base))[] ->[r11arg, r11arg2] : (((x: { foo: T; }, y: { foo: U; bar: U; }) => Base) | ((x: { foo: T; }, y: { foo: T; bar: T; }) => Base))[] +>r11a : ((x: { foo: T; }, y: { foo: U; bar: U; }) => Base)[] +>[r11arg, r11arg2] : ((x: { foo: T; }, y: { foo: U; bar: U; }) => Base)[] >r11arg : (x: { foo: T; }, y: { foo: U; bar: U; }) => Base >r11arg2 : (x: { foo: T; }, y: { foo: T; bar: T; }) => Base var r11b = [r11arg2, r11arg]; ->r11b : (((x: { foo: T; }, y: { foo: T; bar: T; }) => Base) | ((x: { foo: T; }, y: { foo: U; bar: U; }) => Base))[] ->[r11arg2, r11arg] : (((x: { foo: T; }, y: { foo: T; bar: T; }) => Base) | ((x: { foo: T; }, y: { foo: U; bar: U; }) => Base))[] +>r11b : ((x: { foo: T; }, y: { foo: T; bar: T; }) => Base)[] +>[r11arg2, r11arg] : ((x: { foo: T; }, y: { foo: T; bar: T; }) => Base)[] >r11arg2 : (x: { foo: T; }, y: { foo: T; bar: T; }) => Base >r11arg : (x: { foo: T; }, y: { foo: U; bar: U; }) => Base @@ -543,14 +543,14 @@ var r15 = foo15(r15arg); >r15arg : (x: { a: U; b: V; }) => U[] var r15a = [r15arg, r15arg2]; ->r15a : (((x: { a: U; b: V; }) => U[]) | ((x: { a: T; b: T; }) => T[]))[] ->[r15arg, r15arg2] : (((x: { a: U; b: V; }) => U[]) | ((x: { a: T; b: T; }) => T[]))[] +>r15a : ((x: { a: U; b: V; }) => U[])[] +>[r15arg, r15arg2] : ((x: { a: U; b: V; }) => U[])[] >r15arg : (x: { a: U; b: V; }) => U[] >r15arg2 : (x: { a: T; b: T; }) => T[] var r15b = [r15arg2, r15arg]; ->r15b : (((x: { a: T; b: T; }) => T[]) | ((x: { a: U; b: V; }) => U[]))[] ->[r15arg2, r15arg] : (((x: { a: T; b: T; }) => T[]) | ((x: { a: U; b: V; }) => U[]))[] +>r15b : ((x: { a: T; b: T; }) => T[])[] +>[r15arg2, r15arg] : ((x: { a: T; b: T; }) => T[])[] >r15arg2 : (x: { a: T; b: T; }) => T[] >r15arg : (x: { a: U; b: V; }) => U[] diff --git a/tests/baselines/reference/subtypingWithConstructSignatures2.types b/tests/baselines/reference/subtypingWithConstructSignatures2.types index f00ad0332ca..c66d6055558 100644 --- a/tests/baselines/reference/subtypingWithConstructSignatures2.types +++ b/tests/baselines/reference/subtypingWithConstructSignatures2.types @@ -326,14 +326,14 @@ var r1 = foo1(r1arg1); // any, return types are not subtype of first overload >r1arg1 : new (x: T) => T[] var r1a = [r1arg2, r1arg1]; // generic signature, subtype in both directions ->r1a : ((new (x: number) => number[]) | (new (x: T) => T[]))[] ->[r1arg2, r1arg1] : ((new (x: number) => number[]) | (new (x: T) => T[]))[] +>r1a : (new (x: T) => T[])[] +>[r1arg2, r1arg1] : (new (x: T) => T[])[] >r1arg2 : new (x: number) => number[] >r1arg1 : new (x: T) => T[] var r1b = [r1arg1, r1arg2]; // generic signature, subtype in both directions ->r1b : ((new (x: T) => T[]) | (new (x: number) => number[]))[] ->[r1arg1, r1arg2] : ((new (x: T) => T[]) | (new (x: number) => number[]))[] +>r1b : (new (x: T) => T[])[] +>[r1arg1, r1arg2] : (new (x: T) => T[])[] >r1arg1 : new (x: T) => T[] >r1arg2 : new (x: number) => number[] @@ -354,14 +354,14 @@ var r2 = foo2(r2arg1); >r2arg1 : new (x: T) => string[] var r2a = [r2arg1, r2arg2]; ->r2a : ((new (x: T) => string[]) | (new (x: number) => string[]))[] ->[r2arg1, r2arg2] : ((new (x: T) => string[]) | (new (x: number) => string[]))[] +>r2a : (new (x: T) => string[])[] +>[r2arg1, r2arg2] : (new (x: T) => string[])[] >r2arg1 : new (x: T) => string[] >r2arg2 : new (x: number) => string[] var r2b = [r2arg2, r2arg1]; ->r2b : ((new (x: number) => string[]) | (new (x: T) => string[]))[] ->[r2arg2, r2arg1] : ((new (x: number) => string[]) | (new (x: T) => string[]))[] +>r2b : (new (x: number) => string[])[] +>[r2arg2, r2arg1] : (new (x: number) => string[])[] >r2arg2 : new (x: number) => string[] >r2arg1 : new (x: T) => string[] @@ -383,14 +383,14 @@ var r3 = foo3(r3arg1); >r3arg1 : new (x: T) => T var r3a = [r3arg1, r3arg2]; ->r3a : ((new (x: T) => T) | (new (x: number) => void))[] ->[r3arg1, r3arg2] : ((new (x: T) => T) | (new (x: number) => void))[] +>r3a : (new (x: T) => T)[] +>[r3arg1, r3arg2] : (new (x: T) => T)[] >r3arg1 : new (x: T) => T >r3arg2 : new (x: number) => void var r3b = [r3arg2, r3arg1]; ->r3b : ((new (x: number) => void) | (new (x: T) => T))[] ->[r3arg2, r3arg1] : ((new (x: number) => void) | (new (x: T) => T))[] +>r3b : (new (x: number) => void)[] +>[r3arg2, r3arg1] : (new (x: number) => void)[] >r3arg2 : new (x: number) => void >r3arg1 : new (x: T) => T @@ -416,14 +416,14 @@ var r4 = foo4(r4arg1); // any >r4arg1 : new (x: T, y: U) => T var r4a = [r4arg1, r4arg2]; ->r4a : ((new (x: T, y: U) => T) | (new (x: string, y: number) => string))[] ->[r4arg1, r4arg2] : ((new (x: T, y: U) => T) | (new (x: string, y: number) => string))[] +>r4a : (new (x: T, y: U) => T)[] +>[r4arg1, r4arg2] : (new (x: T, y: U) => T)[] >r4arg1 : new (x: T, y: U) => T >r4arg2 : new (x: string, y: number) => string var r4b = [r4arg2, r4arg1]; ->r4b : ((new (x: string, y: number) => string) | (new (x: T, y: U) => T))[] ->[r4arg2, r4arg1] : ((new (x: string, y: number) => string) | (new (x: T, y: U) => T))[] +>r4b : (new (x: T, y: U) => T)[] +>[r4arg2, r4arg1] : (new (x: T, y: U) => T)[] >r4arg2 : new (x: string, y: number) => string >r4arg1 : new (x: T, y: U) => T @@ -449,14 +449,14 @@ var r5 = foo5(r5arg1); // any >r5arg1 : new (x: new (arg: T) => U) => T var r5a = [r5arg1, r5arg2]; ->r5a : ((new (x: new (arg: T) => U) => T) | (new (x: new (arg: string) => number) => string))[] ->[r5arg1, r5arg2] : ((new (x: new (arg: T) => U) => T) | (new (x: new (arg: string) => number) => string))[] +>r5a : (new (x: new (arg: T) => U) => T)[] +>[r5arg1, r5arg2] : (new (x: new (arg: T) => U) => T)[] >r5arg1 : new (x: new (arg: T) => U) => T >r5arg2 : new (x: new (arg: string) => number) => string var r5b = [r5arg2, r5arg1]; ->r5b : ((new (x: new (arg: string) => number) => string) | (new (x: new (arg: T) => U) => T))[] ->[r5arg2, r5arg1] : ((new (x: new (arg: string) => number) => string) | (new (x: new (arg: T) => U) => T))[] +>r5b : (new (x: new (arg: T) => U) => T)[] +>[r5arg2, r5arg1] : (new (x: new (arg: T) => U) => T)[] >r5arg2 : new (x: new (arg: string) => number) => string >r5arg1 : new (x: new (arg: T) => U) => T @@ -487,14 +487,14 @@ var r6 = foo6(r6arg1); // any >r6arg1 : new (x: new (arg: T) => U) => T var r6a = [r6arg1, r6arg2]; ->r6a : ((new (x: new (arg: T) => U) => T) | (new (x: new (arg: Base) => Derived) => Base))[] ->[r6arg1, r6arg2] : ((new (x: new (arg: T) => U) => T) | (new (x: new (arg: Base) => Derived) => Base))[] +>r6a : (new (x: new (arg: T) => U) => T)[] +>[r6arg1, r6arg2] : (new (x: new (arg: T) => U) => T)[] >r6arg1 : new (x: new (arg: T) => U) => T >r6arg2 : new (x: new (arg: Base) => Derived) => Base var r6b = [r6arg2, r6arg1]; ->r6b : ((new (x: new (arg: Base) => Derived) => Base) | (new (x: new (arg: T) => U) => T))[] ->[r6arg2, r6arg1] : ((new (x: new (arg: Base) => Derived) => Base) | (new (x: new (arg: T) => U) => T))[] +>r6b : (new (x: new (arg: T) => U) => T)[] +>[r6arg2, r6arg1] : (new (x: new (arg: T) => U) => T)[] >r6arg2 : new (x: new (arg: Base) => Derived) => Base >r6arg1 : new (x: new (arg: T) => U) => T @@ -529,14 +529,14 @@ var r7 = foo7(r7arg1); // any >r7arg1 : new (x: new (arg: T) => U) => new (r: T) => U var r7a = [r7arg1, r7arg2]; ->r7a : ((new (x: new (arg: T) => U) => new (r: T) => U) | (new (x: new (arg: Base) => Derived) => new (r: Base) => Derived))[] ->[r7arg1, r7arg2] : ((new (x: new (arg: T) => U) => new (r: T) => U) | (new (x: new (arg: Base) => Derived) => new (r: Base) => Derived))[] +>r7a : (new (x: new (arg: T) => U) => new (r: T) => U)[] +>[r7arg1, r7arg2] : (new (x: new (arg: T) => U) => new (r: T) => U)[] >r7arg1 : new (x: new (arg: T) => U) => new (r: T) => U >r7arg2 : new (x: new (arg: Base) => Derived) => new (r: Base) => Derived var r7b = [r7arg2, r7arg1]; ->r7b : ((new (x: new (arg: Base) => Derived) => new (r: Base) => Derived) | (new (x: new (arg: T) => U) => new (r: T) => U))[] ->[r7arg2, r7arg1] : ((new (x: new (arg: Base) => Derived) => new (r: Base) => Derived) | (new (x: new (arg: T) => U) => new (r: T) => U))[] +>r7b : (new (x: new (arg: T) => U) => new (r: T) => U)[] +>[r7arg2, r7arg1] : (new (x: new (arg: T) => U) => new (r: T) => U)[] >r7arg2 : new (x: new (arg: Base) => Derived) => new (r: Base) => Derived >r7arg1 : new (x: new (arg: T) => U) => new (r: T) => U @@ -579,14 +579,14 @@ var r8 = foo8(r8arg1); // any >r8arg1 : new (x: new (arg: T) => U, y: new (arg2: T) => U) => new (r: T) => U var r8a = [r8arg1, r8arg2]; ->r8a : ((new (x: new (arg: T) => U, y: new (arg2: T) => U) => new (r: T) => U) | (new (x: new (arg: Base) => Derived, y: new (arg2: Base) => Derived) => new (r: Base) => Derived))[] ->[r8arg1, r8arg2] : ((new (x: new (arg: T) => U, y: new (arg2: T) => U) => new (r: T) => U) | (new (x: new (arg: Base) => Derived, y: new (arg2: Base) => Derived) => new (r: Base) => Derived))[] +>r8a : (new (x: new (arg: T) => U, y: new (arg2: T) => U) => new (r: T) => U)[] +>[r8arg1, r8arg2] : (new (x: new (arg: T) => U, y: new (arg2: T) => U) => new (r: T) => U)[] >r8arg1 : new (x: new (arg: T) => U, y: new (arg2: T) => U) => new (r: T) => U >r8arg2 : new (x: new (arg: Base) => Derived, y: new (arg2: Base) => Derived) => new (r: Base) => Derived var r8b = [r8arg2, r8arg1]; ->r8b : ((new (x: new (arg: Base) => Derived, y: new (arg2: Base) => Derived) => new (r: Base) => Derived) | (new (x: new (arg: T) => U, y: new (arg2: T) => U) => new (r: T) => U))[] ->[r8arg2, r8arg1] : ((new (x: new (arg: Base) => Derived, y: new (arg2: Base) => Derived) => new (r: Base) => Derived) | (new (x: new (arg: T) => U, y: new (arg2: T) => U) => new (r: T) => U))[] +>r8b : (new (x: new (arg: T) => U, y: new (arg2: T) => U) => new (r: T) => U)[] +>[r8arg2, r8arg1] : (new (x: new (arg: T) => U, y: new (arg2: T) => U) => new (r: T) => U)[] >r8arg2 : new (x: new (arg: Base) => Derived, y: new (arg2: Base) => Derived) => new (r: Base) => Derived >r8arg1 : new (x: new (arg: T) => U, y: new (arg2: T) => U) => new (r: T) => U @@ -662,14 +662,14 @@ var r10 = foo10(r10arg1); // any >r10arg1 : new (...x: T[]) => T var r10a = [r10arg1, r10arg2]; ->r10a : ((new (...x: T[]) => T) | (new (...x: Derived[]) => Derived))[] ->[r10arg1, r10arg2] : ((new (...x: T[]) => T) | (new (...x: Derived[]) => Derived))[] +>r10a : (new (...x: T[]) => T)[] +>[r10arg1, r10arg2] : (new (...x: T[]) => T)[] >r10arg1 : new (...x: T[]) => T >r10arg2 : new (...x: Derived[]) => Derived var r10b = [r10arg2, r10arg1]; ->r10b : ((new (...x: Derived[]) => Derived) | (new (...x: T[]) => T))[] ->[r10arg2, r10arg1] : ((new (...x: Derived[]) => Derived) | (new (...x: T[]) => T))[] +>r10b : (new (...x: T[]) => T)[] +>[r10arg2, r10arg1] : (new (...x: T[]) => T)[] >r10arg2 : new (...x: Derived[]) => Derived >r10arg1 : new (...x: T[]) => T @@ -699,14 +699,14 @@ var r11 = foo11(r11arg1); // any >r11arg1 : new (x: T, y: T) => T var r11a = [r11arg1, r11arg2]; ->r11a : ((new (x: T, y: T) => T) | (new (x: { foo: string; }, y: { foo: string; bar: string; }) => Base))[] ->[r11arg1, r11arg2] : ((new (x: T, y: T) => T) | (new (x: { foo: string; }, y: { foo: string; bar: string; }) => Base))[] +>r11a : (new (x: T, y: T) => T)[] +>[r11arg1, r11arg2] : (new (x: T, y: T) => T)[] >r11arg1 : new (x: T, y: T) => T >r11arg2 : new (x: { foo: string; }, y: { foo: string; bar: string; }) => Base var r11b = [r11arg2, r11arg1]; ->r11b : ((new (x: { foo: string; }, y: { foo: string; bar: string; }) => Base) | (new (x: T, y: T) => T))[] ->[r11arg2, r11arg1] : ((new (x: { foo: string; }, y: { foo: string; bar: string; }) => Base) | (new (x: T, y: T) => T))[] +>r11b : (new (x: T, y: T) => T)[] +>[r11arg2, r11arg1] : (new (x: T, y: T) => T)[] >r11arg2 : new (x: { foo: string; }, y: { foo: string; bar: string; }) => Base >r11arg1 : new (x: T, y: T) => T @@ -741,14 +741,14 @@ var r12 = foo12(r12arg1); // any >r12arg1 : new (x: Base[], y: T) => Derived[] var r12a = [r12arg1, r12arg2]; ->r12a : ((new (x: Base[], y: T) => Derived[]) | (new (x: Base[], y: Derived2[]) => Derived[]))[] ->[r12arg1, r12arg2] : ((new (x: Base[], y: T) => Derived[]) | (new (x: Base[], y: Derived2[]) => Derived[]))[] +>r12a : (new (x: Base[], y: T) => Derived[])[] +>[r12arg1, r12arg2] : (new (x: Base[], y: T) => Derived[])[] >r12arg1 : new (x: Base[], y: T) => Derived[] >r12arg2 : new (x: Base[], y: Derived2[]) => Derived[] var r12b = [r12arg2, r12arg1]; ->r12b : ((new (x: Base[], y: Derived2[]) => Derived[]) | (new (x: Base[], y: T) => Derived[]))[] ->[r12arg2, r12arg1] : ((new (x: Base[], y: Derived2[]) => Derived[]) | (new (x: Base[], y: T) => Derived[]))[] +>r12b : (new (x: Base[], y: Derived2[]) => Derived[])[] +>[r12arg2, r12arg1] : (new (x: Base[], y: Derived2[]) => Derived[])[] >r12arg2 : new (x: Base[], y: Derived2[]) => Derived[] >r12arg1 : new (x: Base[], y: T) => Derived[] @@ -782,14 +782,14 @@ var r13 = foo13(r13arg1); // any >r13arg1 : new (x: Base[], y: T) => T var r13a = [r13arg1, r13arg2]; ->r13a : ((new (x: Base[], y: T) => T) | (new (x: Base[], y: Derived[]) => Derived[]))[] ->[r13arg1, r13arg2] : ((new (x: Base[], y: T) => T) | (new (x: Base[], y: Derived[]) => Derived[]))[] +>r13a : (new (x: Base[], y: T) => T)[] +>[r13arg1, r13arg2] : (new (x: Base[], y: T) => T)[] >r13arg1 : new (x: Base[], y: T) => T >r13arg2 : new (x: Base[], y: Derived[]) => Derived[] var r13b = [r13arg2, r13arg1]; ->r13b : ((new (x: Base[], y: Derived[]) => Derived[]) | (new (x: Base[], y: T) => T))[] ->[r13arg2, r13arg1] : ((new (x: Base[], y: Derived[]) => Derived[]) | (new (x: Base[], y: T) => T))[] +>r13b : (new (x: Base[], y: T) => T)[] +>[r13arg2, r13arg1] : (new (x: Base[], y: T) => T)[] >r13arg2 : new (x: Base[], y: Derived[]) => Derived[] >r13arg1 : new (x: Base[], y: T) => T @@ -817,14 +817,14 @@ var r14 = foo14(r14arg1); // any >r14arg1 : new (x: { a: T; b: T; }) => T var r14a = [r14arg1, r14arg2]; ->r14a : ((new (x: { a: T; b: T; }) => T) | (new (x: { a: string; b: number; }) => Object))[] ->[r14arg1, r14arg2] : ((new (x: { a: T; b: T; }) => T) | (new (x: { a: string; b: number; }) => Object))[] +>r14a : (new (x: { a: T; b: T; }) => T)[] +>[r14arg1, r14arg2] : (new (x: { a: T; b: T; }) => T)[] >r14arg1 : new (x: { a: T; b: T; }) => T >r14arg2 : new (x: { a: string; b: number; }) => Object var r14b = [r14arg2, r14arg1]; ->r14b : ((new (x: { a: string; b: number; }) => Object) | (new (x: { a: T; b: T; }) => T))[] ->[r14arg2, r14arg1] : ((new (x: { a: string; b: number; }) => Object) | (new (x: { a: T; b: T; }) => T))[] +>r14b : (new (x: { a: T; b: T; }) => T)[] +>[r14arg2, r14arg1] : (new (x: { a: T; b: T; }) => T)[] >r14arg2 : new (x: { a: string; b: number; }) => Object >r14arg1 : new (x: { a: T; b: T; }) => T diff --git a/tests/baselines/reference/subtypingWithConstructSignatures3.types b/tests/baselines/reference/subtypingWithConstructSignatures3.types index b7c90d8697e..741db4f4ba6 100644 --- a/tests/baselines/reference/subtypingWithConstructSignatures3.types +++ b/tests/baselines/reference/subtypingWithConstructSignatures3.types @@ -224,14 +224,14 @@ module Errors { >r1arg1 : new (x: T) => U[] var r1a = [r1arg2, r1arg1]; ->r1a : ((new (x: number) => string[]) | (new (x: T) => U[]))[] ->[r1arg2, r1arg1] : ((new (x: number) => string[]) | (new (x: T) => U[]))[] +>r1a : (new (x: T) => U[])[] +>[r1arg2, r1arg1] : (new (x: T) => U[])[] >r1arg2 : new (x: number) => string[] >r1arg1 : new (x: T) => U[] var r1b = [r1arg1, r1arg2]; ->r1b : ((new (x: T) => U[]) | (new (x: number) => string[]))[] ->[r1arg1, r1arg2] : ((new (x: T) => U[]) | (new (x: number) => string[]))[] +>r1b : (new (x: T) => U[])[] +>[r1arg1, r1arg2] : (new (x: T) => U[])[] >r1arg1 : new (x: T) => U[] >r1arg2 : new (x: number) => string[] @@ -268,14 +268,14 @@ module Errors { >r2arg1 : new (x: new (arg: T) => U) => new (r: T) => V var r2a = [r2arg2, r2arg1]; ->r2a : ((new (x: new (arg: Base) => Derived) => new (r: Base) => Derived2) | (new (x: new (arg: T) => U) => new (r: T) => V))[] ->[r2arg2, r2arg1] : ((new (x: new (arg: Base) => Derived) => new (r: Base) => Derived2) | (new (x: new (arg: T) => U) => new (r: T) => V))[] +>r2a : (new (x: new (arg: T) => U) => new (r: T) => V)[] +>[r2arg2, r2arg1] : (new (x: new (arg: T) => U) => new (r: T) => V)[] >r2arg2 : new (x: new (arg: Base) => Derived) => new (r: Base) => Derived2 >r2arg1 : new (x: new (arg: T) => U) => new (r: T) => V var r2b = [r2arg1, r2arg2]; ->r2b : ((new (x: new (arg: T) => U) => new (r: T) => V) | (new (x: new (arg: Base) => Derived) => new (r: Base) => Derived2))[] ->[r2arg1, r2arg2] : ((new (x: new (arg: T) => U) => new (r: T) => V) | (new (x: new (arg: Base) => Derived) => new (r: Base) => Derived2))[] +>r2b : (new (x: new (arg: T) => U) => new (r: T) => V)[] +>[r2arg1, r2arg2] : (new (x: new (arg: T) => U) => new (r: T) => V)[] >r2arg1 : new (x: new (arg: T) => U) => new (r: T) => V >r2arg2 : new (x: new (arg: Base) => Derived) => new (r: Base) => Derived2 @@ -350,14 +350,14 @@ module Errors { >r4arg1 : new (...x: T[]) => T var r4a = [r4arg2, r4arg1]; ->r4a : ((new (...x: Base[]) => Base) | (new (...x: T[]) => T))[] ->[r4arg2, r4arg1] : ((new (...x: Base[]) => Base) | (new (...x: T[]) => T))[] +>r4a : (new (...x: T[]) => T)[] +>[r4arg2, r4arg1] : (new (...x: T[]) => T)[] >r4arg2 : new (...x: Base[]) => Base >r4arg1 : new (...x: T[]) => T var r4b = [r4arg1, r4arg2]; ->r4b : ((new (...x: T[]) => T) | (new (...x: Base[]) => Base))[] ->[r4arg1, r4arg2] : ((new (...x: T[]) => T) | (new (...x: Base[]) => Base))[] +>r4b : (new (...x: T[]) => T)[] +>[r4arg1, r4arg2] : (new (...x: T[]) => T)[] >r4arg1 : new (...x: T[]) => T >r4arg2 : new (...x: Base[]) => Base @@ -387,14 +387,14 @@ module Errors { >r5arg1 : new (x: T, y: T) => T var r5a = [r5arg2, r5arg1]; ->r5a : ((new (x: { foo: string; }, y: { foo: string; bar: string; }) => Base) | (new (x: T, y: T) => T))[] ->[r5arg2, r5arg1] : ((new (x: { foo: string; }, y: { foo: string; bar: string; }) => Base) | (new (x: T, y: T) => T))[] +>r5a : (new (x: T, y: T) => T)[] +>[r5arg2, r5arg1] : (new (x: T, y: T) => T)[] >r5arg2 : new (x: { foo: string; }, y: { foo: string; bar: string; }) => Base >r5arg1 : new (x: T, y: T) => T var r5b = [r5arg1, r5arg2]; ->r5b : ((new (x: T, y: T) => T) | (new (x: { foo: string; }, y: { foo: string; bar: string; }) => Base))[] ->[r5arg1, r5arg2] : ((new (x: T, y: T) => T) | (new (x: { foo: string; }, y: { foo: string; bar: string; }) => Base))[] +>r5b : (new (x: T, y: T) => T)[] +>[r5arg1, r5arg2] : (new (x: T, y: T) => T)[] >r5arg1 : new (x: T, y: T) => T >r5arg2 : new (x: { foo: string; }, y: { foo: string; bar: string; }) => Base @@ -429,14 +429,14 @@ module Errors { >r6arg1 : new (x: Base[], y: Derived2[]) => Derived[] var r6a = [r6arg2, r6arg1]; ->r6a : ((new (x: Base[], y: Base[]) => T) | (new (x: Base[], y: Derived2[]) => Derived[]))[] ->[r6arg2, r6arg1] : ((new (x: Base[], y: Base[]) => T) | (new (x: Base[], y: Derived2[]) => Derived[]))[] +>r6a : (new (x: Base[], y: Base[]) => T)[] +>[r6arg2, r6arg1] : (new (x: Base[], y: Base[]) => T)[] >r6arg2 : new (x: Base[], y: Base[]) => T >r6arg1 : new (x: Base[], y: Derived2[]) => Derived[] var r6b = [r6arg1, r6arg2]; ->r6b : ((new (x: Base[], y: Derived2[]) => Derived[]) | (new (x: Base[], y: Base[]) => T))[] ->[r6arg1, r6arg2] : ((new (x: Base[], y: Derived2[]) => Derived[]) | (new (x: Base[], y: Base[]) => T))[] +>r6b : (new (x: Base[], y: Base[]) => T)[] +>[r6arg1, r6arg2] : (new (x: Base[], y: Base[]) => T)[] >r6arg1 : new (x: Base[], y: Derived2[]) => Derived[] >r6arg2 : new (x: Base[], y: Base[]) => T @@ -463,14 +463,14 @@ module Errors { >r7arg1 : new (x: { a: T; b: T; }) => T var r7a = [r7arg2, r7arg1]; ->r7a : ((new (x: { a: string; b: number; }) => number) | (new (x: { a: T; b: T; }) => T))[] ->[r7arg2, r7arg1] : ((new (x: { a: string; b: number; }) => number) | (new (x: { a: T; b: T; }) => T))[] +>r7a : (new (x: { a: T; b: T; }) => T)[] +>[r7arg2, r7arg1] : (new (x: { a: T; b: T; }) => T)[] >r7arg2 : new (x: { a: string; b: number; }) => number >r7arg1 : new (x: { a: T; b: T; }) => T var r7b = [r7arg1, r7arg2]; ->r7b : ((new (x: { a: T; b: T; }) => T) | (new (x: { a: string; b: number; }) => number))[] ->[r7arg1, r7arg2] : ((new (x: { a: T; b: T; }) => T) | (new (x: { a: string; b: number; }) => number))[] +>r7b : (new (x: { a: T; b: T; }) => T)[] +>[r7arg1, r7arg2] : (new (x: { a: T; b: T; }) => T)[] >r7arg1 : new (x: { a: T; b: T; }) => T >r7arg2 : new (x: { a: string; b: number; }) => number @@ -491,14 +491,14 @@ module Errors { >r7arg3 : new (x: { a: T; b: T; }) => number var r7d = [r7arg2, r7arg3]; ->r7d : ((new (x: { a: string; b: number; }) => number) | (new (x: { a: T; b: T; }) => number))[] ->[r7arg2, r7arg3] : ((new (x: { a: string; b: number; }) => number) | (new (x: { a: T; b: T; }) => number))[] +>r7d : (new (x: { a: string; b: number; }) => number)[] +>[r7arg2, r7arg3] : (new (x: { a: string; b: number; }) => number)[] >r7arg2 : new (x: { a: string; b: number; }) => number >r7arg3 : new (x: { a: T; b: T; }) => number var r7e = [r7arg3, r7arg2]; ->r7e : ((new (x: { a: T; b: T; }) => number) | (new (x: { a: string; b: number; }) => number))[] ->[r7arg3, r7arg2] : ((new (x: { a: T; b: T; }) => number) | (new (x: { a: string; b: number; }) => number))[] +>r7e : (new (x: { a: T; b: T; }) => number)[] +>[r7arg3, r7arg2] : (new (x: { a: T; b: T; }) => number)[] >r7arg3 : new (x: { a: T; b: T; }) => number >r7arg2 : new (x: { a: string; b: number; }) => number diff --git a/tests/baselines/reference/subtypingWithConstructSignatures4.types b/tests/baselines/reference/subtypingWithConstructSignatures4.types index 328dadad41c..932adcb7368 100644 --- a/tests/baselines/reference/subtypingWithConstructSignatures4.types +++ b/tests/baselines/reference/subtypingWithConstructSignatures4.types @@ -301,14 +301,14 @@ var r3 = foo3(r3arg); >r3arg : new (x: T) => T var r3a = [r3arg, r3arg2]; ->r3a : ((new (x: T) => T) | (new (x: T) => void))[] ->[r3arg, r3arg2] : ((new (x: T) => T) | (new (x: T) => void))[] +>r3a : (new (x: T) => T)[] +>[r3arg, r3arg2] : (new (x: T) => T)[] >r3arg : new (x: T) => T >r3arg2 : new (x: T) => void var r3b = [r3arg2, r3arg]; ->r3b : ((new (x: T) => void) | (new (x: T) => T))[] ->[r3arg2, r3arg] : ((new (x: T) => void) | (new (x: T) => T))[] +>r3b : (new (x: T) => void)[] +>[r3arg2, r3arg] : (new (x: T) => void)[] >r3arg2 : new (x: T) => void >r3arg : new (x: T) => T @@ -415,14 +415,14 @@ var r6 = foo6(r6arg); >r6arg : new (x: new (arg: T) => U) => T var r6a = [r6arg, r6arg2]; ->r6a : ((new (x: new (arg: T) => U) => T) | (new (x: new (arg: T) => Derived) => T))[] ->[r6arg, r6arg2] : ((new (x: new (arg: T) => U) => T) | (new (x: new (arg: T) => Derived) => T))[] +>r6a : (new (x: new (arg: T) => U) => T)[] +>[r6arg, r6arg2] : (new (x: new (arg: T) => U) => T)[] >r6arg : new (x: new (arg: T) => U) => T >r6arg2 : new (x: new (arg: T) => Derived) => T var r6b = [r6arg2, r6arg]; ->r6b : ((new (x: new (arg: T) => Derived) => T) | (new (x: new (arg: T) => U) => T))[] ->[r6arg2, r6arg] : ((new (x: new (arg: T) => Derived) => T) | (new (x: new (arg: T) => U) => T))[] +>r6b : (new (x: new (arg: T) => Derived) => T)[] +>[r6arg2, r6arg] : (new (x: new (arg: T) => Derived) => T)[] >r6arg2 : new (x: new (arg: T) => Derived) => T >r6arg : new (x: new (arg: T) => U) => T @@ -460,14 +460,14 @@ var r11 = foo11(r11arg); >r11arg : new (x: { foo: T; }, y: { foo: U; bar: U; }) => Base var r11a = [r11arg, r11arg2]; ->r11a : ((new (x: { foo: T; }, y: { foo: U; bar: U; }) => Base) | (new (x: { foo: T; }, y: { foo: T; bar: T; }) => Base))[] ->[r11arg, r11arg2] : ((new (x: { foo: T; }, y: { foo: U; bar: U; }) => Base) | (new (x: { foo: T; }, y: { foo: T; bar: T; }) => Base))[] +>r11a : (new (x: { foo: T; }, y: { foo: U; bar: U; }) => Base)[] +>[r11arg, r11arg2] : (new (x: { foo: T; }, y: { foo: U; bar: U; }) => Base)[] >r11arg : new (x: { foo: T; }, y: { foo: U; bar: U; }) => Base >r11arg2 : new (x: { foo: T; }, y: { foo: T; bar: T; }) => Base var r11b = [r11arg2, r11arg]; ->r11b : ((new (x: { foo: T; }, y: { foo: T; bar: T; }) => Base) | (new (x: { foo: T; }, y: { foo: U; bar: U; }) => Base))[] ->[r11arg2, r11arg] : ((new (x: { foo: T; }, y: { foo: T; bar: T; }) => Base) | (new (x: { foo: T; }, y: { foo: U; bar: U; }) => Base))[] +>r11b : (new (x: { foo: T; }, y: { foo: T; bar: T; }) => Base)[] +>[r11arg2, r11arg] : (new (x: { foo: T; }, y: { foo: T; bar: T; }) => Base)[] >r11arg2 : new (x: { foo: T; }, y: { foo: T; bar: T; }) => Base >r11arg : new (x: { foo: T; }, y: { foo: U; bar: U; }) => Base @@ -499,14 +499,14 @@ var r15 = foo15(r15arg); >r15arg : new (x: { a: U; b: V; }) => U[] var r15a = [r15arg, r15arg2]; ->r15a : ((new (x: { a: U; b: V; }) => U[]) | (new (x: { a: T; b: T; }) => T[]))[] ->[r15arg, r15arg2] : ((new (x: { a: U; b: V; }) => U[]) | (new (x: { a: T; b: T; }) => T[]))[] +>r15a : (new (x: { a: U; b: V; }) => U[])[] +>[r15arg, r15arg2] : (new (x: { a: U; b: V; }) => U[])[] >r15arg : new (x: { a: U; b: V; }) => U[] >r15arg2 : new (x: { a: T; b: T; }) => T[] var r15b = [r15arg2, r15arg]; ->r15b : ((new (x: { a: T; b: T; }) => T[]) | (new (x: { a: U; b: V; }) => U[]))[] ->[r15arg2, r15arg] : ((new (x: { a: T; b: T; }) => T[]) | (new (x: { a: U; b: V; }) => U[]))[] +>r15b : (new (x: { a: T; b: T; }) => T[])[] +>[r15arg2, r15arg] : (new (x: { a: T; b: T; }) => T[])[] >r15arg2 : new (x: { a: T; b: T; }) => T[] >r15arg : new (x: { a: U; b: V; }) => U[] diff --git a/tests/baselines/reference/subtypingWithObjectMembersOptionality.types b/tests/baselines/reference/subtypingWithObjectMembersOptionality.types index 0d55d78e266..815f2d60740 100644 --- a/tests/baselines/reference/subtypingWithObjectMembersOptionality.types +++ b/tests/baselines/reference/subtypingWithObjectMembersOptionality.types @@ -85,8 +85,8 @@ var b = { Foo: null }; >null : null var r = true ? a : b; ->r : { Foo?: Base; } | { Foo: Derived; } ->true ? a : b : { Foo?: Base; } | { Foo: Derived; } +>r : { Foo?: Base; } +>true ? a : b : { Foo?: Base; } >true : boolean >a : { Foo?: Base; } >b : { Foo: Derived; } @@ -156,8 +156,8 @@ module TwoLevels { >null : null var r = true ? a : b; ->r : { Foo?: Base; } | { Foo: Derived2; } ->true ? a : b : { Foo?: Base; } | { Foo: Derived2; } +>r : { Foo?: Base; } +>true ? a : b : { Foo?: Base; } >true : boolean >a : { Foo?: Base; } >b : { Foo: Derived2; } diff --git a/tests/baselines/reference/symbolType11.types b/tests/baselines/reference/symbolType11.types index a7de59a11b7..b251db43301 100644 --- a/tests/baselines/reference/symbolType11.types +++ b/tests/baselines/reference/symbolType11.types @@ -33,7 +33,7 @@ s || 1; >1 : number ({}) || s; ->({}) || s : {} | symbol +>({}) || s : {} >({}) : {} >{} : {} >s : symbol diff --git a/tests/baselines/reference/typeGuardsInConditionalExpression.types b/tests/baselines/reference/typeGuardsInConditionalExpression.types index ef048fb8562..493a8c0a31a 100644 --- a/tests/baselines/reference/typeGuardsInConditionalExpression.types +++ b/tests/baselines/reference/typeGuardsInConditionalExpression.types @@ -363,9 +363,9 @@ function foo12(x: number | string | boolean) { >10 : number >x.toString().length : number >x.toString() : string ->x.toString : ((radix?: number) => string) | (() => string) +>x.toString : (radix?: number) => string >x : number | string | boolean ->toString : ((radix?: number) => string) | (() => string) +>toString : (radix?: number) => string >length : number : ((b = x) // x is number | boolean | string - changed in true branch diff --git a/tests/baselines/reference/typeGuardsInIfStatement.types b/tests/baselines/reference/typeGuardsInIfStatement.types index 8e22d4ba3e0..0095a7cc768 100644 --- a/tests/baselines/reference/typeGuardsInIfStatement.types +++ b/tests/baselines/reference/typeGuardsInIfStatement.types @@ -333,9 +333,9 @@ function foo11(x: number | string | boolean) { >10 && x.toString() : string >10 : number >x.toString() : string ->x.toString : ((radix?: number) => string) | (() => string) +>x.toString : (radix?: number) => string >x : number | string | boolean ->toString : ((radix?: number) => string) | (() => string) +>toString : (radix?: number) => string ) : ( @@ -348,9 +348,9 @@ function foo11(x: number | string | boolean) { >x && x.toString() : string >x : number | string | boolean >x.toString() : string ->x.toString : ((radix?: number) => string) | (() => string) +>x.toString : (radix?: number) => string >x : number | string | boolean ->toString : ((radix?: number) => string) | (() => string) +>toString : (radix?: number) => string ); } @@ -369,9 +369,9 @@ function foo12(x: number | string | boolean) { return x.toString(); // string | number | boolean - x changed in else branch >x.toString() : string ->x.toString : ((radix?: number) => string) | (() => string) +>x.toString : (radix?: number) => string >x : number | string | boolean ->toString : ((radix?: number) => string) | (() => string) +>toString : (radix?: number) => string } else { x = 10; diff --git a/tests/baselines/reference/typeGuardsInRightOperandOfAndAndOperator.types b/tests/baselines/reference/typeGuardsInRightOperandOfAndAndOperator.types index b69c80ff55a..22d390618c1 100644 --- a/tests/baselines/reference/typeGuardsInRightOperandOfAndAndOperator.types +++ b/tests/baselines/reference/typeGuardsInRightOperandOfAndAndOperator.types @@ -180,9 +180,9 @@ function foo7(x: number | string | boolean) { >10 && x.toString() : string >10 : number >x.toString() : string ->x.toString : ((radix?: number) => string) | (() => string) +>x.toString : (radix?: number) => string >x : number | string | boolean ->toString : ((radix?: number) => string) | (() => string) +>toString : (radix?: number) => string // do not change value : (y = x && x.toString()))); // number | boolean | string @@ -192,9 +192,9 @@ function foo7(x: number | string | boolean) { >x && x.toString() : string >x : number | string | boolean >x.toString() : string ->x.toString : ((radix?: number) => string) | (() => string) +>x.toString : (radix?: number) => string >x : number | string | boolean ->toString : ((radix?: number) => string) | (() => string) +>toString : (radix?: number) => string } function foo8(x: number | string) { >foo8 : (x: number | string) => number diff --git a/tests/baselines/reference/typeGuardsInRightOperandOfOrOrOperator.types b/tests/baselines/reference/typeGuardsInRightOperandOfOrOrOperator.types index b2f5401e843..38d9a723d3a 100644 --- a/tests/baselines/reference/typeGuardsInRightOperandOfOrOrOperator.types +++ b/tests/baselines/reference/typeGuardsInRightOperandOfOrOrOperator.types @@ -180,9 +180,9 @@ function foo7(x: number | string | boolean) { >10 && x.toString() : string >10 : number >x.toString() : string ->x.toString : ((radix?: number) => string) | (() => string) +>x.toString : (radix?: number) => string >x : number | string | boolean ->toString : ((radix?: number) => string) | (() => string) +>toString : (radix?: number) => string // do not change value : (y = x && x.toString()))); // number | boolean | string @@ -192,9 +192,9 @@ function foo7(x: number | string | boolean) { >x && x.toString() : string >x : number | string | boolean >x.toString() : string ->x.toString : ((radix?: number) => string) | (() => string) +>x.toString : (radix?: number) => string >x : number | string | boolean ->toString : ((radix?: number) => string) | (() => string) +>toString : (radix?: number) => string } function foo8(x: number | string) { >foo8 : (x: number | string) => boolean | number diff --git a/tests/baselines/reference/underscoreTest1.types b/tests/baselines/reference/underscoreTest1.types index 31b01c5f76e..7fe233c4490 100644 --- a/tests/baselines/reference/underscoreTest1.types +++ b/tests/baselines/reference/underscoreTest1.types @@ -547,7 +547,7 @@ _.flatten([1, [2], [3, [[4]]]]); >_.flatten : { (list: T[][]): T[]; (array: any[], shallow?: boolean): T[]; } >_ : Underscore.Static >flatten : { (list: T[][]): T[]; (array: any[], shallow?: boolean): T[]; } ->[1, [2], [3, [[4]]]] : (number | number[] | (number | number[][])[])[] +>[1, [2], [3, [[4]]]] : (number | (number | number[][])[])[] >1 : number >[2] : number[] >2 : number @@ -562,7 +562,7 @@ _.flatten([1, [2], [3, [[4]]]], true); >_.flatten : { (list: T[][]): T[]; (array: any[], shallow?: boolean): T[]; } >_ : Underscore.Static >flatten : { (list: T[][]): T[]; (array: any[], shallow?: boolean): T[]; } ->[1, [2], [3, [[4]]]] : (number | number[] | (number | number[][])[])[] +>[1, [2], [3, [[4]]]] : (number | (number | number[][])[])[] >1 : number >[2] : number[] >2 : number diff --git a/tests/baselines/reference/unionTypeFromArrayLiteral.types b/tests/baselines/reference/unionTypeFromArrayLiteral.types index 604925eb25f..63aefdd214c 100644 --- a/tests/baselines/reference/unionTypeFromArrayLiteral.types +++ b/tests/baselines/reference/unionTypeFromArrayLiteral.types @@ -83,15 +83,15 @@ var arr6 = [c, d]; // (C | D)[] >d : D var arr7 = [c, d, e]; // (C | D)[] ->arr7 : (C | D | E)[] ->[c, d, e] : (C | D | E)[] +>arr7 : (C | D)[] +>[c, d, e] : (C | D)[] >c : C >d : D >e : E var arr8 = [c, e]; // C[] ->arr8 : (C | E)[] ->[c, e] : (C | E)[] +>arr8 : C[] +>[c, e] : C[] >c : C >e : E diff --git a/tests/baselines/reference/unionTypeReduction.types b/tests/baselines/reference/unionTypeReduction.types index 8ecd9b33fb5..073d690162a 100644 --- a/tests/baselines/reference/unionTypeReduction.types +++ b/tests/baselines/reference/unionTypeReduction.types @@ -25,8 +25,8 @@ var e1: I2 | I3; >I3 : I3 var e2 = i2 || i3; // Type of e2 immediately reduced to I3 ->e2 : I2 | I3 ->i2 || i3 : I2 | I3 +>e2 : I3 +>i2 || i3 : I3 >i2 : I2 >i3 : I3 @@ -38,5 +38,5 @@ var r1 = e1(); // Type of e1 reduced to I3 upon accessing property or signature var r2 = e2(); >r2 : number >e2() : number ->e2 : I2 | I3 +>e2 : I3 diff --git a/tests/baselines/reference/unionTypeWithRecursiveSubtypeReduction1.types b/tests/baselines/reference/unionTypeWithRecursiveSubtypeReduction1.types index f609301c19c..caaa02b7b53 100644 --- a/tests/baselines/reference/unionTypeWithRecursiveSubtypeReduction1.types +++ b/tests/baselines/reference/unionTypeWithRecursiveSubtypeReduction1.types @@ -39,7 +39,7 @@ var t: Class | Property; >Property : Property t.parent; ->t.parent : Namespace | Module | Class +>t.parent : Namespace | Class >t : Class | Property ->parent : Namespace | Module | Class +>parent : Namespace | Class From 565696217f10d6c57cbf63f98a272c266f491a6c Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Fri, 28 Aug 2015 17:39:50 -0700 Subject: [PATCH 048/117] Addressing CR feedback --- 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 936f8dcd397..a7e9561c57f 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -4081,7 +4081,7 @@ namespace ts { } function isSubtypeOfAny(candidate: Type, types: Type[]): boolean { - for (var i = 0, len = types.length; i < len; i++) { + for (let i = 0, len = types.length; i < len; i++) { if (candidate !== types[i] && isTypeSubtypeOf(candidate, types[i])) { return true; } @@ -4090,7 +4090,7 @@ namespace ts { } function removeSubtypes(types: Type[]) { - var i = types.length; + let i = types.length; while (i > 0) { i--; if (isSubtypeOfAny(types[i], types)) { From 5542e396d71b0a8100164cf24790fffcc5d5bbe2 Mon Sep 17 00:00:00 2001 From: Mohamed Hegazy Date: Fri, 28 Aug 2015 17:52:47 -0700 Subject: [PATCH 049/117] Update LKG --- lib/tsc.js | 125 ++++++++++------------------- lib/tsserver.js | 125 ++++++++++------------------- lib/typescript.d.ts | 2 +- lib/typescript.js | 154 +++++++++++++----------------------- lib/typescriptServices.d.ts | 2 +- lib/typescriptServices.js | 154 +++++++++++++----------------------- 6 files changed, 194 insertions(+), 368 deletions(-) diff --git a/lib/tsc.js b/lib/tsc.js index 39fd0e10a7e..591a22bceb9 100644 --- a/lib/tsc.js +++ b/lib/tsc.js @@ -12973,25 +12973,6 @@ var ts; } return undefined; } - function isKnownProperty(type, name) { - if (type.flags & 80896 && type !== globalObjectType) { - var resolved = resolveStructuredTypeMembers(type); - return !!(resolved.properties.length === 0 || - resolved.stringIndexType || - resolved.numberIndexType || - getPropertyOfType(type, name)); - } - if (type.flags & 49152) { - for (var _i = 0, _a = type.types; _i < _a.length; _i++) { - var t = _a[_i]; - if (isKnownProperty(t, name)) { - return true; - } - } - return false; - } - return true; - } function getSignaturesOfStructuredType(type, kind) { if (type.flags & 130048) { var resolved = resolveStructuredTypeMembers(type); @@ -13447,7 +13428,7 @@ var ts; } function createTypedPropertyDescriptorType(propertyType) { var globalTypedPropertyDescriptorType = getGlobalTypedPropertyDescriptorType(); - return globalTypedPropertyDescriptorType !== emptyObjectType + return globalTypedPropertyDescriptorType !== emptyGenericType ? createTypeReference(globalTypedPropertyDescriptorType, [propertyType]) : emptyObjectType; } @@ -13500,68 +13481,19 @@ var ts; addTypeToSet(typeSet, type, typeSetKind); } } - function isObjectLiteralTypeDuplicateOf(source, target) { - var sourceProperties = getPropertiesOfObjectType(source); - var targetProperties = getPropertiesOfObjectType(target); - if (sourceProperties.length !== targetProperties.length) { - return false; - } - for (var _i = 0; _i < sourceProperties.length; _i++) { - var sourceProp = sourceProperties[_i]; - var targetProp = getPropertyOfObjectType(target, sourceProp.name); - if (!targetProp || - getDeclarationFlagsFromSymbol(targetProp) & (32 | 64) || - !isTypeDuplicateOf(getTypeOfSymbol(sourceProp), getTypeOfSymbol(targetProp))) { - return false; - } - } - return true; - } - function isTupleTypeDuplicateOf(source, target) { - var sourceTypes = source.elementTypes; - var targetTypes = target.elementTypes; - if (sourceTypes.length !== targetTypes.length) { - return false; - } - for (var i = 0; i < sourceTypes.length; i++) { - if (!isTypeDuplicateOf(sourceTypes[i], targetTypes[i])) { - return false; - } - } - return true; - } - function isTypeDuplicateOf(source, target) { - if (source === target) { - return true; - } - if (source.flags & 32 || source.flags & 64 && !(target.flags & 32)) { - return true; - } - if (source.flags & 524288 && target.flags & 80896) { - return isObjectLiteralTypeDuplicateOf(source, target); - } - if (isArrayType(source) && isArrayType(target)) { - return isTypeDuplicateOf(source.typeArguments[0], target.typeArguments[0]); - } - if (isTupleType(source) && isTupleType(target)) { - return isTupleTypeDuplicateOf(source, target); - } - return isTypeIdenticalTo(source, target); - } - function isTypeDuplicateOfSomeType(candidate, types) { - for (var _i = 0; _i < types.length; _i++) { - var type = types[_i]; - if (candidate !== type && isTypeDuplicateOf(candidate, type)) { + function isSubtypeOfAny(candidate, types) { + for (var i = 0, len = types.length; i < len; i++) { + if (candidate !== types[i] && isTypeSubtypeOf(candidate, types[i])) { return true; } } return false; } - function removeDuplicateTypes(types) { + function removeSubtypes(types) { var i = types.length; while (i > 0) { i--; - if (isTypeDuplicateOfSomeType(types[i], types)) { + if (isSubtypeOfAny(types[i], types)) { types.splice(i, 1); } } @@ -13584,7 +13516,7 @@ var ts; } } } - function getUnionType(types, noDeduplication) { + function getUnionType(types, noSubtypeReduction) { if (types.length === 0) { return emptyObjectType; } @@ -13593,12 +13525,12 @@ var ts; if (containsTypeAny(typeSet)) { return anyType; } - if (noDeduplication) { + if (noSubtypeReduction) { removeAllButLast(typeSet, undefinedType); removeAllButLast(typeSet, nullType); } else { - removeDuplicateTypes(typeSet); + removeSubtypes(typeSet); } if (typeSet.length === 1) { return typeSet[0]; @@ -14092,6 +14024,26 @@ var ts; } return 0; } + function isKnownProperty(type, name) { + if (type.flags & 80896) { + var resolved = resolveStructuredTypeMembers(type); + if (relation === assignableRelation && (type === globalObjectType || resolved.properties.length === 0) || + resolved.stringIndexType || resolved.numberIndexType || getPropertyOfType(type, name)) { + return true; + } + return false; + } + if (type.flags & 49152) { + for (var _i = 0, _a = type.types; _i < _a.length; _i++) { + var t = _a[_i]; + if (isKnownProperty(t, name)) { + return true; + } + } + return false; + } + return true; + } function hasExcessProperties(source, target, reportErrors) { for (var _i = 0, _a = getPropertiesOfObjectType(source); _i < _a.length; _i++) { var prop = _a[_i]; @@ -14764,7 +14716,7 @@ var ts; return getWidenedTypeOfObjectLiteral(type); } if (type.flags & 16384) { - return getUnionType(ts.map(type.types, getWidenedType)); + return getUnionType(ts.map(type.types, getWidenedType), true); } if (isArrayType(type)) { return createArrayType(getWidenedType(type.typeArguments[0])); @@ -17262,7 +17214,7 @@ var ts; } function createPromiseType(promisedType) { var globalPromiseType = getGlobalPromiseType(); - if (globalPromiseType !== emptyObjectType) { + if (globalPromiseType !== emptyGenericType) { promisedType = getAwaitedType(promisedType); return createTypeReference(globalPromiseType, [promisedType]); } @@ -21343,7 +21295,7 @@ var ts; } function createInstantiatedPromiseLikeType() { var promiseLikeType = getGlobalPromiseLikeType(); - if (promiseLikeType !== emptyObjectType) { + if (promiseLikeType !== emptyGenericType) { return createTypeReference(promiseLikeType, [anyType]); } return emptyObjectType; @@ -24459,8 +24411,12 @@ var ts; } } function emitJsxElement(openingNode, children) { + var syntheticReactRef = ts.createSynthesizedNode(67); + syntheticReactRef.text = 'React'; + syntheticReactRef.parent = openingNode; emitLeadingComments(openingNode); - write("React.createElement("); + emitExpressionIdentifier(syntheticReactRef); + write(".createElement("); emitTagName(openingNode.tagName); write(", "); if (openingNode.attributes.length === 0) { @@ -24469,7 +24425,8 @@ var ts; else { var attrs = openingNode.attributes; if (ts.forEach(attrs, function (attr) { return attr.kind === 237; })) { - write("React.__spread("); + emitExpressionIdentifier(syntheticReactRef); + write(".__spread("); var haveOpenedObjectLiteral = false; for (var i_1 = 0; i_1 < attrs.length; i_1++) { if (attrs[i_1].kind === 237) { @@ -30461,7 +30418,7 @@ var ts; return optionNameMapCache; } ts.getOptionNameMap = getOptionNameMap; - function parseCommandLine(commandLine) { + function parseCommandLine(commandLine, readFile) { var options = {}; var fileNames = []; var errors = []; @@ -30520,7 +30477,7 @@ var ts; } } function parseResponseFile(fileName) { - var text = ts.sys.readFile(fileName); + var text = readFile ? readFile(fileName) : ts.sys.readFile(fileName); if (!text) { errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.File_0_not_found, fileName)); return; diff --git a/lib/tsserver.js b/lib/tsserver.js index bfc84fd1a92..78836160678 100644 --- a/lib/tsserver.js +++ b/lib/tsserver.js @@ -3244,7 +3244,7 @@ var ts; return optionNameMapCache; } ts.getOptionNameMap = getOptionNameMap; - function parseCommandLine(commandLine) { + function parseCommandLine(commandLine, readFile) { var options = {}; var fileNames = []; var errors = []; @@ -3303,7 +3303,7 @@ var ts; } } function parseResponseFile(fileName) { - var text = ts.sys.readFile(fileName); + var text = readFile ? readFile(fileName) : ts.sys.readFile(fileName); if (!text) { errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.File_0_not_found, fileName)); return; @@ -13435,25 +13435,6 @@ var ts; } return undefined; } - function isKnownProperty(type, name) { - if (type.flags & 80896 && type !== globalObjectType) { - var resolved = resolveStructuredTypeMembers(type); - return !!(resolved.properties.length === 0 || - resolved.stringIndexType || - resolved.numberIndexType || - getPropertyOfType(type, name)); - } - if (type.flags & 49152) { - for (var _i = 0, _a = type.types; _i < _a.length; _i++) { - var t = _a[_i]; - if (isKnownProperty(t, name)) { - return true; - } - } - return false; - } - return true; - } function getSignaturesOfStructuredType(type, kind) { if (type.flags & 130048) { var resolved = resolveStructuredTypeMembers(type); @@ -13909,7 +13890,7 @@ var ts; } function createTypedPropertyDescriptorType(propertyType) { var globalTypedPropertyDescriptorType = getGlobalTypedPropertyDescriptorType(); - return globalTypedPropertyDescriptorType !== emptyObjectType + return globalTypedPropertyDescriptorType !== emptyGenericType ? createTypeReference(globalTypedPropertyDescriptorType, [propertyType]) : emptyObjectType; } @@ -13962,68 +13943,19 @@ var ts; addTypeToSet(typeSet, type, typeSetKind); } } - function isObjectLiteralTypeDuplicateOf(source, target) { - var sourceProperties = getPropertiesOfObjectType(source); - var targetProperties = getPropertiesOfObjectType(target); - if (sourceProperties.length !== targetProperties.length) { - return false; - } - for (var _i = 0; _i < sourceProperties.length; _i++) { - var sourceProp = sourceProperties[_i]; - var targetProp = getPropertyOfObjectType(target, sourceProp.name); - if (!targetProp || - getDeclarationFlagsFromSymbol(targetProp) & (32 | 64) || - !isTypeDuplicateOf(getTypeOfSymbol(sourceProp), getTypeOfSymbol(targetProp))) { - return false; - } - } - return true; - } - function isTupleTypeDuplicateOf(source, target) { - var sourceTypes = source.elementTypes; - var targetTypes = target.elementTypes; - if (sourceTypes.length !== targetTypes.length) { - return false; - } - for (var i = 0; i < sourceTypes.length; i++) { - if (!isTypeDuplicateOf(sourceTypes[i], targetTypes[i])) { - return false; - } - } - return true; - } - function isTypeDuplicateOf(source, target) { - if (source === target) { - return true; - } - if (source.flags & 32 || source.flags & 64 && !(target.flags & 32)) { - return true; - } - if (source.flags & 524288 && target.flags & 80896) { - return isObjectLiteralTypeDuplicateOf(source, target); - } - if (isArrayType(source) && isArrayType(target)) { - return isTypeDuplicateOf(source.typeArguments[0], target.typeArguments[0]); - } - if (isTupleType(source) && isTupleType(target)) { - return isTupleTypeDuplicateOf(source, target); - } - return isTypeIdenticalTo(source, target); - } - function isTypeDuplicateOfSomeType(candidate, types) { - for (var _i = 0; _i < types.length; _i++) { - var type = types[_i]; - if (candidate !== type && isTypeDuplicateOf(candidate, type)) { + function isSubtypeOfAny(candidate, types) { + for (var i = 0, len = types.length; i < len; i++) { + if (candidate !== types[i] && isTypeSubtypeOf(candidate, types[i])) { return true; } } return false; } - function removeDuplicateTypes(types) { + function removeSubtypes(types) { var i = types.length; while (i > 0) { i--; - if (isTypeDuplicateOfSomeType(types[i], types)) { + if (isSubtypeOfAny(types[i], types)) { types.splice(i, 1); } } @@ -14046,7 +13978,7 @@ var ts; } } } - function getUnionType(types, noDeduplication) { + function getUnionType(types, noSubtypeReduction) { if (types.length === 0) { return emptyObjectType; } @@ -14055,12 +13987,12 @@ var ts; if (containsTypeAny(typeSet)) { return anyType; } - if (noDeduplication) { + if (noSubtypeReduction) { removeAllButLast(typeSet, undefinedType); removeAllButLast(typeSet, nullType); } else { - removeDuplicateTypes(typeSet); + removeSubtypes(typeSet); } if (typeSet.length === 1) { return typeSet[0]; @@ -14554,6 +14486,26 @@ var ts; } return 0; } + function isKnownProperty(type, name) { + if (type.flags & 80896) { + var resolved = resolveStructuredTypeMembers(type); + if (relation === assignableRelation && (type === globalObjectType || resolved.properties.length === 0) || + resolved.stringIndexType || resolved.numberIndexType || getPropertyOfType(type, name)) { + return true; + } + return false; + } + if (type.flags & 49152) { + for (var _i = 0, _a = type.types; _i < _a.length; _i++) { + var t = _a[_i]; + if (isKnownProperty(t, name)) { + return true; + } + } + return false; + } + return true; + } function hasExcessProperties(source, target, reportErrors) { for (var _i = 0, _a = getPropertiesOfObjectType(source); _i < _a.length; _i++) { var prop = _a[_i]; @@ -15226,7 +15178,7 @@ var ts; return getWidenedTypeOfObjectLiteral(type); } if (type.flags & 16384) { - return getUnionType(ts.map(type.types, getWidenedType)); + return getUnionType(ts.map(type.types, getWidenedType), true); } if (isArrayType(type)) { return createArrayType(getWidenedType(type.typeArguments[0])); @@ -17724,7 +17676,7 @@ var ts; } function createPromiseType(promisedType) { var globalPromiseType = getGlobalPromiseType(); - if (globalPromiseType !== emptyObjectType) { + if (globalPromiseType !== emptyGenericType) { promisedType = getAwaitedType(promisedType); return createTypeReference(globalPromiseType, [promisedType]); } @@ -21805,7 +21757,7 @@ var ts; } function createInstantiatedPromiseLikeType() { var promiseLikeType = getGlobalPromiseLikeType(); - if (promiseLikeType !== emptyObjectType) { + if (promiseLikeType !== emptyGenericType) { return createTypeReference(promiseLikeType, [anyType]); } return emptyObjectType; @@ -24921,8 +24873,12 @@ var ts; } } function emitJsxElement(openingNode, children) { + var syntheticReactRef = ts.createSynthesizedNode(67); + syntheticReactRef.text = 'React'; + syntheticReactRef.parent = openingNode; emitLeadingComments(openingNode); - write("React.createElement("); + emitExpressionIdentifier(syntheticReactRef); + write(".createElement("); emitTagName(openingNode.tagName); write(", "); if (openingNode.attributes.length === 0) { @@ -24931,7 +24887,8 @@ var ts; else { var attrs = openingNode.attributes; if (ts.forEach(attrs, function (attr) { return attr.kind === 237; })) { - write("React.__spread("); + emitExpressionIdentifier(syntheticReactRef); + write(".__spread("); var haveOpenedObjectLiteral = false; for (var i_1 = 0; i_1 < attrs.length; i_1++) { if (attrs[i_1].kind === 237) { diff --git a/lib/typescript.d.ts b/lib/typescript.d.ts index 72fca78224e..bf0510cf1c8 100644 --- a/lib/typescript.d.ts +++ b/lib/typescript.d.ts @@ -1525,7 +1525,7 @@ declare module "typescript" { function createProgram(rootNames: string[], options: CompilerOptions, host?: CompilerHost, oldProgram?: Program): Program; } declare module "typescript" { - function parseCommandLine(commandLine: string[]): ParsedCommandLine; + function parseCommandLine(commandLine: string[], readFile?: (path: string) => string): ParsedCommandLine; /** * Read tsconfig.json file * @param fileName The path to the config file diff --git a/lib/typescript.js b/lib/typescript.js index ccbef3d8d87..b4d21639d3b 100644 --- a/lib/typescript.js +++ b/lib/typescript.js @@ -15703,7 +15703,7 @@ var ts; return members; } function resolveTupleTypeMembers(type) { - var arrayType = resolveStructuredTypeMembers(createArrayType(getUnionType(type.elementTypes, /*noDeduplication*/ true))); + var arrayType = resolveStructuredTypeMembers(createArrayType(getUnionType(type.elementTypes, /*noSubtypeReduction*/ true))); var members = createTupleTypeMemberSymbols(type.elementTypes); addInheritedMembers(members, arrayType.properties); setObjectTypeMembers(type, members, arrayType.callSignatures, arrayType.constructSignatures, arrayType.stringIndexType, arrayType.numberIndexType); @@ -16024,29 +16024,6 @@ var ts; } return undefined; } - // Check if a property with the given name is known anywhere in the given type. In an object - // type, a property is considered known if the object type is empty, if it has any index - // signatures, or if the property is actually declared in the type. In a union or intersection - // type, a property is considered known if it is known in any constituent type. - function isKnownProperty(type, name) { - if (type.flags & 80896 /* ObjectType */ && type !== globalObjectType) { - var resolved = resolveStructuredTypeMembers(type); - return !!(resolved.properties.length === 0 || - resolved.stringIndexType || - resolved.numberIndexType || - getPropertyOfType(type, name)); - } - if (type.flags & 49152 /* UnionOrIntersection */) { - for (var _i = 0, _a = type.types; _i < _a.length; _i++) { - var t = _a[_i]; - if (isKnownProperty(t, name)) { - return true; - } - } - return false; - } - return true; - } function getSignaturesOfStructuredType(type, kind) { if (type.flags & 130048 /* StructuredType */) { var resolved = resolveStructuredTypeMembers(type); @@ -16560,7 +16537,7 @@ var ts; */ function createTypedPropertyDescriptorType(propertyType) { var globalTypedPropertyDescriptorType = getGlobalTypedPropertyDescriptorType(); - return globalTypedPropertyDescriptorType !== emptyObjectType + return globalTypedPropertyDescriptorType !== emptyGenericType ? createTypeReference(globalTypedPropertyDescriptorType, [propertyType]) : emptyObjectType; } @@ -16618,71 +16595,19 @@ var ts; addTypeToSet(typeSet, type, typeSetKind); } } - function isObjectLiteralTypeDuplicateOf(source, target) { - var sourceProperties = getPropertiesOfObjectType(source); - var targetProperties = getPropertiesOfObjectType(target); - if (sourceProperties.length !== targetProperties.length) { - return false; - } - for (var _i = 0; _i < sourceProperties.length; _i++) { - var sourceProp = sourceProperties[_i]; - var targetProp = getPropertyOfObjectType(target, sourceProp.name); - if (!targetProp || - getDeclarationFlagsFromSymbol(targetProp) & (32 /* Private */ | 64 /* Protected */) || - !isTypeDuplicateOf(getTypeOfSymbol(sourceProp), getTypeOfSymbol(targetProp))) { - return false; - } - } - return true; - } - function isTupleTypeDuplicateOf(source, target) { - var sourceTypes = source.elementTypes; - var targetTypes = target.elementTypes; - if (sourceTypes.length !== targetTypes.length) { - return false; - } - for (var i = 0; i < sourceTypes.length; i++) { - if (!isTypeDuplicateOf(sourceTypes[i], targetTypes[i])) { - return false; - } - } - return true; - } - // Returns true if the source type is a duplicate of the target type. A source type is a duplicate of - // a target type if the the two are identical, with the exception that the source type may have null or - // undefined in places where the target type doesn't. This is by design an asymmetric relationship. - function isTypeDuplicateOf(source, target) { - if (source === target) { - return true; - } - if (source.flags & 32 /* Undefined */ || source.flags & 64 /* Null */ && !(target.flags & 32 /* Undefined */)) { - return true; - } - if (source.flags & 524288 /* ObjectLiteral */ && target.flags & 80896 /* ObjectType */) { - return isObjectLiteralTypeDuplicateOf(source, target); - } - if (isArrayType(source) && isArrayType(target)) { - return isTypeDuplicateOf(source.typeArguments[0], target.typeArguments[0]); - } - if (isTupleType(source) && isTupleType(target)) { - return isTupleTypeDuplicateOf(source, target); - } - return isTypeIdenticalTo(source, target); - } - function isTypeDuplicateOfSomeType(candidate, types) { - for (var _i = 0; _i < types.length; _i++) { - var type = types[_i]; - if (candidate !== type && isTypeDuplicateOf(candidate, type)) { + function isSubtypeOfAny(candidate, types) { + for (var i = 0, len = types.length; i < len; i++) { + if (candidate !== types[i] && isTypeSubtypeOf(candidate, types[i])) { return true; } } return false; } - function removeDuplicateTypes(types) { + function removeSubtypes(types) { var i = types.length; while (i > 0) { i--; - if (isTypeDuplicateOfSomeType(types[i], types)) { + if (isSubtypeOfAny(types[i], types)) { types.splice(i, 1); } } @@ -16705,12 +16630,14 @@ var ts; } } } - // We always deduplicate the constituent type set based on object identity, but we'll also deduplicate - // based on the structure of the types unless the noDeduplication flag is true, which is the case when - // creating a union type from a type node and when instantiating a union type. In both of those cases, - // structural deduplication has to be deferred to properly support recursive union types. For example, - // a type of the form "type Item = string | (() => Item)" cannot be deduplicated during its declaration. - function getUnionType(types, noDeduplication) { + // We reduce the constituent type set to only include types that aren't subtypes of other types, unless + // the noSubtypeReduction flag is specified, in which case we perform a simple deduplication based on + // object identity. Subtype reduction is possible only when union types are known not to circularly + // reference themselves (as is the case with union types created by expression constructs such as array + // literals and the || and ?: operators). Named types can circularly reference themselves and therefore + // cannot be deduplicated during their declaration. For example, "type Item = string | (() => Item" is + // a named type that circularly references itself. + function getUnionType(types, noSubtypeReduction) { if (types.length === 0) { return emptyObjectType; } @@ -16719,12 +16646,12 @@ var ts; if (containsTypeAny(typeSet)) { return anyType; } - if (noDeduplication) { + if (noSubtypeReduction) { removeAllButLast(typeSet, undefinedType); removeAllButLast(typeSet, nullType); } else { - removeDuplicateTypes(typeSet); + removeSubtypes(typeSet); } if (typeSet.length === 1) { return typeSet[0]; @@ -16740,7 +16667,7 @@ var ts; function getTypeFromUnionTypeNode(node) { var links = getNodeLinks(node); if (!links.resolvedType) { - links.resolvedType = getUnionType(ts.map(node.types, getTypeFromTypeNode), /*noDeduplication*/ true); + links.resolvedType = getUnionType(ts.map(node.types, getTypeFromTypeNode), /*noSubtypeReduction*/ true); } return links.resolvedType; } @@ -17011,7 +16938,7 @@ var ts; return createTupleType(instantiateList(type.elementTypes, mapper, instantiateType)); } if (type.flags & 16384 /* Union */) { - return getUnionType(instantiateList(type.types, mapper, instantiateType), /*noDeduplication*/ true); + return getUnionType(instantiateList(type.types, mapper, instantiateType), /*noSubtypeReduction*/ true); } if (type.flags & 32768 /* Intersection */) { return getIntersectionType(instantiateList(type.types, mapper, instantiateType)); @@ -17272,6 +17199,30 @@ var ts; } return 0 /* False */; } + // Check if a property with the given name is known anywhere in the given type. In an object type, a property + // is considered known if the object type is empty and the check is for assignability, if the object type has + // index signatures, or if the property is actually declared in the object type. In a union or intersection + // type, a property is considered known if it is known in any constituent type. + function isKnownProperty(type, name) { + if (type.flags & 80896 /* ObjectType */) { + var resolved = resolveStructuredTypeMembers(type); + if (relation === assignableRelation && (type === globalObjectType || resolved.properties.length === 0) || + resolved.stringIndexType || resolved.numberIndexType || getPropertyOfType(type, name)) { + return true; + } + return false; + } + if (type.flags & 49152 /* UnionOrIntersection */) { + for (var _i = 0, _a = type.types; _i < _a.length; _i++) { + var t = _a[_i]; + if (isKnownProperty(t, name)) { + return true; + } + } + return false; + } + return true; + } function hasExcessProperties(source, target, reportErrors) { for (var _i = 0, _a = getPropertiesOfObjectType(source); _i < _a.length; _i++) { var prop = _a[_i]; @@ -18000,7 +17951,7 @@ var ts; return getWidenedTypeOfObjectLiteral(type); } if (type.flags & 16384 /* Union */) { - return getUnionType(ts.map(type.types, getWidenedType)); + return getUnionType(ts.map(type.types, getWidenedType), /*noSubtypeReduction*/ true); } if (isArrayType(type)) { return createArrayType(getWidenedType(type.typeArguments[0])); @@ -21218,7 +21169,7 @@ var ts; function createPromiseType(promisedType) { // creates a `Promise` type where `T` is the promisedType argument var globalPromiseType = getGlobalPromiseType(); - if (globalPromiseType !== emptyObjectType) { + if (globalPromiseType !== emptyGenericType) { // if the promised type is itself a promise, get the underlying type; otherwise, fallback to the promised type promisedType = getAwaitedType(promisedType); return createTypeReference(globalPromiseType, [promisedType]); @@ -26054,7 +26005,7 @@ var ts; } function createInstantiatedPromiseLikeType() { var promiseLikeType = getGlobalPromiseLikeType(); - if (promiseLikeType !== emptyObjectType) { + if (promiseLikeType !== emptyGenericType) { return createTypeReference(promiseLikeType, [anyType]); } return emptyObjectType; @@ -29505,9 +29456,13 @@ var ts; } } function emitJsxElement(openingNode, children) { + var syntheticReactRef = ts.createSynthesizedNode(67 /* Identifier */); + syntheticReactRef.text = 'React'; + syntheticReactRef.parent = openingNode; // Call React.createElement(tag, ... emitLeadingComments(openingNode); - write("React.createElement("); + emitExpressionIdentifier(syntheticReactRef); + write(".createElement("); emitTagName(openingNode.tagName); write(", "); // Attribute list @@ -29520,7 +29475,8 @@ var ts; // a call to React.__spread var attrs = openingNode.attributes; if (ts.forEach(attrs, function (attr) { return attr.kind === 237 /* JsxSpreadAttribute */; })) { - write("React.__spread("); + emitExpressionIdentifier(syntheticReactRef); + write(".__spread("); var haveOpenedObjectLiteral = false; for (var i_1 = 0; i_1 < attrs.length; i_1++) { if (attrs[i_1].kind === 237 /* JsxSpreadAttribute */) { @@ -36317,7 +36273,7 @@ var ts; return optionNameMapCache; } ts.getOptionNameMap = getOptionNameMap; - function parseCommandLine(commandLine) { + function parseCommandLine(commandLine, readFile) { var options = {}; var fileNames = []; var errors = []; @@ -36379,7 +36335,7 @@ var ts; } } function parseResponseFile(fileName) { - var text = ts.sys.readFile(fileName); + var text = readFile ? readFile(fileName) : ts.sys.readFile(fileName); if (!text) { errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.File_0_not_found, fileName)); return; diff --git a/lib/typescriptServices.d.ts b/lib/typescriptServices.d.ts index 339be4b1195..3d4418a9750 100644 --- a/lib/typescriptServices.d.ts +++ b/lib/typescriptServices.d.ts @@ -1525,7 +1525,7 @@ declare namespace ts { function createProgram(rootNames: string[], options: CompilerOptions, host?: CompilerHost, oldProgram?: Program): Program; } declare namespace ts { - function parseCommandLine(commandLine: string[]): ParsedCommandLine; + function parseCommandLine(commandLine: string[], readFile?: (path: string) => string): ParsedCommandLine; /** * Read tsconfig.json file * @param fileName The path to the config file diff --git a/lib/typescriptServices.js b/lib/typescriptServices.js index ccbef3d8d87..b4d21639d3b 100644 --- a/lib/typescriptServices.js +++ b/lib/typescriptServices.js @@ -15703,7 +15703,7 @@ var ts; return members; } function resolveTupleTypeMembers(type) { - var arrayType = resolveStructuredTypeMembers(createArrayType(getUnionType(type.elementTypes, /*noDeduplication*/ true))); + var arrayType = resolveStructuredTypeMembers(createArrayType(getUnionType(type.elementTypes, /*noSubtypeReduction*/ true))); var members = createTupleTypeMemberSymbols(type.elementTypes); addInheritedMembers(members, arrayType.properties); setObjectTypeMembers(type, members, arrayType.callSignatures, arrayType.constructSignatures, arrayType.stringIndexType, arrayType.numberIndexType); @@ -16024,29 +16024,6 @@ var ts; } return undefined; } - // Check if a property with the given name is known anywhere in the given type. In an object - // type, a property is considered known if the object type is empty, if it has any index - // signatures, or if the property is actually declared in the type. In a union or intersection - // type, a property is considered known if it is known in any constituent type. - function isKnownProperty(type, name) { - if (type.flags & 80896 /* ObjectType */ && type !== globalObjectType) { - var resolved = resolveStructuredTypeMembers(type); - return !!(resolved.properties.length === 0 || - resolved.stringIndexType || - resolved.numberIndexType || - getPropertyOfType(type, name)); - } - if (type.flags & 49152 /* UnionOrIntersection */) { - for (var _i = 0, _a = type.types; _i < _a.length; _i++) { - var t = _a[_i]; - if (isKnownProperty(t, name)) { - return true; - } - } - return false; - } - return true; - } function getSignaturesOfStructuredType(type, kind) { if (type.flags & 130048 /* StructuredType */) { var resolved = resolveStructuredTypeMembers(type); @@ -16560,7 +16537,7 @@ var ts; */ function createTypedPropertyDescriptorType(propertyType) { var globalTypedPropertyDescriptorType = getGlobalTypedPropertyDescriptorType(); - return globalTypedPropertyDescriptorType !== emptyObjectType + return globalTypedPropertyDescriptorType !== emptyGenericType ? createTypeReference(globalTypedPropertyDescriptorType, [propertyType]) : emptyObjectType; } @@ -16618,71 +16595,19 @@ var ts; addTypeToSet(typeSet, type, typeSetKind); } } - function isObjectLiteralTypeDuplicateOf(source, target) { - var sourceProperties = getPropertiesOfObjectType(source); - var targetProperties = getPropertiesOfObjectType(target); - if (sourceProperties.length !== targetProperties.length) { - return false; - } - for (var _i = 0; _i < sourceProperties.length; _i++) { - var sourceProp = sourceProperties[_i]; - var targetProp = getPropertyOfObjectType(target, sourceProp.name); - if (!targetProp || - getDeclarationFlagsFromSymbol(targetProp) & (32 /* Private */ | 64 /* Protected */) || - !isTypeDuplicateOf(getTypeOfSymbol(sourceProp), getTypeOfSymbol(targetProp))) { - return false; - } - } - return true; - } - function isTupleTypeDuplicateOf(source, target) { - var sourceTypes = source.elementTypes; - var targetTypes = target.elementTypes; - if (sourceTypes.length !== targetTypes.length) { - return false; - } - for (var i = 0; i < sourceTypes.length; i++) { - if (!isTypeDuplicateOf(sourceTypes[i], targetTypes[i])) { - return false; - } - } - return true; - } - // Returns true if the source type is a duplicate of the target type. A source type is a duplicate of - // a target type if the the two are identical, with the exception that the source type may have null or - // undefined in places where the target type doesn't. This is by design an asymmetric relationship. - function isTypeDuplicateOf(source, target) { - if (source === target) { - return true; - } - if (source.flags & 32 /* Undefined */ || source.flags & 64 /* Null */ && !(target.flags & 32 /* Undefined */)) { - return true; - } - if (source.flags & 524288 /* ObjectLiteral */ && target.flags & 80896 /* ObjectType */) { - return isObjectLiteralTypeDuplicateOf(source, target); - } - if (isArrayType(source) && isArrayType(target)) { - return isTypeDuplicateOf(source.typeArguments[0], target.typeArguments[0]); - } - if (isTupleType(source) && isTupleType(target)) { - return isTupleTypeDuplicateOf(source, target); - } - return isTypeIdenticalTo(source, target); - } - function isTypeDuplicateOfSomeType(candidate, types) { - for (var _i = 0; _i < types.length; _i++) { - var type = types[_i]; - if (candidate !== type && isTypeDuplicateOf(candidate, type)) { + function isSubtypeOfAny(candidate, types) { + for (var i = 0, len = types.length; i < len; i++) { + if (candidate !== types[i] && isTypeSubtypeOf(candidate, types[i])) { return true; } } return false; } - function removeDuplicateTypes(types) { + function removeSubtypes(types) { var i = types.length; while (i > 0) { i--; - if (isTypeDuplicateOfSomeType(types[i], types)) { + if (isSubtypeOfAny(types[i], types)) { types.splice(i, 1); } } @@ -16705,12 +16630,14 @@ var ts; } } } - // We always deduplicate the constituent type set based on object identity, but we'll also deduplicate - // based on the structure of the types unless the noDeduplication flag is true, which is the case when - // creating a union type from a type node and when instantiating a union type. In both of those cases, - // structural deduplication has to be deferred to properly support recursive union types. For example, - // a type of the form "type Item = string | (() => Item)" cannot be deduplicated during its declaration. - function getUnionType(types, noDeduplication) { + // We reduce the constituent type set to only include types that aren't subtypes of other types, unless + // the noSubtypeReduction flag is specified, in which case we perform a simple deduplication based on + // object identity. Subtype reduction is possible only when union types are known not to circularly + // reference themselves (as is the case with union types created by expression constructs such as array + // literals and the || and ?: operators). Named types can circularly reference themselves and therefore + // cannot be deduplicated during their declaration. For example, "type Item = string | (() => Item" is + // a named type that circularly references itself. + function getUnionType(types, noSubtypeReduction) { if (types.length === 0) { return emptyObjectType; } @@ -16719,12 +16646,12 @@ var ts; if (containsTypeAny(typeSet)) { return anyType; } - if (noDeduplication) { + if (noSubtypeReduction) { removeAllButLast(typeSet, undefinedType); removeAllButLast(typeSet, nullType); } else { - removeDuplicateTypes(typeSet); + removeSubtypes(typeSet); } if (typeSet.length === 1) { return typeSet[0]; @@ -16740,7 +16667,7 @@ var ts; function getTypeFromUnionTypeNode(node) { var links = getNodeLinks(node); if (!links.resolvedType) { - links.resolvedType = getUnionType(ts.map(node.types, getTypeFromTypeNode), /*noDeduplication*/ true); + links.resolvedType = getUnionType(ts.map(node.types, getTypeFromTypeNode), /*noSubtypeReduction*/ true); } return links.resolvedType; } @@ -17011,7 +16938,7 @@ var ts; return createTupleType(instantiateList(type.elementTypes, mapper, instantiateType)); } if (type.flags & 16384 /* Union */) { - return getUnionType(instantiateList(type.types, mapper, instantiateType), /*noDeduplication*/ true); + return getUnionType(instantiateList(type.types, mapper, instantiateType), /*noSubtypeReduction*/ true); } if (type.flags & 32768 /* Intersection */) { return getIntersectionType(instantiateList(type.types, mapper, instantiateType)); @@ -17272,6 +17199,30 @@ var ts; } return 0 /* False */; } + // Check if a property with the given name is known anywhere in the given type. In an object type, a property + // is considered known if the object type is empty and the check is for assignability, if the object type has + // index signatures, or if the property is actually declared in the object type. In a union or intersection + // type, a property is considered known if it is known in any constituent type. + function isKnownProperty(type, name) { + if (type.flags & 80896 /* ObjectType */) { + var resolved = resolveStructuredTypeMembers(type); + if (relation === assignableRelation && (type === globalObjectType || resolved.properties.length === 0) || + resolved.stringIndexType || resolved.numberIndexType || getPropertyOfType(type, name)) { + return true; + } + return false; + } + if (type.flags & 49152 /* UnionOrIntersection */) { + for (var _i = 0, _a = type.types; _i < _a.length; _i++) { + var t = _a[_i]; + if (isKnownProperty(t, name)) { + return true; + } + } + return false; + } + return true; + } function hasExcessProperties(source, target, reportErrors) { for (var _i = 0, _a = getPropertiesOfObjectType(source); _i < _a.length; _i++) { var prop = _a[_i]; @@ -18000,7 +17951,7 @@ var ts; return getWidenedTypeOfObjectLiteral(type); } if (type.flags & 16384 /* Union */) { - return getUnionType(ts.map(type.types, getWidenedType)); + return getUnionType(ts.map(type.types, getWidenedType), /*noSubtypeReduction*/ true); } if (isArrayType(type)) { return createArrayType(getWidenedType(type.typeArguments[0])); @@ -21218,7 +21169,7 @@ var ts; function createPromiseType(promisedType) { // creates a `Promise` type where `T` is the promisedType argument var globalPromiseType = getGlobalPromiseType(); - if (globalPromiseType !== emptyObjectType) { + if (globalPromiseType !== emptyGenericType) { // if the promised type is itself a promise, get the underlying type; otherwise, fallback to the promised type promisedType = getAwaitedType(promisedType); return createTypeReference(globalPromiseType, [promisedType]); @@ -26054,7 +26005,7 @@ var ts; } function createInstantiatedPromiseLikeType() { var promiseLikeType = getGlobalPromiseLikeType(); - if (promiseLikeType !== emptyObjectType) { + if (promiseLikeType !== emptyGenericType) { return createTypeReference(promiseLikeType, [anyType]); } return emptyObjectType; @@ -29505,9 +29456,13 @@ var ts; } } function emitJsxElement(openingNode, children) { + var syntheticReactRef = ts.createSynthesizedNode(67 /* Identifier */); + syntheticReactRef.text = 'React'; + syntheticReactRef.parent = openingNode; // Call React.createElement(tag, ... emitLeadingComments(openingNode); - write("React.createElement("); + emitExpressionIdentifier(syntheticReactRef); + write(".createElement("); emitTagName(openingNode.tagName); write(", "); // Attribute list @@ -29520,7 +29475,8 @@ var ts; // a call to React.__spread var attrs = openingNode.attributes; if (ts.forEach(attrs, function (attr) { return attr.kind === 237 /* JsxSpreadAttribute */; })) { - write("React.__spread("); + emitExpressionIdentifier(syntheticReactRef); + write(".__spread("); var haveOpenedObjectLiteral = false; for (var i_1 = 0; i_1 < attrs.length; i_1++) { if (attrs[i_1].kind === 237 /* JsxSpreadAttribute */) { @@ -36317,7 +36273,7 @@ var ts; return optionNameMapCache; } ts.getOptionNameMap = getOptionNameMap; - function parseCommandLine(commandLine) { + function parseCommandLine(commandLine, readFile) { var options = {}; var fileNames = []; var errors = []; @@ -36379,7 +36335,7 @@ var ts; } } function parseResponseFile(fileName) { - var text = ts.sys.readFile(fileName); + var text = readFile ? readFile(fileName) : ts.sys.readFile(fileName); if (!text) { errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.File_0_not_found, fileName)); return; From 758cdf337872067758ab65efbb850cfd6465da1d Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Sun, 30 Aug 2015 15:07:04 -0700 Subject: [PATCH 050/117] Only obtain regular type of fresh object literal type if necessary --- src/compiler/checker.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index e624eb41d86..58b7e920bff 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -4640,7 +4640,9 @@ namespace ts { // and intersection types are further deconstructed on the target side, we don't want to // make the check again (as it might fail for a partial target type). Therefore we obtain // the regular source type and proceed with that. - source = getRegularTypeOfObjectLiteral(source); + if (target.flags & TypeFlags.UnionOrIntersection) { + source = getRegularTypeOfObjectLiteral(source); + } } let saveErrorInfo = errorInfo; From 19e54fe1afe8e9b4a2ce61547eaf6e7743066739 Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Mon, 31 Aug 2015 01:07:30 -0700 Subject: [PATCH 051/117] Improve error message spans when object literals have excess properties. --- src/compiler/checker.ts | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index a7e9561c57f..2dd3c47ac15 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -4593,6 +4593,16 @@ namespace ts { } return result !== Ternary.False; + function reportErrorAndTryImproveErrorNode( + newErrorNode: Node, + message: DiagnosticMessage, + arg0?: string, + arg1?: string, + arg2?: string) { + errorNode = newErrorNode || errorNode; + reportError(message, arg0, arg1, arg2); + } + function reportError(message: DiagnosticMessage, arg0?: string, arg1?: string, arg2?: string): void { errorInfo = chainDiagnosticMessages(errorInfo, message, arg0, arg1, arg2); } @@ -4767,7 +4777,8 @@ namespace ts { for (let prop of getPropertiesOfObjectType(source)) { if (!isKnownProperty(target, prop.name)) { if (reportErrors) { - reportError(Diagnostics.Object_literal_may_only_specify_known_properties_and_0_does_not_exist_in_type_1, symbolToString(prop), typeToString(target)); + reportErrorAndTryImproveErrorNode(prop.valueDeclaration, + Diagnostics.Object_literal_may_only_specify_known_properties_and_0_does_not_exist_in_type_1, symbolToString(prop), typeToString(target)); } return true; } From 4d42d21912d39663e9a6d662e58a480d33c10628 Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Mon, 31 Aug 2015 01:08:09 -0700 Subject: [PATCH 052/117] Accepted baselines. --- tests/baselines/reference/arrayCast.errors.txt | 4 ++-- .../reference/arrayLiteralTypeInference.errors.txt | 14 +++++++------- tests/baselines/reference/arrayLiterals.errors.txt | 4 ++-- .../reference/assignmentCompatBug2.errors.txt | 12 ++++++------ .../reference/assignmentCompatBug5.errors.txt | 4 ++-- .../reference/contextualTyping12.errors.txt | 4 ++-- .../reference/contextualTyping17.errors.txt | 4 ++-- .../reference/contextualTyping2.errors.txt | 4 ++-- .../reference/contextualTyping20.errors.txt | 4 ++-- .../reference/contextualTyping4.errors.txt | 4 ++-- .../reference/contextualTyping9.errors.txt | 4 ++-- ...HiddenBaseCallViaSuperPropertyAccess.errors.txt | 4 ++-- .../destructuringParameterProperties5.errors.txt | 4 ++-- .../reference/incompatibleTypes.errors.txt | 8 ++++---- ...gicalOrExpressionIsContextuallyTyped.errors.txt | 4 ++-- .../objectLitStructuralTypeMismatch.errors.txt | 4 ++-- ...ctLiteralFunctionArgContextualTyping.errors.txt | 8 ++++---- ...tLiteralFunctionArgContextualTyping2.errors.txt | 8 ++++---- ...alShorthandPropertiesAssignmentError.errors.txt | 4 ++-- ...AssignmentErrorFromMissingIdentifier.errors.txt | 4 ++-- ...rderMattersForSignatureGroupIdentity.errors.txt | 8 ++++---- .../reference/switchStatements.errors.txt | 4 ++-- .../reference/symbolProperty21.errors.txt | 14 +++++--------- ...TemplateStringsTypeArgumentInference.errors.txt | 4 ++-- ...plateStringsTypeArgumentInferenceES6.errors.txt | 4 ++-- .../reference/typeArgInference2.errors.txt | 4 ++-- .../reference/typeArgumentInference.errors.txt | 8 ++++---- ...ArgumentInferenceConstructSignatures.errors.txt | 14 +++++++------- ...typeArgumentInferenceWithConstraints.errors.txt | 14 +++++++------- tests/baselines/reference/typeInfer1.errors.txt | 6 +++--- tests/baselines/reference/typeMatch2.errors.txt | 12 ++++++------ 31 files changed, 99 insertions(+), 103 deletions(-) diff --git a/tests/baselines/reference/arrayCast.errors.txt b/tests/baselines/reference/arrayCast.errors.txt index 82b4b856a97..815813ea727 100644 --- a/tests/baselines/reference/arrayCast.errors.txt +++ b/tests/baselines/reference/arrayCast.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/arrayCast.ts(3,1): error TS2352: Neither type '{ foo: string; }[]' nor type '{ id: number; }[]' is assignable to the other. +tests/cases/compiler/arrayCast.ts(3,23): error TS2352: Neither type '{ foo: string; }[]' nor type '{ id: number; }[]' is assignable to the other. Type '{ foo: string; }' is not assignable to type '{ id: number; }'. Object literal may only specify known properties, and 'foo' does not exist in type '{ id: number; }'. @@ -7,7 +7,7 @@ tests/cases/compiler/arrayCast.ts(3,1): error TS2352: Neither type '{ foo: strin // Should fail. Even though the array is contextually typed with { id: number }[], it still // has type { foo: string }[], which is not assignable to { id: number }[]. <{ id: number; }[]>[{ foo: "s" }]; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + ~~~~~~~~ !!! error TS2352: Neither type '{ foo: string; }[]' nor type '{ id: number; }[]' is assignable to the other. !!! error TS2352: Type '{ foo: string; }' is not assignable to type '{ id: number; }'. !!! error TS2352: Object literal may only specify known properties, and 'foo' does not exist in type '{ id: number; }'. diff --git a/tests/baselines/reference/arrayLiteralTypeInference.errors.txt b/tests/baselines/reference/arrayLiteralTypeInference.errors.txt index 105375f2e74..a2c4597127f 100644 --- a/tests/baselines/reference/arrayLiteralTypeInference.errors.txt +++ b/tests/baselines/reference/arrayLiteralTypeInference.errors.txt @@ -1,8 +1,8 @@ -tests/cases/compiler/arrayLiteralTypeInference.ts(13,5): error TS2322: Type '({ id: number; trueness: boolean; } | { id: number; name: string; })[]' is not assignable to type 'Action[]'. +tests/cases/compiler/arrayLiteralTypeInference.ts(14,14): error TS2322: Type '({ id: number; trueness: boolean; } | { id: number; name: string; })[]' is not assignable to type 'Action[]'. Type '{ id: number; trueness: boolean; } | { id: number; name: string; }' is not assignable to type 'Action'. Type '{ id: number; trueness: boolean; }' is not assignable to type 'Action'. Object literal may only specify known properties, and 'trueness' does not exist in type 'Action'. -tests/cases/compiler/arrayLiteralTypeInference.ts(29,5): error TS2322: Type '({ id: number; trueness: boolean; } | { id: number; name: string; })[]' is not assignable to type '{ id: number; }[]'. +tests/cases/compiler/arrayLiteralTypeInference.ts(31,18): error TS2322: Type '({ id: number; trueness: boolean; } | { id: number; name: string; })[]' is not assignable to type '{ id: number; }[]'. Type '{ id: number; trueness: boolean; } | { id: number; name: string; }' is not assignable to type '{ id: number; }'. Type '{ id: number; trueness: boolean; }' is not assignable to type '{ id: number; }'. Object literal may only specify known properties, and 'trueness' does not exist in type '{ id: number; }'. @@ -22,12 +22,12 @@ tests/cases/compiler/arrayLiteralTypeInference.ts(29,5): error TS2322: Type '({ } var x1: Action[] = [ - ~~ + { id: 2, trueness: false }, + ~~~~~~~~~~~~~~~ !!! error TS2322: Type '({ id: number; trueness: boolean; } | { id: number; name: string; })[]' is not assignable to type 'Action[]'. !!! error TS2322: Type '{ id: number; trueness: boolean; } | { id: number; name: string; }' is not assignable to type 'Action'. !!! error TS2322: Type '{ id: number; trueness: boolean; }' is not assignable to type 'Action'. !!! error TS2322: Object literal may only specify known properties, and 'trueness' does not exist in type 'Action'. - { id: 2, trueness: false }, { id: 3, name: "three" } ] @@ -43,13 +43,13 @@ tests/cases/compiler/arrayLiteralTypeInference.ts(29,5): error TS2322: Type '({ ] var z1: { id: number }[] = - ~~ + [ + { id: 2, trueness: false }, + ~~~~~~~~~~~~~~~ !!! error TS2322: Type '({ id: number; trueness: boolean; } | { id: number; name: string; })[]' is not assignable to type '{ id: number; }[]'. !!! error TS2322: Type '{ id: number; trueness: boolean; } | { id: number; name: string; }' is not assignable to type '{ id: number; }'. !!! error TS2322: Type '{ id: number; trueness: boolean; }' is not assignable to type '{ id: number; }'. !!! error TS2322: Object literal may only specify known properties, and 'trueness' does not exist in type '{ id: number; }'. - [ - { id: 2, trueness: false }, { id: 3, name: "three" } ] diff --git a/tests/baselines/reference/arrayLiterals.errors.txt b/tests/baselines/reference/arrayLiterals.errors.txt index fd882804b8a..f5fe71b79a6 100644 --- a/tests/baselines/reference/arrayLiterals.errors.txt +++ b/tests/baselines/reference/arrayLiterals.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/expressions/arrayLiterals/arrayLiterals.ts(24,5): error TS2322: Type '({ a: string; b: number; c: string; } | { a: string; b: number; c: number; })[]' is not assignable to type '{ [n: number]: { a: string; b: number; }; }'. +tests/cases/conformance/expressions/arrayLiterals/arrayLiterals.ts(24,77): error TS2322: Type '({ a: string; b: number; c: string; } | { a: string; b: number; c: number; })[]' is not assignable to type '{ [n: number]: { a: string; b: number; }; }'. Index signatures are incompatible. Type '{ a: string; b: number; c: string; } | { a: string; b: number; c: number; }' is not assignable to type '{ a: string; b: number; }'. Type '{ a: string; b: number; c: string; }' is not assignable to type '{ a: string; b: number; }'. @@ -30,7 +30,7 @@ tests/cases/conformance/expressions/arrayLiterals/arrayLiterals.ts(24,5): error // Contextual type C with numeric index signature makes array literal of EveryType E of type BCT(E,C)[] var context1: { [n: number]: { a: string; b: number; }; } = [{ a: '', b: 0, c: '' }, { a: "", b: 3, c: 0 }]; - ~~~~~~~~ + ~~~~~ !!! error TS2322: Type '({ a: string; b: number; c: string; } | { a: string; b: number; c: number; })[]' is not assignable to type '{ [n: number]: { a: string; b: number; }; }'. !!! error TS2322: Index signatures are incompatible. !!! error TS2322: Type '{ a: string; b: number; c: string; } | { a: string; b: number; c: number; }' is not assignable to type '{ a: string; b: number; }'. diff --git a/tests/baselines/reference/assignmentCompatBug2.errors.txt b/tests/baselines/reference/assignmentCompatBug2.errors.txt index 53e12635888..29ba96e6586 100644 --- a/tests/baselines/reference/assignmentCompatBug2.errors.txt +++ b/tests/baselines/reference/assignmentCompatBug2.errors.txt @@ -1,8 +1,8 @@ -tests/cases/compiler/assignmentCompatBug2.ts(1,5): error TS2322: Type '{ a: number; }' is not assignable to type '{ b: number; }'. +tests/cases/compiler/assignmentCompatBug2.ts(1,27): error TS2322: Type '{ a: number; }' is not assignable to type '{ b: number; }'. Object literal may only specify known properties, and 'a' does not exist in type '{ b: number; }'. -tests/cases/compiler/assignmentCompatBug2.ts(3,1): error TS2322: Type '{ a: number; }' is not assignable to type '{ b: number; }'. +tests/cases/compiler/assignmentCompatBug2.ts(3,8): error TS2322: Type '{ a: number; }' is not assignable to type '{ b: number; }'. Object literal may only specify known properties, and 'a' does not exist in type '{ b: number; }'. -tests/cases/compiler/assignmentCompatBug2.ts(5,1): error TS2322: Type '{ b: number; a: number; }' is not assignable to type '{ b: number; }'. +tests/cases/compiler/assignmentCompatBug2.ts(5,13): error TS2322: Type '{ b: number; a: number; }' is not assignable to type '{ b: number; }'. Object literal may only specify known properties, and 'a' does not exist in type '{ b: number; }'. tests/cases/compiler/assignmentCompatBug2.ts(15,1): error TS2322: Type '{ f: (n: number) => number; g: (s: string) => number; }' is not assignable to type '{ f(n: number): number; g(s: string): number; m: number; n?: number; k?(a: any): any; }'. Property 'm' is missing in type '{ f: (n: number) => number; g: (s: string) => number; }'. @@ -14,17 +14,17 @@ tests/cases/compiler/assignmentCompatBug2.ts(33,1): error TS2322: Type '{ f: (n: ==== tests/cases/compiler/assignmentCompatBug2.ts (6 errors) ==== var b2: { b: number;} = { a: 0 }; // error - ~~ + ~~~~ !!! error TS2322: Type '{ a: number; }' is not assignable to type '{ b: number; }'. !!! error TS2322: Object literal may only specify known properties, and 'a' does not exist in type '{ b: number; }'. b2 = { a: 0 }; // error - ~~ + ~~~~ !!! error TS2322: Type '{ a: number; }' is not assignable to type '{ b: number; }'. !!! error TS2322: Object literal may only specify known properties, and 'a' does not exist in type '{ b: number; }'. b2 = {b: 0, a: 0 }; - ~~ + ~~~~ !!! error TS2322: Type '{ b: number; a: number; }' is not assignable to type '{ b: number; }'. !!! error TS2322: Object literal may only specify known properties, and 'a' does not exist in type '{ b: number; }'. diff --git a/tests/baselines/reference/assignmentCompatBug5.errors.txt b/tests/baselines/reference/assignmentCompatBug5.errors.txt index 790848babf4..1b5e3d80259 100644 --- a/tests/baselines/reference/assignmentCompatBug5.errors.txt +++ b/tests/baselines/reference/assignmentCompatBug5.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/assignmentCompatBug5.ts(2,6): error TS2345: Argument of type '{ b: number; }' is not assignable to parameter of type '{ a: number; }'. +tests/cases/compiler/assignmentCompatBug5.ts(2,8): error TS2345: Argument of type '{ b: number; }' is not assignable to parameter of type '{ a: number; }'. Object literal may only specify known properties, and 'b' does not exist in type '{ a: number; }'. tests/cases/compiler/assignmentCompatBug5.ts(5,6): error TS2345: Argument of type 'string[]' is not assignable to parameter of type 'number[]'. Type 'string' is not assignable to type 'number'. @@ -12,7 +12,7 @@ tests/cases/compiler/assignmentCompatBug5.ts(9,6): error TS2345: Argument of typ ==== tests/cases/compiler/assignmentCompatBug5.ts (4 errors) ==== function foo1(x: { a: number; }) { } foo1({ b: 5 }); - ~~~~~~~~ + ~~~~ !!! error TS2345: Argument of type '{ b: number; }' is not assignable to parameter of type '{ a: number; }'. !!! error TS2345: Object literal may only specify known properties, and 'b' does not exist in type '{ a: number; }'. diff --git a/tests/baselines/reference/contextualTyping12.errors.txt b/tests/baselines/reference/contextualTyping12.errors.txt index 8b079ecc5e0..22ed6ad931e 100644 --- a/tests/baselines/reference/contextualTyping12.errors.txt +++ b/tests/baselines/reference/contextualTyping12.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/contextualTyping12.ts(1,13): error TS2322: Type '({ id: number; } | { id: number; name: string; })[]' is not assignable to type '{ id: number; }[]'. +tests/cases/compiler/contextualTyping12.ts(1,57): error TS2322: Type '({ id: number; } | { id: number; name: string; })[]' is not assignable to type '{ id: number; }[]'. Type '{ id: number; } | { id: number; name: string; }' is not assignable to type '{ id: number; }'. Type '{ id: number; name: string; }' is not assignable to type '{ id: number; }'. Object literal may only specify known properties, and 'name' does not exist in type '{ id: number; }'. @@ -6,7 +6,7 @@ tests/cases/compiler/contextualTyping12.ts(1,13): error TS2322: Type '({ id: num ==== tests/cases/compiler/contextualTyping12.ts (1 errors) ==== class foo { public bar:{id:number;}[] = [{id:1}, {id:2, name:"foo"}]; } - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + ~~~~~~~~~~ !!! error TS2322: Type '({ id: number; } | { id: number; name: string; })[]' is not assignable to type '{ id: number; }[]'. !!! error TS2322: Type '{ id: number; } | { id: number; name: string; }' is not assignable to type '{ id: number; }'. !!! error TS2322: Type '{ id: number; name: string; }' is not assignable to type '{ id: number; }'. diff --git a/tests/baselines/reference/contextualTyping17.errors.txt b/tests/baselines/reference/contextualTyping17.errors.txt index 24c428db58b..b6375c9c9c9 100644 --- a/tests/baselines/reference/contextualTyping17.errors.txt +++ b/tests/baselines/reference/contextualTyping17.errors.txt @@ -1,9 +1,9 @@ -tests/cases/compiler/contextualTyping17.ts(1,33): error TS2322: Type '{ id: number; name: string; }' is not assignable to type '{ id: number; }'. +tests/cases/compiler/contextualTyping17.ts(1,47): error TS2322: Type '{ id: number; name: string; }' is not assignable to type '{ id: number; }'. Object literal may only specify known properties, and 'name' does not exist in type '{ id: number; }'. ==== tests/cases/compiler/contextualTyping17.ts (1 errors) ==== var foo: {id:number;} = {id:4}; foo = {id: 5, name:"foo"}; - ~~~ + ~~~~~~~~~~ !!! error TS2322: Type '{ id: number; name: string; }' is not assignable to type '{ id: number; }'. !!! error TS2322: Object literal may only specify known properties, and 'name' does not exist in type '{ id: number; }'. \ No newline at end of file diff --git a/tests/baselines/reference/contextualTyping2.errors.txt b/tests/baselines/reference/contextualTyping2.errors.txt index 2665204b167..1daa4a2a71f 100644 --- a/tests/baselines/reference/contextualTyping2.errors.txt +++ b/tests/baselines/reference/contextualTyping2.errors.txt @@ -1,9 +1,9 @@ -tests/cases/compiler/contextualTyping2.ts(1,5): error TS2322: Type '{ id: number; name: string; }' is not assignable to type '{ id: number; }'. +tests/cases/compiler/contextualTyping2.ts(1,32): error TS2322: Type '{ id: number; name: string; }' is not assignable to type '{ id: number; }'. Object literal may only specify known properties, and 'name' does not exist in type '{ id: number; }'. ==== tests/cases/compiler/contextualTyping2.ts (1 errors) ==== var foo: {id:number;} = {id:4, name:"foo"}; - ~~~ + ~~~~~~~~~~ !!! error TS2322: Type '{ id: number; name: string; }' is not assignable to type '{ id: number; }'. !!! error TS2322: Object literal may only specify known properties, and 'name' does not exist in type '{ id: number; }'. \ No newline at end of file diff --git a/tests/baselines/reference/contextualTyping20.errors.txt b/tests/baselines/reference/contextualTyping20.errors.txt index d723dcd1d1b..a9112f1db84 100644 --- a/tests/baselines/reference/contextualTyping20.errors.txt +++ b/tests/baselines/reference/contextualTyping20.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/contextualTyping20.ts(1,36): error TS2322: Type '({ id: number; } | { id: number; name: string; })[]' is not assignable to type '{ id: number; }[]'. +tests/cases/compiler/contextualTyping20.ts(1,58): error TS2322: Type '({ id: number; } | { id: number; name: string; })[]' is not assignable to type '{ id: number; }[]'. Type '{ id: number; } | { id: number; name: string; }' is not assignable to type '{ id: number; }'. Type '{ id: number; name: string; }' is not assignable to type '{ id: number; }'. Object literal may only specify known properties, and 'name' does not exist in type '{ id: number; }'. @@ -6,7 +6,7 @@ tests/cases/compiler/contextualTyping20.ts(1,36): error TS2322: Type '({ id: num ==== tests/cases/compiler/contextualTyping20.ts (1 errors) ==== var foo:{id:number;}[] = [{id:1}]; foo = [{id:1}, {id:2, name:"foo"}]; - ~~~ + ~~~~~~~~~~ !!! error TS2322: Type '({ id: number; } | { id: number; name: string; })[]' is not assignable to type '{ id: number; }[]'. !!! error TS2322: Type '{ id: number; } | { id: number; name: string; }' is not assignable to type '{ id: number; }'. !!! error TS2322: Type '{ id: number; name: string; }' is not assignable to type '{ id: number; }'. diff --git a/tests/baselines/reference/contextualTyping4.errors.txt b/tests/baselines/reference/contextualTyping4.errors.txt index 48eb2c406f0..c472e7ccb18 100644 --- a/tests/baselines/reference/contextualTyping4.errors.txt +++ b/tests/baselines/reference/contextualTyping4.errors.txt @@ -1,9 +1,9 @@ -tests/cases/compiler/contextualTyping4.ts(1,13): error TS2322: Type '{ id: number; name: string; }' is not assignable to type '{ id: number; }'. +tests/cases/compiler/contextualTyping4.ts(1,46): error TS2322: Type '{ id: number; name: string; }' is not assignable to type '{ id: number; }'. Object literal may only specify known properties, and 'name' does not exist in type '{ id: number; }'. ==== tests/cases/compiler/contextualTyping4.ts (1 errors) ==== class foo { public bar:{id:number;} = {id:5, name:"foo"}; } - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + ~~~~~~~~~~ !!! error TS2322: Type '{ id: number; name: string; }' is not assignable to type '{ id: number; }'. !!! error TS2322: Object literal may only specify known properties, and 'name' does not exist in type '{ id: number; }'. \ No newline at end of file diff --git a/tests/baselines/reference/contextualTyping9.errors.txt b/tests/baselines/reference/contextualTyping9.errors.txt index f959d1e2e69..4a12574fa21 100644 --- a/tests/baselines/reference/contextualTyping9.errors.txt +++ b/tests/baselines/reference/contextualTyping9.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/contextualTyping9.ts(1,5): error TS2322: Type '({ id: number; } | { id: number; name: string; })[]' is not assignable to type '{ id: number; }[]'. +tests/cases/compiler/contextualTyping9.ts(1,42): error TS2322: Type '({ id: number; } | { id: number; name: string; })[]' is not assignable to type '{ id: number; }[]'. Type '{ id: number; } | { id: number; name: string; }' is not assignable to type '{ id: number; }'. Type '{ id: number; name: string; }' is not assignable to type '{ id: number; }'. Object literal may only specify known properties, and 'name' does not exist in type '{ id: number; }'. @@ -6,7 +6,7 @@ tests/cases/compiler/contextualTyping9.ts(1,5): error TS2322: Type '({ id: numbe ==== tests/cases/compiler/contextualTyping9.ts (1 errors) ==== var foo:{id:number;}[] = [{id:1}, {id:2, name:"foo"}]; - ~~~ + ~~~~~~~~~~ !!! error TS2322: Type '({ id: number; } | { id: number; name: string; })[]' is not assignable to type '{ id: number; }[]'. !!! error TS2322: Type '{ id: number; } | { id: number; name: string; }' is not assignable to type '{ id: number; }'. !!! error TS2322: Type '{ id: number; name: string; }' is not assignable to type '{ id: number; }'. diff --git a/tests/baselines/reference/derivedTypeAccessesHiddenBaseCallViaSuperPropertyAccess.errors.txt b/tests/baselines/reference/derivedTypeAccessesHiddenBaseCallViaSuperPropertyAccess.errors.txt index dc2db292eb5..19bf8d1ff22 100644 --- a/tests/baselines/reference/derivedTypeAccessesHiddenBaseCallViaSuperPropertyAccess.errors.txt +++ b/tests/baselines/reference/derivedTypeAccessesHiddenBaseCallViaSuperPropertyAccess.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/classes/propertyMemberDeclarations/memberFunctionDeclarations/derivedTypeAccessesHiddenBaseCallViaSuperPropertyAccess.ts(14,28): error TS2345: Argument of type '{ a: number; b: number; }' is not assignable to parameter of type '{ a: number; }'. +tests/cases/conformance/classes/propertyMemberDeclarations/memberFunctionDeclarations/derivedTypeAccessesHiddenBaseCallViaSuperPropertyAccess.ts(14,36): error TS2345: Argument of type '{ a: number; b: number; }' is not assignable to parameter of type '{ a: number; }'. Object literal may only specify known properties, and 'b' does not exist in type '{ a: number; }'. @@ -17,7 +17,7 @@ tests/cases/conformance/classes/propertyMemberDeclarations/memberFunctionDeclara bar() { var r = super.foo({ a: 1 }); // { a: number } var r2 = super.foo({ a: 1, b: 2 }); // { a: number } - ~~~~~~~~~~~~~~ + ~~~~ !!! error TS2345: Argument of type '{ a: number; b: number; }' is not assignable to parameter of type '{ a: number; }'. !!! error TS2345: Object literal may only specify known properties, and 'b' does not exist in type '{ a: number; }'. var r3 = this.foo({ a: 1, b: 2 }); // { a: number; b: number; } diff --git a/tests/baselines/reference/destructuringParameterProperties5.errors.txt b/tests/baselines/reference/destructuringParameterProperties5.errors.txt index 47e50b1df83..cfb38fde90b 100644 --- a/tests/baselines/reference/destructuringParameterProperties5.errors.txt +++ b/tests/baselines/reference/destructuringParameterProperties5.errors.txt @@ -7,7 +7,7 @@ tests/cases/conformance/es6/destructuring/destructuringParameterProperties5.ts(7 tests/cases/conformance/es6/destructuring/destructuringParameterProperties5.ts(7,51): error TS2339: Property 'x3' does not exist on type 'C1'. tests/cases/conformance/es6/destructuring/destructuringParameterProperties5.ts(7,62): error TS2339: Property 'y' does not exist on type 'C1'. tests/cases/conformance/es6/destructuring/destructuringParameterProperties5.ts(7,72): error TS2339: Property 'z' does not exist on type 'C1'. -tests/cases/conformance/es6/destructuring/destructuringParameterProperties5.ts(11,16): error TS2345: Argument of type '[{ x1: number; x2: string; x3: boolean; }, string, boolean]' is not assignable to parameter of type '[{ x: number; y: string; z: boolean; }, number, string]'. +tests/cases/conformance/es6/destructuring/destructuringParameterProperties5.ts(11,19): error TS2345: Argument of type '[{ x1: number; x2: string; x3: boolean; }, string, boolean]' is not assignable to parameter of type '[{ x: number; y: string; z: boolean; }, number, string]'. Types of property '0' are incompatible. Type '{ x1: number; x2: string; x3: boolean; }' is not assignable to type '{ x: number; y: string; z: boolean; }'. Object literal may only specify known properties, and 'x1' does not exist in type '{ x: number; y: string; z: boolean; }'. @@ -43,7 +43,7 @@ tests/cases/conformance/es6/destructuring/destructuringParameterProperties5.ts(1 } var a = new C1([{ x1: 10, x2: "", x3: true }, "", false]); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + ~~~~~~ !!! error TS2345: Argument of type '[{ x1: number; x2: string; x3: boolean; }, string, boolean]' is not assignable to parameter of type '[{ x: number; y: string; z: boolean; }, number, string]'. !!! error TS2345: Types of property '0' are incompatible. !!! error TS2345: Type '{ x1: number; x2: string; x3: boolean; }' is not assignable to type '{ x: number; y: string; z: boolean; }'. diff --git a/tests/baselines/reference/incompatibleTypes.errors.txt b/tests/baselines/reference/incompatibleTypes.errors.txt index e8763b0d54c..e612600a7f8 100644 --- a/tests/baselines/reference/incompatibleTypes.errors.txt +++ b/tests/baselines/reference/incompatibleTypes.errors.txt @@ -18,9 +18,9 @@ tests/cases/compiler/incompatibleTypes.ts(42,5): error TS2345: Argument of type Types of property 'p1' are incompatible. Type '() => string' is not assignable to type '(s: string) => number'. Type 'string' is not assignable to type 'number'. -tests/cases/compiler/incompatibleTypes.ts(49,5): error TS2345: Argument of type '{ e: number; f: number; }' is not assignable to parameter of type '{ c: { b: string; }; d: string; }'. +tests/cases/compiler/incompatibleTypes.ts(49,7): error TS2345: Argument of type '{ e: number; f: number; }' is not assignable to parameter of type '{ c: { b: string; }; d: string; }'. Object literal may only specify known properties, and 'e' does not exist in type '{ c: { b: string; }; d: string; }'. -tests/cases/compiler/incompatibleTypes.ts(66,5): error TS2322: Type '{ e: number; f: number; }' is not assignable to type '{ a: { a: string; }; b: string; }'. +tests/cases/compiler/incompatibleTypes.ts(66,47): error TS2322: Type '{ e: number; f: number; }' is not assignable to type '{ a: { a: string; }; b: string; }'. Object literal may only specify known properties, and 'e' does not exist in type '{ a: { a: string; }; b: string; }'. tests/cases/compiler/incompatibleTypes.ts(72,5): error TS2322: Type 'number' is not assignable to type '() => string'. tests/cases/compiler/incompatibleTypes.ts(74,5): error TS2322: Type '(a: any) => number' is not assignable to type '() => any'. @@ -101,7 +101,7 @@ tests/cases/compiler/incompatibleTypes.ts(74,5): error TS2322: Type '(a: any) => function of1(a: any) { return null; } of1({ e: 0, f: 0 }); - ~~~~~~~~~~~~~~ + ~~~~ !!! error TS2345: Argument of type '{ e: number; f: number; }' is not assignable to parameter of type '{ c: { b: string; }; d: string; }'. !!! error TS2345: Object literal may only specify known properties, and 'e' does not exist in type '{ c: { b: string; }; d: string; }'. @@ -121,7 +121,7 @@ tests/cases/compiler/incompatibleTypes.ts(74,5): error TS2322: Type '(a: any) => } var o1: { a: { a: string; }; b: string; } = { e: 0, f: 0 }; - ~~ + ~~~~ !!! error TS2322: Type '{ e: number; f: number; }' is not assignable to type '{ a: { a: string; }; b: string; }'. !!! error TS2322: Object literal may only specify known properties, and 'e' does not exist in type '{ a: { a: string; }; b: string; }'. diff --git a/tests/baselines/reference/logicalOrExpressionIsContextuallyTyped.errors.txt b/tests/baselines/reference/logicalOrExpressionIsContextuallyTyped.errors.txt index bd210c55570..484c8f63b46 100644 --- a/tests/baselines/reference/logicalOrExpressionIsContextuallyTyped.errors.txt +++ b/tests/baselines/reference/logicalOrExpressionIsContextuallyTyped.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/expressions/binaryOperators/logicalOrOperator/logicalOrExpressionIsContextuallyTyped.ts(6,5): error TS2322: Type '{ a: string; b: number; } | { a: string; b: boolean; }' is not assignable to type '{ a: string; }'. +tests/cases/conformance/expressions/binaryOperators/logicalOrOperator/logicalOrExpressionIsContextuallyTyped.ts(6,33): error TS2322: Type '{ a: string; b: number; } | { a: string; b: boolean; }' is not assignable to type '{ a: string; }'. Type '{ a: string; b: number; }' is not assignable to type '{ a: string; }'. Object literal may only specify known properties, and 'b' does not exist in type '{ a: string; }'. @@ -10,7 +10,7 @@ tests/cases/conformance/expressions/binaryOperators/logicalOrOperator/logicalOrE // operand types. var r: { a: string } = { a: '', b: 123 } || { a: '', b: true }; - ~ + ~~~~~~ !!! error TS2322: Type '{ a: string; b: number; } | { a: string; b: boolean; }' is not assignable to type '{ a: string; }'. !!! error TS2322: Type '{ a: string; b: number; }' is not assignable to type '{ a: string; }'. !!! error TS2322: Object literal may only specify known properties, and 'b' does not exist in type '{ a: string; }'. \ No newline at end of file diff --git a/tests/baselines/reference/objectLitStructuralTypeMismatch.errors.txt b/tests/baselines/reference/objectLitStructuralTypeMismatch.errors.txt index 465c4d6d9f6..1b79e4db5ad 100644 --- a/tests/baselines/reference/objectLitStructuralTypeMismatch.errors.txt +++ b/tests/baselines/reference/objectLitStructuralTypeMismatch.errors.txt @@ -1,10 +1,10 @@ -tests/cases/compiler/objectLitStructuralTypeMismatch.ts(2,5): error TS2322: Type '{ b: number; }' is not assignable to type '{ a: number; }'. +tests/cases/compiler/objectLitStructuralTypeMismatch.ts(2,27): error TS2322: Type '{ b: number; }' is not assignable to type '{ a: number; }'. Object literal may only specify known properties, and 'b' does not exist in type '{ a: number; }'. ==== tests/cases/compiler/objectLitStructuralTypeMismatch.ts (1 errors) ==== // Shouldn't compile var x: { a: number; } = { b: 5 }; - ~ + ~~~~ !!! error TS2322: Type '{ b: number; }' is not assignable to type '{ a: number; }'. !!! error TS2322: Object literal may only specify known properties, and 'b' does not exist in type '{ a: number; }'. \ No newline at end of file diff --git a/tests/baselines/reference/objectLiteralFunctionArgContextualTyping.errors.txt b/tests/baselines/reference/objectLiteralFunctionArgContextualTyping.errors.txt index 149aca43a42..fb2cbdaf649 100644 --- a/tests/baselines/reference/objectLiteralFunctionArgContextualTyping.errors.txt +++ b/tests/baselines/reference/objectLiteralFunctionArgContextualTyping.errors.txt @@ -1,6 +1,6 @@ -tests/cases/compiler/objectLiteralFunctionArgContextualTyping.ts(8,4): error TS2345: Argument of type '{ hello: number; }' is not assignable to parameter of type 'I'. +tests/cases/compiler/objectLiteralFunctionArgContextualTyping.ts(8,6): error TS2345: Argument of type '{ hello: number; }' is not assignable to parameter of type 'I'. Object literal may only specify known properties, and 'hello' does not exist in type 'I'. -tests/cases/compiler/objectLiteralFunctionArgContextualTyping.ts(10,4): error TS2345: Argument of type '{ value: string; what: number; }' is not assignable to parameter of type 'I'. +tests/cases/compiler/objectLiteralFunctionArgContextualTyping.ts(10,17): error TS2345: Argument of type '{ value: string; what: number; }' is not assignable to parameter of type 'I'. Object literal may only specify known properties, and 'what' does not exist in type 'I'. tests/cases/compiler/objectLiteralFunctionArgContextualTyping.ts(11,4): error TS2345: Argument of type '{ toString: (s: string) => string; }' is not assignable to parameter of type 'I'. Property 'value' is missing in type '{ toString: (s: string) => string; }'. @@ -18,12 +18,12 @@ tests/cases/compiler/objectLiteralFunctionArgContextualTyping.ts(13,36): error T function f2(args: I) { } f2({ hello: 1 }) // error - ~~~~~~~~~~~~ + ~~~~~~~~ !!! error TS2345: Argument of type '{ hello: number; }' is not assignable to parameter of type 'I'. !!! error TS2345: Object literal may only specify known properties, and 'hello' does not exist in type 'I'. f2({ value: '' }) // missing toString satisfied by Object's member f2({ value: '', what: 1 }) // missing toString satisfied by Object's member - ~~~~~~~~~~~~~~~~~~~~~~ + ~~~~~~~ !!! error TS2345: Argument of type '{ value: string; what: number; }' is not assignable to parameter of type 'I'. !!! error TS2345: Object literal may only specify known properties, and 'what' does not exist in type 'I'. f2({ toString: (s) => s }) // error, missing property value from ArgsString diff --git a/tests/baselines/reference/objectLiteralFunctionArgContextualTyping2.errors.txt b/tests/baselines/reference/objectLiteralFunctionArgContextualTyping2.errors.txt index 367a676abc6..b967b227809 100644 --- a/tests/baselines/reference/objectLiteralFunctionArgContextualTyping2.errors.txt +++ b/tests/baselines/reference/objectLiteralFunctionArgContextualTyping2.errors.txt @@ -1,8 +1,8 @@ -tests/cases/compiler/objectLiteralFunctionArgContextualTyping2.ts(8,4): error TS2345: Argument of type '{ hello: number; }' is not assignable to parameter of type 'I2'. +tests/cases/compiler/objectLiteralFunctionArgContextualTyping2.ts(8,6): error TS2345: Argument of type '{ hello: number; }' is not assignable to parameter of type 'I2'. Object literal may only specify known properties, and 'hello' does not exist in type 'I2'. tests/cases/compiler/objectLiteralFunctionArgContextualTyping2.ts(9,4): error TS2345: Argument of type '{ value: string; }' is not assignable to parameter of type 'I2'. Property 'doStuff' is missing in type '{ value: string; }'. -tests/cases/compiler/objectLiteralFunctionArgContextualTyping2.ts(10,4): error TS2345: Argument of type '{ value: string; what: number; }' is not assignable to parameter of type 'I2'. +tests/cases/compiler/objectLiteralFunctionArgContextualTyping2.ts(10,17): error TS2345: Argument of type '{ value: string; what: number; }' is not assignable to parameter of type 'I2'. Object literal may only specify known properties, and 'what' does not exist in type 'I2'. tests/cases/compiler/objectLiteralFunctionArgContextualTyping2.ts(11,4): error TS2345: Argument of type '{ toString: (s: any) => any; }' is not assignable to parameter of type 'I2'. Property 'value' is missing in type '{ toString: (s: any) => any; }'. @@ -21,7 +21,7 @@ tests/cases/compiler/objectLiteralFunctionArgContextualTyping2.ts(13,4): error T function f2(args: I2) { } f2({ hello: 1 }) - ~~~~~~~~~~~~ + ~~~~~~~~ !!! error TS2345: Argument of type '{ hello: number; }' is not assignable to parameter of type 'I2'. !!! error TS2345: Object literal may only specify known properties, and 'hello' does not exist in type 'I2'. f2({ value: '' }) @@ -29,7 +29,7 @@ tests/cases/compiler/objectLiteralFunctionArgContextualTyping2.ts(13,4): error T !!! error TS2345: Argument of type '{ value: string; }' is not assignable to parameter of type 'I2'. !!! error TS2345: Property 'doStuff' is missing in type '{ value: string; }'. f2({ value: '', what: 1 }) - ~~~~~~~~~~~~~~~~~~~~~~ + ~~~~~~~ !!! error TS2345: Argument of type '{ value: string; what: number; }' is not assignable to parameter of type 'I2'. !!! error TS2345: Object literal may only specify known properties, and 'what' does not exist in type 'I2'. f2({ toString: (s) => s }) diff --git a/tests/baselines/reference/objectLiteralShorthandPropertiesAssignmentError.errors.txt b/tests/baselines/reference/objectLiteralShorthandPropertiesAssignmentError.errors.txt index d00a8ddf074..50839d5e56b 100644 --- a/tests/baselines/reference/objectLiteralShorthandPropertiesAssignmentError.errors.txt +++ b/tests/baselines/reference/objectLiteralShorthandPropertiesAssignmentError.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesAssignmentError.ts(4,5): error TS2322: Type '{ name: string; id: number; }' is not assignable to type '{ b: string; id: number; }'. +tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesAssignmentError.ts(4,43): error TS2322: Type '{ name: string; id: number; }' is not assignable to type '{ b: string; id: number; }'. Object literal may only specify known properties, and 'name' does not exist in type '{ b: string; id: number; }'. tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesAssignmentError.ts(5,16): error TS1131: Property or signature expected. tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesAssignmentError.ts(5,22): error TS2403: Subsequent variable declarations must have the same type. Variable 'id' must be of type 'number', but here has type 'any'. @@ -16,7 +16,7 @@ tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPr var name: string = "my name"; var person: { b: string; id: number } = { name, id }; // error - ~~~~~~ + ~~~~ !!! error TS2322: Type '{ name: string; id: number; }' is not assignable to type '{ b: string; id: number; }'. !!! error TS2322: Object literal may only specify known properties, and 'name' does not exist in type '{ b: string; id: number; }'. var person1: { name, id }; // error: can't use short-hand property assignment in type position diff --git a/tests/baselines/reference/objectLiteralShorthandPropertiesAssignmentErrorFromMissingIdentifier.errors.txt b/tests/baselines/reference/objectLiteralShorthandPropertiesAssignmentErrorFromMissingIdentifier.errors.txt index f6f4f625c45..b4f695c835d 100644 --- a/tests/baselines/reference/objectLiteralShorthandPropertiesAssignmentErrorFromMissingIdentifier.errors.txt +++ b/tests/baselines/reference/objectLiteralShorthandPropertiesAssignmentErrorFromMissingIdentifier.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesAssignmentErrorFromMissingIdentifier.ts(4,5): error TS2322: Type '{ name: string; id: number; }' is not assignable to type '{ b: string; id: number; }'. +tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesAssignmentErrorFromMissingIdentifier.ts(4,43): error TS2322: Type '{ name: string; id: number; }' is not assignable to type '{ b: string; id: number; }'. Object literal may only specify known properties, and 'name' does not exist in type '{ b: string; id: number; }'. tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesAssignmentErrorFromMissingIdentifier.ts(5,79): error TS2322: Type '{ name: string; id: number; }' is not assignable to type '{ name: number; id: string; }'. Types of property 'name' are incompatible. @@ -16,7 +16,7 @@ tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPr var name: string = "my name"; var person: { b: string; id: number } = { name, id }; // error - ~~~~~~ + ~~~~ !!! error TS2322: Type '{ name: string; id: number; }' is not assignable to type '{ b: string; id: number; }'. !!! error TS2322: Object literal may only specify known properties, and 'name' does not exist in type '{ b: string; id: number; }'. function bar(name: string, id: number): { name: number, id: string } { return { name, id }; } // error diff --git a/tests/baselines/reference/orderMattersForSignatureGroupIdentity.errors.txt b/tests/baselines/reference/orderMattersForSignatureGroupIdentity.errors.txt index 47401a7ae8b..f108f0ea92d 100644 --- a/tests/baselines/reference/orderMattersForSignatureGroupIdentity.errors.txt +++ b/tests/baselines/reference/orderMattersForSignatureGroupIdentity.errors.txt @@ -1,7 +1,7 @@ -tests/cases/compiler/orderMattersForSignatureGroupIdentity.ts(19,3): error TS2345: Argument of type '{ s: string; n: number; }' is not assignable to parameter of type '{ n: number; }'. +tests/cases/compiler/orderMattersForSignatureGroupIdentity.ts(19,5): error TS2345: Argument of type '{ s: string; n: number; }' is not assignable to parameter of type '{ n: number; }'. Object literal may only specify known properties, and 's' does not exist in type '{ n: number; }'. tests/cases/compiler/orderMattersForSignatureGroupIdentity.ts(22,5): error TS2403: Subsequent variable declarations must have the same type. Variable 'w' must be of type 'A', but here has type 'C'. -tests/cases/compiler/orderMattersForSignatureGroupIdentity.ts(24,3): error TS2345: Argument of type '{ s: string; n: number; }' is not assignable to parameter of type '{ n: number; }'. +tests/cases/compiler/orderMattersForSignatureGroupIdentity.ts(24,5): error TS2345: Argument of type '{ s: string; n: number; }' is not assignable to parameter of type '{ n: number; }'. Object literal may only specify known properties, and 's' does not exist in type '{ n: number; }'. @@ -25,7 +25,7 @@ tests/cases/compiler/orderMattersForSignatureGroupIdentity.ts(24,3): error TS234 var v: B; v({ s: "", n: 0 }).toLowerCase(); - ~~~~~~~~~~~~~~~ + ~~~~~ !!! error TS2345: Argument of type '{ s: string; n: number; }' is not assignable to parameter of type '{ n: number; }'. !!! error TS2345: Object literal may only specify known properties, and 's' does not exist in type '{ n: number; }'. @@ -35,6 +35,6 @@ tests/cases/compiler/orderMattersForSignatureGroupIdentity.ts(24,3): error TS234 !!! error TS2403: Subsequent variable declarations must have the same type. Variable 'w' must be of type 'A', but here has type 'C'. w({ s: "", n: 0 }).toLowerCase(); - ~~~~~~~~~~~~~~~ + ~~~~~ !!! error TS2345: Argument of type '{ s: string; n: number; }' is not assignable to parameter of type '{ n: number; }'. !!! error TS2345: Object literal may only specify known properties, and 's' does not exist in type '{ n: number; }'. \ No newline at end of file diff --git a/tests/baselines/reference/switchStatements.errors.txt b/tests/baselines/reference/switchStatements.errors.txt index aa5b796e252..c99b0eba909 100644 --- a/tests/baselines/reference/switchStatements.errors.txt +++ b/tests/baselines/reference/switchStatements.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/statements/switchStatements/switchStatements.ts(35,10): error TS2322: Type '{ id: number; name: string; }' is not assignable to type 'C'. +tests/cases/conformance/statements/switchStatements/switchStatements.ts(35,20): error TS2322: Type '{ id: number; name: string; }' is not assignable to type 'C'. Object literal may only specify known properties, and 'name' does not exist in type 'C'. @@ -38,7 +38,7 @@ tests/cases/conformance/statements/switchStatements/switchStatements.ts(35,10): switch (new C()) { case new D(): case { id: 12, name: '' }: - ~~~~~~~~~~~~~~~~~~~~ + ~~~~~~~~ !!! error TS2322: Type '{ id: number; name: string; }' is not assignable to type 'C'. !!! error TS2322: Object literal may only specify known properties, and 'name' does not exist in type 'C'. case new C(): diff --git a/tests/baselines/reference/symbolProperty21.errors.txt b/tests/baselines/reference/symbolProperty21.errors.txt index b9162acc84f..fa9cabc9b61 100644 --- a/tests/baselines/reference/symbolProperty21.errors.txt +++ b/tests/baselines/reference/symbolProperty21.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/es6/Symbols/symbolProperty21.ts(8,5): error TS2345: Argument of type '{ [Symbol.isConcatSpreadable]: string; [Symbol.toPrimitive]: number; [Symbol.unscopables]: boolean; }' is not assignable to parameter of type 'I'. +tests/cases/conformance/es6/Symbols/symbolProperty21.ts(10,5): error TS2345: Argument of type '{ [Symbol.isConcatSpreadable]: string; [Symbol.toPrimitive]: number; [Symbol.unscopables]: boolean; }' is not assignable to parameter of type 'I'. Object literal may only specify known properties, and '[Symbol.toPrimitive]' does not exist in type 'I'. @@ -11,14 +11,10 @@ tests/cases/conformance/es6/Symbols/symbolProperty21.ts(8,5): error TS2345: Argu declare function foo(p: I): { t: T; u: U }; foo({ - ~ [Symbol.isConcatSpreadable]: "", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Symbol.toPrimitive]: 0, - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - [Symbol.unscopables]: true - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - }); - ~ + ~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS2345: Argument of type '{ [Symbol.isConcatSpreadable]: string; [Symbol.toPrimitive]: number; [Symbol.unscopables]: boolean; }' is not assignable to parameter of type 'I'. -!!! error TS2345: Object literal may only specify known properties, and '[Symbol.toPrimitive]' does not exist in type 'I'. \ No newline at end of file +!!! error TS2345: Object literal may only specify known properties, and '[Symbol.toPrimitive]' does not exist in type 'I'. + [Symbol.unscopables]: true + }); \ No newline at end of file diff --git a/tests/baselines/reference/taggedTemplateStringsTypeArgumentInference.errors.txt b/tests/baselines/reference/taggedTemplateStringsTypeArgumentInference.errors.txt index 6464366d33d..be5c21f1a0b 100644 --- a/tests/baselines/reference/taggedTemplateStringsTypeArgumentInference.errors.txt +++ b/tests/baselines/reference/taggedTemplateStringsTypeArgumentInference.errors.txt @@ -1,6 +1,6 @@ tests/cases/conformance/es6/templates/taggedTemplateStringsTypeArgumentInference.ts(64,11): error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly. Type argument candidate 'string' is not a valid type argument because it is not a supertype of candidate 'number'. -tests/cases/conformance/es6/templates/taggedTemplateStringsTypeArgumentInference.ts(77,11): error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly. +tests/cases/conformance/es6/templates/taggedTemplateStringsTypeArgumentInference.ts(77,79): error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly. Type argument candidate '{ x: number; z: Date; }' is not a valid type argument because it is not a supertype of candidate '{ x: number; y: string; }'. Object literal may only specify known properties, and 'y' does not exist in type '{ x: number; z: Date; }'. @@ -86,7 +86,7 @@ tests/cases/conformance/es6/templates/taggedTemplateStringsTypeArgumentInference } var a9e = someGenerics9 `${ undefined }${ { x: 6, z: new Date() } }${ { x: 6, y: '' } }`; - ~~~~~~~~~~~~~ + ~~~~~ !!! error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly. !!! error TS2453: Type argument candidate '{ x: number; z: Date; }' is not a valid type argument because it is not a supertype of candidate '{ x: number; y: string; }'. !!! error TS2453: Object literal may only specify known properties, and 'y' does not exist in type '{ x: number; z: Date; }'. diff --git a/tests/baselines/reference/taggedTemplateStringsTypeArgumentInferenceES6.errors.txt b/tests/baselines/reference/taggedTemplateStringsTypeArgumentInferenceES6.errors.txt index be8c517d39c..63d04a42b3b 100644 --- a/tests/baselines/reference/taggedTemplateStringsTypeArgumentInferenceES6.errors.txt +++ b/tests/baselines/reference/taggedTemplateStringsTypeArgumentInferenceES6.errors.txt @@ -1,6 +1,6 @@ tests/cases/conformance/es6/templates/taggedTemplateStringsTypeArgumentInferenceES6.ts(63,11): error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly. Type argument candidate 'string' is not a valid type argument because it is not a supertype of candidate 'number'. -tests/cases/conformance/es6/templates/taggedTemplateStringsTypeArgumentInferenceES6.ts(76,11): error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly. +tests/cases/conformance/es6/templates/taggedTemplateStringsTypeArgumentInferenceES6.ts(76,79): error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly. Type argument candidate '{ x: number; z: Date; }' is not a valid type argument because it is not a supertype of candidate '{ x: number; y: string; }'. Object literal may only specify known properties, and 'y' does not exist in type '{ x: number; z: Date; }'. @@ -85,7 +85,7 @@ tests/cases/conformance/es6/templates/taggedTemplateStringsTypeArgumentInference } var a9e = someGenerics9 `${ undefined }${ { x: 6, z: new Date() } }${ { x: 6, y: '' } }`; - ~~~~~~~~~~~~~ + ~~~~~ !!! error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly. !!! error TS2453: Type argument candidate '{ x: number; z: Date; }' is not a valid type argument because it is not a supertype of candidate '{ x: number; y: string; }'. !!! error TS2453: Object literal may only specify known properties, and 'y' does not exist in type '{ x: number; z: Date; }'. diff --git a/tests/baselines/reference/typeArgInference2.errors.txt b/tests/baselines/reference/typeArgInference2.errors.txt index 71d2a13f4a1..b7201fd1033 100644 --- a/tests/baselines/reference/typeArgInference2.errors.txt +++ b/tests/baselines/reference/typeArgInference2.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/typeArgInference2.ts(12,10): error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly. +tests/cases/compiler/typeArgInference2.ts(12,52): error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly. Type argument candidate '{ name: string; a: number; }' is not a valid type argument because it is not a supertype of candidate '{ name: string; b: number; }'. Object literal may only specify known properties, and 'b' does not exist in type '{ name: string; a: number; }'. @@ -16,7 +16,7 @@ tests/cases/compiler/typeArgInference2.ts(12,10): error TS2453: The type argumen var z4 = foo({ name: "abc" }); // { name: string } var z5 = foo({ name: "abc", a: 5 }); // { name: string; a: number } var z6 = foo({ name: "abc", a: 5 }, { name: "def", b: 5 }); // error - ~~~ + ~~~~ !!! error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly. !!! error TS2453: Type argument candidate '{ name: string; a: number; }' is not a valid type argument because it is not a supertype of candidate '{ name: string; b: number; }'. !!! error TS2453: Object literal may only specify known properties, and 'b' does not exist in type '{ name: string; a: number; }'. \ No newline at end of file diff --git a/tests/baselines/reference/typeArgumentInference.errors.txt b/tests/baselines/reference/typeArgumentInference.errors.txt index 669ebadd28a..51cf4ccf7d2 100644 --- a/tests/baselines/reference/typeArgumentInference.errors.txt +++ b/tests/baselines/reference/typeArgumentInference.errors.txt @@ -1,9 +1,9 @@ tests/cases/conformance/expressions/functionCalls/typeArgumentInference.ts(68,11): error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly. Type argument candidate 'string' is not a valid type argument because it is not a supertype of candidate 'number'. -tests/cases/conformance/expressions/functionCalls/typeArgumentInference.ts(82,11): error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly. +tests/cases/conformance/expressions/functionCalls/typeArgumentInference.ts(82,69): error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly. Type argument candidate '{ x: number; z: Date; }' is not a valid type argument because it is not a supertype of candidate '{ x: number; y: string; }'. Object literal may only specify known properties, and 'y' does not exist in type '{ x: number; z: Date; }'. -tests/cases/conformance/expressions/functionCalls/typeArgumentInference.ts(84,66): error TS2345: Argument of type '{ x: number; y: string; }' is not assignable to parameter of type 'A92'. +tests/cases/conformance/expressions/functionCalls/typeArgumentInference.ts(84,74): error TS2345: Argument of type '{ x: number; y: string; }' is not assignable to parameter of type 'A92'. Object literal may only specify known properties, and 'y' does not exist in type 'A92'. @@ -93,13 +93,13 @@ tests/cases/conformance/expressions/functionCalls/typeArgumentInference.ts(84,66 z?: Date; } var a9e = someGenerics9(undefined, { x: 6, z: new Date() }, { x: 6, y: '' }); - ~~~~~~~~~~~~~ + ~~~~~ !!! error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly. !!! error TS2453: Type argument candidate '{ x: number; z: Date; }' is not a valid type argument because it is not a supertype of candidate '{ x: number; y: string; }'. !!! error TS2453: Object literal may only specify known properties, and 'y' does not exist in type '{ x: number; z: Date; }'. var a9e: {}; var a9f = someGenerics9(undefined, { x: 6, z: new Date() }, { x: 6, y: '' }); - ~~~~~~~~~~~~~~~ + ~~~~~ !!! error TS2345: Argument of type '{ x: number; y: string; }' is not assignable to parameter of type 'A92'. !!! error TS2345: Object literal may only specify known properties, and 'y' does not exist in type 'A92'. var a9f: A92; diff --git a/tests/baselines/reference/typeArgumentInferenceConstructSignatures.errors.txt b/tests/baselines/reference/typeArgumentInferenceConstructSignatures.errors.txt index 305eee1c941..d058426b9c9 100644 --- a/tests/baselines/reference/typeArgumentInferenceConstructSignatures.errors.txt +++ b/tests/baselines/reference/typeArgumentInferenceConstructSignatures.errors.txt @@ -12,12 +12,12 @@ tests/cases/conformance/expressions/functionCalls/typeArgumentInferenceConstruct tests/cases/conformance/expressions/functionCalls/typeArgumentInferenceConstructSignatures.ts(106,15): error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly. Type argument candidate 'string' is not a valid type argument because it is not a supertype of candidate 'number'. tests/cases/conformance/expressions/functionCalls/typeArgumentInferenceConstructSignatures.ts(118,9): error TS2304: Cannot find name 'Window'. -tests/cases/conformance/expressions/functionCalls/typeArgumentInferenceConstructSignatures.ts(120,15): error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly. +tests/cases/conformance/expressions/functionCalls/typeArgumentInferenceConstructSignatures.ts(120,51): error TS2304: Cannot find name 'window'. +tests/cases/conformance/expressions/functionCalls/typeArgumentInferenceConstructSignatures.ts(120,69): error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly. Type argument candidate '{ x: number; z: any; }' is not a valid type argument because it is not a supertype of candidate '{ x: number; y: string; }'. Object literal may only specify known properties, and 'y' does not exist in type '{ x: number; z: any; }'. -tests/cases/conformance/expressions/functionCalls/typeArgumentInferenceConstructSignatures.ts(120,51): error TS2304: Cannot find name 'window'. tests/cases/conformance/expressions/functionCalls/typeArgumentInferenceConstructSignatures.ts(122,56): error TS2304: Cannot find name 'window'. -tests/cases/conformance/expressions/functionCalls/typeArgumentInferenceConstructSignatures.ts(122,66): error TS2345: Argument of type '{ x: number; y: string; }' is not assignable to parameter of type 'A92'. +tests/cases/conformance/expressions/functionCalls/typeArgumentInferenceConstructSignatures.ts(122,74): error TS2345: Argument of type '{ x: number; y: string; }' is not assignable to parameter of type 'A92'. Object literal may only specify known properties, and 'y' does not exist in type 'A92'. @@ -163,17 +163,17 @@ tests/cases/conformance/expressions/functionCalls/typeArgumentInferenceConstruct !!! error TS2304: Cannot find name 'Window'. } var a9e = new someGenerics9(undefined, { x: 6, z: window }, { x: 6, y: '' }); - ~~~~~~~~~~~~~ + ~~~~~~ +!!! error TS2304: Cannot find name 'window'. + ~~~~~ !!! error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly. !!! error TS2453: Type argument candidate '{ x: number; z: any; }' is not a valid type argument because it is not a supertype of candidate '{ x: number; y: string; }'. !!! error TS2453: Object literal may only specify known properties, and 'y' does not exist in type '{ x: number; z: any; }'. - ~~~~~~ -!!! error TS2304: Cannot find name 'window'. var a9e: {}; var a9f = new someGenerics9(undefined, { x: 6, z: window }, { x: 6, y: '' }); ~~~~~~ !!! error TS2304: Cannot find name 'window'. - ~~~~~~~~~~~~~~~ + ~~~~~ !!! error TS2345: Argument of type '{ x: number; y: string; }' is not assignable to parameter of type 'A92'. !!! error TS2345: Object literal may only specify known properties, and 'y' does not exist in type 'A92'. var a9f: A92; diff --git a/tests/baselines/reference/typeArgumentInferenceWithConstraints.errors.txt b/tests/baselines/reference/typeArgumentInferenceWithConstraints.errors.txt index 6b81cd6f232..0c1e8cc4e97 100644 --- a/tests/baselines/reference/typeArgumentInferenceWithConstraints.errors.txt +++ b/tests/baselines/reference/typeArgumentInferenceWithConstraints.errors.txt @@ -17,12 +17,12 @@ tests/cases/conformance/expressions/functionCalls/typeArgumentInferenceWithConst tests/cases/conformance/expressions/functionCalls/typeArgumentInferenceWithConstraints.ts(73,11): error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly. Type argument candidate 'string' is not a valid type argument because it is not a supertype of candidate 'number'. tests/cases/conformance/expressions/functionCalls/typeArgumentInferenceWithConstraints.ts(85,9): error TS2304: Cannot find name 'Window'. -tests/cases/conformance/expressions/functionCalls/typeArgumentInferenceWithConstraints.ts(87,11): error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly. +tests/cases/conformance/expressions/functionCalls/typeArgumentInferenceWithConstraints.ts(87,47): error TS2304: Cannot find name 'window'. +tests/cases/conformance/expressions/functionCalls/typeArgumentInferenceWithConstraints.ts(87,65): error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly. Type argument candidate '{ x: number; z: any; }' is not a valid type argument because it is not a supertype of candidate '{ x: number; y: string; }'. Object literal may only specify known properties, and 'y' does not exist in type '{ x: number; z: any; }'. -tests/cases/conformance/expressions/functionCalls/typeArgumentInferenceWithConstraints.ts(87,47): error TS2304: Cannot find name 'window'. tests/cases/conformance/expressions/functionCalls/typeArgumentInferenceWithConstraints.ts(89,52): error TS2304: Cannot find name 'window'. -tests/cases/conformance/expressions/functionCalls/typeArgumentInferenceWithConstraints.ts(89,62): error TS2345: Argument of type '{ x: number; y: string; }' is not assignable to parameter of type 'A92'. +tests/cases/conformance/expressions/functionCalls/typeArgumentInferenceWithConstraints.ts(89,70): error TS2345: Argument of type '{ x: number; y: string; }' is not assignable to parameter of type 'A92'. Object literal may only specify known properties, and 'y' does not exist in type 'A92'. @@ -145,17 +145,17 @@ tests/cases/conformance/expressions/functionCalls/typeArgumentInferenceWithConst !!! error TS2304: Cannot find name 'Window'. } var a9e = someGenerics9(undefined, { x: 6, z: window }, { x: 6, y: '' }); - ~~~~~~~~~~~~~ + ~~~~~~ +!!! error TS2304: Cannot find name 'window'. + ~~~~~ !!! error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly. !!! error TS2453: Type argument candidate '{ x: number; z: any; }' is not a valid type argument because it is not a supertype of candidate '{ x: number; y: string; }'. !!! error TS2453: Object literal may only specify known properties, and 'y' does not exist in type '{ x: number; z: any; }'. - ~~~~~~ -!!! error TS2304: Cannot find name 'window'. var a9e: {}; var a9f = someGenerics9(undefined, { x: 6, z: window }, { x: 6, y: '' }); ~~~~~~ !!! error TS2304: Cannot find name 'window'. - ~~~~~~~~~~~~~~~ + ~~~~~ !!! error TS2345: Argument of type '{ x: number; y: string; }' is not assignable to parameter of type 'A92'. !!! error TS2345: Object literal may only specify known properties, and 'y' does not exist in type 'A92'. var a9f: A92; diff --git a/tests/baselines/reference/typeInfer1.errors.txt b/tests/baselines/reference/typeInfer1.errors.txt index 2550bb1fe8d..6f26b2e6054 100644 --- a/tests/baselines/reference/typeInfer1.errors.txt +++ b/tests/baselines/reference/typeInfer1.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/typeInfer1.ts(11,5): error TS2322: Type '{ Moo: () => string; }' is not assignable to type 'ITextWriter2'. +tests/cases/compiler/typeInfer1.ts(12,5): error TS2322: Type '{ Moo: () => string; }' is not assignable to type 'ITextWriter2'. Object literal may only specify known properties, and 'Moo' does not exist in type 'ITextWriter2'. @@ -14,8 +14,8 @@ tests/cases/compiler/typeInfer1.ts(11,5): error TS2322: Type '{ Moo: () => strin } var yyyyyyyy: ITextWriter2 = { - ~~~~~~~~ + Moo: function() { return "cow"; } + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS2322: Type '{ Moo: () => string; }' is not assignable to type 'ITextWriter2'. !!! error TS2322: Object literal may only specify known properties, and 'Moo' does not exist in type 'ITextWriter2'. - Moo: function() { return "cow"; } } \ No newline at end of file diff --git a/tests/baselines/reference/typeMatch2.errors.txt b/tests/baselines/reference/typeMatch2.errors.txt index a497551c953..e82439c0ad5 100644 --- a/tests/baselines/reference/typeMatch2.errors.txt +++ b/tests/baselines/reference/typeMatch2.errors.txt @@ -2,9 +2,9 @@ tests/cases/compiler/typeMatch2.ts(3,2): error TS2322: Type '{}' is not assignab Property 'x' is missing in type '{}'. tests/cases/compiler/typeMatch2.ts(4,5): error TS2322: Type '{ x: number; }' is not assignable to type '{ x: number; y: number; }'. Property 'y' is missing in type '{ x: number; }'. -tests/cases/compiler/typeMatch2.ts(5,2): error TS2322: Type '{ x: number; y: number; z: number; }' is not assignable to type '{ x: number; y: number; }'. +tests/cases/compiler/typeMatch2.ts(5,20): error TS2322: Type '{ x: number; y: number; z: number; }' is not assignable to type '{ x: number; y: number; }'. Object literal may only specify known properties, and 'z' does not exist in type '{ x: number; y: number; }'. -tests/cases/compiler/typeMatch2.ts(6,5): error TS2322: Type '{ x: number; z: number; }' is not assignable to type '{ x: number; y: number; }'. +tests/cases/compiler/typeMatch2.ts(6,17): error TS2322: Type '{ x: number; z: number; }' is not assignable to type '{ x: number; y: number; }'. Object literal may only specify known properties, and 'z' does not exist in type '{ x: number; y: number; }'. tests/cases/compiler/typeMatch2.ts(18,5): error TS2322: Type 'Animal[]' is not assignable to type 'Giraffe[]'. Type 'Animal' is not assignable to type 'Giraffe'. @@ -13,7 +13,7 @@ tests/cases/compiler/typeMatch2.ts(22,5): error TS2322: Type '{ f1: number; f2: Types of property 'f2' are incompatible. Type 'Animal[]' is not assignable to type 'Giraffe[]'. Type 'Animal' is not assignable to type 'Giraffe'. -tests/cases/compiler/typeMatch2.ts(34,5): error TS2322: Type '{ x: number; y: any; z: number; }' is not assignable to type '{ x: number; y: number; }'. +tests/cases/compiler/typeMatch2.ts(34,26): error TS2322: Type '{ x: number; y: any; z: number; }' is not assignable to type '{ x: number; y: number; }'. Object literal may only specify known properties, and 'z' does not exist in type '{ x: number; y: number; }'. tests/cases/compiler/typeMatch2.ts(35,5): error TS2322: Type '{ x: number; }' is not assignable to type '{ x: number; y: number; }'. Property 'y' is missing in type '{ x: number; }'. @@ -31,11 +31,11 @@ tests/cases/compiler/typeMatch2.ts(35,5): error TS2322: Type '{ x: number; }' is !!! error TS2322: Type '{ x: number; }' is not assignable to type '{ x: number; y: number; }'. !!! error TS2322: Property 'y' is missing in type '{ x: number; }'. a = { x: 1, y: 2, z: 3 }; - ~ + ~~~~ !!! error TS2322: Type '{ x: number; y: number; z: number; }' is not assignable to type '{ x: number; y: number; }'. !!! error TS2322: Object literal may only specify known properties, and 'z' does not exist in type '{ x: number; y: number; }'. a = { x: 1, z: 3 }; // error - ~ + ~~~~ !!! error TS2322: Type '{ x: number; z: number; }' is not assignable to type '{ x: number; y: number; }'. !!! error TS2322: Object literal may only specify known properties, and 'z' does not exist in type '{ x: number; y: number; }'. } @@ -75,7 +75,7 @@ tests/cases/compiler/typeMatch2.ts(35,5): error TS2322: Type '{ x: number; }' is a = { x: 1, y: undefined }; a = { x: 1, y: _any }; a = { x: 1, y: _any, z:1 }; - ~ + ~~~ !!! error TS2322: Type '{ x: number; y: any; z: number; }' is not assignable to type '{ x: number; y: number; }'. !!! error TS2322: Object literal may only specify known properties, and 'z' does not exist in type '{ x: number; y: number; }'. a = { x: 1 }; // error From 42e08686be31b0ff13f6990ca2ba9cc1b29b03c0 Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Mon, 31 Aug 2015 01:09:48 -0700 Subject: [PATCH 053/117] Style. --- src/compiler/checker.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 2dd3c47ac15..d79cf0a8767 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -4777,8 +4777,11 @@ namespace ts { for (let prop of getPropertiesOfObjectType(source)) { if (!isKnownProperty(target, prop.name)) { if (reportErrors) { - reportErrorAndTryImproveErrorNode(prop.valueDeclaration, - Diagnostics.Object_literal_may_only_specify_known_properties_and_0_does_not_exist_in_type_1, symbolToString(prop), typeToString(target)); + reportErrorAndTryImproveErrorNode( + prop.valueDeclaration, + Diagnostics.Object_literal_may_only_specify_known_properties_and_0_does_not_exist_in_type_1, + symbolToString(prop), + typeToString(target)); } return true; } From 712d5c483fb236c2f11728db5f9a3a370f351867 Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Mon, 31 Aug 2015 14:53:02 -0700 Subject: [PATCH 054/117] Added comment, inlined function. --- src/compiler/checker.ts | 24 ++++++++---------------- 1 file changed, 8 insertions(+), 16 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index d79cf0a8767..739f5341a3c 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -4548,7 +4548,7 @@ namespace ts { * @param target The right-hand-side of the relation. * @param relation The relation considered. One of 'identityRelation', 'assignableRelation', or 'subTypeRelation'. * Used as both to determine which checks are performed and as a cache of previously computed results. - * @param errorNode The node upon which all errors will be reported, if defined. + * @param errorNode The suggested node upon which all errors will be reported, if defined. This may or may not be the actual node used. * @param headMessage If the error chain should be prepended by a head message, then headMessage will be used. * @param containingMessageChain A chain of errors to prepend any new errors found. */ @@ -4593,16 +4593,6 @@ namespace ts { } return result !== Ternary.False; - function reportErrorAndTryImproveErrorNode( - newErrorNode: Node, - message: DiagnosticMessage, - arg0?: string, - arg1?: string, - arg2?: string) { - errorNode = newErrorNode || errorNode; - reportError(message, arg0, arg1, arg2); - } - function reportError(message: DiagnosticMessage, arg0?: string, arg1?: string, arg2?: string): void { errorInfo = chainDiagnosticMessages(errorInfo, message, arg0, arg1, arg2); } @@ -4777,11 +4767,13 @@ namespace ts { for (let prop of getPropertiesOfObjectType(source)) { if (!isKnownProperty(target, prop.name)) { if (reportErrors) { - reportErrorAndTryImproveErrorNode( - prop.valueDeclaration, - Diagnostics.Object_literal_may_only_specify_known_properties_and_0_does_not_exist_in_type_1, - symbolToString(prop), - typeToString(target)); + // We know *exactly* where things went wrong when comparing the types. + // Use this property as the error node as this will be more helpful in + // reasoning about what went wrong. + errorNode = prop.valueDeclaration + reportError(Diagnostics.Object_literal_may_only_specify_known_properties_and_0_does_not_exist_in_type_1, + symbolToString(prop), + typeToString(target)); } return true; } From 1854adb56b47d39a84073972beb61a05e3223397 Mon Sep 17 00:00:00 2001 From: Yui T Date: Mon, 31 Aug 2015 20:33:02 -0700 Subject: [PATCH 055/117] address PR --- src/compiler/emitter.ts | 30 ++++++++++++++++++++++-------- 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index 99c69c91e43..6e4bdff069b 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -7047,9 +7047,11 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi } function emitLeadingCommentsWorker(node: Node, isEmittedNode: boolean) { - if (compilerOptions.removeComments) return; + if (compilerOptions.removeComments) { + return; + } + let leadingComments: CommentRange[]; - if (isEmittedNode) { leadingComments = getLeadingCommentsToEmit(node); } @@ -7062,7 +7064,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi // /// // interface F {} // The first /// will NOT be removed while the second one will be removed eventhough both node will not be emitted - leadingComments = node.pos === 0 ? filter(getLeadingCommentsToEmit(node), isTripleSlashComments) : []; + if (node.pos === 0) { + leadingComments = filter(getLeadingCommentsToEmit(node), isTripleSlashComments); + } } emitNewLineBeforeLeadingComments(currentSourceFile, writer, node, leadingComments); @@ -7072,7 +7076,10 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi } function emitTrailingComments(node: Node) { - if (compilerOptions.removeComments) return; + if (compilerOptions.removeComments) { + return; + } + // Emit the trailing comments only if the parent's end doesn't match let trailingComments = getTrailingCommentsToEmit(node); @@ -7086,7 +7093,10 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi * ^ => pos; the function will emit "comment1" in the emitJS */ function emitTrailingCommentsOfPosition(pos: number) { - if (compilerOptions.removeComments) return; + if (compilerOptions.removeComments) { + return; + } + let trailingComments = getTrailingCommentRanges(currentSourceFile.text, pos); // trailing comments are emitted at space/*trailing comment1 */space/*trailing comment*/ @@ -7094,7 +7104,10 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi } function emitLeadingCommentsOfPosition(pos: number) { - if (compilerOptions.removeComments) return; + if (compilerOptions.removeComments) { + return; + } + let leadingComments: CommentRange[]; if (hasDetachedComments(pos)) { // get comments without detached comments @@ -7119,8 +7132,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi // /*! Pinned Comment */ // // var x = 10; - leadingComments = node.pos === 0 ? - filter(getLeadingCommentRanges(currentSourceFile.text, node.pos), isPinnedComments) : []; + if (node.pos === 0) { + leadingComments = filter(getLeadingCommentRanges(currentSourceFile.text, node.pos), isPinnedComments); + } } else { // removeComments is false, just get detached as normal and bypass the process to filter comment From e78478b76738326fa1b6927826496c165e927e25 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Tue, 1 Sep 2015 12:34:29 -0700 Subject: [PATCH 056/117] More flexible rules when destructuring have literal initializers --- src/compiler/checker.ts | 53 +++++++++++++++++++++++++++++++++-------- src/compiler/types.ts | 4 ++-- 2 files changed, 45 insertions(+), 12 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index e624eb41d86..7c4a438664f 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -2318,8 +2318,8 @@ namespace ts { // Use type of the specified property, or otherwise, for a numeric name, the type of the numeric index signature, // or otherwise the type of the string index signature. type = getTypeOfPropertyOfType(parentType, name.text) || - isNumericLiteralName(name.text) && getIndexTypeOfType(parentType, IndexKind.Number) || - getIndexTypeOfType(parentType, IndexKind.String); + isNumericLiteralName(name.text) && getIndexTypeOfType(parentType, IndexKind.Number) || + getIndexTypeOfType(parentType, IndexKind.String); if (!type) { error(name, Diagnostics.Type_0_has_no_property_1_and_no_string_index_signature, typeToString(parentType), declarationNameToString(name)); return unknownType; @@ -2456,7 +2456,6 @@ namespace ts { let unionOfElements = getUnionType(elementTypes); return languageVersion >= ScriptTarget.ES6 ? createIterableType(unionOfElements) : createArrayType(unionOfElements); } - // If the pattern has at least one element, and no rest element, then it should imply a tuple type. return createTupleType(elementTypes); } @@ -6607,12 +6606,18 @@ namespace ts { } } if (isBindingPattern(declaration.name)) { - return getTypeFromBindingPattern(declaration.name); + return createImpliedType(getTypeFromBindingPattern(declaration.name)); } } return undefined; } + function createImpliedType(type: Type): Type { + var result = clone(type); + result.flags |= TypeFlags.ImpliedType; + return result; + } + function getContextualTypeForReturnExpression(node: Expression): Type { let func = getContainingFunction(node); if (func && !func.asteriskToken) { @@ -7005,9 +7010,6 @@ namespace ts { function checkArrayLiteral(node: ArrayLiteralExpression, contextualMapper?: TypeMapper): Type { let elements = node.elements; - if (!elements.length) { - return createArrayType(undefinedType); - } let hasSpreadElement = false; let elementTypes: Type[] = []; let inDestructuringPattern = isAssignmentTarget(node); @@ -7039,12 +7041,24 @@ namespace ts { hasSpreadElement = hasSpreadElement || e.kind === SyntaxKind.SpreadElementExpression; } if (!hasSpreadElement) { + if (inDestructuringPattern && elementTypes.length) { + return createImpliedType(createTupleType(elementTypes)); + } let contextualType = getContextualType(node); - if (contextualType && contextualTypeIsTupleLikeType(contextualType) || inDestructuringPattern) { - return createTupleType(elementTypes); + let contextualTupleLikeType = contextualType && contextualTypeIsTupleLikeType(contextualType) ? contextualType : undefined; + if (contextualTupleLikeType) { + if (contextualTupleLikeType.flags & TypeFlags.Tuple && contextualTupleLikeType.flags & TypeFlags.ImpliedType) { + let contextualElementTypes = (contextualTupleLikeType).elementTypes; + for (let i = elementTypes.length; i < contextualElementTypes.length; i++) { + elementTypes.push(contextualElementTypes[i]); + } + } + if (elementTypes.length) { + return createTupleType(elementTypes); + } } } - return createArrayType(getUnionType(elementTypes)); + return createArrayType(elementTypes.length ? getUnionType(elementTypes) : undefinedType) } function isNumericName(name: DeclarationName): boolean { @@ -7131,6 +7145,14 @@ namespace ts { } typeFlags |= type.flags; let prop = createSymbol(SymbolFlags.Property | SymbolFlags.Transient | member.flags, member.name); + // If object literal is contextually typed by the implied type of a binding pattern, and if the + // binding pattern specifies a default value for the property, make the property optional. + if (contextualType && contextualType.flags & TypeFlags.ImpliedType) { + let impliedProp = getPropertyOfType(contextualType, member.name); + if (impliedProp) { + prop.flags |= impliedProp.flags & SymbolFlags.Optional; + } + } prop.declarations = member.declarations; prop.parent = member.parent; if (member.valueDeclaration) { @@ -7157,6 +7179,17 @@ namespace ts { propertiesArray.push(member); } + // If object literal is contextually typed by the implied type of a binding pattern, augment the result + // type with those properties for which the binding pattern specifies a default value. + if (contextualType && contextualType.flags & TypeFlags.ImpliedType) { + for (let prop of getPropertiesOfType(contextualType)) { + if (prop.flags & SymbolFlags.Optional && !hasProperty(propertiesTable, prop.name)) { + propertiesTable[prop.name] = prop; + propertiesArray.push(prop); + } + } + } + let stringIndexType = getIndexType(IndexKind.String); let numberIndexType = getIndexType(IndexKind.Number); let result = createAnonymousType(node.symbol, propertiesTable, emptyArray, emptyArray, stringIndexType, numberIndexType); diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 47182e39527..1313fb5b031 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -1795,6 +1795,7 @@ namespace ts { /* @internal */ ContainsAnyFunctionType = 0x00800000, // Type is or contains object literal type ESSymbol = 0x01000000, // Type of symbol primitive introduced in ES6 + ImpliedType = 0x02000000, // Type implied by object binding pattern /* @internal */ Intrinsic = Any | String | Number | Boolean | ESSymbol | Void | Undefined | Null, @@ -1864,8 +1865,7 @@ namespace ts { } export interface TupleType extends ObjectType { - elementTypes: Type[]; // Element types - baseArrayType: TypeReference; // Array where T is best common type of element types + elementTypes: Type[]; // Element types } export interface UnionOrIntersectionType extends Type { From 538d5b9480af4a65710a87e58ba6527875ab4d3d Mon Sep 17 00:00:00 2001 From: Vladimir Matveev Date: Tue, 1 Sep 2015 12:41:48 -0700 Subject: [PATCH 057/117] fix 'findPrecedingToken' for jsxText --- src/services/utilities.ts | 39 ++++++++++++++-------- tests/cases/fourslash/indentationInJsx1.ts | 17 ++++++++++ tests/cases/fourslash/indentationInJsx2.ts | 7 ++++ 3 files changed, 49 insertions(+), 14 deletions(-) create mode 100644 tests/cases/fourslash/indentationInJsx1.ts create mode 100644 tests/cases/fourslash/indentationInJsx2.ts diff --git a/src/services/utilities.ts b/src/services/utilities.ts index d5ad93260cd..8b77dcb953b 100644 --- a/src/services/utilities.ts +++ b/src/services/utilities.ts @@ -360,7 +360,7 @@ namespace ts { return find(startNode || sourceFile); function findRightmostToken(n: Node): Node { - if (isToken(n)) { + if (isToken(n) || n.kind === SyntaxKind.JsxText) { return n; } @@ -371,24 +371,35 @@ namespace ts { } function find(n: Node): Node { - if (isToken(n)) { + if (isToken(n) || n.kind === SyntaxKind.JsxText) { return n; } - let children = n.getChildren(); + const children = n.getChildren(); for (let i = 0, len = children.length; i < len; i++) { let child = children[i]; - if (nodeHasTokens(child)) { - if (position <= child.end) { - if (child.getStart(sourceFile) >= position) { - // actual start of the node is past the position - previous token should be at the end of previous child - let candidate = findRightmostChildNodeWithTokens(children, /*exclusiveStartPosition*/ i); - return candidate && findRightmostToken(candidate) - } - else { - // candidate should be in this node - return find(child); - } + // condition 'position < child.end' checks if child node end after the position + // in the example below this condition will be false for 'aaaa' and 'bbbb' and true for 'ccc' + // aaaa___bbbb___$__ccc + // after we found child node with end after the position we check if start of the node is after the position. + // if yes - then position is in the trivia and we need to look into the previous child to find the token in question. + // if no - position is in the node itself so we should recurse in it. + // NOTE: JsxText is a weird kind of node that can contain only whitespaces (since they are not counted as trivia). + // if this is the case - then we should assume that token in question is located in previous child. + if (position < child.end && (nodeHasTokens(child) || child.kind === SyntaxKind.JsxText)) { + const start = child.getStart(sourceFile); + const lookInPreviousChild = + (start >= position) || // cursor in the leading trivia + (child.kind === SyntaxKind.JsxText && start === child.end); // whitespace only JsxText + + if (lookInPreviousChild) { + // actual start of the node is past the position - previous token should be at the end of previous child + let candidate = findRightmostChildNodeWithTokens(children, /*exclusiveStartPosition*/ i); + return candidate && findRightmostToken(candidate) + } + else { + // candidate should be in this node + return find(child); } } } diff --git a/tests/cases/fourslash/indentationInJsx1.ts b/tests/cases/fourslash/indentationInJsx1.ts new file mode 100644 index 00000000000..5343c7a7c10 --- /dev/null +++ b/tests/cases/fourslash/indentationInJsx1.ts @@ -0,0 +1,17 @@ +/// + +//@Filename: file.tsx +////(function () { +//// return ( +////
+////
+////
+//// /*indent2*/ +////
+//// ) +////}) + + +format.document(); +goTo.marker("indent2"); +verify.indentationIs(12); \ No newline at end of file diff --git a/tests/cases/fourslash/indentationInJsx2.ts b/tests/cases/fourslash/indentationInJsx2.ts new file mode 100644 index 00000000000..f23a14f68cc --- /dev/null +++ b/tests/cases/fourslash/indentationInJsx2.ts @@ -0,0 +1,7 @@ +/// + +//@Filename: file.tsx +////
/*1*/ +goTo.marker("1"); +edit.insert("\n"); +verify.indentationIs(0); From c436736e1e127d99f4c9213229e9d7265789ba4d Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Tue, 1 Sep 2015 13:15:43 -0700 Subject: [PATCH 058/117] Adding a few comments --- src/compiler/checker.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 7c4a438664f..d4e68381f7b 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -7041,12 +7041,16 @@ namespace ts { hasSpreadElement = hasSpreadElement || e.kind === SyntaxKind.SpreadElementExpression; } if (!hasSpreadElement) { + // If array literal is actually a destructuring pattern, mark it as an implied type. We do this such + // that we get the same behavior for "var [x, y] = []" and "[x, y] = []". if (inDestructuringPattern && elementTypes.length) { return createImpliedType(createTupleType(elementTypes)); } let contextualType = getContextualType(node); let contextualTupleLikeType = contextualType && contextualTypeIsTupleLikeType(contextualType) ? contextualType : undefined; if (contextualTupleLikeType) { + // If array literal is contextually typed by the implied type of a binding pattern, pad the resulting + // tuple type with elements from the binding tuple type to make the lengths equal. if (contextualTupleLikeType.flags & TypeFlags.Tuple && contextualTupleLikeType.flags & TypeFlags.ImpliedType) { let contextualElementTypes = (contextualTupleLikeType).elementTypes; for (let i = elementTypes.length; i < contextualElementTypes.length; i++) { From f28e424d31cb06b141a81580122cb43495066e54 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Tue, 1 Sep 2015 13:16:54 -0700 Subject: [PATCH 059/117] Adding tests --- .../destructuringWithLiteralInitializers.js | 117 +++++++++ ...structuringWithLiteralInitializers.symbols | 150 +++++++++++ ...destructuringWithLiteralInitializers.types | 235 ++++++++++++++++++ .../destructuringWithLiteralInitializers.ts | 51 ++++ 4 files changed, 553 insertions(+) create mode 100644 tests/baselines/reference/destructuringWithLiteralInitializers.js create mode 100644 tests/baselines/reference/destructuringWithLiteralInitializers.symbols create mode 100644 tests/baselines/reference/destructuringWithLiteralInitializers.types create mode 100644 tests/cases/conformance/es6/destructuring/destructuringWithLiteralInitializers.ts diff --git a/tests/baselines/reference/destructuringWithLiteralInitializers.js b/tests/baselines/reference/destructuringWithLiteralInitializers.js new file mode 100644 index 00000000000..c25216a55f8 --- /dev/null +++ b/tests/baselines/reference/destructuringWithLiteralInitializers.js @@ -0,0 +1,117 @@ +//// [destructuringWithLiteralInitializers.ts] +// (arg: { x: any, y: any }) => void +function f1({ x, y }) { } +f1({ x: 1, y: 1 }); + +function f2({ x, y = 0 }) { } +f2({ x: 1 }); +f2({ x: 1, y: 1 }); + +// (arg: { x?: number, y?: number }) => void +function f3({ x = 0, y = 0 }) { } +f3({}); +f3({ x: 1 }); +f3({ y: 1 }); +f3({ x: 1, y: 1 }); + +// (arg?: { x: number, y: number }) => void +function f4({ x, y } = { x: 0, y: 0 }) { } +f4(); +f4({ x: 1, y: 1 }); + +// (arg?: { x: number, y?: number }) => void +function f5({ x, y = 0 } = { x: 0 }) { } +f5(); +f5({ x: 1 }); +f5({ x: 1, y: 1 }); + +// (arg?: { x?: number, y?: number }) => void +function f6({ x = 0, y = 0 } = {}) { } +f6(); +f6({}); +f6({ x: 1 }); +f6({ y: 1 }); +f6({ x: 1, y: 1 }); + +// (arg: [any, any]) => void +function g1([x, y]) { } +g1([1, 1]); + +// (arg: [number, number]) => void +function g2([x = 0, y = 0]) { } +g2([1, 1]); + +// (arg?: [any, any]) => void +function g3([x, y] = []) { } +g3(); +g3([1, 1]); + +// (arg?: [number, number]) => void +function g4([x, y] = [0, 0]) { } +g4(); +g4([1, 1]); + + +//// [destructuringWithLiteralInitializers.js] +// (arg: { x: any, y: any }) => void +function f1(_a) { + var x = _a.x, y = _a.y; +} +f1({ x: 1, y: 1 }); +function f2(_a) { + var x = _a.x, _b = _a.y, y = _b === void 0 ? 0 : _b; +} +f2({ x: 1 }); +f2({ x: 1, y: 1 }); +// (arg: { x?: number, y?: number }) => void +function f3(_a) { + var _b = _a.x, x = _b === void 0 ? 0 : _b, _c = _a.y, y = _c === void 0 ? 0 : _c; +} +f3({}); +f3({ x: 1 }); +f3({ y: 1 }); +f3({ x: 1, y: 1 }); +// (arg?: { x: number, y: number }) => void +function f4(_a) { + var _b = _a === void 0 ? { x: 0, y: 0 } : _a, x = _b.x, y = _b.y; +} +f4(); +f4({ x: 1, y: 1 }); +// (arg?: { x: number, y?: number }) => void +function f5(_a) { + var _b = _a === void 0 ? { x: 0 } : _a, x = _b.x, _c = _b.y, y = _c === void 0 ? 0 : _c; +} +f5(); +f5({ x: 1 }); +f5({ x: 1, y: 1 }); +// (arg?: { x?: number, y?: number }) => void +function f6(_a) { + var _b = _a === void 0 ? {} : _a, _c = _b.x, x = _c === void 0 ? 0 : _c, _d = _b.y, y = _d === void 0 ? 0 : _d; +} +f6(); +f6({}); +f6({ x: 1 }); +f6({ y: 1 }); +f6({ x: 1, y: 1 }); +// (arg: [any, any]) => void +function g1(_a) { + var x = _a[0], y = _a[1]; +} +g1([1, 1]); +// (arg: [number, number]) => void +function g2(_a) { + var _b = _a[0], x = _b === void 0 ? 0 : _b, _c = _a[1], y = _c === void 0 ? 0 : _c; +} +g2([1, 1]); +// (arg?: [any, any]) => void +function g3(_a) { + var _b = _a === void 0 ? [] : _a, x = _b[0], y = _b[1]; +} +g3(); +g3([1, 1]); +// (arg?: [number, number]) => void +function g4(_a) { + var _b = _a === void 0 ? [0, 0] : _a, x = _b[0], y = _b[1]; +} +g4(); +g4([1, 1]); diff --git a/tests/baselines/reference/destructuringWithLiteralInitializers.symbols b/tests/baselines/reference/destructuringWithLiteralInitializers.symbols new file mode 100644 index 00000000000..992a9c3ace5 --- /dev/null +++ b/tests/baselines/reference/destructuringWithLiteralInitializers.symbols @@ -0,0 +1,150 @@ +=== tests/cases/conformance/es6/destructuring/destructuringWithLiteralInitializers.ts === +// (arg: { x: any, y: any }) => void +function f1({ x, y }) { } +>f1 : Symbol(f1, Decl(destructuringWithLiteralInitializers.ts, 0, 0)) +>x : Symbol(x, Decl(destructuringWithLiteralInitializers.ts, 1, 13)) +>y : Symbol(y, Decl(destructuringWithLiteralInitializers.ts, 1, 16)) + +f1({ x: 1, y: 1 }); +>f1 : Symbol(f1, Decl(destructuringWithLiteralInitializers.ts, 0, 0)) +>x : Symbol(x, Decl(destructuringWithLiteralInitializers.ts, 2, 4)) +>y : Symbol(y, Decl(destructuringWithLiteralInitializers.ts, 2, 10)) + +function f2({ x, y = 0 }) { } +>f2 : Symbol(f2, Decl(destructuringWithLiteralInitializers.ts, 2, 19)) +>x : Symbol(x, Decl(destructuringWithLiteralInitializers.ts, 4, 13)) +>y : Symbol(y, Decl(destructuringWithLiteralInitializers.ts, 4, 16)) + +f2({ x: 1 }); +>f2 : Symbol(f2, Decl(destructuringWithLiteralInitializers.ts, 2, 19)) +>x : Symbol(x, Decl(destructuringWithLiteralInitializers.ts, 5, 4)) + +f2({ x: 1, y: 1 }); +>f2 : Symbol(f2, Decl(destructuringWithLiteralInitializers.ts, 2, 19)) +>x : Symbol(x, Decl(destructuringWithLiteralInitializers.ts, 6, 4)) +>y : Symbol(y, Decl(destructuringWithLiteralInitializers.ts, 6, 10)) + +// (arg: { x?: number, y?: number }) => void +function f3({ x = 0, y = 0 }) { } +>f3 : Symbol(f3, Decl(destructuringWithLiteralInitializers.ts, 6, 19)) +>x : Symbol(x, Decl(destructuringWithLiteralInitializers.ts, 9, 13)) +>y : Symbol(y, Decl(destructuringWithLiteralInitializers.ts, 9, 20)) + +f3({}); +>f3 : Symbol(f3, Decl(destructuringWithLiteralInitializers.ts, 6, 19)) + +f3({ x: 1 }); +>f3 : Symbol(f3, Decl(destructuringWithLiteralInitializers.ts, 6, 19)) +>x : Symbol(x, Decl(destructuringWithLiteralInitializers.ts, 11, 4)) + +f3({ y: 1 }); +>f3 : Symbol(f3, Decl(destructuringWithLiteralInitializers.ts, 6, 19)) +>y : Symbol(y, Decl(destructuringWithLiteralInitializers.ts, 12, 4)) + +f3({ x: 1, y: 1 }); +>f3 : Symbol(f3, Decl(destructuringWithLiteralInitializers.ts, 6, 19)) +>x : Symbol(x, Decl(destructuringWithLiteralInitializers.ts, 13, 4)) +>y : Symbol(y, Decl(destructuringWithLiteralInitializers.ts, 13, 10)) + +// (arg?: { x: number, y: number }) => void +function f4({ x, y } = { x: 0, y: 0 }) { } +>f4 : Symbol(f4, Decl(destructuringWithLiteralInitializers.ts, 13, 19)) +>x : Symbol(x, Decl(destructuringWithLiteralInitializers.ts, 16, 13)) +>y : Symbol(y, Decl(destructuringWithLiteralInitializers.ts, 16, 16)) +>x : Symbol(x, Decl(destructuringWithLiteralInitializers.ts, 16, 24)) +>y : Symbol(y, Decl(destructuringWithLiteralInitializers.ts, 16, 30)) + +f4(); +>f4 : Symbol(f4, Decl(destructuringWithLiteralInitializers.ts, 13, 19)) + +f4({ x: 1, y: 1 }); +>f4 : Symbol(f4, Decl(destructuringWithLiteralInitializers.ts, 13, 19)) +>x : Symbol(x, Decl(destructuringWithLiteralInitializers.ts, 18, 4)) +>y : Symbol(y, Decl(destructuringWithLiteralInitializers.ts, 18, 10)) + +// (arg?: { x: number, y?: number }) => void +function f5({ x, y = 0 } = { x: 0 }) { } +>f5 : Symbol(f5, Decl(destructuringWithLiteralInitializers.ts, 18, 19)) +>x : Symbol(x, Decl(destructuringWithLiteralInitializers.ts, 21, 13)) +>y : Symbol(y, Decl(destructuringWithLiteralInitializers.ts, 21, 16)) +>x : Symbol(x, Decl(destructuringWithLiteralInitializers.ts, 21, 28)) + +f5(); +>f5 : Symbol(f5, Decl(destructuringWithLiteralInitializers.ts, 18, 19)) + +f5({ x: 1 }); +>f5 : Symbol(f5, Decl(destructuringWithLiteralInitializers.ts, 18, 19)) +>x : Symbol(x, Decl(destructuringWithLiteralInitializers.ts, 23, 4)) + +f5({ x: 1, y: 1 }); +>f5 : Symbol(f5, Decl(destructuringWithLiteralInitializers.ts, 18, 19)) +>x : Symbol(x, Decl(destructuringWithLiteralInitializers.ts, 24, 4)) +>y : Symbol(y, Decl(destructuringWithLiteralInitializers.ts, 24, 10)) + +// (arg?: { x?: number, y?: number }) => void +function f6({ x = 0, y = 0 } = {}) { } +>f6 : Symbol(f6, Decl(destructuringWithLiteralInitializers.ts, 24, 19)) +>x : Symbol(x, Decl(destructuringWithLiteralInitializers.ts, 27, 13)) +>y : Symbol(y, Decl(destructuringWithLiteralInitializers.ts, 27, 20)) + +f6(); +>f6 : Symbol(f6, Decl(destructuringWithLiteralInitializers.ts, 24, 19)) + +f6({}); +>f6 : Symbol(f6, Decl(destructuringWithLiteralInitializers.ts, 24, 19)) + +f6({ x: 1 }); +>f6 : Symbol(f6, Decl(destructuringWithLiteralInitializers.ts, 24, 19)) +>x : Symbol(x, Decl(destructuringWithLiteralInitializers.ts, 30, 4)) + +f6({ y: 1 }); +>f6 : Symbol(f6, Decl(destructuringWithLiteralInitializers.ts, 24, 19)) +>y : Symbol(y, Decl(destructuringWithLiteralInitializers.ts, 31, 4)) + +f6({ x: 1, y: 1 }); +>f6 : Symbol(f6, Decl(destructuringWithLiteralInitializers.ts, 24, 19)) +>x : Symbol(x, Decl(destructuringWithLiteralInitializers.ts, 32, 4)) +>y : Symbol(y, Decl(destructuringWithLiteralInitializers.ts, 32, 10)) + +// (arg: [any, any]) => void +function g1([x, y]) { } +>g1 : Symbol(g1, Decl(destructuringWithLiteralInitializers.ts, 32, 19)) +>x : Symbol(x, Decl(destructuringWithLiteralInitializers.ts, 35, 13)) +>y : Symbol(y, Decl(destructuringWithLiteralInitializers.ts, 35, 15)) + +g1([1, 1]); +>g1 : Symbol(g1, Decl(destructuringWithLiteralInitializers.ts, 32, 19)) + +// (arg: [number, number]) => void +function g2([x = 0, y = 0]) { } +>g2 : Symbol(g2, Decl(destructuringWithLiteralInitializers.ts, 36, 11)) +>x : Symbol(x, Decl(destructuringWithLiteralInitializers.ts, 39, 13)) +>y : Symbol(y, Decl(destructuringWithLiteralInitializers.ts, 39, 19)) + +g2([1, 1]); +>g2 : Symbol(g2, Decl(destructuringWithLiteralInitializers.ts, 36, 11)) + +// (arg?: [any, any]) => void +function g3([x, y] = []) { } +>g3 : Symbol(g3, Decl(destructuringWithLiteralInitializers.ts, 40, 11)) +>x : Symbol(x, Decl(destructuringWithLiteralInitializers.ts, 43, 13)) +>y : Symbol(y, Decl(destructuringWithLiteralInitializers.ts, 43, 15)) + +g3(); +>g3 : Symbol(g3, Decl(destructuringWithLiteralInitializers.ts, 40, 11)) + +g3([1, 1]); +>g3 : Symbol(g3, Decl(destructuringWithLiteralInitializers.ts, 40, 11)) + +// (arg?: [number, number]) => void +function g4([x, y] = [0, 0]) { } +>g4 : Symbol(g4, Decl(destructuringWithLiteralInitializers.ts, 45, 11)) +>x : Symbol(x, Decl(destructuringWithLiteralInitializers.ts, 48, 13)) +>y : Symbol(y, Decl(destructuringWithLiteralInitializers.ts, 48, 15)) + +g4(); +>g4 : Symbol(g4, Decl(destructuringWithLiteralInitializers.ts, 45, 11)) + +g4([1, 1]); +>g4 : Symbol(g4, Decl(destructuringWithLiteralInitializers.ts, 45, 11)) + diff --git a/tests/baselines/reference/destructuringWithLiteralInitializers.types b/tests/baselines/reference/destructuringWithLiteralInitializers.types new file mode 100644 index 00000000000..c0577cb9950 --- /dev/null +++ b/tests/baselines/reference/destructuringWithLiteralInitializers.types @@ -0,0 +1,235 @@ +=== tests/cases/conformance/es6/destructuring/destructuringWithLiteralInitializers.ts === +// (arg: { x: any, y: any }) => void +function f1({ x, y }) { } +>f1 : ({ x, y }: { x: any; y: any; }) => void +>x : any +>y : any + +f1({ x: 1, y: 1 }); +>f1({ x: 1, y: 1 }) : void +>f1 : ({ x, y }: { x: any; y: any; }) => void +>{ x: 1, y: 1 } : { x: number; y: number; } +>x : number +>1 : number +>y : number +>1 : number + +function f2({ x, y = 0 }) { } +>f2 : ({ x, y = 0 }: { x: any; y?: number; }) => void +>x : any +>y : number +>0 : number + +f2({ x: 1 }); +>f2({ x: 1 }) : void +>f2 : ({ x, y = 0 }: { x: any; y?: number; }) => void +>{ x: 1 } : { x: number; } +>x : number +>1 : number + +f2({ x: 1, y: 1 }); +>f2({ x: 1, y: 1 }) : void +>f2 : ({ x, y = 0 }: { x: any; y?: number; }) => void +>{ x: 1, y: 1 } : { x: number; y: number; } +>x : number +>1 : number +>y : number +>1 : number + +// (arg: { x?: number, y?: number }) => void +function f3({ x = 0, y = 0 }) { } +>f3 : ({ x = 0, y = 0 }: { x?: number; y?: number; }) => void +>x : number +>0 : number +>y : number +>0 : number + +f3({}); +>f3({}) : void +>f3 : ({ x = 0, y = 0 }: { x?: number; y?: number; }) => void +>{} : {} + +f3({ x: 1 }); +>f3({ x: 1 }) : void +>f3 : ({ x = 0, y = 0 }: { x?: number; y?: number; }) => void +>{ x: 1 } : { x: number; } +>x : number +>1 : number + +f3({ y: 1 }); +>f3({ y: 1 }) : void +>f3 : ({ x = 0, y = 0 }: { x?: number; y?: number; }) => void +>{ y: 1 } : { y: number; } +>y : number +>1 : number + +f3({ x: 1, y: 1 }); +>f3({ x: 1, y: 1 }) : void +>f3 : ({ x = 0, y = 0 }: { x?: number; y?: number; }) => void +>{ x: 1, y: 1 } : { x: number; y: number; } +>x : number +>1 : number +>y : number +>1 : number + +// (arg?: { x: number, y: number }) => void +function f4({ x, y } = { x: 0, y: 0 }) { } +>f4 : ({ x, y }?: { x: number; y: number; }) => void +>x : number +>y : number +>{ x: 0, y: 0 } : { x: number; y: number; } +>x : number +>0 : number +>y : number +>0 : number + +f4(); +>f4() : void +>f4 : ({ x, y }?: { x: number; y: number; }) => void + +f4({ x: 1, y: 1 }); +>f4({ x: 1, y: 1 }) : void +>f4 : ({ x, y }?: { x: number; y: number; }) => void +>{ x: 1, y: 1 } : { x: number; y: number; } +>x : number +>1 : number +>y : number +>1 : number + +// (arg?: { x: number, y?: number }) => void +function f5({ x, y = 0 } = { x: 0 }) { } +>f5 : ({ x, y = 0 }?: { x: number; y?: number; }) => void +>x : number +>y : number +>0 : number +>{ x: 0 } : { x: number; y?: number; } +>x : number +>0 : number + +f5(); +>f5() : void +>f5 : ({ x, y = 0 }?: { x: number; y?: number; }) => void + +f5({ x: 1 }); +>f5({ x: 1 }) : void +>f5 : ({ x, y = 0 }?: { x: number; y?: number; }) => void +>{ x: 1 } : { x: number; } +>x : number +>1 : number + +f5({ x: 1, y: 1 }); +>f5({ x: 1, y: 1 }) : void +>f5 : ({ x, y = 0 }?: { x: number; y?: number; }) => void +>{ x: 1, y: 1 } : { x: number; y: number; } +>x : number +>1 : number +>y : number +>1 : number + +// (arg?: { x?: number, y?: number }) => void +function f6({ x = 0, y = 0 } = {}) { } +>f6 : ({ x = 0, y = 0 }?: { x?: number; y?: number; }) => void +>x : number +>0 : number +>y : number +>0 : number +>{} : { x?: number; y?: number; } + +f6(); +>f6() : void +>f6 : ({ x = 0, y = 0 }?: { x?: number; y?: number; }) => void + +f6({}); +>f6({}) : void +>f6 : ({ x = 0, y = 0 }?: { x?: number; y?: number; }) => void +>{} : {} + +f6({ x: 1 }); +>f6({ x: 1 }) : void +>f6 : ({ x = 0, y = 0 }?: { x?: number; y?: number; }) => void +>{ x: 1 } : { x: number; } +>x : number +>1 : number + +f6({ y: 1 }); +>f6({ y: 1 }) : void +>f6 : ({ x = 0, y = 0 }?: { x?: number; y?: number; }) => void +>{ y: 1 } : { y: number; } +>y : number +>1 : number + +f6({ x: 1, y: 1 }); +>f6({ x: 1, y: 1 }) : void +>f6 : ({ x = 0, y = 0 }?: { x?: number; y?: number; }) => void +>{ x: 1, y: 1 } : { x: number; y: number; } +>x : number +>1 : number +>y : number +>1 : number + +// (arg: [any, any]) => void +function g1([x, y]) { } +>g1 : ([x, y]: [any, any]) => void +>x : any +>y : any + +g1([1, 1]); +>g1([1, 1]) : void +>g1 : ([x, y]: [any, any]) => void +>[1, 1] : [number, number] +>1 : number +>1 : number + +// (arg: [number, number]) => void +function g2([x = 0, y = 0]) { } +>g2 : ([x = 0, y = 0]: [number, number]) => void +>x : number +>0 : number +>y : number +>0 : number + +g2([1, 1]); +>g2([1, 1]) : void +>g2 : ([x = 0, y = 0]: [number, number]) => void +>[1, 1] : [number, number] +>1 : number +>1 : number + +// (arg?: [any, any]) => void +function g3([x, y] = []) { } +>g3 : ([x, y]?: [any, any]) => void +>x : any +>y : any +>[] : [any, any] + +g3(); +>g3() : void +>g3 : ([x, y]?: [any, any]) => void + +g3([1, 1]); +>g3([1, 1]) : void +>g3 : ([x, y]?: [any, any]) => void +>[1, 1] : [number, number] +>1 : number +>1 : number + +// (arg?: [number, number]) => void +function g4([x, y] = [0, 0]) { } +>g4 : ([x, y]?: [number, number]) => void +>x : number +>y : number +>[0, 0] : [number, number] +>0 : number +>0 : number + +g4(); +>g4() : void +>g4 : ([x, y]?: [number, number]) => void + +g4([1, 1]); +>g4([1, 1]) : void +>g4 : ([x, y]?: [number, number]) => void +>[1, 1] : [number, number] +>1 : number +>1 : number + diff --git a/tests/cases/conformance/es6/destructuring/destructuringWithLiteralInitializers.ts b/tests/cases/conformance/es6/destructuring/destructuringWithLiteralInitializers.ts new file mode 100644 index 00000000000..8f6b77d95c9 --- /dev/null +++ b/tests/cases/conformance/es6/destructuring/destructuringWithLiteralInitializers.ts @@ -0,0 +1,51 @@ +// (arg: { x: any, y: any }) => void +function f1({ x, y }) { } +f1({ x: 1, y: 1 }); + +function f2({ x, y = 0 }) { } +f2({ x: 1 }); +f2({ x: 1, y: 1 }); + +// (arg: { x?: number, y?: number }) => void +function f3({ x = 0, y = 0 }) { } +f3({}); +f3({ x: 1 }); +f3({ y: 1 }); +f3({ x: 1, y: 1 }); + +// (arg?: { x: number, y: number }) => void +function f4({ x, y } = { x: 0, y: 0 }) { } +f4(); +f4({ x: 1, y: 1 }); + +// (arg?: { x: number, y?: number }) => void +function f5({ x, y = 0 } = { x: 0 }) { } +f5(); +f5({ x: 1 }); +f5({ x: 1, y: 1 }); + +// (arg?: { x?: number, y?: number }) => void +function f6({ x = 0, y = 0 } = {}) { } +f6(); +f6({}); +f6({ x: 1 }); +f6({ y: 1 }); +f6({ x: 1, y: 1 }); + +// (arg: [any, any]) => void +function g1([x, y]) { } +g1([1, 1]); + +// (arg: [number, number]) => void +function g2([x = 0, y = 0]) { } +g2([1, 1]); + +// (arg?: [any, any]) => void +function g3([x, y] = []) { } +g3(); +g3([1, 1]); + +// (arg?: [number, number]) => void +function g4([x, y] = [0, 0]) { } +g4(); +g4([1, 1]); From 66e3abaa12c8fab57d99c77807341f553907a7f5 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Tue, 1 Sep 2015 13:17:02 -0700 Subject: [PATCH 060/117] Accepting new baselines --- .../reference/arrowFunctionExpressions.types | 6 +++--- .../reference/declarationEmitDestructuring2.js | 4 ++-- ...declarationEmitDestructuringArrayPattern2.types | 2 +- .../declarationsAndAssignments.errors.txt | 14 ++++---------- ...uringArrayBindingPatternAndAssignment1ES5.types | 2 +- ...uringArrayBindingPatternAndAssignment1ES6.types | 2 +- ...ingArrayBindingPatternAndAssignment2.errors.txt | 8 +------- ...ringObjectBindingPatternAndAssignment1ES5.types | 2 +- ...ringObjectBindingPatternAndAssignment1ES6.types | 2 +- .../destructuringVariableDeclaration1ES5.types | 2 +- .../destructuringVariableDeclaration1ES6.types | 2 +- .../baselines/reference/downlevelLetConst12.types | 4 ++-- .../baselines/reference/emitArrowFunctionES6.types | 6 +++--- .../reference/nonIterableRestElement1.types | 2 +- .../reference/nonIterableRestElement2.types | 2 +- 15 files changed, 24 insertions(+), 36 deletions(-) diff --git a/tests/baselines/reference/arrowFunctionExpressions.types b/tests/baselines/reference/arrowFunctionExpressions.types index fc9fdb8a3bd..6ac405e6d7e 100644 --- a/tests/baselines/reference/arrowFunctionExpressions.types +++ b/tests/baselines/reference/arrowFunctionExpressions.types @@ -100,12 +100,12 @@ var p8 = ({ a = 1 }) => { }; >1 : number var p9 = ({ a: { b = 1 } = { b: 1 } }) => { }; ->p9 : ({ a: { b = 1 } = { b: 1 } }: { a?: { b: number; }; }) => void ->({ a: { b = 1 } = { b: 1 } }) => { } : ({ a: { b = 1 } = { b: 1 } }: { a?: { b: number; }; }) => void +>p9 : ({ a: { b = 1 } = { b: 1 } }: { a?: { b?: number; }; }) => void +>({ a: { b = 1 } = { b: 1 } }) => { } : ({ a: { b = 1 } = { b: 1 } }: { a?: { b?: number; }; }) => void >a : any >b : number >1 : number ->{ b: 1 } : { b: number; } +>{ b: 1 } : { b?: number; } >b : number >1 : number diff --git a/tests/baselines/reference/declarationEmitDestructuring2.js b/tests/baselines/reference/declarationEmitDestructuring2.js index eeabbf1ff37..09980c5c9dd 100644 --- a/tests/baselines/reference/declarationEmitDestructuring2.js +++ b/tests/baselines/reference/declarationEmitDestructuring2.js @@ -21,8 +21,8 @@ function h1(_a) { //// [declarationEmitDestructuring2.d.ts] declare function f({x, y: [a, b, c, d]}?: { - x: number; - y: [number, number, number, number]; + x?: number; + y?: [number, number, number, number]; }): void; declare function g([a, b, c, d]?: [number, number, number, number]): void; declare function h([a, [b], [[c]], {x, y: [a, b, c], z: {a1, b1}}]: [any, [any], [[any]], { diff --git a/tests/baselines/reference/declarationEmitDestructuringArrayPattern2.types b/tests/baselines/reference/declarationEmitDestructuringArrayPattern2.types index eb028aacff4..5820449cde9 100644 --- a/tests/baselines/reference/declarationEmitDestructuringArrayPattern2.types +++ b/tests/baselines/reference/declarationEmitDestructuringArrayPattern2.types @@ -23,7 +23,7 @@ var [a11, b11, c11] = []; >a11 : any >b11 : any >c11 : any ->[] : undefined[] +>[] : [any, any, any] var [a2, [b2, { x12, y12: c2 }]=["abc", { x12: 10, y12: false }]] = [1, ["hello", { x12: 5, y12: true }]]; >a2 : number diff --git a/tests/baselines/reference/declarationsAndAssignments.errors.txt b/tests/baselines/reference/declarationsAndAssignments.errors.txt index 828083e7687..3e0666a96c0 100644 --- a/tests/baselines/reference/declarationsAndAssignments.errors.txt +++ b/tests/baselines/reference/declarationsAndAssignments.errors.txt @@ -1,7 +1,5 @@ -tests/cases/conformance/es6/destructuring/declarationsAndAssignments.ts(5,16): error TS2493: Tuple type '[number, string]' with length '2' cannot be assigned to tuple with length '3'. +tests/cases/conformance/es6/destructuring/declarationsAndAssignments.ts(6,13): error TS2403: Subsequent variable declarations must have the same type. Variable 'z' must be of type 'any', but here has type 'number'. tests/cases/conformance/es6/destructuring/declarationsAndAssignments.ts(56,17): error TS2322: Type 'number' is not assignable to type 'string'. -tests/cases/conformance/es6/destructuring/declarationsAndAssignments.ts(63,13): error TS2493: Tuple type '[number]' with length '1' cannot be assigned to tuple with length '3'. -tests/cases/conformance/es6/destructuring/declarationsAndAssignments.ts(63,16): error TS2493: Tuple type '[number]' with length '1' cannot be assigned to tuple with length '3'. tests/cases/conformance/es6/destructuring/declarationsAndAssignments.ts(67,9): error TS2461: Type '{ [x: number]: undefined; }' is not an array type. tests/cases/conformance/es6/destructuring/declarationsAndAssignments.ts(68,9): error TS2461: Type '{ [x: number]: number; 0: number; 1: number; }' is not an array type. tests/cases/conformance/es6/destructuring/declarationsAndAssignments.ts(73,11): error TS2459: Type '{}' has no property 'a' and no string index signature. @@ -18,15 +16,15 @@ tests/cases/conformance/es6/destructuring/declarationsAndAssignments.ts(138,6): tests/cases/conformance/es6/destructuring/declarationsAndAssignments.ts(138,9): error TS2322: Type 'number' is not assignable to type 'string'. -==== tests/cases/conformance/es6/destructuring/declarationsAndAssignments.ts (13 errors) ==== +==== tests/cases/conformance/es6/destructuring/declarationsAndAssignments.ts (11 errors) ==== function f0() { var [] = [1, "hello"]; var [x] = [1, "hello"]; var [x, y] = [1, "hello"]; var [x, y, z] = [1, "hello"]; // Error - ~ -!!! error TS2493: Tuple type '[number, string]' with length '2' cannot be assigned to tuple with length '3'. var [,, z] = [0, 1, 2]; + ~ +!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'z' must be of type 'any', but here has type 'number'. var x: number; var y: string; } @@ -86,10 +84,6 @@ tests/cases/conformance/es6/destructuring/declarationsAndAssignments.ts(138,9): function f8() { var [a, b, c] = []; // Ok, [] is an array var [d, e, f] = [1]; // Error, [1] is a tuple - ~ -!!! error TS2493: Tuple type '[number]' with length '1' cannot be assigned to tuple with length '3'. - ~ -!!! error TS2493: Tuple type '[number]' with length '1' cannot be assigned to tuple with length '3'. } function f9() { diff --git a/tests/baselines/reference/destructuringArrayBindingPatternAndAssignment1ES5.types b/tests/baselines/reference/destructuringArrayBindingPatternAndAssignment1ES5.types index adff61e407c..9325fbf6b2d 100644 --- a/tests/baselines/reference/destructuringArrayBindingPatternAndAssignment1ES5.types +++ b/tests/baselines/reference/destructuringArrayBindingPatternAndAssignment1ES5.types @@ -93,7 +93,7 @@ var [c0, c1] = [...temp]; var [c2] = []; >c2 : any ->[] : undefined[] +>[] : [any] var [[[c3]], [[[[c4]]]]] = [[[]], [[[[]]]]] >c3 : any diff --git a/tests/baselines/reference/destructuringArrayBindingPatternAndAssignment1ES6.types b/tests/baselines/reference/destructuringArrayBindingPatternAndAssignment1ES6.types index 0a9e75a8aed..aaa56cde3bc 100644 --- a/tests/baselines/reference/destructuringArrayBindingPatternAndAssignment1ES6.types +++ b/tests/baselines/reference/destructuringArrayBindingPatternAndAssignment1ES6.types @@ -94,7 +94,7 @@ var [c0, c1] = [...temp]; var [c2] = []; >c2 : any ->[] : undefined[] +>[] : [any] var [[[c3]], [[[[c4]]]]] = [[[]], [[[[]]]]] >c3 : any diff --git a/tests/baselines/reference/destructuringArrayBindingPatternAndAssignment2.errors.txt b/tests/baselines/reference/destructuringArrayBindingPatternAndAssignment2.errors.txt index a2e5cb7e17c..5244dd55ec6 100644 --- a/tests/baselines/reference/destructuringArrayBindingPatternAndAssignment2.errors.txt +++ b/tests/baselines/reference/destructuringArrayBindingPatternAndAssignment2.errors.txt @@ -1,5 +1,3 @@ -tests/cases/conformance/es6/destructuring/destructuringArrayBindingPatternAndAssignment2.ts(3,6): error TS2461: Type 'undefined' is not an array type. -tests/cases/conformance/es6/destructuring/destructuringArrayBindingPatternAndAssignment2.ts(3,12): error TS2461: Type 'undefined' is not an array type. tests/cases/conformance/es6/destructuring/destructuringArrayBindingPatternAndAssignment2.ts(4,5): error TS2461: Type 'undefined' is not an array type. tests/cases/conformance/es6/destructuring/destructuringArrayBindingPatternAndAssignment2.ts(9,5): error TS2322: Type '[number, number, string]' is not assignable to type '[number, boolean, string]'. Types of property '1' are incompatible. @@ -13,14 +11,10 @@ tests/cases/conformance/es6/destructuring/destructuringArrayBindingPatternAndAss tests/cases/conformance/es6/destructuring/destructuringArrayBindingPatternAndAssignment2.ts(34,5): error TS2461: Type 'F' is not an array type. -==== tests/cases/conformance/es6/destructuring/destructuringArrayBindingPatternAndAssignment2.ts (8 errors) ==== +==== tests/cases/conformance/es6/destructuring/destructuringArrayBindingPatternAndAssignment2.ts (6 errors) ==== // V is an array assignment pattern, S is the type Any or an array-like type (section 3.3.2), and, for each assignment element E in V, // S is the type Any, or var [[a0], [[a1]]] = [] // Error - ~~~~ -!!! error TS2461: Type 'undefined' is not an array type. - ~~~~~~ -!!! error TS2461: Type 'undefined' is not an array type. var [[a2], [[a3]]] = undefined // Error ~~~~~~~~~~~~~~ !!! error TS2461: Type 'undefined' is not an array type. diff --git a/tests/baselines/reference/destructuringObjectBindingPatternAndAssignment1ES5.types b/tests/baselines/reference/destructuringObjectBindingPatternAndAssignment1ES5.types index f44adab359f..476b5bee0cc 100644 --- a/tests/baselines/reference/destructuringObjectBindingPatternAndAssignment1ES5.types +++ b/tests/baselines/reference/destructuringObjectBindingPatternAndAssignment1ES5.types @@ -27,7 +27,7 @@ var { b2: { b21 } = { b21: "string" } } = { b2: { b21: "world" } }; >{ b21: "string" } : { b21: string; } >b21 : string >"string" : string ->{ b2: { b21: "world" } } : { b2: { b21: string; }; } +>{ b2: { b21: "world" } } : { b2?: { b21: string; }; } >b2 : { b21: string; } >{ b21: "world" } : { b21: string; } >b21 : string diff --git a/tests/baselines/reference/destructuringObjectBindingPatternAndAssignment1ES6.types b/tests/baselines/reference/destructuringObjectBindingPatternAndAssignment1ES6.types index 47d4474b63e..7a7f631eddf 100644 --- a/tests/baselines/reference/destructuringObjectBindingPatternAndAssignment1ES6.types +++ b/tests/baselines/reference/destructuringObjectBindingPatternAndAssignment1ES6.types @@ -27,7 +27,7 @@ var { b2: { b21 } = { b21: "string" } } = { b2: { b21: "world" } }; >{ b21: "string" } : { b21: string; } >b21 : string >"string" : string ->{ b2: { b21: "world" } } : { b2: { b21: string; }; } +>{ b2: { b21: "world" } } : { b2?: { b21: string; }; } >b2 : { b21: string; } >{ b21: "world" } : { b21: string; } >b21 : string diff --git a/tests/baselines/reference/destructuringVariableDeclaration1ES5.types b/tests/baselines/reference/destructuringVariableDeclaration1ES5.types index a0630fee995..620ad90d414 100644 --- a/tests/baselines/reference/destructuringVariableDeclaration1ES5.types +++ b/tests/baselines/reference/destructuringVariableDeclaration1ES5.types @@ -31,7 +31,7 @@ var { b1: { b11 } = { b11: "string" } } = { b1: { b11: "world" } }; >{ b11: "string" } : { b11: string; } >b11 : string >"string" : string ->{ b1: { b11: "world" } } : { b1: { b11: string; }; } +>{ b1: { b11: "world" } } : { b1?: { b11: string; }; } >b1 : { b11: string; } >{ b11: "world" } : { b11: string; } >b11 : string diff --git a/tests/baselines/reference/destructuringVariableDeclaration1ES6.types b/tests/baselines/reference/destructuringVariableDeclaration1ES6.types index f9faf519b0a..a3004f87c82 100644 --- a/tests/baselines/reference/destructuringVariableDeclaration1ES6.types +++ b/tests/baselines/reference/destructuringVariableDeclaration1ES6.types @@ -31,7 +31,7 @@ var { b1: { b11 } = { b11: "string" } } = { b1: { b11: "world" } }; >{ b11: "string" } : { b11: string; } >b11 : string >"string" : string ->{ b1: { b11: "world" } } : { b1: { b11: string; }; } +>{ b1: { b11: "world" } } : { b1?: { b11: string; }; } >b1 : { b11: string; } >{ b11: "world" } : { b11: string; } >b11 : string diff --git a/tests/baselines/reference/downlevelLetConst12.types b/tests/baselines/reference/downlevelLetConst12.types index 51d3b8eb086..85002abbe5e 100644 --- a/tests/baselines/reference/downlevelLetConst12.types +++ b/tests/baselines/reference/downlevelLetConst12.types @@ -13,7 +13,7 @@ const bar = 1; let [baz] = []; >baz : any ->[] : undefined[] +>[] : [any] let {a: baz2} = { a: 1 }; >a : any @@ -24,7 +24,7 @@ let {a: baz2} = { a: 1 }; const [baz3] = [] >baz3 : any ->[] : undefined[] +>[] : [any] const {a: baz4} = { a: 1 }; >a : any diff --git a/tests/baselines/reference/emitArrowFunctionES6.types b/tests/baselines/reference/emitArrowFunctionES6.types index e2ad176fd7d..cc48cecd96a 100644 --- a/tests/baselines/reference/emitArrowFunctionES6.types +++ b/tests/baselines/reference/emitArrowFunctionES6.types @@ -87,12 +87,12 @@ var p8 = ({ a = 1 }) => { }; >1 : number var p9 = ({ a: { b = 1 } = { b: 1 } }) => { }; ->p9 : ({ a: { b = 1 } = { b: 1 } }: { a?: { b: number; }; }) => void ->({ a: { b = 1 } = { b: 1 } }) => { } : ({ a: { b = 1 } = { b: 1 } }: { a?: { b: number; }; }) => void +>p9 : ({ a: { b = 1 } = { b: 1 } }: { a?: { b?: number; }; }) => void +>({ a: { b = 1 } = { b: 1 } }) => { } : ({ a: { b = 1 } = { b: 1 } }: { a?: { b?: number; }; }) => void >a : any >b : number >1 : number ->{ b: 1 } : { b: number; } +>{ b: 1 } : { b?: number; } >b : number >1 : number diff --git a/tests/baselines/reference/nonIterableRestElement1.types b/tests/baselines/reference/nonIterableRestElement1.types index 4973b67d4ae..a15fe5afd38 100644 --- a/tests/baselines/reference/nonIterableRestElement1.types +++ b/tests/baselines/reference/nonIterableRestElement1.types @@ -5,7 +5,7 @@ var c = {}; [...c] = ["", 0]; >[...c] = ["", 0] : (string | number)[] ->[...c] : {}[] +>[...c] : undefined[] >...c : any >c : {} >["", 0] : (string | number)[] diff --git a/tests/baselines/reference/nonIterableRestElement2.types b/tests/baselines/reference/nonIterableRestElement2.types index e6d84d5297e..c39a592d2e6 100644 --- a/tests/baselines/reference/nonIterableRestElement2.types +++ b/tests/baselines/reference/nonIterableRestElement2.types @@ -5,7 +5,7 @@ var c = {}; [...c] = ["", 0]; >[...c] = ["", 0] : (string | number)[] ->[...c] : {}[] +>[...c] : undefined[] >...c : any >c : {} >["", 0] : (string | number)[] From 5f78d39662646ad3ba4f8af435b0ffbcf161f8cf Mon Sep 17 00:00:00 2001 From: Sheetal Nandi Date: Tue, 1 Sep 2015 13:46:44 -0700 Subject: [PATCH 061/117] If Type annotation is missing, emit design:Type as Object Fixes #4549 --- src/compiler/emitter.ts | 110 +++++++++--------- .../decoratorMetadataOnInferredType.js | 39 +++++++ .../decoratorMetadataOnInferredType.symbols | 38 ++++++ .../decoratorMetadataOnInferredType.types | 41 +++++++ .../decoratorMetadataOnInferredType.ts | 21 ++++ 5 files changed, 193 insertions(+), 56 deletions(-) create mode 100644 tests/baselines/reference/decoratorMetadataOnInferredType.js create mode 100644 tests/baselines/reference/decoratorMetadataOnInferredType.symbols create mode 100644 tests/baselines/reference/decoratorMetadataOnInferredType.types create mode 100644 tests/cases/compiler/decoratorMetadataOnInferredType.ts diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index eeaab6d2123..d84b7b70ada 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -4939,63 +4939,61 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi } function emitSerializedTypeNode(node: TypeNode) { - if (!node) { - return; + if (node) { + + switch (node.kind) { + case SyntaxKind.VoidKeyword: + write("void 0"); + return; + + case SyntaxKind.ParenthesizedType: + emitSerializedTypeNode((node).type); + return; + + case SyntaxKind.FunctionType: + case SyntaxKind.ConstructorType: + write("Function"); + return; + + case SyntaxKind.ArrayType: + case SyntaxKind.TupleType: + write("Array"); + return; + + case SyntaxKind.TypePredicate: + case SyntaxKind.BooleanKeyword: + write("Boolean"); + return; + + case SyntaxKind.StringKeyword: + case SyntaxKind.StringLiteral: + write("String"); + return; + + case SyntaxKind.NumberKeyword: + write("Number"); + return; + + case SyntaxKind.SymbolKeyword: + write("Symbol"); + return; + + case SyntaxKind.TypeReference: + emitSerializedTypeReferenceNode(node); + return; + + case SyntaxKind.TypeQuery: + case SyntaxKind.TypeLiteral: + case SyntaxKind.UnionType: + case SyntaxKind.IntersectionType: + case SyntaxKind.AnyKeyword: + break; + + default: + Debug.fail("Cannot serialize unexpected type node."); + break; + } } - - switch (node.kind) { - case SyntaxKind.VoidKeyword: - write("void 0"); - return; - - case SyntaxKind.ParenthesizedType: - emitSerializedTypeNode((node).type); - return; - - case SyntaxKind.FunctionType: - case SyntaxKind.ConstructorType: - write("Function"); - return; - - case SyntaxKind.ArrayType: - case SyntaxKind.TupleType: - write("Array"); - return; - - case SyntaxKind.TypePredicate: - case SyntaxKind.BooleanKeyword: - write("Boolean"); - return; - - case SyntaxKind.StringKeyword: - case SyntaxKind.StringLiteral: - write("String"); - return; - - case SyntaxKind.NumberKeyword: - write("Number"); - return; - - case SyntaxKind.SymbolKeyword: - write("Symbol"); - return; - - case SyntaxKind.TypeReference: - emitSerializedTypeReferenceNode(node); - return; - - case SyntaxKind.TypeQuery: - case SyntaxKind.TypeLiteral: - case SyntaxKind.UnionType: - case SyntaxKind.IntersectionType: - case SyntaxKind.AnyKeyword: - break; - - default: - Debug.fail("Cannot serialize unexpected type node."); - break; - } - write("Object"); } diff --git a/tests/baselines/reference/decoratorMetadataOnInferredType.js b/tests/baselines/reference/decoratorMetadataOnInferredType.js new file mode 100644 index 00000000000..8103dbbdafa --- /dev/null +++ b/tests/baselines/reference/decoratorMetadataOnInferredType.js @@ -0,0 +1,39 @@ +//// [decoratorMetadataOnInferredType.ts] + +declare var console: { + log(msg: string): void; +}; + +class A { + constructor() { console.log('new A'); } +} + +function decorator(target: Object, propertyKey: string) { +} + +export class B { + @decorator + x = new A(); +} + + +//// [decoratorMetadataOnInferredType.js] +var A = (function () { + function A() { + console.log('new A'); + } + return A; +})(); +function decorator(target, propertyKey) { +} +var B = (function () { + function B() { + this.x = new A(); + } + __decorate([ + decorator, + __metadata('design:type', Object) + ], B.prototype, "x"); + return B; +})(); +exports.B = B; diff --git a/tests/baselines/reference/decoratorMetadataOnInferredType.symbols b/tests/baselines/reference/decoratorMetadataOnInferredType.symbols new file mode 100644 index 00000000000..e1507c75e94 --- /dev/null +++ b/tests/baselines/reference/decoratorMetadataOnInferredType.symbols @@ -0,0 +1,38 @@ +=== tests/cases/compiler/decoratorMetadataOnInferredType.ts === + +declare var console: { +>console : Symbol(console, Decl(decoratorMetadataOnInferredType.ts, 1, 11)) + + log(msg: string): void; +>log : Symbol(log, Decl(decoratorMetadataOnInferredType.ts, 1, 22)) +>msg : Symbol(msg, Decl(decoratorMetadataOnInferredType.ts, 2, 8)) + +}; + +class A { +>A : Symbol(A, Decl(decoratorMetadataOnInferredType.ts, 3, 2)) + + constructor() { console.log('new A'); } +>console.log : Symbol(log, Decl(decoratorMetadataOnInferredType.ts, 1, 22)) +>console : Symbol(console, Decl(decoratorMetadataOnInferredType.ts, 1, 11)) +>log : Symbol(log, Decl(decoratorMetadataOnInferredType.ts, 1, 22)) +} + +function decorator(target: Object, propertyKey: string) { +>decorator : Symbol(decorator, Decl(decoratorMetadataOnInferredType.ts, 7, 1)) +>target : Symbol(target, Decl(decoratorMetadataOnInferredType.ts, 9, 19)) +>Object : Symbol(Object, Decl(lib.d.ts, 92, 1), Decl(lib.d.ts, 223, 11)) +>propertyKey : Symbol(propertyKey, Decl(decoratorMetadataOnInferredType.ts, 9, 34)) +} + +export class B { +>B : Symbol(B, Decl(decoratorMetadataOnInferredType.ts, 10, 1)) + + @decorator +>decorator : Symbol(decorator, Decl(decoratorMetadataOnInferredType.ts, 7, 1)) + + x = new A(); +>x : Symbol(x, Decl(decoratorMetadataOnInferredType.ts, 12, 16)) +>A : Symbol(A, Decl(decoratorMetadataOnInferredType.ts, 3, 2)) +} + diff --git a/tests/baselines/reference/decoratorMetadataOnInferredType.types b/tests/baselines/reference/decoratorMetadataOnInferredType.types new file mode 100644 index 00000000000..41c9334244f --- /dev/null +++ b/tests/baselines/reference/decoratorMetadataOnInferredType.types @@ -0,0 +1,41 @@ +=== tests/cases/compiler/decoratorMetadataOnInferredType.ts === + +declare var console: { +>console : { log(msg: string): void; } + + log(msg: string): void; +>log : (msg: string) => void +>msg : string + +}; + +class A { +>A : A + + constructor() { console.log('new A'); } +>console.log('new A') : void +>console.log : (msg: string) => void +>console : { log(msg: string): void; } +>log : (msg: string) => void +>'new A' : string +} + +function decorator(target: Object, propertyKey: string) { +>decorator : (target: Object, propertyKey: string) => void +>target : Object +>Object : Object +>propertyKey : string +} + +export class B { +>B : B + + @decorator +>decorator : (target: Object, propertyKey: string) => void + + x = new A(); +>x : A +>new A() : A +>A : typeof A +} + diff --git a/tests/cases/compiler/decoratorMetadataOnInferredType.ts b/tests/cases/compiler/decoratorMetadataOnInferredType.ts new file mode 100644 index 00000000000..170afe3b3e5 --- /dev/null +++ b/tests/cases/compiler/decoratorMetadataOnInferredType.ts @@ -0,0 +1,21 @@ +// @noemithelpers: true +// @experimentaldecorators: true +// @emitdecoratormetadata: true +// @target: es5 +// @module: commonjs + +declare var console: { + log(msg: string): void; +}; + +class A { + constructor() { console.log('new A'); } +} + +function decorator(target: Object, propertyKey: string) { +} + +export class B { + @decorator + x = new A(); +} From cd6152ebe6dd0245ad61d67ff447ce18790594e0 Mon Sep 17 00:00:00 2001 From: Vladimir Matveev Date: Tue, 1 Sep 2015 11:09:41 -0700 Subject: [PATCH 062/117] remove 'experimental' from 'moduleResolution' command line argument --- src/compiler/commandLineParser.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/compiler/commandLineParser.ts b/src/compiler/commandLineParser.ts index 1a0c971001e..c56a18b3ab2 100644 --- a/src/compiler/commandLineParser.ts +++ b/src/compiler/commandLineParser.ts @@ -243,7 +243,6 @@ namespace ts { "node": ModuleResolutionKind.NodeJs, "classic": ModuleResolutionKind.Classic }, - experimental: true, description: Diagnostics.Specifies_module_resolution_strategy_Colon_node_Node_or_classic_TypeScript_pre_1_6 } ]; From 3c568251bb53d88be6fbb858e1b9609a7cdc3535 Mon Sep 17 00:00:00 2001 From: Zhengbo Li Date: Wed, 2 Sep 2015 16:02:42 -0700 Subject: [PATCH 063/117] Merge pull request #4557 from gwicksted/patch-1 Add parameters to toLocaleDateString --- src/lib/intl.d.ts | 32 ++++++++++++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) diff --git a/src/lib/intl.d.ts b/src/lib/intl.d.ts index 57df70672d4..b5291306b87 100644 --- a/src/lib/intl.d.ts +++ b/src/lib/intl.d.ts @@ -88,6 +88,7 @@ declare module Intl { timeZoneName?: string; formatMatcher?: string; hour12?: boolean; + timeZone?: string; } interface ResolvedDateTimeFormatOptions { @@ -157,17 +158,44 @@ interface Number { interface Date { /** - * Converts a date to a string by using the current or specified locale. + * Converts a date and time to a string by using the current or specified locale. * @param locales An array of locale strings that contain one or more language or locale tags. If you include more than one locale string, list them in descending order of priority so that the first entry is the preferred locale. If you omit this parameter, the default locale of the JavaScript runtime is used. * @param options An object that contains one or more properties that specify comparison options. */ toLocaleString(locales?: string[], options?: Intl.DateTimeFormatOptions): string; + /** + * Converts a date to a string by using the current or specified locale. + * @param locales An array of locale strings that contain one or more language or locale tags. If you include more than one locale string, list them in descending order of priority so that the first entry is the preferred locale. If you omit this parameter, the default locale of the JavaScript runtime is used. + * @param options An object that contains one or more properties that specify comparison options. + */ + toLocaleDateString(locales?: string[], options?: Intl.DateTimeFormatOptions): string; + /** + * Converts a time to a string by using the current or specified locale. + * @param locale Locale tag. If you omit this parameter, the default locale of the JavaScript runtime is used. + * @param options An object that contains one or more properties that specify comparison options. + */ + toLocaleTimeString(locale?: string[], options?: Intl.DateTimeFormatOptions): string; + + /** + * Converts a date and time to a string by using the current or specified locale. + * @param locale Locale tag. If you omit this parameter, the default locale of the JavaScript runtime is used. + * @param options An object that contains one or more properties that specify comparison options. + */ + toLocaleString(locale?: string, options?: Intl.DateTimeFormatOptions): string; + /** * Converts a date to a string by using the current or specified locale. * @param locale Locale tag. If you omit this parameter, the default locale of the JavaScript runtime is used. * @param options An object that contains one or more properties that specify comparison options. */ - toLocaleString(locale?: string, options?: Intl.DateTimeFormatOptions): string; + toLocaleDateString(locale?: string, options?: Intl.DateTimeFormatOptions): string; + + /** + * Converts a time to a string by using the current or specified locale. + * @param locale Locale tag. If you omit this parameter, the default locale of the JavaScript runtime is used. + * @param options An object that contains one or more properties that specify comparison options. + */ + toLocaleTimeString(locale?: string, options?: Intl.DateTimeFormatOptions): string; } From 8d1d0d8d700652036603f371944685a5d00a3b08 Mon Sep 17 00:00:00 2001 From: SaschaNaz Date: Thu, 3 Sep 2015 22:07:52 +0900 Subject: [PATCH 064/117] format class expression indentation --- src/services/formatting/rules.ts | 3 ++- src/services/formatting/smartIndenter.ts | 1 + .../cases/fourslash/formatClassExpression.ts | 23 +++++++++++++++++++ 3 files changed, 26 insertions(+), 1 deletion(-) create mode 100644 tests/cases/fourslash/formatClassExpression.ts diff --git a/src/services/formatting/rules.ts b/src/services/formatting/rules.ts index f609edb0501..1898040daad 100644 --- a/src/services/formatting/rules.ts +++ b/src/services/formatting/rules.ts @@ -272,7 +272,7 @@ namespace ts.formatting { this.SpaceBeforeOpenBraceInFunction = new Rule(RuleDescriptor.create2(this.FunctionOpenBraceLeftTokenRange, SyntaxKind.OpenBraceToken), RuleOperation.create2(new RuleOperationContext(Rules.IsFunctionDeclContext, Rules.IsBeforeBlockContext, Rules.IsNotFormatOnEnter, Rules.IsSameLineTokenOrBeforeMultilineBlockContext), RuleAction.Space), RuleFlags.CanDeleteNewLines); // Place a space before open brace in a TypeScript declaration that has braces as children (class, module, enum, etc) - this.TypeScriptOpenBraceLeftTokenRange = Shared.TokenRange.FromTokens([SyntaxKind.Identifier, SyntaxKind.MultiLineCommentTrivia]); + this.TypeScriptOpenBraceLeftTokenRange = Shared.TokenRange.FromTokens([SyntaxKind.Identifier, SyntaxKind.MultiLineCommentTrivia, SyntaxKind.ClassKeyword]); this.SpaceBeforeOpenBraceInTypeScriptDeclWithBlock = new Rule(RuleDescriptor.create2(this.TypeScriptOpenBraceLeftTokenRange, SyntaxKind.OpenBraceToken), RuleOperation.create2(new RuleOperationContext(Rules.IsTypeScriptDeclWithBlockContext, Rules.IsNotFormatOnEnter, Rules.IsSameLineTokenOrBeforeMultilineBlockContext), RuleAction.Space), RuleFlags.CanDeleteNewLines); // Place a space before open brace in a control flow construct @@ -663,6 +663,7 @@ namespace ts.formatting { static NodeIsTypeScriptDeclWithBlockContext(node: Node): boolean { switch (node.kind) { case SyntaxKind.ClassDeclaration: + case SyntaxKind.ClassExpression: case SyntaxKind.InterfaceDeclaration: case SyntaxKind.EnumDeclaration: case SyntaxKind.TypeLiteral: diff --git a/src/services/formatting/smartIndenter.ts b/src/services/formatting/smartIndenter.ts index ebbf09e9feb..b159a6676f5 100644 --- a/src/services/formatting/smartIndenter.ts +++ b/src/services/formatting/smartIndenter.ts @@ -406,6 +406,7 @@ namespace ts.formatting { function nodeContentIsAlwaysIndented(kind: SyntaxKind): boolean { switch (kind) { case SyntaxKind.ClassDeclaration: + case SyntaxKind.ClassExpression: case SyntaxKind.InterfaceDeclaration: case SyntaxKind.EnumDeclaration: case SyntaxKind.TypeAliasDeclaration: diff --git a/tests/cases/fourslash/formatClassExpression.ts b/tests/cases/fourslash/formatClassExpression.ts new file mode 100644 index 00000000000..0a00203e77f --- /dev/null +++ b/tests/cases/fourslash/formatClassExpression.ts @@ -0,0 +1,23 @@ +/// + +////class Thing extends ( +//// class/*classOpenBrace*/ +//// { +/////*classIndent*/ +//// protected doThing() {/*methodAutoformat*/ +/////*methodIndent*/ +//// } +//// } +////) { +////} + +format.document(); + +goTo.marker("classOpenBrace"); +verify.currentLineContentIs(" class {"); +goTo.marker("classIndent"); +verify.indentationIs(8); +goTo.marker("methodAutoformat"); +verify.currentLineContentIs(" protected doThing() {"); +goTo.marker("methodIndent"); +verify.indentationIs(12); \ No newline at end of file From dfde9e4e1024cbc2c088ebdde09c988afabd7c9a Mon Sep 17 00:00:00 2001 From: SaschaNaz Date: Thu, 3 Sep 2015 22:33:07 +0900 Subject: [PATCH 065/117] format intersection type --- src/services/formatting/rules.ts | 10 +++++--- src/services/formatting/smartIndenter.ts | 1 - tests/cases/fourslash/formatTypeOperation.ts | 26 ++++++++++++++++++++ tests/cases/fourslash/formatTypeUnion.ts | 14 ----------- 4 files changed, 33 insertions(+), 18 deletions(-) create mode 100644 tests/cases/fourslash/formatTypeOperation.ts delete mode 100644 tests/cases/fourslash/formatTypeUnion.ts diff --git a/src/services/formatting/rules.ts b/src/services/formatting/rules.ts index f609edb0501..56290800c0d 100644 --- a/src/services/formatting/rules.ts +++ b/src/services/formatting/rules.ts @@ -227,11 +227,13 @@ namespace ts.formatting { public SpaceBetweenTagAndTemplateString: Rule; public NoSpaceBetweenTagAndTemplateString: Rule; - // Union type + // Type operation public SpaceBeforeBar: Rule; public NoSpaceBeforeBar: Rule; public SpaceAfterBar: Rule; public NoSpaceAfterBar: Rule; + public SpaceBeforeAmpersand: Rule; + public SpaceAfterAmpersand: Rule; constructor() { /// @@ -394,12 +396,13 @@ namespace ts.formatting { this.SpaceBetweenTagAndTemplateString = new Rule(RuleDescriptor.create3(SyntaxKind.Identifier, Shared.TokenRange.FromTokens([SyntaxKind.NoSubstitutionTemplateLiteral, SyntaxKind.TemplateHead])), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Space)); this.NoSpaceBetweenTagAndTemplateString = new Rule(RuleDescriptor.create3(SyntaxKind.Identifier, Shared.TokenRange.FromTokens([SyntaxKind.NoSubstitutionTemplateLiteral, SyntaxKind.TemplateHead])), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Delete)); - // union type + // type operation this.SpaceBeforeBar = new Rule(RuleDescriptor.create3(SyntaxKind.BarToken, Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Space)); this.NoSpaceBeforeBar = new Rule(RuleDescriptor.create3(SyntaxKind.BarToken, Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Delete)); this.SpaceAfterBar = new Rule(RuleDescriptor.create2(Shared.TokenRange.Any, SyntaxKind.BarToken), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Space)); this.NoSpaceAfterBar = new Rule(RuleDescriptor.create2(Shared.TokenRange.Any, SyntaxKind.BarToken), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Delete)); - + this.SpaceBeforeAmpersand = new Rule(RuleDescriptor.create3(SyntaxKind.AmpersandToken, Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Space)); + this.SpaceAfterAmpersand = new Rule(RuleDescriptor.create2(Shared.TokenRange.Any, SyntaxKind.AmpersandToken), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Space)); // These rules are higher in priority than user-configurable rules. this.HighPriorityCommonRules = @@ -432,6 +435,7 @@ namespace ts.formatting { this.SpaceAfterTypeKeyword, this.NoSpaceAfterTypeKeyword, this.SpaceBetweenTagAndTemplateString, this.NoSpaceBetweenTagAndTemplateString, this.SpaceBeforeBar, this.NoSpaceBeforeBar, this.SpaceAfterBar, this.NoSpaceAfterBar, + this.SpaceBeforeAmpersand, this.SpaceAfterAmpersand, // TypeScript-specific rules this.NoSpaceAfterConstructor, this.NoSpaceAfterModuleImport, diff --git a/src/services/formatting/smartIndenter.ts b/src/services/formatting/smartIndenter.ts index ebbf09e9feb..9c341dca5ff 100644 --- a/src/services/formatting/smartIndenter.ts +++ b/src/services/formatting/smartIndenter.ts @@ -436,7 +436,6 @@ namespace ts.formatting { case SyntaxKind.Parameter: case SyntaxKind.FunctionType: case SyntaxKind.ConstructorType: - case SyntaxKind.UnionType: case SyntaxKind.ParenthesizedType: case SyntaxKind.TaggedTemplateExpression: case SyntaxKind.AwaitExpression: diff --git a/tests/cases/fourslash/formatTypeOperation.ts b/tests/cases/fourslash/formatTypeOperation.ts new file mode 100644 index 00000000000..8708ef34d5c --- /dev/null +++ b/tests/cases/fourslash/formatTypeOperation.ts @@ -0,0 +1,26 @@ +/// + +////type Union = number | {}/*formatBarOperator*/ +/////*indent*/ +////|string/*autoformat*/ +////type Intersection = Foo & Bar;/*formatAmpersandOperator*/ +////type Complexed = +//// Foo& +//// Bar|/*unionTypeNoIndent*/ +//// Baz;/*intersectionTypeNoIndent*/ + +format.document(); + +goTo.marker("formatBarOperator"); +verify.currentLineContentIs("type Union = number | {}"); +goTo.marker("indent"); +verify.indentationIs(4); +goTo.marker("autoformat"); +verify.currentLineContentIs(" | string"); +goTo.marker("formatAmpersandOperator"); +verify.currentLineContentIs("type Intersection = Foo & Bar;"); + +goTo.marker("unionTypeNoIndent"); +verify.currentLineContentIs("Bar |"); +goTo.marker("intersectionTypeNoIndent"); +verify.currentLineContentIs("Baz;"); \ No newline at end of file diff --git a/tests/cases/fourslash/formatTypeUnion.ts b/tests/cases/fourslash/formatTypeUnion.ts deleted file mode 100644 index 267ba656612..00000000000 --- a/tests/cases/fourslash/formatTypeUnion.ts +++ /dev/null @@ -1,14 +0,0 @@ -/// - -////type Union = number | {}/*formatOperator*/ -/////*indent*/ -////|string/*autoformat*/ - -format.document(); - -goTo.marker("formatOperator"); -verify.currentLineContentIs("type Union = number | {}"); -goTo.marker("indent"); -verify.indentationIs(4); -goTo.marker("autoformat"); -verify.currentLineContentIs(" | string"); \ No newline at end of file From b8e91814bb98a3c1c413762dc07b694d9532c54e Mon Sep 17 00:00:00 2001 From: SaschaNaz Date: Thu, 3 Sep 2015 22:45:41 +0900 Subject: [PATCH 066/117] fix test --- tests/cases/fourslash/formatTypeOperation.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/cases/fourslash/formatTypeOperation.ts b/tests/cases/fourslash/formatTypeOperation.ts index 8708ef34d5c..956508f7290 100644 --- a/tests/cases/fourslash/formatTypeOperation.ts +++ b/tests/cases/fourslash/formatTypeOperation.ts @@ -21,6 +21,6 @@ goTo.marker("formatAmpersandOperator"); verify.currentLineContentIs("type Intersection = Foo & Bar;"); goTo.marker("unionTypeNoIndent"); -verify.currentLineContentIs("Bar |"); +verify.currentLineContentIs(" Bar |"); goTo.marker("intersectionTypeNoIndent"); -verify.currentLineContentIs("Baz;"); \ No newline at end of file +verify.currentLineContentIs(" Baz;"); \ No newline at end of file From 9a78b66068038b356ca37fb954f98f474d60b5ef Mon Sep 17 00:00:00 2001 From: Vladimir Matveev Date: Thu, 3 Sep 2015 09:25:43 -0700 Subject: [PATCH 067/117] allow backslashes in fileName argument of the transpile function --- src/services/services.ts | 2 +- tests/cases/unittests/transpile.ts | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/services/services.ts b/src/services/services.ts index 752fb93cd00..d5ede917b8f 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -1866,7 +1866,7 @@ namespace ts { let sourceMapText: string; // Create a compilerHost object to allow the compiler to read and write files let compilerHost: CompilerHost = { - getSourceFile: (fileName, target) => fileName === inputFileName ? sourceFile : undefined, + getSourceFile: (fileName, target) => fileName === normalizeSlashes(inputFileName) ? sourceFile : undefined, writeFile: (name, text, writeByteOrderMark) => { if (fileExtensionIs(name, ".map")) { Debug.assert(sourceMapText === undefined, `Unexpected multiple source map outputs for the file '${name}'`); diff --git a/tests/cases/unittests/transpile.ts b/tests/cases/unittests/transpile.ts index 0b87910d26e..9336c323bb4 100644 --- a/tests/cases/unittests/transpile.ts +++ b/tests/cases/unittests/transpile.ts @@ -64,8 +64,8 @@ module ts { let transpileModuleResultWithSourceMap = transpileModule(input, transpileOptions); assert.isTrue(transpileModuleResultWithSourceMap.sourceMapText !== undefined); - let expectedSourceMapFileName = removeFileExtension(transpileOptions.fileName) + ".js.map"; - let expectedSourceMappingUrlLine = `//# sourceMappingURL=${expectedSourceMapFileName}`; + let expectedSourceMapFileName = removeFileExtension(getBaseFileName(normalizeSlashes(transpileOptions.fileName))) + ".js.map"; + let expectedSourceMappingUrlLine = `//# sourceMappingURL=${expectedSourceMapFileName}`; if (testSettings.expectedOutput !== undefined) { assert.equal(transpileModuleResultWithSourceMap.outputText, testSettings.expectedOutput + expectedSourceMappingUrlLine); @@ -270,5 +270,9 @@ var x = 0;`, expectedOutput: output }); }); + + it("Supports backslashes in file name", () => { + test("var x", { expectedOutput: "var x;\r\n", options: { fileName: "a\\b.ts" }}); + }); }); } From e484305c9816431aeb94e1233d42627a953f69d7 Mon Sep 17 00:00:00 2001 From: Vladimir Matveev Date: Thu, 3 Sep 2015 09:25:43 -0700 Subject: [PATCH 068/117] allow backslashes in fileName argument of the transpile function --- src/services/services.ts | 2 +- tests/cases/unittests/transpile.ts | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/services/services.ts b/src/services/services.ts index 4358c9d58a9..b174f240875 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -1866,7 +1866,7 @@ namespace ts { let sourceMapText: string; // Create a compilerHost object to allow the compiler to read and write files let compilerHost: CompilerHost = { - getSourceFile: (fileName, target) => fileName === inputFileName ? sourceFile : undefined, + getSourceFile: (fileName, target) => fileName === normalizeSlashes(inputFileName) ? sourceFile : undefined, writeFile: (name, text, writeByteOrderMark) => { if (fileExtensionIs(name, ".map")) { Debug.assert(sourceMapText === undefined, `Unexpected multiple source map outputs for the file '${name}'`); diff --git a/tests/cases/unittests/transpile.ts b/tests/cases/unittests/transpile.ts index 0b87910d26e..9336c323bb4 100644 --- a/tests/cases/unittests/transpile.ts +++ b/tests/cases/unittests/transpile.ts @@ -64,8 +64,8 @@ module ts { let transpileModuleResultWithSourceMap = transpileModule(input, transpileOptions); assert.isTrue(transpileModuleResultWithSourceMap.sourceMapText !== undefined); - let expectedSourceMapFileName = removeFileExtension(transpileOptions.fileName) + ".js.map"; - let expectedSourceMappingUrlLine = `//# sourceMappingURL=${expectedSourceMapFileName}`; + let expectedSourceMapFileName = removeFileExtension(getBaseFileName(normalizeSlashes(transpileOptions.fileName))) + ".js.map"; + let expectedSourceMappingUrlLine = `//# sourceMappingURL=${expectedSourceMapFileName}`; if (testSettings.expectedOutput !== undefined) { assert.equal(transpileModuleResultWithSourceMap.outputText, testSettings.expectedOutput + expectedSourceMappingUrlLine); @@ -270,5 +270,9 @@ var x = 0;`, expectedOutput: output }); }); + + it("Supports backslashes in file name", () => { + test("var x", { expectedOutput: "var x;\r\n", options: { fileName: "a\\b.ts" }}); + }); }); } From b8071f99bcb52bcfe8384cece68be9781a0e9467 Mon Sep 17 00:00:00 2001 From: SaschaNaz Date: Thu, 3 Sep 2015 22:33:07 +0900 Subject: [PATCH 069/117] format intersection type --- src/services/formatting/rules.ts | 10 +++++--- src/services/formatting/smartIndenter.ts | 1 - tests/cases/fourslash/formatTypeOperation.ts | 26 ++++++++++++++++++++ tests/cases/fourslash/formatTypeUnion.ts | 14 ----------- 4 files changed, 33 insertions(+), 18 deletions(-) create mode 100644 tests/cases/fourslash/formatTypeOperation.ts delete mode 100644 tests/cases/fourslash/formatTypeUnion.ts diff --git a/src/services/formatting/rules.ts b/src/services/formatting/rules.ts index f609edb0501..56290800c0d 100644 --- a/src/services/formatting/rules.ts +++ b/src/services/formatting/rules.ts @@ -227,11 +227,13 @@ namespace ts.formatting { public SpaceBetweenTagAndTemplateString: Rule; public NoSpaceBetweenTagAndTemplateString: Rule; - // Union type + // Type operation public SpaceBeforeBar: Rule; public NoSpaceBeforeBar: Rule; public SpaceAfterBar: Rule; public NoSpaceAfterBar: Rule; + public SpaceBeforeAmpersand: Rule; + public SpaceAfterAmpersand: Rule; constructor() { /// @@ -394,12 +396,13 @@ namespace ts.formatting { this.SpaceBetweenTagAndTemplateString = new Rule(RuleDescriptor.create3(SyntaxKind.Identifier, Shared.TokenRange.FromTokens([SyntaxKind.NoSubstitutionTemplateLiteral, SyntaxKind.TemplateHead])), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Space)); this.NoSpaceBetweenTagAndTemplateString = new Rule(RuleDescriptor.create3(SyntaxKind.Identifier, Shared.TokenRange.FromTokens([SyntaxKind.NoSubstitutionTemplateLiteral, SyntaxKind.TemplateHead])), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Delete)); - // union type + // type operation this.SpaceBeforeBar = new Rule(RuleDescriptor.create3(SyntaxKind.BarToken, Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Space)); this.NoSpaceBeforeBar = new Rule(RuleDescriptor.create3(SyntaxKind.BarToken, Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Delete)); this.SpaceAfterBar = new Rule(RuleDescriptor.create2(Shared.TokenRange.Any, SyntaxKind.BarToken), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Space)); this.NoSpaceAfterBar = new Rule(RuleDescriptor.create2(Shared.TokenRange.Any, SyntaxKind.BarToken), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Delete)); - + this.SpaceBeforeAmpersand = new Rule(RuleDescriptor.create3(SyntaxKind.AmpersandToken, Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Space)); + this.SpaceAfterAmpersand = new Rule(RuleDescriptor.create2(Shared.TokenRange.Any, SyntaxKind.AmpersandToken), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Space)); // These rules are higher in priority than user-configurable rules. this.HighPriorityCommonRules = @@ -432,6 +435,7 @@ namespace ts.formatting { this.SpaceAfterTypeKeyword, this.NoSpaceAfterTypeKeyword, this.SpaceBetweenTagAndTemplateString, this.NoSpaceBetweenTagAndTemplateString, this.SpaceBeforeBar, this.NoSpaceBeforeBar, this.SpaceAfterBar, this.NoSpaceAfterBar, + this.SpaceBeforeAmpersand, this.SpaceAfterAmpersand, // TypeScript-specific rules this.NoSpaceAfterConstructor, this.NoSpaceAfterModuleImport, diff --git a/src/services/formatting/smartIndenter.ts b/src/services/formatting/smartIndenter.ts index ebbf09e9feb..9c341dca5ff 100644 --- a/src/services/formatting/smartIndenter.ts +++ b/src/services/formatting/smartIndenter.ts @@ -436,7 +436,6 @@ namespace ts.formatting { case SyntaxKind.Parameter: case SyntaxKind.FunctionType: case SyntaxKind.ConstructorType: - case SyntaxKind.UnionType: case SyntaxKind.ParenthesizedType: case SyntaxKind.TaggedTemplateExpression: case SyntaxKind.AwaitExpression: diff --git a/tests/cases/fourslash/formatTypeOperation.ts b/tests/cases/fourslash/formatTypeOperation.ts new file mode 100644 index 00000000000..8708ef34d5c --- /dev/null +++ b/tests/cases/fourslash/formatTypeOperation.ts @@ -0,0 +1,26 @@ +/// + +////type Union = number | {}/*formatBarOperator*/ +/////*indent*/ +////|string/*autoformat*/ +////type Intersection = Foo & Bar;/*formatAmpersandOperator*/ +////type Complexed = +//// Foo& +//// Bar|/*unionTypeNoIndent*/ +//// Baz;/*intersectionTypeNoIndent*/ + +format.document(); + +goTo.marker("formatBarOperator"); +verify.currentLineContentIs("type Union = number | {}"); +goTo.marker("indent"); +verify.indentationIs(4); +goTo.marker("autoformat"); +verify.currentLineContentIs(" | string"); +goTo.marker("formatAmpersandOperator"); +verify.currentLineContentIs("type Intersection = Foo & Bar;"); + +goTo.marker("unionTypeNoIndent"); +verify.currentLineContentIs("Bar |"); +goTo.marker("intersectionTypeNoIndent"); +verify.currentLineContentIs("Baz;"); \ No newline at end of file diff --git a/tests/cases/fourslash/formatTypeUnion.ts b/tests/cases/fourslash/formatTypeUnion.ts deleted file mode 100644 index 267ba656612..00000000000 --- a/tests/cases/fourslash/formatTypeUnion.ts +++ /dev/null @@ -1,14 +0,0 @@ -/// - -////type Union = number | {}/*formatOperator*/ -/////*indent*/ -////|string/*autoformat*/ - -format.document(); - -goTo.marker("formatOperator"); -verify.currentLineContentIs("type Union = number | {}"); -goTo.marker("indent"); -verify.indentationIs(4); -goTo.marker("autoformat"); -verify.currentLineContentIs(" | string"); \ No newline at end of file From 40112c51378cbfac4ec72f08e5f32f94efbf9bcd Mon Sep 17 00:00:00 2001 From: SaschaNaz Date: Thu, 3 Sep 2015 22:45:41 +0900 Subject: [PATCH 070/117] fix test --- tests/cases/fourslash/formatTypeOperation.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/cases/fourslash/formatTypeOperation.ts b/tests/cases/fourslash/formatTypeOperation.ts index 8708ef34d5c..956508f7290 100644 --- a/tests/cases/fourslash/formatTypeOperation.ts +++ b/tests/cases/fourslash/formatTypeOperation.ts @@ -21,6 +21,6 @@ goTo.marker("formatAmpersandOperator"); verify.currentLineContentIs("type Intersection = Foo & Bar;"); goTo.marker("unionTypeNoIndent"); -verify.currentLineContentIs("Bar |"); +verify.currentLineContentIs(" Bar |"); goTo.marker("intersectionTypeNoIndent"); -verify.currentLineContentIs("Baz;"); \ No newline at end of file +verify.currentLineContentIs(" Baz;"); \ No newline at end of file From 58c732b47dfbd9459b28764645e7a4e997bf8699 Mon Sep 17 00:00:00 2001 From: SaschaNaz Date: Thu, 3 Sep 2015 22:07:52 +0900 Subject: [PATCH 071/117] format class expression indentation --- src/services/formatting/rules.ts | 3 ++- src/services/formatting/smartIndenter.ts | 1 + .../cases/fourslash/formatClassExpression.ts | 23 +++++++++++++++++++ 3 files changed, 26 insertions(+), 1 deletion(-) create mode 100644 tests/cases/fourslash/formatClassExpression.ts diff --git a/src/services/formatting/rules.ts b/src/services/formatting/rules.ts index 56290800c0d..876efa3a9e1 100644 --- a/src/services/formatting/rules.ts +++ b/src/services/formatting/rules.ts @@ -274,7 +274,7 @@ namespace ts.formatting { this.SpaceBeforeOpenBraceInFunction = new Rule(RuleDescriptor.create2(this.FunctionOpenBraceLeftTokenRange, SyntaxKind.OpenBraceToken), RuleOperation.create2(new RuleOperationContext(Rules.IsFunctionDeclContext, Rules.IsBeforeBlockContext, Rules.IsNotFormatOnEnter, Rules.IsSameLineTokenOrBeforeMultilineBlockContext), RuleAction.Space), RuleFlags.CanDeleteNewLines); // Place a space before open brace in a TypeScript declaration that has braces as children (class, module, enum, etc) - this.TypeScriptOpenBraceLeftTokenRange = Shared.TokenRange.FromTokens([SyntaxKind.Identifier, SyntaxKind.MultiLineCommentTrivia]); + this.TypeScriptOpenBraceLeftTokenRange = Shared.TokenRange.FromTokens([SyntaxKind.Identifier, SyntaxKind.MultiLineCommentTrivia, SyntaxKind.ClassKeyword]); this.SpaceBeforeOpenBraceInTypeScriptDeclWithBlock = new Rule(RuleDescriptor.create2(this.TypeScriptOpenBraceLeftTokenRange, SyntaxKind.OpenBraceToken), RuleOperation.create2(new RuleOperationContext(Rules.IsTypeScriptDeclWithBlockContext, Rules.IsNotFormatOnEnter, Rules.IsSameLineTokenOrBeforeMultilineBlockContext), RuleAction.Space), RuleFlags.CanDeleteNewLines); // Place a space before open brace in a control flow construct @@ -667,6 +667,7 @@ namespace ts.formatting { static NodeIsTypeScriptDeclWithBlockContext(node: Node): boolean { switch (node.kind) { case SyntaxKind.ClassDeclaration: + case SyntaxKind.ClassExpression: case SyntaxKind.InterfaceDeclaration: case SyntaxKind.EnumDeclaration: case SyntaxKind.TypeLiteral: diff --git a/src/services/formatting/smartIndenter.ts b/src/services/formatting/smartIndenter.ts index 9c341dca5ff..9c19e32ab6f 100644 --- a/src/services/formatting/smartIndenter.ts +++ b/src/services/formatting/smartIndenter.ts @@ -406,6 +406,7 @@ namespace ts.formatting { function nodeContentIsAlwaysIndented(kind: SyntaxKind): boolean { switch (kind) { case SyntaxKind.ClassDeclaration: + case SyntaxKind.ClassExpression: case SyntaxKind.InterfaceDeclaration: case SyntaxKind.EnumDeclaration: case SyntaxKind.TypeAliasDeclaration: diff --git a/tests/cases/fourslash/formatClassExpression.ts b/tests/cases/fourslash/formatClassExpression.ts new file mode 100644 index 00000000000..0a00203e77f --- /dev/null +++ b/tests/cases/fourslash/formatClassExpression.ts @@ -0,0 +1,23 @@ +/// + +////class Thing extends ( +//// class/*classOpenBrace*/ +//// { +/////*classIndent*/ +//// protected doThing() {/*methodAutoformat*/ +/////*methodIndent*/ +//// } +//// } +////) { +////} + +format.document(); + +goTo.marker("classOpenBrace"); +verify.currentLineContentIs(" class {"); +goTo.marker("classIndent"); +verify.indentationIs(8); +goTo.marker("methodAutoformat"); +verify.currentLineContentIs(" protected doThing() {"); +goTo.marker("methodIndent"); +verify.indentationIs(12); \ No newline at end of file From ff640e415f112dd35df6377b0813e7991bce021b Mon Sep 17 00:00:00 2001 From: Vladimir Matveev Date: Tue, 1 Sep 2015 12:41:48 -0700 Subject: [PATCH 072/117] fix 'findPrecedingToken' for jsxText --- src/services/utilities.ts | 39 ++++++++++++++-------- tests/cases/fourslash/indentationInJsx1.ts | 17 ++++++++++ tests/cases/fourslash/indentationInJsx2.ts | 7 ++++ 3 files changed, 49 insertions(+), 14 deletions(-) create mode 100644 tests/cases/fourslash/indentationInJsx1.ts create mode 100644 tests/cases/fourslash/indentationInJsx2.ts diff --git a/src/services/utilities.ts b/src/services/utilities.ts index d5ad93260cd..8b77dcb953b 100644 --- a/src/services/utilities.ts +++ b/src/services/utilities.ts @@ -360,7 +360,7 @@ namespace ts { return find(startNode || sourceFile); function findRightmostToken(n: Node): Node { - if (isToken(n)) { + if (isToken(n) || n.kind === SyntaxKind.JsxText) { return n; } @@ -371,24 +371,35 @@ namespace ts { } function find(n: Node): Node { - if (isToken(n)) { + if (isToken(n) || n.kind === SyntaxKind.JsxText) { return n; } - let children = n.getChildren(); + const children = n.getChildren(); for (let i = 0, len = children.length; i < len; i++) { let child = children[i]; - if (nodeHasTokens(child)) { - if (position <= child.end) { - if (child.getStart(sourceFile) >= position) { - // actual start of the node is past the position - previous token should be at the end of previous child - let candidate = findRightmostChildNodeWithTokens(children, /*exclusiveStartPosition*/ i); - return candidate && findRightmostToken(candidate) - } - else { - // candidate should be in this node - return find(child); - } + // condition 'position < child.end' checks if child node end after the position + // in the example below this condition will be false for 'aaaa' and 'bbbb' and true for 'ccc' + // aaaa___bbbb___$__ccc + // after we found child node with end after the position we check if start of the node is after the position. + // if yes - then position is in the trivia and we need to look into the previous child to find the token in question. + // if no - position is in the node itself so we should recurse in it. + // NOTE: JsxText is a weird kind of node that can contain only whitespaces (since they are not counted as trivia). + // if this is the case - then we should assume that token in question is located in previous child. + if (position < child.end && (nodeHasTokens(child) || child.kind === SyntaxKind.JsxText)) { + const start = child.getStart(sourceFile); + const lookInPreviousChild = + (start >= position) || // cursor in the leading trivia + (child.kind === SyntaxKind.JsxText && start === child.end); // whitespace only JsxText + + if (lookInPreviousChild) { + // actual start of the node is past the position - previous token should be at the end of previous child + let candidate = findRightmostChildNodeWithTokens(children, /*exclusiveStartPosition*/ i); + return candidate && findRightmostToken(candidate) + } + else { + // candidate should be in this node + return find(child); } } } diff --git a/tests/cases/fourslash/indentationInJsx1.ts b/tests/cases/fourslash/indentationInJsx1.ts new file mode 100644 index 00000000000..5343c7a7c10 --- /dev/null +++ b/tests/cases/fourslash/indentationInJsx1.ts @@ -0,0 +1,17 @@ +/// + +//@Filename: file.tsx +////(function () { +//// return ( +////
+////
+////
+//// /*indent2*/ +////
+//// ) +////}) + + +format.document(); +goTo.marker("indent2"); +verify.indentationIs(12); \ No newline at end of file diff --git a/tests/cases/fourslash/indentationInJsx2.ts b/tests/cases/fourslash/indentationInJsx2.ts new file mode 100644 index 00000000000..f23a14f68cc --- /dev/null +++ b/tests/cases/fourslash/indentationInJsx2.ts @@ -0,0 +1,7 @@ +/// + +//@Filename: file.tsx +////
/*1*/ +goTo.marker("1"); +edit.insert("\n"); +verify.indentationIs(0); From 59f5ce4582c648b9d98f891ed3fe9567fba34d19 Mon Sep 17 00:00:00 2001 From: SaschaNaz Date: Fri, 4 Sep 2015 19:35:07 +0900 Subject: [PATCH 073/117] fix comment indentation --- src/services/formatting/formatting.ts | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/src/services/formatting/formatting.ts b/src/services/formatting/formatting.ts index 66cdbd53750..490cca74775 100644 --- a/src/services/formatting/formatting.ts +++ b/src/services/formatting/formatting.ts @@ -32,7 +32,7 @@ namespace ts.formatting { */ interface DynamicIndentation { getIndentationForToken(tokenLine: number, tokenKind: SyntaxKind): number; - getIndentationForComment(owningToken: SyntaxKind): number; + getIndentationForComment(owningToken: SyntaxKind, tokenIndentation: number): number; /** * Indentation for open and close tokens of the node if it is block or another node that needs special indentation * ... { @@ -455,7 +455,7 @@ namespace ts.formatting { function getDynamicIndentation(node: Node, nodeStartLine: number, indentation: number, delta: number): DynamicIndentation { return { - getIndentationForComment: kind => { + getIndentationForComment: (kind, tokenIndentation) => { switch (kind) { // preceding comment to the token that closes the indentation scope inherits the indentation from the scope // .. { @@ -463,9 +463,10 @@ namespace ts.formatting { // } case SyntaxKind.CloseBraceToken: case SyntaxKind.CloseBracketToken: + case SyntaxKind.CloseParenToken: return indentation + delta; } - return indentation; + return tokenIndentation !== Constants.Unknown ? tokenIndentation : indentation; }, getIndentationForToken: (line, kind) => { if (nodeStartLine !== line && node.decorators) { @@ -716,8 +717,13 @@ namespace ts.formatting { } if (indentToken) { - let indentNextTokenOrTrivia = true; + let tokenIndentation = (isTokenInRange && !rangeContainsError(currentTokenInfo.token)) ? + dynamicIndentation.getIndentationForToken(tokenStart.line, currentTokenInfo.token.kind) : + Constants.Unknown; + let commentIndentation = dynamicIndentation.getIndentationForComment(currentTokenInfo.token.kind, tokenIndentation); + if (currentTokenInfo.leadingTrivia) { + let indentNextTokenOrTrivia = true; for (let triviaItem of currentTokenInfo.leadingTrivia) { if (!rangeContainsRange(originalRange, triviaItem)) { continue; @@ -725,13 +731,11 @@ namespace ts.formatting { switch (triviaItem.kind) { case SyntaxKind.MultiLineCommentTrivia: - let commentIndentation = dynamicIndentation.getIndentationForComment(currentTokenInfo.token.kind); indentMultilineComment(triviaItem, commentIndentation, /*firstLineIsIndented*/ !indentNextTokenOrTrivia); indentNextTokenOrTrivia = false; break; case SyntaxKind.SingleLineCommentTrivia: if (indentNextTokenOrTrivia) { - let commentIndentation = dynamicIndentation.getIndentationForComment(currentTokenInfo.token.kind); insertIndentation(triviaItem.pos, commentIndentation, /*lineAdded*/ false); indentNextTokenOrTrivia = false; } @@ -744,8 +748,7 @@ namespace ts.formatting { } // indent token only if is it is in target range and does not overlap with any error ranges - if (isTokenInRange && !rangeContainsError(currentTokenInfo.token)) { - let tokenIndentation = dynamicIndentation.getIndentationForToken(tokenStart.line, currentTokenInfo.token.kind); + if (tokenIndentation !== Constants.Unknown) { insertIndentation(currentTokenInfo.token.pos, tokenIndentation, lineAdded); lastIndentedLine = tokenStart.line; From b0f0dc1fd8437d3fdafb624c800076ca6cba0629 Mon Sep 17 00:00:00 2001 From: SaschaNaz Date: Fri, 4 Sep 2015 21:38:39 +0900 Subject: [PATCH 074/117] add tests for comments --- tests/cases/fourslash/formatComments.ts | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 tests/cases/fourslash/formatComments.ts diff --git a/tests/cases/fourslash/formatComments.ts b/tests/cases/fourslash/formatComments.ts new file mode 100644 index 00000000000..083ba6c078d --- /dev/null +++ b/tests/cases/fourslash/formatComments.ts @@ -0,0 +1,24 @@ +/// + +////_.chain() +////// wow/*callChain1*/ +//// .then() +////// waa/*callChain2*/ +//// .then(); +////wow( +//// 3, +////// uaa/*argument1*/ +//// 4 +////// wua/*argument2*/ +////); + +format.document(); + +goTo.marker("callChain1"); +verify.currentLineContentIs(" // wow"); +goTo.marker("callChain2"); +verify.currentLineContentIs(" // waa"); +goTo.marker("argument1"); +verify.currentLineContentIs(" // uaa"); +goTo.marker("argument2"); +verify.currentLineContentIs(" // wua"); \ No newline at end of file From 4aded270f72882087da96b21478203dbb0c52109 Mon Sep 17 00:00:00 2001 From: SaschaNaz Date: Fri, 4 Sep 2015 21:54:14 +0900 Subject: [PATCH 075/117] move declaration into the block --- src/services/formatting/formatting.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/services/formatting/formatting.ts b/src/services/formatting/formatting.ts index 490cca74775..fad3ebe6e2b 100644 --- a/src/services/formatting/formatting.ts +++ b/src/services/formatting/formatting.ts @@ -720,10 +720,11 @@ namespace ts.formatting { let tokenIndentation = (isTokenInRange && !rangeContainsError(currentTokenInfo.token)) ? dynamicIndentation.getIndentationForToken(tokenStart.line, currentTokenInfo.token.kind) : Constants.Unknown; - let commentIndentation = dynamicIndentation.getIndentationForComment(currentTokenInfo.token.kind, tokenIndentation); if (currentTokenInfo.leadingTrivia) { + let commentIndentation = dynamicIndentation.getIndentationForComment(currentTokenInfo.token.kind, tokenIndentation); let indentNextTokenOrTrivia = true; + for (let triviaItem of currentTokenInfo.leadingTrivia) { if (!rangeContainsRange(originalRange, triviaItem)) { continue; From 856f2d895c4f18f1b7c89f4248622788e8c85fd3 Mon Sep 17 00:00:00 2001 From: vilicvane Date: Fri, 4 Sep 2015 21:47:28 +0800 Subject: [PATCH 076/117] Fix issue #4603 --- src/compiler/emitter.ts | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index eeaab6d2123..8a04be99caa 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -897,6 +897,16 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi write(text); } } + + function getEmittingNumericLiteralText(node: LiteralExpression): string { + let text = getLiteralText(node); + + if (languageVersion < ScriptTarget.ES6 && isBinaryOrOctalIntegerLiteral(node, text)) { + return node.text; + } else { + return text; + } + } function getLiteralText(node: LiteralExpression) { // Any template literal or string literal with an extended escape @@ -2352,7 +2362,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi operand.kind !== SyntaxKind.PostfixUnaryExpression && operand.kind !== SyntaxKind.NewExpression && !(operand.kind === SyntaxKind.CallExpression && node.parent.kind === SyntaxKind.NewExpression) && - !(operand.kind === SyntaxKind.FunctionExpression && node.parent.kind === SyntaxKind.CallExpression)) { + !(operand.kind === SyntaxKind.FunctionExpression && node.parent.kind === SyntaxKind.CallExpression) && + !(operand.kind === SyntaxKind.NumericLiteral && node.parent.kind === SyntaxKind.PropertyAccessExpression && !/^0[box]|[e.]/i.test(getEmittingNumericLiteralText(operand)))) { emit(operand); return; } From 32d8a22990612e3616068960042803d63b5b3150 Mon Sep 17 00:00:00 2001 From: vilicvane Date: Fri, 4 Sep 2015 22:15:10 +0800 Subject: [PATCH 077/117] Add tests for issue #4603 --- .../reference/castExpressionParentheses.js | 14 ++++++ .../castExpressionParentheses.symbols | 27 +++++++---- .../reference/castExpressionParentheses.types | 48 +++++++++++++++++++ .../castExpressionParentheses_ES6.js | 11 +++++ .../castExpressionParentheses_ES6.symbols | 7 +++ .../castExpressionParentheses_ES6.types | 11 +++++ .../compiler/castExpressionParentheses.ts | 7 +++ .../compiler/castExpressionParentheses_ES6.ts | 5 ++ 8 files changed, 120 insertions(+), 10 deletions(-) create mode 100644 tests/baselines/reference/castExpressionParentheses_ES6.js create mode 100644 tests/baselines/reference/castExpressionParentheses_ES6.symbols create mode 100644 tests/baselines/reference/castExpressionParentheses_ES6.types create mode 100644 tests/cases/compiler/castExpressionParentheses_ES6.ts diff --git a/tests/baselines/reference/castExpressionParentheses.js b/tests/baselines/reference/castExpressionParentheses.js index ec18d6e373e..22316df7f43 100644 --- a/tests/baselines/reference/castExpressionParentheses.js +++ b/tests/baselines/reference/castExpressionParentheses.js @@ -7,6 +7,11 @@ declare var a; ([1,3,]); ("string"); (23.0); +(1); +(1.).foo; +(1.0).foo; +(12e+34).foo; +(0xff).foo; (/regexp/g); (false); (true); @@ -23,6 +28,8 @@ declare var a; declare var A; // should keep the parentheses in emit +(1).foo; +((1.0)).foo; (new A).foo; (typeof A).x; (-A).x; @@ -46,6 +53,11 @@ new (A()); [1, 3,]; "string"; 23.0; +1; +1..foo; +1.0.foo; +12e+34.foo; +0xff.foo; /regexp/g; false; true; @@ -59,6 +71,8 @@ a[0]; a.b["0"]; a().x; // should keep the parentheses in emit +(1).foo; +(1.0).foo; (new A).foo; (typeof A).x; (-A).x; diff --git a/tests/baselines/reference/castExpressionParentheses.symbols b/tests/baselines/reference/castExpressionParentheses.symbols index 7bc8169e40f..a7f51f9f2cb 100644 --- a/tests/baselines/reference/castExpressionParentheses.symbols +++ b/tests/baselines/reference/castExpressionParentheses.symbols @@ -10,6 +10,11 @@ declare var a; ([1,3,]); ("string"); (23.0); +(1); +(1.).foo; +(1.0).foo; +(12e+34).foo; +(0xff).foo; (/regexp/g); (false); (true); @@ -33,36 +38,38 @@ declare var a; >a : Symbol(a, Decl(castExpressionParentheses.ts, 0, 11)) declare var A; ->A : Symbol(A, Decl(castExpressionParentheses.ts, 21, 11)) +>A : Symbol(A, Decl(castExpressionParentheses.ts, 26, 11)) // should keep the parentheses in emit +(1).foo; +((1.0)).foo; (new A).foo; ->A : Symbol(A, Decl(castExpressionParentheses.ts, 21, 11)) +>A : Symbol(A, Decl(castExpressionParentheses.ts, 26, 11)) (typeof A).x; ->A : Symbol(A, Decl(castExpressionParentheses.ts, 21, 11)) +>A : Symbol(A, Decl(castExpressionParentheses.ts, 26, 11)) (-A).x; ->A : Symbol(A, Decl(castExpressionParentheses.ts, 21, 11)) +>A : Symbol(A, Decl(castExpressionParentheses.ts, 26, 11)) new (A()); ->A : Symbol(A, Decl(castExpressionParentheses.ts, 21, 11)) +>A : Symbol(A, Decl(castExpressionParentheses.ts, 26, 11)) (()=> {})(); ->Tany : Symbol(Tany, Decl(castExpressionParentheses.ts, 28, 2)) +>Tany : Symbol(Tany, Decl(castExpressionParentheses.ts, 35, 2)) (function foo() { })(); ->foo : Symbol(foo, Decl(castExpressionParentheses.ts, 29, 6)) +>foo : Symbol(foo, Decl(castExpressionParentheses.ts, 36, 6)) (-A).x; ->A : Symbol(A, Decl(castExpressionParentheses.ts, 21, 11)) +>A : Symbol(A, Decl(castExpressionParentheses.ts, 26, 11)) // nested cast, should keep one pair of parenthese ((-A)).x; ->A : Symbol(A, Decl(castExpressionParentheses.ts, 21, 11)) +>A : Symbol(A, Decl(castExpressionParentheses.ts, 26, 11)) // nested parenthesized expression, should keep one pair of parenthese ((A)) ->A : Symbol(A, Decl(castExpressionParentheses.ts, 21, 11)) +>A : Symbol(A, Decl(castExpressionParentheses.ts, 26, 11)) diff --git a/tests/baselines/reference/castExpressionParentheses.types b/tests/baselines/reference/castExpressionParentheses.types index ab563a4e8b7..1d203958555 100644 --- a/tests/baselines/reference/castExpressionParentheses.types +++ b/tests/baselines/reference/castExpressionParentheses.types @@ -28,6 +28,39 @@ declare var a; >23.0 : any >23.0 : number +(1); +>(1) : any +>1 : any +>1 : number + +(1.).foo; +>(1.).foo : any +>(1.) : any +>1. : any +>1. : number +>foo : any + +(1.0).foo; +>(1.0).foo : any +>(1.0) : any +>1.0 : any +>1.0 : number +>foo : any + +(12e+34).foo; +>(12e+34).foo : any +>(12e+34) : any +>12e+34 : any +>12e+34 : number +>foo : any + +(0xff).foo; +>(0xff).foo : any +>(0xff) : any +>0xff : any +>0xff : number +>foo : any + (/regexp/g); >(/regexp/g) : any >/regexp/g : any @@ -104,6 +137,21 @@ declare var A; >A : any // should keep the parentheses in emit +(1).foo; +>(1).foo : any +>(1) : any +>1 : any +>1 : number +>foo : any + +((1.0)).foo; +>((1.0)).foo : any +>((1.0)) : any +>(1.0) : any +>(1.0) : number +>1.0 : number +>foo : any + (new A).foo; >(new A).foo : any >(new A) : any diff --git a/tests/baselines/reference/castExpressionParentheses_ES6.js b/tests/baselines/reference/castExpressionParentheses_ES6.js new file mode 100644 index 00000000000..6ffbe7c2885 --- /dev/null +++ b/tests/baselines/reference/castExpressionParentheses_ES6.js @@ -0,0 +1,11 @@ +//// [castExpressionParentheses_ES6.ts] + +// parentheses should be omitted +// numeric literal +(0o123).foo; + + +//// [castExpressionParentheses_ES6.js] +// parentheses should be omitted +// numeric literal +0o123.foo; diff --git a/tests/baselines/reference/castExpressionParentheses_ES6.symbols b/tests/baselines/reference/castExpressionParentheses_ES6.symbols new file mode 100644 index 00000000000..c1b31043cb1 --- /dev/null +++ b/tests/baselines/reference/castExpressionParentheses_ES6.symbols @@ -0,0 +1,7 @@ +=== tests/cases/compiler/castExpressionParentheses_ES6.ts === + +No type information for this code.// parentheses should be omitted +No type information for this code.// numeric literal +No type information for this code.(0o123).foo; +No type information for this code. +No type information for this code. \ No newline at end of file diff --git a/tests/baselines/reference/castExpressionParentheses_ES6.types b/tests/baselines/reference/castExpressionParentheses_ES6.types new file mode 100644 index 00000000000..41f968a834f --- /dev/null +++ b/tests/baselines/reference/castExpressionParentheses_ES6.types @@ -0,0 +1,11 @@ +=== tests/cases/compiler/castExpressionParentheses_ES6.ts === + +// parentheses should be omitted +// numeric literal +(0o123).foo; +>(0o123).foo : any +>(0o123) : any +>0o123 : any +>0o123 : number +>foo : any + diff --git a/tests/cases/compiler/castExpressionParentheses.ts b/tests/cases/compiler/castExpressionParentheses.ts index 93b26ebaf4e..e6ed4d82785 100644 --- a/tests/cases/compiler/castExpressionParentheses.ts +++ b/tests/cases/compiler/castExpressionParentheses.ts @@ -6,6 +6,11 @@ declare var a; ([1,3,]); ("string"); (23.0); +(1); +(1.).foo; +(1.0).foo; +(12e+34).foo; +(0xff).foo; (/regexp/g); (false); (true); @@ -22,6 +27,8 @@ declare var a; declare var A; // should keep the parentheses in emit +(1).foo; +((1.0)).foo; (new A).foo; (typeof A).x; (-A).x; diff --git a/tests/cases/compiler/castExpressionParentheses_ES6.ts b/tests/cases/compiler/castExpressionParentheses_ES6.ts new file mode 100644 index 00000000000..03d6d8ae5fa --- /dev/null +++ b/tests/cases/compiler/castExpressionParentheses_ES6.ts @@ -0,0 +1,5 @@ +// @target: es6 + +// parentheses should be omitted +// numeric literal +(0o123).foo; From 35d608692ba7220566a3846e2f494acbf26209d5 Mon Sep 17 00:00:00 2001 From: Vladimir Matveev Date: Fri, 4 Sep 2015 10:53:33 -0700 Subject: [PATCH 078/117] handle jsx identifiers correctly, indent content of JsxSelfClosingElement --- src/services/formatting/formattingScanner.ts | 25 ++++++- src/services/formatting/smartIndenter.ts | 1 + .../cases/fourslash/formattingJsxElements.ts | 70 ++++++++++++++++++- 3 files changed, 92 insertions(+), 4 deletions(-) diff --git a/src/services/formatting/formattingScanner.ts b/src/services/formatting/formattingScanner.ts index 7e77878051c..6f6167d6ba9 100644 --- a/src/services/formatting/formattingScanner.ts +++ b/src/services/formatting/formattingScanner.ts @@ -17,7 +17,8 @@ namespace ts.formatting { Scan, RescanGreaterThanToken, RescanSlashToken, - RescanTemplateToken + RescanTemplateToken, + RescanJsxIdentifier } export function getFormattingScanner(sourceFile: SourceFile, startPos: number, endPos: number): FormattingScanner { @@ -108,6 +109,20 @@ namespace ts.formatting { return false; } + + function shouldRescanJsxIdentifier(node: Node): boolean { + if (node.parent) { + switch(node.parent.kind) { + case SyntaxKind.JsxAttribute: + case SyntaxKind.JsxOpeningElement: + case SyntaxKind.JsxClosingElement: + case SyntaxKind.JsxSelfClosingElement: + return node.kind === SyntaxKind.Identifier; + } + } + + return false; + } function shouldRescanSlashToken(container: Node): boolean { return container.kind === SyntaxKind.RegularExpressionLiteral; @@ -141,7 +156,9 @@ namespace ts.formatting { ? ScanAction.RescanSlashToken : shouldRescanTemplateToken(n) ? ScanAction.RescanTemplateToken - : ScanAction.Scan + : shouldRescanJsxIdentifier(n) + ? ScanAction.RescanJsxIdentifier + : ScanAction.Scan if (lastTokenInfo && expectedScanAction === lastScanAction) { // readTokenInfo was called before with the same expected scan action. @@ -176,6 +193,10 @@ namespace ts.formatting { currentToken = scanner.reScanTemplateToken(); lastScanAction = ScanAction.RescanTemplateToken; } + else if (expectedScanAction === ScanAction.RescanJsxIdentifier && currentToken === SyntaxKind.Identifier) { + currentToken = scanner.scanJsxIdentifier(); + lastScanAction = ScanAction.RescanJsxIdentifier; + } else { lastScanAction = ScanAction.Scan; } diff --git a/src/services/formatting/smartIndenter.ts b/src/services/formatting/smartIndenter.ts index 9c19e32ab6f..8355fac03f5 100644 --- a/src/services/formatting/smartIndenter.ts +++ b/src/services/formatting/smartIndenter.ts @@ -431,6 +431,7 @@ namespace ts.formatting { case SyntaxKind.ArrayBindingPattern: case SyntaxKind.ObjectBindingPattern: case SyntaxKind.JsxElement: + case SyntaxKind.JsxSelfClosingElement: case SyntaxKind.MethodSignature: case SyntaxKind.CallSignature: case SyntaxKind.ConstructSignature: diff --git a/tests/cases/fourslash/formattingJsxElements.ts b/tests/cases/fourslash/formattingJsxElements.ts index d0c77804ed5..fd4ccc504a4 100644 --- a/tests/cases/fourslash/formattingJsxElements.ts +++ b/tests/cases/fourslash/formattingJsxElements.ts @@ -1,7 +1,7 @@ /// //@Filename: file.tsx -////function () { +////function foo0() { //// return ( ////
////Hello, World!/*autoformat*/ @@ -10,10 +10,76 @@ //// ) ////} //// +////function foo1() { +//// return ( +////
+////Hello, World!/*autoformat1*/ +/////*indent1*/ +////
+//// ) +////} +//// +////function foo2() { +//// return ( +////
/*2*/ +////Hello, World!/*autoformat2*/ +/////*indent2*/ +////
+//// ) +////} +////function foo3() { +//// return ( +//// /*4*/ +//// Hello, World!/*autoformat3*/ +//// /*indent3*/ +//// +//// ) +////} +////function foo4() { +//// return ( +//// /*6*/ +//// ) +////} format.document(); goTo.marker("autoformat"); verify.currentLineContentIs(' Hello, World!'); goTo.marker("indent"); -verify.indentationIs(12); \ No newline at end of file +verify.indentationIs(12); + +goTo.marker("autoformat1"); +verify.currentLineContentIs(' Hello, World!'); +goTo.marker("indent1"); +verify.indentationIs(12); + +goTo.marker("1"); +verify.currentLineContentIs(' class1= {'); +goTo.marker("2"); +verify.currentLineContentIs(' }>'); + +goTo.marker("autoformat2"); +verify.currentLineContentIs(' Hello, World!'); +goTo.marker("indent2"); +verify.indentationIs(12); + +goTo.marker("3"); +verify.currentLineContentIs(' class2= {'); +goTo.marker("4"); +verify.currentLineContentIs(' }>'); + +goTo.marker("autoformat3"); +verify.currentLineContentIs(' Hello, World!'); +goTo.marker("indent3"); +verify.indentationIs(12); + +goTo.marker("5"); +verify.currentLineContentIs(' class3= {'); +goTo.marker("6"); +verify.currentLineContentIs(' }/>'); From 8d457113957da422b5cc88e5149bc0936bc8cf1f Mon Sep 17 00:00:00 2001 From: vilicvane Date: Sat, 5 Sep 2015 06:43:37 +0800 Subject: [PATCH 079/117] Else on the next line --- src/compiler/emitter.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index 8a04be99caa..8fcd13c3ada 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -903,7 +903,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi if (languageVersion < ScriptTarget.ES6 && isBinaryOrOctalIntegerLiteral(node, text)) { return node.text; - } else { + } + else { return text; } } From 3a08af1450fdcefedca850e718deaafffee0b9f9 Mon Sep 17 00:00:00 2001 From: Mohamed Hegazy Date: Fri, 4 Sep 2015 17:45:57 -0700 Subject: [PATCH 080/117] Check for class expressions as well as class declarations --- src/compiler/checker.ts | 18 +++++++++--- .../diagnosticInformationMap.generated.ts | 1 + src/compiler/diagnosticMessages.json | 7 ++++- ...xpressionExtendingAbstractClass.errors.txt | 14 ++++++++++ .../classExpressionExtendingAbstractClass.js | 28 +++++++++++++++++++ .../classExpressionExtendingAbstractClass.ts | 7 +++++ 6 files changed, 70 insertions(+), 5 deletions(-) create mode 100644 tests/baselines/reference/classExpressionExtendingAbstractClass.errors.txt create mode 100644 tests/baselines/reference/classExpressionExtendingAbstractClass.js create mode 100644 tests/cases/compiler/classExpressionExtendingAbstractClass.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index a7e9561c57f..45ea200a091 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -12625,6 +12625,10 @@ namespace ts { return s.flags & SymbolFlags.Instantiated ? getSymbolLinks(s).target : s; } + function getClassLikeDeclarationOfSymbol(symbol: Symbol): Declaration { + return forEach(symbol.declarations, d => isClassLike(d) ? d : undefined); + } + function checkKindsOfPropertyMemberOverrides(type: InterfaceType, baseType: ObjectType): void { // TypeScript 1.0 spec (April 2014): 8.2.3 @@ -12662,14 +12666,20 @@ namespace ts { if (derived === base) { // derived class inherits base without override/redeclaration - let derivedClassDecl = getDeclarationOfKind(type.symbol, SyntaxKind.ClassDeclaration); + let derivedClassDecl = getClassLikeDeclarationOfSymbol(type.symbol); // It is an error to inherit an abstract member without implementing it or being declared abstract. // If there is no declaration for the derived class (as in the case of class expressions), // then the class cannot be declared abstract. - if ( baseDeclarationFlags & NodeFlags.Abstract && (!derivedClassDecl || !(derivedClassDecl.flags & NodeFlags.Abstract))) { - error(derivedClassDecl, Diagnostics.Non_abstract_class_0_does_not_implement_inherited_abstract_member_1_from_class_2, - typeToString(type), symbolToString(baseProperty), typeToString(baseType)); + if (baseDeclarationFlags & NodeFlags.Abstract && (!derivedClassDecl || !(derivedClassDecl.flags & NodeFlags.Abstract))) { + if (derivedClassDecl.kind === SyntaxKind.ClassExpression) { + error(derivedClassDecl, Diagnostics.Non_abstract_class_expression_does_not_implement_inherited_abstract_member_0_from_class_1, + symbolToString(baseProperty), typeToString(baseType)); + } + else { + error(derivedClassDecl, Diagnostics.Non_abstract_class_0_does_not_implement_inherited_abstract_member_1_from_class_2, + typeToString(type), symbolToString(baseProperty), typeToString(baseType)); + } } } else { diff --git a/src/compiler/diagnosticInformationMap.generated.ts b/src/compiler/diagnosticInformationMap.generated.ts index f7351bf6912..e1b1bf3bc9d 100644 --- a/src/compiler/diagnosticInformationMap.generated.ts +++ b/src/compiler/diagnosticInformationMap.generated.ts @@ -427,6 +427,7 @@ namespace ts { Cannot_emit_namespaced_JSX_elements_in_React: { code: 2650, category: DiagnosticCategory.Error, key: "Cannot emit namespaced JSX elements in React" }, A_member_initializer_in_a_enum_declaration_cannot_reference_members_declared_after_it_including_members_defined_in_other_enums: { code: 2651, category: DiagnosticCategory.Error, key: "A member initializer in a enum declaration cannot reference members declared after it, including members defined in other enums." }, Merged_declaration_0_cannot_include_a_default_export_declaration_Consider_adding_a_separate_export_default_0_declaration_instead: { code: 2652, category: DiagnosticCategory.Error, key: "Merged declaration '{0}' cannot include a default export declaration. Consider adding a separate 'export default {0}' declaration instead." }, + Non_abstract_class_expression_does_not_implement_inherited_abstract_member_0_from_class_1: { code: 2653, category: DiagnosticCategory.Error, key: "Non-abstract class expression does not implement inherited abstract member '{0}' from class '{1}'." }, Import_declaration_0_is_using_private_name_1: { code: 4000, category: DiagnosticCategory.Error, key: "Import declaration '{0}' is using private name '{1}'." }, Type_parameter_0_of_exported_class_has_or_is_using_private_name_1: { code: 4002, category: DiagnosticCategory.Error, key: "Type parameter '{0}' of exported class has or is using private name '{1}'." }, Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1: { code: 4004, category: DiagnosticCategory.Error, key: "Type parameter '{0}' of exported interface has or is using private name '{1}'." }, diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index 9fd08ef9bca..f41e24461c4 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -1692,11 +1692,16 @@ "A member initializer in a enum declaration cannot reference members declared after it, including members defined in other enums.": { "category": "Error", "code": 2651 - }, + }, "Merged declaration '{0}' cannot include a default export declaration. Consider adding a separate 'export default {0}' declaration instead.": { "category": "Error", "code": 2652 }, + "Non-abstract class expression does not implement inherited abstract member '{0}' from class '{1}'.": { + "category": "Error", + "code": 2653 + }, + "Import declaration '{0}' is using private name '{1}'.": { "category": "Error", "code": 4000 diff --git a/tests/baselines/reference/classExpressionExtendingAbstractClass.errors.txt b/tests/baselines/reference/classExpressionExtendingAbstractClass.errors.txt new file mode 100644 index 00000000000..b5d709fbf60 --- /dev/null +++ b/tests/baselines/reference/classExpressionExtendingAbstractClass.errors.txt @@ -0,0 +1,14 @@ +tests/cases/compiler/classExpressionExtendingAbstractClass.ts(5,9): error TS2653: Non-abstract class expression does not implement inherited abstract member 'foo' from class 'A'. + + +==== tests/cases/compiler/classExpressionExtendingAbstractClass.ts (1 errors) ==== + abstract class A { + abstract foo(): void; + } + + var C = class extends A { // no error reported! + ~~~~~ +!!! error TS2653: Non-abstract class expression does not implement inherited abstract member 'foo' from class 'A'. + }; + + \ No newline at end of file diff --git a/tests/baselines/reference/classExpressionExtendingAbstractClass.js b/tests/baselines/reference/classExpressionExtendingAbstractClass.js new file mode 100644 index 00000000000..a5149538da2 --- /dev/null +++ b/tests/baselines/reference/classExpressionExtendingAbstractClass.js @@ -0,0 +1,28 @@ +//// [classExpressionExtendingAbstractClass.ts] +abstract class A { + abstract foo(): void; +} + +var C = class extends A { // no error reported! +}; + + + +//// [classExpressionExtendingAbstractClass.js] +var __extends = (this && this.__extends) || function (d, b) { + for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); +}; +var A = (function () { + function A() { + } + return A; +})(); +var C = (function (_super) { + __extends(class_1, _super); + function class_1() { + _super.apply(this, arguments); + } + return class_1; +})(A); diff --git a/tests/cases/compiler/classExpressionExtendingAbstractClass.ts b/tests/cases/compiler/classExpressionExtendingAbstractClass.ts new file mode 100644 index 00000000000..aadec5be7a4 --- /dev/null +++ b/tests/cases/compiler/classExpressionExtendingAbstractClass.ts @@ -0,0 +1,7 @@ +abstract class A { + abstract foo(): void; +} + +var C = class extends A { // no error reported! +}; + From d8c6f7edc32d6eeba06b19cbe2d17f0355fc1a21 Mon Sep 17 00:00:00 2001 From: Mohamed Hegazy Date: Fri, 4 Sep 2015 17:46:26 -0700 Subject: [PATCH 081/117] fix additional places where class expression should be queried --- src/compiler/checker.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 45ea200a091..0c40780d8e4 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -5105,8 +5105,8 @@ namespace ts { function abstractSignatureRelatedTo(source: Type, sourceSig: Signature, target: Type, targetSig: Signature) { if (sourceSig && targetSig) { - let sourceDecl = source.symbol && getDeclarationOfKind(source.symbol, SyntaxKind.ClassDeclaration); - let targetDecl = target.symbol && getDeclarationOfKind(target.symbol, SyntaxKind.ClassDeclaration); + let sourceDecl = source.symbol && getClassLikeDeclarationOfSymbol(source.symbol); + let targetDecl = target.symbol && getClassLikeDeclarationOfSymbol(target.symbol); if (!sourceDecl) { // If the source object isn't itself a class declaration, it can be freely assigned, regardless @@ -5120,8 +5120,8 @@ namespace ts { let sourceReturnType = sourceErasedSignature && getReturnTypeOfSignature(sourceErasedSignature); let targetReturnType = targetErasedSignature && getReturnTypeOfSignature(targetErasedSignature); - let sourceReturnDecl = sourceReturnType && sourceReturnType.symbol && getDeclarationOfKind(sourceReturnType.symbol, SyntaxKind.ClassDeclaration); - let targetReturnDecl = targetReturnType && targetReturnType.symbol && getDeclarationOfKind(targetReturnType.symbol, SyntaxKind.ClassDeclaration); + let sourceReturnDecl = sourceReturnType && sourceReturnType.symbol && getClassLikeDeclarationOfSymbol(sourceReturnType.symbol); + let targetReturnDecl = targetReturnType && targetReturnType.symbol && getClassLikeDeclarationOfSymbol(targetReturnType.symbol); let sourceIsAbstract = sourceReturnDecl && sourceReturnDecl.flags & NodeFlags.Abstract; let targetIsAbstract = targetReturnDecl && targetReturnDecl.flags & NodeFlags.Abstract; @@ -8873,7 +8873,7 @@ namespace ts { // Note, only class declarations can be declared abstract. // In the case of a merged class-module or class-interface declaration, // only the class declaration node will have the Abstract flag set. - let valueDecl = expressionType.symbol && getDeclarationOfKind(expressionType.symbol, SyntaxKind.ClassDeclaration); + let valueDecl = expressionType.symbol && getClassLikeDeclarationOfSymbol(expressionType.symbol); if (valueDecl && valueDecl.flags & NodeFlags.Abstract) { error(node, Diagnostics.Cannot_create_an_instance_of_the_abstract_class_0, declarationNameToString(valueDecl.name)); return resolveErrorCall(node); From bd520e10ca2123a75d55e57ec0952801acd70da0 Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Fri, 4 Sep 2015 18:01:43 -0700 Subject: [PATCH 082/117] Add debug option to runtests Running `runtests` with `debug` will cause mocha to run in debug mode and break on the first line, enabling one to connect a debugger to the running tests and step through a test at their leisure. --- Jakefile.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Jakefile.js b/Jakefile.js index ea13cce6685..3ac2e8fad13 100644 --- a/Jakefile.js +++ b/Jakefile.js @@ -588,9 +588,10 @@ function deleteTemporaryProjectOutput() { } var testTimeout = 20000; -desc("Runs the tests using the built run.js file. Syntax is jake runtests. Optional parameters 'host=', 'tests=[regex], reporter=[list|spec|json|]'."); +desc("Runs the tests using the built run.js file. Syntax is jake runtests. Optional parameters 'host=', 'tests=[regex], reporter=[list|spec|json|]', debug=true."); task("runtests", ["tests", builtLocalDirectory], function() { cleanTestDirs(); + var debug = process.env.debug || process.env.d; host = "mocha" tests = process.env.test || process.env.tests || process.env.t; var light = process.env.light || false; @@ -613,7 +614,7 @@ task("runtests", ["tests", builtLocalDirectory], function() { reporter = process.env.reporter || process.env.r || 'mocha-fivemat-progress-reporter'; // timeout normally isn't necessary but Travis-CI has been timing out on compiler baselines occasionally // default timeout is 2sec which really should be enough, but maybe we just need a small amount longer - var cmd = host + " -R " + reporter + tests + colors + ' -t ' + testTimeout + ' ' + run; + var cmd = host + (debug ? " --debug-brk" : "") + " -R " + reporter + tests + colors + ' -t ' + testTimeout + ' ' + run; console.log(cmd); exec(cmd, deleteTemporaryProjectOutput); }, {async: true}); From 52c99634ffe1cb17a187a340820de158fff19859 Mon Sep 17 00:00:00 2001 From: progre Date: Sat, 5 Sep 2015 11:16:27 +0900 Subject: [PATCH 083/117] #4396 fix error message typo --- src/compiler/diagnosticInformationMap.generated.ts | 2 +- src/compiler/diagnosticMessages.json | 2 +- tests/baselines/reference/indexTypeCheck.errors.txt | 4 ++-- ...bjectCreationOfElementAccessExpression.errors.txt | 8 ++++---- tests/baselines/reference/propertyAccess.errors.txt | 12 ++++++------ .../reference/superSymbolIndexedAccess3.errors.txt | 4 ++-- .../baselines/reference/symbolProperty53.errors.txt | 4 ++-- 7 files changed, 18 insertions(+), 18 deletions(-) diff --git a/src/compiler/diagnosticInformationMap.generated.ts b/src/compiler/diagnosticInformationMap.generated.ts index f7351bf6912..7935540356e 100644 --- a/src/compiler/diagnosticInformationMap.generated.ts +++ b/src/compiler/diagnosticInformationMap.generated.ts @@ -244,7 +244,7 @@ namespace ts { Property_0_does_not_exist_on_type_1: { code: 2339, category: DiagnosticCategory.Error, key: "Property '{0}' does not exist on type '{1}'." }, Only_public_and_protected_methods_of_the_base_class_are_accessible_via_the_super_keyword: { code: 2340, category: DiagnosticCategory.Error, key: "Only public and protected methods of the base class are accessible via the 'super' keyword." }, Property_0_is_private_and_only_accessible_within_class_1: { code: 2341, category: DiagnosticCategory.Error, key: "Property '{0}' is private and only accessible within class '{1}'." }, - An_index_expression_argument_must_be_of_type_string_number_symbol_or_any: { code: 2342, category: DiagnosticCategory.Error, key: "An index expression argument must be of type 'string', 'number', 'symbol, or 'any'." }, + An_index_expression_argument_must_be_of_type_string_number_symbol_or_any: { code: 2342, category: DiagnosticCategory.Error, key: "An index expression argument must be of type 'string', 'number', 'symbol', or 'any'." }, Type_0_does_not_satisfy_the_constraint_1: { code: 2344, category: DiagnosticCategory.Error, key: "Type '{0}' does not satisfy the constraint '{1}'." }, Argument_of_type_0_is_not_assignable_to_parameter_of_type_1: { code: 2345, category: DiagnosticCategory.Error, key: "Argument of type '{0}' is not assignable to parameter of type '{1}'." }, Supplied_parameters_do_not_match_any_signature_of_call_target: { code: 2346, category: DiagnosticCategory.Error, key: "Supplied parameters do not match any signature of call target." }, diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index 9fd08ef9bca..0b4c0fdf974 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -965,7 +965,7 @@ "category": "Error", "code": 2341 }, - "An index expression argument must be of type 'string', 'number', 'symbol, or 'any'.": { + "An index expression argument must be of type 'string', 'number', 'symbol', or 'any'.": { "category": "Error", "code": 2342 }, diff --git a/tests/baselines/reference/indexTypeCheck.errors.txt b/tests/baselines/reference/indexTypeCheck.errors.txt index 9e003197e41..2ea5a2f413a 100644 --- a/tests/baselines/reference/indexTypeCheck.errors.txt +++ b/tests/baselines/reference/indexTypeCheck.errors.txt @@ -4,7 +4,7 @@ tests/cases/compiler/indexTypeCheck.ts(17,2): error TS2413: Numeric index type ' tests/cases/compiler/indexTypeCheck.ts(27,2): error TS2413: Numeric index type 'number' is not assignable to string index type 'string'. tests/cases/compiler/indexTypeCheck.ts(32,3): error TS1096: An index signature must have exactly one parameter. tests/cases/compiler/indexTypeCheck.ts(36,3): error TS1023: An index signature parameter type must be 'string' or 'number'. -tests/cases/compiler/indexTypeCheck.ts(51,1): error TS2342: An index expression argument must be of type 'string', 'number', 'symbol, or 'any'. +tests/cases/compiler/indexTypeCheck.ts(51,1): error TS2342: An index expression argument must be of type 'string', 'number', 'symbol', or 'any'. ==== tests/cases/compiler/indexTypeCheck.ts (7 errors) ==== @@ -72,7 +72,7 @@ tests/cases/compiler/indexTypeCheck.ts(51,1): error TS2342: An index expression yellow[blue]; // error ~~~~~~~~~~~~ -!!! error TS2342: An index expression argument must be of type 'string', 'number', 'symbol, or 'any'. +!!! error TS2342: An index expression argument must be of type 'string', 'number', 'symbol', or 'any'. var x:number[]; x[0]; diff --git a/tests/baselines/reference/objectCreationOfElementAccessExpression.errors.txt b/tests/baselines/reference/objectCreationOfElementAccessExpression.errors.txt index b2f3bd9d824..ef50db9e4e5 100644 --- a/tests/baselines/reference/objectCreationOfElementAccessExpression.errors.txt +++ b/tests/baselines/reference/objectCreationOfElementAccessExpression.errors.txt @@ -1,6 +1,6 @@ -tests/cases/compiler/objectCreationOfElementAccessExpression.ts(53,17): error TS2342: An index expression argument must be of type 'string', 'number', 'symbol, or 'any'. +tests/cases/compiler/objectCreationOfElementAccessExpression.ts(53,17): error TS2342: An index expression argument must be of type 'string', 'number', 'symbol', or 'any'. tests/cases/compiler/objectCreationOfElementAccessExpression.ts(53,63): error TS2348: Value of type 'typeof Cookie' is not callable. Did you mean to include 'new'? -tests/cases/compiler/objectCreationOfElementAccessExpression.ts(54,33): error TS2342: An index expression argument must be of type 'string', 'number', 'symbol, or 'any'. +tests/cases/compiler/objectCreationOfElementAccessExpression.ts(54,33): error TS2342: An index expression argument must be of type 'string', 'number', 'symbol', or 'any'. tests/cases/compiler/objectCreationOfElementAccessExpression.ts(54,79): error TS2348: Value of type 'typeof Cookie' is not callable. Did you mean to include 'new'? @@ -59,12 +59,12 @@ tests/cases/compiler/objectCreationOfElementAccessExpression.ts(54,79): error TS // ElementAccessExpressions can only contain one expression. There should be a parse error here. var foods = new PetFood[new IceCream('Mint chocolate chip') , Cookie('Chocolate chip', false) , new Cookie('Peanut butter', true)]; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2342: An index expression argument must be of type 'string', 'number', 'symbol, or 'any'. +!!! error TS2342: An index expression argument must be of type 'string', 'number', 'symbol', or 'any'. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS2348: Value of type 'typeof Cookie' is not callable. Did you mean to include 'new'? var foods2: MonsterFood[] = new PetFood[new IceCream('Mint chocolate chip') , Cookie('Chocolate chip', false) , new Cookie('Peanut butter', true)]; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2342: An index expression argument must be of type 'string', 'number', 'symbol, or 'any'. +!!! error TS2342: An index expression argument must be of type 'string', 'number', 'symbol', or 'any'. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS2348: Value of type 'typeof Cookie' is not callable. Did you mean to include 'new'? \ No newline at end of file diff --git a/tests/baselines/reference/propertyAccess.errors.txt b/tests/baselines/reference/propertyAccess.errors.txt index d9cd90a48fc..7d496f87751 100644 --- a/tests/baselines/reference/propertyAccess.errors.txt +++ b/tests/baselines/reference/propertyAccess.errors.txt @@ -1,7 +1,7 @@ tests/cases/conformance/expressions/propertyAccess/propertyAccess.ts(45,14): error TS2339: Property 'qqq' does not exist on type '{ 10: string; x: string; y: number; z: { n: string; m: number; o: () => boolean; }; 'literal property': number; }'. -tests/cases/conformance/expressions/propertyAccess/propertyAccess.ts(80,10): error TS2342: An index expression argument must be of type 'string', 'number', 'symbol, or 'any'. -tests/cases/conformance/expressions/propertyAccess/propertyAccess.ts(117,10): error TS2342: An index expression argument must be of type 'string', 'number', 'symbol, or 'any'. -tests/cases/conformance/expressions/propertyAccess/propertyAccess.ts(140,12): error TS2342: An index expression argument must be of type 'string', 'number', 'symbol, or 'any'. +tests/cases/conformance/expressions/propertyAccess/propertyAccess.ts(80,10): error TS2342: An index expression argument must be of type 'string', 'number', 'symbol', or 'any'. +tests/cases/conformance/expressions/propertyAccess/propertyAccess.ts(117,10): error TS2342: An index expression argument must be of type 'string', 'number', 'symbol', or 'any'. +tests/cases/conformance/expressions/propertyAccess/propertyAccess.ts(140,12): error TS2342: An index expression argument must be of type 'string', 'number', 'symbol', or 'any'. ==== tests/cases/conformance/expressions/propertyAccess/propertyAccess.ts (4 errors) ==== @@ -88,7 +88,7 @@ tests/cases/conformance/expressions/propertyAccess/propertyAccess.ts(140,12): er // Bracket notation property access using value of other type on type with numeric index signature and no string index signature var ll = numIndex[someObject]; // Error ~~~~~~~~~~~~~~~~~~~~ -!!! error TS2342: An index expression argument must be of type 'string', 'number', 'symbol, or 'any'. +!!! error TS2342: An index expression argument must be of type 'string', 'number', 'symbol', or 'any'. // Bracket notation property access using string value on type with string index signature and no numeric index signature var mm = strIndex['N']; @@ -127,7 +127,7 @@ tests/cases/conformance/expressions/propertyAccess/propertyAccess.ts(140,12): er // Bracket notation property access using values of other types on type with no index signatures var uu = noIndex[someObject]; // Error ~~~~~~~~~~~~~~~~~~~ -!!! error TS2342: An index expression argument must be of type 'string', 'number', 'symbol, or 'any'. +!!! error TS2342: An index expression argument must be of type 'string', 'number', 'symbol', or 'any'. // Bracket notation property access using numeric value on type with numeric index signature and string index signature var vv = noIndex[32]; @@ -152,7 +152,7 @@ tests/cases/conformance/expressions/propertyAccess/propertyAccess.ts(140,12): er // Bracket notation property access using value of other type on type with numeric index signature and no string index signature and string index signature var zzzz = bothIndex[someObject]; // Error ~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2342: An index expression argument must be of type 'string', 'number', 'symbol, or 'any'. +!!! error TS2342: An index expression argument must be of type 'string', 'number', 'symbol', or 'any'. var x1 = numIndex[stringOrNumber]; var x1: any; diff --git a/tests/baselines/reference/superSymbolIndexedAccess3.errors.txt b/tests/baselines/reference/superSymbolIndexedAccess3.errors.txt index 7f25510e00b..1cac31dec40 100644 --- a/tests/baselines/reference/superSymbolIndexedAccess3.errors.txt +++ b/tests/baselines/reference/superSymbolIndexedAccess3.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/expressions/superPropertyAccess/superSymbolIndexedAccess3.ts(11,16): error TS2342: An index expression argument must be of type 'string', 'number', 'symbol, or 'any'. +tests/cases/conformance/expressions/superPropertyAccess/superSymbolIndexedAccess3.ts(11,16): error TS2342: An index expression argument must be of type 'string', 'number', 'symbol', or 'any'. ==== tests/cases/conformance/expressions/superPropertyAccess/superSymbolIndexedAccess3.ts (1 errors) ==== @@ -14,6 +14,6 @@ tests/cases/conformance/expressions/superPropertyAccess/superSymbolIndexedAccess [symbol]() { return super[Bar](); ~~~~~~~~~~ -!!! error TS2342: An index expression argument must be of type 'string', 'number', 'symbol, or 'any'. +!!! error TS2342: An index expression argument must be of type 'string', 'number', 'symbol', or 'any'. } } \ No newline at end of file diff --git a/tests/baselines/reference/symbolProperty53.errors.txt b/tests/baselines/reference/symbolProperty53.errors.txt index 7658744eb55..03002cd92b2 100644 --- a/tests/baselines/reference/symbolProperty53.errors.txt +++ b/tests/baselines/reference/symbolProperty53.errors.txt @@ -1,5 +1,5 @@ tests/cases/conformance/es6/Symbols/symbolProperty53.ts(2,5): error TS2464: A computed property name must be of type 'string', 'number', 'symbol', or 'any'. -tests/cases/conformance/es6/Symbols/symbolProperty53.ts(5,1): error TS2342: An index expression argument must be of type 'string', 'number', 'symbol, or 'any'. +tests/cases/conformance/es6/Symbols/symbolProperty53.ts(5,1): error TS2342: An index expression argument must be of type 'string', 'number', 'symbol', or 'any'. ==== tests/cases/conformance/es6/Symbols/symbolProperty53.ts (2 errors) ==== @@ -11,4 +11,4 @@ tests/cases/conformance/es6/Symbols/symbolProperty53.ts(5,1): error TS2342: An i obj[Symbol.for]; ~~~~~~~~~~~~~~~ -!!! error TS2342: An index expression argument must be of type 'string', 'number', 'symbol, or 'any'. \ No newline at end of file +!!! error TS2342: An index expression argument must be of type 'string', 'number', 'symbol', or 'any'. \ No newline at end of file From dc8ad6eb5e34980fca18de037d65f2f1924e444e Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Sat, 5 Sep 2015 13:17:33 -0700 Subject: [PATCH 084/117] Store binding pattern in contextual type --- src/compiler/checker.ts | 86 ++++++++++++++++++++++------------------- src/compiler/types.ts | 10 +++-- 2 files changed, 52 insertions(+), 44 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index d4e68381f7b..e08d30ca9b9 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -2406,7 +2406,7 @@ namespace ts { // If the declaration specifies a binding pattern, use the type implied by the binding pattern if (isBindingPattern(declaration.name)) { - return getTypeFromBindingPattern(declaration.name); + return getTypeFromBindingPattern(declaration.name, /*includePatternInType*/ false); } // No type specified and nothing can be inferred @@ -2421,13 +2421,13 @@ namespace ts { return getWidenedType(checkExpressionCached(element.initializer)); } if (isBindingPattern(element.name)) { - return getTypeFromBindingPattern(element.name); + return getTypeFromBindingPattern(element.name, /*includePatternInType*/ false); } return anyType; } // Return the type implied by an object binding pattern - function getTypeFromObjectBindingPattern(pattern: BindingPattern): Type { + function getTypeFromObjectBindingPattern(pattern: BindingPattern, includePatternInType: boolean): Type { let members: SymbolTable = {}; forEach(pattern.elements, e => { let flags = SymbolFlags.Property | SymbolFlags.Transient | (e.initializer ? SymbolFlags.Optional : 0); @@ -2436,28 +2436,27 @@ namespace ts { symbol.type = getTypeFromBindingElement(e); members[symbol.name] = symbol; }); - return createAnonymousType(undefined, members, emptyArray, emptyArray, undefined, undefined); + let result = createAnonymousType(undefined, members, emptyArray, emptyArray, undefined, undefined); + if (includePatternInType) { + result.pattern = pattern; + } + return result; } // Return the type implied by an array binding pattern - function getTypeFromArrayBindingPattern(pattern: BindingPattern): Type { - let hasSpreadElement: boolean = false; - let elementTypes: Type[] = []; - forEach(pattern.elements, e => { - elementTypes.push(e.kind === SyntaxKind.OmittedExpression || e.dotDotDotToken ? anyType : getTypeFromBindingElement(e)); - if (e.dotDotDotToken) { - hasSpreadElement = true; - } - }); - if (!elementTypes.length) { + function getTypeFromArrayBindingPattern(pattern: BindingPattern, includePatternInType: boolean): Type { + let elements = pattern.elements; + if (elements.length === 0 || elements[elements.length - 1].dotDotDotToken) { return languageVersion >= ScriptTarget.ES6 ? createIterableType(anyType) : anyArrayType; } - else if (hasSpreadElement) { - let unionOfElements = getUnionType(elementTypes); - return languageVersion >= ScriptTarget.ES6 ? createIterableType(unionOfElements) : createArrayType(unionOfElements); - } // If the pattern has at least one element, and no rest element, then it should imply a tuple type. - return createTupleType(elementTypes); + let elementTypes = map(elements, e => e.kind === SyntaxKind.OmittedExpression ? anyType : getTypeFromBindingElement(e)); + let result = createTupleType(elementTypes); + if (includePatternInType) { + result = clone(result); + result.pattern = pattern; + } + return result; } // Return the type implied by a binding pattern. This is the type implied purely by the binding pattern itself @@ -2467,10 +2466,10 @@ namespace ts { // used as the contextual type of an initializer associated with the binding pattern. Also, for a destructuring // parameter with no type annotation or initializer, the type implied by the binding pattern becomes the type of // the parameter. - function getTypeFromBindingPattern(pattern: BindingPattern): Type { + function getTypeFromBindingPattern(pattern: BindingPattern, includePatternInType?: boolean): Type { return pattern.kind === SyntaxKind.ObjectBindingPattern - ? getTypeFromObjectBindingPattern(pattern) - : getTypeFromArrayBindingPattern(pattern); + ? getTypeFromObjectBindingPattern(pattern, includePatternInType) + : getTypeFromArrayBindingPattern(pattern, includePatternInType); } // Return the type associated with a variable, parameter, or property declaration. In the simple case this is the type @@ -6606,18 +6605,12 @@ namespace ts { } } if (isBindingPattern(declaration.name)) { - return createImpliedType(getTypeFromBindingPattern(declaration.name)); + return getTypeFromBindingPattern(declaration.name, /*includePatternInType*/ true); } } return undefined; } - function createImpliedType(type: Type): Type { - var result = clone(type); - result.flags |= TypeFlags.ImpliedType; - return result; - } - function getContextualTypeForReturnExpression(node: Expression): Type { let func = getContainingFunction(node); if (func && !func.asteriskToken) { @@ -7044,17 +7037,28 @@ namespace ts { // If array literal is actually a destructuring pattern, mark it as an implied type. We do this such // that we get the same behavior for "var [x, y] = []" and "[x, y] = []". if (inDestructuringPattern && elementTypes.length) { - return createImpliedType(createTupleType(elementTypes)); + let type = clone(createTupleType(elementTypes)); + type.pattern = node; + return type; } let contextualType = getContextualType(node); - let contextualTupleLikeType = contextualType && contextualTypeIsTupleLikeType(contextualType) ? contextualType : undefined; - if (contextualTupleLikeType) { - // If array literal is contextually typed by the implied type of a binding pattern, pad the resulting - // tuple type with elements from the binding tuple type to make the lengths equal. - if (contextualTupleLikeType.flags & TypeFlags.Tuple && contextualTupleLikeType.flags & TypeFlags.ImpliedType) { - let contextualElementTypes = (contextualTupleLikeType).elementTypes; - for (let i = elementTypes.length; i < contextualElementTypes.length; i++) { - elementTypes.push(contextualElementTypes[i]); + if (contextualType && contextualTypeIsTupleLikeType(contextualType)) { + let pattern = contextualType.pattern; + // If array literal is contextually typed by a binding pattern or an assignment pattern, + // pad the resulting tuple type to make the lengths equal. + if (pattern && pattern.kind === SyntaxKind.ArrayBindingPattern) { + let bindingElements = (pattern).elements; + for (let i = elementTypes.length; i < bindingElements.length; i++) { + let hasDefaultValue = bindingElements[i].initializer; + elementTypes.push(hasDefaultValue ? (contextualType).elementTypes[i] : undefinedType); + } + } + else if (pattern && pattern.kind === SyntaxKind.ArrayLiteralExpression) { + let assignmentElements = (pattern).elements; + for (let i = elementTypes.length; i < assignmentElements.length; i++) { + let hasDefaultValue = assignmentElements[i].kind === SyntaxKind.BinaryExpression && + (assignmentElements[i]).operatorToken.kind === SyntaxKind.EqualsToken; + elementTypes.push(hasDefaultValue ? (contextualType).elementTypes[i] : undefinedType); } } if (elementTypes.length) { @@ -7129,6 +7133,8 @@ namespace ts { let propertiesTable: SymbolTable = {}; let propertiesArray: Symbol[] = []; let contextualType = getContextualType(node); + let contextualTypeHasPattern = contextualType && contextualType.pattern && + contextualType.pattern.kind === SyntaxKind.ObjectBindingPattern; let typeFlags: TypeFlags = 0; for (let memberDecl of node.properties) { @@ -7151,7 +7157,7 @@ namespace ts { let prop = createSymbol(SymbolFlags.Property | SymbolFlags.Transient | member.flags, member.name); // If object literal is contextually typed by the implied type of a binding pattern, and if the // binding pattern specifies a default value for the property, make the property optional. - if (contextualType && contextualType.flags & TypeFlags.ImpliedType) { + if (contextualTypeHasPattern) { let impliedProp = getPropertyOfType(contextualType, member.name); if (impliedProp) { prop.flags |= impliedProp.flags & SymbolFlags.Optional; @@ -7185,7 +7191,7 @@ namespace ts { // If object literal is contextually typed by the implied type of a binding pattern, augment the result // type with those properties for which the binding pattern specifies a default value. - if (contextualType && contextualType.flags & TypeFlags.ImpliedType) { + if (contextualTypeHasPattern) { for (let prop of getPropertiesOfType(contextualType)) { if (prop.flags & SymbolFlags.Optional && !hasProperty(propertiesTable, prop.name)) { propertiesTable[prop.name] = prop; diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 1313fb5b031..d23a42e753a 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -1795,7 +1795,6 @@ namespace ts { /* @internal */ ContainsAnyFunctionType = 0x00800000, // Type is or contains object literal type ESSymbol = 0x01000000, // Type of symbol primitive introduced in ES6 - ImpliedType = 0x02000000, // Type implied by object binding pattern /* @internal */ Intrinsic = Any | String | Number | Boolean | ESSymbol | Void | Undefined | Null, @@ -1812,11 +1811,14 @@ namespace ts { PropagatingFlags = ContainsUndefinedOrNull | ContainsObjectLiteral | ContainsAnyFunctionType } + export type DestructuringPattern = BindingPattern | ObjectLiteralExpression | ArrayLiteralExpression; + // Properties common to all types export interface Type { - flags: TypeFlags; // Flags - /* @internal */ id: number; // Unique ID - symbol?: Symbol; // Symbol associated with type (if any) + flags: TypeFlags; // Flags + /* @internal */ id: number; // Unique ID + symbol?: Symbol; // Symbol associated with type (if any) + pattern?: DestructuringPattern; // Destructuring pattern represented by type (if any) } /* @internal */ From e40b86f1958be0e70ddc769bbf3e1e0c822a3b51 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Sat, 5 Sep 2015 13:19:06 -0700 Subject: [PATCH 085/117] Accepting new baselines --- .../declarationEmitDestructuringArrayPattern2.types | 2 +- ...estructuringArrayBindingPatternAndAssignment1ES5.types | 2 +- ...estructuringArrayBindingPatternAndAssignment1ES6.types | 2 +- ...tructuringArrayBindingPatternAndAssignment2.errors.txt | 8 +++++++- .../reference/destructuringWithLiteralInitializers.types | 2 +- tests/baselines/reference/downlevelLetConst12.types | 4 ++-- 6 files changed, 13 insertions(+), 7 deletions(-) diff --git a/tests/baselines/reference/declarationEmitDestructuringArrayPattern2.types b/tests/baselines/reference/declarationEmitDestructuringArrayPattern2.types index 5820449cde9..57acfe1dde1 100644 --- a/tests/baselines/reference/declarationEmitDestructuringArrayPattern2.types +++ b/tests/baselines/reference/declarationEmitDestructuringArrayPattern2.types @@ -23,7 +23,7 @@ var [a11, b11, c11] = []; >a11 : any >b11 : any >c11 : any ->[] : [any, any, any] +>[] : [undefined, undefined, undefined] var [a2, [b2, { x12, y12: c2 }]=["abc", { x12: 10, y12: false }]] = [1, ["hello", { x12: 5, y12: true }]]; >a2 : number diff --git a/tests/baselines/reference/destructuringArrayBindingPatternAndAssignment1ES5.types b/tests/baselines/reference/destructuringArrayBindingPatternAndAssignment1ES5.types index 9325fbf6b2d..3af7b65c625 100644 --- a/tests/baselines/reference/destructuringArrayBindingPatternAndAssignment1ES5.types +++ b/tests/baselines/reference/destructuringArrayBindingPatternAndAssignment1ES5.types @@ -93,7 +93,7 @@ var [c0, c1] = [...temp]; var [c2] = []; >c2 : any ->[] : [any] +>[] : [undefined] var [[[c3]], [[[[c4]]]]] = [[[]], [[[[]]]]] >c3 : any diff --git a/tests/baselines/reference/destructuringArrayBindingPatternAndAssignment1ES6.types b/tests/baselines/reference/destructuringArrayBindingPatternAndAssignment1ES6.types index aaa56cde3bc..cded5cdec8e 100644 --- a/tests/baselines/reference/destructuringArrayBindingPatternAndAssignment1ES6.types +++ b/tests/baselines/reference/destructuringArrayBindingPatternAndAssignment1ES6.types @@ -94,7 +94,7 @@ var [c0, c1] = [...temp]; var [c2] = []; >c2 : any ->[] : [any] +>[] : [undefined] var [[[c3]], [[[[c4]]]]] = [[[]], [[[[]]]]] >c3 : any diff --git a/tests/baselines/reference/destructuringArrayBindingPatternAndAssignment2.errors.txt b/tests/baselines/reference/destructuringArrayBindingPatternAndAssignment2.errors.txt index 5244dd55ec6..a2e5cb7e17c 100644 --- a/tests/baselines/reference/destructuringArrayBindingPatternAndAssignment2.errors.txt +++ b/tests/baselines/reference/destructuringArrayBindingPatternAndAssignment2.errors.txt @@ -1,3 +1,5 @@ +tests/cases/conformance/es6/destructuring/destructuringArrayBindingPatternAndAssignment2.ts(3,6): error TS2461: Type 'undefined' is not an array type. +tests/cases/conformance/es6/destructuring/destructuringArrayBindingPatternAndAssignment2.ts(3,12): error TS2461: Type 'undefined' is not an array type. tests/cases/conformance/es6/destructuring/destructuringArrayBindingPatternAndAssignment2.ts(4,5): error TS2461: Type 'undefined' is not an array type. tests/cases/conformance/es6/destructuring/destructuringArrayBindingPatternAndAssignment2.ts(9,5): error TS2322: Type '[number, number, string]' is not assignable to type '[number, boolean, string]'. Types of property '1' are incompatible. @@ -11,10 +13,14 @@ tests/cases/conformance/es6/destructuring/destructuringArrayBindingPatternAndAss tests/cases/conformance/es6/destructuring/destructuringArrayBindingPatternAndAssignment2.ts(34,5): error TS2461: Type 'F' is not an array type. -==== tests/cases/conformance/es6/destructuring/destructuringArrayBindingPatternAndAssignment2.ts (6 errors) ==== +==== tests/cases/conformance/es6/destructuring/destructuringArrayBindingPatternAndAssignment2.ts (8 errors) ==== // V is an array assignment pattern, S is the type Any or an array-like type (section 3.3.2), and, for each assignment element E in V, // S is the type Any, or var [[a0], [[a1]]] = [] // Error + ~~~~ +!!! error TS2461: Type 'undefined' is not an array type. + ~~~~~~ +!!! error TS2461: Type 'undefined' is not an array type. var [[a2], [[a3]]] = undefined // Error ~~~~~~~~~~~~~~ !!! error TS2461: Type 'undefined' is not an array type. diff --git a/tests/baselines/reference/destructuringWithLiteralInitializers.types b/tests/baselines/reference/destructuringWithLiteralInitializers.types index c0577cb9950..cbb1e343bf4 100644 --- a/tests/baselines/reference/destructuringWithLiteralInitializers.types +++ b/tests/baselines/reference/destructuringWithLiteralInitializers.types @@ -200,7 +200,7 @@ function g3([x, y] = []) { } >g3 : ([x, y]?: [any, any]) => void >x : any >y : any ->[] : [any, any] +>[] : [undefined, undefined] g3(); >g3() : void diff --git a/tests/baselines/reference/downlevelLetConst12.types b/tests/baselines/reference/downlevelLetConst12.types index 85002abbe5e..a6146b55dd7 100644 --- a/tests/baselines/reference/downlevelLetConst12.types +++ b/tests/baselines/reference/downlevelLetConst12.types @@ -13,7 +13,7 @@ const bar = 1; let [baz] = []; >baz : any ->[] : [any] +>[] : [undefined] let {a: baz2} = { a: 1 }; >a : any @@ -24,7 +24,7 @@ let {a: baz2} = { a: 1 }; const [baz3] = [] >baz3 : any ->[] : [any] +>[] : [undefined] const {a: baz4} = { a: 1 }; >a : any From bb8179766a46a12bba508f6603eb1c1c1b0320d0 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Sat, 5 Sep 2015 15:42:58 -0700 Subject: [PATCH 086/117] Check for excess properties --- src/compiler/checker.ts | 49 +++++++++++++++++++++++++---------------- 1 file changed, 30 insertions(+), 19 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index e08d30ca9b9..6f617d69798 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -7001,6 +7001,11 @@ namespace ts { return checkIteratedTypeOrElementType(arrayOrIterableType, node.expression, /*allowStringInput*/ false); } + function hasDefaultValue(node: BindingElement | Expression): boolean { + return (node.kind === SyntaxKind.BindingElement && !!(node).initializer) || + (node.kind === SyntaxKind.BinaryExpression && (node).operatorToken.kind === SyntaxKind.EqualsToken); + } + function checkArrayLiteral(node: ArrayLiteralExpression, contextualMapper?: TypeMapper): Type { let elements = node.elements; let hasSpreadElement = false; @@ -7044,21 +7049,12 @@ namespace ts { let contextualType = getContextualType(node); if (contextualType && contextualTypeIsTupleLikeType(contextualType)) { let pattern = contextualType.pattern; - // If array literal is contextually typed by a binding pattern or an assignment pattern, - // pad the resulting tuple type to make the lengths equal. - if (pattern && pattern.kind === SyntaxKind.ArrayBindingPattern) { - let bindingElements = (pattern).elements; - for (let i = elementTypes.length; i < bindingElements.length; i++) { - let hasDefaultValue = bindingElements[i].initializer; - elementTypes.push(hasDefaultValue ? (contextualType).elementTypes[i] : undefinedType); - } - } - else if (pattern && pattern.kind === SyntaxKind.ArrayLiteralExpression) { - let assignmentElements = (pattern).elements; - for (let i = elementTypes.length; i < assignmentElements.length; i++) { - let hasDefaultValue = assignmentElements[i].kind === SyntaxKind.BinaryExpression && - (assignmentElements[i]).operatorToken.kind === SyntaxKind.EqualsToken; - elementTypes.push(hasDefaultValue ? (contextualType).elementTypes[i] : undefinedType); + // If array literal is contextually typed by a binding pattern or an assignment pattern, pad the + // resulting tuple type to make the lengths equal. + if (pattern && (pattern.kind === SyntaxKind.ArrayBindingPattern || pattern.kind === SyntaxKind.ArrayLiteralExpression)) { + let patternElements = (pattern).elements; + for (let i = elementTypes.length; i < patternElements.length; i++) { + elementTypes.push(hasDefaultValue(patternElements[i]) ? (contextualType).elementTypes[i] : undefinedType); } } if (elementTypes.length) { @@ -7134,7 +7130,8 @@ namespace ts { let propertiesArray: Symbol[] = []; let contextualType = getContextualType(node); let contextualTypeHasPattern = contextualType && contextualType.pattern && - contextualType.pattern.kind === SyntaxKind.ObjectBindingPattern; + (contextualType.pattern.kind === SyntaxKind.ObjectBindingPattern || contextualType.pattern.kind === SyntaxKind.ObjectLiteralExpression); + let inDestructuringPattern = isAssignmentTarget(node); let typeFlags: TypeFlags = 0; for (let memberDecl of node.properties) { @@ -7155,13 +7152,24 @@ namespace ts { } typeFlags |= type.flags; let prop = createSymbol(SymbolFlags.Property | SymbolFlags.Transient | member.flags, member.name); - // If object literal is contextually typed by the implied type of a binding pattern, and if the - // binding pattern specifies a default value for the property, make the property optional. - if (contextualTypeHasPattern) { + if (inDestructuringPattern) { + // If object literal is an assignment pattern and if the assignment pattern specifies a default value + // for the property, make the property optional. + if (memberDecl.kind === SyntaxKind.PropertyAssignment && hasDefaultValue((memberDecl).initializer)) { + prop.flags |= SymbolFlags.Optional; + } + } + else if (contextualTypeHasPattern) { + // If object literal is contextually typed by the implied type of a binding pattern, and if the + // binding pattern specifies a default value for the property, make the property optional. let impliedProp = getPropertyOfType(contextualType, member.name); if (impliedProp) { prop.flags |= impliedProp.flags & SymbolFlags.Optional; } + else if (!compilerOptions.suppressExcessPropertyErrors) { + error(memberDecl.name, Diagnostics.Object_literal_may_only_specify_known_properties_and_0_does_not_exist_in_type_1, + symbolToString(member), typeToString(contextualType)); + } } prop.declarations = member.declarations; prop.parent = member.parent; @@ -7205,6 +7213,9 @@ namespace ts { let result = createAnonymousType(node.symbol, propertiesTable, emptyArray, emptyArray, stringIndexType, numberIndexType); let freshObjectLiteralFlag = compilerOptions.suppressExcessPropertyErrors ? 0 : TypeFlags.FreshObjectLiteral; result.flags |= TypeFlags.ObjectLiteral | TypeFlags.ContainsObjectLiteral | freshObjectLiteralFlag | (typeFlags & TypeFlags.PropagatingFlags); + if (inDestructuringPattern) { + result.pattern = node; + } return result; function getIndexType(kind: IndexKind) { From a0ddd437efa1b4fb52b418192176727069debec6 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Sat, 5 Sep 2015 15:45:20 -0700 Subject: [PATCH 087/117] Modifying tests --- .../destructuring/declarationsAndAssignments.ts | 14 +++++++------- .../destructuringWithLiteralInitializers.ts | 1 + 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/tests/cases/conformance/es6/destructuring/declarationsAndAssignments.ts b/tests/cases/conformance/es6/destructuring/declarationsAndAssignments.ts index 2202a482f8b..69b7462cd03 100644 --- a/tests/cases/conformance/es6/destructuring/declarationsAndAssignments.ts +++ b/tests/cases/conformance/es6/destructuring/declarationsAndAssignments.ts @@ -2,8 +2,8 @@ function f0() { var [] = [1, "hello"]; var [x] = [1, "hello"]; var [x, y] = [1, "hello"]; - var [x, y, z] = [1, "hello"]; // Error - var [,, z] = [0, 1, 2]; + var [x, y, z] = [1, "hello"]; + var [,, x] = [0, 1, 2]; var x: number; var y: string; } @@ -19,14 +19,14 @@ function f1() { } function f2() { - var { } = { x: 5, y: "hello" }; - var { x } = { x: 5, y: "hello" }; - var { y } = { x: 5, y: "hello" }; + var { } = { x: 5, y: "hello" }; // Error, no x and y in target + var { x } = { x: 5, y: "hello" }; // Error, no y in target + var { y } = { x: 5, y: "hello" }; // Error, no x in target var { x, y } = { x: 5, y: "hello" }; var x: number; var y: string; - var { x: a } = { x: 5, y: "hello" }; - var { y: b } = { x: 5, y: "hello" }; + var { x: a } = { x: 5, y: "hello" }; // Error, no y in target + var { y: b } = { x: 5, y: "hello" }; // Error, no x in target var { x: a, y: b } = { x: 5, y: "hello" }; var a: number; var b: string; diff --git a/tests/cases/conformance/es6/destructuring/destructuringWithLiteralInitializers.ts b/tests/cases/conformance/es6/destructuring/destructuringWithLiteralInitializers.ts index 8f6b77d95c9..04298d8cbd7 100644 --- a/tests/cases/conformance/es6/destructuring/destructuringWithLiteralInitializers.ts +++ b/tests/cases/conformance/es6/destructuring/destructuringWithLiteralInitializers.ts @@ -2,6 +2,7 @@ function f1({ x, y }) { } f1({ x: 1, y: 1 }); +// (arg: { x: any, y?: number }) => void function f2({ x, y = 0 }) { } f2({ x: 1 }); f2({ x: 1, y: 1 }); From f80142094614be2483b0d8eff31e5b5843d4edf9 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Sat, 5 Sep 2015 15:46:20 -0700 Subject: [PATCH 088/117] Accepting new baselines --- .../declarationEmitDestructuring4.errors.txt | 17 +++ .../declarationEmitDestructuring4.symbols | 21 --- .../declarationEmitDestructuring4.types | 32 ----- ...structuringObjectLiteralPattern.errors.txt | 43 ++++++ ...tDestructuringObjectLiteralPattern.symbols | 89 ------------ ...mitDestructuringObjectLiteralPattern.types | 122 ---------------- ...tructuringObjectLiteralPattern1.errors.txt | 29 ++++ ...DestructuringObjectLiteralPattern1.symbols | 42 ------ ...itDestructuringObjectLiteralPattern1.types | 63 --------- .../declarationsAndAssignments.errors.txt | 37 +++-- .../reference/declarationsAndAssignments.js | 28 ++-- ...ectBindingPatternAndAssignment3.errors.txt | 14 +- .../destructuringWithLiteralInitializers.js | 2 + ...structuringWithLiteralInitializers.symbols | 131 +++++++++--------- ...destructuringWithLiteralInitializers.types | 1 + ...ObjectBindingPatternParameter04.errors.txt | 17 +++ ...ptyObjectBindingPatternParameter04.symbols | 14 -- ...emptyObjectBindingPatternParameter04.types | 18 --- 18 files changed, 228 insertions(+), 492 deletions(-) create mode 100644 tests/baselines/reference/declarationEmitDestructuring4.errors.txt delete mode 100644 tests/baselines/reference/declarationEmitDestructuring4.symbols delete mode 100644 tests/baselines/reference/declarationEmitDestructuring4.types create mode 100644 tests/baselines/reference/declarationEmitDestructuringObjectLiteralPattern.errors.txt delete mode 100644 tests/baselines/reference/declarationEmitDestructuringObjectLiteralPattern.symbols delete mode 100644 tests/baselines/reference/declarationEmitDestructuringObjectLiteralPattern.types create mode 100644 tests/baselines/reference/declarationEmitDestructuringObjectLiteralPattern1.errors.txt delete mode 100644 tests/baselines/reference/declarationEmitDestructuringObjectLiteralPattern1.symbols delete mode 100644 tests/baselines/reference/declarationEmitDestructuringObjectLiteralPattern1.types create mode 100644 tests/baselines/reference/emptyObjectBindingPatternParameter04.errors.txt delete mode 100644 tests/baselines/reference/emptyObjectBindingPatternParameter04.symbols delete mode 100644 tests/baselines/reference/emptyObjectBindingPatternParameter04.types diff --git a/tests/baselines/reference/declarationEmitDestructuring4.errors.txt b/tests/baselines/reference/declarationEmitDestructuring4.errors.txt new file mode 100644 index 00000000000..2787d5e6674 --- /dev/null +++ b/tests/baselines/reference/declarationEmitDestructuring4.errors.txt @@ -0,0 +1,17 @@ +tests/cases/compiler/declarationEmitDestructuring4.ts(9,22): error TS2353: Object literal may only specify known properties, and 'x' does not exist in type '{}'. + + +==== tests/cases/compiler/declarationEmitDestructuring4.ts (1 errors) ==== + // For an array binding pattern with empty elements, + // we will not make any modification and will emit + // the similar binding pattern users' have written + function baz([]) { } + function baz1([] = [1,2,3]) { } + function baz2([[]] = [[1,2,3]]) { } + + function baz3({}) { } + function baz4({} = { x: 10 }) { } + ~ +!!! error TS2353: Object literal may only specify known properties, and 'x' does not exist in type '{}'. + + \ No newline at end of file diff --git a/tests/baselines/reference/declarationEmitDestructuring4.symbols b/tests/baselines/reference/declarationEmitDestructuring4.symbols deleted file mode 100644 index 9f2eb162b6f..00000000000 --- a/tests/baselines/reference/declarationEmitDestructuring4.symbols +++ /dev/null @@ -1,21 +0,0 @@ -=== tests/cases/compiler/declarationEmitDestructuring4.ts === -// For an array binding pattern with empty elements, -// we will not make any modification and will emit -// the similar binding pattern users' have written -function baz([]) { } ->baz : Symbol(baz, Decl(declarationEmitDestructuring4.ts, 0, 0)) - -function baz1([] = [1,2,3]) { } ->baz1 : Symbol(baz1, Decl(declarationEmitDestructuring4.ts, 3, 20)) - -function baz2([[]] = [[1,2,3]]) { } ->baz2 : Symbol(baz2, Decl(declarationEmitDestructuring4.ts, 4, 31)) - -function baz3({}) { } ->baz3 : Symbol(baz3, Decl(declarationEmitDestructuring4.ts, 5, 35)) - -function baz4({} = { x: 10 }) { } ->baz4 : Symbol(baz4, Decl(declarationEmitDestructuring4.ts, 7, 21)) ->x : Symbol(x, Decl(declarationEmitDestructuring4.ts, 8, 20)) - - diff --git a/tests/baselines/reference/declarationEmitDestructuring4.types b/tests/baselines/reference/declarationEmitDestructuring4.types deleted file mode 100644 index 9621d61e02b..00000000000 --- a/tests/baselines/reference/declarationEmitDestructuring4.types +++ /dev/null @@ -1,32 +0,0 @@ -=== tests/cases/compiler/declarationEmitDestructuring4.ts === -// For an array binding pattern with empty elements, -// we will not make any modification and will emit -// the similar binding pattern users' have written -function baz([]) { } ->baz : ([]: any[]) => void - -function baz1([] = [1,2,3]) { } ->baz1 : ([]?: number[]) => void ->[1,2,3] : number[] ->1 : number ->2 : number ->3 : number - -function baz2([[]] = [[1,2,3]]) { } ->baz2 : ([[]]?: [number[]]) => void ->[[1,2,3]] : [number[]] ->[1,2,3] : number[] ->1 : number ->2 : number ->3 : number - -function baz3({}) { } ->baz3 : ({}: {}) => void - -function baz4({} = { x: 10 }) { } ->baz4 : ({}?: { x: number; }) => void ->{ x: 10 } : { x: number; } ->x : number ->10 : number - - diff --git a/tests/baselines/reference/declarationEmitDestructuringObjectLiteralPattern.errors.txt b/tests/baselines/reference/declarationEmitDestructuringObjectLiteralPattern.errors.txt new file mode 100644 index 00000000000..92a8cba2d40 --- /dev/null +++ b/tests/baselines/reference/declarationEmitDestructuringObjectLiteralPattern.errors.txt @@ -0,0 +1,43 @@ +tests/cases/compiler/declarationEmitDestructuringObjectLiteralPattern.ts(2,13): error TS2353: Object literal may only specify known properties, and 'x' does not exist in type '{}'. +tests/cases/compiler/declarationEmitDestructuringObjectLiteralPattern.ts(2,19): error TS2353: Object literal may only specify known properties, and 'y' does not exist in type '{}'. +tests/cases/compiler/declarationEmitDestructuringObjectLiteralPattern.ts(3,23): error TS2353: Object literal may only specify known properties, and 'y4' does not exist in type '{ x4: any; }'. +tests/cases/compiler/declarationEmitDestructuringObjectLiteralPattern.ts(4,16): error TS2353: Object literal may only specify known properties, and 'x5' does not exist in type '{ y5: any; }'. +tests/cases/compiler/declarationEmitDestructuringObjectLiteralPattern.ts(6,27): error TS2353: Object literal may only specify known properties, and 'y7' does not exist in type '{ x7: any; }'. +tests/cases/compiler/declarationEmitDestructuringObjectLiteralPattern.ts(7,20): error TS2353: Object literal may only specify known properties, and 'x8' does not exist in type '{ y8: any; }'. + + +==== tests/cases/compiler/declarationEmitDestructuringObjectLiteralPattern.ts (6 errors) ==== + + var { } = { x: 5, y: "hello" }; + ~ +!!! error TS2353: Object literal may only specify known properties, and 'x' does not exist in type '{}'. + ~ +!!! error TS2353: Object literal may only specify known properties, and 'y' does not exist in type '{}'. + var { x4 } = { x4: 5, y4: "hello" }; + ~~ +!!! error TS2353: Object literal may only specify known properties, and 'y4' does not exist in type '{ x4: any; }'. + var { y5 } = { x5: 5, y5: "hello" }; + ~~ +!!! error TS2353: Object literal may only specify known properties, and 'x5' does not exist in type '{ y5: any; }'. + var { x6, y6 } = { x6: 5, y6: "hello" }; + var { x7: a1 } = { x7: 5, y7: "hello" }; + ~~ +!!! error TS2353: Object literal may only specify known properties, and 'y7' does not exist in type '{ x7: any; }'. + var { y8: b1 } = { x8: 5, y8: "hello" }; + ~~ +!!! error TS2353: Object literal may only specify known properties, and 'x8' does not exist in type '{ y8: any; }'. + var { x9: a2, y9: b2 } = { x9: 5, y9: "hello" }; + + var { a: x11, b: { a: y11, b: { a: z11 }}} = { a: 1, b: { a: "hello", b: { a: true } } }; + + function f15() { + var a4 = "hello"; + var b4 = 1; + var c4 = true; + return { a4, b4, c4 }; + } + var { a4, b4, c4 } = f15(); + + module m { + export var { a4, b4, c4 } = f15(); + } \ No newline at end of file diff --git a/tests/baselines/reference/declarationEmitDestructuringObjectLiteralPattern.symbols b/tests/baselines/reference/declarationEmitDestructuringObjectLiteralPattern.symbols deleted file mode 100644 index 0a57a93f3d0..00000000000 --- a/tests/baselines/reference/declarationEmitDestructuringObjectLiteralPattern.symbols +++ /dev/null @@ -1,89 +0,0 @@ -=== tests/cases/compiler/declarationEmitDestructuringObjectLiteralPattern.ts === - -var { } = { x: 5, y: "hello" }; ->x : Symbol(x, Decl(declarationEmitDestructuringObjectLiteralPattern.ts, 1, 11)) ->y : Symbol(y, Decl(declarationEmitDestructuringObjectLiteralPattern.ts, 1, 17)) - -var { x4 } = { x4: 5, y4: "hello" }; ->x4 : Symbol(x4, Decl(declarationEmitDestructuringObjectLiteralPattern.ts, 2, 5)) ->x4 : Symbol(x4, Decl(declarationEmitDestructuringObjectLiteralPattern.ts, 2, 14)) ->y4 : Symbol(y4, Decl(declarationEmitDestructuringObjectLiteralPattern.ts, 2, 21)) - -var { y5 } = { x5: 5, y5: "hello" }; ->y5 : Symbol(y5, Decl(declarationEmitDestructuringObjectLiteralPattern.ts, 3, 5)) ->x5 : Symbol(x5, Decl(declarationEmitDestructuringObjectLiteralPattern.ts, 3, 14)) ->y5 : Symbol(y5, Decl(declarationEmitDestructuringObjectLiteralPattern.ts, 3, 21)) - -var { x6, y6 } = { x6: 5, y6: "hello" }; ->x6 : Symbol(x6, Decl(declarationEmitDestructuringObjectLiteralPattern.ts, 4, 5)) ->y6 : Symbol(y6, Decl(declarationEmitDestructuringObjectLiteralPattern.ts, 4, 9)) ->x6 : Symbol(x6, Decl(declarationEmitDestructuringObjectLiteralPattern.ts, 4, 18)) ->y6 : Symbol(y6, Decl(declarationEmitDestructuringObjectLiteralPattern.ts, 4, 25)) - -var { x7: a1 } = { x7: 5, y7: "hello" }; ->x7 : Symbol(x7, Decl(declarationEmitDestructuringObjectLiteralPattern.ts, 5, 18)) ->a1 : Symbol(a1, Decl(declarationEmitDestructuringObjectLiteralPattern.ts, 5, 5)) ->x7 : Symbol(x7, Decl(declarationEmitDestructuringObjectLiteralPattern.ts, 5, 18)) ->y7 : Symbol(y7, Decl(declarationEmitDestructuringObjectLiteralPattern.ts, 5, 25)) - -var { y8: b1 } = { x8: 5, y8: "hello" }; ->y8 : Symbol(y8, Decl(declarationEmitDestructuringObjectLiteralPattern.ts, 6, 25)) ->b1 : Symbol(b1, Decl(declarationEmitDestructuringObjectLiteralPattern.ts, 6, 5)) ->x8 : Symbol(x8, Decl(declarationEmitDestructuringObjectLiteralPattern.ts, 6, 18)) ->y8 : Symbol(y8, Decl(declarationEmitDestructuringObjectLiteralPattern.ts, 6, 25)) - -var { x9: a2, y9: b2 } = { x9: 5, y9: "hello" }; ->x9 : Symbol(x9, Decl(declarationEmitDestructuringObjectLiteralPattern.ts, 7, 26)) ->a2 : Symbol(a2, Decl(declarationEmitDestructuringObjectLiteralPattern.ts, 7, 5)) ->y9 : Symbol(y9, Decl(declarationEmitDestructuringObjectLiteralPattern.ts, 7, 33)) ->b2 : Symbol(b2, Decl(declarationEmitDestructuringObjectLiteralPattern.ts, 7, 13)) ->x9 : Symbol(x9, Decl(declarationEmitDestructuringObjectLiteralPattern.ts, 7, 26)) ->y9 : Symbol(y9, Decl(declarationEmitDestructuringObjectLiteralPattern.ts, 7, 33)) - -var { a: x11, b: { a: y11, b: { a: z11 }}} = { a: 1, b: { a: "hello", b: { a: true } } }; ->a : Symbol(a, Decl(declarationEmitDestructuringObjectLiteralPattern.ts, 9, 46)) ->x11 : Symbol(x11, Decl(declarationEmitDestructuringObjectLiteralPattern.ts, 9, 5)) ->b : Symbol(b, Decl(declarationEmitDestructuringObjectLiteralPattern.ts, 9, 52)) ->a : Symbol(a, Decl(declarationEmitDestructuringObjectLiteralPattern.ts, 9, 57)) ->y11 : Symbol(y11, Decl(declarationEmitDestructuringObjectLiteralPattern.ts, 9, 18)) ->b : Symbol(b, Decl(declarationEmitDestructuringObjectLiteralPattern.ts, 9, 69)) ->a : Symbol(a, Decl(declarationEmitDestructuringObjectLiteralPattern.ts, 9, 74)) ->z11 : Symbol(z11, Decl(declarationEmitDestructuringObjectLiteralPattern.ts, 9, 31)) ->a : Symbol(a, Decl(declarationEmitDestructuringObjectLiteralPattern.ts, 9, 46)) ->b : Symbol(b, Decl(declarationEmitDestructuringObjectLiteralPattern.ts, 9, 52)) ->a : Symbol(a, Decl(declarationEmitDestructuringObjectLiteralPattern.ts, 9, 57)) ->b : Symbol(b, Decl(declarationEmitDestructuringObjectLiteralPattern.ts, 9, 69)) ->a : Symbol(a, Decl(declarationEmitDestructuringObjectLiteralPattern.ts, 9, 74)) - -function f15() { ->f15 : Symbol(f15, Decl(declarationEmitDestructuringObjectLiteralPattern.ts, 9, 89)) - - var a4 = "hello"; ->a4 : Symbol(a4, Decl(declarationEmitDestructuringObjectLiteralPattern.ts, 12, 7)) - - var b4 = 1; ->b4 : Symbol(b4, Decl(declarationEmitDestructuringObjectLiteralPattern.ts, 13, 7)) - - var c4 = true; ->c4 : Symbol(c4, Decl(declarationEmitDestructuringObjectLiteralPattern.ts, 14, 7)) - - return { a4, b4, c4 }; ->a4 : Symbol(a4, Decl(declarationEmitDestructuringObjectLiteralPattern.ts, 15, 12)) ->b4 : Symbol(b4, Decl(declarationEmitDestructuringObjectLiteralPattern.ts, 15, 16)) ->c4 : Symbol(c4, Decl(declarationEmitDestructuringObjectLiteralPattern.ts, 15, 20)) -} -var { a4, b4, c4 } = f15(); ->a4 : Symbol(a4, Decl(declarationEmitDestructuringObjectLiteralPattern.ts, 17, 5)) ->b4 : Symbol(b4, Decl(declarationEmitDestructuringObjectLiteralPattern.ts, 17, 9)) ->c4 : Symbol(c4, Decl(declarationEmitDestructuringObjectLiteralPattern.ts, 17, 13)) ->f15 : Symbol(f15, Decl(declarationEmitDestructuringObjectLiteralPattern.ts, 9, 89)) - -module m { ->m : Symbol(m, Decl(declarationEmitDestructuringObjectLiteralPattern.ts, 17, 27)) - - export var { a4, b4, c4 } = f15(); ->a4 : Symbol(a4, Decl(declarationEmitDestructuringObjectLiteralPattern.ts, 20, 16)) ->b4 : Symbol(b4, Decl(declarationEmitDestructuringObjectLiteralPattern.ts, 20, 20)) ->c4 : Symbol(c4, Decl(declarationEmitDestructuringObjectLiteralPattern.ts, 20, 24)) ->f15 : Symbol(f15, Decl(declarationEmitDestructuringObjectLiteralPattern.ts, 9, 89)) -} diff --git a/tests/baselines/reference/declarationEmitDestructuringObjectLiteralPattern.types b/tests/baselines/reference/declarationEmitDestructuringObjectLiteralPattern.types deleted file mode 100644 index 0911a27838b..00000000000 --- a/tests/baselines/reference/declarationEmitDestructuringObjectLiteralPattern.types +++ /dev/null @@ -1,122 +0,0 @@ -=== tests/cases/compiler/declarationEmitDestructuringObjectLiteralPattern.ts === - -var { } = { x: 5, y: "hello" }; ->{ x: 5, y: "hello" } : { x: number; y: string; } ->x : number ->5 : number ->y : string ->"hello" : string - -var { x4 } = { x4: 5, y4: "hello" }; ->x4 : number ->{ x4: 5, y4: "hello" } : { x4: number; y4: string; } ->x4 : number ->5 : number ->y4 : string ->"hello" : string - -var { y5 } = { x5: 5, y5: "hello" }; ->y5 : string ->{ x5: 5, y5: "hello" } : { x5: number; y5: string; } ->x5 : number ->5 : number ->y5 : string ->"hello" : string - -var { x6, y6 } = { x6: 5, y6: "hello" }; ->x6 : number ->y6 : string ->{ x6: 5, y6: "hello" } : { x6: number; y6: string; } ->x6 : number ->5 : number ->y6 : string ->"hello" : string - -var { x7: a1 } = { x7: 5, y7: "hello" }; ->x7 : any ->a1 : number ->{ x7: 5, y7: "hello" } : { x7: number; y7: string; } ->x7 : number ->5 : number ->y7 : string ->"hello" : string - -var { y8: b1 } = { x8: 5, y8: "hello" }; ->y8 : any ->b1 : string ->{ x8: 5, y8: "hello" } : { x8: number; y8: string; } ->x8 : number ->5 : number ->y8 : string ->"hello" : string - -var { x9: a2, y9: b2 } = { x9: 5, y9: "hello" }; ->x9 : any ->a2 : number ->y9 : any ->b2 : string ->{ x9: 5, y9: "hello" } : { x9: number; y9: string; } ->x9 : number ->5 : number ->y9 : string ->"hello" : string - -var { a: x11, b: { a: y11, b: { a: z11 }}} = { a: 1, b: { a: "hello", b: { a: true } } }; ->a : any ->x11 : number ->b : any ->a : any ->y11 : string ->b : any ->a : any ->z11 : boolean ->{ a: 1, b: { a: "hello", b: { a: true } } } : { a: number; b: { a: string; b: { a: boolean; }; }; } ->a : number ->1 : number ->b : { a: string; b: { a: boolean; }; } ->{ a: "hello", b: { a: true } } : { a: string; b: { a: boolean; }; } ->a : string ->"hello" : string ->b : { a: boolean; } ->{ a: true } : { a: boolean; } ->a : boolean ->true : boolean - -function f15() { ->f15 : () => { a4: string; b4: number; c4: boolean; } - - var a4 = "hello"; ->a4 : string ->"hello" : string - - var b4 = 1; ->b4 : number ->1 : number - - var c4 = true; ->c4 : boolean ->true : boolean - - return { a4, b4, c4 }; ->{ a4, b4, c4 } : { a4: string; b4: number; c4: boolean; } ->a4 : string ->b4 : number ->c4 : boolean -} -var { a4, b4, c4 } = f15(); ->a4 : string ->b4 : number ->c4 : boolean ->f15() : { a4: string; b4: number; c4: boolean; } ->f15 : () => { a4: string; b4: number; c4: boolean; } - -module m { ->m : typeof m - - export var { a4, b4, c4 } = f15(); ->a4 : string ->b4 : number ->c4 : boolean ->f15() : { a4: string; b4: number; c4: boolean; } ->f15 : () => { a4: string; b4: number; c4: boolean; } -} diff --git a/tests/baselines/reference/declarationEmitDestructuringObjectLiteralPattern1.errors.txt b/tests/baselines/reference/declarationEmitDestructuringObjectLiteralPattern1.errors.txt new file mode 100644 index 00000000000..24fbcf99ad1 --- /dev/null +++ b/tests/baselines/reference/declarationEmitDestructuringObjectLiteralPattern1.errors.txt @@ -0,0 +1,29 @@ +tests/cases/compiler/declarationEmitDestructuringObjectLiteralPattern1.ts(2,13): error TS2353: Object literal may only specify known properties, and 'x' does not exist in type '{}'. +tests/cases/compiler/declarationEmitDestructuringObjectLiteralPattern1.ts(2,19): error TS2353: Object literal may only specify known properties, and 'y' does not exist in type '{}'. +tests/cases/compiler/declarationEmitDestructuringObjectLiteralPattern1.ts(3,23): error TS2353: Object literal may only specify known properties, and 'y4' does not exist in type '{ x4: any; }'. +tests/cases/compiler/declarationEmitDestructuringObjectLiteralPattern1.ts(4,16): error TS2353: Object literal may only specify known properties, and 'x5' does not exist in type '{ y5: any; }'. +tests/cases/compiler/declarationEmitDestructuringObjectLiteralPattern1.ts(6,27): error TS2353: Object literal may only specify known properties, and 'y7' does not exist in type '{ x7: any; }'. +tests/cases/compiler/declarationEmitDestructuringObjectLiteralPattern1.ts(7,20): error TS2353: Object literal may only specify known properties, and 'x8' does not exist in type '{ y8: any; }'. + + +==== tests/cases/compiler/declarationEmitDestructuringObjectLiteralPattern1.ts (6 errors) ==== + + var { } = { x: 5, y: "hello" }; + ~ +!!! error TS2353: Object literal may only specify known properties, and 'x' does not exist in type '{}'. + ~ +!!! error TS2353: Object literal may only specify known properties, and 'y' does not exist in type '{}'. + var { x4 } = { x4: 5, y4: "hello" }; + ~~ +!!! error TS2353: Object literal may only specify known properties, and 'y4' does not exist in type '{ x4: any; }'. + var { y5 } = { x5: 5, y5: "hello" }; + ~~ +!!! error TS2353: Object literal may only specify known properties, and 'x5' does not exist in type '{ y5: any; }'. + var { x6, y6 } = { x6: 5, y6: "hello" }; + var { x7: a1 } = { x7: 5, y7: "hello" }; + ~~ +!!! error TS2353: Object literal may only specify known properties, and 'y7' does not exist in type '{ x7: any; }'. + var { y8: b1 } = { x8: 5, y8: "hello" }; + ~~ +!!! error TS2353: Object literal may only specify known properties, and 'x8' does not exist in type '{ y8: any; }'. + var { x9: a2, y9: b2 } = { x9: 5, y9: "hello" }; \ No newline at end of file diff --git a/tests/baselines/reference/declarationEmitDestructuringObjectLiteralPattern1.symbols b/tests/baselines/reference/declarationEmitDestructuringObjectLiteralPattern1.symbols deleted file mode 100644 index cac2431411e..00000000000 --- a/tests/baselines/reference/declarationEmitDestructuringObjectLiteralPattern1.symbols +++ /dev/null @@ -1,42 +0,0 @@ -=== tests/cases/compiler/declarationEmitDestructuringObjectLiteralPattern1.ts === - -var { } = { x: 5, y: "hello" }; ->x : Symbol(x, Decl(declarationEmitDestructuringObjectLiteralPattern1.ts, 1, 11)) ->y : Symbol(y, Decl(declarationEmitDestructuringObjectLiteralPattern1.ts, 1, 17)) - -var { x4 } = { x4: 5, y4: "hello" }; ->x4 : Symbol(x4, Decl(declarationEmitDestructuringObjectLiteralPattern1.ts, 2, 5)) ->x4 : Symbol(x4, Decl(declarationEmitDestructuringObjectLiteralPattern1.ts, 2, 14)) ->y4 : Symbol(y4, Decl(declarationEmitDestructuringObjectLiteralPattern1.ts, 2, 21)) - -var { y5 } = { x5: 5, y5: "hello" }; ->y5 : Symbol(y5, Decl(declarationEmitDestructuringObjectLiteralPattern1.ts, 3, 5)) ->x5 : Symbol(x5, Decl(declarationEmitDestructuringObjectLiteralPattern1.ts, 3, 14)) ->y5 : Symbol(y5, Decl(declarationEmitDestructuringObjectLiteralPattern1.ts, 3, 21)) - -var { x6, y6 } = { x6: 5, y6: "hello" }; ->x6 : Symbol(x6, Decl(declarationEmitDestructuringObjectLiteralPattern1.ts, 4, 5)) ->y6 : Symbol(y6, Decl(declarationEmitDestructuringObjectLiteralPattern1.ts, 4, 9)) ->x6 : Symbol(x6, Decl(declarationEmitDestructuringObjectLiteralPattern1.ts, 4, 18)) ->y6 : Symbol(y6, Decl(declarationEmitDestructuringObjectLiteralPattern1.ts, 4, 25)) - -var { x7: a1 } = { x7: 5, y7: "hello" }; ->x7 : Symbol(x7, Decl(declarationEmitDestructuringObjectLiteralPattern1.ts, 5, 18)) ->a1 : Symbol(a1, Decl(declarationEmitDestructuringObjectLiteralPattern1.ts, 5, 5)) ->x7 : Symbol(x7, Decl(declarationEmitDestructuringObjectLiteralPattern1.ts, 5, 18)) ->y7 : Symbol(y7, Decl(declarationEmitDestructuringObjectLiteralPattern1.ts, 5, 25)) - -var { y8: b1 } = { x8: 5, y8: "hello" }; ->y8 : Symbol(y8, Decl(declarationEmitDestructuringObjectLiteralPattern1.ts, 6, 25)) ->b1 : Symbol(b1, Decl(declarationEmitDestructuringObjectLiteralPattern1.ts, 6, 5)) ->x8 : Symbol(x8, Decl(declarationEmitDestructuringObjectLiteralPattern1.ts, 6, 18)) ->y8 : Symbol(y8, Decl(declarationEmitDestructuringObjectLiteralPattern1.ts, 6, 25)) - -var { x9: a2, y9: b2 } = { x9: 5, y9: "hello" }; ->x9 : Symbol(x9, Decl(declarationEmitDestructuringObjectLiteralPattern1.ts, 7, 26)) ->a2 : Symbol(a2, Decl(declarationEmitDestructuringObjectLiteralPattern1.ts, 7, 5)) ->y9 : Symbol(y9, Decl(declarationEmitDestructuringObjectLiteralPattern1.ts, 7, 33)) ->b2 : Symbol(b2, Decl(declarationEmitDestructuringObjectLiteralPattern1.ts, 7, 13)) ->x9 : Symbol(x9, Decl(declarationEmitDestructuringObjectLiteralPattern1.ts, 7, 26)) ->y9 : Symbol(y9, Decl(declarationEmitDestructuringObjectLiteralPattern1.ts, 7, 33)) - diff --git a/tests/baselines/reference/declarationEmitDestructuringObjectLiteralPattern1.types b/tests/baselines/reference/declarationEmitDestructuringObjectLiteralPattern1.types deleted file mode 100644 index 5411f36fa9a..00000000000 --- a/tests/baselines/reference/declarationEmitDestructuringObjectLiteralPattern1.types +++ /dev/null @@ -1,63 +0,0 @@ -=== tests/cases/compiler/declarationEmitDestructuringObjectLiteralPattern1.ts === - -var { } = { x: 5, y: "hello" }; ->{ x: 5, y: "hello" } : { x: number; y: string; } ->x : number ->5 : number ->y : string ->"hello" : string - -var { x4 } = { x4: 5, y4: "hello" }; ->x4 : number ->{ x4: 5, y4: "hello" } : { x4: number; y4: string; } ->x4 : number ->5 : number ->y4 : string ->"hello" : string - -var { y5 } = { x5: 5, y5: "hello" }; ->y5 : string ->{ x5: 5, y5: "hello" } : { x5: number; y5: string; } ->x5 : number ->5 : number ->y5 : string ->"hello" : string - -var { x6, y6 } = { x6: 5, y6: "hello" }; ->x6 : number ->y6 : string ->{ x6: 5, y6: "hello" } : { x6: number; y6: string; } ->x6 : number ->5 : number ->y6 : string ->"hello" : string - -var { x7: a1 } = { x7: 5, y7: "hello" }; ->x7 : any ->a1 : number ->{ x7: 5, y7: "hello" } : { x7: number; y7: string; } ->x7 : number ->5 : number ->y7 : string ->"hello" : string - -var { y8: b1 } = { x8: 5, y8: "hello" }; ->y8 : any ->b1 : string ->{ x8: 5, y8: "hello" } : { x8: number; y8: string; } ->x8 : number ->5 : number ->y8 : string ->"hello" : string - -var { x9: a2, y9: b2 } = { x9: 5, y9: "hello" }; ->x9 : any ->a2 : number ->y9 : any ->b2 : string ->{ x9: 5, y9: "hello" } : { x9: number; y9: string; } ->x9 : number ->5 : number ->y9 : string ->"hello" : string - diff --git a/tests/baselines/reference/declarationsAndAssignments.errors.txt b/tests/baselines/reference/declarationsAndAssignments.errors.txt index 3e0666a96c0..802e72562af 100644 --- a/tests/baselines/reference/declarationsAndAssignments.errors.txt +++ b/tests/baselines/reference/declarationsAndAssignments.errors.txt @@ -1,4 +1,9 @@ -tests/cases/conformance/es6/destructuring/declarationsAndAssignments.ts(6,13): error TS2403: Subsequent variable declarations must have the same type. Variable 'z' must be of type 'any', but here has type 'number'. +tests/cases/conformance/es6/destructuring/declarationsAndAssignments.ts(22,17): error TS2353: Object literal may only specify known properties, and 'x' does not exist in type '{}'. +tests/cases/conformance/es6/destructuring/declarationsAndAssignments.ts(22,23): error TS2353: Object literal may only specify known properties, and 'y' does not exist in type '{}'. +tests/cases/conformance/es6/destructuring/declarationsAndAssignments.ts(23,25): error TS2353: Object literal may only specify known properties, and 'y' does not exist in type '{ x: any; }'. +tests/cases/conformance/es6/destructuring/declarationsAndAssignments.ts(24,19): error TS2353: Object literal may only specify known properties, and 'x' does not exist in type '{ y: any; }'. +tests/cases/conformance/es6/destructuring/declarationsAndAssignments.ts(28,28): error TS2353: Object literal may only specify known properties, and 'y' does not exist in type '{ x: any; }'. +tests/cases/conformance/es6/destructuring/declarationsAndAssignments.ts(29,22): error TS2353: Object literal may only specify known properties, and 'x' does not exist in type '{ y: any; }'. tests/cases/conformance/es6/destructuring/declarationsAndAssignments.ts(56,17): error TS2322: Type 'number' is not assignable to type 'string'. tests/cases/conformance/es6/destructuring/declarationsAndAssignments.ts(67,9): error TS2461: Type '{ [x: number]: undefined; }' is not an array type. tests/cases/conformance/es6/destructuring/declarationsAndAssignments.ts(68,9): error TS2461: Type '{ [x: number]: number; 0: number; 1: number; }' is not an array type. @@ -16,15 +21,13 @@ tests/cases/conformance/es6/destructuring/declarationsAndAssignments.ts(138,6): tests/cases/conformance/es6/destructuring/declarationsAndAssignments.ts(138,9): error TS2322: Type 'number' is not assignable to type 'string'. -==== tests/cases/conformance/es6/destructuring/declarationsAndAssignments.ts (11 errors) ==== +==== tests/cases/conformance/es6/destructuring/declarationsAndAssignments.ts (16 errors) ==== function f0() { var [] = [1, "hello"]; var [x] = [1, "hello"]; var [x, y] = [1, "hello"]; - var [x, y, z] = [1, "hello"]; // Error - var [,, z] = [0, 1, 2]; - ~ -!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'z' must be of type 'any', but here has type 'number'. + var [x, y, z] = [1, "hello"]; + var [,, x] = [0, 1, 2]; var x: number; var y: string; } @@ -40,14 +43,26 @@ tests/cases/conformance/es6/destructuring/declarationsAndAssignments.ts(138,9): } function f2() { - var { } = { x: 5, y: "hello" }; - var { x } = { x: 5, y: "hello" }; - var { y } = { x: 5, y: "hello" }; + var { } = { x: 5, y: "hello" }; // Error, no x and y in target + ~ +!!! error TS2353: Object literal may only specify known properties, and 'x' does not exist in type '{}'. + ~ +!!! error TS2353: Object literal may only specify known properties, and 'y' does not exist in type '{}'. + var { x } = { x: 5, y: "hello" }; // Error, no y in target + ~ +!!! error TS2353: Object literal may only specify known properties, and 'y' does not exist in type '{ x: any; }'. + var { y } = { x: 5, y: "hello" }; // Error, no x in target + ~ +!!! error TS2353: Object literal may only specify known properties, and 'x' does not exist in type '{ y: any; }'. var { x, y } = { x: 5, y: "hello" }; var x: number; var y: string; - var { x: a } = { x: 5, y: "hello" }; - var { y: b } = { x: 5, y: "hello" }; + var { x: a } = { x: 5, y: "hello" }; // Error, no y in target + ~ +!!! error TS2353: Object literal may only specify known properties, and 'y' does not exist in type '{ x: any; }'. + var { y: b } = { x: 5, y: "hello" }; // Error, no x in target + ~ +!!! error TS2353: Object literal may only specify known properties, and 'x' does not exist in type '{ y: any; }'. var { x: a, y: b } = { x: 5, y: "hello" }; var a: number; var b: string; diff --git a/tests/baselines/reference/declarationsAndAssignments.js b/tests/baselines/reference/declarationsAndAssignments.js index 5c47756e7fe..018aa5522ca 100644 --- a/tests/baselines/reference/declarationsAndAssignments.js +++ b/tests/baselines/reference/declarationsAndAssignments.js @@ -3,8 +3,8 @@ function f0() { var [] = [1, "hello"]; var [x] = [1, "hello"]; var [x, y] = [1, "hello"]; - var [x, y, z] = [1, "hello"]; // Error - var [,, z] = [0, 1, 2]; + var [x, y, z] = [1, "hello"]; + var [,, x] = [0, 1, 2]; var x: number; var y: string; } @@ -20,14 +20,14 @@ function f1() { } function f2() { - var { } = { x: 5, y: "hello" }; - var { x } = { x: 5, y: "hello" }; - var { y } = { x: 5, y: "hello" }; + var { } = { x: 5, y: "hello" }; // Error, no x and y in target + var { x } = { x: 5, y: "hello" }; // Error, no y in target + var { y } = { x: 5, y: "hello" }; // Error, no x in target var { x, y } = { x: 5, y: "hello" }; var x: number; var y: string; - var { x: a } = { x: 5, y: "hello" }; - var { y: b } = { x: 5, y: "hello" }; + var { x: a } = { x: 5, y: "hello" }; // Error, no y in target + var { y: b } = { x: 5, y: "hello" }; // Error, no x in target var { x: a, y: b } = { x: 5, y: "hello" }; var a: number; var b: string; @@ -185,8 +185,8 @@ function f0() { var _a = [1, "hello"]; var x = [1, "hello"][0]; var _b = [1, "hello"], x = _b[0], y = _b[1]; - var _c = [1, "hello"], x = _c[0], y = _c[1], z = _c[2]; // Error - var _d = [0, 1, 2], z = _d[2]; + var _c = [1, "hello"], x = _c[0], y = _c[1], z = _c[2]; + var _d = [0, 1, 2], x = _d[2]; var x; var y; } @@ -200,14 +200,14 @@ function f1() { var z; } function f2() { - var _a = { x: 5, y: "hello" }; - var x = { x: 5, y: "hello" }.x; - var y = { x: 5, y: "hello" }.y; + var _a = { x: 5, y: "hello" }; // Error, no x and y in target + var x = { x: 5, y: "hello" }.x; // Error, no y in target + var y = { x: 5, y: "hello" }.y; // Error, no x in target var _b = { x: 5, y: "hello" }, x = _b.x, y = _b.y; var x; var y; - var a = { x: 5, y: "hello" }.x; - var b = { x: 5, y: "hello" }.y; + var a = { x: 5, y: "hello" }.x; // Error, no y in target + var b = { x: 5, y: "hello" }.y; // Error, no x in target var _c = { x: 5, y: "hello" }, a = _c.x, b = _c.y; var a; var b; diff --git a/tests/baselines/reference/destructuringObjectBindingPatternAndAssignment3.errors.txt b/tests/baselines/reference/destructuringObjectBindingPatternAndAssignment3.errors.txt index 9025f24f992..4cee4314466 100644 --- a/tests/baselines/reference/destructuringObjectBindingPatternAndAssignment3.errors.txt +++ b/tests/baselines/reference/destructuringObjectBindingPatternAndAssignment3.errors.txt @@ -4,13 +4,17 @@ tests/cases/conformance/es6/destructuring/destructuringObjectBindingPatternAndAs tests/cases/conformance/es6/destructuring/destructuringObjectBindingPatternAndAssignment3.ts(3,6): error TS2459: Type 'string | number' has no property 'i' and no string index signature. tests/cases/conformance/es6/destructuring/destructuringObjectBindingPatternAndAssignment3.ts(4,6): error TS2459: Type 'string | number | {}' has no property 'i1' and no string index signature. tests/cases/conformance/es6/destructuring/destructuringObjectBindingPatternAndAssignment3.ts(5,12): error TS2459: Type '{ f212: string; }' has no property 'f21' and no string index signature. +tests/cases/conformance/es6/destructuring/destructuringObjectBindingPatternAndAssignment3.ts(5,21): error TS2353: Object literal may only specify known properties, and 'f212' does not exist in type '{ f21: any; }'. tests/cases/conformance/es6/destructuring/destructuringObjectBindingPatternAndAssignment3.ts(6,7): error TS1180: Property destructuring pattern expected. +tests/cases/conformance/es6/destructuring/destructuringObjectBindingPatternAndAssignment3.ts(7,5): error TS2353: Object literal may only specify known properties, and 'a' does not exist in type '{ d1: any; }'. +tests/cases/conformance/es6/destructuring/destructuringObjectBindingPatternAndAssignment3.ts(7,11): error TS2353: Object literal may only specify known properties, and 'b' does not exist in type '{ d1: any; }'. +tests/cases/conformance/es6/destructuring/destructuringObjectBindingPatternAndAssignment3.ts(7,24): error TS2353: Object literal may only specify known properties, and 'e' does not exist in type '{ d1: any; }'. tests/cases/conformance/es6/destructuring/destructuringObjectBindingPatternAndAssignment3.ts(9,7): error TS1005: ':' expected. tests/cases/conformance/es6/destructuring/destructuringObjectBindingPatternAndAssignment3.ts(9,15): error TS1005: ':' expected. tests/cases/conformance/es6/destructuring/destructuringObjectBindingPatternAndAssignment3.ts(10,12): error TS1005: ':' expected. -==== tests/cases/conformance/es6/destructuring/destructuringObjectBindingPatternAndAssignment3.ts (9 errors) ==== +==== tests/cases/conformance/es6/destructuring/destructuringObjectBindingPatternAndAssignment3.ts (13 errors) ==== // Error var {h?} = { h?: 1 }; ~ @@ -27,10 +31,18 @@ tests/cases/conformance/es6/destructuring/destructuringObjectBindingPatternAndAs var { f2: {f21} = { f212: "string" } }: any = undefined; ~~~ !!! error TS2459: Type '{ f212: string; }' has no property 'f21' and no string index signature. + ~~~~ +!!! error TS2353: Object literal may only specify known properties, and 'f212' does not exist in type '{ f21: any; }'. var { ...d1 } = { ~~~ !!! error TS1180: Property destructuring pattern expected. a: 1, b: 1, d1: 9, e: 10 + ~ +!!! error TS2353: Object literal may only specify known properties, and 'a' does not exist in type '{ d1: any; }'. + ~ +!!! error TS2353: Object literal may only specify known properties, and 'b' does not exist in type '{ d1: any; }'. + ~ +!!! error TS2353: Object literal may only specify known properties, and 'e' does not exist in type '{ d1: any; }'. } var {1} = { 1 }; ~ diff --git a/tests/baselines/reference/destructuringWithLiteralInitializers.js b/tests/baselines/reference/destructuringWithLiteralInitializers.js index c25216a55f8..a8251435d39 100644 --- a/tests/baselines/reference/destructuringWithLiteralInitializers.js +++ b/tests/baselines/reference/destructuringWithLiteralInitializers.js @@ -3,6 +3,7 @@ function f1({ x, y }) { } f1({ x: 1, y: 1 }); +// (arg: { x: any, y?: number }) => void function f2({ x, y = 0 }) { } f2({ x: 1 }); f2({ x: 1, y: 1 }); @@ -58,6 +59,7 @@ function f1(_a) { var x = _a.x, y = _a.y; } f1({ x: 1, y: 1 }); +// (arg: { x: any, y?: number }) => void function f2(_a) { var x = _a.x, _b = _a.y, y = _b === void 0 ? 0 : _b; } diff --git a/tests/baselines/reference/destructuringWithLiteralInitializers.symbols b/tests/baselines/reference/destructuringWithLiteralInitializers.symbols index 992a9c3ace5..9dc3960f2af 100644 --- a/tests/baselines/reference/destructuringWithLiteralInitializers.symbols +++ b/tests/baselines/reference/destructuringWithLiteralInitializers.symbols @@ -10,141 +10,142 @@ f1({ x: 1, y: 1 }); >x : Symbol(x, Decl(destructuringWithLiteralInitializers.ts, 2, 4)) >y : Symbol(y, Decl(destructuringWithLiteralInitializers.ts, 2, 10)) +// (arg: { x: any, y?: number }) => void function f2({ x, y = 0 }) { } >f2 : Symbol(f2, Decl(destructuringWithLiteralInitializers.ts, 2, 19)) ->x : Symbol(x, Decl(destructuringWithLiteralInitializers.ts, 4, 13)) ->y : Symbol(y, Decl(destructuringWithLiteralInitializers.ts, 4, 16)) +>x : Symbol(x, Decl(destructuringWithLiteralInitializers.ts, 5, 13)) +>y : Symbol(y, Decl(destructuringWithLiteralInitializers.ts, 5, 16)) f2({ x: 1 }); >f2 : Symbol(f2, Decl(destructuringWithLiteralInitializers.ts, 2, 19)) ->x : Symbol(x, Decl(destructuringWithLiteralInitializers.ts, 5, 4)) +>x : Symbol(x, Decl(destructuringWithLiteralInitializers.ts, 6, 4)) f2({ x: 1, y: 1 }); >f2 : Symbol(f2, Decl(destructuringWithLiteralInitializers.ts, 2, 19)) ->x : Symbol(x, Decl(destructuringWithLiteralInitializers.ts, 6, 4)) ->y : Symbol(y, Decl(destructuringWithLiteralInitializers.ts, 6, 10)) +>x : Symbol(x, Decl(destructuringWithLiteralInitializers.ts, 7, 4)) +>y : Symbol(y, Decl(destructuringWithLiteralInitializers.ts, 7, 10)) // (arg: { x?: number, y?: number }) => void function f3({ x = 0, y = 0 }) { } ->f3 : Symbol(f3, Decl(destructuringWithLiteralInitializers.ts, 6, 19)) ->x : Symbol(x, Decl(destructuringWithLiteralInitializers.ts, 9, 13)) ->y : Symbol(y, Decl(destructuringWithLiteralInitializers.ts, 9, 20)) +>f3 : Symbol(f3, Decl(destructuringWithLiteralInitializers.ts, 7, 19)) +>x : Symbol(x, Decl(destructuringWithLiteralInitializers.ts, 10, 13)) +>y : Symbol(y, Decl(destructuringWithLiteralInitializers.ts, 10, 20)) f3({}); ->f3 : Symbol(f3, Decl(destructuringWithLiteralInitializers.ts, 6, 19)) +>f3 : Symbol(f3, Decl(destructuringWithLiteralInitializers.ts, 7, 19)) f3({ x: 1 }); ->f3 : Symbol(f3, Decl(destructuringWithLiteralInitializers.ts, 6, 19)) ->x : Symbol(x, Decl(destructuringWithLiteralInitializers.ts, 11, 4)) +>f3 : Symbol(f3, Decl(destructuringWithLiteralInitializers.ts, 7, 19)) +>x : Symbol(x, Decl(destructuringWithLiteralInitializers.ts, 12, 4)) f3({ y: 1 }); ->f3 : Symbol(f3, Decl(destructuringWithLiteralInitializers.ts, 6, 19)) ->y : Symbol(y, Decl(destructuringWithLiteralInitializers.ts, 12, 4)) +>f3 : Symbol(f3, Decl(destructuringWithLiteralInitializers.ts, 7, 19)) +>y : Symbol(y, Decl(destructuringWithLiteralInitializers.ts, 13, 4)) f3({ x: 1, y: 1 }); ->f3 : Symbol(f3, Decl(destructuringWithLiteralInitializers.ts, 6, 19)) ->x : Symbol(x, Decl(destructuringWithLiteralInitializers.ts, 13, 4)) ->y : Symbol(y, Decl(destructuringWithLiteralInitializers.ts, 13, 10)) +>f3 : Symbol(f3, Decl(destructuringWithLiteralInitializers.ts, 7, 19)) +>x : Symbol(x, Decl(destructuringWithLiteralInitializers.ts, 14, 4)) +>y : Symbol(y, Decl(destructuringWithLiteralInitializers.ts, 14, 10)) // (arg?: { x: number, y: number }) => void function f4({ x, y } = { x: 0, y: 0 }) { } ->f4 : Symbol(f4, Decl(destructuringWithLiteralInitializers.ts, 13, 19)) ->x : Symbol(x, Decl(destructuringWithLiteralInitializers.ts, 16, 13)) ->y : Symbol(y, Decl(destructuringWithLiteralInitializers.ts, 16, 16)) ->x : Symbol(x, Decl(destructuringWithLiteralInitializers.ts, 16, 24)) ->y : Symbol(y, Decl(destructuringWithLiteralInitializers.ts, 16, 30)) +>f4 : Symbol(f4, Decl(destructuringWithLiteralInitializers.ts, 14, 19)) +>x : Symbol(x, Decl(destructuringWithLiteralInitializers.ts, 17, 13)) +>y : Symbol(y, Decl(destructuringWithLiteralInitializers.ts, 17, 16)) +>x : Symbol(x, Decl(destructuringWithLiteralInitializers.ts, 17, 24)) +>y : Symbol(y, Decl(destructuringWithLiteralInitializers.ts, 17, 30)) f4(); ->f4 : Symbol(f4, Decl(destructuringWithLiteralInitializers.ts, 13, 19)) +>f4 : Symbol(f4, Decl(destructuringWithLiteralInitializers.ts, 14, 19)) f4({ x: 1, y: 1 }); ->f4 : Symbol(f4, Decl(destructuringWithLiteralInitializers.ts, 13, 19)) ->x : Symbol(x, Decl(destructuringWithLiteralInitializers.ts, 18, 4)) ->y : Symbol(y, Decl(destructuringWithLiteralInitializers.ts, 18, 10)) +>f4 : Symbol(f4, Decl(destructuringWithLiteralInitializers.ts, 14, 19)) +>x : Symbol(x, Decl(destructuringWithLiteralInitializers.ts, 19, 4)) +>y : Symbol(y, Decl(destructuringWithLiteralInitializers.ts, 19, 10)) // (arg?: { x: number, y?: number }) => void function f5({ x, y = 0 } = { x: 0 }) { } ->f5 : Symbol(f5, Decl(destructuringWithLiteralInitializers.ts, 18, 19)) ->x : Symbol(x, Decl(destructuringWithLiteralInitializers.ts, 21, 13)) ->y : Symbol(y, Decl(destructuringWithLiteralInitializers.ts, 21, 16)) ->x : Symbol(x, Decl(destructuringWithLiteralInitializers.ts, 21, 28)) +>f5 : Symbol(f5, Decl(destructuringWithLiteralInitializers.ts, 19, 19)) +>x : Symbol(x, Decl(destructuringWithLiteralInitializers.ts, 22, 13)) +>y : Symbol(y, Decl(destructuringWithLiteralInitializers.ts, 22, 16)) +>x : Symbol(x, Decl(destructuringWithLiteralInitializers.ts, 22, 28)) f5(); ->f5 : Symbol(f5, Decl(destructuringWithLiteralInitializers.ts, 18, 19)) +>f5 : Symbol(f5, Decl(destructuringWithLiteralInitializers.ts, 19, 19)) f5({ x: 1 }); ->f5 : Symbol(f5, Decl(destructuringWithLiteralInitializers.ts, 18, 19)) ->x : Symbol(x, Decl(destructuringWithLiteralInitializers.ts, 23, 4)) +>f5 : Symbol(f5, Decl(destructuringWithLiteralInitializers.ts, 19, 19)) +>x : Symbol(x, Decl(destructuringWithLiteralInitializers.ts, 24, 4)) f5({ x: 1, y: 1 }); ->f5 : Symbol(f5, Decl(destructuringWithLiteralInitializers.ts, 18, 19)) ->x : Symbol(x, Decl(destructuringWithLiteralInitializers.ts, 24, 4)) ->y : Symbol(y, Decl(destructuringWithLiteralInitializers.ts, 24, 10)) +>f5 : Symbol(f5, Decl(destructuringWithLiteralInitializers.ts, 19, 19)) +>x : Symbol(x, Decl(destructuringWithLiteralInitializers.ts, 25, 4)) +>y : Symbol(y, Decl(destructuringWithLiteralInitializers.ts, 25, 10)) // (arg?: { x?: number, y?: number }) => void function f6({ x = 0, y = 0 } = {}) { } ->f6 : Symbol(f6, Decl(destructuringWithLiteralInitializers.ts, 24, 19)) ->x : Symbol(x, Decl(destructuringWithLiteralInitializers.ts, 27, 13)) ->y : Symbol(y, Decl(destructuringWithLiteralInitializers.ts, 27, 20)) +>f6 : Symbol(f6, Decl(destructuringWithLiteralInitializers.ts, 25, 19)) +>x : Symbol(x, Decl(destructuringWithLiteralInitializers.ts, 28, 13)) +>y : Symbol(y, Decl(destructuringWithLiteralInitializers.ts, 28, 20)) f6(); ->f6 : Symbol(f6, Decl(destructuringWithLiteralInitializers.ts, 24, 19)) +>f6 : Symbol(f6, Decl(destructuringWithLiteralInitializers.ts, 25, 19)) f6({}); ->f6 : Symbol(f6, Decl(destructuringWithLiteralInitializers.ts, 24, 19)) +>f6 : Symbol(f6, Decl(destructuringWithLiteralInitializers.ts, 25, 19)) f6({ x: 1 }); ->f6 : Symbol(f6, Decl(destructuringWithLiteralInitializers.ts, 24, 19)) ->x : Symbol(x, Decl(destructuringWithLiteralInitializers.ts, 30, 4)) +>f6 : Symbol(f6, Decl(destructuringWithLiteralInitializers.ts, 25, 19)) +>x : Symbol(x, Decl(destructuringWithLiteralInitializers.ts, 31, 4)) f6({ y: 1 }); ->f6 : Symbol(f6, Decl(destructuringWithLiteralInitializers.ts, 24, 19)) ->y : Symbol(y, Decl(destructuringWithLiteralInitializers.ts, 31, 4)) +>f6 : Symbol(f6, Decl(destructuringWithLiteralInitializers.ts, 25, 19)) +>y : Symbol(y, Decl(destructuringWithLiteralInitializers.ts, 32, 4)) f6({ x: 1, y: 1 }); ->f6 : Symbol(f6, Decl(destructuringWithLiteralInitializers.ts, 24, 19)) ->x : Symbol(x, Decl(destructuringWithLiteralInitializers.ts, 32, 4)) ->y : Symbol(y, Decl(destructuringWithLiteralInitializers.ts, 32, 10)) +>f6 : Symbol(f6, Decl(destructuringWithLiteralInitializers.ts, 25, 19)) +>x : Symbol(x, Decl(destructuringWithLiteralInitializers.ts, 33, 4)) +>y : Symbol(y, Decl(destructuringWithLiteralInitializers.ts, 33, 10)) // (arg: [any, any]) => void function g1([x, y]) { } ->g1 : Symbol(g1, Decl(destructuringWithLiteralInitializers.ts, 32, 19)) ->x : Symbol(x, Decl(destructuringWithLiteralInitializers.ts, 35, 13)) ->y : Symbol(y, Decl(destructuringWithLiteralInitializers.ts, 35, 15)) +>g1 : Symbol(g1, Decl(destructuringWithLiteralInitializers.ts, 33, 19)) +>x : Symbol(x, Decl(destructuringWithLiteralInitializers.ts, 36, 13)) +>y : Symbol(y, Decl(destructuringWithLiteralInitializers.ts, 36, 15)) g1([1, 1]); ->g1 : Symbol(g1, Decl(destructuringWithLiteralInitializers.ts, 32, 19)) +>g1 : Symbol(g1, Decl(destructuringWithLiteralInitializers.ts, 33, 19)) // (arg: [number, number]) => void function g2([x = 0, y = 0]) { } ->g2 : Symbol(g2, Decl(destructuringWithLiteralInitializers.ts, 36, 11)) ->x : Symbol(x, Decl(destructuringWithLiteralInitializers.ts, 39, 13)) ->y : Symbol(y, Decl(destructuringWithLiteralInitializers.ts, 39, 19)) +>g2 : Symbol(g2, Decl(destructuringWithLiteralInitializers.ts, 37, 11)) +>x : Symbol(x, Decl(destructuringWithLiteralInitializers.ts, 40, 13)) +>y : Symbol(y, Decl(destructuringWithLiteralInitializers.ts, 40, 19)) g2([1, 1]); ->g2 : Symbol(g2, Decl(destructuringWithLiteralInitializers.ts, 36, 11)) +>g2 : Symbol(g2, Decl(destructuringWithLiteralInitializers.ts, 37, 11)) // (arg?: [any, any]) => void function g3([x, y] = []) { } ->g3 : Symbol(g3, Decl(destructuringWithLiteralInitializers.ts, 40, 11)) ->x : Symbol(x, Decl(destructuringWithLiteralInitializers.ts, 43, 13)) ->y : Symbol(y, Decl(destructuringWithLiteralInitializers.ts, 43, 15)) +>g3 : Symbol(g3, Decl(destructuringWithLiteralInitializers.ts, 41, 11)) +>x : Symbol(x, Decl(destructuringWithLiteralInitializers.ts, 44, 13)) +>y : Symbol(y, Decl(destructuringWithLiteralInitializers.ts, 44, 15)) g3(); ->g3 : Symbol(g3, Decl(destructuringWithLiteralInitializers.ts, 40, 11)) +>g3 : Symbol(g3, Decl(destructuringWithLiteralInitializers.ts, 41, 11)) g3([1, 1]); ->g3 : Symbol(g3, Decl(destructuringWithLiteralInitializers.ts, 40, 11)) +>g3 : Symbol(g3, Decl(destructuringWithLiteralInitializers.ts, 41, 11)) // (arg?: [number, number]) => void function g4([x, y] = [0, 0]) { } ->g4 : Symbol(g4, Decl(destructuringWithLiteralInitializers.ts, 45, 11)) ->x : Symbol(x, Decl(destructuringWithLiteralInitializers.ts, 48, 13)) ->y : Symbol(y, Decl(destructuringWithLiteralInitializers.ts, 48, 15)) +>g4 : Symbol(g4, Decl(destructuringWithLiteralInitializers.ts, 46, 11)) +>x : Symbol(x, Decl(destructuringWithLiteralInitializers.ts, 49, 13)) +>y : Symbol(y, Decl(destructuringWithLiteralInitializers.ts, 49, 15)) g4(); ->g4 : Symbol(g4, Decl(destructuringWithLiteralInitializers.ts, 45, 11)) +>g4 : Symbol(g4, Decl(destructuringWithLiteralInitializers.ts, 46, 11)) g4([1, 1]); ->g4 : Symbol(g4, Decl(destructuringWithLiteralInitializers.ts, 45, 11)) +>g4 : Symbol(g4, Decl(destructuringWithLiteralInitializers.ts, 46, 11)) diff --git a/tests/baselines/reference/destructuringWithLiteralInitializers.types b/tests/baselines/reference/destructuringWithLiteralInitializers.types index cbb1e343bf4..7807ba201c3 100644 --- a/tests/baselines/reference/destructuringWithLiteralInitializers.types +++ b/tests/baselines/reference/destructuringWithLiteralInitializers.types @@ -14,6 +14,7 @@ f1({ x: 1, y: 1 }); >y : number >1 : number +// (arg: { x: any, y?: number }) => void function f2({ x, y = 0 }) { } >f2 : ({ x, y = 0 }: { x: any; y?: number; }) => void >x : any diff --git a/tests/baselines/reference/emptyObjectBindingPatternParameter04.errors.txt b/tests/baselines/reference/emptyObjectBindingPatternParameter04.errors.txt new file mode 100644 index 00000000000..cf1b0e9a9a1 --- /dev/null +++ b/tests/baselines/reference/emptyObjectBindingPatternParameter04.errors.txt @@ -0,0 +1,17 @@ +tests/cases/conformance/es6/destructuring/emptyObjectBindingPatternParameter04.ts(3,18): error TS2353: Object literal may only specify known properties, and 'a' does not exist in type '{}'. +tests/cases/conformance/es6/destructuring/emptyObjectBindingPatternParameter04.ts(3,24): error TS2353: Object literal may only specify known properties, and 'b' does not exist in type '{}'. +tests/cases/conformance/es6/destructuring/emptyObjectBindingPatternParameter04.ts(3,32): error TS2353: Object literal may only specify known properties, and 'c' does not exist in type '{}'. + + +==== tests/cases/conformance/es6/destructuring/emptyObjectBindingPatternParameter04.ts (3 errors) ==== + + + function f({} = {a: 1, b: "2", c: true}) { + ~ +!!! error TS2353: Object literal may only specify known properties, and 'a' does not exist in type '{}'. + ~ +!!! error TS2353: Object literal may only specify known properties, and 'b' does not exist in type '{}'. + ~ +!!! error TS2353: Object literal may only specify known properties, and 'c' does not exist in type '{}'. + var x, y, z; + } \ No newline at end of file diff --git a/tests/baselines/reference/emptyObjectBindingPatternParameter04.symbols b/tests/baselines/reference/emptyObjectBindingPatternParameter04.symbols deleted file mode 100644 index 9922d4cd074..00000000000 --- a/tests/baselines/reference/emptyObjectBindingPatternParameter04.symbols +++ /dev/null @@ -1,14 +0,0 @@ -=== tests/cases/conformance/es6/destructuring/emptyObjectBindingPatternParameter04.ts === - - -function f({} = {a: 1, b: "2", c: true}) { ->f : Symbol(f, Decl(emptyObjectBindingPatternParameter04.ts, 0, 0)) ->a : Symbol(a, Decl(emptyObjectBindingPatternParameter04.ts, 2, 17)) ->b : Symbol(b, Decl(emptyObjectBindingPatternParameter04.ts, 2, 22)) ->c : Symbol(c, Decl(emptyObjectBindingPatternParameter04.ts, 2, 30)) - - var x, y, z; ->x : Symbol(x, Decl(emptyObjectBindingPatternParameter04.ts, 3, 7)) ->y : Symbol(y, Decl(emptyObjectBindingPatternParameter04.ts, 3, 10)) ->z : Symbol(z, Decl(emptyObjectBindingPatternParameter04.ts, 3, 13)) -} diff --git a/tests/baselines/reference/emptyObjectBindingPatternParameter04.types b/tests/baselines/reference/emptyObjectBindingPatternParameter04.types deleted file mode 100644 index 5ee32d422a9..00000000000 --- a/tests/baselines/reference/emptyObjectBindingPatternParameter04.types +++ /dev/null @@ -1,18 +0,0 @@ -=== tests/cases/conformance/es6/destructuring/emptyObjectBindingPatternParameter04.ts === - - -function f({} = {a: 1, b: "2", c: true}) { ->f : ({}?: { a: number; b: string; c: boolean; }) => void ->{a: 1, b: "2", c: true} : { a: number; b: string; c: boolean; } ->a : number ->1 : number ->b : string ->"2" : string ->c : boolean ->true : boolean - - var x, y, z; ->x : any ->y : any ->z : any -} From 31f8a8148c952fcc9716b2953d49c23715cc0438 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Sat, 5 Sep 2015 15:46:45 -0700 Subject: [PATCH 089/117] Adding test for excess/missing properties --- .../missingAndExcessProperties.errors.txt | 85 +++++++++++++++++++ .../reference/missingAndExcessProperties.js | 69 +++++++++++++++ .../missingAndExcessProperties.ts | 33 +++++++ 3 files changed, 187 insertions(+) create mode 100644 tests/baselines/reference/missingAndExcessProperties.errors.txt create mode 100644 tests/baselines/reference/missingAndExcessProperties.js create mode 100644 tests/cases/conformance/es6/destructuring/missingAndExcessProperties.ts diff --git a/tests/baselines/reference/missingAndExcessProperties.errors.txt b/tests/baselines/reference/missingAndExcessProperties.errors.txt new file mode 100644 index 00000000000..294b564a239 --- /dev/null +++ b/tests/baselines/reference/missingAndExcessProperties.errors.txt @@ -0,0 +1,85 @@ +tests/cases/conformance/es6/destructuring/missingAndExcessProperties.ts(3,11): error TS2459: Type '{}' has no property 'x' and no string index signature. +tests/cases/conformance/es6/destructuring/missingAndExcessProperties.ts(3,14): error TS2459: Type '{}' has no property 'y' and no string index signature. +tests/cases/conformance/es6/destructuring/missingAndExcessProperties.ts(4,18): error TS2459: Type '{ x?: number; }' has no property 'y' and no string index signature. +tests/cases/conformance/es6/destructuring/missingAndExcessProperties.ts(5,11): error TS2459: Type '{ y?: number; }' has no property 'x' and no string index signature. +tests/cases/conformance/es6/destructuring/missingAndExcessProperties.ts(12,8): error TS2459: Type '{}' has no property 'x' and no string index signature. +tests/cases/conformance/es6/destructuring/missingAndExcessProperties.ts(12,11): error TS2459: Type '{}' has no property 'y' and no string index signature. +tests/cases/conformance/es6/destructuring/missingAndExcessProperties.ts(13,18): error TS2459: Type '{ x?: number; }' has no property 'y' and no string index signature. +tests/cases/conformance/es6/destructuring/missingAndExcessProperties.ts(14,8): error TS2459: Type '{ y?: number; }' has no property 'x' and no string index signature. +tests/cases/conformance/es6/destructuring/missingAndExcessProperties.ts(20,17): error TS2353: Object literal may only specify known properties, and 'x' does not exist in type '{}'. +tests/cases/conformance/es6/destructuring/missingAndExcessProperties.ts(20,23): error TS2353: Object literal may only specify known properties, and 'y' does not exist in type '{}'. +tests/cases/conformance/es6/destructuring/missingAndExcessProperties.ts(21,25): error TS2353: Object literal may only specify known properties, and 'y' does not exist in type '{ x: any; }'. +tests/cases/conformance/es6/destructuring/missingAndExcessProperties.ts(22,19): error TS2353: Object literal may only specify known properties, and 'x' does not exist in type '{ y: any; }'. +tests/cases/conformance/es6/destructuring/missingAndExcessProperties.ts(29,14): error TS2353: Object literal may only specify known properties, and 'x' does not exist in type '{}'. +tests/cases/conformance/es6/destructuring/missingAndExcessProperties.ts(29,20): error TS2353: Object literal may only specify known properties, and 'y' does not exist in type '{}'. +tests/cases/conformance/es6/destructuring/missingAndExcessProperties.ts(30,22): error TS2353: Object literal may only specify known properties, and 'y' does not exist in type '{ x: number; }'. +tests/cases/conformance/es6/destructuring/missingAndExcessProperties.ts(31,16): error TS2353: Object literal may only specify known properties, and 'x' does not exist in type '{ y: number; }'. + + +==== tests/cases/conformance/es6/destructuring/missingAndExcessProperties.ts (16 errors) ==== + // Missing properties + function f1() { + var { x, y } = {}; + ~ +!!! error TS2459: Type '{}' has no property 'x' and no string index signature. + ~ +!!! error TS2459: Type '{}' has no property 'y' and no string index signature. + var { x = 1, y } = {}; + ~ +!!! error TS2459: Type '{ x?: number; }' has no property 'y' and no string index signature. + var { x, y = 1 } = {}; + ~ +!!! error TS2459: Type '{ y?: number; }' has no property 'x' and no string index signature. + var { x = 1, y = 1 } = {}; + } + + // Missing properties + function f2() { + var x: number, y: number; + ({ x, y } = {}); + ~ +!!! error TS2459: Type '{}' has no property 'x' and no string index signature. + ~ +!!! error TS2459: Type '{}' has no property 'y' and no string index signature. + ({ x: x = 1, y } = {}); + ~ +!!! error TS2459: Type '{ x?: number; }' has no property 'y' and no string index signature. + ({ x, y: y = 1 } = {}); + ~ +!!! error TS2459: Type '{ y?: number; }' has no property 'x' and no string index signature. + ({ x: x = 1, y: y = 1 } = {}); + } + + // Excess properties + function f3() { + var { } = { x: 0, y: 0 }; + ~ +!!! error TS2353: Object literal may only specify known properties, and 'x' does not exist in type '{}'. + ~ +!!! error TS2353: Object literal may only specify known properties, and 'y' does not exist in type '{}'. + var { x } = { x: 0, y: 0 }; + ~ +!!! error TS2353: Object literal may only specify known properties, and 'y' does not exist in type '{ x: any; }'. + var { y } = { x: 0, y: 0 }; + ~ +!!! error TS2353: Object literal may only specify known properties, and 'x' does not exist in type '{ y: any; }'. + var { x, y } = { x: 0, y: 0 }; + } + + // Excess properties + function f4() { + var x: number, y: number; + ({ } = { x: 0, y: 0 }); + ~ +!!! error TS2353: Object literal may only specify known properties, and 'x' does not exist in type '{}'. + ~ +!!! error TS2353: Object literal may only specify known properties, and 'y' does not exist in type '{}'. + ({ x } = { x: 0, y: 0 }); + ~ +!!! error TS2353: Object literal may only specify known properties, and 'y' does not exist in type '{ x: number; }'. + ({ y } = { x: 0, y: 0 }); + ~ +!!! error TS2353: Object literal may only specify known properties, and 'x' does not exist in type '{ y: number; }'. + ({ x, y } = { x: 0, y: 0 }); + } + \ No newline at end of file diff --git a/tests/baselines/reference/missingAndExcessProperties.js b/tests/baselines/reference/missingAndExcessProperties.js new file mode 100644 index 00000000000..b9fcadd9519 --- /dev/null +++ b/tests/baselines/reference/missingAndExcessProperties.js @@ -0,0 +1,69 @@ +//// [missingAndExcessProperties.ts] +// Missing properties +function f1() { + var { x, y } = {}; + var { x = 1, y } = {}; + var { x, y = 1 } = {}; + var { x = 1, y = 1 } = {}; +} + +// Missing properties +function f2() { + var x: number, y: number; + ({ x, y } = {}); + ({ x: x = 1, y } = {}); + ({ x, y: y = 1 } = {}); + ({ x: x = 1, y: y = 1 } = {}); +} + +// Excess properties +function f3() { + var { } = { x: 0, y: 0 }; + var { x } = { x: 0, y: 0 }; + var { y } = { x: 0, y: 0 }; + var { x, y } = { x: 0, y: 0 }; +} + +// Excess properties +function f4() { + var x: number, y: number; + ({ } = { x: 0, y: 0 }); + ({ x } = { x: 0, y: 0 }); + ({ y } = { x: 0, y: 0 }); + ({ x, y } = { x: 0, y: 0 }); +} + + +//// [missingAndExcessProperties.js] +// Missing properties +function f1() { + var _a = {}, x = _a.x, y = _a.y; + var _b = {}, _c = _b.x, x = _c === void 0 ? 1 : _c, y = _b.y; + var _d = {}, x = _d.x, _e = _d.y, y = _e === void 0 ? 1 : _e; + var _f = {}, _g = _f.x, x = _g === void 0 ? 1 : _g, _h = _f.y, y = _h === void 0 ? 1 : _h; +} +// Missing properties +function f2() { + var x, y; + (_a = {}, x = _a.x, y = _a.y, _a); + (_b = {}, _c = _b.x, x = _c === void 0 ? 1 : _c, y = _b.y, _b); + (_d = {}, x = _d.x, _e = _d.y, y = _e === void 0 ? 1 : _e, _d); + (_f = {}, _g = _f.x, x = _g === void 0 ? 1 : _g, _h = _f.y, y = _h === void 0 ? 1 : _h, _f); + var _a, _b, _c, _d, _e, _f, _g, _h; +} +// Excess properties +function f3() { + var _a = { x: 0, y: 0 }; + var x = { x: 0, y: 0 }.x; + var y = { x: 0, y: 0 }.y; + var _b = { x: 0, y: 0 }, x = _b.x, y = _b.y; +} +// Excess properties +function f4() { + var x, y; + ({ x: 0, y: 0 }); + (_a = { x: 0, y: 0 }, x = _a.x, _a); + (_b = { x: 0, y: 0 }, y = _b.y, _b); + (_c = { x: 0, y: 0 }, x = _c.x, y = _c.y, _c); + var _a, _b, _c; +} diff --git a/tests/cases/conformance/es6/destructuring/missingAndExcessProperties.ts b/tests/cases/conformance/es6/destructuring/missingAndExcessProperties.ts new file mode 100644 index 00000000000..ef91b8249da --- /dev/null +++ b/tests/cases/conformance/es6/destructuring/missingAndExcessProperties.ts @@ -0,0 +1,33 @@ +// Missing properties +function f1() { + var { x, y } = {}; + var { x = 1, y } = {}; + var { x, y = 1 } = {}; + var { x = 1, y = 1 } = {}; +} + +// Missing properties +function f2() { + var x: number, y: number; + ({ x, y } = {}); + ({ x: x = 1, y } = {}); + ({ x, y: y = 1 } = {}); + ({ x: x = 1, y: y = 1 } = {}); +} + +// Excess properties +function f3() { + var { } = { x: 0, y: 0 }; + var { x } = { x: 0, y: 0 }; + var { y } = { x: 0, y: 0 }; + var { x, y } = { x: 0, y: 0 }; +} + +// Excess properties +function f4() { + var x: number, y: number; + ({ } = { x: 0, y: 0 }); + ({ x } = { x: 0, y: 0 }); + ({ y } = { x: 0, y: 0 }); + ({ x, y } = { x: 0, y: 0 }); +} From 546da60a2a9321d50856e28c10bee8be3264c0e2 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Sun, 6 Sep 2015 08:54:38 -0700 Subject: [PATCH 090/117] Correct propagation of includePatternInType flag --- src/compiler/checker.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 6f617d69798..91234ebb387 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -2416,12 +2416,12 @@ namespace ts { // Return the type implied by a binding pattern element. This is the type of the initializer of the element if // one is present. Otherwise, if the element is itself a binding pattern, it is the type implied by the binding // pattern. Otherwise, it is the type any. - function getTypeFromBindingElement(element: BindingElement): Type { + function getTypeFromBindingElement(element: BindingElement, includePatternInType?: boolean): Type { if (element.initializer) { return getWidenedType(checkExpressionCached(element.initializer)); } if (isBindingPattern(element.name)) { - return getTypeFromBindingPattern(element.name, /*includePatternInType*/ false); + return getTypeFromBindingPattern(element.name, includePatternInType); } return anyType; } @@ -2433,7 +2433,7 @@ namespace ts { let flags = SymbolFlags.Property | SymbolFlags.Transient | (e.initializer ? SymbolFlags.Optional : 0); let name = e.propertyName || e.name; let symbol = createSymbol(flags, name.text); - symbol.type = getTypeFromBindingElement(e); + symbol.type = getTypeFromBindingElement(e, includePatternInType); members[symbol.name] = symbol; }); let result = createAnonymousType(undefined, members, emptyArray, emptyArray, undefined, undefined); @@ -2450,7 +2450,7 @@ namespace ts { return languageVersion >= ScriptTarget.ES6 ? createIterableType(anyType) : anyArrayType; } // If the pattern has at least one element, and no rest element, then it should imply a tuple type. - let elementTypes = map(elements, e => e.kind === SyntaxKind.OmittedExpression ? anyType : getTypeFromBindingElement(e)); + let elementTypes = map(elements, e => e.kind === SyntaxKind.OmittedExpression ? anyType : getTypeFromBindingElement(e, includePatternInType)); let result = createTupleType(elementTypes); if (includePatternInType) { result = clone(result); From 27380f40dccd2b0df0c2b7356e1efff86cded02f Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Sun, 6 Sep 2015 08:55:13 -0700 Subject: [PATCH 091/117] Adding test --- .../destructuring/destructuringWithLiteralInitializers.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tests/cases/conformance/es6/destructuring/destructuringWithLiteralInitializers.ts b/tests/cases/conformance/es6/destructuring/destructuringWithLiteralInitializers.ts index 04298d8cbd7..dd3a0ae28a6 100644 --- a/tests/cases/conformance/es6/destructuring/destructuringWithLiteralInitializers.ts +++ b/tests/cases/conformance/es6/destructuring/destructuringWithLiteralInitializers.ts @@ -33,6 +33,14 @@ f6({ x: 1 }); f6({ y: 1 }); f6({ x: 1, y: 1 }); +// (arg?: { a: { x?: number, y?: number } }) => void +function f7({ a: { x = 0, y = 0 } } = { a: {} }) { } +f7(); +f7({ a: {} }); +f7({ a: { x: 1 } }); +f7({ a: { y: 1 } }); +f7({ a: { x: 1, y: 1 } }); + // (arg: [any, any]) => void function g1([x, y]) { } g1([1, 1]); From 055363c98deaf588dd74fa4bd6215d26382b794b Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Sun, 6 Sep 2015 08:55:48 -0700 Subject: [PATCH 092/117] Accepting new baselines --- ...ArrayBindingPatternAndAssignment1ES5.types | 14 ++-- ...ArrayBindingPatternAndAssignment1ES6.types | 14 ++-- ...destructuringVariableDeclaration1ES5.types | 6 +- ...destructuringVariableDeclaration1ES6.types | 6 +- .../destructuringWithLiteralInitializers.js | 17 ++++ ...structuringWithLiteralInitializers.symbols | 83 +++++++++++++------ ...destructuringWithLiteralInitializers.types | 52 ++++++++++++ 7 files changed, 146 insertions(+), 46 deletions(-) diff --git a/tests/baselines/reference/destructuringArrayBindingPatternAndAssignment1ES5.types b/tests/baselines/reference/destructuringArrayBindingPatternAndAssignment1ES5.types index 3af7b65c625..fcd71e85dbf 100644 --- a/tests/baselines/reference/destructuringArrayBindingPatternAndAssignment1ES5.types +++ b/tests/baselines/reference/destructuringArrayBindingPatternAndAssignment1ES5.types @@ -98,13 +98,13 @@ var [c2] = []; var [[[c3]], [[[[c4]]]]] = [[[]], [[[[]]]]] >c3 : any >c4 : any ->[[[]], [[[[]]]]] : [[undefined[]], [[[undefined[]]]]] ->[[]] : [undefined[]] ->[] : undefined[] ->[[[[]]]] : [[[undefined[]]]] ->[[[]]] : [[undefined[]]] ->[[]] : [undefined[]] ->[] : undefined[] +>[[[]], [[[[]]]]] : [[[undefined]], [[[[undefined]]]]] +>[[]] : [[undefined]] +>[] : [undefined] +>[[[[]]]] : [[[[undefined]]]] +>[[[]]] : [[[undefined]]] +>[[]] : [[undefined]] +>[] : [undefined] var [[c5], c6]: [[string|number], boolean] = [[1], true]; >c5 : string | number diff --git a/tests/baselines/reference/destructuringArrayBindingPatternAndAssignment1ES6.types b/tests/baselines/reference/destructuringArrayBindingPatternAndAssignment1ES6.types index cded5cdec8e..d154f091214 100644 --- a/tests/baselines/reference/destructuringArrayBindingPatternAndAssignment1ES6.types +++ b/tests/baselines/reference/destructuringArrayBindingPatternAndAssignment1ES6.types @@ -99,13 +99,13 @@ var [c2] = []; var [[[c3]], [[[[c4]]]]] = [[[]], [[[[]]]]] >c3 : any >c4 : any ->[[[]], [[[[]]]]] : [[undefined[]], [[[undefined[]]]]] ->[[]] : [undefined[]] ->[] : undefined[] ->[[[[]]]] : [[[undefined[]]]] ->[[[]]] : [[undefined[]]] ->[[]] : [undefined[]] ->[] : undefined[] +>[[[]], [[[[]]]]] : [[[undefined]], [[[[undefined]]]]] +>[[]] : [[undefined]] +>[] : [undefined] +>[[[[]]]] : [[[[undefined]]]] +>[[[]]] : [[[undefined]]] +>[[]] : [[undefined]] +>[] : [undefined] var [[c5], c6]: [[string|number], boolean] = [[1], true]; >c5 : string | number diff --git a/tests/baselines/reference/destructuringVariableDeclaration1ES5.types b/tests/baselines/reference/destructuringVariableDeclaration1ES5.types index 620ad90d414..c024fdfe862 100644 --- a/tests/baselines/reference/destructuringVariableDeclaration1ES5.types +++ b/tests/baselines/reference/destructuringVariableDeclaration1ES5.types @@ -151,9 +151,9 @@ var {f: [f1, f2, { f3: f4, f5 }, , ]} = { f: [1, 2, { f3: 4, f5: 0 }] }; >f4 : number >f5 : number > : undefined ->{ f: [1, 2, { f3: 4, f5: 0 }] } : { f: [number, number, { f3: number; f5: number; }]; } ->f : [number, number, { f3: number; f5: number; }] ->[1, 2, { f3: 4, f5: 0 }] : [number, number, { f3: number; f5: number; }] +>{ f: [1, 2, { f3: 4, f5: 0 }] } : { f: [number, number, { f3: number; f5: number; }, undefined]; } +>f : [number, number, { f3: number; f5: number; }, undefined] +>[1, 2, { f3: 4, f5: 0 }] : [number, number, { f3: number; f5: number; }, undefined] >1 : number >2 : number >{ f3: 4, f5: 0 } : { f3: number; f5: number; } diff --git a/tests/baselines/reference/destructuringVariableDeclaration1ES6.types b/tests/baselines/reference/destructuringVariableDeclaration1ES6.types index a3004f87c82..730abd843a2 100644 --- a/tests/baselines/reference/destructuringVariableDeclaration1ES6.types +++ b/tests/baselines/reference/destructuringVariableDeclaration1ES6.types @@ -151,9 +151,9 @@ var {f: [f1, f2, { f3: f4, f5 }, , ]} = { f: [1, 2, { f3: 4, f5: 0 }] }; >f4 : number >f5 : number > : undefined ->{ f: [1, 2, { f3: 4, f5: 0 }] } : { f: [number, number, { f3: number; f5: number; }]; } ->f : [number, number, { f3: number; f5: number; }] ->[1, 2, { f3: 4, f5: 0 }] : [number, number, { f3: number; f5: number; }] +>{ f: [1, 2, { f3: 4, f5: 0 }] } : { f: [number, number, { f3: number; f5: number; }, undefined]; } +>f : [number, number, { f3: number; f5: number; }, undefined] +>[1, 2, { f3: 4, f5: 0 }] : [number, number, { f3: number; f5: number; }, undefined] >1 : number >2 : number >{ f3: 4, f5: 0 } : { f3: number; f5: number; } diff --git a/tests/baselines/reference/destructuringWithLiteralInitializers.js b/tests/baselines/reference/destructuringWithLiteralInitializers.js index a8251435d39..640b5a37756 100644 --- a/tests/baselines/reference/destructuringWithLiteralInitializers.js +++ b/tests/baselines/reference/destructuringWithLiteralInitializers.js @@ -34,6 +34,14 @@ f6({ x: 1 }); f6({ y: 1 }); f6({ x: 1, y: 1 }); +// (arg?: { a: { x?: number, y?: number } }) => void +function f7({ a: { x = 0, y = 0 } } = { a: {} }) { } +f7(); +f7({ a: {} }); +f7({ a: { x: 1 } }); +f7({ a: { y: 1 } }); +f7({ a: { x: 1, y: 1 } }); + // (arg: [any, any]) => void function g1([x, y]) { } g1([1, 1]); @@ -95,6 +103,15 @@ f6({}); f6({ x: 1 }); f6({ y: 1 }); f6({ x: 1, y: 1 }); +// (arg?: { a: { x?: number, y?: number } }) => void +function f7(_a) { + var _b = (_a === void 0 ? { a: {} } : _a).a, _c = _b.x, x = _c === void 0 ? 0 : _c, _d = _b.y, y = _d === void 0 ? 0 : _d; +} +f7(); +f7({ a: {} }); +f7({ a: { x: 1 } }); +f7({ a: { y: 1 } }); +f7({ a: { x: 1, y: 1 } }); // (arg: [any, any]) => void function g1(_a) { var x = _a[0], y = _a[1]; diff --git a/tests/baselines/reference/destructuringWithLiteralInitializers.symbols b/tests/baselines/reference/destructuringWithLiteralInitializers.symbols index 9dc3960f2af..fc8c7a2f621 100644 --- a/tests/baselines/reference/destructuringWithLiteralInitializers.symbols +++ b/tests/baselines/reference/destructuringWithLiteralInitializers.symbols @@ -107,45 +107,76 @@ f6({ x: 1, y: 1 }); >x : Symbol(x, Decl(destructuringWithLiteralInitializers.ts, 33, 4)) >y : Symbol(y, Decl(destructuringWithLiteralInitializers.ts, 33, 10)) +// (arg?: { a: { x?: number, y?: number } }) => void +function f7({ a: { x = 0, y = 0 } } = { a: {} }) { } +>f7 : Symbol(f7, Decl(destructuringWithLiteralInitializers.ts, 33, 19)) +>a : Symbol(a, Decl(destructuringWithLiteralInitializers.ts, 36, 39)) +>x : Symbol(x, Decl(destructuringWithLiteralInitializers.ts, 36, 18)) +>y : Symbol(y, Decl(destructuringWithLiteralInitializers.ts, 36, 25)) +>a : Symbol(a, Decl(destructuringWithLiteralInitializers.ts, 36, 39)) + +f7(); +>f7 : Symbol(f7, Decl(destructuringWithLiteralInitializers.ts, 33, 19)) + +f7({ a: {} }); +>f7 : Symbol(f7, Decl(destructuringWithLiteralInitializers.ts, 33, 19)) +>a : Symbol(a, Decl(destructuringWithLiteralInitializers.ts, 38, 4)) + +f7({ a: { x: 1 } }); +>f7 : Symbol(f7, Decl(destructuringWithLiteralInitializers.ts, 33, 19)) +>a : Symbol(a, Decl(destructuringWithLiteralInitializers.ts, 39, 4)) +>x : Symbol(x, Decl(destructuringWithLiteralInitializers.ts, 39, 9)) + +f7({ a: { y: 1 } }); +>f7 : Symbol(f7, Decl(destructuringWithLiteralInitializers.ts, 33, 19)) +>a : Symbol(a, Decl(destructuringWithLiteralInitializers.ts, 40, 4)) +>y : Symbol(y, Decl(destructuringWithLiteralInitializers.ts, 40, 9)) + +f7({ a: { x: 1, y: 1 } }); +>f7 : Symbol(f7, Decl(destructuringWithLiteralInitializers.ts, 33, 19)) +>a : Symbol(a, Decl(destructuringWithLiteralInitializers.ts, 41, 4)) +>x : Symbol(x, Decl(destructuringWithLiteralInitializers.ts, 41, 9)) +>y : Symbol(y, Decl(destructuringWithLiteralInitializers.ts, 41, 15)) + // (arg: [any, any]) => void function g1([x, y]) { } ->g1 : Symbol(g1, Decl(destructuringWithLiteralInitializers.ts, 33, 19)) ->x : Symbol(x, Decl(destructuringWithLiteralInitializers.ts, 36, 13)) ->y : Symbol(y, Decl(destructuringWithLiteralInitializers.ts, 36, 15)) - -g1([1, 1]); ->g1 : Symbol(g1, Decl(destructuringWithLiteralInitializers.ts, 33, 19)) - -// (arg: [number, number]) => void -function g2([x = 0, y = 0]) { } ->g2 : Symbol(g2, Decl(destructuringWithLiteralInitializers.ts, 37, 11)) ->x : Symbol(x, Decl(destructuringWithLiteralInitializers.ts, 40, 13)) ->y : Symbol(y, Decl(destructuringWithLiteralInitializers.ts, 40, 19)) - -g2([1, 1]); ->g2 : Symbol(g2, Decl(destructuringWithLiteralInitializers.ts, 37, 11)) - -// (arg?: [any, any]) => void -function g3([x, y] = []) { } ->g3 : Symbol(g3, Decl(destructuringWithLiteralInitializers.ts, 41, 11)) +>g1 : Symbol(g1, Decl(destructuringWithLiteralInitializers.ts, 41, 26)) >x : Symbol(x, Decl(destructuringWithLiteralInitializers.ts, 44, 13)) >y : Symbol(y, Decl(destructuringWithLiteralInitializers.ts, 44, 15)) +g1([1, 1]); +>g1 : Symbol(g1, Decl(destructuringWithLiteralInitializers.ts, 41, 26)) + +// (arg: [number, number]) => void +function g2([x = 0, y = 0]) { } +>g2 : Symbol(g2, Decl(destructuringWithLiteralInitializers.ts, 45, 11)) +>x : Symbol(x, Decl(destructuringWithLiteralInitializers.ts, 48, 13)) +>y : Symbol(y, Decl(destructuringWithLiteralInitializers.ts, 48, 19)) + +g2([1, 1]); +>g2 : Symbol(g2, Decl(destructuringWithLiteralInitializers.ts, 45, 11)) + +// (arg?: [any, any]) => void +function g3([x, y] = []) { } +>g3 : Symbol(g3, Decl(destructuringWithLiteralInitializers.ts, 49, 11)) +>x : Symbol(x, Decl(destructuringWithLiteralInitializers.ts, 52, 13)) +>y : Symbol(y, Decl(destructuringWithLiteralInitializers.ts, 52, 15)) + g3(); ->g3 : Symbol(g3, Decl(destructuringWithLiteralInitializers.ts, 41, 11)) +>g3 : Symbol(g3, Decl(destructuringWithLiteralInitializers.ts, 49, 11)) g3([1, 1]); ->g3 : Symbol(g3, Decl(destructuringWithLiteralInitializers.ts, 41, 11)) +>g3 : Symbol(g3, Decl(destructuringWithLiteralInitializers.ts, 49, 11)) // (arg?: [number, number]) => void function g4([x, y] = [0, 0]) { } ->g4 : Symbol(g4, Decl(destructuringWithLiteralInitializers.ts, 46, 11)) ->x : Symbol(x, Decl(destructuringWithLiteralInitializers.ts, 49, 13)) ->y : Symbol(y, Decl(destructuringWithLiteralInitializers.ts, 49, 15)) +>g4 : Symbol(g4, Decl(destructuringWithLiteralInitializers.ts, 54, 11)) +>x : Symbol(x, Decl(destructuringWithLiteralInitializers.ts, 57, 13)) +>y : Symbol(y, Decl(destructuringWithLiteralInitializers.ts, 57, 15)) g4(); ->g4 : Symbol(g4, Decl(destructuringWithLiteralInitializers.ts, 46, 11)) +>g4 : Symbol(g4, Decl(destructuringWithLiteralInitializers.ts, 54, 11)) g4([1, 1]); ->g4 : Symbol(g4, Decl(destructuringWithLiteralInitializers.ts, 46, 11)) +>g4 : Symbol(g4, Decl(destructuringWithLiteralInitializers.ts, 54, 11)) diff --git a/tests/baselines/reference/destructuringWithLiteralInitializers.types b/tests/baselines/reference/destructuringWithLiteralInitializers.types index 7807ba201c3..97c07bc281d 100644 --- a/tests/baselines/reference/destructuringWithLiteralInitializers.types +++ b/tests/baselines/reference/destructuringWithLiteralInitializers.types @@ -168,6 +168,58 @@ f6({ x: 1, y: 1 }); >y : number >1 : number +// (arg?: { a: { x?: number, y?: number } }) => void +function f7({ a: { x = 0, y = 0 } } = { a: {} }) { } +>f7 : ({ a: { x = 0, y = 0 } }?: { a: { x?: number; y?: number; }; }) => void +>a : any +>x : number +>0 : number +>y : number +>0 : number +>{ a: {} } : { a: { x?: number; y?: number; }; } +>a : { x?: number; y?: number; } +>{} : { x?: number; y?: number; } + +f7(); +>f7() : void +>f7 : ({ a: { x = 0, y = 0 } }?: { a: { x?: number; y?: number; }; }) => void + +f7({ a: {} }); +>f7({ a: {} }) : void +>f7 : ({ a: { x = 0, y = 0 } }?: { a: { x?: number; y?: number; }; }) => void +>{ a: {} } : { a: {}; } +>a : {} +>{} : {} + +f7({ a: { x: 1 } }); +>f7({ a: { x: 1 } }) : void +>f7 : ({ a: { x = 0, y = 0 } }?: { a: { x?: number; y?: number; }; }) => void +>{ a: { x: 1 } } : { a: { x: number; }; } +>a : { x: number; } +>{ x: 1 } : { x: number; } +>x : number +>1 : number + +f7({ a: { y: 1 } }); +>f7({ a: { y: 1 } }) : void +>f7 : ({ a: { x = 0, y = 0 } }?: { a: { x?: number; y?: number; }; }) => void +>{ a: { y: 1 } } : { a: { y: number; }; } +>a : { y: number; } +>{ y: 1 } : { y: number; } +>y : number +>1 : number + +f7({ a: { x: 1, y: 1 } }); +>f7({ a: { x: 1, y: 1 } }) : void +>f7 : ({ a: { x = 0, y = 0 } }?: { a: { x?: number; y?: number; }; }) => void +>{ a: { x: 1, y: 1 } } : { a: { x: number; y: number; }; } +>a : { x: number; y: number; } +>{ x: 1, y: 1 } : { x: number; y: number; } +>x : number +>1 : number +>y : number +>1 : number + // (arg: [any, any]) => void function g1([x, y]) { } >g1 : ([x, y]: [any, any]) => void From 83214150f8eb7bb6360769d745652ccaa21ba5e3 Mon Sep 17 00:00:00 2001 From: Vladimir Matveev Date: Tue, 8 Sep 2015 18:40:30 -0700 Subject: [PATCH 093/117] do not emit '=' in jsx attribute if initializer is missing --- src/compiler/emitter.ts | 6 ++++-- .../reference/jsxEmitAttributeWithPreserve.js | 7 +++++++ .../reference/jsxEmitAttributeWithPreserve.symbols | 8 ++++++++ .../reference/jsxEmitAttributeWithPreserve.types | 10 ++++++++++ .../baselines/reference/jsxInvalidEsprimaTestSuite.js | 6 +++--- tests/baselines/reference/jsxReactTestSuite.js | 4 ++-- tests/baselines/reference/tsxAttributeResolution6.js | 6 +++--- .../reference/tsxGenericArrowFunctionParsing.js | 2 +- tests/cases/compiler/jsxEmitAttributeWithPreserve.tsx | 4 ++++ 9 files changed, 42 insertions(+), 11 deletions(-) create mode 100644 tests/baselines/reference/jsxEmitAttributeWithPreserve.js create mode 100644 tests/baselines/reference/jsxEmitAttributeWithPreserve.symbols create mode 100644 tests/baselines/reference/jsxEmitAttributeWithPreserve.types create mode 100644 tests/cases/compiler/jsxEmitAttributeWithPreserve.tsx diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index d84b7b70ada..c83c743e4a2 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -1292,8 +1292,10 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi function jsxEmitPreserve(node: JsxElement|JsxSelfClosingElement) { function emitJsxAttribute(node: JsxAttribute) { emit(node.name); - write("="); - emit(node.initializer); + if (node.initializer) { + write("="); + emit(node.initializer); + } } function emitJsxSpreadAttribute(node: JsxSpreadAttribute) { diff --git a/tests/baselines/reference/jsxEmitAttributeWithPreserve.js b/tests/baselines/reference/jsxEmitAttributeWithPreserve.js new file mode 100644 index 00000000000..07cb0dee485 --- /dev/null +++ b/tests/baselines/reference/jsxEmitAttributeWithPreserve.js @@ -0,0 +1,7 @@ +//// [jsxEmitAttributeWithPreserve.tsx] + +declare var React: any; + + +//// [jsxEmitAttributeWithPreserve.jsx] +; diff --git a/tests/baselines/reference/jsxEmitAttributeWithPreserve.symbols b/tests/baselines/reference/jsxEmitAttributeWithPreserve.symbols new file mode 100644 index 00000000000..4ffadb8e888 --- /dev/null +++ b/tests/baselines/reference/jsxEmitAttributeWithPreserve.symbols @@ -0,0 +1,8 @@ +=== tests/cases/compiler/jsxEmitAttributeWithPreserve.tsx === + +declare var React: any; +>React : Symbol(React, Decl(jsxEmitAttributeWithPreserve.tsx, 1, 11)) + + +>data : Symbol(unknown) + diff --git a/tests/baselines/reference/jsxEmitAttributeWithPreserve.types b/tests/baselines/reference/jsxEmitAttributeWithPreserve.types new file mode 100644 index 00000000000..972ca1c3d88 --- /dev/null +++ b/tests/baselines/reference/jsxEmitAttributeWithPreserve.types @@ -0,0 +1,10 @@ +=== tests/cases/compiler/jsxEmitAttributeWithPreserve.tsx === + +declare var React: any; +>React : any + + +> : any +>foo : any +>data : any + diff --git a/tests/baselines/reference/jsxInvalidEsprimaTestSuite.js b/tests/baselines/reference/jsxInvalidEsprimaTestSuite.js index daf344b08da..d623e127be7 100644 --- a/tests/baselines/reference/jsxInvalidEsprimaTestSuite.js +++ b/tests/baselines/reference/jsxInvalidEsprimaTestSuite.js @@ -47,9 +47,9 @@ a / > ; < a; b > ; b > ; -; +; b.c > ; -; +; c > ; ; < .a > ; @@ -67,7 +67,7 @@ var x =
one
two
;; var x =
one
/* intervening comment */ /* intervening comment */
two
;; {"str"}}; id="b" />; -
>; +
>;
;
stuff
...props}>; diff --git a/tests/baselines/reference/jsxReactTestSuite.js b/tests/baselines/reference/jsxReactTestSuite.js index 300274a1614..18013d4be9b 100644 --- a/tests/baselines/reference/jsxReactTestSuite.js +++ b/tests/baselines/reference/jsxReactTestSuite.js @@ -158,14 +158,14 @@ var x =
; ; ; -; +; ; ; ; ; ; ; -; +; ; ; Text; diff --git a/tests/baselines/reference/tsxAttributeResolution6.js b/tests/baselines/reference/tsxAttributeResolution6.js index f4af0ba875a..5d6ad1e20c6 100644 --- a/tests/baselines/reference/tsxAttributeResolution6.js +++ b/tests/baselines/reference/tsxAttributeResolution6.js @@ -20,10 +20,10 @@ declare module JSX { //// [tsxAttributeResolution6.jsx] // Error -; +; ; ; // OK -; +; ; -; +; diff --git a/tests/baselines/reference/tsxGenericArrowFunctionParsing.js b/tests/baselines/reference/tsxGenericArrowFunctionParsing.js index f493347ca9c..ece48831f8e 100644 --- a/tests/baselines/reference/tsxGenericArrowFunctionParsing.js +++ b/tests/baselines/reference/tsxGenericArrowFunctionParsing.js @@ -42,5 +42,5 @@ x3(); var x4 = () => ; x4.isElement; // This is an element -var x5 = () => ; +var x5 = () => ; x5.isElement; diff --git a/tests/cases/compiler/jsxEmitAttributeWithPreserve.tsx b/tests/cases/compiler/jsxEmitAttributeWithPreserve.tsx new file mode 100644 index 00000000000..dc32ef7a0ca --- /dev/null +++ b/tests/cases/compiler/jsxEmitAttributeWithPreserve.tsx @@ -0,0 +1,4 @@ +//@jsx: preserve + +declare var React: any; + \ No newline at end of file From aa29644c2a17a9ea20aca894bf67c44c78f46b2d Mon Sep 17 00:00:00 2001 From: Vladimir Matveev Date: Tue, 8 Sep 2015 22:40:16 -0700 Subject: [PATCH 094/117] allow to use keywords as jsx identifiers --- src/compiler/parser.ts | 6 +++++- src/compiler/scanner.ts | 2 +- tests/baselines/reference/keywordInJsxIdentifier.js | 7 +++++++ .../baselines/reference/keywordInJsxIdentifier.symbols | 8 ++++++++ tests/baselines/reference/keywordInJsxIdentifier.types | 10 ++++++++++ tests/cases/compiler/keywordInJsxIdentifier.tsx | 4 ++++ 6 files changed, 35 insertions(+), 2 deletions(-) create mode 100644 tests/baselines/reference/keywordInJsxIdentifier.js create mode 100644 tests/baselines/reference/keywordInJsxIdentifier.symbols create mode 100644 tests/baselines/reference/keywordInJsxIdentifier.types create mode 100644 tests/cases/compiler/keywordInJsxIdentifier.tsx diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index 350b9d450b8..57e19156568 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -12,6 +12,10 @@ namespace ts { export function createNode(kind: SyntaxKind): Node { return new (getNodeConstructor(kind))(); } + + export function tokenIsIdentifierOrKeyword(token: SyntaxKind): boolean { + return token >= SyntaxKind.Identifier; + } function visitNode(cbNode: (node: Node) => T, node: Node): T { if (node) { @@ -4102,7 +4106,7 @@ namespace ts { } function isIdentifierOrKeyword() { - return token >= SyntaxKind.Identifier; + return tokenIsIdentifierOrKeyword(token); } function nextTokenIsIdentifierOrKeywordOnSameLine() { diff --git a/src/compiler/scanner.ts b/src/compiler/scanner.ts index 199e7e9b638..2e10a1f1b84 100644 --- a/src/compiler/scanner.ts +++ b/src/compiler/scanner.ts @@ -1590,7 +1590,7 @@ namespace ts { // Scans a JSX identifier; these differ from normal identifiers in that // they allow dashes function scanJsxIdentifier(): SyntaxKind { - if (token === SyntaxKind.Identifier) { + if (tokenIsIdentifierOrKeyword(token)) { let firstCharPosition = pos; while (pos < end) { let ch = text.charCodeAt(pos); diff --git a/tests/baselines/reference/keywordInJsxIdentifier.js b/tests/baselines/reference/keywordInJsxIdentifier.js new file mode 100644 index 00000000000..8a00a68e334 --- /dev/null +++ b/tests/baselines/reference/keywordInJsxIdentifier.js @@ -0,0 +1,7 @@ +//// [keywordInJsxIdentifier.tsx] + +declare var React: any; + + +//// [keywordInJsxIdentifier.js] +React.createElement("foo", {"class-id": true}); diff --git a/tests/baselines/reference/keywordInJsxIdentifier.symbols b/tests/baselines/reference/keywordInJsxIdentifier.symbols new file mode 100644 index 00000000000..6617a640dca --- /dev/null +++ b/tests/baselines/reference/keywordInJsxIdentifier.symbols @@ -0,0 +1,8 @@ +=== tests/cases/compiler/keywordInJsxIdentifier.tsx === + +declare var React: any; +>React : Symbol(React, Decl(keywordInJsxIdentifier.tsx, 1, 11)) + + +>class-id : Symbol(unknown) + diff --git a/tests/baselines/reference/keywordInJsxIdentifier.types b/tests/baselines/reference/keywordInJsxIdentifier.types new file mode 100644 index 00000000000..888d027fddb --- /dev/null +++ b/tests/baselines/reference/keywordInJsxIdentifier.types @@ -0,0 +1,10 @@ +=== tests/cases/compiler/keywordInJsxIdentifier.tsx === + +declare var React: any; +>React : any + + +> : any +>foo : any +>class-id : any + diff --git a/tests/cases/compiler/keywordInJsxIdentifier.tsx b/tests/cases/compiler/keywordInJsxIdentifier.tsx new file mode 100644 index 00000000000..8c09c90b170 --- /dev/null +++ b/tests/cases/compiler/keywordInJsxIdentifier.tsx @@ -0,0 +1,4 @@ +//@jsx: react + +declare var React: any; + \ No newline at end of file From 44009fa9512b8bf64c20f8e3849742f65f0d22f5 Mon Sep 17 00:00:00 2001 From: SaschaNaz Date: Thu, 10 Sep 2015 01:37:34 +0900 Subject: [PATCH 095/117] Housekeeping part from #4609 --- src/services/formatting/rules.ts | 39 +++++++++----------------------- 1 file changed, 11 insertions(+), 28 deletions(-) diff --git a/src/services/formatting/rules.ts b/src/services/formatting/rules.ts index 876efa3a9e1..38a2bb74372 100644 --- a/src/services/formatting/rules.ts +++ b/src/services/formatting/rules.ts @@ -213,25 +213,15 @@ namespace ts.formatting { public NoSpaceBetweenYieldKeywordAndStar: Rule; public SpaceBetweenYieldOrYieldStarAndOperand: Rule; - // Async-await + // Async functions public SpaceBetweenAsyncAndFunctionKeyword: Rule; - public NoSpaceBetweenAsyncAndFunctionKeyword: Rule; - public SpaceAfterAwaitKeyword: Rule; - public NoSpaceAfterAwaitKeyword: Rule; - - // Type alias declaration - public SpaceAfterTypeKeyword: Rule; - public NoSpaceAfterTypeKeyword: Rule; // Tagged template string public SpaceBetweenTagAndTemplateString: Rule; - public NoSpaceBetweenTagAndTemplateString: Rule; // Type operation public SpaceBeforeBar: Rule; - public NoSpaceBeforeBar: Rule; public SpaceAfterBar: Rule; - public NoSpaceAfterBar: Rule; public SpaceBeforeAmpersand: Rule; public SpaceAfterAmpersand: Rule; @@ -315,7 +305,7 @@ namespace ts.formatting { this.NoSpaceBeforeComma = new Rule(RuleDescriptor.create2(Shared.TokenRange.Any, SyntaxKind.CommaToken), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Delete)); - this.SpaceAfterCertainKeywords = new Rule(RuleDescriptor.create4(Shared.TokenRange.FromTokens([SyntaxKind.VarKeyword, SyntaxKind.ThrowKeyword, SyntaxKind.NewKeyword, SyntaxKind.DeleteKeyword, SyntaxKind.ReturnKeyword, SyntaxKind.TypeOfKeyword]), Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Space)); + this.SpaceAfterCertainKeywords = new Rule(RuleDescriptor.create4(Shared.TokenRange.FromTokens([SyntaxKind.VarKeyword, SyntaxKind.ThrowKeyword, SyntaxKind.NewKeyword, SyntaxKind.DeleteKeyword, SyntaxKind.ReturnKeyword, SyntaxKind.TypeOfKeyword, SyntaxKind.AwaitKeyword]), Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Space)); this.SpaceAfterLetConstInVariableDeclaration = new Rule(RuleDescriptor.create4(Shared.TokenRange.FromTokens([SyntaxKind.LetKeyword, SyntaxKind.ConstKeyword]), Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsStartOfVariableDeclarationList), RuleAction.Space)); this.NoSpaceBeforeOpenParenInFuncCall = new Rule(RuleDescriptor.create2(Shared.TokenRange.Any, SyntaxKind.OpenParenToken), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsFunctionCallOrNewContext, Rules.IsPreviousTokenNotComma), RuleAction.Delete)); this.SpaceAfterFunctionInFuncDecl = new Rule(RuleDescriptor.create3(SyntaxKind.FunctionKeyword, Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsFunctionDeclContext), RuleAction.Space)); @@ -348,7 +338,12 @@ namespace ts.formatting { this.NoSpaceAfterModuleImport = new Rule(RuleDescriptor.create2(Shared.TokenRange.FromTokens([SyntaxKind.ModuleKeyword, SyntaxKind.RequireKeyword]), SyntaxKind.OpenParenToken), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Delete)); // Add a space around certain TypeScript keywords - this.SpaceAfterCertainTypeScriptKeywords = new Rule(RuleDescriptor.create4(Shared.TokenRange.FromTokens([SyntaxKind.AbstractKeyword, SyntaxKind.ClassKeyword, SyntaxKind.DeclareKeyword, SyntaxKind.DefaultKeyword, SyntaxKind.EnumKeyword, SyntaxKind.ExportKeyword, SyntaxKind.ExtendsKeyword, SyntaxKind.GetKeyword, SyntaxKind.ImplementsKeyword, SyntaxKind.ImportKeyword, SyntaxKind.InterfaceKeyword, SyntaxKind.ModuleKeyword, SyntaxKind.NamespaceKeyword, SyntaxKind.PrivateKeyword, SyntaxKind.PublicKeyword, SyntaxKind.ProtectedKeyword, SyntaxKind.SetKeyword, SyntaxKind.StaticKeyword]), Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Space)); + this.SpaceAfterCertainTypeScriptKeywords = new Rule(RuleDescriptor.create4(Shared.TokenRange.FromTokens([ + SyntaxKind.AbstractKeyword, SyntaxKind.ClassKeyword, SyntaxKind.DeclareKeyword, SyntaxKind.DefaultKeyword, SyntaxKind.EnumKeyword, SyntaxKind.ExportKeyword, + SyntaxKind.ExtendsKeyword, SyntaxKind.GetKeyword, SyntaxKind.ImplementsKeyword, SyntaxKind.ImportKeyword, SyntaxKind.InterfaceKeyword, SyntaxKind.ModuleKeyword, + SyntaxKind.NamespaceKeyword, SyntaxKind.PrivateKeyword, SyntaxKind.PublicKeyword, SyntaxKind.ProtectedKeyword, SyntaxKind.SetKeyword, SyntaxKind.StaticKeyword, + SyntaxKind.TypeKeyword + ]), Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Space)); this.SpaceBeforeCertainTypeScriptKeywords = new Rule(RuleDescriptor.create4(Shared.TokenRange.Any, Shared.TokenRange.FromTokens([SyntaxKind.ExtendsKeyword, SyntaxKind.ImplementsKeyword])), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Space)); // Treat string literals in module names as identifiers, and add a space between the literal and the opening Brace braces, e.g.: module "m2" { @@ -384,23 +379,13 @@ namespace ts.formatting { // Async-await this.SpaceBetweenAsyncAndFunctionKeyword = new Rule(RuleDescriptor.create1(SyntaxKind.AsyncKeyword, SyntaxKind.FunctionKeyword), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Space)); - this.NoSpaceBetweenAsyncAndFunctionKeyword = new Rule(RuleDescriptor.create1(SyntaxKind.AsyncKeyword, SyntaxKind.FunctionKeyword), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Delete)); - this.SpaceAfterAwaitKeyword = new Rule(RuleDescriptor.create3(SyntaxKind.AwaitKeyword, Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Space)); - this.NoSpaceAfterAwaitKeyword = new Rule(RuleDescriptor.create3(SyntaxKind.AwaitKeyword, Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Delete)); - - // Type alias declaration - this.SpaceAfterTypeKeyword = new Rule(RuleDescriptor.create3(SyntaxKind.TypeKeyword, Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Space)); - this.NoSpaceAfterTypeKeyword = new Rule(RuleDescriptor.create3(SyntaxKind.TypeKeyword, Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Delete)); // template string this.SpaceBetweenTagAndTemplateString = new Rule(RuleDescriptor.create3(SyntaxKind.Identifier, Shared.TokenRange.FromTokens([SyntaxKind.NoSubstitutionTemplateLiteral, SyntaxKind.TemplateHead])), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Space)); - this.NoSpaceBetweenTagAndTemplateString = new Rule(RuleDescriptor.create3(SyntaxKind.Identifier, Shared.TokenRange.FromTokens([SyntaxKind.NoSubstitutionTemplateLiteral, SyntaxKind.TemplateHead])), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Delete)); // type operation this.SpaceBeforeBar = new Rule(RuleDescriptor.create3(SyntaxKind.BarToken, Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Space)); - this.NoSpaceBeforeBar = new Rule(RuleDescriptor.create3(SyntaxKind.BarToken, Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Delete)); this.SpaceAfterBar = new Rule(RuleDescriptor.create2(Shared.TokenRange.Any, SyntaxKind.BarToken), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Space)); - this.NoSpaceAfterBar = new Rule(RuleDescriptor.create2(Shared.TokenRange.Any, SyntaxKind.BarToken), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Delete)); this.SpaceBeforeAmpersand = new Rule(RuleDescriptor.create3(SyntaxKind.AmpersandToken, Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Space)); this.SpaceAfterAmpersand = new Rule(RuleDescriptor.create2(Shared.TokenRange.Any, SyntaxKind.AmpersandToken), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Space)); @@ -430,11 +415,9 @@ namespace ts.formatting { this.NoSpaceBeforeOpenParenInFuncCall, this.SpaceBeforeBinaryKeywordOperator, this.SpaceAfterBinaryKeywordOperator, this.SpaceAfterVoidOperator, - this.SpaceBetweenAsyncAndFunctionKeyword, this.NoSpaceBetweenAsyncAndFunctionKeyword, - this.SpaceAfterAwaitKeyword, this.NoSpaceAfterAwaitKeyword, - this.SpaceAfterTypeKeyword, this.NoSpaceAfterTypeKeyword, - this.SpaceBetweenTagAndTemplateString, this.NoSpaceBetweenTagAndTemplateString, - this.SpaceBeforeBar, this.NoSpaceBeforeBar, this.SpaceAfterBar, this.NoSpaceAfterBar, + this.SpaceBetweenAsyncAndFunctionKeyword, + this.SpaceBetweenTagAndTemplateString, + this.SpaceBeforeBar, this.SpaceAfterBar, this.SpaceBeforeAmpersand, this.SpaceAfterAmpersand, // TypeScript-specific rules From 8cd8f863b36d8c072ebb8d7becffeee5f9753b24 Mon Sep 17 00:00:00 2001 From: SaschaNaz Date: Thu, 10 Sep 2015 01:41:21 +0900 Subject: [PATCH 096/117] remove type operation rules, add types instead --- src/services/formatting/rules.ts | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) diff --git a/src/services/formatting/rules.ts b/src/services/formatting/rules.ts index 38a2bb74372..0db1865e352 100644 --- a/src/services/formatting/rules.ts +++ b/src/services/formatting/rules.ts @@ -219,12 +219,6 @@ namespace ts.formatting { // Tagged template string public SpaceBetweenTagAndTemplateString: Rule; - // Type operation - public SpaceBeforeBar: Rule; - public SpaceAfterBar: Rule; - public SpaceBeforeAmpersand: Rule; - public SpaceAfterAmpersand: Rule; - constructor() { /// /// Common Rules @@ -383,12 +377,6 @@ namespace ts.formatting { // template string this.SpaceBetweenTagAndTemplateString = new Rule(RuleDescriptor.create3(SyntaxKind.Identifier, Shared.TokenRange.FromTokens([SyntaxKind.NoSubstitutionTemplateLiteral, SyntaxKind.TemplateHead])), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Space)); - // type operation - this.SpaceBeforeBar = new Rule(RuleDescriptor.create3(SyntaxKind.BarToken, Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Space)); - this.SpaceAfterBar = new Rule(RuleDescriptor.create2(Shared.TokenRange.Any, SyntaxKind.BarToken), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Space)); - this.SpaceBeforeAmpersand = new Rule(RuleDescriptor.create3(SyntaxKind.AmpersandToken, Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Space)); - this.SpaceAfterAmpersand = new Rule(RuleDescriptor.create2(Shared.TokenRange.Any, SyntaxKind.AmpersandToken), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Space)); - // These rules are higher in priority than user-configurable rules. this.HighPriorityCommonRules = [ @@ -417,8 +405,6 @@ namespace ts.formatting { this.SpaceAfterVoidOperator, this.SpaceBetweenAsyncAndFunctionKeyword, this.SpaceBetweenTagAndTemplateString, - this.SpaceBeforeBar, this.SpaceAfterBar, - this.SpaceBeforeAmpersand, this.SpaceAfterAmpersand, // TypeScript-specific rules this.NoSpaceAfterConstructor, this.NoSpaceAfterModuleImport, @@ -522,6 +508,8 @@ namespace ts.formatting { case SyntaxKind.ConditionalExpression: case SyntaxKind.AsExpression: case SyntaxKind.TypePredicate: + case SyntaxKind.UnionType: + case SyntaxKind.IntersectionType: return true; // equals in binding elements: function foo([[x, y] = [1, 2]]) From eb2d86aa7b9881fa53dc890e13b632313edcf15f Mon Sep 17 00:00:00 2001 From: SaschaNaz Date: Thu, 10 Sep 2015 02:20:15 +0900 Subject: [PATCH 097/117] revert newlines --- src/services/formatting/rules.ts | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/src/services/formatting/rules.ts b/src/services/formatting/rules.ts index 0db1865e352..02e785f6b3e 100644 --- a/src/services/formatting/rules.ts +++ b/src/services/formatting/rules.ts @@ -332,12 +332,7 @@ namespace ts.formatting { this.NoSpaceAfterModuleImport = new Rule(RuleDescriptor.create2(Shared.TokenRange.FromTokens([SyntaxKind.ModuleKeyword, SyntaxKind.RequireKeyword]), SyntaxKind.OpenParenToken), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Delete)); // Add a space around certain TypeScript keywords - this.SpaceAfterCertainTypeScriptKeywords = new Rule(RuleDescriptor.create4(Shared.TokenRange.FromTokens([ - SyntaxKind.AbstractKeyword, SyntaxKind.ClassKeyword, SyntaxKind.DeclareKeyword, SyntaxKind.DefaultKeyword, SyntaxKind.EnumKeyword, SyntaxKind.ExportKeyword, - SyntaxKind.ExtendsKeyword, SyntaxKind.GetKeyword, SyntaxKind.ImplementsKeyword, SyntaxKind.ImportKeyword, SyntaxKind.InterfaceKeyword, SyntaxKind.ModuleKeyword, - SyntaxKind.NamespaceKeyword, SyntaxKind.PrivateKeyword, SyntaxKind.PublicKeyword, SyntaxKind.ProtectedKeyword, SyntaxKind.SetKeyword, SyntaxKind.StaticKeyword, - SyntaxKind.TypeKeyword - ]), Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Space)); + this.SpaceAfterCertainTypeScriptKeywords = new Rule(RuleDescriptor.create4(Shared.TokenRange.FromTokens([SyntaxKind.AbstractKeyword, SyntaxKind.ClassKeyword, SyntaxKind.DeclareKeyword, SyntaxKind.DefaultKeyword, SyntaxKind.EnumKeyword, SyntaxKind.ExportKeyword, SyntaxKind.ExtendsKeyword, SyntaxKind.GetKeyword, SyntaxKind.ImplementsKeyword, SyntaxKind.ImportKeyword, SyntaxKind.InterfaceKeyword, SyntaxKind.ModuleKeyword, SyntaxKind.NamespaceKeyword, SyntaxKind.PrivateKeyword, SyntaxKind.PublicKeyword, SyntaxKind.ProtectedKeyword, SyntaxKind.SetKeyword, SyntaxKind.StaticKeyword, SyntaxKind.TypeKeyword]), Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Space)); this.SpaceBeforeCertainTypeScriptKeywords = new Rule(RuleDescriptor.create4(Shared.TokenRange.Any, Shared.TokenRange.FromTokens([SyntaxKind.ExtendsKeyword, SyntaxKind.ImplementsKeyword])), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Space)); // Treat string literals in module names as identifiers, and add a space between the literal and the opening Brace braces, e.g.: module "m2" { From c05650aea3c473f41f4de0687080620758310527 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Wed, 9 Sep 2015 16:38:04 -0700 Subject: [PATCH 098/117] Actually cache regular version of fresh object literal type --- src/compiler/checker.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 58b7e920bff..3d1250616ef 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -5507,6 +5507,7 @@ namespace ts { regularType.constructSignatures = (type).constructSignatures; regularType.stringIndexType = (type).stringIndexType; regularType.numberIndexType = (type).numberIndexType; + (type).regularType = regularType; } return regularType; } From 6e245701356ebc7f5dbca7fbd31407e9f4495685 Mon Sep 17 00:00:00 2001 From: Vladimir Matveev Date: Thu, 10 Sep 2015 10:46:39 -0700 Subject: [PATCH 099/117] reattach file diagnostics for modified files when reusing program structure --- src/compiler/program.ts | 78 +++++++++++-------- src/compiler/types.ts | 3 + src/compiler/utilities.ts | 13 +++- .../cases/unittests/reuseProgramStructure.ts | 9 ++- 4 files changed, 67 insertions(+), 36 deletions(-) diff --git a/src/compiler/program.ts b/src/compiler/program.ts index a1861f6b462..d86a80a5387 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -358,7 +358,8 @@ namespace ts { export function createProgram(rootNames: string[], options: CompilerOptions, host?: CompilerHost, oldProgram?: Program): Program { let program: Program; let files: SourceFile[] = []; - let diagnostics = createDiagnosticCollection(); + let fileProcessingDiagnostics = createDiagnosticCollection(); + let programDiagnostics = createDiagnosticCollection(); let commonSourceDirectory: string; let diagnosticsProducingTypeChecker: TypeChecker; @@ -428,6 +429,7 @@ namespace ts { getIdentifierCount: () => getDiagnosticsProducingTypeChecker().getIdentifierCount(), getSymbolCount: () => getDiagnosticsProducingTypeChecker().getSymbolCount(), getTypeCount: () => getDiagnosticsProducingTypeChecker().getTypeCount(), + getFileProcessingDiagnostics: () => fileProcessingDiagnostics }; return program; @@ -460,6 +462,7 @@ namespace ts { // check if program source files has changed in the way that can affect structure of the program let newSourceFiles: SourceFile[] = []; + let modifiedSourceFiles: SourceFile[] = []; for (let oldSourceFile of oldProgram.getSourceFiles()) { let newSourceFile = host.getSourceFile(oldSourceFile.fileName, options.target); if (!newSourceFile) { @@ -499,6 +502,7 @@ namespace ts { } // pass the cache of module resolutions from the old source file newSourceFile.resolvedModules = oldSourceFile.resolvedModules; + modifiedSourceFiles.push(newSourceFile); } else { // file has no changes - use it as is @@ -515,7 +519,11 @@ namespace ts { } files = newSourceFiles; + fileProcessingDiagnostics = oldProgram.getFileProcessingDiagnostics(); + for (let modifiedFile of modifiedSourceFiles) { + fileProcessingDiagnostics.reattachFileDiagnostics(modifiedFile); + } oldProgram.structureIsReused = true; return true; @@ -645,9 +653,10 @@ namespace ts { Debug.assert(!!sourceFile.bindDiagnostics); let bindDiagnostics = sourceFile.bindDiagnostics; let checkDiagnostics = typeChecker.getDiagnostics(sourceFile, cancellationToken); - let programDiagnostics = diagnostics.getDiagnostics(sourceFile.fileName); + let fileProcessingDiagnosticsInFile = fileProcessingDiagnostics.getDiagnostics(sourceFile.fileName); + let programDiagnosticsInFile = programDiagnostics.getDiagnostics(sourceFile.fileName); - return bindDiagnostics.concat(checkDiagnostics).concat(programDiagnostics); + return bindDiagnostics.concat(checkDiagnostics).concat(fileProcessingDiagnosticsInFile).concat(programDiagnosticsInFile); }); } @@ -664,7 +673,8 @@ namespace ts { function getOptionsDiagnostics(): Diagnostic[] { let allDiagnostics: Diagnostic[] = []; - addRange(allDiagnostics, diagnostics.getGlobalDiagnostics()); + addRange(allDiagnostics, fileProcessingDiagnostics.getGlobalDiagnostics()) + addRange(allDiagnostics, programDiagnostics.getGlobalDiagnostics()); return sortAndDeduplicateDiagnostics(allDiagnostics); } @@ -772,10 +782,10 @@ namespace ts { if (diagnostic) { if (refFile !== undefined && refEnd !== undefined && refPos !== undefined) { - diagnostics.add(createFileDiagnostic(refFile, refPos, refEnd - refPos, diagnostic, ...diagnosticArgument)); + fileProcessingDiagnostics.add(createFileDiagnostic(refFile, refPos, refEnd - refPos, diagnostic, ...diagnosticArgument)); } else { - diagnostics.add(createCompilerDiagnostic(diagnostic, ...diagnosticArgument)); + fileProcessingDiagnostics.add(createCompilerDiagnostic(diagnostic, ...diagnosticArgument)); } } } @@ -797,11 +807,11 @@ namespace ts { // We haven't looked for this file, do so now and cache result let file = host.getSourceFile(fileName, options.target, hostErrorMessage => { if (refFile !== undefined && refPos !== undefined && refEnd !== undefined) { - diagnostics.add(createFileDiagnostic(refFile, refPos, refEnd - refPos, + fileProcessingDiagnostics.add(createFileDiagnostic(refFile, refPos, refEnd - refPos, Diagnostics.Cannot_read_file_0_Colon_1, fileName, hostErrorMessage)); } else { - diagnostics.add(createCompilerDiagnostic(Diagnostics.Cannot_read_file_0_Colon_1, fileName, hostErrorMessage)); + fileProcessingDiagnostics.add(createCompilerDiagnostic(Diagnostics.Cannot_read_file_0_Colon_1, fileName, hostErrorMessage)); } }); filesByName.set(canonicalName, file); @@ -837,11 +847,11 @@ namespace ts { let sourceFileName = useAbsolutePath ? getNormalizedAbsolutePath(file.fileName, host.getCurrentDirectory()) : file.fileName; if (canonicalName !== sourceFileName) { if (refFile !== undefined && refPos !== undefined && refEnd !== undefined) { - diagnostics.add(createFileDiagnostic(refFile, refPos, refEnd - refPos, + fileProcessingDiagnostics.add(createFileDiagnostic(refFile, refPos, refEnd - refPos, Diagnostics.File_name_0_differs_from_already_included_file_name_1_only_in_casing, fileName, sourceFileName)); } else { - diagnostics.add(createCompilerDiagnostic(Diagnostics.File_name_0_differs_from_already_included_file_name_1_only_in_casing, fileName, sourceFileName)); + fileProcessingDiagnostics.add(createCompilerDiagnostic(Diagnostics.File_name_0_differs_from_already_included_file_name_1_only_in_casing, fileName, sourceFileName)); } } } @@ -877,7 +887,7 @@ namespace ts { return; function findModuleSourceFile(fileName: string, nameLiteral: Expression) { - return findSourceFile(fileName, /* isDefaultLib */ false, file, nameLiteral.pos, nameLiteral.end); + return findSourceFile(fileName, /* isDefaultLib */ false, file, skipTrivia(file.text, nameLiteral.pos), nameLiteral.end); } } @@ -902,7 +912,7 @@ namespace ts { for (let i = 0, n = Math.min(commonPathComponents.length, sourcePathComponents.length); i < n; i++) { if (commonPathComponents[i] !== sourcePathComponents[i]) { if (i === 0) { - diagnostics.add(createCompilerDiagnostic(Diagnostics.Cannot_find_the_common_subdirectory_path_for_the_input_files)); + programDiagnostics.add(createCompilerDiagnostic(Diagnostics.Cannot_find_the_common_subdirectory_path_for_the_input_files)); return; } @@ -931,7 +941,7 @@ namespace ts { if (!isDeclarationFile(sourceFile)) { let absoluteSourceFilePath = host.getCanonicalFileName(getNormalizedAbsolutePath(sourceFile.fileName, currentDirectory)); if (absoluteSourceFilePath.indexOf(absoluteRootDirectoryPath) !== 0) { - diagnostics.add(createCompilerDiagnostic(Diagnostics.File_0_is_not_under_rootDir_1_rootDir_is_expected_to_contain_all_source_files, sourceFile.fileName, options.rootDir)); + programDiagnostics.add(createCompilerDiagnostic(Diagnostics.File_0_is_not_under_rootDir_1_rootDir_is_expected_to_contain_all_source_files, sourceFile.fileName, options.rootDir)); allFilesBelongToPath = false; } } @@ -944,52 +954,52 @@ namespace ts { function verifyCompilerOptions() { if (options.isolatedModules) { if (options.declaration) { - diagnostics.add(createCompilerDiagnostic(Diagnostics.Option_0_cannot_be_specified_with_option_1, "declaration", "isolatedModules")); + programDiagnostics.add(createCompilerDiagnostic(Diagnostics.Option_0_cannot_be_specified_with_option_1, "declaration", "isolatedModules")); } if (options.noEmitOnError) { - diagnostics.add(createCompilerDiagnostic(Diagnostics.Option_0_cannot_be_specified_with_option_1, "noEmitOnError", "isolatedModules")); + programDiagnostics.add(createCompilerDiagnostic(Diagnostics.Option_0_cannot_be_specified_with_option_1, "noEmitOnError", "isolatedModules")); } if (options.out) { - diagnostics.add(createCompilerDiagnostic(Diagnostics.Option_0_cannot_be_specified_with_option_1, "out", "isolatedModules")); + programDiagnostics.add(createCompilerDiagnostic(Diagnostics.Option_0_cannot_be_specified_with_option_1, "out", "isolatedModules")); } if (options.outFile) { - diagnostics.add(createCompilerDiagnostic(Diagnostics.Option_0_cannot_be_specified_with_option_1, "outFile", "isolatedModules")); + programDiagnostics.add(createCompilerDiagnostic(Diagnostics.Option_0_cannot_be_specified_with_option_1, "outFile", "isolatedModules")); } } if (options.inlineSourceMap) { if (options.sourceMap) { - diagnostics.add(createCompilerDiagnostic(Diagnostics.Option_0_cannot_be_specified_with_option_1, "sourceMap", "inlineSourceMap")); + programDiagnostics.add(createCompilerDiagnostic(Diagnostics.Option_0_cannot_be_specified_with_option_1, "sourceMap", "inlineSourceMap")); } if (options.mapRoot) { - diagnostics.add(createCompilerDiagnostic(Diagnostics.Option_0_cannot_be_specified_with_option_1, "mapRoot", "inlineSourceMap")); + programDiagnostics.add(createCompilerDiagnostic(Diagnostics.Option_0_cannot_be_specified_with_option_1, "mapRoot", "inlineSourceMap")); } if (options.sourceRoot) { - diagnostics.add(createCompilerDiagnostic(Diagnostics.Option_0_cannot_be_specified_with_option_1, "sourceRoot", "inlineSourceMap")); + programDiagnostics.add(createCompilerDiagnostic(Diagnostics.Option_0_cannot_be_specified_with_option_1, "sourceRoot", "inlineSourceMap")); } } if (options.inlineSources) { if (!options.sourceMap && !options.inlineSourceMap) { - diagnostics.add(createCompilerDiagnostic(Diagnostics.Option_inlineSources_can_only_be_used_when_either_option_inlineSourceMap_or_option_sourceMap_is_provided)); + programDiagnostics.add(createCompilerDiagnostic(Diagnostics.Option_inlineSources_can_only_be_used_when_either_option_inlineSourceMap_or_option_sourceMap_is_provided)); } } if (options.out && options.outFile) { - diagnostics.add(createCompilerDiagnostic(Diagnostics.Option_0_cannot_be_specified_with_option_1, "out", "outFile")); + programDiagnostics.add(createCompilerDiagnostic(Diagnostics.Option_0_cannot_be_specified_with_option_1, "out", "outFile")); } if (!options.sourceMap && (options.mapRoot || options.sourceRoot)) { // Error to specify --mapRoot or --sourceRoot without mapSourceFiles if (options.mapRoot) { - diagnostics.add(createCompilerDiagnostic(Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "mapRoot", "sourceMap")); + programDiagnostics.add(createCompilerDiagnostic(Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "mapRoot", "sourceMap")); } if (options.sourceRoot) { - diagnostics.add(createCompilerDiagnostic(Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "sourceRoot", "sourceMap")); + programDiagnostics.add(createCompilerDiagnostic(Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "sourceRoot", "sourceMap")); } return; } @@ -1000,24 +1010,24 @@ namespace ts { let firstExternalModuleSourceFile = forEach(files, f => isExternalModule(f) ? f : undefined); if (options.isolatedModules) { if (!options.module && languageVersion < ScriptTarget.ES6) { - diagnostics.add(createCompilerDiagnostic(Diagnostics.Option_isolatedModules_can_only_be_used_when_either_option_module_is_provided_or_option_target_is_ES6_or_higher)); + programDiagnostics.add(createCompilerDiagnostic(Diagnostics.Option_isolatedModules_can_only_be_used_when_either_option_module_is_provided_or_option_target_is_ES6_or_higher)); } let firstNonExternalModuleSourceFile = forEach(files, f => !isExternalModule(f) && !isDeclarationFile(f) ? f : undefined); if (firstNonExternalModuleSourceFile) { let span = getErrorSpanForNode(firstNonExternalModuleSourceFile, firstNonExternalModuleSourceFile); - diagnostics.add(createFileDiagnostic(firstNonExternalModuleSourceFile, span.start, span.length, Diagnostics.Cannot_compile_namespaces_when_the_isolatedModules_flag_is_provided)); + programDiagnostics.add(createFileDiagnostic(firstNonExternalModuleSourceFile, span.start, span.length, Diagnostics.Cannot_compile_namespaces_when_the_isolatedModules_flag_is_provided)); } } else if (firstExternalModuleSourceFile && languageVersion < ScriptTarget.ES6 && !options.module) { // We cannot use createDiagnosticFromNode because nodes do not have parents yet let span = getErrorSpanForNode(firstExternalModuleSourceFile, firstExternalModuleSourceFile.externalModuleIndicator); - diagnostics.add(createFileDiagnostic(firstExternalModuleSourceFile, span.start, span.length, Diagnostics.Cannot_compile_modules_unless_the_module_flag_is_provided)); + programDiagnostics.add(createFileDiagnostic(firstExternalModuleSourceFile, span.start, span.length, Diagnostics.Cannot_compile_modules_unless_the_module_flag_is_provided)); } // Cannot specify module gen target when in es6 or above if (options.module && languageVersion >= ScriptTarget.ES6) { - diagnostics.add(createCompilerDiagnostic(Diagnostics.Cannot_compile_modules_into_commonjs_amd_system_or_umd_when_targeting_ES6_or_higher)); + programDiagnostics.add(createCompilerDiagnostic(Diagnostics.Cannot_compile_modules_into_commonjs_amd_system_or_umd_when_targeting_ES6_or_higher)); } // there has to be common source directory if user specified --outdir || --sourceRoot @@ -1046,30 +1056,30 @@ namespace ts { if (options.noEmit) { if (options.out) { - diagnostics.add(createCompilerDiagnostic(Diagnostics.Option_0_cannot_be_specified_with_option_1, "noEmit", "out")); + programDiagnostics.add(createCompilerDiagnostic(Diagnostics.Option_0_cannot_be_specified_with_option_1, "noEmit", "out")); } if (options.outFile) { - diagnostics.add(createCompilerDiagnostic(Diagnostics.Option_0_cannot_be_specified_with_option_1, "noEmit", "outFile")); + programDiagnostics.add(createCompilerDiagnostic(Diagnostics.Option_0_cannot_be_specified_with_option_1, "noEmit", "outFile")); } if (options.outDir) { - diagnostics.add(createCompilerDiagnostic(Diagnostics.Option_0_cannot_be_specified_with_option_1, "noEmit", "outDir")); + programDiagnostics.add(createCompilerDiagnostic(Diagnostics.Option_0_cannot_be_specified_with_option_1, "noEmit", "outDir")); } if (options.declaration) { - diagnostics.add(createCompilerDiagnostic(Diagnostics.Option_0_cannot_be_specified_with_option_1, "noEmit", "declaration")); + programDiagnostics.add(createCompilerDiagnostic(Diagnostics.Option_0_cannot_be_specified_with_option_1, "noEmit", "declaration")); } } if (options.emitDecoratorMetadata && !options.experimentalDecorators) { - diagnostics.add(createCompilerDiagnostic(Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "emitDecoratorMetadata", "experimentalDecorators")); + programDiagnostics.add(createCompilerDiagnostic(Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "emitDecoratorMetadata", "experimentalDecorators")); } if (options.experimentalAsyncFunctions && options.target !== ScriptTarget.ES6) { - diagnostics.add(createCompilerDiagnostic(Diagnostics.Option_experimentalAsyncFunctions_cannot_be_specified_when_targeting_ES5_or_lower)); + programDiagnostics.add(createCompilerDiagnostic(Diagnostics.Option_experimentalAsyncFunctions_cannot_be_specified_when_targeting_ES5_or_lower)); } } } diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 47182e39527..265fa5c86fb 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -1359,6 +1359,7 @@ namespace ts { /* @internal */ getSymbolCount(): number; /* @internal */ getTypeCount(): number; + /* @internal */ getFileProcessingDiagnostics(): DiagnosticCollection; // For testing purposes only. /* @internal */ structureIsReused?: boolean; } @@ -2322,5 +2323,7 @@ namespace ts { // operation caused diagnostics to be returned by storing and comparing the return value // of this method before/after the operation is performed. getModificationCount(): number; + + /* @internal */ reattachFileDiagnostics(newFile: SourceFile): void; } } diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index 99ea06532a0..6c5bd8df95d 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -1507,12 +1507,23 @@ namespace ts { add, getGlobalDiagnostics, getDiagnostics, - getModificationCount + getModificationCount, + reattachFileDiagnostics }; function getModificationCount() { return modificationCount; } + + function reattachFileDiagnostics(newFile: SourceFile): void { + if (!hasProperty(fileDiagnostics, newFile.fileName)) { + return; + } + + for (let diagnostic of fileDiagnostics[newFile.fileName]) { + diagnostic.file = newFile; + } + } function add(diagnostic: Diagnostic): void { let diagnostics: Diagnostic[]; diff --git a/tests/cases/unittests/reuseProgramStructure.ts b/tests/cases/unittests/reuseProgramStructure.ts index 6c043299c8f..56b1dedbcbb 100644 --- a/tests/cases/unittests/reuseProgramStructure.ts +++ b/tests/cases/unittests/reuseProgramStructure.ts @@ -184,7 +184,11 @@ module ts { describe("Reuse program structure", () => { let target = ScriptTarget.Latest; let files = [ - { name: "a.ts", text: SourceText.New(`/// `, "", `var x = 1`) }, + { name: "a.ts", text: SourceText.New( + ` +/// +/// +`, "",`var x = 1`) }, { name: "b.ts", text: SourceText.New(`/// `, "", `var y = 2`) }, { name: "c.ts", text: SourceText.New("", "", `var z = 1;`) }, ] @@ -195,6 +199,9 @@ module ts { files[0].text = files[0].text.updateProgram("var x = 100"); }); assert.isTrue(program_1.structureIsReused); + let program1Diagnostics = program_1.getSemanticDiagnostics(program_1.getSourceFile("a.ts")) + let program2Diagnostics = program_2.getSemanticDiagnostics(program_1.getSourceFile("a.ts")) + assert.equal(program1Diagnostics.length, program2Diagnostics.length); }); it("fails if change affects tripleslash references", () => { From 5989d4826755286588975d5863e4eda2fc727694 Mon Sep 17 00:00:00 2001 From: Vladimir Matveev Date: Thu, 10 Sep 2015 12:05:23 -0700 Subject: [PATCH 100/117] addressed PR feedback --- src/compiler/parser.ts | 34 +++++++------------ src/compiler/scanner.ts | 5 +++ .../reference/keywordInJsxIdentifier.js | 9 ++++- .../reference/keywordInJsxIdentifier.symbols | 11 +++++- .../reference/keywordInJsxIdentifier.types | 17 +++++++++- .../cases/compiler/keywordInJsxIdentifier.tsx | 5 ++- 6 files changed, 56 insertions(+), 25 deletions(-) diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index 57e19156568..330ad05518b 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -12,10 +12,6 @@ namespace ts { export function createNode(kind: SyntaxKind): Node { return new (getNodeConstructor(kind))(); } - - export function tokenIsIdentifierOrKeyword(token: SyntaxKind): boolean { - return token >= SyntaxKind.Identifier; - } function visitNode(cbNode: (node: Node) => T, node: Node): T { if (node) { @@ -1062,11 +1058,11 @@ namespace ts { } function parseIdentifierName(): Identifier { - return createIdentifier(isIdentifierOrKeyword()); + return createIdentifier(tokenIsIdentifierOrKeyword(token)); } function isLiteralPropertyName(): boolean { - return isIdentifierOrKeyword() || + return tokenIsIdentifierOrKeyword(token) || token === SyntaxKind.StringLiteral || token === SyntaxKind.NumericLiteral; } @@ -1090,7 +1086,7 @@ namespace ts { } function isSimplePropertyName() { - return token === SyntaxKind.StringLiteral || token === SyntaxKind.NumericLiteral || isIdentifierOrKeyword(); + return token === SyntaxKind.StringLiteral || token === SyntaxKind.NumericLiteral || tokenIsIdentifierOrKeyword(token); } function parseComputedPropertyName(): ComputedPropertyName { @@ -1217,9 +1213,9 @@ namespace ts { case ParsingContext.HeritageClauses: return isHeritageClause(); case ParsingContext.ImportOrExportSpecifiers: - return isIdentifierOrKeyword(); + return tokenIsIdentifierOrKeyword(token); case ParsingContext.JsxAttributes: - return isIdentifierOrKeyword() || token === SyntaxKind.OpenBraceToken; + return tokenIsIdentifierOrKeyword(token) || token === SyntaxKind.OpenBraceToken; case ParsingContext.JsxChildren: return true; case ParsingContext.JSDocFunctionParameters: @@ -1258,7 +1254,7 @@ namespace ts { function nextTokenIsIdentifierOrKeyword() { nextToken(); - return isIdentifierOrKeyword(); + return tokenIsIdentifierOrKeyword(token); } function isHeritageClauseExtendsOrImplementsKeyword(): boolean { @@ -1828,7 +1824,7 @@ namespace ts { // the code would be implicitly: "name.identifierOrKeyword; identifierNameOrKeyword". // In the first case though, ASI will not take effect because there is not a // line terminator after the identifier or keyword. - if (scanner.hasPrecedingLineBreak() && isIdentifierOrKeyword()) { + if (scanner.hasPrecedingLineBreak() && tokenIsIdentifierOrKeyword(token)) { let matchesPattern = lookAhead(nextTokenIsIdentifierOrKeywordOnSameLine); if (matchesPattern) { @@ -2286,7 +2282,7 @@ namespace ts { } } - if (isIdentifierOrKeyword()) { + if (tokenIsIdentifierOrKeyword(token)) { return parsePropertyOrMethodSignature(); } } @@ -4105,13 +4101,9 @@ namespace ts { } } - function isIdentifierOrKeyword() { - return tokenIsIdentifierOrKeyword(token); - } - function nextTokenIsIdentifierOrKeywordOnSameLine() { nextToken(); - return isIdentifierOrKeyword() && !scanner.hasPrecedingLineBreak(); + return tokenIsIdentifierOrKeyword(token) && !scanner.hasPrecedingLineBreak(); } function nextTokenIsFunctionKeywordOnSameLine() { @@ -4121,7 +4113,7 @@ namespace ts { function nextTokenIsIdentifierOrKeywordOrNumberOnSameLine() { nextToken(); - return (isIdentifierOrKeyword() || token === SyntaxKind.NumericLiteral) && !scanner.hasPrecedingLineBreak(); + return (tokenIsIdentifierOrKeyword(token) || token === SyntaxKind.NumericLiteral) && !scanner.hasPrecedingLineBreak(); } function isDeclaration(): boolean { @@ -4174,7 +4166,7 @@ namespace ts { case SyntaxKind.ImportKeyword: nextToken(); return token === SyntaxKind.StringLiteral || token === SyntaxKind.AsteriskToken || - token === SyntaxKind.OpenBraceToken || isIdentifierOrKeyword(); + token === SyntaxKind.OpenBraceToken || tokenIsIdentifierOrKeyword(token); case SyntaxKind.ExportKeyword: nextToken(); if (token === SyntaxKind.EqualsToken || token === SyntaxKind.AsteriskToken || @@ -4781,7 +4773,7 @@ namespace ts { // It is very important that we check this *after* checking indexers because // the [ token can start an index signature or a computed property name - if (isIdentifierOrKeyword() || + if (tokenIsIdentifierOrKeyword(token) || token === SyntaxKind.StringLiteral || token === SyntaxKind.NumericLiteral || token === SyntaxKind.AsteriskToken || @@ -5324,7 +5316,7 @@ namespace ts { return true; } - return isIdentifierOrKeyword(); + return tokenIsIdentifierOrKeyword(token); } export function parseJSDocTypeExpressionForTests(content: string, start: number, length: number) { diff --git a/src/compiler/scanner.ts b/src/compiler/scanner.ts index 2e10a1f1b84..82fbc8c2a59 100644 --- a/src/compiler/scanner.ts +++ b/src/compiler/scanner.ts @@ -6,6 +6,11 @@ namespace ts { (message: DiagnosticMessage, length: number): void; } + /* @internal */ + export function tokenIsIdentifierOrKeyword(token: SyntaxKind): boolean { + return token >= SyntaxKind.Identifier; + } + export interface Scanner { getStartPos(): number; getToken(): SyntaxKind; diff --git a/tests/baselines/reference/keywordInJsxIdentifier.js b/tests/baselines/reference/keywordInJsxIdentifier.js index 8a00a68e334..677a79138e6 100644 --- a/tests/baselines/reference/keywordInJsxIdentifier.js +++ b/tests/baselines/reference/keywordInJsxIdentifier.js @@ -1,7 +1,14 @@ //// [keywordInJsxIdentifier.tsx] declare var React: any; - +; +; +; +; + //// [keywordInJsxIdentifier.js] React.createElement("foo", {"class-id": true}); +React.createElement("foo", {"class": true}); +React.createElement("foo", {"class-id": "1"}); +React.createElement("foo", {"class": "1"}); diff --git a/tests/baselines/reference/keywordInJsxIdentifier.symbols b/tests/baselines/reference/keywordInJsxIdentifier.symbols index 6617a640dca..874d7801a7f 100644 --- a/tests/baselines/reference/keywordInJsxIdentifier.symbols +++ b/tests/baselines/reference/keywordInJsxIdentifier.symbols @@ -3,6 +3,15 @@ declare var React: any; >React : Symbol(React, Decl(keywordInJsxIdentifier.tsx, 1, 11)) - +; >class-id : Symbol(unknown) +; +>class : Symbol(unknown) + +; +>class-id : Symbol(unknown) + +; +>class : Symbol(unknown) + diff --git a/tests/baselines/reference/keywordInJsxIdentifier.types b/tests/baselines/reference/keywordInJsxIdentifier.types index 888d027fddb..745fa5998b5 100644 --- a/tests/baselines/reference/keywordInJsxIdentifier.types +++ b/tests/baselines/reference/keywordInJsxIdentifier.types @@ -3,8 +3,23 @@ declare var React: any; >React : any - +; > : any >foo : any >class-id : any +; +> : any +>foo : any +>class : any + +; +> : any +>foo : any +>class-id : any + +; +> : any +>foo : any +>class : any + diff --git a/tests/cases/compiler/keywordInJsxIdentifier.tsx b/tests/cases/compiler/keywordInJsxIdentifier.tsx index 8c09c90b170..ce858edae5d 100644 --- a/tests/cases/compiler/keywordInJsxIdentifier.tsx +++ b/tests/cases/compiler/keywordInJsxIdentifier.tsx @@ -1,4 +1,7 @@ //@jsx: react declare var React: any; - \ No newline at end of file +; +; +; +; From c3323c9a6939d1ba754db50829886472a468b519 Mon Sep 17 00:00:00 2001 From: vilicvane Date: Fri, 11 Sep 2015 03:06:13 +0800 Subject: [PATCH 101/117] Keep parentheses for all numeric literals with property access expression --- src/compiler/emitter.ts | 13 +---- .../reference/castExpressionParentheses.js | 28 +++++++---- .../castExpressionParentheses.symbols | 20 +++++--- .../reference/castExpressionParentheses.types | 50 +++++++++++++------ .../castExpressionParentheses_ES6.js | 11 ---- .../castExpressionParentheses_ES6.symbols | 7 --- .../castExpressionParentheses_ES6.types | 11 ---- .../compiler/castExpressionParentheses.ts | 16 +++--- .../compiler/castExpressionParentheses_ES6.ts | 5 -- 9 files changed, 75 insertions(+), 86 deletions(-) delete mode 100644 tests/baselines/reference/castExpressionParentheses_ES6.js delete mode 100644 tests/baselines/reference/castExpressionParentheses_ES6.symbols delete mode 100644 tests/baselines/reference/castExpressionParentheses_ES6.types delete mode 100644 tests/cases/compiler/castExpressionParentheses_ES6.ts diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index 8fcd13c3ada..85607fd73d3 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -897,17 +897,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi write(text); } } - - function getEmittingNumericLiteralText(node: LiteralExpression): string { - let text = getLiteralText(node); - - if (languageVersion < ScriptTarget.ES6 && isBinaryOrOctalIntegerLiteral(node, text)) { - return node.text; - } - else { - return text; - } - } function getLiteralText(node: LiteralExpression) { // Any template literal or string literal with an extended escape @@ -2364,7 +2353,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi operand.kind !== SyntaxKind.NewExpression && !(operand.kind === SyntaxKind.CallExpression && node.parent.kind === SyntaxKind.NewExpression) && !(operand.kind === SyntaxKind.FunctionExpression && node.parent.kind === SyntaxKind.CallExpression) && - !(operand.kind === SyntaxKind.NumericLiteral && node.parent.kind === SyntaxKind.PropertyAccessExpression && !/^0[box]|[e.]/i.test(getEmittingNumericLiteralText(operand)))) { + !(operand.kind === SyntaxKind.NumericLiteral && node.parent.kind === SyntaxKind.PropertyAccessExpression)) { emit(operand); return; } diff --git a/tests/baselines/reference/castExpressionParentheses.js b/tests/baselines/reference/castExpressionParentheses.js index 22316df7f43..b4754d0ad41 100644 --- a/tests/baselines/reference/castExpressionParentheses.js +++ b/tests/baselines/reference/castExpressionParentheses.js @@ -8,10 +8,10 @@ declare var a; ("string"); (23.0); (1); -(1.).foo; -(1.0).foo; -(12e+34).foo; -(0xff).foo; +(1.); +(1.0); +(12e+34); +(0xff); (/regexp/g); (false); (true); @@ -28,8 +28,12 @@ declare var a; declare var A; // should keep the parentheses in emit -(1).foo; -((1.0)).foo; +(1).foo; +(1.).foo; +(1.0).foo; +(12e+34).foo; +(0xff).foo; +((1.0)); (new A).foo; (typeof A).x; (-A).x; @@ -54,10 +58,10 @@ new (A()); "string"; 23.0; 1; -1..foo; -1.0.foo; -12e+34.foo; -0xff.foo; +1.; +1.0; +12e+34; +0xff; /regexp/g; false; true; @@ -72,7 +76,11 @@ a.b["0"]; a().x; // should keep the parentheses in emit (1).foo; +(1.).foo; (1.0).foo; +(12e+34).foo; +(0xff).foo; +(1.0); (new A).foo; (typeof A).x; (-A).x; diff --git a/tests/baselines/reference/castExpressionParentheses.symbols b/tests/baselines/reference/castExpressionParentheses.symbols index a7f51f9f2cb..ef31ee0f226 100644 --- a/tests/baselines/reference/castExpressionParentheses.symbols +++ b/tests/baselines/reference/castExpressionParentheses.symbols @@ -11,10 +11,10 @@ declare var a; ("string"); (23.0); (1); -(1.).foo; -(1.0).foo; -(12e+34).foo; -(0xff).foo; +(1.); +(1.0); +(12e+34); +(0xff); (/regexp/g); (false); (true); @@ -41,8 +41,12 @@ declare var A; >A : Symbol(A, Decl(castExpressionParentheses.ts, 26, 11)) // should keep the parentheses in emit -(1).foo; -((1.0)).foo; +(1).foo; +(1.).foo; +(1.0).foo; +(12e+34).foo; +(0xff).foo; +((1.0)); (new A).foo; >A : Symbol(A, Decl(castExpressionParentheses.ts, 26, 11)) @@ -56,10 +60,10 @@ new (A()); >A : Symbol(A, Decl(castExpressionParentheses.ts, 26, 11)) (()=> {})(); ->Tany : Symbol(Tany, Decl(castExpressionParentheses.ts, 35, 2)) +>Tany : Symbol(Tany, Decl(castExpressionParentheses.ts, 39, 2)) (function foo() { })(); ->foo : Symbol(foo, Decl(castExpressionParentheses.ts, 36, 6)) +>foo : Symbol(foo, Decl(castExpressionParentheses.ts, 40, 6)) (-A).x; >A : Symbol(A, Decl(castExpressionParentheses.ts, 26, 11)) diff --git a/tests/baselines/reference/castExpressionParentheses.types b/tests/baselines/reference/castExpressionParentheses.types index 1d203958555..cdfbf4f7db2 100644 --- a/tests/baselines/reference/castExpressionParentheses.types +++ b/tests/baselines/reference/castExpressionParentheses.types @@ -33,33 +33,25 @@ declare var a; >1 : any >1 : number -(1.).foo; ->(1.).foo : any +(1.); >(1.) : any >1. : any >1. : number ->foo : any -(1.0).foo; ->(1.0).foo : any +(1.0); >(1.0) : any >1.0 : any >1.0 : number ->foo : any -(12e+34).foo; ->(12e+34).foo : any +(12e+34); >(12e+34) : any >12e+34 : any >12e+34 : number ->foo : any -(0xff).foo; ->(0xff).foo : any +(0xff); >(0xff) : any >0xff : any >0xff : number ->foo : any (/regexp/g); >(/regexp/g) : any @@ -137,20 +129,46 @@ declare var A; >A : any // should keep the parentheses in emit -(1).foo; +(1).foo; >(1).foo : any >(1) : any >1 : any >1 : number >foo : any -((1.0)).foo; ->((1.0)).foo : any +(1.).foo; +>(1.).foo : any +>(1.) : any +>1. : any +>1. : number +>foo : any + +(1.0).foo; +>(1.0).foo : any +>(1.0) : any +>1.0 : any +>1.0 : number +>foo : any + +(12e+34).foo; +>(12e+34).foo : any +>(12e+34) : any +>12e+34 : any +>12e+34 : number +>foo : any + +(0xff).foo; +>(0xff).foo : any +>(0xff) : any +>0xff : any +>0xff : number +>foo : any + +((1.0)); >((1.0)) : any >(1.0) : any >(1.0) : number >1.0 : number ->foo : any (new A).foo; >(new A).foo : any diff --git a/tests/baselines/reference/castExpressionParentheses_ES6.js b/tests/baselines/reference/castExpressionParentheses_ES6.js deleted file mode 100644 index 6ffbe7c2885..00000000000 --- a/tests/baselines/reference/castExpressionParentheses_ES6.js +++ /dev/null @@ -1,11 +0,0 @@ -//// [castExpressionParentheses_ES6.ts] - -// parentheses should be omitted -// numeric literal -(0o123).foo; - - -//// [castExpressionParentheses_ES6.js] -// parentheses should be omitted -// numeric literal -0o123.foo; diff --git a/tests/baselines/reference/castExpressionParentheses_ES6.symbols b/tests/baselines/reference/castExpressionParentheses_ES6.symbols deleted file mode 100644 index c1b31043cb1..00000000000 --- a/tests/baselines/reference/castExpressionParentheses_ES6.symbols +++ /dev/null @@ -1,7 +0,0 @@ -=== tests/cases/compiler/castExpressionParentheses_ES6.ts === - -No type information for this code.// parentheses should be omitted -No type information for this code.// numeric literal -No type information for this code.(0o123).foo; -No type information for this code. -No type information for this code. \ No newline at end of file diff --git a/tests/baselines/reference/castExpressionParentheses_ES6.types b/tests/baselines/reference/castExpressionParentheses_ES6.types deleted file mode 100644 index 41f968a834f..00000000000 --- a/tests/baselines/reference/castExpressionParentheses_ES6.types +++ /dev/null @@ -1,11 +0,0 @@ -=== tests/cases/compiler/castExpressionParentheses_ES6.ts === - -// parentheses should be omitted -// numeric literal -(0o123).foo; ->(0o123).foo : any ->(0o123) : any ->0o123 : any ->0o123 : number ->foo : any - diff --git a/tests/cases/compiler/castExpressionParentheses.ts b/tests/cases/compiler/castExpressionParentheses.ts index e6ed4d82785..06908f39936 100644 --- a/tests/cases/compiler/castExpressionParentheses.ts +++ b/tests/cases/compiler/castExpressionParentheses.ts @@ -7,10 +7,10 @@ declare var a; ("string"); (23.0); (1); -(1.).foo; -(1.0).foo; -(12e+34).foo; -(0xff).foo; +(1.); +(1.0); +(12e+34); +(0xff); (/regexp/g); (false); (true); @@ -27,8 +27,12 @@ declare var a; declare var A; // should keep the parentheses in emit -(1).foo; -((1.0)).foo; +(1).foo; +(1.).foo; +(1.0).foo; +(12e+34).foo; +(0xff).foo; +((1.0)); (new A).foo; (typeof A).x; (-A).x; diff --git a/tests/cases/compiler/castExpressionParentheses_ES6.ts b/tests/cases/compiler/castExpressionParentheses_ES6.ts deleted file mode 100644 index 03d6d8ae5fa..00000000000 --- a/tests/cases/compiler/castExpressionParentheses_ES6.ts +++ /dev/null @@ -1,5 +0,0 @@ -// @target: es6 - -// parentheses should be omitted -// numeric literal -(0o123).foo; From 40f05b7f7dd4090e9123b68900b5c9310c659fb5 Mon Sep 17 00:00:00 2001 From: Yui T Date: Thu, 10 Sep 2015 13:05:51 -0700 Subject: [PATCH 102/117] Address CR --- src/compiler/emitter.ts | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index 6e4bdff069b..ec14100e197 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -190,6 +190,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi /** Sourcemap data that will get encoded */ let sourceMapData: SourceMapData; + /** If removeComments is true, no leading-comments needed to be emitted **/ + let emitLeadingCommentsOfPosition = compilerOptions.removeComments ? function (pos: number) { } : emitLeadingCommentsOfPositionWorker; + if (compilerOptions.sourceMap || compilerOptions.inlineSourceMap) { initializeEmitterWithSourceMaps(); } @@ -6986,9 +6989,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi } function isPinnedComments(comment: CommentRange) { - if (currentSourceFile.text.charCodeAt(comment.pos + 1) === CharacterCodes.asterisk) { - return currentSourceFile.text.charCodeAt(comment.pos + 2) === CharacterCodes.exclamation; - } + return currentSourceFile.text.charCodeAt(comment.pos + 1) === CharacterCodes.asterisk && + currentSourceFile.text.charCodeAt(comment.pos + 2) === CharacterCodes.exclamation; } /** @@ -6996,7 +6998,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi * * @return true if the comment is a triple-slash comment else false **/ - function isTripleSlashComments(comment: CommentRange) { + function isTripleSlashComment(comment: CommentRange) { // Verify this is /// comment, but do the regexp match only when we first can find /// in the comment text // so that we don't end up computing comment string and doing match for all // comments if (currentSourceFile.text.charCodeAt(comment.pos + 1) === CharacterCodes.slash && @@ -7065,7 +7067,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi // interface F {} // The first /// will NOT be removed while the second one will be removed eventhough both node will not be emitted if (node.pos === 0) { - leadingComments = filter(getLeadingCommentsToEmit(node), isTripleSlashComments); + leadingComments = filter(getLeadingCommentsToEmit(node), isTripleSlashComment); } } @@ -7103,7 +7105,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi emitComments(currentSourceFile, writer, trailingComments, /*trailingSeparator*/ true, newLine, writeComment); } - function emitLeadingCommentsOfPosition(pos: number) { + function emitLeadingCommentsOfPositionWorker(pos: number) { if (compilerOptions.removeComments) { return; } From e0c16b433216409282d9ada5cbc5b63aa173eabd Mon Sep 17 00:00:00 2001 From: Vladimir Matveev Date: Thu, 10 Sep 2015 11:36:31 -0700 Subject: [PATCH 103/117] Check if imported file is a proper external module --- src/compiler/checker.ts | 4 +- .../diagnosticInformationMap.generated.ts | 2 + src/compiler/diagnosticMessages.json | 9 +- src/compiler/program.ts | 91 +++++++++---------- src/compiler/types.ts | 17 +++- src/compiler/utilities.ts | 10 +- src/harness/harnessLanguageService.ts | 4 +- src/server/editorServices.ts | 14 +-- src/services/services.ts | 4 +- src/services/shims.ts | 13 ++- tests/baselines/reference/nodeResolution4.js | 17 ++++ .../reference/nodeResolution4.symbols | 14 +++ .../baselines/reference/nodeResolution4.types | 15 +++ .../reference/nodeResolution5.errors.txt | 14 +++ tests/baselines/reference/nodeResolution5.js | 13 +++ .../reference/nodeResolution6.errors.txt | 17 ++++ tests/baselines/reference/nodeResolution6.js | 18 ++++ .../reference/nodeResolution7.errors.txt | 14 +++ tests/baselines/reference/nodeResolution7.js | 13 +++ .../reference/nodeResolution8.errors.txt | 16 ++++ tests/baselines/reference/nodeResolution8.js | 17 ++++ tests/cases/compiler/nodeResolution4.ts | 12 +++ tests/cases/compiler/nodeResolution5.ts | 10 ++ tests/cases/compiler/nodeResolution6.ts | 13 +++ tests/cases/compiler/nodeResolution7.ts | 10 ++ tests/cases/compiler/nodeResolution8.ts | 13 +++ tests/cases/unittests/moduleResolution.ts | 79 +++------------- .../cases/unittests/reuseProgramStructure.ts | 19 +++- 28 files changed, 347 insertions(+), 145 deletions(-) create mode 100644 tests/baselines/reference/nodeResolution4.js create mode 100644 tests/baselines/reference/nodeResolution4.symbols create mode 100644 tests/baselines/reference/nodeResolution4.types create mode 100644 tests/baselines/reference/nodeResolution5.errors.txt create mode 100644 tests/baselines/reference/nodeResolution5.js create mode 100644 tests/baselines/reference/nodeResolution6.errors.txt create mode 100644 tests/baselines/reference/nodeResolution6.js create mode 100644 tests/baselines/reference/nodeResolution7.errors.txt create mode 100644 tests/baselines/reference/nodeResolution7.js create mode 100644 tests/baselines/reference/nodeResolution8.errors.txt create mode 100644 tests/baselines/reference/nodeResolution8.js create mode 100644 tests/cases/compiler/nodeResolution4.ts create mode 100644 tests/cases/compiler/nodeResolution5.ts create mode 100644 tests/cases/compiler/nodeResolution6.ts create mode 100644 tests/cases/compiler/nodeResolution7.ts create mode 100644 tests/cases/compiler/nodeResolution8.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index df432808f30..48ad97ad4f9 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -976,8 +976,8 @@ namespace ts { } } - let fileName = getResolvedModuleFileName(getSourceFile(location), moduleReferenceLiteral.text); - let sourceFile = fileName && host.getSourceFile(fileName); + let resolvedModule = getResolvedModule(getSourceFile(location), moduleReferenceLiteral.text); + let sourceFile = resolvedModule && host.getSourceFile(resolvedModule.resolvedFileName); if (sourceFile) { if (sourceFile.symbol) { return sourceFile.symbol; diff --git a/src/compiler/diagnosticInformationMap.generated.ts b/src/compiler/diagnosticInformationMap.generated.ts index af48e67d964..efe4ba20d49 100644 --- a/src/compiler/diagnosticInformationMap.generated.ts +++ b/src/compiler/diagnosticInformationMap.generated.ts @@ -428,6 +428,8 @@ namespace ts { A_member_initializer_in_a_enum_declaration_cannot_reference_members_declared_after_it_including_members_defined_in_other_enums: { code: 2651, category: DiagnosticCategory.Error, key: "A member initializer in a enum declaration cannot reference members declared after it, including members defined in other enums." }, Merged_declaration_0_cannot_include_a_default_export_declaration_Consider_adding_a_separate_export_default_0_declaration_instead: { code: 2652, category: DiagnosticCategory.Error, key: "Merged declaration '{0}' cannot include a default export declaration. Consider adding a separate 'export default {0}' declaration instead." }, Non_abstract_class_expression_does_not_implement_inherited_abstract_member_0_from_class_1: { code: 2653, category: DiagnosticCategory.Error, key: "Non-abstract class expression does not implement inherited abstract member '{0}' from class '{1}'." }, + Proper_external_module_that_carries_external_typings_cannot_contain_tripleslash_references: { code: 2654, category: DiagnosticCategory.Error, key: "Proper external module that carries external typings cannot contain tripleslash references." }, + Proper_external_module_that_carries_external_typings_should_be_d_ts_file: { code: 2655, category: DiagnosticCategory.Error, key: "Proper external module that carries external typings should be '.d.ts' file." }, Import_declaration_0_is_using_private_name_1: { code: 4000, category: DiagnosticCategory.Error, key: "Import declaration '{0}' is using private name '{1}'." }, Type_parameter_0_of_exported_class_has_or_is_using_private_name_1: { code: 4002, category: DiagnosticCategory.Error, key: "Type parameter '{0}' of exported class has or is using private name '{1}'." }, Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1: { code: 4004, category: DiagnosticCategory.Error, key: "Type parameter '{0}' of exported interface has or is using private name '{1}'." }, diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index 7abec7b7c43..c62f08555df 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -1701,7 +1701,14 @@ "category": "Error", "code": 2653 }, - + "Proper external module that carries external typings cannot contain tripleslash references.": { + "category": "Error", + "code": 2654 + }, + "Proper external module that carries external typings should be '.d.ts' file.": { + "category": "Error", + "code": 2655 + }, "Import declaration '{0}' is using private name '{1}'.": { "category": "Error", "code": 4000 diff --git a/src/compiler/program.ts b/src/compiler/program.ts index a1861f6b462..ff3f5c2ba8a 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -36,7 +36,7 @@ namespace ts { return normalizePath(referencedFileName); } - export function resolveModuleName(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost): ResolvedModule { + export function resolveModuleName(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost): ResolvedModuleWithFailedLookupLocations { let moduleResolution = compilerOptions.moduleResolution !== undefined ? compilerOptions.moduleResolution : compilerOptions.module === ModuleKind.CommonJS ? ModuleResolutionKind.NodeJs : ModuleResolutionKind.Classic; @@ -47,7 +47,7 @@ namespace ts { } } - export function nodeModuleNameResolver(moduleName: string, containingFile: string, host: ModuleResolutionHost): ResolvedModule { + export function nodeModuleNameResolver(moduleName: string, containingFile: string, host: ModuleResolutionHost): ResolvedModuleWithFailedLookupLocations { let containingDirectory = getDirectoryPath(containingFile); if (getRootLength(moduleName) !== 0 || nameStartsWithDotSlashOrDotDotSlash(moduleName)) { @@ -56,11 +56,13 @@ namespace ts { let resolvedFileName = loadNodeModuleFromFile(candidate, /* loadOnlyDts */ false, failedLookupLocations, host); if (resolvedFileName) { - return { resolvedFileName, failedLookupLocations }; + return { resolvedModule: { resolvedFileName }, failedLookupLocations }; } resolvedFileName = loadNodeModuleFromDirectory(candidate, /* loadOnlyDts */ false, failedLookupLocations, host); - return { resolvedFileName, failedLookupLocations }; + return resolvedFileName + ? { resolvedModule: { resolvedFileName }, failedLookupLocations } + : { resolvedModule: undefined, failedLookupLocations }; } else { return loadModuleFromNodeModules(moduleName, containingDirectory, host); @@ -117,7 +119,7 @@ namespace ts { return loadNodeModuleFromFile(combinePaths(candidate, "index"), loadOnlyDts, failedLookupLocation, host); } - function loadModuleFromNodeModules(moduleName: string, directory: string, host: ModuleResolutionHost): ResolvedModule { + function loadModuleFromNodeModules(moduleName: string, directory: string, host: ModuleResolutionHost): ResolvedModuleWithFailedLookupLocations { let failedLookupLocations: string[] = []; directory = normalizeSlashes(directory); while (true) { @@ -127,12 +129,12 @@ namespace ts { let candidate = normalizePath(combinePaths(nodeModulesFolder, moduleName)); let result = loadNodeModuleFromFile(candidate, /* loadOnlyDts */ true, failedLookupLocations, host); if (result) { - return { resolvedFileName: result, failedLookupLocations }; + return { resolvedModule: { resolvedFileName: result, shouldBeProperExternalModule: true }, failedLookupLocations }; } result = loadNodeModuleFromDirectory(candidate, /* loadOnlyDts */ true, failedLookupLocations, host); if (result) { - return { resolvedFileName: result, failedLookupLocations }; + return { resolvedModule: { resolvedFileName: result, shouldBeProperExternalModule: true }, failedLookupLocations }; } } @@ -144,47 +146,19 @@ namespace ts { directory = parentPath; } - return { resolvedFileName: undefined, failedLookupLocations }; - } - - export function baseUrlModuleNameResolver(moduleName: string, containingFile: string, baseUrl: string, host: ModuleResolutionHost): ResolvedModule { - Debug.assert(baseUrl !== undefined); - - let normalizedModuleName = normalizeSlashes(moduleName); - let basePart = useBaseUrl(moduleName) ? baseUrl : getDirectoryPath(containingFile); - let candidate = normalizePath(combinePaths(basePart, moduleName)); - - let failedLookupLocations: string[] = []; - - return forEach(supportedExtensions, ext => tryLoadFile(candidate + ext)) || { resolvedFileName: undefined, failedLookupLocations }; - - function tryLoadFile(location: string): ResolvedModule { - if (host.fileExists(location)) { - return { resolvedFileName: location, failedLookupLocations }; - } - else { - failedLookupLocations.push(location); - return undefined; - } - } + return { resolvedModule: undefined, failedLookupLocations }; } function nameStartsWithDotSlashOrDotDotSlash(name: string) { let i = name.lastIndexOf("./", 1); return i === 0 || (i === 1 && name.charCodeAt(0) === CharacterCodes.dot); } - - function useBaseUrl(moduleName: string): boolean { - // path is not rooted - // module name does not start with './' or '../' - return getRootLength(moduleName) === 0 && !nameStartsWithDotSlashOrDotDotSlash(moduleName); - } - export function classicNameResolver(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost): ResolvedModule { + export function classicNameResolver(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost): ResolvedModuleWithFailedLookupLocations { // module names that contain '!' are used to reference resources and are not resolved to actual files on disk if (moduleName.indexOf('!') != -1) { - return { resolvedFileName: undefined, failedLookupLocations: [] }; + return { resolvedModule: undefined, failedLookupLocations: [] }; } let searchPath = getDirectoryPath(containingFile); @@ -222,7 +196,9 @@ namespace ts { searchPath = parentPath; } - return { resolvedFileName: referencedSourceFile, failedLookupLocations }; + return referencedSourceFile + ? { resolvedModule: { resolvedFileName: referencedSourceFile }, failedLookupLocations } + : { resolvedModule: undefined, failedLookupLocations }; } /* @internal */ @@ -371,9 +347,9 @@ namespace ts { host = host || createCompilerHost(options); - const resolveModuleNamesWorker = - host.resolveModuleNames || - ((moduleNames, containingFile) => map(moduleNames, moduleName => resolveModuleName(moduleName, containingFile, options, host).resolvedFileName)); + const resolveModuleNamesWorker = host.resolveModuleNames + ? ((moduleNames: string[], containingFile: string) => host.resolveModuleNames(moduleNames, containingFile)) + : ((moduleNames: string[], containingFile: string) => map(moduleNames, moduleName => resolveModuleName(moduleName, containingFile, options, host).resolvedModule)); let filesByName = createFileMap(fileName => host.getCanonicalFileName(fileName)); @@ -491,10 +467,17 @@ namespace ts { let resolutions = resolveModuleNamesWorker(moduleNames, newSourceFile.fileName); // ensure that module resolution results are still correct for (let i = 0; i < moduleNames.length; ++i) { - let oldResolution = getResolvedModuleFileName(oldSourceFile, moduleNames[i]); - if (oldResolution !== resolutions[i]) { + let newResolution = resolutions[i]; + let oldResolution = getResolvedModule(oldSourceFile, moduleNames[i]); + let resolutionChanged = oldResolution + ? !newResolution || + oldResolution.resolvedFileName !== newResolution.resolvedFileName || + !!oldResolution.shouldBeProperExternalModule !== !!newResolution.shouldBeProperExternalModule + : newResolution; + + if (resolutionChanged) { return false; - } + } } } // pass the cache of module resolutions from the old source file @@ -864,9 +847,23 @@ namespace ts { let resolutions = resolveModuleNamesWorker(moduleNames, file.fileName); for (let i = 0; i < file.imports.length; ++i) { let resolution = resolutions[i]; - setResolvedModuleName(file, moduleNames[i], resolution); + setResolvedModule(file, moduleNames[i], resolution); if (resolution && !options.noResolve) { - findModuleSourceFile(resolution, file.imports[i]); + const importedFile = findModuleSourceFile(resolution.resolvedFileName, file.imports[i]); + if (importedFile && resolution.shouldBeProperExternalModule) { + if (!isExternalModule(importedFile)) { + let start = getTokenPosOfNode(file.imports[i], file) + diagnostics.add(createFileDiagnostic(file, start, file.imports[i].end - start, Diagnostics.File_0_is_not_a_module, importedFile.fileName)); + } + else if (!fileExtensionIs(importedFile.fileName, ".d.ts")) { + let start = getTokenPosOfNode(file.imports[i], file) + diagnostics.add(createFileDiagnostic(file, start, file.imports[i].end - start, Diagnostics.Proper_external_module_that_carries_external_typings_should_be_d_ts_file)); + } + else if (importedFile.referencedFiles.length) { + let firstRef = importedFile.referencedFiles[0]; + diagnostics.add(createFileDiagnostic(importedFile, firstRef.pos, firstRef.end - firstRef.pos, Diagnostics.Proper_external_module_that_carries_external_typings_cannot_contain_tripleslash_references)); + } + } } } } diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 47182e39527..d7bc6b4edbc 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -1284,7 +1284,7 @@ namespace ts { // Stores a mapping 'external module reference text' -> 'resolved file name' | undefined // It is used to resolve module names in the checker. // Content of this fiels should never be used directly - use getResolvedModuleFileName/setResolvedModuleFileName functions instead - /* @internal */ resolvedModules: Map; + /* @internal */ resolvedModules: Map; /* @internal */ imports: LiteralExpression[]; } @@ -2269,11 +2269,20 @@ namespace ts { export interface ResolvedModule { resolvedFileName: string; + /* + * Denotes if 'resolvedFileName' should be proper external module: + * - be a .d.ts file + * - use top level imports\exports + * - don't use tripleslash references + */ + shouldBeProperExternalModule?: boolean; + } + + export interface ResolvedModuleWithFailedLookupLocations { + resolvedModule: ResolvedModule; failedLookupLocations: string[]; } - export type ModuleNameResolver = (moduleName: string, containingFile: string, options: CompilerOptions, host: ModuleResolutionHost) => ResolvedModule; - export interface CompilerHost extends ModuleResolutionHost { getSourceFile(fileName: string, languageVersion: ScriptTarget, onError?: (message: string) => void): SourceFile; getCancellationToken?(): CancellationToken; @@ -2291,7 +2300,7 @@ namespace ts { * If resolveModuleNames is implemented then implementation for members from ModuleResolutionHost can be just * 'throw new Error("NotImplemented")' */ - resolveModuleNames?(moduleNames: string[], containingFile: string): string[]; + resolveModuleNames?(moduleNames: string[], containingFile: string): ResolvedModule[]; } export interface TextSpan { diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index 99ea06532a0..096907cef62 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -99,20 +99,20 @@ namespace ts { return true; } - export function hasResolvedModuleName(sourceFile: SourceFile, moduleNameText: string): boolean { + export function hasResolvedModule(sourceFile: SourceFile, moduleNameText: string): boolean { return sourceFile.resolvedModules && hasProperty(sourceFile.resolvedModules, moduleNameText); } - export function getResolvedModuleFileName(sourceFile: SourceFile, moduleNameText: string): string { - return hasResolvedModuleName(sourceFile, moduleNameText) ? sourceFile.resolvedModules[moduleNameText] : undefined; + export function getResolvedModule(sourceFile: SourceFile, moduleNameText: string): ResolvedModule { + return hasResolvedModule(sourceFile, moduleNameText) ? sourceFile.resolvedModules[moduleNameText] : undefined; } - export function setResolvedModuleName(sourceFile: SourceFile, moduleNameText: string, resolvedFileName: string): void { + export function setResolvedModule(sourceFile: SourceFile, moduleNameText: string, resolvedModule: ResolvedModule): void { if (!sourceFile.resolvedModules) { sourceFile.resolvedModules = {}; } - sourceFile.resolvedModules[moduleNameText] = resolvedFileName; + sourceFile.resolvedModules[moduleNameText] = resolvedModule; } // Returns true if this node contains a parse error anywhere underneath it. diff --git a/src/harness/harnessLanguageService.ts b/src/harness/harnessLanguageService.ts index f228bc862d8..c97ce50d275 100644 --- a/src/harness/harnessLanguageService.ts +++ b/src/harness/harnessLanguageService.ts @@ -225,8 +225,8 @@ module Harness.LanguageService { let imports: ts.Map = {}; for (let module of preprocessInfo.importedFiles) { let resolutionInfo = ts.resolveModuleName(module.fileName, fileName, compilerOptions, moduleResolutionHost); - if (resolutionInfo.resolvedFileName) { - imports[module.fileName] = resolutionInfo.resolvedFileName; + if (resolutionInfo.resolvedModule) { + imports[module.fileName] = resolutionInfo.resolvedModule.resolvedFileName; } } return JSON.stringify(imports); diff --git a/src/server/editorServices.ts b/src/server/editorServices.ts index 76bc586b8bb..7ab46fc689e 100644 --- a/src/server/editorServices.ts +++ b/src/server/editorServices.ts @@ -79,7 +79,7 @@ namespace ts.server { } } - interface TimestampedResolvedModule extends ResolvedModule { + interface TimestampedResolvedModule extends ResolvedModuleWithFailedLookupLocations { lastCheckTime: number; } @@ -99,11 +99,11 @@ namespace ts.server { } } - resolveModuleNames(moduleNames: string[], containingFile: string): string[] { + resolveModuleNames(moduleNames: string[], containingFile: string): ResolvedModule[] { let currentResolutionsInFile = this.resolvedModuleNames.get(containingFile); let newResolutions: Map = {}; - let resolvedFileNames: string[] = []; + let resolvedModules: ResolvedModule[] = []; let compilerOptions = this.getCompilationSettings(); @@ -119,25 +119,25 @@ namespace ts.server { else { resolution = resolveModuleName(moduleName, containingFile, compilerOptions, this.moduleResolutionHost); resolution.lastCheckTime = Date.now(); - newResolutions[moduleName] = resolution; + newResolutions[moduleName] = resolution; } } ts.Debug.assert(resolution !== undefined); - resolvedFileNames.push(resolution.resolvedFileName); + resolvedModules.push(resolution.resolvedModule); } // replace old results with a new one this.resolvedModuleNames.set(containingFile, newResolutions); - return resolvedFileNames; + return resolvedModules; function moduleResolutionIsValid(resolution: TimestampedResolvedModule): boolean { if (!resolution) { return false; } - if (resolution.resolvedFileName) { + if (resolution.resolvedModule) { // TODO: consider checking failedLookupLocations // TODO: use lastCheckTime to track expiration for module name resolution return true; diff --git a/src/services/services.ts b/src/services/services.ts index d5ede917b8f..9fbcc05a5ff 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -802,7 +802,7 @@ namespace ts { public languageVariant: LanguageVariant; public identifiers: Map; public nameTable: Map; - public resolvedModules: Map; + public resolvedModules: Map; public imports: LiteralExpression[]; private namedDeclarations: Map; @@ -1022,7 +1022,7 @@ namespace ts { * if implementation is omitted then language service will use built-in module resolution logic and get answers to * host specific questions using 'getScriptSnapshot'. */ - resolveModuleNames?(moduleNames: string[], containingFile: string): string[]; + resolveModuleNames?(moduleNames: string[], containingFile: string): ResolvedModule[]; } // diff --git a/src/services/shims.ts b/src/services/shims.ts index 307062cebd8..351514a1499 100644 --- a/src/services/shims.ts +++ b/src/services/shims.ts @@ -273,7 +273,7 @@ namespace ts { private loggingEnabled = false; private tracingEnabled = false; - public resolveModuleNames: (moduleName: string[], containingFile: string) => string[]; + public resolveModuleNames: (moduleName: string[], containingFile: string) => ResolvedModule[]; constructor(private shimHost: LanguageServiceShimHost) { // if shimHost is a COM object then property check will become method call with no arguments. @@ -281,7 +281,10 @@ namespace ts { if ("getModuleResolutionsForFile" in this.shimHost) { this.resolveModuleNames = (moduleNames: string[], containingFile: string) => { let resolutionsInFile = >JSON.parse(this.shimHost.getModuleResolutionsForFile(containingFile)); - return map(moduleNames, name => lookUp(resolutionsInFile, name)); + return map(moduleNames, name => { + const result = lookUp(resolutionsInFile, name); + return result ? { resolvedFileName: result } : undefined; + }); }; } } @@ -942,7 +945,11 @@ namespace ts { public resolveModuleName(fileName: string, moduleName: string, compilerOptionsJson: string): string { return this.forwardJSONCall(`resolveModuleName('${fileName}')`, () => { let compilerOptions = JSON.parse(compilerOptionsJson); - return resolveModuleName(moduleName, normalizeSlashes(fileName), compilerOptions, this.host); + const result = resolveModuleName(moduleName, normalizeSlashes(fileName), compilerOptions, this.host); + return { + resolvedFileName: result.resolvedModule ? result.resolvedModule.resolvedFileName: undefined, + failedLookupLocations: result.failedLookupLocations + }; }); } diff --git a/tests/baselines/reference/nodeResolution4.js b/tests/baselines/reference/nodeResolution4.js new file mode 100644 index 00000000000..0965c257da9 --- /dev/null +++ b/tests/baselines/reference/nodeResolution4.js @@ -0,0 +1,17 @@ +//// [tests/cases/compiler/nodeResolution4.ts] //// + +//// [ref.ts] + +var x = 1; + +//// [a.ts] +/// +export var y; + +//// [b.ts] +import y = require("./a"); + +//// [ref.js] +var x = 1; +//// [a.js] +//// [b.js] diff --git a/tests/baselines/reference/nodeResolution4.symbols b/tests/baselines/reference/nodeResolution4.symbols new file mode 100644 index 00000000000..b8e0b59284a --- /dev/null +++ b/tests/baselines/reference/nodeResolution4.symbols @@ -0,0 +1,14 @@ +=== tests/cases/compiler/b.ts === +import y = require("./a"); +>y : Symbol(y, Decl(b.ts, 0, 0)) + +=== tests/cases/compiler/ref.ts === + +var x = 1; +>x : Symbol(x, Decl(ref.ts, 1, 3)) + +=== tests/cases/compiler/a.ts === +/// +export var y; +>y : Symbol(y, Decl(a.ts, 1, 10)) + diff --git a/tests/baselines/reference/nodeResolution4.types b/tests/baselines/reference/nodeResolution4.types new file mode 100644 index 00000000000..b273b203bde --- /dev/null +++ b/tests/baselines/reference/nodeResolution4.types @@ -0,0 +1,15 @@ +=== tests/cases/compiler/b.ts === +import y = require("./a"); +>y : typeof y + +=== tests/cases/compiler/ref.ts === + +var x = 1; +>x : number +>1 : number + +=== tests/cases/compiler/a.ts === +/// +export var y; +>y : any + diff --git a/tests/baselines/reference/nodeResolution5.errors.txt b/tests/baselines/reference/nodeResolution5.errors.txt new file mode 100644 index 00000000000..1fc4e1cee52 --- /dev/null +++ b/tests/baselines/reference/nodeResolution5.errors.txt @@ -0,0 +1,14 @@ +tests/cases/compiler/b.ts(1,20): error TS2306: File 'tests/cases/compiler/node_modules/a.d.ts' is not a module. + + +==== tests/cases/compiler/b.ts (1 errors) ==== + import y = require("a"); + ~~~ +!!! error TS2306: File 'a.d.ts' is not a module. + +==== tests/cases/compiler/node_modules/a.d.ts (0 errors) ==== + + declare module "a" { + var x: number; + } + \ No newline at end of file diff --git a/tests/baselines/reference/nodeResolution5.js b/tests/baselines/reference/nodeResolution5.js new file mode 100644 index 00000000000..2bc009c1522 --- /dev/null +++ b/tests/baselines/reference/nodeResolution5.js @@ -0,0 +1,13 @@ +//// [tests/cases/compiler/nodeResolution5.ts] //// + +//// [a.d.ts] + +declare module "a" { + var x: number; +} + +//// [b.ts] +import y = require("a"); + + +//// [b.js] diff --git a/tests/baselines/reference/nodeResolution6.errors.txt b/tests/baselines/reference/nodeResolution6.errors.txt new file mode 100644 index 00000000000..8a462043207 --- /dev/null +++ b/tests/baselines/reference/nodeResolution6.errors.txt @@ -0,0 +1,17 @@ +tests/cases/compiler/node_modules/a.d.ts(1,1): error TS2654: Proper external module that carries external typings cannot contain tripleslash references. + + +==== tests/cases/compiler/b.ts (0 errors) ==== + import y = require("a"); + +==== tests/cases/compiler/node_modules/ref.ts (0 errors) ==== + + var x = 1; + +==== tests/cases/compiler/node_modules/a.d.ts (1 errors) ==== + /// + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2654: Proper external module that carries external typings cannot contain tripleslash references. + export declare var y; + + \ No newline at end of file diff --git a/tests/baselines/reference/nodeResolution6.js b/tests/baselines/reference/nodeResolution6.js new file mode 100644 index 00000000000..140edd61f5a --- /dev/null +++ b/tests/baselines/reference/nodeResolution6.js @@ -0,0 +1,18 @@ +//// [tests/cases/compiler/nodeResolution6.ts] //// + +//// [ref.ts] + +var x = 1; + +//// [a.d.ts] +/// +export declare var y; + + +//// [b.ts] +import y = require("a"); + + +//// [ref.js] +var x = 1; +//// [b.js] diff --git a/tests/baselines/reference/nodeResolution7.errors.txt b/tests/baselines/reference/nodeResolution7.errors.txt new file mode 100644 index 00000000000..1e1f822f0d4 --- /dev/null +++ b/tests/baselines/reference/nodeResolution7.errors.txt @@ -0,0 +1,14 @@ +tests/cases/compiler/b.ts(1,20): error TS2306: File 'tests/cases/compiler/node_modules/a/index.d.ts' is not a module. + + +==== tests/cases/compiler/b.ts (1 errors) ==== + import y = require("a"); + ~~~ +!!! error TS2306: File 'index.d.ts' is not a module. + +==== tests/cases/compiler/node_modules/a/index.d.ts (0 errors) ==== + + declare module "a" { + var x: number; + } + \ No newline at end of file diff --git a/tests/baselines/reference/nodeResolution7.js b/tests/baselines/reference/nodeResolution7.js new file mode 100644 index 00000000000..abfbbad52a6 --- /dev/null +++ b/tests/baselines/reference/nodeResolution7.js @@ -0,0 +1,13 @@ +//// [tests/cases/compiler/nodeResolution7.ts] //// + +//// [index.d.ts] + +declare module "a" { + var x: number; +} + +//// [b.ts] +import y = require("a"); + + +//// [b.js] diff --git a/tests/baselines/reference/nodeResolution8.errors.txt b/tests/baselines/reference/nodeResolution8.errors.txt new file mode 100644 index 00000000000..82753a2049b --- /dev/null +++ b/tests/baselines/reference/nodeResolution8.errors.txt @@ -0,0 +1,16 @@ +tests/cases/compiler/node_modules/a/index.d.ts(1,1): error TS2654: Proper external module that carries external typings cannot contain tripleslash references. + + +==== tests/cases/compiler/b.ts (0 errors) ==== + import y = require("a"); +==== tests/cases/compiler/node_modules/a/ref.ts (0 errors) ==== + + var x = 1; + +==== tests/cases/compiler/node_modules/a/index.d.ts (1 errors) ==== + /// + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2654: Proper external module that carries external typings cannot contain tripleslash references. + export declare var y; + + \ No newline at end of file diff --git a/tests/baselines/reference/nodeResolution8.js b/tests/baselines/reference/nodeResolution8.js new file mode 100644 index 00000000000..aa67f4bf9cc --- /dev/null +++ b/tests/baselines/reference/nodeResolution8.js @@ -0,0 +1,17 @@ +//// [tests/cases/compiler/nodeResolution8.ts] //// + +//// [ref.ts] + +var x = 1; + +//// [index.d.ts] +/// +export declare var y; + + +//// [b.ts] +import y = require("a"); + +//// [ref.js] +var x = 1; +//// [b.js] diff --git a/tests/cases/compiler/nodeResolution4.ts b/tests/cases/compiler/nodeResolution4.ts new file mode 100644 index 00000000000..247546c3f0c --- /dev/null +++ b/tests/cases/compiler/nodeResolution4.ts @@ -0,0 +1,12 @@ +// @module: commonjs +// @moduleResolution: node + +// @filename: ref.ts +var x = 1; + +// @filename: a.ts +/// +export var y; + +// @filename: b.ts +import y = require("./a"); \ No newline at end of file diff --git a/tests/cases/compiler/nodeResolution5.ts b/tests/cases/compiler/nodeResolution5.ts new file mode 100644 index 00000000000..313dabd7899 --- /dev/null +++ b/tests/cases/compiler/nodeResolution5.ts @@ -0,0 +1,10 @@ +// @module: commonjs +// @moduleResolution: node + +// @filename: node_modules/a.d.ts +declare module "a" { + var x: number; +} + +// @filename: b.ts +import y = require("a"); diff --git a/tests/cases/compiler/nodeResolution6.ts b/tests/cases/compiler/nodeResolution6.ts new file mode 100644 index 00000000000..3f6dc81c847 --- /dev/null +++ b/tests/cases/compiler/nodeResolution6.ts @@ -0,0 +1,13 @@ +// @module: commonjs +// @moduleResolution: node + +// @filename: node_modules/ref.ts +var x = 1; + +// @filename: node_modules/a.d.ts +/// +export declare var y; + + +// @filename: b.ts +import y = require("a"); diff --git a/tests/cases/compiler/nodeResolution7.ts b/tests/cases/compiler/nodeResolution7.ts new file mode 100644 index 00000000000..b4283edb76a --- /dev/null +++ b/tests/cases/compiler/nodeResolution7.ts @@ -0,0 +1,10 @@ +// @module: commonjs +// @moduleResolution: node + +// @filename: node_modules/a/index.d.ts +declare module "a" { + var x: number; +} + +// @filename: b.ts +import y = require("a"); diff --git a/tests/cases/compiler/nodeResolution8.ts b/tests/cases/compiler/nodeResolution8.ts new file mode 100644 index 00000000000..0a6e528f20a --- /dev/null +++ b/tests/cases/compiler/nodeResolution8.ts @@ -0,0 +1,13 @@ +// @module: commonjs +// @moduleResolution: node + +// @filename: node_modules/a/ref.ts +var x = 1; + +// @filename: node_modules/a/index.d.ts +/// +export declare var y; + + +// @filename: b.ts +import y = require("a"); \ No newline at end of file diff --git a/tests/cases/unittests/moduleResolution.ts b/tests/cases/unittests/moduleResolution.ts index 0917e72f1ce..ab12119ec5a 100644 --- a/tests/cases/unittests/moduleResolution.ts +++ b/tests/cases/unittests/moduleResolution.ts @@ -40,8 +40,9 @@ module ts { let containingFile = { name: containingFileName } let moduleFile = { name: moduleFileNameNoExt + ext } let resolution = nodeModuleNameResolver(moduleName, containingFile.name, createModuleResolutionHost(containingFile, moduleFile)); - assert.equal(resolution.resolvedFileName, moduleFile.name); - + assert.equal(resolution.resolvedModule.resolvedFileName, moduleFile.name); + assert.equal(!!resolution.resolvedModule.shouldBeProperExternalModule, false); + let failedLookupLocations: string[] = []; let dir = getDirectoryPath(containingFileName); for (let e of supportedExtensions) { @@ -78,7 +79,8 @@ module ts { let packageJson = { name: packageJsonFileName, content: JSON.stringify({ "typings": fieldRef }) }; let moduleFile = { name: moduleFileName }; let resolution = nodeModuleNameResolver(moduleName, containingFile.name, createModuleResolutionHost(containingFile, packageJson, moduleFile)); - assert.equal(resolution.resolvedFileName, moduleFile.name); + assert.equal(resolution.resolvedModule.resolvedFileName, moduleFile.name); + assert.equal(!!resolution.resolvedModule.shouldBeProperExternalModule, false); // expect three failed lookup location - attempt to load module as file with all supported extensions assert.equal(resolution.failedLookupLocations.length, 3); } @@ -95,7 +97,8 @@ module ts { let packageJson = {name: "/a/b/foo/package.json", content: JSON.stringify({main: "/c/d"})}; let indexFile = { name: "/a/b/foo/index.d.ts" }; let resolution = nodeModuleNameResolver("./foo", containingFile.name, createModuleResolutionHost(containingFile, packageJson, indexFile)); - assert.equal(resolution.resolvedFileName, indexFile.name); + assert.equal(resolution.resolvedModule.resolvedFileName, indexFile.name); + assert.equal(!!resolution.resolvedModule.shouldBeProperExternalModule, false); assert.deepEqual(resolution.failedLookupLocations, [ "/a/b/foo.ts", "/a/b/foo.tsx", @@ -111,7 +114,7 @@ module ts { let containingFile = { name: "/a/b/c/d/e.ts" }; let moduleFile = { name: "/a/b/node_modules/foo.ts" }; let resolution = nodeModuleNameResolver("foo", containingFile.name, createModuleResolutionHost(containingFile, moduleFile)); - assert.equal(resolution.resolvedFileName, undefined); + assert.equal(resolution.resolvedModule, undefined); assert.deepEqual(resolution.failedLookupLocations, [ "/a/b/c/d/node_modules/foo.d.ts", "/a/b/c/d/node_modules/foo/package.json", @@ -135,14 +138,16 @@ module ts { let containingFile = { name: "/a/b/c/d/e.ts" }; let moduleFile = { name: "/a/b/node_modules/foo.d.ts" }; let resolution = nodeModuleNameResolver("foo", containingFile.name, createModuleResolutionHost(containingFile, moduleFile)); - assert.equal(resolution.resolvedFileName, moduleFile.name); + assert.equal(resolution.resolvedModule.resolvedFileName, moduleFile.name); + assert.equal(resolution.resolvedModule.shouldBeProperExternalModule, true); }); it("load module as directory", () => { let containingFile = { name: "/a/node_modules/b/c/node_modules/d/e.ts" }; let moduleFile = { name: "/a/node_modules/foo/index.d.ts" }; let resolution = nodeModuleNameResolver("foo", containingFile.name, createModuleResolutionHost(containingFile, moduleFile)); - assert.equal(resolution.resolvedFileName, moduleFile.name); + assert.equal(resolution.resolvedModule.resolvedFileName, moduleFile.name); + assert.equal(resolution.resolvedModule.shouldBeProperExternalModule, true); assert.deepEqual(resolution.failedLookupLocations, [ "/a/node_modules/b/c/node_modules/d/node_modules/foo.d.ts", "/a/node_modules/b/c/node_modules/d/node_modules/foo/package.json", @@ -158,64 +163,4 @@ module ts { ]); }); }); - - describe("BaseUrl mode", () => { - - it ("load module as relative url", () => { - function test(containingFileName: string, moduleFileName: string, moduleName: string): void { - let containingFile = {name: containingFileName }; - let moduleFile = { name: moduleFileName }; - let resolution = baseUrlModuleNameResolver(moduleName, containingFile.name, "", createModuleResolutionHost(containingFile, moduleFile)); - assert.equal(resolution.resolvedFileName, moduleFile.name); - let expectedFailedLookupLocations: string[] = []; - - let moduleNameHasExt = forEach(supportedExtensions, e => fileExtensionIs(moduleName, e)); - if (!moduleNameHasExt) { - let dir = getDirectoryPath(containingFileName); - - // add candidates with extensions that precede extension of the actual module name file in the list of supportd extensions - for (let ext of supportedExtensions) { - - let hasExtension = ext !== ".ts" - ? fileExtensionIs(moduleFileName, ext) - : fileExtensionIs(moduleFileName, ".ts") && !fileExtensionIs(moduleFileName, ".d.ts"); - - if (hasExtension) { - break; - } - else { - expectedFailedLookupLocations.push(normalizePath(combinePaths(dir, moduleName + ext))); - } - } - } - - assert.deepEqual(resolution.failedLookupLocations, expectedFailedLookupLocations) - } - - test("/a/b/c/d.ts", "/foo.ts", "/foo"); - test("/a/b/c/d.ts", "/foo.d.ts", "/foo"); - test("/a/b/c/d.ts", "/foo.tsx", "/foo"); - - test("/a/b/c/d.ts", "/a/b/c/foo.ts", "./foo"); - test("/a/b/c/d.ts", "/a/b/c/foo.d.ts", "./foo"); - test("/a/b/c/d.ts", "/a/b/c/foo.tsx", "./foo"); - - test("/a/b/c/d.ts", "/a/b/foo.ts", "../foo"); - test("/a/b/c/d.ts", "/a/b/foo.d.ts", "../foo"); - test("/a/b/c/d.ts", "/a/b/foo.tsx", "../foo"); - }); - - it ("load module using base url", () => { - function test(containingFileName: string, moduleFileName: string, moduleName: string, baseUrl: string): void { - let containingFile = { name: containingFileName }; - let moduleFile = { name: moduleFileName }; - let resolution = baseUrlModuleNameResolver(moduleName, containingFileName, baseUrl, createModuleResolutionHost(containingFile, moduleFile)); - assert.equal(resolution.resolvedFileName, moduleFile.name); - } - - test("/a/base/c/d.ts", "/a/base/c/d/e.ts", "c/d/e", "/a/base"); - test("/a/base/c/d.ts", "/a/base/c/d/e.d.ts", "c/d/e", "/a/base"); - test("/a/base/c/d.ts", "/a/base/c/d/e.tsx", "c/d/e", "/a/base"); - }); - }); } \ No newline at end of file diff --git a/tests/cases/unittests/reuseProgramStructure.ts b/tests/cases/unittests/reuseProgramStructure.ts index 6c043299c8f..14bf09d6db8 100644 --- a/tests/cases/unittests/reuseProgramStructure.ts +++ b/tests/cases/unittests/reuseProgramStructure.ts @@ -160,7 +160,7 @@ module ts { return size; } - function checkResolvedModulesCache(program: Program, fileName: string, expectedContent: Map): void { + function checkResolvedModulesCache(program: Program, fileName: string, expectedContent: Map): void { let file = program.getSourceFile(fileName); assert.isTrue(file !== undefined, `cannot find file ${fileName}`); if (expectedContent === undefined) { @@ -175,7 +175,16 @@ module ts { for (let id in expectedContent) { if (hasProperty(expectedContent, id)) { assert.isTrue(hasProperty(file.resolvedModules, id), `expected ${id} to be found in resolved modules`); - assert.isTrue(expectedContent[id] === file.resolvedModules[id], `expected '${expectedContent[id]}' to be equal to '${file.resolvedModules[id]}'`); + if (expectedContent[id]) { + const expected = expectedContent[id]; + const actual = file.resolvedModules[id]; + assert.isTrue(actual !== undefined); + assert.isTrue(expected.resolvedFileName === actual.resolvedFileName, `'resolvedFileName': expected '${expected.resolvedFileName}' to be equal to '${actual.resolvedFileName}'`); + assert.isTrue(expected.shouldBeProperExternalModule === actual.shouldBeProperExternalModule, `'shouldBeProperExternalModule': expected '${expected.shouldBeProperExternalModule}' to be equal to '${actual.shouldBeProperExternalModule}'`); + } + else { + assert.isTrue(file.resolvedModules[id] === undefined); + } } } } @@ -230,7 +239,7 @@ module ts { var options: CompilerOptions = { target }; var program_1 = newProgram(files, ["a.ts"], options); - checkResolvedModulesCache(program_1, "a.ts", { "b": "b.ts" }); + checkResolvedModulesCache(program_1, "a.ts", { "b": { resolvedFileName: "b.ts" } }); checkResolvedModulesCache(program_1, "b.ts", undefined); var program_2 = updateProgram(program_1, ["a.ts"], options, files => { @@ -239,7 +248,7 @@ module ts { assert.isTrue(program_1.structureIsReused); // content of resolution cache should not change - checkResolvedModulesCache(program_1, "a.ts", { "b": "b.ts" }); + checkResolvedModulesCache(program_1, "a.ts", { "b": { resolvedFileName: "b.ts" } }); checkResolvedModulesCache(program_1, "b.ts", undefined); // imports has changed - program is not reused @@ -256,7 +265,7 @@ module ts { files[0].text = files[0].text.updateImportsAndExports(newImports); }); assert.isTrue(!program_3.structureIsReused); - checkResolvedModulesCache(program_4, "a.ts", { "b": "b.ts", "c": undefined }); + checkResolvedModulesCache(program_4, "a.ts", { "b": { resolvedFileName: "b.ts" }, "c": undefined }); }); }) } \ No newline at end of file From 32ac25d48fc1d79d6e0686a73717d13957b6ea41 Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Thu, 10 Sep 2015 16:12:41 -0700 Subject: [PATCH 104/117] rename .settings to .vscode --- {.settings => .vscode}/tasks.json | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {.settings => .vscode}/tasks.json (100%) diff --git a/.settings/tasks.json b/.vscode/tasks.json similarity index 100% rename from .settings/tasks.json rename to .vscode/tasks.json From d5ff9ee1e1e20b82a08a44d1183c1ea545af8a3e Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Thu, 10 Sep 2015 16:22:50 -0700 Subject: [PATCH 105/117] Error when binding element has no value in initializer and no default --- src/compiler/checker.ts | 43 +++++++++++++------ .../diagnosticInformationMap.generated.ts | 1 + src/compiler/diagnosticMessages.json | 4 ++ src/compiler/types.ts | 1 + 4 files changed, 35 insertions(+), 14 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 91234ebb387..e4d6929fe6b 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -2434,6 +2434,7 @@ namespace ts { let name = e.propertyName || e.name; let symbol = createSymbol(flags, name.text); symbol.type = getTypeFromBindingElement(e, includePatternInType); + symbol.bindingElement = e; members[symbol.name] = symbol; }); let result = createAnonymousType(undefined, members, emptyArray, emptyArray, undefined, undefined); @@ -2451,12 +2452,12 @@ namespace ts { } // If the pattern has at least one element, and no rest element, then it should imply a tuple type. let elementTypes = map(elements, e => e.kind === SyntaxKind.OmittedExpression ? anyType : getTypeFromBindingElement(e, includePatternInType)); - let result = createTupleType(elementTypes); if (includePatternInType) { - result = clone(result); + let result = createNewTupleType(elementTypes); result.pattern = pattern; + return result; } - return result; + return createTupleType(elementTypes); } // Return the type implied by a binding pattern. This is the type implied purely by the binding pattern itself @@ -3124,7 +3125,7 @@ namespace ts { } function findMatchingSignature(signatureList: Signature[], signature: Signature, partialMatch: boolean, ignoreReturnTypes: boolean): Signature { - for (let s of signatureList) { + for (let s of signatureList) { if (compareSignatures(s, signature, partialMatch, ignoreReturnTypes, compareTypes)) { return s; } @@ -4045,11 +4046,12 @@ namespace ts { function createTupleType(elementTypes: Type[]) { let id = getTypeListId(elementTypes); - let type = tupleTypes[id]; - if (!type) { - type = tupleTypes[id] = createObjectType(TypeFlags.Tuple | getPropagatingFlagsOfTypes(elementTypes)); - type.elementTypes = elementTypes; - } + return tupleTypes[id] || (tupleTypes[id] = createNewTupleType(elementTypes)); + } + + function createNewTupleType(elementTypes: Type[]) { + let type = createObjectType(TypeFlags.Tuple | getPropagatingFlagsOfTypes(elementTypes)); + type.elementTypes = elementTypes; return type; } @@ -7042,19 +7044,28 @@ namespace ts { // If array literal is actually a destructuring pattern, mark it as an implied type. We do this such // that we get the same behavior for "var [x, y] = []" and "[x, y] = []". if (inDestructuringPattern && elementTypes.length) { - let type = clone(createTupleType(elementTypes)); + let type = createNewTupleType(elementTypes); type.pattern = node; return type; } let contextualType = getContextualType(node); if (contextualType && contextualTypeIsTupleLikeType(contextualType)) { let pattern = contextualType.pattern; - // If array literal is contextually typed by a binding pattern or an assignment pattern, pad the - // resulting tuple type to make the lengths equal. + // If array literal is contextually typed by a binding pattern or an assignment pattern, pad the resulting + // tuple type with the corresponding binding or assignment element types to make the lengths equal. if (pattern && (pattern.kind === SyntaxKind.ArrayBindingPattern || pattern.kind === SyntaxKind.ArrayLiteralExpression)) { let patternElements = (pattern).elements; for (let i = elementTypes.length; i < patternElements.length; i++) { - elementTypes.push(hasDefaultValue(patternElements[i]) ? (contextualType).elementTypes[i] : undefinedType); + let patternElement = patternElements[i]; + if (hasDefaultValue(patternElement)) { + elementTypes.push((contextualType).elementTypes[i]); + } + else { + if (patternElement.kind !== SyntaxKind.OmittedExpression) { + error(patternElement, Diagnostics.Initializer_provides_no_value_for_this_binding_element_and_the_binding_element_has_no_default_value); + } + elementTypes.push(unknownType); + } } } if (elementTypes.length) { @@ -7201,7 +7212,11 @@ namespace ts { // type with those properties for which the binding pattern specifies a default value. if (contextualTypeHasPattern) { for (let prop of getPropertiesOfType(contextualType)) { - if (prop.flags & SymbolFlags.Optional && !hasProperty(propertiesTable, prop.name)) { + if (!hasProperty(propertiesTable, prop.name)) { + if (!(prop.flags & SymbolFlags.Optional)) { + error(prop.valueDeclaration || (prop).bindingElement, + Diagnostics.Initializer_provides_no_value_for_this_binding_element_and_the_binding_element_has_no_default_value); + } propertiesTable[prop.name] = prop; propertiesArray.push(prop); } diff --git a/src/compiler/diagnosticInformationMap.generated.ts b/src/compiler/diagnosticInformationMap.generated.ts index f7351bf6912..9686d6580f5 100644 --- a/src/compiler/diagnosticInformationMap.generated.ts +++ b/src/compiler/diagnosticInformationMap.generated.ts @@ -415,6 +415,7 @@ namespace ts { The_arguments_object_cannot_be_referenced_in_an_async_arrow_function_Consider_using_a_standard_async_function_expression: { code: 2522, category: DiagnosticCategory.Error, key: "The 'arguments' object cannot be referenced in an async arrow function. Consider using a standard async function expression." }, yield_expressions_cannot_be_used_in_a_parameter_initializer: { code: 2523, category: DiagnosticCategory.Error, key: "'yield' expressions cannot be used in a parameter initializer." }, await_expressions_cannot_be_used_in_a_parameter_initializer: { code: 2524, category: DiagnosticCategory.Error, key: "'await' expressions cannot be used in a parameter initializer." }, + Initializer_provides_no_value_for_this_binding_element_and_the_binding_element_has_no_default_value: { code: 2525, category: DiagnosticCategory.Error, key: "Initializer provides no value for this binding element and the binding element has no default value" }, JSX_element_attributes_type_0_must_be_an_object_type: { code: 2600, category: DiagnosticCategory.Error, key: "JSX element attributes type '{0}' must be an object type." }, The_return_type_of_a_JSX_element_constructor_must_return_an_object_type: { code: 2601, category: DiagnosticCategory.Error, key: "The return type of a JSX element constructor must return an object type." }, JSX_element_implicitly_has_type_any_because_the_global_type_JSX_Element_does_not_exist: { code: 2602, category: DiagnosticCategory.Error, key: "JSX element implicitly has type 'any' because the global type 'JSX.Element' does not exist." }, diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index 9fd08ef9bca..515afda49aa 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -1649,6 +1649,10 @@ "category": "Error", "code": 2524 }, + "Initializer provides no value for this binding element and the binding element has no default value": { + "category": "Error", + "code": 2525 + }, "JSX element attributes type '{0}' must be an object type.": { "category": "Error", "code": 2600 diff --git a/src/compiler/types.ts b/src/compiler/types.ts index d23a42e753a..cfdf869dd77 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -1714,6 +1714,7 @@ namespace ts { resolvedExports?: SymbolTable; // Resolved exports of module exportsChecked?: boolean; // True if exports of external module have been checked isNestedRedeclaration?: boolean; // True if symbol is block scoped redeclaration + bindingElement?: BindingElement; // Binding element associated with property symbol } /* @internal */ From a95c42384babcd3915c216e0a799a185db603813 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Thu, 10 Sep 2015 16:27:35 -0700 Subject: [PATCH 106/117] Revising test --- .../destructuringWithLiteralInitializers.js | 23 ++++-- ...structuringWithLiteralInitializers.symbols | 18 ++++- ...destructuringWithLiteralInitializers.types | 74 ++++++++++++------- .../destructuringWithLiteralInitializers.ts | 11 ++- 4 files changed, 88 insertions(+), 38 deletions(-) diff --git a/tests/baselines/reference/destructuringWithLiteralInitializers.js b/tests/baselines/reference/destructuringWithLiteralInitializers.js index 640b5a37756..740648b04e8 100644 --- a/tests/baselines/reference/destructuringWithLiteralInitializers.js +++ b/tests/baselines/reference/destructuringWithLiteralInitializers.js @@ -50,15 +50,20 @@ g1([1, 1]); function g2([x = 0, y = 0]) { } g2([1, 1]); -// (arg?: [any, any]) => void -function g3([x, y] = []) { } +// (arg?: [number, number]) => void +function g3([x, y] = [0, 0]) { } g3(); g3([1, 1]); // (arg?: [number, number]) => void -function g4([x, y] = [0, 0]) { } +function g4([x, y = 0] = [0]) { } g4(); g4([1, 1]); + +// (arg?: [number, number]) => void +function g5([x = 0, y = 0] = []) { } +g5(); +g5([1, 1]); //// [destructuringWithLiteralInitializers.js] @@ -122,15 +127,21 @@ function g2(_a) { var _b = _a[0], x = _b === void 0 ? 0 : _b, _c = _a[1], y = _c === void 0 ? 0 : _c; } g2([1, 1]); -// (arg?: [any, any]) => void +// (arg?: [number, number]) => void function g3(_a) { - var _b = _a === void 0 ? [] : _a, x = _b[0], y = _b[1]; + var _b = _a === void 0 ? [0, 0] : _a, x = _b[0], y = _b[1]; } g3(); g3([1, 1]); // (arg?: [number, number]) => void function g4(_a) { - var _b = _a === void 0 ? [0, 0] : _a, x = _b[0], y = _b[1]; + var _b = _a === void 0 ? [0] : _a, x = _b[0], _c = _b[1], y = _c === void 0 ? 0 : _c; } g4(); g4([1, 1]); +// (arg?: [number, number]) => void +function g5(_a) { + var _b = _a === void 0 ? [] : _a, _c = _b[0], x = _c === void 0 ? 0 : _c, _d = _b[1], y = _d === void 0 ? 0 : _d; +} +g5(); +g5([1, 1]); diff --git a/tests/baselines/reference/destructuringWithLiteralInitializers.symbols b/tests/baselines/reference/destructuringWithLiteralInitializers.symbols index fc8c7a2f621..1141fc140c7 100644 --- a/tests/baselines/reference/destructuringWithLiteralInitializers.symbols +++ b/tests/baselines/reference/destructuringWithLiteralInitializers.symbols @@ -156,8 +156,8 @@ function g2([x = 0, y = 0]) { } g2([1, 1]); >g2 : Symbol(g2, Decl(destructuringWithLiteralInitializers.ts, 45, 11)) -// (arg?: [any, any]) => void -function g3([x, y] = []) { } +// (arg?: [number, number]) => void +function g3([x, y] = [0, 0]) { } >g3 : Symbol(g3, Decl(destructuringWithLiteralInitializers.ts, 49, 11)) >x : Symbol(x, Decl(destructuringWithLiteralInitializers.ts, 52, 13)) >y : Symbol(y, Decl(destructuringWithLiteralInitializers.ts, 52, 15)) @@ -169,7 +169,7 @@ g3([1, 1]); >g3 : Symbol(g3, Decl(destructuringWithLiteralInitializers.ts, 49, 11)) // (arg?: [number, number]) => void -function g4([x, y] = [0, 0]) { } +function g4([x, y = 0] = [0]) { } >g4 : Symbol(g4, Decl(destructuringWithLiteralInitializers.ts, 54, 11)) >x : Symbol(x, Decl(destructuringWithLiteralInitializers.ts, 57, 13)) >y : Symbol(y, Decl(destructuringWithLiteralInitializers.ts, 57, 15)) @@ -180,3 +180,15 @@ g4(); g4([1, 1]); >g4 : Symbol(g4, Decl(destructuringWithLiteralInitializers.ts, 54, 11)) +// (arg?: [number, number]) => void +function g5([x = 0, y = 0] = []) { } +>g5 : Symbol(g5, Decl(destructuringWithLiteralInitializers.ts, 59, 11)) +>x : Symbol(x, Decl(destructuringWithLiteralInitializers.ts, 62, 13)) +>y : Symbol(y, Decl(destructuringWithLiteralInitializers.ts, 62, 19)) + +g5(); +>g5 : Symbol(g5, Decl(destructuringWithLiteralInitializers.ts, 59, 11)) + +g5([1, 1]); +>g5 : Symbol(g5, Decl(destructuringWithLiteralInitializers.ts, 59, 11)) + diff --git a/tests/baselines/reference/destructuringWithLiteralInitializers.types b/tests/baselines/reference/destructuringWithLiteralInitializers.types index 97c07bc281d..da1e4bfd6f3 100644 --- a/tests/baselines/reference/destructuringWithLiteralInitializers.types +++ b/tests/baselines/reference/destructuringWithLiteralInitializers.types @@ -248,40 +248,62 @@ g2([1, 1]); >1 : number >1 : number -// (arg?: [any, any]) => void -function g3([x, y] = []) { } ->g3 : ([x, y]?: [any, any]) => void ->x : any ->y : any ->[] : [undefined, undefined] - -g3(); ->g3() : void ->g3 : ([x, y]?: [any, any]) => void - -g3([1, 1]); ->g3([1, 1]) : void ->g3 : ([x, y]?: [any, any]) => void ->[1, 1] : [number, number] ->1 : number ->1 : number - // (arg?: [number, number]) => void -function g4([x, y] = [0, 0]) { } ->g4 : ([x, y]?: [number, number]) => void +function g3([x, y] = [0, 0]) { } +>g3 : ([x, y]?: [number, number]) => void >x : number >y : number >[0, 0] : [number, number] >0 : number >0 : number -g4(); ->g4() : void ->g4 : ([x, y]?: [number, number]) => void +g3(); +>g3() : void +>g3 : ([x, y]?: [number, number]) => void -g4([1, 1]); ->g4([1, 1]) : void ->g4 : ([x, y]?: [number, number]) => void +g3([1, 1]); +>g3([1, 1]) : void +>g3 : ([x, y]?: [number, number]) => void +>[1, 1] : [number, number] +>1 : number +>1 : number + +// (arg?: [number, number]) => void +function g4([x, y = 0] = [0]) { } +>g4 : ([x, y = 0]?: [number, number]) => void +>x : number +>y : number +>0 : number +>[0] : [number, number] +>0 : number + +g4(); +>g4() : void +>g4 : ([x, y = 0]?: [number, number]) => void + +g4([1, 1]); +>g4([1, 1]) : void +>g4 : ([x, y = 0]?: [number, number]) => void +>[1, 1] : [number, number] +>1 : number +>1 : number + +// (arg?: [number, number]) => void +function g5([x = 0, y = 0] = []) { } +>g5 : ([x = 0, y = 0]?: [number, number]) => void +>x : number +>0 : number +>y : number +>0 : number +>[] : [number, number] + +g5(); +>g5() : void +>g5 : ([x = 0, y = 0]?: [number, number]) => void + +g5([1, 1]); +>g5([1, 1]) : void +>g5 : ([x = 0, y = 0]?: [number, number]) => void >[1, 1] : [number, number] >1 : number >1 : number diff --git a/tests/cases/conformance/es6/destructuring/destructuringWithLiteralInitializers.ts b/tests/cases/conformance/es6/destructuring/destructuringWithLiteralInitializers.ts index dd3a0ae28a6..17de6dd2858 100644 --- a/tests/cases/conformance/es6/destructuring/destructuringWithLiteralInitializers.ts +++ b/tests/cases/conformance/es6/destructuring/destructuringWithLiteralInitializers.ts @@ -49,12 +49,17 @@ g1([1, 1]); function g2([x = 0, y = 0]) { } g2([1, 1]); -// (arg?: [any, any]) => void -function g3([x, y] = []) { } +// (arg?: [number, number]) => void +function g3([x, y] = [0, 0]) { } g3(); g3([1, 1]); // (arg?: [number, number]) => void -function g4([x, y] = [0, 0]) { } +function g4([x, y = 0] = [0]) { } g4(); g4([1, 1]); + +// (arg?: [number, number]) => void +function g5([x = 0, y = 0] = []) { } +g5(); +g5([1, 1]); From 273b9ff1ec12f4a81c8cc96296b3fef0aec6eac2 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Thu, 10 Sep 2015 16:27:58 -0700 Subject: [PATCH 107/117] Accepting new baselines --- ...nEmitDestructuringArrayPattern2.errors.txt | 22 +++ ...tionEmitDestructuringArrayPattern2.symbols | 40 ---- ...rationEmitDestructuringArrayPattern2.types | 70 ------- .../declarationsAndAssignments.errors.txt | 28 ++- ...BindingPatternAndAssignment1ES5.errors.txt | 65 +++++++ ...rayBindingPatternAndAssignment1ES5.symbols | 105 ----------- ...ArrayBindingPatternAndAssignment1ES5.types | 177 ------------------ ...BindingPatternAndAssignment1ES6.errors.txt | 64 +++++++ ...rayBindingPatternAndAssignment1ES6.symbols | 105 ----------- ...ArrayBindingPatternAndAssignment1ES6.types | 177 ------------------ ...rayBindingPatternAndAssignment2.errors.txt | 8 +- ...ectBindingPatternAndAssignment3.errors.txt | 4 +- ...destructuringVariableDeclaration1ES5.types | 6 +- ...destructuringVariableDeclaration1ES6.types | 6 +- .../reference/downlevelLetConst12.errors.txt | 20 ++ .../reference/downlevelLetConst12.symbols | 26 --- .../reference/downlevelLetConst12.types | 35 ---- .../reference/downlevelLetConst16.errors.txt | 8 +- .../missingAndExcessProperties.errors.txt | 46 +++-- 19 files changed, 242 insertions(+), 770 deletions(-) create mode 100644 tests/baselines/reference/declarationEmitDestructuringArrayPattern2.errors.txt delete mode 100644 tests/baselines/reference/declarationEmitDestructuringArrayPattern2.symbols delete mode 100644 tests/baselines/reference/declarationEmitDestructuringArrayPattern2.types create mode 100644 tests/baselines/reference/destructuringArrayBindingPatternAndAssignment1ES5.errors.txt delete mode 100644 tests/baselines/reference/destructuringArrayBindingPatternAndAssignment1ES5.symbols delete mode 100644 tests/baselines/reference/destructuringArrayBindingPatternAndAssignment1ES5.types create mode 100644 tests/baselines/reference/destructuringArrayBindingPatternAndAssignment1ES6.errors.txt delete mode 100644 tests/baselines/reference/destructuringArrayBindingPatternAndAssignment1ES6.symbols delete mode 100644 tests/baselines/reference/destructuringArrayBindingPatternAndAssignment1ES6.types create mode 100644 tests/baselines/reference/downlevelLetConst12.errors.txt delete mode 100644 tests/baselines/reference/downlevelLetConst12.symbols delete mode 100644 tests/baselines/reference/downlevelLetConst12.types diff --git a/tests/baselines/reference/declarationEmitDestructuringArrayPattern2.errors.txt b/tests/baselines/reference/declarationEmitDestructuringArrayPattern2.errors.txt new file mode 100644 index 00000000000..ea5b38a3b2f --- /dev/null +++ b/tests/baselines/reference/declarationEmitDestructuringArrayPattern2.errors.txt @@ -0,0 +1,22 @@ +tests/cases/compiler/declarationEmitDestructuringArrayPattern2.ts(4,6): error TS2525: Initializer provides no value for this binding element and the binding element has no default value +tests/cases/compiler/declarationEmitDestructuringArrayPattern2.ts(4,11): error TS2525: Initializer provides no value for this binding element and the binding element has no default value +tests/cases/compiler/declarationEmitDestructuringArrayPattern2.ts(4,16): error TS2525: Initializer provides no value for this binding element and the binding element has no default value + + +==== tests/cases/compiler/declarationEmitDestructuringArrayPattern2.ts (3 errors) ==== + var [x10, [y10, [z10]]] = [1, ["hello", [true]]]; + + var [x11 = 0, y11 = ""] = [1, "hello"]; + var [a11, b11, c11] = []; + ~~~ +!!! error TS2525: Initializer provides no value for this binding element and the binding element has no default value + ~~~ +!!! error TS2525: Initializer provides no value for this binding element and the binding element has no default value + ~~~ +!!! error TS2525: Initializer provides no value for this binding element and the binding element has no default value + + var [a2, [b2, { x12, y12: c2 }]=["abc", { x12: 10, y12: false }]] = [1, ["hello", { x12: 5, y12: true }]]; + + var [x13, y13] = [1, "hello"]; + var [a3, b3] = [[x13, y13], { x: x13, y: y13 }]; + \ No newline at end of file diff --git a/tests/baselines/reference/declarationEmitDestructuringArrayPattern2.symbols b/tests/baselines/reference/declarationEmitDestructuringArrayPattern2.symbols deleted file mode 100644 index 0a3c6f4044d..00000000000 --- a/tests/baselines/reference/declarationEmitDestructuringArrayPattern2.symbols +++ /dev/null @@ -1,40 +0,0 @@ -=== tests/cases/compiler/declarationEmitDestructuringArrayPattern2.ts === -var [x10, [y10, [z10]]] = [1, ["hello", [true]]]; ->x10 : Symbol(x10, Decl(declarationEmitDestructuringArrayPattern2.ts, 0, 5)) ->y10 : Symbol(y10, Decl(declarationEmitDestructuringArrayPattern2.ts, 0, 11)) ->z10 : Symbol(z10, Decl(declarationEmitDestructuringArrayPattern2.ts, 0, 17)) - -var [x11 = 0, y11 = ""] = [1, "hello"]; ->x11 : Symbol(x11, Decl(declarationEmitDestructuringArrayPattern2.ts, 2, 5)) ->y11 : Symbol(y11, Decl(declarationEmitDestructuringArrayPattern2.ts, 2, 13)) - -var [a11, b11, c11] = []; ->a11 : Symbol(a11, Decl(declarationEmitDestructuringArrayPattern2.ts, 3, 5)) ->b11 : Symbol(b11, Decl(declarationEmitDestructuringArrayPattern2.ts, 3, 9)) ->c11 : Symbol(c11, Decl(declarationEmitDestructuringArrayPattern2.ts, 3, 14)) - -var [a2, [b2, { x12, y12: c2 }]=["abc", { x12: 10, y12: false }]] = [1, ["hello", { x12: 5, y12: true }]]; ->a2 : Symbol(a2, Decl(declarationEmitDestructuringArrayPattern2.ts, 5, 5)) ->b2 : Symbol(b2, Decl(declarationEmitDestructuringArrayPattern2.ts, 5, 10)) ->x12 : Symbol(x12, Decl(declarationEmitDestructuringArrayPattern2.ts, 5, 15)) ->y12 : Symbol(y12, Decl(declarationEmitDestructuringArrayPattern2.ts, 5, 91)) ->c2 : Symbol(c2, Decl(declarationEmitDestructuringArrayPattern2.ts, 5, 20)) ->x12 : Symbol(x12, Decl(declarationEmitDestructuringArrayPattern2.ts, 5, 41)) ->y12 : Symbol(y12, Decl(declarationEmitDestructuringArrayPattern2.ts, 5, 50)) ->x12 : Symbol(x12, Decl(declarationEmitDestructuringArrayPattern2.ts, 5, 83)) ->y12 : Symbol(y12, Decl(declarationEmitDestructuringArrayPattern2.ts, 5, 91)) - -var [x13, y13] = [1, "hello"]; ->x13 : Symbol(x13, Decl(declarationEmitDestructuringArrayPattern2.ts, 7, 5)) ->y13 : Symbol(y13, Decl(declarationEmitDestructuringArrayPattern2.ts, 7, 9)) - -var [a3, b3] = [[x13, y13], { x: x13, y: y13 }]; ->a3 : Symbol(a3, Decl(declarationEmitDestructuringArrayPattern2.ts, 8, 5)) ->b3 : Symbol(b3, Decl(declarationEmitDestructuringArrayPattern2.ts, 8, 8)) ->x13 : Symbol(x13, Decl(declarationEmitDestructuringArrayPattern2.ts, 7, 5)) ->y13 : Symbol(y13, Decl(declarationEmitDestructuringArrayPattern2.ts, 7, 9)) ->x : Symbol(x, Decl(declarationEmitDestructuringArrayPattern2.ts, 8, 29)) ->x13 : Symbol(x13, Decl(declarationEmitDestructuringArrayPattern2.ts, 7, 5)) ->y : Symbol(y, Decl(declarationEmitDestructuringArrayPattern2.ts, 8, 37)) ->y13 : Symbol(y13, Decl(declarationEmitDestructuringArrayPattern2.ts, 7, 9)) - diff --git a/tests/baselines/reference/declarationEmitDestructuringArrayPattern2.types b/tests/baselines/reference/declarationEmitDestructuringArrayPattern2.types deleted file mode 100644 index 57acfe1dde1..00000000000 --- a/tests/baselines/reference/declarationEmitDestructuringArrayPattern2.types +++ /dev/null @@ -1,70 +0,0 @@ -=== tests/cases/compiler/declarationEmitDestructuringArrayPattern2.ts === -var [x10, [y10, [z10]]] = [1, ["hello", [true]]]; ->x10 : number ->y10 : string ->z10 : boolean ->[1, ["hello", [true]]] : [number, [string, [boolean]]] ->1 : number ->["hello", [true]] : [string, [boolean]] ->"hello" : string ->[true] : [boolean] ->true : boolean - -var [x11 = 0, y11 = ""] = [1, "hello"]; ->x11 : number ->0 : number ->y11 : string ->"" : string ->[1, "hello"] : [number, string] ->1 : number ->"hello" : string - -var [a11, b11, c11] = []; ->a11 : any ->b11 : any ->c11 : any ->[] : [undefined, undefined, undefined] - -var [a2, [b2, { x12, y12: c2 }]=["abc", { x12: 10, y12: false }]] = [1, ["hello", { x12: 5, y12: true }]]; ->a2 : number ->b2 : string ->x12 : number ->y12 : any ->c2 : boolean ->["abc", { x12: 10, y12: false }] : [string, { x12: number; y12: boolean; }] ->"abc" : string ->{ x12: 10, y12: false } : { x12: number; y12: boolean; } ->x12 : number ->10 : number ->y12 : boolean ->false : boolean ->[1, ["hello", { x12: 5, y12: true }]] : [number, [string, { x12: number; y12: boolean; }]] ->1 : number ->["hello", { x12: 5, y12: true }] : [string, { x12: number; y12: boolean; }] ->"hello" : string ->{ x12: 5, y12: true } : { x12: number; y12: boolean; } ->x12 : number ->5 : number ->y12 : boolean ->true : boolean - -var [x13, y13] = [1, "hello"]; ->x13 : number ->y13 : string ->[1, "hello"] : [number, string] ->1 : number ->"hello" : string - -var [a3, b3] = [[x13, y13], { x: x13, y: y13 }]; ->a3 : (number | string)[] ->b3 : { x: number; y: string; } ->[[x13, y13], { x: x13, y: y13 }] : [(number | string)[], { x: number; y: string; }] ->[x13, y13] : (number | string)[] ->x13 : number ->y13 : string ->{ x: x13, y: y13 } : { x: number; y: string; } ->x : number ->x13 : number ->y : string ->y13 : string - diff --git a/tests/baselines/reference/declarationsAndAssignments.errors.txt b/tests/baselines/reference/declarationsAndAssignments.errors.txt index 802e72562af..cd72c12951c 100644 --- a/tests/baselines/reference/declarationsAndAssignments.errors.txt +++ b/tests/baselines/reference/declarationsAndAssignments.errors.txt @@ -1,3 +1,4 @@ +tests/cases/conformance/es6/destructuring/declarationsAndAssignments.ts(5,16): error TS2525: Initializer provides no value for this binding element and the binding element has no default value tests/cases/conformance/es6/destructuring/declarationsAndAssignments.ts(22,17): error TS2353: Object literal may only specify known properties, and 'x' does not exist in type '{}'. tests/cases/conformance/es6/destructuring/declarationsAndAssignments.ts(22,23): error TS2353: Object literal may only specify known properties, and 'y' does not exist in type '{}'. tests/cases/conformance/es6/destructuring/declarationsAndAssignments.ts(23,25): error TS2353: Object literal may only specify known properties, and 'y' does not exist in type '{ x: any; }'. @@ -5,10 +6,15 @@ tests/cases/conformance/es6/destructuring/declarationsAndAssignments.ts(24,19): tests/cases/conformance/es6/destructuring/declarationsAndAssignments.ts(28,28): error TS2353: Object literal may only specify known properties, and 'y' does not exist in type '{ x: any; }'. tests/cases/conformance/es6/destructuring/declarationsAndAssignments.ts(29,22): error TS2353: Object literal may only specify known properties, and 'x' does not exist in type '{ y: any; }'. tests/cases/conformance/es6/destructuring/declarationsAndAssignments.ts(56,17): error TS2322: Type 'number' is not assignable to type 'string'. +tests/cases/conformance/es6/destructuring/declarationsAndAssignments.ts(62,10): error TS2525: Initializer provides no value for this binding element and the binding element has no default value +tests/cases/conformance/es6/destructuring/declarationsAndAssignments.ts(62,13): error TS2525: Initializer provides no value for this binding element and the binding element has no default value +tests/cases/conformance/es6/destructuring/declarationsAndAssignments.ts(62,16): error TS2525: Initializer provides no value for this binding element and the binding element has no default value +tests/cases/conformance/es6/destructuring/declarationsAndAssignments.ts(63,13): error TS2525: Initializer provides no value for this binding element and the binding element has no default value +tests/cases/conformance/es6/destructuring/declarationsAndAssignments.ts(63,16): error TS2525: Initializer provides no value for this binding element and the binding element has no default value tests/cases/conformance/es6/destructuring/declarationsAndAssignments.ts(67,9): error TS2461: Type '{ [x: number]: undefined; }' is not an array type. tests/cases/conformance/es6/destructuring/declarationsAndAssignments.ts(68,9): error TS2461: Type '{ [x: number]: number; 0: number; 1: number; }' is not an array type. -tests/cases/conformance/es6/destructuring/declarationsAndAssignments.ts(73,11): error TS2459: Type '{}' has no property 'a' and no string index signature. -tests/cases/conformance/es6/destructuring/declarationsAndAssignments.ts(73,14): error TS2459: Type '{}' has no property 'b' and no string index signature. +tests/cases/conformance/es6/destructuring/declarationsAndAssignments.ts(73,11): error TS2525: Initializer provides no value for this binding element and the binding element has no default value +tests/cases/conformance/es6/destructuring/declarationsAndAssignments.ts(73,14): error TS2525: Initializer provides no value for this binding element and the binding element has no default value tests/cases/conformance/es6/destructuring/declarationsAndAssignments.ts(74,11): error TS2459: Type 'undefined[]' has no property 'a' and no string index signature. tests/cases/conformance/es6/destructuring/declarationsAndAssignments.ts(74,14): error TS2459: Type 'undefined[]' has no property 'b' and no string index signature. tests/cases/conformance/es6/destructuring/declarationsAndAssignments.ts(106,5): error TS2345: Argument of type '[number, [string, { y: boolean; }]]' is not assignable to parameter of type '[number, [string, { x: any; y?: boolean; }]]'. @@ -21,12 +27,14 @@ tests/cases/conformance/es6/destructuring/declarationsAndAssignments.ts(138,6): tests/cases/conformance/es6/destructuring/declarationsAndAssignments.ts(138,9): error TS2322: Type 'number' is not assignable to type 'string'. -==== tests/cases/conformance/es6/destructuring/declarationsAndAssignments.ts (16 errors) ==== +==== tests/cases/conformance/es6/destructuring/declarationsAndAssignments.ts (22 errors) ==== function f0() { var [] = [1, "hello"]; var [x] = [1, "hello"]; var [x, y] = [1, "hello"]; var [x, y, z] = [1, "hello"]; + ~ +!!! error TS2525: Initializer provides no value for this binding element and the binding element has no default value var [,, x] = [0, 1, 2]; var x: number; var y: string; @@ -98,7 +106,17 @@ tests/cases/conformance/es6/destructuring/declarationsAndAssignments.ts(138,9): function f8() { var [a, b, c] = []; // Ok, [] is an array + ~ +!!! error TS2525: Initializer provides no value for this binding element and the binding element has no default value + ~ +!!! error TS2525: Initializer provides no value for this binding element and the binding element has no default value + ~ +!!! error TS2525: Initializer provides no value for this binding element and the binding element has no default value var [d, e, f] = [1]; // Error, [1] is a tuple + ~ +!!! error TS2525: Initializer provides no value for this binding element and the binding element has no default value + ~ +!!! error TS2525: Initializer provides no value for this binding element and the binding element has no default value } function f9() { @@ -114,9 +132,9 @@ tests/cases/conformance/es6/destructuring/declarationsAndAssignments.ts(138,9): function f10() { var { a, b } = {}; // Error ~ -!!! error TS2459: Type '{}' has no property 'a' and no string index signature. +!!! error TS2525: Initializer provides no value for this binding element and the binding element has no default value ~ -!!! error TS2459: Type '{}' has no property 'b' and no string index signature. +!!! error TS2525: Initializer provides no value for this binding element and the binding element has no default value var { a, b } = []; // Error ~ !!! error TS2459: Type 'undefined[]' has no property 'a' and no string index signature. diff --git a/tests/baselines/reference/destructuringArrayBindingPatternAndAssignment1ES5.errors.txt b/tests/baselines/reference/destructuringArrayBindingPatternAndAssignment1ES5.errors.txt new file mode 100644 index 00000000000..5fd60c296c9 --- /dev/null +++ b/tests/baselines/reference/destructuringArrayBindingPatternAndAssignment1ES5.errors.txt @@ -0,0 +1,65 @@ +tests/cases/conformance/es6/destructuring/destructuringArrayBindingPatternAndAssignment1ES5.ts(43,6): error TS2525: Initializer provides no value for this binding element and the binding element has no default value +tests/cases/conformance/es6/destructuring/destructuringArrayBindingPatternAndAssignment1ES5.ts(44,8): error TS2525: Initializer provides no value for this binding element and the binding element has no default value +tests/cases/conformance/es6/destructuring/destructuringArrayBindingPatternAndAssignment1ES5.ts(44,18): error TS2525: Initializer provides no value for this binding element and the binding element has no default value + + +==== tests/cases/conformance/es6/destructuring/destructuringArrayBindingPatternAndAssignment1ES5.ts (3 errors) ==== + /* AssignmentPattern: + * ObjectAssignmentPattern + * ArrayAssignmentPattern + * ArrayAssignmentPattern: + * [Elision AssignmentRestElementopt ] + * [AssignmentElementList] + * [AssignmentElementList, Elision AssignmentRestElementopt ] + * AssignmentElementList: + * Elision AssignmentElement + * AssignmentElementList, Elisionopt AssignmentElement + * AssignmentElement: + * LeftHandSideExpression Initialiseropt + * AssignmentPattern Initialiseropt + * AssignmentRestElement: + * ... LeftHandSideExpression + */ + + // In a destructuring assignment expression, the type of the expression on the right must be assignable to the assignment target on the left. + // An expression of type S is considered assignable to an assignment target V if one of the following is true + + // V is an array assignment pattern, S is the type Any or an array-like type (section 3.3.2), and, for each assignment element E in V, + // S is the type Any, or + + var [a0, a1]: any = undefined; + var [a2 = false, a3 = 1]: any = undefined; + + // V is an array assignment pattern, S is the type Any or an array-like type (section 3.3.2), and, for each assignment element E in V, + // S is a tuple- like type (section 3.3.3) with a property named N of a type that is assignable to the target given in E, + // where N is the numeric index of E in the array assignment pattern, or + var [b0, b1, b2] = [2, 3, 4]; + var [b3, b4, b5]: [number, number, string] = [1, 2, "string"]; + + function foo() { + return [1, 2, 3]; + } + + var [b6, b7] = foo(); + var [...b8] = foo(); + + // S is not a tuple- like type and the numeric index signature type of S is assignable to the target given in E. + var temp = [1,2,3] + var [c0, c1] = [...temp]; + var [c2] = []; + ~~ +!!! error TS2525: Initializer provides no value for this binding element and the binding element has no default value + var [[[c3]], [[[[c4]]]]] = [[[]], [[[[]]]]] + ~~ +!!! error TS2525: Initializer provides no value for this binding element and the binding element has no default value + ~~ +!!! error TS2525: Initializer provides no value for this binding element and the binding element has no default value + var [[c5], c6]: [[string|number], boolean] = [[1], true]; + var [, c7] = [1, 2, 3]; + var [,,, c8] = [1, 2, 3, 4]; + var [,,, c9] = [1, 2, 3, 4]; + var [,,,...c10] = [1, 2, 3, 4, "hello"]; + var [c11, c12, ...c13] = [1, 2, "string"]; + var [c14, c15, c16] = [1, 2, "string"]; + + \ No newline at end of file diff --git a/tests/baselines/reference/destructuringArrayBindingPatternAndAssignment1ES5.symbols b/tests/baselines/reference/destructuringArrayBindingPatternAndAssignment1ES5.symbols deleted file mode 100644 index d8e319f4120..00000000000 --- a/tests/baselines/reference/destructuringArrayBindingPatternAndAssignment1ES5.symbols +++ /dev/null @@ -1,105 +0,0 @@ -=== tests/cases/conformance/es6/destructuring/destructuringArrayBindingPatternAndAssignment1ES5.ts === -/* AssignmentPattern: - * ObjectAssignmentPattern - * ArrayAssignmentPattern - * ArrayAssignmentPattern: - * [Elision AssignmentRestElementopt ] - * [AssignmentElementList] - * [AssignmentElementList, Elision AssignmentRestElementopt ] - * AssignmentElementList: - * Elision AssignmentElement - * AssignmentElementList, Elisionopt AssignmentElement - * AssignmentElement: - * LeftHandSideExpression Initialiseropt - * AssignmentPattern Initialiseropt - * AssignmentRestElement: - * ... LeftHandSideExpression - */ - -// In a destructuring assignment expression, the type of the expression on the right must be assignable to the assignment target on the left. -// An expression of type S is considered assignable to an assignment target V if one of the following is true - -// V is an array assignment pattern, S is the type Any or an array-like type (section 3.3.2), and, for each assignment element E in V, -// S is the type Any, or - -var [a0, a1]: any = undefined; ->a0 : Symbol(a0, Decl(destructuringArrayBindingPatternAndAssignment1ES5.ts, 23, 5)) ->a1 : Symbol(a1, Decl(destructuringArrayBindingPatternAndAssignment1ES5.ts, 23, 8)) ->undefined : Symbol(undefined) - -var [a2 = false, a3 = 1]: any = undefined; ->a2 : Symbol(a2, Decl(destructuringArrayBindingPatternAndAssignment1ES5.ts, 24, 5)) ->a3 : Symbol(a3, Decl(destructuringArrayBindingPatternAndAssignment1ES5.ts, 24, 16)) ->undefined : Symbol(undefined) - -// V is an array assignment pattern, S is the type Any or an array-like type (section 3.3.2), and, for each assignment element E in V, -// S is a tuple- like type (section 3.3.3) with a property named N of a type that is assignable to the target given in E, -// where N is the numeric index of E in the array assignment pattern, or -var [b0, b1, b2] = [2, 3, 4]; ->b0 : Symbol(b0, Decl(destructuringArrayBindingPatternAndAssignment1ES5.ts, 29, 5)) ->b1 : Symbol(b1, Decl(destructuringArrayBindingPatternAndAssignment1ES5.ts, 29, 8)) ->b2 : Symbol(b2, Decl(destructuringArrayBindingPatternAndAssignment1ES5.ts, 29, 12)) - -var [b3, b4, b5]: [number, number, string] = [1, 2, "string"]; ->b3 : Symbol(b3, Decl(destructuringArrayBindingPatternAndAssignment1ES5.ts, 30, 5)) ->b4 : Symbol(b4, Decl(destructuringArrayBindingPatternAndAssignment1ES5.ts, 30, 8)) ->b5 : Symbol(b5, Decl(destructuringArrayBindingPatternAndAssignment1ES5.ts, 30, 12)) - -function foo() { ->foo : Symbol(foo, Decl(destructuringArrayBindingPatternAndAssignment1ES5.ts, 30, 62)) - - return [1, 2, 3]; -} - -var [b6, b7] = foo(); ->b6 : Symbol(b6, Decl(destructuringArrayBindingPatternAndAssignment1ES5.ts, 36, 5)) ->b7 : Symbol(b7, Decl(destructuringArrayBindingPatternAndAssignment1ES5.ts, 36, 8)) ->foo : Symbol(foo, Decl(destructuringArrayBindingPatternAndAssignment1ES5.ts, 30, 62)) - -var [...b8] = foo(); ->b8 : Symbol(b8, Decl(destructuringArrayBindingPatternAndAssignment1ES5.ts, 37, 5)) ->foo : Symbol(foo, Decl(destructuringArrayBindingPatternAndAssignment1ES5.ts, 30, 62)) - -// S is not a tuple- like type and the numeric index signature type of S is assignable to the target given in E. -var temp = [1,2,3] ->temp : Symbol(temp, Decl(destructuringArrayBindingPatternAndAssignment1ES5.ts, 40, 3)) - -var [c0, c1] = [...temp]; ->c0 : Symbol(c0, Decl(destructuringArrayBindingPatternAndAssignment1ES5.ts, 41, 5)) ->c1 : Symbol(c1, Decl(destructuringArrayBindingPatternAndAssignment1ES5.ts, 41, 8)) ->temp : Symbol(temp, Decl(destructuringArrayBindingPatternAndAssignment1ES5.ts, 40, 3)) - -var [c2] = []; ->c2 : Symbol(c2, Decl(destructuringArrayBindingPatternAndAssignment1ES5.ts, 42, 5)) - -var [[[c3]], [[[[c4]]]]] = [[[]], [[[[]]]]] ->c3 : Symbol(c3, Decl(destructuringArrayBindingPatternAndAssignment1ES5.ts, 43, 7)) ->c4 : Symbol(c4, Decl(destructuringArrayBindingPatternAndAssignment1ES5.ts, 43, 17)) - -var [[c5], c6]: [[string|number], boolean] = [[1], true]; ->c5 : Symbol(c5, Decl(destructuringArrayBindingPatternAndAssignment1ES5.ts, 44, 6)) ->c6 : Symbol(c6, Decl(destructuringArrayBindingPatternAndAssignment1ES5.ts, 44, 10)) - -var [, c7] = [1, 2, 3]; ->c7 : Symbol(c7, Decl(destructuringArrayBindingPatternAndAssignment1ES5.ts, 45, 6)) - -var [,,, c8] = [1, 2, 3, 4]; ->c8 : Symbol(c8, Decl(destructuringArrayBindingPatternAndAssignment1ES5.ts, 46, 8)) - -var [,,, c9] = [1, 2, 3, 4]; ->c9 : Symbol(c9, Decl(destructuringArrayBindingPatternAndAssignment1ES5.ts, 47, 8)) - -var [,,,...c10] = [1, 2, 3, 4, "hello"]; ->c10 : Symbol(c10, Decl(destructuringArrayBindingPatternAndAssignment1ES5.ts, 48, 8)) - -var [c11, c12, ...c13] = [1, 2, "string"]; ->c11 : Symbol(c11, Decl(destructuringArrayBindingPatternAndAssignment1ES5.ts, 49, 5)) ->c12 : Symbol(c12, Decl(destructuringArrayBindingPatternAndAssignment1ES5.ts, 49, 9)) ->c13 : Symbol(c13, Decl(destructuringArrayBindingPatternAndAssignment1ES5.ts, 49, 14)) - -var [c14, c15, c16] = [1, 2, "string"]; ->c14 : Symbol(c14, Decl(destructuringArrayBindingPatternAndAssignment1ES5.ts, 50, 5)) ->c15 : Symbol(c15, Decl(destructuringArrayBindingPatternAndAssignment1ES5.ts, 50, 9)) ->c16 : Symbol(c16, Decl(destructuringArrayBindingPatternAndAssignment1ES5.ts, 50, 14)) - - diff --git a/tests/baselines/reference/destructuringArrayBindingPatternAndAssignment1ES5.types b/tests/baselines/reference/destructuringArrayBindingPatternAndAssignment1ES5.types deleted file mode 100644 index fcd71e85dbf..00000000000 --- a/tests/baselines/reference/destructuringArrayBindingPatternAndAssignment1ES5.types +++ /dev/null @@ -1,177 +0,0 @@ -=== tests/cases/conformance/es6/destructuring/destructuringArrayBindingPatternAndAssignment1ES5.ts === -/* AssignmentPattern: - * ObjectAssignmentPattern - * ArrayAssignmentPattern - * ArrayAssignmentPattern: - * [Elision AssignmentRestElementopt ] - * [AssignmentElementList] - * [AssignmentElementList, Elision AssignmentRestElementopt ] - * AssignmentElementList: - * Elision AssignmentElement - * AssignmentElementList, Elisionopt AssignmentElement - * AssignmentElement: - * LeftHandSideExpression Initialiseropt - * AssignmentPattern Initialiseropt - * AssignmentRestElement: - * ... LeftHandSideExpression - */ - -// In a destructuring assignment expression, the type of the expression on the right must be assignable to the assignment target on the left. -// An expression of type S is considered assignable to an assignment target V if one of the following is true - -// V is an array assignment pattern, S is the type Any or an array-like type (section 3.3.2), and, for each assignment element E in V, -// S is the type Any, or - -var [a0, a1]: any = undefined; ->a0 : any ->a1 : any ->undefined : undefined - -var [a2 = false, a3 = 1]: any = undefined; ->a2 : boolean ->false : boolean ->a3 : number ->1 : number ->undefined : undefined - -// V is an array assignment pattern, S is the type Any or an array-like type (section 3.3.2), and, for each assignment element E in V, -// S is a tuple- like type (section 3.3.3) with a property named N of a type that is assignable to the target given in E, -// where N is the numeric index of E in the array assignment pattern, or -var [b0, b1, b2] = [2, 3, 4]; ->b0 : number ->b1 : number ->b2 : number ->[2, 3, 4] : [number, number, number] ->2 : number ->3 : number ->4 : number - -var [b3, b4, b5]: [number, number, string] = [1, 2, "string"]; ->b3 : number ->b4 : number ->b5 : string ->[1, 2, "string"] : [number, number, string] ->1 : number ->2 : number ->"string" : string - -function foo() { ->foo : () => number[] - - return [1, 2, 3]; ->[1, 2, 3] : number[] ->1 : number ->2 : number ->3 : number -} - -var [b6, b7] = foo(); ->b6 : number ->b7 : number ->foo() : number[] ->foo : () => number[] - -var [...b8] = foo(); ->b8 : number[] ->foo() : number[] ->foo : () => number[] - -// S is not a tuple- like type and the numeric index signature type of S is assignable to the target given in E. -var temp = [1,2,3] ->temp : number[] ->[1,2,3] : number[] ->1 : number ->2 : number ->3 : number - -var [c0, c1] = [...temp]; ->c0 : number ->c1 : number ->[...temp] : number[] ->...temp : number ->temp : number[] - -var [c2] = []; ->c2 : any ->[] : [undefined] - -var [[[c3]], [[[[c4]]]]] = [[[]], [[[[]]]]] ->c3 : any ->c4 : any ->[[[]], [[[[]]]]] : [[[undefined]], [[[[undefined]]]]] ->[[]] : [[undefined]] ->[] : [undefined] ->[[[[]]]] : [[[[undefined]]]] ->[[[]]] : [[[undefined]]] ->[[]] : [[undefined]] ->[] : [undefined] - -var [[c5], c6]: [[string|number], boolean] = [[1], true]; ->c5 : string | number ->c6 : boolean ->[[1], true] : [[number], boolean] ->[1] : [number] ->1 : number ->true : boolean - -var [, c7] = [1, 2, 3]; -> : undefined ->c7 : number ->[1, 2, 3] : [number, number, number] ->1 : number ->2 : number ->3 : number - -var [,,, c8] = [1, 2, 3, 4]; -> : undefined -> : undefined -> : undefined ->c8 : number ->[1, 2, 3, 4] : [number, number, number, number] ->1 : number ->2 : number ->3 : number ->4 : number - -var [,,, c9] = [1, 2, 3, 4]; -> : undefined -> : undefined -> : undefined ->c9 : number ->[1, 2, 3, 4] : [number, number, number, number] ->1 : number ->2 : number ->3 : number ->4 : number - -var [,,,...c10] = [1, 2, 3, 4, "hello"]; -> : undefined -> : undefined -> : undefined ->c10 : (number | string)[] ->[1, 2, 3, 4, "hello"] : (number | string)[] ->1 : number ->2 : number ->3 : number ->4 : number ->"hello" : string - -var [c11, c12, ...c13] = [1, 2, "string"]; ->c11 : number | string ->c12 : number | string ->c13 : (number | string)[] ->[1, 2, "string"] : (number | string)[] ->1 : number ->2 : number ->"string" : string - -var [c14, c15, c16] = [1, 2, "string"]; ->c14 : number ->c15 : number ->c16 : string ->[1, 2, "string"] : [number, number, string] ->1 : number ->2 : number ->"string" : string - - diff --git a/tests/baselines/reference/destructuringArrayBindingPatternAndAssignment1ES6.errors.txt b/tests/baselines/reference/destructuringArrayBindingPatternAndAssignment1ES6.errors.txt new file mode 100644 index 00000000000..a847cc44f0c --- /dev/null +++ b/tests/baselines/reference/destructuringArrayBindingPatternAndAssignment1ES6.errors.txt @@ -0,0 +1,64 @@ +tests/cases/conformance/es6/destructuring/destructuringArrayBindingPatternAndAssignment1ES6.ts(44,6): error TS2525: Initializer provides no value for this binding element and the binding element has no default value +tests/cases/conformance/es6/destructuring/destructuringArrayBindingPatternAndAssignment1ES6.ts(45,8): error TS2525: Initializer provides no value for this binding element and the binding element has no default value +tests/cases/conformance/es6/destructuring/destructuringArrayBindingPatternAndAssignment1ES6.ts(45,18): error TS2525: Initializer provides no value for this binding element and the binding element has no default value + + +==== tests/cases/conformance/es6/destructuring/destructuringArrayBindingPatternAndAssignment1ES6.ts (3 errors) ==== + + /* AssignmentPattern: + * ObjectAssignmentPattern + * ArrayAssignmentPattern + * ArrayAssignmentPattern: + * [Elision AssignmentRestElementopt ] + * [AssignmentElementList] + * [AssignmentElementList, Elision AssignmentRestElementopt ] + * AssignmentElementList: + * Elision AssignmentElement + * AssignmentElementList, Elisionopt AssignmentElement + * AssignmentElement: + * LeftHandSideExpression Initialiseropt + * AssignmentPattern Initialiseropt + * AssignmentRestElement: + * ... LeftHandSideExpression + */ + + // In a destructuring assignment expression, the type of the expression on the right must be assignable to the assignment target on the left. + // An expression of type S is considered assignable to an assignment target V if one of the following is true + + // V is an array assignment pattern, S is the type Any or an array-like type (section 3.3.2), and, for each assignment element E in V, + // S is the type Any, or + + var [a0, a1]: any = undefined; + var [a2 = false, a3 = 1]: any = undefined; + + // V is an array assignment pattern, S is the type Any or an array-like type (section 3.3.2), and, for each assignment element E in V, + // S is a tuple- like type (section 3.3.3) with a property named N of a type that is assignable to the target given in E, + // where N is the numeric index of E in the array assignment pattern, or + var [b0, b1, b2] = [2, 3, 4]; + var [b3, b4, b5]: [number, number, string] = [1, 2, "string"]; + + function foo() { + return [1, 2, 3]; + } + + var [b6, b7] = foo(); + var [...b8] = foo(); + + // S is not a tuple- like type and the numeric index signature type of S is assignable to the target given in E. + var temp = [1,2,3] + var [c0, c1] = [...temp]; + var [c2] = []; + ~~ +!!! error TS2525: Initializer provides no value for this binding element and the binding element has no default value + var [[[c3]], [[[[c4]]]]] = [[[]], [[[[]]]]] + ~~ +!!! error TS2525: Initializer provides no value for this binding element and the binding element has no default value + ~~ +!!! error TS2525: Initializer provides no value for this binding element and the binding element has no default value + var [[c5], c6]: [[string|number], boolean] = [[1], true]; + var [, c7] = [1, 2, 3]; + var [,,, c8] = [1, 2, 3, 4]; + var [,,, c9] = [1, 2, 3, 4]; + var [,,,...c10] = [1, 2, 3, 4, "hello"]; + var [c11, c12, ...c13] = [1, 2, "string"]; + var [c14, c15, c16] = [1, 2, "string"]; \ No newline at end of file diff --git a/tests/baselines/reference/destructuringArrayBindingPatternAndAssignment1ES6.symbols b/tests/baselines/reference/destructuringArrayBindingPatternAndAssignment1ES6.symbols deleted file mode 100644 index 33f9b4e88be..00000000000 --- a/tests/baselines/reference/destructuringArrayBindingPatternAndAssignment1ES6.symbols +++ /dev/null @@ -1,105 +0,0 @@ -=== tests/cases/conformance/es6/destructuring/destructuringArrayBindingPatternAndAssignment1ES6.ts === - -/* AssignmentPattern: - * ObjectAssignmentPattern - * ArrayAssignmentPattern - * ArrayAssignmentPattern: - * [Elision AssignmentRestElementopt ] - * [AssignmentElementList] - * [AssignmentElementList, Elision AssignmentRestElementopt ] - * AssignmentElementList: - * Elision AssignmentElement - * AssignmentElementList, Elisionopt AssignmentElement - * AssignmentElement: - * LeftHandSideExpression Initialiseropt - * AssignmentPattern Initialiseropt - * AssignmentRestElement: - * ... LeftHandSideExpression - */ - -// In a destructuring assignment expression, the type of the expression on the right must be assignable to the assignment target on the left. -// An expression of type S is considered assignable to an assignment target V if one of the following is true - -// V is an array assignment pattern, S is the type Any or an array-like type (section 3.3.2), and, for each assignment element E in V, -// S is the type Any, or - -var [a0, a1]: any = undefined; ->a0 : Symbol(a0, Decl(destructuringArrayBindingPatternAndAssignment1ES6.ts, 24, 5)) ->a1 : Symbol(a1, Decl(destructuringArrayBindingPatternAndAssignment1ES6.ts, 24, 8)) ->undefined : Symbol(undefined) - -var [a2 = false, a3 = 1]: any = undefined; ->a2 : Symbol(a2, Decl(destructuringArrayBindingPatternAndAssignment1ES6.ts, 25, 5)) ->a3 : Symbol(a3, Decl(destructuringArrayBindingPatternAndAssignment1ES6.ts, 25, 16)) ->undefined : Symbol(undefined) - -// V is an array assignment pattern, S is the type Any or an array-like type (section 3.3.2), and, for each assignment element E in V, -// S is a tuple- like type (section 3.3.3) with a property named N of a type that is assignable to the target given in E, -// where N is the numeric index of E in the array assignment pattern, or -var [b0, b1, b2] = [2, 3, 4]; ->b0 : Symbol(b0, Decl(destructuringArrayBindingPatternAndAssignment1ES6.ts, 30, 5)) ->b1 : Symbol(b1, Decl(destructuringArrayBindingPatternAndAssignment1ES6.ts, 30, 8)) ->b2 : Symbol(b2, Decl(destructuringArrayBindingPatternAndAssignment1ES6.ts, 30, 12)) - -var [b3, b4, b5]: [number, number, string] = [1, 2, "string"]; ->b3 : Symbol(b3, Decl(destructuringArrayBindingPatternAndAssignment1ES6.ts, 31, 5)) ->b4 : Symbol(b4, Decl(destructuringArrayBindingPatternAndAssignment1ES6.ts, 31, 8)) ->b5 : Symbol(b5, Decl(destructuringArrayBindingPatternAndAssignment1ES6.ts, 31, 12)) - -function foo() { ->foo : Symbol(foo, Decl(destructuringArrayBindingPatternAndAssignment1ES6.ts, 31, 62)) - - return [1, 2, 3]; -} - -var [b6, b7] = foo(); ->b6 : Symbol(b6, Decl(destructuringArrayBindingPatternAndAssignment1ES6.ts, 37, 5)) ->b7 : Symbol(b7, Decl(destructuringArrayBindingPatternAndAssignment1ES6.ts, 37, 8)) ->foo : Symbol(foo, Decl(destructuringArrayBindingPatternAndAssignment1ES6.ts, 31, 62)) - -var [...b8] = foo(); ->b8 : Symbol(b8, Decl(destructuringArrayBindingPatternAndAssignment1ES6.ts, 38, 5)) ->foo : Symbol(foo, Decl(destructuringArrayBindingPatternAndAssignment1ES6.ts, 31, 62)) - -// S is not a tuple- like type and the numeric index signature type of S is assignable to the target given in E. -var temp = [1,2,3] ->temp : Symbol(temp, Decl(destructuringArrayBindingPatternAndAssignment1ES6.ts, 41, 3)) - -var [c0, c1] = [...temp]; ->c0 : Symbol(c0, Decl(destructuringArrayBindingPatternAndAssignment1ES6.ts, 42, 5)) ->c1 : Symbol(c1, Decl(destructuringArrayBindingPatternAndAssignment1ES6.ts, 42, 8)) ->temp : Symbol(temp, Decl(destructuringArrayBindingPatternAndAssignment1ES6.ts, 41, 3)) - -var [c2] = []; ->c2 : Symbol(c2, Decl(destructuringArrayBindingPatternAndAssignment1ES6.ts, 43, 5)) - -var [[[c3]], [[[[c4]]]]] = [[[]], [[[[]]]]] ->c3 : Symbol(c3, Decl(destructuringArrayBindingPatternAndAssignment1ES6.ts, 44, 7)) ->c4 : Symbol(c4, Decl(destructuringArrayBindingPatternAndAssignment1ES6.ts, 44, 17)) - -var [[c5], c6]: [[string|number], boolean] = [[1], true]; ->c5 : Symbol(c5, Decl(destructuringArrayBindingPatternAndAssignment1ES6.ts, 45, 6)) ->c6 : Symbol(c6, Decl(destructuringArrayBindingPatternAndAssignment1ES6.ts, 45, 10)) - -var [, c7] = [1, 2, 3]; ->c7 : Symbol(c7, Decl(destructuringArrayBindingPatternAndAssignment1ES6.ts, 46, 6)) - -var [,,, c8] = [1, 2, 3, 4]; ->c8 : Symbol(c8, Decl(destructuringArrayBindingPatternAndAssignment1ES6.ts, 47, 8)) - -var [,,, c9] = [1, 2, 3, 4]; ->c9 : Symbol(c9, Decl(destructuringArrayBindingPatternAndAssignment1ES6.ts, 48, 8)) - -var [,,,...c10] = [1, 2, 3, 4, "hello"]; ->c10 : Symbol(c10, Decl(destructuringArrayBindingPatternAndAssignment1ES6.ts, 49, 8)) - -var [c11, c12, ...c13] = [1, 2, "string"]; ->c11 : Symbol(c11, Decl(destructuringArrayBindingPatternAndAssignment1ES6.ts, 50, 5)) ->c12 : Symbol(c12, Decl(destructuringArrayBindingPatternAndAssignment1ES6.ts, 50, 9)) ->c13 : Symbol(c13, Decl(destructuringArrayBindingPatternAndAssignment1ES6.ts, 50, 14)) - -var [c14, c15, c16] = [1, 2, "string"]; ->c14 : Symbol(c14, Decl(destructuringArrayBindingPatternAndAssignment1ES6.ts, 51, 5)) ->c15 : Symbol(c15, Decl(destructuringArrayBindingPatternAndAssignment1ES6.ts, 51, 9)) ->c16 : Symbol(c16, Decl(destructuringArrayBindingPatternAndAssignment1ES6.ts, 51, 14)) - diff --git a/tests/baselines/reference/destructuringArrayBindingPatternAndAssignment1ES6.types b/tests/baselines/reference/destructuringArrayBindingPatternAndAssignment1ES6.types deleted file mode 100644 index d154f091214..00000000000 --- a/tests/baselines/reference/destructuringArrayBindingPatternAndAssignment1ES6.types +++ /dev/null @@ -1,177 +0,0 @@ -=== tests/cases/conformance/es6/destructuring/destructuringArrayBindingPatternAndAssignment1ES6.ts === - -/* AssignmentPattern: - * ObjectAssignmentPattern - * ArrayAssignmentPattern - * ArrayAssignmentPattern: - * [Elision AssignmentRestElementopt ] - * [AssignmentElementList] - * [AssignmentElementList, Elision AssignmentRestElementopt ] - * AssignmentElementList: - * Elision AssignmentElement - * AssignmentElementList, Elisionopt AssignmentElement - * AssignmentElement: - * LeftHandSideExpression Initialiseropt - * AssignmentPattern Initialiseropt - * AssignmentRestElement: - * ... LeftHandSideExpression - */ - -// In a destructuring assignment expression, the type of the expression on the right must be assignable to the assignment target on the left. -// An expression of type S is considered assignable to an assignment target V if one of the following is true - -// V is an array assignment pattern, S is the type Any or an array-like type (section 3.3.2), and, for each assignment element E in V, -// S is the type Any, or - -var [a0, a1]: any = undefined; ->a0 : any ->a1 : any ->undefined : undefined - -var [a2 = false, a3 = 1]: any = undefined; ->a2 : boolean ->false : boolean ->a3 : number ->1 : number ->undefined : undefined - -// V is an array assignment pattern, S is the type Any or an array-like type (section 3.3.2), and, for each assignment element E in V, -// S is a tuple- like type (section 3.3.3) with a property named N of a type that is assignable to the target given in E, -// where N is the numeric index of E in the array assignment pattern, or -var [b0, b1, b2] = [2, 3, 4]; ->b0 : number ->b1 : number ->b2 : number ->[2, 3, 4] : [number, number, number] ->2 : number ->3 : number ->4 : number - -var [b3, b4, b5]: [number, number, string] = [1, 2, "string"]; ->b3 : number ->b4 : number ->b5 : string ->[1, 2, "string"] : [number, number, string] ->1 : number ->2 : number ->"string" : string - -function foo() { ->foo : () => number[] - - return [1, 2, 3]; ->[1, 2, 3] : number[] ->1 : number ->2 : number ->3 : number -} - -var [b6, b7] = foo(); ->b6 : number ->b7 : number ->foo() : number[] ->foo : () => number[] - -var [...b8] = foo(); ->b8 : number[] ->foo() : number[] ->foo : () => number[] - -// S is not a tuple- like type and the numeric index signature type of S is assignable to the target given in E. -var temp = [1,2,3] ->temp : number[] ->[1,2,3] : number[] ->1 : number ->2 : number ->3 : number - -var [c0, c1] = [...temp]; ->c0 : number ->c1 : number ->[...temp] : number[] ->...temp : number ->temp : number[] - -var [c2] = []; ->c2 : any ->[] : [undefined] - -var [[[c3]], [[[[c4]]]]] = [[[]], [[[[]]]]] ->c3 : any ->c4 : any ->[[[]], [[[[]]]]] : [[[undefined]], [[[[undefined]]]]] ->[[]] : [[undefined]] ->[] : [undefined] ->[[[[]]]] : [[[[undefined]]]] ->[[[]]] : [[[undefined]]] ->[[]] : [[undefined]] ->[] : [undefined] - -var [[c5], c6]: [[string|number], boolean] = [[1], true]; ->c5 : string | number ->c6 : boolean ->[[1], true] : [[number], boolean] ->[1] : [number] ->1 : number ->true : boolean - -var [, c7] = [1, 2, 3]; -> : undefined ->c7 : number ->[1, 2, 3] : [number, number, number] ->1 : number ->2 : number ->3 : number - -var [,,, c8] = [1, 2, 3, 4]; -> : undefined -> : undefined -> : undefined ->c8 : number ->[1, 2, 3, 4] : [number, number, number, number] ->1 : number ->2 : number ->3 : number ->4 : number - -var [,,, c9] = [1, 2, 3, 4]; -> : undefined -> : undefined -> : undefined ->c9 : number ->[1, 2, 3, 4] : [number, number, number, number] ->1 : number ->2 : number ->3 : number ->4 : number - -var [,,,...c10] = [1, 2, 3, 4, "hello"]; -> : undefined -> : undefined -> : undefined ->c10 : (number | string)[] ->[1, 2, 3, 4, "hello"] : (number | string)[] ->1 : number ->2 : number ->3 : number ->4 : number ->"hello" : string - -var [c11, c12, ...c13] = [1, 2, "string"]; ->c11 : number | string ->c12 : number | string ->c13 : (number | string)[] ->[1, 2, "string"] : (number | string)[] ->1 : number ->2 : number ->"string" : string - -var [c14, c15, c16] = [1, 2, "string"]; ->c14 : number ->c15 : number ->c16 : string ->[1, 2, "string"] : [number, number, string] ->1 : number ->2 : number ->"string" : string - diff --git a/tests/baselines/reference/destructuringArrayBindingPatternAndAssignment2.errors.txt b/tests/baselines/reference/destructuringArrayBindingPatternAndAssignment2.errors.txt index a2e5cb7e17c..082bc7aa72a 100644 --- a/tests/baselines/reference/destructuringArrayBindingPatternAndAssignment2.errors.txt +++ b/tests/baselines/reference/destructuringArrayBindingPatternAndAssignment2.errors.txt @@ -1,5 +1,5 @@ -tests/cases/conformance/es6/destructuring/destructuringArrayBindingPatternAndAssignment2.ts(3,6): error TS2461: Type 'undefined' is not an array type. -tests/cases/conformance/es6/destructuring/destructuringArrayBindingPatternAndAssignment2.ts(3,12): error TS2461: Type 'undefined' is not an array type. +tests/cases/conformance/es6/destructuring/destructuringArrayBindingPatternAndAssignment2.ts(3,6): error TS2525: Initializer provides no value for this binding element and the binding element has no default value +tests/cases/conformance/es6/destructuring/destructuringArrayBindingPatternAndAssignment2.ts(3,12): error TS2525: Initializer provides no value for this binding element and the binding element has no default value tests/cases/conformance/es6/destructuring/destructuringArrayBindingPatternAndAssignment2.ts(4,5): error TS2461: Type 'undefined' is not an array type. tests/cases/conformance/es6/destructuring/destructuringArrayBindingPatternAndAssignment2.ts(9,5): error TS2322: Type '[number, number, string]' is not assignable to type '[number, boolean, string]'. Types of property '1' are incompatible. @@ -18,9 +18,9 @@ tests/cases/conformance/es6/destructuring/destructuringArrayBindingPatternAndAss // S is the type Any, or var [[a0], [[a1]]] = [] // Error ~~~~ -!!! error TS2461: Type 'undefined' is not an array type. +!!! error TS2525: Initializer provides no value for this binding element and the binding element has no default value ~~~~~~ -!!! error TS2461: Type 'undefined' is not an array type. +!!! error TS2525: Initializer provides no value for this binding element and the binding element has no default value var [[a2], [[a3]]] = undefined // Error ~~~~~~~~~~~~~~ !!! error TS2461: Type 'undefined' is not an array type. diff --git a/tests/baselines/reference/destructuringObjectBindingPatternAndAssignment3.errors.txt b/tests/baselines/reference/destructuringObjectBindingPatternAndAssignment3.errors.txt index 4cee4314466..709774fb9b4 100644 --- a/tests/baselines/reference/destructuringObjectBindingPatternAndAssignment3.errors.txt +++ b/tests/baselines/reference/destructuringObjectBindingPatternAndAssignment3.errors.txt @@ -3,7 +3,7 @@ tests/cases/conformance/es6/destructuring/destructuringObjectBindingPatternAndAs Type '{ i: number; }' is not assignable to type 'number'. tests/cases/conformance/es6/destructuring/destructuringObjectBindingPatternAndAssignment3.ts(3,6): error TS2459: Type 'string | number' has no property 'i' and no string index signature. tests/cases/conformance/es6/destructuring/destructuringObjectBindingPatternAndAssignment3.ts(4,6): error TS2459: Type 'string | number | {}' has no property 'i1' and no string index signature. -tests/cases/conformance/es6/destructuring/destructuringObjectBindingPatternAndAssignment3.ts(5,12): error TS2459: Type '{ f212: string; }' has no property 'f21' and no string index signature. +tests/cases/conformance/es6/destructuring/destructuringObjectBindingPatternAndAssignment3.ts(5,12): error TS2525: Initializer provides no value for this binding element and the binding element has no default value tests/cases/conformance/es6/destructuring/destructuringObjectBindingPatternAndAssignment3.ts(5,21): error TS2353: Object literal may only specify known properties, and 'f212' does not exist in type '{ f21: any; }'. tests/cases/conformance/es6/destructuring/destructuringObjectBindingPatternAndAssignment3.ts(6,7): error TS1180: Property destructuring pattern expected. tests/cases/conformance/es6/destructuring/destructuringObjectBindingPatternAndAssignment3.ts(7,5): error TS2353: Object literal may only specify known properties, and 'a' does not exist in type '{ d1: any; }'. @@ -30,7 +30,7 @@ tests/cases/conformance/es6/destructuring/destructuringObjectBindingPatternAndAs !!! error TS2459: Type 'string | number | {}' has no property 'i1' and no string index signature. var { f2: {f21} = { f212: "string" } }: any = undefined; ~~~ -!!! error TS2459: Type '{ f212: string; }' has no property 'f21' and no string index signature. +!!! error TS2525: Initializer provides no value for this binding element and the binding element has no default value ~~~~ !!! error TS2353: Object literal may only specify known properties, and 'f212' does not exist in type '{ f21: any; }'. var { ...d1 } = { diff --git a/tests/baselines/reference/destructuringVariableDeclaration1ES5.types b/tests/baselines/reference/destructuringVariableDeclaration1ES5.types index c024fdfe862..f8188147a79 100644 --- a/tests/baselines/reference/destructuringVariableDeclaration1ES5.types +++ b/tests/baselines/reference/destructuringVariableDeclaration1ES5.types @@ -151,9 +151,9 @@ var {f: [f1, f2, { f3: f4, f5 }, , ]} = { f: [1, 2, { f3: 4, f5: 0 }] }; >f4 : number >f5 : number > : undefined ->{ f: [1, 2, { f3: 4, f5: 0 }] } : { f: [number, number, { f3: number; f5: number; }, undefined]; } ->f : [number, number, { f3: number; f5: number; }, undefined] ->[1, 2, { f3: 4, f5: 0 }] : [number, number, { f3: number; f5: number; }, undefined] +>{ f: [1, 2, { f3: 4, f5: 0 }] } : { f: [number, number, { f3: number; f5: number; }, any]; } +>f : [number, number, { f3: number; f5: number; }, any] +>[1, 2, { f3: 4, f5: 0 }] : [number, number, { f3: number; f5: number; }, any] >1 : number >2 : number >{ f3: 4, f5: 0 } : { f3: number; f5: number; } diff --git a/tests/baselines/reference/destructuringVariableDeclaration1ES6.types b/tests/baselines/reference/destructuringVariableDeclaration1ES6.types index 730abd843a2..7b4fe5409db 100644 --- a/tests/baselines/reference/destructuringVariableDeclaration1ES6.types +++ b/tests/baselines/reference/destructuringVariableDeclaration1ES6.types @@ -151,9 +151,9 @@ var {f: [f1, f2, { f3: f4, f5 }, , ]} = { f: [1, 2, { f3: 4, f5: 0 }] }; >f4 : number >f5 : number > : undefined ->{ f: [1, 2, { f3: 4, f5: 0 }] } : { f: [number, number, { f3: number; f5: number; }, undefined]; } ->f : [number, number, { f3: number; f5: number; }, undefined] ->[1, 2, { f3: 4, f5: 0 }] : [number, number, { f3: number; f5: number; }, undefined] +>{ f: [1, 2, { f3: 4, f5: 0 }] } : { f: [number, number, { f3: number; f5: number; }, any]; } +>f : [number, number, { f3: number; f5: number; }, any] +>[1, 2, { f3: 4, f5: 0 }] : [number, number, { f3: number; f5: number; }, any] >1 : number >2 : number >{ f3: 4, f5: 0 } : { f3: number; f5: number; } diff --git a/tests/baselines/reference/downlevelLetConst12.errors.txt b/tests/baselines/reference/downlevelLetConst12.errors.txt new file mode 100644 index 00000000000..f29d9435dbb --- /dev/null +++ b/tests/baselines/reference/downlevelLetConst12.errors.txt @@ -0,0 +1,20 @@ +tests/cases/compiler/downlevelLetConst12.ts(7,6): error TS2525: Initializer provides no value for this binding element and the binding element has no default value +tests/cases/compiler/downlevelLetConst12.ts(10,8): error TS2525: Initializer provides no value for this binding element and the binding element has no default value + + +==== tests/cases/compiler/downlevelLetConst12.ts (2 errors) ==== + + 'use strict' + // top level let\const should not be renamed + let foo; + const bar = 1; + + let [baz] = []; + ~~~ +!!! error TS2525: Initializer provides no value for this binding element and the binding element has no default value + let {a: baz2} = { a: 1 }; + + const [baz3] = [] + ~~~~ +!!! error TS2525: Initializer provides no value for this binding element and the binding element has no default value + const {a: baz4} = { a: 1 }; \ No newline at end of file diff --git a/tests/baselines/reference/downlevelLetConst12.symbols b/tests/baselines/reference/downlevelLetConst12.symbols deleted file mode 100644 index 97d6d5eebf8..00000000000 --- a/tests/baselines/reference/downlevelLetConst12.symbols +++ /dev/null @@ -1,26 +0,0 @@ -=== tests/cases/compiler/downlevelLetConst12.ts === - -'use strict' -// top level let\const should not be renamed -let foo; ->foo : Symbol(foo, Decl(downlevelLetConst12.ts, 3, 3)) - -const bar = 1; ->bar : Symbol(bar, Decl(downlevelLetConst12.ts, 4, 5)) - -let [baz] = []; ->baz : Symbol(baz, Decl(downlevelLetConst12.ts, 6, 5)) - -let {a: baz2} = { a: 1 }; ->a : Symbol(a, Decl(downlevelLetConst12.ts, 7, 17)) ->baz2 : Symbol(baz2, Decl(downlevelLetConst12.ts, 7, 5)) ->a : Symbol(a, Decl(downlevelLetConst12.ts, 7, 17)) - -const [baz3] = [] ->baz3 : Symbol(baz3, Decl(downlevelLetConst12.ts, 9, 7)) - -const {a: baz4} = { a: 1 }; ->a : Symbol(a, Decl(downlevelLetConst12.ts, 10, 19)) ->baz4 : Symbol(baz4, Decl(downlevelLetConst12.ts, 10, 7)) ->a : Symbol(a, Decl(downlevelLetConst12.ts, 10, 19)) - diff --git a/tests/baselines/reference/downlevelLetConst12.types b/tests/baselines/reference/downlevelLetConst12.types deleted file mode 100644 index a6146b55dd7..00000000000 --- a/tests/baselines/reference/downlevelLetConst12.types +++ /dev/null @@ -1,35 +0,0 @@ -=== tests/cases/compiler/downlevelLetConst12.ts === - -'use strict' ->'use strict' : string - -// top level let\const should not be renamed -let foo; ->foo : any - -const bar = 1; ->bar : number ->1 : number - -let [baz] = []; ->baz : any ->[] : [undefined] - -let {a: baz2} = { a: 1 }; ->a : any ->baz2 : number ->{ a: 1 } : { a: number; } ->a : number ->1 : number - -const [baz3] = [] ->baz3 : any ->[] : [undefined] - -const {a: baz4} = { a: 1 }; ->a : any ->baz4 : number ->{ a: 1 } : { a: number; } ->a : number ->1 : number - diff --git a/tests/baselines/reference/downlevelLetConst16.errors.txt b/tests/baselines/reference/downlevelLetConst16.errors.txt index 94c53360b87..43acc162d7a 100644 --- a/tests/baselines/reference/downlevelLetConst16.errors.txt +++ b/tests/baselines/reference/downlevelLetConst16.errors.txt @@ -1,10 +1,12 @@ +tests/cases/compiler/downlevelLetConst16.ts(151,15): error TS2525: Initializer provides no value for this binding element and the binding element has no default value +tests/cases/compiler/downlevelLetConst16.ts(164,17): error TS2525: Initializer provides no value for this binding element and the binding element has no default value tests/cases/compiler/downlevelLetConst16.ts(195,14): error TS2461: Type 'undefined' is not an array type. tests/cases/compiler/downlevelLetConst16.ts(202,15): error TS2459: Type 'undefined' has no property 'a' and no string index signature. tests/cases/compiler/downlevelLetConst16.ts(216,16): error TS2461: Type 'undefined' is not an array type. tests/cases/compiler/downlevelLetConst16.ts(223,17): error TS2459: Type 'undefined' has no property 'a' and no string index signature. -==== tests/cases/compiler/downlevelLetConst16.ts (4 errors) ==== +==== tests/cases/compiler/downlevelLetConst16.ts (6 errors) ==== 'use strict' declare function use(a: any); @@ -156,6 +158,8 @@ tests/cases/compiler/downlevelLetConst16.ts(223,17): error TS2459: Type 'undefin use(x); } for (let [y] = []; ;) { + ~ +!!! error TS2525: Initializer provides no value for this binding element and the binding element has no default value use(y); } for (let {a: z} = {a: 1}; ;) { @@ -169,6 +173,8 @@ tests/cases/compiler/downlevelLetConst16.ts(223,17): error TS2459: Type 'undefin use(x); } for (const [y] = []; ;) { + ~ +!!! error TS2525: Initializer provides no value for this binding element and the binding element has no default value use(y); } for (const {a: z} = { a: 1 }; ;) { diff --git a/tests/baselines/reference/missingAndExcessProperties.errors.txt b/tests/baselines/reference/missingAndExcessProperties.errors.txt index 294b564a239..6b015001829 100644 --- a/tests/baselines/reference/missingAndExcessProperties.errors.txt +++ b/tests/baselines/reference/missingAndExcessProperties.errors.txt @@ -1,11 +1,15 @@ -tests/cases/conformance/es6/destructuring/missingAndExcessProperties.ts(3,11): error TS2459: Type '{}' has no property 'x' and no string index signature. -tests/cases/conformance/es6/destructuring/missingAndExcessProperties.ts(3,14): error TS2459: Type '{}' has no property 'y' and no string index signature. -tests/cases/conformance/es6/destructuring/missingAndExcessProperties.ts(4,18): error TS2459: Type '{ x?: number; }' has no property 'y' and no string index signature. -tests/cases/conformance/es6/destructuring/missingAndExcessProperties.ts(5,11): error TS2459: Type '{ y?: number; }' has no property 'x' and no string index signature. -tests/cases/conformance/es6/destructuring/missingAndExcessProperties.ts(12,8): error TS2459: Type '{}' has no property 'x' and no string index signature. -tests/cases/conformance/es6/destructuring/missingAndExcessProperties.ts(12,11): error TS2459: Type '{}' has no property 'y' and no string index signature. -tests/cases/conformance/es6/destructuring/missingAndExcessProperties.ts(13,18): error TS2459: Type '{ x?: number; }' has no property 'y' and no string index signature. -tests/cases/conformance/es6/destructuring/missingAndExcessProperties.ts(14,8): error TS2459: Type '{ y?: number; }' has no property 'x' and no string index signature. +tests/cases/conformance/es6/destructuring/missingAndExcessProperties.ts(3,11): error TS2525: Initializer provides no value for this binding element and the binding element has no default value +tests/cases/conformance/es6/destructuring/missingAndExcessProperties.ts(3,14): error TS2525: Initializer provides no value for this binding element and the binding element has no default value +tests/cases/conformance/es6/destructuring/missingAndExcessProperties.ts(4,11): error TS2403: Subsequent variable declarations must have the same type. Variable 'x' must be of type 'any', but here has type 'number'. +tests/cases/conformance/es6/destructuring/missingAndExcessProperties.ts(4,18): error TS2525: Initializer provides no value for this binding element and the binding element has no default value +tests/cases/conformance/es6/destructuring/missingAndExcessProperties.ts(5,11): error TS2525: Initializer provides no value for this binding element and the binding element has no default value +tests/cases/conformance/es6/destructuring/missingAndExcessProperties.ts(5,14): error TS2403: Subsequent variable declarations must have the same type. Variable 'y' must be of type 'any', but here has type 'number'. +tests/cases/conformance/es6/destructuring/missingAndExcessProperties.ts(6,11): error TS2403: Subsequent variable declarations must have the same type. Variable 'x' must be of type 'any', but here has type 'number'. +tests/cases/conformance/es6/destructuring/missingAndExcessProperties.ts(6,18): error TS2403: Subsequent variable declarations must have the same type. Variable 'y' must be of type 'any', but here has type 'number'. +tests/cases/conformance/es6/destructuring/missingAndExcessProperties.ts(12,8): error TS2525: Initializer provides no value for this binding element and the binding element has no default value +tests/cases/conformance/es6/destructuring/missingAndExcessProperties.ts(12,11): error TS2525: Initializer provides no value for this binding element and the binding element has no default value +tests/cases/conformance/es6/destructuring/missingAndExcessProperties.ts(13,18): error TS2525: Initializer provides no value for this binding element and the binding element has no default value +tests/cases/conformance/es6/destructuring/missingAndExcessProperties.ts(14,8): error TS2525: Initializer provides no value for this binding element and the binding element has no default value tests/cases/conformance/es6/destructuring/missingAndExcessProperties.ts(20,17): error TS2353: Object literal may only specify known properties, and 'x' does not exist in type '{}'. tests/cases/conformance/es6/destructuring/missingAndExcessProperties.ts(20,23): error TS2353: Object literal may only specify known properties, and 'y' does not exist in type '{}'. tests/cases/conformance/es6/destructuring/missingAndExcessProperties.ts(21,25): error TS2353: Object literal may only specify known properties, and 'y' does not exist in type '{ x: any; }'. @@ -16,21 +20,29 @@ tests/cases/conformance/es6/destructuring/missingAndExcessProperties.ts(30,22): tests/cases/conformance/es6/destructuring/missingAndExcessProperties.ts(31,16): error TS2353: Object literal may only specify known properties, and 'x' does not exist in type '{ y: number; }'. -==== tests/cases/conformance/es6/destructuring/missingAndExcessProperties.ts (16 errors) ==== +==== tests/cases/conformance/es6/destructuring/missingAndExcessProperties.ts (20 errors) ==== // Missing properties function f1() { var { x, y } = {}; ~ -!!! error TS2459: Type '{}' has no property 'x' and no string index signature. +!!! error TS2525: Initializer provides no value for this binding element and the binding element has no default value ~ -!!! error TS2459: Type '{}' has no property 'y' and no string index signature. +!!! error TS2525: Initializer provides no value for this binding element and the binding element has no default value var { x = 1, y } = {}; + ~ +!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'x' must be of type 'any', but here has type 'number'. ~ -!!! error TS2459: Type '{ x?: number; }' has no property 'y' and no string index signature. +!!! error TS2525: Initializer provides no value for this binding element and the binding element has no default value var { x, y = 1 } = {}; ~ -!!! error TS2459: Type '{ y?: number; }' has no property 'x' and no string index signature. +!!! error TS2525: Initializer provides no value for this binding element and the binding element has no default value + ~ +!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'y' must be of type 'any', but here has type 'number'. var { x = 1, y = 1 } = {}; + ~ +!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'x' must be of type 'any', but here has type 'number'. + ~ +!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'y' must be of type 'any', but here has type 'number'. } // Missing properties @@ -38,15 +50,15 @@ tests/cases/conformance/es6/destructuring/missingAndExcessProperties.ts(31,16): var x: number, y: number; ({ x, y } = {}); ~ -!!! error TS2459: Type '{}' has no property 'x' and no string index signature. +!!! error TS2525: Initializer provides no value for this binding element and the binding element has no default value ~ -!!! error TS2459: Type '{}' has no property 'y' and no string index signature. +!!! error TS2525: Initializer provides no value for this binding element and the binding element has no default value ({ x: x = 1, y } = {}); ~ -!!! error TS2459: Type '{ x?: number; }' has no property 'y' and no string index signature. +!!! error TS2525: Initializer provides no value for this binding element and the binding element has no default value ({ x, y: y = 1 } = {}); ~ -!!! error TS2459: Type '{ y?: number; }' has no property 'x' and no string index signature. +!!! error TS2525: Initializer provides no value for this binding element and the binding element has no default value ({ x: x = 1, y: y = 1 } = {}); } From 297c60ea01091a1fc65e4fdc301ee5e8303e42d8 Mon Sep 17 00:00:00 2001 From: Vladimir Matveev Date: Thu, 10 Sep 2015 16:42:02 -0700 Subject: [PATCH 108/117] addressed PR feedback --- src/compiler/diagnosticInformationMap.generated.ts | 4 ++-- src/compiler/diagnosticMessages.json | 4 ++-- src/compiler/program.ts | 12 ++++++------ src/compiler/types.ts | 4 ++-- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/compiler/diagnosticInformationMap.generated.ts b/src/compiler/diagnosticInformationMap.generated.ts index efe4ba20d49..3775c9ce405 100644 --- a/src/compiler/diagnosticInformationMap.generated.ts +++ b/src/compiler/diagnosticInformationMap.generated.ts @@ -428,8 +428,8 @@ namespace ts { A_member_initializer_in_a_enum_declaration_cannot_reference_members_declared_after_it_including_members_defined_in_other_enums: { code: 2651, category: DiagnosticCategory.Error, key: "A member initializer in a enum declaration cannot reference members declared after it, including members defined in other enums." }, Merged_declaration_0_cannot_include_a_default_export_declaration_Consider_adding_a_separate_export_default_0_declaration_instead: { code: 2652, category: DiagnosticCategory.Error, key: "Merged declaration '{0}' cannot include a default export declaration. Consider adding a separate 'export default {0}' declaration instead." }, Non_abstract_class_expression_does_not_implement_inherited_abstract_member_0_from_class_1: { code: 2653, category: DiagnosticCategory.Error, key: "Non-abstract class expression does not implement inherited abstract member '{0}' from class '{1}'." }, - Proper_external_module_that_carries_external_typings_cannot_contain_tripleslash_references: { code: 2654, category: DiagnosticCategory.Error, key: "Proper external module that carries external typings cannot contain tripleslash references." }, - Proper_external_module_that_carries_external_typings_should_be_d_ts_file: { code: 2655, category: DiagnosticCategory.Error, key: "Proper external module that carries external typings should be '.d.ts' file." }, + Exported_external_package_typings_file_cannot_contain_tripleslash_references_Please_contact_the_package_author_to_update_the_package_definition: { code: 2654, category: DiagnosticCategory.Error, key: "Exported external package typings file cannot contain tripleslash references. Please contact the package author to update the package definition." }, + Exported_external_package_typings_can_only_be_in_d_ts_files_Please_contact_the_package_author_to_update_the_package_definition: { code: 2655, category: DiagnosticCategory.Error, key: "Exported external package typings can only be in '.d.ts' files. Please contact the package author to update the package definition." }, Import_declaration_0_is_using_private_name_1: { code: 4000, category: DiagnosticCategory.Error, key: "Import declaration '{0}' is using private name '{1}'." }, Type_parameter_0_of_exported_class_has_or_is_using_private_name_1: { code: 4002, category: DiagnosticCategory.Error, key: "Type parameter '{0}' of exported class has or is using private name '{1}'." }, Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1: { code: 4004, category: DiagnosticCategory.Error, key: "Type parameter '{0}' of exported interface has or is using private name '{1}'." }, diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index c62f08555df..79fd114e9a3 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -1701,11 +1701,11 @@ "category": "Error", "code": 2653 }, - "Proper external module that carries external typings cannot contain tripleslash references.": { + "Exported external package typings file cannot contain tripleslash references. Please contact the package author to update the package definition.": { "category": "Error", "code": 2654 }, - "Proper external module that carries external typings should be '.d.ts' file.": { + "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 }, diff --git a/src/compiler/program.ts b/src/compiler/program.ts index ff3f5c2ba8a..790d121d135 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -129,12 +129,12 @@ namespace ts { let candidate = normalizePath(combinePaths(nodeModulesFolder, moduleName)); let result = loadNodeModuleFromFile(candidate, /* loadOnlyDts */ true, failedLookupLocations, host); if (result) { - return { resolvedModule: { resolvedFileName: result, shouldBeProperExternalModule: true }, failedLookupLocations }; + return { resolvedModule: { resolvedFileName: result, isExternalLibraryImport: true }, failedLookupLocations }; } result = loadNodeModuleFromDirectory(candidate, /* loadOnlyDts */ true, failedLookupLocations, host); if (result) { - return { resolvedModule: { resolvedFileName: result, shouldBeProperExternalModule: true }, failedLookupLocations }; + return { resolvedModule: { resolvedFileName: result, isExternalLibraryImport: true }, failedLookupLocations }; } } @@ -472,7 +472,7 @@ namespace ts { let resolutionChanged = oldResolution ? !newResolution || oldResolution.resolvedFileName !== newResolution.resolvedFileName || - !!oldResolution.shouldBeProperExternalModule !== !!newResolution.shouldBeProperExternalModule + !!oldResolution.isExternalLibraryImport !== !!newResolution.isExternalLibraryImport : newResolution; if (resolutionChanged) { @@ -850,18 +850,18 @@ namespace ts { setResolvedModule(file, moduleNames[i], resolution); if (resolution && !options.noResolve) { const importedFile = findModuleSourceFile(resolution.resolvedFileName, file.imports[i]); - if (importedFile && resolution.shouldBeProperExternalModule) { + if (importedFile && resolution.isExternalLibraryImport) { if (!isExternalModule(importedFile)) { let start = getTokenPosOfNode(file.imports[i], file) diagnostics.add(createFileDiagnostic(file, start, file.imports[i].end - start, Diagnostics.File_0_is_not_a_module, importedFile.fileName)); } else if (!fileExtensionIs(importedFile.fileName, ".d.ts")) { let start = getTokenPosOfNode(file.imports[i], file) - diagnostics.add(createFileDiagnostic(file, start, file.imports[i].end - start, Diagnostics.Proper_external_module_that_carries_external_typings_should_be_d_ts_file)); + diagnostics.add(createFileDiagnostic(file, start, file.imports[i].end - start, Diagnostics.Exported_external_package_typings_can_only_be_in_d_ts_files_Please_contact_the_package_author_to_update_the_package_definition)); } else if (importedFile.referencedFiles.length) { let firstRef = importedFile.referencedFiles[0]; - diagnostics.add(createFileDiagnostic(importedFile, firstRef.pos, firstRef.end - firstRef.pos, Diagnostics.Proper_external_module_that_carries_external_typings_cannot_contain_tripleslash_references)); + diagnostics.add(createFileDiagnostic(importedFile, firstRef.pos, firstRef.end - firstRef.pos, Diagnostics.Exported_external_package_typings_file_cannot_contain_tripleslash_references_Please_contact_the_package_author_to_update_the_package_definition)); } } } diff --git a/src/compiler/types.ts b/src/compiler/types.ts index d7bc6b4edbc..fd21cc79ab6 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -2270,12 +2270,12 @@ namespace ts { export interface ResolvedModule { resolvedFileName: string; /* - * Denotes if 'resolvedFileName' should be proper external module: + * Denotes if 'resolvedFileName' is isExternalLibraryImport and thus should be proper external module: * - be a .d.ts file * - use top level imports\exports * - don't use tripleslash references */ - shouldBeProperExternalModule?: boolean; + isExternalLibraryImport?: boolean; } export interface ResolvedModuleWithFailedLookupLocations { From 87e1569d1f759bb43707ac2f8ae5c1aec645de90 Mon Sep 17 00:00:00 2001 From: Vladimir Matveev Date: Thu, 10 Sep 2015 17:00:29 -0700 Subject: [PATCH 109/117] resolve merge conflicts, update tests --- src/compiler/program.ts | 6 +++--- tests/baselines/reference/nodeResolution6.errors.txt | 4 ++-- tests/baselines/reference/nodeResolution8.errors.txt | 4 ++-- tests/cases/unittests/moduleResolution.ts | 10 +++++----- tests/cases/unittests/reuseProgramStructure.ts | 2 +- 5 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/compiler/program.ts b/src/compiler/program.ts index 92fbfebce6c..28dd477666b 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -863,15 +863,15 @@ namespace ts { if (importedFile && resolution.isExternalLibraryImport) { if (!isExternalModule(importedFile)) { let start = getTokenPosOfNode(file.imports[i], file) - diagnostics.add(createFileDiagnostic(file, start, file.imports[i].end - start, Diagnostics.File_0_is_not_a_module, importedFile.fileName)); + fileProcessingDiagnostics.add(createFileDiagnostic(file, start, file.imports[i].end - start, Diagnostics.File_0_is_not_a_module, importedFile.fileName)); } else if (!fileExtensionIs(importedFile.fileName, ".d.ts")) { let start = getTokenPosOfNode(file.imports[i], file) - diagnostics.add(createFileDiagnostic(file, start, file.imports[i].end - start, Diagnostics.Exported_external_package_typings_can_only_be_in_d_ts_files_Please_contact_the_package_author_to_update_the_package_definition)); + fileProcessingDiagnostics.add(createFileDiagnostic(file, start, file.imports[i].end - start, Diagnostics.Exported_external_package_typings_can_only_be_in_d_ts_files_Please_contact_the_package_author_to_update_the_package_definition)); } else if (importedFile.referencedFiles.length) { let firstRef = importedFile.referencedFiles[0]; - diagnostics.add(createFileDiagnostic(importedFile, firstRef.pos, firstRef.end - firstRef.pos, Diagnostics.Exported_external_package_typings_file_cannot_contain_tripleslash_references_Please_contact_the_package_author_to_update_the_package_definition)); + fileProcessingDiagnostics.add(createFileDiagnostic(importedFile, firstRef.pos, firstRef.end - firstRef.pos, Diagnostics.Exported_external_package_typings_file_cannot_contain_tripleslash_references_Please_contact_the_package_author_to_update_the_package_definition)); } } } diff --git a/tests/baselines/reference/nodeResolution6.errors.txt b/tests/baselines/reference/nodeResolution6.errors.txt index 8a462043207..6bab6e34389 100644 --- a/tests/baselines/reference/nodeResolution6.errors.txt +++ b/tests/baselines/reference/nodeResolution6.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/node_modules/a.d.ts(1,1): error TS2654: Proper external module that carries external typings cannot contain tripleslash references. +tests/cases/compiler/node_modules/a.d.ts(1,1): error TS2654: Exported external package typings file cannot contain tripleslash references. Please contact the package author to update the package definition. ==== tests/cases/compiler/b.ts (0 errors) ==== @@ -11,7 +11,7 @@ tests/cases/compiler/node_modules/a.d.ts(1,1): error TS2654: Proper external mod ==== tests/cases/compiler/node_modules/a.d.ts (1 errors) ==== /// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2654: Proper external module that carries external typings cannot contain tripleslash references. +!!! error TS2654: Exported external package typings file cannot contain tripleslash references. Please contact the package author to update the package definition. export declare var y; \ No newline at end of file diff --git a/tests/baselines/reference/nodeResolution8.errors.txt b/tests/baselines/reference/nodeResolution8.errors.txt index 82753a2049b..3f14a4313c8 100644 --- a/tests/baselines/reference/nodeResolution8.errors.txt +++ b/tests/baselines/reference/nodeResolution8.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/node_modules/a/index.d.ts(1,1): error TS2654: Proper external module that carries external typings cannot contain tripleslash references. +tests/cases/compiler/node_modules/a/index.d.ts(1,1): error TS2654: Exported external package typings file cannot contain tripleslash references. Please contact the package author to update the package definition. ==== tests/cases/compiler/b.ts (0 errors) ==== @@ -10,7 +10,7 @@ tests/cases/compiler/node_modules/a/index.d.ts(1,1): error TS2654: Proper extern ==== tests/cases/compiler/node_modules/a/index.d.ts (1 errors) ==== /// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2654: Proper external module that carries external typings cannot contain tripleslash references. +!!! error TS2654: Exported external package typings file cannot contain tripleslash references. Please contact the package author to update the package definition. export declare var y; \ No newline at end of file diff --git a/tests/cases/unittests/moduleResolution.ts b/tests/cases/unittests/moduleResolution.ts index ab12119ec5a..ed9f0b0a986 100644 --- a/tests/cases/unittests/moduleResolution.ts +++ b/tests/cases/unittests/moduleResolution.ts @@ -41,7 +41,7 @@ module ts { let moduleFile = { name: moduleFileNameNoExt + ext } let resolution = nodeModuleNameResolver(moduleName, containingFile.name, createModuleResolutionHost(containingFile, moduleFile)); assert.equal(resolution.resolvedModule.resolvedFileName, moduleFile.name); - assert.equal(!!resolution.resolvedModule.shouldBeProperExternalModule, false); + assert.equal(!!resolution.resolvedModule.isExternalLibraryImport, false); let failedLookupLocations: string[] = []; let dir = getDirectoryPath(containingFileName); @@ -80,7 +80,7 @@ module ts { let moduleFile = { name: moduleFileName }; let resolution = nodeModuleNameResolver(moduleName, containingFile.name, createModuleResolutionHost(containingFile, packageJson, moduleFile)); assert.equal(resolution.resolvedModule.resolvedFileName, moduleFile.name); - assert.equal(!!resolution.resolvedModule.shouldBeProperExternalModule, false); + assert.equal(!!resolution.resolvedModule.isExternalLibraryImport, false); // expect three failed lookup location - attempt to load module as file with all supported extensions assert.equal(resolution.failedLookupLocations.length, 3); } @@ -98,7 +98,7 @@ module ts { let indexFile = { name: "/a/b/foo/index.d.ts" }; let resolution = nodeModuleNameResolver("./foo", containingFile.name, createModuleResolutionHost(containingFile, packageJson, indexFile)); assert.equal(resolution.resolvedModule.resolvedFileName, indexFile.name); - assert.equal(!!resolution.resolvedModule.shouldBeProperExternalModule, false); + assert.equal(!!resolution.resolvedModule.isExternalLibraryImport, false); assert.deepEqual(resolution.failedLookupLocations, [ "/a/b/foo.ts", "/a/b/foo.tsx", @@ -139,7 +139,7 @@ module ts { let moduleFile = { name: "/a/b/node_modules/foo.d.ts" }; let resolution = nodeModuleNameResolver("foo", containingFile.name, createModuleResolutionHost(containingFile, moduleFile)); assert.equal(resolution.resolvedModule.resolvedFileName, moduleFile.name); - assert.equal(resolution.resolvedModule.shouldBeProperExternalModule, true); + assert.equal(resolution.resolvedModule.isExternalLibraryImport, true); }); it("load module as directory", () => { @@ -147,7 +147,7 @@ module ts { let moduleFile = { name: "/a/node_modules/foo/index.d.ts" }; let resolution = nodeModuleNameResolver("foo", containingFile.name, createModuleResolutionHost(containingFile, moduleFile)); assert.equal(resolution.resolvedModule.resolvedFileName, moduleFile.name); - assert.equal(resolution.resolvedModule.shouldBeProperExternalModule, true); + assert.equal(resolution.resolvedModule.isExternalLibraryImport, true); assert.deepEqual(resolution.failedLookupLocations, [ "/a/node_modules/b/c/node_modules/d/node_modules/foo.d.ts", "/a/node_modules/b/c/node_modules/d/node_modules/foo/package.json", diff --git a/tests/cases/unittests/reuseProgramStructure.ts b/tests/cases/unittests/reuseProgramStructure.ts index 4d167cb1bb0..5f313eeae2b 100644 --- a/tests/cases/unittests/reuseProgramStructure.ts +++ b/tests/cases/unittests/reuseProgramStructure.ts @@ -180,7 +180,7 @@ module ts { const actual = file.resolvedModules[id]; assert.isTrue(actual !== undefined); assert.isTrue(expected.resolvedFileName === actual.resolvedFileName, `'resolvedFileName': expected '${expected.resolvedFileName}' to be equal to '${actual.resolvedFileName}'`); - assert.isTrue(expected.shouldBeProperExternalModule === actual.shouldBeProperExternalModule, `'shouldBeProperExternalModule': expected '${expected.shouldBeProperExternalModule}' to be equal to '${actual.shouldBeProperExternalModule}'`); + assert.isTrue(expected.isExternalLibraryImport === actual.isExternalLibraryImport, `'shouldBeProperExternalModule': expected '${expected.isExternalLibraryImport}' to be equal to '${actual.isExternalLibraryImport}'`); } else { assert.isTrue(file.resolvedModules[id] === undefined); From 262f122d997c1f82ebfb517a1986d398658591ed Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Thu, 10 Sep 2015 17:03:13 -0700 Subject: [PATCH 110/117] Adding "." to error message --- .../diagnosticInformationMap.generated.ts | 2 +- src/compiler/diagnosticMessages.json | 2 +- ...nEmitDestructuringArrayPattern2.errors.txt | 12 +++---- .../declarationsAndAssignments.errors.txt | 32 +++++++++---------- ...BindingPatternAndAssignment1ES5.errors.txt | 12 +++---- ...BindingPatternAndAssignment1ES6.errors.txt | 12 +++---- ...rayBindingPatternAndAssignment2.errors.txt | 8 ++--- ...ectBindingPatternAndAssignment3.errors.txt | 4 +-- .../reference/downlevelLetConst12.errors.txt | 8 ++--- .../reference/downlevelLetConst16.errors.txt | 8 ++--- .../missingAndExcessProperties.errors.txt | 32 +++++++++---------- 11 files changed, 66 insertions(+), 66 deletions(-) diff --git a/src/compiler/diagnosticInformationMap.generated.ts b/src/compiler/diagnosticInformationMap.generated.ts index 9686d6580f5..4f53537d0c3 100644 --- a/src/compiler/diagnosticInformationMap.generated.ts +++ b/src/compiler/diagnosticInformationMap.generated.ts @@ -415,7 +415,7 @@ namespace ts { The_arguments_object_cannot_be_referenced_in_an_async_arrow_function_Consider_using_a_standard_async_function_expression: { code: 2522, category: DiagnosticCategory.Error, key: "The 'arguments' object cannot be referenced in an async arrow function. Consider using a standard async function expression." }, yield_expressions_cannot_be_used_in_a_parameter_initializer: { code: 2523, category: DiagnosticCategory.Error, key: "'yield' expressions cannot be used in a parameter initializer." }, await_expressions_cannot_be_used_in_a_parameter_initializer: { code: 2524, category: DiagnosticCategory.Error, key: "'await' expressions cannot be used in a parameter initializer." }, - Initializer_provides_no_value_for_this_binding_element_and_the_binding_element_has_no_default_value: { code: 2525, category: DiagnosticCategory.Error, key: "Initializer provides no value for this binding element and the binding element has no default value" }, + Initializer_provides_no_value_for_this_binding_element_and_the_binding_element_has_no_default_value: { code: 2525, category: DiagnosticCategory.Error, key: "Initializer provides no value for this binding element and the binding element has no default value." }, JSX_element_attributes_type_0_must_be_an_object_type: { code: 2600, category: DiagnosticCategory.Error, key: "JSX element attributes type '{0}' must be an object type." }, The_return_type_of_a_JSX_element_constructor_must_return_an_object_type: { code: 2601, category: DiagnosticCategory.Error, key: "The return type of a JSX element constructor must return an object type." }, JSX_element_implicitly_has_type_any_because_the_global_type_JSX_Element_does_not_exist: { code: 2602, category: DiagnosticCategory.Error, key: "JSX element implicitly has type 'any' because the global type 'JSX.Element' does not exist." }, diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index 515afda49aa..33749f67285 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -1649,7 +1649,7 @@ "category": "Error", "code": 2524 }, - "Initializer provides no value for this binding element and the binding element has no default value": { + "Initializer provides no value for this binding element and the binding element has no default value.": { "category": "Error", "code": 2525 }, diff --git a/tests/baselines/reference/declarationEmitDestructuringArrayPattern2.errors.txt b/tests/baselines/reference/declarationEmitDestructuringArrayPattern2.errors.txt index ea5b38a3b2f..26998fd83ae 100644 --- a/tests/baselines/reference/declarationEmitDestructuringArrayPattern2.errors.txt +++ b/tests/baselines/reference/declarationEmitDestructuringArrayPattern2.errors.txt @@ -1,6 +1,6 @@ -tests/cases/compiler/declarationEmitDestructuringArrayPattern2.ts(4,6): error TS2525: Initializer provides no value for this binding element and the binding element has no default value -tests/cases/compiler/declarationEmitDestructuringArrayPattern2.ts(4,11): error TS2525: Initializer provides no value for this binding element and the binding element has no default value -tests/cases/compiler/declarationEmitDestructuringArrayPattern2.ts(4,16): error TS2525: Initializer provides no value for this binding element and the binding element has no default value +tests/cases/compiler/declarationEmitDestructuringArrayPattern2.ts(4,6): error TS2525: Initializer provides no value for this binding element and the binding element has no default value. +tests/cases/compiler/declarationEmitDestructuringArrayPattern2.ts(4,11): error TS2525: Initializer provides no value for this binding element and the binding element has no default value. +tests/cases/compiler/declarationEmitDestructuringArrayPattern2.ts(4,16): error TS2525: Initializer provides no value for this binding element and the binding element has no default value. ==== tests/cases/compiler/declarationEmitDestructuringArrayPattern2.ts (3 errors) ==== @@ -9,11 +9,11 @@ tests/cases/compiler/declarationEmitDestructuringArrayPattern2.ts(4,16): error T var [x11 = 0, y11 = ""] = [1, "hello"]; var [a11, b11, c11] = []; ~~~ -!!! error TS2525: Initializer provides no value for this binding element and the binding element has no default value +!!! error TS2525: Initializer provides no value for this binding element and the binding element has no default value. ~~~ -!!! error TS2525: Initializer provides no value for this binding element and the binding element has no default value +!!! error TS2525: Initializer provides no value for this binding element and the binding element has no default value. ~~~ -!!! error TS2525: Initializer provides no value for this binding element and the binding element has no default value +!!! error TS2525: Initializer provides no value for this binding element and the binding element has no default value. var [a2, [b2, { x12, y12: c2 }]=["abc", { x12: 10, y12: false }]] = [1, ["hello", { x12: 5, y12: true }]]; diff --git a/tests/baselines/reference/declarationsAndAssignments.errors.txt b/tests/baselines/reference/declarationsAndAssignments.errors.txt index cd72c12951c..7c4671022ea 100644 --- a/tests/baselines/reference/declarationsAndAssignments.errors.txt +++ b/tests/baselines/reference/declarationsAndAssignments.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/es6/destructuring/declarationsAndAssignments.ts(5,16): error TS2525: Initializer provides no value for this binding element and the binding element has no default value +tests/cases/conformance/es6/destructuring/declarationsAndAssignments.ts(5,16): error TS2525: Initializer provides no value for this binding element and the binding element has no default value. tests/cases/conformance/es6/destructuring/declarationsAndAssignments.ts(22,17): error TS2353: Object literal may only specify known properties, and 'x' does not exist in type '{}'. tests/cases/conformance/es6/destructuring/declarationsAndAssignments.ts(22,23): error TS2353: Object literal may only specify known properties, and 'y' does not exist in type '{}'. tests/cases/conformance/es6/destructuring/declarationsAndAssignments.ts(23,25): error TS2353: Object literal may only specify known properties, and 'y' does not exist in type '{ x: any; }'. @@ -6,15 +6,15 @@ tests/cases/conformance/es6/destructuring/declarationsAndAssignments.ts(24,19): tests/cases/conformance/es6/destructuring/declarationsAndAssignments.ts(28,28): error TS2353: Object literal may only specify known properties, and 'y' does not exist in type '{ x: any; }'. tests/cases/conformance/es6/destructuring/declarationsAndAssignments.ts(29,22): error TS2353: Object literal may only specify known properties, and 'x' does not exist in type '{ y: any; }'. tests/cases/conformance/es6/destructuring/declarationsAndAssignments.ts(56,17): error TS2322: Type 'number' is not assignable to type 'string'. -tests/cases/conformance/es6/destructuring/declarationsAndAssignments.ts(62,10): error TS2525: Initializer provides no value for this binding element and the binding element has no default value -tests/cases/conformance/es6/destructuring/declarationsAndAssignments.ts(62,13): error TS2525: Initializer provides no value for this binding element and the binding element has no default value -tests/cases/conformance/es6/destructuring/declarationsAndAssignments.ts(62,16): error TS2525: Initializer provides no value for this binding element and the binding element has no default value -tests/cases/conformance/es6/destructuring/declarationsAndAssignments.ts(63,13): error TS2525: Initializer provides no value for this binding element and the binding element has no default value -tests/cases/conformance/es6/destructuring/declarationsAndAssignments.ts(63,16): error TS2525: Initializer provides no value for this binding element and the binding element has no default value +tests/cases/conformance/es6/destructuring/declarationsAndAssignments.ts(62,10): error TS2525: Initializer provides no value for this binding element and the binding element has no default value. +tests/cases/conformance/es6/destructuring/declarationsAndAssignments.ts(62,13): error TS2525: Initializer provides no value for this binding element and the binding element has no default value. +tests/cases/conformance/es6/destructuring/declarationsAndAssignments.ts(62,16): error TS2525: Initializer provides no value for this binding element and the binding element has no default value. +tests/cases/conformance/es6/destructuring/declarationsAndAssignments.ts(63,13): error TS2525: Initializer provides no value for this binding element and the binding element has no default value. +tests/cases/conformance/es6/destructuring/declarationsAndAssignments.ts(63,16): error TS2525: Initializer provides no value for this binding element and the binding element has no default value. tests/cases/conformance/es6/destructuring/declarationsAndAssignments.ts(67,9): error TS2461: Type '{ [x: number]: undefined; }' is not an array type. tests/cases/conformance/es6/destructuring/declarationsAndAssignments.ts(68,9): error TS2461: Type '{ [x: number]: number; 0: number; 1: number; }' is not an array type. -tests/cases/conformance/es6/destructuring/declarationsAndAssignments.ts(73,11): error TS2525: Initializer provides no value for this binding element and the binding element has no default value -tests/cases/conformance/es6/destructuring/declarationsAndAssignments.ts(73,14): error TS2525: Initializer provides no value for this binding element and the binding element has no default value +tests/cases/conformance/es6/destructuring/declarationsAndAssignments.ts(73,11): error TS2525: Initializer provides no value for this binding element and the binding element has no default value. +tests/cases/conformance/es6/destructuring/declarationsAndAssignments.ts(73,14): error TS2525: Initializer provides no value for this binding element and the binding element has no default value. tests/cases/conformance/es6/destructuring/declarationsAndAssignments.ts(74,11): error TS2459: Type 'undefined[]' has no property 'a' and no string index signature. tests/cases/conformance/es6/destructuring/declarationsAndAssignments.ts(74,14): error TS2459: Type 'undefined[]' has no property 'b' and no string index signature. tests/cases/conformance/es6/destructuring/declarationsAndAssignments.ts(106,5): error TS2345: Argument of type '[number, [string, { y: boolean; }]]' is not assignable to parameter of type '[number, [string, { x: any; y?: boolean; }]]'. @@ -34,7 +34,7 @@ tests/cases/conformance/es6/destructuring/declarationsAndAssignments.ts(138,9): var [x, y] = [1, "hello"]; var [x, y, z] = [1, "hello"]; ~ -!!! error TS2525: Initializer provides no value for this binding element and the binding element has no default value +!!! error TS2525: Initializer provides no value for this binding element and the binding element has no default value. var [,, x] = [0, 1, 2]; var x: number; var y: string; @@ -107,16 +107,16 @@ tests/cases/conformance/es6/destructuring/declarationsAndAssignments.ts(138,9): function f8() { var [a, b, c] = []; // Ok, [] is an array ~ -!!! error TS2525: Initializer provides no value for this binding element and the binding element has no default value +!!! error TS2525: Initializer provides no value for this binding element and the binding element has no default value. ~ -!!! error TS2525: Initializer provides no value for this binding element and the binding element has no default value +!!! error TS2525: Initializer provides no value for this binding element and the binding element has no default value. ~ -!!! error TS2525: Initializer provides no value for this binding element and the binding element has no default value +!!! error TS2525: Initializer provides no value for this binding element and the binding element has no default value. var [d, e, f] = [1]; // Error, [1] is a tuple ~ -!!! error TS2525: Initializer provides no value for this binding element and the binding element has no default value +!!! error TS2525: Initializer provides no value for this binding element and the binding element has no default value. ~ -!!! error TS2525: Initializer provides no value for this binding element and the binding element has no default value +!!! error TS2525: Initializer provides no value for this binding element and the binding element has no default value. } function f9() { @@ -132,9 +132,9 @@ tests/cases/conformance/es6/destructuring/declarationsAndAssignments.ts(138,9): function f10() { var { a, b } = {}; // Error ~ -!!! error TS2525: Initializer provides no value for this binding element and the binding element has no default value +!!! error TS2525: Initializer provides no value for this binding element and the binding element has no default value. ~ -!!! error TS2525: Initializer provides no value for this binding element and the binding element has no default value +!!! error TS2525: Initializer provides no value for this binding element and the binding element has no default value. var { a, b } = []; // Error ~ !!! error TS2459: Type 'undefined[]' has no property 'a' and no string index signature. diff --git a/tests/baselines/reference/destructuringArrayBindingPatternAndAssignment1ES5.errors.txt b/tests/baselines/reference/destructuringArrayBindingPatternAndAssignment1ES5.errors.txt index 5fd60c296c9..1f1bc85757b 100644 --- a/tests/baselines/reference/destructuringArrayBindingPatternAndAssignment1ES5.errors.txt +++ b/tests/baselines/reference/destructuringArrayBindingPatternAndAssignment1ES5.errors.txt @@ -1,6 +1,6 @@ -tests/cases/conformance/es6/destructuring/destructuringArrayBindingPatternAndAssignment1ES5.ts(43,6): error TS2525: Initializer provides no value for this binding element and the binding element has no default value -tests/cases/conformance/es6/destructuring/destructuringArrayBindingPatternAndAssignment1ES5.ts(44,8): error TS2525: Initializer provides no value for this binding element and the binding element has no default value -tests/cases/conformance/es6/destructuring/destructuringArrayBindingPatternAndAssignment1ES5.ts(44,18): error TS2525: Initializer provides no value for this binding element and the binding element has no default value +tests/cases/conformance/es6/destructuring/destructuringArrayBindingPatternAndAssignment1ES5.ts(43,6): error TS2525: Initializer provides no value for this binding element and the binding element has no default value. +tests/cases/conformance/es6/destructuring/destructuringArrayBindingPatternAndAssignment1ES5.ts(44,8): error TS2525: Initializer provides no value for this binding element and the binding element has no default value. +tests/cases/conformance/es6/destructuring/destructuringArrayBindingPatternAndAssignment1ES5.ts(44,18): error TS2525: Initializer provides no value for this binding element and the binding element has no default value. ==== tests/cases/conformance/es6/destructuring/destructuringArrayBindingPatternAndAssignment1ES5.ts (3 errors) ==== @@ -48,12 +48,12 @@ tests/cases/conformance/es6/destructuring/destructuringArrayBindingPatternAndAss var [c0, c1] = [...temp]; var [c2] = []; ~~ -!!! error TS2525: Initializer provides no value for this binding element and the binding element has no default value +!!! error TS2525: Initializer provides no value for this binding element and the binding element has no default value. var [[[c3]], [[[[c4]]]]] = [[[]], [[[[]]]]] ~~ -!!! error TS2525: Initializer provides no value for this binding element and the binding element has no default value +!!! error TS2525: Initializer provides no value for this binding element and the binding element has no default value. ~~ -!!! error TS2525: Initializer provides no value for this binding element and the binding element has no default value +!!! error TS2525: Initializer provides no value for this binding element and the binding element has no default value. var [[c5], c6]: [[string|number], boolean] = [[1], true]; var [, c7] = [1, 2, 3]; var [,,, c8] = [1, 2, 3, 4]; diff --git a/tests/baselines/reference/destructuringArrayBindingPatternAndAssignment1ES6.errors.txt b/tests/baselines/reference/destructuringArrayBindingPatternAndAssignment1ES6.errors.txt index a847cc44f0c..beefbc9a85b 100644 --- a/tests/baselines/reference/destructuringArrayBindingPatternAndAssignment1ES6.errors.txt +++ b/tests/baselines/reference/destructuringArrayBindingPatternAndAssignment1ES6.errors.txt @@ -1,6 +1,6 @@ -tests/cases/conformance/es6/destructuring/destructuringArrayBindingPatternAndAssignment1ES6.ts(44,6): error TS2525: Initializer provides no value for this binding element and the binding element has no default value -tests/cases/conformance/es6/destructuring/destructuringArrayBindingPatternAndAssignment1ES6.ts(45,8): error TS2525: Initializer provides no value for this binding element and the binding element has no default value -tests/cases/conformance/es6/destructuring/destructuringArrayBindingPatternAndAssignment1ES6.ts(45,18): error TS2525: Initializer provides no value for this binding element and the binding element has no default value +tests/cases/conformance/es6/destructuring/destructuringArrayBindingPatternAndAssignment1ES6.ts(44,6): error TS2525: Initializer provides no value for this binding element and the binding element has no default value. +tests/cases/conformance/es6/destructuring/destructuringArrayBindingPatternAndAssignment1ES6.ts(45,8): error TS2525: Initializer provides no value for this binding element and the binding element has no default value. +tests/cases/conformance/es6/destructuring/destructuringArrayBindingPatternAndAssignment1ES6.ts(45,18): error TS2525: Initializer provides no value for this binding element and the binding element has no default value. ==== tests/cases/conformance/es6/destructuring/destructuringArrayBindingPatternAndAssignment1ES6.ts (3 errors) ==== @@ -49,12 +49,12 @@ tests/cases/conformance/es6/destructuring/destructuringArrayBindingPatternAndAss var [c0, c1] = [...temp]; var [c2] = []; ~~ -!!! error TS2525: Initializer provides no value for this binding element and the binding element has no default value +!!! error TS2525: Initializer provides no value for this binding element and the binding element has no default value. var [[[c3]], [[[[c4]]]]] = [[[]], [[[[]]]]] ~~ -!!! error TS2525: Initializer provides no value for this binding element and the binding element has no default value +!!! error TS2525: Initializer provides no value for this binding element and the binding element has no default value. ~~ -!!! error TS2525: Initializer provides no value for this binding element and the binding element has no default value +!!! error TS2525: Initializer provides no value for this binding element and the binding element has no default value. var [[c5], c6]: [[string|number], boolean] = [[1], true]; var [, c7] = [1, 2, 3]; var [,,, c8] = [1, 2, 3, 4]; diff --git a/tests/baselines/reference/destructuringArrayBindingPatternAndAssignment2.errors.txt b/tests/baselines/reference/destructuringArrayBindingPatternAndAssignment2.errors.txt index 082bc7aa72a..91405285973 100644 --- a/tests/baselines/reference/destructuringArrayBindingPatternAndAssignment2.errors.txt +++ b/tests/baselines/reference/destructuringArrayBindingPatternAndAssignment2.errors.txt @@ -1,5 +1,5 @@ -tests/cases/conformance/es6/destructuring/destructuringArrayBindingPatternAndAssignment2.ts(3,6): error TS2525: Initializer provides no value for this binding element and the binding element has no default value -tests/cases/conformance/es6/destructuring/destructuringArrayBindingPatternAndAssignment2.ts(3,12): error TS2525: Initializer provides no value for this binding element and the binding element has no default value +tests/cases/conformance/es6/destructuring/destructuringArrayBindingPatternAndAssignment2.ts(3,6): error TS2525: Initializer provides no value for this binding element and the binding element has no default value. +tests/cases/conformance/es6/destructuring/destructuringArrayBindingPatternAndAssignment2.ts(3,12): error TS2525: Initializer provides no value for this binding element and the binding element has no default value. tests/cases/conformance/es6/destructuring/destructuringArrayBindingPatternAndAssignment2.ts(4,5): error TS2461: Type 'undefined' is not an array type. tests/cases/conformance/es6/destructuring/destructuringArrayBindingPatternAndAssignment2.ts(9,5): error TS2322: Type '[number, number, string]' is not assignable to type '[number, boolean, string]'. Types of property '1' are incompatible. @@ -18,9 +18,9 @@ tests/cases/conformance/es6/destructuring/destructuringArrayBindingPatternAndAss // S is the type Any, or var [[a0], [[a1]]] = [] // Error ~~~~ -!!! error TS2525: Initializer provides no value for this binding element and the binding element has no default value +!!! error TS2525: Initializer provides no value for this binding element and the binding element has no default value. ~~~~~~ -!!! error TS2525: Initializer provides no value for this binding element and the binding element has no default value +!!! error TS2525: Initializer provides no value for this binding element and the binding element has no default value. var [[a2], [[a3]]] = undefined // Error ~~~~~~~~~~~~~~ !!! error TS2461: Type 'undefined' is not an array type. diff --git a/tests/baselines/reference/destructuringObjectBindingPatternAndAssignment3.errors.txt b/tests/baselines/reference/destructuringObjectBindingPatternAndAssignment3.errors.txt index 709774fb9b4..bb4b79987e3 100644 --- a/tests/baselines/reference/destructuringObjectBindingPatternAndAssignment3.errors.txt +++ b/tests/baselines/reference/destructuringObjectBindingPatternAndAssignment3.errors.txt @@ -3,7 +3,7 @@ tests/cases/conformance/es6/destructuring/destructuringObjectBindingPatternAndAs Type '{ i: number; }' is not assignable to type 'number'. tests/cases/conformance/es6/destructuring/destructuringObjectBindingPatternAndAssignment3.ts(3,6): error TS2459: Type 'string | number' has no property 'i' and no string index signature. tests/cases/conformance/es6/destructuring/destructuringObjectBindingPatternAndAssignment3.ts(4,6): error TS2459: Type 'string | number | {}' has no property 'i1' and no string index signature. -tests/cases/conformance/es6/destructuring/destructuringObjectBindingPatternAndAssignment3.ts(5,12): error TS2525: Initializer provides no value for this binding element and the binding element has no default value +tests/cases/conformance/es6/destructuring/destructuringObjectBindingPatternAndAssignment3.ts(5,12): error TS2525: Initializer provides no value for this binding element and the binding element has no default value. tests/cases/conformance/es6/destructuring/destructuringObjectBindingPatternAndAssignment3.ts(5,21): error TS2353: Object literal may only specify known properties, and 'f212' does not exist in type '{ f21: any; }'. tests/cases/conformance/es6/destructuring/destructuringObjectBindingPatternAndAssignment3.ts(6,7): error TS1180: Property destructuring pattern expected. tests/cases/conformance/es6/destructuring/destructuringObjectBindingPatternAndAssignment3.ts(7,5): error TS2353: Object literal may only specify known properties, and 'a' does not exist in type '{ d1: any; }'. @@ -30,7 +30,7 @@ tests/cases/conformance/es6/destructuring/destructuringObjectBindingPatternAndAs !!! error TS2459: Type 'string | number | {}' has no property 'i1' and no string index signature. var { f2: {f21} = { f212: "string" } }: any = undefined; ~~~ -!!! error TS2525: Initializer provides no value for this binding element and the binding element has no default value +!!! error TS2525: Initializer provides no value for this binding element and the binding element has no default value. ~~~~ !!! error TS2353: Object literal may only specify known properties, and 'f212' does not exist in type '{ f21: any; }'. var { ...d1 } = { diff --git a/tests/baselines/reference/downlevelLetConst12.errors.txt b/tests/baselines/reference/downlevelLetConst12.errors.txt index f29d9435dbb..0af224b017e 100644 --- a/tests/baselines/reference/downlevelLetConst12.errors.txt +++ b/tests/baselines/reference/downlevelLetConst12.errors.txt @@ -1,5 +1,5 @@ -tests/cases/compiler/downlevelLetConst12.ts(7,6): error TS2525: Initializer provides no value for this binding element and the binding element has no default value -tests/cases/compiler/downlevelLetConst12.ts(10,8): error TS2525: Initializer provides no value for this binding element and the binding element has no default value +tests/cases/compiler/downlevelLetConst12.ts(7,6): error TS2525: Initializer provides no value for this binding element and the binding element has no default value. +tests/cases/compiler/downlevelLetConst12.ts(10,8): error TS2525: Initializer provides no value for this binding element and the binding element has no default value. ==== tests/cases/compiler/downlevelLetConst12.ts (2 errors) ==== @@ -11,10 +11,10 @@ tests/cases/compiler/downlevelLetConst12.ts(10,8): error TS2525: Initializer pro let [baz] = []; ~~~ -!!! error TS2525: Initializer provides no value for this binding element and the binding element has no default value +!!! error TS2525: Initializer provides no value for this binding element and the binding element has no default value. let {a: baz2} = { a: 1 }; const [baz3] = [] ~~~~ -!!! error TS2525: Initializer provides no value for this binding element and the binding element has no default value +!!! error TS2525: Initializer provides no value for this binding element and the binding element has no default value. const {a: baz4} = { a: 1 }; \ No newline at end of file diff --git a/tests/baselines/reference/downlevelLetConst16.errors.txt b/tests/baselines/reference/downlevelLetConst16.errors.txt index 43acc162d7a..905d1a607e8 100644 --- a/tests/baselines/reference/downlevelLetConst16.errors.txt +++ b/tests/baselines/reference/downlevelLetConst16.errors.txt @@ -1,5 +1,5 @@ -tests/cases/compiler/downlevelLetConst16.ts(151,15): error TS2525: Initializer provides no value for this binding element and the binding element has no default value -tests/cases/compiler/downlevelLetConst16.ts(164,17): error TS2525: Initializer provides no value for this binding element and the binding element has no default value +tests/cases/compiler/downlevelLetConst16.ts(151,15): error TS2525: Initializer provides no value for this binding element and the binding element has no default value. +tests/cases/compiler/downlevelLetConst16.ts(164,17): error TS2525: Initializer provides no value for this binding element and the binding element has no default value. tests/cases/compiler/downlevelLetConst16.ts(195,14): error TS2461: Type 'undefined' is not an array type. tests/cases/compiler/downlevelLetConst16.ts(202,15): error TS2459: Type 'undefined' has no property 'a' and no string index signature. tests/cases/compiler/downlevelLetConst16.ts(216,16): error TS2461: Type 'undefined' is not an array type. @@ -159,7 +159,7 @@ tests/cases/compiler/downlevelLetConst16.ts(223,17): error TS2459: Type 'undefin } for (let [y] = []; ;) { ~ -!!! error TS2525: Initializer provides no value for this binding element and the binding element has no default value +!!! error TS2525: Initializer provides no value for this binding element and the binding element has no default value. use(y); } for (let {a: z} = {a: 1}; ;) { @@ -174,7 +174,7 @@ tests/cases/compiler/downlevelLetConst16.ts(223,17): error TS2459: Type 'undefin } for (const [y] = []; ;) { ~ -!!! error TS2525: Initializer provides no value for this binding element and the binding element has no default value +!!! error TS2525: Initializer provides no value for this binding element and the binding element has no default value. use(y); } for (const {a: z} = { a: 1 }; ;) { diff --git a/tests/baselines/reference/missingAndExcessProperties.errors.txt b/tests/baselines/reference/missingAndExcessProperties.errors.txt index 6b015001829..0ee69d9af30 100644 --- a/tests/baselines/reference/missingAndExcessProperties.errors.txt +++ b/tests/baselines/reference/missingAndExcessProperties.errors.txt @@ -1,15 +1,15 @@ -tests/cases/conformance/es6/destructuring/missingAndExcessProperties.ts(3,11): error TS2525: Initializer provides no value for this binding element and the binding element has no default value -tests/cases/conformance/es6/destructuring/missingAndExcessProperties.ts(3,14): error TS2525: Initializer provides no value for this binding element and the binding element has no default value +tests/cases/conformance/es6/destructuring/missingAndExcessProperties.ts(3,11): error TS2525: Initializer provides no value for this binding element and the binding element has no default value. +tests/cases/conformance/es6/destructuring/missingAndExcessProperties.ts(3,14): error TS2525: Initializer provides no value for this binding element and the binding element has no default value. tests/cases/conformance/es6/destructuring/missingAndExcessProperties.ts(4,11): error TS2403: Subsequent variable declarations must have the same type. Variable 'x' must be of type 'any', but here has type 'number'. -tests/cases/conformance/es6/destructuring/missingAndExcessProperties.ts(4,18): error TS2525: Initializer provides no value for this binding element and the binding element has no default value -tests/cases/conformance/es6/destructuring/missingAndExcessProperties.ts(5,11): error TS2525: Initializer provides no value for this binding element and the binding element has no default value +tests/cases/conformance/es6/destructuring/missingAndExcessProperties.ts(4,18): error TS2525: Initializer provides no value for this binding element and the binding element has no default value. +tests/cases/conformance/es6/destructuring/missingAndExcessProperties.ts(5,11): error TS2525: Initializer provides no value for this binding element and the binding element has no default value. tests/cases/conformance/es6/destructuring/missingAndExcessProperties.ts(5,14): error TS2403: Subsequent variable declarations must have the same type. Variable 'y' must be of type 'any', but here has type 'number'. tests/cases/conformance/es6/destructuring/missingAndExcessProperties.ts(6,11): error TS2403: Subsequent variable declarations must have the same type. Variable 'x' must be of type 'any', but here has type 'number'. tests/cases/conformance/es6/destructuring/missingAndExcessProperties.ts(6,18): error TS2403: Subsequent variable declarations must have the same type. Variable 'y' must be of type 'any', but here has type 'number'. -tests/cases/conformance/es6/destructuring/missingAndExcessProperties.ts(12,8): error TS2525: Initializer provides no value for this binding element and the binding element has no default value -tests/cases/conformance/es6/destructuring/missingAndExcessProperties.ts(12,11): error TS2525: Initializer provides no value for this binding element and the binding element has no default value -tests/cases/conformance/es6/destructuring/missingAndExcessProperties.ts(13,18): error TS2525: Initializer provides no value for this binding element and the binding element has no default value -tests/cases/conformance/es6/destructuring/missingAndExcessProperties.ts(14,8): error TS2525: Initializer provides no value for this binding element and the binding element has no default value +tests/cases/conformance/es6/destructuring/missingAndExcessProperties.ts(12,8): error TS2525: Initializer provides no value for this binding element and the binding element has no default value. +tests/cases/conformance/es6/destructuring/missingAndExcessProperties.ts(12,11): error TS2525: Initializer provides no value for this binding element and the binding element has no default value. +tests/cases/conformance/es6/destructuring/missingAndExcessProperties.ts(13,18): error TS2525: Initializer provides no value for this binding element and the binding element has no default value. +tests/cases/conformance/es6/destructuring/missingAndExcessProperties.ts(14,8): error TS2525: Initializer provides no value for this binding element and the binding element has no default value. tests/cases/conformance/es6/destructuring/missingAndExcessProperties.ts(20,17): error TS2353: Object literal may only specify known properties, and 'x' does not exist in type '{}'. tests/cases/conformance/es6/destructuring/missingAndExcessProperties.ts(20,23): error TS2353: Object literal may only specify known properties, and 'y' does not exist in type '{}'. tests/cases/conformance/es6/destructuring/missingAndExcessProperties.ts(21,25): error TS2353: Object literal may only specify known properties, and 'y' does not exist in type '{ x: any; }'. @@ -25,17 +25,17 @@ tests/cases/conformance/es6/destructuring/missingAndExcessProperties.ts(31,16): function f1() { var { x, y } = {}; ~ -!!! error TS2525: Initializer provides no value for this binding element and the binding element has no default value +!!! error TS2525: Initializer provides no value for this binding element and the binding element has no default value. ~ -!!! error TS2525: Initializer provides no value for this binding element and the binding element has no default value +!!! error TS2525: Initializer provides no value for this binding element and the binding element has no default value. var { x = 1, y } = {}; ~ !!! error TS2403: Subsequent variable declarations must have the same type. Variable 'x' must be of type 'any', but here has type 'number'. ~ -!!! error TS2525: Initializer provides no value for this binding element and the binding element has no default value +!!! error TS2525: Initializer provides no value for this binding element and the binding element has no default value. var { x, y = 1 } = {}; ~ -!!! error TS2525: Initializer provides no value for this binding element and the binding element has no default value +!!! error TS2525: Initializer provides no value for this binding element and the binding element has no default value. ~ !!! error TS2403: Subsequent variable declarations must have the same type. Variable 'y' must be of type 'any', but here has type 'number'. var { x = 1, y = 1 } = {}; @@ -50,15 +50,15 @@ tests/cases/conformance/es6/destructuring/missingAndExcessProperties.ts(31,16): var x: number, y: number; ({ x, y } = {}); ~ -!!! error TS2525: Initializer provides no value for this binding element and the binding element has no default value +!!! error TS2525: Initializer provides no value for this binding element and the binding element has no default value. ~ -!!! error TS2525: Initializer provides no value for this binding element and the binding element has no default value +!!! error TS2525: Initializer provides no value for this binding element and the binding element has no default value. ({ x: x = 1, y } = {}); ~ -!!! error TS2525: Initializer provides no value for this binding element and the binding element has no default value +!!! error TS2525: Initializer provides no value for this binding element and the binding element has no default value. ({ x, y: y = 1 } = {}); ~ -!!! error TS2525: Initializer provides no value for this binding element and the binding element has no default value +!!! error TS2525: Initializer provides no value for this binding element and the binding element has no default value. ({ x: x = 1, y: y = 1 } = {}); } From c72469a66f6809e092c14b860286cccdefdd787c Mon Sep 17 00:00:00 2001 From: Vladimir Matveev Date: Fri, 11 Sep 2015 09:36:17 -0700 Subject: [PATCH 111/117] emit export specifiers in system modules only if export has a value side --- src/compiler/emitter.ts | 6 +- tests/baselines/reference/systemModule17.js | 84 ++++++++++++++++ .../reference/systemModule17.symbols | 93 ++++++++++++++++++ .../baselines/reference/systemModule17.types | 95 +++++++++++++++++++ tests/cases/compiler/systemModule17.ts | 41 ++++++++ 5 files changed, 318 insertions(+), 1 deletion(-) create mode 100644 tests/baselines/reference/systemModule17.js create mode 100644 tests/baselines/reference/systemModule17.symbols create mode 100644 tests/baselines/reference/systemModule17.types create mode 100644 tests/cases/compiler/systemModule17.ts diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index d84b7b70ada..d3a7615a27f 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -3142,6 +3142,10 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi function emitExportSpecifierInSystemModule(specifier: ExportSpecifier): void { Debug.assert(compilerOptions.module === ModuleKind.System); + + if (!resolver.getReferencedValueDeclaration(specifier.propertyName || specifier.name) && !resolver.isValueAliasDeclaration(specifier) ) { + return; + } writeLine(); emitStart(specifier.name); @@ -6089,7 +6093,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi return; } - if (isInternalModuleImportEqualsDeclaration(node)) { + if (isInternalModuleImportEqualsDeclaration(node) && resolver.isValueAliasDeclaration(node)) { if (!hoistedVars) { hoistedVars = []; } diff --git a/tests/baselines/reference/systemModule17.js b/tests/baselines/reference/systemModule17.js new file mode 100644 index 00000000000..90efdc8872a --- /dev/null +++ b/tests/baselines/reference/systemModule17.js @@ -0,0 +1,84 @@ +//// [tests/cases/compiler/systemModule17.ts] //// + +//// [f1.ts] + + +export class A {} +export interface I {} + +//// [f2.ts] + +var x = 1; +interface I { } + +namespace N { + export var x = 1; + export interface I { } +} + +import IX = N.x; +import II = N.I; +import { A, A as EA, I as EI } from "f1"; + +export {x}; +export {x as x1}; + +export {I}; +export {I as I1}; + +export {A}; +export {A as A1}; + +export {EA}; +export {EA as EA1}; + +export {EI }; +export {EI as EI1}; + +export {IX}; +export {IX as IX1}; + +export {II}; +export {II as II1}; + +//// [f1.js] +System.register([], function(exports_1) { + var A; + return { + setters:[], + execute: function() { + A = (function () { + function A() { + } + return A; + })(); + exports_1("A", A); + } + } +}); +//// [f2.js] +System.register(["f1"], function(exports_1) { + var f1_1; + var x, N, IX; + return { + setters:[ + function (f1_1_1) { + f1_1 = f1_1_1; + }], + execute: function() { + x = 1; + (function (N) { + N.x = 1; + })(N || (N = {})); + IX = N.x; + exports_1("x", x); + exports_1("x1", x); + exports_1("A", f1_1.A); + exports_1("A1", f1_1.A); + exports_1("EA", f1_1.A); + exports_1("EA1", f1_1.A); + exports_1("IX", IX); + exports_1("IX1", IX); + } + } +}); diff --git a/tests/baselines/reference/systemModule17.symbols b/tests/baselines/reference/systemModule17.symbols new file mode 100644 index 00000000000..3bf19dad950 --- /dev/null +++ b/tests/baselines/reference/systemModule17.symbols @@ -0,0 +1,93 @@ +=== tests/cases/compiler/f1.ts === + + +export class A {} +>A : Symbol(A, Decl(f1.ts, 0, 0)) + +export interface I {} +>I : Symbol(I, Decl(f1.ts, 2, 17)) + +=== tests/cases/compiler/f2.ts === + +var x = 1; +>x : Symbol(x, Decl(f2.ts, 1, 3)) + +interface I { } +>I : Symbol(I, Decl(f2.ts, 1, 10)) + +namespace N { +>N : Symbol(N, Decl(f2.ts, 2, 15)) + + export var x = 1; +>x : Symbol(x, Decl(f2.ts, 5, 11)) + + export interface I { } +>I : Symbol(I, Decl(f2.ts, 5, 18)) +} + +import IX = N.x; +>IX : Symbol(IX, Decl(f2.ts, 7, 1)) +>N : Symbol(N, Decl(f2.ts, 2, 15)) +>x : Symbol(IX, Decl(f2.ts, 5, 11)) + +import II = N.I; +>II : Symbol(II, Decl(f2.ts, 9, 16)) +>N : Symbol(N, Decl(f2.ts, 2, 15)) +>I : Symbol(II, Decl(f2.ts, 5, 18)) + +import { A, A as EA, I as EI } from "f1"; +>A : Symbol(A, Decl(f2.ts, 11, 8)) +>A : Symbol(EA, Decl(f2.ts, 11, 11)) +>EA : Symbol(EA, Decl(f2.ts, 11, 11)) +>I : Symbol(EI, Decl(f2.ts, 11, 20)) +>EI : Symbol(EI, Decl(f2.ts, 11, 20)) + +export {x}; +>x : Symbol(x, Decl(f2.ts, 13, 8)) + +export {x as x1}; +>x : Symbol(x1, Decl(f2.ts, 14, 8)) +>x1 : Symbol(x1, Decl(f2.ts, 14, 8)) + +export {I}; +>I : Symbol(I, Decl(f2.ts, 16, 8)) + +export {I as I1}; +>I : Symbol(I1, Decl(f2.ts, 17, 8)) +>I1 : Symbol(I1, Decl(f2.ts, 17, 8)) + +export {A}; +>A : Symbol(A, Decl(f2.ts, 19, 8)) + +export {A as A1}; +>A : Symbol(A1, Decl(f2.ts, 20, 8)) +>A1 : Symbol(A1, Decl(f2.ts, 20, 8)) + +export {EA}; +>EA : Symbol(EA, Decl(f2.ts, 22, 8)) + +export {EA as EA1}; +>EA : Symbol(EA1, Decl(f2.ts, 23, 8)) +>EA1 : Symbol(EA1, Decl(f2.ts, 23, 8)) + +export {EI }; +>EI : Symbol(EI, Decl(f2.ts, 25, 8)) + +export {EI as EI1}; +>EI : Symbol(EI1, Decl(f2.ts, 26, 8)) +>EI1 : Symbol(EI1, Decl(f2.ts, 26, 8)) + +export {IX}; +>IX : Symbol(IX, Decl(f2.ts, 28, 8)) + +export {IX as IX1}; +>IX : Symbol(IX1, Decl(f2.ts, 29, 8)) +>IX1 : Symbol(IX1, Decl(f2.ts, 29, 8)) + +export {II}; +>II : Symbol(II, Decl(f2.ts, 31, 8)) + +export {II as II1}; +>II : Symbol(II1, Decl(f2.ts, 32, 8)) +>II1 : Symbol(II1, Decl(f2.ts, 32, 8)) + diff --git a/tests/baselines/reference/systemModule17.types b/tests/baselines/reference/systemModule17.types new file mode 100644 index 00000000000..1f0b1b51842 --- /dev/null +++ b/tests/baselines/reference/systemModule17.types @@ -0,0 +1,95 @@ +=== tests/cases/compiler/f1.ts === + + +export class A {} +>A : A + +export interface I {} +>I : I + +=== tests/cases/compiler/f2.ts === + +var x = 1; +>x : number +>1 : number + +interface I { } +>I : I + +namespace N { +>N : typeof N + + export var x = 1; +>x : number +>1 : number + + export interface I { } +>I : I +} + +import IX = N.x; +>IX : number +>N : typeof N +>x : number + +import II = N.I; +>II : any +>N : typeof N +>I : II + +import { A, A as EA, I as EI } from "f1"; +>A : typeof A +>A : typeof A +>EA : typeof A +>I : any +>EI : any + +export {x}; +>x : number + +export {x as x1}; +>x : number +>x1 : number + +export {I}; +>I : any + +export {I as I1}; +>I : any +>I1 : any + +export {A}; +>A : typeof A + +export {A as A1}; +>A : typeof A +>A1 : typeof A + +export {EA}; +>EA : typeof A + +export {EA as EA1}; +>EA : typeof A +>EA1 : typeof A + +export {EI }; +>EI : any + +export {EI as EI1}; +>EI : any +>EI1 : any + +export {IX}; +>IX : number + +export {IX as IX1}; +>IX : number +>IX1 : number + +export {II}; +>II : any + +export {II as II1}; +>II : any +>II1 : any + diff --git a/tests/cases/compiler/systemModule17.ts b/tests/cases/compiler/systemModule17.ts new file mode 100644 index 00000000000..f6b6d6ea2f2 --- /dev/null +++ b/tests/cases/compiler/systemModule17.ts @@ -0,0 +1,41 @@ +// @module: system + +// @filename: f1.ts + +export class A {} +export interface I {} + +// @filename: f2.ts + +var x = 1; +interface I { } + +namespace N { + export var x = 1; + export interface I { } +} + +import IX = N.x; +import II = N.I; +import { A, A as EA, I as EI } from "f1"; + +export {x}; +export {x as x1}; + +export {I}; +export {I as I1}; + +export {A}; +export {A as A1}; + +export {EA}; +export {EA as EA1}; + +export {EI }; +export {EI as EI1}; + +export {IX}; +export {IX as IX1}; + +export {II}; +export {II as II1}; \ No newline at end of file From d37eaa8d701afad991fe0b7c8c1bafeb613a0aa4 Mon Sep 17 00:00:00 2001 From: Vladimir Matveev Date: Sat, 12 Sep 2015 12:46:18 -0700 Subject: [PATCH 112/117] update error message text --- src/compiler/diagnosticInformationMap.generated.ts | 1 + src/compiler/diagnosticMessages.json | 4 ++++ src/compiler/program.ts | 2 +- tests/baselines/reference/nodeResolution5.errors.txt | 4 ++-- tests/baselines/reference/nodeResolution7.errors.txt | 4 ++-- 5 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/compiler/diagnosticInformationMap.generated.ts b/src/compiler/diagnosticInformationMap.generated.ts index cf30e250d85..7d1d63e5a56 100644 --- a/src/compiler/diagnosticInformationMap.generated.ts +++ b/src/compiler/diagnosticInformationMap.generated.ts @@ -431,6 +431,7 @@ namespace ts { Non_abstract_class_expression_does_not_implement_inherited_abstract_member_0_from_class_1: { code: 2653, category: DiagnosticCategory.Error, key: "Non-abstract class expression does not implement inherited abstract member '{0}' from class '{1}'." }, Exported_external_package_typings_file_cannot_contain_tripleslash_references_Please_contact_the_package_author_to_update_the_package_definition: { code: 2654, category: DiagnosticCategory.Error, key: "Exported external package typings file cannot contain tripleslash references. Please contact the package author to update the package definition." }, Exported_external_package_typings_can_only_be_in_d_ts_files_Please_contact_the_package_author_to_update_the_package_definition: { code: 2655, category: DiagnosticCategory.Error, key: "Exported external package typings can only be in '.d.ts' files. Please contact the package author to update the package definition." }, + Exported_external_package_typings_file_0_is_not_a_module_Please_contact_the_package_author_to_update_the_package_definition: { code: 2656, category: DiagnosticCategory.Error, key: "Exported external package typings file '{0}' is not a module. Please contact the package author to update the package definition." }, Import_declaration_0_is_using_private_name_1: { code: 4000, category: DiagnosticCategory.Error, key: "Import declaration '{0}' is using private name '{1}'." }, Type_parameter_0_of_exported_class_has_or_is_using_private_name_1: { code: 4002, category: DiagnosticCategory.Error, key: "Type parameter '{0}' of exported class has or is using private name '{1}'." }, Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1: { code: 4004, category: DiagnosticCategory.Error, key: "Type parameter '{0}' of exported interface has or is using private name '{1}'." }, diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index 4720303df25..245be4a3c9b 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -1713,6 +1713,10 @@ "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 diff --git a/src/compiler/program.ts b/src/compiler/program.ts index 28dd477666b..1ac4151e834 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -863,7 +863,7 @@ namespace ts { if (importedFile && resolution.isExternalLibraryImport) { if (!isExternalModule(importedFile)) { let start = getTokenPosOfNode(file.imports[i], file) - fileProcessingDiagnostics.add(createFileDiagnostic(file, start, file.imports[i].end - start, Diagnostics.File_0_is_not_a_module, importedFile.fileName)); + fileProcessingDiagnostics.add(createFileDiagnostic(file, start, file.imports[i].end - start, Diagnostics.Exported_external_package_typings_file_0_is_not_a_module_Please_contact_the_package_author_to_update_the_package_definition, importedFile.fileName)); } else if (!fileExtensionIs(importedFile.fileName, ".d.ts")) { let start = getTokenPosOfNode(file.imports[i], file) diff --git a/tests/baselines/reference/nodeResolution5.errors.txt b/tests/baselines/reference/nodeResolution5.errors.txt index 1fc4e1cee52..c36cce45b6d 100644 --- a/tests/baselines/reference/nodeResolution5.errors.txt +++ b/tests/baselines/reference/nodeResolution5.errors.txt @@ -1,10 +1,10 @@ -tests/cases/compiler/b.ts(1,20): error TS2306: File 'tests/cases/compiler/node_modules/a.d.ts' is not a module. +tests/cases/compiler/b.ts(1,20): error TS2656: Exported external package typings file 'tests/cases/compiler/node_modules/a.d.ts' is not a module. Please contact the package author to update the package definition. ==== tests/cases/compiler/b.ts (1 errors) ==== import y = require("a"); ~~~ -!!! error TS2306: File 'a.d.ts' is not a module. +!!! error TS2656: Exported external package typings file 'a.d.ts' is not a module. Please contact the package author to update the package definition. ==== tests/cases/compiler/node_modules/a.d.ts (0 errors) ==== diff --git a/tests/baselines/reference/nodeResolution7.errors.txt b/tests/baselines/reference/nodeResolution7.errors.txt index 1e1f822f0d4..f9e8ef7ac0f 100644 --- a/tests/baselines/reference/nodeResolution7.errors.txt +++ b/tests/baselines/reference/nodeResolution7.errors.txt @@ -1,10 +1,10 @@ -tests/cases/compiler/b.ts(1,20): error TS2306: File 'tests/cases/compiler/node_modules/a/index.d.ts' is not a module. +tests/cases/compiler/b.ts(1,20): error TS2656: Exported external package typings file 'tests/cases/compiler/node_modules/a/index.d.ts' is not a module. Please contact the package author to update the package definition. ==== tests/cases/compiler/b.ts (1 errors) ==== import y = require("a"); ~~~ -!!! error TS2306: File 'index.d.ts' is not a module. +!!! error TS2656: Exported external package typings file 'index.d.ts' is not a module. Please contact the package author to update the package definition. ==== tests/cases/compiler/node_modules/a/index.d.ts (0 errors) ==== From 5636655cf4229c84c82ee401cf65774c8c34d989 Mon Sep 17 00:00:00 2001 From: Vladimir Matveev Date: Mon, 14 Sep 2015 14:33:35 -0700 Subject: [PATCH 113/117] report error if module name is empty --- src/compiler/checker.ts | 2 +- .../reference/emptyModuleName.errors.txt | 9 +++++++++ tests/baselines/reference/emptyModuleName.js | 19 +++++++++++++++++++ tests/cases/compiler/emptyModuleName.ts | 4 ++++ 4 files changed, 33 insertions(+), 1 deletion(-) create mode 100644 tests/baselines/reference/emptyModuleName.errors.txt create mode 100644 tests/baselines/reference/emptyModuleName.js create mode 100644 tests/cases/compiler/emptyModuleName.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index f2d1f070b2d..13eb00f5af7 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -965,7 +965,7 @@ namespace ts { // Escape the name in the "require(...)" clause to ensure we find the right symbol. let moduleName = escapeIdentifier(moduleReferenceLiteral.text); - if (!moduleName) { + if (moduleName === undefined) { return; } let isRelative = isExternalModuleNameRelative(moduleName); diff --git a/tests/baselines/reference/emptyModuleName.errors.txt b/tests/baselines/reference/emptyModuleName.errors.txt new file mode 100644 index 00000000000..16f04b247ea --- /dev/null +++ b/tests/baselines/reference/emptyModuleName.errors.txt @@ -0,0 +1,9 @@ +tests/cases/compiler/emptyModuleName.ts(1,20): error TS2307: Cannot find module ''. + + +==== tests/cases/compiler/emptyModuleName.ts (1 errors) ==== + import * as A from ""; + ~~ +!!! error TS2307: Cannot find module ''. + class B extends A { + } \ No newline at end of file diff --git a/tests/baselines/reference/emptyModuleName.js b/tests/baselines/reference/emptyModuleName.js new file mode 100644 index 00000000000..bb870f717c1 --- /dev/null +++ b/tests/baselines/reference/emptyModuleName.js @@ -0,0 +1,19 @@ +//// [emptyModuleName.ts] +import * as A from ""; +class B extends A { +} + +//// [emptyModuleName.js] +var __extends = (this && this.__extends) || function (d, b) { + for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); +}; +var A = require(""); +var B = (function (_super) { + __extends(B, _super); + function B() { + _super.apply(this, arguments); + } + return B; +})(A); diff --git a/tests/cases/compiler/emptyModuleName.ts b/tests/cases/compiler/emptyModuleName.ts new file mode 100644 index 00000000000..d82ff2ba608 --- /dev/null +++ b/tests/cases/compiler/emptyModuleName.ts @@ -0,0 +1,4 @@ +// @module: commonjs +import * as A from ""; +class B extends A { +} \ No newline at end of file From c63dfbd4c7c0905b016e9b317ca2bb150ea24136 Mon Sep 17 00:00:00 2001 From: Mohamed Hegazy Date: Tue, 15 Sep 2015 11:43:28 -0700 Subject: [PATCH 114/117] Update node resolution tests --- .../aliasUsageInFunctionExpression.symbols | 16 ++--- .../aliasUsageInFunctionExpression.types | 6 +- .../reference/aliasUsageInGenericFunction.js | 10 ++-- .../aliasUsageInGenericFunction.symbols | 18 +++--- .../aliasUsageInGenericFunction.types | 6 +- .../reference/aliasUsageInIndexerOfClass.js | 10 ++-- .../aliasUsageInIndexerOfClass.symbols | 20 +++---- .../aliasUsageInIndexerOfClass.types | 6 +- .../reference/aliasUsageInObjectLiteral.js | 10 ++-- .../aliasUsageInObjectLiteral.symbols | 24 ++++---- .../reference/aliasUsageInObjectLiteral.types | 6 +- .../reference/aliasUsageInOrExpression.js | 10 ++-- .../aliasUsageInOrExpression.symbols | 36 +++++------ .../reference/aliasUsageInOrExpression.types | 6 +- ...aliasUsageInTypeArgumentOfExtendsClause.js | 10 ++-- ...UsageInTypeArgumentOfExtendsClause.symbols | 18 +++--- ...asUsageInTypeArgumentOfExtendsClause.types | 6 +- .../reference/aliasUsageInVarAssignment.js | 8 +-- .../aliasUsageInVarAssignment.symbols | 16 ++--- .../reference/aliasUsageInVarAssignment.types | 6 +- .../reference/aliasUsedAsNameValue.js | 8 +-- .../reference/aliasUsedAsNameValue.symbols | 8 +-- .../reference/aliasUsedAsNameValue.types | 4 +- ...tAssignmentUsedInVarInitializer.errors.txt | 2 +- ...aceExportAssignmentUsedInVarInitializer.js | 2 +- .../reference/arrayOfExportedClass.js | 2 +- .../reference/arrayOfExportedClass.symbols | 8 +-- .../reference/arrayOfExportedClass.types | 2 +- .../baselines/reference/chainedImportAlias.js | 4 +- .../reference/chainedImportAlias.symbols | 6 +- .../reference/chainedImportAlias.types | 2 +- .../reference/commentsExternalModules3.js | 6 +- .../commentsExternalModules3.symbols | 2 +- .../reference/commentsExternalModules3.types | 2 +- .../declFileAliasUseBeforeDeclaration.js | 4 +- .../declFileAliasUseBeforeDeclaration.symbols | 2 +- .../declFileAliasUseBeforeDeclaration.types | 2 +- .../reference/declFileForExportedImport.js | 6 +- .../declFileForExportedImport.symbols | 2 +- .../reference/declFileForExportedImport.types | 2 +- ...eclFileImportModuleWithExportAssignment.js | 6 +- ...leImportModuleWithExportAssignment.symbols | 2 +- ...FileImportModuleWithExportAssignment.types | 2 +- .../declarationEmit_exportAssignment.js | 6 +- .../declarationEmit_exportAssignment.symbols | 2 +- .../declarationEmit_exportAssignment.types | 2 +- .../declarationEmit_exportDeclaration.js | 6 +- .../declarationEmit_exportDeclaration.symbols | 2 +- .../declarationEmit_exportDeclaration.types | 2 +- .../declarationEmit_nameConflicts.js | 6 +- .../declarationEmit_nameConflicts.symbols | 30 +++++----- .../declarationEmit_nameConflicts.types | 2 +- .../defaultExportsCannotMerge01.errors.txt | 19 ++---- .../defaultExportsCannotMerge02.errors.txt | 19 ++---- .../defaultExportsCannotMerge03.errors.txt | 19 ++---- .../baselines/reference/elidingImportNames.js | 8 +-- .../reference/elidingImportNames.symbols | 4 +- .../reference/elidingImportNames.types | 4 +- .../reference/enumFromExternalModule.js | 4 +- .../reference/enumFromExternalModule.symbols | 2 +- .../reference/enumFromExternalModule.types | 2 +- .../errorsOnImportedSymbol.errors.txt | 2 +- .../reference/errorsOnImportedSymbol.js | 2 +- .../baselines/reference/es6ExportAllInEs5.js | 6 +- .../reference/es6ExportAllInEs5.symbols | 2 +- .../reference/es6ExportAllInEs5.types | 2 +- ...ExportClauseWithoutModuleSpecifierInEs5.js | 28 ++++----- ...tClauseWithoutModuleSpecifierInEs5.symbols | 10 ++-- ...ortClauseWithoutModuleSpecifierInEs5.types | 10 ++-- .../reference/es6ImportDefaultBindingDts.js | 8 +-- .../es6ImportDefaultBindingDts.symbols | 4 +- .../es6ImportDefaultBindingDts.types | 4 +- ...tBindingFollowedWithNamedImport.errors.txt | 12 ++-- ...rtDefaultBindingFollowedWithNamedImport.js | 22 +++---- ...ngFollowedWithNamedImport1InEs5.errors.txt | 12 ++-- ...ultBindingFollowedWithNamedImport1InEs5.js | 24 ++++---- ...lowedWithNamedImport1WithExport.errors.txt | 12 ++-- ...ndingFollowedWithNamedImport1WithExport.js | 24 ++++---- ...ndingFollowedWithNamedImportDts.errors.txt | 12 ++-- ...efaultBindingFollowedWithNamedImportDts.js | 32 +++++----- ...dingFollowedWithNamedImportDts1.errors.txt | 12 ++-- ...faultBindingFollowedWithNamedImportDts1.js | 26 ++++---- ...ingFollowedWithNamedImportInEs5.errors.txt | 12 ++-- ...aultBindingFollowedWithNamedImportInEs5.js | 22 +++---- ...ndingFollowedWithNamespaceBinding1InEs5.js | 4 +- ...FollowedWithNamespaceBinding1InEs5.symbols | 2 +- ...ngFollowedWithNamespaceBinding1InEs5.types | 2 +- ...FollowedWithNamespaceBindingDts.errors.txt | 2 +- ...tBindingFollowedWithNamespaceBindingDts.js | 6 +- ...llowedWithNamespaceBindingInEs5.errors.txt | 2 +- ...indingFollowedWithNamespaceBindingInEs5.js | 4 +- ...dWithNamespaceBindingWithExport.errors.txt | 2 +- ...gFollowedWithNamespaceBindingWithExport.js | 4 +- .../es6ImportDefaultBindingInEs5.errors.txt | 2 +- .../reference/es6ImportDefaultBindingInEs5.js | 2 +- ...ImportDefaultBindingMergeErrors.errors.txt | 8 +-- .../es6ImportDefaultBindingMergeErrors.js | 10 ++-- ...DefaultBindingNoDefaultProperty.errors.txt | 2 +- ...s6ImportDefaultBindingNoDefaultProperty.js | 2 +- .../es6ImportNameSpaceImport.errors.txt | 4 +- .../reference/es6ImportNameSpaceImport.js | 6 +- .../reference/es6ImportNameSpaceImportDts.js | 8 +-- .../es6ImportNameSpaceImportDts.symbols | 4 +- .../es6ImportNameSpaceImportDts.types | 4 +- .../es6ImportNameSpaceImportInEs5.js | 6 +- .../es6ImportNameSpaceImportInEs5.symbols | 4 +- .../es6ImportNameSpaceImportInEs5.types | 4 +- ...mportNameSpaceImportMergeErrors.errors.txt | 8 +-- .../es6ImportNameSpaceImportMergeErrors.js | 8 +-- .../es6ImportNameSpaceImportNoNamedExports.js | 2 +- ...mportNameSpaceImportNoNamedExports.symbols | 2 +- ...6ImportNameSpaceImportNoNamedExports.types | 2 +- .../reference/es6ImportNamedImport.errors.txt | 24 ++++---- .../reference/es6ImportNamedImport.js | 42 ++++++------- .../reference/es6ImportNamedImportDts.js | 60 +++++++++---------- .../reference/es6ImportNamedImportDts.symbols | 24 ++++---- .../reference/es6ImportNamedImportDts.types | 24 ++++---- .../reference/es6ImportNamedImportInEs5.js | 42 ++++++------- .../es6ImportNamedImportInEs5.symbols | 24 ++++---- .../reference/es6ImportNamedImportInEs5.types | 24 ++++---- ...rtNamedImportInExportAssignment.errors.txt | 2 +- .../es6ImportNamedImportInExportAssignment.js | 6 +- ...rtNamedImportInIndirectExportAssignment.js | 6 +- ...edImportInIndirectExportAssignment.symbols | 6 +- ...amedImportInIndirectExportAssignment.types | 2 +- ...es6ImportNamedImportMergeErrors.errors.txt | 12 ++-- .../es6ImportNamedImportMergeErrors.js | 12 ++-- ...ImportNamedImportNoExportMember.errors.txt | 4 +- .../es6ImportNamedImportNoExportMember.js | 4 +- ...ImportNamedImportNoNamedExports.errors.txt | 4 +- .../es6ImportNamedImportNoNamedExports.js | 4 +- .../es6ImportNamedImportWithExport.errors.txt | 24 ++++---- .../es6ImportNamedImportWithExport.js | 42 ++++++------- .../es6ImportNamedImportWithTypesAndValues.js | 6 +- ...mportNamedImportWithTypesAndValues.symbols | 4 +- ...6ImportNamedImportWithTypesAndValues.types | 2 +- .../reference/exportAssignClassAndModule.js | 2 +- .../exportAssignClassAndModule.symbols | 2 +- .../exportAssignClassAndModule.types | 2 +- .../reference/exportAssignmentEnum.js | 4 +- .../reference/exportAssignmentEnum.symbols | 2 +- .../reference/exportAssignmentEnum.types | 2 +- ...ignmentOfDeclaredExternalModule.errors.txt | 2 +- ...xportAssignmentOfDeclaredExternalModule.js | 2 +- .../reference/exportAssignmentVariable.js | 4 +- .../exportAssignmentVariable.symbols | 2 +- .../reference/exportAssignmentVariable.types | 2 +- .../exportEqualMemberMissing.errors.txt | 2 +- .../reference/exportEqualMemberMissing.js | 4 +- .../exportStarFromEmptyModule.errors.txt | 8 +-- .../reference/exportStarFromEmptyModule.js | 16 ++--- ...xtendingClassFromAliasAndUsageInIndexer.js | 18 +++--- ...ingClassFromAliasAndUsageInIndexer.symbols | 30 +++++----- ...ndingClassFromAliasAndUsageInIndexer.types | 10 ++-- ...rnalModuleExportingGenericClass.errors.txt | 2 +- .../externalModuleExportingGenericClass.js | 4 +- ...externalModuleImmutableBindings.errors.txt | 2 +- .../externalModuleImmutableBindings.js | 4 +- .../reference/importAsBaseClass.errors.txt | 2 +- .../baselines/reference/importAsBaseClass.js | 4 +- tests/baselines/reference/importDecl.js | 34 +++++------ tests/baselines/reference/importDecl.symbols | 22 +++---- tests/baselines/reference/importDecl.types | 14 ++--- .../importDeclarationUsedAsTypeQuery.js | 4 +- .../importDeclarationUsedAsTypeQuery.symbols | 2 +- .../importDeclarationUsedAsTypeQuery.types | 2 +- .../reference/importUsedInExtendsList1.js | 4 +- .../importUsedInExtendsList1.symbols | 6 +- .../reference/importUsedInExtendsList1.types | 2 +- .../reference/localAliasExportAssignment.js | 4 +- .../localAliasExportAssignment.symbols | 2 +- .../localAliasExportAssignment.types | 2 +- .../moduleInTypePosition1.errors.txt | 2 +- .../reference/moduleInTypePosition1.js | 2 +- .../baselines/reference/multiImportExport.js | 12 ++-- .../reference/multiImportExport.symbols | 4 +- .../reference/multiImportExport.types | 4 +- .../multipleDefaultExports01.errors.txt | 2 +- .../reference/multipleDefaultExports01.js | 4 +- .../multipleDefaultExports02.errors.txt | 2 +- .../reference/multipleDefaultExports02.js | 4 +- ...ivacyCannotNameAccessorDeclFile.errors.txt | 4 +- .../privacyCannotNameAccessorDeclFile.js | 10 ++-- ...rivacyCannotNameVarTypeDeclFile.errors.txt | 4 +- .../privacyCannotNameVarTypeDeclFile.js | 10 ++-- ...nalModuleExportAssignmentOfGenericClass.js | 4 +- ...duleExportAssignmentOfGenericClass.symbols | 2 +- ...ModuleExportAssignmentOfGenericClass.types | 2 +- ...CannotNameParameterTypeDeclFile.errors.txt | 4 +- ...FunctionCannotNameParameterTypeDeclFile.js | 10 ++-- ...ionCannotNameReturnTypeDeclFile.errors.txt | 4 +- ...acyFunctionCannotNameReturnTypeDeclFile.js | 10 ++-- ...elAmbientExternalModuleImportWithExport.js | 12 ++-- ...ientExternalModuleImportWithExport.symbols | 20 +++---- ...mbientExternalModuleImportWithExport.types | 4 +- .../requireOfAnEmptyFile1.errors.txt | 4 +- .../reference/requireOfAnEmptyFile1.js | 2 +- .../reference/reuseInnerModuleMember.js | 2 +- .../reference/reuseInnerModuleMember.symbols | 6 +- .../reference/reuseInnerModuleMember.types | 2 +- .../reference/staticInstanceResolution3.js | 4 +- .../staticInstanceResolution3.symbols | 2 +- .../reference/staticInstanceResolution3.types | 2 +- .../baselines/reference/topLevelFileModule.js | 8 +-- .../reference/topLevelFileModule.symbols | 8 +-- .../reference/topLevelFileModule.types | 4 +- ...pressionWithUndefinedCallResolutionData.js | 4 +- ...ionWithUndefinedCallResolutionData.symbols | 2 +- ...ssionWithUndefinedCallResolutionData.types | 2 +- .../typeofAmbientExternalModules.errors.txt | 4 +- .../reference/typeofAmbientExternalModules.js | 8 +-- .../typeofExternalModules.errors.txt | 4 +- .../reference/typeofExternalModules.js | 8 +-- .../reference/unusedImportDeclaration.js | 2 +- .../reference/unusedImportDeclaration.symbols | 2 +- .../reference/unusedImportDeclaration.types | 2 +- .../visibilityOfCrossModuleTypeUsage.js | 6 +- .../visibilityOfCrossModuleTypeUsage.symbols | 18 +++--- .../visibilityOfCrossModuleTypeUsage.types | 6 +- .../voidAsNonAmbiguousReturnType.errors.txt | 2 +- .../reference/voidAsNonAmbiguousReturnType.js | 4 +- tests/cases/compiler/aliasAssignments.ts | 2 +- .../compiler/aliasUsageInAccessorsOfClass.ts | 8 +-- tests/cases/compiler/aliasUsageInArray.ts | 6 +- .../aliasUsageInFunctionExpression.ts | 8 +-- .../compiler/aliasUsageInGenericFunction.ts | 8 +-- .../compiler/aliasUsageInIndexerOfClass.ts | 8 +-- .../compiler/aliasUsageInObjectLiteral.ts | 8 +-- .../compiler/aliasUsageInOrExpression.ts | 8 +-- ...aliasUsageInTypeArgumentOfExtendsClause.ts | 8 +-- .../compiler/aliasUsageInVarAssignment.ts | 8 +-- tests/cases/compiler/aliasUsedAsNameValue.ts | 6 +- ...aceExportAssignmentUsedInVarInitializer.ts | 4 +- tests/cases/compiler/arrayOfExportedClass.ts | 4 +- tests/cases/compiler/chainedImportAlias.ts | 4 +- .../compiler/commentsExternalModules3.ts | 2 +- .../declFileAliasUseBeforeDeclaration.ts | 6 +- .../compiler/declFileForExportedImport.ts | 2 +- ...eclFileImportModuleWithExportAssignment.ts | 4 +- .../declarationEmit_exportAssignment.ts | 2 +- .../declarationEmit_exportDeclaration.ts | 2 +- .../compiler/declarationEmit_nameConflicts.ts | 2 +- tests/cases/compiler/elidingImportNames.ts | 4 +- .../cases/compiler/enumFromExternalModule.ts | 4 +- .../cases/compiler/errorsOnImportedSymbol.ts | 6 +- tests/cases/compiler/es6ExportAllInEs5.ts | 2 +- ...ExportClauseWithoutModuleSpecifierInEs5.ts | 10 ++-- .../compiler/es6ImportDefaultBindingDts.ts | 4 +- ...rtDefaultBindingFollowedWithNamedImport.ts | 12 ++-- ...ultBindingFollowedWithNamedImport1InEs5.ts | 12 ++-- ...ndingFollowedWithNamedImport1WithExport.ts | 12 ++-- ...efaultBindingFollowedWithNamedImportDts.ts | 12 ++-- ...faultBindingFollowedWithNamedImportDts1.ts | 12 ++-- ...aultBindingFollowedWithNamedImportInEs5.ts | 12 ++-- ...ndingFollowedWithNamespaceBinding1InEs5.ts | 2 +- ...tBindingFollowedWithNamespaceBindingDts.ts | 2 +- ...indingFollowedWithNamespaceBindingInEs5.ts | 2 +- ...gFollowedWithNamespaceBindingWithExport.ts | 2 +- .../compiler/es6ImportDefaultBindingInEs5.ts | 2 +- .../es6ImportDefaultBindingMergeErrors.ts | 8 +-- ...s6ImportDefaultBindingNoDefaultProperty.ts | 2 +- .../compiler/es6ImportNameSpaceImport.ts | 4 +- .../compiler/es6ImportNameSpaceImportDts.ts | 4 +- .../compiler/es6ImportNameSpaceImportInEs5.ts | 4 +- .../es6ImportNameSpaceImportMergeErrors.ts | 8 +-- .../es6ImportNameSpaceImportNoNamedExports.ts | 2 +- tests/cases/compiler/es6ImportNamedImport.ts | 24 ++++---- .../cases/compiler/es6ImportNamedImportDts.ts | 24 ++++---- .../compiler/es6ImportNamedImportInEs5.ts | 24 ++++---- .../es6ImportNamedImportInExportAssignment.ts | 2 +- ...rtNamedImportInIndirectExportAssignment.ts | 2 +- .../es6ImportNamedImportMergeErrors.ts | 12 ++-- .../es6ImportNamedImportNoExportMember.ts | 4 +- .../es6ImportNamedImportNoNamedExports.ts | 4 +- .../es6ImportNamedImportWithExport.ts | 24 ++++---- .../es6ImportNamedImportWithTypesAndValues.ts | 2 +- .../compiler/exportAssignClassAndModule.ts | 4 +- tests/cases/compiler/exportAssignmentEnum.ts | 4 +- ...xportAssignmentOfDeclaredExternalModule.ts | 4 +- .../compiler/exportAssignmentVariable.ts | 4 +- .../compiler/exportEqualMemberMissing.ts | 4 +- .../compiler/exportStarFromEmptyModule.ts | 6 +- ...xtendingClassFromAliasAndUsageInIndexer.ts | 12 ++-- .../externalModuleExportingGenericClass.ts | 2 +- .../externalModuleImmutableBindings.ts | 2 +- ...ernceResolutionOrderInImportDeclaration.ts | 4 +- tests/cases/compiler/importAsBaseClass.ts | 4 +- tests/cases/compiler/importDecl.ts | 16 ++--- .../importDeclarationUsedAsTypeQuery.ts | 4 +- .../compiler/importUsedInExtendsList1.ts | 4 +- .../compiler/localAliasExportAssignment.ts | 4 +- tests/cases/compiler/moduleInTypePosition1.ts | 4 +- tests/cases/compiler/multiImportExport.ts | 4 +- .../privacyCannotNameAccessorDeclFile.ts | 4 +- .../privacyCannotNameVarTypeDeclFile.ts | 4 +- ...nalModuleExportAssignmentOfGenericClass.ts | 6 +- ...FunctionCannotNameParameterTypeDeclFile.ts | 4 +- ...acyFunctionCannotNameReturnTypeDeclFile.ts | 4 +- ...elAmbientExternalModuleImportWithExport.ts | 8 +-- tests/cases/compiler/requireOfAnEmptyFile1.ts | 4 +- .../cases/compiler/reuseInnerModuleMember.ts | 4 +- .../compiler/staticInstanceResolution3.ts | 4 +- ...pressionWithUndefinedCallResolutionData.ts | 4 +- .../compiler/typeofAmbientExternalModules.ts | 6 +- tests/cases/compiler/typeofExternalModules.ts | 6 +- .../cases/compiler/unusedImportDeclaration.ts | 6 +- .../visibilityOfCrossModuleTypeUsage.ts | 8 +-- .../compiler/voidAsNonAmbiguousReturnType.ts | 4 +- .../es6/modules/multipleDefaultExports01.ts | 2 +- .../es6/modules/multipleDefaultExports02.ts | 2 +- .../externalModules/topLevelFileModule.ts | 4 +- .../topLevelModuleDeclarationAndFile.ts | 2 +- 312 files changed, 1149 insertions(+), 1176 deletions(-) diff --git a/tests/baselines/reference/aliasUsageInFunctionExpression.symbols b/tests/baselines/reference/aliasUsageInFunctionExpression.symbols index 2afb6be55c5..bd791d4d38f 100644 --- a/tests/baselines/reference/aliasUsageInFunctionExpression.symbols +++ b/tests/baselines/reference/aliasUsageInFunctionExpression.symbols @@ -1,12 +1,12 @@ === tests/cases/compiler/aliasUsageInFunctionExpression_main.ts === -import Backbone = require("aliasUsageInFunctionExpression_backbone"); +import Backbone = require("./aliasUsageInFunctionExpression_backbone"); >Backbone : Symbol(Backbone, Decl(aliasUsageInFunctionExpression_main.ts, 0, 0)) -import moduleA = require("aliasUsageInFunctionExpression_moduleA"); ->moduleA : Symbol(moduleA, Decl(aliasUsageInFunctionExpression_main.ts, 0, 69)) +import moduleA = require("./aliasUsageInFunctionExpression_moduleA"); +>moduleA : Symbol(moduleA, Decl(aliasUsageInFunctionExpression_main.ts, 0, 71)) interface IHasVisualizationModel { ->IHasVisualizationModel : Symbol(IHasVisualizationModel, Decl(aliasUsageInFunctionExpression_main.ts, 1, 67)) +>IHasVisualizationModel : Symbol(IHasVisualizationModel, Decl(aliasUsageInFunctionExpression_main.ts, 1, 69)) VisualizationModel: typeof Backbone.Model; >VisualizationModel : Symbol(VisualizationModel, Decl(aliasUsageInFunctionExpression_main.ts, 2, 34)) @@ -17,13 +17,13 @@ interface IHasVisualizationModel { var f = (x: IHasVisualizationModel) => x; >f : Symbol(f, Decl(aliasUsageInFunctionExpression_main.ts, 5, 3)) >x : Symbol(x, Decl(aliasUsageInFunctionExpression_main.ts, 5, 9)) ->IHasVisualizationModel : Symbol(IHasVisualizationModel, Decl(aliasUsageInFunctionExpression_main.ts, 1, 67)) +>IHasVisualizationModel : Symbol(IHasVisualizationModel, Decl(aliasUsageInFunctionExpression_main.ts, 1, 69)) >x : Symbol(x, Decl(aliasUsageInFunctionExpression_main.ts, 5, 9)) f = (x) => moduleA; >f : Symbol(f, Decl(aliasUsageInFunctionExpression_main.ts, 5, 3)) >x : Symbol(x, Decl(aliasUsageInFunctionExpression_main.ts, 6, 5)) ->moduleA : Symbol(moduleA, Decl(aliasUsageInFunctionExpression_main.ts, 0, 69)) +>moduleA : Symbol(moduleA, Decl(aliasUsageInFunctionExpression_main.ts, 0, 71)) === tests/cases/compiler/aliasUsageInFunctionExpression_backbone.ts === export class Model { @@ -34,11 +34,11 @@ export class Model { } === tests/cases/compiler/aliasUsageInFunctionExpression_moduleA.ts === -import Backbone = require("aliasUsageInFunctionExpression_backbone"); +import Backbone = require("./aliasUsageInFunctionExpression_backbone"); >Backbone : Symbol(Backbone, Decl(aliasUsageInFunctionExpression_moduleA.ts, 0, 0)) export class VisualizationModel extends Backbone.Model { ->VisualizationModel : Symbol(VisualizationModel, Decl(aliasUsageInFunctionExpression_moduleA.ts, 0, 69)) +>VisualizationModel : Symbol(VisualizationModel, Decl(aliasUsageInFunctionExpression_moduleA.ts, 0, 71)) >Backbone.Model : Symbol(Backbone.Model, Decl(aliasUsageInFunctionExpression_backbone.ts, 0, 0)) >Backbone : Symbol(Backbone, Decl(aliasUsageInFunctionExpression_moduleA.ts, 0, 0)) >Model : Symbol(Backbone.Model, Decl(aliasUsageInFunctionExpression_backbone.ts, 0, 0)) diff --git a/tests/baselines/reference/aliasUsageInFunctionExpression.types b/tests/baselines/reference/aliasUsageInFunctionExpression.types index eec4341fd67..15716de5330 100644 --- a/tests/baselines/reference/aliasUsageInFunctionExpression.types +++ b/tests/baselines/reference/aliasUsageInFunctionExpression.types @@ -1,8 +1,8 @@ === tests/cases/compiler/aliasUsageInFunctionExpression_main.ts === -import Backbone = require("aliasUsageInFunctionExpression_backbone"); +import Backbone = require("./aliasUsageInFunctionExpression_backbone"); >Backbone : typeof Backbone -import moduleA = require("aliasUsageInFunctionExpression_moduleA"); +import moduleA = require("./aliasUsageInFunctionExpression_moduleA"); >moduleA : typeof moduleA interface IHasVisualizationModel { @@ -37,7 +37,7 @@ export class Model { } === tests/cases/compiler/aliasUsageInFunctionExpression_moduleA.ts === -import Backbone = require("aliasUsageInFunctionExpression_backbone"); +import Backbone = require("./aliasUsageInFunctionExpression_backbone"); >Backbone : typeof Backbone export class VisualizationModel extends Backbone.Model { diff --git a/tests/baselines/reference/aliasUsageInGenericFunction.js b/tests/baselines/reference/aliasUsageInGenericFunction.js index 8706dd592eb..7091c6d27c6 100644 --- a/tests/baselines/reference/aliasUsageInGenericFunction.js +++ b/tests/baselines/reference/aliasUsageInGenericFunction.js @@ -6,14 +6,14 @@ export class Model { } //// [aliasUsageInGenericFunction_moduleA.ts] -import Backbone = require("aliasUsageInGenericFunction_backbone"); +import Backbone = require("./aliasUsageInGenericFunction_backbone"); export class VisualizationModel extends Backbone.Model { // interesting stuff here } //// [aliasUsageInGenericFunction_main.ts] -import Backbone = require("aliasUsageInGenericFunction_backbone"); -import moduleA = require("aliasUsageInGenericFunction_moduleA"); +import Backbone = require("./aliasUsageInGenericFunction_backbone"); +import moduleA = require("./aliasUsageInGenericFunction_moduleA"); interface IHasVisualizationModel { VisualizationModel: typeof Backbone.Model; } @@ -37,7 +37,7 @@ var __extends = (this && this.__extends) || function (d, b) { function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; -var Backbone = require("aliasUsageInGenericFunction_backbone"); +var Backbone = require("./aliasUsageInGenericFunction_backbone"); var VisualizationModel = (function (_super) { __extends(VisualizationModel, _super); function VisualizationModel() { @@ -47,7 +47,7 @@ var VisualizationModel = (function (_super) { })(Backbone.Model); exports.VisualizationModel = VisualizationModel; //// [aliasUsageInGenericFunction_main.js] -var moduleA = require("aliasUsageInGenericFunction_moduleA"); +var moduleA = require("./aliasUsageInGenericFunction_moduleA"); function foo(x) { return x; } diff --git a/tests/baselines/reference/aliasUsageInGenericFunction.symbols b/tests/baselines/reference/aliasUsageInGenericFunction.symbols index 3f001e8bd1a..fccf60c3514 100644 --- a/tests/baselines/reference/aliasUsageInGenericFunction.symbols +++ b/tests/baselines/reference/aliasUsageInGenericFunction.symbols @@ -1,12 +1,12 @@ === tests/cases/compiler/aliasUsageInGenericFunction_main.ts === -import Backbone = require("aliasUsageInGenericFunction_backbone"); +import Backbone = require("./aliasUsageInGenericFunction_backbone"); >Backbone : Symbol(Backbone, Decl(aliasUsageInGenericFunction_main.ts, 0, 0)) -import moduleA = require("aliasUsageInGenericFunction_moduleA"); ->moduleA : Symbol(moduleA, Decl(aliasUsageInGenericFunction_main.ts, 0, 66)) +import moduleA = require("./aliasUsageInGenericFunction_moduleA"); +>moduleA : Symbol(moduleA, Decl(aliasUsageInGenericFunction_main.ts, 0, 68)) interface IHasVisualizationModel { ->IHasVisualizationModel : Symbol(IHasVisualizationModel, Decl(aliasUsageInGenericFunction_main.ts, 1, 64)) +>IHasVisualizationModel : Symbol(IHasVisualizationModel, Decl(aliasUsageInGenericFunction_main.ts, 1, 66)) VisualizationModel: typeof Backbone.Model; >VisualizationModel : Symbol(VisualizationModel, Decl(aliasUsageInGenericFunction_main.ts, 2, 34)) @@ -18,7 +18,7 @@ function foo(x: T) { >foo : Symbol(foo, Decl(aliasUsageInGenericFunction_main.ts, 4, 1)) >T : Symbol(T, Decl(aliasUsageInGenericFunction_main.ts, 5, 13)) >a : Symbol(a, Decl(aliasUsageInGenericFunction_main.ts, 5, 24)) ->IHasVisualizationModel : Symbol(IHasVisualizationModel, Decl(aliasUsageInGenericFunction_main.ts, 1, 64)) +>IHasVisualizationModel : Symbol(IHasVisualizationModel, Decl(aliasUsageInGenericFunction_main.ts, 1, 66)) >x : Symbol(x, Decl(aliasUsageInGenericFunction_main.ts, 5, 54)) >T : Symbol(T, Decl(aliasUsageInGenericFunction_main.ts, 5, 13)) @@ -29,13 +29,13 @@ var r = foo({ a: moduleA }); >r : Symbol(r, Decl(aliasUsageInGenericFunction_main.ts, 8, 3)) >foo : Symbol(foo, Decl(aliasUsageInGenericFunction_main.ts, 4, 1)) >a : Symbol(a, Decl(aliasUsageInGenericFunction_main.ts, 8, 13)) ->moduleA : Symbol(moduleA, Decl(aliasUsageInGenericFunction_main.ts, 0, 66)) +>moduleA : Symbol(moduleA, Decl(aliasUsageInGenericFunction_main.ts, 0, 68)) var r2 = foo({ a: null }); >r2 : Symbol(r2, Decl(aliasUsageInGenericFunction_main.ts, 9, 3)) >foo : Symbol(foo, Decl(aliasUsageInGenericFunction_main.ts, 4, 1)) >a : Symbol(a, Decl(aliasUsageInGenericFunction_main.ts, 9, 14)) ->IHasVisualizationModel : Symbol(IHasVisualizationModel, Decl(aliasUsageInGenericFunction_main.ts, 1, 64)) +>IHasVisualizationModel : Symbol(IHasVisualizationModel, Decl(aliasUsageInGenericFunction_main.ts, 1, 66)) === tests/cases/compiler/aliasUsageInGenericFunction_backbone.ts === export class Model { @@ -46,11 +46,11 @@ export class Model { } === tests/cases/compiler/aliasUsageInGenericFunction_moduleA.ts === -import Backbone = require("aliasUsageInGenericFunction_backbone"); +import Backbone = require("./aliasUsageInGenericFunction_backbone"); >Backbone : Symbol(Backbone, Decl(aliasUsageInGenericFunction_moduleA.ts, 0, 0)) export class VisualizationModel extends Backbone.Model { ->VisualizationModel : Symbol(VisualizationModel, Decl(aliasUsageInGenericFunction_moduleA.ts, 0, 66)) +>VisualizationModel : Symbol(VisualizationModel, Decl(aliasUsageInGenericFunction_moduleA.ts, 0, 68)) >Backbone.Model : Symbol(Backbone.Model, Decl(aliasUsageInGenericFunction_backbone.ts, 0, 0)) >Backbone : Symbol(Backbone, Decl(aliasUsageInGenericFunction_moduleA.ts, 0, 0)) >Model : Symbol(Backbone.Model, Decl(aliasUsageInGenericFunction_backbone.ts, 0, 0)) diff --git a/tests/baselines/reference/aliasUsageInGenericFunction.types b/tests/baselines/reference/aliasUsageInGenericFunction.types index c21e691d773..5fe7a3e49ef 100644 --- a/tests/baselines/reference/aliasUsageInGenericFunction.types +++ b/tests/baselines/reference/aliasUsageInGenericFunction.types @@ -1,8 +1,8 @@ === tests/cases/compiler/aliasUsageInGenericFunction_main.ts === -import Backbone = require("aliasUsageInGenericFunction_backbone"); +import Backbone = require("./aliasUsageInGenericFunction_backbone"); >Backbone : typeof Backbone -import moduleA = require("aliasUsageInGenericFunction_moduleA"); +import moduleA = require("./aliasUsageInGenericFunction_moduleA"); >moduleA : typeof moduleA interface IHasVisualizationModel { @@ -52,7 +52,7 @@ export class Model { } === tests/cases/compiler/aliasUsageInGenericFunction_moduleA.ts === -import Backbone = require("aliasUsageInGenericFunction_backbone"); +import Backbone = require("./aliasUsageInGenericFunction_backbone"); >Backbone : typeof Backbone export class VisualizationModel extends Backbone.Model { diff --git a/tests/baselines/reference/aliasUsageInIndexerOfClass.js b/tests/baselines/reference/aliasUsageInIndexerOfClass.js index 78ddd2d4a94..82490739687 100644 --- a/tests/baselines/reference/aliasUsageInIndexerOfClass.js +++ b/tests/baselines/reference/aliasUsageInIndexerOfClass.js @@ -6,14 +6,14 @@ export class Model { } //// [aliasUsageInIndexerOfClass_moduleA.ts] -import Backbone = require("aliasUsageInIndexerOfClass_backbone"); +import Backbone = require("./aliasUsageInIndexerOfClass_backbone"); export class VisualizationModel extends Backbone.Model { // interesting stuff here } //// [aliasUsageInIndexerOfClass_main.ts] -import Backbone = require("aliasUsageInIndexerOfClass_backbone"); -import moduleA = require("aliasUsageInIndexerOfClass_moduleA"); +import Backbone = require("./aliasUsageInIndexerOfClass_backbone"); +import moduleA = require("./aliasUsageInIndexerOfClass_moduleA"); interface IHasVisualizationModel { VisualizationModel: typeof Backbone.Model; } @@ -39,7 +39,7 @@ var __extends = (this && this.__extends) || function (d, b) { function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; -var Backbone = require("aliasUsageInIndexerOfClass_backbone"); +var Backbone = require("./aliasUsageInIndexerOfClass_backbone"); var VisualizationModel = (function (_super) { __extends(VisualizationModel, _super); function VisualizationModel() { @@ -49,7 +49,7 @@ var VisualizationModel = (function (_super) { })(Backbone.Model); exports.VisualizationModel = VisualizationModel; //// [aliasUsageInIndexerOfClass_main.js] -var moduleA = require("aliasUsageInIndexerOfClass_moduleA"); +var moduleA = require("./aliasUsageInIndexerOfClass_moduleA"); var N = (function () { function N() { this.x = moduleA; diff --git a/tests/baselines/reference/aliasUsageInIndexerOfClass.symbols b/tests/baselines/reference/aliasUsageInIndexerOfClass.symbols index 900653c7fd1..37529d2ead2 100644 --- a/tests/baselines/reference/aliasUsageInIndexerOfClass.symbols +++ b/tests/baselines/reference/aliasUsageInIndexerOfClass.symbols @@ -1,12 +1,12 @@ === tests/cases/compiler/aliasUsageInIndexerOfClass_main.ts === -import Backbone = require("aliasUsageInIndexerOfClass_backbone"); +import Backbone = require("./aliasUsageInIndexerOfClass_backbone"); >Backbone : Symbol(Backbone, Decl(aliasUsageInIndexerOfClass_main.ts, 0, 0)) -import moduleA = require("aliasUsageInIndexerOfClass_moduleA"); ->moduleA : Symbol(moduleA, Decl(aliasUsageInIndexerOfClass_main.ts, 0, 65)) +import moduleA = require("./aliasUsageInIndexerOfClass_moduleA"); +>moduleA : Symbol(moduleA, Decl(aliasUsageInIndexerOfClass_main.ts, 0, 67)) interface IHasVisualizationModel { ->IHasVisualizationModel : Symbol(IHasVisualizationModel, Decl(aliasUsageInIndexerOfClass_main.ts, 1, 63)) +>IHasVisualizationModel : Symbol(IHasVisualizationModel, Decl(aliasUsageInIndexerOfClass_main.ts, 1, 65)) VisualizationModel: typeof Backbone.Model; >VisualizationModel : Symbol(VisualizationModel, Decl(aliasUsageInIndexerOfClass_main.ts, 2, 34)) @@ -19,22 +19,22 @@ class N { [idx: string]: IHasVisualizationModel >idx : Symbol(idx, Decl(aliasUsageInIndexerOfClass_main.ts, 6, 5)) ->IHasVisualizationModel : Symbol(IHasVisualizationModel, Decl(aliasUsageInIndexerOfClass_main.ts, 1, 63)) +>IHasVisualizationModel : Symbol(IHasVisualizationModel, Decl(aliasUsageInIndexerOfClass_main.ts, 1, 65)) x = moduleA; >x : Symbol(x, Decl(aliasUsageInIndexerOfClass_main.ts, 6, 41)) ->moduleA : Symbol(moduleA, Decl(aliasUsageInIndexerOfClass_main.ts, 0, 65)) +>moduleA : Symbol(moduleA, Decl(aliasUsageInIndexerOfClass_main.ts, 0, 67)) } class N2 { >N2 : Symbol(N2, Decl(aliasUsageInIndexerOfClass_main.ts, 8, 1)) [idx: string]: typeof moduleA >idx : Symbol(idx, Decl(aliasUsageInIndexerOfClass_main.ts, 10, 5)) ->moduleA : Symbol(moduleA, Decl(aliasUsageInIndexerOfClass_main.ts, 0, 65)) +>moduleA : Symbol(moduleA, Decl(aliasUsageInIndexerOfClass_main.ts, 0, 67)) x: IHasVisualizationModel; >x : Symbol(x, Decl(aliasUsageInIndexerOfClass_main.ts, 10, 33)) ->IHasVisualizationModel : Symbol(IHasVisualizationModel, Decl(aliasUsageInIndexerOfClass_main.ts, 1, 63)) +>IHasVisualizationModel : Symbol(IHasVisualizationModel, Decl(aliasUsageInIndexerOfClass_main.ts, 1, 65)) } === tests/cases/compiler/aliasUsageInIndexerOfClass_backbone.ts === export class Model { @@ -45,11 +45,11 @@ export class Model { } === tests/cases/compiler/aliasUsageInIndexerOfClass_moduleA.ts === -import Backbone = require("aliasUsageInIndexerOfClass_backbone"); +import Backbone = require("./aliasUsageInIndexerOfClass_backbone"); >Backbone : Symbol(Backbone, Decl(aliasUsageInIndexerOfClass_moduleA.ts, 0, 0)) export class VisualizationModel extends Backbone.Model { ->VisualizationModel : Symbol(VisualizationModel, Decl(aliasUsageInIndexerOfClass_moduleA.ts, 0, 65)) +>VisualizationModel : Symbol(VisualizationModel, Decl(aliasUsageInIndexerOfClass_moduleA.ts, 0, 67)) >Backbone.Model : Symbol(Backbone.Model, Decl(aliasUsageInIndexerOfClass_backbone.ts, 0, 0)) >Backbone : Symbol(Backbone, Decl(aliasUsageInIndexerOfClass_moduleA.ts, 0, 0)) >Model : Symbol(Backbone.Model, Decl(aliasUsageInIndexerOfClass_backbone.ts, 0, 0)) diff --git a/tests/baselines/reference/aliasUsageInIndexerOfClass.types b/tests/baselines/reference/aliasUsageInIndexerOfClass.types index b7e4873ba34..d6040a90410 100644 --- a/tests/baselines/reference/aliasUsageInIndexerOfClass.types +++ b/tests/baselines/reference/aliasUsageInIndexerOfClass.types @@ -1,8 +1,8 @@ === tests/cases/compiler/aliasUsageInIndexerOfClass_main.ts === -import Backbone = require("aliasUsageInIndexerOfClass_backbone"); +import Backbone = require("./aliasUsageInIndexerOfClass_backbone"); >Backbone : typeof Backbone -import moduleA = require("aliasUsageInIndexerOfClass_moduleA"); +import moduleA = require("./aliasUsageInIndexerOfClass_moduleA"); >moduleA : typeof moduleA interface IHasVisualizationModel { @@ -45,7 +45,7 @@ export class Model { } === tests/cases/compiler/aliasUsageInIndexerOfClass_moduleA.ts === -import Backbone = require("aliasUsageInIndexerOfClass_backbone"); +import Backbone = require("./aliasUsageInIndexerOfClass_backbone"); >Backbone : typeof Backbone export class VisualizationModel extends Backbone.Model { diff --git a/tests/baselines/reference/aliasUsageInObjectLiteral.js b/tests/baselines/reference/aliasUsageInObjectLiteral.js index f38cdf2111c..f1bb99018df 100644 --- a/tests/baselines/reference/aliasUsageInObjectLiteral.js +++ b/tests/baselines/reference/aliasUsageInObjectLiteral.js @@ -6,14 +6,14 @@ export class Model { } //// [aliasUsageInObjectLiteral_moduleA.ts] -import Backbone = require("aliasUsageInObjectLiteral_backbone"); +import Backbone = require("./aliasUsageInObjectLiteral_backbone"); export class VisualizationModel extends Backbone.Model { // interesting stuff here } //// [aliasUsageInObjectLiteral_main.ts] -import Backbone = require("aliasUsageInObjectLiteral_backbone"); -import moduleA = require("aliasUsageInObjectLiteral_moduleA"); +import Backbone = require("./aliasUsageInObjectLiteral_backbone"); +import moduleA = require("./aliasUsageInObjectLiteral_moduleA"); interface IHasVisualizationModel { VisualizationModel: typeof Backbone.Model; } @@ -34,7 +34,7 @@ var __extends = (this && this.__extends) || function (d, b) { function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; -var Backbone = require("aliasUsageInObjectLiteral_backbone"); +var Backbone = require("./aliasUsageInObjectLiteral_backbone"); var VisualizationModel = (function (_super) { __extends(VisualizationModel, _super); function VisualizationModel() { @@ -44,7 +44,7 @@ var VisualizationModel = (function (_super) { })(Backbone.Model); exports.VisualizationModel = VisualizationModel; //// [aliasUsageInObjectLiteral_main.js] -var moduleA = require("aliasUsageInObjectLiteral_moduleA"); +var moduleA = require("./aliasUsageInObjectLiteral_moduleA"); var a = { x: moduleA }; var b = { x: moduleA }; var c = { y: { z: moduleA } }; diff --git a/tests/baselines/reference/aliasUsageInObjectLiteral.symbols b/tests/baselines/reference/aliasUsageInObjectLiteral.symbols index a508e9fafc1..ef94a9037ad 100644 --- a/tests/baselines/reference/aliasUsageInObjectLiteral.symbols +++ b/tests/baselines/reference/aliasUsageInObjectLiteral.symbols @@ -1,12 +1,12 @@ === tests/cases/compiler/aliasUsageInObjectLiteral_main.ts === -import Backbone = require("aliasUsageInObjectLiteral_backbone"); +import Backbone = require("./aliasUsageInObjectLiteral_backbone"); >Backbone : Symbol(Backbone, Decl(aliasUsageInObjectLiteral_main.ts, 0, 0)) -import moduleA = require("aliasUsageInObjectLiteral_moduleA"); ->moduleA : Symbol(moduleA, Decl(aliasUsageInObjectLiteral_main.ts, 0, 64)) +import moduleA = require("./aliasUsageInObjectLiteral_moduleA"); +>moduleA : Symbol(moduleA, Decl(aliasUsageInObjectLiteral_main.ts, 0, 66)) interface IHasVisualizationModel { ->IHasVisualizationModel : Symbol(IHasVisualizationModel, Decl(aliasUsageInObjectLiteral_main.ts, 1, 62)) +>IHasVisualizationModel : Symbol(IHasVisualizationModel, Decl(aliasUsageInObjectLiteral_main.ts, 1, 64)) VisualizationModel: typeof Backbone.Model; >VisualizationModel : Symbol(VisualizationModel, Decl(aliasUsageInObjectLiteral_main.ts, 2, 34)) @@ -17,25 +17,25 @@ interface IHasVisualizationModel { var a: { x: typeof moduleA } = { x: moduleA }; >a : Symbol(a, Decl(aliasUsageInObjectLiteral_main.ts, 5, 3)) >x : Symbol(x, Decl(aliasUsageInObjectLiteral_main.ts, 5, 8)) ->moduleA : Symbol(moduleA, Decl(aliasUsageInObjectLiteral_main.ts, 0, 64)) +>moduleA : Symbol(moduleA, Decl(aliasUsageInObjectLiteral_main.ts, 0, 66)) >x : Symbol(x, Decl(aliasUsageInObjectLiteral_main.ts, 5, 32)) ->moduleA : Symbol(moduleA, Decl(aliasUsageInObjectLiteral_main.ts, 0, 64)) +>moduleA : Symbol(moduleA, Decl(aliasUsageInObjectLiteral_main.ts, 0, 66)) var b: { x: IHasVisualizationModel } = { x: moduleA }; >b : Symbol(b, Decl(aliasUsageInObjectLiteral_main.ts, 6, 3)) >x : Symbol(x, Decl(aliasUsageInObjectLiteral_main.ts, 6, 8)) ->IHasVisualizationModel : Symbol(IHasVisualizationModel, Decl(aliasUsageInObjectLiteral_main.ts, 1, 62)) +>IHasVisualizationModel : Symbol(IHasVisualizationModel, Decl(aliasUsageInObjectLiteral_main.ts, 1, 64)) >x : Symbol(x, Decl(aliasUsageInObjectLiteral_main.ts, 6, 40)) ->moduleA : Symbol(moduleA, Decl(aliasUsageInObjectLiteral_main.ts, 0, 64)) +>moduleA : Symbol(moduleA, Decl(aliasUsageInObjectLiteral_main.ts, 0, 66)) var c: { y: { z: IHasVisualizationModel } } = { y: { z: moduleA } }; >c : Symbol(c, Decl(aliasUsageInObjectLiteral_main.ts, 7, 3)) >y : Symbol(y, Decl(aliasUsageInObjectLiteral_main.ts, 7, 8)) >z : Symbol(z, Decl(aliasUsageInObjectLiteral_main.ts, 7, 13)) ->IHasVisualizationModel : Symbol(IHasVisualizationModel, Decl(aliasUsageInObjectLiteral_main.ts, 1, 62)) +>IHasVisualizationModel : Symbol(IHasVisualizationModel, Decl(aliasUsageInObjectLiteral_main.ts, 1, 64)) >y : Symbol(y, Decl(aliasUsageInObjectLiteral_main.ts, 7, 47)) >z : Symbol(z, Decl(aliasUsageInObjectLiteral_main.ts, 7, 52)) ->moduleA : Symbol(moduleA, Decl(aliasUsageInObjectLiteral_main.ts, 0, 64)) +>moduleA : Symbol(moduleA, Decl(aliasUsageInObjectLiteral_main.ts, 0, 66)) === tests/cases/compiler/aliasUsageInObjectLiteral_backbone.ts === export class Model { @@ -46,11 +46,11 @@ export class Model { } === tests/cases/compiler/aliasUsageInObjectLiteral_moduleA.ts === -import Backbone = require("aliasUsageInObjectLiteral_backbone"); +import Backbone = require("./aliasUsageInObjectLiteral_backbone"); >Backbone : Symbol(Backbone, Decl(aliasUsageInObjectLiteral_moduleA.ts, 0, 0)) export class VisualizationModel extends Backbone.Model { ->VisualizationModel : Symbol(VisualizationModel, Decl(aliasUsageInObjectLiteral_moduleA.ts, 0, 64)) +>VisualizationModel : Symbol(VisualizationModel, Decl(aliasUsageInObjectLiteral_moduleA.ts, 0, 66)) >Backbone.Model : Symbol(Backbone.Model, Decl(aliasUsageInObjectLiteral_backbone.ts, 0, 0)) >Backbone : Symbol(Backbone, Decl(aliasUsageInObjectLiteral_moduleA.ts, 0, 0)) >Model : Symbol(Backbone.Model, Decl(aliasUsageInObjectLiteral_backbone.ts, 0, 0)) diff --git a/tests/baselines/reference/aliasUsageInObjectLiteral.types b/tests/baselines/reference/aliasUsageInObjectLiteral.types index 5ab294b7350..5c8f08a6af2 100644 --- a/tests/baselines/reference/aliasUsageInObjectLiteral.types +++ b/tests/baselines/reference/aliasUsageInObjectLiteral.types @@ -1,8 +1,8 @@ === tests/cases/compiler/aliasUsageInObjectLiteral_main.ts === -import Backbone = require("aliasUsageInObjectLiteral_backbone"); +import Backbone = require("./aliasUsageInObjectLiteral_backbone"); >Backbone : typeof Backbone -import moduleA = require("aliasUsageInObjectLiteral_moduleA"); +import moduleA = require("./aliasUsageInObjectLiteral_moduleA"); >moduleA : typeof moduleA interface IHasVisualizationModel { @@ -50,7 +50,7 @@ export class Model { } === tests/cases/compiler/aliasUsageInObjectLiteral_moduleA.ts === -import Backbone = require("aliasUsageInObjectLiteral_backbone"); +import Backbone = require("./aliasUsageInObjectLiteral_backbone"); >Backbone : typeof Backbone export class VisualizationModel extends Backbone.Model { diff --git a/tests/baselines/reference/aliasUsageInOrExpression.js b/tests/baselines/reference/aliasUsageInOrExpression.js index 906a2c019d7..817ad95aaea 100644 --- a/tests/baselines/reference/aliasUsageInOrExpression.js +++ b/tests/baselines/reference/aliasUsageInOrExpression.js @@ -6,14 +6,14 @@ export class Model { } //// [aliasUsageInOrExpression_moduleA.ts] -import Backbone = require("aliasUsageInOrExpression_backbone"); +import Backbone = require("./aliasUsageInOrExpression_backbone"); export class VisualizationModel extends Backbone.Model { // interesting stuff here } //// [aliasUsageInOrExpression_main.ts] -import Backbone = require("aliasUsageInOrExpression_backbone"); -import moduleA = require("aliasUsageInOrExpression_moduleA"); +import Backbone = require("./aliasUsageInOrExpression_backbone"); +import moduleA = require("./aliasUsageInOrExpression_moduleA"); interface IHasVisualizationModel { VisualizationModel: typeof Backbone.Model; } @@ -37,7 +37,7 @@ var __extends = (this && this.__extends) || function (d, b) { function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; -var Backbone = require("aliasUsageInOrExpression_backbone"); +var Backbone = require("./aliasUsageInOrExpression_backbone"); var VisualizationModel = (function (_super) { __extends(VisualizationModel, _super); function VisualizationModel() { @@ -47,7 +47,7 @@ var VisualizationModel = (function (_super) { })(Backbone.Model); exports.VisualizationModel = VisualizationModel; //// [aliasUsageInOrExpression_main.js] -var moduleA = require("aliasUsageInOrExpression_moduleA"); +var moduleA = require("./aliasUsageInOrExpression_moduleA"); var i; var d1 = i || moduleA; var d2 = i || moduleA; diff --git a/tests/baselines/reference/aliasUsageInOrExpression.symbols b/tests/baselines/reference/aliasUsageInOrExpression.symbols index adfba01a119..3d9331b1fa9 100644 --- a/tests/baselines/reference/aliasUsageInOrExpression.symbols +++ b/tests/baselines/reference/aliasUsageInOrExpression.symbols @@ -1,12 +1,12 @@ === tests/cases/compiler/aliasUsageInOrExpression_main.ts === -import Backbone = require("aliasUsageInOrExpression_backbone"); +import Backbone = require("./aliasUsageInOrExpression_backbone"); >Backbone : Symbol(Backbone, Decl(aliasUsageInOrExpression_main.ts, 0, 0)) -import moduleA = require("aliasUsageInOrExpression_moduleA"); ->moduleA : Symbol(moduleA, Decl(aliasUsageInOrExpression_main.ts, 0, 63)) +import moduleA = require("./aliasUsageInOrExpression_moduleA"); +>moduleA : Symbol(moduleA, Decl(aliasUsageInOrExpression_main.ts, 0, 65)) interface IHasVisualizationModel { ->IHasVisualizationModel : Symbol(IHasVisualizationModel, Decl(aliasUsageInOrExpression_main.ts, 1, 61)) +>IHasVisualizationModel : Symbol(IHasVisualizationModel, Decl(aliasUsageInOrExpression_main.ts, 1, 63)) VisualizationModel: typeof Backbone.Model; >VisualizationModel : Symbol(VisualizationModel, Decl(aliasUsageInOrExpression_main.ts, 2, 34)) @@ -16,42 +16,42 @@ interface IHasVisualizationModel { } var i: IHasVisualizationModel; >i : Symbol(i, Decl(aliasUsageInOrExpression_main.ts, 5, 3)) ->IHasVisualizationModel : Symbol(IHasVisualizationModel, Decl(aliasUsageInOrExpression_main.ts, 1, 61)) +>IHasVisualizationModel : Symbol(IHasVisualizationModel, Decl(aliasUsageInOrExpression_main.ts, 1, 63)) var d1 = i || moduleA; >d1 : Symbol(d1, Decl(aliasUsageInOrExpression_main.ts, 6, 3)) >i : Symbol(i, Decl(aliasUsageInOrExpression_main.ts, 5, 3)) ->moduleA : Symbol(moduleA, Decl(aliasUsageInOrExpression_main.ts, 0, 63)) +>moduleA : Symbol(moduleA, Decl(aliasUsageInOrExpression_main.ts, 0, 65)) var d2: IHasVisualizationModel = i || moduleA; >d2 : Symbol(d2, Decl(aliasUsageInOrExpression_main.ts, 7, 3), Decl(aliasUsageInOrExpression_main.ts, 8, 3)) ->IHasVisualizationModel : Symbol(IHasVisualizationModel, Decl(aliasUsageInOrExpression_main.ts, 1, 61)) +>IHasVisualizationModel : Symbol(IHasVisualizationModel, Decl(aliasUsageInOrExpression_main.ts, 1, 63)) >i : Symbol(i, Decl(aliasUsageInOrExpression_main.ts, 5, 3)) ->moduleA : Symbol(moduleA, Decl(aliasUsageInOrExpression_main.ts, 0, 63)) +>moduleA : Symbol(moduleA, Decl(aliasUsageInOrExpression_main.ts, 0, 65)) var d2: IHasVisualizationModel = moduleA || i; >d2 : Symbol(d2, Decl(aliasUsageInOrExpression_main.ts, 7, 3), Decl(aliasUsageInOrExpression_main.ts, 8, 3)) ->IHasVisualizationModel : Symbol(IHasVisualizationModel, Decl(aliasUsageInOrExpression_main.ts, 1, 61)) ->moduleA : Symbol(moduleA, Decl(aliasUsageInOrExpression_main.ts, 0, 63)) +>IHasVisualizationModel : Symbol(IHasVisualizationModel, Decl(aliasUsageInOrExpression_main.ts, 1, 63)) +>moduleA : Symbol(moduleA, Decl(aliasUsageInOrExpression_main.ts, 0, 65)) >i : Symbol(i, Decl(aliasUsageInOrExpression_main.ts, 5, 3)) var e: { x: IHasVisualizationModel } = <{ x: IHasVisualizationModel }>null || { x: moduleA }; >e : Symbol(e, Decl(aliasUsageInOrExpression_main.ts, 9, 3)) >x : Symbol(x, Decl(aliasUsageInOrExpression_main.ts, 9, 8)) ->IHasVisualizationModel : Symbol(IHasVisualizationModel, Decl(aliasUsageInOrExpression_main.ts, 1, 61)) +>IHasVisualizationModel : Symbol(IHasVisualizationModel, Decl(aliasUsageInOrExpression_main.ts, 1, 63)) >x : Symbol(x, Decl(aliasUsageInOrExpression_main.ts, 9, 41)) ->IHasVisualizationModel : Symbol(IHasVisualizationModel, Decl(aliasUsageInOrExpression_main.ts, 1, 61)) +>IHasVisualizationModel : Symbol(IHasVisualizationModel, Decl(aliasUsageInOrExpression_main.ts, 1, 63)) >x : Symbol(x, Decl(aliasUsageInOrExpression_main.ts, 9, 79)) ->moduleA : Symbol(moduleA, Decl(aliasUsageInOrExpression_main.ts, 0, 63)) +>moduleA : Symbol(moduleA, Decl(aliasUsageInOrExpression_main.ts, 0, 65)) var f: { x: IHasVisualizationModel } = <{ x: IHasVisualizationModel }>null ? { x: moduleA } : null; >f : Symbol(f, Decl(aliasUsageInOrExpression_main.ts, 10, 3)) >x : Symbol(x, Decl(aliasUsageInOrExpression_main.ts, 10, 8)) ->IHasVisualizationModel : Symbol(IHasVisualizationModel, Decl(aliasUsageInOrExpression_main.ts, 1, 61)) +>IHasVisualizationModel : Symbol(IHasVisualizationModel, Decl(aliasUsageInOrExpression_main.ts, 1, 63)) >x : Symbol(x, Decl(aliasUsageInOrExpression_main.ts, 10, 41)) ->IHasVisualizationModel : Symbol(IHasVisualizationModel, Decl(aliasUsageInOrExpression_main.ts, 1, 61)) +>IHasVisualizationModel : Symbol(IHasVisualizationModel, Decl(aliasUsageInOrExpression_main.ts, 1, 63)) >x : Symbol(x, Decl(aliasUsageInOrExpression_main.ts, 10, 78)) ->moduleA : Symbol(moduleA, Decl(aliasUsageInOrExpression_main.ts, 0, 63)) +>moduleA : Symbol(moduleA, Decl(aliasUsageInOrExpression_main.ts, 0, 65)) === tests/cases/compiler/aliasUsageInOrExpression_backbone.ts === export class Model { @@ -62,11 +62,11 @@ export class Model { } === tests/cases/compiler/aliasUsageInOrExpression_moduleA.ts === -import Backbone = require("aliasUsageInOrExpression_backbone"); +import Backbone = require("./aliasUsageInOrExpression_backbone"); >Backbone : Symbol(Backbone, Decl(aliasUsageInOrExpression_moduleA.ts, 0, 0)) export class VisualizationModel extends Backbone.Model { ->VisualizationModel : Symbol(VisualizationModel, Decl(aliasUsageInOrExpression_moduleA.ts, 0, 63)) +>VisualizationModel : Symbol(VisualizationModel, Decl(aliasUsageInOrExpression_moduleA.ts, 0, 65)) >Backbone.Model : Symbol(Backbone.Model, Decl(aliasUsageInOrExpression_backbone.ts, 0, 0)) >Backbone : Symbol(Backbone, Decl(aliasUsageInOrExpression_moduleA.ts, 0, 0)) >Model : Symbol(Backbone.Model, Decl(aliasUsageInOrExpression_backbone.ts, 0, 0)) diff --git a/tests/baselines/reference/aliasUsageInOrExpression.types b/tests/baselines/reference/aliasUsageInOrExpression.types index f009e7084eb..c43b7889cc5 100644 --- a/tests/baselines/reference/aliasUsageInOrExpression.types +++ b/tests/baselines/reference/aliasUsageInOrExpression.types @@ -1,8 +1,8 @@ === tests/cases/compiler/aliasUsageInOrExpression_main.ts === -import Backbone = require("aliasUsageInOrExpression_backbone"); +import Backbone = require("./aliasUsageInOrExpression_backbone"); >Backbone : typeof Backbone -import moduleA = require("aliasUsageInOrExpression_moduleA"); +import moduleA = require("./aliasUsageInOrExpression_moduleA"); >moduleA : typeof moduleA interface IHasVisualizationModel { @@ -74,7 +74,7 @@ export class Model { } === tests/cases/compiler/aliasUsageInOrExpression_moduleA.ts === -import Backbone = require("aliasUsageInOrExpression_backbone"); +import Backbone = require("./aliasUsageInOrExpression_backbone"); >Backbone : typeof Backbone export class VisualizationModel extends Backbone.Model { diff --git a/tests/baselines/reference/aliasUsageInTypeArgumentOfExtendsClause.js b/tests/baselines/reference/aliasUsageInTypeArgumentOfExtendsClause.js index 27f85bb5fcd..270a2807319 100644 --- a/tests/baselines/reference/aliasUsageInTypeArgumentOfExtendsClause.js +++ b/tests/baselines/reference/aliasUsageInTypeArgumentOfExtendsClause.js @@ -6,14 +6,14 @@ export class Model { } //// [aliasUsageInTypeArgumentOfExtendsClause_moduleA.ts] -import Backbone = require("aliasUsageInTypeArgumentOfExtendsClause_backbone"); +import Backbone = require("./aliasUsageInTypeArgumentOfExtendsClause_backbone"); export class VisualizationModel extends Backbone.Model { // interesting stuff here } //// [aliasUsageInTypeArgumentOfExtendsClause_main.ts] -import Backbone = require("aliasUsageInTypeArgumentOfExtendsClause_backbone"); -import moduleA = require("aliasUsageInTypeArgumentOfExtendsClause_moduleA"); +import Backbone = require("./aliasUsageInTypeArgumentOfExtendsClause_backbone"); +import moduleA = require("./aliasUsageInTypeArgumentOfExtendsClause_moduleA"); interface IHasVisualizationModel { VisualizationModel: typeof Backbone.Model; } @@ -37,7 +37,7 @@ var __extends = (this && this.__extends) || function (d, b) { function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; -var Backbone = require("aliasUsageInTypeArgumentOfExtendsClause_backbone"); +var Backbone = require("./aliasUsageInTypeArgumentOfExtendsClause_backbone"); var VisualizationModel = (function (_super) { __extends(VisualizationModel, _super); function VisualizationModel() { @@ -52,7 +52,7 @@ var __extends = (this && this.__extends) || function (d, b) { function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; -var moduleA = require("aliasUsageInTypeArgumentOfExtendsClause_moduleA"); +var moduleA = require("./aliasUsageInTypeArgumentOfExtendsClause_moduleA"); var C = (function () { function C() { } diff --git a/tests/baselines/reference/aliasUsageInTypeArgumentOfExtendsClause.symbols b/tests/baselines/reference/aliasUsageInTypeArgumentOfExtendsClause.symbols index f3ca1f7ec37..6fc639da2c1 100644 --- a/tests/baselines/reference/aliasUsageInTypeArgumentOfExtendsClause.symbols +++ b/tests/baselines/reference/aliasUsageInTypeArgumentOfExtendsClause.symbols @@ -1,12 +1,12 @@ === tests/cases/compiler/aliasUsageInTypeArgumentOfExtendsClause_main.ts === -import Backbone = require("aliasUsageInTypeArgumentOfExtendsClause_backbone"); +import Backbone = require("./aliasUsageInTypeArgumentOfExtendsClause_backbone"); >Backbone : Symbol(Backbone, Decl(aliasUsageInTypeArgumentOfExtendsClause_main.ts, 0, 0)) -import moduleA = require("aliasUsageInTypeArgumentOfExtendsClause_moduleA"); ->moduleA : Symbol(moduleA, Decl(aliasUsageInTypeArgumentOfExtendsClause_main.ts, 0, 78)) +import moduleA = require("./aliasUsageInTypeArgumentOfExtendsClause_moduleA"); +>moduleA : Symbol(moduleA, Decl(aliasUsageInTypeArgumentOfExtendsClause_main.ts, 0, 80)) interface IHasVisualizationModel { ->IHasVisualizationModel : Symbol(IHasVisualizationModel, Decl(aliasUsageInTypeArgumentOfExtendsClause_main.ts, 1, 76)) +>IHasVisualizationModel : Symbol(IHasVisualizationModel, Decl(aliasUsageInTypeArgumentOfExtendsClause_main.ts, 1, 78)) VisualizationModel: typeof Backbone.Model; >VisualizationModel : Symbol(VisualizationModel, Decl(aliasUsageInTypeArgumentOfExtendsClause_main.ts, 2, 34)) @@ -17,7 +17,7 @@ interface IHasVisualizationModel { class C { >C : Symbol(C, Decl(aliasUsageInTypeArgumentOfExtendsClause_main.ts, 4, 1)) >T : Symbol(T, Decl(aliasUsageInTypeArgumentOfExtendsClause_main.ts, 5, 8)) ->IHasVisualizationModel : Symbol(IHasVisualizationModel, Decl(aliasUsageInTypeArgumentOfExtendsClause_main.ts, 1, 76)) +>IHasVisualizationModel : Symbol(IHasVisualizationModel, Decl(aliasUsageInTypeArgumentOfExtendsClause_main.ts, 1, 78)) x: T; >x : Symbol(x, Decl(aliasUsageInTypeArgumentOfExtendsClause_main.ts, 5, 43)) @@ -26,11 +26,11 @@ class C { class D extends C { >D : Symbol(D, Decl(aliasUsageInTypeArgumentOfExtendsClause_main.ts, 7, 1)) >C : Symbol(C, Decl(aliasUsageInTypeArgumentOfExtendsClause_main.ts, 4, 1)) ->IHasVisualizationModel : Symbol(IHasVisualizationModel, Decl(aliasUsageInTypeArgumentOfExtendsClause_main.ts, 1, 76)) +>IHasVisualizationModel : Symbol(IHasVisualizationModel, Decl(aliasUsageInTypeArgumentOfExtendsClause_main.ts, 1, 78)) x = moduleA; >x : Symbol(x, Decl(aliasUsageInTypeArgumentOfExtendsClause_main.ts, 8, 43)) ->moduleA : Symbol(moduleA, Decl(aliasUsageInTypeArgumentOfExtendsClause_main.ts, 0, 78)) +>moduleA : Symbol(moduleA, Decl(aliasUsageInTypeArgumentOfExtendsClause_main.ts, 0, 80)) } === tests/cases/compiler/aliasUsageInTypeArgumentOfExtendsClause_backbone.ts === export class Model { @@ -41,11 +41,11 @@ export class Model { } === tests/cases/compiler/aliasUsageInTypeArgumentOfExtendsClause_moduleA.ts === -import Backbone = require("aliasUsageInTypeArgumentOfExtendsClause_backbone"); +import Backbone = require("./aliasUsageInTypeArgumentOfExtendsClause_backbone"); >Backbone : Symbol(Backbone, Decl(aliasUsageInTypeArgumentOfExtendsClause_moduleA.ts, 0, 0)) export class VisualizationModel extends Backbone.Model { ->VisualizationModel : Symbol(VisualizationModel, Decl(aliasUsageInTypeArgumentOfExtendsClause_moduleA.ts, 0, 78)) +>VisualizationModel : Symbol(VisualizationModel, Decl(aliasUsageInTypeArgumentOfExtendsClause_moduleA.ts, 0, 80)) >Backbone.Model : Symbol(Backbone.Model, Decl(aliasUsageInTypeArgumentOfExtendsClause_backbone.ts, 0, 0)) >Backbone : Symbol(Backbone, Decl(aliasUsageInTypeArgumentOfExtendsClause_moduleA.ts, 0, 0)) >Model : Symbol(Backbone.Model, Decl(aliasUsageInTypeArgumentOfExtendsClause_backbone.ts, 0, 0)) diff --git a/tests/baselines/reference/aliasUsageInTypeArgumentOfExtendsClause.types b/tests/baselines/reference/aliasUsageInTypeArgumentOfExtendsClause.types index ae20caa9c37..3d3d3b6d3f5 100644 --- a/tests/baselines/reference/aliasUsageInTypeArgumentOfExtendsClause.types +++ b/tests/baselines/reference/aliasUsageInTypeArgumentOfExtendsClause.types @@ -1,8 +1,8 @@ === tests/cases/compiler/aliasUsageInTypeArgumentOfExtendsClause_main.ts === -import Backbone = require("aliasUsageInTypeArgumentOfExtendsClause_backbone"); +import Backbone = require("./aliasUsageInTypeArgumentOfExtendsClause_backbone"); >Backbone : typeof Backbone -import moduleA = require("aliasUsageInTypeArgumentOfExtendsClause_moduleA"); +import moduleA = require("./aliasUsageInTypeArgumentOfExtendsClause_moduleA"); >moduleA : typeof moduleA interface IHasVisualizationModel { @@ -41,7 +41,7 @@ export class Model { } === tests/cases/compiler/aliasUsageInTypeArgumentOfExtendsClause_moduleA.ts === -import Backbone = require("aliasUsageInTypeArgumentOfExtendsClause_backbone"); +import Backbone = require("./aliasUsageInTypeArgumentOfExtendsClause_backbone"); >Backbone : typeof Backbone export class VisualizationModel extends Backbone.Model { diff --git a/tests/baselines/reference/aliasUsageInVarAssignment.js b/tests/baselines/reference/aliasUsageInVarAssignment.js index bfc63868ff4..f7949348cdd 100644 --- a/tests/baselines/reference/aliasUsageInVarAssignment.js +++ b/tests/baselines/reference/aliasUsageInVarAssignment.js @@ -6,14 +6,14 @@ export class Model { } //// [aliasUsageInVarAssignment_moduleA.ts] -import Backbone = require("aliasUsageInVarAssignment_backbone"); +import Backbone = require("./aliasUsageInVarAssignment_backbone"); export class VisualizationModel extends Backbone.Model { // interesting stuff here } //// [aliasUsageInVarAssignment_main.ts] -import Backbone = require("aliasUsageInVarAssignment_backbone"); -import moduleA = require("aliasUsageInVarAssignment_moduleA"); +import Backbone = require("./aliasUsageInVarAssignment_backbone"); +import moduleA = require("./aliasUsageInVarAssignment_moduleA"); interface IHasVisualizationModel { VisualizationModel: typeof Backbone.Model; } @@ -33,7 +33,7 @@ var __extends = (this && this.__extends) || function (d, b) { function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; -var Backbone = require("aliasUsageInVarAssignment_backbone"); +var Backbone = require("./aliasUsageInVarAssignment_backbone"); var VisualizationModel = (function (_super) { __extends(VisualizationModel, _super); function VisualizationModel() { diff --git a/tests/baselines/reference/aliasUsageInVarAssignment.symbols b/tests/baselines/reference/aliasUsageInVarAssignment.symbols index d1996fe8ecb..d0e7f6b7d05 100644 --- a/tests/baselines/reference/aliasUsageInVarAssignment.symbols +++ b/tests/baselines/reference/aliasUsageInVarAssignment.symbols @@ -1,12 +1,12 @@ === tests/cases/compiler/aliasUsageInVarAssignment_main.ts === -import Backbone = require("aliasUsageInVarAssignment_backbone"); +import Backbone = require("./aliasUsageInVarAssignment_backbone"); >Backbone : Symbol(Backbone, Decl(aliasUsageInVarAssignment_main.ts, 0, 0)) -import moduleA = require("aliasUsageInVarAssignment_moduleA"); ->moduleA : Symbol(moduleA, Decl(aliasUsageInVarAssignment_main.ts, 0, 64)) +import moduleA = require("./aliasUsageInVarAssignment_moduleA"); +>moduleA : Symbol(moduleA, Decl(aliasUsageInVarAssignment_main.ts, 0, 66)) interface IHasVisualizationModel { ->IHasVisualizationModel : Symbol(IHasVisualizationModel, Decl(aliasUsageInVarAssignment_main.ts, 1, 62)) +>IHasVisualizationModel : Symbol(IHasVisualizationModel, Decl(aliasUsageInVarAssignment_main.ts, 1, 64)) VisualizationModel: typeof Backbone.Model; >VisualizationModel : Symbol(VisualizationModel, Decl(aliasUsageInVarAssignment_main.ts, 2, 34)) @@ -16,11 +16,11 @@ interface IHasVisualizationModel { } var i: IHasVisualizationModel; >i : Symbol(i, Decl(aliasUsageInVarAssignment_main.ts, 5, 3)) ->IHasVisualizationModel : Symbol(IHasVisualizationModel, Decl(aliasUsageInVarAssignment_main.ts, 1, 62)) +>IHasVisualizationModel : Symbol(IHasVisualizationModel, Decl(aliasUsageInVarAssignment_main.ts, 1, 64)) var m: typeof moduleA = i; >m : Symbol(m, Decl(aliasUsageInVarAssignment_main.ts, 6, 3)) ->moduleA : Symbol(moduleA, Decl(aliasUsageInVarAssignment_main.ts, 0, 64)) +>moduleA : Symbol(moduleA, Decl(aliasUsageInVarAssignment_main.ts, 0, 66)) >i : Symbol(i, Decl(aliasUsageInVarAssignment_main.ts, 5, 3)) === tests/cases/compiler/aliasUsageInVarAssignment_backbone.ts === @@ -32,11 +32,11 @@ export class Model { } === tests/cases/compiler/aliasUsageInVarAssignment_moduleA.ts === -import Backbone = require("aliasUsageInVarAssignment_backbone"); +import Backbone = require("./aliasUsageInVarAssignment_backbone"); >Backbone : Symbol(Backbone, Decl(aliasUsageInVarAssignment_moduleA.ts, 0, 0)) export class VisualizationModel extends Backbone.Model { ->VisualizationModel : Symbol(VisualizationModel, Decl(aliasUsageInVarAssignment_moduleA.ts, 0, 64)) +>VisualizationModel : Symbol(VisualizationModel, Decl(aliasUsageInVarAssignment_moduleA.ts, 0, 66)) >Backbone.Model : Symbol(Backbone.Model, Decl(aliasUsageInVarAssignment_backbone.ts, 0, 0)) >Backbone : Symbol(Backbone, Decl(aliasUsageInVarAssignment_moduleA.ts, 0, 0)) >Model : Symbol(Backbone.Model, Decl(aliasUsageInVarAssignment_backbone.ts, 0, 0)) diff --git a/tests/baselines/reference/aliasUsageInVarAssignment.types b/tests/baselines/reference/aliasUsageInVarAssignment.types index 6a23293ea7c..cf636a15240 100644 --- a/tests/baselines/reference/aliasUsageInVarAssignment.types +++ b/tests/baselines/reference/aliasUsageInVarAssignment.types @@ -1,8 +1,8 @@ === tests/cases/compiler/aliasUsageInVarAssignment_main.ts === -import Backbone = require("aliasUsageInVarAssignment_backbone"); +import Backbone = require("./aliasUsageInVarAssignment_backbone"); >Backbone : typeof Backbone -import moduleA = require("aliasUsageInVarAssignment_moduleA"); +import moduleA = require("./aliasUsageInVarAssignment_moduleA"); >moduleA : typeof moduleA interface IHasVisualizationModel { @@ -32,7 +32,7 @@ export class Model { } === tests/cases/compiler/aliasUsageInVarAssignment_moduleA.ts === -import Backbone = require("aliasUsageInVarAssignment_backbone"); +import Backbone = require("./aliasUsageInVarAssignment_backbone"); >Backbone : typeof Backbone export class VisualizationModel extends Backbone.Model { diff --git a/tests/baselines/reference/aliasUsedAsNameValue.js b/tests/baselines/reference/aliasUsedAsNameValue.js index c93acb43fa6..9893eae6e1c 100644 --- a/tests/baselines/reference/aliasUsedAsNameValue.js +++ b/tests/baselines/reference/aliasUsedAsNameValue.js @@ -9,8 +9,8 @@ export function b(a: any): any { return null; } //// [aliasUsedAsNameValue_2.ts] /// /// -import mod = require("aliasUsedAsNameValue_0"); -import b = require("aliasUsedAsNameValue_1"); +import mod = require("./aliasUsedAsNameValue_0"); +import b = require("./aliasUsedAsNameValue_1"); export var a = function () { //var x = mod.id; // TODO needed hack that mod is loaded @@ -25,8 +25,8 @@ exports.b = b; //// [aliasUsedAsNameValue_2.js] /// /// -var mod = require("aliasUsedAsNameValue_0"); -var b = require("aliasUsedAsNameValue_1"); +var mod = require("./aliasUsedAsNameValue_0"); +var b = require("./aliasUsedAsNameValue_1"); exports.a = function () { //var x = mod.id; // TODO needed hack that mod is loaded b.b(mod); diff --git a/tests/baselines/reference/aliasUsedAsNameValue.symbols b/tests/baselines/reference/aliasUsedAsNameValue.symbols index a816e2b2c63..314780eba7c 100644 --- a/tests/baselines/reference/aliasUsedAsNameValue.symbols +++ b/tests/baselines/reference/aliasUsedAsNameValue.symbols @@ -1,11 +1,11 @@ === tests/cases/compiler/aliasUsedAsNameValue_2.ts === /// /// -import mod = require("aliasUsedAsNameValue_0"); +import mod = require("./aliasUsedAsNameValue_0"); >mod : Symbol(mod, Decl(aliasUsedAsNameValue_2.ts, 0, 0)) -import b = require("aliasUsedAsNameValue_1"); ->b : Symbol(b, Decl(aliasUsedAsNameValue_2.ts, 2, 47)) +import b = require("./aliasUsedAsNameValue_1"); +>b : Symbol(b, Decl(aliasUsedAsNameValue_2.ts, 2, 49)) export var a = function () { >a : Symbol(a, Decl(aliasUsedAsNameValue_2.ts, 5, 10)) @@ -13,7 +13,7 @@ export var a = function () { //var x = mod.id; // TODO needed hack that mod is loaded b.b(mod); >b.b : Symbol(b.b, Decl(aliasUsedAsNameValue_1.ts, 0, 0)) ->b : Symbol(b, Decl(aliasUsedAsNameValue_2.ts, 2, 47)) +>b : Symbol(b, Decl(aliasUsedAsNameValue_2.ts, 2, 49)) >b : Symbol(b.b, Decl(aliasUsedAsNameValue_1.ts, 0, 0)) >mod : Symbol(mod, Decl(aliasUsedAsNameValue_2.ts, 0, 0)) } diff --git a/tests/baselines/reference/aliasUsedAsNameValue.types b/tests/baselines/reference/aliasUsedAsNameValue.types index 9c519786c76..86e1eeee9f5 100644 --- a/tests/baselines/reference/aliasUsedAsNameValue.types +++ b/tests/baselines/reference/aliasUsedAsNameValue.types @@ -1,10 +1,10 @@ === tests/cases/compiler/aliasUsedAsNameValue_2.ts === /// /// -import mod = require("aliasUsedAsNameValue_0"); +import mod = require("./aliasUsedAsNameValue_0"); >mod : typeof mod -import b = require("aliasUsedAsNameValue_1"); +import b = require("./aliasUsedAsNameValue_1"); >b : typeof b export var a = function () { diff --git a/tests/baselines/reference/aliasWithInterfaceExportAssignmentUsedInVarInitializer.errors.txt b/tests/baselines/reference/aliasWithInterfaceExportAssignmentUsedInVarInitializer.errors.txt index a2532be9344..1a9d7d26168 100644 --- a/tests/baselines/reference/aliasWithInterfaceExportAssignmentUsedInVarInitializer.errors.txt +++ b/tests/baselines/reference/aliasWithInterfaceExportAssignmentUsedInVarInitializer.errors.txt @@ -2,7 +2,7 @@ tests/cases/compiler/aliasWithInterfaceExportAssignmentUsedInVarInitializer_1.ts ==== tests/cases/compiler/aliasWithInterfaceExportAssignmentUsedInVarInitializer_1.ts (1 errors) ==== - import moduleA = require("aliasWithInterfaceExportAssignmentUsedInVarInitializer_0"); + import moduleA = require("./aliasWithInterfaceExportAssignmentUsedInVarInitializer_0"); var d = b.q3; ~ !!! error TS2304: Cannot find name 'b'. diff --git a/tests/baselines/reference/aliasWithInterfaceExportAssignmentUsedInVarInitializer.js b/tests/baselines/reference/aliasWithInterfaceExportAssignmentUsedInVarInitializer.js index bd76945438f..19534b279c0 100644 --- a/tests/baselines/reference/aliasWithInterfaceExportAssignmentUsedInVarInitializer.js +++ b/tests/baselines/reference/aliasWithInterfaceExportAssignmentUsedInVarInitializer.js @@ -7,7 +7,7 @@ interface c { export = c; //// [aliasWithInterfaceExportAssignmentUsedInVarInitializer_1.ts] -import moduleA = require("aliasWithInterfaceExportAssignmentUsedInVarInitializer_0"); +import moduleA = require("./aliasWithInterfaceExportAssignmentUsedInVarInitializer_0"); var d = b.q3; //// [aliasWithInterfaceExportAssignmentUsedInVarInitializer_0.js] diff --git a/tests/baselines/reference/arrayOfExportedClass.js b/tests/baselines/reference/arrayOfExportedClass.js index 7fde4aa6775..c3f81aca7b0 100644 --- a/tests/baselines/reference/arrayOfExportedClass.js +++ b/tests/baselines/reference/arrayOfExportedClass.js @@ -9,7 +9,7 @@ export = Car; //// [arrayOfExportedClass_1.ts] /// -import Car = require('arrayOfExportedClass_0'); +import Car = require('./arrayOfExportedClass_0'); class Road { diff --git a/tests/baselines/reference/arrayOfExportedClass.symbols b/tests/baselines/reference/arrayOfExportedClass.symbols index 3d0905a1e2d..bdcaf98eb0d 100644 --- a/tests/baselines/reference/arrayOfExportedClass.symbols +++ b/tests/baselines/reference/arrayOfExportedClass.symbols @@ -1,10 +1,10 @@ === tests/cases/compiler/arrayOfExportedClass_1.ts === /// -import Car = require('arrayOfExportedClass_0'); +import Car = require('./arrayOfExportedClass_0'); >Car : Symbol(Car, Decl(arrayOfExportedClass_1.ts, 0, 0)) class Road { ->Road : Symbol(Road, Decl(arrayOfExportedClass_1.ts, 1, 47)) +>Road : Symbol(Road, Decl(arrayOfExportedClass_1.ts, 1, 49)) public cars: Car[]; >cars : Symbol(cars, Decl(arrayOfExportedClass_1.ts, 3, 12)) @@ -17,14 +17,14 @@ class Road { this.cars = cars; >this.cars : Symbol(cars, Decl(arrayOfExportedClass_1.ts, 3, 12)) ->this : Symbol(Road, Decl(arrayOfExportedClass_1.ts, 1, 47)) +>this : Symbol(Road, Decl(arrayOfExportedClass_1.ts, 1, 49)) >cars : Symbol(cars, Decl(arrayOfExportedClass_1.ts, 3, 12)) >cars : Symbol(cars, Decl(arrayOfExportedClass_1.ts, 7, 19)) } } export = Road; ->Road : Symbol(Road, Decl(arrayOfExportedClass_1.ts, 1, 47)) +>Road : Symbol(Road, Decl(arrayOfExportedClass_1.ts, 1, 49)) === tests/cases/compiler/arrayOfExportedClass_0.ts === class Car { diff --git a/tests/baselines/reference/arrayOfExportedClass.types b/tests/baselines/reference/arrayOfExportedClass.types index 3d542b88d80..1e41e82e448 100644 --- a/tests/baselines/reference/arrayOfExportedClass.types +++ b/tests/baselines/reference/arrayOfExportedClass.types @@ -1,6 +1,6 @@ === tests/cases/compiler/arrayOfExportedClass_1.ts === /// -import Car = require('arrayOfExportedClass_0'); +import Car = require('./arrayOfExportedClass_0'); >Car : typeof Car class Road { diff --git a/tests/baselines/reference/chainedImportAlias.js b/tests/baselines/reference/chainedImportAlias.js index 077a92d7450..ec751b0329a 100644 --- a/tests/baselines/reference/chainedImportAlias.js +++ b/tests/baselines/reference/chainedImportAlias.js @@ -6,7 +6,7 @@ export module m { } //// [chainedImportAlias_file1.ts] -import x = require('chainedImportAlias_file0'); +import x = require('./chainedImportAlias_file0'); import y = x; y.m.foo(); @@ -18,6 +18,6 @@ var m; m.foo = foo; })(m = exports.m || (exports.m = {})); //// [chainedImportAlias_file1.js] -var x = require('chainedImportAlias_file0'); +var x = require('./chainedImportAlias_file0'); var y = x; y.m.foo(); diff --git a/tests/baselines/reference/chainedImportAlias.symbols b/tests/baselines/reference/chainedImportAlias.symbols index 3aebb4502f8..0f374305aeb 100644 --- a/tests/baselines/reference/chainedImportAlias.symbols +++ b/tests/baselines/reference/chainedImportAlias.symbols @@ -1,15 +1,15 @@ === tests/cases/compiler/chainedImportAlias_file1.ts === -import x = require('chainedImportAlias_file0'); +import x = require('./chainedImportAlias_file0'); >x : Symbol(x, Decl(chainedImportAlias_file1.ts, 0, 0)) import y = x; ->y : Symbol(y, Decl(chainedImportAlias_file1.ts, 0, 47)) +>y : Symbol(y, Decl(chainedImportAlias_file1.ts, 0, 49)) >x : Symbol(x, Decl(chainedImportAlias_file0.ts, 0, 0)) y.m.foo(); >y.m.foo : Symbol(x.m.foo, Decl(chainedImportAlias_file0.ts, 0, 17)) >y.m : Symbol(x.m, Decl(chainedImportAlias_file0.ts, 0, 0)) ->y : Symbol(y, Decl(chainedImportAlias_file1.ts, 0, 47)) +>y : Symbol(y, Decl(chainedImportAlias_file1.ts, 0, 49)) >m : Symbol(x.m, Decl(chainedImportAlias_file0.ts, 0, 0)) >foo : Symbol(x.m.foo, Decl(chainedImportAlias_file0.ts, 0, 17)) diff --git a/tests/baselines/reference/chainedImportAlias.types b/tests/baselines/reference/chainedImportAlias.types index 1435776fff2..db06c833d0b 100644 --- a/tests/baselines/reference/chainedImportAlias.types +++ b/tests/baselines/reference/chainedImportAlias.types @@ -1,5 +1,5 @@ === tests/cases/compiler/chainedImportAlias_file1.ts === -import x = require('chainedImportAlias_file0'); +import x = require('./chainedImportAlias_file0'); >x : typeof x import y = x; diff --git a/tests/baselines/reference/commentsExternalModules3.js b/tests/baselines/reference/commentsExternalModules3.js index 283e07ebc7f..2acf93296de 100644 --- a/tests/baselines/reference/commentsExternalModules3.js +++ b/tests/baselines/reference/commentsExternalModules3.js @@ -54,7 +54,7 @@ var myvar2 = new m4.m2.c(); //// [commentsExternalModules_1.ts] /**This is on import declaration*/ -import extMod = require("commentsExternalModules2_0"); // trailing comment 1 +import extMod = require("./commentsExternalModules2_0"); // trailing comment 1 extMod.m1.fooExport(); export var newVar = new extMod.m1.m2.c(); extMod.m4.fooExport(); @@ -124,7 +124,7 @@ m4.fooExport(); var myvar2 = new m4.m2.c(); //// [commentsExternalModules_1.js] /**This is on import declaration*/ -var extMod = require("commentsExternalModules2_0"); // trailing comment 1 +var extMod = require("./commentsExternalModules2_0"); // trailing comment 1 extMod.m1.fooExport(); exports.newVar = new extMod.m1.m2.c(); extMod.m4.fooExport(); @@ -165,6 +165,6 @@ export declare module m4 { } //// [commentsExternalModules_1.d.ts] /**This is on import declaration*/ -import extMod = require("commentsExternalModules2_0"); +import extMod = require("./commentsExternalModules2_0"); export declare var newVar: extMod.m1.m2.c; export declare var newVar2: extMod.m4.m2.c; diff --git a/tests/baselines/reference/commentsExternalModules3.symbols b/tests/baselines/reference/commentsExternalModules3.symbols index cfd01db377d..4cab3b0d28a 100644 --- a/tests/baselines/reference/commentsExternalModules3.symbols +++ b/tests/baselines/reference/commentsExternalModules3.symbols @@ -1,6 +1,6 @@ === tests/cases/compiler/commentsExternalModules_1.ts === /**This is on import declaration*/ -import extMod = require("commentsExternalModules2_0"); // trailing comment 1 +import extMod = require("./commentsExternalModules2_0"); // trailing comment 1 >extMod : Symbol(extMod, Decl(commentsExternalModules_1.ts, 0, 0)) extMod.m1.fooExport(); diff --git a/tests/baselines/reference/commentsExternalModules3.types b/tests/baselines/reference/commentsExternalModules3.types index 556b5d11d35..2898784b7ea 100644 --- a/tests/baselines/reference/commentsExternalModules3.types +++ b/tests/baselines/reference/commentsExternalModules3.types @@ -1,6 +1,6 @@ === tests/cases/compiler/commentsExternalModules_1.ts === /**This is on import declaration*/ -import extMod = require("commentsExternalModules2_0"); // trailing comment 1 +import extMod = require("./commentsExternalModules2_0"); // trailing comment 1 >extMod : typeof extMod extMod.m1.fooExport(); diff --git a/tests/baselines/reference/declFileAliasUseBeforeDeclaration.js b/tests/baselines/reference/declFileAliasUseBeforeDeclaration.js index 7814e9641ba..2355d7bbc7a 100644 --- a/tests/baselines/reference/declFileAliasUseBeforeDeclaration.js +++ b/tests/baselines/reference/declFileAliasUseBeforeDeclaration.js @@ -6,7 +6,7 @@ export class Foo { } //// [declFileAliasUseBeforeDeclaration_test.ts] export function bar(a: foo.Foo) { } -import foo = require("declFileAliasUseBeforeDeclaration_foo"); +import foo = require("./declFileAliasUseBeforeDeclaration_foo"); //// [declFileAliasUseBeforeDeclaration_foo.js] var Foo = (function () { @@ -25,4 +25,4 @@ export declare class Foo { } //// [declFileAliasUseBeforeDeclaration_test.d.ts] export declare function bar(a: foo.Foo): void; -import foo = require("declFileAliasUseBeforeDeclaration_foo"); +import foo = require("./declFileAliasUseBeforeDeclaration_foo"); diff --git a/tests/baselines/reference/declFileAliasUseBeforeDeclaration.symbols b/tests/baselines/reference/declFileAliasUseBeforeDeclaration.symbols index ee7795ae455..ba74b6cdfb7 100644 --- a/tests/baselines/reference/declFileAliasUseBeforeDeclaration.symbols +++ b/tests/baselines/reference/declFileAliasUseBeforeDeclaration.symbols @@ -5,7 +5,7 @@ export function bar(a: foo.Foo) { } >foo : Symbol(foo, Decl(declFileAliasUseBeforeDeclaration_test.ts, 0, 35)) >Foo : Symbol(foo.Foo, Decl(declFileAliasUseBeforeDeclaration_foo.ts, 0, 0)) -import foo = require("declFileAliasUseBeforeDeclaration_foo"); +import foo = require("./declFileAliasUseBeforeDeclaration_foo"); >foo : Symbol(foo, Decl(declFileAliasUseBeforeDeclaration_test.ts, 0, 35)) === tests/cases/compiler/declFileAliasUseBeforeDeclaration_foo.ts === diff --git a/tests/baselines/reference/declFileAliasUseBeforeDeclaration.types b/tests/baselines/reference/declFileAliasUseBeforeDeclaration.types index c21d98d90d5..544efded5ee 100644 --- a/tests/baselines/reference/declFileAliasUseBeforeDeclaration.types +++ b/tests/baselines/reference/declFileAliasUseBeforeDeclaration.types @@ -5,7 +5,7 @@ export function bar(a: foo.Foo) { } >foo : any >Foo : foo.Foo -import foo = require("declFileAliasUseBeforeDeclaration_foo"); +import foo = require("./declFileAliasUseBeforeDeclaration_foo"); >foo : typeof foo === tests/cases/compiler/declFileAliasUseBeforeDeclaration_foo.ts === diff --git a/tests/baselines/reference/declFileForExportedImport.js b/tests/baselines/reference/declFileForExportedImport.js index af7cfa46b73..88967c4c2a4 100644 --- a/tests/baselines/reference/declFileForExportedImport.js +++ b/tests/baselines/reference/declFileForExportedImport.js @@ -5,7 +5,7 @@ export var x: number; //// [declFileForExportedImport_1.ts] /// -export import a = require('declFileForExportedImport_0'); +export import a = require('./declFileForExportedImport_0'); var y = a.x; export import b = a; @@ -14,7 +14,7 @@ var z = b.x; //// [declFileForExportedImport_0.js] //// [declFileForExportedImport_1.js] /// -exports.a = require('declFileForExportedImport_0'); +exports.a = require('./declFileForExportedImport_0'); var y = exports.a.x; exports.b = exports.a; var z = exports.b.x; @@ -24,5 +24,5 @@ var z = exports.b.x; export declare var x: number; //// [declFileForExportedImport_1.d.ts] /// -export import a = require('declFileForExportedImport_0'); +export import a = require('./declFileForExportedImport_0'); export import b = a; diff --git a/tests/baselines/reference/declFileForExportedImport.symbols b/tests/baselines/reference/declFileForExportedImport.symbols index fb7b7cd343f..fe14836199c 100644 --- a/tests/baselines/reference/declFileForExportedImport.symbols +++ b/tests/baselines/reference/declFileForExportedImport.symbols @@ -1,6 +1,6 @@ === tests/cases/compiler/declFileForExportedImport_1.ts === /// -export import a = require('declFileForExportedImport_0'); +export import a = require('./declFileForExportedImport_0'); >a : Symbol(a, Decl(declFileForExportedImport_1.ts, 0, 0)) var y = a.x; diff --git a/tests/baselines/reference/declFileForExportedImport.types b/tests/baselines/reference/declFileForExportedImport.types index 987f82bf5a0..0ff8c2f454b 100644 --- a/tests/baselines/reference/declFileForExportedImport.types +++ b/tests/baselines/reference/declFileForExportedImport.types @@ -1,6 +1,6 @@ === tests/cases/compiler/declFileForExportedImport_1.ts === /// -export import a = require('declFileForExportedImport_0'); +export import a = require('./declFileForExportedImport_0'); >a : typeof a var y = a.x; diff --git a/tests/baselines/reference/declFileImportModuleWithExportAssignment.js b/tests/baselines/reference/declFileImportModuleWithExportAssignment.js index 145d4ad3ff2..b070b67ad18 100644 --- a/tests/baselines/reference/declFileImportModuleWithExportAssignment.js +++ b/tests/baselines/reference/declFileImportModuleWithExportAssignment.js @@ -21,7 +21,7 @@ export = m2; //// [declFileImportModuleWithExportAssignment_1.ts] /**This is on import declaration*/ -import a1 = require("declFileImportModuleWithExportAssignment_0"); +import a1 = require("./declFileImportModuleWithExportAssignment_0"); export var a = a1; a.test1(null, null, null); @@ -31,7 +31,7 @@ var m2; module.exports = m2; //// [declFileImportModuleWithExportAssignment_1.js] /**This is on import declaration*/ -var a1 = require("declFileImportModuleWithExportAssignment_0"); +var a1 = require("./declFileImportModuleWithExportAssignment_0"); exports.a = a1; exports.a.test1(null, null, null); @@ -54,7 +54,7 @@ declare var m2: { export = m2; //// [declFileImportModuleWithExportAssignment_1.d.ts] /**This is on import declaration*/ -import a1 = require("declFileImportModuleWithExportAssignment_0"); +import a1 = require("./declFileImportModuleWithExportAssignment_0"); export declare var a: { (): a1.connectExport; test1: a1.connectModule; diff --git a/tests/baselines/reference/declFileImportModuleWithExportAssignment.symbols b/tests/baselines/reference/declFileImportModuleWithExportAssignment.symbols index 62d9d599939..a33e0fef758 100644 --- a/tests/baselines/reference/declFileImportModuleWithExportAssignment.symbols +++ b/tests/baselines/reference/declFileImportModuleWithExportAssignment.symbols @@ -1,6 +1,6 @@ === tests/cases/compiler/declFileImportModuleWithExportAssignment_1.ts === /**This is on import declaration*/ -import a1 = require("declFileImportModuleWithExportAssignment_0"); +import a1 = require("./declFileImportModuleWithExportAssignment_0"); >a1 : Symbol(a1, Decl(declFileImportModuleWithExportAssignment_1.ts, 0, 0)) export var a = a1; diff --git a/tests/baselines/reference/declFileImportModuleWithExportAssignment.types b/tests/baselines/reference/declFileImportModuleWithExportAssignment.types index d3082311c1d..123b7b56d4f 100644 --- a/tests/baselines/reference/declFileImportModuleWithExportAssignment.types +++ b/tests/baselines/reference/declFileImportModuleWithExportAssignment.types @@ -1,6 +1,6 @@ === tests/cases/compiler/declFileImportModuleWithExportAssignment_1.ts === /**This is on import declaration*/ -import a1 = require("declFileImportModuleWithExportAssignment_0"); +import a1 = require("./declFileImportModuleWithExportAssignment_0"); >a1 : { (): a1.connectExport; test1: a1.connectModule; test2(): a1.connectModule; } export var a = a1; diff --git a/tests/baselines/reference/declarationEmit_exportAssignment.js b/tests/baselines/reference/declarationEmit_exportAssignment.js index 54f3eb5fd0e..d761e2c45eb 100644 --- a/tests/baselines/reference/declarationEmit_exportAssignment.js +++ b/tests/baselines/reference/declarationEmit_exportAssignment.js @@ -7,7 +7,7 @@ export function bar() { } export interface Buzz { } //// [index.ts] -import {foo} from "utils"; +import {foo} from "./utils"; export = foo; //// [utils.js] @@ -16,7 +16,7 @@ exports.foo = foo; function bar() { } exports.bar = bar; //// [index.js] -var utils_1 = require("utils"); +var utils_1 = require("./utils"); module.exports = utils_1.foo; @@ -26,5 +26,5 @@ export declare function bar(): void; export interface Buzz { } //// [index.d.ts] -import { foo } from "utils"; +import { foo } from "./utils"; export = foo; diff --git a/tests/baselines/reference/declarationEmit_exportAssignment.symbols b/tests/baselines/reference/declarationEmit_exportAssignment.symbols index b443ba6e797..d2131d27a8f 100644 --- a/tests/baselines/reference/declarationEmit_exportAssignment.symbols +++ b/tests/baselines/reference/declarationEmit_exportAssignment.symbols @@ -10,7 +10,7 @@ export interface Buzz { } >Buzz : Symbol(Buzz, Decl(utils.ts, 2, 25)) === tests/cases/compiler/index.ts === -import {foo} from "utils"; +import {foo} from "./utils"; >foo : Symbol(foo, Decl(index.ts, 0, 8)) export = foo; diff --git a/tests/baselines/reference/declarationEmit_exportAssignment.types b/tests/baselines/reference/declarationEmit_exportAssignment.types index 81c56da432f..763441b8a90 100644 --- a/tests/baselines/reference/declarationEmit_exportAssignment.types +++ b/tests/baselines/reference/declarationEmit_exportAssignment.types @@ -10,7 +10,7 @@ export interface Buzz { } >Buzz : Buzz === tests/cases/compiler/index.ts === -import {foo} from "utils"; +import {foo} from "./utils"; >foo : () => void export = foo; diff --git a/tests/baselines/reference/declarationEmit_exportDeclaration.js b/tests/baselines/reference/declarationEmit_exportDeclaration.js index f05639dc18f..e2cb15b408c 100644 --- a/tests/baselines/reference/declarationEmit_exportDeclaration.js +++ b/tests/baselines/reference/declarationEmit_exportDeclaration.js @@ -7,7 +7,7 @@ export function bar() { } export interface Buzz { } //// [index.ts] -import {foo, bar, Buzz} from "utils"; +import {foo, bar, Buzz} from "./utils"; foo(); let obj: Buzz; @@ -19,7 +19,7 @@ exports.foo = foo; function bar() { } exports.bar = bar; //// [index.js] -var utils_1 = require("utils"); +var utils_1 = require("./utils"); exports.bar = utils_1.bar; utils_1.foo(); var obj; @@ -31,5 +31,5 @@ export declare function bar(): void; export interface Buzz { } //// [index.d.ts] -import { bar } from "utils"; +import { bar } from "./utils"; export { bar }; diff --git a/tests/baselines/reference/declarationEmit_exportDeclaration.symbols b/tests/baselines/reference/declarationEmit_exportDeclaration.symbols index 5cd8c5fee99..40d6bafdee5 100644 --- a/tests/baselines/reference/declarationEmit_exportDeclaration.symbols +++ b/tests/baselines/reference/declarationEmit_exportDeclaration.symbols @@ -10,7 +10,7 @@ export interface Buzz { } >Buzz : Symbol(Buzz, Decl(utils.ts, 2, 25)) === tests/cases/compiler/index.ts === -import {foo, bar, Buzz} from "utils"; +import {foo, bar, Buzz} from "./utils"; >foo : Symbol(foo, Decl(index.ts, 0, 8)) >bar : Symbol(bar, Decl(index.ts, 0, 12)) >Buzz : Symbol(Buzz, Decl(index.ts, 0, 17)) diff --git a/tests/baselines/reference/declarationEmit_exportDeclaration.types b/tests/baselines/reference/declarationEmit_exportDeclaration.types index 058ee863c61..25a8f1d29bd 100644 --- a/tests/baselines/reference/declarationEmit_exportDeclaration.types +++ b/tests/baselines/reference/declarationEmit_exportDeclaration.types @@ -10,7 +10,7 @@ export interface Buzz { } >Buzz : Buzz === tests/cases/compiler/index.ts === -import {foo, bar, Buzz} from "utils"; +import {foo, bar, Buzz} from "./utils"; >foo : () => void >bar : () => void >Buzz : any diff --git a/tests/baselines/reference/declarationEmit_nameConflicts.js b/tests/baselines/reference/declarationEmit_nameConflicts.js index ae517bb7460..857fbee764d 100644 --- a/tests/baselines/reference/declarationEmit_nameConflicts.js +++ b/tests/baselines/reference/declarationEmit_nameConflicts.js @@ -5,7 +5,7 @@ module f { export class c { } } export = f; //// [declarationEmit_nameConflicts_0.ts] -import im = require('declarationEmit_nameConflicts_1'); +import im = require('./declarationEmit_nameConflicts_1'); export module M { export function f() { } export class C { } @@ -61,7 +61,7 @@ var f; })(f || (f = {})); module.exports = f; //// [declarationEmit_nameConflicts_0.js] -var im = require('declarationEmit_nameConflicts_1'); +var im = require('./declarationEmit_nameConflicts_1'); var M; (function (M) { function f() { } @@ -138,7 +138,7 @@ declare module f { } export = f; //// [declarationEmit_nameConflicts_0.d.ts] -import im = require('declarationEmit_nameConflicts_1'); +import im = require('./declarationEmit_nameConflicts_1'); export declare module M { function f(): void; class C { diff --git a/tests/baselines/reference/declarationEmit_nameConflicts.symbols b/tests/baselines/reference/declarationEmit_nameConflicts.symbols index a626ed05b15..1c5bb35b756 100644 --- a/tests/baselines/reference/declarationEmit_nameConflicts.symbols +++ b/tests/baselines/reference/declarationEmit_nameConflicts.symbols @@ -1,9 +1,9 @@ === tests/cases/compiler/declarationEmit_nameConflicts_0.ts === -import im = require('declarationEmit_nameConflicts_1'); +import im = require('./declarationEmit_nameConflicts_1'); >im : Symbol(im, Decl(declarationEmit_nameConflicts_0.ts, 0, 0)) export module M { ->M : Symbol(M, Decl(declarationEmit_nameConflicts_0.ts, 0, 55), Decl(declarationEmit_nameConflicts_0.ts, 13, 1), Decl(declarationEmit_nameConflicts_0.ts, 28, 1)) +>M : Symbol(M, Decl(declarationEmit_nameConflicts_0.ts, 0, 57), Decl(declarationEmit_nameConflicts_0.ts, 13, 1), Decl(declarationEmit_nameConflicts_0.ts, 28, 1)) export function f() { } >f : Symbol(f, Decl(declarationEmit_nameConflicts_0.ts, 1, 17)) @@ -23,12 +23,12 @@ export module M { export import a = M.f; >a : Symbol(a, Decl(declarationEmit_nameConflicts_0.ts, 7, 5)) ->M : Symbol(M, Decl(declarationEmit_nameConflicts_0.ts, 0, 55), Decl(declarationEmit_nameConflicts_0.ts, 13, 1), Decl(declarationEmit_nameConflicts_0.ts, 28, 1)) +>M : Symbol(M, Decl(declarationEmit_nameConflicts_0.ts, 0, 57), Decl(declarationEmit_nameConflicts_0.ts, 13, 1), Decl(declarationEmit_nameConflicts_0.ts, 28, 1)) >f : Symbol(f, Decl(declarationEmit_nameConflicts_0.ts, 1, 17)) export import b = M.C; >b : Symbol(b, Decl(declarationEmit_nameConflicts_0.ts, 9, 26)) ->M : Symbol(M, Decl(declarationEmit_nameConflicts_0.ts, 0, 55), Decl(declarationEmit_nameConflicts_0.ts, 13, 1), Decl(declarationEmit_nameConflicts_0.ts, 28, 1)) +>M : Symbol(M, Decl(declarationEmit_nameConflicts_0.ts, 0, 57), Decl(declarationEmit_nameConflicts_0.ts, 13, 1), Decl(declarationEmit_nameConflicts_0.ts, 28, 1)) >C : Symbol(C, Decl(declarationEmit_nameConflicts_0.ts, 2, 27)) export import c = N; @@ -41,7 +41,7 @@ export module M { } export module M.P { ->M : Symbol(M, Decl(declarationEmit_nameConflicts_0.ts, 0, 55), Decl(declarationEmit_nameConflicts_0.ts, 13, 1), Decl(declarationEmit_nameConflicts_0.ts, 28, 1)) +>M : Symbol(M, Decl(declarationEmit_nameConflicts_0.ts, 0, 57), Decl(declarationEmit_nameConflicts_0.ts, 13, 1), Decl(declarationEmit_nameConflicts_0.ts, 28, 1)) >P : Symbol(P, Decl(declarationEmit_nameConflicts_0.ts, 15, 16)) export function f() { } @@ -61,45 +61,45 @@ export module M.P { } export import im = M.P.f; >im : Symbol(im, Decl(declarationEmit_nameConflicts_0.ts, 21, 5)) ->M : Symbol(M, Decl(declarationEmit_nameConflicts_0.ts, 0, 55), Decl(declarationEmit_nameConflicts_0.ts, 13, 1), Decl(declarationEmit_nameConflicts_0.ts, 28, 1)) +>M : Symbol(M, Decl(declarationEmit_nameConflicts_0.ts, 0, 57), Decl(declarationEmit_nameConflicts_0.ts, 13, 1), Decl(declarationEmit_nameConflicts_0.ts, 28, 1)) >P : Symbol(P, Decl(declarationEmit_nameConflicts_0.ts, 15, 16)) >f : Symbol(f, Decl(declarationEmit_nameConflicts_0.ts, 15, 19)) export var a = M.a; // emitted incorrectly as typeof f >a : Symbol(a, Decl(declarationEmit_nameConflicts_0.ts, 23, 14)) >M.a : Symbol(a, Decl(declarationEmit_nameConflicts_0.ts, 7, 5)) ->M : Symbol(M, Decl(declarationEmit_nameConflicts_0.ts, 0, 55), Decl(declarationEmit_nameConflicts_0.ts, 13, 1), Decl(declarationEmit_nameConflicts_0.ts, 28, 1)) +>M : Symbol(M, Decl(declarationEmit_nameConflicts_0.ts, 0, 57), Decl(declarationEmit_nameConflicts_0.ts, 13, 1), Decl(declarationEmit_nameConflicts_0.ts, 28, 1)) >a : Symbol(a, Decl(declarationEmit_nameConflicts_0.ts, 7, 5)) export var b = M.b; // ok >b : Symbol(b, Decl(declarationEmit_nameConflicts_0.ts, 24, 14)) >M.b : Symbol(b, Decl(declarationEmit_nameConflicts_0.ts, 9, 26)) ->M : Symbol(M, Decl(declarationEmit_nameConflicts_0.ts, 0, 55), Decl(declarationEmit_nameConflicts_0.ts, 13, 1), Decl(declarationEmit_nameConflicts_0.ts, 28, 1)) +>M : Symbol(M, Decl(declarationEmit_nameConflicts_0.ts, 0, 57), Decl(declarationEmit_nameConflicts_0.ts, 13, 1), Decl(declarationEmit_nameConflicts_0.ts, 28, 1)) >b : Symbol(b, Decl(declarationEmit_nameConflicts_0.ts, 9, 26)) export var c = M.c; // ok >c : Symbol(c, Decl(declarationEmit_nameConflicts_0.ts, 25, 14)) >M.c : Symbol(c, Decl(declarationEmit_nameConflicts_0.ts, 10, 26)) ->M : Symbol(M, Decl(declarationEmit_nameConflicts_0.ts, 0, 55), Decl(declarationEmit_nameConflicts_0.ts, 13, 1), Decl(declarationEmit_nameConflicts_0.ts, 28, 1)) +>M : Symbol(M, Decl(declarationEmit_nameConflicts_0.ts, 0, 57), Decl(declarationEmit_nameConflicts_0.ts, 13, 1), Decl(declarationEmit_nameConflicts_0.ts, 28, 1)) >c : Symbol(c, Decl(declarationEmit_nameConflicts_0.ts, 10, 26)) export var g = M.c.g; // ok >g : Symbol(g, Decl(declarationEmit_nameConflicts_0.ts, 26, 14)) >M.c.g : Symbol(c.g, Decl(declarationEmit_nameConflicts_0.ts, 4, 21)) >M.c : Symbol(c, Decl(declarationEmit_nameConflicts_0.ts, 10, 26)) ->M : Symbol(M, Decl(declarationEmit_nameConflicts_0.ts, 0, 55), Decl(declarationEmit_nameConflicts_0.ts, 13, 1), Decl(declarationEmit_nameConflicts_0.ts, 28, 1)) +>M : Symbol(M, Decl(declarationEmit_nameConflicts_0.ts, 0, 57), Decl(declarationEmit_nameConflicts_0.ts, 13, 1), Decl(declarationEmit_nameConflicts_0.ts, 28, 1)) >c : Symbol(c, Decl(declarationEmit_nameConflicts_0.ts, 10, 26)) >g : Symbol(c.g, Decl(declarationEmit_nameConflicts_0.ts, 4, 21)) export var d = M.d; // emitted incorrectly as typeof im >d : Symbol(d, Decl(declarationEmit_nameConflicts_0.ts, 27, 14)) >M.d : Symbol(d, Decl(declarationEmit_nameConflicts_0.ts, 11, 24)) ->M : Symbol(M, Decl(declarationEmit_nameConflicts_0.ts, 0, 55), Decl(declarationEmit_nameConflicts_0.ts, 13, 1), Decl(declarationEmit_nameConflicts_0.ts, 28, 1)) +>M : Symbol(M, Decl(declarationEmit_nameConflicts_0.ts, 0, 57), Decl(declarationEmit_nameConflicts_0.ts, 13, 1), Decl(declarationEmit_nameConflicts_0.ts, 28, 1)) >d : Symbol(d, Decl(declarationEmit_nameConflicts_0.ts, 11, 24)) } export module M.Q { ->M : Symbol(M, Decl(declarationEmit_nameConflicts_0.ts, 0, 55), Decl(declarationEmit_nameConflicts_0.ts, 13, 1), Decl(declarationEmit_nameConflicts_0.ts, 28, 1)) +>M : Symbol(M, Decl(declarationEmit_nameConflicts_0.ts, 0, 57), Decl(declarationEmit_nameConflicts_0.ts, 13, 1), Decl(declarationEmit_nameConflicts_0.ts, 28, 1)) >Q : Symbol(Q, Decl(declarationEmit_nameConflicts_0.ts, 30, 16)) export function f() { } @@ -120,14 +120,14 @@ export module M.Q { export interface b extends M.b { } // ok >b : Symbol(b, Decl(declarationEmit_nameConflicts_0.ts, 36, 5)) >M.b : Symbol(b, Decl(declarationEmit_nameConflicts_0.ts, 9, 26)) ->M : Symbol(M, Decl(declarationEmit_nameConflicts_0.ts, 0, 55), Decl(declarationEmit_nameConflicts_0.ts, 13, 1), Decl(declarationEmit_nameConflicts_0.ts, 28, 1)) +>M : Symbol(M, Decl(declarationEmit_nameConflicts_0.ts, 0, 57), Decl(declarationEmit_nameConflicts_0.ts, 13, 1), Decl(declarationEmit_nameConflicts_0.ts, 28, 1)) >b : Symbol(b, Decl(declarationEmit_nameConflicts_0.ts, 9, 26)) export interface I extends M.c.I { } // ok >I : Symbol(I, Decl(declarationEmit_nameConflicts_0.ts, 37, 38)) >M.c.I : Symbol(M.c.I, Decl(declarationEmit_nameConflicts_0.ts, 5, 32)) >M.c : Symbol(c, Decl(declarationEmit_nameConflicts_0.ts, 10, 26)) ->M : Symbol(M, Decl(declarationEmit_nameConflicts_0.ts, 0, 55), Decl(declarationEmit_nameConflicts_0.ts, 13, 1), Decl(declarationEmit_nameConflicts_0.ts, 28, 1)) +>M : Symbol(M, Decl(declarationEmit_nameConflicts_0.ts, 0, 57), Decl(declarationEmit_nameConflicts_0.ts, 13, 1), Decl(declarationEmit_nameConflicts_0.ts, 28, 1)) >c : Symbol(c, Decl(declarationEmit_nameConflicts_0.ts, 10, 26)) >I : Symbol(M.c.I, Decl(declarationEmit_nameConflicts_0.ts, 5, 32)) @@ -138,7 +138,7 @@ export module M.Q { >I : Symbol(I, Decl(declarationEmit_nameConflicts_0.ts, 39, 21)) >M.c.I : Symbol(M.c.I, Decl(declarationEmit_nameConflicts_0.ts, 5, 32)) >M.c : Symbol(c, Decl(declarationEmit_nameConflicts_0.ts, 10, 26)) ->M : Symbol(M, Decl(declarationEmit_nameConflicts_0.ts, 0, 55), Decl(declarationEmit_nameConflicts_0.ts, 13, 1), Decl(declarationEmit_nameConflicts_0.ts, 28, 1)) +>M : Symbol(M, Decl(declarationEmit_nameConflicts_0.ts, 0, 57), Decl(declarationEmit_nameConflicts_0.ts, 13, 1), Decl(declarationEmit_nameConflicts_0.ts, 28, 1)) >c : Symbol(c, Decl(declarationEmit_nameConflicts_0.ts, 10, 26)) >I : Symbol(M.c.I, Decl(declarationEmit_nameConflicts_0.ts, 5, 32)) } diff --git a/tests/baselines/reference/declarationEmit_nameConflicts.types b/tests/baselines/reference/declarationEmit_nameConflicts.types index dacd657706d..6ea650946c5 100644 --- a/tests/baselines/reference/declarationEmit_nameConflicts.types +++ b/tests/baselines/reference/declarationEmit_nameConflicts.types @@ -1,5 +1,5 @@ === tests/cases/compiler/declarationEmit_nameConflicts_0.ts === -import im = require('declarationEmit_nameConflicts_1'); +import im = require('./declarationEmit_nameConflicts_1'); >im : typeof im export module M { diff --git a/tests/baselines/reference/defaultExportsCannotMerge01.errors.txt b/tests/baselines/reference/defaultExportsCannotMerge01.errors.txt index be08d976eeb..15c60e32d9f 100644 --- a/tests/baselines/reference/defaultExportsCannotMerge01.errors.txt +++ b/tests/baselines/reference/defaultExportsCannotMerge01.errors.txt @@ -1,9 +1,6 @@ tests/cases/conformance/es6/modules/m1.ts(2,25): error TS2652: Merged declaration 'Decl' cannot include a default export declaration. Consider adding a separate 'export default Decl' declaration instead. tests/cases/conformance/es6/modules/m1.ts(11,18): error TS2652: Merged declaration 'Decl' cannot include a default export declaration. Consider adding a separate 'export default Decl' declaration instead. -tests/cases/conformance/es6/modules/m2.ts(5,8): error TS2304: Cannot find name 'Entity'. -tests/cases/conformance/es6/modules/m2.ts(6,8): error TS2503: Cannot find namespace 'Entity'. -tests/cases/conformance/es6/modules/m2.ts(8,8): error TS2339: Property 'x' does not exist on type '() => number'. -tests/cases/conformance/es6/modules/m2.ts(9,8): error TS2339: Property 'y' does not exist on type '() => number'. +tests/cases/conformance/es6/modules/m2.ts(1,20): error TS2307: Cannot find module 'm1'. ==== tests/cases/conformance/es6/modules/m1.ts (2 errors) ==== @@ -29,21 +26,15 @@ tests/cases/conformance/es6/modules/m2.ts(9,8): error TS2339: Property 'y' does } } -==== tests/cases/conformance/es6/modules/m2.ts (4 errors) ==== +==== tests/cases/conformance/es6/modules/m2.ts (1 errors) ==== import Entity from "m1" + ~~~~ +!!! error TS2307: Cannot find module 'm1'. Entity(); var x: Entity; - ~~~~~~ -!!! error TS2304: Cannot find name 'Entity'. var y: Entity.I; - ~~~~~~ -!!! error TS2503: Cannot find namespace 'Entity'. Entity.x; - ~ -!!! error TS2339: Property 'x' does not exist on type '() => number'. - Entity.y; - ~ -!!! error TS2339: Property 'y' does not exist on type '() => number'. \ No newline at end of file + Entity.y; \ No newline at end of file diff --git a/tests/baselines/reference/defaultExportsCannotMerge02.errors.txt b/tests/baselines/reference/defaultExportsCannotMerge02.errors.txt index ad9b85c7e94..30bab504c7e 100644 --- a/tests/baselines/reference/defaultExportsCannotMerge02.errors.txt +++ b/tests/baselines/reference/defaultExportsCannotMerge02.errors.txt @@ -1,9 +1,6 @@ tests/cases/conformance/es6/modules/m1.ts(2,22): error TS2652: Merged declaration 'Decl' cannot include a default export declaration. Consider adding a separate 'export default Decl' declaration instead. tests/cases/conformance/es6/modules/m1.ts(5,18): error TS2652: Merged declaration 'Decl' cannot include a default export declaration. Consider adding a separate 'export default Decl' declaration instead. -tests/cases/conformance/es6/modules/m2.ts(3,1): error TS2348: Value of type 'typeof Decl' is not callable. Did you mean to include 'new'? -tests/cases/conformance/es6/modules/m2.ts(6,8): error TS2503: Cannot find namespace 'Entity'. -tests/cases/conformance/es6/modules/m2.ts(8,13): error TS2339: Property 'p1' does not exist on type 'Decl'. -tests/cases/conformance/es6/modules/m2.ts(8,20): error TS2339: Property 'p2' does not exist on type 'Decl'. +tests/cases/conformance/es6/modules/m2.ts(1,20): error TS2307: Cannot find module 'm1'. ==== tests/cases/conformance/es6/modules/m1.ts (2 errors) ==== @@ -25,20 +22,14 @@ tests/cases/conformance/es6/modules/m2.ts(8,20): error TS2339: Property 'p2' doe } } -==== tests/cases/conformance/es6/modules/m2.ts (4 errors) ==== +==== tests/cases/conformance/es6/modules/m2.ts (1 errors) ==== import Entity from "m1" + ~~~~ +!!! error TS2307: Cannot find module 'm1'. Entity(); - ~~~~~~~~ -!!! error TS2348: Value of type 'typeof Decl' is not callable. Did you mean to include 'new'? var x: Entity; var y: Entity.I; - ~~~~~~ -!!! error TS2503: Cannot find namespace 'Entity'. var z = new Entity(); - var sum = z.p1 + z.p2 - ~~ -!!! error TS2339: Property 'p1' does not exist on type 'Decl'. - ~~ -!!! error TS2339: Property 'p2' does not exist on type 'Decl'. \ No newline at end of file + var sum = z.p1 + z.p2 \ No newline at end of file diff --git a/tests/baselines/reference/defaultExportsCannotMerge03.errors.txt b/tests/baselines/reference/defaultExportsCannotMerge03.errors.txt index b1d405671e3..11e9c63b893 100644 --- a/tests/baselines/reference/defaultExportsCannotMerge03.errors.txt +++ b/tests/baselines/reference/defaultExportsCannotMerge03.errors.txt @@ -1,10 +1,7 @@ tests/cases/conformance/es6/modules/m1.ts(2,22): error TS2652: Merged declaration 'Decl' cannot include a default export declaration. Consider adding a separate 'export default Decl' declaration instead. tests/cases/conformance/es6/modules/m1.ts(5,11): error TS2518: Only an ambient class can be merged with an interface. tests/cases/conformance/es6/modules/m1.ts(5,11): error TS2652: Merged declaration 'Decl' cannot include a default export declaration. Consider adding a separate 'export default Decl' declaration instead. -tests/cases/conformance/es6/modules/m2.ts(3,1): error TS2348: Value of type 'typeof Decl' is not callable. Did you mean to include 'new'? -tests/cases/conformance/es6/modules/m2.ts(6,8): error TS2503: Cannot find namespace 'Entity'. -tests/cases/conformance/es6/modules/m2.ts(8,13): error TS2339: Property 'p1' does not exist on type 'Decl'. -tests/cases/conformance/es6/modules/m2.ts(8,20): error TS2339: Property 'p2' does not exist on type 'Decl'. +tests/cases/conformance/es6/modules/m2.ts(1,20): error TS2307: Cannot find module 'm1'. ==== tests/cases/conformance/es6/modules/m1.ts (3 errors) ==== @@ -28,20 +25,14 @@ tests/cases/conformance/es6/modules/m2.ts(8,20): error TS2339: Property 'p2' doe } } -==== tests/cases/conformance/es6/modules/m2.ts (4 errors) ==== +==== tests/cases/conformance/es6/modules/m2.ts (1 errors) ==== import Entity from "m1" + ~~~~ +!!! error TS2307: Cannot find module 'm1'. Entity(); - ~~~~~~~~ -!!! error TS2348: Value of type 'typeof Decl' is not callable. Did you mean to include 'new'? var x: Entity; var y: Entity.I; - ~~~~~~ -!!! error TS2503: Cannot find namespace 'Entity'. var z = new Entity(); - var sum = z.p1 + z.p2 - ~~ -!!! error TS2339: Property 'p1' does not exist on type 'Decl'. - ~~ -!!! error TS2339: Property 'p2' does not exist on type 'Decl'. \ No newline at end of file + var sum = z.p1 + z.p2 \ No newline at end of file diff --git a/tests/baselines/reference/elidingImportNames.js b/tests/baselines/reference/elidingImportNames.js index 3c61789a1a7..e07ee6fa54a 100644 --- a/tests/baselines/reference/elidingImportNames.js +++ b/tests/baselines/reference/elidingImportNames.js @@ -2,10 +2,10 @@ //// [elidingImportNames_test.ts] -import a = require('elidingImportNames_main'); // alias used in typeof +import a = require('./elidingImportNames_main'); // alias used in typeof var b = a; var x: typeof a; -import a2 = require('elidingImportNames_main1'); // alias not used in typeof +import a2 = require('./elidingImportNames_main1'); // alias not used in typeof var b2 = a2; @@ -20,8 +20,8 @@ exports.main = 10; //// [elidingImportNames_main1.js] exports.main = 10; //// [elidingImportNames_test.js] -var a = require('elidingImportNames_main'); // alias used in typeof +var a = require('./elidingImportNames_main'); // alias used in typeof var b = a; var x; -var a2 = require('elidingImportNames_main1'); // alias not used in typeof +var a2 = require('./elidingImportNames_main1'); // alias not used in typeof var b2 = a2; diff --git a/tests/baselines/reference/elidingImportNames.symbols b/tests/baselines/reference/elidingImportNames.symbols index 02646b5c3e2..d9cdcd61ffe 100644 --- a/tests/baselines/reference/elidingImportNames.symbols +++ b/tests/baselines/reference/elidingImportNames.symbols @@ -1,6 +1,6 @@ === tests/cases/compiler/elidingImportNames_test.ts === -import a = require('elidingImportNames_main'); // alias used in typeof +import a = require('./elidingImportNames_main'); // alias used in typeof >a : Symbol(a, Decl(elidingImportNames_test.ts, 0, 0)) var b = a; @@ -11,7 +11,7 @@ var x: typeof a; >x : Symbol(x, Decl(elidingImportNames_test.ts, 3, 3)) >a : Symbol(a, Decl(elidingImportNames_test.ts, 0, 0)) -import a2 = require('elidingImportNames_main1'); // alias not used in typeof +import a2 = require('./elidingImportNames_main1'); // alias not used in typeof >a2 : Symbol(a2, Decl(elidingImportNames_test.ts, 3, 16)) var b2 = a2; diff --git a/tests/baselines/reference/elidingImportNames.types b/tests/baselines/reference/elidingImportNames.types index 65bd16a6d97..947cd38f6d4 100644 --- a/tests/baselines/reference/elidingImportNames.types +++ b/tests/baselines/reference/elidingImportNames.types @@ -1,6 +1,6 @@ === tests/cases/compiler/elidingImportNames_test.ts === -import a = require('elidingImportNames_main'); // alias used in typeof +import a = require('./elidingImportNames_main'); // alias used in typeof >a : typeof a var b = a; @@ -11,7 +11,7 @@ var x: typeof a; >x : typeof a >a : typeof a -import a2 = require('elidingImportNames_main1'); // alias not used in typeof +import a2 = require('./elidingImportNames_main1'); // alias not used in typeof >a2 : typeof a2 var b2 = a2; diff --git a/tests/baselines/reference/enumFromExternalModule.js b/tests/baselines/reference/enumFromExternalModule.js index ed2a1f3926a..af04d9522b0 100644 --- a/tests/baselines/reference/enumFromExternalModule.js +++ b/tests/baselines/reference/enumFromExternalModule.js @@ -5,7 +5,7 @@ export enum Mode { Open } //// [enumFromExternalModule_1.ts] /// -import f = require('enumFromExternalModule_0'); +import f = require('./enumFromExternalModule_0'); var x = f.Mode.Open; @@ -17,5 +17,5 @@ var x = f.Mode.Open; var Mode = exports.Mode; //// [enumFromExternalModule_1.js] /// -var f = require('enumFromExternalModule_0'); +var f = require('./enumFromExternalModule_0'); var x = f.Mode.Open; diff --git a/tests/baselines/reference/enumFromExternalModule.symbols b/tests/baselines/reference/enumFromExternalModule.symbols index 90ff7cd7aac..3f2b1de5293 100644 --- a/tests/baselines/reference/enumFromExternalModule.symbols +++ b/tests/baselines/reference/enumFromExternalModule.symbols @@ -1,6 +1,6 @@ === tests/cases/compiler/enumFromExternalModule_1.ts === /// -import f = require('enumFromExternalModule_0'); +import f = require('./enumFromExternalModule_0'); >f : Symbol(f, Decl(enumFromExternalModule_1.ts, 0, 0)) var x = f.Mode.Open; diff --git a/tests/baselines/reference/enumFromExternalModule.types b/tests/baselines/reference/enumFromExternalModule.types index 554ac17ec67..05555572aa7 100644 --- a/tests/baselines/reference/enumFromExternalModule.types +++ b/tests/baselines/reference/enumFromExternalModule.types @@ -1,6 +1,6 @@ === tests/cases/compiler/enumFromExternalModule_1.ts === /// -import f = require('enumFromExternalModule_0'); +import f = require('./enumFromExternalModule_0'); >f : typeof f var x = f.Mode.Open; diff --git a/tests/baselines/reference/errorsOnImportedSymbol.errors.txt b/tests/baselines/reference/errorsOnImportedSymbol.errors.txt index ec108d48881..19839e4e544 100644 --- a/tests/baselines/reference/errorsOnImportedSymbol.errors.txt +++ b/tests/baselines/reference/errorsOnImportedSymbol.errors.txt @@ -3,7 +3,7 @@ tests/cases/compiler/errorsOnImportedSymbol_1.ts(3,9): error TS2304: Cannot find ==== tests/cases/compiler/errorsOnImportedSymbol_1.ts (2 errors) ==== - import Sammy = require("errorsOnImportedSymbol_0"); + import Sammy = require("./errorsOnImportedSymbol_0"); var x = new Sammy.Sammy(); ~~~~~ !!! error TS2304: Cannot find name 'Sammy'. diff --git a/tests/baselines/reference/errorsOnImportedSymbol.js b/tests/baselines/reference/errorsOnImportedSymbol.js index 6a001bcd0f1..2c991ecd821 100644 --- a/tests/baselines/reference/errorsOnImportedSymbol.js +++ b/tests/baselines/reference/errorsOnImportedSymbol.js @@ -9,7 +9,7 @@ interface Sammy { export = Sammy; //// [errorsOnImportedSymbol_1.ts] -import Sammy = require("errorsOnImportedSymbol_0"); +import Sammy = require("./errorsOnImportedSymbol_0"); var x = new Sammy.Sammy(); var y = Sammy.Sammy(); diff --git a/tests/baselines/reference/es6ExportAllInEs5.js b/tests/baselines/reference/es6ExportAllInEs5.js index 1be3fa1f1b2..73689019ed4 100644 --- a/tests/baselines/reference/es6ExportAllInEs5.js +++ b/tests/baselines/reference/es6ExportAllInEs5.js @@ -14,7 +14,7 @@ export module uninstantiated { } //// [client.ts] -export * from "server"; +export * from "./server"; //// [server.js] var c = (function () { @@ -32,7 +32,7 @@ exports.x = 10; function __export(m) { for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p]; } -__export(require("server")); +__export(require("./server")); //// [server.d.ts] @@ -47,4 +47,4 @@ export declare var x: number; export declare module uninstantiated { } //// [client.d.ts] -export * from "server"; +export * from "./server"; diff --git a/tests/baselines/reference/es6ExportAllInEs5.symbols b/tests/baselines/reference/es6ExportAllInEs5.symbols index c2a575f5e5c..26d47f63af3 100644 --- a/tests/baselines/reference/es6ExportAllInEs5.symbols +++ b/tests/baselines/reference/es6ExportAllInEs5.symbols @@ -20,5 +20,5 @@ export module uninstantiated { } === tests/cases/compiler/client.ts === -export * from "server"; +export * from "./server"; No type information for this code. \ No newline at end of file diff --git a/tests/baselines/reference/es6ExportAllInEs5.types b/tests/baselines/reference/es6ExportAllInEs5.types index 876ff152e2c..68187384602 100644 --- a/tests/baselines/reference/es6ExportAllInEs5.types +++ b/tests/baselines/reference/es6ExportAllInEs5.types @@ -22,5 +22,5 @@ export module uninstantiated { } === tests/cases/compiler/client.ts === -export * from "server"; +export * from "./server"; No type information for this code. \ No newline at end of file diff --git a/tests/baselines/reference/es6ExportClauseWithoutModuleSpecifierInEs5.js b/tests/baselines/reference/es6ExportClauseWithoutModuleSpecifierInEs5.js index 6250e0ce326..63ac2c04b3e 100644 --- a/tests/baselines/reference/es6ExportClauseWithoutModuleSpecifierInEs5.js +++ b/tests/baselines/reference/es6ExportClauseWithoutModuleSpecifierInEs5.js @@ -14,11 +14,11 @@ export module uninstantiated { } //// [client.ts] -export { c } from "server"; -export { c as c2 } from "server"; -export { i, m as instantiatedModule } from "server"; -export { uninstantiated } from "server"; -export { x } from "server"; +export { c } from "./server"; +export { c as c2 } from "./server"; +export { i, m as instantiatedModule } from "./server"; +export { uninstantiated } from "./server"; +export { x } from "./server"; //// [server.js] var c = (function () { @@ -33,13 +33,13 @@ var m; })(m = exports.m || (exports.m = {})); exports.x = 10; //// [client.js] -var server_1 = require("server"); +var server_1 = require("./server"); exports.c = server_1.c; -var server_2 = require("server"); +var server_2 = require("./server"); exports.c2 = server_2.c; -var server_3 = require("server"); +var server_3 = require("./server"); exports.instantiatedModule = server_3.m; -var server_4 = require("server"); +var server_4 = require("./server"); exports.x = server_4.x; @@ -55,8 +55,8 @@ export declare var x: number; export declare module uninstantiated { } //// [client.d.ts] -export { c } from "server"; -export { c as c2 } from "server"; -export { i, m as instantiatedModule } from "server"; -export { uninstantiated } from "server"; -export { x } from "server"; +export { c } from "./server"; +export { c as c2 } from "./server"; +export { i, m as instantiatedModule } from "./server"; +export { uninstantiated } from "./server"; +export { x } from "./server"; diff --git a/tests/baselines/reference/es6ExportClauseWithoutModuleSpecifierInEs5.symbols b/tests/baselines/reference/es6ExportClauseWithoutModuleSpecifierInEs5.symbols index 731a0fdcc30..c8e279e65bf 100644 --- a/tests/baselines/reference/es6ExportClauseWithoutModuleSpecifierInEs5.symbols +++ b/tests/baselines/reference/es6ExportClauseWithoutModuleSpecifierInEs5.symbols @@ -20,21 +20,21 @@ export module uninstantiated { } === tests/cases/compiler/client.ts === -export { c } from "server"; +export { c } from "./server"; >c : Symbol(c, Decl(client.ts, 0, 8)) -export { c as c2 } from "server"; +export { c as c2 } from "./server"; >c : Symbol(c2, Decl(client.ts, 1, 8)) >c2 : Symbol(c2, Decl(client.ts, 1, 8)) -export { i, m as instantiatedModule } from "server"; +export { i, m as instantiatedModule } from "./server"; >i : Symbol(i, Decl(client.ts, 2, 8)) >m : Symbol(instantiatedModule, Decl(client.ts, 2, 11)) >instantiatedModule : Symbol(instantiatedModule, Decl(client.ts, 2, 11)) -export { uninstantiated } from "server"; +export { uninstantiated } from "./server"; >uninstantiated : Symbol(uninstantiated, Decl(client.ts, 3, 8)) -export { x } from "server"; +export { x } from "./server"; >x : Symbol(x, Decl(client.ts, 4, 8)) diff --git a/tests/baselines/reference/es6ExportClauseWithoutModuleSpecifierInEs5.types b/tests/baselines/reference/es6ExportClauseWithoutModuleSpecifierInEs5.types index 6b621f4c777..4bd93b39031 100644 --- a/tests/baselines/reference/es6ExportClauseWithoutModuleSpecifierInEs5.types +++ b/tests/baselines/reference/es6ExportClauseWithoutModuleSpecifierInEs5.types @@ -22,21 +22,21 @@ export module uninstantiated { } === tests/cases/compiler/client.ts === -export { c } from "server"; +export { c } from "./server"; >c : typeof c -export { c as c2 } from "server"; +export { c as c2 } from "./server"; >c : typeof c >c2 : typeof c -export { i, m as instantiatedModule } from "server"; +export { i, m as instantiatedModule } from "./server"; >i : any >m : typeof m >instantiatedModule : typeof m -export { uninstantiated } from "server"; +export { uninstantiated } from "./server"; >uninstantiated : any -export { x } from "server"; +export { x } from "./server"; >x : number diff --git a/tests/baselines/reference/es6ImportDefaultBindingDts.js b/tests/baselines/reference/es6ImportDefaultBindingDts.js index a5e8d509da1..5593d762f85 100644 --- a/tests/baselines/reference/es6ImportDefaultBindingDts.js +++ b/tests/baselines/reference/es6ImportDefaultBindingDts.js @@ -6,9 +6,9 @@ class c { } export default c; //// [client.ts] -import defaultBinding from "server"; +import defaultBinding from "./server"; export var x = new defaultBinding(); -import defaultBinding2 from "server"; // elide this import since defaultBinding2 is not used +import defaultBinding2 from "./server"; // elide this import since defaultBinding2 is not used //// [server.js] @@ -20,7 +20,7 @@ var c = (function () { Object.defineProperty(exports, "__esModule", { value: true }); exports.default = c; //// [client.js] -var server_1 = require("server"); +var server_1 = require("./server"); exports.x = new server_1.default(); @@ -29,5 +29,5 @@ declare class c { } export default c; //// [client.d.ts] -import defaultBinding from "server"; +import defaultBinding from "./server"; export declare var x: defaultBinding; diff --git a/tests/baselines/reference/es6ImportDefaultBindingDts.symbols b/tests/baselines/reference/es6ImportDefaultBindingDts.symbols index 1ca93aa6641..f25be3eacad 100644 --- a/tests/baselines/reference/es6ImportDefaultBindingDts.symbols +++ b/tests/baselines/reference/es6ImportDefaultBindingDts.symbols @@ -7,13 +7,13 @@ export default c; >c : Symbol(c, Decl(server.ts, 0, 0)) === tests/cases/compiler/client.ts === -import defaultBinding from "server"; +import defaultBinding from "./server"; >defaultBinding : Symbol(defaultBinding, Decl(client.ts, 0, 6)) export var x = new defaultBinding(); >x : Symbol(x, Decl(client.ts, 1, 10)) >defaultBinding : Symbol(defaultBinding, Decl(client.ts, 0, 6)) -import defaultBinding2 from "server"; // elide this import since defaultBinding2 is not used +import defaultBinding2 from "./server"; // elide this import since defaultBinding2 is not used >defaultBinding2 : Symbol(defaultBinding2, Decl(client.ts, 2, 6)) diff --git a/tests/baselines/reference/es6ImportDefaultBindingDts.types b/tests/baselines/reference/es6ImportDefaultBindingDts.types index 65754d80680..8543c6845b2 100644 --- a/tests/baselines/reference/es6ImportDefaultBindingDts.types +++ b/tests/baselines/reference/es6ImportDefaultBindingDts.types @@ -7,7 +7,7 @@ export default c; >c : c === tests/cases/compiler/client.ts === -import defaultBinding from "server"; +import defaultBinding from "./server"; >defaultBinding : typeof defaultBinding export var x = new defaultBinding(); @@ -15,6 +15,6 @@ export var x = new defaultBinding(); >new defaultBinding() : defaultBinding >defaultBinding : typeof defaultBinding -import defaultBinding2 from "server"; // elide this import since defaultBinding2 is not used +import defaultBinding2 from "./server"; // elide this import since defaultBinding2 is not used >defaultBinding2 : typeof defaultBinding diff --git a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImport.errors.txt b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImport.errors.txt index 2688d4af06f..b0b7465477b 100644 --- a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImport.errors.txt +++ b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImport.errors.txt @@ -10,16 +10,16 @@ error TS1204: Cannot compile modules into 'commonjs', 'amd', 'system' or 'umd' w export default {}; ==== tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImport_1.ts (0 errors) ==== - import defaultBinding1, { } from "es6ImportDefaultBindingFollowedWithNamedImport_0"; - import defaultBinding2, { a } from "es6ImportDefaultBindingFollowedWithNamedImport_0"; + import defaultBinding1, { } from "./es6ImportDefaultBindingFollowedWithNamedImport_0"; + import defaultBinding2, { a } from "./es6ImportDefaultBindingFollowedWithNamedImport_0"; var x1: number = a; - import defaultBinding3, { a as b } from "es6ImportDefaultBindingFollowedWithNamedImport_0"; + import defaultBinding3, { a as b } from "./es6ImportDefaultBindingFollowedWithNamedImport_0"; var x1: number = b; - import defaultBinding4, { x, a as y } from "es6ImportDefaultBindingFollowedWithNamedImport_0"; + import defaultBinding4, { x, a as y } from "./es6ImportDefaultBindingFollowedWithNamedImport_0"; var x1: number = x; var x1: number = y; - import defaultBinding5, { x as z, } from "es6ImportDefaultBindingFollowedWithNamedImport_0"; + import defaultBinding5, { x as z, } from "./es6ImportDefaultBindingFollowedWithNamedImport_0"; var x1: number = z; - import defaultBinding6, { m, } from "es6ImportDefaultBindingFollowedWithNamedImport_0"; + import defaultBinding6, { m, } from "./es6ImportDefaultBindingFollowedWithNamedImport_0"; var x1: number = m; \ No newline at end of file diff --git a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImport.js b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImport.js index 641941db9e5..554fecf9116 100644 --- a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImport.js +++ b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImport.js @@ -8,17 +8,17 @@ export var m = a; export default {}; //// [es6ImportDefaultBindingFollowedWithNamedImport_1.ts] -import defaultBinding1, { } from "es6ImportDefaultBindingFollowedWithNamedImport_0"; -import defaultBinding2, { a } from "es6ImportDefaultBindingFollowedWithNamedImport_0"; +import defaultBinding1, { } from "./es6ImportDefaultBindingFollowedWithNamedImport_0"; +import defaultBinding2, { a } from "./es6ImportDefaultBindingFollowedWithNamedImport_0"; var x1: number = a; -import defaultBinding3, { a as b } from "es6ImportDefaultBindingFollowedWithNamedImport_0"; +import defaultBinding3, { a as b } from "./es6ImportDefaultBindingFollowedWithNamedImport_0"; var x1: number = b; -import defaultBinding4, { x, a as y } from "es6ImportDefaultBindingFollowedWithNamedImport_0"; +import defaultBinding4, { x, a as y } from "./es6ImportDefaultBindingFollowedWithNamedImport_0"; var x1: number = x; var x1: number = y; -import defaultBinding5, { x as z, } from "es6ImportDefaultBindingFollowedWithNamedImport_0"; +import defaultBinding5, { x as z, } from "./es6ImportDefaultBindingFollowedWithNamedImport_0"; var x1: number = z; -import defaultBinding6, { m, } from "es6ImportDefaultBindingFollowedWithNamedImport_0"; +import defaultBinding6, { m, } from "./es6ImportDefaultBindingFollowedWithNamedImport_0"; var x1: number = m; @@ -28,16 +28,16 @@ export var x = a; export var m = a; export default {}; //// [es6ImportDefaultBindingFollowedWithNamedImport_1.js] -import { a } from "es6ImportDefaultBindingFollowedWithNamedImport_0"; +import { a } from "./es6ImportDefaultBindingFollowedWithNamedImport_0"; var x1 = a; -import { a as b } from "es6ImportDefaultBindingFollowedWithNamedImport_0"; +import { a as b } from "./es6ImportDefaultBindingFollowedWithNamedImport_0"; var x1 = b; -import { x, a as y } from "es6ImportDefaultBindingFollowedWithNamedImport_0"; +import { x, a as y } from "./es6ImportDefaultBindingFollowedWithNamedImport_0"; var x1 = x; var x1 = y; -import { x as z } from "es6ImportDefaultBindingFollowedWithNamedImport_0"; +import { x as z } from "./es6ImportDefaultBindingFollowedWithNamedImport_0"; var x1 = z; -import { m } from "es6ImportDefaultBindingFollowedWithNamedImport_0"; +import { m } from "./es6ImportDefaultBindingFollowedWithNamedImport_0"; var x1 = m; diff --git a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImport1InEs5.errors.txt b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImport1InEs5.errors.txt index 5809e0874dc..c62ecb70c58 100644 --- a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImport1InEs5.errors.txt +++ b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImport1InEs5.errors.txt @@ -12,27 +12,27 @@ tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImport1InEs5_1.ts(1 export default a; ==== tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImport1InEs5_1.ts (6 errors) ==== - import defaultBinding1, { } from "es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0"; + import defaultBinding1, { } from "./es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0"; var x: number = defaultBinding1; - import defaultBinding2, { a } from "es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0"; + import defaultBinding2, { a } from "./es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0"; ~ !!! error TS2305: Module '"tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0"' has no exported member 'a'. var x: number = defaultBinding2; - import defaultBinding3, { a as b } from "es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0"; + import defaultBinding3, { a as b } from "./es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0"; ~ !!! error TS2305: Module '"tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0"' has no exported member 'a'. var x: number = defaultBinding3; - import defaultBinding4, { x, a as y } from "es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0"; + import defaultBinding4, { x, a as y } from "./es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0"; ~ !!! error TS2305: Module '"tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0"' has no exported member 'x'. ~ !!! error TS2305: Module '"tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0"' has no exported member 'a'. var x: number = defaultBinding4; - import defaultBinding5, { x as z, } from "es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0"; + import defaultBinding5, { x as z, } from "./es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0"; ~ !!! error TS2305: Module '"tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0"' has no exported member 'x'. var x: number = defaultBinding5; - import defaultBinding6, { m, } from "es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0"; + import defaultBinding6, { m, } from "./es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0"; ~ !!! error TS2305: Module '"tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0"' has no exported member 'm'. var x: number = defaultBinding6; diff --git a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImport1InEs5.js b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImport1InEs5.js index 7090b7a0663..7eda76622de 100644 --- a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImport1InEs5.js +++ b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImport1InEs5.js @@ -6,17 +6,17 @@ var a = 10; export default a; //// [es6ImportDefaultBindingFollowedWithNamedImport1InEs5_1.ts] -import defaultBinding1, { } from "es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0"; +import defaultBinding1, { } from "./es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0"; var x: number = defaultBinding1; -import defaultBinding2, { a } from "es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0"; +import defaultBinding2, { a } from "./es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0"; var x: number = defaultBinding2; -import defaultBinding3, { a as b } from "es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0"; +import defaultBinding3, { a as b } from "./es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0"; var x: number = defaultBinding3; -import defaultBinding4, { x, a as y } from "es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0"; +import defaultBinding4, { x, a as y } from "./es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0"; var x: number = defaultBinding4; -import defaultBinding5, { x as z, } from "es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0"; +import defaultBinding5, { x as z, } from "./es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0"; var x: number = defaultBinding5; -import defaultBinding6, { m, } from "es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0"; +import defaultBinding6, { m, } from "./es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0"; var x: number = defaultBinding6; @@ -25,17 +25,17 @@ var a = 10; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = a; //// [es6ImportDefaultBindingFollowedWithNamedImport1InEs5_1.js] -var es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0_1 = require("es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0"); +var es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0_1 = require("./es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0"); var x = es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0_1.default; -var es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0_2 = require("es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0"); +var es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0_2 = require("./es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0"); var x = es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0_2.default; -var es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0_3 = require("es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0"); +var es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0_3 = require("./es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0"); var x = es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0_3.default; -var es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0_4 = require("es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0"); +var es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0_4 = require("./es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0"); var x = es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0_4.default; -var es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0_5 = require("es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0"); +var es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0_5 = require("./es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0"); var x = es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0_5.default; -var es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0_6 = require("es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0"); +var es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0_6 = require("./es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0"); var x = es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0_6.default; diff --git a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImport1WithExport.errors.txt b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImport1WithExport.errors.txt index aa9e0cb3af3..76c424a74d4 100644 --- a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImport1WithExport.errors.txt +++ b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImport1WithExport.errors.txt @@ -18,23 +18,23 @@ tests/cases/compiler/client.ts(11,34): error TS2305: Module '"tests/cases/compil export default a; ==== tests/cases/compiler/client.ts (12 errors) ==== - export import defaultBinding1, { } from "server"; + export import defaultBinding1, { } from "./server"; ~~~~~~ !!! error TS1191: An import declaration cannot have modifiers. export var x1: number = defaultBinding1; - export import defaultBinding2, { a } from "server"; + export import defaultBinding2, { a } from "./server"; ~~~~~~ !!! error TS1191: An import declaration cannot have modifiers. ~ !!! error TS2305: Module '"tests/cases/compiler/server"' has no exported member 'a'. export var x1: number = defaultBinding2; - export import defaultBinding3, { a as b } from "server"; + export import defaultBinding3, { a as b } from "./server"; ~~~~~~ !!! error TS1191: An import declaration cannot have modifiers. ~ !!! error TS2305: Module '"tests/cases/compiler/server"' has no exported member 'a'. export var x1: number = defaultBinding3; - export import defaultBinding4, { x, a as y } from "server"; + export import defaultBinding4, { x, a as y } from "./server"; ~~~~~~ !!! error TS1191: An import declaration cannot have modifiers. ~ @@ -42,13 +42,13 @@ tests/cases/compiler/client.ts(11,34): error TS2305: Module '"tests/cases/compil ~ !!! error TS2305: Module '"tests/cases/compiler/server"' has no exported member 'a'. export var x1: number = defaultBinding4; - export import defaultBinding5, { x as z, } from "server"; + export import defaultBinding5, { x as z, } from "./server"; ~~~~~~ !!! error TS1191: An import declaration cannot have modifiers. ~ !!! error TS2305: Module '"tests/cases/compiler/server"' has no exported member 'x'. export var x1: number = defaultBinding5; - export import defaultBinding6, { m, } from "server"; + export import defaultBinding6, { m, } from "./server"; ~~~~~~ !!! error TS1191: An import declaration cannot have modifiers. ~ diff --git a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImport1WithExport.js b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImport1WithExport.js index 2b0e3ebbeb5..b83571066f0 100644 --- a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImport1WithExport.js +++ b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImport1WithExport.js @@ -6,17 +6,17 @@ var a = 10; export default a; //// [client.ts] -export import defaultBinding1, { } from "server"; +export import defaultBinding1, { } from "./server"; export var x1: number = defaultBinding1; -export import defaultBinding2, { a } from "server"; +export import defaultBinding2, { a } from "./server"; export var x1: number = defaultBinding2; -export import defaultBinding3, { a as b } from "server"; +export import defaultBinding3, { a as b } from "./server"; export var x1: number = defaultBinding3; -export import defaultBinding4, { x, a as y } from "server"; +export import defaultBinding4, { x, a as y } from "./server"; export var x1: number = defaultBinding4; -export import defaultBinding5, { x as z, } from "server"; +export import defaultBinding5, { x as z, } from "./server"; export var x1: number = defaultBinding5; -export import defaultBinding6, { m, } from "server"; +export import defaultBinding6, { m, } from "./server"; export var x1: number = defaultBinding6; @@ -25,17 +25,17 @@ var a = 10; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = a; //// [client.js] -var server_1 = require("server"); +var server_1 = require("./server"); exports.x1 = server_1.default; -var server_2 = require("server"); +var server_2 = require("./server"); exports.x1 = server_2.default; -var server_3 = require("server"); +var server_3 = require("./server"); exports.x1 = server_3.default; -var server_4 = require("server"); +var server_4 = require("./server"); exports.x1 = server_4.default; -var server_5 = require("server"); +var server_5 = require("./server"); exports.x1 = server_5.default; -var server_6 = require("server"); +var server_6 = require("./server"); exports.x1 = server_6.default; diff --git a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImportDts.errors.txt b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImportDts.errors.txt index 451543d78f5..47e0cb347f3 100644 --- a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImportDts.errors.txt +++ b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImportDts.errors.txt @@ -16,27 +16,27 @@ tests/cases/compiler/client.ts(11,8): error TS1192: Module '"tests/cases/compile export class x11 { } ==== tests/cases/compiler/client.ts (6 errors) ==== - import defaultBinding1, { } from "server"; + import defaultBinding1, { } from "./server"; ~~~~~~~~~~~~~~~ !!! error TS1192: Module '"tests/cases/compiler/server"' has no default export. - import defaultBinding2, { a } from "server"; + import defaultBinding2, { a } from "./server"; ~~~~~~~~~~~~~~~ !!! error TS1192: Module '"tests/cases/compiler/server"' has no default export. export var x1 = new a(); - import defaultBinding3, { a11 as b } from "server"; + import defaultBinding3, { a11 as b } from "./server"; ~~~~~~~~~~~~~~~ !!! error TS1192: Module '"tests/cases/compiler/server"' has no default export. export var x2 = new b(); - import defaultBinding4, { x, a12 as y } from "server"; + import defaultBinding4, { x, a12 as y } from "./server"; ~~~~~~~~~~~~~~~ !!! error TS1192: Module '"tests/cases/compiler/server"' has no default export. export var x4 = new x(); export var x5 = new y(); - import defaultBinding5, { x11 as z, } from "server"; + import defaultBinding5, { x11 as z, } from "./server"; ~~~~~~~~~~~~~~~ !!! error TS1192: Module '"tests/cases/compiler/server"' has no default export. export var x3 = new z(); - import defaultBinding6, { m, } from "server"; + import defaultBinding6, { m, } from "./server"; ~~~~~~~~~~~~~~~ !!! error TS1192: Module '"tests/cases/compiler/server"' has no default export. export var x6 = new m(); diff --git a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImportDts.js b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImportDts.js index 8cf9ab1ffb1..9314190e786 100644 --- a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImportDts.js +++ b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImportDts.js @@ -10,17 +10,17 @@ export class a12 { } export class x11 { } //// [client.ts] -import defaultBinding1, { } from "server"; -import defaultBinding2, { a } from "server"; +import defaultBinding1, { } from "./server"; +import defaultBinding2, { a } from "./server"; export var x1 = new a(); -import defaultBinding3, { a11 as b } from "server"; +import defaultBinding3, { a11 as b } from "./server"; export var x2 = new b(); -import defaultBinding4, { x, a12 as y } from "server"; +import defaultBinding4, { x, a12 as y } from "./server"; export var x4 = new x(); export var x5 = new y(); -import defaultBinding5, { x11 as z, } from "server"; +import defaultBinding5, { x11 as z, } from "./server"; export var x3 = new z(); -import defaultBinding6, { m, } from "server"; +import defaultBinding6, { m, } from "./server"; export var x6 = new m(); @@ -62,16 +62,16 @@ var x11 = (function () { })(); exports.x11 = x11; //// [client.js] -var server_1 = require("server"); +var server_1 = require("./server"); exports.x1 = new server_1.a(); -var server_2 = require("server"); +var server_2 = require("./server"); exports.x2 = new server_2.a11(); -var server_3 = require("server"); +var server_3 = require("./server"); exports.x4 = new server_3.x(); exports.x5 = new server_3.a12(); -var server_4 = require("server"); +var server_4 = require("./server"); exports.x3 = new server_4.x11(); -var server_5 = require("server"); +var server_5 = require("./server"); exports.x6 = new server_5.m(); @@ -89,14 +89,14 @@ export declare class a12 { export declare class x11 { } //// [client.d.ts] -import { a } from "server"; +import { a } from "./server"; export declare var x1: a; -import { a11 as b } from "server"; +import { a11 as b } from "./server"; export declare var x2: b; -import { x, a12 as y } from "server"; +import { x, a12 as y } from "./server"; export declare var x4: x; export declare var x5: y; -import { x11 as z } from "server"; +import { x11 as z } from "./server"; export declare var x3: z; -import { m } from "server"; +import { m } from "./server"; export declare var x6: m; diff --git a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImportDts1.errors.txt b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImportDts1.errors.txt index 0e259f142b6..e939398632c 100644 --- a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImportDts1.errors.txt +++ b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImportDts1.errors.txt @@ -12,27 +12,27 @@ tests/cases/compiler/client.ts(11,27): error TS2305: Module '"tests/cases/compil export default a; ==== tests/cases/compiler/client.ts (6 errors) ==== - import defaultBinding1, { } from "server"; + import defaultBinding1, { } from "./server"; export var x1 = new defaultBinding1(); - import defaultBinding2, { a } from "server"; + import defaultBinding2, { a } from "./server"; ~ !!! error TS2305: Module '"tests/cases/compiler/server"' has no exported member 'a'. export var x2 = new defaultBinding2(); - import defaultBinding3, { a as b } from "server"; + import defaultBinding3, { a as b } from "./server"; ~ !!! error TS2305: Module '"tests/cases/compiler/server"' has no exported member 'a'. export var x3 = new defaultBinding3(); - import defaultBinding4, { x, a as y } from "server"; + import defaultBinding4, { x, a as y } from "./server"; ~ !!! error TS2305: Module '"tests/cases/compiler/server"' has no exported member 'x'. ~ !!! error TS2305: Module '"tests/cases/compiler/server"' has no exported member 'a'. export var x4 = new defaultBinding4(); - import defaultBinding5, { x as z, } from "server"; + import defaultBinding5, { x as z, } from "./server"; ~ !!! error TS2305: Module '"tests/cases/compiler/server"' has no exported member 'x'. export var x5 = new defaultBinding5(); - import defaultBinding6, { m, } from "server"; + import defaultBinding6, { m, } from "./server"; ~ !!! error TS2305: Module '"tests/cases/compiler/server"' has no exported member 'm'. export var x6 = new defaultBinding6(); \ No newline at end of file diff --git a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImportDts1.js b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImportDts1.js index dad034c618c..71d35fd85a1 100644 --- a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImportDts1.js +++ b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImportDts1.js @@ -6,17 +6,17 @@ class a { } export default a; //// [client.ts] -import defaultBinding1, { } from "server"; +import defaultBinding1, { } from "./server"; export var x1 = new defaultBinding1(); -import defaultBinding2, { a } from "server"; +import defaultBinding2, { a } from "./server"; export var x2 = new defaultBinding2(); -import defaultBinding3, { a as b } from "server"; +import defaultBinding3, { a as b } from "./server"; export var x3 = new defaultBinding3(); -import defaultBinding4, { x, a as y } from "server"; +import defaultBinding4, { x, a as y } from "./server"; export var x4 = new defaultBinding4(); -import defaultBinding5, { x as z, } from "server"; +import defaultBinding5, { x as z, } from "./server"; export var x5 = new defaultBinding5(); -import defaultBinding6, { m, } from "server"; +import defaultBinding6, { m, } from "./server"; export var x6 = new defaultBinding6(); //// [server.js] @@ -28,17 +28,17 @@ var a = (function () { Object.defineProperty(exports, "__esModule", { value: true }); exports.default = a; //// [client.js] -var server_1 = require("server"); +var server_1 = require("./server"); exports.x1 = new server_1.default(); -var server_2 = require("server"); +var server_2 = require("./server"); exports.x2 = new server_2.default(); -var server_3 = require("server"); +var server_3 = require("./server"); exports.x3 = new server_3.default(); -var server_4 = require("server"); +var server_4 = require("./server"); exports.x4 = new server_4.default(); -var server_5 = require("server"); +var server_5 = require("./server"); exports.x5 = new server_5.default(); -var server_6 = require("server"); +var server_6 = require("./server"); exports.x6 = new server_6.default(); @@ -47,7 +47,7 @@ declare class a { } export default a; //// [client.d.ts] -import defaultBinding1 from "server"; +import defaultBinding1 from "./server"; export declare var x1: defaultBinding1; export declare var x2: defaultBinding1; export declare var x3: defaultBinding1; diff --git a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImportInEs5.errors.txt b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImportInEs5.errors.txt index c1c28416ec7..7c5080241f1 100644 --- a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImportInEs5.errors.txt +++ b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImportInEs5.errors.txt @@ -13,27 +13,27 @@ tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImportInEs5_1.ts(11 export var m = a; ==== tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImportInEs5_1.ts (6 errors) ==== - import defaultBinding1, { } from "es6ImportDefaultBindingFollowedWithNamedImportInEs5_0"; + import defaultBinding1, { } from "./es6ImportDefaultBindingFollowedWithNamedImportInEs5_0"; ~~~~~~~~~~~~~~~ !!! error TS1192: Module '"tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImportInEs5_0"' has no default export. - import defaultBinding2, { a } from "es6ImportDefaultBindingFollowedWithNamedImportInEs5_0"; + import defaultBinding2, { a } from "./es6ImportDefaultBindingFollowedWithNamedImportInEs5_0"; ~~~~~~~~~~~~~~~ !!! error TS1192: Module '"tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImportInEs5_0"' has no default export. var x1: number = a; - import defaultBinding3, { a as b } from "es6ImportDefaultBindingFollowedWithNamedImportInEs5_0"; + import defaultBinding3, { a as b } from "./es6ImportDefaultBindingFollowedWithNamedImportInEs5_0"; ~~~~~~~~~~~~~~~ !!! error TS1192: Module '"tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImportInEs5_0"' has no default export. var x1: number = b; - import defaultBinding4, { x, a as y } from "es6ImportDefaultBindingFollowedWithNamedImportInEs5_0"; + import defaultBinding4, { x, a as y } from "./es6ImportDefaultBindingFollowedWithNamedImportInEs5_0"; ~~~~~~~~~~~~~~~ !!! error TS1192: Module '"tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImportInEs5_0"' has no default export. var x1: number = x; var x1: number = y; - import defaultBinding5, { x as z, } from "es6ImportDefaultBindingFollowedWithNamedImportInEs5_0"; + import defaultBinding5, { x as z, } from "./es6ImportDefaultBindingFollowedWithNamedImportInEs5_0"; ~~~~~~~~~~~~~~~ !!! error TS1192: Module '"tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImportInEs5_0"' has no default export. var x1: number = z; - import defaultBinding6, { m, } from "es6ImportDefaultBindingFollowedWithNamedImportInEs5_0"; + import defaultBinding6, { m, } from "./es6ImportDefaultBindingFollowedWithNamedImportInEs5_0"; ~~~~~~~~~~~~~~~ !!! error TS1192: Module '"tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImportInEs5_0"' has no default export. var x1: number = m; diff --git a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImportInEs5.js b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImportInEs5.js index 1c65fadbe1d..9674f8c12f4 100644 --- a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImportInEs5.js +++ b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImportInEs5.js @@ -7,17 +7,17 @@ export var x = a; export var m = a; //// [es6ImportDefaultBindingFollowedWithNamedImportInEs5_1.ts] -import defaultBinding1, { } from "es6ImportDefaultBindingFollowedWithNamedImportInEs5_0"; -import defaultBinding2, { a } from "es6ImportDefaultBindingFollowedWithNamedImportInEs5_0"; +import defaultBinding1, { } from "./es6ImportDefaultBindingFollowedWithNamedImportInEs5_0"; +import defaultBinding2, { a } from "./es6ImportDefaultBindingFollowedWithNamedImportInEs5_0"; var x1: number = a; -import defaultBinding3, { a as b } from "es6ImportDefaultBindingFollowedWithNamedImportInEs5_0"; +import defaultBinding3, { a as b } from "./es6ImportDefaultBindingFollowedWithNamedImportInEs5_0"; var x1: number = b; -import defaultBinding4, { x, a as y } from "es6ImportDefaultBindingFollowedWithNamedImportInEs5_0"; +import defaultBinding4, { x, a as y } from "./es6ImportDefaultBindingFollowedWithNamedImportInEs5_0"; var x1: number = x; var x1: number = y; -import defaultBinding5, { x as z, } from "es6ImportDefaultBindingFollowedWithNamedImportInEs5_0"; +import defaultBinding5, { x as z, } from "./es6ImportDefaultBindingFollowedWithNamedImportInEs5_0"; var x1: number = z; -import defaultBinding6, { m, } from "es6ImportDefaultBindingFollowedWithNamedImportInEs5_0"; +import defaultBinding6, { m, } from "./es6ImportDefaultBindingFollowedWithNamedImportInEs5_0"; var x1: number = m; @@ -26,16 +26,16 @@ exports.a = 10; exports.x = exports.a; exports.m = exports.a; //// [es6ImportDefaultBindingFollowedWithNamedImportInEs5_1.js] -var es6ImportDefaultBindingFollowedWithNamedImportInEs5_0_1 = require("es6ImportDefaultBindingFollowedWithNamedImportInEs5_0"); +var es6ImportDefaultBindingFollowedWithNamedImportInEs5_0_1 = require("./es6ImportDefaultBindingFollowedWithNamedImportInEs5_0"); var x1 = es6ImportDefaultBindingFollowedWithNamedImportInEs5_0_1.a; -var es6ImportDefaultBindingFollowedWithNamedImportInEs5_0_2 = require("es6ImportDefaultBindingFollowedWithNamedImportInEs5_0"); +var es6ImportDefaultBindingFollowedWithNamedImportInEs5_0_2 = require("./es6ImportDefaultBindingFollowedWithNamedImportInEs5_0"); var x1 = es6ImportDefaultBindingFollowedWithNamedImportInEs5_0_2.a; -var es6ImportDefaultBindingFollowedWithNamedImportInEs5_0_3 = require("es6ImportDefaultBindingFollowedWithNamedImportInEs5_0"); +var es6ImportDefaultBindingFollowedWithNamedImportInEs5_0_3 = require("./es6ImportDefaultBindingFollowedWithNamedImportInEs5_0"); var x1 = es6ImportDefaultBindingFollowedWithNamedImportInEs5_0_3.x; var x1 = es6ImportDefaultBindingFollowedWithNamedImportInEs5_0_3.a; -var es6ImportDefaultBindingFollowedWithNamedImportInEs5_0_4 = require("es6ImportDefaultBindingFollowedWithNamedImportInEs5_0"); +var es6ImportDefaultBindingFollowedWithNamedImportInEs5_0_4 = require("./es6ImportDefaultBindingFollowedWithNamedImportInEs5_0"); var x1 = es6ImportDefaultBindingFollowedWithNamedImportInEs5_0_4.x; -var es6ImportDefaultBindingFollowedWithNamedImportInEs5_0_5 = require("es6ImportDefaultBindingFollowedWithNamedImportInEs5_0"); +var es6ImportDefaultBindingFollowedWithNamedImportInEs5_0_5 = require("./es6ImportDefaultBindingFollowedWithNamedImportInEs5_0"); var x1 = es6ImportDefaultBindingFollowedWithNamedImportInEs5_0_5.m; diff --git a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBinding1InEs5.js b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBinding1InEs5.js index 4a987110224..ada6e423e73 100644 --- a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBinding1InEs5.js +++ b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBinding1InEs5.js @@ -6,7 +6,7 @@ var a = 10; export default a; //// [es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5_1.ts] -import defaultBinding, * as nameSpaceBinding from "es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5_0"; +import defaultBinding, * as nameSpaceBinding from "./es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5_0"; var x: number = defaultBinding; //// [es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5_0.js] @@ -14,7 +14,7 @@ var a = 10; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = a; //// [es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5_1.js] -var es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5_0_1 = require("es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5_0"), nameSpaceBinding = es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5_0_1; +var es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5_0_1 = require("./es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5_0"), nameSpaceBinding = es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5_0_1; var x = es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5_0_1.default; diff --git a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBinding1InEs5.symbols b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBinding1InEs5.symbols index d4a9c289e60..4262dd3c61b 100644 --- a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBinding1InEs5.symbols +++ b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBinding1InEs5.symbols @@ -7,7 +7,7 @@ export default a; >a : Symbol(a, Decl(es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5_0.ts, 1, 3)) === tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5_1.ts === -import defaultBinding, * as nameSpaceBinding from "es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5_0"; +import defaultBinding, * as nameSpaceBinding from "./es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5_0"; >defaultBinding : Symbol(defaultBinding, Decl(es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5_1.ts, 0, 6)) >nameSpaceBinding : Symbol(nameSpaceBinding, Decl(es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5_1.ts, 0, 22)) diff --git a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBinding1InEs5.types b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBinding1InEs5.types index 4a05b57e304..4f9c618f10c 100644 --- a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBinding1InEs5.types +++ b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBinding1InEs5.types @@ -8,7 +8,7 @@ export default a; >a : number === tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5_1.ts === -import defaultBinding, * as nameSpaceBinding from "es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5_0"; +import defaultBinding, * as nameSpaceBinding from "./es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5_0"; >defaultBinding : number >nameSpaceBinding : typeof nameSpaceBinding diff --git a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBindingDts.errors.txt b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBindingDts.errors.txt index 19fa0383d52..1fc12619017 100644 --- a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBindingDts.errors.txt +++ b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBindingDts.errors.txt @@ -6,7 +6,7 @@ tests/cases/compiler/client.ts(1,8): error TS1192: Module '"tests/cases/compiler export class a { } ==== tests/cases/compiler/client.ts (1 errors) ==== - import defaultBinding, * as nameSpaceBinding from "server"; + import defaultBinding, * as nameSpaceBinding from "./server"; ~~~~~~~~~~~~~~ !!! error TS1192: Module '"tests/cases/compiler/server"' has no default export. export var x = new nameSpaceBinding.a(); \ No newline at end of file diff --git a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBindingDts.js b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBindingDts.js index 31ef01c464c..93918f6171a 100644 --- a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBindingDts.js +++ b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBindingDts.js @@ -5,7 +5,7 @@ export class a { } //// [client.ts] -import defaultBinding, * as nameSpaceBinding from "server"; +import defaultBinding, * as nameSpaceBinding from "./server"; export var x = new nameSpaceBinding.a(); //// [server.js] @@ -16,7 +16,7 @@ var a = (function () { })(); exports.a = a; //// [client.js] -var server_1 = require("server"), nameSpaceBinding = server_1; +var server_1 = require("./server"), nameSpaceBinding = server_1; exports.x = new nameSpaceBinding.a(); @@ -24,5 +24,5 @@ exports.x = new nameSpaceBinding.a(); export declare class a { } //// [client.d.ts] -import * as nameSpaceBinding from "server"; +import * as nameSpaceBinding from "./server"; export declare var x: nameSpaceBinding.a; diff --git a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5.errors.txt b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5.errors.txt index dbbbf67118e..f14af87315c 100644 --- a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5.errors.txt +++ b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5.errors.txt @@ -6,7 +6,7 @@ tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5_1. export var a = 10; ==== tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5_1.ts (1 errors) ==== - import defaultBinding, * as nameSpaceBinding from "es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5_0"; + import defaultBinding, * as nameSpaceBinding from "./es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5_0"; ~~~~~~~~~~~~~~ !!! error TS1192: Module '"tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5_0"' has no default export. var x: number = nameSpaceBinding.a; \ No newline at end of file diff --git a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5.js b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5.js index 4a49d3c2d6f..49717c588b7 100644 --- a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5.js +++ b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5.js @@ -5,13 +5,13 @@ export var a = 10; //// [es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5_1.ts] -import defaultBinding, * as nameSpaceBinding from "es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5_0"; +import defaultBinding, * as nameSpaceBinding from "./es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5_0"; var x: number = nameSpaceBinding.a; //// [es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5_0.js] exports.a = 10; //// [es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5_1.js] -var es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5_0_1 = require("es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5_0"), nameSpaceBinding = es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5_0_1; +var es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5_0_1 = require("./es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5_0"), nameSpaceBinding = es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5_0_1; var x = nameSpaceBinding.a; diff --git a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBindingWithExport.errors.txt b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBindingWithExport.errors.txt index 3da1cf3fda8..d0eee527356 100644 --- a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBindingWithExport.errors.txt +++ b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBindingWithExport.errors.txt @@ -7,7 +7,7 @@ tests/cases/compiler/client.ts(1,15): error TS1192: Module '"tests/cases/compile export var a = 10; ==== tests/cases/compiler/client.ts (2 errors) ==== - export import defaultBinding, * as nameSpaceBinding from "server"; + export import defaultBinding, * as nameSpaceBinding from "./server"; ~~~~~~ !!! error TS1191: An import declaration cannot have modifiers. ~~~~~~~~~~~~~~ diff --git a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBindingWithExport.js b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBindingWithExport.js index df233fe18a5..dec9b8cfebe 100644 --- a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBindingWithExport.js +++ b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBindingWithExport.js @@ -5,13 +5,13 @@ export var a = 10; //// [client.ts] -export import defaultBinding, * as nameSpaceBinding from "server"; +export import defaultBinding, * as nameSpaceBinding from "./server"; export var x: number = nameSpaceBinding.a; //// [server.js] exports.a = 10; //// [client.js] -var server_1 = require("server"), nameSpaceBinding = server_1; +var server_1 = require("./server"), nameSpaceBinding = server_1; exports.x = nameSpaceBinding.a; diff --git a/tests/baselines/reference/es6ImportDefaultBindingInEs5.errors.txt b/tests/baselines/reference/es6ImportDefaultBindingInEs5.errors.txt index 109b322f4bb..18f634d7b73 100644 --- a/tests/baselines/reference/es6ImportDefaultBindingInEs5.errors.txt +++ b/tests/baselines/reference/es6ImportDefaultBindingInEs5.errors.txt @@ -7,6 +7,6 @@ tests/cases/compiler/es6ImportDefaultBindingInEs5_1.ts(1,8): error TS1192: Modul export = a; ==== tests/cases/compiler/es6ImportDefaultBindingInEs5_1.ts (1 errors) ==== - import defaultBinding from "es6ImportDefaultBindingInEs5_0"; + import defaultBinding from "./es6ImportDefaultBindingInEs5_0"; ~~~~~~~~~~~~~~ !!! error TS1192: Module '"tests/cases/compiler/es6ImportDefaultBindingInEs5_0"' has no default export. \ No newline at end of file diff --git a/tests/baselines/reference/es6ImportDefaultBindingInEs5.js b/tests/baselines/reference/es6ImportDefaultBindingInEs5.js index 0b703f829ca..34323b2752b 100644 --- a/tests/baselines/reference/es6ImportDefaultBindingInEs5.js +++ b/tests/baselines/reference/es6ImportDefaultBindingInEs5.js @@ -6,7 +6,7 @@ var a = 10; export = a; //// [es6ImportDefaultBindingInEs5_1.ts] -import defaultBinding from "es6ImportDefaultBindingInEs5_0"; +import defaultBinding from "./es6ImportDefaultBindingInEs5_0"; //// [es6ImportDefaultBindingInEs5_0.js] var a = 10; diff --git a/tests/baselines/reference/es6ImportDefaultBindingMergeErrors.errors.txt b/tests/baselines/reference/es6ImportDefaultBindingMergeErrors.errors.txt index cd0550609c7..8b67ddfeac3 100644 --- a/tests/baselines/reference/es6ImportDefaultBindingMergeErrors.errors.txt +++ b/tests/baselines/reference/es6ImportDefaultBindingMergeErrors.errors.txt @@ -9,18 +9,18 @@ tests/cases/compiler/es6ImportDefaultBindingMergeErrors_1.ts(8,8): error TS2300: export default a; ==== tests/cases/compiler/es6ImportDefaultBindingMergeErrors_1.ts (3 errors) ==== - import defaultBinding from "es6ImportDefaultBindingMergeErrors_0"; + import defaultBinding from "./es6ImportDefaultBindingMergeErrors_0"; interface defaultBinding { // This is ok } var x = defaultBinding; - import defaultBinding2 from "es6ImportDefaultBindingMergeErrors_0"; // Should be error + import defaultBinding2 from "./es6ImportDefaultBindingMergeErrors_0"; // Should be error ~~~~~~~~~~~~~~~ !!! error TS2440: Import declaration conflicts with local declaration of 'defaultBinding2' var defaultBinding2 = "hello world"; - import defaultBinding3 from "es6ImportDefaultBindingMergeErrors_0"; // Should be error + import defaultBinding3 from "./es6ImportDefaultBindingMergeErrors_0"; // Should be error ~~~~~~~~~~~~~~~ !!! error TS2300: Duplicate identifier 'defaultBinding3'. - import defaultBinding3 from "es6ImportDefaultBindingMergeErrors_0"; // SHould be error + import defaultBinding3 from "./es6ImportDefaultBindingMergeErrors_0"; // SHould be error ~~~~~~~~~~~~~~~ !!! error TS2300: Duplicate identifier 'defaultBinding3'. \ No newline at end of file diff --git a/tests/baselines/reference/es6ImportDefaultBindingMergeErrors.js b/tests/baselines/reference/es6ImportDefaultBindingMergeErrors.js index 10b8bec03c7..fb80fdd3e4f 100644 --- a/tests/baselines/reference/es6ImportDefaultBindingMergeErrors.js +++ b/tests/baselines/reference/es6ImportDefaultBindingMergeErrors.js @@ -6,14 +6,14 @@ var a = 10; export default a; //// [es6ImportDefaultBindingMergeErrors_1.ts] -import defaultBinding from "es6ImportDefaultBindingMergeErrors_0"; +import defaultBinding from "./es6ImportDefaultBindingMergeErrors_0"; interface defaultBinding { // This is ok } var x = defaultBinding; -import defaultBinding2 from "es6ImportDefaultBindingMergeErrors_0"; // Should be error +import defaultBinding2 from "./es6ImportDefaultBindingMergeErrors_0"; // Should be error var defaultBinding2 = "hello world"; -import defaultBinding3 from "es6ImportDefaultBindingMergeErrors_0"; // Should be error -import defaultBinding3 from "es6ImportDefaultBindingMergeErrors_0"; // SHould be error +import defaultBinding3 from "./es6ImportDefaultBindingMergeErrors_0"; // Should be error +import defaultBinding3 from "./es6ImportDefaultBindingMergeErrors_0"; // SHould be error //// [es6ImportDefaultBindingMergeErrors_0.js] @@ -21,6 +21,6 @@ var a = 10; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = a; //// [es6ImportDefaultBindingMergeErrors_1.js] -var es6ImportDefaultBindingMergeErrors_0_1 = require("es6ImportDefaultBindingMergeErrors_0"); +var es6ImportDefaultBindingMergeErrors_0_1 = require("./es6ImportDefaultBindingMergeErrors_0"); var x = es6ImportDefaultBindingMergeErrors_0_1.default; var defaultBinding2 = "hello world"; diff --git a/tests/baselines/reference/es6ImportDefaultBindingNoDefaultProperty.errors.txt b/tests/baselines/reference/es6ImportDefaultBindingNoDefaultProperty.errors.txt index a37a71e7378..9d0e46ceb97 100644 --- a/tests/baselines/reference/es6ImportDefaultBindingNoDefaultProperty.errors.txt +++ b/tests/baselines/reference/es6ImportDefaultBindingNoDefaultProperty.errors.txt @@ -6,7 +6,7 @@ tests/cases/compiler/es6ImportDefaultBindingNoDefaultProperty_1.ts(1,8): error T export var a = 10; ==== tests/cases/compiler/es6ImportDefaultBindingNoDefaultProperty_1.ts (1 errors) ==== - import defaultBinding from "es6ImportDefaultBindingNoDefaultProperty_0"; + import defaultBinding from "./es6ImportDefaultBindingNoDefaultProperty_0"; ~~~~~~~~~~~~~~ !!! error TS1192: Module '"tests/cases/compiler/es6ImportDefaultBindingNoDefaultProperty_0"' has no default export. \ No newline at end of file diff --git a/tests/baselines/reference/es6ImportDefaultBindingNoDefaultProperty.js b/tests/baselines/reference/es6ImportDefaultBindingNoDefaultProperty.js index f824dbf71d5..1c9ec4eeae5 100644 --- a/tests/baselines/reference/es6ImportDefaultBindingNoDefaultProperty.js +++ b/tests/baselines/reference/es6ImportDefaultBindingNoDefaultProperty.js @@ -5,7 +5,7 @@ export var a = 10; //// [es6ImportDefaultBindingNoDefaultProperty_1.ts] -import defaultBinding from "es6ImportDefaultBindingNoDefaultProperty_0"; +import defaultBinding from "./es6ImportDefaultBindingNoDefaultProperty_0"; //// [es6ImportDefaultBindingNoDefaultProperty_0.js] diff --git a/tests/baselines/reference/es6ImportNameSpaceImport.errors.txt b/tests/baselines/reference/es6ImportNameSpaceImport.errors.txt index 00a6dcb2cfd..67616662ca8 100644 --- a/tests/baselines/reference/es6ImportNameSpaceImport.errors.txt +++ b/tests/baselines/reference/es6ImportNameSpaceImport.errors.txt @@ -7,7 +7,7 @@ error TS1204: Cannot compile modules into 'commonjs', 'amd', 'system' or 'umd' w export var a = 10; ==== tests/cases/compiler/es6ImportNameSpaceImport_1.ts (0 errors) ==== - import * as nameSpaceBinding from "es6ImportNameSpaceImport_0"; + import * as nameSpaceBinding from "./es6ImportNameSpaceImport_0"; var x = nameSpaceBinding.a; - import * as nameSpaceBinding2 from "es6ImportNameSpaceImport_0"; // elide this + import * as nameSpaceBinding2 from "./es6ImportNameSpaceImport_0"; // elide this \ No newline at end of file diff --git a/tests/baselines/reference/es6ImportNameSpaceImport.js b/tests/baselines/reference/es6ImportNameSpaceImport.js index 653feeb22b7..7498b8ee9e8 100644 --- a/tests/baselines/reference/es6ImportNameSpaceImport.js +++ b/tests/baselines/reference/es6ImportNameSpaceImport.js @@ -5,15 +5,15 @@ export var a = 10; //// [es6ImportNameSpaceImport_1.ts] -import * as nameSpaceBinding from "es6ImportNameSpaceImport_0"; +import * as nameSpaceBinding from "./es6ImportNameSpaceImport_0"; var x = nameSpaceBinding.a; -import * as nameSpaceBinding2 from "es6ImportNameSpaceImport_0"; // elide this +import * as nameSpaceBinding2 from "./es6ImportNameSpaceImport_0"; // elide this //// [es6ImportNameSpaceImport_0.js] export var a = 10; //// [es6ImportNameSpaceImport_1.js] -import * as nameSpaceBinding from "es6ImportNameSpaceImport_0"; +import * as nameSpaceBinding from "./es6ImportNameSpaceImport_0"; var x = nameSpaceBinding.a; diff --git a/tests/baselines/reference/es6ImportNameSpaceImportDts.js b/tests/baselines/reference/es6ImportNameSpaceImportDts.js index 91e927428a1..dfdfe2602a3 100644 --- a/tests/baselines/reference/es6ImportNameSpaceImportDts.js +++ b/tests/baselines/reference/es6ImportNameSpaceImportDts.js @@ -5,9 +5,9 @@ export class c { }; //// [client.ts] -import * as nameSpaceBinding from "server"; +import * as nameSpaceBinding from "./server"; export var x = new nameSpaceBinding.c(); -import * as nameSpaceBinding2 from "server"; // unreferenced +import * as nameSpaceBinding2 from "./server"; // unreferenced //// [server.js] var c = (function () { @@ -18,7 +18,7 @@ var c = (function () { exports.c = c; ; //// [client.js] -var nameSpaceBinding = require("server"); +var nameSpaceBinding = require("./server"); exports.x = new nameSpaceBinding.c(); @@ -26,5 +26,5 @@ exports.x = new nameSpaceBinding.c(); export declare class c { } //// [client.d.ts] -import * as nameSpaceBinding from "server"; +import * as nameSpaceBinding from "./server"; export declare var x: nameSpaceBinding.c; diff --git a/tests/baselines/reference/es6ImportNameSpaceImportDts.symbols b/tests/baselines/reference/es6ImportNameSpaceImportDts.symbols index 8104cbcce50..5f6fea374be 100644 --- a/tests/baselines/reference/es6ImportNameSpaceImportDts.symbols +++ b/tests/baselines/reference/es6ImportNameSpaceImportDts.symbols @@ -4,7 +4,7 @@ export class c { }; >c : Symbol(c, Decl(server.ts, 0, 0)) === tests/cases/compiler/client.ts === -import * as nameSpaceBinding from "server"; +import * as nameSpaceBinding from "./server"; >nameSpaceBinding : Symbol(nameSpaceBinding, Decl(client.ts, 0, 6)) export var x = new nameSpaceBinding.c(); @@ -13,6 +13,6 @@ export var x = new nameSpaceBinding.c(); >nameSpaceBinding : Symbol(nameSpaceBinding, Decl(client.ts, 0, 6)) >c : Symbol(nameSpaceBinding.c, Decl(server.ts, 0, 0)) -import * as nameSpaceBinding2 from "server"; // unreferenced +import * as nameSpaceBinding2 from "./server"; // unreferenced >nameSpaceBinding2 : Symbol(nameSpaceBinding2, Decl(client.ts, 2, 6)) diff --git a/tests/baselines/reference/es6ImportNameSpaceImportDts.types b/tests/baselines/reference/es6ImportNameSpaceImportDts.types index 345d593b143..e49f3ace57a 100644 --- a/tests/baselines/reference/es6ImportNameSpaceImportDts.types +++ b/tests/baselines/reference/es6ImportNameSpaceImportDts.types @@ -4,7 +4,7 @@ export class c { }; >c : c === tests/cases/compiler/client.ts === -import * as nameSpaceBinding from "server"; +import * as nameSpaceBinding from "./server"; >nameSpaceBinding : typeof nameSpaceBinding export var x = new nameSpaceBinding.c(); @@ -14,6 +14,6 @@ export var x = new nameSpaceBinding.c(); >nameSpaceBinding : typeof nameSpaceBinding >c : typeof nameSpaceBinding.c -import * as nameSpaceBinding2 from "server"; // unreferenced +import * as nameSpaceBinding2 from "./server"; // unreferenced >nameSpaceBinding2 : typeof nameSpaceBinding diff --git a/tests/baselines/reference/es6ImportNameSpaceImportInEs5.js b/tests/baselines/reference/es6ImportNameSpaceImportInEs5.js index 50a03972cc2..dfc90c3e9af 100644 --- a/tests/baselines/reference/es6ImportNameSpaceImportInEs5.js +++ b/tests/baselines/reference/es6ImportNameSpaceImportInEs5.js @@ -5,15 +5,15 @@ export var a = 10; //// [es6ImportNameSpaceImportInEs5_1.ts] -import * as nameSpaceBinding from "es6ImportNameSpaceImportInEs5_0"; +import * as nameSpaceBinding from "./es6ImportNameSpaceImportInEs5_0"; var x = nameSpaceBinding.a; -import * as nameSpaceBinding2 from "es6ImportNameSpaceImportInEs5_0"; // elide this +import * as nameSpaceBinding2 from "./es6ImportNameSpaceImportInEs5_0"; // elide this //// [es6ImportNameSpaceImportInEs5_0.js] exports.a = 10; //// [es6ImportNameSpaceImportInEs5_1.js] -var nameSpaceBinding = require("es6ImportNameSpaceImportInEs5_0"); +var nameSpaceBinding = require("./es6ImportNameSpaceImportInEs5_0"); var x = nameSpaceBinding.a; diff --git a/tests/baselines/reference/es6ImportNameSpaceImportInEs5.symbols b/tests/baselines/reference/es6ImportNameSpaceImportInEs5.symbols index 119787de817..7be619dcc7e 100644 --- a/tests/baselines/reference/es6ImportNameSpaceImportInEs5.symbols +++ b/tests/baselines/reference/es6ImportNameSpaceImportInEs5.symbols @@ -4,7 +4,7 @@ export var a = 10; >a : Symbol(a, Decl(es6ImportNameSpaceImportInEs5_0.ts, 1, 10)) === tests/cases/compiler/es6ImportNameSpaceImportInEs5_1.ts === -import * as nameSpaceBinding from "es6ImportNameSpaceImportInEs5_0"; +import * as nameSpaceBinding from "./es6ImportNameSpaceImportInEs5_0"; >nameSpaceBinding : Symbol(nameSpaceBinding, Decl(es6ImportNameSpaceImportInEs5_1.ts, 0, 6)) var x = nameSpaceBinding.a; @@ -13,6 +13,6 @@ var x = nameSpaceBinding.a; >nameSpaceBinding : Symbol(nameSpaceBinding, Decl(es6ImportNameSpaceImportInEs5_1.ts, 0, 6)) >a : Symbol(nameSpaceBinding.a, Decl(es6ImportNameSpaceImportInEs5_0.ts, 1, 10)) -import * as nameSpaceBinding2 from "es6ImportNameSpaceImportInEs5_0"; // elide this +import * as nameSpaceBinding2 from "./es6ImportNameSpaceImportInEs5_0"; // elide this >nameSpaceBinding2 : Symbol(nameSpaceBinding2, Decl(es6ImportNameSpaceImportInEs5_1.ts, 2, 6)) diff --git a/tests/baselines/reference/es6ImportNameSpaceImportInEs5.types b/tests/baselines/reference/es6ImportNameSpaceImportInEs5.types index 01531cd233d..13631060813 100644 --- a/tests/baselines/reference/es6ImportNameSpaceImportInEs5.types +++ b/tests/baselines/reference/es6ImportNameSpaceImportInEs5.types @@ -5,7 +5,7 @@ export var a = 10; >10 : number === tests/cases/compiler/es6ImportNameSpaceImportInEs5_1.ts === -import * as nameSpaceBinding from "es6ImportNameSpaceImportInEs5_0"; +import * as nameSpaceBinding from "./es6ImportNameSpaceImportInEs5_0"; >nameSpaceBinding : typeof nameSpaceBinding var x = nameSpaceBinding.a; @@ -14,6 +14,6 @@ var x = nameSpaceBinding.a; >nameSpaceBinding : typeof nameSpaceBinding >a : number -import * as nameSpaceBinding2 from "es6ImportNameSpaceImportInEs5_0"; // elide this +import * as nameSpaceBinding2 from "./es6ImportNameSpaceImportInEs5_0"; // elide this >nameSpaceBinding2 : typeof nameSpaceBinding diff --git a/tests/baselines/reference/es6ImportNameSpaceImportMergeErrors.errors.txt b/tests/baselines/reference/es6ImportNameSpaceImportMergeErrors.errors.txt index 98a68870833..b8b22ce3ed1 100644 --- a/tests/baselines/reference/es6ImportNameSpaceImportMergeErrors.errors.txt +++ b/tests/baselines/reference/es6ImportNameSpaceImportMergeErrors.errors.txt @@ -8,17 +8,17 @@ tests/cases/compiler/es6ImportNameSpaceImportMergeErrors_1.ts(7,8): error TS2440 export var a = 10; ==== tests/cases/compiler/es6ImportNameSpaceImportMergeErrors_1.ts (3 errors) ==== - import * as nameSpaceBinding from "es6ImportNameSpaceImportMergeErrors_0"; + import * as nameSpaceBinding from "./es6ImportNameSpaceImportMergeErrors_0"; interface nameSpaceBinding { } // this should be ok - import * as nameSpaceBinding1 from "es6ImportNameSpaceImportMergeErrors_0"; // should be error + import * as nameSpaceBinding1 from "./es6ImportNameSpaceImportMergeErrors_0"; // should be error ~~~~~~~~~~~~~~~~~ !!! error TS2300: Duplicate identifier 'nameSpaceBinding1'. - import * as nameSpaceBinding1 from "es6ImportNameSpaceImportMergeErrors_0"; // should be error + import * as nameSpaceBinding1 from "./es6ImportNameSpaceImportMergeErrors_0"; // should be error ~~~~~~~~~~~~~~~~~ !!! error TS2300: Duplicate identifier 'nameSpaceBinding1'. - import * as nameSpaceBinding3 from "es6ImportNameSpaceImportMergeErrors_0"; // should be error + import * as nameSpaceBinding3 from "./es6ImportNameSpaceImportMergeErrors_0"; // should be error ~~~~~~~~~~~~~~~~~~~~~~ !!! error TS2440: Import declaration conflicts with local declaration of 'nameSpaceBinding3' var nameSpaceBinding3 = 10; diff --git a/tests/baselines/reference/es6ImportNameSpaceImportMergeErrors.js b/tests/baselines/reference/es6ImportNameSpaceImportMergeErrors.js index 3c8461fba2b..b94640349c0 100644 --- a/tests/baselines/reference/es6ImportNameSpaceImportMergeErrors.js +++ b/tests/baselines/reference/es6ImportNameSpaceImportMergeErrors.js @@ -5,13 +5,13 @@ export var a = 10; //// [es6ImportNameSpaceImportMergeErrors_1.ts] -import * as nameSpaceBinding from "es6ImportNameSpaceImportMergeErrors_0"; +import * as nameSpaceBinding from "./es6ImportNameSpaceImportMergeErrors_0"; interface nameSpaceBinding { } // this should be ok -import * as nameSpaceBinding1 from "es6ImportNameSpaceImportMergeErrors_0"; // should be error -import * as nameSpaceBinding1 from "es6ImportNameSpaceImportMergeErrors_0"; // should be error +import * as nameSpaceBinding1 from "./es6ImportNameSpaceImportMergeErrors_0"; // should be error +import * as nameSpaceBinding1 from "./es6ImportNameSpaceImportMergeErrors_0"; // should be error -import * as nameSpaceBinding3 from "es6ImportNameSpaceImportMergeErrors_0"; // should be error +import * as nameSpaceBinding3 from "./es6ImportNameSpaceImportMergeErrors_0"; // should be error var nameSpaceBinding3 = 10; diff --git a/tests/baselines/reference/es6ImportNameSpaceImportNoNamedExports.js b/tests/baselines/reference/es6ImportNameSpaceImportNoNamedExports.js index 3d6dab17785..efa3a04bc9a 100644 --- a/tests/baselines/reference/es6ImportNameSpaceImportNoNamedExports.js +++ b/tests/baselines/reference/es6ImportNameSpaceImportNoNamedExports.js @@ -6,7 +6,7 @@ var a = 10; export = a; //// [es6ImportNameSpaceImportNoNamedExports_1.ts] -import * as nameSpaceBinding from "es6ImportNameSpaceImportNoNamedExports_0"; // error +import * as nameSpaceBinding from "./es6ImportNameSpaceImportNoNamedExports_0"; // error //// [es6ImportNameSpaceImportNoNamedExports_0.js] var a = 10; diff --git a/tests/baselines/reference/es6ImportNameSpaceImportNoNamedExports.symbols b/tests/baselines/reference/es6ImportNameSpaceImportNoNamedExports.symbols index 6a443d1fa00..8767c1a4add 100644 --- a/tests/baselines/reference/es6ImportNameSpaceImportNoNamedExports.symbols +++ b/tests/baselines/reference/es6ImportNameSpaceImportNoNamedExports.symbols @@ -7,6 +7,6 @@ export = a; >a : Symbol(a, Decl(es6ImportNameSpaceImportNoNamedExports_0.ts, 1, 3)) === tests/cases/compiler/es6ImportNameSpaceImportNoNamedExports_1.ts === -import * as nameSpaceBinding from "es6ImportNameSpaceImportNoNamedExports_0"; // error +import * as nameSpaceBinding from "./es6ImportNameSpaceImportNoNamedExports_0"; // error >nameSpaceBinding : Symbol(nameSpaceBinding, Decl(es6ImportNameSpaceImportNoNamedExports_1.ts, 0, 6)) diff --git a/tests/baselines/reference/es6ImportNameSpaceImportNoNamedExports.types b/tests/baselines/reference/es6ImportNameSpaceImportNoNamedExports.types index 2cc4844dd42..4aaf33d5930 100644 --- a/tests/baselines/reference/es6ImportNameSpaceImportNoNamedExports.types +++ b/tests/baselines/reference/es6ImportNameSpaceImportNoNamedExports.types @@ -8,6 +8,6 @@ export = a; >a : number === tests/cases/compiler/es6ImportNameSpaceImportNoNamedExports_1.ts === -import * as nameSpaceBinding from "es6ImportNameSpaceImportNoNamedExports_0"; // error +import * as nameSpaceBinding from "./es6ImportNameSpaceImportNoNamedExports_0"; // error >nameSpaceBinding : number diff --git a/tests/baselines/reference/es6ImportNamedImport.errors.txt b/tests/baselines/reference/es6ImportNamedImport.errors.txt index 12dcf331967..efcda1f5368 100644 --- a/tests/baselines/reference/es6ImportNamedImport.errors.txt +++ b/tests/baselines/reference/es6ImportNamedImport.errors.txt @@ -14,31 +14,31 @@ error TS1204: Cannot compile modules into 'commonjs', 'amd', 'system' or 'umd' w export var aaaa = 10; ==== tests/cases/compiler/es6ImportNamedImport_1.ts (0 errors) ==== - import { } from "es6ImportNamedImport_0"; - import { a } from "es6ImportNamedImport_0"; + import { } from "./es6ImportNamedImport_0"; + import { a } from "./es6ImportNamedImport_0"; var xxxx = a; - import { a as b } from "es6ImportNamedImport_0"; + import { a as b } from "./es6ImportNamedImport_0"; var xxxx = b; - import { x, a as y } from "es6ImportNamedImport_0"; + import { x, a as y } from "./es6ImportNamedImport_0"; var xxxx = x; var xxxx = y; - import { x as z, } from "es6ImportNamedImport_0"; + import { x as z, } from "./es6ImportNamedImport_0"; var xxxx = z; - import { m, } from "es6ImportNamedImport_0"; + import { m, } from "./es6ImportNamedImport_0"; var xxxx = m; - import { a1, x1 } from "es6ImportNamedImport_0"; + import { a1, x1 } from "./es6ImportNamedImport_0"; var xxxx = a1; var xxxx = x1; - import { a1 as a11, x1 as x11 } from "es6ImportNamedImport_0"; + import { a1 as a11, x1 as x11 } from "./es6ImportNamedImport_0"; var xxxx = a11; var xxxx = x11; - import { z1 } from "es6ImportNamedImport_0"; + import { z1 } from "./es6ImportNamedImport_0"; var z111 = z1; - import { z2 as z3 } from "es6ImportNamedImport_0"; + import { z2 as z3 } from "./es6ImportNamedImport_0"; var z2 = z3; // z2 shouldn't give redeclare error // These are elided - import { aaaa } from "es6ImportNamedImport_0"; + import { aaaa } from "./es6ImportNamedImport_0"; // These are elided - import { aaaa as bbbb } from "es6ImportNamedImport_0"; + import { aaaa as bbbb } from "./es6ImportNamedImport_0"; \ No newline at end of file diff --git a/tests/baselines/reference/es6ImportNamedImport.js b/tests/baselines/reference/es6ImportNamedImport.js index 9606c59351b..6edb6ccb7cd 100644 --- a/tests/baselines/reference/es6ImportNamedImport.js +++ b/tests/baselines/reference/es6ImportNamedImport.js @@ -12,33 +12,33 @@ export var z2 = 10; export var aaaa = 10; //// [es6ImportNamedImport_1.ts] -import { } from "es6ImportNamedImport_0"; -import { a } from "es6ImportNamedImport_0"; +import { } from "./es6ImportNamedImport_0"; +import { a } from "./es6ImportNamedImport_0"; var xxxx = a; -import { a as b } from "es6ImportNamedImport_0"; +import { a as b } from "./es6ImportNamedImport_0"; var xxxx = b; -import { x, a as y } from "es6ImportNamedImport_0"; +import { x, a as y } from "./es6ImportNamedImport_0"; var xxxx = x; var xxxx = y; -import { x as z, } from "es6ImportNamedImport_0"; +import { x as z, } from "./es6ImportNamedImport_0"; var xxxx = z; -import { m, } from "es6ImportNamedImport_0"; +import { m, } from "./es6ImportNamedImport_0"; var xxxx = m; -import { a1, x1 } from "es6ImportNamedImport_0"; +import { a1, x1 } from "./es6ImportNamedImport_0"; var xxxx = a1; var xxxx = x1; -import { a1 as a11, x1 as x11 } from "es6ImportNamedImport_0"; +import { a1 as a11, x1 as x11 } from "./es6ImportNamedImport_0"; var xxxx = a11; var xxxx = x11; -import { z1 } from "es6ImportNamedImport_0"; +import { z1 } from "./es6ImportNamedImport_0"; var z111 = z1; -import { z2 as z3 } from "es6ImportNamedImport_0"; +import { z2 as z3 } from "./es6ImportNamedImport_0"; var z2 = z3; // z2 shouldn't give redeclare error // These are elided -import { aaaa } from "es6ImportNamedImport_0"; +import { aaaa } from "./es6ImportNamedImport_0"; // These are elided -import { aaaa as bbbb } from "es6ImportNamedImport_0"; +import { aaaa as bbbb } from "./es6ImportNamedImport_0"; //// [es6ImportNamedImport_0.js] @@ -51,26 +51,26 @@ export var z1 = 10; export var z2 = 10; export var aaaa = 10; //// [es6ImportNamedImport_1.js] -import { a } from "es6ImportNamedImport_0"; +import { a } from "./es6ImportNamedImport_0"; var xxxx = a; -import { a as b } from "es6ImportNamedImport_0"; +import { a as b } from "./es6ImportNamedImport_0"; var xxxx = b; -import { x, a as y } from "es6ImportNamedImport_0"; +import { x, a as y } from "./es6ImportNamedImport_0"; var xxxx = x; var xxxx = y; -import { x as z } from "es6ImportNamedImport_0"; +import { x as z } from "./es6ImportNamedImport_0"; var xxxx = z; -import { m } from "es6ImportNamedImport_0"; +import { m } from "./es6ImportNamedImport_0"; var xxxx = m; -import { a1, x1 } from "es6ImportNamedImport_0"; +import { a1, x1 } from "./es6ImportNamedImport_0"; var xxxx = a1; var xxxx = x1; -import { a1 as a11, x1 as x11 } from "es6ImportNamedImport_0"; +import { a1 as a11, x1 as x11 } from "./es6ImportNamedImport_0"; var xxxx = a11; var xxxx = x11; -import { z1 } from "es6ImportNamedImport_0"; +import { z1 } from "./es6ImportNamedImport_0"; var z111 = z1; -import { z2 as z3 } from "es6ImportNamedImport_0"; +import { z2 as z3 } from "./es6ImportNamedImport_0"; var z2 = z3; // z2 shouldn't give redeclare error diff --git a/tests/baselines/reference/es6ImportNamedImportDts.js b/tests/baselines/reference/es6ImportNamedImportDts.js index a72632a737e..59b47635ba9 100644 --- a/tests/baselines/reference/es6ImportNamedImportDts.js +++ b/tests/baselines/reference/es6ImportNamedImportDts.js @@ -18,32 +18,32 @@ export class aaaa { } export class aaaa1 { } //// [client.ts] -import { } from "server"; -import { a } from "server"; +import { } from "./server"; +import { a } from "./server"; export var xxxx = new a(); -import { a11 as b } from "server"; +import { a11 as b } from "./server"; export var xxxx1 = new b(); -import { x, a12 as y } from "server"; +import { x, a12 as y } from "./server"; export var xxxx2 = new x(); export var xxxx3 = new y(); -import { x11 as z, } from "server"; +import { x11 as z, } from "./server"; export var xxxx4 = new z(); -import { m, } from "server"; +import { m, } from "./server"; export var xxxx5 = new m(); -import { a1, x1 } from "server"; +import { a1, x1 } from "./server"; export var xxxx6 = new a1(); export var xxxx7 = new x1(); -import { a111 as a11, x111 as x11 } from "server"; +import { a111 as a11, x111 as x11 } from "./server"; export var xxxx8 = new a11(); export var xxxx9 = new x11(); -import { z1 } from "server"; +import { z1 } from "./server"; export var z111 = new z1(); -import { z2 as z3 } from "server"; +import { z2 as z3 } from "./server"; export var z2 = new z3(); // z2 shouldn't give redeclare error // not referenced -import { aaaa } from "server"; -import { aaaa1 as bbbb } from "server"; +import { aaaa } from "./server"; +import { aaaa1 as bbbb } from "./server"; //// [server.js] @@ -132,26 +132,26 @@ var aaaa1 = (function () { })(); exports.aaaa1 = aaaa1; //// [client.js] -var server_1 = require("server"); +var server_1 = require("./server"); exports.xxxx = new server_1.a(); -var server_2 = require("server"); +var server_2 = require("./server"); exports.xxxx1 = new server_2.a11(); -var server_3 = require("server"); +var server_3 = require("./server"); exports.xxxx2 = new server_3.x(); exports.xxxx3 = new server_3.a12(); -var server_4 = require("server"); +var server_4 = require("./server"); exports.xxxx4 = new server_4.x11(); -var server_5 = require("server"); +var server_5 = require("./server"); exports.xxxx5 = new server_5.m(); -var server_6 = require("server"); +var server_6 = require("./server"); exports.xxxx6 = new server_6.a1(); exports.xxxx7 = new server_6.x1(); -var server_7 = require("server"); +var server_7 = require("./server"); exports.xxxx8 = new server_7.a111(); exports.xxxx9 = new server_7.x111(); -var server_8 = require("server"); +var server_8 = require("./server"); exports.z111 = new server_8.z1(); -var server_9 = require("server"); +var server_9 = require("./server"); exports.z2 = new server_9.z2(); // z2 shouldn't give redeclare error @@ -185,24 +185,24 @@ export declare class aaaa { export declare class aaaa1 { } //// [client.d.ts] -import { a } from "server"; +import { a } from "./server"; export declare var xxxx: a; -import { a11 as b } from "server"; +import { a11 as b } from "./server"; export declare var xxxx1: b; -import { x, a12 as y } from "server"; +import { x, a12 as y } from "./server"; export declare var xxxx2: x; export declare var xxxx3: y; -import { x11 as z } from "server"; +import { x11 as z } from "./server"; export declare var xxxx4: z; -import { m } from "server"; +import { m } from "./server"; export declare var xxxx5: m; -import { a1, x1 } from "server"; +import { a1, x1 } from "./server"; export declare var xxxx6: a1; export declare var xxxx7: x1; -import { a111 as a11, x111 as x11 } from "server"; +import { a111 as a11, x111 as x11 } from "./server"; export declare var xxxx8: a11; export declare var xxxx9: x11; -import { z1 } from "server"; +import { z1 } from "./server"; export declare var z111: z1; -import { z2 as z3 } from "server"; +import { z2 as z3 } from "./server"; export declare var z2: z3; diff --git a/tests/baselines/reference/es6ImportNamedImportDts.symbols b/tests/baselines/reference/es6ImportNamedImportDts.symbols index 2e3b2735b3d..dab2e13d0f6 100644 --- a/tests/baselines/reference/es6ImportNamedImportDts.symbols +++ b/tests/baselines/reference/es6ImportNamedImportDts.symbols @@ -43,15 +43,15 @@ export class aaaa1 { } >aaaa1 : Symbol(aaaa1, Decl(server.ts, 13, 21)) === tests/cases/compiler/client.ts === -import { } from "server"; -import { a } from "server"; +import { } from "./server"; +import { a } from "./server"; >a : Symbol(a, Decl(client.ts, 1, 8)) export var xxxx = new a(); >xxxx : Symbol(xxxx, Decl(client.ts, 2, 10)) >a : Symbol(a, Decl(client.ts, 1, 8)) -import { a11 as b } from "server"; +import { a11 as b } from "./server"; >a11 : Symbol(b, Decl(client.ts, 3, 8)) >b : Symbol(b, Decl(client.ts, 3, 8)) @@ -59,7 +59,7 @@ export var xxxx1 = new b(); >xxxx1 : Symbol(xxxx1, Decl(client.ts, 4, 10)) >b : Symbol(b, Decl(client.ts, 3, 8)) -import { x, a12 as y } from "server"; +import { x, a12 as y } from "./server"; >x : Symbol(x, Decl(client.ts, 5, 8)) >a12 : Symbol(y, Decl(client.ts, 5, 11)) >y : Symbol(y, Decl(client.ts, 5, 11)) @@ -72,7 +72,7 @@ export var xxxx3 = new y(); >xxxx3 : Symbol(xxxx3, Decl(client.ts, 7, 10)) >y : Symbol(y, Decl(client.ts, 5, 11)) -import { x11 as z, } from "server"; +import { x11 as z, } from "./server"; >x11 : Symbol(z, Decl(client.ts, 8, 8)) >z : Symbol(z, Decl(client.ts, 8, 8)) @@ -80,14 +80,14 @@ export var xxxx4 = new z(); >xxxx4 : Symbol(xxxx4, Decl(client.ts, 9, 10)) >z : Symbol(z, Decl(client.ts, 8, 8)) -import { m, } from "server"; +import { m, } from "./server"; >m : Symbol(m, Decl(client.ts, 10, 8)) export var xxxx5 = new m(); >xxxx5 : Symbol(xxxx5, Decl(client.ts, 11, 10)) >m : Symbol(m, Decl(client.ts, 10, 8)) -import { a1, x1 } from "server"; +import { a1, x1 } from "./server"; >a1 : Symbol(a1, Decl(client.ts, 12, 8)) >x1 : Symbol(x1, Decl(client.ts, 12, 12)) @@ -99,7 +99,7 @@ export var xxxx7 = new x1(); >xxxx7 : Symbol(xxxx7, Decl(client.ts, 14, 10)) >x1 : Symbol(x1, Decl(client.ts, 12, 12)) -import { a111 as a11, x111 as x11 } from "server"; +import { a111 as a11, x111 as x11 } from "./server"; >a111 : Symbol(a11, Decl(client.ts, 15, 8)) >a11 : Symbol(a11, Decl(client.ts, 15, 8)) >x111 : Symbol(x11, Decl(client.ts, 15, 21)) @@ -113,14 +113,14 @@ export var xxxx9 = new x11(); >xxxx9 : Symbol(xxxx9, Decl(client.ts, 17, 10)) >x11 : Symbol(x11, Decl(client.ts, 15, 21)) -import { z1 } from "server"; +import { z1 } from "./server"; >z1 : Symbol(z1, Decl(client.ts, 18, 8)) export var z111 = new z1(); >z111 : Symbol(z111, Decl(client.ts, 19, 10)) >z1 : Symbol(z1, Decl(client.ts, 18, 8)) -import { z2 as z3 } from "server"; +import { z2 as z3 } from "./server"; >z2 : Symbol(z3, Decl(client.ts, 20, 8)) >z3 : Symbol(z3, Decl(client.ts, 20, 8)) @@ -129,10 +129,10 @@ export var z2 = new z3(); // z2 shouldn't give redeclare error >z3 : Symbol(z3, Decl(client.ts, 20, 8)) // not referenced -import { aaaa } from "server"; +import { aaaa } from "./server"; >aaaa : Symbol(aaaa, Decl(client.ts, 24, 8)) -import { aaaa1 as bbbb } from "server"; +import { aaaa1 as bbbb } from "./server"; >aaaa1 : Symbol(bbbb, Decl(client.ts, 25, 8)) >bbbb : Symbol(bbbb, Decl(client.ts, 25, 8)) diff --git a/tests/baselines/reference/es6ImportNamedImportDts.types b/tests/baselines/reference/es6ImportNamedImportDts.types index 93bd55716a5..9aba1012117 100644 --- a/tests/baselines/reference/es6ImportNamedImportDts.types +++ b/tests/baselines/reference/es6ImportNamedImportDts.types @@ -43,8 +43,8 @@ export class aaaa1 { } >aaaa1 : aaaa1 === tests/cases/compiler/client.ts === -import { } from "server"; -import { a } from "server"; +import { } from "./server"; +import { a } from "./server"; >a : typeof a export var xxxx = new a(); @@ -52,7 +52,7 @@ export var xxxx = new a(); >new a() : a >a : typeof a -import { a11 as b } from "server"; +import { a11 as b } from "./server"; >a11 : typeof b >b : typeof b @@ -61,7 +61,7 @@ export var xxxx1 = new b(); >new b() : b >b : typeof b -import { x, a12 as y } from "server"; +import { x, a12 as y } from "./server"; >x : typeof x >a12 : typeof y >y : typeof y @@ -76,7 +76,7 @@ export var xxxx3 = new y(); >new y() : y >y : typeof y -import { x11 as z, } from "server"; +import { x11 as z, } from "./server"; >x11 : typeof z >z : typeof z @@ -85,7 +85,7 @@ export var xxxx4 = new z(); >new z() : z >z : typeof z -import { m, } from "server"; +import { m, } from "./server"; >m : typeof m export var xxxx5 = new m(); @@ -93,7 +93,7 @@ export var xxxx5 = new m(); >new m() : m >m : typeof m -import { a1, x1 } from "server"; +import { a1, x1 } from "./server"; >a1 : typeof a1 >x1 : typeof x1 @@ -107,7 +107,7 @@ export var xxxx7 = new x1(); >new x1() : x1 >x1 : typeof x1 -import { a111 as a11, x111 as x11 } from "server"; +import { a111 as a11, x111 as x11 } from "./server"; >a111 : typeof a11 >a11 : typeof a11 >x111 : typeof x11 @@ -123,7 +123,7 @@ export var xxxx9 = new x11(); >new x11() : x11 >x11 : typeof x11 -import { z1 } from "server"; +import { z1 } from "./server"; >z1 : typeof z1 export var z111 = new z1(); @@ -131,7 +131,7 @@ export var z111 = new z1(); >new z1() : z1 >z1 : typeof z1 -import { z2 as z3 } from "server"; +import { z2 as z3 } from "./server"; >z2 : typeof z3 >z3 : typeof z3 @@ -141,10 +141,10 @@ export var z2 = new z3(); // z2 shouldn't give redeclare error >z3 : typeof z3 // not referenced -import { aaaa } from "server"; +import { aaaa } from "./server"; >aaaa : typeof aaaa -import { aaaa1 as bbbb } from "server"; +import { aaaa1 as bbbb } from "./server"; >aaaa1 : typeof bbbb >bbbb : typeof bbbb diff --git a/tests/baselines/reference/es6ImportNamedImportInEs5.js b/tests/baselines/reference/es6ImportNamedImportInEs5.js index 9992508c00b..ce2cbea3d3d 100644 --- a/tests/baselines/reference/es6ImportNamedImportInEs5.js +++ b/tests/baselines/reference/es6ImportNamedImportInEs5.js @@ -12,33 +12,33 @@ export var z2 = 10; export var aaaa = 10; //// [es6ImportNamedImportInEs5_1.ts] -import { } from "es6ImportNamedImportInEs5_0"; -import { a } from "es6ImportNamedImportInEs5_0"; +import { } from "./es6ImportNamedImportInEs5_0"; +import { a } from "./es6ImportNamedImportInEs5_0"; var xxxx = a; -import { a as b } from "es6ImportNamedImportInEs5_0"; +import { a as b } from "./es6ImportNamedImportInEs5_0"; var xxxx = b; -import { x, a as y } from "es6ImportNamedImportInEs5_0"; +import { x, a as y } from "./es6ImportNamedImportInEs5_0"; var xxxx = x; var xxxx = y; -import { x as z, } from "es6ImportNamedImportInEs5_0"; +import { x as z, } from "./es6ImportNamedImportInEs5_0"; var xxxx = z; -import { m, } from "es6ImportNamedImportInEs5_0"; +import { m, } from "./es6ImportNamedImportInEs5_0"; var xxxx = m; -import { a1, x1 } from "es6ImportNamedImportInEs5_0"; +import { a1, x1 } from "./es6ImportNamedImportInEs5_0"; var xxxx = a1; var xxxx = x1; -import { a1 as a11, x1 as x11 } from "es6ImportNamedImportInEs5_0"; +import { a1 as a11, x1 as x11 } from "./es6ImportNamedImportInEs5_0"; var xxxx = a11; var xxxx = x11; -import { z1 } from "es6ImportNamedImportInEs5_0"; +import { z1 } from "./es6ImportNamedImportInEs5_0"; var z111 = z1; -import { z2 as z3 } from "es6ImportNamedImportInEs5_0"; +import { z2 as z3 } from "./es6ImportNamedImportInEs5_0"; var z2 = z3; // z2 shouldn't give redeclare error // These are elided -import { aaaa } from "es6ImportNamedImportInEs5_0"; +import { aaaa } from "./es6ImportNamedImportInEs5_0"; // These are elided -import { aaaa as bbbb } from "es6ImportNamedImportInEs5_0"; +import { aaaa as bbbb } from "./es6ImportNamedImportInEs5_0"; //// [es6ImportNamedImportInEs5_0.js] @@ -51,26 +51,26 @@ exports.z1 = 10; exports.z2 = 10; exports.aaaa = 10; //// [es6ImportNamedImportInEs5_1.js] -var es6ImportNamedImportInEs5_0_1 = require("es6ImportNamedImportInEs5_0"); +var es6ImportNamedImportInEs5_0_1 = require("./es6ImportNamedImportInEs5_0"); var xxxx = es6ImportNamedImportInEs5_0_1.a; -var es6ImportNamedImportInEs5_0_2 = require("es6ImportNamedImportInEs5_0"); +var es6ImportNamedImportInEs5_0_2 = require("./es6ImportNamedImportInEs5_0"); var xxxx = es6ImportNamedImportInEs5_0_2.a; -var es6ImportNamedImportInEs5_0_3 = require("es6ImportNamedImportInEs5_0"); +var es6ImportNamedImportInEs5_0_3 = require("./es6ImportNamedImportInEs5_0"); var xxxx = es6ImportNamedImportInEs5_0_3.x; var xxxx = es6ImportNamedImportInEs5_0_3.a; -var es6ImportNamedImportInEs5_0_4 = require("es6ImportNamedImportInEs5_0"); +var es6ImportNamedImportInEs5_0_4 = require("./es6ImportNamedImportInEs5_0"); var xxxx = es6ImportNamedImportInEs5_0_4.x; -var es6ImportNamedImportInEs5_0_5 = require("es6ImportNamedImportInEs5_0"); +var es6ImportNamedImportInEs5_0_5 = require("./es6ImportNamedImportInEs5_0"); var xxxx = es6ImportNamedImportInEs5_0_5.m; -var es6ImportNamedImportInEs5_0_6 = require("es6ImportNamedImportInEs5_0"); +var es6ImportNamedImportInEs5_0_6 = require("./es6ImportNamedImportInEs5_0"); var xxxx = es6ImportNamedImportInEs5_0_6.a1; var xxxx = es6ImportNamedImportInEs5_0_6.x1; -var es6ImportNamedImportInEs5_0_7 = require("es6ImportNamedImportInEs5_0"); +var es6ImportNamedImportInEs5_0_7 = require("./es6ImportNamedImportInEs5_0"); var xxxx = es6ImportNamedImportInEs5_0_7.a1; var xxxx = es6ImportNamedImportInEs5_0_7.x1; -var es6ImportNamedImportInEs5_0_8 = require("es6ImportNamedImportInEs5_0"); +var es6ImportNamedImportInEs5_0_8 = require("./es6ImportNamedImportInEs5_0"); var z111 = es6ImportNamedImportInEs5_0_8.z1; -var es6ImportNamedImportInEs5_0_9 = require("es6ImportNamedImportInEs5_0"); +var es6ImportNamedImportInEs5_0_9 = require("./es6ImportNamedImportInEs5_0"); var z2 = es6ImportNamedImportInEs5_0_9.z2; // z2 shouldn't give redeclare error diff --git a/tests/baselines/reference/es6ImportNamedImportInEs5.symbols b/tests/baselines/reference/es6ImportNamedImportInEs5.symbols index 546487514ce..f9e949e7efb 100644 --- a/tests/baselines/reference/es6ImportNamedImportInEs5.symbols +++ b/tests/baselines/reference/es6ImportNamedImportInEs5.symbols @@ -27,15 +27,15 @@ export var aaaa = 10; >aaaa : Symbol(aaaa, Decl(es6ImportNamedImportInEs5_0.ts, 8, 10)) === tests/cases/compiler/es6ImportNamedImportInEs5_1.ts === -import { } from "es6ImportNamedImportInEs5_0"; -import { a } from "es6ImportNamedImportInEs5_0"; +import { } from "./es6ImportNamedImportInEs5_0"; +import { a } from "./es6ImportNamedImportInEs5_0"; >a : Symbol(a, Decl(es6ImportNamedImportInEs5_1.ts, 1, 8)) var xxxx = a; >xxxx : Symbol(xxxx, Decl(es6ImportNamedImportInEs5_1.ts, 2, 3), Decl(es6ImportNamedImportInEs5_1.ts, 4, 3), Decl(es6ImportNamedImportInEs5_1.ts, 6, 3), Decl(es6ImportNamedImportInEs5_1.ts, 7, 3), Decl(es6ImportNamedImportInEs5_1.ts, 9, 3), Decl(es6ImportNamedImportInEs5_1.ts, 11, 3), Decl(es6ImportNamedImportInEs5_1.ts, 13, 3), Decl(es6ImportNamedImportInEs5_1.ts, 14, 3), Decl(es6ImportNamedImportInEs5_1.ts, 16, 3), Decl(es6ImportNamedImportInEs5_1.ts, 17, 3)) >a : Symbol(a, Decl(es6ImportNamedImportInEs5_1.ts, 1, 8)) -import { a as b } from "es6ImportNamedImportInEs5_0"; +import { a as b } from "./es6ImportNamedImportInEs5_0"; >a : Symbol(b, Decl(es6ImportNamedImportInEs5_1.ts, 3, 8)) >b : Symbol(b, Decl(es6ImportNamedImportInEs5_1.ts, 3, 8)) @@ -43,7 +43,7 @@ var xxxx = b; >xxxx : Symbol(xxxx, Decl(es6ImportNamedImportInEs5_1.ts, 2, 3), Decl(es6ImportNamedImportInEs5_1.ts, 4, 3), Decl(es6ImportNamedImportInEs5_1.ts, 6, 3), Decl(es6ImportNamedImportInEs5_1.ts, 7, 3), Decl(es6ImportNamedImportInEs5_1.ts, 9, 3), Decl(es6ImportNamedImportInEs5_1.ts, 11, 3), Decl(es6ImportNamedImportInEs5_1.ts, 13, 3), Decl(es6ImportNamedImportInEs5_1.ts, 14, 3), Decl(es6ImportNamedImportInEs5_1.ts, 16, 3), Decl(es6ImportNamedImportInEs5_1.ts, 17, 3)) >b : Symbol(b, Decl(es6ImportNamedImportInEs5_1.ts, 3, 8)) -import { x, a as y } from "es6ImportNamedImportInEs5_0"; +import { x, a as y } from "./es6ImportNamedImportInEs5_0"; >x : Symbol(x, Decl(es6ImportNamedImportInEs5_1.ts, 5, 8)) >a : Symbol(y, Decl(es6ImportNamedImportInEs5_1.ts, 5, 11)) >y : Symbol(y, Decl(es6ImportNamedImportInEs5_1.ts, 5, 11)) @@ -56,7 +56,7 @@ var xxxx = y; >xxxx : Symbol(xxxx, Decl(es6ImportNamedImportInEs5_1.ts, 2, 3), Decl(es6ImportNamedImportInEs5_1.ts, 4, 3), Decl(es6ImportNamedImportInEs5_1.ts, 6, 3), Decl(es6ImportNamedImportInEs5_1.ts, 7, 3), Decl(es6ImportNamedImportInEs5_1.ts, 9, 3), Decl(es6ImportNamedImportInEs5_1.ts, 11, 3), Decl(es6ImportNamedImportInEs5_1.ts, 13, 3), Decl(es6ImportNamedImportInEs5_1.ts, 14, 3), Decl(es6ImportNamedImportInEs5_1.ts, 16, 3), Decl(es6ImportNamedImportInEs5_1.ts, 17, 3)) >y : Symbol(y, Decl(es6ImportNamedImportInEs5_1.ts, 5, 11)) -import { x as z, } from "es6ImportNamedImportInEs5_0"; +import { x as z, } from "./es6ImportNamedImportInEs5_0"; >x : Symbol(z, Decl(es6ImportNamedImportInEs5_1.ts, 8, 8)) >z : Symbol(z, Decl(es6ImportNamedImportInEs5_1.ts, 8, 8)) @@ -64,14 +64,14 @@ var xxxx = z; >xxxx : Symbol(xxxx, Decl(es6ImportNamedImportInEs5_1.ts, 2, 3), Decl(es6ImportNamedImportInEs5_1.ts, 4, 3), Decl(es6ImportNamedImportInEs5_1.ts, 6, 3), Decl(es6ImportNamedImportInEs5_1.ts, 7, 3), Decl(es6ImportNamedImportInEs5_1.ts, 9, 3), Decl(es6ImportNamedImportInEs5_1.ts, 11, 3), Decl(es6ImportNamedImportInEs5_1.ts, 13, 3), Decl(es6ImportNamedImportInEs5_1.ts, 14, 3), Decl(es6ImportNamedImportInEs5_1.ts, 16, 3), Decl(es6ImportNamedImportInEs5_1.ts, 17, 3)) >z : Symbol(z, Decl(es6ImportNamedImportInEs5_1.ts, 8, 8)) -import { m, } from "es6ImportNamedImportInEs5_0"; +import { m, } from "./es6ImportNamedImportInEs5_0"; >m : Symbol(m, Decl(es6ImportNamedImportInEs5_1.ts, 10, 8)) var xxxx = m; >xxxx : Symbol(xxxx, Decl(es6ImportNamedImportInEs5_1.ts, 2, 3), Decl(es6ImportNamedImportInEs5_1.ts, 4, 3), Decl(es6ImportNamedImportInEs5_1.ts, 6, 3), Decl(es6ImportNamedImportInEs5_1.ts, 7, 3), Decl(es6ImportNamedImportInEs5_1.ts, 9, 3), Decl(es6ImportNamedImportInEs5_1.ts, 11, 3), Decl(es6ImportNamedImportInEs5_1.ts, 13, 3), Decl(es6ImportNamedImportInEs5_1.ts, 14, 3), Decl(es6ImportNamedImportInEs5_1.ts, 16, 3), Decl(es6ImportNamedImportInEs5_1.ts, 17, 3)) >m : Symbol(m, Decl(es6ImportNamedImportInEs5_1.ts, 10, 8)) -import { a1, x1 } from "es6ImportNamedImportInEs5_0"; +import { a1, x1 } from "./es6ImportNamedImportInEs5_0"; >a1 : Symbol(a1, Decl(es6ImportNamedImportInEs5_1.ts, 12, 8)) >x1 : Symbol(x1, Decl(es6ImportNamedImportInEs5_1.ts, 12, 12)) @@ -83,7 +83,7 @@ var xxxx = x1; >xxxx : Symbol(xxxx, Decl(es6ImportNamedImportInEs5_1.ts, 2, 3), Decl(es6ImportNamedImportInEs5_1.ts, 4, 3), Decl(es6ImportNamedImportInEs5_1.ts, 6, 3), Decl(es6ImportNamedImportInEs5_1.ts, 7, 3), Decl(es6ImportNamedImportInEs5_1.ts, 9, 3), Decl(es6ImportNamedImportInEs5_1.ts, 11, 3), Decl(es6ImportNamedImportInEs5_1.ts, 13, 3), Decl(es6ImportNamedImportInEs5_1.ts, 14, 3), Decl(es6ImportNamedImportInEs5_1.ts, 16, 3), Decl(es6ImportNamedImportInEs5_1.ts, 17, 3)) >x1 : Symbol(x1, Decl(es6ImportNamedImportInEs5_1.ts, 12, 12)) -import { a1 as a11, x1 as x11 } from "es6ImportNamedImportInEs5_0"; +import { a1 as a11, x1 as x11 } from "./es6ImportNamedImportInEs5_0"; >a1 : Symbol(a11, Decl(es6ImportNamedImportInEs5_1.ts, 15, 8)) >a11 : Symbol(a11, Decl(es6ImportNamedImportInEs5_1.ts, 15, 8)) >x1 : Symbol(x11, Decl(es6ImportNamedImportInEs5_1.ts, 15, 19)) @@ -97,14 +97,14 @@ var xxxx = x11; >xxxx : Symbol(xxxx, Decl(es6ImportNamedImportInEs5_1.ts, 2, 3), Decl(es6ImportNamedImportInEs5_1.ts, 4, 3), Decl(es6ImportNamedImportInEs5_1.ts, 6, 3), Decl(es6ImportNamedImportInEs5_1.ts, 7, 3), Decl(es6ImportNamedImportInEs5_1.ts, 9, 3), Decl(es6ImportNamedImportInEs5_1.ts, 11, 3), Decl(es6ImportNamedImportInEs5_1.ts, 13, 3), Decl(es6ImportNamedImportInEs5_1.ts, 14, 3), Decl(es6ImportNamedImportInEs5_1.ts, 16, 3), Decl(es6ImportNamedImportInEs5_1.ts, 17, 3)) >x11 : Symbol(x11, Decl(es6ImportNamedImportInEs5_1.ts, 15, 19)) -import { z1 } from "es6ImportNamedImportInEs5_0"; +import { z1 } from "./es6ImportNamedImportInEs5_0"; >z1 : Symbol(z1, Decl(es6ImportNamedImportInEs5_1.ts, 18, 8)) var z111 = z1; >z111 : Symbol(z111, Decl(es6ImportNamedImportInEs5_1.ts, 19, 3)) >z1 : Symbol(z1, Decl(es6ImportNamedImportInEs5_1.ts, 18, 8)) -import { z2 as z3 } from "es6ImportNamedImportInEs5_0"; +import { z2 as z3 } from "./es6ImportNamedImportInEs5_0"; >z2 : Symbol(z3, Decl(es6ImportNamedImportInEs5_1.ts, 20, 8)) >z3 : Symbol(z3, Decl(es6ImportNamedImportInEs5_1.ts, 20, 8)) @@ -113,11 +113,11 @@ var z2 = z3; // z2 shouldn't give redeclare error >z3 : Symbol(z3, Decl(es6ImportNamedImportInEs5_1.ts, 20, 8)) // These are elided -import { aaaa } from "es6ImportNamedImportInEs5_0"; +import { aaaa } from "./es6ImportNamedImportInEs5_0"; >aaaa : Symbol(aaaa, Decl(es6ImportNamedImportInEs5_1.ts, 24, 8)) // These are elided -import { aaaa as bbbb } from "es6ImportNamedImportInEs5_0"; +import { aaaa as bbbb } from "./es6ImportNamedImportInEs5_0"; >aaaa : Symbol(bbbb, Decl(es6ImportNamedImportInEs5_1.ts, 26, 8)) >bbbb : Symbol(bbbb, Decl(es6ImportNamedImportInEs5_1.ts, 26, 8)) diff --git a/tests/baselines/reference/es6ImportNamedImportInEs5.types b/tests/baselines/reference/es6ImportNamedImportInEs5.types index 95f784c5eac..1d55b4bf51e 100644 --- a/tests/baselines/reference/es6ImportNamedImportInEs5.types +++ b/tests/baselines/reference/es6ImportNamedImportInEs5.types @@ -33,15 +33,15 @@ export var aaaa = 10; >10 : number === tests/cases/compiler/es6ImportNamedImportInEs5_1.ts === -import { } from "es6ImportNamedImportInEs5_0"; -import { a } from "es6ImportNamedImportInEs5_0"; +import { } from "./es6ImportNamedImportInEs5_0"; +import { a } from "./es6ImportNamedImportInEs5_0"; >a : number var xxxx = a; >xxxx : number >a : number -import { a as b } from "es6ImportNamedImportInEs5_0"; +import { a as b } from "./es6ImportNamedImportInEs5_0"; >a : number >b : number @@ -49,7 +49,7 @@ var xxxx = b; >xxxx : number >b : number -import { x, a as y } from "es6ImportNamedImportInEs5_0"; +import { x, a as y } from "./es6ImportNamedImportInEs5_0"; >x : number >a : number >y : number @@ -62,7 +62,7 @@ var xxxx = y; >xxxx : number >y : number -import { x as z, } from "es6ImportNamedImportInEs5_0"; +import { x as z, } from "./es6ImportNamedImportInEs5_0"; >x : number >z : number @@ -70,14 +70,14 @@ var xxxx = z; >xxxx : number >z : number -import { m, } from "es6ImportNamedImportInEs5_0"; +import { m, } from "./es6ImportNamedImportInEs5_0"; >m : number var xxxx = m; >xxxx : number >m : number -import { a1, x1 } from "es6ImportNamedImportInEs5_0"; +import { a1, x1 } from "./es6ImportNamedImportInEs5_0"; >a1 : number >x1 : number @@ -89,7 +89,7 @@ var xxxx = x1; >xxxx : number >x1 : number -import { a1 as a11, x1 as x11 } from "es6ImportNamedImportInEs5_0"; +import { a1 as a11, x1 as x11 } from "./es6ImportNamedImportInEs5_0"; >a1 : number >a11 : number >x1 : number @@ -103,14 +103,14 @@ var xxxx = x11; >xxxx : number >x11 : number -import { z1 } from "es6ImportNamedImportInEs5_0"; +import { z1 } from "./es6ImportNamedImportInEs5_0"; >z1 : number var z111 = z1; >z111 : number >z1 : number -import { z2 as z3 } from "es6ImportNamedImportInEs5_0"; +import { z2 as z3 } from "./es6ImportNamedImportInEs5_0"; >z2 : number >z3 : number @@ -119,11 +119,11 @@ var z2 = z3; // z2 shouldn't give redeclare error >z3 : number // These are elided -import { aaaa } from "es6ImportNamedImportInEs5_0"; +import { aaaa } from "./es6ImportNamedImportInEs5_0"; >aaaa : number // These are elided -import { aaaa as bbbb } from "es6ImportNamedImportInEs5_0"; +import { aaaa as bbbb } from "./es6ImportNamedImportInEs5_0"; >aaaa : number >bbbb : number diff --git a/tests/baselines/reference/es6ImportNamedImportInExportAssignment.errors.txt b/tests/baselines/reference/es6ImportNamedImportInExportAssignment.errors.txt index 970c51973b2..fec4d182158 100644 --- a/tests/baselines/reference/es6ImportNamedImportInExportAssignment.errors.txt +++ b/tests/baselines/reference/es6ImportNamedImportInExportAssignment.errors.txt @@ -8,7 +8,7 @@ tests/cases/compiler/es6ImportNamedImportInExportAssignment_1.ts(2,1): error TS1 export var a = 10; ==== tests/cases/compiler/es6ImportNamedImportInExportAssignment_1.ts (1 errors) ==== - import { a } from "es6ImportNamedImportInExportAssignment_0"; + import { a } from "./es6ImportNamedImportInExportAssignment_0"; export = a; ~~~~~~~~~~~ !!! error TS1203: Export assignment cannot be used when targeting ECMAScript 6 or higher. Consider using 'export default' instead. \ No newline at end of file diff --git a/tests/baselines/reference/es6ImportNamedImportInExportAssignment.js b/tests/baselines/reference/es6ImportNamedImportInExportAssignment.js index eab345e4e7f..44ac0d188b3 100644 --- a/tests/baselines/reference/es6ImportNamedImportInExportAssignment.js +++ b/tests/baselines/reference/es6ImportNamedImportInExportAssignment.js @@ -5,17 +5,17 @@ export var a = 10; //// [es6ImportNamedImportInExportAssignment_1.ts] -import { a } from "es6ImportNamedImportInExportAssignment_0"; +import { a } from "./es6ImportNamedImportInExportAssignment_0"; export = a; //// [es6ImportNamedImportInExportAssignment_0.js] export var a = 10; //// [es6ImportNamedImportInExportAssignment_1.js] -import { a } from "es6ImportNamedImportInExportAssignment_0"; +import { a } from "./es6ImportNamedImportInExportAssignment_0"; //// [es6ImportNamedImportInExportAssignment_0.d.ts] export declare var a: number; //// [es6ImportNamedImportInExportAssignment_1.d.ts] -import { a } from "es6ImportNamedImportInExportAssignment_0"; +import { a } from "./es6ImportNamedImportInExportAssignment_0"; export = a; diff --git a/tests/baselines/reference/es6ImportNamedImportInIndirectExportAssignment.js b/tests/baselines/reference/es6ImportNamedImportInIndirectExportAssignment.js index f457e31f53c..418cd76c907 100644 --- a/tests/baselines/reference/es6ImportNamedImportInIndirectExportAssignment.js +++ b/tests/baselines/reference/es6ImportNamedImportInIndirectExportAssignment.js @@ -8,7 +8,7 @@ export module a { } //// [es6ImportNamedImportInIndirectExportAssignment_1.ts] -import { a } from "es6ImportNamedImportInIndirectExportAssignment_0"; +import { a } from "./es6ImportNamedImportInIndirectExportAssignment_0"; import x = a; export = x; @@ -23,7 +23,7 @@ var a; a.c = c; })(a = exports.a || (exports.a = {})); //// [es6ImportNamedImportInIndirectExportAssignment_1.js] -var es6ImportNamedImportInIndirectExportAssignment_0_1 = require("es6ImportNamedImportInIndirectExportAssignment_0"); +var es6ImportNamedImportInIndirectExportAssignment_0_1 = require("./es6ImportNamedImportInIndirectExportAssignment_0"); var x = es6ImportNamedImportInIndirectExportAssignment_0_1.a; module.exports = x; @@ -34,6 +34,6 @@ export declare module a { } } //// [es6ImportNamedImportInIndirectExportAssignment_1.d.ts] -import { a } from "es6ImportNamedImportInIndirectExportAssignment_0"; +import { a } from "./es6ImportNamedImportInIndirectExportAssignment_0"; import x = a; export = x; diff --git a/tests/baselines/reference/es6ImportNamedImportInIndirectExportAssignment.symbols b/tests/baselines/reference/es6ImportNamedImportInIndirectExportAssignment.symbols index 2598735d6d8..24eab96f54b 100644 --- a/tests/baselines/reference/es6ImportNamedImportInIndirectExportAssignment.symbols +++ b/tests/baselines/reference/es6ImportNamedImportInIndirectExportAssignment.symbols @@ -9,13 +9,13 @@ export module a { } === tests/cases/compiler/es6ImportNamedImportInIndirectExportAssignment_1.ts === -import { a } from "es6ImportNamedImportInIndirectExportAssignment_0"; +import { a } from "./es6ImportNamedImportInIndirectExportAssignment_0"; >a : Symbol(a, Decl(es6ImportNamedImportInIndirectExportAssignment_1.ts, 0, 8)) import x = a; ->x : Symbol(x, Decl(es6ImportNamedImportInIndirectExportAssignment_1.ts, 0, 69)) +>x : Symbol(x, Decl(es6ImportNamedImportInIndirectExportAssignment_1.ts, 0, 71)) >a : Symbol(a, Decl(es6ImportNamedImportInIndirectExportAssignment_0.ts, 0, 0)) export = x; ->x : Symbol(x, Decl(es6ImportNamedImportInIndirectExportAssignment_1.ts, 0, 69)) +>x : Symbol(x, Decl(es6ImportNamedImportInIndirectExportAssignment_1.ts, 0, 71)) diff --git a/tests/baselines/reference/es6ImportNamedImportInIndirectExportAssignment.types b/tests/baselines/reference/es6ImportNamedImportInIndirectExportAssignment.types index 36792ece82e..d4dd62aacb2 100644 --- a/tests/baselines/reference/es6ImportNamedImportInIndirectExportAssignment.types +++ b/tests/baselines/reference/es6ImportNamedImportInIndirectExportAssignment.types @@ -9,7 +9,7 @@ export module a { } === tests/cases/compiler/es6ImportNamedImportInIndirectExportAssignment_1.ts === -import { a } from "es6ImportNamedImportInIndirectExportAssignment_0"; +import { a } from "./es6ImportNamedImportInIndirectExportAssignment_0"; >a : typeof a import x = a; diff --git a/tests/baselines/reference/es6ImportNamedImportMergeErrors.errors.txt b/tests/baselines/reference/es6ImportNamedImportMergeErrors.errors.txt index b9461b6caca..4fca12ee8e1 100644 --- a/tests/baselines/reference/es6ImportNamedImportMergeErrors.errors.txt +++ b/tests/baselines/reference/es6ImportNamedImportMergeErrors.errors.txt @@ -12,22 +12,22 @@ tests/cases/compiler/es6ImportNamedImportMergeErrors_1.ts(10,16): error TS2300: export var z1 = a; ==== tests/cases/compiler/es6ImportNamedImportMergeErrors_1.ts (4 errors) ==== - import { a } from "es6ImportNamedImportMergeErrors_0"; + import { a } from "./es6ImportNamedImportMergeErrors_0"; interface a { } // shouldnt be error - import { x as x1 } from "es6ImportNamedImportMergeErrors_0"; + import { x as x1 } from "./es6ImportNamedImportMergeErrors_0"; interface x1 { } // shouldnt be error - import { x } from "es6ImportNamedImportMergeErrors_0"; // should be error + import { x } from "./es6ImportNamedImportMergeErrors_0"; // should be error ~ !!! error TS2440: Import declaration conflicts with local declaration of 'x' var x = 10; - import { x as x44 } from "es6ImportNamedImportMergeErrors_0"; // should be error + import { x as x44 } from "./es6ImportNamedImportMergeErrors_0"; // should be error ~~~~~~~~ !!! error TS2440: Import declaration conflicts with local declaration of 'x44' var x44 = 10; - import { z } from "es6ImportNamedImportMergeErrors_0"; // should be error + import { z } from "./es6ImportNamedImportMergeErrors_0"; // should be error ~ !!! error TS2300: Duplicate identifier 'z'. - import { z1 as z } from "es6ImportNamedImportMergeErrors_0"; // should be error + import { z1 as z } from "./es6ImportNamedImportMergeErrors_0"; // should be error ~ !!! error TS2300: Duplicate identifier 'z'. \ No newline at end of file diff --git a/tests/baselines/reference/es6ImportNamedImportMergeErrors.js b/tests/baselines/reference/es6ImportNamedImportMergeErrors.js index fad411f557d..63bf1127a53 100644 --- a/tests/baselines/reference/es6ImportNamedImportMergeErrors.js +++ b/tests/baselines/reference/es6ImportNamedImportMergeErrors.js @@ -8,16 +8,16 @@ export var z = a; export var z1 = a; //// [es6ImportNamedImportMergeErrors_1.ts] -import { a } from "es6ImportNamedImportMergeErrors_0"; +import { a } from "./es6ImportNamedImportMergeErrors_0"; interface a { } // shouldnt be error -import { x as x1 } from "es6ImportNamedImportMergeErrors_0"; +import { x as x1 } from "./es6ImportNamedImportMergeErrors_0"; interface x1 { } // shouldnt be error -import { x } from "es6ImportNamedImportMergeErrors_0"; // should be error +import { x } from "./es6ImportNamedImportMergeErrors_0"; // should be error var x = 10; -import { x as x44 } from "es6ImportNamedImportMergeErrors_0"; // should be error +import { x as x44 } from "./es6ImportNamedImportMergeErrors_0"; // should be error var x44 = 10; -import { z } from "es6ImportNamedImportMergeErrors_0"; // should be error -import { z1 as z } from "es6ImportNamedImportMergeErrors_0"; // should be error +import { z } from "./es6ImportNamedImportMergeErrors_0"; // should be error +import { z1 as z } from "./es6ImportNamedImportMergeErrors_0"; // should be error //// [es6ImportNamedImportMergeErrors_0.js] diff --git a/tests/baselines/reference/es6ImportNamedImportNoExportMember.errors.txt b/tests/baselines/reference/es6ImportNamedImportNoExportMember.errors.txt index 57a77410cb2..47a836fd422 100644 --- a/tests/baselines/reference/es6ImportNamedImportNoExportMember.errors.txt +++ b/tests/baselines/reference/es6ImportNamedImportNoExportMember.errors.txt @@ -8,9 +8,9 @@ tests/cases/compiler/es6ImportNamedImport_1.ts(2,10): error TS2305: Module '"tes export var x = a; ==== tests/cases/compiler/es6ImportNamedImport_1.ts (2 errors) ==== - import { a1 } from "es6ImportNamedImportNoExportMember_0"; + import { a1 } from "./es6ImportNamedImportNoExportMember_0"; ~~ !!! error TS2305: Module '"tests/cases/compiler/es6ImportNamedImportNoExportMember_0"' has no exported member 'a1'. - import { x1 as x } from "es6ImportNamedImportNoExportMember_0"; + import { x1 as x } from "./es6ImportNamedImportNoExportMember_0"; ~~ !!! error TS2305: Module '"tests/cases/compiler/es6ImportNamedImportNoExportMember_0"' has no exported member 'x1'. \ No newline at end of file diff --git a/tests/baselines/reference/es6ImportNamedImportNoExportMember.js b/tests/baselines/reference/es6ImportNamedImportNoExportMember.js index da473fa42a3..ba607b4626f 100644 --- a/tests/baselines/reference/es6ImportNamedImportNoExportMember.js +++ b/tests/baselines/reference/es6ImportNamedImportNoExportMember.js @@ -6,8 +6,8 @@ export var a = 10; export var x = a; //// [es6ImportNamedImport_1.ts] -import { a1 } from "es6ImportNamedImportNoExportMember_0"; -import { x1 as x } from "es6ImportNamedImportNoExportMember_0"; +import { a1 } from "./es6ImportNamedImportNoExportMember_0"; +import { x1 as x } from "./es6ImportNamedImportNoExportMember_0"; //// [es6ImportNamedImportNoExportMember_0.js] exports.a = 10; diff --git a/tests/baselines/reference/es6ImportNamedImportNoNamedExports.errors.txt b/tests/baselines/reference/es6ImportNamedImportNoNamedExports.errors.txt index a5abd986ee8..e2cacba59e8 100644 --- a/tests/baselines/reference/es6ImportNamedImportNoNamedExports.errors.txt +++ b/tests/baselines/reference/es6ImportNamedImportNoNamedExports.errors.txt @@ -8,9 +8,9 @@ tests/cases/compiler/es6ImportNamedImportNoNamedExports_1.ts(2,10): error TS2305 export = a; ==== tests/cases/compiler/es6ImportNamedImportNoNamedExports_1.ts (2 errors) ==== - import { a } from "es6ImportNamedImportNoNamedExports_0"; + import { a } from "./es6ImportNamedImportNoNamedExports_0"; ~ !!! error TS2305: Module '"tests/cases/compiler/es6ImportNamedImportNoNamedExports_0"' has no exported member 'a'. - import { a as x } from "es6ImportNamedImportNoNamedExports_0"; + import { a as x } from "./es6ImportNamedImportNoNamedExports_0"; ~ !!! error TS2305: Module '"tests/cases/compiler/es6ImportNamedImportNoNamedExports_0"' has no exported member 'a'. \ No newline at end of file diff --git a/tests/baselines/reference/es6ImportNamedImportNoNamedExports.js b/tests/baselines/reference/es6ImportNamedImportNoNamedExports.js index 524860827e6..273f9a3fc3a 100644 --- a/tests/baselines/reference/es6ImportNamedImportNoNamedExports.js +++ b/tests/baselines/reference/es6ImportNamedImportNoNamedExports.js @@ -6,8 +6,8 @@ var a = 10; export = a; //// [es6ImportNamedImportNoNamedExports_1.ts] -import { a } from "es6ImportNamedImportNoNamedExports_0"; -import { a as x } from "es6ImportNamedImportNoNamedExports_0"; +import { a } from "./es6ImportNamedImportNoNamedExports_0"; +import { a as x } from "./es6ImportNamedImportNoNamedExports_0"; //// [es6ImportNamedImportNoNamedExports_0.js] var a = 10; diff --git a/tests/baselines/reference/es6ImportNamedImportWithExport.errors.txt b/tests/baselines/reference/es6ImportNamedImportWithExport.errors.txt index ff8fe604622..a5a4301683e 100644 --- a/tests/baselines/reference/es6ImportNamedImportWithExport.errors.txt +++ b/tests/baselines/reference/es6ImportNamedImportWithExport.errors.txt @@ -24,54 +24,54 @@ tests/cases/compiler/client.ts(26,1): error TS1191: An import declaration cannot export var aaaa = 10; ==== tests/cases/compiler/client.ts (12 errors) ==== - export import { } from "server"; + export import { } from "./server"; ~~~~~~ !!! error TS1191: An import declaration cannot have modifiers. - export import { a } from "server"; + export import { a } from "./server"; ~~~~~~ !!! error TS1191: An import declaration cannot have modifiers. export var xxxx = a; - export import { a as b } from "server"; + export import { a as b } from "./server"; ~~~~~~ !!! error TS1191: An import declaration cannot have modifiers. export var xxxx = b; - export import { x, a as y } from "server"; + export import { x, a as y } from "./server"; ~~~~~~ !!! error TS1191: An import declaration cannot have modifiers. export var xxxx = x; export var xxxx = y; - export import { x as z, } from "server"; + export import { x as z, } from "./server"; ~~~~~~ !!! error TS1191: An import declaration cannot have modifiers. export var xxxx = z; - export import { m, } from "server"; + export import { m, } from "./server"; ~~~~~~ !!! error TS1191: An import declaration cannot have modifiers. export var xxxx = m; - export import { a1, x1 } from "server"; + export import { a1, x1 } from "./server"; ~~~~~~ !!! error TS1191: An import declaration cannot have modifiers. export var xxxx = a1; export var xxxx = x1; - export import { a1 as a11, x1 as x11 } from "server"; + export import { a1 as a11, x1 as x11 } from "./server"; ~~~~~~ !!! error TS1191: An import declaration cannot have modifiers. export var xxxx = a11; export var xxxx = x11; - export import { z1 } from "server"; + export import { z1 } from "./server"; ~~~~~~ !!! error TS1191: An import declaration cannot have modifiers. export var z111 = z1; - export import { z2 as z3 } from "server"; + export import { z2 as z3 } from "./server"; ~~~~~~ !!! error TS1191: An import declaration cannot have modifiers. export var z2 = z3; // z2 shouldn't give redeclare error // Non referenced imports - export import { aaaa } from "server"; + export import { aaaa } from "./server"; ~~~~~~ !!! error TS1191: An import declaration cannot have modifiers. - export import { aaaa as bbbb } from "server"; + export import { aaaa as bbbb } from "./server"; ~~~~~~ !!! error TS1191: An import declaration cannot have modifiers. \ No newline at end of file diff --git a/tests/baselines/reference/es6ImportNamedImportWithExport.js b/tests/baselines/reference/es6ImportNamedImportWithExport.js index 60ba6bf706b..5175554f0f9 100644 --- a/tests/baselines/reference/es6ImportNamedImportWithExport.js +++ b/tests/baselines/reference/es6ImportNamedImportWithExport.js @@ -12,32 +12,32 @@ export var z2 = 10; export var aaaa = 10; //// [client.ts] -export import { } from "server"; -export import { a } from "server"; +export import { } from "./server"; +export import { a } from "./server"; export var xxxx = a; -export import { a as b } from "server"; +export import { a as b } from "./server"; export var xxxx = b; -export import { x, a as y } from "server"; +export import { x, a as y } from "./server"; export var xxxx = x; export var xxxx = y; -export import { x as z, } from "server"; +export import { x as z, } from "./server"; export var xxxx = z; -export import { m, } from "server"; +export import { m, } from "./server"; export var xxxx = m; -export import { a1, x1 } from "server"; +export import { a1, x1 } from "./server"; export var xxxx = a1; export var xxxx = x1; -export import { a1 as a11, x1 as x11 } from "server"; +export import { a1 as a11, x1 as x11 } from "./server"; export var xxxx = a11; export var xxxx = x11; -export import { z1 } from "server"; +export import { z1 } from "./server"; export var z111 = z1; -export import { z2 as z3 } from "server"; +export import { z2 as z3 } from "./server"; export var z2 = z3; // z2 shouldn't give redeclare error // Non referenced imports -export import { aaaa } from "server"; -export import { aaaa as bbbb } from "server"; +export import { aaaa } from "./server"; +export import { aaaa as bbbb } from "./server"; //// [server.js] @@ -50,26 +50,26 @@ exports.z1 = 10; exports.z2 = 10; exports.aaaa = 10; //// [client.js] -var server_1 = require("server"); +var server_1 = require("./server"); exports.xxxx = server_1.a; -var server_2 = require("server"); +var server_2 = require("./server"); exports.xxxx = server_2.a; -var server_3 = require("server"); +var server_3 = require("./server"); exports.xxxx = server_3.x; exports.xxxx = server_3.a; -var server_4 = require("server"); +var server_4 = require("./server"); exports.xxxx = server_4.x; -var server_5 = require("server"); +var server_5 = require("./server"); exports.xxxx = server_5.m; -var server_6 = require("server"); +var server_6 = require("./server"); exports.xxxx = server_6.a1; exports.xxxx = server_6.x1; -var server_7 = require("server"); +var server_7 = require("./server"); exports.xxxx = server_7.a1; exports.xxxx = server_7.x1; -var server_8 = require("server"); +var server_8 = require("./server"); exports.z111 = server_8.z1; -var server_9 = require("server"); +var server_9 = require("./server"); exports.z2 = server_9.z2; // z2 shouldn't give redeclare error diff --git a/tests/baselines/reference/es6ImportNamedImportWithTypesAndValues.js b/tests/baselines/reference/es6ImportNamedImportWithTypesAndValues.js index dcf99c5359a..8593f4e6343 100644 --- a/tests/baselines/reference/es6ImportNamedImportWithTypesAndValues.js +++ b/tests/baselines/reference/es6ImportNamedImportWithTypesAndValues.js @@ -16,7 +16,7 @@ export class C2 implements I2 { } //// [client.ts] -import { C, I, C2 } from "server"; // Shouldnt emit I and C2 into the js file and emit C and I in .d.ts file +import { C, I, C2 } from "./server"; // Shouldnt emit I and C2 into the js file and emit C and I in .d.ts file export type cValInterface = I; export var cVal = new C(); @@ -36,7 +36,7 @@ var C2 = (function () { })(); exports.C2 = C2; //// [client.js] -var server_1 = require("server"); // Shouldnt emit I and C2 into the js file and emit C and I in .d.ts file +var server_1 = require("./server"); // Shouldnt emit I and C2 into the js file and emit C and I in .d.ts file exports.cVal = new server_1.C(); @@ -54,6 +54,6 @@ export declare class C2 implements I2 { prop2: string; } //// [client.d.ts] -import { C, I } from "server"; +import { C, I } from "./server"; export declare type cValInterface = I; export declare var cVal: C; diff --git a/tests/baselines/reference/es6ImportNamedImportWithTypesAndValues.symbols b/tests/baselines/reference/es6ImportNamedImportWithTypesAndValues.symbols index e294124c6f4..cff0406b220 100644 --- a/tests/baselines/reference/es6ImportNamedImportWithTypesAndValues.symbols +++ b/tests/baselines/reference/es6ImportNamedImportWithTypesAndValues.symbols @@ -28,13 +28,13 @@ export class C2 implements I2 { } === tests/cases/compiler/client.ts === -import { C, I, C2 } from "server"; // Shouldnt emit I and C2 into the js file and emit C and I in .d.ts file +import { C, I, C2 } from "./server"; // Shouldnt emit I and C2 into the js file and emit C and I in .d.ts file >C : Symbol(C, Decl(client.ts, 0, 8)) >I : Symbol(I, Decl(client.ts, 0, 11)) >C2 : Symbol(C2, Decl(client.ts, 0, 14)) export type cValInterface = I; ->cValInterface : Symbol(cValInterface, Decl(client.ts, 0, 34)) +>cValInterface : Symbol(cValInterface, Decl(client.ts, 0, 36)) >I : Symbol(I, Decl(client.ts, 0, 11)) export var cVal = new C(); diff --git a/tests/baselines/reference/es6ImportNamedImportWithTypesAndValues.types b/tests/baselines/reference/es6ImportNamedImportWithTypesAndValues.types index 12e5271c8b0..a65a2978e1b 100644 --- a/tests/baselines/reference/es6ImportNamedImportWithTypesAndValues.types +++ b/tests/baselines/reference/es6ImportNamedImportWithTypesAndValues.types @@ -30,7 +30,7 @@ export class C2 implements I2 { } === tests/cases/compiler/client.ts === -import { C, I, C2 } from "server"; // Shouldnt emit I and C2 into the js file and emit C and I in .d.ts file +import { C, I, C2 } from "./server"; // Shouldnt emit I and C2 into the js file and emit C and I in .d.ts file >C : typeof C >I : any >C2 : typeof C2 diff --git a/tests/baselines/reference/exportAssignClassAndModule.js b/tests/baselines/reference/exportAssignClassAndModule.js index 37fecdcc53f..d440fb9a8e5 100644 --- a/tests/baselines/reference/exportAssignClassAndModule.js +++ b/tests/baselines/reference/exportAssignClassAndModule.js @@ -12,7 +12,7 @@ export = Foo; //// [exportAssignClassAndModule_1.ts] /// -import Foo = require('exportAssignClassAndModule_0'); +import Foo = require('./exportAssignClassAndModule_0'); var z: Foo.Bar; var zz: Foo; diff --git a/tests/baselines/reference/exportAssignClassAndModule.symbols b/tests/baselines/reference/exportAssignClassAndModule.symbols index 9f38ed80b1b..016e91f79a2 100644 --- a/tests/baselines/reference/exportAssignClassAndModule.symbols +++ b/tests/baselines/reference/exportAssignClassAndModule.symbols @@ -1,6 +1,6 @@ === tests/cases/compiler/exportAssignClassAndModule_1.ts === /// -import Foo = require('exportAssignClassAndModule_0'); +import Foo = require('./exportAssignClassAndModule_0'); >Foo : Symbol(Foo, Decl(exportAssignClassAndModule_1.ts, 0, 0)) var z: Foo.Bar; diff --git a/tests/baselines/reference/exportAssignClassAndModule.types b/tests/baselines/reference/exportAssignClassAndModule.types index aa1ede6b2d4..5517d32badc 100644 --- a/tests/baselines/reference/exportAssignClassAndModule.types +++ b/tests/baselines/reference/exportAssignClassAndModule.types @@ -1,6 +1,6 @@ === tests/cases/compiler/exportAssignClassAndModule_1.ts === /// -import Foo = require('exportAssignClassAndModule_0'); +import Foo = require('./exportAssignClassAndModule_0'); >Foo : typeof Foo var z: Foo.Bar; diff --git a/tests/baselines/reference/exportAssignmentEnum.js b/tests/baselines/reference/exportAssignmentEnum.js index a484e43738f..06438fb2b53 100644 --- a/tests/baselines/reference/exportAssignmentEnum.js +++ b/tests/baselines/reference/exportAssignmentEnum.js @@ -10,7 +10,7 @@ enum E { export = E; //// [exportAssignmentEnum_B.ts] -import EnumE = require("exportAssignmentEnum_A"); +import EnumE = require("./exportAssignmentEnum_A"); var a = EnumE.A; var b = EnumE.B; @@ -25,7 +25,7 @@ var E; })(E || (E = {})); module.exports = E; //// [exportAssignmentEnum_B.js] -var EnumE = require("exportAssignmentEnum_A"); +var EnumE = require("./exportAssignmentEnum_A"); var a = EnumE.A; var b = EnumE.B; var c = EnumE.C; diff --git a/tests/baselines/reference/exportAssignmentEnum.symbols b/tests/baselines/reference/exportAssignmentEnum.symbols index 07eb5f7b907..dea194b3508 100644 --- a/tests/baselines/reference/exportAssignmentEnum.symbols +++ b/tests/baselines/reference/exportAssignmentEnum.symbols @@ -1,5 +1,5 @@ === tests/cases/compiler/exportAssignmentEnum_B.ts === -import EnumE = require("exportAssignmentEnum_A"); +import EnumE = require("./exportAssignmentEnum_A"); >EnumE : Symbol(EnumE, Decl(exportAssignmentEnum_B.ts, 0, 0)) var a = EnumE.A; diff --git a/tests/baselines/reference/exportAssignmentEnum.types b/tests/baselines/reference/exportAssignmentEnum.types index 9dfa34d3777..a186cf6f255 100644 --- a/tests/baselines/reference/exportAssignmentEnum.types +++ b/tests/baselines/reference/exportAssignmentEnum.types @@ -1,5 +1,5 @@ === tests/cases/compiler/exportAssignmentEnum_B.ts === -import EnumE = require("exportAssignmentEnum_A"); +import EnumE = require("./exportAssignmentEnum_A"); >EnumE : typeof EnumE var a = EnumE.A; diff --git a/tests/baselines/reference/exportAssignmentOfDeclaredExternalModule.errors.txt b/tests/baselines/reference/exportAssignmentOfDeclaredExternalModule.errors.txt index f6736e468f0..b0bfac0adfd 100644 --- a/tests/baselines/reference/exportAssignmentOfDeclaredExternalModule.errors.txt +++ b/tests/baselines/reference/exportAssignmentOfDeclaredExternalModule.errors.txt @@ -4,7 +4,7 @@ tests/cases/compiler/exportAssignmentOfDeclaredExternalModule_1.ts(4,9): error T ==== tests/cases/compiler/exportAssignmentOfDeclaredExternalModule_1.ts (2 errors) ==== /// - import Sammy = require('exportAssignmentOfDeclaredExternalModule_0'); + import Sammy = require('./exportAssignmentOfDeclaredExternalModule_0'); var x = new Sammy(); // error to use as constructor as there is not constructor symbol ~~~~~ !!! error TS2304: Cannot find name 'Sammy'. diff --git a/tests/baselines/reference/exportAssignmentOfDeclaredExternalModule.js b/tests/baselines/reference/exportAssignmentOfDeclaredExternalModule.js index c8ba8324ad2..460707a3502 100644 --- a/tests/baselines/reference/exportAssignmentOfDeclaredExternalModule.js +++ b/tests/baselines/reference/exportAssignmentOfDeclaredExternalModule.js @@ -9,7 +9,7 @@ export = Sammy; //// [exportAssignmentOfDeclaredExternalModule_1.ts] /// -import Sammy = require('exportAssignmentOfDeclaredExternalModule_0'); +import Sammy = require('./exportAssignmentOfDeclaredExternalModule_0'); var x = new Sammy(); // error to use as constructor as there is not constructor symbol var y = Sammy(); // error to use interface name as call target var z: Sammy; // no error - z is of type interface Sammy from module 'M' diff --git a/tests/baselines/reference/exportAssignmentVariable.js b/tests/baselines/reference/exportAssignmentVariable.js index c20e6ec4f7b..8afbf222e6d 100644 --- a/tests/baselines/reference/exportAssignmentVariable.js +++ b/tests/baselines/reference/exportAssignmentVariable.js @@ -6,7 +6,7 @@ var x = 0; export = x; //// [exportAssignmentVariable_B.ts] -import y = require("exportAssignmentVariable_A"); +import y = require("./exportAssignmentVariable_A"); var n: number = y; @@ -14,5 +14,5 @@ var n: number = y; var x = 0; module.exports = x; //// [exportAssignmentVariable_B.js] -var y = require("exportAssignmentVariable_A"); +var y = require("./exportAssignmentVariable_A"); var n = y; diff --git a/tests/baselines/reference/exportAssignmentVariable.symbols b/tests/baselines/reference/exportAssignmentVariable.symbols index b819678d080..919a96ded33 100644 --- a/tests/baselines/reference/exportAssignmentVariable.symbols +++ b/tests/baselines/reference/exportAssignmentVariable.symbols @@ -1,5 +1,5 @@ === tests/cases/compiler/exportAssignmentVariable_B.ts === -import y = require("exportAssignmentVariable_A"); +import y = require("./exportAssignmentVariable_A"); >y : Symbol(y, Decl(exportAssignmentVariable_B.ts, 0, 0)) var n: number = y; diff --git a/tests/baselines/reference/exportAssignmentVariable.types b/tests/baselines/reference/exportAssignmentVariable.types index 71f0afdea68..7c6d9b45cce 100644 --- a/tests/baselines/reference/exportAssignmentVariable.types +++ b/tests/baselines/reference/exportAssignmentVariable.types @@ -1,5 +1,5 @@ === tests/cases/compiler/exportAssignmentVariable_B.ts === -import y = require("exportAssignmentVariable_A"); +import y = require("./exportAssignmentVariable_A"); >y : number var n: number = y; diff --git a/tests/baselines/reference/exportEqualMemberMissing.errors.txt b/tests/baselines/reference/exportEqualMemberMissing.errors.txt index 3e6e7a35a12..4cd142668b9 100644 --- a/tests/baselines/reference/exportEqualMemberMissing.errors.txt +++ b/tests/baselines/reference/exportEqualMemberMissing.errors.txt @@ -3,7 +3,7 @@ tests/cases/compiler/exportEqualMemberMissing_1.ts(3,23): error TS2339: Property ==== tests/cases/compiler/exportEqualMemberMissing_1.ts (1 errors) ==== /// - import connect = require('exportEqualMemberMissing_0'); + import connect = require('./exportEqualMemberMissing_0'); connect().use(connect.static('foo')); // Error 1 The property 'static' does not exist on value of type ''. ~~~~~~ !!! error TS2339: Property 'static' does not exist on type '{ (): connectExport; foo: Date; }'. diff --git a/tests/baselines/reference/exportEqualMemberMissing.js b/tests/baselines/reference/exportEqualMemberMissing.js index 583176f12f3..85972ce0945 100644 --- a/tests/baselines/reference/exportEqualMemberMissing.js +++ b/tests/baselines/reference/exportEqualMemberMissing.js @@ -17,7 +17,7 @@ export = server; //// [exportEqualMemberMissing_1.ts] /// -import connect = require('exportEqualMemberMissing_0'); +import connect = require('./exportEqualMemberMissing_0'); connect().use(connect.static('foo')); // Error 1 The property 'static' does not exist on value of type ''. @@ -26,5 +26,5 @@ var server; module.exports = server; //// [exportEqualMemberMissing_1.js] /// -var connect = require('exportEqualMemberMissing_0'); +var connect = require('./exportEqualMemberMissing_0'); connect().use(connect.static('foo')); // Error 1 The property 'static' does not exist on value of type ''. diff --git a/tests/baselines/reference/exportStarFromEmptyModule.errors.txt b/tests/baselines/reference/exportStarFromEmptyModule.errors.txt index c88ac3b3f19..9d781da2707 100644 --- a/tests/baselines/reference/exportStarFromEmptyModule.errors.txt +++ b/tests/baselines/reference/exportStarFromEmptyModule.errors.txt @@ -12,17 +12,17 @@ tests/cases/compiler/exportStarFromEmptyModule_module4.ts(4,5): error TS2339: Pr // empty ==== tests/cases/compiler/exportStarFromEmptyModule_module3.ts (1 errors) ==== - export * from "exportStarFromEmptyModule_module2"; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + export * from "./exportStarFromEmptyModule_module2"; + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS2306: File 'exportStarFromEmptyModule_module2.ts' is not a module. - export * from "exportStarFromEmptyModule_module1"; + export * from "./exportStarFromEmptyModule_module1"; export class A { static q; } ==== tests/cases/compiler/exportStarFromEmptyModule_module4.ts (1 errors) ==== - import * as X from "exportStarFromEmptyModule_module3"; + import * as X from "./exportStarFromEmptyModule_module3"; var s: X.A; X.A.q; X.A.r; // Error diff --git a/tests/baselines/reference/exportStarFromEmptyModule.js b/tests/baselines/reference/exportStarFromEmptyModule.js index 9b486af4eae..d433e7b3682 100644 --- a/tests/baselines/reference/exportStarFromEmptyModule.js +++ b/tests/baselines/reference/exportStarFromEmptyModule.js @@ -10,15 +10,15 @@ export class A { // empty //// [exportStarFromEmptyModule_module3.ts] -export * from "exportStarFromEmptyModule_module2"; -export * from "exportStarFromEmptyModule_module1"; +export * from "./exportStarFromEmptyModule_module2"; +export * from "./exportStarFromEmptyModule_module1"; export class A { static q; } //// [exportStarFromEmptyModule_module4.ts] -import * as X from "exportStarFromEmptyModule_module3"; +import * as X from "./exportStarFromEmptyModule_module3"; var s: X.A; X.A.q; X.A.r; // Error @@ -36,8 +36,8 @@ exports.A = A; function __export(m) { for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p]; } -__export(require("exportStarFromEmptyModule_module2")); -__export(require("exportStarFromEmptyModule_module1")); +__export(require("./exportStarFromEmptyModule_module2")); +__export(require("./exportStarFromEmptyModule_module1")); var A = (function () { function A() { } @@ -45,7 +45,7 @@ var A = (function () { })(); exports.A = A; //// [exportStarFromEmptyModule_module4.js] -var X = require("exportStarFromEmptyModule_module3"); +var X = require("./exportStarFromEmptyModule_module3"); var s; X.A.q; X.A.r; // Error @@ -57,8 +57,8 @@ export declare class A { } //// [exportStarFromEmptyModule_module2.d.ts] //// [exportStarFromEmptyModule_module3.d.ts] -export * from "exportStarFromEmptyModule_module2"; -export * from "exportStarFromEmptyModule_module1"; +export * from "./exportStarFromEmptyModule_module2"; +export * from "./exportStarFromEmptyModule_module1"; export declare class A { static q: any; } diff --git a/tests/baselines/reference/extendingClassFromAliasAndUsageInIndexer.js b/tests/baselines/reference/extendingClassFromAliasAndUsageInIndexer.js index 297a7527ec0..3c05ccc6866 100644 --- a/tests/baselines/reference/extendingClassFromAliasAndUsageInIndexer.js +++ b/tests/baselines/reference/extendingClassFromAliasAndUsageInIndexer.js @@ -6,21 +6,21 @@ export class Model { } //// [extendingClassFromAliasAndUsageInIndexer_moduleA.ts] -import Backbone = require("extendingClassFromAliasAndUsageInIndexer_backbone"); +import Backbone = require("./extendingClassFromAliasAndUsageInIndexer_backbone"); export class VisualizationModel extends Backbone.Model { // interesting stuff here } //// [extendingClassFromAliasAndUsageInIndexer_moduleB.ts] -import Backbone = require("extendingClassFromAliasAndUsageInIndexer_backbone"); +import Backbone = require("./extendingClassFromAliasAndUsageInIndexer_backbone"); export class VisualizationModel extends Backbone.Model { // different interesting stuff here } //// [extendingClassFromAliasAndUsageInIndexer_main.ts] -import Backbone = require("extendingClassFromAliasAndUsageInIndexer_backbone"); -import moduleA = require("extendingClassFromAliasAndUsageInIndexer_moduleA"); -import moduleB = require("extendingClassFromAliasAndUsageInIndexer_moduleB"); +import Backbone = require("./extendingClassFromAliasAndUsageInIndexer_backbone"); +import moduleA = require("./extendingClassFromAliasAndUsageInIndexer_moduleA"); +import moduleB = require("./extendingClassFromAliasAndUsageInIndexer_moduleB"); interface IHasVisualizationModel { VisualizationModel: typeof Backbone.Model; } @@ -45,7 +45,7 @@ var __extends = (this && this.__extends) || function (d, b) { function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; -var Backbone = require("extendingClassFromAliasAndUsageInIndexer_backbone"); +var Backbone = require("./extendingClassFromAliasAndUsageInIndexer_backbone"); var VisualizationModel = (function (_super) { __extends(VisualizationModel, _super); function VisualizationModel() { @@ -60,7 +60,7 @@ var __extends = (this && this.__extends) || function (d, b) { function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; -var Backbone = require("extendingClassFromAliasAndUsageInIndexer_backbone"); +var Backbone = require("./extendingClassFromAliasAndUsageInIndexer_backbone"); var VisualizationModel = (function (_super) { __extends(VisualizationModel, _super); function VisualizationModel() { @@ -70,8 +70,8 @@ var VisualizationModel = (function (_super) { })(Backbone.Model); exports.VisualizationModel = VisualizationModel; //// [extendingClassFromAliasAndUsageInIndexer_main.js] -var moduleA = require("extendingClassFromAliasAndUsageInIndexer_moduleA"); -var moduleB = require("extendingClassFromAliasAndUsageInIndexer_moduleB"); +var moduleA = require("./extendingClassFromAliasAndUsageInIndexer_moduleA"); +var moduleB = require("./extendingClassFromAliasAndUsageInIndexer_moduleB"); var moduleATyped = moduleA; var moduleMap = { "moduleA": moduleA, diff --git a/tests/baselines/reference/extendingClassFromAliasAndUsageInIndexer.symbols b/tests/baselines/reference/extendingClassFromAliasAndUsageInIndexer.symbols index 02d57509a55..33e0c226e67 100644 --- a/tests/baselines/reference/extendingClassFromAliasAndUsageInIndexer.symbols +++ b/tests/baselines/reference/extendingClassFromAliasAndUsageInIndexer.symbols @@ -1,15 +1,15 @@ === tests/cases/compiler/extendingClassFromAliasAndUsageInIndexer_main.ts === -import Backbone = require("extendingClassFromAliasAndUsageInIndexer_backbone"); +import Backbone = require("./extendingClassFromAliasAndUsageInIndexer_backbone"); >Backbone : Symbol(Backbone, Decl(extendingClassFromAliasAndUsageInIndexer_main.ts, 0, 0)) -import moduleA = require("extendingClassFromAliasAndUsageInIndexer_moduleA"); ->moduleA : Symbol(moduleA, Decl(extendingClassFromAliasAndUsageInIndexer_main.ts, 0, 79)) +import moduleA = require("./extendingClassFromAliasAndUsageInIndexer_moduleA"); +>moduleA : Symbol(moduleA, Decl(extendingClassFromAliasAndUsageInIndexer_main.ts, 0, 81)) -import moduleB = require("extendingClassFromAliasAndUsageInIndexer_moduleB"); ->moduleB : Symbol(moduleB, Decl(extendingClassFromAliasAndUsageInIndexer_main.ts, 1, 77)) +import moduleB = require("./extendingClassFromAliasAndUsageInIndexer_moduleB"); +>moduleB : Symbol(moduleB, Decl(extendingClassFromAliasAndUsageInIndexer_main.ts, 1, 79)) interface IHasVisualizationModel { ->IHasVisualizationModel : Symbol(IHasVisualizationModel, Decl(extendingClassFromAliasAndUsageInIndexer_main.ts, 2, 77)) +>IHasVisualizationModel : Symbol(IHasVisualizationModel, Decl(extendingClassFromAliasAndUsageInIndexer_main.ts, 2, 79)) VisualizationModel: typeof Backbone.Model; >VisualizationModel : Symbol(VisualizationModel, Decl(extendingClassFromAliasAndUsageInIndexer_main.ts, 3, 34)) @@ -19,19 +19,19 @@ interface IHasVisualizationModel { } var moduleATyped: IHasVisualizationModel = moduleA; >moduleATyped : Symbol(moduleATyped, Decl(extendingClassFromAliasAndUsageInIndexer_main.ts, 6, 3)) ->IHasVisualizationModel : Symbol(IHasVisualizationModel, Decl(extendingClassFromAliasAndUsageInIndexer_main.ts, 2, 77)) ->moduleA : Symbol(moduleA, Decl(extendingClassFromAliasAndUsageInIndexer_main.ts, 0, 79)) +>IHasVisualizationModel : Symbol(IHasVisualizationModel, Decl(extendingClassFromAliasAndUsageInIndexer_main.ts, 2, 79)) +>moduleA : Symbol(moduleA, Decl(extendingClassFromAliasAndUsageInIndexer_main.ts, 0, 81)) var moduleMap: { [key: string]: IHasVisualizationModel } = { >moduleMap : Symbol(moduleMap, Decl(extendingClassFromAliasAndUsageInIndexer_main.ts, 7, 3)) >key : Symbol(key, Decl(extendingClassFromAliasAndUsageInIndexer_main.ts, 7, 18)) ->IHasVisualizationModel : Symbol(IHasVisualizationModel, Decl(extendingClassFromAliasAndUsageInIndexer_main.ts, 2, 77)) +>IHasVisualizationModel : Symbol(IHasVisualizationModel, Decl(extendingClassFromAliasAndUsageInIndexer_main.ts, 2, 79)) "moduleA": moduleA, ->moduleA : Symbol(moduleA, Decl(extendingClassFromAliasAndUsageInIndexer_main.ts, 0, 79)) +>moduleA : Symbol(moduleA, Decl(extendingClassFromAliasAndUsageInIndexer_main.ts, 0, 81)) "moduleB": moduleB ->moduleB : Symbol(moduleB, Decl(extendingClassFromAliasAndUsageInIndexer_main.ts, 1, 77)) +>moduleB : Symbol(moduleB, Decl(extendingClassFromAliasAndUsageInIndexer_main.ts, 1, 79)) }; var moduleName: string; @@ -53,11 +53,11 @@ export class Model { } === tests/cases/compiler/extendingClassFromAliasAndUsageInIndexer_moduleA.ts === -import Backbone = require("extendingClassFromAliasAndUsageInIndexer_backbone"); +import Backbone = require("./extendingClassFromAliasAndUsageInIndexer_backbone"); >Backbone : Symbol(Backbone, Decl(extendingClassFromAliasAndUsageInIndexer_moduleA.ts, 0, 0)) export class VisualizationModel extends Backbone.Model { ->VisualizationModel : Symbol(VisualizationModel, Decl(extendingClassFromAliasAndUsageInIndexer_moduleA.ts, 0, 79)) +>VisualizationModel : Symbol(VisualizationModel, Decl(extendingClassFromAliasAndUsageInIndexer_moduleA.ts, 0, 81)) >Backbone.Model : Symbol(Backbone.Model, Decl(extendingClassFromAliasAndUsageInIndexer_backbone.ts, 0, 0)) >Backbone : Symbol(Backbone, Decl(extendingClassFromAliasAndUsageInIndexer_moduleA.ts, 0, 0)) >Model : Symbol(Backbone.Model, Decl(extendingClassFromAliasAndUsageInIndexer_backbone.ts, 0, 0)) @@ -66,11 +66,11 @@ export class VisualizationModel extends Backbone.Model { } === tests/cases/compiler/extendingClassFromAliasAndUsageInIndexer_moduleB.ts === -import Backbone = require("extendingClassFromAliasAndUsageInIndexer_backbone"); +import Backbone = require("./extendingClassFromAliasAndUsageInIndexer_backbone"); >Backbone : Symbol(Backbone, Decl(extendingClassFromAliasAndUsageInIndexer_moduleB.ts, 0, 0)) export class VisualizationModel extends Backbone.Model { ->VisualizationModel : Symbol(VisualizationModel, Decl(extendingClassFromAliasAndUsageInIndexer_moduleB.ts, 0, 79)) +>VisualizationModel : Symbol(VisualizationModel, Decl(extendingClassFromAliasAndUsageInIndexer_moduleB.ts, 0, 81)) >Backbone.Model : Symbol(Backbone.Model, Decl(extendingClassFromAliasAndUsageInIndexer_backbone.ts, 0, 0)) >Backbone : Symbol(Backbone, Decl(extendingClassFromAliasAndUsageInIndexer_moduleB.ts, 0, 0)) >Model : Symbol(Backbone.Model, Decl(extendingClassFromAliasAndUsageInIndexer_backbone.ts, 0, 0)) diff --git a/tests/baselines/reference/extendingClassFromAliasAndUsageInIndexer.types b/tests/baselines/reference/extendingClassFromAliasAndUsageInIndexer.types index b5323ae5c85..e1bfd195698 100644 --- a/tests/baselines/reference/extendingClassFromAliasAndUsageInIndexer.types +++ b/tests/baselines/reference/extendingClassFromAliasAndUsageInIndexer.types @@ -1,11 +1,11 @@ === tests/cases/compiler/extendingClassFromAliasAndUsageInIndexer_main.ts === -import Backbone = require("extendingClassFromAliasAndUsageInIndexer_backbone"); +import Backbone = require("./extendingClassFromAliasAndUsageInIndexer_backbone"); >Backbone : typeof Backbone -import moduleA = require("extendingClassFromAliasAndUsageInIndexer_moduleA"); +import moduleA = require("./extendingClassFromAliasAndUsageInIndexer_moduleA"); >moduleA : typeof moduleA -import moduleB = require("extendingClassFromAliasAndUsageInIndexer_moduleB"); +import moduleB = require("./extendingClassFromAliasAndUsageInIndexer_moduleB"); >moduleB : typeof moduleB interface IHasVisualizationModel { @@ -56,7 +56,7 @@ export class Model { } === tests/cases/compiler/extendingClassFromAliasAndUsageInIndexer_moduleA.ts === -import Backbone = require("extendingClassFromAliasAndUsageInIndexer_backbone"); +import Backbone = require("./extendingClassFromAliasAndUsageInIndexer_backbone"); >Backbone : typeof Backbone export class VisualizationModel extends Backbone.Model { @@ -69,7 +69,7 @@ export class VisualizationModel extends Backbone.Model { } === tests/cases/compiler/extendingClassFromAliasAndUsageInIndexer_moduleB.ts === -import Backbone = require("extendingClassFromAliasAndUsageInIndexer_backbone"); +import Backbone = require("./extendingClassFromAliasAndUsageInIndexer_backbone"); >Backbone : typeof Backbone export class VisualizationModel extends Backbone.Model { diff --git a/tests/baselines/reference/externalModuleExportingGenericClass.errors.txt b/tests/baselines/reference/externalModuleExportingGenericClass.errors.txt index c8712b20864..7825345a1b5 100644 --- a/tests/baselines/reference/externalModuleExportingGenericClass.errors.txt +++ b/tests/baselines/reference/externalModuleExportingGenericClass.errors.txt @@ -2,7 +2,7 @@ tests/cases/compiler/externalModuleExportingGenericClass_file1.ts(2,8): error TS ==== tests/cases/compiler/externalModuleExportingGenericClass_file1.ts (1 errors) ==== - import a = require('externalModuleExportingGenericClass_file0'); + import a = require('./externalModuleExportingGenericClass_file0'); var v: a; // this should report error ~ !!! error TS2314: Generic type 'C' requires 1 type argument(s). diff --git a/tests/baselines/reference/externalModuleExportingGenericClass.js b/tests/baselines/reference/externalModuleExportingGenericClass.js index 14f18ddfc04..5dc1e9bea1d 100644 --- a/tests/baselines/reference/externalModuleExportingGenericClass.js +++ b/tests/baselines/reference/externalModuleExportingGenericClass.js @@ -9,7 +9,7 @@ export = C; //// [externalModuleExportingGenericClass_file1.ts] -import a = require('externalModuleExportingGenericClass_file0'); +import a = require('./externalModuleExportingGenericClass_file0'); var v: a; // this should report error var v2: any = (new a()).foo; var v3: number = (new a()).foo; @@ -23,7 +23,7 @@ var C = (function () { })(); module.exports = C; //// [externalModuleExportingGenericClass_file1.js] -var a = require('externalModuleExportingGenericClass_file0'); +var a = require('./externalModuleExportingGenericClass_file0'); var v; // this should report error var v2 = (new a()).foo; var v3 = (new a()).foo; diff --git a/tests/baselines/reference/externalModuleImmutableBindings.errors.txt b/tests/baselines/reference/externalModuleImmutableBindings.errors.txt index 8ab07c26851..a6040c154f0 100644 --- a/tests/baselines/reference/externalModuleImmutableBindings.errors.txt +++ b/tests/baselines/reference/externalModuleImmutableBindings.errors.txt @@ -16,7 +16,7 @@ tests/cases/compiler/f2.ts(41,13): error TS2339: Property 'blah' does not exist ==== tests/cases/compiler/f2.ts (10 errors) ==== // all mutations below are illegal and should be fixed - import * as stuff from 'f1'; + import * as stuff from './f1'; var n = 'baz'; diff --git a/tests/baselines/reference/externalModuleImmutableBindings.js b/tests/baselines/reference/externalModuleImmutableBindings.js index 5e5ba6c2294..47d83ded80c 100644 --- a/tests/baselines/reference/externalModuleImmutableBindings.js +++ b/tests/baselines/reference/externalModuleImmutableBindings.js @@ -6,7 +6,7 @@ export var x = 1; //// [f2.ts] // all mutations below are illegal and should be fixed -import * as stuff from 'f1'; +import * as stuff from './f1'; var n = 'baz'; @@ -55,7 +55,7 @@ for ((stuff[n]) of []) {} exports.x = 1; //// [f2.js] // all mutations below are illegal and should be fixed -var stuff = require('f1'); +var stuff = require('./f1'); var n = 'baz'; stuff.x = 0; stuff['x'] = 1; diff --git a/tests/baselines/reference/importAsBaseClass.errors.txt b/tests/baselines/reference/importAsBaseClass.errors.txt index 835fd143f70..8f23baad543 100644 --- a/tests/baselines/reference/importAsBaseClass.errors.txt +++ b/tests/baselines/reference/importAsBaseClass.errors.txt @@ -2,7 +2,7 @@ tests/cases/compiler/importAsBaseClass_1.ts(2,21): error TS2507: Type 'typeof "t ==== tests/cases/compiler/importAsBaseClass_1.ts (1 errors) ==== - import Greeter = require("importAsBaseClass_0"); + import Greeter = require("./importAsBaseClass_0"); class Hello extends Greeter { } ~~~~~~~ !!! error TS2507: Type 'typeof "tests/cases/compiler/importAsBaseClass_0"' is not a constructor function type. diff --git a/tests/baselines/reference/importAsBaseClass.js b/tests/baselines/reference/importAsBaseClass.js index b79905911b1..57d71af2cda 100644 --- a/tests/baselines/reference/importAsBaseClass.js +++ b/tests/baselines/reference/importAsBaseClass.js @@ -6,7 +6,7 @@ export class Greeter { } //// [importAsBaseClass_1.ts] -import Greeter = require("importAsBaseClass_0"); +import Greeter = require("./importAsBaseClass_0"); class Hello extends Greeter { } @@ -24,7 +24,7 @@ var __extends = (this && this.__extends) || function (d, b) { function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; -var Greeter = require("importAsBaseClass_0"); +var Greeter = require("./importAsBaseClass_0"); var Hello = (function (_super) { __extends(Hello, _super); function Hello() { diff --git a/tests/baselines/reference/importDecl.js b/tests/baselines/reference/importDecl.js index fb2aa6e0d1f..4b2672c4135 100644 --- a/tests/baselines/reference/importDecl.js +++ b/tests/baselines/reference/importDecl.js @@ -29,7 +29,7 @@ export var x: d; export function foo(): d { return null; } //// [importDecl_require4.ts] -import m4 = require("importDecl_require"); +import m4 = require("./importDecl_require"); export function foo2(): m4.d { return null; } //// [importDecl_1.ts] @@ -38,7 +38,7 @@ export function foo2(): m4.d { return null; } /// /// /// -import m4 = require("importDecl_require"); // Emit used +import m4 = require("./importDecl_require"); // Emit used export var x4 = m4.x; export var d4 = m4.d; export var f4 = m4.foo(); @@ -54,16 +54,16 @@ export module m1 { } //Emit global only usage -import glo_m4 = require("importDecl_require1"); +import glo_m4 = require("./importDecl_require1"); export var useGlo_m4_d4 = glo_m4.d; export var useGlo_m4_f4 = glo_m4.foo(); //Emit even when used just in function type -import fncOnly_m4 = require("importDecl_require2"); +import fncOnly_m4 = require("./importDecl_require2"); export var useFncOnly_m4_f4 = fncOnly_m4.foo(); // only used privately no need to emit -import private_m4 = require("importDecl_require3"); +import private_m4 = require("./importDecl_require3"); export module usePrivate_m4_m1 { var x3 = private_m4.x; var d3 = private_m4.d; @@ -71,11 +71,11 @@ export module usePrivate_m4_m1 { } // Do not emit unused import -import m5 = require("importDecl_require4"); +import m5 = require("./importDecl_require4"); export var d = m5.foo2(); // Do not emit multiple used import statements -import multiImport_m4 = require("importDecl_require"); // Emit used +import multiImport_m4 = require("./importDecl_require"); // Emit used export var useMultiImport_m4_x4 = multiImport_m4.x; export var useMultiImport_m4_d4 = multiImport_m4.d; export var useMultiImport_m4_f4 = multiImport_m4.foo(); @@ -127,7 +127,7 @@ exports.foo2 = foo2; /// /// /// -var m4 = require("importDecl_require"); // Emit used +var m4 = require("./importDecl_require"); // Emit used exports.x4 = m4.x; exports.d4 = m4.d; exports.f4 = m4.foo(); @@ -141,14 +141,14 @@ var m1; var f3 = m4.foo(); })(m1 = exports.m1 || (exports.m1 = {})); //Emit global only usage -var glo_m4 = require("importDecl_require1"); +var glo_m4 = require("./importDecl_require1"); exports.useGlo_m4_d4 = glo_m4.d; exports.useGlo_m4_f4 = glo_m4.foo(); //Emit even when used just in function type -var fncOnly_m4 = require("importDecl_require2"); +var fncOnly_m4 = require("./importDecl_require2"); exports.useFncOnly_m4_f4 = fncOnly_m4.foo(); // only used privately no need to emit -var private_m4 = require("importDecl_require3"); +var private_m4 = require("./importDecl_require3"); var usePrivate_m4_m1; (function (usePrivate_m4_m1) { var x3 = private_m4.x; @@ -156,10 +156,10 @@ var usePrivate_m4_m1; var f3 = private_m4.foo(); })(usePrivate_m4_m1 = exports.usePrivate_m4_m1 || (exports.usePrivate_m4_m1 = {})); // Do not emit unused import -var m5 = require("importDecl_require4"); +var m5 = require("./importDecl_require4"); exports.d = m5.foo2(); // Do not emit multiple used import statements -var multiImport_m4 = require("importDecl_require"); // Emit used +var multiImport_m4 = require("./importDecl_require"); // Emit used exports.useMultiImport_m4_x4 = multiImport_m4.x; exports.useMultiImport_m4_d4 = multiImport_m4.d; exports.useMultiImport_m4_f4 = multiImport_m4.foo(); @@ -189,7 +189,7 @@ export declare class d { export declare var x: d; export declare function foo(): d; //// [importDecl_require4.d.ts] -import m4 = require("importDecl_require"); +import m4 = require("./importDecl_require"); export declare function foo2(): m4.d; //// [importDecl_1.d.ts] /// @@ -197,7 +197,7 @@ export declare function foo2(): m4.d; /// /// /// -import m4 = require("importDecl_require"); +import m4 = require("./importDecl_require"); export declare var x4: m4.d; export declare var d4: typeof m4.d; export declare var f4: m4.d; @@ -206,10 +206,10 @@ export declare module m1 { var d2: typeof m4.d; var f2: m4.d; } -import glo_m4 = require("importDecl_require1"); +import glo_m4 = require("./importDecl_require1"); export declare var useGlo_m4_d4: typeof glo_m4.d; export declare var useGlo_m4_f4: glo_m4.d; -import fncOnly_m4 = require("importDecl_require2"); +import fncOnly_m4 = require("./importDecl_require2"); export declare var useFncOnly_m4_f4: fncOnly_m4.d; export declare module usePrivate_m4_m1 { } diff --git a/tests/baselines/reference/importDecl.symbols b/tests/baselines/reference/importDecl.symbols index 2341101b672..32b9f3bb2a7 100644 --- a/tests/baselines/reference/importDecl.symbols +++ b/tests/baselines/reference/importDecl.symbols @@ -4,7 +4,7 @@ /// /// /// -import m4 = require("importDecl_require"); // Emit used +import m4 = require("./importDecl_require"); // Emit used >m4 : Symbol(m4, Decl(importDecl_1.ts, 0, 0)) export var x4 = m4.x; @@ -66,7 +66,7 @@ export module m1 { } //Emit global only usage -import glo_m4 = require("importDecl_require1"); +import glo_m4 = require("./importDecl_require1"); >glo_m4 : Symbol(glo_m4, Decl(importDecl_1.ts, 18, 1)) export var useGlo_m4_d4 = glo_m4.d; @@ -82,7 +82,7 @@ export var useGlo_m4_f4 = glo_m4.foo(); >foo : Symbol(glo_m4.foo, Decl(importDecl_require1.ts, 3, 9)) //Emit even when used just in function type -import fncOnly_m4 = require("importDecl_require2"); +import fncOnly_m4 = require("./importDecl_require2"); >fncOnly_m4 : Symbol(fncOnly_m4, Decl(importDecl_1.ts, 23, 39)) export var useFncOnly_m4_f4 = fncOnly_m4.foo(); @@ -92,11 +92,11 @@ export var useFncOnly_m4_f4 = fncOnly_m4.foo(); >foo : Symbol(fncOnly_m4.foo, Decl(importDecl_require2.ts, 3, 16)) // only used privately no need to emit -import private_m4 = require("importDecl_require3"); +import private_m4 = require("./importDecl_require3"); >private_m4 : Symbol(private_m4, Decl(importDecl_1.ts, 27, 47)) export module usePrivate_m4_m1 { ->usePrivate_m4_m1 : Symbol(usePrivate_m4_m1, Decl(importDecl_1.ts, 30, 51)) +>usePrivate_m4_m1 : Symbol(usePrivate_m4_m1, Decl(importDecl_1.ts, 30, 53)) var x3 = private_m4.x; >x3 : Symbol(x3, Decl(importDecl_1.ts, 32, 7)) @@ -118,17 +118,17 @@ export module usePrivate_m4_m1 { } // Do not emit unused import -import m5 = require("importDecl_require4"); +import m5 = require("./importDecl_require4"); >m5 : Symbol(m5, Decl(importDecl_1.ts, 35, 1)) export var d = m5.foo2(); >d : Symbol(d, Decl(importDecl_1.ts, 39, 10)) ->m5.foo2 : Symbol(m5.foo2, Decl(importDecl_require4.ts, 0, 42)) +>m5.foo2 : Symbol(m5.foo2, Decl(importDecl_require4.ts, 0, 44)) >m5 : Symbol(m5, Decl(importDecl_1.ts, 35, 1)) ->foo2 : Symbol(m5.foo2, Decl(importDecl_require4.ts, 0, 42)) +>foo2 : Symbol(m5.foo2, Decl(importDecl_require4.ts, 0, 44)) // Do not emit multiple used import statements -import multiImport_m4 = require("importDecl_require"); // Emit used +import multiImport_m4 = require("./importDecl_require"); // Emit used >multiImport_m4 : Symbol(multiImport_m4, Decl(importDecl_1.ts, 39, 25)) export var useMultiImport_m4_x4 = multiImport_m4.x; @@ -210,11 +210,11 @@ export function foo(): d { return null; } >d : Symbol(d, Decl(importDecl_require3.ts, 0, 0)) === tests/cases/compiler/importDecl_require4.ts === -import m4 = require("importDecl_require"); +import m4 = require("./importDecl_require"); >m4 : Symbol(m4, Decl(importDecl_require4.ts, 0, 0)) export function foo2(): m4.d { return null; } ->foo2 : Symbol(foo2, Decl(importDecl_require4.ts, 0, 42)) +>foo2 : Symbol(foo2, Decl(importDecl_require4.ts, 0, 44)) >m4 : Symbol(m4, Decl(importDecl_require4.ts, 0, 0)) >d : Symbol(m4.d, Decl(importDecl_require.ts, 0, 0)) diff --git a/tests/baselines/reference/importDecl.types b/tests/baselines/reference/importDecl.types index 58a56281bae..7bf4da78121 100644 --- a/tests/baselines/reference/importDecl.types +++ b/tests/baselines/reference/importDecl.types @@ -4,7 +4,7 @@ /// /// /// -import m4 = require("importDecl_require"); // Emit used +import m4 = require("./importDecl_require"); // Emit used >m4 : typeof m4 export var x4 = m4.x; @@ -69,7 +69,7 @@ export module m1 { } //Emit global only usage -import glo_m4 = require("importDecl_require1"); +import glo_m4 = require("./importDecl_require1"); >glo_m4 : typeof glo_m4 export var useGlo_m4_d4 = glo_m4.d; @@ -86,7 +86,7 @@ export var useGlo_m4_f4 = glo_m4.foo(); >foo : () => glo_m4.d //Emit even when used just in function type -import fncOnly_m4 = require("importDecl_require2"); +import fncOnly_m4 = require("./importDecl_require2"); >fncOnly_m4 : typeof fncOnly_m4 export var useFncOnly_m4_f4 = fncOnly_m4.foo(); @@ -97,7 +97,7 @@ export var useFncOnly_m4_f4 = fncOnly_m4.foo(); >foo : () => fncOnly_m4.d // only used privately no need to emit -import private_m4 = require("importDecl_require3"); +import private_m4 = require("./importDecl_require3"); >private_m4 : typeof private_m4 export module usePrivate_m4_m1 { @@ -124,7 +124,7 @@ export module usePrivate_m4_m1 { } // Do not emit unused import -import m5 = require("importDecl_require4"); +import m5 = require("./importDecl_require4"); >m5 : typeof m5 export var d = m5.foo2(); @@ -135,7 +135,7 @@ export var d = m5.foo2(); >foo2 : () => m4.d // Do not emit multiple used import statements -import multiImport_m4 = require("importDecl_require"); // Emit used +import multiImport_m4 = require("./importDecl_require"); // Emit used >multiImport_m4 : typeof m4 export var useMultiImport_m4_x4 = multiImport_m4.x; @@ -222,7 +222,7 @@ export function foo(): d { return null; } >null : null === tests/cases/compiler/importDecl_require4.ts === -import m4 = require("importDecl_require"); +import m4 = require("./importDecl_require"); >m4 : typeof m4 export function foo2(): m4.d { return null; } diff --git a/tests/baselines/reference/importDeclarationUsedAsTypeQuery.js b/tests/baselines/reference/importDeclarationUsedAsTypeQuery.js index 70244f47381..51839c35df2 100644 --- a/tests/baselines/reference/importDeclarationUsedAsTypeQuery.js +++ b/tests/baselines/reference/importDeclarationUsedAsTypeQuery.js @@ -7,7 +7,7 @@ export class B { //// [importDeclarationUsedAsTypeQuery_1.ts] /// -import a = require('importDeclarationUsedAsTypeQuery_require'); +import a = require('./importDeclarationUsedAsTypeQuery_require'); export var x: typeof a; @@ -27,5 +27,5 @@ export declare class B { } //// [importDeclarationUsedAsTypeQuery_1.d.ts] /// -import a = require('importDeclarationUsedAsTypeQuery_require'); +import a = require('./importDeclarationUsedAsTypeQuery_require'); export declare var x: typeof a; diff --git a/tests/baselines/reference/importDeclarationUsedAsTypeQuery.symbols b/tests/baselines/reference/importDeclarationUsedAsTypeQuery.symbols index 2664691972f..0cd2498e2af 100644 --- a/tests/baselines/reference/importDeclarationUsedAsTypeQuery.symbols +++ b/tests/baselines/reference/importDeclarationUsedAsTypeQuery.symbols @@ -1,6 +1,6 @@ === tests/cases/compiler/importDeclarationUsedAsTypeQuery_1.ts === /// -import a = require('importDeclarationUsedAsTypeQuery_require'); +import a = require('./importDeclarationUsedAsTypeQuery_require'); >a : Symbol(a, Decl(importDeclarationUsedAsTypeQuery_1.ts, 0, 0)) export var x: typeof a; diff --git a/tests/baselines/reference/importDeclarationUsedAsTypeQuery.types b/tests/baselines/reference/importDeclarationUsedAsTypeQuery.types index 2f449c2aa87..5d4c8efc7d4 100644 --- a/tests/baselines/reference/importDeclarationUsedAsTypeQuery.types +++ b/tests/baselines/reference/importDeclarationUsedAsTypeQuery.types @@ -1,6 +1,6 @@ === tests/cases/compiler/importDeclarationUsedAsTypeQuery_1.ts === /// -import a = require('importDeclarationUsedAsTypeQuery_require'); +import a = require('./importDeclarationUsedAsTypeQuery_require'); >a : typeof a export var x: typeof a; diff --git a/tests/baselines/reference/importUsedInExtendsList1.js b/tests/baselines/reference/importUsedInExtendsList1.js index e86b1a41456..129e7b44fd7 100644 --- a/tests/baselines/reference/importUsedInExtendsList1.js +++ b/tests/baselines/reference/importUsedInExtendsList1.js @@ -5,7 +5,7 @@ export class Super { foo: string; } //// [importUsedInExtendsList1_1.ts] /// -import foo = require('importUsedInExtendsList1_require'); +import foo = require('./importUsedInExtendsList1_require'); class Sub extends foo.Super { } var s: Sub; var r: string = s.foo; @@ -25,7 +25,7 @@ var __extends = (this && this.__extends) || function (d, b) { d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; /// -var foo = require('importUsedInExtendsList1_require'); +var foo = require('./importUsedInExtendsList1_require'); var Sub = (function (_super) { __extends(Sub, _super); function Sub() { diff --git a/tests/baselines/reference/importUsedInExtendsList1.symbols b/tests/baselines/reference/importUsedInExtendsList1.symbols index 1b3ac99ee9d..263b4f50ed8 100644 --- a/tests/baselines/reference/importUsedInExtendsList1.symbols +++ b/tests/baselines/reference/importUsedInExtendsList1.symbols @@ -1,17 +1,17 @@ === tests/cases/compiler/importUsedInExtendsList1_1.ts === /// -import foo = require('importUsedInExtendsList1_require'); +import foo = require('./importUsedInExtendsList1_require'); >foo : Symbol(foo, Decl(importUsedInExtendsList1_1.ts, 0, 0)) class Sub extends foo.Super { } ->Sub : Symbol(Sub, Decl(importUsedInExtendsList1_1.ts, 1, 57)) +>Sub : Symbol(Sub, Decl(importUsedInExtendsList1_1.ts, 1, 59)) >foo.Super : Symbol(foo.Super, Decl(importUsedInExtendsList1_require.ts, 0, 0)) >foo : Symbol(foo, Decl(importUsedInExtendsList1_1.ts, 0, 0)) >Super : Symbol(foo.Super, Decl(importUsedInExtendsList1_require.ts, 0, 0)) var s: Sub; >s : Symbol(s, Decl(importUsedInExtendsList1_1.ts, 3, 3)) ->Sub : Symbol(Sub, Decl(importUsedInExtendsList1_1.ts, 1, 57)) +>Sub : Symbol(Sub, Decl(importUsedInExtendsList1_1.ts, 1, 59)) var r: string = s.foo; >r : Symbol(r, Decl(importUsedInExtendsList1_1.ts, 4, 3)) diff --git a/tests/baselines/reference/importUsedInExtendsList1.types b/tests/baselines/reference/importUsedInExtendsList1.types index 3c1b69f5a83..752f4764976 100644 --- a/tests/baselines/reference/importUsedInExtendsList1.types +++ b/tests/baselines/reference/importUsedInExtendsList1.types @@ -1,6 +1,6 @@ === tests/cases/compiler/importUsedInExtendsList1_1.ts === /// -import foo = require('importUsedInExtendsList1_require'); +import foo = require('./importUsedInExtendsList1_require'); >foo : typeof foo class Sub extends foo.Super { } diff --git a/tests/baselines/reference/localAliasExportAssignment.js b/tests/baselines/reference/localAliasExportAssignment.js index ce0f57d57cb..686ab4126a2 100644 --- a/tests/baselines/reference/localAliasExportAssignment.js +++ b/tests/baselines/reference/localAliasExportAssignment.js @@ -9,7 +9,7 @@ export = server; //// [localAliasExportAssignment_1.ts] /// -import connect = require('localAliasExportAssignment_0'); +import connect = require('./localAliasExportAssignment_0'); connect(); @@ -21,5 +21,5 @@ var server; module.exports = server; //// [localAliasExportAssignment_1.js] /// -var connect = require('localAliasExportAssignment_0'); +var connect = require('./localAliasExportAssignment_0'); connect(); diff --git a/tests/baselines/reference/localAliasExportAssignment.symbols b/tests/baselines/reference/localAliasExportAssignment.symbols index 43c99941384..0c73dfd79de 100644 --- a/tests/baselines/reference/localAliasExportAssignment.symbols +++ b/tests/baselines/reference/localAliasExportAssignment.symbols @@ -1,6 +1,6 @@ === tests/cases/compiler/localAliasExportAssignment_1.ts === /// -import connect = require('localAliasExportAssignment_0'); +import connect = require('./localAliasExportAssignment_0'); >connect : Symbol(connect, Decl(localAliasExportAssignment_1.ts, 0, 0)) connect(); diff --git a/tests/baselines/reference/localAliasExportAssignment.types b/tests/baselines/reference/localAliasExportAssignment.types index 5ea0d3085c1..f83b63fedb7 100644 --- a/tests/baselines/reference/localAliasExportAssignment.types +++ b/tests/baselines/reference/localAliasExportAssignment.types @@ -1,6 +1,6 @@ === tests/cases/compiler/localAliasExportAssignment_1.ts === /// -import connect = require('localAliasExportAssignment_0'); +import connect = require('./localAliasExportAssignment_0'); >connect : () => any connect(); diff --git a/tests/baselines/reference/moduleInTypePosition1.errors.txt b/tests/baselines/reference/moduleInTypePosition1.errors.txt index a5b5076e172..ff5fa2da4eb 100644 --- a/tests/baselines/reference/moduleInTypePosition1.errors.txt +++ b/tests/baselines/reference/moduleInTypePosition1.errors.txt @@ -3,7 +3,7 @@ tests/cases/compiler/moduleInTypePosition1_1.ts(3,14): error TS2304: Cannot find ==== tests/cases/compiler/moduleInTypePosition1_1.ts (1 errors) ==== /// - import WinJS = require('moduleInTypePosition1_0'); + import WinJS = require('./moduleInTypePosition1_0'); var x = (w1: WinJS) => { }; ~~~~~ !!! error TS2304: Cannot find name 'WinJS'. diff --git a/tests/baselines/reference/moduleInTypePosition1.js b/tests/baselines/reference/moduleInTypePosition1.js index 972bbae63d1..bcce5f74632 100644 --- a/tests/baselines/reference/moduleInTypePosition1.js +++ b/tests/baselines/reference/moduleInTypePosition1.js @@ -7,7 +7,7 @@ export class Promise { //// [moduleInTypePosition1_1.ts] /// -import WinJS = require('moduleInTypePosition1_0'); +import WinJS = require('./moduleInTypePosition1_0'); var x = (w1: WinJS) => { }; diff --git a/tests/baselines/reference/multiImportExport.js b/tests/baselines/reference/multiImportExport.js index 06d81f7e984..5a03f3c848d 100644 --- a/tests/baselines/reference/multiImportExport.js +++ b/tests/baselines/reference/multiImportExport.js @@ -5,10 +5,10 @@ import Drawing = require('./Drawing'); var addr = new Drawing.Math.Adder(); //// [Drawing.ts] -export import Math = require('Math/Math') +export import Math = require('./Math/Math') //// [Math.ts] -import Adder = require('Math/Adder'); +import Adder = require('./Adder'); var Math = { Adder:Adder @@ -35,13 +35,13 @@ var Adder = (function () { })(); module.exports = Adder; //// [Math.js] -var Adder = require('Math/Adder'); +var Adder = require('./Adder'); var Math = { Adder: Adder }; module.exports = Math; //// [Drawing.js] -exports.Math = require('Math/Math'); +exports.Math = require('./Math/Math'); //// [consumer.js] var Drawing = require('./Drawing'); var addr = new Drawing.Math.Adder(); @@ -53,11 +53,11 @@ declare class Adder { } export = Adder; //// [Math.d.ts] -import Adder = require('Math/Adder'); +import Adder = require('./Adder'); declare var Math: { Adder: typeof Adder; }; export = Math; //// [Drawing.d.ts] -export import Math = require('Math/Math'); +export import Math = require('./Math/Math'); //// [consumer.d.ts] diff --git a/tests/baselines/reference/multiImportExport.symbols b/tests/baselines/reference/multiImportExport.symbols index 6601571aabc..45b59752b2a 100644 --- a/tests/baselines/reference/multiImportExport.symbols +++ b/tests/baselines/reference/multiImportExport.symbols @@ -11,11 +11,11 @@ var addr = new Drawing.Math.Adder(); >Adder : Symbol(Adder, Decl(Math.ts, 2, 12)) === tests/cases/compiler/Drawing.ts === -export import Math = require('Math/Math') +export import Math = require('./Math/Math') >Math : Symbol(Math, Decl(Drawing.ts, 0, 0)) === tests/cases/compiler/Math/Math.ts === -import Adder = require('Math/Adder'); +import Adder = require('./Adder'); >Adder : Symbol(Adder, Decl(Math.ts, 0, 0)) var Math = { diff --git a/tests/baselines/reference/multiImportExport.types b/tests/baselines/reference/multiImportExport.types index aac60aaee90..4a94eef9865 100644 --- a/tests/baselines/reference/multiImportExport.types +++ b/tests/baselines/reference/multiImportExport.types @@ -12,11 +12,11 @@ var addr = new Drawing.Math.Adder(); >Adder : typeof Adder === tests/cases/compiler/Drawing.ts === -export import Math = require('Math/Math') +export import Math = require('./Math/Math') >Math : { Adder: typeof Adder; } === tests/cases/compiler/Math/Math.ts === -import Adder = require('Math/Adder'); +import Adder = require('./Adder'); >Adder : typeof Adder var Math = { diff --git a/tests/baselines/reference/multipleDefaultExports01.errors.txt b/tests/baselines/reference/multipleDefaultExports01.errors.txt index 7b49afe1a4e..72898d474e8 100644 --- a/tests/baselines/reference/multipleDefaultExports01.errors.txt +++ b/tests/baselines/reference/multipleDefaultExports01.errors.txt @@ -24,7 +24,7 @@ tests/cases/conformance/es6/modules/m2.ts(3,1): error TS2348: Value of type 'typ !!! error TS2300: Duplicate identifier 'default'. ==== tests/cases/conformance/es6/modules/m2.ts (1 errors) ==== - import Entity from "m1" + import Entity from "./m1" Entity(); ~~~~~~~~ diff --git a/tests/baselines/reference/multipleDefaultExports01.js b/tests/baselines/reference/multipleDefaultExports01.js index e633cf69f55..b1ff3b4353c 100644 --- a/tests/baselines/reference/multipleDefaultExports01.js +++ b/tests/baselines/reference/multipleDefaultExports01.js @@ -14,7 +14,7 @@ var x = 10; export default x; //// [m2.ts] -import Entity from "m1" +import Entity from "./m1" Entity(); @@ -34,5 +34,5 @@ var x = 10; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = x; //// [m2.js] -var m1_1 = require("m1"); +var m1_1 = require("./m1"); m1_1.default(); diff --git a/tests/baselines/reference/multipleDefaultExports02.errors.txt b/tests/baselines/reference/multipleDefaultExports02.errors.txt index 51220ecfae2..235f8f7c3e3 100644 --- a/tests/baselines/reference/multipleDefaultExports02.errors.txt +++ b/tests/baselines/reference/multipleDefaultExports02.errors.txt @@ -17,6 +17,6 @@ tests/cases/conformance/es6/modules/m1.ts(6,25): error TS2393: Duplicate functio } ==== tests/cases/conformance/es6/modules/m2.ts (0 errors) ==== - import Entity from "m1" + import Entity from "./m1" Entity(); \ No newline at end of file diff --git a/tests/baselines/reference/multipleDefaultExports02.js b/tests/baselines/reference/multipleDefaultExports02.js index 3d1b84ff6a6..7b43c43ee60 100644 --- a/tests/baselines/reference/multipleDefaultExports02.js +++ b/tests/baselines/reference/multipleDefaultExports02.js @@ -11,7 +11,7 @@ export default function bar() { } //// [m2.ts] -import Entity from "m1" +import Entity from "./m1" Entity(); @@ -25,5 +25,5 @@ function bar() { Object.defineProperty(exports, "__esModule", { value: true }); exports.default = bar; //// [m2.js] -var m1_1 = require("m1"); +var m1_1 = require("./m1"); m1_1.default(); diff --git a/tests/baselines/reference/privacyCannotNameAccessorDeclFile.errors.txt b/tests/baselines/reference/privacyCannotNameAccessorDeclFile.errors.txt index 578baa694fd..b5d0ea8223e 100644 --- a/tests/baselines/reference/privacyCannotNameAccessorDeclFile.errors.txt +++ b/tests/baselines/reference/privacyCannotNameAccessorDeclFile.errors.txt @@ -9,7 +9,7 @@ tests/cases/compiler/privacyCannotNameAccessorDeclFile_consumer.ts(66,9): error ==== tests/cases/compiler/privacyCannotNameAccessorDeclFile_consumer.ts (8 errors) ==== - import exporter = require("privacyCannotNameAccessorDeclFile_exporter"); + import exporter = require("./privacyCannotNameAccessorDeclFile_exporter"); export class publicClassWithWithPrivateGetAccessorTypes { static get myPublicStaticMethod() { // Error ~~~~~~~~~~~~~~~~~~~~ @@ -144,7 +144,7 @@ tests/cases/compiler/privacyCannotNameAccessorDeclFile_consumer.ts(66,9): error ==== tests/cases/compiler/privacyCannotNameAccessorDeclFile_exporter.ts (0 errors) ==== /// - import Widgets = require("privacyCannotNameAccessorDeclFile_Widgets"); + import Widgets = require("./privacyCannotNameAccessorDeclFile_Widgets"); import Widgets1 = require("GlobalWidgets"); export function createExportedWidget1() { return Widgets.createWidget1(); diff --git a/tests/baselines/reference/privacyCannotNameAccessorDeclFile.js b/tests/baselines/reference/privacyCannotNameAccessorDeclFile.js index 0295e42e654..8c4108ea9e8 100644 --- a/tests/baselines/reference/privacyCannotNameAccessorDeclFile.js +++ b/tests/baselines/reference/privacyCannotNameAccessorDeclFile.js @@ -35,7 +35,7 @@ export module SpecializedWidget { //// [privacyCannotNameAccessorDeclFile_exporter.ts] /// -import Widgets = require("privacyCannotNameAccessorDeclFile_Widgets"); +import Widgets = require("./privacyCannotNameAccessorDeclFile_Widgets"); import Widgets1 = require("GlobalWidgets"); export function createExportedWidget1() { return Widgets.createWidget1(); @@ -51,7 +51,7 @@ export function createExportedWidget4() { } //// [privacyCannotNameAccessorDeclFile_consumer.ts] -import exporter = require("privacyCannotNameAccessorDeclFile_exporter"); +import exporter = require("./privacyCannotNameAccessorDeclFile_exporter"); export class publicClassWithWithPrivateGetAccessorTypes { static get myPublicStaticMethod() { // Error return exporter.createExportedWidget1(); @@ -165,7 +165,7 @@ var SpecializedWidget; })(SpecializedWidget = exports.SpecializedWidget || (exports.SpecializedWidget = {})); //// [privacyCannotNameAccessorDeclFile_exporter.js] /// -var Widgets = require("privacyCannotNameAccessorDeclFile_Widgets"); +var Widgets = require("./privacyCannotNameAccessorDeclFile_Widgets"); var Widgets1 = require("GlobalWidgets"); function createExportedWidget1() { return Widgets.createWidget1(); @@ -184,7 +184,7 @@ function createExportedWidget4() { } exports.createExportedWidget4 = createExportedWidget4; //// [privacyCannotNameAccessorDeclFile_consumer.js] -var exporter = require("privacyCannotNameAccessorDeclFile_exporter"); +var exporter = require("./privacyCannotNameAccessorDeclFile_exporter"); var publicClassWithWithPrivateGetAccessorTypes = (function () { function publicClassWithWithPrivateGetAccessorTypes() { } @@ -403,7 +403,7 @@ export declare module SpecializedWidget { } //// [privacyCannotNameAccessorDeclFile_exporter.d.ts] /// -import Widgets = require("privacyCannotNameAccessorDeclFile_Widgets"); +import Widgets = require("./privacyCannotNameAccessorDeclFile_Widgets"); import Widgets1 = require("GlobalWidgets"); export declare function createExportedWidget1(): Widgets.Widget1; export declare function createExportedWidget2(): Widgets.SpecializedWidget.Widget2; diff --git a/tests/baselines/reference/privacyCannotNameVarTypeDeclFile.errors.txt b/tests/baselines/reference/privacyCannotNameVarTypeDeclFile.errors.txt index 7f155f0e454..e76474d2d33 100644 --- a/tests/baselines/reference/privacyCannotNameVarTypeDeclFile.errors.txt +++ b/tests/baselines/reference/privacyCannotNameVarTypeDeclFile.errors.txt @@ -13,7 +13,7 @@ tests/cases/compiler/privacyCannotNameVarTypeDeclFile_consumer.ts(38,12): error ==== tests/cases/compiler/privacyCannotNameVarTypeDeclFile_consumer.ts (12 errors) ==== - import exporter = require("privacyCannotNameVarTypeDeclFile_exporter"); + import exporter = require("./privacyCannotNameVarTypeDeclFile_exporter"); export class publicClassWithWithPrivatePropertyTypes { static myPublicStaticProperty = exporter.createExportedWidget1(); // Error ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -120,7 +120,7 @@ tests/cases/compiler/privacyCannotNameVarTypeDeclFile_consumer.ts(38,12): error ==== tests/cases/compiler/privacyCannotNameVarTypeDeclFile_exporter.ts (0 errors) ==== /// - import Widgets = require("privacyCannotNameVarTypeDeclFile_Widgets"); + import Widgets = require("./privacyCannotNameVarTypeDeclFile_Widgets"); import Widgets1 = require("GlobalWidgets"); export function createExportedWidget1() { return Widgets.createWidget1(); diff --git a/tests/baselines/reference/privacyCannotNameVarTypeDeclFile.js b/tests/baselines/reference/privacyCannotNameVarTypeDeclFile.js index d1f04ee3cef..b40d1dc4980 100644 --- a/tests/baselines/reference/privacyCannotNameVarTypeDeclFile.js +++ b/tests/baselines/reference/privacyCannotNameVarTypeDeclFile.js @@ -36,7 +36,7 @@ export module SpecializedWidget { //// [privacyCannotNameVarTypeDeclFile_exporter.ts] /// -import Widgets = require("privacyCannotNameVarTypeDeclFile_Widgets"); +import Widgets = require("./privacyCannotNameVarTypeDeclFile_Widgets"); import Widgets1 = require("GlobalWidgets"); export function createExportedWidget1() { return Widgets.createWidget1(); @@ -52,7 +52,7 @@ export function createExportedWidget4() { } //// [privacyCannotNameVarTypeDeclFile_consumer.ts] -import exporter = require("privacyCannotNameVarTypeDeclFile_exporter"); +import exporter = require("./privacyCannotNameVarTypeDeclFile_exporter"); export class publicClassWithWithPrivatePropertyTypes { static myPublicStaticProperty = exporter.createExportedWidget1(); // Error private static myPrivateStaticProperty = exporter.createExportedWidget1(); @@ -129,7 +129,7 @@ var SpecializedWidget; })(SpecializedWidget = exports.SpecializedWidget || (exports.SpecializedWidget = {})); //// [privacyCannotNameVarTypeDeclFile_exporter.js] /// -var Widgets = require("privacyCannotNameVarTypeDeclFile_Widgets"); +var Widgets = require("./privacyCannotNameVarTypeDeclFile_Widgets"); var Widgets1 = require("GlobalWidgets"); function createExportedWidget1() { return Widgets.createWidget1(); @@ -148,7 +148,7 @@ function createExportedWidget4() { } exports.createExportedWidget4 = createExportedWidget4; //// [privacyCannotNameVarTypeDeclFile_consumer.js] -var exporter = require("privacyCannotNameVarTypeDeclFile_exporter"); +var exporter = require("./privacyCannotNameVarTypeDeclFile_exporter"); var publicClassWithWithPrivatePropertyTypes = (function () { function publicClassWithWithPrivatePropertyTypes() { this.myPublicProperty = exporter.createExportedWidget1(); // Error @@ -231,7 +231,7 @@ export declare module SpecializedWidget { } //// [privacyCannotNameVarTypeDeclFile_exporter.d.ts] /// -import Widgets = require("privacyCannotNameVarTypeDeclFile_Widgets"); +import Widgets = require("./privacyCannotNameVarTypeDeclFile_Widgets"); import Widgets1 = require("GlobalWidgets"); export declare function createExportedWidget1(): Widgets.Widget1; export declare function createExportedWidget2(): Widgets.SpecializedWidget.Widget2; diff --git a/tests/baselines/reference/privacyCheckExternalModuleExportAssignmentOfGenericClass.js b/tests/baselines/reference/privacyCheckExternalModuleExportAssignmentOfGenericClass.js index eeaea58e0ab..8ed0b3cfa1b 100644 --- a/tests/baselines/reference/privacyCheckExternalModuleExportAssignmentOfGenericClass.js +++ b/tests/baselines/reference/privacyCheckExternalModuleExportAssignmentOfGenericClass.js @@ -7,7 +7,7 @@ class Foo { } //// [privacyCheckExternalModuleExportAssignmentOfGenericClass_1.ts] -import Foo = require("privacyCheckExternalModuleExportAssignmentOfGenericClass_0"); +import Foo = require("./privacyCheckExternalModuleExportAssignmentOfGenericClass_0"); export = Bar; interface Bar { foo: Foo; @@ -31,7 +31,7 @@ declare class Foo { constructor(a: A); } //// [privacyCheckExternalModuleExportAssignmentOfGenericClass_1.d.ts] -import Foo = require("privacyCheckExternalModuleExportAssignmentOfGenericClass_0"); +import Foo = require("./privacyCheckExternalModuleExportAssignmentOfGenericClass_0"); export = Bar; interface Bar { foo: Foo; diff --git a/tests/baselines/reference/privacyCheckExternalModuleExportAssignmentOfGenericClass.symbols b/tests/baselines/reference/privacyCheckExternalModuleExportAssignmentOfGenericClass.symbols index fed3799f950..75ebd0bff0a 100644 --- a/tests/baselines/reference/privacyCheckExternalModuleExportAssignmentOfGenericClass.symbols +++ b/tests/baselines/reference/privacyCheckExternalModuleExportAssignmentOfGenericClass.symbols @@ -1,5 +1,5 @@ === tests/cases/compiler/privacyCheckExternalModuleExportAssignmentOfGenericClass_1.ts === -import Foo = require("privacyCheckExternalModuleExportAssignmentOfGenericClass_0"); +import Foo = require("./privacyCheckExternalModuleExportAssignmentOfGenericClass_0"); >Foo : Symbol(Foo, Decl(privacyCheckExternalModuleExportAssignmentOfGenericClass_1.ts, 0, 0)) export = Bar; diff --git a/tests/baselines/reference/privacyCheckExternalModuleExportAssignmentOfGenericClass.types b/tests/baselines/reference/privacyCheckExternalModuleExportAssignmentOfGenericClass.types index 2259b039c91..ebf2a0e3ff6 100644 --- a/tests/baselines/reference/privacyCheckExternalModuleExportAssignmentOfGenericClass.types +++ b/tests/baselines/reference/privacyCheckExternalModuleExportAssignmentOfGenericClass.types @@ -1,5 +1,5 @@ === tests/cases/compiler/privacyCheckExternalModuleExportAssignmentOfGenericClass_1.ts === -import Foo = require("privacyCheckExternalModuleExportAssignmentOfGenericClass_0"); +import Foo = require("./privacyCheckExternalModuleExportAssignmentOfGenericClass_0"); >Foo : typeof Foo export = Bar; diff --git a/tests/baselines/reference/privacyFunctionCannotNameParameterTypeDeclFile.errors.txt b/tests/baselines/reference/privacyFunctionCannotNameParameterTypeDeclFile.errors.txt index 1e221ccd70a..76fd8b4e80a 100644 --- a/tests/baselines/reference/privacyFunctionCannotNameParameterTypeDeclFile.errors.txt +++ b/tests/baselines/reference/privacyFunctionCannotNameParameterTypeDeclFile.errors.txt @@ -25,7 +25,7 @@ tests/cases/compiler/privacyFunctionCannotNameParameterTypeDeclFile_consumer.ts( ==== tests/cases/compiler/privacyFunctionCannotNameParameterTypeDeclFile_consumer.ts (24 errors) ==== - import exporter = require("privacyFunctionCannotNameParameterTypeDeclFile_exporter"); + import exporter = require("./privacyFunctionCannotNameParameterTypeDeclFile_exporter"); export class publicClassWithWithPrivateParmeterTypes { static myPublicStaticMethod(param = exporter.createExportedWidget1()) { // Error ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -212,7 +212,7 @@ tests/cases/compiler/privacyFunctionCannotNameParameterTypeDeclFile_consumer.ts( ==== tests/cases/compiler/privacyFunctionCannotNameParameterTypeDeclFile_exporter.ts (0 errors) ==== /// - import Widgets = require("privacyFunctionCannotNameParameterTypeDeclFile_Widgets"); + import Widgets = require("./privacyFunctionCannotNameParameterTypeDeclFile_Widgets"); import Widgets1 = require("GlobalWidgets"); export function createExportedWidget1() { return Widgets.createWidget1(); diff --git a/tests/baselines/reference/privacyFunctionCannotNameParameterTypeDeclFile.js b/tests/baselines/reference/privacyFunctionCannotNameParameterTypeDeclFile.js index 7acd56927c7..bf2d820e2ea 100644 --- a/tests/baselines/reference/privacyFunctionCannotNameParameterTypeDeclFile.js +++ b/tests/baselines/reference/privacyFunctionCannotNameParameterTypeDeclFile.js @@ -36,7 +36,7 @@ export module SpecializedWidget { //// [privacyFunctionCannotNameParameterTypeDeclFile_exporter.ts] /// -import Widgets = require("privacyFunctionCannotNameParameterTypeDeclFile_Widgets"); +import Widgets = require("./privacyFunctionCannotNameParameterTypeDeclFile_Widgets"); import Widgets1 = require("GlobalWidgets"); export function createExportedWidget1() { return Widgets.createWidget1(); @@ -52,7 +52,7 @@ export function createExportedWidget4() { } //// [privacyFunctionCannotNameParameterTypeDeclFile_consumer.ts] -import exporter = require("privacyFunctionCannotNameParameterTypeDeclFile_exporter"); +import exporter = require("./privacyFunctionCannotNameParameterTypeDeclFile_exporter"); export class publicClassWithWithPrivateParmeterTypes { static myPublicStaticMethod(param = exporter.createExportedWidget1()) { // Error } @@ -185,7 +185,7 @@ var SpecializedWidget; })(SpecializedWidget = exports.SpecializedWidget || (exports.SpecializedWidget = {})); //// [privacyFunctionCannotNameParameterTypeDeclFile_exporter.js] /// -var Widgets = require("privacyFunctionCannotNameParameterTypeDeclFile_Widgets"); +var Widgets = require("./privacyFunctionCannotNameParameterTypeDeclFile_Widgets"); var Widgets1 = require("GlobalWidgets"); function createExportedWidget1() { return Widgets.createWidget1(); @@ -204,7 +204,7 @@ function createExportedWidget4() { } exports.createExportedWidget4 = createExportedWidget4; //// [privacyFunctionCannotNameParameterTypeDeclFile_consumer.js] -var exporter = require("privacyFunctionCannotNameParameterTypeDeclFile_exporter"); +var exporter = require("./privacyFunctionCannotNameParameterTypeDeclFile_exporter"); var publicClassWithWithPrivateParmeterTypes = (function () { function publicClassWithWithPrivateParmeterTypes(param, param1, param2) { if (param === void 0) { param = exporter.createExportedWidget1(); } @@ -417,7 +417,7 @@ export declare module SpecializedWidget { } //// [privacyFunctionCannotNameParameterTypeDeclFile_exporter.d.ts] /// -import Widgets = require("privacyFunctionCannotNameParameterTypeDeclFile_Widgets"); +import Widgets = require("./privacyFunctionCannotNameParameterTypeDeclFile_Widgets"); import Widgets1 = require("GlobalWidgets"); export declare function createExportedWidget1(): Widgets.Widget1; export declare function createExportedWidget2(): Widgets.SpecializedWidget.Widget2; diff --git a/tests/baselines/reference/privacyFunctionCannotNameReturnTypeDeclFile.errors.txt b/tests/baselines/reference/privacyFunctionCannotNameReturnTypeDeclFile.errors.txt index 4be9aec9abe..bc6229815f5 100644 --- a/tests/baselines/reference/privacyFunctionCannotNameReturnTypeDeclFile.errors.txt +++ b/tests/baselines/reference/privacyFunctionCannotNameReturnTypeDeclFile.errors.txt @@ -13,7 +13,7 @@ tests/cases/compiler/privacyFunctionReturnTypeDeclFile_consumer.ts(86,17): error ==== tests/cases/compiler/privacyFunctionReturnTypeDeclFile_consumer.ts (12 errors) ==== - import exporter = require("privacyFunctionReturnTypeDeclFile_exporter"); + import exporter = require("./privacyFunctionReturnTypeDeclFile_exporter"); export class publicClassWithWithPrivateParmeterTypes { static myPublicStaticMethod() { // Error ~~~~~~~~~~~~~~~~~~~~ @@ -183,7 +183,7 @@ tests/cases/compiler/privacyFunctionReturnTypeDeclFile_consumer.ts(86,17): error ==== tests/cases/compiler/privacyFunctionReturnTypeDeclFile_exporter.ts (0 errors) ==== /// - import Widgets = require("privacyFunctionReturnTypeDeclFile_Widgets"); + import Widgets = require("./privacyFunctionReturnTypeDeclFile_Widgets"); import Widgets1 = require("GlobalWidgets"); export function createExportedWidget1() { return Widgets.createWidget1(); diff --git a/tests/baselines/reference/privacyFunctionCannotNameReturnTypeDeclFile.js b/tests/baselines/reference/privacyFunctionCannotNameReturnTypeDeclFile.js index 5f822929a48..8de50f4ea8a 100644 --- a/tests/baselines/reference/privacyFunctionCannotNameReturnTypeDeclFile.js +++ b/tests/baselines/reference/privacyFunctionCannotNameReturnTypeDeclFile.js @@ -36,7 +36,7 @@ export module SpecializedWidget { //// [privacyFunctionReturnTypeDeclFile_exporter.ts] /// -import Widgets = require("privacyFunctionReturnTypeDeclFile_Widgets"); +import Widgets = require("./privacyFunctionReturnTypeDeclFile_Widgets"); import Widgets1 = require("GlobalWidgets"); export function createExportedWidget1() { return Widgets.createWidget1(); @@ -52,7 +52,7 @@ export function createExportedWidget4() { } //// [privacyFunctionReturnTypeDeclFile_consumer.ts] -import exporter = require("privacyFunctionReturnTypeDeclFile_exporter"); +import exporter = require("./privacyFunctionReturnTypeDeclFile_exporter"); export class publicClassWithWithPrivateParmeterTypes { static myPublicStaticMethod() { // Error return exporter.createExportedWidget1(); @@ -192,7 +192,7 @@ var SpecializedWidget; })(SpecializedWidget = exports.SpecializedWidget || (exports.SpecializedWidget = {})); //// [privacyFunctionReturnTypeDeclFile_exporter.js] /// -var Widgets = require("privacyFunctionReturnTypeDeclFile_Widgets"); +var Widgets = require("./privacyFunctionReturnTypeDeclFile_Widgets"); var Widgets1 = require("GlobalWidgets"); function createExportedWidget1() { return Widgets.createWidget1(); @@ -211,7 +211,7 @@ function createExportedWidget4() { } exports.createExportedWidget4 = createExportedWidget4; //// [privacyFunctionReturnTypeDeclFile_consumer.js] -var exporter = require("privacyFunctionReturnTypeDeclFile_exporter"); +var exporter = require("./privacyFunctionReturnTypeDeclFile_exporter"); var publicClassWithWithPrivateParmeterTypes = (function () { function publicClassWithWithPrivateParmeterTypes() { } @@ -374,7 +374,7 @@ export declare module SpecializedWidget { } //// [privacyFunctionReturnTypeDeclFile_exporter.d.ts] /// -import Widgets = require("privacyFunctionReturnTypeDeclFile_Widgets"); +import Widgets = require("./privacyFunctionReturnTypeDeclFile_Widgets"); import Widgets1 = require("GlobalWidgets"); export declare function createExportedWidget1(): Widgets.Widget1; export declare function createExportedWidget2(): Widgets.SpecializedWidget.Widget2; diff --git a/tests/baselines/reference/privacyTopLevelAmbientExternalModuleImportWithExport.js b/tests/baselines/reference/privacyTopLevelAmbientExternalModuleImportWithExport.js index f0ee8c1bb6c..4d184dfe714 100644 --- a/tests/baselines/reference/privacyTopLevelAmbientExternalModuleImportWithExport.js +++ b/tests/baselines/reference/privacyTopLevelAmbientExternalModuleImportWithExport.js @@ -32,8 +32,8 @@ declare module 'm2' { /// /// // Privacy errors - importing private elements -export import im_public_mi_private = require("privacyTopLevelAmbientExternalModuleImportWithExport_require"); -export import im_public_mu_private = require("privacyTopLevelAmbientExternalModuleImportWithExport_require1"); +export import im_public_mi_private = require("./privacyTopLevelAmbientExternalModuleImportWithExport_require"); +export import im_public_mu_private = require("./privacyTopLevelAmbientExternalModuleImportWithExport_require1"); export import im_public_mi_public = require("m"); export import im_public_mu_public = require("m2"); @@ -69,8 +69,8 @@ exports.c_public = c_public; /// /// // Privacy errors - importing private elements -exports.im_public_mi_private = require("privacyTopLevelAmbientExternalModuleImportWithExport_require"); -exports.im_public_mu_private = require("privacyTopLevelAmbientExternalModuleImportWithExport_require1"); +exports.im_public_mi_private = require("./privacyTopLevelAmbientExternalModuleImportWithExport_require"); +exports.im_public_mu_private = require("./privacyTopLevelAmbientExternalModuleImportWithExport_require1"); exports.im_public_mi_public = require("m"); exports.im_public_mu_public = require("m2"); // Usage of privacy error imports @@ -107,8 +107,8 @@ export declare class c_public { //// [privacyTopLevelAmbientExternalModuleImportWithExport_core.d.ts] /// /// -export import im_public_mi_private = require("privacyTopLevelAmbientExternalModuleImportWithExport_require"); -export import im_public_mu_private = require("privacyTopLevelAmbientExternalModuleImportWithExport_require1"); +export import im_public_mi_private = require("./privacyTopLevelAmbientExternalModuleImportWithExport_require"); +export import im_public_mu_private = require("./privacyTopLevelAmbientExternalModuleImportWithExport_require1"); export import im_public_mi_public = require("m"); export import im_public_mu_public = require("m2"); export declare var publicUse_im_public_mi_private: im_public_mi_private.c_public; diff --git a/tests/baselines/reference/privacyTopLevelAmbientExternalModuleImportWithExport.symbols b/tests/baselines/reference/privacyTopLevelAmbientExternalModuleImportWithExport.symbols index 3c0bd5ff61b..2dcddbbfa06 100644 --- a/tests/baselines/reference/privacyTopLevelAmbientExternalModuleImportWithExport.symbols +++ b/tests/baselines/reference/privacyTopLevelAmbientExternalModuleImportWithExport.symbols @@ -2,14 +2,14 @@ /// /// // Privacy errors - importing private elements -export import im_public_mi_private = require("privacyTopLevelAmbientExternalModuleImportWithExport_require"); +export import im_public_mi_private = require("./privacyTopLevelAmbientExternalModuleImportWithExport_require"); >im_public_mi_private : Symbol(im_public_mi_private, Decl(privacyTopLevelAmbientExternalModuleImportWithExport_core.ts, 0, 0)) -export import im_public_mu_private = require("privacyTopLevelAmbientExternalModuleImportWithExport_require1"); ->im_public_mu_private : Symbol(im_public_mu_private, Decl(privacyTopLevelAmbientExternalModuleImportWithExport_core.ts, 3, 109)) +export import im_public_mu_private = require("./privacyTopLevelAmbientExternalModuleImportWithExport_require1"); +>im_public_mu_private : Symbol(im_public_mu_private, Decl(privacyTopLevelAmbientExternalModuleImportWithExport_core.ts, 3, 111)) export import im_public_mi_public = require("m"); ->im_public_mi_public : Symbol(im_public_mi_public, Decl(privacyTopLevelAmbientExternalModuleImportWithExport_core.ts, 4, 110)) +>im_public_mi_public : Symbol(im_public_mi_public, Decl(privacyTopLevelAmbientExternalModuleImportWithExport_core.ts, 4, 112)) export import im_public_mu_public = require("m2"); >im_public_mu_public : Symbol(im_public_mu_public, Decl(privacyTopLevelAmbientExternalModuleImportWithExport_core.ts, 5, 49)) @@ -30,37 +30,37 @@ export var publicUse_im_public_mi_private = new im_public_mi_private.c_public(); var privateUse_im_public_mu_private = new im_public_mu_private.c_public(); >privateUse_im_public_mu_private : Symbol(privateUse_im_public_mu_private, Decl(privacyTopLevelAmbientExternalModuleImportWithExport_core.ts, 11, 3)) >im_public_mu_private.c_public : Symbol(im_public_mu_private.c_public, Decl(privacyTopLevelAmbientExternalModuleImportWithExport_require1.ts, 0, 0)) ->im_public_mu_private : Symbol(im_public_mu_private, Decl(privacyTopLevelAmbientExternalModuleImportWithExport_core.ts, 3, 109)) +>im_public_mu_private : Symbol(im_public_mu_private, Decl(privacyTopLevelAmbientExternalModuleImportWithExport_core.ts, 3, 111)) >c_public : Symbol(im_public_mu_private.c_public, Decl(privacyTopLevelAmbientExternalModuleImportWithExport_require1.ts, 0, 0)) export var publicUse_im_public_mu_private = new im_public_mu_private.c_public(); >publicUse_im_public_mu_private : Symbol(publicUse_im_public_mu_private, Decl(privacyTopLevelAmbientExternalModuleImportWithExport_core.ts, 12, 10)) >im_public_mu_private.c_public : Symbol(im_public_mu_private.c_public, Decl(privacyTopLevelAmbientExternalModuleImportWithExport_require1.ts, 0, 0)) ->im_public_mu_private : Symbol(im_public_mu_private, Decl(privacyTopLevelAmbientExternalModuleImportWithExport_core.ts, 3, 109)) +>im_public_mu_private : Symbol(im_public_mu_private, Decl(privacyTopLevelAmbientExternalModuleImportWithExport_core.ts, 3, 111)) >c_public : Symbol(im_public_mu_private.c_public, Decl(privacyTopLevelAmbientExternalModuleImportWithExport_require1.ts, 0, 0)) var privateUse_im_public_mi_public = new im_public_mi_public.c_private(); >privateUse_im_public_mi_public : Symbol(privateUse_im_public_mi_public, Decl(privacyTopLevelAmbientExternalModuleImportWithExport_core.ts, 13, 3), Decl(privacyTopLevelAmbientExternalModuleImportWithExport_core.ts, 15, 3)) >im_public_mi_public.c_private : Symbol(im_public_mi_public.c_private, Decl(privacyTopLevelAmbientExternalModuleImportWithExport_require2.ts, 2, 20)) ->im_public_mi_public : Symbol(im_public_mi_public, Decl(privacyTopLevelAmbientExternalModuleImportWithExport_core.ts, 4, 110)) +>im_public_mi_public : Symbol(im_public_mi_public, Decl(privacyTopLevelAmbientExternalModuleImportWithExport_core.ts, 4, 112)) >c_private : Symbol(im_public_mi_public.c_private, Decl(privacyTopLevelAmbientExternalModuleImportWithExport_require2.ts, 2, 20)) export var publicUse_im_public_mi_public = new im_public_mi_public.c_private(); >publicUse_im_public_mi_public : Symbol(publicUse_im_public_mi_public, Decl(privacyTopLevelAmbientExternalModuleImportWithExport_core.ts, 14, 10), Decl(privacyTopLevelAmbientExternalModuleImportWithExport_core.ts, 16, 10)) >im_public_mi_public.c_private : Symbol(im_public_mi_public.c_private, Decl(privacyTopLevelAmbientExternalModuleImportWithExport_require2.ts, 2, 20)) ->im_public_mi_public : Symbol(im_public_mi_public, Decl(privacyTopLevelAmbientExternalModuleImportWithExport_core.ts, 4, 110)) +>im_public_mi_public : Symbol(im_public_mi_public, Decl(privacyTopLevelAmbientExternalModuleImportWithExport_core.ts, 4, 112)) >c_private : Symbol(im_public_mi_public.c_private, Decl(privacyTopLevelAmbientExternalModuleImportWithExport_require2.ts, 2, 20)) var privateUse_im_public_mi_public = new im_public_mi_public.c_private(); >privateUse_im_public_mi_public : Symbol(privateUse_im_public_mi_public, Decl(privacyTopLevelAmbientExternalModuleImportWithExport_core.ts, 13, 3), Decl(privacyTopLevelAmbientExternalModuleImportWithExport_core.ts, 15, 3)) >im_public_mi_public.c_private : Symbol(im_public_mi_public.c_private, Decl(privacyTopLevelAmbientExternalModuleImportWithExport_require2.ts, 2, 20)) ->im_public_mi_public : Symbol(im_public_mi_public, Decl(privacyTopLevelAmbientExternalModuleImportWithExport_core.ts, 4, 110)) +>im_public_mi_public : Symbol(im_public_mi_public, Decl(privacyTopLevelAmbientExternalModuleImportWithExport_core.ts, 4, 112)) >c_private : Symbol(im_public_mi_public.c_private, Decl(privacyTopLevelAmbientExternalModuleImportWithExport_require2.ts, 2, 20)) export var publicUse_im_public_mi_public = new im_public_mi_public.c_private(); >publicUse_im_public_mi_public : Symbol(publicUse_im_public_mi_public, Decl(privacyTopLevelAmbientExternalModuleImportWithExport_core.ts, 14, 10), Decl(privacyTopLevelAmbientExternalModuleImportWithExport_core.ts, 16, 10)) >im_public_mi_public.c_private : Symbol(im_public_mi_public.c_private, Decl(privacyTopLevelAmbientExternalModuleImportWithExport_require2.ts, 2, 20)) ->im_public_mi_public : Symbol(im_public_mi_public, Decl(privacyTopLevelAmbientExternalModuleImportWithExport_core.ts, 4, 110)) +>im_public_mi_public : Symbol(im_public_mi_public, Decl(privacyTopLevelAmbientExternalModuleImportWithExport_core.ts, 4, 112)) >c_private : Symbol(im_public_mi_public.c_private, Decl(privacyTopLevelAmbientExternalModuleImportWithExport_require2.ts, 2, 20)) === tests/cases/compiler/privacyTopLevelAmbientExternalModuleImportWithExport_require.ts === diff --git a/tests/baselines/reference/privacyTopLevelAmbientExternalModuleImportWithExport.types b/tests/baselines/reference/privacyTopLevelAmbientExternalModuleImportWithExport.types index b6d3d2967dc..5c082bef5de 100644 --- a/tests/baselines/reference/privacyTopLevelAmbientExternalModuleImportWithExport.types +++ b/tests/baselines/reference/privacyTopLevelAmbientExternalModuleImportWithExport.types @@ -2,10 +2,10 @@ /// /// // Privacy errors - importing private elements -export import im_public_mi_private = require("privacyTopLevelAmbientExternalModuleImportWithExport_require"); +export import im_public_mi_private = require("./privacyTopLevelAmbientExternalModuleImportWithExport_require"); >im_public_mi_private : typeof im_public_mi_private -export import im_public_mu_private = require("privacyTopLevelAmbientExternalModuleImportWithExport_require1"); +export import im_public_mu_private = require("./privacyTopLevelAmbientExternalModuleImportWithExport_require1"); >im_public_mu_private : typeof im_public_mu_private export import im_public_mi_public = require("m"); diff --git a/tests/baselines/reference/requireOfAnEmptyFile1.errors.txt b/tests/baselines/reference/requireOfAnEmptyFile1.errors.txt index 7094bc6699f..d02593feff9 100644 --- a/tests/baselines/reference/requireOfAnEmptyFile1.errors.txt +++ b/tests/baselines/reference/requireOfAnEmptyFile1.errors.txt @@ -4,8 +4,8 @@ tests/cases/compiler/requireOfAnEmptyFile1_a.ts(3,21): error TS2306: File 'tests ==== tests/cases/compiler/requireOfAnEmptyFile1_a.ts (1 errors) ==== //requireOfAnEmptyFile1 - import fs = require('requireOfAnEmptyFile1_b'); - ~~~~~~~~~~~~~~~~~~~~~~~~~ + import fs = require('./requireOfAnEmptyFile1_b'); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS2306: File 'requireOfAnEmptyFile1_b.ts' is not a module. ==== tests/cases/compiler/requireOfAnEmptyFile1_b.ts (0 errors) ==== diff --git a/tests/baselines/reference/requireOfAnEmptyFile1.js b/tests/baselines/reference/requireOfAnEmptyFile1.js index 779bc887140..b2079afa6ef 100644 --- a/tests/baselines/reference/requireOfAnEmptyFile1.js +++ b/tests/baselines/reference/requireOfAnEmptyFile1.js @@ -3,7 +3,7 @@ //// [requireOfAnEmptyFile1_a.ts] //requireOfAnEmptyFile1 -import fs = require('requireOfAnEmptyFile1_b'); +import fs = require('./requireOfAnEmptyFile1_b'); //// [requireOfAnEmptyFile1_b.ts] diff --git a/tests/baselines/reference/reuseInnerModuleMember.js b/tests/baselines/reference/reuseInnerModuleMember.js index 8999ccea633..a15ec5e39a2 100644 --- a/tests/baselines/reference/reuseInnerModuleMember.js +++ b/tests/baselines/reference/reuseInnerModuleMember.js @@ -9,7 +9,7 @@ declare module bar { interface alpha { } } -import f = require('reuseInnerModuleMember_0'); +import f = require('./reuseInnerModuleMember_0'); module bar { var x: alpha; } diff --git a/tests/baselines/reference/reuseInnerModuleMember.symbols b/tests/baselines/reference/reuseInnerModuleMember.symbols index 27301f1256b..5dbd830293f 100644 --- a/tests/baselines/reference/reuseInnerModuleMember.symbols +++ b/tests/baselines/reference/reuseInnerModuleMember.symbols @@ -1,17 +1,17 @@ === tests/cases/compiler/reuseInnerModuleMember_1.ts === /// declare module bar { ->bar : Symbol(bar, Decl(reuseInnerModuleMember_1.ts, 0, 0), Decl(reuseInnerModuleMember_1.ts, 5, 47)) +>bar : Symbol(bar, Decl(reuseInnerModuleMember_1.ts, 0, 0), Decl(reuseInnerModuleMember_1.ts, 5, 49)) interface alpha { } >alpha : Symbol(alpha, Decl(reuseInnerModuleMember_1.ts, 1, 20)) } -import f = require('reuseInnerModuleMember_0'); +import f = require('./reuseInnerModuleMember_0'); >f : Symbol(f, Decl(reuseInnerModuleMember_1.ts, 3, 1)) module bar { ->bar : Symbol(bar, Decl(reuseInnerModuleMember_1.ts, 0, 0), Decl(reuseInnerModuleMember_1.ts, 5, 47)) +>bar : Symbol(bar, Decl(reuseInnerModuleMember_1.ts, 0, 0), Decl(reuseInnerModuleMember_1.ts, 5, 49)) var x: alpha; >x : Symbol(x, Decl(reuseInnerModuleMember_1.ts, 7, 7)) diff --git a/tests/baselines/reference/reuseInnerModuleMember.types b/tests/baselines/reference/reuseInnerModuleMember.types index d42e071e16b..433da749b49 100644 --- a/tests/baselines/reference/reuseInnerModuleMember.types +++ b/tests/baselines/reference/reuseInnerModuleMember.types @@ -7,7 +7,7 @@ declare module bar { >alpha : alpha } -import f = require('reuseInnerModuleMember_0'); +import f = require('./reuseInnerModuleMember_0'); >f : typeof f module bar { diff --git a/tests/baselines/reference/staticInstanceResolution3.js b/tests/baselines/reference/staticInstanceResolution3.js index 92a4e6522c7..0a41cd77909 100644 --- a/tests/baselines/reference/staticInstanceResolution3.js +++ b/tests/baselines/reference/staticInstanceResolution3.js @@ -9,7 +9,7 @@ export class Promise { //// [staticInstanceResolution3_1.ts] /// -import WinJS = require('staticInstanceResolution3_0'); +import WinJS = require('./staticInstanceResolution3_0'); WinJS.Promise.timeout(10); //// [staticInstanceResolution3_0.js] @@ -24,5 +24,5 @@ var Promise = (function () { exports.Promise = Promise; //// [staticInstanceResolution3_1.js] /// -var WinJS = require('staticInstanceResolution3_0'); +var WinJS = require('./staticInstanceResolution3_0'); WinJS.Promise.timeout(10); diff --git a/tests/baselines/reference/staticInstanceResolution3.symbols b/tests/baselines/reference/staticInstanceResolution3.symbols index 8d4fecbaab2..f1afeecd34e 100644 --- a/tests/baselines/reference/staticInstanceResolution3.symbols +++ b/tests/baselines/reference/staticInstanceResolution3.symbols @@ -1,6 +1,6 @@ === tests/cases/compiler/staticInstanceResolution3_1.ts === /// -import WinJS = require('staticInstanceResolution3_0'); +import WinJS = require('./staticInstanceResolution3_0'); >WinJS : Symbol(WinJS, Decl(staticInstanceResolution3_1.ts, 0, 0)) WinJS.Promise.timeout(10); diff --git a/tests/baselines/reference/staticInstanceResolution3.types b/tests/baselines/reference/staticInstanceResolution3.types index ef5c1cc5166..fe50c659f6d 100644 --- a/tests/baselines/reference/staticInstanceResolution3.types +++ b/tests/baselines/reference/staticInstanceResolution3.types @@ -1,6 +1,6 @@ === tests/cases/compiler/staticInstanceResolution3_1.ts === /// -import WinJS = require('staticInstanceResolution3_0'); +import WinJS = require('./staticInstanceResolution3_0'); >WinJS : typeof WinJS WinJS.Promise.timeout(10); diff --git a/tests/baselines/reference/topLevelFileModule.js b/tests/baselines/reference/topLevelFileModule.js index 5d655f78397..a6e7a151eb9 100644 --- a/tests/baselines/reference/topLevelFileModule.js +++ b/tests/baselines/reference/topLevelFileModule.js @@ -7,13 +7,13 @@ export var x: number; export declare var y: number; //// [foo_1.ts] -import foo = require("vs/foo_0"); -import fum = require("vs/fum"); +import foo = require("./vs/foo_0"); +import fum = require("./vs/fum"); var z = foo.x + fum.y; //// [foo_0.js] //// [foo_1.js] -var foo = require("vs/foo_0"); -var fum = require("vs/fum"); +var foo = require("./vs/foo_0"); +var fum = require("./vs/fum"); var z = foo.x + fum.y; diff --git a/tests/baselines/reference/topLevelFileModule.symbols b/tests/baselines/reference/topLevelFileModule.symbols index a677274ec07..d3961c0fa72 100644 --- a/tests/baselines/reference/topLevelFileModule.symbols +++ b/tests/baselines/reference/topLevelFileModule.symbols @@ -1,9 +1,9 @@ === tests/cases/conformance/externalModules/foo_1.ts === -import foo = require("vs/foo_0"); +import foo = require("./vs/foo_0"); >foo : Symbol(foo, Decl(foo_1.ts, 0, 0)) -import fum = require("vs/fum"); ->fum : Symbol(fum, Decl(foo_1.ts, 0, 33)) +import fum = require("./vs/fum"); +>fum : Symbol(fum, Decl(foo_1.ts, 0, 35)) var z = foo.x + fum.y; >z : Symbol(z, Decl(foo_1.ts, 2, 3)) @@ -11,7 +11,7 @@ var z = foo.x + fum.y; >foo : Symbol(foo, Decl(foo_1.ts, 0, 0)) >x : Symbol(foo.x, Decl(foo_0.ts, 0, 10)) >fum.y : Symbol(fum.y, Decl(fum.d.ts, 0, 18)) ->fum : Symbol(fum, Decl(foo_1.ts, 0, 33)) +>fum : Symbol(fum, Decl(foo_1.ts, 0, 35)) >y : Symbol(fum.y, Decl(fum.d.ts, 0, 18)) === tests/cases/conformance/externalModules/vs/foo_0.ts === diff --git a/tests/baselines/reference/topLevelFileModule.types b/tests/baselines/reference/topLevelFileModule.types index 033dbf197d3..2706fd75670 100644 --- a/tests/baselines/reference/topLevelFileModule.types +++ b/tests/baselines/reference/topLevelFileModule.types @@ -1,8 +1,8 @@ === tests/cases/conformance/externalModules/foo_1.ts === -import foo = require("vs/foo_0"); +import foo = require("./vs/foo_0"); >foo : typeof foo -import fum = require("vs/fum"); +import fum = require("./vs/fum"); >fum : typeof fum var z = foo.x + fum.y; diff --git a/tests/baselines/reference/typeCheckObjectCreationExpressionWithUndefinedCallResolutionData.js b/tests/baselines/reference/typeCheckObjectCreationExpressionWithUndefinedCallResolutionData.js index b25ad480a9d..e75fa63c4b7 100644 --- a/tests/baselines/reference/typeCheckObjectCreationExpressionWithUndefinedCallResolutionData.js +++ b/tests/baselines/reference/typeCheckObjectCreationExpressionWithUndefinedCallResolutionData.js @@ -7,7 +7,7 @@ var classes = undefined; } //// [file2.ts] -import f = require('file1'); +import f = require('./file1'); f.foo(); @@ -18,7 +18,7 @@ function foo() { } exports.foo = foo; //// [file2.js] -var f = require('file1'); +var f = require('./file1'); f.foo(); diff --git a/tests/baselines/reference/typeCheckObjectCreationExpressionWithUndefinedCallResolutionData.symbols b/tests/baselines/reference/typeCheckObjectCreationExpressionWithUndefinedCallResolutionData.symbols index 2326ee5a8cd..4a4e4ef57da 100644 --- a/tests/baselines/reference/typeCheckObjectCreationExpressionWithUndefinedCallResolutionData.symbols +++ b/tests/baselines/reference/typeCheckObjectCreationExpressionWithUndefinedCallResolutionData.symbols @@ -1,5 +1,5 @@ === tests/cases/compiler/file2.ts === -import f = require('file1'); +import f = require('./file1'); >f : Symbol(f, Decl(file2.ts, 0, 0)) f.foo(); diff --git a/tests/baselines/reference/typeCheckObjectCreationExpressionWithUndefinedCallResolutionData.types b/tests/baselines/reference/typeCheckObjectCreationExpressionWithUndefinedCallResolutionData.types index 23d2c3167d6..044de70c5cd 100644 --- a/tests/baselines/reference/typeCheckObjectCreationExpressionWithUndefinedCallResolutionData.types +++ b/tests/baselines/reference/typeCheckObjectCreationExpressionWithUndefinedCallResolutionData.types @@ -1,5 +1,5 @@ === tests/cases/compiler/file2.ts === -import f = require('file1'); +import f = require('./file1'); >f : typeof f f.foo(); diff --git a/tests/baselines/reference/typeofAmbientExternalModules.errors.txt b/tests/baselines/reference/typeofAmbientExternalModules.errors.txt index cde3247b7cd..9046972c895 100644 --- a/tests/baselines/reference/typeofAmbientExternalModules.errors.txt +++ b/tests/baselines/reference/typeofAmbientExternalModules.errors.txt @@ -7,8 +7,8 @@ tests/cases/compiler/typeofAmbientExternalModules_2.ts(9,1): error TS2322: Type ==== tests/cases/compiler/typeofAmbientExternalModules_2.ts (2 errors) ==== /// /// - import ext = require('typeofAmbientExternalModules_0'); - import exp = require('typeofAmbientExternalModules_1'); + import ext = require('./typeofAmbientExternalModules_0'); + import exp = require('./typeofAmbientExternalModules_1'); var y1: typeof ext = ext; y1 = exp; diff --git a/tests/baselines/reference/typeofAmbientExternalModules.js b/tests/baselines/reference/typeofAmbientExternalModules.js index 1bfd549fb04..66e6d7d45ea 100644 --- a/tests/baselines/reference/typeofAmbientExternalModules.js +++ b/tests/baselines/reference/typeofAmbientExternalModules.js @@ -10,8 +10,8 @@ export = D; //// [typeofAmbientExternalModules_2.ts] /// /// -import ext = require('typeofAmbientExternalModules_0'); -import exp = require('typeofAmbientExternalModules_1'); +import ext = require('./typeofAmbientExternalModules_0'); +import exp = require('./typeofAmbientExternalModules_1'); var y1: typeof ext = ext; y1 = exp; @@ -35,8 +35,8 @@ module.exports = D; //// [typeofAmbientExternalModules_2.js] /// /// -var ext = require('typeofAmbientExternalModules_0'); -var exp = require('typeofAmbientExternalModules_1'); +var ext = require('./typeofAmbientExternalModules_0'); +var exp = require('./typeofAmbientExternalModules_1'); var y1 = ext; y1 = exp; var y2 = exp; diff --git a/tests/baselines/reference/typeofExternalModules.errors.txt b/tests/baselines/reference/typeofExternalModules.errors.txt index 05b56c9fe1b..0290a40c326 100644 --- a/tests/baselines/reference/typeofExternalModules.errors.txt +++ b/tests/baselines/reference/typeofExternalModules.errors.txt @@ -5,8 +5,8 @@ tests/cases/compiler/typeofExternalModules_core.ts(7,1): error TS2322: Type 'typ ==== tests/cases/compiler/typeofExternalModules_core.ts (2 errors) ==== - import ext = require('typeofExternalModules_external'); - import exp = require('typeofExternalModules_exportAssign'); + import ext = require('./typeofExternalModules_external'); + import exp = require('./typeofExternalModules_exportAssign'); var y1: typeof ext = ext; y1 = exp; diff --git a/tests/baselines/reference/typeofExternalModules.js b/tests/baselines/reference/typeofExternalModules.js index 8ffea8ca8ec..676f6f10b9f 100644 --- a/tests/baselines/reference/typeofExternalModules.js +++ b/tests/baselines/reference/typeofExternalModules.js @@ -8,8 +8,8 @@ class D { } export = D; //// [typeofExternalModules_core.ts] -import ext = require('typeofExternalModules_external'); -import exp = require('typeofExternalModules_exportAssign'); +import ext = require('./typeofExternalModules_external'); +import exp = require('./typeofExternalModules_exportAssign'); var y1: typeof ext = ext; y1 = exp; @@ -31,8 +31,8 @@ var D = (function () { })(); module.exports = D; //// [typeofExternalModules_core.js] -var ext = require('typeofExternalModules_external'); -var exp = require('typeofExternalModules_exportAssign'); +var ext = require('./typeofExternalModules_external'); +var exp = require('./typeofExternalModules_exportAssign'); var y1 = ext; y1 = exp; var y2 = exp; diff --git a/tests/baselines/reference/unusedImportDeclaration.js b/tests/baselines/reference/unusedImportDeclaration.js index 54885f09e36..04e897c081a 100644 --- a/tests/baselines/reference/unusedImportDeclaration.js +++ b/tests/baselines/reference/unusedImportDeclaration.js @@ -7,7 +7,7 @@ class TesterB { export = TesterB; //// [unusedImportDeclaration_testerA.ts] -import B = require("unusedImportDeclaration_testerB"); +import B = require("./unusedImportDeclaration_testerB"); var thingy: B = { me: "A" }; diff --git a/tests/baselines/reference/unusedImportDeclaration.symbols b/tests/baselines/reference/unusedImportDeclaration.symbols index 5506c4ad6b6..a298ba94631 100644 --- a/tests/baselines/reference/unusedImportDeclaration.symbols +++ b/tests/baselines/reference/unusedImportDeclaration.symbols @@ -1,5 +1,5 @@ === tests/cases/compiler/unusedImportDeclaration_testerA.ts === -import B = require("unusedImportDeclaration_testerB"); +import B = require("./unusedImportDeclaration_testerB"); >B : Symbol(B, Decl(unusedImportDeclaration_testerA.ts, 0, 0)) var thingy: B = { diff --git a/tests/baselines/reference/unusedImportDeclaration.types b/tests/baselines/reference/unusedImportDeclaration.types index dcedf3fd350..c14338756da 100644 --- a/tests/baselines/reference/unusedImportDeclaration.types +++ b/tests/baselines/reference/unusedImportDeclaration.types @@ -1,5 +1,5 @@ === tests/cases/compiler/unusedImportDeclaration_testerA.ts === -import B = require("unusedImportDeclaration_testerB"); +import B = require("./unusedImportDeclaration_testerB"); >B : typeof B var thingy: B = { diff --git a/tests/baselines/reference/visibilityOfCrossModuleTypeUsage.js b/tests/baselines/reference/visibilityOfCrossModuleTypeUsage.js index e3f60cfa17b..660a4017a7f 100644 --- a/tests/baselines/reference/visibilityOfCrossModuleTypeUsage.js +++ b/tests/baselines/reference/visibilityOfCrossModuleTypeUsage.js @@ -3,8 +3,8 @@ //// [visibilityOfCrossModuleTypeUsage_commands.ts] //visibilityOfCrossModuleTypeUsage -import fs = require('visibilityOfCrossModuleTypeUsage_fs'); -import server = require('visibilityOfCrossModuleTypeUsage_server'); +import fs = require('./visibilityOfCrossModuleTypeUsage_fs'); +import server = require('./visibilityOfCrossModuleTypeUsage_server'); export interface IConfiguration { workspace: server.IWorkspace; @@ -20,7 +20,7 @@ export interface IWorkspace { } //// [visibilityOfCrossModuleTypeUsage_fs.ts] -import commands = require('visibilityOfCrossModuleTypeUsage_commands'); +import commands = require('./visibilityOfCrossModuleTypeUsage_commands'); function run(configuration: commands.IConfiguration) { var absoluteWorkspacePath = configuration.workspace.toAbsolutePath(configuration.server); } diff --git a/tests/baselines/reference/visibilityOfCrossModuleTypeUsage.symbols b/tests/baselines/reference/visibilityOfCrossModuleTypeUsage.symbols index 0fdd5c4fbe1..d1132151097 100644 --- a/tests/baselines/reference/visibilityOfCrossModuleTypeUsage.symbols +++ b/tests/baselines/reference/visibilityOfCrossModuleTypeUsage.symbols @@ -1,12 +1,12 @@ === tests/cases/compiler/visibilityOfCrossModuleTypeUsage_fs.ts === -import commands = require('visibilityOfCrossModuleTypeUsage_commands'); +import commands = require('./visibilityOfCrossModuleTypeUsage_commands'); >commands : Symbol(commands, Decl(visibilityOfCrossModuleTypeUsage_fs.ts, 0, 0)) function run(configuration: commands.IConfiguration) { ->run : Symbol(run, Decl(visibilityOfCrossModuleTypeUsage_fs.ts, 0, 71)) +>run : Symbol(run, Decl(visibilityOfCrossModuleTypeUsage_fs.ts, 0, 73)) >configuration : Symbol(configuration, Decl(visibilityOfCrossModuleTypeUsage_fs.ts, 1, 13)) >commands : Symbol(commands, Decl(visibilityOfCrossModuleTypeUsage_fs.ts, 0, 0)) ->IConfiguration : Symbol(commands.IConfiguration, Decl(visibilityOfCrossModuleTypeUsage_commands.ts, 3, 67)) +>IConfiguration : Symbol(commands.IConfiguration, Decl(visibilityOfCrossModuleTypeUsage_commands.ts, 3, 69)) var absoluteWorkspacePath = configuration.workspace.toAbsolutePath(configuration.server); >absoluteWorkspacePath : Symbol(absoluteWorkspacePath, Decl(visibilityOfCrossModuleTypeUsage_fs.ts, 2, 7)) @@ -22,23 +22,23 @@ function run(configuration: commands.IConfiguration) { === tests/cases/compiler/visibilityOfCrossModuleTypeUsage_commands.ts === //visibilityOfCrossModuleTypeUsage -import fs = require('visibilityOfCrossModuleTypeUsage_fs'); +import fs = require('./visibilityOfCrossModuleTypeUsage_fs'); >fs : Symbol(fs, Decl(visibilityOfCrossModuleTypeUsage_commands.ts, 0, 0)) -import server = require('visibilityOfCrossModuleTypeUsage_server'); ->server : Symbol(server, Decl(visibilityOfCrossModuleTypeUsage_commands.ts, 2, 59)) +import server = require('./visibilityOfCrossModuleTypeUsage_server'); +>server : Symbol(server, Decl(visibilityOfCrossModuleTypeUsage_commands.ts, 2, 61)) export interface IConfiguration { ->IConfiguration : Symbol(IConfiguration, Decl(visibilityOfCrossModuleTypeUsage_commands.ts, 3, 67)) +>IConfiguration : Symbol(IConfiguration, Decl(visibilityOfCrossModuleTypeUsage_commands.ts, 3, 69)) workspace: server.IWorkspace; >workspace : Symbol(workspace, Decl(visibilityOfCrossModuleTypeUsage_commands.ts, 5, 33)) ->server : Symbol(server, Decl(visibilityOfCrossModuleTypeUsage_commands.ts, 2, 59)) +>server : Symbol(server, Decl(visibilityOfCrossModuleTypeUsage_commands.ts, 2, 61)) >IWorkspace : Symbol(server.IWorkspace, Decl(visibilityOfCrossModuleTypeUsage_server.ts, 1, 1)) server?: server.IServer; >server : Symbol(server, Decl(visibilityOfCrossModuleTypeUsage_commands.ts, 6, 33)) ->server : Symbol(server, Decl(visibilityOfCrossModuleTypeUsage_commands.ts, 2, 59)) +>server : Symbol(server, Decl(visibilityOfCrossModuleTypeUsage_commands.ts, 2, 61)) >IServer : Symbol(server.IServer, Decl(visibilityOfCrossModuleTypeUsage_server.ts, 0, 0)) } diff --git a/tests/baselines/reference/visibilityOfCrossModuleTypeUsage.types b/tests/baselines/reference/visibilityOfCrossModuleTypeUsage.types index 90cb54fe1e0..2ee7189a77c 100644 --- a/tests/baselines/reference/visibilityOfCrossModuleTypeUsage.types +++ b/tests/baselines/reference/visibilityOfCrossModuleTypeUsage.types @@ -1,5 +1,5 @@ === tests/cases/compiler/visibilityOfCrossModuleTypeUsage_fs.ts === -import commands = require('visibilityOfCrossModuleTypeUsage_commands'); +import commands = require('./visibilityOfCrossModuleTypeUsage_commands'); >commands : typeof commands function run(configuration: commands.IConfiguration) { @@ -23,10 +23,10 @@ function run(configuration: commands.IConfiguration) { === tests/cases/compiler/visibilityOfCrossModuleTypeUsage_commands.ts === //visibilityOfCrossModuleTypeUsage -import fs = require('visibilityOfCrossModuleTypeUsage_fs'); +import fs = require('./visibilityOfCrossModuleTypeUsage_fs'); >fs : typeof fs -import server = require('visibilityOfCrossModuleTypeUsage_server'); +import server = require('./visibilityOfCrossModuleTypeUsage_server'); >server : typeof server export interface IConfiguration { diff --git a/tests/baselines/reference/voidAsNonAmbiguousReturnType.errors.txt b/tests/baselines/reference/voidAsNonAmbiguousReturnType.errors.txt index aa61a114145..ce8b52f316c 100644 --- a/tests/baselines/reference/voidAsNonAmbiguousReturnType.errors.txt +++ b/tests/baselines/reference/voidAsNonAmbiguousReturnType.errors.txt @@ -3,7 +3,7 @@ tests/cases/compiler/voidAsNonAmbiguousReturnType_0.ts(1,17): error TS2394: Over ==== tests/cases/compiler/voidAsNonAmbiguousReturnType_1.ts (0 errors) ==== /// - import fs = require("voidAsNonAmbiguousReturnType_0"); + import fs = require("./voidAsNonAmbiguousReturnType_0"); function main() { fs.mkdirSync('test'); // should not error - return types are the same diff --git a/tests/baselines/reference/voidAsNonAmbiguousReturnType.js b/tests/baselines/reference/voidAsNonAmbiguousReturnType.js index 713c4ffe47b..0ab15304493 100644 --- a/tests/baselines/reference/voidAsNonAmbiguousReturnType.js +++ b/tests/baselines/reference/voidAsNonAmbiguousReturnType.js @@ -6,7 +6,7 @@ export function mkdirSync(path: string, mode?: string): void {} //// [voidAsNonAmbiguousReturnType_1.ts] /// -import fs = require("voidAsNonAmbiguousReturnType_0"); +import fs = require("./voidAsNonAmbiguousReturnType_0"); function main() { fs.mkdirSync('test'); // should not error - return types are the same @@ -18,7 +18,7 @@ function mkdirSync(path, mode) { } exports.mkdirSync = mkdirSync; //// [voidAsNonAmbiguousReturnType_1.js] /// -var fs = require("voidAsNonAmbiguousReturnType_0"); +var fs = require("./voidAsNonAmbiguousReturnType_0"); function main() { fs.mkdirSync('test'); // should not error - return types are the same } diff --git a/tests/cases/compiler/aliasAssignments.ts b/tests/cases/compiler/aliasAssignments.ts index 4a83ee80da7..6a7ed9a9974 100644 --- a/tests/cases/compiler/aliasAssignments.ts +++ b/tests/cases/compiler/aliasAssignments.ts @@ -5,7 +5,7 @@ export class someClass { } // @Filename: aliasAssignments_1.ts -import moduleA = require("aliasAssignments_moduleA"); +import moduleA = require("./aliasAssignments_moduleA"); var x = moduleA; x = 1; // Should be error var y = 1; diff --git a/tests/cases/compiler/aliasUsageInAccessorsOfClass.ts b/tests/cases/compiler/aliasUsageInAccessorsOfClass.ts index 2aeddbad947..c6d1b1480c0 100644 --- a/tests/cases/compiler/aliasUsageInAccessorsOfClass.ts +++ b/tests/cases/compiler/aliasUsageInAccessorsOfClass.ts @@ -1,4 +1,4 @@ -//@module: commonjs +// @module: commonjs // @target: ES5 // @Filename: aliasUsage1_backbone.ts export class Model { @@ -6,14 +6,14 @@ export class Model { } // @Filename: aliasUsage1_moduleA.ts -import Backbone = require("aliasUsage1_backbone"); +import Backbone = require("./aliasUsage1_backbone"); export class VisualizationModel extends Backbone.Model { // interesting stuff here } // @Filename: aliasUsage1_main.ts -import Backbone = require("aliasUsage1_backbone"); -import moduleA = require("aliasUsage1_moduleA"); +import Backbone = require("./aliasUsage1_backbone"); +import moduleA = require("./aliasUsage1_moduleA"); interface IHasVisualizationModel { VisualizationModel: typeof Backbone.Model; } diff --git a/tests/cases/compiler/aliasUsageInArray.ts b/tests/cases/compiler/aliasUsageInArray.ts index 9c2e4e64e48..7f71b00e72a 100644 --- a/tests/cases/compiler/aliasUsageInArray.ts +++ b/tests/cases/compiler/aliasUsageInArray.ts @@ -5,14 +5,14 @@ export class Model { } // @Filename: aliasUsageInArray_moduleA.ts -import Backbone = require("aliasUsageInArray_backbone"); +import Backbone = require("./aliasUsageInArray_backbone"); export class VisualizationModel extends Backbone.Model { // interesting stuff here } // @Filename: aliasUsageInArray_main.ts -import Backbone = require("aliasUsageInArray_backbone"); -import moduleA = require("aliasUsageInArray_moduleA"); +import Backbone = require("./aliasUsageInArray_backbone"); +import moduleA = require("./aliasUsageInArray_moduleA"); interface IHasVisualizationModel { VisualizationModel: typeof Backbone.Model; } diff --git a/tests/cases/compiler/aliasUsageInFunctionExpression.ts b/tests/cases/compiler/aliasUsageInFunctionExpression.ts index 47b377c5b28..4c9a91b713b 100644 --- a/tests/cases/compiler/aliasUsageInFunctionExpression.ts +++ b/tests/cases/compiler/aliasUsageInFunctionExpression.ts @@ -1,18 +1,18 @@ -//@module: commonjs +// @module: commonjs // @Filename: aliasUsageInFunctionExpression_backbone.ts export class Model { public someData: string; } // @Filename: aliasUsageInFunctionExpression_moduleA.ts -import Backbone = require("aliasUsageInFunctionExpression_backbone"); +import Backbone = require("./aliasUsageInFunctionExpression_backbone"); export class VisualizationModel extends Backbone.Model { // interesting stuff here } // @Filename: aliasUsageInFunctionExpression_main.ts -import Backbone = require("aliasUsageInFunctionExpression_backbone"); -import moduleA = require("aliasUsageInFunctionExpression_moduleA"); +import Backbone = require("./aliasUsageInFunctionExpression_backbone"); +import moduleA = require("./aliasUsageInFunctionExpression_moduleA"); interface IHasVisualizationModel { VisualizationModel: typeof Backbone.Model; } diff --git a/tests/cases/compiler/aliasUsageInGenericFunction.ts b/tests/cases/compiler/aliasUsageInGenericFunction.ts index d9966dbd299..f153195009c 100644 --- a/tests/cases/compiler/aliasUsageInGenericFunction.ts +++ b/tests/cases/compiler/aliasUsageInGenericFunction.ts @@ -1,18 +1,18 @@ -//@module: commonjs +// @module: commonjs // @Filename: aliasUsageInGenericFunction_backbone.ts export class Model { public someData: string; } // @Filename: aliasUsageInGenericFunction_moduleA.ts -import Backbone = require("aliasUsageInGenericFunction_backbone"); +import Backbone = require("./aliasUsageInGenericFunction_backbone"); export class VisualizationModel extends Backbone.Model { // interesting stuff here } // @Filename: aliasUsageInGenericFunction_main.ts -import Backbone = require("aliasUsageInGenericFunction_backbone"); -import moduleA = require("aliasUsageInGenericFunction_moduleA"); +import Backbone = require("./aliasUsageInGenericFunction_backbone"); +import moduleA = require("./aliasUsageInGenericFunction_moduleA"); interface IHasVisualizationModel { VisualizationModel: typeof Backbone.Model; } diff --git a/tests/cases/compiler/aliasUsageInIndexerOfClass.ts b/tests/cases/compiler/aliasUsageInIndexerOfClass.ts index a6df86fbc99..a9aca7d2970 100644 --- a/tests/cases/compiler/aliasUsageInIndexerOfClass.ts +++ b/tests/cases/compiler/aliasUsageInIndexerOfClass.ts @@ -1,18 +1,18 @@ -//@module: commonjs +// @module: commonjs // @Filename: aliasUsageInIndexerOfClass_backbone.ts export class Model { public someData: string; } // @Filename: aliasUsageInIndexerOfClass_moduleA.ts -import Backbone = require("aliasUsageInIndexerOfClass_backbone"); +import Backbone = require("./aliasUsageInIndexerOfClass_backbone"); export class VisualizationModel extends Backbone.Model { // interesting stuff here } // @Filename: aliasUsageInIndexerOfClass_main.ts -import Backbone = require("aliasUsageInIndexerOfClass_backbone"); -import moduleA = require("aliasUsageInIndexerOfClass_moduleA"); +import Backbone = require("./aliasUsageInIndexerOfClass_backbone"); +import moduleA = require("./aliasUsageInIndexerOfClass_moduleA"); interface IHasVisualizationModel { VisualizationModel: typeof Backbone.Model; } diff --git a/tests/cases/compiler/aliasUsageInObjectLiteral.ts b/tests/cases/compiler/aliasUsageInObjectLiteral.ts index a9d2017d50c..e16d5552fe6 100644 --- a/tests/cases/compiler/aliasUsageInObjectLiteral.ts +++ b/tests/cases/compiler/aliasUsageInObjectLiteral.ts @@ -1,18 +1,18 @@ -//@module: commonjs +// @module: commonjs // @Filename: aliasUsageInObjectLiteral_backbone.ts export class Model { public someData: string; } // @Filename: aliasUsageInObjectLiteral_moduleA.ts -import Backbone = require("aliasUsageInObjectLiteral_backbone"); +import Backbone = require("./aliasUsageInObjectLiteral_backbone"); export class VisualizationModel extends Backbone.Model { // interesting stuff here } // @Filename: aliasUsageInObjectLiteral_main.ts -import Backbone = require("aliasUsageInObjectLiteral_backbone"); -import moduleA = require("aliasUsageInObjectLiteral_moduleA"); +import Backbone = require("./aliasUsageInObjectLiteral_backbone"); +import moduleA = require("./aliasUsageInObjectLiteral_moduleA"); interface IHasVisualizationModel { VisualizationModel: typeof Backbone.Model; } diff --git a/tests/cases/compiler/aliasUsageInOrExpression.ts b/tests/cases/compiler/aliasUsageInOrExpression.ts index e7ddd4014f0..540a3ae91c0 100644 --- a/tests/cases/compiler/aliasUsageInOrExpression.ts +++ b/tests/cases/compiler/aliasUsageInOrExpression.ts @@ -1,18 +1,18 @@ -//@module: commonjs +// @module: commonjs // @Filename: aliasUsageInOrExpression_backbone.ts export class Model { public someData: string; } // @Filename: aliasUsageInOrExpression_moduleA.ts -import Backbone = require("aliasUsageInOrExpression_backbone"); +import Backbone = require("./aliasUsageInOrExpression_backbone"); export class VisualizationModel extends Backbone.Model { // interesting stuff here } // @Filename: aliasUsageInOrExpression_main.ts -import Backbone = require("aliasUsageInOrExpression_backbone"); -import moduleA = require("aliasUsageInOrExpression_moduleA"); +import Backbone = require("./aliasUsageInOrExpression_backbone"); +import moduleA = require("./aliasUsageInOrExpression_moduleA"); interface IHasVisualizationModel { VisualizationModel: typeof Backbone.Model; } diff --git a/tests/cases/compiler/aliasUsageInTypeArgumentOfExtendsClause.ts b/tests/cases/compiler/aliasUsageInTypeArgumentOfExtendsClause.ts index 548963ff123..c09c715ed3a 100644 --- a/tests/cases/compiler/aliasUsageInTypeArgumentOfExtendsClause.ts +++ b/tests/cases/compiler/aliasUsageInTypeArgumentOfExtendsClause.ts @@ -1,18 +1,18 @@ -//@module: commonjs +// @module: commonjs // @Filename: aliasUsageInTypeArgumentOfExtendsClause_backbone.ts export class Model { public someData: string; } // @Filename: aliasUsageInTypeArgumentOfExtendsClause_moduleA.ts -import Backbone = require("aliasUsageInTypeArgumentOfExtendsClause_backbone"); +import Backbone = require("./aliasUsageInTypeArgumentOfExtendsClause_backbone"); export class VisualizationModel extends Backbone.Model { // interesting stuff here } // @Filename: aliasUsageInTypeArgumentOfExtendsClause_main.ts -import Backbone = require("aliasUsageInTypeArgumentOfExtendsClause_backbone"); -import moduleA = require("aliasUsageInTypeArgumentOfExtendsClause_moduleA"); +import Backbone = require("./aliasUsageInTypeArgumentOfExtendsClause_backbone"); +import moduleA = require("./aliasUsageInTypeArgumentOfExtendsClause_moduleA"); interface IHasVisualizationModel { VisualizationModel: typeof Backbone.Model; } diff --git a/tests/cases/compiler/aliasUsageInVarAssignment.ts b/tests/cases/compiler/aliasUsageInVarAssignment.ts index 1644c825a4d..ed14d4241f5 100644 --- a/tests/cases/compiler/aliasUsageInVarAssignment.ts +++ b/tests/cases/compiler/aliasUsageInVarAssignment.ts @@ -1,18 +1,18 @@ -//@module: commonjs +// @module: commonjs // @Filename: aliasUsageInVarAssignment_backbone.ts export class Model { public someData: string; } // @Filename: aliasUsageInVarAssignment_moduleA.ts -import Backbone = require("aliasUsageInVarAssignment_backbone"); +import Backbone = require("./aliasUsageInVarAssignment_backbone"); export class VisualizationModel extends Backbone.Model { // interesting stuff here } // @Filename: aliasUsageInVarAssignment_main.ts -import Backbone = require("aliasUsageInVarAssignment_backbone"); -import moduleA = require("aliasUsageInVarAssignment_moduleA"); +import Backbone = require("./aliasUsageInVarAssignment_backbone"); +import moduleA = require("./aliasUsageInVarAssignment_moduleA"); interface IHasVisualizationModel { VisualizationModel: typeof Backbone.Model; } diff --git a/tests/cases/compiler/aliasUsedAsNameValue.ts b/tests/cases/compiler/aliasUsedAsNameValue.ts index 20b60b53d1e..2426399252b 100644 --- a/tests/cases/compiler/aliasUsedAsNameValue.ts +++ b/tests/cases/compiler/aliasUsedAsNameValue.ts @@ -1,4 +1,4 @@ -//@module: commonjs +// @module: commonjs // @Filename: aliasUsedAsNameValue_0.ts export var id: number; @@ -8,8 +8,8 @@ export function b(a: any): any { return null; } // @Filename: aliasUsedAsNameValue_2.ts /// /// -import mod = require("aliasUsedAsNameValue_0"); -import b = require("aliasUsedAsNameValue_1"); +import mod = require("./aliasUsedAsNameValue_0"); +import b = require("./aliasUsedAsNameValue_1"); export var a = function () { //var x = mod.id; // TODO needed hack that mod is loaded diff --git a/tests/cases/compiler/aliasWithInterfaceExportAssignmentUsedInVarInitializer.ts b/tests/cases/compiler/aliasWithInterfaceExportAssignmentUsedInVarInitializer.ts index f4d818d9562..37a6c42caee 100644 --- a/tests/cases/compiler/aliasWithInterfaceExportAssignmentUsedInVarInitializer.ts +++ b/tests/cases/compiler/aliasWithInterfaceExportAssignmentUsedInVarInitializer.ts @@ -1,4 +1,4 @@ -//@module: commonjs +// @module: commonjs // @Filename: aliasWithInterfaceExportAssignmentUsedInVarInitializer_0.ts interface c { q3: number; @@ -6,5 +6,5 @@ interface c { export = c; // @Filename: aliasWithInterfaceExportAssignmentUsedInVarInitializer_1.ts -import moduleA = require("aliasWithInterfaceExportAssignmentUsedInVarInitializer_0"); +import moduleA = require("./aliasWithInterfaceExportAssignmentUsedInVarInitializer_0"); var d = b.q3; \ No newline at end of file diff --git a/tests/cases/compiler/arrayOfExportedClass.ts b/tests/cases/compiler/arrayOfExportedClass.ts index 020be79408c..794a83fbd83 100644 --- a/tests/cases/compiler/arrayOfExportedClass.ts +++ b/tests/cases/compiler/arrayOfExportedClass.ts @@ -1,4 +1,4 @@ -//@module: commonjs +// @module: commonjs // @Filename: arrayOfExportedClass_0.ts class Car { foo: string; @@ -8,7 +8,7 @@ export = Car; // @Filename: arrayOfExportedClass_1.ts /// -import Car = require('arrayOfExportedClass_0'); +import Car = require('./arrayOfExportedClass_0'); class Road { diff --git a/tests/cases/compiler/chainedImportAlias.ts b/tests/cases/compiler/chainedImportAlias.ts index 97bf28bf4a5..5b91c58f4bc 100644 --- a/tests/cases/compiler/chainedImportAlias.ts +++ b/tests/cases/compiler/chainedImportAlias.ts @@ -1,10 +1,10 @@ -//@module: commonjs +// @module: commonjs // @Filename: chainedImportAlias_file0.ts export module m { export function foo() { } } // @Filename: chainedImportAlias_file1.ts -import x = require('chainedImportAlias_file0'); +import x = require('./chainedImportAlias_file0'); import y = x; y.m.foo(); diff --git a/tests/cases/compiler/commentsExternalModules3.ts b/tests/cases/compiler/commentsExternalModules3.ts index e6979939ac8..a59458893ca 100644 --- a/tests/cases/compiler/commentsExternalModules3.ts +++ b/tests/cases/compiler/commentsExternalModules3.ts @@ -56,7 +56,7 @@ var myvar2 = new m4.m2.c(); // @Filename: commentsExternalModules_1.ts /**This is on import declaration*/ -import extMod = require("commentsExternalModules2_0"); // trailing comment 1 +import extMod = require("./commentsExternalModules2_0"); // trailing comment 1 extMod.m1.fooExport(); export var newVar = new extMod.m1.m2.c(); extMod.m4.fooExport(); diff --git a/tests/cases/compiler/declFileAliasUseBeforeDeclaration.ts b/tests/cases/compiler/declFileAliasUseBeforeDeclaration.ts index c803f65cf7c..63cd2761a9e 100644 --- a/tests/cases/compiler/declFileAliasUseBeforeDeclaration.ts +++ b/tests/cases/compiler/declFileAliasUseBeforeDeclaration.ts @@ -1,9 +1,9 @@ -//@module: commonjs -//@declaration: true +// @module: commonjs +// @declaration: true // @Filename: declFileAliasUseBeforeDeclaration_foo.ts export class Foo { } // @Filename: declFileAliasUseBeforeDeclaration_test.ts export function bar(a: foo.Foo) { } -import foo = require("declFileAliasUseBeforeDeclaration_foo"); \ No newline at end of file +import foo = require("./declFileAliasUseBeforeDeclaration_foo"); \ No newline at end of file diff --git a/tests/cases/compiler/declFileForExportedImport.ts b/tests/cases/compiler/declFileForExportedImport.ts index ec286c2711e..8809d0baa37 100644 --- a/tests/cases/compiler/declFileForExportedImport.ts +++ b/tests/cases/compiler/declFileForExportedImport.ts @@ -5,7 +5,7 @@ export var x: number; // @Filename: declFileForExportedImport_1.ts /// -export import a = require('declFileForExportedImport_0'); +export import a = require('./declFileForExportedImport_0'); var y = a.x; export import b = a; diff --git a/tests/cases/compiler/declFileImportModuleWithExportAssignment.ts b/tests/cases/compiler/declFileImportModuleWithExportAssignment.ts index 3e00557eec5..3a619905768 100644 --- a/tests/cases/compiler/declFileImportModuleWithExportAssignment.ts +++ b/tests/cases/compiler/declFileImportModuleWithExportAssignment.ts @@ -1,4 +1,4 @@ -//@module: commonjs +// @module: commonjs // @declaration: true // @Filename: declFileImportModuleWithExportAssignment_0.ts @@ -21,6 +21,6 @@ export = m2; // @Filename: declFileImportModuleWithExportAssignment_1.ts /**This is on import declaration*/ -import a1 = require("declFileImportModuleWithExportAssignment_0"); +import a1 = require("./declFileImportModuleWithExportAssignment_0"); export var a = a1; a.test1(null, null, null); diff --git a/tests/cases/compiler/declarationEmit_exportAssignment.ts b/tests/cases/compiler/declarationEmit_exportAssignment.ts index 166f4abe8e7..bf9e443c85a 100644 --- a/tests/cases/compiler/declarationEmit_exportAssignment.ts +++ b/tests/cases/compiler/declarationEmit_exportAssignment.ts @@ -8,5 +8,5 @@ export function bar() { } export interface Buzz { } // @filename: index.ts -import {foo} from "utils"; +import {foo} from "./utils"; export = foo; \ No newline at end of file diff --git a/tests/cases/compiler/declarationEmit_exportDeclaration.ts b/tests/cases/compiler/declarationEmit_exportDeclaration.ts index a9e0bda761f..c7cff923b08 100644 --- a/tests/cases/compiler/declarationEmit_exportDeclaration.ts +++ b/tests/cases/compiler/declarationEmit_exportDeclaration.ts @@ -8,7 +8,7 @@ export function bar() { } export interface Buzz { } // @filename: index.ts -import {foo, bar, Buzz} from "utils"; +import {foo, bar, Buzz} from "./utils"; foo(); let obj: Buzz; diff --git a/tests/cases/compiler/declarationEmit_nameConflicts.ts b/tests/cases/compiler/declarationEmit_nameConflicts.ts index 66eb732ddae..a30f4b2ff1b 100644 --- a/tests/cases/compiler/declarationEmit_nameConflicts.ts +++ b/tests/cases/compiler/declarationEmit_nameConflicts.ts @@ -5,7 +5,7 @@ module f { export class c { } } export = f; // @Filename: declarationEmit_nameConflicts_0.ts -import im = require('declarationEmit_nameConflicts_1'); +import im = require('./declarationEmit_nameConflicts_1'); export module M { export function f() { } export class C { } diff --git a/tests/cases/compiler/elidingImportNames.ts b/tests/cases/compiler/elidingImportNames.ts index b5893461664..f9cbf457d53 100644 --- a/tests/cases/compiler/elidingImportNames.ts +++ b/tests/cases/compiler/elidingImportNames.ts @@ -1,10 +1,10 @@ // @module: commonjs // @Filename: elidingImportNames_test.ts -import a = require('elidingImportNames_main'); // alias used in typeof +import a = require('./elidingImportNames_main'); // alias used in typeof var b = a; var x: typeof a; -import a2 = require('elidingImportNames_main1'); // alias not used in typeof +import a2 = require('./elidingImportNames_main1'); // alias not used in typeof var b2 = a2; diff --git a/tests/cases/compiler/enumFromExternalModule.ts b/tests/cases/compiler/enumFromExternalModule.ts index 3047dd52db3..2e943caf413 100644 --- a/tests/cases/compiler/enumFromExternalModule.ts +++ b/tests/cases/compiler/enumFromExternalModule.ts @@ -1,9 +1,9 @@ -//@module: commonjs +// @module: commonjs // @Filename: enumFromExternalModule_0.ts export enum Mode { Open } // @Filename: enumFromExternalModule_1.ts /// -import f = require('enumFromExternalModule_0'); +import f = require('./enumFromExternalModule_0'); var x = f.Mode.Open; diff --git a/tests/cases/compiler/errorsOnImportedSymbol.ts b/tests/cases/compiler/errorsOnImportedSymbol.ts index 17f3e5fb92c..b3da9da162e 100644 --- a/tests/cases/compiler/errorsOnImportedSymbol.ts +++ b/tests/cases/compiler/errorsOnImportedSymbol.ts @@ -1,4 +1,4 @@ -//@module: commonjs +// @module: commonjs // @target: ES5 // @Filename: errorsOnImportedSymbol_0.ts @@ -9,7 +9,7 @@ interface Sammy { export = Sammy; // @Filename: errorsOnImportedSymbol_1.ts -import Sammy = require("errorsOnImportedSymbol_0"); +import Sammy = require("./errorsOnImportedSymbol_0"); var x = new Sammy.Sammy(); var y = Sammy.Sammy(); - + diff --git a/tests/cases/compiler/es6ExportAllInEs5.ts b/tests/cases/compiler/es6ExportAllInEs5.ts index ed754e5cacb..3ee95e1a217 100644 --- a/tests/cases/compiler/es6ExportAllInEs5.ts +++ b/tests/cases/compiler/es6ExportAllInEs5.ts @@ -15,4 +15,4 @@ export module uninstantiated { } // @filename: client.ts -export * from "server"; \ No newline at end of file +export * from "./server"; \ No newline at end of file diff --git a/tests/cases/compiler/es6ExportClauseWithoutModuleSpecifierInEs5.ts b/tests/cases/compiler/es6ExportClauseWithoutModuleSpecifierInEs5.ts index 6361c013367..24dbc77e98f 100644 --- a/tests/cases/compiler/es6ExportClauseWithoutModuleSpecifierInEs5.ts +++ b/tests/cases/compiler/es6ExportClauseWithoutModuleSpecifierInEs5.ts @@ -15,8 +15,8 @@ export module uninstantiated { } // @filename: client.ts -export { c } from "server"; -export { c as c2 } from "server"; -export { i, m as instantiatedModule } from "server"; -export { uninstantiated } from "server"; -export { x } from "server"; \ No newline at end of file +export { c } from "./server"; +export { c as c2 } from "./server"; +export { i, m as instantiatedModule } from "./server"; +export { uninstantiated } from "./server"; +export { x } from "./server"; \ No newline at end of file diff --git a/tests/cases/compiler/es6ImportDefaultBindingDts.ts b/tests/cases/compiler/es6ImportDefaultBindingDts.ts index 8b8a9787fdd..b4b82768691 100644 --- a/tests/cases/compiler/es6ImportDefaultBindingDts.ts +++ b/tests/cases/compiler/es6ImportDefaultBindingDts.ts @@ -7,6 +7,6 @@ class c { } export default c; // @filename: client.ts -import defaultBinding from "server"; +import defaultBinding from "./server"; export var x = new defaultBinding(); -import defaultBinding2 from "server"; // elide this import since defaultBinding2 is not used +import defaultBinding2 from "./server"; // elide this import since defaultBinding2 is not used diff --git a/tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImport.ts b/tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImport.ts index 9a6e1a8ebf5..cb84036af5e 100644 --- a/tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImport.ts +++ b/tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImport.ts @@ -9,15 +9,15 @@ export var m = a; export default {}; // @filename: es6ImportDefaultBindingFollowedWithNamedImport_1.ts -import defaultBinding1, { } from "es6ImportDefaultBindingFollowedWithNamedImport_0"; -import defaultBinding2, { a } from "es6ImportDefaultBindingFollowedWithNamedImport_0"; +import defaultBinding1, { } from "./es6ImportDefaultBindingFollowedWithNamedImport_0"; +import defaultBinding2, { a } from "./es6ImportDefaultBindingFollowedWithNamedImport_0"; var x1: number = a; -import defaultBinding3, { a as b } from "es6ImportDefaultBindingFollowedWithNamedImport_0"; +import defaultBinding3, { a as b } from "./es6ImportDefaultBindingFollowedWithNamedImport_0"; var x1: number = b; -import defaultBinding4, { x, a as y } from "es6ImportDefaultBindingFollowedWithNamedImport_0"; +import defaultBinding4, { x, a as y } from "./es6ImportDefaultBindingFollowedWithNamedImport_0"; var x1: number = x; var x1: number = y; -import defaultBinding5, { x as z, } from "es6ImportDefaultBindingFollowedWithNamedImport_0"; +import defaultBinding5, { x as z, } from "./es6ImportDefaultBindingFollowedWithNamedImport_0"; var x1: number = z; -import defaultBinding6, { m, } from "es6ImportDefaultBindingFollowedWithNamedImport_0"; +import defaultBinding6, { m, } from "./es6ImportDefaultBindingFollowedWithNamedImport_0"; var x1: number = m; diff --git a/tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImport1InEs5.ts b/tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImport1InEs5.ts index d5c9a6a395d..fc13b26e737 100644 --- a/tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImport1InEs5.ts +++ b/tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImport1InEs5.ts @@ -7,15 +7,15 @@ var a = 10; export default a; // @filename: es6ImportDefaultBindingFollowedWithNamedImport1InEs5_1.ts -import defaultBinding1, { } from "es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0"; +import defaultBinding1, { } from "./es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0"; var x: number = defaultBinding1; -import defaultBinding2, { a } from "es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0"; +import defaultBinding2, { a } from "./es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0"; var x: number = defaultBinding2; -import defaultBinding3, { a as b } from "es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0"; +import defaultBinding3, { a as b } from "./es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0"; var x: number = defaultBinding3; -import defaultBinding4, { x, a as y } from "es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0"; +import defaultBinding4, { x, a as y } from "./es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0"; var x: number = defaultBinding4; -import defaultBinding5, { x as z, } from "es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0"; +import defaultBinding5, { x as z, } from "./es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0"; var x: number = defaultBinding5; -import defaultBinding6, { m, } from "es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0"; +import defaultBinding6, { m, } from "./es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0"; var x: number = defaultBinding6; diff --git a/tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImport1WithExport.ts b/tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImport1WithExport.ts index 23ec8767d94..ca2b0561433 100644 --- a/tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImport1WithExport.ts +++ b/tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImport1WithExport.ts @@ -7,15 +7,15 @@ var a = 10; export default a; // @filename: client.ts -export import defaultBinding1, { } from "server"; +export import defaultBinding1, { } from "./server"; export var x1: number = defaultBinding1; -export import defaultBinding2, { a } from "server"; +export import defaultBinding2, { a } from "./server"; export var x1: number = defaultBinding2; -export import defaultBinding3, { a as b } from "server"; +export import defaultBinding3, { a as b } from "./server"; export var x1: number = defaultBinding3; -export import defaultBinding4, { x, a as y } from "server"; +export import defaultBinding4, { x, a as y } from "./server"; export var x1: number = defaultBinding4; -export import defaultBinding5, { x as z, } from "server"; +export import defaultBinding5, { x as z, } from "./server"; export var x1: number = defaultBinding5; -export import defaultBinding6, { m, } from "server"; +export import defaultBinding6, { m, } from "./server"; export var x1: number = defaultBinding6; diff --git a/tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImportDts.ts b/tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImportDts.ts index a84dab94033..87782d66aff 100644 --- a/tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImportDts.ts +++ b/tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImportDts.ts @@ -10,15 +10,15 @@ export class a12 { } export class x11 { } // @filename: client.ts -import defaultBinding1, { } from "server"; -import defaultBinding2, { a } from "server"; +import defaultBinding1, { } from "./server"; +import defaultBinding2, { a } from "./server"; export var x1 = new a(); -import defaultBinding3, { a11 as b } from "server"; +import defaultBinding3, { a11 as b } from "./server"; export var x2 = new b(); -import defaultBinding4, { x, a12 as y } from "server"; +import defaultBinding4, { x, a12 as y } from "./server"; export var x4 = new x(); export var x5 = new y(); -import defaultBinding5, { x11 as z, } from "server"; +import defaultBinding5, { x11 as z, } from "./server"; export var x3 = new z(); -import defaultBinding6, { m, } from "server"; +import defaultBinding6, { m, } from "./server"; export var x6 = new m(); diff --git a/tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImportDts1.ts b/tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImportDts1.ts index 7940f211ec7..64e771bebd1 100644 --- a/tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImportDts1.ts +++ b/tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImportDts1.ts @@ -7,15 +7,15 @@ class a { } export default a; // @filename: client.ts -import defaultBinding1, { } from "server"; +import defaultBinding1, { } from "./server"; export var x1 = new defaultBinding1(); -import defaultBinding2, { a } from "server"; +import defaultBinding2, { a } from "./server"; export var x2 = new defaultBinding2(); -import defaultBinding3, { a as b } from "server"; +import defaultBinding3, { a as b } from "./server"; export var x3 = new defaultBinding3(); -import defaultBinding4, { x, a as y } from "server"; +import defaultBinding4, { x, a as y } from "./server"; export var x4 = new defaultBinding4(); -import defaultBinding5, { x as z, } from "server"; +import defaultBinding5, { x as z, } from "./server"; export var x5 = new defaultBinding5(); -import defaultBinding6, { m, } from "server"; +import defaultBinding6, { m, } from "./server"; export var x6 = new defaultBinding6(); \ No newline at end of file diff --git a/tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImportInEs5.ts b/tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImportInEs5.ts index 6e42898d1bc..9a7902d66a0 100644 --- a/tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImportInEs5.ts +++ b/tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImportInEs5.ts @@ -8,15 +8,15 @@ export var x = a; export var m = a; // @filename: es6ImportDefaultBindingFollowedWithNamedImportInEs5_1.ts -import defaultBinding1, { } from "es6ImportDefaultBindingFollowedWithNamedImportInEs5_0"; -import defaultBinding2, { a } from "es6ImportDefaultBindingFollowedWithNamedImportInEs5_0"; +import defaultBinding1, { } from "./es6ImportDefaultBindingFollowedWithNamedImportInEs5_0"; +import defaultBinding2, { a } from "./es6ImportDefaultBindingFollowedWithNamedImportInEs5_0"; var x1: number = a; -import defaultBinding3, { a as b } from "es6ImportDefaultBindingFollowedWithNamedImportInEs5_0"; +import defaultBinding3, { a as b } from "./es6ImportDefaultBindingFollowedWithNamedImportInEs5_0"; var x1: number = b; -import defaultBinding4, { x, a as y } from "es6ImportDefaultBindingFollowedWithNamedImportInEs5_0"; +import defaultBinding4, { x, a as y } from "./es6ImportDefaultBindingFollowedWithNamedImportInEs5_0"; var x1: number = x; var x1: number = y; -import defaultBinding5, { x as z, } from "es6ImportDefaultBindingFollowedWithNamedImportInEs5_0"; +import defaultBinding5, { x as z, } from "./es6ImportDefaultBindingFollowedWithNamedImportInEs5_0"; var x1: number = z; -import defaultBinding6, { m, } from "es6ImportDefaultBindingFollowedWithNamedImportInEs5_0"; +import defaultBinding6, { m, } from "./es6ImportDefaultBindingFollowedWithNamedImportInEs5_0"; var x1: number = m; diff --git a/tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamespaceBinding1InEs5.ts b/tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamespaceBinding1InEs5.ts index 6195b279f72..133abf147cb 100644 --- a/tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamespaceBinding1InEs5.ts +++ b/tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamespaceBinding1InEs5.ts @@ -7,5 +7,5 @@ var a = 10; export default a; // @filename: es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5_1.ts -import defaultBinding, * as nameSpaceBinding from "es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5_0"; +import defaultBinding, * as nameSpaceBinding from "./es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5_0"; var x: number = defaultBinding; \ No newline at end of file diff --git a/tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamespaceBindingDts.ts b/tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamespaceBindingDts.ts index 732f7ef7ba0..c9bb1a6dd10 100644 --- a/tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamespaceBindingDts.ts +++ b/tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamespaceBindingDts.ts @@ -5,5 +5,5 @@ export class a { } // @filename: client.ts -import defaultBinding, * as nameSpaceBinding from "server"; +import defaultBinding, * as nameSpaceBinding from "./server"; export var x = new nameSpaceBinding.a(); \ No newline at end of file diff --git a/tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5.ts b/tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5.ts index c58ba286e0a..cdc1590ec8f 100644 --- a/tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5.ts +++ b/tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5.ts @@ -6,5 +6,5 @@ export var a = 10; // @filename: es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5_1.ts -import defaultBinding, * as nameSpaceBinding from "es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5_0"; +import defaultBinding, * as nameSpaceBinding from "./es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5_0"; var x: number = nameSpaceBinding.a; \ No newline at end of file diff --git a/tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamespaceBindingWithExport.ts b/tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamespaceBindingWithExport.ts index cafcace08a0..768386f67f6 100644 --- a/tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamespaceBindingWithExport.ts +++ b/tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamespaceBindingWithExport.ts @@ -5,5 +5,5 @@ export var a = 10; // @filename: client.ts -export import defaultBinding, * as nameSpaceBinding from "server"; +export import defaultBinding, * as nameSpaceBinding from "./server"; export var x: number = nameSpaceBinding.a; \ No newline at end of file diff --git a/tests/cases/compiler/es6ImportDefaultBindingInEs5.ts b/tests/cases/compiler/es6ImportDefaultBindingInEs5.ts index e0877bd74c1..261c1b6079c 100644 --- a/tests/cases/compiler/es6ImportDefaultBindingInEs5.ts +++ b/tests/cases/compiler/es6ImportDefaultBindingInEs5.ts @@ -7,4 +7,4 @@ var a = 10; export = a; // @filename: es6ImportDefaultBindingInEs5_1.ts -import defaultBinding from "es6ImportDefaultBindingInEs5_0"; \ No newline at end of file +import defaultBinding from "./es6ImportDefaultBindingInEs5_0"; \ No newline at end of file diff --git a/tests/cases/compiler/es6ImportDefaultBindingMergeErrors.ts b/tests/cases/compiler/es6ImportDefaultBindingMergeErrors.ts index 1d87fde5784..3d637abd798 100644 --- a/tests/cases/compiler/es6ImportDefaultBindingMergeErrors.ts +++ b/tests/cases/compiler/es6ImportDefaultBindingMergeErrors.ts @@ -6,11 +6,11 @@ var a = 10; export default a; // @filename: es6ImportDefaultBindingMergeErrors_1.ts -import defaultBinding from "es6ImportDefaultBindingMergeErrors_0"; +import defaultBinding from "./es6ImportDefaultBindingMergeErrors_0"; interface defaultBinding { // This is ok } var x = defaultBinding; -import defaultBinding2 from "es6ImportDefaultBindingMergeErrors_0"; // Should be error +import defaultBinding2 from "./es6ImportDefaultBindingMergeErrors_0"; // Should be error var defaultBinding2 = "hello world"; -import defaultBinding3 from "es6ImportDefaultBindingMergeErrors_0"; // Should be error -import defaultBinding3 from "es6ImportDefaultBindingMergeErrors_0"; // SHould be error +import defaultBinding3 from "./es6ImportDefaultBindingMergeErrors_0"; // Should be error +import defaultBinding3 from "./es6ImportDefaultBindingMergeErrors_0"; // SHould be error diff --git a/tests/cases/compiler/es6ImportDefaultBindingNoDefaultProperty.ts b/tests/cases/compiler/es6ImportDefaultBindingNoDefaultProperty.ts index 5ab1c743721..74b2abfa83c 100644 --- a/tests/cases/compiler/es6ImportDefaultBindingNoDefaultProperty.ts +++ b/tests/cases/compiler/es6ImportDefaultBindingNoDefaultProperty.ts @@ -4,4 +4,4 @@ export var a = 10; // @filename: es6ImportDefaultBindingNoDefaultProperty_1.ts -import defaultBinding from "es6ImportDefaultBindingNoDefaultProperty_0"; +import defaultBinding from "./es6ImportDefaultBindingNoDefaultProperty_0"; diff --git a/tests/cases/compiler/es6ImportNameSpaceImport.ts b/tests/cases/compiler/es6ImportNameSpaceImport.ts index 0c831d323d1..87fc59fdbaa 100644 --- a/tests/cases/compiler/es6ImportNameSpaceImport.ts +++ b/tests/cases/compiler/es6ImportNameSpaceImport.ts @@ -6,6 +6,6 @@ export var a = 10; // @filename: es6ImportNameSpaceImport_1.ts -import * as nameSpaceBinding from "es6ImportNameSpaceImport_0"; +import * as nameSpaceBinding from "./es6ImportNameSpaceImport_0"; var x = nameSpaceBinding.a; -import * as nameSpaceBinding2 from "es6ImportNameSpaceImport_0"; // elide this +import * as nameSpaceBinding2 from "./es6ImportNameSpaceImport_0"; // elide this diff --git a/tests/cases/compiler/es6ImportNameSpaceImportDts.ts b/tests/cases/compiler/es6ImportNameSpaceImportDts.ts index 95b85e53edc..77e65123e78 100644 --- a/tests/cases/compiler/es6ImportNameSpaceImportDts.ts +++ b/tests/cases/compiler/es6ImportNameSpaceImportDts.ts @@ -5,6 +5,6 @@ export class c { }; // @filename: client.ts -import * as nameSpaceBinding from "server"; +import * as nameSpaceBinding from "./server"; export var x = new nameSpaceBinding.c(); -import * as nameSpaceBinding2 from "server"; // unreferenced \ No newline at end of file +import * as nameSpaceBinding2 from "./server"; // unreferenced \ No newline at end of file diff --git a/tests/cases/compiler/es6ImportNameSpaceImportInEs5.ts b/tests/cases/compiler/es6ImportNameSpaceImportInEs5.ts index 8104fe8b3c0..7900e5b5a2b 100644 --- a/tests/cases/compiler/es6ImportNameSpaceImportInEs5.ts +++ b/tests/cases/compiler/es6ImportNameSpaceImportInEs5.ts @@ -6,6 +6,6 @@ export var a = 10; // @filename: es6ImportNameSpaceImportInEs5_1.ts -import * as nameSpaceBinding from "es6ImportNameSpaceImportInEs5_0"; +import * as nameSpaceBinding from "./es6ImportNameSpaceImportInEs5_0"; var x = nameSpaceBinding.a; -import * as nameSpaceBinding2 from "es6ImportNameSpaceImportInEs5_0"; // elide this +import * as nameSpaceBinding2 from "./es6ImportNameSpaceImportInEs5_0"; // elide this diff --git a/tests/cases/compiler/es6ImportNameSpaceImportMergeErrors.ts b/tests/cases/compiler/es6ImportNameSpaceImportMergeErrors.ts index d4b69e8bcf4..cdedbe3fe9b 100644 --- a/tests/cases/compiler/es6ImportNameSpaceImportMergeErrors.ts +++ b/tests/cases/compiler/es6ImportNameSpaceImportMergeErrors.ts @@ -5,11 +5,11 @@ export var a = 10; // @filename: es6ImportNameSpaceImportMergeErrors_1.ts -import * as nameSpaceBinding from "es6ImportNameSpaceImportMergeErrors_0"; +import * as nameSpaceBinding from "./es6ImportNameSpaceImportMergeErrors_0"; interface nameSpaceBinding { } // this should be ok -import * as nameSpaceBinding1 from "es6ImportNameSpaceImportMergeErrors_0"; // should be error -import * as nameSpaceBinding1 from "es6ImportNameSpaceImportMergeErrors_0"; // should be error +import * as nameSpaceBinding1 from "./es6ImportNameSpaceImportMergeErrors_0"; // should be error +import * as nameSpaceBinding1 from "./es6ImportNameSpaceImportMergeErrors_0"; // should be error -import * as nameSpaceBinding3 from "es6ImportNameSpaceImportMergeErrors_0"; // should be error +import * as nameSpaceBinding3 from "./es6ImportNameSpaceImportMergeErrors_0"; // should be error var nameSpaceBinding3 = 10; diff --git a/tests/cases/compiler/es6ImportNameSpaceImportNoNamedExports.ts b/tests/cases/compiler/es6ImportNameSpaceImportNoNamedExports.ts index 7d3bdcec94c..fe471dbc6c7 100644 --- a/tests/cases/compiler/es6ImportNameSpaceImportNoNamedExports.ts +++ b/tests/cases/compiler/es6ImportNameSpaceImportNoNamedExports.ts @@ -6,4 +6,4 @@ var a = 10; export = a; // @filename: es6ImportNameSpaceImportNoNamedExports_1.ts -import * as nameSpaceBinding from "es6ImportNameSpaceImportNoNamedExports_0"; // error \ No newline at end of file +import * as nameSpaceBinding from "./es6ImportNameSpaceImportNoNamedExports_0"; // error \ No newline at end of file diff --git a/tests/cases/compiler/es6ImportNamedImport.ts b/tests/cases/compiler/es6ImportNamedImport.ts index 0a12e10169b..d71b27eeede 100644 --- a/tests/cases/compiler/es6ImportNamedImport.ts +++ b/tests/cases/compiler/es6ImportNamedImport.ts @@ -13,30 +13,30 @@ export var z2 = 10; export var aaaa = 10; // @filename: es6ImportNamedImport_1.ts -import { } from "es6ImportNamedImport_0"; -import { a } from "es6ImportNamedImport_0"; +import { } from "./es6ImportNamedImport_0"; +import { a } from "./es6ImportNamedImport_0"; var xxxx = a; -import { a as b } from "es6ImportNamedImport_0"; +import { a as b } from "./es6ImportNamedImport_0"; var xxxx = b; -import { x, a as y } from "es6ImportNamedImport_0"; +import { x, a as y } from "./es6ImportNamedImport_0"; var xxxx = x; var xxxx = y; -import { x as z, } from "es6ImportNamedImport_0"; +import { x as z, } from "./es6ImportNamedImport_0"; var xxxx = z; -import { m, } from "es6ImportNamedImport_0"; +import { m, } from "./es6ImportNamedImport_0"; var xxxx = m; -import { a1, x1 } from "es6ImportNamedImport_0"; +import { a1, x1 } from "./es6ImportNamedImport_0"; var xxxx = a1; var xxxx = x1; -import { a1 as a11, x1 as x11 } from "es6ImportNamedImport_0"; +import { a1 as a11, x1 as x11 } from "./es6ImportNamedImport_0"; var xxxx = a11; var xxxx = x11; -import { z1 } from "es6ImportNamedImport_0"; +import { z1 } from "./es6ImportNamedImport_0"; var z111 = z1; -import { z2 as z3 } from "es6ImportNamedImport_0"; +import { z2 as z3 } from "./es6ImportNamedImport_0"; var z2 = z3; // z2 shouldn't give redeclare error // These are elided -import { aaaa } from "es6ImportNamedImport_0"; +import { aaaa } from "./es6ImportNamedImport_0"; // These are elided -import { aaaa as bbbb } from "es6ImportNamedImport_0"; +import { aaaa as bbbb } from "./es6ImportNamedImport_0"; diff --git a/tests/cases/compiler/es6ImportNamedImportDts.ts b/tests/cases/compiler/es6ImportNamedImportDts.ts index d83672f3754..b98a20ecfa1 100644 --- a/tests/cases/compiler/es6ImportNamedImportDts.ts +++ b/tests/cases/compiler/es6ImportNamedImportDts.ts @@ -18,29 +18,29 @@ export class aaaa { } export class aaaa1 { } // @filename: client.ts -import { } from "server"; -import { a } from "server"; +import { } from "./server"; +import { a } from "./server"; export var xxxx = new a(); -import { a11 as b } from "server"; +import { a11 as b } from "./server"; export var xxxx1 = new b(); -import { x, a12 as y } from "server"; +import { x, a12 as y } from "./server"; export var xxxx2 = new x(); export var xxxx3 = new y(); -import { x11 as z, } from "server"; +import { x11 as z, } from "./server"; export var xxxx4 = new z(); -import { m, } from "server"; +import { m, } from "./server"; export var xxxx5 = new m(); -import { a1, x1 } from "server"; +import { a1, x1 } from "./server"; export var xxxx6 = new a1(); export var xxxx7 = new x1(); -import { a111 as a11, x111 as x11 } from "server"; +import { a111 as a11, x111 as x11 } from "./server"; export var xxxx8 = new a11(); export var xxxx9 = new x11(); -import { z1 } from "server"; +import { z1 } from "./server"; export var z111 = new z1(); -import { z2 as z3 } from "server"; +import { z2 as z3 } from "./server"; export var z2 = new z3(); // z2 shouldn't give redeclare error // not referenced -import { aaaa } from "server"; -import { aaaa1 as bbbb } from "server"; +import { aaaa } from "./server"; +import { aaaa1 as bbbb } from "./server"; diff --git a/tests/cases/compiler/es6ImportNamedImportInEs5.ts b/tests/cases/compiler/es6ImportNamedImportInEs5.ts index e12a8d032d3..428ad235329 100644 --- a/tests/cases/compiler/es6ImportNamedImportInEs5.ts +++ b/tests/cases/compiler/es6ImportNamedImportInEs5.ts @@ -13,30 +13,30 @@ export var z2 = 10; export var aaaa = 10; // @filename: es6ImportNamedImportInEs5_1.ts -import { } from "es6ImportNamedImportInEs5_0"; -import { a } from "es6ImportNamedImportInEs5_0"; +import { } from "./es6ImportNamedImportInEs5_0"; +import { a } from "./es6ImportNamedImportInEs5_0"; var xxxx = a; -import { a as b } from "es6ImportNamedImportInEs5_0"; +import { a as b } from "./es6ImportNamedImportInEs5_0"; var xxxx = b; -import { x, a as y } from "es6ImportNamedImportInEs5_0"; +import { x, a as y } from "./es6ImportNamedImportInEs5_0"; var xxxx = x; var xxxx = y; -import { x as z, } from "es6ImportNamedImportInEs5_0"; +import { x as z, } from "./es6ImportNamedImportInEs5_0"; var xxxx = z; -import { m, } from "es6ImportNamedImportInEs5_0"; +import { m, } from "./es6ImportNamedImportInEs5_0"; var xxxx = m; -import { a1, x1 } from "es6ImportNamedImportInEs5_0"; +import { a1, x1 } from "./es6ImportNamedImportInEs5_0"; var xxxx = a1; var xxxx = x1; -import { a1 as a11, x1 as x11 } from "es6ImportNamedImportInEs5_0"; +import { a1 as a11, x1 as x11 } from "./es6ImportNamedImportInEs5_0"; var xxxx = a11; var xxxx = x11; -import { z1 } from "es6ImportNamedImportInEs5_0"; +import { z1 } from "./es6ImportNamedImportInEs5_0"; var z111 = z1; -import { z2 as z3 } from "es6ImportNamedImportInEs5_0"; +import { z2 as z3 } from "./es6ImportNamedImportInEs5_0"; var z2 = z3; // z2 shouldn't give redeclare error // These are elided -import { aaaa } from "es6ImportNamedImportInEs5_0"; +import { aaaa } from "./es6ImportNamedImportInEs5_0"; // These are elided -import { aaaa as bbbb } from "es6ImportNamedImportInEs5_0"; +import { aaaa as bbbb } from "./es6ImportNamedImportInEs5_0"; diff --git a/tests/cases/compiler/es6ImportNamedImportInExportAssignment.ts b/tests/cases/compiler/es6ImportNamedImportInExportAssignment.ts index 7a4519c68bb..e3f64e1e747 100644 --- a/tests/cases/compiler/es6ImportNamedImportInExportAssignment.ts +++ b/tests/cases/compiler/es6ImportNamedImportInExportAssignment.ts @@ -6,5 +6,5 @@ export var a = 10; // @filename: es6ImportNamedImportInExportAssignment_1.ts -import { a } from "es6ImportNamedImportInExportAssignment_0"; +import { a } from "./es6ImportNamedImportInExportAssignment_0"; export = a; \ No newline at end of file diff --git a/tests/cases/compiler/es6ImportNamedImportInIndirectExportAssignment.ts b/tests/cases/compiler/es6ImportNamedImportInIndirectExportAssignment.ts index 16d11d4e19f..381a21f58ea 100644 --- a/tests/cases/compiler/es6ImportNamedImportInIndirectExportAssignment.ts +++ b/tests/cases/compiler/es6ImportNamedImportInIndirectExportAssignment.ts @@ -8,6 +8,6 @@ export module a { } // @filename: es6ImportNamedImportInIndirectExportAssignment_1.ts -import { a } from "es6ImportNamedImportInIndirectExportAssignment_0"; +import { a } from "./es6ImportNamedImportInIndirectExportAssignment_0"; import x = a; export = x; \ No newline at end of file diff --git a/tests/cases/compiler/es6ImportNamedImportMergeErrors.ts b/tests/cases/compiler/es6ImportNamedImportMergeErrors.ts index 54e30be1e23..60f13d51355 100644 --- a/tests/cases/compiler/es6ImportNamedImportMergeErrors.ts +++ b/tests/cases/compiler/es6ImportNamedImportMergeErrors.ts @@ -7,13 +7,13 @@ export var z = a; export var z1 = a; // @filename: es6ImportNamedImportMergeErrors_1.ts -import { a } from "es6ImportNamedImportMergeErrors_0"; +import { a } from "./es6ImportNamedImportMergeErrors_0"; interface a { } // shouldnt be error -import { x as x1 } from "es6ImportNamedImportMergeErrors_0"; +import { x as x1 } from "./es6ImportNamedImportMergeErrors_0"; interface x1 { } // shouldnt be error -import { x } from "es6ImportNamedImportMergeErrors_0"; // should be error +import { x } from "./es6ImportNamedImportMergeErrors_0"; // should be error var x = 10; -import { x as x44 } from "es6ImportNamedImportMergeErrors_0"; // should be error +import { x as x44 } from "./es6ImportNamedImportMergeErrors_0"; // should be error var x44 = 10; -import { z } from "es6ImportNamedImportMergeErrors_0"; // should be error -import { z1 as z } from "es6ImportNamedImportMergeErrors_0"; // should be error +import { z } from "./es6ImportNamedImportMergeErrors_0"; // should be error +import { z1 as z } from "./es6ImportNamedImportMergeErrors_0"; // should be error diff --git a/tests/cases/compiler/es6ImportNamedImportNoExportMember.ts b/tests/cases/compiler/es6ImportNamedImportNoExportMember.ts index bd507308d8d..48f8036a753 100644 --- a/tests/cases/compiler/es6ImportNamedImportNoExportMember.ts +++ b/tests/cases/compiler/es6ImportNamedImportNoExportMember.ts @@ -5,5 +5,5 @@ export var a = 10; export var x = a; // @filename: es6ImportNamedImport_1.ts -import { a1 } from "es6ImportNamedImportNoExportMember_0"; -import { x1 as x } from "es6ImportNamedImportNoExportMember_0"; \ No newline at end of file +import { a1 } from "./es6ImportNamedImportNoExportMember_0"; +import { x1 as x } from "./es6ImportNamedImportNoExportMember_0"; \ No newline at end of file diff --git a/tests/cases/compiler/es6ImportNamedImportNoNamedExports.ts b/tests/cases/compiler/es6ImportNamedImportNoNamedExports.ts index 9dd243ff36d..9e46253cc9c 100644 --- a/tests/cases/compiler/es6ImportNamedImportNoNamedExports.ts +++ b/tests/cases/compiler/es6ImportNamedImportNoNamedExports.ts @@ -6,5 +6,5 @@ var a = 10; export = a; // @filename: es6ImportNamedImportNoNamedExports_1.ts -import { a } from "es6ImportNamedImportNoNamedExports_0"; -import { a as x } from "es6ImportNamedImportNoNamedExports_0"; \ No newline at end of file +import { a } from "./es6ImportNamedImportNoNamedExports_0"; +import { a as x } from "./es6ImportNamedImportNoNamedExports_0"; \ No newline at end of file diff --git a/tests/cases/compiler/es6ImportNamedImportWithExport.ts b/tests/cases/compiler/es6ImportNamedImportWithExport.ts index f25a3779b99..9643a82b9b9 100644 --- a/tests/cases/compiler/es6ImportNamedImportWithExport.ts +++ b/tests/cases/compiler/es6ImportNamedImportWithExport.ts @@ -12,29 +12,29 @@ export var z2 = 10; export var aaaa = 10; // @filename: client.ts -export import { } from "server"; -export import { a } from "server"; +export import { } from "./server"; +export import { a } from "./server"; export var xxxx = a; -export import { a as b } from "server"; +export import { a as b } from "./server"; export var xxxx = b; -export import { x, a as y } from "server"; +export import { x, a as y } from "./server"; export var xxxx = x; export var xxxx = y; -export import { x as z, } from "server"; +export import { x as z, } from "./server"; export var xxxx = z; -export import { m, } from "server"; +export import { m, } from "./server"; export var xxxx = m; -export import { a1, x1 } from "server"; +export import { a1, x1 } from "./server"; export var xxxx = a1; export var xxxx = x1; -export import { a1 as a11, x1 as x11 } from "server"; +export import { a1 as a11, x1 as x11 } from "./server"; export var xxxx = a11; export var xxxx = x11; -export import { z1 } from "server"; +export import { z1 } from "./server"; export var z111 = z1; -export import { z2 as z3 } from "server"; +export import { z2 as z3 } from "./server"; export var z2 = z3; // z2 shouldn't give redeclare error // Non referenced imports -export import { aaaa } from "server"; -export import { aaaa as bbbb } from "server"; +export import { aaaa } from "./server"; +export import { aaaa as bbbb } from "./server"; diff --git a/tests/cases/compiler/es6ImportNamedImportWithTypesAndValues.ts b/tests/cases/compiler/es6ImportNamedImportWithTypesAndValues.ts index 08294e57232..4b5a2f17ab0 100644 --- a/tests/cases/compiler/es6ImportNamedImportWithTypesAndValues.ts +++ b/tests/cases/compiler/es6ImportNamedImportWithTypesAndValues.ts @@ -16,6 +16,6 @@ export class C2 implements I2 { } // @filename: client.ts -import { C, I, C2 } from "server"; // Shouldnt emit I and C2 into the js file and emit C and I in .d.ts file +import { C, I, C2 } from "./server"; // Shouldnt emit I and C2 into the js file and emit C and I in .d.ts file export type cValInterface = I; export var cVal = new C(); \ No newline at end of file diff --git a/tests/cases/compiler/exportAssignClassAndModule.ts b/tests/cases/compiler/exportAssignClassAndModule.ts index 1124234ae8d..0ac65454b00 100644 --- a/tests/cases/compiler/exportAssignClassAndModule.ts +++ b/tests/cases/compiler/exportAssignClassAndModule.ts @@ -1,4 +1,4 @@ -//@module: commonjs +// @module: commonjs // @Filename: exportAssignClassAndModule_0.ts class Foo { x: Foo.Bar; @@ -11,7 +11,7 @@ export = Foo; // @Filename: exportAssignClassAndModule_1.ts /// -import Foo = require('exportAssignClassAndModule_0'); +import Foo = require('./exportAssignClassAndModule_0'); var z: Foo.Bar; var zz: Foo; diff --git a/tests/cases/compiler/exportAssignmentEnum.ts b/tests/cases/compiler/exportAssignmentEnum.ts index debaab1e5e8..dff61fdb5df 100644 --- a/tests/cases/compiler/exportAssignmentEnum.ts +++ b/tests/cases/compiler/exportAssignmentEnum.ts @@ -1,4 +1,4 @@ -//@module: commonjs +// @module: commonjs // @Filename: exportAssignmentEnum_A.ts enum E { A, @@ -9,7 +9,7 @@ enum E { export = E; // @Filename: exportAssignmentEnum_B.ts -import EnumE = require("exportAssignmentEnum_A"); +import EnumE = require("./exportAssignmentEnum_A"); var a = EnumE.A; var b = EnumE.B; diff --git a/tests/cases/compiler/exportAssignmentOfDeclaredExternalModule.ts b/tests/cases/compiler/exportAssignmentOfDeclaredExternalModule.ts index 63c1f01eb28..fd6b55c9c08 100644 --- a/tests/cases/compiler/exportAssignmentOfDeclaredExternalModule.ts +++ b/tests/cases/compiler/exportAssignmentOfDeclaredExternalModule.ts @@ -1,4 +1,4 @@ -//@module: commonjs +// @module: commonjs // @Filename: exportAssignmentOfDeclaredExternalModule_0.ts interface Sammy { new (): any; // a constructor signature @@ -8,7 +8,7 @@ export = Sammy; // @Filename: exportAssignmentOfDeclaredExternalModule_1.ts /// -import Sammy = require('exportAssignmentOfDeclaredExternalModule_0'); +import Sammy = require('./exportAssignmentOfDeclaredExternalModule_0'); var x = new Sammy(); // error to use as constructor as there is not constructor symbol var y = Sammy(); // error to use interface name as call target var z: Sammy; // no error - z is of type interface Sammy from module 'M' diff --git a/tests/cases/compiler/exportAssignmentVariable.ts b/tests/cases/compiler/exportAssignmentVariable.ts index b1ba2452884..9bb53a7c89d 100644 --- a/tests/cases/compiler/exportAssignmentVariable.ts +++ b/tests/cases/compiler/exportAssignmentVariable.ts @@ -1,10 +1,10 @@ -//@module: commonjs +// @module: commonjs // @Filename: exportAssignmentVariable_A.ts var x = 0; export = x; // @Filename: exportAssignmentVariable_B.ts -import y = require("exportAssignmentVariable_A"); +import y = require("./exportAssignmentVariable_A"); var n: number = y; \ No newline at end of file diff --git a/tests/cases/compiler/exportEqualMemberMissing.ts b/tests/cases/compiler/exportEqualMemberMissing.ts index 6f916b65260..89b328f0536 100644 --- a/tests/cases/compiler/exportEqualMemberMissing.ts +++ b/tests/cases/compiler/exportEqualMemberMissing.ts @@ -1,4 +1,4 @@ -//@module: commonjs +// @module: commonjs // @Filename: exportEqualMemberMissing_0.ts module server { export interface connectModule { @@ -16,5 +16,5 @@ export = server; // @Filename: exportEqualMemberMissing_1.ts /// -import connect = require('exportEqualMemberMissing_0'); +import connect = require('./exportEqualMemberMissing_0'); connect().use(connect.static('foo')); // Error 1 The property 'static' does not exist on value of type ''. diff --git a/tests/cases/compiler/exportStarFromEmptyModule.ts b/tests/cases/compiler/exportStarFromEmptyModule.ts index 163576f1c08..8e4ea8a7b21 100644 --- a/tests/cases/compiler/exportStarFromEmptyModule.ts +++ b/tests/cases/compiler/exportStarFromEmptyModule.ts @@ -11,15 +11,15 @@ export class A { // empty // @filename: exportStarFromEmptyModule_module3.ts -export * from "exportStarFromEmptyModule_module2"; -export * from "exportStarFromEmptyModule_module1"; +export * from "./exportStarFromEmptyModule_module2"; +export * from "./exportStarFromEmptyModule_module1"; export class A { static q; } // @filename: exportStarFromEmptyModule_module4.ts -import * as X from "exportStarFromEmptyModule_module3"; +import * as X from "./exportStarFromEmptyModule_module3"; var s: X.A; X.A.q; X.A.r; // Error \ No newline at end of file diff --git a/tests/cases/compiler/extendingClassFromAliasAndUsageInIndexer.ts b/tests/cases/compiler/extendingClassFromAliasAndUsageInIndexer.ts index 9cd73deb90d..4e5a67665d9 100644 --- a/tests/cases/compiler/extendingClassFromAliasAndUsageInIndexer.ts +++ b/tests/cases/compiler/extendingClassFromAliasAndUsageInIndexer.ts @@ -1,25 +1,25 @@ -//@module: commonjs +// @module: commonjs // @Filename: extendingClassFromAliasAndUsageInIndexer_backbone.ts export class Model { public someData: string; } // @Filename: extendingClassFromAliasAndUsageInIndexer_moduleA.ts -import Backbone = require("extendingClassFromAliasAndUsageInIndexer_backbone"); +import Backbone = require("./extendingClassFromAliasAndUsageInIndexer_backbone"); export class VisualizationModel extends Backbone.Model { // interesting stuff here } // @Filename: extendingClassFromAliasAndUsageInIndexer_moduleB.ts -import Backbone = require("extendingClassFromAliasAndUsageInIndexer_backbone"); +import Backbone = require("./extendingClassFromAliasAndUsageInIndexer_backbone"); export class VisualizationModel extends Backbone.Model { // different interesting stuff here } // @Filename: extendingClassFromAliasAndUsageInIndexer_main.ts -import Backbone = require("extendingClassFromAliasAndUsageInIndexer_backbone"); -import moduleA = require("extendingClassFromAliasAndUsageInIndexer_moduleA"); -import moduleB = require("extendingClassFromAliasAndUsageInIndexer_moduleB"); +import Backbone = require("./extendingClassFromAliasAndUsageInIndexer_backbone"); +import moduleA = require("./extendingClassFromAliasAndUsageInIndexer_moduleA"); +import moduleB = require("./extendingClassFromAliasAndUsageInIndexer_moduleB"); interface IHasVisualizationModel { VisualizationModel: typeof Backbone.Model; } diff --git a/tests/cases/compiler/externalModuleExportingGenericClass.ts b/tests/cases/compiler/externalModuleExportingGenericClass.ts index 882dd1c5603..b20afb56013 100644 --- a/tests/cases/compiler/externalModuleExportingGenericClass.ts +++ b/tests/cases/compiler/externalModuleExportingGenericClass.ts @@ -8,7 +8,7 @@ export = C; // @Filename: externalModuleExportingGenericClass_file1.ts -import a = require('externalModuleExportingGenericClass_file0'); +import a = require('./externalModuleExportingGenericClass_file0'); var v: a; // this should report error var v2: any = (new a()).foo; var v3: number = (new a()).foo; diff --git a/tests/cases/compiler/externalModuleImmutableBindings.ts b/tests/cases/compiler/externalModuleImmutableBindings.ts index 2321961f6f8..33e1b9894e1 100644 --- a/tests/cases/compiler/externalModuleImmutableBindings.ts +++ b/tests/cases/compiler/externalModuleImmutableBindings.ts @@ -5,7 +5,7 @@ export var x = 1; // @Filename: f2.ts // all mutations below are illegal and should be fixed -import * as stuff from 'f1'; +import * as stuff from './f1'; var n = 'baz'; diff --git a/tests/cases/compiler/externalModuleRefernceResolutionOrderInImportDeclaration.ts b/tests/cases/compiler/externalModuleRefernceResolutionOrderInImportDeclaration.ts index 79cf425bdda..55922da6ca8 100644 --- a/tests/cases/compiler/externalModuleRefernceResolutionOrderInImportDeclaration.ts +++ b/tests/cases/compiler/externalModuleRefernceResolutionOrderInImportDeclaration.ts @@ -1,4 +1,4 @@ -//@module: commonjs +// @module: commonjs // @Filename: externalModuleRefernceResolutionOrderInImportDeclaration_file1.ts export function foo() { }; @@ -10,7 +10,7 @@ declare module "externalModuleRefernceResolutionOrderInImportDeclaration_file1" // @Filename: externalModuleRefernceResolutionOrderInImportDeclaration_file3.ts /// -import file1 = require('externalModuleRefernceResolutionOrderInImportDeclaration_file1'); +import file1 = require('./externalModuleRefernceResolutionOrderInImportDeclaration_file1'); file1.foo(); file1.bar(); diff --git a/tests/cases/compiler/importAsBaseClass.ts b/tests/cases/compiler/importAsBaseClass.ts index b533453773c..4077ca952b9 100644 --- a/tests/cases/compiler/importAsBaseClass.ts +++ b/tests/cases/compiler/importAsBaseClass.ts @@ -1,9 +1,9 @@ -//@module: commonjs +// @module: commonjs // @Filename: importAsBaseClass_0.ts export class Greeter { greet() { return 'greet' } } // @Filename: importAsBaseClass_1.ts -import Greeter = require("importAsBaseClass_0"); +import Greeter = require("./importAsBaseClass_0"); class Hello extends Greeter { } diff --git a/tests/cases/compiler/importDecl.ts b/tests/cases/compiler/importDecl.ts index c28b332eb43..e7c3a0789ce 100644 --- a/tests/cases/compiler/importDecl.ts +++ b/tests/cases/compiler/importDecl.ts @@ -1,4 +1,4 @@ -//@module: commonjs +// @module: commonjs // @declaration: true // @Filename: importDecl_require.ts export class d { @@ -29,7 +29,7 @@ export var x: d; export function foo(): d { return null; } // @Filename: importDecl_require4.ts -import m4 = require("importDecl_require"); +import m4 = require("./importDecl_require"); export function foo2(): m4.d { return null; } // @Filename: importDecl_1.ts @@ -38,7 +38,7 @@ export function foo2(): m4.d { return null; } /// /// /// -import m4 = require("importDecl_require"); // Emit used +import m4 = require("./importDecl_require"); // Emit used export var x4 = m4.x; export var d4 = m4.d; export var f4 = m4.foo(); @@ -54,16 +54,16 @@ export module m1 { } //Emit global only usage -import glo_m4 = require("importDecl_require1"); +import glo_m4 = require("./importDecl_require1"); export var useGlo_m4_d4 = glo_m4.d; export var useGlo_m4_f4 = glo_m4.foo(); //Emit even when used just in function type -import fncOnly_m4 = require("importDecl_require2"); +import fncOnly_m4 = require("./importDecl_require2"); export var useFncOnly_m4_f4 = fncOnly_m4.foo(); // only used privately no need to emit -import private_m4 = require("importDecl_require3"); +import private_m4 = require("./importDecl_require3"); export module usePrivate_m4_m1 { var x3 = private_m4.x; var d3 = private_m4.d; @@ -71,11 +71,11 @@ export module usePrivate_m4_m1 { } // Do not emit unused import -import m5 = require("importDecl_require4"); +import m5 = require("./importDecl_require4"); export var d = m5.foo2(); // Do not emit multiple used import statements -import multiImport_m4 = require("importDecl_require"); // Emit used +import multiImport_m4 = require("./importDecl_require"); // Emit used export var useMultiImport_m4_x4 = multiImport_m4.x; export var useMultiImport_m4_d4 = multiImport_m4.d; export var useMultiImport_m4_f4 = multiImport_m4.foo(); diff --git a/tests/cases/compiler/importDeclarationUsedAsTypeQuery.ts b/tests/cases/compiler/importDeclarationUsedAsTypeQuery.ts index aea205dd447..5fc77ca1a8e 100644 --- a/tests/cases/compiler/importDeclarationUsedAsTypeQuery.ts +++ b/tests/cases/compiler/importDeclarationUsedAsTypeQuery.ts @@ -1,4 +1,4 @@ -//@module: commonjs +// @module: commonjs // @declaration: true // @Filename: importDeclarationUsedAsTypeQuery_require.ts export class B { @@ -7,5 +7,5 @@ export class B { // @Filename: importDeclarationUsedAsTypeQuery_1.ts /// -import a = require('importDeclarationUsedAsTypeQuery_require'); +import a = require('./importDeclarationUsedAsTypeQuery_require'); export var x: typeof a; diff --git a/tests/cases/compiler/importUsedInExtendsList1.ts b/tests/cases/compiler/importUsedInExtendsList1.ts index f76ccc874c9..f5e3b77f1e3 100644 --- a/tests/cases/compiler/importUsedInExtendsList1.ts +++ b/tests/cases/compiler/importUsedInExtendsList1.ts @@ -1,10 +1,10 @@ -//@module: commonjs +// @module: commonjs // @Filename: importUsedInExtendsList1_require.ts export class Super { foo: string; } // @Filename: importUsedInExtendsList1_1.ts /// -import foo = require('importUsedInExtendsList1_require'); +import foo = require('./importUsedInExtendsList1_require'); class Sub extends foo.Super { } var s: Sub; var r: string = s.foo; diff --git a/tests/cases/compiler/localAliasExportAssignment.ts b/tests/cases/compiler/localAliasExportAssignment.ts index 8e6df40403b..9fe29ba91d1 100644 --- a/tests/cases/compiler/localAliasExportAssignment.ts +++ b/tests/cases/compiler/localAliasExportAssignment.ts @@ -1,4 +1,4 @@ -//@module: commonjs +// @module: commonjs // @Filename: localAliasExportAssignment_0.ts var server: { (): any; @@ -8,7 +8,7 @@ export = server; // @Filename: localAliasExportAssignment_1.ts /// -import connect = require('localAliasExportAssignment_0'); +import connect = require('./localAliasExportAssignment_0'); connect(); diff --git a/tests/cases/compiler/moduleInTypePosition1.ts b/tests/cases/compiler/moduleInTypePosition1.ts index 170afc1f876..51481a5c0ea 100644 --- a/tests/cases/compiler/moduleInTypePosition1.ts +++ b/tests/cases/compiler/moduleInTypePosition1.ts @@ -1,4 +1,4 @@ -//@module: commonjs +// @module: commonjs // @Filename: moduleInTypePosition1_0.ts export class Promise { foo: string; @@ -6,5 +6,5 @@ export class Promise { // @Filename: moduleInTypePosition1_1.ts /// -import WinJS = require('moduleInTypePosition1_0'); +import WinJS = require('./moduleInTypePosition1_0'); var x = (w1: WinJS) => { }; diff --git a/tests/cases/compiler/multiImportExport.ts b/tests/cases/compiler/multiImportExport.ts index 939a6e1061e..fe253e282ad 100644 --- a/tests/cases/compiler/multiImportExport.ts +++ b/tests/cases/compiler/multiImportExport.ts @@ -5,10 +5,10 @@ import Drawing = require('./Drawing'); var addr = new Drawing.Math.Adder(); // @Filename: Drawing.ts -export import Math = require('Math/Math') +export import Math = require('./Math/Math') // @Filename: Math/Math.ts -import Adder = require('Math/Adder'); +import Adder = require('./Adder'); var Math = { Adder:Adder diff --git a/tests/cases/compiler/privacyCannotNameAccessorDeclFile.ts b/tests/cases/compiler/privacyCannotNameAccessorDeclFile.ts index 1150cf963bf..70369c47895 100644 --- a/tests/cases/compiler/privacyCannotNameAccessorDeclFile.ts +++ b/tests/cases/compiler/privacyCannotNameAccessorDeclFile.ts @@ -36,7 +36,7 @@ export module SpecializedWidget { // @Filename:privacyCannotNameAccessorDeclFile_exporter.ts /// -import Widgets = require("privacyCannotNameAccessorDeclFile_Widgets"); +import Widgets = require("./privacyCannotNameAccessorDeclFile_Widgets"); import Widgets1 = require("GlobalWidgets"); export function createExportedWidget1() { return Widgets.createWidget1(); @@ -52,7 +52,7 @@ export function createExportedWidget4() { } // @Filename:privacyCannotNameAccessorDeclFile_consumer.ts -import exporter = require("privacyCannotNameAccessorDeclFile_exporter"); +import exporter = require("./privacyCannotNameAccessorDeclFile_exporter"); export class publicClassWithWithPrivateGetAccessorTypes { static get myPublicStaticMethod() { // Error return exporter.createExportedWidget1(); diff --git a/tests/cases/compiler/privacyCannotNameVarTypeDeclFile.ts b/tests/cases/compiler/privacyCannotNameVarTypeDeclFile.ts index e49d31946c6..1135e3c86f4 100644 --- a/tests/cases/compiler/privacyCannotNameVarTypeDeclFile.ts +++ b/tests/cases/compiler/privacyCannotNameVarTypeDeclFile.ts @@ -36,7 +36,7 @@ export module SpecializedWidget { // @Filename:privacyCannotNameVarTypeDeclFile_exporter.ts /// -import Widgets = require("privacyCannotNameVarTypeDeclFile_Widgets"); +import Widgets = require("./privacyCannotNameVarTypeDeclFile_Widgets"); import Widgets1 = require("GlobalWidgets"); export function createExportedWidget1() { return Widgets.createWidget1(); @@ -52,7 +52,7 @@ export function createExportedWidget4() { } // @Filename:privacyCannotNameVarTypeDeclFile_consumer.ts -import exporter = require("privacyCannotNameVarTypeDeclFile_exporter"); +import exporter = require("./privacyCannotNameVarTypeDeclFile_exporter"); export class publicClassWithWithPrivatePropertyTypes { static myPublicStaticProperty = exporter.createExportedWidget1(); // Error private static myPrivateStaticProperty = exporter.createExportedWidget1(); diff --git a/tests/cases/compiler/privacyCheckExternalModuleExportAssignmentOfGenericClass.ts b/tests/cases/compiler/privacyCheckExternalModuleExportAssignmentOfGenericClass.ts index b412622ad40..a214104fafb 100644 --- a/tests/cases/compiler/privacyCheckExternalModuleExportAssignmentOfGenericClass.ts +++ b/tests/cases/compiler/privacyCheckExternalModuleExportAssignmentOfGenericClass.ts @@ -1,5 +1,5 @@ -//@module: commonjs -//@declaration: true +// @module: commonjs +// @declaration: true // @Filename: privacyCheckExternalModuleExportAssignmentOfGenericClass_0.ts export = Foo; class Foo { @@ -7,7 +7,7 @@ class Foo { } // @Filename: privacyCheckExternalModuleExportAssignmentOfGenericClass_1.ts -import Foo = require("privacyCheckExternalModuleExportAssignmentOfGenericClass_0"); +import Foo = require("./privacyCheckExternalModuleExportAssignmentOfGenericClass_0"); export = Bar; interface Bar { foo: Foo; diff --git a/tests/cases/compiler/privacyFunctionCannotNameParameterTypeDeclFile.ts b/tests/cases/compiler/privacyFunctionCannotNameParameterTypeDeclFile.ts index f24ed8ea32b..dd5eaf82bdf 100644 --- a/tests/cases/compiler/privacyFunctionCannotNameParameterTypeDeclFile.ts +++ b/tests/cases/compiler/privacyFunctionCannotNameParameterTypeDeclFile.ts @@ -36,7 +36,7 @@ export module SpecializedWidget { // @Filename:privacyFunctionCannotNameParameterTypeDeclFile_exporter.ts /// -import Widgets = require("privacyFunctionCannotNameParameterTypeDeclFile_Widgets"); +import Widgets = require("./privacyFunctionCannotNameParameterTypeDeclFile_Widgets"); import Widgets1 = require("GlobalWidgets"); export function createExportedWidget1() { return Widgets.createWidget1(); @@ -52,7 +52,7 @@ export function createExportedWidget4() { } // @Filename:privacyFunctionCannotNameParameterTypeDeclFile_consumer.ts -import exporter = require("privacyFunctionCannotNameParameterTypeDeclFile_exporter"); +import exporter = require("./privacyFunctionCannotNameParameterTypeDeclFile_exporter"); export class publicClassWithWithPrivateParmeterTypes { static myPublicStaticMethod(param = exporter.createExportedWidget1()) { // Error } diff --git a/tests/cases/compiler/privacyFunctionCannotNameReturnTypeDeclFile.ts b/tests/cases/compiler/privacyFunctionCannotNameReturnTypeDeclFile.ts index 2eff22327b5..cb1993286a4 100644 --- a/tests/cases/compiler/privacyFunctionCannotNameReturnTypeDeclFile.ts +++ b/tests/cases/compiler/privacyFunctionCannotNameReturnTypeDeclFile.ts @@ -36,7 +36,7 @@ export module SpecializedWidget { // @Filename:privacyFunctionReturnTypeDeclFile_exporter.ts /// -import Widgets = require("privacyFunctionReturnTypeDeclFile_Widgets"); +import Widgets = require("./privacyFunctionReturnTypeDeclFile_Widgets"); import Widgets1 = require("GlobalWidgets"); export function createExportedWidget1() { return Widgets.createWidget1(); @@ -52,7 +52,7 @@ export function createExportedWidget4() { } // @Filename:privacyFunctionReturnTypeDeclFile_consumer.ts -import exporter = require("privacyFunctionReturnTypeDeclFile_exporter"); +import exporter = require("./privacyFunctionReturnTypeDeclFile_exporter"); export class publicClassWithWithPrivateParmeterTypes { static myPublicStaticMethod() { // Error return exporter.createExportedWidget1(); diff --git a/tests/cases/compiler/privacyTopLevelAmbientExternalModuleImportWithExport.ts b/tests/cases/compiler/privacyTopLevelAmbientExternalModuleImportWithExport.ts index 16c6e19fb59..1ea30d1f3c4 100644 --- a/tests/cases/compiler/privacyTopLevelAmbientExternalModuleImportWithExport.ts +++ b/tests/cases/compiler/privacyTopLevelAmbientExternalModuleImportWithExport.ts @@ -1,5 +1,5 @@ -//@module: commonjs -//@declaration: true +// @module: commonjs +// @declaration: true // @Filename: privacyTopLevelAmbientExternalModuleImportWithExport_require.ts // Public elements export class c_public { @@ -32,8 +32,8 @@ declare module 'm2' { /// /// // Privacy errors - importing private elements -export import im_public_mi_private = require("privacyTopLevelAmbientExternalModuleImportWithExport_require"); -export import im_public_mu_private = require("privacyTopLevelAmbientExternalModuleImportWithExport_require1"); +export import im_public_mi_private = require("./privacyTopLevelAmbientExternalModuleImportWithExport_require"); +export import im_public_mu_private = require("./privacyTopLevelAmbientExternalModuleImportWithExport_require1"); export import im_public_mi_public = require("m"); export import im_public_mu_public = require("m2"); diff --git a/tests/cases/compiler/requireOfAnEmptyFile1.ts b/tests/cases/compiler/requireOfAnEmptyFile1.ts index 365817f1339..98d5003ad67 100644 --- a/tests/cases/compiler/requireOfAnEmptyFile1.ts +++ b/tests/cases/compiler/requireOfAnEmptyFile1.ts @@ -1,7 +1,7 @@ -//@module: commonjs +// @module: commonjs //requireOfAnEmptyFile1 // @Filename: requireOfAnEmptyFile1_a.ts -import fs = require('requireOfAnEmptyFile1_b'); +import fs = require('./requireOfAnEmptyFile1_b'); // @Filename: requireOfAnEmptyFile1_b.ts diff --git a/tests/cases/compiler/reuseInnerModuleMember.ts b/tests/cases/compiler/reuseInnerModuleMember.ts index ebffcad6060..e2f9900e73f 100644 --- a/tests/cases/compiler/reuseInnerModuleMember.ts +++ b/tests/cases/compiler/reuseInnerModuleMember.ts @@ -1,4 +1,4 @@ -//@module: commonjs +// @module: commonjs // @Filename: reuseInnerModuleMember_0.ts export module M { } @@ -8,7 +8,7 @@ declare module bar { interface alpha { } } -import f = require('reuseInnerModuleMember_0'); +import f = require('./reuseInnerModuleMember_0'); module bar { var x: alpha; } diff --git a/tests/cases/compiler/staticInstanceResolution3.ts b/tests/cases/compiler/staticInstanceResolution3.ts index ae8cefc8102..bc4586b2adf 100644 --- a/tests/cases/compiler/staticInstanceResolution3.ts +++ b/tests/cases/compiler/staticInstanceResolution3.ts @@ -1,4 +1,4 @@ -//@module: commonjs +// @module: commonjs // @Filename: staticInstanceResolution3_0.ts export class Promise { static timeout(delay: number): Promise { @@ -8,5 +8,5 @@ export class Promise { // @Filename: staticInstanceResolution3_1.ts /// -import WinJS = require('staticInstanceResolution3_0'); +import WinJS = require('./staticInstanceResolution3_0'); WinJS.Promise.timeout(10); \ No newline at end of file diff --git a/tests/cases/compiler/typeCheckObjectCreationExpressionWithUndefinedCallResolutionData.ts b/tests/cases/compiler/typeCheckObjectCreationExpressionWithUndefinedCallResolutionData.ts index 28a9e821131..70be28f74eb 100644 --- a/tests/cases/compiler/typeCheckObjectCreationExpressionWithUndefinedCallResolutionData.ts +++ b/tests/cases/compiler/typeCheckObjectCreationExpressionWithUndefinedCallResolutionData.ts @@ -1,4 +1,4 @@ -//@module: commonjs +// @module: commonjs // @declaration: true // @Filename: file1.ts export function foo() { @@ -7,5 +7,5 @@ var classes = undefined; } // @Filename: file2.ts -import f = require('file1'); +import f = require('./file1'); f.foo(); diff --git a/tests/cases/compiler/typeofAmbientExternalModules.ts b/tests/cases/compiler/typeofAmbientExternalModules.ts index df3283bfb45..b6b8237dac6 100644 --- a/tests/cases/compiler/typeofAmbientExternalModules.ts +++ b/tests/cases/compiler/typeofAmbientExternalModules.ts @@ -1,4 +1,4 @@ -//@module: commonjs +// @module: commonjs // @Filename: typeofAmbientExternalModules_0.ts export class C { foo: string; } @@ -9,8 +9,8 @@ export = D; // @Filename: typeofAmbientExternalModules_2.ts /// /// -import ext = require('typeofAmbientExternalModules_0'); -import exp = require('typeofAmbientExternalModules_1'); +import ext = require('./typeofAmbientExternalModules_0'); +import exp = require('./typeofAmbientExternalModules_1'); var y1: typeof ext = ext; y1 = exp; diff --git a/tests/cases/compiler/typeofExternalModules.ts b/tests/cases/compiler/typeofExternalModules.ts index fe3dfad5d86..32475215e24 100644 --- a/tests/cases/compiler/typeofExternalModules.ts +++ b/tests/cases/compiler/typeofExternalModules.ts @@ -1,4 +1,4 @@ -//@module: commonjs +// @module: commonjs // @Filename: typeofExternalModules_external.ts export class C { } @@ -7,8 +7,8 @@ class D { } export = D; // @Filename: typeofExternalModules_core.ts -import ext = require('typeofExternalModules_external'); -import exp = require('typeofExternalModules_exportAssign'); +import ext = require('./typeofExternalModules_external'); +import exp = require('./typeofExternalModules_exportAssign'); var y1: typeof ext = ext; y1 = exp; diff --git a/tests/cases/compiler/unusedImportDeclaration.ts b/tests/cases/compiler/unusedImportDeclaration.ts index 263b355f69c..71fe5aae5a3 100644 --- a/tests/cases/compiler/unusedImportDeclaration.ts +++ b/tests/cases/compiler/unusedImportDeclaration.ts @@ -1,5 +1,5 @@ -//@module: commonjs -//@declaration: true +// @module: commonjs +// @declaration: true // @Filename: unusedImportDeclaration_testerB.ts class TesterB { me: string; @@ -7,7 +7,7 @@ class TesterB { export = TesterB; // @Filename: unusedImportDeclaration_testerA.ts -import B = require("unusedImportDeclaration_testerB"); +import B = require("./unusedImportDeclaration_testerB"); var thingy: B = { me: "A" }; diff --git a/tests/cases/compiler/visibilityOfCrossModuleTypeUsage.ts b/tests/cases/compiler/visibilityOfCrossModuleTypeUsage.ts index ff9610a2f65..ee22e3a4172 100644 --- a/tests/cases/compiler/visibilityOfCrossModuleTypeUsage.ts +++ b/tests/cases/compiler/visibilityOfCrossModuleTypeUsage.ts @@ -1,9 +1,9 @@ -//@module: commonjs +// @module: commonjs //visibilityOfCrossModuleTypeUsage // @Filename: visibilityOfCrossModuleTypeUsage_commands.ts -import fs = require('visibilityOfCrossModuleTypeUsage_fs'); -import server = require('visibilityOfCrossModuleTypeUsage_server'); +import fs = require('./visibilityOfCrossModuleTypeUsage_fs'); +import server = require('./visibilityOfCrossModuleTypeUsage_server'); export interface IConfiguration { workspace: server.IWorkspace; @@ -19,7 +19,7 @@ export interface IWorkspace { } // @Filename: visibilityOfCrossModuleTypeUsage_fs.ts -import commands = require('visibilityOfCrossModuleTypeUsage_commands'); +import commands = require('./visibilityOfCrossModuleTypeUsage_commands'); function run(configuration: commands.IConfiguration) { var absoluteWorkspacePath = configuration.workspace.toAbsolutePath(configuration.server); } \ No newline at end of file diff --git a/tests/cases/compiler/voidAsNonAmbiguousReturnType.ts b/tests/cases/compiler/voidAsNonAmbiguousReturnType.ts index d20f9941fbf..c00ef99e1aa 100644 --- a/tests/cases/compiler/voidAsNonAmbiguousReturnType.ts +++ b/tests/cases/compiler/voidAsNonAmbiguousReturnType.ts @@ -1,11 +1,11 @@ -//@module: commonjs +// @module: commonjs // @Filename: voidAsNonAmbiguousReturnType_0.ts export function mkdirSync(path: string, mode?: number): void; export function mkdirSync(path: string, mode?: string): void {} // @Filename: voidAsNonAmbiguousReturnType_1.ts /// -import fs = require("voidAsNonAmbiguousReturnType_0"); +import fs = require("./voidAsNonAmbiguousReturnType_0"); function main() { fs.mkdirSync('test'); // should not error - return types are the same diff --git a/tests/cases/conformance/es6/modules/multipleDefaultExports01.ts b/tests/cases/conformance/es6/modules/multipleDefaultExports01.ts index 84172248e93..e6a467820b4 100644 --- a/tests/cases/conformance/es6/modules/multipleDefaultExports01.ts +++ b/tests/cases/conformance/es6/modules/multipleDefaultExports01.ts @@ -14,6 +14,6 @@ var x = 10; export default x; // @filename: m2.ts -import Entity from "m1" +import Entity from "./m1" Entity(); \ No newline at end of file diff --git a/tests/cases/conformance/es6/modules/multipleDefaultExports02.ts b/tests/cases/conformance/es6/modules/multipleDefaultExports02.ts index 1e9c8dabc13..d642b72b6f3 100644 --- a/tests/cases/conformance/es6/modules/multipleDefaultExports02.ts +++ b/tests/cases/conformance/es6/modules/multipleDefaultExports02.ts @@ -11,6 +11,6 @@ export default function bar() { } // @filename: m2.ts -import Entity from "m1" +import Entity from "./m1" Entity(); \ No newline at end of file diff --git a/tests/cases/conformance/externalModules/topLevelFileModule.ts b/tests/cases/conformance/externalModules/topLevelFileModule.ts index 7f694f6f98d..e6680889d26 100644 --- a/tests/cases/conformance/externalModules/topLevelFileModule.ts +++ b/tests/cases/conformance/externalModules/topLevelFileModule.ts @@ -6,6 +6,6 @@ export var x: number; export declare var y: number; // @Filename: foo_1.ts -import foo = require("vs/foo_0"); -import fum = require("vs/fum"); +import foo = require("./vs/foo_0"); +import fum = require("./vs/fum"); var z = foo.x + fum.y; diff --git a/tests/cases/conformance/externalModules/topLevelModuleDeclarationAndFile.ts b/tests/cases/conformance/externalModules/topLevelModuleDeclarationAndFile.ts index db0e2ce742c..456527acfae 100644 --- a/tests/cases/conformance/externalModules/topLevelModuleDeclarationAndFile.ts +++ b/tests/cases/conformance/externalModules/topLevelModuleDeclarationAndFile.ts @@ -1,5 +1,5 @@ // @module: commonjs -// @Filename: vs/foo_0.ts +// @Filename: vs/foo_0/index.ts export var x: number = 42; // @Filename: foo_1.ts From d491a301e578d57a1c7c769098efcebc797c4bef Mon Sep 17 00:00:00 2001 From: Mohamed Hegazy Date: Tue, 15 Sep 2015 11:44:12 -0700 Subject: [PATCH 115/117] Breaking changes from node resolution changes. ambient module declarations do not take precedance any longer. --- ...eRefernceResolutionOrderInImportDeclaration.errors.txt | 8 ++++---- ...nalModuleRefernceResolutionOrderInImportDeclaration.js | 4 ++-- .../reference/topLevelModuleDeclarationAndFile.errors.txt | 2 +- .../reference/topLevelModuleDeclarationAndFile.js | 4 +--- 4 files changed, 8 insertions(+), 10 deletions(-) diff --git a/tests/baselines/reference/externalModuleRefernceResolutionOrderInImportDeclaration.errors.txt b/tests/baselines/reference/externalModuleRefernceResolutionOrderInImportDeclaration.errors.txt index 588183c6283..a0b34ecbee1 100644 --- a/tests/baselines/reference/externalModuleRefernceResolutionOrderInImportDeclaration.errors.txt +++ b/tests/baselines/reference/externalModuleRefernceResolutionOrderInImportDeclaration.errors.txt @@ -1,13 +1,13 @@ -tests/cases/compiler/externalModuleRefernceResolutionOrderInImportDeclaration_file3.ts(3,7): error TS2339: Property 'foo' does not exist on type 'typeof "externalModuleRefernceResolutionOrderInImportDeclaration_file1"'. +tests/cases/compiler/externalModuleRefernceResolutionOrderInImportDeclaration_file3.ts(4,7): error TS2339: Property 'bar' does not exist on type 'typeof "tests/cases/compiler/externalModuleRefernceResolutionOrderInImportDeclaration_file1"'. ==== tests/cases/compiler/externalModuleRefernceResolutionOrderInImportDeclaration_file3.ts (1 errors) ==== /// - import file1 = require('externalModuleRefernceResolutionOrderInImportDeclaration_file1'); + import file1 = require('./externalModuleRefernceResolutionOrderInImportDeclaration_file1'); file1.foo(); - ~~~ -!!! error TS2339: Property 'foo' does not exist on type 'typeof "externalModuleRefernceResolutionOrderInImportDeclaration_file1"'. file1.bar(); + ~~~ +!!! error TS2339: Property 'bar' does not exist on type 'typeof "tests/cases/compiler/externalModuleRefernceResolutionOrderInImportDeclaration_file1"'. ==== tests/cases/compiler/externalModuleRefernceResolutionOrderInImportDeclaration_file1.ts (0 errors) ==== diff --git a/tests/baselines/reference/externalModuleRefernceResolutionOrderInImportDeclaration.js b/tests/baselines/reference/externalModuleRefernceResolutionOrderInImportDeclaration.js index f1d1d9fb561..48411da4a02 100644 --- a/tests/baselines/reference/externalModuleRefernceResolutionOrderInImportDeclaration.js +++ b/tests/baselines/reference/externalModuleRefernceResolutionOrderInImportDeclaration.js @@ -11,7 +11,7 @@ declare module "externalModuleRefernceResolutionOrderInImportDeclaration_file1" //// [externalModuleRefernceResolutionOrderInImportDeclaration_file3.ts] /// -import file1 = require('externalModuleRefernceResolutionOrderInImportDeclaration_file1'); +import file1 = require('./externalModuleRefernceResolutionOrderInImportDeclaration_file1'); file1.foo(); file1.bar(); @@ -24,6 +24,6 @@ exports.foo = foo; ; //// [externalModuleRefernceResolutionOrderInImportDeclaration_file3.js] /// -var file1 = require('externalModuleRefernceResolutionOrderInImportDeclaration_file1'); +var file1 = require('./externalModuleRefernceResolutionOrderInImportDeclaration_file1'); file1.foo(); file1.bar(); diff --git a/tests/baselines/reference/topLevelModuleDeclarationAndFile.errors.txt b/tests/baselines/reference/topLevelModuleDeclarationAndFile.errors.txt index de343803529..cb555b7a603 100644 --- a/tests/baselines/reference/topLevelModuleDeclarationAndFile.errors.txt +++ b/tests/baselines/reference/topLevelModuleDeclarationAndFile.errors.txt @@ -9,7 +9,7 @@ tests/cases/conformance/externalModules/foo_2.ts(3,14): error TS2339: Property ' !!! error TS2339: Property 'x' does not exist on type 'typeof "vs/foo_0"'. var z2 = foo.y() + 10; // Should resolve -==== tests/cases/conformance/externalModules/vs/foo_0.ts (0 errors) ==== +==== tests/cases/conformance/externalModules/vs/foo_0/index.ts (0 errors) ==== export var x: number = 42; ==== tests/cases/conformance/externalModules/foo_1.ts (0 errors) ==== diff --git a/tests/baselines/reference/topLevelModuleDeclarationAndFile.js b/tests/baselines/reference/topLevelModuleDeclarationAndFile.js index c47de516108..e223a293d7c 100644 --- a/tests/baselines/reference/topLevelModuleDeclarationAndFile.js +++ b/tests/baselines/reference/topLevelModuleDeclarationAndFile.js @@ -1,6 +1,6 @@ //// [tests/cases/conformance/externalModules/topLevelModuleDeclarationAndFile.ts] //// -//// [foo_0.ts] +//// [index.ts] export var x: number = 42; //// [foo_1.ts] @@ -17,8 +17,6 @@ var z2 = foo.y() + 10; // Should resolve //// [foo_1.js] -//// [foo_0.js] -exports.x = 42; //// [foo_2.js] /// var foo = require("vs/foo_0"); From 48d0e6d1978b7b742e4640c61dd1d838df861f66 Mon Sep 17 00:00:00 2001 From: Mohamed Hegazy Date: Tue, 15 Sep 2015 12:08:55 -0700 Subject: [PATCH 116/117] Update tests to use "removeComments" instead of "comments" --- tests/cases/compiler/doNotEmitDetachedComments.ts | 2 +- .../compiler/doNotEmitDetachedCommentsAtStartOfConstructor.ts | 2 +- .../compiler/doNotEmitDetachedCommentsAtStartOfFunctionBody.ts | 2 +- .../doNotEmitDetachedCommentsAtStartOfLambdaFunction.ts | 2 +- tests/cases/compiler/doNotEmitPinnedCommentNotOnTopOfFile.ts | 2 +- tests/cases/compiler/doNotEmitPinnedCommentOnNotEmittedNode.ts | 2 +- .../cases/compiler/doNotEmitPinnedCommentOnNotEmittedNodets.ts | 2 +- tests/cases/compiler/doNotEmitPinnedDetachedComments.ts | 2 +- tests/cases/compiler/doNotEmitTripleSlashCommentsInEmptyFile.ts | 2 +- .../compiler/doNotEmitTripleSlashCommentsOnNotEmittedNode.ts | 2 +- tests/cases/compiler/doNotemitTripleSlashComments.ts | 2 +- tests/cases/compiler/emitPinnedCommentsOnTopOfFile.ts | 2 +- ...TripleSlashCommentOnNotEmittedNodeIfRemoveCommentsIsFalse.ts | 2 +- 13 files changed, 13 insertions(+), 13 deletions(-) diff --git a/tests/cases/compiler/doNotEmitDetachedComments.ts b/tests/cases/compiler/doNotEmitDetachedComments.ts index 412dbeac19b..13facb6625e 100644 --- a/tests/cases/compiler/doNotEmitDetachedComments.ts +++ b/tests/cases/compiler/doNotEmitDetachedComments.ts @@ -1,4 +1,4 @@ -// @comments: false +// @removeComments: true /* multi line diff --git a/tests/cases/compiler/doNotEmitDetachedCommentsAtStartOfConstructor.ts b/tests/cases/compiler/doNotEmitDetachedCommentsAtStartOfConstructor.ts index 1ea96993a5e..094d624df40 100644 --- a/tests/cases/compiler/doNotEmitDetachedCommentsAtStartOfConstructor.ts +++ b/tests/cases/compiler/doNotEmitDetachedCommentsAtStartOfConstructor.ts @@ -1,4 +1,4 @@ -// @comments: false +// @removeComments: true class A { constructor() { // Single Line Comment diff --git a/tests/cases/compiler/doNotEmitDetachedCommentsAtStartOfFunctionBody.ts b/tests/cases/compiler/doNotEmitDetachedCommentsAtStartOfFunctionBody.ts index 31adbc18de8..83dd8716df2 100644 --- a/tests/cases/compiler/doNotEmitDetachedCommentsAtStartOfFunctionBody.ts +++ b/tests/cases/compiler/doNotEmitDetachedCommentsAtStartOfFunctionBody.ts @@ -1,4 +1,4 @@ -// @comments: false +// @removeComments: true function foo1() { // Single line comment diff --git a/tests/cases/compiler/doNotEmitDetachedCommentsAtStartOfLambdaFunction.ts b/tests/cases/compiler/doNotEmitDetachedCommentsAtStartOfLambdaFunction.ts index c6a9cfc9e25..be6cd7b37ce 100644 --- a/tests/cases/compiler/doNotEmitDetachedCommentsAtStartOfLambdaFunction.ts +++ b/tests/cases/compiler/doNotEmitDetachedCommentsAtStartOfLambdaFunction.ts @@ -1,4 +1,4 @@ -// @comments: false +// @removeComments: true () => { // Single line comment diff --git a/tests/cases/compiler/doNotEmitPinnedCommentNotOnTopOfFile.ts b/tests/cases/compiler/doNotEmitPinnedCommentNotOnTopOfFile.ts index 0fbb1fddd81..bae1654af87 100644 --- a/tests/cases/compiler/doNotEmitPinnedCommentNotOnTopOfFile.ts +++ b/tests/cases/compiler/doNotEmitPinnedCommentNotOnTopOfFile.ts @@ -1,4 +1,4 @@ -// @comments: false +// @removeComments: true var x = 10; /*! diff --git a/tests/cases/compiler/doNotEmitPinnedCommentOnNotEmittedNode.ts b/tests/cases/compiler/doNotEmitPinnedCommentOnNotEmittedNode.ts index 48e02a372f7..23a1000fa11 100644 --- a/tests/cases/compiler/doNotEmitPinnedCommentOnNotEmittedNode.ts +++ b/tests/cases/compiler/doNotEmitPinnedCommentOnNotEmittedNode.ts @@ -1,4 +1,4 @@ -// @comments: false +// @removeComments: true class C { /*! remove pinned comment anywhere else */ diff --git a/tests/cases/compiler/doNotEmitPinnedCommentOnNotEmittedNodets.ts b/tests/cases/compiler/doNotEmitPinnedCommentOnNotEmittedNodets.ts index a59e13df55c..27c5c5f6b7b 100644 --- a/tests/cases/compiler/doNotEmitPinnedCommentOnNotEmittedNodets.ts +++ b/tests/cases/compiler/doNotEmitPinnedCommentOnNotEmittedNodets.ts @@ -1,4 +1,4 @@ -// @comments: false +// @removeComments: true class C { /*! remove pinned comment anywhere else */ diff --git a/tests/cases/compiler/doNotEmitPinnedDetachedComments.ts b/tests/cases/compiler/doNotEmitPinnedDetachedComments.ts index 534963cf4b7..f30dc9299ee 100644 --- a/tests/cases/compiler/doNotEmitPinnedDetachedComments.ts +++ b/tests/cases/compiler/doNotEmitPinnedDetachedComments.ts @@ -1,4 +1,4 @@ -// @comments: false +// @removeComments: true var x = 10; /*! Single Line comment */ diff --git a/tests/cases/compiler/doNotEmitTripleSlashCommentsInEmptyFile.ts b/tests/cases/compiler/doNotEmitTripleSlashCommentsInEmptyFile.ts index 047510e2ec9..357ce67dbed 100644 --- a/tests/cases/compiler/doNotEmitTripleSlashCommentsInEmptyFile.ts +++ b/tests/cases/compiler/doNotEmitTripleSlashCommentsInEmptyFile.ts @@ -1,4 +1,4 @@ -// @comments: false +// @removeComments: true // @Filename: file0.ts diff --git a/tests/cases/compiler/doNotEmitTripleSlashCommentsOnNotEmittedNode.ts b/tests/cases/compiler/doNotEmitTripleSlashCommentsOnNotEmittedNode.ts index 91941a6cf81..bfa5c5ffc67 100644 --- a/tests/cases/compiler/doNotEmitTripleSlashCommentsOnNotEmittedNode.ts +++ b/tests/cases/compiler/doNotEmitTripleSlashCommentsOnNotEmittedNode.ts @@ -1,4 +1,4 @@ -// @comments: false +// @removeComments: true // @Filename: file0.ts /// diff --git a/tests/cases/compiler/doNotemitTripleSlashComments.ts b/tests/cases/compiler/doNotemitTripleSlashComments.ts index f3b90662159..14fdfda2d72 100644 --- a/tests/cases/compiler/doNotemitTripleSlashComments.ts +++ b/tests/cases/compiler/doNotemitTripleSlashComments.ts @@ -1,4 +1,4 @@ -// @comments: false +// @removeComments: true // @Filename: file0.ts /// diff --git a/tests/cases/compiler/emitPinnedCommentsOnTopOfFile.ts b/tests/cases/compiler/emitPinnedCommentsOnTopOfFile.ts index bbe6c400601..985a5f638b8 100644 --- a/tests/cases/compiler/emitPinnedCommentsOnTopOfFile.ts +++ b/tests/cases/compiler/emitPinnedCommentsOnTopOfFile.ts @@ -1,4 +1,4 @@ -// @comments: false +// @removeComments: true /*! multi line diff --git a/tests/cases/compiler/emitTopOfFileTripleSlashCommentOnNotEmittedNodeIfRemoveCommentsIsFalse.ts b/tests/cases/compiler/emitTopOfFileTripleSlashCommentOnNotEmittedNodeIfRemoveCommentsIsFalse.ts index 20c04702544..56f7814104d 100644 --- a/tests/cases/compiler/emitTopOfFileTripleSlashCommentOnNotEmittedNodeIfRemoveCommentsIsFalse.ts +++ b/tests/cases/compiler/emitTopOfFileTripleSlashCommentOnNotEmittedNodeIfRemoveCommentsIsFalse.ts @@ -1,4 +1,4 @@ -// @comments: true +// @removeComments: false // @Filename: file0.ts var x = 10 From c735a98523e112ccb1e7a45fc854fb3e21327939 Mon Sep 17 00:00:00 2001 From: Mohamed Hegazy Date: Tue, 15 Sep 2015 12:47:11 -0700 Subject: [PATCH 117/117] Respond to code review comments --- src/harness/fourslash.ts | 2 +- src/harness/harness.ts | 15 +++++++++------ 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/src/harness/fourslash.ts b/src/harness/fourslash.ts index ae131b8390f..1d333a29ccb 100644 --- a/src/harness/fourslash.ts +++ b/src/harness/fourslash.ts @@ -125,7 +125,7 @@ module FourSlash { // List of allowed metadata names let fileMetadataNames = [metadataOptionNames.fileName, metadataOptionNames.emitThisFile, metadataOptionNames.resolveReference]; - function convertGlobalOptionsToCompilerOptions(globalOptions: { [idx: string]: string }): ts.CompilerOptions { + function convertGlobalOptionsToCompilerOptions(globalOptions: Harness.TestCaseParser.CompilerSettings): ts.CompilerOptions { let settings: ts.CompilerOptions = { target: ts.ScriptTarget.ES5 }; Harness.Compiler.setCompilerOptionsFromHarnessSetting(globalOptions, settings); return settings; diff --git a/src/harness/harness.ts b/src/harness/harness.ts index c4287bacb43..01b583d64e1 100644 --- a/src/harness/harness.ts +++ b/src/harness/harness.ts @@ -949,7 +949,7 @@ module Harness { }; } - interface HarnesOptions { + interface HarnessOptions { useCaseSensitiveFileNames?: boolean; includeBuiltFile?: string; baselineFile?: string; @@ -977,10 +977,13 @@ module Harness { return ts.lookUp(optionsIndex, name.toLowerCase()); } - export function setCompilerOptionsFromHarnessSetting(settings: Harness.TestCaseParser.CompilerSettings, options: ts.CompilerOptions & HarnesOptions): void { + export function setCompilerOptionsFromHarnessSetting(settings: Harness.TestCaseParser.CompilerSettings, options: ts.CompilerOptions & HarnessOptions): void { for (let name in settings) { if (settings.hasOwnProperty(name)) { let value = settings[name]; + if (value === undefined) { + throw new Error(`Cannot have undefined value for compiler option '${name}'.`); + } let option = getCommandLineOption(name); if (option) { switch (option.type) { @@ -993,17 +996,17 @@ module Harness { // If not a primitive, the possible types are specified in what is effectively a map of options. default: let map = >option.type; - let key = (value).toLowerCase(); + let key = value.toLowerCase(); if (ts.hasProperty(map, key)) { options[option.name] = map[key]; } else { - throw new Error(`Unkown value '${value}' for compiler option '${name}'.`); + throw new Error(`Unknown value '${value}' for compiler option '${name}'.`); } } } else { - throw new Error(`Unkown compiler option '${name}'.`); + throw new Error(`Unknown compiler option '${name}'.`); } } } @@ -1062,7 +1065,7 @@ module Harness { otherFiles: { unitName: string; content: string }[], onComplete: (result: CompilerResult, program: ts.Program) => void, settingsCallback?: (settings: ts.CompilerOptions) => void, - options?: ts.CompilerOptions & HarnesOptions, + options?: ts.CompilerOptions & HarnessOptions, // Current directory is needed for rwcRunner to be able to use currentDirectory defined in json file currentDirectory?: string) {