From 35b16ab7a8294abd093e7eed36260b46f1c4942e Mon Sep 17 00:00:00 2001 From: Arthur Ozga Date: Wed, 7 Jun 2017 14:01:42 -0700 Subject: [PATCH 001/370] temp --- src/harness/fourslash.ts | 14 ++++++++++++++ src/harness/harnessLanguageService.ts | 3 +++ src/server/client.ts | 4 ++++ src/server/protocol.ts | 15 +++++++++++++++ src/server/session.ts | 11 +++++++++++ src/services/services.ts | 11 +++++++++++ src/services/shims.ts | 12 ++++++++++++ src/services/types.ts | 1 + tests/cases/fourslash/fourslash.ts | 1 + tests/cases/fourslash/isInMultiLineComment.ts | 6 ++++++ 10 files changed, 78 insertions(+) create mode 100644 tests/cases/fourslash/isInMultiLineComment.ts diff --git a/src/harness/fourslash.ts b/src/harness/fourslash.ts index fc50e71478e..ed29e74f66f 100644 --- a/src/harness/fourslash.ts +++ b/src/harness/fourslash.ts @@ -2427,6 +2427,16 @@ namespace FourSlash { } } + public verifyIsInMultiLineComment(negative: boolean) { + const expected = !negative; + const position = this.currentCaretPosition; + const fileName = this.activeFile.fileName; + const actual = this.languageService.getIsInMultiLineComment(fileName, position); + if (expected !== actual) { + this.raiseError(`verifyIsInDocComment failed: at position '${position}' in '${fileName}', expected '${expected}'.`); + } + } + private clarifyNewlines(str: string) { return str.replace(/\r?\n/g, lineEnding => { const representation = lineEnding === "\r\n" ? "CRLF" : "LF"; @@ -3577,6 +3587,10 @@ namespace FourSlashInterface { this.state.verifyCodeFixAvailable(this.negative); } + public isInMultiLineComment() { + this.state.verifyIsInMultiLineComment(this.negative); + } + public applicableRefactorAvailableAtMarker(markerName: string) { this.state.verifyApplicableRefactorAvailableAtMarker(this.negative, markerName); } diff --git a/src/harness/harnessLanguageService.ts b/src/harness/harnessLanguageService.ts index 7aefb0f3a1f..c67dde5f67b 100644 --- a/src/harness/harnessLanguageService.ts +++ b/src/harness/harnessLanguageService.ts @@ -483,6 +483,9 @@ namespace Harness.LanguageService { getDocCommentTemplateAtPosition(fileName: string, position: number): ts.TextInsertion { return unwrapJSONCallResult(this.shim.getDocCommentTemplateAtPosition(fileName, position)); } + getIsInMultiLineComment(fileName: string, position: number): boolean { + return unwrapJSONCallResult(this.shim.getIsInMultiLineComment(fileName, position)); + } isValidBraceCompletionAtPosition(fileName: string, position: number, openingBrace: number): boolean { return unwrapJSONCallResult(this.shim.isValidBraceCompletionAtPosition(fileName, position, openingBrace)); } diff --git a/src/server/client.ts b/src/server/client.ts index e29261f7244..779d3bce6bf 100644 --- a/src/server/client.ts +++ b/src/server/client.ts @@ -672,6 +672,10 @@ namespace ts.server { return notImplemented(); } + getIsInMultiLineComment(_fileName: string, _position: number): boolean { + return notImplemented(); + } + isValidBraceCompletionAtPosition(_fileName: string, _position: number, _openingBrace: number): boolean { return notImplemented(); } diff --git a/src/server/protocol.ts b/src/server/protocol.ts index 8d85ad125d5..2df147a4d37 100644 --- a/src/server/protocol.ts +++ b/src/server/protocol.ts @@ -84,6 +84,7 @@ namespace ts.server.protocol { export type TodoComments = "todoComments"; export type Indentation = "indentation"; export type DocCommentTemplate = "docCommentTemplate"; + export type IsInMultiLineComment = "isInMultiLineComment"; /* @internal */ export type CompilerOptionsDiagnosticsFull = "compilerOptionsDiagnostics-full"; /* @internal */ @@ -237,6 +238,20 @@ namespace ts.server.protocol { body?: TodoComment[]; } + /** + * A request to determine if the caret is inside a multi-line comment. + */ + export interface IsInMultiLineCommentRequest extends FileLocationRequest { + command: CommandTypes.IsInMultiLineComment; + } + + /** + * Response for TodoCommentRequest request. + */ + export interface IsInMultiLineCommentResponse extends Response { + body?: { isInMultiLineComment: boolean }; + } + /** * Request to obtain outlining spans in file. */ diff --git a/src/server/session.ts b/src/server/session.ts index bae53dcafe8..a79e572e11b 100644 --- a/src/server/session.ts +++ b/src/server/session.ts @@ -194,6 +194,7 @@ namespace ts.server { export const TodoComments: protocol.CommandTypes.TodoComments = "todoComments"; export const Indentation: protocol.CommandTypes.Indentation = "indentation"; export const DocCommentTemplate: protocol.CommandTypes.DocCommentTemplate = "docCommentTemplate"; + export const IsInMultiLineComment: protocol.CommandTypes.IsInMultiLineComment = "isInMultiLineComment"; /* @internal */ export const CompilerOptionsDiagnosticsFull: protocol.CommandTypes.CompilerOptionsDiagnosticsFull = "compilerOptionsDiagnostics-full"; /* @internal */ @@ -1049,6 +1050,13 @@ namespace ts.server { return project.getLanguageService(/*ensureSynchronized*/ false).getDocCommentTemplateAtPosition(file, position); } + private getIsInMultiLineComment(args: protocol.FileLocationRequestArgs) { + const { file, project } = this.getFileAndProjectWithoutRefreshingInferredProjects(args); + const scriptInfo = project.getScriptInfoForNormalizedPath(file); + const position = this.getPosition(args, scriptInfo); + return project.getLanguageService(/*ensureSynchronized*/ false).getIsInMultiLineComment(file, position); + } + private getIndentation(args: protocol.IndentationRequestArgs) { const { file, project } = this.getFileAndProjectWithoutRefreshingInferredProjects(args); const position = this.getPosition(args, project.getScriptInfoForNormalizedPath(file)); @@ -1782,6 +1790,9 @@ namespace ts.server { [CommandNames.DocCommentTemplate]: (request: protocol.DocCommentTemplateRequest) => { return this.requiredResponse(this.getDocCommentTemplate(request.arguments)); }, + [CommandNames.IsInMultiLineComment]: (request: protocol.IsInMultiLineCommentRequest) => { + return this.requiredResponse(this.getIsInMultiLineComment(request.arguments)); + }, [CommandNames.Format]: (request: protocol.FormatRequest) => { return this.requiredResponse(this.getFormattingEditsForRange(request.arguments)); }, diff --git a/src/services/services.ts b/src/services/services.ts index 1a1ac47847f..83c94e91c58 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -1779,6 +1779,16 @@ namespace ts { return JsDoc.getDocCommentTemplateAtPosition(getNewLineOrDefaultFromHost(host), syntaxTreeCache.getCurrentSourceFile(fileName), position); } + function getIsInMultiLineComment(_fileName: string, position: number): boolean { + const sourceFile = syntaxTreeCache.getCurrentSourceFile(_fileName); + const token = getTokenAtPosition(sourceFile, position); + const _triviaWidth = token.getLeadingTriviaWidth(sourceFile); _triviaWidth; + const _text = token.getText(sourceFile); _text; + const _fullText = token.getFullText(sourceFile); _fullText; + // TODO: distinguish multi-line and single line comments... + return token.getFullStart() <= position && position < token.getStart(sourceFile, /*includeJsDocComment*/ false); + } + function isValidBraceCompletionAtPosition(fileName: string, position: number, openingBrace: number): boolean { // '<' is currently not supported, figuring out if we're in a Generic Type vs. a comparison is too // expensive to do during typing scenarios @@ -2030,6 +2040,7 @@ namespace ts { getFormattingEditsForDocument, getFormattingEditsAfterKeystroke, getDocCommentTemplateAtPosition, + getIsInMultiLineComment, isValidBraceCompletionAtPosition, getCodeFixesAtPosition, getEmitOutput, diff --git a/src/services/shims.ts b/src/services/shims.ts index 498c1834a60..3ce553d552e 100644 --- a/src/services/shims.ts +++ b/src/services/shims.ts @@ -247,6 +247,11 @@ namespace ts { */ getDocCommentTemplateAtPosition(fileName: string, position: number): string; + /** + * Returns JSON-encoded value of the type TextInsertion. + */ + getIsInMultiLineComment(fileName: string, position: number): string; + /** * Returns JSON-encoded boolean to indicate whether we should support brace location * at the current position. @@ -935,6 +940,13 @@ namespace ts { ); } + public getIsInMultiLineComment(fileName: string, position: number): string { + return this.forwardJSONCall( + `getIsInMultiLineComment('${fileName}', ${position})`, + () => this.languageService.getIsInMultiLineComment(fileName, position) + ); + } + /// NAVIGATE TO /** Return a list of symbols that are interesting to navigate to */ diff --git a/src/services/types.ts b/src/services/types.ts index 6c64ce5b9ba..20505378882 100644 --- a/src/services/types.ts +++ b/src/services/types.ts @@ -257,6 +257,7 @@ namespace ts { getFormattingEditsAfterKeystroke(fileName: string, position: number, key: string, options: FormatCodeOptions | FormatCodeSettings): TextChange[]; getDocCommentTemplateAtPosition(fileName: string, position: number): TextInsertion; + getIsInMultiLineComment(fileName: string, position: number): boolean; isValidBraceCompletionAtPosition(fileName: string, position: number, openingBrace: number): boolean; diff --git a/tests/cases/fourslash/fourslash.ts b/tests/cases/fourslash/fourslash.ts index 3fada673f35..3af3464138a 100644 --- a/tests/cases/fourslash/fourslash.ts +++ b/tests/cases/fourslash/fourslash.ts @@ -150,6 +150,7 @@ declare namespace FourSlashInterface { implementationListIsEmpty(): void; isValidBraceCompletionAtPosition(openingBrace?: string): void; codeFixAvailable(): void; + isInMultiLineComment(): void; applicableRefactorAvailableAtMarker(markerName: string): void; codeFixDiagnosticsAvailableAtMarkers(markerNames: string[], diagnosticCode?: number): void; applicableRefactorAvailableForRange(): void; diff --git a/tests/cases/fourslash/isInMultiLineComment.ts b/tests/cases/fourslash/isInMultiLineComment.ts new file mode 100644 index 00000000000..4d6c8d6af1a --- /dev/null +++ b/tests/cases/fourslash/isInMultiLineComment.ts @@ -0,0 +1,6 @@ +/// + +//// /* blach /*m0*/ */ let x = 10; + +goTo.marker("m0"); +verify.isInMultiLineComment(); \ No newline at end of file From a819e4ed172405bffe6fb419483bdccaeb1de16b Mon Sep 17 00:00:00 2001 From: Arthur Ozga Date: Wed, 7 Jun 2017 16:43:13 -0700 Subject: [PATCH 002/370] isInMultiLineComment --- src/services/services.ts | 17 +++++---- tests/cases/fourslash/isInMultiLineComment.ts | 36 +++++++++++++++++-- .../fourslash/isInMultiLineCommentEOF.ts | 12 +++++++ 3 files changed, 56 insertions(+), 9 deletions(-) create mode 100644 tests/cases/fourslash/isInMultiLineCommentEOF.ts diff --git a/src/services/services.ts b/src/services/services.ts index 8da654140e0..1f85ad427f5 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -1791,12 +1791,17 @@ namespace ts { function getIsInMultiLineComment(_fileName: string, position: number): boolean { const sourceFile = syntaxTreeCache.getCurrentSourceFile(_fileName); - const token = getTokenAtPosition(sourceFile, position, /*includeJsDocComment*/ true); - const _triviaWidth = token.getLeadingTriviaWidth(sourceFile); _triviaWidth; - const _text = token.getText(sourceFile); _text; - const _fullText = token.getFullText(sourceFile); _fullText; - // TODO: distinguish multi-line and single line comments... - return token.getFullStart() <= position && position < token.getStart(sourceFile, /*includeJsDocComment*/ false); + const token = getTokenAtPosition(sourceFile, position, /*includeJsDocComment*/ false); + const leadingCommentRanges = getLeadingCommentRangesOfNode(token, sourceFile); + + for (const range of leadingCommentRanges) { + // We need to extend the range when in an unclosed multi-line comment. + if (range.pos < position && (position < range.end || position === range.end && position === sourceFile.getFullWidth())) { + return range.kind === SyntaxKind.MultiLineCommentTrivia; + } + } + + return false; } function isValidBraceCompletionAtPosition(fileName: string, position: number, openingBrace: number): boolean { diff --git a/tests/cases/fourslash/isInMultiLineComment.ts b/tests/cases/fourslash/isInMultiLineComment.ts index 4d6c8d6af1a..ebcac7215f9 100644 --- a/tests/cases/fourslash/isInMultiLineComment.ts +++ b/tests/cases/fourslash/isInMultiLineComment.ts @@ -1,6 +1,36 @@ /// -//// /* blach /*m0*/ */ let x = 10; +//// /* x */ +//// /** x */ +//// // x +//// let x = 1; -goTo.marker("m0"); -verify.isInMultiLineComment(); \ No newline at end of file + +for (let i = 1; i < 7; ++i) { + goTo.position(i); + verify.isInMultiLineComment(); +} + +for (let i = 0; i < 2; ++i) { + goTo.position(i * 7); + verify.not.isInMultiLineComment(); +} + +const jsDocStart = 8; + +for (let i = 1; i < 8; ++i) { + goTo.position(jsDocStart + i); + verify.isInMultiLineComment(); +} + +for (let i = 0; i < 2; ++i) { + goTo.position(jsDocStart + i * 8); + verify.not.isInMultiLineComment(); +} + +const singleLineCommentStart = 17; + +for (let i = 0; i < 5; ++i) { + goTo.position(singleLineCommentStart + i); + verify.not.isInMultiLineComment(); +} diff --git a/tests/cases/fourslash/isInMultiLineCommentEOF.ts b/tests/cases/fourslash/isInMultiLineCommentEOF.ts new file mode 100644 index 00000000000..2e34264b1f6 --- /dev/null +++ b/tests/cases/fourslash/isInMultiLineCommentEOF.ts @@ -0,0 +1,12 @@ +/// + +// @Filename: f1.ts +//// /* /*0*/ blah /*1*/ */ + +// @Filename: f2.ts +//// /* /*2*/ blah /*3*/ + +for (let i = 0; i < 4; ++i) { + goTo.marker(`${i}`); + verify.isInMultiLineComment(); +} \ No newline at end of file From 8f28a0264ffcaa75e99617f9888f46e6c8f2ff41 Mon Sep 17 00:00:00 2001 From: Arthur Ozga Date: Thu, 8 Jun 2017 17:08:07 -0700 Subject: [PATCH 003/370] indent block comments according to first line --- src/harness/fourslash.ts | 28 +++++++++---------- src/harness/harnessLanguageService.ts | 6 ++-- src/server/client.ts | 4 +-- src/server/protocol.ts | 13 ++------- src/server/session.ts | 8 +++--- src/services/formatting/formatting.ts | 21 ++++++++++++++ src/services/formatting/smartIndenter.ts | 7 ++++- src/services/services.ts | 22 ++++----------- src/services/shims.ts | 25 +++++++++-------- src/services/types.ts | 3 +- tests/cases/fourslash/fourslash.ts | 2 +- tests/cases/fourslash/isInMultiLineComment.ts | 10 +++---- .../fourslash/isInMultiLineCommentEOF.ts | 2 +- 13 files changed, 81 insertions(+), 70 deletions(-) diff --git a/src/harness/fourslash.ts b/src/harness/fourslash.ts index aa3097debad..54b5b48da2b 100644 --- a/src/harness/fourslash.ts +++ b/src/harness/fourslash.ts @@ -2427,16 +2427,6 @@ namespace FourSlash { } } - public verifyIsInMultiLineComment(negative: boolean) { - const expected = !negative; - const position = this.currentCaretPosition; - const fileName = this.activeFile.fileName; - const actual = this.languageService.getIsInMultiLineComment(fileName, position); - if (expected !== actual) { - this.raiseError(`verifyIsInDocComment failed: at position '${position}' in '${fileName}', expected '${expected}'.`); - } - } - private clarifyNewlines(str: string) { return str.replace(/\r?\n/g, lineEnding => { const representation = lineEnding === "\r\n" ? "CRLF" : "LF"; @@ -2510,6 +2500,16 @@ namespace FourSlash { } } + public verifyisInMultiLineCommentAtPosition(negative: boolean) { + const expected = !negative; + const position = this.currentCaretPosition; + const fileName = this.activeFile.fileName; + const actual = this.languageService.getisInMultiLineCommentAtPosition(fileName, position); + if (expected !== actual) { + this.raiseError(`verifyIsInDocComment failed: at position '${position}' in '${fileName}', expected '${expected}'.`); + } + } + /* Check number of navigationItems which match both searchValue and matchKind, if a filename is passed in, limit the results to that file. @@ -3583,12 +3583,12 @@ namespace FourSlashInterface { this.state.verifyBraceCompletionAtPosition(this.negative, openingBrace); } - public codeFixAvailable() { - this.state.verifyCodeFixAvailable(this.negative); + public isInMultiLineCommentAtPosition() { + this.state.verifyisInMultiLineCommentAtPosition(this.negative); } - public isInMultiLineComment() { - this.state.verifyIsInMultiLineComment(this.negative); + public codeFixAvailable() { + this.state.verifyCodeFixAvailable(this.negative); } public applicableRefactorAvailableAtMarker(markerName: string) { diff --git a/src/harness/harnessLanguageService.ts b/src/harness/harnessLanguageService.ts index c67dde5f67b..c3a09b3926f 100644 --- a/src/harness/harnessLanguageService.ts +++ b/src/harness/harnessLanguageService.ts @@ -483,12 +483,12 @@ namespace Harness.LanguageService { getDocCommentTemplateAtPosition(fileName: string, position: number): ts.TextInsertion { return unwrapJSONCallResult(this.shim.getDocCommentTemplateAtPosition(fileName, position)); } - getIsInMultiLineComment(fileName: string, position: number): boolean { - return unwrapJSONCallResult(this.shim.getIsInMultiLineComment(fileName, position)); - } isValidBraceCompletionAtPosition(fileName: string, position: number, openingBrace: number): boolean { return unwrapJSONCallResult(this.shim.isValidBraceCompletionAtPosition(fileName, position, openingBrace)); } + getisInMultiLineCommentAtPosition(fileName: string, position: number): boolean { + return unwrapJSONCallResult(this.shim.getisInMultiLineCommentAtPosition(fileName, position)); + } getCodeFixesAtPosition(): ts.CodeAction[] { throw new Error("Not supported on the shim."); } diff --git a/src/server/client.ts b/src/server/client.ts index 69727a18e60..5a162c1041d 100644 --- a/src/server/client.ts +++ b/src/server/client.ts @@ -672,11 +672,11 @@ namespace ts.server { return notImplemented(); } - getIsInMultiLineComment(_fileName: string, _position: number): boolean { + isValidBraceCompletionAtPosition(_fileName: string, _position: number, _openingBrace: number): boolean { return notImplemented(); } - isValidBraceCompletionAtPosition(_fileName: string, _position: number, _openingBrace: number): boolean { + getisInMultiLineCommentAtPosition(_fileName: string, _position: number): boolean { return notImplemented(); } diff --git a/src/server/protocol.ts b/src/server/protocol.ts index 1cfe617ca72..299ba4fceed 100644 --- a/src/server/protocol.ts +++ b/src/server/protocol.ts @@ -8,6 +8,7 @@ namespace ts.server.protocol { /* @internal */ BraceFull = "brace-full", BraceCompletion = "braceCompletion", + isInMultiLineComment = "isInMultiLineComment", Change = "change", Close = "close", Completions = "completions", @@ -85,7 +86,6 @@ namespace ts.server.protocol { TodoComments = "todoComments", Indentation = "indentation", DocCommentTemplate = "docCommentTemplate", - IsInMultiLineComment = "isInMultiLineComment", /* @internal */ CompilerOptionsDiagnosticsFull = "compilerOptionsDiagnostics-full", /* @internal */ @@ -242,15 +242,8 @@ namespace ts.server.protocol { /** * A request to determine if the caret is inside a multi-line comment. */ - export interface IsInMultiLineCommentRequest extends FileLocationRequest { - command: CommandTypes.IsInMultiLineComment; - } - - /** - * Response for TodoCommentRequest request. - */ - export interface IsInMultiLineCommentResponse extends Response { - body?: { isInMultiLineComment: boolean }; + export interface IsInMultiLineCommentAtPositionRequest extends FileLocationRequest { + command: CommandTypes.isInMultiLineComment; } /** diff --git a/src/server/session.ts b/src/server/session.ts index abebdb5fae9..e4e900ddce7 100644 --- a/src/server/session.ts +++ b/src/server/session.ts @@ -961,11 +961,11 @@ namespace ts.server { return project.getLanguageService(/*ensureSynchronized*/ false).getDocCommentTemplateAtPosition(file, position); } - private getIsInMultiLineComment(args: protocol.FileLocationRequestArgs) { + private getisInMultiLineCommentAtPosition(args: protocol.FileLocationRequestArgs) { const { file, project } = this.getFileAndProjectWithoutRefreshingInferredProjects(args); const scriptInfo = project.getScriptInfoForNormalizedPath(file); const position = this.getPosition(args, scriptInfo); - return project.getLanguageService(/*ensureSynchronized*/ false).getIsInMultiLineComment(file, position); + return project.getLanguageService(/*ensureSynchronized*/ false).getisInMultiLineCommentAtPosition(file, position); } private getIndentation(args: protocol.IndentationRequestArgs) { @@ -1701,8 +1701,8 @@ namespace ts.server { [CommandNames.DocCommentTemplate]: (request: protocol.DocCommentTemplateRequest) => { return this.requiredResponse(this.getDocCommentTemplate(request.arguments)); }, - [CommandNames.IsInMultiLineComment]: (request: protocol.IsInMultiLineCommentRequest) => { - return this.requiredResponse(this.getIsInMultiLineComment(request.arguments)); + [CommandNames.isInMultiLineComment]: (request: protocol.IsInMultiLineCommentAtPositionRequest) => { + return this.requiredResponse(this.getisInMultiLineCommentAtPosition(request.arguments)); }, [CommandNames.Format]: (request: protocol.FormatRequest) => { return this.requiredResponse(this.getFormattingEditsForRange(request.arguments)); diff --git a/src/services/formatting/formatting.ts b/src/services/formatting/formatting.ts index 531b768f6d8..fa49ee852b1 100644 --- a/src/services/formatting/formatting.ts +++ b/src/services/formatting/formatting.ts @@ -1117,6 +1117,27 @@ namespace ts.formatting { } } + /** + * @returns -1 iff the position is not in a multi-line comment. + */ + export function getIndentationOfEnclosingMultiLineComment(sourceFile: SourceFile, position: number): number { + const token = getTokenAtPosition(sourceFile, position, /*includeJsDocComment*/ false); + const leadingCommentRanges = getLeadingCommentRangesOfNode(token, sourceFile); + if (leadingCommentRanges) { + loop: for (const range of leadingCommentRanges) { + // We need to extend the range when in an unclosed multi-line comment. + if (range.pos < position && (position < range.end || position === range.end && position === sourceFile.getFullWidth())) { + if (range.kind === SyntaxKind.MultiLineCommentTrivia) { + return range.pos - getLineStartPositionForPosition(range.pos, sourceFile); + } + break loop; + } + } + } + return -1; + } + + function getOpenTokenForList(node: Node, list: Node[]) { switch (node.kind) { case SyntaxKind.Constructor: diff --git a/src/services/formatting/smartIndenter.ts b/src/services/formatting/smartIndenter.ts index 18b0479c85a..8acab0e6603 100644 --- a/src/services/formatting/smartIndenter.ts +++ b/src/services/formatting/smartIndenter.ts @@ -38,12 +38,17 @@ namespace ts.formatting { // no indentation in string \regex\template literals const precedingTokenIsLiteral = isStringOrRegularExpressionOrTemplateLiteral(precedingToken.kind); - if (precedingTokenIsLiteral && precedingToken.getStart(sourceFile) <= position && precedingToken.end > position) { + if (precedingTokenIsLiteral && precedingToken.getStart(sourceFile) <= position && position < precedingToken.end) { return 0; } const lineAtPosition = sourceFile.getLineAndCharacterOfPosition(position).line; + const indentationOfEnclosingMultiLineComment = getIndentationOfEnclosingMultiLineComment(sourceFile, position); + if (indentationOfEnclosingMultiLineComment !== -1) { + return indentationOfEnclosingMultiLineComment; + } + // indentation is first non-whitespace character in a previous line // for block indentation, we should look for a line which contains something that's not // whitespace. diff --git a/src/services/services.ts b/src/services/services.ts index 1f85ad427f5..ab398db7c35 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -1789,21 +1789,6 @@ namespace ts { return JsDoc.getDocCommentTemplateAtPosition(getNewLineOrDefaultFromHost(host), syntaxTreeCache.getCurrentSourceFile(fileName), position); } - function getIsInMultiLineComment(_fileName: string, position: number): boolean { - const sourceFile = syntaxTreeCache.getCurrentSourceFile(_fileName); - const token = getTokenAtPosition(sourceFile, position, /*includeJsDocComment*/ false); - const leadingCommentRanges = getLeadingCommentRangesOfNode(token, sourceFile); - - for (const range of leadingCommentRanges) { - // We need to extend the range when in an unclosed multi-line comment. - if (range.pos < position && (position < range.end || position === range.end && position === sourceFile.getFullWidth())) { - return range.kind === SyntaxKind.MultiLineCommentTrivia; - } - } - - return false; - } - function isValidBraceCompletionAtPosition(fileName: string, position: number, openingBrace: number): boolean { // '<' is currently not supported, figuring out if we're in a Generic Type vs. a comparison is too // expensive to do during typing scenarios @@ -1833,6 +1818,11 @@ namespace ts { return true; } + function getisInMultiLineCommentAtPosition(fileName: string, position: number): boolean { + const sourceFile = syntaxTreeCache.getCurrentSourceFile(fileName); + return ts.formatting.getIndentationOfEnclosingMultiLineComment(sourceFile, position) !== -1; + } + function getTodoComments(fileName: string, descriptors: TodoCommentDescriptor[]): TodoComment[] { // Note: while getting todo comments seems like a syntactic operation, we actually // treat it as a semantic operation here. This is because we expect our host to call @@ -2054,8 +2044,8 @@ namespace ts { getFormattingEditsForDocument, getFormattingEditsAfterKeystroke, getDocCommentTemplateAtPosition, - getIsInMultiLineComment, isValidBraceCompletionAtPosition, + getisInMultiLineCommentAtPosition, getCodeFixesAtPosition, getEmitOutput, getNonBoundSourceFile, diff --git a/src/services/shims.ts b/src/services/shims.ts index 3ce553d552e..75c5e8445c1 100644 --- a/src/services/shims.ts +++ b/src/services/shims.ts @@ -247,11 +247,6 @@ namespace ts { */ getDocCommentTemplateAtPosition(fileName: string, position: number): string; - /** - * Returns JSON-encoded value of the type TextInsertion. - */ - getIsInMultiLineComment(fileName: string, position: number): string; - /** * Returns JSON-encoded boolean to indicate whether we should support brace location * at the current position. @@ -259,6 +254,11 @@ namespace ts { */ isValidBraceCompletionAtPosition(fileName: string, position: number, openingBrace: number): string; + /** + * Returns JSON-encoded boolean to indicate whether the caret at the current position is in a multi-line comment. + */ + getisInMultiLineCommentAtPosition(fileName: string, position: number): string; + getEmitOutput(fileName: string): string; getEmitOutputObject(fileName: string): EmitOutput; } @@ -840,6 +840,14 @@ namespace ts { ); } + /// GET IS IN MULTI-LINE COMMENT + public getisInMultiLineCommentAtPosition(fileName: string, position: number): string { + return this.forwardJSONCall( + `getisInMultiLineCommentAtPosition('${fileName}', ${position})`, + () => this.languageService.getisInMultiLineCommentAtPosition(fileName, position) + ); + } + /// GET SMART INDENT public getIndentationAtPosition(fileName: string, position: number, options: string /*Services.EditorOptions*/): string { return this.forwardJSONCall( @@ -940,13 +948,6 @@ namespace ts { ); } - public getIsInMultiLineComment(fileName: string, position: number): string { - return this.forwardJSONCall( - `getIsInMultiLineComment('${fileName}', ${position})`, - () => this.languageService.getIsInMultiLineComment(fileName, position) - ); - } - /// NAVIGATE TO /** Return a list of symbols that are interesting to navigate to */ diff --git a/src/services/types.ts b/src/services/types.ts index 62d2db1b65c..3a7a14d3dbc 100644 --- a/src/services/types.ts +++ b/src/services/types.ts @@ -257,10 +257,11 @@ namespace ts { getFormattingEditsAfterKeystroke(fileName: string, position: number, key: string, options: FormatCodeOptions | FormatCodeSettings): TextChange[]; getDocCommentTemplateAtPosition(fileName: string, position: number): TextInsertion; - getIsInMultiLineComment(fileName: string, position: number): boolean; isValidBraceCompletionAtPosition(fileName: string, position: number, openingBrace: number): boolean; + getisInMultiLineCommentAtPosition(fileName: string, position: number): boolean; + getCodeFixesAtPosition(fileName: string, start: number, end: number, errorCodes: number[], formatOptions: FormatCodeSettings): CodeAction[]; getApplicableRefactors(fileName: string, positionOrRaneg: number | TextRange): ApplicableRefactorInfo[]; getRefactorCodeActions(fileName: string, formatOptions: FormatCodeSettings, positionOrRange: number | TextRange, refactorName: string): CodeAction[] | undefined; diff --git a/tests/cases/fourslash/fourslash.ts b/tests/cases/fourslash/fourslash.ts index 3984a074fd9..96cc152f0ff 100644 --- a/tests/cases/fourslash/fourslash.ts +++ b/tests/cases/fourslash/fourslash.ts @@ -149,8 +149,8 @@ declare namespace FourSlashInterface { typeDefinitionCountIs(expectedCount: number): void; implementationListIsEmpty(): void; isValidBraceCompletionAtPosition(openingBrace?: string): void; + isInMultiLineCommentAtPosition(): void; codeFixAvailable(): void; - isInMultiLineComment(): void; applicableRefactorAvailableAtMarker(markerName: string): void; codeFixDiagnosticsAvailableAtMarkers(markerNames: string[], diagnosticCode?: number): void; applicableRefactorAvailableForRange(): void; diff --git a/tests/cases/fourslash/isInMultiLineComment.ts b/tests/cases/fourslash/isInMultiLineComment.ts index ebcac7215f9..39aac71a8bd 100644 --- a/tests/cases/fourslash/isInMultiLineComment.ts +++ b/tests/cases/fourslash/isInMultiLineComment.ts @@ -8,29 +8,29 @@ for (let i = 1; i < 7; ++i) { goTo.position(i); - verify.isInMultiLineComment(); + verify.isInMultiLineCommentAtPosition(); } for (let i = 0; i < 2; ++i) { goTo.position(i * 7); - verify.not.isInMultiLineComment(); + verify.not.isInMultiLineCommentAtPosition(); } const jsDocStart = 8; for (let i = 1; i < 8; ++i) { goTo.position(jsDocStart + i); - verify.isInMultiLineComment(); + verify.isInMultiLineCommentAtPosition(); } for (let i = 0; i < 2; ++i) { goTo.position(jsDocStart + i * 8); - verify.not.isInMultiLineComment(); + verify.not.isInMultiLineCommentAtPosition(); } const singleLineCommentStart = 17; for (let i = 0; i < 5; ++i) { goTo.position(singleLineCommentStart + i); - verify.not.isInMultiLineComment(); + verify.not.isInMultiLineCommentAtPosition(); } diff --git a/tests/cases/fourslash/isInMultiLineCommentEOF.ts b/tests/cases/fourslash/isInMultiLineCommentEOF.ts index 2e34264b1f6..2b65a958340 100644 --- a/tests/cases/fourslash/isInMultiLineCommentEOF.ts +++ b/tests/cases/fourslash/isInMultiLineCommentEOF.ts @@ -8,5 +8,5 @@ for (let i = 0; i < 4; ++i) { goTo.marker(`${i}`); - verify.isInMultiLineComment(); + verify.isInMultiLineCommentAtPosition(); } \ No newline at end of file From b02963b2380f8cd4c2675a72f974552e5acd7f1e Mon Sep 17 00:00:00 2001 From: Arthur Ozga Date: Fri, 9 Jun 2017 14:43:28 -0700 Subject: [PATCH 004/370] make indent work with trailing comments --- src/harness/fourslash.ts | 8 +-- src/harness/harnessLanguageService.ts | 2 +- src/server/client.ts | 2 +- src/server/session.ts | 2 +- src/services/formatting/formatting.ts | 35 +++++++---- src/services/formatting/smartIndenter.ts | 18 +++--- src/services/services.ts | 6 +- src/services/shims.ts | 2 +- src/services/types.ts | 2 +- tests/cases/fourslash/isInMultiLineComment.ts | 58 +++++++++++-------- 10 files changed, 79 insertions(+), 56 deletions(-) diff --git a/src/harness/fourslash.ts b/src/harness/fourslash.ts index 54b5b48da2b..080614fc623 100644 --- a/src/harness/fourslash.ts +++ b/src/harness/fourslash.ts @@ -2500,13 +2500,13 @@ namespace FourSlash { } } - public verifyisInMultiLineCommentAtPosition(negative: boolean) { + public verifyIsInMultiLineCommentAtPosition(negative: boolean) { const expected = !negative; const position = this.currentCaretPosition; const fileName = this.activeFile.fileName; - const actual = this.languageService.getisInMultiLineCommentAtPosition(fileName, position); + const actual = this.languageService.isInMultiLineCommentAtPosition(fileName, position); if (expected !== actual) { - this.raiseError(`verifyIsInDocComment failed: at position '${position}' in '${fileName}', expected '${expected}'.`); + this.raiseError(`verifyIsInMultiLineCommentAtPosition failed: at position '${position}' in '${fileName}', expected '${expected}'.`); } } @@ -3584,7 +3584,7 @@ namespace FourSlashInterface { } public isInMultiLineCommentAtPosition() { - this.state.verifyisInMultiLineCommentAtPosition(this.negative); + this.state.verifyIsInMultiLineCommentAtPosition(this.negative); } public codeFixAvailable() { diff --git a/src/harness/harnessLanguageService.ts b/src/harness/harnessLanguageService.ts index c3a09b3926f..962f9a0df5d 100644 --- a/src/harness/harnessLanguageService.ts +++ b/src/harness/harnessLanguageService.ts @@ -486,7 +486,7 @@ namespace Harness.LanguageService { isValidBraceCompletionAtPosition(fileName: string, position: number, openingBrace: number): boolean { return unwrapJSONCallResult(this.shim.isValidBraceCompletionAtPosition(fileName, position, openingBrace)); } - getisInMultiLineCommentAtPosition(fileName: string, position: number): boolean { + isInMultiLineCommentAtPosition(fileName: string, position: number): boolean { return unwrapJSONCallResult(this.shim.getisInMultiLineCommentAtPosition(fileName, position)); } getCodeFixesAtPosition(): ts.CodeAction[] { diff --git a/src/server/client.ts b/src/server/client.ts index 5a162c1041d..0e66516da40 100644 --- a/src/server/client.ts +++ b/src/server/client.ts @@ -676,7 +676,7 @@ namespace ts.server { return notImplemented(); } - getisInMultiLineCommentAtPosition(_fileName: string, _position: number): boolean { + isInMultiLineCommentAtPosition(_fileName: string, _position: number): boolean { return notImplemented(); } diff --git a/src/server/session.ts b/src/server/session.ts index e4e900ddce7..9657c666238 100644 --- a/src/server/session.ts +++ b/src/server/session.ts @@ -965,7 +965,7 @@ namespace ts.server { const { file, project } = this.getFileAndProjectWithoutRefreshingInferredProjects(args); const scriptInfo = project.getScriptInfoForNormalizedPath(file); const position = this.getPosition(args, scriptInfo); - return project.getLanguageService(/*ensureSynchronized*/ false).getisInMultiLineCommentAtPosition(file, position); + return project.getLanguageService(/*ensureSynchronized*/ false).isInMultiLineCommentAtPosition(file, position); } private getIndentation(args: protocol.IndentationRequestArgs) { diff --git a/src/services/formatting/formatting.ts b/src/services/formatting/formatting.ts index fa49ee852b1..7feba4b7dd2 100644 --- a/src/services/formatting/formatting.ts +++ b/src/services/formatting/formatting.ts @@ -1118,23 +1118,36 @@ namespace ts.formatting { } /** - * @returns -1 iff the position is not in a multi-line comment. + * Gets the indentation level of the multi-line comment enclosing position, + * and a negative value if the position is not in a multi-line comment. */ - export function getIndentationOfEnclosingMultiLineComment(sourceFile: SourceFile, position: number): number { - const token = getTokenAtPosition(sourceFile, position, /*includeJsDocComment*/ false); - const leadingCommentRanges = getLeadingCommentRangesOfNode(token, sourceFile); - if (leadingCommentRanges) { - loop: for (const range of leadingCommentRanges) { + export function getIndentationOfEnclosingMultiLineComment(sourceFile: SourceFile, position: number, options: EditorSettings): number { + const range = getRangeOfEnclosingComment(sourceFile, position, SyntaxKind.MultiLineCommentTrivia); + if (range) { + const commentStart = range.pos; + const commentLineStart = getLineStartPositionForPosition(commentStart, sourceFile); + const { column, character } = SmartIndenter.findFirstNonWhitespaceCharacterAndColumn(commentLineStart, commentStart, sourceFile, options); + return range.pos - character + column; + } + return undefined; + } + + export function getRangeOfEnclosingComment(sourceFile: SourceFile, position: number, kind: CommentKind): CommentRange | undefined { + const precedingToken = findPrecedingToken(position, sourceFile); + const trailingRangesOfPreviousToken = precedingToken && getTrailingCommentRanges(sourceFile.text, precedingToken.end); + const leadingCommentRangesOfNextToken = getLeadingCommentRangesOfNode(getTokenAtPosition(sourceFile, position, /*includeJsDocComment*/ false), sourceFile); + const commentRanges = trailingRangesOfPreviousToken && leadingCommentRangesOfNextToken ? + trailingRangesOfPreviousToken.concat(leadingCommentRangesOfNextToken) : + trailingRangesOfPreviousToken || leadingCommentRangesOfNextToken; + if (commentRanges) { + for (const range of commentRanges) { // We need to extend the range when in an unclosed multi-line comment. if (range.pos < position && (position < range.end || position === range.end && position === sourceFile.getFullWidth())) { - if (range.kind === SyntaxKind.MultiLineCommentTrivia) { - return range.pos - getLineStartPositionForPosition(range.pos, sourceFile); - } - break loop; + return range.kind === kind ? range : undefined; } } } - return -1; + return undefined; } diff --git a/src/services/formatting/smartIndenter.ts b/src/services/formatting/smartIndenter.ts index 8acab0e6603..c5aee567a41 100644 --- a/src/services/formatting/smartIndenter.ts +++ b/src/services/formatting/smartIndenter.ts @@ -44,8 +44,8 @@ namespace ts.formatting { const lineAtPosition = sourceFile.getLineAndCharacterOfPosition(position).line; - const indentationOfEnclosingMultiLineComment = getIndentationOfEnclosingMultiLineComment(sourceFile, position); - if (indentationOfEnclosingMultiLineComment !== -1) { + const indentationOfEnclosingMultiLineComment = getIndentationOfEnclosingMultiLineComment(sourceFile, position, options); + if (indentationOfEnclosingMultiLineComment >= 0) { return indentationOfEnclosingMultiLineComment; } @@ -410,13 +410,13 @@ namespace ts.formatting { return findFirstNonWhitespaceColumn(lineStart, lineStart + lineAndCharacter.character, sourceFile, options); } - /* - Character is the actual index of the character since the beginning of the line. - Column - position of the character after expanding tabs to spaces - "0\t2$" - value of 'character' for '$' is 3 - value of 'column' for '$' is 6 (assuming that tab size is 4) - */ + /** + * Character is the actual index of the character since the beginning of the line. + * Column - position of the character after expanding tabs to spaces. + * "0\t2$" + * value of 'character' for '$' is 3 + * value of 'column' for '$' is 6 (assuming that tab size is 4) + */ export function findFirstNonWhitespaceCharacterAndColumn(startPos: number, endPos: number, sourceFile: SourceFileLike, options: EditorSettings) { let character = 0; let column = 0; diff --git a/src/services/services.ts b/src/services/services.ts index ab398db7c35..294afec6029 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -1818,9 +1818,9 @@ namespace ts { return true; } - function getisInMultiLineCommentAtPosition(fileName: string, position: number): boolean { + function isInMultiLineCommentAtPosition(fileName: string, position: number): boolean { const sourceFile = syntaxTreeCache.getCurrentSourceFile(fileName); - return ts.formatting.getIndentationOfEnclosingMultiLineComment(sourceFile, position) !== -1; + return !!ts.formatting.getRangeOfEnclosingComment(sourceFile, position, SyntaxKind.MultiLineCommentTrivia); } function getTodoComments(fileName: string, descriptors: TodoCommentDescriptor[]): TodoComment[] { @@ -2045,7 +2045,7 @@ namespace ts { getFormattingEditsAfterKeystroke, getDocCommentTemplateAtPosition, isValidBraceCompletionAtPosition, - getisInMultiLineCommentAtPosition, + isInMultiLineCommentAtPosition, getCodeFixesAtPosition, getEmitOutput, getNonBoundSourceFile, diff --git a/src/services/shims.ts b/src/services/shims.ts index 75c5e8445c1..fd2ba1cca72 100644 --- a/src/services/shims.ts +++ b/src/services/shims.ts @@ -844,7 +844,7 @@ namespace ts { public getisInMultiLineCommentAtPosition(fileName: string, position: number): string { return this.forwardJSONCall( `getisInMultiLineCommentAtPosition('${fileName}', ${position})`, - () => this.languageService.getisInMultiLineCommentAtPosition(fileName, position) + () => this.languageService.isInMultiLineCommentAtPosition(fileName, position) ); } diff --git a/src/services/types.ts b/src/services/types.ts index 3a7a14d3dbc..bbd9fa9986c 100644 --- a/src/services/types.ts +++ b/src/services/types.ts @@ -260,7 +260,7 @@ namespace ts { isValidBraceCompletionAtPosition(fileName: string, position: number, openingBrace: number): boolean; - getisInMultiLineCommentAtPosition(fileName: string, position: number): boolean; + isInMultiLineCommentAtPosition(fileName: string, position: number): boolean; getCodeFixesAtPosition(fileName: string, start: number, end: number, errorCodes: number[], formatOptions: FormatCodeSettings): CodeAction[]; getApplicableRefactors(fileName: string, positionOrRaneg: number | TextRange): ApplicableRefactorInfo[]; diff --git a/tests/cases/fourslash/isInMultiLineComment.ts b/tests/cases/fourslash/isInMultiLineComment.ts index 39aac71a8bd..58e4e4d3337 100644 --- a/tests/cases/fourslash/isInMultiLineComment.ts +++ b/tests/cases/fourslash/isInMultiLineComment.ts @@ -1,36 +1,46 @@ /// //// /* x */ -//// /** x */ +//// /** +//// * @param this doesn't make sense here. +//// */ //// // x -//// let x = 1; +//// let x = 1; /* +//// * +const firstCommentStart = 0; +const firstCommentEnd = 7; +goTo.position(firstCommentStart); +verify.not.isInMultiLineCommentAtPosition(); -for (let i = 1; i < 7; ++i) { - goTo.position(i); - verify.isInMultiLineCommentAtPosition(); -} +goTo.position(firstCommentStart + 1); +verify.isInMultiLineCommentAtPosition(); +goTo.position(firstCommentEnd - 1); +verify.isInMultiLineCommentAtPosition(); -for (let i = 0; i < 2; ++i) { - goTo.position(i * 7); - verify.not.isInMultiLineCommentAtPosition(); -} +goTo.position(firstCommentEnd); +verify.not.isInMultiLineCommentAtPosition(); -const jsDocStart = 8; +const multilineJsDocStart = firstCommentEnd + 1; +const multilineJsDocEnd = multilineJsDocStart + 49; -for (let i = 1; i < 8; ++i) { - goTo.position(jsDocStart + i); - verify.isInMultiLineCommentAtPosition(); -} +goTo.position(multilineJsDocStart); +verify.not.isInMultiLineCommentAtPosition(); +goTo.position(multilineJsDocStart + 1); +verify.isInMultiLineCommentAtPosition(); +goTo.position(multilineJsDocEnd - 1); +verify.isInMultiLineCommentAtPosition(); +goTo.position(multilineJsDocEnd); +verify.not.isInMultiLineCommentAtPosition(); -for (let i = 0; i < 2; ++i) { - goTo.position(jsDocStart + i * 8); - verify.not.isInMultiLineCommentAtPosition(); -} +const singleLineCommentStart = multilineJsDocEnd + 1; -const singleLineCommentStart = 17; +goTo.position(singleLineCommentStart + 1); +verify.not.isInMultiLineCommentAtPosition(); -for (let i = 0; i < 5; ++i) { - goTo.position(singleLineCommentStart + i); - verify.not.isInMultiLineCommentAtPosition(); -} +const postNodeCommentStart = singleLineCommentStart + 16; + +goTo.position(postNodeCommentStart); +verify.not.isInMultiLineCommentAtPosition(); +goTo.position(postNodeCommentStart + 1); +verify.isInMultiLineCommentAtPosition(); From 8fc3fd9a20fb30e8602d20c68c799449497a7870 Mon Sep 17 00:00:00 2001 From: Arthur Ozga Date: Fri, 9 Jun 2017 18:02:42 -0700 Subject: [PATCH 005/370] request returns span --- src/harness/fourslash.ts | 14 +++++++++----- src/harness/harnessLanguageService.ts | 4 ++-- src/server/client.ts | 2 +- src/server/protocol.ts | 16 ++++++++++++---- src/server/session.ts | 9 +++++---- src/services/formatting/formatting.ts | 6 +++--- src/services/services.ts | 7 ++++--- src/services/shims.ts | 11 +++++------ src/services/types.ts | 2 +- 9 files changed, 42 insertions(+), 29 deletions(-) diff --git a/src/harness/fourslash.ts b/src/harness/fourslash.ts index 080614fc623..3feb5c0b19d 100644 --- a/src/harness/fourslash.ts +++ b/src/harness/fourslash.ts @@ -2500,13 +2500,17 @@ namespace FourSlash { } } - public verifyIsInMultiLineCommentAtPosition(negative: boolean) { + public verifySpanOfEnclosingComment(negative: boolean, onlyMultiLine: boolean) { const expected = !negative; const position = this.currentCaretPosition; const fileName = this.activeFile.fileName; - const actual = this.languageService.isInMultiLineCommentAtPosition(fileName, position); + const actual = !!this.languageService.getSpanOfEnclosingComment(fileName, position, /*onlyMultiLine*/ onlyMultiLine); if (expected !== actual) { - this.raiseError(`verifyIsInMultiLineCommentAtPosition failed: at position '${position}' in '${fileName}', expected '${expected}'.`); + this.raiseError(`verifySpanOfEnclosingComment failed: + position: '${position}' + fileName: '${fileName}' + onlyMultiLine: '${onlyMultiLine}' + expected: '${expected}'.`); } } @@ -3583,8 +3587,8 @@ namespace FourSlashInterface { this.state.verifyBraceCompletionAtPosition(this.negative, openingBrace); } - public isInMultiLineCommentAtPosition() { - this.state.verifyIsInMultiLineCommentAtPosition(this.negative); + public isInCommentAtPosition(onlyMultiLine: boolean) { + this.state.verifySpanOfEnclosingComment(this.negative, onlyMultiLine); } public codeFixAvailable() { diff --git a/src/harness/harnessLanguageService.ts b/src/harness/harnessLanguageService.ts index 962f9a0df5d..6d7eee5757f 100644 --- a/src/harness/harnessLanguageService.ts +++ b/src/harness/harnessLanguageService.ts @@ -486,8 +486,8 @@ namespace Harness.LanguageService { isValidBraceCompletionAtPosition(fileName: string, position: number, openingBrace: number): boolean { return unwrapJSONCallResult(this.shim.isValidBraceCompletionAtPosition(fileName, position, openingBrace)); } - isInMultiLineCommentAtPosition(fileName: string, position: number): boolean { - return unwrapJSONCallResult(this.shim.getisInMultiLineCommentAtPosition(fileName, position)); + getSpanOfEnclosingComment(fileName: string, position: number, onlyMultiLine: boolean): ts.TextSpan { + return unwrapJSONCallResult(this.shim.getSpanOfEnclosingComment(fileName, position, onlyMultiLine)); } getCodeFixesAtPosition(): ts.CodeAction[] { throw new Error("Not supported on the shim."); diff --git a/src/server/client.ts b/src/server/client.ts index 0e66516da40..5e5a6fcfcd5 100644 --- a/src/server/client.ts +++ b/src/server/client.ts @@ -676,7 +676,7 @@ namespace ts.server { return notImplemented(); } - isInMultiLineCommentAtPosition(_fileName: string, _position: number): boolean { + getSpanOfEnclosingComment(_fileName: string, _position: number, _onlyMultiLine: boolean): TextSpan { return notImplemented(); } diff --git a/src/server/protocol.ts b/src/server/protocol.ts index 299ba4fceed..0dc510c4f6e 100644 --- a/src/server/protocol.ts +++ b/src/server/protocol.ts @@ -8,7 +8,7 @@ namespace ts.server.protocol { /* @internal */ BraceFull = "brace-full", BraceCompletion = "braceCompletion", - isInMultiLineComment = "isInMultiLineComment", + GetSpanOfEnclosingComment = "getSpanOfEnclosingComment", Change = "change", Close = "close", Completions = "completions", @@ -240,10 +240,18 @@ namespace ts.server.protocol { } /** - * A request to determine if the caret is inside a multi-line comment. + * A request to determine if the caret is inside a comment. */ - export interface IsInMultiLineCommentAtPositionRequest extends FileLocationRequest { - command: CommandTypes.isInMultiLineComment; + export interface SpanOfEnclosingCommentRequest extends FileLocationRequest { + command: CommandTypes.GetSpanOfEnclosingComment; + arguments: SpanOfEnclosingCommentRequestArgs; + } + + export interface SpanOfEnclosingCommentRequestArgs extends FileLocationRequestArgs { + /** + * Requires that the enclosing span be a multi-line comment, or else the request returns undefined. + */ + onlyMultiLine: boolean; } /** diff --git a/src/server/session.ts b/src/server/session.ts index 9657c666238..2be7cade587 100644 --- a/src/server/session.ts +++ b/src/server/session.ts @@ -961,11 +961,12 @@ namespace ts.server { return project.getLanguageService(/*ensureSynchronized*/ false).getDocCommentTemplateAtPosition(file, position); } - private getisInMultiLineCommentAtPosition(args: protocol.FileLocationRequestArgs) { + private getSpanOfEnclosingComment(args: protocol.SpanOfEnclosingCommentRequestArgs) { const { file, project } = this.getFileAndProjectWithoutRefreshingInferredProjects(args); const scriptInfo = project.getScriptInfoForNormalizedPath(file); + const onlyMultiLine = args.onlyMultiLine; const position = this.getPosition(args, scriptInfo); - return project.getLanguageService(/*ensureSynchronized*/ false).isInMultiLineCommentAtPosition(file, position); + return project.getLanguageService(/*ensureSynchronized*/ false).getSpanOfEnclosingComment(file, position, onlyMultiLine); } private getIndentation(args: protocol.IndentationRequestArgs) { @@ -1701,8 +1702,8 @@ namespace ts.server { [CommandNames.DocCommentTemplate]: (request: protocol.DocCommentTemplateRequest) => { return this.requiredResponse(this.getDocCommentTemplate(request.arguments)); }, - [CommandNames.isInMultiLineComment]: (request: protocol.IsInMultiLineCommentAtPositionRequest) => { - return this.requiredResponse(this.getisInMultiLineCommentAtPosition(request.arguments)); + [CommandNames.GetSpanOfEnclosingComment]: (request: protocol.SpanOfEnclosingCommentRequest) => { + return this.requiredResponse(this.getSpanOfEnclosingComment(request.arguments)); }, [CommandNames.Format]: (request: protocol.FormatRequest) => { return this.requiredResponse(this.getFormattingEditsForRange(request.arguments)); diff --git a/src/services/formatting/formatting.ts b/src/services/formatting/formatting.ts index 7feba4b7dd2..08d2bd83616 100644 --- a/src/services/formatting/formatting.ts +++ b/src/services/formatting/formatting.ts @@ -1122,7 +1122,7 @@ namespace ts.formatting { * and a negative value if the position is not in a multi-line comment. */ export function getIndentationOfEnclosingMultiLineComment(sourceFile: SourceFile, position: number, options: EditorSettings): number { - const range = getRangeOfEnclosingComment(sourceFile, position, SyntaxKind.MultiLineCommentTrivia); + const range = getRangeOfEnclosingComment(sourceFile, position, /*onlyMultiLine*/ true); if (range) { const commentStart = range.pos; const commentLineStart = getLineStartPositionForPosition(commentStart, sourceFile); @@ -1132,7 +1132,7 @@ namespace ts.formatting { return undefined; } - export function getRangeOfEnclosingComment(sourceFile: SourceFile, position: number, kind: CommentKind): CommentRange | undefined { + export function getRangeOfEnclosingComment(sourceFile: SourceFile, position: number, onlyMultiLine: boolean): CommentRange | undefined { const precedingToken = findPrecedingToken(position, sourceFile); const trailingRangesOfPreviousToken = precedingToken && getTrailingCommentRanges(sourceFile.text, precedingToken.end); const leadingCommentRangesOfNextToken = getLeadingCommentRangesOfNode(getTokenAtPosition(sourceFile, position, /*includeJsDocComment*/ false), sourceFile); @@ -1143,7 +1143,7 @@ namespace ts.formatting { for (const range of commentRanges) { // We need to extend the range when in an unclosed multi-line comment. if (range.pos < position && (position < range.end || position === range.end && position === sourceFile.getFullWidth())) { - return range.kind === kind ? range : undefined; + return onlyMultiLine && range.kind !== SyntaxKind.MultiLineCommentTrivia ? undefined : range; } } } diff --git a/src/services/services.ts b/src/services/services.ts index 294afec6029..8234a100522 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -1818,9 +1818,10 @@ namespace ts { return true; } - function isInMultiLineCommentAtPosition(fileName: string, position: number): boolean { + function getSpanOfEnclosingComment(fileName: string, position: number, onlyMultiLine: boolean) { const sourceFile = syntaxTreeCache.getCurrentSourceFile(fileName); - return !!ts.formatting.getRangeOfEnclosingComment(sourceFile, position, SyntaxKind.MultiLineCommentTrivia); + const range = ts.formatting.getRangeOfEnclosingComment(sourceFile, position, onlyMultiLine); + return range && createTextSpanFromRange(range); } function getTodoComments(fileName: string, descriptors: TodoCommentDescriptor[]): TodoComment[] { @@ -2045,7 +2046,7 @@ namespace ts { getFormattingEditsAfterKeystroke, getDocCommentTemplateAtPosition, isValidBraceCompletionAtPosition, - isInMultiLineCommentAtPosition, + getSpanOfEnclosingComment, getCodeFixesAtPosition, getEmitOutput, getNonBoundSourceFile, diff --git a/src/services/shims.ts b/src/services/shims.ts index fd2ba1cca72..2e9825e1457 100644 --- a/src/services/shims.ts +++ b/src/services/shims.ts @@ -255,9 +255,9 @@ namespace ts { isValidBraceCompletionAtPosition(fileName: string, position: number, openingBrace: number): string; /** - * Returns JSON-encoded boolean to indicate whether the caret at the current position is in a multi-line comment. + * Returns a JSON-encoded TextSpan | undefined indicating the range of the enclosing comment, if it exists. */ - getisInMultiLineCommentAtPosition(fileName: string, position: number): string; + getSpanOfEnclosingComment(fileName: string, position: number, onlyMultiLine: boolean): string; getEmitOutput(fileName: string): string; getEmitOutputObject(fileName: string): EmitOutput; @@ -840,11 +840,10 @@ namespace ts { ); } - /// GET IS IN MULTI-LINE COMMENT - public getisInMultiLineCommentAtPosition(fileName: string, position: number): string { + public getSpanOfEnclosingComment(fileName: string, position: number, onlyMultiLine: boolean): string { return this.forwardJSONCall( - `getisInMultiLineCommentAtPosition('${fileName}', ${position})`, - () => this.languageService.isInMultiLineCommentAtPosition(fileName, position) + `getSpanOfEnclosingComment('${fileName}', ${position})`, + () => this.languageService.getSpanOfEnclosingComment(fileName, position, onlyMultiLine) ); } diff --git a/src/services/types.ts b/src/services/types.ts index bbd9fa9986c..73bf75b5508 100644 --- a/src/services/types.ts +++ b/src/services/types.ts @@ -260,7 +260,7 @@ namespace ts { isValidBraceCompletionAtPosition(fileName: string, position: number, openingBrace: number): boolean; - isInMultiLineCommentAtPosition(fileName: string, position: number): boolean; + getSpanOfEnclosingComment(fileName: string, position: number, onlyMultiLine: boolean): TextSpan; getCodeFixesAtPosition(fileName: string, start: number, end: number, errorCodes: number[], formatOptions: FormatCodeSettings): CodeAction[]; getApplicableRefactors(fileName: string, positionOrRaneg: number | TextRange): ApplicableRefactorInfo[]; From cc880915d5b1077477387fb6e4d16cb2fa21e30d Mon Sep 17 00:00:00 2001 From: Arthur Ozga Date: Fri, 9 Jun 2017 21:19:29 -0700 Subject: [PATCH 006/370] fix offsetting and tests --- src/services/formatting/formatting.ts | 5 ++-- tests/cases/fourslash/fourslash.ts | 2 +- tests/cases/fourslash/isInMultiLineComment.ts | 23 ++++++++++--------- .../fourslash/isInMultiLineCommentEOF.ts | 12 ---------- 4 files changed, 16 insertions(+), 26 deletions(-) delete mode 100644 tests/cases/fourslash/isInMultiLineCommentEOF.ts diff --git a/src/services/formatting/formatting.ts b/src/services/formatting/formatting.ts index 08d2bd83616..b5cede24e95 100644 --- a/src/services/formatting/formatting.ts +++ b/src/services/formatting/formatting.ts @@ -1127,7 +1127,7 @@ namespace ts.formatting { const commentStart = range.pos; const commentLineStart = getLineStartPositionForPosition(commentStart, sourceFile); const { column, character } = SmartIndenter.findFirstNonWhitespaceCharacterAndColumn(commentLineStart, commentStart, sourceFile, options); - return range.pos - character + column; + return column + /*length after whitespace ends*/ range.pos - (commentLineStart + character); } return undefined; } @@ -1142,7 +1142,8 @@ namespace ts.formatting { if (commentRanges) { for (const range of commentRanges) { // We need to extend the range when in an unclosed multi-line comment. - if (range.pos < position && (position < range.end || position === range.end && position === sourceFile.getFullWidth())) { + if (range.pos < position && position < range.end || + position === range.end && (range.kind === SyntaxKind.SingleLineCommentTrivia || position === sourceFile.getFullWidth())) { return onlyMultiLine && range.kind !== SyntaxKind.MultiLineCommentTrivia ? undefined : range; } } diff --git a/tests/cases/fourslash/fourslash.ts b/tests/cases/fourslash/fourslash.ts index 96cc152f0ff..67ab1d2a2e2 100644 --- a/tests/cases/fourslash/fourslash.ts +++ b/tests/cases/fourslash/fourslash.ts @@ -149,7 +149,7 @@ declare namespace FourSlashInterface { typeDefinitionCountIs(expectedCount: number): void; implementationListIsEmpty(): void; isValidBraceCompletionAtPosition(openingBrace?: string): void; - isInMultiLineCommentAtPosition(): void; + isInCommentAtPosition(onlyMultiLine: boolean): void; codeFixAvailable(): void; applicableRefactorAvailableAtMarker(markerName: string): void; codeFixDiagnosticsAvailableAtMarkers(markerNames: string[], diagnosticCode?: number): void; diff --git a/tests/cases/fourslash/isInMultiLineComment.ts b/tests/cases/fourslash/isInMultiLineComment.ts index 58e4e4d3337..3dc8a6e15d1 100644 --- a/tests/cases/fourslash/isInMultiLineComment.ts +++ b/tests/cases/fourslash/isInMultiLineComment.ts @@ -11,36 +11,37 @@ const firstCommentStart = 0; const firstCommentEnd = 7; goTo.position(firstCommentStart); -verify.not.isInMultiLineCommentAtPosition(); +verify.not.isInCommentAtPosition(/*onlyMultiLine*/ true); goTo.position(firstCommentStart + 1); -verify.isInMultiLineCommentAtPosition(); +verify.isInCommentAtPosition(/*onlyMultiLine*/ true); goTo.position(firstCommentEnd - 1); -verify.isInMultiLineCommentAtPosition(); +verify.isInCommentAtPosition(/*onlyMultiLine*/ true); goTo.position(firstCommentEnd); -verify.not.isInMultiLineCommentAtPosition(); +verify.not.isInCommentAtPosition(/*onlyMultiLine*/ true); const multilineJsDocStart = firstCommentEnd + 1; const multilineJsDocEnd = multilineJsDocStart + 49; goTo.position(multilineJsDocStart); -verify.not.isInMultiLineCommentAtPosition(); +verify.not.isInCommentAtPosition(/*onlyMultiLine*/ true); goTo.position(multilineJsDocStart + 1); -verify.isInMultiLineCommentAtPosition(); +verify.isInCommentAtPosition(/*onlyMultiLine*/ true); goTo.position(multilineJsDocEnd - 1); -verify.isInMultiLineCommentAtPosition(); +verify.isInCommentAtPosition(/*onlyMultiLine*/ true); goTo.position(multilineJsDocEnd); -verify.not.isInMultiLineCommentAtPosition(); +verify.not.isInCommentAtPosition(/*onlyMultiLine*/ true); const singleLineCommentStart = multilineJsDocEnd + 1; goTo.position(singleLineCommentStart + 1); -verify.not.isInMultiLineCommentAtPosition(); +verify.not.isInCommentAtPosition(/*onlyMultiLine*/ true); +verify.isInCommentAtPosition(/*onlyMultiLine*/ false); const postNodeCommentStart = singleLineCommentStart + 16; goTo.position(postNodeCommentStart); -verify.not.isInMultiLineCommentAtPosition(); +verify.not.isInCommentAtPosition(/*onlyMultiLine*/ true); goTo.position(postNodeCommentStart + 1); -verify.isInMultiLineCommentAtPosition(); +verify.isInCommentAtPosition(/*onlyMultiLine*/ true); diff --git a/tests/cases/fourslash/isInMultiLineCommentEOF.ts b/tests/cases/fourslash/isInMultiLineCommentEOF.ts deleted file mode 100644 index 2b65a958340..00000000000 --- a/tests/cases/fourslash/isInMultiLineCommentEOF.ts +++ /dev/null @@ -1,12 +0,0 @@ -/// - -// @Filename: f1.ts -//// /* /*0*/ blah /*1*/ */ - -// @Filename: f2.ts -//// /* /*2*/ blah /*3*/ - -for (let i = 0; i < 4; ++i) { - goTo.marker(`${i}`); - verify.isInMultiLineCommentAtPosition(); -} \ No newline at end of file From 2a2595fc5fe997df5659a1f867a2688ada68e1e1 Mon Sep 17 00:00:00 2001 From: Arthur Ozga Date: Mon, 19 Jun 2017 10:57:47 -0700 Subject: [PATCH 007/370] apply formatting after parse error --- src/services/formatting/formatting.ts | 4 +--- tests/cases/fourslash/formatOnEnterEmptyBlock.ts | 16 ++++++++++++++++ tests/cases/fourslash/fourslash.ts | 2 +- 3 files changed, 18 insertions(+), 4 deletions(-) create mode 100644 tests/cases/fourslash/formatOnEnterEmptyBlock.ts diff --git a/src/services/formatting/formatting.ts b/src/services/formatting/formatting.ts index 531b768f6d8..2450cdca604 100644 --- a/src/services/formatting/formatting.ts +++ b/src/services/formatting/formatting.ts @@ -363,7 +363,6 @@ namespace ts.formatting { // formatting context is used by rules provider const formattingContext = new FormattingContext(sourceFile, requestKind, options); - let previousRangeHasError: boolean; let previousRange: TextRangeWithKind; let previousParent: Node; let previousRangeStartLine: number; @@ -848,7 +847,7 @@ namespace ts.formatting { const rangeHasError = rangeContainsError(range); let lineAdded: boolean; - if (!rangeHasError && !previousRangeHasError) { + if (!rangeHasError) { if (!previousRange) { // trim whitespaces starting from the beginning of the span up to the current line const originalStart = sourceFile.getLineAndCharacterOfPosition(originalRange.pos); @@ -863,7 +862,6 @@ namespace ts.formatting { previousRange = range; previousParent = parent; previousRangeStartLine = rangeStart.line; - previousRangeHasError = rangeHasError; return lineAdded; } diff --git a/tests/cases/fourslash/formatOnEnterEmptyBlock.ts b/tests/cases/fourslash/formatOnEnterEmptyBlock.ts new file mode 100644 index 00000000000..fd24edf4e5f --- /dev/null +++ b/tests/cases/fourslash/formatOnEnterEmptyBlock.ts @@ -0,0 +1,16 @@ +/// + +//// if (true) { +//// } +//// if () { +//// } + +format.setOption("PlaceOpenBraceOnNewLineForControlBlocks", true); +format.document(); +verify.currentFileContentIs( +`if (true) +{ +} +if () +{ +}`); diff --git a/tests/cases/fourslash/fourslash.ts b/tests/cases/fourslash/fourslash.ts index 767701a2af6..69a1551635c 100644 --- a/tests/cases/fourslash/fourslash.ts +++ b/tests/cases/fourslash/fourslash.ts @@ -329,7 +329,7 @@ declare namespace FourSlashInterface { setFormatOptions(options: FormatCodeOptions): any; selection(startMarker: string, endMarker: string): void; onType(posMarker: string, key: string): void; - setOption(name: string, value: number | string | boolean): void; + setOption(name: keyof FormatCodeOptions, value: number | string | boolean): void; } class cancellation { resetCancelled(): void; From 0dcc8deace445bf7ac069e226025e224abccfe04 Mon Sep 17 00:00:00 2001 From: Arthur Ozga Date: Mon, 19 Jun 2017 11:13:58 -0700 Subject: [PATCH 008/370] update tests --- tests/cases/fourslash/formatEmptyParamList.ts | 2 +- tests/cases/fourslash/formattingOnConstructorSignature.ts | 4 ++-- tests/cases/fourslash/formattingSkippedTokens.ts | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/cases/fourslash/formatEmptyParamList.ts b/tests/cases/fourslash/formatEmptyParamList.ts index a5372010baa..46c5e0072bb 100644 --- a/tests/cases/fourslash/formatEmptyParamList.ts +++ b/tests/cases/fourslash/formatEmptyParamList.ts @@ -2,4 +2,4 @@ ////function f( f: function){/*1*/ goTo.marker("1"); edit.insert("}"); -verify.currentLineContentIs("function f(f: function){ }") \ No newline at end of file +verify.currentLineContentIs("function f(f: function) { }") \ No newline at end of file diff --git a/tests/cases/fourslash/formattingOnConstructorSignature.ts b/tests/cases/fourslash/formattingOnConstructorSignature.ts index 6b91396e532..209527e8257 100644 --- a/tests/cases/fourslash/formattingOnConstructorSignature.ts +++ b/tests/cases/fourslash/formattingOnConstructorSignature.ts @@ -4,6 +4,6 @@ /////*2*/type Stylet = { new () {} } format.document(); goTo.marker("1"); -verify.currentLineContentIs("interface Gourai { new() {} }"); +verify.currentLineContentIs("interface Gourai { new() { } }"); goTo.marker("2"); -verify.currentLineContentIs("type Stylet = { new() {} }"); \ No newline at end of file +verify.currentLineContentIs("type Stylet = { new() { } }"); \ No newline at end of file diff --git a/tests/cases/fourslash/formattingSkippedTokens.ts b/tests/cases/fourslash/formattingSkippedTokens.ts index d3e76e97354..caf65d1dc2f 100644 --- a/tests/cases/fourslash/formattingSkippedTokens.ts +++ b/tests/cases/fourslash/formattingSkippedTokens.ts @@ -14,7 +14,7 @@ verify.currentLineContentIs('foo(): Bar { }'); goTo.marker('2'); verify.currentLineContentIs('function Foo() # { }'); goTo.marker('3'); -verify.currentLineContentIs('4 +:5'); +verify.currentLineContentIs('4 +: 5'); goTo.marker('4'); verify.currentLineContentIs(' : T) { }'); goTo.marker('5'); From 37d4116ae0e69f31425cbd560e0fdf2ad61d10b6 Mon Sep 17 00:00:00 2001 From: Arthur Ozga Date: Mon, 19 Jun 2017 14:22:56 -0700 Subject: [PATCH 009/370] rename test --- ...tOnEnterEmptyBlock.ts => formatIfWithEmptyCondition.ts} | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) rename tests/cases/fourslash/{formatOnEnterEmptyBlock.ts => formatIfWithEmptyCondition.ts} (74%) diff --git a/tests/cases/fourslash/formatOnEnterEmptyBlock.ts b/tests/cases/fourslash/formatIfWithEmptyCondition.ts similarity index 74% rename from tests/cases/fourslash/formatOnEnterEmptyBlock.ts rename to tests/cases/fourslash/formatIfWithEmptyCondition.ts index fd24edf4e5f..6e949900e22 100644 --- a/tests/cases/fourslash/formatOnEnterEmptyBlock.ts +++ b/tests/cases/fourslash/formatIfWithEmptyCondition.ts @@ -1,16 +1,11 @@ /// -//// if (true) { -//// } //// if () { //// } format.setOption("PlaceOpenBraceOnNewLineForControlBlocks", true); format.document(); verify.currentFileContentIs( -`if (true) -{ -} -if () +`if () { }`); From 115884aa30e23b751981585f0121e29a9ebd276a Mon Sep 17 00:00:00 2001 From: Ron Buckton Date: Wed, 21 Jun 2017 18:20:46 -0700 Subject: [PATCH 010/370] Follow symbol through commonjs require for inferred class type --- src/compiler/checker.ts | 31 ++++++++--- .../reference/constructorFunctions2.symbols | 41 ++++++++++++++ .../reference/constructorFunctions2.types | 55 +++++++++++++++++++ .../salsa/constructorFunctions2.ts | 18 ++++++ 4 files changed, 136 insertions(+), 9 deletions(-) create mode 100644 tests/baselines/reference/constructorFunctions2.symbols create mode 100644 tests/baselines/reference/constructorFunctions2.types create mode 100644 tests/cases/conformance/salsa/constructorFunctions2.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 05c20ffb11a..29b0420201e 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -16073,8 +16073,8 @@ namespace ts { * Indicates whether a declaration can be treated as a constructor in a JavaScript * file. */ - function isJavaScriptConstructor(node: Declaration): boolean { - if (isInJavaScriptFile(node)) { + function isJavaScriptConstructor(node: Declaration | undefined): boolean { + if (node && isInJavaScriptFile(node)) { // If the node has a @class tag, treat it like a constructor. if (getJSDocClassTag(node)) return true; @@ -16089,6 +16089,21 @@ namespace ts { return false; } + function getJavaScriptClassType(symbol: Symbol): Type | undefined { + if (symbol && isDeclarationOfFunctionOrClassExpression(symbol)) { + symbol = getSymbolOfNode((symbol.valueDeclaration).initializer); + } + if (isJavaScriptConstructor(symbol.valueDeclaration)) { + return getInferredClassType(symbol); + } + if (symbol.flags & SymbolFlags.Variable) { + const valueType = getTypeOfSymbol(symbol); + if (valueType.symbol && !isInferredClassType(valueType) && isJavaScriptConstructor(valueType.symbol.valueDeclaration)) { + return getInferredClassType(valueType.symbol); + } + } + } + function getInferredClassType(symbol: Symbol) { const links = getSymbolLinks(symbol); if (!links.inferredClassType) { @@ -16132,16 +16147,14 @@ namespace ts { // in a JS file // Note:JS inferred classes might come from a variable declaration instead of a function declaration. // In this case, using getResolvedSymbol directly is required to avoid losing the members from the declaration. - let funcSymbol = node.expression.kind === SyntaxKind.Identifier ? + const funcSymbol = node.expression.kind === SyntaxKind.Identifier ? getResolvedSymbol(node.expression as Identifier) : checkExpression(node.expression).symbol; - if (funcSymbol && isDeclarationOfFunctionOrClassExpression(funcSymbol)) { - funcSymbol = getSymbolOfNode((funcSymbol.valueDeclaration).initializer); + const type = funcSymbol && getJavaScriptClassType(funcSymbol); + if (type) { + return type; } - if (funcSymbol && funcSymbol.flags & SymbolFlags.Function && (funcSymbol.members || getJSDocClassTag(funcSymbol.valueDeclaration))) { - return getInferredClassType(funcSymbol); - } - else if (noImplicitAny) { + if (noImplicitAny) { error(node, Diagnostics.new_expression_whose_target_lacks_a_construct_signature_implicitly_has_an_any_type); } return anyType; diff --git a/tests/baselines/reference/constructorFunctions2.symbols b/tests/baselines/reference/constructorFunctions2.symbols new file mode 100644 index 00000000000..1046aa32e9a --- /dev/null +++ b/tests/baselines/reference/constructorFunctions2.symbols @@ -0,0 +1,41 @@ +=== tests/cases/conformance/salsa/node.d.ts === +declare function require(id: string): any; +>require : Symbol(require, Decl(node.d.ts, 0, 0)) +>id : Symbol(id, Decl(node.d.ts, 0, 25)) + +declare var module: any, exports: any; +>module : Symbol(module, Decl(node.d.ts, 1, 11)) +>exports : Symbol(exports, Decl(node.d.ts, 1, 24)) + +=== tests/cases/conformance/salsa/index.js === +const A = require("./other"); +>A : Symbol(A, Decl(index.js, 0, 5)) +>require : Symbol(require, Decl(node.d.ts, 0, 0)) +>"./other" : Symbol("tests/cases/conformance/salsa/other", Decl(other.js, 0, 0)) + +const a = new A().id; +>a : Symbol(a, Decl(index.js, 1, 5)) +>new A().id : Symbol(A.id, Decl(other.js, 0, 14)) +>A : Symbol(A, Decl(index.js, 0, 5)) +>id : Symbol(A.id, Decl(other.js, 0, 14)) + +const B = function() { this.id = 1; } +>B : Symbol(B, Decl(index.js, 3, 5)) +>id : Symbol(B.id, Decl(index.js, 3, 22)) + +const b = new B().id; +>b : Symbol(b, Decl(index.js, 4, 5)) +>new B().id : Symbol(B.id, Decl(index.js, 3, 22)) +>B : Symbol(B, Decl(index.js, 3, 5)) +>id : Symbol(B.id, Decl(index.js, 3, 22)) + +=== tests/cases/conformance/salsa/other.js === +function A() { this.id = 1; } +>A : Symbol(A, Decl(other.js, 0, 0)) +>id : Symbol(A.id, Decl(other.js, 0, 14)) + +module.exports = A; +>module : Symbol(export=, Decl(other.js, 0, 29)) +>exports : Symbol(export=, Decl(other.js, 0, 29)) +>A : Symbol(A, Decl(other.js, 0, 0)) + diff --git a/tests/baselines/reference/constructorFunctions2.types b/tests/baselines/reference/constructorFunctions2.types new file mode 100644 index 00000000000..e96053b4f49 --- /dev/null +++ b/tests/baselines/reference/constructorFunctions2.types @@ -0,0 +1,55 @@ +=== tests/cases/conformance/salsa/node.d.ts === +declare function require(id: string): any; +>require : (id: string) => any +>id : string + +declare var module: any, exports: any; +>module : any +>exports : any + +=== tests/cases/conformance/salsa/index.js === +const A = require("./other"); +>A : () => void +>require("./other") : () => void +>require : (id: string) => any +>"./other" : "./other" + +const a = new A().id; +>a : number +>new A().id : number +>new A() : { id: number; } +>A : () => void +>id : number + +const B = function() { this.id = 1; } +>B : () => void +>function() { this.id = 1; } : () => void +>this.id = 1 : 1 +>this.id : any +>this : any +>id : any +>1 : 1 + +const b = new B().id; +>b : number +>new B().id : number +>new B() : { id: number; } +>B : () => void +>id : number + +=== tests/cases/conformance/salsa/other.js === +function A() { this.id = 1; } +>A : () => void +>this.id = 1 : 1 +>this.id : any +>this : any +>id : any +>1 : 1 + +module.exports = A; +>module.exports = A : () => void +>module.exports : any +>module : any +>exports : any +>A : () => void + diff --git a/tests/cases/conformance/salsa/constructorFunctions2.ts b/tests/cases/conformance/salsa/constructorFunctions2.ts new file mode 100644 index 00000000000..13a6e7b9a3a --- /dev/null +++ b/tests/cases/conformance/salsa/constructorFunctions2.ts @@ -0,0 +1,18 @@ +// @allowJs: true +// @checkJs: true +// @noEmit: true +// @module: commonjs +// @filename: node.d.ts +declare function require(id: string): any; +declare var module: any, exports: any; + +// @filename: index.js +const A = require("./other"); +const a = new A().id; + +const B = function() { this.id = 1; } +const b = new B().id; + +// @filename: other.js +function A() { this.id = 1; } +module.exports = A; \ No newline at end of file From 5272ec63091f96bf25df326267f69d5fca00a407 Mon Sep 17 00:00:00 2001 From: Ryan Cavanaugh Date: Thu, 27 Jul 2017 16:07:50 -0700 Subject: [PATCH 011/370] Types Map WIP --- Gulpfile.ts | 21 +- Jakefile.js | 16 +- .../unittests/tsserverProjectSystem.ts | 33 +- src/server/editorServices.ts | 64 ++- src/server/project.ts | 10 + src/server/server.ts | 11 +- src/server/shared.ts | 1 + src/server/typesMap.json | 487 ++++++++++++++++++ .../typingsInstaller/nodeTypingsInstaller.ts | 10 +- .../typingsInstaller/typingsInstaller.ts | 19 +- src/server/utilities.ts | 2 +- src/services/jsTyping.ts | 8 + 12 files changed, 642 insertions(+), 40 deletions(-) create mode 100644 src/server/typesMap.json diff --git a/Gulpfile.ts b/Gulpfile.ts index f6e5ed627d8..f70e8a88aab 100644 --- a/Gulpfile.ts +++ b/Gulpfile.ts @@ -464,6 +464,7 @@ gulp.task(serverFile, /*help*/ false, [servicesFile, typingsInstallerJs, cancell .pipe(gulp.dest("src/server")); }); +const typesMapJson = path.join(builtLocalDirectory, "typesMap.json"); const tsserverLibraryFile = path.join(builtLocalDirectory, "tsserverlibrary.js"); const tsserverLibraryDefinitionFile = path.join(builtLocalDirectory, "tsserverlibrary.d.ts"); @@ -473,7 +474,7 @@ gulp.task(tsserverLibraryFile, /*help*/ false, [servicesFile], (done) => { .pipe(sourcemaps.init()) .pipe(newer(tsserverLibraryFile)) .pipe(serverLibraryProject()); - + return merge2([ js.pipe(prependCopyright()) .pipe(sourcemaps.write(".")) @@ -486,7 +487,23 @@ gulp.task(tsserverLibraryFile, /*help*/ false, [servicesFile], (done) => { ]); }); -gulp.task("lssl", "Builds language service server library", [tsserverLibraryFile]); +gulp.task(typesMapJson, /*help*/ false, [], (done) => { + fs.readFile('src/server/typesMaps.json', 'utf-8', (err, data) => { + if (err) { + return done(err); + } + try { + JSON.parse(data); + } catch (e) { + done(e); + } + fs.writeFile(typesMapJson, data, err => { + done(err); + }); + }); +}); + +gulp.task("lssl", "Builds language service server library", [tsserverLibraryFile, typesMapJson]); gulp.task("local", "Builds the full compiler and services", [builtLocalCompiler, servicesFile, serverFile, builtGeneratedDiagnosticMessagesJSON, tsserverLibraryFile]); gulp.task("tsc", "Builds only the compiler", [builtLocalCompiler]); diff --git a/Jakefile.js b/Jakefile.js index 31243f77c42..0ddfeb19fbe 100644 --- a/Jakefile.js +++ b/Jakefile.js @@ -88,6 +88,8 @@ var watchGuardSources = filesFromConfig(path.join(serverDirectory, "watchGuard/t var serverSources = filesFromConfig(path.join(serverDirectory, "tsconfig.json")) var languageServiceLibrarySources = filesFromConfig(path.join(serverDirectory, "tsconfig.library.json")); +var typesMapOutputPath = path.join(builtLocalDirectory, 'typesMap.json'); + var harnessCoreSources = [ "harness.ts", "virtualFileSystem.ts", @@ -422,6 +424,7 @@ var buildProtocolTs = path.join(scriptsDirectory, "buildProtocol.ts"); var buildProtocolJs = path.join(scriptsDirectory, "buildProtocol.js"); var buildProtocolDts = path.join(builtLocalDirectory, "protocol.d.ts"); var typescriptServicesDts = path.join(builtLocalDirectory, "typescriptServices.d.ts"); +var typesMapJson = path.join(builtLocalDirectory, "typesMap.json"); file(buildProtocolTs); @@ -603,6 +606,16 @@ var serverFile = path.join(builtLocalDirectory, "tsserver.js"); compileFile(serverFile, serverSources, [builtLocalDirectory, copyright, cancellationTokenFile, typingsInstallerFile, watchGuardFile].concat(serverSources).concat(servicesSources), /*prefixes*/ [copyright], /*useBuiltCompiler*/ true, { types: ["node"], preserveConstEnums: true, lib: "es6" }); var tsserverLibraryFile = path.join(builtLocalDirectory, "tsserverlibrary.js"); var tsserverLibraryDefinitionFile = path.join(builtLocalDirectory, "tsserverlibrary.d.ts"); +file(typesMapOutputPath, function() { + var content = fs.readFileSync(path.join(serverDirectory, 'typesMap.json')); + // Validate that it's valid JSON + try { + JSON.parse(content); + } catch (e) { + console.log("Parse error in typesMap.json: " + e); + } + fs.writeFileSync(typesMapOutputPath, content); +}); compileFile( tsserverLibraryFile, languageServiceLibrarySources, @@ -625,7 +638,7 @@ compileFile( // Local target to build the language service server library desc("Builds language service server library"); -task("lssl", [tsserverLibraryFile, tsserverLibraryDefinitionFile]); +task("lssl", [tsserverLibraryFile, tsserverLibraryDefinitionFile, typesMapOutputPath]); desc("Emit the start of the build fold"); task("build-fold-start", [], function () { @@ -654,7 +667,6 @@ task("release", function () { // Set the default task to "local" task("default", ["local"]); - // Cleans the built directory desc("Cleans the compiler output, declare files, and tests"); task("clean", function () { diff --git a/src/harness/unittests/tsserverProjectSystem.ts b/src/harness/unittests/tsserverProjectSystem.ts index f11900aea11..4942a8ef53b 100644 --- a/src/harness/unittests/tsserverProjectSystem.ts +++ b/src/harness/unittests/tsserverProjectSystem.ts @@ -18,14 +18,24 @@ namespace ts.projectSystem { }) }; - const customSafeList = { - path: "/typeMapList.json", - content: JSON.stringify({ - "quack": { - "match": "/duckquack-(\\d+)\\.min\\.js", - "types": ["duck-types"] + const customTypesMap = { + path: "/typesMap.json", + content: `{ + "typesMap": { + "jquery": { + "match": "jquery(-(\\\\.?\\\\d+)+)?(\\\\.intellisense)?(\\\\.min)?\\\\.js$", + "types": ["jquery"] + }, + "quack": { + "match": "/duckquack-(\\\\d+)\\\\.min\\\\.js", + "types": ["duck-types"] + } }, - }) + "simpleMap": { + "Bacon": "baconjs", + "bliss": "blissfuljs" + } + }` }; export interface PostExecAction { @@ -59,7 +69,7 @@ namespace ts.projectSystem { installTypingHost: server.ServerHost, readonly typesRegistry = createMap(), log?: TI.Log) { - super(installTypingHost, globalTypingsCacheLocation, safeList.path, throttleLimit, log); + super(installTypingHost, globalTypingsCacheLocation, safeList.path, customTypesMap.path, throttleLimit, log); } protected postExecActions: PostExecAction[] = []; @@ -218,7 +228,7 @@ namespace ts.projectSystem { constructor(host: server.ServerHost, logger: server.Logger, cancellationToken: HostCancellationToken, useSingleInferredProject: boolean, typingsInstaller: server.ITypingsInstaller, eventHandler: server.ProjectServiceEventHandler) { super({ - host, logger, cancellationToken, useSingleInferredProject, typingsInstaller, eventHandler + host, logger, cancellationToken, useSingleInferredProject, typingsInstaller, eventHandler, typesMapLocation: customTypesMap.path }); } @@ -1479,9 +1489,8 @@ namespace ts.projectSystem { path: "/lib/duckquack-3.min.js", content: "whoa do @@ not parse me ok thanks!!!" }; - const host = createServerHost([customSafeList, file1, office]); + const host = createServerHost([file1, office, customTypesMap]); const projectService = createProjectService(host); - projectService.loadSafeList(customSafeList.path); try { projectService.openExternalProject({ projectFileName: "project", options: {}, rootFiles: toExternalFiles([file1.path, office.path]) }); const proj = projectService.externalProjects[0]; @@ -1491,7 +1500,7 @@ namespace ts.projectSystem { projectService.resetSafeList(); } }); - + it("ignores files excluded by the default type list", () => { const file1 = { path: "/a/b/f1.ts", diff --git a/src/server/editorServices.ts b/src/server/editorServices.ts index 4ffdf5d6c5d..54b393053ca 100644 --- a/src/server/editorServices.ts +++ b/src/server/editorServices.ts @@ -109,6 +109,11 @@ namespace ts.server { "smart": IndentStyle.Smart }); + export interface TypesMapFile { + typesMap: SafeList; + simpleMap: string[]; + } + /** * How to understand this block: * * The 'match' property is a regexp that matches a filename. @@ -329,6 +334,7 @@ namespace ts.server { globalPlugins?: string[]; pluginProbeLocations?: string[]; allowLocalPluginLoads?: boolean; + typesMapLocation?: string; } export class ProjectService { @@ -389,6 +395,7 @@ namespace ts.server { public readonly globalPlugins: ReadonlyArray; public readonly pluginProbeLocations: ReadonlyArray; public readonly allowLocalPluginLoads: boolean; + public readonly typesMapLocation: string | undefined; /** Tracks projects that we have already sent telemetry for. */ private readonly seenProjects = createMap(); @@ -404,6 +411,7 @@ namespace ts.server { this.globalPlugins = opts.globalPlugins || emptyArray; this.pluginProbeLocations = opts.pluginProbeLocations || emptyArray; this.allowLocalPluginLoads = !!opts.allowLocalPluginLoads; + this.typesMapLocation = (opts.typesMapLocation === undefined) ? combinePaths(this.host.getExecutingFilePath(), '../typesMap.json') : opts.typesMapLocation; Debug.assert(!!this.host.createHash, "'ServerHost.createHash' is required for ProjectService"); @@ -411,6 +419,10 @@ namespace ts.server { this.directoryWatchers = new DirectoryWatchers(this); this.throttledOperations = new ThrottledOperations(this.host); + if (opts.typesMapLocation) { + this.loadTypesMap(); + } + this.typingsInstaller.attach(this); this.typingsCache = new TypingsCache(this.typingsInstaller); @@ -447,6 +459,25 @@ namespace ts.server { }); } + private loadTypesMap() { + if (!this.host.fileExists(this.typesMapLocation)) { + this.logger.info(`Provided types map file "${this.typesMapLocation}" doesn't exist`); + return; + } + try { + const raw: TypesMapFile = JSON.parse(this.host.readFile(this.typesMapLocation)); + // Parse the regexps + for (const k of Object.keys(raw.typesMap)) { + raw.typesMap[k].match = new RegExp(raw.typesMap[k].match as {} as string, "i"); + } + // raw is now fixed and ready + this.safelist = raw.typesMap; + } catch(e) { + this.logger.info(`Error loading types map: ${e}`); + this.safelist = defaultTypeSafeList; + } + } + updateTypingsForProject(response: SetTypings | InvalidateCachedTypings): void { const project = this.findProject(response.projectName); if (!project) { @@ -1623,23 +1654,14 @@ namespace ts.server { this.safelist = defaultTypeSafeList; } - loadSafeList(fileName: string): void { - const raw: SafeList = JSON.parse(this.host.readFile(fileName, "utf-8")); - // Parse the regexps - for (const k of Object.keys(raw)) { - raw[k].match = new RegExp(raw[k].match as {} as string, "i"); - } - // raw is now fixed and ready - this.safelist = raw; - } - - applySafeList(proj: protocol.ExternalProject): void { + applySafeList(proj: protocol.ExternalProject): NormalizedPath[] { const { rootFiles, typeAcquisition } = proj; const types = (typeAcquisition && typeAcquisition.include) || []; const excludeRules: string[] = []; - const normalizedNames = rootFiles.map(f => normalizeSlashes(f.fileName)); + const normalizedNames = rootFiles.map(f => normalizeSlashes(f.fileName)) as NormalizedPath[]; + const excludedFiles: NormalizedPath[] = []; for (const name of Object.keys(this.safelist)) { const rule = this.safelist[name]; @@ -1698,7 +1720,17 @@ namespace ts.server { } const excludeRegexes = excludeRules.map(e => new RegExp(e, "i")); - proj.rootFiles = proj.rootFiles.filter((_file, index) => !excludeRegexes.some(re => re.test(normalizedNames[index]))); + const filesToKeep: ts.server.protocol.ExternalFile[] = []; + for(let i = 0; i < proj.rootFiles.length; i++) { + if (excludeRegexes.some(re => re.test(normalizedNames[i]))) { + excludedFiles.push(normalizedNames[i]); + } + else { + filesToKeep.push(proj.rootFiles[i]); + } + } + proj.rootFiles = filesToKeep; + return excludedFiles; } openExternalProject(proj: protocol.ExternalProject, suppressRefreshOfInferredProjects = false): void { @@ -1709,7 +1741,7 @@ namespace ts.server { proj.typeAcquisition = typeAcquisition; } - this.applySafeList(proj); + const excludedFiles = this.applySafeList(proj); let tsConfigFiles: NormalizedPath[]; const rootFiles: protocol.ExternalFile[] = []; @@ -1733,6 +1765,7 @@ namespace ts.server { const externalProject = this.findExternalProjectByProjectName(proj.projectFileName); let exisingConfigFiles: string[]; if (externalProject) { + externalProject.excludedFiles = excludedFiles; if (!tsConfigFiles) { const compilerOptions = convertCompilerOptions(proj.options); if (this.exceededTotalSizeLimitForNonTsFiles(proj.projectFileName, compilerOptions, proj.rootFiles, externalFilePropertyReader)) { @@ -1802,7 +1835,8 @@ namespace ts.server { else { // no config files - remove the item from the collection this.externalProjectToConfiguredProjectMap.delete(proj.projectFileName); - this.createAndAddExternalProject(proj.projectFileName, rootFiles, proj.options, proj.typeAcquisition); + const newProj = this.createAndAddExternalProject(proj.projectFileName, rootFiles, proj.options, proj.typeAcquisition); + newProj.excludedFiles = excludedFiles; } if (!suppressRefreshOfInferredProjects) { this.refreshInferredProjects(); diff --git a/src/server/project.ts b/src/server/project.ts index 106089fad97..6686f4c1a83 100644 --- a/src/server/project.ts +++ b/src/server/project.ts @@ -375,6 +375,10 @@ namespace ts.server { return this.getLanguageService().getEmitOutput(info.fileName, emitOnlyDtsFiles); } + getExcludedFiles(): ReadonlyArray { + return emptyArray; + } + getFileNames(excludeFilesFromExternalLibraries?: boolean, excludeConfigFiles?: boolean) { if (!this.program) { return []; @@ -1161,6 +1165,7 @@ namespace ts.server { * These are created only if a host explicitly calls `openExternalProject`. */ export class ExternalProject extends Project { + excludedFiles: ReadonlyArray = []; private typeAcquisition: TypeAcquisition; constructor(public externalProjectName: string, projectService: ProjectService, @@ -1170,6 +1175,11 @@ namespace ts.server { public compileOnSaveEnabled: boolean, private readonly projectFilePath?: string) { super(externalProjectName, ProjectKind.External, projectService, documentRegistry, /*hasExplicitListOfFiles*/ true, languageServiceEnabled, compilerOptions, compileOnSaveEnabled); + + } + + getExcludedFiles() { + return this.excludedFiles; } getProjectRootPath() { diff --git a/src/server/server.ts b/src/server/server.ts index 6600b63dcb1..06e2a6482d7 100644 --- a/src/server/server.ts +++ b/src/server/server.ts @@ -13,6 +13,7 @@ namespace ts.server { globalTypingsCacheLocation: string; logger: Logger; typingSafeListLocation: string; + typesMapLocation: string | undefined; npmLocation: string | undefined; telemetryEnabled: boolean; globalPlugins: string[]; @@ -243,6 +244,7 @@ namespace ts.server { eventPort: number, readonly globalTypingsCacheLocation: string, readonly typingSafeListLocation: string, + readonly typesMapLocation: string, private readonly npmLocation: string | undefined, private newLine: string) { this.throttledOperations = new ThrottledOperations(host); @@ -288,6 +290,9 @@ namespace ts.server { if (this.typingSafeListLocation) { args.push(Arguments.TypingSafeListLocation, this.typingSafeListLocation); } + if (this.typesMapLocation) { + args.push(Arguments.TypesMapLocation, this.typesMapLocation); + } if (this.npmLocation) { args.push(Arguments.NpmLocation, this.npmLocation); } @@ -401,10 +406,10 @@ namespace ts.server { class IOSession extends Session { constructor(options: IOSessionOptions) { - const { host, installerEventPort, globalTypingsCacheLocation, typingSafeListLocation, npmLocation, canUseEvents } = options; + const { host, installerEventPort, globalTypingsCacheLocation, typingSafeListLocation, typesMapLocation, npmLocation, canUseEvents } = options; const typingsInstaller = disableAutomaticTypingAcquisition ? undefined - : new NodeTypingsInstaller(telemetryEnabled, logger, host, installerEventPort, globalTypingsCacheLocation, typingSafeListLocation, npmLocation, host.newLine); + : new NodeTypingsInstaller(telemetryEnabled, logger, host, installerEventPort, globalTypingsCacheLocation, typingSafeListLocation, typesMapLocation, npmLocation, host.newLine); super({ host, @@ -758,6 +763,7 @@ namespace ts.server { } const typingSafeListLocation = findArgument(Arguments.TypingSafeListLocation); + const typesMapLocation = findArgument(Arguments.TypesMapLocation) || combinePaths(sys.getExecutingFilePath(), '../typesMap.json'); const npmLocation = findArgument(Arguments.NpmLocation); const globalPlugins = (findArgument("--globalPlugins") || "").split(","); @@ -777,6 +783,7 @@ namespace ts.server { disableAutomaticTypingAcquisition, globalTypingsCacheLocation: getGlobalTypingsCacheLocation(), typingSafeListLocation, + typesMapLocation, npmLocation, telemetryEnabled, logger, diff --git a/src/server/shared.ts b/src/server/shared.ts index 1285eba06e1..66f739a5b97 100644 --- a/src/server/shared.ts +++ b/src/server/shared.ts @@ -12,6 +12,7 @@ namespace ts.server { export const LogFile = "--logFile"; export const EnableTelemetry = "--enableTelemetry"; export const TypingSafeListLocation = "--typingSafeListLocation"; + export const TypesMapLocation = "--typesMapLocation"; /** * This argument specifies the location of the NPM executable. * typingsInstaller will run the command with `${npmLocation} install ...`. diff --git a/src/server/typesMap.json b/src/server/typesMap.json new file mode 100644 index 00000000000..5e7df046dbe --- /dev/null +++ b/src/server/typesMap.json @@ -0,0 +1,487 @@ +{ + "typesMap": { + "jquery": { + "match": "jquery(-(\\.?\\d+)+)?(\\.intellisense)?(\\.min)?\\.js$", + "types": ["jquery"] + }, + "WinJS": { + "match": "^(.*\\/winjs-[.\\d]+)\\/js\\/base\\.js$", + "exclude": [["^", 1, "/.*"]], + "types": ["winjs"] + }, + "Kendo": { + "match": "^(.*\\/kendo)\\/kendo\\.all\\.min\\.js$", + "exclude": [["^", 1, "/.*"]], + "types": ["kendo-ui"] + }, + "Office Nuget": { + "match": "^(.*\\/office\\/1)\\/excel-\\d+\\.debug\\.js$", + "exclude": [["^", 1, "/.*"]], + "types": ["office"] + }, + "Minified files": { + "match": "^(.+\\.min\\.js)$", + "exclude": [["^", 1, "$"]] + } + }, + "simpleMap": { + "accounting": "accounting", + "ace.js": "ace", + "ag-grid": "ag-grid", + "alertify": "alertify", + "alt": "alt", + "amcharts.js": "amcharts", + "amplify": "amplifyjs", + "angular": "angular", + "angular-bootstrap-lightbox": "angular-bootstrap-lightbox", + "angular-cookie": "angular-cookie", + "angular-file-upload": "angular-file-upload", + "angularfire": "angularfire", + "angular-gettext": "angular-gettext", + "angular-google-analytics": "angular-google-analytics", + "angular-local-storage": "angular-local-storage", + "angularLocalStorage": "angularLocalStorage", + "angular-scroll": "angular-scroll", + "angular-spinner": "angular-spinner", + "angular-strap": "angular-strap", + "angulartics": "angulartics", + "angular-toastr": "angular-toastr", + "angular-translate": "angular-translate", + "angular-ui-router": "angular-ui-router", + "angular-ui-tree": "angular-ui-tree", + "angular-wizard": "angular-wizard", + "async": "async", + "atmosphere": "atmosphere", + "aws-sdk": "aws-sdk", + "aws-sdk-js": "aws-sdk", + "axios": "axios", + "backbone": "backbone", + "backbone.layoutmanager": "backbone.layoutmanager", + "backbone.paginator": "backbone.paginator", + "backbone.radio": "backbone.radio", + "backbone-associations": "backbone-associations", + "backbone-relational": "backbone-relational", + "backgrid": "backgrid", + "Bacon": "baconjs", + "benchmark": "benchmark", + "blazy": "blazy", + "bliss": "blissfuljs", + "bluebird": "bluebird", + "body-parser": "body-parser", + "bootbox": "bootbox", + "bootstrap": "bootstrap", + "bootstrap-editable": "x-editable", + "bootstrap-maxlength": "bootstrap-maxlength", + "bootstrap-notify": "bootstrap-notify", + "bootstrap-slider": "bootstrap-slider", + "bootstrap-switch": "bootstrap-switch", + "bowser": "bowser", + "breeze": "breeze", + "browserify": "browserify", + "bson": "bson", + "c3": "c3", + "canvasjs": "canvasjs", + "chai": "chai", + "chalk": "chalk", + "chance": "chance", + "chartist": "chartist", + "cheerio": "cheerio", + "chokidar": "chokidar", + "chosen.jquery": "chosen", + "chroma": "chroma-js", + "ckeditor.js": "ckeditor", + "cli-color": "cli-color", + "clipboard": "clipboard", + "codemirror": "codemirror", + "colors": "colors", + "commander": "commander", + "commonmark": "commonmark", + "compression": "compression", + "confidence": "confidence", + "connect": "connect", + "Control.FullScreen": "leaflet.fullscreen", + "cookie": "cookie", + "cookie-parser": "cookie-parser", + "cookies": "cookies", + "core": "core-js", + "core-js": "core-js", + "crossfilter": "crossfilter", + "crossroads": "crossroads", + "css": "css", + "ct-ui-router-extras": "ui-router-extras", + "d3": "d3", + "dagre-d3": "dagre-d3", + "dat.gui": "dat-gui", + "debug": "debug", + "deep-diff": "deep-diff", + "Dexie": "dexie", + "dialogs": "angular-dialog-service", + "dojo.js": "dojo", + "doT": "dot", + "dragula": "dragula", + "drop": "drop", + "dropbox": "dropboxjs", + "dropzone": "dropzone", + "Dts Name": "Dts Name", + "dust-core": "dustjs-linkedin", + "easeljs": "easeljs", + "ejs": "ejs", + "ember": "ember", + "envify": "envify", + "epiceditor": "epiceditor", + "es6-promise": "es6-promise", + "ES6-Promise": "es6-promise", + "es6-shim": "es6-shim", + "expect": "expect", + "express": "express", + "express-session": "express-session", + "ext-all.js": "extjs", + "extend": "extend", + "fabric": "fabricjs", + "faker": "faker", + "fastclick": "fastclick", + "favico": "favico.js", + "featherlight": "featherlight", + "FileSaver": "FileSaver", + "fingerprint": "fingerprintjs", + "fixed-data-table": "fixed-data-table", + "flickity.pkgd": "flickity", + "flight": "flight", + "flow": "flowjs", + "Flux": "flux", + "formly": "angular-formly", + "foundation": "foundation", + "fpsmeter": "fpsmeter", + "fuse": "fuse", + "generator": "yeoman-generator", + "gl-matrix": "gl-matrix", + "globalize": "globalize", + "graceful-fs": "graceful-fs", + "gridstack": "gridstack", + "gulp": "gulp", + "gulp-rename": "gulp-rename", + "gulp-uglify": "gulp-uglify", + "gulp-util": "gulp-util", + "hammer": "hammerjs", + "handlebars": "handlebars", + "hasher": "hasher", + "he": "he", + "hello.all": "hellojs", + "highcharts.js": "highcharts", + "highlight": "highlightjs", + "history": "history", + "History": "history", + "hopscotch": "hopscotch", + "hotkeys": "angular-hotkeys", + "html2canvas": "html2canvas", + "humane": "humane", + "i18next": "i18next", + "icheck": "icheck", + "impress": "impress", + "incremental-dom": "incremental-dom", + "Inquirer": "inquirer", + "insight": "insight", + "interact": "interactjs", + "intercom": "intercomjs", + "intro": "intro.js", + "ion.rangeSlider": "ion.rangeSlider", + "ionic": "ionic", + "is": "is_js", + "iscroll": "iscroll", + "jade": "jade", + "jasmine": "jasmine", + "joint": "jointjs", + "jquery": "jquery", + "jquery.address": "jquery.address", + "jquery.are-you-sure": "jquery.are-you-sure", + "jquery.blockUI": "jquery.blockUI", + "jquery.bootstrap.wizard": "jquery.bootstrap.wizard", + "jquery.bootstrap-touchspin": "bootstrap-touchspin", + "jquery.color": "jquery.color", + "jquery.colorbox": "jquery.colorbox", + "jquery.contextMenu": "jquery.contextMenu", + "jquery.cookie": "jquery.cookie", + "jquery.customSelect": "jquery.customSelect", + "jquery.cycle.all": "jquery.cycle", + "jquery.cycle2": "jquery.cycle2", + "jquery.dataTables": "jquery.dataTables", + "jquery.dropotron": "jquery.dropotron", + "jquery.fancybox.pack.js": "fancybox", + "jquery.fancytree-all": "jquery.fancytree", + "jquery.fileupload": "jquery.fileupload", + "jquery.flot": "flot", + "jquery.form": "jquery.form", + "jquery.gridster": "jquery.gridster", + "jquery.handsontable.full": "jquery-handsontable", + "jquery.joyride": "jquery.joyride", + "jquery.jqGrid": "jqgrid", + "jquery.mmenu": "jquery.mmenu", + "jquery.mockjax": "jquery-mockjax", + "jquery.noty": "jquery.noty", + "jquery.payment": "jquery.payment", + "jquery.pjax": "jquery.pjax", + "jquery.placeholder": "jquery.placeholder", + "jquery.qrcode": "jquery.qrcode", + "jquery.qtip": "qtip2", + "jquery.raty": "raty", + "jquery.scrollTo": "jquery.scrollTo", + "jquery.signalR": "signalr", + "jquery.simplemodal": "jquery.simplemodal", + "jquery.timeago": "jquery.timeago", + "jquery.tinyscrollbar": "jquery.tinyscrollbar", + "jquery.tipsy": "jquery.tipsy", + "jquery.tooltipster": "tooltipster", + "jquery.transit": "jquery.transit", + "jquery.uniform": "jquery.uniform", + "jquery.watch": "watch", + "jquery-sortable": "jquery-sortable", + "jquery-ui": "jqueryui", + "js.cookie": "js-cookie", + "js-data": "js-data", + "js-data-angular": "js-data-angular", + "js-data-http": "js-data-http", + "jsdom": "jsdom", + "jsnlog": "jsnlog", + "json5": "json5", + "jspdf": "jspdf", + "jsrender": "jsrender", + "js-signals": "js-signals", + "jstorage": "jstorage", + "jstree": "jstree", + "js-yaml": "js-yaml", + "jszip": "jszip", + "katex": "katex", + "kefir": "kefir", + "keymaster": "keymaster", + "keypress": "keypress", + "kinetic": "kineticjs", + "knockback": "knockback", + "knockout": "knockout", + "knockout.mapping": "knockout.mapping", + "knockout.validation": "knockout.validation", + "knockout-paging": "knockout-paging", + "knockout-pre-rendered": "knockout-pre-rendered", + "ladda": "ladda", + "later": "later", + "lazy": "lazy.js", + "Leaflet.Editable": "leaflet-editable", + "leaflet.js": "leaflet", + "less": "less", + "linq": "linq", + "loading-bar": "angular-loading-bar", + "lodash": "lodash", + "log4javascript": "log4javascript", + "loglevel": "loglevel", + "lokijs": "lokijs", + "lovefield": "lovefield", + "lunr": "lunr", + "lz-string": "lz-string", + "mailcheck": "mailcheck", + "maquette": "maquette", + "marked": "marked", + "math": "mathjs", + "MathJax.js": "mathjax", + "matter": "matter-js", + "md5": "blueimp-md5", + "md5.js": "crypto-js", + "messenger": "messenger", + "method-override": "method-override", + "minimatch": "minimatch", + "minimist": "minimist", + "mithril": "mithril", + "mobile-detect": "mobile-detect", + "mocha": "mocha", + "mock-ajax": "jasmine-ajax", + "modernizr": "modernizr", + "Modernizr": "Modernizr", + "moment": "moment", + "moment-range": "moment-range", + "moment-timezone": "moment-timezone", + "mongoose": "mongoose", + "morgan": "morgan", + "mousetrap": "mousetrap", + "ms": "ms", + "mustache": "mustache", + "native.history": "history", + "nconf": "nconf", + "ncp": "ncp", + "nedb": "nedb", + "ng-cordova": "ng-cordova", + "ngDialog": "ng-dialog", + "ng-flow-standalone": "ng-flow", + "ng-grid": "ng-grid", + "ng-i18next": "ng-i18next", + "ng-table": "ng-table", + "node_redis": "redis", + "node-clone": "clone", + "node-fs-extra": "fs-extra", + "node-glob": "glob", + "Nodemailer": "nodemailer", + "node-mime": "mime", + "node-mkdirp": "mkdirp", + "node-mongodb-native": "mongodb", + "node-mysql": "mysql", + "node-open": "open", + "node-optimist": "optimist", + "node-progress": "progress", + "node-semver": "semver", + "node-tar": "tar", + "node-uuid": "node-uuid", + "node-xml2js": "xml2js", + "nopt": "nopt", + "notify": "notify", + "nouislider": "nouislider", + "npm": "npm", + "nprogress": "nprogress", + "numbro": "numbro", + "numeral": "numeraljs", + "nunjucks": "nunjucks", + "nv.d3": "nvd3", + "object-assign": "object-assign", + "oboe-browser": "oboe", + "office": "office-js", + "offline": "offline-js", + "onsenui": "onsenui", + "OpenLayers.js": "openlayers", + "openpgp": "openpgp", + "p2": "p2", + "packery.pkgd": "packery", + "page": "page", + "pako": "pako", + "papaparse": "papaparse", + "passport": "passport", + "passport-local": "passport-local", + "path": "pathjs", + "peer": "peerjs", + "peg": "pegjs", + "photoswipe": "photoswipe", + "picker.js": "pickadate", + "pikaday": "pikaday", + "pixi": "pixi.js", + "platform": "platform", + "Please": "pleasejs", + "plottable": "plottable", + "polymer": "polymer", + "postal": "postal", + "preloadjs": "preloadjs", + "progress": "progress", + "purify": "dompurify", + "purl": "purl", + "q": "q", + "qs": "qs", + "qunit": "qunit", + "ractive": "ractive", + "rangy-core": "rangy", + "raphael": "raphael", + "raven": "ravenjs", + "react": "react", + "react-bootstrap": "react-bootstrap", + "react-intl": "react-intl", + "react-redux": "react-redux", + "ReactRouter": "react-router", + "ready": "domready", + "redux": "redux", + "request": "request", + "require": "require", + "restangular": "restangular", + "reveal": "reveal", + "rickshaw": "rickshaw", + "rimraf": "rimraf", + "rivets": "rivets", + "rx": "rx", + "rx.angular": "rx-angular", + "sammy": "sammyjs", + "SAT": "sat", + "sax-js": "sax", + "screenfull": "screenfull", + "seedrandom": "seedrandom", + "select2": "select2", + "selectize": "selectize", + "serve-favicon": "serve-favicon", + "serve-static": "serve-static", + "shelljs": "shelljs", + "should": "should", + "showdown": "showdown", + "sigma": "sigmajs", + "signature_pad": "signature_pad", + "sinon": "sinon", + "sjcl": "sjcl", + "slick": "slick-carousel", + "smoothie": "smoothie", + "socket.io": "socket.io", + "socket.io-client": "socket.io-client", + "sockjs": "sockjs-client", + "sortable": "angular-ui-sortable", + "soundjs": "soundjs", + "source-map": "source-map", + "spectrum": "spectrum", + "spin": "spin", + "sprintf": "sprintf", + "stampit": "stampit", + "state-machine": "state-machine", + "Stats": "stats", + "store": "storejs", + "string": "string", + "string_score": "string_score", + "strophe": "strophe", + "stylus": "stylus", + "sugar": "sugar", + "superagent": "superagent", + "svg": "svgjs", + "svg-injector": "svg-injector", + "swfobject": "swfobject", + "swig": "swig", + "swipe": "swipe", + "swiper": "swiper", + "system.js": "systemjs", + "tether": "tether", + "three": "threejs", + "through": "through", + "through2": "through2", + "timeline": "timelinejs", + "tinycolor": "tinycolor", + "tmhDynamicLocale": "angular-dynamic-locale", + "toaster": "angularjs-toaster", + "toastr": "toastr", + "tracking": "tracking", + "trunk8": "trunk8", + "turf": "turf", + "tweenjs": "tweenjs", + "TweenMax": "gsap", + "twig": "twig", + "twix": "twix", + "typeahead.bundle": "typeahead", + "typescript": "typescript", + "ui": "winjs", + "ui-bootstrap-tpls": "angular-ui-bootstrap", + "ui-grid": "ui-grid", + "uikit": "uikit", + "underscore": "underscore", + "underscore.string": "underscore.string", + "update-notifier": "update-notifier", + "url": "jsurl", + "UUID": "uuid", + "validator": "validator", + "vega": "vega", + "vex": "vex-js", + "video": "videojs", + "vue": "vue", + "vue-router": "vue-router", + "webtorrent": "webtorrent", + "when": "when", + "winston": "winston", + "wrench-js": "wrench", + "ws": "ws", + "xlsx": "xlsx", + "xml2json": "x2js", + "xmlbuilder-js": "xmlbuilder", + "xregexp": "xregexp", + "yargs": "yargs", + "yosay": "yosay", + "yui": "yui", + "yui3": "yui", + "zepto": "zepto", + "ZeroClipboard": "zeroclipboard", + "ZSchema-browser": "z-schema" + } +} \ No newline at end of file diff --git a/src/server/typingsInstaller/nodeTypingsInstaller.ts b/src/server/typingsInstaller/nodeTypingsInstaller.ts index de23b2649a6..e7987a767e0 100644 --- a/src/server/typingsInstaller/nodeTypingsInstaller.ts +++ b/src/server/typingsInstaller/nodeTypingsInstaller.ts @@ -17,10 +17,10 @@ namespace ts.server.typingsInstaller { constructor(private readonly logFile?: string) { } - isEnabled() { + isEnabled = () => { return this.logEnabled && this.logFile !== undefined; } - writeLine(text: string) { + writeLine = (text: string) => { try { fs.appendFileSync(this.logFile, text + sys.newLine); } @@ -77,11 +77,12 @@ namespace ts.server.typingsInstaller { private delayedInitializationError: InitializationFailedResponse; - constructor(globalTypingsCacheLocation: string, typingSafeListLocation: string, npmLocation: string | undefined, throttleLimit: number, log: Log) { + constructor(globalTypingsCacheLocation: string, typingSafeListLocation: string, typesMapLocation: string, npmLocation: string | undefined, throttleLimit: number, log: Log) { super( sys, globalTypingsCacheLocation, typingSafeListLocation ? toPath(typingSafeListLocation, "", createGetCanonicalFileName(sys.useCaseSensitiveFileNames)) : toPath("typingSafeList.json", __dirname, createGetCanonicalFileName(sys.useCaseSensitiveFileNames)), + typesMapLocation ? toPath(typesMapLocation, "", createGetCanonicalFileName(sys.useCaseSensitiveFileNames)) : toPath("typesMap.json", __dirname, createGetCanonicalFileName(sys.useCaseSensitiveFileNames)), throttleLimit, log); this.npmPath = npmLocation !== undefined ? npmLocation : getDefaultNPMLocation(process.argv[0]); @@ -175,6 +176,7 @@ namespace ts.server.typingsInstaller { const logFilePath = findArgument(server.Arguments.LogFile); const globalTypingsCacheLocation = findArgument(server.Arguments.GlobalCacheLocation); const typingSafeListLocation = findArgument(server.Arguments.TypingSafeListLocation); + const typesMapLocation = findArgument(server.Arguments.TypesMapLocation); const npmLocation = findArgument(server.Arguments.NpmLocation); const log = new FileLog(logFilePath); @@ -189,6 +191,6 @@ namespace ts.server.typingsInstaller { } process.exit(0); }); - const installer = new NodeTypingsInstaller(globalTypingsCacheLocation, typingSafeListLocation, npmLocation, /*throttleLimit*/5, log); + const installer = new NodeTypingsInstaller(globalTypingsCacheLocation, typingSafeListLocation, typesMapLocation, npmLocation, /*throttleLimit*/5, log); installer.listen(); } diff --git a/src/server/typingsInstaller/typingsInstaller.ts b/src/server/typingsInstaller/typingsInstaller.ts index 8a3840fd984..4624a8cc33a 100644 --- a/src/server/typingsInstaller/typingsInstaller.ts +++ b/src/server/typingsInstaller/typingsInstaller.ts @@ -97,10 +97,11 @@ namespace ts.server.typingsInstaller { protected readonly installTypingHost: InstallTypingHost, private readonly globalCachePath: string, private readonly safeListPath: Path, + private readonly typesMapLocation: Path, private readonly throttleLimit: number, protected readonly log = nullLog) { if (this.log.isEnabled()) { - this.log.writeLine(`Global cache location '${globalCachePath}', safe file path '${safeListPath}'`); + this.log.writeLine(`Global cache location '${globalCachePath}', safe file path '${safeListPath}', types map path ${typesMapLocation}`); } this.processCacheLocation(this.globalCachePath); } @@ -145,7 +146,7 @@ namespace ts.server.typingsInstaller { } if (this.safeList === undefined) { - this.safeList = JsTyping.loadSafeList(this.installTypingHost, this.safeListPath); + this.initializeSafeList(); } const discoverTypingsResult = JsTyping.discoverTypings( this.installTypingHost, @@ -178,6 +179,20 @@ namespace ts.server.typingsInstaller { } } + private initializeSafeList() { + // Prefer the safe list from the types map if it exists + if (this.typesMapLocation) { + const safeListFromMap = JsTyping.loadTypesMap(this.installTypingHost, this.typesMapLocation); + if (safeListFromMap) { + this.log.writeLine(`Loaded safelist from types map file '${this.typesMapLocation}'`); + this.safeList = safeListFromMap; + return; + } + this.log.writeLine(`Failed to load safelist from types map file '${this.typesMapLocation}'`); + } + this.safeList = JsTyping.loadSafeList(this.installTypingHost, this.safeListPath); + } + private processCacheLocation(cacheLocation: string) { if (this.log.isEnabled()) { this.log.writeLine(`Processing cache location '${cacheLocation}'`); diff --git a/src/server/utilities.ts b/src/server/utilities.ts index 174bcc17dfc..4d237bf5ded 100644 --- a/src/server/utilities.ts +++ b/src/server/utilities.ts @@ -49,7 +49,7 @@ namespace ts.server { export function createInstallTypingsRequest(project: Project, typeAcquisition: TypeAcquisition, unresolvedImports: SortedReadonlyArray, cachePath?: string): DiscoverTypings { return { projectName: project.getProjectName(), - fileNames: project.getFileNames(/*excludeFilesFromExternalLibraries*/ true, /*excludeConfigFiles*/ true), + fileNames: project.getFileNames(/*excludeFilesFromExternalLibraries*/ true, /*excludeConfigFiles*/ true).concat(project.getExcludedFiles() as NormalizedPath[]), compilerOptions: project.getCompilerOptions(), typeAcquisition, unresolvedImports, diff --git a/src/services/jsTyping.ts b/src/services/jsTyping.ts index 84f2ef5ba9a..6421cb932cd 100644 --- a/src/services/jsTyping.ts +++ b/src/services/jsTyping.ts @@ -46,6 +46,14 @@ namespace ts.JsTyping { return createMapFromTemplate(result.config); } + export function loadTypesMap(host: TypingResolutionHost, typesMapPath: Path): SafeList | undefined { + const result = readConfigFile(typesMapPath, path => host.readFile(path)); + if (result.config) { + return createMapFromTemplate(result.config.simpleMap); + } + return undefined; + } + /** * @param host is the object providing I/O related operations. * @param fileNames are the file names that belong to the same project From f2a801e49c81303f0b002724027f25f3da7d63b8 Mon Sep 17 00:00:00 2001 From: Ryan Cavanaugh Date: Thu, 27 Jul 2017 16:22:10 -0700 Subject: [PATCH 012/370] Add gulpfile support --- Gulpfile.ts | 25 +++++++++---------------- 1 file changed, 9 insertions(+), 16 deletions(-) diff --git a/Gulpfile.ts b/Gulpfile.ts index f70e8a88aab..abc71380d2f 100644 --- a/Gulpfile.ts +++ b/Gulpfile.ts @@ -468,7 +468,7 @@ const typesMapJson = path.join(builtLocalDirectory, "typesMap.json"); const tsserverLibraryFile = path.join(builtLocalDirectory, "tsserverlibrary.js"); const tsserverLibraryDefinitionFile = path.join(builtLocalDirectory, "tsserverlibrary.d.ts"); -gulp.task(tsserverLibraryFile, /*help*/ false, [servicesFile], (done) => { +gulp.task(tsserverLibraryFile, /*help*/ false, [servicesFile, typesMapJson], (done) => { const serverLibraryProject = tsc.createProject("src/server/tsconfig.library.json", getCompilerSettings({}, /*useBuiltCompiler*/ true)); const {js, dts}: { js: NodeJS.ReadableStream, dts: NodeJS.ReadableStream } = serverLibraryProject.src() .pipe(sourcemaps.init()) @@ -487,23 +487,16 @@ gulp.task(tsserverLibraryFile, /*help*/ false, [servicesFile], (done) => { ]); }); -gulp.task(typesMapJson, /*help*/ false, [], (done) => { - fs.readFile('src/server/typesMaps.json', 'utf-8', (err, data) => { - if (err) { - return done(err); - } - try { - JSON.parse(data); - } catch (e) { - done(e); - } - fs.writeFile(typesMapJson, data, err => { - done(err); - }); - }); +gulp.task(typesMapJson, /*help*/ false, [], () => { + return gulp.src('src/server/typesMap.json') + .pipe(insert.transform((contents, file) => { + JSON.parse(contents); + return contents; + })) + .pipe(gulp.dest(builtLocalDirectory)); }); -gulp.task("lssl", "Builds language service server library", [tsserverLibraryFile, typesMapJson]); +gulp.task("lssl", "Builds language service server library", [tsserverLibraryFile]); gulp.task("local", "Builds the full compiler and services", [builtLocalCompiler, servicesFile, serverFile, builtGeneratedDiagnosticMessagesJSON, tsserverLibraryFile]); gulp.task("tsc", "Builds only the compiler", [builtLocalCompiler]); From 253cde49077de5c67f5371dab5a2710428ef9c90 Mon Sep 17 00:00:00 2001 From: Ryan Cavanaugh Date: Thu, 27 Jul 2017 16:59:31 -0700 Subject: [PATCH 013/370] Fix tests --- Gulpfile.ts | 4 ++-- package.json | 3 +++ src/harness/unittests/tsserverProjectSystem.ts | 15 ++++++++------- src/harness/unittests/typingsInstaller.ts | 9 +++++---- src/server/editorServices.ts | 7 ++++--- src/server/server.ts | 2 +- 6 files changed, 23 insertions(+), 17 deletions(-) diff --git a/Gulpfile.ts b/Gulpfile.ts index abc71380d2f..a28408c4614 100644 --- a/Gulpfile.ts +++ b/Gulpfile.ts @@ -474,7 +474,7 @@ gulp.task(tsserverLibraryFile, /*help*/ false, [servicesFile, typesMapJson], (do .pipe(sourcemaps.init()) .pipe(newer(tsserverLibraryFile)) .pipe(serverLibraryProject()); - + return merge2([ js.pipe(prependCopyright()) .pipe(sourcemaps.write(".")) @@ -488,7 +488,7 @@ gulp.task(tsserverLibraryFile, /*help*/ false, [servicesFile, typesMapJson], (do }); gulp.task(typesMapJson, /*help*/ false, [], () => { - return gulp.src('src/server/typesMap.json') + return gulp.src("src/server/typesMap.json") .pipe(insert.transform((contents, file) => { JSON.parse(contents); return contents; diff --git a/package.json b/package.json index 5a3bc7ad58c..94d5f54a64a 100644 --- a/package.json +++ b/package.json @@ -95,5 +95,8 @@ "fs": false, "os": false, "path": false + }, + "dependencies": { + "browser-resolve": "^1.11.2" } } diff --git a/src/harness/unittests/tsserverProjectSystem.ts b/src/harness/unittests/tsserverProjectSystem.ts index 4942a8ef53b..a6d669b3681 100644 --- a/src/harness/unittests/tsserverProjectSystem.ts +++ b/src/harness/unittests/tsserverProjectSystem.ts @@ -18,7 +18,7 @@ namespace ts.projectSystem { }) }; - const customTypesMap = { + export const customTypesMap = { path: "/typesMap.json", content: `{ "typesMap": { @@ -33,7 +33,11 @@ namespace ts.projectSystem { }, "simpleMap": { "Bacon": "baconjs", - "bliss": "blissfuljs" + "bliss": "blissfuljs", + "commander": "commander", + "cordova": "cordova", + "react": "react", + "lodash": "lodash" } }` }; @@ -297,10 +301,7 @@ namespace ts.projectSystem { } export function checkFileNames(caption: string, actualFileNames: string[], expectedFileNames: string[]) { - assert.equal(actualFileNames.length, expectedFileNames.length, `${caption}: incorrect actual number of files, expected ${JSON.stringify(expectedFileNames)}, got ${actualFileNames}`); - for (const f of expectedFileNames) { - assert.isTrue(contains(actualFileNames, f), `${caption}: expected to find ${f} in ${JSON.stringify(actualFileNames)}`); - } + assert.sameMembers(actualFileNames, expectedFileNames, caption); } export function checkNumberOfConfiguredProjects(projectService: server.ProjectService, expected: number) { @@ -1500,7 +1501,7 @@ namespace ts.projectSystem { projectService.resetSafeList(); } }); - + it("ignores files excluded by the default type list", () => { const file1 = { path: "/a/b/f1.ts", diff --git a/src/harness/unittests/typingsInstaller.ts b/src/harness/unittests/typingsInstaller.ts index a0a770ad093..7285dadb0a6 100644 --- a/src/harness/unittests/typingsInstaller.ts +++ b/src/harness/unittests/typingsInstaller.ts @@ -322,7 +322,7 @@ namespace ts.projectSystem { content: "declare const lodash: { x: number }" }; - const host = createServerHost([file1, file2, file3]); + const host = createServerHost([file1, file2, file3, customTypesMap]); const installer = new (class extends Installer { constructor() { super(host, { typesRegistry: createTypesRegistry("lodash", "react") }); @@ -347,6 +347,7 @@ namespace ts.projectSystem { projectService.checkNumberOfProjects({ externalProjects: 1 }); checkProjectActualFiles(p, [file1.path, file2.path, file3.path]); + debugger; installer.installAll(/*expectedCount*/ 1); checkNumberOfProjects(projectService, { externalProjects: 1 }); @@ -445,7 +446,7 @@ namespace ts.projectSystem { content: "declare const moment: { x: number }" }; - const host = createServerHost([file1, file2, file3, packageJson]); + const host = createServerHost([file1, file2, file3, packageJson, customTypesMap]); const installer = new (class extends Installer { constructor() { super(host, { typesRegistry: createTypesRegistry("jquery", "commander", "moment", "express") }); @@ -521,7 +522,7 @@ namespace ts.projectSystem { }; const typingFiles = [commander, express, jquery, moment, lodash]; - const host = createServerHost([lodashJs, commanderJs, file3, packageJson]); + const host = createServerHost([lodashJs, commanderJs, file3, packageJson, customTypesMap]); const installer = new (class extends Installer { constructor() { super(host, { throttleLimit: 3, typesRegistry: createTypesRegistry("commander", "express", "jquery", "moment", "lodash") }); @@ -600,7 +601,7 @@ namespace ts.projectSystem { typings: typingsName("gulp") }; - const host = createServerHost([lodashJs, commanderJs, file3]); + const host = createServerHost([lodashJs, commanderJs, file3, customTypesMap]); const installer = new (class extends Installer { constructor() { super(host, { throttleLimit: 1, typesRegistry: createTypesRegistry("commander", "jquery", "lodash", "cordova", "gulp", "grunt") }); diff --git a/src/server/editorServices.ts b/src/server/editorServices.ts index 54b393053ca..226ba99fbea 100644 --- a/src/server/editorServices.ts +++ b/src/server/editorServices.ts @@ -411,7 +411,7 @@ namespace ts.server { this.globalPlugins = opts.globalPlugins || emptyArray; this.pluginProbeLocations = opts.pluginProbeLocations || emptyArray; this.allowLocalPluginLoads = !!opts.allowLocalPluginLoads; - this.typesMapLocation = (opts.typesMapLocation === undefined) ? combinePaths(this.host.getExecutingFilePath(), '../typesMap.json') : opts.typesMapLocation; + this.typesMapLocation = (opts.typesMapLocation === undefined) ? combinePaths(this.host.getExecutingFilePath(), "../typesMap.json") : opts.typesMapLocation; Debug.assert(!!this.host.createHash, "'ServerHost.createHash' is required for ProjectService"); @@ -472,7 +472,8 @@ namespace ts.server { } // raw is now fixed and ready this.safelist = raw.typesMap; - } catch(e) { + } + catch (e) { this.logger.info(`Error loading types map: ${e}`); this.safelist = defaultTypeSafeList; } @@ -1721,7 +1722,7 @@ namespace ts.server { const excludeRegexes = excludeRules.map(e => new RegExp(e, "i")); const filesToKeep: ts.server.protocol.ExternalFile[] = []; - for(let i = 0; i < proj.rootFiles.length; i++) { + for (let i = 0; i < proj.rootFiles.length; i++) { if (excludeRegexes.some(re => re.test(normalizedNames[i]))) { excludedFiles.push(normalizedNames[i]); } diff --git a/src/server/server.ts b/src/server/server.ts index 06e2a6482d7..c44cf362197 100644 --- a/src/server/server.ts +++ b/src/server/server.ts @@ -763,7 +763,7 @@ namespace ts.server { } const typingSafeListLocation = findArgument(Arguments.TypingSafeListLocation); - const typesMapLocation = findArgument(Arguments.TypesMapLocation) || combinePaths(sys.getExecutingFilePath(), '../typesMap.json'); + const typesMapLocation = findArgument(Arguments.TypesMapLocation) || combinePaths(sys.getExecutingFilePath(), "../typesMap.json"); const npmLocation = findArgument(Arguments.NpmLocation); const globalPlugins = (findArgument("--globalPlugins") || "").split(","); From e83a8ea2fc0f4580114ec313e064074d34dbadaf Mon Sep 17 00:00:00 2001 From: Ryan Cavanaugh Date: Thu, 27 Jul 2017 17:01:18 -0700 Subject: [PATCH 014/370] Remove debugger; --- src/harness/unittests/typingsInstaller.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/harness/unittests/typingsInstaller.ts b/src/harness/unittests/typingsInstaller.ts index 7285dadb0a6..a4064f7a2d8 100644 --- a/src/harness/unittests/typingsInstaller.ts +++ b/src/harness/unittests/typingsInstaller.ts @@ -347,7 +347,6 @@ namespace ts.projectSystem { projectService.checkNumberOfProjects({ externalProjects: 1 }); checkProjectActualFiles(p, [file1.path, file2.path, file3.path]); - debugger; installer.installAll(/*expectedCount*/ 1); checkNumberOfProjects(projectService, { externalProjects: 1 }); From 777bc575ac8117994acd34c9716854c40c92c59e Mon Sep 17 00:00:00 2001 From: Arthur Ozga Date: Fri, 4 Aug 2017 15:51:06 -0700 Subject: [PATCH 015/370] implementation comment --- src/services/formatting/formatting.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/services/formatting/formatting.ts b/src/services/formatting/formatting.ts index c4c4bad5de8..fbda42d3840 100644 --- a/src/services/formatting/formatting.ts +++ b/src/services/formatting/formatting.ts @@ -1168,6 +1168,14 @@ namespace ts.formatting { } export function getRangeOfEnclosingComment(sourceFile: SourceFile, position: number, onlyMultiLine: boolean): CommentRange | undefined { + // Considering a fixed position, + // - trailing comments are those following and on the same line as the position. + // - leading comments are those in the range [position, start of next non-trivia token) + // that are not trailing comments of that position. + // + // Note, `node.start` is the start-position of the first comment following the previous + // token that is not a trailing comment, so the leading and trailing comments of all + // tokens contain all comments in a sourcefile disjointly. const precedingToken = findPrecedingToken(position, sourceFile); const trailingRangesOfPreviousToken = precedingToken && getTrailingCommentRanges(sourceFile.text, precedingToken.end); const leadingCommentRangesOfNextToken = getLeadingCommentRangesOfNode(getTokenAtPosition(sourceFile, position, /*includeJsDocComment*/ false), sourceFile); From b44ac91de932012d54b576e9ae343aac7ce8c940 Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Fri, 4 Aug 2017 23:45:09 -0700 Subject: [PATCH 016/370] Added failing test for a before-transform that indirectly replaces a namespace declaration. --- src/harness/unittests/transform.ts | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/src/harness/unittests/transform.ts b/src/harness/unittests/transform.ts index 537235f2f67..5799de1bfbd 100644 --- a/src/harness/unittests/transform.ts +++ b/src/harness/unittests/transform.ts @@ -74,6 +74,32 @@ namespace ts { } }).outputText; }); + + testBaseline("synthesizedNamespace", () => { + return ts.transpileModule(`namespace Reflect { const x = 1; }`, { + transformers: { + before: [forceSyntheticModuleDeclaration], + }, + compilerOptions: { + newLine: NewLineKind.CarriageReturnLineFeed, + } + }).outputText; + + function forceSyntheticModuleDeclaration(context: ts.TransformationContext) { + return (sourceFile: ts.SourceFile): ts.SourceFile => { + return visitNode(sourceFile); + + function visitNode(node: T): T { + if (node.kind === ts.SyntaxKind.ModuleBlock) { + const block = node as T & ts.ModuleBlock; + const statements = ts.createNodeArray([...block.statements]); + return ts.updateModuleBlock(block, statements) as typeof block; + } + return ts.visitEachChild(node, visitNode, context); + } + }; + } + }) }); } From 5cb5cf14de2cc46613214b258eb5c5e52881c632 Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Fri, 4 Aug 2017 23:48:45 -0700 Subject: [PATCH 017/370] Accepted baselines. --- .../transformApi/transformsCorrectly.synthesizedNamespace.js | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 tests/baselines/reference/transformApi/transformsCorrectly.synthesizedNamespace.js diff --git a/tests/baselines/reference/transformApi/transformsCorrectly.synthesizedNamespace.js b/tests/baselines/reference/transformApi/transformsCorrectly.synthesizedNamespace.js new file mode 100644 index 00000000000..5897d293ff5 --- /dev/null +++ b/tests/baselines/reference/transformApi/transformsCorrectly.synthesizedNamespace.js @@ -0,0 +1,3 @@ +(function (Reflect) { + var x = 1; +})(Reflect || (Reflect = {})); From 9f1b7471139f3ed91b2b987dcb2cacb66b9de0cb Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Sat, 5 Aug 2017 00:12:54 -0700 Subject: [PATCH 018/370] Made the first-declaration check conservative in the TypeScript transform. --- src/compiler/transformers/ts.ts | 17 +++++++++-------- src/harness/unittests/transform.ts | 2 +- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/src/compiler/transformers/ts.ts b/src/compiler/transformers/ts.ts index 19ba8b1f2d2..89693c0d22a 100644 --- a/src/compiler/transformers/ts.ts +++ b/src/compiler/transformers/ts.ts @@ -2639,9 +2639,6 @@ namespace ts { /** * Records that a declaration was emitted in the current scope, if it was the first * declaration for the provided symbol. - * - * NOTE: if there is ever a transformation above this one, we may not be able to rely - * on symbol names. */ function recordEmittedDeclarationInScope(node: Node) { const name = node.symbol && node.symbol.escapedName; @@ -2657,10 +2654,13 @@ namespace ts { } /** - * Determines whether a declaration is the first declaration with the same name emitted - * in the current scope. + * Determines whether a declaration is *could* be the first declaration with + * the same name emitted in the current scope. Only returns false if we are absolutely + * certain a previous declaration has been emitted. */ - function isFirstEmittedDeclarationInScope(node: Node) { + function isPotentiallyFirstEmittedDeclarationInScope(node: Node) { + // If the node has a named symbol, then we have enough knowledge to determine + // whether a prior declaration has been emitted. if (currentScopeFirstDeclarationsOfName) { const name = node.symbol && node.symbol.escapedName; if (name) { @@ -2668,7 +2668,8 @@ namespace ts { } } - return false; + // Otherwise, we can't be sure. For example, this node could be synthetic. + return true; } /** @@ -2690,7 +2691,7 @@ namespace ts { setOriginalNode(statement, node); recordEmittedDeclarationInScope(node); - if (isFirstEmittedDeclarationInScope(node)) { + if (isPotentiallyFirstEmittedDeclarationInScope(node)) { // Adjust the source map emit to match the old emitter. if (node.kind === SyntaxKind.EnumDeclaration) { setSourceMapRange(statement.declarationList, node); diff --git a/src/harness/unittests/transform.ts b/src/harness/unittests/transform.ts index 5799de1bfbd..74b92f7c5a7 100644 --- a/src/harness/unittests/transform.ts +++ b/src/harness/unittests/transform.ts @@ -99,7 +99,7 @@ namespace ts { } }; } - }) + }); }); } From 22e0d9f7911124f23ee7cfd6e67dc1cf063a4e75 Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Sat, 5 Aug 2017 00:14:23 -0700 Subject: [PATCH 019/370] Accepted baselines. --- tests/baselines/reference/parserEnumDeclaration4.js | 1 + tests/baselines/reference/reservedWords2.js | 1 + .../transformApi/transformsCorrectly.synthesizedNamespace.js | 1 + 3 files changed, 3 insertions(+) diff --git a/tests/baselines/reference/parserEnumDeclaration4.js b/tests/baselines/reference/parserEnumDeclaration4.js index d5b1e696a3d..47450d419e1 100644 --- a/tests/baselines/reference/parserEnumDeclaration4.js +++ b/tests/baselines/reference/parserEnumDeclaration4.js @@ -3,6 +3,7 @@ enum void { } //// [parserEnumDeclaration4.js] +var ; (function () { })( || ( = {})); void {}; diff --git a/tests/baselines/reference/reservedWords2.js b/tests/baselines/reference/reservedWords2.js index f172f37d053..da6a35bba82 100644 --- a/tests/baselines/reference/reservedWords2.js +++ b/tests/baselines/reference/reservedWords2.js @@ -35,6 +35,7 @@ debugger; if () ; [1, 2]; +var ; (function () { })( || ( = {})); void {}; diff --git a/tests/baselines/reference/transformApi/transformsCorrectly.synthesizedNamespace.js b/tests/baselines/reference/transformApi/transformsCorrectly.synthesizedNamespace.js index 5897d293ff5..76d5d9a4dab 100644 --- a/tests/baselines/reference/transformApi/transformsCorrectly.synthesizedNamespace.js +++ b/tests/baselines/reference/transformApi/transformsCorrectly.synthesizedNamespace.js @@ -1,3 +1,4 @@ +var Reflect; (function (Reflect) { var x = 1; })(Reflect || (Reflect = {})); From 091376f46ff928feb79b6faee3dd1b88804fd336 Mon Sep 17 00:00:00 2001 From: Arthur Ozga Date: Mon, 7 Aug 2017 15:45:56 -0700 Subject: [PATCH 020/370] supressFormatOnKeyInComments --- src/services/formatting/smartIndenter.ts | 10 +++++----- src/services/services.ts | 25 +++++++++++++----------- 2 files changed, 19 insertions(+), 16 deletions(-) diff --git a/src/services/formatting/smartIndenter.ts b/src/services/formatting/smartIndenter.ts index d0651ce140f..b0d58ddad12 100644 --- a/src/services/formatting/smartIndenter.ts +++ b/src/services/formatting/smartIndenter.ts @@ -31,6 +31,11 @@ namespace ts.formatting { return 0; } + const indentationOfEnclosingMultiLineComment = getIndentationOfEnclosingMultiLineComment(sourceFile, position, options); + if (indentationOfEnclosingMultiLineComment >= 0) { + return indentationOfEnclosingMultiLineComment; + } + const precedingToken = findPrecedingToken(position, sourceFile); if (!precedingToken) { return getBaseIndentation(options); @@ -44,11 +49,6 @@ namespace ts.formatting { const lineAtPosition = sourceFile.getLineAndCharacterOfPosition(position).line; - const indentationOfEnclosingMultiLineComment = getIndentationOfEnclosingMultiLineComment(sourceFile, position, options); - if (indentationOfEnclosingMultiLineComment >= 0) { - return indentationOfEnclosingMultiLineComment; - } - // indentation is first non-whitespace character in a previous line // for block indentation, we should look for a line which contains something that's not // whitespace. diff --git a/src/services/services.ts b/src/services/services.ts index d6310258885..5a70ccca501 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -1757,17 +1757,20 @@ namespace ts { function getFormattingEditsAfterKeystroke(fileName: string, position: number, key: string, options: FormatCodeOptions | FormatCodeSettings): TextChange[] { const sourceFile = syntaxTreeCache.getCurrentSourceFile(fileName); const settings = toEditorSettings(options); - if (key === "{") { - return formatting.formatOnOpeningCurly(position, sourceFile, getRuleProvider(settings), settings); - } - else if (key === "}") { - return formatting.formatOnClosingCurly(position, sourceFile, getRuleProvider(settings), settings); - } - else if (key === ";") { - return formatting.formatOnSemicolon(position, sourceFile, getRuleProvider(settings), settings); - } - else if (key === "\n") { - return formatting.formatOnEnter(position, sourceFile, getRuleProvider(settings), settings); + + if (!isInComment(sourceFile, position)) { + if (key === "{") { + return formatting.formatOnOpeningCurly(position, sourceFile, getRuleProvider(settings), settings); + } + else if (key === "}") { + return formatting.formatOnClosingCurly(position, sourceFile, getRuleProvider(settings), settings); + } + else if (key === ";") { + return formatting.formatOnSemicolon(position, sourceFile, getRuleProvider(settings), settings); + } + else if (key === "\n") { + return formatting.formatOnEnter(position, sourceFile, getRuleProvider(settings), settings); + } } return []; From 0255adc4076b7b963e2db2b0c8bba4e330fbfd01 Mon Sep 17 00:00:00 2001 From: Herrington Darkholme Date: Tue, 8 Aug 2017 10:08:48 +0800 Subject: [PATCH 021/370] fix #16567: better coloring on light theme terminal --- 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 64e8eb0c803..db83f740253 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -243,7 +243,7 @@ namespace ts { const redForegroundEscapeSequence = "\u001b[91m"; const yellowForegroundEscapeSequence = "\u001b[93m"; const blueForegroundEscapeSequence = "\u001b[93m"; - const gutterStyleSequence = "\u001b[100;30m"; + const gutterStyleSequence = "\u001b[30;47m"; const gutterSeparator = " "; const resetEscapeSequence = "\u001b[0m"; const ellipsis = "..."; From 1663d01844ee79b9d87ad07008e5c6d7cb2cc28b Mon Sep 17 00:00:00 2001 From: uniqueiniquity Date: Wed, 9 Aug 2017 14:38:26 -0700 Subject: [PATCH 022/370] Fix outlining of objects in array --- src/services/outliningElementsCollector.ts | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/services/outliningElementsCollector.ts b/src/services/outliningElementsCollector.ts index 5099f8b66bd..0958892c1e6 100644 --- a/src/services/outliningElementsCollector.ts +++ b/src/services/outliningElementsCollector.ts @@ -16,6 +16,18 @@ namespace ts.OutliningElementsCollector { } } + function addOutliningForObjectLiteralsInArray(startElement: Node, endElement: Node, autoCollapse: boolean) { + if (startElement && endElement) { + const span: OutliningSpan = { + textSpan: createTextSpanFromBounds(startElement.getStart(), endElement.end), + hintSpan: createTextSpanFromBounds(startElement.getStart(), endElement.end), + bannerText: collapseText, + autoCollapse + }; + elements.push(span); + } + } + function addOutliningSpanComments(commentSpan: CommentRange, autoCollapse: boolean) { if (commentSpan) { const span: OutliningSpan = { @@ -161,6 +173,10 @@ namespace ts.OutliningElementsCollector { case SyntaxKind.CaseBlock: { const openBrace = findChildOfKind(n, SyntaxKind.OpenBraceToken, sourceFile); const closeBrace = findChildOfKind(n, SyntaxKind.CloseBraceToken, sourceFile); + if (n.kind === SyntaxKind.ObjectLiteralExpression && n.parent.kind === SyntaxKind.ArrayLiteralExpression) { + addOutliningForObjectLiteralsInArray(openBrace, closeBrace, autoCollapse(n)); + break; + } addOutliningSpan(n, openBrace, closeBrace, autoCollapse(n)); break; } From df5e1a0f6971a06916be4f6046267c0b72ddedde Mon Sep 17 00:00:00 2001 From: uniqueiniquity Date: Wed, 9 Aug 2017 15:55:02 -0700 Subject: [PATCH 023/370] add fourslash test --- .../getOutliningForObjectsInArray.ts | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 tests/cases/fourslash/getOutliningForObjectsInArray.ts diff --git a/tests/cases/fourslash/getOutliningForObjectsInArray.ts b/tests/cases/fourslash/getOutliningForObjectsInArray.ts new file mode 100644 index 00000000000..87d2bc96e2e --- /dev/null +++ b/tests/cases/fourslash/getOutliningForObjectsInArray.ts @@ -0,0 +1,23 @@ +/// + +////// objects in x should generate outlining spans that do not render in VS +//// const x =[| [ +//// [|{ a: 0 }|], +//// [|{ b: 1 }|], +//// [|{ c: 2 }|] +//// ]|]; +//// +////// objects in y should generate outlining spans that render as expected +//// const y =[| [ +//// [|{ +//// a: 0 +//// }|], +//// [|{ +//// b: 1 +//// }|], +//// [|{ +//// c: 2 +//// }|] +//// ]|]; + +verify.outliningSpansInCurrentFile(test.ranges()); \ No newline at end of file From 6ef27a4e1e2d7daf77c21bdd2148ee4459be1420 Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Thu, 10 Aug 2017 08:28:25 -0700 Subject: [PATCH 024/370] Added test for class/namespace merging with an ESNext target. --- src/harness/unittests/transform.ts | 47 ++++++++++++++++++++---------- 1 file changed, 31 insertions(+), 16 deletions(-) diff --git a/src/harness/unittests/transform.ts b/src/harness/unittests/transform.ts index 74b92f7c5a7..dc90638afd1 100644 --- a/src/harness/unittests/transform.ts +++ b/src/harness/unittests/transform.ts @@ -78,28 +78,43 @@ namespace ts { testBaseline("synthesizedNamespace", () => { return ts.transpileModule(`namespace Reflect { const x = 1; }`, { transformers: { - before: [forceSyntheticModuleDeclaration], + before: [forceNamespaceRewrite], }, compilerOptions: { newLine: NewLineKind.CarriageReturnLineFeed, } }).outputText; - - function forceSyntheticModuleDeclaration(context: ts.TransformationContext) { - return (sourceFile: ts.SourceFile): ts.SourceFile => { - return visitNode(sourceFile); - - function visitNode(node: T): T { - if (node.kind === ts.SyntaxKind.ModuleBlock) { - const block = node as T & ts.ModuleBlock; - const statements = ts.createNodeArray([...block.statements]); - return ts.updateModuleBlock(block, statements) as typeof block; - } - return ts.visitEachChild(node, visitNode, context); - } - }; - } }); + + testBaseline("synthesizedNamespaceFollowingClass", () => { + return ts.transpileModule(` + class C { foo = 10; static bar = 20 } + namespace C { export let x = 10; } + `, { + transformers: { + before: [forceNamespaceRewrite], + }, + compilerOptions: { + target: ts.ScriptTarget.ESNext, + newLine: NewLineKind.CarriageReturnLineFeed, + } + }).outputText; + }); + + function forceNamespaceRewrite(context: ts.TransformationContext) { + return (sourceFile: ts.SourceFile): ts.SourceFile => { + return visitNode(sourceFile); + + function visitNode(node: T): T { + if (node.kind === ts.SyntaxKind.ModuleBlock) { + const block = node as T & ts.ModuleBlock; + const statements = ts.createNodeArray([...block.statements]); + return ts.updateModuleBlock(block, statements) as typeof block; + } + return ts.visitEachChild(node, visitNode, context); + } + }; + } }); } From 66e2a0bb943538f3496e41f55a80899f0cfd78e1 Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Thu, 10 Aug 2017 08:28:43 -0700 Subject: [PATCH 025/370] Accepted baselines. --- ...ormsCorrectly.synthesizedNamespaceFollowingClass.js | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 tests/baselines/reference/transformApi/transformsCorrectly.synthesizedNamespaceFollowingClass.js diff --git a/tests/baselines/reference/transformApi/transformsCorrectly.synthesizedNamespaceFollowingClass.js b/tests/baselines/reference/transformApi/transformsCorrectly.synthesizedNamespaceFollowingClass.js new file mode 100644 index 00000000000..9dedde29f8b --- /dev/null +++ b/tests/baselines/reference/transformApi/transformsCorrectly.synthesizedNamespaceFollowingClass.js @@ -0,0 +1,10 @@ +class C { + constructor() { + this.foo = 10; + } +} +C.bar = 20; +var C; +(function (C) { + C.x = 10; +})(C || (C = {})); From de92e98770384e5e6023e10fce0609bbb0d029d8 Mon Sep 17 00:00:00 2001 From: Arthur Ozga Date: Thu, 10 Aug 2017 10:01:42 -0700 Subject: [PATCH 026/370] fix end-of-file assert failure --- src/services/services.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/services/services.ts b/src/services/services.ts index 648cc6c8320..24e85a2a019 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -107,12 +107,14 @@ namespace ts { scanner.setTextPos(pos); while (pos < end) { const token = scanner.scan(); - Debug.assert(token !== SyntaxKind.EndOfFileToken); // Else it would infinitely loop const textPos = scanner.getTextPos(); if (textPos <= end) { nodes.push(createNode(token, pos, textPos, this)); } pos = textPos; + if (token === SyntaxKind.EndOfFileToken) { + return pos; + } } return pos; } From c7d691dc15550b69cfec59bcb10c8e261e7dd7db Mon Sep 17 00:00:00 2001 From: uniqueiniquity Date: Thu, 10 Aug 2017 13:27:24 -0700 Subject: [PATCH 027/370] Generalize to nested arrays and refactor --- src/services/outliningElementsCollector.ts | 40 +++++++------------ .../getOutliningForObjectsInArray.ts | 19 +++++++++ 2 files changed, 33 insertions(+), 26 deletions(-) diff --git a/src/services/outliningElementsCollector.ts b/src/services/outliningElementsCollector.ts index 0958892c1e6..edebf98a24b 100644 --- a/src/services/outliningElementsCollector.ts +++ b/src/services/outliningElementsCollector.ts @@ -4,25 +4,13 @@ namespace ts.OutliningElementsCollector { const elements: OutliningSpan[] = []; const collapseText = "..."; - function addOutliningSpan(hintSpanNode: Node, startElement: Node, endElement: Node, autoCollapse: boolean) { + function addOutliningSpan(hintSpanNode: Node, startElement: Node, endElement: Node, autoCollapse: boolean, fullStart: boolean) { if (hintSpanNode && startElement && endElement) { const span: OutliningSpan = { - textSpan: createTextSpanFromBounds(startElement.pos, endElement.end), - hintSpan: createTextSpanFromNode(hintSpanNode, sourceFile), - bannerText: collapseText, - autoCollapse, - }; - elements.push(span); - } - } - - function addOutliningForObjectLiteralsInArray(startElement: Node, endElement: Node, autoCollapse: boolean) { - if (startElement && endElement) { - const span: OutliningSpan = { - textSpan: createTextSpanFromBounds(startElement.getStart(), endElement.end), + textSpan: createTextSpanFromBounds(fullStart ? startElement.pos : startElement.getStart(), endElement.end), hintSpan: createTextSpanFromBounds(startElement.getStart(), endElement.end), bannerText: collapseText, - autoCollapse + autoCollapse, }; elements.push(span); } @@ -125,7 +113,7 @@ namespace ts.OutliningElementsCollector { parent.kind === SyntaxKind.WithStatement || parent.kind === SyntaxKind.CatchClause) { - addOutliningSpan(parent, openBrace, closeBrace, autoCollapse(n)); + addOutliningSpan(parent, openBrace, closeBrace, autoCollapse(n), /* fullStart */ true); break; } @@ -133,13 +121,13 @@ namespace ts.OutliningElementsCollector { // Could be the try-block, or the finally-block. const tryStatement = parent; if (tryStatement.tryBlock === n) { - addOutliningSpan(parent, openBrace, closeBrace, autoCollapse(n)); + addOutliningSpan(parent, openBrace, closeBrace, autoCollapse(n), /* fullStart */ true); break; } else if (tryStatement.finallyBlock === n) { const finallyKeyword = findChildOfKind(tryStatement, SyntaxKind.FinallyKeyword, sourceFile); if (finallyKeyword) { - addOutliningSpan(finallyKeyword, openBrace, closeBrace, autoCollapse(n)); + addOutliningSpan(finallyKeyword, openBrace, closeBrace, autoCollapse(n), /* fullStart */ true); break; } } @@ -163,27 +151,27 @@ namespace ts.OutliningElementsCollector { case SyntaxKind.ModuleBlock: { const openBrace = findChildOfKind(n, SyntaxKind.OpenBraceToken, sourceFile); const closeBrace = findChildOfKind(n, SyntaxKind.CloseBraceToken, sourceFile); - addOutliningSpan(n.parent, openBrace, closeBrace, autoCollapse(n)); + addOutliningSpan(n.parent, openBrace, closeBrace, autoCollapse(n), /* fullStart */ true); break; } case SyntaxKind.ClassDeclaration: case SyntaxKind.InterfaceDeclaration: case SyntaxKind.EnumDeclaration: - case SyntaxKind.ObjectLiteralExpression: case SyntaxKind.CaseBlock: { const openBrace = findChildOfKind(n, SyntaxKind.OpenBraceToken, sourceFile); const closeBrace = findChildOfKind(n, SyntaxKind.CloseBraceToken, sourceFile); - if (n.kind === SyntaxKind.ObjectLiteralExpression && n.parent.kind === SyntaxKind.ArrayLiteralExpression) { - addOutliningForObjectLiteralsInArray(openBrace, closeBrace, autoCollapse(n)); - break; - } - addOutliningSpan(n, openBrace, closeBrace, autoCollapse(n)); + addOutliningSpan(n, openBrace, closeBrace, autoCollapse(n), /* fullStart */ true); break; } + case SyntaxKind.ObjectLiteralExpression: + const openBrace = findChildOfKind(n, SyntaxKind.OpenBraceToken, sourceFile); + const closeBrace = findChildOfKind(n, SyntaxKind.CloseBraceToken, sourceFile); + addOutliningSpan(n, openBrace, closeBrace, autoCollapse(n), /* fullStart */ n.parent.kind !== SyntaxKind.ArrayLiteralExpression); + break; case SyntaxKind.ArrayLiteralExpression: const openBracket = findChildOfKind(n, SyntaxKind.OpenBracketToken, sourceFile); const closeBracket = findChildOfKind(n, SyntaxKind.CloseBracketToken, sourceFile); - addOutliningSpan(n, openBracket, closeBracket, autoCollapse(n)); + addOutliningSpan(n, openBracket, closeBracket, autoCollapse(n), /* fullStart */ n.parent.kind !== SyntaxKind.ArrayLiteralExpression); break; } depth++; diff --git a/tests/cases/fourslash/getOutliningForObjectsInArray.ts b/tests/cases/fourslash/getOutliningForObjectsInArray.ts index 87d2bc96e2e..207da1997b4 100644 --- a/tests/cases/fourslash/getOutliningForObjectsInArray.ts +++ b/tests/cases/fourslash/getOutliningForObjectsInArray.ts @@ -19,5 +19,24 @@ //// c: 2 //// }|] //// ]|]; +//// +////// same behavior for nested arrays +//// const w =[| [ +//// [|[ a: 0 ]|], +//// [|[ b: 1 ]|], +//// [|[ c: 2 ]|] +//// ]|]; +//// +//// const z =[| [ +//// [|[ +//// a: 0 +//// ]|], +//// [|[ +//// b: 1 +//// ]|], +//// [|[ +//// c: 2 +//// ]|] +//// ]|]; verify.outliningSpansInCurrentFile(test.ranges()); \ No newline at end of file From d6ccee67661987373949af9c97bf3c636a22d496 Mon Sep 17 00:00:00 2001 From: uniqueiniquity Date: Fri, 11 Aug 2017 13:42:14 -0700 Subject: [PATCH 028/370] Cleans up and adds nested case to test --- .../getOutliningForObjectsInArray.ts | 26 ++++++++++++++----- 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/tests/cases/fourslash/getOutliningForObjectsInArray.ts b/tests/cases/fourslash/getOutliningForObjectsInArray.ts index 207da1997b4..2d57d3335bd 100644 --- a/tests/cases/fourslash/getOutliningForObjectsInArray.ts +++ b/tests/cases/fourslash/getOutliningForObjectsInArray.ts @@ -22,20 +22,34 @@ //// ////// same behavior for nested arrays //// const w =[| [ -//// [|[ a: 0 ]|], -//// [|[ b: 1 ]|], -//// [|[ c: 2 ]|] +//// [|[ 0 ]|], +//// [|[ 1 ]|], +//// [|[ 2 ]|] //// ]|]; //// //// const z =[| [ //// [|[ -//// a: 0 +//// 0 //// ]|], //// [|[ -//// b: 1 +//// 1 //// ]|], //// [|[ -//// c: 2 +//// 2 +//// ]|] +//// ]|]; +//// +////// multiple levels of nesting work as expected +//// const z =[| [ +//// [|[ +//// [|{ hello: 0 }|] +//// ]|], +//// [|[ +//// [|{ hello: 3 }|] +//// ]|], +//// [|[ +//// [|{ hello: 5 }|], +//// [|{ hello: 7 }|] //// ]|] //// ]|]; From 18cced9abd97005b5c139bd97ac41e892f0c3b9d Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Fri, 11 Aug 2017 18:35:31 -0400 Subject: [PATCH 029/370] Added test. --- src/harness/unittests/transform.ts | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/src/harness/unittests/transform.ts b/src/harness/unittests/transform.ts index dc90638afd1..6edd174da23 100644 --- a/src/harness/unittests/transform.ts +++ b/src/harness/unittests/transform.ts @@ -75,7 +75,7 @@ namespace ts { }).outputText; }); - testBaseline("synthesizedNamespace", () => { + testBaseline("rewrittenNamespace", () => { return ts.transpileModule(`namespace Reflect { const x = 1; }`, { transformers: { before: [forceNamespaceRewrite], @@ -86,7 +86,7 @@ namespace ts { }).outputText; }); - testBaseline("synthesizedNamespaceFollowingClass", () => { + testBaseline("rewrittenNamespaceFollowingClass", () => { return ts.transpileModule(` class C { foo = 10; static bar = 20 } namespace C { export let x = 10; } @@ -101,6 +101,29 @@ namespace ts { }).outputText; }); + testBaseline("synthesizedClassAndNamespaceCombination", () => { + return ts.transpileModule("", { + transformers: { + before: [replaceWithClassAndNamespace], + }, + compilerOptions: { + target: ts.ScriptTarget.ESNext, + newLine: NewLineKind.CarriageReturnLineFeed, + } + }).outputText; + + function replaceWithClassAndNamespace() { + return (sourceFile: ts.SourceFile) => { + const result = getMutableClone(sourceFile); + result.statements = ts.createNodeArray([ + ts.createClassDeclaration(undefined, undefined, "Foo", undefined, undefined, undefined), + ts.createModuleDeclaration(undefined, undefined, createIdentifier("Foo"), createModuleBlock([createEmptyStatement()])) + ]); + return result; + } + } + }); + function forceNamespaceRewrite(context: ts.TransformationContext) { return (sourceFile: ts.SourceFile): ts.SourceFile => { return visitNode(sourceFile); From 33a036b6799f297fcf7b913c3a56385e47026cd6 Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Fri, 11 Aug 2017 18:47:21 -0400 Subject: [PATCH 030/370] Accepted baselines. --- ...mespace.js => transformsCorrectly.rewrittenNamespace.js} | 0 ...transformsCorrectly.rewrittenNamespaceFollowingClass.js} | 0 ...ormsCorrectly.synthesizedClassAndNamespaceCombination.js | 6 ++++++ 3 files changed, 6 insertions(+) rename tests/baselines/reference/transformApi/{transformsCorrectly.synthesizedNamespace.js => transformsCorrectly.rewrittenNamespace.js} (100%) rename tests/baselines/reference/transformApi/{transformsCorrectly.synthesizedNamespaceFollowingClass.js => transformsCorrectly.rewrittenNamespaceFollowingClass.js} (100%) create mode 100644 tests/baselines/reference/transformApi/transformsCorrectly.synthesizedClassAndNamespaceCombination.js diff --git a/tests/baselines/reference/transformApi/transformsCorrectly.synthesizedNamespace.js b/tests/baselines/reference/transformApi/transformsCorrectly.rewrittenNamespace.js similarity index 100% rename from tests/baselines/reference/transformApi/transformsCorrectly.synthesizedNamespace.js rename to tests/baselines/reference/transformApi/transformsCorrectly.rewrittenNamespace.js diff --git a/tests/baselines/reference/transformApi/transformsCorrectly.synthesizedNamespaceFollowingClass.js b/tests/baselines/reference/transformApi/transformsCorrectly.rewrittenNamespaceFollowingClass.js similarity index 100% rename from tests/baselines/reference/transformApi/transformsCorrectly.synthesizedNamespaceFollowingClass.js rename to tests/baselines/reference/transformApi/transformsCorrectly.rewrittenNamespaceFollowingClass.js diff --git a/tests/baselines/reference/transformApi/transformsCorrectly.synthesizedClassAndNamespaceCombination.js b/tests/baselines/reference/transformApi/transformsCorrectly.synthesizedClassAndNamespaceCombination.js new file mode 100644 index 00000000000..ad11068a512 --- /dev/null +++ b/tests/baselines/reference/transformApi/transformsCorrectly.synthesizedClassAndNamespaceCombination.js @@ -0,0 +1,6 @@ +class Foo { +} +var Foo; +(function (Foo) { + ; +})(Foo || (Foo = {})); From 8ca66d318061f6b95d90293413fea98189d84e4d Mon Sep 17 00:00:00 2001 From: Ron Buckton Date: Fri, 11 Aug 2017 16:15:28 -0700 Subject: [PATCH 031/370] PR feedback --- src/compiler/checker.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 29b0420201e..e0ef3ca82ba 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -16090,7 +16090,7 @@ namespace ts { } function getJavaScriptClassType(symbol: Symbol): Type | undefined { - if (symbol && isDeclarationOfFunctionOrClassExpression(symbol)) { + if (isDeclarationOfFunctionOrClassExpression(symbol)) { symbol = getSymbolOfNode((symbol.valueDeclaration).initializer); } if (isJavaScriptConstructor(symbol.valueDeclaration)) { From 903d137cea1dc25556bf2e90fda21f4d416eb72c Mon Sep 17 00:00:00 2001 From: Jan Melcher Date: Tue, 27 Jun 2017 17:22:39 +0200 Subject: [PATCH 032/370] Add missing visitNode call to object literal members Object literal elements that are neither spread elements, nor property assignments would not have visitNode called on them. Therefore, the esnext transformer would not be called on them and their children. Fixes #16765. --- src/compiler/transformers/esnext.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/compiler/transformers/esnext.ts b/src/compiler/transformers/esnext.ts index 8d71016b051..3bdcc9e9ee7 100644 --- a/src/compiler/transformers/esnext.ts +++ b/src/compiler/transformers/esnext.ts @@ -158,8 +158,8 @@ namespace ts { return visitEachChild(node, visitor, context); } - function chunkObjectLiteralElements(elements: ReadonlyArray): Expression[] { - let chunkObject: (ShorthandPropertyAssignment | PropertyAssignment)[]; + function chunkObjectLiteralElements(elements: ReadonlyArray): Expression[] { + let chunkObject: ObjectLiteralElementLike[]; const objects: Expression[] = []; for (const e of elements) { if (e.kind === SyntaxKind.SpreadAssignment) { @@ -179,7 +179,7 @@ namespace ts { chunkObject.push(createPropertyAssignment(p.name, visitNode(p.initializer, visitor, isExpression))); } else { - chunkObject.push(e as ShorthandPropertyAssignment); + chunkObject.push(visitNode(e, visitor, isObjectLiteralElementLike)); } } } From 8b4db9875d6eb60a243dc7e20fc51c7c04ab569d Mon Sep 17 00:00:00 2001 From: Jan Melcher Date: Tue, 27 Jun 2017 18:03:16 +0200 Subject: [PATCH 033/370] Add test case for nested object spread / methods See #16765. --- ...preadWithinMethodWithinObjectWithSpread.js | 26 +++++++++++++++++ ...WithinMethodWithinObjectWithSpread.symbols | 24 +++++++++++++++ ...adWithinMethodWithinObjectWithSpread.types | 29 +++++++++++++++++++ ...preadWithinMethodWithinObjectWithSpread.ts | 10 +++++++ 4 files changed, 89 insertions(+) create mode 100644 tests/baselines/reference/objectSpreadWithinMethodWithinObjectWithSpread.js create mode 100644 tests/baselines/reference/objectSpreadWithinMethodWithinObjectWithSpread.symbols create mode 100644 tests/baselines/reference/objectSpreadWithinMethodWithinObjectWithSpread.types create mode 100644 tests/cases/compiler/objectSpreadWithinMethodWithinObjectWithSpread.ts diff --git a/tests/baselines/reference/objectSpreadWithinMethodWithinObjectWithSpread.js b/tests/baselines/reference/objectSpreadWithinMethodWithinObjectWithSpread.js new file mode 100644 index 00000000000..e16695b655e --- /dev/null +++ b/tests/baselines/reference/objectSpreadWithinMethodWithinObjectWithSpread.js @@ -0,0 +1,26 @@ +//// [objectSpreadWithinMethodWithinObjectWithSpread.ts] +const obj = {}; +const a = { + ...obj, + prop() { + return { + ...obj, + metadata: 213 + }; + } +}; + + +//// [objectSpreadWithinMethodWithinObjectWithSpread.js] +var __assign = (this && this.__assign) || Object.assign || function(t) { + for (var s, i = 1, n = arguments.length; i < n; i++) { + s = arguments[i]; + for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) + t[p] = s[p]; + } + return t; +}; +var obj = {}; +var a = __assign({}, obj, { prop: function () { + return __assign({}, obj, { metadata: 213 }); + } }); diff --git a/tests/baselines/reference/objectSpreadWithinMethodWithinObjectWithSpread.symbols b/tests/baselines/reference/objectSpreadWithinMethodWithinObjectWithSpread.symbols new file mode 100644 index 00000000000..181cacd5e07 --- /dev/null +++ b/tests/baselines/reference/objectSpreadWithinMethodWithinObjectWithSpread.symbols @@ -0,0 +1,24 @@ +=== tests/cases/compiler/objectSpreadWithinMethodWithinObjectWithSpread.ts === +const obj = {}; +>obj : Symbol(obj, Decl(objectSpreadWithinMethodWithinObjectWithSpread.ts, 0, 5)) + +const a = { +>a : Symbol(a, Decl(objectSpreadWithinMethodWithinObjectWithSpread.ts, 1, 5)) + + ...obj, +>obj : Symbol(obj, Decl(objectSpreadWithinMethodWithinObjectWithSpread.ts, 0, 5)) + + prop() { +>prop : Symbol(prop, Decl(objectSpreadWithinMethodWithinObjectWithSpread.ts, 2, 11)) + + return { + ...obj, +>obj : Symbol(obj, Decl(objectSpreadWithinMethodWithinObjectWithSpread.ts, 0, 5)) + + metadata: 213 +>metadata : Symbol(metadata, Decl(objectSpreadWithinMethodWithinObjectWithSpread.ts, 5, 19)) + + }; + } +}; + diff --git a/tests/baselines/reference/objectSpreadWithinMethodWithinObjectWithSpread.types b/tests/baselines/reference/objectSpreadWithinMethodWithinObjectWithSpread.types new file mode 100644 index 00000000000..351aa0c374b --- /dev/null +++ b/tests/baselines/reference/objectSpreadWithinMethodWithinObjectWithSpread.types @@ -0,0 +1,29 @@ +=== tests/cases/compiler/objectSpreadWithinMethodWithinObjectWithSpread.ts === +const obj = {}; +>obj : {} +>{} : {} + +const a = { +>a : { prop(): { metadata: number; }; } +>{ ...obj, prop() { return { ...obj, metadata: 213 }; }} : { prop(): { metadata: number; }; } + + ...obj, +>obj : {} + + prop() { +>prop : () => { metadata: number; } + + return { +>{ ...obj, metadata: 213 } : { metadata: number; } + + ...obj, +>obj : {} + + metadata: 213 +>metadata : number +>213 : 213 + + }; + } +}; + diff --git a/tests/cases/compiler/objectSpreadWithinMethodWithinObjectWithSpread.ts b/tests/cases/compiler/objectSpreadWithinMethodWithinObjectWithSpread.ts new file mode 100644 index 00000000000..4d1663bb456 --- /dev/null +++ b/tests/cases/compiler/objectSpreadWithinMethodWithinObjectWithSpread.ts @@ -0,0 +1,10 @@ +const obj = {}; +const a = { + ...obj, + prop() { + return { + ...obj, + metadata: 213 + }; + } +}; From 760812f7143ccc311746e0c3eac191d2905722c9 Mon Sep 17 00:00:00 2001 From: uniqueiniquity Date: Mon, 14 Aug 2017 09:27:45 -0700 Subject: [PATCH 034/370] Add explanatory comments, consolidate main body --- src/services/outliningElementsCollector.ts | 18 +++++++++++------- .../fourslash/getOutliningForObjectsInArray.ts | 8 ++++---- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/src/services/outliningElementsCollector.ts b/src/services/outliningElementsCollector.ts index edebf98a24b..cdeba21b32b 100644 --- a/src/services/outliningElementsCollector.ts +++ b/src/services/outliningElementsCollector.ts @@ -3,11 +3,17 @@ namespace ts.OutliningElementsCollector { export function collectElements(sourceFile: SourceFile, cancellationToken: CancellationToken): OutliningSpan[] { const elements: OutliningSpan[] = []; const collapseText = "..."; + let depth = 0; + const maxDepth = 20; - function addOutliningSpan(hintSpanNode: Node, startElement: Node, endElement: Node, autoCollapse: boolean, fullStart: boolean) { + walk(sourceFile); + return elements; + + // If useFullStart is true, then the collapsing span includes leading whitespace, including linebreaks. + function addOutliningSpan(hintSpanNode: Node, startElement: Node, endElement: Node, autoCollapse: boolean, useFullStart: boolean) { if (hintSpanNode && startElement && endElement) { const span: OutliningSpan = { - textSpan: createTextSpanFromBounds(fullStart ? startElement.pos : startElement.getStart(), endElement.end), + textSpan: createTextSpanFromBounds(useFullStart ? startElement.pos : startElement.getStart(), endElement.end), hintSpan: createTextSpanFromBounds(startElement.getStart(), endElement.end), bannerText: collapseText, autoCollapse, @@ -82,8 +88,6 @@ namespace ts.OutliningElementsCollector { return isFunctionBlock(node) && node.parent.kind !== SyntaxKind.ArrowFunction; } - let depth = 0; - const maxDepth = 20; function walk(n: Node): void { cancellationToken.throwIfCancellationRequested(); if (depth > maxDepth) { @@ -163,6 +167,9 @@ namespace ts.OutliningElementsCollector { addOutliningSpan(n, openBrace, closeBrace, autoCollapse(n), /* fullStart */ true); break; } + // If the block has no leading keywords and is a member of an array literal, + // we again want to only collapse the span of the block. + // Otherwise, the collapsed section will include the end of the previous line. case SyntaxKind.ObjectLiteralExpression: const openBrace = findChildOfKind(n, SyntaxKind.OpenBraceToken, sourceFile); const closeBrace = findChildOfKind(n, SyntaxKind.CloseBraceToken, sourceFile); @@ -178,8 +185,5 @@ namespace ts.OutliningElementsCollector { forEachChild(n, walk); depth--; } - - walk(sourceFile); - return elements; } } \ No newline at end of file diff --git a/tests/cases/fourslash/getOutliningForObjectsInArray.ts b/tests/cases/fourslash/getOutliningForObjectsInArray.ts index 2d57d3335bd..89634224832 100644 --- a/tests/cases/fourslash/getOutliningForObjectsInArray.ts +++ b/tests/cases/fourslash/getOutliningForObjectsInArray.ts @@ -1,13 +1,13 @@ /// -////// objects in x should generate outlining spans that do not render in VS +// objects in x should generate outlining spans that do not render in VS //// const x =[| [ //// [|{ a: 0 }|], //// [|{ b: 1 }|], //// [|{ c: 2 }|] //// ]|]; //// -////// objects in y should generate outlining spans that render as expected +// objects in y should generate outlining spans that render as expected //// const y =[| [ //// [|{ //// a: 0 @@ -20,7 +20,7 @@ //// }|] //// ]|]; //// -////// same behavior for nested arrays +// same behavior for nested arrays //// const w =[| [ //// [|[ 0 ]|], //// [|[ 1 ]|], @@ -39,7 +39,7 @@ //// ]|] //// ]|]; //// -////// multiple levels of nesting work as expected +// multiple levels of nesting work as expected //// const z =[| [ //// [|[ //// [|{ hello: 0 }|] From 5665c098dab4429eb66744884315bef80b5e4486 Mon Sep 17 00:00:00 2001 From: Paul van Brenk Date: Mon, 14 Aug 2017 16:55:37 -0700 Subject: [PATCH 035/370] Introduce the concept of a Dynamic File Dynamic files are generally created by the debugger when while debugging it can't find a matching file on disk. Since these files don't exist on disk, we shouldn't check if the file exists on disk, and allow the content to be controlled by the host. --- src/server/builder.ts | 6 +++--- src/server/editorServices.ts | 28 +++++++++++++++++----------- src/server/scriptInfo.ts | 11 ++++++----- src/server/utilities.ts | 8 ++++---- 4 files changed, 30 insertions(+), 23 deletions(-) diff --git a/src/server/builder.ts b/src/server/builder.ts index 8a10682b4cc..5cf65611fb3 100644 --- a/src/server/builder.ts +++ b/src/server/builder.ts @@ -5,7 +5,7 @@ namespace ts.server { export function shouldEmitFile(scriptInfo: ScriptInfo) { - return !scriptInfo.hasMixedContent; + return !scriptInfo.hasMixedContent && !scriptInfo.isDynamic; } /** @@ -188,7 +188,7 @@ namespace ts.server { */ getFilesAffectedBy(scriptInfo: ScriptInfo): string[] { const info = this.getOrCreateFileInfo(scriptInfo.path); - const singleFileResult = scriptInfo.hasMixedContent ? [] : [scriptInfo.fileName]; + const singleFileResult = scriptInfo.hasMixedContent || scriptInfo.isDynamic ? [] : [scriptInfo.fileName]; if (info.updateShapeSignature()) { const options = this.project.getCompilerOptions(); // If `--out` or `--outFile` is specified, any new emit will result in re-emitting the entire project, @@ -303,7 +303,7 @@ namespace ts.server { getFilesAffectedBy(scriptInfo: ScriptInfo): string[] { this.ensureProjectDependencyGraphUpToDate(); - const singleFileResult = scriptInfo.hasMixedContent ? [] : [scriptInfo.fileName]; + const singleFileResult = scriptInfo.hasMixedContent || scriptInfo.isDynamic ? [] : [scriptInfo.fileName]; const fileInfo = this.getFileInfo(scriptInfo.path); if (!fileInfo || !fileInfo.updateShapeSignature()) { return singleFileResult; diff --git a/src/server/editorServices.ts b/src/server/editorServices.ts index fe7946fc0f7..6d0f8d41e61 100644 --- a/src/server/editorServices.ts +++ b/src/server/editorServices.ts @@ -234,18 +234,21 @@ namespace ts.server { getFileName(f: T): string; getScriptKind(f: T): ScriptKind; hasMixedContent(f: T, extraFileExtensions: JsFileExtensionInfo[]): boolean; + isDynamicFile(f: T): boolean; } const fileNamePropertyReader: FilePropertyReader = { getFileName: x => x, getScriptKind: _ => undefined, hasMixedContent: (fileName, extraFileExtensions) => some(extraFileExtensions, ext => ext.isMixedContent && fileExtensionIs(fileName, ext.extension)), + isDynamicFile: x => x[0] == '^', }; const externalFilePropertyReader: FilePropertyReader = { getFileName: x => x.fileName, getScriptKind: x => tryConvertScriptKindName(x.scriptKind), - hasMixedContent: x => x.hasMixedContent + hasMixedContent: x => x.hasMixedContent, + isDynamicFile: x => x.fileName[0] == '^', }; function findProjectByName(projectName: string, projects: T[]): T { @@ -1177,15 +1180,16 @@ namespace ts.server { private addFilesToProjectAndUpdateGraph(project: ConfiguredProject | ExternalProject, files: T[], propertyReader: FilePropertyReader, clientFileName: string, typeAcquisition: TypeAcquisition, configFileErrors: ReadonlyArray): void { let errors: Diagnostic[]; for (const f of files) { - const rootFilename = propertyReader.getFileName(f); + const rootFileName = propertyReader.getFileName(f); const scriptKind = propertyReader.getScriptKind(f); const hasMixedContent = propertyReader.hasMixedContent(f, this.hostConfiguration.extraFileExtensions); - if (this.host.fileExists(rootFilename)) { - const info = this.getOrCreateScriptInfoForNormalizedPath(toNormalizedPath(rootFilename), /*openedByClient*/ clientFileName === rootFilename, /*fileContent*/ undefined, scriptKind, hasMixedContent); + const isDynamicFile = propertyReader.isDynamicFile(f); + if (isDynamicFile || this.host.fileExists(rootFileName)) { + const info = this.getOrCreateScriptInfoForNormalizedPath(toNormalizedPath(rootFileName), /*openedByClient*/ clientFileName === rootFileName, /*fileContent*/ undefined, scriptKind, hasMixedContent, isDynamicFile); project.addRoot(info); } else { - (errors || (errors = [])).push(createFileNotFoundDiagnostic(rootFilename)); + (errors || (errors = [])).push(createFileNotFoundDiagnostic(rootFileName)); } } project.setProjectErrors(concatenate(configFileErrors, errors)); @@ -1215,7 +1219,8 @@ namespace ts.server { let rootFilesChanged = false; for (const f of newUncheckedFiles) { const newRootFile = propertyReader.getFileName(f); - if (!this.host.fileExists(newRootFile)) { + const isDynamic = propertyReader.isDynamicFile(f); + if (!isDynamic && !this.host.fileExists(newRootFile)) { (projectErrors || (projectErrors = [])).push(createFileNotFoundDiagnostic(newRootFile)); continue; } @@ -1226,7 +1231,7 @@ namespace ts.server { if (!scriptInfo) { const scriptKind = propertyReader.getScriptKind(f); const hasMixedContent = propertyReader.hasMixedContent(f, this.hostConfiguration.extraFileExtensions); - scriptInfo = this.getOrCreateScriptInfoForNormalizedPath(normalizedPath, /*openedByClient*/ false, /*fileContent*/ undefined, scriptKind, hasMixedContent); + scriptInfo = this.getOrCreateScriptInfoForNormalizedPath(normalizedPath, /*openedByClient*/ false, /*fileContent*/ undefined, scriptKind, hasMixedContent, isDynamic); } } newRootScriptInfos.push(scriptInfo); @@ -1410,17 +1415,17 @@ namespace ts.server { watchClosedScriptInfo(info: ScriptInfo) { // do not watch files with mixed content - server doesn't know how to interpret it - if (!info.hasMixedContent) { + if (!info.hasMixedContent && !info.isDynamic) { const { fileName } = info; info.setWatcher(this.host.watchFile(fileName, _ => this.onSourceFileChanged(fileName))); } } - getOrCreateScriptInfoForNormalizedPath(fileName: NormalizedPath, openedByClient: boolean, fileContent?: string, scriptKind?: ScriptKind, hasMixedContent?: boolean) { + getOrCreateScriptInfoForNormalizedPath(fileName: NormalizedPath, openedByClient: boolean, fileContent?: string, scriptKind?: ScriptKind, hasMixedContent?: boolean, isDynamic?: boolean) { let info = this.getScriptInfoForNormalizedPath(fileName); if (!info) { - if (openedByClient || this.host.fileExists(fileName)) { - info = new ScriptInfo(this.host, fileName, scriptKind, hasMixedContent); + if (openedByClient || isDynamic || this.host.fileExists(fileName)) { + info = new ScriptInfo(this.host, fileName, scriptKind, hasMixedContent, isDynamic); this.filenameToScriptInfo.set(info.path, info); @@ -1430,6 +1435,7 @@ namespace ts.server { fileContent = this.host.readFile(fileName) || ""; } } + else { this.watchClosedScriptInfo(info); } diff --git a/src/server/scriptInfo.ts b/src/server/scriptInfo.ts index 4d73fc47403..a8ba9f5d4c2 100644 --- a/src/server/scriptInfo.ts +++ b/src/server/scriptInfo.ts @@ -156,11 +156,12 @@ namespace ts.server { private readonly host: ServerHost, readonly fileName: NormalizedPath, readonly scriptKind: ScriptKind, - public hasMixedContent = false) { + public hasMixedContent = false, + public isDynamic = false) { this.path = toPath(fileName, host.getCurrentDirectory(), createGetCanonicalFileName(host.useCaseSensitiveFileNames)); this.textStorage = new TextStorage(host, fileName); - if (hasMixedContent) { + if (hasMixedContent || isDynamic) { this.textStorage.reload(""); } this.scriptKind = scriptKind @@ -180,7 +181,7 @@ namespace ts.server { public close() { this.isOpen = false; - this.textStorage.useText(this.hasMixedContent ? "" : undefined); + this.textStorage.useText(this.hasMixedContent || this.isDynamic ? "" : undefined); this.markContainingProjectsAsDirty(); } @@ -307,7 +308,7 @@ namespace ts.server { } reloadFromFile(tempFileName?: NormalizedPath) { - if (this.hasMixedContent) { + if (this.hasMixedContent || this.isDynamic) { this.reload(""); } else { @@ -354,4 +355,4 @@ namespace ts.server { return this.scriptKind === ScriptKind.JS || this.scriptKind === ScriptKind.JSX; } } -} \ No newline at end of file +} diff --git a/src/server/utilities.ts b/src/server/utilities.ts index 0d4bc101ff6..7a5dbdf7cc7 100644 --- a/src/server/utilities.ts +++ b/src/server/utilities.ts @@ -84,7 +84,7 @@ namespace ts.server { }; } - export function mergeMapLikes(target: MapLike, source: MapLike ): void { + export function mergeMapLikes(target: MapLike, source: MapLike): void { for (const key in source) { if (hasProperty(source, key)) { target[key] = source[key]; @@ -115,9 +115,9 @@ namespace ts.server { } export function createNormalizedPathMap(): NormalizedPathMap { -/* tslint:disable:no-null-keyword */ + /* tslint:disable:no-null-keyword */ const map = createMap(); -/* tslint:enable:no-null-keyword */ + /* tslint:enable:no-null-keyword */ return { get(path) { return map.get(path); @@ -290,4 +290,4 @@ namespace ts.server { deleted(oldItems[oldIndex++]); } } -} \ No newline at end of file +} From 5b860557867bed3a10b33a98c0ac99a8e9cd5dab Mon Sep 17 00:00:00 2001 From: Armando Aguirre Date: Tue, 25 Jul 2017 14:21:57 -0700 Subject: [PATCH 036/370] Excluded the default library from rename service. --- src/compiler/program.ts | 5 +++++ src/compiler/types.ts | 1 + src/services/services.ts | 43 ++++++++++++++++++++++++++-------------- 3 files changed, 34 insertions(+), 15 deletions(-) diff --git a/src/compiler/program.ts b/src/compiler/program.ts index 305058285f9..55edb377373 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -555,6 +555,7 @@ namespace ts { getFileProcessingDiagnostics: () => fileProcessingDiagnostics, getResolvedTypeReferenceDirectives: () => resolvedTypeReferenceDirectives, isSourceFileFromExternalLibrary, + isSourceFileDefaultLibrary, dropDiagnosticsProducingTypeChecker, getSourceFileFromReference, sourceFileToPackageName, @@ -975,6 +976,10 @@ namespace ts { return sourceFilesFoundSearchingNodeModules.get(file.path); } + function isSourceFileDefaultLibrary(file: SourceFile): boolean { + return file.fileName === host.getDefaultLibFileName(options); + } + function getDiagnosticsProducingTypeChecker() { return diagnosticsProducingTypeChecker || (diagnosticsProducingTypeChecker = createTypeChecker(program, /*produceDiagnostics:*/ true)); } diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 2b3e5ab36df..66a4517a5bd 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -2452,6 +2452,7 @@ namespace ts { /* @internal */ getFileProcessingDiagnostics(): DiagnosticCollection; /* @internal */ getResolvedTypeReferenceDirectives(): Map; /* @internal */ isSourceFileFromExternalLibrary(file: SourceFile): boolean; + /* @internal */ isSourceFileDefaultLibrary(file: SourceFile): boolean; // For testing purposes only. /* @internal */ structureIsReused?: StructureIsReused; diff --git a/src/services/services.ts b/src/services/services.ts index ed9732cc9cf..998a5d36898 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -670,7 +670,7 @@ namespace ts { if (!hasModifier(node, ModifierFlags.ParameterPropertyModifier)) { break; } - // falls through + // falls through case SyntaxKind.VariableDeclaration: case SyntaxKind.BindingElement: { const decl = node; @@ -682,7 +682,7 @@ namespace ts { visit(decl.initializer); } } - // falls through + // falls through case SyntaxKind.EnumMember: case SyntaxKind.PropertyDeclaration: case SyntaxKind.PropertySignature: @@ -729,7 +729,7 @@ namespace ts { class SourceMapSourceObject implements SourceMapSource { lineMap: number[]; - constructor (public fileName: string, public text: string, public skipTrivia?: (pos: number) => number) {} + constructor(public fileName: string, public text: string, public skipTrivia?: (pos: number) => number) { } public getLineAndCharacterOfPosition(pos: number): LineAndCharacter { return ts.getLineAndCharacterOfPosition(this, pos); @@ -1130,14 +1130,14 @@ namespace ts { const newSettings = hostCache.compilationSettings(); const shouldCreateNewSourceFiles = oldSettings && (oldSettings.target !== newSettings.target || - oldSettings.module !== newSettings.module || - oldSettings.moduleResolution !== newSettings.moduleResolution || - oldSettings.noResolve !== newSettings.noResolve || - oldSettings.jsx !== newSettings.jsx || - oldSettings.allowJs !== newSettings.allowJs || - oldSettings.disableSizeLimit !== oldSettings.disableSizeLimit || - oldSettings.baseUrl !== newSettings.baseUrl || - !equalOwnProperties(oldSettings.paths, newSettings.paths)); + oldSettings.module !== newSettings.module || + oldSettings.moduleResolution !== newSettings.moduleResolution || + oldSettings.noResolve !== newSettings.noResolve || + oldSettings.jsx !== newSettings.jsx || + oldSettings.allowJs !== newSettings.allowJs || + oldSettings.disableSizeLimit !== oldSettings.disableSizeLimit || + oldSettings.baseUrl !== newSettings.baseUrl || + !equalOwnProperties(oldSettings.paths, newSettings.paths)); // Now create a new compiler const compilerHost: CompilerHost = { @@ -1365,7 +1365,7 @@ namespace ts { function getCompilerOptionsDiagnostics() { synchronizeHostData(); return program.getOptionsDiagnostics(cancellationToken).concat( - program.getGlobalDiagnostics(cancellationToken)); + program.getGlobalDiagnostics(cancellationToken)); } function getCompletionsAtPosition(fileName: string, position: number): CompletionInfo { @@ -1510,7 +1510,20 @@ namespace ts { function getReferences(fileName: string, position: number, options?: FindAllReferences.Options) { synchronizeHostData(); - return FindAllReferences.findReferencedEntries(program, cancellationToken, program.getSourceFiles(), getValidSourceFile(fileName), position, options); + + //Exclude default library when renaming as commonly user don't want to change that file. + let sourceFiles: SourceFile[] = []; + if (options.isForRename) { + for (let sourceFile of program.getSourceFiles()) { + if (!program.isSourceFileDefaultLibrary(sourceFile)) { + sourceFiles.push(sourceFile); + } + } + } else { + sourceFiles = program.getSourceFiles(); + } + + return FindAllReferences.findReferencedEntries(program, cancellationToken, sourceFiles, getValidSourceFile(fileName), position, options); } function findReferences(fileName: string, position: number): ReferencedSymbol[] { @@ -2100,7 +2113,7 @@ namespace ts { isLiteralComputedPropertyDeclarationName(node); } - function isObjectLiteralElement(node: Node): node is ObjectLiteralElement { + function isObjectLiteralElement(node: Node): node is ObjectLiteralElement { switch (node.kind) { case SyntaxKind.JsxAttribute: case SyntaxKind.JsxSpreadAttribute: @@ -2125,7 +2138,7 @@ namespace ts { if (node.parent.kind === SyntaxKind.ComputedPropertyName) { return isObjectLiteralElement(node.parent.parent) ? node.parent.parent : undefined; } - // falls through + // falls through case SyntaxKind.Identifier: return isObjectLiteralElement(node.parent) && (node.parent.parent.kind === SyntaxKind.ObjectLiteralExpression || node.parent.parent.kind === SyntaxKind.JsxAttributes) && From 675b6fb90ce3b8e659a6acc4f161a64cb31b111a Mon Sep 17 00:00:00 2001 From: Armando Aguirre Date: Tue, 25 Jul 2017 16:29:08 -0700 Subject: [PATCH 037/370] Fixed failing tests and lint. Added unit tests. --- src/services/services.ts | 9 +++++---- tests/cases/fourslash/renameDefaultLibDontWork.ts | 11 +++++++++++ 2 files changed, 16 insertions(+), 4 deletions(-) create mode 100644 tests/cases/fourslash/renameDefaultLibDontWork.ts diff --git a/src/services/services.ts b/src/services/services.ts index 998a5d36898..2a1b0bf4eb0 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -1511,15 +1511,16 @@ namespace ts { function getReferences(fileName: string, position: number, options?: FindAllReferences.Options) { synchronizeHostData(); - //Exclude default library when renaming as commonly user don't want to change that file. + // Exclude default library when renaming as commonly user don't want to change that file. let sourceFiles: SourceFile[] = []; - if (options.isForRename) { - for (let sourceFile of program.getSourceFiles()) { + if (options && options.isForRename) { + for (const sourceFile of program.getSourceFiles()) { if (!program.isSourceFileDefaultLibrary(sourceFile)) { sourceFiles.push(sourceFile); } } - } else { + } + else { sourceFiles = program.getSourceFiles(); } diff --git a/tests/cases/fourslash/renameDefaultLibDontWork.ts b/tests/cases/fourslash/renameDefaultLibDontWork.ts new file mode 100644 index 00000000000..5d2cfb43eb4 --- /dev/null +++ b/tests/cases/fourslash/renameDefaultLibDontWork.ts @@ -0,0 +1,11 @@ +/// + +// Tests that tokens found on the default library are not renamed. +// "test" is a comment on the default library. + +// @Filename: file1.ts +//// var [|test|] = "foo"; +//// console.log([|test|]); + +const ranges = test.ranges(); +verify.renameLocations(ranges[0], { findInComments: true, ranges }); \ No newline at end of file From 88262dbeb0dfb60af0e27735c10c5a8d9e7b3e27 Mon Sep 17 00:00:00 2001 From: Armando Aguirre Date: Mon, 14 Aug 2017 18:19:43 -0700 Subject: [PATCH 038/370] Changed check for default library by first checking hasNoDefaultLib, second library path and third name of file. --- src/compiler/program.ts | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/src/compiler/program.ts b/src/compiler/program.ts index 55edb377373..25a526ddaf4 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -436,6 +436,7 @@ namespace ts { host = host || createCompilerHost(options); let skipDefaultLib = options.noLib; + const defaultLibraryPath = host.getDefaultLibLocation ? host.getDefaultLibLocation() : getDirectoryPath(host.getDefaultLibFileName(options)); const programDiagnostics = createDiagnosticCollection(); const currentDirectory = host.getCurrentDirectory(); const supportedExtensions = getSupportedExtensions(options); @@ -977,7 +978,15 @@ namespace ts { } function isSourceFileDefaultLibrary(file: SourceFile): boolean { - return file.fileName === host.getDefaultLibFileName(options); + if (file.hasNoDefaultLib) { + return true; + } + + if (defaultLibraryPath !== undefined && defaultLibraryPath.length !== 0) { + return comparePaths(defaultLibraryPath, file.path, currentDirectory, /*ignoreCase*/ true) === Comparison.EqualTo; + } + + return compareStrings(file.fileName, host.getDefaultLibFileName(options), /*ignoreCase*/ true) === Comparison.EqualTo; } function getDiagnosticsProducingTypeChecker() { @@ -1209,7 +1218,7 @@ namespace ts { diagnostics.push(createDiagnosticForNode(node, Diagnostics._0_can_only_be_used_in_a_ts_file, "?")); return; } - // falls through + // falls through case SyntaxKind.MethodDeclaration: case SyntaxKind.MethodSignature: case SyntaxKind.Constructor: @@ -1291,7 +1300,7 @@ namespace ts { diagnostics.push(createDiagnosticForNodeArray(nodes, Diagnostics.type_parameter_declarations_can_only_be_used_in_a_ts_file)); return; } - // falls through + // falls through case SyntaxKind.VariableStatement: // Check modifiers if (nodes === (parent).modifiers) { @@ -1339,8 +1348,8 @@ namespace ts { if (isConstValid) { continue; } - // to report error, - // falls through + // to report error, + // falls through case SyntaxKind.PublicKeyword: case SyntaxKind.PrivateKeyword: case SyntaxKind.ProtectedKeyword: @@ -1556,10 +1565,10 @@ namespace ts { } function getSourceFileFromReferenceWorker( - fileName: string, - getSourceFile: (fileName: string) => SourceFile | undefined, - fail?: (diagnostic: DiagnosticMessage, ...argument: string[]) => void, - refFile?: SourceFile): SourceFile | undefined { + fileName: string, + getSourceFile: (fileName: string) => SourceFile | undefined, + fail?: (diagnostic: DiagnosticMessage, ...argument: string[]) => void, + refFile?: SourceFile): SourceFile | undefined { if (hasExtension(fileName)) { if (!options.allowNonTsExtensions && !forEach(supportedExtensions, extension => fileExtensionIs(host.getCanonicalFileName(fileName), extension))) { From a51397e339c35cf8466460ee014c7100ea266c95 Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Mon, 14 Aug 2017 21:24:30 -0400 Subject: [PATCH 039/370] Just track the local names of identifiers instead of ever using symbols. --- src/compiler/transformers/ts.ts | 47 +++++++++++++++++++++------------ src/compiler/types.ts | 2 +- 2 files changed, 31 insertions(+), 18 deletions(-) diff --git a/src/compiler/transformers/ts.ts b/src/compiler/transformers/ts.ts index 89693c0d22a..df070827667 100644 --- a/src/compiler/transformers/ts.ts +++ b/src/compiler/transformers/ts.ts @@ -151,7 +151,17 @@ namespace ts { break; } - recordEmittedDeclarationInScope(node); + // Record these declarations provided that they have a name. + if ((node as ClassDeclaration | FunctionDeclaration).name) { + recordEmittedDeclarationInScope(node as ClassDeclaration | FunctionDeclaration); + } + else { + // These nodes should always have names unless they are default-exports; + // however, class declaration parsing allows for undefined names, so syntactically invalid + // programs may also have an undefined name. + Debug.assert(node.kind === SyntaxKind.ClassDeclaration || hasModifier(node, ModifierFlags.Default)); + } + break; } } @@ -2640,16 +2650,14 @@ namespace ts { * Records that a declaration was emitted in the current scope, if it was the first * declaration for the provided symbol. */ - function recordEmittedDeclarationInScope(node: Node) { - const name = node.symbol && node.symbol.escapedName; - if (name) { - if (!currentScopeFirstDeclarationsOfName) { - currentScopeFirstDeclarationsOfName = createUnderscoreEscapedMap(); - } + function recordEmittedDeclarationInScope(node: FunctionDeclaration | ClassDeclaration | ModuleDeclaration | EnumDeclaration) { + if (!currentScopeFirstDeclarationsOfName) { + currentScopeFirstDeclarationsOfName = createUnderscoreEscapedMap(); + } - if (!currentScopeFirstDeclarationsOfName.has(name)) { - currentScopeFirstDeclarationsOfName.set(name, node); - } + const name = declaredNameInScope(node); + if (!currentScopeFirstDeclarationsOfName.has(name)) { + currentScopeFirstDeclarationsOfName.set(name, node); } } @@ -2658,20 +2666,25 @@ namespace ts { * the same name emitted in the current scope. Only returns false if we are absolutely * certain a previous declaration has been emitted. */ - function isPotentiallyFirstEmittedDeclarationInScope(node: Node) { + function isFirstEmittedDeclarationInScope(node: ModuleDeclaration | EnumDeclaration) { // If the node has a named symbol, then we have enough knowledge to determine // whether a prior declaration has been emitted. if (currentScopeFirstDeclarationsOfName) { - const name = node.symbol && node.symbol.escapedName; - if (name) { - return currentScopeFirstDeclarationsOfName.get(name) === node; - } + const name = declaredNameInScope(node); + return currentScopeFirstDeclarationsOfName.get(name) === node; } // Otherwise, we can't be sure. For example, this node could be synthetic. return true; } + function declaredNameInScope(node: FunctionDeclaration | ClassDeclaration | ModuleDeclaration | EnumDeclaration): __String { + if (node.name.kind !== SyntaxKind.Identifier) { + Debug.fail(formatSyntaxKind(node.kind) + " should have an identifier name."); + } + return (node.name as Identifier).escapedText; + } + /** * Adds a leading VariableStatement for a enum or module declaration. */ @@ -2691,7 +2704,7 @@ namespace ts { setOriginalNode(statement, node); recordEmittedDeclarationInScope(node); - if (isPotentiallyFirstEmittedDeclarationInScope(node)) { + if (isFirstEmittedDeclarationInScope(node)) { // Adjust the source map emit to match the old emitter. if (node.kind === SyntaxKind.EnumDeclaration) { setSourceMapRange(statement.declarationList, node); @@ -2747,7 +2760,7 @@ namespace ts { return createNotEmittedStatement(node); } - Debug.assert(isIdentifier(node.name), "TypeScript module should have an Identifier name."); + Debug.assert(isIdentifier(node.name), "A TypeScript namespace should have an Identifier name."); enableSubstitutionForNamespaceExports(); const statements: Statement[] = []; diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 09f1b5cfcc5..b0580956a4b 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -2896,7 +2896,7 @@ namespace ts { export interface Symbol { flags: SymbolFlags; // Symbol flags - escapedName: __String; // Name of symbol + escapedName: __String; // Name of symbol declarations?: Declaration[]; // Declarations associated with this symbol valueDeclaration?: Declaration; // First value declaration of the symbol members?: SymbolTable; // Class, interface or literal instance members From 6e60a017bbc187d10c76ca7c392623f8b4060dd9 Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Mon, 14 Aug 2017 21:24:51 -0400 Subject: [PATCH 040/370] Accepted baselines. --- tests/baselines/reference/defaultExportsCannotMerge01.js | 1 - tests/baselines/reference/defaultExportsCannotMerge04.js | 1 - tests/baselines/reference/reservedWords2.js | 1 - .../transformsCorrectly.rewrittenNamespaceFollowingClass.js | 1 - ...ransformsCorrectly.synthesizedClassAndNamespaceCombination.js | 1 - 5 files changed, 5 deletions(-) diff --git a/tests/baselines/reference/defaultExportsCannotMerge01.js b/tests/baselines/reference/defaultExportsCannotMerge01.js index c7091371d36..9c433ce3a2b 100644 --- a/tests/baselines/reference/defaultExportsCannotMerge01.js +++ b/tests/baselines/reference/defaultExportsCannotMerge01.js @@ -36,7 +36,6 @@ function Decl() { return 0; } exports.default = Decl; -var Decl; (function (Decl) { Decl.x = 10; Decl.y = 20; diff --git a/tests/baselines/reference/defaultExportsCannotMerge04.js b/tests/baselines/reference/defaultExportsCannotMerge04.js index de32618d8cc..f8f375377eb 100644 --- a/tests/baselines/reference/defaultExportsCannotMerge04.js +++ b/tests/baselines/reference/defaultExportsCannotMerge04.js @@ -18,6 +18,5 @@ Object.defineProperty(exports, "__esModule", { value: true }); function Foo() { } exports.default = Foo; -var Foo; (function (Foo) { })(Foo || (Foo = {})); diff --git a/tests/baselines/reference/reservedWords2.js b/tests/baselines/reference/reservedWords2.js index da6a35bba82..f172f37d053 100644 --- a/tests/baselines/reference/reservedWords2.js +++ b/tests/baselines/reference/reservedWords2.js @@ -35,7 +35,6 @@ debugger; if () ; [1, 2]; -var ; (function () { })( || ( = {})); void {}; diff --git a/tests/baselines/reference/transformApi/transformsCorrectly.rewrittenNamespaceFollowingClass.js b/tests/baselines/reference/transformApi/transformsCorrectly.rewrittenNamespaceFollowingClass.js index 9dedde29f8b..3f2dd6cdb56 100644 --- a/tests/baselines/reference/transformApi/transformsCorrectly.rewrittenNamespaceFollowingClass.js +++ b/tests/baselines/reference/transformApi/transformsCorrectly.rewrittenNamespaceFollowingClass.js @@ -4,7 +4,6 @@ class C { } } C.bar = 20; -var C; (function (C) { C.x = 10; })(C || (C = {})); diff --git a/tests/baselines/reference/transformApi/transformsCorrectly.synthesizedClassAndNamespaceCombination.js b/tests/baselines/reference/transformApi/transformsCorrectly.synthesizedClassAndNamespaceCombination.js index ad11068a512..ababb49d717 100644 --- a/tests/baselines/reference/transformApi/transformsCorrectly.synthesizedClassAndNamespaceCombination.js +++ b/tests/baselines/reference/transformApi/transformsCorrectly.synthesizedClassAndNamespaceCombination.js @@ -1,6 +1,5 @@ class Foo { } -var Foo; (function (Foo) { ; })(Foo || (Foo = {})); From 4fc9831a439b39eda5809b227838dcc20536a0ac Mon Sep 17 00:00:00 2001 From: Ryan Cavanaugh Date: Tue, 15 Aug 2017 10:35:15 -0700 Subject: [PATCH 041/370] Filter + log undefined elements from the codeActions array --- src/services/codeFixProvider.ts | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/services/codeFixProvider.ts b/src/services/codeFixProvider.ts index 6ff78572f82..13e11ed4674 100644 --- a/src/services/codeFixProvider.ts +++ b/src/services/codeFixProvider.ts @@ -36,12 +36,19 @@ namespace ts { export function getFixes(context: CodeFixContext): CodeAction[] { const fixes = codeFixes[context.errorCode]; - let allActions: CodeAction[] = []; + const allActions: CodeAction[] = []; forEach(fixes, f => { const actions = f.getCodeActions(context); if (actions && actions.length > 0) { - allActions = allActions.concat(actions); + for (const action of actions) { + if (action === undefined) { + context.host.log(`Action for error code ${context.errorCode} added an invalid action entry; please log a bug`); + } + else { + allActions.push(action); + } + } } }); From b2188ad66c03e575c5bfd13314add12677e26ad3 Mon Sep 17 00:00:00 2001 From: Arthur Ozga Date: Mon, 14 Aug 2017 16:43:20 -0700 Subject: [PATCH 042/370] cleanup --- src/services/formatting/formatting.ts | 31 +++++++++++++++++++++------ 1 file changed, 24 insertions(+), 7 deletions(-) diff --git a/src/services/formatting/formatting.ts b/src/services/formatting/formatting.ts index fbda42d3840..13a7f466f46 100644 --- a/src/services/formatting/formatting.ts +++ b/src/services/formatting/formatting.ts @@ -1164,10 +1164,15 @@ namespace ts.formatting { const { column, character } = SmartIndenter.findFirstNonWhitespaceCharacterAndColumn(commentLineStart, commentStart, sourceFile, options); return column + /*length after whitespace ends*/ range.pos - (commentLineStart + character); } - return undefined; + return -1; } - export function getRangeOfEnclosingComment(sourceFile: SourceFile, position: number, onlyMultiLine: boolean): CommentRange | undefined { + export function getRangeOfEnclosingComment( + sourceFile: SourceFile, + position: number, + onlyMultiLine: boolean, + tokenAtPosition = getTokenAtPosition(sourceFile, position, /*includeJsDocComment*/ false), + predicate?: (c: CommentRange) => boolean): CommentRange | undefined { // Considering a fixed position, // - trailing comments are those following and on the same line as the position. // - leading comments are those in the range [position, start of next non-trivia token) @@ -1178,16 +1183,28 @@ namespace ts.formatting { // tokens contain all comments in a sourcefile disjointly. const precedingToken = findPrecedingToken(position, sourceFile); const trailingRangesOfPreviousToken = precedingToken && getTrailingCommentRanges(sourceFile.text, precedingToken.end); - const leadingCommentRangesOfNextToken = getLeadingCommentRangesOfNode(getTokenAtPosition(sourceFile, position, /*includeJsDocComment*/ false), sourceFile); + const leadingCommentRangesOfNextToken = getLeadingCommentRangesOfNode(tokenAtPosition, sourceFile); const commentRanges = trailingRangesOfPreviousToken && leadingCommentRangesOfNextToken ? trailingRangesOfPreviousToken.concat(leadingCommentRangesOfNextToken) : trailingRangesOfPreviousToken || leadingCommentRangesOfNextToken; if (commentRanges) { for (const range of commentRanges) { - // We need to extend the range when in an unclosed multi-line comment. - if (range.pos < position && position < range.end || - position === range.end && (range.kind === SyntaxKind.SingleLineCommentTrivia || position === sourceFile.getFullWidth())) { - return onlyMultiLine && range.kind !== SyntaxKind.MultiLineCommentTrivia ? undefined : range; + // The end marker of a single-line comment does not include the newline character. + // With caret at `^`, in the following case, we are inside a comment (^ denotes the cursor position): + // + // // asdf ^\n + // + // But for closed multi-line comments, we don't want to be inside the comment in the following case: + // + // /* asdf */^ + // + // However, unterminated multi-line comments *do* contain their end. + // + // Internally, we represent the end of the comment at the newline and closing '/', respectively. + // + if ((range.pos < position && position < range.end || + position === range.end && (range.kind === SyntaxKind.SingleLineCommentTrivia || position === sourceFile.getFullWidth()))) { + return (range.kind === SyntaxKind.MultiLineCommentTrivia || !onlyMultiLine) && (!predicate || predicate(range)) ? range : undefined; } } } From 472ad9d3131c2738c4400e22f8696bad1522f342 Mon Sep 17 00:00:00 2001 From: Arthur Ozga Date: Mon, 14 Aug 2017 16:43:31 -0700 Subject: [PATCH 043/370] findPrevious changes --- src/services/utilities.ts | 64 +++++++++++---------------------------- 1 file changed, 18 insertions(+), 46 deletions(-) diff --git a/src/services/utilities.ts b/src/services/utilities.ts index a5b035154be..c5b2a2b4f90 100644 --- a/src/services/utilities.ts +++ b/src/services/utilities.ts @@ -742,18 +742,18 @@ namespace ts { const children = n.getChildren(); for (let i = 0; i < children.length; i++) { const child = children[i]; - // 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)) { + // Note that the span of a node's tokens is [node.getStart(...), node.end). + // Given that `position < child.end` and child has constiutent tokens*, we distinguish these cases: + // 1) `position` precedes `child`'s tokens or `child` has no tokens (ie: in a comment or whitespace preceding `child`): + // we need to find the last token in a previous child. + // 2) `position` is within the same span: we recurse on `child`. + // * JsxText is exceptional in that its tokens are (non-trivia) whitespace, which we do not want to return. + // TODO(arozga): shouldn't `findRightmost...` need to handle JsxText? + if (position < child.end) { const start = child.getStart(sourceFile, includeJsDoc); const lookInPreviousChild = (start >= position) || // cursor in the leading trivia + nodeHasTokens(child) || (child.kind === SyntaxKind.JsxText && start === child.end); // whitespace only JsxText if (lookInPreviousChild) { @@ -768,7 +768,7 @@ namespace ts { } } - Debug.assert(startNode !== undefined || n.kind === SyntaxKind.SourceFile || isJSDocCommentContainingNode(n)); + Debug.assert(startNode !== undefined || n.kind === SyntaxKind.SourceFile || isJSDocCommentContainingNode(n) || n.kind === SyntaxKind.JsxSelfClosingElement); // Here we know that none of child token nodes embrace the position, // the only known case is when position is at the end of the file. @@ -780,7 +780,9 @@ namespace ts { } } - /// finds last node that is considered as candidate for search (isCandidate(node) === true) starting from 'exclusiveStartPosition' + /** + * Finds the rightmost child to the left of `children[exclusiveStartPosition]` which has constituent tokens. + */ function findRightmostChildNodeWithTokens(children: Node[], exclusiveStartPosition: number): Node { for (let i = exclusiveStartPosition - 1; i >= 0; i--) { if (nodeHasTokens(children[i])) { @@ -863,41 +865,11 @@ namespace ts { * @param predicate Additional predicate to test on the comment range. */ export function isInComment( - sourceFile: SourceFile, - position: number, - tokenAtPosition = getTokenAtPosition(sourceFile, position, /*includeJsDocComment*/ false), - predicate?: (c: CommentRange) => boolean): boolean { - return position <= tokenAtPosition.getStart(sourceFile) && - (isInCommentRange(getLeadingCommentRanges(sourceFile.text, tokenAtPosition.pos)) || - isInCommentRange(getTrailingCommentRanges(sourceFile.text, tokenAtPosition.pos))); - - function isInCommentRange(commentRanges: CommentRange[]): boolean { - return forEach(commentRanges, c => isPositionInCommentRange(c, position, sourceFile.text) && (!predicate || predicate(c))); - } - } - - function isPositionInCommentRange({ pos, end, kind }: ts.CommentRange, position: number, text: string): boolean { - if (pos < position && position < end) { - return true; - } - else if (position === end) { - // The end marker of a single-line comment does not include the newline character. - // In the following case, we are inside a comment (^ denotes the cursor position): - // - // // asdf ^\n - // - // But for multi-line comments, we don't want to be inside the comment in the following case: - // - // /* asdf */^ - // - // Internally, we represent the end of the comment at the newline and closing '/', respectively. - return kind === SyntaxKind.SingleLineCommentTrivia || - // true for unterminated multi-line comment - !(text.charCodeAt(end - 1) === CharacterCodes.slash && text.charCodeAt(end - 2) === CharacterCodes.asterisk); - } - else { - return false; - } + sourceFile: SourceFile, + position: number, + tokenAtPosition = getTokenAtPosition(sourceFile, position, /*includeJsDocComment*/ false), + predicate?: (c: CommentRange) => boolean): boolean { + return !!formatting.getRangeOfEnclosingComment(sourceFile, position, /*onlyMultiLine*/ false, tokenAtPosition, predicate); } export function hasDocComment(sourceFile: SourceFile, position: number) { From f3e0cbbd526b4975c342a936cfb328a19dccd6a2 Mon Sep 17 00:00:00 2001 From: Arthur Ozga Date: Tue, 15 Aug 2017 11:26:47 -0700 Subject: [PATCH 044/370] `findPrecedingToken` handles EOF child more gracefully --- src/services/services.ts | 2 +- src/services/utilities.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/services/services.ts b/src/services/services.ts index 24e85a2a019..c623fe15b02 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -113,7 +113,7 @@ namespace ts { } pos = textPos; if (token === SyntaxKind.EndOfFileToken) { - return pos; + break; } } return pos; diff --git a/src/services/utilities.ts b/src/services/utilities.ts index c5b2a2b4f90..5336d47c1f3 100644 --- a/src/services/utilities.ts +++ b/src/services/utilities.ts @@ -753,7 +753,7 @@ namespace ts { const start = child.getStart(sourceFile, includeJsDoc); const lookInPreviousChild = (start >= position) || // cursor in the leading trivia - nodeHasTokens(child) || + !nodeHasTokens(child) || (child.kind === SyntaxKind.JsxText && start === child.end); // whitespace only JsxText if (lookInPreviousChild) { From a209db7bb62b8ab99675d0a7a2047d1a2915f436 Mon Sep 17 00:00:00 2001 From: Arthur Ozga Date: Tue, 15 Aug 2017 12:00:15 -0700 Subject: [PATCH 045/370] dont compute preceding token twice --- src/services/formatting/formatting.ts | 11 ++++++++--- src/services/formatting/smartIndenter.ts | 4 ++-- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/services/formatting/formatting.ts b/src/services/formatting/formatting.ts index 13a7f466f46..c34585c5bca 100644 --- a/src/services/formatting/formatting.ts +++ b/src/services/formatting/formatting.ts @@ -1155,9 +1155,11 @@ namespace ts.formatting { /** * Gets the indentation level of the multi-line comment enclosing position, * and a negative value if the position is not in a multi-line comment. + * + * @param precedingToken Must be the result of `findPrecedingToken(position, sourceFile)`. */ - export function getIndentationOfEnclosingMultiLineComment(sourceFile: SourceFile, position: number, options: EditorSettings): number { - const range = getRangeOfEnclosingComment(sourceFile, position, /*onlyMultiLine*/ true); + export function getIndentationOfEnclosingMultiLineComment(sourceFile: SourceFile, position: number, precedingToken: Node | undefined, options: EditorSettings): number { + const range = getRangeOfEnclosingComment(sourceFile, position, /*onlyMultiLine*/ true, precedingToken || null); // tslint:disable-line:no-null-keyword if (range) { const commentStart = range.pos; const commentLineStart = getLineStartPositionForPosition(commentStart, sourceFile); @@ -1167,10 +1169,14 @@ namespace ts.formatting { return -1; } + /** + * @param precedingToken pass `null` if preceding token was already computed and result was `undefined`. + */ export function getRangeOfEnclosingComment( sourceFile: SourceFile, position: number, onlyMultiLine: boolean, + precedingToken: Node | null | undefined = findPrecedingToken(position, sourceFile), // tslint:disable-line:no-null-keyword tokenAtPosition = getTokenAtPosition(sourceFile, position, /*includeJsDocComment*/ false), predicate?: (c: CommentRange) => boolean): CommentRange | undefined { // Considering a fixed position, @@ -1181,7 +1187,6 @@ namespace ts.formatting { // Note, `node.start` is the start-position of the first comment following the previous // token that is not a trailing comment, so the leading and trailing comments of all // tokens contain all comments in a sourcefile disjointly. - const precedingToken = findPrecedingToken(position, sourceFile); const trailingRangesOfPreviousToken = precedingToken && getTrailingCommentRanges(sourceFile.text, precedingToken.end); const leadingCommentRangesOfNextToken = getLeadingCommentRangesOfNode(tokenAtPosition, sourceFile); const commentRanges = trailingRangesOfPreviousToken && leadingCommentRangesOfNextToken ? diff --git a/src/services/formatting/smartIndenter.ts b/src/services/formatting/smartIndenter.ts index b0d58ddad12..c868ce04847 100644 --- a/src/services/formatting/smartIndenter.ts +++ b/src/services/formatting/smartIndenter.ts @@ -31,12 +31,12 @@ namespace ts.formatting { return 0; } - const indentationOfEnclosingMultiLineComment = getIndentationOfEnclosingMultiLineComment(sourceFile, position, options); + const precedingToken = findPrecedingToken(position, sourceFile); + const indentationOfEnclosingMultiLineComment = getIndentationOfEnclosingMultiLineComment(sourceFile, position, precedingToken, options); if (indentationOfEnclosingMultiLineComment >= 0) { return indentationOfEnclosingMultiLineComment; } - const precedingToken = findPrecedingToken(position, sourceFile); if (!precedingToken) { return getBaseIndentation(options); } From a08d18af579b0c492e98dd2d9c16358c1c3b2d67 Mon Sep 17 00:00:00 2001 From: Arthur Ozga Date: Tue, 15 Aug 2017 12:01:43 -0700 Subject: [PATCH 046/370] consolidate isInComment and getRangeOfEnclosingComment --- src/services/utilities.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/services/utilities.ts b/src/services/utilities.ts index 5336d47c1f3..160ef6db451 100644 --- a/src/services/utilities.ts +++ b/src/services/utilities.ts @@ -867,9 +867,9 @@ namespace ts { export function isInComment( sourceFile: SourceFile, position: number, - tokenAtPosition = getTokenAtPosition(sourceFile, position, /*includeJsDocComment*/ false), + tokenAtPosition?: Node, predicate?: (c: CommentRange) => boolean): boolean { - return !!formatting.getRangeOfEnclosingComment(sourceFile, position, /*onlyMultiLine*/ false, tokenAtPosition, predicate); + return !!formatting.getRangeOfEnclosingComment(sourceFile, position, /*onlyMultiLine*/ false, /*precedingToken*/ undefined, tokenAtPosition, predicate); } export function hasDocComment(sourceFile: SourceFile, position: number) { From 281d821fe812f171ae94fa77503514ec0edb8521 Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Tue, 15 Aug 2017 12:16:54 -0700 Subject: [PATCH 047/370] Fix lint errors. --- src/harness/unittests/transform.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/harness/unittests/transform.ts b/src/harness/unittests/transform.ts index 6edd174da23..27e41a96dfc 100644 --- a/src/harness/unittests/transform.ts +++ b/src/harness/unittests/transform.ts @@ -116,11 +116,11 @@ namespace ts { return (sourceFile: ts.SourceFile) => { const result = getMutableClone(sourceFile); result.statements = ts.createNodeArray([ - ts.createClassDeclaration(undefined, undefined, "Foo", undefined, undefined, undefined), - ts.createModuleDeclaration(undefined, undefined, createIdentifier("Foo"), createModuleBlock([createEmptyStatement()])) + ts.createClassDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, "Foo", /*typeParameters*/ undefined, /*heritageClauses*/ undefined, /*members*/ undefined), + ts.createModuleDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, createIdentifier("Foo"), createModuleBlock([createEmptyStatement()])) ]); return result; - } + }; } }); From b07fd3e1809fcde8f8360349b913cedf838181d9 Mon Sep 17 00:00:00 2001 From: Paul van Brenk Date: Tue, 15 Aug 2017 12:27:02 -0700 Subject: [PATCH 048/370] Fix linter issues --- src/server/editorServices.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/server/editorServices.ts b/src/server/editorServices.ts index 6d0f8d41e61..19953c9a79b 100644 --- a/src/server/editorServices.ts +++ b/src/server/editorServices.ts @@ -241,14 +241,14 @@ namespace ts.server { getFileName: x => x, getScriptKind: _ => undefined, hasMixedContent: (fileName, extraFileExtensions) => some(extraFileExtensions, ext => ext.isMixedContent && fileExtensionIs(fileName, ext.extension)), - isDynamicFile: x => x[0] == '^', + isDynamicFile: x => x[0] === "^", }; const externalFilePropertyReader: FilePropertyReader = { getFileName: x => x.fileName, getScriptKind: x => tryConvertScriptKindName(x.scriptKind), hasMixedContent: x => x.hasMixedContent, - isDynamicFile: x => x.fileName[0] == '^', + isDynamicFile: x => x.fileName[0] === "^", }; function findProjectByName(projectName: string, projects: T[]): T { From ad9c29b9281baed9d736adca0ffbf3d9634e2ccf Mon Sep 17 00:00:00 2001 From: Arthur Ozga Date: Tue, 15 Aug 2017 12:39:40 -0700 Subject: [PATCH 049/370] add test --- tests/cases/fourslash/formatOnEnterInComment.ts | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 tests/cases/fourslash/formatOnEnterInComment.ts diff --git a/tests/cases/fourslash/formatOnEnterInComment.ts b/tests/cases/fourslash/formatOnEnterInComment.ts new file mode 100644 index 00000000000..489eb6ac6ce --- /dev/null +++ b/tests/cases/fourslash/formatOnEnterInComment.ts @@ -0,0 +1,14 @@ +/// + +//// /** +//// * /*1*/ +//// */ + +goTo.marker("1"); +edit.insertLine(""); +verify.currentFileContentIs( +` /** + * + + */` +); \ No newline at end of file From 9dd574b1a92d02dc941a3160d92671281265161b Mon Sep 17 00:00:00 2001 From: Armando Aguirre Date: Tue, 15 Aug 2017 18:44:28 -0700 Subject: [PATCH 050/370] Added host.useCaseSens..., memoized getDefaultLibFileName. --- src/compiler/program.ts | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/compiler/program.ts b/src/compiler/program.ts index 25a526ddaf4..bc8f65b35cb 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -325,12 +325,12 @@ namespace ts { } output += sys.newLine; - output += `${ relativeFileName }(${ firstLine + 1 },${ firstLineChar + 1 }): `; + output += `${relativeFileName}(${firstLine + 1},${firstLineChar + 1}): `; } const categoryColor = getCategoryFormat(diagnostic.category); const category = DiagnosticCategory[diagnostic.category].toLowerCase(); - output += `${ formatAndReset(category, categoryColor) } TS${ diagnostic.code }: ${ flattenDiagnosticMessageText(diagnostic.messageText, sys.newLine) }`; + output += `${formatAndReset(category, categoryColor)} TS${diagnostic.code}: ${flattenDiagnosticMessageText(diagnostic.messageText, sys.newLine)}`; output += sys.newLine; } return output; @@ -436,7 +436,8 @@ namespace ts { host = host || createCompilerHost(options); let skipDefaultLib = options.noLib; - const defaultLibraryPath = host.getDefaultLibLocation ? host.getDefaultLibLocation() : getDirectoryPath(host.getDefaultLibFileName(options)); + const getDefaultLibraryFileName = memoize(() => host.getDefaultLibFileName(options)); + const defaultLibraryPath = host.getDefaultLibLocation ? host.getDefaultLibLocation() : getDirectoryPath(getDefaultLibraryFileName()); const programDiagnostics = createDiagnosticCollection(); const currentDirectory = host.getCurrentDirectory(); const supportedExtensions = getSupportedExtensions(options); @@ -512,12 +513,11 @@ namespace ts { // If '--lib' is not specified, include default library file according to '--target' // otherwise, using options specified in '--lib' instead of '--target' default library file if (!options.lib) { - processRootFile(host.getDefaultLibFileName(options), /*isDefaultLib*/ true); + processRootFile(getDefaultLibraryFileName(), /*isDefaultLib*/ true); } else { - const libDirectory = host.getDefaultLibLocation ? host.getDefaultLibLocation() : getDirectoryPath(host.getDefaultLibFileName(options)); forEach(options.lib, libFileName => { - processRootFile(combinePaths(libDirectory, libFileName), /*isDefaultLib*/ true); + processRootFile(combinePaths(defaultLibraryPath, libFileName), /*isDefaultLib*/ true); }); } } @@ -982,11 +982,11 @@ namespace ts { return true; } - if (defaultLibraryPath !== undefined && defaultLibraryPath.length !== 0) { - return comparePaths(defaultLibraryPath, file.path, currentDirectory, /*ignoreCase*/ true) === Comparison.EqualTo; + if (defaultLibraryPath && defaultLibraryPath.length !== 0) { + return containsPath(defaultLibraryPath, file.path, currentDirectory, /*ignoreCase*/ !host.useCaseSensitiveFileNames()); } - return compareStrings(file.fileName, host.getDefaultLibFileName(options), /*ignoreCase*/ true) === Comparison.EqualTo; + return compareStrings(file.fileName, getDefaultLibraryFileName(), /*ignoreCase*/ !host.useCaseSensitiveFileNames()) === Comparison.EqualTo; } function getDiagnosticsProducingTypeChecker() { From afdd77f1f6703c9974f5e65cfbca1700e391e59e Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Wed, 16 Aug 2017 10:41:49 -0700 Subject: [PATCH 051/370] Bump version to 2.6.0. --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index a114ac68a2d..66d22594377 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "typescript", "author": "Microsoft Corp.", "homepage": "http://typescriptlang.org/", - "version": "2.5.0", + "version": "2.6.0", "license": "Apache-2.0", "description": "TypeScript is a language for application scale JavaScript development", "keywords": [ From af68a61ba7204d767bb09d450d90f080c755bbcb Mon Sep 17 00:00:00 2001 From: Ryan Cavanaugh Date: Wed, 16 Aug 2017 11:50:00 -0700 Subject: [PATCH 052/370] Ignore scripts for types packages --- src/server/typingsInstaller/nodeTypingsInstaller.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/server/typingsInstaller/nodeTypingsInstaller.ts b/src/server/typingsInstaller/nodeTypingsInstaller.ts index de23b2649a6..f80b7a70df6 100644 --- a/src/server/typingsInstaller/nodeTypingsInstaller.ts +++ b/src/server/typingsInstaller/nodeTypingsInstaller.ts @@ -102,7 +102,7 @@ namespace ts.server.typingsInstaller { if (this.log.isEnabled()) { this.log.writeLine(`Updating ${TypesRegistryPackageName} npm package...`); } - this.execSync(`${this.npmPath} install ${TypesRegistryPackageName}`, { cwd: globalTypingsCacheLocation, stdio: "ignore" }); + this.execSync(`${this.npmPath} install --ignore-scripts ${TypesRegistryPackageName}`, { cwd: globalTypingsCacheLocation, stdio: "ignore" }); if (this.log.isEnabled()) { this.log.writeLine(`Updated ${TypesRegistryPackageName} npm package`); } @@ -152,7 +152,7 @@ namespace ts.server.typingsInstaller { if (this.log.isEnabled()) { this.log.writeLine(`#${requestId} with arguments'${JSON.stringify(args)}'.`); } - const command = `${this.npmPath} install ${args.join(" ")} --save-dev --user-agent="typesInstaller/${version}"`; + const command = `${this.npmPath} install --ignore-scripts ${args.join(" ")} --save-dev --user-agent="typesInstaller/${version}"`; const start = Date.now(); let stdout: Buffer; let stderr: Buffer; From 3f50f20d0aeeb08fb38b9357c6b97dd29807f3fd Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Wed, 16 Aug 2017 14:49:44 -0700 Subject: [PATCH 053/370] Updated version in 'src' as well. --- src/compiler/core.ts | 2 +- src/services/shims.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/compiler/core.ts b/src/compiler/core.ts index 728fb433c04..b55cbb16133 100644 --- a/src/compiler/core.ts +++ b/src/compiler/core.ts @@ -4,7 +4,7 @@ namespace ts { // WARNING: The script `configureNightly.ts` uses a regexp to parse out these values. // If changing the text in this section, be sure to test `configureNightly` too. - export const versionMajorMinor = "2.5"; + export const versionMajorMinor = "2.6"; /** The version of the TypeScript compiler release */ export const version = `${versionMajorMinor}.0`; } diff --git a/src/services/shims.ts b/src/services/shims.ts index b7c85d2ce82..4bfe3590082 100644 --- a/src/services/shims.ts +++ b/src/services/shims.ts @@ -1222,4 +1222,4 @@ namespace TypeScript.Services { // TODO: it should be moved into a namespace though. /* @internal */ -const toolsVersion = "2.5"; +const toolsVersion = "2.6"; From b7020628c14284dfcb1df8525ac61a22f945c0ab Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Wed, 16 Aug 2017 15:06:51 -0700 Subject: [PATCH 054/370] Addressed code review feedback. --- src/compiler/transformers/ts.ts | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/src/compiler/transformers/ts.ts b/src/compiler/transformers/ts.ts index df070827667..4c679ea1eee 100644 --- a/src/compiler/transformers/ts.ts +++ b/src/compiler/transformers/ts.ts @@ -2662,26 +2662,19 @@ namespace ts { } /** - * Determines whether a declaration is *could* be the first declaration with - * the same name emitted in the current scope. Only returns false if we are absolutely - * certain a previous declaration has been emitted. + * Determines whether a declaration is the first declaration with + * the same name emitted in the current scope. */ function isFirstEmittedDeclarationInScope(node: ModuleDeclaration | EnumDeclaration) { - // If the node has a named symbol, then we have enough knowledge to determine - // whether a prior declaration has been emitted. if (currentScopeFirstDeclarationsOfName) { const name = declaredNameInScope(node); return currentScopeFirstDeclarationsOfName.get(name) === node; } - - // Otherwise, we can't be sure. For example, this node could be synthetic. return true; } function declaredNameInScope(node: FunctionDeclaration | ClassDeclaration | ModuleDeclaration | EnumDeclaration): __String { - if (node.name.kind !== SyntaxKind.Identifier) { - Debug.fail(formatSyntaxKind(node.kind) + " should have an identifier name."); - } + Debug.assertNode(node.name, isIdentifier); return (node.name as Identifier).escapedText; } @@ -2760,7 +2753,7 @@ namespace ts { return createNotEmittedStatement(node); } - Debug.assert(isIdentifier(node.name), "A TypeScript namespace should have an Identifier name."); + Debug.assertNode(node.name, isIdentifier, "A TypeScript namespace should have an Identifier name."); enableSubstitutionForNamespaceExports(); const statements: Statement[] = []; From 153b94aeb4931437802d02e193be88f5240a1978 Mon Sep 17 00:00:00 2001 From: Arthur Ozga Date: Wed, 16 Aug 2017 15:28:47 -0700 Subject: [PATCH 055/370] `JsxText` has no leading comments --- src/compiler/utilities.ts | 2 +- .../fourslash/isInMultiLineCommentJsxText.ts | 27 +++++++++++++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) create mode 100644 tests/cases/fourslash/isInMultiLineCommentJsxText.ts diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index 76d242e8b08..8c82b9d26df 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -635,7 +635,7 @@ namespace ts { } export function getLeadingCommentRangesOfNode(node: Node, sourceFileOfNode: SourceFile) { - return getLeadingCommentRanges(sourceFileOfNode.text, node.pos); + return node.kind !== SyntaxKind.JsxText ? getLeadingCommentRanges(sourceFileOfNode.text, node.pos) : undefined; } export function getLeadingCommentRangesOfNodeFromText(node: Node, text: string) { diff --git a/tests/cases/fourslash/isInMultiLineCommentJsxText.ts b/tests/cases/fourslash/isInMultiLineCommentJsxText.ts new file mode 100644 index 00000000000..db88f6b9a55 --- /dev/null +++ b/tests/cases/fourslash/isInMultiLineCommentJsxText.ts @@ -0,0 +1,27 @@ +/// + +// @Filename: file.jsx +////
+//// // /*0*/ +//// /* /*1*/ */ +//// /** +//// * /*2*/ +//// */ +//// foo() /* /*3*/ */ +//// // /*4*/ +//// /* /*5*/ */ +//// /** +//// * /*6*/ +//// */ +////
+////
+//// // /*7*/ +//// /* /*8*/ */ +//// /** +//// * /*9*/ +//// */ + +for (let i = 0; i < 10; ++i) { + goTo.marker(i.toString()); + verify.not.isInCommentAtPosition(/*onlyMultiLine*/ false); +} From 70e4f346bb12ce773173a1d0edad2e3ca6632748 Mon Sep 17 00:00:00 2001 From: Arthur Ozga Date: Wed, 16 Aug 2017 17:35:14 -0700 Subject: [PATCH 056/370] update test --- .../fourslash/indentionsOfCommentBlockAfterFormatting.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/cases/fourslash/indentionsOfCommentBlockAfterFormatting.ts b/tests/cases/fourslash/indentionsOfCommentBlockAfterFormatting.ts index 3b686285b99..b965b314234 100644 --- a/tests/cases/fourslash/indentionsOfCommentBlockAfterFormatting.ts +++ b/tests/cases/fourslash/indentionsOfCommentBlockAfterFormatting.ts @@ -27,13 +27,13 @@ verify.indentationIs(4); goTo.marker("2"); verify.indentationIs(4); goTo.marker("3"); -verify.indentationIs(4); +verify.indentationIs(3); goTo.marker("4"); -verify.indentationIs(4); +verify.indentationIs(3); // Putting a marker in line "*" would bring some error when parsing code in automation. // So move right by 1 offset from marker 4 to locate the caret in this line. edit.moveRight(1); -verify.indentationIs(4); +verify.indentationIs(3); // Putting a marker in line " */" would bring some error when parsing code in automation. // So move left by 1 offset from marker 5 to locate the caret in this line. goTo.marker("5"); From 4b9f5a0f8fa7b1ef9bac8fc12b40479044ab9676 Mon Sep 17 00:00:00 2001 From: Arthur Ozga Date: Wed, 16 Aug 2017 17:36:39 -0700 Subject: [PATCH 057/370] rename tests --- ...rFormatting.ts => indentationInBlockCommentAfterFormatting.ts} | 0 ...ultiLineCommentJsxText.ts => isInMultiLineCommentInJsxText.ts} | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename tests/cases/fourslash/{indentionsOfCommentBlockAfterFormatting.ts => indentationInBlockCommentAfterFormatting.ts} (100%) rename tests/cases/fourslash/{isInMultiLineCommentJsxText.ts => isInMultiLineCommentInJsxText.ts} (100%) diff --git a/tests/cases/fourslash/indentionsOfCommentBlockAfterFormatting.ts b/tests/cases/fourslash/indentationInBlockCommentAfterFormatting.ts similarity index 100% rename from tests/cases/fourslash/indentionsOfCommentBlockAfterFormatting.ts rename to tests/cases/fourslash/indentationInBlockCommentAfterFormatting.ts diff --git a/tests/cases/fourslash/isInMultiLineCommentJsxText.ts b/tests/cases/fourslash/isInMultiLineCommentInJsxText.ts similarity index 100% rename from tests/cases/fourslash/isInMultiLineCommentJsxText.ts rename to tests/cases/fourslash/isInMultiLineCommentInJsxText.ts From 62f16bee557f2cb604a4399c67dea623fc455afe Mon Sep 17 00:00:00 2001 From: Arthur Ozga Date: Wed, 16 Aug 2017 17:36:50 -0700 Subject: [PATCH 058/370] add tests --- .../cases/fourslash/indentationInComments.ts | 32 ++++++++++++++++ .../isInMultiLineCommentInTemplateLiteral.ts | 27 +++++++++++++ .../isInMultiLineCommentOnlyTrivia.ts | 38 +++++++++++++++++++ 3 files changed, 97 insertions(+) create mode 100644 tests/cases/fourslash/indentationInComments.ts create mode 100644 tests/cases/fourslash/isInMultiLineCommentInTemplateLiteral.ts create mode 100644 tests/cases/fourslash/isInMultiLineCommentOnlyTrivia.ts diff --git a/tests/cases/fourslash/indentationInComments.ts b/tests/cases/fourslash/indentationInComments.ts new file mode 100644 index 00000000000..d54ec9daacb --- /dev/null +++ b/tests/cases/fourslash/indentationInComments.ts @@ -0,0 +1,32 @@ +/// + +//// // /*0_0*/ +//// /* /*0_1*/ +//// some text /*0_2*/ +//// some text /*1_0*/ +//// * some text /*0_3*/ +//// /*0_4*/ +//// */ +//// function foo() { +//// // /*4_0*/ +//// /** /*4_1*/ +//// * /*4_2*/ +//// * /*4_3*/ +//// /*7_0*/ +//// */ +//// /* /*4_4*/ */ +//// } + +for (let i = 0; i < 5; ++i) { + goTo.marker(`0_${i}`); + verify.indentationIs(0); + + goTo.marker(`4_${i}`); + verify.indentationIs(4); +} + +goTo.marker(`1_0`); +verify.indentationIs(1); + +goTo.marker(`7_0`); +verify.indentationIs(7); diff --git a/tests/cases/fourslash/isInMultiLineCommentInTemplateLiteral.ts b/tests/cases/fourslash/isInMultiLineCommentInTemplateLiteral.ts new file mode 100644 index 00000000000..ca6f11499da --- /dev/null +++ b/tests/cases/fourslash/isInMultiLineCommentInTemplateLiteral.ts @@ -0,0 +1,27 @@ +/// + +// @Filename: file.jsx +//// ` +//// // /*0*/ +//// /* /*1*/ */ +//// /** +//// * /*2*/ +//// */ +//// foo() +//// // /*3*/ +//// /* /*4*/ */ +//// /** +//// * /*5*/ +//// */ +//// ` +//// ` +//// // /*6*/ +//// /* /*7*/ */ +//// /** +//// * /*8*/ +//// */ + +for (let i = 0; i < 9; ++i) { + goTo.marker(i.toString()); + verify.not.isInCommentAtPosition(/*onlyMultiLine*/ false); +} \ No newline at end of file diff --git a/tests/cases/fourslash/isInMultiLineCommentOnlyTrivia.ts b/tests/cases/fourslash/isInMultiLineCommentOnlyTrivia.ts new file mode 100644 index 00000000000..e279af47699 --- /dev/null +++ b/tests/cases/fourslash/isInMultiLineCommentOnlyTrivia.ts @@ -0,0 +1,38 @@ +/// + +//// /* x */ +//// /** +//// * @param this doesn't make sense here. +//// */ +//// // x + +const firstCommentStart = 0; +const firstCommentEnd = 7; +goTo.position(firstCommentStart); +verify.not.isInCommentAtPosition(/*onlyMultiLine*/ true); + +goTo.position(firstCommentStart + 1); +verify.isInCommentAtPosition(/*onlyMultiLine*/ true); +goTo.position(firstCommentEnd - 1); +verify.isInCommentAtPosition(/*onlyMultiLine*/ true); + +goTo.position(firstCommentEnd); +verify.not.isInCommentAtPosition(/*onlyMultiLine*/ true); + +const multilineJsDocStart = firstCommentEnd + 1; +const multilineJsDocEnd = multilineJsDocStart + 49; + +goTo.position(multilineJsDocStart); +verify.not.isInCommentAtPosition(/*onlyMultiLine*/ true); +goTo.position(multilineJsDocStart + 1); +verify.isInCommentAtPosition(/*onlyMultiLine*/ true); +goTo.position(multilineJsDocEnd - 1); +verify.isInCommentAtPosition(/*onlyMultiLine*/ true); +goTo.position(multilineJsDocEnd); +verify.not.isInCommentAtPosition(/*onlyMultiLine*/ true); + +const singleLineCommentStart = multilineJsDocEnd + 1; + +goTo.position(singleLineCommentStart + 1); +verify.not.isInCommentAtPosition(/*onlyMultiLine*/ true); +verify.isInCommentAtPosition(/*onlyMultiLine*/ false); \ No newline at end of file From 23ca368020548d4a9b6d56e6719c5eb86cdcd68f Mon Sep 17 00:00:00 2001 From: Arthur Ozga Date: Wed, 16 Aug 2017 17:51:29 -0700 Subject: [PATCH 059/370] Use simpler indentation for comments * When in a multi-line comment, we would have liked to use the start of the comment as a reference point for the indentation inside the comment, but determining the number of columns shifted for the comment start woudl require determining the length w/r/t graphemes, which we do not currently implement. We would like to avoid taking on a runtime dependency on a grapheme-parsing library. Instead, we look at the indentation level on the previoud line or start of the comment as a reference point, and correct shift for lines starting with an asterisk. --- src/services/formatting/formatting.ts | 17 ---------------- src/services/formatting/smartIndenter.ts | 25 +++++++++++++++++++++--- 2 files changed, 22 insertions(+), 20 deletions(-) diff --git a/src/services/formatting/formatting.ts b/src/services/formatting/formatting.ts index c34585c5bca..22602d6031c 100644 --- a/src/services/formatting/formatting.ts +++ b/src/services/formatting/formatting.ts @@ -1152,23 +1152,6 @@ namespace ts.formatting { } } - /** - * Gets the indentation level of the multi-line comment enclosing position, - * and a negative value if the position is not in a multi-line comment. - * - * @param precedingToken Must be the result of `findPrecedingToken(position, sourceFile)`. - */ - export function getIndentationOfEnclosingMultiLineComment(sourceFile: SourceFile, position: number, precedingToken: Node | undefined, options: EditorSettings): number { - const range = getRangeOfEnclosingComment(sourceFile, position, /*onlyMultiLine*/ true, precedingToken || null); // tslint:disable-line:no-null-keyword - if (range) { - const commentStart = range.pos; - const commentLineStart = getLineStartPositionForPosition(commentStart, sourceFile); - const { column, character } = SmartIndenter.findFirstNonWhitespaceCharacterAndColumn(commentLineStart, commentStart, sourceFile, options); - return column + /*length after whitespace ends*/ range.pos - (commentLineStart + character); - } - return -1; - } - /** * @param precedingToken pass `null` if preceding token was already computed and result was `undefined`. */ diff --git a/src/services/formatting/smartIndenter.ts b/src/services/formatting/smartIndenter.ts index c868ce04847..5af93bc025f 100644 --- a/src/services/formatting/smartIndenter.ts +++ b/src/services/formatting/smartIndenter.ts @@ -32,9 +32,28 @@ namespace ts.formatting { } const precedingToken = findPrecedingToken(position, sourceFile); - const indentationOfEnclosingMultiLineComment = getIndentationOfEnclosingMultiLineComment(sourceFile, position, precedingToken, options); - if (indentationOfEnclosingMultiLineComment >= 0) { - return indentationOfEnclosingMultiLineComment; + + const enclosingCommentRange = getRangeOfEnclosingComment(sourceFile, position, /*onlyMultiLine*/ true, precedingToken || null); // tslint:disable-line:no-null-keyword + if (enclosingCommentRange) { + const previousLine = getLineAndCharacterOfPosition(sourceFile, position).line - 1; + const commentStartLine = getLineAndCharacterOfPosition(sourceFile, enclosingCommentRange.pos).line; + + Debug.assert(commentStartLine >= 0); + + if (previousLine <= commentStartLine) { + return findFirstNonWhitespaceColumn(getStartPositionOfLine(commentStartLine, sourceFile), position, sourceFile, options); + } + + // get first character of previous line -- if it is '*', move back one more character (or stay at 0) + const startPostionOfLine = getStartPositionOfLine(previousLine, sourceFile); + const { column, character } = findFirstNonWhitespaceCharacterAndColumn(startPostionOfLine, position, sourceFile, options); + + if (column === 0) { + return column; + } + + const firstNonWhitespaceCharacterCode = sourceFile.text.charCodeAt(startPostionOfLine + character); + return firstNonWhitespaceCharacterCode === CharacterCodes.asterisk ? column - 1 : column; } if (!precedingToken) { From b7bc7d889ec432cea7c9a681ed284eb6162f3baf Mon Sep 17 00:00:00 2001 From: Arthur Ozga Date: Wed, 16 Aug 2017 17:56:20 -0700 Subject: [PATCH 060/370] clarify `JsxText` handling --- src/services/utilities.ts | 32 +++++++++++++++++++++++--------- 1 file changed, 23 insertions(+), 9 deletions(-) diff --git a/src/services/utilities.ts b/src/services/utilities.ts index 160ef6db451..2ee46c28ca9 100644 --- a/src/services/utilities.ts +++ b/src/services/utilities.ts @@ -720,8 +720,14 @@ namespace ts { } } - export function findPrecedingToken(position: number, sourceFile: SourceFile, startNode?: Node, includeJsDoc?: boolean): Node { - return find(startNode || sourceFile); + /** + * Finds the rightmost token satisfying `token.end <= position`, + * excluding `JsxText` tokens containing only whitespace. + */ + export function findPrecedingToken(position: number, sourceFile: SourceFile, startNode?: Node, includeJsDoc?: boolean): Node | undefined { + const result = find(startNode || sourceFile); + Debug.assert(!(result && isWhiteSpaceOnlyJsxText(result))); + return result; function findRightmostToken(n: Node): Node { if (isToken(n)) { @@ -743,18 +749,16 @@ namespace ts { for (let i = 0; i < children.length; i++) { const child = children[i]; // Note that the span of a node's tokens is [node.getStart(...), node.end). - // Given that `position < child.end` and child has constiutent tokens*, we distinguish these cases: + // Given that `position < child.end` and child has constituent tokens, we distinguish these cases: // 1) `position` precedes `child`'s tokens or `child` has no tokens (ie: in a comment or whitespace preceding `child`): // we need to find the last token in a previous child. // 2) `position` is within the same span: we recurse on `child`. - // * JsxText is exceptional in that its tokens are (non-trivia) whitespace, which we do not want to return. - // TODO(arozga): shouldn't `findRightmost...` need to handle JsxText? if (position < child.end) { const start = child.getStart(sourceFile, includeJsDoc); const lookInPreviousChild = (start >= position) || // cursor in the leading trivia !nodeHasTokens(child) || - (child.kind === SyntaxKind.JsxText && start === child.end); // whitespace only JsxText + isWhiteSpaceOnlyJsxText(child); if (lookInPreviousChild) { // actual start of the node is past the position - previous token should be at the end of previous child @@ -781,11 +785,16 @@ namespace ts { } /** - * Finds the rightmost child to the left of `children[exclusiveStartPosition]` which has constituent tokens. + * Finds the rightmost child to the left of `children[exclusiveStartPosition]` which is a non-all-whitespace token or has constituent tokens. */ function findRightmostChildNodeWithTokens(children: Node[], exclusiveStartPosition: number): Node { for (let i = exclusiveStartPosition - 1; i >= 0; i--) { - if (nodeHasTokens(children[i])) { + const child = children[i]; + + if (isWhiteSpaceOnlyJsxText(child)) { + Debug.assert(i > 0, "`JsxText` tokens should not be the first child of `JsxElement | JsxSelfClosingElement`"); + } + else if (nodeHasTokens(children[i])) { return children[i]; } } @@ -853,6 +862,11 @@ namespace ts { return false; } + export function isWhiteSpaceOnlyJsxText(node: Node): node is JsxText { + return isJsxText(node) && node.containsOnlyWhiteSpaces; + } + + export function isInTemplateString(sourceFile: SourceFile, position: number) { const token = getTokenAtPosition(sourceFile, position, /*includeJsDocComment*/ false); return isTemplateLiteralKind(token.kind) && position > token.getStart(sourceFile); @@ -888,7 +902,7 @@ namespace ts { function nodeHasTokens(n: Node): boolean { // If we have a token or node that has a non-zero width, it must have tokens. - // Note, that getWidth() does not take trivia into account. + // Note: getWidth() does not take trivia into account. return n.getWidth() !== 0; } From 6029b5cce80fe2172273c9a253e230c5813dde09 Mon Sep 17 00:00:00 2001 From: Arthur Ozga Date: Wed, 16 Aug 2017 18:12:28 -0700 Subject: [PATCH 061/370] cleanup --- src/services/formatting/smartIndenter.ts | 1 - src/services/utilities.ts | 3 +-- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/src/services/formatting/smartIndenter.ts b/src/services/formatting/smartIndenter.ts index 5af93bc025f..4de2e5765e5 100644 --- a/src/services/formatting/smartIndenter.ts +++ b/src/services/formatting/smartIndenter.ts @@ -44,7 +44,6 @@ namespace ts.formatting { return findFirstNonWhitespaceColumn(getStartPositionOfLine(commentStartLine, sourceFile), position, sourceFile, options); } - // get first character of previous line -- if it is '*', move back one more character (or stay at 0) const startPostionOfLine = getStartPositionOfLine(previousLine, sourceFile); const { column, character } = findFirstNonWhitespaceCharacterAndColumn(startPostionOfLine, position, sourceFile, options); diff --git a/src/services/utilities.ts b/src/services/utilities.ts index ee099a50a73..e8f01bb0785 100644 --- a/src/services/utilities.ts +++ b/src/services/utilities.ts @@ -772,7 +772,7 @@ namespace ts { } } - Debug.assert(startNode !== undefined || n.kind === SyntaxKind.SourceFile || isJSDocCommentContainingNode(n) || n.kind === SyntaxKind.JsxSelfClosingElement); + Debug.assert(startNode !== undefined || n.kind === SyntaxKind.SourceFile || isJSDocCommentContainingNode(n)); // Here we know that none of child token nodes embrace the position, // the only known case is when position is at the end of the file. @@ -866,7 +866,6 @@ namespace ts { return isJsxText(node) && node.containsOnlyWhiteSpaces; } - export function isInTemplateString(sourceFile: SourceFile, position: number) { const token = getTokenAtPosition(sourceFile, position, /*includeJsDocComment*/ false); return isTemplateLiteralKind(token.kind) && position > token.getStart(sourceFile); From 760ef44c36e3dc6e4a88800fd094f925882ec94b Mon Sep 17 00:00:00 2001 From: Arthur Ozga Date: Wed, 16 Aug 2017 18:48:27 -0700 Subject: [PATCH 062/370] test if `onlyMultiLine` flag changes answer --- src/harness/fourslash.ts | 15 +++++++----- tests/cases/fourslash/fourslash.ts | 2 +- tests/cases/fourslash/isInMultiLineComment.ts | 23 +++++++++---------- .../isInMultiLineCommentInJsxText.ts | 2 +- .../isInMultiLineCommentInTemplateLiteral.ts | 2 +- .../isInMultiLineCommentOnlyTrivia.ts | 19 ++++++++------- 6 files changed, 32 insertions(+), 31 deletions(-) diff --git a/src/harness/fourslash.ts b/src/harness/fourslash.ts index f50ebcc3a14..32c9fb67da0 100644 --- a/src/harness/fourslash.ts +++ b/src/harness/fourslash.ts @@ -2508,16 +2508,19 @@ namespace FourSlash { } } - public verifySpanOfEnclosingComment(negative: boolean, onlyMultiLine: boolean) { + public verifySpanOfEnclosingComment(negative: boolean, onlyMultiLineDiverges?: boolean) { const expected = !negative; const position = this.currentCaretPosition; const fileName = this.activeFile.fileName; - const actual = !!this.languageService.getSpanOfEnclosingComment(fileName, position, /*onlyMultiLine*/ onlyMultiLine); - if (expected !== actual) { + const actual = !!this.languageService.getSpanOfEnclosingComment(fileName, position, /*onlyMultiLine*/ false); + const actualOnlyMultiLine = !!this.languageService.getSpanOfEnclosingComment(fileName, position, /*onlyMultiLine*/ true); + if (expected !== actual || onlyMultiLineDiverges === (actual === actualOnlyMultiLine)) { this.raiseError(`verifySpanOfEnclosingComment failed: position: '${position}' fileName: '${fileName}' - onlyMultiLine: '${onlyMultiLine}' + onlyMultiLineDiverges: '${onlyMultiLineDiverges}' + actual: '${actual}' + actualOnlyMultiLine: '${actualOnlyMultiLine}' expected: '${expected}'.`); } } @@ -3662,8 +3665,8 @@ namespace FourSlashInterface { this.state.verifyBraceCompletionAtPosition(this.negative, openingBrace); } - public isInCommentAtPosition(onlyMultiLine: boolean) { - this.state.verifySpanOfEnclosingComment(this.negative, onlyMultiLine); + public isInCommentAtPosition(onlyMultiLineDiverges?: boolean) { + this.state.verifySpanOfEnclosingComment(this.negative, onlyMultiLineDiverges); } public codeFixAvailable() { diff --git a/tests/cases/fourslash/fourslash.ts b/tests/cases/fourslash/fourslash.ts index 088cbfaa490..87e11ae4262 100644 --- a/tests/cases/fourslash/fourslash.ts +++ b/tests/cases/fourslash/fourslash.ts @@ -153,7 +153,7 @@ declare namespace FourSlashInterface { typeDefinitionCountIs(expectedCount: number): void; implementationListIsEmpty(): void; isValidBraceCompletionAtPosition(openingBrace?: string): void; - isInCommentAtPosition(onlyMultiLine: boolean): void; + isInCommentAtPosition(onlyMultiLineDiverges?: boolean): void; codeFixAvailable(): void; applicableRefactorAvailableAtMarker(markerName: string): void; codeFixDiagnosticsAvailableAtMarkers(markerNames: string[], diagnosticCode?: number): void; diff --git a/tests/cases/fourslash/isInMultiLineComment.ts b/tests/cases/fourslash/isInMultiLineComment.ts index 3dc8a6e15d1..96da4f0021f 100644 --- a/tests/cases/fourslash/isInMultiLineComment.ts +++ b/tests/cases/fourslash/isInMultiLineComment.ts @@ -11,37 +11,36 @@ const firstCommentStart = 0; const firstCommentEnd = 7; goTo.position(firstCommentStart); -verify.not.isInCommentAtPosition(/*onlyMultiLine*/ true); +verify.not.isInCommentAtPosition(); goTo.position(firstCommentStart + 1); -verify.isInCommentAtPosition(/*onlyMultiLine*/ true); +verify.isInCommentAtPosition(); goTo.position(firstCommentEnd - 1); -verify.isInCommentAtPosition(/*onlyMultiLine*/ true); +verify.isInCommentAtPosition(); goTo.position(firstCommentEnd); -verify.not.isInCommentAtPosition(/*onlyMultiLine*/ true); +verify.not.isInCommentAtPosition(); const multilineJsDocStart = firstCommentEnd + 1; const multilineJsDocEnd = multilineJsDocStart + 49; goTo.position(multilineJsDocStart); -verify.not.isInCommentAtPosition(/*onlyMultiLine*/ true); +verify.not.isInCommentAtPosition(); goTo.position(multilineJsDocStart + 1); -verify.isInCommentAtPosition(/*onlyMultiLine*/ true); +verify.isInCommentAtPosition(); goTo.position(multilineJsDocEnd - 1); -verify.isInCommentAtPosition(/*onlyMultiLine*/ true); +verify.isInCommentAtPosition(); goTo.position(multilineJsDocEnd); -verify.not.isInCommentAtPosition(/*onlyMultiLine*/ true); +verify.not.isInCommentAtPosition(); const singleLineCommentStart = multilineJsDocEnd + 1; goTo.position(singleLineCommentStart + 1); -verify.not.isInCommentAtPosition(/*onlyMultiLine*/ true); -verify.isInCommentAtPosition(/*onlyMultiLine*/ false); +verify.isInCommentAtPosition(/*onlyMultiLineDiverges*/ true); const postNodeCommentStart = singleLineCommentStart + 16; goTo.position(postNodeCommentStart); -verify.not.isInCommentAtPosition(/*onlyMultiLine*/ true); +verify.not.isInCommentAtPosition(); goTo.position(postNodeCommentStart + 1); -verify.isInCommentAtPosition(/*onlyMultiLine*/ true); +verify.isInCommentAtPosition(); diff --git a/tests/cases/fourslash/isInMultiLineCommentInJsxText.ts b/tests/cases/fourslash/isInMultiLineCommentInJsxText.ts index db88f6b9a55..1664ca0cd1b 100644 --- a/tests/cases/fourslash/isInMultiLineCommentInJsxText.ts +++ b/tests/cases/fourslash/isInMultiLineCommentInJsxText.ts @@ -23,5 +23,5 @@ for (let i = 0; i < 10; ++i) { goTo.marker(i.toString()); - verify.not.isInCommentAtPosition(/*onlyMultiLine*/ false); + verify.not.isInCommentAtPosition(); } diff --git a/tests/cases/fourslash/isInMultiLineCommentInTemplateLiteral.ts b/tests/cases/fourslash/isInMultiLineCommentInTemplateLiteral.ts index ca6f11499da..c3e2ae92e8a 100644 --- a/tests/cases/fourslash/isInMultiLineCommentInTemplateLiteral.ts +++ b/tests/cases/fourslash/isInMultiLineCommentInTemplateLiteral.ts @@ -23,5 +23,5 @@ for (let i = 0; i < 9; ++i) { goTo.marker(i.toString()); - verify.not.isInCommentAtPosition(/*onlyMultiLine*/ false); + verify.not.isInCommentAtPosition(); } \ No newline at end of file diff --git a/tests/cases/fourslash/isInMultiLineCommentOnlyTrivia.ts b/tests/cases/fourslash/isInMultiLineCommentOnlyTrivia.ts index e279af47699..41c9bbadfd8 100644 --- a/tests/cases/fourslash/isInMultiLineCommentOnlyTrivia.ts +++ b/tests/cases/fourslash/isInMultiLineCommentOnlyTrivia.ts @@ -9,30 +9,29 @@ const firstCommentStart = 0; const firstCommentEnd = 7; goTo.position(firstCommentStart); -verify.not.isInCommentAtPosition(/*onlyMultiLine*/ true); +verify.not.isInCommentAtPosition(); goTo.position(firstCommentStart + 1); -verify.isInCommentAtPosition(/*onlyMultiLine*/ true); +verify.isInCommentAtPosition(); goTo.position(firstCommentEnd - 1); -verify.isInCommentAtPosition(/*onlyMultiLine*/ true); +verify.isInCommentAtPosition(); goTo.position(firstCommentEnd); -verify.not.isInCommentAtPosition(/*onlyMultiLine*/ true); +verify.not.isInCommentAtPosition(); const multilineJsDocStart = firstCommentEnd + 1; const multilineJsDocEnd = multilineJsDocStart + 49; goTo.position(multilineJsDocStart); -verify.not.isInCommentAtPosition(/*onlyMultiLine*/ true); +verify.not.isInCommentAtPosition(); goTo.position(multilineJsDocStart + 1); -verify.isInCommentAtPosition(/*onlyMultiLine*/ true); +verify.isInCommentAtPosition(); goTo.position(multilineJsDocEnd - 1); -verify.isInCommentAtPosition(/*onlyMultiLine*/ true); +verify.isInCommentAtPosition(); goTo.position(multilineJsDocEnd); -verify.not.isInCommentAtPosition(/*onlyMultiLine*/ true); +verify.not.isInCommentAtPosition(); const singleLineCommentStart = multilineJsDocEnd + 1; goTo.position(singleLineCommentStart + 1); -verify.not.isInCommentAtPosition(/*onlyMultiLine*/ true); -verify.isInCommentAtPosition(/*onlyMultiLine*/ false); \ No newline at end of file +verify.isInCommentAtPosition(/*onlyMultiLineDiverges*/ true); \ No newline at end of file From babb88a0aa4f240baee1264f68e77f1a5be67bfb Mon Sep 17 00:00:00 2001 From: Andy Date: Thu, 17 Aug 2017 06:52:15 -0700 Subject: [PATCH 063/370] Remove duplicate function (#17807) --- src/services/refactors/extractMethod.ts | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/services/refactors/extractMethod.ts b/src/services/refactors/extractMethod.ts index de163d07717..cf58ede99bd 100644 --- a/src/services/refactors/extractMethod.ts +++ b/src/services/refactors/extractMethod.ts @@ -830,10 +830,6 @@ namespace ts.refactor.extractMethod { } } - function isModuleBlock(n: Node): n is ModuleBlock { - return n.kind === SyntaxKind.ModuleBlock; - } - function isReadonlyArray(v: any): v is ReadonlyArray { return isArray(v); } From b8e0dedac03c0049e7e8500a93f99b8f383c75d4 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Thu, 17 Aug 2017 12:40:10 -0700 Subject: [PATCH 064/370] Fix #17069 and #15371 1. `T[K]` now correctly produces `number` when `K extends string, T extends Record`. 2. `T[K]` no longer allows any type to be assigned to it when `T extends object, K extends keyof T`. Previously both of these cases failed in getConstraintOfIndexedAccessType because both bases followed `K`'s base constraint to `string` and then incorrectly produced `any` for types (like `object`) with no string index signature. In (1), this produced an error in checkBinaryLikeExpression`. In (2), this failed to produce an error in `checkTypeRelatedTo`. --- src/compiler/checker.ts | 15 +++++++++++---- src/compiler/core.ts | 2 +- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 6778bacd05a..ff311177629 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -5912,7 +5912,13 @@ namespace ts { return transformed; } const baseObjectType = getBaseConstraintOfType(type.objectType); - const baseIndexType = getBaseConstraintOfType(type.indexType); + const keepTypeParameterForMappedType = baseObjectType && getObjectFlags(baseObjectType) & ObjectFlags.Mapped && type.indexType.flags & TypeFlags.TypeParameter; + const baseIndexType = !keepTypeParameterForMappedType && getBaseConstraintOfType(type.indexType); + if (baseObjectType && baseIndexType === stringType && !getIndexInfoOfType(baseObjectType, IndexKind.String)) { + // getIndexedAccessType returns `any` for X[string] where X doesn't have an index signature. + // instead, return undefined so that the indexed access check fails + return undefined; + } return baseObjectType || baseIndexType ? getIndexedAccessType(baseObjectType || type.objectType, baseIndexType || type.indexType) : undefined; } @@ -5962,8 +5968,9 @@ namespace ts { function computeBaseConstraint(t: Type): Type { if (t.flags & TypeFlags.TypeParameter) { const constraint = getConstraintFromTypeParameter(t); - return (t).isThisType ? constraint : - constraint ? getBaseConstraint(constraint) : undefined; + return ((t as TypeParameter).isThisType || !constraint || getObjectFlags(constraint) & ObjectFlags.Mapped) ? + constraint : + getBaseConstraint(constraint); } if (t.flags & TypeFlags.UnionOrIntersection) { const types = (t).types; @@ -9290,7 +9297,7 @@ namespace ts { } else if (target.flags & TypeFlags.IndexedAccess) { // A type S is related to a type T[K] if S is related to A[K], where K is string-like and - // A is the apparent type of S. + // A is the apparent type of T. const constraint = getConstraintOfType(target); if (constraint) { if (result = isRelatedTo(source, constraint, reportErrors)) { diff --git a/src/compiler/core.ts b/src/compiler/core.ts index 85514987b3b..6649bb21fe5 100644 --- a/src/compiler/core.ts +++ b/src/compiler/core.ts @@ -718,7 +718,7 @@ namespace ts { export function sum, K extends string>(array: T[], prop: K): number { let result = 0; for (const v of array) { - // Note: we need the following type assertion because of GH #17069 + // TODO: Remove the following type assertion once the fix for #17069 is merged result += v[prop] as number; } return result; From 1b4f90705fb042ecf7773c00a6f366a716fa7aa4 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Thu, 17 Aug 2017 12:45:20 -0700 Subject: [PATCH 065/370] Test getConstraintOfIndexedAccess fixes and update baselines --- ...ionOperatorWithConstrainedTypeParameter.js | 27 ++++++++ ...eratorWithConstrainedTypeParameter.symbols | 54 +++++++++++++++ ...OperatorWithConstrainedTypeParameter.types | 64 ++++++++++++++++++ ...tiveConstraintOfIndexAccessType.errors.txt | 67 +++++++++++++++++++ ...nonPrimitiveConstraintOfIndexAccessType.js | 67 +++++++++++++++++++ ...ionOperatorWithConstrainedTypeParameter.ts | 11 +++ ...nonPrimitiveConstraintOfIndexAccessType.ts | 32 +++++++++ 7 files changed, 322 insertions(+) create mode 100644 tests/baselines/reference/additionOperatorWithConstrainedTypeParameter.js create mode 100644 tests/baselines/reference/additionOperatorWithConstrainedTypeParameter.symbols create mode 100644 tests/baselines/reference/additionOperatorWithConstrainedTypeParameter.types create mode 100644 tests/baselines/reference/nonPrimitiveConstraintOfIndexAccessType.errors.txt create mode 100644 tests/baselines/reference/nonPrimitiveConstraintOfIndexAccessType.js create mode 100644 tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithConstrainedTypeParameter.ts create mode 100644 tests/cases/conformance/types/nonPrimitive/nonPrimitiveConstraintOfIndexAccessType.ts diff --git a/tests/baselines/reference/additionOperatorWithConstrainedTypeParameter.js b/tests/baselines/reference/additionOperatorWithConstrainedTypeParameter.js new file mode 100644 index 00000000000..1366e242182 --- /dev/null +++ b/tests/baselines/reference/additionOperatorWithConstrainedTypeParameter.js @@ -0,0 +1,27 @@ +//// [additionOperatorWithConstrainedTypeParameter.ts] +// test for #17069 +function sum, K extends string>(n: number, v: T, k: K) { + n = n + v[k]; + n += v[k]; // += should work the same way +} +function realSum, K extends string>(n: number, vs: T[], k: K) { + for (const v of vs) { + n = n + v[k]; + n += v[k]; + } +} + + +//// [additionOperatorWithConstrainedTypeParameter.js] +// test for #17069 +function sum(n, v, k) { + n = n + v[k]; + n += v[k]; // += should work the same way +} +function realSum(n, vs, k) { + for (var _i = 0, vs_1 = vs; _i < vs_1.length; _i++) { + var v = vs_1[_i]; + n = n + v[k]; + n += v[k]; + } +} diff --git a/tests/baselines/reference/additionOperatorWithConstrainedTypeParameter.symbols b/tests/baselines/reference/additionOperatorWithConstrainedTypeParameter.symbols new file mode 100644 index 00000000000..e7055c1e38f --- /dev/null +++ b/tests/baselines/reference/additionOperatorWithConstrainedTypeParameter.symbols @@ -0,0 +1,54 @@ +=== tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithConstrainedTypeParameter.ts === +// test for #17069 +function sum, K extends string>(n: number, v: T, k: K) { +>sum : Symbol(sum, Decl(additionOperatorWithConstrainedTypeParameter.ts, 0, 0)) +>T : Symbol(T, Decl(additionOperatorWithConstrainedTypeParameter.ts, 1, 13)) +>Record : Symbol(Record, Decl(lib.d.ts, --, --)) +>K : Symbol(K, Decl(additionOperatorWithConstrainedTypeParameter.ts, 1, 41)) +>K : Symbol(K, Decl(additionOperatorWithConstrainedTypeParameter.ts, 1, 41)) +>n : Symbol(n, Decl(additionOperatorWithConstrainedTypeParameter.ts, 1, 60)) +>v : Symbol(v, Decl(additionOperatorWithConstrainedTypeParameter.ts, 1, 70)) +>T : Symbol(T, Decl(additionOperatorWithConstrainedTypeParameter.ts, 1, 13)) +>k : Symbol(k, Decl(additionOperatorWithConstrainedTypeParameter.ts, 1, 76)) +>K : Symbol(K, Decl(additionOperatorWithConstrainedTypeParameter.ts, 1, 41)) + + n = n + v[k]; +>n : Symbol(n, Decl(additionOperatorWithConstrainedTypeParameter.ts, 1, 60)) +>n : Symbol(n, Decl(additionOperatorWithConstrainedTypeParameter.ts, 1, 60)) +>v : Symbol(v, Decl(additionOperatorWithConstrainedTypeParameter.ts, 1, 70)) +>k : Symbol(k, Decl(additionOperatorWithConstrainedTypeParameter.ts, 1, 76)) + + n += v[k]; // += should work the same way +>n : Symbol(n, Decl(additionOperatorWithConstrainedTypeParameter.ts, 1, 60)) +>v : Symbol(v, Decl(additionOperatorWithConstrainedTypeParameter.ts, 1, 70)) +>k : Symbol(k, Decl(additionOperatorWithConstrainedTypeParameter.ts, 1, 76)) +} +function realSum, K extends string>(n: number, vs: T[], k: K) { +>realSum : Symbol(realSum, Decl(additionOperatorWithConstrainedTypeParameter.ts, 4, 1)) +>T : Symbol(T, Decl(additionOperatorWithConstrainedTypeParameter.ts, 5, 17)) +>Record : Symbol(Record, Decl(lib.d.ts, --, --)) +>K : Symbol(K, Decl(additionOperatorWithConstrainedTypeParameter.ts, 5, 45)) +>K : Symbol(K, Decl(additionOperatorWithConstrainedTypeParameter.ts, 5, 45)) +>n : Symbol(n, Decl(additionOperatorWithConstrainedTypeParameter.ts, 5, 64)) +>vs : Symbol(vs, Decl(additionOperatorWithConstrainedTypeParameter.ts, 5, 74)) +>T : Symbol(T, Decl(additionOperatorWithConstrainedTypeParameter.ts, 5, 17)) +>k : Symbol(k, Decl(additionOperatorWithConstrainedTypeParameter.ts, 5, 83)) +>K : Symbol(K, Decl(additionOperatorWithConstrainedTypeParameter.ts, 5, 45)) + + for (const v of vs) { +>v : Symbol(v, Decl(additionOperatorWithConstrainedTypeParameter.ts, 6, 14)) +>vs : Symbol(vs, Decl(additionOperatorWithConstrainedTypeParameter.ts, 5, 74)) + + n = n + v[k]; +>n : Symbol(n, Decl(additionOperatorWithConstrainedTypeParameter.ts, 5, 64)) +>n : Symbol(n, Decl(additionOperatorWithConstrainedTypeParameter.ts, 5, 64)) +>v : Symbol(v, Decl(additionOperatorWithConstrainedTypeParameter.ts, 6, 14)) +>k : Symbol(k, Decl(additionOperatorWithConstrainedTypeParameter.ts, 5, 83)) + + n += v[k]; +>n : Symbol(n, Decl(additionOperatorWithConstrainedTypeParameter.ts, 5, 64)) +>v : Symbol(v, Decl(additionOperatorWithConstrainedTypeParameter.ts, 6, 14)) +>k : Symbol(k, Decl(additionOperatorWithConstrainedTypeParameter.ts, 5, 83)) + } +} + diff --git a/tests/baselines/reference/additionOperatorWithConstrainedTypeParameter.types b/tests/baselines/reference/additionOperatorWithConstrainedTypeParameter.types new file mode 100644 index 00000000000..d52c77a94fd --- /dev/null +++ b/tests/baselines/reference/additionOperatorWithConstrainedTypeParameter.types @@ -0,0 +1,64 @@ +=== tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithConstrainedTypeParameter.ts === +// test for #17069 +function sum, K extends string>(n: number, v: T, k: K) { +>sum : , K extends string>(n: number, v: T, k: K) => void +>T : T +>Record : Record +>K : K +>K : K +>n : number +>v : T +>T : T +>k : K +>K : K + + n = n + v[k]; +>n = n + v[k] : number +>n : number +>n + v[k] : number +>n : number +>v[k] : T[K] +>v : T +>k : K + + n += v[k]; // += should work the same way +>n += v[k] : number +>n : number +>v[k] : T[K] +>v : T +>k : K +} +function realSum, K extends string>(n: number, vs: T[], k: K) { +>realSum : , K extends string>(n: number, vs: T[], k: K) => void +>T : T +>Record : Record +>K : K +>K : K +>n : number +>vs : T[] +>T : T +>k : K +>K : K + + for (const v of vs) { +>v : T +>vs : T[] + + n = n + v[k]; +>n = n + v[k] : number +>n : number +>n + v[k] : number +>n : number +>v[k] : T[K] +>v : T +>k : K + + n += v[k]; +>n += v[k] : number +>n : number +>v[k] : T[K] +>v : T +>k : K + } +} + diff --git a/tests/baselines/reference/nonPrimitiveConstraintOfIndexAccessType.errors.txt b/tests/baselines/reference/nonPrimitiveConstraintOfIndexAccessType.errors.txt new file mode 100644 index 00000000000..56781157131 --- /dev/null +++ b/tests/baselines/reference/nonPrimitiveConstraintOfIndexAccessType.errors.txt @@ -0,0 +1,67 @@ +tests/cases/conformance/types/nonPrimitive/nonPrimitiveConstraintOfIndexAccessType.ts(3,5): error TS2322: Type 'string' is not assignable to type 'T[P]'. +tests/cases/conformance/types/nonPrimitive/nonPrimitiveConstraintOfIndexAccessType.ts(6,5): error TS2322: Type 'string' is not assignable to type 'T[P]'. +tests/cases/conformance/types/nonPrimitive/nonPrimitiveConstraintOfIndexAccessType.ts(9,5): error TS2322: Type 'string' is not assignable to type 'T[P]'. +tests/cases/conformance/types/nonPrimitive/nonPrimitiveConstraintOfIndexAccessType.ts(12,5): error TS2322: Type 'string' is not assignable to type 'T[P]'. +tests/cases/conformance/types/nonPrimitive/nonPrimitiveConstraintOfIndexAccessType.ts(15,5): error TS2322: Type 'string' is not assignable to type 'T[P]'. +tests/cases/conformance/types/nonPrimitive/nonPrimitiveConstraintOfIndexAccessType.ts(18,5): error TS2322: Type 'string' is not assignable to type 'T[P]'. +tests/cases/conformance/types/nonPrimitive/nonPrimitiveConstraintOfIndexAccessType.ts(21,5): error TS2322: Type 'string' is not assignable to type 'T[P]'. +tests/cases/conformance/types/nonPrimitive/nonPrimitiveConstraintOfIndexAccessType.ts(24,5): error TS2322: Type 'string' is not assignable to type 'T[P]'. +tests/cases/conformance/types/nonPrimitive/nonPrimitiveConstraintOfIndexAccessType.ts(27,5): error TS2322: Type 'string' is not assignable to type 'T[P]'. +tests/cases/conformance/types/nonPrimitive/nonPrimitiveConstraintOfIndexAccessType.ts(30,5): error TS2322: Type 'string' is not assignable to type 'T[P]'. + Type 'string' is not assignable to type 'number'. + + +==== tests/cases/conformance/types/nonPrimitive/nonPrimitiveConstraintOfIndexAccessType.ts (10 errors) ==== + // test for #15371 + function f(s: string, tp: T[P]): void { + tp = s; + ~~ +!!! error TS2322: Type 'string' is not assignable to type 'T[P]'. + } + function g(s: string, tp: T[P]): void { + tp = s; + ~~ +!!! error TS2322: Type 'string' is not assignable to type 'T[P]'. + } + function h(s: string, tp: T[P]): void { + tp = s; + ~~ +!!! error TS2322: Type 'string' is not assignable to type 'T[P]'. + } + function i(s: string, tp: T[P]): void { + tp = s; + ~~ +!!! error TS2322: Type 'string' is not assignable to type 'T[P]'. + } + function j(s: string, tp: T[P]): void { + tp = s; + ~~ +!!! error TS2322: Type 'string' is not assignable to type 'T[P]'. + } + function k(s: string, tp: T[P]): void { + tp = s; + ~~ +!!! error TS2322: Type 'string' is not assignable to type 'T[P]'. + } + function o(s: string, tp: T[P]): void { + tp = s; + ~~ +!!! error TS2322: Type 'string' is not assignable to type 'T[P]'. + } + function l(s: string, tp: T[P]): void { + tp = s; + ~~ +!!! error TS2322: Type 'string' is not assignable to type 'T[P]'. + } + function m(s: string, tp: T[P]): void { + tp = s; + ~~ +!!! error TS2322: Type 'string' is not assignable to type 'T[P]'. + } + function n(s: string, tp: T[P]): void { + tp = s; + ~~ +!!! error TS2322: Type 'string' is not assignable to type 'T[P]'. +!!! error TS2322: Type 'string' is not assignable to type 'number'. + } + \ No newline at end of file diff --git a/tests/baselines/reference/nonPrimitiveConstraintOfIndexAccessType.js b/tests/baselines/reference/nonPrimitiveConstraintOfIndexAccessType.js new file mode 100644 index 00000000000..7a24345a94b --- /dev/null +++ b/tests/baselines/reference/nonPrimitiveConstraintOfIndexAccessType.js @@ -0,0 +1,67 @@ +//// [nonPrimitiveConstraintOfIndexAccessType.ts] +// test for #15371 +function f(s: string, tp: T[P]): void { + tp = s; +} +function g(s: string, tp: T[P]): void { + tp = s; +} +function h(s: string, tp: T[P]): void { + tp = s; +} +function i(s: string, tp: T[P]): void { + tp = s; +} +function j(s: string, tp: T[P]): void { + tp = s; +} +function k(s: string, tp: T[P]): void { + tp = s; +} +function o(s: string, tp: T[P]): void { + tp = s; +} +function l(s: string, tp: T[P]): void { + tp = s; +} +function m(s: string, tp: T[P]): void { + tp = s; +} +function n(s: string, tp: T[P]): void { + tp = s; +} + + +//// [nonPrimitiveConstraintOfIndexAccessType.js] +"use strict"; +// test for #15371 +function f(s, tp) { + tp = s; +} +function g(s, tp) { + tp = s; +} +function h(s, tp) { + tp = s; +} +function i(s, tp) { + tp = s; +} +function j(s, tp) { + tp = s; +} +function k(s, tp) { + tp = s; +} +function o(s, tp) { + tp = s; +} +function l(s, tp) { + tp = s; +} +function m(s, tp) { + tp = s; +} +function n(s, tp) { + tp = s; +} diff --git a/tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithConstrainedTypeParameter.ts b/tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithConstrainedTypeParameter.ts new file mode 100644 index 00000000000..2303bb33944 --- /dev/null +++ b/tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithConstrainedTypeParameter.ts @@ -0,0 +1,11 @@ +// test for #17069 +function sum, K extends string>(n: number, v: T, k: K) { + n = n + v[k]; + n += v[k]; // += should work the same way +} +function realSum, K extends string>(n: number, vs: T[], k: K) { + for (const v of vs) { + n = n + v[k]; + n += v[k]; + } +} diff --git a/tests/cases/conformance/types/nonPrimitive/nonPrimitiveConstraintOfIndexAccessType.ts b/tests/cases/conformance/types/nonPrimitive/nonPrimitiveConstraintOfIndexAccessType.ts new file mode 100644 index 00000000000..1e852f12f92 --- /dev/null +++ b/tests/cases/conformance/types/nonPrimitive/nonPrimitiveConstraintOfIndexAccessType.ts @@ -0,0 +1,32 @@ +// @strict: true +// test for #15371 +function f(s: string, tp: T[P]): void { + tp = s; +} +function g(s: string, tp: T[P]): void { + tp = s; +} +function h(s: string, tp: T[P]): void { + tp = s; +} +function i(s: string, tp: T[P]): void { + tp = s; +} +function j(s: string, tp: T[P]): void { + tp = s; +} +function k(s: string, tp: T[P]): void { + tp = s; +} +function o(s: string, tp: T[P]): void { + tp = s; +} +function l(s: string, tp: T[P]): void { + tp = s; +} +function m(s: string, tp: T[P]): void { + tp = s; +} +function n(s: string, tp: T[P]): void { + tp = s; +} From a187b17e97fece8012bc8529ea3b1a9ebe4804e9 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Thu, 17 Aug 2017 13:09:21 -0700 Subject: [PATCH 066/370] Simplify mapped-type handling in computeBaseConstraint --- src/compiler/checker.ts | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index ff311177629..b3e7b01123d 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -5968,7 +5968,7 @@ namespace ts { function computeBaseConstraint(t: Type): Type { if (t.flags & TypeFlags.TypeParameter) { const constraint = getConstraintFromTypeParameter(t); - return ((t as TypeParameter).isThisType || !constraint || getObjectFlags(constraint) & ObjectFlags.Mapped) ? + return (t as TypeParameter).isThisType || !constraint ? constraint : getBaseConstraint(constraint); } @@ -5998,9 +5998,6 @@ namespace ts { const baseIndexedAccess = baseObjectType && baseIndexType ? getIndexedAccessType(baseObjectType, baseIndexType) : undefined; return baseIndexedAccess && baseIndexedAccess !== unknownType ? getBaseConstraint(baseIndexedAccess) : undefined; } - if (isGenericMappedType(t)) { - return emptyObjectType; - } return t; } } From eef7d8bd3d974528464c7968deab78b747568c06 Mon Sep 17 00:00:00 2001 From: Andy Date: Thu, 17 Aug 2017 13:26:38 -0700 Subject: [PATCH 067/370] Treat explicit imports from `node_modules` as external library imports (#16364) * Treat explicit imports from `node_modules` as external library imports * Update baselines --- src/compiler/checker.ts | 3 +-- src/compiler/core.ts | 14 +++++++++----- src/compiler/moduleNameResolver.ts | 5 +++-- src/compiler/types.ts | 7 +------ .../moduleResolution_explicitNodeModulesImport.js | 12 ++++++++++++ ...uleResolution_explicitNodeModulesImport.symbols | 9 +++++++++ ...oduleResolution_explicitNodeModulesImport.types | 12 ++++++++++++ ...lution_explicitNodeModulesImport_implicitAny.js | 12 ++++++++++++ ...n_explicitNodeModulesImport_implicitAny.symbols | 4 ++++ ...ion_explicitNodeModulesImport_implicitAny.types | 4 ++++ .../amd/nodeModulesMaxDepthExceeded.errors.txt | 6 +++--- .../amd/nodeModulesMaxDepthExceeded.json | 8 ++++---- .../node/nodeModulesMaxDepthExceeded.errors.txt | 6 +++--- .../node/nodeModulesMaxDepthExceeded.json | 8 ++++---- .../moduleResolution_explicitNodeModulesImport.ts | 9 +++++++++ ...lution_explicitNodeModulesImport_implicitAny.ts | 9 +++++++++ 16 files changed, 99 insertions(+), 29 deletions(-) create mode 100644 tests/baselines/reference/moduleResolution_explicitNodeModulesImport.js create mode 100644 tests/baselines/reference/moduleResolution_explicitNodeModulesImport.symbols create mode 100644 tests/baselines/reference/moduleResolution_explicitNodeModulesImport.types create mode 100644 tests/baselines/reference/moduleResolution_explicitNodeModulesImport_implicitAny.js create mode 100644 tests/baselines/reference/moduleResolution_explicitNodeModulesImport_implicitAny.symbols create mode 100644 tests/baselines/reference/moduleResolution_explicitNodeModulesImport_implicitAny.types create mode 100644 tests/cases/compiler/moduleResolution_explicitNodeModulesImport.ts create mode 100644 tests/cases/compiler/moduleResolution_explicitNodeModulesImport_implicitAny.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index ce5f5a4f1c5..6df6b1f9ce1 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -1694,7 +1694,6 @@ namespace ts { if (ambientModule) { return ambientModule; } - const isRelative = isExternalModuleNameRelative(moduleReference); const resolvedModule = getResolvedModule(getSourceFileOfNode(location), moduleReference); const resolutionDiagnostic = resolvedModule && getResolutionDiagnostic(compilerOptions, resolvedModule); const sourceFile = resolvedModule && !resolutionDiagnostic && host.getSourceFile(resolvedModule.resolvedFileName); @@ -1718,7 +1717,7 @@ namespace ts { } // May be an untyped module. If so, ignore resolutionDiagnostic. - if (!isRelative && resolvedModule && !extensionIsTypeScript(resolvedModule.extension)) { + if (resolvedModule && resolvedModule.isExternalLibraryImport && !extensionIsTypeScript(resolvedModule.extension)) { if (isForAugmentation) { const diag = Diagnostics.Invalid_module_name_in_augmentation_Module_0_resolves_to_an_untyped_module_at_1_which_cannot_be_augmented; error(errorNode, diag, moduleReference, resolvedModule.resolvedFileName); diff --git a/src/compiler/core.ts b/src/compiler/core.ts index b2d0528d89a..8cab1b41155 100644 --- a/src/compiler/core.ts +++ b/src/compiler/core.ts @@ -1543,16 +1543,20 @@ namespace ts { } export function normalizePath(path: string): string { + return normalizePathAndParts(path).path; + } + + export function normalizePathAndParts(path: string): { path: string, parts: string[] } { path = normalizeSlashes(path); const rootLength = getRootLength(path); const root = path.substr(0, rootLength); - const normalized = getNormalizedParts(path, rootLength); - if (normalized.length) { - const joinedParts = root + normalized.join(directorySeparator); - return pathEndsWithDirectorySeparator(path) ? joinedParts + directorySeparator : joinedParts; + const parts = getNormalizedParts(path, rootLength); + if (parts.length) { + const joinedParts = root + parts.join(directorySeparator); + return { path: pathEndsWithDirectorySeparator(path) ? joinedParts + directorySeparator : joinedParts, parts }; } else { - return root; + return { path: root, parts }; } } diff --git a/src/compiler/moduleNameResolver.ts b/src/compiler/moduleNameResolver.ts index 1593e630b6d..5fdac504896 100644 --- a/src/compiler/moduleNameResolver.ts +++ b/src/compiler/moduleNameResolver.ts @@ -747,9 +747,10 @@ namespace ts { return { value: resolvedValue && { resolved: resolvedValue, isExternalLibraryImport: true } }; } else { - const candidate = normalizePath(combinePaths(containingDirectory, moduleName)); + const { path: candidate, parts } = normalizePathAndParts(combinePaths(containingDirectory, moduleName)); const resolved = nodeLoadModuleByRelativeName(extensions, candidate, failedLookupLocations, /*onlyRecordFailures*/ false, state, /*considerPackageJson*/ true); - return resolved && toSearchResult({ resolved, isExternalLibraryImport: false }); + // Treat explicit "node_modules" import as an external library import. + return resolved && toSearchResult({ resolved, isExternalLibraryImport: contains(parts, "node_modules") }); } } } diff --git a/src/compiler/types.ts b/src/compiler/types.ts index d274f560e21..608bc779042 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -3953,12 +3953,7 @@ namespace ts { export interface ResolvedModule { /** Path of the file the module was resolved to. */ resolvedFileName: string; - /** - * Denotes if 'resolvedFileName' is isExternalLibraryImport and thus should be a proper external module: - * - be a .d.ts file - * - use top level imports\exports - * - don't use tripleslash references - */ + /** True if `resolvedFileName` comes from `node_modules`. */ isExternalLibraryImport?: boolean; } diff --git a/tests/baselines/reference/moduleResolution_explicitNodeModulesImport.js b/tests/baselines/reference/moduleResolution_explicitNodeModulesImport.js new file mode 100644 index 00000000000..93a083da53a --- /dev/null +++ b/tests/baselines/reference/moduleResolution_explicitNodeModulesImport.js @@ -0,0 +1,12 @@ +//// [tests/cases/compiler/moduleResolution_explicitNodeModulesImport.ts] //// + +//// [index.js] +exports.x = 0; + +//// [index.ts] +import { x } from "../node_modules/foo"; + + +//// [index.js] +"use strict"; +exports.__esModule = true; diff --git a/tests/baselines/reference/moduleResolution_explicitNodeModulesImport.symbols b/tests/baselines/reference/moduleResolution_explicitNodeModulesImport.symbols new file mode 100644 index 00000000000..b635ba2c7c7 --- /dev/null +++ b/tests/baselines/reference/moduleResolution_explicitNodeModulesImport.symbols @@ -0,0 +1,9 @@ +=== /src/index.ts === +import { x } from "../node_modules/foo"; +>x : Symbol(x, Decl(index.ts, 0, 8)) + +=== /node_modules/foo/index.js === +exports.x = 0; +>exports : Symbol(x, Decl(index.js, 0, 0)) +>x : Symbol(x, Decl(index.js, 0, 0)) + diff --git a/tests/baselines/reference/moduleResolution_explicitNodeModulesImport.types b/tests/baselines/reference/moduleResolution_explicitNodeModulesImport.types new file mode 100644 index 00000000000..ca7541d2140 --- /dev/null +++ b/tests/baselines/reference/moduleResolution_explicitNodeModulesImport.types @@ -0,0 +1,12 @@ +=== /src/index.ts === +import { x } from "../node_modules/foo"; +>x : number + +=== /node_modules/foo/index.js === +exports.x = 0; +>exports.x = 0 : 0 +>exports.x : any +>exports : any +>x : any +>0 : 0 + diff --git a/tests/baselines/reference/moduleResolution_explicitNodeModulesImport_implicitAny.js b/tests/baselines/reference/moduleResolution_explicitNodeModulesImport_implicitAny.js new file mode 100644 index 00000000000..1b5b469570d --- /dev/null +++ b/tests/baselines/reference/moduleResolution_explicitNodeModulesImport_implicitAny.js @@ -0,0 +1,12 @@ +//// [tests/cases/compiler/moduleResolution_explicitNodeModulesImport_implicitAny.ts] //// + +//// [index.js] +exports.x = 0; + +//// [index.ts] +import { y } from "../node_modules/foo"; + + +//// [index.js] +"use strict"; +exports.__esModule = true; diff --git a/tests/baselines/reference/moduleResolution_explicitNodeModulesImport_implicitAny.symbols b/tests/baselines/reference/moduleResolution_explicitNodeModulesImport_implicitAny.symbols new file mode 100644 index 00000000000..e320d4d18e1 --- /dev/null +++ b/tests/baselines/reference/moduleResolution_explicitNodeModulesImport_implicitAny.symbols @@ -0,0 +1,4 @@ +=== /src/index.ts === +import { y } from "../node_modules/foo"; +>y : Symbol(y, Decl(index.ts, 0, 8)) + diff --git a/tests/baselines/reference/moduleResolution_explicitNodeModulesImport_implicitAny.types b/tests/baselines/reference/moduleResolution_explicitNodeModulesImport_implicitAny.types new file mode 100644 index 00000000000..a22e0be7a66 --- /dev/null +++ b/tests/baselines/reference/moduleResolution_explicitNodeModulesImport_implicitAny.types @@ -0,0 +1,4 @@ +=== /src/index.ts === +import { y } from "../node_modules/foo"; +>y : any + diff --git a/tests/baselines/reference/project/nodeModulesMaxDepthExceeded/amd/nodeModulesMaxDepthExceeded.errors.txt b/tests/baselines/reference/project/nodeModulesMaxDepthExceeded/amd/nodeModulesMaxDepthExceeded.errors.txt index bd2dd6231f3..e878d0fd54f 100644 --- a/tests/baselines/reference/project/nodeModulesMaxDepthExceeded/amd/nodeModulesMaxDepthExceeded.errors.txt +++ b/tests/baselines/reference/project/nodeModulesMaxDepthExceeded/amd/nodeModulesMaxDepthExceeded.errors.txt @@ -13,9 +13,6 @@ maxDepthExceeded/root.ts(4,4): error TS2540: Cannot assign to 'rel' because it i "exclude": ["node_modules/m2/**/*"] } -==== relative.js (0 errors) ==== - exports.relativeProp = true; - ==== index.js (0 errors) ==== var m2 = require('m2'); var rel = require('./relative'); @@ -51,4 +48,7 @@ maxDepthExceeded/root.ts(4,4): error TS2540: Cannot assign to 'rel' because it i "b": "hello, world", "person": m3.person }; + +==== relative.js (0 errors) ==== + exports.relativeProp = true; \ No newline at end of file diff --git a/tests/baselines/reference/project/nodeModulesMaxDepthExceeded/amd/nodeModulesMaxDepthExceeded.json b/tests/baselines/reference/project/nodeModulesMaxDepthExceeded/amd/nodeModulesMaxDepthExceeded.json index 9efa0e936ac..4a9b2346854 100644 --- a/tests/baselines/reference/project/nodeModulesMaxDepthExceeded/amd/nodeModulesMaxDepthExceeded.json +++ b/tests/baselines/reference/project/nodeModulesMaxDepthExceeded/amd/nodeModulesMaxDepthExceeded.json @@ -7,14 +7,14 @@ "project": "maxDepthExceeded", "resolvedInputFiles": [ "lib.d.ts", - "maxDepthExceeded/node_modules/m1/relative.js", "maxDepthExceeded/node_modules/m1/index.js", "maxDepthExceeded/root.ts", - "maxDepthExceeded/node_modules/m2/entry.js" + "maxDepthExceeded/node_modules/m2/entry.js", + "maxDepthExceeded/node_modules/m1/relative.js" ], "emittedFiles": [ - "maxDepthExceeded/built/node_modules/m1/relative.js", "maxDepthExceeded/built/node_modules/m1/index.js", - "maxDepthExceeded/built/root.js" + "maxDepthExceeded/built/root.js", + "maxDepthExceeded/built/node_modules/m1/relative.js" ] } \ No newline at end of file diff --git a/tests/baselines/reference/project/nodeModulesMaxDepthExceeded/node/nodeModulesMaxDepthExceeded.errors.txt b/tests/baselines/reference/project/nodeModulesMaxDepthExceeded/node/nodeModulesMaxDepthExceeded.errors.txt index bd2dd6231f3..e878d0fd54f 100644 --- a/tests/baselines/reference/project/nodeModulesMaxDepthExceeded/node/nodeModulesMaxDepthExceeded.errors.txt +++ b/tests/baselines/reference/project/nodeModulesMaxDepthExceeded/node/nodeModulesMaxDepthExceeded.errors.txt @@ -13,9 +13,6 @@ maxDepthExceeded/root.ts(4,4): error TS2540: Cannot assign to 'rel' because it i "exclude": ["node_modules/m2/**/*"] } -==== relative.js (0 errors) ==== - exports.relativeProp = true; - ==== index.js (0 errors) ==== var m2 = require('m2'); var rel = require('./relative'); @@ -51,4 +48,7 @@ maxDepthExceeded/root.ts(4,4): error TS2540: Cannot assign to 'rel' because it i "b": "hello, world", "person": m3.person }; + +==== relative.js (0 errors) ==== + exports.relativeProp = true; \ No newline at end of file diff --git a/tests/baselines/reference/project/nodeModulesMaxDepthExceeded/node/nodeModulesMaxDepthExceeded.json b/tests/baselines/reference/project/nodeModulesMaxDepthExceeded/node/nodeModulesMaxDepthExceeded.json index 9efa0e936ac..4a9b2346854 100644 --- a/tests/baselines/reference/project/nodeModulesMaxDepthExceeded/node/nodeModulesMaxDepthExceeded.json +++ b/tests/baselines/reference/project/nodeModulesMaxDepthExceeded/node/nodeModulesMaxDepthExceeded.json @@ -7,14 +7,14 @@ "project": "maxDepthExceeded", "resolvedInputFiles": [ "lib.d.ts", - "maxDepthExceeded/node_modules/m1/relative.js", "maxDepthExceeded/node_modules/m1/index.js", "maxDepthExceeded/root.ts", - "maxDepthExceeded/node_modules/m2/entry.js" + "maxDepthExceeded/node_modules/m2/entry.js", + "maxDepthExceeded/node_modules/m1/relative.js" ], "emittedFiles": [ - "maxDepthExceeded/built/node_modules/m1/relative.js", "maxDepthExceeded/built/node_modules/m1/index.js", - "maxDepthExceeded/built/root.js" + "maxDepthExceeded/built/root.js", + "maxDepthExceeded/built/node_modules/m1/relative.js" ] } \ No newline at end of file diff --git a/tests/cases/compiler/moduleResolution_explicitNodeModulesImport.ts b/tests/cases/compiler/moduleResolution_explicitNodeModulesImport.ts new file mode 100644 index 00000000000..76c1d141976 --- /dev/null +++ b/tests/cases/compiler/moduleResolution_explicitNodeModulesImport.ts @@ -0,0 +1,9 @@ +// @allowJs: true +// @noImplicitReferences: true +// @maxNodeModuleJsDepth: 1 + +// @Filename: /node_modules/foo/index.js +exports.x = 0; + +// @Filename: /src/index.ts +import { x } from "../node_modules/foo"; diff --git a/tests/cases/compiler/moduleResolution_explicitNodeModulesImport_implicitAny.ts b/tests/cases/compiler/moduleResolution_explicitNodeModulesImport_implicitAny.ts new file mode 100644 index 00000000000..97320be0137 --- /dev/null +++ b/tests/cases/compiler/moduleResolution_explicitNodeModulesImport_implicitAny.ts @@ -0,0 +1,9 @@ +// @allowJs: true +// @noImplicitReferences: true +// @maxNodeModuleJsDepth: 0 + +// @Filename: /node_modules/foo/index.js +exports.x = 0; + +// @Filename: /src/index.ts +import { y } from "../node_modules/foo"; From fad97e369a24cd5df3ad1c491cf23bb9378d76cb Mon Sep 17 00:00:00 2001 From: Ron Buckton Date: Thu, 17 Aug 2017 17:32:06 -0700 Subject: [PATCH 068/370] Remove debug assertions due to invalid syntax in generators transform --- src/compiler/transformers/generators.ts | 82 +++++++++++-------- ...invalidContinueInDownlevelAsync.errors.txt | 17 ++++ .../invalidContinueInDownlevelAsync.js | 63 ++++++++++++++ .../invalidContinueInDownlevelAsync.ts | 8 ++ 4 files changed, 134 insertions(+), 36 deletions(-) create mode 100644 tests/baselines/reference/invalidContinueInDownlevelAsync.errors.txt create mode 100644 tests/baselines/reference/invalidContinueInDownlevelAsync.js create mode 100644 tests/cases/compiler/invalidContinueInDownlevelAsync.ts diff --git a/src/compiler/transformers/generators.ts b/src/compiler/transformers/generators.ts index f45147b526c..20195adeef4 100644 --- a/src/compiler/transformers/generators.ts +++ b/src/compiler/transformers/generators.ts @@ -1639,8 +1639,13 @@ namespace ts { function transformAndEmitContinueStatement(node: ContinueStatement): void { const label = findContinueTarget(node.label ? unescapeLeadingUnderscores(node.label.escapedText) : undefined); - Debug.assert(label > 0, "Expected continue statment to point to a valid Label."); - emitBreak(label, /*location*/ node); + if (label > 0) { + emitBreak(label, /*location*/ node); + } + else { + // invalid continue without a containing loop. Leave the node as is, per #17875. + emitStatement(node); + } } function visitContinueStatement(node: ContinueStatement): Statement { @@ -1656,8 +1661,13 @@ namespace ts { function transformAndEmitBreakStatement(node: BreakStatement): void { const label = findBreakTarget(node.label ? unescapeLeadingUnderscores(node.label.escapedText) : undefined); - Debug.assert(label > 0, "Expected break statment to point to a valid Label."); - emitBreak(label, /*location*/ node); + if (label > 0) { + emitBreak(label, /*location*/ node); + } + else { + // invalid break without a containing loop, switch, or labeled statement. Leave the node as is, per #17875. + emitStatement(node); + } } function visitBreakStatement(node: BreakStatement): Statement { @@ -2351,27 +2361,27 @@ namespace ts { * @param labelText An optional name of a containing labeled statement. */ function findBreakTarget(labelText?: string): Label { - Debug.assert(blocks !== undefined); - if (labelText) { - for (let i = blockStack.length - 1; i >= 0; i--) { - const block = blockStack[i]; - if (supportsLabeledBreakOrContinue(block) && block.labelText === labelText) { - return block.breakLabel; + if (blockStack) { + if (labelText) { + for (let i = blockStack.length - 1; i >= 0; i--) { + const block = blockStack[i]; + if (supportsLabeledBreakOrContinue(block) && block.labelText === labelText) { + return block.breakLabel; + } + else if (supportsUnlabeledBreak(block) && hasImmediateContainingLabeledBlock(labelText, i - 1)) { + return block.breakLabel; + } } - else if (supportsUnlabeledBreak(block) && hasImmediateContainingLabeledBlock(labelText, i - 1)) { - return block.breakLabel; + } + else { + for (let i = blockStack.length - 1; i >= 0; i--) { + const block = blockStack[i]; + if (supportsUnlabeledBreak(block)) { + return block.breakLabel; + } } } } - else { - for (let i = blockStack.length - 1; i >= 0; i--) { - const block = blockStack[i]; - if (supportsUnlabeledBreak(block)) { - return block.breakLabel; - } - } - } - return 0; } @@ -2381,24 +2391,24 @@ namespace ts { * @param labelText An optional name of a containing labeled statement. */ function findContinueTarget(labelText?: string): Label { - Debug.assert(blocks !== undefined); - if (labelText) { - for (let i = blockStack.length - 1; i >= 0; i--) { - const block = blockStack[i]; - if (supportsUnlabeledContinue(block) && hasImmediateContainingLabeledBlock(labelText, i - 1)) { - return block.continueLabel; + if (blockStack) { + if (labelText) { + for (let i = blockStack.length - 1; i >= 0; i--) { + const block = blockStack[i]; + if (supportsUnlabeledContinue(block) && hasImmediateContainingLabeledBlock(labelText, i - 1)) { + return block.continueLabel; + } + } + } + else { + for (let i = blockStack.length - 1; i >= 0; i--) { + const block = blockStack[i]; + if (supportsUnlabeledContinue(block)) { + return block.continueLabel; + } } } } - else { - for (let i = blockStack.length - 1; i >= 0; i--) { - const block = blockStack[i]; - if (supportsUnlabeledContinue(block)) { - return block.continueLabel; - } - } - } - return 0; } diff --git a/tests/baselines/reference/invalidContinueInDownlevelAsync.errors.txt b/tests/baselines/reference/invalidContinueInDownlevelAsync.errors.txt new file mode 100644 index 00000000000..ffdfee20090 --- /dev/null +++ b/tests/baselines/reference/invalidContinueInDownlevelAsync.errors.txt @@ -0,0 +1,17 @@ +tests/cases/compiler/invalidContinueInDownlevelAsync.ts(3,9): error TS1107: Jump target cannot cross function boundary. +tests/cases/compiler/invalidContinueInDownlevelAsync.ts(6,9): error TS7027: Unreachable code detected. + + +==== tests/cases/compiler/invalidContinueInDownlevelAsync.ts (2 errors) ==== + async function func() { + if (true) { + continue; + ~~~~~~~~~ +!!! error TS1107: Jump target cannot cross function boundary. + } + else { + await 1; + ~~~~~ +!!! error TS7027: Unreachable code detected. + } + } \ No newline at end of file diff --git a/tests/baselines/reference/invalidContinueInDownlevelAsync.js b/tests/baselines/reference/invalidContinueInDownlevelAsync.js new file mode 100644 index 00000000000..69e5e76e442 --- /dev/null +++ b/tests/baselines/reference/invalidContinueInDownlevelAsync.js @@ -0,0 +1,63 @@ +//// [invalidContinueInDownlevelAsync.ts] +async function func() { + if (true) { + continue; + } + else { + await 1; + } +} + +//// [invalidContinueInDownlevelAsync.js] +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; +var __generator = (this && this.__generator) || function (thisArg, body) { + var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; + return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; + function verb(n) { return function (v) { return step([n, v]); }; } + function step(op) { + if (f) throw new TypeError("Generator is already executing."); + while (_) try { + if (f = 1, y && (t = y[op[0] & 2 ? "return" : op[0] ? "throw" : "next"]) && !(t = t.call(y, op[1])).done) return t; + if (y = 0, t) op = [0, t.value]; + switch (op[0]) { + case 0: case 1: t = op; break; + case 4: _.label++; return { value: op[1], done: false }; + case 5: _.label++; y = op[1]; op = [0]; continue; + case 7: op = _.ops.pop(); _.trys.pop(); continue; + default: + if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } + if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } + if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } + if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } + if (t[2]) _.ops.pop(); + _.trys.pop(); continue; + } + op = body.call(thisArg, _); + } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } + if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; + } +}; +function func() { + return __awaiter(this, void 0, void 0, function () { + return __generator(this, function (_a) { + switch (_a.label) { + case 0: + if (!true) return [3 /*break*/, 1]; + continue; + return [3 /*break*/, 3]; + case 1: return [4 /*yield*/, 1]; + case 2: + _a.sent(); + _a.label = 3; + case 3: return [2 /*return*/]; + } + }); + }); +} diff --git a/tests/cases/compiler/invalidContinueInDownlevelAsync.ts b/tests/cases/compiler/invalidContinueInDownlevelAsync.ts new file mode 100644 index 00000000000..bdf476c8033 --- /dev/null +++ b/tests/cases/compiler/invalidContinueInDownlevelAsync.ts @@ -0,0 +1,8 @@ +async function func() { + if (true) { + continue; + } + else { + await 1; + } +} \ No newline at end of file From e7d2af0d72cbd0981174f76b3b66259e9a591ae5 Mon Sep 17 00:00:00 2001 From: Arthur Ozga Date: Thu, 17 Aug 2017 20:06:34 -0700 Subject: [PATCH 069/370] remove duplicate verify --- .../cases/fourslash/completionListAndMemberListOnCommentedDot.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/cases/fourslash/completionListAndMemberListOnCommentedDot.ts b/tests/cases/fourslash/completionListAndMemberListOnCommentedDot.ts index d0517d87279..b57e7b84b53 100644 --- a/tests/cases/fourslash/completionListAndMemberListOnCommentedDot.ts +++ b/tests/cases/fourslash/completionListAndMemberListOnCommentedDot.ts @@ -14,5 +14,4 @@ //////c./**/ goTo.marker(); -verify.completionListIsEmpty(); verify.completionListIsEmpty(); \ No newline at end of file From e4e969a210325190097c963cc3e4023682125c4a Mon Sep 17 00:00:00 2001 From: Arthur Ozga Date: Thu, 17 Aug 2017 20:06:46 -0700 Subject: [PATCH 070/370] respond to comments --- src/services/formatting/formatting.ts | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/src/services/formatting/formatting.ts b/src/services/formatting/formatting.ts index 22602d6031c..85cab126559 100644 --- a/src/services/formatting/formatting.ts +++ b/src/services/formatting/formatting.ts @@ -1159,17 +1159,20 @@ namespace ts.formatting { sourceFile: SourceFile, position: number, onlyMultiLine: boolean, - precedingToken: Node | null | undefined = findPrecedingToken(position, sourceFile), // tslint:disable-line:no-null-keyword + precedingToken?: Node | null, // tslint:disable-line:no-null-keyword tokenAtPosition = getTokenAtPosition(sourceFile, position, /*includeJsDocComment*/ false), predicate?: (c: CommentRange) => boolean): CommentRange | undefined { - // Considering a fixed position, - // - trailing comments are those following and on the same line as the position. - // - leading comments are those in the range [position, start of next non-trivia token) - // that are not trailing comments of that position. - // - // Note, `node.start` is the start-position of the first comment following the previous - // token that is not a trailing comment, so the leading and trailing comments of all - // tokens contain all comments in a sourcefile disjointly. + const tokenStart = tokenAtPosition.getStart(sourceFile); + if (tokenStart <= position && position < tokenAtPosition.getEnd()) { + return undefined; + } + + if (precedingToken === undefined) { + precedingToken = findPrecedingToken(position, sourceFile); + } + + // Between two consecutive tokens, all comments are either trailing on the former + // or leading on the latter (and none are in both lists). const trailingRangesOfPreviousToken = precedingToken && getTrailingCommentRanges(sourceFile.text, precedingToken.end); const leadingCommentRangesOfNextToken = getLeadingCommentRangesOfNode(tokenAtPosition, sourceFile); const commentRanges = trailingRangesOfPreviousToken && leadingCommentRangesOfNextToken ? From fa6773e685e2c1f19d6e35cb12f06edfa9c31ad5 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Fri, 18 Aug 2017 11:00:46 +0200 Subject: [PATCH 071/370] Type parameters from class should not be in scope in base class expression --- src/compiler/checker.ts | 12 +++++++++++- src/compiler/diagnosticMessages.json | 4 ++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 1c41be84ba7..d5518eee3da 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -1016,7 +1016,17 @@ namespace ts { } } break; - + case SyntaxKind.ExpressionWithTypeArguments: + if (lastLocation === (location).expression && (location.parent).token === SyntaxKind.ExtendsKeyword) { + const container = location.parent.parent; + if (isClassLike(container) && (result = lookup(getSymbolOfNode(container).members, name, meaning & SymbolFlags.Type))) { + if (nameNotFoundMessage) { + error(errorLocation, Diagnostics.Base_class_expressions_cannot_reference_class_type_parameters); + } + return undefined; + } + } + break; // It is not legal to reference a class's own type parameters from a computed property name that // belongs to the class. For example: // diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index 77e7f7e7b62..049483fdb8f 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -1912,6 +1912,10 @@ "category": "Error", "code": 2560 }, + "Base class expressions cannot reference class type parameters.": { + "category": "Error", + "code": 2561 + }, "JSX element attributes type '{0}' may not be a union type.": { "category": "Error", "code": 2600 From ade3b565ae9a5d483fcb85400ca183a90041c66f Mon Sep 17 00:00:00 2001 From: Andy Date: Fri, 18 Aug 2017 11:20:07 -0700 Subject: [PATCH 072/370] Revert public API changes to logger (#17899) --- src/harness/harnessLanguageService.ts | 5 +-- .../unittests/tsserverProjectSystem.ts | 5 +-- src/server/editorServices.ts | 32 +++++++++---------- src/server/server.ts | 28 ++++++++-------- src/server/session.ts | 4 +-- src/server/utilities.ts | 17 +++++++--- 6 files changed, 52 insertions(+), 39 deletions(-) diff --git a/src/harness/harnessLanguageService.ts b/src/harness/harnessLanguageService.ts index 5e8d6e76716..58df0d9a5e2 100644 --- a/src/harness/harnessLanguageService.ts +++ b/src/harness/harnessLanguageService.ts @@ -686,7 +686,7 @@ namespace Harness.LanguageService { this.host.log(message); } - err(message: string): void { + msg(message: string): void { this.host.log(message); } @@ -702,7 +702,8 @@ namespace Harness.LanguageService { return false; } - group() { throw ts.notImplemented(); } + startGroup() { throw ts.notImplemented(); } + endGroup() { throw ts.notImplemented(); } perftrc(message: string): void { return this.host.log(message); diff --git a/src/harness/unittests/tsserverProjectSystem.ts b/src/harness/unittests/tsserverProjectSystem.ts index 596e080430c..6e548231c91 100644 --- a/src/harness/unittests/tsserverProjectSystem.ts +++ b/src/harness/unittests/tsserverProjectSystem.ts @@ -39,8 +39,9 @@ namespace ts.projectSystem { loggingEnabled: () => false, perftrc: noop, info: noop, - err: noop, - group: noop, + msg: noop, + startGroup: noop, + endGroup: noop, getLogFileName: (): string => undefined }; diff --git a/src/server/editorServices.ts b/src/server/editorServices.ts index fe7946fc0f7..cb497ff774f 100644 --- a/src/server/editorServices.ts +++ b/src/server/editorServices.ts @@ -958,28 +958,28 @@ namespace ts.server { return; } - this.logger.group(info => { - let counter = 0; - counter = printProjects(this.externalProjects, info, counter); - counter = printProjects(this.configuredProjects, info, counter); - printProjects(this.inferredProjects, info, counter); - - info("Open files: "); - for (const rootFile of this.openFiles) { - info(`\t${rootFile.fileName}`); - } - }); - - function printProjects(projects: Project[], info: (msg: string) => void, counter: number): number { + this.logger.startGroup(); + let counter = 0; + const printProjects = (projects: Project[], counter: number): number => { for (const project of projects) { project.updateGraph(); - info(`Project '${project.getProjectName()}' (${ProjectKind[project.projectKind]}) ${counter}`); - info(project.filesToString()); - info("-----------------------------------------------"); + this.logger.info(`Project '${project.getProjectName()}' (${ProjectKind[project.projectKind]}) ${counter}`); + this.logger.info(project.filesToString()); + this.logger.info("-----------------------------------------------"); counter++; } return counter; + }; + counter = printProjects(this.externalProjects, counter); + counter = printProjects(this.configuredProjects, counter); + printProjects(this.inferredProjects, counter); + + this.logger.info("Open files: "); + for (const rootFile of this.openFiles) { + this.logger.info(`\t${rootFile.fileName}`); } + + this.logger.endGroup(); } private findConfiguredProjectByProjectName(configFileName: NormalizedPath) { diff --git a/src/server/server.ts b/src/server/server.ts index 66467fd46ae..0fe37dd8ba0 100644 --- a/src/server/server.ts +++ b/src/server/server.ts @@ -140,6 +140,8 @@ namespace ts.server { class Logger implements server.Logger { private fd = -1; private seq = 0; + private inGroup = false; + private firstInGroup = true; constructor(private readonly logFilename: string, private readonly traceToConsole: boolean, @@ -169,24 +171,24 @@ namespace ts.server { } perftrc(s: string) { - this.msg(s, "Perf"); + this.msg(s, Msg.Perf); } info(s: string) { - this.msg(s, "Info"); + this.msg(s, Msg.Info); } err(s: string) { - this.msg(s, "Err"); + this.msg(s, Msg.Err); } - group(logGroupEntries: (log: (msg: string) => void) => void) { - let firstInGroup = false; - logGroupEntries(s => { - this.msg(s, "Info", /*inGroup*/ true, firstInGroup); - firstInGroup = false; - }); - this.seq++; + startGroup() { + this.inGroup = true; + this.firstInGroup = true; + } + + endGroup() { + this.inGroup = false; } loggingEnabled() { @@ -197,16 +199,16 @@ namespace ts.server { return this.loggingEnabled() && this.level >= level; } - private msg(s: string, type: string, inGroup = false, firstInGroup = false) { + msg(s: string, type: Msg.Types = Msg.Err) { if (!this.canWrite) return; s = `[${nowString()}] ${s}\n`; - if (!inGroup || firstInGroup) { + if (!this.inGroup || this.firstInGroup) { const prefix = Logger.padStringRight(type + " " + this.seq.toString(), " "); s = prefix + s; } this.write(s); - if (!inGroup) { + if (!this.inGroup) { this.seq++; } } diff --git a/src/server/session.ts b/src/server/session.ts index 4122408cfa6..6eb0413f6d8 100644 --- a/src/server/session.ts +++ b/src/server/session.ts @@ -368,7 +368,7 @@ namespace ts.server { msg += "\n" + (err).stack; } } - this.logger.err(msg); + this.logger.msg(msg, Msg.Err); } public send(msg: protocol.Message) { @@ -1947,7 +1947,7 @@ namespace ts.server { return this.executeWithRequestId(request.seq, () => handler(request)); } else { - this.logger.err(`Unrecognized JSON command: ${JSON.stringify(request)}`); + this.logger.msg(`Unrecognized JSON command: ${JSON.stringify(request)}`, Msg.Err); this.output(undefined, CommandNames.Unknown, request.seq, `Unrecognized JSON command: ${request.command}`); return { responseRequired: false }; } diff --git a/src/server/utilities.ts b/src/server/utilities.ts index 0d4bc101ff6..e2e2a67eaf1 100644 --- a/src/server/utilities.ts +++ b/src/server/utilities.ts @@ -17,11 +17,22 @@ namespace ts.server { loggingEnabled(): boolean; perftrc(s: string): void; info(s: string): void; - err(s: string): void; - group(logGroupEntries: (log: (msg: string) => void) => void): void; + startGroup(): void; + endGroup(): void; + msg(s: string, type?: Msg.Types): void; getLogFileName(): string; } + export namespace Msg { + export type Err = "Err"; + export const Err: Err = "Err"; + export type Info = "Info"; + export const Info: Info = "Info"; + export type Perf = "Perf"; + export const Perf: Perf = "Perf"; + export type Types = Err | Info | Perf; + } + function getProjectRootPath(project: Project): Path { switch (project.projectKind) { case ProjectKind.Configured: @@ -115,9 +126,7 @@ namespace ts.server { } export function createNormalizedPathMap(): NormalizedPathMap { -/* tslint:disable:no-null-keyword */ const map = createMap(); -/* tslint:enable:no-null-keyword */ return { get(path) { return map.get(path); From 6b68da1185d80a04a910240493dd7a8b5852bc93 Mon Sep 17 00:00:00 2001 From: Arthur Ozga Date: Fri, 18 Aug 2017 11:32:53 -0700 Subject: [PATCH 073/370] Revert "Fix getConstraintOfIndexedAccess" --- src/compiler/checker.ts | 18 ++--- src/compiler/core.ts | 2 +- ...ionOperatorWithConstrainedTypeParameter.js | 27 -------- ...eratorWithConstrainedTypeParameter.symbols | 54 --------------- ...OperatorWithConstrainedTypeParameter.types | 64 ------------------ ...tiveConstraintOfIndexAccessType.errors.txt | 67 ------------------- ...nonPrimitiveConstraintOfIndexAccessType.js | 67 ------------------- ...ionOperatorWithConstrainedTypeParameter.ts | 11 --- ...nonPrimitiveConstraintOfIndexAccessType.ts | 32 --------- 9 files changed, 8 insertions(+), 334 deletions(-) delete mode 100644 tests/baselines/reference/additionOperatorWithConstrainedTypeParameter.js delete mode 100644 tests/baselines/reference/additionOperatorWithConstrainedTypeParameter.symbols delete mode 100644 tests/baselines/reference/additionOperatorWithConstrainedTypeParameter.types delete mode 100644 tests/baselines/reference/nonPrimitiveConstraintOfIndexAccessType.errors.txt delete mode 100644 tests/baselines/reference/nonPrimitiveConstraintOfIndexAccessType.js delete mode 100644 tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithConstrainedTypeParameter.ts delete mode 100644 tests/cases/conformance/types/nonPrimitive/nonPrimitiveConstraintOfIndexAccessType.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 41921e3c789..6df6b1f9ce1 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -5911,13 +5911,7 @@ namespace ts { return transformed; } const baseObjectType = getBaseConstraintOfType(type.objectType); - const keepTypeParameterForMappedType = baseObjectType && getObjectFlags(baseObjectType) & ObjectFlags.Mapped && type.indexType.flags & TypeFlags.TypeParameter; - const baseIndexType = !keepTypeParameterForMappedType && getBaseConstraintOfType(type.indexType); - if (baseObjectType && baseIndexType === stringType && !getIndexInfoOfType(baseObjectType, IndexKind.String)) { - // getIndexedAccessType returns `any` for X[string] where X doesn't have an index signature. - // instead, return undefined so that the indexed access check fails - return undefined; - } + const baseIndexType = getBaseConstraintOfType(type.indexType); return baseObjectType || baseIndexType ? getIndexedAccessType(baseObjectType || type.objectType, baseIndexType || type.indexType) : undefined; } @@ -5967,9 +5961,8 @@ namespace ts { function computeBaseConstraint(t: Type): Type { if (t.flags & TypeFlags.TypeParameter) { const constraint = getConstraintFromTypeParameter(t); - return (t as TypeParameter).isThisType || !constraint ? - constraint : - getBaseConstraint(constraint); + return (t).isThisType ? constraint : + constraint ? getBaseConstraint(constraint) : undefined; } if (t.flags & TypeFlags.UnionOrIntersection) { const types = (t).types; @@ -5997,6 +5990,9 @@ namespace ts { const baseIndexedAccess = baseObjectType && baseIndexType ? getIndexedAccessType(baseObjectType, baseIndexType) : undefined; return baseIndexedAccess && baseIndexedAccess !== unknownType ? getBaseConstraint(baseIndexedAccess) : undefined; } + if (isGenericMappedType(t)) { + return emptyObjectType; + } return t; } } @@ -9293,7 +9289,7 @@ namespace ts { } else if (target.flags & TypeFlags.IndexedAccess) { // A type S is related to a type T[K] if S is related to A[K], where K is string-like and - // A is the apparent type of T. + // A is the apparent type of S. const constraint = getConstraintOfType(target); if (constraint) { if (result = isRelatedTo(source, constraint, reportErrors)) { diff --git a/src/compiler/core.ts b/src/compiler/core.ts index 422df2ead05..8cab1b41155 100644 --- a/src/compiler/core.ts +++ b/src/compiler/core.ts @@ -718,7 +718,7 @@ namespace ts { export function sum, K extends string>(array: T[], prop: K): number { let result = 0; for (const v of array) { - // TODO: Remove the following type assertion once the fix for #17069 is merged + // Note: we need the following type assertion because of GH #17069 result += v[prop] as number; } return result; diff --git a/tests/baselines/reference/additionOperatorWithConstrainedTypeParameter.js b/tests/baselines/reference/additionOperatorWithConstrainedTypeParameter.js deleted file mode 100644 index 1366e242182..00000000000 --- a/tests/baselines/reference/additionOperatorWithConstrainedTypeParameter.js +++ /dev/null @@ -1,27 +0,0 @@ -//// [additionOperatorWithConstrainedTypeParameter.ts] -// test for #17069 -function sum, K extends string>(n: number, v: T, k: K) { - n = n + v[k]; - n += v[k]; // += should work the same way -} -function realSum, K extends string>(n: number, vs: T[], k: K) { - for (const v of vs) { - n = n + v[k]; - n += v[k]; - } -} - - -//// [additionOperatorWithConstrainedTypeParameter.js] -// test for #17069 -function sum(n, v, k) { - n = n + v[k]; - n += v[k]; // += should work the same way -} -function realSum(n, vs, k) { - for (var _i = 0, vs_1 = vs; _i < vs_1.length; _i++) { - var v = vs_1[_i]; - n = n + v[k]; - n += v[k]; - } -} diff --git a/tests/baselines/reference/additionOperatorWithConstrainedTypeParameter.symbols b/tests/baselines/reference/additionOperatorWithConstrainedTypeParameter.symbols deleted file mode 100644 index e7055c1e38f..00000000000 --- a/tests/baselines/reference/additionOperatorWithConstrainedTypeParameter.symbols +++ /dev/null @@ -1,54 +0,0 @@ -=== tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithConstrainedTypeParameter.ts === -// test for #17069 -function sum, K extends string>(n: number, v: T, k: K) { ->sum : Symbol(sum, Decl(additionOperatorWithConstrainedTypeParameter.ts, 0, 0)) ->T : Symbol(T, Decl(additionOperatorWithConstrainedTypeParameter.ts, 1, 13)) ->Record : Symbol(Record, Decl(lib.d.ts, --, --)) ->K : Symbol(K, Decl(additionOperatorWithConstrainedTypeParameter.ts, 1, 41)) ->K : Symbol(K, Decl(additionOperatorWithConstrainedTypeParameter.ts, 1, 41)) ->n : Symbol(n, Decl(additionOperatorWithConstrainedTypeParameter.ts, 1, 60)) ->v : Symbol(v, Decl(additionOperatorWithConstrainedTypeParameter.ts, 1, 70)) ->T : Symbol(T, Decl(additionOperatorWithConstrainedTypeParameter.ts, 1, 13)) ->k : Symbol(k, Decl(additionOperatorWithConstrainedTypeParameter.ts, 1, 76)) ->K : Symbol(K, Decl(additionOperatorWithConstrainedTypeParameter.ts, 1, 41)) - - n = n + v[k]; ->n : Symbol(n, Decl(additionOperatorWithConstrainedTypeParameter.ts, 1, 60)) ->n : Symbol(n, Decl(additionOperatorWithConstrainedTypeParameter.ts, 1, 60)) ->v : Symbol(v, Decl(additionOperatorWithConstrainedTypeParameter.ts, 1, 70)) ->k : Symbol(k, Decl(additionOperatorWithConstrainedTypeParameter.ts, 1, 76)) - - n += v[k]; // += should work the same way ->n : Symbol(n, Decl(additionOperatorWithConstrainedTypeParameter.ts, 1, 60)) ->v : Symbol(v, Decl(additionOperatorWithConstrainedTypeParameter.ts, 1, 70)) ->k : Symbol(k, Decl(additionOperatorWithConstrainedTypeParameter.ts, 1, 76)) -} -function realSum, K extends string>(n: number, vs: T[], k: K) { ->realSum : Symbol(realSum, Decl(additionOperatorWithConstrainedTypeParameter.ts, 4, 1)) ->T : Symbol(T, Decl(additionOperatorWithConstrainedTypeParameter.ts, 5, 17)) ->Record : Symbol(Record, Decl(lib.d.ts, --, --)) ->K : Symbol(K, Decl(additionOperatorWithConstrainedTypeParameter.ts, 5, 45)) ->K : Symbol(K, Decl(additionOperatorWithConstrainedTypeParameter.ts, 5, 45)) ->n : Symbol(n, Decl(additionOperatorWithConstrainedTypeParameter.ts, 5, 64)) ->vs : Symbol(vs, Decl(additionOperatorWithConstrainedTypeParameter.ts, 5, 74)) ->T : Symbol(T, Decl(additionOperatorWithConstrainedTypeParameter.ts, 5, 17)) ->k : Symbol(k, Decl(additionOperatorWithConstrainedTypeParameter.ts, 5, 83)) ->K : Symbol(K, Decl(additionOperatorWithConstrainedTypeParameter.ts, 5, 45)) - - for (const v of vs) { ->v : Symbol(v, Decl(additionOperatorWithConstrainedTypeParameter.ts, 6, 14)) ->vs : Symbol(vs, Decl(additionOperatorWithConstrainedTypeParameter.ts, 5, 74)) - - n = n + v[k]; ->n : Symbol(n, Decl(additionOperatorWithConstrainedTypeParameter.ts, 5, 64)) ->n : Symbol(n, Decl(additionOperatorWithConstrainedTypeParameter.ts, 5, 64)) ->v : Symbol(v, Decl(additionOperatorWithConstrainedTypeParameter.ts, 6, 14)) ->k : Symbol(k, Decl(additionOperatorWithConstrainedTypeParameter.ts, 5, 83)) - - n += v[k]; ->n : Symbol(n, Decl(additionOperatorWithConstrainedTypeParameter.ts, 5, 64)) ->v : Symbol(v, Decl(additionOperatorWithConstrainedTypeParameter.ts, 6, 14)) ->k : Symbol(k, Decl(additionOperatorWithConstrainedTypeParameter.ts, 5, 83)) - } -} - diff --git a/tests/baselines/reference/additionOperatorWithConstrainedTypeParameter.types b/tests/baselines/reference/additionOperatorWithConstrainedTypeParameter.types deleted file mode 100644 index d52c77a94fd..00000000000 --- a/tests/baselines/reference/additionOperatorWithConstrainedTypeParameter.types +++ /dev/null @@ -1,64 +0,0 @@ -=== tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithConstrainedTypeParameter.ts === -// test for #17069 -function sum, K extends string>(n: number, v: T, k: K) { ->sum : , K extends string>(n: number, v: T, k: K) => void ->T : T ->Record : Record ->K : K ->K : K ->n : number ->v : T ->T : T ->k : K ->K : K - - n = n + v[k]; ->n = n + v[k] : number ->n : number ->n + v[k] : number ->n : number ->v[k] : T[K] ->v : T ->k : K - - n += v[k]; // += should work the same way ->n += v[k] : number ->n : number ->v[k] : T[K] ->v : T ->k : K -} -function realSum, K extends string>(n: number, vs: T[], k: K) { ->realSum : , K extends string>(n: number, vs: T[], k: K) => void ->T : T ->Record : Record ->K : K ->K : K ->n : number ->vs : T[] ->T : T ->k : K ->K : K - - for (const v of vs) { ->v : T ->vs : T[] - - n = n + v[k]; ->n = n + v[k] : number ->n : number ->n + v[k] : number ->n : number ->v[k] : T[K] ->v : T ->k : K - - n += v[k]; ->n += v[k] : number ->n : number ->v[k] : T[K] ->v : T ->k : K - } -} - diff --git a/tests/baselines/reference/nonPrimitiveConstraintOfIndexAccessType.errors.txt b/tests/baselines/reference/nonPrimitiveConstraintOfIndexAccessType.errors.txt deleted file mode 100644 index 56781157131..00000000000 --- a/tests/baselines/reference/nonPrimitiveConstraintOfIndexAccessType.errors.txt +++ /dev/null @@ -1,67 +0,0 @@ -tests/cases/conformance/types/nonPrimitive/nonPrimitiveConstraintOfIndexAccessType.ts(3,5): error TS2322: Type 'string' is not assignable to type 'T[P]'. -tests/cases/conformance/types/nonPrimitive/nonPrimitiveConstraintOfIndexAccessType.ts(6,5): error TS2322: Type 'string' is not assignable to type 'T[P]'. -tests/cases/conformance/types/nonPrimitive/nonPrimitiveConstraintOfIndexAccessType.ts(9,5): error TS2322: Type 'string' is not assignable to type 'T[P]'. -tests/cases/conformance/types/nonPrimitive/nonPrimitiveConstraintOfIndexAccessType.ts(12,5): error TS2322: Type 'string' is not assignable to type 'T[P]'. -tests/cases/conformance/types/nonPrimitive/nonPrimitiveConstraintOfIndexAccessType.ts(15,5): error TS2322: Type 'string' is not assignable to type 'T[P]'. -tests/cases/conformance/types/nonPrimitive/nonPrimitiveConstraintOfIndexAccessType.ts(18,5): error TS2322: Type 'string' is not assignable to type 'T[P]'. -tests/cases/conformance/types/nonPrimitive/nonPrimitiveConstraintOfIndexAccessType.ts(21,5): error TS2322: Type 'string' is not assignable to type 'T[P]'. -tests/cases/conformance/types/nonPrimitive/nonPrimitiveConstraintOfIndexAccessType.ts(24,5): error TS2322: Type 'string' is not assignable to type 'T[P]'. -tests/cases/conformance/types/nonPrimitive/nonPrimitiveConstraintOfIndexAccessType.ts(27,5): error TS2322: Type 'string' is not assignable to type 'T[P]'. -tests/cases/conformance/types/nonPrimitive/nonPrimitiveConstraintOfIndexAccessType.ts(30,5): error TS2322: Type 'string' is not assignable to type 'T[P]'. - Type 'string' is not assignable to type 'number'. - - -==== tests/cases/conformance/types/nonPrimitive/nonPrimitiveConstraintOfIndexAccessType.ts (10 errors) ==== - // test for #15371 - function f(s: string, tp: T[P]): void { - tp = s; - ~~ -!!! error TS2322: Type 'string' is not assignable to type 'T[P]'. - } - function g(s: string, tp: T[P]): void { - tp = s; - ~~ -!!! error TS2322: Type 'string' is not assignable to type 'T[P]'. - } - function h(s: string, tp: T[P]): void { - tp = s; - ~~ -!!! error TS2322: Type 'string' is not assignable to type 'T[P]'. - } - function i(s: string, tp: T[P]): void { - tp = s; - ~~ -!!! error TS2322: Type 'string' is not assignable to type 'T[P]'. - } - function j(s: string, tp: T[P]): void { - tp = s; - ~~ -!!! error TS2322: Type 'string' is not assignable to type 'T[P]'. - } - function k(s: string, tp: T[P]): void { - tp = s; - ~~ -!!! error TS2322: Type 'string' is not assignable to type 'T[P]'. - } - function o(s: string, tp: T[P]): void { - tp = s; - ~~ -!!! error TS2322: Type 'string' is not assignable to type 'T[P]'. - } - function l(s: string, tp: T[P]): void { - tp = s; - ~~ -!!! error TS2322: Type 'string' is not assignable to type 'T[P]'. - } - function m(s: string, tp: T[P]): void { - tp = s; - ~~ -!!! error TS2322: Type 'string' is not assignable to type 'T[P]'. - } - function n(s: string, tp: T[P]): void { - tp = s; - ~~ -!!! error TS2322: Type 'string' is not assignable to type 'T[P]'. -!!! error TS2322: Type 'string' is not assignable to type 'number'. - } - \ No newline at end of file diff --git a/tests/baselines/reference/nonPrimitiveConstraintOfIndexAccessType.js b/tests/baselines/reference/nonPrimitiveConstraintOfIndexAccessType.js deleted file mode 100644 index 7a24345a94b..00000000000 --- a/tests/baselines/reference/nonPrimitiveConstraintOfIndexAccessType.js +++ /dev/null @@ -1,67 +0,0 @@ -//// [nonPrimitiveConstraintOfIndexAccessType.ts] -// test for #15371 -function f(s: string, tp: T[P]): void { - tp = s; -} -function g(s: string, tp: T[P]): void { - tp = s; -} -function h(s: string, tp: T[P]): void { - tp = s; -} -function i(s: string, tp: T[P]): void { - tp = s; -} -function j(s: string, tp: T[P]): void { - tp = s; -} -function k(s: string, tp: T[P]): void { - tp = s; -} -function o(s: string, tp: T[P]): void { - tp = s; -} -function l(s: string, tp: T[P]): void { - tp = s; -} -function m(s: string, tp: T[P]): void { - tp = s; -} -function n(s: string, tp: T[P]): void { - tp = s; -} - - -//// [nonPrimitiveConstraintOfIndexAccessType.js] -"use strict"; -// test for #15371 -function f(s, tp) { - tp = s; -} -function g(s, tp) { - tp = s; -} -function h(s, tp) { - tp = s; -} -function i(s, tp) { - tp = s; -} -function j(s, tp) { - tp = s; -} -function k(s, tp) { - tp = s; -} -function o(s, tp) { - tp = s; -} -function l(s, tp) { - tp = s; -} -function m(s, tp) { - tp = s; -} -function n(s, tp) { - tp = s; -} diff --git a/tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithConstrainedTypeParameter.ts b/tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithConstrainedTypeParameter.ts deleted file mode 100644 index 2303bb33944..00000000000 --- a/tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithConstrainedTypeParameter.ts +++ /dev/null @@ -1,11 +0,0 @@ -// test for #17069 -function sum, K extends string>(n: number, v: T, k: K) { - n = n + v[k]; - n += v[k]; // += should work the same way -} -function realSum, K extends string>(n: number, vs: T[], k: K) { - for (const v of vs) { - n = n + v[k]; - n += v[k]; - } -} diff --git a/tests/cases/conformance/types/nonPrimitive/nonPrimitiveConstraintOfIndexAccessType.ts b/tests/cases/conformance/types/nonPrimitive/nonPrimitiveConstraintOfIndexAccessType.ts deleted file mode 100644 index 1e852f12f92..00000000000 --- a/tests/cases/conformance/types/nonPrimitive/nonPrimitiveConstraintOfIndexAccessType.ts +++ /dev/null @@ -1,32 +0,0 @@ -// @strict: true -// test for #15371 -function f(s: string, tp: T[P]): void { - tp = s; -} -function g(s: string, tp: T[P]): void { - tp = s; -} -function h(s: string, tp: T[P]): void { - tp = s; -} -function i(s: string, tp: T[P]): void { - tp = s; -} -function j(s: string, tp: T[P]): void { - tp = s; -} -function k(s: string, tp: T[P]): void { - tp = s; -} -function o(s: string, tp: T[P]): void { - tp = s; -} -function l(s: string, tp: T[P]): void { - tp = s; -} -function m(s: string, tp: T[P]): void { - tp = s; -} -function n(s: string, tp: T[P]): void { - tp = s; -} From ecd2ae8dac34ab8cc9f41d054824b1fc9cfa73ff Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Fri, 18 Aug 2017 11:44:36 -0700 Subject: [PATCH 074/370] Deduplicate inputfiles before running RWC tests (#17877) * Deduplicate inputfiles before running RWC tests We deduplicate in the compiler, but we don't in the harness - this causes tests where the same file is listed multiple times in the arguments to not have the expected errors written, because we write out the same file multiple times when we should not. * Don't completely omit both copied of duplicates * Remove trailing whitespace * Maintain list order while filtering duplicates * Merge adjacent loops --- src/harness/rwcRunner.ts | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/harness/rwcRunner.ts b/src/harness/rwcRunner.ts index a1dc50349e4..cddb9b19d4a 100644 --- a/src/harness/rwcRunner.ts +++ b/src/harness/rwcRunner.ts @@ -90,9 +90,16 @@ namespace RWC { ts.setConfigFileInOptions(opts.options, configParseResult.options.configFile); } - // Load the files + // Deduplicate files so they are only printed once in baselines (they are deduplicated within the compiler already) + const uniqueNames = ts.createMap(); for (const fileName of fileNames) { - inputFiles.push(getHarnessCompilerInputUnit(fileName)); + // Must maintain order, build result list while checking map + const normalized = ts.normalizeSlashes(fileName); + if (!uniqueNames.has(normalized)) { + uniqueNames.set(normalized, true); + // Load the file + inputFiles.push(getHarnessCompilerInputUnit(fileName)); + } } // Add files to compilation From 4983e11b67af07c4d0c737249f22a51e2f614f5a Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Fri, 18 Aug 2017 11:04:53 -0700 Subject: [PATCH 075/370] Added test for leading underscore property name suggestions. --- .../spellingSuggestionLeadingUnderscores01.ts | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 tests/cases/compiler/spellingSuggestionLeadingUnderscores01.ts diff --git a/tests/cases/compiler/spellingSuggestionLeadingUnderscores01.ts b/tests/cases/compiler/spellingSuggestionLeadingUnderscores01.ts new file mode 100644 index 00000000000..99c9644b095 --- /dev/null +++ b/tests/cases/compiler/spellingSuggestionLeadingUnderscores01.ts @@ -0,0 +1,17 @@ +// @module: commonjs +// @filename abc.ts +export declare let a: { + __foo: 10, +} + +a.___foo + +// @filename def.ts +export let b: { + __foo: number +} + +b = { + __foo: 100, +} + From 4ac9091ea14665a42cfd397113b9f04a4e8abd7c Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Fri, 18 Aug 2017 11:46:51 -0700 Subject: [PATCH 076/370] Accepted baselines. --- ...gSuggestionLeadingUnderscores01.errors.txt | 23 ++++++++++++++++ .../spellingSuggestionLeadingUnderscores01.js | 26 +++++++++++++++++++ 2 files changed, 49 insertions(+) create mode 100644 tests/baselines/reference/spellingSuggestionLeadingUnderscores01.errors.txt create mode 100644 tests/baselines/reference/spellingSuggestionLeadingUnderscores01.js diff --git a/tests/baselines/reference/spellingSuggestionLeadingUnderscores01.errors.txt b/tests/baselines/reference/spellingSuggestionLeadingUnderscores01.errors.txt new file mode 100644 index 00000000000..a265dfc1fb6 --- /dev/null +++ b/tests/baselines/reference/spellingSuggestionLeadingUnderscores01.errors.txt @@ -0,0 +1,23 @@ +tests/cases/compiler/spellingSuggestionLeadingUnderscores01.ts(6,3): error TS2551: Property '___foo' does not exist on type '{ __foo: 10; }'. Did you mean '___foo'? + + +==== tests/cases/compiler/spellingSuggestionLeadingUnderscores01.ts (1 errors) ==== + // @filename abc.ts + export declare let a: { + __foo: 10, + } + + a.___foo + ~~~~~~ +!!! error TS2551: Property '___foo' does not exist on type '{ __foo: 10; }'. Did you mean '___foo'? + + // @filename def.ts + export let b: { + __foo: number + } + + b = { + __foo: 100, + } + + \ No newline at end of file diff --git a/tests/baselines/reference/spellingSuggestionLeadingUnderscores01.js b/tests/baselines/reference/spellingSuggestionLeadingUnderscores01.js new file mode 100644 index 00000000000..fbcc3dc1cad --- /dev/null +++ b/tests/baselines/reference/spellingSuggestionLeadingUnderscores01.js @@ -0,0 +1,26 @@ +//// [spellingSuggestionLeadingUnderscores01.ts] +// @filename abc.ts +export declare let a: { + __foo: 10, +} + +a.___foo + +// @filename def.ts +export let b: { + __foo: number +} + +b = { + __foo: 100, +} + + + +//// [spellingSuggestionLeadingUnderscores01.js] +"use strict"; +exports.__esModule = true; +exports.a.___foo; +exports.b = { + __foo: 100 +}; From 70ad2bdb3134139ec21c6682c42e523aa4a1784c Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Fri, 18 Aug 2017 12:54:35 -0700 Subject: [PATCH 077/370] Ensure that property suggestions are correctly escaped. --- src/compiler/checker.ts | 4 ++-- src/compiler/core.ts | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 6df6b1f9ce1..54388d09e7d 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -14676,8 +14676,8 @@ namespace ts { } } const suggestion = getSuggestionForNonexistentProperty(propNode, containingType); - if (suggestion) { - errorInfo = chainDiagnosticMessages(errorInfo, Diagnostics.Property_0_does_not_exist_on_type_1_Did_you_mean_2, declarationNameToString(propNode), typeToString(containingType), suggestion); + if (suggestion !== undefined) { + errorInfo = chainDiagnosticMessages(errorInfo, Diagnostics.Property_0_does_not_exist_on_type_1_Did_you_mean_2, declarationNameToString(propNode), typeToString(containingType), unescapeLeadingUnderscores(suggestion)); } else { errorInfo = chainDiagnosticMessages(errorInfo, Diagnostics.Property_0_does_not_exist_on_type_1, declarationNameToString(propNode), typeToString(containingType)); diff --git a/src/compiler/core.ts b/src/compiler/core.ts index 8cab1b41155..eae2e5ee336 100644 --- a/src/compiler/core.ts +++ b/src/compiler/core.ts @@ -1359,7 +1359,7 @@ namespace ts { }; } - export function chainDiagnosticMessages(details: DiagnosticMessageChain, message: DiagnosticMessage, ...args: any[]): DiagnosticMessageChain; + export function chainDiagnosticMessages(details: DiagnosticMessageChain, message: DiagnosticMessage, ...args: string[]): DiagnosticMessageChain; export function chainDiagnosticMessages(details: DiagnosticMessageChain, message: DiagnosticMessage): DiagnosticMessageChain { let text = getLocaleSpecificMessage(message); From 50671c374c51383d80360963f8635c5a9af97eed Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Fri, 18 Aug 2017 12:55:35 -0700 Subject: [PATCH 078/370] Try to provide a spelling suggestion when object literals have excess properties. --- src/compiler/checker.ts | 21 ++++++++++++++++++--- src/compiler/diagnosticMessages.json | 4 ++++ 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 54388d09e7d..d2b51867217 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -9067,11 +9067,26 @@ namespace ts { else { // use the property's value declaration if the property is assigned inside the literal itself const objectLiteralDeclaration = source.symbol && firstOrUndefined(source.symbol.declarations); + let suggestion; if (prop.valueDeclaration && findAncestor(prop.valueDeclaration, d => d === objectLiteralDeclaration)) { - errorNode = prop.valueDeclaration; + const propDeclaration = prop.valueDeclaration as ObjectLiteralElementLike; + Debug.assertNode(propDeclaration, isObjectLiteralElementLike); + + errorNode = propDeclaration; + + const propNameNode = propDeclaration.name as Identifier; + Debug.assertNode(propNameNode, isIdentifier); + suggestion = getSuggestionForNonexistentProperty(propNameNode, target); + } + + if (suggestion !== undefined) { + reportError(Diagnostics.Object_literal_may_only_specify_known_properties_but_0_does_not_exist_in_type_1_Did_you_mean_to_write_2, + symbolToString(prop), typeToString(target), unescapeLeadingUnderscores(suggestion)); + } + else { + reportError(Diagnostics.Object_literal_may_only_specify_known_properties_and_0_does_not_exist_in_type_1, + symbolToString(prop), typeToString(target)); } - reportError(Diagnostics.Object_literal_may_only_specify_known_properties_and_0_does_not_exist_in_type_1, - symbolToString(prop), typeToString(target)); } } return true; diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index 77e7f7e7b62..e7d292d57d1 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -1912,6 +1912,10 @@ "category": "Error", "code": 2560 }, + "Object literal may only specify known properties, but '{0}' does not exist in type '{1}'. Did you mean to write '{2}'?": { + "category": "Error", + "code": 2561 + }, "JSX element attributes type '{0}' may not be a union type.": { "category": "Error", "code": 2600 From 8b10ea4c1d3a4376e18a70a8be7d0e0af780ceed Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Fri, 18 Aug 2017 12:55:54 -0700 Subject: [PATCH 079/370] Accepted baselines. --- .../reference/nestedFreshLiteral.errors.txt | 4 ++-- .../objectLiteralExcessProperties.errors.txt | 16 ++++++++-------- ...lingSuggestionLeadingUnderscores01.errors.txt | 4 ++-- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/tests/baselines/reference/nestedFreshLiteral.errors.txt b/tests/baselines/reference/nestedFreshLiteral.errors.txt index 6aff94ac0a6..d68b398449d 100644 --- a/tests/baselines/reference/nestedFreshLiteral.errors.txt +++ b/tests/baselines/reference/nestedFreshLiteral.errors.txt @@ -4,7 +4,7 @@ tests/cases/compiler/nestedFreshLiteral.ts(12,21): error TS2322: Type '{ nested: Type '{ prop: { colour: string; }; }' is not assignable to type 'NestedSelector'. Types of property 'prop' are incompatible. Type '{ colour: string; }' is not assignable to type 'CSSProps'. - Object literal may only specify known properties, and 'colour' does not exist in type 'CSSProps'. + Object literal may only specify known properties, but 'colour' does not exist in type 'CSSProps'. Did you mean to write 'color'? ==== tests/cases/compiler/nestedFreshLiteral.ts (1 errors) ==== @@ -27,5 +27,5 @@ tests/cases/compiler/nestedFreshLiteral.ts(12,21): error TS2322: Type '{ nested: !!! error TS2322: Type '{ prop: { colour: string; }; }' is not assignable to type 'NestedSelector'. !!! error TS2322: Types of property 'prop' are incompatible. !!! error TS2322: Type '{ colour: string; }' is not assignable to type 'CSSProps'. -!!! error TS2322: Object literal may only specify known properties, and 'colour' does not exist in type 'CSSProps'. +!!! error TS2322: Object literal may only specify known properties, but 'colour' does not exist in type 'CSSProps'. Did you mean to write 'color'? } \ No newline at end of file diff --git a/tests/baselines/reference/objectLiteralExcessProperties.errors.txt b/tests/baselines/reference/objectLiteralExcessProperties.errors.txt index 98f2e30287c..0c5909dc4ed 100644 --- a/tests/baselines/reference/objectLiteralExcessProperties.errors.txt +++ b/tests/baselines/reference/objectLiteralExcessProperties.errors.txt @@ -1,5 +1,5 @@ tests/cases/compiler/objectLiteralExcessProperties.ts(9,18): error TS2322: Type '{ forword: string; }' is not assignable to type 'Book'. - Object literal may only specify known properties, and 'forword' does not exist in type 'Book'. + Object literal may only specify known properties, but 'forword' does not exist in type 'Book'. Did you mean to write 'foreword'? tests/cases/compiler/objectLiteralExcessProperties.ts(11,27): error TS2322: Type '{ foreward: string; }' is not assignable to type 'string | Book'. Object literal may only specify known properties, and 'foreward' does not exist in type 'string | Book'. tests/cases/compiler/objectLiteralExcessProperties.ts(13,53): error TS2322: Type '({ foreword: string; } | { forwards: string; })[]' is not assignable to type 'Book | Book[]'. @@ -8,9 +8,9 @@ tests/cases/compiler/objectLiteralExcessProperties.ts(13,53): error TS2322: Type Type '{ forwards: string; }' is not assignable to type 'Book'. Object literal may only specify known properties, and 'forwards' does not exist in type 'Book'. tests/cases/compiler/objectLiteralExcessProperties.ts(15,42): error TS2322: Type '{ foreword: string; colour: string; }' is not assignable to type 'Book & Cover'. - Object literal may only specify known properties, and 'colour' does not exist in type 'Book & Cover'. + Object literal may only specify known properties, but 'colour' does not exist in type 'Book & Cover'. Did you mean to write 'color'? tests/cases/compiler/objectLiteralExcessProperties.ts(17,26): error TS2322: Type '{ foreward: string; color: string; }' is not assignable to type 'Book & Cover'. - Object literal may only specify known properties, and 'foreward' does not exist in type 'Book & Cover'. + Object literal may only specify known properties, but 'foreward' does not exist in type 'Book & Cover'. Did you mean to write 'foreword'? tests/cases/compiler/objectLiteralExcessProperties.ts(19,57): error TS2322: Type '{ foreword: string; color: string; price: number; }' is not assignable to type 'Book & Cover'. Object literal may only specify known properties, and 'price' does not exist in type 'Book & Cover'. tests/cases/compiler/objectLiteralExcessProperties.ts(21,43): error TS2322: Type '{ foreword: string; price: number; }' is not assignable to type 'Book & number'. @@ -22,7 +22,7 @@ tests/cases/compiler/objectLiteralExcessProperties.ts(25,27): error TS2322: Type tests/cases/compiler/objectLiteralExcessProperties.ts(33,27): error TS2322: Type '{ 0: { colour: string; }; }' is not assignable to type 'Indexed'. Property '0' is incompatible with index signature. Type '{ colour: string; }' is not assignable to type 'Cover'. - Object literal may only specify known properties, and 'colour' does not exist in type 'Cover'. + Object literal may only specify known properties, but 'colour' does not exist in type 'Cover'. Did you mean to write 'color'? ==== tests/cases/compiler/objectLiteralExcessProperties.ts (10 errors) ==== @@ -37,7 +37,7 @@ tests/cases/compiler/objectLiteralExcessProperties.ts(33,27): error TS2322: Type var b1: Book = { forword: "oops" }; ~~~~~~~~~~~~~~~ !!! error TS2322: Type '{ forword: string; }' is not assignable to type 'Book'. -!!! error TS2322: Object literal may only specify known properties, and 'forword' does not exist in type 'Book'. +!!! error TS2322: Object literal may only specify known properties, but 'forword' does not exist in type 'Book'. Did you mean to write 'foreword'? var b2: Book | string = { foreward: "nope" }; ~~~~~~~~~~~~~~~~ @@ -55,12 +55,12 @@ tests/cases/compiler/objectLiteralExcessProperties.ts(33,27): error TS2322: Type var b4: Book & Cover = { foreword: "hi", colour: "blue" }; ~~~~~~~~~~~~~~ !!! error TS2322: Type '{ foreword: string; colour: string; }' is not assignable to type 'Book & Cover'. -!!! error TS2322: Object literal may only specify known properties, and 'colour' does not exist in type 'Book & Cover'. +!!! error TS2322: Object literal may only specify known properties, but 'colour' does not exist in type 'Book & Cover'. Did you mean to write 'color'? var b5: Book & Cover = { foreward: "hi", color: "blue" }; ~~~~~~~~~~~~~~ !!! error TS2322: Type '{ foreward: string; color: string; }' is not assignable to type 'Book & Cover'. -!!! error TS2322: Object literal may only specify known properties, and 'foreward' does not exist in type 'Book & Cover'. +!!! error TS2322: Object literal may only specify known properties, but 'foreward' does not exist in type 'Book & Cover'. Did you mean to write 'foreword'? var b6: Book & Cover = { foreword: "hi", color: "blue", price: 10.99 }; ~~~~~~~~~~~~ @@ -93,5 +93,5 @@ tests/cases/compiler/objectLiteralExcessProperties.ts(33,27): error TS2322: Type !!! error TS2322: Type '{ 0: { colour: string; }; }' is not assignable to type 'Indexed'. !!! error TS2322: Property '0' is incompatible with index signature. !!! error TS2322: Type '{ colour: string; }' is not assignable to type 'Cover'. -!!! error TS2322: Object literal may only specify known properties, and 'colour' does not exist in type 'Cover'. +!!! error TS2322: Object literal may only specify known properties, but 'colour' does not exist in type 'Cover'. Did you mean to write 'color'? \ No newline at end of file diff --git a/tests/baselines/reference/spellingSuggestionLeadingUnderscores01.errors.txt b/tests/baselines/reference/spellingSuggestionLeadingUnderscores01.errors.txt index a265dfc1fb6..af0a647f87e 100644 --- a/tests/baselines/reference/spellingSuggestionLeadingUnderscores01.errors.txt +++ b/tests/baselines/reference/spellingSuggestionLeadingUnderscores01.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/spellingSuggestionLeadingUnderscores01.ts(6,3): error TS2551: Property '___foo' does not exist on type '{ __foo: 10; }'. Did you mean '___foo'? +tests/cases/compiler/spellingSuggestionLeadingUnderscores01.ts(6,3): error TS2551: Property '___foo' does not exist on type '{ __foo: 10; }'. Did you mean '__foo'? ==== tests/cases/compiler/spellingSuggestionLeadingUnderscores01.ts (1 errors) ==== @@ -9,7 +9,7 @@ tests/cases/compiler/spellingSuggestionLeadingUnderscores01.ts(6,3): error TS255 a.___foo ~~~~~~ -!!! error TS2551: Property '___foo' does not exist on type '{ __foo: 10; }'. Did you mean '___foo'? +!!! error TS2551: Property '___foo' does not exist on type '{ __foo: 10; }'. Did you mean '__foo'? // @filename def.ts export let b: { From 8e5e6c626b24253a55e048c698c9283b25dce5b2 Mon Sep 17 00:00:00 2001 From: Mohamed Hegazy Date: Fri, 18 Aug 2017 13:00:29 -0700 Subject: [PATCH 080/370] Update .npmignore (#17905) --- .npmignore | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.npmignore b/.npmignore index d3c27afeff4..50ae145423a 100644 --- a/.npmignore +++ b/.npmignore @@ -16,4 +16,5 @@ Jakefile.js .gitattributes .settings/ .travis.yml -.vscode/ \ No newline at end of file +.vscode/ +test.config \ No newline at end of file From a14aaf47721bd1728897c1b527a1326a3ca7fbb0 Mon Sep 17 00:00:00 2001 From: Mohamed Hegazy Date: Fri, 18 Aug 2017 15:58:21 -0700 Subject: [PATCH 081/370] Add release-2.5 to covered branches --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 4a99aaf2237..27b14739d8b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -16,6 +16,7 @@ matrix: branches: only: - master + - release-2.5 install: - npm uninstall typescript --no-save From 7cc6bfc98572c2812088dddffaede3df3d36a904 Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Fri, 18 Aug 2017 15:58:31 -0700 Subject: [PATCH 082/370] Only give suggestions when the name is an identifier. --- 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 d2b51867217..d128eb29d95 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -9074,9 +9074,9 @@ namespace ts { errorNode = propDeclaration; - const propNameNode = propDeclaration.name as Identifier; - Debug.assertNode(propNameNode, isIdentifier); - suggestion = getSuggestionForNonexistentProperty(propNameNode, target); + if (isIdentifier(propDeclaration.name)) { + suggestion = getSuggestionForNonexistentProperty(propDeclaration.name, target); + } } if (suggestion !== undefined) { From e6c1afb4a0b8f04f6202a7dd1f39d7cdffeaf096 Mon Sep 17 00:00:00 2001 From: uniqueiniquity Date: Fri, 18 Aug 2017 15:59:22 -0700 Subject: [PATCH 083/370] Style changes and cleanup --- src/services/outliningElementsCollector.ts | 29 +++++++++++----------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/src/services/outliningElementsCollector.ts b/src/services/outliningElementsCollector.ts index cdeba21b32b..e0d99d1d271 100644 --- a/src/services/outliningElementsCollector.ts +++ b/src/services/outliningElementsCollector.ts @@ -1,20 +1,21 @@ /* @internal */ namespace ts.OutliningElementsCollector { + const collapseText = "..."; + const maxDepth = 20; + export function collectElements(sourceFile: SourceFile, cancellationToken: CancellationToken): OutliningSpan[] { const elements: OutliningSpan[] = []; - const collapseText = "..."; let depth = 0; - const maxDepth = 20; walk(sourceFile); return elements; - // If useFullStart is true, then the collapsing span includes leading whitespace, including linebreaks. + /** If useFullStart is true, then the collapsing span includes leading whitespace, including linebreaks. */ function addOutliningSpan(hintSpanNode: Node, startElement: Node, endElement: Node, autoCollapse: boolean, useFullStart: boolean) { if (hintSpanNode && startElement && endElement) { const span: OutliningSpan = { - textSpan: createTextSpanFromBounds(useFullStart ? startElement.pos : startElement.getStart(), endElement.end), - hintSpan: createTextSpanFromBounds(startElement.getStart(), endElement.end), + textSpan: createTextSpanFromBounds(useFullStart ? startElement.getFullStart() : startElement.getStart(), endElement.getEnd()), + hintSpan: createTextSpanFromNode(hintSpanNode, sourceFile), bannerText: collapseText, autoCollapse, }; @@ -117,7 +118,7 @@ namespace ts.OutliningElementsCollector { parent.kind === SyntaxKind.WithStatement || parent.kind === SyntaxKind.CatchClause) { - addOutliningSpan(parent, openBrace, closeBrace, autoCollapse(n), /* fullStart */ true); + addOutliningSpan(parent, openBrace, closeBrace, autoCollapse(n), /*useFullStart*/ true); break; } @@ -125,13 +126,13 @@ namespace ts.OutliningElementsCollector { // Could be the try-block, or the finally-block. const tryStatement = parent; if (tryStatement.tryBlock === n) { - addOutliningSpan(parent, openBrace, closeBrace, autoCollapse(n), /* fullStart */ true); + addOutliningSpan(parent, openBrace, closeBrace, autoCollapse(n), /*useFullStart*/ true); break; } else if (tryStatement.finallyBlock === n) { const finallyKeyword = findChildOfKind(tryStatement, SyntaxKind.FinallyKeyword, sourceFile); if (finallyKeyword) { - addOutliningSpan(finallyKeyword, openBrace, closeBrace, autoCollapse(n), /* fullStart */ true); + addOutliningSpan(finallyKeyword, openBrace, closeBrace, autoCollapse(n), /*useFullStart*/ true); break; } } @@ -155,7 +156,7 @@ namespace ts.OutliningElementsCollector { case SyntaxKind.ModuleBlock: { const openBrace = findChildOfKind(n, SyntaxKind.OpenBraceToken, sourceFile); const closeBrace = findChildOfKind(n, SyntaxKind.CloseBraceToken, sourceFile); - addOutliningSpan(n.parent, openBrace, closeBrace, autoCollapse(n), /* fullStart */ true); + addOutliningSpan(n.parent, openBrace, closeBrace, autoCollapse(n), /*useFullStart*/ true); break; } case SyntaxKind.ClassDeclaration: @@ -164,21 +165,21 @@ namespace ts.OutliningElementsCollector { case SyntaxKind.CaseBlock: { const openBrace = findChildOfKind(n, SyntaxKind.OpenBraceToken, sourceFile); const closeBrace = findChildOfKind(n, SyntaxKind.CloseBraceToken, sourceFile); - addOutliningSpan(n, openBrace, closeBrace, autoCollapse(n), /* fullStart */ true); + addOutliningSpan(n, openBrace, closeBrace, autoCollapse(n), /*useFullStart*/ true); break; } - // If the block has no leading keywords and is a member of an array literal, - // we again want to only collapse the span of the block. + // If the block has no leading keywords and is inside an array literal, + // we only want to collapse the span of the block. // Otherwise, the collapsed section will include the end of the previous line. case SyntaxKind.ObjectLiteralExpression: const openBrace = findChildOfKind(n, SyntaxKind.OpenBraceToken, sourceFile); const closeBrace = findChildOfKind(n, SyntaxKind.CloseBraceToken, sourceFile); - addOutliningSpan(n, openBrace, closeBrace, autoCollapse(n), /* fullStart */ n.parent.kind !== SyntaxKind.ArrayLiteralExpression); + addOutliningSpan(n, openBrace, closeBrace, autoCollapse(n), /*useFullStart*/ !isArrayLiteralExpression(n.parent)); break; case SyntaxKind.ArrayLiteralExpression: const openBracket = findChildOfKind(n, SyntaxKind.OpenBracketToken, sourceFile); const closeBracket = findChildOfKind(n, SyntaxKind.CloseBracketToken, sourceFile); - addOutliningSpan(n, openBracket, closeBracket, autoCollapse(n), /* fullStart */ n.parent.kind !== SyntaxKind.ArrayLiteralExpression); + addOutliningSpan(n, openBracket, closeBracket, autoCollapse(n), /*useFullStart*/ !isArrayLiteralExpression(n.parent)); break; } depth++; From a136f554a708f8caf2fe4b9060207e7d9869a7d2 Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Fri, 18 Aug 2017 17:20:57 -0700 Subject: [PATCH 084/370] Fix stack overflow when resolving default construct signatures (#17878) * Fix stack overflow when resolving default construct signatures * No need for || emptyArray --- src/compiler/checker.ts | 16 ++++--- .../reference/cloduleGenericOnSelfMember.js | 42 +++++++++++++++++++ .../cloduleGenericOnSelfMember.symbols | 30 +++++++++++++ .../cloduleGenericOnSelfMember.types | 33 +++++++++++++++ .../compiler/cloduleGenericOnSelfMember.ts | 11 +++++ 5 files changed, 126 insertions(+), 6 deletions(-) create mode 100644 tests/baselines/reference/cloduleGenericOnSelfMember.js create mode 100644 tests/baselines/reference/cloduleGenericOnSelfMember.symbols create mode 100644 tests/baselines/reference/cloduleGenericOnSelfMember.types create mode 100644 tests/cases/compiler/cloduleGenericOnSelfMember.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 6df6b1f9ce1..6febaf0052d 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -5657,17 +5657,12 @@ namespace ts { else { // Combinations of function, class, enum and module let members = emptySymbols; - let constructSignatures: Signature[] = emptyArray; let stringIndexInfo: IndexInfo = undefined; if (symbol.exports) { members = getExportsOfSymbol(symbol); } if (symbol.flags & SymbolFlags.Class) { const classType = getDeclaredTypeOfClassOrInterface(symbol); - constructSignatures = getSignaturesOfSymbol(symbol.members.get(InternalSymbolName.Constructor)); - if (!constructSignatures.length) { - constructSignatures = getDefaultConstructSignatures(classType); - } const baseConstructorType = getBaseConstructorTypeOfClass(classType); if (baseConstructorType.flags & (TypeFlags.Object | TypeFlags.Intersection | TypeFlags.TypeVariable)) { members = createSymbolTable(getNamedMembers(members)); @@ -5678,7 +5673,7 @@ namespace ts { } } const numberIndexInfo = symbol.flags & SymbolFlags.Enum ? enumNumberIndexInfo : undefined; - setStructuredTypeMembers(type, members, emptyArray, constructSignatures, stringIndexInfo, numberIndexInfo); + setStructuredTypeMembers(type, members, emptyArray, emptyArray, stringIndexInfo, numberIndexInfo); // We resolve the members before computing the signatures because a signature may use // typeof with a qualified name expression that circularly references the type we are // in the process of resolving (see issue #6072). The temporarily empty signature list @@ -5686,6 +5681,15 @@ namespace ts { if (symbol.flags & (SymbolFlags.Function | SymbolFlags.Method)) { (type).callSignatures = getSignaturesOfSymbol(symbol); } + // And likewise for construct signatures for classes + if (symbol.flags & SymbolFlags.Class) { + const classType = getDeclaredTypeOfClassOrInterface(symbol); + let constructSignatures = getSignaturesOfSymbol(symbol.members.get(InternalSymbolName.Constructor)); + if (!constructSignatures.length) { + constructSignatures = getDefaultConstructSignatures(classType); + } + (type).constructSignatures = constructSignatures; + } } } diff --git a/tests/baselines/reference/cloduleGenericOnSelfMember.js b/tests/baselines/reference/cloduleGenericOnSelfMember.js new file mode 100644 index 00000000000..972651f1045 --- /dev/null +++ b/tests/baselines/reference/cloduleGenericOnSelfMember.js @@ -0,0 +1,42 @@ +//// [cloduleGenericOnSelfMember.ts] +class ServiceBase { + field: T; +} +class Service extends ServiceBase { +} +namespace Service { + export const Base = { + name: "1", + value: 5 + }; +} + +//// [cloduleGenericOnSelfMember.js] +var __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +var ServiceBase = /** @class */ (function () { + function ServiceBase() { + } + return ServiceBase; +}()); +var Service = /** @class */ (function (_super) { + __extends(Service, _super); + function Service() { + return _super !== null && _super.apply(this, arguments) || this; + } + return Service; +}(ServiceBase)); +(function (Service) { + Service.Base = { + name: "1", + value: 5 + }; +})(Service || (Service = {})); diff --git a/tests/baselines/reference/cloduleGenericOnSelfMember.symbols b/tests/baselines/reference/cloduleGenericOnSelfMember.symbols new file mode 100644 index 00000000000..c7e0126fa7a --- /dev/null +++ b/tests/baselines/reference/cloduleGenericOnSelfMember.symbols @@ -0,0 +1,30 @@ +=== tests/cases/compiler/cloduleGenericOnSelfMember.ts === +class ServiceBase { +>ServiceBase : Symbol(ServiceBase, Decl(cloduleGenericOnSelfMember.ts, 0, 0)) +>T : Symbol(T, Decl(cloduleGenericOnSelfMember.ts, 0, 18)) + + field: T; +>field : Symbol(ServiceBase.field, Decl(cloduleGenericOnSelfMember.ts, 0, 22)) +>T : Symbol(T, Decl(cloduleGenericOnSelfMember.ts, 0, 18)) +} +class Service extends ServiceBase { +>Service : Symbol(Service, Decl(cloduleGenericOnSelfMember.ts, 2, 1), Decl(cloduleGenericOnSelfMember.ts, 4, 1)) +>ServiceBase : Symbol(ServiceBase, Decl(cloduleGenericOnSelfMember.ts, 0, 0)) +>Service.Base : Symbol(Service.Base, Decl(cloduleGenericOnSelfMember.ts, 6, 16)) +>Service : Symbol(Service, Decl(cloduleGenericOnSelfMember.ts, 2, 1), Decl(cloduleGenericOnSelfMember.ts, 4, 1)) +>Base : Symbol(Service.Base, Decl(cloduleGenericOnSelfMember.ts, 6, 16)) +} +namespace Service { +>Service : Symbol(Service, Decl(cloduleGenericOnSelfMember.ts, 2, 1), Decl(cloduleGenericOnSelfMember.ts, 4, 1)) + + export const Base = { +>Base : Symbol(Base, Decl(cloduleGenericOnSelfMember.ts, 6, 16)) + + name: "1", +>name : Symbol(name, Decl(cloduleGenericOnSelfMember.ts, 6, 25)) + + value: 5 +>value : Symbol(value, Decl(cloduleGenericOnSelfMember.ts, 7, 18)) + + }; +} diff --git a/tests/baselines/reference/cloduleGenericOnSelfMember.types b/tests/baselines/reference/cloduleGenericOnSelfMember.types new file mode 100644 index 00000000000..87590745c6f --- /dev/null +++ b/tests/baselines/reference/cloduleGenericOnSelfMember.types @@ -0,0 +1,33 @@ +=== tests/cases/compiler/cloduleGenericOnSelfMember.ts === +class ServiceBase { +>ServiceBase : ServiceBase +>T : T + + field: T; +>field : T +>T : T +} +class Service extends ServiceBase { +>Service : Service +>ServiceBase : ServiceBase<{ name: string; value: number; }> +>Service.Base : { name: string; value: number; } +>Service : typeof Service +>Base : { name: string; value: number; } +} +namespace Service { +>Service : typeof Service + + export const Base = { +>Base : { name: string; value: number; } +>{ name: "1", value: 5 } : { name: string; value: number; } + + name: "1", +>name : string +>"1" : "1" + + value: 5 +>value : number +>5 : 5 + + }; +} diff --git a/tests/cases/compiler/cloduleGenericOnSelfMember.ts b/tests/cases/compiler/cloduleGenericOnSelfMember.ts new file mode 100644 index 00000000000..23f0e6af1b6 --- /dev/null +++ b/tests/cases/compiler/cloduleGenericOnSelfMember.ts @@ -0,0 +1,11 @@ +class ServiceBase { + field: T; +} +class Service extends ServiceBase { +} +namespace Service { + export const Base = { + name: "1", + value: 5 + }; +} \ No newline at end of file From 5e8e735db55e82ff0cf4bddaf4f0fe6d8a4d39f7 Mon Sep 17 00:00:00 2001 From: Andy Date: Fri, 18 Aug 2017 17:21:25 -0700 Subject: [PATCH 085/370] quickInfo: Don't check for `type === undefined`, check for `any` (#17815) * quickInfo: Don't check for `type === undefined`, check for `any` * Fixes: * We still want to do some work even if type is `any` * Second test for `if (type)` is necessary because it might not have been assigned. --- src/services/symbolDisplay.ts | 215 ++++++++++---------- tests/cases/fourslash/quickInfoTypeError.ts | 10 + 2 files changed, 118 insertions(+), 107 deletions(-) create mode 100644 tests/cases/fourslash/quickInfoTypeError.ts diff --git a/src/services/symbolDisplay.ts b/src/services/symbolDisplay.ts index 303bb8395ee..05c451cc3f3 100644 --- a/src/services/symbolDisplay.ts +++ b/src/services/symbolDisplay.ts @@ -111,124 +111,123 @@ namespace ts.SymbolDisplay { let signature: Signature; type = isThisExpression ? typeChecker.getTypeAtLocation(location) : typeChecker.getTypeOfSymbolAtLocation(symbol.exportSymbol || symbol, location); - if (type) { - if (location.parent && location.parent.kind === SyntaxKind.PropertyAccessExpression) { - const right = (location.parent).name; - // Either the location is on the right of a property access, or on the left and the right is missing - if (right === location || (right && right.getFullWidth() === 0)) { - location = location.parent; + + if (location.parent && location.parent.kind === SyntaxKind.PropertyAccessExpression) { + const right = (location.parent).name; + // Either the location is on the right of a property access, or on the left and the right is missing + if (right === location || (right && right.getFullWidth() === 0)) { + location = location.parent; + } + } + + // try get the call/construct signature from the type if it matches + let callExpressionLike: CallExpression | NewExpression | JsxOpeningLikeElement; + if (isCallOrNewExpression(location)) { + callExpressionLike = location; + } + else if (isCallExpressionTarget(location) || isNewExpressionTarget(location)) { + callExpressionLike = location.parent; + } + else if (location.parent && isJsxOpeningLikeElement(location.parent) && isFunctionLike(symbol.valueDeclaration)) { + callExpressionLike = location.parent; + } + + if (callExpressionLike) { + const candidateSignatures: Signature[] = []; + signature = typeChecker.getResolvedSignature(callExpressionLike, candidateSignatures); + if (!signature && candidateSignatures.length) { + // Use the first candidate: + signature = candidateSignatures[0]; + } + + const useConstructSignatures = callExpressionLike.kind === SyntaxKind.NewExpression || (isCallExpression(callExpressionLike) && callExpressionLike.expression.kind === SyntaxKind.SuperKeyword); + + const allSignatures = useConstructSignatures ? type.getConstructSignatures() : type.getCallSignatures(); + + if (!contains(allSignatures, signature.target) && !contains(allSignatures, signature)) { + // Get the first signature if there is one -- allSignatures may contain + // either the original signature or its target, so check for either + signature = allSignatures.length ? allSignatures[0] : undefined; + } + + if (signature) { + if (useConstructSignatures && (symbolFlags & SymbolFlags.Class)) { + // Constructor + symbolKind = ScriptElementKind.constructorImplementationElement; + addPrefixForAnyFunctionOrVar(type.symbol, symbolKind); } - } - - // try get the call/construct signature from the type if it matches - let callExpressionLike: CallExpression | NewExpression | JsxOpeningLikeElement; - if (isCallOrNewExpression(location)) { - callExpressionLike = location; - } - else if (isCallExpressionTarget(location) || isNewExpressionTarget(location)) { - callExpressionLike = location.parent; - } - else if (location.parent && isJsxOpeningLikeElement(location.parent) && isFunctionLike(symbol.valueDeclaration)) { - callExpressionLike = location.parent; - } - - if (callExpressionLike) { - const candidateSignatures: Signature[] = []; - signature = typeChecker.getResolvedSignature(callExpressionLike, candidateSignatures); - if (!signature && candidateSignatures.length) { - // Use the first candidate: - signature = candidateSignatures[0]; - } - - const useConstructSignatures = callExpressionLike.kind === SyntaxKind.NewExpression || (isCallExpression(callExpressionLike) && callExpressionLike.expression.kind === SyntaxKind.SuperKeyword); - - const allSignatures = useConstructSignatures ? type.getConstructSignatures() : type.getCallSignatures(); - - if (!contains(allSignatures, signature.target) && !contains(allSignatures, signature)) { - // Get the first signature if there is one -- allSignatures may contain - // either the original signature or its target, so check for either - signature = allSignatures.length ? allSignatures[0] : undefined; - } - - if (signature) { - if (useConstructSignatures && (symbolFlags & SymbolFlags.Class)) { - // Constructor - symbolKind = ScriptElementKind.constructorImplementationElement; - addPrefixForAnyFunctionOrVar(type.symbol, symbolKind); + else if (symbolFlags & SymbolFlags.Alias) { + symbolKind = ScriptElementKind.alias; + pushTypePart(symbolKind); + displayParts.push(spacePart()); + if (useConstructSignatures) { + displayParts.push(keywordPart(SyntaxKind.NewKeyword)); + displayParts.push(spacePart()); } - else if (symbolFlags & SymbolFlags.Alias) { - symbolKind = ScriptElementKind.alias; - pushTypePart(symbolKind); + addFullSymbolName(symbol); + } + else { + addPrefixForAnyFunctionOrVar(symbol, symbolKind); + } + + switch (symbolKind) { + case ScriptElementKind.jsxAttribute: + case ScriptElementKind.memberVariableElement: + case ScriptElementKind.variableElement: + case ScriptElementKind.constElement: + case ScriptElementKind.letElement: + case ScriptElementKind.parameterElement: + case ScriptElementKind.localVariableElement: + // If it is call or construct signature of lambda's write type name + displayParts.push(punctuationPart(SyntaxKind.ColonToken)); displayParts.push(spacePart()); if (useConstructSignatures) { displayParts.push(keywordPart(SyntaxKind.NewKeyword)); displayParts.push(spacePart()); } - addFullSymbolName(symbol); - } - else { - addPrefixForAnyFunctionOrVar(symbol, symbolKind); - } + if (!(type.flags & TypeFlags.Object && (type).objectFlags & ObjectFlags.Anonymous) && type.symbol) { + addRange(displayParts, symbolToDisplayParts(typeChecker, type.symbol, enclosingDeclaration, /*meaning*/ undefined, SymbolFormatFlags.WriteTypeParametersOrArguments)); + } + addSignatureDisplayParts(signature, allSignatures, TypeFormatFlags.WriteArrowStyleSignature); + break; - switch (symbolKind) { - case ScriptElementKind.jsxAttribute: - case ScriptElementKind.memberVariableElement: - case ScriptElementKind.variableElement: - case ScriptElementKind.constElement: - case ScriptElementKind.letElement: - case ScriptElementKind.parameterElement: - case ScriptElementKind.localVariableElement: - // If it is call or construct signature of lambda's write type name - displayParts.push(punctuationPart(SyntaxKind.ColonToken)); - displayParts.push(spacePart()); - if (useConstructSignatures) { - displayParts.push(keywordPart(SyntaxKind.NewKeyword)); - displayParts.push(spacePart()); - } - if (!(type.flags & TypeFlags.Object && (type).objectFlags & ObjectFlags.Anonymous) && type.symbol) { - addRange(displayParts, symbolToDisplayParts(typeChecker, type.symbol, enclosingDeclaration, /*meaning*/ undefined, SymbolFormatFlags.WriteTypeParametersOrArguments)); - } - addSignatureDisplayParts(signature, allSignatures, TypeFormatFlags.WriteArrowStyleSignature); - break; - - default: - // Just signature - addSignatureDisplayParts(signature, allSignatures); - } - hasAddedSymbolInfo = true; + default: + // Just signature + addSignatureDisplayParts(signature, allSignatures); } + hasAddedSymbolInfo = true; } - else if ((isNameOfFunctionDeclaration(location) && !(symbolFlags & SymbolFlags.Accessor)) || // name of function declaration - (location.kind === SyntaxKind.ConstructorKeyword && location.parent.kind === SyntaxKind.Constructor)) { // At constructor keyword of constructor declaration - // get the signature from the declaration and write it - const functionDeclaration = location.parent; - // Use function declaration to write the signatures only if the symbol corresponding to this declaration - const locationIsSymbolDeclaration = find(symbol.declarations, declaration => - declaration === (location.kind === SyntaxKind.ConstructorKeyword ? functionDeclaration.parent : functionDeclaration)); + } + else if ((isNameOfFunctionDeclaration(location) && !(symbolFlags & SymbolFlags.Accessor)) || // name of function declaration + (location.kind === SyntaxKind.ConstructorKeyword && location.parent.kind === SyntaxKind.Constructor)) { // At constructor keyword of constructor declaration + // get the signature from the declaration and write it + const functionDeclaration = location.parent; + // Use function declaration to write the signatures only if the symbol corresponding to this declaration + const locationIsSymbolDeclaration = find(symbol.declarations, declaration => + declaration === (location.kind === SyntaxKind.ConstructorKeyword ? functionDeclaration.parent : functionDeclaration)); - if (locationIsSymbolDeclaration) { - const allSignatures = functionDeclaration.kind === SyntaxKind.Constructor ? type.getNonNullableType().getConstructSignatures() : type.getNonNullableType().getCallSignatures(); - if (!typeChecker.isImplementationOfOverload(functionDeclaration)) { - signature = typeChecker.getSignatureFromDeclaration(functionDeclaration); - } - else { - signature = allSignatures[0]; - } - - if (functionDeclaration.kind === SyntaxKind.Constructor) { - // show (constructor) Type(...) signature - symbolKind = ScriptElementKind.constructorImplementationElement; - addPrefixForAnyFunctionOrVar(type.symbol, symbolKind); - } - else { - // (function/method) symbol(..signature) - addPrefixForAnyFunctionOrVar(functionDeclaration.kind === SyntaxKind.CallSignature && - !(type.symbol.flags & SymbolFlags.TypeLiteral || type.symbol.flags & SymbolFlags.ObjectLiteral) ? type.symbol : symbol, symbolKind); - } - - addSignatureDisplayParts(signature, allSignatures); - hasAddedSymbolInfo = true; + if (locationIsSymbolDeclaration) { + const allSignatures = functionDeclaration.kind === SyntaxKind.Constructor ? type.getNonNullableType().getConstructSignatures() : type.getNonNullableType().getCallSignatures(); + if (!typeChecker.isImplementationOfOverload(functionDeclaration)) { + signature = typeChecker.getSignatureFromDeclaration(functionDeclaration); } + else { + signature = allSignatures[0]; + } + + if (functionDeclaration.kind === SyntaxKind.Constructor) { + // show (constructor) Type(...) signature + symbolKind = ScriptElementKind.constructorImplementationElement; + addPrefixForAnyFunctionOrVar(type.symbol, symbolKind); + } + else { + // (function/method) symbol(..signature) + addPrefixForAnyFunctionOrVar(functionDeclaration.kind === SyntaxKind.CallSignature && + !(type.symbol.flags & SymbolFlags.TypeLiteral || type.symbol.flags & SymbolFlags.ObjectLiteral) ? type.symbol : symbol, symbolKind); + } + + addSignatureDisplayParts(signature, allSignatures); + hasAddedSymbolInfo = true; } } } @@ -417,7 +416,9 @@ namespace ts.SymbolDisplay { symbolFlags & SymbolFlags.Accessor || symbolKind === ScriptElementKind.memberFunctionElement) { const allSignatures = type.getNonNullableType().getCallSignatures(); - addSignatureDisplayParts(allSignatures[0], allSignatures); + if (allSignatures.length) { + addSignatureDisplayParts(allSignatures[0], allSignatures); + } } } } diff --git a/tests/cases/fourslash/quickInfoTypeError.ts b/tests/cases/fourslash/quickInfoTypeError.ts new file mode 100644 index 00000000000..7e0c9b20303 --- /dev/null +++ b/tests/cases/fourslash/quickInfoTypeError.ts @@ -0,0 +1,10 @@ +/// + +////foo({ +//// /**/f: function() {}, +//// f() {} +////}); + +// The symbol indicates that this is a funciton, but the type is `any`. +// Regression test that we don't crash (by trying to get signatures from `any`). +verify.quickInfoAt("", "(method) f"); From 7739a1cea01236ced5990d77bec2d6e4d40963e4 Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Sat, 19 Aug 2017 00:03:35 -0700 Subject: [PATCH 086/370] Actually misspell the property name. --- tests/cases/compiler/spellingSuggestionLeadingUnderscores01.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/cases/compiler/spellingSuggestionLeadingUnderscores01.ts b/tests/cases/compiler/spellingSuggestionLeadingUnderscores01.ts index 99c9644b095..cf60136f5eb 100644 --- a/tests/cases/compiler/spellingSuggestionLeadingUnderscores01.ts +++ b/tests/cases/compiler/spellingSuggestionLeadingUnderscores01.ts @@ -12,6 +12,6 @@ export let b: { } b = { - __foo: 100, + ___foo: 100, } From a1ad389d247d0e5960fd5616867b7d03fb6d0564 Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Sat, 19 Aug 2017 00:08:25 -0700 Subject: [PATCH 087/370] Accepted baselines. --- .../spellingSuggestionLeadingUnderscores01.errors.txt | 9 +++++++-- .../reference/spellingSuggestionLeadingUnderscores01.js | 4 ++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/tests/baselines/reference/spellingSuggestionLeadingUnderscores01.errors.txt b/tests/baselines/reference/spellingSuggestionLeadingUnderscores01.errors.txt index af0a647f87e..39a4901da98 100644 --- a/tests/baselines/reference/spellingSuggestionLeadingUnderscores01.errors.txt +++ b/tests/baselines/reference/spellingSuggestionLeadingUnderscores01.errors.txt @@ -1,7 +1,9 @@ tests/cases/compiler/spellingSuggestionLeadingUnderscores01.ts(6,3): error TS2551: Property '___foo' does not exist on type '{ __foo: 10; }'. Did you mean '__foo'? +tests/cases/compiler/spellingSuggestionLeadingUnderscores01.ts(14,5): error TS2322: Type '{ ___foo: number; }' is not assignable to type '{ __foo: number; }'. + Object literal may only specify known properties, but '___foo' does not exist in type '{ __foo: number; }'. Did you mean to write '__foo'? -==== tests/cases/compiler/spellingSuggestionLeadingUnderscores01.ts (1 errors) ==== +==== tests/cases/compiler/spellingSuggestionLeadingUnderscores01.ts (2 errors) ==== // @filename abc.ts export declare let a: { __foo: 10, @@ -17,7 +19,10 @@ tests/cases/compiler/spellingSuggestionLeadingUnderscores01.ts(6,3): error TS255 } b = { - __foo: 100, + ___foo: 100, + ~~~~~~~~~~~ +!!! error TS2322: Type '{ ___foo: number; }' is not assignable to type '{ __foo: number; }'. +!!! error TS2322: Object literal may only specify known properties, but '___foo' does not exist in type '{ __foo: number; }'. Did you mean to write '__foo'? } \ No newline at end of file diff --git a/tests/baselines/reference/spellingSuggestionLeadingUnderscores01.js b/tests/baselines/reference/spellingSuggestionLeadingUnderscores01.js index fbcc3dc1cad..6a84749b153 100644 --- a/tests/baselines/reference/spellingSuggestionLeadingUnderscores01.js +++ b/tests/baselines/reference/spellingSuggestionLeadingUnderscores01.js @@ -12,7 +12,7 @@ export let b: { } b = { - __foo: 100, + ___foo: 100, } @@ -22,5 +22,5 @@ b = { exports.__esModule = true; exports.a.___foo; exports.b = { - __foo: 100 + ___foo: 100 }; From 35addce79ede5c2f439623401a0fcc2d58943215 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Sat, 19 Aug 2017 09:46:02 +0200 Subject: [PATCH 088/370] Add comment --- src/compiler/checker.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index d5518eee3da..3c1ed9a9492 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -1017,6 +1017,7 @@ namespace ts { } break; case SyntaxKind.ExpressionWithTypeArguments: + // The type parameters of a class are not in scope in the base class expression. if (lastLocation === (location).expression && (location.parent).token === SyntaxKind.ExtendsKeyword) { const container = location.parent.parent; if (isClassLike(container) && (result = lookup(getSymbolOfNode(container).members, name, meaning & SymbolFlags.Type))) { From 049b33693633b5dc5970db230b28fff492efcce0 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Sat, 19 Aug 2017 09:46:09 +0200 Subject: [PATCH 089/370] Accept new baselines --- .../reference/inheritFromGenericTypeParameter.errors.txt | 4 ++-- .../reference/typeParameterAsBaseClass.errors.txt | 4 ++-- .../reference/typeParameterAsBaseType.errors.txt | 8 ++++---- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/tests/baselines/reference/inheritFromGenericTypeParameter.errors.txt b/tests/baselines/reference/inheritFromGenericTypeParameter.errors.txt index 08d138f2e5d..c043e37575c 100644 --- a/tests/baselines/reference/inheritFromGenericTypeParameter.errors.txt +++ b/tests/baselines/reference/inheritFromGenericTypeParameter.errors.txt @@ -1,11 +1,11 @@ -tests/cases/compiler/inheritFromGenericTypeParameter.ts(1,20): error TS2693: 'T' only refers to a type, but is being used as a value here. +tests/cases/compiler/inheritFromGenericTypeParameter.ts(1,20): error TS2304: Cannot find name 'T'. tests/cases/compiler/inheritFromGenericTypeParameter.ts(2,24): error TS2312: An interface may only extend a class or another interface. ==== tests/cases/compiler/inheritFromGenericTypeParameter.ts (2 errors) ==== class C extends T { } ~ -!!! error TS2693: 'T' only refers to a type, but is being used as a value here. +!!! error TS2304: Cannot find name 'T'. interface I extends T { } ~ !!! error TS2312: An interface may only extend a class or another interface. \ No newline at end of file diff --git a/tests/baselines/reference/typeParameterAsBaseClass.errors.txt b/tests/baselines/reference/typeParameterAsBaseClass.errors.txt index e633a6dd396..dec7f7f2a4a 100644 --- a/tests/baselines/reference/typeParameterAsBaseClass.errors.txt +++ b/tests/baselines/reference/typeParameterAsBaseClass.errors.txt @@ -1,11 +1,11 @@ -tests/cases/compiler/typeParameterAsBaseClass.ts(1,20): error TS2693: 'T' only refers to a type, but is being used as a value here. +tests/cases/compiler/typeParameterAsBaseClass.ts(1,20): error TS2304: Cannot find name 'T'. tests/cases/compiler/typeParameterAsBaseClass.ts(2,24): error TS2422: A class may only implement another class or interface. ==== tests/cases/compiler/typeParameterAsBaseClass.ts (2 errors) ==== class C extends T {} ~ -!!! error TS2693: 'T' only refers to a type, but is being used as a value here. +!!! error TS2304: Cannot find name 'T'. class C2 implements T {} ~ !!! error TS2422: A class may only implement another class or interface. \ No newline at end of file diff --git a/tests/baselines/reference/typeParameterAsBaseType.errors.txt b/tests/baselines/reference/typeParameterAsBaseType.errors.txt index c16b16d0b1a..835b2369948 100644 --- a/tests/baselines/reference/typeParameterAsBaseType.errors.txt +++ b/tests/baselines/reference/typeParameterAsBaseType.errors.txt @@ -1,5 +1,5 @@ -tests/cases/conformance/types/typeParameters/typeParameterAsBaseType.ts(4,20): error TS2693: 'T' only refers to a type, but is being used as a value here. -tests/cases/conformance/types/typeParameters/typeParameterAsBaseType.ts(5,24): error TS2693: 'U' only refers to a type, but is being used as a value here. +tests/cases/conformance/types/typeParameters/typeParameterAsBaseType.ts(4,20): error TS2304: Cannot find name 'T'. +tests/cases/conformance/types/typeParameters/typeParameterAsBaseType.ts(5,24): error TS2304: Cannot find name 'U'. tests/cases/conformance/types/typeParameters/typeParameterAsBaseType.ts(7,24): error TS2312: An interface may only extend a class or another interface. tests/cases/conformance/types/typeParameters/typeParameterAsBaseType.ts(8,28): error TS2312: An interface may only extend a class or another interface. @@ -10,10 +10,10 @@ tests/cases/conformance/types/typeParameters/typeParameterAsBaseType.ts(8,28): e class C extends T { } ~ -!!! error TS2693: 'T' only refers to a type, but is being used as a value here. +!!! error TS2304: Cannot find name 'T'. class C2 extends U { } ~ -!!! error TS2693: 'U' only refers to a type, but is being used as a value here. +!!! error TS2304: Cannot find name 'U'. interface I extends T { } ~ From 914d428ff12a7c7c8a7c2fc778a83810b852bd5f Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Sat, 19 Aug 2017 09:53:46 +0200 Subject: [PATCH 090/370] Add regression test --- .../baseExpressionTypeParameters.errors.txt | 19 +++++++ .../reference/baseExpressionTypeParameters.js | 50 +++++++++++++++++++ .../compiler/baseExpressionTypeParameters.ts | 13 +++++ 3 files changed, 82 insertions(+) create mode 100644 tests/baselines/reference/baseExpressionTypeParameters.errors.txt create mode 100644 tests/baselines/reference/baseExpressionTypeParameters.js create mode 100644 tests/cases/compiler/baseExpressionTypeParameters.ts diff --git a/tests/baselines/reference/baseExpressionTypeParameters.errors.txt b/tests/baselines/reference/baseExpressionTypeParameters.errors.txt new file mode 100644 index 00000000000..4fa8f2f6d3d --- /dev/null +++ b/tests/baselines/reference/baseExpressionTypeParameters.errors.txt @@ -0,0 +1,19 @@ +tests/cases/compiler/baseExpressionTypeParameters.ts(10,27): error TS2561: Base class expressions cannot reference class type parameters. + + +==== tests/cases/compiler/baseExpressionTypeParameters.ts (1 errors) ==== + // Repro from #17829 + + function base() { + class Base { + static prop: T; + } + return Base; + } + + class Gen extends base() {} // Error, T not in scope + ~ +!!! error TS2561: Base class expressions cannot reference class type parameters. + class Spec extends Gen {} + + Spec.prop; \ No newline at end of file diff --git a/tests/baselines/reference/baseExpressionTypeParameters.js b/tests/baselines/reference/baseExpressionTypeParameters.js new file mode 100644 index 00000000000..a3a77cbc6e3 --- /dev/null +++ b/tests/baselines/reference/baseExpressionTypeParameters.js @@ -0,0 +1,50 @@ +//// [baseExpressionTypeParameters.ts] +// Repro from #17829 + +function base() { + class Base { + static prop: T; + } + return Base; +} + +class Gen extends base() {} // Error, T not in scope +class Spec extends Gen {} + +Spec.prop; + +//// [baseExpressionTypeParameters.js] +// Repro from #17829 +var __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +function base() { + var Base = /** @class */ (function () { + function Base() { + } + return Base; + }()); + return Base; +} +var Gen = /** @class */ (function (_super) { + __extends(Gen, _super); + function Gen() { + return _super !== null && _super.apply(this, arguments) || this; + } + return Gen; +}(base())); // Error, T not in scope +var Spec = /** @class */ (function (_super) { + __extends(Spec, _super); + function Spec() { + return _super !== null && _super.apply(this, arguments) || this; + } + return Spec; +}(Gen)); +Spec.prop; diff --git a/tests/cases/compiler/baseExpressionTypeParameters.ts b/tests/cases/compiler/baseExpressionTypeParameters.ts new file mode 100644 index 00000000000..ca864f9a7f0 --- /dev/null +++ b/tests/cases/compiler/baseExpressionTypeParameters.ts @@ -0,0 +1,13 @@ +// Repro from #17829 + +function base() { + class Base { + static prop: T; + } + return Base; +} + +class Gen extends base() {} // Error, T not in scope +class Spec extends Gen {} + +Spec.prop; \ No newline at end of file From 07e1d3b13d66e82f901ba8ceb02e6eb90de797ef Mon Sep 17 00:00:00 2001 From: Mohamed Hegazy Date: Mon, 21 Aug 2017 09:44:03 -0700 Subject: [PATCH 091/370] Ensure string enums are generated in protocol.d.ts (#17914) --- scripts/buildProtocol.ts | 14 +++++++++----- src/server/protocol.ts | 4 ++++ 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/scripts/buildProtocol.ts b/scripts/buildProtocol.ts index e03338bf60d..c2ac33c83fc 100644 --- a/scripts/buildProtocol.ts +++ b/scripts/buildProtocol.ts @@ -7,11 +7,15 @@ function endsWith(s: string, suffix: string) { return s.lastIndexOf(suffix, s.length - suffix.length) !== -1; } +function isStringEnum(declaration: ts.EnumDeclaration) { + return declaration.members.length && declaration.members.every(m => m.initializer && m.initializer.kind === ts.SyntaxKind.StringLiteral); +} + class DeclarationsWalker { private visitedTypes: ts.Type[] = []; private text = ""; private removedTypes: ts.Type[] = []; - + private constructor(private typeChecker: ts.TypeChecker, private protocolFile: ts.SourceFile) { } @@ -19,7 +23,7 @@ class DeclarationsWalker { let text = "declare namespace ts.server.protocol {\n"; var walker = new DeclarationsWalker(typeChecker, protocolFile); walker.visitTypeNodes(protocolFile); - text = walker.text + text = walker.text ? `declare namespace ts.server.protocol {\n${walker.text}}` : ""; if (walker.removedTypes) { @@ -52,7 +56,7 @@ class DeclarationsWalker { if (sourceFile === this.protocolFile || path.basename(sourceFile.fileName) === "lib.d.ts") { return; } - if (decl.kind === ts.SyntaxKind.EnumDeclaration) { + if (decl.kind === ts.SyntaxKind.EnumDeclaration && !isStringEnum(decl as ts.EnumDeclaration)) { this.removedTypes.push(type); return; } @@ -91,7 +95,7 @@ class DeclarationsWalker { for (const type of heritageClauses[0].types) { this.processTypeOfNode(type); } - } + } break; } } @@ -110,7 +114,7 @@ class DeclarationsWalker { this.processType(type); } } - } + } } function writeProtocolFile(outputFile: string, protocolTs: string, typeScriptServicesDts: string) { diff --git a/src/server/protocol.ts b/src/server/protocol.ts index f50c8731126..37bf79837c9 100644 --- a/src/server/protocol.ts +++ b/src/server/protocol.ts @@ -2489,6 +2489,7 @@ namespace ts.server.protocol { System = "System", ES6 = "ES6", ES2015 = "ES2015", + ESNext = "ESNext" } export const enum ModuleResolutionKind { @@ -2506,5 +2507,8 @@ namespace ts.server.protocol { ES5 = "ES5", ES6 = "ES6", ES2015 = "ES2015", + ES2016 = "ES2016", + ES2017 = "ES2017", + ESNext = "ESNext" } } From 2b28916e5ee9f3f02f780b448ac8a58d31b84628 Mon Sep 17 00:00:00 2001 From: Andy Date: Mon, 21 Aug 2017 11:34:53 -0700 Subject: [PATCH 092/370] Simplify resolveBaseTypesOfClass (#17918) --- src/compiler/checker.ts | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 6febaf0052d..f7921181568 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -4929,7 +4929,7 @@ namespace ts { } function resolveBaseTypesOfClass(type: InterfaceType): void { - type.resolvedBaseTypes = type.resolvedBaseTypes || emptyArray; + type.resolvedBaseTypes = emptyArray; const baseConstructorType = getApparentType(getBaseConstructorTypeOfClass(type)); if (!(baseConstructorType.flags & (TypeFlags.Object | TypeFlags.Intersection | TypeFlags.Any))) { return; @@ -4976,17 +4976,12 @@ namespace ts { error(baseTypeNode.expression, Diagnostics.Base_constructor_return_type_0_is_not_a_class_or_interface_type, typeToString(baseType)); return; } - if (type === baseType || hasBaseType(baseType, type)) { + if (type === baseType || hasBaseType(baseType, type)) { error(valueDecl, Diagnostics.Type_0_recursively_references_itself_as_a_base_type, typeToString(type, /*enclosingDeclaration*/ undefined, TypeFormatFlags.WriteArrayAsGenericType)); return; } - if (type.resolvedBaseTypes === emptyArray) { - type.resolvedBaseTypes = [baseType]; - } - else { - type.resolvedBaseTypes.push(baseType); - } + type.resolvedBaseTypes = [baseType]; } function areAllOuterTypeParametersApplied(type: Type): boolean { @@ -5003,7 +4998,7 @@ namespace ts { // A valid base type is `any`, any non-generic object type or intersection of non-generic // object types. - function isValidBaseType(type: Type): boolean { + function isValidBaseType(type: Type): type is BaseType { return type.flags & (TypeFlags.Object | TypeFlags.NonPrimitive | TypeFlags.Any) && !isGenericMappedType(type) || type.flags & TypeFlags.Intersection && !forEach((type).types, t => !isValidBaseType(t)); } @@ -5016,12 +5011,12 @@ namespace ts { const baseType = getTypeFromTypeNode(node); if (baseType !== unknownType) { if (isValidBaseType(baseType)) { - if (type !== baseType && !hasBaseType(baseType, type)) { + if (type !== baseType && !hasBaseType(baseType, type)) { if (type.resolvedBaseTypes === emptyArray) { type.resolvedBaseTypes = [baseType]; } else { - type.resolvedBaseTypes.push(baseType); + type.resolvedBaseTypes.push(baseType); } } else { From 9726ba1198dddce9dc2d8a5508d1dc8904185444 Mon Sep 17 00:00:00 2001 From: uniqueiniquity Date: Tue, 8 Aug 2017 09:50:07 -0700 Subject: [PATCH 093/370] Add support for custom outlining regions --- src/compiler/types.ts | 4 ++ src/services/outliningElementsCollector.ts | 69 ++++++++++++++++++++++ 2 files changed, 73 insertions(+) diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 608bc779042..4bf180c595a 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -2037,6 +2037,10 @@ namespace ts { end: -1; } + export interface RegionRange extends TextRange { + name?: string; + } + // represents a top level: { type } expression in a JSDoc comment. export interface JSDocTypeExpression extends TypeNode { kind: SyntaxKind.JSDocTypeExpression; diff --git a/src/services/outliningElementsCollector.ts b/src/services/outliningElementsCollector.ts index e0d99d1d271..3bd53f86301 100644 --- a/src/services/outliningElementsCollector.ts +++ b/src/services/outliningElementsCollector.ts @@ -6,6 +6,10 @@ namespace ts.OutliningElementsCollector { export function collectElements(sourceFile: SourceFile, cancellationToken: CancellationToken): OutliningSpan[] { const elements: OutliningSpan[] = []; let depth = 0; + const regions: RegionRange[] = []; + const regionText = "#region"; + const regionStart = new RegExp("// #region( .+| *)", "g"); + const regionEnd = new RegExp("// #endregion *"); walk(sourceFile); return elements; @@ -35,6 +39,18 @@ namespace ts.OutliningElementsCollector { } } + function addOutliningSpanRegions(regionSpan: RegionRange) { + if (regionSpan) { + const span: OutliningSpan = { + textSpan: createTextSpanFromBounds(regionSpan.pos, regionSpan.end), + hintSpan: createTextSpanFromBounds(regionSpan.pos, regionSpan.end), + bannerText: regionSpan.name, + autoCollapse: false, + }; + elements.push(span); + } + } + function addOutliningForLeadingCommentsForNode(n: Node) { const comments = ts.getLeadingCommentRangesOfNode(n, sourceFile); @@ -89,12 +105,65 @@ namespace ts.OutliningElementsCollector { return isFunctionBlock(node) && node.parent.kind !== SyntaxKind.ArrowFunction; } + function isRegionStart(range: CommentRange) { + const comment = sourceFile.text.substring(range.pos, range.end); + const result = comment.match(regionStart); + + if (result && result.length > 0) { + const name = result[0].substring(10).trim(); + if (name) { + return name; + } + else { + return regionText; + } + } + return ""; + } + + function isRegionEnd(range: CommentRange) { + const comment = sourceFile.text.substring(range.pos, range.end); + return comment.match(regionEnd); + } + + function addRegionsNearNode(n: Node) { + const comments = ts.getLeadingCommentRangesOfNode(n, sourceFile); + + if (n.kind !== SyntaxKind.SourceFile && comments) { + for (const currentComment of comments) { + cancellationToken.throwIfCancellationRequested(); + + if (currentComment.kind === SyntaxKind.SingleLineCommentTrivia) { + const name = isRegionStart(currentComment); + if (name) { + const region: RegionRange = { + pos: currentComment.pos, + end: currentComment.end, + name, + }; + regions.push(region); + } + else if (isRegionEnd(currentComment)) { + const region = regions.pop(); + + if (region) { + region.end = currentComment.end; + addOutliningSpanRegions(region); + } + } + } + } + } + } + function walk(n: Node): void { cancellationToken.throwIfCancellationRequested(); if (depth > maxDepth) { return; } + addRegionsNearNode(n); + if (isDeclaration(n)) { addOutliningForLeadingCommentsForNode(n); } From f91c23b25f63913124a60366fe7365424611144d Mon Sep 17 00:00:00 2001 From: uniqueiniquity Date: Tue, 8 Aug 2017 15:58:42 -0700 Subject: [PATCH 094/370] Add regex sweep implementation --- src/services/outliningElementsCollector.ts | 55 +++++++++++++++++++++- 1 file changed, 53 insertions(+), 2 deletions(-) diff --git a/src/services/outliningElementsCollector.ts b/src/services/outliningElementsCollector.ts index 3bd53f86301..e79175b4b24 100644 --- a/src/services/outliningElementsCollector.ts +++ b/src/services/outliningElementsCollector.ts @@ -12,6 +12,7 @@ namespace ts.OutliningElementsCollector { const regionEnd = new RegExp("// #endregion *"); walk(sourceFile); + gatherRegions(); return elements; /** If useFullStart is true, then the collapsing span includes leading whitespace, including linebreaks. */ @@ -127,7 +128,10 @@ namespace ts.OutliningElementsCollector { } function addRegionsNearNode(n: Node) { - const comments = ts.getLeadingCommentRangesOfNode(n, sourceFile); + const precedingToken = ts.findPrecedingToken(n.pos, sourceFile); + const trailingComments = precedingToken && ts.getTrailingCommentRanges(sourceFile.text, precedingToken.end); + const leadingComments = ts.getLeadingCommentRangesOfNode(n, sourceFile); + const comments = concatenate(trailingComments, leadingComments); if (n.kind !== SyntaxKind.SourceFile && comments) { for (const currentComment of comments) { @@ -148,7 +152,7 @@ namespace ts.OutliningElementsCollector { if (region) { region.end = currentComment.end; - addOutliningSpanRegions(region); + // addOutliningSpanRegions(region); } } } @@ -156,6 +160,53 @@ namespace ts.OutliningElementsCollector { } } + function isRegionStartBoundaries(start: number, end: number) { + const comment = sourceFile.text.substring(start, end); + const result = comment.match(regionStart); + + if (result && result.length > 0) { + const name = result[0].substring(10).trim(); + if (name) { + return name; + } + else { + return regionText; + } + } + return ""; + } + + function isRegionEndBoundaries(start: number, end: number) { + const comment = sourceFile.text.substring(start, end); + return comment.match(regionEnd); + } + + function gatherRegions(): void { + const lineStarts = sourceFile.getLineStarts(); + + for (const currentLineStart of lineStarts) { + const lineEnd = sourceFile.getLineEndOfPosition(currentLineStart); + + const name = isRegionStartBoundaries(currentLineStart, lineEnd); + if (name) { + const region: RegionRange = { + pos: currentLineStart, + end: lineEnd, + name, + }; + regions.push(region); + } + else if (isRegionEndBoundaries(currentLineStart, lineEnd)) { + const region = regions.pop(); + + if (region) { + region.end = lineEnd; + addOutliningSpanRegions(region); + } + } + } + } + function walk(n: Node): void { cancellationToken.throwIfCancellationRequested(); if (depth > maxDepth) { From 0b3ec247bcbce77115b4155688f5b718ce7f7ee1 Mon Sep 17 00:00:00 2001 From: uniqueiniquity Date: Wed, 9 Aug 2017 09:00:46 -0700 Subject: [PATCH 095/370] Fix name capture logic --- src/services/outliningElementsCollector.ts | 23 ++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/src/services/outliningElementsCollector.ts b/src/services/outliningElementsCollector.ts index e79175b4b24..255e7c9aad6 100644 --- a/src/services/outliningElementsCollector.ts +++ b/src/services/outliningElementsCollector.ts @@ -8,8 +8,8 @@ namespace ts.OutliningElementsCollector { let depth = 0; const regions: RegionRange[] = []; const regionText = "#region"; - const regionStart = new RegExp("// #region( .+| *)", "g"); - const regionEnd = new RegExp("// #endregion *"); + const regionStart = new RegExp("//\\s*#region(\\s+.*)?$", "gm"); + const regionEnd = new RegExp("//\\s*#endregion(\\s|$)", "gm"); walk(sourceFile); gatherRegions(); @@ -165,12 +165,23 @@ namespace ts.OutliningElementsCollector { const result = comment.match(regionStart); if (result && result.length > 0) { - const name = result[0].substring(10).trim(); - if (name) { - return name; + const sections = result[0].split(" ").filter(function (s) { return s !== ""; }); + + if (sections[0] === "//") { + if (sections.length > 2) { + return result[0].substring(result[0].indexOf(sections[2])); + } + else { + return regionText; + } } else { - return regionText; + if (sections.length > 1) { + return result[0].substring(result[0].indexOf(sections[1])); + } + else { + return regionText; + } } } return ""; From 0ef5498de3aff69da3a7e56574f98e0b4e6b5e10 Mon Sep 17 00:00:00 2001 From: uniqueiniquity Date: Wed, 9 Aug 2017 09:13:18 -0700 Subject: [PATCH 096/370] Clean up unused functions --- src/services/outliningElementsCollector.ts | 64 ++-------------------- 1 file changed, 4 insertions(+), 60 deletions(-) diff --git a/src/services/outliningElementsCollector.ts b/src/services/outliningElementsCollector.ts index 255e7c9aad6..cad56fe1ced 100644 --- a/src/services/outliningElementsCollector.ts +++ b/src/services/outliningElementsCollector.ts @@ -106,61 +106,7 @@ namespace ts.OutliningElementsCollector { return isFunctionBlock(node) && node.parent.kind !== SyntaxKind.ArrowFunction; } - function isRegionStart(range: CommentRange) { - const comment = sourceFile.text.substring(range.pos, range.end); - const result = comment.match(regionStart); - - if (result && result.length > 0) { - const name = result[0].substring(10).trim(); - if (name) { - return name; - } - else { - return regionText; - } - } - return ""; - } - - function isRegionEnd(range: CommentRange) { - const comment = sourceFile.text.substring(range.pos, range.end); - return comment.match(regionEnd); - } - - function addRegionsNearNode(n: Node) { - const precedingToken = ts.findPrecedingToken(n.pos, sourceFile); - const trailingComments = precedingToken && ts.getTrailingCommentRanges(sourceFile.text, precedingToken.end); - const leadingComments = ts.getLeadingCommentRangesOfNode(n, sourceFile); - const comments = concatenate(trailingComments, leadingComments); - - if (n.kind !== SyntaxKind.SourceFile && comments) { - for (const currentComment of comments) { - cancellationToken.throwIfCancellationRequested(); - - if (currentComment.kind === SyntaxKind.SingleLineCommentTrivia) { - const name = isRegionStart(currentComment); - if (name) { - const region: RegionRange = { - pos: currentComment.pos, - end: currentComment.end, - name, - }; - regions.push(region); - } - else if (isRegionEnd(currentComment)) { - const region = regions.pop(); - - if (region) { - region.end = currentComment.end; - // addOutliningSpanRegions(region); - } - } - } - } - } - } - - function isRegionStartBoundaries(start: number, end: number) { + function isRegionStart(start: number, end: number) { const comment = sourceFile.text.substring(start, end); const result = comment.match(regionStart); @@ -187,7 +133,7 @@ namespace ts.OutliningElementsCollector { return ""; } - function isRegionEndBoundaries(start: number, end: number) { + function isRegionEnd(start: number, end: number) { const comment = sourceFile.text.substring(start, end); return comment.match(regionEnd); } @@ -198,7 +144,7 @@ namespace ts.OutliningElementsCollector { for (const currentLineStart of lineStarts) { const lineEnd = sourceFile.getLineEndOfPosition(currentLineStart); - const name = isRegionStartBoundaries(currentLineStart, lineEnd); + const name = isRegionStart(currentLineStart, lineEnd); if (name) { const region: RegionRange = { pos: currentLineStart, @@ -207,7 +153,7 @@ namespace ts.OutliningElementsCollector { }; regions.push(region); } - else if (isRegionEndBoundaries(currentLineStart, lineEnd)) { + else if (isRegionEnd(currentLineStart, lineEnd)) { const region = regions.pop(); if (region) { @@ -224,8 +170,6 @@ namespace ts.OutliningElementsCollector { return; } - addRegionsNearNode(n); - if (isDeclaration(n)) { addOutliningForLeadingCommentsForNode(n); } From 4971e3152c2ba1d5256c986b936322aeb22be436 Mon Sep 17 00:00:00 2001 From: uniqueiniquity Date: Wed, 9 Aug 2017 10:14:52 -0700 Subject: [PATCH 097/370] Ensure region boundaries are entire line --- src/services/outliningElementsCollector.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/services/outliningElementsCollector.ts b/src/services/outliningElementsCollector.ts index cad56fe1ced..7c4bf24d580 100644 --- a/src/services/outliningElementsCollector.ts +++ b/src/services/outliningElementsCollector.ts @@ -8,8 +8,8 @@ namespace ts.OutliningElementsCollector { let depth = 0; const regions: RegionRange[] = []; const regionText = "#region"; - const regionStart = new RegExp("//\\s*#region(\\s+.*)?$", "gm"); - const regionEnd = new RegExp("//\\s*#endregion(\\s|$)", "gm"); + const regionStart = new RegExp("^\\s*//\\s*#region(\\s+.*)?$", "gm"); + const regionEnd = new RegExp("^\\s*//\\s*#endregion(\\s|$)", "gm"); walk(sourceFile); gatherRegions(); From 562d988614e967910f06da72ce9d0f57c7c8a39a Mon Sep 17 00:00:00 2001 From: uniqueiniquity Date: Mon, 21 Aug 2017 11:19:21 -0700 Subject: [PATCH 098/370] Exclude region delimiters in multiline comments --- src/services/outliningElementsCollector.ts | 41 ++++++++++++---------- 1 file changed, 23 insertions(+), 18 deletions(-) diff --git a/src/services/outliningElementsCollector.ts b/src/services/outliningElementsCollector.ts index 7c4bf24d580..82ac22e644c 100644 --- a/src/services/outliningElementsCollector.ts +++ b/src/services/outliningElementsCollector.ts @@ -107,26 +107,28 @@ namespace ts.OutliningElementsCollector { } function isRegionStart(start: number, end: number) { - const comment = sourceFile.text.substring(start, end); - const result = comment.match(regionStart); + if (!ts.formatting.getRangeOfEnclosingComment(sourceFile, start, /*onlyMultiLine*/ true)) { + const comment = sourceFile.text.substring(start, end); + const result = comment.match(regionStart); - if (result && result.length > 0) { - const sections = result[0].split(" ").filter(function (s) { return s !== ""; }); + if (result && result.length > 0) { + const sections = result[0].split(" ").filter(function (s) { return s !== ""; }); - if (sections[0] === "//") { - if (sections.length > 2) { - return result[0].substring(result[0].indexOf(sections[2])); + if (sections[0] === "//") { + if (sections.length > 2) { + return result[0].substring(result[0].indexOf(sections[2])); + } + else { + return regionText; + } } else { - return regionText; - } - } - else { - if (sections.length > 1) { - return result[0].substring(result[0].indexOf(sections[1])); - } - else { - return regionText; + if (sections.length > 1) { + return result[0].substring(result[0].indexOf(sections[1])); + } + else { + return regionText; + } } } } @@ -134,8 +136,11 @@ namespace ts.OutliningElementsCollector { } function isRegionEnd(start: number, end: number) { - const comment = sourceFile.text.substring(start, end); - return comment.match(regionEnd); + if (!ts.formatting.getRangeOfEnclosingComment(sourceFile, start, /*onlyMultiLine*/ true)) { + const comment = sourceFile.text.substring(start, end); + return comment.match(regionEnd); + } + return undefined; } function gatherRegions(): void { From fb462c91a4a4089a05eeb83a3d6b5333d4385c2d Mon Sep 17 00:00:00 2001 From: uniqueiniquity Date: Mon, 21 Aug 2017 15:28:40 -0700 Subject: [PATCH 099/370] Ensure returned spans are ordered by start --- src/services/outliningElementsCollector.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/services/outliningElementsCollector.ts b/src/services/outliningElementsCollector.ts index 82ac22e644c..59f8e9f5549 100644 --- a/src/services/outliningElementsCollector.ts +++ b/src/services/outliningElementsCollector.ts @@ -13,7 +13,7 @@ namespace ts.OutliningElementsCollector { walk(sourceFile); gatherRegions(); - return elements; + return elements.sort((span1, span2) => span1.textSpan.start - span2.textSpan.start); /** If useFullStart is true, then the collapsing span includes leading whitespace, including linebreaks. */ function addOutliningSpan(hintSpanNode: Node, startElement: Node, endElement: Node, autoCollapse: boolean, useFullStart: boolean) { From 442bc56fc2b1a4ba862cd33895f3185dafc85044 Mon Sep 17 00:00:00 2001 From: uniqueiniquity Date: Mon, 21 Aug 2017 15:39:58 -0700 Subject: [PATCH 100/370] Add test for region spans --- .../fourslash/getOutliningSpansForRegions.ts | 46 +++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 tests/cases/fourslash/getOutliningSpansForRegions.ts diff --git a/tests/cases/fourslash/getOutliningSpansForRegions.ts b/tests/cases/fourslash/getOutliningSpansForRegions.ts new file mode 100644 index 00000000000..73202fb9c9c --- /dev/null +++ b/tests/cases/fourslash/getOutliningSpansForRegions.ts @@ -0,0 +1,46 @@ +/// + +////// basic region +////[|// #region +//// +////// #endregion|] +//// +////// region with label +////[|// #region label1 +//// +////// #endregion|] +//// +////// region with extra whitespace in all valid locations +////[| // #region label2 label3 +//// +//// // #endregion|] +//// +////// No space before directive +////[|//#region label4 +//// +//////#endregion|] +//// +////// Nested regions +////[|// #region outer +//// +////[|// #region inner +//// +////// #endregion inner|] +//// +////// #endregion outer|] +//// +////// region delimiters not valid when preceding text on line +//// test // #region invalid1 +//// +////test // #endregion +//// +////// region delimiters not valid when in multiline comment +/////* +////// #region invalid2 +////*/ +//// +/////* +////// #endregion +////*/ + +verify.outliningSpansInCurrentFile(test.ranges()); \ No newline at end of file From ac098535cbd0db5f7f401d7e391f54274fd44639 Mon Sep 17 00:00:00 2001 From: Basarat Ali Syed Date: Tue, 22 Aug 2017 09:55:40 +1000 Subject: [PATCH 101/370] =?UTF-8?q?export=20UsageEntry=20used=20by=20alrea?= =?UTF-8?q?dy=20exported=20functions=20=F0=9F=8C=B9=20(#17853)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/services/refactors/extractMethod.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/services/refactors/extractMethod.ts b/src/services/refactors/extractMethod.ts index cf58ede99bd..90e33041695 100644 --- a/src/services/refactors/extractMethod.ts +++ b/src/services/refactors/extractMethod.ts @@ -856,7 +856,7 @@ namespace ts.refactor.extractMethod { Write = 2 } - interface UsageEntry { + export interface UsageEntry { readonly usage: Usage; readonly symbol: Symbol; readonly node: Node; From a3a2ff5f1286649043d51d4dd416ede5acc7ee83 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Tue, 22 Aug 2017 10:13:08 +0100 Subject: [PATCH 102/370] Optimize relations for type references with unconstrained type arguments --- src/compiler/checker.ts | 44 ++++++++++++++++++++++++++++++++++++++--- 1 file changed, 41 insertions(+), 3 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index d2d3697f175..b179231736c 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -8805,8 +8805,7 @@ namespace ts { return true; } if (source.flags & TypeFlags.Object && target.flags & TypeFlags.Object) { - const id = relation !== identityRelation || source.id < target.id ? source.id + "," + target.id : target.id + "," + source.id; - const related = relation.get(id); + const related = relation.get(getRelationKey(source, target, relation)); if (related !== undefined) { return related === RelationComparisonResult.Succeeded; } @@ -9207,7 +9206,7 @@ namespace ts { if (overflow) { return Ternary.False; } - const id = relation !== identityRelation || source.id < target.id ? source.id + "," + target.id : target.id + "," + source.id; + const id = getRelationKey(source, target, relation); const related = relation.get(id); if (related !== undefined) { if (reportErrors && related === RelationComparisonResult.Failed) { @@ -9772,6 +9771,45 @@ namespace ts { } } + function isUnconstrainedTypeParameter(type: Type) { + return type.flags & TypeFlags.TypeParameter && !getConstraintFromTypeParameter(type); + } + + function isTypeReferenceWithGenericArguments(type: Type) { + return getObjectFlags(type) & ObjectFlags.Reference && some((type).typeArguments, isUnconstrainedTypeParameter); + } + + function getTypeReferenceId(type: TypeReference, typeParameters: Type[]) { + let result = "" + type.id; + for (const t of type.typeArguments) { + if (isUnconstrainedTypeParameter(t)) { + let index = indexOf(typeParameters, t); + if (index < 0) { + index = typeParameters.length; + typeParameters.push(t); + } + result += "=" + index; + } + else { + result += "-" + t.id; + } + } + return result; + } + + function getRelationKey(source: Type, target: Type, relation: Map) { + if (relation === identityRelation && source.id > target.id) { + const temp = source; + source = target; + target = temp; + } + if (isTypeReferenceWithGenericArguments(source) && isTypeReferenceWithGenericArguments(target)) { + const typeParameters: Type[] = []; + return getTypeReferenceId(source, typeParameters) + "," + getTypeReferenceId(target, typeParameters); + } + return source.id + "," + target.id; + } + // Invoke the callback for each underlying property symbol of the given symbol and return the first // value that isn't undefined. function forEachProperty(prop: Symbol, callback: (p: Symbol) => T): T { From 11c4c4cd61cbc2f0a42f7bd81e55bbf9b4c7a70f Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Tue, 22 Aug 2017 17:41:07 +0100 Subject: [PATCH 103/370] Fix to use correct target type ID --- src/compiler/checker.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index b179231736c..3accf163738 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -9780,7 +9780,7 @@ namespace ts { } function getTypeReferenceId(type: TypeReference, typeParameters: Type[]) { - let result = "" + type.id; + let result = "" + type.target.id; for (const t of type.typeArguments) { if (isUnconstrainedTypeParameter(t)) { let index = indexOf(typeParameters, t); From 6678d961aabdaea865308a81000d0b5cdf48e6d3 Mon Sep 17 00:00:00 2001 From: Matt Mitchell Date: Tue, 22 Aug 2017 09:47:29 -0700 Subject: [PATCH 104/370] Update imaged with Java 8 and other patches (#17965) Updated image, java 8 required --- netci.groovy | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/netci.groovy b/netci.groovy index bc512f6b245..c60957730c4 100644 --- a/netci.groovy +++ b/netci.groovy @@ -17,6 +17,6 @@ nodeVersions.each { nodeVer -> } Utilities.standardJobSetup(newJob, project, true, "*/${branch}") - Utilities.setMachineAffinity(newJob, 'Ubuntu', '20161020') + Utilities.setMachineAffinity(newJob, 'Ubuntu14.04', '20170821-1') Utilities.addGithubPRTriggerForBranch(newJob, branch, "TypeScript Test Run ${newJobName}") } From 053b91506103cf185d852d816f4010e162e3729e Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Wed, 20 Jul 2016 14:58:46 -0700 Subject: [PATCH 105/370] Rebase SymbolWalker change onto master From PR #9847. --- Jakefile.js | 1 + src/compiler/checker.ts | 2 + src/compiler/symbolWalker.ts | 163 ++++++++++++++++++++++++++ src/compiler/tsconfig.json | 1 + src/compiler/types.ts | 8 ++ src/harness/tsconfig.json | 2 + src/harness/unittests/symbolWalker.ts | 53 +++++++++ src/services/tsconfig.json | 1 + 8 files changed, 231 insertions(+) create mode 100644 src/compiler/symbolWalker.ts create mode 100644 src/harness/unittests/symbolWalker.ts diff --git a/Jakefile.js b/Jakefile.js index 15fe40141f6..46573e701ff 100644 --- a/Jakefile.js +++ b/Jakefile.js @@ -140,6 +140,7 @@ var harnessSources = harnessCoreSources.concat([ "transform.ts", "customTransforms.ts", "programMissingFiles.ts", + "symbolWalker.ts", ].map(function (f) { return path.join(unittestsDirectory, f); })).concat([ diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index d2d3697f175..d69c6cdebda 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -1,5 +1,6 @@ /// /// +/// /* @internal */ namespace ts { @@ -204,6 +205,7 @@ namespace ts { getEmitResolver, getExportsOfModule: getExportsOfModuleAsArray, getExportsAndPropertiesOfModule, + getSymbolWalker: createGetSymbolWalker(getRestTypeOfSignature, getReturnTypeOfSignature, getBaseTypes, resolveStructuredTypeMembers, getTypeOfSymbol, getResolvedSymbol, getIndexTypeOfStructuredType), getAmbientModules, getAllAttributesTypeFromJsxOpeningLikeElement: node => { node = getParseTreeNode(node, isJsxOpeningLikeElement); diff --git a/src/compiler/symbolWalker.ts b/src/compiler/symbolWalker.ts new file mode 100644 index 00000000000..c85661df29a --- /dev/null +++ b/src/compiler/symbolWalker.ts @@ -0,0 +1,163 @@ +namespace ts { + export function createGetSymbolWalker( + getRestTypeOfSignature: (sig: Signature) => Type, + getReturnTypeOfSignature: (sig: Signature) => Type, + getBaseTypes: (type: Type) => Type[], + resolveStructuredTypeMembers: (type: ObjectType) => ResolvedType, + getTypeOfSymbol: (sym: Symbol) => Type, + getResolvedSymbol: (node: Node) => Symbol, + getIndexTypeOfStructuredType: (type: Type, kind: IndexKind) => Type) { + + return getSymbolWalker; + + function getSymbolWalker(accept: (symbol: Symbol) => boolean = () => true): SymbolWalker { + let visited: Type[] = []; + let visitedSymbols: Symbol[] = []; + + return { + visitType, + visitSymbol, + reset: (newCallback: (symbol: Symbol) => boolean = () => true) => { + accept = newCallback; + visited = []; + visitedSymbols = []; + } + }; + + function visitType(type: Type): void { + if (!type) { + return; + } + if (contains(visited, type)) { + return; + } + visited.push(type); + + // Reuse visitSymbol to visit the type's symbol, + // but be sure to bail on recuring into the type if accept declines the symbol. + const shouldBail = visitSymbol(type.symbol); + if (shouldBail) return; + + // Visit the type's related types, if any + if (type.flags & TypeFlags.Object) { + const objectType = type as ObjectType; + const objectFlags = objectType.objectFlags; + if (objectFlags & ObjectFlags.Reference) { + visitTypeReference(type as TypeReference); + } + if (objectFlags & (ObjectFlags.Class | ObjectFlags.Interface)) { + visitInterfaceType(type as InterfaceType); + } + if (objectFlags & (ObjectFlags.Tuple | ObjectFlags.Anonymous)) { + visitObjectType(objectType); + } + } + if (type.flags & TypeFlags.TypeParameter) { + visitTypeParameter(type as TypeParameter); + } + if (type.flags & TypeFlags.UnionOrIntersection) { + visitUnionOrIntersectionType(type as UnionOrIntersectionType); + } + } + + function visitTypeList(types: Type[]): void { + if (!types) { + return; + } + for (let i = 0; i < types.length; i++) { + visitType(types[i]); + } + } + + function visitTypeReference(type: TypeReference): void { + visitType(type.target); + visitTypeList(type.typeArguments); + } + + function visitTypeParameter(type: TypeParameter): void { + visitType(type.constraint); + } + + function visitUnionOrIntersectionType(type: UnionOrIntersectionType): void { + visitTypeList(type.types); + } + + function visitSignature(signature: Signature): void { + if (signature.typePredicate) { + visitType(signature.typePredicate.type); + } + visitTypeList(signature.typeParameters); + + for (const parameter of signature.parameters){ + visitSymbol(parameter); + } + visitType(getRestTypeOfSignature(signature)); + visitType(getReturnTypeOfSignature(signature)); + } + + function visitInterfaceType(interfaceT: InterfaceType): void { + visitObjectType(interfaceT); + visitTypeList(interfaceT.typeParameters); + visitTypeList(getBaseTypes(interfaceT)); + visitType(interfaceT.thisType); + } + + function visitObjectType(type: ObjectType): void { + const stringIndexType = getIndexTypeOfStructuredType(type, IndexKind.String); + visitType(stringIndexType); + const numberIndexType = getIndexTypeOfStructuredType(type, IndexKind.String); + visitType(numberIndexType); + + // The two checks above *should* have already resolved the type (if needed), so this should be cached + const resolved = resolveStructuredTypeMembers(type); + for (const signature of resolved.callSignatures) { + visitSignature(signature); + } + for (const signature of resolved.constructSignatures) { + visitSignature(signature); + } + for (const p of resolved.properties) { + visitSymbol(p); + } + } + + function visitSymbol(symbol: Symbol): boolean { + if (!symbol) { + return; + } + if (contains(visitedSymbols, symbol)) { + return; + } + visitedSymbols.push(symbol); + if (!accept(symbol)) { + return true; + } + const t = getTypeOfSymbol(symbol); + visitType(t); // Should handle members on classes and such + if (symbol.flags & SymbolFlags.HasExports) { + symbol.exports.forEach(visitSymbol); + } + forEach(symbol.declarations, d => { + // Type queries are too far resolved when we just visit the symbol's type + // (their type resolved directly to the member deeply referenced) + // So to get the intervening symbols, we need to check if there's a type + // query node on any of the symbol's declarations and get symbols there + if ((d as any).type && (d as any).type.kind === SyntaxKind.TypeQuery) { + const query = (d as any).type as TypeQueryNode; + const entity = leftmostSymbol(query.exprName); + visitSymbol(entity); + } + }); + } + } + + function leftmostSymbol(expr: QualifiedName | Identifier): Symbol { + if (expr.kind === SyntaxKind.Identifier) { + return getResolvedSymbol(expr as Identifier); + } + else { + return leftmostSymbol((expr as QualifiedName).left); + } + } + } +} \ No newline at end of file diff --git a/src/compiler/tsconfig.json b/src/compiler/tsconfig.json index 3709d65b7fd..c048359fcb7 100644 --- a/src/compiler/tsconfig.json +++ b/src/compiler/tsconfig.json @@ -14,6 +14,7 @@ "parser.ts", "utilities.ts", "binder.ts", + "symbolWalker.ts", "checker.ts", "factory.ts", "visitor.ts", diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 608bc779042..7bce522d5ba 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -2625,6 +2625,8 @@ namespace ts { /* @internal */ tryFindAmbientModuleWithoutAugmentations(moduleName: string): Symbol | undefined; + getSymbolWalker(accept?: (symbol: Symbol) => boolean): SymbolWalker; + // Should not be called directly. Should only be accessed through the Program instance. /* @internal */ getDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): Diagnostic[]; /* @internal */ getGlobalDiagnostics(): Diagnostic[]; @@ -2669,6 +2671,12 @@ namespace ts { InTypeAlias = 1 << 23, // Writing type in type alias declaration } + export interface SymbolWalker { + visitType(type: Type): void; + visitSymbol(symbol: Symbol): void; + reset(accept?: (symbol: Symbol) => boolean): void; + } + export interface SymbolDisplayBuilder { buildTypeDisplay(type: Type, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void; buildSymbolDisplay(symbol: Symbol, writer: SymbolWriter, enclosingDeclaration?: Node, meaning?: SymbolFlags, flags?: SymbolFormatFlags): void; diff --git a/src/harness/tsconfig.json b/src/harness/tsconfig.json index 66ca2fc3f48..9165e59cb0a 100644 --- a/src/harness/tsconfig.json +++ b/src/harness/tsconfig.json @@ -21,6 +21,7 @@ "../compiler/parser.ts", "../compiler/utilities.ts", "../compiler/binder.ts", + "../compiler/symbolWalker.ts", "../compiler/checker.ts", "../compiler/factory.ts", "../compiler/visitor.ts", @@ -103,6 +104,7 @@ "./unittests/services/preProcessFile.ts", "./unittests/services/patternMatcher.ts", "./unittests/session.ts", + "./unittests/symbolWalker.ts", "./unittests/versionCache.ts", "./unittests/convertToBase64.ts", "./unittests/transpile.ts", diff --git a/src/harness/unittests/symbolWalker.ts b/src/harness/unittests/symbolWalker.ts new file mode 100644 index 00000000000..275c37d41f6 --- /dev/null +++ b/src/harness/unittests/symbolWalker.ts @@ -0,0 +1,53 @@ +/// + +namespace ts { + describe("Symbol Walker", () => { + function test(description: string, source: string, verifier: (file: SourceFile, checker: TypeChecker, walker: SymbolWalker) => void) { + it(description, () => { + let {result} = Harness.Compiler.compileFiles([{ + unitName: "main.ts", + content: source + }], [], {}, {}, "/"); + let file = result.program.getSourceFile("main.ts"); + let checker = result.program.getTypeChecker(); + let walker = checker.getSymbolWalker(); + verifier(file, checker, walker); + + result = undefined; + file = undefined; + checker = undefined; + walker = undefined; + }); + } + + test("can be created", ` +interface Bar { + x: number; + y: number; + history: Bar[]; +} +export default function foo(a: number, b: Bar): void {}`, (file, checker, walker) => { + let foundCount = 0; + let stdLibRefSymbols = 0; + const expectedSymbols = ["default", "a", "b", "Bar", "x", "y", "history"]; + walker.reset(symbol => { + const isStdLibSymbol = forEach(symbol.declarations, d => { + return getSourceFileOfNode(d).hasNoDefaultLib; + }); + if (isStdLibSymbol) { + stdLibRefSymbols++; + return false; // Don't traverse into the stdlib. That's unnecessary for this test. + } + assert.equal(symbol.name, expectedSymbols[foundCount]); + foundCount++; + return true; + }); + const symbols = checker.getExportsOfModule(file.symbol); + for (const symbol of symbols) { + walker.visitSymbol(symbol); + } + assert.equal(foundCount, expectedSymbols.length); + assert.equal(stdLibRefSymbols, 1); // Expect 1 stdlib entry symbol - the implicit Array referenced by Bar.history + }); + }); +} \ No newline at end of file diff --git a/src/services/tsconfig.json b/src/services/tsconfig.json index f4ca2a7f130..d73014a93a2 100644 --- a/src/services/tsconfig.json +++ b/src/services/tsconfig.json @@ -14,6 +14,7 @@ "../compiler/parser.ts", "../compiler/utilities.ts", "../compiler/binder.ts", + "../compiler/symbolWalker.ts", "../compiler/checker.ts", "../compiler/factory.ts", "../compiler/visitor.ts", From 2c8a5c40b835d01c0edb2b5c4ae419f2763ff65f Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Tue, 26 Jul 2016 10:35:49 -0700 Subject: [PATCH 106/370] Make SymbolWalker internal ...until required by an external consumer. --- src/compiler/symbolWalker.ts | 2 ++ src/compiler/types.ts | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/compiler/symbolWalker.ts b/src/compiler/symbolWalker.ts index c85661df29a..0ae1e32ea9a 100644 --- a/src/compiler/symbolWalker.ts +++ b/src/compiler/symbolWalker.ts @@ -1,4 +1,6 @@ +/** @internal */ namespace ts { + /** @internal */ export function createGetSymbolWalker( getRestTypeOfSignature: (sig: Signature) => Type, getReturnTypeOfSignature: (sig: Signature) => Type, diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 7bce522d5ba..76922ab98e6 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -2625,7 +2625,7 @@ namespace ts { /* @internal */ tryFindAmbientModuleWithoutAugmentations(moduleName: string): Symbol | undefined; - getSymbolWalker(accept?: (symbol: Symbol) => boolean): SymbolWalker; + /* @internal */ getSymbolWalker(accept?: (symbol: Symbol) => boolean): SymbolWalker; // Should not be called directly. Should only be accessed through the Program instance. /* @internal */ getDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): Diagnostic[]; @@ -2671,6 +2671,7 @@ namespace ts { InTypeAlias = 1 << 23, // Writing type in type alias declaration } + /* @internal */ export interface SymbolWalker { visitType(type: Type): void; visitSymbol(symbol: Symbol): void; From 801c1f70a2cc6aecac3f5bdbf872adf469726243 Mon Sep 17 00:00:00 2001 From: Andrew Casey Date: Tue, 15 Aug 2017 13:09:24 -0700 Subject: [PATCH 107/370] Reshape SymbolWalker API 1. Expose visited types and symbols 2. Automatically reset before each walk --- src/compiler/symbolWalker.ts | 25 ++++++++++++++++--------- src/compiler/types.ts | 5 ++--- 2 files changed, 18 insertions(+), 12 deletions(-) diff --git a/src/compiler/symbolWalker.ts b/src/compiler/symbolWalker.ts index 0ae1e32ea9a..784ee840363 100644 --- a/src/compiler/symbolWalker.ts +++ b/src/compiler/symbolWalker.ts @@ -13,27 +13,34 @@ namespace ts { return getSymbolWalker; function getSymbolWalker(accept: (symbol: Symbol) => boolean = () => true): SymbolWalker { - let visited: Type[] = []; + let visitedTypes: Type[] = []; let visitedSymbols: Symbol[] = []; return { - visitType, - visitSymbol, - reset: (newCallback: (symbol: Symbol) => boolean = () => true) => { - accept = newCallback; - visited = []; + walkType: type => + { + visitedTypes = []; visitedSymbols = []; - } + visitType(type); + return { visitedTypes, visitedSymbols }; + }, + walkSymbol: symbol => + { + visitedTypes = []; + visitedSymbols = []; + visitSymbol(symbol); + return { visitedTypes, visitedSymbols }; + }, }; function visitType(type: Type): void { if (!type) { return; } - if (contains(visited, type)) { + if (contains(visitedTypes, type)) { return; } - visited.push(type); + visitedTypes.push(type); // Reuse visitSymbol to visit the type's symbol, // but be sure to bail on recuring into the type if accept declines the symbol. diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 76922ab98e6..34ae124d636 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -2673,9 +2673,8 @@ namespace ts { /* @internal */ export interface SymbolWalker { - visitType(type: Type): void; - visitSymbol(symbol: Symbol): void; - reset(accept?: (symbol: Symbol) => boolean): void; + walkType(root: Type) : { visitedTypes: Type[], visitedSymbols: Symbol[] }; + walkSymbol(root: Symbol) : { visitedTypes: Type[], visitedSymbols: Symbol[] }; } export interface SymbolDisplayBuilder { From f2eacc6395c1847da2425e761d03a852a79dc85b Mon Sep 17 00:00:00 2001 From: Andrew Casey Date: Tue, 15 Aug 2017 14:45:36 -0700 Subject: [PATCH 108/370] Use Maps to store visited types and symbols --- src/compiler/symbolWalker.ts | 27 +++++++++++++++------------ src/compiler/types.ts | 6 ++++-- 2 files changed, 19 insertions(+), 14 deletions(-) diff --git a/src/compiler/symbolWalker.ts b/src/compiler/symbolWalker.ts index 784ee840363..fda1febfb04 100644 --- a/src/compiler/symbolWalker.ts +++ b/src/compiler/symbolWalker.ts @@ -13,23 +13,23 @@ namespace ts { return getSymbolWalker; function getSymbolWalker(accept: (symbol: Symbol) => boolean = () => true): SymbolWalker { - let visitedTypes: Type[] = []; - let visitedSymbols: Symbol[] = []; + let visitedTypes = createMap(); // Key is id as string + let visitedSymbols = createMap(); // Key is id as string return { walkType: type => { - visitedTypes = []; - visitedSymbols = []; + visitedTypes.clear(); + visitedSymbols.clear(); visitType(type); - return { visitedTypes, visitedSymbols }; + return { visitedTypes: arrayFrom(visitedTypes.values()), visitedSymbols: arrayFrom(visitedSymbols.values()) }; }, walkSymbol: symbol => { - visitedTypes = []; - visitedSymbols = []; + visitedTypes.clear(); + visitedSymbols.clear(); visitSymbol(symbol); - return { visitedTypes, visitedSymbols }; + return { visitedTypes: arrayFrom(visitedTypes.values()), visitedSymbols: arrayFrom(visitedSymbols.values()) }; }, }; @@ -37,10 +37,12 @@ namespace ts { if (!type) { return; } - if (contains(visitedTypes, type)) { + + const typeIdString = type.id.toString(); + if (visitedTypes.has(typeIdString)) { return; } - visitedTypes.push(type); + visitedTypes.set(typeIdString, type); // Reuse visitSymbol to visit the type's symbol, // but be sure to bail on recuring into the type if accept declines the symbol. @@ -134,10 +136,11 @@ namespace ts { if (!symbol) { return; } - if (contains(visitedSymbols, symbol)) { + const symbolIdString = getSymbolId(symbol).toString(); + if (visitedSymbols.has(symbolIdString)) { return; } - visitedSymbols.push(symbol); + visitedSymbols.set(symbolIdString, symbol); if (!accept(symbol)) { return true; } diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 34ae124d636..2182f02afe0 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -2673,8 +2673,10 @@ namespace ts { /* @internal */ export interface SymbolWalker { - walkType(root: Type) : { visitedTypes: Type[], visitedSymbols: Symbol[] }; - walkSymbol(root: Symbol) : { visitedTypes: Type[], visitedSymbols: Symbol[] }; + /** Note: Return values are not ordered. */ + walkType(root: Type) : { visitedTypes: ReadonlyArray, visitedSymbols: ReadonlyArray }; + /** Note: Return values are not ordered. */ + walkSymbol(root: Symbol) : { visitedTypes: ReadonlyArray, visitedSymbols: ReadonlyArray }; } export interface SymbolDisplayBuilder { From 129ace5047d787ab55396680fe23746e78074eaa Mon Sep 17 00:00:00 2001 From: Andrew Casey Date: Tue, 15 Aug 2017 16:06:54 -0700 Subject: [PATCH 109/370] Update SymbolWalker tests ...to consume revised API. --- src/harness/unittests/symbolWalker.ts | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/harness/unittests/symbolWalker.ts b/src/harness/unittests/symbolWalker.ts index 275c37d41f6..8857fb66e0e 100644 --- a/src/harness/unittests/symbolWalker.ts +++ b/src/harness/unittests/symbolWalker.ts @@ -2,7 +2,7 @@ namespace ts { describe("Symbol Walker", () => { - function test(description: string, source: string, verifier: (file: SourceFile, checker: TypeChecker, walker: SymbolWalker) => void) { + function test(description: string, source: string, verifier: (file: SourceFile, checker: TypeChecker) => void) { it(description, () => { let {result} = Harness.Compiler.compileFiles([{ unitName: "main.ts", @@ -10,13 +10,11 @@ namespace ts { }], [], {}, {}, "/"); let file = result.program.getSourceFile("main.ts"); let checker = result.program.getTypeChecker(); - let walker = checker.getSymbolWalker(); - verifier(file, checker, walker); + verifier(file, checker); result = undefined; file = undefined; checker = undefined; - walker = undefined; }); } @@ -26,11 +24,11 @@ interface Bar { y: number; history: Bar[]; } -export default function foo(a: number, b: Bar): void {}`, (file, checker, walker) => { +export default function foo(a: number, b: Bar): void {}`, (file, checker) => { let foundCount = 0; let stdLibRefSymbols = 0; const expectedSymbols = ["default", "a", "b", "Bar", "x", "y", "history"]; - walker.reset(symbol => { + let walker = checker.getSymbolWalker(symbol => { const isStdLibSymbol = forEach(symbol.declarations, d => { return getSourceFileOfNode(d).hasNoDefaultLib; }); @@ -44,7 +42,7 @@ export default function foo(a: number, b: Bar): void {}`, (file, checker, walker }); const symbols = checker.getExportsOfModule(file.symbol); for (const symbol of symbols) { - walker.visitSymbol(symbol); + walker.walkSymbol(symbol); } assert.equal(foundCount, expectedSymbols.length); assert.equal(stdLibRefSymbols, 1); // Expect 1 stdlib entry symbol - the implicit Array referenced by Bar.history From 8cbf42cff534682a4a5f5ec2182152eafb338f76 Mon Sep 17 00:00:00 2001 From: Andrew Casey Date: Wed, 16 Aug 2017 14:54:59 -0700 Subject: [PATCH 110/370] Fix lint errors --- src/compiler/symbolWalker.ts | 10 ++++------ src/compiler/types.ts | 4 ++-- src/harness/unittests/symbolWalker.ts | 2 +- 3 files changed, 7 insertions(+), 9 deletions(-) diff --git a/src/compiler/symbolWalker.ts b/src/compiler/symbolWalker.ts index fda1febfb04..ade9e12d039 100644 --- a/src/compiler/symbolWalker.ts +++ b/src/compiler/symbolWalker.ts @@ -13,19 +13,17 @@ namespace ts { return getSymbolWalker; function getSymbolWalker(accept: (symbol: Symbol) => boolean = () => true): SymbolWalker { - let visitedTypes = createMap(); // Key is id as string - let visitedSymbols = createMap(); // Key is id as string + const visitedTypes = createMap(); // Key is id as string + const visitedSymbols = createMap(); // Key is id as string return { - walkType: type => - { + walkType: type => { visitedTypes.clear(); visitedSymbols.clear(); visitType(type); return { visitedTypes: arrayFrom(visitedTypes.values()), visitedSymbols: arrayFrom(visitedSymbols.values()) }; }, - walkSymbol: symbol => - { + walkSymbol: symbol => { visitedTypes.clear(); visitedSymbols.clear(); visitSymbol(symbol); diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 2182f02afe0..37e12cc9d29 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -2674,9 +2674,9 @@ namespace ts { /* @internal */ export interface SymbolWalker { /** Note: Return values are not ordered. */ - walkType(root: Type) : { visitedTypes: ReadonlyArray, visitedSymbols: ReadonlyArray }; + walkType(root: Type): { visitedTypes: ReadonlyArray, visitedSymbols: ReadonlyArray }; /** Note: Return values are not ordered. */ - walkSymbol(root: Symbol) : { visitedTypes: ReadonlyArray, visitedSymbols: ReadonlyArray }; + walkSymbol(root: Symbol): { visitedTypes: ReadonlyArray, visitedSymbols: ReadonlyArray }; } export interface SymbolDisplayBuilder { diff --git a/src/harness/unittests/symbolWalker.ts b/src/harness/unittests/symbolWalker.ts index 8857fb66e0e..6d38fbb5198 100644 --- a/src/harness/unittests/symbolWalker.ts +++ b/src/harness/unittests/symbolWalker.ts @@ -28,7 +28,7 @@ export default function foo(a: number, b: Bar): void {}`, (file, checker) => { let foundCount = 0; let stdLibRefSymbols = 0; const expectedSymbols = ["default", "a", "b", "Bar", "x", "y", "history"]; - let walker = checker.getSymbolWalker(symbol => { + const walker = checker.getSymbolWalker(symbol => { const isStdLibSymbol = forEach(symbol.declarations, d => { return getSourceFileOfNode(d).hasNoDefaultLib; }); From d7ace2086fc9a2e46d5381444c421e861ff105b3 Mon Sep 17 00:00:00 2001 From: Andrew Casey Date: Thu, 17 Aug 2017 13:17:51 -0700 Subject: [PATCH 111/370] Fix copy-paste error --- src/compiler/symbolWalker.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/compiler/symbolWalker.ts b/src/compiler/symbolWalker.ts index ade9e12d039..39f7f131c37 100644 --- a/src/compiler/symbolWalker.ts +++ b/src/compiler/symbolWalker.ts @@ -1,6 +1,5 @@ /** @internal */ namespace ts { - /** @internal */ export function createGetSymbolWalker( getRestTypeOfSignature: (sig: Signature) => Type, getReturnTypeOfSignature: (sig: Signature) => Type, @@ -114,7 +113,7 @@ namespace ts { function visitObjectType(type: ObjectType): void { const stringIndexType = getIndexTypeOfStructuredType(type, IndexKind.String); visitType(stringIndexType); - const numberIndexType = getIndexTypeOfStructuredType(type, IndexKind.String); + const numberIndexType = getIndexTypeOfStructuredType(type, IndexKind.Number); visitType(numberIndexType); // The two checks above *should* have already resolved the type (if needed), so this should be cached From 1a20b6a7c337d62a42d22e9e050bf64dc78f6679 Mon Sep 17 00:00:00 2001 From: Andrew Casey Date: Thu, 17 Aug 2017 13:23:11 -0700 Subject: [PATCH 112/370] Add support for walking IndexTypes, IndexedAccessTypes, and MappedTypes. --- src/compiler/symbolWalker.ts | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/src/compiler/symbolWalker.ts b/src/compiler/symbolWalker.ts index 39f7f131c37..7f1745b8742 100644 --- a/src/compiler/symbolWalker.ts +++ b/src/compiler/symbolWalker.ts @@ -53,6 +53,9 @@ namespace ts { if (objectFlags & ObjectFlags.Reference) { visitTypeReference(type as TypeReference); } + if (objectFlags & ObjectFlags.Mapped) { + visitMappedType(type as MappedType); + } if (objectFlags & (ObjectFlags.Class | ObjectFlags.Interface)) { visitInterfaceType(type as InterfaceType); } @@ -66,6 +69,12 @@ namespace ts { if (type.flags & TypeFlags.UnionOrIntersection) { visitUnionOrIntersectionType(type as UnionOrIntersectionType); } + if (type.flags & TypeFlags.Index) { + visitIndexType(type as IndexType); + } + if (type.flags & TypeFlags.IndexedAccess) { + visitIndexedAccessType(type as IndexedAccessType); + } } function visitTypeList(types: Type[]): void { @@ -90,6 +99,23 @@ namespace ts { visitTypeList(type.types); } + function visitIndexType(type: IndexType): void { + visitType(type.type); + } + + function visitIndexedAccessType(type: IndexedAccessType): void { + visitType(type.objectType); + visitType(type.indexType); + visitType(type.constraint); + } + + function visitMappedType(type: MappedType): void { + visitType(type.typeParameter); + visitType(type.constraintType); + visitType(type.templateType); + visitType(type.modifiersType); + } + function visitSignature(signature: Signature): void { if (signature.typePredicate) { visitType(signature.typePredicate.type); From e02da343db817b148d2b533f6ec392b69f297a1b Mon Sep 17 00:00:00 2001 From: Andrew Casey Date: Thu, 17 Aug 2017 15:44:06 -0700 Subject: [PATCH 113/370] Retrieve type parameter constraint using getConstraintFromTypeParameter --- src/compiler/checker.ts | 2 +- src/compiler/symbolWalker.ts | 5 +++-- src/compiler/types.ts | 1 + 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index d69c6cdebda..4781f4bc183 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -205,7 +205,7 @@ namespace ts { getEmitResolver, getExportsOfModule: getExportsOfModuleAsArray, getExportsAndPropertiesOfModule, - getSymbolWalker: createGetSymbolWalker(getRestTypeOfSignature, getReturnTypeOfSignature, getBaseTypes, resolveStructuredTypeMembers, getTypeOfSymbol, getResolvedSymbol, getIndexTypeOfStructuredType), + getSymbolWalker: createGetSymbolWalker(getRestTypeOfSignature, getReturnTypeOfSignature, getBaseTypes, resolveStructuredTypeMembers, getTypeOfSymbol, getResolvedSymbol, getIndexTypeOfStructuredType, getConstraintFromTypeParameter), getAmbientModules, getAllAttributesTypeFromJsxOpeningLikeElement: node => { node = getParseTreeNode(node, isJsxOpeningLikeElement); diff --git a/src/compiler/symbolWalker.ts b/src/compiler/symbolWalker.ts index 7f1745b8742..6567870c961 100644 --- a/src/compiler/symbolWalker.ts +++ b/src/compiler/symbolWalker.ts @@ -7,7 +7,8 @@ namespace ts { resolveStructuredTypeMembers: (type: ObjectType) => ResolvedType, getTypeOfSymbol: (sym: Symbol) => Type, getResolvedSymbol: (node: Node) => Symbol, - getIndexTypeOfStructuredType: (type: Type, kind: IndexKind) => Type) { + getIndexTypeOfStructuredType: (type: Type, kind: IndexKind) => Type, + getConstraintFromTypeParameter: (typeParameter: TypeParameter) => Type) { return getSymbolWalker; @@ -92,7 +93,7 @@ namespace ts { } function visitTypeParameter(type: TypeParameter): void { - visitType(type.constraint); + visitType(getConstraintFromTypeParameter(type)); } function visitUnionOrIntersectionType(type: UnionOrIntersectionType): void { diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 37e12cc9d29..26bf5e1a91f 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -3377,6 +3377,7 @@ namespace ts { // Type parameters (TypeFlags.TypeParameter) export interface TypeParameter extends TypeVariable { + /** Retrieve using getConstraintFromTypeParameter */ constraint: Type; // Constraint default?: Type; /* @internal */ From 89447748d500e66846f9f4068ada12424da0ce74 Mon Sep 17 00:00:00 2001 From: Andrew Casey Date: Tue, 22 Aug 2017 10:47:37 -0700 Subject: [PATCH 114/370] Reuse exiting getFirstIdentifier function --- src/compiler/checker.ts | 2 +- src/compiler/symbolWalker.ts | 14 +++----------- 2 files changed, 4 insertions(+), 12 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 4781f4bc183..cff540c3f06 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -205,7 +205,7 @@ namespace ts { getEmitResolver, getExportsOfModule: getExportsOfModuleAsArray, getExportsAndPropertiesOfModule, - getSymbolWalker: createGetSymbolWalker(getRestTypeOfSignature, getReturnTypeOfSignature, getBaseTypes, resolveStructuredTypeMembers, getTypeOfSymbol, getResolvedSymbol, getIndexTypeOfStructuredType, getConstraintFromTypeParameter), + getSymbolWalker: createGetSymbolWalker(getRestTypeOfSignature, getReturnTypeOfSignature, getBaseTypes, resolveStructuredTypeMembers, getTypeOfSymbol, getResolvedSymbol, getIndexTypeOfStructuredType, getConstraintFromTypeParameter, getFirstIdentifier), getAmbientModules, getAllAttributesTypeFromJsxOpeningLikeElement: node => { node = getParseTreeNode(node, isJsxOpeningLikeElement); diff --git a/src/compiler/symbolWalker.ts b/src/compiler/symbolWalker.ts index 6567870c961..e20ef9f9d98 100644 --- a/src/compiler/symbolWalker.ts +++ b/src/compiler/symbolWalker.ts @@ -8,7 +8,8 @@ namespace ts { getTypeOfSymbol: (sym: Symbol) => Type, getResolvedSymbol: (node: Node) => Symbol, getIndexTypeOfStructuredType: (type: Type, kind: IndexKind) => Type, - getConstraintFromTypeParameter: (typeParameter: TypeParameter) => Type) { + getConstraintFromTypeParameter: (typeParameter: TypeParameter) => Type, + getFirstIdentifier: (node: EntityNameOrEntityNameExpression) => Identifier) { return getSymbolWalker; @@ -180,20 +181,11 @@ namespace ts { // query node on any of the symbol's declarations and get symbols there if ((d as any).type && (d as any).type.kind === SyntaxKind.TypeQuery) { const query = (d as any).type as TypeQueryNode; - const entity = leftmostSymbol(query.exprName); + const entity = getResolvedSymbol(getFirstIdentifier(query.exprName)); visitSymbol(entity); } }); } } - - function leftmostSymbol(expr: QualifiedName | Identifier): Symbol { - if (expr.kind === SyntaxKind.Identifier) { - return getResolvedSymbol(expr as Identifier); - } - else { - return leftmostSymbol((expr as QualifiedName).left); - } - } } } \ No newline at end of file From 509d347ab9c922daec779ef6c7c64b841d2e3201 Mon Sep 17 00:00:00 2001 From: uniqueiniquity Date: Tue, 22 Aug 2017 12:59:47 -0700 Subject: [PATCH 115/370] Region now starts at beginning of comment, and reviewer edits --- src/services/outliningElementsCollector.ts | 42 ++++++++----------- .../fourslash/getOutliningSpansForRegions.ts | 2 +- ...getOutliningSpansForUnbalancedEndRegion.ts | 10 +++++ .../getOutliningSpansForUnbalancedRegion.ts | 11 +++++ 4 files changed, 39 insertions(+), 26 deletions(-) create mode 100644 tests/cases/fourslash/getOutliningSpansForUnbalancedEndRegion.ts create mode 100644 tests/cases/fourslash/getOutliningSpansForUnbalancedRegion.ts diff --git a/src/services/outliningElementsCollector.ts b/src/services/outliningElementsCollector.ts index 59f8e9f5549..748085bd041 100644 --- a/src/services/outliningElementsCollector.ts +++ b/src/services/outliningElementsCollector.ts @@ -2,14 +2,14 @@ namespace ts.OutliningElementsCollector { const collapseText = "..."; const maxDepth = 20; + const regionText = "#region"; + const regionStart = new RegExp("^\\s*//\\s*#region(\\s+.*)?$"); + const regionEnd = new RegExp("^\\s*//\\s*#endregion(\\s|$)"); export function collectElements(sourceFile: SourceFile, cancellationToken: CancellationToken): OutliningSpan[] { const elements: OutliningSpan[] = []; let depth = 0; const regions: RegionRange[] = []; - const regionText = "#region"; - const regionStart = new RegExp("^\\s*//\\s*#region(\\s+.*)?$", "gm"); - const regionEnd = new RegExp("^\\s*//\\s*#endregion(\\s|$)", "gm"); walk(sourceFile); gatherRegions(); @@ -42,9 +42,10 @@ namespace ts.OutliningElementsCollector { function addOutliningSpanRegions(regionSpan: RegionRange) { if (regionSpan) { + const textSpan = createTextSpanFromBounds(regionSpan.pos, regionSpan.end); const span: OutliningSpan = { - textSpan: createTextSpanFromBounds(regionSpan.pos, regionSpan.end), - hintSpan: createTextSpanFromBounds(regionSpan.pos, regionSpan.end), + textSpan, + hintSpan: textSpan, bannerText: regionSpan.name, autoCollapse: false, }; @@ -106,29 +107,18 @@ namespace ts.OutliningElementsCollector { return isFunctionBlock(node) && node.parent.kind !== SyntaxKind.ArrowFunction; } - function isRegionStart(start: number, end: number) { + function getRegionName(start: number, end: number) { if (!ts.formatting.getRangeOfEnclosingComment(sourceFile, start, /*onlyMultiLine*/ true)) { const comment = sourceFile.text.substring(start, end); const result = comment.match(regionStart); if (result && result.length > 0) { - const sections = result[0].split(" ").filter(function (s) { return s !== ""; }); - - if (sections[0] === "//") { - if (sections.length > 2) { - return result[0].substring(result[0].indexOf(sections[2])); - } - else { - return regionText; - } + const label = result.pop(); + if (label) { + return label.trim(); } else { - if (sections.length > 1) { - return result[0].substring(result[0].indexOf(sections[1])); - } - else { - return regionText; - } + return regionText; } } } @@ -146,13 +136,15 @@ namespace ts.OutliningElementsCollector { function gatherRegions(): void { const lineStarts = sourceFile.getLineStarts(); - for (const currentLineStart of lineStarts) { - const lineEnd = sourceFile.getLineEndOfPosition(currentLineStart); + for (let i = 0; i < lineStarts.length; i++) { + const currentLineStart = lineStarts[i]; + const lineEnd = lineStarts[i + 1] - 1 || sourceFile.getEnd(); - const name = isRegionStart(currentLineStart, lineEnd); + const name = getRegionName(currentLineStart, lineEnd); if (name) { + const start = sourceFile.getFullText().indexOf("//", currentLineStart); const region: RegionRange = { - pos: currentLineStart, + pos: start, end: lineEnd, name, }; diff --git a/tests/cases/fourslash/getOutliningSpansForRegions.ts b/tests/cases/fourslash/getOutliningSpansForRegions.ts index 73202fb9c9c..80e1c3113cf 100644 --- a/tests/cases/fourslash/getOutliningSpansForRegions.ts +++ b/tests/cases/fourslash/getOutliningSpansForRegions.ts @@ -11,7 +11,7 @@ ////// #endregion|] //// ////// region with extra whitespace in all valid locations -////[| // #region label2 label3 +//// [|// #region label2 label3 //// //// // #endregion|] //// diff --git a/tests/cases/fourslash/getOutliningSpansForUnbalancedEndRegion.ts b/tests/cases/fourslash/getOutliningSpansForUnbalancedEndRegion.ts new file mode 100644 index 00000000000..c15e23eba75 --- /dev/null +++ b/tests/cases/fourslash/getOutliningSpansForUnbalancedEndRegion.ts @@ -0,0 +1,10 @@ +/// + +////// bottom-heavy region balance +////[|// #region matched +//// +////// #endregion matched|] +//// +////// #endregion unmatched + +verify.outliningSpansInCurrentFile(test.ranges()); \ No newline at end of file diff --git a/tests/cases/fourslash/getOutliningSpansForUnbalancedRegion.ts b/tests/cases/fourslash/getOutliningSpansForUnbalancedRegion.ts new file mode 100644 index 00000000000..f50aae713a5 --- /dev/null +++ b/tests/cases/fourslash/getOutliningSpansForUnbalancedRegion.ts @@ -0,0 +1,11 @@ +/// + +////// top-heavy region balance +////// #region unmatched +//// +////[|// #region matched +//// +////// #endregion matched|] + +debugger; +verify.outliningSpansInCurrentFile(test.ranges()); \ No newline at end of file From bdc2aa8afb7b423e23ee2f1ed6507c0deb1c4e33 Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Tue, 22 Aug 2017 13:47:53 -0700 Subject: [PATCH 116/370] Allow use before declaration for export= assignments (#17967) --- src/compiler/checker.ts | 7 ++++++- .../exportAssignmentOfGenericType1.errors.txt | 17 --------------- .../reference/exportImport.errors.txt | 21 ------------------- ...eExportAssignmentOfGenericClass.errors.txt | 20 ------------------ 4 files changed, 6 insertions(+), 59 deletions(-) delete mode 100644 tests/baselines/reference/exportAssignmentOfGenericType1.errors.txt delete mode 100644 tests/baselines/reference/exportImport.errors.txt delete mode 100644 tests/baselines/reference/privacyCheckExternalModuleExportAssignmentOfGenericClass.errors.txt diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index d2d3697f175..82521698fa9 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -794,12 +794,17 @@ namespace ts { // 2. inside a function // 3. inside an instance property initializer, a reference to a non-instance property // 4. inside a static property initializer, a reference to a static method in the same class + // 5. inside a TS export= declaration (since we will move the export statement during emit to avoid TDZ) // or if usage is in a type context: // 1. inside a type query (typeof in type position) - if (usage.parent.kind === SyntaxKind.ExportSpecifier) { + if (usage.parent.kind === SyntaxKind.ExportSpecifier || (usage.parent.kind === SyntaxKind.ExportAssignment && (usage.parent as ExportAssignment).isExportEquals)) { // export specifiers do not use the variable, they only make it available for use return true; } + // When resolving symbols for exports, the `usage` location passed in can be the export site directly + if (usage.kind === SyntaxKind.ExportAssignment && (usage as ExportAssignment).isExportEquals) { + return true; + } const container = getEnclosingBlockScopeContainer(declaration); return isInTypeQuery(usage) || isUsedInFunctionOrInstanceProperty(usage, declaration, container); diff --git a/tests/baselines/reference/exportAssignmentOfGenericType1.errors.txt b/tests/baselines/reference/exportAssignmentOfGenericType1.errors.txt deleted file mode 100644 index e484d4096bb..00000000000 --- a/tests/baselines/reference/exportAssignmentOfGenericType1.errors.txt +++ /dev/null @@ -1,17 +0,0 @@ -tests/cases/compiler/exportAssignmentOfGenericType1_0.ts(1,10): error TS2449: Class 'T' used before its declaration. - - -==== tests/cases/compiler/exportAssignmentOfGenericType1_1.ts (0 errors) ==== - /// - import q = require("exportAssignmentOfGenericType1_0"); - - class M extends q { } - var m: M; - var r: string = m.foo; - -==== tests/cases/compiler/exportAssignmentOfGenericType1_0.ts (1 errors) ==== - export = T; - ~ -!!! error TS2449: Class 'T' used before its declaration. - class T { foo: X; } - \ No newline at end of file diff --git a/tests/baselines/reference/exportImport.errors.txt b/tests/baselines/reference/exportImport.errors.txt deleted file mode 100644 index 4f397d54a55..00000000000 --- a/tests/baselines/reference/exportImport.errors.txt +++ /dev/null @@ -1,21 +0,0 @@ -tests/cases/compiler/w1.ts(1,1): error TS2449: Class 'Widget1' used before its declaration. -tests/cases/compiler/w1.ts(1,10): error TS2449: Class 'Widget1' used before its declaration. - - -==== tests/cases/compiler/consumer.ts (0 errors) ==== - import e = require('./exporter'); - - export function w(): e.w { // Should be OK - return new e.w(); - } -==== tests/cases/compiler/w1.ts (2 errors) ==== - export = Widget1 - ~~~~~~~~~~~~~~~~ -!!! error TS2449: Class 'Widget1' used before its declaration. - ~~~~~~~ -!!! error TS2449: Class 'Widget1' used before its declaration. - class Widget1 { name = 'one'; } - -==== tests/cases/compiler/exporter.ts (0 errors) ==== - export import w = require('./w1'); - \ No newline at end of file diff --git a/tests/baselines/reference/privacyCheckExternalModuleExportAssignmentOfGenericClass.errors.txt b/tests/baselines/reference/privacyCheckExternalModuleExportAssignmentOfGenericClass.errors.txt deleted file mode 100644 index 2945950068a..00000000000 --- a/tests/baselines/reference/privacyCheckExternalModuleExportAssignmentOfGenericClass.errors.txt +++ /dev/null @@ -1,20 +0,0 @@ -tests/cases/compiler/privacyCheckExternalModuleExportAssignmentOfGenericClass_0.ts(1,1): error TS2449: Class 'Foo' used before its declaration. -tests/cases/compiler/privacyCheckExternalModuleExportAssignmentOfGenericClass_0.ts(1,10): error TS2449: Class 'Foo' used before its declaration. - - -==== tests/cases/compiler/privacyCheckExternalModuleExportAssignmentOfGenericClass_1.ts (0 errors) ==== - import Foo = require("./privacyCheckExternalModuleExportAssignmentOfGenericClass_0"); - export = Bar; - interface Bar { - foo: Foo; - } -==== tests/cases/compiler/privacyCheckExternalModuleExportAssignmentOfGenericClass_0.ts (2 errors) ==== - export = Foo; - ~~~~~~~~~~~~~ -!!! error TS2449: Class 'Foo' used before its declaration. - ~~~ -!!! error TS2449: Class 'Foo' used before its declaration. - class Foo { - constructor(public a: A) { } - } - \ No newline at end of file From c3f2648ba4d851ed9ab2dec9ded1ced7fbf144a9 Mon Sep 17 00:00:00 2001 From: uniqueiniquity Date: Tue, 22 Aug 2017 13:59:02 -0700 Subject: [PATCH 117/370] Edits from aozgaa review and simplify regex --- src/services/outliningElementsCollector.ts | 22 +++++++++---------- .../fourslash/getOutliningSpansForRegions.ts | 4 ++-- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/services/outliningElementsCollector.ts b/src/services/outliningElementsCollector.ts index 748085bd041..d4f70d52eda 100644 --- a/src/services/outliningElementsCollector.ts +++ b/src/services/outliningElementsCollector.ts @@ -2,9 +2,9 @@ namespace ts.OutliningElementsCollector { const collapseText = "..."; const maxDepth = 20; - const regionText = "#region"; - const regionStart = new RegExp("^\\s*//\\s*#region(\\s+.*)?$"); - const regionEnd = new RegExp("^\\s*//\\s*#endregion(\\s|$)"); + const defaultLabel = "#region"; + const regionStart = new RegExp("^//\\s*#region(\\s+.*)?$"); + const regionEnd = new RegExp("^//\\s*#endregion(\\s|$)"); export function collectElements(sourceFile: SourceFile, cancellationToken: CancellationToken): OutliningSpan[] { const elements: OutliningSpan[] = []; @@ -42,7 +42,7 @@ namespace ts.OutliningElementsCollector { function addOutliningSpanRegions(regionSpan: RegionRange) { if (regionSpan) { - const textSpan = createTextSpanFromBounds(regionSpan.pos, regionSpan.end); + const textSpan = createTextSpanFromRange(regionSpan); const span: OutliningSpan = { textSpan, hintSpan: textSpan, @@ -108,8 +108,8 @@ namespace ts.OutliningElementsCollector { } function getRegionName(start: number, end: number) { - if (!ts.formatting.getRangeOfEnclosingComment(sourceFile, start, /*onlyMultiLine*/ true)) { - const comment = sourceFile.text.substring(start, end); + if (!isInComment(sourceFile, start)) { + const comment = sourceFile.text.substring(start, end).trim(); const result = comment.match(regionStart); if (result && result.length > 0) { @@ -118,7 +118,7 @@ namespace ts.OutliningElementsCollector { return label.trim(); } else { - return regionText; + return defaultLabel; } } } @@ -126,11 +126,11 @@ namespace ts.OutliningElementsCollector { } function isRegionEnd(start: number, end: number) { - if (!ts.formatting.getRangeOfEnclosingComment(sourceFile, start, /*onlyMultiLine*/ true)) { - const comment = sourceFile.text.substring(start, end); - return comment.match(regionEnd); + if (!isInComment(sourceFile, start)) { + const comment = sourceFile.text.substring(start, end).trim(); + return !!comment.match(regionEnd); } - return undefined; + return false; } function gatherRegions(): void { diff --git a/tests/cases/fourslash/getOutliningSpansForRegions.ts b/tests/cases/fourslash/getOutliningSpansForRegions.ts index 80e1c3113cf..151526c6b99 100644 --- a/tests/cases/fourslash/getOutliningSpansForRegions.ts +++ b/tests/cases/fourslash/getOutliningSpansForRegions.ts @@ -1,6 +1,6 @@ /// -////// basic region +////// region without label ////[|// #region //// ////// #endregion|] @@ -29,7 +29,7 @@ //// ////// #endregion outer|] //// -////// region delimiters not valid when preceding text on line +////// region delimiters not valid when there is preceding text on line //// test // #region invalid1 //// ////test // #endregion From 009d9b4f22b32d6cb3c1da4d8836c0972316e5c0 Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Tue, 22 Aug 2017 14:13:56 -0700 Subject: [PATCH 118/370] For JSX Attributes, map over unions of props for contextual types (#17790) * For JSX Attributes, allow attributes to fulfill the member of any union member; rather than all of them * Use cached way of getting partial union members * Reuse methodology used for object literals for jsx attributes * Inline assignment * Rename type --- src/compiler/checker.ts | 6 +- .../tsxInferenceShouldNotYieldAnyOnUnions.js | 40 ++++++ ...InferenceShouldNotYieldAnyOnUnions.symbols | 90 +++++++++++++ ...sxInferenceShouldNotYieldAnyOnUnions.types | 118 ++++++++++++++++++ .../tsxInferenceShouldNotYieldAnyOnUnions.tsx | 29 +++++ 5 files changed, 280 insertions(+), 3 deletions(-) create mode 100644 tests/baselines/reference/tsxInferenceShouldNotYieldAnyOnUnions.js create mode 100644 tests/baselines/reference/tsxInferenceShouldNotYieldAnyOnUnions.symbols create mode 100644 tests/baselines/reference/tsxInferenceShouldNotYieldAnyOnUnions.types create mode 100644 tests/cases/compiler/tsxInferenceShouldNotYieldAnyOnUnions.tsx diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 82521698fa9..3fdee5e9a10 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -13121,12 +13121,12 @@ namespace ts { if (isJsxAttribute(node.parent)) { // JSX expression is in JSX attribute - return getTypeOfPropertyOfType(attributesType, node.parent.name.escapedText); + return getTypeOfPropertyOfContextualType(attributesType, node.parent.name.escapedText); } else if (node.parent.kind === SyntaxKind.JsxElement) { // JSX expression is in children of JSX Element, we will look for an "children" atttribute (we get the name from JSX.ElementAttributesProperty) const jsxChildrenPropertyName = getJsxElementChildrenPropertyname(); - return jsxChildrenPropertyName && jsxChildrenPropertyName !== "" ? getTypeOfPropertyOfType(attributesType, jsxChildrenPropertyName) : anyType; + return jsxChildrenPropertyName && jsxChildrenPropertyName !== "" ? getTypeOfPropertyOfContextualType(attributesType, jsxChildrenPropertyName) : anyType; } else { // JSX expression is in JSX spread attribute @@ -13144,7 +13144,7 @@ namespace ts { if (!attributesType || isTypeAny(attributesType)) { return undefined; } - return getTypeOfPropertyOfType(attributesType, attribute.name.escapedText); + return getTypeOfPropertyOfContextualType(attributesType, attribute.name.escapedText); } else { return attributesType; diff --git a/tests/baselines/reference/tsxInferenceShouldNotYieldAnyOnUnions.js b/tests/baselines/reference/tsxInferenceShouldNotYieldAnyOnUnions.js new file mode 100644 index 00000000000..0459b56d874 --- /dev/null +++ b/tests/baselines/reference/tsxInferenceShouldNotYieldAnyOnUnions.js @@ -0,0 +1,40 @@ +//// [index.tsx] +namespace JSX { + export interface Element {} +} + +type Props = PropsBase | PropsWithConvert; + +interface PropsBase { + data: T; +} + +interface PropsWithConvert extends PropsBase { + convert: (t: T) => string; +} + +function ShouldInferFromData(props: Props): JSX.Element { + return
; +} + +// Sanity check: function call equivalent versions work fine +ShouldInferFromData({ data: "1" }); +ShouldInferFromData({ data: "1", convert: n => "" + n }); +ShouldInferFromData({ data: 2, convert: n => "" + n }); + + +const f1 = ; +const f2 = "" + n} />; +const f3 = "" + n} />; + +//// [index.jsx] +function ShouldInferFromData(props) { + return
; +} +// Sanity check: function call equivalent versions work fine +ShouldInferFromData({ data: "1" }); +ShouldInferFromData({ data: "1", convert: function (n) { return "" + n; } }); +ShouldInferFromData({ data: 2, convert: function (n) { return "" + n; } }); +var f1 = ; +var f2 = ; +var f3 = ; diff --git a/tests/baselines/reference/tsxInferenceShouldNotYieldAnyOnUnions.symbols b/tests/baselines/reference/tsxInferenceShouldNotYieldAnyOnUnions.symbols new file mode 100644 index 00000000000..b6163a36df6 --- /dev/null +++ b/tests/baselines/reference/tsxInferenceShouldNotYieldAnyOnUnions.symbols @@ -0,0 +1,90 @@ +=== tests/cases/compiler/index.tsx === +namespace JSX { +>JSX : Symbol(JSX, Decl(index.tsx, 0, 0)) + + export interface Element {} +>Element : Symbol(Element, Decl(index.tsx, 0, 15)) +} + +type Props = PropsBase | PropsWithConvert; +>Props : Symbol(Props, Decl(index.tsx, 2, 1)) +>T : Symbol(T, Decl(index.tsx, 4, 11)) +>PropsBase : Symbol(PropsBase, Decl(index.tsx, 4, 56)) +>PropsWithConvert : Symbol(PropsWithConvert, Decl(index.tsx, 8, 1)) +>T : Symbol(T, Decl(index.tsx, 4, 11)) + +interface PropsBase { +>PropsBase : Symbol(PropsBase, Decl(index.tsx, 4, 56)) +>T : Symbol(T, Decl(index.tsx, 6, 20)) + + data: T; +>data : Symbol(PropsBase.data, Decl(index.tsx, 6, 24)) +>T : Symbol(T, Decl(index.tsx, 6, 20)) +} + +interface PropsWithConvert extends PropsBase { +>PropsWithConvert : Symbol(PropsWithConvert, Decl(index.tsx, 8, 1)) +>T : Symbol(T, Decl(index.tsx, 10, 27)) +>PropsBase : Symbol(PropsBase, Decl(index.tsx, 4, 56)) +>T : Symbol(T, Decl(index.tsx, 10, 27)) + + convert: (t: T) => string; +>convert : Symbol(PropsWithConvert.convert, Decl(index.tsx, 10, 52)) +>t : Symbol(t, Decl(index.tsx, 11, 14)) +>T : Symbol(T, Decl(index.tsx, 10, 27)) +} + +function ShouldInferFromData(props: Props): JSX.Element { +>ShouldInferFromData : Symbol(ShouldInferFromData, Decl(index.tsx, 12, 1)) +>T : Symbol(T, Decl(index.tsx, 14, 29)) +>props : Symbol(props, Decl(index.tsx, 14, 32)) +>Props : Symbol(Props, Decl(index.tsx, 2, 1)) +>T : Symbol(T, Decl(index.tsx, 14, 29)) +>JSX : Symbol(JSX, Decl(index.tsx, 0, 0)) +>Element : Symbol(JSX.Element, Decl(index.tsx, 0, 15)) + + return
; +>div : Symbol(unknown) +} + +// Sanity check: function call equivalent versions work fine +ShouldInferFromData({ data: "1" }); +>ShouldInferFromData : Symbol(ShouldInferFromData, Decl(index.tsx, 12, 1)) +>data : Symbol(data, Decl(index.tsx, 19, 21)) + +ShouldInferFromData({ data: "1", convert: n => "" + n }); +>ShouldInferFromData : Symbol(ShouldInferFromData, Decl(index.tsx, 12, 1)) +>data : Symbol(data, Decl(index.tsx, 20, 21)) +>convert : Symbol(convert, Decl(index.tsx, 20, 32)) +>n : Symbol(n, Decl(index.tsx, 20, 41)) +>n : Symbol(n, Decl(index.tsx, 20, 41)) + +ShouldInferFromData({ data: 2, convert: n => "" + n }); +>ShouldInferFromData : Symbol(ShouldInferFromData, Decl(index.tsx, 12, 1)) +>data : Symbol(data, Decl(index.tsx, 21, 21)) +>convert : Symbol(convert, Decl(index.tsx, 21, 30)) +>n : Symbol(n, Decl(index.tsx, 21, 39)) +>n : Symbol(n, Decl(index.tsx, 21, 39)) + + +const f1 = ; +>f1 : Symbol(f1, Decl(index.tsx, 24, 5)) +>ShouldInferFromData : Symbol(ShouldInferFromData, Decl(index.tsx, 12, 1)) +>data : Symbol(data, Decl(index.tsx, 24, 31)) + +const f2 = "" + n} />; +>f2 : Symbol(f2, Decl(index.tsx, 25, 5)) +>ShouldInferFromData : Symbol(ShouldInferFromData, Decl(index.tsx, 12, 1)) +>data : Symbol(data, Decl(index.tsx, 25, 31)) +>convert : Symbol(convert, Decl(index.tsx, 25, 42)) +>n : Symbol(n, Decl(index.tsx, 25, 52)) +>n : Symbol(n, Decl(index.tsx, 25, 52)) + +const f3 = "" + n} />; +>f3 : Symbol(f3, Decl(index.tsx, 26, 5)) +>ShouldInferFromData : Symbol(ShouldInferFromData, Decl(index.tsx, 12, 1)) +>data : Symbol(data, Decl(index.tsx, 26, 31)) +>convert : Symbol(convert, Decl(index.tsx, 26, 40)) +>n : Symbol(n, Decl(index.tsx, 26, 50)) +>n : Symbol(n, Decl(index.tsx, 26, 50)) + diff --git a/tests/baselines/reference/tsxInferenceShouldNotYieldAnyOnUnions.types b/tests/baselines/reference/tsxInferenceShouldNotYieldAnyOnUnions.types new file mode 100644 index 00000000000..68ad55854a7 --- /dev/null +++ b/tests/baselines/reference/tsxInferenceShouldNotYieldAnyOnUnions.types @@ -0,0 +1,118 @@ +=== tests/cases/compiler/index.tsx === +namespace JSX { +>JSX : any + + export interface Element {} +>Element : Element +} + +type Props = PropsBase | PropsWithConvert; +>Props : Props +>T : T +>PropsBase : PropsBase +>PropsWithConvert : PropsWithConvert +>T : T + +interface PropsBase { +>PropsBase : PropsBase +>T : T + + data: T; +>data : T +>T : T +} + +interface PropsWithConvert extends PropsBase { +>PropsWithConvert : PropsWithConvert +>T : T +>PropsBase : PropsBase +>T : T + + convert: (t: T) => string; +>convert : (t: T) => string +>t : T +>T : T +} + +function ShouldInferFromData(props: Props): JSX.Element { +>ShouldInferFromData : (props: Props) => JSX.Element +>T : T +>props : Props +>Props : Props +>T : T +>JSX : any +>Element : JSX.Element + + return
; +>
: JSX.Element +>div : any +} + +// Sanity check: function call equivalent versions work fine +ShouldInferFromData({ data: "1" }); +>ShouldInferFromData({ data: "1" }) : JSX.Element +>ShouldInferFromData : (props: Props) => JSX.Element +>{ data: "1" } : { data: string; } +>data : string +>"1" : "1" + +ShouldInferFromData({ data: "1", convert: n => "" + n }); +>ShouldInferFromData({ data: "1", convert: n => "" + n }) : JSX.Element +>ShouldInferFromData : (props: Props) => JSX.Element +>{ data: "1", convert: n => "" + n } : { data: string; convert: (n: string) => string; } +>data : string +>"1" : "1" +>convert : (n: string) => string +>n => "" + n : (n: string) => string +>n : string +>"" + n : string +>"" : "" +>n : string + +ShouldInferFromData({ data: 2, convert: n => "" + n }); +>ShouldInferFromData({ data: 2, convert: n => "" + n }) : JSX.Element +>ShouldInferFromData : (props: Props) => JSX.Element +>{ data: 2, convert: n => "" + n } : { data: number; convert: (n: number) => string; } +>data : number +>2 : 2 +>convert : (n: number) => string +>n => "" + n : (n: number) => string +>n : number +>"" + n : string +>"" : "" +>n : number + + +const f1 = ; +>f1 : JSX.Element +> : JSX.Element +>ShouldInferFromData : (props: Props) => JSX.Element +>data : string +>"1" : "1" + +const f2 = "" + n} />; +>f2 : JSX.Element +> "" + n} /> : JSX.Element +>ShouldInferFromData : (props: Props) => JSX.Element +>data : string +>"1" : "1" +>convert : (n: "1") => string +>n => "" + n : (n: "1") => string +>n : "1" +>"" + n : string +>"" : "" +>n : "1" + +const f3 = "" + n} />; +>f3 : JSX.Element +> "" + n} /> : JSX.Element +>ShouldInferFromData : (props: Props) => JSX.Element +>data : number +>2 : 2 +>convert : (n: 2) => string +>n => "" + n : (n: 2) => string +>n : 2 +>"" + n : string +>"" : "" +>n : 2 + diff --git a/tests/cases/compiler/tsxInferenceShouldNotYieldAnyOnUnions.tsx b/tests/cases/compiler/tsxInferenceShouldNotYieldAnyOnUnions.tsx new file mode 100644 index 00000000000..a0d4f5984e4 --- /dev/null +++ b/tests/cases/compiler/tsxInferenceShouldNotYieldAnyOnUnions.tsx @@ -0,0 +1,29 @@ +// @jsx: preserve +// @filename: index.tsx +namespace JSX { + export interface Element {} +} + +type Props = PropsBase | PropsWithConvert; + +interface PropsBase { + data: T; +} + +interface PropsWithConvert extends PropsBase { + convert: (t: T) => string; +} + +function ShouldInferFromData(props: Props): JSX.Element { + return
; +} + +// Sanity check: function call equivalent versions work fine +ShouldInferFromData({ data: "1" }); +ShouldInferFromData({ data: "1", convert: n => "" + n }); +ShouldInferFromData({ data: 2, convert: n => "" + n }); + + +const f1 = ; +const f2 = "" + n} />; +const f3 = "" + n} />; \ No newline at end of file From 8d44e48dd0f63a2f48bd5045d4833e709c299a3b Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Tue, 22 Aug 2017 15:39:10 -0700 Subject: [PATCH 119/370] Fix instrumenter target + deprecation warning (#17973) --- Gulpfile.ts | 6 +++--- Jakefile.js | 2 +- src/harness/instrumenter.ts | 8 +++++--- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/Gulpfile.ts b/Gulpfile.ts index 645443370eb..4a03557270f 100644 --- a/Gulpfile.ts +++ b/Gulpfile.ts @@ -978,7 +978,7 @@ const instrumenterPath = path.join(harnessDirectory, "instrumenter.ts"); const instrumenterJsPath = path.join(builtLocalDirectory, "instrumenter.js"); gulp.task(instrumenterJsPath, /*help*/ false, [servicesFile], () => { const settings: tsc.Settings = getCompilerSettings({ - outFile: instrumenterJsPath, + module: "commonjs", target: "es5", lib: [ "es6", @@ -990,8 +990,8 @@ gulp.task(instrumenterJsPath, /*help*/ false, [servicesFile], () => { .pipe(newer(instrumenterJsPath)) .pipe(sourcemaps.init()) .pipe(tsc(settings)) - .pipe(sourcemaps.write(".")) - .pipe(gulp.dest(".")); + .pipe(sourcemaps.write(builtLocalDirectory)) + .pipe(gulp.dest(builtLocalDirectory)); }); gulp.task("tsc-instrumented", "Builds an instrumented tsc.js", ["local", loggedIOJsPath, instrumenterJsPath, servicesFile], (done) => { diff --git a/Jakefile.js b/Jakefile.js index 546727db4e0..5ae887ee238 100644 --- a/Jakefile.js +++ b/Jakefile.js @@ -1098,7 +1098,7 @@ file(loggedIOJsPath, [builtLocalDirectory, loggedIOpath], function () { var instrumenterPath = harnessDirectory + 'instrumenter.ts'; var instrumenterJsPath = builtLocalDirectory + 'instrumenter.js'; -compileFile(instrumenterJsPath, [instrumenterPath], [tscFile, instrumenterPath].concat(libraryTargets), [], /*useBuiltCompiler*/ true, { lib: "es6", types: ["node"] }); +compileFile(instrumenterJsPath, [instrumenterPath], [tscFile, instrumenterPath].concat(libraryTargets), [], /*useBuiltCompiler*/ true, { lib: "es6", types: ["node"], noOutFile: true, outDir: builtLocalDirectory }); desc("Builds an instrumented tsc.js"); task('tsc-instrumented', [loggedIOJsPath, instrumenterJsPath, tscFile], function () { diff --git a/src/harness/instrumenter.ts b/src/harness/instrumenter.ts index 02aba0e7661..cb11be5c745 100644 --- a/src/harness/instrumenter.ts +++ b/src/harness/instrumenter.ts @@ -1,5 +1,5 @@ -const fs: any = require("fs"); -const path: any = require("path"); +import fs = require("fs"); +import path = require("path"); function instrumentForRecording(fn: string, tscPath: string) { instrument(tscPath, ` @@ -38,7 +38,9 @@ function instrument(tscPath: string, prepareCode: string, cleanupCode = "") { const index2 = index1 + invocationLine.length; const newContent = tscContent.substr(0, index1) + loggerContent + prepareCode + invocationLine + cleanupCode + tscContent.substr(index2) + "\r\n"; - fs.writeFile(tscPath, newContent); + fs.writeFile(tscPath, newContent, err => { + if (err) throw err; + }); }); }); }); From f8e8afec1b45b5d7d8ae6ba95ecbea37fcb7936b Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Tue, 22 Aug 2017 21:18:25 -0700 Subject: [PATCH 120/370] Accepted baselines. --- .../reference/baseExpressionTypeParameters.errors.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/baselines/reference/baseExpressionTypeParameters.errors.txt b/tests/baselines/reference/baseExpressionTypeParameters.errors.txt index 4fa8f2f6d3d..cb259e49dd2 100644 --- a/tests/baselines/reference/baseExpressionTypeParameters.errors.txt +++ b/tests/baselines/reference/baseExpressionTypeParameters.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/baseExpressionTypeParameters.ts(10,27): error TS2561: Base class expressions cannot reference class type parameters. +tests/cases/compiler/baseExpressionTypeParameters.ts(10,27): error TS2562: Base class expressions cannot reference class type parameters. ==== tests/cases/compiler/baseExpressionTypeParameters.ts (1 errors) ==== @@ -13,7 +13,7 @@ tests/cases/compiler/baseExpressionTypeParameters.ts(10,27): error TS2561: Base class Gen extends base() {} // Error, T not in scope ~ -!!! error TS2561: Base class expressions cannot reference class type parameters. +!!! error TS2562: Base class expressions cannot reference class type parameters. class Spec extends Gen {} Spec.prop; \ No newline at end of file From e3abc12209cb0cecc53ba530fef10f8fc1f74520 Mon Sep 17 00:00:00 2001 From: Matt Mitchell Date: Wed, 23 Aug 2017 11:03:05 -0700 Subject: [PATCH 121/370] Revert image label change (#17981) * Revert image label change I decided to avoid doing the image update change, reverting. * Use full OS name --- netci.groovy | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/netci.groovy b/netci.groovy index c60957730c4..fc6d00e4e7f 100644 --- a/netci.groovy +++ b/netci.groovy @@ -17,6 +17,6 @@ nodeVersions.each { nodeVer -> } Utilities.standardJobSetup(newJob, project, true, "*/${branch}") - Utilities.setMachineAffinity(newJob, 'Ubuntu14.04', '20170821-1') + Utilities.setMachineAffinity(newJob, 'Ubuntu14.04', '20161020') Utilities.addGithubPRTriggerForBranch(newJob, branch, "TypeScript Test Run ${newJobName}") } From e27d0917c9d0a9d364f0cbbc67bf880f32fd8808 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Mon, 21 Aug 2017 10:09:21 -0700 Subject: [PATCH 122/370] Test performance improvement:nested reference skip --- .../complexRecursiveCollections.errors.txt | 847 ++++++++++++++++++ .../compiler/complexRecursiveCollections.ts | 532 +++++++++++ 2 files changed, 1379 insertions(+) create mode 100644 tests/baselines/reference/complexRecursiveCollections.errors.txt create mode 100644 tests/cases/compiler/complexRecursiveCollections.ts diff --git a/tests/baselines/reference/complexRecursiveCollections.errors.txt b/tests/baselines/reference/complexRecursiveCollections.errors.txt new file mode 100644 index 00000000000..38f66b7456a --- /dev/null +++ b/tests/baselines/reference/complexRecursiveCollections.errors.txt @@ -0,0 +1,847 @@ +tests/cases/compiler/immutable.d.ts(25,39): error TS2304: Cannot find name 'Iterable'. +tests/cases/compiler/immutable.d.ts(46,20): error TS2304: Cannot find name 'Iterable'. +tests/cases/compiler/immutable.d.ts(47,23): error TS2304: Cannot find name 'Iterable'. +tests/cases/compiler/immutable.d.ts(48,23): error TS2304: Cannot find name 'Iterable'. +tests/cases/compiler/immutable.d.ts(49,23): error TS2304: Cannot find name 'Iterable'. +tests/cases/compiler/immutable.d.ts(50,23): error TS2304: Cannot find name 'Iterable'. +tests/cases/compiler/immutable.d.ts(51,22): error TS2304: Cannot find name 'Iterable'. +tests/cases/compiler/immutable.d.ts(52,26): error TS2304: Cannot find name 'Iterable'. +tests/cases/compiler/immutable.d.ts(58,45): error TS2304: Cannot find name 'Iterable'. +tests/cases/compiler/immutable.d.ts(60,63): error TS2304: Cannot find name 'Iterable'. +tests/cases/compiler/immutable.d.ts(68,41): error TS2304: Cannot find name 'Iterable'. +tests/cases/compiler/immutable.d.ts(69,38): error TS2304: Cannot find name 'Iterable'. +tests/cases/compiler/immutable.d.ts(69,47): error TS2304: Cannot find name 'Iterable'. +tests/cases/compiler/immutable.d.ts(78,21): error TS2304: Cannot find name 'Iterable'. +tests/cases/compiler/immutable.d.ts(79,21): error TS2304: Cannot find name 'Iterable'. +tests/cases/compiler/immutable.d.ts(89,20): error TS2304: Cannot find name 'Iterable'. +tests/cases/compiler/immutable.d.ts(90,23): error TS2304: Cannot find name 'Iterable'. +tests/cases/compiler/immutable.d.ts(91,23): error TS2304: Cannot find name 'Iterable'. +tests/cases/compiler/immutable.d.ts(92,23): error TS2304: Cannot find name 'Iterable'. +tests/cases/compiler/immutable.d.ts(93,23): error TS2304: Cannot find name 'Iterable'. +tests/cases/compiler/immutable.d.ts(94,22): error TS2304: Cannot find name 'Iterable'. +tests/cases/compiler/immutable.d.ts(95,26): error TS2304: Cannot find name 'Iterable'. +tests/cases/compiler/immutable.d.ts(101,42): error TS2304: Cannot find name 'Iterable'. +tests/cases/compiler/immutable.d.ts(106,58): error TS2304: Cannot find name 'Iterable'. +tests/cases/compiler/immutable.d.ts(113,48): error TS2304: Cannot find name 'Iterable'. +tests/cases/compiler/immutable.d.ts(114,45): error TS2304: Cannot find name 'Iterable'. +tests/cases/compiler/immutable.d.ts(114,54): error TS2304: Cannot find name 'Iterable'. +tests/cases/compiler/immutable.d.ts(120,42): error TS2304: Cannot find name 'Iterable'. +tests/cases/compiler/immutable.d.ts(125,58): error TS2304: Cannot find name 'Iterable'. +tests/cases/compiler/immutable.d.ts(134,33): error TS2304: Cannot find name 'Iterable'. +tests/cases/compiler/immutable.d.ts(134,42): error TS2304: Cannot find name 'Iterable'. +tests/cases/compiler/immutable.d.ts(135,29): error TS2304: Cannot find name 'Iterable'. +tests/cases/compiler/immutable.d.ts(135,38): error TS2304: Cannot find name 'Iterable'. +tests/cases/compiler/immutable.d.ts(139,38): error TS2304: Cannot find name 'Iterable'. +tests/cases/compiler/immutable.d.ts(155,45): error TS2304: Cannot find name 'Iterable'. +tests/cases/compiler/immutable.d.ts(157,62): error TS2304: Cannot find name 'Iterable'. +tests/cases/compiler/immutable.d.ts(169,45): error TS2304: Cannot find name 'Iterable'. +tests/cases/compiler/immutable.d.ts(172,45): error TS2304: Cannot find name 'Iterable'. +tests/cases/compiler/immutable.d.ts(174,62): error TS2304: Cannot find name 'Iterable'. +tests/cases/compiler/immutable.d.ts(188,40): error TS2304: Cannot find name 'Iterable'. +tests/cases/compiler/immutable.d.ts(195,22): error TS2304: Cannot find name 'Iterable'. +tests/cases/compiler/immutable.d.ts(198,19): error TS2304: Cannot find name 'Iterable'. +tests/cases/compiler/immutable.d.ts(205,45): error TS2304: Cannot find name 'Iterable'. +tests/cases/compiler/immutable.d.ts(207,63): error TS2304: Cannot find name 'Iterable'. +tests/cases/compiler/immutable.d.ts(217,30): error TS2304: Cannot find name 'Iterable'. +tests/cases/compiler/immutable.d.ts(218,34): error TS2304: Cannot find name 'Iterable'. +tests/cases/compiler/immutable.d.ts(226,22): error TS2304: Cannot find name 'Iterable'. +tests/cases/compiler/immutable.d.ts(227,22): error TS2304: Cannot find name 'Iterable'. +tests/cases/compiler/immutable.d.ts(234,48): error TS2304: Cannot find name 'Iterable'. +tests/cases/compiler/immutable.d.ts(235,52): error TS2304: Cannot find name 'Iterable'. +tests/cases/compiler/immutable.d.ts(236,109): error TS2304: Cannot find name 'Iterable'. +tests/cases/compiler/immutable.d.ts(237,109): error TS2304: Cannot find name 'Iterable'. +tests/cases/compiler/immutable.d.ts(242,22): error TS2304: Cannot find name 'Iterable'. +tests/cases/compiler/immutable.d.ts(243,25): error TS2304: Cannot find name 'Iterable'. +tests/cases/compiler/immutable.d.ts(244,24): error TS2304: Cannot find name 'Iterable'. +tests/cases/compiler/immutable.d.ts(245,28): error TS2304: Cannot find name 'Iterable'. +tests/cases/compiler/immutable.d.ts(246,25): error TS2304: Cannot find name 'Iterable'. +tests/cases/compiler/immutable.d.ts(247,25): error TS2304: Cannot find name 'Iterable'. +tests/cases/compiler/immutable.d.ts(258,8): error TS2304: Cannot find name 'Symbol'. +tests/cases/compiler/immutable.d.ts(258,28): error TS2304: Cannot find name 'IterableIterator'. +tests/cases/compiler/immutable.d.ts(266,45): error TS2304: Cannot find name 'Iterable'. +tests/cases/compiler/immutable.d.ts(274,44): error TS2304: Cannot find name 'Iterable'. +tests/cases/compiler/immutable.d.ts(279,60): error TS2304: Cannot find name 'Iterable'. +tests/cases/compiler/immutable.d.ts(288,44): error TS2304: Cannot find name 'Iterable'. +tests/cases/compiler/immutable.d.ts(293,47): error TS2304: Cannot find name 'Iterable'. +tests/cases/compiler/immutable.d.ts(295,65): error TS2304: Cannot find name 'Iterable'. +tests/cases/compiler/immutable.d.ts(304,40): error TS2304: Cannot find name 'Iterable'. +tests/cases/compiler/immutable.d.ts(309,47): error TS2304: Cannot find name 'Iterable'. +tests/cases/compiler/immutable.d.ts(311,64): error TS2304: Cannot find name 'Iterable'. +tests/cases/compiler/immutable.d.ts(320,38): error TS2304: Cannot find name 'Iterable'. +tests/cases/compiler/immutable.d.ts(329,58): error TS2304: Cannot find name 'Iterable'. +tests/cases/compiler/immutable.d.ts(339,45): error TS2304: Cannot find name 'Iterable'. +tests/cases/compiler/immutable.d.ts(341,22): error TS2430: Interface 'Keyed' incorrectly extends interface 'Collection'. + Types of property 'toSeq' are incompatible. + Type '() => Keyed' is not assignable to type '() => this'. + Type 'Keyed' is not assignable to type 'this'. +tests/cases/compiler/immutable.d.ts(347,44): error TS2304: Cannot find name 'Iterable'. +tests/cases/compiler/immutable.d.ts(352,60): error TS2304: Cannot find name 'Iterable'. +tests/cases/compiler/immutable.d.ts(355,8): error TS2304: Cannot find name 'Symbol'. +tests/cases/compiler/immutable.d.ts(355,28): error TS2304: Cannot find name 'IterableIterator'. +tests/cases/compiler/immutable.d.ts(358,44): error TS2304: Cannot find name 'Iterable'. +tests/cases/compiler/immutable.d.ts(359,22): error TS2430: Interface 'Indexed' incorrectly extends interface 'Collection'. + Types of property 'toSeq' are incompatible. + Type '() => Indexed' is not assignable to type '() => this'. + Type 'Indexed' is not assignable to type 'this'. +tests/cases/compiler/immutable.d.ts(382,47): error TS2304: Cannot find name 'Iterable'. +tests/cases/compiler/immutable.d.ts(384,65): error TS2304: Cannot find name 'Iterable'. +tests/cases/compiler/immutable.d.ts(387,8): error TS2304: Cannot find name 'Symbol'. +tests/cases/compiler/immutable.d.ts(387,28): error TS2304: Cannot find name 'IterableIterator'. +tests/cases/compiler/immutable.d.ts(390,40): error TS2304: Cannot find name 'Iterable'. +tests/cases/compiler/immutable.d.ts(391,22): error TS2430: Interface 'Set' incorrectly extends interface 'Collection'. + Types of property 'toSeq' are incompatible. + Type '() => Set' is not assignable to type '() => this'. + Type 'Set' is not assignable to type 'this'. +tests/cases/compiler/immutable.d.ts(396,47): error TS2304: Cannot find name 'Iterable'. +tests/cases/compiler/immutable.d.ts(398,64): error TS2304: Cannot find name 'Iterable'. +tests/cases/compiler/immutable.d.ts(401,8): error TS2304: Cannot find name 'Symbol'. +tests/cases/compiler/immutable.d.ts(401,28): error TS2304: Cannot find name 'IterableIterator'. +tests/cases/compiler/immutable.d.ts(405,45): error TS2304: Cannot find name 'Iterable'. +tests/cases/compiler/immutable.d.ts(420,26): error TS2304: Cannot find name 'Iterable'. +tests/cases/compiler/immutable.d.ts(421,26): error TS2304: Cannot find name 'Iterable'. +tests/cases/compiler/immutable.d.ts(442,13): error TS2304: Cannot find name 'IterableIterator'. +tests/cases/compiler/immutable.d.ts(443,15): error TS2304: Cannot find name 'IterableIterator'. +tests/cases/compiler/immutable.d.ts(444,16): error TS2304: Cannot find name 'IterableIterator'. +tests/cases/compiler/immutable.d.ts(476,58): error TS2304: Cannot find name 'Iterable'. +tests/cases/compiler/immutable.d.ts(503,20): error TS2304: Cannot find name 'Iterable'. +tests/cases/compiler/immutable.d.ts(504,22): error TS2304: Cannot find name 'Iterable'. + + +==== tests/cases/compiler/complex.d.ts (0 errors) ==== + interface Ara { t: T } + interface Collection { + map(mapper: (value: V, key: K, iter: this) => M): Collection; + flatMap(mapper: (value: V, key: K, iter: this) => Ara, context?: any): Collection; + // these seem necessary to push it over the top for memory usage + reduce(reducer: (reduction: R, value: V, key: K, iter: this) => R, initialReduction: R, context?: any): R; + reduce(reducer: (reduction: V | R, value: V, key: K, iter: this) => R): R; + toSeq(): Seq; + } + interface Seq extends Collection { + } + interface N1 extends Collection { + map(mapper: (value: T, key: void, iter: this) => M): N1; + flatMap(mapper: (value: T, key: void, iter: this) => Ara, context?: any): N1; + } + interface N2 extends N1 { + map(mapper: (value: T, key: void, iter: this) => M): N2; + flatMap(mapper: (value: T, key: void, iter: this) => Ara, context?: any): N2; + toSeq(): N2; + } +==== tests/cases/compiler/immutable.d.ts (98 errors) ==== + // Test that complex recursive collections can pass the `extends` assignability check without + // running out of memory. This bug was exposed in Typescript 2.4 when more generic signatures + // started being checked. + declare module Immutable { + export function fromJS(jsValue: any, reviver?: (key: string | number, sequence: Collection.Keyed | Collection.Indexed, path?: Array) => any): any; + export function is(first: any, second: any): boolean; + export function hash(value: any): number; + export function isImmutable(maybeImmutable: any): maybeImmutable is Collection; + export function isCollection(maybeCollection: any): maybeCollection is Collection; + export function isKeyed(maybeKeyed: any): maybeKeyed is Collection.Keyed; + export function isIndexed(maybeIndexed: any): maybeIndexed is Collection.Indexed; + export function isAssociative(maybeAssociative: any): maybeAssociative is Collection.Keyed | Collection.Indexed; + export function isOrdered(maybeOrdered: any): boolean; + export function isValueObject(maybeValue: any): maybeValue is ValueObject; + export interface ValueObject { + equals(other: any): boolean; + hashCode(): number; + } + export module List { + function isList(maybeList: any): maybeList is List; + function of(...values: Array): List; + } + export function List(): List; + export function List(): List; + export function List(collection: Iterable): List; + ~~~~~~~~ +!!! error TS2304: Cannot find name 'Iterable'. + export interface List extends Collection.Indexed { + // Persistent changes + set(index: number, value: T): List; + delete(index: number): List; + remove(index: number): List; + insert(index: number, value: T): List; + clear(): List; + push(...values: Array): List; + pop(): List; + unshift(...values: Array): List; + shift(): List; + update(index: number, notSetValue: T, updater: (value: T) => T): this; + update(index: number, updater: (value: T) => T): this; + update(updater: (value: this) => R): R; + merge(...collections: Array | Array>): this; + mergeWith(merger: (oldVal: T, newVal: T, key: number) => T, ...collections: Array | Array>): this; + mergeDeep(...collections: Array | Array>): this; + mergeDeepWith(merger: (oldVal: T, newVal: T, key: number) => T, ...collections: Array | Array>): this; + setSize(size: number): List; + // Deep persistent changes + setIn(keyPath: Iterable, value: any): this; + ~~~~~~~~ +!!! error TS2304: Cannot find name 'Iterable'. + deleteIn(keyPath: Iterable): this; + ~~~~~~~~ +!!! error TS2304: Cannot find name 'Iterable'. + removeIn(keyPath: Iterable): this; + ~~~~~~~~ +!!! error TS2304: Cannot find name 'Iterable'. + updateIn(keyPath: Iterable, notSetValue: any, updater: (value: any) => any): this; + ~~~~~~~~ +!!! error TS2304: Cannot find name 'Iterable'. + updateIn(keyPath: Iterable, updater: (value: any) => any): this; + ~~~~~~~~ +!!! error TS2304: Cannot find name 'Iterable'. + mergeIn(keyPath: Iterable, ...collections: Array): this; + ~~~~~~~~ +!!! error TS2304: Cannot find name 'Iterable'. + mergeDeepIn(keyPath: Iterable, ...collections: Array): this; + ~~~~~~~~ +!!! error TS2304: Cannot find name 'Iterable'. + // Transient changes + withMutations(mutator: (mutable: this) => any): this; + asMutable(): this; + asImmutable(): this; + // Sequence algorithms + concat(...valuesOrCollections: Array | C>): List; + ~~~~~~~~ +!!! error TS2304: Cannot find name 'Iterable'. + map(mapper: (value: T, key: number, iter: this) => M, context?: any): List; + flatMap(mapper: (value: T, key: number, iter: this) => Iterable, context?: any): List; + ~~~~~~~~ +!!! error TS2304: Cannot find name 'Iterable'. + filter(predicate: (value: T, index: number, iter: this) => value is F, context?: any): List; + filter(predicate: (value: T, index: number, iter: this) => any, context?: any): this; + } + export module Map { + function isMap(maybeMap: any): maybeMap is Map; + function of(...keyValues: Array): Map; + } + export function Map(collection: Iterable<[K, V]>): Map; + ~~~~~~~~ +!!! error TS2304: Cannot find name 'Iterable'. + export function Map(collection: Iterable>): Map; + ~~~~~~~~ +!!! error TS2304: Cannot find name 'Iterable'. + ~~~~~~~~ +!!! error TS2304: Cannot find name 'Iterable'. + export function Map(obj: {[key: string]: V}): Map; + export function Map(): Map; + export function Map(): Map; + export interface Map extends Collection.Keyed { + // Persistent changes + set(key: K, value: V): this; + delete(key: K): this; + remove(key: K): this; + deleteAll(keys: Iterable): this; + ~~~~~~~~ +!!! error TS2304: Cannot find name 'Iterable'. + removeAll(keys: Iterable): this; + ~~~~~~~~ +!!! error TS2304: Cannot find name 'Iterable'. + clear(): this; + update(key: K, notSetValue: V, updater: (value: V) => V): this; + update(key: K, updater: (value: V) => V): this; + update(updater: (value: this) => R): R; + merge(...collections: Array | {[key: string]: V}>): this; + mergeWith(merger: (oldVal: V, newVal: V, key: K) => V, ...collections: Array | {[key: string]: V}>): this; + mergeDeep(...collections: Array | {[key: string]: V}>): this; + mergeDeepWith(merger: (oldVal: V, newVal: V, key: K) => V, ...collections: Array | {[key: string]: V}>): this; + // Deep persistent changes + setIn(keyPath: Iterable, value: any): this; + ~~~~~~~~ +!!! error TS2304: Cannot find name 'Iterable'. + deleteIn(keyPath: Iterable): this; + ~~~~~~~~ +!!! error TS2304: Cannot find name 'Iterable'. + removeIn(keyPath: Iterable): this; + ~~~~~~~~ +!!! error TS2304: Cannot find name 'Iterable'. + updateIn(keyPath: Iterable, notSetValue: any, updater: (value: any) => any): this; + ~~~~~~~~ +!!! error TS2304: Cannot find name 'Iterable'. + updateIn(keyPath: Iterable, updater: (value: any) => any): this; + ~~~~~~~~ +!!! error TS2304: Cannot find name 'Iterable'. + mergeIn(keyPath: Iterable, ...collections: Array): this; + ~~~~~~~~ +!!! error TS2304: Cannot find name 'Iterable'. + mergeDeepIn(keyPath: Iterable, ...collections: Array): this; + ~~~~~~~~ +!!! error TS2304: Cannot find name 'Iterable'. + // Transient changes + withMutations(mutator: (mutable: this) => any): this; + asMutable(): this; + asImmutable(): this; + // Sequence algorithms + concat(...collections: Array>): Map; + ~~~~~~~~ +!!! error TS2304: Cannot find name 'Iterable'. + concat(...collections: Array<{[key: string]: C}>): Map; + map(mapper: (value: V, key: K, iter: this) => M, context?: any): Map; + mapKeys(mapper: (key: K, value: V, iter: this) => M, context?: any): Map; + mapEntries(mapper: (entry: [K, V], index: number, iter: this) => [KM, VM], context?: any): Map; + flatMap(mapper: (value: V, key: K, iter: this) => Iterable, context?: any): Map; + ~~~~~~~~ +!!! error TS2304: Cannot find name 'Iterable'. + filter(predicate: (value: V, key: K, iter: this) => value is F, context?: any): Map; + filter(predicate: (value: V, key: K, iter: this) => any, context?: any): this; + } + export module OrderedMap { + function isOrderedMap(maybeOrderedMap: any): maybeOrderedMap is OrderedMap; + } + export function OrderedMap(collection: Iterable<[K, V]>): OrderedMap; + ~~~~~~~~ +!!! error TS2304: Cannot find name 'Iterable'. + export function OrderedMap(collection: Iterable>): OrderedMap; + ~~~~~~~~ +!!! error TS2304: Cannot find name 'Iterable'. + ~~~~~~~~ +!!! error TS2304: Cannot find name 'Iterable'. + export function OrderedMap(obj: {[key: string]: V}): OrderedMap; + export function OrderedMap(): OrderedMap; + export function OrderedMap(): OrderedMap; + export interface OrderedMap extends Map { + // Sequence algorithms + concat(...collections: Array>): OrderedMap; + ~~~~~~~~ +!!! error TS2304: Cannot find name 'Iterable'. + concat(...collections: Array<{[key: string]: C}>): OrderedMap; + map(mapper: (value: V, key: K, iter: this) => M, context?: any): OrderedMap; + mapKeys(mapper: (key: K, value: V, iter: this) => M, context?: any): OrderedMap; + mapEntries(mapper: (entry: [K, V], index: number, iter: this) => [KM, VM], context?: any): OrderedMap; + flatMap(mapper: (value: V, key: K, iter: this) => Iterable, context?: any): OrderedMap; + ~~~~~~~~ +!!! error TS2304: Cannot find name 'Iterable'. + filter(predicate: (value: V, key: K, iter: this) => value is F, context?: any): OrderedMap; + filter(predicate: (value: V, key: K, iter: this) => any, context?: any): this; + } + export module Set { + function isSet(maybeSet: any): maybeSet is Set; + function of(...values: Array): Set; + function fromKeys(iter: Collection): Set; + function fromKeys(obj: {[key: string]: any}): Set; + function intersect(sets: Iterable>): Set; + ~~~~~~~~ +!!! error TS2304: Cannot find name 'Iterable'. + ~~~~~~~~ +!!! error TS2304: Cannot find name 'Iterable'. + function union(sets: Iterable>): Set; + ~~~~~~~~ +!!! error TS2304: Cannot find name 'Iterable'. + ~~~~~~~~ +!!! error TS2304: Cannot find name 'Iterable'. + } + export function Set(): Set; + export function Set(): Set; + export function Set(collection: Iterable): Set; + ~~~~~~~~ +!!! error TS2304: Cannot find name 'Iterable'. + export interface Set extends Collection.Set { + // Persistent changes + add(value: T): this; + delete(value: T): this; + remove(value: T): this; + clear(): this; + union(...collections: Array | Array>): this; + merge(...collections: Array | Array>): this; + intersect(...collections: Array | Array>): this; + subtract(...collections: Array | Array>): this; + // Transient changes + withMutations(mutator: (mutable: this) => any): this; + asMutable(): this; + asImmutable(): this; + // Sequence algorithms + concat(...valuesOrCollections: Array | C>): Set; + ~~~~~~~~ +!!! error TS2304: Cannot find name 'Iterable'. + map(mapper: (value: T, key: never, iter: this) => M, context?: any): Set; + flatMap(mapper: (value: T, key: never, iter: this) => Iterable, context?: any): Set; + ~~~~~~~~ +!!! error TS2304: Cannot find name 'Iterable'. + filter(predicate: (value: T, key: never, iter: this) => value is F, context?: any): Set; + filter(predicate: (value: T, key: never, iter: this) => any, context?: any): this; + } + export module OrderedSet { + function isOrderedSet(maybeOrderedSet: any): boolean; + function of(...values: Array): OrderedSet; + function fromKeys(iter: Collection): OrderedSet; + function fromKeys(obj: {[key: string]: any}): OrderedSet; + } + export function OrderedSet(): OrderedSet; + export function OrderedSet(): OrderedSet; + export function OrderedSet(collection: Iterable): OrderedSet; + ~~~~~~~~ +!!! error TS2304: Cannot find name 'Iterable'. + export interface OrderedSet extends Set { + // Sequence algorithms + concat(...valuesOrCollections: Array | C>): OrderedSet; + ~~~~~~~~ +!!! error TS2304: Cannot find name 'Iterable'. + map(mapper: (value: T, key: never, iter: this) => M, context?: any): OrderedSet; + flatMap(mapper: (value: T, key: never, iter: this) => Iterable, context?: any): OrderedSet; + ~~~~~~~~ +!!! error TS2304: Cannot find name 'Iterable'. + filter(predicate: (value: T, key: never, iter: this) => value is F, context?: any): OrderedSet; + filter(predicate: (value: T, key: never, iter: this) => any, context?: any): this; + zip(...collections: Array>): OrderedSet; + zipWith(zipper: (value: T, otherValue: U) => Z, otherCollection: Collection): OrderedSet; + zipWith(zipper: (value: T, otherValue: U, thirdValue: V) => Z, otherCollection: Collection, thirdCollection: Collection): OrderedSet; + zipWith(zipper: (...any: Array) => Z, ...collections: Array>): OrderedSet; + } + export module Stack { + function isStack(maybeStack: any): maybeStack is Stack; + function of(...values: Array): Stack; + } + export function Stack(): Stack; + export function Stack(): Stack; + export function Stack(collection: Iterable): Stack; + ~~~~~~~~ +!!! error TS2304: Cannot find name 'Iterable'. + export interface Stack extends Collection.Indexed { + // Reading values + peek(): T | undefined; + // Persistent changes + clear(): Stack; + unshift(...values: Array): Stack; + unshiftAll(iter: Iterable): Stack; + ~~~~~~~~ +!!! error TS2304: Cannot find name 'Iterable'. + shift(): Stack; + push(...values: Array): Stack; + pushAll(iter: Iterable): Stack; + ~~~~~~~~ +!!! error TS2304: Cannot find name 'Iterable'. + pop(): Stack; + // Transient changes + withMutations(mutator: (mutable: this) => any): this; + asMutable(): this; + asImmutable(): this; + // Sequence algorithms + concat(...valuesOrCollections: Array | C>): Stack; + ~~~~~~~~ +!!! error TS2304: Cannot find name 'Iterable'. + map(mapper: (value: T, key: number, iter: this) => M, context?: any): Stack; + flatMap(mapper: (value: T, key: number, iter: this) => Iterable, context?: any): Stack; + ~~~~~~~~ +!!! error TS2304: Cannot find name 'Iterable'. + filter(predicate: (value: T, index: number, iter: this) => value is F, context?: any): Set; + filter(predicate: (value: T, index: number, iter: this) => any, context?: any): this; + } + export function Range(start?: number, end?: number, step?: number): Seq.Indexed; + export function Repeat(value: T, times?: number): Seq.Indexed; + export module Record { + export function isRecord(maybeRecord: any): maybeRecord is Record.Instance; + export function getDescriptiveName(record: Instance): string; + export interface Class { + (values?: Partial | Iterable<[string, any]>): Instance & Readonly; + ~~~~~~~~ +!!! error TS2304: Cannot find name 'Iterable'. + new (values?: Partial | Iterable<[string, any]>): Instance & Readonly; + ~~~~~~~~ +!!! error TS2304: Cannot find name 'Iterable'. + } + export interface Instance { + readonly size: number; + // Reading values + has(key: string): boolean; + get(key: K): T[K]; + // Reading deep values + hasIn(keyPath: Iterable): boolean; + ~~~~~~~~ +!!! error TS2304: Cannot find name 'Iterable'. + getIn(keyPath: Iterable): any; + ~~~~~~~~ +!!! error TS2304: Cannot find name 'Iterable'. + // Value equality + equals(other: any): boolean; + hashCode(): number; + // Persistent changes + set(key: K, value: T[K]): this; + update(key: K, updater: (value: T[K]) => T[K]): this; + merge(...collections: Array | Iterable<[string, any]>>): this; + ~~~~~~~~ +!!! error TS2304: Cannot find name 'Iterable'. + mergeDeep(...collections: Array | Iterable<[string, any]>>): this; + ~~~~~~~~ +!!! error TS2304: Cannot find name 'Iterable'. + mergeWith(merger: (oldVal: any, newVal: any, key: keyof T) => any, ...collections: Array | Iterable<[string, any]>>): this; + ~~~~~~~~ +!!! error TS2304: Cannot find name 'Iterable'. + mergeDeepWith(merger: (oldVal: any, newVal: any, key: any) => any, ...collections: Array | Iterable<[string, any]>>): this; + ~~~~~~~~ +!!! error TS2304: Cannot find name 'Iterable'. + delete(key: K): this; + remove(key: K): this; + clear(): this; + // Deep persistent changes + setIn(keyPath: Iterable, value: any): this; + ~~~~~~~~ +!!! error TS2304: Cannot find name 'Iterable'. + updateIn(keyPath: Iterable, updater: (value: any) => any): this; + ~~~~~~~~ +!!! error TS2304: Cannot find name 'Iterable'. + mergeIn(keyPath: Iterable, ...collections: Array): this; + ~~~~~~~~ +!!! error TS2304: Cannot find name 'Iterable'. + mergeDeepIn(keyPath: Iterable, ...collections: Array): this; + ~~~~~~~~ +!!! error TS2304: Cannot find name 'Iterable'. + deleteIn(keyPath: Iterable): this; + ~~~~~~~~ +!!! error TS2304: Cannot find name 'Iterable'. + removeIn(keyPath: Iterable): this; + ~~~~~~~~ +!!! error TS2304: Cannot find name 'Iterable'. + // Conversion to JavaScript types + toJS(): { [K in keyof T]: any }; + toJSON(): T; + toObject(): T; + // Transient changes + withMutations(mutator: (mutable: this) => any): this; + asMutable(): this; + asImmutable(): this; + // Sequence algorithms + toSeq(): Seq.Keyed; + [Symbol.iterator](): IterableIterator<[keyof T, T[keyof T]]>; + ~~~~~~ +!!! error TS2304: Cannot find name 'Symbol'. + ~~~~~~~~~~~~~~~~ +!!! error TS2304: Cannot find name 'IterableIterator'. + } + } + export function Record(defaultValues: T, name?: string): Record.Class; + export module Seq { + function isSeq(maybeSeq: any): maybeSeq is Seq.Indexed | Seq.Keyed; + function of(...values: Array): Seq.Indexed; + export module Keyed {} + export function Keyed(collection: Iterable<[K, V]>): Seq.Keyed; + ~~~~~~~~ +!!! error TS2304: Cannot find name 'Iterable'. + export function Keyed(obj: {[key: string]: V}): Seq.Keyed; + export function Keyed(): Seq.Keyed; + export function Keyed(): Seq.Keyed; + export interface Keyed extends Seq, Collection.Keyed { + toJS(): Object; + toJSON(): { [key: string]: V }; + toSeq(): this; + concat(...collections: Array>): Seq.Keyed; + ~~~~~~~~ +!!! error TS2304: Cannot find name 'Iterable'. + concat(...collections: Array<{[key: string]: C}>): Seq.Keyed; + map(mapper: (value: V, key: K, iter: this) => M, context?: any): Seq.Keyed; + mapKeys(mapper: (key: K, value: V, iter: this) => M, context?: any): Seq.Keyed; + mapEntries(mapper: (entry: [K, V], index: number, iter: this) => [KM, VM], context?: any): Seq.Keyed; + flatMap(mapper: (value: V, key: K, iter: this) => Iterable, context?: any): Seq.Keyed; + ~~~~~~~~ +!!! error TS2304: Cannot find name 'Iterable'. + filter(predicate: (value: V, key: K, iter: this) => value is F, context?: any): Seq.Keyed; + filter(predicate: (value: V, key: K, iter: this) => any, context?: any): this; + } + module Indexed { + function of(...values: Array): Seq.Indexed; + } + export function Indexed(): Seq.Indexed; + export function Indexed(): Seq.Indexed; + export function Indexed(collection: Iterable): Seq.Indexed; + ~~~~~~~~ +!!! error TS2304: Cannot find name 'Iterable'. + export interface Indexed extends Seq, Collection.Indexed { + toJS(): Array; + toJSON(): Array; + toSeq(): this; + concat(...valuesOrCollections: Array | C>): Seq.Indexed; + ~~~~~~~~ +!!! error TS2304: Cannot find name 'Iterable'. + map(mapper: (value: T, key: number, iter: this) => M, context?: any): Seq.Indexed; + flatMap(mapper: (value: T, key: number, iter: this) => Iterable, context?: any): Seq.Indexed; + ~~~~~~~~ +!!! error TS2304: Cannot find name 'Iterable'. + filter(predicate: (value: T, index: number, iter: this) => value is F, context?: any): Seq.Indexed; + filter(predicate: (value: T, index: number, iter: this) => any, context?: any): this; + } + export module Set { + function of(...values: Array): Seq.Set; + } + export function Set(): Seq.Set; + export function Set(): Seq.Set; + export function Set(collection: Iterable): Seq.Set; + ~~~~~~~~ +!!! error TS2304: Cannot find name 'Iterable'. + export interface Set extends Seq, Collection.Set { + toJS(): Array; + toJSON(): Array; + toSeq(): this; + concat(...valuesOrCollections: Array | C>): Seq.Set; + ~~~~~~~~ +!!! error TS2304: Cannot find name 'Iterable'. + map(mapper: (value: T, key: never, iter: this) => M, context?: any): Seq.Set; + flatMap(mapper: (value: T, key: never, iter: this) => Iterable, context?: any): Seq.Set; + ~~~~~~~~ +!!! error TS2304: Cannot find name 'Iterable'. + filter(predicate: (value: T, key: never, iter: this) => value is F, context?: any): Seq.Set; + filter(predicate: (value: T, key: never, iter: this) => any, context?: any): this; + } + } + export function Seq>(seq: S): S; + export function Seq(collection: Collection.Keyed): Seq.Keyed; + export function Seq(collection: Collection.Indexed): Seq.Indexed; + export function Seq(collection: Collection.Set): Seq.Set; + export function Seq(collection: Iterable): Seq.Indexed; + ~~~~~~~~ +!!! error TS2304: Cannot find name 'Iterable'. + export function Seq(obj: {[key: string]: V}): Seq.Keyed; + export function Seq(): Seq; + export interface Seq extends Collection { + readonly size: number | undefined; + // Force evaluation + cacheResult(): this; + // Sequence algorithms + map(mapper: (value: V, key: K, iter: this) => M, context?: any): Seq; + flatMap(mapper: (value: V, key: K, iter: this) => Iterable, context?: any): Seq; + ~~~~~~~~ +!!! error TS2304: Cannot find name 'Iterable'. + filter(predicate: (value: V, key: K, iter: this) => value is F, context?: any): Seq; + filter(predicate: (value: V, key: K, iter: this) => any, context?: any): this; + } + export module Collection { + function isKeyed(maybeKeyed: any): maybeKeyed is Collection.Keyed; + function isIndexed(maybeIndexed: any): maybeIndexed is Collection.Indexed; + function isAssociative(maybeAssociative: any): maybeAssociative is Collection.Keyed | Collection.Indexed; + function isOrdered(maybeOrdered: any): boolean; + export module Keyed {} + export function Keyed(collection: Iterable<[K, V]>): Collection.Keyed; + ~~~~~~~~ +!!! error TS2304: Cannot find name 'Iterable'. + export function Keyed(obj: {[key: string]: V}): Collection.Keyed; + export interface Keyed extends Collection { + ~~~~~ +!!! error TS2430: Interface 'Keyed' incorrectly extends interface 'Collection'. +!!! error TS2430: Types of property 'toSeq' are incompatible. +!!! error TS2430: Type '() => Keyed' is not assignable to type '() => this'. +!!! error TS2430: Type 'Keyed' is not assignable to type 'this'. + toJS(): Object; + toJSON(): { [key: string]: V }; + toSeq(): Seq.Keyed; + // Sequence functions + flip(): this; + concat(...collections: Array>): Collection.Keyed; + ~~~~~~~~ +!!! error TS2304: Cannot find name 'Iterable'. + concat(...collections: Array<{[key: string]: C}>): Collection.Keyed; + map(mapper: (value: V, key: K, iter: this) => M, context?: any): Collection.Keyed; + mapKeys(mapper: (key: K, value: V, iter: this) => M, context?: any): Collection.Keyed; + mapEntries(mapper: (entry: [K, V], index: number, iter: this) => [KM, VM], context?: any): Collection.Keyed; + flatMap(mapper: (value: V, key: K, iter: this) => Iterable, context?: any): Collection.Keyed; + ~~~~~~~~ +!!! error TS2304: Cannot find name 'Iterable'. + filter(predicate: (value: V, key: K, iter: this) => value is F, context?: any): Collection.Keyed; + filter(predicate: (value: V, key: K, iter: this) => any, context?: any): this; + [Symbol.iterator](): IterableIterator<[K, V]>; + ~~~~~~ +!!! error TS2304: Cannot find name 'Symbol'. + ~~~~~~~~~~~~~~~~ +!!! error TS2304: Cannot find name 'IterableIterator'. + } + export module Indexed {} + export function Indexed(collection: Iterable): Collection.Indexed; + ~~~~~~~~ +!!! error TS2304: Cannot find name 'Iterable'. + export interface Indexed extends Collection { + ~~~~~~~ +!!! error TS2430: Interface 'Indexed' incorrectly extends interface 'Collection'. +!!! error TS2430: Types of property 'toSeq' are incompatible. +!!! error TS2430: Type '() => Indexed' is not assignable to type '() => this'. +!!! error TS2430: Type 'Indexed' is not assignable to type 'this'. + toJS(): Array; + toJSON(): Array; + // Reading values + get(index: number, notSetValue: NSV): T | NSV; + get(index: number): T | undefined; + // Conversion to Seq + toSeq(): Seq.Indexed; + fromEntrySeq(): Seq.Keyed; + // Combination + interpose(separator: T): this; + interleave(...collections: Array>): this; + splice(index: number, removeNum: number, ...values: Array): this; + zip(...collections: Array>): Collection.Indexed; + zipWith(zipper: (value: T, otherValue: U) => Z, otherCollection: Collection): Collection.Indexed; + zipWith(zipper: (value: T, otherValue: U, thirdValue: V) => Z, otherCollection: Collection, thirdCollection: Collection): Collection.Indexed; + zipWith(zipper: (...any: Array) => Z, ...collections: Array>): Collection.Indexed; + // Search for value + indexOf(searchValue: T): number; + lastIndexOf(searchValue: T): number; + findIndex(predicate: (value: T, index: number, iter: this) => boolean, context?: any): number; + findLastIndex(predicate: (value: T, index: number, iter: this) => boolean, context?: any): number; + // Sequence algorithms + concat(...valuesOrCollections: Array | C>): Collection.Indexed; + ~~~~~~~~ +!!! error TS2304: Cannot find name 'Iterable'. + map(mapper: (value: T, key: number, iter: this) => M, context?: any): Collection.Indexed; + flatMap(mapper: (value: T, key: number, iter: this) => Iterable, context?: any): Collection.Indexed; + ~~~~~~~~ +!!! error TS2304: Cannot find name 'Iterable'. + filter(predicate: (value: T, index: number, iter: this) => value is F, context?: any): Collection.Indexed; + filter(predicate: (value: T, index: number, iter: this) => any, context?: any): this; + [Symbol.iterator](): IterableIterator; + ~~~~~~ +!!! error TS2304: Cannot find name 'Symbol'. + ~~~~~~~~~~~~~~~~ +!!! error TS2304: Cannot find name 'IterableIterator'. + } + export module Set {} + export function Set(collection: Iterable): Collection.Set; + ~~~~~~~~ +!!! error TS2304: Cannot find name 'Iterable'. + export interface Set extends Collection { + ~~~ +!!! error TS2430: Interface 'Set' incorrectly extends interface 'Collection'. +!!! error TS2430: Types of property 'toSeq' are incompatible. +!!! error TS2430: Type '() => Set' is not assignable to type '() => this'. +!!! error TS2430: Type 'Set' is not assignable to type 'this'. + toJS(): Array; + toJSON(): Array; + toSeq(): Seq.Set; + // Sequence algorithms + concat(...valuesOrCollections: Array | C>): Collection.Set; + ~~~~~~~~ +!!! error TS2304: Cannot find name 'Iterable'. + map(mapper: (value: T, key: never, iter: this) => M, context?: any): Collection.Set; + flatMap(mapper: (value: T, key: never, iter: this) => Iterable, context?: any): Collection.Set; + ~~~~~~~~ +!!! error TS2304: Cannot find name 'Iterable'. + filter(predicate: (value: T, key: never, iter: this) => value is F, context?: any): Collection.Set; + filter(predicate: (value: T, key: never, iter: this) => any, context?: any): this; + [Symbol.iterator](): IterableIterator; + ~~~~~~ +!!! error TS2304: Cannot find name 'Symbol'. + ~~~~~~~~~~~~~~~~ +!!! error TS2304: Cannot find name 'IterableIterator'. + } + } + export function Collection>(collection: I): I; + export function Collection(collection: Iterable): Collection.Indexed; + ~~~~~~~~ +!!! error TS2304: Cannot find name 'Iterable'. + export function Collection(obj: {[key: string]: V}): Collection.Keyed; + export interface Collection extends ValueObject { + // Value equality + equals(other: any): boolean; + hashCode(): number; + // Reading values + get(key: K, notSetValue: NSV): V | NSV; + get(key: K): V | undefined; + has(key: K): boolean; + includes(value: V): boolean; + contains(value: V): boolean; + first(): V | undefined; + last(): V | undefined; + // Reading deep values + getIn(searchKeyPath: Iterable, notSetValue?: any): any; + ~~~~~~~~ +!!! error TS2304: Cannot find name 'Iterable'. + hasIn(searchKeyPath: Iterable): boolean; + ~~~~~~~~ +!!! error TS2304: Cannot find name 'Iterable'. + // Persistent changes + update(updater: (value: this) => R): R; + // Conversion to JavaScript types + toJS(): Array | { [key: string]: any }; + toJSON(): Array | { [key: string]: V }; + toArray(): Array; + toObject(): { [key: string]: V }; + // Conversion to Collections + toMap(): Map; + toOrderedMap(): OrderedMap; + toSet(): Set; + toOrderedSet(): OrderedSet; + toList(): List; + toStack(): Stack; + // Conversion to Seq + toSeq(): this; + toKeyedSeq(): Seq.Keyed; + toIndexedSeq(): Seq.Indexed; + toSetSeq(): Seq.Set; + // Iterators + keys(): IterableIterator; + ~~~~~~~~~~~~~~~~ +!!! error TS2304: Cannot find name 'IterableIterator'. + values(): IterableIterator; + ~~~~~~~~~~~~~~~~ +!!! error TS2304: Cannot find name 'IterableIterator'. + entries(): IterableIterator<[K, V]>; + ~~~~~~~~~~~~~~~~ +!!! error TS2304: Cannot find name 'IterableIterator'. + // Collections (Seq) + keySeq(): Seq.Indexed; + valueSeq(): Seq.Indexed; + entrySeq(): Seq.Indexed<[K, V]>; + // Sequence algorithms + map(mapper: (value: V, key: K, iter: this) => M, context?: any): Collection; + filter(predicate: (value: V, key: K, iter: this) => value is F, context?: any): Collection; + filter(predicate: (value: V, key: K, iter: this) => any, context?: any): this; + filterNot(predicate: (value: V, key: K, iter: this) => boolean, context?: any): this; + reverse(): this; + sort(comparator?: (valueA: V, valueB: V) => number): this; + sortBy(comparatorValueMapper: (value: V, key: K, iter: this) => C, comparator?: (valueA: C, valueB: C) => number): this; + groupBy(grouper: (value: V, key: K, iter: this) => G, context?: any): /*Map*/Seq.Keyed>; + // Side effects + forEach(sideEffect: (value: V, key: K, iter: this) => any, context?: any): number; + // Creating subsets + slice(begin?: number, end?: number): this; + rest(): this; + butLast(): this; + skip(amount: number): this; + skipLast(amount: number): this; + skipWhile(predicate: (value: V, key: K, iter: this) => boolean, context?: any): this; + skipUntil(predicate: (value: V, key: K, iter: this) => boolean, context?: any): this; + take(amount: number): this; + takeLast(amount: number): this; + takeWhile(predicate: (value: V, key: K, iter: this) => boolean, context?: any): this; + takeUntil(predicate: (value: V, key: K, iter: this) => boolean, context?: any): this; + // Combination + concat(...valuesOrCollections: Array): Collection; + flatten(depth?: number): Collection; + flatten(shallow?: boolean): Collection; + flatMap(mapper: (value: V, key: K, iter: this) => Iterable, context?: any): Collection; + ~~~~~~~~ +!!! error TS2304: Cannot find name 'Iterable'. + // Reducing a value + reduce(reducer: (reduction: R, value: V, key: K, iter: this) => R, initialReduction: R, context?: any): R; + reduce(reducer: (reduction: V | R, value: V, key: K, iter: this) => R): R; + reduceRight(reducer: (reduction: R, value: V, key: K, iter: this) => R, initialReduction: R, context?: any): R; + reduceRight(reducer: (reduction: V | R, value: V, key: K, iter: this) => R): R; + every(predicate: (value: V, key: K, iter: this) => boolean, context?: any): boolean; + some(predicate: (value: V, key: K, iter: this) => boolean, context?: any): boolean; + join(separator?: string): string; + isEmpty(): boolean; + count(): number; + count(predicate: (value: V, key: K, iter: this) => boolean, context?: any): number; + countBy(grouper: (value: V, key: K, iter: this) => G, context?: any): Map; + // Search for value + find(predicate: (value: V, key: K, iter: this) => boolean, context?: any, notSetValue?: V): V | undefined; + findLast(predicate: (value: V, key: K, iter: this) => boolean, context?: any, notSetValue?: V): V | undefined; + findEntry(predicate: (value: V, key: K, iter: this) => boolean, context?: any, notSetValue?: V): [K, V] | undefined; + findLastEntry(predicate: (value: V, key: K, iter: this) => boolean, context?: any, notSetValue?: V): [K, V] | undefined; + findKey(predicate: (value: V, key: K, iter: this) => boolean, context?: any): K | undefined; + findLastKey(predicate: (value: V, key: K, iter: this) => boolean, context?: any): K | undefined; + keyOf(searchValue: V): K | undefined; + lastKeyOf(searchValue: V): K | undefined; + max(comparator?: (valueA: V, valueB: V) => number): V | undefined; + maxBy(comparatorValueMapper: (value: V, key: K, iter: this) => C, comparator?: (valueA: C, valueB: C) => number): V | undefined; + min(comparator?: (valueA: V, valueB: V) => number): V | undefined; + minBy(comparatorValueMapper: (value: V, key: K, iter: this) => C, comparator?: (valueA: C, valueB: C) => number): V | undefined; + // Comparison + isSubset(iter: Iterable): boolean; + ~~~~~~~~ +!!! error TS2304: Cannot find name 'Iterable'. + isSuperset(iter: Iterable): boolean; + ~~~~~~~~ +!!! error TS2304: Cannot find name 'Iterable'. + readonly size: number; + } + } + declare module "immutable" { + export = Immutable + } + \ No newline at end of file diff --git a/tests/cases/compiler/complexRecursiveCollections.ts b/tests/cases/compiler/complexRecursiveCollections.ts new file mode 100644 index 00000000000..a79b429f204 --- /dev/null +++ b/tests/cases/compiler/complexRecursiveCollections.ts @@ -0,0 +1,532 @@ +// @Filename: complex.d.ts +interface Ara { t: T } +interface Collection { + map(mapper: (value: V, key: K, iter: this) => M): Collection; + flatMap(mapper: (value: V, key: K, iter: this) => Ara, context?: any): Collection; + // these seem necessary to push it over the top for memory usage + reduce(reducer: (reduction: R, value: V, key: K, iter: this) => R, initialReduction: R, context?: any): R; + reduce(reducer: (reduction: V | R, value: V, key: K, iter: this) => R): R; + toSeq(): Seq; +} +interface Seq extends Collection { +} +interface N1 extends Collection { + map(mapper: (value: T, key: void, iter: this) => M): N1; + flatMap(mapper: (value: T, key: void, iter: this) => Ara, context?: any): N1; +} +interface N2 extends N1 { + map(mapper: (value: T, key: void, iter: this) => M): N2; + flatMap(mapper: (value: T, key: void, iter: this) => Ara, context?: any): N2; + toSeq(): N2; +} +// @Filename: immutable.d.ts +// Test that complex recursive collections can pass the `extends` assignability check without +// running out of memory. This bug was exposed in Typescript 2.4 when more generic signatures +// started being checked. +declare module Immutable { + export function fromJS(jsValue: any, reviver?: (key: string | number, sequence: Collection.Keyed | Collection.Indexed, path?: Array) => any): any; + export function is(first: any, second: any): boolean; + export function hash(value: any): number; + export function isImmutable(maybeImmutable: any): maybeImmutable is Collection; + export function isCollection(maybeCollection: any): maybeCollection is Collection; + export function isKeyed(maybeKeyed: any): maybeKeyed is Collection.Keyed; + export function isIndexed(maybeIndexed: any): maybeIndexed is Collection.Indexed; + export function isAssociative(maybeAssociative: any): maybeAssociative is Collection.Keyed | Collection.Indexed; + export function isOrdered(maybeOrdered: any): boolean; + export function isValueObject(maybeValue: any): maybeValue is ValueObject; + export interface ValueObject { + equals(other: any): boolean; + hashCode(): number; + } + export module List { + function isList(maybeList: any): maybeList is List; + function of(...values: Array): List; + } + export function List(): List; + export function List(): List; + export function List(collection: Iterable): List; + export interface List extends Collection.Indexed { + // Persistent changes + set(index: number, value: T): List; + delete(index: number): List; + remove(index: number): List; + insert(index: number, value: T): List; + clear(): List; + push(...values: Array): List; + pop(): List; + unshift(...values: Array): List; + shift(): List; + update(index: number, notSetValue: T, updater: (value: T) => T): this; + update(index: number, updater: (value: T) => T): this; + update(updater: (value: this) => R): R; + merge(...collections: Array | Array>): this; + mergeWith(merger: (oldVal: T, newVal: T, key: number) => T, ...collections: Array | Array>): this; + mergeDeep(...collections: Array | Array>): this; + mergeDeepWith(merger: (oldVal: T, newVal: T, key: number) => T, ...collections: Array | Array>): this; + setSize(size: number): List; + // Deep persistent changes + setIn(keyPath: Iterable, value: any): this; + deleteIn(keyPath: Iterable): this; + removeIn(keyPath: Iterable): this; + updateIn(keyPath: Iterable, notSetValue: any, updater: (value: any) => any): this; + updateIn(keyPath: Iterable, updater: (value: any) => any): this; + mergeIn(keyPath: Iterable, ...collections: Array): this; + mergeDeepIn(keyPath: Iterable, ...collections: Array): this; + // Transient changes + withMutations(mutator: (mutable: this) => any): this; + asMutable(): this; + asImmutable(): this; + // Sequence algorithms + concat(...valuesOrCollections: Array | C>): List; + map(mapper: (value: T, key: number, iter: this) => M, context?: any): List; + flatMap(mapper: (value: T, key: number, iter: this) => Iterable, context?: any): List; + filter(predicate: (value: T, index: number, iter: this) => value is F, context?: any): List; + filter(predicate: (value: T, index: number, iter: this) => any, context?: any): this; + } + export module Map { + function isMap(maybeMap: any): maybeMap is Map; + function of(...keyValues: Array): Map; + } + export function Map(collection: Iterable<[K, V]>): Map; + export function Map(collection: Iterable>): Map; + export function Map(obj: {[key: string]: V}): Map; + export function Map(): Map; + export function Map(): Map; + export interface Map extends Collection.Keyed { + // Persistent changes + set(key: K, value: V): this; + delete(key: K): this; + remove(key: K): this; + deleteAll(keys: Iterable): this; + removeAll(keys: Iterable): this; + clear(): this; + update(key: K, notSetValue: V, updater: (value: V) => V): this; + update(key: K, updater: (value: V) => V): this; + update(updater: (value: this) => R): R; + merge(...collections: Array | {[key: string]: V}>): this; + mergeWith(merger: (oldVal: V, newVal: V, key: K) => V, ...collections: Array | {[key: string]: V}>): this; + mergeDeep(...collections: Array | {[key: string]: V}>): this; + mergeDeepWith(merger: (oldVal: V, newVal: V, key: K) => V, ...collections: Array | {[key: string]: V}>): this; + // Deep persistent changes + setIn(keyPath: Iterable, value: any): this; + deleteIn(keyPath: Iterable): this; + removeIn(keyPath: Iterable): this; + updateIn(keyPath: Iterable, notSetValue: any, updater: (value: any) => any): this; + updateIn(keyPath: Iterable, updater: (value: any) => any): this; + mergeIn(keyPath: Iterable, ...collections: Array): this; + mergeDeepIn(keyPath: Iterable, ...collections: Array): this; + // Transient changes + withMutations(mutator: (mutable: this) => any): this; + asMutable(): this; + asImmutable(): this; + // Sequence algorithms + concat(...collections: Array>): Map; + concat(...collections: Array<{[key: string]: C}>): Map; + map(mapper: (value: V, key: K, iter: this) => M, context?: any): Map; + mapKeys(mapper: (key: K, value: V, iter: this) => M, context?: any): Map; + mapEntries(mapper: (entry: [K, V], index: number, iter: this) => [KM, VM], context?: any): Map; + flatMap(mapper: (value: V, key: K, iter: this) => Iterable, context?: any): Map; + filter(predicate: (value: V, key: K, iter: this) => value is F, context?: any): Map; + filter(predicate: (value: V, key: K, iter: this) => any, context?: any): this; + } + export module OrderedMap { + function isOrderedMap(maybeOrderedMap: any): maybeOrderedMap is OrderedMap; + } + export function OrderedMap(collection: Iterable<[K, V]>): OrderedMap; + export function OrderedMap(collection: Iterable>): OrderedMap; + export function OrderedMap(obj: {[key: string]: V}): OrderedMap; + export function OrderedMap(): OrderedMap; + export function OrderedMap(): OrderedMap; + export interface OrderedMap extends Map { + // Sequence algorithms + concat(...collections: Array>): OrderedMap; + concat(...collections: Array<{[key: string]: C}>): OrderedMap; + map(mapper: (value: V, key: K, iter: this) => M, context?: any): OrderedMap; + mapKeys(mapper: (key: K, value: V, iter: this) => M, context?: any): OrderedMap; + mapEntries(mapper: (entry: [K, V], index: number, iter: this) => [KM, VM], context?: any): OrderedMap; + flatMap(mapper: (value: V, key: K, iter: this) => Iterable, context?: any): OrderedMap; + filter(predicate: (value: V, key: K, iter: this) => value is F, context?: any): OrderedMap; + filter(predicate: (value: V, key: K, iter: this) => any, context?: any): this; + } + export module Set { + function isSet(maybeSet: any): maybeSet is Set; + function of(...values: Array): Set; + function fromKeys(iter: Collection): Set; + function fromKeys(obj: {[key: string]: any}): Set; + function intersect(sets: Iterable>): Set; + function union(sets: Iterable>): Set; + } + export function Set(): Set; + export function Set(): Set; + export function Set(collection: Iterable): Set; + export interface Set extends Collection.Set { + // Persistent changes + add(value: T): this; + delete(value: T): this; + remove(value: T): this; + clear(): this; + union(...collections: Array | Array>): this; + merge(...collections: Array | Array>): this; + intersect(...collections: Array | Array>): this; + subtract(...collections: Array | Array>): this; + // Transient changes + withMutations(mutator: (mutable: this) => any): this; + asMutable(): this; + asImmutable(): this; + // Sequence algorithms + concat(...valuesOrCollections: Array | C>): Set; + map(mapper: (value: T, key: never, iter: this) => M, context?: any): Set; + flatMap(mapper: (value: T, key: never, iter: this) => Iterable, context?: any): Set; + filter(predicate: (value: T, key: never, iter: this) => value is F, context?: any): Set; + filter(predicate: (value: T, key: never, iter: this) => any, context?: any): this; + } + export module OrderedSet { + function isOrderedSet(maybeOrderedSet: any): boolean; + function of(...values: Array): OrderedSet; + function fromKeys(iter: Collection): OrderedSet; + function fromKeys(obj: {[key: string]: any}): OrderedSet; + } + export function OrderedSet(): OrderedSet; + export function OrderedSet(): OrderedSet; + export function OrderedSet(collection: Iterable): OrderedSet; + export interface OrderedSet extends Set { + // Sequence algorithms + concat(...valuesOrCollections: Array | C>): OrderedSet; + map(mapper: (value: T, key: never, iter: this) => M, context?: any): OrderedSet; + flatMap(mapper: (value: T, key: never, iter: this) => Iterable, context?: any): OrderedSet; + filter(predicate: (value: T, key: never, iter: this) => value is F, context?: any): OrderedSet; + filter(predicate: (value: T, key: never, iter: this) => any, context?: any): this; + zip(...collections: Array>): OrderedSet; + zipWith(zipper: (value: T, otherValue: U) => Z, otherCollection: Collection): OrderedSet; + zipWith(zipper: (value: T, otherValue: U, thirdValue: V) => Z, otherCollection: Collection, thirdCollection: Collection): OrderedSet; + zipWith(zipper: (...any: Array) => Z, ...collections: Array>): OrderedSet; + } + export module Stack { + function isStack(maybeStack: any): maybeStack is Stack; + function of(...values: Array): Stack; + } + export function Stack(): Stack; + export function Stack(): Stack; + export function Stack(collection: Iterable): Stack; + export interface Stack extends Collection.Indexed { + // Reading values + peek(): T | undefined; + // Persistent changes + clear(): Stack; + unshift(...values: Array): Stack; + unshiftAll(iter: Iterable): Stack; + shift(): Stack; + push(...values: Array): Stack; + pushAll(iter: Iterable): Stack; + pop(): Stack; + // Transient changes + withMutations(mutator: (mutable: this) => any): this; + asMutable(): this; + asImmutable(): this; + // Sequence algorithms + concat(...valuesOrCollections: Array | C>): Stack; + map(mapper: (value: T, key: number, iter: this) => M, context?: any): Stack; + flatMap(mapper: (value: T, key: number, iter: this) => Iterable, context?: any): Stack; + filter(predicate: (value: T, index: number, iter: this) => value is F, context?: any): Set; + filter(predicate: (value: T, index: number, iter: this) => any, context?: any): this; + } + export function Range(start?: number, end?: number, step?: number): Seq.Indexed; + export function Repeat(value: T, times?: number): Seq.Indexed; + export module Record { + export function isRecord(maybeRecord: any): maybeRecord is Record.Instance; + export function getDescriptiveName(record: Instance): string; + export interface Class { + (values?: Partial | Iterable<[string, any]>): Instance & Readonly; + new (values?: Partial | Iterable<[string, any]>): Instance & Readonly; + } + export interface Instance { + readonly size: number; + // Reading values + has(key: string): boolean; + get(key: K): T[K]; + // Reading deep values + hasIn(keyPath: Iterable): boolean; + getIn(keyPath: Iterable): any; + // Value equality + equals(other: any): boolean; + hashCode(): number; + // Persistent changes + set(key: K, value: T[K]): this; + update(key: K, updater: (value: T[K]) => T[K]): this; + merge(...collections: Array | Iterable<[string, any]>>): this; + mergeDeep(...collections: Array | Iterable<[string, any]>>): this; + mergeWith(merger: (oldVal: any, newVal: any, key: keyof T) => any, ...collections: Array | Iterable<[string, any]>>): this; + mergeDeepWith(merger: (oldVal: any, newVal: any, key: any) => any, ...collections: Array | Iterable<[string, any]>>): this; + delete(key: K): this; + remove(key: K): this; + clear(): this; + // Deep persistent changes + setIn(keyPath: Iterable, value: any): this; + updateIn(keyPath: Iterable, updater: (value: any) => any): this; + mergeIn(keyPath: Iterable, ...collections: Array): this; + mergeDeepIn(keyPath: Iterable, ...collections: Array): this; + deleteIn(keyPath: Iterable): this; + removeIn(keyPath: Iterable): this; + // Conversion to JavaScript types + toJS(): { [K in keyof T]: any }; + toJSON(): T; + toObject(): T; + // Transient changes + withMutations(mutator: (mutable: this) => any): this; + asMutable(): this; + asImmutable(): this; + // Sequence algorithms + toSeq(): Seq.Keyed; + [Symbol.iterator](): IterableIterator<[keyof T, T[keyof T]]>; + } + } + export function Record(defaultValues: T, name?: string): Record.Class; + export module Seq { + function isSeq(maybeSeq: any): maybeSeq is Seq.Indexed | Seq.Keyed; + function of(...values: Array): Seq.Indexed; + export module Keyed {} + export function Keyed(collection: Iterable<[K, V]>): Seq.Keyed; + export function Keyed(obj: {[key: string]: V}): Seq.Keyed; + export function Keyed(): Seq.Keyed; + export function Keyed(): Seq.Keyed; + export interface Keyed extends Seq, Collection.Keyed { + toJS(): Object; + toJSON(): { [key: string]: V }; + toSeq(): this; + concat(...collections: Array>): Seq.Keyed; + concat(...collections: Array<{[key: string]: C}>): Seq.Keyed; + map(mapper: (value: V, key: K, iter: this) => M, context?: any): Seq.Keyed; + mapKeys(mapper: (key: K, value: V, iter: this) => M, context?: any): Seq.Keyed; + mapEntries(mapper: (entry: [K, V], index: number, iter: this) => [KM, VM], context?: any): Seq.Keyed; + flatMap(mapper: (value: V, key: K, iter: this) => Iterable, context?: any): Seq.Keyed; + filter(predicate: (value: V, key: K, iter: this) => value is F, context?: any): Seq.Keyed; + filter(predicate: (value: V, key: K, iter: this) => any, context?: any): this; + } + module Indexed { + function of(...values: Array): Seq.Indexed; + } + export function Indexed(): Seq.Indexed; + export function Indexed(): Seq.Indexed; + export function Indexed(collection: Iterable): Seq.Indexed; + export interface Indexed extends Seq, Collection.Indexed { + toJS(): Array; + toJSON(): Array; + toSeq(): this; + concat(...valuesOrCollections: Array | C>): Seq.Indexed; + map(mapper: (value: T, key: number, iter: this) => M, context?: any): Seq.Indexed; + flatMap(mapper: (value: T, key: number, iter: this) => Iterable, context?: any): Seq.Indexed; + filter(predicate: (value: T, index: number, iter: this) => value is F, context?: any): Seq.Indexed; + filter(predicate: (value: T, index: number, iter: this) => any, context?: any): this; + } + export module Set { + function of(...values: Array): Seq.Set; + } + export function Set(): Seq.Set; + export function Set(): Seq.Set; + export function Set(collection: Iterable): Seq.Set; + export interface Set extends Seq, Collection.Set { + toJS(): Array; + toJSON(): Array; + toSeq(): this; + concat(...valuesOrCollections: Array | C>): Seq.Set; + map(mapper: (value: T, key: never, iter: this) => M, context?: any): Seq.Set; + flatMap(mapper: (value: T, key: never, iter: this) => Iterable, context?: any): Seq.Set; + filter(predicate: (value: T, key: never, iter: this) => value is F, context?: any): Seq.Set; + filter(predicate: (value: T, key: never, iter: this) => any, context?: any): this; + } + } + export function Seq>(seq: S): S; + export function Seq(collection: Collection.Keyed): Seq.Keyed; + export function Seq(collection: Collection.Indexed): Seq.Indexed; + export function Seq(collection: Collection.Set): Seq.Set; + export function Seq(collection: Iterable): Seq.Indexed; + export function Seq(obj: {[key: string]: V}): Seq.Keyed; + export function Seq(): Seq; + export interface Seq extends Collection { + readonly size: number | undefined; + // Force evaluation + cacheResult(): this; + // Sequence algorithms + map(mapper: (value: V, key: K, iter: this) => M, context?: any): Seq; + flatMap(mapper: (value: V, key: K, iter: this) => Iterable, context?: any): Seq; + filter(predicate: (value: V, key: K, iter: this) => value is F, context?: any): Seq; + filter(predicate: (value: V, key: K, iter: this) => any, context?: any): this; + } + export module Collection { + function isKeyed(maybeKeyed: any): maybeKeyed is Collection.Keyed; + function isIndexed(maybeIndexed: any): maybeIndexed is Collection.Indexed; + function isAssociative(maybeAssociative: any): maybeAssociative is Collection.Keyed | Collection.Indexed; + function isOrdered(maybeOrdered: any): boolean; + export module Keyed {} + export function Keyed(collection: Iterable<[K, V]>): Collection.Keyed; + export function Keyed(obj: {[key: string]: V}): Collection.Keyed; + export interface Keyed extends Collection { + toJS(): Object; + toJSON(): { [key: string]: V }; + toSeq(): Seq.Keyed; + // Sequence functions + flip(): this; + concat(...collections: Array>): Collection.Keyed; + concat(...collections: Array<{[key: string]: C}>): Collection.Keyed; + map(mapper: (value: V, key: K, iter: this) => M, context?: any): Collection.Keyed; + mapKeys(mapper: (key: K, value: V, iter: this) => M, context?: any): Collection.Keyed; + mapEntries(mapper: (entry: [K, V], index: number, iter: this) => [KM, VM], context?: any): Collection.Keyed; + flatMap(mapper: (value: V, key: K, iter: this) => Iterable, context?: any): Collection.Keyed; + filter(predicate: (value: V, key: K, iter: this) => value is F, context?: any): Collection.Keyed; + filter(predicate: (value: V, key: K, iter: this) => any, context?: any): this; + [Symbol.iterator](): IterableIterator<[K, V]>; + } + export module Indexed {} + export function Indexed(collection: Iterable): Collection.Indexed; + export interface Indexed extends Collection { + toJS(): Array; + toJSON(): Array; + // Reading values + get(index: number, notSetValue: NSV): T | NSV; + get(index: number): T | undefined; + // Conversion to Seq + toSeq(): Seq.Indexed; + fromEntrySeq(): Seq.Keyed; + // Combination + interpose(separator: T): this; + interleave(...collections: Array>): this; + splice(index: number, removeNum: number, ...values: Array): this; + zip(...collections: Array>): Collection.Indexed; + zipWith(zipper: (value: T, otherValue: U) => Z, otherCollection: Collection): Collection.Indexed; + zipWith(zipper: (value: T, otherValue: U, thirdValue: V) => Z, otherCollection: Collection, thirdCollection: Collection): Collection.Indexed; + zipWith(zipper: (...any: Array) => Z, ...collections: Array>): Collection.Indexed; + // Search for value + indexOf(searchValue: T): number; + lastIndexOf(searchValue: T): number; + findIndex(predicate: (value: T, index: number, iter: this) => boolean, context?: any): number; + findLastIndex(predicate: (value: T, index: number, iter: this) => boolean, context?: any): number; + // Sequence algorithms + concat(...valuesOrCollections: Array | C>): Collection.Indexed; + map(mapper: (value: T, key: number, iter: this) => M, context?: any): Collection.Indexed; + flatMap(mapper: (value: T, key: number, iter: this) => Iterable, context?: any): Collection.Indexed; + filter(predicate: (value: T, index: number, iter: this) => value is F, context?: any): Collection.Indexed; + filter(predicate: (value: T, index: number, iter: this) => any, context?: any): this; + [Symbol.iterator](): IterableIterator; + } + export module Set {} + export function Set(collection: Iterable): Collection.Set; + export interface Set extends Collection { + toJS(): Array; + toJSON(): Array; + toSeq(): Seq.Set; + // Sequence algorithms + concat(...valuesOrCollections: Array | C>): Collection.Set; + map(mapper: (value: T, key: never, iter: this) => M, context?: any): Collection.Set; + flatMap(mapper: (value: T, key: never, iter: this) => Iterable, context?: any): Collection.Set; + filter(predicate: (value: T, key: never, iter: this) => value is F, context?: any): Collection.Set; + filter(predicate: (value: T, key: never, iter: this) => any, context?: any): this; + [Symbol.iterator](): IterableIterator; + } + } + export function Collection>(collection: I): I; + export function Collection(collection: Iterable): Collection.Indexed; + export function Collection(obj: {[key: string]: V}): Collection.Keyed; + export interface Collection extends ValueObject { + // Value equality + equals(other: any): boolean; + hashCode(): number; + // Reading values + get(key: K, notSetValue: NSV): V | NSV; + get(key: K): V | undefined; + has(key: K): boolean; + includes(value: V): boolean; + contains(value: V): boolean; + first(): V | undefined; + last(): V | undefined; + // Reading deep values + getIn(searchKeyPath: Iterable, notSetValue?: any): any; + hasIn(searchKeyPath: Iterable): boolean; + // Persistent changes + update(updater: (value: this) => R): R; + // Conversion to JavaScript types + toJS(): Array | { [key: string]: any }; + toJSON(): Array | { [key: string]: V }; + toArray(): Array; + toObject(): { [key: string]: V }; + // Conversion to Collections + toMap(): Map; + toOrderedMap(): OrderedMap; + toSet(): Set; + toOrderedSet(): OrderedSet; + toList(): List; + toStack(): Stack; + // Conversion to Seq + toSeq(): this; + toKeyedSeq(): Seq.Keyed; + toIndexedSeq(): Seq.Indexed; + toSetSeq(): Seq.Set; + // Iterators + keys(): IterableIterator; + values(): IterableIterator; + entries(): IterableIterator<[K, V]>; + // Collections (Seq) + keySeq(): Seq.Indexed; + valueSeq(): Seq.Indexed; + entrySeq(): Seq.Indexed<[K, V]>; + // Sequence algorithms + map(mapper: (value: V, key: K, iter: this) => M, context?: any): Collection; + filter(predicate: (value: V, key: K, iter: this) => value is F, context?: any): Collection; + filter(predicate: (value: V, key: K, iter: this) => any, context?: any): this; + filterNot(predicate: (value: V, key: K, iter: this) => boolean, context?: any): this; + reverse(): this; + sort(comparator?: (valueA: V, valueB: V) => number): this; + sortBy(comparatorValueMapper: (value: V, key: K, iter: this) => C, comparator?: (valueA: C, valueB: C) => number): this; + groupBy(grouper: (value: V, key: K, iter: this) => G, context?: any): /*Map*/Seq.Keyed>; + // Side effects + forEach(sideEffect: (value: V, key: K, iter: this) => any, context?: any): number; + // Creating subsets + slice(begin?: number, end?: number): this; + rest(): this; + butLast(): this; + skip(amount: number): this; + skipLast(amount: number): this; + skipWhile(predicate: (value: V, key: K, iter: this) => boolean, context?: any): this; + skipUntil(predicate: (value: V, key: K, iter: this) => boolean, context?: any): this; + take(amount: number): this; + takeLast(amount: number): this; + takeWhile(predicate: (value: V, key: K, iter: this) => boolean, context?: any): this; + takeUntil(predicate: (value: V, key: K, iter: this) => boolean, context?: any): this; + // Combination + concat(...valuesOrCollections: Array): Collection; + flatten(depth?: number): Collection; + flatten(shallow?: boolean): Collection; + flatMap(mapper: (value: V, key: K, iter: this) => Iterable, context?: any): Collection; + // Reducing a value + reduce(reducer: (reduction: R, value: V, key: K, iter: this) => R, initialReduction: R, context?: any): R; + reduce(reducer: (reduction: V | R, value: V, key: K, iter: this) => R): R; + reduceRight(reducer: (reduction: R, value: V, key: K, iter: this) => R, initialReduction: R, context?: any): R; + reduceRight(reducer: (reduction: V | R, value: V, key: K, iter: this) => R): R; + every(predicate: (value: V, key: K, iter: this) => boolean, context?: any): boolean; + some(predicate: (value: V, key: K, iter: this) => boolean, context?: any): boolean; + join(separator?: string): string; + isEmpty(): boolean; + count(): number; + count(predicate: (value: V, key: K, iter: this) => boolean, context?: any): number; + countBy(grouper: (value: V, key: K, iter: this) => G, context?: any): Map; + // Search for value + find(predicate: (value: V, key: K, iter: this) => boolean, context?: any, notSetValue?: V): V | undefined; + findLast(predicate: (value: V, key: K, iter: this) => boolean, context?: any, notSetValue?: V): V | undefined; + findEntry(predicate: (value: V, key: K, iter: this) => boolean, context?: any, notSetValue?: V): [K, V] | undefined; + findLastEntry(predicate: (value: V, key: K, iter: this) => boolean, context?: any, notSetValue?: V): [K, V] | undefined; + findKey(predicate: (value: V, key: K, iter: this) => boolean, context?: any): K | undefined; + findLastKey(predicate: (value: V, key: K, iter: this) => boolean, context?: any): K | undefined; + keyOf(searchValue: V): K | undefined; + lastKeyOf(searchValue: V): K | undefined; + max(comparator?: (valueA: V, valueB: V) => number): V | undefined; + maxBy(comparatorValueMapper: (value: V, key: K, iter: this) => C, comparator?: (valueA: C, valueB: C) => number): V | undefined; + min(comparator?: (valueA: V, valueB: V) => number): V | undefined; + minBy(comparatorValueMapper: (value: V, key: K, iter: this) => C, comparator?: (valueA: C, valueB: C) => number): V | undefined; + // Comparison + isSubset(iter: Iterable): boolean; + isSuperset(iter: Iterable): boolean; + readonly size: number; + } +} +declare module "immutable" { + export = Immutable +} From 7a9491384c24f02757d23751da16bf647abd8b49 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Wed, 23 Aug 2017 11:49:24 -0700 Subject: [PATCH 123/370] Update baselines --- .../reference/typeParameterAssignmentCompat1.errors.txt | 6 ------ 1 file changed, 6 deletions(-) diff --git a/tests/baselines/reference/typeParameterAssignmentCompat1.errors.txt b/tests/baselines/reference/typeParameterAssignmentCompat1.errors.txt index 9665ef017c0..2ca4299c7f8 100644 --- a/tests/baselines/reference/typeParameterAssignmentCompat1.errors.txt +++ b/tests/baselines/reference/typeParameterAssignmentCompat1.errors.txt @@ -1,11 +1,8 @@ tests/cases/compiler/typeParameterAssignmentCompat1.ts(8,5): error TS2322: Type 'Foo' is not assignable to type 'Foo'. Type 'U' is not assignable to type 'T'. tests/cases/compiler/typeParameterAssignmentCompat1.ts(9,5): error TS2322: Type 'Foo' is not assignable to type 'Foo'. - Type 'T' is not assignable to type 'U'. tests/cases/compiler/typeParameterAssignmentCompat1.ts(16,9): error TS2322: Type 'Foo' is not assignable to type 'Foo'. - Type 'U' is not assignable to type 'T'. tests/cases/compiler/typeParameterAssignmentCompat1.ts(17,9): error TS2322: Type 'Foo' is not assignable to type 'Foo'. - Type 'T' is not assignable to type 'U'. ==== tests/cases/compiler/typeParameterAssignmentCompat1.ts (4 errors) ==== @@ -23,7 +20,6 @@ tests/cases/compiler/typeParameterAssignmentCompat1.ts(17,9): error TS2322: Type return x; ~~~~~~~~~ !!! error TS2322: Type 'Foo' is not assignable to type 'Foo'. -!!! error TS2322: Type 'T' is not assignable to type 'U'. } class C { @@ -33,10 +29,8 @@ tests/cases/compiler/typeParameterAssignmentCompat1.ts(17,9): error TS2322: Type x = y; // should be an error ~ !!! error TS2322: Type 'Foo' is not assignable to type 'Foo'. -!!! error TS2322: Type 'U' is not assignable to type 'T'. return x; ~~~~~~~~~ !!! error TS2322: Type 'Foo' is not assignable to type 'Foo'. -!!! error TS2322: Type 'T' is not assignable to type 'U'. } } \ No newline at end of file From f30931cddd606a34143b10049255185b8810a30c Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Wed, 23 Aug 2017 11:57:06 -0700 Subject: [PATCH 124/370] Comment getTypeReferenceId and getRelationKey --- src/compiler/checker.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 3accf163738..4124fefbe95 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -9779,6 +9779,10 @@ namespace ts { return getObjectFlags(type) & ObjectFlags.Reference && some((type).typeArguments, isUnconstrainedTypeParameter); } + /** + * getTypeReferenceId(A) returns "111=0-12=1" + * where A.id=111 and number.id=12 + */ function getTypeReferenceId(type: TypeReference, typeParameters: Type[]) { let result = "" + type.target.id; for (const t of type.typeArguments) { @@ -9797,6 +9801,10 @@ namespace ts { return result; } + /** + * To improve caching, the relation key for two generic types uses the target's id plus ids of the type parameters. + * For other cases, the types ids are used. + */ function getRelationKey(source: Type, target: Type, relation: Map) { if (relation === identityRelation && source.id > target.id) { const temp = source; From deaddb559544399fc670a88b5ab2624e534703f1 Mon Sep 17 00:00:00 2001 From: Mohamed Hegazy Date: Wed, 23 Aug 2017 13:01:14 -0700 Subject: [PATCH 125/370] Ports #17983 (#17986) * Bind logger function before using * Use lambda isntead of bind --- src/server/typingsInstaller/typingsInstaller.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/server/typingsInstaller/typingsInstaller.ts b/src/server/typingsInstaller/typingsInstaller.ts index 2b941c42141..c6423bc3c7b 100644 --- a/src/server/typingsInstaller/typingsInstaller.ts +++ b/src/server/typingsInstaller/typingsInstaller.ts @@ -150,7 +150,7 @@ namespace ts.server.typingsInstaller { } const discoverTypingsResult = JsTyping.discoverTypings( this.installTypingHost, - this.log.isEnabled() ? this.log.writeLine : undefined, + this.log.isEnabled() ? (s => this.log.writeLine(s)) : undefined, req.fileNames, req.projectRootPath, this.safeList, From 8d13314056b084cf9fb97df3ffa168059ed2af5f Mon Sep 17 00:00:00 2001 From: Klaus Meinhardt Date: Wed, 23 Aug 2017 23:33:53 +0200 Subject: [PATCH 126/370] Expose isSourceFileFromExternalLibrary (#16112) --- src/compiler/types.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 26bf5e1a91f..8fe602ea6f9 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -2431,7 +2431,7 @@ namespace ts { getDeclarationDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): Diagnostic[]; /** - * Gets a type checker that can be used to semantically analyze source fils in the program. + * Gets a type checker that can be used to semantically analyze source files in the program. */ getTypeChecker(): TypeChecker; @@ -2451,7 +2451,7 @@ namespace ts { /* @internal */ getFileProcessingDiagnostics(): DiagnosticCollection; /* @internal */ getResolvedTypeReferenceDirectives(): Map; - /* @internal */ isSourceFileFromExternalLibrary(file: SourceFile): boolean; + isSourceFileFromExternalLibrary(file: SourceFile): boolean; // For testing purposes only. /* @internal */ structureIsReused?: StructureIsReused; From 71c5b1b3548dcb3dc380d343c3b828a8df73b68d Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Wed, 23 Aug 2017 15:00:12 -0700 Subject: [PATCH 127/370] Parsing:Allow QuestionToken as start of type --- src/compiler/parser.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index a2fe752ad18..7486c7541be 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -2721,6 +2721,7 @@ namespace ts { case SyntaxKind.FalseKeyword: case SyntaxKind.ObjectKeyword: case SyntaxKind.AsteriskToken: + case SyntaxKind.QuestionToken: return true; case SyntaxKind.MinusToken: return lookAhead(nextTokenIsNumericLiteral); From ca86dc4deb15f1fe16ee0e1d797af4d92975cced Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Wed, 23 Aug 2017 15:00:40 -0700 Subject: [PATCH 128/370] Test:jsdoc nullable syntax legal in type arguments And update baselines --- .../reference/checkJsdocTypeTag3.errors.txt | 21 ---------------- .../baselines/reference/checkJsdocTypeTag3.js | 24 ------------------- .../reference/checkJsdocTypeTag3.symbols | 5 ++++ .../reference/checkJsdocTypeTag3.types | 5 ++++ .../thisTypeInFunctionsNegative.errors.txt | 5 +--- .../reference/thisTypeInFunctionsNegative.js | 2 +- .../conformance/jsdoc/checkJsdocTypeTag3.ts | 6 +++++ 7 files changed, 18 insertions(+), 50 deletions(-) delete mode 100644 tests/baselines/reference/checkJsdocTypeTag3.errors.txt delete mode 100644 tests/baselines/reference/checkJsdocTypeTag3.js create mode 100644 tests/baselines/reference/checkJsdocTypeTag3.symbols create mode 100644 tests/baselines/reference/checkJsdocTypeTag3.types create mode 100644 tests/cases/conformance/jsdoc/checkJsdocTypeTag3.ts diff --git a/tests/baselines/reference/checkJsdocTypeTag3.errors.txt b/tests/baselines/reference/checkJsdocTypeTag3.errors.txt deleted file mode 100644 index d53c0972fa3..00000000000 --- a/tests/baselines/reference/checkJsdocTypeTag3.errors.txt +++ /dev/null @@ -1,21 +0,0 @@ -tests/cases/conformance/jsdoc/0.js(5,4): error TS2345: Argument of type '"string"' is not assignable to parameter of type 'number'. -tests/cases/conformance/jsdoc/0.js(12,1): error TS2322: Type 'number' is not assignable to type 'string'. - - -==== tests/cases/conformance/jsdoc/0.js (2 errors) ==== - // @ts-check - - /** @type {function (number)} */ - const x1 = (a) => a + 1; - x1("string"); - ~~~~~~~~ -!!! error TS2345: Argument of type '"string"' is not assignable to parameter of type 'number'. - - /** @type {function (number): number} */ - const x2 = (a) => a + 1; - - /** @type {string} */ - var a; - a = x2(0); - ~ -!!! error TS2322: Type 'number' is not assignable to type 'string'. \ No newline at end of file diff --git a/tests/baselines/reference/checkJsdocTypeTag3.js b/tests/baselines/reference/checkJsdocTypeTag3.js deleted file mode 100644 index 2eb50223ba2..00000000000 --- a/tests/baselines/reference/checkJsdocTypeTag3.js +++ /dev/null @@ -1,24 +0,0 @@ -//// [0.js] -// @ts-check - -/** @type {function (number)} */ -const x1 = (a) => a + 1; -x1("string"); - -/** @type {function (number): number} */ -const x2 = (a) => a + 1; - -/** @type {string} */ -var a; -a = x2(0); - -//// [0.js] -// @ts-check -/** @type {function (number)} */ -var x1 = function (a) { return a + 1; }; -x1("string"); -/** @type {function (number): number} */ -var x2 = function (a) { return a + 1; }; -/** @type {string} */ -var a; -a = x2(0); diff --git a/tests/baselines/reference/checkJsdocTypeTag3.symbols b/tests/baselines/reference/checkJsdocTypeTag3.symbols new file mode 100644 index 00000000000..4e731fbdc87 --- /dev/null +++ b/tests/baselines/reference/checkJsdocTypeTag3.symbols @@ -0,0 +1,5 @@ +=== tests/cases/conformance/jsdoc/test.js === +/** @type {Array} */ +var nns; +>nns : Symbol(nns, Decl(test.js, 1, 3)) + diff --git a/tests/baselines/reference/checkJsdocTypeTag3.types b/tests/baselines/reference/checkJsdocTypeTag3.types new file mode 100644 index 00000000000..94d953e0b44 --- /dev/null +++ b/tests/baselines/reference/checkJsdocTypeTag3.types @@ -0,0 +1,5 @@ +=== tests/cases/conformance/jsdoc/test.js === +/** @type {Array} */ +var nns; +>nns : number[] + diff --git a/tests/baselines/reference/thisTypeInFunctionsNegative.errors.txt b/tests/baselines/reference/thisTypeInFunctionsNegative.errors.txt index 4f566c1a7ae..b813c08705b 100644 --- a/tests/baselines/reference/thisTypeInFunctionsNegative.errors.txt +++ b/tests/baselines/reference/thisTypeInFunctionsNegative.errors.txt @@ -84,7 +84,6 @@ tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(169,20): e tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(169,23): error TS1003: Identifier expected. tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(169,27): error TS1005: ',' expected. tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(170,23): error TS1005: ',' expected. -tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(170,24): error TS1138: Parameter declaration expected. tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(171,28): error TS1003: Identifier expected. tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(171,32): error TS1005: ',' expected. tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(172,30): error TS1005: ',' expected. @@ -94,7 +93,7 @@ tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(175,32): e tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(175,35): error TS2304: Cannot find name 'm'. -==== tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts (60 errors) ==== +==== tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts (59 errors) ==== class C { n: number; explicitThis(this: this, m: number): number { @@ -403,8 +402,6 @@ tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(175,35): e function optional(this?: C): number { return this.n; } ~ !!! error TS1005: ',' expected. - ~ -!!! error TS1138: Parameter declaration expected. function decorated(@deco() this: C): number { return this.n; } ~~~~ !!! error TS1003: Identifier expected. diff --git a/tests/baselines/reference/thisTypeInFunctionsNegative.js b/tests/baselines/reference/thisTypeInFunctionsNegative.js index c0a6ecb1dee..94a0565e237 100644 --- a/tests/baselines/reference/thisTypeInFunctionsNegative.js +++ b/tests/baselines/reference/thisTypeInFunctionsNegative.js @@ -345,7 +345,7 @@ function modifiers(, C) { return this.n; } function restParam(C) { return this.n; } -function optional(C) { return this.n; } +function optional() { return this.n; } function decorated(, C) { if ( === void 0) { = this; } return this.n; diff --git a/tests/cases/conformance/jsdoc/checkJsdocTypeTag3.ts b/tests/cases/conformance/jsdoc/checkJsdocTypeTag3.ts new file mode 100644 index 00000000000..0051e1029f9 --- /dev/null +++ b/tests/cases/conformance/jsdoc/checkJsdocTypeTag3.ts @@ -0,0 +1,6 @@ +// @Filename:test.js +// @checkJs: true +// @allowJs: true +// @noEmit: true +/** @type {Array} */ +var nns; From 1bae5f2c69177251794462eee3c16efc17ce8de3 Mon Sep 17 00:00:00 2001 From: Mohamed Hegazy Date: Wed, 23 Aug 2017 17:08:25 -0700 Subject: [PATCH 129/370] Update generated files (#17995) --- src/lib/dom.generated.d.ts | 279 +++++++++++++++++++------------ src/lib/webworker.generated.d.ts | 72 +++++--- 2 files changed, 216 insertions(+), 135 deletions(-) diff --git a/src/lib/dom.generated.d.ts b/src/lib/dom.generated.d.ts index da81bba5d78..feb38887ab9 100644 --- a/src/lib/dom.generated.d.ts +++ b/src/lib/dom.generated.d.ts @@ -4,11 +4,11 @@ ///////////////////////////// interface Account { - displayName?: string; - id?: string; + displayName: string; + id: string; imageURL?: string; name?: string; - rpDisplayName?: string; + rpDisplayName: string; } interface Algorithm { @@ -35,11 +35,11 @@ interface CacheQueryOptions { } interface ClientData { - challenge?: string; + challenge: string; extensions?: WebAuthnExtensions; - hashAlg?: string | Algorithm; - origin?: string; - rpId?: string; + hashAlg: string | Algorithm; + origin: string; + rpId: string; tokenBinding?: string; } @@ -87,9 +87,9 @@ interface CustomEventInit extends EventInit { } interface DeviceAccelerationDict { - x?: number; - y?: number; - z?: number; + x?: number | null; + y?: number | null; + z?: number | null; } interface DeviceLightEventInit extends EventInit { @@ -97,30 +97,30 @@ interface DeviceLightEventInit extends EventInit { } interface DeviceMotionEventInit extends EventInit { - acceleration?: DeviceAccelerationDict; - accelerationIncludingGravity?: DeviceAccelerationDict; - interval?: number; - rotationRate?: DeviceRotationRateDict; + acceleration?: DeviceAccelerationDict | null; + accelerationIncludingGravity?: DeviceAccelerationDict | null; + interval?: number | null; + rotationRate?: DeviceRotationRateDict | null; } interface DeviceOrientationEventInit extends EventInit { absolute?: boolean; - alpha?: number; - beta?: number; - gamma?: number; + alpha?: number | null; + beta?: number | null; + gamma?: number | null; } interface DeviceRotationRateDict { - alpha?: number; - beta?: number; - gamma?: number; + alpha?: number | null; + beta?: number | null; + gamma?: number | null; } interface DOMRectInit { - height?: any; - width?: any; - x?: any; - y?: any; + height?: number; + width?: number; + x?: number; + y?: number; } interface DoubleRange { @@ -161,15 +161,15 @@ interface EventModifierInit extends UIEventInit { } interface ExceptionInformation { - domain?: string; + domain?: string | null; } interface FocusEventInit extends UIEventInit { - relatedTarget?: EventTarget; + relatedTarget?: EventTarget | null; } interface FocusNavigationEventInit extends EventInit { - navigationReason?: string; + navigationReason?: string | null; originHeight?: number; originLeft?: number; originTop?: number; @@ -184,7 +184,7 @@ interface FocusNavigationOrigin { } interface GamepadEventInit extends EventInit { - gamepad?: Gamepad; + gamepad?: Gamepad | null; } interface GetNotificationOptions { @@ -192,8 +192,8 @@ interface GetNotificationOptions { } interface HashChangeEventInit extends EventInit { - newURL?: string; - oldURL?: string; + newURL?: string | null; + oldURL?: string | null; } interface IDBIndexParameters { @@ -203,19 +203,20 @@ interface IDBIndexParameters { interface IDBObjectStoreParameters { autoIncrement?: boolean; - keyPath?: IDBKeyPath; + keyPath?: IDBKeyPath | null; } interface IntersectionObserverEntryInit { - boundingClientRect?: DOMRectInit; - intersectionRect?: DOMRectInit; - rootBounds?: DOMRectInit; - target?: Element; - time?: number; + isIntersecting: boolean; + boundingClientRect: DOMRectInit; + intersectionRect: DOMRectInit; + rootBounds: DOMRectInit; + target: Element; + time: number; } interface IntersectionObserverInit { - root?: Element; + root?: Element | null; rootMargin?: string; threshold?: number | number[]; } @@ -237,12 +238,12 @@ interface LongRange { } interface MediaEncryptedEventInit extends EventInit { - initData?: ArrayBuffer; + initData?: ArrayBuffer | null; initDataType?: string; } interface MediaKeyMessageEventInit extends EventInit { - message?: ArrayBuffer; + message?: ArrayBuffer | null; messageType?: MediaKeyMessageType; } @@ -265,7 +266,7 @@ interface MediaStreamConstraints { } interface MediaStreamErrorEventInit extends EventInit { - error?: MediaStreamError; + error?: MediaStreamError | null; } interface MediaStreamEventInit extends EventInit { @@ -273,7 +274,7 @@ interface MediaStreamEventInit extends EventInit { } interface MediaStreamTrackEventInit extends EventInit { - track?: MediaStreamTrack; + track?: MediaStreamTrack | null; } interface MediaTrackCapabilities { @@ -350,7 +351,7 @@ interface MouseEventInit extends EventModifierInit { buttons?: number; clientX?: number; clientY?: number; - relatedTarget?: EventTarget; + relatedTarget?: EventTarget | null; screenX?: number; screenY?: number; } @@ -358,8 +359,8 @@ interface MouseEventInit extends EventModifierInit { interface MSAccountInfo { accountImageUri?: string; accountName?: string; - rpDisplayName?: string; - userDisplayName?: string; + rpDisplayName: string; + userDisplayName: string; userId?: string; } @@ -442,7 +443,7 @@ interface MSCredentialParameters { interface MSCredentialSpec { id?: string; - type?: MSCredentialType; + type: MSCredentialType; } interface MSDelay { @@ -652,8 +653,8 @@ interface MsZoomToOptions { contentX?: number; contentY?: number; scaleFactor?: number; - viewportX?: string; - viewportY?: string; + viewportX?: string | null; + viewportY?: string | null; } interface MutationObserverInit { @@ -679,9 +680,9 @@ interface ObjectURLOptions { } interface PaymentCurrencyAmount { - currency?: string; + currency: string; currencySystem?: string; - value?: string; + value: string; } interface PaymentDetails { @@ -695,19 +696,19 @@ interface PaymentDetails { interface PaymentDetailsModifier { additionalDisplayItems?: PaymentItem[]; data?: any; - supportedMethods?: string[]; + supportedMethods: string[]; total?: PaymentItem; } interface PaymentItem { - amount?: PaymentCurrencyAmount; - label?: string; + amount: PaymentCurrencyAmount; + label: string; pending?: boolean; } interface PaymentMethodData { data?: any; - supportedMethods?: string[]; + supportedMethods: string[]; } interface PaymentOptions { @@ -722,9 +723,9 @@ interface PaymentRequestUpdateEventInit extends EventInit { } interface PaymentShippingOption { - amount?: PaymentCurrencyAmount; - id?: string; - label?: string; + amount: PaymentCurrencyAmount; + id: string; + label: string; selected?: boolean; } @@ -772,7 +773,7 @@ interface RequestInit { body?: any; cache?: RequestCache; credentials?: RequestCredentials; - headers?: any; + headers?: Headers | string[][]; integrity?: string; keepalive?: boolean; method?: string; @@ -784,7 +785,7 @@ interface RequestInit { } interface ResponseInit { - headers?: any; + headers?: Headers | string[][]; status?: number; statusText?: string; } @@ -869,15 +870,15 @@ interface RTCIceGatherOptions { } interface RTCIceParameters { - iceLite?: boolean; + iceLite?: boolean | null; password?: string; usernameFragment?: string; } interface RTCIceServer { - credential?: string; + credential?: string | null; urls?: any; - username?: string; + username?: string | null; } interface RTCInboundRTPStreamStats extends RTCRTPStreamStats { @@ -1087,9 +1088,9 @@ interface RTCTransportStats extends RTCStats { } interface ScopedCredentialDescriptor { - id?: any; + id: any; transports?: Transport[]; - type?: ScopedCredentialType; + type: ScopedCredentialType; } interface ScopedCredentialOptions { @@ -1100,29 +1101,29 @@ interface ScopedCredentialOptions { } interface ScopedCredentialParameters { - algorithm?: string | Algorithm; - type?: ScopedCredentialType; + algorithm: string | Algorithm; + type: ScopedCredentialType; } interface ServiceWorkerMessageEventInit extends EventInit { data?: any; lastEventId?: string; origin?: string; - ports?: MessagePort[]; - source?: ServiceWorker | MessagePort; + ports?: MessagePort[] | null; + source?: ServiceWorker | MessagePort | null; } interface SpeechSynthesisEventInit extends EventInit { charIndex?: number; elapsedTime?: number; name?: string; - utterance?: SpeechSynthesisUtterance; + utterance?: SpeechSynthesisUtterance | null; } interface StoreExceptionsInformation extends ExceptionInformation { - detailURI?: string; - explanationString?: string; - siteName?: string; + detailURI?: string | null; + explanationString?: string | null; + siteName?: string | null; } interface StoreSiteSpecificExceptionsInformation extends StoreExceptionsInformation { @@ -1130,7 +1131,7 @@ interface StoreSiteSpecificExceptionsInformation extends StoreExceptionsInformat } interface TrackEventInit extends EventInit { - track?: VideoTrack | AudioTrack | TextTrack; + track?: VideoTrack | AudioTrack | TextTrack | null; } interface TransitionEventInit extends EventInit { @@ -1140,7 +1141,7 @@ interface TransitionEventInit extends EventInit { interface UIEventInit extends EventInit { detail?: number; - view?: Window; + view?: Window | null; } interface WebAuthnExtensions { @@ -1520,9 +1521,9 @@ interface Cache { add(request: RequestInfo): Promise; addAll(requests: RequestInfo[]): Promise; delete(request: RequestInfo, options?: CacheQueryOptions): Promise; - keys(request?: RequestInfo, options?: CacheQueryOptions): any; + keys(request?: RequestInfo, options?: CacheQueryOptions): Promise; match(request: RequestInfo, options?: CacheQueryOptions): Promise; - matchAll(request?: RequestInfo, options?: CacheQueryOptions): any; + matchAll(request?: RequestInfo, options?: CacheQueryOptions): Promise; put(request: RequestInfo, response: Response): Promise; } @@ -1534,7 +1535,7 @@ declare var Cache: { interface CacheStorage { delete(cacheName: string): Promise; has(cacheName: string): Promise; - keys(): any; + keys(): Promise; match(request: RequestInfo, options?: CacheQueryOptions): Promise; open(cacheName: string): Promise; } @@ -2639,7 +2640,7 @@ interface Document extends Node, GlobalEventHandlers, NodeSelector, DocumentEven */ readonly compatMode: string; cookie: string; - readonly currentScript: HTMLScriptElement | SVGScriptElement; + readonly currentScript: HTMLScriptElement | SVGScriptElement | null; readonly defaultView: Window; /** * Sets or gets a value that indicates whether the document can be edited. @@ -3378,7 +3379,7 @@ interface DOMException { declare var DOMException: { prototype: DOMException; - new(): DOMException; + new(message?: string, name?: string): DOMException; readonly ABORT_ERR: number; readonly DATA_CLONE_ERR: number; readonly DOMSTRING_SIZE_ERR: number; @@ -3884,7 +3885,7 @@ interface Headers { declare var Headers: { prototype: Headers; - new(init?: any): Headers; + new(init?: Headers | string[][]): Headers; }; interface History { @@ -4044,7 +4045,7 @@ interface HTMLAppletElement extends HTMLElement { * Sets or retrieves a character string that can be used to implement your own declare functionality for the object. */ declare: boolean; - readonly form: HTMLFormElement; + readonly form: HTMLFormElement | null; /** * Sets or retrieves the height of the object. */ @@ -4282,7 +4283,7 @@ interface HTMLButtonElement extends HTMLElement { /** * Retrieves a reference to the form that the object is embedded in. */ - readonly form: HTMLFormElement; + readonly form: HTMLFormElement | null; /** * Overrides the action attribute (where the data on a form is sent) on the parent form element. */ @@ -4715,7 +4716,7 @@ interface HTMLFieldSetElement extends HTMLElement { /** * Retrieves a reference to the form that the object is embedded in. */ - readonly form: HTMLFormElement; + readonly form: HTMLFormElement | null; name: string; /** * Returns the error message that would be displayed if the user submits the form, or an empty string if no error message. It also triggers the standard error message, such as "this is a required field". The result is that the user sees validation messages without actually submitting. @@ -5294,7 +5295,7 @@ interface HTMLInputElement extends HTMLElement { /** * Retrieves a reference to the form that the object is embedded in. */ - readonly form: HTMLFormElement; + readonly form: HTMLFormElement | null; /** * Overrides the action attribute (where the data on a form is sent) on the parent form element. */ @@ -5461,7 +5462,7 @@ interface HTMLLabelElement extends HTMLElement { /** * Retrieves a reference to the form that the object is embedded in. */ - readonly form: HTMLFormElement; + readonly form: HTMLFormElement | null; /** * Sets or retrieves the object to which the given label object is assigned. */ @@ -5483,7 +5484,7 @@ interface HTMLLegendElement extends HTMLElement { /** * Retrieves a reference to the form that the object is embedded in. */ - readonly form: HTMLFormElement; + readonly form: HTMLFormElement | null; addEventListener(type: K, listener: (this: HTMLLegendElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -5917,7 +5918,7 @@ interface HTMLObjectElement extends HTMLElement, GetSVGDocument { /** * Retrieves a reference to the form that the object is embedded in. */ - readonly form: HTMLFormElement; + readonly form: HTMLFormElement | null; /** * Sets or retrieves the height of the object. */ @@ -6016,7 +6017,7 @@ interface HTMLOptGroupElement extends HTMLElement { /** * Retrieves a reference to the form that the object is embedded in. */ - readonly form: HTMLFormElement; + readonly form: HTMLFormElement | null; /** * Sets or retrieves the ordinal position of an option in a list box. */ @@ -6055,7 +6056,7 @@ interface HTMLOptionElement extends HTMLElement { /** * Retrieves a reference to the form that the object is embedded in. */ - readonly form: HTMLFormElement; + readonly form: HTMLFormElement | null; /** * Sets or retrieves the ordinal position of an option in a list box. */ @@ -6099,7 +6100,7 @@ declare var HTMLOptionsCollection: { interface HTMLOutputElement extends HTMLElement { defaultValue: string; - readonly form: HTMLFormElement; + readonly form: HTMLFormElement | null; readonly htmlFor: DOMSettableTokenList; name: string; readonly type: string; @@ -6188,7 +6189,7 @@ interface HTMLProgressElement extends HTMLElement { /** * Retrieves a reference to the form that the object is embedded in. */ - readonly form: HTMLFormElement; + readonly form: HTMLFormElement | null; /** * Defines the maximum, or "done" value for a progress element. */ @@ -6274,7 +6275,7 @@ interface HTMLSelectElement extends HTMLElement { /** * Retrieves a reference to the form that the object is embedded in. */ - readonly form: HTMLFormElement; + readonly form: HTMLFormElement | null; /** * Sets or retrieves the number of objects in a collection. */ @@ -6745,7 +6746,7 @@ interface HTMLTextAreaElement extends HTMLElement { /** * Retrieves a reference to the form that the object is embedded in. */ - readonly form: HTMLFormElement; + readonly form: HTMLFormElement | null; /** * Sets or retrieves the maximum number of characters that the user can enter in a text control. */ @@ -7211,6 +7212,7 @@ interface IntersectionObserverEntry { readonly rootBounds: ClientRect; readonly target: Element; readonly time: number; + readonly isIntersecting: boolean; } declare var IntersectionObserverEntry: { @@ -7312,7 +7314,7 @@ interface MediaDevicesEventMap { interface MediaDevices extends EventTarget { ondevicechange: (this: MediaDevices, ev: Event) => any; - enumerateDevices(): any; + enumerateDevices(): Promise; getSupportedConstraints(): MediaTrackSupportedConstraints; getUserMedia(constraints: MediaStreamConstraints): Promise; addEventListener(type: K, listener: (this: MediaDevices, ev: MediaDevicesEventMap[K]) => any, useCapture?: boolean): void; @@ -9058,6 +9060,7 @@ interface Response extends Object, Body { readonly statusText: string; readonly type: ResponseType; readonly url: string; + readonly redirected: boolean; clone(): Response; } @@ -9512,7 +9515,7 @@ interface ServiceWorkerContainer extends EventTarget { onmessage: (this: ServiceWorkerContainer, ev: ServiceWorkerMessageEvent) => any; readonly ready: Promise; getRegistration(clientURL?: USVString): Promise; - getRegistrations(): any; + getRegistrations(): Promise; register(scriptURL: USVString, options?: RegistrationOptions): Promise; addEventListener(type: K, listener: (this: ServiceWorkerContainer, ev: ServiceWorkerContainerEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; @@ -9548,7 +9551,7 @@ interface ServiceWorkerRegistration extends EventTarget { readonly scope: USVString; readonly sync: SyncManager; readonly waiting: ServiceWorker | null; - getNotifications(filter?: GetNotificationOptions): any; + getNotifications(filter?: GetNotificationOptions): Promise; showNotification(title: string, options?: NotificationOptions): Promise; unregister(): Promise; update(): Promise; @@ -11573,7 +11576,7 @@ declare var SVGZoomEvent: { }; interface SyncManager { - getTags(): any; + getTags(): Promise; register(tag: string): Promise; } @@ -11881,6 +11884,7 @@ interface ValidityState { readonly typeMismatch: boolean; readonly valid: boolean; readonly valueMissing: boolean; + readonly tooShort: boolean; } declare var ValidityState: { @@ -13742,13 +13746,13 @@ interface NavigatorUserMedia { interface NodeSelector { querySelector(selectors: K): ElementTagNameMap[K] | null; - querySelector(selectors: string): Element | null; + querySelector(selectors: string): E | null; querySelectorAll(selectors: K): ElementListTagNameMap[K]; - querySelectorAll(selectors: string): NodeListOf; + querySelectorAll(selectors: string): NodeListOf; } interface RandomSource { - getRandomValues(array: ArrayBufferView): ArrayBufferView; + getRandomValues(array: T): T; } interface SVGAnimatedPoints { @@ -13823,17 +13827,37 @@ interface XMLHttpRequestEventTargetEventMap { } interface XMLHttpRequestEventTarget { - onabort: (this: XMLHttpRequestEventTarget, ev: Event) => any; - onerror: (this: XMLHttpRequestEventTarget, ev: ErrorEvent) => any; - onload: (this: XMLHttpRequestEventTarget, ev: Event) => any; - onloadend: (this: XMLHttpRequestEventTarget, ev: ProgressEvent) => any; - onloadstart: (this: XMLHttpRequestEventTarget, ev: Event) => any; - onprogress: (this: XMLHttpRequestEventTarget, ev: ProgressEvent) => any; - ontimeout: (this: XMLHttpRequestEventTarget, ev: ProgressEvent) => any; + onabort: (this: XMLHttpRequest, ev: Event) => any; + onerror: (this: XMLHttpRequest, ev: ErrorEvent) => any; + onload: (this: XMLHttpRequest, ev: Event) => any; + onloadend: (this: XMLHttpRequest, ev: ProgressEvent) => any; + onloadstart: (this: XMLHttpRequest, ev: Event) => any; + onprogress: (this: XMLHttpRequest, ev: ProgressEvent) => any; + ontimeout: (this: XMLHttpRequest, ev: ProgressEvent) => any; addEventListener(type: K, listener: (this: XMLHttpRequestEventTarget, ev: XMLHttpRequestEventTargetEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } +interface BroadcastChannel extends EventTarget { + readonly name: string; + onmessage: (ev: MessageEvent) => any; + onmessageerror: (ev: MessageEvent) => any; + close(): void; + postMessage(message: any): void; + addEventListener(type: K, listener: (this: BroadcastChannel, ev: BroadcastChannelEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var BroadcastChannel: { + prototype: BroadcastChannel; + new(name: string): BroadcastChannel; +}; + +interface BroadcastChannelEventMap { + message: MessageEvent; + messageerror: MessageEvent; +} + interface ErrorEventInit { message?: string; filename?: string; @@ -13924,8 +13948,7 @@ interface BlobPropertyBag { endings?: string; } -interface FilePropertyBag { - type?: string; +interface FilePropertyBag extends BlobPropertyBag { lastModified?: number; } @@ -14201,6 +14224,44 @@ interface TouchEventInit extends EventModifierInit { changedTouches?: Touch[]; } +interface HTMLDialogElement extends HTMLElement { + open: boolean; + returnValue: string; + close(returnValue?: string): void; + show(): void; + showModal(): void; +} + +declare var HTMLDialogElement: { + prototype: HTMLDialogElement; + new(): HTMLDialogElement; +}; + +interface HTMLMainElement extends HTMLElement { +} + +declare var HTMLMainElement: { + prototype: HTMLMainElement; + new(): HTMLMainElement; +}; + +interface HTMLDetailsElement extends HTMLElement { + open: boolean; +} + +declare var HTMLDetailsElement: { + prototype: HTMLDetailsElement; + new(): HTMLDetailsElement; +}; + +interface HTMLSummaryElement extends HTMLElement { +} + +declare var HTMLSummaryElement: { + prototype: HTMLSummaryElement; + new(): HTMLSummaryElement; +}; + declare type EventListenerOrEventListenerObject = EventListener | EventListenerObject; interface DecodeErrorCallback { @@ -14690,7 +14751,7 @@ type GLsizeiptr = number; type GLubyte = number; type GLuint = number; type GLushort = number; -type HeadersInit = any; +type HeadersInit = Headers | string[][]; type IDBKeyPath = string; type KeyFormat = string; type KeyType = string; diff --git a/src/lib/webworker.generated.d.ts b/src/lib/webworker.generated.d.ts index ba358d6402b..38c0cfeefff 100644 --- a/src/lib/webworker.generated.d.ts +++ b/src/lib/webworker.generated.d.ts @@ -37,7 +37,7 @@ interface IDBIndexParameters { interface IDBObjectStoreParameters { autoIncrement?: boolean; - keyPath?: IDBKeyPath; + keyPath?: IDBKeyPath | null; } interface KeyAlgorithm { @@ -74,7 +74,7 @@ interface RequestInit { body?: any; cache?: RequestCache; credentials?: RequestCredentials; - headers?: any; + headers?: Headers | string[][]; integrity?: string; keepalive?: boolean; method?: string; @@ -86,7 +86,7 @@ interface RequestInit { } interface ResponseInit { - headers?: any; + headers?: Headers | string[][]; status?: number; statusText?: string; } @@ -103,18 +103,18 @@ interface ExtendableMessageEventInit extends ExtendableEventInit { data?: any; origin?: string; lastEventId?: string; - source?: Client | ServiceWorker | MessagePort; - ports?: MessagePort[]; + source?: Client | ServiceWorker | MessagePort | null; + ports?: MessagePort[] | null; } interface FetchEventInit extends ExtendableEventInit { - request?: Request; - clientId?: string; + request: Request; + clientId?: string | null; isReload?: boolean; } interface NotificationEventInit extends ExtendableEventInit { - notification?: Notification; + notification: Notification; action?: string; } @@ -123,7 +123,7 @@ interface PushEventInit extends ExtendableEventInit { } interface SyncEventInit extends ExtendableEventInit { - tag?: string; + tag: string; lastChance?: boolean; } @@ -175,9 +175,9 @@ interface Cache { add(request: RequestInfo): Promise; addAll(requests: RequestInfo[]): Promise; delete(request: RequestInfo, options?: CacheQueryOptions): Promise; - keys(request?: RequestInfo, options?: CacheQueryOptions): any; + keys(request?: RequestInfo, options?: CacheQueryOptions): Promise; match(request: RequestInfo, options?: CacheQueryOptions): Promise; - matchAll(request?: RequestInfo, options?: CacheQueryOptions): any; + matchAll(request?: RequestInfo, options?: CacheQueryOptions): Promise; put(request: RequestInfo, response: Response): Promise; } @@ -189,7 +189,7 @@ declare var Cache: { interface CacheStorage { delete(cacheName: string): Promise; has(cacheName: string): Promise; - keys(): any; + keys(): Promise; match(request: RequestInfo, options?: CacheQueryOptions): Promise; open(cacheName: string): Promise; } @@ -314,7 +314,7 @@ interface DOMException { declare var DOMException: { prototype: DOMException; - new(): DOMException; + new(message?: string, name?: string): DOMException; readonly ABORT_ERR: number; readonly DATA_CLONE_ERR: number; readonly DOMSTRING_SIZE_ERR: number; @@ -470,7 +470,7 @@ interface Headers { declare var Headers: { prototype: Headers; - new(init?: any): Headers; + new(init?: Headers | string[][]): Headers; }; interface IDBCursor { @@ -960,6 +960,7 @@ interface Response extends Object, Body { readonly statusText: string; readonly type: ResponseType; readonly url: string; + readonly redirected: boolean; clone(): Response; } @@ -1000,7 +1001,7 @@ interface ServiceWorkerRegistration extends EventTarget { readonly scope: USVString; readonly sync: SyncManager; readonly waiting: ServiceWorker | null; - getNotifications(filter?: GetNotificationOptions): any; + getNotifications(filter?: GetNotificationOptions): Promise; showNotification(title: string, options?: NotificationOptions): Promise; unregister(): Promise; update(): Promise; @@ -1014,7 +1015,7 @@ declare var ServiceWorkerRegistration: { }; interface SyncManager { - getTags(): any; + getTags(): Promise; register(tag: string): Promise; } @@ -1248,13 +1249,13 @@ interface XMLHttpRequestEventTargetEventMap { } interface XMLHttpRequestEventTarget { - onabort: (this: XMLHttpRequestEventTarget, ev: Event) => any; - onerror: (this: XMLHttpRequestEventTarget, ev: ErrorEvent) => any; - onload: (this: XMLHttpRequestEventTarget, ev: Event) => any; - onloadend: (this: XMLHttpRequestEventTarget, ev: ProgressEvent) => any; - onloadstart: (this: XMLHttpRequestEventTarget, ev: Event) => any; - onprogress: (this: XMLHttpRequestEventTarget, ev: ProgressEvent) => any; - ontimeout: (this: XMLHttpRequestEventTarget, ev: ProgressEvent) => any; + onabort: (this: XMLHttpRequest, ev: Event) => any; + onerror: (this: XMLHttpRequest, ev: ErrorEvent) => any; + onload: (this: XMLHttpRequest, ev: Event) => any; + onloadend: (this: XMLHttpRequest, ev: ProgressEvent) => any; + onloadstart: (this: XMLHttpRequest, ev: Event) => any; + onprogress: (this: XMLHttpRequest, ev: ProgressEvent) => any; + ontimeout: (this: XMLHttpRequest, ev: ProgressEvent) => any; addEventListener(type: K, listener: (this: XMLHttpRequestEventTarget, ev: XMLHttpRequestEventTargetEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -1274,7 +1275,7 @@ declare var Client: { interface Clients { claim(): Promise; get(id: string): Promise; - matchAll(options?: ClientQueryOptions): any; + matchAll(options?: ClientQueryOptions): Promise; openWindow(url: USVString): Promise; } @@ -1499,6 +1500,26 @@ interface WorkerUtils extends Object, WindowBase64 { setTimeout(handler: any, timeout?: any, ...args: any[]): number; } +interface BroadcastChannel extends EventTarget { + readonly name: string; + onmessage: (ev: MessageEvent) => any; + onmessageerror: (ev: MessageEvent) => any; + close(): void; + postMessage(message: any): void; + addEventListener(type: K, listener: (this: BroadcastChannel, ev: BroadcastChannelEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var BroadcastChannel: { + prototype: BroadcastChannel; + new(name: string): BroadcastChannel; +}; + +interface BroadcastChannelEventMap { + message: MessageEvent; + messageerror: MessageEvent; +} + interface ErrorEventInit { message?: string; filename?: string; @@ -1562,8 +1583,7 @@ interface BlobPropertyBag { endings?: string; } -interface FilePropertyBag { - type?: string; +interface FilePropertyBag extends BlobPropertyBag { lastModified?: number; } From 26a02860b0e99699e5851b62ff4f3d761bb7780a Mon Sep 17 00:00:00 2001 From: Ron Buckton Date: Wed, 23 Aug 2017 17:09:47 -0700 Subject: [PATCH 130/370] Fix crash when exporting class without name --- src/compiler/transformers/module/module.ts | 2 +- src/compiler/transformers/utilities.ts | 2 +- .../reference/exportClassWithoutName.errors.txt | 8 ++++++++ tests/baselines/reference/exportClassWithoutName.js | 10 ++++++++++ tests/cases/compiler/exportClassWithoutName.ts | 4 ++++ 5 files changed, 24 insertions(+), 2 deletions(-) create mode 100644 tests/baselines/reference/exportClassWithoutName.errors.txt create mode 100644 tests/baselines/reference/exportClassWithoutName.js create mode 100644 tests/cases/compiler/exportClassWithoutName.ts diff --git a/src/compiler/transformers/module/module.ts b/src/compiler/transformers/module/module.ts index 2c3133de6f5..a0f593e5111 100644 --- a/src/compiler/transformers/module/module.ts +++ b/src/compiler/transformers/module/module.ts @@ -1204,7 +1204,7 @@ namespace ts { } if (hasModifier(decl, ModifierFlags.Export)) { - const exportName = hasModifier(decl, ModifierFlags.Default) ? createIdentifier("default") : decl.name; + const exportName = hasModifier(decl, ModifierFlags.Default) ? createIdentifier("default") : getDeclarationName(decl); statements = appendExportStatement(statements, exportName, getLocalName(decl), /*location*/ decl); } diff --git a/src/compiler/transformers/utilities.ts b/src/compiler/transformers/utilities.ts index be99df62b67..f641ee49faf 100644 --- a/src/compiler/transformers/utilities.ts +++ b/src/compiler/transformers/utilities.ts @@ -124,7 +124,7 @@ namespace ts { else { // export class x { } const name = (node).name; - if (!uniqueExports.get(unescapeLeadingUnderscores(name.escapedText))) { + if (name && !uniqueExports.get(unescapeLeadingUnderscores(name.escapedText))) { multiMapSparseArrayAdd(exportedBindings, getOriginalNodeId(node), name); uniqueExports.set(unescapeLeadingUnderscores(name.escapedText), true); exportedNames = append(exportedNames, name); diff --git a/tests/baselines/reference/exportClassWithoutName.errors.txt b/tests/baselines/reference/exportClassWithoutName.errors.txt new file mode 100644 index 00000000000..448a1b2bb03 --- /dev/null +++ b/tests/baselines/reference/exportClassWithoutName.errors.txt @@ -0,0 +1,8 @@ +tests/cases/compiler/exportClassWithoutName.ts(1,1): error TS1211: A class declaration without the 'default' modifier must have a name. + + +==== tests/cases/compiler/exportClassWithoutName.ts (1 errors) ==== + export class { + ~~~~~~ +!!! error TS1211: A class declaration without the 'default' modifier must have a name. + } \ No newline at end of file diff --git a/tests/baselines/reference/exportClassWithoutName.js b/tests/baselines/reference/exportClassWithoutName.js new file mode 100644 index 00000000000..45b4301a812 --- /dev/null +++ b/tests/baselines/reference/exportClassWithoutName.js @@ -0,0 +1,10 @@ +//// [exportClassWithoutName.ts] +export class { +} + +//// [exportClassWithoutName.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +class default_1 { +} +exports.default_1 = default_1; diff --git a/tests/cases/compiler/exportClassWithoutName.ts b/tests/cases/compiler/exportClassWithoutName.ts new file mode 100644 index 00000000000..a83ca9758c7 --- /dev/null +++ b/tests/cases/compiler/exportClassWithoutName.ts @@ -0,0 +1,4 @@ +//@module: commonjs +//@target: es2015 +export class { +} \ No newline at end of file From cd2ea9a12f2bf42fcd4747782b34543a6c36c08c Mon Sep 17 00:00:00 2001 From: Andy Date: Wed, 23 Aug 2017 17:48:01 -0700 Subject: [PATCH 131/370] Update LKG (#17993) --- lib/cancellationToken.js | 2 + lib/lib.d.ts | 10 +- lib/lib.es2015.symbol.wellknown.d.ts | 2 +- lib/lib.es2016.full.d.ts | 1824 +++++++++ lib/lib.es2017.full.d.ts | 1824 +++++++++ lib/lib.es5.d.ts | 10 +- lib/lib.es6.d.ts | 12 +- lib/lib.esnext.full.d.ts | 1824 +++++++++ lib/tsc.js | 3403 +++++++++++++---- lib/tsserver.js | 4465 ++++++++++++++-------- lib/tsserverlibrary.d.ts | 315 +- lib/tsserverlibrary.js | 5145 +++++++++++++++++--------- lib/typescript.d.ts | 85 +- lib/typescript.js | 4464 +++++++++++++++------- lib/typescriptServices.d.ts | 85 +- lib/typescriptServices.js | 4464 +++++++++++++++------- lib/typingsInstaller.js | 1815 +++++++-- 17 files changed, 22392 insertions(+), 7357 deletions(-) diff --git a/lib/cancellationToken.js b/lib/cancellationToken.js index 0e37b0689e0..ec9453bb00c 100644 --- a/lib/cancellationToken.js +++ b/lib/cancellationToken.js @@ -69,3 +69,5 @@ function createCancellationToken(args) { } } module.exports = createCancellationToken; + +//# sourceMappingURL=cancellationToken.js.map diff --git a/lib/lib.d.ts b/lib/lib.d.ts index 1a8b1d72833..c99bf56ef43 100644 --- a/lib/lib.d.ts +++ b/lib/lib.d.ts @@ -236,7 +236,7 @@ interface ObjectConstructor { * Returns the names of the enumerable properties and methods of an object. * @param o Object that contains the properties and methods. This can be an object that you created or an existing Document Object Model (DOM) object. */ - keys(o: any): string[]; + keys(o: {}): string[]; } /** @@ -1000,12 +1000,12 @@ interface ReadonlyArray { * Combines two or more arrays. * @param items Additional items to add to the end of array1. */ - concat(...items: T[][]): T[]; + concat(...items: ReadonlyArray[]): T[]; /** * Combines two or more arrays. * @param items Additional items to add to the end of array1. */ - concat(...items: (T | T[])[]): T[]; + concat(...items: (T | ReadonlyArray)[]): T[]; /** * Adds all the elements of an array separated by the specified separator string. * @param separator A string used to separate one element of an array from the next in the resulting String. If omitted, the array elements are separated with a comma. @@ -1119,12 +1119,12 @@ interface Array { * Combines two or more arrays. * @param items Additional items to add to the end of array1. */ - concat(...items: T[][]): T[]; + concat(...items: ReadonlyArray[]): T[]; /** * Combines two or more arrays. * @param items Additional items to add to the end of array1. */ - concat(...items: (T | T[])[]): T[]; + concat(...items: (T | ReadonlyArray)[]): T[]; /** * Adds all the elements of an array separated by the specified separator string. * @param separator A string used to separate one element of an array from the next in the resulting String. If omitted, the array elements are separated with a comma. diff --git a/lib/lib.es2015.symbol.wellknown.d.ts b/lib/lib.es2015.symbol.wellknown.d.ts index 1d17534723a..f323260bf89 100644 --- a/lib/lib.es2015.symbol.wellknown.d.ts +++ b/lib/lib.es2015.symbol.wellknown.d.ts @@ -130,7 +130,7 @@ interface Map { readonly [Symbol.toStringTag]: "Map"; } -interface WeakMap{ +interface WeakMap { readonly [Symbol.toStringTag]: "WeakMap"; } diff --git a/lib/lib.es2016.full.d.ts b/lib/lib.es2016.full.d.ts index 09220599d5f..07c6a3e8283 100644 --- a/lib/lib.es2016.full.d.ts +++ b/lib/lib.es2016.full.d.ts @@ -21,6 +21,1830 @@ and limitations under the License. /// /// +declare type PropertyKey = string | number | symbol; + +interface Array { + /** + * Returns the value of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ + find(predicate: (this: void, value: T, index: number, obj: Array) => boolean): T | undefined; + find(predicate: (this: void, value: T, index: number, obj: Array) => boolean, thisArg: undefined): T | undefined; + find(predicate: (this: Z, value: T, index: number, obj: Array) => boolean, thisArg: Z): T | undefined; + + /** + * Returns the index of the first element in the array where predicate is true, and -1 + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, + * findIndex immediately returns that element index. Otherwise, findIndex returns -1. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ + findIndex(predicate: (this: void, value: T, index: number, obj: Array) => boolean): number; + findIndex(predicate: (this: void, value: T, index: number, obj: Array) => boolean, thisArg: undefined): number; + findIndex(predicate: (this: Z, value: T, index: number, obj: Array) => boolean, thisArg: Z): number; + + /** + * Returns the this object after filling the section identified by start and end with value + * @param value value to fill array section with + * @param start index to start filling the array at. If start is negative, it is treated as + * length+start where length is the length of the array. + * @param end index to stop filling the array at. If end is negative, it is treated as + * length+end. + */ + fill(value: T, start?: number, end?: number): this; + + /** + * Returns the this object after copying a section of the array identified by start and end + * to the same array starting at position target + * @param target If target is negative, it is treated as length+target where length is the + * length of the array. + * @param start If start is negative, it is treated as length+start. If end is negative, it + * is treated as length+end. + * @param end If not specified, length of the this object is used as its default value. + */ + copyWithin(target: number, start: number, end?: number): this; +} + +interface ArrayConstructor { + /** + * Creates an array from an array-like object. + * @param arrayLike An array-like object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ + from(arrayLike: ArrayLike, mapfn: (this: void, v: T, k: number) => U): Array; + from(arrayLike: ArrayLike, mapfn: (this: void, v: T, k: number) => U, thisArg: undefined): Array; + from(arrayLike: ArrayLike, mapfn: (this: Z, v: T, k: number) => U, thisArg: Z): Array; + + + /** + * Creates an array from an array-like object. + * @param arrayLike An array-like object to convert to an array. + */ + from(arrayLike: ArrayLike): Array; + + /** + * Returns a new array from a set of elements. + * @param items A set of elements to include in the new array object. + */ + of(...items: T[]): Array; +} + +interface DateConstructor { + new (value: Date): Date; +} + +interface Function { + /** + * Returns the name of the function. Function names are read-only and can not be changed. + */ + readonly name: string; +} + +interface Math { + /** + * Returns the number of leading zero bits in the 32-bit binary representation of a number. + * @param x A numeric expression. + */ + clz32(x: number): number; + + /** + * Returns the result of 32-bit multiplication of two numbers. + * @param x First number + * @param y Second number + */ + imul(x: number, y: number): number; + + /** + * Returns the sign of the x, indicating whether x is positive, negative or zero. + * @param x The numeric expression to test + */ + sign(x: number): number; + + /** + * Returns the base 10 logarithm of a number. + * @param x A numeric expression. + */ + log10(x: number): number; + + /** + * Returns the base 2 logarithm of a number. + * @param x A numeric expression. + */ + log2(x: number): number; + + /** + * Returns the natural logarithm of 1 + x. + * @param x A numeric expression. + */ + log1p(x: number): number; + + /** + * Returns the result of (e^x - 1) of x (e raised to the power of x, where e is the base of + * the natural logarithms). + * @param x A numeric expression. + */ + expm1(x: number): number; + + /** + * Returns the hyperbolic cosine of a number. + * @param x A numeric expression that contains an angle measured in radians. + */ + cosh(x: number): number; + + /** + * Returns the hyperbolic sine of a number. + * @param x A numeric expression that contains an angle measured in radians. + */ + sinh(x: number): number; + + /** + * Returns the hyperbolic tangent of a number. + * @param x A numeric expression that contains an angle measured in radians. + */ + tanh(x: number): number; + + /** + * Returns the inverse hyperbolic cosine of a number. + * @param x A numeric expression that contains an angle measured in radians. + */ + acosh(x: number): number; + + /** + * Returns the inverse hyperbolic sine of a number. + * @param x A numeric expression that contains an angle measured in radians. + */ + asinh(x: number): number; + + /** + * Returns the inverse hyperbolic tangent of a number. + * @param x A numeric expression that contains an angle measured in radians. + */ + atanh(x: number): number; + + /** + * Returns the square root of the sum of squares of its arguments. + * @param values Values to compute the square root for. + * If no arguments are passed, the result is +0. + * If there is only one argument, the result is the absolute value. + * If any argument is +Infinity or -Infinity, the result is +Infinity. + * If any argument is NaN, the result is NaN. + * If all arguments are either +0 or −0, the result is +0. + */ + hypot(...values: number[] ): number; + + /** + * Returns the integral part of the a numeric expression, x, removing any fractional digits. + * If x is already an integer, the result is x. + * @param x A numeric expression. + */ + trunc(x: number): number; + + /** + * Returns the nearest single precision float representation of a number. + * @param x A numeric expression. + */ + fround(x: number): number; + + /** + * Returns an implementation-dependent approximation to the cube root of number. + * @param x A numeric expression. + */ + cbrt(x: number): number; +} + +interface NumberConstructor { + /** + * The value of Number.EPSILON is the difference between 1 and the smallest value greater than 1 + * that is representable as a Number value, which is approximately: + * 2.2204460492503130808472633361816 x 10‍−‍16. + */ + readonly EPSILON: number; + + /** + * Returns true if passed value is finite. + * Unlike the global isFinite, Number.isFinite doesn't forcibly convert the parameter to a + * number. Only finite values of the type number, result in true. + * @param number A numeric value. + */ + isFinite(number: number): boolean; + + /** + * Returns true if the value passed is an integer, false otherwise. + * @param number A numeric value. + */ + isInteger(number: number): boolean; + + /** + * Returns a Boolean value that indicates whether a value is the reserved value NaN (not a + * number). Unlike the global isNaN(), Number.isNaN() doesn't forcefully convert the parameter + * to a number. Only values of the type number, that are also NaN, result in true. + * @param number A numeric value. + */ + isNaN(number: number): boolean; + + /** + * Returns true if the value passed is a safe integer. + * @param number A numeric value. + */ + isSafeInteger(number: number): boolean; + + /** + * The value of the largest integer n such that n and n + 1 are both exactly representable as + * a Number value. + * The value of Number.MAX_SAFE_INTEGER is 9007199254740991 2^53 − 1. + */ + readonly MAX_SAFE_INTEGER: number; + + /** + * The value of the smallest integer n such that n and n − 1 are both exactly representable as + * a Number value. + * The value of Number.MIN_SAFE_INTEGER is −9007199254740991 (−(2^53 − 1)). + */ + readonly MIN_SAFE_INTEGER: number; + + /** + * Converts a string to a floating-point number. + * @param string A string that contains a floating-point number. + */ + parseFloat(string: string): number; + + /** + * Converts A string to an integer. + * @param s A string to convert into a number. + * @param radix A value between 2 and 36 that specifies the base of the number in numString. + * If this argument is not supplied, strings with a prefix of '0x' are considered hexadecimal. + * All other strings are considered decimal. + */ + parseInt(string: string, radix?: number): number; +} + +interface Object { + /** + * Determines whether an object has a property with the specified name. + * @param v A property name. + */ + hasOwnProperty(v: PropertyKey): boolean; + + /** + * Determines whether a specified property is enumerable. + * @param v A property name. + */ + propertyIsEnumerable(v: PropertyKey): boolean; +} + +interface ObjectConstructor { + /** + * Copy the values of all of the enumerable own properties from one or more source objects to a + * target object. Returns the target object. + * @param target The target object to copy to. + * @param source The source object from which to copy properties. + */ + assign(target: T, source: U): T & U; + + /** + * Copy the values of all of the enumerable own properties from one or more source objects to a + * target object. Returns the target object. + * @param target The target object to copy to. + * @param source1 The first source object from which to copy properties. + * @param source2 The second source object from which to copy properties. + */ + assign(target: T, source1: U, source2: V): T & U & V; + + /** + * Copy the values of all of the enumerable own properties from one or more source objects to a + * target object. Returns the target object. + * @param target The target object to copy to. + * @param source1 The first source object from which to copy properties. + * @param source2 The second source object from which to copy properties. + * @param source3 The third source object from which to copy properties. + */ + assign(target: T, source1: U, source2: V, source3: W): T & U & V & W; + + /** + * Copy the values of all of the enumerable own properties from one or more source objects to a + * target object. Returns the target object. + * @param target The target object to copy to. + * @param sources One or more source objects from which to copy properties + */ + assign(target: object, ...sources: any[]): any; + + /** + * Returns an array of all symbol properties found directly on object o. + * @param o Object to retrieve the symbols from. + */ + getOwnPropertySymbols(o: any): symbol[]; + + /** + * Returns true if the values are the same value, false otherwise. + * @param value1 The first value. + * @param value2 The second value. + */ + is(value1: any, value2: any): boolean; + + /** + * Sets the prototype of a specified object o to object proto or null. Returns the object o. + * @param o The object to change its prototype. + * @param proto The value of the new prototype or null. + */ + setPrototypeOf(o: any, proto: object | null): any; + + /** + * Gets the own property descriptor of the specified object. + * An own property descriptor is one that is defined directly on the object and is not + * inherited from the object's prototype. + * @param o Object that contains the property. + * @param p Name of the property. + */ + getOwnPropertyDescriptor(o: any, propertyKey: PropertyKey): PropertyDescriptor; + + /** + * Adds a property to an object, or modifies attributes of an existing property. + * @param o Object on which to add or modify the property. This can be a native JavaScript + * object (that is, a user-defined object or a built in object) or a DOM object. + * @param p The property name. + * @param attributes Descriptor for the property. It can be for a data property or an accessor + * property. + */ + defineProperty(o: any, propertyKey: PropertyKey, attributes: PropertyDescriptor): any; +} + +interface ReadonlyArray { + /** + * Returns the value of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ + find(predicate: (this: void, value: T, index: number, obj: ReadonlyArray) => boolean): T | undefined; + find(predicate: (this: void, value: T, index: number, obj: ReadonlyArray) => boolean, thisArg: undefined): T | undefined; + find(predicate: (this: Z, value: T, index: number, obj: ReadonlyArray) => boolean, thisArg: Z): T | undefined; + + /** + * Returns the index of the first element in the array where predicate is true, and -1 + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, + * findIndex immediately returns that element index. Otherwise, findIndex returns -1. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ + findIndex(predicate: (this: void, value: T, index: number, obj: Array) => boolean): number; + findIndex(predicate: (this: void, value: T, index: number, obj: Array) => boolean, thisArg: undefined): number; + findIndex(predicate: (this: Z, value: T, index: number, obj: Array) => boolean, thisArg: Z): number; +} + +interface RegExp { + /** + * Returns a string indicating the flags of the regular expression in question. This field is read-only. + * The characters in this string are sequenced and concatenated in the following order: + * + * - "g" for global + * - "i" for ignoreCase + * - "m" for multiline + * - "u" for unicode + * - "y" for sticky + * + * If no flags are set, the value is the empty string. + */ + readonly flags: string; + + /** + * Returns a Boolean value indicating the state of the sticky flag (y) used with a regular + * expression. Default is false. Read-only. + */ + readonly sticky: boolean; + + /** + * Returns a Boolean value indicating the state of the Unicode flag (u) used with a regular + * expression. Default is false. Read-only. + */ + readonly unicode: boolean; +} + +interface RegExpConstructor { + new (pattern: RegExp, flags?: string): RegExp; + (pattern: RegExp, flags?: string): RegExp; +} + +interface String { + /** + * Returns a nonnegative integer Number less than 1114112 (0x110000) that is the code point + * value of the UTF-16 encoded code point starting at the string element at position pos in + * the String resulting from converting this object to a String. + * If there is no element at that position, the result is undefined. + * If a valid UTF-16 surrogate pair does not begin at pos, the result is the code unit at pos. + */ + codePointAt(pos: number): number | undefined; + + /** + * Returns true if searchString appears as a substring of the result of converting this + * object to a String, at one or more positions that are + * greater than or equal to position; otherwise, returns false. + * @param searchString search string + * @param position If position is undefined, 0 is assumed, so as to search all of the String. + */ + includes(searchString: string, position?: number): boolean; + + /** + * Returns true if the sequence of elements of searchString converted to a String is the + * same as the corresponding elements of this object (converted to a String) starting at + * endPosition – length(this). Otherwise returns false. + */ + endsWith(searchString: string, endPosition?: number): boolean; + + /** + * Returns the String value result of normalizing the string into the normalization form + * named by form as specified in Unicode Standard Annex #15, Unicode Normalization Forms. + * @param form Applicable values: "NFC", "NFD", "NFKC", or "NFKD", If not specified default + * is "NFC" + */ + normalize(form: "NFC" | "NFD" | "NFKC" | "NFKD"): string; + + /** + * Returns the String value result of normalizing the string into the normalization form + * named by form as specified in Unicode Standard Annex #15, Unicode Normalization Forms. + * @param form Applicable values: "NFC", "NFD", "NFKC", or "NFKD", If not specified default + * is "NFC" + */ + normalize(form?: string): string; + + /** + * Returns a String value that is made from count copies appended together. If count is 0, + * T is the empty String is returned. + * @param count number of copies to append + */ + repeat(count: number): string; + + /** + * Returns true if the sequence of elements of searchString converted to a String is the + * same as the corresponding elements of this object (converted to a String) starting at + * position. Otherwise returns false. + */ + startsWith(searchString: string, position?: number): boolean; + + /** + * Returns an HTML anchor element and sets the name attribute to the text value + * @param name + */ + anchor(name: string): string; + + /** Returns a HTML element */ + big(): string; + + /** Returns a HTML element */ + blink(): string; + + /** Returns a HTML element */ + bold(): string; + + /** Returns a HTML element */ + fixed(): string; + + /** Returns a HTML element and sets the color attribute value */ + fontcolor(color: string): string; + + /** Returns a HTML element and sets the size attribute value */ + fontsize(size: number): string; + + /** Returns a HTML element and sets the size attribute value */ + fontsize(size: string): string; + + /** Returns an HTML element */ + italics(): string; + + /** Returns an HTML element and sets the href attribute value */ + link(url: string): string; + + /** Returns a HTML element */ + small(): string; + + /** Returns a HTML element */ + strike(): string; + + /** Returns a HTML element */ + sub(): string; + + /** Returns a HTML element */ + sup(): string; +} + +interface StringConstructor { + /** + * Return the String value whose elements are, in order, the elements in the List elements. + * If length is 0, the empty string is returned. + */ + fromCodePoint(...codePoints: number[]): string; + + /** + * String.raw is intended for use as a tag function of a Tagged Template String. When called + * as such the first argument will be a well formed template call site object and the rest + * parameter will contain the substitution values. + * @param template A well-formed template string call site representation. + * @param substitutions A set of substitution values. + */ + raw(template: TemplateStringsArray, ...substitutions: any[]): string; +} + + +interface Map { + clear(): void; + delete(key: K): boolean; + forEach(callbackfn: (value: V, key: K, map: Map) => void, thisArg?: any): void; + get(key: K): V | undefined; + has(key: K): boolean; + set(key: K, value: V): this; + readonly size: number; +} + +interface MapConstructor { + new (): Map; + new (entries?: [K, V][]): Map; + readonly prototype: Map; +} +declare var Map: MapConstructor; + +interface ReadonlyMap { + forEach(callbackfn: (value: V, key: K, map: ReadonlyMap) => void, thisArg?: any): void; + get(key: K): V | undefined; + has(key: K): boolean; + readonly size: number; +} + +interface WeakMap { + delete(key: K): boolean; + get(key: K): V | undefined; + has(key: K): boolean; + set(key: K, value: V): this; +} + +interface WeakMapConstructor { + new (): WeakMap; + new (entries?: [K, V][]): WeakMap; + readonly prototype: WeakMap; +} +declare var WeakMap: WeakMapConstructor; + +interface Set { + add(value: T): this; + clear(): void; + delete(value: T): boolean; + forEach(callbackfn: (value: T, value2: T, set: Set) => void, thisArg?: any): void; + has(value: T): boolean; + readonly size: number; +} + +interface SetConstructor { + new (): Set; + new (values?: T[]): Set; + readonly prototype: Set; +} +declare var Set: SetConstructor; + +interface ReadonlySet { + forEach(callbackfn: (value: T, value2: T, set: ReadonlySet) => void, thisArg?: any): void; + has(value: T): boolean; + readonly size: number; +} + +interface WeakSet { + add(value: T): this; + delete(value: T): boolean; + has(value: T): boolean; +} + +interface WeakSetConstructor { + new (): WeakSet; + new (values?: T[]): WeakSet; + readonly prototype: WeakSet; +} +declare var WeakSet: WeakSetConstructor; + + +interface Generator extends Iterator { } + +interface GeneratorFunction { + /** + * Creates a new Generator object. + * @param args A list of arguments the function accepts. + */ + new (...args: any[]): Generator; + /** + * Creates a new Generator object. + * @param args A list of arguments the function accepts. + */ + (...args: any[]): Generator; + /** + * The length of the arguments. + */ + readonly length: number; + /** + * Returns the name of the function. + */ + readonly name: string; + /** + * A reference to the prototype. + */ + readonly prototype: Generator; +} + +interface GeneratorFunctionConstructor { + /** + * Creates a new Generator function. + * @param args A list of arguments the function accepts. + */ + new (...args: string[]): GeneratorFunction; + /** + * Creates a new Generator function. + * @param args A list of arguments the function accepts. + */ + (...args: string[]): GeneratorFunction; + /** + * The length of the arguments. + */ + readonly length: number; + /** + * Returns the name of the function. + */ + readonly name: string; + /** + * A reference to the prototype. + */ + readonly prototype: GeneratorFunction; +} +declare var GeneratorFunction: GeneratorFunctionConstructor; + + +/// + +interface SymbolConstructor { + /** + * A method that returns the default iterator for an object. Called by the semantics of the + * for-of statement. + */ + readonly iterator: symbol; +} + +interface IteratorResult { + done: boolean; + value: T; +} + +interface Iterator { + next(value?: any): IteratorResult; + return?(value?: any): IteratorResult; + throw?(e?: any): IteratorResult; +} + +interface Iterable { + [Symbol.iterator](): Iterator; +} + +interface IterableIterator extends Iterator { + [Symbol.iterator](): IterableIterator; +} + +interface Array { + /** Iterator */ + [Symbol.iterator](): IterableIterator; + + /** + * Returns an iterable of key, value pairs for every entry in the array + */ + entries(): IterableIterator<[number, T]>; + + /** + * Returns an iterable of keys in the array + */ + keys(): IterableIterator; + + /** + * Returns an iterable of values in the array + */ + values(): IterableIterator; +} + +interface ArrayConstructor { + /** + * Creates an array from an iterable object. + * @param iterable An iterable object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ + from(iterable: Iterable, mapfn: (this: void, v: T, k: number) => U): Array; + from(iterable: Iterable, mapfn: (this: void, v: T, k: number) => U, thisArg: undefined): Array; + from(iterable: Iterable, mapfn: (this: Z, v: T, k: number) => U, thisArg: Z): Array; + + /** + * Creates an array from an iterable object. + * @param iterable An iterable object to convert to an array. + */ + from(iterable: Iterable): Array; +} + +interface ReadonlyArray { + /** Iterator of values in the array. */ + [Symbol.iterator](): IterableIterator; + + /** + * Returns an iterable of key, value pairs for every entry in the array + */ + entries(): IterableIterator<[number, T]>; + + /** + * Returns an iterable of keys in the array + */ + keys(): IterableIterator; + + /** + * Returns an iterable of values in the array + */ + values(): IterableIterator; +} + +interface IArguments { + /** Iterator */ + [Symbol.iterator](): IterableIterator; +} + +interface Map { + /** Returns an iterable of entries in the map. */ + [Symbol.iterator](): IterableIterator<[K, V]>; + + /** + * Returns an iterable of key, value pairs for every entry in the map. + */ + entries(): IterableIterator<[K, V]>; + + /** + * Returns an iterable of keys in the map + */ + keys(): IterableIterator; + + /** + * Returns an iterable of values in the map + */ + values(): IterableIterator; +} + +interface ReadonlyMap { + /** Returns an iterable of entries in the map. */ + [Symbol.iterator](): IterableIterator<[K, V]>; + + /** + * Returns an iterable of key, value pairs for every entry in the map. + */ + entries(): IterableIterator<[K, V]>; + + /** + * Returns an iterable of keys in the map + */ + keys(): IterableIterator; + + /** + * Returns an iterable of values in the map + */ + values(): IterableIterator; +} + +interface MapConstructor { + new (iterable: Iterable<[K, V]>): Map; +} + +interface WeakMap { } + +interface WeakMapConstructor { + new (iterable: Iterable<[K, V]>): WeakMap; +} + +interface Set { + /** Iterates over values in the set. */ + [Symbol.iterator](): IterableIterator; + /** + * Returns an iterable of [v,v] pairs for every value `v` in the set. + */ + entries(): IterableIterator<[T, T]>; + /** + * Despite its name, returns an iterable of the values in the set, + */ + keys(): IterableIterator; + + /** + * Returns an iterable of values in the set. + */ + values(): IterableIterator; +} + +interface ReadonlySet { + /** Iterates over values in the set. */ + [Symbol.iterator](): IterableIterator; + + /** + * Returns an iterable of [v,v] pairs for every value `v` in the set. + */ + entries(): IterableIterator<[T, T]>; + + /** + * Despite its name, returns an iterable of the values in the set, + */ + keys(): IterableIterator; + + /** + * Returns an iterable of values in the set. + */ + values(): IterableIterator; +} + +interface SetConstructor { + new (iterable: Iterable): Set; +} + +interface WeakSet { } + +interface WeakSetConstructor { + new (iterable: Iterable): WeakSet; +} + +interface Promise { } + +interface PromiseConstructor { + /** + * Creates a Promise that is resolved with an array of results when all of the provided Promises + * resolve, or rejected when any Promise is rejected. + * @param values An array of Promises. + * @returns A new Promise. + */ + all(values: Iterable>): Promise; + + /** + * Creates a Promise that is resolved or rejected when any of the provided Promises are resolved + * or rejected. + * @param values An array of Promises. + * @returns A new Promise. + */ + race(values: Iterable>): Promise; +} + +declare namespace Reflect { + function enumerate(target: object): IterableIterator; +} + +interface String { + /** Iterator */ + [Symbol.iterator](): IterableIterator; +} + +/** + * A typed array of 8-bit integer values. The contents are initialized to 0. If the requested + * number of bytes could not be allocated an exception is raised. + */ +interface Int8Array { + [Symbol.iterator](): IterableIterator; + /** + * Returns an array of key, value pairs for every entry in the array + */ + entries(): IterableIterator<[number, number]>; + /** + * Returns an list of keys in the array + */ + keys(): IterableIterator; + /** + * Returns an list of values in the array + */ + values(): IterableIterator; +} + +interface Int8ArrayConstructor { + new (elements: Iterable): Int8Array; + + /** + * Creates an array from an array-like or iterable object. + * @param arrayLike An array-like or iterable object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ + from(arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Int8Array; + from(arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Int8Array; + from(arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Int8Array; + + from(arrayLike: Iterable): Int8Array; +} + +/** + * A typed array of 8-bit unsigned integer values. The contents are initialized to 0. If the + * requested number of bytes could not be allocated an exception is raised. + */ +interface Uint8Array { + [Symbol.iterator](): IterableIterator; + /** + * Returns an array of key, value pairs for every entry in the array + */ + entries(): IterableIterator<[number, number]>; + /** + * Returns an list of keys in the array + */ + keys(): IterableIterator; + /** + * Returns an list of values in the array + */ + values(): IterableIterator; +} + +interface Uint8ArrayConstructor { + new (elements: Iterable): Uint8Array; + + /** + * Creates an array from an array-like or iterable object. + * @param arrayLike An array-like or iterable object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ + from(arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Uint8Array; + from(arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Uint8Array; + from(arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint8Array; + + from(arrayLike: Iterable): Uint8Array; +} + +/** + * A typed array of 8-bit unsigned integer (clamped) values. The contents are initialized to 0. + * If the requested number of bytes could not be allocated an exception is raised. + */ +interface Uint8ClampedArray { + [Symbol.iterator](): IterableIterator; + /** + * Returns an array of key, value pairs for every entry in the array + */ + entries(): IterableIterator<[number, number]>; + + /** + * Returns an list of keys in the array + */ + keys(): IterableIterator; + + /** + * Returns an list of values in the array + */ + values(): IterableIterator; +} + +interface Uint8ClampedArrayConstructor { + new (elements: Iterable): Uint8ClampedArray; + + + /** + * Creates an array from an array-like or iterable object. + * @param arrayLike An array-like or iterable object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ + from(arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Uint8ClampedArray; + from(arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Uint8ClampedArray; + from(arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint8ClampedArray; + + from(arrayLike: Iterable): Uint8ClampedArray; +} + +/** + * A typed array of 16-bit signed integer values. The contents are initialized to 0. If the + * requested number of bytes could not be allocated an exception is raised. + */ +interface Int16Array { + [Symbol.iterator](): IterableIterator; + /** + * Returns an array of key, value pairs for every entry in the array + */ + entries(): IterableIterator<[number, number]>; + + /** + * Returns an list of keys in the array + */ + keys(): IterableIterator; + + /** + * Returns an list of values in the array + */ + values(): IterableIterator; +} + +interface Int16ArrayConstructor { + new (elements: Iterable): Int16Array; + + /** + * Creates an array from an array-like or iterable object. + * @param arrayLike An array-like or iterable object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ + from(arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Int16Array; + from(arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Int16Array; + from(arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Int16Array; + + from(arrayLike: Iterable): Int16Array; +} + +/** + * A typed array of 16-bit unsigned integer values. The contents are initialized to 0. If the + * requested number of bytes could not be allocated an exception is raised. + */ +interface Uint16Array { + [Symbol.iterator](): IterableIterator; + /** + * Returns an array of key, value pairs for every entry in the array + */ + entries(): IterableIterator<[number, number]>; + /** + * Returns an list of keys in the array + */ + keys(): IterableIterator; + /** + * Returns an list of values in the array + */ + values(): IterableIterator; +} + +interface Uint16ArrayConstructor { + new (elements: Iterable): Uint16Array; + + /** + * Creates an array from an array-like or iterable object. + * @param arrayLike An array-like or iterable object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ + from(arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Uint16Array; + from(arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Uint16Array; + from(arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint16Array; + + from(arrayLike: Iterable): Uint16Array; +} + +/** + * A typed array of 32-bit signed integer values. The contents are initialized to 0. If the + * requested number of bytes could not be allocated an exception is raised. + */ +interface Int32Array { + [Symbol.iterator](): IterableIterator; + /** + * Returns an array of key, value pairs for every entry in the array + */ + entries(): IterableIterator<[number, number]>; + /** + * Returns an list of keys in the array + */ + keys(): IterableIterator; + /** + * Returns an list of values in the array + */ + values(): IterableIterator; +} + +interface Int32ArrayConstructor { + new (elements: Iterable): Int32Array; + + /** + * Creates an array from an array-like or iterable object. + * @param arrayLike An array-like or iterable object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ + from(arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Int32Array; + from(arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Int32Array; + from(arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Int32Array; + + from(arrayLike: Iterable): Int32Array; +} + +/** + * A typed array of 32-bit unsigned integer values. The contents are initialized to 0. If the + * requested number of bytes could not be allocated an exception is raised. + */ +interface Uint32Array { + [Symbol.iterator](): IterableIterator; + /** + * Returns an array of key, value pairs for every entry in the array + */ + entries(): IterableIterator<[number, number]>; + /** + * Returns an list of keys in the array + */ + keys(): IterableIterator; + /** + * Returns an list of values in the array + */ + values(): IterableIterator; +} + +interface Uint32ArrayConstructor { + new (elements: Iterable): Uint32Array; + + /** + * Creates an array from an array-like or iterable object. + * @param arrayLike An array-like or iterable object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ + from(arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Uint32Array; + from(arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Uint32Array; + from(arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint32Array; + + from(arrayLike: Iterable): Uint32Array; +} + +/** + * A typed array of 32-bit float values. The contents are initialized to 0. If the requested number + * of bytes could not be allocated an exception is raised. + */ +interface Float32Array { + [Symbol.iterator](): IterableIterator; + /** + * Returns an array of key, value pairs for every entry in the array + */ + entries(): IterableIterator<[number, number]>; + /** + * Returns an list of keys in the array + */ + keys(): IterableIterator; + /** + * Returns an list of values in the array + */ + values(): IterableIterator; +} + +interface Float32ArrayConstructor { + new (elements: Iterable): Float32Array; + + /** + * Creates an array from an array-like or iterable object. + * @param arrayLike An array-like or iterable object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ + from(arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Float32Array; + from(arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Float32Array; + from(arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Float32Array; + + from(arrayLike: Iterable): Float32Array; +} + +/** + * A typed array of 64-bit float values. The contents are initialized to 0. If the requested + * number of bytes could not be allocated an exception is raised. + */ +interface Float64Array { + [Symbol.iterator](): IterableIterator; + /** + * Returns an array of key, value pairs for every entry in the array + */ + entries(): IterableIterator<[number, number]>; + /** + * Returns an list of keys in the array + */ + keys(): IterableIterator; + /** + * Returns an list of values in the array + */ + values(): IterableIterator; +} + +interface Float64ArrayConstructor { + new (elements: Iterable): Float64Array; + + /** + * Creates an array from an array-like or iterable object. + * @param arrayLike An array-like or iterable object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ + from(arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Float64Array; + from(arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Float64Array; + from(arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Float64Array; + + from(arrayLike: Iterable): Float64Array; +} + + +interface PromiseConstructor { + /** + * A reference to the prototype. + */ + readonly prototype: Promise; + + /** + * Creates a new Promise. + * @param executor A callback used to initialize the promise. This callback is passed two arguments: + * a resolve callback used resolve the promise with a value or the result of another promise, + * and a reject callback used to reject the promise with a provided reason or error. + */ + new (executor: (resolve: (value?: T | PromiseLike) => void, reject: (reason?: any) => void) => void): Promise; + + /** + * Creates a Promise that is resolved with an array of results when all of the provided Promises + * resolve, or rejected when any Promise is rejected. + * @param values An array of Promises. + * @returns A new Promise. + */ + all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike , T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike, T8 | PromiseLike, T9 | PromiseLike, T10 | PromiseLike]): Promise<[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10]>; + + /** + * Creates a Promise that is resolved with an array of results when all of the provided Promises + * resolve, or rejected when any Promise is rejected. + * @param values An array of Promises. + * @returns A new Promise. + */ + all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike , T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike, T8 | PromiseLike, T9 | PromiseLike]): Promise<[T1, T2, T3, T4, T5, T6, T7, T8, T9]>; + + /** + * Creates a Promise that is resolved with an array of results when all of the provided Promises + * resolve, or rejected when any Promise is rejected. + * @param values An array of Promises. + * @returns A new Promise. + */ + all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike , T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike, T8 | PromiseLike]): Promise<[T1, T2, T3, T4, T5, T6, T7, T8]>; + + /** + * Creates a Promise that is resolved with an array of results when all of the provided Promises + * resolve, or rejected when any Promise is rejected. + * @param values An array of Promises. + * @returns A new Promise. + */ + all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike , T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike]): Promise<[T1, T2, T3, T4, T5, T6, T7]>; + + /** + * Creates a Promise that is resolved with an array of results when all of the provided Promises + * resolve, or rejected when any Promise is rejected. + * @param values An array of Promises. + * @returns A new Promise. + */ + all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike , T5 | PromiseLike, T6 | PromiseLike]): Promise<[T1, T2, T3, T4, T5, T6]>; + + /** + * Creates a Promise that is resolved with an array of results when all of the provided Promises + * resolve, or rejected when any Promise is rejected. + * @param values An array of Promises. + * @returns A new Promise. + */ + all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike , T5 | PromiseLike]): Promise<[T1, T2, T3, T4, T5]>; + + /** + * Creates a Promise that is resolved with an array of results when all of the provided Promises + * resolve, or rejected when any Promise is rejected. + * @param values An array of Promises. + * @returns A new Promise. + */ + all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike ]): Promise<[T1, T2, T3, T4]>; + + /** + * Creates a Promise that is resolved with an array of results when all of the provided Promises + * resolve, or rejected when any Promise is rejected. + * @param values An array of Promises. + * @returns A new Promise. + */ + all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike]): Promise<[T1, T2, T3]>; + + /** + * Creates a Promise that is resolved with an array of results when all of the provided Promises + * resolve, or rejected when any Promise is rejected. + * @param values An array of Promises. + * @returns A new Promise. + */ + all(values: [T1 | PromiseLike, T2 | PromiseLike]): Promise<[T1, T2]>; + + /** + * Creates a Promise that is resolved with an array of results when all of the provided Promises + * resolve, or rejected when any Promise is rejected. + * @param values An array of Promises. + * @returns A new Promise. + */ + all(values: (T | PromiseLike)[]): Promise; + + /** + * Creates a Promise that is resolved or rejected when any of the provided Promises are resolved + * or rejected. + * @param values An array of Promises. + * @returns A new Promise. + */ + race(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike, T8 | PromiseLike, T9 | PromiseLike, T10 | PromiseLike]): Promise; + + /** + * Creates a Promise that is resolved or rejected when any of the provided Promises are resolved + * or rejected. + * @param values An array of Promises. + * @returns A new Promise. + */ + race(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike, T8 | PromiseLike, T9 | PromiseLike]): Promise; + + /** + * Creates a Promise that is resolved or rejected when any of the provided Promises are resolved + * or rejected. + * @param values An array of Promises. + * @returns A new Promise. + */ + race(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike, T8 | PromiseLike]): Promise; + + /** + * Creates a Promise that is resolved or rejected when any of the provided Promises are resolved + * or rejected. + * @param values An array of Promises. + * @returns A new Promise. + */ + race(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike]): Promise; + + /** + * Creates a Promise that is resolved or rejected when any of the provided Promises are resolved + * or rejected. + * @param values An array of Promises. + * @returns A new Promise. + */ + race(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike]): Promise; + + /** + * Creates a Promise that is resolved or rejected when any of the provided Promises are resolved + * or rejected. + * @param values An array of Promises. + * @returns A new Promise. + */ + race(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike]): Promise; + + /** + * Creates a Promise that is resolved or rejected when any of the provided Promises are resolved + * or rejected. + * @param values An array of Promises. + * @returns A new Promise. + */ + race(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike]): Promise; + + /** + * Creates a Promise that is resolved or rejected when any of the provided Promises are resolved + * or rejected. + * @param values An array of Promises. + * @returns A new Promise. + */ + race(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike]): Promise; + + /** + * Creates a Promise that is resolved or rejected when any of the provided Promises are resolved + * or rejected. + * @param values An array of Promises. + * @returns A new Promise. + */ + race(values: [T1 | PromiseLike, T2 | PromiseLike]): Promise; + + /** + * Creates a Promise that is resolved or rejected when any of the provided Promises are resolved + * or rejected. + * @param values An array of Promises. + * @returns A new Promise. + */ + race(values: (T | PromiseLike)[]): Promise; + + /** + * Creates a new rejected promise for the provided reason. + * @param reason The reason the promise was rejected. + * @returns A new rejected Promise. + */ + reject(reason: any): Promise; + + /** + * Creates a new rejected promise for the provided reason. + * @param reason The reason the promise was rejected. + * @returns A new rejected Promise. + */ + reject(reason: any): Promise; + + /** + * Creates a new resolved promise for the provided value. + * @param value A promise. + * @returns A promise whose internal state matches the provided promise. + */ + resolve(value: T | PromiseLike): Promise; + + /** + * Creates a new resolved promise . + * @returns A resolved promise. + */ + resolve(): Promise; +} + +declare var Promise: PromiseConstructor; + +interface ProxyHandler { + getPrototypeOf? (target: T): object | null; + setPrototypeOf? (target: T, v: any): boolean; + isExtensible? (target: T): boolean; + preventExtensions? (target: T): boolean; + getOwnPropertyDescriptor? (target: T, p: PropertyKey): PropertyDescriptor | undefined; + has? (target: T, p: PropertyKey): boolean; + get? (target: T, p: PropertyKey, receiver: any): any; + set? (target: T, p: PropertyKey, value: any, receiver: any): boolean; + deleteProperty? (target: T, p: PropertyKey): boolean; + defineProperty? (target: T, p: PropertyKey, attributes: PropertyDescriptor): boolean; + enumerate? (target: T): PropertyKey[]; + ownKeys? (target: T): PropertyKey[]; + apply? (target: T, thisArg: any, argArray?: any): any; + construct? (target: T, argArray: any, newTarget?: any): object; +} + +interface ProxyConstructor { + revocable(target: T, handler: ProxyHandler): { proxy: T; revoke: () => void; }; + new (target: T, handler: ProxyHandler): T; +} +declare var Proxy: ProxyConstructor; + + +declare namespace Reflect { + function apply(target: Function, thisArgument: any, argumentsList: ArrayLike): any; + function construct(target: Function, argumentsList: ArrayLike, newTarget?: any): any; + function defineProperty(target: object, propertyKey: PropertyKey, attributes: PropertyDescriptor): boolean; + function deleteProperty(target: object, propertyKey: PropertyKey): boolean; + function get(target: object, propertyKey: PropertyKey, receiver?: any): any; + function getOwnPropertyDescriptor(target: object, propertyKey: PropertyKey): PropertyDescriptor; + function getPrototypeOf(target: object): object; + function has(target: object, propertyKey: PropertyKey): boolean; + function isExtensible(target: object): boolean; + function ownKeys(target: object): Array; + function preventExtensions(target: object): boolean; + function set(target: object, propertyKey: PropertyKey, value: any, receiver?: any): boolean; + function setPrototypeOf(target: object, proto: any): boolean; +} + + +interface Symbol { + /** Returns a string representation of an object. */ + toString(): string; + + /** Returns the primitive value of the specified object. */ + valueOf(): symbol; +} + +interface SymbolConstructor { + /** + * A reference to the prototype. + */ + readonly prototype: Symbol; + + /** + * Returns a new unique Symbol value. + * @param description Description of the new Symbol object. + */ + (description?: string | number): symbol; + + /** + * Returns a Symbol object from the global symbol registry matching the given key if found. + * Otherwise, returns a new symbol with this key. + * @param key key to search for. + */ + for(key: string): symbol; + + /** + * Returns a key from the global symbol registry matching the given Symbol if found. + * Otherwise, returns a undefined. + * @param sym Symbol to find the key for. + */ + keyFor(sym: symbol): string | undefined; +} + +declare var Symbol: SymbolConstructor; + +/// + +interface SymbolConstructor { + /** + * A method that determines if a constructor object recognizes an object as one of the + * constructor’s instances. Called by the semantics of the instanceof operator. + */ + readonly hasInstance: symbol; + + /** + * A Boolean value that if true indicates that an object should flatten to its array elements + * by Array.prototype.concat. + */ + readonly isConcatSpreadable: symbol; + + /** + * A regular expression method that matches the regular expression against a string. Called + * by the String.prototype.match method. + */ + readonly match: symbol; + + /** + * A regular expression method that replaces matched substrings of a string. Called by the + * String.prototype.replace method. + */ + readonly replace: symbol; + + /** + * A regular expression method that returns the index within a string that matches the + * regular expression. Called by the String.prototype.search method. + */ + readonly search: symbol; + + /** + * A function valued property that is the constructor function that is used to create + * derived objects. + */ + readonly species: symbol; + + /** + * A regular expression method that splits a string at the indices that match the regular + * expression. Called by the String.prototype.split method. + */ + readonly split: symbol; + + /** + * A method that converts an object to a corresponding primitive value. + * Called by the ToPrimitive abstract operation. + */ + readonly toPrimitive: symbol; + + /** + * A String value that is used in the creation of the default string description of an object. + * Called by the built-in method Object.prototype.toString. + */ + readonly toStringTag: symbol; + + /** + * An Object whose own property names are property names that are excluded from the 'with' + * environment bindings of the associated objects. + */ + readonly unscopables: symbol; +} + +interface Symbol { + readonly [Symbol.toStringTag]: "Symbol"; +} + +interface Array { + /** + * Returns an object whose properties have the value 'true' + * when they will be absent when used in a 'with' statement. + */ + [Symbol.unscopables](): { + copyWithin: boolean; + entries: boolean; + fill: boolean; + find: boolean; + findIndex: boolean; + keys: boolean; + values: boolean; + }; +} + +interface Date { + /** + * Converts a Date object to a string. + */ + [Symbol.toPrimitive](hint: "default"): string; + /** + * Converts a Date object to a string. + */ + [Symbol.toPrimitive](hint: "string"): string; + /** + * Converts a Date object to a number. + */ + [Symbol.toPrimitive](hint: "number"): number; + /** + * Converts a Date object to a string or number. + * + * @param hint The strings "number", "string", or "default" to specify what primitive to return. + * + * @throws {TypeError} If 'hint' was given something other than "number", "string", or "default". + * @returns A number if 'hint' was "number", a string if 'hint' was "string" or "default". + */ + [Symbol.toPrimitive](hint: string): string | number; +} + +interface Map { + readonly [Symbol.toStringTag]: "Map"; +} + +interface WeakMap { + readonly [Symbol.toStringTag]: "WeakMap"; +} + +interface Set { + readonly [Symbol.toStringTag]: "Set"; +} + +interface WeakSet { + readonly [Symbol.toStringTag]: "WeakSet"; +} + +interface JSON { + readonly [Symbol.toStringTag]: "JSON"; +} + +interface Function { + /** + * Determines whether the given value inherits from this function if this function was used + * as a constructor function. + * + * A constructor function can control which objects are recognized as its instances by + * 'instanceof' by overriding this method. + */ + [Symbol.hasInstance](value: any): boolean; +} + +interface GeneratorFunction { + readonly [Symbol.toStringTag]: "GeneratorFunction"; +} + +interface Math { + readonly [Symbol.toStringTag]: "Math"; +} + +interface Promise { + readonly [Symbol.toStringTag]: "Promise"; +} + +interface PromiseConstructor { + readonly [Symbol.species]: Function; +} + +interface RegExp { + /** + * Matches a string with this regular expression, and returns an array containing the results of + * that search. + * @param string A string to search within. + */ + [Symbol.match](string: string): RegExpMatchArray | null; + + /** + * Replaces text in a string, using this regular expression. + * @param string A String object or string literal whose contents matching against + * this regular expression will be replaced + * @param replaceValue A String object or string literal containing the text to replace for every + * successful match of this regular expression. + */ + [Symbol.replace](string: string, replaceValue: string): string; + + /** + * Replaces text in a string, using this regular expression. + * @param string A String object or string literal whose contents matching against + * this regular expression will be replaced + * @param replacer A function that returns the replacement text. + */ + [Symbol.replace](string: string, replacer: (substring: string, ...args: any[]) => string): string; + + /** + * Finds the position beginning first substring match in a regular expression search + * using this regular expression. + * + * @param string The string to search within. + */ + [Symbol.search](string: string): number; + + /** + * Returns an array of substrings that were delimited by strings in the original input that + * match against this regular expression. + * + * If the regular expression contains capturing parentheses, then each time this + * regular expression matches, the results (including any undefined results) of the + * capturing parentheses are spliced. + * + * @param string string value to split + * @param limit if not undefined, the output array is truncated so that it contains no more + * than 'limit' elements. + */ + [Symbol.split](string: string, limit?: number): string[]; +} + +interface RegExpConstructor { + [Symbol.species](): RegExpConstructor; +} + +interface String { + /** + * Matches a string an object that supports being matched against, and returns an array containing the results of that search. + * @param matcher An object that supports being matched against. + */ + match(matcher: { [Symbol.match](string: string): RegExpMatchArray | null; }): RegExpMatchArray | null; + + /** + * Replaces text in a string, using an object that supports replacement within a string. + * @param searchValue A object can search for and replace matches within a string. + * @param replaceValue A string containing the text to replace for every successful match of searchValue in this string. + */ + replace(searchValue: { [Symbol.replace](string: string, replaceValue: string): string; }, replaceValue: string): string; + + /** + * Replaces text in a string, using an object that supports replacement within a string. + * @param searchValue A object can search for and replace matches within a string. + * @param replacer A function that returns the replacement text. + */ + replace(searchValue: { [Symbol.replace](string: string, replacer: (substring: string, ...args: any[]) => string): string; }, replacer: (substring: string, ...args: any[]) => string): string; + + /** + * Finds the first substring match in a regular expression search. + * @param searcher An object which supports searching within a string. + */ + search(searcher: { [Symbol.search](string: string): number; }): number; + + /** + * Split a string into substrings using the specified separator and return them as an array. + * @param splitter An object that can split a string. + * @param limit A value used to limit the number of elements returned in the array. + */ + split(splitter: { [Symbol.split](string: string, limit?: number): string[]; }, limit?: number): string[]; +} + +/** + * Represents a raw buffer of binary data, which is used to store data for the + * different typed arrays. ArrayBuffers cannot be read from or written to directly, + * but can be passed to a typed array or DataView Object to interpret the raw + * buffer as needed. + */ +interface ArrayBuffer { + readonly [Symbol.toStringTag]: "ArrayBuffer"; +} + +interface DataView { + readonly [Symbol.toStringTag]: "DataView"; +} + +/** + * A typed array of 8-bit integer values. The contents are initialized to 0. If the requested + * number of bytes could not be allocated an exception is raised. + */ +interface Int8Array { + readonly [Symbol.toStringTag]: "Int8Array"; +} + +/** + * A typed array of 8-bit unsigned integer values. The contents are initialized to 0. If the + * requested number of bytes could not be allocated an exception is raised. + */ +interface Uint8Array { + readonly [Symbol.toStringTag]: "UInt8Array"; +} + +/** + * A typed array of 8-bit unsigned integer (clamped) values. The contents are initialized to 0. + * If the requested number of bytes could not be allocated an exception is raised. + */ +interface Uint8ClampedArray { + readonly [Symbol.toStringTag]: "Uint8ClampedArray"; +} + +/** + * A typed array of 16-bit signed integer values. The contents are initialized to 0. If the + * requested number of bytes could not be allocated an exception is raised. + */ +interface Int16Array { + readonly [Symbol.toStringTag]: "Int16Array"; +} + +/** + * A typed array of 16-bit unsigned integer values. The contents are initialized to 0. If the + * requested number of bytes could not be allocated an exception is raised. + */ +interface Uint16Array { + readonly [Symbol.toStringTag]: "Uint16Array"; +} + +/** + * A typed array of 32-bit signed integer values. The contents are initialized to 0. If the + * requested number of bytes could not be allocated an exception is raised. + */ +interface Int32Array { + readonly [Symbol.toStringTag]: "Int32Array"; +} + +/** + * A typed array of 32-bit unsigned integer values. The contents are initialized to 0. If the + * requested number of bytes could not be allocated an exception is raised. + */ +interface Uint32Array { + readonly [Symbol.toStringTag]: "Uint32Array"; +} + +/** + * A typed array of 32-bit float values. The contents are initialized to 0. If the requested number + * of bytes could not be allocated an exception is raised. + */ +interface Float32Array { + readonly [Symbol.toStringTag]: "Float32Array"; +} + +/** + * A typed array of 64-bit float values. The contents are initialized to 0. If the requested + * number of bytes could not be allocated an exception is raised. + */ +interface Float64Array { + readonly [Symbol.toStringTag]: "Float64Array"; +} + + ///////////////////////////// /// DOM APIs diff --git a/lib/lib.es2017.full.d.ts b/lib/lib.es2017.full.d.ts index 6c2f2606640..331f822c6fe 100644 --- a/lib/lib.es2017.full.d.ts +++ b/lib/lib.es2017.full.d.ts @@ -25,6 +25,1830 @@ and limitations under the License. /// +declare type PropertyKey = string | number | symbol; + +interface Array { + /** + * Returns the value of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ + find(predicate: (this: void, value: T, index: number, obj: Array) => boolean): T | undefined; + find(predicate: (this: void, value: T, index: number, obj: Array) => boolean, thisArg: undefined): T | undefined; + find(predicate: (this: Z, value: T, index: number, obj: Array) => boolean, thisArg: Z): T | undefined; + + /** + * Returns the index of the first element in the array where predicate is true, and -1 + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, + * findIndex immediately returns that element index. Otherwise, findIndex returns -1. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ + findIndex(predicate: (this: void, value: T, index: number, obj: Array) => boolean): number; + findIndex(predicate: (this: void, value: T, index: number, obj: Array) => boolean, thisArg: undefined): number; + findIndex(predicate: (this: Z, value: T, index: number, obj: Array) => boolean, thisArg: Z): number; + + /** + * Returns the this object after filling the section identified by start and end with value + * @param value value to fill array section with + * @param start index to start filling the array at. If start is negative, it is treated as + * length+start where length is the length of the array. + * @param end index to stop filling the array at. If end is negative, it is treated as + * length+end. + */ + fill(value: T, start?: number, end?: number): this; + + /** + * Returns the this object after copying a section of the array identified by start and end + * to the same array starting at position target + * @param target If target is negative, it is treated as length+target where length is the + * length of the array. + * @param start If start is negative, it is treated as length+start. If end is negative, it + * is treated as length+end. + * @param end If not specified, length of the this object is used as its default value. + */ + copyWithin(target: number, start: number, end?: number): this; +} + +interface ArrayConstructor { + /** + * Creates an array from an array-like object. + * @param arrayLike An array-like object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ + from(arrayLike: ArrayLike, mapfn: (this: void, v: T, k: number) => U): Array; + from(arrayLike: ArrayLike, mapfn: (this: void, v: T, k: number) => U, thisArg: undefined): Array; + from(arrayLike: ArrayLike, mapfn: (this: Z, v: T, k: number) => U, thisArg: Z): Array; + + + /** + * Creates an array from an array-like object. + * @param arrayLike An array-like object to convert to an array. + */ + from(arrayLike: ArrayLike): Array; + + /** + * Returns a new array from a set of elements. + * @param items A set of elements to include in the new array object. + */ + of(...items: T[]): Array; +} + +interface DateConstructor { + new (value: Date): Date; +} + +interface Function { + /** + * Returns the name of the function. Function names are read-only and can not be changed. + */ + readonly name: string; +} + +interface Math { + /** + * Returns the number of leading zero bits in the 32-bit binary representation of a number. + * @param x A numeric expression. + */ + clz32(x: number): number; + + /** + * Returns the result of 32-bit multiplication of two numbers. + * @param x First number + * @param y Second number + */ + imul(x: number, y: number): number; + + /** + * Returns the sign of the x, indicating whether x is positive, negative or zero. + * @param x The numeric expression to test + */ + sign(x: number): number; + + /** + * Returns the base 10 logarithm of a number. + * @param x A numeric expression. + */ + log10(x: number): number; + + /** + * Returns the base 2 logarithm of a number. + * @param x A numeric expression. + */ + log2(x: number): number; + + /** + * Returns the natural logarithm of 1 + x. + * @param x A numeric expression. + */ + log1p(x: number): number; + + /** + * Returns the result of (e^x - 1) of x (e raised to the power of x, where e is the base of + * the natural logarithms). + * @param x A numeric expression. + */ + expm1(x: number): number; + + /** + * Returns the hyperbolic cosine of a number. + * @param x A numeric expression that contains an angle measured in radians. + */ + cosh(x: number): number; + + /** + * Returns the hyperbolic sine of a number. + * @param x A numeric expression that contains an angle measured in radians. + */ + sinh(x: number): number; + + /** + * Returns the hyperbolic tangent of a number. + * @param x A numeric expression that contains an angle measured in radians. + */ + tanh(x: number): number; + + /** + * Returns the inverse hyperbolic cosine of a number. + * @param x A numeric expression that contains an angle measured in radians. + */ + acosh(x: number): number; + + /** + * Returns the inverse hyperbolic sine of a number. + * @param x A numeric expression that contains an angle measured in radians. + */ + asinh(x: number): number; + + /** + * Returns the inverse hyperbolic tangent of a number. + * @param x A numeric expression that contains an angle measured in radians. + */ + atanh(x: number): number; + + /** + * Returns the square root of the sum of squares of its arguments. + * @param values Values to compute the square root for. + * If no arguments are passed, the result is +0. + * If there is only one argument, the result is the absolute value. + * If any argument is +Infinity or -Infinity, the result is +Infinity. + * If any argument is NaN, the result is NaN. + * If all arguments are either +0 or −0, the result is +0. + */ + hypot(...values: number[] ): number; + + /** + * Returns the integral part of the a numeric expression, x, removing any fractional digits. + * If x is already an integer, the result is x. + * @param x A numeric expression. + */ + trunc(x: number): number; + + /** + * Returns the nearest single precision float representation of a number. + * @param x A numeric expression. + */ + fround(x: number): number; + + /** + * Returns an implementation-dependent approximation to the cube root of number. + * @param x A numeric expression. + */ + cbrt(x: number): number; +} + +interface NumberConstructor { + /** + * The value of Number.EPSILON is the difference between 1 and the smallest value greater than 1 + * that is representable as a Number value, which is approximately: + * 2.2204460492503130808472633361816 x 10‍−‍16. + */ + readonly EPSILON: number; + + /** + * Returns true if passed value is finite. + * Unlike the global isFinite, Number.isFinite doesn't forcibly convert the parameter to a + * number. Only finite values of the type number, result in true. + * @param number A numeric value. + */ + isFinite(number: number): boolean; + + /** + * Returns true if the value passed is an integer, false otherwise. + * @param number A numeric value. + */ + isInteger(number: number): boolean; + + /** + * Returns a Boolean value that indicates whether a value is the reserved value NaN (not a + * number). Unlike the global isNaN(), Number.isNaN() doesn't forcefully convert the parameter + * to a number. Only values of the type number, that are also NaN, result in true. + * @param number A numeric value. + */ + isNaN(number: number): boolean; + + /** + * Returns true if the value passed is a safe integer. + * @param number A numeric value. + */ + isSafeInteger(number: number): boolean; + + /** + * The value of the largest integer n such that n and n + 1 are both exactly representable as + * a Number value. + * The value of Number.MAX_SAFE_INTEGER is 9007199254740991 2^53 − 1. + */ + readonly MAX_SAFE_INTEGER: number; + + /** + * The value of the smallest integer n such that n and n − 1 are both exactly representable as + * a Number value. + * The value of Number.MIN_SAFE_INTEGER is −9007199254740991 (−(2^53 − 1)). + */ + readonly MIN_SAFE_INTEGER: number; + + /** + * Converts a string to a floating-point number. + * @param string A string that contains a floating-point number. + */ + parseFloat(string: string): number; + + /** + * Converts A string to an integer. + * @param s A string to convert into a number. + * @param radix A value between 2 and 36 that specifies the base of the number in numString. + * If this argument is not supplied, strings with a prefix of '0x' are considered hexadecimal. + * All other strings are considered decimal. + */ + parseInt(string: string, radix?: number): number; +} + +interface Object { + /** + * Determines whether an object has a property with the specified name. + * @param v A property name. + */ + hasOwnProperty(v: PropertyKey): boolean; + + /** + * Determines whether a specified property is enumerable. + * @param v A property name. + */ + propertyIsEnumerable(v: PropertyKey): boolean; +} + +interface ObjectConstructor { + /** + * Copy the values of all of the enumerable own properties from one or more source objects to a + * target object. Returns the target object. + * @param target The target object to copy to. + * @param source The source object from which to copy properties. + */ + assign(target: T, source: U): T & U; + + /** + * Copy the values of all of the enumerable own properties from one or more source objects to a + * target object. Returns the target object. + * @param target The target object to copy to. + * @param source1 The first source object from which to copy properties. + * @param source2 The second source object from which to copy properties. + */ + assign(target: T, source1: U, source2: V): T & U & V; + + /** + * Copy the values of all of the enumerable own properties from one or more source objects to a + * target object. Returns the target object. + * @param target The target object to copy to. + * @param source1 The first source object from which to copy properties. + * @param source2 The second source object from which to copy properties. + * @param source3 The third source object from which to copy properties. + */ + assign(target: T, source1: U, source2: V, source3: W): T & U & V & W; + + /** + * Copy the values of all of the enumerable own properties from one or more source objects to a + * target object. Returns the target object. + * @param target The target object to copy to. + * @param sources One or more source objects from which to copy properties + */ + assign(target: object, ...sources: any[]): any; + + /** + * Returns an array of all symbol properties found directly on object o. + * @param o Object to retrieve the symbols from. + */ + getOwnPropertySymbols(o: any): symbol[]; + + /** + * Returns true if the values are the same value, false otherwise. + * @param value1 The first value. + * @param value2 The second value. + */ + is(value1: any, value2: any): boolean; + + /** + * Sets the prototype of a specified object o to object proto or null. Returns the object o. + * @param o The object to change its prototype. + * @param proto The value of the new prototype or null. + */ + setPrototypeOf(o: any, proto: object | null): any; + + /** + * Gets the own property descriptor of the specified object. + * An own property descriptor is one that is defined directly on the object and is not + * inherited from the object's prototype. + * @param o Object that contains the property. + * @param p Name of the property. + */ + getOwnPropertyDescriptor(o: any, propertyKey: PropertyKey): PropertyDescriptor; + + /** + * Adds a property to an object, or modifies attributes of an existing property. + * @param o Object on which to add or modify the property. This can be a native JavaScript + * object (that is, a user-defined object or a built in object) or a DOM object. + * @param p The property name. + * @param attributes Descriptor for the property. It can be for a data property or an accessor + * property. + */ + defineProperty(o: any, propertyKey: PropertyKey, attributes: PropertyDescriptor): any; +} + +interface ReadonlyArray { + /** + * Returns the value of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ + find(predicate: (this: void, value: T, index: number, obj: ReadonlyArray) => boolean): T | undefined; + find(predicate: (this: void, value: T, index: number, obj: ReadonlyArray) => boolean, thisArg: undefined): T | undefined; + find(predicate: (this: Z, value: T, index: number, obj: ReadonlyArray) => boolean, thisArg: Z): T | undefined; + + /** + * Returns the index of the first element in the array where predicate is true, and -1 + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, + * findIndex immediately returns that element index. Otherwise, findIndex returns -1. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ + findIndex(predicate: (this: void, value: T, index: number, obj: Array) => boolean): number; + findIndex(predicate: (this: void, value: T, index: number, obj: Array) => boolean, thisArg: undefined): number; + findIndex(predicate: (this: Z, value: T, index: number, obj: Array) => boolean, thisArg: Z): number; +} + +interface RegExp { + /** + * Returns a string indicating the flags of the regular expression in question. This field is read-only. + * The characters in this string are sequenced and concatenated in the following order: + * + * - "g" for global + * - "i" for ignoreCase + * - "m" for multiline + * - "u" for unicode + * - "y" for sticky + * + * If no flags are set, the value is the empty string. + */ + readonly flags: string; + + /** + * Returns a Boolean value indicating the state of the sticky flag (y) used with a regular + * expression. Default is false. Read-only. + */ + readonly sticky: boolean; + + /** + * Returns a Boolean value indicating the state of the Unicode flag (u) used with a regular + * expression. Default is false. Read-only. + */ + readonly unicode: boolean; +} + +interface RegExpConstructor { + new (pattern: RegExp, flags?: string): RegExp; + (pattern: RegExp, flags?: string): RegExp; +} + +interface String { + /** + * Returns a nonnegative integer Number less than 1114112 (0x110000) that is the code point + * value of the UTF-16 encoded code point starting at the string element at position pos in + * the String resulting from converting this object to a String. + * If there is no element at that position, the result is undefined. + * If a valid UTF-16 surrogate pair does not begin at pos, the result is the code unit at pos. + */ + codePointAt(pos: number): number | undefined; + + /** + * Returns true if searchString appears as a substring of the result of converting this + * object to a String, at one or more positions that are + * greater than or equal to position; otherwise, returns false. + * @param searchString search string + * @param position If position is undefined, 0 is assumed, so as to search all of the String. + */ + includes(searchString: string, position?: number): boolean; + + /** + * Returns true if the sequence of elements of searchString converted to a String is the + * same as the corresponding elements of this object (converted to a String) starting at + * endPosition – length(this). Otherwise returns false. + */ + endsWith(searchString: string, endPosition?: number): boolean; + + /** + * Returns the String value result of normalizing the string into the normalization form + * named by form as specified in Unicode Standard Annex #15, Unicode Normalization Forms. + * @param form Applicable values: "NFC", "NFD", "NFKC", or "NFKD", If not specified default + * is "NFC" + */ + normalize(form: "NFC" | "NFD" | "NFKC" | "NFKD"): string; + + /** + * Returns the String value result of normalizing the string into the normalization form + * named by form as specified in Unicode Standard Annex #15, Unicode Normalization Forms. + * @param form Applicable values: "NFC", "NFD", "NFKC", or "NFKD", If not specified default + * is "NFC" + */ + normalize(form?: string): string; + + /** + * Returns a String value that is made from count copies appended together. If count is 0, + * T is the empty String is returned. + * @param count number of copies to append + */ + repeat(count: number): string; + + /** + * Returns true if the sequence of elements of searchString converted to a String is the + * same as the corresponding elements of this object (converted to a String) starting at + * position. Otherwise returns false. + */ + startsWith(searchString: string, position?: number): boolean; + + /** + * Returns an HTML anchor element and sets the name attribute to the text value + * @param name + */ + anchor(name: string): string; + + /** Returns a HTML element */ + big(): string; + + /** Returns a HTML element */ + blink(): string; + + /** Returns a HTML element */ + bold(): string; + + /** Returns a HTML element */ + fixed(): string; + + /** Returns a HTML element and sets the color attribute value */ + fontcolor(color: string): string; + + /** Returns a HTML element and sets the size attribute value */ + fontsize(size: number): string; + + /** Returns a HTML element and sets the size attribute value */ + fontsize(size: string): string; + + /** Returns an HTML element */ + italics(): string; + + /** Returns an HTML element and sets the href attribute value */ + link(url: string): string; + + /** Returns a HTML element */ + small(): string; + + /** Returns a HTML element */ + strike(): string; + + /** Returns a HTML element */ + sub(): string; + + /** Returns a HTML element */ + sup(): string; +} + +interface StringConstructor { + /** + * Return the String value whose elements are, in order, the elements in the List elements. + * If length is 0, the empty string is returned. + */ + fromCodePoint(...codePoints: number[]): string; + + /** + * String.raw is intended for use as a tag function of a Tagged Template String. When called + * as such the first argument will be a well formed template call site object and the rest + * parameter will contain the substitution values. + * @param template A well-formed template string call site representation. + * @param substitutions A set of substitution values. + */ + raw(template: TemplateStringsArray, ...substitutions: any[]): string; +} + + +interface Map { + clear(): void; + delete(key: K): boolean; + forEach(callbackfn: (value: V, key: K, map: Map) => void, thisArg?: any): void; + get(key: K): V | undefined; + has(key: K): boolean; + set(key: K, value: V): this; + readonly size: number; +} + +interface MapConstructor { + new (): Map; + new (entries?: [K, V][]): Map; + readonly prototype: Map; +} +declare var Map: MapConstructor; + +interface ReadonlyMap { + forEach(callbackfn: (value: V, key: K, map: ReadonlyMap) => void, thisArg?: any): void; + get(key: K): V | undefined; + has(key: K): boolean; + readonly size: number; +} + +interface WeakMap { + delete(key: K): boolean; + get(key: K): V | undefined; + has(key: K): boolean; + set(key: K, value: V): this; +} + +interface WeakMapConstructor { + new (): WeakMap; + new (entries?: [K, V][]): WeakMap; + readonly prototype: WeakMap; +} +declare var WeakMap: WeakMapConstructor; + +interface Set { + add(value: T): this; + clear(): void; + delete(value: T): boolean; + forEach(callbackfn: (value: T, value2: T, set: Set) => void, thisArg?: any): void; + has(value: T): boolean; + readonly size: number; +} + +interface SetConstructor { + new (): Set; + new (values?: T[]): Set; + readonly prototype: Set; +} +declare var Set: SetConstructor; + +interface ReadonlySet { + forEach(callbackfn: (value: T, value2: T, set: ReadonlySet) => void, thisArg?: any): void; + has(value: T): boolean; + readonly size: number; +} + +interface WeakSet { + add(value: T): this; + delete(value: T): boolean; + has(value: T): boolean; +} + +interface WeakSetConstructor { + new (): WeakSet; + new (values?: T[]): WeakSet; + readonly prototype: WeakSet; +} +declare var WeakSet: WeakSetConstructor; + + +interface Generator extends Iterator { } + +interface GeneratorFunction { + /** + * Creates a new Generator object. + * @param args A list of arguments the function accepts. + */ + new (...args: any[]): Generator; + /** + * Creates a new Generator object. + * @param args A list of arguments the function accepts. + */ + (...args: any[]): Generator; + /** + * The length of the arguments. + */ + readonly length: number; + /** + * Returns the name of the function. + */ + readonly name: string; + /** + * A reference to the prototype. + */ + readonly prototype: Generator; +} + +interface GeneratorFunctionConstructor { + /** + * Creates a new Generator function. + * @param args A list of arguments the function accepts. + */ + new (...args: string[]): GeneratorFunction; + /** + * Creates a new Generator function. + * @param args A list of arguments the function accepts. + */ + (...args: string[]): GeneratorFunction; + /** + * The length of the arguments. + */ + readonly length: number; + /** + * Returns the name of the function. + */ + readonly name: string; + /** + * A reference to the prototype. + */ + readonly prototype: GeneratorFunction; +} +declare var GeneratorFunction: GeneratorFunctionConstructor; + + +/// + +interface SymbolConstructor { + /** + * A method that returns the default iterator for an object. Called by the semantics of the + * for-of statement. + */ + readonly iterator: symbol; +} + +interface IteratorResult { + done: boolean; + value: T; +} + +interface Iterator { + next(value?: any): IteratorResult; + return?(value?: any): IteratorResult; + throw?(e?: any): IteratorResult; +} + +interface Iterable { + [Symbol.iterator](): Iterator; +} + +interface IterableIterator extends Iterator { + [Symbol.iterator](): IterableIterator; +} + +interface Array { + /** Iterator */ + [Symbol.iterator](): IterableIterator; + + /** + * Returns an iterable of key, value pairs for every entry in the array + */ + entries(): IterableIterator<[number, T]>; + + /** + * Returns an iterable of keys in the array + */ + keys(): IterableIterator; + + /** + * Returns an iterable of values in the array + */ + values(): IterableIterator; +} + +interface ArrayConstructor { + /** + * Creates an array from an iterable object. + * @param iterable An iterable object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ + from(iterable: Iterable, mapfn: (this: void, v: T, k: number) => U): Array; + from(iterable: Iterable, mapfn: (this: void, v: T, k: number) => U, thisArg: undefined): Array; + from(iterable: Iterable, mapfn: (this: Z, v: T, k: number) => U, thisArg: Z): Array; + + /** + * Creates an array from an iterable object. + * @param iterable An iterable object to convert to an array. + */ + from(iterable: Iterable): Array; +} + +interface ReadonlyArray { + /** Iterator of values in the array. */ + [Symbol.iterator](): IterableIterator; + + /** + * Returns an iterable of key, value pairs for every entry in the array + */ + entries(): IterableIterator<[number, T]>; + + /** + * Returns an iterable of keys in the array + */ + keys(): IterableIterator; + + /** + * Returns an iterable of values in the array + */ + values(): IterableIterator; +} + +interface IArguments { + /** Iterator */ + [Symbol.iterator](): IterableIterator; +} + +interface Map { + /** Returns an iterable of entries in the map. */ + [Symbol.iterator](): IterableIterator<[K, V]>; + + /** + * Returns an iterable of key, value pairs for every entry in the map. + */ + entries(): IterableIterator<[K, V]>; + + /** + * Returns an iterable of keys in the map + */ + keys(): IterableIterator; + + /** + * Returns an iterable of values in the map + */ + values(): IterableIterator; +} + +interface ReadonlyMap { + /** Returns an iterable of entries in the map. */ + [Symbol.iterator](): IterableIterator<[K, V]>; + + /** + * Returns an iterable of key, value pairs for every entry in the map. + */ + entries(): IterableIterator<[K, V]>; + + /** + * Returns an iterable of keys in the map + */ + keys(): IterableIterator; + + /** + * Returns an iterable of values in the map + */ + values(): IterableIterator; +} + +interface MapConstructor { + new (iterable: Iterable<[K, V]>): Map; +} + +interface WeakMap { } + +interface WeakMapConstructor { + new (iterable: Iterable<[K, V]>): WeakMap; +} + +interface Set { + /** Iterates over values in the set. */ + [Symbol.iterator](): IterableIterator; + /** + * Returns an iterable of [v,v] pairs for every value `v` in the set. + */ + entries(): IterableIterator<[T, T]>; + /** + * Despite its name, returns an iterable of the values in the set, + */ + keys(): IterableIterator; + + /** + * Returns an iterable of values in the set. + */ + values(): IterableIterator; +} + +interface ReadonlySet { + /** Iterates over values in the set. */ + [Symbol.iterator](): IterableIterator; + + /** + * Returns an iterable of [v,v] pairs for every value `v` in the set. + */ + entries(): IterableIterator<[T, T]>; + + /** + * Despite its name, returns an iterable of the values in the set, + */ + keys(): IterableIterator; + + /** + * Returns an iterable of values in the set. + */ + values(): IterableIterator; +} + +interface SetConstructor { + new (iterable: Iterable): Set; +} + +interface WeakSet { } + +interface WeakSetConstructor { + new (iterable: Iterable): WeakSet; +} + +interface Promise { } + +interface PromiseConstructor { + /** + * Creates a Promise that is resolved with an array of results when all of the provided Promises + * resolve, or rejected when any Promise is rejected. + * @param values An array of Promises. + * @returns A new Promise. + */ + all(values: Iterable>): Promise; + + /** + * Creates a Promise that is resolved or rejected when any of the provided Promises are resolved + * or rejected. + * @param values An array of Promises. + * @returns A new Promise. + */ + race(values: Iterable>): Promise; +} + +declare namespace Reflect { + function enumerate(target: object): IterableIterator; +} + +interface String { + /** Iterator */ + [Symbol.iterator](): IterableIterator; +} + +/** + * A typed array of 8-bit integer values. The contents are initialized to 0. If the requested + * number of bytes could not be allocated an exception is raised. + */ +interface Int8Array { + [Symbol.iterator](): IterableIterator; + /** + * Returns an array of key, value pairs for every entry in the array + */ + entries(): IterableIterator<[number, number]>; + /** + * Returns an list of keys in the array + */ + keys(): IterableIterator; + /** + * Returns an list of values in the array + */ + values(): IterableIterator; +} + +interface Int8ArrayConstructor { + new (elements: Iterable): Int8Array; + + /** + * Creates an array from an array-like or iterable object. + * @param arrayLike An array-like or iterable object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ + from(arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Int8Array; + from(arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Int8Array; + from(arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Int8Array; + + from(arrayLike: Iterable): Int8Array; +} + +/** + * A typed array of 8-bit unsigned integer values. The contents are initialized to 0. If the + * requested number of bytes could not be allocated an exception is raised. + */ +interface Uint8Array { + [Symbol.iterator](): IterableIterator; + /** + * Returns an array of key, value pairs for every entry in the array + */ + entries(): IterableIterator<[number, number]>; + /** + * Returns an list of keys in the array + */ + keys(): IterableIterator; + /** + * Returns an list of values in the array + */ + values(): IterableIterator; +} + +interface Uint8ArrayConstructor { + new (elements: Iterable): Uint8Array; + + /** + * Creates an array from an array-like or iterable object. + * @param arrayLike An array-like or iterable object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ + from(arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Uint8Array; + from(arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Uint8Array; + from(arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint8Array; + + from(arrayLike: Iterable): Uint8Array; +} + +/** + * A typed array of 8-bit unsigned integer (clamped) values. The contents are initialized to 0. + * If the requested number of bytes could not be allocated an exception is raised. + */ +interface Uint8ClampedArray { + [Symbol.iterator](): IterableIterator; + /** + * Returns an array of key, value pairs for every entry in the array + */ + entries(): IterableIterator<[number, number]>; + + /** + * Returns an list of keys in the array + */ + keys(): IterableIterator; + + /** + * Returns an list of values in the array + */ + values(): IterableIterator; +} + +interface Uint8ClampedArrayConstructor { + new (elements: Iterable): Uint8ClampedArray; + + + /** + * Creates an array from an array-like or iterable object. + * @param arrayLike An array-like or iterable object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ + from(arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Uint8ClampedArray; + from(arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Uint8ClampedArray; + from(arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint8ClampedArray; + + from(arrayLike: Iterable): Uint8ClampedArray; +} + +/** + * A typed array of 16-bit signed integer values. The contents are initialized to 0. If the + * requested number of bytes could not be allocated an exception is raised. + */ +interface Int16Array { + [Symbol.iterator](): IterableIterator; + /** + * Returns an array of key, value pairs for every entry in the array + */ + entries(): IterableIterator<[number, number]>; + + /** + * Returns an list of keys in the array + */ + keys(): IterableIterator; + + /** + * Returns an list of values in the array + */ + values(): IterableIterator; +} + +interface Int16ArrayConstructor { + new (elements: Iterable): Int16Array; + + /** + * Creates an array from an array-like or iterable object. + * @param arrayLike An array-like or iterable object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ + from(arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Int16Array; + from(arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Int16Array; + from(arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Int16Array; + + from(arrayLike: Iterable): Int16Array; +} + +/** + * A typed array of 16-bit unsigned integer values. The contents are initialized to 0. If the + * requested number of bytes could not be allocated an exception is raised. + */ +interface Uint16Array { + [Symbol.iterator](): IterableIterator; + /** + * Returns an array of key, value pairs for every entry in the array + */ + entries(): IterableIterator<[number, number]>; + /** + * Returns an list of keys in the array + */ + keys(): IterableIterator; + /** + * Returns an list of values in the array + */ + values(): IterableIterator; +} + +interface Uint16ArrayConstructor { + new (elements: Iterable): Uint16Array; + + /** + * Creates an array from an array-like or iterable object. + * @param arrayLike An array-like or iterable object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ + from(arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Uint16Array; + from(arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Uint16Array; + from(arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint16Array; + + from(arrayLike: Iterable): Uint16Array; +} + +/** + * A typed array of 32-bit signed integer values. The contents are initialized to 0. If the + * requested number of bytes could not be allocated an exception is raised. + */ +interface Int32Array { + [Symbol.iterator](): IterableIterator; + /** + * Returns an array of key, value pairs for every entry in the array + */ + entries(): IterableIterator<[number, number]>; + /** + * Returns an list of keys in the array + */ + keys(): IterableIterator; + /** + * Returns an list of values in the array + */ + values(): IterableIterator; +} + +interface Int32ArrayConstructor { + new (elements: Iterable): Int32Array; + + /** + * Creates an array from an array-like or iterable object. + * @param arrayLike An array-like or iterable object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ + from(arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Int32Array; + from(arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Int32Array; + from(arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Int32Array; + + from(arrayLike: Iterable): Int32Array; +} + +/** + * A typed array of 32-bit unsigned integer values. The contents are initialized to 0. If the + * requested number of bytes could not be allocated an exception is raised. + */ +interface Uint32Array { + [Symbol.iterator](): IterableIterator; + /** + * Returns an array of key, value pairs for every entry in the array + */ + entries(): IterableIterator<[number, number]>; + /** + * Returns an list of keys in the array + */ + keys(): IterableIterator; + /** + * Returns an list of values in the array + */ + values(): IterableIterator; +} + +interface Uint32ArrayConstructor { + new (elements: Iterable): Uint32Array; + + /** + * Creates an array from an array-like or iterable object. + * @param arrayLike An array-like or iterable object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ + from(arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Uint32Array; + from(arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Uint32Array; + from(arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint32Array; + + from(arrayLike: Iterable): Uint32Array; +} + +/** + * A typed array of 32-bit float values. The contents are initialized to 0. If the requested number + * of bytes could not be allocated an exception is raised. + */ +interface Float32Array { + [Symbol.iterator](): IterableIterator; + /** + * Returns an array of key, value pairs for every entry in the array + */ + entries(): IterableIterator<[number, number]>; + /** + * Returns an list of keys in the array + */ + keys(): IterableIterator; + /** + * Returns an list of values in the array + */ + values(): IterableIterator; +} + +interface Float32ArrayConstructor { + new (elements: Iterable): Float32Array; + + /** + * Creates an array from an array-like or iterable object. + * @param arrayLike An array-like or iterable object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ + from(arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Float32Array; + from(arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Float32Array; + from(arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Float32Array; + + from(arrayLike: Iterable): Float32Array; +} + +/** + * A typed array of 64-bit float values. The contents are initialized to 0. If the requested + * number of bytes could not be allocated an exception is raised. + */ +interface Float64Array { + [Symbol.iterator](): IterableIterator; + /** + * Returns an array of key, value pairs for every entry in the array + */ + entries(): IterableIterator<[number, number]>; + /** + * Returns an list of keys in the array + */ + keys(): IterableIterator; + /** + * Returns an list of values in the array + */ + values(): IterableIterator; +} + +interface Float64ArrayConstructor { + new (elements: Iterable): Float64Array; + + /** + * Creates an array from an array-like or iterable object. + * @param arrayLike An array-like or iterable object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ + from(arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Float64Array; + from(arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Float64Array; + from(arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Float64Array; + + from(arrayLike: Iterable): Float64Array; +} + + +interface PromiseConstructor { + /** + * A reference to the prototype. + */ + readonly prototype: Promise; + + /** + * Creates a new Promise. + * @param executor A callback used to initialize the promise. This callback is passed two arguments: + * a resolve callback used resolve the promise with a value or the result of another promise, + * and a reject callback used to reject the promise with a provided reason or error. + */ + new (executor: (resolve: (value?: T | PromiseLike) => void, reject: (reason?: any) => void) => void): Promise; + + /** + * Creates a Promise that is resolved with an array of results when all of the provided Promises + * resolve, or rejected when any Promise is rejected. + * @param values An array of Promises. + * @returns A new Promise. + */ + all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike , T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike, T8 | PromiseLike, T9 | PromiseLike, T10 | PromiseLike]): Promise<[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10]>; + + /** + * Creates a Promise that is resolved with an array of results when all of the provided Promises + * resolve, or rejected when any Promise is rejected. + * @param values An array of Promises. + * @returns A new Promise. + */ + all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike , T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike, T8 | PromiseLike, T9 | PromiseLike]): Promise<[T1, T2, T3, T4, T5, T6, T7, T8, T9]>; + + /** + * Creates a Promise that is resolved with an array of results when all of the provided Promises + * resolve, or rejected when any Promise is rejected. + * @param values An array of Promises. + * @returns A new Promise. + */ + all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike , T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike, T8 | PromiseLike]): Promise<[T1, T2, T3, T4, T5, T6, T7, T8]>; + + /** + * Creates a Promise that is resolved with an array of results when all of the provided Promises + * resolve, or rejected when any Promise is rejected. + * @param values An array of Promises. + * @returns A new Promise. + */ + all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike , T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike]): Promise<[T1, T2, T3, T4, T5, T6, T7]>; + + /** + * Creates a Promise that is resolved with an array of results when all of the provided Promises + * resolve, or rejected when any Promise is rejected. + * @param values An array of Promises. + * @returns A new Promise. + */ + all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike , T5 | PromiseLike, T6 | PromiseLike]): Promise<[T1, T2, T3, T4, T5, T6]>; + + /** + * Creates a Promise that is resolved with an array of results when all of the provided Promises + * resolve, or rejected when any Promise is rejected. + * @param values An array of Promises. + * @returns A new Promise. + */ + all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike , T5 | PromiseLike]): Promise<[T1, T2, T3, T4, T5]>; + + /** + * Creates a Promise that is resolved with an array of results when all of the provided Promises + * resolve, or rejected when any Promise is rejected. + * @param values An array of Promises. + * @returns A new Promise. + */ + all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike ]): Promise<[T1, T2, T3, T4]>; + + /** + * Creates a Promise that is resolved with an array of results when all of the provided Promises + * resolve, or rejected when any Promise is rejected. + * @param values An array of Promises. + * @returns A new Promise. + */ + all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike]): Promise<[T1, T2, T3]>; + + /** + * Creates a Promise that is resolved with an array of results when all of the provided Promises + * resolve, or rejected when any Promise is rejected. + * @param values An array of Promises. + * @returns A new Promise. + */ + all(values: [T1 | PromiseLike, T2 | PromiseLike]): Promise<[T1, T2]>; + + /** + * Creates a Promise that is resolved with an array of results when all of the provided Promises + * resolve, or rejected when any Promise is rejected. + * @param values An array of Promises. + * @returns A new Promise. + */ + all(values: (T | PromiseLike)[]): Promise; + + /** + * Creates a Promise that is resolved or rejected when any of the provided Promises are resolved + * or rejected. + * @param values An array of Promises. + * @returns A new Promise. + */ + race(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike, T8 | PromiseLike, T9 | PromiseLike, T10 | PromiseLike]): Promise; + + /** + * Creates a Promise that is resolved or rejected when any of the provided Promises are resolved + * or rejected. + * @param values An array of Promises. + * @returns A new Promise. + */ + race(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike, T8 | PromiseLike, T9 | PromiseLike]): Promise; + + /** + * Creates a Promise that is resolved or rejected when any of the provided Promises are resolved + * or rejected. + * @param values An array of Promises. + * @returns A new Promise. + */ + race(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike, T8 | PromiseLike]): Promise; + + /** + * Creates a Promise that is resolved or rejected when any of the provided Promises are resolved + * or rejected. + * @param values An array of Promises. + * @returns A new Promise. + */ + race(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike]): Promise; + + /** + * Creates a Promise that is resolved or rejected when any of the provided Promises are resolved + * or rejected. + * @param values An array of Promises. + * @returns A new Promise. + */ + race(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike]): Promise; + + /** + * Creates a Promise that is resolved or rejected when any of the provided Promises are resolved + * or rejected. + * @param values An array of Promises. + * @returns A new Promise. + */ + race(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike]): Promise; + + /** + * Creates a Promise that is resolved or rejected when any of the provided Promises are resolved + * or rejected. + * @param values An array of Promises. + * @returns A new Promise. + */ + race(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike]): Promise; + + /** + * Creates a Promise that is resolved or rejected when any of the provided Promises are resolved + * or rejected. + * @param values An array of Promises. + * @returns A new Promise. + */ + race(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike]): Promise; + + /** + * Creates a Promise that is resolved or rejected when any of the provided Promises are resolved + * or rejected. + * @param values An array of Promises. + * @returns A new Promise. + */ + race(values: [T1 | PromiseLike, T2 | PromiseLike]): Promise; + + /** + * Creates a Promise that is resolved or rejected when any of the provided Promises are resolved + * or rejected. + * @param values An array of Promises. + * @returns A new Promise. + */ + race(values: (T | PromiseLike)[]): Promise; + + /** + * Creates a new rejected promise for the provided reason. + * @param reason The reason the promise was rejected. + * @returns A new rejected Promise. + */ + reject(reason: any): Promise; + + /** + * Creates a new rejected promise for the provided reason. + * @param reason The reason the promise was rejected. + * @returns A new rejected Promise. + */ + reject(reason: any): Promise; + + /** + * Creates a new resolved promise for the provided value. + * @param value A promise. + * @returns A promise whose internal state matches the provided promise. + */ + resolve(value: T | PromiseLike): Promise; + + /** + * Creates a new resolved promise . + * @returns A resolved promise. + */ + resolve(): Promise; +} + +declare var Promise: PromiseConstructor; + +interface ProxyHandler { + getPrototypeOf? (target: T): object | null; + setPrototypeOf? (target: T, v: any): boolean; + isExtensible? (target: T): boolean; + preventExtensions? (target: T): boolean; + getOwnPropertyDescriptor? (target: T, p: PropertyKey): PropertyDescriptor | undefined; + has? (target: T, p: PropertyKey): boolean; + get? (target: T, p: PropertyKey, receiver: any): any; + set? (target: T, p: PropertyKey, value: any, receiver: any): boolean; + deleteProperty? (target: T, p: PropertyKey): boolean; + defineProperty? (target: T, p: PropertyKey, attributes: PropertyDescriptor): boolean; + enumerate? (target: T): PropertyKey[]; + ownKeys? (target: T): PropertyKey[]; + apply? (target: T, thisArg: any, argArray?: any): any; + construct? (target: T, argArray: any, newTarget?: any): object; +} + +interface ProxyConstructor { + revocable(target: T, handler: ProxyHandler): { proxy: T; revoke: () => void; }; + new (target: T, handler: ProxyHandler): T; +} +declare var Proxy: ProxyConstructor; + + +declare namespace Reflect { + function apply(target: Function, thisArgument: any, argumentsList: ArrayLike): any; + function construct(target: Function, argumentsList: ArrayLike, newTarget?: any): any; + function defineProperty(target: object, propertyKey: PropertyKey, attributes: PropertyDescriptor): boolean; + function deleteProperty(target: object, propertyKey: PropertyKey): boolean; + function get(target: object, propertyKey: PropertyKey, receiver?: any): any; + function getOwnPropertyDescriptor(target: object, propertyKey: PropertyKey): PropertyDescriptor; + function getPrototypeOf(target: object): object; + function has(target: object, propertyKey: PropertyKey): boolean; + function isExtensible(target: object): boolean; + function ownKeys(target: object): Array; + function preventExtensions(target: object): boolean; + function set(target: object, propertyKey: PropertyKey, value: any, receiver?: any): boolean; + function setPrototypeOf(target: object, proto: any): boolean; +} + + +interface Symbol { + /** Returns a string representation of an object. */ + toString(): string; + + /** Returns the primitive value of the specified object. */ + valueOf(): symbol; +} + +interface SymbolConstructor { + /** + * A reference to the prototype. + */ + readonly prototype: Symbol; + + /** + * Returns a new unique Symbol value. + * @param description Description of the new Symbol object. + */ + (description?: string | number): symbol; + + /** + * Returns a Symbol object from the global symbol registry matching the given key if found. + * Otherwise, returns a new symbol with this key. + * @param key key to search for. + */ + for(key: string): symbol; + + /** + * Returns a key from the global symbol registry matching the given Symbol if found. + * Otherwise, returns a undefined. + * @param sym Symbol to find the key for. + */ + keyFor(sym: symbol): string | undefined; +} + +declare var Symbol: SymbolConstructor; + +/// + +interface SymbolConstructor { + /** + * A method that determines if a constructor object recognizes an object as one of the + * constructor’s instances. Called by the semantics of the instanceof operator. + */ + readonly hasInstance: symbol; + + /** + * A Boolean value that if true indicates that an object should flatten to its array elements + * by Array.prototype.concat. + */ + readonly isConcatSpreadable: symbol; + + /** + * A regular expression method that matches the regular expression against a string. Called + * by the String.prototype.match method. + */ + readonly match: symbol; + + /** + * A regular expression method that replaces matched substrings of a string. Called by the + * String.prototype.replace method. + */ + readonly replace: symbol; + + /** + * A regular expression method that returns the index within a string that matches the + * regular expression. Called by the String.prototype.search method. + */ + readonly search: symbol; + + /** + * A function valued property that is the constructor function that is used to create + * derived objects. + */ + readonly species: symbol; + + /** + * A regular expression method that splits a string at the indices that match the regular + * expression. Called by the String.prototype.split method. + */ + readonly split: symbol; + + /** + * A method that converts an object to a corresponding primitive value. + * Called by the ToPrimitive abstract operation. + */ + readonly toPrimitive: symbol; + + /** + * A String value that is used in the creation of the default string description of an object. + * Called by the built-in method Object.prototype.toString. + */ + readonly toStringTag: symbol; + + /** + * An Object whose own property names are property names that are excluded from the 'with' + * environment bindings of the associated objects. + */ + readonly unscopables: symbol; +} + +interface Symbol { + readonly [Symbol.toStringTag]: "Symbol"; +} + +interface Array { + /** + * Returns an object whose properties have the value 'true' + * when they will be absent when used in a 'with' statement. + */ + [Symbol.unscopables](): { + copyWithin: boolean; + entries: boolean; + fill: boolean; + find: boolean; + findIndex: boolean; + keys: boolean; + values: boolean; + }; +} + +interface Date { + /** + * Converts a Date object to a string. + */ + [Symbol.toPrimitive](hint: "default"): string; + /** + * Converts a Date object to a string. + */ + [Symbol.toPrimitive](hint: "string"): string; + /** + * Converts a Date object to a number. + */ + [Symbol.toPrimitive](hint: "number"): number; + /** + * Converts a Date object to a string or number. + * + * @param hint The strings "number", "string", or "default" to specify what primitive to return. + * + * @throws {TypeError} If 'hint' was given something other than "number", "string", or "default". + * @returns A number if 'hint' was "number", a string if 'hint' was "string" or "default". + */ + [Symbol.toPrimitive](hint: string): string | number; +} + +interface Map { + readonly [Symbol.toStringTag]: "Map"; +} + +interface WeakMap { + readonly [Symbol.toStringTag]: "WeakMap"; +} + +interface Set { + readonly [Symbol.toStringTag]: "Set"; +} + +interface WeakSet { + readonly [Symbol.toStringTag]: "WeakSet"; +} + +interface JSON { + readonly [Symbol.toStringTag]: "JSON"; +} + +interface Function { + /** + * Determines whether the given value inherits from this function if this function was used + * as a constructor function. + * + * A constructor function can control which objects are recognized as its instances by + * 'instanceof' by overriding this method. + */ + [Symbol.hasInstance](value: any): boolean; +} + +interface GeneratorFunction { + readonly [Symbol.toStringTag]: "GeneratorFunction"; +} + +interface Math { + readonly [Symbol.toStringTag]: "Math"; +} + +interface Promise { + readonly [Symbol.toStringTag]: "Promise"; +} + +interface PromiseConstructor { + readonly [Symbol.species]: Function; +} + +interface RegExp { + /** + * Matches a string with this regular expression, and returns an array containing the results of + * that search. + * @param string A string to search within. + */ + [Symbol.match](string: string): RegExpMatchArray | null; + + /** + * Replaces text in a string, using this regular expression. + * @param string A String object or string literal whose contents matching against + * this regular expression will be replaced + * @param replaceValue A String object or string literal containing the text to replace for every + * successful match of this regular expression. + */ + [Symbol.replace](string: string, replaceValue: string): string; + + /** + * Replaces text in a string, using this regular expression. + * @param string A String object or string literal whose contents matching against + * this regular expression will be replaced + * @param replacer A function that returns the replacement text. + */ + [Symbol.replace](string: string, replacer: (substring: string, ...args: any[]) => string): string; + + /** + * Finds the position beginning first substring match in a regular expression search + * using this regular expression. + * + * @param string The string to search within. + */ + [Symbol.search](string: string): number; + + /** + * Returns an array of substrings that were delimited by strings in the original input that + * match against this regular expression. + * + * If the regular expression contains capturing parentheses, then each time this + * regular expression matches, the results (including any undefined results) of the + * capturing parentheses are spliced. + * + * @param string string value to split + * @param limit if not undefined, the output array is truncated so that it contains no more + * than 'limit' elements. + */ + [Symbol.split](string: string, limit?: number): string[]; +} + +interface RegExpConstructor { + [Symbol.species](): RegExpConstructor; +} + +interface String { + /** + * Matches a string an object that supports being matched against, and returns an array containing the results of that search. + * @param matcher An object that supports being matched against. + */ + match(matcher: { [Symbol.match](string: string): RegExpMatchArray | null; }): RegExpMatchArray | null; + + /** + * Replaces text in a string, using an object that supports replacement within a string. + * @param searchValue A object can search for and replace matches within a string. + * @param replaceValue A string containing the text to replace for every successful match of searchValue in this string. + */ + replace(searchValue: { [Symbol.replace](string: string, replaceValue: string): string; }, replaceValue: string): string; + + /** + * Replaces text in a string, using an object that supports replacement within a string. + * @param searchValue A object can search for and replace matches within a string. + * @param replacer A function that returns the replacement text. + */ + replace(searchValue: { [Symbol.replace](string: string, replacer: (substring: string, ...args: any[]) => string): string; }, replacer: (substring: string, ...args: any[]) => string): string; + + /** + * Finds the first substring match in a regular expression search. + * @param searcher An object which supports searching within a string. + */ + search(searcher: { [Symbol.search](string: string): number; }): number; + + /** + * Split a string into substrings using the specified separator and return them as an array. + * @param splitter An object that can split a string. + * @param limit A value used to limit the number of elements returned in the array. + */ + split(splitter: { [Symbol.split](string: string, limit?: number): string[]; }, limit?: number): string[]; +} + +/** + * Represents a raw buffer of binary data, which is used to store data for the + * different typed arrays. ArrayBuffers cannot be read from or written to directly, + * but can be passed to a typed array or DataView Object to interpret the raw + * buffer as needed. + */ +interface ArrayBuffer { + readonly [Symbol.toStringTag]: "ArrayBuffer"; +} + +interface DataView { + readonly [Symbol.toStringTag]: "DataView"; +} + +/** + * A typed array of 8-bit integer values. The contents are initialized to 0. If the requested + * number of bytes could not be allocated an exception is raised. + */ +interface Int8Array { + readonly [Symbol.toStringTag]: "Int8Array"; +} + +/** + * A typed array of 8-bit unsigned integer values. The contents are initialized to 0. If the + * requested number of bytes could not be allocated an exception is raised. + */ +interface Uint8Array { + readonly [Symbol.toStringTag]: "UInt8Array"; +} + +/** + * A typed array of 8-bit unsigned integer (clamped) values. The contents are initialized to 0. + * If the requested number of bytes could not be allocated an exception is raised. + */ +interface Uint8ClampedArray { + readonly [Symbol.toStringTag]: "Uint8ClampedArray"; +} + +/** + * A typed array of 16-bit signed integer values. The contents are initialized to 0. If the + * requested number of bytes could not be allocated an exception is raised. + */ +interface Int16Array { + readonly [Symbol.toStringTag]: "Int16Array"; +} + +/** + * A typed array of 16-bit unsigned integer values. The contents are initialized to 0. If the + * requested number of bytes could not be allocated an exception is raised. + */ +interface Uint16Array { + readonly [Symbol.toStringTag]: "Uint16Array"; +} + +/** + * A typed array of 32-bit signed integer values. The contents are initialized to 0. If the + * requested number of bytes could not be allocated an exception is raised. + */ +interface Int32Array { + readonly [Symbol.toStringTag]: "Int32Array"; +} + +/** + * A typed array of 32-bit unsigned integer values. The contents are initialized to 0. If the + * requested number of bytes could not be allocated an exception is raised. + */ +interface Uint32Array { + readonly [Symbol.toStringTag]: "Uint32Array"; +} + +/** + * A typed array of 32-bit float values. The contents are initialized to 0. If the requested number + * of bytes could not be allocated an exception is raised. + */ +interface Float32Array { + readonly [Symbol.toStringTag]: "Float32Array"; +} + +/** + * A typed array of 64-bit float values. The contents are initialized to 0. If the requested + * number of bytes could not be allocated an exception is raised. + */ +interface Float64Array { + readonly [Symbol.toStringTag]: "Float64Array"; +} + + ///////////////////////////// /// DOM APIs diff --git a/lib/lib.es5.d.ts b/lib/lib.es5.d.ts index f628dc4fe84..8353dc1500f 100644 --- a/lib/lib.es5.d.ts +++ b/lib/lib.es5.d.ts @@ -236,7 +236,7 @@ interface ObjectConstructor { * Returns the names of the enumerable properties and methods of an object. * @param o Object that contains the properties and methods. This can be an object that you created or an existing Document Object Model (DOM) object. */ - keys(o: any): string[]; + keys(o: {}): string[]; } /** @@ -1000,12 +1000,12 @@ interface ReadonlyArray { * Combines two or more arrays. * @param items Additional items to add to the end of array1. */ - concat(...items: T[][]): T[]; + concat(...items: ReadonlyArray[]): T[]; /** * Combines two or more arrays. * @param items Additional items to add to the end of array1. */ - concat(...items: (T | T[])[]): T[]; + concat(...items: (T | ReadonlyArray)[]): T[]; /** * Adds all the elements of an array separated by the specified separator string. * @param separator A string used to separate one element of an array from the next in the resulting String. If omitted, the array elements are separated with a comma. @@ -1119,12 +1119,12 @@ interface Array { * Combines two or more arrays. * @param items Additional items to add to the end of array1. */ - concat(...items: T[][]): T[]; + concat(...items: ReadonlyArray[]): T[]; /** * Combines two or more arrays. * @param items Additional items to add to the end of array1. */ - concat(...items: (T | T[])[]): T[]; + concat(...items: (T | ReadonlyArray)[]): T[]; /** * Adds all the elements of an array separated by the specified separator string. * @param separator A string used to separate one element of an array from the next in the resulting String. If omitted, the array elements are separated with a comma. diff --git a/lib/lib.es6.d.ts b/lib/lib.es6.d.ts index 588c609a164..b44acacc872 100644 --- a/lib/lib.es6.d.ts +++ b/lib/lib.es6.d.ts @@ -236,7 +236,7 @@ interface ObjectConstructor { * Returns the names of the enumerable properties and methods of an object. * @param o Object that contains the properties and methods. This can be an object that you created or an existing Document Object Model (DOM) object. */ - keys(o: any): string[]; + keys(o: {}): string[]; } /** @@ -1000,12 +1000,12 @@ interface ReadonlyArray { * Combines two or more arrays. * @param items Additional items to add to the end of array1. */ - concat(...items: T[][]): T[]; + concat(...items: ReadonlyArray[]): T[]; /** * Combines two or more arrays. * @param items Additional items to add to the end of array1. */ - concat(...items: (T | T[])[]): T[]; + concat(...items: (T | ReadonlyArray)[]): T[]; /** * Adds all the elements of an array separated by the specified separator string. * @param separator A string used to separate one element of an array from the next in the resulting String. If omitted, the array elements are separated with a comma. @@ -1119,12 +1119,12 @@ interface Array { * Combines two or more arrays. * @param items Additional items to add to the end of array1. */ - concat(...items: T[][]): T[]; + concat(...items: ReadonlyArray[]): T[]; /** * Combines two or more arrays. * @param items Additional items to add to the end of array1. */ - concat(...items: (T | T[])[]): T[]; + concat(...items: (T | ReadonlyArray)[]): T[]; /** * Adds all the elements of an array separated by the specified separator string. * @param separator A string used to separate one element of an array from the next in the resulting String. If omitted, the array elements are separated with a comma. @@ -5689,7 +5689,7 @@ interface Map { readonly [Symbol.toStringTag]: "Map"; } -interface WeakMap{ +interface WeakMap { readonly [Symbol.toStringTag]: "WeakMap"; } diff --git a/lib/lib.esnext.full.d.ts b/lib/lib.esnext.full.d.ts index 4d06a07f65e..f7b59da3002 100644 --- a/lib/lib.esnext.full.d.ts +++ b/lib/lib.esnext.full.d.ts @@ -22,6 +22,1830 @@ and limitations under the License. /// +declare type PropertyKey = string | number | symbol; + +interface Array { + /** + * Returns the value of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ + find(predicate: (this: void, value: T, index: number, obj: Array) => boolean): T | undefined; + find(predicate: (this: void, value: T, index: number, obj: Array) => boolean, thisArg: undefined): T | undefined; + find(predicate: (this: Z, value: T, index: number, obj: Array) => boolean, thisArg: Z): T | undefined; + + /** + * Returns the index of the first element in the array where predicate is true, and -1 + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, + * findIndex immediately returns that element index. Otherwise, findIndex returns -1. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ + findIndex(predicate: (this: void, value: T, index: number, obj: Array) => boolean): number; + findIndex(predicate: (this: void, value: T, index: number, obj: Array) => boolean, thisArg: undefined): number; + findIndex(predicate: (this: Z, value: T, index: number, obj: Array) => boolean, thisArg: Z): number; + + /** + * Returns the this object after filling the section identified by start and end with value + * @param value value to fill array section with + * @param start index to start filling the array at. If start is negative, it is treated as + * length+start where length is the length of the array. + * @param end index to stop filling the array at. If end is negative, it is treated as + * length+end. + */ + fill(value: T, start?: number, end?: number): this; + + /** + * Returns the this object after copying a section of the array identified by start and end + * to the same array starting at position target + * @param target If target is negative, it is treated as length+target where length is the + * length of the array. + * @param start If start is negative, it is treated as length+start. If end is negative, it + * is treated as length+end. + * @param end If not specified, length of the this object is used as its default value. + */ + copyWithin(target: number, start: number, end?: number): this; +} + +interface ArrayConstructor { + /** + * Creates an array from an array-like object. + * @param arrayLike An array-like object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ + from(arrayLike: ArrayLike, mapfn: (this: void, v: T, k: number) => U): Array; + from(arrayLike: ArrayLike, mapfn: (this: void, v: T, k: number) => U, thisArg: undefined): Array; + from(arrayLike: ArrayLike, mapfn: (this: Z, v: T, k: number) => U, thisArg: Z): Array; + + + /** + * Creates an array from an array-like object. + * @param arrayLike An array-like object to convert to an array. + */ + from(arrayLike: ArrayLike): Array; + + /** + * Returns a new array from a set of elements. + * @param items A set of elements to include in the new array object. + */ + of(...items: T[]): Array; +} + +interface DateConstructor { + new (value: Date): Date; +} + +interface Function { + /** + * Returns the name of the function. Function names are read-only and can not be changed. + */ + readonly name: string; +} + +interface Math { + /** + * Returns the number of leading zero bits in the 32-bit binary representation of a number. + * @param x A numeric expression. + */ + clz32(x: number): number; + + /** + * Returns the result of 32-bit multiplication of two numbers. + * @param x First number + * @param y Second number + */ + imul(x: number, y: number): number; + + /** + * Returns the sign of the x, indicating whether x is positive, negative or zero. + * @param x The numeric expression to test + */ + sign(x: number): number; + + /** + * Returns the base 10 logarithm of a number. + * @param x A numeric expression. + */ + log10(x: number): number; + + /** + * Returns the base 2 logarithm of a number. + * @param x A numeric expression. + */ + log2(x: number): number; + + /** + * Returns the natural logarithm of 1 + x. + * @param x A numeric expression. + */ + log1p(x: number): number; + + /** + * Returns the result of (e^x - 1) of x (e raised to the power of x, where e is the base of + * the natural logarithms). + * @param x A numeric expression. + */ + expm1(x: number): number; + + /** + * Returns the hyperbolic cosine of a number. + * @param x A numeric expression that contains an angle measured in radians. + */ + cosh(x: number): number; + + /** + * Returns the hyperbolic sine of a number. + * @param x A numeric expression that contains an angle measured in radians. + */ + sinh(x: number): number; + + /** + * Returns the hyperbolic tangent of a number. + * @param x A numeric expression that contains an angle measured in radians. + */ + tanh(x: number): number; + + /** + * Returns the inverse hyperbolic cosine of a number. + * @param x A numeric expression that contains an angle measured in radians. + */ + acosh(x: number): number; + + /** + * Returns the inverse hyperbolic sine of a number. + * @param x A numeric expression that contains an angle measured in radians. + */ + asinh(x: number): number; + + /** + * Returns the inverse hyperbolic tangent of a number. + * @param x A numeric expression that contains an angle measured in radians. + */ + atanh(x: number): number; + + /** + * Returns the square root of the sum of squares of its arguments. + * @param values Values to compute the square root for. + * If no arguments are passed, the result is +0. + * If there is only one argument, the result is the absolute value. + * If any argument is +Infinity or -Infinity, the result is +Infinity. + * If any argument is NaN, the result is NaN. + * If all arguments are either +0 or −0, the result is +0. + */ + hypot(...values: number[] ): number; + + /** + * Returns the integral part of the a numeric expression, x, removing any fractional digits. + * If x is already an integer, the result is x. + * @param x A numeric expression. + */ + trunc(x: number): number; + + /** + * Returns the nearest single precision float representation of a number. + * @param x A numeric expression. + */ + fround(x: number): number; + + /** + * Returns an implementation-dependent approximation to the cube root of number. + * @param x A numeric expression. + */ + cbrt(x: number): number; +} + +interface NumberConstructor { + /** + * The value of Number.EPSILON is the difference between 1 and the smallest value greater than 1 + * that is representable as a Number value, which is approximately: + * 2.2204460492503130808472633361816 x 10‍−‍16. + */ + readonly EPSILON: number; + + /** + * Returns true if passed value is finite. + * Unlike the global isFinite, Number.isFinite doesn't forcibly convert the parameter to a + * number. Only finite values of the type number, result in true. + * @param number A numeric value. + */ + isFinite(number: number): boolean; + + /** + * Returns true if the value passed is an integer, false otherwise. + * @param number A numeric value. + */ + isInteger(number: number): boolean; + + /** + * Returns a Boolean value that indicates whether a value is the reserved value NaN (not a + * number). Unlike the global isNaN(), Number.isNaN() doesn't forcefully convert the parameter + * to a number. Only values of the type number, that are also NaN, result in true. + * @param number A numeric value. + */ + isNaN(number: number): boolean; + + /** + * Returns true if the value passed is a safe integer. + * @param number A numeric value. + */ + isSafeInteger(number: number): boolean; + + /** + * The value of the largest integer n such that n and n + 1 are both exactly representable as + * a Number value. + * The value of Number.MAX_SAFE_INTEGER is 9007199254740991 2^53 − 1. + */ + readonly MAX_SAFE_INTEGER: number; + + /** + * The value of the smallest integer n such that n and n − 1 are both exactly representable as + * a Number value. + * The value of Number.MIN_SAFE_INTEGER is −9007199254740991 (−(2^53 − 1)). + */ + readonly MIN_SAFE_INTEGER: number; + + /** + * Converts a string to a floating-point number. + * @param string A string that contains a floating-point number. + */ + parseFloat(string: string): number; + + /** + * Converts A string to an integer. + * @param s A string to convert into a number. + * @param radix A value between 2 and 36 that specifies the base of the number in numString. + * If this argument is not supplied, strings with a prefix of '0x' are considered hexadecimal. + * All other strings are considered decimal. + */ + parseInt(string: string, radix?: number): number; +} + +interface Object { + /** + * Determines whether an object has a property with the specified name. + * @param v A property name. + */ + hasOwnProperty(v: PropertyKey): boolean; + + /** + * Determines whether a specified property is enumerable. + * @param v A property name. + */ + propertyIsEnumerable(v: PropertyKey): boolean; +} + +interface ObjectConstructor { + /** + * Copy the values of all of the enumerable own properties from one or more source objects to a + * target object. Returns the target object. + * @param target The target object to copy to. + * @param source The source object from which to copy properties. + */ + assign(target: T, source: U): T & U; + + /** + * Copy the values of all of the enumerable own properties from one or more source objects to a + * target object. Returns the target object. + * @param target The target object to copy to. + * @param source1 The first source object from which to copy properties. + * @param source2 The second source object from which to copy properties. + */ + assign(target: T, source1: U, source2: V): T & U & V; + + /** + * Copy the values of all of the enumerable own properties from one or more source objects to a + * target object. Returns the target object. + * @param target The target object to copy to. + * @param source1 The first source object from which to copy properties. + * @param source2 The second source object from which to copy properties. + * @param source3 The third source object from which to copy properties. + */ + assign(target: T, source1: U, source2: V, source3: W): T & U & V & W; + + /** + * Copy the values of all of the enumerable own properties from one or more source objects to a + * target object. Returns the target object. + * @param target The target object to copy to. + * @param sources One or more source objects from which to copy properties + */ + assign(target: object, ...sources: any[]): any; + + /** + * Returns an array of all symbol properties found directly on object o. + * @param o Object to retrieve the symbols from. + */ + getOwnPropertySymbols(o: any): symbol[]; + + /** + * Returns true if the values are the same value, false otherwise. + * @param value1 The first value. + * @param value2 The second value. + */ + is(value1: any, value2: any): boolean; + + /** + * Sets the prototype of a specified object o to object proto or null. Returns the object o. + * @param o The object to change its prototype. + * @param proto The value of the new prototype or null. + */ + setPrototypeOf(o: any, proto: object | null): any; + + /** + * Gets the own property descriptor of the specified object. + * An own property descriptor is one that is defined directly on the object and is not + * inherited from the object's prototype. + * @param o Object that contains the property. + * @param p Name of the property. + */ + getOwnPropertyDescriptor(o: any, propertyKey: PropertyKey): PropertyDescriptor; + + /** + * Adds a property to an object, or modifies attributes of an existing property. + * @param o Object on which to add or modify the property. This can be a native JavaScript + * object (that is, a user-defined object or a built in object) or a DOM object. + * @param p The property name. + * @param attributes Descriptor for the property. It can be for a data property or an accessor + * property. + */ + defineProperty(o: any, propertyKey: PropertyKey, attributes: PropertyDescriptor): any; +} + +interface ReadonlyArray { + /** + * Returns the value of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ + find(predicate: (this: void, value: T, index: number, obj: ReadonlyArray) => boolean): T | undefined; + find(predicate: (this: void, value: T, index: number, obj: ReadonlyArray) => boolean, thisArg: undefined): T | undefined; + find(predicate: (this: Z, value: T, index: number, obj: ReadonlyArray) => boolean, thisArg: Z): T | undefined; + + /** + * Returns the index of the first element in the array where predicate is true, and -1 + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, + * findIndex immediately returns that element index. Otherwise, findIndex returns -1. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ + findIndex(predicate: (this: void, value: T, index: number, obj: Array) => boolean): number; + findIndex(predicate: (this: void, value: T, index: number, obj: Array) => boolean, thisArg: undefined): number; + findIndex(predicate: (this: Z, value: T, index: number, obj: Array) => boolean, thisArg: Z): number; +} + +interface RegExp { + /** + * Returns a string indicating the flags of the regular expression in question. This field is read-only. + * The characters in this string are sequenced and concatenated in the following order: + * + * - "g" for global + * - "i" for ignoreCase + * - "m" for multiline + * - "u" for unicode + * - "y" for sticky + * + * If no flags are set, the value is the empty string. + */ + readonly flags: string; + + /** + * Returns a Boolean value indicating the state of the sticky flag (y) used with a regular + * expression. Default is false. Read-only. + */ + readonly sticky: boolean; + + /** + * Returns a Boolean value indicating the state of the Unicode flag (u) used with a regular + * expression. Default is false. Read-only. + */ + readonly unicode: boolean; +} + +interface RegExpConstructor { + new (pattern: RegExp, flags?: string): RegExp; + (pattern: RegExp, flags?: string): RegExp; +} + +interface String { + /** + * Returns a nonnegative integer Number less than 1114112 (0x110000) that is the code point + * value of the UTF-16 encoded code point starting at the string element at position pos in + * the String resulting from converting this object to a String. + * If there is no element at that position, the result is undefined. + * If a valid UTF-16 surrogate pair does not begin at pos, the result is the code unit at pos. + */ + codePointAt(pos: number): number | undefined; + + /** + * Returns true if searchString appears as a substring of the result of converting this + * object to a String, at one or more positions that are + * greater than or equal to position; otherwise, returns false. + * @param searchString search string + * @param position If position is undefined, 0 is assumed, so as to search all of the String. + */ + includes(searchString: string, position?: number): boolean; + + /** + * Returns true if the sequence of elements of searchString converted to a String is the + * same as the corresponding elements of this object (converted to a String) starting at + * endPosition – length(this). Otherwise returns false. + */ + endsWith(searchString: string, endPosition?: number): boolean; + + /** + * Returns the String value result of normalizing the string into the normalization form + * named by form as specified in Unicode Standard Annex #15, Unicode Normalization Forms. + * @param form Applicable values: "NFC", "NFD", "NFKC", or "NFKD", If not specified default + * is "NFC" + */ + normalize(form: "NFC" | "NFD" | "NFKC" | "NFKD"): string; + + /** + * Returns the String value result of normalizing the string into the normalization form + * named by form as specified in Unicode Standard Annex #15, Unicode Normalization Forms. + * @param form Applicable values: "NFC", "NFD", "NFKC", or "NFKD", If not specified default + * is "NFC" + */ + normalize(form?: string): string; + + /** + * Returns a String value that is made from count copies appended together. If count is 0, + * T is the empty String is returned. + * @param count number of copies to append + */ + repeat(count: number): string; + + /** + * Returns true if the sequence of elements of searchString converted to a String is the + * same as the corresponding elements of this object (converted to a String) starting at + * position. Otherwise returns false. + */ + startsWith(searchString: string, position?: number): boolean; + + /** + * Returns an HTML anchor element and sets the name attribute to the text value + * @param name + */ + anchor(name: string): string; + + /** Returns a HTML element */ + big(): string; + + /** Returns a HTML element */ + blink(): string; + + /** Returns a HTML element */ + bold(): string; + + /** Returns a HTML element */ + fixed(): string; + + /** Returns a HTML element and sets the color attribute value */ + fontcolor(color: string): string; + + /** Returns a HTML element and sets the size attribute value */ + fontsize(size: number): string; + + /** Returns a HTML element and sets the size attribute value */ + fontsize(size: string): string; + + /** Returns an HTML element */ + italics(): string; + + /** Returns an HTML element and sets the href attribute value */ + link(url: string): string; + + /** Returns a HTML element */ + small(): string; + + /** Returns a HTML element */ + strike(): string; + + /** Returns a HTML element */ + sub(): string; + + /** Returns a HTML element */ + sup(): string; +} + +interface StringConstructor { + /** + * Return the String value whose elements are, in order, the elements in the List elements. + * If length is 0, the empty string is returned. + */ + fromCodePoint(...codePoints: number[]): string; + + /** + * String.raw is intended for use as a tag function of a Tagged Template String. When called + * as such the first argument will be a well formed template call site object and the rest + * parameter will contain the substitution values. + * @param template A well-formed template string call site representation. + * @param substitutions A set of substitution values. + */ + raw(template: TemplateStringsArray, ...substitutions: any[]): string; +} + + +interface Map { + clear(): void; + delete(key: K): boolean; + forEach(callbackfn: (value: V, key: K, map: Map) => void, thisArg?: any): void; + get(key: K): V | undefined; + has(key: K): boolean; + set(key: K, value: V): this; + readonly size: number; +} + +interface MapConstructor { + new (): Map; + new (entries?: [K, V][]): Map; + readonly prototype: Map; +} +declare var Map: MapConstructor; + +interface ReadonlyMap { + forEach(callbackfn: (value: V, key: K, map: ReadonlyMap) => void, thisArg?: any): void; + get(key: K): V | undefined; + has(key: K): boolean; + readonly size: number; +} + +interface WeakMap { + delete(key: K): boolean; + get(key: K): V | undefined; + has(key: K): boolean; + set(key: K, value: V): this; +} + +interface WeakMapConstructor { + new (): WeakMap; + new (entries?: [K, V][]): WeakMap; + readonly prototype: WeakMap; +} +declare var WeakMap: WeakMapConstructor; + +interface Set { + add(value: T): this; + clear(): void; + delete(value: T): boolean; + forEach(callbackfn: (value: T, value2: T, set: Set) => void, thisArg?: any): void; + has(value: T): boolean; + readonly size: number; +} + +interface SetConstructor { + new (): Set; + new (values?: T[]): Set; + readonly prototype: Set; +} +declare var Set: SetConstructor; + +interface ReadonlySet { + forEach(callbackfn: (value: T, value2: T, set: ReadonlySet) => void, thisArg?: any): void; + has(value: T): boolean; + readonly size: number; +} + +interface WeakSet { + add(value: T): this; + delete(value: T): boolean; + has(value: T): boolean; +} + +interface WeakSetConstructor { + new (): WeakSet; + new (values?: T[]): WeakSet; + readonly prototype: WeakSet; +} +declare var WeakSet: WeakSetConstructor; + + +interface Generator extends Iterator { } + +interface GeneratorFunction { + /** + * Creates a new Generator object. + * @param args A list of arguments the function accepts. + */ + new (...args: any[]): Generator; + /** + * Creates a new Generator object. + * @param args A list of arguments the function accepts. + */ + (...args: any[]): Generator; + /** + * The length of the arguments. + */ + readonly length: number; + /** + * Returns the name of the function. + */ + readonly name: string; + /** + * A reference to the prototype. + */ + readonly prototype: Generator; +} + +interface GeneratorFunctionConstructor { + /** + * Creates a new Generator function. + * @param args A list of arguments the function accepts. + */ + new (...args: string[]): GeneratorFunction; + /** + * Creates a new Generator function. + * @param args A list of arguments the function accepts. + */ + (...args: string[]): GeneratorFunction; + /** + * The length of the arguments. + */ + readonly length: number; + /** + * Returns the name of the function. + */ + readonly name: string; + /** + * A reference to the prototype. + */ + readonly prototype: GeneratorFunction; +} +declare var GeneratorFunction: GeneratorFunctionConstructor; + + +/// + +interface SymbolConstructor { + /** + * A method that returns the default iterator for an object. Called by the semantics of the + * for-of statement. + */ + readonly iterator: symbol; +} + +interface IteratorResult { + done: boolean; + value: T; +} + +interface Iterator { + next(value?: any): IteratorResult; + return?(value?: any): IteratorResult; + throw?(e?: any): IteratorResult; +} + +interface Iterable { + [Symbol.iterator](): Iterator; +} + +interface IterableIterator extends Iterator { + [Symbol.iterator](): IterableIterator; +} + +interface Array { + /** Iterator */ + [Symbol.iterator](): IterableIterator; + + /** + * Returns an iterable of key, value pairs for every entry in the array + */ + entries(): IterableIterator<[number, T]>; + + /** + * Returns an iterable of keys in the array + */ + keys(): IterableIterator; + + /** + * Returns an iterable of values in the array + */ + values(): IterableIterator; +} + +interface ArrayConstructor { + /** + * Creates an array from an iterable object. + * @param iterable An iterable object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ + from(iterable: Iterable, mapfn: (this: void, v: T, k: number) => U): Array; + from(iterable: Iterable, mapfn: (this: void, v: T, k: number) => U, thisArg: undefined): Array; + from(iterable: Iterable, mapfn: (this: Z, v: T, k: number) => U, thisArg: Z): Array; + + /** + * Creates an array from an iterable object. + * @param iterable An iterable object to convert to an array. + */ + from(iterable: Iterable): Array; +} + +interface ReadonlyArray { + /** Iterator of values in the array. */ + [Symbol.iterator](): IterableIterator; + + /** + * Returns an iterable of key, value pairs for every entry in the array + */ + entries(): IterableIterator<[number, T]>; + + /** + * Returns an iterable of keys in the array + */ + keys(): IterableIterator; + + /** + * Returns an iterable of values in the array + */ + values(): IterableIterator; +} + +interface IArguments { + /** Iterator */ + [Symbol.iterator](): IterableIterator; +} + +interface Map { + /** Returns an iterable of entries in the map. */ + [Symbol.iterator](): IterableIterator<[K, V]>; + + /** + * Returns an iterable of key, value pairs for every entry in the map. + */ + entries(): IterableIterator<[K, V]>; + + /** + * Returns an iterable of keys in the map + */ + keys(): IterableIterator; + + /** + * Returns an iterable of values in the map + */ + values(): IterableIterator; +} + +interface ReadonlyMap { + /** Returns an iterable of entries in the map. */ + [Symbol.iterator](): IterableIterator<[K, V]>; + + /** + * Returns an iterable of key, value pairs for every entry in the map. + */ + entries(): IterableIterator<[K, V]>; + + /** + * Returns an iterable of keys in the map + */ + keys(): IterableIterator; + + /** + * Returns an iterable of values in the map + */ + values(): IterableIterator; +} + +interface MapConstructor { + new (iterable: Iterable<[K, V]>): Map; +} + +interface WeakMap { } + +interface WeakMapConstructor { + new (iterable: Iterable<[K, V]>): WeakMap; +} + +interface Set { + /** Iterates over values in the set. */ + [Symbol.iterator](): IterableIterator; + /** + * Returns an iterable of [v,v] pairs for every value `v` in the set. + */ + entries(): IterableIterator<[T, T]>; + /** + * Despite its name, returns an iterable of the values in the set, + */ + keys(): IterableIterator; + + /** + * Returns an iterable of values in the set. + */ + values(): IterableIterator; +} + +interface ReadonlySet { + /** Iterates over values in the set. */ + [Symbol.iterator](): IterableIterator; + + /** + * Returns an iterable of [v,v] pairs for every value `v` in the set. + */ + entries(): IterableIterator<[T, T]>; + + /** + * Despite its name, returns an iterable of the values in the set, + */ + keys(): IterableIterator; + + /** + * Returns an iterable of values in the set. + */ + values(): IterableIterator; +} + +interface SetConstructor { + new (iterable: Iterable): Set; +} + +interface WeakSet { } + +interface WeakSetConstructor { + new (iterable: Iterable): WeakSet; +} + +interface Promise { } + +interface PromiseConstructor { + /** + * Creates a Promise that is resolved with an array of results when all of the provided Promises + * resolve, or rejected when any Promise is rejected. + * @param values An array of Promises. + * @returns A new Promise. + */ + all(values: Iterable>): Promise; + + /** + * Creates a Promise that is resolved or rejected when any of the provided Promises are resolved + * or rejected. + * @param values An array of Promises. + * @returns A new Promise. + */ + race(values: Iterable>): Promise; +} + +declare namespace Reflect { + function enumerate(target: object): IterableIterator; +} + +interface String { + /** Iterator */ + [Symbol.iterator](): IterableIterator; +} + +/** + * A typed array of 8-bit integer values. The contents are initialized to 0. If the requested + * number of bytes could not be allocated an exception is raised. + */ +interface Int8Array { + [Symbol.iterator](): IterableIterator; + /** + * Returns an array of key, value pairs for every entry in the array + */ + entries(): IterableIterator<[number, number]>; + /** + * Returns an list of keys in the array + */ + keys(): IterableIterator; + /** + * Returns an list of values in the array + */ + values(): IterableIterator; +} + +interface Int8ArrayConstructor { + new (elements: Iterable): Int8Array; + + /** + * Creates an array from an array-like or iterable object. + * @param arrayLike An array-like or iterable object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ + from(arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Int8Array; + from(arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Int8Array; + from(arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Int8Array; + + from(arrayLike: Iterable): Int8Array; +} + +/** + * A typed array of 8-bit unsigned integer values. The contents are initialized to 0. If the + * requested number of bytes could not be allocated an exception is raised. + */ +interface Uint8Array { + [Symbol.iterator](): IterableIterator; + /** + * Returns an array of key, value pairs for every entry in the array + */ + entries(): IterableIterator<[number, number]>; + /** + * Returns an list of keys in the array + */ + keys(): IterableIterator; + /** + * Returns an list of values in the array + */ + values(): IterableIterator; +} + +interface Uint8ArrayConstructor { + new (elements: Iterable): Uint8Array; + + /** + * Creates an array from an array-like or iterable object. + * @param arrayLike An array-like or iterable object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ + from(arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Uint8Array; + from(arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Uint8Array; + from(arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint8Array; + + from(arrayLike: Iterable): Uint8Array; +} + +/** + * A typed array of 8-bit unsigned integer (clamped) values. The contents are initialized to 0. + * If the requested number of bytes could not be allocated an exception is raised. + */ +interface Uint8ClampedArray { + [Symbol.iterator](): IterableIterator; + /** + * Returns an array of key, value pairs for every entry in the array + */ + entries(): IterableIterator<[number, number]>; + + /** + * Returns an list of keys in the array + */ + keys(): IterableIterator; + + /** + * Returns an list of values in the array + */ + values(): IterableIterator; +} + +interface Uint8ClampedArrayConstructor { + new (elements: Iterable): Uint8ClampedArray; + + + /** + * Creates an array from an array-like or iterable object. + * @param arrayLike An array-like or iterable object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ + from(arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Uint8ClampedArray; + from(arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Uint8ClampedArray; + from(arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint8ClampedArray; + + from(arrayLike: Iterable): Uint8ClampedArray; +} + +/** + * A typed array of 16-bit signed integer values. The contents are initialized to 0. If the + * requested number of bytes could not be allocated an exception is raised. + */ +interface Int16Array { + [Symbol.iterator](): IterableIterator; + /** + * Returns an array of key, value pairs for every entry in the array + */ + entries(): IterableIterator<[number, number]>; + + /** + * Returns an list of keys in the array + */ + keys(): IterableIterator; + + /** + * Returns an list of values in the array + */ + values(): IterableIterator; +} + +interface Int16ArrayConstructor { + new (elements: Iterable): Int16Array; + + /** + * Creates an array from an array-like or iterable object. + * @param arrayLike An array-like or iterable object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ + from(arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Int16Array; + from(arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Int16Array; + from(arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Int16Array; + + from(arrayLike: Iterable): Int16Array; +} + +/** + * A typed array of 16-bit unsigned integer values. The contents are initialized to 0. If the + * requested number of bytes could not be allocated an exception is raised. + */ +interface Uint16Array { + [Symbol.iterator](): IterableIterator; + /** + * Returns an array of key, value pairs for every entry in the array + */ + entries(): IterableIterator<[number, number]>; + /** + * Returns an list of keys in the array + */ + keys(): IterableIterator; + /** + * Returns an list of values in the array + */ + values(): IterableIterator; +} + +interface Uint16ArrayConstructor { + new (elements: Iterable): Uint16Array; + + /** + * Creates an array from an array-like or iterable object. + * @param arrayLike An array-like or iterable object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ + from(arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Uint16Array; + from(arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Uint16Array; + from(arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint16Array; + + from(arrayLike: Iterable): Uint16Array; +} + +/** + * A typed array of 32-bit signed integer values. The contents are initialized to 0. If the + * requested number of bytes could not be allocated an exception is raised. + */ +interface Int32Array { + [Symbol.iterator](): IterableIterator; + /** + * Returns an array of key, value pairs for every entry in the array + */ + entries(): IterableIterator<[number, number]>; + /** + * Returns an list of keys in the array + */ + keys(): IterableIterator; + /** + * Returns an list of values in the array + */ + values(): IterableIterator; +} + +interface Int32ArrayConstructor { + new (elements: Iterable): Int32Array; + + /** + * Creates an array from an array-like or iterable object. + * @param arrayLike An array-like or iterable object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ + from(arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Int32Array; + from(arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Int32Array; + from(arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Int32Array; + + from(arrayLike: Iterable): Int32Array; +} + +/** + * A typed array of 32-bit unsigned integer values. The contents are initialized to 0. If the + * requested number of bytes could not be allocated an exception is raised. + */ +interface Uint32Array { + [Symbol.iterator](): IterableIterator; + /** + * Returns an array of key, value pairs for every entry in the array + */ + entries(): IterableIterator<[number, number]>; + /** + * Returns an list of keys in the array + */ + keys(): IterableIterator; + /** + * Returns an list of values in the array + */ + values(): IterableIterator; +} + +interface Uint32ArrayConstructor { + new (elements: Iterable): Uint32Array; + + /** + * Creates an array from an array-like or iterable object. + * @param arrayLike An array-like or iterable object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ + from(arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Uint32Array; + from(arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Uint32Array; + from(arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint32Array; + + from(arrayLike: Iterable): Uint32Array; +} + +/** + * A typed array of 32-bit float values. The contents are initialized to 0. If the requested number + * of bytes could not be allocated an exception is raised. + */ +interface Float32Array { + [Symbol.iterator](): IterableIterator; + /** + * Returns an array of key, value pairs for every entry in the array + */ + entries(): IterableIterator<[number, number]>; + /** + * Returns an list of keys in the array + */ + keys(): IterableIterator; + /** + * Returns an list of values in the array + */ + values(): IterableIterator; +} + +interface Float32ArrayConstructor { + new (elements: Iterable): Float32Array; + + /** + * Creates an array from an array-like or iterable object. + * @param arrayLike An array-like or iterable object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ + from(arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Float32Array; + from(arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Float32Array; + from(arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Float32Array; + + from(arrayLike: Iterable): Float32Array; +} + +/** + * A typed array of 64-bit float values. The contents are initialized to 0. If the requested + * number of bytes could not be allocated an exception is raised. + */ +interface Float64Array { + [Symbol.iterator](): IterableIterator; + /** + * Returns an array of key, value pairs for every entry in the array + */ + entries(): IterableIterator<[number, number]>; + /** + * Returns an list of keys in the array + */ + keys(): IterableIterator; + /** + * Returns an list of values in the array + */ + values(): IterableIterator; +} + +interface Float64ArrayConstructor { + new (elements: Iterable): Float64Array; + + /** + * Creates an array from an array-like or iterable object. + * @param arrayLike An array-like or iterable object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ + from(arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Float64Array; + from(arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Float64Array; + from(arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Float64Array; + + from(arrayLike: Iterable): Float64Array; +} + + +interface PromiseConstructor { + /** + * A reference to the prototype. + */ + readonly prototype: Promise; + + /** + * Creates a new Promise. + * @param executor A callback used to initialize the promise. This callback is passed two arguments: + * a resolve callback used resolve the promise with a value or the result of another promise, + * and a reject callback used to reject the promise with a provided reason or error. + */ + new (executor: (resolve: (value?: T | PromiseLike) => void, reject: (reason?: any) => void) => void): Promise; + + /** + * Creates a Promise that is resolved with an array of results when all of the provided Promises + * resolve, or rejected when any Promise is rejected. + * @param values An array of Promises. + * @returns A new Promise. + */ + all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike , T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike, T8 | PromiseLike, T9 | PromiseLike, T10 | PromiseLike]): Promise<[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10]>; + + /** + * Creates a Promise that is resolved with an array of results when all of the provided Promises + * resolve, or rejected when any Promise is rejected. + * @param values An array of Promises. + * @returns A new Promise. + */ + all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike , T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike, T8 | PromiseLike, T9 | PromiseLike]): Promise<[T1, T2, T3, T4, T5, T6, T7, T8, T9]>; + + /** + * Creates a Promise that is resolved with an array of results when all of the provided Promises + * resolve, or rejected when any Promise is rejected. + * @param values An array of Promises. + * @returns A new Promise. + */ + all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike , T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike, T8 | PromiseLike]): Promise<[T1, T2, T3, T4, T5, T6, T7, T8]>; + + /** + * Creates a Promise that is resolved with an array of results when all of the provided Promises + * resolve, or rejected when any Promise is rejected. + * @param values An array of Promises. + * @returns A new Promise. + */ + all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike , T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike]): Promise<[T1, T2, T3, T4, T5, T6, T7]>; + + /** + * Creates a Promise that is resolved with an array of results when all of the provided Promises + * resolve, or rejected when any Promise is rejected. + * @param values An array of Promises. + * @returns A new Promise. + */ + all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike , T5 | PromiseLike, T6 | PromiseLike]): Promise<[T1, T2, T3, T4, T5, T6]>; + + /** + * Creates a Promise that is resolved with an array of results when all of the provided Promises + * resolve, or rejected when any Promise is rejected. + * @param values An array of Promises. + * @returns A new Promise. + */ + all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike , T5 | PromiseLike]): Promise<[T1, T2, T3, T4, T5]>; + + /** + * Creates a Promise that is resolved with an array of results when all of the provided Promises + * resolve, or rejected when any Promise is rejected. + * @param values An array of Promises. + * @returns A new Promise. + */ + all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike ]): Promise<[T1, T2, T3, T4]>; + + /** + * Creates a Promise that is resolved with an array of results when all of the provided Promises + * resolve, or rejected when any Promise is rejected. + * @param values An array of Promises. + * @returns A new Promise. + */ + all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike]): Promise<[T1, T2, T3]>; + + /** + * Creates a Promise that is resolved with an array of results when all of the provided Promises + * resolve, or rejected when any Promise is rejected. + * @param values An array of Promises. + * @returns A new Promise. + */ + all(values: [T1 | PromiseLike, T2 | PromiseLike]): Promise<[T1, T2]>; + + /** + * Creates a Promise that is resolved with an array of results when all of the provided Promises + * resolve, or rejected when any Promise is rejected. + * @param values An array of Promises. + * @returns A new Promise. + */ + all(values: (T | PromiseLike)[]): Promise; + + /** + * Creates a Promise that is resolved or rejected when any of the provided Promises are resolved + * or rejected. + * @param values An array of Promises. + * @returns A new Promise. + */ + race(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike, T8 | PromiseLike, T9 | PromiseLike, T10 | PromiseLike]): Promise; + + /** + * Creates a Promise that is resolved or rejected when any of the provided Promises are resolved + * or rejected. + * @param values An array of Promises. + * @returns A new Promise. + */ + race(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike, T8 | PromiseLike, T9 | PromiseLike]): Promise; + + /** + * Creates a Promise that is resolved or rejected when any of the provided Promises are resolved + * or rejected. + * @param values An array of Promises. + * @returns A new Promise. + */ + race(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike, T8 | PromiseLike]): Promise; + + /** + * Creates a Promise that is resolved or rejected when any of the provided Promises are resolved + * or rejected. + * @param values An array of Promises. + * @returns A new Promise. + */ + race(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike]): Promise; + + /** + * Creates a Promise that is resolved or rejected when any of the provided Promises are resolved + * or rejected. + * @param values An array of Promises. + * @returns A new Promise. + */ + race(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike]): Promise; + + /** + * Creates a Promise that is resolved or rejected when any of the provided Promises are resolved + * or rejected. + * @param values An array of Promises. + * @returns A new Promise. + */ + race(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike]): Promise; + + /** + * Creates a Promise that is resolved or rejected when any of the provided Promises are resolved + * or rejected. + * @param values An array of Promises. + * @returns A new Promise. + */ + race(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike]): Promise; + + /** + * Creates a Promise that is resolved or rejected when any of the provided Promises are resolved + * or rejected. + * @param values An array of Promises. + * @returns A new Promise. + */ + race(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike]): Promise; + + /** + * Creates a Promise that is resolved or rejected when any of the provided Promises are resolved + * or rejected. + * @param values An array of Promises. + * @returns A new Promise. + */ + race(values: [T1 | PromiseLike, T2 | PromiseLike]): Promise; + + /** + * Creates a Promise that is resolved or rejected when any of the provided Promises are resolved + * or rejected. + * @param values An array of Promises. + * @returns A new Promise. + */ + race(values: (T | PromiseLike)[]): Promise; + + /** + * Creates a new rejected promise for the provided reason. + * @param reason The reason the promise was rejected. + * @returns A new rejected Promise. + */ + reject(reason: any): Promise; + + /** + * Creates a new rejected promise for the provided reason. + * @param reason The reason the promise was rejected. + * @returns A new rejected Promise. + */ + reject(reason: any): Promise; + + /** + * Creates a new resolved promise for the provided value. + * @param value A promise. + * @returns A promise whose internal state matches the provided promise. + */ + resolve(value: T | PromiseLike): Promise; + + /** + * Creates a new resolved promise . + * @returns A resolved promise. + */ + resolve(): Promise; +} + +declare var Promise: PromiseConstructor; + +interface ProxyHandler { + getPrototypeOf? (target: T): object | null; + setPrototypeOf? (target: T, v: any): boolean; + isExtensible? (target: T): boolean; + preventExtensions? (target: T): boolean; + getOwnPropertyDescriptor? (target: T, p: PropertyKey): PropertyDescriptor | undefined; + has? (target: T, p: PropertyKey): boolean; + get? (target: T, p: PropertyKey, receiver: any): any; + set? (target: T, p: PropertyKey, value: any, receiver: any): boolean; + deleteProperty? (target: T, p: PropertyKey): boolean; + defineProperty? (target: T, p: PropertyKey, attributes: PropertyDescriptor): boolean; + enumerate? (target: T): PropertyKey[]; + ownKeys? (target: T): PropertyKey[]; + apply? (target: T, thisArg: any, argArray?: any): any; + construct? (target: T, argArray: any, newTarget?: any): object; +} + +interface ProxyConstructor { + revocable(target: T, handler: ProxyHandler): { proxy: T; revoke: () => void; }; + new (target: T, handler: ProxyHandler): T; +} +declare var Proxy: ProxyConstructor; + + +declare namespace Reflect { + function apply(target: Function, thisArgument: any, argumentsList: ArrayLike): any; + function construct(target: Function, argumentsList: ArrayLike, newTarget?: any): any; + function defineProperty(target: object, propertyKey: PropertyKey, attributes: PropertyDescriptor): boolean; + function deleteProperty(target: object, propertyKey: PropertyKey): boolean; + function get(target: object, propertyKey: PropertyKey, receiver?: any): any; + function getOwnPropertyDescriptor(target: object, propertyKey: PropertyKey): PropertyDescriptor; + function getPrototypeOf(target: object): object; + function has(target: object, propertyKey: PropertyKey): boolean; + function isExtensible(target: object): boolean; + function ownKeys(target: object): Array; + function preventExtensions(target: object): boolean; + function set(target: object, propertyKey: PropertyKey, value: any, receiver?: any): boolean; + function setPrototypeOf(target: object, proto: any): boolean; +} + + +interface Symbol { + /** Returns a string representation of an object. */ + toString(): string; + + /** Returns the primitive value of the specified object. */ + valueOf(): symbol; +} + +interface SymbolConstructor { + /** + * A reference to the prototype. + */ + readonly prototype: Symbol; + + /** + * Returns a new unique Symbol value. + * @param description Description of the new Symbol object. + */ + (description?: string | number): symbol; + + /** + * Returns a Symbol object from the global symbol registry matching the given key if found. + * Otherwise, returns a new symbol with this key. + * @param key key to search for. + */ + for(key: string): symbol; + + /** + * Returns a key from the global symbol registry matching the given Symbol if found. + * Otherwise, returns a undefined. + * @param sym Symbol to find the key for. + */ + keyFor(sym: symbol): string | undefined; +} + +declare var Symbol: SymbolConstructor; + +/// + +interface SymbolConstructor { + /** + * A method that determines if a constructor object recognizes an object as one of the + * constructor’s instances. Called by the semantics of the instanceof operator. + */ + readonly hasInstance: symbol; + + /** + * A Boolean value that if true indicates that an object should flatten to its array elements + * by Array.prototype.concat. + */ + readonly isConcatSpreadable: symbol; + + /** + * A regular expression method that matches the regular expression against a string. Called + * by the String.prototype.match method. + */ + readonly match: symbol; + + /** + * A regular expression method that replaces matched substrings of a string. Called by the + * String.prototype.replace method. + */ + readonly replace: symbol; + + /** + * A regular expression method that returns the index within a string that matches the + * regular expression. Called by the String.prototype.search method. + */ + readonly search: symbol; + + /** + * A function valued property that is the constructor function that is used to create + * derived objects. + */ + readonly species: symbol; + + /** + * A regular expression method that splits a string at the indices that match the regular + * expression. Called by the String.prototype.split method. + */ + readonly split: symbol; + + /** + * A method that converts an object to a corresponding primitive value. + * Called by the ToPrimitive abstract operation. + */ + readonly toPrimitive: symbol; + + /** + * A String value that is used in the creation of the default string description of an object. + * Called by the built-in method Object.prototype.toString. + */ + readonly toStringTag: symbol; + + /** + * An Object whose own property names are property names that are excluded from the 'with' + * environment bindings of the associated objects. + */ + readonly unscopables: symbol; +} + +interface Symbol { + readonly [Symbol.toStringTag]: "Symbol"; +} + +interface Array { + /** + * Returns an object whose properties have the value 'true' + * when they will be absent when used in a 'with' statement. + */ + [Symbol.unscopables](): { + copyWithin: boolean; + entries: boolean; + fill: boolean; + find: boolean; + findIndex: boolean; + keys: boolean; + values: boolean; + }; +} + +interface Date { + /** + * Converts a Date object to a string. + */ + [Symbol.toPrimitive](hint: "default"): string; + /** + * Converts a Date object to a string. + */ + [Symbol.toPrimitive](hint: "string"): string; + /** + * Converts a Date object to a number. + */ + [Symbol.toPrimitive](hint: "number"): number; + /** + * Converts a Date object to a string or number. + * + * @param hint The strings "number", "string", or "default" to specify what primitive to return. + * + * @throws {TypeError} If 'hint' was given something other than "number", "string", or "default". + * @returns A number if 'hint' was "number", a string if 'hint' was "string" or "default". + */ + [Symbol.toPrimitive](hint: string): string | number; +} + +interface Map { + readonly [Symbol.toStringTag]: "Map"; +} + +interface WeakMap { + readonly [Symbol.toStringTag]: "WeakMap"; +} + +interface Set { + readonly [Symbol.toStringTag]: "Set"; +} + +interface WeakSet { + readonly [Symbol.toStringTag]: "WeakSet"; +} + +interface JSON { + readonly [Symbol.toStringTag]: "JSON"; +} + +interface Function { + /** + * Determines whether the given value inherits from this function if this function was used + * as a constructor function. + * + * A constructor function can control which objects are recognized as its instances by + * 'instanceof' by overriding this method. + */ + [Symbol.hasInstance](value: any): boolean; +} + +interface GeneratorFunction { + readonly [Symbol.toStringTag]: "GeneratorFunction"; +} + +interface Math { + readonly [Symbol.toStringTag]: "Math"; +} + +interface Promise { + readonly [Symbol.toStringTag]: "Promise"; +} + +interface PromiseConstructor { + readonly [Symbol.species]: Function; +} + +interface RegExp { + /** + * Matches a string with this regular expression, and returns an array containing the results of + * that search. + * @param string A string to search within. + */ + [Symbol.match](string: string): RegExpMatchArray | null; + + /** + * Replaces text in a string, using this regular expression. + * @param string A String object or string literal whose contents matching against + * this regular expression will be replaced + * @param replaceValue A String object or string literal containing the text to replace for every + * successful match of this regular expression. + */ + [Symbol.replace](string: string, replaceValue: string): string; + + /** + * Replaces text in a string, using this regular expression. + * @param string A String object or string literal whose contents matching against + * this regular expression will be replaced + * @param replacer A function that returns the replacement text. + */ + [Symbol.replace](string: string, replacer: (substring: string, ...args: any[]) => string): string; + + /** + * Finds the position beginning first substring match in a regular expression search + * using this regular expression. + * + * @param string The string to search within. + */ + [Symbol.search](string: string): number; + + /** + * Returns an array of substrings that were delimited by strings in the original input that + * match against this regular expression. + * + * If the regular expression contains capturing parentheses, then each time this + * regular expression matches, the results (including any undefined results) of the + * capturing parentheses are spliced. + * + * @param string string value to split + * @param limit if not undefined, the output array is truncated so that it contains no more + * than 'limit' elements. + */ + [Symbol.split](string: string, limit?: number): string[]; +} + +interface RegExpConstructor { + [Symbol.species](): RegExpConstructor; +} + +interface String { + /** + * Matches a string an object that supports being matched against, and returns an array containing the results of that search. + * @param matcher An object that supports being matched against. + */ + match(matcher: { [Symbol.match](string: string): RegExpMatchArray | null; }): RegExpMatchArray | null; + + /** + * Replaces text in a string, using an object that supports replacement within a string. + * @param searchValue A object can search for and replace matches within a string. + * @param replaceValue A string containing the text to replace for every successful match of searchValue in this string. + */ + replace(searchValue: { [Symbol.replace](string: string, replaceValue: string): string; }, replaceValue: string): string; + + /** + * Replaces text in a string, using an object that supports replacement within a string. + * @param searchValue A object can search for and replace matches within a string. + * @param replacer A function that returns the replacement text. + */ + replace(searchValue: { [Symbol.replace](string: string, replacer: (substring: string, ...args: any[]) => string): string; }, replacer: (substring: string, ...args: any[]) => string): string; + + /** + * Finds the first substring match in a regular expression search. + * @param searcher An object which supports searching within a string. + */ + search(searcher: { [Symbol.search](string: string): number; }): number; + + /** + * Split a string into substrings using the specified separator and return them as an array. + * @param splitter An object that can split a string. + * @param limit A value used to limit the number of elements returned in the array. + */ + split(splitter: { [Symbol.split](string: string, limit?: number): string[]; }, limit?: number): string[]; +} + +/** + * Represents a raw buffer of binary data, which is used to store data for the + * different typed arrays. ArrayBuffers cannot be read from or written to directly, + * but can be passed to a typed array or DataView Object to interpret the raw + * buffer as needed. + */ +interface ArrayBuffer { + readonly [Symbol.toStringTag]: "ArrayBuffer"; +} + +interface DataView { + readonly [Symbol.toStringTag]: "DataView"; +} + +/** + * A typed array of 8-bit integer values. The contents are initialized to 0. If the requested + * number of bytes could not be allocated an exception is raised. + */ +interface Int8Array { + readonly [Symbol.toStringTag]: "Int8Array"; +} + +/** + * A typed array of 8-bit unsigned integer values. The contents are initialized to 0. If the + * requested number of bytes could not be allocated an exception is raised. + */ +interface Uint8Array { + readonly [Symbol.toStringTag]: "UInt8Array"; +} + +/** + * A typed array of 8-bit unsigned integer (clamped) values. The contents are initialized to 0. + * If the requested number of bytes could not be allocated an exception is raised. + */ +interface Uint8ClampedArray { + readonly [Symbol.toStringTag]: "Uint8ClampedArray"; +} + +/** + * A typed array of 16-bit signed integer values. The contents are initialized to 0. If the + * requested number of bytes could not be allocated an exception is raised. + */ +interface Int16Array { + readonly [Symbol.toStringTag]: "Int16Array"; +} + +/** + * A typed array of 16-bit unsigned integer values. The contents are initialized to 0. If the + * requested number of bytes could not be allocated an exception is raised. + */ +interface Uint16Array { + readonly [Symbol.toStringTag]: "Uint16Array"; +} + +/** + * A typed array of 32-bit signed integer values. The contents are initialized to 0. If the + * requested number of bytes could not be allocated an exception is raised. + */ +interface Int32Array { + readonly [Symbol.toStringTag]: "Int32Array"; +} + +/** + * A typed array of 32-bit unsigned integer values. The contents are initialized to 0. If the + * requested number of bytes could not be allocated an exception is raised. + */ +interface Uint32Array { + readonly [Symbol.toStringTag]: "Uint32Array"; +} + +/** + * A typed array of 32-bit float values. The contents are initialized to 0. If the requested number + * of bytes could not be allocated an exception is raised. + */ +interface Float32Array { + readonly [Symbol.toStringTag]: "Float32Array"; +} + +/** + * A typed array of 64-bit float values. The contents are initialized to 0. If the requested + * number of bytes could not be allocated an exception is raised. + */ +interface Float64Array { + readonly [Symbol.toStringTag]: "Float64Array"; +} + + ///////////////////////////// /// DOM APIs diff --git a/lib/tsc.js b/lib/tsc.js index 9ad790d1385..cf9717975cf 100644 --- a/lib/tsc.js +++ b/lib/tsc.js @@ -14,14 +14,453 @@ and limitations under the License. ***************************************************************************** */ "use strict"; +var __assign = (this && this.__assign) || Object.assign || function(t) { + for (var s, i = 1, n = arguments.length; i < n; i++) { + s = arguments[i]; + for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) + t[p] = s[p]; + } + return t; +}; var ts; (function (ts) { + var SyntaxKind; + (function (SyntaxKind) { + SyntaxKind[SyntaxKind["Unknown"] = 0] = "Unknown"; + SyntaxKind[SyntaxKind["EndOfFileToken"] = 1] = "EndOfFileToken"; + SyntaxKind[SyntaxKind["SingleLineCommentTrivia"] = 2] = "SingleLineCommentTrivia"; + SyntaxKind[SyntaxKind["MultiLineCommentTrivia"] = 3] = "MultiLineCommentTrivia"; + SyntaxKind[SyntaxKind["NewLineTrivia"] = 4] = "NewLineTrivia"; + SyntaxKind[SyntaxKind["WhitespaceTrivia"] = 5] = "WhitespaceTrivia"; + SyntaxKind[SyntaxKind["ShebangTrivia"] = 6] = "ShebangTrivia"; + SyntaxKind[SyntaxKind["ConflictMarkerTrivia"] = 7] = "ConflictMarkerTrivia"; + SyntaxKind[SyntaxKind["NumericLiteral"] = 8] = "NumericLiteral"; + SyntaxKind[SyntaxKind["StringLiteral"] = 9] = "StringLiteral"; + SyntaxKind[SyntaxKind["JsxText"] = 10] = "JsxText"; + SyntaxKind[SyntaxKind["JsxTextAllWhiteSpaces"] = 11] = "JsxTextAllWhiteSpaces"; + SyntaxKind[SyntaxKind["RegularExpressionLiteral"] = 12] = "RegularExpressionLiteral"; + SyntaxKind[SyntaxKind["NoSubstitutionTemplateLiteral"] = 13] = "NoSubstitutionTemplateLiteral"; + SyntaxKind[SyntaxKind["TemplateHead"] = 14] = "TemplateHead"; + SyntaxKind[SyntaxKind["TemplateMiddle"] = 15] = "TemplateMiddle"; + SyntaxKind[SyntaxKind["TemplateTail"] = 16] = "TemplateTail"; + SyntaxKind[SyntaxKind["OpenBraceToken"] = 17] = "OpenBraceToken"; + SyntaxKind[SyntaxKind["CloseBraceToken"] = 18] = "CloseBraceToken"; + SyntaxKind[SyntaxKind["OpenParenToken"] = 19] = "OpenParenToken"; + SyntaxKind[SyntaxKind["CloseParenToken"] = 20] = "CloseParenToken"; + SyntaxKind[SyntaxKind["OpenBracketToken"] = 21] = "OpenBracketToken"; + SyntaxKind[SyntaxKind["CloseBracketToken"] = 22] = "CloseBracketToken"; + SyntaxKind[SyntaxKind["DotToken"] = 23] = "DotToken"; + SyntaxKind[SyntaxKind["DotDotDotToken"] = 24] = "DotDotDotToken"; + SyntaxKind[SyntaxKind["SemicolonToken"] = 25] = "SemicolonToken"; + SyntaxKind[SyntaxKind["CommaToken"] = 26] = "CommaToken"; + SyntaxKind[SyntaxKind["LessThanToken"] = 27] = "LessThanToken"; + SyntaxKind[SyntaxKind["LessThanSlashToken"] = 28] = "LessThanSlashToken"; + SyntaxKind[SyntaxKind["GreaterThanToken"] = 29] = "GreaterThanToken"; + SyntaxKind[SyntaxKind["LessThanEqualsToken"] = 30] = "LessThanEqualsToken"; + SyntaxKind[SyntaxKind["GreaterThanEqualsToken"] = 31] = "GreaterThanEqualsToken"; + SyntaxKind[SyntaxKind["EqualsEqualsToken"] = 32] = "EqualsEqualsToken"; + SyntaxKind[SyntaxKind["ExclamationEqualsToken"] = 33] = "ExclamationEqualsToken"; + SyntaxKind[SyntaxKind["EqualsEqualsEqualsToken"] = 34] = "EqualsEqualsEqualsToken"; + SyntaxKind[SyntaxKind["ExclamationEqualsEqualsToken"] = 35] = "ExclamationEqualsEqualsToken"; + SyntaxKind[SyntaxKind["EqualsGreaterThanToken"] = 36] = "EqualsGreaterThanToken"; + SyntaxKind[SyntaxKind["PlusToken"] = 37] = "PlusToken"; + SyntaxKind[SyntaxKind["MinusToken"] = 38] = "MinusToken"; + SyntaxKind[SyntaxKind["AsteriskToken"] = 39] = "AsteriskToken"; + SyntaxKind[SyntaxKind["AsteriskAsteriskToken"] = 40] = "AsteriskAsteriskToken"; + SyntaxKind[SyntaxKind["SlashToken"] = 41] = "SlashToken"; + SyntaxKind[SyntaxKind["PercentToken"] = 42] = "PercentToken"; + SyntaxKind[SyntaxKind["PlusPlusToken"] = 43] = "PlusPlusToken"; + SyntaxKind[SyntaxKind["MinusMinusToken"] = 44] = "MinusMinusToken"; + SyntaxKind[SyntaxKind["LessThanLessThanToken"] = 45] = "LessThanLessThanToken"; + SyntaxKind[SyntaxKind["GreaterThanGreaterThanToken"] = 46] = "GreaterThanGreaterThanToken"; + SyntaxKind[SyntaxKind["GreaterThanGreaterThanGreaterThanToken"] = 47] = "GreaterThanGreaterThanGreaterThanToken"; + SyntaxKind[SyntaxKind["AmpersandToken"] = 48] = "AmpersandToken"; + SyntaxKind[SyntaxKind["BarToken"] = 49] = "BarToken"; + SyntaxKind[SyntaxKind["CaretToken"] = 50] = "CaretToken"; + SyntaxKind[SyntaxKind["ExclamationToken"] = 51] = "ExclamationToken"; + SyntaxKind[SyntaxKind["TildeToken"] = 52] = "TildeToken"; + SyntaxKind[SyntaxKind["AmpersandAmpersandToken"] = 53] = "AmpersandAmpersandToken"; + SyntaxKind[SyntaxKind["BarBarToken"] = 54] = "BarBarToken"; + SyntaxKind[SyntaxKind["QuestionToken"] = 55] = "QuestionToken"; + SyntaxKind[SyntaxKind["ColonToken"] = 56] = "ColonToken"; + SyntaxKind[SyntaxKind["AtToken"] = 57] = "AtToken"; + SyntaxKind[SyntaxKind["EqualsToken"] = 58] = "EqualsToken"; + SyntaxKind[SyntaxKind["PlusEqualsToken"] = 59] = "PlusEqualsToken"; + SyntaxKind[SyntaxKind["MinusEqualsToken"] = 60] = "MinusEqualsToken"; + SyntaxKind[SyntaxKind["AsteriskEqualsToken"] = 61] = "AsteriskEqualsToken"; + SyntaxKind[SyntaxKind["AsteriskAsteriskEqualsToken"] = 62] = "AsteriskAsteriskEqualsToken"; + SyntaxKind[SyntaxKind["SlashEqualsToken"] = 63] = "SlashEqualsToken"; + SyntaxKind[SyntaxKind["PercentEqualsToken"] = 64] = "PercentEqualsToken"; + SyntaxKind[SyntaxKind["LessThanLessThanEqualsToken"] = 65] = "LessThanLessThanEqualsToken"; + SyntaxKind[SyntaxKind["GreaterThanGreaterThanEqualsToken"] = 66] = "GreaterThanGreaterThanEqualsToken"; + SyntaxKind[SyntaxKind["GreaterThanGreaterThanGreaterThanEqualsToken"] = 67] = "GreaterThanGreaterThanGreaterThanEqualsToken"; + SyntaxKind[SyntaxKind["AmpersandEqualsToken"] = 68] = "AmpersandEqualsToken"; + SyntaxKind[SyntaxKind["BarEqualsToken"] = 69] = "BarEqualsToken"; + SyntaxKind[SyntaxKind["CaretEqualsToken"] = 70] = "CaretEqualsToken"; + SyntaxKind[SyntaxKind["Identifier"] = 71] = "Identifier"; + SyntaxKind[SyntaxKind["BreakKeyword"] = 72] = "BreakKeyword"; + SyntaxKind[SyntaxKind["CaseKeyword"] = 73] = "CaseKeyword"; + SyntaxKind[SyntaxKind["CatchKeyword"] = 74] = "CatchKeyword"; + SyntaxKind[SyntaxKind["ClassKeyword"] = 75] = "ClassKeyword"; + SyntaxKind[SyntaxKind["ConstKeyword"] = 76] = "ConstKeyword"; + SyntaxKind[SyntaxKind["ContinueKeyword"] = 77] = "ContinueKeyword"; + SyntaxKind[SyntaxKind["DebuggerKeyword"] = 78] = "DebuggerKeyword"; + SyntaxKind[SyntaxKind["DefaultKeyword"] = 79] = "DefaultKeyword"; + SyntaxKind[SyntaxKind["DeleteKeyword"] = 80] = "DeleteKeyword"; + SyntaxKind[SyntaxKind["DoKeyword"] = 81] = "DoKeyword"; + SyntaxKind[SyntaxKind["ElseKeyword"] = 82] = "ElseKeyword"; + SyntaxKind[SyntaxKind["EnumKeyword"] = 83] = "EnumKeyword"; + SyntaxKind[SyntaxKind["ExportKeyword"] = 84] = "ExportKeyword"; + SyntaxKind[SyntaxKind["ExtendsKeyword"] = 85] = "ExtendsKeyword"; + SyntaxKind[SyntaxKind["FalseKeyword"] = 86] = "FalseKeyword"; + SyntaxKind[SyntaxKind["FinallyKeyword"] = 87] = "FinallyKeyword"; + SyntaxKind[SyntaxKind["ForKeyword"] = 88] = "ForKeyword"; + SyntaxKind[SyntaxKind["FunctionKeyword"] = 89] = "FunctionKeyword"; + SyntaxKind[SyntaxKind["IfKeyword"] = 90] = "IfKeyword"; + SyntaxKind[SyntaxKind["ImportKeyword"] = 91] = "ImportKeyword"; + SyntaxKind[SyntaxKind["InKeyword"] = 92] = "InKeyword"; + SyntaxKind[SyntaxKind["InstanceOfKeyword"] = 93] = "InstanceOfKeyword"; + SyntaxKind[SyntaxKind["NewKeyword"] = 94] = "NewKeyword"; + SyntaxKind[SyntaxKind["NullKeyword"] = 95] = "NullKeyword"; + SyntaxKind[SyntaxKind["ReturnKeyword"] = 96] = "ReturnKeyword"; + SyntaxKind[SyntaxKind["SuperKeyword"] = 97] = "SuperKeyword"; + SyntaxKind[SyntaxKind["SwitchKeyword"] = 98] = "SwitchKeyword"; + SyntaxKind[SyntaxKind["ThisKeyword"] = 99] = "ThisKeyword"; + SyntaxKind[SyntaxKind["ThrowKeyword"] = 100] = "ThrowKeyword"; + SyntaxKind[SyntaxKind["TrueKeyword"] = 101] = "TrueKeyword"; + SyntaxKind[SyntaxKind["TryKeyword"] = 102] = "TryKeyword"; + SyntaxKind[SyntaxKind["TypeOfKeyword"] = 103] = "TypeOfKeyword"; + SyntaxKind[SyntaxKind["VarKeyword"] = 104] = "VarKeyword"; + SyntaxKind[SyntaxKind["VoidKeyword"] = 105] = "VoidKeyword"; + SyntaxKind[SyntaxKind["WhileKeyword"] = 106] = "WhileKeyword"; + SyntaxKind[SyntaxKind["WithKeyword"] = 107] = "WithKeyword"; + SyntaxKind[SyntaxKind["ImplementsKeyword"] = 108] = "ImplementsKeyword"; + SyntaxKind[SyntaxKind["InterfaceKeyword"] = 109] = "InterfaceKeyword"; + SyntaxKind[SyntaxKind["LetKeyword"] = 110] = "LetKeyword"; + SyntaxKind[SyntaxKind["PackageKeyword"] = 111] = "PackageKeyword"; + SyntaxKind[SyntaxKind["PrivateKeyword"] = 112] = "PrivateKeyword"; + SyntaxKind[SyntaxKind["ProtectedKeyword"] = 113] = "ProtectedKeyword"; + SyntaxKind[SyntaxKind["PublicKeyword"] = 114] = "PublicKeyword"; + SyntaxKind[SyntaxKind["StaticKeyword"] = 115] = "StaticKeyword"; + SyntaxKind[SyntaxKind["YieldKeyword"] = 116] = "YieldKeyword"; + SyntaxKind[SyntaxKind["AbstractKeyword"] = 117] = "AbstractKeyword"; + SyntaxKind[SyntaxKind["AsKeyword"] = 118] = "AsKeyword"; + SyntaxKind[SyntaxKind["AnyKeyword"] = 119] = "AnyKeyword"; + SyntaxKind[SyntaxKind["AsyncKeyword"] = 120] = "AsyncKeyword"; + SyntaxKind[SyntaxKind["AwaitKeyword"] = 121] = "AwaitKeyword"; + SyntaxKind[SyntaxKind["BooleanKeyword"] = 122] = "BooleanKeyword"; + SyntaxKind[SyntaxKind["ConstructorKeyword"] = 123] = "ConstructorKeyword"; + SyntaxKind[SyntaxKind["DeclareKeyword"] = 124] = "DeclareKeyword"; + SyntaxKind[SyntaxKind["GetKeyword"] = 125] = "GetKeyword"; + SyntaxKind[SyntaxKind["IsKeyword"] = 126] = "IsKeyword"; + SyntaxKind[SyntaxKind["KeyOfKeyword"] = 127] = "KeyOfKeyword"; + SyntaxKind[SyntaxKind["ModuleKeyword"] = 128] = "ModuleKeyword"; + SyntaxKind[SyntaxKind["NamespaceKeyword"] = 129] = "NamespaceKeyword"; + SyntaxKind[SyntaxKind["NeverKeyword"] = 130] = "NeverKeyword"; + SyntaxKind[SyntaxKind["ReadonlyKeyword"] = 131] = "ReadonlyKeyword"; + SyntaxKind[SyntaxKind["RequireKeyword"] = 132] = "RequireKeyword"; + SyntaxKind[SyntaxKind["NumberKeyword"] = 133] = "NumberKeyword"; + SyntaxKind[SyntaxKind["ObjectKeyword"] = 134] = "ObjectKeyword"; + SyntaxKind[SyntaxKind["SetKeyword"] = 135] = "SetKeyword"; + SyntaxKind[SyntaxKind["StringKeyword"] = 136] = "StringKeyword"; + SyntaxKind[SyntaxKind["SymbolKeyword"] = 137] = "SymbolKeyword"; + SyntaxKind[SyntaxKind["TypeKeyword"] = 138] = "TypeKeyword"; + SyntaxKind[SyntaxKind["UndefinedKeyword"] = 139] = "UndefinedKeyword"; + SyntaxKind[SyntaxKind["FromKeyword"] = 140] = "FromKeyword"; + SyntaxKind[SyntaxKind["GlobalKeyword"] = 141] = "GlobalKeyword"; + SyntaxKind[SyntaxKind["OfKeyword"] = 142] = "OfKeyword"; + SyntaxKind[SyntaxKind["QualifiedName"] = 143] = "QualifiedName"; + SyntaxKind[SyntaxKind["ComputedPropertyName"] = 144] = "ComputedPropertyName"; + SyntaxKind[SyntaxKind["TypeParameter"] = 145] = "TypeParameter"; + SyntaxKind[SyntaxKind["Parameter"] = 146] = "Parameter"; + SyntaxKind[SyntaxKind["Decorator"] = 147] = "Decorator"; + SyntaxKind[SyntaxKind["PropertySignature"] = 148] = "PropertySignature"; + SyntaxKind[SyntaxKind["PropertyDeclaration"] = 149] = "PropertyDeclaration"; + SyntaxKind[SyntaxKind["MethodSignature"] = 150] = "MethodSignature"; + SyntaxKind[SyntaxKind["MethodDeclaration"] = 151] = "MethodDeclaration"; + SyntaxKind[SyntaxKind["Constructor"] = 152] = "Constructor"; + SyntaxKind[SyntaxKind["GetAccessor"] = 153] = "GetAccessor"; + SyntaxKind[SyntaxKind["SetAccessor"] = 154] = "SetAccessor"; + SyntaxKind[SyntaxKind["CallSignature"] = 155] = "CallSignature"; + SyntaxKind[SyntaxKind["ConstructSignature"] = 156] = "ConstructSignature"; + SyntaxKind[SyntaxKind["IndexSignature"] = 157] = "IndexSignature"; + SyntaxKind[SyntaxKind["TypePredicate"] = 158] = "TypePredicate"; + SyntaxKind[SyntaxKind["TypeReference"] = 159] = "TypeReference"; + SyntaxKind[SyntaxKind["FunctionType"] = 160] = "FunctionType"; + SyntaxKind[SyntaxKind["ConstructorType"] = 161] = "ConstructorType"; + SyntaxKind[SyntaxKind["TypeQuery"] = 162] = "TypeQuery"; + SyntaxKind[SyntaxKind["TypeLiteral"] = 163] = "TypeLiteral"; + SyntaxKind[SyntaxKind["ArrayType"] = 164] = "ArrayType"; + SyntaxKind[SyntaxKind["TupleType"] = 165] = "TupleType"; + SyntaxKind[SyntaxKind["UnionType"] = 166] = "UnionType"; + SyntaxKind[SyntaxKind["IntersectionType"] = 167] = "IntersectionType"; + SyntaxKind[SyntaxKind["ParenthesizedType"] = 168] = "ParenthesizedType"; + SyntaxKind[SyntaxKind["ThisType"] = 169] = "ThisType"; + SyntaxKind[SyntaxKind["TypeOperator"] = 170] = "TypeOperator"; + SyntaxKind[SyntaxKind["IndexedAccessType"] = 171] = "IndexedAccessType"; + SyntaxKind[SyntaxKind["MappedType"] = 172] = "MappedType"; + SyntaxKind[SyntaxKind["LiteralType"] = 173] = "LiteralType"; + SyntaxKind[SyntaxKind["ObjectBindingPattern"] = 174] = "ObjectBindingPattern"; + SyntaxKind[SyntaxKind["ArrayBindingPattern"] = 175] = "ArrayBindingPattern"; + SyntaxKind[SyntaxKind["BindingElement"] = 176] = "BindingElement"; + SyntaxKind[SyntaxKind["ArrayLiteralExpression"] = 177] = "ArrayLiteralExpression"; + SyntaxKind[SyntaxKind["ObjectLiteralExpression"] = 178] = "ObjectLiteralExpression"; + SyntaxKind[SyntaxKind["PropertyAccessExpression"] = 179] = "PropertyAccessExpression"; + SyntaxKind[SyntaxKind["ElementAccessExpression"] = 180] = "ElementAccessExpression"; + SyntaxKind[SyntaxKind["CallExpression"] = 181] = "CallExpression"; + SyntaxKind[SyntaxKind["NewExpression"] = 182] = "NewExpression"; + SyntaxKind[SyntaxKind["TaggedTemplateExpression"] = 183] = "TaggedTemplateExpression"; + SyntaxKind[SyntaxKind["TypeAssertionExpression"] = 184] = "TypeAssertionExpression"; + SyntaxKind[SyntaxKind["ParenthesizedExpression"] = 185] = "ParenthesizedExpression"; + SyntaxKind[SyntaxKind["FunctionExpression"] = 186] = "FunctionExpression"; + SyntaxKind[SyntaxKind["ArrowFunction"] = 187] = "ArrowFunction"; + SyntaxKind[SyntaxKind["DeleteExpression"] = 188] = "DeleteExpression"; + SyntaxKind[SyntaxKind["TypeOfExpression"] = 189] = "TypeOfExpression"; + SyntaxKind[SyntaxKind["VoidExpression"] = 190] = "VoidExpression"; + SyntaxKind[SyntaxKind["AwaitExpression"] = 191] = "AwaitExpression"; + SyntaxKind[SyntaxKind["PrefixUnaryExpression"] = 192] = "PrefixUnaryExpression"; + SyntaxKind[SyntaxKind["PostfixUnaryExpression"] = 193] = "PostfixUnaryExpression"; + SyntaxKind[SyntaxKind["BinaryExpression"] = 194] = "BinaryExpression"; + SyntaxKind[SyntaxKind["ConditionalExpression"] = 195] = "ConditionalExpression"; + SyntaxKind[SyntaxKind["TemplateExpression"] = 196] = "TemplateExpression"; + SyntaxKind[SyntaxKind["YieldExpression"] = 197] = "YieldExpression"; + SyntaxKind[SyntaxKind["SpreadElement"] = 198] = "SpreadElement"; + SyntaxKind[SyntaxKind["ClassExpression"] = 199] = "ClassExpression"; + SyntaxKind[SyntaxKind["OmittedExpression"] = 200] = "OmittedExpression"; + SyntaxKind[SyntaxKind["ExpressionWithTypeArguments"] = 201] = "ExpressionWithTypeArguments"; + SyntaxKind[SyntaxKind["AsExpression"] = 202] = "AsExpression"; + SyntaxKind[SyntaxKind["NonNullExpression"] = 203] = "NonNullExpression"; + SyntaxKind[SyntaxKind["MetaProperty"] = 204] = "MetaProperty"; + SyntaxKind[SyntaxKind["TemplateSpan"] = 205] = "TemplateSpan"; + SyntaxKind[SyntaxKind["SemicolonClassElement"] = 206] = "SemicolonClassElement"; + SyntaxKind[SyntaxKind["Block"] = 207] = "Block"; + SyntaxKind[SyntaxKind["VariableStatement"] = 208] = "VariableStatement"; + SyntaxKind[SyntaxKind["EmptyStatement"] = 209] = "EmptyStatement"; + SyntaxKind[SyntaxKind["ExpressionStatement"] = 210] = "ExpressionStatement"; + SyntaxKind[SyntaxKind["IfStatement"] = 211] = "IfStatement"; + SyntaxKind[SyntaxKind["DoStatement"] = 212] = "DoStatement"; + SyntaxKind[SyntaxKind["WhileStatement"] = 213] = "WhileStatement"; + SyntaxKind[SyntaxKind["ForStatement"] = 214] = "ForStatement"; + SyntaxKind[SyntaxKind["ForInStatement"] = 215] = "ForInStatement"; + SyntaxKind[SyntaxKind["ForOfStatement"] = 216] = "ForOfStatement"; + SyntaxKind[SyntaxKind["ContinueStatement"] = 217] = "ContinueStatement"; + SyntaxKind[SyntaxKind["BreakStatement"] = 218] = "BreakStatement"; + SyntaxKind[SyntaxKind["ReturnStatement"] = 219] = "ReturnStatement"; + SyntaxKind[SyntaxKind["WithStatement"] = 220] = "WithStatement"; + SyntaxKind[SyntaxKind["SwitchStatement"] = 221] = "SwitchStatement"; + SyntaxKind[SyntaxKind["LabeledStatement"] = 222] = "LabeledStatement"; + SyntaxKind[SyntaxKind["ThrowStatement"] = 223] = "ThrowStatement"; + SyntaxKind[SyntaxKind["TryStatement"] = 224] = "TryStatement"; + SyntaxKind[SyntaxKind["DebuggerStatement"] = 225] = "DebuggerStatement"; + SyntaxKind[SyntaxKind["VariableDeclaration"] = 226] = "VariableDeclaration"; + SyntaxKind[SyntaxKind["VariableDeclarationList"] = 227] = "VariableDeclarationList"; + SyntaxKind[SyntaxKind["FunctionDeclaration"] = 228] = "FunctionDeclaration"; + SyntaxKind[SyntaxKind["ClassDeclaration"] = 229] = "ClassDeclaration"; + SyntaxKind[SyntaxKind["InterfaceDeclaration"] = 230] = "InterfaceDeclaration"; + SyntaxKind[SyntaxKind["TypeAliasDeclaration"] = 231] = "TypeAliasDeclaration"; + SyntaxKind[SyntaxKind["EnumDeclaration"] = 232] = "EnumDeclaration"; + SyntaxKind[SyntaxKind["ModuleDeclaration"] = 233] = "ModuleDeclaration"; + SyntaxKind[SyntaxKind["ModuleBlock"] = 234] = "ModuleBlock"; + SyntaxKind[SyntaxKind["CaseBlock"] = 235] = "CaseBlock"; + SyntaxKind[SyntaxKind["NamespaceExportDeclaration"] = 236] = "NamespaceExportDeclaration"; + SyntaxKind[SyntaxKind["ImportEqualsDeclaration"] = 237] = "ImportEqualsDeclaration"; + SyntaxKind[SyntaxKind["ImportDeclaration"] = 238] = "ImportDeclaration"; + SyntaxKind[SyntaxKind["ImportClause"] = 239] = "ImportClause"; + SyntaxKind[SyntaxKind["NamespaceImport"] = 240] = "NamespaceImport"; + SyntaxKind[SyntaxKind["NamedImports"] = 241] = "NamedImports"; + SyntaxKind[SyntaxKind["ImportSpecifier"] = 242] = "ImportSpecifier"; + SyntaxKind[SyntaxKind["ExportAssignment"] = 243] = "ExportAssignment"; + SyntaxKind[SyntaxKind["ExportDeclaration"] = 244] = "ExportDeclaration"; + SyntaxKind[SyntaxKind["NamedExports"] = 245] = "NamedExports"; + SyntaxKind[SyntaxKind["ExportSpecifier"] = 246] = "ExportSpecifier"; + SyntaxKind[SyntaxKind["MissingDeclaration"] = 247] = "MissingDeclaration"; + SyntaxKind[SyntaxKind["ExternalModuleReference"] = 248] = "ExternalModuleReference"; + SyntaxKind[SyntaxKind["JsxElement"] = 249] = "JsxElement"; + SyntaxKind[SyntaxKind["JsxSelfClosingElement"] = 250] = "JsxSelfClosingElement"; + SyntaxKind[SyntaxKind["JsxOpeningElement"] = 251] = "JsxOpeningElement"; + SyntaxKind[SyntaxKind["JsxClosingElement"] = 252] = "JsxClosingElement"; + SyntaxKind[SyntaxKind["JsxAttribute"] = 253] = "JsxAttribute"; + SyntaxKind[SyntaxKind["JsxAttributes"] = 254] = "JsxAttributes"; + SyntaxKind[SyntaxKind["JsxSpreadAttribute"] = 255] = "JsxSpreadAttribute"; + SyntaxKind[SyntaxKind["JsxExpression"] = 256] = "JsxExpression"; + SyntaxKind[SyntaxKind["CaseClause"] = 257] = "CaseClause"; + SyntaxKind[SyntaxKind["DefaultClause"] = 258] = "DefaultClause"; + SyntaxKind[SyntaxKind["HeritageClause"] = 259] = "HeritageClause"; + SyntaxKind[SyntaxKind["CatchClause"] = 260] = "CatchClause"; + SyntaxKind[SyntaxKind["PropertyAssignment"] = 261] = "PropertyAssignment"; + SyntaxKind[SyntaxKind["ShorthandPropertyAssignment"] = 262] = "ShorthandPropertyAssignment"; + SyntaxKind[SyntaxKind["SpreadAssignment"] = 263] = "SpreadAssignment"; + SyntaxKind[SyntaxKind["EnumMember"] = 264] = "EnumMember"; + SyntaxKind[SyntaxKind["SourceFile"] = 265] = "SourceFile"; + SyntaxKind[SyntaxKind["Bundle"] = 266] = "Bundle"; + SyntaxKind[SyntaxKind["JSDocTypeExpression"] = 267] = "JSDocTypeExpression"; + SyntaxKind[SyntaxKind["JSDocAllType"] = 268] = "JSDocAllType"; + SyntaxKind[SyntaxKind["JSDocUnknownType"] = 269] = "JSDocUnknownType"; + SyntaxKind[SyntaxKind["JSDocNullableType"] = 270] = "JSDocNullableType"; + SyntaxKind[SyntaxKind["JSDocNonNullableType"] = 271] = "JSDocNonNullableType"; + SyntaxKind[SyntaxKind["JSDocOptionalType"] = 272] = "JSDocOptionalType"; + SyntaxKind[SyntaxKind["JSDocFunctionType"] = 273] = "JSDocFunctionType"; + SyntaxKind[SyntaxKind["JSDocVariadicType"] = 274] = "JSDocVariadicType"; + SyntaxKind[SyntaxKind["JSDocComment"] = 275] = "JSDocComment"; + SyntaxKind[SyntaxKind["JSDocTag"] = 276] = "JSDocTag"; + SyntaxKind[SyntaxKind["JSDocAugmentsTag"] = 277] = "JSDocAugmentsTag"; + SyntaxKind[SyntaxKind["JSDocClassTag"] = 278] = "JSDocClassTag"; + SyntaxKind[SyntaxKind["JSDocParameterTag"] = 279] = "JSDocParameterTag"; + SyntaxKind[SyntaxKind["JSDocReturnTag"] = 280] = "JSDocReturnTag"; + SyntaxKind[SyntaxKind["JSDocTypeTag"] = 281] = "JSDocTypeTag"; + SyntaxKind[SyntaxKind["JSDocTemplateTag"] = 282] = "JSDocTemplateTag"; + SyntaxKind[SyntaxKind["JSDocTypedefTag"] = 283] = "JSDocTypedefTag"; + SyntaxKind[SyntaxKind["JSDocPropertyTag"] = 284] = "JSDocPropertyTag"; + SyntaxKind[SyntaxKind["JSDocTypeLiteral"] = 285] = "JSDocTypeLiteral"; + SyntaxKind[SyntaxKind["SyntaxList"] = 286] = "SyntaxList"; + SyntaxKind[SyntaxKind["NotEmittedStatement"] = 287] = "NotEmittedStatement"; + SyntaxKind[SyntaxKind["PartiallyEmittedExpression"] = 288] = "PartiallyEmittedExpression"; + SyntaxKind[SyntaxKind["CommaListExpression"] = 289] = "CommaListExpression"; + SyntaxKind[SyntaxKind["MergeDeclarationMarker"] = 290] = "MergeDeclarationMarker"; + SyntaxKind[SyntaxKind["EndOfDeclarationMarker"] = 291] = "EndOfDeclarationMarker"; + SyntaxKind[SyntaxKind["Count"] = 292] = "Count"; + SyntaxKind[SyntaxKind["FirstAssignment"] = 58] = "FirstAssignment"; + SyntaxKind[SyntaxKind["LastAssignment"] = 70] = "LastAssignment"; + SyntaxKind[SyntaxKind["FirstCompoundAssignment"] = 59] = "FirstCompoundAssignment"; + SyntaxKind[SyntaxKind["LastCompoundAssignment"] = 70] = "LastCompoundAssignment"; + SyntaxKind[SyntaxKind["FirstReservedWord"] = 72] = "FirstReservedWord"; + SyntaxKind[SyntaxKind["LastReservedWord"] = 107] = "LastReservedWord"; + SyntaxKind[SyntaxKind["FirstKeyword"] = 72] = "FirstKeyword"; + SyntaxKind[SyntaxKind["LastKeyword"] = 142] = "LastKeyword"; + SyntaxKind[SyntaxKind["FirstFutureReservedWord"] = 108] = "FirstFutureReservedWord"; + SyntaxKind[SyntaxKind["LastFutureReservedWord"] = 116] = "LastFutureReservedWord"; + SyntaxKind[SyntaxKind["FirstTypeNode"] = 158] = "FirstTypeNode"; + SyntaxKind[SyntaxKind["LastTypeNode"] = 173] = "LastTypeNode"; + SyntaxKind[SyntaxKind["FirstPunctuation"] = 17] = "FirstPunctuation"; + SyntaxKind[SyntaxKind["LastPunctuation"] = 70] = "LastPunctuation"; + SyntaxKind[SyntaxKind["FirstToken"] = 0] = "FirstToken"; + SyntaxKind[SyntaxKind["LastToken"] = 142] = "LastToken"; + SyntaxKind[SyntaxKind["FirstTriviaToken"] = 2] = "FirstTriviaToken"; + SyntaxKind[SyntaxKind["LastTriviaToken"] = 7] = "LastTriviaToken"; + SyntaxKind[SyntaxKind["FirstLiteralToken"] = 8] = "FirstLiteralToken"; + SyntaxKind[SyntaxKind["LastLiteralToken"] = 13] = "LastLiteralToken"; + SyntaxKind[SyntaxKind["FirstTemplateToken"] = 13] = "FirstTemplateToken"; + SyntaxKind[SyntaxKind["LastTemplateToken"] = 16] = "LastTemplateToken"; + SyntaxKind[SyntaxKind["FirstBinaryOperator"] = 27] = "FirstBinaryOperator"; + SyntaxKind[SyntaxKind["LastBinaryOperator"] = 70] = "LastBinaryOperator"; + SyntaxKind[SyntaxKind["FirstNode"] = 143] = "FirstNode"; + SyntaxKind[SyntaxKind["FirstJSDocNode"] = 267] = "FirstJSDocNode"; + SyntaxKind[SyntaxKind["LastJSDocNode"] = 285] = "LastJSDocNode"; + SyntaxKind[SyntaxKind["FirstJSDocTagNode"] = 276] = "FirstJSDocTagNode"; + SyntaxKind[SyntaxKind["LastJSDocTagNode"] = 285] = "LastJSDocTagNode"; + })(SyntaxKind = ts.SyntaxKind || (ts.SyntaxKind = {})); + var NodeFlags; + (function (NodeFlags) { + NodeFlags[NodeFlags["None"] = 0] = "None"; + NodeFlags[NodeFlags["Let"] = 1] = "Let"; + NodeFlags[NodeFlags["Const"] = 2] = "Const"; + NodeFlags[NodeFlags["NestedNamespace"] = 4] = "NestedNamespace"; + NodeFlags[NodeFlags["Synthesized"] = 8] = "Synthesized"; + NodeFlags[NodeFlags["Namespace"] = 16] = "Namespace"; + NodeFlags[NodeFlags["ExportContext"] = 32] = "ExportContext"; + NodeFlags[NodeFlags["ContainsThis"] = 64] = "ContainsThis"; + NodeFlags[NodeFlags["HasImplicitReturn"] = 128] = "HasImplicitReturn"; + NodeFlags[NodeFlags["HasExplicitReturn"] = 256] = "HasExplicitReturn"; + NodeFlags[NodeFlags["GlobalAugmentation"] = 512] = "GlobalAugmentation"; + NodeFlags[NodeFlags["HasAsyncFunctions"] = 1024] = "HasAsyncFunctions"; + NodeFlags[NodeFlags["DisallowInContext"] = 2048] = "DisallowInContext"; + NodeFlags[NodeFlags["YieldContext"] = 4096] = "YieldContext"; + NodeFlags[NodeFlags["DecoratorContext"] = 8192] = "DecoratorContext"; + NodeFlags[NodeFlags["AwaitContext"] = 16384] = "AwaitContext"; + NodeFlags[NodeFlags["ThisNodeHasError"] = 32768] = "ThisNodeHasError"; + NodeFlags[NodeFlags["JavaScriptFile"] = 65536] = "JavaScriptFile"; + NodeFlags[NodeFlags["ThisNodeOrAnySubNodesHasError"] = 131072] = "ThisNodeOrAnySubNodesHasError"; + NodeFlags[NodeFlags["HasAggregatedChildData"] = 262144] = "HasAggregatedChildData"; + NodeFlags[NodeFlags["PossiblyContainsDynamicImport"] = 524288] = "PossiblyContainsDynamicImport"; + NodeFlags[NodeFlags["JSDoc"] = 1048576] = "JSDoc"; + NodeFlags[NodeFlags["BlockScoped"] = 3] = "BlockScoped"; + NodeFlags[NodeFlags["ReachabilityCheckFlags"] = 384] = "ReachabilityCheckFlags"; + NodeFlags[NodeFlags["ReachabilityAndEmitFlags"] = 1408] = "ReachabilityAndEmitFlags"; + NodeFlags[NodeFlags["ContextFlags"] = 96256] = "ContextFlags"; + NodeFlags[NodeFlags["TypeExcludesFlags"] = 20480] = "TypeExcludesFlags"; + })(NodeFlags = ts.NodeFlags || (ts.NodeFlags = {})); + var ModifierFlags; + (function (ModifierFlags) { + ModifierFlags[ModifierFlags["None"] = 0] = "None"; + ModifierFlags[ModifierFlags["Export"] = 1] = "Export"; + ModifierFlags[ModifierFlags["Ambient"] = 2] = "Ambient"; + ModifierFlags[ModifierFlags["Public"] = 4] = "Public"; + ModifierFlags[ModifierFlags["Private"] = 8] = "Private"; + ModifierFlags[ModifierFlags["Protected"] = 16] = "Protected"; + ModifierFlags[ModifierFlags["Static"] = 32] = "Static"; + ModifierFlags[ModifierFlags["Readonly"] = 64] = "Readonly"; + ModifierFlags[ModifierFlags["Abstract"] = 128] = "Abstract"; + ModifierFlags[ModifierFlags["Async"] = 256] = "Async"; + ModifierFlags[ModifierFlags["Default"] = 512] = "Default"; + ModifierFlags[ModifierFlags["Const"] = 2048] = "Const"; + ModifierFlags[ModifierFlags["HasComputedFlags"] = 536870912] = "HasComputedFlags"; + ModifierFlags[ModifierFlags["AccessibilityModifier"] = 28] = "AccessibilityModifier"; + ModifierFlags[ModifierFlags["ParameterPropertyModifier"] = 92] = "ParameterPropertyModifier"; + ModifierFlags[ModifierFlags["NonPublicAccessibilityModifier"] = 24] = "NonPublicAccessibilityModifier"; + ModifierFlags[ModifierFlags["TypeScriptModifier"] = 2270] = "TypeScriptModifier"; + ModifierFlags[ModifierFlags["ExportDefault"] = 513] = "ExportDefault"; + })(ModifierFlags = ts.ModifierFlags || (ts.ModifierFlags = {})); + var JsxFlags; + (function (JsxFlags) { + JsxFlags[JsxFlags["None"] = 0] = "None"; + JsxFlags[JsxFlags["IntrinsicNamedElement"] = 1] = "IntrinsicNamedElement"; + JsxFlags[JsxFlags["IntrinsicIndexedElement"] = 2] = "IntrinsicIndexedElement"; + JsxFlags[JsxFlags["IntrinsicElement"] = 3] = "IntrinsicElement"; + })(JsxFlags = ts.JsxFlags || (ts.JsxFlags = {})); + var RelationComparisonResult; + (function (RelationComparisonResult) { + RelationComparisonResult[RelationComparisonResult["Succeeded"] = 1] = "Succeeded"; + RelationComparisonResult[RelationComparisonResult["Failed"] = 2] = "Failed"; + RelationComparisonResult[RelationComparisonResult["FailedAndReported"] = 3] = "FailedAndReported"; + })(RelationComparisonResult = ts.RelationComparisonResult || (ts.RelationComparisonResult = {})); + var GeneratedIdentifierKind; + (function (GeneratedIdentifierKind) { + GeneratedIdentifierKind[GeneratedIdentifierKind["None"] = 0] = "None"; + GeneratedIdentifierKind[GeneratedIdentifierKind["Auto"] = 1] = "Auto"; + GeneratedIdentifierKind[GeneratedIdentifierKind["Loop"] = 2] = "Loop"; + GeneratedIdentifierKind[GeneratedIdentifierKind["Unique"] = 3] = "Unique"; + GeneratedIdentifierKind[GeneratedIdentifierKind["Node"] = 4] = "Node"; + })(GeneratedIdentifierKind = ts.GeneratedIdentifierKind || (ts.GeneratedIdentifierKind = {})); + var NumericLiteralFlags; + (function (NumericLiteralFlags) { + NumericLiteralFlags[NumericLiteralFlags["None"] = 0] = "None"; + NumericLiteralFlags[NumericLiteralFlags["Scientific"] = 2] = "Scientific"; + NumericLiteralFlags[NumericLiteralFlags["Octal"] = 4] = "Octal"; + NumericLiteralFlags[NumericLiteralFlags["HexSpecifier"] = 8] = "HexSpecifier"; + NumericLiteralFlags[NumericLiteralFlags["BinarySpecifier"] = 16] = "BinarySpecifier"; + NumericLiteralFlags[NumericLiteralFlags["OctalSpecifier"] = 32] = "OctalSpecifier"; + NumericLiteralFlags[NumericLiteralFlags["BinaryOrOctalSpecifier"] = 48] = "BinaryOrOctalSpecifier"; + })(NumericLiteralFlags = ts.NumericLiteralFlags || (ts.NumericLiteralFlags = {})); + var FlowFlags; + (function (FlowFlags) { + FlowFlags[FlowFlags["Unreachable"] = 1] = "Unreachable"; + FlowFlags[FlowFlags["Start"] = 2] = "Start"; + FlowFlags[FlowFlags["BranchLabel"] = 4] = "BranchLabel"; + FlowFlags[FlowFlags["LoopLabel"] = 8] = "LoopLabel"; + FlowFlags[FlowFlags["Assignment"] = 16] = "Assignment"; + FlowFlags[FlowFlags["TrueCondition"] = 32] = "TrueCondition"; + FlowFlags[FlowFlags["FalseCondition"] = 64] = "FalseCondition"; + FlowFlags[FlowFlags["SwitchClause"] = 128] = "SwitchClause"; + FlowFlags[FlowFlags["ArrayMutation"] = 256] = "ArrayMutation"; + FlowFlags[FlowFlags["Referenced"] = 512] = "Referenced"; + FlowFlags[FlowFlags["Shared"] = 1024] = "Shared"; + FlowFlags[FlowFlags["PreFinally"] = 2048] = "PreFinally"; + FlowFlags[FlowFlags["AfterFinally"] = 4096] = "AfterFinally"; + FlowFlags[FlowFlags["Label"] = 12] = "Label"; + FlowFlags[FlowFlags["Condition"] = 96] = "Condition"; + })(FlowFlags = ts.FlowFlags || (ts.FlowFlags = {})); var OperationCanceledException = (function () { function OperationCanceledException() { } return OperationCanceledException; }()); ts.OperationCanceledException = OperationCanceledException; + var StructureIsReused; + (function (StructureIsReused) { + StructureIsReused[StructureIsReused["Not"] = 0] = "Not"; + StructureIsReused[StructureIsReused["SafeModules"] = 1] = "SafeModules"; + StructureIsReused[StructureIsReused["Completely"] = 2] = "Completely"; + })(StructureIsReused = ts.StructureIsReused || (ts.StructureIsReused = {})); var ExitStatus; (function (ExitStatus) { ExitStatus[ExitStatus["Success"] = 0] = "Success"; @@ -46,6 +485,47 @@ var ts; NodeBuilderFlags[NodeBuilderFlags["InObjectTypeLiteral"] = 1048576] = "InObjectTypeLiteral"; NodeBuilderFlags[NodeBuilderFlags["InTypeAlias"] = 8388608] = "InTypeAlias"; })(NodeBuilderFlags = ts.NodeBuilderFlags || (ts.NodeBuilderFlags = {})); + var TypeFormatFlags; + (function (TypeFormatFlags) { + TypeFormatFlags[TypeFormatFlags["None"] = 0] = "None"; + TypeFormatFlags[TypeFormatFlags["WriteArrayAsGenericType"] = 1] = "WriteArrayAsGenericType"; + TypeFormatFlags[TypeFormatFlags["UseTypeOfFunction"] = 4] = "UseTypeOfFunction"; + TypeFormatFlags[TypeFormatFlags["NoTruncation"] = 8] = "NoTruncation"; + TypeFormatFlags[TypeFormatFlags["WriteArrowStyleSignature"] = 16] = "WriteArrowStyleSignature"; + TypeFormatFlags[TypeFormatFlags["WriteOwnNameForAnyLike"] = 32] = "WriteOwnNameForAnyLike"; + TypeFormatFlags[TypeFormatFlags["WriteTypeArgumentsOfSignature"] = 64] = "WriteTypeArgumentsOfSignature"; + TypeFormatFlags[TypeFormatFlags["InElementType"] = 128] = "InElementType"; + TypeFormatFlags[TypeFormatFlags["UseFullyQualifiedType"] = 256] = "UseFullyQualifiedType"; + TypeFormatFlags[TypeFormatFlags["InFirstTypeArgument"] = 512] = "InFirstTypeArgument"; + TypeFormatFlags[TypeFormatFlags["InTypeAlias"] = 1024] = "InTypeAlias"; + TypeFormatFlags[TypeFormatFlags["SuppressAnyReturnType"] = 4096] = "SuppressAnyReturnType"; + TypeFormatFlags[TypeFormatFlags["AddUndefined"] = 8192] = "AddUndefined"; + TypeFormatFlags[TypeFormatFlags["WriteClassExpressionAsTypeLiteral"] = 16384] = "WriteClassExpressionAsTypeLiteral"; + TypeFormatFlags[TypeFormatFlags["InArrayType"] = 32768] = "InArrayType"; + TypeFormatFlags[TypeFormatFlags["UseAliasDefinedOutsideCurrentScope"] = 65536] = "UseAliasDefinedOutsideCurrentScope"; + })(TypeFormatFlags = ts.TypeFormatFlags || (ts.TypeFormatFlags = {})); + var SymbolFormatFlags; + (function (SymbolFormatFlags) { + SymbolFormatFlags[SymbolFormatFlags["None"] = 0] = "None"; + SymbolFormatFlags[SymbolFormatFlags["WriteTypeParametersOrArguments"] = 1] = "WriteTypeParametersOrArguments"; + SymbolFormatFlags[SymbolFormatFlags["UseOnlyExternalAliasing"] = 2] = "UseOnlyExternalAliasing"; + })(SymbolFormatFlags = ts.SymbolFormatFlags || (ts.SymbolFormatFlags = {})); + var SymbolAccessibility; + (function (SymbolAccessibility) { + SymbolAccessibility[SymbolAccessibility["Accessible"] = 0] = "Accessible"; + SymbolAccessibility[SymbolAccessibility["NotAccessible"] = 1] = "NotAccessible"; + SymbolAccessibility[SymbolAccessibility["CannotBeNamed"] = 2] = "CannotBeNamed"; + })(SymbolAccessibility = ts.SymbolAccessibility || (ts.SymbolAccessibility = {})); + var SyntheticSymbolKind; + (function (SyntheticSymbolKind) { + SyntheticSymbolKind[SyntheticSymbolKind["UnionOrIntersection"] = 0] = "UnionOrIntersection"; + SyntheticSymbolKind[SyntheticSymbolKind["Spread"] = 1] = "Spread"; + })(SyntheticSymbolKind = ts.SyntheticSymbolKind || (ts.SyntheticSymbolKind = {})); + var TypePredicateKind; + (function (TypePredicateKind) { + TypePredicateKind[TypePredicateKind["This"] = 0] = "This"; + TypePredicateKind[TypePredicateKind["Identifier"] = 1] = "Identifier"; + })(TypePredicateKind = ts.TypePredicateKind || (ts.TypePredicateKind = {})); var TypeReferenceSerializationKind; (function (TypeReferenceSerializationKind) { TypeReferenceSerializationKind[TypeReferenceSerializationKind["Unknown"] = 0] = "Unknown"; @@ -60,6 +540,230 @@ var ts; TypeReferenceSerializationKind[TypeReferenceSerializationKind["TypeWithCallSignature"] = 9] = "TypeWithCallSignature"; TypeReferenceSerializationKind[TypeReferenceSerializationKind["ObjectType"] = 10] = "ObjectType"; })(TypeReferenceSerializationKind = ts.TypeReferenceSerializationKind || (ts.TypeReferenceSerializationKind = {})); + var SymbolFlags; + (function (SymbolFlags) { + SymbolFlags[SymbolFlags["None"] = 0] = "None"; + SymbolFlags[SymbolFlags["FunctionScopedVariable"] = 1] = "FunctionScopedVariable"; + SymbolFlags[SymbolFlags["BlockScopedVariable"] = 2] = "BlockScopedVariable"; + SymbolFlags[SymbolFlags["Property"] = 4] = "Property"; + SymbolFlags[SymbolFlags["EnumMember"] = 8] = "EnumMember"; + SymbolFlags[SymbolFlags["Function"] = 16] = "Function"; + SymbolFlags[SymbolFlags["Class"] = 32] = "Class"; + SymbolFlags[SymbolFlags["Interface"] = 64] = "Interface"; + SymbolFlags[SymbolFlags["ConstEnum"] = 128] = "ConstEnum"; + SymbolFlags[SymbolFlags["RegularEnum"] = 256] = "RegularEnum"; + SymbolFlags[SymbolFlags["ValueModule"] = 512] = "ValueModule"; + SymbolFlags[SymbolFlags["NamespaceModule"] = 1024] = "NamespaceModule"; + SymbolFlags[SymbolFlags["TypeLiteral"] = 2048] = "TypeLiteral"; + SymbolFlags[SymbolFlags["ObjectLiteral"] = 4096] = "ObjectLiteral"; + SymbolFlags[SymbolFlags["Method"] = 8192] = "Method"; + SymbolFlags[SymbolFlags["Constructor"] = 16384] = "Constructor"; + SymbolFlags[SymbolFlags["GetAccessor"] = 32768] = "GetAccessor"; + SymbolFlags[SymbolFlags["SetAccessor"] = 65536] = "SetAccessor"; + SymbolFlags[SymbolFlags["Signature"] = 131072] = "Signature"; + SymbolFlags[SymbolFlags["TypeParameter"] = 262144] = "TypeParameter"; + SymbolFlags[SymbolFlags["TypeAlias"] = 524288] = "TypeAlias"; + SymbolFlags[SymbolFlags["ExportValue"] = 1048576] = "ExportValue"; + SymbolFlags[SymbolFlags["Alias"] = 2097152] = "Alias"; + SymbolFlags[SymbolFlags["Prototype"] = 4194304] = "Prototype"; + SymbolFlags[SymbolFlags["ExportStar"] = 8388608] = "ExportStar"; + SymbolFlags[SymbolFlags["Optional"] = 16777216] = "Optional"; + SymbolFlags[SymbolFlags["Transient"] = 33554432] = "Transient"; + SymbolFlags[SymbolFlags["Enum"] = 384] = "Enum"; + SymbolFlags[SymbolFlags["Variable"] = 3] = "Variable"; + SymbolFlags[SymbolFlags["Value"] = 107455] = "Value"; + SymbolFlags[SymbolFlags["Type"] = 793064] = "Type"; + SymbolFlags[SymbolFlags["Namespace"] = 1920] = "Namespace"; + SymbolFlags[SymbolFlags["Module"] = 1536] = "Module"; + SymbolFlags[SymbolFlags["Accessor"] = 98304] = "Accessor"; + SymbolFlags[SymbolFlags["FunctionScopedVariableExcludes"] = 107454] = "FunctionScopedVariableExcludes"; + SymbolFlags[SymbolFlags["BlockScopedVariableExcludes"] = 107455] = "BlockScopedVariableExcludes"; + SymbolFlags[SymbolFlags["ParameterExcludes"] = 107455] = "ParameterExcludes"; + SymbolFlags[SymbolFlags["PropertyExcludes"] = 0] = "PropertyExcludes"; + SymbolFlags[SymbolFlags["EnumMemberExcludes"] = 900095] = "EnumMemberExcludes"; + SymbolFlags[SymbolFlags["FunctionExcludes"] = 106927] = "FunctionExcludes"; + SymbolFlags[SymbolFlags["ClassExcludes"] = 899519] = "ClassExcludes"; + SymbolFlags[SymbolFlags["InterfaceExcludes"] = 792968] = "InterfaceExcludes"; + SymbolFlags[SymbolFlags["RegularEnumExcludes"] = 899327] = "RegularEnumExcludes"; + SymbolFlags[SymbolFlags["ConstEnumExcludes"] = 899967] = "ConstEnumExcludes"; + SymbolFlags[SymbolFlags["ValueModuleExcludes"] = 106639] = "ValueModuleExcludes"; + SymbolFlags[SymbolFlags["NamespaceModuleExcludes"] = 0] = "NamespaceModuleExcludes"; + SymbolFlags[SymbolFlags["MethodExcludes"] = 99263] = "MethodExcludes"; + SymbolFlags[SymbolFlags["GetAccessorExcludes"] = 41919] = "GetAccessorExcludes"; + SymbolFlags[SymbolFlags["SetAccessorExcludes"] = 74687] = "SetAccessorExcludes"; + SymbolFlags[SymbolFlags["TypeParameterExcludes"] = 530920] = "TypeParameterExcludes"; + SymbolFlags[SymbolFlags["TypeAliasExcludes"] = 793064] = "TypeAliasExcludes"; + SymbolFlags[SymbolFlags["AliasExcludes"] = 2097152] = "AliasExcludes"; + SymbolFlags[SymbolFlags["ModuleMember"] = 2623475] = "ModuleMember"; + SymbolFlags[SymbolFlags["ExportHasLocal"] = 944] = "ExportHasLocal"; + SymbolFlags[SymbolFlags["HasExports"] = 1952] = "HasExports"; + SymbolFlags[SymbolFlags["HasMembers"] = 6240] = "HasMembers"; + SymbolFlags[SymbolFlags["BlockScoped"] = 418] = "BlockScoped"; + SymbolFlags[SymbolFlags["PropertyOrAccessor"] = 98308] = "PropertyOrAccessor"; + SymbolFlags[SymbolFlags["ClassMember"] = 106500] = "ClassMember"; + SymbolFlags[SymbolFlags["Classifiable"] = 788448] = "Classifiable"; + })(SymbolFlags = ts.SymbolFlags || (ts.SymbolFlags = {})); + var EnumKind; + (function (EnumKind) { + EnumKind[EnumKind["Numeric"] = 0] = "Numeric"; + EnumKind[EnumKind["Literal"] = 1] = "Literal"; + })(EnumKind = ts.EnumKind || (ts.EnumKind = {})); + var CheckFlags; + (function (CheckFlags) { + CheckFlags[CheckFlags["Instantiated"] = 1] = "Instantiated"; + CheckFlags[CheckFlags["SyntheticProperty"] = 2] = "SyntheticProperty"; + CheckFlags[CheckFlags["SyntheticMethod"] = 4] = "SyntheticMethod"; + CheckFlags[CheckFlags["Readonly"] = 8] = "Readonly"; + CheckFlags[CheckFlags["Partial"] = 16] = "Partial"; + CheckFlags[CheckFlags["HasNonUniformType"] = 32] = "HasNonUniformType"; + CheckFlags[CheckFlags["ContainsPublic"] = 64] = "ContainsPublic"; + CheckFlags[CheckFlags["ContainsProtected"] = 128] = "ContainsProtected"; + CheckFlags[CheckFlags["ContainsPrivate"] = 256] = "ContainsPrivate"; + CheckFlags[CheckFlags["ContainsStatic"] = 512] = "ContainsStatic"; + CheckFlags[CheckFlags["Synthetic"] = 6] = "Synthetic"; + })(CheckFlags = ts.CheckFlags || (ts.CheckFlags = {})); + var InternalSymbolName; + (function (InternalSymbolName) { + InternalSymbolName["Call"] = "__call"; + InternalSymbolName["Constructor"] = "__constructor"; + InternalSymbolName["New"] = "__new"; + InternalSymbolName["Index"] = "__index"; + InternalSymbolName["ExportStar"] = "__export"; + InternalSymbolName["Global"] = "__global"; + InternalSymbolName["Missing"] = "__missing"; + InternalSymbolName["Type"] = "__type"; + InternalSymbolName["Object"] = "__object"; + InternalSymbolName["JSXAttributes"] = "__jsxAttributes"; + InternalSymbolName["Class"] = "__class"; + InternalSymbolName["Function"] = "__function"; + InternalSymbolName["Computed"] = "__computed"; + InternalSymbolName["Resolving"] = "__resolving__"; + InternalSymbolName["ExportEquals"] = "export="; + InternalSymbolName["Default"] = "default"; + })(InternalSymbolName = ts.InternalSymbolName || (ts.InternalSymbolName = {})); + var NodeCheckFlags; + (function (NodeCheckFlags) { + NodeCheckFlags[NodeCheckFlags["TypeChecked"] = 1] = "TypeChecked"; + NodeCheckFlags[NodeCheckFlags["LexicalThis"] = 2] = "LexicalThis"; + NodeCheckFlags[NodeCheckFlags["CaptureThis"] = 4] = "CaptureThis"; + NodeCheckFlags[NodeCheckFlags["CaptureNewTarget"] = 8] = "CaptureNewTarget"; + NodeCheckFlags[NodeCheckFlags["SuperInstance"] = 256] = "SuperInstance"; + NodeCheckFlags[NodeCheckFlags["SuperStatic"] = 512] = "SuperStatic"; + NodeCheckFlags[NodeCheckFlags["ContextChecked"] = 1024] = "ContextChecked"; + NodeCheckFlags[NodeCheckFlags["AsyncMethodWithSuper"] = 2048] = "AsyncMethodWithSuper"; + NodeCheckFlags[NodeCheckFlags["AsyncMethodWithSuperBinding"] = 4096] = "AsyncMethodWithSuperBinding"; + NodeCheckFlags[NodeCheckFlags["CaptureArguments"] = 8192] = "CaptureArguments"; + NodeCheckFlags[NodeCheckFlags["EnumValuesComputed"] = 16384] = "EnumValuesComputed"; + NodeCheckFlags[NodeCheckFlags["LexicalModuleMergesWithClass"] = 32768] = "LexicalModuleMergesWithClass"; + NodeCheckFlags[NodeCheckFlags["LoopWithCapturedBlockScopedBinding"] = 65536] = "LoopWithCapturedBlockScopedBinding"; + NodeCheckFlags[NodeCheckFlags["CapturedBlockScopedBinding"] = 131072] = "CapturedBlockScopedBinding"; + NodeCheckFlags[NodeCheckFlags["BlockScopedBindingInLoop"] = 262144] = "BlockScopedBindingInLoop"; + NodeCheckFlags[NodeCheckFlags["ClassWithBodyScopedClassBinding"] = 524288] = "ClassWithBodyScopedClassBinding"; + NodeCheckFlags[NodeCheckFlags["BodyScopedClassBinding"] = 1048576] = "BodyScopedClassBinding"; + NodeCheckFlags[NodeCheckFlags["NeedsLoopOutParameter"] = 2097152] = "NeedsLoopOutParameter"; + NodeCheckFlags[NodeCheckFlags["AssignmentsMarked"] = 4194304] = "AssignmentsMarked"; + NodeCheckFlags[NodeCheckFlags["ClassWithConstructorReference"] = 8388608] = "ClassWithConstructorReference"; + NodeCheckFlags[NodeCheckFlags["ConstructorReferenceInClass"] = 16777216] = "ConstructorReferenceInClass"; + })(NodeCheckFlags = ts.NodeCheckFlags || (ts.NodeCheckFlags = {})); + var TypeFlags; + (function (TypeFlags) { + TypeFlags[TypeFlags["Any"] = 1] = "Any"; + TypeFlags[TypeFlags["String"] = 2] = "String"; + TypeFlags[TypeFlags["Number"] = 4] = "Number"; + TypeFlags[TypeFlags["Boolean"] = 8] = "Boolean"; + TypeFlags[TypeFlags["Enum"] = 16] = "Enum"; + TypeFlags[TypeFlags["StringLiteral"] = 32] = "StringLiteral"; + TypeFlags[TypeFlags["NumberLiteral"] = 64] = "NumberLiteral"; + TypeFlags[TypeFlags["BooleanLiteral"] = 128] = "BooleanLiteral"; + TypeFlags[TypeFlags["EnumLiteral"] = 256] = "EnumLiteral"; + TypeFlags[TypeFlags["ESSymbol"] = 512] = "ESSymbol"; + TypeFlags[TypeFlags["Void"] = 1024] = "Void"; + TypeFlags[TypeFlags["Undefined"] = 2048] = "Undefined"; + TypeFlags[TypeFlags["Null"] = 4096] = "Null"; + TypeFlags[TypeFlags["Never"] = 8192] = "Never"; + TypeFlags[TypeFlags["TypeParameter"] = 16384] = "TypeParameter"; + TypeFlags[TypeFlags["Object"] = 32768] = "Object"; + TypeFlags[TypeFlags["Union"] = 65536] = "Union"; + TypeFlags[TypeFlags["Intersection"] = 131072] = "Intersection"; + TypeFlags[TypeFlags["Index"] = 262144] = "Index"; + TypeFlags[TypeFlags["IndexedAccess"] = 524288] = "IndexedAccess"; + TypeFlags[TypeFlags["FreshLiteral"] = 1048576] = "FreshLiteral"; + TypeFlags[TypeFlags["ContainsWideningType"] = 2097152] = "ContainsWideningType"; + TypeFlags[TypeFlags["ContainsObjectLiteral"] = 4194304] = "ContainsObjectLiteral"; + TypeFlags[TypeFlags["ContainsAnyFunctionType"] = 8388608] = "ContainsAnyFunctionType"; + TypeFlags[TypeFlags["NonPrimitive"] = 16777216] = "NonPrimitive"; + TypeFlags[TypeFlags["JsxAttributes"] = 33554432] = "JsxAttributes"; + TypeFlags[TypeFlags["Nullable"] = 6144] = "Nullable"; + TypeFlags[TypeFlags["Literal"] = 224] = "Literal"; + TypeFlags[TypeFlags["StringOrNumberLiteral"] = 96] = "StringOrNumberLiteral"; + TypeFlags[TypeFlags["DefinitelyFalsy"] = 7392] = "DefinitelyFalsy"; + TypeFlags[TypeFlags["PossiblyFalsy"] = 7406] = "PossiblyFalsy"; + TypeFlags[TypeFlags["Intrinsic"] = 16793231] = "Intrinsic"; + TypeFlags[TypeFlags["Primitive"] = 8190] = "Primitive"; + TypeFlags[TypeFlags["StringLike"] = 262178] = "StringLike"; + TypeFlags[TypeFlags["NumberLike"] = 84] = "NumberLike"; + TypeFlags[TypeFlags["BooleanLike"] = 136] = "BooleanLike"; + TypeFlags[TypeFlags["EnumLike"] = 272] = "EnumLike"; + TypeFlags[TypeFlags["UnionOrIntersection"] = 196608] = "UnionOrIntersection"; + TypeFlags[TypeFlags["StructuredType"] = 229376] = "StructuredType"; + TypeFlags[TypeFlags["StructuredOrTypeVariable"] = 1032192] = "StructuredOrTypeVariable"; + TypeFlags[TypeFlags["TypeVariable"] = 540672] = "TypeVariable"; + TypeFlags[TypeFlags["Narrowable"] = 17810175] = "Narrowable"; + TypeFlags[TypeFlags["NotUnionOrUnit"] = 16810497] = "NotUnionOrUnit"; + TypeFlags[TypeFlags["RequiresWidening"] = 6291456] = "RequiresWidening"; + TypeFlags[TypeFlags["PropagatingFlags"] = 14680064] = "PropagatingFlags"; + })(TypeFlags = ts.TypeFlags || (ts.TypeFlags = {})); + var ObjectFlags; + (function (ObjectFlags) { + ObjectFlags[ObjectFlags["Class"] = 1] = "Class"; + ObjectFlags[ObjectFlags["Interface"] = 2] = "Interface"; + ObjectFlags[ObjectFlags["Reference"] = 4] = "Reference"; + ObjectFlags[ObjectFlags["Tuple"] = 8] = "Tuple"; + ObjectFlags[ObjectFlags["Anonymous"] = 16] = "Anonymous"; + ObjectFlags[ObjectFlags["Mapped"] = 32] = "Mapped"; + ObjectFlags[ObjectFlags["Instantiated"] = 64] = "Instantiated"; + ObjectFlags[ObjectFlags["ObjectLiteral"] = 128] = "ObjectLiteral"; + ObjectFlags[ObjectFlags["EvolvingArray"] = 256] = "EvolvingArray"; + ObjectFlags[ObjectFlags["ObjectLiteralPatternWithComputedProperties"] = 512] = "ObjectLiteralPatternWithComputedProperties"; + ObjectFlags[ObjectFlags["ClassOrInterface"] = 3] = "ClassOrInterface"; + })(ObjectFlags = ts.ObjectFlags || (ts.ObjectFlags = {})); + var SignatureKind; + (function (SignatureKind) { + SignatureKind[SignatureKind["Call"] = 0] = "Call"; + SignatureKind[SignatureKind["Construct"] = 1] = "Construct"; + })(SignatureKind = ts.SignatureKind || (ts.SignatureKind = {})); + var IndexKind; + (function (IndexKind) { + IndexKind[IndexKind["String"] = 0] = "String"; + IndexKind[IndexKind["Number"] = 1] = "Number"; + })(IndexKind = ts.IndexKind || (ts.IndexKind = {})); + var InferencePriority; + (function (InferencePriority) { + InferencePriority[InferencePriority["NakedTypeVariable"] = 1] = "NakedTypeVariable"; + InferencePriority[InferencePriority["MappedType"] = 2] = "MappedType"; + InferencePriority[InferencePriority["ReturnType"] = 4] = "ReturnType"; + })(InferencePriority = ts.InferencePriority || (ts.InferencePriority = {})); + var InferenceFlags; + (function (InferenceFlags) { + InferenceFlags[InferenceFlags["InferUnionTypes"] = 1] = "InferUnionTypes"; + InferenceFlags[InferenceFlags["NoDefault"] = 2] = "NoDefault"; + InferenceFlags[InferenceFlags["AnyDefault"] = 4] = "AnyDefault"; + })(InferenceFlags = ts.InferenceFlags || (ts.InferenceFlags = {})); + var Ternary; + (function (Ternary) { + Ternary[Ternary["False"] = 0] = "False"; + Ternary[Ternary["Maybe"] = 1] = "Maybe"; + Ternary[Ternary["True"] = -1] = "True"; + })(Ternary = ts.Ternary || (ts.Ternary = {})); + var SpecialPropertyAssignmentKind; + (function (SpecialPropertyAssignmentKind) { + SpecialPropertyAssignmentKind[SpecialPropertyAssignmentKind["None"] = 0] = "None"; + SpecialPropertyAssignmentKind[SpecialPropertyAssignmentKind["ExportsProperty"] = 1] = "ExportsProperty"; + SpecialPropertyAssignmentKind[SpecialPropertyAssignmentKind["ModuleExports"] = 2] = "ModuleExports"; + SpecialPropertyAssignmentKind[SpecialPropertyAssignmentKind["PrototypeProperty"] = 3] = "PrototypeProperty"; + SpecialPropertyAssignmentKind[SpecialPropertyAssignmentKind["ThisProperty"] = 4] = "ThisProperty"; + SpecialPropertyAssignmentKind[SpecialPropertyAssignmentKind["Property"] = 5] = "Property"; + })(SpecialPropertyAssignmentKind = ts.SpecialPropertyAssignmentKind || (ts.SpecialPropertyAssignmentKind = {})); var DiagnosticCategory; (function (DiagnosticCategory) { DiagnosticCategory[DiagnosticCategory["Warning"] = 0] = "Warning"; @@ -81,6 +785,310 @@ var ts; ModuleKind[ModuleKind["ES2015"] = 5] = "ES2015"; ModuleKind[ModuleKind["ESNext"] = 6] = "ESNext"; })(ModuleKind = ts.ModuleKind || (ts.ModuleKind = {})); + var JsxEmit; + (function (JsxEmit) { + JsxEmit[JsxEmit["None"] = 0] = "None"; + JsxEmit[JsxEmit["Preserve"] = 1] = "Preserve"; + JsxEmit[JsxEmit["React"] = 2] = "React"; + JsxEmit[JsxEmit["ReactNative"] = 3] = "ReactNative"; + })(JsxEmit = ts.JsxEmit || (ts.JsxEmit = {})); + var NewLineKind; + (function (NewLineKind) { + NewLineKind[NewLineKind["CarriageReturnLineFeed"] = 0] = "CarriageReturnLineFeed"; + NewLineKind[NewLineKind["LineFeed"] = 1] = "LineFeed"; + })(NewLineKind = ts.NewLineKind || (ts.NewLineKind = {})); + var ScriptKind; + (function (ScriptKind) { + ScriptKind[ScriptKind["Unknown"] = 0] = "Unknown"; + ScriptKind[ScriptKind["JS"] = 1] = "JS"; + ScriptKind[ScriptKind["JSX"] = 2] = "JSX"; + ScriptKind[ScriptKind["TS"] = 3] = "TS"; + ScriptKind[ScriptKind["TSX"] = 4] = "TSX"; + ScriptKind[ScriptKind["External"] = 5] = "External"; + ScriptKind[ScriptKind["JSON"] = 6] = "JSON"; + })(ScriptKind = ts.ScriptKind || (ts.ScriptKind = {})); + var ScriptTarget; + (function (ScriptTarget) { + ScriptTarget[ScriptTarget["ES3"] = 0] = "ES3"; + ScriptTarget[ScriptTarget["ES5"] = 1] = "ES5"; + ScriptTarget[ScriptTarget["ES2015"] = 2] = "ES2015"; + ScriptTarget[ScriptTarget["ES2016"] = 3] = "ES2016"; + ScriptTarget[ScriptTarget["ES2017"] = 4] = "ES2017"; + ScriptTarget[ScriptTarget["ESNext"] = 5] = "ESNext"; + ScriptTarget[ScriptTarget["Latest"] = 5] = "Latest"; + })(ScriptTarget = ts.ScriptTarget || (ts.ScriptTarget = {})); + var LanguageVariant; + (function (LanguageVariant) { + LanguageVariant[LanguageVariant["Standard"] = 0] = "Standard"; + LanguageVariant[LanguageVariant["JSX"] = 1] = "JSX"; + })(LanguageVariant = ts.LanguageVariant || (ts.LanguageVariant = {})); + var DiagnosticStyle; + (function (DiagnosticStyle) { + DiagnosticStyle[DiagnosticStyle["Simple"] = 0] = "Simple"; + DiagnosticStyle[DiagnosticStyle["Pretty"] = 1] = "Pretty"; + })(DiagnosticStyle = ts.DiagnosticStyle || (ts.DiagnosticStyle = {})); + var WatchDirectoryFlags; + (function (WatchDirectoryFlags) { + WatchDirectoryFlags[WatchDirectoryFlags["None"] = 0] = "None"; + WatchDirectoryFlags[WatchDirectoryFlags["Recursive"] = 1] = "Recursive"; + })(WatchDirectoryFlags = ts.WatchDirectoryFlags || (ts.WatchDirectoryFlags = {})); + var CharacterCodes; + (function (CharacterCodes) { + CharacterCodes[CharacterCodes["nullCharacter"] = 0] = "nullCharacter"; + CharacterCodes[CharacterCodes["maxAsciiCharacter"] = 127] = "maxAsciiCharacter"; + CharacterCodes[CharacterCodes["lineFeed"] = 10] = "lineFeed"; + CharacterCodes[CharacterCodes["carriageReturn"] = 13] = "carriageReturn"; + CharacterCodes[CharacterCodes["lineSeparator"] = 8232] = "lineSeparator"; + CharacterCodes[CharacterCodes["paragraphSeparator"] = 8233] = "paragraphSeparator"; + CharacterCodes[CharacterCodes["nextLine"] = 133] = "nextLine"; + CharacterCodes[CharacterCodes["space"] = 32] = "space"; + CharacterCodes[CharacterCodes["nonBreakingSpace"] = 160] = "nonBreakingSpace"; + CharacterCodes[CharacterCodes["enQuad"] = 8192] = "enQuad"; + CharacterCodes[CharacterCodes["emQuad"] = 8193] = "emQuad"; + CharacterCodes[CharacterCodes["enSpace"] = 8194] = "enSpace"; + CharacterCodes[CharacterCodes["emSpace"] = 8195] = "emSpace"; + CharacterCodes[CharacterCodes["threePerEmSpace"] = 8196] = "threePerEmSpace"; + CharacterCodes[CharacterCodes["fourPerEmSpace"] = 8197] = "fourPerEmSpace"; + CharacterCodes[CharacterCodes["sixPerEmSpace"] = 8198] = "sixPerEmSpace"; + CharacterCodes[CharacterCodes["figureSpace"] = 8199] = "figureSpace"; + CharacterCodes[CharacterCodes["punctuationSpace"] = 8200] = "punctuationSpace"; + CharacterCodes[CharacterCodes["thinSpace"] = 8201] = "thinSpace"; + CharacterCodes[CharacterCodes["hairSpace"] = 8202] = "hairSpace"; + CharacterCodes[CharacterCodes["zeroWidthSpace"] = 8203] = "zeroWidthSpace"; + CharacterCodes[CharacterCodes["narrowNoBreakSpace"] = 8239] = "narrowNoBreakSpace"; + CharacterCodes[CharacterCodes["ideographicSpace"] = 12288] = "ideographicSpace"; + CharacterCodes[CharacterCodes["mathematicalSpace"] = 8287] = "mathematicalSpace"; + CharacterCodes[CharacterCodes["ogham"] = 5760] = "ogham"; + CharacterCodes[CharacterCodes["_"] = 95] = "_"; + CharacterCodes[CharacterCodes["$"] = 36] = "$"; + CharacterCodes[CharacterCodes["_0"] = 48] = "_0"; + CharacterCodes[CharacterCodes["_1"] = 49] = "_1"; + CharacterCodes[CharacterCodes["_2"] = 50] = "_2"; + CharacterCodes[CharacterCodes["_3"] = 51] = "_3"; + CharacterCodes[CharacterCodes["_4"] = 52] = "_4"; + CharacterCodes[CharacterCodes["_5"] = 53] = "_5"; + CharacterCodes[CharacterCodes["_6"] = 54] = "_6"; + CharacterCodes[CharacterCodes["_7"] = 55] = "_7"; + CharacterCodes[CharacterCodes["_8"] = 56] = "_8"; + CharacterCodes[CharacterCodes["_9"] = 57] = "_9"; + CharacterCodes[CharacterCodes["a"] = 97] = "a"; + CharacterCodes[CharacterCodes["b"] = 98] = "b"; + CharacterCodes[CharacterCodes["c"] = 99] = "c"; + CharacterCodes[CharacterCodes["d"] = 100] = "d"; + CharacterCodes[CharacterCodes["e"] = 101] = "e"; + CharacterCodes[CharacterCodes["f"] = 102] = "f"; + CharacterCodes[CharacterCodes["g"] = 103] = "g"; + CharacterCodes[CharacterCodes["h"] = 104] = "h"; + CharacterCodes[CharacterCodes["i"] = 105] = "i"; + CharacterCodes[CharacterCodes["j"] = 106] = "j"; + CharacterCodes[CharacterCodes["k"] = 107] = "k"; + CharacterCodes[CharacterCodes["l"] = 108] = "l"; + CharacterCodes[CharacterCodes["m"] = 109] = "m"; + CharacterCodes[CharacterCodes["n"] = 110] = "n"; + CharacterCodes[CharacterCodes["o"] = 111] = "o"; + CharacterCodes[CharacterCodes["p"] = 112] = "p"; + CharacterCodes[CharacterCodes["q"] = 113] = "q"; + CharacterCodes[CharacterCodes["r"] = 114] = "r"; + CharacterCodes[CharacterCodes["s"] = 115] = "s"; + CharacterCodes[CharacterCodes["t"] = 116] = "t"; + CharacterCodes[CharacterCodes["u"] = 117] = "u"; + CharacterCodes[CharacterCodes["v"] = 118] = "v"; + CharacterCodes[CharacterCodes["w"] = 119] = "w"; + CharacterCodes[CharacterCodes["x"] = 120] = "x"; + CharacterCodes[CharacterCodes["y"] = 121] = "y"; + CharacterCodes[CharacterCodes["z"] = 122] = "z"; + CharacterCodes[CharacterCodes["A"] = 65] = "A"; + CharacterCodes[CharacterCodes["B"] = 66] = "B"; + CharacterCodes[CharacterCodes["C"] = 67] = "C"; + CharacterCodes[CharacterCodes["D"] = 68] = "D"; + CharacterCodes[CharacterCodes["E"] = 69] = "E"; + CharacterCodes[CharacterCodes["F"] = 70] = "F"; + CharacterCodes[CharacterCodes["G"] = 71] = "G"; + CharacterCodes[CharacterCodes["H"] = 72] = "H"; + CharacterCodes[CharacterCodes["I"] = 73] = "I"; + CharacterCodes[CharacterCodes["J"] = 74] = "J"; + CharacterCodes[CharacterCodes["K"] = 75] = "K"; + CharacterCodes[CharacterCodes["L"] = 76] = "L"; + CharacterCodes[CharacterCodes["M"] = 77] = "M"; + CharacterCodes[CharacterCodes["N"] = 78] = "N"; + CharacterCodes[CharacterCodes["O"] = 79] = "O"; + CharacterCodes[CharacterCodes["P"] = 80] = "P"; + CharacterCodes[CharacterCodes["Q"] = 81] = "Q"; + CharacterCodes[CharacterCodes["R"] = 82] = "R"; + CharacterCodes[CharacterCodes["S"] = 83] = "S"; + CharacterCodes[CharacterCodes["T"] = 84] = "T"; + CharacterCodes[CharacterCodes["U"] = 85] = "U"; + CharacterCodes[CharacterCodes["V"] = 86] = "V"; + CharacterCodes[CharacterCodes["W"] = 87] = "W"; + CharacterCodes[CharacterCodes["X"] = 88] = "X"; + CharacterCodes[CharacterCodes["Y"] = 89] = "Y"; + CharacterCodes[CharacterCodes["Z"] = 90] = "Z"; + CharacterCodes[CharacterCodes["ampersand"] = 38] = "ampersand"; + CharacterCodes[CharacterCodes["asterisk"] = 42] = "asterisk"; + CharacterCodes[CharacterCodes["at"] = 64] = "at"; + CharacterCodes[CharacterCodes["backslash"] = 92] = "backslash"; + CharacterCodes[CharacterCodes["backtick"] = 96] = "backtick"; + CharacterCodes[CharacterCodes["bar"] = 124] = "bar"; + CharacterCodes[CharacterCodes["caret"] = 94] = "caret"; + CharacterCodes[CharacterCodes["closeBrace"] = 125] = "closeBrace"; + CharacterCodes[CharacterCodes["closeBracket"] = 93] = "closeBracket"; + CharacterCodes[CharacterCodes["closeParen"] = 41] = "closeParen"; + CharacterCodes[CharacterCodes["colon"] = 58] = "colon"; + CharacterCodes[CharacterCodes["comma"] = 44] = "comma"; + CharacterCodes[CharacterCodes["dot"] = 46] = "dot"; + CharacterCodes[CharacterCodes["doubleQuote"] = 34] = "doubleQuote"; + CharacterCodes[CharacterCodes["equals"] = 61] = "equals"; + CharacterCodes[CharacterCodes["exclamation"] = 33] = "exclamation"; + CharacterCodes[CharacterCodes["greaterThan"] = 62] = "greaterThan"; + CharacterCodes[CharacterCodes["hash"] = 35] = "hash"; + CharacterCodes[CharacterCodes["lessThan"] = 60] = "lessThan"; + CharacterCodes[CharacterCodes["minus"] = 45] = "minus"; + CharacterCodes[CharacterCodes["openBrace"] = 123] = "openBrace"; + CharacterCodes[CharacterCodes["openBracket"] = 91] = "openBracket"; + CharacterCodes[CharacterCodes["openParen"] = 40] = "openParen"; + CharacterCodes[CharacterCodes["percent"] = 37] = "percent"; + CharacterCodes[CharacterCodes["plus"] = 43] = "plus"; + CharacterCodes[CharacterCodes["question"] = 63] = "question"; + CharacterCodes[CharacterCodes["semicolon"] = 59] = "semicolon"; + CharacterCodes[CharacterCodes["singleQuote"] = 39] = "singleQuote"; + CharacterCodes[CharacterCodes["slash"] = 47] = "slash"; + CharacterCodes[CharacterCodes["tilde"] = 126] = "tilde"; + CharacterCodes[CharacterCodes["backspace"] = 8] = "backspace"; + CharacterCodes[CharacterCodes["formFeed"] = 12] = "formFeed"; + CharacterCodes[CharacterCodes["byteOrderMark"] = 65279] = "byteOrderMark"; + CharacterCodes[CharacterCodes["tab"] = 9] = "tab"; + CharacterCodes[CharacterCodes["verticalTab"] = 11] = "verticalTab"; + })(CharacterCodes = ts.CharacterCodes || (ts.CharacterCodes = {})); + var Extension; + (function (Extension) { + Extension["Ts"] = ".ts"; + Extension["Tsx"] = ".tsx"; + Extension["Dts"] = ".d.ts"; + Extension["Js"] = ".js"; + Extension["Jsx"] = ".jsx"; + })(Extension = ts.Extension || (ts.Extension = {})); + var TransformFlags; + (function (TransformFlags) { + TransformFlags[TransformFlags["None"] = 0] = "None"; + TransformFlags[TransformFlags["TypeScript"] = 1] = "TypeScript"; + TransformFlags[TransformFlags["ContainsTypeScript"] = 2] = "ContainsTypeScript"; + TransformFlags[TransformFlags["ContainsJsx"] = 4] = "ContainsJsx"; + TransformFlags[TransformFlags["ContainsESNext"] = 8] = "ContainsESNext"; + TransformFlags[TransformFlags["ContainsES2017"] = 16] = "ContainsES2017"; + TransformFlags[TransformFlags["ContainsES2016"] = 32] = "ContainsES2016"; + TransformFlags[TransformFlags["ES2015"] = 64] = "ES2015"; + TransformFlags[TransformFlags["ContainsES2015"] = 128] = "ContainsES2015"; + TransformFlags[TransformFlags["Generator"] = 256] = "Generator"; + TransformFlags[TransformFlags["ContainsGenerator"] = 512] = "ContainsGenerator"; + TransformFlags[TransformFlags["DestructuringAssignment"] = 1024] = "DestructuringAssignment"; + TransformFlags[TransformFlags["ContainsDestructuringAssignment"] = 2048] = "ContainsDestructuringAssignment"; + TransformFlags[TransformFlags["ContainsDecorators"] = 4096] = "ContainsDecorators"; + TransformFlags[TransformFlags["ContainsPropertyInitializer"] = 8192] = "ContainsPropertyInitializer"; + TransformFlags[TransformFlags["ContainsLexicalThis"] = 16384] = "ContainsLexicalThis"; + TransformFlags[TransformFlags["ContainsCapturedLexicalThis"] = 32768] = "ContainsCapturedLexicalThis"; + TransformFlags[TransformFlags["ContainsLexicalThisInComputedPropertyName"] = 65536] = "ContainsLexicalThisInComputedPropertyName"; + TransformFlags[TransformFlags["ContainsDefaultValueAssignments"] = 131072] = "ContainsDefaultValueAssignments"; + TransformFlags[TransformFlags["ContainsParameterPropertyAssignments"] = 262144] = "ContainsParameterPropertyAssignments"; + TransformFlags[TransformFlags["ContainsSpread"] = 524288] = "ContainsSpread"; + TransformFlags[TransformFlags["ContainsObjectSpread"] = 1048576] = "ContainsObjectSpread"; + TransformFlags[TransformFlags["ContainsRest"] = 524288] = "ContainsRest"; + TransformFlags[TransformFlags["ContainsObjectRest"] = 1048576] = "ContainsObjectRest"; + TransformFlags[TransformFlags["ContainsComputedPropertyName"] = 2097152] = "ContainsComputedPropertyName"; + TransformFlags[TransformFlags["ContainsBlockScopedBinding"] = 4194304] = "ContainsBlockScopedBinding"; + TransformFlags[TransformFlags["ContainsBindingPattern"] = 8388608] = "ContainsBindingPattern"; + TransformFlags[TransformFlags["ContainsYield"] = 16777216] = "ContainsYield"; + TransformFlags[TransformFlags["ContainsHoistedDeclarationOrCompletion"] = 33554432] = "ContainsHoistedDeclarationOrCompletion"; + TransformFlags[TransformFlags["ContainsDynamicImport"] = 67108864] = "ContainsDynamicImport"; + TransformFlags[TransformFlags["HasComputedFlags"] = 536870912] = "HasComputedFlags"; + TransformFlags[TransformFlags["AssertTypeScript"] = 3] = "AssertTypeScript"; + TransformFlags[TransformFlags["AssertJsx"] = 4] = "AssertJsx"; + TransformFlags[TransformFlags["AssertESNext"] = 8] = "AssertESNext"; + TransformFlags[TransformFlags["AssertES2017"] = 16] = "AssertES2017"; + TransformFlags[TransformFlags["AssertES2016"] = 32] = "AssertES2016"; + TransformFlags[TransformFlags["AssertES2015"] = 192] = "AssertES2015"; + TransformFlags[TransformFlags["AssertGenerator"] = 768] = "AssertGenerator"; + TransformFlags[TransformFlags["AssertDestructuringAssignment"] = 3072] = "AssertDestructuringAssignment"; + TransformFlags[TransformFlags["NodeExcludes"] = 536872257] = "NodeExcludes"; + TransformFlags[TransformFlags["ArrowFunctionExcludes"] = 601249089] = "ArrowFunctionExcludes"; + TransformFlags[TransformFlags["FunctionExcludes"] = 601281857] = "FunctionExcludes"; + TransformFlags[TransformFlags["ConstructorExcludes"] = 601015617] = "ConstructorExcludes"; + TransformFlags[TransformFlags["MethodOrAccessorExcludes"] = 601015617] = "MethodOrAccessorExcludes"; + TransformFlags[TransformFlags["ClassExcludes"] = 539358529] = "ClassExcludes"; + TransformFlags[TransformFlags["ModuleExcludes"] = 574674241] = "ModuleExcludes"; + TransformFlags[TransformFlags["TypeExcludes"] = -3] = "TypeExcludes"; + TransformFlags[TransformFlags["ObjectLiteralExcludes"] = 540087617] = "ObjectLiteralExcludes"; + TransformFlags[TransformFlags["ArrayLiteralOrCallOrNewExcludes"] = 537396545] = "ArrayLiteralOrCallOrNewExcludes"; + TransformFlags[TransformFlags["VariableDeclarationListExcludes"] = 546309441] = "VariableDeclarationListExcludes"; + TransformFlags[TransformFlags["ParameterExcludes"] = 536872257] = "ParameterExcludes"; + TransformFlags[TransformFlags["CatchClauseExcludes"] = 537920833] = "CatchClauseExcludes"; + TransformFlags[TransformFlags["BindingPatternExcludes"] = 537396545] = "BindingPatternExcludes"; + TransformFlags[TransformFlags["TypeScriptClassSyntaxMask"] = 274432] = "TypeScriptClassSyntaxMask"; + TransformFlags[TransformFlags["ES2015FunctionSyntaxMask"] = 163840] = "ES2015FunctionSyntaxMask"; + })(TransformFlags = ts.TransformFlags || (ts.TransformFlags = {})); + var EmitFlags; + (function (EmitFlags) { + EmitFlags[EmitFlags["SingleLine"] = 1] = "SingleLine"; + EmitFlags[EmitFlags["AdviseOnEmitNode"] = 2] = "AdviseOnEmitNode"; + EmitFlags[EmitFlags["NoSubstitution"] = 4] = "NoSubstitution"; + EmitFlags[EmitFlags["CapturesThis"] = 8] = "CapturesThis"; + EmitFlags[EmitFlags["NoLeadingSourceMap"] = 16] = "NoLeadingSourceMap"; + EmitFlags[EmitFlags["NoTrailingSourceMap"] = 32] = "NoTrailingSourceMap"; + EmitFlags[EmitFlags["NoSourceMap"] = 48] = "NoSourceMap"; + EmitFlags[EmitFlags["NoNestedSourceMaps"] = 64] = "NoNestedSourceMaps"; + EmitFlags[EmitFlags["NoTokenLeadingSourceMaps"] = 128] = "NoTokenLeadingSourceMaps"; + EmitFlags[EmitFlags["NoTokenTrailingSourceMaps"] = 256] = "NoTokenTrailingSourceMaps"; + EmitFlags[EmitFlags["NoTokenSourceMaps"] = 384] = "NoTokenSourceMaps"; + EmitFlags[EmitFlags["NoLeadingComments"] = 512] = "NoLeadingComments"; + EmitFlags[EmitFlags["NoTrailingComments"] = 1024] = "NoTrailingComments"; + EmitFlags[EmitFlags["NoComments"] = 1536] = "NoComments"; + EmitFlags[EmitFlags["NoNestedComments"] = 2048] = "NoNestedComments"; + EmitFlags[EmitFlags["HelperName"] = 4096] = "HelperName"; + EmitFlags[EmitFlags["ExportName"] = 8192] = "ExportName"; + EmitFlags[EmitFlags["LocalName"] = 16384] = "LocalName"; + EmitFlags[EmitFlags["InternalName"] = 32768] = "InternalName"; + EmitFlags[EmitFlags["Indented"] = 65536] = "Indented"; + EmitFlags[EmitFlags["NoIndentation"] = 131072] = "NoIndentation"; + EmitFlags[EmitFlags["AsyncFunctionBody"] = 262144] = "AsyncFunctionBody"; + EmitFlags[EmitFlags["ReuseTempVariableScope"] = 524288] = "ReuseTempVariableScope"; + EmitFlags[EmitFlags["CustomPrologue"] = 1048576] = "CustomPrologue"; + EmitFlags[EmitFlags["NoHoisting"] = 2097152] = "NoHoisting"; + EmitFlags[EmitFlags["HasEndOfDeclarationMarker"] = 4194304] = "HasEndOfDeclarationMarker"; + EmitFlags[EmitFlags["Iterator"] = 8388608] = "Iterator"; + EmitFlags[EmitFlags["NoAsciiEscaping"] = 16777216] = "NoAsciiEscaping"; + })(EmitFlags = ts.EmitFlags || (ts.EmitFlags = {})); + var ExternalEmitHelpers; + (function (ExternalEmitHelpers) { + ExternalEmitHelpers[ExternalEmitHelpers["Extends"] = 1] = "Extends"; + ExternalEmitHelpers[ExternalEmitHelpers["Assign"] = 2] = "Assign"; + ExternalEmitHelpers[ExternalEmitHelpers["Rest"] = 4] = "Rest"; + ExternalEmitHelpers[ExternalEmitHelpers["Decorate"] = 8] = "Decorate"; + ExternalEmitHelpers[ExternalEmitHelpers["Metadata"] = 16] = "Metadata"; + ExternalEmitHelpers[ExternalEmitHelpers["Param"] = 32] = "Param"; + ExternalEmitHelpers[ExternalEmitHelpers["Awaiter"] = 64] = "Awaiter"; + ExternalEmitHelpers[ExternalEmitHelpers["Generator"] = 128] = "Generator"; + ExternalEmitHelpers[ExternalEmitHelpers["Values"] = 256] = "Values"; + ExternalEmitHelpers[ExternalEmitHelpers["Read"] = 512] = "Read"; + ExternalEmitHelpers[ExternalEmitHelpers["Spread"] = 1024] = "Spread"; + ExternalEmitHelpers[ExternalEmitHelpers["Await"] = 2048] = "Await"; + ExternalEmitHelpers[ExternalEmitHelpers["AsyncGenerator"] = 4096] = "AsyncGenerator"; + ExternalEmitHelpers[ExternalEmitHelpers["AsyncDelegator"] = 8192] = "AsyncDelegator"; + ExternalEmitHelpers[ExternalEmitHelpers["AsyncValues"] = 16384] = "AsyncValues"; + ExternalEmitHelpers[ExternalEmitHelpers["ExportStar"] = 32768] = "ExportStar"; + ExternalEmitHelpers[ExternalEmitHelpers["ForOfIncludes"] = 256] = "ForOfIncludes"; + ExternalEmitHelpers[ExternalEmitHelpers["ForAwaitOfIncludes"] = 16384] = "ForAwaitOfIncludes"; + ExternalEmitHelpers[ExternalEmitHelpers["AsyncGeneratorIncludes"] = 6144] = "AsyncGeneratorIncludes"; + ExternalEmitHelpers[ExternalEmitHelpers["AsyncDelegatorIncludes"] = 26624] = "AsyncDelegatorIncludes"; + ExternalEmitHelpers[ExternalEmitHelpers["SpreadIncludes"] = 1536] = "SpreadIncludes"; + ExternalEmitHelpers[ExternalEmitHelpers["FirstEmitHelper"] = 1] = "FirstEmitHelper"; + ExternalEmitHelpers[ExternalEmitHelpers["LastEmitHelper"] = 32768] = "LastEmitHelper"; + })(ExternalEmitHelpers = ts.ExternalEmitHelpers || (ts.ExternalEmitHelpers = {})); + var EmitHint; + (function (EmitHint) { + EmitHint[EmitHint["SourceFile"] = 0] = "SourceFile"; + EmitHint[EmitHint["Expression"] = 1] = "Expression"; + EmitHint[EmitHint["IdentifierName"] = 2] = "IdentifierName"; + EmitHint[EmitHint["Unspecified"] = 3] = "Unspecified"; + })(EmitHint = ts.EmitHint || (ts.EmitHint = {})); })(ts || (ts = {})); var ts; (function (ts) { @@ -143,7 +1151,7 @@ var ts; })(ts || (ts = {})); var ts; (function (ts) { - ts.versionMajorMinor = "2.5"; + ts.versionMajorMinor = "2.6"; ts.version = ts.versionMajorMinor + ".0"; })(ts || (ts = {})); (function (ts) { @@ -257,6 +1265,12 @@ var ts; return getCanonicalFileName(nonCanonicalizedPath); } ts.toPath = toPath; + var Comparison; + (function (Comparison) { + Comparison[Comparison["LessThan"] = -1] = "LessThan"; + Comparison[Comparison["EqualTo"] = 0] = "EqualTo"; + Comparison[Comparison["GreaterThan"] = 1] = "GreaterThan"; + })(Comparison = ts.Comparison || (ts.Comparison = {})); function length(array) { return array ? array.length : 0; } @@ -428,10 +1442,9 @@ var ts; ts.removeWhere = removeWhere; function filterMutate(array, f) { var outIndex = 0; - for (var _i = 0, array_3 = array; _i < array_3.length; _i++) { - var item = array_3[_i]; - if (f(item)) { - array[outIndex] = item; + for (var i = 0; i < array.length; i++) { + if (f(array[i], i, array)) { + array[outIndex] = array[i]; outIndex++; } } @@ -477,8 +1490,8 @@ var ts; var result; if (array) { result = []; - for (var _i = 0, array_4 = array; _i < array_4.length; _i++) { - var v = array_4[_i]; + for (var _i = 0, array_3 = array; _i < array_3.length; _i++) { + var v = array_3[_i]; if (v) { if (isArray(v)) { addRange(result, v); @@ -548,11 +1561,13 @@ var ts; ts.sameFlatMap = sameFlatMap; function mapDefined(array, mapFn) { var result = []; - for (var i = 0; i < array.length; i++) { - var item = array[i]; - var mapped = mapFn(item, i); - if (mapped !== undefined) { - result.push(mapped); + if (array) { + for (var i = 0; i < array.length; i++) { + var item = array[i]; + var mapped = mapFn(item, i); + if (mapped !== undefined) { + result.push(mapped); + } } } return result; @@ -620,8 +1635,8 @@ var ts; function some(array, predicate) { if (array) { if (predicate) { - for (var _i = 0, array_5 = array; _i < array_5.length; _i++) { - var v = array_5[_i]; + for (var _i = 0, array_4 = array; _i < array_4.length; _i++) { + var v = array_4[_i]; if (predicate(v)) { return true; } @@ -646,8 +1661,8 @@ var ts; var result; if (array) { result = []; - loop: for (var _i = 0, array_6 = array; _i < array_6.length; _i++) { - var item = array_6[_i]; + loop: for (var _i = 0, array_5 = array; _i < array_5.length; _i++) { + var item = array_5[_i]; for (var _a = 0, result_1 = result; _a < result_1.length; _a++) { var res = result_1[_a]; if (areEqual ? areEqual(res, item) : res === item) { @@ -735,8 +1750,8 @@ var ts; ts.relativeComplement = relativeComplement; function sum(array, prop) { var result = 0; - for (var _i = 0, array_7 = array; _i < array_7.length; _i++) { - var v = array_7[_i]; + for (var _i = 0, array_6 = array; _i < array_6.length; _i++) { + var v = array_6[_i]; result += v[prop]; } return result; @@ -996,8 +2011,8 @@ var ts; ts.equalOwnProperties = equalOwnProperties; function arrayToMap(array, makeKey, makeValue) { var result = createMap(); - for (var _i = 0, array_8 = array; _i < array_8.length; _i++) { - var value = array_8[_i]; + for (var _i = 0, array_7 = array; _i < array_7.length; _i++) { + var value = array_7[_i]; result.set(makeKey(value), makeValue ? makeValue(value) : value); } return result; @@ -1157,11 +2172,11 @@ var ts; ts.getLocaleSpecificMessage = getLocaleSpecificMessage; function createFileDiagnostic(file, start, length, message) { var end = start + length; - Debug.assert(start >= 0, "start must be non-negative, is " + start); - Debug.assert(length >= 0, "length must be non-negative, is " + length); + Debug.assertGreaterThanOrEqual(start, 0); + Debug.assertGreaterThanOrEqual(length, 0); if (file) { - Debug.assert(start <= file.text.length, "start must be within the bounds of the file. " + start + " > " + file.text.length); - Debug.assert(end <= file.text.length, "end must be the bounds of the file. " + end + " > " + file.text.length); + Debug.assertLessThanOrEqual(start, file.text.length); + Debug.assertLessThanOrEqual(end, file.text.length); } var text = getLocaleSpecificMessage(message); if (arguments.length > 4) { @@ -1370,19 +2385,23 @@ var ts; return normalized; } function normalizePath(path) { + return normalizePathAndParts(path).path; + } + ts.normalizePath = normalizePath; + function normalizePathAndParts(path) { path = normalizeSlashes(path); var rootLength = getRootLength(path); var root = path.substr(0, rootLength); - var normalized = getNormalizedParts(path, rootLength); - if (normalized.length) { - var joinedParts = root + normalized.join(ts.directorySeparator); - return pathEndsWithDirectorySeparator(path) ? joinedParts + ts.directorySeparator : joinedParts; + var parts = getNormalizedParts(path, rootLength); + if (parts.length) { + var joinedParts = root + parts.join(ts.directorySeparator); + return { path: pathEndsWithDirectorySeparator(path) ? joinedParts + ts.directorySeparator : joinedParts, parts: parts }; } else { - return root; + return { path: root, parts: parts }; } } - ts.normalizePath = normalizePath; + ts.normalizePathAndParts = normalizePathAndParts; function pathEndsWithDirectorySeparator(path) { return path.charCodeAt(path.length - 1) === directorySeparatorCharCode; } @@ -1645,8 +2664,28 @@ var ts; ts.fileExtensionIsOneOf = fileExtensionIsOneOf; var reservedCharacterPattern = /[^\w\s\/]/g; var wildcardCharCodes = [42, 63]; - var singleAsteriskRegexFragmentFiles = "([^./]|(\\.(?!min\\.js$))?)*"; - var singleAsteriskRegexFragmentOther = "[^/]*"; + ts.commonPackageFolders = ["node_modules", "bower_components", "jspm_packages"]; + var implicitExcludePathRegexPattern = "(?!(" + ts.commonPackageFolders.join("|") + ")(/|$))"; + var filesMatcher = { + singleAsteriskRegexFragment: "([^./]|(\\.(?!min\\.js$))?)*", + doubleAsteriskRegexFragment: "(/" + implicitExcludePathRegexPattern + "[^/.][^/]*)*?", + replaceWildcardCharacter: function (match) { return replaceWildcardCharacter(match, filesMatcher.singleAsteriskRegexFragment); } + }; + var directoriesMatcher = { + singleAsteriskRegexFragment: "[^/]*", + doubleAsteriskRegexFragment: "(/" + implicitExcludePathRegexPattern + "[^/.][^/]*)*?", + replaceWildcardCharacter: function (match) { return replaceWildcardCharacter(match, directoriesMatcher.singleAsteriskRegexFragment); } + }; + var excludeMatcher = { + singleAsteriskRegexFragment: "[^/]*", + doubleAsteriskRegexFragment: "(/.+?)?", + replaceWildcardCharacter: function (match) { return replaceWildcardCharacter(match, excludeMatcher.singleAsteriskRegexFragment); } + }; + var wildcardMatchers = { + files: filesMatcher, + directories: directoriesMatcher, + exclude: excludeMatcher + }; function getRegularExpressionForWildcard(specs, basePath, usage) { var patterns = getRegularExpressionsForWildcards(specs, basePath, usage); if (!patterns || !patterns.length) { @@ -1661,18 +2700,16 @@ var ts; if (specs === undefined || specs.length === 0) { return undefined; } - var replaceWildcardCharacter = usage === "files" ? replaceWildCardCharacterFiles : replaceWildCardCharacterOther; - var singleAsteriskRegexFragment = usage === "files" ? singleAsteriskRegexFragmentFiles : singleAsteriskRegexFragmentOther; - var doubleAsteriskRegexFragment = usage === "exclude" ? "(/.+?)?" : "(/[^/.][^/]*)*?"; return flatMap(specs, function (spec) { - return spec && getSubPatternFromSpec(spec, basePath, usage, singleAsteriskRegexFragment, doubleAsteriskRegexFragment, replaceWildcardCharacter); + return spec && getSubPatternFromSpec(spec, basePath, usage, wildcardMatchers[usage]); }); } function isImplicitGlob(lastPathComponent) { return !/[.*?]/.test(lastPathComponent); } ts.isImplicitGlob = isImplicitGlob; - function getSubPatternFromSpec(spec, basePath, usage, singleAsteriskRegexFragment, doubleAsteriskRegexFragment, replaceWildcardCharacter) { + function getSubPatternFromSpec(spec, basePath, usage, _a) { + var singleAsteriskRegexFragment = _a.singleAsteriskRegexFragment, doubleAsteriskRegexFragment = _a.doubleAsteriskRegexFragment, replaceWildcardCharacter = _a.replaceWildcardCharacter; var subpattern = ""; var hasRecursiveDirectoryWildcard = false; var hasWrittenComponent = false; @@ -1704,16 +2741,24 @@ var ts; subpattern += ts.directorySeparator; } if (usage !== "exclude") { + var componentPattern = ""; if (component.charCodeAt(0) === 42) { - subpattern += "([^./]" + singleAsteriskRegexFragment + ")?"; + componentPattern += "([^./]" + singleAsteriskRegexFragment + ")?"; component = component.substr(1); } else if (component.charCodeAt(0) === 63) { - subpattern += "[^./]"; + componentPattern += "[^./]"; component = component.substr(1); } + componentPattern += component.replace(reservedCharacterPattern, replaceWildcardCharacter); + if (componentPattern !== component) { + subpattern += implicitExcludePathRegexPattern; + } + subpattern += componentPattern; + } + else { + subpattern += component.replace(reservedCharacterPattern, replaceWildcardCharacter); } - subpattern += component.replace(reservedCharacterPattern, replaceWildcardCharacter); } hasWrittenComponent = true; } @@ -1723,12 +2768,6 @@ var ts; } return subpattern; } - function replaceWildCardCharacterFiles(match) { - return replaceWildcardCharacter(match, singleAsteriskRegexFragmentFiles); - } - function replaceWildCardCharacterOther(match) { - return replaceWildcardCharacter(match, singleAsteriskRegexFragmentOther); - } function replaceWildcardCharacter(match, singleAsteriskRegexFragment) { return match === "*" ? singleAsteriskRegexFragment : match === "?" ? "[^/]" : "\\" + match; } @@ -1865,14 +2904,7 @@ var ts; if (!extraFileExtensions || extraFileExtensions.length === 0 || !needAllExtensions) { return needAllExtensions ? allSupportedExtensions : ts.supportedTypeScriptExtensions; } - var extensions = allSupportedExtensions.slice(0); - for (var _i = 0, extraFileExtensions_1 = extraFileExtensions; _i < extraFileExtensions_1.length; _i++) { - var extInfo = extraFileExtensions_1[_i]; - if (extensions.indexOf(extInfo.extension) === -1) { - extensions.push(extInfo.extension); - } - } - return extensions; + return deduplicate(allSupportedExtensions.concat(extraFileExtensions.map(function (e) { return e.extension; }))); } ts.getSupportedExtensions = getSupportedExtensions; function hasJavaScriptFileExtension(fileName) { @@ -1896,6 +2928,13 @@ var ts; return false; } ts.isSupportedSourceFileName = isSupportedSourceFileName; + var ExtensionPriority; + (function (ExtensionPriority) { + ExtensionPriority[ExtensionPriority["TypeScriptFiles"] = 0] = "TypeScriptFiles"; + ExtensionPriority[ExtensionPriority["DeclarationAndJavaScriptFiles"] = 2] = "DeclarationAndJavaScriptFiles"; + ExtensionPriority[ExtensionPriority["Highest"] = 0] = "Highest"; + ExtensionPriority[ExtensionPriority["Lowest"] = 2] = "Lowest"; + })(ExtensionPriority = ts.ExtensionPriority || (ts.ExtensionPriority = {})); function getExtensionPriority(path, supportedExtensions) { for (var i = supportedExtensions.length - 1; i >= 0; i--) { if (fileExtensionIs(path, supportedExtensions[i])) { @@ -1989,6 +3028,13 @@ var ts; getSignatureConstructor: function () { return Signature; }, getSourceMapSourceConstructor: function () { return SourceMapSource; }, }; + var AssertionLevel; + (function (AssertionLevel) { + AssertionLevel[AssertionLevel["None"] = 0] = "None"; + AssertionLevel[AssertionLevel["Normal"] = 1] = "Normal"; + AssertionLevel[AssertionLevel["Aggressive"] = 2] = "Aggressive"; + AssertionLevel[AssertionLevel["VeryAggressive"] = 3] = "VeryAggressive"; + })(AssertionLevel = ts.AssertionLevel || (ts.AssertionLevel = {})); var Debug; (function (Debug) { Debug.currentAssertionLevel = 0; @@ -2000,12 +3046,37 @@ var ts; function assert(expression, message, verboseDebugInfo, stackCrawlMark) { if (!expression) { if (verboseDebugInfo) { - message += "\r\nVerbose Debug Information: " + verboseDebugInfo(); + message += "\r\nVerbose Debug Information: " + (typeof verboseDebugInfo === "string" ? verboseDebugInfo : verboseDebugInfo()); } fail(message ? "False expression: " + message : "False expression.", stackCrawlMark || assert); } } Debug.assert = assert; + function assertEqual(a, b, msg, msg2) { + if (a !== b) { + var message = msg ? msg2 ? msg + " " + msg2 : msg : ""; + fail("Expected " + a + " === " + b + ". " + message); + } + } + Debug.assertEqual = assertEqual; + function assertLessThan(a, b, msg) { + if (a >= b) { + fail("Expected " + a + " < " + b + ". " + (msg || "")); + } + } + Debug.assertLessThan = assertLessThan; + function assertLessThanOrEqual(a, b) { + if (a > b) { + fail("Expected " + a + " <= " + b); + } + } + Debug.assertLessThanOrEqual = assertLessThanOrEqual; + function assertGreaterThanOrEqual(a, b) { + if (a < b) { + fail("Expected " + a + " >= " + b); + } + } + Debug.assertGreaterThanOrEqual = assertGreaterThanOrEqual; function fail(message, stackCrawlMark) { debugger; var e = new Error(message ? "Debug Failure. " + message : "Debug Failure."); @@ -2140,6 +3211,10 @@ var ts; Debug.fail("File " + path + " has unknown extension."); } ts.extensionFromPath = extensionFromPath; + function isAnySupportedFileExtension(path) { + return tryGetExtensionFromPath(path) !== undefined; + } + ts.isAnySupportedFileExtension = isAnySupportedFileExtension; function tryGetExtensionFromPath(path) { return find(ts.supportedTypescriptExtensionsForExtractExtension, function (e) { return fileExtensionIs(path, e); }) || find(ts.supportedJavascriptExtensions, function (e) { return fileExtensionIs(path, e); }); } @@ -2151,6 +3226,12 @@ var ts; })(ts || (ts = {})); var ts; (function (ts) { + function setStackTraceLimit() { + if (Error.stackTraceLimit < 100) { + Error.stackTraceLimit = 100; + } + } + ts.setStackTraceLimit = setStackTraceLimit; var FileWatcherEventKind; (function (FileWatcherEventKind) { FileWatcherEventKind[FileWatcherEventKind["Created"] = 0] = "Created"; @@ -2200,7 +3281,7 @@ var ts; watcher.referenceCount += 1; return; } - watcher = _fs.watch(dirPath, { persistent: true }, function (eventName, relativeFileName) { return fileEventHandler(eventName, relativeFileName, dirPath); }); + watcher = _fs.watch(dirPath || ".", { persistent: true }, function (eventName, relativeFileName) { return fileEventHandler(eventName, relativeFileName, dirPath); }); watcher.referenceCount = 1; dirWatchers.set(dirPath, watcher); return; @@ -2324,6 +3405,11 @@ var ts; function readDirectory(path, extensions, excludes, includes, depth) { return ts.matchFiles(path, extensions, excludes, includes, useCaseSensitiveFileNames, process.cwd(), depth, getAccessibleFileSystemEntries); } + var FileSystemEntryKind; + (function (FileSystemEntryKind) { + FileSystemEntryKind[FileSystemEntryKind["File"] = 0] = "File"; + FileSystemEntryKind[FileSystemEntryKind["Directory"] = 1] = "Directory"; + })(FileSystemEntryKind || (FileSystemEntryKind = {})); function fileSystemEntryExists(path, entryKind) { try { var stat = _fs.statSync(path); @@ -3021,6 +4107,8 @@ var ts; Expected_at_least_0_arguments_but_got_a_minimum_of_1: diag(2557, ts.DiagnosticCategory.Error, "Expected_at_least_0_arguments_but_got_a_minimum_of_1_2557", "Expected at least {0} arguments, but got a minimum of {1}."), Expected_0_type_arguments_but_got_1: diag(2558, ts.DiagnosticCategory.Error, "Expected_0_type_arguments_but_got_1_2558", "Expected {0} type arguments, but got {1}."), Type_0_has_no_properties_in_common_with_type_1: diag(2559, ts.DiagnosticCategory.Error, "Type_0_has_no_properties_in_common_with_type_1_2559", "Type '{0}' has no properties in common with type '{1}'."), + Value_of_type_0_has_no_properties_in_common_with_type_1_Did_you_mean_to_call_it: diag(2560, ts.DiagnosticCategory.Error, "Value_of_type_0_has_no_properties_in_common_with_type_1_Did_you_mean_to_call_it_2560", "Value of type '{0}' has no properties in common with type '{1}'. Did you mean to call it?"), + Base_class_expressions_cannot_reference_class_type_parameters: diag(2561, ts.DiagnosticCategory.Error, "Base_class_expressions_cannot_reference_class_type_parameters_2561", "Base class expressions cannot reference class type parameters."), JSX_element_attributes_type_0_may_not_be_a_union_type: diag(2600, ts.DiagnosticCategory.Error, "JSX_element_attributes_type_0_may_not_be_a_union_type_2600", "JSX element attributes type '{0}' may not be a union type."), The_return_type_of_a_JSX_element_constructor_must_return_an_object_type: diag(2601, ts.DiagnosticCategory.Error, "The_return_type_of_a_JSX_element_constructor_must_return_an_object_type_2601", "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: diag(2602, ts.DiagnosticCategory.Error, "JSX_element_implicitly_has_type_any_because_the_global_type_JSX_Element_does_not_exist_2602", "JSX element implicitly has type 'any' because the global type 'JSX.Element' does not exist."), @@ -3208,6 +4296,7 @@ var ts; Do_not_emit_outputs: diag(6010, ts.DiagnosticCategory.Message, "Do_not_emit_outputs_6010", "Do not emit outputs."), Allow_default_imports_from_modules_with_no_default_export_This_does_not_affect_code_emit_just_typechecking: diag(6011, ts.DiagnosticCategory.Message, "Allow_default_imports_from_modules_with_no_default_export_This_does_not_affect_code_emit_just_typech_6011", "Allow default imports from modules with no default export. This does not affect code emit, just typechecking."), Skip_type_checking_of_declaration_files: diag(6012, ts.DiagnosticCategory.Message, "Skip_type_checking_of_declaration_files_6012", "Skip type checking of declaration files."), + Do_not_resolve_the_real_path_of_symlinks: diag(6013, ts.DiagnosticCategory.Message, "Do_not_resolve_the_real_path_of_symlinks_6013", "Do not resolve the real path of symlinks."), Specify_ECMAScript_target_version_Colon_ES3_default_ES5_ES2015_ES2016_ES2017_or_ESNEXT: diag(6015, ts.DiagnosticCategory.Message, "Specify_ECMAScript_target_version_Colon_ES3_default_ES5_ES2015_ES2016_ES2017_or_ESNEXT_6015", "Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', or 'ESNEXT'."), Specify_module_code_generation_Colon_none_commonjs_amd_system_umd_es2015_or_ESNext: diag(6016, ts.DiagnosticCategory.Message, "Specify_module_code_generation_Colon_none_commonjs_amd_system_umd_es2015_or_ESNext_6016", "Specify module code generation: 'none', commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'."), Print_this_message: diag(6017, ts.DiagnosticCategory.Message, "Print_this_message_6017", "Print this message."), @@ -3461,6 +4550,8 @@ var ts; Rewrite_as_the_indexed_access_type_0: diag(90026, ts.DiagnosticCategory.Message, "Rewrite_as_the_indexed_access_type_0_90026", "Rewrite as the indexed access type '{0}'."), Convert_function_to_an_ES2015_class: diag(95001, ts.DiagnosticCategory.Message, "Convert_function_to_an_ES2015_class_95001", "Convert function to an ES2015 class"), Convert_function_0_to_class: diag(95002, ts.DiagnosticCategory.Message, "Convert_function_0_to_class_95002", "Convert function '{0}' to class"), + Extract_function: diag(95003, ts.DiagnosticCategory.Message, "Extract_function_95003", "Extract function"), + Extract_function_into_0: diag(95004, ts.DiagnosticCategory.Message, "Extract_function_into_0_95004", "Extract function into '{0}'"), }; })(ts || (ts = {})); var ts; @@ -5077,19 +6168,6 @@ var ts; return undefined; } ts.getDeclarationOfKind = getDeclarationOfKind; - function findDeclaration(symbol, predicate) { - var declarations = symbol.declarations; - if (declarations) { - for (var _i = 0, declarations_2 = declarations; _i < declarations_2.length; _i++) { - var declaration = declarations_2[_i]; - if (predicate(declaration)) { - return declaration; - } - } - } - return undefined; - } - ts.findDeclaration = findDeclaration; var stringWriter = createSingleLineStringWriter(); var stringWriterAcquired = false; function createSingleLineStringWriter() { @@ -5152,9 +6230,13 @@ var ts; function moduleResolutionIsEqualTo(oldResolution, newResolution) { return oldResolution.isExternalLibraryImport === newResolution.isExternalLibraryImport && oldResolution.extension === newResolution.extension && - oldResolution.resolvedFileName === newResolution.resolvedFileName; + oldResolution.resolvedFileName === newResolution.resolvedFileName && + packageIdIsEqual(oldResolution.packageId, newResolution.packageId); } ts.moduleResolutionIsEqualTo = moduleResolutionIsEqualTo; + function packageIdIsEqual(a, b) { + return a === b || a && b && a.name === b.name && a.version === b.version; + } function typeDirectiveIsEqualTo(oldResolution, newResolution) { return oldResolution.resolvedFileName === newResolution.resolvedFileName && oldResolution.primary === newResolution.primary; } @@ -5219,14 +6301,6 @@ var ts; return file.fileName + "(" + (loc.line + 1) + "," + (loc.character + 1) + ")"; } ts.nodePosToString = nodePosToString; - function getStartPosOfNode(node) { - return node.pos; - } - ts.getStartPosOfNode = getStartPosOfNode; - function isDefined(value) { - return value !== undefined; - } - ts.isDefined = isDefined; function getEndLinePosition(line, sourceFile) { ts.Debug.assert(line >= 0); var lineStarts = ts.getLineStarts(sourceFile); @@ -5257,6 +6331,25 @@ var ts; return !nodeIsMissing(node); } ts.nodeIsPresent = nodeIsPresent; + function isRecognizedTripleSlashComment(text, commentPos, commentEnd) { + if (text.charCodeAt(commentPos + 1) === 47 && + commentPos + 2 < commentEnd && + text.charCodeAt(commentPos + 2) === 47) { + var textSubStr = text.substring(commentPos, commentEnd); + return textSubStr.match(ts.fullTripleSlashReferencePathRegEx) || + textSubStr.match(ts.fullTripleSlashAMDReferencePathRegEx) || + textSubStr.match(fullTripleSlashReferenceTypeReferenceDirectiveRegEx) || + textSubStr.match(defaultLibReferenceRegEx) ? + true : false; + } + return false; + } + ts.isRecognizedTripleSlashComment = isRecognizedTripleSlashComment; + function isPinnedComment(text, comment) { + return text.charCodeAt(comment.pos + 1) === 42 && + text.charCodeAt(comment.pos + 2) === 33; + } + ts.isPinnedComment = isPinnedComment; function getTokenPosOfNode(node, sourceFile, includeJsDoc) { if (nodeIsMissing(node)) { return node.pos; @@ -5313,15 +6406,20 @@ var ts; var escapeText = getEmitFlags(node) & 16777216 ? escapeString : escapeNonAsciiString; switch (node.kind) { case 9: - return '"' + escapeText(node.text) + '"'; + if (node.singleQuote) { + return "'" + escapeText(node.text, 39) + "'"; + } + else { + return '"' + escapeText(node.text, 34) + '"'; + } case 13: - return "`" + escapeText(node.text) + "`"; + return "`" + escapeText(node.text, 96) + "`"; case 14: - return "`" + escapeText(node.text) + "${"; + return "`" + escapeText(node.text, 96) + "${"; case 15: - return "}" + escapeText(node.text) + "${"; + return "}" + escapeText(node.text, 96) + "${"; case 16: - return "}" + escapeText(node.text) + "`"; + return "}" + escapeText(node.text, 96) + "`"; case 8: return node.text; } @@ -5573,13 +6671,9 @@ var ts; } ts.isPrologueDirective = isPrologueDirective; function getLeadingCommentRangesOfNode(node, sourceFileOfNode) { - return ts.getLeadingCommentRanges(sourceFileOfNode.text, node.pos); + return node.kind !== 10 ? ts.getLeadingCommentRanges(sourceFileOfNode.text, node.pos) : undefined; } ts.getLeadingCommentRangesOfNode = getLeadingCommentRangesOfNode; - function getLeadingCommentRangesOfNodeFromText(node, text) { - return ts.getLeadingCommentRanges(text, node.pos); - } - ts.getLeadingCommentRangesOfNodeFromText = getLeadingCommentRangesOfNodeFromText; function getJSDocCommentRanges(node, text) { var commentRanges = (node.kind === 146 || node.kind === 145 || @@ -5587,7 +6681,7 @@ var ts; node.kind === 187 || node.kind === 185) ? ts.concatenate(ts.getTrailingCommentRanges(text, node.pos), ts.getLeadingCommentRanges(text, node.pos)) : - getLeadingCommentRangesOfNodeFromText(node, text); + ts.getLeadingCommentRanges(text, node.pos); return ts.filter(commentRanges, function (comment) { return text.charCodeAt(comment.pos + 1) === 42 && text.charCodeAt(comment.pos + 2) === 42 && @@ -5596,8 +6690,9 @@ var ts; } ts.getJSDocCommentRanges = getJSDocCommentRanges; ts.fullTripleSlashReferencePathRegEx = /^(\/\/\/\s*/; - ts.fullTripleSlashReferenceTypeReferenceDirectiveRegEx = /^(\/\/\/\s*/; + var fullTripleSlashReferenceTypeReferenceDirectiveRegEx = /^(\/\/\/\s*/; ts.fullTripleSlashAMDReferencePathRegEx = /^(\/\/\/\s*/; + var defaultLibReferenceRegEx = /^(\/\/\/\s*/; function isPartOfTypeNode(node) { if (158 <= node.kind && node.kind <= 173) { return true; @@ -5824,21 +6919,11 @@ var ts; } ts.getPropertyAssignment = getPropertyAssignment; function getContainingFunction(node) { - while (true) { - node = node.parent; - if (!node || ts.isFunctionLike(node)) { - return node; - } - } + return ts.findAncestor(node.parent, ts.isFunctionLike); } ts.getContainingFunction = getContainingFunction; function getContainingClass(node) { - while (true) { - node = node.parent; - if (!node || ts.isClassLike(node)) { - return node; - } - } + return ts.findAncestor(node.parent, ts.isClassLike); } ts.getContainingClass = getContainingClass; function getThisContainer(node, includeArrowFunctions) { @@ -6445,6 +7530,12 @@ var ts; return node && node.dotDotDotToken !== undefined; } ts.isDeclaredRestParam = isDeclaredRestParam; + var AssignmentKind; + (function (AssignmentKind) { + AssignmentKind[AssignmentKind["None"] = 0] = "None"; + AssignmentKind[AssignmentKind["Definite"] = 1] = "Definite"; + AssignmentKind[AssignmentKind["Compound"] = 2] = "Compound"; + })(AssignmentKind = ts.AssignmentKind || (ts.AssignmentKind = {})); function getAssignmentTargetKind(node) { var parent = node.parent; while (true) { @@ -6642,14 +7733,14 @@ var ts; ts.getAncestor = getAncestor; function getFileReferenceFromReferencePath(comment, commentRange) { var simpleReferenceRegEx = /^\/\/\/\s*/gim; + var isNoDefaultLibRegEx = new RegExp(defaultLibReferenceRegEx.source, "gim"); if (simpleReferenceRegEx.test(comment)) { if (isNoDefaultLibRegEx.test(comment)) { return { isNoDefaultLib: true }; } else { var refMatchResult = ts.fullTripleSlashReferencePathRegEx.exec(comment); - var refLibResult = !refMatchResult && ts.fullTripleSlashReferenceTypeReferenceDirectiveRegEx.exec(comment); + var refLibResult = !refMatchResult && fullTripleSlashReferenceTypeReferenceDirectiveRegEx.exec(comment); var match = refMatchResult || refLibResult; if (match) { var pos = commentRange.pos + match[1].length + match[2].length; @@ -6680,6 +7771,14 @@ var ts; return 2 <= token && token <= 7; } ts.isTrivia = isTrivia; + var FunctionFlags; + (function (FunctionFlags) { + FunctionFlags[FunctionFlags["Normal"] = 0] = "Normal"; + FunctionFlags[FunctionFlags["Generator"] = 1] = "Generator"; + FunctionFlags[FunctionFlags["Async"] = 2] = "Async"; + FunctionFlags[FunctionFlags["Invalid"] = 4] = "Invalid"; + FunctionFlags[FunctionFlags["AsyncGenerator"] = 3] = "AsyncGenerator"; + })(FunctionFlags = ts.FunctionFlags || (ts.FunctionFlags = {})); function getFunctionFlags(node) { if (!node) { return 4; @@ -6830,10 +7929,11 @@ var ts; return ts.getParseTreeNode(sourceFile, ts.isSourceFile) || sourceFile; } ts.getOriginalSourceFile = getOriginalSourceFile; - function getOriginalSourceFiles(sourceFiles) { - return ts.sameMap(sourceFiles, getOriginalSourceFile); - } - ts.getOriginalSourceFiles = getOriginalSourceFiles; + var Associativity; + (function (Associativity) { + Associativity[Associativity["Left"] = 0] = "Left"; + Associativity[Associativity["Right"] = 1] = "Right"; + })(Associativity = ts.Associativity || (ts.Associativity = {})); function getExpressionAssociativity(expression) { var operator = getOperator(expression); var hasArguments = expression.kind === 182 && expression.arguments !== undefined; @@ -7067,7 +8167,9 @@ var ts; } } ts.createDiagnosticCollection = createDiagnosticCollection; - var escapedCharsRegExp = /[\\\"\u0000-\u001f\t\v\f\b\r\n\u2028\u2029\u0085]/g; + var doubleQuoteEscapedCharsRegExp = /[\\\"\u0000-\u001f\t\v\f\b\r\n\u2028\u2029\u0085]/g; + var singleQuoteEscapedCharsRegExp = /[\\\'\u0000-\u001f\t\v\f\b\r\n\u2028\u2029\u0085]/g; + var backtickQuoteEscapedCharsRegExp = /[\\\`\u0000-\u001f\t\v\f\b\r\n\u2028\u2029\u0085]/g; var escapedCharsMap = ts.createMapFromTemplate({ "\0": "\\0", "\t": "\\t", @@ -7078,11 +8180,16 @@ var ts; "\n": "\\n", "\\": "\\\\", "\"": "\\\"", + "\'": "\\\'", + "\`": "\\\`", "\u2028": "\\u2028", "\u2029": "\\u2029", "\u0085": "\\u0085" }); - function escapeString(s) { + function escapeString(s, quoteChar) { + var escapedCharsRegExp = quoteChar === 96 ? backtickQuoteEscapedCharsRegExp : + quoteChar === 39 ? singleQuoteEscapedCharsRegExp : + doubleQuoteEscapedCharsRegExp; return s.replace(escapedCharsRegExp, getReplacement); } ts.escapeString = escapeString; @@ -7100,8 +8207,8 @@ var ts; return "\\u" + paddedHexCode; } var nonAsciiCharacters = /[^\u0000-\u007F]/g; - function escapeNonAsciiString(s) { - s = escapeString(s); + function escapeNonAsciiString(s, quoteChar) { + s = escapeString(s, quoteChar); return nonAsciiCharacters.test(s) ? s.replace(nonAsciiCharacters, function (c) { return get16BitUnicodeEscapeSequence(c.charCodeAt(0)); }) : s; @@ -7442,7 +8549,7 @@ var ts; var currentDetachedCommentInfo; if (removeComments) { if (node.pos === 0) { - leadingComments = ts.filter(ts.getLeadingCommentRanges(text, node.pos), isPinnedComment); + leadingComments = ts.filter(ts.getLeadingCommentRanges(text, node.pos), isPinnedCommentLocal); } } else { @@ -7474,9 +8581,8 @@ var ts; } } return currentDetachedCommentInfo; - function isPinnedComment(comment) { - return text.charCodeAt(comment.pos + 1) === 42 && - text.charCodeAt(comment.pos + 2) === 33; + function isPinnedCommentLocal(comment) { + return isPinnedComment(text, comment); } } ts.emitDetachedComments = emitDetachedComments; @@ -7547,9 +8653,13 @@ var ts; } ts.hasModifiers = hasModifiers; function hasModifier(node, flags) { - return (getModifierFlags(node) & flags) !== 0; + return !!getSelectedModifierFlags(node, flags); } ts.hasModifier = hasModifier; + function getSelectedModifierFlags(node, flags) { + return getModifierFlags(node) & flags; + } + ts.getSelectedModifierFlags = getSelectedModifierFlags; function getModifierFlags(node) { if (node.modifierFlagsCache & 536870912) { return node.modifierFlagsCache & ~536870912; @@ -7625,21 +8735,6 @@ var ts; return false; } ts.isDestructuringAssignment = isDestructuringAssignment; - function isSupportedExpressionWithTypeArguments(node) { - return isSupportedExpressionWithTypeArgumentsRest(node.expression); - } - ts.isSupportedExpressionWithTypeArguments = isSupportedExpressionWithTypeArguments; - function isSupportedExpressionWithTypeArgumentsRest(node) { - if (node.kind === 71) { - return true; - } - else if (ts.isPropertyAccessExpression(node)) { - return isSupportedExpressionWithTypeArgumentsRest(node.expression); - } - else { - return false; - } - } function isExpressionWithTypeArgumentsInClassExtendsClause(node) { return tryGetClassExtendingExpressionWithTypeArguments(node) !== undefined; } @@ -7752,72 +8847,6 @@ var ts; return carriageReturnLineFeed; } ts.getNewLineCharacter = getNewLineCharacter; - function isSimpleExpression(node) { - return isSimpleExpressionWorker(node, 0); - } - ts.isSimpleExpression = isSimpleExpression; - function isSimpleExpressionWorker(node, depth) { - if (depth <= 5) { - var kind = node.kind; - if (kind === 9 - || kind === 8 - || kind === 12 - || kind === 13 - || kind === 71 - || kind === 99 - || kind === 97 - || kind === 101 - || kind === 86 - || kind === 95) { - return true; - } - else if (kind === 179) { - return isSimpleExpressionWorker(node.expression, depth + 1); - } - else if (kind === 180) { - return isSimpleExpressionWorker(node.expression, depth + 1) - && isSimpleExpressionWorker(node.argumentExpression, depth + 1); - } - else if (kind === 192 - || kind === 193) { - return isSimpleExpressionWorker(node.operand, depth + 1); - } - else if (kind === 194) { - return node.operatorToken.kind !== 40 - && isSimpleExpressionWorker(node.left, depth + 1) - && isSimpleExpressionWorker(node.right, depth + 1); - } - else if (kind === 195) { - return isSimpleExpressionWorker(node.condition, depth + 1) - && isSimpleExpressionWorker(node.whenTrue, depth + 1) - && isSimpleExpressionWorker(node.whenFalse, depth + 1); - } - else if (kind === 190 - || kind === 189 - || kind === 188) { - return isSimpleExpressionWorker(node.expression, depth + 1); - } - else if (kind === 177) { - return node.elements.length === 0; - } - else if (kind === 178) { - return node.properties.length === 0; - } - else if (kind === 181) { - if (!isSimpleExpressionWorker(node.expression, depth + 1)) { - return false; - } - for (var _i = 0, _a = node.arguments; _i < _a.length; _i++) { - var argument = _a[_i]; - if (!isSimpleExpressionWorker(argument, depth + 1)) { - return false; - } - } - return true; - } - } - return false; - } function formatEnum(value, enumObject, isFlags) { if (value === void 0) { value = 0; } var members = getEnumMembers(enumObject); @@ -7886,18 +8915,6 @@ var ts; return formatEnum(flags, ts.ObjectFlags, true); } ts.formatObjectFlags = formatObjectFlags; - function getRangePos(range) { - return range ? range.pos : -1; - } - ts.getRangePos = getRangePos; - function getRangeEnd(range) { - return range ? range.end : -1; - } - ts.getRangeEnd = getRangeEnd; - function movePos(pos, value) { - return ts.positionIsSynthesized(pos) ? -1 : pos + value; - } - ts.movePos = movePos; function createRange(pos, end) { return { pos: pos, end: end }; } @@ -7926,14 +8943,6 @@ var ts; return range.pos === range.end; } ts.isCollapsedRange = isCollapsedRange; - function collapseRangeToStart(range) { - return isCollapsedRange(range) ? range : moveRangeEnd(range, range.pos); - } - ts.collapseRangeToStart = collapseRangeToStart; - function collapseRangeToEnd(range) { - return isCollapsedRange(range) ? range : moveRangePos(range, range.end); - } - ts.collapseRangeToEnd = collapseRangeToEnd; function createTokenRange(pos, token) { return createRange(pos, pos + ts.tokenToString(token).length); } @@ -7986,22 +8995,6 @@ var ts; function isInitializedVariable(node) { return node.initializer !== undefined; } - function isMergedWithClass(node) { - if (node.symbol) { - for (var _i = 0, _a = node.symbol.declarations; _i < _a.length; _i++) { - var declaration = _a[_i]; - if (declaration.kind === 229 && declaration !== node) { - return true; - } - } - } - return false; - } - ts.isMergedWithClass = isMergedWithClass; - function isFirstDeclarationOfKind(node, kind) { - return node.symbol && getDeclarationOfKind(node.symbol, kind) === node; - } - ts.isFirstDeclarationOfKind = isFirstDeclarationOfKind; function isWatchSet(options) { return options.watch && options.hasOwnProperty("watch"); } @@ -8202,6 +9195,20 @@ var ts; return ts.hasModifier(node, 92) && node.parent.kind === 152 && ts.isClassLike(node.parent.parent); } ts.isParameterPropertyDeclaration = isParameterPropertyDeclaration; + function isEmptyBindingPattern(node) { + if (ts.isBindingPattern(node)) { + return ts.every(node.elements, isEmptyBindingElement); + } + return false; + } + ts.isEmptyBindingPattern = isEmptyBindingPattern; + function isEmptyBindingElement(node) { + if (ts.isOmittedExpression(node)) { + return true; + } + return isEmptyBindingPattern(node.name); + } + ts.isEmptyBindingElement = isEmptyBindingElement; function walkUpBindingElementsAndPatterns(node) { while (node && (node.kind === 176 || ts.isBindingPattern(node))) { node = node.parent; @@ -9282,6 +10289,18 @@ var ts; return isUnaryExpressionKind(ts.skipPartiallyEmittedExpressions(node).kind); } ts.isUnaryExpression = isUnaryExpression; + function isUnaryExpressionWithWrite(expr) { + switch (expr.kind) { + case 193: + return true; + case 192: + return expr.operator === 43 || + expr.operator === 44; + default: + return false; + } + } + ts.isUnaryExpressionWithWrite = isUnaryExpressionWithWrite; function isExpressionKind(kind) { return kind === 195 || kind === 197 @@ -9466,9 +10485,19 @@ var ts; var kind = node.kind; return isStatementKindButNotDeclarationKind(kind) || isDeclarationStatementKind(kind) - || kind === 207; + || isBlockStatement(node); } ts.isStatement = isStatement; + function isBlockStatement(node) { + if (node.kind !== 207) + return false; + if (node.parent !== undefined) { + if (node.parent.kind === 224 || node.parent.kind === 260) { + return false; + } + } + return !ts.isFunctionBlock(node); + } function isModuleReference(node) { var kind = node.kind; return kind === 248 @@ -9530,6 +10559,16 @@ var ts; })(ts || (ts = {})); var ts; (function (ts) { + var SignatureFlags; + (function (SignatureFlags) { + SignatureFlags[SignatureFlags["None"] = 0] = "None"; + SignatureFlags[SignatureFlags["Yield"] = 1] = "Yield"; + SignatureFlags[SignatureFlags["Await"] = 2] = "Await"; + SignatureFlags[SignatureFlags["Type"] = 4] = "Type"; + SignatureFlags[SignatureFlags["RequireCompleteParameterList"] = 8] = "RequireCompleteParameterList"; + SignatureFlags[SignatureFlags["IgnoreMissingOpenBrace"] = 16] = "IgnoreMissingOpenBrace"; + SignatureFlags[SignatureFlags["JSDoc"] = 32] = "JSDoc"; + })(SignatureFlags || (SignatureFlags = {})); var NodeConstructor; var TokenConstructor; var IdentifierConstructor; @@ -11367,11 +12406,31 @@ var ts; var node = parseTokenNode(); return token() === 23 ? undefined : node; } - function parseLiteralTypeNode() { + function parseLiteralTypeNode(negative) { var node = createNode(173); - node.literal = parseSimpleUnaryExpression(); - finishNode(node); - return node; + var unaryMinusExpression; + if (negative) { + unaryMinusExpression = createNode(192); + unaryMinusExpression.operator = 38; + nextToken(); + } + var expression; + switch (token()) { + case 9: + case 8: + expression = parseLiteralLikeNode(token()); + break; + case 101: + case 86: + expression = parseTokenNode(); + } + if (negative) { + unaryMinusExpression.operand = expression; + finishNode(unaryMinusExpression); + expression = unaryMinusExpression; + } + node.literal = expression; + return finishNode(node); } function nextTokenIsNumericLiteral() { return nextToken() === 8; @@ -11403,7 +12462,7 @@ var ts; case 86: return parseLiteralTypeNode(); case 38: - return lookAhead(nextTokenIsNumericLiteral) ? parseLiteralTypeNode() : parseTypeReference(); + return lookAhead(nextTokenIsNumericLiteral) ? parseLiteralTypeNode(true) : parseTypeReference(); case 105: case 95: return parseTokenNode(); @@ -11452,6 +12511,7 @@ var ts; case 101: case 86: case 134: + case 39: return true; case 38: return lookAhead(nextTokenIsNumericLiteral); @@ -11770,7 +12830,7 @@ var ts; if (!arrowFunction) { return undefined; } - var isAsync = !!(ts.getModifierFlags(arrowFunction) & 256); + var isAsync = ts.hasModifier(arrowFunction, 256); var lastToken = token(); arrowFunction.equalsGreaterThanToken = parseExpectedToken(36, false, ts.Diagnostics._0_expected, "=>"); arrowFunction.body = (lastToken === 36 || lastToken === 17) @@ -11886,7 +12946,7 @@ var ts; function parseParenthesizedArrowFunctionExpressionHead(allowAmbiguity) { var node = createNode(187); node.modifiers = parseModifiersForArrowFunction(); - var isAsync = (ts.getModifierFlags(node) & 256) ? 2 : 0; + var isAsync = ts.hasModifier(node, 256) ? 2 : 0; fillSignature(56, isAsync | (allowAmbiguity ? 0 : 8), node); if (!node.parameters) { return undefined; @@ -12619,7 +13679,7 @@ var ts; parseExpected(89); node.asteriskToken = parseOptionalToken(39); var isGenerator = node.asteriskToken ? 1 : 0; - var isAsync = (ts.getModifierFlags(node) & 256) ? 2 : 0; + var isAsync = ts.hasModifier(node, 256) ? 2 : 0; node.name = isGenerator && isAsync ? doInYieldAndAwaitContext(parseOptionalIdentifier) : isGenerator ? doInYieldContext(parseOptionalIdentifier) : @@ -12844,10 +13904,13 @@ var ts; function parseCatchClause() { var result = createNode(260); parseExpected(74); - if (parseExpected(19)) { + if (parseOptional(19)) { result.variableDeclaration = parseVariableDeclaration(); + parseExpected(20); + } + else { + result.variableDeclaration = undefined; } - parseExpected(20); result.block = parseBlock(false); return finishNode(result); } @@ -13851,6 +14914,39 @@ var ts; : undefined; }); } + var ParsingContext; + (function (ParsingContext) { + ParsingContext[ParsingContext["SourceElements"] = 0] = "SourceElements"; + ParsingContext[ParsingContext["BlockStatements"] = 1] = "BlockStatements"; + ParsingContext[ParsingContext["SwitchClauses"] = 2] = "SwitchClauses"; + ParsingContext[ParsingContext["SwitchClauseStatements"] = 3] = "SwitchClauseStatements"; + ParsingContext[ParsingContext["TypeMembers"] = 4] = "TypeMembers"; + ParsingContext[ParsingContext["ClassMembers"] = 5] = "ClassMembers"; + ParsingContext[ParsingContext["EnumMembers"] = 6] = "EnumMembers"; + ParsingContext[ParsingContext["HeritageClauseElement"] = 7] = "HeritageClauseElement"; + ParsingContext[ParsingContext["VariableDeclarations"] = 8] = "VariableDeclarations"; + ParsingContext[ParsingContext["ObjectBindingElements"] = 9] = "ObjectBindingElements"; + ParsingContext[ParsingContext["ArrayBindingElements"] = 10] = "ArrayBindingElements"; + ParsingContext[ParsingContext["ArgumentExpressions"] = 11] = "ArgumentExpressions"; + ParsingContext[ParsingContext["ObjectLiteralMembers"] = 12] = "ObjectLiteralMembers"; + ParsingContext[ParsingContext["JsxAttributes"] = 13] = "JsxAttributes"; + ParsingContext[ParsingContext["JsxChildren"] = 14] = "JsxChildren"; + ParsingContext[ParsingContext["ArrayLiteralMembers"] = 15] = "ArrayLiteralMembers"; + ParsingContext[ParsingContext["Parameters"] = 16] = "Parameters"; + ParsingContext[ParsingContext["RestProperties"] = 17] = "RestProperties"; + ParsingContext[ParsingContext["TypeParameters"] = 18] = "TypeParameters"; + ParsingContext[ParsingContext["TypeArguments"] = 19] = "TypeArguments"; + ParsingContext[ParsingContext["TupleElementTypes"] = 20] = "TupleElementTypes"; + ParsingContext[ParsingContext["HeritageClauses"] = 21] = "HeritageClauses"; + ParsingContext[ParsingContext["ImportOrExportSpecifiers"] = 22] = "ImportOrExportSpecifiers"; + ParsingContext[ParsingContext["Count"] = 23] = "Count"; + })(ParsingContext || (ParsingContext = {})); + var Tristate; + (function (Tristate) { + Tristate[Tristate["False"] = 0] = "False"; + Tristate[Tristate["True"] = 1] = "True"; + Tristate[Tristate["Unknown"] = 2] = "Unknown"; + })(Tristate || (Tristate = {})); var JSDocParser; (function (JSDocParser) { function parseJSDocTypeExpressionForTests(content, start, length) { @@ -13903,6 +14999,17 @@ var ts; var _a; } JSDocParser.parseJSDocComment = parseJSDocComment; + var JSDocState; + (function (JSDocState) { + JSDocState[JSDocState["BeginningOfLine"] = 0] = "BeginningOfLine"; + JSDocState[JSDocState["SawAsterisk"] = 1] = "SawAsterisk"; + JSDocState[JSDocState["SavingComments"] = 2] = "SavingComments"; + })(JSDocState || (JSDocState = {})); + var PropertyLikeParse; + (function (PropertyLikeParse) { + PropertyLikeParse[PropertyLikeParse["Property"] = 0] = "Property"; + PropertyLikeParse[PropertyLikeParse["Parameter"] = 1] = "Parameter"; + })(PropertyLikeParse || (PropertyLikeParse = {})); function parseJSDocCommentWorker(start, length) { var content = sourceText; start = start || 0; @@ -14535,8 +15642,8 @@ var ts; array._children = undefined; array.pos += delta; array.end += delta; - for (var _i = 0, array_9 = array; _i < array_9.length; _i++) { - var node = array_9[_i]; + for (var _i = 0, array_8 = array; _i < array_8.length; _i++) { + var node = array_8[_i]; visitNode(node); } } @@ -14608,8 +15715,8 @@ var ts; array.intersectsChange = true; array._children = undefined; adjustIntersectingElement(array, changeStart, changeRangeOldEnd, changeRangeNewEnd, delta); - for (var _i = 0, array_10 = array; _i < array_10.length; _i++) { - var node = array_10[_i]; + for (var _i = 0, array_9 = array; _i < array_9.length; _i++) { + var node = array_9[_i]; visitNode(node); } return; @@ -14757,10 +15864,20 @@ var ts; } } } + var InvalidPosition; + (function (InvalidPosition) { + InvalidPosition[InvalidPosition["Value"] = -1] = "Value"; + })(InvalidPosition || (InvalidPosition = {})); })(IncrementalParser || (IncrementalParser = {})); })(ts || (ts = {})); var ts; (function (ts) { + var ModuleInstanceState; + (function (ModuleInstanceState) { + ModuleInstanceState[ModuleInstanceState["NonInstantiated"] = 0] = "NonInstantiated"; + ModuleInstanceState[ModuleInstanceState["Instantiated"] = 1] = "Instantiated"; + ModuleInstanceState[ModuleInstanceState["ConstEnumOnly"] = 2] = "ConstEnumOnly"; + })(ModuleInstanceState = ts.ModuleInstanceState || (ts.ModuleInstanceState = {})); function getModuleInstanceState(node) { if (node.kind === 230 || node.kind === 231) { return 0; @@ -14799,6 +15916,18 @@ var ts; } } ts.getModuleInstanceState = getModuleInstanceState; + var ContainerFlags; + (function (ContainerFlags) { + ContainerFlags[ContainerFlags["None"] = 0] = "None"; + ContainerFlags[ContainerFlags["IsContainer"] = 1] = "IsContainer"; + ContainerFlags[ContainerFlags["IsBlockScopedContainer"] = 2] = "IsBlockScopedContainer"; + ContainerFlags[ContainerFlags["IsControlFlowContainer"] = 4] = "IsControlFlowContainer"; + ContainerFlags[ContainerFlags["IsFunctionLike"] = 8] = "IsFunctionLike"; + ContainerFlags[ContainerFlags["IsFunctionExpression"] = 16] = "IsFunctionExpression"; + ContainerFlags[ContainerFlags["HasLocals"] = 32] = "HasLocals"; + ContainerFlags[ContainerFlags["IsInterface"] = 64] = "IsInterface"; + ContainerFlags[ContainerFlags["IsObjectLiteralOrClassExpressionMethod"] = 128] = "IsObjectLiteralOrClassExpressionMethod"; + })(ContainerFlags || (ContainerFlags = {})); var binder = createBinder(); function bindSourceFile(file, options) { ts.performance.mark("beforeBind"); @@ -15359,40 +16488,23 @@ var ts; return antecedent; } setFlowNodeReferenced(antecedent); - return { - flags: flags, - expression: expression, - antecedent: antecedent - }; + return { flags: flags, expression: expression, antecedent: antecedent }; } function createFlowSwitchClause(antecedent, switchStatement, clauseStart, clauseEnd) { if (!isNarrowingExpression(switchStatement.expression)) { return antecedent; } setFlowNodeReferenced(antecedent); - return { - flags: 128, - switchStatement: switchStatement, - clauseStart: clauseStart, - clauseEnd: clauseEnd, - antecedent: antecedent - }; + return { flags: 128, switchStatement: switchStatement, clauseStart: clauseStart, clauseEnd: clauseEnd, antecedent: antecedent }; } function createFlowAssignment(antecedent, node) { setFlowNodeReferenced(antecedent); - return { - flags: 16, - antecedent: antecedent, - node: node - }; + return { flags: 16, antecedent: antecedent, node: node }; } function createFlowArrayMutation(antecedent, node) { setFlowNodeReferenced(antecedent); - return { - flags: 256, - antecedent: antecedent, - node: node - }; + var res = { flags: 256, antecedent: antecedent, node: node }; + return res; } function finishFlowLabel(flow) { var antecedents = flow.antecedents; @@ -16045,6 +17157,11 @@ var ts; typeLiteralSymbol.members.set(symbol.escapedName, symbol); } function bindObjectLiteralExpression(node) { + var ElementKind; + (function (ElementKind) { + ElementKind[ElementKind["Property"] = 1] = "Property"; + ElementKind[ElementKind["Accessor"] = 2] = "Accessor"; + })(ElementKind || (ElementKind = {})); if (inStrictMode) { var seen = ts.createUnderscoreEscapedMap(); for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { @@ -16855,7 +17972,6 @@ var ts; } function computeParameter(node, subtreeFlags) { var transformFlags = subtreeFlags; - var modifierFlags = ts.getModifierFlags(node); var name = node.name; var initializer = node.initializer; var dotDotDotToken = node.dotDotDotToken; @@ -16865,7 +17981,7 @@ var ts; || ts.isThisIdentifier(name)) { transformFlags |= 3; } - if (modifierFlags & 92) { + if (ts.hasModifier(node, 92)) { transformFlags |= 3 | 262144; } if (subtreeFlags & 1048576) { @@ -16894,8 +18010,7 @@ var ts; } function computeClassDeclaration(node, subtreeFlags) { var transformFlags; - var modifierFlags = ts.getModifierFlags(node); - if (modifierFlags & 2) { + if (ts.hasModifier(node, 2)) { transformFlags = 3; } else { @@ -16941,7 +18056,10 @@ var ts; } function computeCatchClause(node, subtreeFlags) { var transformFlags = subtreeFlags; - if (node.variableDeclaration && ts.isBindingPattern(node.variableDeclaration.name)) { + if (!node.variableDeclaration) { + transformFlags |= 8; + } + else if (ts.isBindingPattern(node.variableDeclaration.name)) { transformFlags |= 192; } node.transformFlags = transformFlags | 536870912; @@ -17105,9 +18223,8 @@ var ts; } function computeVariableStatement(node, subtreeFlags) { var transformFlags; - var modifierFlags = ts.getModifierFlags(node); var declarationListTransformFlags = node.declarationList.transformFlags; - if (modifierFlags & 2) { + if (ts.hasModifier(node, 2)) { transformFlags = 3; } else { @@ -17406,6 +18523,167 @@ var ts; } })(ts || (ts = {})); var ts; +(function (ts) { + function createGetSymbolWalker(getRestTypeOfSignature, getReturnTypeOfSignature, getBaseTypes, resolveStructuredTypeMembers, getTypeOfSymbol, getResolvedSymbol, getIndexTypeOfStructuredType, getConstraintFromTypeParameter, getFirstIdentifier) { + return getSymbolWalker; + function getSymbolWalker(accept) { + if (accept === void 0) { accept = function () { return true; }; } + var visitedTypes = ts.createMap(); + var visitedSymbols = ts.createMap(); + return { + walkType: function (type) { + visitedTypes.clear(); + visitedSymbols.clear(); + visitType(type); + return { visitedTypes: ts.arrayFrom(visitedTypes.values()), visitedSymbols: ts.arrayFrom(visitedSymbols.values()) }; + }, + walkSymbol: function (symbol) { + visitedTypes.clear(); + visitedSymbols.clear(); + visitSymbol(symbol); + return { visitedTypes: ts.arrayFrom(visitedTypes.values()), visitedSymbols: ts.arrayFrom(visitedSymbols.values()) }; + }, + }; + function visitType(type) { + if (!type) { + return; + } + var typeIdString = type.id.toString(); + if (visitedTypes.has(typeIdString)) { + return; + } + visitedTypes.set(typeIdString, type); + var shouldBail = visitSymbol(type.symbol); + if (shouldBail) + return; + if (type.flags & 32768) { + var objectType = type; + var objectFlags = objectType.objectFlags; + if (objectFlags & 4) { + visitTypeReference(type); + } + if (objectFlags & 32) { + visitMappedType(type); + } + if (objectFlags & (1 | 2)) { + visitInterfaceType(type); + } + if (objectFlags & (8 | 16)) { + visitObjectType(objectType); + } + } + if (type.flags & 16384) { + visitTypeParameter(type); + } + if (type.flags & 196608) { + visitUnionOrIntersectionType(type); + } + if (type.flags & 262144) { + visitIndexType(type); + } + if (type.flags & 524288) { + visitIndexedAccessType(type); + } + } + function visitTypeList(types) { + if (!types) { + return; + } + for (var i = 0; i < types.length; i++) { + visitType(types[i]); + } + } + function visitTypeReference(type) { + visitType(type.target); + visitTypeList(type.typeArguments); + } + function visitTypeParameter(type) { + visitType(getConstraintFromTypeParameter(type)); + } + function visitUnionOrIntersectionType(type) { + visitTypeList(type.types); + } + function visitIndexType(type) { + visitType(type.type); + } + function visitIndexedAccessType(type) { + visitType(type.objectType); + visitType(type.indexType); + visitType(type.constraint); + } + function visitMappedType(type) { + visitType(type.typeParameter); + visitType(type.constraintType); + visitType(type.templateType); + visitType(type.modifiersType); + } + function visitSignature(signature) { + if (signature.typePredicate) { + visitType(signature.typePredicate.type); + } + visitTypeList(signature.typeParameters); + for (var _i = 0, _a = signature.parameters; _i < _a.length; _i++) { + var parameter = _a[_i]; + visitSymbol(parameter); + } + visitType(getRestTypeOfSignature(signature)); + visitType(getReturnTypeOfSignature(signature)); + } + function visitInterfaceType(interfaceT) { + visitObjectType(interfaceT); + visitTypeList(interfaceT.typeParameters); + visitTypeList(getBaseTypes(interfaceT)); + visitType(interfaceT.thisType); + } + function visitObjectType(type) { + var stringIndexType = getIndexTypeOfStructuredType(type, 0); + visitType(stringIndexType); + var numberIndexType = getIndexTypeOfStructuredType(type, 1); + visitType(numberIndexType); + var resolved = resolveStructuredTypeMembers(type); + for (var _i = 0, _a = resolved.callSignatures; _i < _a.length; _i++) { + var signature = _a[_i]; + visitSignature(signature); + } + for (var _b = 0, _c = resolved.constructSignatures; _b < _c.length; _b++) { + var signature = _c[_b]; + visitSignature(signature); + } + for (var _d = 0, _e = resolved.properties; _d < _e.length; _d++) { + var p = _e[_d]; + visitSymbol(p); + } + } + function visitSymbol(symbol) { + if (!symbol) { + return; + } + var symbolIdString = ts.getSymbolId(symbol).toString(); + if (visitedSymbols.has(symbolIdString)) { + return; + } + visitedSymbols.set(symbolIdString, symbol); + if (!accept(symbol)) { + return true; + } + var t = getTypeOfSymbol(symbol); + visitType(t); + if (symbol.flags & 1952) { + symbol.exports.forEach(visitSymbol); + } + ts.forEach(symbol.declarations, function (d) { + if (d.type && d.type.kind === 162) { + var query = d.type; + var entity = getResolvedSymbol(getFirstIdentifier(query.exprName)); + visitSymbol(entity); + } + }); + } + } + } + ts.createGetSymbolWalker = createGetSymbolWalker; +})(ts || (ts = {})); +var ts; (function (ts) { function trace(host) { host.trace(ts.formatMessage.apply(undefined, arguments)); @@ -17415,6 +18693,12 @@ var ts; return compilerOptions.traceResolution && host.trace !== undefined; } ts.isTraceEnabled = isTraceEnabled; + function withPackageId(packageId, r) { + return r && { path: r.path, extension: r.ext, packageId: packageId }; + } + function noPackageId(r) { + return withPackageId(undefined, r); + } var Extensions; (function (Extensions) { Extensions[Extensions["TypeScript"] = 0] = "TypeScript"; @@ -17430,12 +18714,11 @@ var ts; } function createResolvedModuleWithFailedLookupLocations(resolved, isExternalLibraryImport, failedLookupLocations) { return { - resolvedModule: resolved && { resolvedFileName: resolved.path, extension: resolved.extension, isExternalLibraryImport: isExternalLibraryImport }, + resolvedModule: resolved && { resolvedFileName: resolved.path, extension: resolved.extension, isExternalLibraryImport: isExternalLibraryImport, packageId: resolved.packageId }, failedLookupLocations: failedLookupLocations }; } - function tryReadPackageJsonFields(readTypes, packageJsonPath, baseDirectory, state) { - var jsonContent = readJson(packageJsonPath, state.host); + function tryReadPackageJsonFields(readTypes, jsonContent, baseDirectory, state) { return readTypes ? tryReadFromField("typings") || tryReadFromField("types") : tryReadFromField("main"); function tryReadFromField(fieldName) { if (!ts.hasProperty(jsonContent, fieldName)) { @@ -17529,7 +18812,9 @@ var ts; } var resolvedTypeReferenceDirective; if (resolved) { - resolved = realpath(resolved, host, traceEnabled); + if (!options.preserveSymlinks) { + resolved = realPath(resolved, host, traceEnabled); + } if (traceEnabled) { trace(host, ts.Diagnostics.Type_reference_directive_0_was_successfully_resolved_to_1_primary_Colon_2, typeReferenceDirectiveName, resolved, primary); } @@ -17830,7 +19115,7 @@ var ts; if (extension !== undefined) { var path_1 = tryFile(candidate, failedLookupLocations, false, state); if (path_1 !== undefined) { - return { path: path_1, extension: extension }; + return { path: path_1, extension: extension, packageId: undefined }; } } return loader(extensions, candidate, failedLookupLocations, !directoryProbablyExists(ts.getDirectoryPath(candidate), state.host), state); @@ -17851,7 +19136,7 @@ var ts; function resolveJavaScriptModule(moduleName, initialDir, host) { var _a = nodeModuleNameResolverWorker(moduleName, initialDir, { moduleResolution: ts.ModuleResolutionKind.NodeJs, allowJs: true }, host, undefined, true), resolvedModule = _a.resolvedModule, failedLookupLocations = _a.failedLookupLocations; if (!resolvedModule) { - throw new Error("Could not resolve JS module " + moduleName + " starting at " + initialDir + ". Looked in: " + failedLookupLocations.join(", ")); + throw new Error("Could not resolve JS module '" + moduleName + "' starting at '" + initialDir + "'. Looked in: " + failedLookupLocations.join(", ")); } return resolvedModule.resolvedFileName; } @@ -17877,16 +19162,22 @@ var ts; trace(host, ts.Diagnostics.Loading_module_0_from_node_modules_folder_target_file_type_1, moduleName, Extensions[extensions]); } var resolved_1 = loadModuleFromNodeModules(extensions, moduleName, containingDirectory, failedLookupLocations, state, cache); - return resolved_1 && { value: resolved_1.value && { resolved: { path: realpath(resolved_1.value.path, host, traceEnabled), extension: resolved_1.value.extension }, isExternalLibraryImport: true } }; + if (!resolved_1) + return undefined; + var resolvedValue = resolved_1.value; + if (!compilerOptions.preserveSymlinks) { + resolvedValue = resolvedValue && __assign({}, resolved_1.value, { path: realPath(resolved_1.value.path, host, traceEnabled), extension: resolved_1.value.extension }); + } + return { value: resolvedValue && { resolved: resolvedValue, isExternalLibraryImport: true } }; } else { - var candidate = ts.normalizePath(ts.combinePaths(containingDirectory, moduleName)); + var _a = ts.normalizePathAndParts(ts.combinePaths(containingDirectory, moduleName)), candidate = _a.path, parts = _a.parts; var resolved_2 = nodeLoadModuleByRelativeName(extensions, candidate, failedLookupLocations, false, state, true); - return resolved_2 && toSearchResult({ resolved: resolved_2, isExternalLibraryImport: false }); + return resolved_2 && toSearchResult({ resolved: resolved_2, isExternalLibraryImport: ts.contains(parts, "node_modules") }); } } } - function realpath(path, host, traceEnabled) { + function realPath(path, host, traceEnabled) { if (!host.realpath) { return path; } @@ -17912,7 +19203,7 @@ var ts; } var resolvedFromFile = loadModuleFromFile(extensions, candidate, failedLookupLocations, onlyRecordFailures, state); if (resolvedFromFile) { - return resolvedFromFile; + return noPackageId(resolvedFromFile); } } if (!onlyRecordFailures) { @@ -17930,6 +19221,9 @@ var ts; return !host.directoryExists || host.directoryExists(directoryName); } ts.directoryProbablyExists = directoryProbablyExists; + function loadModuleFromFileNoPackageId(extensions, candidate, failedLookupLocations, onlyRecordFailures, state) { + return noPackageId(loadModuleFromFile(extensions, candidate, failedLookupLocations, onlyRecordFailures, state)); + } function loadModuleFromFile(extensions, candidate, failedLookupLocations, onlyRecordFailures, state) { var resolvedByAddingExtension = tryAddingExtensions(candidate, extensions, failedLookupLocations, onlyRecordFailures, state); if (resolvedByAddingExtension) { @@ -17959,9 +19253,9 @@ var ts; case Extensions.JavaScript: return tryExtension(".js") || tryExtension(".jsx"); } - function tryExtension(extension) { - var path = tryFile(candidate + extension, failedLookupLocations, onlyRecordFailures, state); - return path && { path: path, extension: extension }; + function tryExtension(ext) { + var path = tryFile(candidate + ext, failedLookupLocations, onlyRecordFailures, state); + return path && { path: path, ext: ext }; } } function tryFile(fileName, failedLookupLocations, onlyRecordFailures, state) { @@ -17984,12 +19278,20 @@ var ts; function loadNodeModuleFromDirectory(extensions, candidate, failedLookupLocations, onlyRecordFailures, state, considerPackageJson) { if (considerPackageJson === void 0) { considerPackageJson = true; } var directoryExists = !onlyRecordFailures && directoryProbablyExists(candidate, state.host); + var packageId; if (considerPackageJson) { var packageJsonPath = pathToPackageJson(candidate); if (directoryExists && state.host.fileExists(packageJsonPath)) { - var fromPackageJson = loadModuleFromPackageJson(packageJsonPath, extensions, candidate, failedLookupLocations, state); + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.Found_package_json_at_0, packageJsonPath); + } + var jsonContent = readJson(packageJsonPath, state.host); + if (typeof jsonContent.name === "string" && typeof jsonContent.version === "string") { + packageId = { name: jsonContent.name, version: jsonContent.version }; + } + var fromPackageJson = loadModuleFromPackageJson(jsonContent, extensions, candidate, failedLookupLocations, state); if (fromPackageJson) { - return fromPackageJson; + return withPackageId(packageId, fromPackageJson); } } else { @@ -17999,13 +19301,10 @@ var ts; failedLookupLocations.push(packageJsonPath); } } - return loadModuleFromFile(extensions, ts.combinePaths(candidate, "index"), failedLookupLocations, !directoryExists, state); + return withPackageId(packageId, loadModuleFromFile(extensions, ts.combinePaths(candidate, "index"), failedLookupLocations, !directoryExists, state)); } - function loadModuleFromPackageJson(packageJsonPath, extensions, candidate, failedLookupLocations, state) { - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.Found_package_json_at_0, packageJsonPath); - } - var file = tryReadPackageJsonFields(extensions !== Extensions.JavaScript, packageJsonPath, candidate, state); + function loadModuleFromPackageJson(jsonContent, extensions, candidate, failedLookupLocations, state) { + var file = tryReadPackageJsonFields(extensions !== Extensions.JavaScript, jsonContent, candidate, state); if (!file) { return undefined; } @@ -18021,11 +19320,15 @@ var ts; } } var nextExtensions = extensions === Extensions.DtsOnly ? Extensions.TypeScript : extensions; - return nodeLoadModuleByRelativeName(nextExtensions, file, failedLookupLocations, onlyRecordFailures, state, false); + var result = nodeLoadModuleByRelativeName(nextExtensions, file, failedLookupLocations, onlyRecordFailures, state, false); + if (result) { + ts.Debug.assert(result.packageId === undefined); + return { path: result.path, ext: result.extension }; + } } function resolvedIfExtensionMatches(extensions, path) { - var extension = ts.tryGetExtensionFromPath(path); - return extension !== undefined && extensionIsOk(extensions, extension) ? { path: path, extension: extension } : undefined; + var ext = ts.tryGetExtensionFromPath(path); + return ext !== undefined && extensionIsOk(extensions, ext) ? { path: path, ext: ext } : undefined; } function extensionIsOk(extensions, extension) { switch (extensions) { @@ -18042,7 +19345,7 @@ var ts; } function loadModuleFromNodeModulesFolder(extensions, moduleName, nodeModulesFolder, nodeModulesFolderExists, failedLookupLocations, state) { var candidate = ts.normalizePath(ts.combinePaths(nodeModulesFolder, moduleName)); - return loadModuleFromFile(extensions, candidate, failedLookupLocations, !nodeModulesFolderExists, state) || + return loadModuleFromFileNoPackageId(extensions, candidate, failedLookupLocations, !nodeModulesFolderExists, state) || loadNodeModuleFromDirectory(extensions, candidate, failedLookupLocations, !nodeModulesFolderExists, state); } function loadModuleFromNodeModules(extensions, moduleName, directory, failedLookupLocations, state, cache) { @@ -18116,7 +19419,7 @@ var ts; if (traceEnabled) { trace(host, ts.Diagnostics.Resolution_for_module_0_was_found_in_cache, moduleName); } - return { value: result.resolvedModule && { path: result.resolvedModule.resolvedFileName, extension: result.resolvedModule.extension } }; + return { value: result.resolvedModule && { path: result.resolvedModule.resolvedFileName, extension: result.resolvedModule.extension, packageId: result.resolvedModule.packageId } }; } } function classicNameResolver(moduleName, containingFile, compilerOptions, host, cache) { @@ -18127,7 +19430,7 @@ var ts; var resolved = tryResolve(Extensions.TypeScript) || tryResolve(Extensions.JavaScript); return createResolvedModuleWithFailedLookupLocations(resolved && resolved.value, false, failedLookupLocations); function tryResolve(extensions) { - var resolvedUsingSettings = tryLoadModuleUsingOptionalResolutionSettings(extensions, moduleName, containingDirectory, loadModuleFromFile, failedLookupLocations, state); + var resolvedUsingSettings = tryLoadModuleUsingOptionalResolutionSettings(extensions, moduleName, containingDirectory, loadModuleFromFileNoPackageId, failedLookupLocations, state); if (resolvedUsingSettings) { return { value: resolvedUsingSettings }; } @@ -18139,7 +19442,7 @@ var ts; return resolutionFromCache; } var searchName = ts.normalizePath(ts.combinePaths(directory, moduleName)); - return toSearchResult(loadModuleFromFile(extensions, searchName, failedLookupLocations, false, state)); + return toSearchResult(loadModuleFromFileNoPackageId(extensions, searchName, failedLookupLocations, false, state)); }); if (resolved_3) { return resolved_3; @@ -18150,7 +19453,7 @@ var ts; } else { var candidate = ts.normalizePath(ts.combinePaths(containingDirectory, moduleName)); - return toSearchResult(loadModuleFromFile(extensions, candidate, failedLookupLocations, false, state)); + return toSearchResult(loadModuleFromFileNoPackageId(extensions, candidate, failedLookupLocations, false, state)); } } } @@ -18294,6 +19597,9 @@ var ts; node = ts.getParseTreeNode(node, ts.isExportSpecifier); return node ? getExportSpecifierLocalTargetSymbol(node) : undefined; }, + getExportSymbolOfSymbol: function (symbol) { + return getMergedSymbol(symbol.exportSymbol || symbol); + }, getTypeAtLocation: function (node) { node = ts.getParseTreeNode(node); return node ? getTypeOfNode(node) : unknownType; @@ -18356,6 +19662,7 @@ var ts; getEmitResolver: getEmitResolver, getExportsOfModule: getExportsOfModuleAsArray, getExportsAndPropertiesOfModule: getExportsAndPropertiesOfModule, + getSymbolWalker: ts.createGetSymbolWalker(getRestTypeOfSignature, getReturnTypeOfSignature, getBaseTypes, resolveStructuredTypeMembers, getTypeOfSymbol, getResolvedSymbol, getIndexTypeOfStructuredType, getConstraintFromTypeParameter, getFirstIdentifier), getAmbientModules: getAmbientModules, getAllAttributesTypeFromJsxOpeningLikeElement: function (node) { node = ts.getParseTreeNode(node, ts.isJsxOpeningLikeElement); @@ -18376,11 +19683,10 @@ var ts; getSuggestionForNonexistentProperty: function (node, type) { return ts.unescapeLeadingUnderscores(getSuggestionForNonexistentProperty(node, type)); }, getSuggestionForNonexistentSymbol: function (location, name, meaning) { return ts.unescapeLeadingUnderscores(getSuggestionForNonexistentSymbol(location, ts.escapeLeadingUnderscores(name), meaning)); }, getBaseConstraintOfType: getBaseConstraintOfType, - getJsxNamespace: function () { return ts.unescapeLeadingUnderscores(getJsxNamespace()); }, - resolveNameAtLocation: function (location, name, meaning) { - location = ts.getParseTreeNode(location); - return resolveName(location, ts.escapeLeadingUnderscores(name), meaning, undefined, ts.escapeLeadingUnderscores(name)); + resolveName: function (name, location, meaning) { + return resolveName(location, ts.escapeLeadingUnderscores(name), meaning, undefined, undefined); }, + getJsxNamespace: function () { return ts.unescapeLeadingUnderscores(getJsxNamespace()); }, }; var tupleTypes = []; var unionTypes = ts.createMap(); @@ -18478,6 +19784,66 @@ var ts; var potentialNewTargetCollisions = []; var awaitedTypeStack = []; var diagnostics = ts.createDiagnosticCollection(); + var TypeFacts; + (function (TypeFacts) { + TypeFacts[TypeFacts["None"] = 0] = "None"; + TypeFacts[TypeFacts["TypeofEQString"] = 1] = "TypeofEQString"; + TypeFacts[TypeFacts["TypeofEQNumber"] = 2] = "TypeofEQNumber"; + TypeFacts[TypeFacts["TypeofEQBoolean"] = 4] = "TypeofEQBoolean"; + TypeFacts[TypeFacts["TypeofEQSymbol"] = 8] = "TypeofEQSymbol"; + TypeFacts[TypeFacts["TypeofEQObject"] = 16] = "TypeofEQObject"; + TypeFacts[TypeFacts["TypeofEQFunction"] = 32] = "TypeofEQFunction"; + TypeFacts[TypeFacts["TypeofEQHostObject"] = 64] = "TypeofEQHostObject"; + TypeFacts[TypeFacts["TypeofNEString"] = 128] = "TypeofNEString"; + TypeFacts[TypeFacts["TypeofNENumber"] = 256] = "TypeofNENumber"; + TypeFacts[TypeFacts["TypeofNEBoolean"] = 512] = "TypeofNEBoolean"; + TypeFacts[TypeFacts["TypeofNESymbol"] = 1024] = "TypeofNESymbol"; + TypeFacts[TypeFacts["TypeofNEObject"] = 2048] = "TypeofNEObject"; + TypeFacts[TypeFacts["TypeofNEFunction"] = 4096] = "TypeofNEFunction"; + TypeFacts[TypeFacts["TypeofNEHostObject"] = 8192] = "TypeofNEHostObject"; + TypeFacts[TypeFacts["EQUndefined"] = 16384] = "EQUndefined"; + TypeFacts[TypeFacts["EQNull"] = 32768] = "EQNull"; + TypeFacts[TypeFacts["EQUndefinedOrNull"] = 65536] = "EQUndefinedOrNull"; + TypeFacts[TypeFacts["NEUndefined"] = 131072] = "NEUndefined"; + TypeFacts[TypeFacts["NENull"] = 262144] = "NENull"; + TypeFacts[TypeFacts["NEUndefinedOrNull"] = 524288] = "NEUndefinedOrNull"; + TypeFacts[TypeFacts["Truthy"] = 1048576] = "Truthy"; + TypeFacts[TypeFacts["Falsy"] = 2097152] = "Falsy"; + TypeFacts[TypeFacts["Discriminatable"] = 4194304] = "Discriminatable"; + TypeFacts[TypeFacts["All"] = 8388607] = "All"; + TypeFacts[TypeFacts["BaseStringStrictFacts"] = 933633] = "BaseStringStrictFacts"; + TypeFacts[TypeFacts["BaseStringFacts"] = 3145473] = "BaseStringFacts"; + TypeFacts[TypeFacts["StringStrictFacts"] = 4079361] = "StringStrictFacts"; + TypeFacts[TypeFacts["StringFacts"] = 4194049] = "StringFacts"; + TypeFacts[TypeFacts["EmptyStringStrictFacts"] = 3030785] = "EmptyStringStrictFacts"; + TypeFacts[TypeFacts["EmptyStringFacts"] = 3145473] = "EmptyStringFacts"; + TypeFacts[TypeFacts["NonEmptyStringStrictFacts"] = 1982209] = "NonEmptyStringStrictFacts"; + TypeFacts[TypeFacts["NonEmptyStringFacts"] = 4194049] = "NonEmptyStringFacts"; + TypeFacts[TypeFacts["BaseNumberStrictFacts"] = 933506] = "BaseNumberStrictFacts"; + TypeFacts[TypeFacts["BaseNumberFacts"] = 3145346] = "BaseNumberFacts"; + TypeFacts[TypeFacts["NumberStrictFacts"] = 4079234] = "NumberStrictFacts"; + TypeFacts[TypeFacts["NumberFacts"] = 4193922] = "NumberFacts"; + TypeFacts[TypeFacts["ZeroStrictFacts"] = 3030658] = "ZeroStrictFacts"; + TypeFacts[TypeFacts["ZeroFacts"] = 3145346] = "ZeroFacts"; + TypeFacts[TypeFacts["NonZeroStrictFacts"] = 1982082] = "NonZeroStrictFacts"; + TypeFacts[TypeFacts["NonZeroFacts"] = 4193922] = "NonZeroFacts"; + TypeFacts[TypeFacts["BaseBooleanStrictFacts"] = 933252] = "BaseBooleanStrictFacts"; + TypeFacts[TypeFacts["BaseBooleanFacts"] = 3145092] = "BaseBooleanFacts"; + TypeFacts[TypeFacts["BooleanStrictFacts"] = 4078980] = "BooleanStrictFacts"; + TypeFacts[TypeFacts["BooleanFacts"] = 4193668] = "BooleanFacts"; + TypeFacts[TypeFacts["FalseStrictFacts"] = 3030404] = "FalseStrictFacts"; + TypeFacts[TypeFacts["FalseFacts"] = 3145092] = "FalseFacts"; + TypeFacts[TypeFacts["TrueStrictFacts"] = 1981828] = "TrueStrictFacts"; + TypeFacts[TypeFacts["TrueFacts"] = 4193668] = "TrueFacts"; + TypeFacts[TypeFacts["SymbolStrictFacts"] = 1981320] = "SymbolStrictFacts"; + TypeFacts[TypeFacts["SymbolFacts"] = 4193160] = "SymbolFacts"; + TypeFacts[TypeFacts["ObjectStrictFacts"] = 6166480] = "ObjectStrictFacts"; + TypeFacts[TypeFacts["ObjectFacts"] = 8378320] = "ObjectFacts"; + TypeFacts[TypeFacts["FunctionStrictFacts"] = 6164448] = "FunctionStrictFacts"; + TypeFacts[TypeFacts["FunctionFacts"] = 8376288] = "FunctionFacts"; + TypeFacts[TypeFacts["UndefinedFacts"] = 2457472] = "UndefinedFacts"; + TypeFacts[TypeFacts["NullFacts"] = 2340752] = "NullFacts"; + })(TypeFacts || (TypeFacts = {})); var typeofEQFacts = ts.createMapFromTemplate({ "string": 1, "number": 2, @@ -18527,6 +19893,19 @@ var ts; var identityRelation = ts.createMap(); var enumRelation = ts.createMap(); var _displayBuilder; + var TypeSystemPropertyName; + (function (TypeSystemPropertyName) { + TypeSystemPropertyName[TypeSystemPropertyName["Type"] = 0] = "Type"; + TypeSystemPropertyName[TypeSystemPropertyName["ResolvedBaseConstructorType"] = 1] = "ResolvedBaseConstructorType"; + TypeSystemPropertyName[TypeSystemPropertyName["DeclaredType"] = 2] = "DeclaredType"; + TypeSystemPropertyName[TypeSystemPropertyName["ResolvedReturnType"] = 3] = "ResolvedReturnType"; + })(TypeSystemPropertyName || (TypeSystemPropertyName = {})); + var CheckMode; + (function (CheckMode) { + CheckMode[CheckMode["Normal"] = 0] = "Normal"; + CheckMode[CheckMode["SkipContextSensitive"] = 1] = "SkipContextSensitive"; + CheckMode[CheckMode["Inferential"] = 2] = "Inferential"; + })(CheckMode || (CheckMode = {})); var builtinGlobals = ts.createSymbolTable(); builtinGlobals.set(undefinedSymbol.escapedName, undefinedSymbol); initializeTypeChecker(); @@ -18790,7 +20169,10 @@ var ts; } return true; } - if (usage.parent.kind === 246) { + if (usage.parent.kind === 246 || (usage.parent.kind === 243 && usage.parent.isExportEquals)) { + return true; + } + if (usage.kind === 243 && usage.isExportEquals) { return true; } var container = ts.getEnclosingBlockScopeContainer(declaration); @@ -18820,13 +20202,13 @@ var ts; current.parent.kind === 149 && current.parent.initializer === current; if (initializerOfProperty) { - if (ts.getModifierFlags(current.parent) & 32) { + if (ts.hasModifier(current.parent, 32)) { if (declaration.kind === 151) { return true; } } else { - var isDeclarationInstanceProperty = declaration.kind === 149 && !(ts.getModifierFlags(declaration) & 32); + var isDeclarationInstanceProperty = declaration.kind === 149 && !ts.hasModifier(declaration, 32); if (!isDeclarationInstanceProperty || ts.getContainingClass(usage) !== ts.getContainingClass(declaration)) { return true; } @@ -18906,7 +20288,7 @@ var ts; break; case 149: case 148: - if (ts.isClassLike(location.parent) && !(ts.getModifierFlags(location) & 32)) { + if (ts.isClassLike(location.parent) && !ts.hasModifier(location, 32)) { var ctor = findConstructorDeclaration(location.parent); if (ctor && ctor.locals) { if (lookup(ctor.locals, name, meaning & 107455)) { @@ -18923,7 +20305,7 @@ var ts; result = undefined; break; } - if (lastLocation && ts.getModifierFlags(lastLocation) & 32) { + if (lastLocation && ts.hasModifier(lastLocation, 32)) { error(errorLocation, ts.Diagnostics.Static_members_cannot_reference_class_type_parameters); return undefined; } @@ -18937,6 +20319,17 @@ var ts; } } break; + case 201: + if (lastLocation === location.expression && location.parent.token === 85) { + var container = location.parent.parent; + if (ts.isClassLike(container) && (result = lookup(getSymbolOfNode(container).members, name, meaning & 793064))) { + if (nameNotFoundMessage) { + error(errorLocation, ts.Diagnostics.Base_class_expressions_cannot_reference_class_type_parameters); + } + return undefined; + } + } + break; case 144: grandparent = location.parent.parent; if (ts.isClassLike(grandparent) || grandparent.kind === 230) { @@ -18983,7 +20376,7 @@ var ts; lastLocation = location; location = location.parent; } - if (result && nameNotFoundMessage && noUnusedIdentifiers) { + if (result && nameNotFoundMessage && noUnusedIdentifiers && result !== lastLocation.symbol) { result.isReferenced = true; } if (!result) { @@ -19064,7 +20457,7 @@ var ts; error(errorLocation, ts.Diagnostics.Cannot_find_name_0_Did_you_mean_the_static_member_1_0, diagnosticName(nameArg), symbolToString(classSymbol)); return true; } - if (location === container && !(ts.getModifierFlags(location) & 32)) { + if (location === container && !ts.hasModifier(location, 32)) { var instanceType = getDeclaredTypeOfSymbol(classSymbol).thisType; if (getPropertyOfType(instanceType, name)) { error(errorLocation, ts.Diagnostics.Cannot_find_name_0_Did_you_mean_the_instance_member_this_0, diagnosticName(nameArg)); @@ -19450,7 +20843,6 @@ var ts; if (ambientModule) { return ambientModule; } - var isRelative = ts.isExternalModuleNameRelative(moduleReference); var resolvedModule = ts.getResolvedModule(ts.getSourceFileOfNode(location), moduleReference); var resolutionDiagnostic = resolvedModule && ts.getResolutionDiagnostic(compilerOptions, resolvedModule); var sourceFile = resolvedModule && !resolutionDiagnostic && host.getSourceFile(resolvedModule.resolvedFileName); @@ -19469,7 +20861,7 @@ var ts; return getMergedSymbol(pattern.symbol); } } - if (!isRelative && resolvedModule && !ts.extensionIsTypeScript(resolvedModule.extension)) { + if (resolvedModule && resolvedModule.isExternalLibraryImport && !ts.extensionIsTypeScript(resolvedModule.extension)) { if (isForAugmentation) { var diag = ts.Diagnostics.Invalid_module_name_in_augmentation_Module_0_resolves_to_an_untyped_module_at_1_which_cannot_be_augmented; error(errorNode, diag, moduleReference, resolvedModule.resolvedFileName); @@ -19804,6 +21196,10 @@ var ts; } return false; } + function isTypeSymbolAccessible(typeSymbol, enclosingDeclaration) { + var access = isSymbolAccessible(typeSymbol, enclosingDeclaration, 793064, false); + return access.accessibility === 0; + } function isSymbolAccessible(symbol, enclosingDeclaration, meaning, shouldComputeAliasesToMakeVisible) { if (symbol && enclosingDeclaration && !(symbol.flags & 262144)) { var initialSymbol = symbol; @@ -19859,7 +21255,7 @@ var ts; if (!isDeclarationVisible(declaration)) { var anyImportSyntax = getAnyImportSyntax(declaration); if (anyImportSyntax && - !(ts.getModifierFlags(anyImportSyntax) & 1) && + !ts.hasModifier(anyImportSyntax, 1) && isDeclarationVisible(anyImportSyntax.parent)) { if (shouldComputeAliasToMakeVisible) { getNodeLinks(declaration).isVisible = true; @@ -20057,8 +21453,7 @@ var ts; var name = symbolToName(type.symbol, context, 793064, false); return ts.createTypeReferenceNode(name, undefined); } - if (!inTypeAlias && type.aliasSymbol && - isSymbolAccessible(type.aliasSymbol, context.enclosingDeclaration, 793064, false).accessibility === 0) { + if (!inTypeAlias && type.aliasSymbol && isTypeSymbolAccessible(type.aliasSymbol, context.enclosingDeclaration)) { var name = symbolToTypeReferenceName(type.aliasSymbol); var typeArgumentNodes = mapToTypeNodes(type.aliasTypeArguments, context); return ts.createTypeReferenceNode(name, typeArgumentNodes); @@ -20133,8 +21528,8 @@ var ts; return createTypeNodeFromObjectType(type); } function shouldWriteTypeOfFunctionSymbol() { - var isStaticMethodSymbol = !!(symbol.flags & 8192 && - ts.forEach(symbol.declarations, function (declaration) { return ts.getModifierFlags(declaration) & 32; })); + var isStaticMethodSymbol = !!(symbol.flags & 8192) && + ts.some(symbol.declarations, function (declaration) { return ts.hasModifier(declaration, 32); }); var isNonLocalFunctionSymbol = !!(symbol.flags & 16) && (symbol.parent || ts.forEach(symbol.declarations, function (declaration) { @@ -20146,10 +21541,8 @@ var ts; } } function createTypeNodeFromObjectType(type) { - if (type.objectFlags & 32) { - if (getConstraintTypeFromMappedType(type).flags & (16384 | 262144)) { - return createMappedTypeNodeFromType(type); - } + if (isGenericMappedType(type)) { + return createMappedTypeNodeFromType(type); } var resolved = resolveStructuredTypeMembers(type); if (!resolved.properties.length && !resolved.stringIndexInfo && !resolved.numberIndexInfo) { @@ -20677,7 +22070,7 @@ var ts; buildSymbolDisplay(type.symbol, writer, enclosingDeclaration, 793064, 0, nextFlags); } else if (!(flags & 1024) && type.aliasSymbol && - isSymbolAccessible(type.aliasSymbol, enclosingDeclaration, 793064, false).accessibility === 0) { + ((flags & 65536) || isTypeSymbolAccessible(type.aliasSymbol, enclosingDeclaration))) { var typeArguments = type.aliasTypeArguments; writeSymbolTypeReference(type.aliasSymbol, typeArguments, 0, ts.length(typeArguments), nextFlags); } @@ -20821,9 +22214,7 @@ var ts; if (!symbolStack) { symbolStack = []; } - var isConstructorObject = type.flags & 32768 && - getObjectFlags(type) & 16 && - type.symbol && type.symbol.flags & 32; + var isConstructorObject = type.objectFlags & 16 && type.symbol && type.symbol.flags & 32; if (isConstructorObject) { writeLiteralType(type, flags); } @@ -20838,16 +22229,16 @@ var ts; writeLiteralType(type, flags); } function shouldWriteTypeOfFunctionSymbol() { - var isStaticMethodSymbol = !!(symbol.flags & 8192 && - ts.forEach(symbol.declarations, function (declaration) { return ts.getModifierFlags(declaration) & 32; })); + var isStaticMethodSymbol = !!(symbol.flags & 8192) && + ts.some(symbol.declarations, function (declaration) { return ts.hasModifier(declaration, 32); }); var isNonLocalFunctionSymbol = !!(symbol.flags & 16) && (symbol.parent || - ts.forEach(symbol.declarations, function (declaration) { + ts.some(symbol.declarations, function (declaration) { return declaration.parent.kind === 265 || declaration.parent.kind === 234; })); if (isStaticMethodSymbol || isNonLocalFunctionSymbol) { return !!(flags & 4) || - (ts.contains(symbolStack, symbol)); + ts.contains(symbolStack, symbol); } } } @@ -20884,11 +22275,9 @@ var ts; return false; } function writeLiteralType(type, flags) { - if (type.objectFlags & 32) { - if (getConstraintTypeFromMappedType(type).flags & (16384 | 262144)) { - writeMappedType(type); - return; - } + if (isGenericMappedType(type)) { + writeMappedType(type); + return; } var resolved = resolveStructuredTypeMembers(type); if (!resolved.properties.length && !resolved.stringIndexInfo && !resolved.numberIndexInfo) { @@ -21256,7 +22645,7 @@ var ts; case 154: case 151: case 150: - if (ts.getModifierFlags(node) & (8 | 16)) { + if (ts.hasModifier(node, 8 | 16)) { return false; } case 152: @@ -21933,8 +23322,8 @@ var ts; } } function appendTypeParameters(typeParameters, declarations) { - for (var _i = 0, declarations_3 = declarations; _i < declarations_3.length; _i++) { - var declaration = declarations_3[_i]; + for (var _i = 0, declarations_2 = declarations; _i < declarations_2.length; _i++) { + var declaration = declarations_2[_i]; var tp = getDeclaredTypeOfTypeParameter(getSymbolOfNode(declaration)); if (!typeParameters) { typeParameters = [tp]; @@ -22058,7 +23447,7 @@ var ts; return type.resolvedBaseTypes; } function resolveBaseTypesOfClass(type) { - type.resolvedBaseTypes = type.resolvedBaseTypes || ts.emptyArray; + type.resolvedBaseTypes = ts.emptyArray; var baseConstructorType = getApparentType(getBaseConstructorTypeOfClass(type)); if (!(baseConstructorType.flags & (32768 | 131072 | 1))) { return; @@ -22100,12 +23489,7 @@ var ts; error(valueDecl, ts.Diagnostics.Type_0_recursively_references_itself_as_a_base_type, typeToString(type, undefined, 1)); return; } - if (type.resolvedBaseTypes === ts.emptyArray) { - type.resolvedBaseTypes = [baseType]; - } - else { - type.resolvedBaseTypes.push(baseType); - } + type.resolvedBaseTypes = [baseType]; } function areAllOuterTypeParametersApplied(type) { var outerTypeParameters = type.outerTypeParameters; @@ -22203,7 +23587,9 @@ var ts; if (!pushTypeResolution(symbol, 2)) { return unknownType; } - var declaration = ts.findDeclaration(symbol, function (d) { return d.kind === 283 || d.kind === 231; }); + var declaration = ts.find(symbol.declarations, function (d) { + return d.kind === 283 || d.kind === 231; + }); var type = getTypeFromTypeNode(declaration.kind === 283 ? declaration.typeExpression : declaration.type); if (popTypeResolution()) { var typeParameters = getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol); @@ -22695,17 +24081,12 @@ var ts; } else { var members = emptySymbols; - var constructSignatures = ts.emptyArray; var stringIndexInfo = undefined; if (symbol.exports) { members = getExportsOfSymbol(symbol); } if (symbol.flags & 32) { var classType = getDeclaredTypeOfClassOrInterface(symbol); - constructSignatures = getSignaturesOfSymbol(symbol.members.get("__constructor")); - if (!constructSignatures.length) { - constructSignatures = getDefaultConstructSignatures(classType); - } var baseConstructorType = getBaseConstructorTypeOfClass(classType); if (baseConstructorType.flags & (32768 | 131072 | 540672)) { members = ts.createSymbolTable(getNamedMembers(members)); @@ -22716,10 +24097,18 @@ var ts; } } var numberIndexInfo = symbol.flags & 384 ? enumNumberIndexInfo : undefined; - setStructuredTypeMembers(type, members, ts.emptyArray, constructSignatures, stringIndexInfo, numberIndexInfo); + setStructuredTypeMembers(type, members, ts.emptyArray, ts.emptyArray, stringIndexInfo, numberIndexInfo); if (symbol.flags & (16 | 8192)) { type.callSignatures = getSignaturesOfSymbol(symbol); } + if (symbol.flags & 32) { + var classType = getDeclaredTypeOfClassOrInterface(symbol); + var constructSignatures = getSignaturesOfSymbol(symbol.members.get("__constructor")); + if (!constructSignatures.length) { + constructSignatures = getDefaultConstructSignatures(classType); + } + type.constructSignatures = constructSignatures; + } } } function resolveMappedTypeMembers(type) { @@ -22802,8 +24191,7 @@ var ts; return getObjectFlags(type) & 32 && !!type.declaration.questionToken; } function isGenericMappedType(type) { - return getObjectFlags(type) & 32 && - maybeTypeOfKind(getConstraintTypeFromMappedType(type), 540672 | 262144); + return getObjectFlags(type) & 32 && isGenericIndexType(getConstraintTypeFromMappedType(type)); } function resolveStructuredTypeMembers(type) { if (!type.members) { @@ -22903,6 +24291,10 @@ var ts; return hasNonCircularBaseConstraint(typeParameter) ? getConstraintFromTypeParameter(typeParameter) : undefined; } function getConstraintOfIndexedAccess(type) { + var transformed = getTransformedIndexedAccessType(type); + if (transformed) { + return transformed; + } var baseObjectType = getBaseConstraintOfType(type.objectType); var baseIndexType = getBaseConstraintOfType(type.indexType); return baseObjectType || baseIndexType ? getIndexedAccessType(baseObjectType || type.objectType, baseIndexType || type.indexType) : undefined; @@ -22965,11 +24357,18 @@ var ts; return stringType; } if (t.flags & 524288) { + var transformed = getTransformedIndexedAccessType(t); + if (transformed) { + return getBaseConstraint(transformed); + } var baseObjectType = getBaseConstraint(t.objectType); var baseIndexType = getBaseConstraint(t.indexType); var baseIndexedAccess = baseObjectType && baseIndexType ? getIndexedAccessType(baseObjectType, baseIndexType) : undefined; return baseIndexedAccess && baseIndexedAccess !== unknownType ? getBaseConstraint(baseIndexedAccess) : undefined; } + if (isGenericMappedType(t)) { + return emptyObjectType; + } return t; } } @@ -23449,6 +24848,9 @@ var ts; } return signature.resolvedReturnType; } + function isResolvingReturnTypeOfSignature(signature) { + return !signature.resolvedReturnType && findResolutionCycleStartIndex(signature, 3) >= 0; + } function getRestTypeOfSignature(signature) { if (signature.hasRestParameter) { var type = getTypeOfSymbol(ts.lastOrUndefined(signature.parameters)); @@ -23517,7 +24919,7 @@ var ts; function getIndexInfoOfSymbol(symbol, kind) { var declaration = getIndexDeclarationOfSymbol(symbol, kind); if (declaration) { - return createIndexInfo(declaration.type ? getTypeFromTypeNode(declaration.type) : anyType, (ts.getModifierFlags(declaration) & 64) !== 0, declaration); + return createIndexInfo(declaration.type ? getTypeFromTypeNode(declaration.type) : anyType, ts.hasModifier(declaration, 64), declaration); } return undefined; } @@ -23785,8 +25187,8 @@ var ts; function getTypeOfGlobalSymbol(symbol, arity) { function getTypeDeclaration(symbol) { var declarations = symbol.declarations; - for (var _i = 0, declarations_4 = declarations; _i < declarations_4.length; _i++) { - var declaration = declarations_4[_i]; + for (var _i = 0, declarations_3 = declarations; _i < declarations_3.length; _i++) { + var declaration = declarations_3[_i]; switch (declaration.kind) { case 229: case 230: @@ -24243,17 +25645,16 @@ var ts; return getTypeOfSymbol(prop); } } - if (isTypeAnyOrAllConstituentTypesHaveKind(indexType, 262178 | 84 | 512)) { + if (!(indexType.flags & 6144) && isTypeAssignableToKind(indexType, 262178 | 84 | 512)) { if (isTypeAny(objectType)) { return anyType; } - var indexInfo = isTypeAnyOrAllConstituentTypesHaveKind(indexType, 84) && getIndexInfoOfType(objectType, 1) || + var indexInfo = isTypeAssignableToKind(indexType, 84) && getIndexInfoOfType(objectType, 1) || getIndexInfoOfType(objectType, 0) || undefined; if (indexInfo) { if (accessExpression && indexInfo.isReadonly && (ts.isAssignmentTarget(accessExpression) || ts.isDeleteTarget(accessExpression))) { error(accessExpression, ts.Diagnostics.Index_signature_in_type_0_only_permits_reading, typeToString(objectType)); - return unknownType; } return indexInfo.type; } @@ -24285,25 +25686,68 @@ var ts; return anyType; } function getIndexedAccessForMappedType(type, indexType, accessNode) { - var accessExpression = accessNode && accessNode.kind === 180 ? accessNode : undefined; - if (accessExpression && ts.isAssignmentTarget(accessExpression) && type.declaration.readonlyToken) { - error(accessExpression, ts.Diagnostics.Index_signature_in_type_0_only_permits_reading, typeToString(type)); - return unknownType; + if (accessNode) { + if (!isTypeAssignableTo(indexType, getIndexType(type))) { + error(accessNode, ts.Diagnostics.Type_0_cannot_be_used_to_index_type_1, typeToString(indexType), typeToString(type)); + return unknownType; + } + if (accessNode.kind === 180 && ts.isAssignmentTarget(accessNode) && type.declaration.readonlyToken) { + error(accessNode, ts.Diagnostics.Index_signature_in_type_0_only_permits_reading, typeToString(type)); + } } var mapper = createTypeMapper([getTypeParameterFromMappedType(type)], [indexType]); var templateMapper = type.mapper ? combineTypeMappers(type.mapper, mapper) : mapper; return instantiateType(getTemplateTypeFromMappedType(type), templateMapper); } + function isGenericObjectType(type) { + return type.flags & 540672 ? true : + getObjectFlags(type) & 32 ? isGenericIndexType(getConstraintTypeFromMappedType(type)) : + type.flags & 196608 ? ts.forEach(type.types, isGenericObjectType) : + false; + } + function isGenericIndexType(type) { + return type.flags & (540672 | 262144) ? true : + type.flags & 196608 ? ts.forEach(type.types, isGenericIndexType) : + false; + } + function isStringIndexOnlyType(type) { + if (type.flags & 32768 && !isGenericMappedType(type)) { + var t = resolveStructuredTypeMembers(type); + return t.properties.length === 0 && + t.callSignatures.length === 0 && t.constructSignatures.length === 0 && + t.stringIndexInfo && !t.numberIndexInfo; + } + return false; + } + function getTransformedIndexedAccessType(type) { + var objectType = type.objectType; + if (objectType.flags & 131072 && isGenericObjectType(objectType) && ts.some(objectType.types, isStringIndexOnlyType)) { + var regularTypes = []; + var stringIndexTypes = []; + for (var _i = 0, _a = objectType.types; _i < _a.length; _i++) { + var t = _a[_i]; + if (isStringIndexOnlyType(t)) { + stringIndexTypes.push(getIndexTypeOfType(t, 0)); + } + else { + regularTypes.push(t); + } + } + return getUnionType([ + getIndexedAccessType(getIntersectionType(regularTypes), type.indexType), + getIntersectionType(stringIndexTypes) + ]); + } + return undefined; + } function getIndexedAccessType(objectType, indexType, accessNode) { - if (maybeTypeOfKind(indexType, 540672 | 262144) || - maybeTypeOfKind(objectType, 540672) && !(accessNode && accessNode.kind === 180) || - isGenericMappedType(objectType)) { + if (isGenericMappedType(objectType)) { + return getIndexedAccessForMappedType(objectType, indexType, accessNode); + } + if (isGenericIndexType(indexType) || !(accessNode && accessNode.kind === 180) && isGenericObjectType(objectType)) { if (objectType.flags & 1) { return objectType; } - if (isGenericMappedType(objectType)) { - return getIndexedAccessForMappedType(objectType, indexType, accessNode); - } var id = objectType.id + "," + indexType.id; var type = indexedAccessTypes.get(id); if (!type) { @@ -24502,7 +25946,7 @@ var ts; var container = ts.getThisContainer(node, false); var parent = container && container.parent; if (parent && (ts.isClassLike(parent) || parent.kind === 230)) { - if (!(ts.getModifierFlags(container) & 32) && + if (!ts.hasModifier(container, 32) && (container.kind !== 152 || ts.isNodeDescendantOf(node, container.body))) { return getDeclaredTypeOfClassOrInterface(getSymbolOfNode(parent)).thisType; } @@ -24649,7 +26093,7 @@ var ts; } function cloneTypeMapper(mapper) { return mapper && isInferenceContext(mapper) ? - createInferenceContext(mapper.signature, mapper.flags | 2, mapper.inferences) : + createInferenceContext(mapper.signature, mapper.flags | 2, mapper.compareTypes, mapper.inferences) : mapper; } function identityMapper(type) { @@ -24913,11 +26357,13 @@ var ts; if (ts.forEach(node.parameters, function (p) { return !ts.getEffectiveTypeAnnotationNode(p); })) { return true; } - if (node.kind === 187) { - return false; + if (node.kind !== 187) { + var parameter = ts.firstOrUndefined(node.parameters); + if (!(parameter && ts.parameterIsThisKeyword(parameter))) { + return true; + } } - var parameter = ts.firstOrUndefined(node.parameters); - return !(parameter && ts.parameterIsThisKeyword(parameter)); + return node.body.kind === 207 ? false : isContextSensitive(node.body); } function isContextSensitiveFunctionOrObjectLiteralMethod(func) { return (isFunctionExpressionOrArrowFunction(func) || ts.isObjectLiteralMethod(func)) && isContextSensitiveFunctionLikeDeclaration(func); @@ -24980,7 +26426,7 @@ var ts; return 0; } if (source.typeParameters) { - source = instantiateSignatureInContextOf(source, target); + source = instantiateSignatureInContextOf(source, target, undefined, compareTypes); } var result = -1; var sourceThisType = getThisTypeOfSignature(source); @@ -25029,7 +26475,7 @@ var ts; var sourceReturnType = getReturnTypeOfSignature(source); if (target.typePredicate) { if (source.typePredicate) { - result &= compareTypePredicateRelatedTo(source.typePredicate, target.typePredicate, reportErrors, errorReporter, compareTypes); + result &= compareTypePredicateRelatedTo(source.typePredicate, target.typePredicate, source.declaration, target.declaration, reportErrors, errorReporter, compareTypes); } else if (ts.isIdentifierTypePredicate(target.typePredicate)) { if (reportErrors) { @@ -25045,7 +26491,7 @@ var ts; } return result; } - function compareTypePredicateRelatedTo(source, target, reportErrors, errorReporter, compareTypes) { + function compareTypePredicateRelatedTo(source, target, sourceDeclaration, targetDeclaration, reportErrors, errorReporter, compareTypes) { if (source.kind !== target.kind) { if (reportErrors) { errorReporter(ts.Diagnostics.A_this_based_type_guard_is_not_compatible_with_a_parameter_based_type_guard); @@ -25054,11 +26500,13 @@ var ts; return 0; } if (source.kind === 1) { - var sourceIdentifierPredicate = source; - var targetIdentifierPredicate = target; - if (sourceIdentifierPredicate.parameterIndex !== targetIdentifierPredicate.parameterIndex) { + var sourcePredicate = source; + var targetPredicate = target; + var sourceIndex = sourcePredicate.parameterIndex - (ts.getThisParameter(sourceDeclaration) ? 1 : 0); + var targetIndex = targetPredicate.parameterIndex - (ts.getThisParameter(targetDeclaration) ? 1 : 0); + if (sourceIndex !== targetIndex) { if (reportErrors) { - errorReporter(ts.Diagnostics.Parameter_0_is_not_in_the_same_position_as_parameter_1, sourceIdentifierPredicate.parameterName, targetIdentifierPredicate.parameterName); + errorReporter(ts.Diagnostics.Parameter_0_is_not_in_the_same_position_as_parameter_1, sourcePredicate.parameterName, targetPredicate.parameterName); errorReporter(ts.Diagnostics.Type_predicate_0_is_not_assignable_to_1, typePredicateToString(source), typePredicateToString(target)); } return 0; @@ -25203,8 +26651,7 @@ var ts; return true; } if (source.flags & 32768 && target.flags & 32768) { - var id = relation !== identityRelation || source.id < target.id ? source.id + "," + target.id : target.id + "," + source.id; - var related = relation.get(id); + var related = relation.get(getRelationKey(source, target, relation)); if (related !== undefined) { return related === 1; } @@ -25317,11 +26764,21 @@ var ts; !(target.flags & 65536) && !isIntersectionConstituent && source !== globalObjectType && - getPropertiesOfType(source).length > 0 && + (getPropertiesOfType(source).length > 0 || + getSignaturesOfType(source, 0).length > 0 || + getSignaturesOfType(source, 1).length > 0) && isWeakType(target) && !hasCommonProperties(source, target)) { if (reportErrors) { - reportError(ts.Diagnostics.Type_0_has_no_properties_in_common_with_type_1, typeToString(source), typeToString(target)); + var calls = getSignaturesOfType(source, 0); + var constructs = getSignaturesOfType(source, 1); + if (calls.length > 0 && isRelatedTo(getReturnTypeOfSignature(calls[0]), target, false) || + constructs.length > 0 && isRelatedTo(getReturnTypeOfSignature(constructs[0]), target, false)) { + reportError(ts.Diagnostics.Value_of_type_0_has_no_properties_in_common_with_type_1_Did_you_mean_to_call_it, typeToString(source), typeToString(target)); + } + else { + reportError(ts.Diagnostics.Type_0_has_no_properties_in_common_with_type_1, typeToString(source), typeToString(target)); + } } return 0; } @@ -25522,7 +26979,7 @@ var ts; if (overflow) { return 0; } - var id = relation !== identityRelation || source.id < target.id ? source.id + "," + target.id : target.id + "," + source.id; + var id = getRelationKey(source, target, relation); var related = relation.get(id); if (related !== undefined) { if (reportErrors && related === 2) { @@ -25942,6 +27399,9 @@ var ts; if (sourceInfo) { return indexInfoRelatedTo(sourceInfo, targetInfo, reportErrors); } + if (isGenericMappedType(source)) { + return kind === 0 && isRelatedTo(getTemplateTypeFromMappedType(source), targetInfo.type, reportErrors); + } if (isObjectLiteralType(source)) { var related = -1; if (kind === 0) { @@ -25975,8 +27435,8 @@ var ts; if (!sourceSignature.declaration || !targetSignature.declaration) { return true; } - var sourceAccessibility = ts.getModifierFlags(sourceSignature.declaration) & 24; - var targetAccessibility = ts.getModifierFlags(targetSignature.declaration) & 24; + var sourceAccessibility = ts.getSelectedModifierFlags(sourceSignature.declaration, 24); + var targetAccessibility = ts.getSelectedModifierFlags(targetSignature.declaration, 24); if (targetAccessibility === 8) { return true; } @@ -25992,6 +27452,42 @@ var ts; return false; } } + function isUnconstrainedTypeParameter(type) { + return type.flags & 16384 && !getConstraintFromTypeParameter(type); + } + function isTypeReferenceWithGenericArguments(type) { + return getObjectFlags(type) & 4 && ts.some(type.typeArguments, isUnconstrainedTypeParameter); + } + function getTypeReferenceId(type, typeParameters) { + var result = "" + type.target.id; + for (var _i = 0, _a = type.typeArguments; _i < _a.length; _i++) { + var t = _a[_i]; + if (isUnconstrainedTypeParameter(t)) { + var index = ts.indexOf(typeParameters, t); + if (index < 0) { + index = typeParameters.length; + typeParameters.push(t); + } + result += "=" + index; + } + else { + result += "-" + t.id; + } + } + return result; + } + function getRelationKey(source, target, relation) { + if (relation === identityRelation && source.id > target.id) { + var temp = source; + source = target; + target = temp; + } + if (isTypeReferenceWithGenericArguments(source) && isTypeReferenceWithGenericArguments(target)) { + var typeParameters = []; + return getTypeReferenceId(source, typeParameters) + "," + getTypeReferenceId(target, typeParameters); + } + return source.id + "," + target.id; + } function forEachProperty(prop, callback) { if (ts.getCheckFlags(prop) & 6) { for (var _i = 0, _a = prop.containingType.types; _i < _a.length; _i++) { @@ -26028,7 +27524,7 @@ var ts; var symbol = type.symbol; if (symbol && symbol.flags & 32) { var declaration = getClassLikeDeclarationOfSymbol(symbol); - if (declaration && ts.getModifierFlags(declaration) & 128) { + if (declaration && ts.hasModifier(declaration, 128)) { return true; } } @@ -26414,13 +27910,14 @@ var ts; callback(getTypeAtPosition(source, i), getTypeAtPosition(target, i)); } } - function createInferenceContext(signature, flags, baseInferences) { + function createInferenceContext(signature, flags, compareTypes, baseInferences) { var inferences = baseInferences ? ts.map(baseInferences, cloneInferenceInfo) : ts.map(signature.typeParameters, createInferenceInfo); var context = mapper; context.mappedTypes = signature.typeParameters; context.signature = signature; context.inferences = inferences; context.flags = flags; + context.compareTypes = compareTypes || compareTypesAssignable; return context; function mapper(t) { for (var i = 0; i < inferences.length; i++) { @@ -26508,6 +28005,19 @@ var ts; return inference.candidates && getUnionType(inference.candidates, true); } } + function isPossiblyAssignableTo(source, target) { + var properties = getPropertiesOfObjectType(target); + for (var _i = 0, properties_5 = properties; _i < properties_5.length; _i++) { + var targetProp = properties_5[_i]; + if (!(targetProp.flags & (16777216 | 4194304))) { + var sourceProp = getPropertyOfObjectType(source, targetProp.escapedName); + if (!sourceProp) { + return false; + } + } + } + return true; + } function inferTypes(inferences, originalSource, originalTarget, priority) { if (priority === void 0) { priority = 0; } var symbolStack; @@ -26668,15 +28178,17 @@ var ts; return; } } - inferFromProperties(source, target); - inferFromSignatures(source, target, 0); - inferFromSignatures(source, target, 1); - inferFromIndexTypes(source, target); + if (isPossiblyAssignableTo(source, target) || isPossiblyAssignableTo(target, source)) { + inferFromProperties(source, target); + inferFromSignatures(source, target, 0); + inferFromSignatures(source, target, 1); + inferFromIndexTypes(source, target); + } } function inferFromProperties(source, target) { var properties = getPropertiesOfObjectType(target); - for (var _i = 0, properties_5 = properties; _i < properties_5.length; _i++) { - var targetProp = properties_5[_i]; + for (var _i = 0, properties_6 = properties; _i < properties_6.length; _i++) { + var targetProp = properties_6[_i]; var sourceProp = getPropertyOfObjectType(source, targetProp.escapedName); if (sourceProp) { inferFromTypes(getTypeOfSymbol(sourceProp), getTypeOfSymbol(targetProp)); @@ -26775,7 +28287,7 @@ var ts; var constraint = getConstraintOfTypeParameter(context.signature.typeParameters[index]); if (constraint) { var instantiatedConstraint = instantiateType(constraint, context); - if (!isTypeAssignableTo(inferredType, getTypeWithThisArgument(instantiatedConstraint, inferredType))) { + if (!context.compareTypes(inferredType, getTypeWithThisArgument(instantiatedConstraint, inferredType))) { inference.inferredType = inferredType = instantiatedConstraint; } } @@ -26823,16 +28335,6 @@ var ts; } return undefined; } - function getLeftmostIdentifierOrThis(node) { - switch (node.kind) { - case 71: - case 99: - return node; - case 179: - return getLeftmostIdentifierOrThis(node.expression); - } - return undefined; - } function getBindingElementNameText(element) { if (element.parent.kind === 174) { var name = element.propertyName || element.name; @@ -27324,7 +28826,7 @@ var ts; parent.parent.operatorToken.kind === 58 && parent.parent.left === parent && !ts.isAssignmentTarget(parent.parent) && - isTypeAnyOrAllConstituentTypesHaveKind(getTypeOfExpression(parent.argumentExpression), 84 | 2048); + isTypeAssignableToKind(getTypeOfExpression(parent.argumentExpression), 84); return isLengthPushOrUnshift || isElementAssignment; } function maybeTypePredicateCall(node) { @@ -27470,7 +28972,7 @@ var ts; } else { var indexType = getTypeOfExpression(node.left.argumentExpression); - if (isTypeAnyOrAllConstituentTypesHaveKind(indexType, 84 | 2048)) { + if (isTypeAssignableToKind(indexType, 84)) { evolvedType_1 = addEvolvingArrayElementType(evolvedType_1, node.right); } } @@ -28156,7 +29658,7 @@ var ts; break; case 149: case 148: - if (ts.getModifierFlags(container) & 32) { + if (ts.hasModifier(container, 32)) { error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_static_property_initializer); } break; @@ -28247,14 +29749,14 @@ var ts; if (!isCallExpression && container.kind === 152) { checkThisBeforeSuper(node, container, ts.Diagnostics.super_must_be_called_before_accessing_a_property_of_super_in_the_constructor_of_a_derived_class); } - if ((ts.getModifierFlags(container) & 32) || isCallExpression) { + if (ts.hasModifier(container, 32) || isCallExpression) { nodeCheckFlag = 512; } else { nodeCheckFlag = 256; } getNodeLinks(node).flags |= nodeCheckFlag; - if (container.kind === 151 && ts.getModifierFlags(container) & 256) { + if (container.kind === 151 && ts.hasModifier(container, 256)) { if (ts.isSuperProperty(node.parent) && ts.isAssignmentTarget(node.parent)) { getNodeLinks(container).flags |= 4096; } @@ -28299,7 +29801,7 @@ var ts; } else { if (ts.isClassLike(container.parent) || container.parent.kind === 178) { - if (ts.getModifierFlags(container) & 32) { + if (ts.hasModifier(container, 32)) { return container.kind === 151 || container.kind === 150 || container.kind === 153 || @@ -28489,7 +29991,7 @@ var ts; return getReturnTypeOfSignature(getSignatureFromDeclaration(functionDecl)); } var signature = getContextualSignatureForFunctionLikeDeclaration(functionDecl); - if (signature) { + if (signature && !isResolvingReturnTypeOfSignature(signature)) { return getReturnTypeOfSignature(signature); } return undefined; @@ -28593,11 +30095,11 @@ var ts; return undefined; } if (ts.isJsxAttribute(node.parent)) { - return getTypeOfPropertyOfType(attributesType, node.parent.name.escapedText); + return getTypeOfPropertyOfContextualType(attributesType, node.parent.name.escapedText); } else if (node.parent.kind === 249) { var jsxChildrenPropertyName = getJsxElementChildrenPropertyname(); - return jsxChildrenPropertyName && jsxChildrenPropertyName !== "" ? getTypeOfPropertyOfType(attributesType, jsxChildrenPropertyName) : anyType; + return jsxChildrenPropertyName && jsxChildrenPropertyName !== "" ? getTypeOfPropertyOfContextualType(attributesType, jsxChildrenPropertyName) : anyType; } else { return attributesType; @@ -28609,7 +30111,7 @@ var ts; if (!attributesType || isTypeAny(attributesType)) { return undefined; } - return getTypeOfPropertyOfType(attributesType, attribute.name.escapedText); + return getTypeOfPropertyOfContextualType(attributesType, attribute.name.escapedText); } else { return attributesType; @@ -28825,10 +30327,7 @@ var ts; } } function isNumericComputedName(name) { - return isTypeAnyOrAllConstituentTypesHaveKind(checkComputedPropertyName(name), 84); - } - function isTypeAnyOrAllConstituentTypesHaveKind(type, kind) { - return isTypeAny(type) || isTypeOfKind(type, kind); + return isTypeAssignableToKind(checkComputedPropertyName(name), 84); } function isInfinityOrNaNString(name) { return name === "Infinity" || name === "-Infinity" || name === "NaN"; @@ -28840,7 +30339,9 @@ var ts; var links = getNodeLinks(node.expression); if (!links.resolvedType) { links.resolvedType = checkExpression(node.expression); - if (!isTypeAnyOrAllConstituentTypesHaveKind(links.resolvedType, 84 | 262178 | 512)) { + if (links.resolvedType.flags & 6144 || + !isTypeAssignableToKind(links.resolvedType, 262178 | 84 | 512) && + !isTypeAssignableTo(links.resolvedType, getUnionType([stringType, numberType, esSymbolType]))) { error(node, ts.Diagnostics.A_computed_property_name_must_be_of_type_string_number_symbol_or_any); } else { @@ -29325,9 +30826,7 @@ var ts; return undefined; } function resolveCustomJsxElementAttributesType(openingLikeElement, shouldIncludeAllStatelessAttributesType, elementType, elementClassType) { - if (!elementType) { - elementType = checkExpression(openingLikeElement.tagName); - } + if (elementType === void 0) { elementType = checkExpression(openingLikeElement.tagName); } if (elementType.flags & 65536) { var types = elementType.types; return getUnionType(types.map(function (type) { @@ -29422,11 +30921,12 @@ var ts; } function getCustomJsxElementAttributesType(node, shouldIncludeAllStatelessAttributesType) { var links = getNodeLinks(node); - if (!links.resolvedJsxElementAttributesType) { + var linkLocation = shouldIncludeAllStatelessAttributesType ? "resolvedJsxElementAllAttributesType" : "resolvedJsxElementAttributesType"; + if (!links[linkLocation]) { var elemClassType = getJsxGlobalElementClassType(); - return links.resolvedJsxElementAttributesType = resolveCustomJsxElementAttributesType(node, shouldIncludeAllStatelessAttributesType, undefined, elemClassType); + return links[linkLocation] = resolveCustomJsxElementAttributesType(node, shouldIncludeAllStatelessAttributesType, undefined, elemClassType); } - return links.resolvedJsxElementAttributesType; + return links[linkLocation]; } function getAllAttributesTypeFromJsxOpeningLikeElement(node) { if (isJsxIntrinsicIdentifier(node.tagName)) { @@ -29653,9 +31153,12 @@ var ts; } var prop = getPropertyOfType(apparentType, right.escapedText); if (!prop) { - var stringIndexType = getIndexTypeOfType(apparentType, 0); - if (stringIndexType) { - return stringIndexType; + var indexInfo = getIndexInfoOfType(apparentType, 0); + if (indexInfo && indexInfo.type) { + if (indexInfo.isReadonly && (ts.isAssignmentTarget(node) || ts.isDeleteTarget(node))) { + error(node, ts.Diagnostics.Index_signature_in_type_0_only_permits_reading, typeToString(apparentType)); + } + return indexInfo.type; } if (right.escapedText && !checkAndReportErrorForExtendingInterface(node)) { reportNonexistentProperty(right, type.flags & 16384 && type.isThisType ? apparentType : type); @@ -29782,7 +31285,7 @@ var ts; if (prop && noUnusedIdentifiers && (prop.flags & 106500) && - prop.valueDeclaration && (ts.getModifierFlags(prop.valueDeclaration) & 8)) { + prop.valueDeclaration && ts.hasModifier(prop.valueDeclaration, 8)) { if (ts.getCheckFlags(prop) & 1) { getSymbolLinks(prop).target.isReferenced = true; } @@ -30053,8 +31556,8 @@ var ts; } return undefined; } - function instantiateSignatureInContextOf(signature, contextualSignature, contextualMapper) { - var context = createInferenceContext(signature, 1); + function instantiateSignatureInContextOf(signature, contextualSignature, contextualMapper, compareTypes) { + var context = createInferenceContext(signature, 1, compareTypes); forEachMatchingParameterType(contextualSignature, signature, function (source, target) { inferTypes(context.inferences, instantiateType(source, contextualMapper || identityMapper), target); }); @@ -30284,7 +31787,7 @@ var ts; return getLiteralType(element.name.text); case 144: var nameType = checkComputedPropertyName(element.name); - if (isTypeOfKind(nameType, 512)) { + if (isTypeAssignableToKind(nameType, 512)) { return nameType; } else { @@ -30377,9 +31880,10 @@ var ts; return resolveErrorCall(node); } var args = getEffectiveCallArguments(node); + var isSingleNonGenericCandidate = candidates.length === 1 && !candidates[0].typeParameters; var excludeArgument; var excludeCount = 0; - if (!isDecorator) { + if (!isDecorator && !isSingleNonGenericCandidate) { for (var i = isTaggedTemplate ? 1 : 0; i < args.length; i++) { if (isContextSensitive(args[i])) { if (!excludeArgument) { @@ -30471,6 +31975,17 @@ var ts; if (signatureHelpTrailingComma === void 0) { signatureHelpTrailingComma = false; } candidateForArgumentError = undefined; candidateForTypeArgumentError = undefined; + if (isSingleNonGenericCandidate) { + var candidate = candidates[0]; + if (!hasCorrectArity(node, args, candidate, signatureHelpTrailingComma)) { + return undefined; + } + if (!checkApplicableSignature(node, args, candidate, relation, excludeArgument, false)) { + candidateForArgumentError = candidate; + return undefined; + } + return candidate; + } for (var candidateIndex = 0; candidateIndex < candidates.length; candidateIndex++) { var originalCandidate = candidates[candidateIndex]; if (!hasCorrectArity(node, args, originalCandidate, signatureHelpTrailingComma)) { @@ -30601,7 +32116,7 @@ var ts; return resolveErrorCall(node); } var valueDecl = expressionType.symbol && getClassLikeDeclarationOfSymbol(expressionType.symbol); - if (valueDecl && ts.getModifierFlags(valueDecl) & 128) { + if (valueDecl && ts.hasModifier(valueDecl, 128)) { error(node, ts.Diagnostics.Cannot_create_an_instance_of_the_abstract_class_0, ts.declarationNameToString(ts.getNameOfDeclaration(valueDecl))); return resolveErrorCall(node); } @@ -30637,8 +32152,8 @@ var ts; return true; } var declaration = signature.declaration; - var modifiers = ts.getModifierFlags(declaration); - if (!(modifiers & 24)) { + var modifiers = ts.getSelectedModifierFlags(declaration, 24); + if (!modifiers) { return true; } var declaringClassDeclaration = getClassLikeDeclarationOfSymbol(declaration.parent.symbol); @@ -30792,7 +32307,7 @@ var ts; && getSymbolLinks(type.symbol).inferredClassType === type; } function checkCallExpression(node) { - checkGrammarTypeArguments(node, node.typeArguments) || checkGrammarArguments(node, node.arguments); + checkGrammarTypeArguments(node, node.typeArguments) || checkGrammarArguments(node.arguments); var signature = getResolvedSignature(node); if (node.expression.kind === 97) { return voidType; @@ -30825,7 +32340,7 @@ var ts; return getReturnTypeOfSignature(signature); } function checkImportCallExpression(node) { - checkGrammarArguments(node, node.arguments) || checkGrammarImportCallExpression(node); + checkGrammarArguments(node.arguments) || checkGrammarImportCallExpression(node); if (node.arguments.length === 0) { return createPromiseReturnType(node, anyType); } @@ -30841,11 +32356,33 @@ var ts; if (moduleSymbol) { var esModuleSymbol = resolveESModuleSymbol(moduleSymbol, specifier, true); if (esModuleSymbol) { - return createPromiseReturnType(node, getTypeOfSymbol(esModuleSymbol)); + return createPromiseReturnType(node, getTypeWithSyntheticDefaultImportType(getTypeOfSymbol(esModuleSymbol), esModuleSymbol)); } } return createPromiseReturnType(node, anyType); } + function getTypeWithSyntheticDefaultImportType(type, symbol) { + if (allowSyntheticDefaultImports && type && type !== unknownType) { + var synthType = type; + if (!synthType.syntheticType) { + if (!getPropertyOfType(type, "default")) { + var memberTable = ts.createSymbolTable(); + var newSymbol = createSymbol(2097152, "default"); + newSymbol.target = resolveSymbol(symbol); + memberTable.set("default", newSymbol); + var anonymousSymbol = createSymbol(2048, "__type"); + var defaultContainingObject = createAnonymousType(anonymousSymbol, memberTable, ts.emptyArray, ts.emptyArray, undefined, undefined); + anonymousSymbol.type = defaultContainingObject; + synthType.syntheticType = getIntersectionType([type, defaultContainingObject]); + } + else { + synthType.syntheticType = type; + } + } + return synthType.syntheticType; + } + return type; + } function isCommonJsRequire(node) { if (!ts.isRequireCall(node, true)) { return false; @@ -30964,15 +32501,15 @@ var ts; } } } - function assignBindingElementTypes(node) { - if (ts.isBindingPattern(node.name)) { - for (var _i = 0, _a = node.name.elements; _i < _a.length; _i++) { - var element = _a[_i]; - if (!ts.isOmittedExpression(element)) { - if (element.name.kind === 71) { - getSymbolLinks(getSymbolOfNode(element)).type = getTypeForBindingElement(element); - } - assignBindingElementTypes(element); + function assignBindingElementTypes(pattern) { + for (var _i = 0, _a = pattern.elements; _i < _a.length; _i++) { + var element = _a[_i]; + if (!ts.isOmittedExpression(element)) { + if (element.name.kind === 71) { + getSymbolLinks(getSymbolOfNode(element)).type = getTypeForBindingElement(element); + } + else { + assignBindingElementTypes(element.name); } } } @@ -30981,12 +32518,13 @@ var ts; var links = getSymbolLinks(parameter); if (!links.type) { links.type = contextualType; - var name = ts.getNameOfDeclaration(parameter.valueDeclaration); - if (links.type === emptyObjectType && - (name.kind === 174 || name.kind === 175)) { - links.type = getTypeFromBindingPattern(name); + var decl = parameter.valueDeclaration; + if (decl.name.kind !== 71) { + if (links.type === emptyObjectType) { + links.type = getTypeFromBindingPattern(decl.name); + } + assignBindingElementTypes(decl.name); } - assignBindingElementTypes(parameter.valueDeclaration); } } function createPromiseType(promisedType) { @@ -31187,14 +32725,14 @@ var ts; } function checkFunctionExpressionOrObjectLiteralMethod(node, checkMode) { ts.Debug.assert(node.kind !== 151 || ts.isObjectLiteralMethod(node)); - var hasGrammarError = checkGrammarFunctionLikeDeclaration(node); - if (!hasGrammarError && node.kind === 186) { - checkGrammarForGenerator(node); - } if (checkMode === 1 && isContextSensitive(node)) { checkNodeDeferred(node); return anyFunctionType; } + var hasGrammarError = checkGrammarFunctionLikeDeclaration(node); + if (!hasGrammarError && node.kind === 186) { + checkGrammarForGenerator(node); + } var links = getNodeLinks(node); var type = getTypeOfSymbol(node.symbol); if (!(links.flags & 1024)) { @@ -31264,7 +32802,7 @@ var ts; } } function checkArithmeticOperandType(operand, type, diagnostic) { - if (!isTypeAnyOrAllConstituentTypesHaveKind(type, 84)) { + if (!isTypeAssignableToKind(type, 84)) { error(operand, diagnostic); return false; } @@ -31352,8 +32890,13 @@ var ts; if (operandType === silentNeverType) { return silentNeverType; } - if (node.operator === 38 && node.operand.kind === 8) { - return getFreshTypeOfLiteralType(getLiteralType(-node.operand.text)); + if (node.operand.kind === 8) { + if (node.operator === 38) { + return getFreshTypeOfLiteralType(getLiteralType(-node.operand.text)); + } + else if (node.operator === 37) { + return getFreshTypeOfLiteralType(getLiteralType(+node.operand.text)); + } } switch (node.operator) { case 37: @@ -31405,30 +32948,22 @@ var ts; } return false; } - function isTypeOfKind(type, kind) { - if (type.flags & kind) { + function isTypeAssignableToKind(source, kind, strict) { + if (source.flags & kind) { return true; } - if (type.flags & 65536) { - var types = type.types; - for (var _i = 0, types_18 = types; _i < types_18.length; _i++) { - var t = types_18[_i]; - if (!isTypeOfKind(t, kind)) { - return false; - } - } - return true; + if (strict && source.flags & (1 | 1024 | 2048 | 4096)) { + return false; } - if (type.flags & 131072) { - var types = type.types; - for (var _a = 0, types_19 = types; _a < types_19.length; _a++) { - var t = types_19[_a]; - if (isTypeOfKind(t, kind)) { - return true; - } - } - } - return false; + return (kind & 84 && isTypeAssignableTo(source, numberType)) || + (kind & 262178 && isTypeAssignableTo(source, stringType)) || + (kind & 136 && isTypeAssignableTo(source, booleanType)) || + (kind & 1024 && isTypeAssignableTo(source, voidType)) || + (kind & 8192 && isTypeAssignableTo(source, neverType)) || + (kind & 4096 && isTypeAssignableTo(source, nullType)) || + (kind & 2048 && isTypeAssignableTo(source, undefinedType)) || + (kind & 512 && isTypeAssignableTo(source, esSymbolType)) || + (kind & 16777216 && isTypeAssignableTo(source, nonPrimitiveType)); } function isConstEnumObjectType(type) { return getObjectFlags(type) & 16 && type.symbol && isConstEnumSymbol(type.symbol); @@ -31440,7 +32975,7 @@ var ts; if (leftType === silentNeverType || rightType === silentNeverType) { return silentNeverType; } - if (isTypeOfKind(leftType, 8190)) { + if (!isTypeAny(leftType) && isTypeAssignableToKind(leftType, 8190)) { error(left, ts.Diagnostics.The_left_hand_side_of_an_instanceof_expression_must_be_of_type_any_an_object_type_or_a_type_parameter); } if (!(isTypeAny(rightType) || @@ -31457,18 +32992,18 @@ var ts; } leftType = checkNonNullType(leftType, left); rightType = checkNonNullType(rightType, right); - if (!(isTypeComparableTo(leftType, stringType) || isTypeOfKind(leftType, 84 | 512))) { + if (!(isTypeComparableTo(leftType, stringType) || isTypeAssignableToKind(leftType, 84 | 512))) { error(left, ts.Diagnostics.The_left_hand_side_of_an_in_expression_must_be_of_type_any_string_number_or_symbol); } - if (!isTypeAnyOrAllConstituentTypesHaveKind(rightType, 32768 | 540672 | 16777216)) { + if (!isTypeAssignableToKind(rightType, 16777216 | 540672)) { error(right, ts.Diagnostics.The_right_hand_side_of_an_in_expression_must_be_of_type_any_an_object_type_or_a_type_parameter); } return booleanType; } function checkObjectLiteralAssignment(node, sourceType) { var properties = node.properties; - for (var _i = 0, properties_6 = properties; _i < properties_6.length; _i++) { - var p = properties_6[_i]; + for (var _i = 0, properties_7 = properties; _i < properties_7.length; _i++) { + var p = properties_7[_i]; checkObjectLiteralDestructuringPropertyAssignment(sourceType, p, properties); } return sourceType; @@ -31724,24 +33259,22 @@ var ts; if (leftType === silentNeverType || rightType === silentNeverType) { return silentNeverType; } - if (!isTypeOfKind(leftType, 1 | 262178) && !isTypeOfKind(rightType, 1 | 262178)) { + if (!isTypeAssignableToKind(leftType, 262178) && !isTypeAssignableToKind(rightType, 262178)) { leftType = checkNonNullType(leftType, left); rightType = checkNonNullType(rightType, right); } var resultType = void 0; - if (isTypeOfKind(leftType, 84) && isTypeOfKind(rightType, 84)) { + if (isTypeAssignableToKind(leftType, 84, true) && isTypeAssignableToKind(rightType, 84, true)) { resultType = numberType; } - else { - if (isTypeOfKind(leftType, 262178) || isTypeOfKind(rightType, 262178)) { - resultType = stringType; - } - else if (isTypeAny(leftType) || isTypeAny(rightType)) { - resultType = leftType === unknownType || rightType === unknownType ? unknownType : anyType; - } - if (resultType && !checkForDisallowedESSymbolOperand(operator)) { - return resultType; - } + else if (isTypeAssignableToKind(leftType, 262178, true) || isTypeAssignableToKind(rightType, 262178, true)) { + resultType = stringType; + } + else if (isTypeAny(leftType) || isTypeAny(rightType)) { + resultType = leftType === unknownType || rightType === unknownType ? unknownType : anyType; + } + if (resultType && !checkForDisallowedESSymbolOperand(operator)) { + return resultType; } if (!resultType) { reportOperatorError(); @@ -31906,13 +33439,12 @@ var ts; return getBestChoiceType(type1, type2); } function checkLiteralExpression(node) { - if (node.kind === 8) { - checkGrammarNumericLiteral(node); - } switch (node.kind) { + case 13: case 9: return getFreshTypeOfLiteralType(getLiteralType(node.text)); case 8: + checkGrammarNumericLiteral(node); return getFreshTypeOfLiteralType(getLiteralType(+node.text)); case 101: return trueType; @@ -32060,6 +33592,7 @@ var ts; return checkSuperExpression(node); case 95: return nullWideningType; + case 13: case 9: case 8: case 101: @@ -32067,8 +33600,6 @@ var ts; return checkLiteralExpression(node); case 196: return checkTemplateExpression(node); - case 13: - return stringType; case 12: return globalRegExpType; case 177: @@ -32159,7 +33690,7 @@ var ts; checkGrammarDecorators(node) || checkGrammarModifiers(node); checkVariableLikeDeclaration(node); var func = ts.getContainingFunction(node); - if (ts.getModifierFlags(node) & 92) { + if (ts.hasModifier(node, 92)) { func = ts.getContainingFunction(node); if (!(func.kind === 152 && ts.nodeIsPresent(func.body))) { error(node, ts.Diagnostics.A_parameter_property_is_only_allowed_in_a_constructor_implementation); @@ -32329,6 +33860,13 @@ var ts; } } function checkClassForDuplicateDeclarations(node) { + var Declaration; + (function (Declaration) { + Declaration[Declaration["Getter"] = 1] = "Getter"; + Declaration[Declaration["Setter"] = 2] = "Setter"; + Declaration[Declaration["Method"] = 4] = "Method"; + Declaration[Declaration["Property"] = 3] = "Property"; + })(Declaration || (Declaration = {})); var instanceNames = ts.createUnderscoreEscapedMap(); var staticNames = ts.createUnderscoreEscapedMap(); for (var _i = 0, _a = node.members; _i < _a.length; _i++) { @@ -32342,7 +33880,7 @@ var ts; } } else { - var isStatic = ts.getModifierFlags(member) & 32; + var isStatic = ts.hasModifier(member, 32); var names = isStatic ? staticNames : instanceNames; var memberName = member.name && ts.getPropertyNameForPropertyNameNode(member.name); if (memberName) { @@ -32387,7 +33925,7 @@ var ts; for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; var memberNameNode = member.name; - var isStatic = ts.getModifierFlags(member) & 32; + var isStatic = ts.hasModifier(member, 32); if (isStatic && memberNameNode) { var memberName = ts.getPropertyNameForPropertyNameNode(memberNameNode); switch (memberName) { @@ -32475,7 +34013,7 @@ var ts; function checkMethodDeclaration(node) { checkGrammarMethod(node) || checkGrammarComputedPropertyName(node.name); checkFunctionOrMethodDeclaration(node); - if (ts.getModifierFlags(node) & 128 && node.body) { + if (ts.hasModifier(node, 128) && node.body) { error(node, ts.Diagnostics.Method_0_cannot_have_an_implementation_because_it_is_marked_abstract, ts.declarationNameToString(node.name)); } } @@ -32511,17 +34049,9 @@ var ts; } return ts.forEachChild(n, containsSuperCall); } - function markThisReferencesAsErrors(n) { - if (n.kind === 99) { - error(n, ts.Diagnostics.this_cannot_be_referenced_in_current_location); - } - else if (n.kind !== 186 && n.kind !== 228) { - ts.forEachChild(n, markThisReferencesAsErrors); - } - } function isInstancePropertyWithInitializer(n) { return n.kind === 149 && - !(ts.getModifierFlags(n) & 32) && + !ts.hasModifier(n, 32) && !!n.initializer; } var containingClassDecl = node.parent; @@ -32533,8 +34063,8 @@ var ts; if (classExtendsNull) { error(superCall, ts.Diagnostics.A_constructor_cannot_contain_a_super_call_when_its_class_extends_null); } - var superCallShouldBeFirst = ts.forEach(node.parent.members, isInstancePropertyWithInitializer) || - ts.forEach(node.parameters, function (p) { return ts.getModifierFlags(p) & 92; }); + var superCallShouldBeFirst = ts.some(node.parent.members, isInstancePropertyWithInitializer) || + ts.some(node.parameters, function (p) { return ts.hasModifier(p, 92); }); if (superCallShouldBeFirst) { var statements = node.body.statements; var superCallStatement = void 0; @@ -32577,10 +34107,12 @@ var ts; var otherKind = node.kind === 153 ? 154 : 153; var otherAccessor = ts.getDeclarationOfKind(node.symbol, otherKind); if (otherAccessor) { - if ((ts.getModifierFlags(node) & 28) !== (ts.getModifierFlags(otherAccessor) & 28)) { + var nodeFlags = ts.getModifierFlags(node); + var otherFlags = ts.getModifierFlags(otherAccessor); + if ((nodeFlags & 28) !== (otherFlags & 28)) { error(node.name, ts.Diagnostics.Getter_and_setter_accessors_do_not_agree_in_visibility); } - if (ts.hasModifier(node, 128) !== ts.hasModifier(otherAccessor, 128)) { + if ((nodeFlags & 128) !== (otherFlags & 128)) { error(node.name, ts.Diagnostics.Accessors_must_both_be_abstract_or_non_abstract); } checkAccessorDeclarationTypesIdentical(node, otherAccessor, getAnnotatedAccessorType, ts.Diagnostics.get_and_set_accessor_must_have_the_same_type); @@ -32626,7 +34158,7 @@ var ts; function checkTypeReferenceNode(node) { checkGrammarTypeArguments(node, node.typeArguments); if (node.kind === 159 && node.typeName.jsdocDotPos !== undefined && !ts.isInJavaScriptFile(node) && !ts.isInJSDoc(node)) { - grammarErrorAtPos(ts.getSourceFileOfNode(node), node.typeName.jsdocDotPos, 1, ts.Diagnostics.JSDoc_types_can_only_be_used_inside_documentation_comments); + grammarErrorAtPos(node, node.typeName.jsdocDotPos, 1, ts.Diagnostics.JSDoc_types_can_only_be_used_inside_documentation_comments); } var type = getTypeFromTypeReference(node); if (type !== unknownType) { @@ -32634,7 +34166,14 @@ var ts; ts.forEach(node.typeArguments, checkSourceElement); if (produceDiagnostics) { var symbol = getNodeLinks(node).resolvedSymbol; - var typeParameters = symbol.flags & 524288 ? getSymbolLinks(symbol).typeParameters : type.target.localTypeParameters; + if (!symbol) { + error(node, ts.Diagnostics.Type_0_is_not_generic, typeToString(type)); + return; + } + var typeParameters = symbol.flags & 524288 && getSymbolLinks(symbol).typeParameters; + if (!typeParameters && getObjectFlags(type) & 4) { + typeParameters = type.target.localTypeParameters; + } checkTypeArgumentConstraints(typeParameters, node.typeArguments); } } @@ -32677,16 +34216,15 @@ var ts; if (isTypeAssignableTo(indexType, getIndexType(objectType))) { return type; } - if (maybeTypeOfKind(objectType, 540672) && isTypeOfKind(indexType, 84)) { - var constraint = getBaseConstraintOfType(objectType); - if (constraint && getIndexInfoOfType(constraint, 1)) { - return type; - } + if (getIndexInfoOfType(getApparentType(objectType), 1) && isTypeAssignableToKind(indexType, 84)) { + return type; } error(accessNode, ts.Diagnostics.Type_0_cannot_be_used_to_index_type_1, typeToString(indexType), typeToString(objectType)); return type; } function checkIndexedAccessType(node) { + checkSourceElement(node.objectType); + checkSourceElement(node.indexType); checkIndexedAccessIndexType(getTypeFromIndexedAccessTypeNode(node), node); } function checkMappedType(node) { @@ -32697,7 +34235,7 @@ var ts; checkTypeAssignableTo(constraintType, stringType, node.typeParameter.constraint); } function isPrivateWithinAmbient(node) { - return (ts.getModifierFlags(node) & 8) && ts.isInAmbientContext(node); + return ts.hasModifier(node, 8) && ts.isInAmbientContext(node); } function getEffectiveDeclarationFlags(n, flagsToCheck) { var flags = ts.getCombinedModifierFlags(n); @@ -32784,9 +34322,9 @@ var ts; (ts.isComputedPropertyName(node.name) && ts.isComputedPropertyName(subsequentName) || !ts.isComputedPropertyName(node.name) && !ts.isComputedPropertyName(subsequentName) && ts.getEscapedTextOfIdentifierOrLiteral(node.name) === ts.getEscapedTextOfIdentifierOrLiteral(subsequentName))) { var reportError = (node.kind === 151 || node.kind === 150) && - (ts.getModifierFlags(node) & 32) !== (ts.getModifierFlags(subsequentNode) & 32); + ts.hasModifier(node, 32) !== ts.hasModifier(subsequentNode, 32); if (reportError) { - var diagnostic = ts.getModifierFlags(node) & 32 ? ts.Diagnostics.Function_overload_must_be_static : ts.Diagnostics.Function_overload_must_not_be_static; + var diagnostic = ts.hasModifier(node, 32) ? ts.Diagnostics.Function_overload_must_be_static : ts.Diagnostics.Function_overload_must_not_be_static; error(errorNode_1, diagnostic); } return; @@ -32802,7 +34340,7 @@ var ts; error(errorNode, ts.Diagnostics.Constructor_implementation_is_missing); } else { - if (ts.getModifierFlags(node) & 128) { + if (ts.hasModifier(node, 128)) { error(errorNode, ts.Diagnostics.All_declarations_of_an_abstract_method_must_be_consecutive); } else { @@ -32812,8 +34350,8 @@ var ts; } var duplicateFunctionDeclaration = false; var multipleConstructorImplementation = false; - for (var _i = 0, declarations_5 = declarations; _i < declarations_5.length; _i++) { - var current = declarations_5[_i]; + for (var _i = 0, declarations_4 = declarations; _i < declarations_4.length; _i++) { + var current = declarations_4[_i]; var node = current; var inAmbientContext = ts.isInAmbientContext(node); var inAmbientContextOrInterface = node.parent.kind === 230 || node.parent.kind === 163 || inAmbientContext; @@ -32862,7 +34400,7 @@ var ts; }); } if (lastSeenNonAmbientDeclaration && !lastSeenNonAmbientDeclaration.body && - !(ts.getModifierFlags(lastSeenNonAmbientDeclaration) & 128) && !lastSeenNonAmbientDeclaration.questionToken) { + !ts.hasModifier(lastSeenNonAmbientDeclaration, 128) && !lastSeenNonAmbientDeclaration.questionToken) { reportImplementationExpectedError(lastSeenNonAmbientDeclaration); } if (hasOverloads) { @@ -32930,6 +34468,13 @@ var ts; } } } + var DeclarationSpaces; + (function (DeclarationSpaces) { + DeclarationSpaces[DeclarationSpaces["None"] = 0] = "None"; + DeclarationSpaces[DeclarationSpaces["ExportValue"] = 1] = "ExportValue"; + DeclarationSpaces[DeclarationSpaces["ExportType"] = 2] = "ExportType"; + DeclarationSpaces[DeclarationSpaces["ExportNamespace"] = 4] = "ExportNamespace"; + })(DeclarationSpaces || (DeclarationSpaces = {})); function getDeclarationSpaces(d) { switch (d.kind) { case 230: @@ -33264,7 +34809,7 @@ var ts; if (!ts.hasDynamicName(node)) { var symbol = getSymbolOfNode(node); var localSymbol = node.localSymbol || symbol; - var firstDeclaration = ts.find(localSymbol.declarations, function (declaration) { return declaration.kind === node.kind && !ts.isSourceFileJavaScript(ts.getSourceFileOfNode(declaration)); }); + var firstDeclaration = ts.find(localSymbol.declarations, function (declaration) { return declaration.kind === node.kind && !(declaration.flags & 65536); }); if (node === firstDeclaration) { checkFunctionOrConstructorSymbol(localSymbol); } @@ -33399,14 +34944,14 @@ var ts; for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; if (member.kind === 151 || member.kind === 149) { - if (!member.symbol.isReferenced && ts.getModifierFlags(member) & 8) { + if (!member.symbol.isReferenced && ts.hasModifier(member, 8)) { error(member.name, ts.Diagnostics._0_is_declared_but_never_used, ts.unescapeLeadingUnderscores(member.symbol.escapedName)); } } else if (member.kind === 152) { for (var _b = 0, _c = member.parameters; _b < _c.length; _b++) { var parameter = _c[_b]; - if (!parameter.symbol.isReferenced && ts.getModifierFlags(parameter) & 8) { + if (!parameter.symbol.isReferenced && ts.hasModifier(parameter, 8)) { error(parameter.name, ts.Diagnostics.Property_0_is_declared_but_never_used, ts.unescapeLeadingUnderscores(parameter.symbol.escapedName)); } } @@ -33746,7 +35291,7 @@ var ts; 128 | 64 | 32; - return (ts.getModifierFlags(left) & interestingFlags) === (ts.getModifierFlags(right) & interestingFlags); + return ts.getSelectedModifierFlags(left, interestingFlags) === ts.getSelectedModifierFlags(right, interestingFlags); } function checkVariableDeclaration(node) { checkGrammarVariableDeclaration(node); @@ -33876,7 +35421,7 @@ var ts; checkReferenceExpression(varExpr, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_must_be_a_variable_or_a_property_access); } } - if (!isTypeAnyOrAllConstituentTypesHaveKind(rightType, 32768 | 540672 | 16777216)) { + if (!isTypeAssignableToKind(rightType, 16777216 | 540672)) { error(node.expression, ts.Diagnostics.The_right_hand_side_of_a_for_in_statement_must_be_of_type_any_an_object_type_or_a_type_parameter); } checkSourceElement(node.statement); @@ -34248,7 +35793,7 @@ var ts; var classDeclaration = type.symbol.valueDeclaration; for (var _i = 0, _a = classDeclaration.members; _i < _a.length; _i++) { var member = _a[_i]; - if (!(ts.getModifierFlags(member) & 32) && ts.hasDynamicName(member)) { + if (!ts.hasModifier(member, 32) && ts.hasDynamicName(member)) { var propType = getTypeOfSymbol(member.symbol); checkIndexConstraintForProperty(member.symbol, propType, type, declaredStringIndexer, stringIndexType, 0); checkIndexConstraintForProperty(member.symbol, propType, type, declaredNumberIndexer, numberIndexType, 1); @@ -34345,8 +35890,8 @@ var ts; var type = getDeclaredTypeOfSymbol(symbol); if (!areTypeParametersIdentical(declarations, type.localTypeParameters)) { var name = symbolToString(symbol); - for (var _i = 0, declarations_6 = declarations; _i < declarations_6.length; _i++) { - var declaration = declarations_6[_i]; + for (var _i = 0, declarations_5 = declarations; _i < declarations_5.length; _i++) { + var declaration = declarations_5[_i]; error(declaration.name, ts.Diagnostics.All_declarations_of_0_must_have_identical_type_parameters, name); } } @@ -34355,8 +35900,8 @@ var ts; function areTypeParametersIdentical(declarations, typeParameters) { var maxTypeArgumentCount = ts.length(typeParameters); var minTypeArgumentCount = getMinTypeArgumentCount(typeParameters); - for (var _i = 0, declarations_7 = declarations; _i < declarations_7.length; _i++) { - var declaration = declarations_7[_i]; + for (var _i = 0, declarations_6 = declarations; _i < declarations_6.length; _i++) { + var declaration = declarations_6[_i]; var numTypeParameters = ts.length(declaration.typeParameters); if (numTypeParameters < minTypeArgumentCount || numTypeParameters > maxTypeArgumentCount) { return false; @@ -34392,7 +35937,7 @@ var ts; registerForUnusedIdentifiersCheck(node); } function checkClassDeclaration(node) { - if (!node.name && !(ts.getModifierFlags(node) & 512)) { + if (!node.name && !ts.hasModifier(node, 512)) { grammarErrorOnFirstToken(node, ts.Diagnostics.A_class_declaration_without_the_default_modifier_must_have_a_name); } checkClassLikeDeclaration(node); @@ -34485,7 +36030,7 @@ var ts; var signatures = getSignaturesOfType(type, 1); if (signatures.length) { var declaration = signatures[0].declaration; - if (declaration && ts.getModifierFlags(declaration) & 8) { + if (declaration && ts.hasModifier(declaration, 8)) { var typeClassDeclaration = getClassLikeDeclarationOfSymbol(type.symbol); if (!isNodeWithinClass(node, typeClassDeclaration)) { error(node, ts.Diagnostics.Cannot_extend_a_class_0_Class_constructor_is_marked_as_private, getFullyQualifiedName(type.symbol)); @@ -34518,7 +36063,7 @@ var ts; if (derived) { if (derived === base) { var derivedClassDecl = getClassLikeDeclarationOfSymbol(type.symbol); - if (baseDeclarationFlags & 128 && (!derivedClassDecl || !(ts.getModifierFlags(derivedClassDecl) & 128))) { + if (baseDeclarationFlags & 128 && (!derivedClassDecl || !ts.hasModifier(derivedClassDecl, 128))) { if (derivedClassDecl.kind === 199) { error(derivedClassDecl, ts.Diagnostics.Non_abstract_class_expression_does_not_implement_inherited_abstract_member_0_from_class_1, symbolToString(baseProperty), typeToString(baseType)); } @@ -34566,8 +36111,8 @@ var ts; for (var _i = 0, baseTypes_2 = baseTypes; _i < baseTypes_2.length; _i++) { var base = baseTypes_2[_i]; var properties = getPropertiesOfType(getTypeWithThisArgument(base, type.thisType)); - for (var _a = 0, properties_7 = properties; _a < properties_7.length; _a++) { - var prop = properties_7[_a]; + for (var _a = 0, properties_8 = properties; _a < properties_8.length; _a++) { + var prop = properties_8[_a]; var existing = seen.get(prop.escapedName); if (!existing) { seen.set(prop.escapedName, { prop: prop, containingType: base }); @@ -34821,8 +36366,8 @@ var ts; } function getFirstNonAmbientClassOrFunctionDeclaration(symbol) { var declarations = symbol.declarations; - for (var _i = 0, declarations_8 = declarations; _i < declarations_8.length; _i++) { - var declaration = declarations_8[_i]; + for (var _i = 0, declarations_7 = declarations; _i < declarations_7.length; _i++) { + var declaration = declarations_7[_i]; if ((declaration.kind === 229 || (declaration.kind === 228 && ts.nodeIsPresent(declaration.body))) && !ts.isInAmbientContext(declaration)) { @@ -35037,7 +36582,7 @@ var ts; if (checkGrammarModuleElementContext(node, ts.Diagnostics.An_import_declaration_can_only_be_used_in_a_namespace_or_module)) { return; } - if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && ts.getModifierFlags(node) !== 0) { + if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && ts.hasModifiers(node)) { grammarErrorOnFirstToken(node, ts.Diagnostics.An_import_declaration_cannot_have_modifiers); } if (checkExternalImportOrExportDeclaration(node)) { @@ -35064,7 +36609,7 @@ var ts; checkGrammarDecorators(node) || checkGrammarModifiers(node); if (ts.isInternalModuleImportEqualsDeclaration(node) || checkExternalImportOrExportDeclaration(node)) { checkImportBinding(node); - if (ts.getModifierFlags(node) & 1) { + if (ts.hasModifier(node, 1)) { markExportAsReferenced(node); } if (ts.isInternalModuleImportEqualsDeclaration(node)) { @@ -35092,7 +36637,7 @@ var ts; if (checkGrammarModuleElementContext(node, ts.Diagnostics.An_export_declaration_can_only_be_used_in_a_module)) { return; } - if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && ts.getModifierFlags(node) !== 0) { + if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && ts.hasModifiers(node)) { grammarErrorOnFirstToken(node, ts.Diagnostics.An_export_declaration_cannot_have_modifiers); } if (!node.moduleSpecifier || checkExternalImportOrExportDeclaration(node)) { @@ -35150,7 +36695,7 @@ var ts; } return; } - if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && ts.getModifierFlags(node) !== 0) { + if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && ts.hasModifiers(node)) { grammarErrorOnFirstToken(node, ts.Diagnostics.An_export_assignment_cannot_have_modifiers); } if (node.expression.kind === 71) { @@ -35197,8 +36742,8 @@ var ts; return; } if (exportedDeclarationsCount > 1) { - for (var _i = 0, declarations_9 = declarations; _i < declarations_9.length; _i++) { - var declaration = declarations_9[_i]; + for (var _i = 0, declarations_8 = declarations; _i < declarations_8.length; _i++) { + var declaration = declarations_8[_i]; if (isNotOverload(declaration)) { diagnostics.add(ts.createDiagnosticForNode(declaration, ts.Diagnostics.Cannot_redeclare_exported_variable_0, ts.unescapeLeadingUnderscores(id))); } @@ -35476,7 +37021,7 @@ var ts; return []; } var symbols = ts.createSymbolTable(); - var memberFlags = 0; + var isStatic = false; populateSymbols(); return symbolsToArray(symbols); function populateSymbols() { @@ -35498,7 +37043,7 @@ var ts; } case 229: case 230: - if (!(memberFlags & 32)) { + if (!isStatic) { copySymbols(getSymbolOfNode(location).members, meaning & 793064); } break; @@ -35512,7 +37057,7 @@ var ts; if (ts.introducesArgumentsExoticObject(location)) { copySymbol(argumentsSymbol, meaning); } - memberFlags = ts.getModifierFlags(location); + isStatic = ts.hasModifier(location, 32); location = location.parent; } copySymbols(globals, meaning); @@ -35747,12 +37292,7 @@ var ts; case 8: if (node.parent.kind === 180 && node.parent.argumentExpression === node) { var objectType = getTypeOfExpression(node.parent.expression); - if (objectType === unknownType) - return undefined; - var apparentType = getApparentType(objectType); - if (apparentType === unknownType) - return undefined; - return getPropertyOfType(apparentType, node.text); + return getPropertyOfType(objectType, node.text); } break; } @@ -35848,7 +37388,7 @@ var ts; } function getParentTypeOfClassElement(node) { var classSymbol = getSymbolOfNode(node.parent); - return ts.getModifierFlags(node) & 32 + return ts.hasModifier(node, 32) ? getTypeOfSymbol(classSymbol) : getDeclaredTypeOfSymbol(classSymbol); } @@ -36073,13 +37613,13 @@ var ts; return strictNullChecks && !isOptionalParameter(parameter) && parameter.initializer && - !(ts.getModifierFlags(parameter) & 92); + !ts.hasModifier(parameter, 92); } function isOptionalUninitializedParameterProperty(parameter) { return strictNullChecks && isOptionalParameter(parameter) && !parameter.initializer && - !!(ts.getModifierFlags(parameter) & 92); + ts.hasModifier(parameter, 92); } function getNodeCheckFlags(node) { return getNodeLinks(node).flags; @@ -36135,22 +37675,22 @@ var ts; else if (type.flags & 1) { return ts.TypeReferenceSerializationKind.ObjectType; } - else if (isTypeOfKind(type, 1024 | 6144 | 8192)) { + else if (isTypeAssignableToKind(type, 1024 | 6144 | 8192)) { return ts.TypeReferenceSerializationKind.VoidNullableOrNeverType; } - else if (isTypeOfKind(type, 136)) { + else if (isTypeAssignableToKind(type, 136)) { return ts.TypeReferenceSerializationKind.BooleanType; } - else if (isTypeOfKind(type, 84)) { + else if (isTypeAssignableToKind(type, 84)) { return ts.TypeReferenceSerializationKind.NumberLikeType; } - else if (isTypeOfKind(type, 262178)) { + else if (isTypeAssignableToKind(type, 262178)) { return ts.TypeReferenceSerializationKind.StringLikeType; } else if (isTupleType(type)) { return ts.TypeReferenceSerializationKind.ArrayLikeType; } - else if (isTypeOfKind(type, 512)) { + else if (isTypeAssignableToKind(type, 512)) { return ts.TypeReferenceSerializationKind.ESSymbolType; } else if (isFunctionType(type)) { @@ -36615,7 +38155,7 @@ var ts; node.kind !== 154) { return grammarErrorOnNode(modifier, ts.Diagnostics.abstract_modifier_can_only_appear_on_a_class_method_or_property_declaration); } - if (!(node.parent.kind === 229 && ts.getModifierFlags(node.parent) & 128)) { + if (!(node.parent.kind === 229 && ts.hasModifier(node.parent, 128))) { return grammarErrorOnNode(modifier, ts.Diagnostics.Abstract_methods_can_only_appear_within_an_abstract_class); } if (flags & 32) { @@ -36734,8 +38274,7 @@ var ts; if (list && list.hasTrailingComma) { var start = list.end - ",".length; var end = list.end; - var sourceFile = ts.getSourceFileOfNode(list[0]); - return grammarErrorAtPos(sourceFile, start, end - start, ts.Diagnostics.Trailing_comma_not_allowed); + return grammarErrorAtPos(list[0], start, end - start, ts.Diagnostics.Trailing_comma_not_allowed); } } function checkGrammarTypeParameterList(typeParameters, file) { @@ -36811,7 +38350,7 @@ var ts; if (parameter.dotDotDotToken) { return grammarErrorOnNode(parameter.dotDotDotToken, ts.Diagnostics.An_index_signature_cannot_have_a_rest_parameter); } - if (ts.getModifierFlags(parameter) !== 0) { + if (ts.hasModifiers(parameter)) { return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_cannot_have_an_accessibility_modifier); } if (parameter.questionToken) { @@ -36845,19 +38384,18 @@ var ts; return checkGrammarForDisallowedTrailingComma(typeArguments) || checkGrammarForAtLeastOneTypeArgument(node, typeArguments); } - function checkGrammarForOmittedArgument(node, args) { + function checkGrammarForOmittedArgument(args) { if (args) { - var sourceFile = ts.getSourceFileOfNode(node); for (var _i = 0, args_5 = args; _i < args_5.length; _i++) { var arg = args_5[_i]; if (arg.kind === 200) { - return grammarErrorAtPos(sourceFile, arg.pos, 0, ts.Diagnostics.Argument_expression_expected); + return grammarErrorAtPos(arg, arg.pos, 0, ts.Diagnostics.Argument_expression_expected); } } } } - function checkGrammarArguments(node, args) { - return checkGrammarForOmittedArgument(node, args); + function checkGrammarArguments(args) { + return checkGrammarForOmittedArgument(args); } function checkGrammarHeritageClause(node) { var types = node.types; @@ -36866,8 +38404,7 @@ var ts; } if (types && types.length === 0) { var listType = ts.tokenToString(node.token); - var sourceFile = ts.getSourceFileOfNode(node); - return grammarErrorAtPos(sourceFile, types.pos, 0, ts.Diagnostics._0_list_cannot_be_empty, listType); + return grammarErrorAtPos(node, types.pos, 0, ts.Diagnostics._0_list_cannot_be_empty, listType); } return ts.forEach(types, checkGrammarExpressionWithTypeArguments); } @@ -37090,10 +38627,10 @@ var ts; else if (ts.isInAmbientContext(accessor)) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.An_accessor_cannot_be_declared_in_an_ambient_context); } - else if (accessor.body === undefined && !(ts.getModifierFlags(accessor) & 128)) { - return grammarErrorAtPos(ts.getSourceFileOfNode(accessor), accessor.end - 1, ";".length, ts.Diagnostics._0_expected, "{"); + else if (accessor.body === undefined && !ts.hasModifier(accessor, 128)) { + return grammarErrorAtPos(accessor, accessor.end - 1, ";".length, ts.Diagnostics._0_expected, "{"); } - else if (accessor.body && ts.getModifierFlags(accessor) & 128) { + else if (accessor.body && ts.hasModifier(accessor, 128)) { return grammarErrorOnNode(accessor, ts.Diagnostics.An_abstract_accessor_cannot_have_an_implementation); } else if (accessor.typeParameters) { @@ -37146,7 +38683,7 @@ var ts; return true; } else if (node.body === undefined) { - return grammarErrorAtPos(ts.getSourceFileOfNode(node), node.end - 1, ";".length, ts.Diagnostics._0_expected, "{"); + return grammarErrorAtPos(node, node.end - 1, ";".length, ts.Diagnostics._0_expected, "{"); } } if (ts.isClassLike(node.parent)) { @@ -37217,7 +38754,7 @@ var ts; return grammarErrorOnNode(node.name, ts.Diagnostics.A_rest_element_cannot_contain_a_binding_pattern); } if (node.initializer) { - return grammarErrorAtPos(ts.getSourceFileOfNode(node), node.initializer.pos - 1, 1, ts.Diagnostics.A_rest_element_cannot_have_an_initializer); + return grammarErrorAtPos(node, node.initializer.pos - 1, 1, ts.Diagnostics.A_rest_element_cannot_have_an_initializer); } } } @@ -37237,12 +38774,12 @@ var ts; } else { var equalsTokenLength = "=".length; - return grammarErrorAtPos(ts.getSourceFileOfNode(node), node.initializer.pos - equalsTokenLength, equalsTokenLength, ts.Diagnostics.Initializers_are_not_allowed_in_ambient_contexts); + return grammarErrorAtPos(node, node.initializer.pos - equalsTokenLength, equalsTokenLength, ts.Diagnostics.Initializers_are_not_allowed_in_ambient_contexts); } } if (node.initializer && !(ts.isConst(node) && isStringOrNumberLiteralExpression(node.initializer))) { var equalsTokenLength = "=".length; - return grammarErrorAtPos(ts.getSourceFileOfNode(node), node.initializer.pos - equalsTokenLength, equalsTokenLength, ts.Diagnostics.Initializers_are_not_allowed_in_ambient_contexts); + return grammarErrorAtPos(node, node.initializer.pos - equalsTokenLength, equalsTokenLength, ts.Diagnostics.Initializers_are_not_allowed_in_ambient_contexts); } } else if (!node.initializer) { @@ -37299,7 +38836,7 @@ var ts; return true; } if (!declarationList.declarations.length) { - return grammarErrorAtPos(ts.getSourceFileOfNode(declarationList), declarations.pos, declarations.end - declarations.pos, ts.Diagnostics.Variable_declaration_list_cannot_be_empty); + return grammarErrorAtPos(declarationList, declarations.pos, declarations.end - declarations.pos, ts.Diagnostics.Variable_declaration_list_cannot_be_empty); } } function allowLetAndConstDeclarations(parent) { @@ -37345,7 +38882,8 @@ var ts; return true; } } - function grammarErrorAtPos(sourceFile, start, length, message, arg0, arg1, arg2) { + function grammarErrorAtPos(nodeForSourceFile, start, length, message, arg0, arg1, arg2) { + var sourceFile = ts.getSourceFileOfNode(nodeForSourceFile); if (!hasParseDiagnostics(sourceFile)) { diagnostics.add(ts.createFileDiagnostic(sourceFile, start, length, message, arg0, arg1, arg2)); return true; @@ -37360,7 +38898,7 @@ var ts; } function checkGrammarConstructorTypeParameters(node) { if (node.typeParameters) { - return grammarErrorAtPos(ts.getSourceFileOfNode(node), node.typeParameters.pos, node.typeParameters.end - node.typeParameters.pos, ts.Diagnostics.Type_parameters_cannot_appear_on_a_constructor_declaration); + return grammarErrorAtPos(node, node.typeParameters.pos, node.typeParameters.end - node.typeParameters.pos, ts.Diagnostics.Type_parameters_cannot_appear_on_a_constructor_declaration); } } function checkGrammarConstructorTypeAnnotation(node) { @@ -37402,7 +38940,7 @@ var ts; node.kind === 244 || node.kind === 243 || node.kind === 236 || - ts.getModifierFlags(node) & (2 | 1 | 512)) { + ts.hasModifier(node, 2 | 1 | 512)) { return false; } return grammarErrorOnFirstToken(node, ts.Diagnostics.A_declare_modifier_is_required_for_a_top_level_declaration_in_a_d_ts_file); @@ -40171,27 +41709,27 @@ var ts; function createExpressionForAccessorDeclaration(properties, property, receiver, multiLine) { var _a = ts.getAllAccessorDeclarations(properties, property), firstAccessor = _a.firstAccessor, getAccessor = _a.getAccessor, setAccessor = _a.setAccessor; if (property === firstAccessor) { - var properties_8 = []; + var properties_9 = []; if (getAccessor) { var getterFunction = ts.createFunctionExpression(getAccessor.modifiers, undefined, undefined, undefined, getAccessor.parameters, undefined, getAccessor.body); ts.setTextRange(getterFunction, getAccessor); ts.setOriginalNode(getterFunction, getAccessor); var getter = ts.createPropertyAssignment("get", getterFunction); - properties_8.push(getter); + properties_9.push(getter); } if (setAccessor) { var setterFunction = ts.createFunctionExpression(setAccessor.modifiers, undefined, undefined, undefined, setAccessor.parameters, undefined, setAccessor.body); ts.setTextRange(setterFunction, setAccessor); ts.setOriginalNode(setterFunction, setAccessor); var setter = ts.createPropertyAssignment("set", setterFunction); - properties_8.push(setter); + properties_9.push(setter); } - properties_8.push(ts.createPropertyAssignment("enumerable", ts.createTrue())); - properties_8.push(ts.createPropertyAssignment("configurable", ts.createTrue())); + properties_9.push(ts.createPropertyAssignment("enumerable", ts.createTrue())); + properties_9.push(ts.createPropertyAssignment("configurable", ts.createTrue())); var expression = ts.setTextRange(ts.createCall(ts.createPropertyAccess(ts.createIdentifier("Object"), "defineProperty"), undefined, [ receiver, createExpressionForPropertyName(property.name), - ts.createObjectLiteral(properties_8, multiLine) + ts.createObjectLiteral(properties_9, multiLine) ]), firstAccessor); return ts.aggregateTransformFlags(expression); } @@ -40597,6 +42135,13 @@ var ts; return body; } ts.parenthesizeConciseBody = parenthesizeConciseBody; + var OuterExpressionKinds; + (function (OuterExpressionKinds) { + OuterExpressionKinds[OuterExpressionKinds["Parentheses"] = 1] = "Parentheses"; + OuterExpressionKinds[OuterExpressionKinds["Assertions"] = 2] = "Assertions"; + OuterExpressionKinds[OuterExpressionKinds["PartiallyEmittedExpressions"] = 4] = "PartiallyEmittedExpressions"; + OuterExpressionKinds[OuterExpressionKinds["All"] = 7] = "All"; + })(OuterExpressionKinds = ts.OuterExpressionKinds || (ts.OuterExpressionKinds = {})); function isOuterExpression(node, kinds) { if (kinds === void 0) { kinds = 7; } switch (node.kind) { @@ -41929,6 +43474,11 @@ var ts; })(ts || (ts = {})); var ts; (function (ts) { + var FlattenLevel; + (function (FlattenLevel) { + FlattenLevel[FlattenLevel["All"] = 0] = "All"; + FlattenLevel[FlattenLevel["ObjectRest"] = 1] = "ObjectRest"; + })(FlattenLevel = ts.FlattenLevel || (ts.FlattenLevel = {})); function flattenDestructuringAssignment(node, visitor, context, level, needsValue, createAssignmentCallback) { var location = node; var value; @@ -42119,7 +43669,8 @@ var ts; ? undefined : numElements, location), false, location); } - else if (numElements !== 1 && (flattenContext.level < 1 || numElements === 0)) { + else if (numElements !== 1 && (flattenContext.level < 1 || numElements === 0) + || ts.every(elements, ts.isOmittedExpression)) { var reuseIdentifierExpressions = !ts.isDeclarationBindingElement(parent) || numElements !== 0; value = ensureIdentifier(flattenContext, value, reuseIdentifierExpressions, location); } @@ -42248,6 +43799,28 @@ var ts; var ts; (function (ts) { var USE_NEW_TYPE_METADATA_FORMAT = false; + var TypeScriptSubstitutionFlags; + (function (TypeScriptSubstitutionFlags) { + TypeScriptSubstitutionFlags[TypeScriptSubstitutionFlags["ClassAliases"] = 1] = "ClassAliases"; + TypeScriptSubstitutionFlags[TypeScriptSubstitutionFlags["NamespaceExports"] = 2] = "NamespaceExports"; + TypeScriptSubstitutionFlags[TypeScriptSubstitutionFlags["NonQualifiedEnumMembers"] = 8] = "NonQualifiedEnumMembers"; + })(TypeScriptSubstitutionFlags || (TypeScriptSubstitutionFlags = {})); + var ClassFacts; + (function (ClassFacts) { + ClassFacts[ClassFacts["None"] = 0] = "None"; + ClassFacts[ClassFacts["HasStaticInitializedProperties"] = 1] = "HasStaticInitializedProperties"; + ClassFacts[ClassFacts["HasConstructorDecorators"] = 2] = "HasConstructorDecorators"; + ClassFacts[ClassFacts["HasMemberDecorators"] = 4] = "HasMemberDecorators"; + ClassFacts[ClassFacts["IsExportOfNamespace"] = 8] = "IsExportOfNamespace"; + ClassFacts[ClassFacts["IsNamedExternalExport"] = 16] = "IsNamedExternalExport"; + ClassFacts[ClassFacts["IsDefaultExternalExport"] = 32] = "IsDefaultExternalExport"; + ClassFacts[ClassFacts["HasExtendsClause"] = 64] = "HasExtendsClause"; + ClassFacts[ClassFacts["UseImmediatelyInvokedFunctionExpression"] = 128] = "UseImmediatelyInvokedFunctionExpression"; + ClassFacts[ClassFacts["HasAnyDecorators"] = 6] = "HasAnyDecorators"; + ClassFacts[ClassFacts["NeedsName"] = 5] = "NeedsName"; + ClassFacts[ClassFacts["MayNeedImmediatelyInvokedFunctionExpression"] = 7] = "MayNeedImmediatelyInvokedFunctionExpression"; + ClassFacts[ClassFacts["IsExported"] = 56] = "IsExported"; + })(ClassFacts || (ClassFacts = {})); function transformTypeScript(context) { var startLexicalEnvironment = context.startLexicalEnvironment, resumeLexicalEnvironment = context.resumeLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment, hoistVariableDeclaration = context.hoistVariableDeclaration; var resolver = context.getEmitResolver(); @@ -42304,7 +43877,12 @@ var ts; if (ts.hasModifier(node, 2)) { break; } - recordEmittedDeclarationInScope(node); + if (node.name) { + recordEmittedDeclarationInScope(node); + } + else { + ts.Debug.assert(node.kind === 229 || ts.hasModifier(node, 512)); + } break; } } @@ -42718,8 +44296,8 @@ var ts; && member.initializer !== undefined; } function addInitializedPropertyStatements(statements, properties, receiver) { - for (var _i = 0, properties_9 = properties; _i < properties_9.length; _i++) { - var property = properties_9[_i]; + for (var _i = 0, properties_10 = properties; _i < properties_10.length; _i++) { + var property = properties_10[_i]; var statement = ts.createStatement(transformInitializedProperty(property, receiver)); ts.setSourceMapRange(statement, ts.moveRangePastModifiers(property)); ts.setCommentRange(statement, property); @@ -42728,8 +44306,8 @@ var ts; } function generateInitializedPropertyExpressions(properties, receiver) { var expressions = []; - for (var _i = 0, properties_10 = properties; _i < properties_10.length; _i++) { - var property = properties_10[_i]; + for (var _i = 0, properties_11 = properties; _i < properties_11.length; _i++) { + var property = properties_11[_i]; var expression = transformInitializedProperty(property, receiver); expression.startsOnNewLine = true; ts.setSourceMapRange(expression, ts.moveRangePastModifiers(property)); @@ -43424,24 +45002,24 @@ var ts; && moduleKind !== ts.ModuleKind.System); } function recordEmittedDeclarationInScope(node) { - var name = node.symbol && node.symbol.escapedName; - if (name) { - if (!currentScopeFirstDeclarationsOfName) { - currentScopeFirstDeclarationsOfName = ts.createUnderscoreEscapedMap(); - } - if (!currentScopeFirstDeclarationsOfName.has(name)) { - currentScopeFirstDeclarationsOfName.set(name, node); - } + if (!currentScopeFirstDeclarationsOfName) { + currentScopeFirstDeclarationsOfName = ts.createUnderscoreEscapedMap(); + } + var name = declaredNameInScope(node); + if (!currentScopeFirstDeclarationsOfName.has(name)) { + currentScopeFirstDeclarationsOfName.set(name, node); } } function isFirstEmittedDeclarationInScope(node) { if (currentScopeFirstDeclarationsOfName) { - var name = node.symbol && node.symbol.escapedName; - if (name) { - return currentScopeFirstDeclarationsOfName.get(name) === node; - } + var name = declaredNameInScope(node); + return currentScopeFirstDeclarationsOfName.get(name) === node; } - return false; + return true; + } + function declaredNameInScope(node) { + ts.Debug.assertNode(node.name, ts.isIdentifier); + return node.name.escapedText; } function addVarForEnumOrModuleDeclaration(statements, node) { var statement = ts.createVariableStatement(ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), ts.createVariableDeclarationList([ @@ -43472,7 +45050,7 @@ var ts; if (!shouldEmitModuleDeclaration(node)) { return ts.createNotEmittedStatement(node); } - ts.Debug.assert(ts.isIdentifier(node.name), "TypeScript module should have an Identifier name."); + ts.Debug.assertNode(node.name, ts.isIdentifier, "A TypeScript namespace should have an Identifier name."); enableSubstitutionForNamespaceExports(); var statements = []; var emitFlags = 2; @@ -43871,6 +45449,10 @@ var ts; })(ts || (ts = {})); var ts; (function (ts) { + var ES2017SubstitutionFlags; + (function (ES2017SubstitutionFlags) { + ES2017SubstitutionFlags[ES2017SubstitutionFlags["AsyncMethodsWithSuper"] = 1] = "AsyncMethodsWithSuper"; + })(ES2017SubstitutionFlags || (ES2017SubstitutionFlags = {})); function transformES2017(context) { var startLexicalEnvironment = context.startLexicalEnvironment, resumeLexicalEnvironment = context.resumeLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment; var resolver = context.getEmitResolver(); @@ -44112,6 +45694,10 @@ var ts; })(ts || (ts = {})); var ts; (function (ts) { + var ESNextSubstitutionFlags; + (function (ESNextSubstitutionFlags) { + ESNextSubstitutionFlags[ESNextSubstitutionFlags["AsyncMethodsWithSuper"] = 1] = "AsyncMethodsWithSuper"; + })(ESNextSubstitutionFlags || (ESNextSubstitutionFlags = {})); function transformESNext(context) { var resumeLexicalEnvironment = context.resumeLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment, hoistVariableDeclaration = context.hoistVariableDeclaration; var resolver = context.getEmitResolver(); @@ -44188,6 +45774,8 @@ var ts; return visitExpressionStatement(node); case 185: return visitParenthesizedExpression(node, noDestructuringValue); + case 260: + return visitCatchClause(node); default: return ts.visitEachChild(node, visitor, context); } @@ -44262,6 +45850,12 @@ var ts; function visitParenthesizedExpression(node, noDestructuringValue) { return ts.visitEachChild(node, noDestructuringValue ? visitorNoDestructuringValue : visitor, context); } + function visitCatchClause(node) { + if (!node.variableDeclaration) { + return ts.updateCatchClause(node, ts.createVariableDeclaration(ts.createTempVariable(undefined)), ts.visitNode(node.block, visitor, ts.isBlock)); + } + return ts.visitEachChild(node, visitor, context); + } function visitBinaryExpression(node, noDestructuringValue) { if (ts.isDestructuringAssignment(node) && node.left.transformFlags & 1048576) { return ts.flattenDestructuringAssignment(node, visitor, context, 1, !noDestructuringValue); @@ -44708,7 +46302,7 @@ var ts; objectProperties = ts.createAssignHelper(context, segments); } } - var element = ts.createExpressionForJsxElement(context.getEmitResolver().getJsxFactoryEntity(), compilerOptions.reactNamespace, tagName, objectProperties, ts.filter(ts.map(children, transformJsxChildToExpression), ts.isDefined), node, location); + var element = ts.createExpressionForJsxElement(context.getEmitResolver().getJsxFactoryEntity(), compilerOptions.reactNamespace, tagName, objectProperties, ts.mapDefined(children, transformJsxChildToExpression), node, location); if (isChild) { ts.startOnNewLine(element); } @@ -45137,6 +46731,75 @@ var ts; })(ts || (ts = {})); var ts; (function (ts) { + var ES2015SubstitutionFlags; + (function (ES2015SubstitutionFlags) { + ES2015SubstitutionFlags[ES2015SubstitutionFlags["CapturedThis"] = 1] = "CapturedThis"; + ES2015SubstitutionFlags[ES2015SubstitutionFlags["BlockScopedBindings"] = 2] = "BlockScopedBindings"; + })(ES2015SubstitutionFlags || (ES2015SubstitutionFlags = {})); + var CopyDirection; + (function (CopyDirection) { + CopyDirection[CopyDirection["ToOriginal"] = 0] = "ToOriginal"; + CopyDirection[CopyDirection["ToOutParameter"] = 1] = "ToOutParameter"; + })(CopyDirection || (CopyDirection = {})); + var Jump; + (function (Jump) { + Jump[Jump["Break"] = 2] = "Break"; + Jump[Jump["Continue"] = 4] = "Continue"; + Jump[Jump["Return"] = 8] = "Return"; + })(Jump || (Jump = {})); + var SuperCaptureResult; + (function (SuperCaptureResult) { + SuperCaptureResult[SuperCaptureResult["NoReplacement"] = 0] = "NoReplacement"; + SuperCaptureResult[SuperCaptureResult["ReplaceSuperCapture"] = 1] = "ReplaceSuperCapture"; + SuperCaptureResult[SuperCaptureResult["ReplaceWithReturn"] = 2] = "ReplaceWithReturn"; + })(SuperCaptureResult || (SuperCaptureResult = {})); + var HierarchyFacts; + (function (HierarchyFacts) { + HierarchyFacts[HierarchyFacts["None"] = 0] = "None"; + HierarchyFacts[HierarchyFacts["Function"] = 1] = "Function"; + HierarchyFacts[HierarchyFacts["ArrowFunction"] = 2] = "ArrowFunction"; + HierarchyFacts[HierarchyFacts["AsyncFunctionBody"] = 4] = "AsyncFunctionBody"; + HierarchyFacts[HierarchyFacts["NonStaticClassElement"] = 8] = "NonStaticClassElement"; + HierarchyFacts[HierarchyFacts["CapturesThis"] = 16] = "CapturesThis"; + HierarchyFacts[HierarchyFacts["ExportedVariableStatement"] = 32] = "ExportedVariableStatement"; + HierarchyFacts[HierarchyFacts["TopLevel"] = 64] = "TopLevel"; + HierarchyFacts[HierarchyFacts["Block"] = 128] = "Block"; + HierarchyFacts[HierarchyFacts["IterationStatement"] = 256] = "IterationStatement"; + HierarchyFacts[HierarchyFacts["IterationStatementBlock"] = 512] = "IterationStatementBlock"; + HierarchyFacts[HierarchyFacts["ForStatement"] = 1024] = "ForStatement"; + HierarchyFacts[HierarchyFacts["ForInOrForOfStatement"] = 2048] = "ForInOrForOfStatement"; + HierarchyFacts[HierarchyFacts["ConstructorWithCapturedSuper"] = 4096] = "ConstructorWithCapturedSuper"; + HierarchyFacts[HierarchyFacts["ComputedPropertyName"] = 8192] = "ComputedPropertyName"; + HierarchyFacts[HierarchyFacts["AncestorFactsMask"] = 16383] = "AncestorFactsMask"; + HierarchyFacts[HierarchyFacts["BlockScopeIncludes"] = 0] = "BlockScopeIncludes"; + HierarchyFacts[HierarchyFacts["BlockScopeExcludes"] = 4032] = "BlockScopeExcludes"; + HierarchyFacts[HierarchyFacts["SourceFileIncludes"] = 64] = "SourceFileIncludes"; + HierarchyFacts[HierarchyFacts["SourceFileExcludes"] = 3968] = "SourceFileExcludes"; + HierarchyFacts[HierarchyFacts["FunctionIncludes"] = 65] = "FunctionIncludes"; + HierarchyFacts[HierarchyFacts["FunctionExcludes"] = 16286] = "FunctionExcludes"; + HierarchyFacts[HierarchyFacts["AsyncFunctionBodyIncludes"] = 69] = "AsyncFunctionBodyIncludes"; + HierarchyFacts[HierarchyFacts["AsyncFunctionBodyExcludes"] = 16278] = "AsyncFunctionBodyExcludes"; + HierarchyFacts[HierarchyFacts["ArrowFunctionIncludes"] = 66] = "ArrowFunctionIncludes"; + HierarchyFacts[HierarchyFacts["ArrowFunctionExcludes"] = 16256] = "ArrowFunctionExcludes"; + HierarchyFacts[HierarchyFacts["ConstructorIncludes"] = 73] = "ConstructorIncludes"; + HierarchyFacts[HierarchyFacts["ConstructorExcludes"] = 16278] = "ConstructorExcludes"; + HierarchyFacts[HierarchyFacts["DoOrWhileStatementIncludes"] = 256] = "DoOrWhileStatementIncludes"; + HierarchyFacts[HierarchyFacts["DoOrWhileStatementExcludes"] = 0] = "DoOrWhileStatementExcludes"; + HierarchyFacts[HierarchyFacts["ForStatementIncludes"] = 1280] = "ForStatementIncludes"; + HierarchyFacts[HierarchyFacts["ForStatementExcludes"] = 3008] = "ForStatementExcludes"; + HierarchyFacts[HierarchyFacts["ForInOrForOfStatementIncludes"] = 2304] = "ForInOrForOfStatementIncludes"; + HierarchyFacts[HierarchyFacts["ForInOrForOfStatementExcludes"] = 1984] = "ForInOrForOfStatementExcludes"; + HierarchyFacts[HierarchyFacts["BlockIncludes"] = 128] = "BlockIncludes"; + HierarchyFacts[HierarchyFacts["BlockExcludes"] = 3904] = "BlockExcludes"; + HierarchyFacts[HierarchyFacts["IterationStatementBlockIncludes"] = 512] = "IterationStatementBlockIncludes"; + HierarchyFacts[HierarchyFacts["IterationStatementBlockExcludes"] = 4032] = "IterationStatementBlockExcludes"; + HierarchyFacts[HierarchyFacts["ComputedPropertyNameIncludes"] = 8192] = "ComputedPropertyNameIncludes"; + HierarchyFacts[HierarchyFacts["ComputedPropertyNameExcludes"] = 0] = "ComputedPropertyNameExcludes"; + HierarchyFacts[HierarchyFacts["NewTarget"] = 16384] = "NewTarget"; + HierarchyFacts[HierarchyFacts["NewTargetInComputedPropertyName"] = 32768] = "NewTargetInComputedPropertyName"; + HierarchyFacts[HierarchyFacts["SubtreeFactsMask"] = -16384] = "SubtreeFactsMask"; + HierarchyFacts[HierarchyFacts["PropagateNewTargetMask"] = 49152] = "PropagateNewTargetMask"; + })(HierarchyFacts || (HierarchyFacts = {})); function transformES2015(context) { var startLexicalEnvironment = context.startLexicalEnvironment, resumeLexicalEnvironment = context.resumeLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment, hoistVariableDeclaration = context.hoistVariableDeclaration; var compilerOptions = context.getCompilerOptions(); @@ -45226,7 +46889,7 @@ var ts; function shouldVisitNode(node) { return (node.transformFlags & 128) !== 0 || convertedLoopState !== undefined - || (hierarchyFacts & 4096 && ts.isStatement(node)) + || (hierarchyFacts & 4096 && (ts.isStatement(node) || (node.kind === 207))) || (ts.isIterationStatement(node, false) && shouldConvertIterationStatementBody(node)) || isTypeScriptClassWrapper(node); } @@ -45506,9 +47169,11 @@ var ts; var outer = ts.createPartiallyEmittedExpression(inner); outer.end = ts.skipTrivia(currentText, node.pos); ts.setEmitFlags(outer, 1536); - return ts.createParen(ts.createCall(outer, undefined, extendsClauseElement + var result = ts.createParen(ts.createCall(outer, undefined, extendsClauseElement ? [ts.visitNode(extendsClauseElement.expression, visitor, ts.isExpression)] : [])); + ts.addSyntheticLeadingComment(result, 3, "* @class "); + return result; } function transformClassBody(node, extendsClauseElement) { var statements = []; @@ -46093,11 +47758,12 @@ var ts; ts.setTextRange(declarationList, node); ts.setCommentRange(declarationList, node); if (node.transformFlags & 8388608 - && (ts.isBindingPattern(node.declarations[0].name) - || ts.isBindingPattern(ts.lastOrUndefined(node.declarations).name))) { + && (ts.isBindingPattern(node.declarations[0].name) || ts.isBindingPattern(ts.lastOrUndefined(node.declarations).name))) { var firstDeclaration = ts.firstOrUndefined(declarations); - var lastDeclaration = ts.lastOrUndefined(declarations); - ts.setSourceMapRange(declarationList, ts.createRange(firstDeclaration.pos, lastDeclaration.end)); + if (firstDeclaration) { + var lastDeclaration = ts.lastOrUndefined(declarations); + ts.setSourceMapRange(declarationList, ts.createRange(firstDeclaration.pos, lastDeclaration.end)); + } } return declarationList; } @@ -46636,6 +48302,7 @@ var ts; function visitCatchClause(node) { var ancestorFacts = enterSubtree(4032, 0); var updated; + ts.Debug.assert(!!node.variableDeclaration, "Catch clause variable should always be present when downleveling ES2015."); if (ts.isBindingPattern(node.variableDeclaration.name)) { var temp = ts.createTempVariable(undefined); var newVariableDeclaration = ts.createVariableDeclaration(temp); @@ -47142,6 +48809,51 @@ var ts; })(ts || (ts = {})); var ts; (function (ts) { + var OpCode; + (function (OpCode) { + OpCode[OpCode["Nop"] = 0] = "Nop"; + OpCode[OpCode["Statement"] = 1] = "Statement"; + OpCode[OpCode["Assign"] = 2] = "Assign"; + OpCode[OpCode["Break"] = 3] = "Break"; + OpCode[OpCode["BreakWhenTrue"] = 4] = "BreakWhenTrue"; + OpCode[OpCode["BreakWhenFalse"] = 5] = "BreakWhenFalse"; + OpCode[OpCode["Yield"] = 6] = "Yield"; + OpCode[OpCode["YieldStar"] = 7] = "YieldStar"; + OpCode[OpCode["Return"] = 8] = "Return"; + OpCode[OpCode["Throw"] = 9] = "Throw"; + OpCode[OpCode["Endfinally"] = 10] = "Endfinally"; + })(OpCode || (OpCode = {})); + var BlockAction; + (function (BlockAction) { + BlockAction[BlockAction["Open"] = 0] = "Open"; + BlockAction[BlockAction["Close"] = 1] = "Close"; + })(BlockAction || (BlockAction = {})); + var CodeBlockKind; + (function (CodeBlockKind) { + CodeBlockKind[CodeBlockKind["Exception"] = 0] = "Exception"; + CodeBlockKind[CodeBlockKind["With"] = 1] = "With"; + CodeBlockKind[CodeBlockKind["Switch"] = 2] = "Switch"; + CodeBlockKind[CodeBlockKind["Loop"] = 3] = "Loop"; + CodeBlockKind[CodeBlockKind["Labeled"] = 4] = "Labeled"; + })(CodeBlockKind || (CodeBlockKind = {})); + var ExceptionBlockState; + (function (ExceptionBlockState) { + ExceptionBlockState[ExceptionBlockState["Try"] = 0] = "Try"; + ExceptionBlockState[ExceptionBlockState["Catch"] = 1] = "Catch"; + ExceptionBlockState[ExceptionBlockState["Finally"] = 2] = "Finally"; + ExceptionBlockState[ExceptionBlockState["Done"] = 3] = "Done"; + })(ExceptionBlockState || (ExceptionBlockState = {})); + var Instruction; + (function (Instruction) { + Instruction[Instruction["Next"] = 0] = "Next"; + Instruction[Instruction["Throw"] = 1] = "Throw"; + Instruction[Instruction["Return"] = 2] = "Return"; + Instruction[Instruction["Break"] = 3] = "Break"; + Instruction[Instruction["Yield"] = 4] = "Yield"; + Instruction[Instruction["YieldStar"] = 5] = "YieldStar"; + Instruction[Instruction["Catch"] = 6] = "Catch"; + Instruction[Instruction["Endfinally"] = 7] = "Endfinally"; + })(Instruction || (Instruction = {})); function getInstructionName(instruction) { switch (instruction) { case 2: return "return"; @@ -47908,8 +49620,12 @@ var ts; } function transformAndEmitContinueStatement(node) { var label = findContinueTarget(node.label ? ts.unescapeLeadingUnderscores(node.label.escapedText) : undefined); - ts.Debug.assert(label > 0, "Expected continue statment to point to a valid Label."); - emitBreak(label, node); + if (label > 0) { + emitBreak(label, node); + } + else { + emitStatement(node); + } } function visitContinueStatement(node) { if (inStatementContainingYield) { @@ -47922,8 +49638,12 @@ var ts; } function transformAndEmitBreakStatement(node) { var label = findBreakTarget(node.label ? ts.unescapeLeadingUnderscores(node.label.escapedText) : undefined); - ts.Debug.assert(label > 0, "Expected break statment to point to a valid Label."); - emitBreak(label, node); + if (label > 0) { + emitBreak(label, node); + } + else { + emitStatement(node); + } } function visitBreakStatement(node) { if (inStatementContainingYield) { @@ -48180,9 +49900,6 @@ var ts; var block = endBlock(); markLabel(block.endLabel); } - function isWithBlock(block) { - return block.kind === 1; - } function beginExceptionBlock() { var startLabel = defineLabel(); var endLabel = defineLabel(); @@ -48251,9 +49968,6 @@ var ts; emitNop(); exception.state = 3; } - function isExceptionBlock(block) { - return block.kind === 0; - } function beginScriptLoopBlock() { beginBlock({ kind: 3, @@ -48353,43 +50067,45 @@ var ts; return false; } function findBreakTarget(labelText) { - ts.Debug.assert(blocks !== undefined); - if (labelText) { - for (var i = blockStack.length - 1; i >= 0; i--) { - var block = blockStack[i]; - if (supportsLabeledBreakOrContinue(block) && block.labelText === labelText) { - return block.breakLabel; - } - else if (supportsUnlabeledBreak(block) && hasImmediateContainingLabeledBlock(labelText, i - 1)) { - return block.breakLabel; + if (blockStack) { + if (labelText) { + for (var i = blockStack.length - 1; i >= 0; i--) { + var block = blockStack[i]; + if (supportsLabeledBreakOrContinue(block) && block.labelText === labelText) { + return block.breakLabel; + } + else if (supportsUnlabeledBreak(block) && hasImmediateContainingLabeledBlock(labelText, i - 1)) { + return block.breakLabel; + } } } - } - else { - for (var i = blockStack.length - 1; i >= 0; i--) { - var block = blockStack[i]; - if (supportsUnlabeledBreak(block)) { - return block.breakLabel; + else { + for (var i = blockStack.length - 1; i >= 0; i--) { + var block = blockStack[i]; + if (supportsUnlabeledBreak(block)) { + return block.breakLabel; + } } } } return 0; } function findContinueTarget(labelText) { - ts.Debug.assert(blocks !== undefined); - if (labelText) { - for (var i = blockStack.length - 1; i >= 0; i--) { - var block = blockStack[i]; - if (supportsUnlabeledContinue(block) && hasImmediateContainingLabeledBlock(labelText, i - 1)) { - return block.continueLabel; + if (blockStack) { + if (labelText) { + for (var i = blockStack.length - 1; i >= 0; i--) { + var block = blockStack[i]; + if (supportsUnlabeledContinue(block) && hasImmediateContainingLabeledBlock(labelText, i - 1)) { + return block.continueLabel; + } } } - } - else { - for (var i = blockStack.length - 1; i >= 0; i--) { - var block = blockStack[i]; - if (supportsUnlabeledContinue(block)) { - return block.continueLabel; + else { + for (var i = blockStack.length - 1; i >= 0; i--) { + var block = blockStack[i]; + if (supportsUnlabeledContinue(block)) { + return block.continueLabel; + } } } } @@ -48417,7 +50133,7 @@ var ts; return literal; } function createInlineBreak(label, location) { - ts.Debug.assert(label > 0, "Invalid label: " + label); + ts.Debug.assertLessThan(0, label, "Invalid label"); return ts.setTextRange(ts.createReturn(ts.createArrayLiteral([ createInstruction(3), createLabel(label) @@ -48625,31 +50341,33 @@ var ts; for (; blockIndex < blockActions.length && blockOffsets[blockIndex] <= operationIndex; blockIndex++) { var block = blocks[blockIndex]; var blockAction = blockActions[blockIndex]; - if (isExceptionBlock(block)) { - if (blockAction === 0) { - if (!exceptionBlockStack) { - exceptionBlockStack = []; + switch (block.kind) { + case 0: + if (blockAction === 0) { + if (!exceptionBlockStack) { + exceptionBlockStack = []; + } + if (!statements) { + statements = []; + } + exceptionBlockStack.push(currentExceptionBlock); + currentExceptionBlock = block; } - if (!statements) { - statements = []; + else if (blockAction === 1) { + currentExceptionBlock = exceptionBlockStack.pop(); } - exceptionBlockStack.push(currentExceptionBlock); - currentExceptionBlock = block; - } - else if (blockAction === 1) { - currentExceptionBlock = exceptionBlockStack.pop(); - } - } - else if (isWithBlock(block)) { - if (blockAction === 0) { - if (!withBlockStack) { - withBlockStack = []; + break; + case 1: + if (blockAction === 0) { + if (!withBlockStack) { + withBlockStack = []; + } + withBlockStack.push(block); } - withBlockStack.push(block); - } - else if (blockAction === 1) { - withBlockStack.pop(); - } + else if (blockAction === 1) { + withBlockStack.pop(); + } + break; } } } @@ -50403,6 +52121,18 @@ var ts; return ts.transformModule; } } + var TransformationState; + (function (TransformationState) { + TransformationState[TransformationState["Uninitialized"] = 0] = "Uninitialized"; + TransformationState[TransformationState["Initialized"] = 1] = "Initialized"; + TransformationState[TransformationState["Completed"] = 2] = "Completed"; + TransformationState[TransformationState["Disposed"] = 3] = "Disposed"; + })(TransformationState || (TransformationState = {})); + var SyntaxKindFeatureFlags; + (function (SyntaxKindFeatureFlags) { + SyntaxKindFeatureFlags[SyntaxKindFeatureFlags["Substitution"] = 1] = "Substitution"; + SyntaxKindFeatureFlags[SyntaxKindFeatureFlags["EmitNotifications"] = 2] = "EmitNotifications"; + })(SyntaxKindFeatureFlags || (SyntaxKindFeatureFlags = {})); function getTransformers(compilerOptions, customTransformers) { var jsx = compilerOptions.jsx; var languageVersion = ts.getEmitScriptTarget(compilerOptions); @@ -51150,14 +52880,14 @@ var ts; writer.writeLine(); } } - function emitTrailingCommentsOfPosition(pos) { + function emitTrailingCommentsOfPosition(pos, prefixSpace) { if (disabled) { return; } if (extendedDiagnostics) { ts.performance.mark("beforeEmitTrailingCommentsOfPosition"); } - forEachTrailingCommentToEmit(pos, emitTrailingCommentOfPosition); + forEachTrailingCommentToEmit(pos, prefixSpace ? emitTrailingComment : emitTrailingCommentOfPosition); if (extendedDiagnostics) { ts.performance.measure("commentTime", "beforeEmitTrailingCommentsOfPosition"); } @@ -51237,15 +52967,7 @@ var ts; emitPos(commentEnd); } function isTripleSlashComment(commentPos, commentEnd) { - if (currentText.charCodeAt(commentPos + 1) === 47 && - commentPos + 2 < commentEnd && - currentText.charCodeAt(commentPos + 2) === 47) { - var textSubStr = currentText.substring(commentPos, commentEnd); - return textSubStr.match(ts.fullTripleSlashReferencePathRegEx) || - textSubStr.match(ts.fullTripleSlashAMDReferencePathRegEx) ? - true : false; - } - return false; + return ts.isRecognizedTripleSlashComment(currentText, commentPos, commentEnd); } } ts.createCommentWriter = createCommentWriter; @@ -51498,7 +53220,6 @@ var ts; errorNameNode = declaration.name; var format = 4 | 16384 | - 2048 | (shouldUseResolverType ? 8192 : 0); resolver.writeTypeOfDeclaration(declaration, enclosingDeclaration, format, writer); errorNameNode = undefined; @@ -51512,7 +53233,7 @@ var ts; } else { errorNameNode = signature.name; - resolver.writeReturnTypeOfSignatureDeclaration(signature, enclosingDeclaration, 4 | 2048 | 16384, writer); + resolver.writeReturnTypeOfSignatureDeclaration(signature, enclosingDeclaration, 4 | 16384, writer); errorNameNode = undefined; } } @@ -51742,7 +53463,7 @@ var ts; write(tempVarName); write(": "); writer.getSymbolAccessibilityDiagnostic = function () { return diagnostic; }; - resolver.writeTypeOfExpression(expr, enclosingDeclaration, 4 | 2048 | 16384, writer); + resolver.writeTypeOfExpression(expr, enclosingDeclaration, 4 | 16384, writer); write(";"); writeLine(); return tempVarName; @@ -52379,6 +54100,9 @@ var ts; return ts.forEach(node.declarationList.declarations, function (varDeclaration) { return resolver.isDeclarationVisible(varDeclaration); }); } function writeVariableStatement(node) { + if (ts.every(node.declarationList && node.declarationList.declarations, function (decl) { return decl.name && ts.isEmptyBindingPattern(decl.name); })) { + return; + } emitJsDocComments(node); emitModuleElementDeclarationFlags(node); if (ts.isLet(node.declarationList)) { @@ -53757,7 +55481,9 @@ var ts; if (!(ts.getEmitFlags(node) & 131072)) { var dotRangeStart = node.expression.end; var dotRangeEnd = ts.skipTrivia(currentSourceFile.text, node.expression.end) + 1; - var dotToken = { kind: 23, pos: dotRangeStart, end: dotRangeEnd }; + var dotToken = ts.createToken(23); + dotToken.pos = dotRangeStart; + dotToken.end = dotRangeEnd; indentBeforeDot = needsIndentation(node, node.expression, dotToken); indentAfterDot = needsIndentation(node, dotToken, node.name); } @@ -53869,7 +55595,9 @@ var ts; var indentAfterOperator = needsIndentation(node, node.operatorToken, node.right); emitExpression(node.left); increaseIndentIf(indentBeforeOperator, isCommaOperator ? " " : undefined); + emitLeadingCommentsOfPosition(node.operatorToken.pos); writeTokenNode(node.operatorToken); + emitTrailingCommentsOfPosition(node.operatorToken.end, true); increaseIndentIf(indentAfterOperator, " "); emitExpression(node.right); decreaseIndentIf(indentBeforeOperator, indentAfterOperator); @@ -54056,8 +55784,19 @@ var ts; emitWithPrefix(" ", node.label); write(";"); } + function emitTokenWithComment(token, pos, contextNode) { + var node = contextNode && ts.getParseTreeNode(contextNode); + if (node && node.kind === contextNode.kind) { + pos = ts.skipTrivia(currentSourceFile.text, pos); + } + pos = writeToken(token, pos, contextNode); + if (node && node.kind === contextNode.kind) { + emitTrailingCommentsOfPosition(pos, true); + } + return pos; + } function emitReturnStatement(node) { - writeToken(96, node.pos, node); + emitTokenWithComment(96, node.pos, node); emitExpressionWithPrefix(" ", node.expression); write(";"); } @@ -54498,10 +56237,12 @@ var ts; function emitCatchClause(node) { var openParenPos = writeToken(74, node.pos); write(" "); - writeToken(19, openParenPos); - emit(node.variableDeclaration); - writeToken(20, node.variableDeclaration ? node.variableDeclaration.end : openParenPos); - write(" "); + if (node.variableDeclaration) { + writeToken(19, openParenPos); + emit(node.variableDeclaration); + writeToken(20, node.variableDeclaration.end); + write(" "); + } emit(node.block); } function emitPropertyAssignment(node) { @@ -55187,6 +56928,76 @@ var ts; function getClosingBracket(format) { return brackets[format & 7680][1]; } + var TempFlags; + (function (TempFlags) { + TempFlags[TempFlags["Auto"] = 0] = "Auto"; + TempFlags[TempFlags["CountMask"] = 268435455] = "CountMask"; + TempFlags[TempFlags["_i"] = 268435456] = "_i"; + })(TempFlags || (TempFlags = {})); + var ListFormat; + (function (ListFormat) { + ListFormat[ListFormat["None"] = 0] = "None"; + ListFormat[ListFormat["SingleLine"] = 0] = "SingleLine"; + ListFormat[ListFormat["MultiLine"] = 1] = "MultiLine"; + ListFormat[ListFormat["PreserveLines"] = 2] = "PreserveLines"; + ListFormat[ListFormat["LinesMask"] = 3] = "LinesMask"; + ListFormat[ListFormat["NotDelimited"] = 0] = "NotDelimited"; + ListFormat[ListFormat["BarDelimited"] = 4] = "BarDelimited"; + ListFormat[ListFormat["AmpersandDelimited"] = 8] = "AmpersandDelimited"; + ListFormat[ListFormat["CommaDelimited"] = 16] = "CommaDelimited"; + ListFormat[ListFormat["DelimitersMask"] = 28] = "DelimitersMask"; + ListFormat[ListFormat["AllowTrailingComma"] = 32] = "AllowTrailingComma"; + ListFormat[ListFormat["Indented"] = 64] = "Indented"; + ListFormat[ListFormat["SpaceBetweenBraces"] = 128] = "SpaceBetweenBraces"; + ListFormat[ListFormat["SpaceBetweenSiblings"] = 256] = "SpaceBetweenSiblings"; + ListFormat[ListFormat["Braces"] = 512] = "Braces"; + ListFormat[ListFormat["Parenthesis"] = 1024] = "Parenthesis"; + ListFormat[ListFormat["AngleBrackets"] = 2048] = "AngleBrackets"; + ListFormat[ListFormat["SquareBrackets"] = 4096] = "SquareBrackets"; + ListFormat[ListFormat["BracketsMask"] = 7680] = "BracketsMask"; + ListFormat[ListFormat["OptionalIfUndefined"] = 8192] = "OptionalIfUndefined"; + ListFormat[ListFormat["OptionalIfEmpty"] = 16384] = "OptionalIfEmpty"; + ListFormat[ListFormat["Optional"] = 24576] = "Optional"; + ListFormat[ListFormat["PreferNewLine"] = 32768] = "PreferNewLine"; + ListFormat[ListFormat["NoTrailingNewLine"] = 65536] = "NoTrailingNewLine"; + ListFormat[ListFormat["NoInterveningComments"] = 131072] = "NoInterveningComments"; + ListFormat[ListFormat["Modifiers"] = 131328] = "Modifiers"; + ListFormat[ListFormat["HeritageClauses"] = 256] = "HeritageClauses"; + ListFormat[ListFormat["SingleLineTypeLiteralMembers"] = 448] = "SingleLineTypeLiteralMembers"; + ListFormat[ListFormat["MultiLineTypeLiteralMembers"] = 65] = "MultiLineTypeLiteralMembers"; + ListFormat[ListFormat["TupleTypeElements"] = 336] = "TupleTypeElements"; + ListFormat[ListFormat["UnionTypeConstituents"] = 260] = "UnionTypeConstituents"; + ListFormat[ListFormat["IntersectionTypeConstituents"] = 264] = "IntersectionTypeConstituents"; + ListFormat[ListFormat["ObjectBindingPatternElements"] = 432] = "ObjectBindingPatternElements"; + ListFormat[ListFormat["ArrayBindingPatternElements"] = 304] = "ArrayBindingPatternElements"; + ListFormat[ListFormat["ObjectLiteralExpressionProperties"] = 978] = "ObjectLiteralExpressionProperties"; + ListFormat[ListFormat["ArrayLiteralExpressionElements"] = 4466] = "ArrayLiteralExpressionElements"; + ListFormat[ListFormat["CommaListElements"] = 272] = "CommaListElements"; + ListFormat[ListFormat["CallExpressionArguments"] = 1296] = "CallExpressionArguments"; + ListFormat[ListFormat["NewExpressionArguments"] = 9488] = "NewExpressionArguments"; + ListFormat[ListFormat["TemplateExpressionSpans"] = 131072] = "TemplateExpressionSpans"; + ListFormat[ListFormat["SingleLineBlockStatements"] = 384] = "SingleLineBlockStatements"; + ListFormat[ListFormat["MultiLineBlockStatements"] = 65] = "MultiLineBlockStatements"; + ListFormat[ListFormat["VariableDeclarationList"] = 272] = "VariableDeclarationList"; + ListFormat[ListFormat["SingleLineFunctionBodyStatements"] = 384] = "SingleLineFunctionBodyStatements"; + ListFormat[ListFormat["MultiLineFunctionBodyStatements"] = 1] = "MultiLineFunctionBodyStatements"; + ListFormat[ListFormat["ClassHeritageClauses"] = 256] = "ClassHeritageClauses"; + ListFormat[ListFormat["ClassMembers"] = 65] = "ClassMembers"; + ListFormat[ListFormat["InterfaceMembers"] = 65] = "InterfaceMembers"; + ListFormat[ListFormat["EnumMembers"] = 81] = "EnumMembers"; + ListFormat[ListFormat["CaseBlockClauses"] = 65] = "CaseBlockClauses"; + ListFormat[ListFormat["NamedImportsOrExportsElements"] = 432] = "NamedImportsOrExportsElements"; + ListFormat[ListFormat["JsxElementChildren"] = 131072] = "JsxElementChildren"; + ListFormat[ListFormat["JsxElementAttributes"] = 131328] = "JsxElementAttributes"; + ListFormat[ListFormat["CaseOrDefaultClauseStatements"] = 81985] = "CaseOrDefaultClauseStatements"; + ListFormat[ListFormat["HeritageClauseTypes"] = 272] = "HeritageClauseTypes"; + ListFormat[ListFormat["SourceFileStatements"] = 65537] = "SourceFileStatements"; + ListFormat[ListFormat["Decorators"] = 24577] = "Decorators"; + ListFormat[ListFormat["TypeArguments"] = 26960] = "TypeArguments"; + ListFormat[ListFormat["TypeParameters"] = 26960] = "TypeParameters"; + ListFormat[ListFormat["Parameters"] = 1360] = "Parameters"; + ListFormat[ListFormat["IndexSignatureParameters"] = 4432] = "IndexSignatureParameters"; + })(ListFormat || (ListFormat = {})); })(ts || (ts = {})); var ts; (function (ts) { @@ -55543,6 +57354,9 @@ var ts; var loader_2 = function (typesRef, containingFile) { return ts.resolveTypeReferenceDirective(typesRef, containingFile, options, host).resolvedTypeReferenceDirective; }; resolveTypeReferenceDirectiveNamesWorker = function (typeReferenceDirectiveNames, containingFile) { return loadWithLocalCache(checkAllDefined(typeReferenceDirectiveNames), containingFile, loader_2); }; } + var packageIdToSourceFile = ts.createMap(); + var sourceFileToPackageName = ts.createMap(); + var redirectTargetsSet = ts.createMap(); var filesByName = ts.createMap(); var filesByNameIgnoreCase = host.useCaseSensitiveFileNames() ? ts.createMap() : undefined; var structuralIsReused = tryReuseStructureFromOldProgram(); @@ -55599,6 +57413,8 @@ var ts; isSourceFileFromExternalLibrary: isSourceFileFromExternalLibrary, dropDiagnosticsProducingTypeChecker: dropDiagnosticsProducingTypeChecker, getSourceFileFromReference: getSourceFileFromReference, + sourceFileToPackageName: sourceFileToPackageName, + redirectTargetsSet: redirectTargetsSet, }; verifyCompilerOptions(); ts.performance.mark("afterProgram"); @@ -55742,17 +57558,51 @@ var ts; var filePaths = []; var modifiedSourceFiles = []; oldProgram.structureIsReused = 2; - for (var _i = 0, _a = oldProgram.getSourceFiles(); _i < _a.length; _i++) { - var oldSourceFile = _a[_i]; + var oldSourceFiles = oldProgram.getSourceFiles(); + var SeenPackageName; + (function (SeenPackageName) { + SeenPackageName[SeenPackageName["Exists"] = 0] = "Exists"; + SeenPackageName[SeenPackageName["Modified"] = 1] = "Modified"; + })(SeenPackageName || (SeenPackageName = {})); + var seenPackageNames = ts.createMap(); + for (var _i = 0, oldSourceFiles_1 = oldSourceFiles; _i < oldSourceFiles_1.length; _i++) { + var oldSourceFile = oldSourceFiles_1[_i]; var newSourceFile = host.getSourceFileByPath ? host.getSourceFileByPath(oldSourceFile.fileName, oldSourceFile.path, options.target) : host.getSourceFile(oldSourceFile.fileName, options.target); if (!newSourceFile) { return oldProgram.structureIsReused = 0; } + ts.Debug.assert(!newSourceFile.redirectInfo, "Host should not return a redirect source file from `getSourceFile`"); + var fileChanged = void 0; + if (oldSourceFile.redirectInfo) { + if (newSourceFile !== oldSourceFile.redirectInfo.unredirected) { + return oldProgram.structureIsReused = 0; + } + fileChanged = false; + newSourceFile = oldSourceFile; + } + else if (oldProgram.redirectTargetsSet.has(oldSourceFile.path)) { + if (newSourceFile !== oldSourceFile) { + return oldProgram.structureIsReused = 0; + } + fileChanged = false; + } + else { + fileChanged = newSourceFile !== oldSourceFile; + } newSourceFile.path = oldSourceFile.path; filePaths.push(newSourceFile.path); - if (oldSourceFile !== newSourceFile) { + var packageName = oldProgram.sourceFileToPackageName.get(oldSourceFile.path); + if (packageName !== undefined) { + var prevKind = seenPackageNames.get(packageName); + var newKind = fileChanged ? 1 : 0; + if ((prevKind !== undefined && newKind === 1) || prevKind === 1) { + return oldProgram.structureIsReused = 0; + } + seenPackageNames.set(packageName, newKind); + } + if (fileChanged) { if (oldSourceFile.hasNoDefaultLib !== newSourceFile.hasNoDefaultLib) { oldProgram.structureIsReused = 1; } @@ -55780,8 +57630,8 @@ var ts; return oldProgram.structureIsReused; } modifiedFilePaths = modifiedSourceFiles.map(function (f) { return f.newFile.path; }); - for (var _b = 0, modifiedSourceFiles_1 = modifiedSourceFiles; _b < modifiedSourceFiles_1.length; _b++) { - var _c = modifiedSourceFiles_1[_b], oldSourceFile = _c.oldFile, newSourceFile = _c.newFile; + for (var _a = 0, modifiedSourceFiles_1 = modifiedSourceFiles; _a < modifiedSourceFiles_1.length; _a++) { + var _b = modifiedSourceFiles_1[_a], oldSourceFile = _b.oldFile, newSourceFile = _b.newFile; var newSourceFilePath = ts.getNormalizedAbsolutePath(newSourceFile.fileName, currentDirectory); if (resolveModuleNamesWorker) { var moduleNames = ts.map(ts.concatenate(newSourceFile.imports, newSourceFile.moduleAugmentations), getTextOfLiteral); @@ -55815,8 +57665,8 @@ var ts; if (oldProgram.getMissingFilePaths().some(function (missingFilePath) { return host.fileExists(missingFilePath); })) { return oldProgram.structureIsReused = 1; } - for (var _d = 0, _e = oldProgram.getMissingFilePaths(); _d < _e.length; _d++) { - var p = _e[_d]; + for (var _c = 0, _d = oldProgram.getMissingFilePaths(); _c < _d.length; _c++) { + var p = _d[_c]; filesByName.set(p, undefined); } for (var i = 0; i < newSourceFiles.length; i++) { @@ -55824,11 +57674,13 @@ var ts; } files = newSourceFiles; fileProcessingDiagnostics = oldProgram.getFileProcessingDiagnostics(); - for (var _f = 0, modifiedSourceFiles_2 = modifiedSourceFiles; _f < modifiedSourceFiles_2.length; _f++) { - var modifiedFile = modifiedSourceFiles_2[_f]; + for (var _e = 0, modifiedSourceFiles_2 = modifiedSourceFiles; _e < modifiedSourceFiles_2.length; _e++) { + var modifiedFile = modifiedSourceFiles_2[_e]; fileProcessingDiagnostics.reattachFileDiagnostics(modifiedFile.newFile); } resolvedTypeReferenceDirectives = oldProgram.getResolvedTypeReferenceDirectives(); + sourceFileToPackageName = oldProgram.sourceFileToPackageName; + redirectTargetsSet = oldProgram.redirectTargetsSet; return oldProgram.structureIsReused = 2; } function getEmitHost(writeFileCallback) { @@ -56307,7 +58159,7 @@ var ts; } } function processSourceFile(fileName, isDefaultLib, refFile, refPos, refEnd) { - getSourceFileFromReferenceWorker(fileName, function (fileName) { return findSourceFile(fileName, toPath(fileName), isDefaultLib, refFile, refPos, refEnd); }, function (diagnostic) { + getSourceFileFromReferenceWorker(fileName, function (fileName) { return findSourceFile(fileName, toPath(fileName), isDefaultLib, refFile, refPos, refEnd, undefined); }, function (diagnostic) { var args = []; for (var _i = 1; _i < arguments.length; _i++) { args[_i - 1] = arguments[_i]; @@ -56324,7 +58176,24 @@ var ts; fileProcessingDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.File_name_0_differs_from_already_included_file_name_1_only_in_casing, fileName, existingFileName)); } } - function findSourceFile(fileName, path, isDefaultLib, refFile, refPos, refEnd) { + function createRedirectSourceFile(redirectTarget, unredirected, fileName, path) { + var redirect = Object.create(redirectTarget); + redirect.fileName = fileName; + redirect.path = path; + redirect.redirectInfo = { redirectTarget: redirectTarget, unredirected: unredirected }; + Object.defineProperties(redirect, { + id: { + get: function () { return this.redirectInfo.redirectTarget.id; }, + set: function (value) { this.redirectInfo.redirectTarget.id = value; }, + }, + symbol: { + get: function () { return this.redirectInfo.redirectTarget.symbol; }, + set: function (value) { this.redirectInfo.redirectTarget.symbol = value; }, + }, + }); + return redirect; + } + function findSourceFile(fileName, path, isDefaultLib, refFile, refPos, refEnd, packageId) { if (filesByName.has(path)) { var file_1 = filesByName.get(path); if (file_1 && options.forceConsistentCasingInFileNames && ts.getNormalizedAbsolutePath(file_1.fileName, currentDirectory) !== ts.getNormalizedAbsolutePath(fileName, currentDirectory)) { @@ -56355,6 +58224,22 @@ var ts; fileProcessingDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_read_file_0_Colon_1, fileName, hostErrorMessage)); } }); + if (packageId) { + var packageIdKey = packageId.name + "@" + packageId.version; + var fileFromPackageId = packageIdToSourceFile.get(packageIdKey); + if (fileFromPackageId) { + var dupFile = createRedirectSourceFile(fileFromPackageId, file, fileName, path); + redirectTargetsSet.set(fileFromPackageId.path, true); + filesByName.set(path, dupFile); + sourceFileToPackageName.set(path, packageId.name); + files.push(dupFile); + return dupFile; + } + else if (file) { + packageIdToSourceFile.set(packageIdKey, file); + sourceFileToPackageName.set(path, packageId.name); + } + } filesByName.set(path, file); if (file) { sourceFilesFoundSearchingNodeModules.set(path, currentNodeModulesDepth > 0); @@ -56476,7 +58361,7 @@ var ts; else if (shouldAddFile) { var path = toPath(resolvedFileName); var pos = ts.skipTrivia(file.text, file.imports[i].pos); - findSourceFile(resolvedFileName, path, false, file, pos, file.imports[i].end); + findSourceFile(resolvedFileName, path, false, file, pos, file.imports[i].end, resolution.packageId); } if (isFromNodeModulesSearch) { currentNodeModulesDepth--; @@ -57155,6 +59040,12 @@ var ts; category: ts.Diagnostics.Module_Resolution_Options, description: ts.Diagnostics.Allow_default_imports_from_modules_with_no_default_export_This_does_not_affect_code_emit_just_typechecking }, + { + name: "preserveSymlinks", + type: "boolean", + category: ts.Diagnostics.Module_Resolution_Options, + description: ts.Diagnostics.Do_not_resolve_the_real_path_of_symlinks, + }, { name: "sourceRoot", type: "string", @@ -57766,7 +59657,7 @@ var ts; var text = valueExpression.text; if (option && typeof option.type !== "string") { var customOption = option; - if (!customOption.type.has(text)) { + if (!customOption.type.has(text.toLowerCase())) { errors.push(createDiagnosticForInvalidCustomType(customOption, function (message, arg0, arg1) { return ts.createDiagnosticForNodeInSourceFile(sourceFile, valueExpression, message, arg0, arg1); })); } } @@ -58017,12 +59908,10 @@ var ts; } } else { - var specs = includeSpecs ? [] : ["node_modules", "bower_components", "jspm_packages"]; var outDir = raw["compilerOptions"] && raw["compilerOptions"]["outDir"]; if (outDir) { - specs.push(outDir); + excludeSpecs = [outDir]; } - excludeSpecs = specs; } if (fileNames === undefined && includeSpecs === undefined) { includeSpecs = ["**/*"]; @@ -58273,7 +60162,7 @@ var ts; return value; } else if (typeof option.type !== "string") { - return option.type.get(value); + return option.type.get(typeof value === "string" ? value.toLowerCase() : value); } return normalizeNonListOptionValue(option, basePath, value); } @@ -58348,23 +60237,13 @@ var ts; }; } function validateSpecs(specs, errors, allowTrailingRecursion, jsonSourceFile, specKey) { - var validSpecs = []; - for (var _i = 0, specs_1 = specs; _i < specs_1.length; _i++) { - var spec = specs_1[_i]; - if (!allowTrailingRecursion && invalidTrailingRecursionPattern.test(spec)) { - errors.push(createDiagnostic(ts.Diagnostics.File_specification_cannot_end_in_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0, spec)); + return specs.filter(function (spec) { + var diag = specToDiagnostic(spec, allowTrailingRecursion); + if (diag !== undefined) { + errors.push(createDiagnostic(diag, spec)); } - else if (invalidMultipleRecursionPatterns.test(spec)) { - errors.push(createDiagnostic(ts.Diagnostics.File_specification_cannot_contain_multiple_recursive_directory_wildcards_Asterisk_Asterisk_Colon_0, spec)); - } - else if (invalidDotDotAfterRecursiveWildcardPattern.test(spec)) { - errors.push(createDiagnostic(ts.Diagnostics.File_specification_cannot_contain_a_parent_directory_that_appears_after_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0, spec)); - } - else { - validSpecs.push(spec); - } - } - return validSpecs; + return diag === undefined; + }); function createDiagnostic(message, spec) { if (jsonSourceFile && jsonSourceFile.jsonObject) { for (var _i = 0, _a = ts.getPropertyAssignment(jsonSourceFile.jsonObject, specKey); _i < _a.length; _i++) { @@ -58382,6 +60261,17 @@ var ts; return ts.createCompilerDiagnostic(message, spec); } } + function specToDiagnostic(spec, allowTrailingRecursion) { + if (!allowTrailingRecursion && invalidTrailingRecursionPattern.test(spec)) { + return ts.Diagnostics.File_specification_cannot_end_in_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0; + } + else if (invalidMultipleRecursionPatterns.test(spec)) { + return ts.Diagnostics.File_specification_cannot_contain_multiple_recursive_directory_wildcards_Asterisk_Asterisk_Colon_0; + } + else if (invalidDotDotAfterRecursiveWildcardPattern.test(spec)) { + return ts.Diagnostics.File_specification_cannot_contain_a_parent_directory_that_appears_after_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0; + } + } function getWildcardDirectories(include, exclude, path, useCaseSensitiveFileNames) { var rawExcludeRegex = ts.getRegularExpressionForWildcard(exclude, path, "exclude"); var excludeRegex = rawExcludeRegex && new RegExp(rawExcludeRegex, useCaseSensitiveFileNames ? "" : "i"); @@ -59004,6 +60894,7 @@ var ts; return; } })(ts || (ts = {})); +ts.setStackTraceLimit(); if (ts.Debug.isDebugging) { ts.Debug.enableDebugInfo(); } @@ -59011,3 +60902,5 @@ if (ts.sys.tryEnableSourceMapsForHost && /^development$/i.test(ts.sys.getEnviron ts.sys.tryEnableSourceMapsForHost(); } ts.executeCommandLine(ts.sys.args); + +//# sourceMappingURL=tsc.js.map diff --git a/lib/tsserver.js b/lib/tsserver.js index e5ab8924285..c18f6507caa 100644 --- a/lib/tsserver.js +++ b/lib/tsserver.js @@ -508,11 +508,11 @@ var ts; TypeFormatFlags[TypeFormatFlags["UseFullyQualifiedType"] = 256] = "UseFullyQualifiedType"; TypeFormatFlags[TypeFormatFlags["InFirstTypeArgument"] = 512] = "InFirstTypeArgument"; TypeFormatFlags[TypeFormatFlags["InTypeAlias"] = 1024] = "InTypeAlias"; - TypeFormatFlags[TypeFormatFlags["UseTypeAliasValue"] = 2048] = "UseTypeAliasValue"; TypeFormatFlags[TypeFormatFlags["SuppressAnyReturnType"] = 4096] = "SuppressAnyReturnType"; TypeFormatFlags[TypeFormatFlags["AddUndefined"] = 8192] = "AddUndefined"; TypeFormatFlags[TypeFormatFlags["WriteClassExpressionAsTypeLiteral"] = 16384] = "WriteClassExpressionAsTypeLiteral"; TypeFormatFlags[TypeFormatFlags["InArrayType"] = 32768] = "InArrayType"; + TypeFormatFlags[TypeFormatFlags["UseAliasDefinedOutsideCurrentScope"] = 65536] = "UseAliasDefinedOutsideCurrentScope"; })(TypeFormatFlags = ts.TypeFormatFlags || (ts.TypeFormatFlags = {})); var SymbolFormatFlags; (function (SymbolFormatFlags) { @@ -759,6 +759,12 @@ var ts; InferenceFlags[InferenceFlags["NoDefault"] = 2] = "NoDefault"; InferenceFlags[InferenceFlags["AnyDefault"] = 4] = "AnyDefault"; })(InferenceFlags = ts.InferenceFlags || (ts.InferenceFlags = {})); + var Ternary; + (function (Ternary) { + Ternary[Ternary["False"] = 0] = "False"; + Ternary[Ternary["Maybe"] = 1] = "Maybe"; + Ternary[Ternary["True"] = -1] = "True"; + })(Ternary = ts.Ternary || (ts.Ternary = {})); var SpecialPropertyAssignmentKind; (function (SpecialPropertyAssignmentKind) { SpecialPropertyAssignmentKind[SpecialPropertyAssignmentKind["None"] = 0] = "None"; @@ -1155,16 +1161,10 @@ var ts; })(ts || (ts = {})); var ts; (function (ts) { - ts.versionMajorMinor = "2.5"; + ts.versionMajorMinor = "2.6"; ts.version = ts.versionMajorMinor + ".0"; })(ts || (ts = {})); (function (ts) { - var Ternary; - (function (Ternary) { - Ternary[Ternary["False"] = 0] = "False"; - Ternary[Ternary["Maybe"] = 1] = "Maybe"; - Ternary[Ternary["True"] = -1] = "True"; - })(Ternary = ts.Ternary || (ts.Ternary = {})); ts.collator = typeof Intl === "object" && typeof Intl.Collator === "function" ? new Intl.Collator(undefined, { usage: "sort", sensitivity: "accent" }) : undefined; ts.localeCompareIsCorrect = ts.collator && ts.collator.compare("a", "B") < 0; function createDictionaryObject() { @@ -1452,10 +1452,9 @@ var ts; ts.removeWhere = removeWhere; function filterMutate(array, f) { var outIndex = 0; - for (var _i = 0, array_3 = array; _i < array_3.length; _i++) { - var item = array_3[_i]; - if (f(item)) { - array[outIndex] = item; + for (var i = 0; i < array.length; i++) { + if (f(array[i], i, array)) { + array[outIndex] = array[i]; outIndex++; } } @@ -1501,8 +1500,8 @@ var ts; var result; if (array) { result = []; - for (var _i = 0, array_4 = array; _i < array_4.length; _i++) { - var v = array_4[_i]; + for (var _i = 0, array_3 = array; _i < array_3.length; _i++) { + var v = array_3[_i]; if (v) { if (isArray(v)) { addRange(result, v); @@ -1572,11 +1571,13 @@ var ts; ts.sameFlatMap = sameFlatMap; function mapDefined(array, mapFn) { var result = []; - for (var i = 0; i < array.length; i++) { - var item = array[i]; - var mapped = mapFn(item, i); - if (mapped !== undefined) { - result.push(mapped); + if (array) { + for (var i = 0; i < array.length; i++) { + var item = array[i]; + var mapped = mapFn(item, i); + if (mapped !== undefined) { + result.push(mapped); + } } } return result; @@ -1644,8 +1645,8 @@ var ts; function some(array, predicate) { if (array) { if (predicate) { - for (var _i = 0, array_5 = array; _i < array_5.length; _i++) { - var v = array_5[_i]; + for (var _i = 0, array_4 = array; _i < array_4.length; _i++) { + var v = array_4[_i]; if (predicate(v)) { return true; } @@ -1670,8 +1671,8 @@ var ts; var result; if (array) { result = []; - loop: for (var _i = 0, array_6 = array; _i < array_6.length; _i++) { - var item = array_6[_i]; + loop: for (var _i = 0, array_5 = array; _i < array_5.length; _i++) { + var item = array_5[_i]; for (var _a = 0, result_1 = result; _a < result_1.length; _a++) { var res = result_1[_a]; if (areEqual ? areEqual(res, item) : res === item) { @@ -1759,8 +1760,8 @@ var ts; ts.relativeComplement = relativeComplement; function sum(array, prop) { var result = 0; - for (var _i = 0, array_7 = array; _i < array_7.length; _i++) { - var v = array_7[_i]; + for (var _i = 0, array_6 = array; _i < array_6.length; _i++) { + var v = array_6[_i]; result += v[prop]; } return result; @@ -2020,8 +2021,8 @@ var ts; ts.equalOwnProperties = equalOwnProperties; function arrayToMap(array, makeKey, makeValue) { var result = createMap(); - for (var _i = 0, array_8 = array; _i < array_8.length; _i++) { - var value = array_8[_i]; + for (var _i = 0, array_7 = array; _i < array_7.length; _i++) { + var value = array_7[_i]; result.set(makeKey(value), makeValue ? makeValue(value) : value); } return result; @@ -2181,11 +2182,11 @@ var ts; ts.getLocaleSpecificMessage = getLocaleSpecificMessage; function createFileDiagnostic(file, start, length, message) { var end = start + length; - Debug.assert(start >= 0, "start must be non-negative, is " + start); - Debug.assert(length >= 0, "length must be non-negative, is " + length); + Debug.assertGreaterThanOrEqual(start, 0); + Debug.assertGreaterThanOrEqual(length, 0); if (file) { - Debug.assert(start <= file.text.length, "start must be within the bounds of the file. " + start + " > " + file.text.length); - Debug.assert(end <= file.text.length, "end must be the bounds of the file. " + end + " > " + file.text.length); + Debug.assertLessThanOrEqual(start, file.text.length); + Debug.assertLessThanOrEqual(end, file.text.length); } var text = getLocaleSpecificMessage(message); if (arguments.length > 4) { @@ -2394,19 +2395,23 @@ var ts; return normalized; } function normalizePath(path) { + return normalizePathAndParts(path).path; + } + ts.normalizePath = normalizePath; + function normalizePathAndParts(path) { path = normalizeSlashes(path); var rootLength = getRootLength(path); var root = path.substr(0, rootLength); - var normalized = getNormalizedParts(path, rootLength); - if (normalized.length) { - var joinedParts = root + normalized.join(ts.directorySeparator); - return pathEndsWithDirectorySeparator(path) ? joinedParts + ts.directorySeparator : joinedParts; + var parts = getNormalizedParts(path, rootLength); + if (parts.length) { + var joinedParts = root + parts.join(ts.directorySeparator); + return { path: pathEndsWithDirectorySeparator(path) ? joinedParts + ts.directorySeparator : joinedParts, parts: parts }; } else { - return root; + return { path: root, parts: parts }; } } - ts.normalizePath = normalizePath; + ts.normalizePathAndParts = normalizePathAndParts; function pathEndsWithDirectorySeparator(path) { return path.charCodeAt(path.length - 1) === directorySeparatorCharCode; } @@ -2669,8 +2674,28 @@ var ts; ts.fileExtensionIsOneOf = fileExtensionIsOneOf; var reservedCharacterPattern = /[^\w\s\/]/g; var wildcardCharCodes = [42, 63]; - var singleAsteriskRegexFragmentFiles = "([^./]|(\\.(?!min\\.js$))?)*"; - var singleAsteriskRegexFragmentOther = "[^/]*"; + ts.commonPackageFolders = ["node_modules", "bower_components", "jspm_packages"]; + var implicitExcludePathRegexPattern = "(?!(" + ts.commonPackageFolders.join("|") + ")(/|$))"; + var filesMatcher = { + singleAsteriskRegexFragment: "([^./]|(\\.(?!min\\.js$))?)*", + doubleAsteriskRegexFragment: "(/" + implicitExcludePathRegexPattern + "[^/.][^/]*)*?", + replaceWildcardCharacter: function (match) { return replaceWildcardCharacter(match, filesMatcher.singleAsteriskRegexFragment); } + }; + var directoriesMatcher = { + singleAsteriskRegexFragment: "[^/]*", + doubleAsteriskRegexFragment: "(/" + implicitExcludePathRegexPattern + "[^/.][^/]*)*?", + replaceWildcardCharacter: function (match) { return replaceWildcardCharacter(match, directoriesMatcher.singleAsteriskRegexFragment); } + }; + var excludeMatcher = { + singleAsteriskRegexFragment: "[^/]*", + doubleAsteriskRegexFragment: "(/.+?)?", + replaceWildcardCharacter: function (match) { return replaceWildcardCharacter(match, excludeMatcher.singleAsteriskRegexFragment); } + }; + var wildcardMatchers = { + files: filesMatcher, + directories: directoriesMatcher, + exclude: excludeMatcher + }; function getRegularExpressionForWildcard(specs, basePath, usage) { var patterns = getRegularExpressionsForWildcards(specs, basePath, usage); if (!patterns || !patterns.length) { @@ -2685,18 +2710,16 @@ var ts; if (specs === undefined || specs.length === 0) { return undefined; } - var replaceWildcardCharacter = usage === "files" ? replaceWildCardCharacterFiles : replaceWildCardCharacterOther; - var singleAsteriskRegexFragment = usage === "files" ? singleAsteriskRegexFragmentFiles : singleAsteriskRegexFragmentOther; - var doubleAsteriskRegexFragment = usage === "exclude" ? "(/.+?)?" : "(/[^/.][^/]*)*?"; return flatMap(specs, function (spec) { - return spec && getSubPatternFromSpec(spec, basePath, usage, singleAsteriskRegexFragment, doubleAsteriskRegexFragment, replaceWildcardCharacter); + return spec && getSubPatternFromSpec(spec, basePath, usage, wildcardMatchers[usage]); }); } function isImplicitGlob(lastPathComponent) { return !/[.*?]/.test(lastPathComponent); } ts.isImplicitGlob = isImplicitGlob; - function getSubPatternFromSpec(spec, basePath, usage, singleAsteriskRegexFragment, doubleAsteriskRegexFragment, replaceWildcardCharacter) { + function getSubPatternFromSpec(spec, basePath, usage, _a) { + var singleAsteriskRegexFragment = _a.singleAsteriskRegexFragment, doubleAsteriskRegexFragment = _a.doubleAsteriskRegexFragment, replaceWildcardCharacter = _a.replaceWildcardCharacter; var subpattern = ""; var hasRecursiveDirectoryWildcard = false; var hasWrittenComponent = false; @@ -2728,16 +2751,24 @@ var ts; subpattern += ts.directorySeparator; } if (usage !== "exclude") { + var componentPattern = ""; if (component.charCodeAt(0) === 42) { - subpattern += "([^./]" + singleAsteriskRegexFragment + ")?"; + componentPattern += "([^./]" + singleAsteriskRegexFragment + ")?"; component = component.substr(1); } else if (component.charCodeAt(0) === 63) { - subpattern += "[^./]"; + componentPattern += "[^./]"; component = component.substr(1); } + componentPattern += component.replace(reservedCharacterPattern, replaceWildcardCharacter); + if (componentPattern !== component) { + subpattern += implicitExcludePathRegexPattern; + } + subpattern += componentPattern; + } + else { + subpattern += component.replace(reservedCharacterPattern, replaceWildcardCharacter); } - subpattern += component.replace(reservedCharacterPattern, replaceWildcardCharacter); } hasWrittenComponent = true; } @@ -2747,12 +2778,6 @@ var ts; } return subpattern; } - function replaceWildCardCharacterFiles(match) { - return replaceWildcardCharacter(match, singleAsteriskRegexFragmentFiles); - } - function replaceWildCardCharacterOther(match) { - return replaceWildcardCharacter(match, singleAsteriskRegexFragmentOther); - } function replaceWildcardCharacter(match, singleAsteriskRegexFragment) { return match === "*" ? singleAsteriskRegexFragment : match === "?" ? "[^/]" : "\\" + match; } @@ -2889,14 +2914,7 @@ var ts; if (!extraFileExtensions || extraFileExtensions.length === 0 || !needAllExtensions) { return needAllExtensions ? allSupportedExtensions : ts.supportedTypeScriptExtensions; } - var extensions = allSupportedExtensions.slice(0); - for (var _i = 0, extraFileExtensions_1 = extraFileExtensions; _i < extraFileExtensions_1.length; _i++) { - var extInfo = extraFileExtensions_1[_i]; - if (extensions.indexOf(extInfo.extension) === -1) { - extensions.push(extInfo.extension); - } - } - return extensions; + return deduplicate(allSupportedExtensions.concat(extraFileExtensions.map(function (e) { return e.extension; }))); } ts.getSupportedExtensions = getSupportedExtensions; function hasJavaScriptFileExtension(fileName) { @@ -3038,12 +3056,37 @@ var ts; function assert(expression, message, verboseDebugInfo, stackCrawlMark) { if (!expression) { if (verboseDebugInfo) { - message += "\r\nVerbose Debug Information: " + verboseDebugInfo(); + message += "\r\nVerbose Debug Information: " + (typeof verboseDebugInfo === "string" ? verboseDebugInfo : verboseDebugInfo()); } fail(message ? "False expression: " + message : "False expression.", stackCrawlMark || assert); } } Debug.assert = assert; + function assertEqual(a, b, msg, msg2) { + if (a !== b) { + var message = msg ? msg2 ? msg + " " + msg2 : msg : ""; + fail("Expected " + a + " === " + b + ". " + message); + } + } + Debug.assertEqual = assertEqual; + function assertLessThan(a, b, msg) { + if (a >= b) { + fail("Expected " + a + " < " + b + ". " + (msg || "")); + } + } + Debug.assertLessThan = assertLessThan; + function assertLessThanOrEqual(a, b) { + if (a > b) { + fail("Expected " + a + " <= " + b); + } + } + Debug.assertLessThanOrEqual = assertLessThanOrEqual; + function assertGreaterThanOrEqual(a, b) { + if (a < b) { + fail("Expected " + a + " >= " + b); + } + } + Debug.assertGreaterThanOrEqual = assertGreaterThanOrEqual; function fail(message, stackCrawlMark) { debugger; var e = new Error(message ? "Debug Failure. " + message : "Debug Failure."); @@ -3178,6 +3221,10 @@ var ts; Debug.fail("File " + path + " has unknown extension."); } ts.extensionFromPath = extensionFromPath; + function isAnySupportedFileExtension(path) { + return tryGetExtensionFromPath(path) !== undefined; + } + ts.isAnySupportedFileExtension = isAnySupportedFileExtension; function tryGetExtensionFromPath(path) { return find(ts.supportedTypescriptExtensionsForExtractExtension, function (e) { return fileExtensionIs(path, e); }) || find(ts.supportedJavascriptExtensions, function (e) { return fileExtensionIs(path, e); }); } @@ -3189,6 +3236,12 @@ var ts; })(ts || (ts = {})); var ts; (function (ts) { + function setStackTraceLimit() { + if (Error.stackTraceLimit < 100) { + Error.stackTraceLimit = 100; + } + } + ts.setStackTraceLimit = setStackTraceLimit; var FileWatcherEventKind; (function (FileWatcherEventKind) { FileWatcherEventKind[FileWatcherEventKind["Created"] = 0] = "Created"; @@ -3238,7 +3291,7 @@ var ts; watcher.referenceCount += 1; return; } - watcher = _fs.watch(dirPath, { persistent: true }, function (eventName, relativeFileName) { return fileEventHandler(eventName, relativeFileName, dirPath); }); + watcher = _fs.watch(dirPath || ".", { persistent: true }, function (eventName, relativeFileName) { return fileEventHandler(eventName, relativeFileName, dirPath); }); watcher.referenceCount = 1; dirWatchers.set(dirPath, watcher); return; @@ -4064,6 +4117,8 @@ var ts; Expected_at_least_0_arguments_but_got_a_minimum_of_1: diag(2557, ts.DiagnosticCategory.Error, "Expected_at_least_0_arguments_but_got_a_minimum_of_1_2557", "Expected at least {0} arguments, but got a minimum of {1}."), Expected_0_type_arguments_but_got_1: diag(2558, ts.DiagnosticCategory.Error, "Expected_0_type_arguments_but_got_1_2558", "Expected {0} type arguments, but got {1}."), Type_0_has_no_properties_in_common_with_type_1: diag(2559, ts.DiagnosticCategory.Error, "Type_0_has_no_properties_in_common_with_type_1_2559", "Type '{0}' has no properties in common with type '{1}'."), + Value_of_type_0_has_no_properties_in_common_with_type_1_Did_you_mean_to_call_it: diag(2560, ts.DiagnosticCategory.Error, "Value_of_type_0_has_no_properties_in_common_with_type_1_Did_you_mean_to_call_it_2560", "Value of type '{0}' has no properties in common with type '{1}'. Did you mean to call it?"), + Base_class_expressions_cannot_reference_class_type_parameters: diag(2561, ts.DiagnosticCategory.Error, "Base_class_expressions_cannot_reference_class_type_parameters_2561", "Base class expressions cannot reference class type parameters."), JSX_element_attributes_type_0_may_not_be_a_union_type: diag(2600, ts.DiagnosticCategory.Error, "JSX_element_attributes_type_0_may_not_be_a_union_type_2600", "JSX element attributes type '{0}' may not be a union type."), The_return_type_of_a_JSX_element_constructor_must_return_an_object_type: diag(2601, ts.DiagnosticCategory.Error, "The_return_type_of_a_JSX_element_constructor_must_return_an_object_type_2601", "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: diag(2602, ts.DiagnosticCategory.Error, "JSX_element_implicitly_has_type_any_because_the_global_type_JSX_Element_does_not_exist_2602", "JSX element implicitly has type 'any' because the global type 'JSX.Element' does not exist."), @@ -4251,6 +4306,7 @@ var ts; Do_not_emit_outputs: diag(6010, ts.DiagnosticCategory.Message, "Do_not_emit_outputs_6010", "Do not emit outputs."), Allow_default_imports_from_modules_with_no_default_export_This_does_not_affect_code_emit_just_typechecking: diag(6011, ts.DiagnosticCategory.Message, "Allow_default_imports_from_modules_with_no_default_export_This_does_not_affect_code_emit_just_typech_6011", "Allow default imports from modules with no default export. This does not affect code emit, just typechecking."), Skip_type_checking_of_declaration_files: diag(6012, ts.DiagnosticCategory.Message, "Skip_type_checking_of_declaration_files_6012", "Skip type checking of declaration files."), + Do_not_resolve_the_real_path_of_symlinks: diag(6013, ts.DiagnosticCategory.Message, "Do_not_resolve_the_real_path_of_symlinks_6013", "Do not resolve the real path of symlinks."), Specify_ECMAScript_target_version_Colon_ES3_default_ES5_ES2015_ES2016_ES2017_or_ESNEXT: diag(6015, ts.DiagnosticCategory.Message, "Specify_ECMAScript_target_version_Colon_ES3_default_ES5_ES2015_ES2016_ES2017_or_ESNEXT_6015", "Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', or 'ESNEXT'."), Specify_module_code_generation_Colon_none_commonjs_amd_system_umd_es2015_or_ESNext: diag(6016, ts.DiagnosticCategory.Message, "Specify_module_code_generation_Colon_none_commonjs_amd_system_umd_es2015_or_ESNext_6016", "Specify module code generation: 'none', commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'."), Print_this_message: diag(6017, ts.DiagnosticCategory.Message, "Print_this_message_6017", "Print this message."), @@ -4504,6 +4560,8 @@ var ts; Rewrite_as_the_indexed_access_type_0: diag(90026, ts.DiagnosticCategory.Message, "Rewrite_as_the_indexed_access_type_0_90026", "Rewrite as the indexed access type '{0}'."), Convert_function_to_an_ES2015_class: diag(95001, ts.DiagnosticCategory.Message, "Convert_function_to_an_ES2015_class_95001", "Convert function to an ES2015 class"), Convert_function_0_to_class: diag(95002, ts.DiagnosticCategory.Message, "Convert_function_0_to_class_95002", "Convert function '{0}' to class"), + Extract_function: diag(95003, ts.DiagnosticCategory.Message, "Extract_function_95003", "Extract function"), + Extract_function_into_0: diag(95004, ts.DiagnosticCategory.Message, "Extract_function_into_0_95004", "Extract function into '{0}'"), }; })(ts || (ts = {})); var ts; @@ -4516,6 +4574,12 @@ var ts; return compilerOptions.traceResolution && host.trace !== undefined; } ts.isTraceEnabled = isTraceEnabled; + function withPackageId(packageId, r) { + return r && { path: r.path, extension: r.ext, packageId: packageId }; + } + function noPackageId(r) { + return withPackageId(undefined, r); + } var Extensions; (function (Extensions) { Extensions[Extensions["TypeScript"] = 0] = "TypeScript"; @@ -4531,12 +4595,11 @@ var ts; } function createResolvedModuleWithFailedLookupLocations(resolved, isExternalLibraryImport, failedLookupLocations) { return { - resolvedModule: resolved && { resolvedFileName: resolved.path, extension: resolved.extension, isExternalLibraryImport: isExternalLibraryImport }, + resolvedModule: resolved && { resolvedFileName: resolved.path, extension: resolved.extension, isExternalLibraryImport: isExternalLibraryImport, packageId: resolved.packageId }, failedLookupLocations: failedLookupLocations }; } - function tryReadPackageJsonFields(readTypes, packageJsonPath, baseDirectory, state) { - var jsonContent = readJson(packageJsonPath, state.host); + function tryReadPackageJsonFields(readTypes, jsonContent, baseDirectory, state) { return readTypes ? tryReadFromField("typings") || tryReadFromField("types") : tryReadFromField("main"); function tryReadFromField(fieldName) { if (!ts.hasProperty(jsonContent, fieldName)) { @@ -4630,7 +4693,9 @@ var ts; } var resolvedTypeReferenceDirective; if (resolved) { - resolved = realpath(resolved, host, traceEnabled); + if (!options.preserveSymlinks) { + resolved = realPath(resolved, host, traceEnabled); + } if (traceEnabled) { trace(host, ts.Diagnostics.Type_reference_directive_0_was_successfully_resolved_to_1_primary_Colon_2, typeReferenceDirectiveName, resolved, primary); } @@ -4931,7 +4996,7 @@ var ts; if (extension !== undefined) { var path_1 = tryFile(candidate, failedLookupLocations, false, state); if (path_1 !== undefined) { - return { path: path_1, extension: extension }; + return { path: path_1, extension: extension, packageId: undefined }; } } return loader(extensions, candidate, failedLookupLocations, !directoryProbablyExists(ts.getDirectoryPath(candidate), state.host), state); @@ -4952,7 +5017,7 @@ var ts; function resolveJavaScriptModule(moduleName, initialDir, host) { var _a = nodeModuleNameResolverWorker(moduleName, initialDir, { moduleResolution: ts.ModuleResolutionKind.NodeJs, allowJs: true }, host, undefined, true), resolvedModule = _a.resolvedModule, failedLookupLocations = _a.failedLookupLocations; if (!resolvedModule) { - throw new Error("Could not resolve JS module " + moduleName + " starting at " + initialDir + ". Looked in: " + failedLookupLocations.join(", ")); + throw new Error("Could not resolve JS module '" + moduleName + "' starting at '" + initialDir + "'. Looked in: " + failedLookupLocations.join(", ")); } return resolvedModule.resolvedFileName; } @@ -4978,16 +5043,22 @@ var ts; trace(host, ts.Diagnostics.Loading_module_0_from_node_modules_folder_target_file_type_1, moduleName, Extensions[extensions]); } var resolved_1 = loadModuleFromNodeModules(extensions, moduleName, containingDirectory, failedLookupLocations, state, cache); - return resolved_1 && { value: resolved_1.value && { resolved: { path: realpath(resolved_1.value.path, host, traceEnabled), extension: resolved_1.value.extension }, isExternalLibraryImport: true } }; + if (!resolved_1) + return undefined; + var resolvedValue = resolved_1.value; + if (!compilerOptions.preserveSymlinks) { + resolvedValue = resolvedValue && __assign({}, resolved_1.value, { path: realPath(resolved_1.value.path, host, traceEnabled), extension: resolved_1.value.extension }); + } + return { value: resolvedValue && { resolved: resolvedValue, isExternalLibraryImport: true } }; } else { - var candidate = ts.normalizePath(ts.combinePaths(containingDirectory, moduleName)); + var _a = ts.normalizePathAndParts(ts.combinePaths(containingDirectory, moduleName)), candidate = _a.path, parts = _a.parts; var resolved_2 = nodeLoadModuleByRelativeName(extensions, candidate, failedLookupLocations, false, state, true); - return resolved_2 && toSearchResult({ resolved: resolved_2, isExternalLibraryImport: false }); + return resolved_2 && toSearchResult({ resolved: resolved_2, isExternalLibraryImport: ts.contains(parts, "node_modules") }); } } } - function realpath(path, host, traceEnabled) { + function realPath(path, host, traceEnabled) { if (!host.realpath) { return path; } @@ -5013,7 +5084,7 @@ var ts; } var resolvedFromFile = loadModuleFromFile(extensions, candidate, failedLookupLocations, onlyRecordFailures, state); if (resolvedFromFile) { - return resolvedFromFile; + return noPackageId(resolvedFromFile); } } if (!onlyRecordFailures) { @@ -5031,6 +5102,9 @@ var ts; return !host.directoryExists || host.directoryExists(directoryName); } ts.directoryProbablyExists = directoryProbablyExists; + function loadModuleFromFileNoPackageId(extensions, candidate, failedLookupLocations, onlyRecordFailures, state) { + return noPackageId(loadModuleFromFile(extensions, candidate, failedLookupLocations, onlyRecordFailures, state)); + } function loadModuleFromFile(extensions, candidate, failedLookupLocations, onlyRecordFailures, state) { var resolvedByAddingExtension = tryAddingExtensions(candidate, extensions, failedLookupLocations, onlyRecordFailures, state); if (resolvedByAddingExtension) { @@ -5060,9 +5134,9 @@ var ts; case Extensions.JavaScript: return tryExtension(".js") || tryExtension(".jsx"); } - function tryExtension(extension) { - var path = tryFile(candidate + extension, failedLookupLocations, onlyRecordFailures, state); - return path && { path: path, extension: extension }; + function tryExtension(ext) { + var path = tryFile(candidate + ext, failedLookupLocations, onlyRecordFailures, state); + return path && { path: path, ext: ext }; } } function tryFile(fileName, failedLookupLocations, onlyRecordFailures, state) { @@ -5085,12 +5159,20 @@ var ts; function loadNodeModuleFromDirectory(extensions, candidate, failedLookupLocations, onlyRecordFailures, state, considerPackageJson) { if (considerPackageJson === void 0) { considerPackageJson = true; } var directoryExists = !onlyRecordFailures && directoryProbablyExists(candidate, state.host); + var packageId; if (considerPackageJson) { var packageJsonPath = pathToPackageJson(candidate); if (directoryExists && state.host.fileExists(packageJsonPath)) { - var fromPackageJson = loadModuleFromPackageJson(packageJsonPath, extensions, candidate, failedLookupLocations, state); + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.Found_package_json_at_0, packageJsonPath); + } + var jsonContent = readJson(packageJsonPath, state.host); + if (typeof jsonContent.name === "string" && typeof jsonContent.version === "string") { + packageId = { name: jsonContent.name, version: jsonContent.version }; + } + var fromPackageJson = loadModuleFromPackageJson(jsonContent, extensions, candidate, failedLookupLocations, state); if (fromPackageJson) { - return fromPackageJson; + return withPackageId(packageId, fromPackageJson); } } else { @@ -5100,13 +5182,10 @@ var ts; failedLookupLocations.push(packageJsonPath); } } - return loadModuleFromFile(extensions, ts.combinePaths(candidate, "index"), failedLookupLocations, !directoryExists, state); + return withPackageId(packageId, loadModuleFromFile(extensions, ts.combinePaths(candidate, "index"), failedLookupLocations, !directoryExists, state)); } - function loadModuleFromPackageJson(packageJsonPath, extensions, candidate, failedLookupLocations, state) { - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.Found_package_json_at_0, packageJsonPath); - } - var file = tryReadPackageJsonFields(extensions !== Extensions.JavaScript, packageJsonPath, candidate, state); + function loadModuleFromPackageJson(jsonContent, extensions, candidate, failedLookupLocations, state) { + var file = tryReadPackageJsonFields(extensions !== Extensions.JavaScript, jsonContent, candidate, state); if (!file) { return undefined; } @@ -5122,11 +5201,15 @@ var ts; } } var nextExtensions = extensions === Extensions.DtsOnly ? Extensions.TypeScript : extensions; - return nodeLoadModuleByRelativeName(nextExtensions, file, failedLookupLocations, onlyRecordFailures, state, false); + var result = nodeLoadModuleByRelativeName(nextExtensions, file, failedLookupLocations, onlyRecordFailures, state, false); + if (result) { + ts.Debug.assert(result.packageId === undefined); + return { path: result.path, ext: result.extension }; + } } function resolvedIfExtensionMatches(extensions, path) { - var extension = ts.tryGetExtensionFromPath(path); - return extension !== undefined && extensionIsOk(extensions, extension) ? { path: path, extension: extension } : undefined; + var ext = ts.tryGetExtensionFromPath(path); + return ext !== undefined && extensionIsOk(extensions, ext) ? { path: path, ext: ext } : undefined; } function extensionIsOk(extensions, extension) { switch (extensions) { @@ -5143,7 +5226,7 @@ var ts; } function loadModuleFromNodeModulesFolder(extensions, moduleName, nodeModulesFolder, nodeModulesFolderExists, failedLookupLocations, state) { var candidate = ts.normalizePath(ts.combinePaths(nodeModulesFolder, moduleName)); - return loadModuleFromFile(extensions, candidate, failedLookupLocations, !nodeModulesFolderExists, state) || + return loadModuleFromFileNoPackageId(extensions, candidate, failedLookupLocations, !nodeModulesFolderExists, state) || loadNodeModuleFromDirectory(extensions, candidate, failedLookupLocations, !nodeModulesFolderExists, state); } function loadModuleFromNodeModules(extensions, moduleName, directory, failedLookupLocations, state, cache) { @@ -5217,7 +5300,7 @@ var ts; if (traceEnabled) { trace(host, ts.Diagnostics.Resolution_for_module_0_was_found_in_cache, moduleName); } - return { value: result.resolvedModule && { path: result.resolvedModule.resolvedFileName, extension: result.resolvedModule.extension } }; + return { value: result.resolvedModule && { path: result.resolvedModule.resolvedFileName, extension: result.resolvedModule.extension, packageId: result.resolvedModule.packageId } }; } } function classicNameResolver(moduleName, containingFile, compilerOptions, host, cache) { @@ -5228,7 +5311,7 @@ var ts; var resolved = tryResolve(Extensions.TypeScript) || tryResolve(Extensions.JavaScript); return createResolvedModuleWithFailedLookupLocations(resolved && resolved.value, false, failedLookupLocations); function tryResolve(extensions) { - var resolvedUsingSettings = tryLoadModuleUsingOptionalResolutionSettings(extensions, moduleName, containingDirectory, loadModuleFromFile, failedLookupLocations, state); + var resolvedUsingSettings = tryLoadModuleUsingOptionalResolutionSettings(extensions, moduleName, containingDirectory, loadModuleFromFileNoPackageId, failedLookupLocations, state); if (resolvedUsingSettings) { return { value: resolvedUsingSettings }; } @@ -5240,7 +5323,7 @@ var ts; return resolutionFromCache; } var searchName = ts.normalizePath(ts.combinePaths(directory, moduleName)); - return toSearchResult(loadModuleFromFile(extensions, searchName, failedLookupLocations, false, state)); + return toSearchResult(loadModuleFromFileNoPackageId(extensions, searchName, failedLookupLocations, false, state)); }); if (resolved_3) { return resolved_3; @@ -5251,7 +5334,7 @@ var ts; } else { var candidate = ts.normalizePath(ts.combinePaths(containingDirectory, moduleName)); - return toSearchResult(loadModuleFromFile(extensions, candidate, failedLookupLocations, false, state)); + return toSearchResult(loadModuleFromFileNoPackageId(extensions, candidate, failedLookupLocations, false, state)); } } } @@ -5302,19 +5385,6 @@ var ts; return undefined; } ts.getDeclarationOfKind = getDeclarationOfKind; - function findDeclaration(symbol, predicate) { - var declarations = symbol.declarations; - if (declarations) { - for (var _i = 0, declarations_2 = declarations; _i < declarations_2.length; _i++) { - var declaration = declarations_2[_i]; - if (predicate(declaration)) { - return declaration; - } - } - } - return undefined; - } - ts.findDeclaration = findDeclaration; var stringWriter = createSingleLineStringWriter(); var stringWriterAcquired = false; function createSingleLineStringWriter() { @@ -5377,9 +5447,13 @@ var ts; function moduleResolutionIsEqualTo(oldResolution, newResolution) { return oldResolution.isExternalLibraryImport === newResolution.isExternalLibraryImport && oldResolution.extension === newResolution.extension && - oldResolution.resolvedFileName === newResolution.resolvedFileName; + oldResolution.resolvedFileName === newResolution.resolvedFileName && + packageIdIsEqual(oldResolution.packageId, newResolution.packageId); } ts.moduleResolutionIsEqualTo = moduleResolutionIsEqualTo; + function packageIdIsEqual(a, b) { + return a === b || a && b && a.name === b.name && a.version === b.version; + } function typeDirectiveIsEqualTo(oldResolution, newResolution) { return oldResolution.resolvedFileName === newResolution.resolvedFileName && oldResolution.primary === newResolution.primary; } @@ -5444,14 +5518,6 @@ var ts; return file.fileName + "(" + (loc.line + 1) + "," + (loc.character + 1) + ")"; } ts.nodePosToString = nodePosToString; - function getStartPosOfNode(node) { - return node.pos; - } - ts.getStartPosOfNode = getStartPosOfNode; - function isDefined(value) { - return value !== undefined; - } - ts.isDefined = isDefined; function getEndLinePosition(line, sourceFile) { ts.Debug.assert(line >= 0); var lineStarts = ts.getLineStarts(sourceFile); @@ -5482,6 +5548,25 @@ var ts; return !nodeIsMissing(node); } ts.nodeIsPresent = nodeIsPresent; + function isRecognizedTripleSlashComment(text, commentPos, commentEnd) { + if (text.charCodeAt(commentPos + 1) === 47 && + commentPos + 2 < commentEnd && + text.charCodeAt(commentPos + 2) === 47) { + var textSubStr = text.substring(commentPos, commentEnd); + return textSubStr.match(ts.fullTripleSlashReferencePathRegEx) || + textSubStr.match(ts.fullTripleSlashAMDReferencePathRegEx) || + textSubStr.match(fullTripleSlashReferenceTypeReferenceDirectiveRegEx) || + textSubStr.match(defaultLibReferenceRegEx) ? + true : false; + } + return false; + } + ts.isRecognizedTripleSlashComment = isRecognizedTripleSlashComment; + function isPinnedComment(text, comment) { + return text.charCodeAt(comment.pos + 1) === 42 && + text.charCodeAt(comment.pos + 2) === 33; + } + ts.isPinnedComment = isPinnedComment; function getTokenPosOfNode(node, sourceFile, includeJsDoc) { if (nodeIsMissing(node)) { return node.pos; @@ -5538,15 +5623,20 @@ var ts; var escapeText = getEmitFlags(node) & 16777216 ? escapeString : escapeNonAsciiString; switch (node.kind) { case 9: - return '"' + escapeText(node.text) + '"'; + if (node.singleQuote) { + return "'" + escapeText(node.text, 39) + "'"; + } + else { + return '"' + escapeText(node.text, 34) + '"'; + } case 13: - return "`" + escapeText(node.text) + "`"; + return "`" + escapeText(node.text, 96) + "`"; case 14: - return "`" + escapeText(node.text) + "${"; + return "`" + escapeText(node.text, 96) + "${"; case 15: - return "}" + escapeText(node.text) + "${"; + return "}" + escapeText(node.text, 96) + "${"; case 16: - return "}" + escapeText(node.text) + "`"; + return "}" + escapeText(node.text, 96) + "`"; case 8: return node.text; } @@ -5798,13 +5888,9 @@ var ts; } ts.isPrologueDirective = isPrologueDirective; function getLeadingCommentRangesOfNode(node, sourceFileOfNode) { - return ts.getLeadingCommentRanges(sourceFileOfNode.text, node.pos); + return node.kind !== 10 ? ts.getLeadingCommentRanges(sourceFileOfNode.text, node.pos) : undefined; } ts.getLeadingCommentRangesOfNode = getLeadingCommentRangesOfNode; - function getLeadingCommentRangesOfNodeFromText(node, text) { - return ts.getLeadingCommentRanges(text, node.pos); - } - ts.getLeadingCommentRangesOfNodeFromText = getLeadingCommentRangesOfNodeFromText; function getJSDocCommentRanges(node, text) { var commentRanges = (node.kind === 146 || node.kind === 145 || @@ -5812,7 +5898,7 @@ var ts; node.kind === 187 || node.kind === 185) ? ts.concatenate(ts.getTrailingCommentRanges(text, node.pos), ts.getLeadingCommentRanges(text, node.pos)) : - getLeadingCommentRangesOfNodeFromText(node, text); + ts.getLeadingCommentRanges(text, node.pos); return ts.filter(commentRanges, function (comment) { return text.charCodeAt(comment.pos + 1) === 42 && text.charCodeAt(comment.pos + 2) === 42 && @@ -5821,8 +5907,9 @@ var ts; } ts.getJSDocCommentRanges = getJSDocCommentRanges; ts.fullTripleSlashReferencePathRegEx = /^(\/\/\/\s*/; - ts.fullTripleSlashReferenceTypeReferenceDirectiveRegEx = /^(\/\/\/\s*/; + var fullTripleSlashReferenceTypeReferenceDirectiveRegEx = /^(\/\/\/\s*/; ts.fullTripleSlashAMDReferencePathRegEx = /^(\/\/\/\s*/; + var defaultLibReferenceRegEx = /^(\/\/\/\s*/; function isPartOfTypeNode(node) { if (158 <= node.kind && node.kind <= 173) { return true; @@ -6049,21 +6136,11 @@ var ts; } ts.getPropertyAssignment = getPropertyAssignment; function getContainingFunction(node) { - while (true) { - node = node.parent; - if (!node || ts.isFunctionLike(node)) { - return node; - } - } + return ts.findAncestor(node.parent, ts.isFunctionLike); } ts.getContainingFunction = getContainingFunction; function getContainingClass(node) { - while (true) { - node = node.parent; - if (!node || ts.isClassLike(node)) { - return node; - } - } + return ts.findAncestor(node.parent, ts.isClassLike); } ts.getContainingClass = getContainingClass; function getThisContainer(node, includeArrowFunctions) { @@ -6873,14 +6950,14 @@ var ts; ts.getAncestor = getAncestor; function getFileReferenceFromReferencePath(comment, commentRange) { var simpleReferenceRegEx = /^\/\/\/\s*/gim; + var isNoDefaultLibRegEx = new RegExp(defaultLibReferenceRegEx.source, "gim"); if (simpleReferenceRegEx.test(comment)) { if (isNoDefaultLibRegEx.test(comment)) { return { isNoDefaultLib: true }; } else { var refMatchResult = ts.fullTripleSlashReferencePathRegEx.exec(comment); - var refLibResult = !refMatchResult && ts.fullTripleSlashReferenceTypeReferenceDirectiveRegEx.exec(comment); + var refLibResult = !refMatchResult && fullTripleSlashReferenceTypeReferenceDirectiveRegEx.exec(comment); var match = refMatchResult || refLibResult; if (match) { var pos = commentRange.pos + match[1].length + match[2].length; @@ -7069,10 +7146,6 @@ var ts; return ts.getParseTreeNode(sourceFile, ts.isSourceFile) || sourceFile; } ts.getOriginalSourceFile = getOriginalSourceFile; - function getOriginalSourceFiles(sourceFiles) { - return ts.sameMap(sourceFiles, getOriginalSourceFile); - } - ts.getOriginalSourceFiles = getOriginalSourceFiles; var Associativity; (function (Associativity) { Associativity[Associativity["Left"] = 0] = "Left"; @@ -7311,7 +7384,9 @@ var ts; } } ts.createDiagnosticCollection = createDiagnosticCollection; - var escapedCharsRegExp = /[\\\"\u0000-\u001f\t\v\f\b\r\n\u2028\u2029\u0085]/g; + var doubleQuoteEscapedCharsRegExp = /[\\\"\u0000-\u001f\t\v\f\b\r\n\u2028\u2029\u0085]/g; + var singleQuoteEscapedCharsRegExp = /[\\\'\u0000-\u001f\t\v\f\b\r\n\u2028\u2029\u0085]/g; + var backtickQuoteEscapedCharsRegExp = /[\\\`\u0000-\u001f\t\v\f\b\r\n\u2028\u2029\u0085]/g; var escapedCharsMap = ts.createMapFromTemplate({ "\0": "\\0", "\t": "\\t", @@ -7322,11 +7397,16 @@ var ts; "\n": "\\n", "\\": "\\\\", "\"": "\\\"", + "\'": "\\\'", + "\`": "\\\`", "\u2028": "\\u2028", "\u2029": "\\u2029", "\u0085": "\\u0085" }); - function escapeString(s) { + function escapeString(s, quoteChar) { + var escapedCharsRegExp = quoteChar === 96 ? backtickQuoteEscapedCharsRegExp : + quoteChar === 39 ? singleQuoteEscapedCharsRegExp : + doubleQuoteEscapedCharsRegExp; return s.replace(escapedCharsRegExp, getReplacement); } ts.escapeString = escapeString; @@ -7344,8 +7424,8 @@ var ts; return "\\u" + paddedHexCode; } var nonAsciiCharacters = /[^\u0000-\u007F]/g; - function escapeNonAsciiString(s) { - s = escapeString(s); + function escapeNonAsciiString(s, quoteChar) { + s = escapeString(s, quoteChar); return nonAsciiCharacters.test(s) ? s.replace(nonAsciiCharacters, function (c) { return get16BitUnicodeEscapeSequence(c.charCodeAt(0)); }) : s; @@ -7686,7 +7766,7 @@ var ts; var currentDetachedCommentInfo; if (removeComments) { if (node.pos === 0) { - leadingComments = ts.filter(ts.getLeadingCommentRanges(text, node.pos), isPinnedComment); + leadingComments = ts.filter(ts.getLeadingCommentRanges(text, node.pos), isPinnedCommentLocal); } } else { @@ -7718,9 +7798,8 @@ var ts; } } return currentDetachedCommentInfo; - function isPinnedComment(comment) { - return text.charCodeAt(comment.pos + 1) === 42 && - text.charCodeAt(comment.pos + 2) === 33; + function isPinnedCommentLocal(comment) { + return isPinnedComment(text, comment); } } ts.emitDetachedComments = emitDetachedComments; @@ -7791,9 +7870,13 @@ var ts; } ts.hasModifiers = hasModifiers; function hasModifier(node, flags) { - return (getModifierFlags(node) & flags) !== 0; + return !!getSelectedModifierFlags(node, flags); } ts.hasModifier = hasModifier; + function getSelectedModifierFlags(node, flags) { + return getModifierFlags(node) & flags; + } + ts.getSelectedModifierFlags = getSelectedModifierFlags; function getModifierFlags(node) { if (node.modifierFlagsCache & 536870912) { return node.modifierFlagsCache & ~536870912; @@ -7869,21 +7952,6 @@ var ts; return false; } ts.isDestructuringAssignment = isDestructuringAssignment; - function isSupportedExpressionWithTypeArguments(node) { - return isSupportedExpressionWithTypeArgumentsRest(node.expression); - } - ts.isSupportedExpressionWithTypeArguments = isSupportedExpressionWithTypeArguments; - function isSupportedExpressionWithTypeArgumentsRest(node) { - if (node.kind === 71) { - return true; - } - else if (ts.isPropertyAccessExpression(node)) { - return isSupportedExpressionWithTypeArgumentsRest(node.expression); - } - else { - return false; - } - } function isExpressionWithTypeArgumentsInClassExtendsClause(node) { return tryGetClassExtendingExpressionWithTypeArguments(node) !== undefined; } @@ -7996,72 +8064,6 @@ var ts; return carriageReturnLineFeed; } ts.getNewLineCharacter = getNewLineCharacter; - function isSimpleExpression(node) { - return isSimpleExpressionWorker(node, 0); - } - ts.isSimpleExpression = isSimpleExpression; - function isSimpleExpressionWorker(node, depth) { - if (depth <= 5) { - var kind = node.kind; - if (kind === 9 - || kind === 8 - || kind === 12 - || kind === 13 - || kind === 71 - || kind === 99 - || kind === 97 - || kind === 101 - || kind === 86 - || kind === 95) { - return true; - } - else if (kind === 179) { - return isSimpleExpressionWorker(node.expression, depth + 1); - } - else if (kind === 180) { - return isSimpleExpressionWorker(node.expression, depth + 1) - && isSimpleExpressionWorker(node.argumentExpression, depth + 1); - } - else if (kind === 192 - || kind === 193) { - return isSimpleExpressionWorker(node.operand, depth + 1); - } - else if (kind === 194) { - return node.operatorToken.kind !== 40 - && isSimpleExpressionWorker(node.left, depth + 1) - && isSimpleExpressionWorker(node.right, depth + 1); - } - else if (kind === 195) { - return isSimpleExpressionWorker(node.condition, depth + 1) - && isSimpleExpressionWorker(node.whenTrue, depth + 1) - && isSimpleExpressionWorker(node.whenFalse, depth + 1); - } - else if (kind === 190 - || kind === 189 - || kind === 188) { - return isSimpleExpressionWorker(node.expression, depth + 1); - } - else if (kind === 177) { - return node.elements.length === 0; - } - else if (kind === 178) { - return node.properties.length === 0; - } - else if (kind === 181) { - if (!isSimpleExpressionWorker(node.expression, depth + 1)) { - return false; - } - for (var _i = 0, _a = node.arguments; _i < _a.length; _i++) { - var argument = _a[_i]; - if (!isSimpleExpressionWorker(argument, depth + 1)) { - return false; - } - } - return true; - } - } - return false; - } function formatEnum(value, enumObject, isFlags) { if (value === void 0) { value = 0; } var members = getEnumMembers(enumObject); @@ -8130,18 +8132,6 @@ var ts; return formatEnum(flags, ts.ObjectFlags, true); } ts.formatObjectFlags = formatObjectFlags; - function getRangePos(range) { - return range ? range.pos : -1; - } - ts.getRangePos = getRangePos; - function getRangeEnd(range) { - return range ? range.end : -1; - } - ts.getRangeEnd = getRangeEnd; - function movePos(pos, value) { - return ts.positionIsSynthesized(pos) ? -1 : pos + value; - } - ts.movePos = movePos; function createRange(pos, end) { return { pos: pos, end: end }; } @@ -8170,14 +8160,6 @@ var ts; return range.pos === range.end; } ts.isCollapsedRange = isCollapsedRange; - function collapseRangeToStart(range) { - return isCollapsedRange(range) ? range : moveRangeEnd(range, range.pos); - } - ts.collapseRangeToStart = collapseRangeToStart; - function collapseRangeToEnd(range) { - return isCollapsedRange(range) ? range : moveRangePos(range, range.end); - } - ts.collapseRangeToEnd = collapseRangeToEnd; function createTokenRange(pos, token) { return createRange(pos, pos + ts.tokenToString(token).length); } @@ -8230,22 +8212,6 @@ var ts; function isInitializedVariable(node) { return node.initializer !== undefined; } - function isMergedWithClass(node) { - if (node.symbol) { - for (var _i = 0, _a = node.symbol.declarations; _i < _a.length; _i++) { - var declaration = _a[_i]; - if (declaration.kind === 229 && declaration !== node) { - return true; - } - } - } - return false; - } - ts.isMergedWithClass = isMergedWithClass; - function isFirstDeclarationOfKind(node, kind) { - return node.symbol && getDeclarationOfKind(node.symbol, kind) === node; - } - ts.isFirstDeclarationOfKind = isFirstDeclarationOfKind; function isWatchSet(options) { return options.watch && options.hasOwnProperty("watch"); } @@ -8446,6 +8412,20 @@ var ts; return ts.hasModifier(node, 92) && node.parent.kind === 152 && ts.isClassLike(node.parent.parent); } ts.isParameterPropertyDeclaration = isParameterPropertyDeclaration; + function isEmptyBindingPattern(node) { + if (ts.isBindingPattern(node)) { + return ts.every(node.elements, isEmptyBindingElement); + } + return false; + } + ts.isEmptyBindingPattern = isEmptyBindingPattern; + function isEmptyBindingElement(node) { + if (ts.isOmittedExpression(node)) { + return true; + } + return isEmptyBindingPattern(node.name); + } + ts.isEmptyBindingElement = isEmptyBindingElement; function walkUpBindingElementsAndPatterns(node) { while (node && (node.kind === 176 || ts.isBindingPattern(node))) { node = node.parent; @@ -9526,6 +9506,18 @@ var ts; return isUnaryExpressionKind(ts.skipPartiallyEmittedExpressions(node).kind); } ts.isUnaryExpression = isUnaryExpression; + function isUnaryExpressionWithWrite(expr) { + switch (expr.kind) { + case 193: + return true; + case 192: + return expr.operator === 43 || + expr.operator === 44; + default: + return false; + } + } + ts.isUnaryExpressionWithWrite = isUnaryExpressionWithWrite; function isExpressionKind(kind) { return kind === 195 || kind === 197 @@ -9710,9 +9702,19 @@ var ts; var kind = node.kind; return isStatementKindButNotDeclarationKind(kind) || isDeclarationStatementKind(kind) - || kind === 207; + || isBlockStatement(node); } ts.isStatement = isStatement; + function isBlockStatement(node) { + if (node.kind !== 207) + return false; + if (node.parent !== undefined) { + if (node.parent.kind === 224 || node.parent.kind === 260) { + return false; + } + } + return !ts.isFunctionBlock(node); + } function isModuleReference(node) { var kind = node.kind; return kind === 248 @@ -13217,11 +13219,31 @@ var ts; var node = parseTokenNode(); return token() === 23 ? undefined : node; } - function parseLiteralTypeNode() { + function parseLiteralTypeNode(negative) { var node = createNode(173); - node.literal = parseSimpleUnaryExpression(); - finishNode(node); - return node; + var unaryMinusExpression; + if (negative) { + unaryMinusExpression = createNode(192); + unaryMinusExpression.operator = 38; + nextToken(); + } + var expression; + switch (token()) { + case 9: + case 8: + expression = parseLiteralLikeNode(token()); + break; + case 101: + case 86: + expression = parseTokenNode(); + } + if (negative) { + unaryMinusExpression.operand = expression; + finishNode(unaryMinusExpression); + expression = unaryMinusExpression; + } + node.literal = expression; + return finishNode(node); } function nextTokenIsNumericLiteral() { return nextToken() === 8; @@ -13253,7 +13275,7 @@ var ts; case 86: return parseLiteralTypeNode(); case 38: - return lookAhead(nextTokenIsNumericLiteral) ? parseLiteralTypeNode() : parseTypeReference(); + return lookAhead(nextTokenIsNumericLiteral) ? parseLiteralTypeNode(true) : parseTypeReference(); case 105: case 95: return parseTokenNode(); @@ -13302,6 +13324,7 @@ var ts; case 101: case 86: case 134: + case 39: return true; case 38: return lookAhead(nextTokenIsNumericLiteral); @@ -13620,7 +13643,7 @@ var ts; if (!arrowFunction) { return undefined; } - var isAsync = !!(ts.getModifierFlags(arrowFunction) & 256); + var isAsync = ts.hasModifier(arrowFunction, 256); var lastToken = token(); arrowFunction.equalsGreaterThanToken = parseExpectedToken(36, false, ts.Diagnostics._0_expected, "=>"); arrowFunction.body = (lastToken === 36 || lastToken === 17) @@ -13736,7 +13759,7 @@ var ts; function parseParenthesizedArrowFunctionExpressionHead(allowAmbiguity) { var node = createNode(187); node.modifiers = parseModifiersForArrowFunction(); - var isAsync = (ts.getModifierFlags(node) & 256) ? 2 : 0; + var isAsync = ts.hasModifier(node, 256) ? 2 : 0; fillSignature(56, isAsync | (allowAmbiguity ? 0 : 8), node); if (!node.parameters) { return undefined; @@ -14469,7 +14492,7 @@ var ts; parseExpected(89); node.asteriskToken = parseOptionalToken(39); var isGenerator = node.asteriskToken ? 1 : 0; - var isAsync = (ts.getModifierFlags(node) & 256) ? 2 : 0; + var isAsync = ts.hasModifier(node, 256) ? 2 : 0; node.name = isGenerator && isAsync ? doInYieldAndAwaitContext(parseOptionalIdentifier) : isGenerator ? doInYieldContext(parseOptionalIdentifier) : @@ -14694,10 +14717,13 @@ var ts; function parseCatchClause() { var result = createNode(260); parseExpected(74); - if (parseExpected(19)) { + if (parseOptional(19)) { result.variableDeclaration = parseVariableDeclaration(); + parseExpected(20); + } + else { + result.variableDeclaration = undefined; } - parseExpected(20); result.block = parseBlock(false); return finishNode(result); } @@ -16429,8 +16455,8 @@ var ts; array._children = undefined; array.pos += delta; array.end += delta; - for (var _i = 0, array_9 = array; _i < array_9.length; _i++) { - var node = array_9[_i]; + for (var _i = 0, array_8 = array; _i < array_8.length; _i++) { + var node = array_8[_i]; visitNode(node); } } @@ -16502,8 +16528,8 @@ var ts; array.intersectsChange = true; array._children = undefined; adjustIntersectingElement(array, changeStart, changeRangeOldEnd, changeRangeNewEnd, delta); - for (var _i = 0, array_10 = array; _i < array_10.length; _i++) { - var node = array_10[_i]; + for (var _i = 0, array_9 = array; _i < array_9.length; _i++) { + var node = array_9[_i]; visitNode(node); } return; @@ -17275,40 +17301,23 @@ var ts; return antecedent; } setFlowNodeReferenced(antecedent); - return { - flags: flags, - expression: expression, - antecedent: antecedent - }; + return { flags: flags, expression: expression, antecedent: antecedent }; } function createFlowSwitchClause(antecedent, switchStatement, clauseStart, clauseEnd) { if (!isNarrowingExpression(switchStatement.expression)) { return antecedent; } setFlowNodeReferenced(antecedent); - return { - flags: 128, - switchStatement: switchStatement, - clauseStart: clauseStart, - clauseEnd: clauseEnd, - antecedent: antecedent - }; + return { flags: 128, switchStatement: switchStatement, clauseStart: clauseStart, clauseEnd: clauseEnd, antecedent: antecedent }; } function createFlowAssignment(antecedent, node) { setFlowNodeReferenced(antecedent); - return { - flags: 16, - antecedent: antecedent, - node: node - }; + return { flags: 16, antecedent: antecedent, node: node }; } function createFlowArrayMutation(antecedent, node) { setFlowNodeReferenced(antecedent); - return { - flags: 256, - antecedent: antecedent, - node: node - }; + var res = { flags: 256, antecedent: antecedent, node: node }; + return res; } function finishFlowLabel(flow) { var antecedents = flow.antecedents; @@ -18776,7 +18785,6 @@ var ts; } function computeParameter(node, subtreeFlags) { var transformFlags = subtreeFlags; - var modifierFlags = ts.getModifierFlags(node); var name = node.name; var initializer = node.initializer; var dotDotDotToken = node.dotDotDotToken; @@ -18786,7 +18794,7 @@ var ts; || ts.isThisIdentifier(name)) { transformFlags |= 3; } - if (modifierFlags & 92) { + if (ts.hasModifier(node, 92)) { transformFlags |= 3 | 262144; } if (subtreeFlags & 1048576) { @@ -18815,8 +18823,7 @@ var ts; } function computeClassDeclaration(node, subtreeFlags) { var transformFlags; - var modifierFlags = ts.getModifierFlags(node); - if (modifierFlags & 2) { + if (ts.hasModifier(node, 2)) { transformFlags = 3; } else { @@ -18862,7 +18869,10 @@ var ts; } function computeCatchClause(node, subtreeFlags) { var transformFlags = subtreeFlags; - if (node.variableDeclaration && ts.isBindingPattern(node.variableDeclaration.name)) { + if (!node.variableDeclaration) { + transformFlags |= 8; + } + else if (ts.isBindingPattern(node.variableDeclaration.name)) { transformFlags |= 192; } node.transformFlags = transformFlags | 536870912; @@ -19026,9 +19036,8 @@ var ts; } function computeVariableStatement(node, subtreeFlags) { var transformFlags; - var modifierFlags = ts.getModifierFlags(node); var declarationListTransformFlags = node.declarationList.transformFlags; - if (modifierFlags & 2) { + if (ts.hasModifier(node, 2)) { transformFlags = 3; } else { @@ -19327,6 +19336,167 @@ var ts; } })(ts || (ts = {})); var ts; +(function (ts) { + function createGetSymbolWalker(getRestTypeOfSignature, getReturnTypeOfSignature, getBaseTypes, resolveStructuredTypeMembers, getTypeOfSymbol, getResolvedSymbol, getIndexTypeOfStructuredType, getConstraintFromTypeParameter, getFirstIdentifier) { + return getSymbolWalker; + function getSymbolWalker(accept) { + if (accept === void 0) { accept = function () { return true; }; } + var visitedTypes = ts.createMap(); + var visitedSymbols = ts.createMap(); + return { + walkType: function (type) { + visitedTypes.clear(); + visitedSymbols.clear(); + visitType(type); + return { visitedTypes: ts.arrayFrom(visitedTypes.values()), visitedSymbols: ts.arrayFrom(visitedSymbols.values()) }; + }, + walkSymbol: function (symbol) { + visitedTypes.clear(); + visitedSymbols.clear(); + visitSymbol(symbol); + return { visitedTypes: ts.arrayFrom(visitedTypes.values()), visitedSymbols: ts.arrayFrom(visitedSymbols.values()) }; + }, + }; + function visitType(type) { + if (!type) { + return; + } + var typeIdString = type.id.toString(); + if (visitedTypes.has(typeIdString)) { + return; + } + visitedTypes.set(typeIdString, type); + var shouldBail = visitSymbol(type.symbol); + if (shouldBail) + return; + if (type.flags & 32768) { + var objectType = type; + var objectFlags = objectType.objectFlags; + if (objectFlags & 4) { + visitTypeReference(type); + } + if (objectFlags & 32) { + visitMappedType(type); + } + if (objectFlags & (1 | 2)) { + visitInterfaceType(type); + } + if (objectFlags & (8 | 16)) { + visitObjectType(objectType); + } + } + if (type.flags & 16384) { + visitTypeParameter(type); + } + if (type.flags & 196608) { + visitUnionOrIntersectionType(type); + } + if (type.flags & 262144) { + visitIndexType(type); + } + if (type.flags & 524288) { + visitIndexedAccessType(type); + } + } + function visitTypeList(types) { + if (!types) { + return; + } + for (var i = 0; i < types.length; i++) { + visitType(types[i]); + } + } + function visitTypeReference(type) { + visitType(type.target); + visitTypeList(type.typeArguments); + } + function visitTypeParameter(type) { + visitType(getConstraintFromTypeParameter(type)); + } + function visitUnionOrIntersectionType(type) { + visitTypeList(type.types); + } + function visitIndexType(type) { + visitType(type.type); + } + function visitIndexedAccessType(type) { + visitType(type.objectType); + visitType(type.indexType); + visitType(type.constraint); + } + function visitMappedType(type) { + visitType(type.typeParameter); + visitType(type.constraintType); + visitType(type.templateType); + visitType(type.modifiersType); + } + function visitSignature(signature) { + if (signature.typePredicate) { + visitType(signature.typePredicate.type); + } + visitTypeList(signature.typeParameters); + for (var _i = 0, _a = signature.parameters; _i < _a.length; _i++) { + var parameter = _a[_i]; + visitSymbol(parameter); + } + visitType(getRestTypeOfSignature(signature)); + visitType(getReturnTypeOfSignature(signature)); + } + function visitInterfaceType(interfaceT) { + visitObjectType(interfaceT); + visitTypeList(interfaceT.typeParameters); + visitTypeList(getBaseTypes(interfaceT)); + visitType(interfaceT.thisType); + } + function visitObjectType(type) { + var stringIndexType = getIndexTypeOfStructuredType(type, 0); + visitType(stringIndexType); + var numberIndexType = getIndexTypeOfStructuredType(type, 1); + visitType(numberIndexType); + var resolved = resolveStructuredTypeMembers(type); + for (var _i = 0, _a = resolved.callSignatures; _i < _a.length; _i++) { + var signature = _a[_i]; + visitSignature(signature); + } + for (var _b = 0, _c = resolved.constructSignatures; _b < _c.length; _b++) { + var signature = _c[_b]; + visitSignature(signature); + } + for (var _d = 0, _e = resolved.properties; _d < _e.length; _d++) { + var p = _e[_d]; + visitSymbol(p); + } + } + function visitSymbol(symbol) { + if (!symbol) { + return; + } + var symbolIdString = ts.getSymbolId(symbol).toString(); + if (visitedSymbols.has(symbolIdString)) { + return; + } + visitedSymbols.set(symbolIdString, symbol); + if (!accept(symbol)) { + return true; + } + var t = getTypeOfSymbol(symbol); + visitType(t); + if (symbol.flags & 1952) { + symbol.exports.forEach(visitSymbol); + } + ts.forEach(symbol.declarations, function (d) { + if (d.type && d.type.kind === 162) { + var query = d.type; + var entity = getResolvedSymbol(getFirstIdentifier(query.exprName)); + visitSymbol(entity); + } + }); + } + } + } + ts.createGetSymbolWalker = createGetSymbolWalker; +})(ts || (ts = {})); +var ts; (function (ts) { var ambientModuleSymbolRegex = /^".+"$/; var nextSymbolId = 1; @@ -19437,6 +19607,9 @@ var ts; node = ts.getParseTreeNode(node, ts.isExportSpecifier); return node ? getExportSpecifierLocalTargetSymbol(node) : undefined; }, + getExportSymbolOfSymbol: function (symbol) { + return getMergedSymbol(symbol.exportSymbol || symbol); + }, getTypeAtLocation: function (node) { node = ts.getParseTreeNode(node); return node ? getTypeOfNode(node) : unknownType; @@ -19499,6 +19672,7 @@ var ts; getEmitResolver: getEmitResolver, getExportsOfModule: getExportsOfModuleAsArray, getExportsAndPropertiesOfModule: getExportsAndPropertiesOfModule, + getSymbolWalker: ts.createGetSymbolWalker(getRestTypeOfSignature, getReturnTypeOfSignature, getBaseTypes, resolveStructuredTypeMembers, getTypeOfSymbol, getResolvedSymbol, getIndexTypeOfStructuredType, getConstraintFromTypeParameter, getFirstIdentifier), getAmbientModules: getAmbientModules, getAllAttributesTypeFromJsxOpeningLikeElement: function (node) { node = ts.getParseTreeNode(node, ts.isJsxOpeningLikeElement); @@ -19519,11 +19693,10 @@ var ts; getSuggestionForNonexistentProperty: function (node, type) { return ts.unescapeLeadingUnderscores(getSuggestionForNonexistentProperty(node, type)); }, getSuggestionForNonexistentSymbol: function (location, name, meaning) { return ts.unescapeLeadingUnderscores(getSuggestionForNonexistentSymbol(location, ts.escapeLeadingUnderscores(name), meaning)); }, getBaseConstraintOfType: getBaseConstraintOfType, - getJsxNamespace: function () { return ts.unescapeLeadingUnderscores(getJsxNamespace()); }, - resolveNameAtLocation: function (location, name, meaning) { - location = ts.getParseTreeNode(location); - return resolveName(location, ts.escapeLeadingUnderscores(name), meaning, undefined, ts.escapeLeadingUnderscores(name)); + resolveName: function (name, location, meaning) { + return resolveName(location, ts.escapeLeadingUnderscores(name), meaning, undefined, undefined); }, + getJsxNamespace: function () { return ts.unescapeLeadingUnderscores(getJsxNamespace()); }, }; var tupleTypes = []; var unionTypes = ts.createMap(); @@ -20006,7 +20179,10 @@ var ts; } return true; } - if (usage.parent.kind === 246) { + if (usage.parent.kind === 246 || (usage.parent.kind === 243 && usage.parent.isExportEquals)) { + return true; + } + if (usage.kind === 243 && usage.isExportEquals) { return true; } var container = ts.getEnclosingBlockScopeContainer(declaration); @@ -20036,13 +20212,13 @@ var ts; current.parent.kind === 149 && current.parent.initializer === current; if (initializerOfProperty) { - if (ts.getModifierFlags(current.parent) & 32) { + if (ts.hasModifier(current.parent, 32)) { if (declaration.kind === 151) { return true; } } else { - var isDeclarationInstanceProperty = declaration.kind === 149 && !(ts.getModifierFlags(declaration) & 32); + var isDeclarationInstanceProperty = declaration.kind === 149 && !ts.hasModifier(declaration, 32); if (!isDeclarationInstanceProperty || ts.getContainingClass(usage) !== ts.getContainingClass(declaration)) { return true; } @@ -20122,7 +20298,7 @@ var ts; break; case 149: case 148: - if (ts.isClassLike(location.parent) && !(ts.getModifierFlags(location) & 32)) { + if (ts.isClassLike(location.parent) && !ts.hasModifier(location, 32)) { var ctor = findConstructorDeclaration(location.parent); if (ctor && ctor.locals) { if (lookup(ctor.locals, name, meaning & 107455)) { @@ -20139,7 +20315,7 @@ var ts; result = undefined; break; } - if (lastLocation && ts.getModifierFlags(lastLocation) & 32) { + if (lastLocation && ts.hasModifier(lastLocation, 32)) { error(errorLocation, ts.Diagnostics.Static_members_cannot_reference_class_type_parameters); return undefined; } @@ -20153,6 +20329,17 @@ var ts; } } break; + case 201: + if (lastLocation === location.expression && location.parent.token === 85) { + var container = location.parent.parent; + if (ts.isClassLike(container) && (result = lookup(getSymbolOfNode(container).members, name, meaning & 793064))) { + if (nameNotFoundMessage) { + error(errorLocation, ts.Diagnostics.Base_class_expressions_cannot_reference_class_type_parameters); + } + return undefined; + } + } + break; case 144: grandparent = location.parent.parent; if (ts.isClassLike(grandparent) || grandparent.kind === 230) { @@ -20199,7 +20386,7 @@ var ts; lastLocation = location; location = location.parent; } - if (result && nameNotFoundMessage && noUnusedIdentifiers) { + if (result && nameNotFoundMessage && noUnusedIdentifiers && result !== lastLocation.symbol) { result.isReferenced = true; } if (!result) { @@ -20280,7 +20467,7 @@ var ts; error(errorLocation, ts.Diagnostics.Cannot_find_name_0_Did_you_mean_the_static_member_1_0, diagnosticName(nameArg), symbolToString(classSymbol)); return true; } - if (location === container && !(ts.getModifierFlags(location) & 32)) { + if (location === container && !ts.hasModifier(location, 32)) { var instanceType = getDeclaredTypeOfSymbol(classSymbol).thisType; if (getPropertyOfType(instanceType, name)) { error(errorLocation, ts.Diagnostics.Cannot_find_name_0_Did_you_mean_the_instance_member_this_0, diagnosticName(nameArg)); @@ -20666,7 +20853,6 @@ var ts; if (ambientModule) { return ambientModule; } - var isRelative = ts.isExternalModuleNameRelative(moduleReference); var resolvedModule = ts.getResolvedModule(ts.getSourceFileOfNode(location), moduleReference); var resolutionDiagnostic = resolvedModule && ts.getResolutionDiagnostic(compilerOptions, resolvedModule); var sourceFile = resolvedModule && !resolutionDiagnostic && host.getSourceFile(resolvedModule.resolvedFileName); @@ -20685,7 +20871,7 @@ var ts; return getMergedSymbol(pattern.symbol); } } - if (!isRelative && resolvedModule && !ts.extensionIsTypeScript(resolvedModule.extension)) { + if (resolvedModule && resolvedModule.isExternalLibraryImport && !ts.extensionIsTypeScript(resolvedModule.extension)) { if (isForAugmentation) { var diag = ts.Diagnostics.Invalid_module_name_in_augmentation_Module_0_resolves_to_an_untyped_module_at_1_which_cannot_be_augmented; error(errorNode, diag, moduleReference, resolvedModule.resolvedFileName); @@ -21020,6 +21206,10 @@ var ts; } return false; } + function isTypeSymbolAccessible(typeSymbol, enclosingDeclaration) { + var access = isSymbolAccessible(typeSymbol, enclosingDeclaration, 793064, false); + return access.accessibility === 0; + } function isSymbolAccessible(symbol, enclosingDeclaration, meaning, shouldComputeAliasesToMakeVisible) { if (symbol && enclosingDeclaration && !(symbol.flags & 262144)) { var initialSymbol = symbol; @@ -21075,7 +21265,7 @@ var ts; if (!isDeclarationVisible(declaration)) { var anyImportSyntax = getAnyImportSyntax(declaration); if (anyImportSyntax && - !(ts.getModifierFlags(anyImportSyntax) & 1) && + !ts.hasModifier(anyImportSyntax, 1) && isDeclarationVisible(anyImportSyntax.parent)) { if (shouldComputeAliasToMakeVisible) { getNodeLinks(declaration).isVisible = true; @@ -21273,8 +21463,7 @@ var ts; var name = symbolToName(type.symbol, context, 793064, false); return ts.createTypeReferenceNode(name, undefined); } - if (!inTypeAlias && type.aliasSymbol && - isSymbolAccessible(type.aliasSymbol, context.enclosingDeclaration, 793064, false).accessibility === 0) { + if (!inTypeAlias && type.aliasSymbol && isTypeSymbolAccessible(type.aliasSymbol, context.enclosingDeclaration)) { var name = symbolToTypeReferenceName(type.aliasSymbol); var typeArgumentNodes = mapToTypeNodes(type.aliasTypeArguments, context); return ts.createTypeReferenceNode(name, typeArgumentNodes); @@ -21349,8 +21538,8 @@ var ts; return createTypeNodeFromObjectType(type); } function shouldWriteTypeOfFunctionSymbol() { - var isStaticMethodSymbol = !!(symbol.flags & 8192 && - ts.forEach(symbol.declarations, function (declaration) { return ts.getModifierFlags(declaration) & 32; })); + var isStaticMethodSymbol = !!(symbol.flags & 8192) && + ts.some(symbol.declarations, function (declaration) { return ts.hasModifier(declaration, 32); }); var isNonLocalFunctionSymbol = !!(symbol.flags & 16) && (symbol.parent || ts.forEach(symbol.declarations, function (declaration) { @@ -21362,10 +21551,8 @@ var ts; } } function createTypeNodeFromObjectType(type) { - if (type.objectFlags & 32) { - if (getConstraintTypeFromMappedType(type).flags & (16384 | 262144)) { - return createMappedTypeNodeFromType(type); - } + if (isGenericMappedType(type)) { + return createMappedTypeNodeFromType(type); } var resolved = resolveStructuredTypeMembers(type); if (!resolved.properties.length && !resolved.stringIndexInfo && !resolved.numberIndexInfo) { @@ -21893,7 +22080,7 @@ var ts; buildSymbolDisplay(type.symbol, writer, enclosingDeclaration, 793064, 0, nextFlags); } else if (!(flags & 1024) && type.aliasSymbol && - isSymbolAccessible(type.aliasSymbol, enclosingDeclaration, 793064, false).accessibility === 0) { + ((flags & 65536) || isTypeSymbolAccessible(type.aliasSymbol, enclosingDeclaration))) { var typeArguments = type.aliasTypeArguments; writeSymbolTypeReference(type.aliasSymbol, typeArguments, 0, ts.length(typeArguments), nextFlags); } @@ -22037,9 +22224,7 @@ var ts; if (!symbolStack) { symbolStack = []; } - var isConstructorObject = type.flags & 32768 && - getObjectFlags(type) & 16 && - type.symbol && type.symbol.flags & 32; + var isConstructorObject = type.objectFlags & 16 && type.symbol && type.symbol.flags & 32; if (isConstructorObject) { writeLiteralType(type, flags); } @@ -22054,16 +22239,16 @@ var ts; writeLiteralType(type, flags); } function shouldWriteTypeOfFunctionSymbol() { - var isStaticMethodSymbol = !!(symbol.flags & 8192 && - ts.forEach(symbol.declarations, function (declaration) { return ts.getModifierFlags(declaration) & 32; })); + var isStaticMethodSymbol = !!(symbol.flags & 8192) && + ts.some(symbol.declarations, function (declaration) { return ts.hasModifier(declaration, 32); }); var isNonLocalFunctionSymbol = !!(symbol.flags & 16) && (symbol.parent || - ts.forEach(symbol.declarations, function (declaration) { + ts.some(symbol.declarations, function (declaration) { return declaration.parent.kind === 265 || declaration.parent.kind === 234; })); if (isStaticMethodSymbol || isNonLocalFunctionSymbol) { return !!(flags & 4) || - (ts.contains(symbolStack, symbol)); + ts.contains(symbolStack, symbol); } } } @@ -22100,11 +22285,9 @@ var ts; return false; } function writeLiteralType(type, flags) { - if (type.objectFlags & 32) { - if (getConstraintTypeFromMappedType(type).flags & (16384 | 262144)) { - writeMappedType(type); - return; - } + if (isGenericMappedType(type)) { + writeMappedType(type); + return; } var resolved = resolveStructuredTypeMembers(type); if (!resolved.properties.length && !resolved.stringIndexInfo && !resolved.numberIndexInfo) { @@ -22472,7 +22655,7 @@ var ts; case 154: case 151: case 150: - if (ts.getModifierFlags(node) & (8 | 16)) { + if (ts.hasModifier(node, 8 | 16)) { return false; } case 152: @@ -23149,8 +23332,8 @@ var ts; } } function appendTypeParameters(typeParameters, declarations) { - for (var _i = 0, declarations_3 = declarations; _i < declarations_3.length; _i++) { - var declaration = declarations_3[_i]; + for (var _i = 0, declarations_2 = declarations; _i < declarations_2.length; _i++) { + var declaration = declarations_2[_i]; var tp = getDeclaredTypeOfTypeParameter(getSymbolOfNode(declaration)); if (!typeParameters) { typeParameters = [tp]; @@ -23274,7 +23457,7 @@ var ts; return type.resolvedBaseTypes; } function resolveBaseTypesOfClass(type) { - type.resolvedBaseTypes = type.resolvedBaseTypes || ts.emptyArray; + type.resolvedBaseTypes = ts.emptyArray; var baseConstructorType = getApparentType(getBaseConstructorTypeOfClass(type)); if (!(baseConstructorType.flags & (32768 | 131072 | 1))) { return; @@ -23316,12 +23499,7 @@ var ts; error(valueDecl, ts.Diagnostics.Type_0_recursively_references_itself_as_a_base_type, typeToString(type, undefined, 1)); return; } - if (type.resolvedBaseTypes === ts.emptyArray) { - type.resolvedBaseTypes = [baseType]; - } - else { - type.resolvedBaseTypes.push(baseType); - } + type.resolvedBaseTypes = [baseType]; } function areAllOuterTypeParametersApplied(type) { var outerTypeParameters = type.outerTypeParameters; @@ -23419,7 +23597,9 @@ var ts; if (!pushTypeResolution(symbol, 2)) { return unknownType; } - var declaration = ts.findDeclaration(symbol, function (d) { return d.kind === 283 || d.kind === 231; }); + var declaration = ts.find(symbol.declarations, function (d) { + return d.kind === 283 || d.kind === 231; + }); var type = getTypeFromTypeNode(declaration.kind === 283 ? declaration.typeExpression : declaration.type); if (popTypeResolution()) { var typeParameters = getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol); @@ -23911,17 +24091,12 @@ var ts; } else { var members = emptySymbols; - var constructSignatures = ts.emptyArray; var stringIndexInfo = undefined; if (symbol.exports) { members = getExportsOfSymbol(symbol); } if (symbol.flags & 32) { var classType = getDeclaredTypeOfClassOrInterface(symbol); - constructSignatures = getSignaturesOfSymbol(symbol.members.get("__constructor")); - if (!constructSignatures.length) { - constructSignatures = getDefaultConstructSignatures(classType); - } var baseConstructorType = getBaseConstructorTypeOfClass(classType); if (baseConstructorType.flags & (32768 | 131072 | 540672)) { members = ts.createSymbolTable(getNamedMembers(members)); @@ -23932,10 +24107,18 @@ var ts; } } var numberIndexInfo = symbol.flags & 384 ? enumNumberIndexInfo : undefined; - setStructuredTypeMembers(type, members, ts.emptyArray, constructSignatures, stringIndexInfo, numberIndexInfo); + setStructuredTypeMembers(type, members, ts.emptyArray, ts.emptyArray, stringIndexInfo, numberIndexInfo); if (symbol.flags & (16 | 8192)) { type.callSignatures = getSignaturesOfSymbol(symbol); } + if (symbol.flags & 32) { + var classType = getDeclaredTypeOfClassOrInterface(symbol); + var constructSignatures = getSignaturesOfSymbol(symbol.members.get("__constructor")); + if (!constructSignatures.length) { + constructSignatures = getDefaultConstructSignatures(classType); + } + type.constructSignatures = constructSignatures; + } } } function resolveMappedTypeMembers(type) { @@ -24018,8 +24201,7 @@ var ts; return getObjectFlags(type) & 32 && !!type.declaration.questionToken; } function isGenericMappedType(type) { - return getObjectFlags(type) & 32 && - maybeTypeOfKind(getConstraintTypeFromMappedType(type), 540672 | 262144); + return getObjectFlags(type) & 32 && isGenericIndexType(getConstraintTypeFromMappedType(type)); } function resolveStructuredTypeMembers(type) { if (!type.members) { @@ -24119,6 +24301,10 @@ var ts; return hasNonCircularBaseConstraint(typeParameter) ? getConstraintFromTypeParameter(typeParameter) : undefined; } function getConstraintOfIndexedAccess(type) { + var transformed = getTransformedIndexedAccessType(type); + if (transformed) { + return transformed; + } var baseObjectType = getBaseConstraintOfType(type.objectType); var baseIndexType = getBaseConstraintOfType(type.indexType); return baseObjectType || baseIndexType ? getIndexedAccessType(baseObjectType || type.objectType, baseIndexType || type.indexType) : undefined; @@ -24181,11 +24367,18 @@ var ts; return stringType; } if (t.flags & 524288) { + var transformed = getTransformedIndexedAccessType(t); + if (transformed) { + return getBaseConstraint(transformed); + } var baseObjectType = getBaseConstraint(t.objectType); var baseIndexType = getBaseConstraint(t.indexType); var baseIndexedAccess = baseObjectType && baseIndexType ? getIndexedAccessType(baseObjectType, baseIndexType) : undefined; return baseIndexedAccess && baseIndexedAccess !== unknownType ? getBaseConstraint(baseIndexedAccess) : undefined; } + if (isGenericMappedType(t)) { + return emptyObjectType; + } return t; } } @@ -24665,6 +24858,9 @@ var ts; } return signature.resolvedReturnType; } + function isResolvingReturnTypeOfSignature(signature) { + return !signature.resolvedReturnType && findResolutionCycleStartIndex(signature, 3) >= 0; + } function getRestTypeOfSignature(signature) { if (signature.hasRestParameter) { var type = getTypeOfSymbol(ts.lastOrUndefined(signature.parameters)); @@ -24733,7 +24929,7 @@ var ts; function getIndexInfoOfSymbol(symbol, kind) { var declaration = getIndexDeclarationOfSymbol(symbol, kind); if (declaration) { - return createIndexInfo(declaration.type ? getTypeFromTypeNode(declaration.type) : anyType, (ts.getModifierFlags(declaration) & 64) !== 0, declaration); + return createIndexInfo(declaration.type ? getTypeFromTypeNode(declaration.type) : anyType, ts.hasModifier(declaration, 64), declaration); } return undefined; } @@ -25001,8 +25197,8 @@ var ts; function getTypeOfGlobalSymbol(symbol, arity) { function getTypeDeclaration(symbol) { var declarations = symbol.declarations; - for (var _i = 0, declarations_4 = declarations; _i < declarations_4.length; _i++) { - var declaration = declarations_4[_i]; + for (var _i = 0, declarations_3 = declarations; _i < declarations_3.length; _i++) { + var declaration = declarations_3[_i]; switch (declaration.kind) { case 229: case 230: @@ -25459,17 +25655,16 @@ var ts; return getTypeOfSymbol(prop); } } - if (isTypeAnyOrAllConstituentTypesHaveKind(indexType, 262178 | 84 | 512)) { + if (!(indexType.flags & 6144) && isTypeAssignableToKind(indexType, 262178 | 84 | 512)) { if (isTypeAny(objectType)) { return anyType; } - var indexInfo = isTypeAnyOrAllConstituentTypesHaveKind(indexType, 84) && getIndexInfoOfType(objectType, 1) || + var indexInfo = isTypeAssignableToKind(indexType, 84) && getIndexInfoOfType(objectType, 1) || getIndexInfoOfType(objectType, 0) || undefined; if (indexInfo) { if (accessExpression && indexInfo.isReadonly && (ts.isAssignmentTarget(accessExpression) || ts.isDeleteTarget(accessExpression))) { error(accessExpression, ts.Diagnostics.Index_signature_in_type_0_only_permits_reading, typeToString(objectType)); - return unknownType; } return indexInfo.type; } @@ -25501,25 +25696,68 @@ var ts; return anyType; } function getIndexedAccessForMappedType(type, indexType, accessNode) { - var accessExpression = accessNode && accessNode.kind === 180 ? accessNode : undefined; - if (accessExpression && ts.isAssignmentTarget(accessExpression) && type.declaration.readonlyToken) { - error(accessExpression, ts.Diagnostics.Index_signature_in_type_0_only_permits_reading, typeToString(type)); - return unknownType; + if (accessNode) { + if (!isTypeAssignableTo(indexType, getIndexType(type))) { + error(accessNode, ts.Diagnostics.Type_0_cannot_be_used_to_index_type_1, typeToString(indexType), typeToString(type)); + return unknownType; + } + if (accessNode.kind === 180 && ts.isAssignmentTarget(accessNode) && type.declaration.readonlyToken) { + error(accessNode, ts.Diagnostics.Index_signature_in_type_0_only_permits_reading, typeToString(type)); + } } var mapper = createTypeMapper([getTypeParameterFromMappedType(type)], [indexType]); var templateMapper = type.mapper ? combineTypeMappers(type.mapper, mapper) : mapper; return instantiateType(getTemplateTypeFromMappedType(type), templateMapper); } + function isGenericObjectType(type) { + return type.flags & 540672 ? true : + getObjectFlags(type) & 32 ? isGenericIndexType(getConstraintTypeFromMappedType(type)) : + type.flags & 196608 ? ts.forEach(type.types, isGenericObjectType) : + false; + } + function isGenericIndexType(type) { + return type.flags & (540672 | 262144) ? true : + type.flags & 196608 ? ts.forEach(type.types, isGenericIndexType) : + false; + } + function isStringIndexOnlyType(type) { + if (type.flags & 32768 && !isGenericMappedType(type)) { + var t = resolveStructuredTypeMembers(type); + return t.properties.length === 0 && + t.callSignatures.length === 0 && t.constructSignatures.length === 0 && + t.stringIndexInfo && !t.numberIndexInfo; + } + return false; + } + function getTransformedIndexedAccessType(type) { + var objectType = type.objectType; + if (objectType.flags & 131072 && isGenericObjectType(objectType) && ts.some(objectType.types, isStringIndexOnlyType)) { + var regularTypes = []; + var stringIndexTypes = []; + for (var _i = 0, _a = objectType.types; _i < _a.length; _i++) { + var t = _a[_i]; + if (isStringIndexOnlyType(t)) { + stringIndexTypes.push(getIndexTypeOfType(t, 0)); + } + else { + regularTypes.push(t); + } + } + return getUnionType([ + getIndexedAccessType(getIntersectionType(regularTypes), type.indexType), + getIntersectionType(stringIndexTypes) + ]); + } + return undefined; + } function getIndexedAccessType(objectType, indexType, accessNode) { - if (maybeTypeOfKind(indexType, 540672 | 262144) || - maybeTypeOfKind(objectType, 540672) && !(accessNode && accessNode.kind === 180) || - isGenericMappedType(objectType)) { + if (isGenericMappedType(objectType)) { + return getIndexedAccessForMappedType(objectType, indexType, accessNode); + } + if (isGenericIndexType(indexType) || !(accessNode && accessNode.kind === 180) && isGenericObjectType(objectType)) { if (objectType.flags & 1) { return objectType; } - if (isGenericMappedType(objectType)) { - return getIndexedAccessForMappedType(objectType, indexType, accessNode); - } var id = objectType.id + "," + indexType.id; var type = indexedAccessTypes.get(id); if (!type) { @@ -25718,7 +25956,7 @@ var ts; var container = ts.getThisContainer(node, false); var parent = container && container.parent; if (parent && (ts.isClassLike(parent) || parent.kind === 230)) { - if (!(ts.getModifierFlags(container) & 32) && + if (!ts.hasModifier(container, 32) && (container.kind !== 152 || ts.isNodeDescendantOf(node, container.body))) { return getDeclaredTypeOfClassOrInterface(getSymbolOfNode(parent)).thisType; } @@ -25865,7 +26103,7 @@ var ts; } function cloneTypeMapper(mapper) { return mapper && isInferenceContext(mapper) ? - createInferenceContext(mapper.signature, mapper.flags | 2, mapper.inferences) : + createInferenceContext(mapper.signature, mapper.flags | 2, mapper.compareTypes, mapper.inferences) : mapper; } function identityMapper(type) { @@ -26129,11 +26367,13 @@ var ts; if (ts.forEach(node.parameters, function (p) { return !ts.getEffectiveTypeAnnotationNode(p); })) { return true; } - if (node.kind === 187) { - return false; + if (node.kind !== 187) { + var parameter = ts.firstOrUndefined(node.parameters); + if (!(parameter && ts.parameterIsThisKeyword(parameter))) { + return true; + } } - var parameter = ts.firstOrUndefined(node.parameters); - return !(parameter && ts.parameterIsThisKeyword(parameter)); + return node.body.kind === 207 ? false : isContextSensitive(node.body); } function isContextSensitiveFunctionOrObjectLiteralMethod(func) { return (isFunctionExpressionOrArrowFunction(func) || ts.isObjectLiteralMethod(func)) && isContextSensitiveFunctionLikeDeclaration(func); @@ -26196,7 +26436,7 @@ var ts; return 0; } if (source.typeParameters) { - source = instantiateSignatureInContextOf(source, target); + source = instantiateSignatureInContextOf(source, target, undefined, compareTypes); } var result = -1; var sourceThisType = getThisTypeOfSignature(source); @@ -26245,7 +26485,7 @@ var ts; var sourceReturnType = getReturnTypeOfSignature(source); if (target.typePredicate) { if (source.typePredicate) { - result &= compareTypePredicateRelatedTo(source.typePredicate, target.typePredicate, reportErrors, errorReporter, compareTypes); + result &= compareTypePredicateRelatedTo(source.typePredicate, target.typePredicate, source.declaration, target.declaration, reportErrors, errorReporter, compareTypes); } else if (ts.isIdentifierTypePredicate(target.typePredicate)) { if (reportErrors) { @@ -26261,7 +26501,7 @@ var ts; } return result; } - function compareTypePredicateRelatedTo(source, target, reportErrors, errorReporter, compareTypes) { + function compareTypePredicateRelatedTo(source, target, sourceDeclaration, targetDeclaration, reportErrors, errorReporter, compareTypes) { if (source.kind !== target.kind) { if (reportErrors) { errorReporter(ts.Diagnostics.A_this_based_type_guard_is_not_compatible_with_a_parameter_based_type_guard); @@ -26270,11 +26510,13 @@ var ts; return 0; } if (source.kind === 1) { - var sourceIdentifierPredicate = source; - var targetIdentifierPredicate = target; - if (sourceIdentifierPredicate.parameterIndex !== targetIdentifierPredicate.parameterIndex) { + var sourcePredicate = source; + var targetPredicate = target; + var sourceIndex = sourcePredicate.parameterIndex - (ts.getThisParameter(sourceDeclaration) ? 1 : 0); + var targetIndex = targetPredicate.parameterIndex - (ts.getThisParameter(targetDeclaration) ? 1 : 0); + if (sourceIndex !== targetIndex) { if (reportErrors) { - errorReporter(ts.Diagnostics.Parameter_0_is_not_in_the_same_position_as_parameter_1, sourceIdentifierPredicate.parameterName, targetIdentifierPredicate.parameterName); + errorReporter(ts.Diagnostics.Parameter_0_is_not_in_the_same_position_as_parameter_1, sourcePredicate.parameterName, targetPredicate.parameterName); errorReporter(ts.Diagnostics.Type_predicate_0_is_not_assignable_to_1, typePredicateToString(source), typePredicateToString(target)); } return 0; @@ -26419,8 +26661,7 @@ var ts; return true; } if (source.flags & 32768 && target.flags & 32768) { - var id = relation !== identityRelation || source.id < target.id ? source.id + "," + target.id : target.id + "," + source.id; - var related = relation.get(id); + var related = relation.get(getRelationKey(source, target, relation)); if (related !== undefined) { return related === 1; } @@ -26533,11 +26774,21 @@ var ts; !(target.flags & 65536) && !isIntersectionConstituent && source !== globalObjectType && - getPropertiesOfType(source).length > 0 && + (getPropertiesOfType(source).length > 0 || + getSignaturesOfType(source, 0).length > 0 || + getSignaturesOfType(source, 1).length > 0) && isWeakType(target) && !hasCommonProperties(source, target)) { if (reportErrors) { - reportError(ts.Diagnostics.Type_0_has_no_properties_in_common_with_type_1, typeToString(source), typeToString(target)); + var calls = getSignaturesOfType(source, 0); + var constructs = getSignaturesOfType(source, 1); + if (calls.length > 0 && isRelatedTo(getReturnTypeOfSignature(calls[0]), target, false) || + constructs.length > 0 && isRelatedTo(getReturnTypeOfSignature(constructs[0]), target, false)) { + reportError(ts.Diagnostics.Value_of_type_0_has_no_properties_in_common_with_type_1_Did_you_mean_to_call_it, typeToString(source), typeToString(target)); + } + else { + reportError(ts.Diagnostics.Type_0_has_no_properties_in_common_with_type_1, typeToString(source), typeToString(target)); + } } return 0; } @@ -26738,7 +26989,7 @@ var ts; if (overflow) { return 0; } - var id = relation !== identityRelation || source.id < target.id ? source.id + "," + target.id : target.id + "," + source.id; + var id = getRelationKey(source, target, relation); var related = relation.get(id); if (related !== undefined) { if (reportErrors && related === 2) { @@ -27158,6 +27409,9 @@ var ts; if (sourceInfo) { return indexInfoRelatedTo(sourceInfo, targetInfo, reportErrors); } + if (isGenericMappedType(source)) { + return kind === 0 && isRelatedTo(getTemplateTypeFromMappedType(source), targetInfo.type, reportErrors); + } if (isObjectLiteralType(source)) { var related = -1; if (kind === 0) { @@ -27191,8 +27445,8 @@ var ts; if (!sourceSignature.declaration || !targetSignature.declaration) { return true; } - var sourceAccessibility = ts.getModifierFlags(sourceSignature.declaration) & 24; - var targetAccessibility = ts.getModifierFlags(targetSignature.declaration) & 24; + var sourceAccessibility = ts.getSelectedModifierFlags(sourceSignature.declaration, 24); + var targetAccessibility = ts.getSelectedModifierFlags(targetSignature.declaration, 24); if (targetAccessibility === 8) { return true; } @@ -27208,6 +27462,42 @@ var ts; return false; } } + function isUnconstrainedTypeParameter(type) { + return type.flags & 16384 && !getConstraintFromTypeParameter(type); + } + function isTypeReferenceWithGenericArguments(type) { + return getObjectFlags(type) & 4 && ts.some(type.typeArguments, isUnconstrainedTypeParameter); + } + function getTypeReferenceId(type, typeParameters) { + var result = "" + type.target.id; + for (var _i = 0, _a = type.typeArguments; _i < _a.length; _i++) { + var t = _a[_i]; + if (isUnconstrainedTypeParameter(t)) { + var index = ts.indexOf(typeParameters, t); + if (index < 0) { + index = typeParameters.length; + typeParameters.push(t); + } + result += "=" + index; + } + else { + result += "-" + t.id; + } + } + return result; + } + function getRelationKey(source, target, relation) { + if (relation === identityRelation && source.id > target.id) { + var temp = source; + source = target; + target = temp; + } + if (isTypeReferenceWithGenericArguments(source) && isTypeReferenceWithGenericArguments(target)) { + var typeParameters = []; + return getTypeReferenceId(source, typeParameters) + "," + getTypeReferenceId(target, typeParameters); + } + return source.id + "," + target.id; + } function forEachProperty(prop, callback) { if (ts.getCheckFlags(prop) & 6) { for (var _i = 0, _a = prop.containingType.types; _i < _a.length; _i++) { @@ -27244,7 +27534,7 @@ var ts; var symbol = type.symbol; if (symbol && symbol.flags & 32) { var declaration = getClassLikeDeclarationOfSymbol(symbol); - if (declaration && ts.getModifierFlags(declaration) & 128) { + if (declaration && ts.hasModifier(declaration, 128)) { return true; } } @@ -27630,13 +27920,14 @@ var ts; callback(getTypeAtPosition(source, i), getTypeAtPosition(target, i)); } } - function createInferenceContext(signature, flags, baseInferences) { + function createInferenceContext(signature, flags, compareTypes, baseInferences) { var inferences = baseInferences ? ts.map(baseInferences, cloneInferenceInfo) : ts.map(signature.typeParameters, createInferenceInfo); var context = mapper; context.mappedTypes = signature.typeParameters; context.signature = signature; context.inferences = inferences; context.flags = flags; + context.compareTypes = compareTypes || compareTypesAssignable; return context; function mapper(t) { for (var i = 0; i < inferences.length; i++) { @@ -27724,6 +28015,19 @@ var ts; return inference.candidates && getUnionType(inference.candidates, true); } } + function isPossiblyAssignableTo(source, target) { + var properties = getPropertiesOfObjectType(target); + for (var _i = 0, properties_5 = properties; _i < properties_5.length; _i++) { + var targetProp = properties_5[_i]; + if (!(targetProp.flags & (16777216 | 4194304))) { + var sourceProp = getPropertyOfObjectType(source, targetProp.escapedName); + if (!sourceProp) { + return false; + } + } + } + return true; + } function inferTypes(inferences, originalSource, originalTarget, priority) { if (priority === void 0) { priority = 0; } var symbolStack; @@ -27884,15 +28188,17 @@ var ts; return; } } - inferFromProperties(source, target); - inferFromSignatures(source, target, 0); - inferFromSignatures(source, target, 1); - inferFromIndexTypes(source, target); + if (isPossiblyAssignableTo(source, target) || isPossiblyAssignableTo(target, source)) { + inferFromProperties(source, target); + inferFromSignatures(source, target, 0); + inferFromSignatures(source, target, 1); + inferFromIndexTypes(source, target); + } } function inferFromProperties(source, target) { var properties = getPropertiesOfObjectType(target); - for (var _i = 0, properties_5 = properties; _i < properties_5.length; _i++) { - var targetProp = properties_5[_i]; + for (var _i = 0, properties_6 = properties; _i < properties_6.length; _i++) { + var targetProp = properties_6[_i]; var sourceProp = getPropertyOfObjectType(source, targetProp.escapedName); if (sourceProp) { inferFromTypes(getTypeOfSymbol(sourceProp), getTypeOfSymbol(targetProp)); @@ -27991,7 +28297,7 @@ var ts; var constraint = getConstraintOfTypeParameter(context.signature.typeParameters[index]); if (constraint) { var instantiatedConstraint = instantiateType(constraint, context); - if (!isTypeAssignableTo(inferredType, getTypeWithThisArgument(instantiatedConstraint, inferredType))) { + if (!context.compareTypes(inferredType, getTypeWithThisArgument(instantiatedConstraint, inferredType))) { inference.inferredType = inferredType = instantiatedConstraint; } } @@ -28039,16 +28345,6 @@ var ts; } return undefined; } - function getLeftmostIdentifierOrThis(node) { - switch (node.kind) { - case 71: - case 99: - return node; - case 179: - return getLeftmostIdentifierOrThis(node.expression); - } - return undefined; - } function getBindingElementNameText(element) { if (element.parent.kind === 174) { var name = element.propertyName || element.name; @@ -28540,7 +28836,7 @@ var ts; parent.parent.operatorToken.kind === 58 && parent.parent.left === parent && !ts.isAssignmentTarget(parent.parent) && - isTypeAnyOrAllConstituentTypesHaveKind(getTypeOfExpression(parent.argumentExpression), 84 | 2048); + isTypeAssignableToKind(getTypeOfExpression(parent.argumentExpression), 84); return isLengthPushOrUnshift || isElementAssignment; } function maybeTypePredicateCall(node) { @@ -28686,7 +28982,7 @@ var ts; } else { var indexType = getTypeOfExpression(node.left.argumentExpression); - if (isTypeAnyOrAllConstituentTypesHaveKind(indexType, 84 | 2048)) { + if (isTypeAssignableToKind(indexType, 84)) { evolvedType_1 = addEvolvingArrayElementType(evolvedType_1, node.right); } } @@ -29372,7 +29668,7 @@ var ts; break; case 149: case 148: - if (ts.getModifierFlags(container) & 32) { + if (ts.hasModifier(container, 32)) { error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_static_property_initializer); } break; @@ -29463,14 +29759,14 @@ var ts; if (!isCallExpression && container.kind === 152) { checkThisBeforeSuper(node, container, ts.Diagnostics.super_must_be_called_before_accessing_a_property_of_super_in_the_constructor_of_a_derived_class); } - if ((ts.getModifierFlags(container) & 32) || isCallExpression) { + if (ts.hasModifier(container, 32) || isCallExpression) { nodeCheckFlag = 512; } else { nodeCheckFlag = 256; } getNodeLinks(node).flags |= nodeCheckFlag; - if (container.kind === 151 && ts.getModifierFlags(container) & 256) { + if (container.kind === 151 && ts.hasModifier(container, 256)) { if (ts.isSuperProperty(node.parent) && ts.isAssignmentTarget(node.parent)) { getNodeLinks(container).flags |= 4096; } @@ -29515,7 +29811,7 @@ var ts; } else { if (ts.isClassLike(container.parent) || container.parent.kind === 178) { - if (ts.getModifierFlags(container) & 32) { + if (ts.hasModifier(container, 32)) { return container.kind === 151 || container.kind === 150 || container.kind === 153 || @@ -29705,7 +30001,7 @@ var ts; return getReturnTypeOfSignature(getSignatureFromDeclaration(functionDecl)); } var signature = getContextualSignatureForFunctionLikeDeclaration(functionDecl); - if (signature) { + if (signature && !isResolvingReturnTypeOfSignature(signature)) { return getReturnTypeOfSignature(signature); } return undefined; @@ -29809,11 +30105,11 @@ var ts; return undefined; } if (ts.isJsxAttribute(node.parent)) { - return getTypeOfPropertyOfType(attributesType, node.parent.name.escapedText); + return getTypeOfPropertyOfContextualType(attributesType, node.parent.name.escapedText); } else if (node.parent.kind === 249) { var jsxChildrenPropertyName = getJsxElementChildrenPropertyname(); - return jsxChildrenPropertyName && jsxChildrenPropertyName !== "" ? getTypeOfPropertyOfType(attributesType, jsxChildrenPropertyName) : anyType; + return jsxChildrenPropertyName && jsxChildrenPropertyName !== "" ? getTypeOfPropertyOfContextualType(attributesType, jsxChildrenPropertyName) : anyType; } else { return attributesType; @@ -29825,7 +30121,7 @@ var ts; if (!attributesType || isTypeAny(attributesType)) { return undefined; } - return getTypeOfPropertyOfType(attributesType, attribute.name.escapedText); + return getTypeOfPropertyOfContextualType(attributesType, attribute.name.escapedText); } else { return attributesType; @@ -30041,10 +30337,7 @@ var ts; } } function isNumericComputedName(name) { - return isTypeAnyOrAllConstituentTypesHaveKind(checkComputedPropertyName(name), 84); - } - function isTypeAnyOrAllConstituentTypesHaveKind(type, kind) { - return isTypeAny(type) || isTypeOfKind(type, kind); + return isTypeAssignableToKind(checkComputedPropertyName(name), 84); } function isInfinityOrNaNString(name) { return name === "Infinity" || name === "-Infinity" || name === "NaN"; @@ -30056,7 +30349,9 @@ var ts; var links = getNodeLinks(node.expression); if (!links.resolvedType) { links.resolvedType = checkExpression(node.expression); - if (!isTypeAnyOrAllConstituentTypesHaveKind(links.resolvedType, 84 | 262178 | 512)) { + if (links.resolvedType.flags & 6144 || + !isTypeAssignableToKind(links.resolvedType, 262178 | 84 | 512) && + !isTypeAssignableTo(links.resolvedType, getUnionType([stringType, numberType, esSymbolType]))) { error(node, ts.Diagnostics.A_computed_property_name_must_be_of_type_string_number_symbol_or_any); } else { @@ -30541,9 +30836,7 @@ var ts; return undefined; } function resolveCustomJsxElementAttributesType(openingLikeElement, shouldIncludeAllStatelessAttributesType, elementType, elementClassType) { - if (!elementType) { - elementType = checkExpression(openingLikeElement.tagName); - } + if (elementType === void 0) { elementType = checkExpression(openingLikeElement.tagName); } if (elementType.flags & 65536) { var types = elementType.types; return getUnionType(types.map(function (type) { @@ -30638,11 +30931,12 @@ var ts; } function getCustomJsxElementAttributesType(node, shouldIncludeAllStatelessAttributesType) { var links = getNodeLinks(node); - if (!links.resolvedJsxElementAttributesType) { + var linkLocation = shouldIncludeAllStatelessAttributesType ? "resolvedJsxElementAllAttributesType" : "resolvedJsxElementAttributesType"; + if (!links[linkLocation]) { var elemClassType = getJsxGlobalElementClassType(); - return links.resolvedJsxElementAttributesType = resolveCustomJsxElementAttributesType(node, shouldIncludeAllStatelessAttributesType, undefined, elemClassType); + return links[linkLocation] = resolveCustomJsxElementAttributesType(node, shouldIncludeAllStatelessAttributesType, undefined, elemClassType); } - return links.resolvedJsxElementAttributesType; + return links[linkLocation]; } function getAllAttributesTypeFromJsxOpeningLikeElement(node) { if (isJsxIntrinsicIdentifier(node.tagName)) { @@ -30869,9 +31163,12 @@ var ts; } var prop = getPropertyOfType(apparentType, right.escapedText); if (!prop) { - var stringIndexType = getIndexTypeOfType(apparentType, 0); - if (stringIndexType) { - return stringIndexType; + var indexInfo = getIndexInfoOfType(apparentType, 0); + if (indexInfo && indexInfo.type) { + if (indexInfo.isReadonly && (ts.isAssignmentTarget(node) || ts.isDeleteTarget(node))) { + error(node, ts.Diagnostics.Index_signature_in_type_0_only_permits_reading, typeToString(apparentType)); + } + return indexInfo.type; } if (right.escapedText && !checkAndReportErrorForExtendingInterface(node)) { reportNonexistentProperty(right, type.flags & 16384 && type.isThisType ? apparentType : type); @@ -30998,7 +31295,7 @@ var ts; if (prop && noUnusedIdentifiers && (prop.flags & 106500) && - prop.valueDeclaration && (ts.getModifierFlags(prop.valueDeclaration) & 8)) { + prop.valueDeclaration && ts.hasModifier(prop.valueDeclaration, 8)) { if (ts.getCheckFlags(prop) & 1) { getSymbolLinks(prop).target.isReferenced = true; } @@ -31269,8 +31566,8 @@ var ts; } return undefined; } - function instantiateSignatureInContextOf(signature, contextualSignature, contextualMapper) { - var context = createInferenceContext(signature, 1); + function instantiateSignatureInContextOf(signature, contextualSignature, contextualMapper, compareTypes) { + var context = createInferenceContext(signature, 1, compareTypes); forEachMatchingParameterType(contextualSignature, signature, function (source, target) { inferTypes(context.inferences, instantiateType(source, contextualMapper || identityMapper), target); }); @@ -31500,7 +31797,7 @@ var ts; return getLiteralType(element.name.text); case 144: var nameType = checkComputedPropertyName(element.name); - if (isTypeOfKind(nameType, 512)) { + if (isTypeAssignableToKind(nameType, 512)) { return nameType; } else { @@ -31593,9 +31890,10 @@ var ts; return resolveErrorCall(node); } var args = getEffectiveCallArguments(node); + var isSingleNonGenericCandidate = candidates.length === 1 && !candidates[0].typeParameters; var excludeArgument; var excludeCount = 0; - if (!isDecorator) { + if (!isDecorator && !isSingleNonGenericCandidate) { for (var i = isTaggedTemplate ? 1 : 0; i < args.length; i++) { if (isContextSensitive(args[i])) { if (!excludeArgument) { @@ -31687,6 +31985,17 @@ var ts; if (signatureHelpTrailingComma === void 0) { signatureHelpTrailingComma = false; } candidateForArgumentError = undefined; candidateForTypeArgumentError = undefined; + if (isSingleNonGenericCandidate) { + var candidate = candidates[0]; + if (!hasCorrectArity(node, args, candidate, signatureHelpTrailingComma)) { + return undefined; + } + if (!checkApplicableSignature(node, args, candidate, relation, excludeArgument, false)) { + candidateForArgumentError = candidate; + return undefined; + } + return candidate; + } for (var candidateIndex = 0; candidateIndex < candidates.length; candidateIndex++) { var originalCandidate = candidates[candidateIndex]; if (!hasCorrectArity(node, args, originalCandidate, signatureHelpTrailingComma)) { @@ -31817,7 +32126,7 @@ var ts; return resolveErrorCall(node); } var valueDecl = expressionType.symbol && getClassLikeDeclarationOfSymbol(expressionType.symbol); - if (valueDecl && ts.getModifierFlags(valueDecl) & 128) { + if (valueDecl && ts.hasModifier(valueDecl, 128)) { error(node, ts.Diagnostics.Cannot_create_an_instance_of_the_abstract_class_0, ts.declarationNameToString(ts.getNameOfDeclaration(valueDecl))); return resolveErrorCall(node); } @@ -31853,8 +32162,8 @@ var ts; return true; } var declaration = signature.declaration; - var modifiers = ts.getModifierFlags(declaration); - if (!(modifiers & 24)) { + var modifiers = ts.getSelectedModifierFlags(declaration, 24); + if (!modifiers) { return true; } var declaringClassDeclaration = getClassLikeDeclarationOfSymbol(declaration.parent.symbol); @@ -32008,7 +32317,7 @@ var ts; && getSymbolLinks(type.symbol).inferredClassType === type; } function checkCallExpression(node) { - checkGrammarTypeArguments(node, node.typeArguments) || checkGrammarArguments(node, node.arguments); + checkGrammarTypeArguments(node, node.typeArguments) || checkGrammarArguments(node.arguments); var signature = getResolvedSignature(node); if (node.expression.kind === 97) { return voidType; @@ -32041,7 +32350,7 @@ var ts; return getReturnTypeOfSignature(signature); } function checkImportCallExpression(node) { - checkGrammarArguments(node, node.arguments) || checkGrammarImportCallExpression(node); + checkGrammarArguments(node.arguments) || checkGrammarImportCallExpression(node); if (node.arguments.length === 0) { return createPromiseReturnType(node, anyType); } @@ -32057,11 +32366,33 @@ var ts; if (moduleSymbol) { var esModuleSymbol = resolveESModuleSymbol(moduleSymbol, specifier, true); if (esModuleSymbol) { - return createPromiseReturnType(node, getTypeOfSymbol(esModuleSymbol)); + return createPromiseReturnType(node, getTypeWithSyntheticDefaultImportType(getTypeOfSymbol(esModuleSymbol), esModuleSymbol)); } } return createPromiseReturnType(node, anyType); } + function getTypeWithSyntheticDefaultImportType(type, symbol) { + if (allowSyntheticDefaultImports && type && type !== unknownType) { + var synthType = type; + if (!synthType.syntheticType) { + if (!getPropertyOfType(type, "default")) { + var memberTable = ts.createSymbolTable(); + var newSymbol = createSymbol(2097152, "default"); + newSymbol.target = resolveSymbol(symbol); + memberTable.set("default", newSymbol); + var anonymousSymbol = createSymbol(2048, "__type"); + var defaultContainingObject = createAnonymousType(anonymousSymbol, memberTable, ts.emptyArray, ts.emptyArray, undefined, undefined); + anonymousSymbol.type = defaultContainingObject; + synthType.syntheticType = getIntersectionType([type, defaultContainingObject]); + } + else { + synthType.syntheticType = type; + } + } + return synthType.syntheticType; + } + return type; + } function isCommonJsRequire(node) { if (!ts.isRequireCall(node, true)) { return false; @@ -32180,15 +32511,15 @@ var ts; } } } - function assignBindingElementTypes(node) { - if (ts.isBindingPattern(node.name)) { - for (var _i = 0, _a = node.name.elements; _i < _a.length; _i++) { - var element = _a[_i]; - if (!ts.isOmittedExpression(element)) { - if (element.name.kind === 71) { - getSymbolLinks(getSymbolOfNode(element)).type = getTypeForBindingElement(element); - } - assignBindingElementTypes(element); + function assignBindingElementTypes(pattern) { + for (var _i = 0, _a = pattern.elements; _i < _a.length; _i++) { + var element = _a[_i]; + if (!ts.isOmittedExpression(element)) { + if (element.name.kind === 71) { + getSymbolLinks(getSymbolOfNode(element)).type = getTypeForBindingElement(element); + } + else { + assignBindingElementTypes(element.name); } } } @@ -32197,12 +32528,13 @@ var ts; var links = getSymbolLinks(parameter); if (!links.type) { links.type = contextualType; - var name = ts.getNameOfDeclaration(parameter.valueDeclaration); - if (links.type === emptyObjectType && - (name.kind === 174 || name.kind === 175)) { - links.type = getTypeFromBindingPattern(name); + var decl = parameter.valueDeclaration; + if (decl.name.kind !== 71) { + if (links.type === emptyObjectType) { + links.type = getTypeFromBindingPattern(decl.name); + } + assignBindingElementTypes(decl.name); } - assignBindingElementTypes(parameter.valueDeclaration); } } function createPromiseType(promisedType) { @@ -32403,14 +32735,14 @@ var ts; } function checkFunctionExpressionOrObjectLiteralMethod(node, checkMode) { ts.Debug.assert(node.kind !== 151 || ts.isObjectLiteralMethod(node)); - var hasGrammarError = checkGrammarFunctionLikeDeclaration(node); - if (!hasGrammarError && node.kind === 186) { - checkGrammarForGenerator(node); - } if (checkMode === 1 && isContextSensitive(node)) { checkNodeDeferred(node); return anyFunctionType; } + var hasGrammarError = checkGrammarFunctionLikeDeclaration(node); + if (!hasGrammarError && node.kind === 186) { + checkGrammarForGenerator(node); + } var links = getNodeLinks(node); var type = getTypeOfSymbol(node.symbol); if (!(links.flags & 1024)) { @@ -32480,7 +32812,7 @@ var ts; } } function checkArithmeticOperandType(operand, type, diagnostic) { - if (!isTypeAnyOrAllConstituentTypesHaveKind(type, 84)) { + if (!isTypeAssignableToKind(type, 84)) { error(operand, diagnostic); return false; } @@ -32568,8 +32900,13 @@ var ts; if (operandType === silentNeverType) { return silentNeverType; } - if (node.operator === 38 && node.operand.kind === 8) { - return getFreshTypeOfLiteralType(getLiteralType(-node.operand.text)); + if (node.operand.kind === 8) { + if (node.operator === 38) { + return getFreshTypeOfLiteralType(getLiteralType(-node.operand.text)); + } + else if (node.operator === 37) { + return getFreshTypeOfLiteralType(getLiteralType(+node.operand.text)); + } } switch (node.operator) { case 37: @@ -32621,30 +32958,22 @@ var ts; } return false; } - function isTypeOfKind(type, kind) { - if (type.flags & kind) { + function isTypeAssignableToKind(source, kind, strict) { + if (source.flags & kind) { return true; } - if (type.flags & 65536) { - var types = type.types; - for (var _i = 0, types_18 = types; _i < types_18.length; _i++) { - var t = types_18[_i]; - if (!isTypeOfKind(t, kind)) { - return false; - } - } - return true; + if (strict && source.flags & (1 | 1024 | 2048 | 4096)) { + return false; } - if (type.flags & 131072) { - var types = type.types; - for (var _a = 0, types_19 = types; _a < types_19.length; _a++) { - var t = types_19[_a]; - if (isTypeOfKind(t, kind)) { - return true; - } - } - } - return false; + return (kind & 84 && isTypeAssignableTo(source, numberType)) || + (kind & 262178 && isTypeAssignableTo(source, stringType)) || + (kind & 136 && isTypeAssignableTo(source, booleanType)) || + (kind & 1024 && isTypeAssignableTo(source, voidType)) || + (kind & 8192 && isTypeAssignableTo(source, neverType)) || + (kind & 4096 && isTypeAssignableTo(source, nullType)) || + (kind & 2048 && isTypeAssignableTo(source, undefinedType)) || + (kind & 512 && isTypeAssignableTo(source, esSymbolType)) || + (kind & 16777216 && isTypeAssignableTo(source, nonPrimitiveType)); } function isConstEnumObjectType(type) { return getObjectFlags(type) & 16 && type.symbol && isConstEnumSymbol(type.symbol); @@ -32656,7 +32985,7 @@ var ts; if (leftType === silentNeverType || rightType === silentNeverType) { return silentNeverType; } - if (isTypeOfKind(leftType, 8190)) { + if (!isTypeAny(leftType) && isTypeAssignableToKind(leftType, 8190)) { error(left, ts.Diagnostics.The_left_hand_side_of_an_instanceof_expression_must_be_of_type_any_an_object_type_or_a_type_parameter); } if (!(isTypeAny(rightType) || @@ -32673,18 +33002,18 @@ var ts; } leftType = checkNonNullType(leftType, left); rightType = checkNonNullType(rightType, right); - if (!(isTypeComparableTo(leftType, stringType) || isTypeOfKind(leftType, 84 | 512))) { + if (!(isTypeComparableTo(leftType, stringType) || isTypeAssignableToKind(leftType, 84 | 512))) { error(left, ts.Diagnostics.The_left_hand_side_of_an_in_expression_must_be_of_type_any_string_number_or_symbol); } - if (!isTypeAnyOrAllConstituentTypesHaveKind(rightType, 32768 | 540672 | 16777216)) { + if (!isTypeAssignableToKind(rightType, 16777216 | 540672)) { error(right, ts.Diagnostics.The_right_hand_side_of_an_in_expression_must_be_of_type_any_an_object_type_or_a_type_parameter); } return booleanType; } function checkObjectLiteralAssignment(node, sourceType) { var properties = node.properties; - for (var _i = 0, properties_6 = properties; _i < properties_6.length; _i++) { - var p = properties_6[_i]; + for (var _i = 0, properties_7 = properties; _i < properties_7.length; _i++) { + var p = properties_7[_i]; checkObjectLiteralDestructuringPropertyAssignment(sourceType, p, properties); } return sourceType; @@ -32940,24 +33269,22 @@ var ts; if (leftType === silentNeverType || rightType === silentNeverType) { return silentNeverType; } - if (!isTypeOfKind(leftType, 1 | 262178) && !isTypeOfKind(rightType, 1 | 262178)) { + if (!isTypeAssignableToKind(leftType, 262178) && !isTypeAssignableToKind(rightType, 262178)) { leftType = checkNonNullType(leftType, left); rightType = checkNonNullType(rightType, right); } var resultType = void 0; - if (isTypeOfKind(leftType, 84) && isTypeOfKind(rightType, 84)) { + if (isTypeAssignableToKind(leftType, 84, true) && isTypeAssignableToKind(rightType, 84, true)) { resultType = numberType; } - else { - if (isTypeOfKind(leftType, 262178) || isTypeOfKind(rightType, 262178)) { - resultType = stringType; - } - else if (isTypeAny(leftType) || isTypeAny(rightType)) { - resultType = leftType === unknownType || rightType === unknownType ? unknownType : anyType; - } - if (resultType && !checkForDisallowedESSymbolOperand(operator)) { - return resultType; - } + else if (isTypeAssignableToKind(leftType, 262178, true) || isTypeAssignableToKind(rightType, 262178, true)) { + resultType = stringType; + } + else if (isTypeAny(leftType) || isTypeAny(rightType)) { + resultType = leftType === unknownType || rightType === unknownType ? unknownType : anyType; + } + if (resultType && !checkForDisallowedESSymbolOperand(operator)) { + return resultType; } if (!resultType) { reportOperatorError(); @@ -33122,13 +33449,12 @@ var ts; return getBestChoiceType(type1, type2); } function checkLiteralExpression(node) { - if (node.kind === 8) { - checkGrammarNumericLiteral(node); - } switch (node.kind) { + case 13: case 9: return getFreshTypeOfLiteralType(getLiteralType(node.text)); case 8: + checkGrammarNumericLiteral(node); return getFreshTypeOfLiteralType(getLiteralType(+node.text)); case 101: return trueType; @@ -33276,6 +33602,7 @@ var ts; return checkSuperExpression(node); case 95: return nullWideningType; + case 13: case 9: case 8: case 101: @@ -33283,8 +33610,6 @@ var ts; return checkLiteralExpression(node); case 196: return checkTemplateExpression(node); - case 13: - return stringType; case 12: return globalRegExpType; case 177: @@ -33375,7 +33700,7 @@ var ts; checkGrammarDecorators(node) || checkGrammarModifiers(node); checkVariableLikeDeclaration(node); var func = ts.getContainingFunction(node); - if (ts.getModifierFlags(node) & 92) { + if (ts.hasModifier(node, 92)) { func = ts.getContainingFunction(node); if (!(func.kind === 152 && ts.nodeIsPresent(func.body))) { error(node, ts.Diagnostics.A_parameter_property_is_only_allowed_in_a_constructor_implementation); @@ -33565,7 +33890,7 @@ var ts; } } else { - var isStatic = ts.getModifierFlags(member) & 32; + var isStatic = ts.hasModifier(member, 32); var names = isStatic ? staticNames : instanceNames; var memberName = member.name && ts.getPropertyNameForPropertyNameNode(member.name); if (memberName) { @@ -33610,7 +33935,7 @@ var ts; for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; var memberNameNode = member.name; - var isStatic = ts.getModifierFlags(member) & 32; + var isStatic = ts.hasModifier(member, 32); if (isStatic && memberNameNode) { var memberName = ts.getPropertyNameForPropertyNameNode(memberNameNode); switch (memberName) { @@ -33698,7 +34023,7 @@ var ts; function checkMethodDeclaration(node) { checkGrammarMethod(node) || checkGrammarComputedPropertyName(node.name); checkFunctionOrMethodDeclaration(node); - if (ts.getModifierFlags(node) & 128 && node.body) { + if (ts.hasModifier(node, 128) && node.body) { error(node, ts.Diagnostics.Method_0_cannot_have_an_implementation_because_it_is_marked_abstract, ts.declarationNameToString(node.name)); } } @@ -33734,17 +34059,9 @@ var ts; } return ts.forEachChild(n, containsSuperCall); } - function markThisReferencesAsErrors(n) { - if (n.kind === 99) { - error(n, ts.Diagnostics.this_cannot_be_referenced_in_current_location); - } - else if (n.kind !== 186 && n.kind !== 228) { - ts.forEachChild(n, markThisReferencesAsErrors); - } - } function isInstancePropertyWithInitializer(n) { return n.kind === 149 && - !(ts.getModifierFlags(n) & 32) && + !ts.hasModifier(n, 32) && !!n.initializer; } var containingClassDecl = node.parent; @@ -33756,8 +34073,8 @@ var ts; if (classExtendsNull) { error(superCall, ts.Diagnostics.A_constructor_cannot_contain_a_super_call_when_its_class_extends_null); } - var superCallShouldBeFirst = ts.forEach(node.parent.members, isInstancePropertyWithInitializer) || - ts.forEach(node.parameters, function (p) { return ts.getModifierFlags(p) & 92; }); + var superCallShouldBeFirst = ts.some(node.parent.members, isInstancePropertyWithInitializer) || + ts.some(node.parameters, function (p) { return ts.hasModifier(p, 92); }); if (superCallShouldBeFirst) { var statements = node.body.statements; var superCallStatement = void 0; @@ -33800,10 +34117,12 @@ var ts; var otherKind = node.kind === 153 ? 154 : 153; var otherAccessor = ts.getDeclarationOfKind(node.symbol, otherKind); if (otherAccessor) { - if ((ts.getModifierFlags(node) & 28) !== (ts.getModifierFlags(otherAccessor) & 28)) { + var nodeFlags = ts.getModifierFlags(node); + var otherFlags = ts.getModifierFlags(otherAccessor); + if ((nodeFlags & 28) !== (otherFlags & 28)) { error(node.name, ts.Diagnostics.Getter_and_setter_accessors_do_not_agree_in_visibility); } - if (ts.hasModifier(node, 128) !== ts.hasModifier(otherAccessor, 128)) { + if ((nodeFlags & 128) !== (otherFlags & 128)) { error(node.name, ts.Diagnostics.Accessors_must_both_be_abstract_or_non_abstract); } checkAccessorDeclarationTypesIdentical(node, otherAccessor, getAnnotatedAccessorType, ts.Diagnostics.get_and_set_accessor_must_have_the_same_type); @@ -33849,7 +34168,7 @@ var ts; function checkTypeReferenceNode(node) { checkGrammarTypeArguments(node, node.typeArguments); if (node.kind === 159 && node.typeName.jsdocDotPos !== undefined && !ts.isInJavaScriptFile(node) && !ts.isInJSDoc(node)) { - grammarErrorAtPos(ts.getSourceFileOfNode(node), node.typeName.jsdocDotPos, 1, ts.Diagnostics.JSDoc_types_can_only_be_used_inside_documentation_comments); + grammarErrorAtPos(node, node.typeName.jsdocDotPos, 1, ts.Diagnostics.JSDoc_types_can_only_be_used_inside_documentation_comments); } var type = getTypeFromTypeReference(node); if (type !== unknownType) { @@ -33857,7 +34176,14 @@ var ts; ts.forEach(node.typeArguments, checkSourceElement); if (produceDiagnostics) { var symbol = getNodeLinks(node).resolvedSymbol; - var typeParameters = symbol.flags & 524288 ? getSymbolLinks(symbol).typeParameters : type.target.localTypeParameters; + if (!symbol) { + error(node, ts.Diagnostics.Type_0_is_not_generic, typeToString(type)); + return; + } + var typeParameters = symbol.flags & 524288 && getSymbolLinks(symbol).typeParameters; + if (!typeParameters && getObjectFlags(type) & 4) { + typeParameters = type.target.localTypeParameters; + } checkTypeArgumentConstraints(typeParameters, node.typeArguments); } } @@ -33900,16 +34226,15 @@ var ts; if (isTypeAssignableTo(indexType, getIndexType(objectType))) { return type; } - if (maybeTypeOfKind(objectType, 540672) && isTypeOfKind(indexType, 84)) { - var constraint = getBaseConstraintOfType(objectType); - if (constraint && getIndexInfoOfType(constraint, 1)) { - return type; - } + if (getIndexInfoOfType(getApparentType(objectType), 1) && isTypeAssignableToKind(indexType, 84)) { + return type; } error(accessNode, ts.Diagnostics.Type_0_cannot_be_used_to_index_type_1, typeToString(indexType), typeToString(objectType)); return type; } function checkIndexedAccessType(node) { + checkSourceElement(node.objectType); + checkSourceElement(node.indexType); checkIndexedAccessIndexType(getTypeFromIndexedAccessTypeNode(node), node); } function checkMappedType(node) { @@ -33920,7 +34245,7 @@ var ts; checkTypeAssignableTo(constraintType, stringType, node.typeParameter.constraint); } function isPrivateWithinAmbient(node) { - return (ts.getModifierFlags(node) & 8) && ts.isInAmbientContext(node); + return ts.hasModifier(node, 8) && ts.isInAmbientContext(node); } function getEffectiveDeclarationFlags(n, flagsToCheck) { var flags = ts.getCombinedModifierFlags(n); @@ -34007,9 +34332,9 @@ var ts; (ts.isComputedPropertyName(node.name) && ts.isComputedPropertyName(subsequentName) || !ts.isComputedPropertyName(node.name) && !ts.isComputedPropertyName(subsequentName) && ts.getEscapedTextOfIdentifierOrLiteral(node.name) === ts.getEscapedTextOfIdentifierOrLiteral(subsequentName))) { var reportError = (node.kind === 151 || node.kind === 150) && - (ts.getModifierFlags(node) & 32) !== (ts.getModifierFlags(subsequentNode) & 32); + ts.hasModifier(node, 32) !== ts.hasModifier(subsequentNode, 32); if (reportError) { - var diagnostic = ts.getModifierFlags(node) & 32 ? ts.Diagnostics.Function_overload_must_be_static : ts.Diagnostics.Function_overload_must_not_be_static; + var diagnostic = ts.hasModifier(node, 32) ? ts.Diagnostics.Function_overload_must_be_static : ts.Diagnostics.Function_overload_must_not_be_static; error(errorNode_1, diagnostic); } return; @@ -34025,7 +34350,7 @@ var ts; error(errorNode, ts.Diagnostics.Constructor_implementation_is_missing); } else { - if (ts.getModifierFlags(node) & 128) { + if (ts.hasModifier(node, 128)) { error(errorNode, ts.Diagnostics.All_declarations_of_an_abstract_method_must_be_consecutive); } else { @@ -34035,8 +34360,8 @@ var ts; } var duplicateFunctionDeclaration = false; var multipleConstructorImplementation = false; - for (var _i = 0, declarations_5 = declarations; _i < declarations_5.length; _i++) { - var current = declarations_5[_i]; + for (var _i = 0, declarations_4 = declarations; _i < declarations_4.length; _i++) { + var current = declarations_4[_i]; var node = current; var inAmbientContext = ts.isInAmbientContext(node); var inAmbientContextOrInterface = node.parent.kind === 230 || node.parent.kind === 163 || inAmbientContext; @@ -34085,7 +34410,7 @@ var ts; }); } if (lastSeenNonAmbientDeclaration && !lastSeenNonAmbientDeclaration.body && - !(ts.getModifierFlags(lastSeenNonAmbientDeclaration) & 128) && !lastSeenNonAmbientDeclaration.questionToken) { + !ts.hasModifier(lastSeenNonAmbientDeclaration, 128) && !lastSeenNonAmbientDeclaration.questionToken) { reportImplementationExpectedError(lastSeenNonAmbientDeclaration); } if (hasOverloads) { @@ -34494,7 +34819,7 @@ var ts; if (!ts.hasDynamicName(node)) { var symbol = getSymbolOfNode(node); var localSymbol = node.localSymbol || symbol; - var firstDeclaration = ts.find(localSymbol.declarations, function (declaration) { return declaration.kind === node.kind && !ts.isSourceFileJavaScript(ts.getSourceFileOfNode(declaration)); }); + var firstDeclaration = ts.find(localSymbol.declarations, function (declaration) { return declaration.kind === node.kind && !(declaration.flags & 65536); }); if (node === firstDeclaration) { checkFunctionOrConstructorSymbol(localSymbol); } @@ -34629,14 +34954,14 @@ var ts; for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; if (member.kind === 151 || member.kind === 149) { - if (!member.symbol.isReferenced && ts.getModifierFlags(member) & 8) { + if (!member.symbol.isReferenced && ts.hasModifier(member, 8)) { error(member.name, ts.Diagnostics._0_is_declared_but_never_used, ts.unescapeLeadingUnderscores(member.symbol.escapedName)); } } else if (member.kind === 152) { for (var _b = 0, _c = member.parameters; _b < _c.length; _b++) { var parameter = _c[_b]; - if (!parameter.symbol.isReferenced && ts.getModifierFlags(parameter) & 8) { + if (!parameter.symbol.isReferenced && ts.hasModifier(parameter, 8)) { error(parameter.name, ts.Diagnostics.Property_0_is_declared_but_never_used, ts.unescapeLeadingUnderscores(parameter.symbol.escapedName)); } } @@ -34976,7 +35301,7 @@ var ts; 128 | 64 | 32; - return (ts.getModifierFlags(left) & interestingFlags) === (ts.getModifierFlags(right) & interestingFlags); + return ts.getSelectedModifierFlags(left, interestingFlags) === ts.getSelectedModifierFlags(right, interestingFlags); } function checkVariableDeclaration(node) { checkGrammarVariableDeclaration(node); @@ -35106,7 +35431,7 @@ var ts; checkReferenceExpression(varExpr, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_must_be_a_variable_or_a_property_access); } } - if (!isTypeAnyOrAllConstituentTypesHaveKind(rightType, 32768 | 540672 | 16777216)) { + if (!isTypeAssignableToKind(rightType, 16777216 | 540672)) { error(node.expression, ts.Diagnostics.The_right_hand_side_of_a_for_in_statement_must_be_of_type_any_an_object_type_or_a_type_parameter); } checkSourceElement(node.statement); @@ -35478,7 +35803,7 @@ var ts; var classDeclaration = type.symbol.valueDeclaration; for (var _i = 0, _a = classDeclaration.members; _i < _a.length; _i++) { var member = _a[_i]; - if (!(ts.getModifierFlags(member) & 32) && ts.hasDynamicName(member)) { + if (!ts.hasModifier(member, 32) && ts.hasDynamicName(member)) { var propType = getTypeOfSymbol(member.symbol); checkIndexConstraintForProperty(member.symbol, propType, type, declaredStringIndexer, stringIndexType, 0); checkIndexConstraintForProperty(member.symbol, propType, type, declaredNumberIndexer, numberIndexType, 1); @@ -35575,8 +35900,8 @@ var ts; var type = getDeclaredTypeOfSymbol(symbol); if (!areTypeParametersIdentical(declarations, type.localTypeParameters)) { var name = symbolToString(symbol); - for (var _i = 0, declarations_6 = declarations; _i < declarations_6.length; _i++) { - var declaration = declarations_6[_i]; + for (var _i = 0, declarations_5 = declarations; _i < declarations_5.length; _i++) { + var declaration = declarations_5[_i]; error(declaration.name, ts.Diagnostics.All_declarations_of_0_must_have_identical_type_parameters, name); } } @@ -35585,8 +35910,8 @@ var ts; function areTypeParametersIdentical(declarations, typeParameters) { var maxTypeArgumentCount = ts.length(typeParameters); var minTypeArgumentCount = getMinTypeArgumentCount(typeParameters); - for (var _i = 0, declarations_7 = declarations; _i < declarations_7.length; _i++) { - var declaration = declarations_7[_i]; + for (var _i = 0, declarations_6 = declarations; _i < declarations_6.length; _i++) { + var declaration = declarations_6[_i]; var numTypeParameters = ts.length(declaration.typeParameters); if (numTypeParameters < minTypeArgumentCount || numTypeParameters > maxTypeArgumentCount) { return false; @@ -35622,7 +35947,7 @@ var ts; registerForUnusedIdentifiersCheck(node); } function checkClassDeclaration(node) { - if (!node.name && !(ts.getModifierFlags(node) & 512)) { + if (!node.name && !ts.hasModifier(node, 512)) { grammarErrorOnFirstToken(node, ts.Diagnostics.A_class_declaration_without_the_default_modifier_must_have_a_name); } checkClassLikeDeclaration(node); @@ -35715,7 +36040,7 @@ var ts; var signatures = getSignaturesOfType(type, 1); if (signatures.length) { var declaration = signatures[0].declaration; - if (declaration && ts.getModifierFlags(declaration) & 8) { + if (declaration && ts.hasModifier(declaration, 8)) { var typeClassDeclaration = getClassLikeDeclarationOfSymbol(type.symbol); if (!isNodeWithinClass(node, typeClassDeclaration)) { error(node, ts.Diagnostics.Cannot_extend_a_class_0_Class_constructor_is_marked_as_private, getFullyQualifiedName(type.symbol)); @@ -35748,7 +36073,7 @@ var ts; if (derived) { if (derived === base) { var derivedClassDecl = getClassLikeDeclarationOfSymbol(type.symbol); - if (baseDeclarationFlags & 128 && (!derivedClassDecl || !(ts.getModifierFlags(derivedClassDecl) & 128))) { + if (baseDeclarationFlags & 128 && (!derivedClassDecl || !ts.hasModifier(derivedClassDecl, 128))) { if (derivedClassDecl.kind === 199) { error(derivedClassDecl, ts.Diagnostics.Non_abstract_class_expression_does_not_implement_inherited_abstract_member_0_from_class_1, symbolToString(baseProperty), typeToString(baseType)); } @@ -35796,8 +36121,8 @@ var ts; for (var _i = 0, baseTypes_2 = baseTypes; _i < baseTypes_2.length; _i++) { var base = baseTypes_2[_i]; var properties = getPropertiesOfType(getTypeWithThisArgument(base, type.thisType)); - for (var _a = 0, properties_7 = properties; _a < properties_7.length; _a++) { - var prop = properties_7[_a]; + for (var _a = 0, properties_8 = properties; _a < properties_8.length; _a++) { + var prop = properties_8[_a]; var existing = seen.get(prop.escapedName); if (!existing) { seen.set(prop.escapedName, { prop: prop, containingType: base }); @@ -36051,8 +36376,8 @@ var ts; } function getFirstNonAmbientClassOrFunctionDeclaration(symbol) { var declarations = symbol.declarations; - for (var _i = 0, declarations_8 = declarations; _i < declarations_8.length; _i++) { - var declaration = declarations_8[_i]; + for (var _i = 0, declarations_7 = declarations; _i < declarations_7.length; _i++) { + var declaration = declarations_7[_i]; if ((declaration.kind === 229 || (declaration.kind === 228 && ts.nodeIsPresent(declaration.body))) && !ts.isInAmbientContext(declaration)) { @@ -36267,7 +36592,7 @@ var ts; if (checkGrammarModuleElementContext(node, ts.Diagnostics.An_import_declaration_can_only_be_used_in_a_namespace_or_module)) { return; } - if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && ts.getModifierFlags(node) !== 0) { + if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && ts.hasModifiers(node)) { grammarErrorOnFirstToken(node, ts.Diagnostics.An_import_declaration_cannot_have_modifiers); } if (checkExternalImportOrExportDeclaration(node)) { @@ -36294,7 +36619,7 @@ var ts; checkGrammarDecorators(node) || checkGrammarModifiers(node); if (ts.isInternalModuleImportEqualsDeclaration(node) || checkExternalImportOrExportDeclaration(node)) { checkImportBinding(node); - if (ts.getModifierFlags(node) & 1) { + if (ts.hasModifier(node, 1)) { markExportAsReferenced(node); } if (ts.isInternalModuleImportEqualsDeclaration(node)) { @@ -36322,7 +36647,7 @@ var ts; if (checkGrammarModuleElementContext(node, ts.Diagnostics.An_export_declaration_can_only_be_used_in_a_module)) { return; } - if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && ts.getModifierFlags(node) !== 0) { + if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && ts.hasModifiers(node)) { grammarErrorOnFirstToken(node, ts.Diagnostics.An_export_declaration_cannot_have_modifiers); } if (!node.moduleSpecifier || checkExternalImportOrExportDeclaration(node)) { @@ -36380,7 +36705,7 @@ var ts; } return; } - if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && ts.getModifierFlags(node) !== 0) { + if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && ts.hasModifiers(node)) { grammarErrorOnFirstToken(node, ts.Diagnostics.An_export_assignment_cannot_have_modifiers); } if (node.expression.kind === 71) { @@ -36427,8 +36752,8 @@ var ts; return; } if (exportedDeclarationsCount > 1) { - for (var _i = 0, declarations_9 = declarations; _i < declarations_9.length; _i++) { - var declaration = declarations_9[_i]; + for (var _i = 0, declarations_8 = declarations; _i < declarations_8.length; _i++) { + var declaration = declarations_8[_i]; if (isNotOverload(declaration)) { diagnostics.add(ts.createDiagnosticForNode(declaration, ts.Diagnostics.Cannot_redeclare_exported_variable_0, ts.unescapeLeadingUnderscores(id))); } @@ -36706,7 +37031,7 @@ var ts; return []; } var symbols = ts.createSymbolTable(); - var memberFlags = 0; + var isStatic = false; populateSymbols(); return symbolsToArray(symbols); function populateSymbols() { @@ -36728,7 +37053,7 @@ var ts; } case 229: case 230: - if (!(memberFlags & 32)) { + if (!isStatic) { copySymbols(getSymbolOfNode(location).members, meaning & 793064); } break; @@ -36742,7 +37067,7 @@ var ts; if (ts.introducesArgumentsExoticObject(location)) { copySymbol(argumentsSymbol, meaning); } - memberFlags = ts.getModifierFlags(location); + isStatic = ts.hasModifier(location, 32); location = location.parent; } copySymbols(globals, meaning); @@ -36977,12 +37302,7 @@ var ts; case 8: if (node.parent.kind === 180 && node.parent.argumentExpression === node) { var objectType = getTypeOfExpression(node.parent.expression); - if (objectType === unknownType) - return undefined; - var apparentType = getApparentType(objectType); - if (apparentType === unknownType) - return undefined; - return getPropertyOfType(apparentType, node.text); + return getPropertyOfType(objectType, node.text); } break; } @@ -37078,7 +37398,7 @@ var ts; } function getParentTypeOfClassElement(node) { var classSymbol = getSymbolOfNode(node.parent); - return ts.getModifierFlags(node) & 32 + return ts.hasModifier(node, 32) ? getTypeOfSymbol(classSymbol) : getDeclaredTypeOfSymbol(classSymbol); } @@ -37303,13 +37623,13 @@ var ts; return strictNullChecks && !isOptionalParameter(parameter) && parameter.initializer && - !(ts.getModifierFlags(parameter) & 92); + !ts.hasModifier(parameter, 92); } function isOptionalUninitializedParameterProperty(parameter) { return strictNullChecks && isOptionalParameter(parameter) && !parameter.initializer && - !!(ts.getModifierFlags(parameter) & 92); + ts.hasModifier(parameter, 92); } function getNodeCheckFlags(node) { return getNodeLinks(node).flags; @@ -37365,22 +37685,22 @@ var ts; else if (type.flags & 1) { return ts.TypeReferenceSerializationKind.ObjectType; } - else if (isTypeOfKind(type, 1024 | 6144 | 8192)) { + else if (isTypeAssignableToKind(type, 1024 | 6144 | 8192)) { return ts.TypeReferenceSerializationKind.VoidNullableOrNeverType; } - else if (isTypeOfKind(type, 136)) { + else if (isTypeAssignableToKind(type, 136)) { return ts.TypeReferenceSerializationKind.BooleanType; } - else if (isTypeOfKind(type, 84)) { + else if (isTypeAssignableToKind(type, 84)) { return ts.TypeReferenceSerializationKind.NumberLikeType; } - else if (isTypeOfKind(type, 262178)) { + else if (isTypeAssignableToKind(type, 262178)) { return ts.TypeReferenceSerializationKind.StringLikeType; } else if (isTupleType(type)) { return ts.TypeReferenceSerializationKind.ArrayLikeType; } - else if (isTypeOfKind(type, 512)) { + else if (isTypeAssignableToKind(type, 512)) { return ts.TypeReferenceSerializationKind.ESSymbolType; } else if (isFunctionType(type)) { @@ -37845,7 +38165,7 @@ var ts; node.kind !== 154) { return grammarErrorOnNode(modifier, ts.Diagnostics.abstract_modifier_can_only_appear_on_a_class_method_or_property_declaration); } - if (!(node.parent.kind === 229 && ts.getModifierFlags(node.parent) & 128)) { + if (!(node.parent.kind === 229 && ts.hasModifier(node.parent, 128))) { return grammarErrorOnNode(modifier, ts.Diagnostics.Abstract_methods_can_only_appear_within_an_abstract_class); } if (flags & 32) { @@ -37964,8 +38284,7 @@ var ts; if (list && list.hasTrailingComma) { var start = list.end - ",".length; var end = list.end; - var sourceFile = ts.getSourceFileOfNode(list[0]); - return grammarErrorAtPos(sourceFile, start, end - start, ts.Diagnostics.Trailing_comma_not_allowed); + return grammarErrorAtPos(list[0], start, end - start, ts.Diagnostics.Trailing_comma_not_allowed); } } function checkGrammarTypeParameterList(typeParameters, file) { @@ -38041,7 +38360,7 @@ var ts; if (parameter.dotDotDotToken) { return grammarErrorOnNode(parameter.dotDotDotToken, ts.Diagnostics.An_index_signature_cannot_have_a_rest_parameter); } - if (ts.getModifierFlags(parameter) !== 0) { + if (ts.hasModifiers(parameter)) { return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_cannot_have_an_accessibility_modifier); } if (parameter.questionToken) { @@ -38075,19 +38394,18 @@ var ts; return checkGrammarForDisallowedTrailingComma(typeArguments) || checkGrammarForAtLeastOneTypeArgument(node, typeArguments); } - function checkGrammarForOmittedArgument(node, args) { + function checkGrammarForOmittedArgument(args) { if (args) { - var sourceFile = ts.getSourceFileOfNode(node); for (var _i = 0, args_5 = args; _i < args_5.length; _i++) { var arg = args_5[_i]; if (arg.kind === 200) { - return grammarErrorAtPos(sourceFile, arg.pos, 0, ts.Diagnostics.Argument_expression_expected); + return grammarErrorAtPos(arg, arg.pos, 0, ts.Diagnostics.Argument_expression_expected); } } } } - function checkGrammarArguments(node, args) { - return checkGrammarForOmittedArgument(node, args); + function checkGrammarArguments(args) { + return checkGrammarForOmittedArgument(args); } function checkGrammarHeritageClause(node) { var types = node.types; @@ -38096,8 +38414,7 @@ var ts; } if (types && types.length === 0) { var listType = ts.tokenToString(node.token); - var sourceFile = ts.getSourceFileOfNode(node); - return grammarErrorAtPos(sourceFile, types.pos, 0, ts.Diagnostics._0_list_cannot_be_empty, listType); + return grammarErrorAtPos(node, types.pos, 0, ts.Diagnostics._0_list_cannot_be_empty, listType); } return ts.forEach(types, checkGrammarExpressionWithTypeArguments); } @@ -38320,10 +38637,10 @@ var ts; else if (ts.isInAmbientContext(accessor)) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.An_accessor_cannot_be_declared_in_an_ambient_context); } - else if (accessor.body === undefined && !(ts.getModifierFlags(accessor) & 128)) { - return grammarErrorAtPos(ts.getSourceFileOfNode(accessor), accessor.end - 1, ";".length, ts.Diagnostics._0_expected, "{"); + else if (accessor.body === undefined && !ts.hasModifier(accessor, 128)) { + return grammarErrorAtPos(accessor, accessor.end - 1, ";".length, ts.Diagnostics._0_expected, "{"); } - else if (accessor.body && ts.getModifierFlags(accessor) & 128) { + else if (accessor.body && ts.hasModifier(accessor, 128)) { return grammarErrorOnNode(accessor, ts.Diagnostics.An_abstract_accessor_cannot_have_an_implementation); } else if (accessor.typeParameters) { @@ -38376,7 +38693,7 @@ var ts; return true; } else if (node.body === undefined) { - return grammarErrorAtPos(ts.getSourceFileOfNode(node), node.end - 1, ";".length, ts.Diagnostics._0_expected, "{"); + return grammarErrorAtPos(node, node.end - 1, ";".length, ts.Diagnostics._0_expected, "{"); } } if (ts.isClassLike(node.parent)) { @@ -38447,7 +38764,7 @@ var ts; return grammarErrorOnNode(node.name, ts.Diagnostics.A_rest_element_cannot_contain_a_binding_pattern); } if (node.initializer) { - return grammarErrorAtPos(ts.getSourceFileOfNode(node), node.initializer.pos - 1, 1, ts.Diagnostics.A_rest_element_cannot_have_an_initializer); + return grammarErrorAtPos(node, node.initializer.pos - 1, 1, ts.Diagnostics.A_rest_element_cannot_have_an_initializer); } } } @@ -38467,12 +38784,12 @@ var ts; } else { var equalsTokenLength = "=".length; - return grammarErrorAtPos(ts.getSourceFileOfNode(node), node.initializer.pos - equalsTokenLength, equalsTokenLength, ts.Diagnostics.Initializers_are_not_allowed_in_ambient_contexts); + return grammarErrorAtPos(node, node.initializer.pos - equalsTokenLength, equalsTokenLength, ts.Diagnostics.Initializers_are_not_allowed_in_ambient_contexts); } } if (node.initializer && !(ts.isConst(node) && isStringOrNumberLiteralExpression(node.initializer))) { var equalsTokenLength = "=".length; - return grammarErrorAtPos(ts.getSourceFileOfNode(node), node.initializer.pos - equalsTokenLength, equalsTokenLength, ts.Diagnostics.Initializers_are_not_allowed_in_ambient_contexts); + return grammarErrorAtPos(node, node.initializer.pos - equalsTokenLength, equalsTokenLength, ts.Diagnostics.Initializers_are_not_allowed_in_ambient_contexts); } } else if (!node.initializer) { @@ -38529,7 +38846,7 @@ var ts; return true; } if (!declarationList.declarations.length) { - return grammarErrorAtPos(ts.getSourceFileOfNode(declarationList), declarations.pos, declarations.end - declarations.pos, ts.Diagnostics.Variable_declaration_list_cannot_be_empty); + return grammarErrorAtPos(declarationList, declarations.pos, declarations.end - declarations.pos, ts.Diagnostics.Variable_declaration_list_cannot_be_empty); } } function allowLetAndConstDeclarations(parent) { @@ -38575,7 +38892,8 @@ var ts; return true; } } - function grammarErrorAtPos(sourceFile, start, length, message, arg0, arg1, arg2) { + function grammarErrorAtPos(nodeForSourceFile, start, length, message, arg0, arg1, arg2) { + var sourceFile = ts.getSourceFileOfNode(nodeForSourceFile); if (!hasParseDiagnostics(sourceFile)) { diagnostics.add(ts.createFileDiagnostic(sourceFile, start, length, message, arg0, arg1, arg2)); return true; @@ -38590,7 +38908,7 @@ var ts; } function checkGrammarConstructorTypeParameters(node) { if (node.typeParameters) { - return grammarErrorAtPos(ts.getSourceFileOfNode(node), node.typeParameters.pos, node.typeParameters.end - node.typeParameters.pos, ts.Diagnostics.Type_parameters_cannot_appear_on_a_constructor_declaration); + return grammarErrorAtPos(node, node.typeParameters.pos, node.typeParameters.end - node.typeParameters.pos, ts.Diagnostics.Type_parameters_cannot_appear_on_a_constructor_declaration); } } function checkGrammarConstructorTypeAnnotation(node) { @@ -38632,7 +38950,7 @@ var ts; node.kind === 244 || node.kind === 243 || node.kind === 236 || - ts.getModifierFlags(node) & (2 | 1 | 512)) { + ts.hasModifier(node, 2 | 1 | 512)) { return false; } return grammarErrorOnFirstToken(node, ts.Diagnostics.A_declare_modifier_is_required_for_a_top_level_declaration_in_a_d_ts_file); @@ -41401,27 +41719,27 @@ var ts; function createExpressionForAccessorDeclaration(properties, property, receiver, multiLine) { var _a = ts.getAllAccessorDeclarations(properties, property), firstAccessor = _a.firstAccessor, getAccessor = _a.getAccessor, setAccessor = _a.setAccessor; if (property === firstAccessor) { - var properties_8 = []; + var properties_9 = []; if (getAccessor) { var getterFunction = ts.createFunctionExpression(getAccessor.modifiers, undefined, undefined, undefined, getAccessor.parameters, undefined, getAccessor.body); ts.setTextRange(getterFunction, getAccessor); ts.setOriginalNode(getterFunction, getAccessor); var getter = ts.createPropertyAssignment("get", getterFunction); - properties_8.push(getter); + properties_9.push(getter); } if (setAccessor) { var setterFunction = ts.createFunctionExpression(setAccessor.modifiers, undefined, undefined, undefined, setAccessor.parameters, undefined, setAccessor.body); ts.setTextRange(setterFunction, setAccessor); ts.setOriginalNode(setterFunction, setAccessor); var setter = ts.createPropertyAssignment("set", setterFunction); - properties_8.push(setter); + properties_9.push(setter); } - properties_8.push(ts.createPropertyAssignment("enumerable", ts.createTrue())); - properties_8.push(ts.createPropertyAssignment("configurable", ts.createTrue())); + properties_9.push(ts.createPropertyAssignment("enumerable", ts.createTrue())); + properties_9.push(ts.createPropertyAssignment("configurable", ts.createTrue())); var expression = ts.setTextRange(ts.createCall(ts.createPropertyAccess(ts.createIdentifier("Object"), "defineProperty"), undefined, [ receiver, createExpressionForPropertyName(property.name), - ts.createObjectLiteral(properties_8, multiLine) + ts.createObjectLiteral(properties_9, multiLine) ]), firstAccessor); return ts.aggregateTransformFlags(expression); } @@ -43361,7 +43679,8 @@ var ts; ? undefined : numElements, location), false, location); } - else if (numElements !== 1 && (flattenContext.level < 1 || numElements === 0)) { + else if (numElements !== 1 && (flattenContext.level < 1 || numElements === 0) + || ts.every(elements, ts.isOmittedExpression)) { var reuseIdentifierExpressions = !ts.isDeclarationBindingElement(parent) || numElements !== 0; value = ensureIdentifier(flattenContext, value, reuseIdentifierExpressions, location); } @@ -43568,7 +43887,12 @@ var ts; if (ts.hasModifier(node, 2)) { break; } - recordEmittedDeclarationInScope(node); + if (node.name) { + recordEmittedDeclarationInScope(node); + } + else { + ts.Debug.assert(node.kind === 229 || ts.hasModifier(node, 512)); + } break; } } @@ -43982,8 +44306,8 @@ var ts; && member.initializer !== undefined; } function addInitializedPropertyStatements(statements, properties, receiver) { - for (var _i = 0, properties_9 = properties; _i < properties_9.length; _i++) { - var property = properties_9[_i]; + for (var _i = 0, properties_10 = properties; _i < properties_10.length; _i++) { + var property = properties_10[_i]; var statement = ts.createStatement(transformInitializedProperty(property, receiver)); ts.setSourceMapRange(statement, ts.moveRangePastModifiers(property)); ts.setCommentRange(statement, property); @@ -43992,8 +44316,8 @@ var ts; } function generateInitializedPropertyExpressions(properties, receiver) { var expressions = []; - for (var _i = 0, properties_10 = properties; _i < properties_10.length; _i++) { - var property = properties_10[_i]; + for (var _i = 0, properties_11 = properties; _i < properties_11.length; _i++) { + var property = properties_11[_i]; var expression = transformInitializedProperty(property, receiver); expression.startsOnNewLine = true; ts.setSourceMapRange(expression, ts.moveRangePastModifiers(property)); @@ -44688,24 +45012,24 @@ var ts; && moduleKind !== ts.ModuleKind.System); } function recordEmittedDeclarationInScope(node) { - var name = node.symbol && node.symbol.escapedName; - if (name) { - if (!currentScopeFirstDeclarationsOfName) { - currentScopeFirstDeclarationsOfName = ts.createUnderscoreEscapedMap(); - } - if (!currentScopeFirstDeclarationsOfName.has(name)) { - currentScopeFirstDeclarationsOfName.set(name, node); - } + if (!currentScopeFirstDeclarationsOfName) { + currentScopeFirstDeclarationsOfName = ts.createUnderscoreEscapedMap(); + } + var name = declaredNameInScope(node); + if (!currentScopeFirstDeclarationsOfName.has(name)) { + currentScopeFirstDeclarationsOfName.set(name, node); } } function isFirstEmittedDeclarationInScope(node) { if (currentScopeFirstDeclarationsOfName) { - var name = node.symbol && node.symbol.escapedName; - if (name) { - return currentScopeFirstDeclarationsOfName.get(name) === node; - } + var name = declaredNameInScope(node); + return currentScopeFirstDeclarationsOfName.get(name) === node; } - return false; + return true; + } + function declaredNameInScope(node) { + ts.Debug.assertNode(node.name, ts.isIdentifier); + return node.name.escapedText; } function addVarForEnumOrModuleDeclaration(statements, node) { var statement = ts.createVariableStatement(ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), ts.createVariableDeclarationList([ @@ -44736,7 +45060,7 @@ var ts; if (!shouldEmitModuleDeclaration(node)) { return ts.createNotEmittedStatement(node); } - ts.Debug.assert(ts.isIdentifier(node.name), "TypeScript module should have an Identifier name."); + ts.Debug.assertNode(node.name, ts.isIdentifier, "A TypeScript namespace should have an Identifier name."); enableSubstitutionForNamespaceExports(); var statements = []; var emitFlags = 2; @@ -45460,6 +45784,8 @@ var ts; return visitExpressionStatement(node); case 185: return visitParenthesizedExpression(node, noDestructuringValue); + case 260: + return visitCatchClause(node); default: return ts.visitEachChild(node, visitor, context); } @@ -45534,6 +45860,12 @@ var ts; function visitParenthesizedExpression(node, noDestructuringValue) { return ts.visitEachChild(node, noDestructuringValue ? visitorNoDestructuringValue : visitor, context); } + function visitCatchClause(node) { + if (!node.variableDeclaration) { + return ts.updateCatchClause(node, ts.createVariableDeclaration(ts.createTempVariable(undefined)), ts.visitNode(node.block, visitor, ts.isBlock)); + } + return ts.visitEachChild(node, visitor, context); + } function visitBinaryExpression(node, noDestructuringValue) { if (ts.isDestructuringAssignment(node) && node.left.transformFlags & 1048576) { return ts.flattenDestructuringAssignment(node, visitor, context, 1, !noDestructuringValue); @@ -45980,7 +46312,7 @@ var ts; objectProperties = ts.createAssignHelper(context, segments); } } - var element = ts.createExpressionForJsxElement(context.getEmitResolver().getJsxFactoryEntity(), compilerOptions.reactNamespace, tagName, objectProperties, ts.filter(ts.map(children, transformJsxChildToExpression), ts.isDefined), node, location); + var element = ts.createExpressionForJsxElement(context.getEmitResolver().getJsxFactoryEntity(), compilerOptions.reactNamespace, tagName, objectProperties, ts.mapDefined(children, transformJsxChildToExpression), node, location); if (isChild) { ts.startOnNewLine(element); } @@ -46567,7 +46899,7 @@ var ts; function shouldVisitNode(node) { return (node.transformFlags & 128) !== 0 || convertedLoopState !== undefined - || (hierarchyFacts & 4096 && ts.isStatement(node)) + || (hierarchyFacts & 4096 && (ts.isStatement(node) || (node.kind === 207))) || (ts.isIterationStatement(node, false) && shouldConvertIterationStatementBody(node)) || isTypeScriptClassWrapper(node); } @@ -46847,9 +47179,11 @@ var ts; var outer = ts.createPartiallyEmittedExpression(inner); outer.end = ts.skipTrivia(currentText, node.pos); ts.setEmitFlags(outer, 1536); - return ts.createParen(ts.createCall(outer, undefined, extendsClauseElement + var result = ts.createParen(ts.createCall(outer, undefined, extendsClauseElement ? [ts.visitNode(extendsClauseElement.expression, visitor, ts.isExpression)] : [])); + ts.addSyntheticLeadingComment(result, 3, "* @class "); + return result; } function transformClassBody(node, extendsClauseElement) { var statements = []; @@ -47434,11 +47768,12 @@ var ts; ts.setTextRange(declarationList, node); ts.setCommentRange(declarationList, node); if (node.transformFlags & 8388608 - && (ts.isBindingPattern(node.declarations[0].name) - || ts.isBindingPattern(ts.lastOrUndefined(node.declarations).name))) { + && (ts.isBindingPattern(node.declarations[0].name) || ts.isBindingPattern(ts.lastOrUndefined(node.declarations).name))) { var firstDeclaration = ts.firstOrUndefined(declarations); - var lastDeclaration = ts.lastOrUndefined(declarations); - ts.setSourceMapRange(declarationList, ts.createRange(firstDeclaration.pos, lastDeclaration.end)); + if (firstDeclaration) { + var lastDeclaration = ts.lastOrUndefined(declarations); + ts.setSourceMapRange(declarationList, ts.createRange(firstDeclaration.pos, lastDeclaration.end)); + } } return declarationList; } @@ -47977,6 +48312,7 @@ var ts; function visitCatchClause(node) { var ancestorFacts = enterSubtree(4032, 0); var updated; + ts.Debug.assert(!!node.variableDeclaration, "Catch clause variable should always be present when downleveling ES2015."); if (ts.isBindingPattern(node.variableDeclaration.name)) { var temp = ts.createTempVariable(undefined); var newVariableDeclaration = ts.createVariableDeclaration(temp); @@ -49224,8 +49560,12 @@ var ts; } function transformAndEmitContinueStatement(node) { var label = findContinueTarget(node.label ? ts.unescapeLeadingUnderscores(node.label.escapedText) : undefined); - ts.Debug.assert(label > 0, "Expected continue statment to point to a valid Label."); - emitBreak(label, node); + if (label > 0) { + emitBreak(label, node); + } + else { + emitStatement(node); + } } function visitContinueStatement(node) { if (inStatementContainingYield) { @@ -49238,8 +49578,12 @@ var ts; } function transformAndEmitBreakStatement(node) { var label = findBreakTarget(node.label ? ts.unescapeLeadingUnderscores(node.label.escapedText) : undefined); - ts.Debug.assert(label > 0, "Expected break statment to point to a valid Label."); - emitBreak(label, node); + if (label > 0) { + emitBreak(label, node); + } + else { + emitStatement(node); + } } function visitBreakStatement(node) { if (inStatementContainingYield) { @@ -49496,9 +49840,6 @@ var ts; var block = endBlock(); markLabel(block.endLabel); } - function isWithBlock(block) { - return block.kind === 1; - } function beginExceptionBlock() { var startLabel = defineLabel(); var endLabel = defineLabel(); @@ -49567,9 +49908,6 @@ var ts; emitNop(); exception.state = 3; } - function isExceptionBlock(block) { - return block.kind === 0; - } function beginScriptLoopBlock() { beginBlock({ kind: 3, @@ -49669,43 +50007,45 @@ var ts; return false; } function findBreakTarget(labelText) { - ts.Debug.assert(blocks !== undefined); - if (labelText) { - for (var i = blockStack.length - 1; i >= 0; i--) { - var block = blockStack[i]; - if (supportsLabeledBreakOrContinue(block) && block.labelText === labelText) { - return block.breakLabel; - } - else if (supportsUnlabeledBreak(block) && hasImmediateContainingLabeledBlock(labelText, i - 1)) { - return block.breakLabel; + if (blockStack) { + if (labelText) { + for (var i = blockStack.length - 1; i >= 0; i--) { + var block = blockStack[i]; + if (supportsLabeledBreakOrContinue(block) && block.labelText === labelText) { + return block.breakLabel; + } + else if (supportsUnlabeledBreak(block) && hasImmediateContainingLabeledBlock(labelText, i - 1)) { + return block.breakLabel; + } } } - } - else { - for (var i = blockStack.length - 1; i >= 0; i--) { - var block = blockStack[i]; - if (supportsUnlabeledBreak(block)) { - return block.breakLabel; + else { + for (var i = blockStack.length - 1; i >= 0; i--) { + var block = blockStack[i]; + if (supportsUnlabeledBreak(block)) { + return block.breakLabel; + } } } } return 0; } function findContinueTarget(labelText) { - ts.Debug.assert(blocks !== undefined); - if (labelText) { - for (var i = blockStack.length - 1; i >= 0; i--) { - var block = blockStack[i]; - if (supportsUnlabeledContinue(block) && hasImmediateContainingLabeledBlock(labelText, i - 1)) { - return block.continueLabel; + if (blockStack) { + if (labelText) { + for (var i = blockStack.length - 1; i >= 0; i--) { + var block = blockStack[i]; + if (supportsUnlabeledContinue(block) && hasImmediateContainingLabeledBlock(labelText, i - 1)) { + return block.continueLabel; + } } } - } - else { - for (var i = blockStack.length - 1; i >= 0; i--) { - var block = blockStack[i]; - if (supportsUnlabeledContinue(block)) { - return block.continueLabel; + else { + for (var i = blockStack.length - 1; i >= 0; i--) { + var block = blockStack[i]; + if (supportsUnlabeledContinue(block)) { + return block.continueLabel; + } } } } @@ -49733,7 +50073,7 @@ var ts; return literal; } function createInlineBreak(label, location) { - ts.Debug.assert(label > 0, "Invalid label: " + label); + ts.Debug.assertLessThan(0, label, "Invalid label"); return ts.setTextRange(ts.createReturn(ts.createArrayLiteral([ createInstruction(3), createLabel(label) @@ -49941,31 +50281,33 @@ var ts; for (; blockIndex < blockActions.length && blockOffsets[blockIndex] <= operationIndex; blockIndex++) { var block = blocks[blockIndex]; var blockAction = blockActions[blockIndex]; - if (isExceptionBlock(block)) { - if (blockAction === 0) { - if (!exceptionBlockStack) { - exceptionBlockStack = []; + switch (block.kind) { + case 0: + if (blockAction === 0) { + if (!exceptionBlockStack) { + exceptionBlockStack = []; + } + if (!statements) { + statements = []; + } + exceptionBlockStack.push(currentExceptionBlock); + currentExceptionBlock = block; } - if (!statements) { - statements = []; + else if (blockAction === 1) { + currentExceptionBlock = exceptionBlockStack.pop(); } - exceptionBlockStack.push(currentExceptionBlock); - currentExceptionBlock = block; - } - else if (blockAction === 1) { - currentExceptionBlock = exceptionBlockStack.pop(); - } - } - else if (isWithBlock(block)) { - if (blockAction === 0) { - if (!withBlockStack) { - withBlockStack = []; + break; + case 1: + if (blockAction === 0) { + if (!withBlockStack) { + withBlockStack = []; + } + withBlockStack.push(block); } - withBlockStack.push(block); - } - else if (blockAction === 1) { - withBlockStack.pop(); - } + else if (blockAction === 1) { + withBlockStack.pop(); + } + break; } } } @@ -52275,7 +52617,6 @@ var ts; errorNameNode = declaration.name; var format = 4 | 16384 | - 2048 | (shouldUseResolverType ? 8192 : 0); resolver.writeTypeOfDeclaration(declaration, enclosingDeclaration, format, writer); errorNameNode = undefined; @@ -52289,7 +52630,7 @@ var ts; } else { errorNameNode = signature.name; - resolver.writeReturnTypeOfSignatureDeclaration(signature, enclosingDeclaration, 4 | 2048 | 16384, writer); + resolver.writeReturnTypeOfSignatureDeclaration(signature, enclosingDeclaration, 4 | 16384, writer); errorNameNode = undefined; } } @@ -52519,7 +52860,7 @@ var ts; write(tempVarName); write(": "); writer.getSymbolAccessibilityDiagnostic = function () { return diagnostic; }; - resolver.writeTypeOfExpression(expr, enclosingDeclaration, 4 | 2048 | 16384, writer); + resolver.writeTypeOfExpression(expr, enclosingDeclaration, 4 | 16384, writer); write(";"); writeLine(); return tempVarName; @@ -53156,6 +53497,9 @@ var ts; return ts.forEach(node.declarationList.declarations, function (varDeclaration) { return resolver.isDeclarationVisible(varDeclaration); }); } function writeVariableStatement(node) { + if (ts.every(node.declarationList && node.declarationList.declarations, function (decl) { return decl.name && ts.isEmptyBindingPattern(decl.name); })) { + return; + } emitJsDocComments(node); emitModuleElementDeclarationFlags(node); if (ts.isLet(node.declarationList)) { @@ -54121,14 +54465,14 @@ var ts; writer.writeLine(); } } - function emitTrailingCommentsOfPosition(pos) { + function emitTrailingCommentsOfPosition(pos, prefixSpace) { if (disabled) { return; } if (extendedDiagnostics) { ts.performance.mark("beforeEmitTrailingCommentsOfPosition"); } - forEachTrailingCommentToEmit(pos, emitTrailingCommentOfPosition); + forEachTrailingCommentToEmit(pos, prefixSpace ? emitTrailingComment : emitTrailingCommentOfPosition); if (extendedDiagnostics) { ts.performance.measure("commentTime", "beforeEmitTrailingCommentsOfPosition"); } @@ -54208,15 +54552,7 @@ var ts; emitPos(commentEnd); } function isTripleSlashComment(commentPos, commentEnd) { - if (currentText.charCodeAt(commentPos + 1) === 47 && - commentPos + 2 < commentEnd && - currentText.charCodeAt(commentPos + 2) === 47) { - var textSubStr = currentText.substring(commentPos, commentEnd); - return textSubStr.match(ts.fullTripleSlashReferencePathRegEx) || - textSubStr.match(ts.fullTripleSlashAMDReferencePathRegEx) ? - true : false; - } - return false; + return ts.isRecognizedTripleSlashComment(currentText, commentPos, commentEnd); } } ts.createCommentWriter = createCommentWriter; @@ -55155,7 +55491,9 @@ var ts; if (!(ts.getEmitFlags(node) & 131072)) { var dotRangeStart = node.expression.end; var dotRangeEnd = ts.skipTrivia(currentSourceFile.text, node.expression.end) + 1; - var dotToken = { kind: 23, pos: dotRangeStart, end: dotRangeEnd }; + var dotToken = ts.createToken(23); + dotToken.pos = dotRangeStart; + dotToken.end = dotRangeEnd; indentBeforeDot = needsIndentation(node, node.expression, dotToken); indentAfterDot = needsIndentation(node, dotToken, node.name); } @@ -55267,7 +55605,9 @@ var ts; var indentAfterOperator = needsIndentation(node, node.operatorToken, node.right); emitExpression(node.left); increaseIndentIf(indentBeforeOperator, isCommaOperator ? " " : undefined); + emitLeadingCommentsOfPosition(node.operatorToken.pos); writeTokenNode(node.operatorToken); + emitTrailingCommentsOfPosition(node.operatorToken.end, true); increaseIndentIf(indentAfterOperator, " "); emitExpression(node.right); decreaseIndentIf(indentBeforeOperator, indentAfterOperator); @@ -55454,8 +55794,19 @@ var ts; emitWithPrefix(" ", node.label); write(";"); } + function emitTokenWithComment(token, pos, contextNode) { + var node = contextNode && ts.getParseTreeNode(contextNode); + if (node && node.kind === contextNode.kind) { + pos = ts.skipTrivia(currentSourceFile.text, pos); + } + pos = writeToken(token, pos, contextNode); + if (node && node.kind === contextNode.kind) { + emitTrailingCommentsOfPosition(pos, true); + } + return pos; + } function emitReturnStatement(node) { - writeToken(96, node.pos, node); + emitTokenWithComment(96, node.pos, node); emitExpressionWithPrefix(" ", node.expression); write(";"); } @@ -55896,10 +56247,12 @@ var ts; function emitCatchClause(node) { var openParenPos = writeToken(74, node.pos); write(" "); - writeToken(19, openParenPos); - emit(node.variableDeclaration); - writeToken(20, node.variableDeclaration ? node.variableDeclaration.end : openParenPos); - write(" "); + if (node.variableDeclaration) { + writeToken(19, openParenPos); + emit(node.variableDeclaration); + writeToken(20, node.variableDeclaration.end); + write(" "); + } emit(node.block); } function emitPropertyAssignment(node) { @@ -57011,6 +57364,9 @@ var ts; var loader_2 = function (typesRef, containingFile) { return ts.resolveTypeReferenceDirective(typesRef, containingFile, options, host).resolvedTypeReferenceDirective; }; resolveTypeReferenceDirectiveNamesWorker = function (typeReferenceDirectiveNames, containingFile) { return loadWithLocalCache(checkAllDefined(typeReferenceDirectiveNames), containingFile, loader_2); }; } + var packageIdToSourceFile = ts.createMap(); + var sourceFileToPackageName = ts.createMap(); + var redirectTargetsSet = ts.createMap(); var filesByName = ts.createMap(); var filesByNameIgnoreCase = host.useCaseSensitiveFileNames() ? ts.createMap() : undefined; var structuralIsReused = tryReuseStructureFromOldProgram(); @@ -57067,6 +57423,8 @@ var ts; isSourceFileFromExternalLibrary: isSourceFileFromExternalLibrary, dropDiagnosticsProducingTypeChecker: dropDiagnosticsProducingTypeChecker, getSourceFileFromReference: getSourceFileFromReference, + sourceFileToPackageName: sourceFileToPackageName, + redirectTargetsSet: redirectTargetsSet, }; verifyCompilerOptions(); ts.performance.mark("afterProgram"); @@ -57210,17 +57568,51 @@ var ts; var filePaths = []; var modifiedSourceFiles = []; oldProgram.structureIsReused = 2; - for (var _i = 0, _a = oldProgram.getSourceFiles(); _i < _a.length; _i++) { - var oldSourceFile = _a[_i]; + var oldSourceFiles = oldProgram.getSourceFiles(); + var SeenPackageName; + (function (SeenPackageName) { + SeenPackageName[SeenPackageName["Exists"] = 0] = "Exists"; + SeenPackageName[SeenPackageName["Modified"] = 1] = "Modified"; + })(SeenPackageName || (SeenPackageName = {})); + var seenPackageNames = ts.createMap(); + for (var _i = 0, oldSourceFiles_1 = oldSourceFiles; _i < oldSourceFiles_1.length; _i++) { + var oldSourceFile = oldSourceFiles_1[_i]; var newSourceFile = host.getSourceFileByPath ? host.getSourceFileByPath(oldSourceFile.fileName, oldSourceFile.path, options.target) : host.getSourceFile(oldSourceFile.fileName, options.target); if (!newSourceFile) { return oldProgram.structureIsReused = 0; } + ts.Debug.assert(!newSourceFile.redirectInfo, "Host should not return a redirect source file from `getSourceFile`"); + var fileChanged = void 0; + if (oldSourceFile.redirectInfo) { + if (newSourceFile !== oldSourceFile.redirectInfo.unredirected) { + return oldProgram.structureIsReused = 0; + } + fileChanged = false; + newSourceFile = oldSourceFile; + } + else if (oldProgram.redirectTargetsSet.has(oldSourceFile.path)) { + if (newSourceFile !== oldSourceFile) { + return oldProgram.structureIsReused = 0; + } + fileChanged = false; + } + else { + fileChanged = newSourceFile !== oldSourceFile; + } newSourceFile.path = oldSourceFile.path; filePaths.push(newSourceFile.path); - if (oldSourceFile !== newSourceFile) { + var packageName = oldProgram.sourceFileToPackageName.get(oldSourceFile.path); + if (packageName !== undefined) { + var prevKind = seenPackageNames.get(packageName); + var newKind = fileChanged ? 1 : 0; + if ((prevKind !== undefined && newKind === 1) || prevKind === 1) { + return oldProgram.structureIsReused = 0; + } + seenPackageNames.set(packageName, newKind); + } + if (fileChanged) { if (oldSourceFile.hasNoDefaultLib !== newSourceFile.hasNoDefaultLib) { oldProgram.structureIsReused = 1; } @@ -57248,8 +57640,8 @@ var ts; return oldProgram.structureIsReused; } modifiedFilePaths = modifiedSourceFiles.map(function (f) { return f.newFile.path; }); - for (var _b = 0, modifiedSourceFiles_1 = modifiedSourceFiles; _b < modifiedSourceFiles_1.length; _b++) { - var _c = modifiedSourceFiles_1[_b], oldSourceFile = _c.oldFile, newSourceFile = _c.newFile; + for (var _a = 0, modifiedSourceFiles_1 = modifiedSourceFiles; _a < modifiedSourceFiles_1.length; _a++) { + var _b = modifiedSourceFiles_1[_a], oldSourceFile = _b.oldFile, newSourceFile = _b.newFile; var newSourceFilePath = ts.getNormalizedAbsolutePath(newSourceFile.fileName, currentDirectory); if (resolveModuleNamesWorker) { var moduleNames = ts.map(ts.concatenate(newSourceFile.imports, newSourceFile.moduleAugmentations), getTextOfLiteral); @@ -57283,8 +57675,8 @@ var ts; if (oldProgram.getMissingFilePaths().some(function (missingFilePath) { return host.fileExists(missingFilePath); })) { return oldProgram.structureIsReused = 1; } - for (var _d = 0, _e = oldProgram.getMissingFilePaths(); _d < _e.length; _d++) { - var p = _e[_d]; + for (var _c = 0, _d = oldProgram.getMissingFilePaths(); _c < _d.length; _c++) { + var p = _d[_c]; filesByName.set(p, undefined); } for (var i = 0; i < newSourceFiles.length; i++) { @@ -57292,11 +57684,13 @@ var ts; } files = newSourceFiles; fileProcessingDiagnostics = oldProgram.getFileProcessingDiagnostics(); - for (var _f = 0, modifiedSourceFiles_2 = modifiedSourceFiles; _f < modifiedSourceFiles_2.length; _f++) { - var modifiedFile = modifiedSourceFiles_2[_f]; + for (var _e = 0, modifiedSourceFiles_2 = modifiedSourceFiles; _e < modifiedSourceFiles_2.length; _e++) { + var modifiedFile = modifiedSourceFiles_2[_e]; fileProcessingDiagnostics.reattachFileDiagnostics(modifiedFile.newFile); } resolvedTypeReferenceDirectives = oldProgram.getResolvedTypeReferenceDirectives(); + sourceFileToPackageName = oldProgram.sourceFileToPackageName; + redirectTargetsSet = oldProgram.redirectTargetsSet; return oldProgram.structureIsReused = 2; } function getEmitHost(writeFileCallback) { @@ -57775,7 +58169,7 @@ var ts; } } function processSourceFile(fileName, isDefaultLib, refFile, refPos, refEnd) { - getSourceFileFromReferenceWorker(fileName, function (fileName) { return findSourceFile(fileName, toPath(fileName), isDefaultLib, refFile, refPos, refEnd); }, function (diagnostic) { + getSourceFileFromReferenceWorker(fileName, function (fileName) { return findSourceFile(fileName, toPath(fileName), isDefaultLib, refFile, refPos, refEnd, undefined); }, function (diagnostic) { var args = []; for (var _i = 1; _i < arguments.length; _i++) { args[_i - 1] = arguments[_i]; @@ -57792,7 +58186,24 @@ var ts; fileProcessingDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.File_name_0_differs_from_already_included_file_name_1_only_in_casing, fileName, existingFileName)); } } - function findSourceFile(fileName, path, isDefaultLib, refFile, refPos, refEnd) { + function createRedirectSourceFile(redirectTarget, unredirected, fileName, path) { + var redirect = Object.create(redirectTarget); + redirect.fileName = fileName; + redirect.path = path; + redirect.redirectInfo = { redirectTarget: redirectTarget, unredirected: unredirected }; + Object.defineProperties(redirect, { + id: { + get: function () { return this.redirectInfo.redirectTarget.id; }, + set: function (value) { this.redirectInfo.redirectTarget.id = value; }, + }, + symbol: { + get: function () { return this.redirectInfo.redirectTarget.symbol; }, + set: function (value) { this.redirectInfo.redirectTarget.symbol = value; }, + }, + }); + return redirect; + } + function findSourceFile(fileName, path, isDefaultLib, refFile, refPos, refEnd, packageId) { if (filesByName.has(path)) { var file_1 = filesByName.get(path); if (file_1 && options.forceConsistentCasingInFileNames && ts.getNormalizedAbsolutePath(file_1.fileName, currentDirectory) !== ts.getNormalizedAbsolutePath(fileName, currentDirectory)) { @@ -57823,6 +58234,22 @@ var ts; fileProcessingDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_read_file_0_Colon_1, fileName, hostErrorMessage)); } }); + if (packageId) { + var packageIdKey = packageId.name + "@" + packageId.version; + var fileFromPackageId = packageIdToSourceFile.get(packageIdKey); + if (fileFromPackageId) { + var dupFile = createRedirectSourceFile(fileFromPackageId, file, fileName, path); + redirectTargetsSet.set(fileFromPackageId.path, true); + filesByName.set(path, dupFile); + sourceFileToPackageName.set(path, packageId.name); + files.push(dupFile); + return dupFile; + } + else if (file) { + packageIdToSourceFile.set(packageIdKey, file); + sourceFileToPackageName.set(path, packageId.name); + } + } filesByName.set(path, file); if (file) { sourceFilesFoundSearchingNodeModules.set(path, currentNodeModulesDepth > 0); @@ -57944,7 +58371,7 @@ var ts; else if (shouldAddFile) { var path = toPath(resolvedFileName); var pos = ts.skipTrivia(file.text, file.imports[i].pos); - findSourceFile(resolvedFileName, path, false, file, pos, file.imports[i].end); + findSourceFile(resolvedFileName, path, false, file, pos, file.imports[i].end, resolution.packageId); } if (isFromNodeModulesSearch) { currentNodeModulesDepth--; @@ -58623,6 +59050,12 @@ var ts; category: ts.Diagnostics.Module_Resolution_Options, description: ts.Diagnostics.Allow_default_imports_from_modules_with_no_default_export_This_does_not_affect_code_emit_just_typechecking }, + { + name: "preserveSymlinks", + type: "boolean", + category: ts.Diagnostics.Module_Resolution_Options, + description: ts.Diagnostics.Do_not_resolve_the_real_path_of_symlinks, + }, { name: "sourceRoot", type: "string", @@ -59234,7 +59667,7 @@ var ts; var text = valueExpression.text; if (option && typeof option.type !== "string") { var customOption = option; - if (!customOption.type.has(text)) { + if (!customOption.type.has(text.toLowerCase())) { errors.push(createDiagnosticForInvalidCustomType(customOption, function (message, arg0, arg1) { return ts.createDiagnosticForNodeInSourceFile(sourceFile, valueExpression, message, arg0, arg1); })); } } @@ -59485,12 +59918,10 @@ var ts; } } else { - var specs = includeSpecs ? [] : ["node_modules", "bower_components", "jspm_packages"]; var outDir = raw["compilerOptions"] && raw["compilerOptions"]["outDir"]; if (outDir) { - specs.push(outDir); + excludeSpecs = [outDir]; } - excludeSpecs = specs; } if (fileNames === undefined && includeSpecs === undefined) { includeSpecs = ["**/*"]; @@ -59741,7 +60172,7 @@ var ts; return value; } else if (typeof option.type !== "string") { - return option.type.get(value); + return option.type.get(typeof value === "string" ? value.toLowerCase() : value); } return normalizeNonListOptionValue(option, basePath, value); } @@ -59816,23 +60247,13 @@ var ts; }; } function validateSpecs(specs, errors, allowTrailingRecursion, jsonSourceFile, specKey) { - var validSpecs = []; - for (var _i = 0, specs_1 = specs; _i < specs_1.length; _i++) { - var spec = specs_1[_i]; - if (!allowTrailingRecursion && invalidTrailingRecursionPattern.test(spec)) { - errors.push(createDiagnostic(ts.Diagnostics.File_specification_cannot_end_in_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0, spec)); + return specs.filter(function (spec) { + var diag = specToDiagnostic(spec, allowTrailingRecursion); + if (diag !== undefined) { + errors.push(createDiagnostic(diag, spec)); } - else if (invalidMultipleRecursionPatterns.test(spec)) { - errors.push(createDiagnostic(ts.Diagnostics.File_specification_cannot_contain_multiple_recursive_directory_wildcards_Asterisk_Asterisk_Colon_0, spec)); - } - else if (invalidDotDotAfterRecursiveWildcardPattern.test(spec)) { - errors.push(createDiagnostic(ts.Diagnostics.File_specification_cannot_contain_a_parent_directory_that_appears_after_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0, spec)); - } - else { - validSpecs.push(spec); - } - } - return validSpecs; + return diag === undefined; + }); function createDiagnostic(message, spec) { if (jsonSourceFile && jsonSourceFile.jsonObject) { for (var _i = 0, _a = ts.getPropertyAssignment(jsonSourceFile.jsonObject, specKey); _i < _a.length; _i++) { @@ -59850,6 +60271,17 @@ var ts; return ts.createCompilerDiagnostic(message, spec); } } + function specToDiagnostic(spec, allowTrailingRecursion) { + if (!allowTrailingRecursion && invalidTrailingRecursionPattern.test(spec)) { + return ts.Diagnostics.File_specification_cannot_end_in_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0; + } + else if (invalidMultipleRecursionPatterns.test(spec)) { + return ts.Diagnostics.File_specification_cannot_contain_multiple_recursive_directory_wildcards_Asterisk_Asterisk_Colon_0; + } + else if (invalidDotDotAfterRecursiveWildcardPattern.test(spec)) { + return ts.Diagnostics.File_specification_cannot_contain_a_parent_directory_that_appears_after_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0; + } + } function getWildcardDirectories(include, exclude, path, useCaseSensitiveFileNames) { var rawExcludeRegex = ts.getRegularExpressionForWildcard(exclude, path, "exclude"); var excludeRegex = rawExcludeRegex && new RegExp(rawExcludeRegex, useCaseSensitiveFileNames ? "" : "i"); @@ -60758,7 +61190,9 @@ var ts; } ts.findNextToken = findNextToken; function findPrecedingToken(position, sourceFile, startNode, includeJsDoc) { - return find(startNode || sourceFile); + var result = find(startNode || sourceFile); + ts.Debug.assert(!(result && isWhiteSpaceOnlyJsxText(result))); + return result; function findRightmostToken(n) { if (ts.isToken(n)) { return n; @@ -60774,10 +61208,11 @@ var ts; var children = n.getChildren(); for (var i = 0; i < children.length; i++) { var child = children[i]; - if (position < child.end && (nodeHasTokens(child) || child.kind === 10)) { + if (position < child.end) { var start = child.getStart(sourceFile, includeJsDoc); var lookInPreviousChild = (start >= position) || - (child.kind === 10 && start === child.end); + !nodeHasTokens(child) || + isWhiteSpaceOnlyJsxText(child); if (lookInPreviousChild) { var candidate = findRightmostChildNodeWithTokens(children, i); return candidate && findRightmostToken(candidate); @@ -60795,7 +61230,11 @@ var ts; } function findRightmostChildNodeWithTokens(children, exclusiveStartPosition) { for (var i = exclusiveStartPosition - 1; i >= 0; i--) { - if (nodeHasTokens(children[i])) { + var child = children[i]; + if (isWhiteSpaceOnlyJsxText(child)) { + ts.Debug.assert(i > 0, "`JsxText` tokens should not be the first child of `JsxElement | JsxSelfClosingElement`"); + } + else if (nodeHasTokens(children[i])) { return children[i]; } } @@ -60840,34 +61279,19 @@ var ts; return false; } ts.isInsideJsxElementOrAttribute = isInsideJsxElementOrAttribute; + function isWhiteSpaceOnlyJsxText(node) { + return ts.isJsxText(node) && node.containsOnlyWhiteSpaces; + } + ts.isWhiteSpaceOnlyJsxText = isWhiteSpaceOnlyJsxText; function isInTemplateString(sourceFile, position) { var token = getTokenAtPosition(sourceFile, position, false); return ts.isTemplateLiteralKind(token.kind) && position > token.getStart(sourceFile); } ts.isInTemplateString = isInTemplateString; function isInComment(sourceFile, position, tokenAtPosition, predicate) { - if (tokenAtPosition === void 0) { tokenAtPosition = getTokenAtPosition(sourceFile, position, false); } - return position <= tokenAtPosition.getStart(sourceFile) && - (isInCommentRange(ts.getLeadingCommentRanges(sourceFile.text, tokenAtPosition.pos)) || - isInCommentRange(ts.getTrailingCommentRanges(sourceFile.text, tokenAtPosition.pos))); - function isInCommentRange(commentRanges) { - return ts.forEach(commentRanges, function (c) { return isPositionInCommentRange(c, position, sourceFile.text) && (!predicate || predicate(c)); }); - } + return !!ts.formatting.getRangeOfEnclosingComment(sourceFile, position, false, undefined, tokenAtPosition, predicate); } ts.isInComment = isInComment; - function isPositionInCommentRange(_a, position, text) { - var pos = _a.pos, end = _a.end, kind = _a.kind; - if (pos < position && position < end) { - return true; - } - else if (position === end) { - return kind === 2 || - !(text.charCodeAt(end - 1) === 47 && text.charCodeAt(end - 2) === 42); - } - else { - return false; - } - } function hasDocComment(sourceFile, position) { var token = getTokenAtPosition(sourceFile, position, false); var commentRanges = ts.getLeadingCommentRanges(sourceFile.text, token.pos); @@ -61220,6 +61644,7 @@ var ts; } ts.symbolToDisplayParts = symbolToDisplayParts; function signatureToDisplayParts(typechecker, signature, enclosingDeclaration, flags) { + flags |= 65536; return mapToDisplayParts(function (writer) { typechecker.getSymbolDisplayBuilder().buildSignatureDisplay(signature, writer, enclosingDeclaration, flags); }); @@ -61925,11 +62350,11 @@ var ts; templateStack.pop(); } else { - ts.Debug.assert(token === 15, "Should have been a template middle. Was " + token); + ts.Debug.assertEqual(token, 15, "Should have been a template middle."); } } else { - ts.Debug.assert(lastTemplateStackToken === 17, "Should have been an open brace. Was: " + token); + ts.Debug.assertEqual(lastTemplateStackToken, 17, "Should have been an open brace"); templateStack.pop(); } } @@ -63587,7 +64012,7 @@ var ts; var typeForObject = typeChecker.getTypeAtLocation(objectLikeContainer); if (!typeForObject) return false; - typeMembers = typeChecker.getPropertiesOfType(typeForObject); + typeMembers = typeChecker.getPropertiesOfType(typeForObject).filter(function (symbol) { return !(ts.getDeclarationModifierFlagsFromSymbol(symbol) & 24); }); existingMembers = objectLikeContainer.elements; } } @@ -63964,8 +64389,8 @@ var ts; addPropertySymbols(implementingTypeSymbols, 24); return result; function addPropertySymbols(properties, inValidModifierFlags) { - for (var _i = 0, properties_11 = properties; _i < properties_11.length; _i++) { - var property = properties_11[_i]; + for (var _i = 0, properties_12 = properties; _i < properties_12.length; _i++) { + var property = properties_12[_i]; if (isValidProperty(property, inValidModifierFlags)) { result.push(property); } @@ -65655,11 +66080,15 @@ var ts; } function getPropertySymbolOfObjectBindingPatternWithoutPropertyName(symbol, checker) { var bindingElement = getObjectBindingElementWithoutPropertyName(symbol); - if (bindingElement) { - var typeOfPattern = checker.getTypeAtLocation(bindingElement.parent); - return typeOfPattern && checker.getPropertyOfType(typeOfPattern, bindingElement.name.text); + if (!bindingElement) + return undefined; + var typeOfPattern = checker.getTypeAtLocation(bindingElement.parent); + var propSymbol = typeOfPattern && checker.getPropertyOfType(typeOfPattern, bindingElement.name.text); + if (propSymbol && propSymbol.flags & 98304) { + ts.Debug.assert(!!(propSymbol.flags & 33554432)); + return propSymbol.target; } - return undefined; + return propSymbol; } function getSymbolScope(symbol) { var declarations = symbol.declarations, flags = symbol.flags, parent = symbol.parent, valueDeclaration = symbol.valueDeclaration; @@ -65679,12 +66108,13 @@ var ts; if (getObjectBindingElementWithoutPropertyName(symbol)) { return undefined; } - if (parent && !((parent.flags & 1536) && ts.isExternalModuleSymbol(parent) && !parent.globalExports)) { + var exposedByParent = parent && !(symbol.flags & 262144); + if (exposedByParent && !((parent.flags & 1536) && ts.isExternalModuleSymbol(parent) && !parent.globalExports)) { return undefined; } var scope; - for (var _i = 0, declarations_10 = declarations; _i < declarations_10.length; _i++) { - var declaration = declarations_10[_i]; + for (var _i = 0, declarations_9 = declarations; _i < declarations_9.length; _i++) { + var declaration = declarations_9[_i]; var container = ts.getContainerNode(declaration); if (scope && scope !== container) { return undefined; @@ -65694,7 +66124,7 @@ var ts; } scope = container; } - return parent ? scope.getSourceFile() : scope; + return exposedByParent ? scope.getSourceFile() : scope; } function getPossibleSymbolReferencePositions(sourceFile, symbolName, container) { if (container === void 0) { container = sourceFile; } @@ -66371,8 +66801,8 @@ var ts; var lastIterationMeaning = void 0; do { lastIterationMeaning = meaning; - for (var _i = 0, declarations_11 = declarations; _i < declarations_11.length; _i++) { - var declaration = declarations_11[_i]; + for (var _i = 0, declarations_10 = declarations; _i < declarations_10.length; _i++) { + var declaration = declarations_10[_i]; var declarationMeaning = ts.getMeaningFromDeclaration(declaration); if (declarationMeaning & meaning) { meaning |= declarationMeaning; @@ -66517,6 +66947,16 @@ var ts; var shorthandContainerName_1 = typeChecker.symbolToString(symbol.parent, node); return ts.map(shorthandDeclarations, function (declaration) { return createDefinitionInfo(declaration, shorthandSymbolKind_1, shorthandSymbolName_1, shorthandContainerName_1); }); } + if (ts.isPropertyName(node) && ts.isBindingElement(node.parent) && ts.isObjectBindingPattern(node.parent.parent) && + (node === (node.parent.propertyName || node.parent.name))) { + var type = typeChecker.getTypeAtLocation(node.parent.parent); + if (type) { + var propSymbols = ts.getPropertySymbolsFromType(type, node); + if (propSymbols) { + return ts.flatMap(propSymbols, function (propSymbol) { return getDefinitionFromSymbol(typeChecker, propSymbol, node); }); + } + } + } var element = ts.getContainingObjectLiteralElement(node); if (element && typeChecker.getContextualType(element.parent)) { return ts.flatMap(ts.getPropertySymbolsFromContextualType(typeChecker, element), function (propertySymbol) { @@ -66933,12 +67373,20 @@ var ts; "crypto", "stream", "util", "assert", "tty", "domain", "constants", "process", "v8", "timers", "console" ]; - var nodeCoreModules = ts.arrayToMap(JsTyping.nodeCoreModuleList, function (x) { return x; }); + var nodeCoreModules = ts.arrayToSet(JsTyping.nodeCoreModuleList); function loadSafeList(host, safeListPath) { var result = ts.readConfigFile(safeListPath, function (path) { return host.readFile(path); }); return ts.createMapFromTemplate(result.config); } JsTyping.loadSafeList = loadSafeList; + function loadTypesMap(host, typesMapPath) { + var result = ts.readConfigFile(typesMapPath, function (path) { return host.readFile(path); }); + if (result.config) { + return ts.createMapFromTemplate(result.config.simpleMap); + } + return undefined; + } + JsTyping.loadTypesMap = loadTypesMap; function discoverTypings(host, log, fileNames, projectRootPath, safeList, packageNameToTypingLocation, typeAcquisition, unresolvedImports) { if (!typeAcquisition || !typeAcquisition.enable) { return { cachedTypingPaths: [], newTypingNames: [], filesToWatch: [] }; @@ -67093,8 +67541,8 @@ var ts; if (!matches) { return; } - for (var _i = 0, declarations_12 = declarations; _i < declarations_12.length; _i++) { - var declaration = declarations_12[_i]; + for (var _i = 0, declarations_11 = declarations; _i < declarations_11.length; _i++) { + var declaration = declarations_11[_i]; if (patternMatcher.patternContainsDots) { var containers = getContainers(declaration); if (!containers) { @@ -67753,13 +68201,17 @@ var ts; (function (ts) { var OutliningElementsCollector; (function (OutliningElementsCollector) { + var collapseText = "..."; + var maxDepth = 20; function collectElements(sourceFile, cancellationToken) { var elements = []; - var collapseText = "..."; - function addOutliningSpan(hintSpanNode, startElement, endElement, autoCollapse) { + var depth = 0; + walk(sourceFile); + return elements; + function addOutliningSpan(hintSpanNode, startElement, endElement, autoCollapse, useFullStart) { if (hintSpanNode && startElement && endElement) { var span_13 = { - textSpan: ts.createTextSpanFromBounds(startElement.pos, endElement.end), + textSpan: ts.createTextSpanFromBounds(useFullStart ? startElement.getFullStart() : startElement.getStart(), endElement.getEnd()), hintSpan: ts.createTextSpanFromNode(hintSpanNode, sourceFile), bannerText: collapseText, autoCollapse: autoCollapse, @@ -67820,8 +68272,6 @@ var ts; function autoCollapse(node) { return ts.isFunctionBlock(node) && node.parent.kind !== 187; } - var depth = 0; - var maxDepth = 20; function walk(n) { cancellationToken.throwIfCancellationRequested(); if (depth > maxDepth) { @@ -67834,8 +68284,8 @@ var ts; case 207: if (!ts.isFunctionBlock(n)) { var parent = n.parent; - var openBrace = ts.findChildOfKind(n, 17, sourceFile); - var closeBrace = ts.findChildOfKind(n, 18, sourceFile); + var openBrace_1 = ts.findChildOfKind(n, 17, sourceFile); + var closeBrace_1 = ts.findChildOfKind(n, 18, sourceFile); if (parent.kind === 212 || parent.kind === 215 || parent.kind === 216 || @@ -67844,19 +68294,19 @@ var ts; parent.kind === 213 || parent.kind === 220 || parent.kind === 260) { - addOutliningSpan(parent, openBrace, closeBrace, autoCollapse(n)); + addOutliningSpan(parent, openBrace_1, closeBrace_1, autoCollapse(n), true); break; } if (parent.kind === 224) { var tryStatement = parent; if (tryStatement.tryBlock === n) { - addOutliningSpan(parent, openBrace, closeBrace, autoCollapse(n)); + addOutliningSpan(parent, openBrace_1, closeBrace_1, autoCollapse(n), true); break; } else if (tryStatement.finallyBlock === n) { var finallyKeyword = ts.findChildOfKind(tryStatement, 87, sourceFile); if (finallyKeyword) { - addOutliningSpan(finallyKeyword, openBrace, closeBrace, autoCollapse(n)); + addOutliningSpan(finallyKeyword, openBrace_1, closeBrace_1, autoCollapse(n), true); break; } } @@ -67871,33 +68321,35 @@ var ts; break; } case 234: { - var openBrace = ts.findChildOfKind(n, 17, sourceFile); - var closeBrace = ts.findChildOfKind(n, 18, sourceFile); - addOutliningSpan(n.parent, openBrace, closeBrace, autoCollapse(n)); + var openBrace_2 = ts.findChildOfKind(n, 17, sourceFile); + var closeBrace_2 = ts.findChildOfKind(n, 18, sourceFile); + addOutliningSpan(n.parent, openBrace_2, closeBrace_2, autoCollapse(n), true); break; } case 229: case 230: case 232: - case 178: case 235: { - var openBrace = ts.findChildOfKind(n, 17, sourceFile); - var closeBrace = ts.findChildOfKind(n, 18, sourceFile); - addOutliningSpan(n, openBrace, closeBrace, autoCollapse(n)); + var openBrace_3 = ts.findChildOfKind(n, 17, sourceFile); + var closeBrace_3 = ts.findChildOfKind(n, 18, sourceFile); + addOutliningSpan(n, openBrace_3, closeBrace_3, autoCollapse(n), true); break; } + case 178: + var openBrace = ts.findChildOfKind(n, 17, sourceFile); + var closeBrace = ts.findChildOfKind(n, 18, sourceFile); + addOutliningSpan(n, openBrace, closeBrace, autoCollapse(n), !ts.isArrayLiteralExpression(n.parent)); + break; case 177: var openBracket = ts.findChildOfKind(n, 21, sourceFile); var closeBracket = ts.findChildOfKind(n, 22, sourceFile); - addOutliningSpan(n, openBracket, closeBracket, autoCollapse(n)); + addOutliningSpan(n, openBracket, closeBracket, autoCollapse(n), !ts.isArrayLiteralExpression(n.parent)); break; } depth++; ts.forEachChild(n, walk); depth--; } - walk(sourceFile); - return elements; } OutliningElementsCollector.collectElements = collectElements; })(OutliningElementsCollector = ts.OutliningElementsCollector || (ts.OutliningElementsCollector = {})); @@ -68741,8 +69193,8 @@ var ts; var nameToDeclarations = sourceFile.getNamedDeclarations(); var declarations = nameToDeclarations.get(name.text); if (declarations) { - for (var _b = 0, declarations_13 = declarations; _b < declarations_13.length; _b++) { - var declaration = declarations_13[_b]; + for (var _b = 0, declarations_12 = declarations; _b < declarations_12.length; _b++) { + var declaration = declarations_12[_b]; var symbol = declaration.symbol; if (symbol) { var type = typeChecker.getTypeOfSymbolAtLocation(symbol, declaration); @@ -68775,7 +69227,9 @@ var ts; } var kind = invocation.typeArguments && invocation.typeArguments.pos === list.pos ? 0 : 1; var argumentCount = getArgumentCount(list); - ts.Debug.assert(argumentIndex === 0 || argumentIndex < argumentCount, "argumentCount < argumentIndex, " + argumentCount + " < " + argumentIndex); + if (argumentIndex !== 0) { + ts.Debug.assertLessThan(argumentIndex, argumentCount); + } var argumentsSpan = getApplicableSpanForArguments(list, sourceFile); return { kind: kind, invocation: invocation, argumentsSpan: argumentsSpan, argumentIndex: argumentIndex, argumentCount: argumentCount }; } @@ -68853,7 +69307,9 @@ var ts; var argumentCount = tagExpression.template.kind === 13 ? 1 : tagExpression.template.templateSpans.length + 1; - ts.Debug.assert(argumentIndex === 0 || argumentIndex < argumentCount, "argumentCount < argumentIndex, " + argumentCount + " < " + argumentIndex); + if (argumentIndex !== 0) { + ts.Debug.assertLessThan(argumentIndex, argumentCount); + } return { kind: 2, invocation: tagExpression, @@ -68950,7 +69406,9 @@ var ts; tags: candidateSignature.getJsDocTags() }; }); - ts.Debug.assert(argumentIndex === 0 || argumentIndex < argumentCount, "argumentCount < argumentIndex, " + argumentCount + " < " + argumentIndex); + if (argumentIndex !== 0) { + ts.Debug.assertLessThan(argumentIndex, argumentCount); + } var selectedItemIndex = candidates.indexOf(resolvedSignature); ts.Debug.assert(selectedItemIndex !== -1); return { items: items, applicableSpan: applicableSpan, selectedItemIndex: selectedItemIndex, argumentIndex: argumentIndex, argumentCount: argumentCount }; @@ -69091,102 +69549,100 @@ var ts; } var signature = void 0; type = isThisExpression ? typeChecker.getTypeAtLocation(location) : typeChecker.getTypeOfSymbolAtLocation(symbol.exportSymbol || symbol, location); - if (type) { - if (location.parent && location.parent.kind === 179) { - var right = location.parent.name; - if (right === location || (right && right.getFullWidth() === 0)) { - location = location.parent; + if (location.parent && location.parent.kind === 179) { + var right = location.parent.name; + if (right === location || (right && right.getFullWidth() === 0)) { + location = location.parent; + } + } + var callExpressionLike = void 0; + if (ts.isCallOrNewExpression(location)) { + callExpressionLike = location; + } + else if (ts.isCallExpressionTarget(location) || ts.isNewExpressionTarget(location)) { + callExpressionLike = location.parent; + } + else if (location.parent && ts.isJsxOpeningLikeElement(location.parent) && ts.isFunctionLike(symbol.valueDeclaration)) { + callExpressionLike = location.parent; + } + if (callExpressionLike) { + var candidateSignatures = []; + signature = typeChecker.getResolvedSignature(callExpressionLike, candidateSignatures); + if (!signature && candidateSignatures.length) { + signature = candidateSignatures[0]; + } + var useConstructSignatures = callExpressionLike.kind === 182 || (ts.isCallExpression(callExpressionLike) && callExpressionLike.expression.kind === 97); + var allSignatures = useConstructSignatures ? type.getConstructSignatures() : type.getCallSignatures(); + if (!ts.contains(allSignatures, signature.target) && !ts.contains(allSignatures, signature)) { + signature = allSignatures.length ? allSignatures[0] : undefined; + } + if (signature) { + if (useConstructSignatures && (symbolFlags & 32)) { + symbolKind = "constructor"; + addPrefixForAnyFunctionOrVar(type.symbol, symbolKind); } - } - var callExpressionLike = void 0; - if (ts.isCallOrNewExpression(location)) { - callExpressionLike = location; - } - else if (ts.isCallExpressionTarget(location) || ts.isNewExpressionTarget(location)) { - callExpressionLike = location.parent; - } - else if (location.parent && ts.isJsxOpeningLikeElement(location.parent) && ts.isFunctionLike(symbol.valueDeclaration)) { - callExpressionLike = location.parent; - } - if (callExpressionLike) { - var candidateSignatures = []; - signature = typeChecker.getResolvedSignature(callExpressionLike, candidateSignatures); - if (!signature && candidateSignatures.length) { - signature = candidateSignatures[0]; - } - var useConstructSignatures = callExpressionLike.kind === 182 || (ts.isCallExpression(callExpressionLike) && callExpressionLike.expression.kind === 97); - var allSignatures = useConstructSignatures ? type.getConstructSignatures() : type.getCallSignatures(); - if (!ts.contains(allSignatures, signature.target) && !ts.contains(allSignatures, signature)) { - signature = allSignatures.length ? allSignatures[0] : undefined; - } - if (signature) { - if (useConstructSignatures && (symbolFlags & 32)) { - symbolKind = "constructor"; - addPrefixForAnyFunctionOrVar(type.symbol, symbolKind); + else if (symbolFlags & 2097152) { + symbolKind = "alias"; + pushTypePart(symbolKind); + displayParts.push(ts.spacePart()); + if (useConstructSignatures) { + displayParts.push(ts.keywordPart(94)); + displayParts.push(ts.spacePart()); } - else if (symbolFlags & 2097152) { - symbolKind = "alias"; - pushTypePart(symbolKind); + addFullSymbolName(symbol); + } + else { + addPrefixForAnyFunctionOrVar(symbol, symbolKind); + } + switch (symbolKind) { + case "JSX attribute": + case "property": + case "var": + case "const": + case "let": + case "parameter": + case "local var": + displayParts.push(ts.punctuationPart(56)); displayParts.push(ts.spacePart()); if (useConstructSignatures) { displayParts.push(ts.keywordPart(94)); displayParts.push(ts.spacePart()); } - addFullSymbolName(symbol); - } - else { - addPrefixForAnyFunctionOrVar(symbol, symbolKind); - } - switch (symbolKind) { - case "JSX attribute": - case "property": - case "var": - case "const": - case "let": - case "parameter": - case "local var": - displayParts.push(ts.punctuationPart(56)); - displayParts.push(ts.spacePart()); - if (useConstructSignatures) { - displayParts.push(ts.keywordPart(94)); - displayParts.push(ts.spacePart()); - } - if (!(type.flags & 32768 && type.objectFlags & 16) && type.symbol) { - ts.addRange(displayParts, ts.symbolToDisplayParts(typeChecker, type.symbol, enclosingDeclaration, undefined, 1)); - } - addSignatureDisplayParts(signature, allSignatures, 16); - break; - default: - addSignatureDisplayParts(signature, allSignatures); - } - hasAddedSymbolInfo = true; + if (!(type.flags & 32768 && type.objectFlags & 16) && type.symbol) { + ts.addRange(displayParts, ts.symbolToDisplayParts(typeChecker, type.symbol, enclosingDeclaration, undefined, 1)); + } + addSignatureDisplayParts(signature, allSignatures, 16); + break; + default: + addSignatureDisplayParts(signature, allSignatures); } + hasAddedSymbolInfo = true; } - else if ((ts.isNameOfFunctionDeclaration(location) && !(symbolFlags & 98304)) || - (location.kind === 123 && location.parent.kind === 152)) { - var functionDeclaration_1 = location.parent; - var locationIsSymbolDeclaration = ts.findDeclaration(symbol, function (declaration) { - return declaration === (location.kind === 123 ? functionDeclaration_1.parent : functionDeclaration_1); - }); - if (locationIsSymbolDeclaration) { - var allSignatures = functionDeclaration_1.kind === 152 ? type.getNonNullableType().getConstructSignatures() : type.getNonNullableType().getCallSignatures(); - if (!typeChecker.isImplementationOfOverload(functionDeclaration_1)) { - signature = typeChecker.getSignatureFromDeclaration(functionDeclaration_1); - } - else { - signature = allSignatures[0]; - } - if (functionDeclaration_1.kind === 152) { - symbolKind = "constructor"; - addPrefixForAnyFunctionOrVar(type.symbol, symbolKind); - } - else { - addPrefixForAnyFunctionOrVar(functionDeclaration_1.kind === 155 && - !(type.symbol.flags & 2048 || type.symbol.flags & 4096) ? type.symbol : symbol, symbolKind); - } - addSignatureDisplayParts(signature, allSignatures); - hasAddedSymbolInfo = true; + } + else if ((ts.isNameOfFunctionDeclaration(location) && !(symbolFlags & 98304)) || + (location.kind === 123 && location.parent.kind === 152)) { + var functionDeclaration_1 = location.parent; + var locationIsSymbolDeclaration = ts.find(symbol.declarations, function (declaration) { + return declaration === (location.kind === 123 ? functionDeclaration_1.parent : functionDeclaration_1); + }); + if (locationIsSymbolDeclaration) { + var allSignatures = functionDeclaration_1.kind === 152 ? type.getNonNullableType().getConstructSignatures() : type.getNonNullableType().getCallSignatures(); + if (!typeChecker.isImplementationOfOverload(functionDeclaration_1)) { + signature = typeChecker.getSignatureFromDeclaration(functionDeclaration_1); } + else { + signature = allSignatures[0]; + } + if (functionDeclaration_1.kind === 152) { + symbolKind = "constructor"; + addPrefixForAnyFunctionOrVar(type.symbol, symbolKind); + } + else { + addPrefixForAnyFunctionOrVar(functionDeclaration_1.kind === 155 && + !(type.symbol.flags & 2048 || type.symbol.flags & 4096) ? type.symbol : symbol, symbolKind); + } + addSignatureDisplayParts(signature, allSignatures); + hasAddedSymbolInfo = true; } } } @@ -69361,7 +69817,9 @@ var ts; symbolFlags & 98304 || symbolKind === "method") { var allSignatures = type.getNonNullableType().getCallSignatures(); - addSignatureDisplayParts(allSignatures[0], allSignatures); + if (allSignatures.length) { + addSignatureDisplayParts(allSignatures[0], allSignatures); + } } } } @@ -69509,11 +69967,11 @@ var ts; getSourceFile: function (fileName) { return fileName === ts.normalizePath(inputFileName) ? sourceFile : undefined; }, writeFile: function (name, text) { if (ts.fileExtensionIs(name, ".map")) { - ts.Debug.assert(sourceMapText === undefined, "Unexpected multiple source map outputs for the file '" + name + "'"); + ts.Debug.assertEqual(sourceMapText, undefined, "Unexpected multiple source map outputs, file:", name); sourceMapText = text; } else { - ts.Debug.assert(outputText === undefined, "Unexpected multiple outputs for the file: '" + name + "'"); + ts.Debug.assertEqual(outputText, undefined, "Unexpected multiple outputs, file:", name); outputText = text; } }, @@ -70132,6 +70590,7 @@ var ts; this.NoSpaceAfterSemicolonInFor = new formatting.Rule(formatting.RuleDescriptor.create3(25, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsOptionDisabledOrUndefined("insertSpaceAfterSemicolonInForStatements"), Rules.IsNonJsxSameLineTokenContext, Rules.IsForContext), 8)); this.SpaceAfterOpenParen = new formatting.Rule(formatting.RuleDescriptor.create3(19, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis"), Rules.IsNonJsxSameLineTokenContext), 2)); this.SpaceBeforeCloseParen = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 20), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis"), Rules.IsNonJsxSameLineTokenContext), 2)); + this.SpaceBetweenOpenParens = new formatting.Rule(formatting.RuleDescriptor.create1(19, 19), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis"), Rules.IsNonJsxSameLineTokenContext), 2)); this.NoSpaceBetweenParens = new formatting.Rule(formatting.RuleDescriptor.create1(19, 20), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); this.NoSpaceAfterOpenParen = new formatting.Rule(formatting.RuleDescriptor.create3(19, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis"), Rules.IsNonJsxSameLineTokenContext), 8)); this.NoSpaceBeforeCloseParen = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 20), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis"), Rules.IsNonJsxSameLineTokenContext), 8)); @@ -70203,7 +70662,7 @@ var ts; this.SpaceAfterComma, this.NoSpaceAfterComma, this.SpaceAfterAnonymousFunctionKeyword, this.NoSpaceAfterAnonymousFunctionKeyword, this.SpaceAfterKeywordInControl, this.NoSpaceAfterKeywordInControl, - this.SpaceAfterOpenParen, this.SpaceBeforeCloseParen, this.NoSpaceBetweenParens, this.NoSpaceAfterOpenParen, this.NoSpaceBeforeCloseParen, + this.SpaceAfterOpenParen, this.SpaceBeforeCloseParen, this.SpaceBetweenOpenParens, this.NoSpaceBetweenParens, this.NoSpaceAfterOpenParen, this.NoSpaceBeforeCloseParen, this.SpaceAfterOpenBracket, this.SpaceBeforeCloseBracket, this.NoSpaceBetweenBrackets, this.NoSpaceAfterOpenBracket, this.NoSpaceBeforeCloseBracket, this.SpaceAfterOpenBrace, this.SpaceBeforeCloseBrace, this.NoSpaceBetweenEmptyBraceBrackets, this.NoSpaceAfterOpenBrace, this.NoSpaceBeforeCloseBrace, this.SpaceAfterTemplateHeadAndMiddle, this.SpaceBeforeTemplateMiddleAndTail, this.NoSpaceAfterTemplateHeadAndMiddle, this.NoSpaceBeforeTemplateMiddleAndTail, @@ -71003,7 +71462,6 @@ var ts; } function formatSpanWorker(originalRange, enclosingNode, initialIndentation, delta, formattingScanner, options, rulesProvider, requestKind, rangeContainsError, sourceFile) { var formattingContext = new formatting.FormattingContext(sourceFile, requestKind, options); - var previousRangeHasError; var previousRange; var previousParent; var previousRangeStartLine; @@ -71339,7 +71797,7 @@ var ts; function processRange(range, rangeStart, parent, contextNode, dynamicIndentation) { var rangeHasError = rangeContainsError(range); var lineAdded; - if (!rangeHasError && !previousRangeHasError) { + if (!rangeHasError) { if (!previousRange) { var originalStart = sourceFile.getLineAndCharacterOfPosition(originalRange.pos); trimTrailingWhitespacesForLines(originalStart.line, rangeStart.line); @@ -71352,7 +71810,6 @@ var ts; previousRange = range; previousParent = parent; previousRangeStartLine = rangeStart.line; - previousRangeHasError = rangeHasError; return lineAdded; } function processPair(currentItem, currentStartLine, currentParent, previousItem, previousStartLine, previousParent, contextNode, dynamicIndentation) { @@ -71531,6 +71988,32 @@ var ts; } } } + function getRangeOfEnclosingComment(sourceFile, position, onlyMultiLine, precedingToken, tokenAtPosition, predicate) { + if (tokenAtPosition === void 0) { tokenAtPosition = ts.getTokenAtPosition(sourceFile, position, false); } + var tokenStart = tokenAtPosition.getStart(sourceFile); + if (tokenStart <= position && position < tokenAtPosition.getEnd()) { + return undefined; + } + if (precedingToken === undefined) { + precedingToken = ts.findPrecedingToken(position, sourceFile); + } + var trailingRangesOfPreviousToken = precedingToken && ts.getTrailingCommentRanges(sourceFile.text, precedingToken.end); + var leadingCommentRangesOfNextToken = ts.getLeadingCommentRangesOfNode(tokenAtPosition, sourceFile); + var commentRanges = trailingRangesOfPreviousToken && leadingCommentRangesOfNextToken ? + trailingRangesOfPreviousToken.concat(leadingCommentRangesOfNextToken) : + trailingRangesOfPreviousToken || leadingCommentRangesOfNextToken; + if (commentRanges) { + for (var _i = 0, commentRanges_1 = commentRanges; _i < commentRanges_1.length; _i++) { + var range = commentRanges_1[_i]; + if ((range.pos < position && position < range.end || + position === range.end && (range.kind === 2 || position === sourceFile.getFullWidth()))) { + return (range.kind === 3 || !onlyMultiLine) && (!predicate || predicate(range)) ? range : undefined; + } + } + } + return undefined; + } + formatting.getRangeOfEnclosingComment = getRangeOfEnclosingComment; function getOpenTokenForList(node, list) { switch (node.kind) { case 152: @@ -71641,11 +72124,27 @@ var ts; return 0; } var precedingToken = ts.findPrecedingToken(position, sourceFile); + var enclosingCommentRange = formatting.getRangeOfEnclosingComment(sourceFile, position, true, precedingToken || null); + if (enclosingCommentRange) { + var previousLine = ts.getLineAndCharacterOfPosition(sourceFile, position).line - 1; + var commentStartLine = ts.getLineAndCharacterOfPosition(sourceFile, enclosingCommentRange.pos).line; + ts.Debug.assert(commentStartLine >= 0); + if (previousLine <= commentStartLine) { + return findFirstNonWhitespaceColumn(ts.getStartPositionOfLine(commentStartLine, sourceFile), position, sourceFile, options); + } + var startPostionOfLine = ts.getStartPositionOfLine(previousLine, sourceFile); + var _a = findFirstNonWhitespaceCharacterAndColumn(startPostionOfLine, position, sourceFile, options), column = _a.column, character = _a.character; + if (column === 0) { + return column; + } + var firstNonWhitespaceCharacterCode = sourceFile.text.charCodeAt(startPostionOfLine + character); + return firstNonWhitespaceCharacterCode === 42 ? column - 1 : column; + } if (!precedingToken) { return getBaseIndentation(options); } var precedingTokenIsLiteral = ts.isStringOrRegularExpressionOrTemplateLiteral(precedingToken.kind); - if (precedingTokenIsLiteral && precedingToken.getStart(sourceFile) <= position && precedingToken.end > position) { + if (precedingTokenIsLiteral && precedingToken.getStart(sourceFile) <= position && position < precedingToken.end) { return 0; } var lineAtPosition = sourceFile.getLineAndCharacterOfPosition(position).line; @@ -72050,6 +72549,12 @@ var ts; } return false; } + var ChangeKind; + (function (ChangeKind) { + ChangeKind[ChangeKind["Remove"] = 0] = "Remove"; + ChangeKind[ChangeKind["ReplaceWithSingleNode"] = 1] = "ReplaceWithSingleNode"; + ChangeKind[ChangeKind["ReplaceWithMultipleNodes"] = 2] = "ReplaceWithMultipleNodes"; + })(ChangeKind || (ChangeKind = {})); function getSeparatorCharacter(separator) { return ts.tokenToString(separator.kind); } @@ -72074,7 +72579,7 @@ var ts; } textChanges.getAdjustedStartPosition = getAdjustedStartPosition; function getAdjustedEndPosition(sourceFile, node, options) { - if (options.useNonAdjustedEndPosition) { + if (options.useNonAdjustedEndPosition || ts.isExpression(node)) { return node.getEnd(); } var end = node.getEnd(); @@ -72094,6 +72599,9 @@ var ts; } return s; } + function getNewlineKind(context) { + return context.newLineCharacter === "\n" ? 1 : 0; + } var ChangeTracker = (function () { function ChangeTracker(newLine, rulesProvider, validator) { this.newLine = newLine; @@ -72103,24 +72611,24 @@ var ts; this.newLineCharacter = ts.getNewLineCharacter({ newLine: newLine }); } ChangeTracker.fromCodeFixContext = function (context) { - return new ChangeTracker(context.newLineCharacter === "\n" ? 1 : 0, context.rulesProvider); + return new ChangeTracker(getNewlineKind(context), context.rulesProvider); + }; + ChangeTracker.prototype.deleteRange = function (sourceFile, range) { + this.changes.push({ kind: ChangeKind.Remove, sourceFile: sourceFile, range: range }); + return this; }; ChangeTracker.prototype.deleteNode = function (sourceFile, node, options) { if (options === void 0) { options = {}; } var startPosition = getAdjustedStartPosition(sourceFile, node, options, Position.FullStart); var endPosition = getAdjustedEndPosition(sourceFile, node, options); - this.changes.push({ sourceFile: sourceFile, options: options, range: { pos: startPosition, end: endPosition } }); - return this; - }; - ChangeTracker.prototype.deleteRange = function (sourceFile, range) { - this.changes.push({ sourceFile: sourceFile, range: range }); + this.changes.push({ kind: ChangeKind.Remove, sourceFile: sourceFile, range: { pos: startPosition, end: endPosition } }); return this; }; ChangeTracker.prototype.deleteNodeRange = function (sourceFile, startNode, endNode, options) { if (options === void 0) { options = {}; } var startPosition = getAdjustedStartPosition(sourceFile, startNode, options, Position.FullStart); var endPosition = getAdjustedEndPosition(sourceFile, endNode, options); - this.changes.push({ sourceFile: sourceFile, options: options, range: { pos: startPosition, end: endPosition } }); + this.changes.push({ kind: ChangeKind.Remove, sourceFile: sourceFile, range: { pos: startPosition, end: endPosition } }); return this; }; ChangeTracker.prototype.deleteNodeInList = function (sourceFile, node) { @@ -72156,33 +72664,68 @@ var ts; }; ChangeTracker.prototype.replaceRange = function (sourceFile, range, newNode, options) { if (options === void 0) { options = {}; } - this.changes.push({ sourceFile: sourceFile, range: range, options: options, node: newNode }); + this.changes.push({ kind: ChangeKind.ReplaceWithSingleNode, sourceFile: sourceFile, range: range, options: options, node: newNode }); return this; }; ChangeTracker.prototype.replaceNode = function (sourceFile, oldNode, newNode, options) { if (options === void 0) { options = {}; } var startPosition = getAdjustedStartPosition(sourceFile, oldNode, options, Position.Start); var endPosition = getAdjustedEndPosition(sourceFile, oldNode, options); - this.changes.push({ sourceFile: sourceFile, options: options, useIndentationFromFile: true, node: newNode, range: { pos: startPosition, end: endPosition } }); - return this; + return this.replaceWithSingle(sourceFile, startPosition, endPosition, newNode, options); }; ChangeTracker.prototype.replaceNodeRange = function (sourceFile, startNode, endNode, newNode, options) { if (options === void 0) { options = {}; } var startPosition = getAdjustedStartPosition(sourceFile, startNode, options, Position.Start); var endPosition = getAdjustedEndPosition(sourceFile, endNode, options); - this.changes.push({ sourceFile: sourceFile, options: options, useIndentationFromFile: true, node: newNode, range: { pos: startPosition, end: endPosition } }); + return this.replaceWithSingle(sourceFile, startPosition, endPosition, newNode, options); + }; + ChangeTracker.prototype.replaceWithSingle = function (sourceFile, startPosition, endPosition, newNode, options) { + this.changes.push({ + kind: ChangeKind.ReplaceWithSingleNode, + sourceFile: sourceFile, + options: options, + node: newNode, + range: { pos: startPosition, end: endPosition } + }); return this; }; + ChangeTracker.prototype.replaceWithMultiple = function (sourceFile, startPosition, endPosition, newNodes, options) { + this.changes.push({ + kind: ChangeKind.ReplaceWithMultipleNodes, + sourceFile: sourceFile, + options: options, + nodes: newNodes, + range: { pos: startPosition, end: endPosition } + }); + return this; + }; + ChangeTracker.prototype.replaceNodeWithNodes = function (sourceFile, oldNode, newNodes, options) { + var startPosition = getAdjustedStartPosition(sourceFile, oldNode, options, Position.Start); + var endPosition = getAdjustedEndPosition(sourceFile, oldNode, options); + return this.replaceWithMultiple(sourceFile, startPosition, endPosition, newNodes, options); + }; + ChangeTracker.prototype.replaceNodesWithNodes = function (sourceFile, oldNodes, newNodes, options) { + var startPosition = getAdjustedStartPosition(sourceFile, oldNodes[0], options, Position.Start); + var endPosition = getAdjustedEndPosition(sourceFile, ts.lastOrUndefined(oldNodes), options); + return this.replaceWithMultiple(sourceFile, startPosition, endPosition, newNodes, options); + }; + ChangeTracker.prototype.replaceRangeWithNodes = function (sourceFile, range, newNodes, options) { + return this.replaceWithMultiple(sourceFile, range.pos, range.end, newNodes, options); + }; + ChangeTracker.prototype.replaceNodeRangeWithNodes = function (sourceFile, startNode, endNode, newNodes, options) { + var startPosition = getAdjustedStartPosition(sourceFile, startNode, options, Position.Start); + var endPosition = getAdjustedEndPosition(sourceFile, endNode, options); + return this.replaceWithMultiple(sourceFile, startPosition, endPosition, newNodes, options); + }; ChangeTracker.prototype.insertNodeAt = function (sourceFile, pos, newNode, options) { if (options === void 0) { options = {}; } - this.changes.push({ sourceFile: sourceFile, options: options, node: newNode, range: { pos: pos, end: pos } }); + this.changes.push({ kind: ChangeKind.ReplaceWithSingleNode, sourceFile: sourceFile, options: options, node: newNode, range: { pos: pos, end: pos } }); return this; }; ChangeTracker.prototype.insertNodeBefore = function (sourceFile, before, newNode, options) { if (options === void 0) { options = {}; } var startPosition = getAdjustedStartPosition(sourceFile, before, options, Position.Start); - this.changes.push({ sourceFile: sourceFile, options: options, useIndentationFromFile: true, node: newNode, range: { pos: startPosition, end: startPosition } }); - return this; + return this.replaceWithSingle(sourceFile, startPosition, startPosition, newNode, options); }; ChangeTracker.prototype.insertNodeAfter = function (sourceFile, after, newNode, options) { if (options === void 0) { options = {}; } @@ -72192,6 +72735,7 @@ var ts; after.kind === 150) { if (sourceFile.text.charCodeAt(after.end - 1) !== 59) { this.changes.push({ + kind: ChangeKind.ReplaceWithSingleNode, sourceFile: sourceFile, options: {}, range: { pos: after.end, end: after.end }, @@ -72200,8 +72744,7 @@ var ts; } } var endPosition = getAdjustedEndPosition(sourceFile, after, options); - this.changes.push({ sourceFile: sourceFile, options: options, useIndentationFromFile: true, node: newNode, range: { pos: endPosition, end: endPosition } }); - return this; + return this.replaceWithSingle(sourceFile, endPosition, endPosition, newNode, options); }; ChangeTracker.prototype.insertNodeInListAfter = function (sourceFile, after, newNode) { var containingList = ts.formatting.SmartIndenter.getContainingList(after, sourceFile); @@ -72229,10 +72772,10 @@ var ts; startPos = ts.getStartPositionOfLine(lineAndCharOfNextElement.line, sourceFile); } this.changes.push({ + kind: ChangeKind.ReplaceWithSingleNode, sourceFile: sourceFile, range: { pos: startPos, end: containingList[index + 1].getStart(sourceFile) }, node: newNode, - useIndentationFromFile: true, options: { prefix: prefix, suffix: "" + ts.tokenToString(nextToken.kind) + sourceFile.text.substring(nextToken.end, containingList[index + 1].getStart(sourceFile)) @@ -72259,6 +72802,7 @@ var ts; } if (multilineList) { this.changes.push({ + kind: ChangeKind.ReplaceWithSingleNode, sourceFile: sourceFile, range: { pos: end, end: end }, node: ts.createToken(separator), @@ -72270,6 +72814,7 @@ var ts; insertPos--; } this.changes.push({ + kind: ChangeKind.ReplaceWithSingleNode, sourceFile: sourceFile, range: { pos: insertPos, end: insertPos }, node: newNode, @@ -72278,6 +72823,7 @@ var ts; } else { this.changes.push({ + kind: ChangeKind.ReplaceWithSingleNode, sourceFile: sourceFile, range: { pos: end, end: end }, node: newNode, @@ -72317,31 +72863,44 @@ var ts; return ts.createTextSpanFromBounds(change.range.pos, change.range.end); }; ChangeTracker.prototype.computeNewText = function (change, sourceFile) { - if (!change.node) { + var _this = this; + if (change.kind === ChangeKind.Remove) { return ""; } var options = change.options || {}; - var nonFormattedText = getNonformattedText(change.node, sourceFile, this.newLine); - if (this.validator) { - this.validator(nonFormattedText); - } - var formatOptions = this.rulesProvider.getFormatOptions(); + var text; var pos = change.range.pos; var posStartsLine = ts.getLineStartPositionForPosition(pos, sourceFile) === pos; - var initialIndentation = change.options.indentation !== undefined - ? change.options.indentation - : change.useIndentationFromFile - ? ts.formatting.SmartIndenter.getIndentation(change.range.pos, sourceFile, formatOptions, posStartsLine || (change.options.prefix === this.newLineCharacter)) - : 0; - var delta = change.options.delta !== undefined - ? change.options.delta - : ts.formatting.SmartIndenter.shouldIndentChildNode(change.node) - ? formatOptions.indentSize - : 0; - var text = applyFormatting(nonFormattedText, sourceFile, initialIndentation, delta, this.rulesProvider); - text = posStartsLine || change.options.indentation !== undefined ? text : text.replace(/^\s+/, ""); + if (change.kind === ChangeKind.ReplaceWithMultipleNodes) { + var parts = change.nodes.map(function (n) { return _this.getFormattedTextOfNode(n, sourceFile, pos, options); }); + text = parts.join(change.options.nodeSeparator); + } + else { + ts.Debug.assert(change.kind === ChangeKind.ReplaceWithSingleNode, "change.kind === ReplaceWithSingleNode"); + text = this.getFormattedTextOfNode(change.node, sourceFile, pos, options); + } + text = (posStartsLine || options.indentation !== undefined) ? text : text.replace(/^\s+/, ""); return (options.prefix || "") + text + (options.suffix || ""); }; + ChangeTracker.prototype.getFormattedTextOfNode = function (node, sourceFile, pos, options) { + var nonformattedText = getNonformattedText(node, sourceFile, this.newLine); + if (this.validator) { + this.validator(nonformattedText); + } + var formatOptions = this.rulesProvider.getFormatOptions(); + var posStartsLine = ts.getLineStartPositionForPosition(pos, sourceFile) === pos; + var initialIndentation = options.indentation !== undefined + ? options.indentation + : (options.useIndentationFromFile !== false) + ? ts.formatting.SmartIndenter.getIndentation(pos, sourceFile, formatOptions, posStartsLine || (options.prefix === this.newLineCharacter)) + : 0; + var delta = options.delta !== undefined + ? options.delta + : ts.formatting.SmartIndenter.shouldIndentChildNode(node) + ? (formatOptions.indentSize || 0) + : 0; + return applyFormatting(nonformattedText, sourceFile, initialIndentation, delta, this.rulesProvider); + }; ChangeTracker.normalize = function (changes) { var normalized = ts.stableSort(changes, function (a, b) { return a.range.pos - b.range.pos; }); for (var i = 0; i < normalized.length - 2; i++) { @@ -73319,7 +73878,7 @@ var ts; symbolName = name; } else if (ts.isJsxOpeningLikeElement(token.parent) && token.parent.tagName === token) { - symbol = checker.getAliasedSymbol(checker.resolveNameAtLocation(token, checker.getJsxNamespace(), 107455)); + symbol = checker.getAliasedSymbol(checker.resolveName(checker.getJsxNamespace(), token.parent.tagName, 107455)); symbolName = symbol.name; } else { @@ -73403,8 +73962,8 @@ var ts; var namespaceImportDeclaration; var namedImportDeclaration; var existingModuleSpecifier; - for (var _i = 0, declarations_14 = declarations; _i < declarations_14.length; _i++) { - var declaration = declarations_14[_i]; + for (var _i = 0, declarations_13 = declarations; _i < declarations_13.length; _i++) { + var declaration = declarations_13[_i]; if (declaration.kind === 238) { var namedBindings = declaration.importClause && declaration.importClause.namedBindings; if (namedBindings && namedBindings.kind === 240) { @@ -73478,14 +74037,53 @@ var ts; : isNamespaceImport ? ts.createImportClause(undefined, ts.createNamespaceImport(ts.createIdentifier(symbolName))) : ts.createImportClause(undefined, ts.createNamedImports([ts.createImportSpecifier(undefined, ts.createIdentifier(symbolName))])); - var importDecl = ts.createImportDeclaration(undefined, undefined, importClause, ts.createLiteral(moduleSpecifierWithoutQuotes)); + var moduleSpecifierLiteral = ts.createLiteral(moduleSpecifierWithoutQuotes); + moduleSpecifierLiteral.singleQuote = getSingleQuoteStyleFromExistingImports(); + var importDecl = ts.createImportDeclaration(undefined, undefined, importClause, moduleSpecifierLiteral); if (!lastImportDeclaration) { - changeTracker.insertNodeAt(sourceFile, sourceFile.getStart(), importDecl, { suffix: "" + context.newLineCharacter + context.newLineCharacter }); + changeTracker.insertNodeAt(sourceFile, getSourceFileImportLocation(sourceFile), importDecl, { suffix: "" + context.newLineCharacter + context.newLineCharacter }); } else { changeTracker.insertNodeAfter(sourceFile, lastImportDeclaration, importDecl, { suffix: context.newLineCharacter }); } return createCodeAction(ts.Diagnostics.Import_0_from_1, [symbolName, "\"" + moduleSpecifierWithoutQuotes + "\""], changeTracker.getChanges(), "NewImport", moduleSpecifierWithoutQuotes); + function getSourceFileImportLocation(node) { + var text = node.text; + var ranges = ts.getLeadingCommentRanges(text, 0); + if (!ranges) + return 0; + var position = 0; + if (ranges.length && ranges[0].kind === 3 && ts.isPinnedComment(text, ranges[0])) { + position = ranges[0].end + 1; + ranges = ranges.slice(1); + } + for (var _i = 0, ranges_1 = ranges; _i < ranges_1.length; _i++) { + var range = ranges_1[_i]; + if (range.kind === 2 && ts.isRecognizedTripleSlashComment(node.text, range.pos, range.end)) { + position = range.end + 1; + continue; + } + break; + } + return position; + } + function getSingleQuoteStyleFromExistingImports() { + var firstModuleSpecifier = ts.forEach(sourceFile.statements, function (node) { + if (ts.isImportDeclaration(node) || ts.isExportDeclaration(node)) { + if (node.moduleSpecifier && ts.isStringLiteral(node.moduleSpecifier)) { + return node.moduleSpecifier; + } + } + else if (ts.isImportEqualsDeclaration(node)) { + if (ts.isExternalModuleReference(node.moduleReference) && ts.isStringLiteral(node.moduleReference.expression)) { + return node.moduleReference.expression; + } + } + }); + if (firstModuleSpecifier) { + return sourceFile.text.charCodeAt(firstModuleSpecifier.getStart()) === 39; + } + } function getModuleSpecifierForNewImport() { var fileName = sourceFile.fileName; var moduleFileName = moduleSymbol.valueDeclaration.getSourceFile().fileName; @@ -73615,7 +74213,8 @@ var ts; (function (States) { States[States["BeforeNodeModules"] = 0] = "BeforeNodeModules"; States[States["NodeModules"] = 1] = "NodeModules"; - States[States["PackageContent"] = 2] = "PackageContent"; + States[States["Scope"] = 2] = "Scope"; + States[States["PackageContent"] = 3] = "PackageContent"; })(States || (States = {})); var partStart = 0; var partEnd = 0; @@ -73632,15 +74231,21 @@ var ts; } break; case 1: - packageRootIndex = partEnd; - state = 2; - break; case 2: + if (state === 1 && fullPath.charAt(partStart + 1) === "@") { + state = 2; + } + else { + packageRootIndex = partEnd; + state = 3; + } + break; + case 3: if (fullPath.indexOf("/node_modules/", partStart) === partStart) { state = 1; } else { - state = 2; + state = 3; } break; } @@ -73930,206 +74535,1029 @@ var ts; (function (ts) { var refactor; (function (refactor) { - var actionName = "convert"; - var convertFunctionToES6Class = { - name: "Convert to ES2015 class", - description: ts.Diagnostics.Convert_function_to_an_ES2015_class.message, - getEditsForAction: getEditsForAction, - getAvailableActions: getAvailableActions - }; - refactor.registerRefactor(convertFunctionToES6Class); - function getAvailableActions(context) { - if (!ts.isInJavaScriptFile(context.file)) { - return undefined; + var convertFunctionToES6Class; + (function (convertFunctionToES6Class_1) { + var actionName = "convert"; + var convertFunctionToES6Class = { + name: "Convert to ES2015 class", + description: ts.Diagnostics.Convert_function_to_an_ES2015_class.message, + getEditsForAction: getEditsForAction, + getAvailableActions: getAvailableActions + }; + refactor.registerRefactor(convertFunctionToES6Class); + function getAvailableActions(context) { + if (!ts.isInJavaScriptFile(context.file)) { + return undefined; + } + var start = context.startPosition; + var node = ts.getTokenAtPosition(context.file, start, false); + var checker = context.program.getTypeChecker(); + var symbol = checker.getSymbolAtLocation(node); + if (symbol && ts.isDeclarationOfFunctionOrClassExpression(symbol)) { + symbol = symbol.valueDeclaration.initializer.symbol; + } + if (symbol && (symbol.flags & 16) && symbol.members && (symbol.members.size > 0)) { + return [ + { + name: convertFunctionToES6Class.name, + description: convertFunctionToES6Class.description, + actions: [ + { + description: convertFunctionToES6Class.description, + name: actionName + } + ] + } + ]; + } } - var start = context.startPosition; - var node = ts.getTokenAtPosition(context.file, start, false); - var checker = context.program.getTypeChecker(); - var symbol = checker.getSymbolAtLocation(node); - if (symbol && ts.isDeclarationOfFunctionOrClassExpression(symbol)) { - symbol = symbol.valueDeclaration.initializer.symbol; - } - if (symbol && (symbol.flags & 16) && symbol.members && (symbol.members.size > 0)) { - return [ - { - name: convertFunctionToES6Class.name, - description: convertFunctionToES6Class.description, - actions: [ - { - description: convertFunctionToES6Class.description, - name: actionName - } - ] + function getEditsForAction(context, action) { + if (actionName !== action) { + return undefined; + } + var start = context.startPosition; + var sourceFile = context.file; + var checker = context.program.getTypeChecker(); + var token = ts.getTokenAtPosition(sourceFile, start, false); + var ctorSymbol = checker.getSymbolAtLocation(token); + var newLine = context.rulesProvider.getFormatOptions().newLineCharacter; + var deletedNodes = []; + var deletes = []; + if (!(ctorSymbol.flags & (16 | 3))) { + return undefined; + } + var ctorDeclaration = ctorSymbol.valueDeclaration; + var changeTracker = ts.textChanges.ChangeTracker.fromCodeFixContext(context); + var precedingNode; + var newClassDeclaration; + switch (ctorDeclaration.kind) { + case 228: + precedingNode = ctorDeclaration; + deleteNode(ctorDeclaration); + newClassDeclaration = createClassFromFunctionDeclaration(ctorDeclaration); + break; + case 226: + precedingNode = ctorDeclaration.parent.parent; + if (ctorDeclaration.parent.declarations.length === 1) { + deleteNode(precedingNode); + } + else { + deleteNode(ctorDeclaration, true); + } + newClassDeclaration = createClassFromVariableDeclaration(ctorDeclaration); + break; + } + if (!newClassDeclaration) { + return undefined; + } + changeTracker.insertNodeAfter(sourceFile, precedingNode, newClassDeclaration, { suffix: newLine }); + for (var _i = 0, deletes_1 = deletes; _i < deletes_1.length; _i++) { + var deleteCallback = deletes_1[_i]; + deleteCallback(); + } + return { + edits: changeTracker.getChanges() + }; + function deleteNode(node, inList) { + if (inList === void 0) { inList = false; } + if (deletedNodes.some(function (n) { return ts.isNodeDescendantOf(node, n); })) { + return; } - ]; - } - } - function getEditsForAction(context, action) { - if (actionName !== action) { - return undefined; - } - var start = context.startPosition; - var sourceFile = context.file; - var checker = context.program.getTypeChecker(); - var token = ts.getTokenAtPosition(sourceFile, start, false); - var ctorSymbol = checker.getSymbolAtLocation(token); - var newLine = context.rulesProvider.getFormatOptions().newLineCharacter; - var deletedNodes = []; - var deletes = []; - if (!(ctorSymbol.flags & (16 | 3))) { - return undefined; - } - var ctorDeclaration = ctorSymbol.valueDeclaration; - var changeTracker = ts.textChanges.ChangeTracker.fromCodeFixContext(context); - var precedingNode; - var newClassDeclaration; - switch (ctorDeclaration.kind) { - case 228: - precedingNode = ctorDeclaration; - deleteNode(ctorDeclaration); - newClassDeclaration = createClassFromFunctionDeclaration(ctorDeclaration); - break; - case 226: - precedingNode = ctorDeclaration.parent.parent; - if (ctorDeclaration.parent.declarations.length === 1) { - deleteNode(precedingNode); + deletedNodes.push(node); + if (inList) { + deletes.push(function () { return changeTracker.deleteNodeInList(sourceFile, node); }); } else { - deleteNode(ctorDeclaration, true); + deletes.push(function () { return changeTracker.deleteNode(sourceFile, node); }); } - newClassDeclaration = createClassFromVariableDeclaration(ctorDeclaration); - break; - } - if (!newClassDeclaration) { - return undefined; - } - changeTracker.insertNodeAfter(sourceFile, precedingNode, newClassDeclaration, { suffix: newLine }); - for (var _i = 0, deletes_1 = deletes; _i < deletes_1.length; _i++) { - var deleteCallback = deletes_1[_i]; - deleteCallback(); - } - return { - edits: changeTracker.getChanges() - }; - function deleteNode(node, inList) { - if (inList === void 0) { inList = false; } - if (deletedNodes.some(function (n) { return ts.isNodeDescendantOf(node, n); })) { - return; } - deletedNodes.push(node); - if (inList) { - deletes.push(function () { return changeTracker.deleteNodeInList(sourceFile, node); }); + function createClassElementsFromSymbol(symbol) { + var memberElements = []; + if (symbol.members) { + symbol.members.forEach(function (member) { + var memberElement = createClassElement(member, undefined); + if (memberElement) { + memberElements.push(memberElement); + } + }); + } + if (symbol.exports) { + symbol.exports.forEach(function (member) { + var memberElement = createClassElement(member, [ts.createToken(115)]); + if (memberElement) { + memberElements.push(memberElement); + } + }); + } + return memberElements; + function shouldConvertDeclaration(_target, source) { + return ts.isFunctionLike(source); + } + function createClassElement(symbol, modifiers) { + if (!(symbol.flags & 4)) { + return; + } + var memberDeclaration = symbol.valueDeclaration; + var assignmentBinaryExpression = memberDeclaration.parent; + if (!shouldConvertDeclaration(memberDeclaration, assignmentBinaryExpression.right)) { + return; + } + var nodeToDelete = assignmentBinaryExpression.parent && assignmentBinaryExpression.parent.kind === 210 + ? assignmentBinaryExpression.parent : assignmentBinaryExpression; + deleteNode(nodeToDelete); + if (!assignmentBinaryExpression.right) { + return ts.createProperty([], modifiers, symbol.name, undefined, undefined, undefined); + } + switch (assignmentBinaryExpression.right.kind) { + case 186: { + var functionExpression = assignmentBinaryExpression.right; + var method = ts.createMethod(undefined, modifiers, undefined, memberDeclaration.name, undefined, undefined, functionExpression.parameters, undefined, functionExpression.body); + copyComments(assignmentBinaryExpression, method); + return method; + } + case 187: { + var arrowFunction = assignmentBinaryExpression.right; + var arrowFunctionBody = arrowFunction.body; + var bodyBlock = void 0; + if (arrowFunctionBody.kind === 207) { + bodyBlock = arrowFunctionBody; + } + else { + var expression = arrowFunctionBody; + bodyBlock = ts.createBlock([ts.createReturn(expression)]); + } + var method = ts.createMethod(undefined, modifiers, undefined, memberDeclaration.name, undefined, undefined, arrowFunction.parameters, undefined, bodyBlock); + copyComments(assignmentBinaryExpression, method); + return method; + } + default: { + if (ts.isSourceFileJavaScript(sourceFile)) { + return; + } + var prop = ts.createProperty(undefined, modifiers, memberDeclaration.name, undefined, undefined, assignmentBinaryExpression.right); + copyComments(assignmentBinaryExpression.parent, prop); + return prop; + } + } + } + } + function copyComments(sourceNode, targetNode) { + ts.forEachLeadingCommentRange(sourceFile.text, sourceNode.pos, function (pos, end, kind, htnl) { + if (kind === 3) { + pos += 2; + end -= 2; + } + else { + pos += 2; + } + ts.addSyntheticLeadingComment(targetNode, kind, sourceFile.text.slice(pos, end), htnl); + }); + } + function createClassFromVariableDeclaration(node) { + var initializer = node.initializer; + if (!initializer || initializer.kind !== 186) { + return undefined; + } + if (node.name.kind !== 71) { + return undefined; + } + var memberElements = createClassElementsFromSymbol(initializer.symbol); + if (initializer.body) { + memberElements.unshift(ts.createConstructor(undefined, undefined, initializer.parameters, initializer.body)); + } + var cls = ts.createClassDeclaration(undefined, undefined, node.name, undefined, undefined, memberElements); + return cls; + } + function createClassFromFunctionDeclaration(node) { + var memberElements = createClassElementsFromSymbol(ctorSymbol); + if (node.body) { + memberElements.unshift(ts.createConstructor(undefined, undefined, node.parameters, node.body)); + } + var cls = ts.createClassDeclaration(undefined, undefined, node.name, undefined, undefined, memberElements); + return cls; + } + } + })(convertFunctionToES6Class = refactor.convertFunctionToES6Class || (refactor.convertFunctionToES6Class = {})); + })(refactor = ts.refactor || (ts.refactor = {})); +})(ts || (ts = {})); +var ts; +(function (ts) { + var refactor; + (function (refactor) { + var extractMethod; + (function (extractMethod_1) { + var extractMethod = { + name: "Extract Method", + description: ts.Diagnostics.Extract_function.message, + getAvailableActions: getAvailableActions, + getEditsForAction: getEditsForAction, + }; + refactor.registerRefactor(extractMethod); + function getAvailableActions(context) { + var rangeToExtract = getRangeToExtract(context.file, { start: context.startPosition, length: context.endPosition - context.startPosition }); + var targetRange = rangeToExtract.targetRange; + if (targetRange === undefined) { + return undefined; + } + var extractions = getPossibleExtractions(targetRange, context); + if (extractions === undefined) { + return undefined; + } + var actions = []; + var usedNames = ts.createMap(); + var i = 0; + for (var _i = 0, extractions_1 = extractions; _i < extractions_1.length; _i++) { + var extr = extractions_1[_i]; + if (extr.errors && extr.errors.length) { + continue; + } + var description = ts.formatStringFromArgs(ts.Diagnostics.Extract_function_into_0.message, [extr.scopeDescription]); + if (!usedNames.has(description)) { + usedNames.set(description, true); + actions.push({ + description: description, + name: "scope_" + i + }); + } + i++; + } + if (actions.length === 0) { + return undefined; + } + return [{ + name: extractMethod.name, + description: extractMethod.description, + inlineable: true, + actions: actions + }]; + } + function getEditsForAction(context, actionName) { + var length = context.endPosition === undefined ? 0 : context.endPosition - context.startPosition; + var rangeToExtract = getRangeToExtract(context.file, { start: context.startPosition, length: length }); + var targetRange = rangeToExtract.targetRange; + var parsedIndexMatch = /^scope_(\d+)$/.exec(actionName); + ts.Debug.assert(!!parsedIndexMatch, "Scope name should have matched the regexp"); + var index = +parsedIndexMatch[1]; + ts.Debug.assert(isFinite(index), "Expected to parse a finite number from the scope index"); + var extractions = getPossibleExtractions(targetRange, context, index); + ts.Debug.assert(extractions !== undefined, "The extraction went missing? How?"); + return ({ edits: extractions[0].changes }); + } + var Messages; + (function (Messages) { + function createMessage(message) { + return { message: message, code: 0, category: ts.DiagnosticCategory.Message, key: message }; + } + Messages.CannotExtractFunction = createMessage("Cannot extract function."); + Messages.StatementOrExpressionExpected = createMessage("Statement or expression expected."); + Messages.CannotExtractRangeContainingConditionalBreakOrContinueStatements = createMessage("Cannot extract range containing conditional break or continue statements."); + Messages.CannotExtractRangeContainingConditionalReturnStatement = createMessage("Cannot extract range containing conditional return statement."); + Messages.CannotExtractRangeContainingLabeledBreakOrContinueStatementWithTargetOutsideOfTheRange = createMessage("Cannot extract range containing labeled break or continue with target outside of the range."); + Messages.CannotExtractRangeThatContainsWritesToReferencesLocatedOutsideOfTheTargetRangeInGenerators = createMessage("Cannot extract range containing writes to references located outside of the target range in generators."); + Messages.TypeWillNotBeVisibleInTheNewScope = createMessage("Type will not visible in the new scope."); + Messages.FunctionWillNotBeVisibleInTheNewScope = createMessage("Function will not visible in the new scope."); + Messages.InsufficientSelection = createMessage("Select more than a single identifier."); + Messages.CannotExtractExportedEntity = createMessage("Cannot extract exported declaration"); + Messages.CannotCombineWritesAndReturns = createMessage("Cannot combine writes and returns"); + Messages.CannotExtractReadonlyPropertyInitializerOutsideConstructor = createMessage("Cannot move initialization of read-only class property outside of the constructor"); + Messages.CannotExtractAmbientBlock = createMessage("Cannot extract code from ambient contexts"); + })(Messages || (Messages = {})); + var RangeFacts; + (function (RangeFacts) { + RangeFacts[RangeFacts["None"] = 0] = "None"; + RangeFacts[RangeFacts["HasReturn"] = 1] = "HasReturn"; + RangeFacts[RangeFacts["IsGenerator"] = 2] = "IsGenerator"; + RangeFacts[RangeFacts["IsAsyncFunction"] = 4] = "IsAsyncFunction"; + RangeFacts[RangeFacts["UsesThis"] = 8] = "UsesThis"; + RangeFacts[RangeFacts["InStaticRegion"] = 16] = "InStaticRegion"; + })(RangeFacts = extractMethod_1.RangeFacts || (extractMethod_1.RangeFacts = {})); + function getRangeToExtract(sourceFile, span) { + var length = span.length || 0; + var start = getParentNodeInSpan(ts.getTokenAtPosition(sourceFile, span.start, false), sourceFile, span); + var end = getParentNodeInSpan(ts.findTokenOnLeftOfPosition(sourceFile, ts.textSpanEnd(span)), sourceFile, span); + var declarations = []; + var rangeFacts = RangeFacts.None; + if (!start || !end) { + return { errors: [ts.createFileDiagnostic(sourceFile, span.start, length, Messages.CannotExtractFunction)] }; + } + if (start.parent !== end.parent) { + var startParent = ts.skipParentheses(start.parent); + var endParent = ts.skipParentheses(end.parent); + if (ts.isBinaryExpression(startParent) && ts.isBinaryExpression(endParent) && ts.isNodeDescendantOf(startParent, endParent)) { + start = end = endParent; + } + else { + return createErrorResult(sourceFile, span.start, length, Messages.CannotExtractFunction); + } + } + if (start !== end) { + if (!isBlockLike(start.parent)) { + return createErrorResult(sourceFile, span.start, length, Messages.CannotExtractFunction); + } + var statements = []; + for (var _i = 0, _a = start.parent.statements; _i < _a.length; _i++) { + var statement = _a[_i]; + if (statement === start || statements.length) { + var errors = checkNode(statement); + if (errors) { + return { errors: errors }; + } + statements.push(statement); + } + if (statement === end) { + break; + } + } + return { targetRange: { range: statements, facts: rangeFacts, declarations: declarations } }; } else { - deletes.push(function () { return changeTracker.deleteNode(sourceFile, node); }); - } - } - function createClassElementsFromSymbol(symbol) { - var memberElements = []; - if (symbol.members) { - symbol.members.forEach(function (member) { - var memberElement = createClassElement(member, undefined); - if (memberElement) { - memberElements.push(memberElement); - } - }); - } - if (symbol.exports) { - symbol.exports.forEach(function (member) { - var memberElement = createClassElement(member, [ts.createToken(115)]); - if (memberElement) { - memberElements.push(memberElement); - } - }); - } - return memberElements; - function shouldConvertDeclaration(_target, source) { - return ts.isFunctionLike(source); - } - function createClassElement(symbol, modifiers) { - if (!(symbol.flags & 4)) { - return; + var errors = checkRootNode(start) || checkNode(start); + if (errors) { + return { errors: errors }; } - var memberDeclaration = symbol.valueDeclaration; - var assignmentBinaryExpression = memberDeclaration.parent; - if (!shouldConvertDeclaration(memberDeclaration, assignmentBinaryExpression.right)) { - return; + var range = ts.isStatement(start) + ? [start] + : start.parent && start.parent.kind === 210 + ? [start.parent] + : start; + return { targetRange: { range: range, facts: rangeFacts, declarations: declarations } }; + } + function createErrorResult(sourceFile, start, length, message) { + return { errors: [ts.createFileDiagnostic(sourceFile, start, length, message)] }; + } + function checkRootNode(node) { + if (ts.isIdentifier(node)) { + return [ts.createDiagnosticForNode(node, Messages.InsufficientSelection)]; } - var nodeToDelete = assignmentBinaryExpression.parent && assignmentBinaryExpression.parent.kind === 210 - ? assignmentBinaryExpression.parent : assignmentBinaryExpression; - deleteNode(nodeToDelete); - if (!assignmentBinaryExpression.right) { - return ts.createProperty([], modifiers, symbol.name, undefined, undefined, undefined); + return undefined; + } + function checkForStaticContext(nodeToCheck, containingClass) { + var current = nodeToCheck; + while (current !== containingClass) { + if (current.kind === 149) { + if (ts.hasModifier(current, 32)) { + rangeFacts |= RangeFacts.InStaticRegion; + } + break; + } + else if (current.kind === 146) { + var ctorOrMethod = ts.getContainingFunction(current); + if (ctorOrMethod.kind === 152) { + rangeFacts |= RangeFacts.InStaticRegion; + } + break; + } + else if (current.kind === 151) { + if (ts.hasModifier(current, 32)) { + rangeFacts |= RangeFacts.InStaticRegion; + } + } + current = current.parent; } - switch (assignmentBinaryExpression.right.kind) { - case 186: { - var functionExpression = assignmentBinaryExpression.right; - var method = ts.createMethod(undefined, modifiers, undefined, memberDeclaration.name, undefined, undefined, functionExpression.parameters, undefined, functionExpression.body); - copyComments(assignmentBinaryExpression, method); - return method; + } + function checkNode(nodeToCheck) { + var PermittedJumps; + (function (PermittedJumps) { + PermittedJumps[PermittedJumps["None"] = 0] = "None"; + PermittedJumps[PermittedJumps["Break"] = 1] = "Break"; + PermittedJumps[PermittedJumps["Continue"] = 2] = "Continue"; + PermittedJumps[PermittedJumps["Return"] = 4] = "Return"; + })(PermittedJumps || (PermittedJumps = {})); + if (!ts.isStatement(nodeToCheck) && !(ts.isExpression(nodeToCheck) && isExtractableExpression(nodeToCheck))) { + return [ts.createDiagnosticForNode(nodeToCheck, Messages.StatementOrExpressionExpected)]; + } + if (ts.isInAmbientContext(nodeToCheck)) { + return [ts.createDiagnosticForNode(nodeToCheck, Messages.CannotExtractAmbientBlock)]; + } + var containingClass = ts.getContainingClass(nodeToCheck); + if (containingClass) { + checkForStaticContext(nodeToCheck, containingClass); + } + var errors; + var permittedJumps = 4; + var seenLabels; + visit(nodeToCheck); + return errors; + function visit(node) { + if (errors) { + return true; } - case 187: { - var arrowFunction = assignmentBinaryExpression.right; - var arrowFunctionBody = arrowFunction.body; - var bodyBlock = void 0; - if (arrowFunctionBody.kind === 207) { - bodyBlock = arrowFunctionBody; + if (ts.isDeclaration(node)) { + var declaringNode = (node.kind === 226) ? node.parent.parent : node; + if (ts.hasModifier(declaringNode, 1)) { + (errors || (errors = [])).push(ts.createDiagnosticForNode(node, Messages.CannotExtractExportedEntity)); + return true; } - else { - var expression = arrowFunctionBody; - bodyBlock = ts.createBlock([ts.createReturn(expression)]); - } - var method = ts.createMethod(undefined, modifiers, undefined, memberDeclaration.name, undefined, undefined, arrowFunction.parameters, undefined, bodyBlock); - copyComments(assignmentBinaryExpression, method); - return method; + declarations.push(node.symbol); } - default: { - if (ts.isSourceFileJavaScript(sourceFile)) { - return; - } - var prop = ts.createProperty(undefined, modifiers, memberDeclaration.name, undefined, undefined, assignmentBinaryExpression.right); - copyComments(assignmentBinaryExpression.parent, prop); - return prop; + switch (node.kind) { + case 238: + (errors || (errors = [])).push(ts.createDiagnosticForNode(node, Messages.CannotExtractFunction)); + return true; + case 97: + if (node.parent.kind === 181) { + var containingClass_1 = ts.getContainingClass(node); + if (containingClass_1.pos < span.start || containingClass_1.end >= (span.start + span.length)) { + (errors || (errors = [])).push(ts.createDiagnosticForNode(node, Messages.CannotExtractFunction)); + return true; + } + } + else { + rangeFacts |= RangeFacts.UsesThis; + } + break; } + if (!node || ts.isFunctionLike(node) || ts.isClassLike(node)) { + switch (node.kind) { + case 228: + case 229: + if (node.parent.kind === 265 && node.parent.externalModuleIndicator === undefined) { + (errors || (errors = [])).push(ts.createDiagnosticForNode(node, Messages.FunctionWillNotBeVisibleInTheNewScope)); + } + break; + } + return false; + } + var savedPermittedJumps = permittedJumps; + if (node.parent) { + switch (node.parent.kind) { + case 211: + if (node.parent.thenStatement === node || node.parent.elseStatement === node) { + permittedJumps = 0; + } + break; + case 224: + if (node.parent.tryBlock === node) { + permittedJumps = 0; + } + else if (node.parent.finallyBlock === node) { + permittedJumps = 4; + } + break; + case 260: + if (node.parent.block === node) { + permittedJumps = 0; + } + break; + case 257: + if (node.expression !== node) { + permittedJumps |= 1; + } + break; + default: + if (ts.isIterationStatement(node.parent, false)) { + if (node.parent.statement === node) { + permittedJumps |= 1 | 2; + } + } + break; + } + } + switch (node.kind) { + case 169: + case 99: + rangeFacts |= RangeFacts.UsesThis; + break; + case 222: + { + var label = node.label; + (seenLabels || (seenLabels = [])).push(label.escapedText); + ts.forEachChild(node, visit); + seenLabels.pop(); + break; + } + case 218: + case 217: + { + var label = node.label; + if (label) { + if (!ts.contains(seenLabels, label.escapedText)) { + (errors || (errors = [])).push(ts.createDiagnosticForNode(node, Messages.CannotExtractRangeContainingLabeledBreakOrContinueStatementWithTargetOutsideOfTheRange)); + } + } + else { + if (!(permittedJumps & (218 ? 1 : 2))) { + (errors || (errors = [])).push(ts.createDiagnosticForNode(node, Messages.CannotExtractRangeContainingConditionalBreakOrContinueStatements)); + } + } + break; + } + case 191: + rangeFacts |= RangeFacts.IsAsyncFunction; + break; + case 197: + rangeFacts |= RangeFacts.IsGenerator; + break; + case 219: + if (permittedJumps & 4) { + rangeFacts |= RangeFacts.HasReturn; + } + else { + (errors || (errors = [])).push(ts.createDiagnosticForNode(node, Messages.CannotExtractRangeContainingConditionalReturnStatement)); + } + break; + default: + ts.forEachChild(node, visit); + break; + } + permittedJumps = savedPermittedJumps; } } } - function copyComments(sourceNode, targetNode) { - ts.forEachLeadingCommentRange(sourceFile.text, sourceNode.pos, function (pos, end, kind, htnl) { - if (kind === 3) { - pos += 2; - end -= 2; + extractMethod_1.getRangeToExtract = getRangeToExtract; + function isValidExtractionTarget(node) { + return (node.kind === 228) || ts.isSourceFile(node) || ts.isModuleBlock(node) || ts.isClassLike(node); + } + function collectEnclosingScopes(range) { + var current = isReadonlyArray(range.range) ? ts.firstOrUndefined(range.range) : range.range; + if (range.facts & RangeFacts.UsesThis) { + var containingClass = ts.getContainingClass(current); + if (containingClass) { + return [containingClass]; + } + } + var start = current; + var scopes = undefined; + while (current) { + if (current !== start && isValidExtractionTarget(current)) { + (scopes = scopes || []).push(current); + } + if (current && current.parent && current.parent.kind === 146) { + current = ts.findAncestor(current, function (parent) { return ts.isFunctionLike(parent); }).parent; } else { - pos += 2; + current = current.parent; } - ts.addSyntheticLeadingComment(targetNode, kind, sourceFile.text.slice(pos, end), htnl); + } + return scopes; + } + extractMethod_1.collectEnclosingScopes = collectEnclosingScopes; + function getPossibleExtractions(targetRange, context, requestedChangesIndex) { + if (requestedChangesIndex === void 0) { requestedChangesIndex = undefined; } + var sourceFile = context.file; + if (targetRange === undefined) { + return undefined; + } + var scopes = collectEnclosingScopes(targetRange); + if (scopes === undefined) { + return undefined; + } + var enclosingTextRange = getEnclosingTextRange(targetRange, sourceFile); + var _a = collectReadsAndWrites(targetRange, scopes, enclosingTextRange, sourceFile, context.program.getTypeChecker()), target = _a.target, usagesPerScope = _a.usagesPerScope, errorsPerScope = _a.errorsPerScope; + context.cancellationToken.throwIfCancellationRequested(); + if (requestedChangesIndex !== undefined) { + if (errorsPerScope[requestedChangesIndex].length) { + return undefined; + } + return [extractFunctionInScope(target, scopes[requestedChangesIndex], usagesPerScope[requestedChangesIndex], targetRange, context)]; + } + else { + return scopes.map(function (scope, i) { + var errors = errorsPerScope[i]; + if (errors.length) { + return { + scope: scope, + scopeDescription: getDescriptionForScope(scope), + errors: errors + }; + } + return { scope: scope, scopeDescription: getDescriptionForScope(scope) }; + }); + } + } + extractMethod_1.getPossibleExtractions = getPossibleExtractions; + function getDescriptionForScope(scope) { + if (ts.isFunctionLike(scope)) { + switch (scope.kind) { + case 152: + return "constructor"; + case 186: + return scope.name + ? "function expression " + scope.name.getText() + : "anonymous function expression"; + case 228: + return "function " + scope.name.getText(); + case 187: + return "arrow function"; + case 151: + return "method " + scope.name.getText(); + case 153: + return "get " + scope.name.getText(); + case 154: + return "set " + scope.name.getText(); + } + } + else if (ts.isModuleBlock(scope)) { + return "namespace " + scope.parent.name.getText(); + } + else if (ts.isClassLike(scope)) { + return scope.kind === 229 + ? "class " + scope.name.text + : scope.name.text + ? "class expression " + scope.name.text + : "anonymous class expression"; + } + else if (ts.isSourceFile(scope)) { + return "file '" + scope.fileName + "'"; + } + else { + return "unknown"; + } + } + function getUniqueName(isNameOkay) { + var functionNameText = "newFunction"; + if (isNameOkay(functionNameText)) { + return functionNameText; + } + var i = 1; + while (!isNameOkay(functionNameText = "newFunction_" + i)) { + i++; + } + return functionNameText; + } + function extractFunctionInScope(node, scope, _a, range, context) { + var usagesInScope = _a.usages, substitutions = _a.substitutions; + var checker = context.program.getTypeChecker(); + var file = scope.getSourceFile(); + var functionNameText = getUniqueName(function (n) { return !file.identifiers.has(n); }); + var isJS = ts.isInJavaScriptFile(scope); + var functionName = ts.createIdentifier(functionNameText); + var functionReference = ts.createIdentifier(functionNameText); + var returnType = undefined; + var parameters = []; + var callArguments = []; + var writes; + usagesInScope.forEach(function (usage, name) { + var typeNode = undefined; + if (!isJS) { + var type = checker.getTypeOfSymbolAtLocation(usage.symbol, usage.node); + type = checker.getBaseTypeOfLiteralType(type); + typeNode = checker.typeToTypeNode(type, node, ts.NodeBuilderFlags.NoTruncation); + } + var paramDecl = ts.createParameter(undefined, undefined, undefined, name, undefined, typeNode); + parameters.push(paramDecl); + if (usage.usage === 2) { + (writes || (writes = [])).push(usage); + } + callArguments.push(ts.createIdentifier(name)); }); + if (ts.isExpression(node) && !isJS) { + var contextualType = checker.getContextualType(node); + returnType = checker.typeToTypeNode(contextualType); + } + var _b = transformFunctionBody(node), body = _b.body, returnValueProperty = _b.returnValueProperty; + var newFunction; + if (ts.isClassLike(scope)) { + var modifiers = isJS ? [] : [ts.createToken(112)]; + if (range.facts & RangeFacts.InStaticRegion) { + modifiers.push(ts.createToken(115)); + } + if (range.facts & RangeFacts.IsAsyncFunction) { + modifiers.push(ts.createToken(120)); + } + newFunction = ts.createMethod(undefined, modifiers, range.facts & RangeFacts.IsGenerator ? ts.createToken(39) : undefined, functionName, undefined, [], parameters, returnType, body); + } + else { + newFunction = ts.createFunctionDeclaration(undefined, range.facts & RangeFacts.IsAsyncFunction ? [ts.createToken(120)] : undefined, range.facts & RangeFacts.IsGenerator ? ts.createToken(39) : undefined, functionName, [], parameters, returnType, body); + } + var changeTracker = ts.textChanges.ChangeTracker.fromCodeFixContext(context); + changeTracker.insertNodeBefore(context.file, scope.getLastToken(), newFunction, { prefix: context.newLineCharacter, suffix: context.newLineCharacter }); + var newNodes = []; + var call = ts.createCall(ts.isClassLike(scope) ? ts.createPropertyAccess(range.facts & RangeFacts.InStaticRegion ? ts.createIdentifier(scope.name.getText()) : ts.createThis(), functionReference) : functionReference, undefined, callArguments); + if (range.facts & RangeFacts.IsGenerator) { + call = ts.createYield(ts.createToken(39), call); + } + if (range.facts & RangeFacts.IsAsyncFunction) { + call = ts.createAwait(call); + } + if (writes) { + if (returnValueProperty) { + newNodes.push(ts.createVariableStatement(undefined, [ts.createVariableDeclaration(returnValueProperty, ts.createKeywordTypeNode(119))])); + } + var assignments = getPropertyAssignmentsForWrites(writes); + if (returnValueProperty) { + assignments.unshift(ts.createShorthandPropertyAssignment(returnValueProperty)); + } + if (assignments.length === 1) { + if (returnValueProperty) { + newNodes.push(ts.createReturn(ts.createIdentifier(returnValueProperty))); + } + else { + newNodes.push(ts.createStatement(ts.createBinary(assignments[0].name, 58, call))); + } + } + else { + newNodes.push(ts.createStatement(ts.createBinary(ts.createObjectLiteral(assignments), 58, call))); + if (returnValueProperty) { + newNodes.push(ts.createReturn(ts.createIdentifier(returnValueProperty))); + } + } + } + else { + if (range.facts & RangeFacts.HasReturn) { + newNodes.push(ts.createReturn(call)); + } + else if (isReadonlyArray(range.range)) { + newNodes.push(ts.createStatement(call)); + } + else { + newNodes.push(call); + } + } + if (isReadonlyArray(range.range)) { + changeTracker.replaceNodesWithNodes(context.file, range.range, newNodes, { + nodeSeparator: context.newLineCharacter, + suffix: context.newLineCharacter + }); + } + else { + changeTracker.replaceNodeWithNodes(context.file, range.range, newNodes, { nodeSeparator: context.newLineCharacter }); + } + return { + scope: scope, + scopeDescription: getDescriptionForScope(scope), + changes: changeTracker.getChanges() + }; + function getPropertyAssignmentsForWrites(writes) { + return writes.map(function (w) { return ts.createShorthandPropertyAssignment(w.symbol.name); }); + } + function generateReturnValueProperty() { + return "__return"; + } + function transformFunctionBody(body) { + if (ts.isBlock(body) && !writes && substitutions.size === 0) { + return { body: ts.createBlock(body.statements, true), returnValueProperty: undefined }; + } + var returnValueProperty; + var statements = ts.createNodeArray(ts.isBlock(body) ? body.statements.slice(0) : [ts.isStatement(body) ? body : ts.createReturn(body)]); + if (writes || substitutions.size) { + var rewrittenStatements = ts.visitNodes(statements, visitor).slice(); + if (writes && !(range.facts & RangeFacts.HasReturn) && ts.isStatement(body)) { + var assignments = getPropertyAssignmentsForWrites(writes); + if (assignments.length === 1) { + rewrittenStatements.push(ts.createReturn(assignments[0].name)); + } + else { + rewrittenStatements.push(ts.createReturn(ts.createObjectLiteral(assignments))); + } + } + return { body: ts.createBlock(rewrittenStatements, true), returnValueProperty: returnValueProperty }; + } + else { + return { body: ts.createBlock(statements, true), returnValueProperty: undefined }; + } + function visitor(node) { + if (node.kind === 219 && writes) { + var assignments = getPropertyAssignmentsForWrites(writes); + if (node.expression) { + if (!returnValueProperty) { + returnValueProperty = generateReturnValueProperty(); + } + assignments.unshift(ts.createPropertyAssignment(returnValueProperty, ts.visitNode(node.expression, visitor))); + } + if (assignments.length === 1) { + return ts.createReturn(assignments[0].name); + } + else { + return ts.createReturn(ts.createObjectLiteral(assignments)); + } + } + else { + var substitution = substitutions.get(ts.getNodeId(node).toString()); + return substitution || ts.visitEachChild(node, visitor, ts.nullTransformationContext); + } + } + } } - function createClassFromVariableDeclaration(node) { - var initializer = node.initializer; - if (!initializer || initializer.kind !== 186) { + extractMethod_1.extractFunctionInScope = extractFunctionInScope; + function isReadonlyArray(v) { + return ts.isArray(v); + } + function getEnclosingTextRange(targetRange, sourceFile) { + return isReadonlyArray(targetRange.range) + ? { pos: targetRange.range[0].getStart(sourceFile), end: targetRange.range[targetRange.range.length - 1].getEnd() } + : targetRange.range; + } + var Usage; + (function (Usage) { + Usage[Usage["Read"] = 1] = "Read"; + Usage[Usage["Write"] = 2] = "Write"; + })(Usage || (Usage = {})); + function collectReadsAndWrites(targetRange, scopes, enclosingTextRange, sourceFile, checker) { + var usagesPerScope = []; + var substitutionsPerScope = []; + var errorsPerScope = []; + var visibleDeclarationsInExtractedRange = []; + for (var _i = 0, scopes_1 = scopes; _i < scopes_1.length; _i++) { + var _ = scopes_1[_i]; + usagesPerScope.push({ usages: ts.createMap(), substitutions: ts.createMap() }); + substitutionsPerScope.push(ts.createMap()); + errorsPerScope.push([]); + } + var seenUsages = ts.createMap(); + var target = isReadonlyArray(targetRange.range) ? ts.createBlock(targetRange.range) : targetRange.range; + var containingLexicalScopeOfExtraction = ts.isBlockScope(scopes[0], scopes[0].parent) ? scopes[0] : ts.getEnclosingBlockScopeContainer(scopes[0]); + collectUsages(target); + var _loop_8 = function (i) { + var hasWrite = false; + var readonlyClassPropertyWrite = undefined; + usagesPerScope[i].usages.forEach(function (value) { + if (value.usage === 2) { + hasWrite = true; + if (value.symbol.flags & 106500 && + value.symbol.valueDeclaration && + ts.hasModifier(value.symbol.valueDeclaration, 64)) { + readonlyClassPropertyWrite = value.symbol.valueDeclaration; + } + } + }); + if (hasWrite && !isReadonlyArray(targetRange.range) && ts.isExpression(targetRange.range)) { + errorsPerScope[i].push(ts.createDiagnosticForNode(targetRange.range, Messages.CannotCombineWritesAndReturns)); + } + else if (readonlyClassPropertyWrite && i > 0) { + errorsPerScope[i].push(ts.createDiagnosticForNode(readonlyClassPropertyWrite, Messages.CannotCombineWritesAndReturns)); + } + }; + for (var i = 0; i < scopes.length; i++) { + _loop_8(i); + } + if (visibleDeclarationsInExtractedRange.length) { + ts.forEachChild(containingLexicalScopeOfExtraction, checkForUsedDeclarations); + } + return { target: target, usagesPerScope: usagesPerScope, errorsPerScope: errorsPerScope }; + function collectUsages(node, valueUsage) { + if (valueUsage === void 0) { valueUsage = 1; } + if (ts.isDeclaration(node) && node.symbol) { + visibleDeclarationsInExtractedRange.push(node.symbol); + } + if (ts.isAssignmentExpression(node)) { + collectUsages(node.left, 2); + collectUsages(node.right); + } + else if (ts.isUnaryExpressionWithWrite(node)) { + collectUsages(node.operand, 2); + } + else if (ts.isPropertyAccessExpression(node) || ts.isElementAccessExpression(node)) { + ts.forEachChild(node, collectUsages); + } + else if (ts.isIdentifier(node)) { + if (!node.parent) { + return; + } + if (ts.isQualifiedName(node.parent) && node !== node.parent.left) { + return; + } + if (ts.isPropertyAccessExpression(node.parent) && node !== node.parent.expression) { + return; + } + recordUsage(node, valueUsage, ts.isPartOfTypeNode(node)); + } + else { + ts.forEachChild(node, collectUsages); + } + } + function recordUsage(n, usage, isTypeNode) { + var symbolId = recordUsagebySymbol(n, usage, isTypeNode); + if (symbolId) { + for (var i = 0; i < scopes.length; i++) { + var substitition = substitutionsPerScope[i].get(symbolId); + if (substitition) { + usagesPerScope[i].substitutions.set(ts.getNodeId(n).toString(), substitition); + } + } + } + } + function recordUsagebySymbol(identifier, usage, isTypeName) { + var symbol = checker.getSymbolAtLocation(identifier); + if (!symbol) { + return undefined; + } + var symbolId = ts.getSymbolId(symbol).toString(); + var lastUsage = seenUsages.get(symbolId); + if (lastUsage && lastUsage >= usage) { + return symbolId; + } + seenUsages.set(symbolId, usage); + if (lastUsage) { + for (var _i = 0, usagesPerScope_1 = usagesPerScope; _i < usagesPerScope_1.length; _i++) { + var perScope = usagesPerScope_1[_i]; + var prevEntry = perScope.usages.get(identifier.text); + if (prevEntry) { + perScope.usages.set(identifier.text, { usage: usage, symbol: symbol, node: identifier }); + } + } + return symbolId; + } + var declInFile = ts.find(symbol.getDeclarations(), function (d) { return d.getSourceFile() === sourceFile; }); + if (!declInFile) { + return undefined; + } + if (ts.rangeContainsRange(enclosingTextRange, declInFile)) { + return undefined; + } + if (targetRange.facts & RangeFacts.IsGenerator && usage === 2) { + for (var _a = 0, errorsPerScope_1 = errorsPerScope; _a < errorsPerScope_1.length; _a++) { + var errors = errorsPerScope_1[_a]; + errors.push(ts.createDiagnosticForNode(identifier, Messages.CannotExtractRangeThatContainsWritesToReferencesLocatedOutsideOfTheTargetRangeInGenerators)); + } + } + for (var i = 0; i < scopes.length; i++) { + var scope = scopes[i]; + var resolvedSymbol = checker.resolveName(symbol.name, scope, symbol.flags); + if (resolvedSymbol === symbol) { + continue; + } + if (!substitutionsPerScope[i].has(symbolId)) { + var substitution = tryReplaceWithQualifiedNameOrPropertyAccess(symbol.exportSymbol || symbol, scope, isTypeName); + if (substitution) { + substitutionsPerScope[i].set(symbolId, substitution); + } + else if (isTypeName) { + errorsPerScope[i].push(ts.createDiagnosticForNode(identifier, Messages.TypeWillNotBeVisibleInTheNewScope)); + } + else { + usagesPerScope[i].usages.set(identifier.text, { usage: usage, symbol: symbol, node: identifier }); + } + } + } + return symbolId; + } + function checkForUsedDeclarations(node) { + if (node === targetRange.range || (isReadonlyArray(targetRange.range) && targetRange.range.indexOf(node) >= 0)) { + return; + } + var sym = checker.getSymbolAtLocation(node); + if (sym && visibleDeclarationsInExtractedRange.some(function (d) { return d === sym; })) { + for (var _i = 0, errorsPerScope_2 = errorsPerScope; _i < errorsPerScope_2.length; _i++) { + var scope = errorsPerScope_2[_i]; + scope.push(ts.createDiagnosticForNode(node, Messages.CannotExtractExportedEntity)); + } + return true; + } + else { + ts.forEachChild(node, checkForUsedDeclarations); + } + } + function tryReplaceWithQualifiedNameOrPropertyAccess(symbol, scopeDecl, isTypeNode) { + if (!symbol) { + return undefined; + } + if (symbol.getDeclarations().some(function (d) { return d.parent === scopeDecl; })) { + return ts.createIdentifier(symbol.name); + } + var prefix = tryReplaceWithQualifiedNameOrPropertyAccess(symbol.parent, scopeDecl, isTypeNode); + if (prefix === undefined) { + return undefined; + } + return isTypeNode ? ts.createQualifiedName(prefix, ts.createIdentifier(symbol.name)) : ts.createPropertyAccess(prefix, symbol.name); + } + } + function getParentNodeInSpan(node, file, span) { + if (!node) return undefined; + while (node.parent) { + if (ts.isSourceFile(node.parent) || !spanContainsNode(span, node.parent, file)) { + return node; + } + node = node.parent; } - if (node.name.kind !== 71) { - return undefined; - } - var memberElements = createClassElementsFromSymbol(initializer.symbol); - if (initializer.body) { - memberElements.unshift(ts.createConstructor(undefined, undefined, initializer.parameters, initializer.body)); - } - var cls = ts.createClassDeclaration(undefined, undefined, node.name, undefined, undefined, memberElements); - return cls; } - function createClassFromFunctionDeclaration(node) { - var memberElements = createClassElementsFromSymbol(ctorSymbol); - if (node.body) { - memberElements.unshift(ts.createConstructor(undefined, undefined, node.parameters, node.body)); - } - var cls = ts.createClassDeclaration(undefined, undefined, node.name, undefined, undefined, memberElements); - return cls; + function spanContainsNode(span, node, file) { + return ts.textSpanContainsPosition(span, node.getStart(file)) && + node.getEnd() <= ts.textSpanEnd(span); } - } + function isExtractableExpression(node) { + switch (node.parent.kind) { + case 264: + return false; + } + switch (node.kind) { + case 9: + return node.parent.kind !== 238 && + node.parent.kind !== 242; + case 198: + case 174: + case 176: + return false; + case 71: + return node.parent.kind !== 176 && + node.parent.kind !== 242 && + node.parent.kind !== 246; + } + return true; + } + function isBlockLike(node) { + switch (node.kind) { + case 207: + case 265: + case 234: + case 257: + return true; + default: + return false; + } + } + })(extractMethod = refactor.extractMethod || (refactor.extractMethod = {})); })(refactor = ts.refactor || (ts.refactor = {})); })(ts || (ts = {})); var ts; @@ -74186,12 +75614,14 @@ var ts; ts.scanner.setTextPos(pos); while (pos < end) { var token = ts.scanner.scan(); - ts.Debug.assert(token !== 1); var textPos = ts.scanner.getTextPos(); if (textPos <= end) { nodes.push(createNode(token, pos, textPos, this)); } pos = textPos; + if (token === 1) { + break; + } } return pos; }; @@ -74986,8 +76416,8 @@ var ts; if (program) { var oldSourceFiles = program.getSourceFiles(); var oldSettingsKey = documentRegistry.getKeyForCompilationSettings(oldSettings); - for (var _i = 0, oldSourceFiles_1 = oldSourceFiles; _i < oldSourceFiles_1.length; _i++) { - var oldSourceFile = oldSourceFiles_1[_i]; + for (var _i = 0, oldSourceFiles_2 = oldSourceFiles; _i < oldSourceFiles_2.length; _i++) { + var oldSourceFile = oldSourceFiles_2[_i]; if (!newProgram.getSourceFile(oldSourceFile.fileName) || shouldCreateNewSourceFiles) { documentRegistry.releaseDocumentWithKey(oldSourceFile.path, oldSettingsKey); } @@ -75009,7 +76439,7 @@ var ts; if (!shouldCreateNewSourceFiles) { var oldSourceFile = program && program.getSourceFileByPath(path); if (oldSourceFile) { - ts.Debug.assert(hostFileInformation.scriptKind === oldSourceFile.scriptKind, "Registered script kind (" + oldSourceFile.scriptKind + ") should match new script kind (" + hostFileInformation.scriptKind + ") for file: " + path); + ts.Debug.assertEqual(hostFileInformation.scriptKind, oldSourceFile.scriptKind, "Registered script kind should match new script kind.", path); return documentRegistry.updateDocumentWithKey(fileName, path, newSettings, documentRegistryBucketKey, hostFileInformation.scriptSnapshot, hostFileInformation.version, hostFileInformation.scriptKind); } } @@ -75372,17 +76802,19 @@ var ts; function getFormattingEditsAfterKeystroke(fileName, position, key, options) { var sourceFile = syntaxTreeCache.getCurrentSourceFile(fileName); var settings = toEditorSettings(options); - if (key === "{") { - return ts.formatting.formatOnOpeningCurly(position, sourceFile, getRuleProvider(settings), settings); - } - else if (key === "}") { - return ts.formatting.formatOnClosingCurly(position, sourceFile, getRuleProvider(settings), settings); - } - else if (key === ";") { - return ts.formatting.formatOnSemicolon(position, sourceFile, getRuleProvider(settings), settings); - } - else if (key === "\n") { - return ts.formatting.formatOnEnter(position, sourceFile, getRuleProvider(settings), settings); + if (!ts.isInComment(sourceFile, position)) { + if (key === "{") { + return ts.formatting.formatOnOpeningCurly(position, sourceFile, getRuleProvider(settings), settings); + } + else if (key === "}") { + return ts.formatting.formatOnClosingCurly(position, sourceFile, getRuleProvider(settings), settings); + } + else if (key === ";") { + return ts.formatting.formatOnSemicolon(position, sourceFile, getRuleProvider(settings), settings); + } + else if (key === "\n") { + return ts.formatting.formatOnEnter(position, sourceFile, getRuleProvider(settings), settings); + } } return []; } @@ -75422,6 +76854,11 @@ var ts; } return true; } + function getSpanOfEnclosingComment(fileName, position, onlyMultiLine) { + var sourceFile = syntaxTreeCache.getCurrentSourceFile(fileName); + var range = ts.formatting.getRangeOfEnclosingComment(sourceFile, position, onlyMultiLine); + return range && ts.createTextSpanFromRange(range); + } function getTodoComments(fileName, descriptors) { synchronizeHostData(); var sourceFile = getValidSourceFile(fileName); @@ -75545,6 +76982,7 @@ var ts; getFormattingEditsAfterKeystroke: getFormattingEditsAfterKeystroke, getDocCommentTemplateAtPosition: getDocCommentTemplateAtPosition, isValidBraceCompletionAtPosition: isValidBraceCompletionAtPosition, + getSpanOfEnclosingComment: getSpanOfEnclosingComment, getCodeFixesAtPosition: getCodeFixesAtPosition, getEmitOutput: getEmitOutput, getNonBoundSourceFile: getNonBoundSourceFile, @@ -75615,12 +77053,16 @@ var ts; function getPropertySymbolsFromContextualType(typeChecker, node) { var objectLiteral = node.parent; var contextualType = typeChecker.getContextualType(objectLiteral); - var name = ts.unescapeLeadingUnderscores(ts.getTextOfPropertyName(node.name)); - if (name && contextualType) { + return getPropertySymbolsFromType(contextualType, node.name); + } + ts.getPropertySymbolsFromContextualType = getPropertySymbolsFromContextualType; + function getPropertySymbolsFromType(type, propName) { + var name = ts.unescapeLeadingUnderscores(ts.getTextOfPropertyName(propName)); + if (name && type) { var result_10 = []; - var symbol = contextualType.getProperty(name); - if (contextualType.flags & 65536) { - ts.forEach(contextualType.types, function (t) { + var symbol = type.getProperty(name); + if (type.flags & 65536) { + ts.forEach(type.types, function (t) { var symbol = t.getProperty(name); if (symbol) { result_10.push(symbol); @@ -75635,7 +77077,7 @@ var ts; } return undefined; } - ts.getPropertySymbolsFromContextualType = getPropertySymbolsFromContextualType; + ts.getPropertySymbolsFromType = getPropertySymbolsFromType; function isArgumentOfElementAccessExpression(node) { return node && node.parent && @@ -76012,6 +77454,10 @@ var ts; var _this = this; return this.forwardJSONCall("isValidBraceCompletionAtPosition('" + fileName + "', " + position + ", " + openingBrace + ")", function () { return _this.languageService.isValidBraceCompletionAtPosition(fileName, position, openingBrace); }); }; + LanguageServiceShimObject.prototype.getSpanOfEnclosingComment = function (fileName, position, onlyMultiLine) { + var _this = this; + return this.forwardJSONCall("getSpanOfEnclosingComment('" + fileName + "', " + position + ")", function () { return _this.languageService.getSpanOfEnclosingComment(fileName, position, onlyMultiLine); }); + }; LanguageServiceShimObject.prototype.getIndentationAtPosition = function (fileName, position, options) { var _this = this; return this.forwardJSONCall("getIndentationAtPosition('" + fileName + "', " + position + ")", function () { @@ -76307,7 +77753,7 @@ var TypeScript; Services.TypeScriptServicesFactory = ts.TypeScriptServicesFactory; })(Services = TypeScript.Services || (TypeScript.Services = {})); })(TypeScript || (TypeScript = {})); -var toolsVersion = "2.5"; +var toolsVersion = "2.6"; var ts; (function (ts) { var server; @@ -76323,6 +77769,7 @@ var ts; Arguments.LogFile = "--logFile"; Arguments.EnableTelemetry = "--enableTelemetry"; Arguments.TypingSafeListLocation = "--typingSafeListLocation"; + Arguments.TypesMapLocation = "--typesMapLocation"; Arguments.NpmLocation = "--npmLocation"; })(Arguments = server.Arguments || (server.Arguments = {})); function hasArgument(argumentName) { @@ -76370,7 +77817,7 @@ var ts; function createInstallTypingsRequest(project, typeAcquisition, unresolvedImports, cachePath) { return { projectName: project.getProjectName(), - fileNames: project.getFileNames(true, true), + fileNames: project.getFileNames(true, true).concat(project.getExcludedFiles()), compilerOptions: project.getCompilerOptions(), typeAcquisition: typeAcquisition, unresolvedImports: unresolvedImports, @@ -76470,42 +77917,6 @@ var ts; return []; } server.createSortedArray = createSortedArray; - function toSortedArray(arr, comparer) { - arr.sort(comparer); - return arr; - } - server.toSortedArray = toSortedArray; - function enumerateInsertsAndDeletes(newItems, oldItems, inserted, deleted, compare) { - compare = compare || ts.compareValues; - var newIndex = 0; - var oldIndex = 0; - var newLen = newItems.length; - var oldLen = oldItems.length; - while (newIndex < newLen && oldIndex < oldLen) { - var newItem = newItems[newIndex]; - var oldItem = oldItems[oldIndex]; - var compareResult = compare(newItem, oldItem); - if (compareResult === -1) { - inserted(newItem); - newIndex++; - } - else if (compareResult === 1) { - deleted(oldItem); - oldIndex++; - } - else { - newIndex++; - oldIndex++; - } - } - while (newIndex < newLen) { - inserted(newItems[newIndex++]); - } - while (oldIndex < oldLen) { - deleted(oldItems[oldIndex++]); - } - } - server.enumerateInsertsAndDeletes = enumerateInsertsAndDeletes; var ThrottledOperations = (function () { function ThrottledOperations(host) { this.host = host; @@ -76550,6 +77961,11 @@ var ts; return GcTimer; }()); server.GcTimer = GcTimer; + })(server = ts.server || (ts.server = {})); +})(ts || (ts = {})); +(function (ts) { + var server; + (function (server) { function insertSorted(array, insert, compare) { if (array.length === 0) { array.push(insert); @@ -76575,6 +77991,51 @@ var ts; } } server.removeSorted = removeSorted; + function toSortedArray(arr, comparer) { + arr.sort(comparer); + return arr; + } + server.toSortedArray = toSortedArray; + function toDeduplicatedSortedArray(arr) { + arr.sort(); + ts.filterMutate(arr, isNonDuplicateInSortedArray); + return arr; + } + server.toDeduplicatedSortedArray = toDeduplicatedSortedArray; + function isNonDuplicateInSortedArray(value, index, array) { + return index === 0 || value !== array[index - 1]; + } + function enumerateInsertsAndDeletes(newItems, oldItems, inserted, deleted, compare) { + compare = compare || ts.compareValues; + var newIndex = 0; + var oldIndex = 0; + var newLen = newItems.length; + var oldLen = oldItems.length; + while (newIndex < newLen && oldIndex < oldLen) { + var newItem = newItems[newIndex]; + var oldItem = oldItems[oldIndex]; + var compareResult = compare(newItem, oldItem); + if (compareResult === -1) { + inserted(newItem); + newIndex++; + } + else if (compareResult === 1) { + deleted(oldItem); + oldIndex++; + } + else { + newIndex++; + oldIndex++; + } + } + while (newIndex < newLen) { + inserted(newItems[newIndex++]); + } + while (oldIndex < oldLen) { + deleted(oldItems[oldIndex++]); + } + } + server.enumerateInsertsAndDeletes = enumerateInsertsAndDeletes; })(server = ts.server || (ts.server = {})); })(ts || (ts = {})); var ts; @@ -76588,6 +78049,7 @@ var ts; CommandTypes["Brace"] = "brace"; CommandTypes["BraceFull"] = "brace-full"; CommandTypes["BraceCompletion"] = "braceCompletion"; + CommandTypes["GetSpanOfEnclosingComment"] = "getSpanOfEnclosingComment"; CommandTypes["Change"] = "change"; CommandTypes["Close"] = "close"; CommandTypes["Completions"] = "completions"; @@ -76679,6 +78141,7 @@ var ts; ModuleKind["System"] = "System"; ModuleKind["ES6"] = "ES6"; ModuleKind["ES2015"] = "ES2015"; + ModuleKind["ESNext"] = "ESNext"; })(ModuleKind = protocol.ModuleKind || (protocol.ModuleKind = {})); var ModuleResolutionKind; (function (ModuleResolutionKind) { @@ -76696,6 +78159,9 @@ var ts; ScriptTarget["ES5"] = "ES5"; ScriptTarget["ES6"] = "ES6"; ScriptTarget["ES2015"] = "ES2015"; + ScriptTarget["ES2016"] = "ES2016"; + ScriptTarget["ES2017"] = "ES2017"; + ScriptTarget["ESNext"] = "ESNext"; })(ScriptTarget = protocol.ScriptTarget || (protocol.ScriptTarget = {})); })(protocol = server.protocol || (server.protocol = {})); })(server = ts.server || (ts.server = {})); @@ -76713,7 +78179,7 @@ var ts; } TextStorage.prototype.getVersion = function () { return this.svc - ? "SVC-" + this.svcVersion + "-" + this.svc.getSnapshot().version + ? "SVC-" + this.svcVersion + "-" + this.svc.getSnapshotVersion() : "Text-" + this.textVersion; }; TextStorage.prototype.hasScriptVersionCache = function () { @@ -76751,7 +78217,7 @@ var ts; : ts.ScriptSnapshot.fromString(this.getOrLoadText()); }; TextStorage.prototype.getLineInfo = function (line) { - return this.switchToScriptVersionCache().getSnapshot().index.lineNumberToInfo(line); + return this.switchToScriptVersionCache().getLineInfo(line); }; TextStorage.prototype.lineToTextSpan = function (line) { if (!this.svc) { @@ -76760,23 +78226,20 @@ var ts; var end = line + 1 < lineMap.length ? lineMap[line + 1] : this.text.length; return ts.createTextSpanFromBounds(start, end); } - var index = this.svc.getSnapshot().index; - var _a = index.lineNumberToInfo(line + 1), lineText = _a.lineText, absolutePosition = _a.absolutePosition; - var len = lineText !== undefined ? lineText.length : index.absolutePositionOfStartOfLine(line + 2) - absolutePosition; - return ts.createTextSpan(absolutePosition, len); + return this.svc.lineToTextSpan(line); }; TextStorage.prototype.lineOffsetToPosition = function (line, offset) { if (!this.svc) { return ts.computePositionOfLineAndCharacter(this.getLineMap(), line - 1, offset - 1, this.text); } - return this.svc.getSnapshot().index.absolutePositionOfStartOfLine(line) + (offset - 1); + return this.svc.lineOffsetToPosition(line, offset); }; TextStorage.prototype.positionToLineOffset = function (position) { if (!this.svc) { var _a = ts.computeLineAndCharacterOfPosition(this.getLineMap(), position), line = _a.line, character = _a.character; return { line: line + 1, offset: character + 1 }; } - return this.svc.getSnapshot().index.positionToLineOffset(position); + return this.svc.positionToLineOffset(position); }; TextStorage.prototype.getFileText = function (tempFileName) { return this.host.readFile(tempFileName || this.fileName) || ""; @@ -77685,7 +79148,8 @@ var ts; log("Loading " + moduleName + " from " + initialDir + " (resolved to " + resolvedPath + ")"); var result = host.require(resolvedPath, moduleName); if (result.error) { - log("Failed to load module: " + JSON.stringify(result.error)); + var err = result.error.stack || result.error.message || JSON.stringify(result.error); + log("Failed to load module '" + moduleName + "': " + err); return undefined; } return result.module; @@ -77815,7 +79279,7 @@ var ts; return ts.map(this.program.getSourceFiles(), function (sourceFile) { var scriptInfo = _this.projectService.getScriptInfoForPath(sourceFile.path); if (!scriptInfo) { - ts.Debug.assert(false, "scriptInfo for a file '" + sourceFile.fileName + "' is missing."); + ts.Debug.fail("scriptInfo for a file '" + sourceFile.fileName + "' is missing."); } return scriptInfo; }); @@ -77826,6 +79290,9 @@ var ts; } return this.getLanguageService().getEmitOutput(info.fileName, emitOnlyDtsFiles); }; + Project.prototype.getExcludedFiles = function () { + return server.emptyArray; + }; Project.prototype.getFileNames = function (excludeFilesFromExternalLibraries, excludeConfigFiles) { if (!this.program) { return []; @@ -77977,7 +79444,7 @@ var ts; var sourceFile = _b[_a]; this.extractUnresolvedImportsFromSourceFile(sourceFile, result); } - this.lastCachedUnresolvedImportsList = server.toSortedArray(result); + this.lastCachedUnresolvedImportsList = server.toDeduplicatedSortedArray(result); } unresolvedImports = this.lastCachedUnresolvedImportsList; var cachedTypings = this.projectService.typingsCache.getTypingsForProject(this, unresolvedImports, hasChanges); @@ -78029,7 +79496,7 @@ var ts; fileWatcher.close(); } }); - var _loop_8 = function (missingFilePath) { + var _loop_9 = function (missingFilePath) { if (!this_1.missingFilesMap.has(missingFilePath)) { var fileWatcher_1 = this_1.projectService.host.watchFile(missingFilePath, function (_filename, eventKind) { if (eventKind === ts.FileWatcherEventKind.Created && _this.missingFilesMap.has(missingFilePath)) { @@ -78045,7 +79512,7 @@ var ts; var this_1 = this; for (var _b = 0, missingFilePaths_1 = missingFilePaths; _b < missingFilePaths_1.length; _b++) { var missingFilePath = missingFilePaths_1[_b]; - _loop_8(missingFilePath); + _loop_9(missingFilePath); } } var oldExternalFiles = this.externalFiles || server.emptyArray; @@ -78209,10 +79676,11 @@ var ts; server.Project = Project; var InferredProject = (function (_super) { __extends(InferredProject, _super); - function InferredProject(projectService, documentRegistry, compilerOptions) { + function InferredProject(projectService, documentRegistry, compilerOptions, projectRootPath) { var _this = _super.call(this, InferredProject.newName(), ProjectKind.Inferred, projectService, documentRegistry, undefined, true, compilerOptions, false) || this; _this._isJsInferredProject = false; _this.directoriesWatchedForTsconfig = []; + _this.projectRootPath = projectRootPath; return _this; } InferredProject.prototype.toggleJsInferredProject = function (isJsInferredProject) { @@ -78316,7 +79784,7 @@ var ts; } } if (this.projectService.globalPlugins) { - var _loop_9 = function (globalPluginName) { + var _loop_10 = function (globalPluginName) { if (options.plugins && options.plugins.some(function (p) { return p.name === globalPluginName; })) return "continue"; this_2.enablePlugin({ name: globalPluginName, global: true }, searchPaths); @@ -78324,7 +79792,7 @@ var ts; var this_2 = this; for (var _b = 0, _c = this.projectService.globalPlugins; _b < _c.length; _b++) { var globalPluginName = _c[_b]; - _loop_9(globalPluginName); + _loop_10(globalPluginName); } } }; @@ -78447,10 +79915,12 @@ var ts; } this.typeRootsWatchers = undefined; } - this.directoriesWatchedForWildcards.forEach(function (watcher) { - watcher.close(); - }); - this.directoriesWatchedForWildcards = undefined; + if (this.directoriesWatchedForWildcards) { + this.directoriesWatchedForWildcards.forEach(function (watcher) { + watcher.close(); + }); + this.directoriesWatchedForWildcards = undefined; + } this.stopWatchingDirectory(); }; ConfiguredProject.prototype.addOpenRef = function () { @@ -78473,8 +79943,12 @@ var ts; _this.externalProjectName = externalProjectName; _this.compileOnSaveEnabled = compileOnSaveEnabled; _this.projectFilePath = projectFilePath; + _this.excludedFiles = []; return _this; } + ExternalProject.prototype.getExcludedFiles = function () { + return this.excludedFiles; + }; ExternalProject.prototype.getProjectRootPath = function () { if (this.projectFilePath) { return ts.getDirectoryPath(this.projectFilePath); @@ -78680,6 +80154,7 @@ var ts; this.inferredProjects = []; this.configuredProjects = []; this.openFiles = []; + this.compilerOptionsForInferredProjectsPerProjectRoot = ts.createMap(); this.projectToSizeMap = ts.createMap(); this.safelist = defaultTypeSafeList; this.seenProjects = ts.createMap(); @@ -78687,16 +80162,21 @@ var ts; this.logger = opts.logger; this.cancellationToken = opts.cancellationToken; this.useSingleInferredProject = opts.useSingleInferredProject; + this.useInferredProjectPerProjectRoot = opts.useInferredProjectPerProjectRoot; this.typingsInstaller = opts.typingsInstaller || server.nullTypingsInstaller; this.throttleWaitMilliseconds = opts.throttleWaitMilliseconds; this.eventHandler = opts.eventHandler; this.globalPlugins = opts.globalPlugins || server.emptyArray; this.pluginProbeLocations = opts.pluginProbeLocations || server.emptyArray; this.allowLocalPluginLoads = !!opts.allowLocalPluginLoads; + this.typesMapLocation = (opts.typesMapLocation === undefined) ? ts.combinePaths(this.host.getExecutingFilePath(), "../typesMap.json") : opts.typesMapLocation; ts.Debug.assert(!!this.host.createHash, "'ServerHost.createHash' is required for ProjectService"); this.toCanonicalFileName = ts.createGetCanonicalFileName(this.host.useCaseSensitiveFileNames); this.directoryWatchers = new DirectoryWatchers(this); this.throttledOperations = new server.ThrottledOperations(this.host); + if (opts.typesMapLocation) { + this.loadTypesMap(); + } this.typingsInstaller.attach(this); this.typingsCache = new server.TypingsCache(this.typingsInstaller); this.hostConfiguration = { @@ -78719,10 +80199,30 @@ var ts; if (!this.eventHandler) { return; } - this.eventHandler({ + var event = { eventName: server.ProjectLanguageServiceStateEvent, data: { project: project, languageServiceEnabled: languageServiceEnabled } - }); + }; + this.eventHandler(event); + }; + ProjectService.prototype.loadTypesMap = function () { + try { + var fileContent = this.host.readFile(this.typesMapLocation); + if (fileContent === undefined) { + this.logger.info("Provided types map file \"" + this.typesMapLocation + "\" doesn't exist"); + return; + } + var raw = JSON.parse(fileContent); + for (var _i = 0, _a = Object.keys(raw.typesMap); _i < _a.length; _i++) { + var k = _a[_i]; + raw.typesMap[k].match = new RegExp(raw.typesMap[k].match, "i"); + } + this.safelist = raw.typesMap; + } + catch (e) { + this.logger.info("Error loading types map: " + e); + this.safelist = defaultTypeSafeList; + } }; ProjectService.prototype.updateTypingsForProject = function (response) { var project = this.findProject(response.projectName); @@ -78739,16 +80239,28 @@ var ts; } project.updateGraph(); }; - ProjectService.prototype.setCompilerOptionsForInferredProjects = function (projectCompilerOptions) { - this.compilerOptionsForInferredProjects = convertCompilerOptions(projectCompilerOptions); - this.compilerOptionsForInferredProjects.allowNonTsExtensions = true; - this.compileOnSaveForInferredProjects = projectCompilerOptions.compileOnSave; - for (var _i = 0, _a = this.inferredProjects; _i < _a.length; _i++) { - var proj = _a[_i]; - proj.setCompilerOptions(this.compilerOptionsForInferredProjects); - proj.compileOnSaveEnabled = projectCompilerOptions.compileOnSave; + ProjectService.prototype.setCompilerOptionsForInferredProjects = function (projectCompilerOptions, projectRootPath) { + ts.Debug.assert(projectRootPath === undefined || this.useInferredProjectPerProjectRoot, "Setting compiler options per project root path is only supported when useInferredProjectPerProjectRoot is enabled"); + var compilerOptions = convertCompilerOptions(projectCompilerOptions); + compilerOptions.allowNonTsExtensions = true; + if (projectRootPath) { + this.compilerOptionsForInferredProjectsPerProjectRoot.set(projectRootPath, compilerOptions); } - this.updateProjectGraphs(this.inferredProjects); + else { + this.compilerOptionsForInferredProjects = compilerOptions; + } + var updatedProjects = []; + for (var _i = 0, _a = this.inferredProjects; _i < _a.length; _i++) { + var project = _a[_i]; + if (projectRootPath ? + project.projectRootPath === projectRootPath : + !project.projectRootPath || !this.compilerOptionsForInferredProjectsPerProjectRoot.has(project.projectRootPath)) { + project.setCompilerOptions(compilerOptions); + project.compileOnSaveEnabled = compilerOptions.compileOnSave; + updatedProjects.push(project); + } + } + this.updateProjectGraphs(updatedProjects); }; ProjectService.prototype.stopWatchingDirectory = function (directory) { this.directoryWatchers.stopWatchingDirectory(directory); @@ -78855,10 +80367,11 @@ var ts; } for (var _i = 0, _a = this.openFiles; _i < _a.length; _i++) { var openFile = _a[_i]; - this.eventHandler({ + var event = { eventName: server.ContextEvent, data: { project: openFile.getDefaultProject(), fileName: openFile.fileName } - }); + }; + this.eventHandler(event); } } this.printProjects(); @@ -78930,7 +80443,7 @@ var ts; break; } }; - ProjectService.prototype.assignScriptInfoToInferredProjectIfNecessary = function (info, addToListOfOpenFiles) { + ProjectService.prototype.assignScriptInfoToInferredProjectIfNecessary = function (info, addToListOfOpenFiles, projectRootPath) { var externalProject = this.findContainingExternalProject(info.fileName); if (externalProject) { if (addToListOfOpenFiles) { @@ -78955,19 +80468,19 @@ var ts; return; } if (info.containingProjects.length === 0) { - var inferredProject = this.createInferredProjectWithRootFileIfNecessary(info); - if (!this.useSingleInferredProject) { + var inferredProject = this.createInferredProjectWithRootFileIfNecessary(info, projectRootPath); + if (!this.useSingleInferredProject && !inferredProject.projectRootPath) { for (var _b = 0, _c = this.openFiles; _b < _c.length; _b++) { var f = _c[_b]; if (f.containingProjects.length === 0 || !inferredProject.containsScriptInfo(f)) { continue; } for (var _d = 0, _e = f.containingProjects; _d < _e.length; _d++) { - var fContainingProject = _e[_d]; - if (fContainingProject.projectKind === server.ProjectKind.Inferred && - fContainingProject.isRoot(f) && - fContainingProject !== inferredProject) { - this.removeProject(fContainingProject); + var containingProject = _e[_d]; + if (containingProject.projectKind === server.ProjectKind.Inferred && + containingProject !== inferredProject && + containingProject.isRoot(f)) { + this.removeProject(containingProject); f.attachToProject(inferredProject); } } @@ -79078,31 +80591,32 @@ var ts; return undefined; }; ProjectService.prototype.printProjects = function () { + var _this = this; if (!this.logger.hasLevel(server.LogLevel.verbose)) { return; } this.logger.startGroup(); var counter = 0; - counter = printProjects(this.logger, this.externalProjects, counter); - counter = printProjects(this.logger, this.configuredProjects, counter); - counter = printProjects(this.logger, this.inferredProjects, counter); + var printProjects = function (projects, counter) { + for (var _i = 0, projects_3 = projects; _i < projects_3.length; _i++) { + var project = projects_3[_i]; + project.updateGraph(); + _this.logger.info("Project '" + project.getProjectName() + "' (" + server.ProjectKind[project.projectKind] + ") " + counter); + _this.logger.info(project.filesToString()); + _this.logger.info("-----------------------------------------------"); + counter++; + } + return counter; + }; + counter = printProjects(this.externalProjects, counter); + counter = printProjects(this.configuredProjects, counter); + printProjects(this.inferredProjects, counter); this.logger.info("Open files: "); for (var _i = 0, _a = this.openFiles; _i < _a.length; _i++) { var rootFile = _a[_i]; this.logger.info("\t" + rootFile.fileName); } this.logger.endGroup(); - function printProjects(logger, projects, counter) { - for (var _i = 0, projects_3 = projects; _i < projects_3.length; _i++) { - var project = projects_3[_i]; - project.updateGraph(); - logger.info("Project '" + project.getProjectName() + "' (" + server.ProjectKind[project.projectKind] + ") " + counter); - logger.info(project.filesToString()); - logger.info("-----------------------------------------------"); - counter++; - } - return counter; - } }; ProjectService.prototype.findConfiguredProjectByProjectName = function (configFileName) { configFileName = server.asNormalizedPath(this.toCanonicalFileName(configFileName)); @@ -79223,10 +80737,11 @@ var ts; if (!this.eventHandler) { return; } - this.eventHandler({ + var event = { eventName: server.ConfigFileDiagEvent, - data: { configFileName: configFileName, diagnostics: diagnostics || [], triggerFile: triggerFile } - }); + data: { configFileName: configFileName, diagnostics: diagnostics || server.emptyArray, triggerFile: triggerFile } + }; + this.eventHandler(event); }; ProjectService.prototype.createAndAddConfiguredProject = function (configFileName, projectOptions, configFileErrors, clientFileName) { var _this = this; @@ -79375,18 +80890,60 @@ var ts; } return configFileErrors; }; - ProjectService.prototype.createInferredProjectWithRootFileIfNecessary = function (root) { + ProjectService.prototype.getOrCreateInferredProjectForProjectRootPathIfEnabled = function (root, projectRootPath) { + if (!this.useInferredProjectPerProjectRoot) { + return undefined; + } + if (projectRootPath) { + for (var _i = 0, _a = this.inferredProjects; _i < _a.length; _i++) { + var project = _a[_i]; + if (project.projectRootPath === projectRootPath) { + return project; + } + } + return this.createInferredProject(false, projectRootPath); + } + var bestMatch; + for (var _b = 0, _c = this.inferredProjects; _b < _c.length; _b++) { + var project = _c[_b]; + if (!project.projectRootPath) + continue; + if (!ts.containsPath(project.projectRootPath, root.path, this.host.getCurrentDirectory(), !this.host.useCaseSensitiveFileNames)) + continue; + if (bestMatch && bestMatch.projectRootPath.length > project.projectRootPath.length) + continue; + bestMatch = project; + } + return bestMatch; + }; + ProjectService.prototype.getOrCreateSingleInferredProjectIfEnabled = function () { + if (!this.useSingleInferredProject) { + return undefined; + } + if (this.inferredProjects.length > 0 && this.inferredProjects[0].projectRootPath === undefined) { + return this.inferredProjects[0]; + } + return this.createInferredProject(true); + }; + ProjectService.prototype.createInferredProject = function (isSingleInferredProject, projectRootPath) { + var compilerOptions = projectRootPath && this.compilerOptionsForInferredProjectsPerProjectRoot.get(projectRootPath) || this.compilerOptionsForInferredProjects; + var project = new server.InferredProject(this, this.documentRegistry, compilerOptions, projectRootPath); + if (isSingleInferredProject) { + this.inferredProjects.unshift(project); + } + else { + this.inferredProjects.push(project); + } + return project; + }; + ProjectService.prototype.createInferredProjectWithRootFileIfNecessary = function (root, projectRootPath) { var _this = this; - var useExistingProject = this.useSingleInferredProject && this.inferredProjects.length; - var project = useExistingProject - ? this.inferredProjects[0] - : new server.InferredProject(this, this.documentRegistry, this.compilerOptionsForInferredProjects); + var project = this.getOrCreateInferredProjectForProjectRootPathIfEnabled(root, projectRootPath) || + this.getOrCreateSingleInferredProjectIfEnabled() || + this.createInferredProject(); project.addRoot(root); this.directoryWatchers.startWatchingContainingDirectoriesForFile(root.fileName, project, function (fileName) { return _this.onConfigFileAddedForInferredProject(fileName); }); project.updateGraph(); - if (!useExistingProject) { - this.inferredProjects.push(project); - } return project; }; ProjectService.prototype.getOrCreateScriptInfo = function (uncheckedFileName, openedByClient, fileContent, scriptKind) { @@ -79519,7 +81076,7 @@ var ts; project.markAsDirty(); } var info = this.getOrCreateScriptInfoForNormalizedPath(fileName, true, fileContent, scriptKind, hasMixedContent); - this.assignScriptInfoToInferredProjectIfNecessary(info, true); + this.assignScriptInfoToInferredProjectIfNecessary(info, true, projectRootPath); this.deleteOrphanScriptInfoNotInAnyProject(); this.printProjects(); return { configFileName: configFileName, configFileErrors: configFileErrors }; @@ -79533,13 +81090,13 @@ var ts; this.printProjects(); }; ProjectService.prototype.collectChanges = function (lastKnownProjectVersions, currentProjects, result) { - var _loop_10 = function (proj) { + var _loop_11 = function (proj) { var knownProject = ts.forEach(lastKnownProjectVersions, function (p) { return p.projectName === proj.getProjectName() && p; }); result.push(proj.getChangesSinceVersion(knownProject && knownProject.version)); }; for (var _i = 0, currentProjects_1 = currentProjects; _i < currentProjects_1.length; _i++) { var proj = currentProjects_1[_i]; - _loop_10(proj); + _loop_11(proj); } }; ProjectService.prototype.synchronizeProjectList = function (knownProjects) { @@ -79644,21 +81201,14 @@ var ts; ProjectService.prototype.resetSafeList = function () { this.safelist = defaultTypeSafeList; }; - ProjectService.prototype.loadSafeList = function (fileName) { - var raw = JSON.parse(this.host.readFile(fileName, "utf-8")); - for (var _i = 0, _a = Object.keys(raw); _i < _a.length; _i++) { - var k = _a[_i]; - raw[k].match = new RegExp(raw[k].match, "i"); - } - this.safelist = raw; - }; ProjectService.prototype.applySafeList = function (proj) { var _this = this; var rootFiles = proj.rootFiles, typeAcquisition = proj.typeAcquisition; var types = (typeAcquisition && typeAcquisition.include) || []; var excludeRules = []; var normalizedNames = rootFiles.map(function (f) { return ts.normalizeSlashes(f.fileName); }); - var _loop_11 = function (name) { + var excludedFiles = []; + var _loop_12 = function (name) { var rule = this_3.safelist[name]; for (var _i = 0, normalizedNames_1 = normalizedNames; _i < normalizedNames_1.length; _i++) { var root = normalizedNames_1[_i]; @@ -79673,7 +81223,7 @@ var ts; } } if (rule.exclude) { - var _loop_12 = function (exclude) { + var _loop_13 = function (exclude) { var processedRule = root.replace(rule.match, function () { var groups = []; for (var _i = 0; _i < arguments.length; _i++) { @@ -79696,7 +81246,7 @@ var ts; }; for (var _c = 0, _d = rule.exclude; _c < _d.length; _c++) { var exclude = _d[_c]; - _loop_12(exclude); + _loop_13(exclude); } } else { @@ -79715,10 +81265,23 @@ var ts; var this_3 = this; for (var _i = 0, _a = Object.keys(this.safelist); _i < _a.length; _i++) { var name = _a[_i]; - _loop_11(name); + _loop_12(name); } var excludeRegexes = excludeRules.map(function (e) { return new RegExp(e, "i"); }); - proj.rootFiles = proj.rootFiles.filter(function (_file, index) { return !excludeRegexes.some(function (re) { return re.test(normalizedNames[index]); }); }); + var filesToKeep = []; + var _loop_14 = function (i) { + if (excludeRegexes.some(function (re) { return re.test(normalizedNames[i]); })) { + excludedFiles.push(normalizedNames[i]); + } + else { + filesToKeep.push(proj.rootFiles[i]); + } + }; + for (var i = 0; i < proj.rootFiles.length; i++) { + _loop_14(i); + } + proj.rootFiles = filesToKeep; + return excludedFiles; }; ProjectService.prototype.openExternalProject = function (proj, suppressRefreshOfInferredProjects) { if (suppressRefreshOfInferredProjects === void 0) { suppressRefreshOfInferredProjects = false; } @@ -79726,7 +81289,7 @@ var ts; var typeAcquisition = ts.convertEnableAutoDiscoveryToEnable(proj.typingOptions); proj.typeAcquisition = typeAcquisition; } - this.applySafeList(proj); + var excludedFiles = this.applySafeList(proj); var tsConfigFiles; var rootFiles = []; for (var _i = 0, _a = proj.rootFiles; _i < _a.length; _i++) { @@ -79747,6 +81310,7 @@ var ts; var externalProject = this.findExternalProjectByProjectName(proj.projectFileName); var exisingConfigFiles; if (externalProject) { + externalProject.excludedFiles = excludedFiles; if (!tsConfigFiles) { var compilerOptions = convertCompilerOptions(proj.options); if (this.exceededTotalSizeLimitForNonTsFiles(proj.projectFileName, compilerOptions, proj.rootFiles, externalFilePropertyReader)) { @@ -79805,7 +81369,8 @@ var ts; } else { this.externalProjectToConfiguredProjectMap.delete(proj.projectFileName); - this.createAndAddExternalProject(proj.projectFileName, rootFiles, proj.options, proj.typeAcquisition); + var newProj = this.createAndAddExternalProject(proj.projectFileName, rootFiles, proj.options, proj.typeAcquisition); + newProj.excludedFiles = excludedFiles; } if (!suppressRefreshOfInferredProjects) { this.refreshInferredProjects(); @@ -79904,20 +81469,16 @@ var ts; var MultistepOperation = (function () { function MultistepOperation(operationHost) { this.operationHost = operationHost; - this.completed = true; } MultistepOperation.prototype.startNew = function (action) { this.complete(); this.requestId = this.operationHost.getCurrentRequestId(); - this.completed = false; this.executeAction(action); }; MultistepOperation.prototype.complete = function () { - if (!this.completed) { - if (this.requestId) { - this.operationHost.sendRequestCompletedEvent(this.requestId); - } - this.completed = true; + if (this.requestId !== undefined) { + this.operationHost.sendRequestCompletedEvent(this.requestId); + this.requestId = undefined; } this.setTimerHandle(undefined); this.setImmediateId(undefined); @@ -80082,6 +81643,9 @@ var ts; _a[server.CommandNames.DocCommentTemplate] = function (request) { return _this.requiredResponse(_this.getDocCommentTemplate(request.arguments)); }, + _a[server.CommandNames.GetSpanOfEnclosingComment] = function (request) { + return _this.requiredResponse(_this.getSpanOfEnclosingComment(request.arguments)); + }, _a[server.CommandNames.Format] = function (request) { return _this.requiredResponse(_this.getFormattingEditsForRange(request.arguments)); }, @@ -80253,6 +81817,7 @@ var ts; logger: this.logger, cancellationToken: this.cancellationToken, useSingleInferredProject: opts.useSingleInferredProject, + useInferredProjectPerProjectRoot: opts.useInferredProjectPerProjectRoot, typingsInstaller: this.typingsInstaller, throttleWaitMilliseconds: throttleWaitMilliseconds, eventHandler: this.eventHandler, @@ -80279,7 +81844,7 @@ var ts; case server.ContextEvent: var _a = event.data, project_1 = _a.project, fileName_3 = _a.fileName; this.projectService.logger.info("got context event, updating diagnostics for " + fileName_3); - this.errorCheck.startNew(function (next) { return _this.updateErrorCheck(next, [{ fileName: fileName_3, project: project_1 }], _this.changeSeq, function (n) { return n === _this.changeSeq; }, 100); }); + this.errorCheck.startNew(function (next) { return _this.updateErrorCheck(next, [{ fileName: fileName_3, project: project_1 }], 100); }); break; case server.ConfigFileDiagEvent: var _b = event.data, triggerFile = _b.triggerFile, configFileName = _b.configFileName, diagnostics = _b.diagnostics; @@ -80387,26 +81952,24 @@ var ts; this.logError(err, "syntactic check"); } }; - Session.prototype.updateProjectStructure = function (seq, matchSeq, ms) { + Session.prototype.updateProjectStructure = function () { var _this = this; - if (ms === void 0) { ms = 1500; } + var ms = 1500; + var seq = this.changeSeq; this.host.setTimeout(function () { - if (matchSeq(seq)) { + if (_this.changeSeq === seq) { _this.projectService.refreshInferredProjects(); } }, ms); }; - Session.prototype.updateErrorCheck = function (next, checkList, seq, matchSeq, ms, followMs, requireOpen) { + Session.prototype.updateErrorCheck = function (next, checkList, ms, requireOpen) { var _this = this; - if (ms === void 0) { ms = 1500; } - if (followMs === void 0) { followMs = 200; } if (requireOpen === void 0) { requireOpen = true; } - if (followMs > ms) { - followMs = ms; - } + var seq = this.changeSeq; + var followMs = Math.min(ms, 200); var index = 0; var checkOne = function () { - if (matchSeq(seq)) { + if (_this.changeSeq === seq) { var checkSpec_1 = checkList[index]; index++; if (checkSpec_1.project.containsFile(checkSpec_1.fileName, requireOpen)) { @@ -80420,7 +81983,7 @@ var ts; } } }; - if ((checkList.length > index) && (matchSeq(seq))) { + if (checkList.length > index && this.changeSeq === seq) { next.delay(ms, checkOne); } }; @@ -80498,7 +82061,7 @@ var ts; Session.prototype.getDiagnosticsWorker = function (args, isSemantic, selector, includeLinePosition) { var _a = this.getFileAndProject(args), project = _a.project, file = _a.file; if (isSemantic && isDeclarationFileInJSOnlyNonConfiguredProject(project, file)) { - return []; + return server.emptyArray; } var scriptInfo = project.getScriptInfoForNormalizedPath(file); var diagnostics = selector(project, file); @@ -80512,7 +82075,7 @@ var ts; var position = this.getPosition(args, scriptInfo); var definitions = project.getLanguageService().getDefinitionAtPosition(file, position); if (!definitions) { - return undefined; + return server.emptyArray; } if (simplifiedResult) { return definitions.map(function (def) { @@ -80534,7 +82097,7 @@ var ts; var position = this.getPosition(args, scriptInfo); var definitions = project.getLanguageService().getTypeDefinitionAtPosition(file, position); if (!definitions) { - return undefined; + return server.emptyArray; } return definitions.map(function (def) { var defScriptInfo = project.getScriptInfo(def.fileName); @@ -80550,7 +82113,7 @@ var ts; var position = this.getPosition(args, project.getScriptInfoForNormalizedPath(file)); var implementations = project.getLanguageService().getImplementationAtPosition(file, position); if (!implementations) { - return []; + return server.emptyArray; } if (simplifiedResult) { return implementations.map(function (_a) { @@ -80573,7 +82136,7 @@ var ts; var position = this.getPosition(args, scriptInfo); var occurrences = project.getLanguageService().getOccurrencesAtPosition(file, position); if (!occurrences) { - return undefined; + return server.emptyArray; } return occurrences.map(function (occurrence) { var fileName = occurrence.fileName, isWriteAccess = occurrence.isWriteAccess, textSpan = occurrence.textSpan, isInString = occurrence.isInString; @@ -80595,7 +82158,7 @@ var ts; Session.prototype.getSyntacticDiagnosticsSync = function (args) { var configFile = this.getConfigFileAndProject(args).configFile; if (configFile) { - return []; + return server.emptyArray; } return this.getDiagnosticsWorker(args, false, function (project, file) { return project.getLanguageService().getSyntacticDiagnostics(file); }, args.includeLinePosition); }; @@ -80612,7 +82175,7 @@ var ts; var position = this.getPosition(args, scriptInfo); var documentHighlights = project.getLanguageService().getDocumentHighlights(file, position, args.filesToSearch); if (!documentHighlights) { - return undefined; + return server.emptyArray; } if (simplifiedResult) { return documentHighlights.map(convertToDocumentHighlightsItem); @@ -80636,7 +82199,7 @@ var ts; } }; Session.prototype.setCompilerOptionsForInferredProjects = function (args) { - this.projectService.setCompilerOptionsForInferredProjects(args.options); + this.projectService.setCompilerOptionsForInferredProjects(args.options, args.projectRootPath); }; Session.prototype.getProjectInfo = function (args) { return this.getProjectInfoWorker(args.file, args.projectFileName, args.needFileNameList, false); @@ -80698,13 +82261,13 @@ var ts; if (!renameInfo.canRename) { return { info: renameInfo, - locs: [] + locs: server.emptyArray }; } var fileSpans = server.combineProjectOutput(projects, function (project) { var renameLocations = project.getLanguageService().findRenameLocations(file, position, args.findInStrings, args.findInComments); if (!renameLocations) { - return []; + return server.emptyArray; } return renameLocations.map(function (location) { var locationScriptInfo = project.getScriptInfo(location.fileName); @@ -80785,7 +82348,7 @@ var ts; var refs = server.combineProjectOutput(projects, function (project) { var references = project.getLanguageService().getReferencesAtPosition(file, position); if (!references) { - return []; + return server.emptyArray; } return references.map(function (ref) { var refScriptInfo = project.getScriptInfo(ref.fileName); @@ -80826,7 +82389,7 @@ var ts; if (this.eventHandler) { this.eventHandler({ eventName: "configFileDiag", - data: { triggerFile: fileName, configFileName: configFileName, diagnostics: configFileErrors || [] } + data: { triggerFile: fileName, configFileName: configFileName, diagnostics: configFileErrors || server.emptyArray } }); } }; @@ -80863,6 +82426,13 @@ var ts; var position = this.getPosition(args, scriptInfo); return project.getLanguageService(false).getDocCommentTemplateAtPosition(file, position); }; + Session.prototype.getSpanOfEnclosingComment = function (args) { + var _a = this.getFileAndProjectWithoutRefreshingInferredProjects(args), file = _a.file, project = _a.project; + var scriptInfo = project.getScriptInfoForNormalizedPath(file); + var onlyMultiLine = args.onlyMultiLine; + var position = this.getPosition(args, scriptInfo); + return project.getLanguageService(false).getSpanOfEnclosingComment(file, position, onlyMultiLine); + }; Session.prototype.getIndentation = function (args) { var _a = this.getFileAndProjectWithoutRefreshingInferredProjects(args), file = _a.file, project = _a.project; var position = this.getPosition(args, project.getScriptInfoForNormalizedPath(file)); @@ -80986,11 +82556,8 @@ var ts; var scriptInfo = project.getScriptInfoForNormalizedPath(file); var position = this.getPosition(args, scriptInfo); var completions = project.getLanguageService().getCompletionsAtPosition(file, position); - if (!completions) { - return undefined; - } if (simplifiedResult) { - return ts.mapDefined(completions.entries, function (entry) { + return ts.mapDefined(completions && completions.entries, function (entry) { if (completions.isMemberCompletion || (entry.name.toLowerCase().indexOf(prefix.toLowerCase()) === 0)) { var name = entry.name, kind = entry.kind, kindModifiers = entry.kindModifiers, sortText = entry.sortText, replacementSpan = entry.replacementSpan; var convertedSpan = replacementSpan ? _this.decorateSpan(replacementSpan, scriptInfo) : undefined; @@ -81014,7 +82581,7 @@ var ts; var info = this.projectService.getScriptInfo(args.file); var result = []; if (!info) { - return []; + return server.emptyArray; } var projectsToSearch = args.projectFileName ? [this.projectService.findProject(args.projectFileName)] : info.containingProjects; for (var _i = 0, projectsToSearch_1 = projectsToSearch; _i < projectsToSearch_1.length; _i++) { @@ -81074,11 +82641,10 @@ var ts; return project && { fileName: fileName, project: project }; }); if (checkList.length > 0) { - this.updateErrorCheck(next, checkList, this.changeSeq, function (n) { return n === _this.changeSeq; }, delay); + this.updateErrorCheck(next, checkList, delay); } }; Session.prototype.change = function (args) { - var _this = this; var _a = this.getFileAndProject(args, false), file = _a.file, project = _a.project; if (project) { var scriptInfo = project.getScriptInfoForNormalizedPath(file); @@ -81088,7 +82654,7 @@ var ts; scriptInfo.editContent(start, end, args.insertString); this.changeSeq++; } - this.updateProjectStructure(this.changeSeq, function (n) { return n === _this.changeSeq; }); + this.updateProjectStructure(); } }; Session.prototype.reload = function (args, reqSeq) { @@ -81167,7 +82733,7 @@ var ts; return server.combineProjectOutput(projects, function (project) { var navItems = project.getLanguageService().getNavigateToItems(args.searchValue, args.maxResultCount, fileName, project.isNonTsProject()); if (!navItems) { - return []; + return server.emptyArray; } return navItems.map(function (navItem) { var scriptInfo = project.getScriptInfo(navItem.fileName); @@ -81357,7 +82923,6 @@ var ts; : spans; }; Session.prototype.getDiagnosticsForProject = function (next, delay, fileName) { - var _this = this; var _a = this.getProjectInfoWorker(fileName, undefined, true, true), fileNames = _a.fileNames, languageServiceDisabled = _a.languageServiceDisabled; if (languageServiceDisabled) { return; @@ -81392,7 +82957,7 @@ var ts; fileNamesInProject = highPriorityFiles.concat(mediumPriorityFiles).concat(lowPriorityFiles).concat(veryLowPriorityFiles); if (fileNamesInProject.length > 0) { var checkList = fileNamesInProject.map(function (fileName) { return ({ fileName: fileName, project: project }); }); - this.updateErrorCheck(next, checkList, this.changeSeq, function (n) { return n === _this.changeSeq; }, delay, 200, false); + this.updateErrorCheck(next, checkList, delay, false); } }; Session.prototype.getCanonicalFileName = function (fileName) { @@ -81499,13 +83064,13 @@ var ts; CharRangeSection[CharRangeSection["Mid"] = 3] = "Mid"; CharRangeSection[CharRangeSection["End"] = 4] = "End"; CharRangeSection[CharRangeSection["PostEnd"] = 5] = "PostEnd"; - })(CharRangeSection = server.CharRangeSection || (server.CharRangeSection = {})); + })(CharRangeSection || (CharRangeSection = {})); var EditWalker = (function () { function EditWalker() { this.goSubtree = true; this.lineIndex = new LineIndex(); this.endBranch = []; - this.state = CharRangeSection.Entire; + this.state = 2; this.initialText = ""; this.trailingText = ""; this.lineIndex.root = new LineNode(); @@ -81594,14 +83159,14 @@ var ts; }; EditWalker.prototype.post = function (_relativeStart, _relativeLength, lineCollection) { if (lineCollection === this.lineCollectionAtBranch) { - this.state = CharRangeSection.End; + this.state = 4; } this.stack.pop(); }; EditWalker.prototype.pre = function (_relativeStart, _relativeLength, lineCollection, _parent, nodeType) { var currentNode = this.stack[this.stack.length - 1]; - if ((this.state === CharRangeSection.Entire) && (nodeType === CharRangeSection.Start)) { - this.state = CharRangeSection.Start; + if ((this.state === 2) && (nodeType === 1)) { + this.state = 1; this.branchNode = currentNode; this.lineCollectionAtBranch = lineCollection; } @@ -81614,14 +83179,14 @@ var ts; return new LineNode(); } switch (nodeType) { - case CharRangeSection.PreStart: + case 0: this.goSubtree = false; - if (this.state !== CharRangeSection.End) { + if (this.state !== 4) { currentNode.add(lineCollection); } break; - case CharRangeSection.Start: - if (this.state === CharRangeSection.End) { + case 1: + if (this.state === 4) { this.goSubtree = false; } else { @@ -81630,8 +83195,8 @@ var ts; this.startPath.push(child); } break; - case CharRangeSection.Entire: - if (this.state !== CharRangeSection.End) { + case 2: + if (this.state !== 4) { child = fresh(lineCollection); currentNode.add(child); this.startPath.push(child); @@ -81644,11 +83209,11 @@ var ts; } } break; - case CharRangeSection.Mid: + case 3: this.goSubtree = false; break; - case CharRangeSection.End: - if (this.state !== CharRangeSection.End) { + case 4: + if (this.state !== 4) { this.goSubtree = false; } else { @@ -81659,9 +83224,9 @@ var ts; } } break; - case CharRangeSection.PostEnd: + case 5: this.goSubtree = false; - if (this.state !== CharRangeSection.Start) { + if (this.state !== 1) { currentNode.add(lineCollection); } break; @@ -81671,10 +83236,10 @@ var ts; } }; EditWalker.prototype.leaf = function (relativeStart, relativeLength, ll) { - if (this.state === CharRangeSection.Start) { + if (this.state === 1) { this.initialText = ll.text.substring(0, relativeStart); } - else if (this.state === CharRangeSection.Entire) { + else if (this.state === 2) { this.initialText = ll.text.substring(0, relativeStart); this.trailingText = ll.text.substring(relativeStart + relativeLength); } @@ -81695,7 +83260,6 @@ var ts; }; return TextChange; }()); - server.TextChange = TextChange; var ScriptVersionCache = (function () { function ScriptVersionCache() { this.changes = []; @@ -81720,15 +83284,6 @@ var ts; this.getSnapshot(); } }; - ScriptVersionCache.prototype.latest = function () { - return this.versions[this.currentVersionToIndex()]; - }; - ScriptVersionCache.prototype.latestVersion = function () { - if (this.changes.length > 0) { - this.getSnapshot(); - } - return this.currentVersion; - }; ScriptVersionCache.prototype.reload = function (script) { this.currentVersion++; this.changes = []; @@ -81741,7 +83296,8 @@ var ts; snap.index.load(lm.lines); this.minVersion = this.currentVersion; }; - ScriptVersionCache.prototype.getSnapshot = function () { + ScriptVersionCache.prototype.getSnapshot = function () { return this._getSnapshot(); }; + ScriptVersionCache.prototype._getSnapshot = function () { var snap = this.versions[this.currentVersionToIndex()]; if (this.changes.length > 0) { var snapIndex = snap.index; @@ -81759,6 +83315,24 @@ var ts; } return snap; }; + ScriptVersionCache.prototype.getSnapshotVersion = function () { + return this._getSnapshot().version; + }; + ScriptVersionCache.prototype.getLineInfo = function (line) { + return this._getSnapshot().index.lineNumberToInfo(line); + }; + ScriptVersionCache.prototype.lineOffsetToPosition = function (line, column) { + return this._getSnapshot().index.absolutePositionOfStartOfLine(line) + (column - 1); + }; + ScriptVersionCache.prototype.positionToLineOffset = function (position) { + return this._getSnapshot().index.positionToLineOffset(position); + }; + ScriptVersionCache.prototype.lineToTextSpan = function (line) { + var index = this._getSnapshot().index; + var _a = index.lineNumberToInfo(line + 1), lineText = _a.lineText, absolutePosition = _a.absolutePosition; + var len = lineText !== undefined ? lineText.length : index.absolutePositionOfStartOfLine(line + 2) - absolutePosition; + return ts.createTextSpan(absolutePosition, len); + }; ScriptVersionCache.prototype.getTextChangesBetweenVersions = function (oldVersion, newVersion) { if (oldVersion < newVersion) { if (oldVersion >= this.minVersion) { @@ -81820,7 +83394,6 @@ var ts; }; return LineIndexSnapshot; }()); - server.LineIndexSnapshot = LineIndexSnapshot; var LineIndex = (function () { function LineIndex() { this.checkEdits = false; @@ -82019,18 +83592,18 @@ var ts; var childCharCount = this.children[childIndex].charCount(); var adjustedStart = rangeStart; while (adjustedStart >= childCharCount) { - this.skipChild(adjustedStart, rangeLength, childIndex, walkFns, CharRangeSection.PreStart); + this.skipChild(adjustedStart, rangeLength, childIndex, walkFns, 0); adjustedStart -= childCharCount; childIndex++; childCharCount = this.children[childIndex].charCount(); } if ((adjustedStart + rangeLength) <= childCharCount) { - if (this.execWalk(adjustedStart, rangeLength, walkFns, childIndex, CharRangeSection.Entire)) { + if (this.execWalk(adjustedStart, rangeLength, walkFns, childIndex, 2)) { return; } } else { - if (this.execWalk(adjustedStart, childCharCount - adjustedStart, walkFns, childIndex, CharRangeSection.Start)) { + if (this.execWalk(adjustedStart, childCharCount - adjustedStart, walkFns, childIndex, 1)) { return; } var adjustedLength = rangeLength - (childCharCount - adjustedStart); @@ -82038,7 +83611,7 @@ var ts; var child = this.children[childIndex]; childCharCount = child.charCount(); while (adjustedLength > childCharCount) { - if (this.execWalk(0, childCharCount, walkFns, childIndex, CharRangeSection.Mid)) { + if (this.execWalk(0, childCharCount, walkFns, childIndex, 3)) { return; } adjustedLength -= childCharCount; @@ -82046,7 +83619,7 @@ var ts; childCharCount = this.children[childIndex].charCount(); } if (adjustedLength > 0) { - if (this.execWalk(0, adjustedLength, walkFns, childIndex, CharRangeSection.End)) { + if (this.execWalk(0, adjustedLength, walkFns, childIndex, 4)) { return; } } @@ -82055,82 +83628,46 @@ var ts; var clen = this.children.length; if (childIndex < (clen - 1)) { for (var ej = childIndex + 1; ej < clen; ej++) { - this.skipChild(0, 0, ej, walkFns, CharRangeSection.PostEnd); + this.skipChild(0, 0, ej, walkFns, 5); } } } }; LineNode.prototype.charOffsetToLineInfo = function (lineNumberAccumulator, relativePosition) { - var childInfo = this.childFromCharOffset(lineNumberAccumulator, relativePosition); - if (!childInfo.child) { - return { - oneBasedLine: lineNumberAccumulator, - zeroBasedColumn: relativePosition, - lineText: undefined, - }; + if (this.children.length === 0) { + return { oneBasedLine: lineNumberAccumulator, zeroBasedColumn: relativePosition, lineText: undefined }; } - else if (childInfo.childIndex < this.children.length) { - if (childInfo.child.isLeaf()) { - return { - oneBasedLine: childInfo.lineNumberAccumulator, - zeroBasedColumn: childInfo.relativePosition, - lineText: childInfo.child.text, - }; - } - else { - var lineNode = (childInfo.child); - return lineNode.charOffsetToLineInfo(childInfo.lineNumberAccumulator, childInfo.relativePosition); - } - } - else { - var lineInfo = this.lineNumberToInfo(this.lineCount(), 0); - return { oneBasedLine: this.lineCount(), zeroBasedColumn: lineInfo.leaf.charCount(), lineText: undefined }; - } - }; - LineNode.prototype.lineNumberToInfo = function (relativeOneBasedLine, positionAccumulator) { - var childInfo = this.childFromLineNumber(relativeOneBasedLine, positionAccumulator); - if (!childInfo.child) { - return { position: positionAccumulator, leaf: undefined }; - } - else if (childInfo.child.isLeaf()) { - return { position: childInfo.positionAccumulator, leaf: childInfo.child }; - } - else { - var lineNode = (childInfo.child); - return lineNode.lineNumberToInfo(childInfo.relativeOneBasedLine, childInfo.positionAccumulator); - } - }; - LineNode.prototype.childFromLineNumber = function (relativeOneBasedLine, positionAccumulator) { - var child; - var i; - for (i = 0; i < this.children.length; i++) { - child = this.children[i]; - var childLineCount = child.lineCount(); - if (childLineCount >= relativeOneBasedLine) { - break; - } - else { - relativeOneBasedLine -= childLineCount; - positionAccumulator += child.charCount(); - } - } - return { child: child, relativeOneBasedLine: relativeOneBasedLine, positionAccumulator: positionAccumulator }; - }; - LineNode.prototype.childFromCharOffset = function (lineNumberAccumulator, relativePosition) { - var child; - var i; - var len; - for (i = 0, len = this.children.length; i < len; i++) { - child = this.children[i]; + for (var _i = 0, _a = this.children; _i < _a.length; _i++) { + var child = _a[_i]; if (child.charCount() > relativePosition) { - break; + if (child.isLeaf()) { + return { oneBasedLine: lineNumberAccumulator, zeroBasedColumn: relativePosition, lineText: child.text }; + } + else { + return child.charOffsetToLineInfo(lineNumberAccumulator, relativePosition); + } } else { relativePosition -= child.charCount(); lineNumberAccumulator += child.lineCount(); } } - return { child: child, childIndex: i, relativePosition: relativePosition, lineNumberAccumulator: lineNumberAccumulator }; + var leaf = this.lineNumberToInfo(this.lineCount(), 0).leaf; + return { oneBasedLine: this.lineCount(), zeroBasedColumn: leaf.charCount(), lineText: undefined }; + }; + LineNode.prototype.lineNumberToInfo = function (relativeOneBasedLine, positionAccumulator) { + for (var _i = 0, _a = this.children; _i < _a.length; _i++) { + var child = _a[_i]; + var childLineCount = child.lineCount(); + if (childLineCount >= relativeOneBasedLine) { + return child.isLeaf() ? { position: positionAccumulator, leaf: child } : child.lineNumberToInfo(relativeOneBasedLine, positionAccumulator); + } + else { + relativeOneBasedLine -= childLineCount; + positionAccumulator += child.charCount(); + } + } + return { position: positionAccumulator, leaf: undefined }; }; LineNode.prototype.splitAfter = function (childIndex) { var splitNode; @@ -82227,7 +83764,6 @@ var ts; }; return LineNode; }()); - server.LineNode = LineNode; var LineLeaf = (function () { function LineLeaf(text) { this.text = text; @@ -82246,7 +83782,6 @@ var ts; }; return LineLeaf; }()); - server.LineLeaf = LineLeaf; })(server = ts.server || (ts.server = {})); })(ts || (ts = {})); var ts; @@ -82335,14 +83870,15 @@ var ts; Logger.prototype.info = function (s) { this.msg(s, server.Msg.Info); }; + Logger.prototype.err = function (s) { + this.msg(s, server.Msg.Err); + }; Logger.prototype.startGroup = function () { this.inGroup = true; this.firstInGroup = true; }; Logger.prototype.endGroup = function () { this.inGroup = false; - this.seq++; - this.firstInGroup = true; }; Logger.prototype.loggingEnabled = function () { return !!this.logFilename || this.traceToConsole; @@ -82352,24 +83888,32 @@ var ts; }; Logger.prototype.msg = function (s, type) { if (type === void 0) { type = server.Msg.Err; } - if (this.fd >= 0 || this.traceToConsole) { - s = "[" + nowString() + "] " + s + "\n"; + if (!this.canWrite) + return; + s = "[" + nowString() + "] " + s + "\n"; + if (!this.inGroup || this.firstInGroup) { var prefix = Logger.padStringRight(type + " " + this.seq.toString(), " "); - if (this.firstInGroup) { - s = prefix + s; - this.firstInGroup = false; - } - if (!this.inGroup) { - this.seq++; - this.firstInGroup = true; - } - if (this.fd >= 0) { - var buf = new Buffer(s); - fs.writeSync(this.fd, buf, 0, buf.length, null); - } - if (this.traceToConsole) { - console.warn(s); - } + s = prefix + s; + } + this.write(s); + if (!this.inGroup) { + this.seq++; + } + }; + Object.defineProperty(Logger.prototype, "canWrite", { + get: function () { + return this.fd >= 0 || this.traceToConsole; + }, + enumerable: true, + configurable: true + }); + Logger.prototype.write = function (s) { + if (this.fd >= 0) { + var buf = new Buffer(s); + fs.writeSync(this.fd, buf, 0, buf.length, null); + } + if (this.traceToConsole) { + console.warn(s); } }; return Logger; @@ -82379,12 +83923,13 @@ var ts; return d.getHours() + ":" + d.getMinutes() + ":" + d.getSeconds() + "." + d.getMilliseconds(); } var NodeTypingsInstaller = (function () { - function NodeTypingsInstaller(telemetryEnabled, logger, host, eventPort, globalTypingsCacheLocation, typingSafeListLocation, npmLocation, newLine) { + function NodeTypingsInstaller(telemetryEnabled, logger, host, eventPort, globalTypingsCacheLocation, typingSafeListLocation, typesMapLocation, npmLocation, newLine) { var _this = this; this.telemetryEnabled = telemetryEnabled; this.logger = logger; this.globalTypingsCacheLocation = globalTypingsCacheLocation; this.typingSafeListLocation = typingSafeListLocation; + this.typesMapLocation = typesMapLocation; this.npmLocation = npmLocation; this.newLine = newLine; this.installerPidReported = false; @@ -82427,6 +83972,9 @@ var ts; if (this.typingSafeListLocation) { args.push(server.Arguments.TypingSafeListLocation, this.typingSafeListLocation); } + if (this.typesMapLocation) { + args.push(server.Arguments.TypesMapLocation, this.typesMapLocation); + } if (this.npmLocation) { args.push(server.Arguments.NpmLocation, this.npmLocation); } @@ -82530,14 +84078,15 @@ var ts; __extends(IOSession, _super); function IOSession(options) { var _this = this; - var host = options.host, installerEventPort = options.installerEventPort, globalTypingsCacheLocation = options.globalTypingsCacheLocation, typingSafeListLocation = options.typingSafeListLocation, npmLocation = options.npmLocation, canUseEvents = options.canUseEvents; + var host = options.host, installerEventPort = options.installerEventPort, globalTypingsCacheLocation = options.globalTypingsCacheLocation, typingSafeListLocation = options.typingSafeListLocation, typesMapLocation = options.typesMapLocation, npmLocation = options.npmLocation, canUseEvents = options.canUseEvents; var typingsInstaller = disableAutomaticTypingAcquisition ? undefined - : new NodeTypingsInstaller(telemetryEnabled, logger, host, installerEventPort, globalTypingsCacheLocation, typingSafeListLocation, npmLocation, host.newLine); + : new NodeTypingsInstaller(telemetryEnabled, logger, host, installerEventPort, globalTypingsCacheLocation, typingSafeListLocation, typesMapLocation, npmLocation, host.newLine); _this = _super.call(this, { host: host, cancellationToken: cancellationToken, useSingleInferredProject: useSingleInferredProject, + useInferredProjectPerProjectRoot: useInferredProjectPerProjectRoot, typingsInstaller: typingsInstaller || server.nullTypingsInstaller, byteLength: Buffer.byteLength, hrtime: process.hrtime, @@ -82820,12 +84369,22 @@ var ts; if (localeStr) { ts.validateLocaleAndSetLanguage(localeStr, sys); } + ts.setStackTraceLimit(); var typingSafeListLocation = server.findArgument(server.Arguments.TypingSafeListLocation); + var typesMapLocation = server.findArgument(server.Arguments.TypesMapLocation) || ts.combinePaths(sys.getExecutingFilePath(), "../typesMap.json"); var npmLocation = server.findArgument(server.Arguments.NpmLocation); - var globalPlugins = (server.findArgument("--globalPlugins") || "").split(","); - var pluginProbeLocations = (server.findArgument("--pluginProbeLocations") || "").split(","); + function parseStringArray(argName) { + var arg = server.findArgument(argName); + if (arg === undefined) { + return server.emptyArray; + } + return arg.split(",").filter(function (name) { return name !== ""; }); + } + var globalPlugins = parseStringArray("--globalPlugins"); + var pluginProbeLocations = parseStringArray("--pluginProbeLocations"); var allowLocalPluginLoads = server.hasArgument("--allowLocalPluginLoads"); var useSingleInferredProject = server.hasArgument("--useSingleInferredProject"); + var useInferredProjectPerProjectRoot = server.hasArgument("--useInferredProjectPerProjectRoot"); var disableAutomaticTypingAcquisition = server.hasArgument("--disableAutomaticTypingAcquisition"); var telemetryEnabled = server.hasArgument(server.Arguments.EnableTelemetry); var options = { @@ -82834,9 +84393,11 @@ var ts; installerEventPort: eventPort, canUseEvents: eventPort === undefined, useSingleInferredProject: useSingleInferredProject, + useInferredProjectPerProjectRoot: useInferredProjectPerProjectRoot, disableAutomaticTypingAcquisition: disableAutomaticTypingAcquisition, globalTypingsCacheLocation: getGlobalTypingsCacheLocation(), typingSafeListLocation: typingSafeListLocation, + typesMapLocation: typesMapLocation, npmLocation: npmLocation, telemetryEnabled: telemetryEnabled, logger: logger, @@ -82852,3 +84413,5 @@ var ts; ioSession.listen(); })(server = ts.server || (ts.server = {})); })(ts || (ts = {})); + +//# sourceMappingURL=tsserver.js.map diff --git a/lib/tsserverlibrary.d.ts b/lib/tsserverlibrary.d.ts index fce0d53e635..513d8079a40 100644 --- a/lib/tsserverlibrary.d.ts +++ b/lib/tsserverlibrary.d.ts @@ -50,7 +50,7 @@ declare namespace ts { pos: number; end: number; } - enum SyntaxKind { + const enum SyntaxKind { Unknown = 0, EndOfFileToken = 1, SingleLineCommentTrivia = 2, @@ -374,7 +374,7 @@ declare namespace ts { FirstJSDocTagNode = 276, LastJSDocTagNode = 285, } - enum NodeFlags { + const enum NodeFlags { None = 0, Let = 1, Const = 2, @@ -402,7 +402,7 @@ declare namespace ts { ContextFlags = 96256, TypeExcludesFlags = 20480, } - enum ModifierFlags { + const enum ModifierFlags { None = 0, Export = 1, Ambient = 2, @@ -422,7 +422,7 @@ declare namespace ts { TypeScriptModifier = 2270, ExportDefault = 513, } - enum JsxFlags { + const enum JsxFlags { None = 0, IntrinsicNamedElement = 1, IntrinsicIndexedElement = 2, @@ -1175,7 +1175,7 @@ declare namespace ts { interface CatchClause extends Node { kind: SyntaxKind.CatchClause; parent?: TryStatement; - variableDeclaration: VariableDeclaration; + variableDeclaration?: VariableDeclaration; block: Block; } type DeclarationWithTypeParameters = SignatureDeclaration | ClassLikeDeclaration | InterfaceDeclaration | TypeAliasDeclaration | JSDocTemplateTag; @@ -1432,7 +1432,7 @@ declare namespace ts { jsDocTypeTag?: JSDocTypeTag; isArrayType?: boolean; } - enum FlowFlags { + const enum FlowFlags { Unreachable = 1, Start = 2, BranchLabel = 4, @@ -1452,38 +1452,39 @@ declare namespace ts { interface FlowLock { locked?: boolean; } - interface AfterFinallyFlow extends FlowNode, FlowLock { + interface AfterFinallyFlow extends FlowNodeBase, FlowLock { antecedent: FlowNode; } - interface PreFinallyFlow extends FlowNode { + interface PreFinallyFlow extends FlowNodeBase { antecedent: FlowNode; lock: FlowLock; } - interface FlowNode { + type FlowNode = AfterFinallyFlow | PreFinallyFlow | FlowStart | FlowLabel | FlowAssignment | FlowCondition | FlowSwitchClause | FlowArrayMutation; + interface FlowNodeBase { flags: FlowFlags; id?: number; } - interface FlowStart extends FlowNode { + interface FlowStart extends FlowNodeBase { container?: FunctionExpression | ArrowFunction | MethodDeclaration; } - interface FlowLabel extends FlowNode { + interface FlowLabel extends FlowNodeBase { antecedents: FlowNode[]; } - interface FlowAssignment extends FlowNode { + interface FlowAssignment extends FlowNodeBase { node: Expression | VariableDeclaration | BindingElement; antecedent: FlowNode; } - interface FlowCondition extends FlowNode { + interface FlowCondition extends FlowNodeBase { expression: Expression; antecedent: FlowNode; } - interface FlowSwitchClause extends FlowNode { + interface FlowSwitchClause extends FlowNodeBase { switchStatement: SwitchStatement; clauseStart: number; clauseEnd: number; antecedent: FlowNode; } - interface FlowArrayMutation extends FlowNode { + interface FlowArrayMutation extends FlowNodeBase { node: CallExpression | BinaryExpression; antecedent: FlowNode; } @@ -1607,6 +1608,7 @@ declare namespace ts { getSymbolsOfParameterPropertyDeclaration(parameter: ParameterDeclaration, parameterName: string): Symbol[]; getShorthandAssignmentValueSymbol(location: Node): Symbol | undefined; getExportSpecifierLocalTargetSymbol(location: ExportSpecifier): Symbol | undefined; + getExportSymbolOfSymbol(symbol: Symbol): Symbol; getPropertySymbolOfDestructuringAssignment(location: Identifier): Symbol | undefined; getTypeAtLocation(node: Node): Type; getTypeFromTypeNode(node: TypeNode): Type; @@ -1684,7 +1686,7 @@ declare namespace ts { reportInaccessibleThisError(): void; reportPrivateInBaseOfClassExpression(propertyName: string): void; } - enum TypeFormatFlags { + const enum TypeFormatFlags { None = 0, WriteArrayAsGenericType = 1, UseTypeOfFunction = 4, @@ -1696,18 +1698,18 @@ declare namespace ts { UseFullyQualifiedType = 256, InFirstTypeArgument = 512, InTypeAlias = 1024, - UseTypeAliasValue = 2048, SuppressAnyReturnType = 4096, AddUndefined = 8192, WriteClassExpressionAsTypeLiteral = 16384, InArrayType = 32768, + UseAliasDefinedOutsideCurrentScope = 65536, } - enum SymbolFormatFlags { + const enum SymbolFormatFlags { None = 0, WriteTypeParametersOrArguments = 1, UseOnlyExternalAliasing = 2, } - enum TypePredicateKind { + const enum TypePredicateKind { This = 0, Identifier = 1, } @@ -1724,7 +1726,7 @@ declare namespace ts { parameterIndex: number; } type TypePredicate = IdentifierTypePredicate | ThisTypePredicate; - enum SymbolFlags { + const enum SymbolFlags { None = 0, FunctionScopedVariable = 1, BlockScopedVariable = 2, @@ -1794,7 +1796,7 @@ declare namespace ts { exports?: SymbolTable; globalExports?: SymbolTable; } - enum InternalSymbolName { + const enum InternalSymbolName { Call = "__call", Constructor = "__constructor", New = "__new", @@ -1832,7 +1834,7 @@ declare namespace ts { clear(): void; } type SymbolTable = UnderscoreEscapedMap; - enum TypeFlags { + const enum TypeFlags { Any = 1, String = 2, Number = 4, @@ -1889,7 +1891,7 @@ declare namespace ts { } interface EnumType extends Type { } - enum ObjectFlags { + const enum ObjectFlags { Class = 1, Interface = 2, Reference = 4, @@ -1951,7 +1953,7 @@ declare namespace ts { interface IndexType extends Type { type: TypeVariable | UnionOrIntersectionType; } - enum SignatureKind { + const enum SignatureKind { Call = 0, Construct = 1, } @@ -1960,7 +1962,7 @@ declare namespace ts { typeParameters?: TypeParameter[]; parameters: Symbol[]; } - enum IndexKind { + const enum IndexKind { String = 0, Number = 1, } @@ -1969,7 +1971,7 @@ declare namespace ts { isReadonly: boolean; declaration?: SignatureDeclaration; } - enum InferencePriority { + const enum InferencePriority { NakedTypeVariable = 1, MappedType = 2, ReturnType = 4, @@ -1982,11 +1984,17 @@ declare namespace ts { topLevel: boolean; isFixed: boolean; } - enum InferenceFlags { + const enum InferenceFlags { InferUnionTypes = 1, NoDefault = 2, AnyDefault = 4, } + const enum Ternary { + False = 0, + Maybe = 1, + True = -1, + } + type TypeComparer = (s: Type, t: Type, reportErrors?: boolean) => Ternary; interface JsFileExtensionInfo { extension: string; isMixedContent: boolean; @@ -2073,6 +2081,7 @@ declare namespace ts { outFile?: string; paths?: MapLike; preserveConstEnums?: boolean; + preserveSymlinks?: boolean; project?: string; reactNamespace?: string; jsxFactory?: string; @@ -2118,13 +2127,13 @@ declare namespace ts { ES2015 = 5, ESNext = 6, } - enum JsxEmit { + const enum JsxEmit { None = 0, Preserve = 1, React = 2, ReactNative = 3, } - enum NewLineKind { + const enum NewLineKind { CarriageReturnLineFeed = 0, LineFeed = 1, } @@ -2132,7 +2141,7 @@ declare namespace ts { line: number; character: number; } - enum ScriptKind { + const enum ScriptKind { Unknown = 0, JS = 1, JSX = 2, @@ -2141,7 +2150,7 @@ declare namespace ts { External = 5, JSON = 6, } - enum ScriptTarget { + const enum ScriptTarget { ES3 = 0, ES5 = 1, ES2015 = 2, @@ -2150,7 +2159,7 @@ declare namespace ts { ESNext = 5, Latest = 5, } - enum LanguageVariant { + const enum LanguageVariant { Standard = 0, JSX = 1, } @@ -2163,7 +2172,7 @@ declare namespace ts { wildcardDirectories?: MapLike; compileOnSave?: boolean; } - enum WatchDirectoryFlags { + const enum WatchDirectoryFlags { None = 0, Recursive = 1, } @@ -2186,8 +2195,13 @@ declare namespace ts { } interface ResolvedModuleFull extends ResolvedModule { extension: Extension; + packageId?: PackageId; } - enum Extension { + interface PackageId { + name: string; + version: string; + } + const enum Extension { Ts = ".ts", Tsx = ".tsx", Dts = ".d.ts", @@ -2229,7 +2243,7 @@ declare namespace ts { text: string; skipTrivia?: (pos: number) => number; } - enum EmitFlags { + const enum EmitFlags { SingleLine = 1, AdviseOnEmitNode = 2, NoSubstitution = 4, @@ -2265,7 +2279,7 @@ declare namespace ts { readonly text: string; readonly priority?: number; } - enum EmitHint { + const enum EmitHint { SourceFile = 0, Expression = 1, IdentifierName = 2, @@ -2326,7 +2340,7 @@ declare namespace ts { } } declare namespace ts { - const versionMajorMinor = "2.5"; + const versionMajorMinor = "2.6"; const version: string; } declare function setTimeout(handler: (...args: any[]) => void, timeout: number): any; @@ -2402,6 +2416,8 @@ declare namespace ts { function collapseTextChangeRangesAcrossMultipleVersions(changes: ReadonlyArray): TextChangeRange; function getTypeParameterOwner(d: Declaration): Declaration; function isParameterPropertyDeclaration(node: Node): boolean; + function isEmptyBindingPattern(node: BindingName): node is BindingPattern; + function isEmptyBindingElement(node: BindingElement): boolean; function getCombinedModifierFlags(node: Node): ModifierFlags; function getCombinedNodeFlags(node: Node): NodeFlags; function validateLocaleAndSetLanguage(locale: string, sys: { @@ -2959,8 +2975,8 @@ declare namespace ts { function updateDefaultClause(node: DefaultClause, statements: ReadonlyArray): DefaultClause; function createHeritageClause(token: HeritageClause["token"], types: ReadonlyArray): HeritageClause; function updateHeritageClause(node: HeritageClause, types: ReadonlyArray): HeritageClause; - function createCatchClause(variableDeclaration: string | VariableDeclaration, block: Block): CatchClause; - function updateCatchClause(node: CatchClause, variableDeclaration: VariableDeclaration, block: Block): CatchClause; + function createCatchClause(variableDeclaration: string | VariableDeclaration | undefined, block: Block): CatchClause; + function updateCatchClause(node: CatchClause, variableDeclaration: VariableDeclaration | undefined, block: Block): CatchClause; function createPropertyAssignment(name: string | PropertyName, initializer: Expression): PropertyAssignment; function updatePropertyAssignment(node: PropertyAssignment, name: PropertyName, initializer: Expression): PropertyAssignment; function createShorthandPropertyAssignment(name: string | Identifier, objectAssignmentInitializer?: Expression): ShorthandPropertyAssignment; @@ -3197,6 +3213,7 @@ declare namespace ts { getFormattingEditsAfterKeystroke(fileName: string, position: number, key: string, options: FormatCodeOptions | FormatCodeSettings): TextChange[]; getDocCommentTemplateAtPosition(fileName: string, position: number): TextInsertion; isValidBraceCompletionAtPosition(fileName: string, position: number, openingBrace: number): boolean; + getSpanOfEnclosingComment(fileName: string, position: number, onlyMultiLine: boolean): TextSpan; getCodeFixesAtPosition(fileName: string, start: number, end: number, errorCodes: number[], formatOptions: FormatCodeSettings): CodeAction[]; getApplicableRefactors(fileName: string, positionOrRaneg: number | TextRange): ApplicableRefactorInfo[]; getEditsForRefactor(fileName: string, formatOptions: FormatCodeSettings, positionOrRange: number | TextRange, refactorName: string, actionName: string): RefactorEditInfo | undefined; @@ -3288,7 +3305,7 @@ declare namespace ts { fileName: string; highlightSpans: HighlightSpan[]; } - enum HighlightSpanKind { + const enum HighlightSpanKind { none = "none", definition = "definition", reference = "reference", @@ -3483,7 +3500,7 @@ declare namespace ts { outputFiles: OutputFile[]; emitSkipped: boolean; } - enum OutputFileType { + const enum OutputFileType { JavaScript = 0, SourceMap = 1, Declaration = 2, @@ -3493,7 +3510,7 @@ declare namespace ts { writeByteOrderMark: boolean; text: string; } - enum EndOfLineState { + const enum EndOfLineState { None = 0, InMultiLineCommentTrivia = 1, InSingleQuoteStringLiteral = 2, @@ -3525,7 +3542,7 @@ declare namespace ts { getClassificationsForLine(text: string, lexState: EndOfLineState, syntacticClassifierAbsent: boolean): ClassificationResult; getEncodedLexicalClassifications(text: string, endOfLineState: EndOfLineState, syntacticClassifierAbsent: boolean): Classifications; } - enum ScriptElementKind { + const enum ScriptElementKind { unknown = "", warning = "warning", keyword = "keyword", @@ -3560,7 +3577,7 @@ declare namespace ts { externalModuleName = "external module name", jsxAttribute = "JSX attribute", } - enum ScriptElementKindModifier { + const enum ScriptElementKindModifier { none = "", publicMemberModifier = "public", privateMemberModifier = "private", @@ -3570,7 +3587,7 @@ declare namespace ts { staticModifier = "static", abstractModifier = "abstract", } - enum ClassificationTypeNames { + const enum ClassificationTypeNames { comment = "comment", identifier = "identifier", keyword = "keyword", @@ -3595,7 +3612,7 @@ declare namespace ts { jsxText = "jsx text", jsxAttributeStringLiteralValue = "jsx attribute string literal value", } - enum ClassificationType { + const enum ClassificationType { comment = 1, identifier = 2, keyword = 3, @@ -3687,7 +3704,10 @@ declare namespace ts.server { error: undefined; } | { module: undefined; - error: {}; + error: { + stack?: string; + message?: string; + }; }; interface ServerHost extends System { setTimeout(callback: (...args: any[]) => void, ms: number, ...args: any[]): any; @@ -3770,6 +3790,7 @@ declare namespace ts.server { const LogFile = "--logFile"; const EnableTelemetry = "--enableTelemetry"; const TypingSafeListLocation = "--typingSafeListLocation"; + const TypesMapLocation = "--typesMapLocation"; const NpmLocation = "--npmLocation"; } function hasArgument(argumentName: string): boolean; @@ -3838,9 +3859,6 @@ declare namespace ts.server { function isInferredProjectName(name: string): boolean; function makeInferredProjectName(counter: number): string; function createSortedArray(): SortedArray; - function toSortedArray(arr: string[]): SortedArray; - function toSortedArray(arr: T[], comparer: Comparer): SortedArray; - function enumerateInsertsAndDeletes(newItems: SortedReadonlyArray, oldItems: SortedReadonlyArray, inserted: (newItem: T) => void, deleted: (oldItem: T) => void, compare?: Comparer): void; class ThrottledOperations { private readonly host; private pendingTimeouts; @@ -3857,13 +3875,12 @@ declare namespace ts.server { scheduleCollect(): void; private static run(self); } - function insertSorted(array: SortedArray, insert: T, compare: Comparer): void; - function removeSorted(array: SortedArray, remove: T, compare: Comparer): void; } declare namespace ts.server.protocol { - enum CommandTypes { + const enum CommandTypes { Brace = "brace", BraceCompletion = "braceCompletion", + GetSpanOfEnclosingComment = "getSpanOfEnclosingComment", Change = "change", Close = "close", Completions = "completions", @@ -3951,6 +3968,13 @@ declare namespace ts.server.protocol { interface TodoCommentsResponse extends Response { body?: TodoComment[]; } + interface SpanOfEnclosingCommentRequest extends FileLocationRequest { + command: CommandTypes.GetSpanOfEnclosingComment; + arguments: SpanOfEnclosingCommentRequestArgs; + } + interface SpanOfEnclosingCommentRequestArgs extends FileLocationRequestArgs { + onlyMultiLine: boolean; + } interface IndentationRequest extends FileLocationRequest { command: CommandTypes.Indentation; arguments: IndentationRequestArgs; @@ -4168,7 +4192,7 @@ declare namespace ts.server.protocol { } interface RenameResponseBody { info: RenameInfo; - locs: SpanGroup[]; + locs: ReadonlyArray; } interface RenameResponse extends Response { body?: RenameResponseBody; @@ -4248,6 +4272,7 @@ declare namespace ts.server.protocol { } interface SetCompilerOptionsForInferredProjectsArgs { options: ExternalProjectCompilerOptions; + projectRootPath?: string; } interface SetCompilerOptionsForInferredProjectsResponse extends Response { } @@ -4603,7 +4628,7 @@ declare namespace ts.server.protocol { interface NavTreeResponse extends Response { body?: NavigationTree; } - enum IndentStyle { + const enum IndentStyle { None = "None", Block = "Block", Smart = "Smart", @@ -4681,6 +4706,7 @@ declare namespace ts.server.protocol { paths?: MapLike; plugins?: PluginImport[]; preserveConstEnums?: boolean; + preserveSymlinks?: boolean; project?: string; reactNamespace?: string; removeComments?: boolean; @@ -4700,13 +4726,13 @@ declare namespace ts.server.protocol { typeRoots?: string[]; [option: string]: CompilerOptionsValue | undefined; } - enum JsxEmit { + const enum JsxEmit { None = "None", Preserve = "Preserve", ReactNative = "ReactNative", React = "React", } - enum ModuleKind { + const enum ModuleKind { None = "None", CommonJS = "CommonJS", AMD = "AMD", @@ -4714,20 +4740,24 @@ declare namespace ts.server.protocol { System = "System", ES6 = "ES6", ES2015 = "ES2015", + ESNext = "ESNext", } - enum ModuleResolutionKind { + const enum ModuleResolutionKind { Classic = "Classic", Node = "Node", } - enum NewLineKind { + const enum NewLineKind { Crlf = "Crlf", Lf = "Lf", } - enum ScriptTarget { + const enum ScriptTarget { ES3 = "ES3", ES5 = "ES5", ES6 = "ES6", ES2015 = "ES2015", + ES2016 = "ES2016", + ES2017 = "ES2017", + ESNext = "ESNext", } } declare namespace ts.server { @@ -4750,6 +4780,7 @@ declare namespace ts.server { host: ServerHost; cancellationToken: ServerCancellationToken; useSingleInferredProject: boolean; + useInferredProjectPerProjectRoot: boolean; typingsInstaller: ITypingsInstaller; byteLength: (buf: string, encoding?: string) => number; hrtime: (start?: number[]) => number[]; @@ -4757,8 +4788,8 @@ declare namespace ts.server { canUseEvents: boolean; eventHandler?: ProjectServiceEventHandler; throttleWaitMilliseconds?: number; - globalPlugins?: string[]; - pluginProbeLocations?: string[]; + globalPlugins?: ReadonlyArray; + pluginProbeLocations?: ReadonlyArray; allowLocalPluginLoads?: boolean; } class Session implements EventSender { @@ -4780,13 +4811,13 @@ declare namespace ts.server { private defaultEventHandler(event); logError(err: Error, cmd: string): void; send(msg: protocol.Message): void; - configFileDiagnosticEvent(triggerFile: string, configFile: string, diagnostics: Diagnostic[]): void; + configFileDiagnosticEvent(triggerFile: string, configFile: string, diagnostics: ReadonlyArray): void; event(info: T, eventName: string): void; output(info: any, cmdName: string, reqSeq?: number, errorMsg?: string): void; private semanticCheck(file, project); private syntacticCheck(file, project); - private updateProjectStructure(seq, matchSeq, ms?); - private updateErrorCheck(next, checkList, seq, matchSeq, ms?, followMs?, requireOpen?); + private updateProjectStructure(); + private updateErrorCheck(next, checkList, ms, requireOpen?); private cleanProjects(caption, projects); private cleanup(); private getEncodedSemanticClassifications(args); @@ -4820,6 +4851,7 @@ declare namespace ts.server { private getOutliningSpans(args); private getTodoComments(args); private getDocCommentTemplate(args); + private getSpanOfEnclosingComment(args); private getIndentation(args); private getBreakpointStatement(args); private getNameOrDottedNameSpan(args); @@ -4878,38 +4910,10 @@ declare namespace ts.server { } } declare namespace ts.server { - interface LineCollection { - charCount(): number; - lineCount(): number; - isLeaf(): this is LineLeaf; - walk(rangeStart: number, rangeLength: number, walkFns: ILineIndexWalker): void; - } interface AbsolutePositionAndLineText { absolutePosition: number; lineText: string | undefined; } - enum CharRangeSection { - PreStart = 0, - Start = 1, - Entire = 2, - Mid = 3, - End = 4, - PostEnd = 5, - } - interface ILineIndexWalker { - goSubtree: boolean; - done: boolean; - leaf(relativeStart: number, relativeLength: number, lineCollection: LineLeaf): void; - pre?(relativeStart: number, relativeLength: number, lineCollection: LineCollection, parent: LineNode, nodeType: CharRangeSection): void; - post?(relativeStart: number, relativeLength: number, lineCollection: LineCollection, parent: LineNode, nodeType: CharRangeSection): void; - } - class TextChange { - pos: number; - deleteLen: number; - insertedText: string; - constructor(pos: number, deleteLen: number, insertedText?: string); - getTextChangeRange(): TextChangeRange; - } class ScriptVersionCache { private changes; private readonly versions; @@ -4921,79 +4925,17 @@ declare namespace ts.server { private versionToIndex(version); private currentVersionToIndex(); edit(pos: number, deleteLen: number, insertedText?: string): void; - latest(): LineIndexSnapshot; - latestVersion(): number; reload(script: string): void; - getSnapshot(): LineIndexSnapshot; + getSnapshot(): IScriptSnapshot; + private _getSnapshot(); + getSnapshotVersion(): number; + getLineInfo(line: number): AbsolutePositionAndLineText; + lineOffsetToPosition(line: number, column: number): number; + positionToLineOffset(position: number): protocol.Location; + lineToTextSpan(line: number): TextSpan; getTextChangesBetweenVersions(oldVersion: number, newVersion: number): TextChangeRange; static fromString(script: string): ScriptVersionCache; } - class LineIndexSnapshot implements IScriptSnapshot { - readonly version: number; - readonly cache: ScriptVersionCache; - readonly index: LineIndex; - readonly changesSincePreviousVersion: ReadonlyArray; - constructor(version: number, cache: ScriptVersionCache, index: LineIndex, changesSincePreviousVersion?: ReadonlyArray); - getText(rangeStart: number, rangeEnd: number): string; - getLength(): number; - getChangeRange(oldSnapshot: IScriptSnapshot): TextChangeRange; - } - class LineIndex { - root: LineNode; - checkEdits: boolean; - absolutePositionOfStartOfLine(oneBasedLine: number): number; - positionToLineOffset(position: number): protocol.Location; - private positionToColumnAndLineText(position); - lineNumberToInfo(oneBasedLine: number): AbsolutePositionAndLineText; - load(lines: string[]): void; - walk(rangeStart: number, rangeLength: number, walkFns: ILineIndexWalker): void; - getText(rangeStart: number, rangeLength: number): string; - getLength(): number; - every(f: (ll: LineLeaf, s: number, len: number) => boolean, rangeStart: number, rangeEnd?: number): boolean; - edit(pos: number, deleteLength: number, newText?: string): LineIndex; - private static buildTreeFromBottom(nodes); - static linesFromText(text: string): { - lines: string[]; - lineMap: number[]; - }; - } - class LineNode implements LineCollection { - private readonly children; - totalChars: number; - totalLines: number; - constructor(children?: LineCollection[]); - isLeaf(): boolean; - updateCounts(): void; - private execWalk(rangeStart, rangeLength, walkFns, childIndex, nodeType); - private skipChild(relativeStart, relativeLength, childIndex, walkFns, nodeType); - walk(rangeStart: number, rangeLength: number, walkFns: ILineIndexWalker): void; - charOffsetToLineInfo(lineNumberAccumulator: number, relativePosition: number): { - oneBasedLine: number; - zeroBasedColumn: number; - lineText: string | undefined; - }; - lineNumberToInfo(relativeOneBasedLine: number, positionAccumulator: number): { - position: number; - leaf: LineLeaf | undefined; - }; - private childFromLineNumber(relativeOneBasedLine, positionAccumulator); - private childFromCharOffset(lineNumberAccumulator, relativePosition); - private splitAfter(childIndex); - remove(child: LineCollection): void; - private findChildIndex(child); - insertAt(child: LineCollection, nodes: LineCollection[]): LineNode[]; - add(collection: LineCollection): void; - charCount(): number; - lineCount(): number; - } - class LineLeaf implements LineCollection { - text: string; - constructor(text: string); - isLeaf(): boolean; - walk(rangeStart: number, rangeLength: number, walkFns: ILineIndexWalker): void; - charCount(): number; - lineCount(): number; - } } declare namespace ts.server { class ScriptInfo { @@ -5174,7 +5116,7 @@ declare namespace ts.server { private projectStructureVersion; private projectStateVersion; private typingFiles; - protected projectErrors: Diagnostic[]; + protected projectErrors: ReadonlyArray; typesVersion: number; isNonTsProject(): boolean; isJsOnlyProject(): boolean; @@ -5182,8 +5124,8 @@ declare namespace ts.server { static resolveModule(moduleName: string, initialDir: string, host: ServerHost, log: (message: string) => void): {}; constructor(projectName: string, projectKind: ProjectKind, projectService: ProjectService, documentRegistry: DocumentRegistry, hasExplicitListOfFiles: boolean, languageServiceEnabled: boolean, compilerOptions: CompilerOptions, compileOnSaveEnabled: boolean); private setInternalCompilerOptionsForEmittingJsFiles(); - getGlobalProjectErrors(): Diagnostic[]; - getAllProjectErrors(): Diagnostic[]; + getGlobalProjectErrors(): ReadonlyArray; + getAllProjectErrors(): ReadonlyArray; getLanguageService(ensureSynchronized?: boolean): LanguageService; getCompileOnSaveAffectedFileList(scriptInfo: ScriptInfo): string[]; getProjectVersion(): string; @@ -5203,6 +5145,7 @@ declare namespace ts.server { getRootScriptInfos(): ScriptInfo[]; getScriptInfos(): ScriptInfo[]; getFileEmitOutput(info: ScriptInfo, emitOnlyDtsFiles: boolean): EmitOutput; + getExcludedFiles(): ReadonlyArray; getFileNames(excludeFilesFromExternalLibraries?: boolean, excludeConfigFiles?: boolean): NormalizedPath[]; hasConfigFile(configFilePath: NormalizedPath): boolean; getAllEmittableFiles(): string[]; @@ -5228,12 +5171,13 @@ declare namespace ts.server { protected removeRoot(info: ScriptInfo): void; } class InferredProject extends Project { + readonly projectRootPath: string | undefined; private static readonly newName; private _isJsInferredProject; toggleJsInferredProject(isJsInferredProject: boolean): void; setCompilerOptions(options?: CompilerOptions): void; directoriesWatchedForTsconfig: string[]; - constructor(projectService: ProjectService, documentRegistry: DocumentRegistry, compilerOptions: CompilerOptions); + constructor(projectService: ProjectService, documentRegistry: DocumentRegistry, compilerOptions: CompilerOptions, projectRootPath?: string); addRoot(info: ScriptInfo): void; removeRoot(info: ScriptInfo): void; getProjectRootPath(): string; @@ -5257,7 +5201,7 @@ declare namespace ts.server { private enablePlugin(pluginConfigEntry, searchPaths); private enableProxy(pluginModuleFactory, configEntry); getProjectRootPath(): string; - setProjectErrors(projectErrors: Diagnostic[]): void; + setProjectErrors(projectErrors: ReadonlyArray): void; setTypeAcquisition(newTypeAcquisition: TypeAcquisition): void; getTypeAcquisition(): TypeAcquisition; getExternalFiles(): SortedReadonlyArray; @@ -5275,11 +5219,13 @@ declare namespace ts.server { externalProjectName: string; compileOnSaveEnabled: boolean; private readonly projectFilePath; + excludedFiles: ReadonlyArray; private typeAcquisition; constructor(externalProjectName: string, projectService: ProjectService, documentRegistry: DocumentRegistry, compilerOptions: CompilerOptions, languageServiceEnabled: boolean, compileOnSaveEnabled: boolean, projectFilePath?: string); + getExcludedFiles(): ReadonlyArray; getProjectRootPath(): string; getTypeAcquisition(): TypeAcquisition; - setProjectErrors(projectErrors: Diagnostic[]): void; + setProjectErrors(projectErrors: ReadonlyArray): void; setTypeAcquisition(newTypeAcquisition: TypeAcquisition): void; } } @@ -5301,7 +5247,7 @@ declare namespace ts.server { data: { triggerFile: string; configFileName: string; - diagnostics: Diagnostic[]; + diagnostics: ReadonlyArray; }; } interface ProjectLanguageServiceStateEvent { @@ -5353,11 +5299,15 @@ declare namespace ts.server { types?: string[]; }; } + interface TypesMapFile { + typesMap: SafeList; + simpleMap: string[]; + } function convertFormatOptions(protocolOptions: protocol.FormatCodeSettings): FormatCodeSettings; function convertCompilerOptions(protocolOptions: protocol.ExternalProjectCompilerOptions): CompilerOptions & protocol.CompileOnSaveMixin; function tryConvertScriptKindName(scriptKindName: protocol.ScriptKindName | ScriptKind): ScriptKind; function convertScriptKindName(scriptKindName: protocol.ScriptKindName): ScriptKind.Unknown | ScriptKind.JS | ScriptKind.JSX | ScriptKind.TS | ScriptKind.TSX; - function combineProjectOutput(projects: Project[], action: (project: Project) => T[], comparer?: (a: T, b: T) => number, areEqual?: (a: T, b: T) => boolean): T[]; + function combineProjectOutput(projects: ReadonlyArray, action: (project: Project) => ReadonlyArray, comparer?: (a: T, b: T) => number, areEqual?: (a: T, b: T) => boolean): T[]; interface HostConfiguration { formatCodeOptions: FormatCodeSettings; hostInfo: string; @@ -5365,19 +5315,21 @@ declare namespace ts.server { } interface OpenConfiguredProjectResult { configFileName?: NormalizedPath; - configFileErrors?: Diagnostic[]; + configFileErrors?: ReadonlyArray; } interface ProjectServiceOptions { host: ServerHost; logger: Logger; cancellationToken: HostCancellationToken; useSingleInferredProject: boolean; + useInferredProjectPerProjectRoot: boolean; typingsInstaller: ITypingsInstaller; eventHandler?: ProjectServiceEventHandler; throttleWaitMilliseconds?: number; - globalPlugins?: string[]; - pluginProbeLocations?: string[]; + globalPlugins?: ReadonlyArray; + pluginProbeLocations?: ReadonlyArray; allowLocalPluginLoads?: boolean; + typesMapLocation?: string; } class ProjectService { readonly typingsCache: TypingsCache; @@ -5389,7 +5341,7 @@ declare namespace ts.server { readonly configuredProjects: ConfiguredProject[]; readonly openFiles: ScriptInfo[]; private compilerOptionsForInferredProjects; - private compileOnSaveForInferredProjects; + private compilerOptionsForInferredProjectsPerProjectRoot; private readonly projectToSizeMap; private readonly directoryWatchers; private readonly throttledOperations; @@ -5402,19 +5354,22 @@ declare namespace ts.server { readonly logger: Logger; readonly cancellationToken: HostCancellationToken; readonly useSingleInferredProject: boolean; + readonly useInferredProjectPerProjectRoot: boolean; readonly typingsInstaller: ITypingsInstaller; readonly throttleWaitMilliseconds?: number; private readonly eventHandler?; readonly globalPlugins: ReadonlyArray; readonly pluginProbeLocations: ReadonlyArray; readonly allowLocalPluginLoads: boolean; + readonly typesMapLocation: string | undefined; private readonly seenProjects; constructor(opts: ProjectServiceOptions); ensureInferredProjectsUpToDate_TestOnly(): void; getCompilerOptionsForInferredProjects(): CompilerOptions; onUpdateLanguageServiceStateForProject(project: Project, languageServiceEnabled: boolean): void; + private loadTypesMap(); updateTypingsForProject(response: SetTypings | InvalidateCachedTypings): void; - setCompilerOptionsForInferredProjects(projectCompilerOptions: protocol.ExternalProjectCompilerOptions): void; + setCompilerOptionsForInferredProjects(projectCompilerOptions: protocol.ExternalProjectCompilerOptions, projectRootPath?: string): void; stopWatchingDirectory(directory: string): void; findProject(projectName: string): Project; getDefaultProjectForFile(fileName: NormalizedPath, refreshInferredProjects: boolean): Project; @@ -5431,7 +5386,7 @@ declare namespace ts.server { private onConfigFileAddedForInferredProject(fileName); private getCanonicalFileName(fileName); private removeProject(project); - private assignScriptInfoToInferredProjectIfNecessary(info, addToListOfOpenFiles); + private assignScriptInfoToInferredProjectIfNecessary(info, addToListOfOpenFiles, projectRootPath?); private closeOpenFile(info); private deleteOrphanScriptInfoNotInAnyProject(); private openOrUpdateConfiguredProjectForFile(fileName, projectRootPath?); @@ -5450,7 +5405,10 @@ declare namespace ts.server { private openConfigFile(configFileName, clientFileName?); private updateNonInferredProject(project, newUncheckedFiles, propertyReader, newOptions, newTypeAcquisition, compileOnSave, configFileErrors); private updateConfiguredProject(project); - createInferredProjectWithRootFileIfNecessary(root: ScriptInfo): InferredProject; + private getOrCreateInferredProjectForProjectRootPathIfEnabled(root, projectRootPath); + private getOrCreateSingleInferredProjectIfEnabled(); + private createInferredProject(isSingleInferredProject?, projectRootPath?); + createInferredProjectWithRootFileIfNecessary(root: ScriptInfo, projectRootPath?: string): InferredProject; getOrCreateScriptInfo(uncheckedFileName: string, openedByClient: boolean, fileContent?: string, scriptKind?: ScriptKind): ScriptInfo; getScriptInfo(uncheckedFileName: string): ScriptInfo; watchClosedScriptInfo(info: ScriptInfo): void; @@ -5471,8 +5429,7 @@ declare namespace ts.server { private static readonly filenameEscapeRegexp; private static escapeFilenameForRegex(filename); resetSafeList(): void; - loadSafeList(fileName: string): void; - applySafeList(proj: protocol.ExternalProject): void; + applySafeList(proj: protocol.ExternalProject): NormalizedPath[]; openExternalProject(proj: protocol.ExternalProject, suppressRefreshOfInferredProjects?: boolean): void; } } diff --git a/lib/tsserverlibrary.js b/lib/tsserverlibrary.js index 07c0852235d..263796daa7a 100644 --- a/lib/tsserverlibrary.js +++ b/lib/tsserverlibrary.js @@ -508,11 +508,11 @@ var ts; TypeFormatFlags[TypeFormatFlags["UseFullyQualifiedType"] = 256] = "UseFullyQualifiedType"; TypeFormatFlags[TypeFormatFlags["InFirstTypeArgument"] = 512] = "InFirstTypeArgument"; TypeFormatFlags[TypeFormatFlags["InTypeAlias"] = 1024] = "InTypeAlias"; - TypeFormatFlags[TypeFormatFlags["UseTypeAliasValue"] = 2048] = "UseTypeAliasValue"; TypeFormatFlags[TypeFormatFlags["SuppressAnyReturnType"] = 4096] = "SuppressAnyReturnType"; TypeFormatFlags[TypeFormatFlags["AddUndefined"] = 8192] = "AddUndefined"; TypeFormatFlags[TypeFormatFlags["WriteClassExpressionAsTypeLiteral"] = 16384] = "WriteClassExpressionAsTypeLiteral"; TypeFormatFlags[TypeFormatFlags["InArrayType"] = 32768] = "InArrayType"; + TypeFormatFlags[TypeFormatFlags["UseAliasDefinedOutsideCurrentScope"] = 65536] = "UseAliasDefinedOutsideCurrentScope"; })(TypeFormatFlags = ts.TypeFormatFlags || (ts.TypeFormatFlags = {})); var SymbolFormatFlags; (function (SymbolFormatFlags) { @@ -759,6 +759,12 @@ var ts; InferenceFlags[InferenceFlags["NoDefault"] = 2] = "NoDefault"; InferenceFlags[InferenceFlags["AnyDefault"] = 4] = "AnyDefault"; })(InferenceFlags = ts.InferenceFlags || (ts.InferenceFlags = {})); + var Ternary; + (function (Ternary) { + Ternary[Ternary["False"] = 0] = "False"; + Ternary[Ternary["Maybe"] = 1] = "Maybe"; + Ternary[Ternary["True"] = -1] = "True"; + })(Ternary = ts.Ternary || (ts.Ternary = {})); var SpecialPropertyAssignmentKind; (function (SpecialPropertyAssignmentKind) { SpecialPropertyAssignmentKind[SpecialPropertyAssignmentKind["None"] = 0] = "None"; @@ -1155,16 +1161,10 @@ var ts; })(ts || (ts = {})); var ts; (function (ts) { - ts.versionMajorMinor = "2.5"; + ts.versionMajorMinor = "2.6"; ts.version = ts.versionMajorMinor + ".0"; })(ts || (ts = {})); (function (ts) { - var Ternary; - (function (Ternary) { - Ternary[Ternary["False"] = 0] = "False"; - Ternary[Ternary["Maybe"] = 1] = "Maybe"; - Ternary[Ternary["True"] = -1] = "True"; - })(Ternary = ts.Ternary || (ts.Ternary = {})); ts.collator = typeof Intl === "object" && typeof Intl.Collator === "function" ? new Intl.Collator(undefined, { usage: "sort", sensitivity: "accent" }) : undefined; ts.localeCompareIsCorrect = ts.collator && ts.collator.compare("a", "B") < 0; function createDictionaryObject() { @@ -1452,10 +1452,9 @@ var ts; ts.removeWhere = removeWhere; function filterMutate(array, f) { var outIndex = 0; - for (var _i = 0, array_3 = array; _i < array_3.length; _i++) { - var item = array_3[_i]; - if (f(item)) { - array[outIndex] = item; + for (var i = 0; i < array.length; i++) { + if (f(array[i], i, array)) { + array[outIndex] = array[i]; outIndex++; } } @@ -1501,8 +1500,8 @@ var ts; var result; if (array) { result = []; - for (var _i = 0, array_4 = array; _i < array_4.length; _i++) { - var v = array_4[_i]; + for (var _i = 0, array_3 = array; _i < array_3.length; _i++) { + var v = array_3[_i]; if (v) { if (isArray(v)) { addRange(result, v); @@ -1572,11 +1571,13 @@ var ts; ts.sameFlatMap = sameFlatMap; function mapDefined(array, mapFn) { var result = []; - for (var i = 0; i < array.length; i++) { - var item = array[i]; - var mapped = mapFn(item, i); - if (mapped !== undefined) { - result.push(mapped); + if (array) { + for (var i = 0; i < array.length; i++) { + var item = array[i]; + var mapped = mapFn(item, i); + if (mapped !== undefined) { + result.push(mapped); + } } } return result; @@ -1644,8 +1645,8 @@ var ts; function some(array, predicate) { if (array) { if (predicate) { - for (var _i = 0, array_5 = array; _i < array_5.length; _i++) { - var v = array_5[_i]; + for (var _i = 0, array_4 = array; _i < array_4.length; _i++) { + var v = array_4[_i]; if (predicate(v)) { return true; } @@ -1670,8 +1671,8 @@ var ts; var result; if (array) { result = []; - loop: for (var _i = 0, array_6 = array; _i < array_6.length; _i++) { - var item = array_6[_i]; + loop: for (var _i = 0, array_5 = array; _i < array_5.length; _i++) { + var item = array_5[_i]; for (var _a = 0, result_1 = result; _a < result_1.length; _a++) { var res = result_1[_a]; if (areEqual ? areEqual(res, item) : res === item) { @@ -1759,8 +1760,8 @@ var ts; ts.relativeComplement = relativeComplement; function sum(array, prop) { var result = 0; - for (var _i = 0, array_7 = array; _i < array_7.length; _i++) { - var v = array_7[_i]; + for (var _i = 0, array_6 = array; _i < array_6.length; _i++) { + var v = array_6[_i]; result += v[prop]; } return result; @@ -2020,8 +2021,8 @@ var ts; ts.equalOwnProperties = equalOwnProperties; function arrayToMap(array, makeKey, makeValue) { var result = createMap(); - for (var _i = 0, array_8 = array; _i < array_8.length; _i++) { - var value = array_8[_i]; + for (var _i = 0, array_7 = array; _i < array_7.length; _i++) { + var value = array_7[_i]; result.set(makeKey(value), makeValue ? makeValue(value) : value); } return result; @@ -2181,11 +2182,11 @@ var ts; ts.getLocaleSpecificMessage = getLocaleSpecificMessage; function createFileDiagnostic(file, start, length, message) { var end = start + length; - Debug.assert(start >= 0, "start must be non-negative, is " + start); - Debug.assert(length >= 0, "length must be non-negative, is " + length); + Debug.assertGreaterThanOrEqual(start, 0); + Debug.assertGreaterThanOrEqual(length, 0); if (file) { - Debug.assert(start <= file.text.length, "start must be within the bounds of the file. " + start + " > " + file.text.length); - Debug.assert(end <= file.text.length, "end must be the bounds of the file. " + end + " > " + file.text.length); + Debug.assertLessThanOrEqual(start, file.text.length); + Debug.assertLessThanOrEqual(end, file.text.length); } var text = getLocaleSpecificMessage(message); if (arguments.length > 4) { @@ -2394,19 +2395,23 @@ var ts; return normalized; } function normalizePath(path) { + return normalizePathAndParts(path).path; + } + ts.normalizePath = normalizePath; + function normalizePathAndParts(path) { path = normalizeSlashes(path); var rootLength = getRootLength(path); var root = path.substr(0, rootLength); - var normalized = getNormalizedParts(path, rootLength); - if (normalized.length) { - var joinedParts = root + normalized.join(ts.directorySeparator); - return pathEndsWithDirectorySeparator(path) ? joinedParts + ts.directorySeparator : joinedParts; + var parts = getNormalizedParts(path, rootLength); + if (parts.length) { + var joinedParts = root + parts.join(ts.directorySeparator); + return { path: pathEndsWithDirectorySeparator(path) ? joinedParts + ts.directorySeparator : joinedParts, parts: parts }; } else { - return root; + return { path: root, parts: parts }; } } - ts.normalizePath = normalizePath; + ts.normalizePathAndParts = normalizePathAndParts; function pathEndsWithDirectorySeparator(path) { return path.charCodeAt(path.length - 1) === directorySeparatorCharCode; } @@ -2669,8 +2674,28 @@ var ts; ts.fileExtensionIsOneOf = fileExtensionIsOneOf; var reservedCharacterPattern = /[^\w\s\/]/g; var wildcardCharCodes = [42, 63]; - var singleAsteriskRegexFragmentFiles = "([^./]|(\\.(?!min\\.js$))?)*"; - var singleAsteriskRegexFragmentOther = "[^/]*"; + ts.commonPackageFolders = ["node_modules", "bower_components", "jspm_packages"]; + var implicitExcludePathRegexPattern = "(?!(" + ts.commonPackageFolders.join("|") + ")(/|$))"; + var filesMatcher = { + singleAsteriskRegexFragment: "([^./]|(\\.(?!min\\.js$))?)*", + doubleAsteriskRegexFragment: "(/" + implicitExcludePathRegexPattern + "[^/.][^/]*)*?", + replaceWildcardCharacter: function (match) { return replaceWildcardCharacter(match, filesMatcher.singleAsteriskRegexFragment); } + }; + var directoriesMatcher = { + singleAsteriskRegexFragment: "[^/]*", + doubleAsteriskRegexFragment: "(/" + implicitExcludePathRegexPattern + "[^/.][^/]*)*?", + replaceWildcardCharacter: function (match) { return replaceWildcardCharacter(match, directoriesMatcher.singleAsteriskRegexFragment); } + }; + var excludeMatcher = { + singleAsteriskRegexFragment: "[^/]*", + doubleAsteriskRegexFragment: "(/.+?)?", + replaceWildcardCharacter: function (match) { return replaceWildcardCharacter(match, excludeMatcher.singleAsteriskRegexFragment); } + }; + var wildcardMatchers = { + files: filesMatcher, + directories: directoriesMatcher, + exclude: excludeMatcher + }; function getRegularExpressionForWildcard(specs, basePath, usage) { var patterns = getRegularExpressionsForWildcards(specs, basePath, usage); if (!patterns || !patterns.length) { @@ -2685,18 +2710,16 @@ var ts; if (specs === undefined || specs.length === 0) { return undefined; } - var replaceWildcardCharacter = usage === "files" ? replaceWildCardCharacterFiles : replaceWildCardCharacterOther; - var singleAsteriskRegexFragment = usage === "files" ? singleAsteriskRegexFragmentFiles : singleAsteriskRegexFragmentOther; - var doubleAsteriskRegexFragment = usage === "exclude" ? "(/.+?)?" : "(/[^/.][^/]*)*?"; return flatMap(specs, function (spec) { - return spec && getSubPatternFromSpec(spec, basePath, usage, singleAsteriskRegexFragment, doubleAsteriskRegexFragment, replaceWildcardCharacter); + return spec && getSubPatternFromSpec(spec, basePath, usage, wildcardMatchers[usage]); }); } function isImplicitGlob(lastPathComponent) { return !/[.*?]/.test(lastPathComponent); } ts.isImplicitGlob = isImplicitGlob; - function getSubPatternFromSpec(spec, basePath, usage, singleAsteriskRegexFragment, doubleAsteriskRegexFragment, replaceWildcardCharacter) { + function getSubPatternFromSpec(spec, basePath, usage, _a) { + var singleAsteriskRegexFragment = _a.singleAsteriskRegexFragment, doubleAsteriskRegexFragment = _a.doubleAsteriskRegexFragment, replaceWildcardCharacter = _a.replaceWildcardCharacter; var subpattern = ""; var hasRecursiveDirectoryWildcard = false; var hasWrittenComponent = false; @@ -2728,16 +2751,24 @@ var ts; subpattern += ts.directorySeparator; } if (usage !== "exclude") { + var componentPattern = ""; if (component.charCodeAt(0) === 42) { - subpattern += "([^./]" + singleAsteriskRegexFragment + ")?"; + componentPattern += "([^./]" + singleAsteriskRegexFragment + ")?"; component = component.substr(1); } else if (component.charCodeAt(0) === 63) { - subpattern += "[^./]"; + componentPattern += "[^./]"; component = component.substr(1); } + componentPattern += component.replace(reservedCharacterPattern, replaceWildcardCharacter); + if (componentPattern !== component) { + subpattern += implicitExcludePathRegexPattern; + } + subpattern += componentPattern; + } + else { + subpattern += component.replace(reservedCharacterPattern, replaceWildcardCharacter); } - subpattern += component.replace(reservedCharacterPattern, replaceWildcardCharacter); } hasWrittenComponent = true; } @@ -2747,12 +2778,6 @@ var ts; } return subpattern; } - function replaceWildCardCharacterFiles(match) { - return replaceWildcardCharacter(match, singleAsteriskRegexFragmentFiles); - } - function replaceWildCardCharacterOther(match) { - return replaceWildcardCharacter(match, singleAsteriskRegexFragmentOther); - } function replaceWildcardCharacter(match, singleAsteriskRegexFragment) { return match === "*" ? singleAsteriskRegexFragment : match === "?" ? "[^/]" : "\\" + match; } @@ -2788,19 +2813,19 @@ var ts; var _a = getFileSystemEntries(path), files = _a.files, directories = _a.directories; files = files.slice().sort(comparer); var _loop_1 = function (current) { - var name = combinePaths(path, current); + var name_1 = combinePaths(path, current); var absoluteName = combinePaths(absolutePath, current); - if (extensions && !fileExtensionIsOneOf(name, extensions)) + if (extensions && !fileExtensionIsOneOf(name_1, extensions)) return "continue"; if (excludeRegex && excludeRegex.test(absoluteName)) return "continue"; if (!includeFileRegexes) { - results[0].push(name); + results[0].push(name_1); } else { var includeIndex = findIndex(includeFileRegexes, function (re) { return re.test(absoluteName); }); if (includeIndex !== -1) { - results[includeIndex].push(name); + results[includeIndex].push(name_1); } } }; @@ -2817,11 +2842,11 @@ var ts; directories = directories.slice().sort(comparer); for (var _b = 0, directories_1 = directories; _b < directories_1.length; _b++) { var current = directories_1[_b]; - var name = combinePaths(path, current); + var name_2 = combinePaths(path, current); var absoluteName = combinePaths(absolutePath, current); if ((!includeDirectoryRegex || includeDirectoryRegex.test(absoluteName)) && (!excludeRegex || !excludeRegex.test(absoluteName))) { - visitDirectory(name, absoluteName, depth); + visitDirectory(name_2, absoluteName, depth); } } } @@ -2889,14 +2914,7 @@ var ts; if (!extraFileExtensions || extraFileExtensions.length === 0 || !needAllExtensions) { return needAllExtensions ? allSupportedExtensions : ts.supportedTypeScriptExtensions; } - var extensions = allSupportedExtensions.slice(0); - for (var _i = 0, extraFileExtensions_1 = extraFileExtensions; _i < extraFileExtensions_1.length; _i++) { - var extInfo = extraFileExtensions_1[_i]; - if (extensions.indexOf(extInfo.extension) === -1) { - extensions.push(extInfo.extension); - } - } - return extensions; + return deduplicate(allSupportedExtensions.concat(extraFileExtensions.map(function (e) { return e.extension; }))); } ts.getSupportedExtensions = getSupportedExtensions; function hasJavaScriptFileExtension(fileName) { @@ -3038,12 +3056,37 @@ var ts; function assert(expression, message, verboseDebugInfo, stackCrawlMark) { if (!expression) { if (verboseDebugInfo) { - message += "\r\nVerbose Debug Information: " + verboseDebugInfo(); + message += "\r\nVerbose Debug Information: " + (typeof verboseDebugInfo === "string" ? verboseDebugInfo : verboseDebugInfo()); } fail(message ? "False expression: " + message : "False expression.", stackCrawlMark || assert); } } Debug.assert = assert; + function assertEqual(a, b, msg, msg2) { + if (a !== b) { + var message = msg ? msg2 ? msg + " " + msg2 : msg : ""; + fail("Expected " + a + " === " + b + ". " + message); + } + } + Debug.assertEqual = assertEqual; + function assertLessThan(a, b, msg) { + if (a >= b) { + fail("Expected " + a + " < " + b + ". " + (msg || "")); + } + } + Debug.assertLessThan = assertLessThan; + function assertLessThanOrEqual(a, b) { + if (a > b) { + fail("Expected " + a + " <= " + b); + } + } + Debug.assertLessThanOrEqual = assertLessThanOrEqual; + function assertGreaterThanOrEqual(a, b) { + if (a < b) { + fail("Expected " + a + " >= " + b); + } + } + Debug.assertGreaterThanOrEqual = assertGreaterThanOrEqual; function fail(message, stackCrawlMark) { debugger; var e = new Error(message ? "Debug Failure. " + message : "Debug Failure."); @@ -3178,6 +3221,10 @@ var ts; Debug.fail("File " + path + " has unknown extension."); } ts.extensionFromPath = extensionFromPath; + function isAnySupportedFileExtension(path) { + return tryGetExtensionFromPath(path) !== undefined; + } + ts.isAnySupportedFileExtension = isAnySupportedFileExtension; function tryGetExtensionFromPath(path) { return find(ts.supportedTypescriptExtensionsForExtractExtension, function (e) { return fileExtensionIs(path, e); }) || find(ts.supportedJavascriptExtensions, function (e) { return fileExtensionIs(path, e); }); } @@ -3189,6 +3236,12 @@ var ts; })(ts || (ts = {})); var ts; (function (ts) { + function setStackTraceLimit() { + if (Error.stackTraceLimit < 100) { + Error.stackTraceLimit = 100; + } + } + ts.setStackTraceLimit = setStackTraceLimit; var FileWatcherEventKind; (function (FileWatcherEventKind) { FileWatcherEventKind[FileWatcherEventKind["Created"] = 0] = "Created"; @@ -3238,7 +3291,7 @@ var ts; watcher.referenceCount += 1; return; } - watcher = _fs.watch(dirPath, { persistent: true }, function (eventName, relativeFileName) { return fileEventHandler(eventName, relativeFileName, dirPath); }); + watcher = _fs.watch(dirPath || ".", { persistent: true }, function (eventName, relativeFileName) { return fileEventHandler(eventName, relativeFileName, dirPath); }); watcher.referenceCount = 1; dirWatchers.set(dirPath, watcher); return; @@ -3338,10 +3391,10 @@ var ts; if (entry === "." || entry === "..") { continue; } - var name = ts.combinePaths(path, entry); + var name_3 = ts.combinePaths(path, entry); var stat = void 0; try { - stat = _fs.statSync(name); + stat = _fs.statSync(name_3); } catch (e) { continue; @@ -4064,6 +4117,8 @@ var ts; Expected_at_least_0_arguments_but_got_a_minimum_of_1: diag(2557, ts.DiagnosticCategory.Error, "Expected_at_least_0_arguments_but_got_a_minimum_of_1_2557", "Expected at least {0} arguments, but got a minimum of {1}."), Expected_0_type_arguments_but_got_1: diag(2558, ts.DiagnosticCategory.Error, "Expected_0_type_arguments_but_got_1_2558", "Expected {0} type arguments, but got {1}."), Type_0_has_no_properties_in_common_with_type_1: diag(2559, ts.DiagnosticCategory.Error, "Type_0_has_no_properties_in_common_with_type_1_2559", "Type '{0}' has no properties in common with type '{1}'."), + Value_of_type_0_has_no_properties_in_common_with_type_1_Did_you_mean_to_call_it: diag(2560, ts.DiagnosticCategory.Error, "Value_of_type_0_has_no_properties_in_common_with_type_1_Did_you_mean_to_call_it_2560", "Value of type '{0}' has no properties in common with type '{1}'. Did you mean to call it?"), + Base_class_expressions_cannot_reference_class_type_parameters: diag(2561, ts.DiagnosticCategory.Error, "Base_class_expressions_cannot_reference_class_type_parameters_2561", "Base class expressions cannot reference class type parameters."), JSX_element_attributes_type_0_may_not_be_a_union_type: diag(2600, ts.DiagnosticCategory.Error, "JSX_element_attributes_type_0_may_not_be_a_union_type_2600", "JSX element attributes type '{0}' may not be a union type."), The_return_type_of_a_JSX_element_constructor_must_return_an_object_type: diag(2601, ts.DiagnosticCategory.Error, "The_return_type_of_a_JSX_element_constructor_must_return_an_object_type_2601", "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: diag(2602, ts.DiagnosticCategory.Error, "JSX_element_implicitly_has_type_any_because_the_global_type_JSX_Element_does_not_exist_2602", "JSX element implicitly has type 'any' because the global type 'JSX.Element' does not exist."), @@ -4251,6 +4306,7 @@ var ts; Do_not_emit_outputs: diag(6010, ts.DiagnosticCategory.Message, "Do_not_emit_outputs_6010", "Do not emit outputs."), Allow_default_imports_from_modules_with_no_default_export_This_does_not_affect_code_emit_just_typechecking: diag(6011, ts.DiagnosticCategory.Message, "Allow_default_imports_from_modules_with_no_default_export_This_does_not_affect_code_emit_just_typech_6011", "Allow default imports from modules with no default export. This does not affect code emit, just typechecking."), Skip_type_checking_of_declaration_files: diag(6012, ts.DiagnosticCategory.Message, "Skip_type_checking_of_declaration_files_6012", "Skip type checking of declaration files."), + Do_not_resolve_the_real_path_of_symlinks: diag(6013, ts.DiagnosticCategory.Message, "Do_not_resolve_the_real_path_of_symlinks_6013", "Do not resolve the real path of symlinks."), Specify_ECMAScript_target_version_Colon_ES3_default_ES5_ES2015_ES2016_ES2017_or_ESNEXT: diag(6015, ts.DiagnosticCategory.Message, "Specify_ECMAScript_target_version_Colon_ES3_default_ES5_ES2015_ES2016_ES2017_or_ESNEXT_6015", "Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', or 'ESNEXT'."), Specify_module_code_generation_Colon_none_commonjs_amd_system_umd_es2015_or_ESNext: diag(6016, ts.DiagnosticCategory.Message, "Specify_module_code_generation_Colon_none_commonjs_amd_system_umd_es2015_or_ESNext_6016", "Specify module code generation: 'none', commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'."), Print_this_message: diag(6017, ts.DiagnosticCategory.Message, "Print_this_message_6017", "Print this message."), @@ -4504,6 +4560,8 @@ var ts; Rewrite_as_the_indexed_access_type_0: diag(90026, ts.DiagnosticCategory.Message, "Rewrite_as_the_indexed_access_type_0_90026", "Rewrite as the indexed access type '{0}'."), Convert_function_to_an_ES2015_class: diag(95001, ts.DiagnosticCategory.Message, "Convert_function_to_an_ES2015_class_95001", "Convert function to an ES2015 class"), Convert_function_0_to_class: diag(95002, ts.DiagnosticCategory.Message, "Convert_function_0_to_class_95002", "Convert function '{0}' to class"), + Extract_function: diag(95003, ts.DiagnosticCategory.Message, "Extract_function_95003", "Extract function"), + Extract_function_into_0: diag(95004, ts.DiagnosticCategory.Message, "Extract_function_into_0_95004", "Extract function into '{0}'"), }; })(ts || (ts = {})); var ts; @@ -4524,19 +4582,6 @@ var ts; return undefined; } ts.getDeclarationOfKind = getDeclarationOfKind; - function findDeclaration(symbol, predicate) { - var declarations = symbol.declarations; - if (declarations) { - for (var _i = 0, declarations_2 = declarations; _i < declarations_2.length; _i++) { - var declaration = declarations_2[_i]; - if (predicate(declaration)) { - return declaration; - } - } - } - return undefined; - } - ts.findDeclaration = findDeclaration; var stringWriter = createSingleLineStringWriter(); var stringWriterAcquired = false; function createSingleLineStringWriter() { @@ -4599,9 +4644,13 @@ var ts; function moduleResolutionIsEqualTo(oldResolution, newResolution) { return oldResolution.isExternalLibraryImport === newResolution.isExternalLibraryImport && oldResolution.extension === newResolution.extension && - oldResolution.resolvedFileName === newResolution.resolvedFileName; + oldResolution.resolvedFileName === newResolution.resolvedFileName && + packageIdIsEqual(oldResolution.packageId, newResolution.packageId); } ts.moduleResolutionIsEqualTo = moduleResolutionIsEqualTo; + function packageIdIsEqual(a, b) { + return a === b || a && b && a.name === b.name && a.version === b.version; + } function typeDirectiveIsEqualTo(oldResolution, newResolution) { return oldResolution.resolvedFileName === newResolution.resolvedFileName && oldResolution.primary === newResolution.primary; } @@ -4666,14 +4715,6 @@ var ts; return file.fileName + "(" + (loc.line + 1) + "," + (loc.character + 1) + ")"; } ts.nodePosToString = nodePosToString; - function getStartPosOfNode(node) { - return node.pos; - } - ts.getStartPosOfNode = getStartPosOfNode; - function isDefined(value) { - return value !== undefined; - } - ts.isDefined = isDefined; function getEndLinePosition(line, sourceFile) { ts.Debug.assert(line >= 0); var lineStarts = ts.getLineStarts(sourceFile); @@ -4704,6 +4745,25 @@ var ts; return !nodeIsMissing(node); } ts.nodeIsPresent = nodeIsPresent; + function isRecognizedTripleSlashComment(text, commentPos, commentEnd) { + if (text.charCodeAt(commentPos + 1) === 47 && + commentPos + 2 < commentEnd && + text.charCodeAt(commentPos + 2) === 47) { + var textSubStr = text.substring(commentPos, commentEnd); + return textSubStr.match(ts.fullTripleSlashReferencePathRegEx) || + textSubStr.match(ts.fullTripleSlashAMDReferencePathRegEx) || + textSubStr.match(fullTripleSlashReferenceTypeReferenceDirectiveRegEx) || + textSubStr.match(defaultLibReferenceRegEx) ? + true : false; + } + return false; + } + ts.isRecognizedTripleSlashComment = isRecognizedTripleSlashComment; + function isPinnedComment(text, comment) { + return text.charCodeAt(comment.pos + 1) === 42 && + text.charCodeAt(comment.pos + 2) === 33; + } + ts.isPinnedComment = isPinnedComment; function getTokenPosOfNode(node, sourceFile, includeJsDoc) { if (nodeIsMissing(node)) { return node.pos; @@ -4760,15 +4820,20 @@ var ts; var escapeText = getEmitFlags(node) & 16777216 ? escapeString : escapeNonAsciiString; switch (node.kind) { case 9: - return '"' + escapeText(node.text) + '"'; + if (node.singleQuote) { + return "'" + escapeText(node.text, 39) + "'"; + } + else { + return '"' + escapeText(node.text, 34) + '"'; + } case 13: - return "`" + escapeText(node.text) + "`"; + return "`" + escapeText(node.text, 96) + "`"; case 14: - return "`" + escapeText(node.text) + "${"; + return "`" + escapeText(node.text, 96) + "${"; case 15: - return "}" + escapeText(node.text) + "${"; + return "}" + escapeText(node.text, 96) + "${"; case 16: - return "}" + escapeText(node.text) + "`"; + return "}" + escapeText(node.text, 96) + "`"; case 8: return node.text; } @@ -5020,13 +5085,9 @@ var ts; } ts.isPrologueDirective = isPrologueDirective; function getLeadingCommentRangesOfNode(node, sourceFileOfNode) { - return ts.getLeadingCommentRanges(sourceFileOfNode.text, node.pos); + return node.kind !== 10 ? ts.getLeadingCommentRanges(sourceFileOfNode.text, node.pos) : undefined; } ts.getLeadingCommentRangesOfNode = getLeadingCommentRangesOfNode; - function getLeadingCommentRangesOfNodeFromText(node, text) { - return ts.getLeadingCommentRanges(text, node.pos); - } - ts.getLeadingCommentRangesOfNodeFromText = getLeadingCommentRangesOfNodeFromText; function getJSDocCommentRanges(node, text) { var commentRanges = (node.kind === 146 || node.kind === 145 || @@ -5034,7 +5095,7 @@ var ts; node.kind === 187 || node.kind === 185) ? ts.concatenate(ts.getTrailingCommentRanges(text, node.pos), ts.getLeadingCommentRanges(text, node.pos)) : - getLeadingCommentRangesOfNodeFromText(node, text); + ts.getLeadingCommentRanges(text, node.pos); return ts.filter(commentRanges, function (comment) { return text.charCodeAt(comment.pos + 1) === 42 && text.charCodeAt(comment.pos + 2) === 42 && @@ -5043,8 +5104,9 @@ var ts; } ts.getJSDocCommentRanges = getJSDocCommentRanges; ts.fullTripleSlashReferencePathRegEx = /^(\/\/\/\s*/; - ts.fullTripleSlashReferenceTypeReferenceDirectiveRegEx = /^(\/\/\/\s*/; + var fullTripleSlashReferenceTypeReferenceDirectiveRegEx = /^(\/\/\/\s*/; ts.fullTripleSlashAMDReferencePathRegEx = /^(\/\/\/\s*/; + var defaultLibReferenceRegEx = /^(\/\/\/\s*/; function isPartOfTypeNode(node) { if (158 <= node.kind && node.kind <= 173) { return true; @@ -5073,23 +5135,23 @@ var ts; case 143: case 179: case 99: - var parent = node.parent; - if (parent.kind === 162) { + var parent_1 = node.parent; + if (parent_1.kind === 162) { return false; } - if (158 <= parent.kind && parent.kind <= 173) { + if (158 <= parent_1.kind && parent_1.kind <= 173) { return true; } - switch (parent.kind) { + switch (parent_1.kind) { case 201: - return !isExpressionWithTypeArgumentsInClassExtendsClause(parent); + return !isExpressionWithTypeArgumentsInClassExtendsClause(parent_1); case 145: - return node === parent.constraint; + return node === parent_1.constraint; case 149: case 148: case 146: case 226: - return node === parent.type; + return node === parent_1.type; case 228: case 186: case 187: @@ -5098,16 +5160,16 @@ var ts; case 150: case 153: case 154: - return node === parent.type; + return node === parent_1.type; case 155: case 156: case 157: - return node === parent.type; + return node === parent_1.type; case 184: - return node === parent.type; + return node === parent_1.type; case 181: case 182: - return parent.typeArguments && ts.indexOf(parent.typeArguments, node) >= 0; + return parent_1.typeArguments && ts.indexOf(parent_1.typeArguments, node) >= 0; case 183: return false; } @@ -5171,9 +5233,9 @@ var ts; return; default: if (ts.isFunctionLike(node)) { - var name = node.name; - if (name && name.kind === 144) { - traverse(name.expression); + var name_4 = node.name; + if (name_4 && name_4.kind === 144) { + traverse(name_4.expression); return; } } @@ -5271,21 +5333,11 @@ var ts; } ts.getPropertyAssignment = getPropertyAssignment; function getContainingFunction(node) { - while (true) { - node = node.parent; - if (!node || ts.isFunctionLike(node)) { - return node; - } - } + return ts.findAncestor(node.parent, ts.isFunctionLike); } ts.getContainingFunction = getContainingFunction; function getContainingClass(node) { - while (true) { - node = node.parent; - if (!node || ts.isClassLike(node)) { - return node; - } - } + return ts.findAncestor(node.parent, ts.isClassLike); } ts.getContainingClass = getContainingClass; function getThisContainer(node, includeArrowFunctions) { @@ -5385,13 +5437,13 @@ var ts; function getImmediatelyInvokedFunctionExpression(func) { if (func.kind === 186 || func.kind === 187) { var prev = func; - var parent = func.parent; - while (parent.kind === 185) { - prev = parent; - parent = parent.parent; + var parent_2 = func.parent; + while (parent_2.kind === 185) { + prev = parent_2; + parent_2 = parent_2.parent; } - if (parent.kind === 181 && parent.expression === prev) { - return parent; + if (parent_2.kind === 181 && parent_2.expression === prev) { + return parent_2; } } } @@ -5527,8 +5579,8 @@ var ts; case 8: case 9: case 99: - var parent = node.parent; - switch (parent.kind) { + var parent_3 = node.parent; + switch (parent_3.kind) { case 226: case 146: case 149: @@ -5536,7 +5588,7 @@ var ts; case 264: case 261: case 176: - return parent.initializer === node; + return parent_3.initializer === node; case 210: case 211: case 212: @@ -5546,33 +5598,33 @@ var ts; case 221: case 257: case 223: - return parent.expression === node; + return parent_3.expression === node; case 214: - var forStatement = parent; + var forStatement = parent_3; return (forStatement.initializer === node && forStatement.initializer.kind !== 227) || forStatement.condition === node || forStatement.incrementor === node; case 215: case 216: - var forInStatement = parent; + var forInStatement = parent_3; return (forInStatement.initializer === node && forInStatement.initializer.kind !== 227) || forInStatement.expression === node; case 184: case 202: - return node === parent.expression; + return node === parent_3.expression; case 205: - return node === parent.expression; + return node === parent_3.expression; case 144: - return node === parent.expression; + return node === parent_3.expression; case 147: case 256: case 255: case 263: return true; case 201: - return parent.expression === node && isExpressionWithTypeArgumentsInClassExtendsClause(parent); + return parent_3.expression === node && isExpressionWithTypeArgumentsInClassExtendsClause(parent_3); default: - if (isPartOfExpression(parent)) { + if (isPartOfExpression(parent_3)) { return true; } } @@ -5807,8 +5859,8 @@ var ts; } function getJSDocParameterTags(param) { if (param.name && ts.isIdentifier(param.name)) { - var name_1 = param.name.escapedText; - return getJSDocTags(param.parent).filter(function (tag) { return ts.isJSDocParameterTag(tag) && ts.isIdentifier(tag.name) && tag.name.escapedText === name_1; }); + var name_5 = param.name.escapedText; + return getJSDocTags(param.parent).filter(function (tag) { return ts.isJSDocParameterTag(tag) && ts.isIdentifier(tag.name) && tag.name.escapedText === name_5; }); } return undefined; } @@ -6095,14 +6147,14 @@ var ts; ts.getAncestor = getAncestor; function getFileReferenceFromReferencePath(comment, commentRange) { var simpleReferenceRegEx = /^\/\/\/\s*/gim; + var isNoDefaultLibRegEx = new RegExp(defaultLibReferenceRegEx.source, "gim"); if (simpleReferenceRegEx.test(comment)) { if (isNoDefaultLibRegEx.test(comment)) { return { isNoDefaultLib: true }; } else { var refMatchResult = ts.fullTripleSlashReferencePathRegEx.exec(comment); - var refLibResult = !refMatchResult && ts.fullTripleSlashReferenceTypeReferenceDirectiveRegEx.exec(comment); + var refLibResult = !refMatchResult && fullTripleSlashReferenceTypeReferenceDirectiveRegEx.exec(comment); var match = refMatchResult || refLibResult; if (match) { var pos = commentRange.pos + match[1].length + match[2].length; @@ -6291,10 +6343,6 @@ var ts; return ts.getParseTreeNode(sourceFile, ts.isSourceFile) || sourceFile; } ts.getOriginalSourceFile = getOriginalSourceFile; - function getOriginalSourceFiles(sourceFiles) { - return ts.sameMap(sourceFiles, getOriginalSourceFile); - } - ts.getOriginalSourceFiles = getOriginalSourceFiles; var Associativity; (function (Associativity) { Associativity[Associativity["Left"] = 0] = "Left"; @@ -6533,7 +6581,9 @@ var ts; } } ts.createDiagnosticCollection = createDiagnosticCollection; - var escapedCharsRegExp = /[\\\"\u0000-\u001f\t\v\f\b\r\n\u2028\u2029\u0085]/g; + var doubleQuoteEscapedCharsRegExp = /[\\\"\u0000-\u001f\t\v\f\b\r\n\u2028\u2029\u0085]/g; + var singleQuoteEscapedCharsRegExp = /[\\\'\u0000-\u001f\t\v\f\b\r\n\u2028\u2029\u0085]/g; + var backtickQuoteEscapedCharsRegExp = /[\\\`\u0000-\u001f\t\v\f\b\r\n\u2028\u2029\u0085]/g; var escapedCharsMap = ts.createMapFromTemplate({ "\0": "\\0", "\t": "\\t", @@ -6544,11 +6594,16 @@ var ts; "\n": "\\n", "\\": "\\\\", "\"": "\\\"", + "\'": "\\\'", + "\`": "\\\`", "\u2028": "\\u2028", "\u2029": "\\u2029", "\u0085": "\\u0085" }); - function escapeString(s) { + function escapeString(s, quoteChar) { + var escapedCharsRegExp = quoteChar === 96 ? backtickQuoteEscapedCharsRegExp : + quoteChar === 39 ? singleQuoteEscapedCharsRegExp : + doubleQuoteEscapedCharsRegExp; return s.replace(escapedCharsRegExp, getReplacement); } ts.escapeString = escapeString; @@ -6566,8 +6621,8 @@ var ts; return "\\u" + paddedHexCode; } var nonAsciiCharacters = /[^\u0000-\u007F]/g; - function escapeNonAsciiString(s) { - s = escapeString(s); + function escapeNonAsciiString(s, quoteChar) { + s = escapeString(s, quoteChar); return nonAsciiCharacters.test(s) ? s.replace(nonAsciiCharacters, function (c) { return get16BitUnicodeEscapeSequence(c.charCodeAt(0)); }) : s; @@ -6908,7 +6963,7 @@ var ts; var currentDetachedCommentInfo; if (removeComments) { if (node.pos === 0) { - leadingComments = ts.filter(ts.getLeadingCommentRanges(text, node.pos), isPinnedComment); + leadingComments = ts.filter(ts.getLeadingCommentRanges(text, node.pos), isPinnedCommentLocal); } } else { @@ -6940,9 +6995,8 @@ var ts; } } return currentDetachedCommentInfo; - function isPinnedComment(comment) { - return text.charCodeAt(comment.pos + 1) === 42 && - text.charCodeAt(comment.pos + 2) === 33; + function isPinnedCommentLocal(comment) { + return isPinnedComment(text, comment); } } ts.emitDetachedComments = emitDetachedComments; @@ -7013,9 +7067,13 @@ var ts; } ts.hasModifiers = hasModifiers; function hasModifier(node, flags) { - return (getModifierFlags(node) & flags) !== 0; + return !!getSelectedModifierFlags(node, flags); } ts.hasModifier = hasModifier; + function getSelectedModifierFlags(node, flags) { + return getModifierFlags(node) & flags; + } + ts.getSelectedModifierFlags = getSelectedModifierFlags; function getModifierFlags(node) { if (node.modifierFlagsCache & 536870912) { return node.modifierFlagsCache & ~536870912; @@ -7091,21 +7149,6 @@ var ts; return false; } ts.isDestructuringAssignment = isDestructuringAssignment; - function isSupportedExpressionWithTypeArguments(node) { - return isSupportedExpressionWithTypeArgumentsRest(node.expression); - } - ts.isSupportedExpressionWithTypeArguments = isSupportedExpressionWithTypeArguments; - function isSupportedExpressionWithTypeArgumentsRest(node) { - if (node.kind === 71) { - return true; - } - else if (ts.isPropertyAccessExpression(node)) { - return isSupportedExpressionWithTypeArgumentsRest(node.expression); - } - else { - return false; - } - } function isExpressionWithTypeArgumentsInClassExtendsClause(node) { return tryGetClassExtendingExpressionWithTypeArguments(node) !== undefined; } @@ -7218,72 +7261,6 @@ var ts; return carriageReturnLineFeed; } ts.getNewLineCharacter = getNewLineCharacter; - function isSimpleExpression(node) { - return isSimpleExpressionWorker(node, 0); - } - ts.isSimpleExpression = isSimpleExpression; - function isSimpleExpressionWorker(node, depth) { - if (depth <= 5) { - var kind = node.kind; - if (kind === 9 - || kind === 8 - || kind === 12 - || kind === 13 - || kind === 71 - || kind === 99 - || kind === 97 - || kind === 101 - || kind === 86 - || kind === 95) { - return true; - } - else if (kind === 179) { - return isSimpleExpressionWorker(node.expression, depth + 1); - } - else if (kind === 180) { - return isSimpleExpressionWorker(node.expression, depth + 1) - && isSimpleExpressionWorker(node.argumentExpression, depth + 1); - } - else if (kind === 192 - || kind === 193) { - return isSimpleExpressionWorker(node.operand, depth + 1); - } - else if (kind === 194) { - return node.operatorToken.kind !== 40 - && isSimpleExpressionWorker(node.left, depth + 1) - && isSimpleExpressionWorker(node.right, depth + 1); - } - else if (kind === 195) { - return isSimpleExpressionWorker(node.condition, depth + 1) - && isSimpleExpressionWorker(node.whenTrue, depth + 1) - && isSimpleExpressionWorker(node.whenFalse, depth + 1); - } - else if (kind === 190 - || kind === 189 - || kind === 188) { - return isSimpleExpressionWorker(node.expression, depth + 1); - } - else if (kind === 177) { - return node.elements.length === 0; - } - else if (kind === 178) { - return node.properties.length === 0; - } - else if (kind === 181) { - if (!isSimpleExpressionWorker(node.expression, depth + 1)) { - return false; - } - for (var _i = 0, _a = node.arguments; _i < _a.length; _i++) { - var argument = _a[_i]; - if (!isSimpleExpressionWorker(argument, depth + 1)) { - return false; - } - } - return true; - } - } - return false; - } function formatEnum(value, enumObject, isFlags) { if (value === void 0) { value = 0; } var members = getEnumMembers(enumObject); @@ -7316,10 +7293,10 @@ var ts; } function getEnumMembers(enumObject) { var result = []; - for (var name in enumObject) { - var value = enumObject[name]; + for (var name_6 in enumObject) { + var value = enumObject[name_6]; if (typeof value === "number") { - result.push([value, name]); + result.push([value, name_6]); } } return ts.stableSort(result, function (x, y) { return ts.compareValues(x[0], y[0]); }); @@ -7352,18 +7329,6 @@ var ts; return formatEnum(flags, ts.ObjectFlags, true); } ts.formatObjectFlags = formatObjectFlags; - function getRangePos(range) { - return range ? range.pos : -1; - } - ts.getRangePos = getRangePos; - function getRangeEnd(range) { - return range ? range.end : -1; - } - ts.getRangeEnd = getRangeEnd; - function movePos(pos, value) { - return ts.positionIsSynthesized(pos) ? -1 : pos + value; - } - ts.movePos = movePos; function createRange(pos, end) { return { pos: pos, end: end }; } @@ -7392,14 +7357,6 @@ var ts; return range.pos === range.end; } ts.isCollapsedRange = isCollapsedRange; - function collapseRangeToStart(range) { - return isCollapsedRange(range) ? range : moveRangeEnd(range, range.pos); - } - ts.collapseRangeToStart = collapseRangeToStart; - function collapseRangeToEnd(range) { - return isCollapsedRange(range) ? range : moveRangePos(range, range.end); - } - ts.collapseRangeToEnd = collapseRangeToEnd; function createTokenRange(pos, token) { return createRange(pos, pos + ts.tokenToString(token).length); } @@ -7452,22 +7409,6 @@ var ts; function isInitializedVariable(node) { return node.initializer !== undefined; } - function isMergedWithClass(node) { - if (node.symbol) { - for (var _i = 0, _a = node.symbol.declarations; _i < _a.length; _i++) { - var declaration = _a[_i]; - if (declaration.kind === 229 && declaration !== node) { - return true; - } - } - } - return false; - } - ts.isMergedWithClass = isMergedWithClass; - function isFirstDeclarationOfKind(node, kind) { - return node.symbol && getDeclarationOfKind(node.symbol, kind) === node; - } - ts.isFirstDeclarationOfKind = isFirstDeclarationOfKind; function isWatchSet(options) { return options.watch && options.hasOwnProperty("watch"); } @@ -7668,6 +7609,20 @@ var ts; return ts.hasModifier(node, 92) && node.parent.kind === 152 && ts.isClassLike(node.parent.parent); } ts.isParameterPropertyDeclaration = isParameterPropertyDeclaration; + function isEmptyBindingPattern(node) { + if (ts.isBindingPattern(node)) { + return ts.every(node.elements, isEmptyBindingElement); + } + return false; + } + ts.isEmptyBindingPattern = isEmptyBindingPattern; + function isEmptyBindingElement(node) { + if (ts.isOmittedExpression(node)) { + return true; + } + return isEmptyBindingPattern(node.name); + } + ts.isEmptyBindingElement = isEmptyBindingElement; function walkUpBindingElementsAndPatterns(node) { while (node && (node.kind === 176 || ts.isBindingPattern(node))) { node = node.parent; @@ -8748,6 +8703,18 @@ var ts; return isUnaryExpressionKind(ts.skipPartiallyEmittedExpressions(node).kind); } ts.isUnaryExpression = isUnaryExpression; + function isUnaryExpressionWithWrite(expr) { + switch (expr.kind) { + case 193: + return true; + case 192: + return expr.operator === 43 || + expr.operator === 44; + default: + return false; + } + } + ts.isUnaryExpressionWithWrite = isUnaryExpressionWithWrite; function isExpressionKind(kind) { return kind === 195 || kind === 197 @@ -8932,9 +8899,19 @@ var ts; var kind = node.kind; return isStatementKindButNotDeclarationKind(kind) || isDeclarationStatementKind(kind) - || kind === 207; + || isBlockStatement(node); } ts.isStatement = isStatement; + function isBlockStatement(node) { + if (node.kind !== 207) + return false; + if (node.parent !== undefined) { + if (node.parent.kind === 224 || node.parent.kind === 260) { + return false; + } + } + return !ts.isFunctionBlock(node); + } function isModuleReference(node) { var kind = node.kind; return kind === 248 @@ -12439,11 +12416,31 @@ var ts; var node = parseTokenNode(); return token() === 23 ? undefined : node; } - function parseLiteralTypeNode() { + function parseLiteralTypeNode(negative) { var node = createNode(173); - node.literal = parseSimpleUnaryExpression(); - finishNode(node); - return node; + var unaryMinusExpression; + if (negative) { + unaryMinusExpression = createNode(192); + unaryMinusExpression.operator = 38; + nextToken(); + } + var expression; + switch (token()) { + case 9: + case 8: + expression = parseLiteralLikeNode(token()); + break; + case 101: + case 86: + expression = parseTokenNode(); + } + if (negative) { + unaryMinusExpression.operand = expression; + finishNode(unaryMinusExpression); + expression = unaryMinusExpression; + } + node.literal = expression; + return finishNode(node); } function nextTokenIsNumericLiteral() { return nextToken() === 8; @@ -12475,7 +12472,7 @@ var ts; case 86: return parseLiteralTypeNode(); case 38: - return lookAhead(nextTokenIsNumericLiteral) ? parseLiteralTypeNode() : parseTypeReference(); + return lookAhead(nextTokenIsNumericLiteral) ? parseLiteralTypeNode(true) : parseTypeReference(); case 105: case 95: return parseTokenNode(); @@ -12524,6 +12521,7 @@ var ts; case 101: case 86: case 134: + case 39: return true; case 38: return lookAhead(nextTokenIsNumericLiteral); @@ -12842,7 +12840,7 @@ var ts; if (!arrowFunction) { return undefined; } - var isAsync = !!(ts.getModifierFlags(arrowFunction) & 256); + var isAsync = ts.hasModifier(arrowFunction, 256); var lastToken = token(); arrowFunction.equalsGreaterThanToken = parseExpectedToken(36, false, ts.Diagnostics._0_expected, "=>"); arrowFunction.body = (lastToken === 36 || lastToken === 17) @@ -12958,7 +12956,7 @@ var ts; function parseParenthesizedArrowFunctionExpressionHead(allowAmbiguity) { var node = createNode(187); node.modifiers = parseModifiersForArrowFunction(); - var isAsync = (ts.getModifierFlags(node) & 256) ? 2 : 0; + var isAsync = ts.hasModifier(node, 256) ? 2 : 0; fillSignature(56, isAsync | (allowAmbiguity ? 0 : 8), node); if (!node.parameters) { return undefined; @@ -13691,7 +13689,7 @@ var ts; parseExpected(89); node.asteriskToken = parseOptionalToken(39); var isGenerator = node.asteriskToken ? 1 : 0; - var isAsync = (ts.getModifierFlags(node) & 256) ? 2 : 0; + var isAsync = ts.hasModifier(node, 256) ? 2 : 0; node.name = isGenerator && isAsync ? doInYieldAndAwaitContext(parseOptionalIdentifier) : isGenerator ? doInYieldContext(parseOptionalIdentifier) : @@ -13916,10 +13914,13 @@ var ts; function parseCatchClause() { var result = createNode(260); parseExpected(74); - if (parseExpected(19)) { + if (parseOptional(19)) { result.variableDeclaration = parseVariableDeclaration(); + parseExpected(20); + } + else { + result.variableDeclaration = undefined; } - parseExpected(20); result.block = parseBlock(false); return finishNode(result); } @@ -14505,8 +14506,8 @@ var ts; return parsePropertyOrMethodDeclaration(fullStart, decorators, modifiers); } if (decorators || modifiers) { - var name = createMissingNode(71, true, ts.Diagnostics.Declaration_expected); - return parsePropertyDeclaration(fullStart, decorators, modifiers, name, undefined); + var name_7 = createMissingNode(71, true, ts.Diagnostics.Declaration_expected); + return parsePropertyDeclaration(fullStart, decorators, modifiers, name_7, undefined); } ts.Debug.fail("Should not have attempted to parse class member declaration."); } @@ -15524,14 +15525,14 @@ var ts; } var typeParameters = createNodeArray(); while (true) { - var name = parseJSDocIdentifierName(); + var name_8 = parseJSDocIdentifierName(); skipWhitespace(); - if (!name) { + if (!name_8) { parseErrorAtPosition(scanner.getStartPos(), 0, ts.Diagnostics.Identifier_expected); return undefined; } - var typeParameter = createNode(145, name.pos); - typeParameter.name = name; + var typeParameter = createNode(145, name_8.pos); + typeParameter.name = name_8; finishNode(typeParameter); typeParameters.push(typeParameter); if (token() === 26) { @@ -15559,11 +15560,11 @@ var ts; parseExpected(22); } while (parseOptional(23)) { - var name = parseJSDocIdentifierName(true); + var name_9 = parseJSDocIdentifierName(true); if (parseOptional(21)) { parseExpected(22); } - entity = createQualifiedName(entity, name); + entity = createQualifiedName(entity, name_9); } return entity; } @@ -15651,8 +15652,8 @@ var ts; array._children = undefined; array.pos += delta; array.end += delta; - for (var _i = 0, array_9 = array; _i < array_9.length; _i++) { - var node = array_9[_i]; + for (var _i = 0, array_8 = array; _i < array_8.length; _i++) { + var node = array_8[_i]; visitNode(node); } } @@ -15724,8 +15725,8 @@ var ts; array.intersectsChange = true; array._children = undefined; adjustIntersectingElement(array, changeStart, changeRangeOldEnd, changeRangeNewEnd, delta); - for (var _i = 0, array_10 = array; _i < array_10.length; _i++) { - var node = array_10[_i]; + for (var _i = 0, array_9 = array; _i < array_9.length; _i++) { + var node = array_9[_i]; visitNode(node); } return; @@ -16241,6 +16242,12 @@ var ts; category: ts.Diagnostics.Module_Resolution_Options, description: ts.Diagnostics.Allow_default_imports_from_modules_with_no_default_export_This_does_not_affect_code_emit_just_typechecking }, + { + name: "preserveSymlinks", + type: "boolean", + category: ts.Diagnostics.Module_Resolution_Options, + description: ts.Diagnostics.Do_not_resolve_the_real_path_of_symlinks, + }, { name: "sourceRoot", type: "string", @@ -16852,7 +16859,7 @@ var ts; var text = valueExpression.text; if (option && typeof option.type !== "string") { var customOption = option; - if (!customOption.type.has(text)) { + if (!customOption.type.has(text.toLowerCase())) { errors.push(createDiagnosticForInvalidCustomType(customOption, function (message, arg0, arg1) { return ts.createDiagnosticForNodeInSourceFile(sourceFile, valueExpression, message, arg0, arg1); })); } } @@ -16930,31 +16937,31 @@ var ts; function serializeCompilerOptions(options) { var result = ts.createMap(); var optionsNameMap = getOptionNameMap().optionNameMap; - var _loop_3 = function (name) { - if (ts.hasProperty(options, name)) { - if (optionsNameMap.has(name) && optionsNameMap.get(name).category === ts.Diagnostics.Command_line_Options) { + var _loop_3 = function (name_10) { + if (ts.hasProperty(options, name_10)) { + if (optionsNameMap.has(name_10) && optionsNameMap.get(name_10).category === ts.Diagnostics.Command_line_Options) { return "continue"; } - var value = options[name]; - var optionDefinition = optionsNameMap.get(name.toLowerCase()); + var value = options[name_10]; + var optionDefinition = optionsNameMap.get(name_10.toLowerCase()); if (optionDefinition) { var customTypeMap_1 = getCustomTypeMapOfCommandLineOption(optionDefinition); if (!customTypeMap_1) { - result.set(name, value); + result.set(name_10, value); } else { if (optionDefinition.type === "list") { - result.set(name, value.map(function (element) { return getNameOfCompilerOptionValue(element, customTypeMap_1); })); + result.set(name_10, value.map(function (element) { return getNameOfCompilerOptionValue(element, customTypeMap_1); })); } else { - result.set(name, getNameOfCompilerOptionValue(value, customTypeMap_1)); + result.set(name_10, getNameOfCompilerOptionValue(value, customTypeMap_1)); } } } } }; - for (var name in options) { - _loop_3(name); + for (var name_10 in options) { + _loop_3(name_10); } return result; } @@ -17103,12 +17110,10 @@ var ts; } } else { - var specs = includeSpecs ? [] : ["node_modules", "bower_components", "jspm_packages"]; var outDir = raw["compilerOptions"] && raw["compilerOptions"]["outDir"]; if (outDir) { - specs.push(outDir); + excludeSpecs = [outDir]; } - excludeSpecs = specs; } if (fileNames === undefined && includeSpecs === undefined) { includeSpecs = ["**/*"]; @@ -17359,7 +17364,7 @@ var ts; return value; } else if (typeof option.type !== "string") { - return option.type.get(value); + return option.type.get(typeof value === "string" ? value.toLowerCase() : value); } return normalizeNonListOptionValue(option, basePath, value); } @@ -17434,23 +17439,13 @@ var ts; }; } function validateSpecs(specs, errors, allowTrailingRecursion, jsonSourceFile, specKey) { - var validSpecs = []; - for (var _i = 0, specs_1 = specs; _i < specs_1.length; _i++) { - var spec = specs_1[_i]; - if (!allowTrailingRecursion && invalidTrailingRecursionPattern.test(spec)) { - errors.push(createDiagnostic(ts.Diagnostics.File_specification_cannot_end_in_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0, spec)); + return specs.filter(function (spec) { + var diag = specToDiagnostic(spec, allowTrailingRecursion); + if (diag !== undefined) { + errors.push(createDiagnostic(diag, spec)); } - else if (invalidMultipleRecursionPatterns.test(spec)) { - errors.push(createDiagnostic(ts.Diagnostics.File_specification_cannot_contain_multiple_recursive_directory_wildcards_Asterisk_Asterisk_Colon_0, spec)); - } - else if (invalidDotDotAfterRecursiveWildcardPattern.test(spec)) { - errors.push(createDiagnostic(ts.Diagnostics.File_specification_cannot_contain_a_parent_directory_that_appears_after_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0, spec)); - } - else { - validSpecs.push(spec); - } - } - return validSpecs; + return diag === undefined; + }); function createDiagnostic(message, spec) { if (jsonSourceFile && jsonSourceFile.jsonObject) { for (var _i = 0, _a = ts.getPropertyAssignment(jsonSourceFile.jsonObject, specKey); _i < _a.length; _i++) { @@ -17468,6 +17463,17 @@ var ts; return ts.createCompilerDiagnostic(message, spec); } } + function specToDiagnostic(spec, allowTrailingRecursion) { + if (!allowTrailingRecursion && invalidTrailingRecursionPattern.test(spec)) { + return ts.Diagnostics.File_specification_cannot_end_in_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0; + } + else if (invalidMultipleRecursionPatterns.test(spec)) { + return ts.Diagnostics.File_specification_cannot_contain_multiple_recursive_directory_wildcards_Asterisk_Asterisk_Colon_0; + } + else if (invalidDotDotAfterRecursiveWildcardPattern.test(spec)) { + return ts.Diagnostics.File_specification_cannot_contain_a_parent_directory_that_appears_after_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0; + } + } function getWildcardDirectories(include, exclude, path, useCaseSensitiveFileNames) { var rawExcludeRegex = ts.getRegularExpressionForWildcard(exclude, path, "exclude"); var excludeRegex = rawExcludeRegex && new RegExp(rawExcludeRegex, useCaseSensitiveFileNames ? "" : "i"); @@ -17590,6 +17596,12 @@ var ts; return compilerOptions.traceResolution && host.trace !== undefined; } ts.isTraceEnabled = isTraceEnabled; + function withPackageId(packageId, r) { + return r && { path: r.path, extension: r.ext, packageId: packageId }; + } + function noPackageId(r) { + return withPackageId(undefined, r); + } var Extensions; (function (Extensions) { Extensions[Extensions["TypeScript"] = 0] = "TypeScript"; @@ -17605,12 +17617,11 @@ var ts; } function createResolvedModuleWithFailedLookupLocations(resolved, isExternalLibraryImport, failedLookupLocations) { return { - resolvedModule: resolved && { resolvedFileName: resolved.path, extension: resolved.extension, isExternalLibraryImport: isExternalLibraryImport }, + resolvedModule: resolved && { resolvedFileName: resolved.path, extension: resolved.extension, isExternalLibraryImport: isExternalLibraryImport, packageId: resolved.packageId }, failedLookupLocations: failedLookupLocations }; } - function tryReadPackageJsonFields(readTypes, packageJsonPath, baseDirectory, state) { - var jsonContent = readJson(packageJsonPath, state.host); + function tryReadPackageJsonFields(readTypes, jsonContent, baseDirectory, state) { return readTypes ? tryReadFromField("typings") || tryReadFromField("types") : tryReadFromField("main"); function tryReadFromField(fieldName) { if (!ts.hasProperty(jsonContent, fieldName)) { @@ -17704,7 +17715,9 @@ var ts; } var resolvedTypeReferenceDirective; if (resolved) { - resolved = realpath(resolved, host, traceEnabled); + if (!options.preserveSymlinks) { + resolved = realPath(resolved, host, traceEnabled); + } if (traceEnabled) { trace(host, ts.Diagnostics.Type_reference_directive_0_was_successfully_resolved_to_1_primary_Colon_2, typeReferenceDirectiveName, resolved, primary); } @@ -17821,12 +17834,12 @@ var ts; var commonPrefix = getCommonPrefix(path, resolvedFileName); var current = path; while (true) { - var parent = ts.getDirectoryPath(current); - if (parent === current || directoryPathMap.has(parent)) { + var parent_4 = ts.getDirectoryPath(current); + if (parent_4 === current || directoryPathMap.has(parent_4)) { break; } - directoryPathMap.set(parent, result); - current = parent; + directoryPathMap.set(parent_4, result); + current = parent_4; if (current === commonPrefix) { break; } @@ -18005,7 +18018,7 @@ var ts; if (extension !== undefined) { var path_1 = tryFile(candidate, failedLookupLocations, false, state); if (path_1 !== undefined) { - return { path: path_1, extension: extension }; + return { path: path_1, extension: extension, packageId: undefined }; } } return loader(extensions, candidate, failedLookupLocations, !directoryProbablyExists(ts.getDirectoryPath(candidate), state.host), state); @@ -18026,7 +18039,7 @@ var ts; function resolveJavaScriptModule(moduleName, initialDir, host) { var _a = nodeModuleNameResolverWorker(moduleName, initialDir, { moduleResolution: ts.ModuleResolutionKind.NodeJs, allowJs: true }, host, undefined, true), resolvedModule = _a.resolvedModule, failedLookupLocations = _a.failedLookupLocations; if (!resolvedModule) { - throw new Error("Could not resolve JS module " + moduleName + " starting at " + initialDir + ". Looked in: " + failedLookupLocations.join(", ")); + throw new Error("Could not resolve JS module '" + moduleName + "' starting at '" + initialDir + "'. Looked in: " + failedLookupLocations.join(", ")); } return resolvedModule.resolvedFileName; } @@ -18052,16 +18065,22 @@ var ts; trace(host, ts.Diagnostics.Loading_module_0_from_node_modules_folder_target_file_type_1, moduleName, Extensions[extensions]); } var resolved_1 = loadModuleFromNodeModules(extensions, moduleName, containingDirectory, failedLookupLocations, state, cache); - return resolved_1 && { value: resolved_1.value && { resolved: { path: realpath(resolved_1.value.path, host, traceEnabled), extension: resolved_1.value.extension }, isExternalLibraryImport: true } }; + if (!resolved_1) + return undefined; + var resolvedValue = resolved_1.value; + if (!compilerOptions.preserveSymlinks) { + resolvedValue = resolvedValue && __assign({}, resolved_1.value, { path: realPath(resolved_1.value.path, host, traceEnabled), extension: resolved_1.value.extension }); + } + return { value: resolvedValue && { resolved: resolvedValue, isExternalLibraryImport: true } }; } else { - var candidate = ts.normalizePath(ts.combinePaths(containingDirectory, moduleName)); + var _a = ts.normalizePathAndParts(ts.combinePaths(containingDirectory, moduleName)), candidate = _a.path, parts = _a.parts; var resolved_2 = nodeLoadModuleByRelativeName(extensions, candidate, failedLookupLocations, false, state, true); - return resolved_2 && toSearchResult({ resolved: resolved_2, isExternalLibraryImport: false }); + return resolved_2 && toSearchResult({ resolved: resolved_2, isExternalLibraryImport: ts.contains(parts, "node_modules") }); } } } - function realpath(path, host, traceEnabled) { + function realPath(path, host, traceEnabled) { if (!host.realpath) { return path; } @@ -18087,7 +18106,7 @@ var ts; } var resolvedFromFile = loadModuleFromFile(extensions, candidate, failedLookupLocations, onlyRecordFailures, state); if (resolvedFromFile) { - return resolvedFromFile; + return noPackageId(resolvedFromFile); } } if (!onlyRecordFailures) { @@ -18105,6 +18124,9 @@ var ts; return !host.directoryExists || host.directoryExists(directoryName); } ts.directoryProbablyExists = directoryProbablyExists; + function loadModuleFromFileNoPackageId(extensions, candidate, failedLookupLocations, onlyRecordFailures, state) { + return noPackageId(loadModuleFromFile(extensions, candidate, failedLookupLocations, onlyRecordFailures, state)); + } function loadModuleFromFile(extensions, candidate, failedLookupLocations, onlyRecordFailures, state) { var resolvedByAddingExtension = tryAddingExtensions(candidate, extensions, failedLookupLocations, onlyRecordFailures, state); if (resolvedByAddingExtension) { @@ -18134,9 +18156,9 @@ var ts; case Extensions.JavaScript: return tryExtension(".js") || tryExtension(".jsx"); } - function tryExtension(extension) { - var path = tryFile(candidate + extension, failedLookupLocations, onlyRecordFailures, state); - return path && { path: path, extension: extension }; + function tryExtension(ext) { + var path = tryFile(candidate + ext, failedLookupLocations, onlyRecordFailures, state); + return path && { path: path, ext: ext }; } } function tryFile(fileName, failedLookupLocations, onlyRecordFailures, state) { @@ -18159,12 +18181,20 @@ var ts; function loadNodeModuleFromDirectory(extensions, candidate, failedLookupLocations, onlyRecordFailures, state, considerPackageJson) { if (considerPackageJson === void 0) { considerPackageJson = true; } var directoryExists = !onlyRecordFailures && directoryProbablyExists(candidate, state.host); + var packageId; if (considerPackageJson) { var packageJsonPath = pathToPackageJson(candidate); if (directoryExists && state.host.fileExists(packageJsonPath)) { - var fromPackageJson = loadModuleFromPackageJson(packageJsonPath, extensions, candidate, failedLookupLocations, state); + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.Found_package_json_at_0, packageJsonPath); + } + var jsonContent = readJson(packageJsonPath, state.host); + if (typeof jsonContent.name === "string" && typeof jsonContent.version === "string") { + packageId = { name: jsonContent.name, version: jsonContent.version }; + } + var fromPackageJson = loadModuleFromPackageJson(jsonContent, extensions, candidate, failedLookupLocations, state); if (fromPackageJson) { - return fromPackageJson; + return withPackageId(packageId, fromPackageJson); } } else { @@ -18174,13 +18204,10 @@ var ts; failedLookupLocations.push(packageJsonPath); } } - return loadModuleFromFile(extensions, ts.combinePaths(candidate, "index"), failedLookupLocations, !directoryExists, state); + return withPackageId(packageId, loadModuleFromFile(extensions, ts.combinePaths(candidate, "index"), failedLookupLocations, !directoryExists, state)); } - function loadModuleFromPackageJson(packageJsonPath, extensions, candidate, failedLookupLocations, state) { - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.Found_package_json_at_0, packageJsonPath); - } - var file = tryReadPackageJsonFields(extensions !== Extensions.JavaScript, packageJsonPath, candidate, state); + function loadModuleFromPackageJson(jsonContent, extensions, candidate, failedLookupLocations, state) { + var file = tryReadPackageJsonFields(extensions !== Extensions.JavaScript, jsonContent, candidate, state); if (!file) { return undefined; } @@ -18196,11 +18223,15 @@ var ts; } } var nextExtensions = extensions === Extensions.DtsOnly ? Extensions.TypeScript : extensions; - return nodeLoadModuleByRelativeName(nextExtensions, file, failedLookupLocations, onlyRecordFailures, state, false); + var result = nodeLoadModuleByRelativeName(nextExtensions, file, failedLookupLocations, onlyRecordFailures, state, false); + if (result) { + ts.Debug.assert(result.packageId === undefined); + return { path: result.path, ext: result.extension }; + } } function resolvedIfExtensionMatches(extensions, path) { - var extension = ts.tryGetExtensionFromPath(path); - return extension !== undefined && extensionIsOk(extensions, extension) ? { path: path, extension: extension } : undefined; + var ext = ts.tryGetExtensionFromPath(path); + return ext !== undefined && extensionIsOk(extensions, ext) ? { path: path, ext: ext } : undefined; } function extensionIsOk(extensions, extension) { switch (extensions) { @@ -18217,7 +18248,7 @@ var ts; } function loadModuleFromNodeModulesFolder(extensions, moduleName, nodeModulesFolder, nodeModulesFolderExists, failedLookupLocations, state) { var candidate = ts.normalizePath(ts.combinePaths(nodeModulesFolder, moduleName)); - return loadModuleFromFile(extensions, candidate, failedLookupLocations, !nodeModulesFolderExists, state) || + return loadModuleFromFileNoPackageId(extensions, candidate, failedLookupLocations, !nodeModulesFolderExists, state) || loadNodeModuleFromDirectory(extensions, candidate, failedLookupLocations, !nodeModulesFolderExists, state); } function loadModuleFromNodeModules(extensions, moduleName, directory, failedLookupLocations, state, cache) { @@ -18291,7 +18322,7 @@ var ts; if (traceEnabled) { trace(host, ts.Diagnostics.Resolution_for_module_0_was_found_in_cache, moduleName); } - return { value: result.resolvedModule && { path: result.resolvedModule.resolvedFileName, extension: result.resolvedModule.extension } }; + return { value: result.resolvedModule && { path: result.resolvedModule.resolvedFileName, extension: result.resolvedModule.extension, packageId: result.resolvedModule.packageId } }; } } function classicNameResolver(moduleName, containingFile, compilerOptions, host, cache) { @@ -18302,7 +18333,7 @@ var ts; var resolved = tryResolve(Extensions.TypeScript) || tryResolve(Extensions.JavaScript); return createResolvedModuleWithFailedLookupLocations(resolved && resolved.value, false, failedLookupLocations); function tryResolve(extensions) { - var resolvedUsingSettings = tryLoadModuleUsingOptionalResolutionSettings(extensions, moduleName, containingDirectory, loadModuleFromFile, failedLookupLocations, state); + var resolvedUsingSettings = tryLoadModuleUsingOptionalResolutionSettings(extensions, moduleName, containingDirectory, loadModuleFromFileNoPackageId, failedLookupLocations, state); if (resolvedUsingSettings) { return { value: resolvedUsingSettings }; } @@ -18314,7 +18345,7 @@ var ts; return resolutionFromCache; } var searchName = ts.normalizePath(ts.combinePaths(directory, moduleName)); - return toSearchResult(loadModuleFromFile(extensions, searchName, failedLookupLocations, false, state)); + return toSearchResult(loadModuleFromFileNoPackageId(extensions, searchName, failedLookupLocations, false, state)); }); if (resolved_3) { return resolved_3; @@ -18325,7 +18356,7 @@ var ts; } else { var candidate = ts.normalizePath(ts.combinePaths(containingDirectory, moduleName)); - return toSearchResult(loadModuleFromFile(extensions, candidate, failedLookupLocations, false, state)); + return toSearchResult(loadModuleFromFileNoPackageId(extensions, candidate, failedLookupLocations, false, state)); } } } @@ -18976,40 +19007,23 @@ var ts; return antecedent; } setFlowNodeReferenced(antecedent); - return { - flags: flags, - expression: expression, - antecedent: antecedent - }; + return { flags: flags, expression: expression, antecedent: antecedent }; } function createFlowSwitchClause(antecedent, switchStatement, clauseStart, clauseEnd) { if (!isNarrowingExpression(switchStatement.expression)) { return antecedent; } setFlowNodeReferenced(antecedent); - return { - flags: 128, - switchStatement: switchStatement, - clauseStart: clauseStart, - clauseEnd: clauseEnd, - antecedent: antecedent - }; + return { flags: 128, switchStatement: switchStatement, clauseStart: clauseStart, clauseEnd: clauseEnd, antecedent: antecedent }; } function createFlowAssignment(antecedent, node) { setFlowNodeReferenced(antecedent); - return { - flags: 16, - antecedent: antecedent, - node: node - }; + return { flags: 16, antecedent: antecedent, node: node }; } function createFlowArrayMutation(antecedent, node) { setFlowNodeReferenced(antecedent); - return { - flags: 256, - antecedent: antecedent, - node: node - }; + var res = { flags: 256, antecedent: antecedent, node: node }; + return res; } function finishFlowLabel(flow) { var antecedents = flow.antecedents; @@ -20107,12 +20121,12 @@ var ts; return; } else { - var parent_1 = node.parent; - if (!ts.isExternalModule(parent_1)) { + var parent_5 = node.parent; + if (!ts.isExternalModule(parent_5)) { file.bindDiagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.Global_module_exports_may_only_appear_in_module_files)); return; } - if (!parent_1.isDeclarationFile) { + if (!parent_5.isDeclarationFile) { file.bindDiagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.Global_module_exports_may_only_appear_in_declaration_files)); return; } @@ -20477,7 +20491,6 @@ var ts; } function computeParameter(node, subtreeFlags) { var transformFlags = subtreeFlags; - var modifierFlags = ts.getModifierFlags(node); var name = node.name; var initializer = node.initializer; var dotDotDotToken = node.dotDotDotToken; @@ -20487,7 +20500,7 @@ var ts; || ts.isThisIdentifier(name)) { transformFlags |= 3; } - if (modifierFlags & 92) { + if (ts.hasModifier(node, 92)) { transformFlags |= 3 | 262144; } if (subtreeFlags & 1048576) { @@ -20516,8 +20529,7 @@ var ts; } function computeClassDeclaration(node, subtreeFlags) { var transformFlags; - var modifierFlags = ts.getModifierFlags(node); - if (modifierFlags & 2) { + if (ts.hasModifier(node, 2)) { transformFlags = 3; } else { @@ -20563,7 +20575,10 @@ var ts; } function computeCatchClause(node, subtreeFlags) { var transformFlags = subtreeFlags; - if (node.variableDeclaration && ts.isBindingPattern(node.variableDeclaration.name)) { + if (!node.variableDeclaration) { + transformFlags |= 8; + } + else if (ts.isBindingPattern(node.variableDeclaration.name)) { transformFlags |= 192; } node.transformFlags = transformFlags | 536870912; @@ -20727,9 +20742,8 @@ var ts; } function computeVariableStatement(node, subtreeFlags) { var transformFlags; - var modifierFlags = ts.getModifierFlags(node); var declarationListTransformFlags = node.declarationList.transformFlags; - if (modifierFlags & 2) { + if (ts.hasModifier(node, 2)) { transformFlags = 3; } else { @@ -21028,6 +21042,167 @@ var ts; } })(ts || (ts = {})); var ts; +(function (ts) { + function createGetSymbolWalker(getRestTypeOfSignature, getReturnTypeOfSignature, getBaseTypes, resolveStructuredTypeMembers, getTypeOfSymbol, getResolvedSymbol, getIndexTypeOfStructuredType, getConstraintFromTypeParameter, getFirstIdentifier) { + return getSymbolWalker; + function getSymbolWalker(accept) { + if (accept === void 0) { accept = function () { return true; }; } + var visitedTypes = ts.createMap(); + var visitedSymbols = ts.createMap(); + return { + walkType: function (type) { + visitedTypes.clear(); + visitedSymbols.clear(); + visitType(type); + return { visitedTypes: ts.arrayFrom(visitedTypes.values()), visitedSymbols: ts.arrayFrom(visitedSymbols.values()) }; + }, + walkSymbol: function (symbol) { + visitedTypes.clear(); + visitedSymbols.clear(); + visitSymbol(symbol); + return { visitedTypes: ts.arrayFrom(visitedTypes.values()), visitedSymbols: ts.arrayFrom(visitedSymbols.values()) }; + }, + }; + function visitType(type) { + if (!type) { + return; + } + var typeIdString = type.id.toString(); + if (visitedTypes.has(typeIdString)) { + return; + } + visitedTypes.set(typeIdString, type); + var shouldBail = visitSymbol(type.symbol); + if (shouldBail) + return; + if (type.flags & 32768) { + var objectType = type; + var objectFlags = objectType.objectFlags; + if (objectFlags & 4) { + visitTypeReference(type); + } + if (objectFlags & 32) { + visitMappedType(type); + } + if (objectFlags & (1 | 2)) { + visitInterfaceType(type); + } + if (objectFlags & (8 | 16)) { + visitObjectType(objectType); + } + } + if (type.flags & 16384) { + visitTypeParameter(type); + } + if (type.flags & 196608) { + visitUnionOrIntersectionType(type); + } + if (type.flags & 262144) { + visitIndexType(type); + } + if (type.flags & 524288) { + visitIndexedAccessType(type); + } + } + function visitTypeList(types) { + if (!types) { + return; + } + for (var i = 0; i < types.length; i++) { + visitType(types[i]); + } + } + function visitTypeReference(type) { + visitType(type.target); + visitTypeList(type.typeArguments); + } + function visitTypeParameter(type) { + visitType(getConstraintFromTypeParameter(type)); + } + function visitUnionOrIntersectionType(type) { + visitTypeList(type.types); + } + function visitIndexType(type) { + visitType(type.type); + } + function visitIndexedAccessType(type) { + visitType(type.objectType); + visitType(type.indexType); + visitType(type.constraint); + } + function visitMappedType(type) { + visitType(type.typeParameter); + visitType(type.constraintType); + visitType(type.templateType); + visitType(type.modifiersType); + } + function visitSignature(signature) { + if (signature.typePredicate) { + visitType(signature.typePredicate.type); + } + visitTypeList(signature.typeParameters); + for (var _i = 0, _a = signature.parameters; _i < _a.length; _i++) { + var parameter = _a[_i]; + visitSymbol(parameter); + } + visitType(getRestTypeOfSignature(signature)); + visitType(getReturnTypeOfSignature(signature)); + } + function visitInterfaceType(interfaceT) { + visitObjectType(interfaceT); + visitTypeList(interfaceT.typeParameters); + visitTypeList(getBaseTypes(interfaceT)); + visitType(interfaceT.thisType); + } + function visitObjectType(type) { + var stringIndexType = getIndexTypeOfStructuredType(type, 0); + visitType(stringIndexType); + var numberIndexType = getIndexTypeOfStructuredType(type, 1); + visitType(numberIndexType); + var resolved = resolveStructuredTypeMembers(type); + for (var _i = 0, _a = resolved.callSignatures; _i < _a.length; _i++) { + var signature = _a[_i]; + visitSignature(signature); + } + for (var _b = 0, _c = resolved.constructSignatures; _b < _c.length; _b++) { + var signature = _c[_b]; + visitSignature(signature); + } + for (var _d = 0, _e = resolved.properties; _d < _e.length; _d++) { + var p = _e[_d]; + visitSymbol(p); + } + } + function visitSymbol(symbol) { + if (!symbol) { + return; + } + var symbolIdString = ts.getSymbolId(symbol).toString(); + if (visitedSymbols.has(symbolIdString)) { + return; + } + visitedSymbols.set(symbolIdString, symbol); + if (!accept(symbol)) { + return true; + } + var t = getTypeOfSymbol(symbol); + visitType(t); + if (symbol.flags & 1952) { + symbol.exports.forEach(visitSymbol); + } + ts.forEach(symbol.declarations, function (d) { + if (d.type && d.type.kind === 162) { + var query = d.type; + var entity = getResolvedSymbol(getFirstIdentifier(query.exprName)); + visitSymbol(entity); + } + }); + } + } + } + ts.createGetSymbolWalker = createGetSymbolWalker; +})(ts || (ts = {})); +var ts; (function (ts) { var ambientModuleSymbolRegex = /^".+"$/; var nextSymbolId = 1; @@ -21138,6 +21313,9 @@ var ts; node = ts.getParseTreeNode(node, ts.isExportSpecifier); return node ? getExportSpecifierLocalTargetSymbol(node) : undefined; }, + getExportSymbolOfSymbol: function (symbol) { + return getMergedSymbol(symbol.exportSymbol || symbol); + }, getTypeAtLocation: function (node) { node = ts.getParseTreeNode(node); return node ? getTypeOfNode(node) : unknownType; @@ -21200,6 +21378,7 @@ var ts; getEmitResolver: getEmitResolver, getExportsOfModule: getExportsOfModuleAsArray, getExportsAndPropertiesOfModule: getExportsAndPropertiesOfModule, + getSymbolWalker: ts.createGetSymbolWalker(getRestTypeOfSignature, getReturnTypeOfSignature, getBaseTypes, resolveStructuredTypeMembers, getTypeOfSymbol, getResolvedSymbol, getIndexTypeOfStructuredType, getConstraintFromTypeParameter, getFirstIdentifier), getAmbientModules: getAmbientModules, getAllAttributesTypeFromJsxOpeningLikeElement: function (node) { node = ts.getParseTreeNode(node, ts.isJsxOpeningLikeElement); @@ -21220,11 +21399,10 @@ var ts; getSuggestionForNonexistentProperty: function (node, type) { return ts.unescapeLeadingUnderscores(getSuggestionForNonexistentProperty(node, type)); }, getSuggestionForNonexistentSymbol: function (location, name, meaning) { return ts.unescapeLeadingUnderscores(getSuggestionForNonexistentSymbol(location, ts.escapeLeadingUnderscores(name), meaning)); }, getBaseConstraintOfType: getBaseConstraintOfType, - getJsxNamespace: function () { return ts.unescapeLeadingUnderscores(getJsxNamespace()); }, - resolveNameAtLocation: function (location, name, meaning) { - location = ts.getParseTreeNode(location); - return resolveName(location, ts.escapeLeadingUnderscores(name), meaning, undefined, ts.escapeLeadingUnderscores(name)); + resolveName: function (name, location, meaning) { + return resolveName(location, ts.escapeLeadingUnderscores(name), meaning, undefined, undefined); }, + getJsxNamespace: function () { return ts.unescapeLeadingUnderscores(getJsxNamespace()); }, }; var tupleTypes = []; var unionTypes = ts.createMap(); @@ -21707,7 +21885,10 @@ var ts; } return true; } - if (usage.parent.kind === 246) { + if (usage.parent.kind === 246 || (usage.parent.kind === 243 && usage.parent.isExportEquals)) { + return true; + } + if (usage.kind === 243 && usage.isExportEquals) { return true; } var container = ts.getEnclosingBlockScopeContainer(declaration); @@ -21737,13 +21918,13 @@ var ts; current.parent.kind === 149 && current.parent.initializer === current; if (initializerOfProperty) { - if (ts.getModifierFlags(current.parent) & 32) { + if (ts.hasModifier(current.parent, 32)) { if (declaration.kind === 151) { return true; } } else { - var isDeclarationInstanceProperty = declaration.kind === 149 && !(ts.getModifierFlags(declaration) & 32); + var isDeclarationInstanceProperty = declaration.kind === 149 && !ts.hasModifier(declaration, 32); if (!isDeclarationInstanceProperty || ts.getContainingClass(usage) !== ts.getContainingClass(declaration)) { return true; } @@ -21823,7 +22004,7 @@ var ts; break; case 149: case 148: - if (ts.isClassLike(location.parent) && !(ts.getModifierFlags(location) & 32)) { + if (ts.isClassLike(location.parent) && !ts.hasModifier(location, 32)) { var ctor = findConstructorDeclaration(location.parent); if (ctor && ctor.locals) { if (lookup(ctor.locals, name, meaning & 107455)) { @@ -21840,7 +22021,7 @@ var ts; result = undefined; break; } - if (lastLocation && ts.getModifierFlags(lastLocation) & 32) { + if (lastLocation && ts.hasModifier(lastLocation, 32)) { error(errorLocation, ts.Diagnostics.Static_members_cannot_reference_class_type_parameters); return undefined; } @@ -21854,6 +22035,17 @@ var ts; } } break; + case 201: + if (lastLocation === location.expression && location.parent.token === 85) { + var container = location.parent.parent; + if (ts.isClassLike(container) && (result = lookup(getSymbolOfNode(container).members, name, meaning & 793064))) { + if (nameNotFoundMessage) { + error(errorLocation, ts.Diagnostics.Base_class_expressions_cannot_reference_class_type_parameters); + } + return undefined; + } + } + break; case 144: grandparent = location.parent.parent; if (ts.isClassLike(grandparent) || grandparent.kind === 230) { @@ -21900,7 +22092,7 @@ var ts; lastLocation = location; location = location.parent; } - if (result && nameNotFoundMessage && noUnusedIdentifiers) { + if (result && nameNotFoundMessage && noUnusedIdentifiers && result !== lastLocation.symbol) { result.isReferenced = true; } if (!result) { @@ -21981,7 +22173,7 @@ var ts; error(errorLocation, ts.Diagnostics.Cannot_find_name_0_Did_you_mean_the_static_member_1_0, diagnosticName(nameArg), symbolToString(classSymbol)); return true; } - if (location === container && !(ts.getModifierFlags(location) & 32)) { + if (location === container && !ts.hasModifier(location, 32)) { var instanceType = getDeclaredTypeOfSymbol(classSymbol).thisType; if (getPropertyOfType(instanceType, name)) { error(errorLocation, ts.Diagnostics.Cannot_find_name_0_Did_you_mean_the_instance_member_this_0, diagnosticName(nameArg)); @@ -22016,14 +22208,14 @@ var ts; function checkAndReportErrorForUsingTypeAsNamespace(errorLocation, name, meaning) { if (meaning === 1920) { var symbol = resolveSymbol(resolveName(errorLocation, name, 793064 & ~107455, undefined, undefined)); - var parent = errorLocation.parent; + var parent_6 = errorLocation.parent; if (symbol) { - if (ts.isQualifiedName(parent)) { - ts.Debug.assert(parent.left === errorLocation, "Should only be resolving left side of qualified name as a namespace"); - var propName = parent.right.escapedText; + if (ts.isQualifiedName(parent_6)) { + ts.Debug.assert(parent_6.left === errorLocation, "Should only be resolving left side of qualified name as a namespace"); + var propName = parent_6.right.escapedText; var propType = getPropertyOfType(getDeclaredTypeOfSymbol(symbol), propName); if (propType) { - error(parent, ts.Diagnostics.Cannot_access_0_1_because_0_is_a_type_but_not_a_namespace_Did_you_mean_to_retrieve_the_type_of_the_property_1_in_0_with_0_1, ts.unescapeLeadingUnderscores(name), ts.unescapeLeadingUnderscores(propName)); + error(parent_6, ts.Diagnostics.Cannot_access_0_1_because_0_is_a_type_but_not_a_namespace_Did_you_mean_to_retrieve_the_type_of_the_property_1_in_0_with_0_1, ts.unescapeLeadingUnderscores(name), ts.unescapeLeadingUnderscores(propName)); return true; } } @@ -22161,28 +22353,28 @@ var ts; var moduleSymbol = resolveExternalModuleName(node, node.moduleSpecifier); var targetSymbol = resolveESModuleSymbol(moduleSymbol, node.moduleSpecifier, dontResolveAlias); if (targetSymbol) { - var name = specifier.propertyName || specifier.name; - if (name.escapedText) { + var name_11 = specifier.propertyName || specifier.name; + if (name_11.escapedText) { if (ts.isShorthandAmbientModuleSymbol(moduleSymbol)) { return moduleSymbol; } var symbolFromVariable = void 0; if (moduleSymbol && moduleSymbol.exports && moduleSymbol.exports.get("export=")) { - symbolFromVariable = getPropertyOfType(getTypeOfSymbol(targetSymbol), name.escapedText); + symbolFromVariable = getPropertyOfType(getTypeOfSymbol(targetSymbol), name_11.escapedText); } else { - symbolFromVariable = getPropertyOfVariable(targetSymbol, name.escapedText); + symbolFromVariable = getPropertyOfVariable(targetSymbol, name_11.escapedText); } symbolFromVariable = resolveSymbol(symbolFromVariable, dontResolveAlias); - var symbolFromModule = getExportOfModule(targetSymbol, name.escapedText, dontResolveAlias); - if (!symbolFromModule && allowSyntheticDefaultImports && name.escapedText === "default") { + var symbolFromModule = getExportOfModule(targetSymbol, name_11.escapedText, dontResolveAlias); + if (!symbolFromModule && allowSyntheticDefaultImports && name_11.escapedText === "default") { symbolFromModule = resolveExternalModuleSymbol(moduleSymbol, dontResolveAlias) || resolveSymbol(moduleSymbol, dontResolveAlias); } var symbol = symbolFromModule && symbolFromVariable ? combineValueAndTypeSymbols(symbolFromVariable, symbolFromModule) : symbolFromModule || symbolFromVariable; if (!symbol) { - error(name, ts.Diagnostics.Module_0_has_no_exported_member_1, getFullyQualifiedName(moduleSymbol), ts.declarationNameToString(name)); + error(name_11, ts.Diagnostics.Module_0_has_no_exported_member_1, getFullyQualifiedName(moduleSymbol), ts.declarationNameToString(name_11)); } return symbol; } @@ -22367,7 +22559,6 @@ var ts; if (ambientModule) { return ambientModule; } - var isRelative = ts.isExternalModuleNameRelative(moduleReference); var resolvedModule = ts.getResolvedModule(ts.getSourceFileOfNode(location), moduleReference); var resolutionDiagnostic = resolvedModule && ts.getResolutionDiagnostic(compilerOptions, resolvedModule); var sourceFile = resolvedModule && !resolutionDiagnostic && host.getSourceFile(resolvedModule.resolvedFileName); @@ -22386,7 +22577,7 @@ var ts; return getMergedSymbol(pattern.symbol); } } - if (!isRelative && resolvedModule && !ts.extensionIsTypeScript(resolvedModule.extension)) { + if (resolvedModule && resolvedModule.isExternalLibraryImport && !ts.extensionIsTypeScript(resolvedModule.extension)) { if (isForAugmentation) { var diag = ts.Diagnostics.Invalid_module_name_in_augmentation_Module_0_resolves_to_an_untyped_module_at_1_which_cannot_be_augmented; error(errorNode, diag, moduleReference, resolvedModule.resolvedFileName); @@ -22609,19 +22800,19 @@ var ts; } function forEachSymbolTableInScope(enclosingDeclaration, callback) { var result; - for (var location = enclosingDeclaration; location; location = location.parent) { - if (location.locals && !isGlobalSourceFile(location)) { - if (result = callback(location.locals)) { + for (var location_1 = enclosingDeclaration; location_1; location_1 = location_1.parent) { + if (location_1.locals && !isGlobalSourceFile(location_1)) { + if (result = callback(location_1.locals)) { return result; } } - switch (location.kind) { + switch (location_1.kind) { case 265: - if (!ts.isExternalOrCommonJsModule(location)) { + if (!ts.isExternalOrCommonJsModule(location_1)) { break; } case 233: - if (result = callback(getSymbolOfNode(location).exports)) { + if (result = callback(getSymbolOfNode(location_1).exports)) { return result; } break; @@ -22721,6 +22912,10 @@ var ts; } return false; } + function isTypeSymbolAccessible(typeSymbol, enclosingDeclaration) { + var access = isSymbolAccessible(typeSymbol, enclosingDeclaration, 793064, false); + return access.accessibility === 0; + } function isSymbolAccessible(symbol, enclosingDeclaration, meaning, shouldComputeAliasesToMakeVisible) { if (symbol && enclosingDeclaration && !(symbol.flags & 262144)) { var initialSymbol = symbol; @@ -22776,7 +22971,7 @@ var ts; if (!isDeclarationVisible(declaration)) { var anyImportSyntax = getAnyImportSyntax(declaration); if (anyImportSyntax && - !(ts.getModifierFlags(anyImportSyntax) & 1) && + !ts.hasModifier(anyImportSyntax, 1) && isDeclarationVisible(anyImportSyntax.parent)) { if (shouldComputeAliasToMakeVisible) { getNodeLinks(declaration).isVisible = true; @@ -22927,8 +23122,8 @@ var ts; return ts.createTypeReferenceNode(enumLiteralName, undefined); } if (type.flags & 272) { - var name = symbolToName(type.symbol, context, 793064, false); - return ts.createTypeReferenceNode(name, undefined); + var name_12 = symbolToName(type.symbol, context, 793064, false); + return ts.createTypeReferenceNode(name_12, undefined); } if (type.flags & (32)) { return ts.createLiteralTypeNode(ts.setEmitFlags(ts.createLiteral(type.value), 16777216)); @@ -22971,14 +23166,13 @@ var ts; return typeReferenceToTypeNode(type); } if (type.flags & 16384 || objectFlags & 3) { - var name = symbolToName(type.symbol, context, 793064, false); - return ts.createTypeReferenceNode(name, undefined); + var name_13 = symbolToName(type.symbol, context, 793064, false); + return ts.createTypeReferenceNode(name_13, undefined); } - if (!inTypeAlias && type.aliasSymbol && - isSymbolAccessible(type.aliasSymbol, context.enclosingDeclaration, 793064, false).accessibility === 0) { - var name = symbolToTypeReferenceName(type.aliasSymbol); + if (!inTypeAlias && type.aliasSymbol && isTypeSymbolAccessible(type.aliasSymbol, context.enclosingDeclaration)) { + var name_14 = symbolToTypeReferenceName(type.aliasSymbol); var typeArgumentNodes = mapToTypeNodes(type.aliasTypeArguments, context); - return ts.createTypeReferenceNode(name, typeArgumentNodes); + return ts.createTypeReferenceNode(name_14, typeArgumentNodes); } if (type.flags & (65536 | 131072)) { var types = type.flags & 65536 ? formatUnionTypes(type.types) : type.types; @@ -23050,8 +23244,8 @@ var ts; return createTypeNodeFromObjectType(type); } function shouldWriteTypeOfFunctionSymbol() { - var isStaticMethodSymbol = !!(symbol.flags & 8192 && - ts.forEach(symbol.declarations, function (declaration) { return ts.getModifierFlags(declaration) & 32; })); + var isStaticMethodSymbol = !!(symbol.flags & 8192) && + ts.some(symbol.declarations, function (declaration) { return ts.hasModifier(declaration, 32); }); var isNonLocalFunctionSymbol = !!(symbol.flags & 16) && (symbol.parent || ts.forEach(symbol.declarations, function (declaration) { @@ -23063,10 +23257,8 @@ var ts; } } function createTypeNodeFromObjectType(type) { - if (type.objectFlags & 32) { - if (getConstraintTypeFromMappedType(type).flags & (16384 | 262144)) { - return createMappedTypeNodeFromType(type); - } + if (isGenericMappedType(type)) { + return createMappedTypeNodeFromType(type); } var resolved = resolveStructuredTypeMembers(type); if (!resolved.properties.length && !resolved.stringIndexInfo && !resolved.numberIndexInfo) { @@ -23130,14 +23322,14 @@ var ts; var length_2 = outerTypeParameters.length; while (i < length_2) { var start = i; - var parent = getParentSymbolOfTypeParameter(outerTypeParameters[i]); + var parent_7 = getParentSymbolOfTypeParameter(outerTypeParameters[i]); do { i++; - } while (i < length_2 && getParentSymbolOfTypeParameter(outerTypeParameters[i]) === parent); + } while (i < length_2 && getParentSymbolOfTypeParameter(outerTypeParameters[i]) === parent_7); if (!ts.rangeEquals(outerTypeParameters, typeArguments, start, i)) { var typeArgumentSlice = mapToTypeNodes(typeArguments.slice(start, i), context); var typeArgumentNodes_1 = typeArgumentSlice && ts.createNodeArray(typeArgumentSlice); - var namePart = symbolToTypeReferenceName(parent); + var namePart = symbolToTypeReferenceName(parent_7); (namePart.kind === 71 ? namePart : namePart.right).typeArguments = typeArgumentNodes_1; if (qualifiedName) { ts.Debug.assert(!qualifiedName.right); @@ -23367,11 +23559,11 @@ var ts; var parentSymbol; if (!accessibleSymbolChain || needsQualification(accessibleSymbolChain[0], context.enclosingDeclaration, accessibleSymbolChain.length === 1 ? meaning : getQualifiedLeftMeaning(meaning))) { - var parent = getParentOfSymbol(accessibleSymbolChain ? accessibleSymbolChain[0] : symbol); - if (parent) { - var parentChain = getSymbolChain(parent, getQualifiedLeftMeaning(meaning), false); + var parent_8 = getParentOfSymbol(accessibleSymbolChain ? accessibleSymbolChain[0] : symbol); + if (parent_8) { + var parentChain = getSymbolChain(parent_8, getQualifiedLeftMeaning(meaning), false); if (parentChain) { - parentSymbol = parent; + parentSymbol = parent_8; accessibleSymbolChain = parentChain.concat(accessibleSymbolChain || [symbol]); } } @@ -23389,9 +23581,9 @@ var ts; function getNameOfSymbol(symbol, context) { var declaration = ts.firstOrUndefined(symbol.declarations); if (declaration) { - var name = ts.getNameOfDeclaration(declaration); - if (name) { - return ts.declarationNameToString(name); + var name_15 = ts.getNameOfDeclaration(declaration); + if (name_15) { + return ts.declarationNameToString(name_15); } if (declaration.parent && declaration.parent.kind === 226) { return ts.declarationNameToString(declaration.parent.name); @@ -23471,9 +23663,9 @@ var ts; function getNameOfSymbol(symbol) { if (symbol.declarations && symbol.declarations.length) { var declaration = symbol.declarations[0]; - var name = ts.getNameOfDeclaration(declaration); - if (name) { - return ts.declarationNameToString(name); + var name_16 = ts.getNameOfDeclaration(declaration); + if (name_16) { + return ts.declarationNameToString(name_16); } if (declaration.parent && declaration.parent.kind === 226) { return ts.declarationNameToString(declaration.parent.name); @@ -23536,9 +23728,9 @@ var ts; var accessibleSymbolChain = getAccessibleSymbolChain(symbol, enclosingDeclaration, meaning, !!(flags & 2)); if (!accessibleSymbolChain || needsQualification(accessibleSymbolChain[0], enclosingDeclaration, accessibleSymbolChain.length === 1 ? meaning : getQualifiedLeftMeaning(meaning))) { - var parent = getParentOfSymbol(accessibleSymbolChain ? accessibleSymbolChain[0] : symbol); - if (parent) { - walkSymbol(parent, getQualifiedLeftMeaning(meaning), false); + var parent_9 = getParentOfSymbol(accessibleSymbolChain ? accessibleSymbolChain[0] : symbol); + if (parent_9) { + walkSymbol(parent_9, getQualifiedLeftMeaning(meaning), false); } } if (accessibleSymbolChain) { @@ -23583,9 +23775,9 @@ var ts; writeTypeReference(type, nextFlags); } else if (type.flags & 256 && !(type.flags & 65536)) { - var parent = getParentOfSymbol(type.symbol); - buildSymbolDisplay(parent, writer, enclosingDeclaration, 793064, 0, nextFlags); - if (getDeclaredTypeOfSymbol(parent) !== type) { + var parent_10 = getParentOfSymbol(type.symbol); + buildSymbolDisplay(parent_10, writer, enclosingDeclaration, 793064, 0, nextFlags); + if (getDeclaredTypeOfSymbol(parent_10) !== type) { writePunctuation(writer, 23); appendSymbolNameOnly(type.symbol, writer); } @@ -23594,7 +23786,7 @@ var ts; buildSymbolDisplay(type.symbol, writer, enclosingDeclaration, 793064, 0, nextFlags); } else if (!(flags & 1024) && type.aliasSymbol && - isSymbolAccessible(type.aliasSymbol, enclosingDeclaration, 793064, false).accessibility === 0) { + ((flags & 65536) || isTypeSymbolAccessible(type.aliasSymbol, enclosingDeclaration))) { var typeArguments = type.aliasTypeArguments; writeSymbolTypeReference(type.aliasSymbol, typeArguments, 0, ts.length(typeArguments), nextFlags); } @@ -23685,12 +23877,12 @@ var ts; var length_3 = outerTypeParameters.length; while (i < length_3) { var start = i; - var parent = getParentSymbolOfTypeParameter(outerTypeParameters[i]); + var parent_11 = getParentSymbolOfTypeParameter(outerTypeParameters[i]); do { i++; - } while (i < length_3 && getParentSymbolOfTypeParameter(outerTypeParameters[i]) === parent); + } while (i < length_3 && getParentSymbolOfTypeParameter(outerTypeParameters[i]) === parent_11); if (!ts.rangeEquals(outerTypeParameters, typeArguments, start, i)) { - writeSymbolTypeReference(parent, typeArguments, start, i, flags); + writeSymbolTypeReference(parent_11, typeArguments, start, i, flags); writePunctuation(writer, 23); } } @@ -23738,9 +23930,7 @@ var ts; if (!symbolStack) { symbolStack = []; } - var isConstructorObject = type.flags & 32768 && - getObjectFlags(type) & 16 && - type.symbol && type.symbol.flags & 32; + var isConstructorObject = type.objectFlags & 16 && type.symbol && type.symbol.flags & 32; if (isConstructorObject) { writeLiteralType(type, flags); } @@ -23755,16 +23945,16 @@ var ts; writeLiteralType(type, flags); } function shouldWriteTypeOfFunctionSymbol() { - var isStaticMethodSymbol = !!(symbol.flags & 8192 && - ts.forEach(symbol.declarations, function (declaration) { return ts.getModifierFlags(declaration) & 32; })); + var isStaticMethodSymbol = !!(symbol.flags & 8192) && + ts.some(symbol.declarations, function (declaration) { return ts.hasModifier(declaration, 32); }); var isNonLocalFunctionSymbol = !!(symbol.flags & 16) && (symbol.parent || - ts.forEach(symbol.declarations, function (declaration) { + ts.some(symbol.declarations, function (declaration) { return declaration.parent.kind === 265 || declaration.parent.kind === 234; })); if (isStaticMethodSymbol || isNonLocalFunctionSymbol) { return !!(flags & 4) || - (ts.contains(symbolStack, symbol)); + ts.contains(symbolStack, symbol); } } } @@ -23801,11 +23991,9 @@ var ts; return false; } function writeLiteralType(type, flags) { - if (type.objectFlags & 32) { - if (getConstraintTypeFromMappedType(type).flags & (16384 | 262144)) { - writeMappedType(type); - return; - } + if (isGenericMappedType(type)) { + writeMappedType(type); + return; } var resolved = resolveStructuredTypeMembers(type); if (!resolved.properties.length && !resolved.stringIndexInfo && !resolved.numberIndexInfo) { @@ -24161,19 +24349,19 @@ var ts; if (ts.isExternalModuleAugmentation(node)) { return true; } - var parent = getDeclarationContainer(node); + var parent_12 = getDeclarationContainer(node); if (!(ts.getCombinedModifierFlags(node) & 1) && - !(node.kind !== 237 && parent.kind !== 265 && ts.isInAmbientContext(parent))) { - return isGlobalSourceFile(parent); + !(node.kind !== 237 && parent_12.kind !== 265 && ts.isInAmbientContext(parent_12))) { + return isGlobalSourceFile(parent_12); } - return isDeclarationVisible(parent); + return isDeclarationVisible(parent_12); case 149: case 148: case 153: case 154: case 151: case 150: - if (ts.getModifierFlags(node) & (8 | 16)) { + if (ts.hasModifier(node, 8 | 16)) { return false; } case 152: @@ -24328,8 +24516,8 @@ var ts; var members = ts.createSymbolTable(); var names = ts.createUnderscoreEscapedMap(); for (var _i = 0, properties_2 = properties; _i < properties_2.length; _i++) { - var name = properties_2[_i]; - names.set(ts.getTextOfPropertyName(name), true); + var name_17 = properties_2[_i]; + names.set(ts.getTextOfPropertyName(name_17), true); } for (var _a = 0, _b = getPropertiesOfType(source); _a < _b.length; _a++) { var prop = _b[_a]; @@ -24373,20 +24561,20 @@ var ts; type = getRestType(parentType, literalMembers, declaration.symbol); } else { - var name = declaration.propertyName || declaration.name; - if (isComputedNonLiteralName(name)) { + var name_18 = declaration.propertyName || declaration.name; + if (isComputedNonLiteralName(name_18)) { return anyType; } if (declaration.initializer) { getContextualType(declaration.initializer); } - var text = ts.getTextOfPropertyName(name); + var text = ts.getTextOfPropertyName(name_18); var declaredType = getTypeOfPropertyOfType(parentType, text); type = declaredType && getFlowTypeOfReference(declaration, declaredType) || isNumericLiteralName(text) && getIndexTypeOfType(parentType, 1) || getIndexTypeOfType(parentType, 0); if (!type) { - error(name, ts.Diagnostics.Type_0_has_no_property_1_and_no_string_index_signature, typeToString(parentType), ts.declarationNameToString(name)); + error(name_18, ts.Diagnostics.Type_0_has_no_property_1_and_no_string_index_signature, typeToString(parentType), ts.declarationNameToString(name_18)); return unknownType; } } @@ -24532,8 +24720,8 @@ var ts; jsDocType = declarationType; } else if (jsDocType !== unknownType && declarationType !== unknownType && !isTypeIdenticalTo(jsDocType, declarationType)) { - var name = ts.getNameOfDeclaration(declaration); - error(name, ts.Diagnostics.Subsequent_variable_declarations_must_have_the_same_type_Variable_0_must_be_of_type_1_but_here_has_type_2, ts.declarationNameToString(name), typeToString(jsDocType), typeToString(declarationType)); + var name_19 = ts.getNameOfDeclaration(declaration); + error(name_19, ts.Diagnostics.Subsequent_variable_declarations_must_have_the_same_type_Variable_0_must_be_of_type_1_but_here_has_type_2, ts.declarationNameToString(name_19), typeToString(jsDocType), typeToString(declarationType)); } } else if (!jsDocType) { @@ -24850,8 +25038,8 @@ var ts; } } function appendTypeParameters(typeParameters, declarations) { - for (var _i = 0, declarations_3 = declarations; _i < declarations_3.length; _i++) { - var declaration = declarations_3[_i]; + for (var _i = 0, declarations_2 = declarations; _i < declarations_2.length; _i++) { + var declaration = declarations_2[_i]; var tp = getDeclaredTypeOfTypeParameter(getSymbolOfNode(declaration)); if (!typeParameters) { typeParameters = [tp]; @@ -24975,7 +25163,7 @@ var ts; return type.resolvedBaseTypes; } function resolveBaseTypesOfClass(type) { - type.resolvedBaseTypes = type.resolvedBaseTypes || ts.emptyArray; + type.resolvedBaseTypes = ts.emptyArray; var baseConstructorType = getApparentType(getBaseConstructorTypeOfClass(type)); if (!(baseConstructorType.flags & (32768 | 131072 | 1))) { return; @@ -25017,12 +25205,7 @@ var ts; error(valueDecl, ts.Diagnostics.Type_0_recursively_references_itself_as_a_base_type, typeToString(type, undefined, 1)); return; } - if (type.resolvedBaseTypes === ts.emptyArray) { - type.resolvedBaseTypes = [baseType]; - } - else { - type.resolvedBaseTypes.push(baseType); - } + type.resolvedBaseTypes = [baseType]; } function areAllOuterTypeParametersApplied(type) { var outerTypeParameters = type.outerTypeParameters; @@ -25120,7 +25303,9 @@ var ts; if (!pushTypeResolution(symbol, 2)) { return unknownType; } - var declaration = ts.findDeclaration(symbol, function (d) { return d.kind === 283 || d.kind === 231; }); + var declaration = ts.find(symbol.declarations, function (d) { + return d.kind === 283 || d.kind === 231; + }); var type = getTypeFromTypeNode(declaration.kind === 283 ? declaration.typeExpression : declaration.type); if (popTypeResolution()) { var typeParameters = getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol); @@ -25612,17 +25797,12 @@ var ts; } else { var members = emptySymbols; - var constructSignatures = ts.emptyArray; var stringIndexInfo = undefined; if (symbol.exports) { members = getExportsOfSymbol(symbol); } if (symbol.flags & 32) { var classType = getDeclaredTypeOfClassOrInterface(symbol); - constructSignatures = getSignaturesOfSymbol(symbol.members.get("__constructor")); - if (!constructSignatures.length) { - constructSignatures = getDefaultConstructSignatures(classType); - } var baseConstructorType = getBaseConstructorTypeOfClass(classType); if (baseConstructorType.flags & (32768 | 131072 | 540672)) { members = ts.createSymbolTable(getNamedMembers(members)); @@ -25633,10 +25813,18 @@ var ts; } } var numberIndexInfo = symbol.flags & 384 ? enumNumberIndexInfo : undefined; - setStructuredTypeMembers(type, members, ts.emptyArray, constructSignatures, stringIndexInfo, numberIndexInfo); + setStructuredTypeMembers(type, members, ts.emptyArray, ts.emptyArray, stringIndexInfo, numberIndexInfo); if (symbol.flags & (16 | 8192)) { type.callSignatures = getSignaturesOfSymbol(symbol); } + if (symbol.flags & 32) { + var classType = getDeclaredTypeOfClassOrInterface(symbol); + var constructSignatures = getSignaturesOfSymbol(symbol.members.get("__constructor")); + if (!constructSignatures.length) { + constructSignatures = getDefaultConstructSignatures(classType); + } + type.constructSignatures = constructSignatures; + } } } function resolveMappedTypeMembers(type) { @@ -25719,8 +25907,7 @@ var ts; return getObjectFlags(type) & 32 && !!type.declaration.questionToken; } function isGenericMappedType(type) { - return getObjectFlags(type) & 32 && - maybeTypeOfKind(getConstraintTypeFromMappedType(type), 540672 | 262144); + return getObjectFlags(type) & 32 && isGenericIndexType(getConstraintTypeFromMappedType(type)); } function resolveStructuredTypeMembers(type) { if (!type.members) { @@ -25820,6 +26007,10 @@ var ts; return hasNonCircularBaseConstraint(typeParameter) ? getConstraintFromTypeParameter(typeParameter) : undefined; } function getConstraintOfIndexedAccess(type) { + var transformed = getTransformedIndexedAccessType(type); + if (transformed) { + return transformed; + } var baseObjectType = getBaseConstraintOfType(type.objectType); var baseIndexType = getBaseConstraintOfType(type.indexType); return baseObjectType || baseIndexType ? getIndexedAccessType(baseObjectType || type.objectType, baseIndexType || type.indexType) : undefined; @@ -25882,11 +26073,18 @@ var ts; return stringType; } if (t.flags & 524288) { + var transformed = getTransformedIndexedAccessType(t); + if (transformed) { + return getBaseConstraint(transformed); + } var baseObjectType = getBaseConstraint(t.objectType); var baseIndexType = getBaseConstraint(t.indexType); var baseIndexedAccess = baseObjectType && baseIndexType ? getIndexedAccessType(baseObjectType, baseIndexType) : undefined; return baseIndexedAccess && baseIndexedAccess !== unknownType ? getBaseConstraint(baseIndexedAccess) : undefined; } + if (isGenericMappedType(t)) { + return emptyObjectType; + } return t; } } @@ -26353,9 +26551,9 @@ var ts; type = anyType; if (noImplicitAny) { var declaration = signature.declaration; - var name = ts.getNameOfDeclaration(declaration); - if (name) { - error(name, ts.Diagnostics._0_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_referenced_directly_or_indirectly_in_one_of_its_return_expressions, ts.declarationNameToString(name)); + var name_20 = ts.getNameOfDeclaration(declaration); + if (name_20) { + error(name_20, ts.Diagnostics._0_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_referenced_directly_or_indirectly_in_one_of_its_return_expressions, ts.declarationNameToString(name_20)); } else { error(declaration, ts.Diagnostics.Function_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_referenced_directly_or_indirectly_in_one_of_its_return_expressions); @@ -26366,6 +26564,9 @@ var ts; } return signature.resolvedReturnType; } + function isResolvingReturnTypeOfSignature(signature) { + return !signature.resolvedReturnType && findResolutionCycleStartIndex(signature, 3) >= 0; + } function getRestTypeOfSignature(signature) { if (signature.hasRestParameter) { var type = getTypeOfSymbol(ts.lastOrUndefined(signature.parameters)); @@ -26434,7 +26635,7 @@ var ts; function getIndexInfoOfSymbol(symbol, kind) { var declaration = getIndexDeclarationOfSymbol(symbol, kind); if (declaration) { - return createIndexInfo(declaration.type ? getTypeFromTypeNode(declaration.type) : anyType, (ts.getModifierFlags(declaration) & 64) !== 0, declaration); + return createIndexInfo(declaration.type ? getTypeFromTypeNode(declaration.type) : anyType, ts.hasModifier(declaration, 64), declaration); } return undefined; } @@ -26702,8 +26903,8 @@ var ts; function getTypeOfGlobalSymbol(symbol, arity) { function getTypeDeclaration(symbol) { var declarations = symbol.declarations; - for (var _i = 0, declarations_4 = declarations; _i < declarations_4.length; _i++) { - var declaration = declarations_4[_i]; + for (var _i = 0, declarations_3 = declarations; _i < declarations_3.length; _i++) { + var declaration = declarations_3[_i]; switch (declaration.kind) { case 229: case 230: @@ -27160,17 +27361,16 @@ var ts; return getTypeOfSymbol(prop); } } - if (isTypeAnyOrAllConstituentTypesHaveKind(indexType, 262178 | 84 | 512)) { + if (!(indexType.flags & 6144) && isTypeAssignableToKind(indexType, 262178 | 84 | 512)) { if (isTypeAny(objectType)) { return anyType; } - var indexInfo = isTypeAnyOrAllConstituentTypesHaveKind(indexType, 84) && getIndexInfoOfType(objectType, 1) || + var indexInfo = isTypeAssignableToKind(indexType, 84) && getIndexInfoOfType(objectType, 1) || getIndexInfoOfType(objectType, 0) || undefined; if (indexInfo) { if (accessExpression && indexInfo.isReadonly && (ts.isAssignmentTarget(accessExpression) || ts.isDeleteTarget(accessExpression))) { error(accessExpression, ts.Diagnostics.Index_signature_in_type_0_only_permits_reading, typeToString(objectType)); - return unknownType; } return indexInfo.type; } @@ -27202,25 +27402,68 @@ var ts; return anyType; } function getIndexedAccessForMappedType(type, indexType, accessNode) { - var accessExpression = accessNode && accessNode.kind === 180 ? accessNode : undefined; - if (accessExpression && ts.isAssignmentTarget(accessExpression) && type.declaration.readonlyToken) { - error(accessExpression, ts.Diagnostics.Index_signature_in_type_0_only_permits_reading, typeToString(type)); - return unknownType; + if (accessNode) { + if (!isTypeAssignableTo(indexType, getIndexType(type))) { + error(accessNode, ts.Diagnostics.Type_0_cannot_be_used_to_index_type_1, typeToString(indexType), typeToString(type)); + return unknownType; + } + if (accessNode.kind === 180 && ts.isAssignmentTarget(accessNode) && type.declaration.readonlyToken) { + error(accessNode, ts.Diagnostics.Index_signature_in_type_0_only_permits_reading, typeToString(type)); + } } var mapper = createTypeMapper([getTypeParameterFromMappedType(type)], [indexType]); var templateMapper = type.mapper ? combineTypeMappers(type.mapper, mapper) : mapper; return instantiateType(getTemplateTypeFromMappedType(type), templateMapper); } + function isGenericObjectType(type) { + return type.flags & 540672 ? true : + getObjectFlags(type) & 32 ? isGenericIndexType(getConstraintTypeFromMappedType(type)) : + type.flags & 196608 ? ts.forEach(type.types, isGenericObjectType) : + false; + } + function isGenericIndexType(type) { + return type.flags & (540672 | 262144) ? true : + type.flags & 196608 ? ts.forEach(type.types, isGenericIndexType) : + false; + } + function isStringIndexOnlyType(type) { + if (type.flags & 32768 && !isGenericMappedType(type)) { + var t = resolveStructuredTypeMembers(type); + return t.properties.length === 0 && + t.callSignatures.length === 0 && t.constructSignatures.length === 0 && + t.stringIndexInfo && !t.numberIndexInfo; + } + return false; + } + function getTransformedIndexedAccessType(type) { + var objectType = type.objectType; + if (objectType.flags & 131072 && isGenericObjectType(objectType) && ts.some(objectType.types, isStringIndexOnlyType)) { + var regularTypes = []; + var stringIndexTypes = []; + for (var _i = 0, _a = objectType.types; _i < _a.length; _i++) { + var t = _a[_i]; + if (isStringIndexOnlyType(t)) { + stringIndexTypes.push(getIndexTypeOfType(t, 0)); + } + else { + regularTypes.push(t); + } + } + return getUnionType([ + getIndexedAccessType(getIntersectionType(regularTypes), type.indexType), + getIntersectionType(stringIndexTypes) + ]); + } + return undefined; + } function getIndexedAccessType(objectType, indexType, accessNode) { - if (maybeTypeOfKind(indexType, 540672 | 262144) || - maybeTypeOfKind(objectType, 540672) && !(accessNode && accessNode.kind === 180) || - isGenericMappedType(objectType)) { + if (isGenericMappedType(objectType)) { + return getIndexedAccessForMappedType(objectType, indexType, accessNode); + } + if (isGenericIndexType(indexType) || !(accessNode && accessNode.kind === 180) && isGenericObjectType(objectType)) { if (objectType.flags & 1) { return objectType; } - if (isGenericMappedType(objectType)) { - return getIndexedAccessForMappedType(objectType, indexType, accessNode); - } var id = objectType.id + "," + indexType.id; var type = indexedAccessTypes.get(id); if (!type) { @@ -27419,7 +27662,7 @@ var ts; var container = ts.getThisContainer(node, false); var parent = container && container.parent; if (parent && (ts.isClassLike(parent) || parent.kind === 230)) { - if (!(ts.getModifierFlags(container) & 32) && + if (!ts.hasModifier(container, 32) && (container.kind !== 152 || ts.isNodeDescendantOf(node, container.body))) { return getDeclaredTypeOfClassOrInterface(getSymbolOfNode(parent)).thisType; } @@ -27566,7 +27809,7 @@ var ts; } function cloneTypeMapper(mapper) { return mapper && isInferenceContext(mapper) ? - createInferenceContext(mapper.signature, mapper.flags | 2, mapper.inferences) : + createInferenceContext(mapper.signature, mapper.flags | 2, mapper.compareTypes, mapper.inferences) : mapper; } function identityMapper(type) { @@ -27830,11 +28073,13 @@ var ts; if (ts.forEach(node.parameters, function (p) { return !ts.getEffectiveTypeAnnotationNode(p); })) { return true; } - if (node.kind === 187) { - return false; + if (node.kind !== 187) { + var parameter = ts.firstOrUndefined(node.parameters); + if (!(parameter && ts.parameterIsThisKeyword(parameter))) { + return true; + } } - var parameter = ts.firstOrUndefined(node.parameters); - return !(parameter && ts.parameterIsThisKeyword(parameter)); + return node.body.kind === 207 ? false : isContextSensitive(node.body); } function isContextSensitiveFunctionOrObjectLiteralMethod(func) { return (isFunctionExpressionOrArrowFunction(func) || ts.isObjectLiteralMethod(func)) && isContextSensitiveFunctionLikeDeclaration(func); @@ -27897,7 +28142,7 @@ var ts; return 0; } if (source.typeParameters) { - source = instantiateSignatureInContextOf(source, target); + source = instantiateSignatureInContextOf(source, target, undefined, compareTypes); } var result = -1; var sourceThisType = getThisTypeOfSignature(source); @@ -27946,7 +28191,7 @@ var ts; var sourceReturnType = getReturnTypeOfSignature(source); if (target.typePredicate) { if (source.typePredicate) { - result &= compareTypePredicateRelatedTo(source.typePredicate, target.typePredicate, reportErrors, errorReporter, compareTypes); + result &= compareTypePredicateRelatedTo(source.typePredicate, target.typePredicate, source.declaration, target.declaration, reportErrors, errorReporter, compareTypes); } else if (ts.isIdentifierTypePredicate(target.typePredicate)) { if (reportErrors) { @@ -27962,7 +28207,7 @@ var ts; } return result; } - function compareTypePredicateRelatedTo(source, target, reportErrors, errorReporter, compareTypes) { + function compareTypePredicateRelatedTo(source, target, sourceDeclaration, targetDeclaration, reportErrors, errorReporter, compareTypes) { if (source.kind !== target.kind) { if (reportErrors) { errorReporter(ts.Diagnostics.A_this_based_type_guard_is_not_compatible_with_a_parameter_based_type_guard); @@ -27971,11 +28216,13 @@ var ts; return 0; } if (source.kind === 1) { - var sourceIdentifierPredicate = source; - var targetIdentifierPredicate = target; - if (sourceIdentifierPredicate.parameterIndex !== targetIdentifierPredicate.parameterIndex) { + var sourcePredicate = source; + var targetPredicate = target; + var sourceIndex = sourcePredicate.parameterIndex - (ts.getThisParameter(sourceDeclaration) ? 1 : 0); + var targetIndex = targetPredicate.parameterIndex - (ts.getThisParameter(targetDeclaration) ? 1 : 0); + if (sourceIndex !== targetIndex) { if (reportErrors) { - errorReporter(ts.Diagnostics.Parameter_0_is_not_in_the_same_position_as_parameter_1, sourceIdentifierPredicate.parameterName, targetIdentifierPredicate.parameterName); + errorReporter(ts.Diagnostics.Parameter_0_is_not_in_the_same_position_as_parameter_1, sourcePredicate.parameterName, targetPredicate.parameterName); errorReporter(ts.Diagnostics.Type_predicate_0_is_not_assignable_to_1, typePredicateToString(source), typePredicateToString(target)); } return 0; @@ -28120,8 +28367,7 @@ var ts; return true; } if (source.flags & 32768 && target.flags & 32768) { - var id = relation !== identityRelation || source.id < target.id ? source.id + "," + target.id : target.id + "," + source.id; - var related = relation.get(id); + var related = relation.get(getRelationKey(source, target, relation)); if (related !== undefined) { return related === 1; } @@ -28234,11 +28480,21 @@ var ts; !(target.flags & 65536) && !isIntersectionConstituent && source !== globalObjectType && - getPropertiesOfType(source).length > 0 && + (getPropertiesOfType(source).length > 0 || + getSignaturesOfType(source, 0).length > 0 || + getSignaturesOfType(source, 1).length > 0) && isWeakType(target) && !hasCommonProperties(source, target)) { if (reportErrors) { - reportError(ts.Diagnostics.Type_0_has_no_properties_in_common_with_type_1, typeToString(source), typeToString(target)); + var calls = getSignaturesOfType(source, 0); + var constructs = getSignaturesOfType(source, 1); + if (calls.length > 0 && isRelatedTo(getReturnTypeOfSignature(calls[0]), target, false) || + constructs.length > 0 && isRelatedTo(getReturnTypeOfSignature(constructs[0]), target, false)) { + reportError(ts.Diagnostics.Value_of_type_0_has_no_properties_in_common_with_type_1_Did_you_mean_to_call_it, typeToString(source), typeToString(target)); + } + else { + reportError(ts.Diagnostics.Type_0_has_no_properties_in_common_with_type_1, typeToString(source), typeToString(target)); + } } return 0; } @@ -28439,7 +28695,7 @@ var ts; if (overflow) { return 0; } - var id = relation !== identityRelation || source.id < target.id ? source.id + "," + target.id : target.id + "," + source.id; + var id = getRelationKey(source, target, relation); var related = relation.get(id); if (related !== undefined) { if (reportErrors && related === 2) { @@ -28859,6 +29115,9 @@ var ts; if (sourceInfo) { return indexInfoRelatedTo(sourceInfo, targetInfo, reportErrors); } + if (isGenericMappedType(source)) { + return kind === 0 && isRelatedTo(getTemplateTypeFromMappedType(source), targetInfo.type, reportErrors); + } if (isObjectLiteralType(source)) { var related = -1; if (kind === 0) { @@ -28892,8 +29151,8 @@ var ts; if (!sourceSignature.declaration || !targetSignature.declaration) { return true; } - var sourceAccessibility = ts.getModifierFlags(sourceSignature.declaration) & 24; - var targetAccessibility = ts.getModifierFlags(targetSignature.declaration) & 24; + var sourceAccessibility = ts.getSelectedModifierFlags(sourceSignature.declaration, 24); + var targetAccessibility = ts.getSelectedModifierFlags(targetSignature.declaration, 24); if (targetAccessibility === 8) { return true; } @@ -28909,6 +29168,42 @@ var ts; return false; } } + function isUnconstrainedTypeParameter(type) { + return type.flags & 16384 && !getConstraintFromTypeParameter(type); + } + function isTypeReferenceWithGenericArguments(type) { + return getObjectFlags(type) & 4 && ts.some(type.typeArguments, isUnconstrainedTypeParameter); + } + function getTypeReferenceId(type, typeParameters) { + var result = "" + type.target.id; + for (var _i = 0, _a = type.typeArguments; _i < _a.length; _i++) { + var t = _a[_i]; + if (isUnconstrainedTypeParameter(t)) { + var index = ts.indexOf(typeParameters, t); + if (index < 0) { + index = typeParameters.length; + typeParameters.push(t); + } + result += "=" + index; + } + else { + result += "-" + t.id; + } + } + return result; + } + function getRelationKey(source, target, relation) { + if (relation === identityRelation && source.id > target.id) { + var temp = source; + source = target; + target = temp; + } + if (isTypeReferenceWithGenericArguments(source) && isTypeReferenceWithGenericArguments(target)) { + var typeParameters = []; + return getTypeReferenceId(source, typeParameters) + "," + getTypeReferenceId(target, typeParameters); + } + return source.id + "," + target.id; + } function forEachProperty(prop, callback) { if (ts.getCheckFlags(prop) & 6) { for (var _i = 0, _a = prop.containingType.types; _i < _a.length; _i++) { @@ -28945,7 +29240,7 @@ var ts; var symbol = type.symbol; if (symbol && symbol.flags & 32) { var declaration = getClassLikeDeclarationOfSymbol(symbol); - if (declaration && ts.getModifierFlags(declaration) & 128) { + if (declaration && ts.hasModifier(declaration, 128)) { return true; } } @@ -29331,13 +29626,14 @@ var ts; callback(getTypeAtPosition(source, i), getTypeAtPosition(target, i)); } } - function createInferenceContext(signature, flags, baseInferences) { + function createInferenceContext(signature, flags, compareTypes, baseInferences) { var inferences = baseInferences ? ts.map(baseInferences, cloneInferenceInfo) : ts.map(signature.typeParameters, createInferenceInfo); var context = mapper; context.mappedTypes = signature.typeParameters; context.signature = signature; context.inferences = inferences; context.flags = flags; + context.compareTypes = compareTypes || compareTypesAssignable; return context; function mapper(t) { for (var i = 0; i < inferences.length; i++) { @@ -29425,6 +29721,19 @@ var ts; return inference.candidates && getUnionType(inference.candidates, true); } } + function isPossiblyAssignableTo(source, target) { + var properties = getPropertiesOfObjectType(target); + for (var _i = 0, properties_5 = properties; _i < properties_5.length; _i++) { + var targetProp = properties_5[_i]; + if (!(targetProp.flags & (16777216 | 4194304))) { + var sourceProp = getPropertyOfObjectType(source, targetProp.escapedName); + if (!sourceProp) { + return false; + } + } + } + return true; + } function inferTypes(inferences, originalSource, originalTarget, priority) { if (priority === void 0) { priority = 0; } var symbolStack; @@ -29585,15 +29894,17 @@ var ts; return; } } - inferFromProperties(source, target); - inferFromSignatures(source, target, 0); - inferFromSignatures(source, target, 1); - inferFromIndexTypes(source, target); + if (isPossiblyAssignableTo(source, target) || isPossiblyAssignableTo(target, source)) { + inferFromProperties(source, target); + inferFromSignatures(source, target, 0); + inferFromSignatures(source, target, 1); + inferFromIndexTypes(source, target); + } } function inferFromProperties(source, target) { var properties = getPropertiesOfObjectType(target); - for (var _i = 0, properties_5 = properties; _i < properties_5.length; _i++) { - var targetProp = properties_5[_i]; + for (var _i = 0, properties_6 = properties; _i < properties_6.length; _i++) { + var targetProp = properties_6[_i]; var sourceProp = getPropertyOfObjectType(source, targetProp.escapedName); if (sourceProp) { inferFromTypes(getTypeOfSymbol(sourceProp), getTypeOfSymbol(targetProp)); @@ -29692,7 +30003,7 @@ var ts; var constraint = getConstraintOfTypeParameter(context.signature.typeParameters[index]); if (constraint) { var instantiatedConstraint = instantiateType(constraint, context); - if (!isTypeAssignableTo(inferredType, getTypeWithThisArgument(instantiatedConstraint, inferredType))) { + if (!context.compareTypes(inferredType, getTypeWithThisArgument(instantiatedConstraint, inferredType))) { inference.inferredType = inferredType = instantiatedConstraint; } } @@ -29740,27 +30051,17 @@ var ts; } return undefined; } - function getLeftmostIdentifierOrThis(node) { - switch (node.kind) { - case 71: - case 99: - return node; - case 179: - return getLeftmostIdentifierOrThis(node.expression); - } - return undefined; - } function getBindingElementNameText(element) { if (element.parent.kind === 174) { - var name = element.propertyName || element.name; - switch (name.kind) { + var name_21 = element.propertyName || element.name; + switch (name_21.kind) { case 71: - return ts.unescapeLeadingUnderscores(name.escapedText); + return ts.unescapeLeadingUnderscores(name_21.escapedText); case 144: - return ts.isStringOrNumericLiteral(name.expression) ? name.expression.text : undefined; + return ts.isStringOrNumericLiteral(name_21.expression) ? name_21.expression.text : undefined; case 9: case 8: - return name.text; + return name_21.text; default: ts.Debug.fail("Unexpected name kind for binding element name"); } @@ -30241,7 +30542,7 @@ var ts; parent.parent.operatorToken.kind === 58 && parent.parent.left === parent && !ts.isAssignmentTarget(parent.parent) && - isTypeAnyOrAllConstituentTypesHaveKind(getTypeOfExpression(parent.argumentExpression), 84 | 2048); + isTypeAssignableToKind(getTypeOfExpression(parent.argumentExpression), 84); return isLengthPushOrUnshift || isElementAssignment; } function maybeTypePredicateCall(node) { @@ -30387,7 +30688,7 @@ var ts; } else { var indexType = getTypeOfExpression(node.left.argumentExpression); - if (isTypeAnyOrAllConstituentTypesHaveKind(indexType, 84 | 2048)) { + if (isTypeAssignableToKind(indexType, 84)) { evolvedType_1 = addEvolvingArrayElementType(evolvedType_1, node.right); } } @@ -31073,7 +31374,7 @@ var ts; break; case 149: case 148: - if (ts.getModifierFlags(container) & 32) { + if (ts.hasModifier(container, 32)) { error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_static_property_initializer); } break; @@ -31164,14 +31465,14 @@ var ts; if (!isCallExpression && container.kind === 152) { checkThisBeforeSuper(node, container, ts.Diagnostics.super_must_be_called_before_accessing_a_property_of_super_in_the_constructor_of_a_derived_class); } - if ((ts.getModifierFlags(container) & 32) || isCallExpression) { + if (ts.hasModifier(container, 32) || isCallExpression) { nodeCheckFlag = 512; } else { nodeCheckFlag = 256; } getNodeLinks(node).flags |= nodeCheckFlag; - if (container.kind === 151 && ts.getModifierFlags(container) & 256) { + if (container.kind === 151 && ts.hasModifier(container, 256)) { if (ts.isSuperProperty(node.parent) && ts.isAssignmentTarget(node.parent)) { getNodeLinks(container).flags |= 4096; } @@ -31216,7 +31517,7 @@ var ts; } else { if (ts.isClassLike(container.parent) || container.parent.kind === 178) { - if (ts.getModifierFlags(container) & 32) { + if (ts.hasModifier(container, 32)) { return container.kind === 151 || container.kind === 150 || container.kind === 153 || @@ -31349,11 +31650,11 @@ var ts; } if (ts.isBindingPattern(declaration.parent)) { var parentDeclaration = declaration.parent.parent; - var name = declaration.propertyName || declaration.name; + var name_22 = declaration.propertyName || declaration.name; if (parentDeclaration.kind !== 176) { var parentTypeNode = ts.getEffectiveTypeAnnotationNode(parentDeclaration); - if (parentTypeNode && !ts.isBindingPattern(name)) { - var text = ts.getTextOfPropertyName(name); + if (parentTypeNode && !ts.isBindingPattern(name_22)) { + var text = ts.getTextOfPropertyName(name_22); if (text) { return getTypeOfPropertyOfType(getTypeFromTypeNode(parentTypeNode), text); } @@ -31406,7 +31707,7 @@ var ts; return getReturnTypeOfSignature(getSignatureFromDeclaration(functionDecl)); } var signature = getContextualSignatureForFunctionLikeDeclaration(functionDecl); - if (signature) { + if (signature && !isResolvingReturnTypeOfSignature(signature)) { return getReturnTypeOfSignature(signature); } return undefined; @@ -31510,11 +31811,11 @@ var ts; return undefined; } if (ts.isJsxAttribute(node.parent)) { - return getTypeOfPropertyOfType(attributesType, node.parent.name.escapedText); + return getTypeOfPropertyOfContextualType(attributesType, node.parent.name.escapedText); } else if (node.parent.kind === 249) { var jsxChildrenPropertyName = getJsxElementChildrenPropertyname(); - return jsxChildrenPropertyName && jsxChildrenPropertyName !== "" ? getTypeOfPropertyOfType(attributesType, jsxChildrenPropertyName) : anyType; + return jsxChildrenPropertyName && jsxChildrenPropertyName !== "" ? getTypeOfPropertyOfContextualType(attributesType, jsxChildrenPropertyName) : anyType; } else { return attributesType; @@ -31526,7 +31827,7 @@ var ts; if (!attributesType || isTypeAny(attributesType)) { return undefined; } - return getTypeOfPropertyOfType(attributesType, attribute.name.escapedText); + return getTypeOfPropertyOfContextualType(attributesType, attribute.name.escapedText); } else { return attributesType; @@ -31742,10 +32043,7 @@ var ts; } } function isNumericComputedName(name) { - return isTypeAnyOrAllConstituentTypesHaveKind(checkComputedPropertyName(name), 84); - } - function isTypeAnyOrAllConstituentTypesHaveKind(type, kind) { - return isTypeAny(type) || isTypeOfKind(type, kind); + return isTypeAssignableToKind(checkComputedPropertyName(name), 84); } function isInfinityOrNaNString(name) { return name === "Infinity" || name === "-Infinity" || name === "NaN"; @@ -31757,7 +32055,9 @@ var ts; var links = getNodeLinks(node.expression); if (!links.resolvedType) { links.resolvedType = checkExpression(node.expression); - if (!isTypeAnyOrAllConstituentTypesHaveKind(links.resolvedType, 84 | 262178 | 512)) { + if (links.resolvedType.flags & 6144 || + !isTypeAssignableToKind(links.resolvedType, 262178 | 84 | 512) && + !isTypeAssignableTo(links.resolvedType, getUnionType([stringType, numberType, esSymbolType]))) { error(node, ts.Diagnostics.A_computed_property_name_must_be_of_type_string_number_symbol_or_any); } else { @@ -32242,9 +32542,7 @@ var ts; return undefined; } function resolveCustomJsxElementAttributesType(openingLikeElement, shouldIncludeAllStatelessAttributesType, elementType, elementClassType) { - if (!elementType) { - elementType = checkExpression(openingLikeElement.tagName); - } + if (elementType === void 0) { elementType = checkExpression(openingLikeElement.tagName); } if (elementType.flags & 65536) { var types = elementType.types; return getUnionType(types.map(function (type) { @@ -32339,11 +32637,12 @@ var ts; } function getCustomJsxElementAttributesType(node, shouldIncludeAllStatelessAttributesType) { var links = getNodeLinks(node); - if (!links.resolvedJsxElementAttributesType) { + var linkLocation = shouldIncludeAllStatelessAttributesType ? "resolvedJsxElementAllAttributesType" : "resolvedJsxElementAttributesType"; + if (!links[linkLocation]) { var elemClassType = getJsxGlobalElementClassType(); - return links.resolvedJsxElementAttributesType = resolveCustomJsxElementAttributesType(node, shouldIncludeAllStatelessAttributesType, undefined, elemClassType); + return links[linkLocation] = resolveCustomJsxElementAttributesType(node, shouldIncludeAllStatelessAttributesType, undefined, elemClassType); } - return links.resolvedJsxElementAttributesType; + return links[linkLocation]; } function getAllAttributesTypeFromJsxOpeningLikeElement(node) { if (isJsxIntrinsicIdentifier(node.tagName)) { @@ -32570,9 +32869,12 @@ var ts; } var prop = getPropertyOfType(apparentType, right.escapedText); if (!prop) { - var stringIndexType = getIndexTypeOfType(apparentType, 0); - if (stringIndexType) { - return stringIndexType; + var indexInfo = getIndexInfoOfType(apparentType, 0); + if (indexInfo && indexInfo.type) { + if (indexInfo.isReadonly && (ts.isAssignmentTarget(node) || ts.isDeleteTarget(node))) { + error(node, ts.Diagnostics.Index_signature_in_type_0_only_permits_reading, typeToString(apparentType)); + } + return indexInfo.type; } if (right.escapedText && !checkAndReportErrorForExtendingInterface(node)) { reportNonexistentProperty(right, type.flags & 16384 && type.isThisType ? apparentType : type); @@ -32699,7 +33001,7 @@ var ts; if (prop && noUnusedIdentifiers && (prop.flags & 106500) && - prop.valueDeclaration && (ts.getModifierFlags(prop.valueDeclaration) & 8)) { + prop.valueDeclaration && ts.hasModifier(prop.valueDeclaration, 8)) { if (ts.getCheckFlags(prop) & 1) { getSymbolLinks(prop).target.isReferenced = true; } @@ -32867,19 +33169,19 @@ var ts; for (var _i = 0, signatures_4 = signatures; _i < signatures_4.length; _i++) { var signature = signatures_4[_i]; var symbol = signature.declaration && getSymbolOfNode(signature.declaration); - var parent = signature.declaration && signature.declaration.parent; + var parent_13 = signature.declaration && signature.declaration.parent; if (!lastSymbol || symbol === lastSymbol) { - if (lastParent && parent === lastParent) { + if (lastParent && parent_13 === lastParent) { index++; } else { - lastParent = parent; + lastParent = parent_13; index = cutoffIndex; } } else { index = cutoffIndex = result.length; - lastParent = parent; + lastParent = parent_13; } lastSymbol = symbol; if (signature.hasLiteralTypes) { @@ -32970,8 +33272,8 @@ var ts; } return undefined; } - function instantiateSignatureInContextOf(signature, contextualSignature, contextualMapper) { - var context = createInferenceContext(signature, 1); + function instantiateSignatureInContextOf(signature, contextualSignature, contextualMapper, compareTypes) { + var context = createInferenceContext(signature, 1, compareTypes); forEachMatchingParameterType(contextualSignature, signature, function (source, target) { inferTypes(context.inferences, instantiateType(source, contextualMapper || identityMapper), target); }); @@ -33201,7 +33503,7 @@ var ts; return getLiteralType(element.name.text); case 144: var nameType = checkComputedPropertyName(element.name); - if (isTypeOfKind(nameType, 512)) { + if (isTypeAssignableToKind(nameType, 512)) { return nameType; } else { @@ -33294,9 +33596,10 @@ var ts; return resolveErrorCall(node); } var args = getEffectiveCallArguments(node); + var isSingleNonGenericCandidate = candidates.length === 1 && !candidates[0].typeParameters; var excludeArgument; var excludeCount = 0; - if (!isDecorator) { + if (!isDecorator && !isSingleNonGenericCandidate) { for (var i = isTaggedTemplate ? 1 : 0; i < args.length; i++) { if (isContextSensitive(args[i])) { if (!excludeArgument) { @@ -33388,6 +33691,17 @@ var ts; if (signatureHelpTrailingComma === void 0) { signatureHelpTrailingComma = false; } candidateForArgumentError = undefined; candidateForTypeArgumentError = undefined; + if (isSingleNonGenericCandidate) { + var candidate = candidates[0]; + if (!hasCorrectArity(node, args, candidate, signatureHelpTrailingComma)) { + return undefined; + } + if (!checkApplicableSignature(node, args, candidate, relation, excludeArgument, false)) { + candidateForArgumentError = candidate; + return undefined; + } + return candidate; + } for (var candidateIndex = 0; candidateIndex < candidates.length; candidateIndex++) { var originalCandidate = candidates[candidateIndex]; if (!hasCorrectArity(node, args, originalCandidate, signatureHelpTrailingComma)) { @@ -33518,7 +33832,7 @@ var ts; return resolveErrorCall(node); } var valueDecl = expressionType.symbol && getClassLikeDeclarationOfSymbol(expressionType.symbol); - if (valueDecl && ts.getModifierFlags(valueDecl) & 128) { + if (valueDecl && ts.hasModifier(valueDecl, 128)) { error(node, ts.Diagnostics.Cannot_create_an_instance_of_the_abstract_class_0, ts.declarationNameToString(ts.getNameOfDeclaration(valueDecl))); return resolveErrorCall(node); } @@ -33554,8 +33868,8 @@ var ts; return true; } var declaration = signature.declaration; - var modifiers = ts.getModifierFlags(declaration); - if (!(modifiers & 24)) { + var modifiers = ts.getSelectedModifierFlags(declaration, 24); + if (!modifiers) { return true; } var declaringClassDeclaration = getClassLikeDeclarationOfSymbol(declaration.parent.symbol); @@ -33709,7 +34023,7 @@ var ts; && getSymbolLinks(type.symbol).inferredClassType === type; } function checkCallExpression(node) { - checkGrammarTypeArguments(node, node.typeArguments) || checkGrammarArguments(node, node.arguments); + checkGrammarTypeArguments(node, node.typeArguments) || checkGrammarArguments(node.arguments); var signature = getResolvedSignature(node); if (node.expression.kind === 97) { return voidType; @@ -33742,7 +34056,7 @@ var ts; return getReturnTypeOfSignature(signature); } function checkImportCallExpression(node) { - checkGrammarArguments(node, node.arguments) || checkGrammarImportCallExpression(node); + checkGrammarArguments(node.arguments) || checkGrammarImportCallExpression(node); if (node.arguments.length === 0) { return createPromiseReturnType(node, anyType); } @@ -33758,11 +34072,33 @@ var ts; if (moduleSymbol) { var esModuleSymbol = resolveESModuleSymbol(moduleSymbol, specifier, true); if (esModuleSymbol) { - return createPromiseReturnType(node, getTypeOfSymbol(esModuleSymbol)); + return createPromiseReturnType(node, getTypeWithSyntheticDefaultImportType(getTypeOfSymbol(esModuleSymbol), esModuleSymbol)); } } return createPromiseReturnType(node, anyType); } + function getTypeWithSyntheticDefaultImportType(type, symbol) { + if (allowSyntheticDefaultImports && type && type !== unknownType) { + var synthType = type; + if (!synthType.syntheticType) { + if (!getPropertyOfType(type, "default")) { + var memberTable = ts.createSymbolTable(); + var newSymbol = createSymbol(2097152, "default"); + newSymbol.target = resolveSymbol(symbol); + memberTable.set("default", newSymbol); + var anonymousSymbol = createSymbol(2048, "__type"); + var defaultContainingObject = createAnonymousType(anonymousSymbol, memberTable, ts.emptyArray, ts.emptyArray, undefined, undefined); + anonymousSymbol.type = defaultContainingObject; + synthType.syntheticType = getIntersectionType([type, defaultContainingObject]); + } + else { + synthType.syntheticType = type; + } + } + return synthType.syntheticType; + } + return type; + } function isCommonJsRequire(node) { if (!ts.isRequireCall(node, true)) { return false; @@ -33881,15 +34217,15 @@ var ts; } } } - function assignBindingElementTypes(node) { - if (ts.isBindingPattern(node.name)) { - for (var _i = 0, _a = node.name.elements; _i < _a.length; _i++) { - var element = _a[_i]; - if (!ts.isOmittedExpression(element)) { - if (element.name.kind === 71) { - getSymbolLinks(getSymbolOfNode(element)).type = getTypeForBindingElement(element); - } - assignBindingElementTypes(element); + function assignBindingElementTypes(pattern) { + for (var _i = 0, _a = pattern.elements; _i < _a.length; _i++) { + var element = _a[_i]; + if (!ts.isOmittedExpression(element)) { + if (element.name.kind === 71) { + getSymbolLinks(getSymbolOfNode(element)).type = getTypeForBindingElement(element); + } + else { + assignBindingElementTypes(element.name); } } } @@ -33898,12 +34234,13 @@ var ts; var links = getSymbolLinks(parameter); if (!links.type) { links.type = contextualType; - var name = ts.getNameOfDeclaration(parameter.valueDeclaration); - if (links.type === emptyObjectType && - (name.kind === 174 || name.kind === 175)) { - links.type = getTypeFromBindingPattern(name); + var decl = parameter.valueDeclaration; + if (decl.name.kind !== 71) { + if (links.type === emptyObjectType) { + links.type = getTypeFromBindingPattern(decl.name); + } + assignBindingElementTypes(decl.name); } - assignBindingElementTypes(parameter.valueDeclaration); } } function createPromiseType(promisedType) { @@ -34104,14 +34441,14 @@ var ts; } function checkFunctionExpressionOrObjectLiteralMethod(node, checkMode) { ts.Debug.assert(node.kind !== 151 || ts.isObjectLiteralMethod(node)); - var hasGrammarError = checkGrammarFunctionLikeDeclaration(node); - if (!hasGrammarError && node.kind === 186) { - checkGrammarForGenerator(node); - } if (checkMode === 1 && isContextSensitive(node)) { checkNodeDeferred(node); return anyFunctionType; } + var hasGrammarError = checkGrammarFunctionLikeDeclaration(node); + if (!hasGrammarError && node.kind === 186) { + checkGrammarForGenerator(node); + } var links = getNodeLinks(node); var type = getTypeOfSymbol(node.symbol); if (!(links.flags & 1024)) { @@ -34181,7 +34518,7 @@ var ts; } } function checkArithmeticOperandType(operand, type, diagnostic) { - if (!isTypeAnyOrAllConstituentTypesHaveKind(type, 84)) { + if (!isTypeAssignableToKind(type, 84)) { error(operand, diagnostic); return false; } @@ -34269,8 +34606,13 @@ var ts; if (operandType === silentNeverType) { return silentNeverType; } - if (node.operator === 38 && node.operand.kind === 8) { - return getFreshTypeOfLiteralType(getLiteralType(-node.operand.text)); + if (node.operand.kind === 8) { + if (node.operator === 38) { + return getFreshTypeOfLiteralType(getLiteralType(-node.operand.text)); + } + else if (node.operator === 37) { + return getFreshTypeOfLiteralType(getLiteralType(+node.operand.text)); + } } switch (node.operator) { case 37: @@ -34322,30 +34664,22 @@ var ts; } return false; } - function isTypeOfKind(type, kind) { - if (type.flags & kind) { + function isTypeAssignableToKind(source, kind, strict) { + if (source.flags & kind) { return true; } - if (type.flags & 65536) { - var types = type.types; - for (var _i = 0, types_18 = types; _i < types_18.length; _i++) { - var t = types_18[_i]; - if (!isTypeOfKind(t, kind)) { - return false; - } - } - return true; + if (strict && source.flags & (1 | 1024 | 2048 | 4096)) { + return false; } - if (type.flags & 131072) { - var types = type.types; - for (var _a = 0, types_19 = types; _a < types_19.length; _a++) { - var t = types_19[_a]; - if (isTypeOfKind(t, kind)) { - return true; - } - } - } - return false; + return (kind & 84 && isTypeAssignableTo(source, numberType)) || + (kind & 262178 && isTypeAssignableTo(source, stringType)) || + (kind & 136 && isTypeAssignableTo(source, booleanType)) || + (kind & 1024 && isTypeAssignableTo(source, voidType)) || + (kind & 8192 && isTypeAssignableTo(source, neverType)) || + (kind & 4096 && isTypeAssignableTo(source, nullType)) || + (kind & 2048 && isTypeAssignableTo(source, undefinedType)) || + (kind & 512 && isTypeAssignableTo(source, esSymbolType)) || + (kind & 16777216 && isTypeAssignableTo(source, nonPrimitiveType)); } function isConstEnumObjectType(type) { return getObjectFlags(type) & 16 && type.symbol && isConstEnumSymbol(type.symbol); @@ -34357,7 +34691,7 @@ var ts; if (leftType === silentNeverType || rightType === silentNeverType) { return silentNeverType; } - if (isTypeOfKind(leftType, 8190)) { + if (!isTypeAny(leftType) && isTypeAssignableToKind(leftType, 8190)) { error(left, ts.Diagnostics.The_left_hand_side_of_an_instanceof_expression_must_be_of_type_any_an_object_type_or_a_type_parameter); } if (!(isTypeAny(rightType) || @@ -34374,32 +34708,32 @@ var ts; } leftType = checkNonNullType(leftType, left); rightType = checkNonNullType(rightType, right); - if (!(isTypeComparableTo(leftType, stringType) || isTypeOfKind(leftType, 84 | 512))) { + if (!(isTypeComparableTo(leftType, stringType) || isTypeAssignableToKind(leftType, 84 | 512))) { error(left, ts.Diagnostics.The_left_hand_side_of_an_in_expression_must_be_of_type_any_string_number_or_symbol); } - if (!isTypeAnyOrAllConstituentTypesHaveKind(rightType, 32768 | 540672 | 16777216)) { + if (!isTypeAssignableToKind(rightType, 16777216 | 540672)) { error(right, ts.Diagnostics.The_right_hand_side_of_an_in_expression_must_be_of_type_any_an_object_type_or_a_type_parameter); } return booleanType; } function checkObjectLiteralAssignment(node, sourceType) { var properties = node.properties; - for (var _i = 0, properties_6 = properties; _i < properties_6.length; _i++) { - var p = properties_6[_i]; + for (var _i = 0, properties_7 = properties; _i < properties_7.length; _i++) { + var p = properties_7[_i]; checkObjectLiteralDestructuringPropertyAssignment(sourceType, p, properties); } return sourceType; } function checkObjectLiteralDestructuringPropertyAssignment(objectLiteralType, property, allProperties) { if (property.kind === 261 || property.kind === 262) { - var name = property.name; - if (name.kind === 144) { - checkComputedPropertyName(name); + var name_23 = property.name; + if (name_23.kind === 144) { + checkComputedPropertyName(name_23); } - if (isComputedNonLiteralName(name)) { + if (isComputedNonLiteralName(name_23)) { return undefined; } - var text = ts.getTextOfPropertyName(name); + var text = ts.getTextOfPropertyName(name_23); var type = isTypeAny(objectLiteralType) ? objectLiteralType : getTypeOfPropertyOfType(objectLiteralType, text) || @@ -34414,7 +34748,7 @@ var ts; } } else { - error(name, ts.Diagnostics.Type_0_has_no_property_1_and_no_string_index_signature, typeToString(objectLiteralType), ts.declarationNameToString(name)); + error(name_23, ts.Diagnostics.Type_0_has_no_property_1_and_no_string_index_signature, typeToString(objectLiteralType), ts.declarationNameToString(name_23)); } } else if (property.kind === 263) { @@ -34641,24 +34975,22 @@ var ts; if (leftType === silentNeverType || rightType === silentNeverType) { return silentNeverType; } - if (!isTypeOfKind(leftType, 1 | 262178) && !isTypeOfKind(rightType, 1 | 262178)) { + if (!isTypeAssignableToKind(leftType, 262178) && !isTypeAssignableToKind(rightType, 262178)) { leftType = checkNonNullType(leftType, left); rightType = checkNonNullType(rightType, right); } var resultType = void 0; - if (isTypeOfKind(leftType, 84) && isTypeOfKind(rightType, 84)) { + if (isTypeAssignableToKind(leftType, 84, true) && isTypeAssignableToKind(rightType, 84, true)) { resultType = numberType; } - else { - if (isTypeOfKind(leftType, 262178) || isTypeOfKind(rightType, 262178)) { - resultType = stringType; - } - else if (isTypeAny(leftType) || isTypeAny(rightType)) { - resultType = leftType === unknownType || rightType === unknownType ? unknownType : anyType; - } - if (resultType && !checkForDisallowedESSymbolOperand(operator)) { - return resultType; - } + else if (isTypeAssignableToKind(leftType, 262178, true) || isTypeAssignableToKind(rightType, 262178, true)) { + resultType = stringType; + } + else if (isTypeAny(leftType) || isTypeAny(rightType)) { + resultType = leftType === unknownType || rightType === unknownType ? unknownType : anyType; + } + if (resultType && !checkForDisallowedESSymbolOperand(operator)) { + return resultType; } if (!resultType) { reportOperatorError(); @@ -34823,13 +35155,12 @@ var ts; return getBestChoiceType(type1, type2); } function checkLiteralExpression(node) { - if (node.kind === 8) { - checkGrammarNumericLiteral(node); - } switch (node.kind) { + case 13: case 9: return getFreshTypeOfLiteralType(getLiteralType(node.text)); case 8: + checkGrammarNumericLiteral(node); return getFreshTypeOfLiteralType(getLiteralType(+node.text)); case 101: return trueType; @@ -34977,6 +35308,7 @@ var ts; return checkSuperExpression(node); case 95: return nullWideningType; + case 13: case 9: case 8: case 101: @@ -34984,8 +35316,6 @@ var ts; return checkLiteralExpression(node); case 196: return checkTemplateExpression(node); - case 13: - return stringType; case 12: return globalRegExpType; case 177: @@ -35076,7 +35406,7 @@ var ts; checkGrammarDecorators(node) || checkGrammarModifiers(node); checkVariableLikeDeclaration(node); var func = ts.getContainingFunction(node); - if (ts.getModifierFlags(node) & 92) { + if (ts.hasModifier(node, 92)) { func = ts.getContainingFunction(node); if (!(func.kind === 152 && ts.nodeIsPresent(func.body))) { error(node, ts.Diagnostics.A_parameter_property_is_only_allowed_in_a_constructor_implementation); @@ -35136,9 +35466,9 @@ var ts; else if (parameterName) { var hasReportedError = false; for (var _i = 0, _a = parent.parameters; _i < _a.length; _i++) { - var name = _a[_i].name; - if (ts.isBindingPattern(name) && - checkIfTypePredicateVariableIsDeclaredInBindingPattern(name, parameterName, typePredicate.parameterName)) { + var name_24 = _a[_i].name; + if (ts.isBindingPattern(name_24) && + checkIfTypePredicateVariableIsDeclaredInBindingPattern(name_24, parameterName, typePredicate.parameterName)) { hasReportedError = true; break; } @@ -35158,9 +35488,9 @@ var ts; case 160: case 151: case 150: - var parent = node.parent; - if (node === parent.type) { - return parent; + var parent_14 = node.parent; + if (node === parent_14.type) { + return parent_14; } } } @@ -35170,13 +35500,13 @@ var ts; if (ts.isOmittedExpression(element)) { continue; } - var name = element.name; - if (name.kind === 71 && name.escapedText === predicateVariableName) { + var name_25 = element.name; + if (name_25.kind === 71 && name_25.escapedText === predicateVariableName) { error(predicateVariableNode, ts.Diagnostics.A_type_predicate_cannot_reference_element_0_in_a_binding_pattern, predicateVariableName); return true; } - else if (name.kind === 175 || name.kind === 174) { - if (checkIfTypePredicateVariableIsDeclaredInBindingPattern(name, predicateVariableNode, predicateVariableName)) { + else if (name_25.kind === 175 || name_25.kind === 174) { + if (checkIfTypePredicateVariableIsDeclaredInBindingPattern(name_25, predicateVariableNode, predicateVariableName)) { return true; } } @@ -35266,7 +35596,7 @@ var ts; } } else { - var isStatic = ts.getModifierFlags(member) & 32; + var isStatic = ts.hasModifier(member, 32); var names = isStatic ? staticNames : instanceNames; var memberName = member.name && ts.getPropertyNameForPropertyNameNode(member.name); if (memberName) { @@ -35311,7 +35641,7 @@ var ts; for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; var memberNameNode = member.name; - var isStatic = ts.getModifierFlags(member) & 32; + var isStatic = ts.hasModifier(member, 32); if (isStatic && memberNameNode) { var memberName = ts.getPropertyNameForPropertyNameNode(memberNameNode); switch (memberName) { @@ -35399,7 +35729,7 @@ var ts; function checkMethodDeclaration(node) { checkGrammarMethod(node) || checkGrammarComputedPropertyName(node.name); checkFunctionOrMethodDeclaration(node); - if (ts.getModifierFlags(node) & 128 && node.body) { + if (ts.hasModifier(node, 128) && node.body) { error(node, ts.Diagnostics.Method_0_cannot_have_an_implementation_because_it_is_marked_abstract, ts.declarationNameToString(node.name)); } } @@ -35435,17 +35765,9 @@ var ts; } return ts.forEachChild(n, containsSuperCall); } - function markThisReferencesAsErrors(n) { - if (n.kind === 99) { - error(n, ts.Diagnostics.this_cannot_be_referenced_in_current_location); - } - else if (n.kind !== 186 && n.kind !== 228) { - ts.forEachChild(n, markThisReferencesAsErrors); - } - } function isInstancePropertyWithInitializer(n) { return n.kind === 149 && - !(ts.getModifierFlags(n) & 32) && + !ts.hasModifier(n, 32) && !!n.initializer; } var containingClassDecl = node.parent; @@ -35457,8 +35779,8 @@ var ts; if (classExtendsNull) { error(superCall, ts.Diagnostics.A_constructor_cannot_contain_a_super_call_when_its_class_extends_null); } - var superCallShouldBeFirst = ts.forEach(node.parent.members, isInstancePropertyWithInitializer) || - ts.forEach(node.parameters, function (p) { return ts.getModifierFlags(p) & 92; }); + var superCallShouldBeFirst = ts.some(node.parent.members, isInstancePropertyWithInitializer) || + ts.some(node.parameters, function (p) { return ts.hasModifier(p, 92); }); if (superCallShouldBeFirst) { var statements = node.body.statements; var superCallStatement = void 0; @@ -35501,10 +35823,12 @@ var ts; var otherKind = node.kind === 153 ? 154 : 153; var otherAccessor = ts.getDeclarationOfKind(node.symbol, otherKind); if (otherAccessor) { - if ((ts.getModifierFlags(node) & 28) !== (ts.getModifierFlags(otherAccessor) & 28)) { + var nodeFlags = ts.getModifierFlags(node); + var otherFlags = ts.getModifierFlags(otherAccessor); + if ((nodeFlags & 28) !== (otherFlags & 28)) { error(node.name, ts.Diagnostics.Getter_and_setter_accessors_do_not_agree_in_visibility); } - if (ts.hasModifier(node, 128) !== ts.hasModifier(otherAccessor, 128)) { + if ((nodeFlags & 128) !== (otherFlags & 128)) { error(node.name, ts.Diagnostics.Accessors_must_both_be_abstract_or_non_abstract); } checkAccessorDeclarationTypesIdentical(node, otherAccessor, getAnnotatedAccessorType, ts.Diagnostics.get_and_set_accessor_must_have_the_same_type); @@ -35550,7 +35874,7 @@ var ts; function checkTypeReferenceNode(node) { checkGrammarTypeArguments(node, node.typeArguments); if (node.kind === 159 && node.typeName.jsdocDotPos !== undefined && !ts.isInJavaScriptFile(node) && !ts.isInJSDoc(node)) { - grammarErrorAtPos(ts.getSourceFileOfNode(node), node.typeName.jsdocDotPos, 1, ts.Diagnostics.JSDoc_types_can_only_be_used_inside_documentation_comments); + grammarErrorAtPos(node, node.typeName.jsdocDotPos, 1, ts.Diagnostics.JSDoc_types_can_only_be_used_inside_documentation_comments); } var type = getTypeFromTypeReference(node); if (type !== unknownType) { @@ -35558,7 +35882,14 @@ var ts; ts.forEach(node.typeArguments, checkSourceElement); if (produceDiagnostics) { var symbol = getNodeLinks(node).resolvedSymbol; - var typeParameters = symbol.flags & 524288 ? getSymbolLinks(symbol).typeParameters : type.target.localTypeParameters; + if (!symbol) { + error(node, ts.Diagnostics.Type_0_is_not_generic, typeToString(type)); + return; + } + var typeParameters = symbol.flags & 524288 && getSymbolLinks(symbol).typeParameters; + if (!typeParameters && getObjectFlags(type) & 4) { + typeParameters = type.target.localTypeParameters; + } checkTypeArgumentConstraints(typeParameters, node.typeArguments); } } @@ -35601,16 +35932,15 @@ var ts; if (isTypeAssignableTo(indexType, getIndexType(objectType))) { return type; } - if (maybeTypeOfKind(objectType, 540672) && isTypeOfKind(indexType, 84)) { - var constraint = getBaseConstraintOfType(objectType); - if (constraint && getIndexInfoOfType(constraint, 1)) { - return type; - } + if (getIndexInfoOfType(getApparentType(objectType), 1) && isTypeAssignableToKind(indexType, 84)) { + return type; } error(accessNode, ts.Diagnostics.Type_0_cannot_be_used_to_index_type_1, typeToString(indexType), typeToString(objectType)); return type; } function checkIndexedAccessType(node) { + checkSourceElement(node.objectType); + checkSourceElement(node.indexType); checkIndexedAccessIndexType(getTypeFromIndexedAccessTypeNode(node), node); } function checkMappedType(node) { @@ -35621,7 +35951,7 @@ var ts; checkTypeAssignableTo(constraintType, stringType, node.typeParameter.constraint); } function isPrivateWithinAmbient(node) { - return (ts.getModifierFlags(node) & 8) && ts.isInAmbientContext(node); + return ts.hasModifier(node, 8) && ts.isInAmbientContext(node); } function getEffectiveDeclarationFlags(n, flagsToCheck) { var flags = ts.getCombinedModifierFlags(n); @@ -35708,9 +36038,9 @@ var ts; (ts.isComputedPropertyName(node.name) && ts.isComputedPropertyName(subsequentName) || !ts.isComputedPropertyName(node.name) && !ts.isComputedPropertyName(subsequentName) && ts.getEscapedTextOfIdentifierOrLiteral(node.name) === ts.getEscapedTextOfIdentifierOrLiteral(subsequentName))) { var reportError = (node.kind === 151 || node.kind === 150) && - (ts.getModifierFlags(node) & 32) !== (ts.getModifierFlags(subsequentNode) & 32); + ts.hasModifier(node, 32) !== ts.hasModifier(subsequentNode, 32); if (reportError) { - var diagnostic = ts.getModifierFlags(node) & 32 ? ts.Diagnostics.Function_overload_must_be_static : ts.Diagnostics.Function_overload_must_not_be_static; + var diagnostic = ts.hasModifier(node, 32) ? ts.Diagnostics.Function_overload_must_be_static : ts.Diagnostics.Function_overload_must_not_be_static; error(errorNode_1, diagnostic); } return; @@ -35726,7 +36056,7 @@ var ts; error(errorNode, ts.Diagnostics.Constructor_implementation_is_missing); } else { - if (ts.getModifierFlags(node) & 128) { + if (ts.hasModifier(node, 128)) { error(errorNode, ts.Diagnostics.All_declarations_of_an_abstract_method_must_be_consecutive); } else { @@ -35736,8 +36066,8 @@ var ts; } var duplicateFunctionDeclaration = false; var multipleConstructorImplementation = false; - for (var _i = 0, declarations_5 = declarations; _i < declarations_5.length; _i++) { - var current = declarations_5[_i]; + for (var _i = 0, declarations_4 = declarations; _i < declarations_4.length; _i++) { + var current = declarations_4[_i]; var node = current; var inAmbientContext = ts.isInAmbientContext(node); var inAmbientContextOrInterface = node.parent.kind === 230 || node.parent.kind === 163 || inAmbientContext; @@ -35786,7 +36116,7 @@ var ts; }); } if (lastSeenNonAmbientDeclaration && !lastSeenNonAmbientDeclaration.body && - !(ts.getModifierFlags(lastSeenNonAmbientDeclaration) & 128) && !lastSeenNonAmbientDeclaration.questionToken) { + !ts.hasModifier(lastSeenNonAmbientDeclaration, 128) && !lastSeenNonAmbientDeclaration.questionToken) { reportImplementationExpectedError(lastSeenNonAmbientDeclaration); } if (hasOverloads) { @@ -35845,12 +36175,12 @@ var ts; for (var _b = 0, _c = symbol.declarations; _b < _c.length; _b++) { var d = _c[_b]; var declarationSpaces = getDeclarationSpaces(d); - var name = ts.getNameOfDeclaration(d); + var name_26 = ts.getNameOfDeclaration(d); if (declarationSpaces & commonDeclarationSpacesForDefaultAndNonDefault) { - error(name, ts.Diagnostics.Merged_declaration_0_cannot_include_a_default_export_declaration_Consider_adding_a_separate_export_default_0_declaration_instead, ts.declarationNameToString(name)); + error(name_26, ts.Diagnostics.Merged_declaration_0_cannot_include_a_default_export_declaration_Consider_adding_a_separate_export_default_0_declaration_instead, ts.declarationNameToString(name_26)); } else if (declarationSpaces & commonDeclarationSpacesForExportsAndLocals) { - error(name, ts.Diagnostics.Individual_declarations_in_merged_declaration_0_must_be_all_exported_or_all_local, ts.declarationNameToString(name)); + error(name_26, ts.Diagnostics.Individual_declarations_in_merged_declaration_0_must_be_all_exported_or_all_local, ts.declarationNameToString(name_26)); } } } @@ -36195,7 +36525,7 @@ var ts; if (!ts.hasDynamicName(node)) { var symbol = getSymbolOfNode(node); var localSymbol = node.localSymbol || symbol; - var firstDeclaration = ts.find(localSymbol.declarations, function (declaration) { return declaration.kind === node.kind && !ts.isSourceFileJavaScript(ts.getSourceFileOfNode(declaration)); }); + var firstDeclaration = ts.find(localSymbol.declarations, function (declaration) { return declaration.kind === node.kind && !(declaration.flags & 65536); }); if (node === firstDeclaration) { checkFunctionOrConstructorSymbol(localSymbol); } @@ -36285,12 +36615,12 @@ var ts; if (!local.isReferenced) { if (local.valueDeclaration && ts.getRootDeclaration(local.valueDeclaration).kind === 146) { var parameter = ts.getRootDeclaration(local.valueDeclaration); - var name = ts.getNameOfDeclaration(local.valueDeclaration); + var name_27 = ts.getNameOfDeclaration(local.valueDeclaration); if (compilerOptions.noUnusedParameters && !ts.isParameterPropertyDeclaration(parameter) && !ts.parameterIsThisKeyword(parameter) && - !parameterNameStartsWithUnderscore(name)) { - error(name, ts.Diagnostics._0_is_declared_but_never_used, ts.unescapeLeadingUnderscores(local.escapedName)); + !parameterNameStartsWithUnderscore(name_27)) { + error(name_27, ts.Diagnostics._0_is_declared_but_never_used, ts.unescapeLeadingUnderscores(local.escapedName)); } } else if (compilerOptions.noUnusedLocals) { @@ -36330,14 +36660,14 @@ var ts; for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; if (member.kind === 151 || member.kind === 149) { - if (!member.symbol.isReferenced && ts.getModifierFlags(member) & 8) { + if (!member.symbol.isReferenced && ts.hasModifier(member, 8)) { error(member.name, ts.Diagnostics._0_is_declared_but_never_used, ts.unescapeLeadingUnderscores(member.symbol.escapedName)); } } else if (member.kind === 152) { for (var _b = 0, _c = member.parameters; _b < _c.length; _b++) { var parameter = _c[_b]; - if (!parameter.symbol.isReferenced && ts.getModifierFlags(parameter) & 8) { + if (!parameter.symbol.isReferenced && ts.hasModifier(parameter, 8)) { error(parameter.name, ts.Diagnostics.Property_0_is_declared_but_never_used, ts.unescapeLeadingUnderscores(parameter.symbol.escapedName)); } } @@ -36526,8 +36856,8 @@ var ts; container.kind === 233 || container.kind === 265); if (!namesShareScope) { - var name = symbolToString(localDeclarationSymbol); - error(node, ts.Diagnostics.Cannot_initialize_outer_scoped_variable_0_in_the_same_scope_as_block_scoped_declaration_1, name, name); + var name_28 = symbolToString(localDeclarationSymbol); + error(node, ts.Diagnostics.Cannot_initialize_outer_scoped_variable_0_in_the_same_scope_as_block_scoped_declaration_1, name_28, name_28); } } } @@ -36604,13 +36934,13 @@ var ts; if (node.propertyName && node.propertyName.kind === 144) { checkComputedPropertyName(node.propertyName); } - var parent = node.parent.parent; - var parentType = getTypeForBindingElementParent(parent); - var name = node.propertyName || node.name; - var property = getPropertyOfType(parentType, ts.getTextOfPropertyName(name)); + var parent_15 = node.parent.parent; + var parentType = getTypeForBindingElementParent(parent_15); + var name_29 = node.propertyName || node.name; + var property = getPropertyOfType(parentType, ts.getTextOfPropertyName(name_29)); markPropertyAsReferenced(property); - if (parent.initializer && property) { - checkPropertyAccessibility(parent, parent.initializer, parentType, property); + if (parent_15.initializer && property) { + checkPropertyAccessibility(parent_15, parent_15.initializer, parentType, property); } } if (ts.isBindingPattern(node.name)) { @@ -36677,7 +37007,7 @@ var ts; 128 | 64 | 32; - return (ts.getModifierFlags(left) & interestingFlags) === (ts.getModifierFlags(right) & interestingFlags); + return ts.getSelectedModifierFlags(left, interestingFlags) === ts.getSelectedModifierFlags(right, interestingFlags); } function checkVariableDeclaration(node) { checkGrammarVariableDeclaration(node); @@ -36807,7 +37137,7 @@ var ts; checkReferenceExpression(varExpr, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_must_be_a_variable_or_a_property_access); } } - if (!isTypeAnyOrAllConstituentTypesHaveKind(rightType, 32768 | 540672 | 16777216)) { + if (!isTypeAssignableToKind(rightType, 16777216 | 540672)) { error(node.expression, ts.Diagnostics.The_right_hand_side_of_a_for_in_statement_must_be_of_type_any_an_object_type_or_a_type_parameter); } checkSourceElement(node.statement); @@ -37179,7 +37509,7 @@ var ts; var classDeclaration = type.symbol.valueDeclaration; for (var _i = 0, _a = classDeclaration.members; _i < _a.length; _i++) { var member = _a[_i]; - if (!(ts.getModifierFlags(member) & 32) && ts.hasDynamicName(member)) { + if (!ts.hasModifier(member, 32) && ts.hasDynamicName(member)) { var propType = getTypeOfSymbol(member.symbol); checkIndexConstraintForProperty(member.symbol, propType, type, declaredStringIndexer, stringIndexType, 0); checkIndexConstraintForProperty(member.symbol, propType, type, declaredNumberIndexer, numberIndexType, 1); @@ -37275,10 +37605,10 @@ var ts; } var type = getDeclaredTypeOfSymbol(symbol); if (!areTypeParametersIdentical(declarations, type.localTypeParameters)) { - var name = symbolToString(symbol); - for (var _i = 0, declarations_6 = declarations; _i < declarations_6.length; _i++) { - var declaration = declarations_6[_i]; - error(declaration.name, ts.Diagnostics.All_declarations_of_0_must_have_identical_type_parameters, name); + var name_30 = symbolToString(symbol); + for (var _i = 0, declarations_5 = declarations; _i < declarations_5.length; _i++) { + var declaration = declarations_5[_i]; + error(declaration.name, ts.Diagnostics.All_declarations_of_0_must_have_identical_type_parameters, name_30); } } } @@ -37286,8 +37616,8 @@ var ts; function areTypeParametersIdentical(declarations, typeParameters) { var maxTypeArgumentCount = ts.length(typeParameters); var minTypeArgumentCount = getMinTypeArgumentCount(typeParameters); - for (var _i = 0, declarations_7 = declarations; _i < declarations_7.length; _i++) { - var declaration = declarations_7[_i]; + for (var _i = 0, declarations_6 = declarations; _i < declarations_6.length; _i++) { + var declaration = declarations_6[_i]; var numTypeParameters = ts.length(declaration.typeParameters); if (numTypeParameters < minTypeArgumentCount || numTypeParameters > maxTypeArgumentCount) { return false; @@ -37323,7 +37653,7 @@ var ts; registerForUnusedIdentifiersCheck(node); } function checkClassDeclaration(node) { - if (!node.name && !(ts.getModifierFlags(node) & 512)) { + if (!node.name && !ts.hasModifier(node, 512)) { grammarErrorOnFirstToken(node, ts.Diagnostics.A_class_declaration_without_the_default_modifier_must_have_a_name); } checkClassLikeDeclaration(node); @@ -37416,7 +37746,7 @@ var ts; var signatures = getSignaturesOfType(type, 1); if (signatures.length) { var declaration = signatures[0].declaration; - if (declaration && ts.getModifierFlags(declaration) & 8) { + if (declaration && ts.hasModifier(declaration, 8)) { var typeClassDeclaration = getClassLikeDeclarationOfSymbol(type.symbol); if (!isNodeWithinClass(node, typeClassDeclaration)) { error(node, ts.Diagnostics.Cannot_extend_a_class_0_Class_constructor_is_marked_as_private, getFullyQualifiedName(type.symbol)); @@ -37449,7 +37779,7 @@ var ts; if (derived) { if (derived === base) { var derivedClassDecl = getClassLikeDeclarationOfSymbol(type.symbol); - if (baseDeclarationFlags & 128 && (!derivedClassDecl || !(ts.getModifierFlags(derivedClassDecl) & 128))) { + if (baseDeclarationFlags & 128 && (!derivedClassDecl || !ts.hasModifier(derivedClassDecl, 128))) { if (derivedClassDecl.kind === 199) { error(derivedClassDecl, ts.Diagnostics.Non_abstract_class_expression_does_not_implement_inherited_abstract_member_0_from_class_1, symbolToString(baseProperty), typeToString(baseType)); } @@ -37497,8 +37827,8 @@ var ts; for (var _i = 0, baseTypes_2 = baseTypes; _i < baseTypes_2.length; _i++) { var base = baseTypes_2[_i]; var properties = getPropertiesOfType(getTypeWithThisArgument(base, type.thisType)); - for (var _a = 0, properties_7 = properties; _a < properties_7.length; _a++) { - var prop = properties_7[_a]; + for (var _a = 0, properties_8 = properties; _a < properties_8.length; _a++) { + var prop = properties_8[_a]; var existing = seen.get(prop.escapedName); if (!existing) { seen.set(prop.escapedName, { prop: prop, containingType: base }); @@ -37666,16 +37996,16 @@ var ts; if (isConstantMemberAccess(ex)) { var type = getTypeOfExpression(ex.expression); if (type.symbol && type.symbol.flags & 384) { - var name = void 0; + var name_31; if (ex.kind === 179) { - name = ex.name.escapedText; + name_31 = ex.name.escapedText; } else { var argument = ex.argumentExpression; ts.Debug.assert(ts.isLiteralExpression(argument)); - name = ts.escapeLeadingUnderscores(argument.text); + name_31 = ts.escapeLeadingUnderscores(argument.text); } - return evaluateEnumMember(expr, type.symbol, name); + return evaluateEnumMember(expr, type.symbol, name_31); } } break; @@ -37752,8 +38082,8 @@ var ts; } function getFirstNonAmbientClassOrFunctionDeclaration(symbol) { var declarations = symbol.declarations; - for (var _i = 0, declarations_8 = declarations; _i < declarations_8.length; _i++) { - var declaration = declarations_8[_i]; + for (var _i = 0, declarations_7 = declarations; _i < declarations_7.length; _i++) { + var declaration = declarations_7[_i]; if ((declaration.kind === 229 || (declaration.kind === 228 && ts.nodeIsPresent(declaration.body))) && !ts.isInAmbientContext(declaration)) { @@ -37873,9 +38203,9 @@ var ts; break; case 176: case 226: - var name = node.name; - if (ts.isBindingPattern(name)) { - for (var _b = 0, _c = name.elements; _b < _c.length; _b++) { + var name_32 = node.name; + if (ts.isBindingPattern(name_32)) { + for (var _b = 0, _c = name_32.elements; _b < _c.length; _b++) { var el = _c[_b]; checkModuleAugmentationElement(el, isGlobalAugmentation); } @@ -37968,7 +38298,7 @@ var ts; if (checkGrammarModuleElementContext(node, ts.Diagnostics.An_import_declaration_can_only_be_used_in_a_namespace_or_module)) { return; } - if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && ts.getModifierFlags(node) !== 0) { + if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && ts.hasModifiers(node)) { grammarErrorOnFirstToken(node, ts.Diagnostics.An_import_declaration_cannot_have_modifiers); } if (checkExternalImportOrExportDeclaration(node)) { @@ -37995,7 +38325,7 @@ var ts; checkGrammarDecorators(node) || checkGrammarModifiers(node); if (ts.isInternalModuleImportEqualsDeclaration(node) || checkExternalImportOrExportDeclaration(node)) { checkImportBinding(node); - if (ts.getModifierFlags(node) & 1) { + if (ts.hasModifier(node, 1)) { markExportAsReferenced(node); } if (ts.isInternalModuleImportEqualsDeclaration(node)) { @@ -38023,7 +38353,7 @@ var ts; if (checkGrammarModuleElementContext(node, ts.Diagnostics.An_export_declaration_can_only_be_used_in_a_module)) { return; } - if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && ts.getModifierFlags(node) !== 0) { + if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && ts.hasModifiers(node)) { grammarErrorOnFirstToken(node, ts.Diagnostics.An_export_declaration_cannot_have_modifiers); } if (!node.moduleSpecifier || checkExternalImportOrExportDeclaration(node)) { @@ -38081,7 +38411,7 @@ var ts; } return; } - if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && ts.getModifierFlags(node) !== 0) { + if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && ts.hasModifiers(node)) { grammarErrorOnFirstToken(node, ts.Diagnostics.An_export_assignment_cannot_have_modifiers); } if (node.expression.kind === 71) { @@ -38128,8 +38458,8 @@ var ts; return; } if (exportedDeclarationsCount > 1) { - for (var _i = 0, declarations_9 = declarations; _i < declarations_9.length; _i++) { - var declaration = declarations_9[_i]; + for (var _i = 0, declarations_8 = declarations; _i < declarations_8.length; _i++) { + var declaration = declarations_8[_i]; if (isNotOverload(declaration)) { diagnostics.add(ts.createDiagnosticForNode(declaration, ts.Diagnostics.Cannot_redeclare_exported_variable_0, ts.unescapeLeadingUnderscores(id))); } @@ -38407,7 +38737,7 @@ var ts; return []; } var symbols = ts.createSymbolTable(); - var memberFlags = 0; + var isStatic = false; populateSymbols(); return symbolsToArray(symbols); function populateSymbols() { @@ -38429,7 +38759,7 @@ var ts; } case 229: case 230: - if (!(memberFlags & 32)) { + if (!isStatic) { copySymbols(getSymbolOfNode(location).members, meaning & 793064); } break; @@ -38443,7 +38773,7 @@ var ts; if (ts.introducesArgumentsExoticObject(location)) { copySymbol(argumentsSymbol, meaning); } - memberFlags = ts.getModifierFlags(location); + isStatic = ts.hasModifier(location, 32); location = location.parent; } copySymbols(globals, meaning); @@ -38678,12 +39008,7 @@ var ts; case 8: if (node.parent.kind === 180 && node.parent.argumentExpression === node) { var objectType = getTypeOfExpression(node.parent.expression); - if (objectType === unknownType) - return undefined; - var apparentType = getApparentType(objectType); - if (apparentType === unknownType) - return undefined; - return getPropertyOfType(apparentType, node.text); + return getPropertyOfType(objectType, node.text); } break; } @@ -38779,7 +39104,7 @@ var ts; } function getParentTypeOfClassElement(node) { var classSymbol = getSymbolOfNode(node.parent); - return ts.getModifierFlags(node) & 32 + return ts.hasModifier(node, 32) ? getTypeOfSymbol(classSymbol) : getDeclaredTypeOfSymbol(classSymbol); } @@ -38798,9 +39123,9 @@ var ts; function getRootSymbols(symbol) { if (ts.getCheckFlags(symbol) & 6) { var symbols_4 = []; - var name_2 = symbol.escapedName; + var name_33 = symbol.escapedName; ts.forEach(getSymbolLinks(symbol).containingType.types, function (t) { - var symbol = getPropertyOfType(t, name_2); + var symbol = getPropertyOfType(t, name_33); if (symbol) { symbols_4.push(symbol); } @@ -39004,13 +39329,13 @@ var ts; return strictNullChecks && !isOptionalParameter(parameter) && parameter.initializer && - !(ts.getModifierFlags(parameter) & 92); + !ts.hasModifier(parameter, 92); } function isOptionalUninitializedParameterProperty(parameter) { return strictNullChecks && isOptionalParameter(parameter) && !parameter.initializer && - !!(ts.getModifierFlags(parameter) & 92); + ts.hasModifier(parameter, 92); } function getNodeCheckFlags(node) { return getNodeLinks(node).flags; @@ -39066,22 +39391,22 @@ var ts; else if (type.flags & 1) { return ts.TypeReferenceSerializationKind.ObjectType; } - else if (isTypeOfKind(type, 1024 | 6144 | 8192)) { + else if (isTypeAssignableToKind(type, 1024 | 6144 | 8192)) { return ts.TypeReferenceSerializationKind.VoidNullableOrNeverType; } - else if (isTypeOfKind(type, 136)) { + else if (isTypeAssignableToKind(type, 136)) { return ts.TypeReferenceSerializationKind.BooleanType; } - else if (isTypeOfKind(type, 84)) { + else if (isTypeAssignableToKind(type, 84)) { return ts.TypeReferenceSerializationKind.NumberLikeType; } - else if (isTypeOfKind(type, 262178)) { + else if (isTypeAssignableToKind(type, 262178)) { return ts.TypeReferenceSerializationKind.StringLikeType; } else if (isTupleType(type)) { return ts.TypeReferenceSerializationKind.ArrayLikeType; } - else if (isTypeOfKind(type, 512)) { + else if (isTypeAssignableToKind(type, 512)) { return ts.TypeReferenceSerializationKind.ESSymbolType; } else if (isFunctionType(type)) { @@ -39122,9 +39447,9 @@ var ts; } var location = reference; if (startInDeclarationContainer) { - var parent = reference.parent; - if (ts.isDeclaration(parent) && reference === parent.name) { - location = getDeclarationContainer(parent); + var parent_16 = reference.parent; + if (ts.isDeclaration(parent_16) && reference === parent_16.name) { + location = getDeclarationContainer(parent_16); } } return resolveName(location, reference.escapedText, 107455 | 1048576 | 2097152, undefined, undefined); @@ -39249,9 +39574,9 @@ var ts; } var current = symbol; while (true) { - var parent = getParentOfSymbol(current); - if (parent) { - current = parent; + var parent_17 = getParentOfSymbol(current); + if (parent_17) { + current = parent_17; } else { break; @@ -39339,10 +39664,10 @@ var ts; var uncheckedHelpers = helpers & ~requestedExternalEmitHelpers; for (var helper = 1; helper <= 32768; helper <<= 1) { if (uncheckedHelpers & helper) { - var name = getHelperName(helper); - var symbol = getSymbol(helpersModule.exports, ts.escapeLeadingUnderscores(name), 107455); + var name_34 = getHelperName(helper); + var symbol = getSymbol(helpersModule.exports, ts.escapeLeadingUnderscores(name_34), 107455); if (!symbol) { - error(location, ts.Diagnostics.This_syntax_requires_an_imported_helper_named_1_but_module_0_has_no_exported_member_1, ts.externalHelpersModuleNameText, name); + error(location, ts.Diagnostics.This_syntax_requires_an_imported_helper_named_1_but_module_0_has_no_exported_member_1, ts.externalHelpersModuleNameText, name_34); } } } @@ -39546,7 +39871,7 @@ var ts; node.kind !== 154) { return grammarErrorOnNode(modifier, ts.Diagnostics.abstract_modifier_can_only_appear_on_a_class_method_or_property_declaration); } - if (!(node.parent.kind === 229 && ts.getModifierFlags(node.parent) & 128)) { + if (!(node.parent.kind === 229 && ts.hasModifier(node.parent, 128))) { return grammarErrorOnNode(modifier, ts.Diagnostics.Abstract_methods_can_only_appear_within_an_abstract_class); } if (flags & 32) { @@ -39665,8 +39990,7 @@ var ts; if (list && list.hasTrailingComma) { var start = list.end - ",".length; var end = list.end; - var sourceFile = ts.getSourceFileOfNode(list[0]); - return grammarErrorAtPos(sourceFile, start, end - start, ts.Diagnostics.Trailing_comma_not_allowed); + return grammarErrorAtPos(list[0], start, end - start, ts.Diagnostics.Trailing_comma_not_allowed); } } function checkGrammarTypeParameterList(typeParameters, file) { @@ -39742,7 +40066,7 @@ var ts; if (parameter.dotDotDotToken) { return grammarErrorOnNode(parameter.dotDotDotToken, ts.Diagnostics.An_index_signature_cannot_have_a_rest_parameter); } - if (ts.getModifierFlags(parameter) !== 0) { + if (ts.hasModifiers(parameter)) { return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_cannot_have_an_accessibility_modifier); } if (parameter.questionToken) { @@ -39776,19 +40100,18 @@ var ts; return checkGrammarForDisallowedTrailingComma(typeArguments) || checkGrammarForAtLeastOneTypeArgument(node, typeArguments); } - function checkGrammarForOmittedArgument(node, args) { + function checkGrammarForOmittedArgument(args) { if (args) { - var sourceFile = ts.getSourceFileOfNode(node); for (var _i = 0, args_5 = args; _i < args_5.length; _i++) { var arg = args_5[_i]; if (arg.kind === 200) { - return grammarErrorAtPos(sourceFile, arg.pos, 0, ts.Diagnostics.Argument_expression_expected); + return grammarErrorAtPos(arg, arg.pos, 0, ts.Diagnostics.Argument_expression_expected); } } } } - function checkGrammarArguments(node, args) { - return checkGrammarForOmittedArgument(node, args); + function checkGrammarArguments(args) { + return checkGrammarForOmittedArgument(args); } function checkGrammarHeritageClause(node) { var types = node.types; @@ -39797,8 +40120,7 @@ var ts; } if (types && types.length === 0) { var listType = ts.tokenToString(node.token); - var sourceFile = ts.getSourceFileOfNode(node); - return grammarErrorAtPos(sourceFile, types.pos, 0, ts.Diagnostics._0_list_cannot_be_empty, listType); + return grammarErrorAtPos(node, types.pos, 0, ts.Diagnostics._0_list_cannot_be_empty, listType); } return ts.forEach(types, checkGrammarExpressionWithTypeArguments); } @@ -39892,9 +40214,9 @@ var ts; if (prop.kind === 263) { continue; } - var name = prop.name; - if (name.kind === 144) { - checkGrammarComputedPropertyName(name); + var name_35 = prop.name; + if (name_35.kind === 144) { + checkGrammarComputedPropertyName(name_35); } if (prop.kind === 262 && !inDestructuring && prop.objectAssignmentInitializer) { return grammarErrorOnNode(prop.equalsToken, ts.Diagnostics.can_only_be_used_in_an_object_literal_property_inside_a_destructuring_assignment); @@ -39910,8 +40232,8 @@ var ts; var currentKind = void 0; if (prop.kind === 261 || prop.kind === 262) { checkGrammarForInvalidQuestionMark(prop.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional); - if (name.kind === 8) { - checkGrammarNumericLiteral(name); + if (name_35.kind === 8) { + checkGrammarNumericLiteral(name_35); } currentKind = Property; } @@ -39927,7 +40249,7 @@ var ts; else { ts.Debug.fail("Unexpected syntax kind:" + prop.kind); } - var effectiveName = ts.getPropertyNameForPropertyNameNode(name); + var effectiveName = ts.getPropertyNameForPropertyNameNode(name_35); if (effectiveName === undefined) { continue; } @@ -39937,18 +40259,18 @@ var ts; } else { if (currentKind === Property && existingKind === Property) { - grammarErrorOnNode(name, ts.Diagnostics.Duplicate_identifier_0, ts.getTextOfNode(name)); + grammarErrorOnNode(name_35, ts.Diagnostics.Duplicate_identifier_0, ts.getTextOfNode(name_35)); } else if ((currentKind & GetOrSetAccessor) && (existingKind & GetOrSetAccessor)) { if (existingKind !== GetOrSetAccessor && currentKind !== existingKind) { seen.set(effectiveName, currentKind | existingKind); } else { - return grammarErrorOnNode(name, ts.Diagnostics.An_object_literal_cannot_have_multiple_get_Slashset_accessors_with_the_same_name); + return grammarErrorOnNode(name_35, ts.Diagnostics.An_object_literal_cannot_have_multiple_get_Slashset_accessors_with_the_same_name); } } else { - return grammarErrorOnNode(name, ts.Diagnostics.An_object_literal_cannot_have_property_and_accessor_with_the_same_name); + return grammarErrorOnNode(name_35, ts.Diagnostics.An_object_literal_cannot_have_property_and_accessor_with_the_same_name); } } } @@ -39961,12 +40283,12 @@ var ts; continue; } var jsxAttr = attr; - var name = jsxAttr.name; - if (!seen.get(name.escapedText)) { - seen.set(name.escapedText, true); + var name_36 = jsxAttr.name; + if (!seen.get(name_36.escapedText)) { + seen.set(name_36.escapedText, true); } else { - return grammarErrorOnNode(name, ts.Diagnostics.JSX_elements_cannot_have_multiple_attributes_with_the_same_name); + return grammarErrorOnNode(name_36, ts.Diagnostics.JSX_elements_cannot_have_multiple_attributes_with_the_same_name); } var initializer = jsxAttr.initializer; if (initializer && initializer.kind === 256 && !initializer.expression) { @@ -40021,10 +40343,10 @@ var ts; else if (ts.isInAmbientContext(accessor)) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.An_accessor_cannot_be_declared_in_an_ambient_context); } - else if (accessor.body === undefined && !(ts.getModifierFlags(accessor) & 128)) { - return grammarErrorAtPos(ts.getSourceFileOfNode(accessor), accessor.end - 1, ";".length, ts.Diagnostics._0_expected, "{"); + else if (accessor.body === undefined && !ts.hasModifier(accessor, 128)) { + return grammarErrorAtPos(accessor, accessor.end - 1, ";".length, ts.Diagnostics._0_expected, "{"); } - else if (accessor.body && ts.getModifierFlags(accessor) & 128) { + else if (accessor.body && ts.hasModifier(accessor, 128)) { return grammarErrorOnNode(accessor, ts.Diagnostics.An_abstract_accessor_cannot_have_an_implementation); } else if (accessor.typeParameters) { @@ -40077,7 +40399,7 @@ var ts; return true; } else if (node.body === undefined) { - return grammarErrorAtPos(ts.getSourceFileOfNode(node), node.end - 1, ";".length, ts.Diagnostics._0_expected, "{"); + return grammarErrorAtPos(node, node.end - 1, ";".length, ts.Diagnostics._0_expected, "{"); } } if (ts.isClassLike(node.parent)) { @@ -40148,7 +40470,7 @@ var ts; return grammarErrorOnNode(node.name, ts.Diagnostics.A_rest_element_cannot_contain_a_binding_pattern); } if (node.initializer) { - return grammarErrorAtPos(ts.getSourceFileOfNode(node), node.initializer.pos - 1, 1, ts.Diagnostics.A_rest_element_cannot_have_an_initializer); + return grammarErrorAtPos(node, node.initializer.pos - 1, 1, ts.Diagnostics.A_rest_element_cannot_have_an_initializer); } } } @@ -40168,12 +40490,12 @@ var ts; } else { var equalsTokenLength = "=".length; - return grammarErrorAtPos(ts.getSourceFileOfNode(node), node.initializer.pos - equalsTokenLength, equalsTokenLength, ts.Diagnostics.Initializers_are_not_allowed_in_ambient_contexts); + return grammarErrorAtPos(node, node.initializer.pos - equalsTokenLength, equalsTokenLength, ts.Diagnostics.Initializers_are_not_allowed_in_ambient_contexts); } } if (node.initializer && !(ts.isConst(node) && isStringOrNumberLiteralExpression(node.initializer))) { var equalsTokenLength = "=".length; - return grammarErrorAtPos(ts.getSourceFileOfNode(node), node.initializer.pos - equalsTokenLength, equalsTokenLength, ts.Diagnostics.Initializers_are_not_allowed_in_ambient_contexts); + return grammarErrorAtPos(node, node.initializer.pos - equalsTokenLength, equalsTokenLength, ts.Diagnostics.Initializers_are_not_allowed_in_ambient_contexts); } } else if (!node.initializer) { @@ -40230,7 +40552,7 @@ var ts; return true; } if (!declarationList.declarations.length) { - return grammarErrorAtPos(ts.getSourceFileOfNode(declarationList), declarations.pos, declarations.end - declarations.pos, ts.Diagnostics.Variable_declaration_list_cannot_be_empty); + return grammarErrorAtPos(declarationList, declarations.pos, declarations.end - declarations.pos, ts.Diagnostics.Variable_declaration_list_cannot_be_empty); } } function allowLetAndConstDeclarations(parent) { @@ -40276,7 +40598,8 @@ var ts; return true; } } - function grammarErrorAtPos(sourceFile, start, length, message, arg0, arg1, arg2) { + function grammarErrorAtPos(nodeForSourceFile, start, length, message, arg0, arg1, arg2) { + var sourceFile = ts.getSourceFileOfNode(nodeForSourceFile); if (!hasParseDiagnostics(sourceFile)) { diagnostics.add(ts.createFileDiagnostic(sourceFile, start, length, message, arg0, arg1, arg2)); return true; @@ -40291,7 +40614,7 @@ var ts; } function checkGrammarConstructorTypeParameters(node) { if (node.typeParameters) { - return grammarErrorAtPos(ts.getSourceFileOfNode(node), node.typeParameters.pos, node.typeParameters.end - node.typeParameters.pos, ts.Diagnostics.Type_parameters_cannot_appear_on_a_constructor_declaration); + return grammarErrorAtPos(node, node.typeParameters.pos, node.typeParameters.end - node.typeParameters.pos, ts.Diagnostics.Type_parameters_cannot_appear_on_a_constructor_declaration); } } function checkGrammarConstructorTypeAnnotation(node) { @@ -40333,7 +40656,7 @@ var ts; node.kind === 244 || node.kind === 243 || node.kind === 236 || - ts.getModifierFlags(node) & (2 | 1 | 512)) { + ts.hasModifier(node, 2 | 1 | 512)) { return false; } return grammarErrorOnFirstToken(node, ts.Diagnostics.A_declare_modifier_is_required_for_a_top_level_declaration_in_a_d_ts_file); @@ -43102,27 +43425,27 @@ var ts; function createExpressionForAccessorDeclaration(properties, property, receiver, multiLine) { var _a = ts.getAllAccessorDeclarations(properties, property), firstAccessor = _a.firstAccessor, getAccessor = _a.getAccessor, setAccessor = _a.setAccessor; if (property === firstAccessor) { - var properties_8 = []; + var properties_9 = []; if (getAccessor) { var getterFunction = ts.createFunctionExpression(getAccessor.modifiers, undefined, undefined, undefined, getAccessor.parameters, undefined, getAccessor.body); ts.setTextRange(getterFunction, getAccessor); ts.setOriginalNode(getterFunction, getAccessor); var getter = ts.createPropertyAssignment("get", getterFunction); - properties_8.push(getter); + properties_9.push(getter); } if (setAccessor) { var setterFunction = ts.createFunctionExpression(setAccessor.modifiers, undefined, undefined, undefined, setAccessor.parameters, undefined, setAccessor.body); ts.setTextRange(setterFunction, setAccessor); ts.setOriginalNode(setterFunction, setAccessor); var setter = ts.createPropertyAssignment("set", setterFunction); - properties_8.push(setter); + properties_9.push(setter); } - properties_8.push(ts.createPropertyAssignment("enumerable", ts.createTrue())); - properties_8.push(ts.createPropertyAssignment("configurable", ts.createTrue())); + properties_9.push(ts.createPropertyAssignment("enumerable", ts.createTrue())); + properties_9.push(ts.createPropertyAssignment("configurable", ts.createTrue())); var expression = ts.setTextRange(ts.createCall(ts.createPropertyAccess(ts.createIdentifier("Object"), "defineProperty"), undefined, [ receiver, createExpressionForPropertyName(property.name), - ts.createObjectLiteral(properties_8, multiLine) + ts.createObjectLiteral(properties_9, multiLine) ]), firstAccessor); return ts.aggregateTransformFlags(expression); } @@ -43168,15 +43491,15 @@ var ts; function getName(node, allowComments, allowSourceMaps, emitFlags) { var nodeName = ts.getNameOfDeclaration(node); if (nodeName && ts.isIdentifier(nodeName) && !ts.isGeneratedIdentifier(nodeName)) { - var name = ts.getMutableClone(nodeName); + var name_37 = ts.getMutableClone(nodeName); emitFlags |= ts.getEmitFlags(nodeName); if (!allowSourceMaps) emitFlags |= 48; if (!allowComments) emitFlags |= 1536; if (emitFlags) - ts.setEmitFlags(name, emitFlags); - return name; + ts.setEmitFlags(name_37, emitFlags); + return name_37; } return ts.getGeneratedNameForNode(node); } @@ -43643,8 +43966,8 @@ var ts; function getLocalNameForExternalImport(node, sourceFile) { var namespaceDeclaration = ts.getNamespaceDeclarationNode(node); if (namespaceDeclaration && !ts.isDefaultImport(node)) { - var name = namespaceDeclaration.name; - return ts.isGeneratedIdentifier(name) ? name : ts.createIdentifier(ts.getSourceTextOfNodeFromSourceFile(sourceFile, namespaceDeclaration.name)); + var name_38 = namespaceDeclaration.name; + return ts.isGeneratedIdentifier(name_38) ? name_38 : ts.createIdentifier(ts.getSourceTextOfNodeFromSourceFile(sourceFile, namespaceDeclaration.name)); } if (node.kind === 238 && node.importClause) { return ts.getGeneratedNameForNode(node); @@ -44765,10 +45088,10 @@ var ts; for (var _b = 0, _c = node.exportClause.elements; _b < _c.length; _b++) { var specifier = _c[_b]; if (!uniqueExports.get(ts.unescapeLeadingUnderscores(specifier.name.escapedText))) { - var name = specifier.propertyName || specifier.name; - exportSpecifiers.add(ts.unescapeLeadingUnderscores(name.escapedText), specifier); - var decl = resolver.getReferencedImportDeclaration(name) - || resolver.getReferencedValueDeclaration(name); + var name_39 = specifier.propertyName || specifier.name; + exportSpecifiers.add(ts.unescapeLeadingUnderscores(name_39.escapedText), specifier); + var decl = resolver.getReferencedImportDeclaration(name_39) + || resolver.getReferencedValueDeclaration(name_39); if (decl) { multiMapSparseArrayAdd(exportedBindings, getOriginalNodeId(decl), specifier.name); } @@ -44800,11 +45123,11 @@ var ts; } } else { - var name = node.name; - if (!uniqueExports.get(ts.unescapeLeadingUnderscores(name.escapedText))) { - multiMapSparseArrayAdd(exportedBindings, getOriginalNodeId(node), name); - uniqueExports.set(ts.unescapeLeadingUnderscores(name.escapedText), true); - exportedNames = ts.append(exportedNames, name); + var name_40 = node.name; + if (!uniqueExports.get(ts.unescapeLeadingUnderscores(name_40.escapedText))) { + multiMapSparseArrayAdd(exportedBindings, getOriginalNodeId(node), name_40); + uniqueExports.set(ts.unescapeLeadingUnderscores(name_40.escapedText), true); + exportedNames = ts.append(exportedNames, name_40); } } } @@ -44818,11 +45141,11 @@ var ts; } } else { - var name = node.name; - if (!uniqueExports.get(ts.unescapeLeadingUnderscores(name.escapedText))) { - multiMapSparseArrayAdd(exportedBindings, getOriginalNodeId(node), name); - uniqueExports.set(ts.unescapeLeadingUnderscores(name.escapedText), true); - exportedNames = ts.append(exportedNames, name); + var name_41 = node.name; + if (!uniqueExports.get(ts.unescapeLeadingUnderscores(name_41.escapedText))) { + multiMapSparseArrayAdd(exportedBindings, getOriginalNodeId(node), name_41); + uniqueExports.set(ts.unescapeLeadingUnderscores(name_41.escapedText), true); + exportedNames = ts.append(exportedNames, name_41); } } } @@ -44965,11 +45288,11 @@ var ts; } } for (var _i = 0, pendingDeclarations_1 = pendingDeclarations; _i < pendingDeclarations_1.length; _i++) { - var _a = pendingDeclarations_1[_i], pendingExpressions_1 = _a.pendingExpressions, name = _a.name, value = _a.value, location = _a.location, original = _a.original; - var variable = ts.createVariableDeclaration(name, undefined, pendingExpressions_1 ? ts.inlineExpressions(ts.append(pendingExpressions_1, value)) : value); + var _a = pendingDeclarations_1[_i], pendingExpressions_1 = _a.pendingExpressions, name_42 = _a.name, value = _a.value, location_2 = _a.location, original = _a.original; + var variable = ts.createVariableDeclaration(name_42, undefined, pendingExpressions_1 ? ts.inlineExpressions(ts.append(pendingExpressions_1, value)) : value); variable.original = original; - ts.setTextRange(variable, location); - if (ts.isIdentifier(name)) { + ts.setTextRange(variable, location_2); + if (ts.isIdentifier(name_42)) { ts.setEmitFlags(variable, 64); } ts.aggregateTransformFlags(variable); @@ -45062,7 +45385,8 @@ var ts; ? undefined : numElements, location), false, location); } - else if (numElements !== 1 && (flattenContext.level < 1 || numElements === 0)) { + else if (numElements !== 1 && (flattenContext.level < 1 || numElements === 0) + || ts.every(elements, ts.isOmittedExpression)) { var reuseIdentifierExpressions = !ts.isDeclarationBindingElement(parent) || numElements !== 0; value = ensureIdentifier(flattenContext, value, reuseIdentifierExpressions, location); } @@ -45120,8 +45444,8 @@ var ts; return ts.createElementAccess(value, argumentExpression); } else { - var name = ts.createIdentifier(ts.unescapeLeadingUnderscores(propertyName.escapedText)); - return ts.createPropertyAccess(value, name); + var name_43 = ts.createIdentifier(ts.unescapeLeadingUnderscores(propertyName.escapedText)); + return ts.createPropertyAccess(value, name_43); } } function ensureIdentifier(flattenContext, value, reuseIdentifierExpressions, location) { @@ -45269,7 +45593,12 @@ var ts; if (ts.hasModifier(node, 2)) { break; } - recordEmittedDeclarationInScope(node); + if (node.name) { + recordEmittedDeclarationInScope(node); + } + else { + ts.Debug.assert(node.kind === 229 || ts.hasModifier(node, 512)); + } break; } } @@ -45683,8 +46012,8 @@ var ts; && member.initializer !== undefined; } function addInitializedPropertyStatements(statements, properties, receiver) { - for (var _i = 0, properties_9 = properties; _i < properties_9.length; _i++) { - var property = properties_9[_i]; + for (var _i = 0, properties_10 = properties; _i < properties_10.length; _i++) { + var property = properties_10[_i]; var statement = ts.createStatement(transformInitializedProperty(property, receiver)); ts.setSourceMapRange(statement, ts.moveRangePastModifiers(property)); ts.setCommentRange(statement, property); @@ -45693,8 +46022,8 @@ var ts; } function generateInitializedPropertyExpressions(properties, receiver) { var expressions = []; - for (var _i = 0, properties_10 = properties; _i < properties_10.length; _i++) { - var property = properties_10[_i]; + for (var _i = 0, properties_11 = properties; _i < properties_11.length; _i++) { + var property = properties_11[_i]; var expression = transformInitializedProperty(property, receiver); expression.startsOnNewLine = true; ts.setSourceMapRange(expression, ts.moveRangePastModifiers(property)); @@ -46117,14 +46446,14 @@ var ts; function serializeEntityNameAsExpression(node, useFallback) { switch (node.kind) { case 71: - var name = ts.getMutableClone(node); - name.flags &= ~8; - name.original = undefined; - name.parent = currentScope; + var name_44 = ts.getMutableClone(node); + name_44.flags &= ~8; + name_44.original = undefined; + name_44.parent = currentScope; if (useFallback) { - return ts.createLogicalAnd(ts.createStrictInequality(ts.createTypeOf(name), ts.createLiteral("undefined")), name); + return ts.createLogicalAnd(ts.createStrictInequality(ts.createTypeOf(name_44), ts.createLiteral("undefined")), name_44); } - return name; + return name_44; case 143: return serializeQualifiedNameAsExpression(node, useFallback); } @@ -46389,24 +46718,24 @@ var ts; && moduleKind !== ts.ModuleKind.System); } function recordEmittedDeclarationInScope(node) { - var name = node.symbol && node.symbol.escapedName; - if (name) { - if (!currentScopeFirstDeclarationsOfName) { - currentScopeFirstDeclarationsOfName = ts.createUnderscoreEscapedMap(); - } - if (!currentScopeFirstDeclarationsOfName.has(name)) { - currentScopeFirstDeclarationsOfName.set(name, node); - } + if (!currentScopeFirstDeclarationsOfName) { + currentScopeFirstDeclarationsOfName = ts.createUnderscoreEscapedMap(); + } + var name = declaredNameInScope(node); + if (!currentScopeFirstDeclarationsOfName.has(name)) { + currentScopeFirstDeclarationsOfName.set(name, node); } } function isFirstEmittedDeclarationInScope(node) { if (currentScopeFirstDeclarationsOfName) { - var name = node.symbol && node.symbol.escapedName; - if (name) { - return currentScopeFirstDeclarationsOfName.get(name) === node; - } + var name_45 = declaredNameInScope(node); + return currentScopeFirstDeclarationsOfName.get(name_45) === node; } - return false; + return true; + } + function declaredNameInScope(node) { + ts.Debug.assertNode(node.name, ts.isIdentifier); + return node.name.escapedText; } function addVarForEnumOrModuleDeclaration(statements, node) { var statement = ts.createVariableStatement(ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), ts.createVariableDeclarationList([ @@ -46437,7 +46766,7 @@ var ts; if (!shouldEmitModuleDeclaration(node)) { return ts.createNotEmittedStatement(node); } - ts.Debug.assert(ts.isIdentifier(node.name), "TypeScript module should have an Identifier name."); + ts.Debug.assertNode(node.name, ts.isIdentifier, "A TypeScript namespace should have an Identifier name."); enableSubstitutionForNamespaceExports(); var statements = []; var emitFlags = 2; @@ -46699,14 +47028,14 @@ var ts; } function substituteShorthandPropertyAssignment(node) { if (enabledSubstitutions & 2) { - var name = node.name; - var exportedName = trySubstituteNamespaceExportedName(name); + var name_46 = node.name; + var exportedName = trySubstituteNamespaceExportedName(name_46); if (exportedName) { if (node.objectAssignmentInitializer) { var initializer = ts.createAssignment(exportedName, node.objectAssignmentInitializer); - return ts.setTextRange(ts.createPropertyAssignment(name, initializer), node); + return ts.setTextRange(ts.createPropertyAssignment(name_46, initializer), node); } - return ts.setTextRange(ts.createPropertyAssignment(name, exportedName), node); + return ts.setTextRange(ts.createPropertyAssignment(name_46, exportedName), node); } } return node; @@ -47161,6 +47490,8 @@ var ts; return visitExpressionStatement(node); case 185: return visitParenthesizedExpression(node, noDestructuringValue); + case 260: + return visitCatchClause(node); default: return ts.visitEachChild(node, visitor, context); } @@ -47235,6 +47566,12 @@ var ts; function visitParenthesizedExpression(node, noDestructuringValue) { return ts.visitEachChild(node, noDestructuringValue ? visitorNoDestructuringValue : visitor, context); } + function visitCatchClause(node) { + if (!node.variableDeclaration) { + return ts.updateCatchClause(node, ts.createVariableDeclaration(ts.createTempVariable(undefined)), ts.visitNode(node.block, visitor, ts.isBlock)); + } + return ts.visitEachChild(node, visitor, context); + } function visitBinaryExpression(node, noDestructuringValue) { if (ts.isDestructuringAssignment(node) && node.left.transformFlags & 1048576) { return ts.flattenDestructuringAssignment(node, visitor, context, 1, !noDestructuringValue); @@ -47681,7 +48018,7 @@ var ts; objectProperties = ts.createAssignHelper(context, segments); } } - var element = ts.createExpressionForJsxElement(context.getEmitResolver().getJsxFactoryEntity(), compilerOptions.reactNamespace, tagName, objectProperties, ts.filter(ts.map(children, transformJsxChildToExpression), ts.isDefined), node, location); + var element = ts.createExpressionForJsxElement(context.getEmitResolver().getJsxFactoryEntity(), compilerOptions.reactNamespace, tagName, objectProperties, ts.mapDefined(children, transformJsxChildToExpression), node, location); if (isChild) { ts.startOnNewLine(element); } @@ -47767,12 +48104,12 @@ var ts; return getTagName(node.openingElement); } else { - var name = node.tagName; - if (ts.isIdentifier(name) && ts.isIntrinsicJsxName(name.escapedText)) { - return ts.createLiteral(ts.unescapeLeadingUnderscores(name.escapedText)); + var name_47 = node.tagName; + if (ts.isIdentifier(name_47) && ts.isIntrinsicJsxName(name_47.escapedText)) { + return ts.createLiteral(ts.unescapeLeadingUnderscores(name_47.escapedText)); } else { - return ts.createExpressionFromEntityName(name); + return ts.createExpressionFromEntityName(name_47); } } } @@ -48268,7 +48605,7 @@ var ts; function shouldVisitNode(node) { return (node.transformFlags & 128) !== 0 || convertedLoopState !== undefined - || (hierarchyFacts & 4096 && ts.isStatement(node)) + || (hierarchyFacts & 4096 && (ts.isStatement(node) || (node.kind === 207))) || (ts.isIterationStatement(node, false) && shouldConvertIterationStatementBody(node)) || isTypeScriptClassWrapper(node); } @@ -48548,9 +48885,11 @@ var ts; var outer = ts.createPartiallyEmittedExpression(inner); outer.end = ts.skipTrivia(currentText, node.pos); ts.setEmitFlags(outer, 1536); - return ts.createParen(ts.createCall(outer, undefined, extendsClauseElement + var result = ts.createParen(ts.createCall(outer, undefined, extendsClauseElement ? [ts.visitNode(extendsClauseElement.expression, visitor, ts.isExpression)] : [])); + ts.addSyntheticLeadingComment(result, 3, "* @class "); + return result; } function transformClassBody(node, extendsClauseElement) { var statements = []; @@ -48732,15 +49071,15 @@ var ts; } for (var _i = 0, _a = node.parameters; _i < _a.length; _i++) { var parameter = _a[_i]; - var name = parameter.name, initializer = parameter.initializer, dotDotDotToken = parameter.dotDotDotToken; + var name_48 = parameter.name, initializer = parameter.initializer, dotDotDotToken = parameter.dotDotDotToken; if (dotDotDotToken) { continue; } - if (ts.isBindingPattern(name)) { - addDefaultValueAssignmentForBindingPattern(statements, parameter, name, initializer); + if (ts.isBindingPattern(name_48)) { + addDefaultValueAssignmentForBindingPattern(statements, parameter, name_48, initializer); } else if (initializer) { - addDefaultValueAssignmentForInitializer(statements, parameter, name, initializer); + addDefaultValueAssignmentForInitializer(statements, parameter, name_48, initializer); } } } @@ -49135,11 +49474,12 @@ var ts; ts.setTextRange(declarationList, node); ts.setCommentRange(declarationList, node); if (node.transformFlags & 8388608 - && (ts.isBindingPattern(node.declarations[0].name) - || ts.isBindingPattern(ts.lastOrUndefined(node.declarations).name))) { + && (ts.isBindingPattern(node.declarations[0].name) || ts.isBindingPattern(ts.lastOrUndefined(node.declarations).name))) { var firstDeclaration = ts.firstOrUndefined(declarations); - var lastDeclaration = ts.lastOrUndefined(declarations); - ts.setSourceMapRange(declarationList, ts.createRange(firstDeclaration.pos, lastDeclaration.end)); + if (firstDeclaration) { + var lastDeclaration = ts.lastOrUndefined(declarations); + ts.setSourceMapRange(declarationList, ts.createRange(firstDeclaration.pos, lastDeclaration.end)); + } } return declarationList; } @@ -49678,6 +50018,7 @@ var ts; function visitCatchClause(node) { var ancestorFacts = enterSubtree(4032, 0); var updated; + ts.Debug.assert(!!node.variableDeclaration, "Catch clause variable should always be present when downleveling ES2015."); if (ts.isBindingPattern(node.variableDeclaration.name)) { var temp = ts.createTempVariable(undefined); var newVariableDeclaration = ts.createVariableDeclaration(temp); @@ -50712,9 +51053,9 @@ var ts; function transformAndEmitVariableDeclarationList(node) { for (var _i = 0, _a = node.declarations; _i < _a.length; _i++) { var variable = _a[_i]; - var name = ts.getSynthesizedClone(variable.name); - ts.setCommentRange(name, variable.name); - hoistVariableDeclaration(name); + var name_49 = ts.getSynthesizedClone(variable.name); + ts.setCommentRange(name_49, variable.name); + hoistVariableDeclaration(name_49); } var variables = ts.getInitializedVariables(node); var numVariables = variables.length; @@ -50925,8 +51266,12 @@ var ts; } function transformAndEmitContinueStatement(node) { var label = findContinueTarget(node.label ? ts.unescapeLeadingUnderscores(node.label.escapedText) : undefined); - ts.Debug.assert(label > 0, "Expected continue statment to point to a valid Label."); - emitBreak(label, node); + if (label > 0) { + emitBreak(label, node); + } + else { + emitStatement(node); + } } function visitContinueStatement(node) { if (inStatementContainingYield) { @@ -50939,8 +51284,12 @@ var ts; } function transformAndEmitBreakStatement(node) { var label = findBreakTarget(node.label ? ts.unescapeLeadingUnderscores(node.label.escapedText) : undefined); - ts.Debug.assert(label > 0, "Expected break statment to point to a valid Label."); - emitBreak(label, node); + if (label > 0) { + emitBreak(label, node); + } + else { + emitStatement(node); + } } function visitBreakStatement(node) { if (inStatementContainingYield) { @@ -51109,9 +51458,9 @@ var ts; if (ts.isIdentifier(original) && original.parent) { var declaration = resolver.getReferencedValueDeclaration(original); if (declaration) { - var name = renamedCatchVariableDeclarations[ts.getOriginalNodeId(declaration)]; - if (name) { - var clone_6 = ts.getMutableClone(name); + var name_50 = renamedCatchVariableDeclarations[ts.getOriginalNodeId(declaration)]; + if (name_50) { + var clone_6 = ts.getMutableClone(name_50); ts.setSourceMapRange(clone_6, node); ts.setCommentRange(clone_6, node); return clone_6; @@ -51197,9 +51546,6 @@ var ts; var block = endBlock(); markLabel(block.endLabel); } - function isWithBlock(block) { - return block.kind === 1; - } function beginExceptionBlock() { var startLabel = defineLabel(); var endLabel = defineLabel(); @@ -51268,9 +51614,6 @@ var ts; emitNop(); exception.state = 3; } - function isExceptionBlock(block) { - return block.kind === 0; - } function beginScriptLoopBlock() { beginBlock({ kind: 3, @@ -51370,43 +51713,45 @@ var ts; return false; } function findBreakTarget(labelText) { - ts.Debug.assert(blocks !== undefined); - if (labelText) { - for (var i = blockStack.length - 1; i >= 0; i--) { - var block = blockStack[i]; - if (supportsLabeledBreakOrContinue(block) && block.labelText === labelText) { - return block.breakLabel; - } - else if (supportsUnlabeledBreak(block) && hasImmediateContainingLabeledBlock(labelText, i - 1)) { - return block.breakLabel; + if (blockStack) { + if (labelText) { + for (var i = blockStack.length - 1; i >= 0; i--) { + var block = blockStack[i]; + if (supportsLabeledBreakOrContinue(block) && block.labelText === labelText) { + return block.breakLabel; + } + else if (supportsUnlabeledBreak(block) && hasImmediateContainingLabeledBlock(labelText, i - 1)) { + return block.breakLabel; + } } } - } - else { - for (var i = blockStack.length - 1; i >= 0; i--) { - var block = blockStack[i]; - if (supportsUnlabeledBreak(block)) { - return block.breakLabel; + else { + for (var i = blockStack.length - 1; i >= 0; i--) { + var block = blockStack[i]; + if (supportsUnlabeledBreak(block)) { + return block.breakLabel; + } } } } return 0; } function findContinueTarget(labelText) { - ts.Debug.assert(blocks !== undefined); - if (labelText) { - for (var i = blockStack.length - 1; i >= 0; i--) { - var block = blockStack[i]; - if (supportsUnlabeledContinue(block) && hasImmediateContainingLabeledBlock(labelText, i - 1)) { - return block.continueLabel; + if (blockStack) { + if (labelText) { + for (var i = blockStack.length - 1; i >= 0; i--) { + var block = blockStack[i]; + if (supportsUnlabeledContinue(block) && hasImmediateContainingLabeledBlock(labelText, i - 1)) { + return block.continueLabel; + } } } - } - else { - for (var i = blockStack.length - 1; i >= 0; i--) { - var block = blockStack[i]; - if (supportsUnlabeledContinue(block)) { - return block.continueLabel; + else { + for (var i = blockStack.length - 1; i >= 0; i--) { + var block = blockStack[i]; + if (supportsUnlabeledContinue(block)) { + return block.continueLabel; + } } } } @@ -51434,7 +51779,7 @@ var ts; return literal; } function createInlineBreak(label, location) { - ts.Debug.assert(label > 0, "Invalid label: " + label); + ts.Debug.assertLessThan(0, label, "Invalid label"); return ts.setTextRange(ts.createReturn(ts.createArrayLiteral([ createInstruction(3), createLabel(label) @@ -51642,31 +51987,33 @@ var ts; for (; blockIndex < blockActions.length && blockOffsets[blockIndex] <= operationIndex; blockIndex++) { var block = blocks[blockIndex]; var blockAction = blockActions[blockIndex]; - if (isExceptionBlock(block)) { - if (blockAction === 0) { - if (!exceptionBlockStack) { - exceptionBlockStack = []; + switch (block.kind) { + case 0: + if (blockAction === 0) { + if (!exceptionBlockStack) { + exceptionBlockStack = []; + } + if (!statements) { + statements = []; + } + exceptionBlockStack.push(currentExceptionBlock); + currentExceptionBlock = block; } - if (!statements) { - statements = []; + else if (blockAction === 1) { + currentExceptionBlock = exceptionBlockStack.pop(); } - exceptionBlockStack.push(currentExceptionBlock); - currentExceptionBlock = block; - } - else if (blockAction === 1) { - currentExceptionBlock = exceptionBlockStack.pop(); - } - } - else if (isWithBlock(block)) { - if (blockAction === 0) { - if (!withBlockStack) { - withBlockStack = []; + break; + case 1: + if (blockAction === 0) { + if (!withBlockStack) { + withBlockStack = []; + } + withBlockStack.push(block); } - withBlockStack.push(block); - } - else if (blockAction === 1) { - withBlockStack.pop(); - } + else if (blockAction === 1) { + withBlockStack.pop(); + } + break; } } } @@ -52501,8 +52848,8 @@ var ts; return ts.setTextRange(ts.createPropertyAccess(ts.getGeneratedNameForNode(importDeclaration.parent), ts.createIdentifier("default")), node); } else if (ts.isImportSpecifier(importDeclaration)) { - var name = importDeclaration.propertyName || importDeclaration.name; - return ts.setTextRange(ts.createPropertyAccess(ts.getGeneratedNameForNode(importDeclaration.parent.parent.parent), ts.getSynthesizedClone(name)), node); + var name_51 = importDeclaration.propertyName || importDeclaration.name; + return ts.setTextRange(ts.createPropertyAccess(ts.getGeneratedNameForNode(importDeclaration.parent.parent.parent), ts.getSynthesizedClone(name_51)), node); } } } @@ -53976,7 +54323,6 @@ var ts; errorNameNode = declaration.name; var format = 4 | 16384 | - 2048 | (shouldUseResolverType ? 8192 : 0); resolver.writeTypeOfDeclaration(declaration, enclosingDeclaration, format, writer); errorNameNode = undefined; @@ -53990,7 +54336,7 @@ var ts; } else { errorNameNode = signature.name; - resolver.writeReturnTypeOfSignatureDeclaration(signature, enclosingDeclaration, 4 | 2048 | 16384, writer); + resolver.writeReturnTypeOfSignatureDeclaration(signature, enclosingDeclaration, 4 | 16384, writer); errorNameNode = undefined; } } @@ -54205,9 +54551,9 @@ var ts; var count = 0; while (true) { count++; - var name = baseName + "_" + count; - if (!currentIdentifiers.has(name)) { - return name; + var name_52 = baseName + "_" + count; + if (!currentIdentifiers.has(name_52)) { + return name_52; } } } @@ -54220,7 +54566,7 @@ var ts; write(tempVarName); write(": "); writer.getSymbolAccessibilityDiagnostic = function () { return diagnostic; }; - resolver.writeTypeOfExpression(expr, enclosingDeclaration, 4 | 2048 | 16384, writer); + resolver.writeTypeOfExpression(expr, enclosingDeclaration, 4 | 16384, writer); write(";"); writeLine(); return tempVarName; @@ -54857,6 +55203,9 @@ var ts; return ts.forEach(node.declarationList.declarations, function (varDeclaration) { return resolver.isDeclarationVisible(varDeclaration); }); } function writeVariableStatement(node) { + if (ts.every(node.declarationList && node.declarationList.declarations, function (decl) { return decl.name && ts.isEmptyBindingPattern(decl.name); })) { + return; + } emitJsDocComments(node); emitModuleElementDeclarationFlags(node); if (ts.isLet(node.declarationList)) { @@ -55822,14 +56171,14 @@ var ts; writer.writeLine(); } } - function emitTrailingCommentsOfPosition(pos) { + function emitTrailingCommentsOfPosition(pos, prefixSpace) { if (disabled) { return; } if (extendedDiagnostics) { ts.performance.mark("beforeEmitTrailingCommentsOfPosition"); } - forEachTrailingCommentToEmit(pos, emitTrailingCommentOfPosition); + forEachTrailingCommentToEmit(pos, prefixSpace ? emitTrailingComment : emitTrailingCommentOfPosition); if (extendedDiagnostics) { ts.performance.measure("commentTime", "beforeEmitTrailingCommentsOfPosition"); } @@ -55909,15 +56258,7 @@ var ts; emitPos(commentEnd); } function isTripleSlashComment(commentPos, commentEnd) { - if (currentText.charCodeAt(commentPos + 1) === 47 && - commentPos + 2 < commentEnd && - currentText.charCodeAt(commentPos + 2) === 47) { - var textSubStr = currentText.substring(commentPos, commentEnd); - return textSubStr.match(ts.fullTripleSlashReferencePathRegEx) || - textSubStr.match(ts.fullTripleSlashAMDReferencePathRegEx) ? - true : false; - } - return false; + return ts.isRecognizedTripleSlashComment(currentText, commentPos, commentEnd); } } ts.createCommentWriter = createCommentWriter; @@ -56856,7 +57197,9 @@ var ts; if (!(ts.getEmitFlags(node) & 131072)) { var dotRangeStart = node.expression.end; var dotRangeEnd = ts.skipTrivia(currentSourceFile.text, node.expression.end) + 1; - var dotToken = { kind: 23, pos: dotRangeStart, end: dotRangeEnd }; + var dotToken = ts.createToken(23); + dotToken.pos = dotRangeStart; + dotToken.end = dotRangeEnd; indentBeforeDot = needsIndentation(node, node.expression, dotToken); indentAfterDot = needsIndentation(node, dotToken, node.name); } @@ -56968,7 +57311,9 @@ var ts; var indentAfterOperator = needsIndentation(node, node.operatorToken, node.right); emitExpression(node.left); increaseIndentIf(indentBeforeOperator, isCommaOperator ? " " : undefined); + emitLeadingCommentsOfPosition(node.operatorToken.pos); writeTokenNode(node.operatorToken); + emitTrailingCommentsOfPosition(node.operatorToken.end, true); increaseIndentIf(indentAfterOperator, " "); emitExpression(node.right); decreaseIndentIf(indentBeforeOperator, indentAfterOperator); @@ -57155,8 +57500,19 @@ var ts; emitWithPrefix(" ", node.label); write(";"); } + function emitTokenWithComment(token, pos, contextNode) { + var node = contextNode && ts.getParseTreeNode(contextNode); + if (node && node.kind === contextNode.kind) { + pos = ts.skipTrivia(currentSourceFile.text, pos); + } + pos = writeToken(token, pos, contextNode); + if (node && node.kind === contextNode.kind) { + emitTrailingCommentsOfPosition(pos, true); + } + return pos; + } function emitReturnStatement(node) { - writeToken(96, node.pos, node); + emitTokenWithComment(96, node.pos, node); emitExpressionWithPrefix(" ", node.expression); write(";"); } @@ -57597,10 +57953,12 @@ var ts; function emitCatchClause(node) { var openParenPos = writeToken(74, node.pos); write(" "); - writeToken(19, openParenPos); - emit(node.variableDeclaration); - writeToken(20, node.variableDeclaration ? node.variableDeclaration.end : openParenPos); - write(" "); + if (node.variableDeclaration) { + writeToken(19, openParenPos); + emit(node.variableDeclaration); + writeToken(20, node.variableDeclaration.end); + write(" "); + } emit(node.block); } function emitPropertyAssignment(node) { @@ -58154,21 +58512,21 @@ var ts; } function makeTempVariableName(flags) { if (flags && !(tempFlags & flags)) { - var name = flags === 268435456 ? "_i" : "_n"; - if (isUniqueName(name)) { + var name_53 = flags === 268435456 ? "_i" : "_n"; + if (isUniqueName(name_53)) { tempFlags |= flags; - return name; + return name_53; } } while (true) { var count = tempFlags & 268435455; tempFlags++; if (count !== 8 && count !== 13) { - var name = count < 26 + var name_54 = count < 26 ? "_" + String.fromCharCode(97 + count) : "_" + (count - 26); - if (isUniqueName(name)) { - return name; + if (isUniqueName(name_54)) { + return name_54; } } } @@ -58651,13 +59009,13 @@ var ts; var resolutions = []; var cache = ts.createMap(); for (var _i = 0, names_1 = names; _i < names_1.length; _i++) { - var name = names_1[_i]; + var name_55 = names_1[_i]; var result = void 0; - if (cache.has(name)) { - result = cache.get(name); + if (cache.has(name_55)) { + result = cache.get(name_55); } else { - cache.set(name, result = loader(name, containingFile)); + cache.set(name_55, result = loader(name_55, containingFile)); } resolutions.push(result); } @@ -58712,6 +59070,9 @@ var ts; var loader_2 = function (typesRef, containingFile) { return ts.resolveTypeReferenceDirective(typesRef, containingFile, options, host).resolvedTypeReferenceDirective; }; resolveTypeReferenceDirectiveNamesWorker = function (typeReferenceDirectiveNames, containingFile) { return loadWithLocalCache(checkAllDefined(typeReferenceDirectiveNames), containingFile, loader_2); }; } + var packageIdToSourceFile = ts.createMap(); + var sourceFileToPackageName = ts.createMap(); + var redirectTargetsSet = ts.createMap(); var filesByName = ts.createMap(); var filesByNameIgnoreCase = host.useCaseSensitiveFileNames() ? ts.createMap() : undefined; var structuralIsReused = tryReuseStructureFromOldProgram(); @@ -58768,6 +59129,8 @@ var ts; isSourceFileFromExternalLibrary: isSourceFileFromExternalLibrary, dropDiagnosticsProducingTypeChecker: dropDiagnosticsProducingTypeChecker, getSourceFileFromReference: getSourceFileFromReference, + sourceFileToPackageName: sourceFileToPackageName, + redirectTargetsSet: redirectTargetsSet, }; verifyCompilerOptions(); ts.performance.mark("afterProgram"); @@ -58911,17 +59274,51 @@ var ts; var filePaths = []; var modifiedSourceFiles = []; oldProgram.structureIsReused = 2; - for (var _i = 0, _a = oldProgram.getSourceFiles(); _i < _a.length; _i++) { - var oldSourceFile = _a[_i]; + var oldSourceFiles = oldProgram.getSourceFiles(); + var SeenPackageName; + (function (SeenPackageName) { + SeenPackageName[SeenPackageName["Exists"] = 0] = "Exists"; + SeenPackageName[SeenPackageName["Modified"] = 1] = "Modified"; + })(SeenPackageName || (SeenPackageName = {})); + var seenPackageNames = ts.createMap(); + for (var _i = 0, oldSourceFiles_1 = oldSourceFiles; _i < oldSourceFiles_1.length; _i++) { + var oldSourceFile = oldSourceFiles_1[_i]; var newSourceFile = host.getSourceFileByPath ? host.getSourceFileByPath(oldSourceFile.fileName, oldSourceFile.path, options.target) : host.getSourceFile(oldSourceFile.fileName, options.target); if (!newSourceFile) { return oldProgram.structureIsReused = 0; } + ts.Debug.assert(!newSourceFile.redirectInfo, "Host should not return a redirect source file from `getSourceFile`"); + var fileChanged = void 0; + if (oldSourceFile.redirectInfo) { + if (newSourceFile !== oldSourceFile.redirectInfo.unredirected) { + return oldProgram.structureIsReused = 0; + } + fileChanged = false; + newSourceFile = oldSourceFile; + } + else if (oldProgram.redirectTargetsSet.has(oldSourceFile.path)) { + if (newSourceFile !== oldSourceFile) { + return oldProgram.structureIsReused = 0; + } + fileChanged = false; + } + else { + fileChanged = newSourceFile !== oldSourceFile; + } newSourceFile.path = oldSourceFile.path; filePaths.push(newSourceFile.path); - if (oldSourceFile !== newSourceFile) { + var packageName = oldProgram.sourceFileToPackageName.get(oldSourceFile.path); + if (packageName !== undefined) { + var prevKind = seenPackageNames.get(packageName); + var newKind = fileChanged ? 1 : 0; + if ((prevKind !== undefined && newKind === 1) || prevKind === 1) { + return oldProgram.structureIsReused = 0; + } + seenPackageNames.set(packageName, newKind); + } + if (fileChanged) { if (oldSourceFile.hasNoDefaultLib !== newSourceFile.hasNoDefaultLib) { oldProgram.structureIsReused = 1; } @@ -58949,8 +59346,8 @@ var ts; return oldProgram.structureIsReused; } modifiedFilePaths = modifiedSourceFiles.map(function (f) { return f.newFile.path; }); - for (var _b = 0, modifiedSourceFiles_1 = modifiedSourceFiles; _b < modifiedSourceFiles_1.length; _b++) { - var _c = modifiedSourceFiles_1[_b], oldSourceFile = _c.oldFile, newSourceFile = _c.newFile; + for (var _a = 0, modifiedSourceFiles_1 = modifiedSourceFiles; _a < modifiedSourceFiles_1.length; _a++) { + var _b = modifiedSourceFiles_1[_a], oldSourceFile = _b.oldFile, newSourceFile = _b.newFile; var newSourceFilePath = ts.getNormalizedAbsolutePath(newSourceFile.fileName, currentDirectory); if (resolveModuleNamesWorker) { var moduleNames = ts.map(ts.concatenate(newSourceFile.imports, newSourceFile.moduleAugmentations), getTextOfLiteral); @@ -58984,8 +59381,8 @@ var ts; if (oldProgram.getMissingFilePaths().some(function (missingFilePath) { return host.fileExists(missingFilePath); })) { return oldProgram.structureIsReused = 1; } - for (var _d = 0, _e = oldProgram.getMissingFilePaths(); _d < _e.length; _d++) { - var p = _e[_d]; + for (var _c = 0, _d = oldProgram.getMissingFilePaths(); _c < _d.length; _c++) { + var p = _d[_c]; filesByName.set(p, undefined); } for (var i = 0; i < newSourceFiles.length; i++) { @@ -58993,11 +59390,13 @@ var ts; } files = newSourceFiles; fileProcessingDiagnostics = oldProgram.getFileProcessingDiagnostics(); - for (var _f = 0, modifiedSourceFiles_2 = modifiedSourceFiles; _f < modifiedSourceFiles_2.length; _f++) { - var modifiedFile = modifiedSourceFiles_2[_f]; + for (var _e = 0, modifiedSourceFiles_2 = modifiedSourceFiles; _e < modifiedSourceFiles_2.length; _e++) { + var modifiedFile = modifiedSourceFiles_2[_e]; fileProcessingDiagnostics.reattachFileDiagnostics(modifiedFile.newFile); } resolvedTypeReferenceDirectives = oldProgram.getResolvedTypeReferenceDirectives(); + sourceFileToPackageName = oldProgram.sourceFileToPackageName; + redirectTargetsSet = oldProgram.redirectTargetsSet; return oldProgram.structureIsReused = 2; } function getEmitHost(writeFileCallback) { @@ -59476,7 +59875,7 @@ var ts; } } function processSourceFile(fileName, isDefaultLib, refFile, refPos, refEnd) { - getSourceFileFromReferenceWorker(fileName, function (fileName) { return findSourceFile(fileName, toPath(fileName), isDefaultLib, refFile, refPos, refEnd); }, function (diagnostic) { + getSourceFileFromReferenceWorker(fileName, function (fileName) { return findSourceFile(fileName, toPath(fileName), isDefaultLib, refFile, refPos, refEnd, undefined); }, function (diagnostic) { var args = []; for (var _i = 1; _i < arguments.length; _i++) { args[_i - 1] = arguments[_i]; @@ -59493,7 +59892,24 @@ var ts; fileProcessingDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.File_name_0_differs_from_already_included_file_name_1_only_in_casing, fileName, existingFileName)); } } - function findSourceFile(fileName, path, isDefaultLib, refFile, refPos, refEnd) { + function createRedirectSourceFile(redirectTarget, unredirected, fileName, path) { + var redirect = Object.create(redirectTarget); + redirect.fileName = fileName; + redirect.path = path; + redirect.redirectInfo = { redirectTarget: redirectTarget, unredirected: unredirected }; + Object.defineProperties(redirect, { + id: { + get: function () { return this.redirectInfo.redirectTarget.id; }, + set: function (value) { this.redirectInfo.redirectTarget.id = value; }, + }, + symbol: { + get: function () { return this.redirectInfo.redirectTarget.symbol; }, + set: function (value) { this.redirectInfo.redirectTarget.symbol = value; }, + }, + }); + return redirect; + } + function findSourceFile(fileName, path, isDefaultLib, refFile, refPos, refEnd, packageId) { if (filesByName.has(path)) { var file_1 = filesByName.get(path); if (file_1 && options.forceConsistentCasingInFileNames && ts.getNormalizedAbsolutePath(file_1.fileName, currentDirectory) !== ts.getNormalizedAbsolutePath(fileName, currentDirectory)) { @@ -59524,6 +59940,22 @@ var ts; fileProcessingDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_read_file_0_Colon_1, fileName, hostErrorMessage)); } }); + if (packageId) { + var packageIdKey = packageId.name + "@" + packageId.version; + var fileFromPackageId = packageIdToSourceFile.get(packageIdKey); + if (fileFromPackageId) { + var dupFile = createRedirectSourceFile(fileFromPackageId, file, fileName, path); + redirectTargetsSet.set(fileFromPackageId.path, true); + filesByName.set(path, dupFile); + sourceFileToPackageName.set(path, packageId.name); + files.push(dupFile); + return dupFile; + } + else if (file) { + packageIdToSourceFile.set(packageIdKey, file); + sourceFileToPackageName.set(path, packageId.name); + } + } filesByName.set(path, file); if (file) { sourceFilesFoundSearchingNodeModules.set(path, currentNodeModulesDepth > 0); @@ -59645,7 +60077,7 @@ var ts; else if (shouldAddFile) { var path = toPath(resolvedFileName); var pos = ts.skipTrivia(file.text, file.imports[i].pos); - findSourceFile(resolvedFileName, path, false, file, pos, file.imports[i].end); + findSourceFile(resolvedFileName, path, false, file, pos, file.imports[i].end, resolution.packageId); } if (isFromNodeModulesSearch) { currentNodeModulesDepth--; @@ -60758,7 +61190,9 @@ var ts; } ts.findNextToken = findNextToken; function findPrecedingToken(position, sourceFile, startNode, includeJsDoc) { - return find(startNode || sourceFile); + var result = find(startNode || sourceFile); + ts.Debug.assert(!(result && isWhiteSpaceOnlyJsxText(result))); + return result; function findRightmostToken(n) { if (ts.isToken(n)) { return n; @@ -60774,10 +61208,11 @@ var ts; var children = n.getChildren(); for (var i = 0; i < children.length; i++) { var child = children[i]; - if (position < child.end && (nodeHasTokens(child) || child.kind === 10)) { + if (position < child.end) { var start = child.getStart(sourceFile, includeJsDoc); var lookInPreviousChild = (start >= position) || - (child.kind === 10 && start === child.end); + !nodeHasTokens(child) || + isWhiteSpaceOnlyJsxText(child); if (lookInPreviousChild) { var candidate = findRightmostChildNodeWithTokens(children, i); return candidate && findRightmostToken(candidate); @@ -60795,7 +61230,11 @@ var ts; } function findRightmostChildNodeWithTokens(children, exclusiveStartPosition) { for (var i = exclusiveStartPosition - 1; i >= 0; i--) { - if (nodeHasTokens(children[i])) { + var child = children[i]; + if (isWhiteSpaceOnlyJsxText(child)) { + ts.Debug.assert(i > 0, "`JsxText` tokens should not be the first child of `JsxElement | JsxSelfClosingElement`"); + } + else if (nodeHasTokens(children[i])) { return children[i]; } } @@ -60840,34 +61279,19 @@ var ts; return false; } ts.isInsideJsxElementOrAttribute = isInsideJsxElementOrAttribute; + function isWhiteSpaceOnlyJsxText(node) { + return ts.isJsxText(node) && node.containsOnlyWhiteSpaces; + } + ts.isWhiteSpaceOnlyJsxText = isWhiteSpaceOnlyJsxText; function isInTemplateString(sourceFile, position) { var token = getTokenAtPosition(sourceFile, position, false); return ts.isTemplateLiteralKind(token.kind) && position > token.getStart(sourceFile); } ts.isInTemplateString = isInTemplateString; function isInComment(sourceFile, position, tokenAtPosition, predicate) { - if (tokenAtPosition === void 0) { tokenAtPosition = getTokenAtPosition(sourceFile, position, false); } - return position <= tokenAtPosition.getStart(sourceFile) && - (isInCommentRange(ts.getLeadingCommentRanges(sourceFile.text, tokenAtPosition.pos)) || - isInCommentRange(ts.getTrailingCommentRanges(sourceFile.text, tokenAtPosition.pos))); - function isInCommentRange(commentRanges) { - return ts.forEach(commentRanges, function (c) { return isPositionInCommentRange(c, position, sourceFile.text) && (!predicate || predicate(c)); }); - } + return !!ts.formatting.getRangeOfEnclosingComment(sourceFile, position, false, undefined, tokenAtPosition, predicate); } ts.isInComment = isInComment; - function isPositionInCommentRange(_a, position, text) { - var pos = _a.pos, end = _a.end, kind = _a.kind; - if (pos < position && position < end) { - return true; - } - else if (position === end) { - return kind === 2 || - !(text.charCodeAt(end - 1) === 47 && text.charCodeAt(end - 2) === 42); - } - else { - return false; - } - } function hasDocComment(sourceFile, position) { var token = getTokenAtPosition(sourceFile, position, false); var commentRanges = ts.getLeadingCommentRanges(sourceFile.text, token.pos); @@ -61220,6 +61644,7 @@ var ts; } ts.symbolToDisplayParts = symbolToDisplayParts; function signatureToDisplayParts(typechecker, signature, enclosingDeclaration, flags) { + flags |= 65536; return mapToDisplayParts(function (writer) { typechecker.getSymbolDisplayBuilder().buildSignatureDisplay(signature, writer, enclosingDeclaration, flags); }); @@ -61925,11 +62350,11 @@ var ts; templateStack.pop(); } else { - ts.Debug.assert(token === 15, "Should have been a template middle. Was " + token); + ts.Debug.assertEqual(token, 15, "Should have been a template middle."); } } else { - ts.Debug.assert(lastTemplateStackToken === 17, "Should have been an open brace. Was: " + token); + ts.Debug.assertEqual(lastTemplateStackToken, 17, "Should have been an open brace"); templateStack.pop(); } } @@ -62791,11 +63216,11 @@ var ts; if (currentConfigPath) { paths.push(currentConfigPath); currentDir = ts.getDirectoryPath(currentConfigPath); - var parent = ts.getDirectoryPath(currentDir); - if (currentDir === parent) { + var parent_18 = ts.getDirectoryPath(currentDir); + if (currentDir === parent_18) { break; } - currentDir = parent; + currentDir = parent_18; } else { break; @@ -63102,11 +63527,11 @@ var ts; } } else if (type.flags & 32) { - var name = type.value; - if (!uniques.has(name)) { - uniques.set(name, true); + var name_56 = type.value; + if (!uniques.has(name_56)) { + uniques.set(name_56, true); result.push({ - name: name, + name: name_56, kindModifiers: "", kind: "var", sortText: "0" @@ -63117,10 +63542,10 @@ var ts; function getCompletionEntryDetails(typeChecker, log, compilerOptions, sourceFile, position, entryName) { var completionData = getCompletionData(typeChecker, log, sourceFile, position); if (completionData) { - var symbols = completionData.symbols, location = completionData.location; + var symbols = completionData.symbols, location_3 = completionData.location; var symbol = ts.forEach(symbols, function (s) { return getCompletionEntryDisplayNameForSymbol(s, compilerOptions.target, false) === entryName ? s : undefined; }); if (symbol) { - var _a = ts.SymbolDisplay.getSymbolDisplayPartsDocumentationAndSymbolKind(typeChecker, symbol, sourceFile, location, location, 7), displayParts = _a.displayParts, documentation = _a.documentation, symbolKind = _a.symbolKind, tags = _a.tags; + var _a = ts.SymbolDisplay.getSymbolDisplayPartsDocumentationAndSymbolKind(typeChecker, symbol, sourceFile, location_3, location_3, 7), displayParts = _a.displayParts, documentation = _a.documentation, symbolKind = _a.symbolKind, tags = _a.tags; return { name: entryName, kindModifiers: ts.SymbolDisplay.getSymbolModifiers(symbol), @@ -63217,13 +63642,13 @@ var ts; log("Returning an empty list because completion was requested in an invalid position."); return undefined; } - var parent = contextToken.parent; + var parent_19 = contextToken.parent; if (contextToken.kind === 23) { - if (parent.kind === 179) { + if (parent_19.kind === 179) { node = contextToken.parent.expression; isRightOfDot = true; } - else if (parent.kind === 143) { + else if (parent_19.kind === 143) { node = contextToken.parent.left; isRightOfDot = true; } @@ -63232,11 +63657,11 @@ var ts; } } else if (sourceFile.languageVariant === 1) { - if (parent && parent.kind === 179) { - contextToken = parent; - parent = parent.parent; + if (parent_19 && parent_19.kind === 179) { + contextToken = parent_19; + parent_19 = parent_19.parent; } - switch (parent.kind) { + switch (parent_19.kind) { case 252: if (contextToken.kind === 41) { isStartingCloseTag = true; @@ -63244,7 +63669,7 @@ var ts; } break; case 194: - if (!(parent.left.flags & 32768)) { + if (!(parent_19.left.flags & 32768)) { break; } case 250: @@ -63587,7 +64012,7 @@ var ts; var typeForObject = typeChecker.getTypeAtLocation(objectLikeContainer); if (!typeForObject) return false; - typeMembers = typeChecker.getPropertiesOfType(typeForObject); + typeMembers = typeChecker.getPropertiesOfType(typeForObject).filter(function (symbol) { return !(ts.getDeclarationModifierFlagsFromSymbol(symbol) & 24); }); existingMembers = objectLikeContainer.elements; } } @@ -63657,9 +64082,9 @@ var ts; switch (contextToken.kind) { case 17: case 26: - var parent = contextToken.parent; - if (ts.isObjectLiteralExpression(parent) || ts.isObjectBindingPattern(parent)) { - return parent; + var parent_20 = contextToken.parent; + if (ts.isObjectLiteralExpression(parent_20) || ts.isObjectBindingPattern(parent_20)) { + return parent_20; } break; } @@ -63739,7 +64164,7 @@ var ts; } function tryGetContainingJsxElement(contextToken) { if (contextToken) { - var parent = contextToken.parent; + var parent_21 = contextToken.parent; switch (contextToken.kind) { case 28: case 41: @@ -63748,26 +64173,26 @@ var ts; case 254: case 253: case 255: - if (parent && (parent.kind === 250 || parent.kind === 251)) { - return parent; + if (parent_21 && (parent_21.kind === 250 || parent_21.kind === 251)) { + return parent_21; } - else if (parent.kind === 253) { - return parent.parent.parent; + else if (parent_21.kind === 253) { + return parent_21.parent.parent; } break; case 9: - if (parent && ((parent.kind === 253) || (parent.kind === 255))) { - return parent.parent.parent; + if (parent_21 && ((parent_21.kind === 253) || (parent_21.kind === 255))) { + return parent_21.parent.parent; } break; case 18: - if (parent && - parent.kind === 256 && - parent.parent && parent.parent.kind === 253) { - return parent.parent.parent.parent; + if (parent_21 && + parent_21.kind === 256 && + parent_21.parent && parent_21.parent.kind === 253) { + return parent_21.parent.parent.parent; } - if (parent && parent.kind === 255) { - return parent.parent.parent; + if (parent_21 && parent_21.kind === 255) { + return parent_21.parent.parent; } break; } @@ -63892,8 +64317,8 @@ var ts; if (isCurrentlyEditingNode(element)) { continue; } - var name = element.propertyName || element.name; - existingImportsOrExports.set(name.escapedText, true); + var name_57 = element.propertyName || element.name; + existingImportsOrExports.set(name_57.escapedText, true); } if (existingImportsOrExports.size === 0) { return ts.filter(exportsOfModule, function (e) { return e.escapedName !== "default"; }); @@ -63925,8 +64350,8 @@ var ts; } } else { - var name = ts.getNameOfDeclaration(m); - existingName = ts.getEscapedTextOfIdentifierOrLiteral(name); + var name_58 = ts.getNameOfDeclaration(m); + existingName = ts.getEscapedTextOfIdentifierOrLiteral(name_58); } existingMemberNames.set(existingName, true); } @@ -63964,8 +64389,8 @@ var ts; addPropertySymbols(implementingTypeSymbols, 24); return result; function addPropertySymbols(properties, inValidModifierFlags) { - for (var _i = 0, properties_11 = properties; _i < properties_11.length; _i++) { - var property = properties_11[_i]; + for (var _i = 0, properties_12 = properties; _i < properties_12.length; _i++) { + var property = properties_12[_i]; if (isValidProperty(property, inValidModifierFlags)) { result.push(property); } @@ -64282,17 +64707,17 @@ var ts; function getThrowStatementOwner(throwStatement) { var child = throwStatement; while (child.parent) { - var parent_2 = child.parent; - if (ts.isFunctionBlock(parent_2) || parent_2.kind === 265) { - return parent_2; + var parent_22 = child.parent; + if (ts.isFunctionBlock(parent_22) || parent_22.kind === 265) { + return parent_22; } - if (parent_2.kind === 224) { - var tryStatement = parent_2; + if (parent_22.kind === 224) { + var tryStatement = parent_22; if (tryStatement.tryBlock === child && tryStatement.catchClause) { return child; } } - child = parent_2; + child = parent_22; } return undefined; } @@ -64763,11 +65188,11 @@ var ts; switch (direct.kind) { case 181: if (!isAvailableThroughGlobal) { - var parent = direct.parent; - if (exportKind === 2 && parent.kind === 226) { - var name = parent.name; - if (name.kind === 71) { - directImports.push(name); + var parent_23 = direct.parent; + if (exportKind === 2 && parent_23.kind === 226) { + var name_59 = parent_23.name; + if (name_59.kind === 71) { + directImports.push(name_59); break; } } @@ -64884,10 +65309,10 @@ var ts; searchForNamedImport(namedBindings); } else { - var name = importClause.name; - if (name && (!isForRename || name.escapedText === symbolName(exportSymbol))) { - var defaultImportAlias = checker.getSymbolAtLocation(name); - addSearch(name, defaultImportAlias); + var name_60 = importClause.name; + if (name_60 && (!isForRename || name_60.escapedText === symbolName(exportSymbol))) { + var defaultImportAlias = checker.getSymbolAtLocation(name_60); + addSearch(name_60, defaultImportAlias); } if (!isForRename && exportKind === 1) { ts.Debug.assert(exportName === "default"); @@ -64904,21 +65329,21 @@ var ts; if (namedBindings) { for (var _i = 0, _a = namedBindings.elements; _i < _a.length; _i++) { var element = _a[_i]; - var name = element.name, propertyName = element.propertyName; - if ((propertyName || name).escapedText !== exportName) { + var name_61 = element.name, propertyName = element.propertyName; + if ((propertyName || name_61).escapedText !== exportName) { continue; } if (propertyName) { singleReferences.push(propertyName); if (!isForRename) { - addSearch(name, checker.getSymbolAtLocation(name)); + addSearch(name_61, checker.getSymbolAtLocation(name_61)); } } else { var localSymbol = element.kind === 246 && element.propertyName ? checker.getExportSpecifierLocalTargetSymbol(element) - : checker.getSymbolAtLocation(name); - addSearch(name, localSymbol); + : checker.getSymbolAtLocation(name_61); + addSearch(name_61, localSymbol); } } } @@ -65288,8 +65713,8 @@ var ts; case "symbol": { var symbol = def.symbol, node_2 = def.node; var _a = getDefinitionKindAndDisplayParts(symbol, node_2, checker), displayParts_1 = _a.displayParts, kind_1 = _a.kind; - var name_3 = displayParts_1.map(function (p) { return p.text; }).join(""); - return { node: node_2, name: name_3, kind: kind_1, displayParts: displayParts_1 }; + var name_62 = displayParts_1.map(function (p) { return p.text; }).join(""); + return { node: node_2, name: name_62, kind: kind_1, displayParts: displayParts_1 }; } case "label": { var node_3 = def.node; @@ -65297,8 +65722,8 @@ var ts; } case "keyword": { var node_4 = def.node; - var name_4 = ts.tokenToString(node_4.kind); - return { node: node_4, name: name_4, kind: "keyword", displayParts: [{ text: name_4, kind: "keyword" }] }; + var name_63 = ts.tokenToString(node_4.kind); + return { node: node_4, name: name_63, kind: "keyword", displayParts: [{ text: name_63, kind: "keyword" }] }; } case "this": { var node_5 = def.node; @@ -65655,11 +66080,15 @@ var ts; } function getPropertySymbolOfObjectBindingPatternWithoutPropertyName(symbol, checker) { var bindingElement = getObjectBindingElementWithoutPropertyName(symbol); - if (bindingElement) { - var typeOfPattern = checker.getTypeAtLocation(bindingElement.parent); - return typeOfPattern && checker.getPropertyOfType(typeOfPattern, bindingElement.name.text); + if (!bindingElement) + return undefined; + var typeOfPattern = checker.getTypeAtLocation(bindingElement.parent); + var propSymbol = typeOfPattern && checker.getPropertyOfType(typeOfPattern, bindingElement.name.text); + if (propSymbol && propSymbol.flags & 98304) { + ts.Debug.assert(!!(propSymbol.flags & 33554432)); + return propSymbol.target; } - return undefined; + return propSymbol; } function getSymbolScope(symbol) { var declarations = symbol.declarations, flags = symbol.flags, parent = symbol.parent, valueDeclaration = symbol.valueDeclaration; @@ -65679,12 +66108,13 @@ var ts; if (getObjectBindingElementWithoutPropertyName(symbol)) { return undefined; } - if (parent && !((parent.flags & 1536) && ts.isExternalModuleSymbol(parent) && !parent.globalExports)) { + var exposedByParent = parent && !(symbol.flags & 262144); + if (exposedByParent && !((parent.flags & 1536) && ts.isExternalModuleSymbol(parent) && !parent.globalExports)) { return undefined; } var scope; - for (var _i = 0, declarations_10 = declarations; _i < declarations_10.length; _i++) { - var declaration = declarations_10[_i]; + for (var _i = 0, declarations_9 = declarations; _i < declarations_9.length; _i++) { + var declaration = declarations_9[_i]; var container = ts.getContainerNode(declaration); if (scope && scope !== container) { return undefined; @@ -65694,7 +66124,7 @@ var ts; } scope = container; } - return parent ? scope.getSourceFile() : scope; + return exposedByParent ? scope.getSourceFile() : scope; } function getPossibleSymbolReferencePositions(sourceFile, symbolName, container) { if (container === void 0) { container = sourceFile; } @@ -65970,12 +66400,12 @@ var ts; } var containingTypeReference = getContainingTypeReference(refNode); if (containingTypeReference && state.markSeenContainingTypeReference(containingTypeReference)) { - var parent = containingTypeReference.parent; - if (ts.isVariableLike(parent) && parent.type === containingTypeReference && parent.initializer && isImplementationExpression(parent.initializer)) { - addReference(parent.initializer); + var parent_24 = containingTypeReference.parent; + if (ts.isVariableLike(parent_24) && parent_24.type === containingTypeReference && parent_24.initializer && isImplementationExpression(parent_24.initializer)) { + addReference(parent_24.initializer); } - else if (ts.isFunctionLike(parent) && parent.type === containingTypeReference && parent.body) { - var body = parent.body; + else if (ts.isFunctionLike(parent_24) && parent_24.type === containingTypeReference && parent_24.body) { + var body = parent_24.body; if (body.kind === 207) { ts.forEachReturnStatement(body, function (returnStatement) { if (returnStatement.expression && isImplementationExpression(returnStatement.expression)) { @@ -65987,8 +66417,8 @@ var ts; addReference(body); } } - else if (ts.isAssertionExpression(parent) && isImplementationExpression(parent.expression)) { - addReference(parent.expression); + else if (ts.isAssertionExpression(parent_24) && isImplementationExpression(parent_24.expression)) { + addReference(parent_24.expression); } } } @@ -66371,8 +66801,8 @@ var ts; var lastIterationMeaning = void 0; do { lastIterationMeaning = meaning; - for (var _i = 0, declarations_11 = declarations; _i < declarations_11.length; _i++) { - var declaration = declarations_11[_i]; + for (var _i = 0, declarations_10 = declarations; _i < declarations_10.length; _i++) { + var declaration = declarations_10[_i]; var declarationMeaning = ts.getMeaningFromDeclaration(declaration); if (declarationMeaning & meaning) { meaning |= declarationMeaning; @@ -66517,6 +66947,16 @@ var ts; var shorthandContainerName_1 = typeChecker.symbolToString(symbol.parent, node); return ts.map(shorthandDeclarations, function (declaration) { return createDefinitionInfo(declaration, shorthandSymbolKind_1, shorthandSymbolName_1, shorthandContainerName_1); }); } + if (ts.isPropertyName(node) && ts.isBindingElement(node.parent) && ts.isObjectBindingPattern(node.parent.parent) && + (node === (node.parent.propertyName || node.parent.name))) { + var type = typeChecker.getTypeAtLocation(node.parent.parent); + if (type) { + var propSymbols = ts.getPropertySymbolsFromType(type, node); + if (propSymbols) { + return ts.flatMap(propSymbols, function (propSymbol) { return getDefinitionFromSymbol(typeChecker, propSymbol, node); }); + } + } + } var element = ts.getContainingObjectLiteralElement(node); if (element && typeChecker.getContextualType(element.parent)) { return ts.flatMap(ts.getPropertySymbolsFromContextualType(typeChecker, element), function (propertySymbol) { @@ -66933,12 +67373,20 @@ var ts; "crypto", "stream", "util", "assert", "tty", "domain", "constants", "process", "v8", "timers", "console" ]; - var nodeCoreModules = ts.arrayToMap(JsTyping.nodeCoreModuleList, function (x) { return x; }); + var nodeCoreModules = ts.arrayToSet(JsTyping.nodeCoreModuleList); function loadSafeList(host, safeListPath) { var result = ts.readConfigFile(safeListPath, function (path) { return host.readFile(path); }); return ts.createMapFromTemplate(result.config); } JsTyping.loadSafeList = loadSafeList; + function loadTypesMap(host, typesMapPath) { + var result = ts.readConfigFile(typesMapPath, function (path) { return host.readFile(path); }); + if (result.config) { + return ts.createMapFromTemplate(result.config.simpleMap); + } + return undefined; + } + JsTyping.loadTypesMap = loadTypesMap; function discoverTypings(host, log, fileNames, projectRootPath, safeList, packageNameToTypingLocation, typeAcquisition, unresolvedImports) { if (!typeAcquisition || !typeAcquisition.enable) { return { cachedTypingPaths: [], newTypingNames: [], filesToWatch: [] }; @@ -67093,8 +67541,8 @@ var ts; if (!matches) { return; } - for (var _i = 0, declarations_12 = declarations; _i < declarations_12.length; _i++) { - var declaration = declarations_12[_i]; + for (var _i = 0, declarations_11 = declarations; _i < declarations_11.length; _i++) { + var declaration = declarations_11[_i]; if (patternMatcher.patternContainsDots) { var containers = getContainers(declaration); if (!containers) { @@ -67145,14 +67593,14 @@ var ts; } function tryAddSingleDeclarationName(declaration, containers) { if (declaration) { - var name = ts.getNameOfDeclaration(declaration); - if (name) { - var text = ts.getTextOfIdentifierOrLiteral(name); + var name_64 = ts.getNameOfDeclaration(declaration); + if (name_64) { + var text = ts.getTextOfIdentifierOrLiteral(name_64); if (text !== undefined) { containers.unshift(text); } - else if (name.kind === 144) { - return tryAddComputedPropertyName(name.expression, containers, true); + else if (name_64.kind === 144) { + return tryAddComputedPropertyName(name_64.expression, containers, true); } else { return false; @@ -67378,9 +67826,9 @@ var ts; case 176: case 226: var decl = node; - var name = decl.name; - if (ts.isBindingPattern(name)) { - addChildrenRecursively(name); + var name_65 = decl.name; + if (ts.isBindingPattern(name_65)) { + addChildrenRecursively(name_65); } else if (decl.initializer && isFunctionOrClassExpression(decl.initializer)) { addChildrenRecursively(decl.initializer); @@ -67753,13 +68201,17 @@ var ts; (function (ts) { var OutliningElementsCollector; (function (OutliningElementsCollector) { + var collapseText = "..."; + var maxDepth = 20; function collectElements(sourceFile, cancellationToken) { var elements = []; - var collapseText = "..."; - function addOutliningSpan(hintSpanNode, startElement, endElement, autoCollapse) { + var depth = 0; + walk(sourceFile); + return elements; + function addOutliningSpan(hintSpanNode, startElement, endElement, autoCollapse, useFullStart) { if (hintSpanNode && startElement && endElement) { var span_13 = { - textSpan: ts.createTextSpanFromBounds(startElement.pos, endElement.end), + textSpan: ts.createTextSpanFromBounds(useFullStart ? startElement.getFullStart() : startElement.getStart(), endElement.getEnd()), hintSpan: ts.createTextSpanFromNode(hintSpanNode, sourceFile), bannerText: collapseText, autoCollapse: autoCollapse, @@ -67820,8 +68272,6 @@ var ts; function autoCollapse(node) { return ts.isFunctionBlock(node) && node.parent.kind !== 187; } - var depth = 0; - var maxDepth = 20; function walk(n) { cancellationToken.throwIfCancellationRequested(); if (depth > maxDepth) { @@ -67833,30 +68283,30 @@ var ts; switch (n.kind) { case 207: if (!ts.isFunctionBlock(n)) { - var parent = n.parent; - var openBrace = ts.findChildOfKind(n, 17, sourceFile); - var closeBrace = ts.findChildOfKind(n, 18, sourceFile); - if (parent.kind === 212 || - parent.kind === 215 || - parent.kind === 216 || - parent.kind === 214 || - parent.kind === 211 || - parent.kind === 213 || - parent.kind === 220 || - parent.kind === 260) { - addOutliningSpan(parent, openBrace, closeBrace, autoCollapse(n)); + var parent_25 = n.parent; + var openBrace_1 = ts.findChildOfKind(n, 17, sourceFile); + var closeBrace_1 = ts.findChildOfKind(n, 18, sourceFile); + if (parent_25.kind === 212 || + parent_25.kind === 215 || + parent_25.kind === 216 || + parent_25.kind === 214 || + parent_25.kind === 211 || + parent_25.kind === 213 || + parent_25.kind === 220 || + parent_25.kind === 260) { + addOutliningSpan(parent_25, openBrace_1, closeBrace_1, autoCollapse(n), true); break; } - if (parent.kind === 224) { - var tryStatement = parent; + if (parent_25.kind === 224) { + var tryStatement = parent_25; if (tryStatement.tryBlock === n) { - addOutliningSpan(parent, openBrace, closeBrace, autoCollapse(n)); + addOutliningSpan(parent_25, openBrace_1, closeBrace_1, autoCollapse(n), true); break; } else if (tryStatement.finallyBlock === n) { var finallyKeyword = ts.findChildOfKind(tryStatement, 87, sourceFile); if (finallyKeyword) { - addOutliningSpan(finallyKeyword, openBrace, closeBrace, autoCollapse(n)); + addOutliningSpan(finallyKeyword, openBrace_1, closeBrace_1, autoCollapse(n), true); break; } } @@ -67871,33 +68321,35 @@ var ts; break; } case 234: { - var openBrace = ts.findChildOfKind(n, 17, sourceFile); - var closeBrace = ts.findChildOfKind(n, 18, sourceFile); - addOutliningSpan(n.parent, openBrace, closeBrace, autoCollapse(n)); + var openBrace_2 = ts.findChildOfKind(n, 17, sourceFile); + var closeBrace_2 = ts.findChildOfKind(n, 18, sourceFile); + addOutliningSpan(n.parent, openBrace_2, closeBrace_2, autoCollapse(n), true); break; } case 229: case 230: case 232: - case 178: case 235: { - var openBrace = ts.findChildOfKind(n, 17, sourceFile); - var closeBrace = ts.findChildOfKind(n, 18, sourceFile); - addOutliningSpan(n, openBrace, closeBrace, autoCollapse(n)); + var openBrace_3 = ts.findChildOfKind(n, 17, sourceFile); + var closeBrace_3 = ts.findChildOfKind(n, 18, sourceFile); + addOutliningSpan(n, openBrace_3, closeBrace_3, autoCollapse(n), true); break; } + case 178: + var openBrace = ts.findChildOfKind(n, 17, sourceFile); + var closeBrace = ts.findChildOfKind(n, 18, sourceFile); + addOutliningSpan(n, openBrace, closeBrace, autoCollapse(n), !ts.isArrayLiteralExpression(n.parent)); + break; case 177: var openBracket = ts.findChildOfKind(n, 21, sourceFile); var closeBracket = ts.findChildOfKind(n, 22, sourceFile); - addOutliningSpan(n, openBracket, closeBracket, autoCollapse(n)); + addOutliningSpan(n, openBracket, closeBracket, autoCollapse(n), !ts.isArrayLiteralExpression(n.parent)); break; } depth++; ts.forEachChild(n, walk); depth--; } - walk(sourceFile); - return elements; } OutliningElementsCollector.collectElements = collectElements; })(OutliningElementsCollector = ts.OutliningElementsCollector || (ts.OutliningElementsCollector = {})); @@ -68741,8 +69193,8 @@ var ts; var nameToDeclarations = sourceFile.getNamedDeclarations(); var declarations = nameToDeclarations.get(name.text); if (declarations) { - for (var _b = 0, declarations_13 = declarations; _b < declarations_13.length; _b++) { - var declaration = declarations_13[_b]; + for (var _b = 0, declarations_12 = declarations; _b < declarations_12.length; _b++) { + var declaration = declarations_12[_b]; var symbol = declaration.symbol; if (symbol) { var type = typeChecker.getTypeOfSymbolAtLocation(symbol, declaration); @@ -68775,7 +69227,9 @@ var ts; } var kind = invocation.typeArguments && invocation.typeArguments.pos === list.pos ? 0 : 1; var argumentCount = getArgumentCount(list); - ts.Debug.assert(argumentIndex === 0 || argumentIndex < argumentCount, "argumentCount < argumentIndex, " + argumentCount + " < " + argumentIndex); + if (argumentIndex !== 0) { + ts.Debug.assertLessThan(argumentIndex, argumentCount); + } var argumentsSpan = getApplicableSpanForArguments(list, sourceFile); return { kind: kind, invocation: invocation, argumentsSpan: argumentsSpan, argumentIndex: argumentIndex, argumentCount: argumentCount }; } @@ -68853,7 +69307,9 @@ var ts; var argumentCount = tagExpression.template.kind === 13 ? 1 : tagExpression.template.templateSpans.length + 1; - ts.Debug.assert(argumentIndex === 0 || argumentIndex < argumentCount, "argumentCount < argumentIndex, " + argumentCount + " < " + argumentIndex); + if (argumentIndex !== 0) { + ts.Debug.assertLessThan(argumentIndex, argumentCount); + } return { kind: 2, invocation: tagExpression, @@ -68950,7 +69406,9 @@ var ts; tags: candidateSignature.getJsDocTags() }; }); - ts.Debug.assert(argumentIndex === 0 || argumentIndex < argumentCount, "argumentCount < argumentIndex, " + argumentCount + " < " + argumentIndex); + if (argumentIndex !== 0) { + ts.Debug.assertLessThan(argumentIndex, argumentCount); + } var selectedItemIndex = candidates.indexOf(resolvedSignature); ts.Debug.assert(selectedItemIndex !== -1); return { items: items, applicableSpan: applicableSpan, selectedItemIndex: selectedItemIndex, argumentIndex: argumentIndex, argumentCount: argumentCount }; @@ -69091,102 +69549,100 @@ var ts; } var signature = void 0; type = isThisExpression ? typeChecker.getTypeAtLocation(location) : typeChecker.getTypeOfSymbolAtLocation(symbol.exportSymbol || symbol, location); - if (type) { - if (location.parent && location.parent.kind === 179) { - var right = location.parent.name; - if (right === location || (right && right.getFullWidth() === 0)) { - location = location.parent; + if (location.parent && location.parent.kind === 179) { + var right = location.parent.name; + if (right === location || (right && right.getFullWidth() === 0)) { + location = location.parent; + } + } + var callExpressionLike = void 0; + if (ts.isCallOrNewExpression(location)) { + callExpressionLike = location; + } + else if (ts.isCallExpressionTarget(location) || ts.isNewExpressionTarget(location)) { + callExpressionLike = location.parent; + } + else if (location.parent && ts.isJsxOpeningLikeElement(location.parent) && ts.isFunctionLike(symbol.valueDeclaration)) { + callExpressionLike = location.parent; + } + if (callExpressionLike) { + var candidateSignatures = []; + signature = typeChecker.getResolvedSignature(callExpressionLike, candidateSignatures); + if (!signature && candidateSignatures.length) { + signature = candidateSignatures[0]; + } + var useConstructSignatures = callExpressionLike.kind === 182 || (ts.isCallExpression(callExpressionLike) && callExpressionLike.expression.kind === 97); + var allSignatures = useConstructSignatures ? type.getConstructSignatures() : type.getCallSignatures(); + if (!ts.contains(allSignatures, signature.target) && !ts.contains(allSignatures, signature)) { + signature = allSignatures.length ? allSignatures[0] : undefined; + } + if (signature) { + if (useConstructSignatures && (symbolFlags & 32)) { + symbolKind = "constructor"; + addPrefixForAnyFunctionOrVar(type.symbol, symbolKind); } - } - var callExpressionLike = void 0; - if (ts.isCallOrNewExpression(location)) { - callExpressionLike = location; - } - else if (ts.isCallExpressionTarget(location) || ts.isNewExpressionTarget(location)) { - callExpressionLike = location.parent; - } - else if (location.parent && ts.isJsxOpeningLikeElement(location.parent) && ts.isFunctionLike(symbol.valueDeclaration)) { - callExpressionLike = location.parent; - } - if (callExpressionLike) { - var candidateSignatures = []; - signature = typeChecker.getResolvedSignature(callExpressionLike, candidateSignatures); - if (!signature && candidateSignatures.length) { - signature = candidateSignatures[0]; - } - var useConstructSignatures = callExpressionLike.kind === 182 || (ts.isCallExpression(callExpressionLike) && callExpressionLike.expression.kind === 97); - var allSignatures = useConstructSignatures ? type.getConstructSignatures() : type.getCallSignatures(); - if (!ts.contains(allSignatures, signature.target) && !ts.contains(allSignatures, signature)) { - signature = allSignatures.length ? allSignatures[0] : undefined; - } - if (signature) { - if (useConstructSignatures && (symbolFlags & 32)) { - symbolKind = "constructor"; - addPrefixForAnyFunctionOrVar(type.symbol, symbolKind); + else if (symbolFlags & 2097152) { + symbolKind = "alias"; + pushTypePart(symbolKind); + displayParts.push(ts.spacePart()); + if (useConstructSignatures) { + displayParts.push(ts.keywordPart(94)); + displayParts.push(ts.spacePart()); } - else if (symbolFlags & 2097152) { - symbolKind = "alias"; - pushTypePart(symbolKind); + addFullSymbolName(symbol); + } + else { + addPrefixForAnyFunctionOrVar(symbol, symbolKind); + } + switch (symbolKind) { + case "JSX attribute": + case "property": + case "var": + case "const": + case "let": + case "parameter": + case "local var": + displayParts.push(ts.punctuationPart(56)); displayParts.push(ts.spacePart()); if (useConstructSignatures) { displayParts.push(ts.keywordPart(94)); displayParts.push(ts.spacePart()); } - addFullSymbolName(symbol); - } - else { - addPrefixForAnyFunctionOrVar(symbol, symbolKind); - } - switch (symbolKind) { - case "JSX attribute": - case "property": - case "var": - case "const": - case "let": - case "parameter": - case "local var": - displayParts.push(ts.punctuationPart(56)); - displayParts.push(ts.spacePart()); - if (useConstructSignatures) { - displayParts.push(ts.keywordPart(94)); - displayParts.push(ts.spacePart()); - } - if (!(type.flags & 32768 && type.objectFlags & 16) && type.symbol) { - ts.addRange(displayParts, ts.symbolToDisplayParts(typeChecker, type.symbol, enclosingDeclaration, undefined, 1)); - } - addSignatureDisplayParts(signature, allSignatures, 16); - break; - default: - addSignatureDisplayParts(signature, allSignatures); - } - hasAddedSymbolInfo = true; + if (!(type.flags & 32768 && type.objectFlags & 16) && type.symbol) { + ts.addRange(displayParts, ts.symbolToDisplayParts(typeChecker, type.symbol, enclosingDeclaration, undefined, 1)); + } + addSignatureDisplayParts(signature, allSignatures, 16); + break; + default: + addSignatureDisplayParts(signature, allSignatures); } + hasAddedSymbolInfo = true; } - else if ((ts.isNameOfFunctionDeclaration(location) && !(symbolFlags & 98304)) || - (location.kind === 123 && location.parent.kind === 152)) { - var functionDeclaration_1 = location.parent; - var locationIsSymbolDeclaration = ts.findDeclaration(symbol, function (declaration) { - return declaration === (location.kind === 123 ? functionDeclaration_1.parent : functionDeclaration_1); - }); - if (locationIsSymbolDeclaration) { - var allSignatures = functionDeclaration_1.kind === 152 ? type.getNonNullableType().getConstructSignatures() : type.getNonNullableType().getCallSignatures(); - if (!typeChecker.isImplementationOfOverload(functionDeclaration_1)) { - signature = typeChecker.getSignatureFromDeclaration(functionDeclaration_1); - } - else { - signature = allSignatures[0]; - } - if (functionDeclaration_1.kind === 152) { - symbolKind = "constructor"; - addPrefixForAnyFunctionOrVar(type.symbol, symbolKind); - } - else { - addPrefixForAnyFunctionOrVar(functionDeclaration_1.kind === 155 && - !(type.symbol.flags & 2048 || type.symbol.flags & 4096) ? type.symbol : symbol, symbolKind); - } - addSignatureDisplayParts(signature, allSignatures); - hasAddedSymbolInfo = true; + } + else if ((ts.isNameOfFunctionDeclaration(location) && !(symbolFlags & 98304)) || + (location.kind === 123 && location.parent.kind === 152)) { + var functionDeclaration_1 = location.parent; + var locationIsSymbolDeclaration = ts.find(symbol.declarations, function (declaration) { + return declaration === (location.kind === 123 ? functionDeclaration_1.parent : functionDeclaration_1); + }); + if (locationIsSymbolDeclaration) { + var allSignatures = functionDeclaration_1.kind === 152 ? type.getNonNullableType().getConstructSignatures() : type.getNonNullableType().getCallSignatures(); + if (!typeChecker.isImplementationOfOverload(functionDeclaration_1)) { + signature = typeChecker.getSignatureFromDeclaration(functionDeclaration_1); } + else { + signature = allSignatures[0]; + } + if (functionDeclaration_1.kind === 152) { + symbolKind = "constructor"; + addPrefixForAnyFunctionOrVar(type.symbol, symbolKind); + } + else { + addPrefixForAnyFunctionOrVar(functionDeclaration_1.kind === 155 && + !(type.symbol.flags & 2048 || type.symbol.flags & 4096) ? type.symbol : symbol, symbolKind); + } + addSignatureDisplayParts(signature, allSignatures); + hasAddedSymbolInfo = true; } } } @@ -69361,7 +69817,9 @@ var ts; symbolFlags & 98304 || symbolKind === "method") { var allSignatures = type.getNonNullableType().getCallSignatures(); - addSignatureDisplayParts(allSignatures[0], allSignatures); + if (allSignatures.length) { + addSignatureDisplayParts(allSignatures[0], allSignatures); + } } } } @@ -69464,8 +69922,8 @@ var ts; if (declaration.kind !== 226 && declaration.kind !== 228) { return false; } - for (var parent = declaration.parent; !ts.isFunctionBlock(parent); parent = parent.parent) { - if (parent.kind === 265 || parent.kind === 234) { + for (var parent_26 = declaration.parent; !ts.isFunctionBlock(parent_26); parent_26 = parent_26.parent) { + if (parent_26.kind === 265 || parent_26.kind === 234) { return false; } } @@ -69509,11 +69967,11 @@ var ts; getSourceFile: function (fileName) { return fileName === ts.normalizePath(inputFileName) ? sourceFile : undefined; }, writeFile: function (name, text) { if (ts.fileExtensionIs(name, ".map")) { - ts.Debug.assert(sourceMapText === undefined, "Unexpected multiple source map outputs for the file '" + name + "'"); + ts.Debug.assertEqual(sourceMapText, undefined, "Unexpected multiple source map outputs, file:", name); sourceMapText = text; } else { - ts.Debug.assert(outputText === undefined, "Unexpected multiple outputs for the file: '" + name + "'"); + ts.Debug.assertEqual(outputText, undefined, "Unexpected multiple outputs, file:", name); outputText = text; } }, @@ -70132,6 +70590,7 @@ var ts; this.NoSpaceAfterSemicolonInFor = new formatting.Rule(formatting.RuleDescriptor.create3(25, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsOptionDisabledOrUndefined("insertSpaceAfterSemicolonInForStatements"), Rules.IsNonJsxSameLineTokenContext, Rules.IsForContext), 8)); this.SpaceAfterOpenParen = new formatting.Rule(formatting.RuleDescriptor.create3(19, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis"), Rules.IsNonJsxSameLineTokenContext), 2)); this.SpaceBeforeCloseParen = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 20), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis"), Rules.IsNonJsxSameLineTokenContext), 2)); + this.SpaceBetweenOpenParens = new formatting.Rule(formatting.RuleDescriptor.create1(19, 19), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis"), Rules.IsNonJsxSameLineTokenContext), 2)); this.NoSpaceBetweenParens = new formatting.Rule(formatting.RuleDescriptor.create1(19, 20), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); this.NoSpaceAfterOpenParen = new formatting.Rule(formatting.RuleDescriptor.create3(19, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis"), Rules.IsNonJsxSameLineTokenContext), 8)); this.NoSpaceBeforeCloseParen = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 20), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis"), Rules.IsNonJsxSameLineTokenContext), 8)); @@ -70203,7 +70662,7 @@ var ts; this.SpaceAfterComma, this.NoSpaceAfterComma, this.SpaceAfterAnonymousFunctionKeyword, this.NoSpaceAfterAnonymousFunctionKeyword, this.SpaceAfterKeywordInControl, this.NoSpaceAfterKeywordInControl, - this.SpaceAfterOpenParen, this.SpaceBeforeCloseParen, this.NoSpaceBetweenParens, this.NoSpaceAfterOpenParen, this.NoSpaceBeforeCloseParen, + this.SpaceAfterOpenParen, this.SpaceBeforeCloseParen, this.SpaceBetweenOpenParens, this.NoSpaceBetweenParens, this.NoSpaceAfterOpenParen, this.NoSpaceBeforeCloseParen, this.SpaceAfterOpenBracket, this.SpaceBeforeCloseBracket, this.NoSpaceBetweenBrackets, this.NoSpaceAfterOpenBracket, this.NoSpaceBeforeCloseBracket, this.SpaceAfterOpenBrace, this.SpaceBeforeCloseBrace, this.NoSpaceBetweenEmptyBraceBrackets, this.NoSpaceAfterOpenBrace, this.NoSpaceBeforeCloseBrace, this.SpaceAfterTemplateHeadAndMiddle, this.SpaceBeforeTemplateMiddleAndTail, this.NoSpaceAfterTemplateHeadAndMiddle, this.NoSpaceBeforeTemplateMiddleAndTail, @@ -70227,9 +70686,9 @@ var ts; } Rules.prototype.getRuleName = function (rule) { var o = this; - for (var name in o) { - if (o[name] === rule) { - return name; + for (var name_66 in o) { + if (o[name_66] === rule) { + return name_66; } } throw new Error("Unknown rule"); @@ -71003,7 +71462,6 @@ var ts; } function formatSpanWorker(originalRange, enclosingNode, initialIndentation, delta, formattingScanner, options, rulesProvider, requestKind, rangeContainsError, sourceFile) { var formattingContext = new formatting.FormattingContext(sourceFile, requestKind, options); - var previousRangeHasError; var previousRange; var previousParent; var previousRangeStartLine; @@ -71339,7 +71797,7 @@ var ts; function processRange(range, rangeStart, parent, contextNode, dynamicIndentation) { var rangeHasError = rangeContainsError(range); var lineAdded; - if (!rangeHasError && !previousRangeHasError) { + if (!rangeHasError) { if (!previousRange) { var originalStart = sourceFile.getLineAndCharacterOfPosition(originalRange.pos); trimTrailingWhitespacesForLines(originalStart.line, rangeStart.line); @@ -71352,7 +71810,6 @@ var ts; previousRange = range; previousParent = parent; previousRangeStartLine = rangeStart.line; - previousRangeHasError = rangeHasError; return lineAdded; } function processPair(currentItem, currentStartLine, currentParent, previousItem, previousStartLine, previousParent, contextNode, dynamicIndentation) { @@ -71531,6 +71988,32 @@ var ts; } } } + function getRangeOfEnclosingComment(sourceFile, position, onlyMultiLine, precedingToken, tokenAtPosition, predicate) { + if (tokenAtPosition === void 0) { tokenAtPosition = ts.getTokenAtPosition(sourceFile, position, false); } + var tokenStart = tokenAtPosition.getStart(sourceFile); + if (tokenStart <= position && position < tokenAtPosition.getEnd()) { + return undefined; + } + if (precedingToken === undefined) { + precedingToken = ts.findPrecedingToken(position, sourceFile); + } + var trailingRangesOfPreviousToken = precedingToken && ts.getTrailingCommentRanges(sourceFile.text, precedingToken.end); + var leadingCommentRangesOfNextToken = ts.getLeadingCommentRangesOfNode(tokenAtPosition, sourceFile); + var commentRanges = trailingRangesOfPreviousToken && leadingCommentRangesOfNextToken ? + trailingRangesOfPreviousToken.concat(leadingCommentRangesOfNextToken) : + trailingRangesOfPreviousToken || leadingCommentRangesOfNextToken; + if (commentRanges) { + for (var _i = 0, commentRanges_1 = commentRanges; _i < commentRanges_1.length; _i++) { + var range = commentRanges_1[_i]; + if ((range.pos < position && position < range.end || + position === range.end && (range.kind === 2 || position === sourceFile.getFullWidth()))) { + return (range.kind === 3 || !onlyMultiLine) && (!predicate || predicate(range)) ? range : undefined; + } + } + } + return undefined; + } + formatting.getRangeOfEnclosingComment = getRangeOfEnclosingComment; function getOpenTokenForList(node, list) { switch (node.kind) { case 152: @@ -71641,11 +72124,27 @@ var ts; return 0; } var precedingToken = ts.findPrecedingToken(position, sourceFile); + var enclosingCommentRange = formatting.getRangeOfEnclosingComment(sourceFile, position, true, precedingToken || null); + if (enclosingCommentRange) { + var previousLine = ts.getLineAndCharacterOfPosition(sourceFile, position).line - 1; + var commentStartLine = ts.getLineAndCharacterOfPosition(sourceFile, enclosingCommentRange.pos).line; + ts.Debug.assert(commentStartLine >= 0); + if (previousLine <= commentStartLine) { + return findFirstNonWhitespaceColumn(ts.getStartPositionOfLine(commentStartLine, sourceFile), position, sourceFile, options); + } + var startPostionOfLine = ts.getStartPositionOfLine(previousLine, sourceFile); + var _a = findFirstNonWhitespaceCharacterAndColumn(startPostionOfLine, position, sourceFile, options), column = _a.column, character = _a.character; + if (column === 0) { + return column; + } + var firstNonWhitespaceCharacterCode = sourceFile.text.charCodeAt(startPostionOfLine + character); + return firstNonWhitespaceCharacterCode === 42 ? column - 1 : column; + } if (!precedingToken) { return getBaseIndentation(options); } var precedingTokenIsLiteral = ts.isStringOrRegularExpressionOrTemplateLiteral(precedingToken.kind); - if (precedingTokenIsLiteral && precedingToken.getStart(sourceFile) <= position && precedingToken.end > position) { + if (precedingTokenIsLiteral && precedingToken.getStart(sourceFile) <= position && position < precedingToken.end) { return 0; } var lineAtPosition = sourceFile.getLineAndCharacterOfPosition(position).line; @@ -72050,6 +72549,12 @@ var ts; } return false; } + var ChangeKind; + (function (ChangeKind) { + ChangeKind[ChangeKind["Remove"] = 0] = "Remove"; + ChangeKind[ChangeKind["ReplaceWithSingleNode"] = 1] = "ReplaceWithSingleNode"; + ChangeKind[ChangeKind["ReplaceWithMultipleNodes"] = 2] = "ReplaceWithMultipleNodes"; + })(ChangeKind || (ChangeKind = {})); function getSeparatorCharacter(separator) { return ts.tokenToString(separator.kind); } @@ -72074,7 +72579,7 @@ var ts; } textChanges.getAdjustedStartPosition = getAdjustedStartPosition; function getAdjustedEndPosition(sourceFile, node, options) { - if (options.useNonAdjustedEndPosition) { + if (options.useNonAdjustedEndPosition || ts.isExpression(node)) { return node.getEnd(); } var end = node.getEnd(); @@ -72094,6 +72599,9 @@ var ts; } return s; } + function getNewlineKind(context) { + return context.newLineCharacter === "\n" ? 1 : 0; + } var ChangeTracker = (function () { function ChangeTracker(newLine, rulesProvider, validator) { this.newLine = newLine; @@ -72103,24 +72611,24 @@ var ts; this.newLineCharacter = ts.getNewLineCharacter({ newLine: newLine }); } ChangeTracker.fromCodeFixContext = function (context) { - return new ChangeTracker(context.newLineCharacter === "\n" ? 1 : 0, context.rulesProvider); + return new ChangeTracker(getNewlineKind(context), context.rulesProvider); + }; + ChangeTracker.prototype.deleteRange = function (sourceFile, range) { + this.changes.push({ kind: ChangeKind.Remove, sourceFile: sourceFile, range: range }); + return this; }; ChangeTracker.prototype.deleteNode = function (sourceFile, node, options) { if (options === void 0) { options = {}; } var startPosition = getAdjustedStartPosition(sourceFile, node, options, Position.FullStart); var endPosition = getAdjustedEndPosition(sourceFile, node, options); - this.changes.push({ sourceFile: sourceFile, options: options, range: { pos: startPosition, end: endPosition } }); - return this; - }; - ChangeTracker.prototype.deleteRange = function (sourceFile, range) { - this.changes.push({ sourceFile: sourceFile, range: range }); + this.changes.push({ kind: ChangeKind.Remove, sourceFile: sourceFile, range: { pos: startPosition, end: endPosition } }); return this; }; ChangeTracker.prototype.deleteNodeRange = function (sourceFile, startNode, endNode, options) { if (options === void 0) { options = {}; } var startPosition = getAdjustedStartPosition(sourceFile, startNode, options, Position.FullStart); var endPosition = getAdjustedEndPosition(sourceFile, endNode, options); - this.changes.push({ sourceFile: sourceFile, options: options, range: { pos: startPosition, end: endPosition } }); + this.changes.push({ kind: ChangeKind.Remove, sourceFile: sourceFile, range: { pos: startPosition, end: endPosition } }); return this; }; ChangeTracker.prototype.deleteNodeInList = function (sourceFile, node) { @@ -72156,33 +72664,68 @@ var ts; }; ChangeTracker.prototype.replaceRange = function (sourceFile, range, newNode, options) { if (options === void 0) { options = {}; } - this.changes.push({ sourceFile: sourceFile, range: range, options: options, node: newNode }); + this.changes.push({ kind: ChangeKind.ReplaceWithSingleNode, sourceFile: sourceFile, range: range, options: options, node: newNode }); return this; }; ChangeTracker.prototype.replaceNode = function (sourceFile, oldNode, newNode, options) { if (options === void 0) { options = {}; } var startPosition = getAdjustedStartPosition(sourceFile, oldNode, options, Position.Start); var endPosition = getAdjustedEndPosition(sourceFile, oldNode, options); - this.changes.push({ sourceFile: sourceFile, options: options, useIndentationFromFile: true, node: newNode, range: { pos: startPosition, end: endPosition } }); - return this; + return this.replaceWithSingle(sourceFile, startPosition, endPosition, newNode, options); }; ChangeTracker.prototype.replaceNodeRange = function (sourceFile, startNode, endNode, newNode, options) { if (options === void 0) { options = {}; } var startPosition = getAdjustedStartPosition(sourceFile, startNode, options, Position.Start); var endPosition = getAdjustedEndPosition(sourceFile, endNode, options); - this.changes.push({ sourceFile: sourceFile, options: options, useIndentationFromFile: true, node: newNode, range: { pos: startPosition, end: endPosition } }); + return this.replaceWithSingle(sourceFile, startPosition, endPosition, newNode, options); + }; + ChangeTracker.prototype.replaceWithSingle = function (sourceFile, startPosition, endPosition, newNode, options) { + this.changes.push({ + kind: ChangeKind.ReplaceWithSingleNode, + sourceFile: sourceFile, + options: options, + node: newNode, + range: { pos: startPosition, end: endPosition } + }); return this; }; + ChangeTracker.prototype.replaceWithMultiple = function (sourceFile, startPosition, endPosition, newNodes, options) { + this.changes.push({ + kind: ChangeKind.ReplaceWithMultipleNodes, + sourceFile: sourceFile, + options: options, + nodes: newNodes, + range: { pos: startPosition, end: endPosition } + }); + return this; + }; + ChangeTracker.prototype.replaceNodeWithNodes = function (sourceFile, oldNode, newNodes, options) { + var startPosition = getAdjustedStartPosition(sourceFile, oldNode, options, Position.Start); + var endPosition = getAdjustedEndPosition(sourceFile, oldNode, options); + return this.replaceWithMultiple(sourceFile, startPosition, endPosition, newNodes, options); + }; + ChangeTracker.prototype.replaceNodesWithNodes = function (sourceFile, oldNodes, newNodes, options) { + var startPosition = getAdjustedStartPosition(sourceFile, oldNodes[0], options, Position.Start); + var endPosition = getAdjustedEndPosition(sourceFile, ts.lastOrUndefined(oldNodes), options); + return this.replaceWithMultiple(sourceFile, startPosition, endPosition, newNodes, options); + }; + ChangeTracker.prototype.replaceRangeWithNodes = function (sourceFile, range, newNodes, options) { + return this.replaceWithMultiple(sourceFile, range.pos, range.end, newNodes, options); + }; + ChangeTracker.prototype.replaceNodeRangeWithNodes = function (sourceFile, startNode, endNode, newNodes, options) { + var startPosition = getAdjustedStartPosition(sourceFile, startNode, options, Position.Start); + var endPosition = getAdjustedEndPosition(sourceFile, endNode, options); + return this.replaceWithMultiple(sourceFile, startPosition, endPosition, newNodes, options); + }; ChangeTracker.prototype.insertNodeAt = function (sourceFile, pos, newNode, options) { if (options === void 0) { options = {}; } - this.changes.push({ sourceFile: sourceFile, options: options, node: newNode, range: { pos: pos, end: pos } }); + this.changes.push({ kind: ChangeKind.ReplaceWithSingleNode, sourceFile: sourceFile, options: options, node: newNode, range: { pos: pos, end: pos } }); return this; }; ChangeTracker.prototype.insertNodeBefore = function (sourceFile, before, newNode, options) { if (options === void 0) { options = {}; } var startPosition = getAdjustedStartPosition(sourceFile, before, options, Position.Start); - this.changes.push({ sourceFile: sourceFile, options: options, useIndentationFromFile: true, node: newNode, range: { pos: startPosition, end: startPosition } }); - return this; + return this.replaceWithSingle(sourceFile, startPosition, startPosition, newNode, options); }; ChangeTracker.prototype.insertNodeAfter = function (sourceFile, after, newNode, options) { if (options === void 0) { options = {}; } @@ -72192,6 +72735,7 @@ var ts; after.kind === 150) { if (sourceFile.text.charCodeAt(after.end - 1) !== 59) { this.changes.push({ + kind: ChangeKind.ReplaceWithSingleNode, sourceFile: sourceFile, options: {}, range: { pos: after.end, end: after.end }, @@ -72200,8 +72744,7 @@ var ts; } } var endPosition = getAdjustedEndPosition(sourceFile, after, options); - this.changes.push({ sourceFile: sourceFile, options: options, useIndentationFromFile: true, node: newNode, range: { pos: endPosition, end: endPosition } }); - return this; + return this.replaceWithSingle(sourceFile, endPosition, endPosition, newNode, options); }; ChangeTracker.prototype.insertNodeInListAfter = function (sourceFile, after, newNode) { var containingList = ts.formatting.SmartIndenter.getContainingList(after, sourceFile); @@ -72229,10 +72772,10 @@ var ts; startPos = ts.getStartPositionOfLine(lineAndCharOfNextElement.line, sourceFile); } this.changes.push({ + kind: ChangeKind.ReplaceWithSingleNode, sourceFile: sourceFile, range: { pos: startPos, end: containingList[index + 1].getStart(sourceFile) }, node: newNode, - useIndentationFromFile: true, options: { prefix: prefix, suffix: "" + ts.tokenToString(nextToken.kind) + sourceFile.text.substring(nextToken.end, containingList[index + 1].getStart(sourceFile)) @@ -72259,6 +72802,7 @@ var ts; } if (multilineList) { this.changes.push({ + kind: ChangeKind.ReplaceWithSingleNode, sourceFile: sourceFile, range: { pos: end, end: end }, node: ts.createToken(separator), @@ -72270,6 +72814,7 @@ var ts; insertPos--; } this.changes.push({ + kind: ChangeKind.ReplaceWithSingleNode, sourceFile: sourceFile, range: { pos: insertPos, end: insertPos }, node: newNode, @@ -72278,6 +72823,7 @@ var ts; } else { this.changes.push({ + kind: ChangeKind.ReplaceWithSingleNode, sourceFile: sourceFile, range: { pos: end, end: end }, node: newNode, @@ -72317,31 +72863,44 @@ var ts; return ts.createTextSpanFromBounds(change.range.pos, change.range.end); }; ChangeTracker.prototype.computeNewText = function (change, sourceFile) { - if (!change.node) { + var _this = this; + if (change.kind === ChangeKind.Remove) { return ""; } var options = change.options || {}; - var nonFormattedText = getNonformattedText(change.node, sourceFile, this.newLine); - if (this.validator) { - this.validator(nonFormattedText); - } - var formatOptions = this.rulesProvider.getFormatOptions(); + var text; var pos = change.range.pos; var posStartsLine = ts.getLineStartPositionForPosition(pos, sourceFile) === pos; - var initialIndentation = change.options.indentation !== undefined - ? change.options.indentation - : change.useIndentationFromFile - ? ts.formatting.SmartIndenter.getIndentation(change.range.pos, sourceFile, formatOptions, posStartsLine || (change.options.prefix === this.newLineCharacter)) - : 0; - var delta = change.options.delta !== undefined - ? change.options.delta - : ts.formatting.SmartIndenter.shouldIndentChildNode(change.node) - ? formatOptions.indentSize - : 0; - var text = applyFormatting(nonFormattedText, sourceFile, initialIndentation, delta, this.rulesProvider); - text = posStartsLine || change.options.indentation !== undefined ? text : text.replace(/^\s+/, ""); + if (change.kind === ChangeKind.ReplaceWithMultipleNodes) { + var parts = change.nodes.map(function (n) { return _this.getFormattedTextOfNode(n, sourceFile, pos, options); }); + text = parts.join(change.options.nodeSeparator); + } + else { + ts.Debug.assert(change.kind === ChangeKind.ReplaceWithSingleNode, "change.kind === ReplaceWithSingleNode"); + text = this.getFormattedTextOfNode(change.node, sourceFile, pos, options); + } + text = (posStartsLine || options.indentation !== undefined) ? text : text.replace(/^\s+/, ""); return (options.prefix || "") + text + (options.suffix || ""); }; + ChangeTracker.prototype.getFormattedTextOfNode = function (node, sourceFile, pos, options) { + var nonformattedText = getNonformattedText(node, sourceFile, this.newLine); + if (this.validator) { + this.validator(nonformattedText); + } + var formatOptions = this.rulesProvider.getFormatOptions(); + var posStartsLine = ts.getLineStartPositionForPosition(pos, sourceFile) === pos; + var initialIndentation = options.indentation !== undefined + ? options.indentation + : (options.useIndentationFromFile !== false) + ? ts.formatting.SmartIndenter.getIndentation(pos, sourceFile, formatOptions, posStartsLine || (options.prefix === this.newLineCharacter)) + : 0; + var delta = options.delta !== undefined + ? options.delta + : ts.formatting.SmartIndenter.shouldIndentChildNode(node) + ? (formatOptions.indentSize || 0) + : 0; + return applyFormatting(nonformattedText, sourceFile, initialIndentation, delta, this.rulesProvider); + }; ChangeTracker.normalize = function (changes) { var normalized = ts.stableSort(changes, function (a, b) { return a.range.pos - b.range.pos; }); for (var i = 0; i < normalized.length - 2; i++) { @@ -73319,7 +73878,7 @@ var ts; symbolName = name; } else if (ts.isJsxOpeningLikeElement(token.parent) && token.parent.tagName === token) { - symbol = checker.getAliasedSymbol(checker.resolveNameAtLocation(token, checker.getJsxNamespace(), 107455)); + symbol = checker.getAliasedSymbol(checker.resolveName(checker.getJsxNamespace(), token.parent.tagName, 107455)); symbolName = symbol.name; } else { @@ -73403,8 +73962,8 @@ var ts; var namespaceImportDeclaration; var namedImportDeclaration; var existingModuleSpecifier; - for (var _i = 0, declarations_14 = declarations; _i < declarations_14.length; _i++) { - var declaration = declarations_14[_i]; + for (var _i = 0, declarations_13 = declarations; _i < declarations_13.length; _i++) { + var declaration = declarations_13[_i]; if (declaration.kind === 238) { var namedBindings = declaration.importClause && declaration.importClause.namedBindings; if (namedBindings && namedBindings.kind === 240) { @@ -73478,14 +74037,53 @@ var ts; : isNamespaceImport ? ts.createImportClause(undefined, ts.createNamespaceImport(ts.createIdentifier(symbolName))) : ts.createImportClause(undefined, ts.createNamedImports([ts.createImportSpecifier(undefined, ts.createIdentifier(symbolName))])); - var importDecl = ts.createImportDeclaration(undefined, undefined, importClause, ts.createLiteral(moduleSpecifierWithoutQuotes)); + var moduleSpecifierLiteral = ts.createLiteral(moduleSpecifierWithoutQuotes); + moduleSpecifierLiteral.singleQuote = getSingleQuoteStyleFromExistingImports(); + var importDecl = ts.createImportDeclaration(undefined, undefined, importClause, moduleSpecifierLiteral); if (!lastImportDeclaration) { - changeTracker.insertNodeAt(sourceFile, sourceFile.getStart(), importDecl, { suffix: "" + context.newLineCharacter + context.newLineCharacter }); + changeTracker.insertNodeAt(sourceFile, getSourceFileImportLocation(sourceFile), importDecl, { suffix: "" + context.newLineCharacter + context.newLineCharacter }); } else { changeTracker.insertNodeAfter(sourceFile, lastImportDeclaration, importDecl, { suffix: context.newLineCharacter }); } return createCodeAction(ts.Diagnostics.Import_0_from_1, [symbolName, "\"" + moduleSpecifierWithoutQuotes + "\""], changeTracker.getChanges(), "NewImport", moduleSpecifierWithoutQuotes); + function getSourceFileImportLocation(node) { + var text = node.text; + var ranges = ts.getLeadingCommentRanges(text, 0); + if (!ranges) + return 0; + var position = 0; + if (ranges.length && ranges[0].kind === 3 && ts.isPinnedComment(text, ranges[0])) { + position = ranges[0].end + 1; + ranges = ranges.slice(1); + } + for (var _i = 0, ranges_1 = ranges; _i < ranges_1.length; _i++) { + var range = ranges_1[_i]; + if (range.kind === 2 && ts.isRecognizedTripleSlashComment(node.text, range.pos, range.end)) { + position = range.end + 1; + continue; + } + break; + } + return position; + } + function getSingleQuoteStyleFromExistingImports() { + var firstModuleSpecifier = ts.forEach(sourceFile.statements, function (node) { + if (ts.isImportDeclaration(node) || ts.isExportDeclaration(node)) { + if (node.moduleSpecifier && ts.isStringLiteral(node.moduleSpecifier)) { + return node.moduleSpecifier; + } + } + else if (ts.isImportEqualsDeclaration(node)) { + if (ts.isExternalModuleReference(node.moduleReference) && ts.isStringLiteral(node.moduleReference.expression)) { + return node.moduleReference.expression; + } + } + }); + if (firstModuleSpecifier) { + return sourceFile.text.charCodeAt(firstModuleSpecifier.getStart()) === 39; + } + } function getModuleSpecifierForNewImport() { var fileName = sourceFile.fileName; var moduleFileName = moduleSymbol.valueDeclaration.getSourceFile().fileName; @@ -73615,7 +74213,8 @@ var ts; (function (States) { States[States["BeforeNodeModules"] = 0] = "BeforeNodeModules"; States[States["NodeModules"] = 1] = "NodeModules"; - States[States["PackageContent"] = 2] = "PackageContent"; + States[States["Scope"] = 2] = "Scope"; + States[States["PackageContent"] = 3] = "PackageContent"; })(States || (States = {})); var partStart = 0; var partEnd = 0; @@ -73632,15 +74231,21 @@ var ts; } break; case 1: - packageRootIndex = partEnd; - state = 2; - break; case 2: + if (state === 1 && fullPath.charAt(partStart + 1) === "@") { + state = 2; + } + else { + packageRootIndex = partEnd; + state = 3; + } + break; + case 3: if (fullPath.indexOf("/node_modules/", partStart) === partStart) { state = 1; } else { - state = 2; + state = 3; } break; } @@ -73867,8 +74472,8 @@ var ts; if (includeTypeScriptSyntax) { var typeArgCount = ts.length(callExpression.typeArguments); for (var i = 0; i < typeArgCount; i++) { - var name = typeArgCount < 8 ? String.fromCharCode(84 + i) : "T" + i; - var typeParameter = ts.createTypeParameterDeclaration(name, undefined, undefined); + var name_67 = typeArgCount < 8 ? String.fromCharCode(84 + i) : "T" + i; + var typeParameter = ts.createTypeParameterDeclaration(name_67, undefined, undefined); (typeParameters ? typeParameters : typeParameters = []).push(typeParameter); } } @@ -73930,206 +74535,1029 @@ var ts; (function (ts) { var refactor; (function (refactor) { - var actionName = "convert"; - var convertFunctionToES6Class = { - name: "Convert to ES2015 class", - description: ts.Diagnostics.Convert_function_to_an_ES2015_class.message, - getEditsForAction: getEditsForAction, - getAvailableActions: getAvailableActions - }; - refactor.registerRefactor(convertFunctionToES6Class); - function getAvailableActions(context) { - if (!ts.isInJavaScriptFile(context.file)) { - return undefined; + var convertFunctionToES6Class; + (function (convertFunctionToES6Class_1) { + var actionName = "convert"; + var convertFunctionToES6Class = { + name: "Convert to ES2015 class", + description: ts.Diagnostics.Convert_function_to_an_ES2015_class.message, + getEditsForAction: getEditsForAction, + getAvailableActions: getAvailableActions + }; + refactor.registerRefactor(convertFunctionToES6Class); + function getAvailableActions(context) { + if (!ts.isInJavaScriptFile(context.file)) { + return undefined; + } + var start = context.startPosition; + var node = ts.getTokenAtPosition(context.file, start, false); + var checker = context.program.getTypeChecker(); + var symbol = checker.getSymbolAtLocation(node); + if (symbol && ts.isDeclarationOfFunctionOrClassExpression(symbol)) { + symbol = symbol.valueDeclaration.initializer.symbol; + } + if (symbol && (symbol.flags & 16) && symbol.members && (symbol.members.size > 0)) { + return [ + { + name: convertFunctionToES6Class.name, + description: convertFunctionToES6Class.description, + actions: [ + { + description: convertFunctionToES6Class.description, + name: actionName + } + ] + } + ]; + } } - var start = context.startPosition; - var node = ts.getTokenAtPosition(context.file, start, false); - var checker = context.program.getTypeChecker(); - var symbol = checker.getSymbolAtLocation(node); - if (symbol && ts.isDeclarationOfFunctionOrClassExpression(symbol)) { - symbol = symbol.valueDeclaration.initializer.symbol; - } - if (symbol && (symbol.flags & 16) && symbol.members && (symbol.members.size > 0)) { - return [ - { - name: convertFunctionToES6Class.name, - description: convertFunctionToES6Class.description, - actions: [ - { - description: convertFunctionToES6Class.description, - name: actionName - } - ] + function getEditsForAction(context, action) { + if (actionName !== action) { + return undefined; + } + var start = context.startPosition; + var sourceFile = context.file; + var checker = context.program.getTypeChecker(); + var token = ts.getTokenAtPosition(sourceFile, start, false); + var ctorSymbol = checker.getSymbolAtLocation(token); + var newLine = context.rulesProvider.getFormatOptions().newLineCharacter; + var deletedNodes = []; + var deletes = []; + if (!(ctorSymbol.flags & (16 | 3))) { + return undefined; + } + var ctorDeclaration = ctorSymbol.valueDeclaration; + var changeTracker = ts.textChanges.ChangeTracker.fromCodeFixContext(context); + var precedingNode; + var newClassDeclaration; + switch (ctorDeclaration.kind) { + case 228: + precedingNode = ctorDeclaration; + deleteNode(ctorDeclaration); + newClassDeclaration = createClassFromFunctionDeclaration(ctorDeclaration); + break; + case 226: + precedingNode = ctorDeclaration.parent.parent; + if (ctorDeclaration.parent.declarations.length === 1) { + deleteNode(precedingNode); + } + else { + deleteNode(ctorDeclaration, true); + } + newClassDeclaration = createClassFromVariableDeclaration(ctorDeclaration); + break; + } + if (!newClassDeclaration) { + return undefined; + } + changeTracker.insertNodeAfter(sourceFile, precedingNode, newClassDeclaration, { suffix: newLine }); + for (var _i = 0, deletes_1 = deletes; _i < deletes_1.length; _i++) { + var deleteCallback = deletes_1[_i]; + deleteCallback(); + } + return { + edits: changeTracker.getChanges() + }; + function deleteNode(node, inList) { + if (inList === void 0) { inList = false; } + if (deletedNodes.some(function (n) { return ts.isNodeDescendantOf(node, n); })) { + return; } - ]; - } - } - function getEditsForAction(context, action) { - if (actionName !== action) { - return undefined; - } - var start = context.startPosition; - var sourceFile = context.file; - var checker = context.program.getTypeChecker(); - var token = ts.getTokenAtPosition(sourceFile, start, false); - var ctorSymbol = checker.getSymbolAtLocation(token); - var newLine = context.rulesProvider.getFormatOptions().newLineCharacter; - var deletedNodes = []; - var deletes = []; - if (!(ctorSymbol.flags & (16 | 3))) { - return undefined; - } - var ctorDeclaration = ctorSymbol.valueDeclaration; - var changeTracker = ts.textChanges.ChangeTracker.fromCodeFixContext(context); - var precedingNode; - var newClassDeclaration; - switch (ctorDeclaration.kind) { - case 228: - precedingNode = ctorDeclaration; - deleteNode(ctorDeclaration); - newClassDeclaration = createClassFromFunctionDeclaration(ctorDeclaration); - break; - case 226: - precedingNode = ctorDeclaration.parent.parent; - if (ctorDeclaration.parent.declarations.length === 1) { - deleteNode(precedingNode); + deletedNodes.push(node); + if (inList) { + deletes.push(function () { return changeTracker.deleteNodeInList(sourceFile, node); }); } else { - deleteNode(ctorDeclaration, true); + deletes.push(function () { return changeTracker.deleteNode(sourceFile, node); }); } - newClassDeclaration = createClassFromVariableDeclaration(ctorDeclaration); - break; - } - if (!newClassDeclaration) { - return undefined; - } - changeTracker.insertNodeAfter(sourceFile, precedingNode, newClassDeclaration, { suffix: newLine }); - for (var _i = 0, deletes_1 = deletes; _i < deletes_1.length; _i++) { - var deleteCallback = deletes_1[_i]; - deleteCallback(); - } - return { - edits: changeTracker.getChanges() - }; - function deleteNode(node, inList) { - if (inList === void 0) { inList = false; } - if (deletedNodes.some(function (n) { return ts.isNodeDescendantOf(node, n); })) { - return; } - deletedNodes.push(node); - if (inList) { - deletes.push(function () { return changeTracker.deleteNodeInList(sourceFile, node); }); + function createClassElementsFromSymbol(symbol) { + var memberElements = []; + if (symbol.members) { + symbol.members.forEach(function (member) { + var memberElement = createClassElement(member, undefined); + if (memberElement) { + memberElements.push(memberElement); + } + }); + } + if (symbol.exports) { + symbol.exports.forEach(function (member) { + var memberElement = createClassElement(member, [ts.createToken(115)]); + if (memberElement) { + memberElements.push(memberElement); + } + }); + } + return memberElements; + function shouldConvertDeclaration(_target, source) { + return ts.isFunctionLike(source); + } + function createClassElement(symbol, modifiers) { + if (!(symbol.flags & 4)) { + return; + } + var memberDeclaration = symbol.valueDeclaration; + var assignmentBinaryExpression = memberDeclaration.parent; + if (!shouldConvertDeclaration(memberDeclaration, assignmentBinaryExpression.right)) { + return; + } + var nodeToDelete = assignmentBinaryExpression.parent && assignmentBinaryExpression.parent.kind === 210 + ? assignmentBinaryExpression.parent : assignmentBinaryExpression; + deleteNode(nodeToDelete); + if (!assignmentBinaryExpression.right) { + return ts.createProperty([], modifiers, symbol.name, undefined, undefined, undefined); + } + switch (assignmentBinaryExpression.right.kind) { + case 186: { + var functionExpression = assignmentBinaryExpression.right; + var method = ts.createMethod(undefined, modifiers, undefined, memberDeclaration.name, undefined, undefined, functionExpression.parameters, undefined, functionExpression.body); + copyComments(assignmentBinaryExpression, method); + return method; + } + case 187: { + var arrowFunction = assignmentBinaryExpression.right; + var arrowFunctionBody = arrowFunction.body; + var bodyBlock = void 0; + if (arrowFunctionBody.kind === 207) { + bodyBlock = arrowFunctionBody; + } + else { + var expression = arrowFunctionBody; + bodyBlock = ts.createBlock([ts.createReturn(expression)]); + } + var method = ts.createMethod(undefined, modifiers, undefined, memberDeclaration.name, undefined, undefined, arrowFunction.parameters, undefined, bodyBlock); + copyComments(assignmentBinaryExpression, method); + return method; + } + default: { + if (ts.isSourceFileJavaScript(sourceFile)) { + return; + } + var prop = ts.createProperty(undefined, modifiers, memberDeclaration.name, undefined, undefined, assignmentBinaryExpression.right); + copyComments(assignmentBinaryExpression.parent, prop); + return prop; + } + } + } + } + function copyComments(sourceNode, targetNode) { + ts.forEachLeadingCommentRange(sourceFile.text, sourceNode.pos, function (pos, end, kind, htnl) { + if (kind === 3) { + pos += 2; + end -= 2; + } + else { + pos += 2; + } + ts.addSyntheticLeadingComment(targetNode, kind, sourceFile.text.slice(pos, end), htnl); + }); + } + function createClassFromVariableDeclaration(node) { + var initializer = node.initializer; + if (!initializer || initializer.kind !== 186) { + return undefined; + } + if (node.name.kind !== 71) { + return undefined; + } + var memberElements = createClassElementsFromSymbol(initializer.symbol); + if (initializer.body) { + memberElements.unshift(ts.createConstructor(undefined, undefined, initializer.parameters, initializer.body)); + } + var cls = ts.createClassDeclaration(undefined, undefined, node.name, undefined, undefined, memberElements); + return cls; + } + function createClassFromFunctionDeclaration(node) { + var memberElements = createClassElementsFromSymbol(ctorSymbol); + if (node.body) { + memberElements.unshift(ts.createConstructor(undefined, undefined, node.parameters, node.body)); + } + var cls = ts.createClassDeclaration(undefined, undefined, node.name, undefined, undefined, memberElements); + return cls; + } + } + })(convertFunctionToES6Class = refactor.convertFunctionToES6Class || (refactor.convertFunctionToES6Class = {})); + })(refactor = ts.refactor || (ts.refactor = {})); +})(ts || (ts = {})); +var ts; +(function (ts) { + var refactor; + (function (refactor) { + var extractMethod; + (function (extractMethod_1) { + var extractMethod = { + name: "Extract Method", + description: ts.Diagnostics.Extract_function.message, + getAvailableActions: getAvailableActions, + getEditsForAction: getEditsForAction, + }; + refactor.registerRefactor(extractMethod); + function getAvailableActions(context) { + var rangeToExtract = getRangeToExtract(context.file, { start: context.startPosition, length: context.endPosition - context.startPosition }); + var targetRange = rangeToExtract.targetRange; + if (targetRange === undefined) { + return undefined; + } + var extractions = getPossibleExtractions(targetRange, context); + if (extractions === undefined) { + return undefined; + } + var actions = []; + var usedNames = ts.createMap(); + var i = 0; + for (var _i = 0, extractions_1 = extractions; _i < extractions_1.length; _i++) { + var extr = extractions_1[_i]; + if (extr.errors && extr.errors.length) { + continue; + } + var description = ts.formatStringFromArgs(ts.Diagnostics.Extract_function_into_0.message, [extr.scopeDescription]); + if (!usedNames.has(description)) { + usedNames.set(description, true); + actions.push({ + description: description, + name: "scope_" + i + }); + } + i++; + } + if (actions.length === 0) { + return undefined; + } + return [{ + name: extractMethod.name, + description: extractMethod.description, + inlineable: true, + actions: actions + }]; + } + function getEditsForAction(context, actionName) { + var length = context.endPosition === undefined ? 0 : context.endPosition - context.startPosition; + var rangeToExtract = getRangeToExtract(context.file, { start: context.startPosition, length: length }); + var targetRange = rangeToExtract.targetRange; + var parsedIndexMatch = /^scope_(\d+)$/.exec(actionName); + ts.Debug.assert(!!parsedIndexMatch, "Scope name should have matched the regexp"); + var index = +parsedIndexMatch[1]; + ts.Debug.assert(isFinite(index), "Expected to parse a finite number from the scope index"); + var extractions = getPossibleExtractions(targetRange, context, index); + ts.Debug.assert(extractions !== undefined, "The extraction went missing? How?"); + return ({ edits: extractions[0].changes }); + } + var Messages; + (function (Messages) { + function createMessage(message) { + return { message: message, code: 0, category: ts.DiagnosticCategory.Message, key: message }; + } + Messages.CannotExtractFunction = createMessage("Cannot extract function."); + Messages.StatementOrExpressionExpected = createMessage("Statement or expression expected."); + Messages.CannotExtractRangeContainingConditionalBreakOrContinueStatements = createMessage("Cannot extract range containing conditional break or continue statements."); + Messages.CannotExtractRangeContainingConditionalReturnStatement = createMessage("Cannot extract range containing conditional return statement."); + Messages.CannotExtractRangeContainingLabeledBreakOrContinueStatementWithTargetOutsideOfTheRange = createMessage("Cannot extract range containing labeled break or continue with target outside of the range."); + Messages.CannotExtractRangeThatContainsWritesToReferencesLocatedOutsideOfTheTargetRangeInGenerators = createMessage("Cannot extract range containing writes to references located outside of the target range in generators."); + Messages.TypeWillNotBeVisibleInTheNewScope = createMessage("Type will not visible in the new scope."); + Messages.FunctionWillNotBeVisibleInTheNewScope = createMessage("Function will not visible in the new scope."); + Messages.InsufficientSelection = createMessage("Select more than a single identifier."); + Messages.CannotExtractExportedEntity = createMessage("Cannot extract exported declaration"); + Messages.CannotCombineWritesAndReturns = createMessage("Cannot combine writes and returns"); + Messages.CannotExtractReadonlyPropertyInitializerOutsideConstructor = createMessage("Cannot move initialization of read-only class property outside of the constructor"); + Messages.CannotExtractAmbientBlock = createMessage("Cannot extract code from ambient contexts"); + })(Messages || (Messages = {})); + var RangeFacts; + (function (RangeFacts) { + RangeFacts[RangeFacts["None"] = 0] = "None"; + RangeFacts[RangeFacts["HasReturn"] = 1] = "HasReturn"; + RangeFacts[RangeFacts["IsGenerator"] = 2] = "IsGenerator"; + RangeFacts[RangeFacts["IsAsyncFunction"] = 4] = "IsAsyncFunction"; + RangeFacts[RangeFacts["UsesThis"] = 8] = "UsesThis"; + RangeFacts[RangeFacts["InStaticRegion"] = 16] = "InStaticRegion"; + })(RangeFacts = extractMethod_1.RangeFacts || (extractMethod_1.RangeFacts = {})); + function getRangeToExtract(sourceFile, span) { + var length = span.length || 0; + var start = getParentNodeInSpan(ts.getTokenAtPosition(sourceFile, span.start, false), sourceFile, span); + var end = getParentNodeInSpan(ts.findTokenOnLeftOfPosition(sourceFile, ts.textSpanEnd(span)), sourceFile, span); + var declarations = []; + var rangeFacts = RangeFacts.None; + if (!start || !end) { + return { errors: [ts.createFileDiagnostic(sourceFile, span.start, length, Messages.CannotExtractFunction)] }; + } + if (start.parent !== end.parent) { + var startParent = ts.skipParentheses(start.parent); + var endParent = ts.skipParentheses(end.parent); + if (ts.isBinaryExpression(startParent) && ts.isBinaryExpression(endParent) && ts.isNodeDescendantOf(startParent, endParent)) { + start = end = endParent; + } + else { + return createErrorResult(sourceFile, span.start, length, Messages.CannotExtractFunction); + } + } + if (start !== end) { + if (!isBlockLike(start.parent)) { + return createErrorResult(sourceFile, span.start, length, Messages.CannotExtractFunction); + } + var statements = []; + for (var _i = 0, _a = start.parent.statements; _i < _a.length; _i++) { + var statement = _a[_i]; + if (statement === start || statements.length) { + var errors = checkNode(statement); + if (errors) { + return { errors: errors }; + } + statements.push(statement); + } + if (statement === end) { + break; + } + } + return { targetRange: { range: statements, facts: rangeFacts, declarations: declarations } }; } else { - deletes.push(function () { return changeTracker.deleteNode(sourceFile, node); }); - } - } - function createClassElementsFromSymbol(symbol) { - var memberElements = []; - if (symbol.members) { - symbol.members.forEach(function (member) { - var memberElement = createClassElement(member, undefined); - if (memberElement) { - memberElements.push(memberElement); - } - }); - } - if (symbol.exports) { - symbol.exports.forEach(function (member) { - var memberElement = createClassElement(member, [ts.createToken(115)]); - if (memberElement) { - memberElements.push(memberElement); - } - }); - } - return memberElements; - function shouldConvertDeclaration(_target, source) { - return ts.isFunctionLike(source); - } - function createClassElement(symbol, modifiers) { - if (!(symbol.flags & 4)) { - return; + var errors = checkRootNode(start) || checkNode(start); + if (errors) { + return { errors: errors }; } - var memberDeclaration = symbol.valueDeclaration; - var assignmentBinaryExpression = memberDeclaration.parent; - if (!shouldConvertDeclaration(memberDeclaration, assignmentBinaryExpression.right)) { - return; + var range = ts.isStatement(start) + ? [start] + : start.parent && start.parent.kind === 210 + ? [start.parent] + : start; + return { targetRange: { range: range, facts: rangeFacts, declarations: declarations } }; + } + function createErrorResult(sourceFile, start, length, message) { + return { errors: [ts.createFileDiagnostic(sourceFile, start, length, message)] }; + } + function checkRootNode(node) { + if (ts.isIdentifier(node)) { + return [ts.createDiagnosticForNode(node, Messages.InsufficientSelection)]; } - var nodeToDelete = assignmentBinaryExpression.parent && assignmentBinaryExpression.parent.kind === 210 - ? assignmentBinaryExpression.parent : assignmentBinaryExpression; - deleteNode(nodeToDelete); - if (!assignmentBinaryExpression.right) { - return ts.createProperty([], modifiers, symbol.name, undefined, undefined, undefined); + return undefined; + } + function checkForStaticContext(nodeToCheck, containingClass) { + var current = nodeToCheck; + while (current !== containingClass) { + if (current.kind === 149) { + if (ts.hasModifier(current, 32)) { + rangeFacts |= RangeFacts.InStaticRegion; + } + break; + } + else if (current.kind === 146) { + var ctorOrMethod = ts.getContainingFunction(current); + if (ctorOrMethod.kind === 152) { + rangeFacts |= RangeFacts.InStaticRegion; + } + break; + } + else if (current.kind === 151) { + if (ts.hasModifier(current, 32)) { + rangeFacts |= RangeFacts.InStaticRegion; + } + } + current = current.parent; } - switch (assignmentBinaryExpression.right.kind) { - case 186: { - var functionExpression = assignmentBinaryExpression.right; - var method = ts.createMethod(undefined, modifiers, undefined, memberDeclaration.name, undefined, undefined, functionExpression.parameters, undefined, functionExpression.body); - copyComments(assignmentBinaryExpression, method); - return method; + } + function checkNode(nodeToCheck) { + var PermittedJumps; + (function (PermittedJumps) { + PermittedJumps[PermittedJumps["None"] = 0] = "None"; + PermittedJumps[PermittedJumps["Break"] = 1] = "Break"; + PermittedJumps[PermittedJumps["Continue"] = 2] = "Continue"; + PermittedJumps[PermittedJumps["Return"] = 4] = "Return"; + })(PermittedJumps || (PermittedJumps = {})); + if (!ts.isStatement(nodeToCheck) && !(ts.isExpression(nodeToCheck) && isExtractableExpression(nodeToCheck))) { + return [ts.createDiagnosticForNode(nodeToCheck, Messages.StatementOrExpressionExpected)]; + } + if (ts.isInAmbientContext(nodeToCheck)) { + return [ts.createDiagnosticForNode(nodeToCheck, Messages.CannotExtractAmbientBlock)]; + } + var containingClass = ts.getContainingClass(nodeToCheck); + if (containingClass) { + checkForStaticContext(nodeToCheck, containingClass); + } + var errors; + var permittedJumps = 4; + var seenLabels; + visit(nodeToCheck); + return errors; + function visit(node) { + if (errors) { + return true; } - case 187: { - var arrowFunction = assignmentBinaryExpression.right; - var arrowFunctionBody = arrowFunction.body; - var bodyBlock = void 0; - if (arrowFunctionBody.kind === 207) { - bodyBlock = arrowFunctionBody; + if (ts.isDeclaration(node)) { + var declaringNode = (node.kind === 226) ? node.parent.parent : node; + if (ts.hasModifier(declaringNode, 1)) { + (errors || (errors = [])).push(ts.createDiagnosticForNode(node, Messages.CannotExtractExportedEntity)); + return true; } - else { - var expression = arrowFunctionBody; - bodyBlock = ts.createBlock([ts.createReturn(expression)]); - } - var method = ts.createMethod(undefined, modifiers, undefined, memberDeclaration.name, undefined, undefined, arrowFunction.parameters, undefined, bodyBlock); - copyComments(assignmentBinaryExpression, method); - return method; + declarations.push(node.symbol); } - default: { - if (ts.isSourceFileJavaScript(sourceFile)) { - return; - } - var prop = ts.createProperty(undefined, modifiers, memberDeclaration.name, undefined, undefined, assignmentBinaryExpression.right); - copyComments(assignmentBinaryExpression.parent, prop); - return prop; + switch (node.kind) { + case 238: + (errors || (errors = [])).push(ts.createDiagnosticForNode(node, Messages.CannotExtractFunction)); + return true; + case 97: + if (node.parent.kind === 181) { + var containingClass_1 = ts.getContainingClass(node); + if (containingClass_1.pos < span.start || containingClass_1.end >= (span.start + span.length)) { + (errors || (errors = [])).push(ts.createDiagnosticForNode(node, Messages.CannotExtractFunction)); + return true; + } + } + else { + rangeFacts |= RangeFacts.UsesThis; + } + break; } + if (!node || ts.isFunctionLike(node) || ts.isClassLike(node)) { + switch (node.kind) { + case 228: + case 229: + if (node.parent.kind === 265 && node.parent.externalModuleIndicator === undefined) { + (errors || (errors = [])).push(ts.createDiagnosticForNode(node, Messages.FunctionWillNotBeVisibleInTheNewScope)); + } + break; + } + return false; + } + var savedPermittedJumps = permittedJumps; + if (node.parent) { + switch (node.parent.kind) { + case 211: + if (node.parent.thenStatement === node || node.parent.elseStatement === node) { + permittedJumps = 0; + } + break; + case 224: + if (node.parent.tryBlock === node) { + permittedJumps = 0; + } + else if (node.parent.finallyBlock === node) { + permittedJumps = 4; + } + break; + case 260: + if (node.parent.block === node) { + permittedJumps = 0; + } + break; + case 257: + if (node.expression !== node) { + permittedJumps |= 1; + } + break; + default: + if (ts.isIterationStatement(node.parent, false)) { + if (node.parent.statement === node) { + permittedJumps |= 1 | 2; + } + } + break; + } + } + switch (node.kind) { + case 169: + case 99: + rangeFacts |= RangeFacts.UsesThis; + break; + case 222: + { + var label = node.label; + (seenLabels || (seenLabels = [])).push(label.escapedText); + ts.forEachChild(node, visit); + seenLabels.pop(); + break; + } + case 218: + case 217: + { + var label = node.label; + if (label) { + if (!ts.contains(seenLabels, label.escapedText)) { + (errors || (errors = [])).push(ts.createDiagnosticForNode(node, Messages.CannotExtractRangeContainingLabeledBreakOrContinueStatementWithTargetOutsideOfTheRange)); + } + } + else { + if (!(permittedJumps & (218 ? 1 : 2))) { + (errors || (errors = [])).push(ts.createDiagnosticForNode(node, Messages.CannotExtractRangeContainingConditionalBreakOrContinueStatements)); + } + } + break; + } + case 191: + rangeFacts |= RangeFacts.IsAsyncFunction; + break; + case 197: + rangeFacts |= RangeFacts.IsGenerator; + break; + case 219: + if (permittedJumps & 4) { + rangeFacts |= RangeFacts.HasReturn; + } + else { + (errors || (errors = [])).push(ts.createDiagnosticForNode(node, Messages.CannotExtractRangeContainingConditionalReturnStatement)); + } + break; + default: + ts.forEachChild(node, visit); + break; + } + permittedJumps = savedPermittedJumps; } } } - function copyComments(sourceNode, targetNode) { - ts.forEachLeadingCommentRange(sourceFile.text, sourceNode.pos, function (pos, end, kind, htnl) { - if (kind === 3) { - pos += 2; - end -= 2; + extractMethod_1.getRangeToExtract = getRangeToExtract; + function isValidExtractionTarget(node) { + return (node.kind === 228) || ts.isSourceFile(node) || ts.isModuleBlock(node) || ts.isClassLike(node); + } + function collectEnclosingScopes(range) { + var current = isReadonlyArray(range.range) ? ts.firstOrUndefined(range.range) : range.range; + if (range.facts & RangeFacts.UsesThis) { + var containingClass = ts.getContainingClass(current); + if (containingClass) { + return [containingClass]; + } + } + var start = current; + var scopes = undefined; + while (current) { + if (current !== start && isValidExtractionTarget(current)) { + (scopes = scopes || []).push(current); + } + if (current && current.parent && current.parent.kind === 146) { + current = ts.findAncestor(current, function (parent) { return ts.isFunctionLike(parent); }).parent; } else { - pos += 2; + current = current.parent; } - ts.addSyntheticLeadingComment(targetNode, kind, sourceFile.text.slice(pos, end), htnl); + } + return scopes; + } + extractMethod_1.collectEnclosingScopes = collectEnclosingScopes; + function getPossibleExtractions(targetRange, context, requestedChangesIndex) { + if (requestedChangesIndex === void 0) { requestedChangesIndex = undefined; } + var sourceFile = context.file; + if (targetRange === undefined) { + return undefined; + } + var scopes = collectEnclosingScopes(targetRange); + if (scopes === undefined) { + return undefined; + } + var enclosingTextRange = getEnclosingTextRange(targetRange, sourceFile); + var _a = collectReadsAndWrites(targetRange, scopes, enclosingTextRange, sourceFile, context.program.getTypeChecker()), target = _a.target, usagesPerScope = _a.usagesPerScope, errorsPerScope = _a.errorsPerScope; + context.cancellationToken.throwIfCancellationRequested(); + if (requestedChangesIndex !== undefined) { + if (errorsPerScope[requestedChangesIndex].length) { + return undefined; + } + return [extractFunctionInScope(target, scopes[requestedChangesIndex], usagesPerScope[requestedChangesIndex], targetRange, context)]; + } + else { + return scopes.map(function (scope, i) { + var errors = errorsPerScope[i]; + if (errors.length) { + return { + scope: scope, + scopeDescription: getDescriptionForScope(scope), + errors: errors + }; + } + return { scope: scope, scopeDescription: getDescriptionForScope(scope) }; + }); + } + } + extractMethod_1.getPossibleExtractions = getPossibleExtractions; + function getDescriptionForScope(scope) { + if (ts.isFunctionLike(scope)) { + switch (scope.kind) { + case 152: + return "constructor"; + case 186: + return scope.name + ? "function expression " + scope.name.getText() + : "anonymous function expression"; + case 228: + return "function " + scope.name.getText(); + case 187: + return "arrow function"; + case 151: + return "method " + scope.name.getText(); + case 153: + return "get " + scope.name.getText(); + case 154: + return "set " + scope.name.getText(); + } + } + else if (ts.isModuleBlock(scope)) { + return "namespace " + scope.parent.name.getText(); + } + else if (ts.isClassLike(scope)) { + return scope.kind === 229 + ? "class " + scope.name.text + : scope.name.text + ? "class expression " + scope.name.text + : "anonymous class expression"; + } + else if (ts.isSourceFile(scope)) { + return "file '" + scope.fileName + "'"; + } + else { + return "unknown"; + } + } + function getUniqueName(isNameOkay) { + var functionNameText = "newFunction"; + if (isNameOkay(functionNameText)) { + return functionNameText; + } + var i = 1; + while (!isNameOkay(functionNameText = "newFunction_" + i)) { + i++; + } + return functionNameText; + } + function extractFunctionInScope(node, scope, _a, range, context) { + var usagesInScope = _a.usages, substitutions = _a.substitutions; + var checker = context.program.getTypeChecker(); + var file = scope.getSourceFile(); + var functionNameText = getUniqueName(function (n) { return !file.identifiers.has(n); }); + var isJS = ts.isInJavaScriptFile(scope); + var functionName = ts.createIdentifier(functionNameText); + var functionReference = ts.createIdentifier(functionNameText); + var returnType = undefined; + var parameters = []; + var callArguments = []; + var writes; + usagesInScope.forEach(function (usage, name) { + var typeNode = undefined; + if (!isJS) { + var type = checker.getTypeOfSymbolAtLocation(usage.symbol, usage.node); + type = checker.getBaseTypeOfLiteralType(type); + typeNode = checker.typeToTypeNode(type, node, ts.NodeBuilderFlags.NoTruncation); + } + var paramDecl = ts.createParameter(undefined, undefined, undefined, name, undefined, typeNode); + parameters.push(paramDecl); + if (usage.usage === 2) { + (writes || (writes = [])).push(usage); + } + callArguments.push(ts.createIdentifier(name)); }); + if (ts.isExpression(node) && !isJS) { + var contextualType = checker.getContextualType(node); + returnType = checker.typeToTypeNode(contextualType); + } + var _b = transformFunctionBody(node), body = _b.body, returnValueProperty = _b.returnValueProperty; + var newFunction; + if (ts.isClassLike(scope)) { + var modifiers = isJS ? [] : [ts.createToken(112)]; + if (range.facts & RangeFacts.InStaticRegion) { + modifiers.push(ts.createToken(115)); + } + if (range.facts & RangeFacts.IsAsyncFunction) { + modifiers.push(ts.createToken(120)); + } + newFunction = ts.createMethod(undefined, modifiers, range.facts & RangeFacts.IsGenerator ? ts.createToken(39) : undefined, functionName, undefined, [], parameters, returnType, body); + } + else { + newFunction = ts.createFunctionDeclaration(undefined, range.facts & RangeFacts.IsAsyncFunction ? [ts.createToken(120)] : undefined, range.facts & RangeFacts.IsGenerator ? ts.createToken(39) : undefined, functionName, [], parameters, returnType, body); + } + var changeTracker = ts.textChanges.ChangeTracker.fromCodeFixContext(context); + changeTracker.insertNodeBefore(context.file, scope.getLastToken(), newFunction, { prefix: context.newLineCharacter, suffix: context.newLineCharacter }); + var newNodes = []; + var call = ts.createCall(ts.isClassLike(scope) ? ts.createPropertyAccess(range.facts & RangeFacts.InStaticRegion ? ts.createIdentifier(scope.name.getText()) : ts.createThis(), functionReference) : functionReference, undefined, callArguments); + if (range.facts & RangeFacts.IsGenerator) { + call = ts.createYield(ts.createToken(39), call); + } + if (range.facts & RangeFacts.IsAsyncFunction) { + call = ts.createAwait(call); + } + if (writes) { + if (returnValueProperty) { + newNodes.push(ts.createVariableStatement(undefined, [ts.createVariableDeclaration(returnValueProperty, ts.createKeywordTypeNode(119))])); + } + var assignments = getPropertyAssignmentsForWrites(writes); + if (returnValueProperty) { + assignments.unshift(ts.createShorthandPropertyAssignment(returnValueProperty)); + } + if (assignments.length === 1) { + if (returnValueProperty) { + newNodes.push(ts.createReturn(ts.createIdentifier(returnValueProperty))); + } + else { + newNodes.push(ts.createStatement(ts.createBinary(assignments[0].name, 58, call))); + } + } + else { + newNodes.push(ts.createStatement(ts.createBinary(ts.createObjectLiteral(assignments), 58, call))); + if (returnValueProperty) { + newNodes.push(ts.createReturn(ts.createIdentifier(returnValueProperty))); + } + } + } + else { + if (range.facts & RangeFacts.HasReturn) { + newNodes.push(ts.createReturn(call)); + } + else if (isReadonlyArray(range.range)) { + newNodes.push(ts.createStatement(call)); + } + else { + newNodes.push(call); + } + } + if (isReadonlyArray(range.range)) { + changeTracker.replaceNodesWithNodes(context.file, range.range, newNodes, { + nodeSeparator: context.newLineCharacter, + suffix: context.newLineCharacter + }); + } + else { + changeTracker.replaceNodeWithNodes(context.file, range.range, newNodes, { nodeSeparator: context.newLineCharacter }); + } + return { + scope: scope, + scopeDescription: getDescriptionForScope(scope), + changes: changeTracker.getChanges() + }; + function getPropertyAssignmentsForWrites(writes) { + return writes.map(function (w) { return ts.createShorthandPropertyAssignment(w.symbol.name); }); + } + function generateReturnValueProperty() { + return "__return"; + } + function transformFunctionBody(body) { + if (ts.isBlock(body) && !writes && substitutions.size === 0) { + return { body: ts.createBlock(body.statements, true), returnValueProperty: undefined }; + } + var returnValueProperty; + var statements = ts.createNodeArray(ts.isBlock(body) ? body.statements.slice(0) : [ts.isStatement(body) ? body : ts.createReturn(body)]); + if (writes || substitutions.size) { + var rewrittenStatements = ts.visitNodes(statements, visitor).slice(); + if (writes && !(range.facts & RangeFacts.HasReturn) && ts.isStatement(body)) { + var assignments = getPropertyAssignmentsForWrites(writes); + if (assignments.length === 1) { + rewrittenStatements.push(ts.createReturn(assignments[0].name)); + } + else { + rewrittenStatements.push(ts.createReturn(ts.createObjectLiteral(assignments))); + } + } + return { body: ts.createBlock(rewrittenStatements, true), returnValueProperty: returnValueProperty }; + } + else { + return { body: ts.createBlock(statements, true), returnValueProperty: undefined }; + } + function visitor(node) { + if (node.kind === 219 && writes) { + var assignments = getPropertyAssignmentsForWrites(writes); + if (node.expression) { + if (!returnValueProperty) { + returnValueProperty = generateReturnValueProperty(); + } + assignments.unshift(ts.createPropertyAssignment(returnValueProperty, ts.visitNode(node.expression, visitor))); + } + if (assignments.length === 1) { + return ts.createReturn(assignments[0].name); + } + else { + return ts.createReturn(ts.createObjectLiteral(assignments)); + } + } + else { + var substitution = substitutions.get(ts.getNodeId(node).toString()); + return substitution || ts.visitEachChild(node, visitor, ts.nullTransformationContext); + } + } + } } - function createClassFromVariableDeclaration(node) { - var initializer = node.initializer; - if (!initializer || initializer.kind !== 186) { + extractMethod_1.extractFunctionInScope = extractFunctionInScope; + function isReadonlyArray(v) { + return ts.isArray(v); + } + function getEnclosingTextRange(targetRange, sourceFile) { + return isReadonlyArray(targetRange.range) + ? { pos: targetRange.range[0].getStart(sourceFile), end: targetRange.range[targetRange.range.length - 1].getEnd() } + : targetRange.range; + } + var Usage; + (function (Usage) { + Usage[Usage["Read"] = 1] = "Read"; + Usage[Usage["Write"] = 2] = "Write"; + })(Usage || (Usage = {})); + function collectReadsAndWrites(targetRange, scopes, enclosingTextRange, sourceFile, checker) { + var usagesPerScope = []; + var substitutionsPerScope = []; + var errorsPerScope = []; + var visibleDeclarationsInExtractedRange = []; + for (var _i = 0, scopes_1 = scopes; _i < scopes_1.length; _i++) { + var _ = scopes_1[_i]; + usagesPerScope.push({ usages: ts.createMap(), substitutions: ts.createMap() }); + substitutionsPerScope.push(ts.createMap()); + errorsPerScope.push([]); + } + var seenUsages = ts.createMap(); + var target = isReadonlyArray(targetRange.range) ? ts.createBlock(targetRange.range) : targetRange.range; + var containingLexicalScopeOfExtraction = ts.isBlockScope(scopes[0], scopes[0].parent) ? scopes[0] : ts.getEnclosingBlockScopeContainer(scopes[0]); + collectUsages(target); + var _loop_8 = function (i) { + var hasWrite = false; + var readonlyClassPropertyWrite = undefined; + usagesPerScope[i].usages.forEach(function (value) { + if (value.usage === 2) { + hasWrite = true; + if (value.symbol.flags & 106500 && + value.symbol.valueDeclaration && + ts.hasModifier(value.symbol.valueDeclaration, 64)) { + readonlyClassPropertyWrite = value.symbol.valueDeclaration; + } + } + }); + if (hasWrite && !isReadonlyArray(targetRange.range) && ts.isExpression(targetRange.range)) { + errorsPerScope[i].push(ts.createDiagnosticForNode(targetRange.range, Messages.CannotCombineWritesAndReturns)); + } + else if (readonlyClassPropertyWrite && i > 0) { + errorsPerScope[i].push(ts.createDiagnosticForNode(readonlyClassPropertyWrite, Messages.CannotCombineWritesAndReturns)); + } + }; + for (var i = 0; i < scopes.length; i++) { + _loop_8(i); + } + if (visibleDeclarationsInExtractedRange.length) { + ts.forEachChild(containingLexicalScopeOfExtraction, checkForUsedDeclarations); + } + return { target: target, usagesPerScope: usagesPerScope, errorsPerScope: errorsPerScope }; + function collectUsages(node, valueUsage) { + if (valueUsage === void 0) { valueUsage = 1; } + if (ts.isDeclaration(node) && node.symbol) { + visibleDeclarationsInExtractedRange.push(node.symbol); + } + if (ts.isAssignmentExpression(node)) { + collectUsages(node.left, 2); + collectUsages(node.right); + } + else if (ts.isUnaryExpressionWithWrite(node)) { + collectUsages(node.operand, 2); + } + else if (ts.isPropertyAccessExpression(node) || ts.isElementAccessExpression(node)) { + ts.forEachChild(node, collectUsages); + } + else if (ts.isIdentifier(node)) { + if (!node.parent) { + return; + } + if (ts.isQualifiedName(node.parent) && node !== node.parent.left) { + return; + } + if (ts.isPropertyAccessExpression(node.parent) && node !== node.parent.expression) { + return; + } + recordUsage(node, valueUsage, ts.isPartOfTypeNode(node)); + } + else { + ts.forEachChild(node, collectUsages); + } + } + function recordUsage(n, usage, isTypeNode) { + var symbolId = recordUsagebySymbol(n, usage, isTypeNode); + if (symbolId) { + for (var i = 0; i < scopes.length; i++) { + var substitition = substitutionsPerScope[i].get(symbolId); + if (substitition) { + usagesPerScope[i].substitutions.set(ts.getNodeId(n).toString(), substitition); + } + } + } + } + function recordUsagebySymbol(identifier, usage, isTypeName) { + var symbol = checker.getSymbolAtLocation(identifier); + if (!symbol) { + return undefined; + } + var symbolId = ts.getSymbolId(symbol).toString(); + var lastUsage = seenUsages.get(symbolId); + if (lastUsage && lastUsage >= usage) { + return symbolId; + } + seenUsages.set(symbolId, usage); + if (lastUsage) { + for (var _i = 0, usagesPerScope_1 = usagesPerScope; _i < usagesPerScope_1.length; _i++) { + var perScope = usagesPerScope_1[_i]; + var prevEntry = perScope.usages.get(identifier.text); + if (prevEntry) { + perScope.usages.set(identifier.text, { usage: usage, symbol: symbol, node: identifier }); + } + } + return symbolId; + } + var declInFile = ts.find(symbol.getDeclarations(), function (d) { return d.getSourceFile() === sourceFile; }); + if (!declInFile) { + return undefined; + } + if (ts.rangeContainsRange(enclosingTextRange, declInFile)) { + return undefined; + } + if (targetRange.facts & RangeFacts.IsGenerator && usage === 2) { + for (var _a = 0, errorsPerScope_1 = errorsPerScope; _a < errorsPerScope_1.length; _a++) { + var errors = errorsPerScope_1[_a]; + errors.push(ts.createDiagnosticForNode(identifier, Messages.CannotExtractRangeThatContainsWritesToReferencesLocatedOutsideOfTheTargetRangeInGenerators)); + } + } + for (var i = 0; i < scopes.length; i++) { + var scope = scopes[i]; + var resolvedSymbol = checker.resolveName(symbol.name, scope, symbol.flags); + if (resolvedSymbol === symbol) { + continue; + } + if (!substitutionsPerScope[i].has(symbolId)) { + var substitution = tryReplaceWithQualifiedNameOrPropertyAccess(symbol.exportSymbol || symbol, scope, isTypeName); + if (substitution) { + substitutionsPerScope[i].set(symbolId, substitution); + } + else if (isTypeName) { + errorsPerScope[i].push(ts.createDiagnosticForNode(identifier, Messages.TypeWillNotBeVisibleInTheNewScope)); + } + else { + usagesPerScope[i].usages.set(identifier.text, { usage: usage, symbol: symbol, node: identifier }); + } + } + } + return symbolId; + } + function checkForUsedDeclarations(node) { + if (node === targetRange.range || (isReadonlyArray(targetRange.range) && targetRange.range.indexOf(node) >= 0)) { + return; + } + var sym = checker.getSymbolAtLocation(node); + if (sym && visibleDeclarationsInExtractedRange.some(function (d) { return d === sym; })) { + for (var _i = 0, errorsPerScope_2 = errorsPerScope; _i < errorsPerScope_2.length; _i++) { + var scope = errorsPerScope_2[_i]; + scope.push(ts.createDiagnosticForNode(node, Messages.CannotExtractExportedEntity)); + } + return true; + } + else { + ts.forEachChild(node, checkForUsedDeclarations); + } + } + function tryReplaceWithQualifiedNameOrPropertyAccess(symbol, scopeDecl, isTypeNode) { + if (!symbol) { + return undefined; + } + if (symbol.getDeclarations().some(function (d) { return d.parent === scopeDecl; })) { + return ts.createIdentifier(symbol.name); + } + var prefix = tryReplaceWithQualifiedNameOrPropertyAccess(symbol.parent, scopeDecl, isTypeNode); + if (prefix === undefined) { + return undefined; + } + return isTypeNode ? ts.createQualifiedName(prefix, ts.createIdentifier(symbol.name)) : ts.createPropertyAccess(prefix, symbol.name); + } + } + function getParentNodeInSpan(node, file, span) { + if (!node) return undefined; + while (node.parent) { + if (ts.isSourceFile(node.parent) || !spanContainsNode(span, node.parent, file)) { + return node; + } + node = node.parent; } - if (node.name.kind !== 71) { - return undefined; - } - var memberElements = createClassElementsFromSymbol(initializer.symbol); - if (initializer.body) { - memberElements.unshift(ts.createConstructor(undefined, undefined, initializer.parameters, initializer.body)); - } - var cls = ts.createClassDeclaration(undefined, undefined, node.name, undefined, undefined, memberElements); - return cls; } - function createClassFromFunctionDeclaration(node) { - var memberElements = createClassElementsFromSymbol(ctorSymbol); - if (node.body) { - memberElements.unshift(ts.createConstructor(undefined, undefined, node.parameters, node.body)); - } - var cls = ts.createClassDeclaration(undefined, undefined, node.name, undefined, undefined, memberElements); - return cls; + function spanContainsNode(span, node, file) { + return ts.textSpanContainsPosition(span, node.getStart(file)) && + node.getEnd() <= ts.textSpanEnd(span); } - } + function isExtractableExpression(node) { + switch (node.parent.kind) { + case 264: + return false; + } + switch (node.kind) { + case 9: + return node.parent.kind !== 238 && + node.parent.kind !== 242; + case 198: + case 174: + case 176: + return false; + case 71: + return node.parent.kind !== 176 && + node.parent.kind !== 242 && + node.parent.kind !== 246; + } + return true; + } + function isBlockLike(node) { + switch (node.kind) { + case 207: + case 265: + case 234: + case 257: + return true; + default: + return false; + } + } + })(extractMethod = refactor.extractMethod || (refactor.extractMethod = {})); })(refactor = ts.refactor || (ts.refactor = {})); })(ts || (ts = {})); var ts; @@ -74186,12 +75614,14 @@ var ts; ts.scanner.setTextPos(pos); while (pos < end) { var token = ts.scanner.scan(); - ts.Debug.assert(token !== 1); var textPos = ts.scanner.getTextPos(); if (textPos <= end) { nodes.push(createNode(token, pos, textPos, this)); } pos = textPos; + if (token === 1) { + break; + } } return pos; }; @@ -74986,8 +76416,8 @@ var ts; if (program) { var oldSourceFiles = program.getSourceFiles(); var oldSettingsKey = documentRegistry.getKeyForCompilationSettings(oldSettings); - for (var _i = 0, oldSourceFiles_1 = oldSourceFiles; _i < oldSourceFiles_1.length; _i++) { - var oldSourceFile = oldSourceFiles_1[_i]; + for (var _i = 0, oldSourceFiles_2 = oldSourceFiles; _i < oldSourceFiles_2.length; _i++) { + var oldSourceFile = oldSourceFiles_2[_i]; if (!newProgram.getSourceFile(oldSourceFile.fileName) || shouldCreateNewSourceFiles) { documentRegistry.releaseDocumentWithKey(oldSourceFile.path, oldSettingsKey); } @@ -75009,7 +76439,7 @@ var ts; if (!shouldCreateNewSourceFiles) { var oldSourceFile = program && program.getSourceFileByPath(path); if (oldSourceFile) { - ts.Debug.assert(hostFileInformation.scriptKind === oldSourceFile.scriptKind, "Registered script kind (" + oldSourceFile.scriptKind + ") should match new script kind (" + hostFileInformation.scriptKind + ") for file: " + path); + ts.Debug.assertEqual(hostFileInformation.scriptKind, oldSourceFile.scriptKind, "Registered script kind should match new script kind.", path); return documentRegistry.updateDocumentWithKey(fileName, path, newSettings, documentRegistryBucketKey, hostFileInformation.scriptSnapshot, hostFileInformation.version, hostFileInformation.scriptKind); } } @@ -75372,17 +76802,19 @@ var ts; function getFormattingEditsAfterKeystroke(fileName, position, key, options) { var sourceFile = syntaxTreeCache.getCurrentSourceFile(fileName); var settings = toEditorSettings(options); - if (key === "{") { - return ts.formatting.formatOnOpeningCurly(position, sourceFile, getRuleProvider(settings), settings); - } - else if (key === "}") { - return ts.formatting.formatOnClosingCurly(position, sourceFile, getRuleProvider(settings), settings); - } - else if (key === ";") { - return ts.formatting.formatOnSemicolon(position, sourceFile, getRuleProvider(settings), settings); - } - else if (key === "\n") { - return ts.formatting.formatOnEnter(position, sourceFile, getRuleProvider(settings), settings); + if (!ts.isInComment(sourceFile, position)) { + if (key === "{") { + return ts.formatting.formatOnOpeningCurly(position, sourceFile, getRuleProvider(settings), settings); + } + else if (key === "}") { + return ts.formatting.formatOnClosingCurly(position, sourceFile, getRuleProvider(settings), settings); + } + else if (key === ";") { + return ts.formatting.formatOnSemicolon(position, sourceFile, getRuleProvider(settings), settings); + } + else if (key === "\n") { + return ts.formatting.formatOnEnter(position, sourceFile, getRuleProvider(settings), settings); + } } return []; } @@ -75422,6 +76854,11 @@ var ts; } return true; } + function getSpanOfEnclosingComment(fileName, position, onlyMultiLine) { + var sourceFile = syntaxTreeCache.getCurrentSourceFile(fileName); + var range = ts.formatting.getRangeOfEnclosingComment(sourceFile, position, onlyMultiLine); + return range && ts.createTextSpanFromRange(range); + } function getTodoComments(fileName, descriptors) { synchronizeHostData(); var sourceFile = getValidSourceFile(fileName); @@ -75545,6 +76982,7 @@ var ts; getFormattingEditsAfterKeystroke: getFormattingEditsAfterKeystroke, getDocCommentTemplateAtPosition: getDocCommentTemplateAtPosition, isValidBraceCompletionAtPosition: isValidBraceCompletionAtPosition, + getSpanOfEnclosingComment: getSpanOfEnclosingComment, getCodeFixesAtPosition: getCodeFixesAtPosition, getEmitOutput: getEmitOutput, getNonBoundSourceFile: getNonBoundSourceFile, @@ -75615,12 +77053,16 @@ var ts; function getPropertySymbolsFromContextualType(typeChecker, node) { var objectLiteral = node.parent; var contextualType = typeChecker.getContextualType(objectLiteral); - var name = ts.unescapeLeadingUnderscores(ts.getTextOfPropertyName(node.name)); - if (name && contextualType) { + return getPropertySymbolsFromType(contextualType, node.name); + } + ts.getPropertySymbolsFromContextualType = getPropertySymbolsFromContextualType; + function getPropertySymbolsFromType(type, propName) { + var name = ts.unescapeLeadingUnderscores(ts.getTextOfPropertyName(propName)); + if (name && type) { var result_10 = []; - var symbol = contextualType.getProperty(name); - if (contextualType.flags & 65536) { - ts.forEach(contextualType.types, function (t) { + var symbol = type.getProperty(name); + if (type.flags & 65536) { + ts.forEach(type.types, function (t) { var symbol = t.getProperty(name); if (symbol) { result_10.push(symbol); @@ -75635,7 +77077,7 @@ var ts; } return undefined; } - ts.getPropertySymbolsFromContextualType = getPropertySymbolsFromContextualType; + ts.getPropertySymbolsFromType = getPropertySymbolsFromType; function isArgumentOfElementAccessExpression(node) { return node && node.parent && @@ -75666,6 +77108,7 @@ var ts; Arguments.LogFile = "--logFile"; Arguments.EnableTelemetry = "--enableTelemetry"; Arguments.TypingSafeListLocation = "--typingSafeListLocation"; + Arguments.TypesMapLocation = "--typesMapLocation"; Arguments.NpmLocation = "--npmLocation"; })(Arguments = server.Arguments || (server.Arguments = {})); function hasArgument(argumentName) { @@ -75713,7 +77156,7 @@ var ts; function createInstallTypingsRequest(project, typeAcquisition, unresolvedImports, cachePath) { return { projectName: project.getProjectName(), - fileNames: project.getFileNames(true, true), + fileNames: project.getFileNames(true, true).concat(project.getExcludedFiles()), compilerOptions: project.getCompilerOptions(), typeAcquisition: typeAcquisition, unresolvedImports: unresolvedImports, @@ -75813,42 +77256,6 @@ var ts; return []; } server.createSortedArray = createSortedArray; - function toSortedArray(arr, comparer) { - arr.sort(comparer); - return arr; - } - server.toSortedArray = toSortedArray; - function enumerateInsertsAndDeletes(newItems, oldItems, inserted, deleted, compare) { - compare = compare || ts.compareValues; - var newIndex = 0; - var oldIndex = 0; - var newLen = newItems.length; - var oldLen = oldItems.length; - while (newIndex < newLen && oldIndex < oldLen) { - var newItem = newItems[newIndex]; - var oldItem = oldItems[oldIndex]; - var compareResult = compare(newItem, oldItem); - if (compareResult === -1) { - inserted(newItem); - newIndex++; - } - else if (compareResult === 1) { - deleted(oldItem); - oldIndex++; - } - else { - newIndex++; - oldIndex++; - } - } - while (newIndex < newLen) { - inserted(newItems[newIndex++]); - } - while (oldIndex < oldLen) { - deleted(oldItems[oldIndex++]); - } - } - server.enumerateInsertsAndDeletes = enumerateInsertsAndDeletes; var ThrottledOperations = (function () { function ThrottledOperations(host) { this.host = host; @@ -75893,6 +77300,11 @@ var ts; return GcTimer; }()); server.GcTimer = GcTimer; + })(server = ts.server || (ts.server = {})); +})(ts || (ts = {})); +(function (ts) { + var server; + (function (server) { function insertSorted(array, insert, compare) { if (array.length === 0) { array.push(insert); @@ -75918,6 +77330,51 @@ var ts; } } server.removeSorted = removeSorted; + function toSortedArray(arr, comparer) { + arr.sort(comparer); + return arr; + } + server.toSortedArray = toSortedArray; + function toDeduplicatedSortedArray(arr) { + arr.sort(); + ts.filterMutate(arr, isNonDuplicateInSortedArray); + return arr; + } + server.toDeduplicatedSortedArray = toDeduplicatedSortedArray; + function isNonDuplicateInSortedArray(value, index, array) { + return index === 0 || value !== array[index - 1]; + } + function enumerateInsertsAndDeletes(newItems, oldItems, inserted, deleted, compare) { + compare = compare || ts.compareValues; + var newIndex = 0; + var oldIndex = 0; + var newLen = newItems.length; + var oldLen = oldItems.length; + while (newIndex < newLen && oldIndex < oldLen) { + var newItem = newItems[newIndex]; + var oldItem = oldItems[oldIndex]; + var compareResult = compare(newItem, oldItem); + if (compareResult === -1) { + inserted(newItem); + newIndex++; + } + else if (compareResult === 1) { + deleted(oldItem); + oldIndex++; + } + else { + newIndex++; + oldIndex++; + } + } + while (newIndex < newLen) { + inserted(newItems[newIndex++]); + } + while (oldIndex < oldLen) { + deleted(oldItems[oldIndex++]); + } + } + server.enumerateInsertsAndDeletes = enumerateInsertsAndDeletes; })(server = ts.server || (ts.server = {})); })(ts || (ts = {})); var ts; @@ -75931,6 +77388,7 @@ var ts; CommandTypes["Brace"] = "brace"; CommandTypes["BraceFull"] = "brace-full"; CommandTypes["BraceCompletion"] = "braceCompletion"; + CommandTypes["GetSpanOfEnclosingComment"] = "getSpanOfEnclosingComment"; CommandTypes["Change"] = "change"; CommandTypes["Close"] = "close"; CommandTypes["Completions"] = "completions"; @@ -76022,6 +77480,7 @@ var ts; ModuleKind["System"] = "System"; ModuleKind["ES6"] = "ES6"; ModuleKind["ES2015"] = "ES2015"; + ModuleKind["ESNext"] = "ESNext"; })(ModuleKind = protocol.ModuleKind || (protocol.ModuleKind = {})); var ModuleResolutionKind; (function (ModuleResolutionKind) { @@ -76039,6 +77498,9 @@ var ts; ScriptTarget["ES5"] = "ES5"; ScriptTarget["ES6"] = "ES6"; ScriptTarget["ES2015"] = "ES2015"; + ScriptTarget["ES2016"] = "ES2016"; + ScriptTarget["ES2017"] = "ES2017"; + ScriptTarget["ESNext"] = "ESNext"; })(ScriptTarget = protocol.ScriptTarget || (protocol.ScriptTarget = {})); })(protocol = server.protocol || (server.protocol = {})); })(server = ts.server || (ts.server = {})); @@ -76130,20 +77592,16 @@ var ts; var MultistepOperation = (function () { function MultistepOperation(operationHost) { this.operationHost = operationHost; - this.completed = true; } MultistepOperation.prototype.startNew = function (action) { this.complete(); this.requestId = this.operationHost.getCurrentRequestId(); - this.completed = false; this.executeAction(action); }; MultistepOperation.prototype.complete = function () { - if (!this.completed) { - if (this.requestId) { - this.operationHost.sendRequestCompletedEvent(this.requestId); - } - this.completed = true; + if (this.requestId !== undefined) { + this.operationHost.sendRequestCompletedEvent(this.requestId); + this.requestId = undefined; } this.setTimerHandle(undefined); this.setImmediateId(undefined); @@ -76308,6 +77766,9 @@ var ts; _a[server.CommandNames.DocCommentTemplate] = function (request) { return _this.requiredResponse(_this.getDocCommentTemplate(request.arguments)); }, + _a[server.CommandNames.GetSpanOfEnclosingComment] = function (request) { + return _this.requiredResponse(_this.getSpanOfEnclosingComment(request.arguments)); + }, _a[server.CommandNames.Format] = function (request) { return _this.requiredResponse(_this.getFormattingEditsForRange(request.arguments)); }, @@ -76479,6 +77940,7 @@ var ts; logger: this.logger, cancellationToken: this.cancellationToken, useSingleInferredProject: opts.useSingleInferredProject, + useInferredProjectPerProjectRoot: opts.useInferredProjectPerProjectRoot, typingsInstaller: this.typingsInstaller, throttleWaitMilliseconds: throttleWaitMilliseconds, eventHandler: this.eventHandler, @@ -76505,7 +77967,7 @@ var ts; case server.ContextEvent: var _a = event.data, project_1 = _a.project, fileName_2 = _a.fileName; this.projectService.logger.info("got context event, updating diagnostics for " + fileName_2); - this.errorCheck.startNew(function (next) { return _this.updateErrorCheck(next, [{ fileName: fileName_2, project: project_1 }], _this.changeSeq, function (n) { return n === _this.changeSeq; }, 100); }); + this.errorCheck.startNew(function (next) { return _this.updateErrorCheck(next, [{ fileName: fileName_2, project: project_1 }], 100); }); break; case server.ConfigFileDiagEvent: var _b = event.data, triggerFile = _b.triggerFile, configFileName = _b.configFileName, diagnostics = _b.diagnostics; @@ -76613,26 +78075,24 @@ var ts; this.logError(err, "syntactic check"); } }; - Session.prototype.updateProjectStructure = function (seq, matchSeq, ms) { + Session.prototype.updateProjectStructure = function () { var _this = this; - if (ms === void 0) { ms = 1500; } + var ms = 1500; + var seq = this.changeSeq; this.host.setTimeout(function () { - if (matchSeq(seq)) { + if (_this.changeSeq === seq) { _this.projectService.refreshInferredProjects(); } }, ms); }; - Session.prototype.updateErrorCheck = function (next, checkList, seq, matchSeq, ms, followMs, requireOpen) { + Session.prototype.updateErrorCheck = function (next, checkList, ms, requireOpen) { var _this = this; - if (ms === void 0) { ms = 1500; } - if (followMs === void 0) { followMs = 200; } if (requireOpen === void 0) { requireOpen = true; } - if (followMs > ms) { - followMs = ms; - } + var seq = this.changeSeq; + var followMs = Math.min(ms, 200); var index = 0; var checkOne = function () { - if (matchSeq(seq)) { + if (_this.changeSeq === seq) { var checkSpec_1 = checkList[index]; index++; if (checkSpec_1.project.containsFile(checkSpec_1.fileName, requireOpen)) { @@ -76646,7 +78106,7 @@ var ts; } } }; - if ((checkList.length > index) && (matchSeq(seq))) { + if (checkList.length > index && this.changeSeq === seq) { next.delay(ms, checkOne); } }; @@ -76724,7 +78184,7 @@ var ts; Session.prototype.getDiagnosticsWorker = function (args, isSemantic, selector, includeLinePosition) { var _a = this.getFileAndProject(args), project = _a.project, file = _a.file; if (isSemantic && isDeclarationFileInJSOnlyNonConfiguredProject(project, file)) { - return []; + return server.emptyArray; } var scriptInfo = project.getScriptInfoForNormalizedPath(file); var diagnostics = selector(project, file); @@ -76738,7 +78198,7 @@ var ts; var position = this.getPosition(args, scriptInfo); var definitions = project.getLanguageService().getDefinitionAtPosition(file, position); if (!definitions) { - return undefined; + return server.emptyArray; } if (simplifiedResult) { return definitions.map(function (def) { @@ -76760,7 +78220,7 @@ var ts; var position = this.getPosition(args, scriptInfo); var definitions = project.getLanguageService().getTypeDefinitionAtPosition(file, position); if (!definitions) { - return undefined; + return server.emptyArray; } return definitions.map(function (def) { var defScriptInfo = project.getScriptInfo(def.fileName); @@ -76776,7 +78236,7 @@ var ts; var position = this.getPosition(args, project.getScriptInfoForNormalizedPath(file)); var implementations = project.getLanguageService().getImplementationAtPosition(file, position); if (!implementations) { - return []; + return server.emptyArray; } if (simplifiedResult) { return implementations.map(function (_a) { @@ -76799,7 +78259,7 @@ var ts; var position = this.getPosition(args, scriptInfo); var occurrences = project.getLanguageService().getOccurrencesAtPosition(file, position); if (!occurrences) { - return undefined; + return server.emptyArray; } return occurrences.map(function (occurrence) { var fileName = occurrence.fileName, isWriteAccess = occurrence.isWriteAccess, textSpan = occurrence.textSpan, isInString = occurrence.isInString; @@ -76821,7 +78281,7 @@ var ts; Session.prototype.getSyntacticDiagnosticsSync = function (args) { var configFile = this.getConfigFileAndProject(args).configFile; if (configFile) { - return []; + return server.emptyArray; } return this.getDiagnosticsWorker(args, false, function (project, file) { return project.getLanguageService().getSyntacticDiagnostics(file); }, args.includeLinePosition); }; @@ -76838,7 +78298,7 @@ var ts; var position = this.getPosition(args, scriptInfo); var documentHighlights = project.getLanguageService().getDocumentHighlights(file, position, args.filesToSearch); if (!documentHighlights) { - return undefined; + return server.emptyArray; } if (simplifiedResult) { return documentHighlights.map(convertToDocumentHighlightsItem); @@ -76862,7 +78322,7 @@ var ts; } }; Session.prototype.setCompilerOptionsForInferredProjects = function (args) { - this.projectService.setCompilerOptionsForInferredProjects(args.options); + this.projectService.setCompilerOptionsForInferredProjects(args.options, args.projectRootPath); }; Session.prototype.getProjectInfo = function (args) { return this.getProjectInfoWorker(args.file, args.projectFileName, args.needFileNameList, false); @@ -76924,13 +78384,13 @@ var ts; if (!renameInfo.canRename) { return { info: renameInfo, - locs: [] + locs: server.emptyArray }; } var fileSpans = server.combineProjectOutput(projects, function (project) { var renameLocations = project.getLanguageService().findRenameLocations(file, position, args.findInStrings, args.findInComments); if (!renameLocations) { - return []; + return server.emptyArray; } return renameLocations.map(function (location) { var locationScriptInfo = project.getScriptInfo(location.fileName); @@ -77011,7 +78471,7 @@ var ts; var refs = server.combineProjectOutput(projects, function (project) { var references = project.getLanguageService().getReferencesAtPosition(file, position); if (!references) { - return []; + return server.emptyArray; } return references.map(function (ref) { var refScriptInfo = project.getScriptInfo(ref.fileName); @@ -77052,7 +78512,7 @@ var ts; if (this.eventHandler) { this.eventHandler({ eventName: "configFileDiag", - data: { triggerFile: fileName, configFileName: configFileName, diagnostics: configFileErrors || [] } + data: { triggerFile: fileName, configFileName: configFileName, diagnostics: configFileErrors || server.emptyArray } }); } }; @@ -77089,6 +78549,13 @@ var ts; var position = this.getPosition(args, scriptInfo); return project.getLanguageService(false).getDocCommentTemplateAtPosition(file, position); }; + Session.prototype.getSpanOfEnclosingComment = function (args) { + var _a = this.getFileAndProjectWithoutRefreshingInferredProjects(args), file = _a.file, project = _a.project; + var scriptInfo = project.getScriptInfoForNormalizedPath(file); + var onlyMultiLine = args.onlyMultiLine; + var position = this.getPosition(args, scriptInfo); + return project.getLanguageService(false).getSpanOfEnclosingComment(file, position, onlyMultiLine); + }; Session.prototype.getIndentation = function (args) { var _a = this.getFileAndProjectWithoutRefreshingInferredProjects(args), file = _a.file, project = _a.project; var position = this.getPosition(args, project.getScriptInfoForNormalizedPath(file)); @@ -77212,15 +78679,12 @@ var ts; var scriptInfo = project.getScriptInfoForNormalizedPath(file); var position = this.getPosition(args, scriptInfo); var completions = project.getLanguageService().getCompletionsAtPosition(file, position); - if (!completions) { - return undefined; - } if (simplifiedResult) { - return ts.mapDefined(completions.entries, function (entry) { + return ts.mapDefined(completions && completions.entries, function (entry) { if (completions.isMemberCompletion || (entry.name.toLowerCase().indexOf(prefix.toLowerCase()) === 0)) { - var name = entry.name, kind = entry.kind, kindModifiers = entry.kindModifiers, sortText = entry.sortText, replacementSpan = entry.replacementSpan; + var name_68 = entry.name, kind = entry.kind, kindModifiers = entry.kindModifiers, sortText = entry.sortText, replacementSpan = entry.replacementSpan; var convertedSpan = replacementSpan ? _this.decorateSpan(replacementSpan, scriptInfo) : undefined; - return { name: name, kind: kind, kindModifiers: kindModifiers, sortText: sortText, replacementSpan: convertedSpan }; + return { name: name_68, kind: kind, kindModifiers: kindModifiers, sortText: sortText, replacementSpan: convertedSpan }; } }).sort(function (a, b) { return ts.compareStrings(a.name, b.name); }); } @@ -77240,7 +78704,7 @@ var ts; var info = this.projectService.getScriptInfo(args.file); var result = []; if (!info) { - return []; + return server.emptyArray; } var projectsToSearch = args.projectFileName ? [this.projectService.findProject(args.projectFileName)] : info.containingProjects; for (var _i = 0, projectsToSearch_1 = projectsToSearch; _i < projectsToSearch_1.length; _i++) { @@ -77300,11 +78764,10 @@ var ts; return project && { fileName: fileName, project: project }; }); if (checkList.length > 0) { - this.updateErrorCheck(next, checkList, this.changeSeq, function (n) { return n === _this.changeSeq; }, delay); + this.updateErrorCheck(next, checkList, delay); } }; Session.prototype.change = function (args) { - var _this = this; var _a = this.getFileAndProject(args, false), file = _a.file, project = _a.project; if (project) { var scriptInfo = project.getScriptInfoForNormalizedPath(file); @@ -77314,7 +78777,7 @@ var ts; scriptInfo.editContent(start, end, args.insertString); this.changeSeq++; } - this.updateProjectStructure(this.changeSeq, function (n) { return n === _this.changeSeq; }); + this.updateProjectStructure(); } }; Session.prototype.reload = function (args, reqSeq) { @@ -77393,7 +78856,7 @@ var ts; return server.combineProjectOutput(projects, function (project) { var navItems = project.getLanguageService().getNavigateToItems(args.searchValue, args.maxResultCount, fileName, project.isNonTsProject()); if (!navItems) { - return []; + return server.emptyArray; } return navItems.map(function (navItem) { var scriptInfo = project.getScriptInfo(navItem.fileName); @@ -77492,13 +78955,13 @@ var ts; } if (simplifiedResult) { var file_2 = result.renameFilename; - var location = void 0; + var location_4; if (file_2 !== undefined && result.renameLocation !== undefined) { var renameScriptInfo = project.getScriptInfoForNormalizedPath(server.toNormalizedPath(file_2)); - location = renameScriptInfo.positionToLineOffset(result.renameLocation); + location_4 = renameScriptInfo.positionToLineOffset(result.renameLocation); } return { - renameLocation: location, + renameLocation: location_4, renameFilename: file_2, edits: result.edits.map(function (change) { return _this.mapTextChangesToCodeEdits(project, change); }) }; @@ -77583,7 +79046,6 @@ var ts; : spans; }; Session.prototype.getDiagnosticsForProject = function (next, delay, fileName) { - var _this = this; var _a = this.getProjectInfoWorker(fileName, undefined, true, true), fileNames = _a.fileNames, languageServiceDisabled = _a.languageServiceDisabled; if (languageServiceDisabled) { return; @@ -77618,7 +79080,7 @@ var ts; fileNamesInProject = highPriorityFiles.concat(mediumPriorityFiles).concat(lowPriorityFiles).concat(veryLowPriorityFiles); if (fileNamesInProject.length > 0) { var checkList = fileNamesInProject.map(function (fileName) { return ({ fileName: fileName, project: project }); }); - this.updateErrorCheck(next, checkList, this.changeSeq, function (n) { return n === _this.changeSeq; }, delay, 200, false); + this.updateErrorCheck(next, checkList, delay, false); } }; Session.prototype.getCanonicalFileName = function (fileName) { @@ -77725,13 +79187,13 @@ var ts; CharRangeSection[CharRangeSection["Mid"] = 3] = "Mid"; CharRangeSection[CharRangeSection["End"] = 4] = "End"; CharRangeSection[CharRangeSection["PostEnd"] = 5] = "PostEnd"; - })(CharRangeSection = server.CharRangeSection || (server.CharRangeSection = {})); + })(CharRangeSection || (CharRangeSection = {})); var EditWalker = (function () { function EditWalker() { this.goSubtree = true; this.lineIndex = new LineIndex(); this.endBranch = []; - this.state = CharRangeSection.Entire; + this.state = 2; this.initialText = ""; this.trailingText = ""; this.lineIndex.root = new LineNode(); @@ -77820,14 +79282,14 @@ var ts; }; EditWalker.prototype.post = function (_relativeStart, _relativeLength, lineCollection) { if (lineCollection === this.lineCollectionAtBranch) { - this.state = CharRangeSection.End; + this.state = 4; } this.stack.pop(); }; EditWalker.prototype.pre = function (_relativeStart, _relativeLength, lineCollection, _parent, nodeType) { var currentNode = this.stack[this.stack.length - 1]; - if ((this.state === CharRangeSection.Entire) && (nodeType === CharRangeSection.Start)) { - this.state = CharRangeSection.Start; + if ((this.state === 2) && (nodeType === 1)) { + this.state = 1; this.branchNode = currentNode; this.lineCollectionAtBranch = lineCollection; } @@ -77840,14 +79302,14 @@ var ts; return new LineNode(); } switch (nodeType) { - case CharRangeSection.PreStart: + case 0: this.goSubtree = false; - if (this.state !== CharRangeSection.End) { + if (this.state !== 4) { currentNode.add(lineCollection); } break; - case CharRangeSection.Start: - if (this.state === CharRangeSection.End) { + case 1: + if (this.state === 4) { this.goSubtree = false; } else { @@ -77856,8 +79318,8 @@ var ts; this.startPath.push(child); } break; - case CharRangeSection.Entire: - if (this.state !== CharRangeSection.End) { + case 2: + if (this.state !== 4) { child = fresh(lineCollection); currentNode.add(child); this.startPath.push(child); @@ -77870,11 +79332,11 @@ var ts; } } break; - case CharRangeSection.Mid: + case 3: this.goSubtree = false; break; - case CharRangeSection.End: - if (this.state !== CharRangeSection.End) { + case 4: + if (this.state !== 4) { this.goSubtree = false; } else { @@ -77885,9 +79347,9 @@ var ts; } } break; - case CharRangeSection.PostEnd: + case 5: this.goSubtree = false; - if (this.state !== CharRangeSection.Start) { + if (this.state !== 1) { currentNode.add(lineCollection); } break; @@ -77897,10 +79359,10 @@ var ts; } }; EditWalker.prototype.leaf = function (relativeStart, relativeLength, ll) { - if (this.state === CharRangeSection.Start) { + if (this.state === 1) { this.initialText = ll.text.substring(0, relativeStart); } - else if (this.state === CharRangeSection.Entire) { + else if (this.state === 2) { this.initialText = ll.text.substring(0, relativeStart); this.trailingText = ll.text.substring(relativeStart + relativeLength); } @@ -77921,7 +79383,6 @@ var ts; }; return TextChange; }()); - server.TextChange = TextChange; var ScriptVersionCache = (function () { function ScriptVersionCache() { this.changes = []; @@ -77946,15 +79407,6 @@ var ts; this.getSnapshot(); } }; - ScriptVersionCache.prototype.latest = function () { - return this.versions[this.currentVersionToIndex()]; - }; - ScriptVersionCache.prototype.latestVersion = function () { - if (this.changes.length > 0) { - this.getSnapshot(); - } - return this.currentVersion; - }; ScriptVersionCache.prototype.reload = function (script) { this.currentVersion++; this.changes = []; @@ -77967,7 +79419,8 @@ var ts; snap.index.load(lm.lines); this.minVersion = this.currentVersion; }; - ScriptVersionCache.prototype.getSnapshot = function () { + ScriptVersionCache.prototype.getSnapshot = function () { return this._getSnapshot(); }; + ScriptVersionCache.prototype._getSnapshot = function () { var snap = this.versions[this.currentVersionToIndex()]; if (this.changes.length > 0) { var snapIndex = snap.index; @@ -77985,6 +79438,24 @@ var ts; } return snap; }; + ScriptVersionCache.prototype.getSnapshotVersion = function () { + return this._getSnapshot().version; + }; + ScriptVersionCache.prototype.getLineInfo = function (line) { + return this._getSnapshot().index.lineNumberToInfo(line); + }; + ScriptVersionCache.prototype.lineOffsetToPosition = function (line, column) { + return this._getSnapshot().index.absolutePositionOfStartOfLine(line) + (column - 1); + }; + ScriptVersionCache.prototype.positionToLineOffset = function (position) { + return this._getSnapshot().index.positionToLineOffset(position); + }; + ScriptVersionCache.prototype.lineToTextSpan = function (line) { + var index = this._getSnapshot().index; + var _a = index.lineNumberToInfo(line + 1), lineText = _a.lineText, absolutePosition = _a.absolutePosition; + var len = lineText !== undefined ? lineText.length : index.absolutePositionOfStartOfLine(line + 2) - absolutePosition; + return ts.createTextSpan(absolutePosition, len); + }; ScriptVersionCache.prototype.getTextChangesBetweenVersions = function (oldVersion, newVersion) { if (oldVersion < newVersion) { if (oldVersion >= this.minVersion) { @@ -78046,7 +79517,6 @@ var ts; }; return LineIndexSnapshot; }()); - server.LineIndexSnapshot = LineIndexSnapshot; var LineIndex = (function () { function LineIndex() { this.checkEdits = false; @@ -78245,18 +79715,18 @@ var ts; var childCharCount = this.children[childIndex].charCount(); var adjustedStart = rangeStart; while (adjustedStart >= childCharCount) { - this.skipChild(adjustedStart, rangeLength, childIndex, walkFns, CharRangeSection.PreStart); + this.skipChild(adjustedStart, rangeLength, childIndex, walkFns, 0); adjustedStart -= childCharCount; childIndex++; childCharCount = this.children[childIndex].charCount(); } if ((adjustedStart + rangeLength) <= childCharCount) { - if (this.execWalk(adjustedStart, rangeLength, walkFns, childIndex, CharRangeSection.Entire)) { + if (this.execWalk(adjustedStart, rangeLength, walkFns, childIndex, 2)) { return; } } else { - if (this.execWalk(adjustedStart, childCharCount - adjustedStart, walkFns, childIndex, CharRangeSection.Start)) { + if (this.execWalk(adjustedStart, childCharCount - adjustedStart, walkFns, childIndex, 1)) { return; } var adjustedLength = rangeLength - (childCharCount - adjustedStart); @@ -78264,7 +79734,7 @@ var ts; var child = this.children[childIndex]; childCharCount = child.charCount(); while (adjustedLength > childCharCount) { - if (this.execWalk(0, childCharCount, walkFns, childIndex, CharRangeSection.Mid)) { + if (this.execWalk(0, childCharCount, walkFns, childIndex, 3)) { return; } adjustedLength -= childCharCount; @@ -78272,7 +79742,7 @@ var ts; childCharCount = this.children[childIndex].charCount(); } if (adjustedLength > 0) { - if (this.execWalk(0, adjustedLength, walkFns, childIndex, CharRangeSection.End)) { + if (this.execWalk(0, adjustedLength, walkFns, childIndex, 4)) { return; } } @@ -78281,82 +79751,46 @@ var ts; var clen = this.children.length; if (childIndex < (clen - 1)) { for (var ej = childIndex + 1; ej < clen; ej++) { - this.skipChild(0, 0, ej, walkFns, CharRangeSection.PostEnd); + this.skipChild(0, 0, ej, walkFns, 5); } } } }; LineNode.prototype.charOffsetToLineInfo = function (lineNumberAccumulator, relativePosition) { - var childInfo = this.childFromCharOffset(lineNumberAccumulator, relativePosition); - if (!childInfo.child) { - return { - oneBasedLine: lineNumberAccumulator, - zeroBasedColumn: relativePosition, - lineText: undefined, - }; + if (this.children.length === 0) { + return { oneBasedLine: lineNumberAccumulator, zeroBasedColumn: relativePosition, lineText: undefined }; } - else if (childInfo.childIndex < this.children.length) { - if (childInfo.child.isLeaf()) { - return { - oneBasedLine: childInfo.lineNumberAccumulator, - zeroBasedColumn: childInfo.relativePosition, - lineText: childInfo.child.text, - }; - } - else { - var lineNode = (childInfo.child); - return lineNode.charOffsetToLineInfo(childInfo.lineNumberAccumulator, childInfo.relativePosition); - } - } - else { - var lineInfo = this.lineNumberToInfo(this.lineCount(), 0); - return { oneBasedLine: this.lineCount(), zeroBasedColumn: lineInfo.leaf.charCount(), lineText: undefined }; - } - }; - LineNode.prototype.lineNumberToInfo = function (relativeOneBasedLine, positionAccumulator) { - var childInfo = this.childFromLineNumber(relativeOneBasedLine, positionAccumulator); - if (!childInfo.child) { - return { position: positionAccumulator, leaf: undefined }; - } - else if (childInfo.child.isLeaf()) { - return { position: childInfo.positionAccumulator, leaf: childInfo.child }; - } - else { - var lineNode = (childInfo.child); - return lineNode.lineNumberToInfo(childInfo.relativeOneBasedLine, childInfo.positionAccumulator); - } - }; - LineNode.prototype.childFromLineNumber = function (relativeOneBasedLine, positionAccumulator) { - var child; - var i; - for (i = 0; i < this.children.length; i++) { - child = this.children[i]; - var childLineCount = child.lineCount(); - if (childLineCount >= relativeOneBasedLine) { - break; - } - else { - relativeOneBasedLine -= childLineCount; - positionAccumulator += child.charCount(); - } - } - return { child: child, relativeOneBasedLine: relativeOneBasedLine, positionAccumulator: positionAccumulator }; - }; - LineNode.prototype.childFromCharOffset = function (lineNumberAccumulator, relativePosition) { - var child; - var i; - var len; - for (i = 0, len = this.children.length; i < len; i++) { - child = this.children[i]; + for (var _i = 0, _a = this.children; _i < _a.length; _i++) { + var child = _a[_i]; if (child.charCount() > relativePosition) { - break; + if (child.isLeaf()) { + return { oneBasedLine: lineNumberAccumulator, zeroBasedColumn: relativePosition, lineText: child.text }; + } + else { + return child.charOffsetToLineInfo(lineNumberAccumulator, relativePosition); + } } else { relativePosition -= child.charCount(); lineNumberAccumulator += child.lineCount(); } } - return { child: child, childIndex: i, relativePosition: relativePosition, lineNumberAccumulator: lineNumberAccumulator }; + var leaf = this.lineNumberToInfo(this.lineCount(), 0).leaf; + return { oneBasedLine: this.lineCount(), zeroBasedColumn: leaf.charCount(), lineText: undefined }; + }; + LineNode.prototype.lineNumberToInfo = function (relativeOneBasedLine, positionAccumulator) { + for (var _i = 0, _a = this.children; _i < _a.length; _i++) { + var child = _a[_i]; + var childLineCount = child.lineCount(); + if (childLineCount >= relativeOneBasedLine) { + return child.isLeaf() ? { position: positionAccumulator, leaf: child } : child.lineNumberToInfo(relativeOneBasedLine, positionAccumulator); + } + else { + relativeOneBasedLine -= childLineCount; + positionAccumulator += child.charCount(); + } + } + return { position: positionAccumulator, leaf: undefined }; }; LineNode.prototype.splitAfter = function (childIndex) { var splitNode; @@ -78453,7 +79887,6 @@ var ts; }; return LineNode; }()); - server.LineNode = LineNode; var LineLeaf = (function () { function LineLeaf(text) { this.text = text; @@ -78472,7 +79905,6 @@ var ts; }; return LineLeaf; }()); - server.LineLeaf = LineLeaf; })(server = ts.server || (ts.server = {})); })(ts || (ts = {})); var ts; @@ -78488,7 +79920,7 @@ var ts; } TextStorage.prototype.getVersion = function () { return this.svc - ? "SVC-" + this.svcVersion + "-" + this.svc.getSnapshot().version + ? "SVC-" + this.svcVersion + "-" + this.svc.getSnapshotVersion() : "Text-" + this.textVersion; }; TextStorage.prototype.hasScriptVersionCache = function () { @@ -78526,7 +79958,7 @@ var ts; : ts.ScriptSnapshot.fromString(this.getOrLoadText()); }; TextStorage.prototype.getLineInfo = function (line) { - return this.switchToScriptVersionCache().getSnapshot().index.lineNumberToInfo(line); + return this.switchToScriptVersionCache().getLineInfo(line); }; TextStorage.prototype.lineToTextSpan = function (line) { if (!this.svc) { @@ -78535,23 +79967,20 @@ var ts; var end = line + 1 < lineMap.length ? lineMap[line + 1] : this.text.length; return ts.createTextSpanFromBounds(start, end); } - var index = this.svc.getSnapshot().index; - var _a = index.lineNumberToInfo(line + 1), lineText = _a.lineText, absolutePosition = _a.absolutePosition; - var len = lineText !== undefined ? lineText.length : index.absolutePositionOfStartOfLine(line + 2) - absolutePosition; - return ts.createTextSpan(absolutePosition, len); + return this.svc.lineToTextSpan(line); }; TextStorage.prototype.lineOffsetToPosition = function (line, offset) { if (!this.svc) { return ts.computePositionOfLineAndCharacter(this.getLineMap(), line - 1, offset - 1, this.text); } - return this.svc.getSnapshot().index.absolutePositionOfStartOfLine(line) + (offset - 1); + return this.svc.lineOffsetToPosition(line, offset); }; TextStorage.prototype.positionToLineOffset = function (position) { if (!this.svc) { var _a = ts.computeLineAndCharacterOfPosition(this.getLineMap(), position), line = _a.line, character = _a.character; return { line: line + 1, offset: character + 1 }; } - return this.svc.getSnapshot().index.positionToLineOffset(position); + return this.svc.positionToLineOffset(position); }; TextStorage.prototype.getFileText = function (tempFileName) { return this.host.readFile(tempFileName || this.fileName) || ""; @@ -78817,16 +80246,16 @@ var ts; var compilerOptions = this.getCompilationSettings(); var lastDeletedFileName = this.project.projectService.lastDeletedFile && this.project.projectService.lastDeletedFile.fileName; for (var _i = 0, names_2 = names; _i < names_2.length; _i++) { - var name = names_2[_i]; - var resolution = newResolutions.get(name); + var name_69 = names_2[_i]; + var resolution = newResolutions.get(name_69); if (!resolution) { - var existingResolution = currentResolutionsInFile && currentResolutionsInFile.get(name); + var existingResolution = currentResolutionsInFile && currentResolutionsInFile.get(name_69); if (moduleResolutionIsValid(existingResolution)) { resolution = existingResolution; } else { - resolution = loader(name, containingFile, compilerOptions, this); - newResolutions.set(name, resolution); + resolution = loader(name_69, containingFile, compilerOptions, this); + newResolutions.set(name_69, resolution); } if (logChanges && this.filesWithChangedSetOfUnresolvedImports && !resolutionIsEqualTo(existingResolution, resolution)) { this.filesWithChangedSetOfUnresolvedImports.push(path); @@ -79460,7 +80889,8 @@ var ts; log("Loading " + moduleName + " from " + initialDir + " (resolved to " + resolvedPath + ")"); var result = host.require(resolvedPath, moduleName); if (result.error) { - log("Failed to load module: " + JSON.stringify(result.error)); + var err = result.error.stack || result.error.message || JSON.stringify(result.error); + log("Failed to load module '" + moduleName + "': " + err); return undefined; } return result.module; @@ -79590,7 +81020,7 @@ var ts; return ts.map(this.program.getSourceFiles(), function (sourceFile) { var scriptInfo = _this.projectService.getScriptInfoForPath(sourceFile.path); if (!scriptInfo) { - ts.Debug.assert(false, "scriptInfo for a file '" + sourceFile.fileName + "' is missing."); + ts.Debug.fail("scriptInfo for a file '" + sourceFile.fileName + "' is missing."); } return scriptInfo; }); @@ -79601,6 +81031,9 @@ var ts; } return this.getLanguageService().getEmitOutput(info.fileName, emitOnlyDtsFiles); }; + Project.prototype.getExcludedFiles = function () { + return server.emptyArray; + }; Project.prototype.getFileNames = function (excludeFilesFromExternalLibraries, excludeConfigFiles) { if (!this.program) { return []; @@ -79752,7 +81185,7 @@ var ts; var sourceFile = _b[_a]; this.extractUnresolvedImportsFromSourceFile(sourceFile, result); } - this.lastCachedUnresolvedImportsList = server.toSortedArray(result); + this.lastCachedUnresolvedImportsList = server.toDeduplicatedSortedArray(result); } unresolvedImports = this.lastCachedUnresolvedImportsList; var cachedTypings = this.projectService.typingsCache.getTypingsForProject(this, unresolvedImports, hasChanges); @@ -79804,7 +81237,7 @@ var ts; fileWatcher.close(); } }); - var _loop_8 = function (missingFilePath) { + var _loop_9 = function (missingFilePath) { if (!this_1.missingFilesMap.has(missingFilePath)) { var fileWatcher_1 = this_1.projectService.host.watchFile(missingFilePath, function (_filename, eventKind) { if (eventKind === ts.FileWatcherEventKind.Created && _this.missingFilesMap.has(missingFilePath)) { @@ -79820,7 +81253,7 @@ var ts; var this_1 = this; for (var _b = 0, missingFilePaths_1 = missingFilePaths; _b < missingFilePaths_1.length; _b++) { var missingFilePath = missingFilePaths_1[_b]; - _loop_8(missingFilePath); + _loop_9(missingFilePath); } } var oldExternalFiles = this.externalFiles || server.emptyArray; @@ -79984,10 +81417,11 @@ var ts; server.Project = Project; var InferredProject = (function (_super) { __extends(InferredProject, _super); - function InferredProject(projectService, documentRegistry, compilerOptions) { + function InferredProject(projectService, documentRegistry, compilerOptions, projectRootPath) { var _this = _super.call(this, InferredProject.newName(), ProjectKind.Inferred, projectService, documentRegistry, undefined, true, compilerOptions, false) || this; _this._isJsInferredProject = false; _this.directoriesWatchedForTsconfig = []; + _this.projectRootPath = projectRootPath; return _this; } InferredProject.prototype.toggleJsInferredProject = function (isJsInferredProject) { @@ -80091,7 +81525,7 @@ var ts; } } if (this.projectService.globalPlugins) { - var _loop_9 = function (globalPluginName) { + var _loop_10 = function (globalPluginName) { if (options.plugins && options.plugins.some(function (p) { return p.name === globalPluginName; })) return "continue"; this_2.enablePlugin({ name: globalPluginName, global: true }, searchPaths); @@ -80099,7 +81533,7 @@ var ts; var this_2 = this; for (var _b = 0, _c = this.projectService.globalPlugins; _b < _c.length; _b++) { var globalPluginName = _c[_b]; - _loop_9(globalPluginName); + _loop_10(globalPluginName); } } }; @@ -80222,10 +81656,12 @@ var ts; } this.typeRootsWatchers = undefined; } - this.directoriesWatchedForWildcards.forEach(function (watcher) { - watcher.close(); - }); - this.directoriesWatchedForWildcards = undefined; + if (this.directoriesWatchedForWildcards) { + this.directoriesWatchedForWildcards.forEach(function (watcher) { + watcher.close(); + }); + this.directoriesWatchedForWildcards = undefined; + } this.stopWatchingDirectory(); }; ConfiguredProject.prototype.addOpenRef = function () { @@ -80248,8 +81684,12 @@ var ts; _this.externalProjectName = externalProjectName; _this.compileOnSaveEnabled = compileOnSaveEnabled; _this.projectFilePath = projectFilePath; + _this.excludedFiles = []; return _this; } + ExternalProject.prototype.getExcludedFiles = function () { + return this.excludedFiles; + }; ExternalProject.prototype.getProjectRootPath = function () { if (this.projectFilePath) { return ts.getDirectoryPath(this.projectFilePath); @@ -80455,6 +81895,7 @@ var ts; this.inferredProjects = []; this.configuredProjects = []; this.openFiles = []; + this.compilerOptionsForInferredProjectsPerProjectRoot = ts.createMap(); this.projectToSizeMap = ts.createMap(); this.safelist = defaultTypeSafeList; this.seenProjects = ts.createMap(); @@ -80462,16 +81903,21 @@ var ts; this.logger = opts.logger; this.cancellationToken = opts.cancellationToken; this.useSingleInferredProject = opts.useSingleInferredProject; + this.useInferredProjectPerProjectRoot = opts.useInferredProjectPerProjectRoot; this.typingsInstaller = opts.typingsInstaller || server.nullTypingsInstaller; this.throttleWaitMilliseconds = opts.throttleWaitMilliseconds; this.eventHandler = opts.eventHandler; this.globalPlugins = opts.globalPlugins || server.emptyArray; this.pluginProbeLocations = opts.pluginProbeLocations || server.emptyArray; this.allowLocalPluginLoads = !!opts.allowLocalPluginLoads; + this.typesMapLocation = (opts.typesMapLocation === undefined) ? ts.combinePaths(this.host.getExecutingFilePath(), "../typesMap.json") : opts.typesMapLocation; ts.Debug.assert(!!this.host.createHash, "'ServerHost.createHash' is required for ProjectService"); this.toCanonicalFileName = ts.createGetCanonicalFileName(this.host.useCaseSensitiveFileNames); this.directoryWatchers = new DirectoryWatchers(this); this.throttledOperations = new server.ThrottledOperations(this.host); + if (opts.typesMapLocation) { + this.loadTypesMap(); + } this.typingsInstaller.attach(this); this.typingsCache = new server.TypingsCache(this.typingsInstaller); this.hostConfiguration = { @@ -80494,10 +81940,30 @@ var ts; if (!this.eventHandler) { return; } - this.eventHandler({ + var event = { eventName: server.ProjectLanguageServiceStateEvent, data: { project: project, languageServiceEnabled: languageServiceEnabled } - }); + }; + this.eventHandler(event); + }; + ProjectService.prototype.loadTypesMap = function () { + try { + var fileContent = this.host.readFile(this.typesMapLocation); + if (fileContent === undefined) { + this.logger.info("Provided types map file \"" + this.typesMapLocation + "\" doesn't exist"); + return; + } + var raw = JSON.parse(fileContent); + for (var _i = 0, _a = Object.keys(raw.typesMap); _i < _a.length; _i++) { + var k = _a[_i]; + raw.typesMap[k].match = new RegExp(raw.typesMap[k].match, "i"); + } + this.safelist = raw.typesMap; + } + catch (e) { + this.logger.info("Error loading types map: " + e); + this.safelist = defaultTypeSafeList; + } }; ProjectService.prototype.updateTypingsForProject = function (response) { var project = this.findProject(response.projectName); @@ -80514,16 +81980,28 @@ var ts; } project.updateGraph(); }; - ProjectService.prototype.setCompilerOptionsForInferredProjects = function (projectCompilerOptions) { - this.compilerOptionsForInferredProjects = convertCompilerOptions(projectCompilerOptions); - this.compilerOptionsForInferredProjects.allowNonTsExtensions = true; - this.compileOnSaveForInferredProjects = projectCompilerOptions.compileOnSave; - for (var _i = 0, _a = this.inferredProjects; _i < _a.length; _i++) { - var proj = _a[_i]; - proj.setCompilerOptions(this.compilerOptionsForInferredProjects); - proj.compileOnSaveEnabled = projectCompilerOptions.compileOnSave; + ProjectService.prototype.setCompilerOptionsForInferredProjects = function (projectCompilerOptions, projectRootPath) { + ts.Debug.assert(projectRootPath === undefined || this.useInferredProjectPerProjectRoot, "Setting compiler options per project root path is only supported when useInferredProjectPerProjectRoot is enabled"); + var compilerOptions = convertCompilerOptions(projectCompilerOptions); + compilerOptions.allowNonTsExtensions = true; + if (projectRootPath) { + this.compilerOptionsForInferredProjectsPerProjectRoot.set(projectRootPath, compilerOptions); } - this.updateProjectGraphs(this.inferredProjects); + else { + this.compilerOptionsForInferredProjects = compilerOptions; + } + var updatedProjects = []; + for (var _i = 0, _a = this.inferredProjects; _i < _a.length; _i++) { + var project = _a[_i]; + if (projectRootPath ? + project.projectRootPath === projectRootPath : + !project.projectRootPath || !this.compilerOptionsForInferredProjectsPerProjectRoot.has(project.projectRootPath)) { + project.setCompilerOptions(compilerOptions); + project.compileOnSaveEnabled = compilerOptions.compileOnSave; + updatedProjects.push(project); + } + } + this.updateProjectGraphs(updatedProjects); }; ProjectService.prototype.stopWatchingDirectory = function (directory) { this.directoryWatchers.stopWatchingDirectory(directory); @@ -80630,10 +82108,11 @@ var ts; } for (var _i = 0, _a = this.openFiles; _i < _a.length; _i++) { var openFile = _a[_i]; - this.eventHandler({ + var event_1 = { eventName: server.ContextEvent, data: { project: openFile.getDefaultProject(), fileName: openFile.fileName } - }); + }; + this.eventHandler(event_1); } } this.printProjects(); @@ -80705,7 +82184,7 @@ var ts; break; } }; - ProjectService.prototype.assignScriptInfoToInferredProjectIfNecessary = function (info, addToListOfOpenFiles) { + ProjectService.prototype.assignScriptInfoToInferredProjectIfNecessary = function (info, addToListOfOpenFiles, projectRootPath) { var externalProject = this.findContainingExternalProject(info.fileName); if (externalProject) { if (addToListOfOpenFiles) { @@ -80730,19 +82209,19 @@ var ts; return; } if (info.containingProjects.length === 0) { - var inferredProject = this.createInferredProjectWithRootFileIfNecessary(info); - if (!this.useSingleInferredProject) { + var inferredProject = this.createInferredProjectWithRootFileIfNecessary(info, projectRootPath); + if (!this.useSingleInferredProject && !inferredProject.projectRootPath) { for (var _b = 0, _c = this.openFiles; _b < _c.length; _b++) { var f = _c[_b]; if (f.containingProjects.length === 0 || !inferredProject.containsScriptInfo(f)) { continue; } for (var _d = 0, _e = f.containingProjects; _d < _e.length; _d++) { - var fContainingProject = _e[_d]; - if (fContainingProject.projectKind === server.ProjectKind.Inferred && - fContainingProject.isRoot(f) && - fContainingProject !== inferredProject) { - this.removeProject(fContainingProject); + var containingProject = _e[_d]; + if (containingProject.projectKind === server.ProjectKind.Inferred && + containingProject !== inferredProject && + containingProject.isRoot(f)) { + this.removeProject(containingProject); f.attachToProject(inferredProject); } } @@ -80853,31 +82332,32 @@ var ts; return undefined; }; ProjectService.prototype.printProjects = function () { + var _this = this; if (!this.logger.hasLevel(server.LogLevel.verbose)) { return; } this.logger.startGroup(); var counter = 0; - counter = printProjects(this.logger, this.externalProjects, counter); - counter = printProjects(this.logger, this.configuredProjects, counter); - counter = printProjects(this.logger, this.inferredProjects, counter); + var printProjects = function (projects, counter) { + for (var _i = 0, projects_4 = projects; _i < projects_4.length; _i++) { + var project = projects_4[_i]; + project.updateGraph(); + _this.logger.info("Project '" + project.getProjectName() + "' (" + server.ProjectKind[project.projectKind] + ") " + counter); + _this.logger.info(project.filesToString()); + _this.logger.info("-----------------------------------------------"); + counter++; + } + return counter; + }; + counter = printProjects(this.externalProjects, counter); + counter = printProjects(this.configuredProjects, counter); + printProjects(this.inferredProjects, counter); this.logger.info("Open files: "); for (var _i = 0, _a = this.openFiles; _i < _a.length; _i++) { var rootFile = _a[_i]; this.logger.info("\t" + rootFile.fileName); } this.logger.endGroup(); - function printProjects(logger, projects, counter) { - for (var _i = 0, projects_4 = projects; _i < projects_4.length; _i++) { - var project = projects_4[_i]; - project.updateGraph(); - logger.info("Project '" + project.getProjectName() + "' (" + server.ProjectKind[project.projectKind] + ") " + counter); - logger.info(project.filesToString()); - logger.info("-----------------------------------------------"); - counter++; - } - return counter; - } }; ProjectService.prototype.findConfiguredProjectByProjectName = function (configFileName) { configFileName = server.asNormalizedPath(this.toCanonicalFileName(configFileName)); @@ -80998,10 +82478,11 @@ var ts; if (!this.eventHandler) { return; } - this.eventHandler({ + var event = { eventName: server.ConfigFileDiagEvent, - data: { configFileName: configFileName, diagnostics: diagnostics || [], triggerFile: triggerFile } - }); + data: { configFileName: configFileName, diagnostics: diagnostics || server.emptyArray, triggerFile: triggerFile } + }; + this.eventHandler(event); }; ProjectService.prototype.createAndAddConfiguredProject = function (configFileName, projectOptions, configFileErrors, clientFileName) { var _this = this; @@ -81150,18 +82631,60 @@ var ts; } return configFileErrors; }; - ProjectService.prototype.createInferredProjectWithRootFileIfNecessary = function (root) { + ProjectService.prototype.getOrCreateInferredProjectForProjectRootPathIfEnabled = function (root, projectRootPath) { + if (!this.useInferredProjectPerProjectRoot) { + return undefined; + } + if (projectRootPath) { + for (var _i = 0, _a = this.inferredProjects; _i < _a.length; _i++) { + var project = _a[_i]; + if (project.projectRootPath === projectRootPath) { + return project; + } + } + return this.createInferredProject(false, projectRootPath); + } + var bestMatch; + for (var _b = 0, _c = this.inferredProjects; _b < _c.length; _b++) { + var project = _c[_b]; + if (!project.projectRootPath) + continue; + if (!ts.containsPath(project.projectRootPath, root.path, this.host.getCurrentDirectory(), !this.host.useCaseSensitiveFileNames)) + continue; + if (bestMatch && bestMatch.projectRootPath.length > project.projectRootPath.length) + continue; + bestMatch = project; + } + return bestMatch; + }; + ProjectService.prototype.getOrCreateSingleInferredProjectIfEnabled = function () { + if (!this.useSingleInferredProject) { + return undefined; + } + if (this.inferredProjects.length > 0 && this.inferredProjects[0].projectRootPath === undefined) { + return this.inferredProjects[0]; + } + return this.createInferredProject(true); + }; + ProjectService.prototype.createInferredProject = function (isSingleInferredProject, projectRootPath) { + var compilerOptions = projectRootPath && this.compilerOptionsForInferredProjectsPerProjectRoot.get(projectRootPath) || this.compilerOptionsForInferredProjects; + var project = new server.InferredProject(this, this.documentRegistry, compilerOptions, projectRootPath); + if (isSingleInferredProject) { + this.inferredProjects.unshift(project); + } + else { + this.inferredProjects.push(project); + } + return project; + }; + ProjectService.prototype.createInferredProjectWithRootFileIfNecessary = function (root, projectRootPath) { var _this = this; - var useExistingProject = this.useSingleInferredProject && this.inferredProjects.length; - var project = useExistingProject - ? this.inferredProjects[0] - : new server.InferredProject(this, this.documentRegistry, this.compilerOptionsForInferredProjects); + var project = this.getOrCreateInferredProjectForProjectRootPathIfEnabled(root, projectRootPath) || + this.getOrCreateSingleInferredProjectIfEnabled() || + this.createInferredProject(); project.addRoot(root); this.directoryWatchers.startWatchingContainingDirectoriesForFile(root.fileName, project, function (fileName) { return _this.onConfigFileAddedForInferredProject(fileName); }); project.updateGraph(); - if (!useExistingProject) { - this.inferredProjects.push(project); - } return project; }; ProjectService.prototype.getOrCreateScriptInfo = function (uncheckedFileName, openedByClient, fileContent, scriptKind) { @@ -81294,7 +82817,7 @@ var ts; project.markAsDirty(); } var info = this.getOrCreateScriptInfoForNormalizedPath(fileName, true, fileContent, scriptKind, hasMixedContent); - this.assignScriptInfoToInferredProjectIfNecessary(info, true); + this.assignScriptInfoToInferredProjectIfNecessary(info, true, projectRootPath); this.deleteOrphanScriptInfoNotInAnyProject(); this.printProjects(); return { configFileName: configFileName, configFileErrors: configFileErrors }; @@ -81308,13 +82831,13 @@ var ts; this.printProjects(); }; ProjectService.prototype.collectChanges = function (lastKnownProjectVersions, currentProjects, result) { - var _loop_10 = function (proj) { + var _loop_11 = function (proj) { var knownProject = ts.forEach(lastKnownProjectVersions, function (p) { return p.projectName === proj.getProjectName() && p; }); result.push(proj.getChangesSinceVersion(knownProject && knownProject.version)); }; for (var _i = 0, currentProjects_1 = currentProjects; _i < currentProjects_1.length; _i++) { var proj = currentProjects_1[_i]; - _loop_10(proj); + _loop_11(proj); } }; ProjectService.prototype.synchronizeProjectList = function (knownProjects) { @@ -81419,26 +82942,19 @@ var ts; ProjectService.prototype.resetSafeList = function () { this.safelist = defaultTypeSafeList; }; - ProjectService.prototype.loadSafeList = function (fileName) { - var raw = JSON.parse(this.host.readFile(fileName, "utf-8")); - for (var _i = 0, _a = Object.keys(raw); _i < _a.length; _i++) { - var k = _a[_i]; - raw[k].match = new RegExp(raw[k].match, "i"); - } - this.safelist = raw; - }; ProjectService.prototype.applySafeList = function (proj) { var _this = this; var rootFiles = proj.rootFiles, typeAcquisition = proj.typeAcquisition; var types = (typeAcquisition && typeAcquisition.include) || []; var excludeRules = []; var normalizedNames = rootFiles.map(function (f) { return ts.normalizeSlashes(f.fileName); }); - var _loop_11 = function (name) { - var rule = this_3.safelist[name]; + var excludedFiles = []; + var _loop_12 = function (name_70) { + var rule = this_3.safelist[name_70]; for (var _i = 0, normalizedNames_1 = normalizedNames; _i < normalizedNames_1.length; _i++) { var root = normalizedNames_1[_i]; if (rule.match.test(root)) { - this_3.logger.info("Excluding files based on rule " + name); + this_3.logger.info("Excluding files based on rule " + name_70); if (rule.types) { for (var _a = 0, _b = rule.types; _a < _b.length; _a++) { var type = _b[_a]; @@ -81448,7 +82964,7 @@ var ts; } } if (rule.exclude) { - var _loop_12 = function (exclude) { + var _loop_13 = function (exclude) { var processedRule = root.replace(rule.match, function () { var groups = []; for (var _i = 0; _i < arguments.length; _i++) { @@ -81457,7 +82973,7 @@ var ts; return exclude.map(function (groupNumberOrString) { if (typeof groupNumberOrString === "number") { if (typeof groups[groupNumberOrString] !== "string") { - _this.logger.info("Incorrect RegExp specification in safelist rule " + name + " - not enough groups"); + _this.logger.info("Incorrect RegExp specification in safelist rule " + name_70 + " - not enough groups"); return "\\*"; } return ProjectService.escapeFilenameForRegex(groups[groupNumberOrString]); @@ -81471,7 +82987,7 @@ var ts; }; for (var _c = 0, _d = rule.exclude; _c < _d.length; _c++) { var exclude = _d[_c]; - _loop_12(exclude); + _loop_13(exclude); } } else { @@ -81489,11 +83005,24 @@ var ts; }; var this_3 = this; for (var _i = 0, _a = Object.keys(this.safelist); _i < _a.length; _i++) { - var name = _a[_i]; - _loop_11(name); + var name_70 = _a[_i]; + _loop_12(name_70); } var excludeRegexes = excludeRules.map(function (e) { return new RegExp(e, "i"); }); - proj.rootFiles = proj.rootFiles.filter(function (_file, index) { return !excludeRegexes.some(function (re) { return re.test(normalizedNames[index]); }); }); + var filesToKeep = []; + var _loop_14 = function (i) { + if (excludeRegexes.some(function (re) { return re.test(normalizedNames[i]); })) { + excludedFiles.push(normalizedNames[i]); + } + else { + filesToKeep.push(proj.rootFiles[i]); + } + }; + for (var i = 0; i < proj.rootFiles.length; i++) { + _loop_14(i); + } + proj.rootFiles = filesToKeep; + return excludedFiles; }; ProjectService.prototype.openExternalProject = function (proj, suppressRefreshOfInferredProjects) { if (suppressRefreshOfInferredProjects === void 0) { suppressRefreshOfInferredProjects = false; } @@ -81501,7 +83030,7 @@ var ts; var typeAcquisition = ts.convertEnableAutoDiscoveryToEnable(proj.typingOptions); proj.typeAcquisition = typeAcquisition; } - this.applySafeList(proj); + var excludedFiles = this.applySafeList(proj); var tsConfigFiles; var rootFiles = []; for (var _i = 0, _a = proj.rootFiles; _i < _a.length; _i++) { @@ -81522,6 +83051,7 @@ var ts; var externalProject = this.findExternalProjectByProjectName(proj.projectFileName); var exisingConfigFiles; if (externalProject) { + externalProject.excludedFiles = excludedFiles; if (!tsConfigFiles) { var compilerOptions = convertCompilerOptions(proj.options); if (this.exceededTotalSizeLimitForNonTsFiles(proj.projectFileName, compilerOptions, proj.rootFiles, externalFilePropertyReader)) { @@ -81580,7 +83110,8 @@ var ts; } else { this.externalProjectToConfiguredProjectMap.delete(proj.projectFileName); - this.createAndAddExternalProject(proj.projectFileName, rootFiles, proj.options, proj.typeAcquisition); + var newProj = this.createAndAddExternalProject(proj.projectFileName, rootFiles, proj.options, proj.typeAcquisition); + newProj.excludedFiles = excludedFiles; } if (!suppressRefreshOfInferredProjects) { this.refreshInferredProjects(); @@ -81953,6 +83484,10 @@ var ts; var _this = this; return this.forwardJSONCall("isValidBraceCompletionAtPosition('" + fileName + "', " + position + ", " + openingBrace + ")", function () { return _this.languageService.isValidBraceCompletionAtPosition(fileName, position, openingBrace); }); }; + LanguageServiceShimObject.prototype.getSpanOfEnclosingComment = function (fileName, position, onlyMultiLine) { + var _this = this; + return this.forwardJSONCall("getSpanOfEnclosingComment('" + fileName + "', " + position + ")", function () { return _this.languageService.getSpanOfEnclosingComment(fileName, position, onlyMultiLine); }); + }; LanguageServiceShimObject.prototype.getIndentationAtPosition = function (fileName, position, options) { var _this = this; return this.forwardJSONCall("getIndentationAtPosition('" + fileName + "', " + position + ")", function () { @@ -82248,4 +83783,6 @@ var TypeScript; Services.TypeScriptServicesFactory = ts.TypeScriptServicesFactory; })(Services = TypeScript.Services || (TypeScript.Services = {})); })(TypeScript || (TypeScript = {})); -var toolsVersion = "2.5"; +var toolsVersion = "2.6"; + +//# sourceMappingURL=tsserverlibrary.js.map diff --git a/lib/typescript.d.ts b/lib/typescript.d.ts index 1ca5c4d7736..dd56f51d4ac 100644 --- a/lib/typescript.d.ts +++ b/lib/typescript.d.ts @@ -1210,7 +1210,7 @@ declare namespace ts { interface CatchClause extends Node { kind: SyntaxKind.CatchClause; parent?: TryStatement; - variableDeclaration: VariableDeclaration; + variableDeclaration?: VariableDeclaration; block: Block; } type DeclarationWithTypeParameters = SignatureDeclaration | ClassLikeDeclaration | InterfaceDeclaration | TypeAliasDeclaration | JSDocTemplateTag; @@ -1496,38 +1496,39 @@ declare namespace ts { interface FlowLock { locked?: boolean; } - interface AfterFinallyFlow extends FlowNode, FlowLock { + interface AfterFinallyFlow extends FlowNodeBase, FlowLock { antecedent: FlowNode; } - interface PreFinallyFlow extends FlowNode { + interface PreFinallyFlow extends FlowNodeBase { antecedent: FlowNode; lock: FlowLock; } - interface FlowNode { + type FlowNode = AfterFinallyFlow | PreFinallyFlow | FlowStart | FlowLabel | FlowAssignment | FlowCondition | FlowSwitchClause | FlowArrayMutation; + interface FlowNodeBase { flags: FlowFlags; id?: number; } - interface FlowStart extends FlowNode { + interface FlowStart extends FlowNodeBase { container?: FunctionExpression | ArrowFunction | MethodDeclaration; } - interface FlowLabel extends FlowNode { + interface FlowLabel extends FlowNodeBase { antecedents: FlowNode[]; } - interface FlowAssignment extends FlowNode { + interface FlowAssignment extends FlowNodeBase { node: Expression | VariableDeclaration | BindingElement; antecedent: FlowNode; } - interface FlowCondition extends FlowNode { + interface FlowCondition extends FlowNodeBase { expression: Expression; antecedent: FlowNode; } - interface FlowSwitchClause extends FlowNode { + interface FlowSwitchClause extends FlowNodeBase { switchStatement: SwitchStatement; clauseStart: number; clauseEnd: number; antecedent: FlowNode; } - interface FlowArrayMutation extends FlowNode { + interface FlowArrayMutation extends FlowNodeBase { node: CallExpression | BinaryExpression; antecedent: FlowNode; } @@ -1696,6 +1697,15 @@ declare namespace ts { getSymbolsOfParameterPropertyDeclaration(parameter: ParameterDeclaration, parameterName: string): Symbol[]; getShorthandAssignmentValueSymbol(location: Node): Symbol | undefined; getExportSpecifierLocalTargetSymbol(location: ExportSpecifier): Symbol | undefined; + /** + * If a symbol is a local symbol with an associated exported symbol, returns the exported symbol. + * Otherwise returns its input. + * For example, at `export type T = number;`: + * - `getSymbolAtLocation` at the location `T` will return the exported symbol for `T`. + * - But the result of `getSymbolsInScope` will contain the *local* symbol for `T`, not the exported symbol. + * - Calling `getExportSymbolOfSymbol` on that local symbol will return the exported symbol. + */ + getExportSymbolOfSymbol(symbol: Symbol): Symbol; getPropertySymbolOfDestructuringAssignment(location: Identifier): Symbol | undefined; getTypeAtLocation(node: Node): Type; getTypeFromTypeNode(node: TypeNode): Type; @@ -1790,11 +1800,11 @@ declare namespace ts { UseFullyQualifiedType = 256, InFirstTypeArgument = 512, InTypeAlias = 1024, - UseTypeAliasValue = 2048, SuppressAnyReturnType = 4096, AddUndefined = 8192, WriteClassExpressionAsTypeLiteral = 16384, InArrayType = 32768, + UseAliasDefinedOutsideCurrentScope = 65536, } enum SymbolFormatFlags { None = 0, @@ -2056,6 +2066,7 @@ declare namespace ts { interface TypeVariable extends Type { } interface TypeParameter extends TypeVariable { + /** Retrieve using getConstraintFromTypeParameter */ constraint: Type; default?: Type; } @@ -2103,6 +2114,21 @@ declare namespace ts { NoDefault = 2, AnyDefault = 4, } + /** + * Ternary values are defined such that + * x & y is False if either x or y is False. + * x & y is Maybe if either x or y is Maybe, but neither x or y is False. + * x & y is True if both x and y are True. + * x | y is False if both x and y are False. + * x | y is Maybe if either x or y is Maybe, but neither x or y is True. + * x | y is True if either x or y is True. + */ + enum Ternary { + False = 0, + Maybe = 1, + True = -1, + } + type TypeComparer = (s: Type, t: Type, reportErrors?: boolean) => Ternary; interface JsFileExtensionInfo { extension: string; isMixedContent: boolean; @@ -2195,6 +2221,7 @@ declare namespace ts { outFile?: string; paths?: MapLike; preserveConstEnums?: boolean; + preserveSymlinks?: boolean; project?: string; reactNamespace?: string; jsxFactory?: string; @@ -2300,6 +2327,10 @@ declare namespace ts { readFile(fileName: string): string | undefined; trace?(s: string): void; directoryExists?(directoryName: string): boolean; + /** + * Resolve a symbolic link. + * @see https://nodejs.org/api/fs.html#fs_fs_realpathsync_path_options + */ realpath?(path: string): string; getCurrentDirectory?(): string; getDirectories?(path: string): string[]; @@ -2314,17 +2345,13 @@ declare namespace ts { interface ResolvedModule { /** Path of the file the module was resolved to. */ resolvedFileName: string; - /** - * Denotes if 'resolvedFileName' is isExternalLibraryImport and thus should be a proper external module: - * - be a .d.ts file - * - use top level imports\exports - * - don't use tripleslash references - */ + /** True if `resolvedFileName` comes from `node_modules`. */ isExternalLibraryImport?: boolean; } /** * ResolvedModule with an explicitly provided `extension` property. * Prefer this over `ResolvedModule`. + * If changing this, remember to change `moduleResolutionIsEqualTo`. */ interface ResolvedModuleFull extends ResolvedModule { /** @@ -2332,6 +2359,21 @@ declare namespace ts { * This is optional for backwards-compatibility, but will be added if not provided. */ extension: Extension; + packageId?: PackageId; + } + /** + * Unique identifier with a package name and version. + * If changing this, remember to change `packageIdIsEqual`. + */ + interface PackageId { + /** + * Name of the package. + * Should not include `@types`. + * If accessing a non-index file, this should include its name e.g. "foo/bar". + */ + name: string; + /** Version of the package, e.g. "1.2.3" */ + version: string; } enum Extension { Ts = ".ts", @@ -2593,7 +2635,7 @@ declare namespace ts { } } declare namespace ts { - const versionMajorMinor = "2.5"; + const versionMajorMinor = "2.6"; /** The version of the TypeScript compiler release */ const version: string; } @@ -2741,6 +2783,8 @@ declare namespace ts { function collapseTextChangeRangesAcrossMultipleVersions(changes: ReadonlyArray): TextChangeRange; function getTypeParameterOwner(d: Declaration): Declaration; function isParameterPropertyDeclaration(node: Node): boolean; + function isEmptyBindingPattern(node: BindingName): node is BindingPattern; + function isEmptyBindingElement(node: BindingElement): boolean; function getCombinedModifierFlags(node: Node): ModifierFlags; function getCombinedNodeFlags(node: Node): NodeFlags; /** @@ -3310,8 +3354,8 @@ declare namespace ts { function updateDefaultClause(node: DefaultClause, statements: ReadonlyArray): DefaultClause; function createHeritageClause(token: HeritageClause["token"], types: ReadonlyArray): HeritageClause; function updateHeritageClause(node: HeritageClause, types: ReadonlyArray): HeritageClause; - function createCatchClause(variableDeclaration: string | VariableDeclaration, block: Block): CatchClause; - function updateCatchClause(node: CatchClause, variableDeclaration: VariableDeclaration, block: Block): CatchClause; + function createCatchClause(variableDeclaration: string | VariableDeclaration | undefined, block: Block): CatchClause; + function updateCatchClause(node: CatchClause, variableDeclaration: VariableDeclaration | undefined, block: Block): CatchClause; function createPropertyAssignment(name: string | PropertyName, initializer: Expression): PropertyAssignment; function updatePropertyAssignment(node: PropertyAssignment, name: PropertyName, initializer: Expression): PropertyAssignment; function createShorthandPropertyAssignment(name: string | Identifier, objectAssignmentInitializer?: Expression): ShorthandPropertyAssignment; @@ -3773,6 +3817,7 @@ declare namespace ts { getFormattingEditsAfterKeystroke(fileName: string, position: number, key: string, options: FormatCodeOptions | FormatCodeSettings): TextChange[]; getDocCommentTemplateAtPosition(fileName: string, position: number): TextInsertion; isValidBraceCompletionAtPosition(fileName: string, position: number, openingBrace: number): boolean; + getSpanOfEnclosingComment(fileName: string, position: number, onlyMultiLine: boolean): TextSpan; getCodeFixesAtPosition(fileName: string, start: number, end: number, errorCodes: number[], formatOptions: FormatCodeSettings): CodeAction[]; getApplicableRefactors(fileName: string, positionOrRaneg: number | TextRange): ApplicableRefactorInfo[]; getEditsForRefactor(fileName: string, formatOptions: FormatCodeSettings, positionOrRange: number | TextRange, refactorName: string, actionName: string): RefactorEditInfo | undefined; diff --git a/lib/typescript.js b/lib/typescript.js index eb71a73ba46..f1356d558c6 100644 --- a/lib/typescript.js +++ b/lib/typescript.js @@ -511,7 +511,7 @@ var ts; FlowFlags[FlowFlags["Label"] = 12] = "Label"; FlowFlags[FlowFlags["Condition"] = 96] = "Condition"; })(FlowFlags = ts.FlowFlags || (ts.FlowFlags = {})); - var OperationCanceledException = (function () { + var OperationCanceledException = /** @class */ (function () { function OperationCanceledException() { } return OperationCanceledException; @@ -570,11 +570,12 @@ var ts; TypeFormatFlags[TypeFormatFlags["UseFullyQualifiedType"] = 256] = "UseFullyQualifiedType"; TypeFormatFlags[TypeFormatFlags["InFirstTypeArgument"] = 512] = "InFirstTypeArgument"; TypeFormatFlags[TypeFormatFlags["InTypeAlias"] = 1024] = "InTypeAlias"; - TypeFormatFlags[TypeFormatFlags["UseTypeAliasValue"] = 2048] = "UseTypeAliasValue"; TypeFormatFlags[TypeFormatFlags["SuppressAnyReturnType"] = 4096] = "SuppressAnyReturnType"; TypeFormatFlags[TypeFormatFlags["AddUndefined"] = 8192] = "AddUndefined"; TypeFormatFlags[TypeFormatFlags["WriteClassExpressionAsTypeLiteral"] = 16384] = "WriteClassExpressionAsTypeLiteral"; TypeFormatFlags[TypeFormatFlags["InArrayType"] = 32768] = "InArrayType"; + TypeFormatFlags[TypeFormatFlags["UseAliasDefinedOutsideCurrentScope"] = 65536] = "UseAliasDefinedOutsideCurrentScope"; + // even though `T` can't be accessed in the current scope. })(TypeFormatFlags = ts.TypeFormatFlags || (ts.TypeFormatFlags = {})); var SymbolFormatFlags; (function (SymbolFormatFlags) { @@ -860,6 +861,21 @@ var ts; InferenceFlags[InferenceFlags["NoDefault"] = 2] = "NoDefault"; InferenceFlags[InferenceFlags["AnyDefault"] = 4] = "AnyDefault"; })(InferenceFlags = ts.InferenceFlags || (ts.InferenceFlags = {})); + /** + * Ternary values are defined such that + * x & y is False if either x or y is False. + * x & y is Maybe if either x or y is Maybe, but neither x or y is False. + * x & y is True if both x and y are True. + * x | y is False if both x and y are False. + * x | y is Maybe if either x or y is Maybe, but neither x or y is True. + * x | y is True if either x or y is True. + */ + var Ternary; + (function (Ternary) { + Ternary[Ternary["False"] = 0] = "False"; + Ternary[Ternary["Maybe"] = 1] = "Maybe"; + Ternary[Ternary["True"] = -1] = "True"; + })(Ternary = ts.Ternary || (ts.Ternary = {})); /* @internal */ var SpecialPropertyAssignmentKind; (function (SpecialPropertyAssignmentKind) { @@ -1329,27 +1345,12 @@ var ts; (function (ts) { // WARNING: The script `configureNightly.ts` uses a regexp to parse out these values. // If changing the text in this section, be sure to test `configureNightly` too. - ts.versionMajorMinor = "2.5"; + ts.versionMajorMinor = "2.6"; /** The version of the TypeScript compiler release */ ts.version = ts.versionMajorMinor + ".0"; })(ts || (ts = {})); /* @internal */ (function (ts) { - /** - * Ternary values are defined such that - * x & y is False if either x or y is False. - * x & y is Maybe if either x or y is Maybe, but neither x or y is False. - * x & y is True if both x and y are True. - * x | y is False if both x and y are False. - * x | y is Maybe if either x or y is Maybe, but neither x or y is True. - * x | y is True if either x or y is True. - */ - var Ternary; - (function (Ternary) { - Ternary[Ternary["False"] = 0] = "False"; - Ternary[Ternary["Maybe"] = 1] = "Maybe"; - Ternary[Ternary["True"] = -1] = "True"; - })(Ternary = ts.Ternary || (ts.Ternary = {})); // More efficient to create a collator once and use its `compare` than to call `a.localeCompare(b)` many times. ts.collator = typeof Intl === "object" && typeof Intl.Collator === "function" ? new Intl.Collator(/*locales*/ undefined, { usage: "sort", sensitivity: "accent" }) : undefined; // Intl is missing in Safari, and node 0.10 treats "a" as greater than "B". @@ -1403,7 +1404,7 @@ var ts; var MapCtr = typeof Map !== "undefined" && "entries" in Map.prototype ? Map : shimMap(); // Keep the class inside a function so it doesn't get compiled if it's not used. function shimMap() { - var MapIterator = (function () { + var MapIterator = /** @class */ (function () { function MapIterator(data, selector) { this.index = 0; this.data = data; @@ -1420,7 +1421,7 @@ var ts; }; return MapIterator; }()); - return (function () { + return /** @class */ (function () { function class_1() { this.data = createDictionaryObject(); this.size = 0; @@ -1668,10 +1669,9 @@ var ts; ts.removeWhere = removeWhere; function filterMutate(array, f) { var outIndex = 0; - for (var _i = 0, array_3 = array; _i < array_3.length; _i++) { - var item = array_3[_i]; - if (f(item)) { - array[outIndex] = item; + for (var i = 0; i < array.length; i++) { + if (f(array[i], i, array)) { + array[outIndex] = array[i]; outIndex++; } } @@ -1722,8 +1722,8 @@ var ts; var result; if (array) { result = []; - for (var _i = 0, array_4 = array; _i < array_4.length; _i++) { - var v = array_4[_i]; + for (var _i = 0, array_3 = array; _i < array_3.length; _i++) { + var v = array_3[_i]; if (v) { if (isArray(v)) { addRange(result, v); @@ -1799,11 +1799,13 @@ var ts; ts.sameFlatMap = sameFlatMap; function mapDefined(array, mapFn) { var result = []; - for (var i = 0; i < array.length; i++) { - var item = array[i]; - var mapped = mapFn(item, i); - if (mapped !== undefined) { - result.push(mapped); + if (array) { + for (var i = 0; i < array.length; i++) { + var item = array[i]; + var mapped = mapFn(item, i); + if (mapped !== undefined) { + result.push(mapped); + } } } return result; @@ -1882,8 +1884,8 @@ var ts; function some(array, predicate) { if (array) { if (predicate) { - for (var _i = 0, array_5 = array; _i < array_5.length; _i++) { - var v = array_5[_i]; + for (var _i = 0, array_4 = array; _i < array_4.length; _i++) { + var v = array_4[_i]; if (predicate(v)) { return true; } @@ -1909,8 +1911,8 @@ var ts; var result; if (array) { result = []; - loop: for (var _i = 0, array_6 = array; _i < array_6.length; _i++) { - var item = array_6[_i]; + loop: for (var _i = 0, array_5 = array; _i < array_5.length; _i++) { + var item = array_5[_i]; for (var _a = 0, result_1 = result; _a < result_1.length; _a++) { var res = result_1[_a]; if (areEqual ? areEqual(res, item) : res === item) { @@ -2003,8 +2005,8 @@ var ts; ts.relativeComplement = relativeComplement; function sum(array, prop) { var result = 0; - for (var _i = 0, array_7 = array; _i < array_7.length; _i++) { - var v = array_7[_i]; + for (var _i = 0, array_6 = array; _i < array_6.length; _i++) { + var v = array_6[_i]; // Note: we need the following type assertion because of GH #17069 result += v[prop]; } @@ -2336,8 +2338,8 @@ var ts; ts.equalOwnProperties = equalOwnProperties; function arrayToMap(array, makeKey, makeValue) { var result = createMap(); - for (var _i = 0, array_8 = array; _i < array_8.length; _i++) { - var value = array_8[_i]; + for (var _i = 0, array_7 = array; _i < array_7.length; _i++) { + var value = array_7[_i]; result.set(makeKey(value), makeValue ? makeValue(value) : value); } return result; @@ -2502,11 +2504,11 @@ var ts; ts.getLocaleSpecificMessage = getLocaleSpecificMessage; function createFileDiagnostic(file, start, length, message) { var end = start + length; - Debug.assert(start >= 0, "start must be non-negative, is " + start); - Debug.assert(length >= 0, "length must be non-negative, is " + length); + Debug.assertGreaterThanOrEqual(start, 0); + Debug.assertGreaterThanOrEqual(length, 0); if (file) { - Debug.assert(start <= file.text.length, "start must be within the bounds of the file. " + start + " > " + file.text.length); - Debug.assert(end <= file.text.length, "end must be the bounds of the file. " + end + " > " + file.text.length); + Debug.assertLessThanOrEqual(start, file.text.length); + Debug.assertLessThanOrEqual(end, file.text.length); } var text = getLocaleSpecificMessage(message); if (arguments.length > 4) { @@ -2736,19 +2738,23 @@ var ts; return normalized; } function normalizePath(path) { + return normalizePathAndParts(path).path; + } + ts.normalizePath = normalizePath; + function normalizePathAndParts(path) { path = normalizeSlashes(path); var rootLength = getRootLength(path); var root = path.substr(0, rootLength); - var normalized = getNormalizedParts(path, rootLength); - if (normalized.length) { - var joinedParts = root + normalized.join(ts.directorySeparator); - return pathEndsWithDirectorySeparator(path) ? joinedParts + ts.directorySeparator : joinedParts; + var parts = getNormalizedParts(path, rootLength); + if (parts.length) { + var joinedParts = root + parts.join(ts.directorySeparator); + return { path: pathEndsWithDirectorySeparator(path) ? joinedParts + ts.directorySeparator : joinedParts, parts: parts }; } else { - return root; + return { path: root, parts: parts }; } } - ts.normalizePath = normalizePath; + ts.normalizePathAndParts = normalizePathAndParts; /** A path ending with '/' refers to a directory only, never a file. */ function pathEndsWithDirectorySeparator(path) { return path.charCodeAt(path.length - 1) === directorySeparatorCharCode; @@ -3055,14 +3061,43 @@ var ts; // proof. var reservedCharacterPattern = /[^\w\s\/]/g; var wildcardCharCodes = [42 /* asterisk */, 63 /* question */]; - /** - * Matches any single directory segment unless it is the last segment and a .min.js file - * Breakdown: - * [^./] # matches everything up to the first . character (excluding directory seperators) - * (\\.(?!min\\.js$))? # matches . characters but not if they are part of the .min.js file extension - */ - var singleAsteriskRegexFragmentFiles = "([^./]|(\\.(?!min\\.js$))?)*"; - var singleAsteriskRegexFragmentOther = "[^/]*"; + /* @internal */ + ts.commonPackageFolders = ["node_modules", "bower_components", "jspm_packages"]; + var implicitExcludePathRegexPattern = "(?!(" + ts.commonPackageFolders.join("|") + ")(/|$))"; + var filesMatcher = { + /** + * Matches any single directory segment unless it is the last segment and a .min.js file + * Breakdown: + * [^./] # matches everything up to the first . character (excluding directory seperators) + * (\\.(?!min\\.js$))? # matches . characters but not if they are part of the .min.js file extension + */ + singleAsteriskRegexFragment: "([^./]|(\\.(?!min\\.js$))?)*", + /** + * Regex for the ** wildcard. Matches any number of subdirectories. When used for including + * files or directories, does not match subdirectories that start with a . character + */ + doubleAsteriskRegexFragment: "(/" + implicitExcludePathRegexPattern + "[^/.][^/]*)*?", + replaceWildcardCharacter: function (match) { return replaceWildcardCharacter(match, filesMatcher.singleAsteriskRegexFragment); } + }; + var directoriesMatcher = { + singleAsteriskRegexFragment: "[^/]*", + /** + * Regex for the ** wildcard. Matches any number of subdirectories. When used for including + * files or directories, does not match subdirectories that start with a . character + */ + doubleAsteriskRegexFragment: "(/" + implicitExcludePathRegexPattern + "[^/.][^/]*)*?", + replaceWildcardCharacter: function (match) { return replaceWildcardCharacter(match, directoriesMatcher.singleAsteriskRegexFragment); } + }; + var excludeMatcher = { + singleAsteriskRegexFragment: "[^/]*", + doubleAsteriskRegexFragment: "(/.+?)?", + replaceWildcardCharacter: function (match) { return replaceWildcardCharacter(match, excludeMatcher.singleAsteriskRegexFragment); } + }; + var wildcardMatchers = { + files: filesMatcher, + directories: directoriesMatcher, + exclude: excludeMatcher + }; function getRegularExpressionForWildcard(specs, basePath, usage) { var patterns = getRegularExpressionsForWildcards(specs, basePath, usage); if (!patterns || !patterns.length) { @@ -3078,15 +3113,8 @@ var ts; if (specs === undefined || specs.length === 0) { return undefined; } - var replaceWildcardCharacter = usage === "files" ? replaceWildCardCharacterFiles : replaceWildCardCharacterOther; - var singleAsteriskRegexFragment = usage === "files" ? singleAsteriskRegexFragmentFiles : singleAsteriskRegexFragmentOther; - /** - * Regex for the ** wildcard. Matches any number of subdirectories. When used for including - * files or directories, does not match subdirectories that start with a . character - */ - var doubleAsteriskRegexFragment = usage === "exclude" ? "(/.+?)?" : "(/[^/.][^/]*)*?"; return flatMap(specs, function (spec) { - return spec && getSubPatternFromSpec(spec, basePath, usage, singleAsteriskRegexFragment, doubleAsteriskRegexFragment, replaceWildcardCharacter); + return spec && getSubPatternFromSpec(spec, basePath, usage, wildcardMatchers[usage]); }); } /** @@ -3097,7 +3125,8 @@ var ts; return !/[.*?]/.test(lastPathComponent); } ts.isImplicitGlob = isImplicitGlob; - function getSubPatternFromSpec(spec, basePath, usage, singleAsteriskRegexFragment, doubleAsteriskRegexFragment, replaceWildcardCharacter) { + function getSubPatternFromSpec(spec, basePath, usage, _a) { + var singleAsteriskRegexFragment = _a.singleAsteriskRegexFragment, doubleAsteriskRegexFragment = _a.doubleAsteriskRegexFragment, replaceWildcardCharacter = _a.replaceWildcardCharacter; var subpattern = ""; var hasRecursiveDirectoryWildcard = false; var hasWrittenComponent = false; @@ -3131,19 +3160,33 @@ var ts; subpattern += ts.directorySeparator; } if (usage !== "exclude") { + var componentPattern = ""; // The * and ? wildcards should not match directories or files that start with . if they // appear first in a component. Dotted directories and files can be included explicitly // like so: **/.*/.* if (component.charCodeAt(0) === 42 /* asterisk */) { - subpattern += "([^./]" + singleAsteriskRegexFragment + ")?"; + componentPattern += "([^./]" + singleAsteriskRegexFragment + ")?"; component = component.substr(1); } else if (component.charCodeAt(0) === 63 /* question */) { - subpattern += "[^./]"; + componentPattern += "[^./]"; component = component.substr(1); } + componentPattern += component.replace(reservedCharacterPattern, replaceWildcardCharacter); + // Patterns should not include subfolders like node_modules unless they are + // explicitly included as part of the path. + // + // As an optimization, if the component pattern is the same as the component, + // then there definitely were no wildcard characters and we do not need to + // add the exclusion pattern. + if (componentPattern !== component) { + subpattern += implicitExcludePathRegexPattern; + } + subpattern += componentPattern; + } + else { + subpattern += component.replace(reservedCharacterPattern, replaceWildcardCharacter); } - subpattern += component.replace(reservedCharacterPattern, replaceWildcardCharacter); } hasWrittenComponent = true; } @@ -3153,12 +3196,6 @@ var ts; } return subpattern; } - function replaceWildCardCharacterFiles(match) { - return replaceWildcardCharacter(match, singleAsteriskRegexFragmentFiles); - } - function replaceWildCardCharacterOther(match) { - return replaceWildcardCharacter(match, singleAsteriskRegexFragmentOther); - } function replaceWildcardCharacter(match, singleAsteriskRegexFragment) { return match === "*" ? singleAsteriskRegexFragment : match === "?" ? "[^/]" : "\\" + match; } @@ -3319,14 +3356,7 @@ var ts; if (!extraFileExtensions || extraFileExtensions.length === 0 || !needAllExtensions) { return needAllExtensions ? allSupportedExtensions : ts.supportedTypeScriptExtensions; } - var extensions = allSupportedExtensions.slice(0); - for (var _i = 0, extraFileExtensions_1 = extraFileExtensions; _i < extraFileExtensions_1.length; _i++) { - var extInfo = extraFileExtensions_1[_i]; - if (extensions.indexOf(extInfo.extension) === -1) { - extensions.push(extInfo.extension); - } - } - return extensions; + return deduplicate(allSupportedExtensions.concat(extraFileExtensions.map(function (e) { return e.extension; }))); } ts.getSupportedExtensions = getSupportedExtensions; function hasJavaScriptFileExtension(fileName) { @@ -3481,12 +3511,37 @@ var ts; function assert(expression, message, verboseDebugInfo, stackCrawlMark) { if (!expression) { if (verboseDebugInfo) { - message += "\r\nVerbose Debug Information: " + verboseDebugInfo(); + message += "\r\nVerbose Debug Information: " + (typeof verboseDebugInfo === "string" ? verboseDebugInfo : verboseDebugInfo()); } fail(message ? "False expression: " + message : "False expression.", stackCrawlMark || assert); } } Debug.assert = assert; + function assertEqual(a, b, msg, msg2) { + if (a !== b) { + var message = msg ? msg2 ? msg + " " + msg2 : msg : ""; + fail("Expected " + a + " === " + b + ". " + message); + } + } + Debug.assertEqual = assertEqual; + function assertLessThan(a, b, msg) { + if (a >= b) { + fail("Expected " + a + " < " + b + ". " + (msg || "")); + } + } + Debug.assertLessThan = assertLessThan; + function assertLessThanOrEqual(a, b) { + if (a > b) { + fail("Expected " + a + " <= " + b); + } + } + Debug.assertLessThanOrEqual = assertLessThanOrEqual; + function assertGreaterThanOrEqual(a, b) { + if (a < b) { + fail("Expected " + a + " >= " + b); + } + } + Debug.assertGreaterThanOrEqual = assertGreaterThanOrEqual; function fail(message, stackCrawlMark) { debugger; var e = new Error(message ? "Debug Failure. " + message : "Debug Failure."); @@ -3652,6 +3707,10 @@ var ts; Debug.fail("File " + path + " has unknown extension."); } ts.extensionFromPath = extensionFromPath; + function isAnySupportedFileExtension(path) { + return tryGetExtensionFromPath(path) !== undefined; + } + ts.isAnySupportedFileExtension = isAnySupportedFileExtension; function tryGetExtensionFromPath(path) { return find(ts.supportedTypescriptExtensionsForExtractExtension, function (e) { return fileExtensionIs(path, e); }) || find(ts.supportedJavascriptExtensions, function (e) { return fileExtensionIs(path, e); }); } @@ -3664,6 +3723,18 @@ var ts; /// var ts; (function (ts) { + /** + * Set a high stack trace limit to provide more information in case of an error. + * Called for command-line and server use cases. + * Not called if TypeScript is used as a library. + */ + /* @internal */ + function setStackTraceLimit() { + if (Error.stackTraceLimit < 100) { + Error.stackTraceLimit = 100; + } + } + ts.setStackTraceLimit = setStackTraceLimit; var FileWatcherEventKind; (function (FileWatcherEventKind) { FileWatcherEventKind[FileWatcherEventKind["Created"] = 0] = "Created"; @@ -3714,7 +3785,7 @@ var ts; watcher.referenceCount += 1; return; } - watcher = _fs.watch(dirPath, { persistent: true }, function (eventName, relativeFileName) { return fileEventHandler(eventName, relativeFileName, dirPath); }); + watcher = _fs.watch(dirPath || ".", { persistent: true }, function (eventName, relativeFileName) { return fileEventHandler(eventName, relativeFileName, dirPath); }); watcher.referenceCount = 1; dirWatchers.set(dirPath, watcher); return; @@ -4569,6 +4640,8 @@ var ts; Expected_at_least_0_arguments_but_got_a_minimum_of_1: diag(2557, ts.DiagnosticCategory.Error, "Expected_at_least_0_arguments_but_got_a_minimum_of_1_2557", "Expected at least {0} arguments, but got a minimum of {1}."), Expected_0_type_arguments_but_got_1: diag(2558, ts.DiagnosticCategory.Error, "Expected_0_type_arguments_but_got_1_2558", "Expected {0} type arguments, but got {1}."), Type_0_has_no_properties_in_common_with_type_1: diag(2559, ts.DiagnosticCategory.Error, "Type_0_has_no_properties_in_common_with_type_1_2559", "Type '{0}' has no properties in common with type '{1}'."), + Value_of_type_0_has_no_properties_in_common_with_type_1_Did_you_mean_to_call_it: diag(2560, ts.DiagnosticCategory.Error, "Value_of_type_0_has_no_properties_in_common_with_type_1_Did_you_mean_to_call_it_2560", "Value of type '{0}' has no properties in common with type '{1}'. Did you mean to call it?"), + Base_class_expressions_cannot_reference_class_type_parameters: diag(2561, ts.DiagnosticCategory.Error, "Base_class_expressions_cannot_reference_class_type_parameters_2561", "Base class expressions cannot reference class type parameters."), JSX_element_attributes_type_0_may_not_be_a_union_type: diag(2600, ts.DiagnosticCategory.Error, "JSX_element_attributes_type_0_may_not_be_a_union_type_2600", "JSX element attributes type '{0}' may not be a union type."), The_return_type_of_a_JSX_element_constructor_must_return_an_object_type: diag(2601, ts.DiagnosticCategory.Error, "The_return_type_of_a_JSX_element_constructor_must_return_an_object_type_2601", "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: diag(2602, ts.DiagnosticCategory.Error, "JSX_element_implicitly_has_type_any_because_the_global_type_JSX_Element_does_not_exist_2602", "JSX element implicitly has type 'any' because the global type 'JSX.Element' does not exist."), @@ -4756,6 +4829,7 @@ var ts; Do_not_emit_outputs: diag(6010, ts.DiagnosticCategory.Message, "Do_not_emit_outputs_6010", "Do not emit outputs."), Allow_default_imports_from_modules_with_no_default_export_This_does_not_affect_code_emit_just_typechecking: diag(6011, ts.DiagnosticCategory.Message, "Allow_default_imports_from_modules_with_no_default_export_This_does_not_affect_code_emit_just_typech_6011", "Allow default imports from modules with no default export. This does not affect code emit, just typechecking."), Skip_type_checking_of_declaration_files: diag(6012, ts.DiagnosticCategory.Message, "Skip_type_checking_of_declaration_files_6012", "Skip type checking of declaration files."), + Do_not_resolve_the_real_path_of_symlinks: diag(6013, ts.DiagnosticCategory.Message, "Do_not_resolve_the_real_path_of_symlinks_6013", "Do not resolve the real path of symlinks."), Specify_ECMAScript_target_version_Colon_ES3_default_ES5_ES2015_ES2016_ES2017_or_ESNEXT: diag(6015, ts.DiagnosticCategory.Message, "Specify_ECMAScript_target_version_Colon_ES3_default_ES5_ES2015_ES2016_ES2017_or_ESNEXT_6015", "Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', or 'ESNEXT'."), Specify_module_code_generation_Colon_none_commonjs_amd_system_umd_es2015_or_ESNext: diag(6016, ts.DiagnosticCategory.Message, "Specify_module_code_generation_Colon_none_commonjs_amd_system_umd_es2015_or_ESNext_6016", "Specify module code generation: 'none', commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'."), Print_this_message: diag(6017, ts.DiagnosticCategory.Message, "Print_this_message_6017", "Print this message."), @@ -5009,6 +5083,8 @@ var ts; Rewrite_as_the_indexed_access_type_0: diag(90026, ts.DiagnosticCategory.Message, "Rewrite_as_the_indexed_access_type_0_90026", "Rewrite as the indexed access type '{0}'."), Convert_function_to_an_ES2015_class: diag(95001, ts.DiagnosticCategory.Message, "Convert_function_to_an_ES2015_class_95001", "Convert function to an ES2015 class"), Convert_function_0_to_class: diag(95002, ts.DiagnosticCategory.Message, "Convert_function_0_to_class_95002", "Convert function '{0}' to class"), + Extract_function: diag(95003, ts.DiagnosticCategory.Message, "Extract_function_95003", "Extract function"), + Extract_function_into_0: diag(95004, ts.DiagnosticCategory.Message, "Extract_function_into_0_95004", "Extract function into '{0}'"), }; })(ts || (ts = {})); /// @@ -6812,19 +6888,6 @@ var ts; return undefined; } ts.getDeclarationOfKind = getDeclarationOfKind; - function findDeclaration(symbol, predicate) { - var declarations = symbol.declarations; - if (declarations) { - for (var _i = 0, declarations_2 = declarations; _i < declarations_2.length; _i++) { - var declaration = declarations_2[_i]; - if (predicate(declaration)) { - return declaration; - } - } - } - return undefined; - } - ts.findDeclaration = findDeclaration; var stringWriter = createSingleLineStringWriter(); var stringWriterAcquired = false; function createSingleLineStringWriter() { @@ -6886,19 +6949,20 @@ var ts; sourceFile.resolvedTypeReferenceDirectiveNames.set(typeReferenceDirectiveName, resolvedTypeReferenceDirective); } ts.setResolvedTypeReferenceDirective = setResolvedTypeReferenceDirective; - /* @internal */ function moduleResolutionIsEqualTo(oldResolution, newResolution) { return oldResolution.isExternalLibraryImport === newResolution.isExternalLibraryImport && oldResolution.extension === newResolution.extension && - oldResolution.resolvedFileName === newResolution.resolvedFileName; + oldResolution.resolvedFileName === newResolution.resolvedFileName && + packageIdIsEqual(oldResolution.packageId, newResolution.packageId); } ts.moduleResolutionIsEqualTo = moduleResolutionIsEqualTo; - /* @internal */ + function packageIdIsEqual(a, b) { + return a === b || a && b && a.name === b.name && a.version === b.version; + } function typeDirectiveIsEqualTo(oldResolution, newResolution) { return oldResolution.resolvedFileName === newResolution.resolvedFileName && oldResolution.primary === newResolution.primary; } ts.typeDirectiveIsEqualTo = typeDirectiveIsEqualTo; - /* @internal */ function hasChangesInResolutions(names, newResolutions, oldResolutions, comparer) { ts.Debug.assert(names.length === newResolutions.length); for (var i = 0; i < names.length; i++) { @@ -6968,14 +7032,6 @@ var ts; return file.fileName + "(" + (loc.line + 1) + "," + (loc.character + 1) + ")"; } ts.nodePosToString = nodePosToString; - function getStartPosOfNode(node) { - return node.pos; - } - ts.getStartPosOfNode = getStartPosOfNode; - function isDefined(value) { - return value !== undefined; - } - ts.isDefined = isDefined; function getEndLinePosition(line, sourceFile) { ts.Debug.assert(line >= 0); var lineStarts = ts.getLineStarts(sourceFile); @@ -7025,6 +7081,32 @@ var ts; return !nodeIsMissing(node); } ts.nodeIsPresent = nodeIsPresent; + /** + * Determine if the given comment is a triple-slash + * + * @return true if the comment is a triple-slash comment else false + */ + function isRecognizedTripleSlashComment(text, commentPos, commentEnd) { + // 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 (text.charCodeAt(commentPos + 1) === 47 /* slash */ && + commentPos + 2 < commentEnd && + text.charCodeAt(commentPos + 2) === 47 /* slash */) { + var textSubStr = text.substring(commentPos, commentEnd); + return textSubStr.match(ts.fullTripleSlashReferencePathRegEx) || + textSubStr.match(ts.fullTripleSlashAMDReferencePathRegEx) || + textSubStr.match(fullTripleSlashReferenceTypeReferenceDirectiveRegEx) || + textSubStr.match(defaultLibReferenceRegEx) ? + true : false; + } + return false; + } + ts.isRecognizedTripleSlashComment = isRecognizedTripleSlashComment; + function isPinnedComment(text, comment) { + return text.charCodeAt(comment.pos + 1) === 42 /* asterisk */ && + text.charCodeAt(comment.pos + 2) === 33 /* exclamation */; + } + ts.isPinnedComment = isPinnedComment; function getTokenPosOfNode(node, sourceFile, includeJsDoc) { // With nodes that have no width (i.e. 'Missing' nodes), we actually *don't* // want to skip trivia because this will launch us forward to the next token. @@ -7094,15 +7176,20 @@ var ts; // or a (possibly escaped) quoted form of the original text if it's string-like. switch (node.kind) { case 9 /* StringLiteral */: - return '"' + escapeText(node.text) + '"'; + if (node.singleQuote) { + return "'" + escapeText(node.text, 39 /* singleQuote */) + "'"; + } + else { + return '"' + escapeText(node.text, 34 /* doubleQuote */) + '"'; + } case 13 /* NoSubstitutionTemplateLiteral */: - return "`" + escapeText(node.text) + "`"; + return "`" + escapeText(node.text, 96 /* backtick */) + "`"; case 14 /* TemplateHead */: - return "`" + escapeText(node.text) + "${"; + return "`" + escapeText(node.text, 96 /* backtick */) + "${"; case 15 /* TemplateMiddle */: - return "}" + escapeText(node.text) + "${"; + return "}" + escapeText(node.text, 96 /* backtick */) + "${"; case 16 /* TemplateTail */: - return "}" + escapeText(node.text) + "`"; + return "}" + escapeText(node.text, 96 /* backtick */) + "`"; case 8 /* NumericLiteral */: return node.text; } @@ -7191,6 +7278,7 @@ var ts; return ts.isExternalModule(node) || compilerOptions.isolatedModules; } ts.isEffectiveExternalModule = isEffectiveExternalModule; + /* @internal */ function isBlockScope(node, parentNode) { switch (node.kind) { case 265 /* SourceFile */: @@ -7381,13 +7469,9 @@ var ts; } ts.isPrologueDirective = isPrologueDirective; function getLeadingCommentRangesOfNode(node, sourceFileOfNode) { - return ts.getLeadingCommentRanges(sourceFileOfNode.text, node.pos); + return node.kind !== 10 /* JsxText */ ? ts.getLeadingCommentRanges(sourceFileOfNode.text, node.pos) : undefined; } ts.getLeadingCommentRangesOfNode = getLeadingCommentRangesOfNode; - function getLeadingCommentRangesOfNodeFromText(node, text) { - return ts.getLeadingCommentRanges(text, node.pos); - } - ts.getLeadingCommentRangesOfNodeFromText = getLeadingCommentRangesOfNodeFromText; function getJSDocCommentRanges(node, text) { var commentRanges = (node.kind === 146 /* Parameter */ || node.kind === 145 /* TypeParameter */ || @@ -7395,7 +7479,7 @@ var ts; node.kind === 187 /* ArrowFunction */ || node.kind === 185 /* ParenthesizedExpression */) ? ts.concatenate(ts.getTrailingCommentRanges(text, node.pos), ts.getLeadingCommentRanges(text, node.pos)) : - getLeadingCommentRangesOfNodeFromText(node, text); + ts.getLeadingCommentRanges(text, node.pos); // True if the comment starts with '/**' but not if it is '/**/' return ts.filter(commentRanges, function (comment) { return text.charCodeAt(comment.pos + 1) === 42 /* asterisk */ && @@ -7405,8 +7489,9 @@ var ts; } ts.getJSDocCommentRanges = getJSDocCommentRanges; ts.fullTripleSlashReferencePathRegEx = /^(\/\/\/\s*/; - ts.fullTripleSlashReferenceTypeReferenceDirectiveRegEx = /^(\/\/\/\s*/; + var fullTripleSlashReferenceTypeReferenceDirectiveRegEx = /^(\/\/\/\s*/; ts.fullTripleSlashAMDReferencePathRegEx = /^(\/\/\/\s*/; + var defaultLibReferenceRegEx = /^(\/\/\/\s*/; function isPartOfTypeNode(node) { if (158 /* FirstTypeNode */ <= node.kind && node.kind <= 173 /* LastTypeNode */) { return true; @@ -7660,21 +7745,11 @@ var ts; } ts.getPropertyAssignment = getPropertyAssignment; function getContainingFunction(node) { - while (true) { - node = node.parent; - if (!node || ts.isFunctionLike(node)) { - return node; - } - } + return ts.findAncestor(node.parent, ts.isFunctionLike); } ts.getContainingFunction = getContainingFunction; function getContainingClass(node) { - while (true) { - node = node.parent; - if (!node || ts.isClassLike(node)) { - return node; - } - } + return ts.findAncestor(node.parent, ts.isClassLike); } ts.getContainingClass = getContainingClass; function getThisContainer(node, includeArrowFunctions) { @@ -8570,14 +8645,14 @@ var ts; ts.getAncestor = getAncestor; function getFileReferenceFromReferencePath(comment, commentRange) { var simpleReferenceRegEx = /^\/\/\/\s*/gim; + var isNoDefaultLibRegEx = new RegExp(defaultLibReferenceRegEx.source, "gim"); if (simpleReferenceRegEx.test(comment)) { if (isNoDefaultLibRegEx.test(comment)) { return { isNoDefaultLib: true }; } else { var refMatchResult = ts.fullTripleSlashReferencePathRegEx.exec(comment); - var refLibResult = !refMatchResult && ts.fullTripleSlashReferenceTypeReferenceDirectiveRegEx.exec(comment); + var refLibResult = !refMatchResult && fullTripleSlashReferenceTypeReferenceDirectiveRegEx.exec(comment); var match = refMatchResult || refLibResult; if (match) { var pos = commentRange.pos + match[1].length + match[2].length; @@ -8782,10 +8857,6 @@ var ts; return ts.getParseTreeNode(sourceFile, ts.isSourceFile) || sourceFile; } ts.getOriginalSourceFile = getOriginalSourceFile; - function getOriginalSourceFiles(sourceFiles) { - return ts.sameMap(sourceFiles, getOriginalSourceFile); - } - ts.getOriginalSourceFiles = getOriginalSourceFiles; var Associativity; (function (Associativity) { Associativity[Associativity["Left"] = 0] = "Left"; @@ -9029,7 +9100,9 @@ var ts; // the language service. These characters should be escaped when printing, and if any characters are added, // the map below must be updated. Note that this regexp *does not* include the 'delete' character. // There is no reason for this other than that JSON.stringify does not handle it either. - var escapedCharsRegExp = /[\\\"\u0000-\u001f\t\v\f\b\r\n\u2028\u2029\u0085]/g; + var doubleQuoteEscapedCharsRegExp = /[\\\"\u0000-\u001f\t\v\f\b\r\n\u2028\u2029\u0085]/g; + var singleQuoteEscapedCharsRegExp = /[\\\'\u0000-\u001f\t\v\f\b\r\n\u2028\u2029\u0085]/g; + var backtickQuoteEscapedCharsRegExp = /[\\\`\u0000-\u001f\t\v\f\b\r\n\u2028\u2029\u0085]/g; var escapedCharsMap = ts.createMapFromTemplate({ "\0": "\\0", "\t": "\\t", @@ -9040,6 +9113,8 @@ var ts; "\n": "\\n", "\\": "\\\\", "\"": "\\\"", + "\'": "\\\'", + "\`": "\\\`", "\u2028": "\\u2028", "\u2029": "\\u2029", "\u0085": "\\u0085" // nextLine @@ -9049,7 +9124,10 @@ var ts; * but augmented for a few select characters (e.g. lineSeparator, paragraphSeparator, nextLine) * Note that this doesn't actually wrap the input in double quotes. */ - function escapeString(s) { + function escapeString(s, quoteChar) { + var escapedCharsRegExp = quoteChar === 96 /* backtick */ ? backtickQuoteEscapedCharsRegExp : + quoteChar === 39 /* singleQuote */ ? singleQuoteEscapedCharsRegExp : + doubleQuoteEscapedCharsRegExp; return s.replace(escapedCharsRegExp, getReplacement); } ts.escapeString = escapeString; @@ -9069,8 +9147,8 @@ var ts; return "\\u" + paddedHexCode; } var nonAsciiCharacters = /[^\u0000-\u007F]/g; - function escapeNonAsciiString(s) { - s = escapeString(s); + function escapeNonAsciiString(s, quoteChar) { + s = escapeString(s, quoteChar); // Replace non-ASCII characters with '\uNNNN' escapes if any exist. // Otherwise just return the original string. return nonAsciiCharacters.test(s) ? @@ -9455,7 +9533,7 @@ var ts; // // var x = 10; if (node.pos === 0) { - leadingComments = ts.filter(ts.getLeadingCommentRanges(text, node.pos), isPinnedComment); + leadingComments = ts.filter(ts.getLeadingCommentRanges(text, node.pos), isPinnedCommentLocal); } } else { @@ -9495,9 +9573,8 @@ var ts; } } return currentDetachedCommentInfo; - function isPinnedComment(comment) { - return text.charCodeAt(comment.pos + 1) === 42 /* asterisk */ && - text.charCodeAt(comment.pos + 2) === 33 /* exclamation */; + function isPinnedCommentLocal(comment) { + return isPinnedComment(text, comment); } } ts.emitDetachedComments = emitDetachedComments; @@ -9593,9 +9670,13 @@ var ts; } ts.hasModifiers = hasModifiers; function hasModifier(node, flags) { - return (getModifierFlags(node) & flags) !== 0; + return !!getSelectedModifierFlags(node, flags); } ts.hasModifier = hasModifier; + function getSelectedModifierFlags(node, flags) { + return getModifierFlags(node) & flags; + } + ts.getSelectedModifierFlags = getSelectedModifierFlags; function getModifierFlags(node) { if (node.modifierFlagsCache & 536870912 /* HasComputedFlags */) { return node.modifierFlagsCache & ~536870912 /* HasComputedFlags */; @@ -9673,23 +9754,6 @@ var ts; return false; } ts.isDestructuringAssignment = isDestructuringAssignment; - // Returns false if this heritage clause element's expression contains something unsupported - // (i.e. not a name or dotted name). - function isSupportedExpressionWithTypeArguments(node) { - return isSupportedExpressionWithTypeArgumentsRest(node.expression); - } - ts.isSupportedExpressionWithTypeArguments = isSupportedExpressionWithTypeArguments; - function isSupportedExpressionWithTypeArgumentsRest(node) { - if (node.kind === 71 /* Identifier */) { - return true; - } - else if (ts.isPropertyAccessExpression(node)) { - return isSupportedExpressionWithTypeArgumentsRest(node.expression); - } - else { - return false; - } - } function isExpressionWithTypeArgumentsInClassExtendsClause(node) { return tryGetClassExtendingExpressionWithTypeArguments(node) !== undefined; } @@ -9816,78 +9880,6 @@ var ts; return carriageReturnLineFeed; } ts.getNewLineCharacter = getNewLineCharacter; - /** - * Tests whether a node and its subtree is simple enough to have its position - * information ignored when emitting source maps in a destructuring assignment. - * - * @param node The expression to test. - */ - function isSimpleExpression(node) { - return isSimpleExpressionWorker(node, 0); - } - ts.isSimpleExpression = isSimpleExpression; - function isSimpleExpressionWorker(node, depth) { - if (depth <= 5) { - var kind = node.kind; - if (kind === 9 /* StringLiteral */ - || kind === 8 /* NumericLiteral */ - || kind === 12 /* RegularExpressionLiteral */ - || kind === 13 /* NoSubstitutionTemplateLiteral */ - || kind === 71 /* Identifier */ - || kind === 99 /* ThisKeyword */ - || kind === 97 /* SuperKeyword */ - || kind === 101 /* TrueKeyword */ - || kind === 86 /* FalseKeyword */ - || kind === 95 /* NullKeyword */) { - return true; - } - else if (kind === 179 /* PropertyAccessExpression */) { - return isSimpleExpressionWorker(node.expression, depth + 1); - } - else if (kind === 180 /* ElementAccessExpression */) { - return isSimpleExpressionWorker(node.expression, depth + 1) - && isSimpleExpressionWorker(node.argumentExpression, depth + 1); - } - else if (kind === 192 /* PrefixUnaryExpression */ - || kind === 193 /* PostfixUnaryExpression */) { - return isSimpleExpressionWorker(node.operand, depth + 1); - } - else if (kind === 194 /* BinaryExpression */) { - return node.operatorToken.kind !== 40 /* AsteriskAsteriskToken */ - && isSimpleExpressionWorker(node.left, depth + 1) - && isSimpleExpressionWorker(node.right, depth + 1); - } - else if (kind === 195 /* ConditionalExpression */) { - return isSimpleExpressionWorker(node.condition, depth + 1) - && isSimpleExpressionWorker(node.whenTrue, depth + 1) - && isSimpleExpressionWorker(node.whenFalse, depth + 1); - } - else if (kind === 190 /* VoidExpression */ - || kind === 189 /* TypeOfExpression */ - || kind === 188 /* DeleteExpression */) { - return isSimpleExpressionWorker(node.expression, depth + 1); - } - else if (kind === 177 /* ArrayLiteralExpression */) { - return node.elements.length === 0; - } - else if (kind === 178 /* ObjectLiteralExpression */) { - return node.properties.length === 0; - } - else if (kind === 181 /* CallExpression */) { - if (!isSimpleExpressionWorker(node.expression, depth + 1)) { - return false; - } - for (var _i = 0, _a = node.arguments; _i < _a.length; _i++) { - var argument = _a[_i]; - if (!isSimpleExpressionWorker(argument, depth + 1)) { - return false; - } - } - return true; - } - } - return false; - } /** * Formats an enum value as a string for debugging and debug assertions. */ @@ -9959,24 +9951,6 @@ var ts; return formatEnum(flags, ts.ObjectFlags, /*isFlags*/ true); } ts.formatObjectFlags = formatObjectFlags; - function getRangePos(range) { - return range ? range.pos : -1; - } - ts.getRangePos = getRangePos; - function getRangeEnd(range) { - return range ? range.end : -1; - } - ts.getRangeEnd = getRangeEnd; - /** - * Increases (or decreases) a position by the provided amount. - * - * @param pos The position. - * @param value The delta. - */ - function movePos(pos, value) { - return ts.positionIsSynthesized(pos) ? -1 : pos + value; - } - ts.movePos = movePos; /** * Creates a new TextRange from the provided pos and end. * @@ -10034,26 +10008,6 @@ var ts; return range.pos === range.end; } ts.isCollapsedRange = isCollapsedRange; - /** - * Creates a new TextRange from a provided range with its end position collapsed to its - * start position. - * - * @param range A TextRange. - */ - function collapseRangeToStart(range) { - return isCollapsedRange(range) ? range : moveRangeEnd(range, range.pos); - } - ts.collapseRangeToStart = collapseRangeToStart; - /** - * Creates a new TextRange from a provided range with its start position collapsed to its - * end position. - * - * @param range A TextRange. - */ - function collapseRangeToEnd(range) { - return isCollapsedRange(range) ? range : moveRangePos(range, range.end); - } - ts.collapseRangeToEnd = collapseRangeToEnd; /** * Creates a new TextRange for a token at the provides start position. * @@ -10116,31 +10070,6 @@ var ts; function isInitializedVariable(node) { return node.initializer !== undefined; } - /** - * Gets a value indicating whether a node is merged with a class declaration in the same scope. - */ - function isMergedWithClass(node) { - if (node.symbol) { - for (var _i = 0, _a = node.symbol.declarations; _i < _a.length; _i++) { - var declaration = _a[_i]; - if (declaration.kind === 229 /* ClassDeclaration */ && declaration !== node) { - return true; - } - } - } - return false; - } - ts.isMergedWithClass = isMergedWithClass; - /** - * Gets a value indicating whether a node is the first declaration of its kind. - * - * @param node A Declaration node. - * @param kind The SyntaxKind to find among related declarations. - */ - function isFirstDeclarationOfKind(node, kind) { - return node.symbol && getDeclarationOfKind(node.symbol, kind) === node; - } - ts.isFirstDeclarationOfKind = isFirstDeclarationOfKind; function isWatchSet(options) { // Firefox has Object.prototype.watch return options.watch && options.hasOwnProperty("watch"); @@ -10434,6 +10363,20 @@ var ts; return ts.hasModifier(node, 92 /* ParameterPropertyModifier */) && node.parent.kind === 152 /* Constructor */ && ts.isClassLike(node.parent.parent); } ts.isParameterPropertyDeclaration = isParameterPropertyDeclaration; + function isEmptyBindingPattern(node) { + if (ts.isBindingPattern(node)) { + return ts.every(node.elements, isEmptyBindingElement); + } + return false; + } + ts.isEmptyBindingPattern = isEmptyBindingPattern; + function isEmptyBindingElement(node) { + if (ts.isOmittedExpression(node)) { + return true; + } + return isEmptyBindingPattern(node.name); + } + ts.isEmptyBindingElement = isEmptyBindingElement; function walkUpBindingElementsAndPatterns(node) { while (node && (node.kind === 176 /* BindingElement */ || ts.isBindingPattern(node))) { node = node.parent; @@ -11618,6 +11561,19 @@ var ts; return isUnaryExpressionKind(ts.skipPartiallyEmittedExpressions(node).kind); } ts.isUnaryExpression = isUnaryExpression; + /* @internal */ + function isUnaryExpressionWithWrite(expr) { + switch (expr.kind) { + case 193 /* PostfixUnaryExpression */: + return true; + case 192 /* PrefixUnaryExpression */: + return expr.operator === 43 /* PlusPlusToken */ || + expr.operator === 44 /* MinusMinusToken */; + default: + return false; + } + } + ts.isUnaryExpressionWithWrite = isUnaryExpressionWithWrite; function isExpressionKind(kind) { return kind === 195 /* ConditionalExpression */ || kind === 197 /* YieldExpression */ @@ -11824,9 +11780,19 @@ var ts; var kind = node.kind; return isStatementKindButNotDeclarationKind(kind) || isDeclarationStatementKind(kind) - || kind === 207 /* Block */; + || isBlockStatement(node); } ts.isStatement = isStatement; + function isBlockStatement(node) { + if (node.kind !== 207 /* Block */) + return false; + if (node.parent !== undefined) { + if (node.parent.kind === 224 /* TryStatement */ || node.parent.kind === 260 /* CatchClause */) { + return false; + } + } + return !ts.isFunctionBlock(node); + } // Module references /* @internal */ function isModuleReference(node) { @@ -14207,11 +14173,31 @@ var ts; var node = parseTokenNode(); return token() === 23 /* DotToken */ ? undefined : node; } - function parseLiteralTypeNode() { + function parseLiteralTypeNode(negative) { var node = createNode(173 /* LiteralType */); - node.literal = parseSimpleUnaryExpression(); - finishNode(node); - return node; + var unaryMinusExpression; + if (negative) { + unaryMinusExpression = createNode(192 /* PrefixUnaryExpression */); + unaryMinusExpression.operator = 38 /* MinusToken */; + nextToken(); + } + var expression; + switch (token()) { + case 9 /* StringLiteral */: + case 8 /* NumericLiteral */: + expression = parseLiteralLikeNode(token()); + break; + case 101 /* TrueKeyword */: + case 86 /* FalseKeyword */: + expression = parseTokenNode(); + } + if (negative) { + unaryMinusExpression.operand = expression; + finishNode(unaryMinusExpression); + expression = unaryMinusExpression; + } + node.literal = expression; + return finishNode(node); } function nextTokenIsNumericLiteral() { return nextToken() === 8 /* NumericLiteral */; @@ -14244,7 +14230,7 @@ var ts; case 86 /* FalseKeyword */: return parseLiteralTypeNode(); case 38 /* MinusToken */: - return lookAhead(nextTokenIsNumericLiteral) ? parseLiteralTypeNode() : parseTypeReference(); + return lookAhead(nextTokenIsNumericLiteral) ? parseLiteralTypeNode(/*negative*/ true) : parseTypeReference(); case 105 /* VoidKeyword */: case 95 /* NullKeyword */: return parseTokenNode(); @@ -14293,6 +14279,7 @@ var ts; case 101 /* TrueKeyword */: case 86 /* FalseKeyword */: case 134 /* ObjectKeyword */: + case 39 /* AsteriskToken */: return true; case 38 /* MinusToken */: return lookAhead(nextTokenIsNumericLiteral); @@ -14721,7 +14708,7 @@ var ts; // Didn't appear to actually be a parenthesized arrow function. Just bail out. return undefined; } - var isAsync = !!(ts.getModifierFlags(arrowFunction) & 256 /* Async */); + var isAsync = ts.hasModifier(arrowFunction, 256 /* Async */); // If we have an arrow, then try to parse the body. Even if not, try to parse if we // have an opening brace, just in case we're in an error state. var lastToken = token(); @@ -14879,7 +14866,7 @@ var ts; function parseParenthesizedArrowFunctionExpressionHead(allowAmbiguity) { var node = createNode(187 /* ArrowFunction */); node.modifiers = parseModifiersForArrowFunction(); - var isAsync = (ts.getModifierFlags(node) & 256 /* Async */) ? 2 /* Await */ : 0 /* None */; + var isAsync = ts.hasModifier(node, 256 /* Async */) ? 2 /* Await */ : 0 /* None */; // Arrow functions are never generators. // // If we're speculatively parsing a signature for a parenthesized arrow function, then @@ -15890,7 +15877,7 @@ var ts; parseExpected(89 /* FunctionKeyword */); node.asteriskToken = parseOptionalToken(39 /* AsteriskToken */); var isGenerator = node.asteriskToken ? 1 /* Yield */ : 0 /* None */; - var isAsync = (ts.getModifierFlags(node) & 256 /* Async */) ? 2 /* Await */ : 0 /* None */; + var isAsync = ts.hasModifier(node, 256 /* Async */) ? 2 /* Await */ : 0 /* None */; node.name = isGenerator && isAsync ? doInYieldAndAwaitContext(parseOptionalIdentifier) : isGenerator ? doInYieldContext(parseOptionalIdentifier) : @@ -16132,10 +16119,14 @@ var ts; function parseCatchClause() { var result = createNode(260 /* CatchClause */); parseExpected(74 /* CatchKeyword */); - if (parseExpected(19 /* OpenParenToken */)) { + if (parseOptional(19 /* OpenParenToken */)) { result.variableDeclaration = parseVariableDeclaration(); + parseExpected(20 /* CloseParenToken */); + } + else { + // Keep shape of node to avoid degrading performance. + result.variableDeclaration = undefined; } - parseExpected(20 /* CloseParenToken */); result.block = parseBlock(/*ignoreMissingOpenBrace*/ false); return finishNode(result); } @@ -17036,8 +17027,8 @@ var ts; // ImportDeclaration: // import ImportClause from ModuleSpecifier ; // import ModuleSpecifier; - if (identifier || - token() === 39 /* AsteriskToken */ || + if (identifier || // import id + token() === 39 /* AsteriskToken */ || // import * token() === 17 /* OpenBraceToken */) { importDeclaration.importClause = parseImportClause(identifier, afterImportPos); parseExpected(140 /* FromKeyword */); @@ -17345,7 +17336,7 @@ var ts; JSDocParser.parseJSDocTypeExpression = parseJSDocTypeExpression; function parseIsolatedJSDocComment(content, start, length) { initializeState(content, 5 /* Latest */, /*_syntaxCursor:*/ undefined, 1 /* JS */); - sourceFile = { languageVariant: 0 /* Standard */, text: content }; + sourceFile = { languageVariant: 0 /* Standard */, text: content }; // tslint:disable-line no-object-literal-type-assertion var jsDoc = parseJSDocCommentWorker(start, length); var diagnostics = parseDiagnostics; clearState(); @@ -18093,8 +18084,8 @@ var ts; array._children = undefined; array.pos += delta; array.end += delta; - for (var _i = 0, array_9 = array; _i < array_9.length; _i++) { - var node = array_9[_i]; + for (var _i = 0, array_8 = array; _i < array_8.length; _i++) { + var node = array_8[_i]; visitNode(node); } } @@ -18231,8 +18222,8 @@ var ts; array._children = undefined; // Adjust the pos or end (or both) of the intersecting array accordingly. adjustIntersectingElement(array, changeStart, changeRangeOldEnd, changeRangeNewEnd, delta); - for (var _i = 0, array_10 = array; _i < array_10.length; _i++) { - var node = array_10[_i]; + for (var _i = 0, array_9 = array; _i < array_9.length; _i++) { + var node = array_9[_i]; visitNode(node); } return; @@ -19201,40 +19192,23 @@ var ts; return antecedent; } setFlowNodeReferenced(antecedent); - return { - flags: flags, - expression: expression, - antecedent: antecedent - }; + return { flags: flags, expression: expression, antecedent: antecedent }; } function createFlowSwitchClause(antecedent, switchStatement, clauseStart, clauseEnd) { if (!isNarrowingExpression(switchStatement.expression)) { return antecedent; } setFlowNodeReferenced(antecedent); - return { - flags: 128 /* SwitchClause */, - switchStatement: switchStatement, - clauseStart: clauseStart, - clauseEnd: clauseEnd, - antecedent: antecedent - }; + return { flags: 128 /* SwitchClause */, switchStatement: switchStatement, clauseStart: clauseStart, clauseEnd: clauseEnd, antecedent: antecedent }; } function createFlowAssignment(antecedent, node) { setFlowNodeReferenced(antecedent); - return { - flags: 16 /* Assignment */, - antecedent: antecedent, - node: node - }; + return { flags: 16 /* Assignment */, antecedent: antecedent, node: node }; } function createFlowArrayMutation(antecedent, node) { setFlowNodeReferenced(antecedent); - return { - flags: 256 /* ArrayMutation */, - antecedent: antecedent, - node: node - }; + var res = { flags: 256 /* ArrayMutation */, antecedent: antecedent, node: node }; + return res; } function finishFlowLabel(flow) { var antecedents = flow.antecedents; @@ -20956,7 +20930,6 @@ var ts; } function computeParameter(node, subtreeFlags) { var transformFlags = subtreeFlags; - var modifierFlags = ts.getModifierFlags(node); var name = node.name; var initializer = node.initializer; var dotDotDotToken = node.dotDotDotToken; @@ -20969,7 +20942,7 @@ var ts; transformFlags |= 3 /* AssertTypeScript */; } // If a parameter has an accessibility modifier, then it is TypeScript syntax. - if (modifierFlags & 92 /* ParameterPropertyModifier */) { + if (ts.hasModifier(node, 92 /* ParameterPropertyModifier */)) { transformFlags |= 3 /* AssertTypeScript */ | 262144 /* ContainsParameterPropertyAssignments */; } // parameters with object rest destructuring are ES Next syntax @@ -21006,8 +20979,7 @@ var ts; } function computeClassDeclaration(node, subtreeFlags) { var transformFlags; - var modifierFlags = ts.getModifierFlags(node); - if (modifierFlags & 2 /* Ambient */) { + if (ts.hasModifier(node, 2 /* Ambient */)) { // An ambient declaration is TypeScript syntax. transformFlags = 3 /* AssertTypeScript */; } @@ -21068,7 +21040,10 @@ var ts; } function computeCatchClause(node, subtreeFlags) { var transformFlags = subtreeFlags; - if (node.variableDeclaration && ts.isBindingPattern(node.variableDeclaration.name)) { + if (!node.variableDeclaration) { + transformFlags |= 8 /* AssertESNext */; + } + else if (ts.isBindingPattern(node.variableDeclaration.name)) { transformFlags |= 192 /* AssertES2015 */; } node.transformFlags = transformFlags | 536870912 /* HasComputedFlags */; @@ -21283,10 +21258,9 @@ var ts; } function computeVariableStatement(node, subtreeFlags) { var transformFlags; - var modifierFlags = ts.getModifierFlags(node); var declarationListTransformFlags = node.declarationList.transformFlags; // An ambient declaration is TypeScript syntax. - if (modifierFlags & 2 /* Ambient */) { + if (ts.hasModifier(node, 2 /* Ambient */)) { transformFlags = 3 /* AssertTypeScript */; } else { @@ -21634,6 +21608,176 @@ var ts; ts.forEachChild(child, function (childsChild) { return setParentPointers(child, childsChild); }); } })(ts || (ts = {})); +/** @internal */ +var ts; +(function (ts) { + function createGetSymbolWalker(getRestTypeOfSignature, getReturnTypeOfSignature, getBaseTypes, resolveStructuredTypeMembers, getTypeOfSymbol, getResolvedSymbol, getIndexTypeOfStructuredType, getConstraintFromTypeParameter, getFirstIdentifier) { + return getSymbolWalker; + function getSymbolWalker(accept) { + if (accept === void 0) { accept = function () { return true; }; } + var visitedTypes = ts.createMap(); // Key is id as string + var visitedSymbols = ts.createMap(); // Key is id as string + return { + walkType: function (type) { + visitedTypes.clear(); + visitedSymbols.clear(); + visitType(type); + return { visitedTypes: ts.arrayFrom(visitedTypes.values()), visitedSymbols: ts.arrayFrom(visitedSymbols.values()) }; + }, + walkSymbol: function (symbol) { + visitedTypes.clear(); + visitedSymbols.clear(); + visitSymbol(symbol); + return { visitedTypes: ts.arrayFrom(visitedTypes.values()), visitedSymbols: ts.arrayFrom(visitedSymbols.values()) }; + }, + }; + function visitType(type) { + if (!type) { + return; + } + var typeIdString = type.id.toString(); + if (visitedTypes.has(typeIdString)) { + return; + } + visitedTypes.set(typeIdString, type); + // Reuse visitSymbol to visit the type's symbol, + // but be sure to bail on recuring into the type if accept declines the symbol. + var shouldBail = visitSymbol(type.symbol); + if (shouldBail) + return; + // Visit the type's related types, if any + if (type.flags & 32768 /* Object */) { + var objectType = type; + var objectFlags = objectType.objectFlags; + if (objectFlags & 4 /* Reference */) { + visitTypeReference(type); + } + if (objectFlags & 32 /* Mapped */) { + visitMappedType(type); + } + if (objectFlags & (1 /* Class */ | 2 /* Interface */)) { + visitInterfaceType(type); + } + if (objectFlags & (8 /* Tuple */ | 16 /* Anonymous */)) { + visitObjectType(objectType); + } + } + if (type.flags & 16384 /* TypeParameter */) { + visitTypeParameter(type); + } + if (type.flags & 196608 /* UnionOrIntersection */) { + visitUnionOrIntersectionType(type); + } + if (type.flags & 262144 /* Index */) { + visitIndexType(type); + } + if (type.flags & 524288 /* IndexedAccess */) { + visitIndexedAccessType(type); + } + } + function visitTypeList(types) { + if (!types) { + return; + } + for (var i = 0; i < types.length; i++) { + visitType(types[i]); + } + } + function visitTypeReference(type) { + visitType(type.target); + visitTypeList(type.typeArguments); + } + function visitTypeParameter(type) { + visitType(getConstraintFromTypeParameter(type)); + } + function visitUnionOrIntersectionType(type) { + visitTypeList(type.types); + } + function visitIndexType(type) { + visitType(type.type); + } + function visitIndexedAccessType(type) { + visitType(type.objectType); + visitType(type.indexType); + visitType(type.constraint); + } + function visitMappedType(type) { + visitType(type.typeParameter); + visitType(type.constraintType); + visitType(type.templateType); + visitType(type.modifiersType); + } + function visitSignature(signature) { + if (signature.typePredicate) { + visitType(signature.typePredicate.type); + } + visitTypeList(signature.typeParameters); + for (var _i = 0, _a = signature.parameters; _i < _a.length; _i++) { + var parameter = _a[_i]; + visitSymbol(parameter); + } + visitType(getRestTypeOfSignature(signature)); + visitType(getReturnTypeOfSignature(signature)); + } + function visitInterfaceType(interfaceT) { + visitObjectType(interfaceT); + visitTypeList(interfaceT.typeParameters); + visitTypeList(getBaseTypes(interfaceT)); + visitType(interfaceT.thisType); + } + function visitObjectType(type) { + var stringIndexType = getIndexTypeOfStructuredType(type, 0 /* String */); + visitType(stringIndexType); + var numberIndexType = getIndexTypeOfStructuredType(type, 1 /* Number */); + visitType(numberIndexType); + // The two checks above *should* have already resolved the type (if needed), so this should be cached + var resolved = resolveStructuredTypeMembers(type); + for (var _i = 0, _a = resolved.callSignatures; _i < _a.length; _i++) { + var signature = _a[_i]; + visitSignature(signature); + } + for (var _b = 0, _c = resolved.constructSignatures; _b < _c.length; _b++) { + var signature = _c[_b]; + visitSignature(signature); + } + for (var _d = 0, _e = resolved.properties; _d < _e.length; _d++) { + var p = _e[_d]; + visitSymbol(p); + } + } + function visitSymbol(symbol) { + if (!symbol) { + return; + } + var symbolIdString = ts.getSymbolId(symbol).toString(); + if (visitedSymbols.has(symbolIdString)) { + return; + } + visitedSymbols.set(symbolIdString, symbol); + if (!accept(symbol)) { + return true; + } + var t = getTypeOfSymbol(symbol); + visitType(t); // Should handle members on classes and such + if (symbol.flags & 1952 /* HasExports */) { + symbol.exports.forEach(visitSymbol); + } + ts.forEach(symbol.declarations, function (d) { + // Type queries are too far resolved when we just visit the symbol's type + // (their type resolved directly to the member deeply referenced) + // So to get the intervening symbols, we need to check if there's a type + // query node on any of the symbol's declarations and get symbols there + if (d.type && d.type.kind === 162 /* TypeQuery */) { + var query = d.type; + var entity = getResolvedSymbol(getFirstIdentifier(query.exprName)); + visitSymbol(entity); + } + }); + } + } + } + ts.createGetSymbolWalker = createGetSymbolWalker; +})(ts || (ts = {})); /// /// var ts; @@ -21647,6 +21791,12 @@ var ts; return compilerOptions.traceResolution && host.trace !== undefined; } ts.isTraceEnabled = isTraceEnabled; + function withPackageId(packageId, r) { + return r && { path: r.path, extension: r.ext, packageId: packageId }; + } + function noPackageId(r) { + return withPackageId(/*packageId*/ undefined, r); + } /** * Kinds of file that we are currently looking for. * Typically there is one pass with Extensions.TypeScript, then a second pass with Extensions.JavaScript. @@ -21667,13 +21817,12 @@ var ts; } function createResolvedModuleWithFailedLookupLocations(resolved, isExternalLibraryImport, failedLookupLocations) { return { - resolvedModule: resolved && { resolvedFileName: resolved.path, extension: resolved.extension, isExternalLibraryImport: isExternalLibraryImport }, + resolvedModule: resolved && { resolvedFileName: resolved.path, extension: resolved.extension, isExternalLibraryImport: isExternalLibraryImport, packageId: resolved.packageId }, failedLookupLocations: failedLookupLocations }; } /** Reads from "main" or "types"/"typings" depending on `extensions`. */ - function tryReadPackageJsonFields(readTypes, packageJsonPath, baseDirectory, state) { - var jsonContent = readJson(packageJsonPath, state.host); + function tryReadPackageJsonFields(readTypes, jsonContent, baseDirectory, state) { return readTypes ? tryReadFromField("typings") || tryReadFromField("types") : tryReadFromField("main"); function tryReadFromField(fieldName) { if (!ts.hasProperty(jsonContent, fieldName)) { @@ -21778,7 +21927,9 @@ var ts; } var resolvedTypeReferenceDirective; if (resolved) { - resolved = realpath(resolved, host, traceEnabled); + if (!options.preserveSymlinks) { + resolved = realPath(resolved, host, traceEnabled); + } if (traceEnabled) { trace(host, ts.Diagnostics.Type_reference_directive_0_was_successfully_resolved_to_1_primary_Colon_2, typeReferenceDirectiveName, resolved, primary); } @@ -22182,7 +22333,7 @@ var ts; if (extension !== undefined) { var path_1 = tryFile(candidate, failedLookupLocations, /*onlyRecordFailures*/ false, state); if (path_1 !== undefined) { - return { path: path_1, extension: extension }; + return { path: path_1, extension: extension, packageId: undefined }; } } return loader(extensions, candidate, failedLookupLocations, !directoryProbablyExists(ts.getDirectoryPath(candidate), state.host), state); @@ -22209,7 +22360,7 @@ var ts; function resolveJavaScriptModule(moduleName, initialDir, host) { var _a = nodeModuleNameResolverWorker(moduleName, initialDir, { moduleResolution: ts.ModuleResolutionKind.NodeJs, allowJs: true }, host, /*cache*/ undefined, /*jsOnly*/ true), resolvedModule = _a.resolvedModule, failedLookupLocations = _a.failedLookupLocations; if (!resolvedModule) { - throw new Error("Could not resolve JS module " + moduleName + " starting at " + initialDir + ". Looked in: " + failedLookupLocations.join(", ")); + throw new Error("Could not resolve JS module '" + moduleName + "' starting at '" + initialDir + "'. Looked in: " + failedLookupLocations.join(", ")); } return resolvedModule.resolvedFileName; } @@ -22235,17 +22386,24 @@ var ts; trace(host, ts.Diagnostics.Loading_module_0_from_node_modules_folder_target_file_type_1, moduleName, Extensions[extensions]); } var resolved_1 = loadModuleFromNodeModules(extensions, moduleName, containingDirectory, failedLookupLocations, state, cache); + if (!resolved_1) + return undefined; + var resolvedValue = resolved_1.value; + if (!compilerOptions.preserveSymlinks) { + resolvedValue = resolvedValue && __assign({}, resolved_1.value, { path: realPath(resolved_1.value.path, host, traceEnabled), extension: resolved_1.value.extension }); + } // For node_modules lookups, get the real path so that multiple accesses to an `npm link`-ed module do not create duplicate files. - return resolved_1 && { value: resolved_1.value && { resolved: { path: realpath(resolved_1.value.path, host, traceEnabled), extension: resolved_1.value.extension }, isExternalLibraryImport: true } }; + return { value: resolvedValue && { resolved: resolvedValue, isExternalLibraryImport: true } }; } else { - var candidate = ts.normalizePath(ts.combinePaths(containingDirectory, moduleName)); + var _a = ts.normalizePathAndParts(ts.combinePaths(containingDirectory, moduleName)), candidate = _a.path, parts = _a.parts; var resolved_2 = nodeLoadModuleByRelativeName(extensions, candidate, failedLookupLocations, /*onlyRecordFailures*/ false, state, /*considerPackageJson*/ true); - return resolved_2 && toSearchResult({ resolved: resolved_2, isExternalLibraryImport: false }); + // Treat explicit "node_modules" import as an external library import. + return resolved_2 && toSearchResult({ resolved: resolved_2, isExternalLibraryImport: ts.contains(parts, "node_modules") }); } } } - function realpath(path, host, traceEnabled) { + function realPath(path, host, traceEnabled) { if (!host.realpath) { return path; } @@ -22271,7 +22429,7 @@ var ts; } var resolvedFromFile = loadModuleFromFile(extensions, candidate, failedLookupLocations, onlyRecordFailures, state); if (resolvedFromFile) { - return resolvedFromFile; + return noPackageId(resolvedFromFile); } } if (!onlyRecordFailures) { @@ -22291,6 +22449,9 @@ var ts; return !host.directoryExists || host.directoryExists(directoryName); } ts.directoryProbablyExists = directoryProbablyExists; + function loadModuleFromFileNoPackageId(extensions, candidate, failedLookupLocations, onlyRecordFailures, state) { + return noPackageId(loadModuleFromFile(extensions, candidate, failedLookupLocations, onlyRecordFailures, state)); + } /** * @param {boolean} onlyRecordFailures - if true then function won't try to actually load files but instead record all attempts as failures. This flag is necessary * in cases when we know upfront that all load attempts will fail (because containing folder does not exists) however we still need to record all failed lookup locations. @@ -22329,9 +22490,9 @@ var ts; case Extensions.JavaScript: return tryExtension(".js" /* Js */) || tryExtension(".jsx" /* Jsx */); } - function tryExtension(extension) { - var path = tryFile(candidate + extension, failedLookupLocations, onlyRecordFailures, state); - return path && { path: path, extension: extension }; + function tryExtension(ext) { + var path = tryFile(candidate + ext, failedLookupLocations, onlyRecordFailures, state); + return path && { path: path, ext: ext }; } } /** Return the file if it exists. */ @@ -22355,12 +22516,20 @@ var ts; function loadNodeModuleFromDirectory(extensions, candidate, failedLookupLocations, onlyRecordFailures, state, considerPackageJson) { if (considerPackageJson === void 0) { considerPackageJson = true; } var directoryExists = !onlyRecordFailures && directoryProbablyExists(candidate, state.host); + var packageId; if (considerPackageJson) { var packageJsonPath = pathToPackageJson(candidate); if (directoryExists && state.host.fileExists(packageJsonPath)) { - var fromPackageJson = loadModuleFromPackageJson(packageJsonPath, extensions, candidate, failedLookupLocations, state); + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.Found_package_json_at_0, packageJsonPath); + } + var jsonContent = readJson(packageJsonPath, state.host); + if (typeof jsonContent.name === "string" && typeof jsonContent.version === "string") { + packageId = { name: jsonContent.name, version: jsonContent.version }; + } + var fromPackageJson = loadModuleFromPackageJson(jsonContent, extensions, candidate, failedLookupLocations, state); if (fromPackageJson) { - return fromPackageJson; + return withPackageId(packageId, fromPackageJson); } } else { @@ -22371,13 +22540,10 @@ var ts; failedLookupLocations.push(packageJsonPath); } } - return loadModuleFromFile(extensions, ts.combinePaths(candidate, "index"), failedLookupLocations, !directoryExists, state); + return withPackageId(packageId, loadModuleFromFile(extensions, ts.combinePaths(candidate, "index"), failedLookupLocations, !directoryExists, state)); } - function loadModuleFromPackageJson(packageJsonPath, extensions, candidate, failedLookupLocations, state) { - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.Found_package_json_at_0, packageJsonPath); - } - var file = tryReadPackageJsonFields(extensions !== Extensions.JavaScript, packageJsonPath, candidate, state); + function loadModuleFromPackageJson(jsonContent, extensions, candidate, failedLookupLocations, state) { + var file = tryReadPackageJsonFields(extensions !== Extensions.JavaScript, jsonContent, candidate, state); if (!file) { return undefined; } @@ -22395,12 +22561,17 @@ var ts; // Even if extensions is DtsOnly, we can still look up a .ts file as a result of package.json "types" var nextExtensions = extensions === Extensions.DtsOnly ? Extensions.TypeScript : extensions; // Don't do package.json lookup recursively, because Node.js' package lookup doesn't. - return nodeLoadModuleByRelativeName(nextExtensions, file, failedLookupLocations, onlyRecordFailures, state, /*considerPackageJson*/ false); + var result = nodeLoadModuleByRelativeName(nextExtensions, file, failedLookupLocations, onlyRecordFailures, state, /*considerPackageJson*/ false); + if (result) { + // It won't have a `packageId` set, because we disabled `considerPackageJson`. + ts.Debug.assert(result.packageId === undefined); + return { path: result.path, ext: result.extension }; + } } /** Resolve from an arbitrarily specified file. Return `undefined` if it has an unsupported extension. */ function resolvedIfExtensionMatches(extensions, path) { - var extension = ts.tryGetExtensionFromPath(path); - return extension !== undefined && extensionIsOk(extensions, extension) ? { path: path, extension: extension } : undefined; + var ext = ts.tryGetExtensionFromPath(path); + return ext !== undefined && extensionIsOk(extensions, ext) ? { path: path, ext: ext } : undefined; } /** True if `extension` is one of the supported `extensions`. */ function extensionIsOk(extensions, extension) { @@ -22418,7 +22589,7 @@ var ts; } function loadModuleFromNodeModulesFolder(extensions, moduleName, nodeModulesFolder, nodeModulesFolderExists, failedLookupLocations, state) { var candidate = ts.normalizePath(ts.combinePaths(nodeModulesFolder, moduleName)); - return loadModuleFromFile(extensions, candidate, failedLookupLocations, !nodeModulesFolderExists, state) || + return loadModuleFromFileNoPackageId(extensions, candidate, failedLookupLocations, !nodeModulesFolderExists, state) || loadNodeModuleFromDirectory(extensions, candidate, failedLookupLocations, !nodeModulesFolderExists, state); } function loadModuleFromNodeModules(extensions, moduleName, directory, failedLookupLocations, state, cache) { @@ -22497,7 +22668,7 @@ var ts; if (traceEnabled) { trace(host, ts.Diagnostics.Resolution_for_module_0_was_found_in_cache, moduleName); } - return { value: result.resolvedModule && { path: result.resolvedModule.resolvedFileName, extension: result.resolvedModule.extension } }; + return { value: result.resolvedModule && { path: result.resolvedModule.resolvedFileName, extension: result.resolvedModule.extension, packageId: result.resolvedModule.packageId } }; } } function classicNameResolver(moduleName, containingFile, compilerOptions, host, cache) { @@ -22508,7 +22679,7 @@ var ts; var resolved = tryResolve(Extensions.TypeScript) || tryResolve(Extensions.JavaScript); return createResolvedModuleWithFailedLookupLocations(resolved && resolved.value, /*isExternalLibraryImport*/ false, failedLookupLocations); function tryResolve(extensions) { - var resolvedUsingSettings = tryLoadModuleUsingOptionalResolutionSettings(extensions, moduleName, containingDirectory, loadModuleFromFile, failedLookupLocations, state); + var resolvedUsingSettings = tryLoadModuleUsingOptionalResolutionSettings(extensions, moduleName, containingDirectory, loadModuleFromFileNoPackageId, failedLookupLocations, state); if (resolvedUsingSettings) { return { value: resolvedUsingSettings }; } @@ -22521,7 +22692,7 @@ var ts; return resolutionFromCache; } var searchName = ts.normalizePath(ts.combinePaths(directory, moduleName)); - return toSearchResult(loadModuleFromFile(extensions, searchName, failedLookupLocations, /*onlyRecordFailures*/ false, state)); + return toSearchResult(loadModuleFromFileNoPackageId(extensions, searchName, failedLookupLocations, /*onlyRecordFailures*/ false, state)); }); if (resolved_3) { return resolved_3; @@ -22533,7 +22704,7 @@ var ts; } else { var candidate = ts.normalizePath(ts.combinePaths(containingDirectory, moduleName)); - return toSearchResult(loadModuleFromFile(extensions, candidate, failedLookupLocations, /*onlyRecordFailures*/ false, state)); + return toSearchResult(loadModuleFromFileNoPackageId(extensions, candidate, failedLookupLocations, /*onlyRecordFailures*/ false, state)); } } } @@ -22578,6 +22749,7 @@ var ts; })(ts || (ts = {})); /// /// +/// /* @internal */ var ts; (function (ts) { @@ -22705,6 +22877,9 @@ var ts; node = ts.getParseTreeNode(node, ts.isExportSpecifier); return node ? getExportSpecifierLocalTargetSymbol(node) : undefined; }, + getExportSymbolOfSymbol: function (symbol) { + return getMergedSymbol(symbol.exportSymbol || symbol); + }, getTypeAtLocation: function (node) { node = ts.getParseTreeNode(node); return node ? getTypeOfNode(node) : unknownType; @@ -22767,6 +22942,7 @@ var ts; getEmitResolver: getEmitResolver, getExportsOfModule: getExportsOfModuleAsArray, getExportsAndPropertiesOfModule: getExportsAndPropertiesOfModule, + getSymbolWalker: ts.createGetSymbolWalker(getRestTypeOfSignature, getReturnTypeOfSignature, getBaseTypes, resolveStructuredTypeMembers, getTypeOfSymbol, getResolvedSymbol, getIndexTypeOfStructuredType, getConstraintFromTypeParameter, getFirstIdentifier), getAmbientModules: getAmbientModules, getAllAttributesTypeFromJsxOpeningLikeElement: function (node) { node = ts.getParseTreeNode(node, ts.isJsxOpeningLikeElement); @@ -22789,11 +22965,10 @@ var ts; getSuggestionForNonexistentProperty: function (node, type) { return ts.unescapeLeadingUnderscores(getSuggestionForNonexistentProperty(node, type)); }, getSuggestionForNonexistentSymbol: function (location, name, meaning) { return ts.unescapeLeadingUnderscores(getSuggestionForNonexistentSymbol(location, ts.escapeLeadingUnderscores(name), meaning)); }, getBaseConstraintOfType: getBaseConstraintOfType, - getJsxNamespace: function () { return ts.unescapeLeadingUnderscores(getJsxNamespace()); }, - resolveNameAtLocation: function (location, name, meaning) { - location = ts.getParseTreeNode(location); - return resolveName(location, ts.escapeLeadingUnderscores(name), meaning, /*nameNotFoundMessage*/ undefined, ts.escapeLeadingUnderscores(name)); + resolveName: function (name, location, meaning) { + return resolveName(location, ts.escapeLeadingUnderscores(name), meaning, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined); }, + getJsxNamespace: function () { return ts.unescapeLeadingUnderscores(getJsxNamespace()); }, }; var tupleTypes = []; var unionTypes = ts.createMap(); @@ -23324,12 +23499,17 @@ var ts; // 2. inside a function // 3. inside an instance property initializer, a reference to a non-instance property // 4. inside a static property initializer, a reference to a static method in the same class + // 5. inside a TS export= declaration (since we will move the export statement during emit to avoid TDZ) // or if usage is in a type context: // 1. inside a type query (typeof in type position) - if (usage.parent.kind === 246 /* ExportSpecifier */) { + if (usage.parent.kind === 246 /* ExportSpecifier */ || (usage.parent.kind === 243 /* ExportAssignment */ && usage.parent.isExportEquals)) { // export specifiers do not use the variable, they only make it available for use return true; } + // When resolving symbols for exports, the `usage` location passed in can be the export site directly + if (usage.kind === 243 /* ExportAssignment */ && usage.isExportEquals) { + return true; + } var container = ts.getEnclosingBlockScopeContainer(declaration); return isInTypeQuery(usage) || isUsedInFunctionOrInstanceProperty(usage, declaration, container); function isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage) { @@ -23360,13 +23540,13 @@ var ts; current.parent.kind === 149 /* PropertyDeclaration */ && current.parent.initializer === current; if (initializerOfProperty) { - if (ts.getModifierFlags(current.parent) & 32 /* Static */) { + if (ts.hasModifier(current.parent, 32 /* Static */)) { if (declaration.kind === 151 /* MethodDeclaration */) { return true; } } else { - var isDeclarationInstanceProperty = declaration.kind === 149 /* PropertyDeclaration */ && !(ts.getModifierFlags(declaration) & 32 /* Static */); + var isDeclarationInstanceProperty = declaration.kind === 149 /* PropertyDeclaration */ && !ts.hasModifier(declaration, 32 /* Static */); if (!isDeclarationInstanceProperty || ts.getContainingClass(usage) !== ts.getContainingClass(declaration)) { return true; } @@ -23480,7 +23660,7 @@ var ts; // local variables of the constructor. This effectively means that entities from outer scopes // by the same name as a constructor parameter or local variable are inaccessible // in initializer expressions for instance member variables. - if (ts.isClassLike(location.parent) && !(ts.getModifierFlags(location) & 32 /* Static */)) { + if (ts.isClassLike(location.parent) && !ts.hasModifier(location, 32 /* Static */)) { var ctor = findConstructorDeclaration(location.parent); if (ctor && ctor.locals) { if (lookup(ctor.locals, name, meaning & 107455 /* Value */)) { @@ -23499,7 +23679,7 @@ var ts; result = undefined; break; } - if (lastLocation && ts.getModifierFlags(lastLocation) & 32 /* Static */) { + if (lastLocation && ts.hasModifier(lastLocation, 32 /* Static */)) { // TypeScript 1.0 spec (April 2014): 3.4.1 // The scope of a type parameter extends over the entire declaration with which the type // parameter list is associated, with the exception of static member declarations in classes. @@ -23516,6 +23696,18 @@ var ts; } } break; + case 201 /* ExpressionWithTypeArguments */: + // The type parameters of a class are not in scope in the base class expression. + if (lastLocation === location.expression && location.parent.token === 85 /* ExtendsKeyword */) { + var container = location.parent.parent; + if (ts.isClassLike(container) && (result = lookup(getSymbolOfNode(container).members, name, meaning & 793064 /* Type */))) { + if (nameNotFoundMessage) { + error(errorLocation, ts.Diagnostics.Base_class_expressions_cannot_reference_class_type_parameters); + } + return undefined; + } + } + break; // It is not legal to reference a class's own type parameters from a computed property name that // belongs to the class. For example: // @@ -23585,7 +23777,10 @@ var ts; lastLocation = location; location = location.parent; } - if (result && nameNotFoundMessage && noUnusedIdentifiers) { + // We just climbed up parents looking for the name, meaning that we started in a descendant node of `lastLocation`. + // If `result === lastLocation.symbol`, that means that we are somewhere inside `lastLocation` looking up a name, and resolving to `lastLocation` itself. + // That means that this is a self-reference of `lastLocation`, and shouldn't count this when considering whether `lastLocation` is used. + if (result && nameNotFoundMessage && noUnusedIdentifiers && result !== lastLocation.symbol) { result.isReferenced = true; } if (!result) { @@ -23684,7 +23879,7 @@ var ts; } // No static member is present. // Check if we're in an instance method and look for a relevant instance member. - if (location === container && !(ts.getModifierFlags(location) & 32 /* Static */)) { + if (location === container && !ts.hasModifier(location, 32 /* Static */)) { var instanceType = getDeclaredTypeOfSymbol(classSymbol).thisType; if (getPropertyOfType(instanceType, name)) { error(errorLocation, ts.Diagnostics.Cannot_find_name_0_Did_you_mean_the_instance_member_this_0, diagnosticName(nameArg)); @@ -24130,7 +24325,6 @@ var ts; if (ambientModule) { return ambientModule; } - var isRelative = ts.isExternalModuleNameRelative(moduleReference); var resolvedModule = ts.getResolvedModule(ts.getSourceFileOfNode(location), moduleReference); var resolutionDiagnostic = resolvedModule && ts.getResolutionDiagnostic(compilerOptions, resolvedModule); var sourceFile = resolvedModule && !resolutionDiagnostic && host.getSourceFile(resolvedModule.resolvedFileName); @@ -24152,7 +24346,7 @@ var ts; } } // May be an untyped module. If so, ignore resolutionDiagnostic. - if (!isRelative && resolvedModule && !ts.extensionIsTypeScript(resolvedModule.extension)) { + if (resolvedModule && resolvedModule.isExternalLibraryImport && !ts.extensionIsTypeScript(resolvedModule.extension)) { if (isForAugmentation) { var diag = ts.Diagnostics.Invalid_module_name_in_augmentation_Module_0_resolves_to_an_untyped_module_at_1_which_cannot_be_augmented; error(errorNode, diag, moduleReference, resolvedModule.resolvedFileName); @@ -24186,7 +24380,7 @@ var ts; // An external module with an 'export =' declaration resolves to the target of the 'export =' declaration, // and an external module with no 'export =' declaration resolves to the module itself. function resolveExternalModuleSymbol(moduleSymbol, dontResolveAlias) { - return moduleSymbol && getMergedSymbol(resolveSymbol(moduleSymbol.exports.get("export="), dontResolveAlias)) || moduleSymbol; + return moduleSymbol && getMergedSymbol(resolveSymbol(moduleSymbol.exports.get("export=" /* ExportEquals */), dontResolveAlias)) || moduleSymbol; } // An external module with an 'export =' declaration may be referenced as an ES6 module provided the 'export =' // references a symbol that is at least declared as a module or a variable. The target of the 'export =' may @@ -24199,7 +24393,7 @@ var ts; return symbol; } function hasExportAssignmentSymbol(moduleSymbol) { - return moduleSymbol.exports.get("export=") !== undefined; + return moduleSymbol.exports.get("export=" /* ExportEquals */) !== undefined; } function getExportsOfModuleAsArray(moduleSymbol) { return symbolsToArray(getExportsOfModule(moduleSymbol)); @@ -24461,7 +24655,7 @@ var ts; if (symbolFromSymbolTable.flags & 2097152 /* Alias */ && symbolFromSymbolTable.escapedName !== "export=" && !ts.getDeclarationOfKind(symbolFromSymbolTable, 246 /* ExportSpecifier */)) { - if (!useOnlyExternalAliasing || + if (!useOnlyExternalAliasing || // We can use any type of alias to get the name // Is this external alias, then use it to name ts.forEach(symbolFromSymbolTable.declarations, ts.isExternalModuleImportEqualsDeclaration)) { var resolvedImportedSymbol = resolveAlias(symbolFromSymbolTable); @@ -24526,6 +24720,10 @@ var ts; } return false; } + function isTypeSymbolAccessible(typeSymbol, enclosingDeclaration) { + var access = isSymbolAccessible(typeSymbol, enclosingDeclaration, 793064 /* Type */, /*shouldComputeAliasesToMakeVisible*/ false); + return access.accessibility === 0 /* Accessible */; + } /** * Check if the given symbol in given enclosing declaration is accessible and mark all associated alias to be visible if requested * @@ -24608,7 +24806,7 @@ var ts; // because these kind of aliases can be used to name types in declaration file var anyImportSyntax = getAnyImportSyntax(declaration); if (anyImportSyntax && - !(ts.getModifierFlags(anyImportSyntax) & 1 /* Export */) && + !ts.hasModifier(anyImportSyntax, 1 /* Export */) && // import clause without export isDeclarationVisible(anyImportSyntax.parent)) { // In function "buildTypeDisplay" where we decide whether to write type-alias or serialize types, // we want to just check if type- alias is accessible or not but we don't care about emitting those alias at that time @@ -24817,8 +25015,7 @@ var ts; // Ignore constraint/default when creating a usage (as opposed to declaration) of a type parameter. return ts.createTypeReferenceNode(name, /*typeArguments*/ undefined); } - if (!inTypeAlias && type.aliasSymbol && - isSymbolAccessible(type.aliasSymbol, context.enclosingDeclaration, 793064 /* Type */, /*shouldComputeAliasesToMakeVisible*/ false).accessibility === 0 /* Accessible */) { + if (!inTypeAlias && type.aliasSymbol && isTypeSymbolAccessible(type.aliasSymbol, context.enclosingDeclaration)) { var name = symbolToTypeReferenceName(type.aliasSymbol); var typeArgumentNodes = mapToTypeNodes(type.aliasTypeArguments, context); return ts.createTypeReferenceNode(name, typeArgumentNodes); @@ -24900,10 +25097,10 @@ var ts; return createTypeNodeFromObjectType(type); } function shouldWriteTypeOfFunctionSymbol() { - var isStaticMethodSymbol = !!(symbol.flags & 8192 /* Method */ && - ts.forEach(symbol.declarations, function (declaration) { return ts.getModifierFlags(declaration) & 32 /* Static */; })); + var isStaticMethodSymbol = !!(symbol.flags & 8192 /* Method */) && // typeof static method + ts.some(symbol.declarations, function (declaration) { return ts.hasModifier(declaration, 32 /* Static */); }); var isNonLocalFunctionSymbol = !!(symbol.flags & 16 /* Function */) && - (symbol.parent || + (symbol.parent || // is exported function symbol ts.forEach(symbol.declarations, function (declaration) { return declaration.parent.kind === 265 /* SourceFile */ || declaration.parent.kind === 234 /* ModuleBlock */; })); @@ -24914,10 +25111,8 @@ var ts; } } function createTypeNodeFromObjectType(type) { - if (type.objectFlags & 32 /* Mapped */) { - if (getConstraintTypeFromMappedType(type).flags & (16384 /* TypeParameter */ | 262144 /* Index */)) { - return createMappedTypeNodeFromType(type); - } + if (isGenericMappedType(type)) { + return createMappedTypeNodeFromType(type); } var resolved = resolveStructuredTypeMembers(type); if (!resolved.properties.length && !resolved.stringIndexInfo && !resolved.numberIndexInfo) { @@ -25505,7 +25700,7 @@ var ts; buildSymbolDisplay(type.symbol, writer, enclosingDeclaration, 793064 /* Type */, 0 /* None */, nextFlags); } else if (!(flags & 1024 /* InTypeAlias */) && type.aliasSymbol && - isSymbolAccessible(type.aliasSymbol, enclosingDeclaration, 793064 /* Type */, /*shouldComputeAliasesToMakeVisible*/ false).accessibility === 0 /* Accessible */) { + ((flags & 65536 /* UseAliasDefinedOutsideCurrentScope */) || isTypeSymbolAccessible(type.aliasSymbol, enclosingDeclaration))) { var typeArguments = type.aliasTypeArguments; writeSymbolTypeReference(type.aliasSymbol, typeArguments, 0, ts.length(typeArguments), nextFlags); } @@ -25667,9 +25862,7 @@ var ts; if (!symbolStack) { symbolStack = []; } - var isConstructorObject = type.flags & 32768 /* Object */ && - getObjectFlags(type) & 16 /* Anonymous */ && - type.symbol && type.symbol.flags & 32 /* Class */; + var isConstructorObject = type.objectFlags & 16 /* Anonymous */ && type.symbol && type.symbol.flags & 32 /* Class */; if (isConstructorObject) { writeLiteralType(type, flags); } @@ -25685,17 +25878,17 @@ var ts; writeLiteralType(type, flags); } function shouldWriteTypeOfFunctionSymbol() { - var isStaticMethodSymbol = !!(symbol.flags & 8192 /* Method */ && - ts.forEach(symbol.declarations, function (declaration) { return ts.getModifierFlags(declaration) & 32 /* Static */; })); + var isStaticMethodSymbol = !!(symbol.flags & 8192 /* Method */) && // typeof static method + ts.some(symbol.declarations, function (declaration) { return ts.hasModifier(declaration, 32 /* Static */); }); var isNonLocalFunctionSymbol = !!(symbol.flags & 16 /* Function */) && - (symbol.parent || - ts.forEach(symbol.declarations, function (declaration) { + (symbol.parent || // is exported function symbol + ts.some(symbol.declarations, function (declaration) { return declaration.parent.kind === 265 /* SourceFile */ || declaration.parent.kind === 234 /* ModuleBlock */; })); if (isStaticMethodSymbol || isNonLocalFunctionSymbol) { // typeof is allowed only for static/non local functions - return !!(flags & 4 /* UseTypeOfFunction */) || - (ts.contains(symbolStack, symbol)); // it is type of the symbol uses itself recursively + return !!(flags & 4 /* UseTypeOfFunction */) || // use typeof if format flags specify it + ts.contains(symbolStack, symbol); // it is type of the symbol uses itself recursively } } } @@ -25733,11 +25926,9 @@ var ts; return false; } function writeLiteralType(type, flags) { - if (type.objectFlags & 32 /* Mapped */) { - if (getConstraintTypeFromMappedType(type).flags & (16384 /* TypeParameter */ | 262144 /* Index */)) { - writeMappedType(type); - return; - } + if (isGenericMappedType(type)) { + writeMappedType(type); + return; } var resolved = resolveStructuredTypeMembers(type); if (!resolved.properties.length && !resolved.stringIndexInfo && !resolved.numberIndexInfo) { @@ -26113,7 +26304,7 @@ var ts; case 154 /* SetAccessor */: case 151 /* MethodDeclaration */: case 150 /* MethodSignature */: - if (ts.getModifierFlags(node) & (8 /* Private */ | 16 /* Protected */)) { + if (ts.hasModifier(node, 8 /* Private */ | 16 /* Protected */)) { // Private/protected properties/methods are not visible return false; } @@ -26910,8 +27101,8 @@ var ts; // The function allocates a new array if the input type parameter set is undefined, but otherwise it modifies the set // in-place and returns the same array. function appendTypeParameters(typeParameters, declarations) { - for (var _i = 0, declarations_3 = declarations; _i < declarations_3.length; _i++) { - var declaration = declarations_3[_i]; + for (var _i = 0, declarations_2 = declarations; _i < declarations_2.length; _i++) { + var declaration = declarations_2[_i]; var tp = getDeclaredTypeOfTypeParameter(getSymbolOfNode(declaration)); if (!typeParameters) { typeParameters = [tp]; @@ -27055,7 +27246,7 @@ var ts; return type.resolvedBaseTypes; } function resolveBaseTypesOfClass(type) { - type.resolvedBaseTypes = type.resolvedBaseTypes || ts.emptyArray; + type.resolvedBaseTypes = ts.emptyArray; var baseConstructorType = getApparentType(getBaseConstructorTypeOfClass(type)); if (!(baseConstructorType.flags & (32768 /* Object */ | 131072 /* Intersection */ | 1 /* Any */))) { return; @@ -27104,12 +27295,7 @@ var ts; error(valueDecl, ts.Diagnostics.Type_0_recursively_references_itself_as_a_base_type, typeToString(type, /*enclosingDeclaration*/ undefined, 1 /* WriteArrayAsGenericType */)); return; } - if (type.resolvedBaseTypes === ts.emptyArray) { - type.resolvedBaseTypes = [baseType]; - } - else { - type.resolvedBaseTypes.push(baseType); - } + type.resolvedBaseTypes = [baseType]; } function areAllOuterTypeParametersApplied(type) { // An unapplied type parameter has its symbol still the same as the matching argument symbol. @@ -27221,7 +27407,9 @@ var ts; if (!pushTypeResolution(symbol, 2 /* DeclaredType */)) { return unknownType; } - var declaration = ts.findDeclaration(symbol, function (d) { return d.kind === 283 /* JSDocTypedefTag */ || d.kind === 231 /* TypeAliasDeclaration */; }); + var declaration = ts.find(symbol.declarations, function (d) { + return d.kind === 283 /* JSDocTypedefTag */ || d.kind === 231 /* TypeAliasDeclaration */; + }); var type = getTypeFromTypeNode(declaration.kind === 283 /* JSDocTypedefTag */ ? declaration.typeExpression : declaration.type); if (popTypeResolution()) { var typeParameters = getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol); @@ -27753,17 +27941,12 @@ var ts; else { // Combinations of function, class, enum and module var members = emptySymbols; - var constructSignatures = ts.emptyArray; var stringIndexInfo = undefined; if (symbol.exports) { members = getExportsOfSymbol(symbol); } if (symbol.flags & 32 /* Class */) { var classType = getDeclaredTypeOfClassOrInterface(symbol); - constructSignatures = getSignaturesOfSymbol(symbol.members.get("__constructor" /* Constructor */)); - if (!constructSignatures.length) { - constructSignatures = getDefaultConstructSignatures(classType); - } var baseConstructorType = getBaseConstructorTypeOfClass(classType); if (baseConstructorType.flags & (32768 /* Object */ | 131072 /* Intersection */ | 540672 /* TypeVariable */)) { members = ts.createSymbolTable(getNamedMembers(members)); @@ -27774,7 +27957,7 @@ var ts; } } var numberIndexInfo = symbol.flags & 384 /* Enum */ ? enumNumberIndexInfo : undefined; - setStructuredTypeMembers(type, members, ts.emptyArray, constructSignatures, stringIndexInfo, numberIndexInfo); + setStructuredTypeMembers(type, members, ts.emptyArray, ts.emptyArray, stringIndexInfo, numberIndexInfo); // We resolve the members before computing the signatures because a signature may use // typeof with a qualified name expression that circularly references the type we are // in the process of resolving (see issue #6072). The temporarily empty signature list @@ -27782,6 +27965,15 @@ var ts; if (symbol.flags & (16 /* Function */ | 8192 /* Method */)) { type.callSignatures = getSignaturesOfSymbol(symbol); } + // And likewise for construct signatures for classes + if (symbol.flags & 32 /* Class */) { + var classType = getDeclaredTypeOfClassOrInterface(symbol); + var constructSignatures = getSignaturesOfSymbol(symbol.members.get("__constructor" /* Constructor */)); + if (!constructSignatures.length) { + constructSignatures = getDefaultConstructSignatures(classType); + } + type.constructSignatures = constructSignatures; + } } } /** Resolve the members of a mapped type { [P in K]: T } */ @@ -27883,8 +28075,7 @@ var ts; return getObjectFlags(type) & 32 /* Mapped */ && !!type.declaration.questionToken; } function isGenericMappedType(type) { - return getObjectFlags(type) & 32 /* Mapped */ && - maybeTypeOfKind(getConstraintTypeFromMappedType(type), 540672 /* TypeVariable */ | 262144 /* Index */); + return getObjectFlags(type) & 32 /* Mapped */ && isGenericIndexType(getConstraintTypeFromMappedType(type)); } function resolveStructuredTypeMembers(type) { if (!type.members) { @@ -27990,6 +28181,10 @@ var ts; return hasNonCircularBaseConstraint(typeParameter) ? getConstraintFromTypeParameter(typeParameter) : undefined; } function getConstraintOfIndexedAccess(type) { + var transformed = getTransformedIndexedAccessType(type); + if (transformed) { + return transformed; + } var baseObjectType = getBaseConstraintOfType(type.objectType); var baseIndexType = getBaseConstraintOfType(type.indexType); return baseObjectType || baseIndexType ? getIndexedAccessType(baseObjectType || type.objectType, baseIndexType || type.indexType) : undefined; @@ -28057,11 +28252,18 @@ var ts; return stringType; } if (t.flags & 524288 /* IndexedAccess */) { + var transformed = getTransformedIndexedAccessType(t); + if (transformed) { + return getBaseConstraint(transformed); + } var baseObjectType = getBaseConstraint(t.objectType); var baseIndexType = getBaseConstraint(t.indexType); var baseIndexedAccess = baseObjectType && baseIndexType ? getIndexedAccessType(baseObjectType, baseIndexType) : undefined; return baseIndexedAccess && baseIndexedAccess !== unknownType ? getBaseConstraint(baseIndexedAccess) : undefined; } + if (isGenericMappedType(t)) { + return emptyObjectType; + } return t; } } @@ -28608,6 +28810,9 @@ var ts; } return signature.resolvedReturnType; } + function isResolvingReturnTypeOfSignature(signature) { + return !signature.resolvedReturnType && findResolutionCycleStartIndex(signature, 3 /* ResolvedReturnType */) >= 0; + } function getRestTypeOfSignature(signature) { if (signature.hasRestParameter) { var type = getTypeOfSymbol(ts.lastOrUndefined(signature.parameters)); @@ -28680,7 +28885,7 @@ var ts; function getIndexInfoOfSymbol(symbol, kind) { var declaration = getIndexDeclarationOfSymbol(symbol, kind); if (declaration) { - return createIndexInfo(declaration.type ? getTypeFromTypeNode(declaration.type) : anyType, (ts.getModifierFlags(declaration) & 64 /* Readonly */) !== 0, declaration); + return createIndexInfo(declaration.type ? getTypeFromTypeNode(declaration.type) : anyType, ts.hasModifier(declaration, 64 /* Readonly */), declaration); } return undefined; } @@ -28978,8 +29183,8 @@ var ts; function getTypeOfGlobalSymbol(symbol, arity) { function getTypeDeclaration(symbol) { var declarations = symbol.declarations; - for (var _i = 0, declarations_4 = declarations; _i < declarations_4.length; _i++) { - var declaration = declarations_4[_i]; + for (var _i = 0, declarations_3 = declarations; _i < declarations_3.length; _i++) { + var declaration = declarations_3[_i]; switch (declaration.kind) { case 229 /* ClassDeclaration */: case 230 /* InterfaceDeclaration */: @@ -29475,17 +29680,16 @@ var ts; return getTypeOfSymbol(prop); } } - if (isTypeAnyOrAllConstituentTypesHaveKind(indexType, 262178 /* StringLike */ | 84 /* NumberLike */ | 512 /* ESSymbol */)) { + if (!(indexType.flags & 6144 /* Nullable */) && isTypeAssignableToKind(indexType, 262178 /* StringLike */ | 84 /* NumberLike */ | 512 /* ESSymbol */)) { if (isTypeAny(objectType)) { return anyType; } - var indexInfo = isTypeAnyOrAllConstituentTypesHaveKind(indexType, 84 /* NumberLike */) && getIndexInfoOfType(objectType, 1 /* Number */) || + var indexInfo = isTypeAssignableToKind(indexType, 84 /* NumberLike */) && getIndexInfoOfType(objectType, 1 /* Number */) || getIndexInfoOfType(objectType, 0 /* String */) || undefined; if (indexInfo) { if (accessExpression && indexInfo.isReadonly && (ts.isAssignmentTarget(accessExpression) || ts.isDeleteTarget(accessExpression))) { error(accessExpression, ts.Diagnostics.Index_signature_in_type_0_only_permits_reading, typeToString(objectType)); - return unknownType; } return indexInfo.type; } @@ -29517,35 +29721,84 @@ var ts; return anyType; } function getIndexedAccessForMappedType(type, indexType, accessNode) { - var accessExpression = accessNode && accessNode.kind === 180 /* ElementAccessExpression */ ? accessNode : undefined; - if (accessExpression && ts.isAssignmentTarget(accessExpression) && type.declaration.readonlyToken) { - error(accessExpression, ts.Diagnostics.Index_signature_in_type_0_only_permits_reading, typeToString(type)); - return unknownType; + if (accessNode) { + // Check if the index type is assignable to 'keyof T' for the object type. + if (!isTypeAssignableTo(indexType, getIndexType(type))) { + error(accessNode, ts.Diagnostics.Type_0_cannot_be_used_to_index_type_1, typeToString(indexType), typeToString(type)); + return unknownType; + } + if (accessNode.kind === 180 /* ElementAccessExpression */ && ts.isAssignmentTarget(accessNode) && type.declaration.readonlyToken) { + error(accessNode, ts.Diagnostics.Index_signature_in_type_0_only_permits_reading, typeToString(type)); + } } var mapper = createTypeMapper([getTypeParameterFromMappedType(type)], [indexType]); var templateMapper = type.mapper ? combineTypeMappers(type.mapper, mapper) : mapper; return instantiateType(getTemplateTypeFromMappedType(type), templateMapper); } + function isGenericObjectType(type) { + return type.flags & 540672 /* TypeVariable */ ? true : + getObjectFlags(type) & 32 /* Mapped */ ? isGenericIndexType(getConstraintTypeFromMappedType(type)) : + type.flags & 196608 /* UnionOrIntersection */ ? ts.forEach(type.types, isGenericObjectType) : + false; + } + function isGenericIndexType(type) { + return type.flags & (540672 /* TypeVariable */ | 262144 /* Index */) ? true : + type.flags & 196608 /* UnionOrIntersection */ ? ts.forEach(type.types, isGenericIndexType) : + false; + } + // Return true if the given type is a non-generic object type with a string index signature and no + // other members. + function isStringIndexOnlyType(type) { + if (type.flags & 32768 /* Object */ && !isGenericMappedType(type)) { + var t = resolveStructuredTypeMembers(type); + return t.properties.length === 0 && + t.callSignatures.length === 0 && t.constructSignatures.length === 0 && + t.stringIndexInfo && !t.numberIndexInfo; + } + return false; + } + // Given an indexed access type T[K], if T is an intersection containing one or more generic types and one or + // more object types with only a string index signature, e.g. '(U & V & { [x: string]: D })[K]', return a + // transformed type of the form '(U & V)[K] | D'. This allows us to properly reason about higher order indexed + // access types with default property values as expressed by D. + function getTransformedIndexedAccessType(type) { + var objectType = type.objectType; + if (objectType.flags & 131072 /* Intersection */ && isGenericObjectType(objectType) && ts.some(objectType.types, isStringIndexOnlyType)) { + var regularTypes = []; + var stringIndexTypes = []; + for (var _i = 0, _a = objectType.types; _i < _a.length; _i++) { + var t = _a[_i]; + if (isStringIndexOnlyType(t)) { + stringIndexTypes.push(getIndexTypeOfType(t, 0 /* String */)); + } + else { + regularTypes.push(t); + } + } + return getUnionType([ + getIndexedAccessType(getIntersectionType(regularTypes), type.indexType), + getIntersectionType(stringIndexTypes) + ]); + } + return undefined; + } function getIndexedAccessType(objectType, indexType, accessNode) { - // If the index type is generic, if the object type is generic and doesn't originate in an expression, - // or if the object type is a mapped type with a generic constraint, we are performing a higher-order - // index access where we cannot meaningfully access the properties of the object type. Note that for a - // generic T and a non-generic K, we eagerly resolve T[K] if it originates in an expression. This is to - // preserve backwards compatibility. For example, an element access 'this["foo"]' has always been resolved - // eagerly using the constraint type of 'this' at the given location. - if (maybeTypeOfKind(indexType, 540672 /* TypeVariable */ | 262144 /* Index */) || - maybeTypeOfKind(objectType, 540672 /* TypeVariable */) && !(accessNode && accessNode.kind === 180 /* ElementAccessExpression */) || - isGenericMappedType(objectType)) { + // If the object type is a mapped type { [P in K]: E }, where K is generic, we instantiate E using a mapper + // that substitutes the index type for P. For example, for an index access { [P in K]: Box }[X], we + // construct the type Box. + if (isGenericMappedType(objectType)) { + return getIndexedAccessForMappedType(objectType, indexType, accessNode); + } + // Otherwise, if the index type is generic, or if the object type is generic and doesn't originate in an + // expression, we are performing a higher-order index access where we cannot meaningfully access the properties + // of the object type. Note that for a generic T and a non-generic K, we eagerly resolve T[K] if it originates + // in an expression. This is to preserve backwards compatibility. For example, an element access 'this["foo"]' + // has always been resolved eagerly using the constraint type of 'this' at the given location. + if (isGenericIndexType(indexType) || !(accessNode && accessNode.kind === 180 /* ElementAccessExpression */) && isGenericObjectType(objectType)) { if (objectType.flags & 1 /* Any */) { return objectType; } - // If the object type is a mapped type { [P in K]: E }, we instantiate E using a mapper that substitutes - // the index type for P. For example, for an index access { [P in K]: Box }[X], we construct the - // type Box. - if (isGenericMappedType(objectType)) { - return getIndexedAccessForMappedType(objectType, indexType, accessNode); - } - // Otherwise we defer the operation by creating an indexed access type. + // Defer the operation by creating an indexed access type. var id = objectType.id + "," + indexType.id; var type = indexedAccessTypes.get(id); if (!type) { @@ -29759,7 +30012,7 @@ var ts; var container = ts.getThisContainer(node, /*includeArrowFunctions*/ false); var parent = container && container.parent; if (parent && (ts.isClassLike(parent) || parent.kind === 230 /* InterfaceDeclaration */)) { - if (!(ts.getModifierFlags(container) & 32 /* Static */) && + if (!ts.hasModifier(container, 32 /* Static */) && (container.kind !== 152 /* Constructor */ || ts.isNodeDescendantOf(node, container.body))) { return getDeclaredTypeOfClassOrInterface(getSymbolOfNode(parent)).thisType; } @@ -29912,7 +30165,7 @@ var ts; } function cloneTypeMapper(mapper) { return mapper && isInferenceContext(mapper) ? - createInferenceContext(mapper.signature, mapper.flags | 2 /* NoDefault */, mapper.inferences) : + createInferenceContext(mapper.signature, mapper.flags | 2 /* NoDefault */, mapper.compareTypes, mapper.inferences) : mapper; } function identityMapper(type) { @@ -30222,16 +30475,16 @@ var ts; if (ts.forEach(node.parameters, function (p) { return !ts.getEffectiveTypeAnnotationNode(p); })) { return true; } - // For arrow functions we now know we're not context sensitive. - if (node.kind === 187 /* ArrowFunction */) { - return false; + if (node.kind !== 187 /* ArrowFunction */) { + // If the first parameter is not an explicit 'this' parameter, then the function has + // an implicit 'this' parameter which is subject to contextual typing. + var parameter = ts.firstOrUndefined(node.parameters); + if (!(parameter && ts.parameterIsThisKeyword(parameter))) { + return true; + } } - // If the first parameter is not an explicit 'this' parameter, then the function has - // an implicit 'this' parameter which is subject to contextual typing. Otherwise we - // know that all parameters (including 'this') have type annotations and nothing is - // subject to contextual typing. - var parameter = ts.firstOrUndefined(node.parameters); - return !(parameter && ts.parameterIsThisKeyword(parameter)); + // TODO(anhans): A block should be context-sensitive if it has a context-sensitive return value. + return node.body.kind === 207 /* Block */ ? false : isContextSensitive(node.body); } function isContextSensitiveFunctionOrObjectLiteralMethod(func) { return (isFunctionExpressionOrArrowFunction(func) || ts.isObjectLiteralMethod(func)) && isContextSensitiveFunctionLikeDeclaration(func); @@ -30317,7 +30570,7 @@ var ts; return 0 /* False */; } if (source.typeParameters) { - source = instantiateSignatureInContextOf(source, target); + source = instantiateSignatureInContextOf(source, target, /*contextualMapper*/ undefined, compareTypes); } var result = -1 /* True */; var sourceThisType = getThisTypeOfSignature(source); @@ -30376,7 +30629,7 @@ var ts; // The following block preserves behavior forbidding boolean returning functions from being assignable to type guard returning functions if (target.typePredicate) { if (source.typePredicate) { - result &= compareTypePredicateRelatedTo(source.typePredicate, target.typePredicate, reportErrors, errorReporter, compareTypes); + result &= compareTypePredicateRelatedTo(source.typePredicate, target.typePredicate, source.declaration, target.declaration, reportErrors, errorReporter, compareTypes); } else if (ts.isIdentifierTypePredicate(target.typePredicate)) { if (reportErrors) { @@ -30395,7 +30648,7 @@ var ts; } return result; } - function compareTypePredicateRelatedTo(source, target, reportErrors, errorReporter, compareTypes) { + function compareTypePredicateRelatedTo(source, target, sourceDeclaration, targetDeclaration, reportErrors, errorReporter, compareTypes) { if (source.kind !== target.kind) { if (reportErrors) { errorReporter(ts.Diagnostics.A_this_based_type_guard_is_not_compatible_with_a_parameter_based_type_guard); @@ -30404,11 +30657,13 @@ var ts; return 0 /* False */; } if (source.kind === 1 /* Identifier */) { - var sourceIdentifierPredicate = source; - var targetIdentifierPredicate = target; - if (sourceIdentifierPredicate.parameterIndex !== targetIdentifierPredicate.parameterIndex) { + var sourcePredicate = source; + var targetPredicate = target; + var sourceIndex = sourcePredicate.parameterIndex - (ts.getThisParameter(sourceDeclaration) ? 1 : 0); + var targetIndex = targetPredicate.parameterIndex - (ts.getThisParameter(targetDeclaration) ? 1 : 0); + if (sourceIndex !== targetIndex) { if (reportErrors) { - errorReporter(ts.Diagnostics.Parameter_0_is_not_in_the_same_position_as_parameter_1, sourceIdentifierPredicate.parameterName, targetIdentifierPredicate.parameterName); + errorReporter(ts.Diagnostics.Parameter_0_is_not_in_the_same_position_as_parameter_1, sourcePredicate.parameterName, targetPredicate.parameterName); errorReporter(ts.Diagnostics.Type_predicate_0_is_not_assignable_to_1, typePredicateToString(source), typePredicateToString(target)); } return 0 /* False */; @@ -30560,8 +30815,7 @@ var ts; return true; } if (source.flags & 32768 /* Object */ && target.flags & 32768 /* Object */) { - var id = relation !== identityRelation || source.id < target.id ? source.id + "," + target.id : target.id + "," + source.id; - var related = relation.get(id); + var related = relation.get(getRelationKey(source, target, relation)); if (related !== undefined) { return related === 1 /* Succeeded */; } @@ -30697,11 +30951,21 @@ var ts; !(target.flags & 65536 /* Union */) && !isIntersectionConstituent && source !== globalObjectType && - getPropertiesOfType(source).length > 0 && + (getPropertiesOfType(source).length > 0 || + getSignaturesOfType(source, 0 /* Call */).length > 0 || + getSignaturesOfType(source, 1 /* Construct */).length > 0) && isWeakType(target) && !hasCommonProperties(source, target)) { if (reportErrors) { - reportError(ts.Diagnostics.Type_0_has_no_properties_in_common_with_type_1, typeToString(source), typeToString(target)); + var calls = getSignaturesOfType(source, 0 /* Call */); + var constructs = getSignaturesOfType(source, 1 /* Construct */); + if (calls.length > 0 && isRelatedTo(getReturnTypeOfSignature(calls[0]), target, /*reportErrors*/ false) || + constructs.length > 0 && isRelatedTo(getReturnTypeOfSignature(constructs[0]), target, /*reportErrors*/ false)) { + reportError(ts.Diagnostics.Value_of_type_0_has_no_properties_in_common_with_type_1_Did_you_mean_to_call_it, typeToString(source), typeToString(target)); + } + else { + reportError(ts.Diagnostics.Type_0_has_no_properties_in_common_with_type_1, typeToString(source), typeToString(target)); + } } return 0 /* False */; } @@ -30929,7 +31193,7 @@ var ts; if (overflow) { return 0 /* False */; } - var id = relation !== identityRelation || source.id < target.id ? source.id + "," + target.id : target.id + "," + source.id; + var id = getRelationKey(source, target, relation); var related = relation.get(id); if (related !== undefined) { if (reportErrors && related === 2 /* Failed */) { @@ -31411,6 +31675,11 @@ var ts; if (sourceInfo) { return indexInfoRelatedTo(sourceInfo, targetInfo, reportErrors); } + if (isGenericMappedType(source)) { + // A generic mapped type { [P in K]: T } is related to an index signature { [x: string]: U } + // if T is related to U. + return kind === 0 /* String */ && isRelatedTo(getTemplateTypeFromMappedType(source), targetInfo.type, reportErrors); + } if (isObjectLiteralType(source)) { var related = -1 /* True */; if (kind === 0 /* String */) { @@ -31444,8 +31713,8 @@ var ts; if (!sourceSignature.declaration || !targetSignature.declaration) { return true; } - var sourceAccessibility = ts.getModifierFlags(sourceSignature.declaration) & 24 /* NonPublicAccessibilityModifier */; - var targetAccessibility = ts.getModifierFlags(targetSignature.declaration) & 24 /* NonPublicAccessibilityModifier */; + var sourceAccessibility = ts.getSelectedModifierFlags(sourceSignature.declaration, 24 /* NonPublicAccessibilityModifier */); + var targetAccessibility = ts.getSelectedModifierFlags(targetSignature.declaration, 24 /* NonPublicAccessibilityModifier */); // A public, protected and private signature is assignable to a private signature. if (targetAccessibility === 8 /* Private */) { return true; @@ -31464,6 +31733,50 @@ var ts; return false; } } + function isUnconstrainedTypeParameter(type) { + return type.flags & 16384 /* TypeParameter */ && !getConstraintFromTypeParameter(type); + } + function isTypeReferenceWithGenericArguments(type) { + return getObjectFlags(type) & 4 /* Reference */ && ts.some(type.typeArguments, isUnconstrainedTypeParameter); + } + /** + * getTypeReferenceId(A) returns "111=0-12=1" + * where A.id=111 and number.id=12 + */ + function getTypeReferenceId(type, typeParameters) { + var result = "" + type.target.id; + for (var _i = 0, _a = type.typeArguments; _i < _a.length; _i++) { + var t = _a[_i]; + if (isUnconstrainedTypeParameter(t)) { + var index = ts.indexOf(typeParameters, t); + if (index < 0) { + index = typeParameters.length; + typeParameters.push(t); + } + result += "=" + index; + } + else { + result += "-" + t.id; + } + } + return result; + } + /** + * To improve caching, the relation key for two generic types uses the target's id plus ids of the type parameters. + * For other cases, the types ids are used. + */ + function getRelationKey(source, target, relation) { + if (relation === identityRelation && source.id > target.id) { + var temp = source; + source = target; + target = temp; + } + if (isTypeReferenceWithGenericArguments(source) && isTypeReferenceWithGenericArguments(target)) { + var typeParameters = []; + return getTypeReferenceId(source, typeParameters) + "," + getTypeReferenceId(target, typeParameters); + } + return source.id + "," + target.id; + } // Invoke the callback for each underlying property symbol of the given symbol and return the first // value that isn't undefined. function forEachProperty(prop, callback) { @@ -31509,7 +31822,7 @@ var ts; var symbol = type.symbol; if (symbol && symbol.flags & 32 /* Class */) { var declaration = getClassLikeDeclarationOfSymbol(symbol); - if (declaration && ts.getModifierFlags(declaration) & 128 /* Abstract */) { + if (declaration && ts.hasModifier(declaration, 128 /* Abstract */)) { return true; } } @@ -31960,13 +32273,14 @@ var ts; callback(getTypeAtPosition(source, i), getTypeAtPosition(target, i)); } } - function createInferenceContext(signature, flags, baseInferences) { + function createInferenceContext(signature, flags, compareTypes, baseInferences) { var inferences = baseInferences ? ts.map(baseInferences, cloneInferenceInfo) : ts.map(signature.typeParameters, createInferenceInfo); var context = mapper; context.mappedTypes = signature.typeParameters; context.signature = signature; context.inferences = inferences; context.flags = flags; + context.compareTypes = compareTypes || compareTypesAssignable; return context; function mapper(t) { for (var i = 0; i < inferences.length; i++) { @@ -32061,6 +32375,19 @@ var ts; return inference.candidates && getUnionType(inference.candidates, /*subtypeReduction*/ true); } } + function isPossiblyAssignableTo(source, target) { + var properties = getPropertiesOfObjectType(target); + for (var _i = 0, properties_5 = properties; _i < properties_5.length; _i++) { + var targetProp = properties_5[_i]; + if (!(targetProp.flags & (16777216 /* Optional */ | 4194304 /* Prototype */))) { + var sourceProp = getPropertyOfObjectType(source, targetProp.escapedName); + if (!sourceProp) { + return false; + } + } + } + return true; + } function inferTypes(inferences, originalSource, originalTarget, priority) { if (priority === void 0) { priority = 0; } var symbolStack; @@ -32257,15 +32584,19 @@ var ts; return; } } - inferFromProperties(source, target); - inferFromSignatures(source, target, 0 /* Call */); - inferFromSignatures(source, target, 1 /* Construct */); - inferFromIndexTypes(source, target); + // Infer from the members of source and target only if the two types are possibly related. We check + // in both directions because we may be inferring for a co-variant or a contra-variant position. + if (isPossiblyAssignableTo(source, target) || isPossiblyAssignableTo(target, source)) { + inferFromProperties(source, target); + inferFromSignatures(source, target, 0 /* Call */); + inferFromSignatures(source, target, 1 /* Construct */); + inferFromIndexTypes(source, target); + } } function inferFromProperties(source, target) { var properties = getPropertiesOfObjectType(target); - for (var _i = 0, properties_5 = properties; _i < properties_5.length; _i++) { - var targetProp = properties_5[_i]; + for (var _i = 0, properties_6 = properties; _i < properties_6.length; _i++) { + var targetProp = properties_6[_i]; var sourceProp = getPropertyOfObjectType(source, targetProp.escapedName); if (sourceProp) { inferFromTypes(getTypeOfSymbol(sourceProp), getTypeOfSymbol(targetProp)); @@ -32382,7 +32713,7 @@ var ts; var constraint = getConstraintOfTypeParameter(context.signature.typeParameters[index]); if (constraint) { var instantiatedConstraint = instantiateType(constraint, context); - if (!isTypeAssignableTo(inferredType, getTypeWithThisArgument(instantiatedConstraint, inferredType))) { + if (!context.compareTypes(inferredType, getTypeWithThisArgument(instantiatedConstraint, inferredType))) { inference.inferredType = inferredType = instantiatedConstraint; } } @@ -32440,16 +32771,6 @@ var ts; } return undefined; } - function getLeftmostIdentifierOrThis(node) { - switch (node.kind) { - case 71 /* Identifier */: - case 99 /* ThisKeyword */: - return node; - case 179 /* PropertyAccessExpression */: - return getLeftmostIdentifierOrThis(node.expression); - } - return undefined; - } function getBindingElementNameText(element) { if (element.parent.kind === 174 /* ObjectBindingPattern */) { var name = element.propertyName || element.name; @@ -32975,7 +33296,7 @@ var ts; parent.parent.operatorToken.kind === 58 /* EqualsToken */ && parent.parent.left === parent && !ts.isAssignmentTarget(parent.parent) && - isTypeAnyOrAllConstituentTypesHaveKind(getTypeOfExpression(parent.argumentExpression), 84 /* NumberLike */ | 2048 /* Undefined */); + isTypeAssignableToKind(getTypeOfExpression(parent.argumentExpression), 84 /* NumberLike */); return isLengthPushOrUnshift || isElementAssignment; } function maybeTypePredicateCall(node) { @@ -33143,7 +33464,7 @@ var ts; } else { var indexType = getTypeOfExpression(node.left.argumentExpression); - if (isTypeAnyOrAllConstituentTypesHaveKind(indexType, 84 /* NumberLike */ | 2048 /* Undefined */)) { + if (isTypeAssignableToKind(indexType, 84 /* NumberLike */)) { evolvedType_1 = addEvolvingArrayElementType(evolvedType_1, node.right); } } @@ -33978,7 +34299,7 @@ var ts; break; case 149 /* PropertyDeclaration */: case 148 /* PropertySignature */: - if (ts.getModifierFlags(container) & 32 /* Static */) { + if (ts.hasModifier(container, 32 /* Static */)) { error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_static_property_initializer); // do not return here so in case if lexical this is captured - it will be reflected in flags on NodeLinks } @@ -34081,7 +34402,7 @@ var ts; if (!isCallExpression && container.kind === 152 /* Constructor */) { checkThisBeforeSuper(node, container, ts.Diagnostics.super_must_be_called_before_accessing_a_property_of_super_in_the_constructor_of_a_derived_class); } - if ((ts.getModifierFlags(container) & 32 /* Static */) || isCallExpression) { + if (ts.hasModifier(container, 32 /* Static */) || isCallExpression) { nodeCheckFlag = 512 /* SuperStatic */; } else { @@ -34144,7 +34465,7 @@ var ts; // This helper creates an object with a "value" property that wraps the `super` property or indexed access for both get and set. // This is required for destructuring assignments, as a call expression cannot be used as the target of a destructuring assignment // while a property access can. - if (container.kind === 151 /* MethodDeclaration */ && ts.getModifierFlags(container) & 256 /* Async */) { + if (container.kind === 151 /* MethodDeclaration */ && ts.hasModifier(container, 256 /* Async */)) { if (ts.isSuperProperty(node.parent) && ts.isAssignmentTarget(node.parent)) { getNodeLinks(container).flags |= 4096 /* AsyncMethodWithSuperBinding */; } @@ -34202,7 +34523,7 @@ var ts; // - In a static member function or static member accessor // topmost container must be something that is directly nested in the class declaration\object literal expression if (ts.isClassLike(container.parent) || container.parent.kind === 178 /* ObjectLiteralExpression */) { - if (ts.getModifierFlags(container) & 32 /* Static */) { + if (ts.hasModifier(container, 32 /* Static */)) { return container.kind === 151 /* MethodDeclaration */ || container.kind === 150 /* MethodSignature */ || container.kind === 153 /* GetAccessor */ || @@ -34414,7 +34735,7 @@ var ts; // Otherwise, if the containing function is contextually typed by a function type with exactly one call signature // and that call signature is non-generic, return statements are contextually typed by the return type of the signature var signature = getContextualSignatureForFunctionLikeDeclaration(functionDecl); - if (signature) { + if (signature && !isResolvingReturnTypeOfSignature(signature)) { return getReturnTypeOfSignature(signature); } return undefined; @@ -34543,12 +34864,12 @@ var ts; } if (ts.isJsxAttribute(node.parent)) { // JSX expression is in JSX attribute - return getTypeOfPropertyOfType(attributesType, node.parent.name.escapedText); + return getTypeOfPropertyOfContextualType(attributesType, node.parent.name.escapedText); } else if (node.parent.kind === 249 /* JsxElement */) { // JSX expression is in children of JSX Element, we will look for an "children" atttribute (we get the name from JSX.ElementAttributesProperty) var jsxChildrenPropertyName = getJsxElementChildrenPropertyname(); - return jsxChildrenPropertyName && jsxChildrenPropertyName !== "" ? getTypeOfPropertyOfType(attributesType, jsxChildrenPropertyName) : anyType; + return jsxChildrenPropertyName && jsxChildrenPropertyName !== "" ? getTypeOfPropertyOfContextualType(attributesType, jsxChildrenPropertyName) : anyType; } else { // JSX expression is in JSX spread attribute @@ -34564,7 +34885,7 @@ var ts; if (!attributesType || isTypeAny(attributesType)) { return undefined; } - return getTypeOfPropertyOfType(attributesType, attribute.name.escapedText); + return getTypeOfPropertyOfContextualType(attributesType, attribute.name.escapedText); } else { return attributesType; @@ -34832,10 +35153,7 @@ var ts; function isNumericComputedName(name) { // It seems odd to consider an expression of type Any to result in a numeric name, // but this behavior is consistent with checkIndexedAccess - return isTypeAnyOrAllConstituentTypesHaveKind(checkComputedPropertyName(name), 84 /* NumberLike */); - } - function isTypeAnyOrAllConstituentTypesHaveKind(type, kind) { - return isTypeAny(type) || isTypeOfKind(type, kind); + return isTypeAssignableToKind(checkComputedPropertyName(name), 84 /* NumberLike */); } function isInfinityOrNaNString(name) { return name === "Infinity" || name === "-Infinity" || name === "NaN"; @@ -34870,7 +35188,9 @@ var ts; links.resolvedType = checkExpression(node.expression); // This will allow types number, string, symbol or any. It will also allow enums, the unknown // type, and any union of these types (like string | number). - if (!isTypeAnyOrAllConstituentTypesHaveKind(links.resolvedType, 84 /* NumberLike */ | 262178 /* StringLike */ | 512 /* ESSymbol */)) { + if (links.resolvedType.flags & 6144 /* Nullable */ || + !isTypeAssignableToKind(links.resolvedType, 262178 /* StringLike */ | 84 /* NumberLike */ | 512 /* ESSymbol */) && + !isTypeAssignableTo(links.resolvedType, getUnionType([stringType, numberType, esSymbolType]))) { error(node, ts.Diagnostics.A_computed_property_name_must_be_of_type_string_number_symbol_or_any); } else { @@ -35484,9 +35804,7 @@ var ts; * emptyObjectType if there is no "prop" in the element instance type */ function resolveCustomJsxElementAttributesType(openingLikeElement, shouldIncludeAllStatelessAttributesType, elementType, elementClassType) { - if (!elementType) { - elementType = checkExpression(openingLikeElement.tagName); - } + if (elementType === void 0) { elementType = checkExpression(openingLikeElement.tagName); } if (elementType.flags & 65536 /* Union */) { var types = elementType.types; return getUnionType(types.map(function (type) { @@ -35607,11 +35925,12 @@ var ts; */ function getCustomJsxElementAttributesType(node, shouldIncludeAllStatelessAttributesType) { var links = getNodeLinks(node); - if (!links.resolvedJsxElementAttributesType) { + var linkLocation = shouldIncludeAllStatelessAttributesType ? "resolvedJsxElementAllAttributesType" : "resolvedJsxElementAttributesType"; + if (!links[linkLocation]) { var elemClassType = getJsxGlobalElementClassType(); - return links.resolvedJsxElementAttributesType = resolveCustomJsxElementAttributesType(node, shouldIncludeAllStatelessAttributesType, /*elementType*/ undefined, elemClassType); + return links[linkLocation] = resolveCustomJsxElementAttributesType(node, shouldIncludeAllStatelessAttributesType, /*elementType*/ undefined, elemClassType); } - return links.resolvedJsxElementAttributesType; + return links[linkLocation]; } /** * Get all possible attributes type, especially from an overload stateless function component, of the given JSX opening-like element. @@ -35933,9 +36252,12 @@ var ts; } var prop = getPropertyOfType(apparentType, right.escapedText); if (!prop) { - var stringIndexType = getIndexTypeOfType(apparentType, 0 /* String */); - if (stringIndexType) { - return stringIndexType; + var indexInfo = getIndexInfoOfType(apparentType, 0 /* String */); + if (indexInfo && indexInfo.type) { + if (indexInfo.isReadonly && (ts.isAssignmentTarget(node) || ts.isDeleteTarget(node))) { + error(node, ts.Diagnostics.Index_signature_in_type_0_only_permits_reading, typeToString(apparentType)); + } + return indexInfo.type; } if (right.escapedText && !checkAndReportErrorForExtendingInterface(node)) { reportNonexistentProperty(right, type.flags & 16384 /* TypeParameter */ && type.isThisType ? apparentType : type); @@ -36084,7 +36406,7 @@ var ts; if (prop && noUnusedIdentifiers && (prop.flags & 106500 /* ClassMember */) && - prop.valueDeclaration && (ts.getModifierFlags(prop.valueDeclaration) & 8 /* Private */)) { + prop.valueDeclaration && ts.hasModifier(prop.valueDeclaration, 8 /* Private */)) { if (ts.getCheckFlags(prop) & 1 /* Instantiated */) { getSymbolLinks(prop).target.isReferenced = true; } @@ -36407,8 +36729,8 @@ var ts; return undefined; } // Instantiate a generic signature in the context of a non-generic signature (section 3.8.5 in TypeScript spec) - function instantiateSignatureInContextOf(signature, contextualSignature, contextualMapper) { - var context = createInferenceContext(signature, 1 /* InferUnionTypes */); + function instantiateSignatureInContextOf(signature, contextualSignature, contextualMapper, compareTypes) { + var context = createInferenceContext(signature, 1 /* InferUnionTypes */, compareTypes); forEachMatchingParameterType(contextualSignature, signature, function (source, target) { // Type parameters from outer context referenced by source type are fixed by instantiation of the source type inferTypes(context.inferences, instantiateType(source, contextualMapper || identityMapper), target); @@ -36780,7 +37102,7 @@ var ts; return getLiteralType(element.name.text); case 144 /* ComputedPropertyName */: var nameType = checkComputedPropertyName(element.name); - if (isTypeOfKind(nameType, 512 /* ESSymbol */)) { + if (isTypeAssignableToKind(nameType, 512 /* ESSymbol */)) { return nameType; } else { @@ -36921,9 +37243,10 @@ var ts; // // For a decorator, no arguments are susceptible to contextual typing due to the fact // decorators are applied to a declaration by the emitter, and not to an expression. + var isSingleNonGenericCandidate = candidates.length === 1 && !candidates[0].typeParameters; var excludeArgument; var excludeCount = 0; - if (!isDecorator) { + if (!isDecorator && !isSingleNonGenericCandidate) { // We do not need to call `getEffectiveArgumentCount` here as it only // applies when calculating the number of arguments for a decorator. for (var i = isTaggedTemplate ? 1 : 0; i < args.length; i++) { @@ -37068,6 +37391,17 @@ var ts; if (signatureHelpTrailingComma === void 0) { signatureHelpTrailingComma = false; } candidateForArgumentError = undefined; candidateForTypeArgumentError = undefined; + if (isSingleNonGenericCandidate) { + var candidate = candidates[0]; + if (!hasCorrectArity(node, args, candidate, signatureHelpTrailingComma)) { + return undefined; + } + if (!checkApplicableSignature(node, args, candidate, relation, excludeArgument, /*reportErrors*/ false)) { + candidateForArgumentError = candidate; + return undefined; + } + return candidate; + } for (var candidateIndex = 0; candidateIndex < candidates.length; candidateIndex++) { var originalCandidate = candidates[candidateIndex]; if (!hasCorrectArity(node, args, originalCandidate, signatureHelpTrailingComma)) { @@ -37230,7 +37564,7 @@ var ts; // In the case of a merged class-module or class-interface declaration, // only the class declaration node will have the Abstract flag set. var valueDecl = expressionType.symbol && getClassLikeDeclarationOfSymbol(expressionType.symbol); - if (valueDecl && ts.getModifierFlags(valueDecl) & 128 /* Abstract */) { + if (valueDecl && ts.hasModifier(valueDecl, 128 /* Abstract */)) { error(node, ts.Diagnostics.Cannot_create_an_instance_of_the_abstract_class_0, ts.declarationNameToString(ts.getNameOfDeclaration(valueDecl))); return resolveErrorCall(node); } @@ -37277,9 +37611,9 @@ var ts; return true; } var declaration = signature.declaration; - var modifiers = ts.getModifierFlags(declaration); + var modifiers = ts.getSelectedModifierFlags(declaration, 24 /* NonPublicAccessibilityModifier */); // Public constructor is accessible. - if (!(modifiers & 24 /* NonPublicAccessibilityModifier */)) { + if (!modifiers) { return true; } var declaringClassDeclaration = getClassLikeDeclarationOfSymbol(declaration.parent.symbol); @@ -37488,7 +37822,7 @@ var ts; */ function checkCallExpression(node) { // Grammar checking; stop grammar-checking if checkGrammarTypeArguments return true - checkGrammarTypeArguments(node, node.typeArguments) || checkGrammarArguments(node, node.arguments); + checkGrammarTypeArguments(node, node.typeArguments) || checkGrammarArguments(node.arguments); var signature = getResolvedSignature(node); if (node.expression.kind === 97 /* SuperKeyword */) { return voidType; @@ -37528,7 +37862,7 @@ var ts; } function checkImportCallExpression(node) { // Check grammar of dynamic import - checkGrammarArguments(node, node.arguments) || checkGrammarImportCallExpression(node); + checkGrammarArguments(node.arguments) || checkGrammarImportCallExpression(node); if (node.arguments.length === 0) { return createPromiseReturnType(node, anyType); } @@ -37546,11 +37880,33 @@ var ts; if (moduleSymbol) { var esModuleSymbol = resolveESModuleSymbol(moduleSymbol, specifier, /*dontRecursivelyResolve*/ true); if (esModuleSymbol) { - return createPromiseReturnType(node, getTypeOfSymbol(esModuleSymbol)); + return createPromiseReturnType(node, getTypeWithSyntheticDefaultImportType(getTypeOfSymbol(esModuleSymbol), esModuleSymbol)); } } return createPromiseReturnType(node, anyType); } + function getTypeWithSyntheticDefaultImportType(type, symbol) { + if (allowSyntheticDefaultImports && type && type !== unknownType) { + var synthType = type; + if (!synthType.syntheticType) { + if (!getPropertyOfType(type, "default" /* Default */)) { + var memberTable = ts.createSymbolTable(); + var newSymbol = createSymbol(2097152 /* Alias */, "default" /* Default */); + newSymbol.target = resolveSymbol(symbol); + memberTable.set("default" /* Default */, newSymbol); + var anonymousSymbol = createSymbol(2048 /* TypeLiteral */, "__type" /* Type */); + var defaultContainingObject = createAnonymousType(anonymousSymbol, memberTable, ts.emptyArray, ts.emptyArray, /*stringIndexInfo*/ undefined, /*numberIndexInfo*/ undefined); + anonymousSymbol.type = defaultContainingObject; + synthType.syntheticType = getIntersectionType([type, defaultContainingObject]); + } + else { + synthType.syntheticType = type; + } + } + return synthType.syntheticType; + } + return type; + } function isCommonJsRequire(node) { if (!ts.isRequireCall(node, /*checkArgumentIsStringLiteral*/ true)) { return false; @@ -37675,15 +38031,15 @@ var ts; } // When contextual typing assigns a type to a parameter that contains a binding pattern, we also need to push // the destructured type into the contained binding elements. - function assignBindingElementTypes(node) { - if (ts.isBindingPattern(node.name)) { - for (var _i = 0, _a = node.name.elements; _i < _a.length; _i++) { - var element = _a[_i]; - if (!ts.isOmittedExpression(element)) { - if (element.name.kind === 71 /* Identifier */) { - getSymbolLinks(getSymbolOfNode(element)).type = getTypeForBindingElement(element); - } - assignBindingElementTypes(element); + function assignBindingElementTypes(pattern) { + for (var _i = 0, _a = pattern.elements; _i < _a.length; _i++) { + var element = _a[_i]; + if (!ts.isOmittedExpression(element)) { + if (element.name.kind === 71 /* Identifier */) { + getSymbolLinks(getSymbolOfNode(element)).type = getTypeForBindingElement(element); + } + else { + assignBindingElementTypes(element.name); } } } @@ -37692,13 +38048,14 @@ var ts; var links = getSymbolLinks(parameter); if (!links.type) { links.type = contextualType; - var name = ts.getNameOfDeclaration(parameter.valueDeclaration); - // if inference didn't come up with anything but {}, fall back to the binding pattern if present. - if (links.type === emptyObjectType && - (name.kind === 174 /* ObjectBindingPattern */ || name.kind === 175 /* ArrayBindingPattern */)) { - links.type = getTypeFromBindingPattern(name); + var decl = parameter.valueDeclaration; + if (decl.name.kind !== 71 /* Identifier */) { + // if inference didn't come up with anything but {}, fall back to the binding pattern if present. + if (links.type === emptyObjectType) { + links.type = getTypeFromBindingPattern(decl.name); + } + assignBindingElementTypes(decl.name); } - assignBindingElementTypes(parameter.valueDeclaration); } } function createPromiseType(promisedType) { @@ -37934,16 +38291,16 @@ var ts; } function checkFunctionExpressionOrObjectLiteralMethod(node, checkMode) { ts.Debug.assert(node.kind !== 151 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); - // Grammar checking - var hasGrammarError = checkGrammarFunctionLikeDeclaration(node); - if (!hasGrammarError && node.kind === 186 /* FunctionExpression */) { - checkGrammarForGenerator(node); - } // The identityMapper object is used to indicate that function expressions are wildcards if (checkMode === 1 /* SkipContextSensitive */ && isContextSensitive(node)) { checkNodeDeferred(node); return anyFunctionType; } + // Grammar checking + var hasGrammarError = checkGrammarFunctionLikeDeclaration(node); + if (!hasGrammarError && node.kind === 186 /* FunctionExpression */) { + checkGrammarForGenerator(node); + } var links = getNodeLinks(node); var type = getTypeOfSymbol(node.symbol); // Check if function expression is contextually typed and assign parameter types if so. @@ -38028,7 +38385,7 @@ var ts; } } function checkArithmeticOperandType(operand, type, diagnostic) { - if (!isTypeAnyOrAllConstituentTypesHaveKind(type, 84 /* NumberLike */)) { + if (!isTypeAssignableToKind(type, 84 /* NumberLike */)) { error(operand, diagnostic); return false; } @@ -38129,8 +38486,13 @@ var ts; if (operandType === silentNeverType) { return silentNeverType; } - if (node.operator === 38 /* MinusToken */ && node.operand.kind === 8 /* NumericLiteral */) { - return getFreshTypeOfLiteralType(getLiteralType(-node.operand.text)); + if (node.operand.kind === 8 /* NumericLiteral */) { + if (node.operator === 38 /* MinusToken */) { + return getFreshTypeOfLiteralType(getLiteralType(-node.operand.text)); + } + else if (node.operator === 37 /* PlusToken */) { + return getFreshTypeOfLiteralType(getLiteralType(+node.operand.text)); + } } switch (node.operator) { case 37 /* PlusToken */: @@ -38186,33 +38548,22 @@ var ts; } return false; } - // Return true if type is of the given kind. A union type is of a given kind if all constituent types - // are of the given kind. An intersection type is of a given kind if at least one constituent type is - // of the given kind. - function isTypeOfKind(type, kind) { - if (type.flags & kind) { + function isTypeAssignableToKind(source, kind, strict) { + if (source.flags & kind) { return true; } - if (type.flags & 65536 /* Union */) { - var types = type.types; - for (var _i = 0, types_18 = types; _i < types_18.length; _i++) { - var t = types_18[_i]; - if (!isTypeOfKind(t, kind)) { - return false; - } - } - return true; + if (strict && source.flags & (1 /* Any */ | 1024 /* Void */ | 2048 /* Undefined */ | 4096 /* Null */)) { + return false; } - if (type.flags & 131072 /* Intersection */) { - var types = type.types; - for (var _a = 0, types_19 = types; _a < types_19.length; _a++) { - var t = types_19[_a]; - if (isTypeOfKind(t, kind)) { - return true; - } - } - } - return false; + return (kind & 84 /* NumberLike */ && isTypeAssignableTo(source, numberType)) || + (kind & 262178 /* StringLike */ && isTypeAssignableTo(source, stringType)) || + (kind & 136 /* BooleanLike */ && isTypeAssignableTo(source, booleanType)) || + (kind & 1024 /* Void */ && isTypeAssignableTo(source, voidType)) || + (kind & 8192 /* Never */ && isTypeAssignableTo(source, neverType)) || + (kind & 4096 /* Null */ && isTypeAssignableTo(source, nullType)) || + (kind & 2048 /* Undefined */ && isTypeAssignableTo(source, undefinedType)) || + (kind & 512 /* ESSymbol */ && isTypeAssignableTo(source, esSymbolType)) || + (kind & 16777216 /* NonPrimitive */ && isTypeAssignableTo(source, nonPrimitiveType)); } function isConstEnumObjectType(type) { return getObjectFlags(type) & 16 /* Anonymous */ && type.symbol && isConstEnumSymbol(type.symbol); @@ -38229,7 +38580,7 @@ var ts; // and the right operand to be of type Any, a subtype of the 'Function' interface type, or have a call or construct signature. // The result is always of the Boolean primitive type. // NOTE: do not raise error if leftType is unknown as related error was already reported - if (isTypeOfKind(leftType, 8190 /* Primitive */)) { + if (!isTypeAny(leftType) && isTypeAssignableToKind(leftType, 8190 /* Primitive */)) { error(left, ts.Diagnostics.The_left_hand_side_of_an_instanceof_expression_must_be_of_type_any_an_object_type_or_a_type_parameter); } // NOTE: do not raise error if right is unknown as related error was already reported @@ -38251,18 +38602,18 @@ var ts; // The in operator requires the left operand to be of type Any, the String primitive type, or the Number primitive type, // and the right operand to be of type Any, an object type, or a type parameter type. // The result is always of the Boolean primitive type. - if (!(isTypeComparableTo(leftType, stringType) || isTypeOfKind(leftType, 84 /* NumberLike */ | 512 /* ESSymbol */))) { + if (!(isTypeComparableTo(leftType, stringType) || isTypeAssignableToKind(leftType, 84 /* NumberLike */ | 512 /* ESSymbol */))) { error(left, ts.Diagnostics.The_left_hand_side_of_an_in_expression_must_be_of_type_any_string_number_or_symbol); } - if (!isTypeAnyOrAllConstituentTypesHaveKind(rightType, 32768 /* Object */ | 540672 /* TypeVariable */ | 16777216 /* NonPrimitive */)) { + if (!isTypeAssignableToKind(rightType, 16777216 /* NonPrimitive */ | 540672 /* TypeVariable */)) { error(right, ts.Diagnostics.The_right_hand_side_of_an_in_expression_must_be_of_type_any_an_object_type_or_a_type_parameter); } return booleanType; } function checkObjectLiteralAssignment(node, sourceType) { var properties = node.properties; - for (var _i = 0, properties_6 = properties; _i < properties_6.length; _i++) { - var p = properties_6[_i]; + for (var _i = 0, properties_7 = properties; _i < properties_7.length; _i++) { + var p = properties_7[_i]; checkObjectLiteralDestructuringPropertyAssignment(sourceType, p, properties); } return sourceType; @@ -38541,30 +38892,28 @@ var ts; if (leftType === silentNeverType || rightType === silentNeverType) { return silentNeverType; } - if (!isTypeOfKind(leftType, 1 /* Any */ | 262178 /* StringLike */) && !isTypeOfKind(rightType, 1 /* Any */ | 262178 /* StringLike */)) { + if (!isTypeAssignableToKind(leftType, 262178 /* StringLike */) && !isTypeAssignableToKind(rightType, 262178 /* StringLike */)) { leftType = checkNonNullType(leftType, left); rightType = checkNonNullType(rightType, right); } var resultType = void 0; - if (isTypeOfKind(leftType, 84 /* NumberLike */) && isTypeOfKind(rightType, 84 /* NumberLike */)) { + if (isTypeAssignableToKind(leftType, 84 /* NumberLike */, /*strict*/ true) && isTypeAssignableToKind(rightType, 84 /* NumberLike */, /*strict*/ true)) { // Operands of an enum type are treated as having the primitive type Number. // If both operands are of the Number primitive type, the result is of the Number primitive type. resultType = numberType; } - else { - if (isTypeOfKind(leftType, 262178 /* StringLike */) || isTypeOfKind(rightType, 262178 /* StringLike */)) { - // If one or both operands are of the String primitive type, the result is of the String primitive type. - resultType = stringType; - } - else if (isTypeAny(leftType) || isTypeAny(rightType)) { - // Otherwise, the result is of type Any. - // NOTE: unknown type here denotes error type. Old compiler treated this case as any type so do we. - resultType = leftType === unknownType || rightType === unknownType ? unknownType : anyType; - } - // Symbols are not allowed at all in arithmetic expressions - if (resultType && !checkForDisallowedESSymbolOperand(operator)) { - return resultType; - } + else if (isTypeAssignableToKind(leftType, 262178 /* StringLike */, /*strict*/ true) || isTypeAssignableToKind(rightType, 262178 /* StringLike */, /*strict*/ true)) { + // If one or both operands are of the String primitive type, the result is of the String primitive type. + resultType = stringType; + } + else if (isTypeAny(leftType) || isTypeAny(rightType)) { + // Otherwise, the result is of type Any. + // NOTE: unknown type here denotes error type. Old compiler treated this case as any type so do we. + resultType = leftType === unknownType || rightType === unknownType ? unknownType : anyType; + } + // Symbols are not allowed at all in arithmetic expressions + if (resultType && !checkForDisallowedESSymbolOperand(operator)) { + return resultType; } if (!resultType) { reportOperatorError(); @@ -38749,13 +39098,12 @@ var ts; return getBestChoiceType(type1, type2); } function checkLiteralExpression(node) { - if (node.kind === 8 /* NumericLiteral */) { - checkGrammarNumericLiteral(node); - } switch (node.kind) { + case 13 /* NoSubstitutionTemplateLiteral */: case 9 /* StringLiteral */: return getFreshTypeOfLiteralType(getLiteralType(node.text)); case 8 /* NumericLiteral */: + checkGrammarNumericLiteral(node); return getFreshTypeOfLiteralType(getLiteralType(+node.text)); case 101 /* TrueKeyword */: return trueType; @@ -38951,6 +39299,7 @@ var ts; return checkSuperExpression(node); case 95 /* NullKeyword */: return nullWideningType; + case 13 /* NoSubstitutionTemplateLiteral */: case 9 /* StringLiteral */: case 8 /* NumericLiteral */: case 101 /* TrueKeyword */: @@ -38958,8 +39307,6 @@ var ts; return checkLiteralExpression(node); case 196 /* TemplateExpression */: return checkTemplateExpression(node); - case 13 /* NoSubstitutionTemplateLiteral */: - return stringType; case 12 /* RegularExpressionLiteral */: return globalRegExpType; case 177 /* ArrayLiteralExpression */: @@ -39058,7 +39405,7 @@ var ts; checkGrammarDecorators(node) || checkGrammarModifiers(node); checkVariableLikeDeclaration(node); var func = ts.getContainingFunction(node); - if (ts.getModifierFlags(node) & 92 /* ParameterPropertyModifier */) { + if (ts.hasModifier(node, 92 /* ParameterPropertyModifier */)) { func = ts.getContainingFunction(node); if (!(func.kind === 152 /* Constructor */ && ts.nodeIsPresent(func.body))) { error(node, ts.Diagnostics.A_parameter_property_is_only_allowed_in_a_constructor_implementation); @@ -39264,7 +39611,7 @@ var ts; } } else { - var isStatic = ts.getModifierFlags(member) & 32 /* Static */; + var isStatic = ts.hasModifier(member, 32 /* Static */); var names = isStatic ? staticNames : instanceNames; var memberName = member.name && ts.getPropertyNameForPropertyNameNode(member.name); if (memberName) { @@ -39320,7 +39667,7 @@ var ts; for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; var memberNameNode = member.name; - var isStatic = ts.getModifierFlags(member) & 32 /* Static */; + var isStatic = ts.hasModifier(member, 32 /* Static */); if (isStatic && memberNameNode) { var memberName = ts.getPropertyNameForPropertyNameNode(memberNameNode); switch (memberName) { @@ -39418,7 +39765,7 @@ var ts; checkFunctionOrMethodDeclaration(node); // Abstract methods cannot have an implementation. // Extra checks are to avoid reporting multiple errors relating to the "abstractness" of the node. - if (ts.getModifierFlags(node) & 128 /* Abstract */ && node.body) { + if (ts.hasModifier(node, 128 /* Abstract */) && node.body) { error(node, ts.Diagnostics.Method_0_cannot_have_an_implementation_because_it_is_marked_abstract, ts.declarationNameToString(node.name)); } } @@ -39458,17 +39805,9 @@ var ts; } return ts.forEachChild(n, containsSuperCall); } - function markThisReferencesAsErrors(n) { - if (n.kind === 99 /* ThisKeyword */) { - error(n, ts.Diagnostics.this_cannot_be_referenced_in_current_location); - } - else if (n.kind !== 186 /* FunctionExpression */ && n.kind !== 228 /* FunctionDeclaration */) { - ts.forEachChild(n, markThisReferencesAsErrors); - } - } function isInstancePropertyWithInitializer(n) { return n.kind === 149 /* PropertyDeclaration */ && - !(ts.getModifierFlags(n) & 32 /* Static */) && + !ts.hasModifier(n, 32 /* Static */) && !!n.initializer; } // TS 1.0 spec (April 2014): 8.3.2 @@ -39488,8 +39827,8 @@ var ts; // - The containing class is a derived class. // - The constructor declares parameter properties // or the containing class declares instance member variables with initializers. - var superCallShouldBeFirst = ts.forEach(node.parent.members, isInstancePropertyWithInitializer) || - ts.forEach(node.parameters, function (p) { return ts.getModifierFlags(p) & 92 /* ParameterPropertyModifier */; }); + var superCallShouldBeFirst = ts.some(node.parent.members, isInstancePropertyWithInitializer) || + ts.some(node.parameters, function (p) { return ts.hasModifier(p, 92 /* ParameterPropertyModifier */); }); // Skip past any prologue directives to find the first statement // to ensure that it was a super call. if (superCallShouldBeFirst) { @@ -39540,10 +39879,12 @@ var ts; var otherKind = node.kind === 153 /* GetAccessor */ ? 154 /* SetAccessor */ : 153 /* GetAccessor */; var otherAccessor = ts.getDeclarationOfKind(node.symbol, otherKind); if (otherAccessor) { - if ((ts.getModifierFlags(node) & 28 /* AccessibilityModifier */) !== (ts.getModifierFlags(otherAccessor) & 28 /* AccessibilityModifier */)) { + var nodeFlags = ts.getModifierFlags(node); + var otherFlags = ts.getModifierFlags(otherAccessor); + if ((nodeFlags & 28 /* AccessibilityModifier */) !== (otherFlags & 28 /* AccessibilityModifier */)) { error(node.name, ts.Diagnostics.Getter_and_setter_accessors_do_not_agree_in_visibility); } - if (ts.hasModifier(node, 128 /* Abstract */) !== ts.hasModifier(otherAccessor, 128 /* Abstract */)) { + if ((nodeFlags & 128 /* Abstract */) !== (otherFlags & 128 /* Abstract */)) { error(node.name, ts.Diagnostics.Accessors_must_both_be_abstract_or_non_abstract); } // TypeScript 1.0 spec (April 2014): 4.5 @@ -39591,7 +39932,7 @@ var ts; function checkTypeReferenceNode(node) { checkGrammarTypeArguments(node, node.typeArguments); if (node.kind === 159 /* TypeReference */ && node.typeName.jsdocDotPos !== undefined && !ts.isInJavaScriptFile(node) && !ts.isInJSDoc(node)) { - grammarErrorAtPos(ts.getSourceFileOfNode(node), node.typeName.jsdocDotPos, 1, ts.Diagnostics.JSDoc_types_can_only_be_used_inside_documentation_comments); + grammarErrorAtPos(node, node.typeName.jsdocDotPos, 1, ts.Diagnostics.JSDoc_types_can_only_be_used_inside_documentation_comments); } var type = getTypeFromTypeReference(node); if (type !== unknownType) { @@ -39600,7 +39941,17 @@ var ts; ts.forEach(node.typeArguments, checkSourceElement); if (produceDiagnostics) { var symbol = getNodeLinks(node).resolvedSymbol; - var typeParameters = symbol.flags & 524288 /* TypeAlias */ ? getSymbolLinks(symbol).typeParameters : type.target.localTypeParameters; + if (!symbol) { + // There is no resolved symbol cached if the type resolved to a builtin + // via JSDoc type reference resolution (eg, Boolean became boolean), none + // of which are generic when they have no associated symbol + error(node, ts.Diagnostics.Type_0_is_not_generic, typeToString(type)); + return; + } + var typeParameters = symbol.flags & 524288 /* TypeAlias */ && getSymbolLinks(symbol).typeParameters; + if (!typeParameters && getObjectFlags(type) & 4 /* Reference */) { + typeParameters = type.target.localTypeParameters; + } checkTypeArgumentConstraints(typeParameters, node.typeArguments); } } @@ -39645,18 +39996,17 @@ var ts; if (isTypeAssignableTo(indexType, getIndexType(objectType))) { return type; } - // Check if we're indexing with a numeric type and the object type is a generic - // type with a constraint that has a numeric index signature. - if (maybeTypeOfKind(objectType, 540672 /* TypeVariable */) && isTypeOfKind(indexType, 84 /* NumberLike */)) { - var constraint = getBaseConstraintOfType(objectType); - if (constraint && getIndexInfoOfType(constraint, 1 /* Number */)) { - return type; - } + // Check if we're indexing with a numeric type and if either object or index types + // is a generic type with a constraint that has a numeric index signature. + if (getIndexInfoOfType(getApparentType(objectType), 1 /* Number */) && isTypeAssignableToKind(indexType, 84 /* NumberLike */)) { + return type; } error(accessNode, ts.Diagnostics.Type_0_cannot_be_used_to_index_type_1, typeToString(indexType), typeToString(objectType)); return type; } function checkIndexedAccessType(node) { + checkSourceElement(node.objectType); + checkSourceElement(node.indexType); checkIndexedAccessIndexType(getTypeFromIndexedAccessTypeNode(node), node); } function checkMappedType(node) { @@ -39667,7 +40017,7 @@ var ts; checkTypeAssignableTo(constraintType, stringType, node.typeParameter.constraint); } function isPrivateWithinAmbient(node) { - return (ts.getModifierFlags(node) & 8 /* Private */) && ts.isInAmbientContext(node); + return ts.hasModifier(node, 8 /* Private */) && ts.isInAmbientContext(node); } function getEffectiveDeclarationFlags(n, flagsToCheck) { var flags = ts.getCombinedModifierFlags(n); @@ -39767,13 +40117,13 @@ var ts; (ts.isComputedPropertyName(node.name) && ts.isComputedPropertyName(subsequentName) || !ts.isComputedPropertyName(node.name) && !ts.isComputedPropertyName(subsequentName) && ts.getEscapedTextOfIdentifierOrLiteral(node.name) === ts.getEscapedTextOfIdentifierOrLiteral(subsequentName))) { var reportError = (node.kind === 151 /* MethodDeclaration */ || node.kind === 150 /* MethodSignature */) && - (ts.getModifierFlags(node) & 32 /* Static */) !== (ts.getModifierFlags(subsequentNode) & 32 /* Static */); + ts.hasModifier(node, 32 /* Static */) !== ts.hasModifier(subsequentNode, 32 /* Static */); // we can get here in two cases // 1. mixed static and instance class members // 2. something with the same name was defined before the set of overloads that prevents them from merging // here we'll report error only for the first case since for second we should already report error in binder if (reportError) { - var diagnostic = ts.getModifierFlags(node) & 32 /* Static */ ? ts.Diagnostics.Function_overload_must_be_static : ts.Diagnostics.Function_overload_must_not_be_static; + var diagnostic = ts.hasModifier(node, 32 /* Static */) ? ts.Diagnostics.Function_overload_must_be_static : ts.Diagnostics.Function_overload_must_not_be_static; error(errorNode_1, diagnostic); } return; @@ -39791,7 +40141,7 @@ var ts; else { // Report different errors regarding non-consecutive blocks of declarations depending on whether // the node in question is abstract. - if (ts.getModifierFlags(node) & 128 /* Abstract */) { + if (ts.hasModifier(node, 128 /* Abstract */)) { error(errorNode, ts.Diagnostics.All_declarations_of_an_abstract_method_must_be_consecutive); } else { @@ -39801,8 +40151,8 @@ var ts; } var duplicateFunctionDeclaration = false; var multipleConstructorImplementation = false; - for (var _i = 0, declarations_5 = declarations; _i < declarations_5.length; _i++) { - var current = declarations_5[_i]; + for (var _i = 0, declarations_4 = declarations; _i < declarations_4.length; _i++) { + var current = declarations_4[_i]; var node = current; var inAmbientContext = ts.isInAmbientContext(node); var inAmbientContextOrInterface = node.parent.kind === 230 /* InterfaceDeclaration */ || node.parent.kind === 163 /* TypeLiteral */ || inAmbientContext; @@ -39859,7 +40209,7 @@ var ts; } // Abstract methods can't have an implementation -- in particular, they don't need one. if (lastSeenNonAmbientDeclaration && !lastSeenNonAmbientDeclaration.body && - !(ts.getModifierFlags(lastSeenNonAmbientDeclaration) & 128 /* Abstract */) && !lastSeenNonAmbientDeclaration.questionToken) { + !ts.hasModifier(lastSeenNonAmbientDeclaration, 128 /* Abstract */) && !lastSeenNonAmbientDeclaration.questionToken) { reportImplementationExpectedError(lastSeenNonAmbientDeclaration); } if (hasOverloads) { @@ -40426,7 +40776,7 @@ var ts; // checkFunctionOrConstructorSymbol wouldn't be called if we didnt ignore javascript function. var firstDeclaration = ts.find(localSymbol.declarations, // Get first non javascript function declaration - function (declaration) { return declaration.kind === node.kind && !ts.isSourceFileJavaScript(ts.getSourceFileOfNode(declaration)); }); + function (declaration) { return declaration.kind === node.kind && !(declaration.flags & 65536 /* JavaScriptFile */); }); // Only type check the symbol once if (node === firstDeclaration) { checkFunctionOrConstructorSymbol(localSymbol); @@ -40569,14 +40919,14 @@ var ts; for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; if (member.kind === 151 /* MethodDeclaration */ || member.kind === 149 /* PropertyDeclaration */) { - if (!member.symbol.isReferenced && ts.getModifierFlags(member) & 8 /* Private */) { + if (!member.symbol.isReferenced && ts.hasModifier(member, 8 /* Private */)) { error(member.name, ts.Diagnostics._0_is_declared_but_never_used, ts.unescapeLeadingUnderscores(member.symbol.escapedName)); } } else if (member.kind === 152 /* Constructor */) { for (var _b = 0, _c = member.parameters; _b < _c.length; _b++) { var parameter = _c[_b]; - if (!parameter.symbol.isReferenced && ts.getModifierFlags(parameter) & 8 /* Private */) { + if (!parameter.symbol.isReferenced && ts.hasModifier(parameter, 8 /* Private */)) { error(parameter.name, ts.Diagnostics.Property_0_is_declared_but_never_used, ts.unescapeLeadingUnderscores(parameter.symbol.escapedName)); } } @@ -40997,7 +41347,7 @@ var ts; 128 /* Abstract */ | 64 /* Readonly */ | 32 /* Static */; - return (ts.getModifierFlags(left) & interestingFlags) === (ts.getModifierFlags(right) & interestingFlags); + return ts.getSelectedModifierFlags(left, interestingFlags) === ts.getSelectedModifierFlags(right, interestingFlags); } function checkVariableDeclaration(node) { checkGrammarVariableDeclaration(node); @@ -41162,7 +41512,7 @@ var ts; } // unknownType is returned i.e. if node.expression is identifier whose name cannot be resolved // in this case error about missing name is already reported - do not report extra one - if (!isTypeAnyOrAllConstituentTypesHaveKind(rightType, 32768 /* Object */ | 540672 /* TypeVariable */ | 16777216 /* NonPrimitive */)) { + if (!isTypeAssignableToKind(rightType, 16777216 /* NonPrimitive */ | 540672 /* TypeVariable */)) { error(node.expression, ts.Diagnostics.The_right_hand_side_of_a_for_in_statement_must_be_of_type_any_an_object_type_or_a_type_parameter); } checkSourceElement(node.statement); @@ -41662,7 +42012,7 @@ var ts; // Only process instance properties with computed names here. // Static properties cannot be in conflict with indexers, // and properties with literal names were already checked. - if (!(ts.getModifierFlags(member) & 32 /* Static */) && ts.hasDynamicName(member)) { + if (!ts.hasModifier(member, 32 /* Static */) && ts.hasDynamicName(member)) { var propType = getTypeOfSymbol(member.symbol); checkIndexConstraintForProperty(member.symbol, propType, type, declaredStringIndexer, stringIndexType, 0 /* String */); checkIndexConstraintForProperty(member.symbol, propType, type, declaredNumberIndexer, numberIndexType, 1 /* Number */); @@ -41773,8 +42123,8 @@ var ts; if (!areTypeParametersIdentical(declarations, type.localTypeParameters)) { // Report an error on every conflicting declaration. var name = symbolToString(symbol); - for (var _i = 0, declarations_6 = declarations; _i < declarations_6.length; _i++) { - var declaration = declarations_6[_i]; + for (var _i = 0, declarations_5 = declarations; _i < declarations_5.length; _i++) { + var declaration = declarations_5[_i]; error(declaration.name, ts.Diagnostics.All_declarations_of_0_must_have_identical_type_parameters, name); } } @@ -41783,8 +42133,8 @@ var ts; function areTypeParametersIdentical(declarations, typeParameters) { var maxTypeArgumentCount = ts.length(typeParameters); var minTypeArgumentCount = getMinTypeArgumentCount(typeParameters); - for (var _i = 0, declarations_7 = declarations; _i < declarations_7.length; _i++) { - var declaration = declarations_7[_i]; + for (var _i = 0, declarations_6 = declarations; _i < declarations_6.length; _i++) { + var declaration = declarations_6[_i]; // If this declaration has too few or too many type parameters, we report an error var numTypeParameters = ts.length(declaration.typeParameters); if (numTypeParameters < minTypeArgumentCount || numTypeParameters > maxTypeArgumentCount) { @@ -41827,7 +42177,7 @@ var ts; registerForUnusedIdentifiersCheck(node); } function checkClassDeclaration(node) { - if (!node.name && !(ts.getModifierFlags(node) & 512 /* Default */)) { + if (!node.name && !ts.hasModifier(node, 512 /* Default */)) { grammarErrorOnFirstToken(node, ts.Diagnostics.A_class_declaration_without_the_default_modifier_must_have_a_name); } checkClassLikeDeclaration(node); @@ -41925,7 +42275,7 @@ var ts; var signatures = getSignaturesOfType(type, 1 /* Construct */); if (signatures.length) { var declaration = signatures[0].declaration; - if (declaration && ts.getModifierFlags(declaration) & 8 /* Private */) { + if (declaration && ts.hasModifier(declaration, 8 /* Private */)) { var typeClassDeclaration = getClassLikeDeclarationOfSymbol(type.symbol); if (!isNodeWithinClass(node, typeClassDeclaration)) { error(node, ts.Diagnostics.Cannot_extend_a_class_0_Class_constructor_is_marked_as_private, getFullyQualifiedName(type.symbol)); @@ -41981,7 +42331,7 @@ var ts; // 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 & 128 /* Abstract */ && (!derivedClassDecl || !(ts.getModifierFlags(derivedClassDecl) & 128 /* Abstract */))) { + if (baseDeclarationFlags & 128 /* Abstract */ && (!derivedClassDecl || !ts.hasModifier(derivedClassDecl, 128 /* Abstract */))) { if (derivedClassDecl.kind === 199 /* ClassExpression */) { error(derivedClassDecl, ts.Diagnostics.Non_abstract_class_expression_does_not_implement_inherited_abstract_member_0_from_class_1, symbolToString(baseProperty), typeToString(baseType)); } @@ -42032,8 +42382,8 @@ var ts; for (var _i = 0, baseTypes_2 = baseTypes; _i < baseTypes_2.length; _i++) { var base = baseTypes_2[_i]; var properties = getPropertiesOfType(getTypeWithThisArgument(base, type.thisType)); - for (var _a = 0, properties_7 = properties; _a < properties_7.length; _a++) { - var prop = properties_7[_a]; + for (var _a = 0, properties_8 = properties; _a < properties_8.length; _a++) { + var prop = properties_8[_a]; var existing = seen.get(prop.escapedName); if (!existing) { seen.set(prop.escapedName, { prop: prop, containingType: base }); @@ -42307,8 +42657,8 @@ var ts; } function getFirstNonAmbientClassOrFunctionDeclaration(symbol) { var declarations = symbol.declarations; - for (var _i = 0, declarations_8 = declarations; _i < declarations_8.length; _i++) { - var declaration = declarations_8[_i]; + for (var _i = 0, declarations_7 = declarations; _i < declarations_7.length; _i++) { + var declaration = declarations_7[_i]; if ((declaration.kind === 229 /* ClassDeclaration */ || (declaration.kind === 228 /* FunctionDeclaration */ && ts.nodeIsPresent(declaration.body))) && !ts.isInAmbientContext(declaration)) { @@ -42558,7 +42908,7 @@ var ts; // If we hit an import declaration in an illegal context, just bail out to avoid cascading errors. return; } - if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && ts.getModifierFlags(node) !== 0) { + if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && ts.hasModifiers(node)) { grammarErrorOnFirstToken(node, ts.Diagnostics.An_import_declaration_cannot_have_modifiers); } if (checkExternalImportOrExportDeclaration(node)) { @@ -42586,7 +42936,7 @@ var ts; checkGrammarDecorators(node) || checkGrammarModifiers(node); if (ts.isInternalModuleImportEqualsDeclaration(node) || checkExternalImportOrExportDeclaration(node)) { checkImportBinding(node); - if (ts.getModifierFlags(node) & 1 /* Export */) { + if (ts.hasModifier(node, 1 /* Export */)) { markExportAsReferenced(node); } if (ts.isInternalModuleImportEqualsDeclaration(node)) { @@ -42617,7 +42967,7 @@ var ts; // If we hit an export in an illegal context, just bail out to avoid cascading errors. return; } - if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && ts.getModifierFlags(node) !== 0) { + if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && ts.hasModifiers(node)) { grammarErrorOnFirstToken(node, ts.Diagnostics.An_export_declaration_cannot_have_modifiers); } if (!node.moduleSpecifier || checkExternalImportOrExportDeclaration(node)) { @@ -42682,7 +43032,7 @@ var ts; return; } // Grammar checking - if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && ts.getModifierFlags(node) !== 0) { + if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && ts.hasModifiers(node)) { grammarErrorOnFirstToken(node, ts.Diagnostics.An_export_assignment_cannot_have_modifiers); } if (node.expression.kind === 71 /* Identifier */) { @@ -42736,8 +43086,8 @@ var ts; return; } if (exportedDeclarationsCount > 1) { - for (var _i = 0, declarations_9 = declarations; _i < declarations_9.length; _i++) { - var declaration = declarations_9[_i]; + for (var _i = 0, declarations_8 = declarations; _i < declarations_8.length; _i++) { + var declaration = declarations_8[_i]; if (isNotOverload(declaration)) { diagnostics.add(ts.createDiagnosticForNode(declaration, ts.Diagnostics.Cannot_redeclare_exported_variable_0, ts.unescapeLeadingUnderscores(id))); } @@ -43046,7 +43396,7 @@ var ts; return []; } var symbols = ts.createSymbolTable(); - var memberFlags = 0 /* None */; + var isStatic = false; populateSymbols(); return symbolsToArray(symbols); function populateSymbols() { @@ -43075,7 +43425,7 @@ var ts; // add the type parameters into the symbol table // (type parameters of classDeclaration/classExpression and interface are in member property of the symbol. // Note: that the memberFlags come from previous iteration. - if (!(memberFlags & 32 /* Static */)) { + if (!isStatic) { copySymbols(getSymbolOfNode(location).members, meaning & 793064 /* Type */); } break; @@ -43089,7 +43439,7 @@ var ts; if (ts.introducesArgumentsExoticObject(location)) { copySymbol(argumentsSymbol, meaning); } - memberFlags = ts.getModifierFlags(location); + isStatic = ts.hasModifier(location, 32 /* Static */); location = location.parent; } copySymbols(globals, meaning); @@ -43351,12 +43701,7 @@ var ts; // index access if (node.parent.kind === 180 /* ElementAccessExpression */ && node.parent.argumentExpression === node) { var objectType = getTypeOfExpression(node.parent.expression); - if (objectType === unknownType) - return undefined; - var apparentType = getApparentType(objectType); - if (apparentType === unknownType) - return undefined; - return getPropertyOfType(apparentType, node.text); + return getPropertyOfType(objectType, node.text); } break; } @@ -43487,7 +43832,7 @@ var ts; */ function getParentTypeOfClassElement(node) { var classSymbol = getSymbolOfNode(node.parent); - return ts.getModifierFlags(node) & 32 /* Static */ + return ts.hasModifier(node, 32 /* Static */) ? getTypeOfSymbol(classSymbol) : getDeclaredTypeOfSymbol(classSymbol); } @@ -43769,13 +44114,13 @@ var ts; return strictNullChecks && !isOptionalParameter(parameter) && parameter.initializer && - !(ts.getModifierFlags(parameter) & 92 /* ParameterPropertyModifier */); + !ts.hasModifier(parameter, 92 /* ParameterPropertyModifier */); } function isOptionalUninitializedParameterProperty(parameter) { return strictNullChecks && isOptionalParameter(parameter) && !parameter.initializer && - !!(ts.getModifierFlags(parameter) & 92 /* ParameterPropertyModifier */); + ts.hasModifier(parameter, 92 /* ParameterPropertyModifier */); } function getNodeCheckFlags(node) { return getNodeLinks(node).flags; @@ -43835,22 +44180,22 @@ var ts; else if (type.flags & 1 /* Any */) { return ts.TypeReferenceSerializationKind.ObjectType; } - else if (isTypeOfKind(type, 1024 /* Void */ | 6144 /* Nullable */ | 8192 /* Never */)) { + else if (isTypeAssignableToKind(type, 1024 /* Void */ | 6144 /* Nullable */ | 8192 /* Never */)) { return ts.TypeReferenceSerializationKind.VoidNullableOrNeverType; } - else if (isTypeOfKind(type, 136 /* BooleanLike */)) { + else if (isTypeAssignableToKind(type, 136 /* BooleanLike */)) { return ts.TypeReferenceSerializationKind.BooleanType; } - else if (isTypeOfKind(type, 84 /* NumberLike */)) { + else if (isTypeAssignableToKind(type, 84 /* NumberLike */)) { return ts.TypeReferenceSerializationKind.NumberLikeType; } - else if (isTypeOfKind(type, 262178 /* StringLike */)) { + else if (isTypeAssignableToKind(type, 262178 /* StringLike */)) { return ts.TypeReferenceSerializationKind.StringLikeType; } else if (isTupleType(type)) { return ts.TypeReferenceSerializationKind.ArrayLikeType; } - else if (isTypeOfKind(type, 512 /* ESSymbol */)) { + else if (isTypeAssignableToKind(type, 512 /* ESSymbol */)) { return ts.TypeReferenceSerializationKind.ESSymbolType; } else if (isFunctionType(type)) { @@ -44346,7 +44691,7 @@ var ts; node.kind !== 154 /* SetAccessor */) { return grammarErrorOnNode(modifier, ts.Diagnostics.abstract_modifier_can_only_appear_on_a_class_method_or_property_declaration); } - if (!(node.parent.kind === 229 /* ClassDeclaration */ && ts.getModifierFlags(node.parent) & 128 /* Abstract */)) { + if (!(node.parent.kind === 229 /* ClassDeclaration */ && ts.hasModifier(node.parent, 128 /* Abstract */))) { return grammarErrorOnNode(modifier, ts.Diagnostics.Abstract_methods_can_only_appear_within_an_abstract_class); } if (flags & 32 /* Static */) { @@ -44469,8 +44814,7 @@ var ts; if (list && list.hasTrailingComma) { var start = list.end - ",".length; var end = list.end; - var sourceFile = ts.getSourceFileOfNode(list[0]); - return grammarErrorAtPos(sourceFile, start, end - start, ts.Diagnostics.Trailing_comma_not_allowed); + return grammarErrorAtPos(list[0], start, end - start, ts.Diagnostics.Trailing_comma_not_allowed); } } function checkGrammarTypeParameterList(typeParameters, file) { @@ -44547,7 +44891,7 @@ var ts; if (parameter.dotDotDotToken) { return grammarErrorOnNode(parameter.dotDotDotToken, ts.Diagnostics.An_index_signature_cannot_have_a_rest_parameter); } - if (ts.getModifierFlags(parameter) !== 0) { + if (ts.hasModifiers(parameter)) { return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_cannot_have_an_accessibility_modifier); } if (parameter.questionToken) { @@ -44582,19 +44926,18 @@ var ts; return checkGrammarForDisallowedTrailingComma(typeArguments) || checkGrammarForAtLeastOneTypeArgument(node, typeArguments); } - function checkGrammarForOmittedArgument(node, args) { + function checkGrammarForOmittedArgument(args) { if (args) { - var sourceFile = ts.getSourceFileOfNode(node); for (var _i = 0, args_5 = args; _i < args_5.length; _i++) { var arg = args_5[_i]; if (arg.kind === 200 /* OmittedExpression */) { - return grammarErrorAtPos(sourceFile, arg.pos, 0, ts.Diagnostics.Argument_expression_expected); + return grammarErrorAtPos(arg, arg.pos, 0, ts.Diagnostics.Argument_expression_expected); } } } } - function checkGrammarArguments(node, args) { - return checkGrammarForOmittedArgument(node, args); + function checkGrammarArguments(args) { + return checkGrammarForOmittedArgument(args); } function checkGrammarHeritageClause(node) { var types = node.types; @@ -44603,8 +44946,7 @@ var ts; } if (types && types.length === 0) { var listType = ts.tokenToString(node.token); - var sourceFile = ts.getSourceFileOfNode(node); - return grammarErrorAtPos(sourceFile, types.pos, 0, ts.Diagnostics._0_list_cannot_be_empty, listType); + return grammarErrorAtPos(node, types.pos, 0, ts.Diagnostics._0_list_cannot_be_empty, listType); } return ts.forEach(types, checkGrammarExpressionWithTypeArguments); } @@ -44850,10 +45192,10 @@ var ts; else if (ts.isInAmbientContext(accessor)) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.An_accessor_cannot_be_declared_in_an_ambient_context); } - else if (accessor.body === undefined && !(ts.getModifierFlags(accessor) & 128 /* Abstract */)) { - return grammarErrorAtPos(ts.getSourceFileOfNode(accessor), accessor.end - 1, ";".length, ts.Diagnostics._0_expected, "{"); + else if (accessor.body === undefined && !ts.hasModifier(accessor, 128 /* Abstract */)) { + return grammarErrorAtPos(accessor, accessor.end - 1, ";".length, ts.Diagnostics._0_expected, "{"); } - else if (accessor.body && ts.getModifierFlags(accessor) & 128 /* Abstract */) { + else if (accessor.body && ts.hasModifier(accessor, 128 /* Abstract */)) { return grammarErrorOnNode(accessor, ts.Diagnostics.An_abstract_accessor_cannot_have_an_implementation); } else if (accessor.typeParameters) { @@ -44910,7 +45252,7 @@ var ts; return true; } else if (node.body === undefined) { - return grammarErrorAtPos(ts.getSourceFileOfNode(node), node.end - 1, ";".length, ts.Diagnostics._0_expected, "{"); + return grammarErrorAtPos(node, node.end - 1, ";".length, ts.Diagnostics._0_expected, "{"); } } if (ts.isClassLike(node.parent)) { @@ -44991,7 +45333,7 @@ var ts; } if (node.initializer) { // Error on equals token which immediately precedes the initializer - return grammarErrorAtPos(ts.getSourceFileOfNode(node), node.initializer.pos - 1, 1, ts.Diagnostics.A_rest_element_cannot_have_an_initializer); + return grammarErrorAtPos(node, node.initializer.pos - 1, 1, ts.Diagnostics.A_rest_element_cannot_have_an_initializer); } } } @@ -45012,13 +45354,13 @@ var ts; else { // Error on equals token which immediate precedes the initializer var equalsTokenLength = "=".length; - return grammarErrorAtPos(ts.getSourceFileOfNode(node), node.initializer.pos - equalsTokenLength, equalsTokenLength, ts.Diagnostics.Initializers_are_not_allowed_in_ambient_contexts); + return grammarErrorAtPos(node, node.initializer.pos - equalsTokenLength, equalsTokenLength, ts.Diagnostics.Initializers_are_not_allowed_in_ambient_contexts); } } if (node.initializer && !(ts.isConst(node) && isStringOrNumberLiteralExpression(node.initializer))) { // Error on equals token which immediate precedes the initializer var equalsTokenLength = "=".length; - return grammarErrorAtPos(ts.getSourceFileOfNode(node), node.initializer.pos - equalsTokenLength, equalsTokenLength, ts.Diagnostics.Initializers_are_not_allowed_in_ambient_contexts); + return grammarErrorAtPos(node, node.initializer.pos - equalsTokenLength, equalsTokenLength, ts.Diagnostics.Initializers_are_not_allowed_in_ambient_contexts); } } else if (!node.initializer) { @@ -45081,7 +45423,7 @@ var ts; return true; } if (!declarationList.declarations.length) { - return grammarErrorAtPos(ts.getSourceFileOfNode(declarationList), declarations.pos, declarations.end - declarations.pos, ts.Diagnostics.Variable_declaration_list_cannot_be_empty); + return grammarErrorAtPos(declarationList, declarations.pos, declarations.end - declarations.pos, ts.Diagnostics.Variable_declaration_list_cannot_be_empty); } } function allowLetAndConstDeclarations(parent) { @@ -45127,7 +45469,8 @@ var ts; return true; } } - function grammarErrorAtPos(sourceFile, start, length, message, arg0, arg1, arg2) { + function grammarErrorAtPos(nodeForSourceFile, start, length, message, arg0, arg1, arg2) { + var sourceFile = ts.getSourceFileOfNode(nodeForSourceFile); if (!hasParseDiagnostics(sourceFile)) { diagnostics.add(ts.createFileDiagnostic(sourceFile, start, length, message, arg0, arg1, arg2)); return true; @@ -45142,7 +45485,7 @@ var ts; } function checkGrammarConstructorTypeParameters(node) { if (node.typeParameters) { - return grammarErrorAtPos(ts.getSourceFileOfNode(node), node.typeParameters.pos, node.typeParameters.end - node.typeParameters.pos, ts.Diagnostics.Type_parameters_cannot_appear_on_a_constructor_declaration); + return grammarErrorAtPos(node, node.typeParameters.pos, node.typeParameters.end - node.typeParameters.pos, ts.Diagnostics.Type_parameters_cannot_appear_on_a_constructor_declaration); } } function checkGrammarConstructorTypeAnnotation(node) { @@ -45196,7 +45539,7 @@ var ts; node.kind === 244 /* ExportDeclaration */ || node.kind === 243 /* ExportAssignment */ || node.kind === 236 /* NamespaceExportDeclaration */ || - ts.getModifierFlags(node) & (2 /* Ambient */ | 1 /* Export */ | 512 /* Default */)) { + ts.hasModifier(node, 2 /* Ambient */ | 1 /* Export */ | 512 /* Default */)) { return false; } return grammarErrorOnFirstToken(node, ts.Diagnostics.A_declare_modifier_is_required_for_a_top_level_declaration_in_a_d_ts_file); @@ -48142,7 +48485,7 @@ var ts; function createExpressionForAccessorDeclaration(properties, property, receiver, multiLine) { var _a = ts.getAllAccessorDeclarations(properties, property), firstAccessor = _a.firstAccessor, getAccessor = _a.getAccessor, setAccessor = _a.setAccessor; if (property === firstAccessor) { - var properties_8 = []; + var properties_9 = []; if (getAccessor) { var getterFunction = ts.createFunctionExpression(getAccessor.modifiers, /*asteriskToken*/ undefined, @@ -48152,7 +48495,7 @@ var ts; ts.setTextRange(getterFunction, getAccessor); ts.setOriginalNode(getterFunction, getAccessor); var getter = ts.createPropertyAssignment("get", getterFunction); - properties_8.push(getter); + properties_9.push(getter); } if (setAccessor) { var setterFunction = ts.createFunctionExpression(setAccessor.modifiers, @@ -48163,15 +48506,15 @@ var ts; ts.setTextRange(setterFunction, setAccessor); ts.setOriginalNode(setterFunction, setAccessor); var setter = ts.createPropertyAssignment("set", setterFunction); - properties_8.push(setter); + properties_9.push(setter); } - properties_8.push(ts.createPropertyAssignment("enumerable", ts.createTrue())); - properties_8.push(ts.createPropertyAssignment("configurable", ts.createTrue())); + properties_9.push(ts.createPropertyAssignment("enumerable", ts.createTrue())); + properties_9.push(ts.createPropertyAssignment("configurable", ts.createTrue())); var expression = ts.setTextRange(ts.createCall(ts.createPropertyAccess(ts.createIdentifier("Object"), "defineProperty"), /*typeArguments*/ undefined, [ receiver, createExpressionForPropertyName(property.name), - ts.createObjectLiteral(properties_8, multiLine) + ts.createObjectLiteral(properties_9, multiLine) ]), /*location*/ firstAccessor); return ts.aggregateTransformFlags(expression); @@ -50628,11 +50971,14 @@ var ts; : numElements, location), /*reuseIdentifierExpressions*/ false, location); } - else if (numElements !== 1 && (flattenContext.level < 1 /* ObjectRest */ || numElements === 0)) { + else if (numElements !== 1 && (flattenContext.level < 1 /* ObjectRest */ || numElements === 0) + || ts.every(elements, ts.isOmittedExpression)) { // For anything other than a single-element destructuring we need to generate a temporary // to ensure value is evaluated exactly once. Additionally, if we have zero elements // we need to emit *something* to ensure that in case a 'var' keyword was already emitted, // so in that case, we'll intentionally create that temporary. + // Or all the elements of the binding pattern are omitted expression such as "var [,] = [1,2]", + // then we will create temporary variable. var reuseIdentifierExpressions = !ts.isDeclarationBindingElement(parent) || numElements !== 0; value = ensureIdentifier(flattenContext, value, reuseIdentifierExpressions, location); } @@ -50919,7 +51265,16 @@ var ts; if (ts.hasModifier(node, 2 /* Ambient */)) { break; } - recordEmittedDeclarationInScope(node); + // Record these declarations provided that they have a name. + if (node.name) { + recordEmittedDeclarationInScope(node); + } + else { + // These nodes should always have names unless they are default-exports; + // however, class declaration parsing allows for undefined names, so syntactically invalid + // programs may also have an undefined name. + ts.Debug.assert(node.kind === 229 /* ClassDeclaration */ || ts.hasModifier(node, 512 /* Default */)); + } break; } } @@ -51748,8 +52103,8 @@ var ts; * @param receiver The receiver on which each property should be assigned. */ function addInitializedPropertyStatements(statements, properties, receiver) { - for (var _i = 0, properties_9 = properties; _i < properties_9.length; _i++) { - var property = properties_9[_i]; + for (var _i = 0, properties_10 = properties; _i < properties_10.length; _i++) { + var property = properties_10[_i]; var statement = ts.createStatement(transformInitializedProperty(property, receiver)); ts.setSourceMapRange(statement, ts.moveRangePastModifiers(property)); ts.setCommentRange(statement, property); @@ -51764,8 +52119,8 @@ var ts; */ function generateInitializedPropertyExpressions(properties, receiver) { var expressions = []; - for (var _i = 0, properties_10 = properties; _i < properties_10.length; _i++) { - var property = properties_10[_i]; + for (var _i = 0, properties_11 = properties; _i < properties_11.length; _i++) { + var property = properties_11[_i]; var expression = transformInitializedProperty(property, receiver); expression.startsOnNewLine = true; ts.setSourceMapRange(expression, ts.moveRangePastModifiers(property)); @@ -52928,33 +53283,30 @@ var ts; /** * Records that a declaration was emitted in the current scope, if it was the first * declaration for the provided symbol. - * - * NOTE: if there is ever a transformation above this one, we may not be able to rely - * on symbol names. */ function recordEmittedDeclarationInScope(node) { - var name = node.symbol && node.symbol.escapedName; - if (name) { - if (!currentScopeFirstDeclarationsOfName) { - currentScopeFirstDeclarationsOfName = ts.createUnderscoreEscapedMap(); - } - if (!currentScopeFirstDeclarationsOfName.has(name)) { - currentScopeFirstDeclarationsOfName.set(name, node); - } + if (!currentScopeFirstDeclarationsOfName) { + currentScopeFirstDeclarationsOfName = ts.createUnderscoreEscapedMap(); + } + var name = declaredNameInScope(node); + if (!currentScopeFirstDeclarationsOfName.has(name)) { + currentScopeFirstDeclarationsOfName.set(name, node); } } /** - * Determines whether a declaration is the first declaration with the same name emitted - * in the current scope. + * Determines whether a declaration is the first declaration with + * the same name emitted in the current scope. */ function isFirstEmittedDeclarationInScope(node) { if (currentScopeFirstDeclarationsOfName) { - var name = node.symbol && node.symbol.escapedName; - if (name) { - return currentScopeFirstDeclarationsOfName.get(name) === node; - } + var name = declaredNameInScope(node); + return currentScopeFirstDeclarationsOfName.get(name) === node; } - return false; + return true; + } + function declaredNameInScope(node) { + ts.Debug.assertNode(node.name, ts.isIdentifier); + return node.name.escapedText; } /** * Adds a leading VariableStatement for a enum or module declaration. @@ -53021,7 +53373,7 @@ var ts; if (!shouldEmitModuleDeclaration(node)) { return ts.createNotEmittedStatement(node); } - ts.Debug.assert(ts.isIdentifier(node.name), "TypeScript module should have an Identifier name."); + ts.Debug.assertNode(node.name, ts.isIdentifier, "A TypeScript namespace should have an Identifier name."); enableSubstitutionForNamespaceExports(); var statements = []; // We request to be advised when the printer is about to print this node. This allows @@ -54050,6 +54402,8 @@ var ts; return visitExpressionStatement(node); case 185 /* ParenthesizedExpression */: return visitParenthesizedExpression(node, noDestructuringValue); + case 260 /* CatchClause */: + return visitCatchClause(node); default: return ts.visitEachChild(node, visitor, context); } @@ -54130,6 +54484,12 @@ var ts; function visitParenthesizedExpression(node, noDestructuringValue) { return ts.visitEachChild(node, noDestructuringValue ? visitorNoDestructuringValue : visitor, context); } + function visitCatchClause(node) { + if (!node.variableDeclaration) { + return ts.updateCatchClause(node, ts.createVariableDeclaration(ts.createTempVariable(/*recordTempVariable*/ undefined)), ts.visitNode(node.block, visitor, ts.isBlock)); + } + return ts.visitEachChild(node, visitor, context); + } /** * Visits a BinaryExpression that contains a destructuring assignment. * @@ -54674,7 +55034,7 @@ var ts; objectProperties = ts.createAssignHelper(context, segments); } } - var element = ts.createExpressionForJsxElement(context.getEmitResolver().getJsxFactoryEntity(), compilerOptions.reactNamespace, tagName, objectProperties, ts.filter(ts.map(children, transformJsxChildToExpression), ts.isDefined), node, location); + var element = ts.createExpressionForJsxElement(context.getEmitResolver().getJsxFactoryEntity(), compilerOptions.reactNamespace, tagName, objectProperties, ts.mapDefined(children, transformJsxChildToExpression), node, location); if (isChild) { ts.startOnNewLine(element); } @@ -55378,7 +55738,7 @@ var ts; function shouldVisitNode(node) { return (node.transformFlags & 128 /* ContainsES2015 */) !== 0 || convertedLoopState !== undefined - || (hierarchyFacts & 4096 /* ConstructorWithCapturedSuper */ && ts.isStatement(node)) + || (hierarchyFacts & 4096 /* ConstructorWithCapturedSuper */ && (ts.isStatement(node) || (node.kind === 207 /* Block */))) || (ts.isIterationStatement(node, /*lookInLabeledStatements*/ false) && shouldConvertIterationStatementBody(node)) || isTypeScriptClassWrapper(node); } @@ -55733,10 +56093,12 @@ var ts; var outer = ts.createPartiallyEmittedExpression(inner); outer.end = ts.skipTrivia(currentText, node.pos); ts.setEmitFlags(outer, 1536 /* NoComments */); - return ts.createParen(ts.createCall(outer, + var result = ts.createParen(ts.createCall(outer, /*typeArguments*/ undefined, extendsClauseElement ? [ts.visitNode(extendsClauseElement.expression, visitor, ts.isExpression)] : [])); + ts.addSyntheticLeadingComment(result, 3 /* MultiLineCommentTrivia */, "* @class "); + return result; } /** * Transforms a ClassExpression or ClassDeclaration into a function body. @@ -56654,13 +57016,14 @@ var ts; ts.setTextRange(declarationList, node); ts.setCommentRange(declarationList, node); if (node.transformFlags & 8388608 /* ContainsBindingPattern */ - && (ts.isBindingPattern(node.declarations[0].name) - || ts.isBindingPattern(ts.lastOrUndefined(node.declarations).name))) { + && (ts.isBindingPattern(node.declarations[0].name) || ts.isBindingPattern(ts.lastOrUndefined(node.declarations).name))) { // If the first or last declaration is a binding pattern, we need to modify // the source map range for the declaration list. var firstDeclaration = ts.firstOrUndefined(declarations); - var lastDeclaration = ts.lastOrUndefined(declarations); - ts.setSourceMapRange(declarationList, ts.createRange(firstDeclaration.pos, lastDeclaration.end)); + if (firstDeclaration) { + var lastDeclaration = ts.lastOrUndefined(declarations); + ts.setSourceMapRange(declarationList, ts.createRange(firstDeclaration.pos, lastDeclaration.end)); + } } return declarationList; } @@ -57405,6 +57768,7 @@ var ts; function visitCatchClause(node) { var ancestorFacts = enterSubtree(4032 /* BlockScopeExcludes */, 0 /* BlockScopeIncludes */); var updated; + ts.Debug.assert(!!node.variableDeclaration, "Catch clause variable should always be present when downleveling ES2015."); if (ts.isBindingPattern(node.variableDeclaration.name)) { var temp = ts.createTempVariable(/*recordTempVariable*/ undefined); var newVariableDeclaration = ts.createVariableDeclaration(temp); @@ -59593,8 +59957,13 @@ var ts; } function transformAndEmitContinueStatement(node) { var label = findContinueTarget(node.label ? ts.unescapeLeadingUnderscores(node.label.escapedText) : undefined); - ts.Debug.assert(label > 0, "Expected continue statment to point to a valid Label."); - emitBreak(label, /*location*/ node); + if (label > 0) { + emitBreak(label, /*location*/ node); + } + else { + // invalid continue without a containing loop. Leave the node as is, per #17875. + emitStatement(node); + } } function visitContinueStatement(node) { if (inStatementContainingYield) { @@ -59607,8 +59976,13 @@ var ts; } function transformAndEmitBreakStatement(node) { var label = findBreakTarget(node.label ? ts.unescapeLeadingUnderscores(node.label.escapedText) : undefined); - ts.Debug.assert(label > 0, "Expected break statment to point to a valid Label."); - emitBreak(label, /*location*/ node); + if (label > 0) { + emitBreak(label, /*location*/ node); + } + else { + // invalid break without a containing loop, switch, or labeled statement. Leave the node as is, per #17875. + emitStatement(node); + } } function visitBreakStatement(node) { if (inStatementContainingYield) { @@ -59979,9 +60353,6 @@ var ts; var block = endBlock(); markLabel(block.endLabel); } - function isWithBlock(block) { - return block.kind === 1 /* With */; - } /** * Begins a code block for a generated `try` statement. */ @@ -60065,9 +60436,6 @@ var ts; emitNop(); exception.state = 3 /* Done */; } - function isExceptionBlock(block) { - return block.kind === 0 /* Exception */; - } /** * Begins a code block that supports `break` or `continue` statements that are defined in * the source tree and not from generated code. @@ -60218,23 +60586,24 @@ var ts; * @param labelText An optional name of a containing labeled statement. */ function findBreakTarget(labelText) { - ts.Debug.assert(blocks !== undefined); - if (labelText) { - for (var i = blockStack.length - 1; i >= 0; i--) { - var block = blockStack[i]; - if (supportsLabeledBreakOrContinue(block) && block.labelText === labelText) { - return block.breakLabel; - } - else if (supportsUnlabeledBreak(block) && hasImmediateContainingLabeledBlock(labelText, i - 1)) { - return block.breakLabel; + if (blockStack) { + if (labelText) { + for (var i = blockStack.length - 1; i >= 0; i--) { + var block = blockStack[i]; + if (supportsLabeledBreakOrContinue(block) && block.labelText === labelText) { + return block.breakLabel; + } + else if (supportsUnlabeledBreak(block) && hasImmediateContainingLabeledBlock(labelText, i - 1)) { + return block.breakLabel; + } } } - } - else { - for (var i = blockStack.length - 1; i >= 0; i--) { - var block = blockStack[i]; - if (supportsUnlabeledBreak(block)) { - return block.breakLabel; + else { + for (var i = blockStack.length - 1; i >= 0; i--) { + var block = blockStack[i]; + if (supportsUnlabeledBreak(block)) { + return block.breakLabel; + } } } } @@ -60246,20 +60615,21 @@ var ts; * @param labelText An optional name of a containing labeled statement. */ function findContinueTarget(labelText) { - ts.Debug.assert(blocks !== undefined); - if (labelText) { - for (var i = blockStack.length - 1; i >= 0; i--) { - var block = blockStack[i]; - if (supportsUnlabeledContinue(block) && hasImmediateContainingLabeledBlock(labelText, i - 1)) { - return block.continueLabel; + if (blockStack) { + if (labelText) { + for (var i = blockStack.length - 1; i >= 0; i--) { + var block = blockStack[i]; + if (supportsUnlabeledContinue(block) && hasImmediateContainingLabeledBlock(labelText, i - 1)) { + return block.continueLabel; + } } } - } - else { - for (var i = blockStack.length - 1; i >= 0; i--) { - var block = blockStack[i]; - if (supportsUnlabeledContinue(block)) { - return block.continueLabel; + else { + for (var i = blockStack.length - 1; i >= 0; i--) { + var block = blockStack[i]; + if (supportsUnlabeledContinue(block)) { + return block.continueLabel; + } } } } @@ -60301,7 +60671,7 @@ var ts; * @param location An optional source map location for the statement. */ function createInlineBreak(label, location) { - ts.Debug.assert(label > 0, "Invalid label: " + label); + ts.Debug.assertLessThan(0, label, "Invalid label"); return ts.setTextRange(ts.createReturn(ts.createArrayLiteral([ createInstruction(3 /* Break */), createLabel(label) @@ -60642,31 +61012,33 @@ var ts; for (; blockIndex < blockActions.length && blockOffsets[blockIndex] <= operationIndex; blockIndex++) { var block = blocks[blockIndex]; var blockAction = blockActions[blockIndex]; - if (isExceptionBlock(block)) { - if (blockAction === 0 /* Open */) { - if (!exceptionBlockStack) { - exceptionBlockStack = []; + switch (block.kind) { + case 0 /* Exception */: + if (blockAction === 0 /* Open */) { + if (!exceptionBlockStack) { + exceptionBlockStack = []; + } + if (!statements) { + statements = []; + } + exceptionBlockStack.push(currentExceptionBlock); + currentExceptionBlock = block; } - if (!statements) { - statements = []; + else if (blockAction === 1 /* Close */) { + currentExceptionBlock = exceptionBlockStack.pop(); } - exceptionBlockStack.push(currentExceptionBlock); - currentExceptionBlock = block; - } - else if (blockAction === 1 /* Close */) { - currentExceptionBlock = exceptionBlockStack.pop(); - } - } - else if (isWithBlock(block)) { - if (blockAction === 0 /* Open */) { - if (!withBlockStack) { - withBlockStack = []; + break; + case 1 /* With */: + if (blockAction === 0 /* Open */) { + if (!withBlockStack) { + withBlockStack = []; + } + withBlockStack.push(block); } - withBlockStack.push(block); - } - else if (blockAction === 1 /* Close */) { - withBlockStack.pop(); - } + else if (blockAction === 1 /* Close */) { + withBlockStack.pop(); + } + break; } } } @@ -64580,14 +64952,14 @@ var ts; writer.writeLine(); } } - function emitTrailingCommentsOfPosition(pos) { + function emitTrailingCommentsOfPosition(pos, prefixSpace) { if (disabled) { return; } if (extendedDiagnostics) { ts.performance.mark("beforeEmitTrailingCommentsOfPosition"); } - forEachTrailingCommentToEmit(pos, emitTrailingCommentOfPosition); + forEachTrailingCommentToEmit(pos, prefixSpace ? emitTrailingComment : emitTrailingCommentOfPosition); if (extendedDiagnostics) { ts.performance.measure("commentTime", "beforeEmitTrailingCommentsOfPosition"); } @@ -64676,17 +65048,7 @@ var ts; * @return true if the comment is a triple-slash comment else false */ function isTripleSlashComment(commentPos, commentEnd) { - // 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 (currentText.charCodeAt(commentPos + 1) === 47 /* slash */ && - commentPos + 2 < commentEnd && - currentText.charCodeAt(commentPos + 2) === 47 /* slash */) { - var textSubStr = currentText.substring(commentPos, commentEnd); - return textSubStr.match(ts.fullTripleSlashReferencePathRegEx) || - textSubStr.match(ts.fullTripleSlashAMDReferencePathRegEx) ? - true : false; - } - return false; + return ts.isRecognizedTripleSlashComment(currentText, commentPos, commentEnd); } } ts.createCommentWriter = createCommentWriter; @@ -64972,7 +65334,6 @@ var ts; errorNameNode = declaration.name; var format = 4 /* UseTypeOfFunction */ | 16384 /* WriteClassExpressionAsTypeLiteral */ | - 2048 /* UseTypeAliasValue */ | (shouldUseResolverType ? 8192 /* AddUndefined */ : 0); resolver.writeTypeOfDeclaration(declaration, enclosingDeclaration, format, writer); errorNameNode = undefined; @@ -64987,7 +65348,7 @@ var ts; } else { errorNameNode = signature.name; - resolver.writeReturnTypeOfSignatureDeclaration(signature, enclosingDeclaration, 4 /* UseTypeOfFunction */ | 2048 /* UseTypeAliasValue */ | 16384 /* WriteClassExpressionAsTypeLiteral */, writer); + resolver.writeReturnTypeOfSignatureDeclaration(signature, enclosingDeclaration, 4 /* UseTypeOfFunction */ | 16384 /* WriteClassExpressionAsTypeLiteral */, writer); errorNameNode = undefined; } } @@ -65225,7 +65586,7 @@ var ts; write(tempVarName); write(": "); writer.getSymbolAccessibilityDiagnostic = function () { return diagnostic; }; - resolver.writeTypeOfExpression(expr, enclosingDeclaration, 4 /* UseTypeOfFunction */ | 2048 /* UseTypeAliasValue */ | 16384 /* WriteClassExpressionAsTypeLiteral */, writer); + resolver.writeTypeOfExpression(expr, enclosingDeclaration, 4 /* UseTypeOfFunction */ | 16384 /* WriteClassExpressionAsTypeLiteral */, writer); write(";"); writeLine(); return tempVarName; @@ -65898,6 +66259,10 @@ var ts; return ts.forEach(node.declarationList.declarations, function (varDeclaration) { return resolver.isDeclarationVisible(varDeclaration); }); } function writeVariableStatement(node) { + // If binding pattern doesn't have name, then there is nothing to be emitted for declaration file i.e. const [,] = [1,2]. + if (ts.every(node.declarationList && node.declarationList.declarations, function (decl) { return decl.name && ts.isEmptyBindingPattern(decl.name); })) { + return; + } emitJsDocComments(node); emitModuleElementDeclarationFlags(node); if (ts.isLet(node.declarationList)) { @@ -67437,7 +67802,9 @@ var ts; if (!(ts.getEmitFlags(node) & 131072 /* NoIndentation */)) { var dotRangeStart = node.expression.end; var dotRangeEnd = ts.skipTrivia(currentSourceFile.text, node.expression.end) + 1; - var dotToken = { kind: 23 /* DotToken */, pos: dotRangeStart, end: dotRangeEnd }; + var dotToken = ts.createToken(23 /* DotToken */); + dotToken.pos = dotRangeStart; + dotToken.end = dotRangeEnd; indentBeforeDot = needsIndentation(node, node.expression, dotToken); indentAfterDot = needsIndentation(node, dotToken, node.name); } @@ -67566,7 +67933,9 @@ var ts; var indentAfterOperator = needsIndentation(node, node.operatorToken, node.right); emitExpression(node.left); increaseIndentIf(indentBeforeOperator, isCommaOperator ? " " : undefined); + emitLeadingCommentsOfPosition(node.operatorToken.pos); writeTokenNode(node.operatorToken); + emitTrailingCommentsOfPosition(node.operatorToken.end, /*prefixSpace*/ true); // Binary operators should have a space before the comment starts increaseIndentIf(indentAfterOperator, " "); emitExpression(node.right); decreaseIndentIf(indentBeforeOperator, indentAfterOperator); @@ -67760,8 +68129,19 @@ var ts; emitWithPrefix(" ", node.label); write(";"); } + function emitTokenWithComment(token, pos, contextNode) { + var node = contextNode && ts.getParseTreeNode(contextNode); + if (node && node.kind === contextNode.kind) { + pos = ts.skipTrivia(currentSourceFile.text, pos); + } + pos = writeToken(token, pos, /*contextNode*/ contextNode); + if (node && node.kind === contextNode.kind) { + emitTrailingCommentsOfPosition(pos, /*prefixSpace*/ true); + } + return pos; + } function emitReturnStatement(node) { - writeToken(96 /* ReturnKeyword */, node.pos, /*contextNode*/ node); + emitTokenWithComment(96 /* ReturnKeyword */, node.pos, /*contextNode*/ node); emitExpressionWithPrefix(" ", node.expression); write(";"); } @@ -68237,10 +68617,12 @@ var ts; function emitCatchClause(node) { var openParenPos = writeToken(74 /* CatchKeyword */, node.pos); write(" "); - writeToken(19 /* OpenParenToken */, openParenPos); - emit(node.variableDeclaration); - writeToken(20 /* CloseParenToken */, node.variableDeclaration ? node.variableDeclaration.end : openParenPos); - write(" "); + if (node.variableDeclaration) { + writeToken(19 /* OpenParenToken */, openParenPos); + emit(node.variableDeclaration); + writeToken(20 /* CloseParenToken */, node.variableDeclaration.end); + write(" "); + } emit(node.block); } // @@ -69520,6 +69902,14 @@ var ts; var loader_2 = function (typesRef, containingFile) { return ts.resolveTypeReferenceDirective(typesRef, containingFile, options, host).resolvedTypeReferenceDirective; }; resolveTypeReferenceDirectiveNamesWorker = function (typeReferenceDirectiveNames, containingFile) { return loadWithLocalCache(checkAllDefined(typeReferenceDirectiveNames), containingFile, loader_2); }; } + // Map from a stringified PackageId to the source file with that id. + // Only one source file may have a given packageId. Others become redirects (see createRedirectSourceFile). + // `packageIdToSourceFile` is only used while building the program, while `sourceFileToPackageName` and `isSourceFileTargetOfRedirect` are kept around. + var packageIdToSourceFile = ts.createMap(); + // Maps from a SourceFile's `.path` to the name of the package it was imported with. + var sourceFileToPackageName = ts.createMap(); + // See `sourceFileIsRedirectedTo`. + var redirectTargetsSet = ts.createMap(); var filesByName = ts.createMap(); // stores 'filename -> file association' ignoring case // used to track cases when two file names differ only in casing @@ -69588,6 +69978,8 @@ var ts; isSourceFileFromExternalLibrary: isSourceFileFromExternalLibrary, dropDiagnosticsProducingTypeChecker: dropDiagnosticsProducingTypeChecker, getSourceFileFromReference: getSourceFileFromReference, + sourceFileToPackageName: sourceFileToPackageName, + redirectTargetsSet: redirectTargetsSet, }; verifyCompilerOptions(); ts.performance.mark("afterProgram"); @@ -69780,17 +70172,57 @@ var ts; var filePaths = []; var modifiedSourceFiles = []; oldProgram.structureIsReused = 2 /* Completely */; - for (var _i = 0, _a = oldProgram.getSourceFiles(); _i < _a.length; _i++) { - var oldSourceFile = _a[_i]; + var oldSourceFiles = oldProgram.getSourceFiles(); + var SeenPackageName; + (function (SeenPackageName) { + SeenPackageName[SeenPackageName["Exists"] = 0] = "Exists"; + SeenPackageName[SeenPackageName["Modified"] = 1] = "Modified"; + })(SeenPackageName || (SeenPackageName = {})); + var seenPackageNames = ts.createMap(); + for (var _i = 0, oldSourceFiles_1 = oldSourceFiles; _i < oldSourceFiles_1.length; _i++) { + var oldSourceFile = oldSourceFiles_1[_i]; var newSourceFile = host.getSourceFileByPath ? host.getSourceFileByPath(oldSourceFile.fileName, oldSourceFile.path, options.target) : host.getSourceFile(oldSourceFile.fileName, options.target); if (!newSourceFile) { return oldProgram.structureIsReused = 0 /* Not */; } + ts.Debug.assert(!newSourceFile.redirectInfo, "Host should not return a redirect source file from `getSourceFile`"); + var fileChanged = void 0; + if (oldSourceFile.redirectInfo) { + // We got `newSourceFile` by path, so it is actually for the unredirected file. + // This lets us know if the unredirected file has changed. If it has we should break the redirect. + if (newSourceFile !== oldSourceFile.redirectInfo.unredirected) { + // Underlying file has changed. Might not redirect anymore. Must rebuild program. + return oldProgram.structureIsReused = 0 /* Not */; + } + fileChanged = false; + newSourceFile = oldSourceFile; // Use the redirect. + } + else if (oldProgram.redirectTargetsSet.has(oldSourceFile.path)) { + // If a redirected-to source file changes, the redirect may be broken. + if (newSourceFile !== oldSourceFile) { + return oldProgram.structureIsReused = 0 /* Not */; + } + fileChanged = false; + } + else { + fileChanged = newSourceFile !== oldSourceFile; + } newSourceFile.path = oldSourceFile.path; filePaths.push(newSourceFile.path); - if (oldSourceFile !== newSourceFile) { + var packageName = oldProgram.sourceFileToPackageName.get(oldSourceFile.path); + if (packageName !== undefined) { + // If there are 2 different source files for the same package name and at least one of them changes, + // they might become redirects. So we must rebuild the program. + var prevKind = seenPackageNames.get(packageName); + var newKind = fileChanged ? 1 /* Modified */ : 0 /* Exists */; + if ((prevKind !== undefined && newKind === 1 /* Modified */) || prevKind === 1 /* Modified */) { + return oldProgram.structureIsReused = 0 /* Not */; + } + seenPackageNames.set(packageName, newKind); + } + if (fileChanged) { // The `newSourceFile` object was created for the new program. if (oldSourceFile.hasNoDefaultLib !== newSourceFile.hasNoDefaultLib) { // value of no-default-lib has changed @@ -69831,8 +70263,8 @@ var ts; } modifiedFilePaths = modifiedSourceFiles.map(function (f) { return f.newFile.path; }); // try to verify results of module resolution - for (var _b = 0, modifiedSourceFiles_1 = modifiedSourceFiles; _b < modifiedSourceFiles_1.length; _b++) { - var _c = modifiedSourceFiles_1[_b], oldSourceFile = _c.oldFile, newSourceFile = _c.newFile; + for (var _a = 0, modifiedSourceFiles_1 = modifiedSourceFiles; _a < modifiedSourceFiles_1.length; _a++) { + var _b = modifiedSourceFiles_1[_a], oldSourceFile = _b.oldFile, newSourceFile = _b.newFile; var newSourceFilePath = ts.getNormalizedAbsolutePath(newSourceFile.fileName, currentDirectory); if (resolveModuleNamesWorker) { var moduleNames = ts.map(ts.concatenate(newSourceFile.imports, newSourceFile.moduleAugmentations), getTextOfLiteral); @@ -69875,8 +70307,8 @@ var ts; if (oldProgram.getMissingFilePaths().some(function (missingFilePath) { return host.fileExists(missingFilePath); })) { return oldProgram.structureIsReused = 1 /* SafeModules */; } - for (var _d = 0, _e = oldProgram.getMissingFilePaths(); _d < _e.length; _d++) { - var p = _e[_d]; + for (var _c = 0, _d = oldProgram.getMissingFilePaths(); _c < _d.length; _c++) { + var p = _d[_c]; filesByName.set(p, undefined); } // update fileName -> file mapping @@ -69885,11 +70317,13 @@ var ts; } files = newSourceFiles; fileProcessingDiagnostics = oldProgram.getFileProcessingDiagnostics(); - for (var _f = 0, modifiedSourceFiles_2 = modifiedSourceFiles; _f < modifiedSourceFiles_2.length; _f++) { - var modifiedFile = modifiedSourceFiles_2[_f]; + for (var _e = 0, modifiedSourceFiles_2 = modifiedSourceFiles; _e < modifiedSourceFiles_2.length; _e++) { + var modifiedFile = modifiedSourceFiles_2[_e]; fileProcessingDiagnostics.reattachFileDiagnostics(modifiedFile.newFile); } resolvedTypeReferenceDirectives = oldProgram.getResolvedTypeReferenceDirectives(); + sourceFileToPackageName = oldProgram.sourceFileToPackageName; + redirectTargetsSet = oldProgram.redirectTargetsSet; return oldProgram.structureIsReused = 2 /* Completely */; } function getEmitHost(writeFileCallback) { @@ -70436,7 +70870,7 @@ var ts; } /** This has side effects through `findSourceFile`. */ function processSourceFile(fileName, isDefaultLib, refFile, refPos, refEnd) { - getSourceFileFromReferenceWorker(fileName, function (fileName) { return findSourceFile(fileName, toPath(fileName), isDefaultLib, refFile, refPos, refEnd); }, function (diagnostic) { + getSourceFileFromReferenceWorker(fileName, function (fileName) { return findSourceFile(fileName, toPath(fileName), isDefaultLib, refFile, refPos, refEnd, /*packageId*/ undefined); }, function (diagnostic) { var args = []; for (var _i = 1; _i < arguments.length; _i++) { args[_i - 1] = arguments[_i]; @@ -70453,8 +70887,25 @@ var ts; fileProcessingDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.File_name_0_differs_from_already_included_file_name_1_only_in_casing, fileName, existingFileName)); } } + function createRedirectSourceFile(redirectTarget, unredirected, fileName, path) { + var redirect = Object.create(redirectTarget); + redirect.fileName = fileName; + redirect.path = path; + redirect.redirectInfo = { redirectTarget: redirectTarget, unredirected: unredirected }; + Object.defineProperties(redirect, { + id: { + get: function () { return this.redirectInfo.redirectTarget.id; }, + set: function (value) { this.redirectInfo.redirectTarget.id = value; }, + }, + symbol: { + get: function () { return this.redirectInfo.redirectTarget.symbol; }, + set: function (value) { this.redirectInfo.redirectTarget.symbol = value; }, + }, + }); + return redirect; + } // Get source file from normalized fileName - function findSourceFile(fileName, path, isDefaultLib, refFile, refPos, refEnd) { + function findSourceFile(fileName, path, isDefaultLib, refFile, refPos, refEnd, packageId) { if (filesByName.has(path)) { var file_1 = filesByName.get(path); // try to check if we've already seen this file but with a different casing in path @@ -70490,6 +70941,25 @@ var ts; fileProcessingDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_read_file_0_Colon_1, fileName, hostErrorMessage)); } }); + if (packageId) { + var packageIdKey = packageId.name + "@" + packageId.version; + var fileFromPackageId = packageIdToSourceFile.get(packageIdKey); + if (fileFromPackageId) { + // Some other SourceFile already exists with this package name and version. + // Instead of creating a duplicate, just redirect to the existing one. + var dupFile = createRedirectSourceFile(fileFromPackageId, file, fileName, path); + redirectTargetsSet.set(fileFromPackageId.path, true); + filesByName.set(path, dupFile); + sourceFileToPackageName.set(path, packageId.name); + files.push(dupFile); + return dupFile; + } + else if (file) { + // This is the first source file to have this packageId. + packageIdToSourceFile.set(packageIdKey, file); + sourceFileToPackageName.set(path, packageId.name); + } + } filesByName.set(path, file); if (file) { sourceFilesFoundSearchingNodeModules.set(path, currentNodeModulesDepth > 0); @@ -70630,7 +71100,7 @@ var ts; else if (shouldAddFile) { var path = toPath(resolvedFileName); var pos = ts.skipTrivia(file.text, file.imports[i].pos); - findSourceFile(resolvedFileName, path, /*isDefaultLib*/ false, file, pos, file.imports[i].end); + findSourceFile(resolvedFileName, path, /*isDefaultLib*/ false, file, pos, file.imports[i].end, resolution.packageId); } if (isFromNodeModulesSearch) { currentNodeModulesDepth--; @@ -70785,8 +71255,8 @@ var ts; } // there has to be common source directory if user specified --outdir || --sourceRoot // if user specified --mapRoot, there needs to be common source directory if there would be multiple files being emitted - if (options.outDir || - options.sourceRoot || + if (options.outDir || // there is --outDir specified + options.sourceRoot || // there is --sourceRoot specified options.mapRoot) { // Precalculate and cache the common source directory var dir = getCommonSourceDirectory(); @@ -71349,6 +71819,12 @@ var ts; category: ts.Diagnostics.Module_Resolution_Options, description: ts.Diagnostics.Allow_default_imports_from_modules_with_no_default_export_This_does_not_affect_code_emit_just_typechecking }, + { + name: "preserveSymlinks", + type: "boolean", + category: ts.Diagnostics.Module_Resolution_Options, + description: ts.Diagnostics.Do_not_resolve_the_real_path_of_symlinks, + }, // Source Maps { name: "sourceRoot", @@ -72006,7 +72482,7 @@ var ts; if (option && typeof option.type !== "string") { var customOption = option; // Validate custom option type - if (!customOption.type.has(text)) { + if (!customOption.type.has(text.toLowerCase())) { errors.push(createDiagnosticForInvalidCustomType(customOption, function (message, arg0, arg1) { return ts.createDiagnosticForNodeInSourceFile(sourceFile, valueExpression, message, arg0, arg1); })); } } @@ -72306,13 +72782,10 @@ var ts; } } else { - // If no includes were specified, exclude common package folders and the outDir - var specs = includeSpecs ? [] : ["node_modules", "bower_components", "jspm_packages"]; var outDir = raw["compilerOptions"] && raw["compilerOptions"]["outDir"]; if (outDir) { - specs.push(outDir); + excludeSpecs = [outDir]; } - excludeSpecs = specs; } if (fileNames === undefined && includeSpecs === undefined) { includeSpecs = ["**/*"]; @@ -72573,7 +73046,7 @@ var ts; return value; } else if (typeof option.type !== "string") { - return option.type.get(value); + return option.type.get(typeof value === "string" ? value.toLowerCase() : value); } return normalizeNonListOptionValue(option, basePath, value); } @@ -72748,23 +73221,13 @@ var ts; }; } function validateSpecs(specs, errors, allowTrailingRecursion, jsonSourceFile, specKey) { - var validSpecs = []; - for (var _i = 0, specs_1 = specs; _i < specs_1.length; _i++) { - var spec = specs_1[_i]; - if (!allowTrailingRecursion && invalidTrailingRecursionPattern.test(spec)) { - errors.push(createDiagnostic(ts.Diagnostics.File_specification_cannot_end_in_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0, spec)); + return specs.filter(function (spec) { + var diag = specToDiagnostic(spec, allowTrailingRecursion); + if (diag !== undefined) { + errors.push(createDiagnostic(diag, spec)); } - else if (invalidMultipleRecursionPatterns.test(spec)) { - errors.push(createDiagnostic(ts.Diagnostics.File_specification_cannot_contain_multiple_recursive_directory_wildcards_Asterisk_Asterisk_Colon_0, spec)); - } - else if (invalidDotDotAfterRecursiveWildcardPattern.test(spec)) { - errors.push(createDiagnostic(ts.Diagnostics.File_specification_cannot_contain_a_parent_directory_that_appears_after_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0, spec)); - } - else { - validSpecs.push(spec); - } - } - return validSpecs; + return diag === undefined; + }); function createDiagnostic(message, spec) { if (jsonSourceFile && jsonSourceFile.jsonObject) { for (var _i = 0, _a = ts.getPropertyAssignment(jsonSourceFile.jsonObject, specKey); _i < _a.length; _i++) { @@ -72782,6 +73245,17 @@ var ts; return ts.createCompilerDiagnostic(message, spec); } } + function specToDiagnostic(spec, allowTrailingRecursion) { + if (!allowTrailingRecursion && invalidTrailingRecursionPattern.test(spec)) { + return ts.Diagnostics.File_specification_cannot_end_in_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0; + } + else if (invalidMultipleRecursionPatterns.test(spec)) { + return ts.Diagnostics.File_specification_cannot_contain_multiple_recursive_directory_wildcards_Asterisk_Asterisk_Colon_0; + } + else if (invalidDotDotAfterRecursiveWildcardPattern.test(spec)) { + return ts.Diagnostics.File_specification_cannot_contain_a_parent_directory_that_appears_after_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0; + } + } /** * Gets directories in a set of include patterns that should be watched for changes. */ @@ -72945,7 +73419,7 @@ var ts; (function (ts) { var ScriptSnapshot; (function (ScriptSnapshot) { - var StringScriptSnapshot = (function () { + var StringScriptSnapshot = /** @class */ (function () { function StringScriptSnapshot(text) { this.text = text; } @@ -72969,7 +73443,7 @@ var ts; } ScriptSnapshot.fromString = fromString; })(ScriptSnapshot = ts.ScriptSnapshot || (ts.ScriptSnapshot = {})); - var TextChange = (function () { + var TextChange = /** @class */ (function () { function TextChange() { } return TextChange; @@ -73831,8 +74305,14 @@ var ts; } } ts.findNextToken = findNextToken; + /** + * Finds the rightmost token satisfying `token.end <= position`, + * excluding `JsxText` tokens containing only whitespace. + */ function findPrecedingToken(position, sourceFile, startNode, includeJsDoc) { - return find(startNode || sourceFile); + var result = find(startNode || sourceFile); + ts.Debug.assert(!(result && isWhiteSpaceOnlyJsxText(result))); + return result; function findRightmostToken(n) { if (ts.isToken(n)) { return n; @@ -73848,18 +74328,16 @@ var ts; var children = n.getChildren(); for (var i = 0; i < children.length; i++) { var child = children[i]; - // 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 === 10 /* JsxText */)) { + // Note that the span of a node's tokens is [node.getStart(...), node.end). + // Given that `position < child.end` and child has constituent tokens, we distinguish these cases: + // 1) `position` precedes `child`'s tokens or `child` has no tokens (ie: in a comment or whitespace preceding `child`): + // we need to find the last token in a previous child. + // 2) `position` is within the same span: we recurse on `child`. + if (position < child.end) { var start = child.getStart(sourceFile, includeJsDoc); - var lookInPreviousChild = (start >= position) || - (child.kind === 10 /* JsxText */ && start === child.end); // whitespace only JsxText + var lookInPreviousChild = (start >= position) || // cursor in the leading trivia + !nodeHasTokens(child) || + isWhiteSpaceOnlyJsxText(child); if (lookInPreviousChild) { // actual start of the node is past the position - previous token should be at the end of previous child var candidate = findRightmostChildNodeWithTokens(children, /*exclusiveStartPosition*/ i); @@ -73881,10 +74359,16 @@ var ts; return candidate && findRightmostToken(candidate); } } - /// finds last node that is considered as candidate for search (isCandidate(node) === true) starting from 'exclusiveStartPosition' + /** + * Finds the rightmost child to the left of `children[exclusiveStartPosition]` which is a non-all-whitespace token or has constituent tokens. + */ function findRightmostChildNodeWithTokens(children, exclusiveStartPosition) { for (var i = exclusiveStartPosition - 1; i >= 0; i--) { - if (nodeHasTokens(children[i])) { + var child = children[i]; + if (isWhiteSpaceOnlyJsxText(child)) { + ts.Debug.assert(i > 0, "`JsxText` tokens should not be the first child of `JsxElement | JsxSelfClosingElement`"); + } + else if (nodeHasTokens(children[i])) { return children[i]; } } @@ -73942,6 +74426,10 @@ var ts; return false; } ts.isInsideJsxElementOrAttribute = isInsideJsxElementOrAttribute; + function isWhiteSpaceOnlyJsxText(node) { + return ts.isJsxText(node) && node.containsOnlyWhiteSpaces; + } + ts.isWhiteSpaceOnlyJsxText = isWhiteSpaceOnlyJsxText; function isInTemplateString(sourceFile, position) { var token = getTokenAtPosition(sourceFile, position, /*includeJsDocComment*/ false); return ts.isTemplateLiteralKind(token.kind) && position > token.getStart(sourceFile); @@ -73954,39 +74442,9 @@ var ts; * @param predicate Additional predicate to test on the comment range. */ function isInComment(sourceFile, position, tokenAtPosition, predicate) { - if (tokenAtPosition === void 0) { tokenAtPosition = getTokenAtPosition(sourceFile, position, /*includeJsDocComment*/ false); } - return position <= tokenAtPosition.getStart(sourceFile) && - (isInCommentRange(ts.getLeadingCommentRanges(sourceFile.text, tokenAtPosition.pos)) || - isInCommentRange(ts.getTrailingCommentRanges(sourceFile.text, tokenAtPosition.pos))); - function isInCommentRange(commentRanges) { - return ts.forEach(commentRanges, function (c) { return isPositionInCommentRange(c, position, sourceFile.text) && (!predicate || predicate(c)); }); - } + return !!ts.formatting.getRangeOfEnclosingComment(sourceFile, position, /*onlyMultiLine*/ false, /*precedingToken*/ undefined, tokenAtPosition, predicate); } ts.isInComment = isInComment; - function isPositionInCommentRange(_a, position, text) { - var pos = _a.pos, end = _a.end, kind = _a.kind; - if (pos < position && position < end) { - return true; - } - else if (position === end) { - // The end marker of a single-line comment does not include the newline character. - // In the following case, we are inside a comment (^ denotes the cursor position): - // - // // asdf ^\n - // - // But for multi-line comments, we don't want to be inside the comment in the following case: - // - // /* asdf */^ - // - // Internally, we represent the end of the comment at the newline and closing '/', respectively. - return kind === 2 /* SingleLineCommentTrivia */ || - // true for unterminated multi-line comment - !(text.charCodeAt(end - 1) === 47 /* slash */ && text.charCodeAt(end - 2) === 42 /* asterisk */); - } - else { - return false; - } - } function hasDocComment(sourceFile, position) { var token = getTokenAtPosition(sourceFile, position, /*includeJsDocComment*/ false); // First, we have to see if this position actually landed in a comment. @@ -74000,7 +74458,7 @@ var ts; ts.hasDocComment = hasDocComment; function nodeHasTokens(n) { // If we have a token or node that has a non-zero width, it must have tokens. - // Note, that getWidth() does not take trivia into account. + // Note: getWidth() does not take trivia into account. return n.getWidth() !== 0; } function getNodeModifiers(node) { @@ -74357,6 +74815,7 @@ var ts; } ts.symbolToDisplayParts = symbolToDisplayParts; function signatureToDisplayParts(typechecker, signature, enclosingDeclaration, flags) { + flags |= 65536 /* UseAliasDefinedOutsideCurrentScope */; return mapToDisplayParts(function (writer) { typechecker.getSymbolDisplayBuilder().buildSignatureDisplay(signature, writer, enclosingDeclaration, flags); }); @@ -74666,11 +75125,11 @@ var ts; templateStack.pop(); } else { - ts.Debug.assert(token === 15 /* TemplateMiddle */, "Should have been a template middle. Was " + token); + ts.Debug.assertEqual(token, 15 /* TemplateMiddle */, "Should have been a template middle."); } } else { - ts.Debug.assert(lastTemplateStackToken === 17 /* OpenBraceToken */, "Should have been an open brace. Was: " + token); + ts.Debug.assertEqual(lastTemplateStackToken, 17 /* OpenBraceToken */, "Should have been an open brace"); templateStack.pop(); } } @@ -76652,7 +77111,7 @@ var ts; if (!typeForObject) return false; // In a binding pattern, get only known properties. Everywhere else we will get all possible properties. - typeMembers = typeChecker.getPropertiesOfType(typeForObject); + typeMembers = typeChecker.getPropertiesOfType(typeForObject).filter(function (symbol) { return !(ts.getDeclarationModifierFlagsFromSymbol(symbol) & 24 /* NonPublicAccessibilityModifier */); }); existingMembers = objectLikeContainer.elements; } } @@ -76916,11 +77375,11 @@ var ts; return containingNodeKind === 226 /* VariableDeclaration */ || containingNodeKind === 227 /* VariableDeclarationList */ || containingNodeKind === 208 /* VariableStatement */ || - containingNodeKind === 232 /* EnumDeclaration */ || + containingNodeKind === 232 /* EnumDeclaration */ || // enum a { foo, | isFunctionLikeButNotConstructor(containingNodeKind) || - containingNodeKind === 230 /* InterfaceDeclaration */ || - containingNodeKind === 175 /* ArrayBindingPattern */ || - containingNodeKind === 231 /* TypeAliasDeclaration */ || + containingNodeKind === 230 /* InterfaceDeclaration */ || // interface A undefined); => should get use to the declaration in file "./foo" + // + // function bar(onfulfilled: (value: T) => void) { //....} + // interface Test { + // pr/*destination*/op1: number + // } + // bar(({pr/*goto*/op1})=>{}); + if (ts.isPropertyName(node) && ts.isBindingElement(node.parent) && ts.isObjectBindingPattern(node.parent.parent) && + (node === (node.parent.propertyName || node.parent.name))) { + var type = typeChecker.getTypeAtLocation(node.parent.parent); + if (type) { + var propSymbols = ts.getPropertySymbolsFromType(type, node); + if (propSymbols) { + return ts.flatMap(propSymbols, function (propSymbol) { return getDefinitionFromSymbol(typeChecker, propSymbol, node); }); + } + } + } // If the current location we want to find its definition is in an object literal, try to get the contextual type for the // object literal, lookup the property symbol in the contextual type, and use this for goto-definition. // For example @@ -80614,12 +81104,20 @@ var ts; "crypto", "stream", "util", "assert", "tty", "domain", "constants", "process", "v8", "timers", "console" ]; - var nodeCoreModules = ts.arrayToMap(JsTyping.nodeCoreModuleList, function (x) { return x; }); + var nodeCoreModules = ts.arrayToSet(JsTyping.nodeCoreModuleList); function loadSafeList(host, safeListPath) { var result = ts.readConfigFile(safeListPath, function (path) { return host.readFile(path); }); return ts.createMapFromTemplate(result.config); } JsTyping.loadSafeList = loadSafeList; + function loadTypesMap(host, typesMapPath) { + var result = ts.readConfigFile(typesMapPath, function (path) { return host.readFile(path); }); + if (result.config) { + return ts.createMapFromTemplate(result.config.simpleMap); + } + return undefined; + } + JsTyping.loadTypesMap = loadTypesMap; /** * @param host is the object providing I/O related operations. * @param fileNames are the file names that belong to the same project @@ -80812,8 +81310,8 @@ var ts; if (!matches) { return; // continue to next named declarations } - for (var _i = 0, declarations_12 = declarations; _i < declarations_12.length; _i++) { - var declaration = declarations_12[_i]; + for (var _i = 0, declarations_11 = declarations; _i < declarations_11.length; _i++) { + var declaration = declarations_11[_i]; // It was a match! If the pattern has dots in it, then also see if the // declaration container matches as well. if (patternMatcher.patternContainsDots) { @@ -81549,13 +82047,18 @@ var ts; (function (ts) { var OutliningElementsCollector; (function (OutliningElementsCollector) { + var collapseText = "..."; + var maxDepth = 20; function collectElements(sourceFile, cancellationToken) { var elements = []; - var collapseText = "..."; - function addOutliningSpan(hintSpanNode, startElement, endElement, autoCollapse) { + var depth = 0; + walk(sourceFile); + return elements; + /** If useFullStart is true, then the collapsing span includes leading whitespace, including linebreaks. */ + function addOutliningSpan(hintSpanNode, startElement, endElement, autoCollapse, useFullStart) { if (hintSpanNode && startElement && endElement) { var span_13 = { - textSpan: ts.createTextSpanFromBounds(startElement.pos, endElement.end), + textSpan: ts.createTextSpanFromBounds(useFullStart ? startElement.getFullStart() : startElement.getStart(), endElement.getEnd()), hintSpan: ts.createTextSpanFromNode(hintSpanNode, sourceFile), bannerText: collapseText, autoCollapse: autoCollapse, @@ -81619,8 +82122,6 @@ var ts; function autoCollapse(node) { return ts.isFunctionBlock(node) && node.parent.kind !== 187 /* ArrowFunction */; } - var depth = 0; - var maxDepth = 20; function walk(n) { cancellationToken.throwIfCancellationRequested(); if (depth > maxDepth) { @@ -81633,8 +82134,8 @@ var ts; case 207 /* Block */: if (!ts.isFunctionBlock(n)) { var parent = n.parent; - var openBrace = ts.findChildOfKind(n, 17 /* OpenBraceToken */, sourceFile); - var closeBrace = ts.findChildOfKind(n, 18 /* CloseBraceToken */, sourceFile); + var openBrace_1 = ts.findChildOfKind(n, 17 /* OpenBraceToken */, sourceFile); + var closeBrace_1 = ts.findChildOfKind(n, 18 /* CloseBraceToken */, sourceFile); // Check if the block is standalone, or 'attached' to some parent statement. // If the latter, we want to collapse the block, but consider its hint span // to be the entire span of the parent. @@ -81646,20 +82147,20 @@ var ts; parent.kind === 213 /* WhileStatement */ || parent.kind === 220 /* WithStatement */ || parent.kind === 260 /* CatchClause */) { - addOutliningSpan(parent, openBrace, closeBrace, autoCollapse(n)); + addOutliningSpan(parent, openBrace_1, closeBrace_1, autoCollapse(n), /*useFullStart*/ true); break; } if (parent.kind === 224 /* TryStatement */) { // Could be the try-block, or the finally-block. var tryStatement = parent; if (tryStatement.tryBlock === n) { - addOutliningSpan(parent, openBrace, closeBrace, autoCollapse(n)); + addOutliningSpan(parent, openBrace_1, closeBrace_1, autoCollapse(n), /*useFullStart*/ true); break; } else if (tryStatement.finallyBlock === n) { var finallyKeyword = ts.findChildOfKind(tryStatement, 87 /* FinallyKeyword */, sourceFile); if (finallyKeyword) { - addOutliningSpan(finallyKeyword, openBrace, closeBrace, autoCollapse(n)); + addOutliningSpan(finallyKeyword, openBrace_1, closeBrace_1, autoCollapse(n), /*useFullStart*/ true); break; } } @@ -81678,33 +82179,38 @@ var ts; } // falls through case 234 /* ModuleBlock */: { - var openBrace = ts.findChildOfKind(n, 17 /* OpenBraceToken */, sourceFile); - var closeBrace = ts.findChildOfKind(n, 18 /* CloseBraceToken */, sourceFile); - addOutliningSpan(n.parent, openBrace, closeBrace, autoCollapse(n)); + var openBrace_2 = ts.findChildOfKind(n, 17 /* OpenBraceToken */, sourceFile); + var closeBrace_2 = ts.findChildOfKind(n, 18 /* CloseBraceToken */, sourceFile); + addOutliningSpan(n.parent, openBrace_2, closeBrace_2, autoCollapse(n), /*useFullStart*/ true); break; } case 229 /* ClassDeclaration */: case 230 /* InterfaceDeclaration */: case 232 /* EnumDeclaration */: - case 178 /* ObjectLiteralExpression */: case 235 /* CaseBlock */: { - var openBrace = ts.findChildOfKind(n, 17 /* OpenBraceToken */, sourceFile); - var closeBrace = ts.findChildOfKind(n, 18 /* CloseBraceToken */, sourceFile); - addOutliningSpan(n, openBrace, closeBrace, autoCollapse(n)); + var openBrace_3 = ts.findChildOfKind(n, 17 /* OpenBraceToken */, sourceFile); + var closeBrace_3 = ts.findChildOfKind(n, 18 /* CloseBraceToken */, sourceFile); + addOutliningSpan(n, openBrace_3, closeBrace_3, autoCollapse(n), /*useFullStart*/ true); break; } + // If the block has no leading keywords and is inside an array literal, + // we only want to collapse the span of the block. + // Otherwise, the collapsed section will include the end of the previous line. + case 178 /* ObjectLiteralExpression */: + var openBrace = ts.findChildOfKind(n, 17 /* OpenBraceToken */, sourceFile); + var closeBrace = ts.findChildOfKind(n, 18 /* CloseBraceToken */, sourceFile); + addOutliningSpan(n, openBrace, closeBrace, autoCollapse(n), /*useFullStart*/ !ts.isArrayLiteralExpression(n.parent)); + break; case 177 /* ArrayLiteralExpression */: var openBracket = ts.findChildOfKind(n, 21 /* OpenBracketToken */, sourceFile); var closeBracket = ts.findChildOfKind(n, 22 /* CloseBracketToken */, sourceFile); - addOutliningSpan(n, openBracket, closeBracket, autoCollapse(n)); + addOutliningSpan(n, openBracket, closeBracket, autoCollapse(n), /*useFullStart*/ !ts.isArrayLiteralExpression(n.parent)); break; } depth++; ts.forEachChild(n, walk); depth--; } - walk(sourceFile); - return elements; } OutliningElementsCollector.collectElements = collectElements; })(OutliningElementsCollector = ts.OutliningElementsCollector || (ts.OutliningElementsCollector = {})); @@ -82760,8 +83266,8 @@ var ts; var nameToDeclarations = sourceFile.getNamedDeclarations(); var declarations = nameToDeclarations.get(name.text); if (declarations) { - for (var _b = 0, declarations_13 = declarations; _b < declarations_13.length; _b++) { - var declaration = declarations_13[_b]; + for (var _b = 0, declarations_12 = declarations; _b < declarations_12.length; _b++) { + var declaration = declarations_12[_b]; var symbol = declaration.symbol; if (symbol) { var type = typeChecker.getTypeOfSymbolAtLocation(symbol, declaration); @@ -82820,7 +83326,9 @@ var ts; } var kind = invocation.typeArguments && invocation.typeArguments.pos === list.pos ? 0 /* TypeArguments */ : 1 /* CallArguments */; var argumentCount = getArgumentCount(list); - ts.Debug.assert(argumentIndex === 0 || argumentIndex < argumentCount, "argumentCount < argumentIndex, " + argumentCount + " < " + argumentIndex); + if (argumentIndex !== 0) { + ts.Debug.assertLessThan(argumentIndex, argumentCount); + } var argumentsSpan = getApplicableSpanForArguments(list, sourceFile); return { kind: kind, invocation: invocation, argumentsSpan: argumentsSpan, argumentIndex: argumentIndex, argumentCount: argumentCount }; } @@ -82942,7 +83450,9 @@ var ts; var argumentCount = tagExpression.template.kind === 13 /* NoSubstitutionTemplateLiteral */ ? 1 : tagExpression.template.templateSpans.length + 1; - ts.Debug.assert(argumentIndex === 0 || argumentIndex < argumentCount, "argumentCount < argumentIndex, " + argumentCount + " < " + argumentIndex); + if (argumentIndex !== 0) { + ts.Debug.assertLessThan(argumentIndex, argumentCount); + } return { kind: 2 /* TaggedTemplateArguments */, invocation: tagExpression, @@ -83060,7 +83570,9 @@ var ts; tags: candidateSignature.getJsDocTags() }; }); - ts.Debug.assert(argumentIndex === 0 || argumentIndex < argumentCount, "argumentCount < argumentIndex, " + argumentCount + " < " + argumentIndex); + if (argumentIndex !== 0) { + ts.Debug.assertLessThan(argumentIndex, argumentCount); + } var selectedItemIndex = candidates.indexOf(resolvedSignature); ts.Debug.assert(selectedItemIndex !== -1); // If candidates is non-empty it should always include bestSignature. We check for an empty candidates before calling this function. return { items: items, applicableSpan: applicableSpan, selectedItemIndex: selectedItemIndex, argumentIndex: argumentIndex, argumentCount: argumentCount }; @@ -83209,114 +83721,112 @@ var ts; } var signature = void 0; type = isThisExpression ? typeChecker.getTypeAtLocation(location) : typeChecker.getTypeOfSymbolAtLocation(symbol.exportSymbol || symbol, location); - if (type) { - if (location.parent && location.parent.kind === 179 /* PropertyAccessExpression */) { - var right = location.parent.name; - // Either the location is on the right of a property access, or on the left and the right is missing - if (right === location || (right && right.getFullWidth() === 0)) { - location = location.parent; + if (location.parent && location.parent.kind === 179 /* PropertyAccessExpression */) { + var right = location.parent.name; + // Either the location is on the right of a property access, or on the left and the right is missing + if (right === location || (right && right.getFullWidth() === 0)) { + location = location.parent; + } + } + // try get the call/construct signature from the type if it matches + var callExpressionLike = void 0; + if (ts.isCallOrNewExpression(location)) { + callExpressionLike = location; + } + else if (ts.isCallExpressionTarget(location) || ts.isNewExpressionTarget(location)) { + callExpressionLike = location.parent; + } + else if (location.parent && ts.isJsxOpeningLikeElement(location.parent) && ts.isFunctionLike(symbol.valueDeclaration)) { + callExpressionLike = location.parent; + } + if (callExpressionLike) { + var candidateSignatures = []; + signature = typeChecker.getResolvedSignature(callExpressionLike, candidateSignatures); + if (!signature && candidateSignatures.length) { + // Use the first candidate: + signature = candidateSignatures[0]; + } + var useConstructSignatures = callExpressionLike.kind === 182 /* NewExpression */ || (ts.isCallExpression(callExpressionLike) && callExpressionLike.expression.kind === 97 /* SuperKeyword */); + var allSignatures = useConstructSignatures ? type.getConstructSignatures() : type.getCallSignatures(); + if (!ts.contains(allSignatures, signature.target) && !ts.contains(allSignatures, signature)) { + // Get the first signature if there is one -- allSignatures may contain + // either the original signature or its target, so check for either + signature = allSignatures.length ? allSignatures[0] : undefined; + } + if (signature) { + if (useConstructSignatures && (symbolFlags & 32 /* Class */)) { + // Constructor + symbolKind = "constructor" /* constructorImplementationElement */; + addPrefixForAnyFunctionOrVar(type.symbol, symbolKind); } - } - // try get the call/construct signature from the type if it matches - var callExpressionLike = void 0; - if (ts.isCallOrNewExpression(location)) { - callExpressionLike = location; - } - else if (ts.isCallExpressionTarget(location) || ts.isNewExpressionTarget(location)) { - callExpressionLike = location.parent; - } - else if (location.parent && ts.isJsxOpeningLikeElement(location.parent) && ts.isFunctionLike(symbol.valueDeclaration)) { - callExpressionLike = location.parent; - } - if (callExpressionLike) { - var candidateSignatures = []; - signature = typeChecker.getResolvedSignature(callExpressionLike, candidateSignatures); - if (!signature && candidateSignatures.length) { - // Use the first candidate: - signature = candidateSignatures[0]; - } - var useConstructSignatures = callExpressionLike.kind === 182 /* NewExpression */ || (ts.isCallExpression(callExpressionLike) && callExpressionLike.expression.kind === 97 /* SuperKeyword */); - var allSignatures = useConstructSignatures ? type.getConstructSignatures() : type.getCallSignatures(); - if (!ts.contains(allSignatures, signature.target) && !ts.contains(allSignatures, signature)) { - // Get the first signature if there is one -- allSignatures may contain - // either the original signature or its target, so check for either - signature = allSignatures.length ? allSignatures[0] : undefined; - } - if (signature) { - if (useConstructSignatures && (symbolFlags & 32 /* Class */)) { - // Constructor - symbolKind = "constructor" /* constructorImplementationElement */; - addPrefixForAnyFunctionOrVar(type.symbol, symbolKind); + else if (symbolFlags & 2097152 /* Alias */) { + symbolKind = "alias" /* alias */; + pushTypePart(symbolKind); + displayParts.push(ts.spacePart()); + if (useConstructSignatures) { + displayParts.push(ts.keywordPart(94 /* NewKeyword */)); + displayParts.push(ts.spacePart()); } - else if (symbolFlags & 2097152 /* Alias */) { - symbolKind = "alias" /* alias */; - pushTypePart(symbolKind); + addFullSymbolName(symbol); + } + else { + addPrefixForAnyFunctionOrVar(symbol, symbolKind); + } + switch (symbolKind) { + case "JSX attribute" /* jsxAttribute */: + case "property" /* memberVariableElement */: + case "var" /* variableElement */: + case "const" /* constElement */: + case "let" /* letElement */: + case "parameter" /* parameterElement */: + case "local var" /* localVariableElement */: + // If it is call or construct signature of lambda's write type name + displayParts.push(ts.punctuationPart(56 /* ColonToken */)); displayParts.push(ts.spacePart()); if (useConstructSignatures) { displayParts.push(ts.keywordPart(94 /* NewKeyword */)); displayParts.push(ts.spacePart()); } - addFullSymbolName(symbol); - } - else { - addPrefixForAnyFunctionOrVar(symbol, symbolKind); - } - switch (symbolKind) { - case "JSX attribute" /* jsxAttribute */: - case "property" /* memberVariableElement */: - case "var" /* variableElement */: - case "const" /* constElement */: - case "let" /* letElement */: - case "parameter" /* parameterElement */: - case "local var" /* localVariableElement */: - // If it is call or construct signature of lambda's write type name - displayParts.push(ts.punctuationPart(56 /* ColonToken */)); - displayParts.push(ts.spacePart()); - if (useConstructSignatures) { - displayParts.push(ts.keywordPart(94 /* NewKeyword */)); - displayParts.push(ts.spacePart()); - } - if (!(type.flags & 32768 /* Object */ && type.objectFlags & 16 /* Anonymous */) && type.symbol) { - ts.addRange(displayParts, ts.symbolToDisplayParts(typeChecker, type.symbol, enclosingDeclaration, /*meaning*/ undefined, 1 /* WriteTypeParametersOrArguments */)); - } - addSignatureDisplayParts(signature, allSignatures, 16 /* WriteArrowStyleSignature */); - break; - default: - // Just signature - addSignatureDisplayParts(signature, allSignatures); - } - hasAddedSymbolInfo = true; + if (!(type.flags & 32768 /* Object */ && type.objectFlags & 16 /* Anonymous */) && type.symbol) { + ts.addRange(displayParts, ts.symbolToDisplayParts(typeChecker, type.symbol, enclosingDeclaration, /*meaning*/ undefined, 1 /* WriteTypeParametersOrArguments */)); + } + addSignatureDisplayParts(signature, allSignatures, 16 /* WriteArrowStyleSignature */); + break; + default: + // Just signature + addSignatureDisplayParts(signature, allSignatures); } + hasAddedSymbolInfo = true; } - else if ((ts.isNameOfFunctionDeclaration(location) && !(symbolFlags & 98304 /* Accessor */)) || - (location.kind === 123 /* ConstructorKeyword */ && location.parent.kind === 152 /* Constructor */)) { - // get the signature from the declaration and write it - var functionDeclaration_1 = location.parent; - // Use function declaration to write the signatures only if the symbol corresponding to this declaration - var locationIsSymbolDeclaration = ts.findDeclaration(symbol, function (declaration) { - return declaration === (location.kind === 123 /* ConstructorKeyword */ ? functionDeclaration_1.parent : functionDeclaration_1); - }); - if (locationIsSymbolDeclaration) { - var allSignatures = functionDeclaration_1.kind === 152 /* Constructor */ ? type.getNonNullableType().getConstructSignatures() : type.getNonNullableType().getCallSignatures(); - if (!typeChecker.isImplementationOfOverload(functionDeclaration_1)) { - signature = typeChecker.getSignatureFromDeclaration(functionDeclaration_1); - } - else { - signature = allSignatures[0]; - } - if (functionDeclaration_1.kind === 152 /* Constructor */) { - // show (constructor) Type(...) signature - symbolKind = "constructor" /* constructorImplementationElement */; - addPrefixForAnyFunctionOrVar(type.symbol, symbolKind); - } - else { - // (function/method) symbol(..signature) - addPrefixForAnyFunctionOrVar(functionDeclaration_1.kind === 155 /* CallSignature */ && - !(type.symbol.flags & 2048 /* TypeLiteral */ || type.symbol.flags & 4096 /* ObjectLiteral */) ? type.symbol : symbol, symbolKind); - } - addSignatureDisplayParts(signature, allSignatures); - hasAddedSymbolInfo = true; + } + else if ((ts.isNameOfFunctionDeclaration(location) && !(symbolFlags & 98304 /* Accessor */)) || // name of function declaration + (location.kind === 123 /* ConstructorKeyword */ && location.parent.kind === 152 /* Constructor */)) { + // get the signature from the declaration and write it + var functionDeclaration_1 = location.parent; + // Use function declaration to write the signatures only if the symbol corresponding to this declaration + var locationIsSymbolDeclaration = ts.find(symbol.declarations, function (declaration) { + return declaration === (location.kind === 123 /* ConstructorKeyword */ ? functionDeclaration_1.parent : functionDeclaration_1); + }); + if (locationIsSymbolDeclaration) { + var allSignatures = functionDeclaration_1.kind === 152 /* Constructor */ ? type.getNonNullableType().getConstructSignatures() : type.getNonNullableType().getCallSignatures(); + if (!typeChecker.isImplementationOfOverload(functionDeclaration_1)) { + signature = typeChecker.getSignatureFromDeclaration(functionDeclaration_1); } + else { + signature = allSignatures[0]; + } + if (functionDeclaration_1.kind === 152 /* Constructor */) { + // show (constructor) Type(...) signature + symbolKind = "constructor" /* constructorImplementationElement */; + addPrefixForAnyFunctionOrVar(type.symbol, symbolKind); + } + else { + // (function/method) symbol(..signature) + addPrefixForAnyFunctionOrVar(functionDeclaration_1.kind === 155 /* CallSignature */ && + !(type.symbol.flags & 2048 /* TypeLiteral */ || type.symbol.flags & 4096 /* ObjectLiteral */) ? type.symbol : symbol, symbolKind); + } + addSignatureDisplayParts(signature, allSignatures); + hasAddedSymbolInfo = true; } } } @@ -83502,7 +84012,9 @@ var ts; symbolFlags & 98304 /* Accessor */ || symbolKind === "method" /* memberFunctionElement */) { var allSignatures = type.getNonNullableType().getCallSignatures(); - addSignatureDisplayParts(allSignatures[0], allSignatures); + if (allSignatures.length) { + addSignatureDisplayParts(allSignatures[0], allSignatures); + } } } } @@ -83676,11 +84188,11 @@ var ts; getSourceFile: function (fileName) { return fileName === ts.normalizePath(inputFileName) ? sourceFile : undefined; }, writeFile: function (name, text) { if (ts.fileExtensionIs(name, ".map")) { - ts.Debug.assert(sourceMapText === undefined, "Unexpected multiple source map outputs for the file '" + name + "'"); + ts.Debug.assertEqual(sourceMapText, undefined, "Unexpected multiple source map outputs, file:", name); sourceMapText = text; } else { - ts.Debug.assert(outputText === undefined, "Unexpected multiple outputs for the file: '" + name + "'"); + ts.Debug.assertEqual(outputText, undefined, "Unexpected multiple outputs, file:", name); outputText = text; } }, @@ -84005,7 +84517,7 @@ var ts; (function (ts) { var formatting; (function (formatting) { - var FormattingContext = (function () { + var FormattingContext = /** @class */ (function () { function FormattingContext(sourceFile, formattingRequestKind, options) { this.sourceFile = sourceFile; this.formattingRequestKind = formattingRequestKind; @@ -84104,7 +84616,7 @@ var ts; (function (ts) { var formatting; (function (formatting) { - var Rule = (function () { + var Rule = /** @class */ (function () { function Rule(Descriptor, Operation, Flag) { if (Flag === void 0) { Flag = 0 /* None */; } this.Descriptor = Descriptor; @@ -84142,7 +84654,7 @@ var ts; (function (ts) { var formatting; (function (formatting) { - var RuleDescriptor = (function () { + var RuleDescriptor = /** @class */ (function () { function RuleDescriptor(LeftTokenRange, RightTokenRange) { this.LeftTokenRange = LeftTokenRange; this.RightTokenRange = RightTokenRange; @@ -84187,7 +84699,7 @@ var ts; (function (ts) { var formatting; (function (formatting) { - var RuleOperation = (function () { + var RuleOperation = /** @class */ (function () { function RuleOperation(Context, Action) { this.Context = Context; this.Action = Action; @@ -84213,7 +84725,7 @@ var ts; (function (ts) { var formatting; (function (formatting) { - var RuleOperationContext = (function () { + var RuleOperationContext = /** @class */ (function () { function RuleOperationContext() { var funcs = []; for (var _i = 0; _i < arguments.length; _i++) { @@ -84248,7 +84760,7 @@ var ts; (function (ts) { var formatting; (function (formatting) { - var Rules = (function () { + var Rules = /** @class */ (function () { function Rules() { /// /// Common Rules @@ -84407,6 +84919,7 @@ var ts; // Insert space after opening and before closing nonempty parenthesis this.SpaceAfterOpenParen = new formatting.Rule(formatting.RuleDescriptor.create3(19 /* OpenParenToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis"), Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); this.SpaceBeforeCloseParen = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 20 /* CloseParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis"), Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); + this.SpaceBetweenOpenParens = new formatting.Rule(formatting.RuleDescriptor.create1(19 /* OpenParenToken */, 19 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis"), Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); this.NoSpaceBetweenParens = new formatting.Rule(formatting.RuleDescriptor.create1(19 /* OpenParenToken */, 20 /* CloseParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); this.NoSpaceAfterOpenParen = new formatting.Rule(formatting.RuleDescriptor.create3(19 /* OpenParenToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis"), Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); this.NoSpaceBeforeCloseParen = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 20 /* CloseParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis"), Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); @@ -84486,7 +84999,7 @@ var ts; this.SpaceAfterComma, this.NoSpaceAfterComma, this.SpaceAfterAnonymousFunctionKeyword, this.NoSpaceAfterAnonymousFunctionKeyword, this.SpaceAfterKeywordInControl, this.NoSpaceAfterKeywordInControl, - this.SpaceAfterOpenParen, this.SpaceBeforeCloseParen, this.NoSpaceBetweenParens, this.NoSpaceAfterOpenParen, this.NoSpaceBeforeCloseParen, + this.SpaceAfterOpenParen, this.SpaceBeforeCloseParen, this.SpaceBetweenOpenParens, this.NoSpaceBetweenParens, this.NoSpaceAfterOpenParen, this.NoSpaceBeforeCloseParen, this.SpaceAfterOpenBracket, this.SpaceBeforeCloseBracket, this.NoSpaceBetweenBrackets, this.NoSpaceAfterOpenBracket, this.NoSpaceBeforeCloseBracket, this.SpaceAfterOpenBrace, this.SpaceBeforeCloseBrace, this.NoSpaceBetweenEmptyBraceBrackets, this.NoSpaceAfterOpenBrace, this.NoSpaceBeforeCloseBrace, this.SpaceAfterTemplateHeadAndMiddle, this.SpaceBeforeTemplateMiddleAndTail, this.NoSpaceAfterTemplateHeadAndMiddle, this.NoSpaceBeforeTemplateMiddleAndTail, @@ -84825,7 +85338,7 @@ var ts; (function (ts) { var formatting; (function (formatting) { - var RulesMap = (function () { + var RulesMap = /** @class */ (function () { function RulesMap() { this.map = []; this.mapRowLength = 0; @@ -84895,7 +85408,7 @@ var ts; RulesPosition[RulesPosition["NoContextRulesSpecific"] = MaskBitSize * 4] = "NoContextRulesSpecific"; RulesPosition[RulesPosition["NoContextRulesAny"] = MaskBitSize * 5] = "NoContextRulesAny"; })(RulesPosition = formatting.RulesPosition || (formatting.RulesPosition = {})); - var RulesBucketConstructionState = (function () { + var RulesBucketConstructionState = /** @class */ (function () { function RulesBucketConstructionState() { //// The Rules list contains all the inserted rules into a rulebucket in the following order: //// 1- Ignore rules with specific token combination @@ -84936,7 +85449,7 @@ var ts; return RulesBucketConstructionState; }()); formatting.RulesBucketConstructionState = RulesBucketConstructionState; - var RulesBucket = (function () { + var RulesBucket = /** @class */ (function () { function RulesBucket() { this.rules = []; } @@ -84985,7 +85498,7 @@ var ts; for (var token = 0 /* FirstToken */; token <= 142 /* LastToken */; token++) { allTokens.push(token); } - var TokenValuesAccess = (function () { + var TokenValuesAccess = /** @class */ (function () { function TokenValuesAccess(tokens) { if (tokens === void 0) { tokens = []; } this.tokens = tokens; @@ -84999,7 +85512,7 @@ var ts; TokenValuesAccess.prototype.isSpecific = function () { return true; }; return TokenValuesAccess; }()); - var TokenSingleValueAccess = (function () { + var TokenSingleValueAccess = /** @class */ (function () { function TokenSingleValueAccess(token) { this.token = token; } @@ -85012,7 +85525,7 @@ var ts; TokenSingleValueAccess.prototype.isSpecific = function () { return true; }; return TokenSingleValueAccess; }()); - var TokenAllAccess = (function () { + var TokenAllAccess = /** @class */ (function () { function TokenAllAccess() { } TokenAllAccess.prototype.GetTokens = function () { @@ -85027,7 +85540,7 @@ var ts; TokenAllAccess.prototype.isSpecific = function () { return false; }; return TokenAllAccess; }()); - var TokenAllExceptAccess = (function () { + var TokenAllExceptAccess = /** @class */ (function () { function TokenAllExceptAccess(except) { this.except = except; } @@ -85119,7 +85632,7 @@ var ts; (function (ts) { var formatting; (function (formatting) { - var RulesProvider = (function () { + var RulesProvider = /** @class */ (function () { function RulesProvider() { this.globalRules = new formatting.Rules(); var activeRules = this.globalRules.HighPriorityCommonRules.slice(0).concat(this.globalRules.UserConfigurableRules).concat(this.globalRules.LowPriorityCommonRules); @@ -85427,7 +85940,6 @@ var ts; function formatSpanWorker(originalRange, enclosingNode, initialIndentation, delta, formattingScanner, options, rulesProvider, requestKind, rangeContainsError, sourceFile) { // formatting context is used by rules provider var formattingContext = new formatting.FormattingContext(sourceFile, requestKind, options); - var previousRangeHasError; var previousRange; var previousParent; var previousRangeStartLine; @@ -85818,7 +86330,7 @@ var ts; function processRange(range, rangeStart, parent, contextNode, dynamicIndentation) { var rangeHasError = rangeContainsError(range); var lineAdded; - if (!rangeHasError && !previousRangeHasError) { + if (!rangeHasError) { if (!previousRange) { // trim whitespaces starting from the beginning of the span up to the current line var originalStart = sourceFile.getLineAndCharacterOfPosition(originalRange.pos); @@ -85832,7 +86344,6 @@ var ts; previousRange = range; previousParent = parent; previousRangeStartLine = rangeStart.line; - previousRangeHasError = rangeHasError; return lineAdded; } function processPair(currentItem, currentStartLine, currentParent, previousItem, previousStartLine, previousParent, contextNode, dynamicIndentation) { @@ -86038,6 +86549,51 @@ var ts; } } } + /** + * @param precedingToken pass `null` if preceding token was already computed and result was `undefined`. + */ + function getRangeOfEnclosingComment(sourceFile, position, onlyMultiLine, precedingToken, // tslint:disable-line:no-null-keyword + tokenAtPosition, predicate) { + if (tokenAtPosition === void 0) { tokenAtPosition = ts.getTokenAtPosition(sourceFile, position, /*includeJsDocComment*/ false); } + var tokenStart = tokenAtPosition.getStart(sourceFile); + if (tokenStart <= position && position < tokenAtPosition.getEnd()) { + return undefined; + } + if (precedingToken === undefined) { + precedingToken = ts.findPrecedingToken(position, sourceFile); + } + // Between two consecutive tokens, all comments are either trailing on the former + // or leading on the latter (and none are in both lists). + var trailingRangesOfPreviousToken = precedingToken && ts.getTrailingCommentRanges(sourceFile.text, precedingToken.end); + var leadingCommentRangesOfNextToken = ts.getLeadingCommentRangesOfNode(tokenAtPosition, sourceFile); + var commentRanges = trailingRangesOfPreviousToken && leadingCommentRangesOfNextToken ? + trailingRangesOfPreviousToken.concat(leadingCommentRangesOfNextToken) : + trailingRangesOfPreviousToken || leadingCommentRangesOfNextToken; + if (commentRanges) { + for (var _i = 0, commentRanges_1 = commentRanges; _i < commentRanges_1.length; _i++) { + var range = commentRanges_1[_i]; + // The end marker of a single-line comment does not include the newline character. + // With caret at `^`, in the following case, we are inside a comment (^ denotes the cursor position): + // + // // asdf ^\n + // + // But for closed multi-line comments, we don't want to be inside the comment in the following case: + // + // /* asdf */^ + // + // However, unterminated multi-line comments *do* contain their end. + // + // Internally, we represent the end of the comment at the newline and closing '/', respectively. + // + if ((range.pos < position && position < range.end || + position === range.end && (range.kind === 2 /* SingleLineCommentTrivia */ || position === sourceFile.getFullWidth()))) { + return (range.kind === 3 /* MultiLineCommentTrivia */ || !onlyMultiLine) && (!predicate || predicate(range)) ? range : undefined; + } + } + } + return undefined; + } + formatting.getRangeOfEnclosingComment = getRangeOfEnclosingComment; function getOpenTokenForList(node, list) { switch (node.kind) { case 152 /* Constructor */: @@ -86165,12 +86721,28 @@ var ts; return 0; } var precedingToken = ts.findPrecedingToken(position, sourceFile); + var enclosingCommentRange = formatting.getRangeOfEnclosingComment(sourceFile, position, /*onlyMultiLine*/ true, precedingToken || null); // tslint:disable-line:no-null-keyword + if (enclosingCommentRange) { + var previousLine = ts.getLineAndCharacterOfPosition(sourceFile, position).line - 1; + var commentStartLine = ts.getLineAndCharacterOfPosition(sourceFile, enclosingCommentRange.pos).line; + ts.Debug.assert(commentStartLine >= 0); + if (previousLine <= commentStartLine) { + return findFirstNonWhitespaceColumn(ts.getStartPositionOfLine(commentStartLine, sourceFile), position, sourceFile, options); + } + var startPostionOfLine = ts.getStartPositionOfLine(previousLine, sourceFile); + var _a = findFirstNonWhitespaceCharacterAndColumn(startPostionOfLine, position, sourceFile, options), column = _a.column, character = _a.character; + if (column === 0) { + return column; + } + var firstNonWhitespaceCharacterCode = sourceFile.text.charCodeAt(startPostionOfLine + character); + return firstNonWhitespaceCharacterCode === 42 /* asterisk */ ? column - 1 : column; + } if (!precedingToken) { return getBaseIndentation(options); } // no indentation in string \regex\template literals var precedingTokenIsLiteral = ts.isStringOrRegularExpressionOrTemplateLiteral(precedingToken.kind); - if (precedingTokenIsLiteral && precedingToken.getStart(sourceFile) <= position && precedingToken.end > position) { + if (precedingTokenIsLiteral && precedingToken.getStart(sourceFile) <= position && position < precedingToken.end) { return 0; } var lineAtPosition = sourceFile.getLineAndCharacterOfPosition(position).line; @@ -86473,13 +87045,13 @@ var ts; var lineStart = sourceFile.getPositionOfLineAndCharacter(lineAndCharacter.line, 0); return findFirstNonWhitespaceColumn(lineStart, lineStart + lineAndCharacter.character, sourceFile, options); } - /* - Character is the actual index of the character since the beginning of the line. - Column - position of the character after expanding tabs to spaces - "0\t2$" - value of 'character' for '$' is 3 - value of 'column' for '$' is 6 (assuming that tab size is 4) - */ + /** + * Character is the actual index of the character since the beginning of the line. + * Column - position of the character after expanding tabs to spaces. + * "0\t2$" + * value of 'character' for '$' is 3 + * value of 'column' for '$' is 6 (assuming that tab size is 4) + */ function findFirstNonWhitespaceCharacterAndColumn(startPos, endPos, sourceFile, options) { var character = 0; var column = 0; @@ -86633,6 +87205,12 @@ var ts; } return false; } + var ChangeKind; + (function (ChangeKind) { + ChangeKind[ChangeKind["Remove"] = 0] = "Remove"; + ChangeKind[ChangeKind["ReplaceWithSingleNode"] = 1] = "ReplaceWithSingleNode"; + ChangeKind[ChangeKind["ReplaceWithMultipleNodes"] = 2] = "ReplaceWithMultipleNodes"; + })(ChangeKind || (ChangeKind = {})); function getSeparatorCharacter(separator) { return ts.tokenToString(separator.kind); } @@ -86666,13 +87244,11 @@ var ts; } textChanges.getAdjustedStartPosition = getAdjustedStartPosition; function getAdjustedEndPosition(sourceFile, node, options) { - if (options.useNonAdjustedEndPosition) { + if (options.useNonAdjustedEndPosition || ts.isExpression(node)) { return node.getEnd(); } var end = node.getEnd(); var newEnd = ts.skipTrivia(sourceFile.text, end, /*stopAfterLineBreak*/ true); - // check if last character before newPos is linebreak - // if yes - considered all skipped trivia to be trailing trivia of the node return newEnd !== end && ts.isLineBreak(sourceFile.text.charCodeAt(newEnd - 1)) ? newEnd : end; @@ -86691,7 +87267,10 @@ var ts; } return s; } - var ChangeTracker = (function () { + function getNewlineKind(context) { + return context.newLineCharacter === "\n" ? 1 /* LineFeed */ : 0 /* CarriageReturnLineFeed */; + } + var ChangeTracker = /** @class */ (function () { function ChangeTracker(newLine, rulesProvider, validator) { this.newLine = newLine; this.rulesProvider = rulesProvider; @@ -86700,24 +87279,24 @@ var ts; this.newLineCharacter = ts.getNewLineCharacter({ newLine: newLine }); } ChangeTracker.fromCodeFixContext = function (context) { - return new ChangeTracker(context.newLineCharacter === "\n" ? 1 /* LineFeed */ : 0 /* CarriageReturnLineFeed */, context.rulesProvider); + return new ChangeTracker(getNewlineKind(context), context.rulesProvider); + }; + ChangeTracker.prototype.deleteRange = function (sourceFile, range) { + this.changes.push({ kind: ChangeKind.Remove, sourceFile: sourceFile, range: range }); + return this; }; ChangeTracker.prototype.deleteNode = function (sourceFile, node, options) { if (options === void 0) { options = {}; } var startPosition = getAdjustedStartPosition(sourceFile, node, options, Position.FullStart); var endPosition = getAdjustedEndPosition(sourceFile, node, options); - this.changes.push({ sourceFile: sourceFile, options: options, range: { pos: startPosition, end: endPosition } }); - return this; - }; - ChangeTracker.prototype.deleteRange = function (sourceFile, range) { - this.changes.push({ sourceFile: sourceFile, range: range }); + this.changes.push({ kind: ChangeKind.Remove, sourceFile: sourceFile, range: { pos: startPosition, end: endPosition } }); return this; }; ChangeTracker.prototype.deleteNodeRange = function (sourceFile, startNode, endNode, options) { if (options === void 0) { options = {}; } var startPosition = getAdjustedStartPosition(sourceFile, startNode, options, Position.FullStart); var endPosition = getAdjustedEndPosition(sourceFile, endNode, options); - this.changes.push({ sourceFile: sourceFile, options: options, range: { pos: startPosition, end: endPosition } }); + this.changes.push({ kind: ChangeKind.Remove, sourceFile: sourceFile, range: { pos: startPosition, end: endPosition } }); return this; }; ChangeTracker.prototype.deleteNodeInList = function (sourceFile, node) { @@ -86756,33 +87335,68 @@ var ts; }; ChangeTracker.prototype.replaceRange = function (sourceFile, range, newNode, options) { if (options === void 0) { options = {}; } - this.changes.push({ sourceFile: sourceFile, range: range, options: options, node: newNode }); + this.changes.push({ kind: ChangeKind.ReplaceWithSingleNode, sourceFile: sourceFile, range: range, options: options, node: newNode }); return this; }; ChangeTracker.prototype.replaceNode = function (sourceFile, oldNode, newNode, options) { if (options === void 0) { options = {}; } var startPosition = getAdjustedStartPosition(sourceFile, oldNode, options, Position.Start); var endPosition = getAdjustedEndPosition(sourceFile, oldNode, options); - this.changes.push({ sourceFile: sourceFile, options: options, useIndentationFromFile: true, node: newNode, range: { pos: startPosition, end: endPosition } }); - return this; + return this.replaceWithSingle(sourceFile, startPosition, endPosition, newNode, options); }; ChangeTracker.prototype.replaceNodeRange = function (sourceFile, startNode, endNode, newNode, options) { if (options === void 0) { options = {}; } var startPosition = getAdjustedStartPosition(sourceFile, startNode, options, Position.Start); var endPosition = getAdjustedEndPosition(sourceFile, endNode, options); - this.changes.push({ sourceFile: sourceFile, options: options, useIndentationFromFile: true, node: newNode, range: { pos: startPosition, end: endPosition } }); + return this.replaceWithSingle(sourceFile, startPosition, endPosition, newNode, options); + }; + ChangeTracker.prototype.replaceWithSingle = function (sourceFile, startPosition, endPosition, newNode, options) { + this.changes.push({ + kind: ChangeKind.ReplaceWithSingleNode, + sourceFile: sourceFile, + options: options, + node: newNode, + range: { pos: startPosition, end: endPosition } + }); return this; }; + ChangeTracker.prototype.replaceWithMultiple = function (sourceFile, startPosition, endPosition, newNodes, options) { + this.changes.push({ + kind: ChangeKind.ReplaceWithMultipleNodes, + sourceFile: sourceFile, + options: options, + nodes: newNodes, + range: { pos: startPosition, end: endPosition } + }); + return this; + }; + ChangeTracker.prototype.replaceNodeWithNodes = function (sourceFile, oldNode, newNodes, options) { + var startPosition = getAdjustedStartPosition(sourceFile, oldNode, options, Position.Start); + var endPosition = getAdjustedEndPosition(sourceFile, oldNode, options); + return this.replaceWithMultiple(sourceFile, startPosition, endPosition, newNodes, options); + }; + ChangeTracker.prototype.replaceNodesWithNodes = function (sourceFile, oldNodes, newNodes, options) { + var startPosition = getAdjustedStartPosition(sourceFile, oldNodes[0], options, Position.Start); + var endPosition = getAdjustedEndPosition(sourceFile, ts.lastOrUndefined(oldNodes), options); + return this.replaceWithMultiple(sourceFile, startPosition, endPosition, newNodes, options); + }; + ChangeTracker.prototype.replaceRangeWithNodes = function (sourceFile, range, newNodes, options) { + return this.replaceWithMultiple(sourceFile, range.pos, range.end, newNodes, options); + }; + ChangeTracker.prototype.replaceNodeRangeWithNodes = function (sourceFile, startNode, endNode, newNodes, options) { + var startPosition = getAdjustedStartPosition(sourceFile, startNode, options, Position.Start); + var endPosition = getAdjustedEndPosition(sourceFile, endNode, options); + return this.replaceWithMultiple(sourceFile, startPosition, endPosition, newNodes, options); + }; ChangeTracker.prototype.insertNodeAt = function (sourceFile, pos, newNode, options) { if (options === void 0) { options = {}; } - this.changes.push({ sourceFile: sourceFile, options: options, node: newNode, range: { pos: pos, end: pos } }); + this.changes.push({ kind: ChangeKind.ReplaceWithSingleNode, sourceFile: sourceFile, options: options, node: newNode, range: { pos: pos, end: pos } }); return this; }; ChangeTracker.prototype.insertNodeBefore = function (sourceFile, before, newNode, options) { if (options === void 0) { options = {}; } var startPosition = getAdjustedStartPosition(sourceFile, before, options, Position.Start); - this.changes.push({ sourceFile: sourceFile, options: options, useIndentationFromFile: true, node: newNode, range: { pos: startPosition, end: startPosition } }); - return this; + return this.replaceWithSingle(sourceFile, startPosition, startPosition, newNode, options); }; ChangeTracker.prototype.insertNodeAfter = function (sourceFile, after, newNode, options) { if (options === void 0) { options = {}; } @@ -86794,6 +87408,7 @@ var ts; // if not - insert semicolon to preserve the code from changing the meaning due to ASI if (sourceFile.text.charCodeAt(after.end - 1) !== 59 /* semicolon */) { this.changes.push({ + kind: ChangeKind.ReplaceWithSingleNode, sourceFile: sourceFile, options: {}, range: { pos: after.end, end: after.end }, @@ -86802,8 +87417,7 @@ var ts; } } var endPosition = getAdjustedEndPosition(sourceFile, after, options); - this.changes.push({ sourceFile: sourceFile, options: options, useIndentationFromFile: true, node: newNode, range: { pos: endPosition, end: endPosition } }); - return this; + return this.replaceWithSingle(sourceFile, endPosition, endPosition, newNode, options); }; /** * This function should be used to insert nodes in lists when nodes don't carry separators as the part of the node range, @@ -86869,10 +87483,10 @@ var ts; startPos = ts.getStartPositionOfLine(lineAndCharOfNextElement.line, sourceFile); } this.changes.push({ + kind: ChangeKind.ReplaceWithSingleNode, sourceFile: sourceFile, range: { pos: startPos, end: containingList[index + 1].getStart(sourceFile) }, node: newNode, - useIndentationFromFile: true, options: { prefix: prefix, // write separator and leading trivia of the next element as suffix @@ -86911,6 +87525,7 @@ var ts; if (multilineList) { // insert separator immediately following the 'after' node to preserve comments in trailing trivia this.changes.push({ + kind: ChangeKind.ReplaceWithSingleNode, sourceFile: sourceFile, range: { pos: end, end: end }, node: ts.createToken(separator), @@ -86924,6 +87539,7 @@ var ts; insertPos--; } this.changes.push({ + kind: ChangeKind.ReplaceWithSingleNode, sourceFile: sourceFile, range: { pos: insertPos, end: insertPos }, node: newNode, @@ -86932,6 +87548,7 @@ var ts; } else { this.changes.push({ + kind: ChangeKind.ReplaceWithSingleNode, sourceFile: sourceFile, range: { pos: end, end: end }, node: newNode, @@ -86973,34 +87590,46 @@ var ts; return ts.createTextSpanFromBounds(change.range.pos, change.range.end); }; ChangeTracker.prototype.computeNewText = function (change, sourceFile) { - if (!change.node) { + var _this = this; + if (change.kind === ChangeKind.Remove) { // deletion case return ""; } var options = change.options || {}; - var nonFormattedText = getNonformattedText(change.node, sourceFile, this.newLine); - if (this.validator) { - this.validator(nonFormattedText); - } - var formatOptions = this.rulesProvider.getFormatOptions(); + var text; var pos = change.range.pos; var posStartsLine = ts.getLineStartPositionForPosition(pos, sourceFile) === pos; - var initialIndentation = change.options.indentation !== undefined - ? change.options.indentation - : change.useIndentationFromFile - ? ts.formatting.SmartIndenter.getIndentation(change.range.pos, sourceFile, formatOptions, posStartsLine || (change.options.prefix === this.newLineCharacter)) - : 0; - var delta = change.options.delta !== undefined - ? change.options.delta - : ts.formatting.SmartIndenter.shouldIndentChildNode(change.node) - ? formatOptions.indentSize - : 0; - var text = applyFormatting(nonFormattedText, sourceFile, initialIndentation, delta, this.rulesProvider); + if (change.kind === ChangeKind.ReplaceWithMultipleNodes) { + var parts = change.nodes.map(function (n) { return _this.getFormattedTextOfNode(n, sourceFile, pos, options); }); + text = parts.join(change.options.nodeSeparator); + } + else { + ts.Debug.assert(change.kind === ChangeKind.ReplaceWithSingleNode, "change.kind === ReplaceWithSingleNode"); + text = this.getFormattedTextOfNode(change.node, sourceFile, pos, options); + } // strip initial indentation (spaces or tabs) if text will be inserted in the middle of the line - // however keep indentation if it is was forced - text = posStartsLine || change.options.indentation !== undefined ? text : text.replace(/^\s+/, ""); + text = (posStartsLine || options.indentation !== undefined) ? text : text.replace(/^\s+/, ""); return (options.prefix || "") + text + (options.suffix || ""); }; + ChangeTracker.prototype.getFormattedTextOfNode = function (node, sourceFile, pos, options) { + var nonformattedText = getNonformattedText(node, sourceFile, this.newLine); + if (this.validator) { + this.validator(nonformattedText); + } + var formatOptions = this.rulesProvider.getFormatOptions(); + var posStartsLine = ts.getLineStartPositionForPosition(pos, sourceFile) === pos; + var initialIndentation = options.indentation !== undefined + ? options.indentation + : (options.useIndentationFromFile !== false) + ? ts.formatting.SmartIndenter.getIndentation(pos, sourceFile, formatOptions, posStartsLine || (options.prefix === this.newLineCharacter)) + : 0; + var delta = options.delta !== undefined + ? options.delta + : ts.formatting.SmartIndenter.shouldIndentChildNode(node) + ? (formatOptions.indentSize || 0) + : 0; + return applyFormatting(nonformattedText, sourceFile, initialIndentation, delta, this.rulesProvider); + }; ChangeTracker.normalize = function (changes) { // order changes by start position var normalized = ts.stableSort(changes, function (a, b) { return a.range.pos - b.range.pos; }); @@ -87065,7 +87694,7 @@ var ts; nodeArray.end = getEnd(nodes); return nodeArray; } - var Writer = (function () { + var Writer = /** @class */ (function () { function Writer(newLine) { var _this = this; this.lastNonTriviaPosition = 0; @@ -87948,7 +88577,7 @@ var ts; ModuleSpecifierComparison[ModuleSpecifierComparison["Equal"] = 1] = "Equal"; ModuleSpecifierComparison[ModuleSpecifierComparison["Worse"] = 2] = "Worse"; })(ModuleSpecifierComparison || (ModuleSpecifierComparison = {})); - var ImportCodeActionMap = (function () { + var ImportCodeActionMap = /** @class */ (function () { function ImportCodeActionMap() { this.symbolIdToActionMap = []; } @@ -88061,7 +88690,7 @@ var ts; } else if (ts.isJsxOpeningLikeElement(token.parent) && token.parent.tagName === token) { // The error wasn't for the symbolAtLocation, it was for the JSX tag itself, which needs access to e.g. `React`. - symbol = checker.getAliasedSymbol(checker.resolveNameAtLocation(token, checker.getJsxNamespace(), 107455 /* Value */)); + symbol = checker.getAliasedSymbol(checker.resolveName(checker.getJsxNamespace(), token.parent.tagName, 107455 /* Value */)); symbolName = symbol.name; } else { @@ -88086,7 +88715,7 @@ var ts; if (localSymbol && localSymbol.escapedName === name && checkSymbolHasMeaning(localSymbol, currentTokenMeaning)) { // check if this symbol is already used var symbolId = getUniqueSymbolId(localSymbol); - symbolIdActionMap.addActions(symbolId, getCodeActionForImport(moduleSymbol, name, /*isDefault*/ true)); + symbolIdActionMap.addActions(symbolId, getCodeActionForImport(moduleSymbol, name, /*isNamespaceImport*/ true)); } } // "default" is a keyword and not a legal identifier for the import, so we don't expect it here @@ -88162,8 +88791,8 @@ var ts; var namespaceImportDeclaration; var namedImportDeclaration; var existingModuleSpecifier; - for (var _i = 0, declarations_14 = declarations; _i < declarations_14.length; _i++) { - var declaration = declarations_14[_i]; + for (var _i = 0, declarations_13 = declarations; _i < declarations_13.length; _i++) { + var declaration = declarations_13[_i]; if (declaration.kind === 238 /* ImportDeclaration */) { var namedBindings = declaration.importClause && declaration.importClause.namedBindings; if (namedBindings && namedBindings.kind === 240 /* NamespaceImport */) { @@ -88273,9 +88902,11 @@ var ts; : isNamespaceImport ? ts.createImportClause(/*name*/ undefined, ts.createNamespaceImport(ts.createIdentifier(symbolName))) : ts.createImportClause(/*name*/ undefined, ts.createNamedImports([ts.createImportSpecifier(/*propertyName*/ undefined, ts.createIdentifier(symbolName))])); - var importDecl = ts.createImportDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, importClause, ts.createLiteral(moduleSpecifierWithoutQuotes)); + var moduleSpecifierLiteral = ts.createLiteral(moduleSpecifierWithoutQuotes); + moduleSpecifierLiteral.singleQuote = getSingleQuoteStyleFromExistingImports(); + var importDecl = ts.createImportDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, importClause, moduleSpecifierLiteral); if (!lastImportDeclaration) { - changeTracker.insertNodeAt(sourceFile, sourceFile.getStart(), importDecl, { suffix: "" + context.newLineCharacter + context.newLineCharacter }); + changeTracker.insertNodeAt(sourceFile, getSourceFileImportLocation(sourceFile), importDecl, { suffix: "" + context.newLineCharacter + context.newLineCharacter }); } else { changeTracker.insertNodeAfter(sourceFile, lastImportDeclaration, importDecl, { suffix: context.newLineCharacter }); @@ -88284,6 +88915,46 @@ var ts; // between the only import statement and user code. Otherwise just insert the statement because chances // are there are already a new line seperating code and import statements. return createCodeAction(ts.Diagnostics.Import_0_from_1, [symbolName, "\"" + moduleSpecifierWithoutQuotes + "\""], changeTracker.getChanges(), "NewImport", moduleSpecifierWithoutQuotes); + function getSourceFileImportLocation(node) { + // For a source file, it is possible there are detached comments we should not skip + var text = node.text; + var ranges = ts.getLeadingCommentRanges(text, 0); + if (!ranges) + return 0; + var position = 0; + // However we should still skip a pinned comment at the top + if (ranges.length && ranges[0].kind === 3 /* MultiLineCommentTrivia */ && ts.isPinnedComment(text, ranges[0])) { + position = ranges[0].end + 1; + ranges = ranges.slice(1); + } + // As well as any triple slash references + for (var _i = 0, ranges_1 = ranges; _i < ranges_1.length; _i++) { + var range = ranges_1[_i]; + if (range.kind === 2 /* SingleLineCommentTrivia */ && ts.isRecognizedTripleSlashComment(node.text, range.pos, range.end)) { + position = range.end + 1; + continue; + } + break; + } + return position; + } + function getSingleQuoteStyleFromExistingImports() { + var firstModuleSpecifier = ts.forEach(sourceFile.statements, function (node) { + if (ts.isImportDeclaration(node) || ts.isExportDeclaration(node)) { + if (node.moduleSpecifier && ts.isStringLiteral(node.moduleSpecifier)) { + return node.moduleSpecifier; + } + } + else if (ts.isImportEqualsDeclaration(node)) { + if (ts.isExternalModuleReference(node.moduleReference) && ts.isStringLiteral(node.moduleReference.expression)) { + return node.moduleReference.expression; + } + } + }); + if (firstModuleSpecifier) { + return sourceFile.text.charCodeAt(firstModuleSpecifier.getStart()) === 39 /* singleQuote */; + } + } function getModuleSpecifierForNewImport() { var fileName = sourceFile.fileName; var moduleFileName = moduleSymbol.valueDeclaration.getSourceFile().fileName; @@ -88415,8 +89086,8 @@ var ts; } function getNodeModulePathParts(fullPath) { // If fullPath can't be valid module file within node_modules, returns undefined. - // Example of expected pattern: /base/path/node_modules/[otherpackage/node_modules/]package/[subdirectory/]file.js - // Returns indices: ^ ^ ^ ^ + // Example of expected pattern: /base/path/node_modules/[@scope/otherpackage/@otherscope/node_modules/]package/[subdirectory/]file.js + // Returns indices: ^ ^ ^ ^ var topLevelNodeModulesIndex = 0; var topLevelPackageNameIndex = 0; var packageRootIndex = 0; @@ -88425,7 +89096,8 @@ var ts; (function (States) { States[States["BeforeNodeModules"] = 0] = "BeforeNodeModules"; States[States["NodeModules"] = 1] = "NodeModules"; - States[States["PackageContent"] = 2] = "PackageContent"; + States[States["Scope"] = 2] = "Scope"; + States[States["PackageContent"] = 3] = "PackageContent"; })(States || (States = {})); var partStart = 0; var partEnd = 0; @@ -88442,15 +89114,21 @@ var ts; } break; case 1 /* NodeModules */: - packageRootIndex = partEnd; - state = 2 /* PackageContent */; + case 2 /* Scope */: + if (state === 1 /* NodeModules */ && fullPath.charAt(partStart + 1) === "@") { + state = 2 /* Scope */; + } + else { + packageRootIndex = partEnd; + state = 3 /* PackageContent */; + } break; - case 2 /* PackageContent */: + case 3 /* PackageContent */: if (fullPath.indexOf("/node_modules/", partStart) === partStart) { state = 1 /* NodeModules */; } else { - state = 2 /* PackageContent */; + state = 3 /* PackageContent */; } break; } @@ -88807,231 +89485,1208 @@ var ts; (function (ts) { var refactor; (function (refactor) { - var actionName = "convert"; - var convertFunctionToES6Class = { - name: "Convert to ES2015 class", - description: ts.Diagnostics.Convert_function_to_an_ES2015_class.message, - getEditsForAction: getEditsForAction, - getAvailableActions: getAvailableActions - }; - refactor.registerRefactor(convertFunctionToES6Class); - function getAvailableActions(context) { - if (!ts.isInJavaScriptFile(context.file)) { - return undefined; + var convertFunctionToES6Class; + (function (convertFunctionToES6Class_1) { + var actionName = "convert"; + var convertFunctionToES6Class = { + name: "Convert to ES2015 class", + description: ts.Diagnostics.Convert_function_to_an_ES2015_class.message, + getEditsForAction: getEditsForAction, + getAvailableActions: getAvailableActions + }; + refactor.registerRefactor(convertFunctionToES6Class); + function getAvailableActions(context) { + if (!ts.isInJavaScriptFile(context.file)) { + return undefined; + } + var start = context.startPosition; + var node = ts.getTokenAtPosition(context.file, start, /*includeJsDocComment*/ false); + var checker = context.program.getTypeChecker(); + var symbol = checker.getSymbolAtLocation(node); + if (symbol && ts.isDeclarationOfFunctionOrClassExpression(symbol)) { + symbol = symbol.valueDeclaration.initializer.symbol; + } + if (symbol && (symbol.flags & 16 /* Function */) && symbol.members && (symbol.members.size > 0)) { + return [ + { + name: convertFunctionToES6Class.name, + description: convertFunctionToES6Class.description, + actions: [ + { + description: convertFunctionToES6Class.description, + name: actionName + } + ] + } + ]; + } } - var start = context.startPosition; - var node = ts.getTokenAtPosition(context.file, start, /*includeJsDocComment*/ false); - var checker = context.program.getTypeChecker(); - var symbol = checker.getSymbolAtLocation(node); - if (symbol && ts.isDeclarationOfFunctionOrClassExpression(symbol)) { - symbol = symbol.valueDeclaration.initializer.symbol; - } - if (symbol && (symbol.flags & 16 /* Function */) && symbol.members && (symbol.members.size > 0)) { - return [ - { - name: convertFunctionToES6Class.name, - description: convertFunctionToES6Class.description, - actions: [ - { - description: convertFunctionToES6Class.description, - name: actionName - } - ] + function getEditsForAction(context, action) { + // Somehow wrong action got invoked? + if (actionName !== action) { + return undefined; + } + var start = context.startPosition; + var sourceFile = context.file; + var checker = context.program.getTypeChecker(); + var token = ts.getTokenAtPosition(sourceFile, start, /*includeJsDocComment*/ false); + var ctorSymbol = checker.getSymbolAtLocation(token); + var newLine = context.rulesProvider.getFormatOptions().newLineCharacter; + var deletedNodes = []; + var deletes = []; + if (!(ctorSymbol.flags & (16 /* Function */ | 3 /* Variable */))) { + return undefined; + } + var ctorDeclaration = ctorSymbol.valueDeclaration; + var changeTracker = ts.textChanges.ChangeTracker.fromCodeFixContext(context); + var precedingNode; + var newClassDeclaration; + switch (ctorDeclaration.kind) { + case 228 /* FunctionDeclaration */: + precedingNode = ctorDeclaration; + deleteNode(ctorDeclaration); + newClassDeclaration = createClassFromFunctionDeclaration(ctorDeclaration); + break; + case 226 /* VariableDeclaration */: + precedingNode = ctorDeclaration.parent.parent; + if (ctorDeclaration.parent.declarations.length === 1) { + deleteNode(precedingNode); + } + else { + deleteNode(ctorDeclaration, /*inList*/ true); + } + newClassDeclaration = createClassFromVariableDeclaration(ctorDeclaration); + break; + } + if (!newClassDeclaration) { + return undefined; + } + // Because the preceding node could be touched, we need to insert nodes before delete nodes. + changeTracker.insertNodeAfter(sourceFile, precedingNode, newClassDeclaration, { suffix: newLine }); + for (var _i = 0, deletes_1 = deletes; _i < deletes_1.length; _i++) { + var deleteCallback = deletes_1[_i]; + deleteCallback(); + } + return { + edits: changeTracker.getChanges() + }; + function deleteNode(node, inList) { + if (inList === void 0) { inList = false; } + if (deletedNodes.some(function (n) { return ts.isNodeDescendantOf(node, n); })) { + // Parent node has already been deleted; do nothing + return; } - ]; - } - } - function getEditsForAction(context, action) { - // Somehow wrong action got invoked? - if (actionName !== action) { - return undefined; - } - var start = context.startPosition; - var sourceFile = context.file; - var checker = context.program.getTypeChecker(); - var token = ts.getTokenAtPosition(sourceFile, start, /*includeJsDocComment*/ false); - var ctorSymbol = checker.getSymbolAtLocation(token); - var newLine = context.rulesProvider.getFormatOptions().newLineCharacter; - var deletedNodes = []; - var deletes = []; - if (!(ctorSymbol.flags & (16 /* Function */ | 3 /* Variable */))) { - return undefined; - } - var ctorDeclaration = ctorSymbol.valueDeclaration; - var changeTracker = ts.textChanges.ChangeTracker.fromCodeFixContext(context); - var precedingNode; - var newClassDeclaration; - switch (ctorDeclaration.kind) { - case 228 /* FunctionDeclaration */: - precedingNode = ctorDeclaration; - deleteNode(ctorDeclaration); - newClassDeclaration = createClassFromFunctionDeclaration(ctorDeclaration); - break; - case 226 /* VariableDeclaration */: - precedingNode = ctorDeclaration.parent.parent; - if (ctorDeclaration.parent.declarations.length === 1) { - deleteNode(precedingNode); + deletedNodes.push(node); + if (inList) { + deletes.push(function () { return changeTracker.deleteNodeInList(sourceFile, node); }); } else { - deleteNode(ctorDeclaration, /*inList*/ true); + deletes.push(function () { return changeTracker.deleteNode(sourceFile, node); }); } - newClassDeclaration = createClassFromVariableDeclaration(ctorDeclaration); - break; - } - if (!newClassDeclaration) { - return undefined; - } - // Because the preceding node could be touched, we need to insert nodes before delete nodes. - changeTracker.insertNodeAfter(sourceFile, precedingNode, newClassDeclaration, { suffix: newLine }); - for (var _i = 0, deletes_1 = deletes; _i < deletes_1.length; _i++) { - var deleteCallback = deletes_1[_i]; - deleteCallback(); - } - return { - edits: changeTracker.getChanges() - }; - function deleteNode(node, inList) { - if (inList === void 0) { inList = false; } - if (deletedNodes.some(function (n) { return ts.isNodeDescendantOf(node, n); })) { - // Parent node has already been deleted; do nothing - return; } - deletedNodes.push(node); - if (inList) { - deletes.push(function () { return changeTracker.deleteNodeInList(sourceFile, node); }); + function createClassElementsFromSymbol(symbol) { + var memberElements = []; + // all instance members are stored in the "member" array of symbol + if (symbol.members) { + symbol.members.forEach(function (member) { + var memberElement = createClassElement(member, /*modifiers*/ undefined); + if (memberElement) { + memberElements.push(memberElement); + } + }); + } + // all static members are stored in the "exports" array of symbol + if (symbol.exports) { + symbol.exports.forEach(function (member) { + var memberElement = createClassElement(member, [ts.createToken(115 /* StaticKeyword */)]); + if (memberElement) { + memberElements.push(memberElement); + } + }); + } + return memberElements; + function shouldConvertDeclaration(_target, source) { + // Right now the only thing we can convert are function expressions - other values shouldn't get + // transformed. We can update this once ES public class properties are available. + return ts.isFunctionLike(source); + } + function createClassElement(symbol, modifiers) { + // both properties and methods are bound as property symbols + if (!(symbol.flags & 4 /* Property */)) { + return; + } + var memberDeclaration = symbol.valueDeclaration; + var assignmentBinaryExpression = memberDeclaration.parent; + if (!shouldConvertDeclaration(memberDeclaration, assignmentBinaryExpression.right)) { + return; + } + // delete the entire statement if this expression is the sole expression to take care of the semicolon at the end + var nodeToDelete = assignmentBinaryExpression.parent && assignmentBinaryExpression.parent.kind === 210 /* ExpressionStatement */ + ? assignmentBinaryExpression.parent : assignmentBinaryExpression; + deleteNode(nodeToDelete); + if (!assignmentBinaryExpression.right) { + return ts.createProperty([], modifiers, symbol.name, /*questionToken*/ undefined, + /*type*/ undefined, /*initializer*/ undefined); + } + switch (assignmentBinaryExpression.right.kind) { + case 186 /* FunctionExpression */: { + var functionExpression = assignmentBinaryExpression.right; + var method = ts.createMethod(/*decorators*/ undefined, modifiers, /*asteriskToken*/ undefined, memberDeclaration.name, /*questionToken*/ undefined, + /*typeParameters*/ undefined, functionExpression.parameters, /*type*/ undefined, functionExpression.body); + copyComments(assignmentBinaryExpression, method); + return method; + } + case 187 /* ArrowFunction */: { + var arrowFunction = assignmentBinaryExpression.right; + var arrowFunctionBody = arrowFunction.body; + var bodyBlock = void 0; + // case 1: () => { return [1,2,3] } + if (arrowFunctionBody.kind === 207 /* Block */) { + bodyBlock = arrowFunctionBody; + } + else { + var expression = arrowFunctionBody; + bodyBlock = ts.createBlock([ts.createReturn(expression)]); + } + var method = ts.createMethod(/*decorators*/ undefined, modifiers, /*asteriskToken*/ undefined, memberDeclaration.name, /*questionToken*/ undefined, + /*typeParameters*/ undefined, arrowFunction.parameters, /*type*/ undefined, bodyBlock); + copyComments(assignmentBinaryExpression, method); + return method; + } + default: { + // Don't try to declare members in JavaScript files + if (ts.isSourceFileJavaScript(sourceFile)) { + return; + } + var prop = ts.createProperty(/*decorators*/ undefined, modifiers, memberDeclaration.name, /*questionToken*/ undefined, + /*type*/ undefined, assignmentBinaryExpression.right); + copyComments(assignmentBinaryExpression.parent, prop); + return prop; + } + } + } + } + function copyComments(sourceNode, targetNode) { + ts.forEachLeadingCommentRange(sourceFile.text, sourceNode.pos, function (pos, end, kind, htnl) { + if (kind === 3 /* MultiLineCommentTrivia */) { + // Remove leading /* + pos += 2; + // Remove trailing */ + end -= 2; + } + else { + // Remove leading // + pos += 2; + } + ts.addSyntheticLeadingComment(targetNode, kind, sourceFile.text.slice(pos, end), htnl); + }); + } + function createClassFromVariableDeclaration(node) { + var initializer = node.initializer; + if (!initializer || initializer.kind !== 186 /* FunctionExpression */) { + return undefined; + } + if (node.name.kind !== 71 /* Identifier */) { + return undefined; + } + var memberElements = createClassElementsFromSymbol(initializer.symbol); + if (initializer.body) { + memberElements.unshift(ts.createConstructor(/*decorators*/ undefined, /*modifiers*/ undefined, initializer.parameters, initializer.body)); + } + var cls = ts.createClassDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, node.name, + /*typeParameters*/ undefined, /*heritageClauses*/ undefined, memberElements); + // Don't call copyComments here because we'll already leave them in place + return cls; + } + function createClassFromFunctionDeclaration(node) { + var memberElements = createClassElementsFromSymbol(ctorSymbol); + if (node.body) { + memberElements.unshift(ts.createConstructor(/*decorators*/ undefined, /*modifiers*/ undefined, node.parameters, node.body)); + } + var cls = ts.createClassDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, node.name, + /*typeParameters*/ undefined, /*heritageClauses*/ undefined, memberElements); + // Don't call copyComments here because we'll already leave them in place + return cls; + } + } + })(convertFunctionToES6Class = refactor.convertFunctionToES6Class || (refactor.convertFunctionToES6Class = {})); + })(refactor = ts.refactor || (ts.refactor = {})); +})(ts || (ts = {})); +/// +/// +/* @internal */ +var ts; +(function (ts) { + var refactor; + (function (refactor) { + var extractMethod; + (function (extractMethod_1) { + var extractMethod = { + name: "Extract Method", + description: ts.Diagnostics.Extract_function.message, + getAvailableActions: getAvailableActions, + getEditsForAction: getEditsForAction, + }; + refactor.registerRefactor(extractMethod); + /** Compute the associated code actions */ + function getAvailableActions(context) { + var rangeToExtract = getRangeToExtract(context.file, { start: context.startPosition, length: context.endPosition - context.startPosition }); + var targetRange = rangeToExtract.targetRange; + if (targetRange === undefined) { + return undefined; + } + var extractions = getPossibleExtractions(targetRange, context); + if (extractions === undefined) { + // No extractions possible + return undefined; + } + var actions = []; + var usedNames = ts.createMap(); + var i = 0; + for (var _i = 0, extractions_1 = extractions; _i < extractions_1.length; _i++) { + var extr = extractions_1[_i]; + // Skip these since we don't have a way to report errors yet + if (extr.errors && extr.errors.length) { + continue; + } + // Don't issue refactorings with duplicated names. + // Scopes come back in "innermost first" order, so extractions will + // preferentially go into nearer scopes + var description = ts.formatStringFromArgs(ts.Diagnostics.Extract_function_into_0.message, [extr.scopeDescription]); + if (!usedNames.has(description)) { + usedNames.set(description, true); + actions.push({ + description: description, + name: "scope_" + i + }); + } + // *do* increment i anyway because we'll look for the i-th scope + // later when actually doing the refactoring if the user requests it + i++; + } + if (actions.length === 0) { + return undefined; + } + return [{ + name: extractMethod.name, + description: extractMethod.description, + inlineable: true, + actions: actions + }]; + } + function getEditsForAction(context, actionName) { + var length = context.endPosition === undefined ? 0 : context.endPosition - context.startPosition; + var rangeToExtract = getRangeToExtract(context.file, { start: context.startPosition, length: length }); + var targetRange = rangeToExtract.targetRange; + var parsedIndexMatch = /^scope_(\d+)$/.exec(actionName); + ts.Debug.assert(!!parsedIndexMatch, "Scope name should have matched the regexp"); + var index = +parsedIndexMatch[1]; + ts.Debug.assert(isFinite(index), "Expected to parse a finite number from the scope index"); + var extractions = getPossibleExtractions(targetRange, context, index); + // Scope is no longer valid from when the user issued the refactor (??) + ts.Debug.assert(extractions !== undefined, "The extraction went missing? How?"); + return ({ edits: extractions[0].changes }); + } + // Move these into diagnostic messages if they become user-facing + var Messages; + (function (Messages) { + function createMessage(message) { + return { message: message, code: 0, category: ts.DiagnosticCategory.Message, key: message }; + } + Messages.CannotExtractFunction = createMessage("Cannot extract function."); + Messages.StatementOrExpressionExpected = createMessage("Statement or expression expected."); + Messages.CannotExtractRangeContainingConditionalBreakOrContinueStatements = createMessage("Cannot extract range containing conditional break or continue statements."); + Messages.CannotExtractRangeContainingConditionalReturnStatement = createMessage("Cannot extract range containing conditional return statement."); + Messages.CannotExtractRangeContainingLabeledBreakOrContinueStatementWithTargetOutsideOfTheRange = createMessage("Cannot extract range containing labeled break or continue with target outside of the range."); + Messages.CannotExtractRangeThatContainsWritesToReferencesLocatedOutsideOfTheTargetRangeInGenerators = createMessage("Cannot extract range containing writes to references located outside of the target range in generators."); + Messages.TypeWillNotBeVisibleInTheNewScope = createMessage("Type will not visible in the new scope."); + Messages.FunctionWillNotBeVisibleInTheNewScope = createMessage("Function will not visible in the new scope."); + Messages.InsufficientSelection = createMessage("Select more than a single identifier."); + Messages.CannotExtractExportedEntity = createMessage("Cannot extract exported declaration"); + Messages.CannotCombineWritesAndReturns = createMessage("Cannot combine writes and returns"); + Messages.CannotExtractReadonlyPropertyInitializerOutsideConstructor = createMessage("Cannot move initialization of read-only class property outside of the constructor"); + Messages.CannotExtractAmbientBlock = createMessage("Cannot extract code from ambient contexts"); + })(Messages || (Messages = {})); + var RangeFacts; + (function (RangeFacts) { + RangeFacts[RangeFacts["None"] = 0] = "None"; + RangeFacts[RangeFacts["HasReturn"] = 1] = "HasReturn"; + RangeFacts[RangeFacts["IsGenerator"] = 2] = "IsGenerator"; + RangeFacts[RangeFacts["IsAsyncFunction"] = 4] = "IsAsyncFunction"; + RangeFacts[RangeFacts["UsesThis"] = 8] = "UsesThis"; + /** + * The range is in a function which needs the 'static' modifier in a class + */ + RangeFacts[RangeFacts["InStaticRegion"] = 16] = "InStaticRegion"; + })(RangeFacts = extractMethod_1.RangeFacts || (extractMethod_1.RangeFacts = {})); + /** + * getRangeToExtract takes a span inside a text file and returns either an expression or an array + * of statements representing the minimum set of nodes needed to extract the entire span. This + * process may fail, in which case a set of errors is returned instead (these are currently + * not shown to the user, but can be used by us diagnostically) + */ + function getRangeToExtract(sourceFile, span) { + var length = span.length || 0; + // Walk up starting from the the start position until we find a non-SourceFile node that subsumes the selected span. + // This may fail (e.g. you select two statements in the root of a source file) + var start = getParentNodeInSpan(ts.getTokenAtPosition(sourceFile, span.start, /*includeJsDocComment*/ false), sourceFile, span); + // Do the same for the ending position + var end = getParentNodeInSpan(ts.findTokenOnLeftOfPosition(sourceFile, ts.textSpanEnd(span)), sourceFile, span); + var declarations = []; + // We'll modify these flags as we walk the tree to collect data + // about what things need to be done as part of the extraction. + var rangeFacts = RangeFacts.None; + if (!start || !end) { + // cannot find either start or end node + return { errors: [ts.createFileDiagnostic(sourceFile, span.start, length, Messages.CannotExtractFunction)] }; + } + if (start.parent !== end.parent) { + // handle cases like 1 + [2 + 3] + 4 + // user selection is marked with []. + // in this case 2 + 3 does not belong to the same tree node + // instead the shape of the tree looks like this: + // + + // / \ + // + 4 + // / \ + // + 3 + // / \ + // 1 2 + // in this case there is no such one node that covers ends of selection and is located inside the selection + // to handle this we check if both start and end of the selection belong to some binary operation + // and start node is parented by the parent of the end node + // if this is the case - expand the selection to the entire parent of end node (in this case it will be [1 + 2 + 3] + 4) + var startParent = ts.skipParentheses(start.parent); + var endParent = ts.skipParentheses(end.parent); + if (ts.isBinaryExpression(startParent) && ts.isBinaryExpression(endParent) && ts.isNodeDescendantOf(startParent, endParent)) { + start = end = endParent; + } + else { + // start and end nodes belong to different subtrees + return createErrorResult(sourceFile, span.start, length, Messages.CannotExtractFunction); + } + } + if (start !== end) { + // start and end should be statements and parent should be either block or a source file + if (!isBlockLike(start.parent)) { + return createErrorResult(sourceFile, span.start, length, Messages.CannotExtractFunction); + } + var statements = []; + for (var _i = 0, _a = start.parent.statements; _i < _a.length; _i++) { + var statement = _a[_i]; + if (statement === start || statements.length) { + var errors = checkNode(statement); + if (errors) { + return { errors: errors }; + } + statements.push(statement); + } + if (statement === end) { + break; + } + } + return { targetRange: { range: statements, facts: rangeFacts, declarations: declarations } }; } else { - deletes.push(function () { return changeTracker.deleteNode(sourceFile, node); }); - } - } - function createClassElementsFromSymbol(symbol) { - var memberElements = []; - // all instance members are stored in the "member" array of symbol - if (symbol.members) { - symbol.members.forEach(function (member) { - var memberElement = createClassElement(member, /*modifiers*/ undefined); - if (memberElement) { - memberElements.push(memberElement); - } - }); - } - // all static members are stored in the "exports" array of symbol - if (symbol.exports) { - symbol.exports.forEach(function (member) { - var memberElement = createClassElement(member, [ts.createToken(115 /* StaticKeyword */)]); - if (memberElement) { - memberElements.push(memberElement); - } - }); - } - return memberElements; - function shouldConvertDeclaration(_target, source) { - // Right now the only thing we can convert are function expressions - other values shouldn't get - // transformed. We can update this once ES public class properties are available. - return ts.isFunctionLike(source); - } - function createClassElement(symbol, modifiers) { - // both properties and methods are bound as property symbols - if (!(symbol.flags & 4 /* Property */)) { - return; + // We have a single node (start) + var errors = checkRootNode(start) || checkNode(start); + if (errors) { + return { errors: errors }; } - var memberDeclaration = symbol.valueDeclaration; - var assignmentBinaryExpression = memberDeclaration.parent; - if (!shouldConvertDeclaration(memberDeclaration, assignmentBinaryExpression.right)) { - return; + // If our selection is the expression in an ExpressionStatement, expand + // the selection to include the enclosing Statement (this stops us + // from trying to care about the return value of the extracted function + // and eliminates double semicolon insertion in certain scenarios) + var range = ts.isStatement(start) + ? [start] + : start.parent && start.parent.kind === 210 /* ExpressionStatement */ + ? [start.parent] + : start; + return { targetRange: { range: range, facts: rangeFacts, declarations: declarations } }; + } + function createErrorResult(sourceFile, start, length, message) { + return { errors: [ts.createFileDiagnostic(sourceFile, start, length, message)] }; + } + function checkRootNode(node) { + if (ts.isIdentifier(node)) { + return [ts.createDiagnosticForNode(node, Messages.InsufficientSelection)]; } - // delete the entire statement if this expression is the sole expression to take care of the semicolon at the end - var nodeToDelete = assignmentBinaryExpression.parent && assignmentBinaryExpression.parent.kind === 210 /* ExpressionStatement */ - ? assignmentBinaryExpression.parent : assignmentBinaryExpression; - deleteNode(nodeToDelete); - if (!assignmentBinaryExpression.right) { - return ts.createProperty([], modifiers, symbol.name, /*questionToken*/ undefined, - /*type*/ undefined, /*initializer*/ undefined); + return undefined; + } + function checkForStaticContext(nodeToCheck, containingClass) { + var current = nodeToCheck; + while (current !== containingClass) { + if (current.kind === 149 /* PropertyDeclaration */) { + if (ts.hasModifier(current, 32 /* Static */)) { + rangeFacts |= RangeFacts.InStaticRegion; + } + break; + } + else if (current.kind === 146 /* Parameter */) { + var ctorOrMethod = ts.getContainingFunction(current); + if (ctorOrMethod.kind === 152 /* Constructor */) { + rangeFacts |= RangeFacts.InStaticRegion; + } + break; + } + else if (current.kind === 151 /* MethodDeclaration */) { + if (ts.hasModifier(current, 32 /* Static */)) { + rangeFacts |= RangeFacts.InStaticRegion; + } + } + current = current.parent; } - switch (assignmentBinaryExpression.right.kind) { - case 186 /* FunctionExpression */: { - var functionExpression = assignmentBinaryExpression.right; - var method = ts.createMethod(/*decorators*/ undefined, modifiers, /*asteriskToken*/ undefined, memberDeclaration.name, /*questionToken*/ undefined, - /*typeParameters*/ undefined, functionExpression.parameters, /*type*/ undefined, functionExpression.body); - copyComments(assignmentBinaryExpression, method); - return method; + } + // Verifies whether we can actually extract this node or not. + function checkNode(nodeToCheck) { + var PermittedJumps; + (function (PermittedJumps) { + PermittedJumps[PermittedJumps["None"] = 0] = "None"; + PermittedJumps[PermittedJumps["Break"] = 1] = "Break"; + PermittedJumps[PermittedJumps["Continue"] = 2] = "Continue"; + PermittedJumps[PermittedJumps["Return"] = 4] = "Return"; + })(PermittedJumps || (PermittedJumps = {})); + if (!ts.isStatement(nodeToCheck) && !(ts.isExpression(nodeToCheck) && isExtractableExpression(nodeToCheck))) { + return [ts.createDiagnosticForNode(nodeToCheck, Messages.StatementOrExpressionExpected)]; + } + if (ts.isInAmbientContext(nodeToCheck)) { + return [ts.createDiagnosticForNode(nodeToCheck, Messages.CannotExtractAmbientBlock)]; + } + // If we're in a class, see whether we're in a static region (static property initializer, static method, class constructor parameter default) + var containingClass = ts.getContainingClass(nodeToCheck); + if (containingClass) { + checkForStaticContext(nodeToCheck, containingClass); + } + var errors; + var permittedJumps = 4 /* Return */; + var seenLabels; + visit(nodeToCheck); + return errors; + function visit(node) { + if (errors) { + // already found an error - can stop now + return true; } - case 187 /* ArrowFunction */: { - var arrowFunction = assignmentBinaryExpression.right; - var arrowFunctionBody = arrowFunction.body; - var bodyBlock = void 0; - // case 1: () => { return [1,2,3] } - if (arrowFunctionBody.kind === 207 /* Block */) { - bodyBlock = arrowFunctionBody; + if (ts.isDeclaration(node)) { + var declaringNode = (node.kind === 226 /* VariableDeclaration */) ? node.parent.parent : node; + if (ts.hasModifier(declaringNode, 1 /* Export */)) { + (errors || (errors = [])).push(ts.createDiagnosticForNode(node, Messages.CannotExtractExportedEntity)); + return true; } - else { - var expression = arrowFunctionBody; - bodyBlock = ts.createBlock([ts.createReturn(expression)]); - } - var method = ts.createMethod(/*decorators*/ undefined, modifiers, /*asteriskToken*/ undefined, memberDeclaration.name, /*questionToken*/ undefined, - /*typeParameters*/ undefined, arrowFunction.parameters, /*type*/ undefined, bodyBlock); - copyComments(assignmentBinaryExpression, method); - return method; + declarations.push(node.symbol); } - default: { - // Don't try to declare members in JavaScript files - if (ts.isSourceFileJavaScript(sourceFile)) { - return; - } - var prop = ts.createProperty(/*decorators*/ undefined, modifiers, memberDeclaration.name, /*questionToken*/ undefined, - /*type*/ undefined, assignmentBinaryExpression.right); - copyComments(assignmentBinaryExpression.parent, prop); - return prop; + // Some things can't be extracted in certain situations + switch (node.kind) { + case 238 /* ImportDeclaration */: + (errors || (errors = [])).push(ts.createDiagnosticForNode(node, Messages.CannotExtractFunction)); + return true; + case 97 /* SuperKeyword */: + // For a super *constructor call*, we have to be extracting the entire class, + // but a super *method call* simply implies a 'this' reference + if (node.parent.kind === 181 /* CallExpression */) { + // Super constructor call + var containingClass_1 = ts.getContainingClass(node); + if (containingClass_1.pos < span.start || containingClass_1.end >= (span.start + span.length)) { + (errors || (errors = [])).push(ts.createDiagnosticForNode(node, Messages.CannotExtractFunction)); + return true; + } + } + else { + rangeFacts |= RangeFacts.UsesThis; + } + break; } + if (!node || ts.isFunctionLike(node) || ts.isClassLike(node)) { + switch (node.kind) { + case 228 /* FunctionDeclaration */: + case 229 /* ClassDeclaration */: + if (node.parent.kind === 265 /* SourceFile */ && node.parent.externalModuleIndicator === undefined) { + // You cannot extract global declarations + (errors || (errors = [])).push(ts.createDiagnosticForNode(node, Messages.FunctionWillNotBeVisibleInTheNewScope)); + } + break; + } + // do not dive into functions or classes + return false; + } + var savedPermittedJumps = permittedJumps; + if (node.parent) { + switch (node.parent.kind) { + case 211 /* IfStatement */: + if (node.parent.thenStatement === node || node.parent.elseStatement === node) { + // forbid all jumps inside thenStatement or elseStatement + permittedJumps = 0 /* None */; + } + break; + case 224 /* TryStatement */: + if (node.parent.tryBlock === node) { + // forbid all jumps inside try blocks + permittedJumps = 0 /* None */; + } + else if (node.parent.finallyBlock === node) { + // allow unconditional returns from finally blocks + permittedJumps = 4 /* Return */; + } + break; + case 260 /* CatchClause */: + if (node.parent.block === node) { + // forbid all jumps inside the block of catch clause + permittedJumps = 0 /* None */; + } + break; + case 257 /* CaseClause */: + if (node.expression !== node) { + // allow unlabeled break inside case clauses + permittedJumps |= 1 /* Break */; + } + break; + default: + if (ts.isIterationStatement(node.parent, /*lookInLabeledStatements*/ false)) { + if (node.parent.statement === node) { + // allow unlabeled break/continue inside loops + permittedJumps |= 1 /* Break */ | 2 /* Continue */; + } + } + break; + } + } + switch (node.kind) { + case 169 /* ThisType */: + case 99 /* ThisKeyword */: + rangeFacts |= RangeFacts.UsesThis; + break; + case 222 /* LabeledStatement */: + { + var label = node.label; + (seenLabels || (seenLabels = [])).push(label.escapedText); + ts.forEachChild(node, visit); + seenLabels.pop(); + break; + } + case 218 /* BreakStatement */: + case 217 /* ContinueStatement */: + { + var label = node.label; + if (label) { + if (!ts.contains(seenLabels, label.escapedText)) { + // attempts to jump to label that is not in range to be extracted + (errors || (errors = [])).push(ts.createDiagnosticForNode(node, Messages.CannotExtractRangeContainingLabeledBreakOrContinueStatementWithTargetOutsideOfTheRange)); + } + } + else { + if (!(permittedJumps & (218 /* BreakStatement */ ? 1 /* Break */ : 2 /* Continue */))) { + // attempt to break or continue in a forbidden context + (errors || (errors = [])).push(ts.createDiagnosticForNode(node, Messages.CannotExtractRangeContainingConditionalBreakOrContinueStatements)); + } + } + break; + } + case 191 /* AwaitExpression */: + rangeFacts |= RangeFacts.IsAsyncFunction; + break; + case 197 /* YieldExpression */: + rangeFacts |= RangeFacts.IsGenerator; + break; + case 219 /* ReturnStatement */: + if (permittedJumps & 4 /* Return */) { + rangeFacts |= RangeFacts.HasReturn; + } + else { + (errors || (errors = [])).push(ts.createDiagnosticForNode(node, Messages.CannotExtractRangeContainingConditionalReturnStatement)); + } + break; + default: + ts.forEachChild(node, visit); + break; + } + permittedJumps = savedPermittedJumps; } } } - function copyComments(sourceNode, targetNode) { - ts.forEachLeadingCommentRange(sourceFile.text, sourceNode.pos, function (pos, end, kind, htnl) { - if (kind === 3 /* MultiLineCommentTrivia */) { - // Remove leading /* - pos += 2; - // Remove trailing */ - end -= 2; + extractMethod_1.getRangeToExtract = getRangeToExtract; + function isValidExtractionTarget(node) { + // Note that we don't use isFunctionLike because we don't want to put the extracted closure *inside* a method + return (node.kind === 228 /* FunctionDeclaration */) || ts.isSourceFile(node) || ts.isModuleBlock(node) || ts.isClassLike(node); + } + /** + * Computes possible places we could extract the function into. For example, + * you may be able to extract into a class method *or* local closure *or* namespace function, + * depending on what's in the extracted body. + */ + function collectEnclosingScopes(range) { + var current = isReadonlyArray(range.range) ? ts.firstOrUndefined(range.range) : range.range; + if (range.facts & RangeFacts.UsesThis) { + // if range uses this as keyword or as type inside the class then it can only be extracted to a method of the containing class + var containingClass = ts.getContainingClass(current); + if (containingClass) { + return [containingClass]; + } + } + var start = current; + var scopes = undefined; + while (current) { + // We want to find the nearest parent where we can place an "equivalent" sibling to the node we're extracting out of. + // Walk up to the closest parent of a place where we can logically put a sibling: + // * Function declaration + // * Class declaration or expression + // * Module/namespace or source file + if (current !== start && isValidExtractionTarget(current)) { + (scopes = scopes || []).push(current); + } + // A function parameter's initializer is actually in the outer scope, not the function declaration + if (current && current.parent && current.parent.kind === 146 /* Parameter */) { + // Skip all the way to the outer scope of the function that declared this parameter + current = ts.findAncestor(current, function (parent) { return ts.isFunctionLike(parent); }).parent; } else { - // Remove leading // - pos += 2; + current = current.parent; } - ts.addSyntheticLeadingComment(targetNode, kind, sourceFile.text.slice(pos, end), htnl); + } + return scopes; + } + extractMethod_1.collectEnclosingScopes = collectEnclosingScopes; + /** + * Given a piece of text to extract ('targetRange'), computes a list of possible extractions. + * Each returned ExtractResultForScope corresponds to a possible target scope and is either a set of changes + * or an error explaining why we can't extract into that scope. + */ + function getPossibleExtractions(targetRange, context, requestedChangesIndex) { + if (requestedChangesIndex === void 0) { requestedChangesIndex = undefined; } + var sourceFile = context.file; + if (targetRange === undefined) { + return undefined; + } + var scopes = collectEnclosingScopes(targetRange); + if (scopes === undefined) { + return undefined; + } + var enclosingTextRange = getEnclosingTextRange(targetRange, sourceFile); + var _a = collectReadsAndWrites(targetRange, scopes, enclosingTextRange, sourceFile, context.program.getTypeChecker()), target = _a.target, usagesPerScope = _a.usagesPerScope, errorsPerScope = _a.errorsPerScope; + context.cancellationToken.throwIfCancellationRequested(); + if (requestedChangesIndex !== undefined) { + if (errorsPerScope[requestedChangesIndex].length) { + return undefined; + } + return [extractFunctionInScope(target, scopes[requestedChangesIndex], usagesPerScope[requestedChangesIndex], targetRange, context)]; + } + else { + return scopes.map(function (scope, i) { + var errors = errorsPerScope[i]; + if (errors.length) { + return { + scope: scope, + scopeDescription: getDescriptionForScope(scope), + errors: errors + }; + } + return { scope: scope, scopeDescription: getDescriptionForScope(scope) }; + }); + } + } + extractMethod_1.getPossibleExtractions = getPossibleExtractions; + function getDescriptionForScope(scope) { + if (ts.isFunctionLike(scope)) { + switch (scope.kind) { + case 152 /* Constructor */: + return "constructor"; + case 186 /* FunctionExpression */: + return scope.name + ? "function expression " + scope.name.getText() + : "anonymous function expression"; + case 228 /* FunctionDeclaration */: + return "function " + scope.name.getText(); + case 187 /* ArrowFunction */: + return "arrow function"; + case 151 /* MethodDeclaration */: + return "method " + scope.name.getText(); + case 153 /* GetAccessor */: + return "get " + scope.name.getText(); + case 154 /* SetAccessor */: + return "set " + scope.name.getText(); + } + } + else if (ts.isModuleBlock(scope)) { + return "namespace " + scope.parent.name.getText(); + } + else if (ts.isClassLike(scope)) { + return scope.kind === 229 /* ClassDeclaration */ + ? "class " + scope.name.text + : scope.name.text + ? "class expression " + scope.name.text + : "anonymous class expression"; + } + else if (ts.isSourceFile(scope)) { + return "file '" + scope.fileName + "'"; + } + else { + return "unknown"; + } + } + function getUniqueName(isNameOkay) { + var functionNameText = "newFunction"; + if (isNameOkay(functionNameText)) { + return functionNameText; + } + var i = 1; + while (!isNameOkay(functionNameText = "newFunction_" + i)) { + i++; + } + return functionNameText; + } + function extractFunctionInScope(node, scope, _a, range, context) { + var usagesInScope = _a.usages, substitutions = _a.substitutions; + var checker = context.program.getTypeChecker(); + // Make a unique name for the extracted function + var file = scope.getSourceFile(); + var functionNameText = getUniqueName(function (n) { return !file.identifiers.has(n); }); + var isJS = ts.isInJavaScriptFile(scope); + var functionName = ts.createIdentifier(functionNameText); + var functionReference = ts.createIdentifier(functionNameText); + var returnType = undefined; + var parameters = []; + var callArguments = []; + var writes; + usagesInScope.forEach(function (usage, name) { + var typeNode = undefined; + if (!isJS) { + var type = checker.getTypeOfSymbolAtLocation(usage.symbol, usage.node); + // Widen the type so we don't emit nonsense annotations like "function fn(x: 3) {" + type = checker.getBaseTypeOfLiteralType(type); + typeNode = checker.typeToTypeNode(type, node, ts.NodeBuilderFlags.NoTruncation); + } + var paramDecl = ts.createParameter( + /*decorators*/ undefined, + /*modifiers*/ undefined, + /*dotDotDotToken*/ undefined, + /*name*/ name, + /*questionToken*/ undefined, typeNode); + parameters.push(paramDecl); + if (usage.usage === 2 /* Write */) { + (writes || (writes = [])).push(usage); + } + callArguments.push(ts.createIdentifier(name)); }); + // Provide explicit return types for contexutally-typed functions + // to avoid problems when there are literal types present + if (ts.isExpression(node) && !isJS) { + var contextualType = checker.getContextualType(node); + returnType = checker.typeToTypeNode(contextualType); + } + var _b = transformFunctionBody(node), body = _b.body, returnValueProperty = _b.returnValueProperty; + var newFunction; + if (ts.isClassLike(scope)) { + // always create private method in TypeScript files + var modifiers = isJS ? [] : [ts.createToken(112 /* PrivateKeyword */)]; + if (range.facts & RangeFacts.InStaticRegion) { + modifiers.push(ts.createToken(115 /* StaticKeyword */)); + } + if (range.facts & RangeFacts.IsAsyncFunction) { + modifiers.push(ts.createToken(120 /* AsyncKeyword */)); + } + newFunction = ts.createMethod( + /*decorators*/ undefined, modifiers, range.facts & RangeFacts.IsGenerator ? ts.createToken(39 /* AsteriskToken */) : undefined, functionName, + /*questionToken*/ undefined, + /*typeParameters*/ [], parameters, returnType, body); + } + else { + newFunction = ts.createFunctionDeclaration( + /*decorators*/ undefined, range.facts & RangeFacts.IsAsyncFunction ? [ts.createToken(120 /* AsyncKeyword */)] : undefined, range.facts & RangeFacts.IsGenerator ? ts.createToken(39 /* AsteriskToken */) : undefined, functionName, + /*typeParameters*/ [], parameters, returnType, body); + } + var changeTracker = ts.textChanges.ChangeTracker.fromCodeFixContext(context); + // insert function at the end of the scope + changeTracker.insertNodeBefore(context.file, scope.getLastToken(), newFunction, { prefix: context.newLineCharacter, suffix: context.newLineCharacter }); + var newNodes = []; + // replace range with function call + var call = ts.createCall(ts.isClassLike(scope) ? ts.createPropertyAccess(range.facts & RangeFacts.InStaticRegion ? ts.createIdentifier(scope.name.getText()) : ts.createThis(), functionReference) : functionReference, + /*typeArguments*/ undefined, callArguments); + if (range.facts & RangeFacts.IsGenerator) { + call = ts.createYield(ts.createToken(39 /* AsteriskToken */), call); + } + if (range.facts & RangeFacts.IsAsyncFunction) { + call = ts.createAwait(call); + } + if (writes) { + if (returnValueProperty) { + // has both writes and return, need to create variable declaration to hold return value; + newNodes.push(ts.createVariableStatement( + /*modifiers*/ undefined, [ts.createVariableDeclaration(returnValueProperty, ts.createKeywordTypeNode(119 /* AnyKeyword */))])); + } + var assignments = getPropertyAssignmentsForWrites(writes); + if (returnValueProperty) { + assignments.unshift(ts.createShorthandPropertyAssignment(returnValueProperty)); + } + // propagate writes back + if (assignments.length === 1) { + if (returnValueProperty) { + newNodes.push(ts.createReturn(ts.createIdentifier(returnValueProperty))); + } + else { + newNodes.push(ts.createStatement(ts.createBinary(assignments[0].name, 58 /* EqualsToken */, call))); + } + } + else { + // emit e.g. + // { a, b, __return } = newFunction(a, b); + // return __return; + newNodes.push(ts.createStatement(ts.createBinary(ts.createObjectLiteral(assignments), 58 /* EqualsToken */, call))); + if (returnValueProperty) { + newNodes.push(ts.createReturn(ts.createIdentifier(returnValueProperty))); + } + } + } + else { + if (range.facts & RangeFacts.HasReturn) { + newNodes.push(ts.createReturn(call)); + } + else if (isReadonlyArray(range.range)) { + newNodes.push(ts.createStatement(call)); + } + else { + newNodes.push(call); + } + } + if (isReadonlyArray(range.range)) { + changeTracker.replaceNodesWithNodes(context.file, range.range, newNodes, { + nodeSeparator: context.newLineCharacter, + suffix: context.newLineCharacter // insert newline only when replacing statements + }); + } + else { + changeTracker.replaceNodeWithNodes(context.file, range.range, newNodes, { nodeSeparator: context.newLineCharacter }); + } + return { + scope: scope, + scopeDescription: getDescriptionForScope(scope), + changes: changeTracker.getChanges() + }; + function getPropertyAssignmentsForWrites(writes) { + return writes.map(function (w) { return ts.createShorthandPropertyAssignment(w.symbol.name); }); + } + function generateReturnValueProperty() { + return "__return"; + } + function transformFunctionBody(body) { + if (ts.isBlock(body) && !writes && substitutions.size === 0) { + // already block, no writes to propagate back, no substitutions - can use node as is + return { body: ts.createBlock(body.statements, /*multLine*/ true), returnValueProperty: undefined }; + } + var returnValueProperty; + var statements = ts.createNodeArray(ts.isBlock(body) ? body.statements.slice(0) : [ts.isStatement(body) ? body : ts.createReturn(body)]); + // rewrite body if either there are writes that should be propagated back via return statements or there are substitutions + if (writes || substitutions.size) { + var rewrittenStatements = ts.visitNodes(statements, visitor).slice(); + if (writes && !(range.facts & RangeFacts.HasReturn) && ts.isStatement(body)) { + // add return at the end to propagate writes back in case if control flow falls out of the function body + // it is ok to know that range has at least one return since it we only allow unconditional returns + var assignments = getPropertyAssignmentsForWrites(writes); + if (assignments.length === 1) { + rewrittenStatements.push(ts.createReturn(assignments[0].name)); + } + else { + rewrittenStatements.push(ts.createReturn(ts.createObjectLiteral(assignments))); + } + } + return { body: ts.createBlock(rewrittenStatements, /*multiLine*/ true), returnValueProperty: returnValueProperty }; + } + else { + return { body: ts.createBlock(statements, /*multiLine*/ true), returnValueProperty: undefined }; + } + function visitor(node) { + if (node.kind === 219 /* ReturnStatement */ && writes) { + var assignments = getPropertyAssignmentsForWrites(writes); + if (node.expression) { + if (!returnValueProperty) { + returnValueProperty = generateReturnValueProperty(); + } + assignments.unshift(ts.createPropertyAssignment(returnValueProperty, ts.visitNode(node.expression, visitor))); + } + if (assignments.length === 1) { + return ts.createReturn(assignments[0].name); + } + else { + return ts.createReturn(ts.createObjectLiteral(assignments)); + } + } + else { + var substitution = substitutions.get(ts.getNodeId(node).toString()); + return substitution || ts.visitEachChild(node, visitor, ts.nullTransformationContext); + } + } + } } - function createClassFromVariableDeclaration(node) { - var initializer = node.initializer; - if (!initializer || initializer.kind !== 186 /* FunctionExpression */) { + extractMethod_1.extractFunctionInScope = extractFunctionInScope; + function isReadonlyArray(v) { + return ts.isArray(v); + } + /** + * Produces a range that spans the entirety of nodes, given a selection + * that might start/end in the middle of nodes. + * + * For example, when the user makes a selection like this + * v---v + * var someThing = foo + bar; + * this returns ^-------^ + */ + function getEnclosingTextRange(targetRange, sourceFile) { + return isReadonlyArray(targetRange.range) + ? { pos: targetRange.range[0].getStart(sourceFile), end: targetRange.range[targetRange.range.length - 1].getEnd() } + : targetRange.range; + } + var Usage; + (function (Usage) { + // value should be passed to extracted method + Usage[Usage["Read"] = 1] = "Read"; + // value should be passed to extracted method and propagated back + Usage[Usage["Write"] = 2] = "Write"; + })(Usage || (Usage = {})); + function collectReadsAndWrites(targetRange, scopes, enclosingTextRange, sourceFile, checker) { + var usagesPerScope = []; + var substitutionsPerScope = []; + var errorsPerScope = []; + var visibleDeclarationsInExtractedRange = []; + // initialize results + for (var _i = 0, scopes_1 = scopes; _i < scopes_1.length; _i++) { + var _ = scopes_1[_i]; + usagesPerScope.push({ usages: ts.createMap(), substitutions: ts.createMap() }); + substitutionsPerScope.push(ts.createMap()); + errorsPerScope.push([]); + } + var seenUsages = ts.createMap(); + var target = isReadonlyArray(targetRange.range) ? ts.createBlock(targetRange.range) : targetRange.range; + var containingLexicalScopeOfExtraction = ts.isBlockScope(scopes[0], scopes[0].parent) ? scopes[0] : ts.getEnclosingBlockScopeContainer(scopes[0]); + collectUsages(target); + var _loop_8 = function (i) { + var hasWrite = false; + var readonlyClassPropertyWrite = undefined; + usagesPerScope[i].usages.forEach(function (value) { + if (value.usage === 2 /* Write */) { + hasWrite = true; + if (value.symbol.flags & 106500 /* ClassMember */ && + value.symbol.valueDeclaration && + ts.hasModifier(value.symbol.valueDeclaration, 64 /* Readonly */)) { + readonlyClassPropertyWrite = value.symbol.valueDeclaration; + } + } + }); + if (hasWrite && !isReadonlyArray(targetRange.range) && ts.isExpression(targetRange.range)) { + errorsPerScope[i].push(ts.createDiagnosticForNode(targetRange.range, Messages.CannotCombineWritesAndReturns)); + } + else if (readonlyClassPropertyWrite && i > 0) { + errorsPerScope[i].push(ts.createDiagnosticForNode(readonlyClassPropertyWrite, Messages.CannotCombineWritesAndReturns)); + } + }; + for (var i = 0; i < scopes.length; i++) { + _loop_8(i); + } + // If there are any declarations in the extracted block that are used in the same enclosing + // lexical scope, we can't move the extraction "up" as those declarations will become unreachable + if (visibleDeclarationsInExtractedRange.length) { + ts.forEachChild(containingLexicalScopeOfExtraction, checkForUsedDeclarations); + } + return { target: target, usagesPerScope: usagesPerScope, errorsPerScope: errorsPerScope }; + function collectUsages(node, valueUsage) { + if (valueUsage === void 0) { valueUsage = 1 /* Read */; } + if (ts.isDeclaration(node) && node.symbol) { + visibleDeclarationsInExtractedRange.push(node.symbol); + } + if (ts.isAssignmentExpression(node)) { + // use 'write' as default usage for values + collectUsages(node.left, 2 /* Write */); + collectUsages(node.right); + } + else if (ts.isUnaryExpressionWithWrite(node)) { + collectUsages(node.operand, 2 /* Write */); + } + else if (ts.isPropertyAccessExpression(node) || ts.isElementAccessExpression(node)) { + // use 'write' as default usage for values + ts.forEachChild(node, collectUsages); + } + else if (ts.isIdentifier(node)) { + if (!node.parent) { + return; + } + if (ts.isQualifiedName(node.parent) && node !== node.parent.left) { + return; + } + if (ts.isPropertyAccessExpression(node.parent) && node !== node.parent.expression) { + return; + } + recordUsage(node, valueUsage, /*isTypeNode*/ ts.isPartOfTypeNode(node)); + } + else { + ts.forEachChild(node, collectUsages); + } + } + function recordUsage(n, usage, isTypeNode) { + var symbolId = recordUsagebySymbol(n, usage, isTypeNode); + if (symbolId) { + for (var i = 0; i < scopes.length; i++) { + // push substitution from map to map to simplify rewriting + var substitition = substitutionsPerScope[i].get(symbolId); + if (substitition) { + usagesPerScope[i].substitutions.set(ts.getNodeId(n).toString(), substitition); + } + } + } + } + function recordUsagebySymbol(identifier, usage, isTypeName) { + var symbol = checker.getSymbolAtLocation(identifier); + if (!symbol) { + // cannot find symbol - do nothing + return undefined; + } + var symbolId = ts.getSymbolId(symbol).toString(); + var lastUsage = seenUsages.get(symbolId); + // there are two kinds of value usages + // - reads - if range contains a read from the value located outside of the range then value should be passed as a parameter + // - writes - if range contains a write to a value located outside the range the value should be passed as a parameter and + // returned as a return value + // 'write' case is a superset of 'read' so if we already have processed 'write' of some symbol there is not need to handle 'read' + // since all information is already recorded + if (lastUsage && lastUsage >= usage) { + return symbolId; + } + seenUsages.set(symbolId, usage); + if (lastUsage) { + // if we get here this means that we are trying to handle 'write' and 'read' was already processed + // walk scopes and update existing records. + for (var _i = 0, usagesPerScope_1 = usagesPerScope; _i < usagesPerScope_1.length; _i++) { + var perScope = usagesPerScope_1[_i]; + var prevEntry = perScope.usages.get(identifier.text); + if (prevEntry) { + perScope.usages.set(identifier.text, { usage: usage, symbol: symbol, node: identifier }); + } + } + return symbolId; + } + // find first declaration in this file + var declInFile = ts.find(symbol.getDeclarations(), function (d) { return d.getSourceFile() === sourceFile; }); + if (!declInFile) { + return undefined; + } + if (ts.rangeContainsRange(enclosingTextRange, declInFile)) { + // declaration is located in range to be extracted - do nothing + return undefined; + } + if (targetRange.facts & RangeFacts.IsGenerator && usage === 2 /* Write */) { + // this is write to a reference located outside of the target scope and range is extracted into generator + // currently this is unsupported scenario + for (var _a = 0, errorsPerScope_1 = errorsPerScope; _a < errorsPerScope_1.length; _a++) { + var errors = errorsPerScope_1[_a]; + errors.push(ts.createDiagnosticForNode(identifier, Messages.CannotExtractRangeThatContainsWritesToReferencesLocatedOutsideOfTheTargetRangeInGenerators)); + } + } + for (var i = 0; i < scopes.length; i++) { + var scope = scopes[i]; + var resolvedSymbol = checker.resolveName(symbol.name, scope, symbol.flags); + if (resolvedSymbol === symbol) { + continue; + } + if (!substitutionsPerScope[i].has(symbolId)) { + var substitution = tryReplaceWithQualifiedNameOrPropertyAccess(symbol.exportSymbol || symbol, scope, isTypeName); + if (substitution) { + substitutionsPerScope[i].set(symbolId, substitution); + } + else if (isTypeName) { + errorsPerScope[i].push(ts.createDiagnosticForNode(identifier, Messages.TypeWillNotBeVisibleInTheNewScope)); + } + else { + usagesPerScope[i].usages.set(identifier.text, { usage: usage, symbol: symbol, node: identifier }); + } + } + } + return symbolId; + } + function checkForUsedDeclarations(node) { + // If this node is entirely within the original extraction range, we don't need to do anything. + if (node === targetRange.range || (isReadonlyArray(targetRange.range) && targetRange.range.indexOf(node) >= 0)) { + return; + } + // Otherwise check and recurse. + var sym = checker.getSymbolAtLocation(node); + if (sym && visibleDeclarationsInExtractedRange.some(function (d) { return d === sym; })) { + for (var _i = 0, errorsPerScope_2 = errorsPerScope; _i < errorsPerScope_2.length; _i++) { + var scope = errorsPerScope_2[_i]; + scope.push(ts.createDiagnosticForNode(node, Messages.CannotExtractExportedEntity)); + } + return true; + } + else { + ts.forEachChild(node, checkForUsedDeclarations); + } + } + function tryReplaceWithQualifiedNameOrPropertyAccess(symbol, scopeDecl, isTypeNode) { + if (!symbol) { + return undefined; + } + if (symbol.getDeclarations().some(function (d) { return d.parent === scopeDecl; })) { + return ts.createIdentifier(symbol.name); + } + var prefix = tryReplaceWithQualifiedNameOrPropertyAccess(symbol.parent, scopeDecl, isTypeNode); + if (prefix === undefined) { + return undefined; + } + return isTypeNode ? ts.createQualifiedName(prefix, ts.createIdentifier(symbol.name)) : ts.createPropertyAccess(prefix, symbol.name); + } + } + function getParentNodeInSpan(node, file, span) { + if (!node) return undefined; + while (node.parent) { + if (ts.isSourceFile(node.parent) || !spanContainsNode(span, node.parent, file)) { + return node; + } + node = node.parent; } - if (node.name.kind !== 71 /* Identifier */) { - return undefined; - } - var memberElements = createClassElementsFromSymbol(initializer.symbol); - if (initializer.body) { - memberElements.unshift(ts.createConstructor(/*decorators*/ undefined, /*modifiers*/ undefined, initializer.parameters, initializer.body)); - } - var cls = ts.createClassDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, node.name, - /*typeParameters*/ undefined, /*heritageClauses*/ undefined, memberElements); - // Don't call copyComments here because we'll already leave them in place - return cls; } - function createClassFromFunctionDeclaration(node) { - var memberElements = createClassElementsFromSymbol(ctorSymbol); - if (node.body) { - memberElements.unshift(ts.createConstructor(/*decorators*/ undefined, /*modifiers*/ undefined, node.parameters, node.body)); - } - var cls = ts.createClassDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, node.name, - /*typeParameters*/ undefined, /*heritageClauses*/ undefined, memberElements); - // Don't call copyComments here because we'll already leave them in place - return cls; + function spanContainsNode(span, node, file) { + return ts.textSpanContainsPosition(span, node.getStart(file)) && + node.getEnd() <= ts.textSpanEnd(span); } - } + /** + * Computes whether or not a node represents an expression in a position where it could + * be extracted. + * The isExpression() in utilities.ts returns some false positives we need to handle, + * such as `import x from 'y'` -- the 'y' is a StringLiteral but is *not* an expression + * in the sense of something that you could extract on + */ + function isExtractableExpression(node) { + switch (node.parent.kind) { + case 264 /* EnumMember */: + return false; + } + switch (node.kind) { + case 9 /* StringLiteral */: + return node.parent.kind !== 238 /* ImportDeclaration */ && + node.parent.kind !== 242 /* ImportSpecifier */; + case 198 /* SpreadElement */: + case 174 /* ObjectBindingPattern */: + case 176 /* BindingElement */: + return false; + case 71 /* Identifier */: + return node.parent.kind !== 176 /* BindingElement */ && + node.parent.kind !== 242 /* ImportSpecifier */ && + node.parent.kind !== 246 /* ExportSpecifier */; + } + return true; + } + function isBlockLike(node) { + switch (node.kind) { + case 207 /* Block */: + case 265 /* SourceFile */: + case 234 /* ModuleBlock */: + case 257 /* CaseClause */: + return true; + default: + return false; + } + } + })(extractMethod = refactor.extractMethod || (refactor.extractMethod = {})); })(refactor = ts.refactor || (ts.refactor = {})); })(ts || (ts = {})); /// +/// /// /// /// @@ -89074,7 +90729,7 @@ var ts; node.parent = parent; return node; } - var NodeObject = (function () { + var NodeObject = /** @class */ (function () { function NodeObject(kind, pos, end) { this.pos = pos; this.end = end; @@ -89117,12 +90772,14 @@ var ts; ts.scanner.setTextPos(pos); while (pos < end) { var token = ts.scanner.scan(); - ts.Debug.assert(token !== 1 /* EndOfFileToken */); // Else it would infinitely loop var textPos = ts.scanner.getTextPos(); if (textPos <= end) { nodes.push(createNode(token, pos, textPos, this)); } pos = textPos; + if (token === 1 /* EndOfFileToken */) { + break; + } } return pos; }; @@ -89227,7 +90884,7 @@ var ts; }; return NodeObject; }()); - var TokenOrIdentifierObject = (function () { + var TokenOrIdentifierObject = /** @class */ (function () { function TokenOrIdentifierObject(pos, end) { // Set properties in same order as NodeObject this.pos = pos; @@ -89282,7 +90939,7 @@ var ts; }; return TokenOrIdentifierObject; }()); - var SymbolObject = (function () { + var SymbolObject = /** @class */ (function () { function SymbolObject(flags, name) { this.flags = flags; this.escapedName = name; @@ -89320,7 +90977,7 @@ var ts; }; return SymbolObject; }()); - var TokenObject = (function (_super) { + var TokenObject = /** @class */ (function (_super) { __extends(TokenObject, _super); function TokenObject(kind, pos, end) { var _this = _super.call(this, pos, end) || this; @@ -89329,7 +90986,7 @@ var ts; } return TokenObject; }(TokenOrIdentifierObject)); - var IdentifierObject = (function (_super) { + var IdentifierObject = /** @class */ (function (_super) { __extends(IdentifierObject, _super); function IdentifierObject(_kind, pos, end) { return _super.call(this, pos, end) || this; @@ -89344,7 +91001,7 @@ var ts; return IdentifierObject; }(TokenOrIdentifierObject)); IdentifierObject.prototype.kind = 71 /* Identifier */; - var TypeObject = (function () { + var TypeObject = /** @class */ (function () { function TypeObject(checker, flags) { this.checker = checker; this.flags = flags; @@ -89386,7 +91043,7 @@ var ts; }; return TypeObject; }()); - var SignatureObject = (function () { + var SignatureObject = /** @class */ (function () { function SignatureObject(checker) { this.checker = checker; } @@ -89416,7 +91073,7 @@ var ts; }; return SignatureObject; }()); - var SourceFileObject = (function (_super) { + var SourceFileObject = /** @class */ (function (_super) { __extends(SourceFileObject, _super); function SourceFileObject(kind, pos, end) { return _super.call(this, kind, pos, end) || this; @@ -89587,7 +91244,7 @@ var ts; }; return SourceFileObject; }(NodeObject)); - var SourceMapSourceObject = (function () { + var SourceMapSourceObject = /** @class */ (function () { function SourceMapSourceObject(fileName, text, skipTrivia) { this.fileName = fileName; this.text = text; @@ -89656,7 +91313,7 @@ var ts; // Cache host information about script Should be refreshed // at each language service public entry point, since we don't know when // the set of scripts handled by the host changes. - var HostCache = (function () { + var HostCache = /** @class */ (function () { function HostCache(host, getCanonicalFileName) { this.host = host; // script id => script index @@ -89718,7 +91375,7 @@ var ts; }; return HostCache; }()); - var SyntaxTreeCache = (function () { + var SyntaxTreeCache = /** @class */ (function () { function SyntaxTreeCache(host) { this.host = host; } @@ -89813,7 +91470,7 @@ var ts; return createLanguageServiceSourceFile(sourceFile.fileName, scriptSnapshot, sourceFile.languageVersion, version, /*setNodeParents*/ true, sourceFile.scriptKind); } ts.updateLanguageServiceSourceFile = updateLanguageServiceSourceFile; - var CancellationTokenObject = (function () { + var CancellationTokenObject = /** @class */ (function () { function CancellationTokenObject(cancellationToken) { this.cancellationToken = cancellationToken; } @@ -89829,7 +91486,7 @@ var ts; }()); /* @internal */ /** A cancellation that throttles calls to the host */ - var ThrottledCancellationToken = (function () { + var ThrottledCancellationToken = /** @class */ (function () { function ThrottledCancellationToken(hostCancellationToken, throttleWaitMilliseconds) { if (throttleWaitMilliseconds === void 0) { throttleWaitMilliseconds = 20; } this.hostCancellationToken = hostCancellationToken; @@ -89980,8 +91637,8 @@ var ts; if (program) { var oldSourceFiles = program.getSourceFiles(); var oldSettingsKey = documentRegistry.getKeyForCompilationSettings(oldSettings); - for (var _i = 0, oldSourceFiles_1 = oldSourceFiles; _i < oldSourceFiles_1.length; _i++) { - var oldSourceFile = oldSourceFiles_1[_i]; + for (var _i = 0, oldSourceFiles_2 = oldSourceFiles; _i < oldSourceFiles_2.length; _i++) { + var oldSourceFile = oldSourceFiles_2[_i]; if (!newProgram.getSourceFile(oldSourceFile.fileName) || shouldCreateNewSourceFiles) { documentRegistry.releaseDocumentWithKey(oldSourceFile.path, oldSettingsKey); } @@ -90038,7 +91695,7 @@ var ts; // We do not support the scenario where a host can modify a registered // file's script kind, i.e. in one project some file is treated as ".ts" // and in another as ".js" - ts.Debug.assert(hostFileInformation.scriptKind === oldSourceFile.scriptKind, "Registered script kind (" + oldSourceFile.scriptKind + ") should match new script kind (" + hostFileInformation.scriptKind + ") for file: " + path); + ts.Debug.assertEqual(hostFileInformation.scriptKind, oldSourceFile.scriptKind, "Registered script kind should match new script kind.", path); return documentRegistry.updateDocumentWithKey(fileName, path, newSettings, documentRegistryBucketKey, hostFileInformation.scriptSnapshot, hostFileInformation.version, hostFileInformation.scriptKind); } // We didn't already have the file. Fall through and acquire it from the registry. @@ -90447,17 +92104,19 @@ var ts; function getFormattingEditsAfterKeystroke(fileName, position, key, options) { var sourceFile = syntaxTreeCache.getCurrentSourceFile(fileName); var settings = toEditorSettings(options); - if (key === "{") { - return ts.formatting.formatOnOpeningCurly(position, sourceFile, getRuleProvider(settings), settings); - } - else if (key === "}") { - return ts.formatting.formatOnClosingCurly(position, sourceFile, getRuleProvider(settings), settings); - } - else if (key === ";") { - return ts.formatting.formatOnSemicolon(position, sourceFile, getRuleProvider(settings), settings); - } - else if (key === "\n") { - return ts.formatting.formatOnEnter(position, sourceFile, getRuleProvider(settings), settings); + if (!ts.isInComment(sourceFile, position)) { + if (key === "{") { + return ts.formatting.formatOnOpeningCurly(position, sourceFile, getRuleProvider(settings), settings); + } + else if (key === "}") { + return ts.formatting.formatOnClosingCurly(position, sourceFile, getRuleProvider(settings), settings); + } + else if (key === ";") { + return ts.formatting.formatOnSemicolon(position, sourceFile, getRuleProvider(settings), settings); + } + else if (key === "\n") { + return ts.formatting.formatOnEnter(position, sourceFile, getRuleProvider(settings), settings); + } } return []; } @@ -90504,6 +92163,11 @@ var ts; } return true; } + function getSpanOfEnclosingComment(fileName, position, onlyMultiLine) { + var sourceFile = syntaxTreeCache.getCurrentSourceFile(fileName); + var range = ts.formatting.getRangeOfEnclosingComment(sourceFile, position, onlyMultiLine); + return range && ts.createTextSpanFromRange(range); + } function getTodoComments(fileName, descriptors) { // Note: while getting todo comments seems like a syntactic operation, we actually // treat it as a semantic operation here. This is because we expect our host to call @@ -90693,6 +92357,7 @@ var ts; getFormattingEditsAfterKeystroke: getFormattingEditsAfterKeystroke, getDocCommentTemplateAtPosition: getDocCommentTemplateAtPosition, isValidBraceCompletionAtPosition: isValidBraceCompletionAtPosition, + getSpanOfEnclosingComment: getSpanOfEnclosingComment, getCodeFixesAtPosition: getCodeFixesAtPosition, getEmitOutput: getEmitOutput, getNonBoundSourceFile: getNonBoundSourceFile, @@ -90777,12 +92442,17 @@ var ts; function getPropertySymbolsFromContextualType(typeChecker, node) { var objectLiteral = node.parent; var contextualType = typeChecker.getContextualType(objectLiteral); - var name = ts.unescapeLeadingUnderscores(ts.getTextOfPropertyName(node.name)); - if (name && contextualType) { + return getPropertySymbolsFromType(contextualType, node.name); + } + ts.getPropertySymbolsFromContextualType = getPropertySymbolsFromContextualType; + /* @internal */ + function getPropertySymbolsFromType(type, propName) { + var name = ts.unescapeLeadingUnderscores(ts.getTextOfPropertyName(propName)); + if (name && type) { var result_10 = []; - var symbol = contextualType.getProperty(name); - if (contextualType.flags & 65536 /* Union */) { - ts.forEach(contextualType.types, function (t) { + var symbol = type.getProperty(name); + if (type.flags & 65536 /* Union */) { + ts.forEach(type.types, function (t) { var symbol = t.getProperty(name); if (symbol) { result_10.push(symbol); @@ -90797,7 +92467,7 @@ var ts; } return undefined; } - ts.getPropertySymbolsFromContextualType = getPropertySymbolsFromContextualType; + ts.getPropertySymbolsFromType = getPropertySymbolsFromType; function isArgumentOfElementAccessExpression(node) { return node && node.parent && @@ -91352,7 +93022,7 @@ var ts; } } function spanInOpenParenToken(node) { - if (node.parent.kind === 212 /* DoStatement */ || + if (node.parent.kind === 212 /* DoStatement */ || // Go to while keyword and do action instead node.parent.kind === 181 /* CallExpression */ || node.parent.kind === 182 /* NewExpression */) { return spanInPreviousNode(node); @@ -91471,7 +93141,7 @@ var ts; logger.log("*INTERNAL ERROR* - Exception in typescript services: " + err.message); } } - var ScriptSnapshotShimAdapter = (function () { + var ScriptSnapshotShimAdapter = /** @class */ (function () { function ScriptSnapshotShimAdapter(scriptSnapshotShim) { this.scriptSnapshotShim = scriptSnapshotShim; } @@ -91499,7 +93169,7 @@ var ts; }; return ScriptSnapshotShimAdapter; }()); - var LanguageServiceShimHostAdapter = (function () { + var LanguageServiceShimHostAdapter = /** @class */ (function () { function LanguageServiceShimHostAdapter(shimHost) { var _this = this; this.shimHost = shimHost; @@ -91623,7 +93293,7 @@ var ts; return LanguageServiceShimHostAdapter; }()); ts.LanguageServiceShimHostAdapter = LanguageServiceShimHostAdapter; - var CoreServicesShimHostAdapter = (function () { + var CoreServicesShimHostAdapter = /** @class */ (function () { function CoreServicesShimHostAdapter(shimHost) { var _this = this; this.shimHost = shimHost; @@ -91688,7 +93358,7 @@ var ts; return JSON.stringify({ error: err }); } } - var ShimBase = (function () { + var ShimBase = /** @class */ (function () { function ShimBase(factory) { this.factory = factory; factory.registerShim(this); @@ -91712,7 +93382,7 @@ var ts; code: diagnostic.code }; } - var LanguageServiceShimObject = (function (_super) { + var LanguageServiceShimObject = /** @class */ (function (_super) { __extends(LanguageServiceShimObject, _super); function LanguageServiceShimObject(factory, host, languageService) { var _this = _super.call(this, factory) || this; @@ -91878,6 +93548,10 @@ var ts; var _this = this; return this.forwardJSONCall("isValidBraceCompletionAtPosition('" + fileName + "', " + position + ", " + openingBrace + ")", function () { return _this.languageService.isValidBraceCompletionAtPosition(fileName, position, openingBrace); }); }; + LanguageServiceShimObject.prototype.getSpanOfEnclosingComment = function (fileName, position, onlyMultiLine) { + var _this = this; + return this.forwardJSONCall("getSpanOfEnclosingComment('" + fileName + "', " + position + ")", function () { return _this.languageService.getSpanOfEnclosingComment(fileName, position, onlyMultiLine); }); + }; /// GET SMART INDENT LanguageServiceShimObject.prototype.getIndentationAtPosition = function (fileName, position, options /*Services.EditorOptions*/) { var _this = this; @@ -91985,7 +93659,7 @@ var ts; function convertClassifications(classifications) { return { spans: classifications.spans.join(","), endOfLineState: classifications.endOfLineState }; } - var ClassifierShimObject = (function (_super) { + var ClassifierShimObject = /** @class */ (function (_super) { __extends(ClassifierShimObject, _super); function ClassifierShimObject(factory, logger) { var _this = _super.call(this, factory) || this; @@ -92012,7 +93686,7 @@ var ts; }; return ClassifierShimObject; }(ShimBase)); - var CoreServicesShimObject = (function (_super) { + var CoreServicesShimObject = /** @class */ (function (_super) { __extends(CoreServicesShimObject, _super); function CoreServicesShimObject(factory, logger, host) { var _this = _super.call(this, factory) || this; @@ -92119,7 +93793,7 @@ var ts; }; return CoreServicesShimObject; }(ShimBase)); - var TypeScriptServicesFactory = (function () { + var TypeScriptServicesFactory = /** @class */ (function () { function TypeScriptServicesFactory() { this._shims = []; } @@ -92200,4 +93874,6 @@ var TypeScript; // 'toolsVersion' gets consumed by the managed side, so it's not unused. // TODO: it should be moved into a namespace though. /* @internal */ -var toolsVersion = "2.5"; +var toolsVersion = "2.6"; + +//# sourceMappingURL=typescriptServices.js.map diff --git a/lib/typescriptServices.d.ts b/lib/typescriptServices.d.ts index 392b7e36a07..0b54986035c 100644 --- a/lib/typescriptServices.d.ts +++ b/lib/typescriptServices.d.ts @@ -1210,7 +1210,7 @@ declare namespace ts { interface CatchClause extends Node { kind: SyntaxKind.CatchClause; parent?: TryStatement; - variableDeclaration: VariableDeclaration; + variableDeclaration?: VariableDeclaration; block: Block; } type DeclarationWithTypeParameters = SignatureDeclaration | ClassLikeDeclaration | InterfaceDeclaration | TypeAliasDeclaration | JSDocTemplateTag; @@ -1496,38 +1496,39 @@ declare namespace ts { interface FlowLock { locked?: boolean; } - interface AfterFinallyFlow extends FlowNode, FlowLock { + interface AfterFinallyFlow extends FlowNodeBase, FlowLock { antecedent: FlowNode; } - interface PreFinallyFlow extends FlowNode { + interface PreFinallyFlow extends FlowNodeBase { antecedent: FlowNode; lock: FlowLock; } - interface FlowNode { + type FlowNode = AfterFinallyFlow | PreFinallyFlow | FlowStart | FlowLabel | FlowAssignment | FlowCondition | FlowSwitchClause | FlowArrayMutation; + interface FlowNodeBase { flags: FlowFlags; id?: number; } - interface FlowStart extends FlowNode { + interface FlowStart extends FlowNodeBase { container?: FunctionExpression | ArrowFunction | MethodDeclaration; } - interface FlowLabel extends FlowNode { + interface FlowLabel extends FlowNodeBase { antecedents: FlowNode[]; } - interface FlowAssignment extends FlowNode { + interface FlowAssignment extends FlowNodeBase { node: Expression | VariableDeclaration | BindingElement; antecedent: FlowNode; } - interface FlowCondition extends FlowNode { + interface FlowCondition extends FlowNodeBase { expression: Expression; antecedent: FlowNode; } - interface FlowSwitchClause extends FlowNode { + interface FlowSwitchClause extends FlowNodeBase { switchStatement: SwitchStatement; clauseStart: number; clauseEnd: number; antecedent: FlowNode; } - interface FlowArrayMutation extends FlowNode { + interface FlowArrayMutation extends FlowNodeBase { node: CallExpression | BinaryExpression; antecedent: FlowNode; } @@ -1696,6 +1697,15 @@ declare namespace ts { getSymbolsOfParameterPropertyDeclaration(parameter: ParameterDeclaration, parameterName: string): Symbol[]; getShorthandAssignmentValueSymbol(location: Node): Symbol | undefined; getExportSpecifierLocalTargetSymbol(location: ExportSpecifier): Symbol | undefined; + /** + * If a symbol is a local symbol with an associated exported symbol, returns the exported symbol. + * Otherwise returns its input. + * For example, at `export type T = number;`: + * - `getSymbolAtLocation` at the location `T` will return the exported symbol for `T`. + * - But the result of `getSymbolsInScope` will contain the *local* symbol for `T`, not the exported symbol. + * - Calling `getExportSymbolOfSymbol` on that local symbol will return the exported symbol. + */ + getExportSymbolOfSymbol(symbol: Symbol): Symbol; getPropertySymbolOfDestructuringAssignment(location: Identifier): Symbol | undefined; getTypeAtLocation(node: Node): Type; getTypeFromTypeNode(node: TypeNode): Type; @@ -1790,11 +1800,11 @@ declare namespace ts { UseFullyQualifiedType = 256, InFirstTypeArgument = 512, InTypeAlias = 1024, - UseTypeAliasValue = 2048, SuppressAnyReturnType = 4096, AddUndefined = 8192, WriteClassExpressionAsTypeLiteral = 16384, InArrayType = 32768, + UseAliasDefinedOutsideCurrentScope = 65536, } enum SymbolFormatFlags { None = 0, @@ -2056,6 +2066,7 @@ declare namespace ts { interface TypeVariable extends Type { } interface TypeParameter extends TypeVariable { + /** Retrieve using getConstraintFromTypeParameter */ constraint: Type; default?: Type; } @@ -2103,6 +2114,21 @@ declare namespace ts { NoDefault = 2, AnyDefault = 4, } + /** + * Ternary values are defined such that + * x & y is False if either x or y is False. + * x & y is Maybe if either x or y is Maybe, but neither x or y is False. + * x & y is True if both x and y are True. + * x | y is False if both x and y are False. + * x | y is Maybe if either x or y is Maybe, but neither x or y is True. + * x | y is True if either x or y is True. + */ + enum Ternary { + False = 0, + Maybe = 1, + True = -1, + } + type TypeComparer = (s: Type, t: Type, reportErrors?: boolean) => Ternary; interface JsFileExtensionInfo { extension: string; isMixedContent: boolean; @@ -2195,6 +2221,7 @@ declare namespace ts { outFile?: string; paths?: MapLike; preserveConstEnums?: boolean; + preserveSymlinks?: boolean; project?: string; reactNamespace?: string; jsxFactory?: string; @@ -2300,6 +2327,10 @@ declare namespace ts { readFile(fileName: string): string | undefined; trace?(s: string): void; directoryExists?(directoryName: string): boolean; + /** + * Resolve a symbolic link. + * @see https://nodejs.org/api/fs.html#fs_fs_realpathsync_path_options + */ realpath?(path: string): string; getCurrentDirectory?(): string; getDirectories?(path: string): string[]; @@ -2314,17 +2345,13 @@ declare namespace ts { interface ResolvedModule { /** Path of the file the module was resolved to. */ resolvedFileName: string; - /** - * Denotes if 'resolvedFileName' is isExternalLibraryImport and thus should be a proper external module: - * - be a .d.ts file - * - use top level imports\exports - * - don't use tripleslash references - */ + /** True if `resolvedFileName` comes from `node_modules`. */ isExternalLibraryImport?: boolean; } /** * ResolvedModule with an explicitly provided `extension` property. * Prefer this over `ResolvedModule`. + * If changing this, remember to change `moduleResolutionIsEqualTo`. */ interface ResolvedModuleFull extends ResolvedModule { /** @@ -2332,6 +2359,21 @@ declare namespace ts { * This is optional for backwards-compatibility, but will be added if not provided. */ extension: Extension; + packageId?: PackageId; + } + /** + * Unique identifier with a package name and version. + * If changing this, remember to change `packageIdIsEqual`. + */ + interface PackageId { + /** + * Name of the package. + * Should not include `@types`. + * If accessing a non-index file, this should include its name e.g. "foo/bar". + */ + name: string; + /** Version of the package, e.g. "1.2.3" */ + version: string; } enum Extension { Ts = ".ts", @@ -2593,7 +2635,7 @@ declare namespace ts { } } declare namespace ts { - const versionMajorMinor = "2.5"; + const versionMajorMinor = "2.6"; /** The version of the TypeScript compiler release */ const version: string; } @@ -2741,6 +2783,8 @@ declare namespace ts { function collapseTextChangeRangesAcrossMultipleVersions(changes: ReadonlyArray): TextChangeRange; function getTypeParameterOwner(d: Declaration): Declaration; function isParameterPropertyDeclaration(node: Node): boolean; + function isEmptyBindingPattern(node: BindingName): node is BindingPattern; + function isEmptyBindingElement(node: BindingElement): boolean; function getCombinedModifierFlags(node: Node): ModifierFlags; function getCombinedNodeFlags(node: Node): NodeFlags; /** @@ -3310,8 +3354,8 @@ declare namespace ts { function updateDefaultClause(node: DefaultClause, statements: ReadonlyArray): DefaultClause; function createHeritageClause(token: HeritageClause["token"], types: ReadonlyArray): HeritageClause; function updateHeritageClause(node: HeritageClause, types: ReadonlyArray): HeritageClause; - function createCatchClause(variableDeclaration: string | VariableDeclaration, block: Block): CatchClause; - function updateCatchClause(node: CatchClause, variableDeclaration: VariableDeclaration, block: Block): CatchClause; + function createCatchClause(variableDeclaration: string | VariableDeclaration | undefined, block: Block): CatchClause; + function updateCatchClause(node: CatchClause, variableDeclaration: VariableDeclaration | undefined, block: Block): CatchClause; function createPropertyAssignment(name: string | PropertyName, initializer: Expression): PropertyAssignment; function updatePropertyAssignment(node: PropertyAssignment, name: PropertyName, initializer: Expression): PropertyAssignment; function createShorthandPropertyAssignment(name: string | Identifier, objectAssignmentInitializer?: Expression): ShorthandPropertyAssignment; @@ -3773,6 +3817,7 @@ declare namespace ts { getFormattingEditsAfterKeystroke(fileName: string, position: number, key: string, options: FormatCodeOptions | FormatCodeSettings): TextChange[]; getDocCommentTemplateAtPosition(fileName: string, position: number): TextInsertion; isValidBraceCompletionAtPosition(fileName: string, position: number, openingBrace: number): boolean; + getSpanOfEnclosingComment(fileName: string, position: number, onlyMultiLine: boolean): TextSpan; getCodeFixesAtPosition(fileName: string, start: number, end: number, errorCodes: number[], formatOptions: FormatCodeSettings): CodeAction[]; getApplicableRefactors(fileName: string, positionOrRaneg: number | TextRange): ApplicableRefactorInfo[]; getEditsForRefactor(fileName: string, formatOptions: FormatCodeSettings, positionOrRange: number | TextRange, refactorName: string, actionName: string): RefactorEditInfo | undefined; diff --git a/lib/typescriptServices.js b/lib/typescriptServices.js index eb71a73ba46..f1356d558c6 100644 --- a/lib/typescriptServices.js +++ b/lib/typescriptServices.js @@ -511,7 +511,7 @@ var ts; FlowFlags[FlowFlags["Label"] = 12] = "Label"; FlowFlags[FlowFlags["Condition"] = 96] = "Condition"; })(FlowFlags = ts.FlowFlags || (ts.FlowFlags = {})); - var OperationCanceledException = (function () { + var OperationCanceledException = /** @class */ (function () { function OperationCanceledException() { } return OperationCanceledException; @@ -570,11 +570,12 @@ var ts; TypeFormatFlags[TypeFormatFlags["UseFullyQualifiedType"] = 256] = "UseFullyQualifiedType"; TypeFormatFlags[TypeFormatFlags["InFirstTypeArgument"] = 512] = "InFirstTypeArgument"; TypeFormatFlags[TypeFormatFlags["InTypeAlias"] = 1024] = "InTypeAlias"; - TypeFormatFlags[TypeFormatFlags["UseTypeAliasValue"] = 2048] = "UseTypeAliasValue"; TypeFormatFlags[TypeFormatFlags["SuppressAnyReturnType"] = 4096] = "SuppressAnyReturnType"; TypeFormatFlags[TypeFormatFlags["AddUndefined"] = 8192] = "AddUndefined"; TypeFormatFlags[TypeFormatFlags["WriteClassExpressionAsTypeLiteral"] = 16384] = "WriteClassExpressionAsTypeLiteral"; TypeFormatFlags[TypeFormatFlags["InArrayType"] = 32768] = "InArrayType"; + TypeFormatFlags[TypeFormatFlags["UseAliasDefinedOutsideCurrentScope"] = 65536] = "UseAliasDefinedOutsideCurrentScope"; + // even though `T` can't be accessed in the current scope. })(TypeFormatFlags = ts.TypeFormatFlags || (ts.TypeFormatFlags = {})); var SymbolFormatFlags; (function (SymbolFormatFlags) { @@ -860,6 +861,21 @@ var ts; InferenceFlags[InferenceFlags["NoDefault"] = 2] = "NoDefault"; InferenceFlags[InferenceFlags["AnyDefault"] = 4] = "AnyDefault"; })(InferenceFlags = ts.InferenceFlags || (ts.InferenceFlags = {})); + /** + * Ternary values are defined such that + * x & y is False if either x or y is False. + * x & y is Maybe if either x or y is Maybe, but neither x or y is False. + * x & y is True if both x and y are True. + * x | y is False if both x and y are False. + * x | y is Maybe if either x or y is Maybe, but neither x or y is True. + * x | y is True if either x or y is True. + */ + var Ternary; + (function (Ternary) { + Ternary[Ternary["False"] = 0] = "False"; + Ternary[Ternary["Maybe"] = 1] = "Maybe"; + Ternary[Ternary["True"] = -1] = "True"; + })(Ternary = ts.Ternary || (ts.Ternary = {})); /* @internal */ var SpecialPropertyAssignmentKind; (function (SpecialPropertyAssignmentKind) { @@ -1329,27 +1345,12 @@ var ts; (function (ts) { // WARNING: The script `configureNightly.ts` uses a regexp to parse out these values. // If changing the text in this section, be sure to test `configureNightly` too. - ts.versionMajorMinor = "2.5"; + ts.versionMajorMinor = "2.6"; /** The version of the TypeScript compiler release */ ts.version = ts.versionMajorMinor + ".0"; })(ts || (ts = {})); /* @internal */ (function (ts) { - /** - * Ternary values are defined such that - * x & y is False if either x or y is False. - * x & y is Maybe if either x or y is Maybe, but neither x or y is False. - * x & y is True if both x and y are True. - * x | y is False if both x and y are False. - * x | y is Maybe if either x or y is Maybe, but neither x or y is True. - * x | y is True if either x or y is True. - */ - var Ternary; - (function (Ternary) { - Ternary[Ternary["False"] = 0] = "False"; - Ternary[Ternary["Maybe"] = 1] = "Maybe"; - Ternary[Ternary["True"] = -1] = "True"; - })(Ternary = ts.Ternary || (ts.Ternary = {})); // More efficient to create a collator once and use its `compare` than to call `a.localeCompare(b)` many times. ts.collator = typeof Intl === "object" && typeof Intl.Collator === "function" ? new Intl.Collator(/*locales*/ undefined, { usage: "sort", sensitivity: "accent" }) : undefined; // Intl is missing in Safari, and node 0.10 treats "a" as greater than "B". @@ -1403,7 +1404,7 @@ var ts; var MapCtr = typeof Map !== "undefined" && "entries" in Map.prototype ? Map : shimMap(); // Keep the class inside a function so it doesn't get compiled if it's not used. function shimMap() { - var MapIterator = (function () { + var MapIterator = /** @class */ (function () { function MapIterator(data, selector) { this.index = 0; this.data = data; @@ -1420,7 +1421,7 @@ var ts; }; return MapIterator; }()); - return (function () { + return /** @class */ (function () { function class_1() { this.data = createDictionaryObject(); this.size = 0; @@ -1668,10 +1669,9 @@ var ts; ts.removeWhere = removeWhere; function filterMutate(array, f) { var outIndex = 0; - for (var _i = 0, array_3 = array; _i < array_3.length; _i++) { - var item = array_3[_i]; - if (f(item)) { - array[outIndex] = item; + for (var i = 0; i < array.length; i++) { + if (f(array[i], i, array)) { + array[outIndex] = array[i]; outIndex++; } } @@ -1722,8 +1722,8 @@ var ts; var result; if (array) { result = []; - for (var _i = 0, array_4 = array; _i < array_4.length; _i++) { - var v = array_4[_i]; + for (var _i = 0, array_3 = array; _i < array_3.length; _i++) { + var v = array_3[_i]; if (v) { if (isArray(v)) { addRange(result, v); @@ -1799,11 +1799,13 @@ var ts; ts.sameFlatMap = sameFlatMap; function mapDefined(array, mapFn) { var result = []; - for (var i = 0; i < array.length; i++) { - var item = array[i]; - var mapped = mapFn(item, i); - if (mapped !== undefined) { - result.push(mapped); + if (array) { + for (var i = 0; i < array.length; i++) { + var item = array[i]; + var mapped = mapFn(item, i); + if (mapped !== undefined) { + result.push(mapped); + } } } return result; @@ -1882,8 +1884,8 @@ var ts; function some(array, predicate) { if (array) { if (predicate) { - for (var _i = 0, array_5 = array; _i < array_5.length; _i++) { - var v = array_5[_i]; + for (var _i = 0, array_4 = array; _i < array_4.length; _i++) { + var v = array_4[_i]; if (predicate(v)) { return true; } @@ -1909,8 +1911,8 @@ var ts; var result; if (array) { result = []; - loop: for (var _i = 0, array_6 = array; _i < array_6.length; _i++) { - var item = array_6[_i]; + loop: for (var _i = 0, array_5 = array; _i < array_5.length; _i++) { + var item = array_5[_i]; for (var _a = 0, result_1 = result; _a < result_1.length; _a++) { var res = result_1[_a]; if (areEqual ? areEqual(res, item) : res === item) { @@ -2003,8 +2005,8 @@ var ts; ts.relativeComplement = relativeComplement; function sum(array, prop) { var result = 0; - for (var _i = 0, array_7 = array; _i < array_7.length; _i++) { - var v = array_7[_i]; + for (var _i = 0, array_6 = array; _i < array_6.length; _i++) { + var v = array_6[_i]; // Note: we need the following type assertion because of GH #17069 result += v[prop]; } @@ -2336,8 +2338,8 @@ var ts; ts.equalOwnProperties = equalOwnProperties; function arrayToMap(array, makeKey, makeValue) { var result = createMap(); - for (var _i = 0, array_8 = array; _i < array_8.length; _i++) { - var value = array_8[_i]; + for (var _i = 0, array_7 = array; _i < array_7.length; _i++) { + var value = array_7[_i]; result.set(makeKey(value), makeValue ? makeValue(value) : value); } return result; @@ -2502,11 +2504,11 @@ var ts; ts.getLocaleSpecificMessage = getLocaleSpecificMessage; function createFileDiagnostic(file, start, length, message) { var end = start + length; - Debug.assert(start >= 0, "start must be non-negative, is " + start); - Debug.assert(length >= 0, "length must be non-negative, is " + length); + Debug.assertGreaterThanOrEqual(start, 0); + Debug.assertGreaterThanOrEqual(length, 0); if (file) { - Debug.assert(start <= file.text.length, "start must be within the bounds of the file. " + start + " > " + file.text.length); - Debug.assert(end <= file.text.length, "end must be the bounds of the file. " + end + " > " + file.text.length); + Debug.assertLessThanOrEqual(start, file.text.length); + Debug.assertLessThanOrEqual(end, file.text.length); } var text = getLocaleSpecificMessage(message); if (arguments.length > 4) { @@ -2736,19 +2738,23 @@ var ts; return normalized; } function normalizePath(path) { + return normalizePathAndParts(path).path; + } + ts.normalizePath = normalizePath; + function normalizePathAndParts(path) { path = normalizeSlashes(path); var rootLength = getRootLength(path); var root = path.substr(0, rootLength); - var normalized = getNormalizedParts(path, rootLength); - if (normalized.length) { - var joinedParts = root + normalized.join(ts.directorySeparator); - return pathEndsWithDirectorySeparator(path) ? joinedParts + ts.directorySeparator : joinedParts; + var parts = getNormalizedParts(path, rootLength); + if (parts.length) { + var joinedParts = root + parts.join(ts.directorySeparator); + return { path: pathEndsWithDirectorySeparator(path) ? joinedParts + ts.directorySeparator : joinedParts, parts: parts }; } else { - return root; + return { path: root, parts: parts }; } } - ts.normalizePath = normalizePath; + ts.normalizePathAndParts = normalizePathAndParts; /** A path ending with '/' refers to a directory only, never a file. */ function pathEndsWithDirectorySeparator(path) { return path.charCodeAt(path.length - 1) === directorySeparatorCharCode; @@ -3055,14 +3061,43 @@ var ts; // proof. var reservedCharacterPattern = /[^\w\s\/]/g; var wildcardCharCodes = [42 /* asterisk */, 63 /* question */]; - /** - * Matches any single directory segment unless it is the last segment and a .min.js file - * Breakdown: - * [^./] # matches everything up to the first . character (excluding directory seperators) - * (\\.(?!min\\.js$))? # matches . characters but not if they are part of the .min.js file extension - */ - var singleAsteriskRegexFragmentFiles = "([^./]|(\\.(?!min\\.js$))?)*"; - var singleAsteriskRegexFragmentOther = "[^/]*"; + /* @internal */ + ts.commonPackageFolders = ["node_modules", "bower_components", "jspm_packages"]; + var implicitExcludePathRegexPattern = "(?!(" + ts.commonPackageFolders.join("|") + ")(/|$))"; + var filesMatcher = { + /** + * Matches any single directory segment unless it is the last segment and a .min.js file + * Breakdown: + * [^./] # matches everything up to the first . character (excluding directory seperators) + * (\\.(?!min\\.js$))? # matches . characters but not if they are part of the .min.js file extension + */ + singleAsteriskRegexFragment: "([^./]|(\\.(?!min\\.js$))?)*", + /** + * Regex for the ** wildcard. Matches any number of subdirectories. When used for including + * files or directories, does not match subdirectories that start with a . character + */ + doubleAsteriskRegexFragment: "(/" + implicitExcludePathRegexPattern + "[^/.][^/]*)*?", + replaceWildcardCharacter: function (match) { return replaceWildcardCharacter(match, filesMatcher.singleAsteriskRegexFragment); } + }; + var directoriesMatcher = { + singleAsteriskRegexFragment: "[^/]*", + /** + * Regex for the ** wildcard. Matches any number of subdirectories. When used for including + * files or directories, does not match subdirectories that start with a . character + */ + doubleAsteriskRegexFragment: "(/" + implicitExcludePathRegexPattern + "[^/.][^/]*)*?", + replaceWildcardCharacter: function (match) { return replaceWildcardCharacter(match, directoriesMatcher.singleAsteriskRegexFragment); } + }; + var excludeMatcher = { + singleAsteriskRegexFragment: "[^/]*", + doubleAsteriskRegexFragment: "(/.+?)?", + replaceWildcardCharacter: function (match) { return replaceWildcardCharacter(match, excludeMatcher.singleAsteriskRegexFragment); } + }; + var wildcardMatchers = { + files: filesMatcher, + directories: directoriesMatcher, + exclude: excludeMatcher + }; function getRegularExpressionForWildcard(specs, basePath, usage) { var patterns = getRegularExpressionsForWildcards(specs, basePath, usage); if (!patterns || !patterns.length) { @@ -3078,15 +3113,8 @@ var ts; if (specs === undefined || specs.length === 0) { return undefined; } - var replaceWildcardCharacter = usage === "files" ? replaceWildCardCharacterFiles : replaceWildCardCharacterOther; - var singleAsteriskRegexFragment = usage === "files" ? singleAsteriskRegexFragmentFiles : singleAsteriskRegexFragmentOther; - /** - * Regex for the ** wildcard. Matches any number of subdirectories. When used for including - * files or directories, does not match subdirectories that start with a . character - */ - var doubleAsteriskRegexFragment = usage === "exclude" ? "(/.+?)?" : "(/[^/.][^/]*)*?"; return flatMap(specs, function (spec) { - return spec && getSubPatternFromSpec(spec, basePath, usage, singleAsteriskRegexFragment, doubleAsteriskRegexFragment, replaceWildcardCharacter); + return spec && getSubPatternFromSpec(spec, basePath, usage, wildcardMatchers[usage]); }); } /** @@ -3097,7 +3125,8 @@ var ts; return !/[.*?]/.test(lastPathComponent); } ts.isImplicitGlob = isImplicitGlob; - function getSubPatternFromSpec(spec, basePath, usage, singleAsteriskRegexFragment, doubleAsteriskRegexFragment, replaceWildcardCharacter) { + function getSubPatternFromSpec(spec, basePath, usage, _a) { + var singleAsteriskRegexFragment = _a.singleAsteriskRegexFragment, doubleAsteriskRegexFragment = _a.doubleAsteriskRegexFragment, replaceWildcardCharacter = _a.replaceWildcardCharacter; var subpattern = ""; var hasRecursiveDirectoryWildcard = false; var hasWrittenComponent = false; @@ -3131,19 +3160,33 @@ var ts; subpattern += ts.directorySeparator; } if (usage !== "exclude") { + var componentPattern = ""; // The * and ? wildcards should not match directories or files that start with . if they // appear first in a component. Dotted directories and files can be included explicitly // like so: **/.*/.* if (component.charCodeAt(0) === 42 /* asterisk */) { - subpattern += "([^./]" + singleAsteriskRegexFragment + ")?"; + componentPattern += "([^./]" + singleAsteriskRegexFragment + ")?"; component = component.substr(1); } else if (component.charCodeAt(0) === 63 /* question */) { - subpattern += "[^./]"; + componentPattern += "[^./]"; component = component.substr(1); } + componentPattern += component.replace(reservedCharacterPattern, replaceWildcardCharacter); + // Patterns should not include subfolders like node_modules unless they are + // explicitly included as part of the path. + // + // As an optimization, if the component pattern is the same as the component, + // then there definitely were no wildcard characters and we do not need to + // add the exclusion pattern. + if (componentPattern !== component) { + subpattern += implicitExcludePathRegexPattern; + } + subpattern += componentPattern; + } + else { + subpattern += component.replace(reservedCharacterPattern, replaceWildcardCharacter); } - subpattern += component.replace(reservedCharacterPattern, replaceWildcardCharacter); } hasWrittenComponent = true; } @@ -3153,12 +3196,6 @@ var ts; } return subpattern; } - function replaceWildCardCharacterFiles(match) { - return replaceWildcardCharacter(match, singleAsteriskRegexFragmentFiles); - } - function replaceWildCardCharacterOther(match) { - return replaceWildcardCharacter(match, singleAsteriskRegexFragmentOther); - } function replaceWildcardCharacter(match, singleAsteriskRegexFragment) { return match === "*" ? singleAsteriskRegexFragment : match === "?" ? "[^/]" : "\\" + match; } @@ -3319,14 +3356,7 @@ var ts; if (!extraFileExtensions || extraFileExtensions.length === 0 || !needAllExtensions) { return needAllExtensions ? allSupportedExtensions : ts.supportedTypeScriptExtensions; } - var extensions = allSupportedExtensions.slice(0); - for (var _i = 0, extraFileExtensions_1 = extraFileExtensions; _i < extraFileExtensions_1.length; _i++) { - var extInfo = extraFileExtensions_1[_i]; - if (extensions.indexOf(extInfo.extension) === -1) { - extensions.push(extInfo.extension); - } - } - return extensions; + return deduplicate(allSupportedExtensions.concat(extraFileExtensions.map(function (e) { return e.extension; }))); } ts.getSupportedExtensions = getSupportedExtensions; function hasJavaScriptFileExtension(fileName) { @@ -3481,12 +3511,37 @@ var ts; function assert(expression, message, verboseDebugInfo, stackCrawlMark) { if (!expression) { if (verboseDebugInfo) { - message += "\r\nVerbose Debug Information: " + verboseDebugInfo(); + message += "\r\nVerbose Debug Information: " + (typeof verboseDebugInfo === "string" ? verboseDebugInfo : verboseDebugInfo()); } fail(message ? "False expression: " + message : "False expression.", stackCrawlMark || assert); } } Debug.assert = assert; + function assertEqual(a, b, msg, msg2) { + if (a !== b) { + var message = msg ? msg2 ? msg + " " + msg2 : msg : ""; + fail("Expected " + a + " === " + b + ". " + message); + } + } + Debug.assertEqual = assertEqual; + function assertLessThan(a, b, msg) { + if (a >= b) { + fail("Expected " + a + " < " + b + ". " + (msg || "")); + } + } + Debug.assertLessThan = assertLessThan; + function assertLessThanOrEqual(a, b) { + if (a > b) { + fail("Expected " + a + " <= " + b); + } + } + Debug.assertLessThanOrEqual = assertLessThanOrEqual; + function assertGreaterThanOrEqual(a, b) { + if (a < b) { + fail("Expected " + a + " >= " + b); + } + } + Debug.assertGreaterThanOrEqual = assertGreaterThanOrEqual; function fail(message, stackCrawlMark) { debugger; var e = new Error(message ? "Debug Failure. " + message : "Debug Failure."); @@ -3652,6 +3707,10 @@ var ts; Debug.fail("File " + path + " has unknown extension."); } ts.extensionFromPath = extensionFromPath; + function isAnySupportedFileExtension(path) { + return tryGetExtensionFromPath(path) !== undefined; + } + ts.isAnySupportedFileExtension = isAnySupportedFileExtension; function tryGetExtensionFromPath(path) { return find(ts.supportedTypescriptExtensionsForExtractExtension, function (e) { return fileExtensionIs(path, e); }) || find(ts.supportedJavascriptExtensions, function (e) { return fileExtensionIs(path, e); }); } @@ -3664,6 +3723,18 @@ var ts; /// var ts; (function (ts) { + /** + * Set a high stack trace limit to provide more information in case of an error. + * Called for command-line and server use cases. + * Not called if TypeScript is used as a library. + */ + /* @internal */ + function setStackTraceLimit() { + if (Error.stackTraceLimit < 100) { + Error.stackTraceLimit = 100; + } + } + ts.setStackTraceLimit = setStackTraceLimit; var FileWatcherEventKind; (function (FileWatcherEventKind) { FileWatcherEventKind[FileWatcherEventKind["Created"] = 0] = "Created"; @@ -3714,7 +3785,7 @@ var ts; watcher.referenceCount += 1; return; } - watcher = _fs.watch(dirPath, { persistent: true }, function (eventName, relativeFileName) { return fileEventHandler(eventName, relativeFileName, dirPath); }); + watcher = _fs.watch(dirPath || ".", { persistent: true }, function (eventName, relativeFileName) { return fileEventHandler(eventName, relativeFileName, dirPath); }); watcher.referenceCount = 1; dirWatchers.set(dirPath, watcher); return; @@ -4569,6 +4640,8 @@ var ts; Expected_at_least_0_arguments_but_got_a_minimum_of_1: diag(2557, ts.DiagnosticCategory.Error, "Expected_at_least_0_arguments_but_got_a_minimum_of_1_2557", "Expected at least {0} arguments, but got a minimum of {1}."), Expected_0_type_arguments_but_got_1: diag(2558, ts.DiagnosticCategory.Error, "Expected_0_type_arguments_but_got_1_2558", "Expected {0} type arguments, but got {1}."), Type_0_has_no_properties_in_common_with_type_1: diag(2559, ts.DiagnosticCategory.Error, "Type_0_has_no_properties_in_common_with_type_1_2559", "Type '{0}' has no properties in common with type '{1}'."), + Value_of_type_0_has_no_properties_in_common_with_type_1_Did_you_mean_to_call_it: diag(2560, ts.DiagnosticCategory.Error, "Value_of_type_0_has_no_properties_in_common_with_type_1_Did_you_mean_to_call_it_2560", "Value of type '{0}' has no properties in common with type '{1}'. Did you mean to call it?"), + Base_class_expressions_cannot_reference_class_type_parameters: diag(2561, ts.DiagnosticCategory.Error, "Base_class_expressions_cannot_reference_class_type_parameters_2561", "Base class expressions cannot reference class type parameters."), JSX_element_attributes_type_0_may_not_be_a_union_type: diag(2600, ts.DiagnosticCategory.Error, "JSX_element_attributes_type_0_may_not_be_a_union_type_2600", "JSX element attributes type '{0}' may not be a union type."), The_return_type_of_a_JSX_element_constructor_must_return_an_object_type: diag(2601, ts.DiagnosticCategory.Error, "The_return_type_of_a_JSX_element_constructor_must_return_an_object_type_2601", "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: diag(2602, ts.DiagnosticCategory.Error, "JSX_element_implicitly_has_type_any_because_the_global_type_JSX_Element_does_not_exist_2602", "JSX element implicitly has type 'any' because the global type 'JSX.Element' does not exist."), @@ -4756,6 +4829,7 @@ var ts; Do_not_emit_outputs: diag(6010, ts.DiagnosticCategory.Message, "Do_not_emit_outputs_6010", "Do not emit outputs."), Allow_default_imports_from_modules_with_no_default_export_This_does_not_affect_code_emit_just_typechecking: diag(6011, ts.DiagnosticCategory.Message, "Allow_default_imports_from_modules_with_no_default_export_This_does_not_affect_code_emit_just_typech_6011", "Allow default imports from modules with no default export. This does not affect code emit, just typechecking."), Skip_type_checking_of_declaration_files: diag(6012, ts.DiagnosticCategory.Message, "Skip_type_checking_of_declaration_files_6012", "Skip type checking of declaration files."), + Do_not_resolve_the_real_path_of_symlinks: diag(6013, ts.DiagnosticCategory.Message, "Do_not_resolve_the_real_path_of_symlinks_6013", "Do not resolve the real path of symlinks."), Specify_ECMAScript_target_version_Colon_ES3_default_ES5_ES2015_ES2016_ES2017_or_ESNEXT: diag(6015, ts.DiagnosticCategory.Message, "Specify_ECMAScript_target_version_Colon_ES3_default_ES5_ES2015_ES2016_ES2017_or_ESNEXT_6015", "Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', or 'ESNEXT'."), Specify_module_code_generation_Colon_none_commonjs_amd_system_umd_es2015_or_ESNext: diag(6016, ts.DiagnosticCategory.Message, "Specify_module_code_generation_Colon_none_commonjs_amd_system_umd_es2015_or_ESNext_6016", "Specify module code generation: 'none', commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'."), Print_this_message: diag(6017, ts.DiagnosticCategory.Message, "Print_this_message_6017", "Print this message."), @@ -5009,6 +5083,8 @@ var ts; Rewrite_as_the_indexed_access_type_0: diag(90026, ts.DiagnosticCategory.Message, "Rewrite_as_the_indexed_access_type_0_90026", "Rewrite as the indexed access type '{0}'."), Convert_function_to_an_ES2015_class: diag(95001, ts.DiagnosticCategory.Message, "Convert_function_to_an_ES2015_class_95001", "Convert function to an ES2015 class"), Convert_function_0_to_class: diag(95002, ts.DiagnosticCategory.Message, "Convert_function_0_to_class_95002", "Convert function '{0}' to class"), + Extract_function: diag(95003, ts.DiagnosticCategory.Message, "Extract_function_95003", "Extract function"), + Extract_function_into_0: diag(95004, ts.DiagnosticCategory.Message, "Extract_function_into_0_95004", "Extract function into '{0}'"), }; })(ts || (ts = {})); /// @@ -6812,19 +6888,6 @@ var ts; return undefined; } ts.getDeclarationOfKind = getDeclarationOfKind; - function findDeclaration(symbol, predicate) { - var declarations = symbol.declarations; - if (declarations) { - for (var _i = 0, declarations_2 = declarations; _i < declarations_2.length; _i++) { - var declaration = declarations_2[_i]; - if (predicate(declaration)) { - return declaration; - } - } - } - return undefined; - } - ts.findDeclaration = findDeclaration; var stringWriter = createSingleLineStringWriter(); var stringWriterAcquired = false; function createSingleLineStringWriter() { @@ -6886,19 +6949,20 @@ var ts; sourceFile.resolvedTypeReferenceDirectiveNames.set(typeReferenceDirectiveName, resolvedTypeReferenceDirective); } ts.setResolvedTypeReferenceDirective = setResolvedTypeReferenceDirective; - /* @internal */ function moduleResolutionIsEqualTo(oldResolution, newResolution) { return oldResolution.isExternalLibraryImport === newResolution.isExternalLibraryImport && oldResolution.extension === newResolution.extension && - oldResolution.resolvedFileName === newResolution.resolvedFileName; + oldResolution.resolvedFileName === newResolution.resolvedFileName && + packageIdIsEqual(oldResolution.packageId, newResolution.packageId); } ts.moduleResolutionIsEqualTo = moduleResolutionIsEqualTo; - /* @internal */ + function packageIdIsEqual(a, b) { + return a === b || a && b && a.name === b.name && a.version === b.version; + } function typeDirectiveIsEqualTo(oldResolution, newResolution) { return oldResolution.resolvedFileName === newResolution.resolvedFileName && oldResolution.primary === newResolution.primary; } ts.typeDirectiveIsEqualTo = typeDirectiveIsEqualTo; - /* @internal */ function hasChangesInResolutions(names, newResolutions, oldResolutions, comparer) { ts.Debug.assert(names.length === newResolutions.length); for (var i = 0; i < names.length; i++) { @@ -6968,14 +7032,6 @@ var ts; return file.fileName + "(" + (loc.line + 1) + "," + (loc.character + 1) + ")"; } ts.nodePosToString = nodePosToString; - function getStartPosOfNode(node) { - return node.pos; - } - ts.getStartPosOfNode = getStartPosOfNode; - function isDefined(value) { - return value !== undefined; - } - ts.isDefined = isDefined; function getEndLinePosition(line, sourceFile) { ts.Debug.assert(line >= 0); var lineStarts = ts.getLineStarts(sourceFile); @@ -7025,6 +7081,32 @@ var ts; return !nodeIsMissing(node); } ts.nodeIsPresent = nodeIsPresent; + /** + * Determine if the given comment is a triple-slash + * + * @return true if the comment is a triple-slash comment else false + */ + function isRecognizedTripleSlashComment(text, commentPos, commentEnd) { + // 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 (text.charCodeAt(commentPos + 1) === 47 /* slash */ && + commentPos + 2 < commentEnd && + text.charCodeAt(commentPos + 2) === 47 /* slash */) { + var textSubStr = text.substring(commentPos, commentEnd); + return textSubStr.match(ts.fullTripleSlashReferencePathRegEx) || + textSubStr.match(ts.fullTripleSlashAMDReferencePathRegEx) || + textSubStr.match(fullTripleSlashReferenceTypeReferenceDirectiveRegEx) || + textSubStr.match(defaultLibReferenceRegEx) ? + true : false; + } + return false; + } + ts.isRecognizedTripleSlashComment = isRecognizedTripleSlashComment; + function isPinnedComment(text, comment) { + return text.charCodeAt(comment.pos + 1) === 42 /* asterisk */ && + text.charCodeAt(comment.pos + 2) === 33 /* exclamation */; + } + ts.isPinnedComment = isPinnedComment; function getTokenPosOfNode(node, sourceFile, includeJsDoc) { // With nodes that have no width (i.e. 'Missing' nodes), we actually *don't* // want to skip trivia because this will launch us forward to the next token. @@ -7094,15 +7176,20 @@ var ts; // or a (possibly escaped) quoted form of the original text if it's string-like. switch (node.kind) { case 9 /* StringLiteral */: - return '"' + escapeText(node.text) + '"'; + if (node.singleQuote) { + return "'" + escapeText(node.text, 39 /* singleQuote */) + "'"; + } + else { + return '"' + escapeText(node.text, 34 /* doubleQuote */) + '"'; + } case 13 /* NoSubstitutionTemplateLiteral */: - return "`" + escapeText(node.text) + "`"; + return "`" + escapeText(node.text, 96 /* backtick */) + "`"; case 14 /* TemplateHead */: - return "`" + escapeText(node.text) + "${"; + return "`" + escapeText(node.text, 96 /* backtick */) + "${"; case 15 /* TemplateMiddle */: - return "}" + escapeText(node.text) + "${"; + return "}" + escapeText(node.text, 96 /* backtick */) + "${"; case 16 /* TemplateTail */: - return "}" + escapeText(node.text) + "`"; + return "}" + escapeText(node.text, 96 /* backtick */) + "`"; case 8 /* NumericLiteral */: return node.text; } @@ -7191,6 +7278,7 @@ var ts; return ts.isExternalModule(node) || compilerOptions.isolatedModules; } ts.isEffectiveExternalModule = isEffectiveExternalModule; + /* @internal */ function isBlockScope(node, parentNode) { switch (node.kind) { case 265 /* SourceFile */: @@ -7381,13 +7469,9 @@ var ts; } ts.isPrologueDirective = isPrologueDirective; function getLeadingCommentRangesOfNode(node, sourceFileOfNode) { - return ts.getLeadingCommentRanges(sourceFileOfNode.text, node.pos); + return node.kind !== 10 /* JsxText */ ? ts.getLeadingCommentRanges(sourceFileOfNode.text, node.pos) : undefined; } ts.getLeadingCommentRangesOfNode = getLeadingCommentRangesOfNode; - function getLeadingCommentRangesOfNodeFromText(node, text) { - return ts.getLeadingCommentRanges(text, node.pos); - } - ts.getLeadingCommentRangesOfNodeFromText = getLeadingCommentRangesOfNodeFromText; function getJSDocCommentRanges(node, text) { var commentRanges = (node.kind === 146 /* Parameter */ || node.kind === 145 /* TypeParameter */ || @@ -7395,7 +7479,7 @@ var ts; node.kind === 187 /* ArrowFunction */ || node.kind === 185 /* ParenthesizedExpression */) ? ts.concatenate(ts.getTrailingCommentRanges(text, node.pos), ts.getLeadingCommentRanges(text, node.pos)) : - getLeadingCommentRangesOfNodeFromText(node, text); + ts.getLeadingCommentRanges(text, node.pos); // True if the comment starts with '/**' but not if it is '/**/' return ts.filter(commentRanges, function (comment) { return text.charCodeAt(comment.pos + 1) === 42 /* asterisk */ && @@ -7405,8 +7489,9 @@ var ts; } ts.getJSDocCommentRanges = getJSDocCommentRanges; ts.fullTripleSlashReferencePathRegEx = /^(\/\/\/\s*/; - ts.fullTripleSlashReferenceTypeReferenceDirectiveRegEx = /^(\/\/\/\s*/; + var fullTripleSlashReferenceTypeReferenceDirectiveRegEx = /^(\/\/\/\s*/; ts.fullTripleSlashAMDReferencePathRegEx = /^(\/\/\/\s*/; + var defaultLibReferenceRegEx = /^(\/\/\/\s*/; function isPartOfTypeNode(node) { if (158 /* FirstTypeNode */ <= node.kind && node.kind <= 173 /* LastTypeNode */) { return true; @@ -7660,21 +7745,11 @@ var ts; } ts.getPropertyAssignment = getPropertyAssignment; function getContainingFunction(node) { - while (true) { - node = node.parent; - if (!node || ts.isFunctionLike(node)) { - return node; - } - } + return ts.findAncestor(node.parent, ts.isFunctionLike); } ts.getContainingFunction = getContainingFunction; function getContainingClass(node) { - while (true) { - node = node.parent; - if (!node || ts.isClassLike(node)) { - return node; - } - } + return ts.findAncestor(node.parent, ts.isClassLike); } ts.getContainingClass = getContainingClass; function getThisContainer(node, includeArrowFunctions) { @@ -8570,14 +8645,14 @@ var ts; ts.getAncestor = getAncestor; function getFileReferenceFromReferencePath(comment, commentRange) { var simpleReferenceRegEx = /^\/\/\/\s*/gim; + var isNoDefaultLibRegEx = new RegExp(defaultLibReferenceRegEx.source, "gim"); if (simpleReferenceRegEx.test(comment)) { if (isNoDefaultLibRegEx.test(comment)) { return { isNoDefaultLib: true }; } else { var refMatchResult = ts.fullTripleSlashReferencePathRegEx.exec(comment); - var refLibResult = !refMatchResult && ts.fullTripleSlashReferenceTypeReferenceDirectiveRegEx.exec(comment); + var refLibResult = !refMatchResult && fullTripleSlashReferenceTypeReferenceDirectiveRegEx.exec(comment); var match = refMatchResult || refLibResult; if (match) { var pos = commentRange.pos + match[1].length + match[2].length; @@ -8782,10 +8857,6 @@ var ts; return ts.getParseTreeNode(sourceFile, ts.isSourceFile) || sourceFile; } ts.getOriginalSourceFile = getOriginalSourceFile; - function getOriginalSourceFiles(sourceFiles) { - return ts.sameMap(sourceFiles, getOriginalSourceFile); - } - ts.getOriginalSourceFiles = getOriginalSourceFiles; var Associativity; (function (Associativity) { Associativity[Associativity["Left"] = 0] = "Left"; @@ -9029,7 +9100,9 @@ var ts; // the language service. These characters should be escaped when printing, and if any characters are added, // the map below must be updated. Note that this regexp *does not* include the 'delete' character. // There is no reason for this other than that JSON.stringify does not handle it either. - var escapedCharsRegExp = /[\\\"\u0000-\u001f\t\v\f\b\r\n\u2028\u2029\u0085]/g; + var doubleQuoteEscapedCharsRegExp = /[\\\"\u0000-\u001f\t\v\f\b\r\n\u2028\u2029\u0085]/g; + var singleQuoteEscapedCharsRegExp = /[\\\'\u0000-\u001f\t\v\f\b\r\n\u2028\u2029\u0085]/g; + var backtickQuoteEscapedCharsRegExp = /[\\\`\u0000-\u001f\t\v\f\b\r\n\u2028\u2029\u0085]/g; var escapedCharsMap = ts.createMapFromTemplate({ "\0": "\\0", "\t": "\\t", @@ -9040,6 +9113,8 @@ var ts; "\n": "\\n", "\\": "\\\\", "\"": "\\\"", + "\'": "\\\'", + "\`": "\\\`", "\u2028": "\\u2028", "\u2029": "\\u2029", "\u0085": "\\u0085" // nextLine @@ -9049,7 +9124,10 @@ var ts; * but augmented for a few select characters (e.g. lineSeparator, paragraphSeparator, nextLine) * Note that this doesn't actually wrap the input in double quotes. */ - function escapeString(s) { + function escapeString(s, quoteChar) { + var escapedCharsRegExp = quoteChar === 96 /* backtick */ ? backtickQuoteEscapedCharsRegExp : + quoteChar === 39 /* singleQuote */ ? singleQuoteEscapedCharsRegExp : + doubleQuoteEscapedCharsRegExp; return s.replace(escapedCharsRegExp, getReplacement); } ts.escapeString = escapeString; @@ -9069,8 +9147,8 @@ var ts; return "\\u" + paddedHexCode; } var nonAsciiCharacters = /[^\u0000-\u007F]/g; - function escapeNonAsciiString(s) { - s = escapeString(s); + function escapeNonAsciiString(s, quoteChar) { + s = escapeString(s, quoteChar); // Replace non-ASCII characters with '\uNNNN' escapes if any exist. // Otherwise just return the original string. return nonAsciiCharacters.test(s) ? @@ -9455,7 +9533,7 @@ var ts; // // var x = 10; if (node.pos === 0) { - leadingComments = ts.filter(ts.getLeadingCommentRanges(text, node.pos), isPinnedComment); + leadingComments = ts.filter(ts.getLeadingCommentRanges(text, node.pos), isPinnedCommentLocal); } } else { @@ -9495,9 +9573,8 @@ var ts; } } return currentDetachedCommentInfo; - function isPinnedComment(comment) { - return text.charCodeAt(comment.pos + 1) === 42 /* asterisk */ && - text.charCodeAt(comment.pos + 2) === 33 /* exclamation */; + function isPinnedCommentLocal(comment) { + return isPinnedComment(text, comment); } } ts.emitDetachedComments = emitDetachedComments; @@ -9593,9 +9670,13 @@ var ts; } ts.hasModifiers = hasModifiers; function hasModifier(node, flags) { - return (getModifierFlags(node) & flags) !== 0; + return !!getSelectedModifierFlags(node, flags); } ts.hasModifier = hasModifier; + function getSelectedModifierFlags(node, flags) { + return getModifierFlags(node) & flags; + } + ts.getSelectedModifierFlags = getSelectedModifierFlags; function getModifierFlags(node) { if (node.modifierFlagsCache & 536870912 /* HasComputedFlags */) { return node.modifierFlagsCache & ~536870912 /* HasComputedFlags */; @@ -9673,23 +9754,6 @@ var ts; return false; } ts.isDestructuringAssignment = isDestructuringAssignment; - // Returns false if this heritage clause element's expression contains something unsupported - // (i.e. not a name or dotted name). - function isSupportedExpressionWithTypeArguments(node) { - return isSupportedExpressionWithTypeArgumentsRest(node.expression); - } - ts.isSupportedExpressionWithTypeArguments = isSupportedExpressionWithTypeArguments; - function isSupportedExpressionWithTypeArgumentsRest(node) { - if (node.kind === 71 /* Identifier */) { - return true; - } - else if (ts.isPropertyAccessExpression(node)) { - return isSupportedExpressionWithTypeArgumentsRest(node.expression); - } - else { - return false; - } - } function isExpressionWithTypeArgumentsInClassExtendsClause(node) { return tryGetClassExtendingExpressionWithTypeArguments(node) !== undefined; } @@ -9816,78 +9880,6 @@ var ts; return carriageReturnLineFeed; } ts.getNewLineCharacter = getNewLineCharacter; - /** - * Tests whether a node and its subtree is simple enough to have its position - * information ignored when emitting source maps in a destructuring assignment. - * - * @param node The expression to test. - */ - function isSimpleExpression(node) { - return isSimpleExpressionWorker(node, 0); - } - ts.isSimpleExpression = isSimpleExpression; - function isSimpleExpressionWorker(node, depth) { - if (depth <= 5) { - var kind = node.kind; - if (kind === 9 /* StringLiteral */ - || kind === 8 /* NumericLiteral */ - || kind === 12 /* RegularExpressionLiteral */ - || kind === 13 /* NoSubstitutionTemplateLiteral */ - || kind === 71 /* Identifier */ - || kind === 99 /* ThisKeyword */ - || kind === 97 /* SuperKeyword */ - || kind === 101 /* TrueKeyword */ - || kind === 86 /* FalseKeyword */ - || kind === 95 /* NullKeyword */) { - return true; - } - else if (kind === 179 /* PropertyAccessExpression */) { - return isSimpleExpressionWorker(node.expression, depth + 1); - } - else if (kind === 180 /* ElementAccessExpression */) { - return isSimpleExpressionWorker(node.expression, depth + 1) - && isSimpleExpressionWorker(node.argumentExpression, depth + 1); - } - else if (kind === 192 /* PrefixUnaryExpression */ - || kind === 193 /* PostfixUnaryExpression */) { - return isSimpleExpressionWorker(node.operand, depth + 1); - } - else if (kind === 194 /* BinaryExpression */) { - return node.operatorToken.kind !== 40 /* AsteriskAsteriskToken */ - && isSimpleExpressionWorker(node.left, depth + 1) - && isSimpleExpressionWorker(node.right, depth + 1); - } - else if (kind === 195 /* ConditionalExpression */) { - return isSimpleExpressionWorker(node.condition, depth + 1) - && isSimpleExpressionWorker(node.whenTrue, depth + 1) - && isSimpleExpressionWorker(node.whenFalse, depth + 1); - } - else if (kind === 190 /* VoidExpression */ - || kind === 189 /* TypeOfExpression */ - || kind === 188 /* DeleteExpression */) { - return isSimpleExpressionWorker(node.expression, depth + 1); - } - else if (kind === 177 /* ArrayLiteralExpression */) { - return node.elements.length === 0; - } - else if (kind === 178 /* ObjectLiteralExpression */) { - return node.properties.length === 0; - } - else if (kind === 181 /* CallExpression */) { - if (!isSimpleExpressionWorker(node.expression, depth + 1)) { - return false; - } - for (var _i = 0, _a = node.arguments; _i < _a.length; _i++) { - var argument = _a[_i]; - if (!isSimpleExpressionWorker(argument, depth + 1)) { - return false; - } - } - return true; - } - } - return false; - } /** * Formats an enum value as a string for debugging and debug assertions. */ @@ -9959,24 +9951,6 @@ var ts; return formatEnum(flags, ts.ObjectFlags, /*isFlags*/ true); } ts.formatObjectFlags = formatObjectFlags; - function getRangePos(range) { - return range ? range.pos : -1; - } - ts.getRangePos = getRangePos; - function getRangeEnd(range) { - return range ? range.end : -1; - } - ts.getRangeEnd = getRangeEnd; - /** - * Increases (or decreases) a position by the provided amount. - * - * @param pos The position. - * @param value The delta. - */ - function movePos(pos, value) { - return ts.positionIsSynthesized(pos) ? -1 : pos + value; - } - ts.movePos = movePos; /** * Creates a new TextRange from the provided pos and end. * @@ -10034,26 +10008,6 @@ var ts; return range.pos === range.end; } ts.isCollapsedRange = isCollapsedRange; - /** - * Creates a new TextRange from a provided range with its end position collapsed to its - * start position. - * - * @param range A TextRange. - */ - function collapseRangeToStart(range) { - return isCollapsedRange(range) ? range : moveRangeEnd(range, range.pos); - } - ts.collapseRangeToStart = collapseRangeToStart; - /** - * Creates a new TextRange from a provided range with its start position collapsed to its - * end position. - * - * @param range A TextRange. - */ - function collapseRangeToEnd(range) { - return isCollapsedRange(range) ? range : moveRangePos(range, range.end); - } - ts.collapseRangeToEnd = collapseRangeToEnd; /** * Creates a new TextRange for a token at the provides start position. * @@ -10116,31 +10070,6 @@ var ts; function isInitializedVariable(node) { return node.initializer !== undefined; } - /** - * Gets a value indicating whether a node is merged with a class declaration in the same scope. - */ - function isMergedWithClass(node) { - if (node.symbol) { - for (var _i = 0, _a = node.symbol.declarations; _i < _a.length; _i++) { - var declaration = _a[_i]; - if (declaration.kind === 229 /* ClassDeclaration */ && declaration !== node) { - return true; - } - } - } - return false; - } - ts.isMergedWithClass = isMergedWithClass; - /** - * Gets a value indicating whether a node is the first declaration of its kind. - * - * @param node A Declaration node. - * @param kind The SyntaxKind to find among related declarations. - */ - function isFirstDeclarationOfKind(node, kind) { - return node.symbol && getDeclarationOfKind(node.symbol, kind) === node; - } - ts.isFirstDeclarationOfKind = isFirstDeclarationOfKind; function isWatchSet(options) { // Firefox has Object.prototype.watch return options.watch && options.hasOwnProperty("watch"); @@ -10434,6 +10363,20 @@ var ts; return ts.hasModifier(node, 92 /* ParameterPropertyModifier */) && node.parent.kind === 152 /* Constructor */ && ts.isClassLike(node.parent.parent); } ts.isParameterPropertyDeclaration = isParameterPropertyDeclaration; + function isEmptyBindingPattern(node) { + if (ts.isBindingPattern(node)) { + return ts.every(node.elements, isEmptyBindingElement); + } + return false; + } + ts.isEmptyBindingPattern = isEmptyBindingPattern; + function isEmptyBindingElement(node) { + if (ts.isOmittedExpression(node)) { + return true; + } + return isEmptyBindingPattern(node.name); + } + ts.isEmptyBindingElement = isEmptyBindingElement; function walkUpBindingElementsAndPatterns(node) { while (node && (node.kind === 176 /* BindingElement */ || ts.isBindingPattern(node))) { node = node.parent; @@ -11618,6 +11561,19 @@ var ts; return isUnaryExpressionKind(ts.skipPartiallyEmittedExpressions(node).kind); } ts.isUnaryExpression = isUnaryExpression; + /* @internal */ + function isUnaryExpressionWithWrite(expr) { + switch (expr.kind) { + case 193 /* PostfixUnaryExpression */: + return true; + case 192 /* PrefixUnaryExpression */: + return expr.operator === 43 /* PlusPlusToken */ || + expr.operator === 44 /* MinusMinusToken */; + default: + return false; + } + } + ts.isUnaryExpressionWithWrite = isUnaryExpressionWithWrite; function isExpressionKind(kind) { return kind === 195 /* ConditionalExpression */ || kind === 197 /* YieldExpression */ @@ -11824,9 +11780,19 @@ var ts; var kind = node.kind; return isStatementKindButNotDeclarationKind(kind) || isDeclarationStatementKind(kind) - || kind === 207 /* Block */; + || isBlockStatement(node); } ts.isStatement = isStatement; + function isBlockStatement(node) { + if (node.kind !== 207 /* Block */) + return false; + if (node.parent !== undefined) { + if (node.parent.kind === 224 /* TryStatement */ || node.parent.kind === 260 /* CatchClause */) { + return false; + } + } + return !ts.isFunctionBlock(node); + } // Module references /* @internal */ function isModuleReference(node) { @@ -14207,11 +14173,31 @@ var ts; var node = parseTokenNode(); return token() === 23 /* DotToken */ ? undefined : node; } - function parseLiteralTypeNode() { + function parseLiteralTypeNode(negative) { var node = createNode(173 /* LiteralType */); - node.literal = parseSimpleUnaryExpression(); - finishNode(node); - return node; + var unaryMinusExpression; + if (negative) { + unaryMinusExpression = createNode(192 /* PrefixUnaryExpression */); + unaryMinusExpression.operator = 38 /* MinusToken */; + nextToken(); + } + var expression; + switch (token()) { + case 9 /* StringLiteral */: + case 8 /* NumericLiteral */: + expression = parseLiteralLikeNode(token()); + break; + case 101 /* TrueKeyword */: + case 86 /* FalseKeyword */: + expression = parseTokenNode(); + } + if (negative) { + unaryMinusExpression.operand = expression; + finishNode(unaryMinusExpression); + expression = unaryMinusExpression; + } + node.literal = expression; + return finishNode(node); } function nextTokenIsNumericLiteral() { return nextToken() === 8 /* NumericLiteral */; @@ -14244,7 +14230,7 @@ var ts; case 86 /* FalseKeyword */: return parseLiteralTypeNode(); case 38 /* MinusToken */: - return lookAhead(nextTokenIsNumericLiteral) ? parseLiteralTypeNode() : parseTypeReference(); + return lookAhead(nextTokenIsNumericLiteral) ? parseLiteralTypeNode(/*negative*/ true) : parseTypeReference(); case 105 /* VoidKeyword */: case 95 /* NullKeyword */: return parseTokenNode(); @@ -14293,6 +14279,7 @@ var ts; case 101 /* TrueKeyword */: case 86 /* FalseKeyword */: case 134 /* ObjectKeyword */: + case 39 /* AsteriskToken */: return true; case 38 /* MinusToken */: return lookAhead(nextTokenIsNumericLiteral); @@ -14721,7 +14708,7 @@ var ts; // Didn't appear to actually be a parenthesized arrow function. Just bail out. return undefined; } - var isAsync = !!(ts.getModifierFlags(arrowFunction) & 256 /* Async */); + var isAsync = ts.hasModifier(arrowFunction, 256 /* Async */); // If we have an arrow, then try to parse the body. Even if not, try to parse if we // have an opening brace, just in case we're in an error state. var lastToken = token(); @@ -14879,7 +14866,7 @@ var ts; function parseParenthesizedArrowFunctionExpressionHead(allowAmbiguity) { var node = createNode(187 /* ArrowFunction */); node.modifiers = parseModifiersForArrowFunction(); - var isAsync = (ts.getModifierFlags(node) & 256 /* Async */) ? 2 /* Await */ : 0 /* None */; + var isAsync = ts.hasModifier(node, 256 /* Async */) ? 2 /* Await */ : 0 /* None */; // Arrow functions are never generators. // // If we're speculatively parsing a signature for a parenthesized arrow function, then @@ -15890,7 +15877,7 @@ var ts; parseExpected(89 /* FunctionKeyword */); node.asteriskToken = parseOptionalToken(39 /* AsteriskToken */); var isGenerator = node.asteriskToken ? 1 /* Yield */ : 0 /* None */; - var isAsync = (ts.getModifierFlags(node) & 256 /* Async */) ? 2 /* Await */ : 0 /* None */; + var isAsync = ts.hasModifier(node, 256 /* Async */) ? 2 /* Await */ : 0 /* None */; node.name = isGenerator && isAsync ? doInYieldAndAwaitContext(parseOptionalIdentifier) : isGenerator ? doInYieldContext(parseOptionalIdentifier) : @@ -16132,10 +16119,14 @@ var ts; function parseCatchClause() { var result = createNode(260 /* CatchClause */); parseExpected(74 /* CatchKeyword */); - if (parseExpected(19 /* OpenParenToken */)) { + if (parseOptional(19 /* OpenParenToken */)) { result.variableDeclaration = parseVariableDeclaration(); + parseExpected(20 /* CloseParenToken */); + } + else { + // Keep shape of node to avoid degrading performance. + result.variableDeclaration = undefined; } - parseExpected(20 /* CloseParenToken */); result.block = parseBlock(/*ignoreMissingOpenBrace*/ false); return finishNode(result); } @@ -17036,8 +17027,8 @@ var ts; // ImportDeclaration: // import ImportClause from ModuleSpecifier ; // import ModuleSpecifier; - if (identifier || - token() === 39 /* AsteriskToken */ || + if (identifier || // import id + token() === 39 /* AsteriskToken */ || // import * token() === 17 /* OpenBraceToken */) { importDeclaration.importClause = parseImportClause(identifier, afterImportPos); parseExpected(140 /* FromKeyword */); @@ -17345,7 +17336,7 @@ var ts; JSDocParser.parseJSDocTypeExpression = parseJSDocTypeExpression; function parseIsolatedJSDocComment(content, start, length) { initializeState(content, 5 /* Latest */, /*_syntaxCursor:*/ undefined, 1 /* JS */); - sourceFile = { languageVariant: 0 /* Standard */, text: content }; + sourceFile = { languageVariant: 0 /* Standard */, text: content }; // tslint:disable-line no-object-literal-type-assertion var jsDoc = parseJSDocCommentWorker(start, length); var diagnostics = parseDiagnostics; clearState(); @@ -18093,8 +18084,8 @@ var ts; array._children = undefined; array.pos += delta; array.end += delta; - for (var _i = 0, array_9 = array; _i < array_9.length; _i++) { - var node = array_9[_i]; + for (var _i = 0, array_8 = array; _i < array_8.length; _i++) { + var node = array_8[_i]; visitNode(node); } } @@ -18231,8 +18222,8 @@ var ts; array._children = undefined; // Adjust the pos or end (or both) of the intersecting array accordingly. adjustIntersectingElement(array, changeStart, changeRangeOldEnd, changeRangeNewEnd, delta); - for (var _i = 0, array_10 = array; _i < array_10.length; _i++) { - var node = array_10[_i]; + for (var _i = 0, array_9 = array; _i < array_9.length; _i++) { + var node = array_9[_i]; visitNode(node); } return; @@ -19201,40 +19192,23 @@ var ts; return antecedent; } setFlowNodeReferenced(antecedent); - return { - flags: flags, - expression: expression, - antecedent: antecedent - }; + return { flags: flags, expression: expression, antecedent: antecedent }; } function createFlowSwitchClause(antecedent, switchStatement, clauseStart, clauseEnd) { if (!isNarrowingExpression(switchStatement.expression)) { return antecedent; } setFlowNodeReferenced(antecedent); - return { - flags: 128 /* SwitchClause */, - switchStatement: switchStatement, - clauseStart: clauseStart, - clauseEnd: clauseEnd, - antecedent: antecedent - }; + return { flags: 128 /* SwitchClause */, switchStatement: switchStatement, clauseStart: clauseStart, clauseEnd: clauseEnd, antecedent: antecedent }; } function createFlowAssignment(antecedent, node) { setFlowNodeReferenced(antecedent); - return { - flags: 16 /* Assignment */, - antecedent: antecedent, - node: node - }; + return { flags: 16 /* Assignment */, antecedent: antecedent, node: node }; } function createFlowArrayMutation(antecedent, node) { setFlowNodeReferenced(antecedent); - return { - flags: 256 /* ArrayMutation */, - antecedent: antecedent, - node: node - }; + var res = { flags: 256 /* ArrayMutation */, antecedent: antecedent, node: node }; + return res; } function finishFlowLabel(flow) { var antecedents = flow.antecedents; @@ -20956,7 +20930,6 @@ var ts; } function computeParameter(node, subtreeFlags) { var transformFlags = subtreeFlags; - var modifierFlags = ts.getModifierFlags(node); var name = node.name; var initializer = node.initializer; var dotDotDotToken = node.dotDotDotToken; @@ -20969,7 +20942,7 @@ var ts; transformFlags |= 3 /* AssertTypeScript */; } // If a parameter has an accessibility modifier, then it is TypeScript syntax. - if (modifierFlags & 92 /* ParameterPropertyModifier */) { + if (ts.hasModifier(node, 92 /* ParameterPropertyModifier */)) { transformFlags |= 3 /* AssertTypeScript */ | 262144 /* ContainsParameterPropertyAssignments */; } // parameters with object rest destructuring are ES Next syntax @@ -21006,8 +20979,7 @@ var ts; } function computeClassDeclaration(node, subtreeFlags) { var transformFlags; - var modifierFlags = ts.getModifierFlags(node); - if (modifierFlags & 2 /* Ambient */) { + if (ts.hasModifier(node, 2 /* Ambient */)) { // An ambient declaration is TypeScript syntax. transformFlags = 3 /* AssertTypeScript */; } @@ -21068,7 +21040,10 @@ var ts; } function computeCatchClause(node, subtreeFlags) { var transformFlags = subtreeFlags; - if (node.variableDeclaration && ts.isBindingPattern(node.variableDeclaration.name)) { + if (!node.variableDeclaration) { + transformFlags |= 8 /* AssertESNext */; + } + else if (ts.isBindingPattern(node.variableDeclaration.name)) { transformFlags |= 192 /* AssertES2015 */; } node.transformFlags = transformFlags | 536870912 /* HasComputedFlags */; @@ -21283,10 +21258,9 @@ var ts; } function computeVariableStatement(node, subtreeFlags) { var transformFlags; - var modifierFlags = ts.getModifierFlags(node); var declarationListTransformFlags = node.declarationList.transformFlags; // An ambient declaration is TypeScript syntax. - if (modifierFlags & 2 /* Ambient */) { + if (ts.hasModifier(node, 2 /* Ambient */)) { transformFlags = 3 /* AssertTypeScript */; } else { @@ -21634,6 +21608,176 @@ var ts; ts.forEachChild(child, function (childsChild) { return setParentPointers(child, childsChild); }); } })(ts || (ts = {})); +/** @internal */ +var ts; +(function (ts) { + function createGetSymbolWalker(getRestTypeOfSignature, getReturnTypeOfSignature, getBaseTypes, resolveStructuredTypeMembers, getTypeOfSymbol, getResolvedSymbol, getIndexTypeOfStructuredType, getConstraintFromTypeParameter, getFirstIdentifier) { + return getSymbolWalker; + function getSymbolWalker(accept) { + if (accept === void 0) { accept = function () { return true; }; } + var visitedTypes = ts.createMap(); // Key is id as string + var visitedSymbols = ts.createMap(); // Key is id as string + return { + walkType: function (type) { + visitedTypes.clear(); + visitedSymbols.clear(); + visitType(type); + return { visitedTypes: ts.arrayFrom(visitedTypes.values()), visitedSymbols: ts.arrayFrom(visitedSymbols.values()) }; + }, + walkSymbol: function (symbol) { + visitedTypes.clear(); + visitedSymbols.clear(); + visitSymbol(symbol); + return { visitedTypes: ts.arrayFrom(visitedTypes.values()), visitedSymbols: ts.arrayFrom(visitedSymbols.values()) }; + }, + }; + function visitType(type) { + if (!type) { + return; + } + var typeIdString = type.id.toString(); + if (visitedTypes.has(typeIdString)) { + return; + } + visitedTypes.set(typeIdString, type); + // Reuse visitSymbol to visit the type's symbol, + // but be sure to bail on recuring into the type if accept declines the symbol. + var shouldBail = visitSymbol(type.symbol); + if (shouldBail) + return; + // Visit the type's related types, if any + if (type.flags & 32768 /* Object */) { + var objectType = type; + var objectFlags = objectType.objectFlags; + if (objectFlags & 4 /* Reference */) { + visitTypeReference(type); + } + if (objectFlags & 32 /* Mapped */) { + visitMappedType(type); + } + if (objectFlags & (1 /* Class */ | 2 /* Interface */)) { + visitInterfaceType(type); + } + if (objectFlags & (8 /* Tuple */ | 16 /* Anonymous */)) { + visitObjectType(objectType); + } + } + if (type.flags & 16384 /* TypeParameter */) { + visitTypeParameter(type); + } + if (type.flags & 196608 /* UnionOrIntersection */) { + visitUnionOrIntersectionType(type); + } + if (type.flags & 262144 /* Index */) { + visitIndexType(type); + } + if (type.flags & 524288 /* IndexedAccess */) { + visitIndexedAccessType(type); + } + } + function visitTypeList(types) { + if (!types) { + return; + } + for (var i = 0; i < types.length; i++) { + visitType(types[i]); + } + } + function visitTypeReference(type) { + visitType(type.target); + visitTypeList(type.typeArguments); + } + function visitTypeParameter(type) { + visitType(getConstraintFromTypeParameter(type)); + } + function visitUnionOrIntersectionType(type) { + visitTypeList(type.types); + } + function visitIndexType(type) { + visitType(type.type); + } + function visitIndexedAccessType(type) { + visitType(type.objectType); + visitType(type.indexType); + visitType(type.constraint); + } + function visitMappedType(type) { + visitType(type.typeParameter); + visitType(type.constraintType); + visitType(type.templateType); + visitType(type.modifiersType); + } + function visitSignature(signature) { + if (signature.typePredicate) { + visitType(signature.typePredicate.type); + } + visitTypeList(signature.typeParameters); + for (var _i = 0, _a = signature.parameters; _i < _a.length; _i++) { + var parameter = _a[_i]; + visitSymbol(parameter); + } + visitType(getRestTypeOfSignature(signature)); + visitType(getReturnTypeOfSignature(signature)); + } + function visitInterfaceType(interfaceT) { + visitObjectType(interfaceT); + visitTypeList(interfaceT.typeParameters); + visitTypeList(getBaseTypes(interfaceT)); + visitType(interfaceT.thisType); + } + function visitObjectType(type) { + var stringIndexType = getIndexTypeOfStructuredType(type, 0 /* String */); + visitType(stringIndexType); + var numberIndexType = getIndexTypeOfStructuredType(type, 1 /* Number */); + visitType(numberIndexType); + // The two checks above *should* have already resolved the type (if needed), so this should be cached + var resolved = resolveStructuredTypeMembers(type); + for (var _i = 0, _a = resolved.callSignatures; _i < _a.length; _i++) { + var signature = _a[_i]; + visitSignature(signature); + } + for (var _b = 0, _c = resolved.constructSignatures; _b < _c.length; _b++) { + var signature = _c[_b]; + visitSignature(signature); + } + for (var _d = 0, _e = resolved.properties; _d < _e.length; _d++) { + var p = _e[_d]; + visitSymbol(p); + } + } + function visitSymbol(symbol) { + if (!symbol) { + return; + } + var symbolIdString = ts.getSymbolId(symbol).toString(); + if (visitedSymbols.has(symbolIdString)) { + return; + } + visitedSymbols.set(symbolIdString, symbol); + if (!accept(symbol)) { + return true; + } + var t = getTypeOfSymbol(symbol); + visitType(t); // Should handle members on classes and such + if (symbol.flags & 1952 /* HasExports */) { + symbol.exports.forEach(visitSymbol); + } + ts.forEach(symbol.declarations, function (d) { + // Type queries are too far resolved when we just visit the symbol's type + // (their type resolved directly to the member deeply referenced) + // So to get the intervening symbols, we need to check if there's a type + // query node on any of the symbol's declarations and get symbols there + if (d.type && d.type.kind === 162 /* TypeQuery */) { + var query = d.type; + var entity = getResolvedSymbol(getFirstIdentifier(query.exprName)); + visitSymbol(entity); + } + }); + } + } + } + ts.createGetSymbolWalker = createGetSymbolWalker; +})(ts || (ts = {})); /// /// var ts; @@ -21647,6 +21791,12 @@ var ts; return compilerOptions.traceResolution && host.trace !== undefined; } ts.isTraceEnabled = isTraceEnabled; + function withPackageId(packageId, r) { + return r && { path: r.path, extension: r.ext, packageId: packageId }; + } + function noPackageId(r) { + return withPackageId(/*packageId*/ undefined, r); + } /** * Kinds of file that we are currently looking for. * Typically there is one pass with Extensions.TypeScript, then a second pass with Extensions.JavaScript. @@ -21667,13 +21817,12 @@ var ts; } function createResolvedModuleWithFailedLookupLocations(resolved, isExternalLibraryImport, failedLookupLocations) { return { - resolvedModule: resolved && { resolvedFileName: resolved.path, extension: resolved.extension, isExternalLibraryImport: isExternalLibraryImport }, + resolvedModule: resolved && { resolvedFileName: resolved.path, extension: resolved.extension, isExternalLibraryImport: isExternalLibraryImport, packageId: resolved.packageId }, failedLookupLocations: failedLookupLocations }; } /** Reads from "main" or "types"/"typings" depending on `extensions`. */ - function tryReadPackageJsonFields(readTypes, packageJsonPath, baseDirectory, state) { - var jsonContent = readJson(packageJsonPath, state.host); + function tryReadPackageJsonFields(readTypes, jsonContent, baseDirectory, state) { return readTypes ? tryReadFromField("typings") || tryReadFromField("types") : tryReadFromField("main"); function tryReadFromField(fieldName) { if (!ts.hasProperty(jsonContent, fieldName)) { @@ -21778,7 +21927,9 @@ var ts; } var resolvedTypeReferenceDirective; if (resolved) { - resolved = realpath(resolved, host, traceEnabled); + if (!options.preserveSymlinks) { + resolved = realPath(resolved, host, traceEnabled); + } if (traceEnabled) { trace(host, ts.Diagnostics.Type_reference_directive_0_was_successfully_resolved_to_1_primary_Colon_2, typeReferenceDirectiveName, resolved, primary); } @@ -22182,7 +22333,7 @@ var ts; if (extension !== undefined) { var path_1 = tryFile(candidate, failedLookupLocations, /*onlyRecordFailures*/ false, state); if (path_1 !== undefined) { - return { path: path_1, extension: extension }; + return { path: path_1, extension: extension, packageId: undefined }; } } return loader(extensions, candidate, failedLookupLocations, !directoryProbablyExists(ts.getDirectoryPath(candidate), state.host), state); @@ -22209,7 +22360,7 @@ var ts; function resolveJavaScriptModule(moduleName, initialDir, host) { var _a = nodeModuleNameResolverWorker(moduleName, initialDir, { moduleResolution: ts.ModuleResolutionKind.NodeJs, allowJs: true }, host, /*cache*/ undefined, /*jsOnly*/ true), resolvedModule = _a.resolvedModule, failedLookupLocations = _a.failedLookupLocations; if (!resolvedModule) { - throw new Error("Could not resolve JS module " + moduleName + " starting at " + initialDir + ". Looked in: " + failedLookupLocations.join(", ")); + throw new Error("Could not resolve JS module '" + moduleName + "' starting at '" + initialDir + "'. Looked in: " + failedLookupLocations.join(", ")); } return resolvedModule.resolvedFileName; } @@ -22235,17 +22386,24 @@ var ts; trace(host, ts.Diagnostics.Loading_module_0_from_node_modules_folder_target_file_type_1, moduleName, Extensions[extensions]); } var resolved_1 = loadModuleFromNodeModules(extensions, moduleName, containingDirectory, failedLookupLocations, state, cache); + if (!resolved_1) + return undefined; + var resolvedValue = resolved_1.value; + if (!compilerOptions.preserveSymlinks) { + resolvedValue = resolvedValue && __assign({}, resolved_1.value, { path: realPath(resolved_1.value.path, host, traceEnabled), extension: resolved_1.value.extension }); + } // For node_modules lookups, get the real path so that multiple accesses to an `npm link`-ed module do not create duplicate files. - return resolved_1 && { value: resolved_1.value && { resolved: { path: realpath(resolved_1.value.path, host, traceEnabled), extension: resolved_1.value.extension }, isExternalLibraryImport: true } }; + return { value: resolvedValue && { resolved: resolvedValue, isExternalLibraryImport: true } }; } else { - var candidate = ts.normalizePath(ts.combinePaths(containingDirectory, moduleName)); + var _a = ts.normalizePathAndParts(ts.combinePaths(containingDirectory, moduleName)), candidate = _a.path, parts = _a.parts; var resolved_2 = nodeLoadModuleByRelativeName(extensions, candidate, failedLookupLocations, /*onlyRecordFailures*/ false, state, /*considerPackageJson*/ true); - return resolved_2 && toSearchResult({ resolved: resolved_2, isExternalLibraryImport: false }); + // Treat explicit "node_modules" import as an external library import. + return resolved_2 && toSearchResult({ resolved: resolved_2, isExternalLibraryImport: ts.contains(parts, "node_modules") }); } } } - function realpath(path, host, traceEnabled) { + function realPath(path, host, traceEnabled) { if (!host.realpath) { return path; } @@ -22271,7 +22429,7 @@ var ts; } var resolvedFromFile = loadModuleFromFile(extensions, candidate, failedLookupLocations, onlyRecordFailures, state); if (resolvedFromFile) { - return resolvedFromFile; + return noPackageId(resolvedFromFile); } } if (!onlyRecordFailures) { @@ -22291,6 +22449,9 @@ var ts; return !host.directoryExists || host.directoryExists(directoryName); } ts.directoryProbablyExists = directoryProbablyExists; + function loadModuleFromFileNoPackageId(extensions, candidate, failedLookupLocations, onlyRecordFailures, state) { + return noPackageId(loadModuleFromFile(extensions, candidate, failedLookupLocations, onlyRecordFailures, state)); + } /** * @param {boolean} onlyRecordFailures - if true then function won't try to actually load files but instead record all attempts as failures. This flag is necessary * in cases when we know upfront that all load attempts will fail (because containing folder does not exists) however we still need to record all failed lookup locations. @@ -22329,9 +22490,9 @@ var ts; case Extensions.JavaScript: return tryExtension(".js" /* Js */) || tryExtension(".jsx" /* Jsx */); } - function tryExtension(extension) { - var path = tryFile(candidate + extension, failedLookupLocations, onlyRecordFailures, state); - return path && { path: path, extension: extension }; + function tryExtension(ext) { + var path = tryFile(candidate + ext, failedLookupLocations, onlyRecordFailures, state); + return path && { path: path, ext: ext }; } } /** Return the file if it exists. */ @@ -22355,12 +22516,20 @@ var ts; function loadNodeModuleFromDirectory(extensions, candidate, failedLookupLocations, onlyRecordFailures, state, considerPackageJson) { if (considerPackageJson === void 0) { considerPackageJson = true; } var directoryExists = !onlyRecordFailures && directoryProbablyExists(candidate, state.host); + var packageId; if (considerPackageJson) { var packageJsonPath = pathToPackageJson(candidate); if (directoryExists && state.host.fileExists(packageJsonPath)) { - var fromPackageJson = loadModuleFromPackageJson(packageJsonPath, extensions, candidate, failedLookupLocations, state); + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.Found_package_json_at_0, packageJsonPath); + } + var jsonContent = readJson(packageJsonPath, state.host); + if (typeof jsonContent.name === "string" && typeof jsonContent.version === "string") { + packageId = { name: jsonContent.name, version: jsonContent.version }; + } + var fromPackageJson = loadModuleFromPackageJson(jsonContent, extensions, candidate, failedLookupLocations, state); if (fromPackageJson) { - return fromPackageJson; + return withPackageId(packageId, fromPackageJson); } } else { @@ -22371,13 +22540,10 @@ var ts; failedLookupLocations.push(packageJsonPath); } } - return loadModuleFromFile(extensions, ts.combinePaths(candidate, "index"), failedLookupLocations, !directoryExists, state); + return withPackageId(packageId, loadModuleFromFile(extensions, ts.combinePaths(candidate, "index"), failedLookupLocations, !directoryExists, state)); } - function loadModuleFromPackageJson(packageJsonPath, extensions, candidate, failedLookupLocations, state) { - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.Found_package_json_at_0, packageJsonPath); - } - var file = tryReadPackageJsonFields(extensions !== Extensions.JavaScript, packageJsonPath, candidate, state); + function loadModuleFromPackageJson(jsonContent, extensions, candidate, failedLookupLocations, state) { + var file = tryReadPackageJsonFields(extensions !== Extensions.JavaScript, jsonContent, candidate, state); if (!file) { return undefined; } @@ -22395,12 +22561,17 @@ var ts; // Even if extensions is DtsOnly, we can still look up a .ts file as a result of package.json "types" var nextExtensions = extensions === Extensions.DtsOnly ? Extensions.TypeScript : extensions; // Don't do package.json lookup recursively, because Node.js' package lookup doesn't. - return nodeLoadModuleByRelativeName(nextExtensions, file, failedLookupLocations, onlyRecordFailures, state, /*considerPackageJson*/ false); + var result = nodeLoadModuleByRelativeName(nextExtensions, file, failedLookupLocations, onlyRecordFailures, state, /*considerPackageJson*/ false); + if (result) { + // It won't have a `packageId` set, because we disabled `considerPackageJson`. + ts.Debug.assert(result.packageId === undefined); + return { path: result.path, ext: result.extension }; + } } /** Resolve from an arbitrarily specified file. Return `undefined` if it has an unsupported extension. */ function resolvedIfExtensionMatches(extensions, path) { - var extension = ts.tryGetExtensionFromPath(path); - return extension !== undefined && extensionIsOk(extensions, extension) ? { path: path, extension: extension } : undefined; + var ext = ts.tryGetExtensionFromPath(path); + return ext !== undefined && extensionIsOk(extensions, ext) ? { path: path, ext: ext } : undefined; } /** True if `extension` is one of the supported `extensions`. */ function extensionIsOk(extensions, extension) { @@ -22418,7 +22589,7 @@ var ts; } function loadModuleFromNodeModulesFolder(extensions, moduleName, nodeModulesFolder, nodeModulesFolderExists, failedLookupLocations, state) { var candidate = ts.normalizePath(ts.combinePaths(nodeModulesFolder, moduleName)); - return loadModuleFromFile(extensions, candidate, failedLookupLocations, !nodeModulesFolderExists, state) || + return loadModuleFromFileNoPackageId(extensions, candidate, failedLookupLocations, !nodeModulesFolderExists, state) || loadNodeModuleFromDirectory(extensions, candidate, failedLookupLocations, !nodeModulesFolderExists, state); } function loadModuleFromNodeModules(extensions, moduleName, directory, failedLookupLocations, state, cache) { @@ -22497,7 +22668,7 @@ var ts; if (traceEnabled) { trace(host, ts.Diagnostics.Resolution_for_module_0_was_found_in_cache, moduleName); } - return { value: result.resolvedModule && { path: result.resolvedModule.resolvedFileName, extension: result.resolvedModule.extension } }; + return { value: result.resolvedModule && { path: result.resolvedModule.resolvedFileName, extension: result.resolvedModule.extension, packageId: result.resolvedModule.packageId } }; } } function classicNameResolver(moduleName, containingFile, compilerOptions, host, cache) { @@ -22508,7 +22679,7 @@ var ts; var resolved = tryResolve(Extensions.TypeScript) || tryResolve(Extensions.JavaScript); return createResolvedModuleWithFailedLookupLocations(resolved && resolved.value, /*isExternalLibraryImport*/ false, failedLookupLocations); function tryResolve(extensions) { - var resolvedUsingSettings = tryLoadModuleUsingOptionalResolutionSettings(extensions, moduleName, containingDirectory, loadModuleFromFile, failedLookupLocations, state); + var resolvedUsingSettings = tryLoadModuleUsingOptionalResolutionSettings(extensions, moduleName, containingDirectory, loadModuleFromFileNoPackageId, failedLookupLocations, state); if (resolvedUsingSettings) { return { value: resolvedUsingSettings }; } @@ -22521,7 +22692,7 @@ var ts; return resolutionFromCache; } var searchName = ts.normalizePath(ts.combinePaths(directory, moduleName)); - return toSearchResult(loadModuleFromFile(extensions, searchName, failedLookupLocations, /*onlyRecordFailures*/ false, state)); + return toSearchResult(loadModuleFromFileNoPackageId(extensions, searchName, failedLookupLocations, /*onlyRecordFailures*/ false, state)); }); if (resolved_3) { return resolved_3; @@ -22533,7 +22704,7 @@ var ts; } else { var candidate = ts.normalizePath(ts.combinePaths(containingDirectory, moduleName)); - return toSearchResult(loadModuleFromFile(extensions, candidate, failedLookupLocations, /*onlyRecordFailures*/ false, state)); + return toSearchResult(loadModuleFromFileNoPackageId(extensions, candidate, failedLookupLocations, /*onlyRecordFailures*/ false, state)); } } } @@ -22578,6 +22749,7 @@ var ts; })(ts || (ts = {})); /// /// +/// /* @internal */ var ts; (function (ts) { @@ -22705,6 +22877,9 @@ var ts; node = ts.getParseTreeNode(node, ts.isExportSpecifier); return node ? getExportSpecifierLocalTargetSymbol(node) : undefined; }, + getExportSymbolOfSymbol: function (symbol) { + return getMergedSymbol(symbol.exportSymbol || symbol); + }, getTypeAtLocation: function (node) { node = ts.getParseTreeNode(node); return node ? getTypeOfNode(node) : unknownType; @@ -22767,6 +22942,7 @@ var ts; getEmitResolver: getEmitResolver, getExportsOfModule: getExportsOfModuleAsArray, getExportsAndPropertiesOfModule: getExportsAndPropertiesOfModule, + getSymbolWalker: ts.createGetSymbolWalker(getRestTypeOfSignature, getReturnTypeOfSignature, getBaseTypes, resolveStructuredTypeMembers, getTypeOfSymbol, getResolvedSymbol, getIndexTypeOfStructuredType, getConstraintFromTypeParameter, getFirstIdentifier), getAmbientModules: getAmbientModules, getAllAttributesTypeFromJsxOpeningLikeElement: function (node) { node = ts.getParseTreeNode(node, ts.isJsxOpeningLikeElement); @@ -22789,11 +22965,10 @@ var ts; getSuggestionForNonexistentProperty: function (node, type) { return ts.unescapeLeadingUnderscores(getSuggestionForNonexistentProperty(node, type)); }, getSuggestionForNonexistentSymbol: function (location, name, meaning) { return ts.unescapeLeadingUnderscores(getSuggestionForNonexistentSymbol(location, ts.escapeLeadingUnderscores(name), meaning)); }, getBaseConstraintOfType: getBaseConstraintOfType, - getJsxNamespace: function () { return ts.unescapeLeadingUnderscores(getJsxNamespace()); }, - resolveNameAtLocation: function (location, name, meaning) { - location = ts.getParseTreeNode(location); - return resolveName(location, ts.escapeLeadingUnderscores(name), meaning, /*nameNotFoundMessage*/ undefined, ts.escapeLeadingUnderscores(name)); + resolveName: function (name, location, meaning) { + return resolveName(location, ts.escapeLeadingUnderscores(name), meaning, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined); }, + getJsxNamespace: function () { return ts.unescapeLeadingUnderscores(getJsxNamespace()); }, }; var tupleTypes = []; var unionTypes = ts.createMap(); @@ -23324,12 +23499,17 @@ var ts; // 2. inside a function // 3. inside an instance property initializer, a reference to a non-instance property // 4. inside a static property initializer, a reference to a static method in the same class + // 5. inside a TS export= declaration (since we will move the export statement during emit to avoid TDZ) // or if usage is in a type context: // 1. inside a type query (typeof in type position) - if (usage.parent.kind === 246 /* ExportSpecifier */) { + if (usage.parent.kind === 246 /* ExportSpecifier */ || (usage.parent.kind === 243 /* ExportAssignment */ && usage.parent.isExportEquals)) { // export specifiers do not use the variable, they only make it available for use return true; } + // When resolving symbols for exports, the `usage` location passed in can be the export site directly + if (usage.kind === 243 /* ExportAssignment */ && usage.isExportEquals) { + return true; + } var container = ts.getEnclosingBlockScopeContainer(declaration); return isInTypeQuery(usage) || isUsedInFunctionOrInstanceProperty(usage, declaration, container); function isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage) { @@ -23360,13 +23540,13 @@ var ts; current.parent.kind === 149 /* PropertyDeclaration */ && current.parent.initializer === current; if (initializerOfProperty) { - if (ts.getModifierFlags(current.parent) & 32 /* Static */) { + if (ts.hasModifier(current.parent, 32 /* Static */)) { if (declaration.kind === 151 /* MethodDeclaration */) { return true; } } else { - var isDeclarationInstanceProperty = declaration.kind === 149 /* PropertyDeclaration */ && !(ts.getModifierFlags(declaration) & 32 /* Static */); + var isDeclarationInstanceProperty = declaration.kind === 149 /* PropertyDeclaration */ && !ts.hasModifier(declaration, 32 /* Static */); if (!isDeclarationInstanceProperty || ts.getContainingClass(usage) !== ts.getContainingClass(declaration)) { return true; } @@ -23480,7 +23660,7 @@ var ts; // local variables of the constructor. This effectively means that entities from outer scopes // by the same name as a constructor parameter or local variable are inaccessible // in initializer expressions for instance member variables. - if (ts.isClassLike(location.parent) && !(ts.getModifierFlags(location) & 32 /* Static */)) { + if (ts.isClassLike(location.parent) && !ts.hasModifier(location, 32 /* Static */)) { var ctor = findConstructorDeclaration(location.parent); if (ctor && ctor.locals) { if (lookup(ctor.locals, name, meaning & 107455 /* Value */)) { @@ -23499,7 +23679,7 @@ var ts; result = undefined; break; } - if (lastLocation && ts.getModifierFlags(lastLocation) & 32 /* Static */) { + if (lastLocation && ts.hasModifier(lastLocation, 32 /* Static */)) { // TypeScript 1.0 spec (April 2014): 3.4.1 // The scope of a type parameter extends over the entire declaration with which the type // parameter list is associated, with the exception of static member declarations in classes. @@ -23516,6 +23696,18 @@ var ts; } } break; + case 201 /* ExpressionWithTypeArguments */: + // The type parameters of a class are not in scope in the base class expression. + if (lastLocation === location.expression && location.parent.token === 85 /* ExtendsKeyword */) { + var container = location.parent.parent; + if (ts.isClassLike(container) && (result = lookup(getSymbolOfNode(container).members, name, meaning & 793064 /* Type */))) { + if (nameNotFoundMessage) { + error(errorLocation, ts.Diagnostics.Base_class_expressions_cannot_reference_class_type_parameters); + } + return undefined; + } + } + break; // It is not legal to reference a class's own type parameters from a computed property name that // belongs to the class. For example: // @@ -23585,7 +23777,10 @@ var ts; lastLocation = location; location = location.parent; } - if (result && nameNotFoundMessage && noUnusedIdentifiers) { + // We just climbed up parents looking for the name, meaning that we started in a descendant node of `lastLocation`. + // If `result === lastLocation.symbol`, that means that we are somewhere inside `lastLocation` looking up a name, and resolving to `lastLocation` itself. + // That means that this is a self-reference of `lastLocation`, and shouldn't count this when considering whether `lastLocation` is used. + if (result && nameNotFoundMessage && noUnusedIdentifiers && result !== lastLocation.symbol) { result.isReferenced = true; } if (!result) { @@ -23684,7 +23879,7 @@ var ts; } // No static member is present. // Check if we're in an instance method and look for a relevant instance member. - if (location === container && !(ts.getModifierFlags(location) & 32 /* Static */)) { + if (location === container && !ts.hasModifier(location, 32 /* Static */)) { var instanceType = getDeclaredTypeOfSymbol(classSymbol).thisType; if (getPropertyOfType(instanceType, name)) { error(errorLocation, ts.Diagnostics.Cannot_find_name_0_Did_you_mean_the_instance_member_this_0, diagnosticName(nameArg)); @@ -24130,7 +24325,6 @@ var ts; if (ambientModule) { return ambientModule; } - var isRelative = ts.isExternalModuleNameRelative(moduleReference); var resolvedModule = ts.getResolvedModule(ts.getSourceFileOfNode(location), moduleReference); var resolutionDiagnostic = resolvedModule && ts.getResolutionDiagnostic(compilerOptions, resolvedModule); var sourceFile = resolvedModule && !resolutionDiagnostic && host.getSourceFile(resolvedModule.resolvedFileName); @@ -24152,7 +24346,7 @@ var ts; } } // May be an untyped module. If so, ignore resolutionDiagnostic. - if (!isRelative && resolvedModule && !ts.extensionIsTypeScript(resolvedModule.extension)) { + if (resolvedModule && resolvedModule.isExternalLibraryImport && !ts.extensionIsTypeScript(resolvedModule.extension)) { if (isForAugmentation) { var diag = ts.Diagnostics.Invalid_module_name_in_augmentation_Module_0_resolves_to_an_untyped_module_at_1_which_cannot_be_augmented; error(errorNode, diag, moduleReference, resolvedModule.resolvedFileName); @@ -24186,7 +24380,7 @@ var ts; // An external module with an 'export =' declaration resolves to the target of the 'export =' declaration, // and an external module with no 'export =' declaration resolves to the module itself. function resolveExternalModuleSymbol(moduleSymbol, dontResolveAlias) { - return moduleSymbol && getMergedSymbol(resolveSymbol(moduleSymbol.exports.get("export="), dontResolveAlias)) || moduleSymbol; + return moduleSymbol && getMergedSymbol(resolveSymbol(moduleSymbol.exports.get("export=" /* ExportEquals */), dontResolveAlias)) || moduleSymbol; } // An external module with an 'export =' declaration may be referenced as an ES6 module provided the 'export =' // references a symbol that is at least declared as a module or a variable. The target of the 'export =' may @@ -24199,7 +24393,7 @@ var ts; return symbol; } function hasExportAssignmentSymbol(moduleSymbol) { - return moduleSymbol.exports.get("export=") !== undefined; + return moduleSymbol.exports.get("export=" /* ExportEquals */) !== undefined; } function getExportsOfModuleAsArray(moduleSymbol) { return symbolsToArray(getExportsOfModule(moduleSymbol)); @@ -24461,7 +24655,7 @@ var ts; if (symbolFromSymbolTable.flags & 2097152 /* Alias */ && symbolFromSymbolTable.escapedName !== "export=" && !ts.getDeclarationOfKind(symbolFromSymbolTable, 246 /* ExportSpecifier */)) { - if (!useOnlyExternalAliasing || + if (!useOnlyExternalAliasing || // We can use any type of alias to get the name // Is this external alias, then use it to name ts.forEach(symbolFromSymbolTable.declarations, ts.isExternalModuleImportEqualsDeclaration)) { var resolvedImportedSymbol = resolveAlias(symbolFromSymbolTable); @@ -24526,6 +24720,10 @@ var ts; } return false; } + function isTypeSymbolAccessible(typeSymbol, enclosingDeclaration) { + var access = isSymbolAccessible(typeSymbol, enclosingDeclaration, 793064 /* Type */, /*shouldComputeAliasesToMakeVisible*/ false); + return access.accessibility === 0 /* Accessible */; + } /** * Check if the given symbol in given enclosing declaration is accessible and mark all associated alias to be visible if requested * @@ -24608,7 +24806,7 @@ var ts; // because these kind of aliases can be used to name types in declaration file var anyImportSyntax = getAnyImportSyntax(declaration); if (anyImportSyntax && - !(ts.getModifierFlags(anyImportSyntax) & 1 /* Export */) && + !ts.hasModifier(anyImportSyntax, 1 /* Export */) && // import clause without export isDeclarationVisible(anyImportSyntax.parent)) { // In function "buildTypeDisplay" where we decide whether to write type-alias or serialize types, // we want to just check if type- alias is accessible or not but we don't care about emitting those alias at that time @@ -24817,8 +25015,7 @@ var ts; // Ignore constraint/default when creating a usage (as opposed to declaration) of a type parameter. return ts.createTypeReferenceNode(name, /*typeArguments*/ undefined); } - if (!inTypeAlias && type.aliasSymbol && - isSymbolAccessible(type.aliasSymbol, context.enclosingDeclaration, 793064 /* Type */, /*shouldComputeAliasesToMakeVisible*/ false).accessibility === 0 /* Accessible */) { + if (!inTypeAlias && type.aliasSymbol && isTypeSymbolAccessible(type.aliasSymbol, context.enclosingDeclaration)) { var name = symbolToTypeReferenceName(type.aliasSymbol); var typeArgumentNodes = mapToTypeNodes(type.aliasTypeArguments, context); return ts.createTypeReferenceNode(name, typeArgumentNodes); @@ -24900,10 +25097,10 @@ var ts; return createTypeNodeFromObjectType(type); } function shouldWriteTypeOfFunctionSymbol() { - var isStaticMethodSymbol = !!(symbol.flags & 8192 /* Method */ && - ts.forEach(symbol.declarations, function (declaration) { return ts.getModifierFlags(declaration) & 32 /* Static */; })); + var isStaticMethodSymbol = !!(symbol.flags & 8192 /* Method */) && // typeof static method + ts.some(symbol.declarations, function (declaration) { return ts.hasModifier(declaration, 32 /* Static */); }); var isNonLocalFunctionSymbol = !!(symbol.flags & 16 /* Function */) && - (symbol.parent || + (symbol.parent || // is exported function symbol ts.forEach(symbol.declarations, function (declaration) { return declaration.parent.kind === 265 /* SourceFile */ || declaration.parent.kind === 234 /* ModuleBlock */; })); @@ -24914,10 +25111,8 @@ var ts; } } function createTypeNodeFromObjectType(type) { - if (type.objectFlags & 32 /* Mapped */) { - if (getConstraintTypeFromMappedType(type).flags & (16384 /* TypeParameter */ | 262144 /* Index */)) { - return createMappedTypeNodeFromType(type); - } + if (isGenericMappedType(type)) { + return createMappedTypeNodeFromType(type); } var resolved = resolveStructuredTypeMembers(type); if (!resolved.properties.length && !resolved.stringIndexInfo && !resolved.numberIndexInfo) { @@ -25505,7 +25700,7 @@ var ts; buildSymbolDisplay(type.symbol, writer, enclosingDeclaration, 793064 /* Type */, 0 /* None */, nextFlags); } else if (!(flags & 1024 /* InTypeAlias */) && type.aliasSymbol && - isSymbolAccessible(type.aliasSymbol, enclosingDeclaration, 793064 /* Type */, /*shouldComputeAliasesToMakeVisible*/ false).accessibility === 0 /* Accessible */) { + ((flags & 65536 /* UseAliasDefinedOutsideCurrentScope */) || isTypeSymbolAccessible(type.aliasSymbol, enclosingDeclaration))) { var typeArguments = type.aliasTypeArguments; writeSymbolTypeReference(type.aliasSymbol, typeArguments, 0, ts.length(typeArguments), nextFlags); } @@ -25667,9 +25862,7 @@ var ts; if (!symbolStack) { symbolStack = []; } - var isConstructorObject = type.flags & 32768 /* Object */ && - getObjectFlags(type) & 16 /* Anonymous */ && - type.symbol && type.symbol.flags & 32 /* Class */; + var isConstructorObject = type.objectFlags & 16 /* Anonymous */ && type.symbol && type.symbol.flags & 32 /* Class */; if (isConstructorObject) { writeLiteralType(type, flags); } @@ -25685,17 +25878,17 @@ var ts; writeLiteralType(type, flags); } function shouldWriteTypeOfFunctionSymbol() { - var isStaticMethodSymbol = !!(symbol.flags & 8192 /* Method */ && - ts.forEach(symbol.declarations, function (declaration) { return ts.getModifierFlags(declaration) & 32 /* Static */; })); + var isStaticMethodSymbol = !!(symbol.flags & 8192 /* Method */) && // typeof static method + ts.some(symbol.declarations, function (declaration) { return ts.hasModifier(declaration, 32 /* Static */); }); var isNonLocalFunctionSymbol = !!(symbol.flags & 16 /* Function */) && - (symbol.parent || - ts.forEach(symbol.declarations, function (declaration) { + (symbol.parent || // is exported function symbol + ts.some(symbol.declarations, function (declaration) { return declaration.parent.kind === 265 /* SourceFile */ || declaration.parent.kind === 234 /* ModuleBlock */; })); if (isStaticMethodSymbol || isNonLocalFunctionSymbol) { // typeof is allowed only for static/non local functions - return !!(flags & 4 /* UseTypeOfFunction */) || - (ts.contains(symbolStack, symbol)); // it is type of the symbol uses itself recursively + return !!(flags & 4 /* UseTypeOfFunction */) || // use typeof if format flags specify it + ts.contains(symbolStack, symbol); // it is type of the symbol uses itself recursively } } } @@ -25733,11 +25926,9 @@ var ts; return false; } function writeLiteralType(type, flags) { - if (type.objectFlags & 32 /* Mapped */) { - if (getConstraintTypeFromMappedType(type).flags & (16384 /* TypeParameter */ | 262144 /* Index */)) { - writeMappedType(type); - return; - } + if (isGenericMappedType(type)) { + writeMappedType(type); + return; } var resolved = resolveStructuredTypeMembers(type); if (!resolved.properties.length && !resolved.stringIndexInfo && !resolved.numberIndexInfo) { @@ -26113,7 +26304,7 @@ var ts; case 154 /* SetAccessor */: case 151 /* MethodDeclaration */: case 150 /* MethodSignature */: - if (ts.getModifierFlags(node) & (8 /* Private */ | 16 /* Protected */)) { + if (ts.hasModifier(node, 8 /* Private */ | 16 /* Protected */)) { // Private/protected properties/methods are not visible return false; } @@ -26910,8 +27101,8 @@ var ts; // The function allocates a new array if the input type parameter set is undefined, but otherwise it modifies the set // in-place and returns the same array. function appendTypeParameters(typeParameters, declarations) { - for (var _i = 0, declarations_3 = declarations; _i < declarations_3.length; _i++) { - var declaration = declarations_3[_i]; + for (var _i = 0, declarations_2 = declarations; _i < declarations_2.length; _i++) { + var declaration = declarations_2[_i]; var tp = getDeclaredTypeOfTypeParameter(getSymbolOfNode(declaration)); if (!typeParameters) { typeParameters = [tp]; @@ -27055,7 +27246,7 @@ var ts; return type.resolvedBaseTypes; } function resolveBaseTypesOfClass(type) { - type.resolvedBaseTypes = type.resolvedBaseTypes || ts.emptyArray; + type.resolvedBaseTypes = ts.emptyArray; var baseConstructorType = getApparentType(getBaseConstructorTypeOfClass(type)); if (!(baseConstructorType.flags & (32768 /* Object */ | 131072 /* Intersection */ | 1 /* Any */))) { return; @@ -27104,12 +27295,7 @@ var ts; error(valueDecl, ts.Diagnostics.Type_0_recursively_references_itself_as_a_base_type, typeToString(type, /*enclosingDeclaration*/ undefined, 1 /* WriteArrayAsGenericType */)); return; } - if (type.resolvedBaseTypes === ts.emptyArray) { - type.resolvedBaseTypes = [baseType]; - } - else { - type.resolvedBaseTypes.push(baseType); - } + type.resolvedBaseTypes = [baseType]; } function areAllOuterTypeParametersApplied(type) { // An unapplied type parameter has its symbol still the same as the matching argument symbol. @@ -27221,7 +27407,9 @@ var ts; if (!pushTypeResolution(symbol, 2 /* DeclaredType */)) { return unknownType; } - var declaration = ts.findDeclaration(symbol, function (d) { return d.kind === 283 /* JSDocTypedefTag */ || d.kind === 231 /* TypeAliasDeclaration */; }); + var declaration = ts.find(symbol.declarations, function (d) { + return d.kind === 283 /* JSDocTypedefTag */ || d.kind === 231 /* TypeAliasDeclaration */; + }); var type = getTypeFromTypeNode(declaration.kind === 283 /* JSDocTypedefTag */ ? declaration.typeExpression : declaration.type); if (popTypeResolution()) { var typeParameters = getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol); @@ -27753,17 +27941,12 @@ var ts; else { // Combinations of function, class, enum and module var members = emptySymbols; - var constructSignatures = ts.emptyArray; var stringIndexInfo = undefined; if (symbol.exports) { members = getExportsOfSymbol(symbol); } if (symbol.flags & 32 /* Class */) { var classType = getDeclaredTypeOfClassOrInterface(symbol); - constructSignatures = getSignaturesOfSymbol(symbol.members.get("__constructor" /* Constructor */)); - if (!constructSignatures.length) { - constructSignatures = getDefaultConstructSignatures(classType); - } var baseConstructorType = getBaseConstructorTypeOfClass(classType); if (baseConstructorType.flags & (32768 /* Object */ | 131072 /* Intersection */ | 540672 /* TypeVariable */)) { members = ts.createSymbolTable(getNamedMembers(members)); @@ -27774,7 +27957,7 @@ var ts; } } var numberIndexInfo = symbol.flags & 384 /* Enum */ ? enumNumberIndexInfo : undefined; - setStructuredTypeMembers(type, members, ts.emptyArray, constructSignatures, stringIndexInfo, numberIndexInfo); + setStructuredTypeMembers(type, members, ts.emptyArray, ts.emptyArray, stringIndexInfo, numberIndexInfo); // We resolve the members before computing the signatures because a signature may use // typeof with a qualified name expression that circularly references the type we are // in the process of resolving (see issue #6072). The temporarily empty signature list @@ -27782,6 +27965,15 @@ var ts; if (symbol.flags & (16 /* Function */ | 8192 /* Method */)) { type.callSignatures = getSignaturesOfSymbol(symbol); } + // And likewise for construct signatures for classes + if (symbol.flags & 32 /* Class */) { + var classType = getDeclaredTypeOfClassOrInterface(symbol); + var constructSignatures = getSignaturesOfSymbol(symbol.members.get("__constructor" /* Constructor */)); + if (!constructSignatures.length) { + constructSignatures = getDefaultConstructSignatures(classType); + } + type.constructSignatures = constructSignatures; + } } } /** Resolve the members of a mapped type { [P in K]: T } */ @@ -27883,8 +28075,7 @@ var ts; return getObjectFlags(type) & 32 /* Mapped */ && !!type.declaration.questionToken; } function isGenericMappedType(type) { - return getObjectFlags(type) & 32 /* Mapped */ && - maybeTypeOfKind(getConstraintTypeFromMappedType(type), 540672 /* TypeVariable */ | 262144 /* Index */); + return getObjectFlags(type) & 32 /* Mapped */ && isGenericIndexType(getConstraintTypeFromMappedType(type)); } function resolveStructuredTypeMembers(type) { if (!type.members) { @@ -27990,6 +28181,10 @@ var ts; return hasNonCircularBaseConstraint(typeParameter) ? getConstraintFromTypeParameter(typeParameter) : undefined; } function getConstraintOfIndexedAccess(type) { + var transformed = getTransformedIndexedAccessType(type); + if (transformed) { + return transformed; + } var baseObjectType = getBaseConstraintOfType(type.objectType); var baseIndexType = getBaseConstraintOfType(type.indexType); return baseObjectType || baseIndexType ? getIndexedAccessType(baseObjectType || type.objectType, baseIndexType || type.indexType) : undefined; @@ -28057,11 +28252,18 @@ var ts; return stringType; } if (t.flags & 524288 /* IndexedAccess */) { + var transformed = getTransformedIndexedAccessType(t); + if (transformed) { + return getBaseConstraint(transformed); + } var baseObjectType = getBaseConstraint(t.objectType); var baseIndexType = getBaseConstraint(t.indexType); var baseIndexedAccess = baseObjectType && baseIndexType ? getIndexedAccessType(baseObjectType, baseIndexType) : undefined; return baseIndexedAccess && baseIndexedAccess !== unknownType ? getBaseConstraint(baseIndexedAccess) : undefined; } + if (isGenericMappedType(t)) { + return emptyObjectType; + } return t; } } @@ -28608,6 +28810,9 @@ var ts; } return signature.resolvedReturnType; } + function isResolvingReturnTypeOfSignature(signature) { + return !signature.resolvedReturnType && findResolutionCycleStartIndex(signature, 3 /* ResolvedReturnType */) >= 0; + } function getRestTypeOfSignature(signature) { if (signature.hasRestParameter) { var type = getTypeOfSymbol(ts.lastOrUndefined(signature.parameters)); @@ -28680,7 +28885,7 @@ var ts; function getIndexInfoOfSymbol(symbol, kind) { var declaration = getIndexDeclarationOfSymbol(symbol, kind); if (declaration) { - return createIndexInfo(declaration.type ? getTypeFromTypeNode(declaration.type) : anyType, (ts.getModifierFlags(declaration) & 64 /* Readonly */) !== 0, declaration); + return createIndexInfo(declaration.type ? getTypeFromTypeNode(declaration.type) : anyType, ts.hasModifier(declaration, 64 /* Readonly */), declaration); } return undefined; } @@ -28978,8 +29183,8 @@ var ts; function getTypeOfGlobalSymbol(symbol, arity) { function getTypeDeclaration(symbol) { var declarations = symbol.declarations; - for (var _i = 0, declarations_4 = declarations; _i < declarations_4.length; _i++) { - var declaration = declarations_4[_i]; + for (var _i = 0, declarations_3 = declarations; _i < declarations_3.length; _i++) { + var declaration = declarations_3[_i]; switch (declaration.kind) { case 229 /* ClassDeclaration */: case 230 /* InterfaceDeclaration */: @@ -29475,17 +29680,16 @@ var ts; return getTypeOfSymbol(prop); } } - if (isTypeAnyOrAllConstituentTypesHaveKind(indexType, 262178 /* StringLike */ | 84 /* NumberLike */ | 512 /* ESSymbol */)) { + if (!(indexType.flags & 6144 /* Nullable */) && isTypeAssignableToKind(indexType, 262178 /* StringLike */ | 84 /* NumberLike */ | 512 /* ESSymbol */)) { if (isTypeAny(objectType)) { return anyType; } - var indexInfo = isTypeAnyOrAllConstituentTypesHaveKind(indexType, 84 /* NumberLike */) && getIndexInfoOfType(objectType, 1 /* Number */) || + var indexInfo = isTypeAssignableToKind(indexType, 84 /* NumberLike */) && getIndexInfoOfType(objectType, 1 /* Number */) || getIndexInfoOfType(objectType, 0 /* String */) || undefined; if (indexInfo) { if (accessExpression && indexInfo.isReadonly && (ts.isAssignmentTarget(accessExpression) || ts.isDeleteTarget(accessExpression))) { error(accessExpression, ts.Diagnostics.Index_signature_in_type_0_only_permits_reading, typeToString(objectType)); - return unknownType; } return indexInfo.type; } @@ -29517,35 +29721,84 @@ var ts; return anyType; } function getIndexedAccessForMappedType(type, indexType, accessNode) { - var accessExpression = accessNode && accessNode.kind === 180 /* ElementAccessExpression */ ? accessNode : undefined; - if (accessExpression && ts.isAssignmentTarget(accessExpression) && type.declaration.readonlyToken) { - error(accessExpression, ts.Diagnostics.Index_signature_in_type_0_only_permits_reading, typeToString(type)); - return unknownType; + if (accessNode) { + // Check if the index type is assignable to 'keyof T' for the object type. + if (!isTypeAssignableTo(indexType, getIndexType(type))) { + error(accessNode, ts.Diagnostics.Type_0_cannot_be_used_to_index_type_1, typeToString(indexType), typeToString(type)); + return unknownType; + } + if (accessNode.kind === 180 /* ElementAccessExpression */ && ts.isAssignmentTarget(accessNode) && type.declaration.readonlyToken) { + error(accessNode, ts.Diagnostics.Index_signature_in_type_0_only_permits_reading, typeToString(type)); + } } var mapper = createTypeMapper([getTypeParameterFromMappedType(type)], [indexType]); var templateMapper = type.mapper ? combineTypeMappers(type.mapper, mapper) : mapper; return instantiateType(getTemplateTypeFromMappedType(type), templateMapper); } + function isGenericObjectType(type) { + return type.flags & 540672 /* TypeVariable */ ? true : + getObjectFlags(type) & 32 /* Mapped */ ? isGenericIndexType(getConstraintTypeFromMappedType(type)) : + type.flags & 196608 /* UnionOrIntersection */ ? ts.forEach(type.types, isGenericObjectType) : + false; + } + function isGenericIndexType(type) { + return type.flags & (540672 /* TypeVariable */ | 262144 /* Index */) ? true : + type.flags & 196608 /* UnionOrIntersection */ ? ts.forEach(type.types, isGenericIndexType) : + false; + } + // Return true if the given type is a non-generic object type with a string index signature and no + // other members. + function isStringIndexOnlyType(type) { + if (type.flags & 32768 /* Object */ && !isGenericMappedType(type)) { + var t = resolveStructuredTypeMembers(type); + return t.properties.length === 0 && + t.callSignatures.length === 0 && t.constructSignatures.length === 0 && + t.stringIndexInfo && !t.numberIndexInfo; + } + return false; + } + // Given an indexed access type T[K], if T is an intersection containing one or more generic types and one or + // more object types with only a string index signature, e.g. '(U & V & { [x: string]: D })[K]', return a + // transformed type of the form '(U & V)[K] | D'. This allows us to properly reason about higher order indexed + // access types with default property values as expressed by D. + function getTransformedIndexedAccessType(type) { + var objectType = type.objectType; + if (objectType.flags & 131072 /* Intersection */ && isGenericObjectType(objectType) && ts.some(objectType.types, isStringIndexOnlyType)) { + var regularTypes = []; + var stringIndexTypes = []; + for (var _i = 0, _a = objectType.types; _i < _a.length; _i++) { + var t = _a[_i]; + if (isStringIndexOnlyType(t)) { + stringIndexTypes.push(getIndexTypeOfType(t, 0 /* String */)); + } + else { + regularTypes.push(t); + } + } + return getUnionType([ + getIndexedAccessType(getIntersectionType(regularTypes), type.indexType), + getIntersectionType(stringIndexTypes) + ]); + } + return undefined; + } function getIndexedAccessType(objectType, indexType, accessNode) { - // If the index type is generic, if the object type is generic and doesn't originate in an expression, - // or if the object type is a mapped type with a generic constraint, we are performing a higher-order - // index access where we cannot meaningfully access the properties of the object type. Note that for a - // generic T and a non-generic K, we eagerly resolve T[K] if it originates in an expression. This is to - // preserve backwards compatibility. For example, an element access 'this["foo"]' has always been resolved - // eagerly using the constraint type of 'this' at the given location. - if (maybeTypeOfKind(indexType, 540672 /* TypeVariable */ | 262144 /* Index */) || - maybeTypeOfKind(objectType, 540672 /* TypeVariable */) && !(accessNode && accessNode.kind === 180 /* ElementAccessExpression */) || - isGenericMappedType(objectType)) { + // If the object type is a mapped type { [P in K]: E }, where K is generic, we instantiate E using a mapper + // that substitutes the index type for P. For example, for an index access { [P in K]: Box }[X], we + // construct the type Box. + if (isGenericMappedType(objectType)) { + return getIndexedAccessForMappedType(objectType, indexType, accessNode); + } + // Otherwise, if the index type is generic, or if the object type is generic and doesn't originate in an + // expression, we are performing a higher-order index access where we cannot meaningfully access the properties + // of the object type. Note that for a generic T and a non-generic K, we eagerly resolve T[K] if it originates + // in an expression. This is to preserve backwards compatibility. For example, an element access 'this["foo"]' + // has always been resolved eagerly using the constraint type of 'this' at the given location. + if (isGenericIndexType(indexType) || !(accessNode && accessNode.kind === 180 /* ElementAccessExpression */) && isGenericObjectType(objectType)) { if (objectType.flags & 1 /* Any */) { return objectType; } - // If the object type is a mapped type { [P in K]: E }, we instantiate E using a mapper that substitutes - // the index type for P. For example, for an index access { [P in K]: Box }[X], we construct the - // type Box. - if (isGenericMappedType(objectType)) { - return getIndexedAccessForMappedType(objectType, indexType, accessNode); - } - // Otherwise we defer the operation by creating an indexed access type. + // Defer the operation by creating an indexed access type. var id = objectType.id + "," + indexType.id; var type = indexedAccessTypes.get(id); if (!type) { @@ -29759,7 +30012,7 @@ var ts; var container = ts.getThisContainer(node, /*includeArrowFunctions*/ false); var parent = container && container.parent; if (parent && (ts.isClassLike(parent) || parent.kind === 230 /* InterfaceDeclaration */)) { - if (!(ts.getModifierFlags(container) & 32 /* Static */) && + if (!ts.hasModifier(container, 32 /* Static */) && (container.kind !== 152 /* Constructor */ || ts.isNodeDescendantOf(node, container.body))) { return getDeclaredTypeOfClassOrInterface(getSymbolOfNode(parent)).thisType; } @@ -29912,7 +30165,7 @@ var ts; } function cloneTypeMapper(mapper) { return mapper && isInferenceContext(mapper) ? - createInferenceContext(mapper.signature, mapper.flags | 2 /* NoDefault */, mapper.inferences) : + createInferenceContext(mapper.signature, mapper.flags | 2 /* NoDefault */, mapper.compareTypes, mapper.inferences) : mapper; } function identityMapper(type) { @@ -30222,16 +30475,16 @@ var ts; if (ts.forEach(node.parameters, function (p) { return !ts.getEffectiveTypeAnnotationNode(p); })) { return true; } - // For arrow functions we now know we're not context sensitive. - if (node.kind === 187 /* ArrowFunction */) { - return false; + if (node.kind !== 187 /* ArrowFunction */) { + // If the first parameter is not an explicit 'this' parameter, then the function has + // an implicit 'this' parameter which is subject to contextual typing. + var parameter = ts.firstOrUndefined(node.parameters); + if (!(parameter && ts.parameterIsThisKeyword(parameter))) { + return true; + } } - // If the first parameter is not an explicit 'this' parameter, then the function has - // an implicit 'this' parameter which is subject to contextual typing. Otherwise we - // know that all parameters (including 'this') have type annotations and nothing is - // subject to contextual typing. - var parameter = ts.firstOrUndefined(node.parameters); - return !(parameter && ts.parameterIsThisKeyword(parameter)); + // TODO(anhans): A block should be context-sensitive if it has a context-sensitive return value. + return node.body.kind === 207 /* Block */ ? false : isContextSensitive(node.body); } function isContextSensitiveFunctionOrObjectLiteralMethod(func) { return (isFunctionExpressionOrArrowFunction(func) || ts.isObjectLiteralMethod(func)) && isContextSensitiveFunctionLikeDeclaration(func); @@ -30317,7 +30570,7 @@ var ts; return 0 /* False */; } if (source.typeParameters) { - source = instantiateSignatureInContextOf(source, target); + source = instantiateSignatureInContextOf(source, target, /*contextualMapper*/ undefined, compareTypes); } var result = -1 /* True */; var sourceThisType = getThisTypeOfSignature(source); @@ -30376,7 +30629,7 @@ var ts; // The following block preserves behavior forbidding boolean returning functions from being assignable to type guard returning functions if (target.typePredicate) { if (source.typePredicate) { - result &= compareTypePredicateRelatedTo(source.typePredicate, target.typePredicate, reportErrors, errorReporter, compareTypes); + result &= compareTypePredicateRelatedTo(source.typePredicate, target.typePredicate, source.declaration, target.declaration, reportErrors, errorReporter, compareTypes); } else if (ts.isIdentifierTypePredicate(target.typePredicate)) { if (reportErrors) { @@ -30395,7 +30648,7 @@ var ts; } return result; } - function compareTypePredicateRelatedTo(source, target, reportErrors, errorReporter, compareTypes) { + function compareTypePredicateRelatedTo(source, target, sourceDeclaration, targetDeclaration, reportErrors, errorReporter, compareTypes) { if (source.kind !== target.kind) { if (reportErrors) { errorReporter(ts.Diagnostics.A_this_based_type_guard_is_not_compatible_with_a_parameter_based_type_guard); @@ -30404,11 +30657,13 @@ var ts; return 0 /* False */; } if (source.kind === 1 /* Identifier */) { - var sourceIdentifierPredicate = source; - var targetIdentifierPredicate = target; - if (sourceIdentifierPredicate.parameterIndex !== targetIdentifierPredicate.parameterIndex) { + var sourcePredicate = source; + var targetPredicate = target; + var sourceIndex = sourcePredicate.parameterIndex - (ts.getThisParameter(sourceDeclaration) ? 1 : 0); + var targetIndex = targetPredicate.parameterIndex - (ts.getThisParameter(targetDeclaration) ? 1 : 0); + if (sourceIndex !== targetIndex) { if (reportErrors) { - errorReporter(ts.Diagnostics.Parameter_0_is_not_in_the_same_position_as_parameter_1, sourceIdentifierPredicate.parameterName, targetIdentifierPredicate.parameterName); + errorReporter(ts.Diagnostics.Parameter_0_is_not_in_the_same_position_as_parameter_1, sourcePredicate.parameterName, targetPredicate.parameterName); errorReporter(ts.Diagnostics.Type_predicate_0_is_not_assignable_to_1, typePredicateToString(source), typePredicateToString(target)); } return 0 /* False */; @@ -30560,8 +30815,7 @@ var ts; return true; } if (source.flags & 32768 /* Object */ && target.flags & 32768 /* Object */) { - var id = relation !== identityRelation || source.id < target.id ? source.id + "," + target.id : target.id + "," + source.id; - var related = relation.get(id); + var related = relation.get(getRelationKey(source, target, relation)); if (related !== undefined) { return related === 1 /* Succeeded */; } @@ -30697,11 +30951,21 @@ var ts; !(target.flags & 65536 /* Union */) && !isIntersectionConstituent && source !== globalObjectType && - getPropertiesOfType(source).length > 0 && + (getPropertiesOfType(source).length > 0 || + getSignaturesOfType(source, 0 /* Call */).length > 0 || + getSignaturesOfType(source, 1 /* Construct */).length > 0) && isWeakType(target) && !hasCommonProperties(source, target)) { if (reportErrors) { - reportError(ts.Diagnostics.Type_0_has_no_properties_in_common_with_type_1, typeToString(source), typeToString(target)); + var calls = getSignaturesOfType(source, 0 /* Call */); + var constructs = getSignaturesOfType(source, 1 /* Construct */); + if (calls.length > 0 && isRelatedTo(getReturnTypeOfSignature(calls[0]), target, /*reportErrors*/ false) || + constructs.length > 0 && isRelatedTo(getReturnTypeOfSignature(constructs[0]), target, /*reportErrors*/ false)) { + reportError(ts.Diagnostics.Value_of_type_0_has_no_properties_in_common_with_type_1_Did_you_mean_to_call_it, typeToString(source), typeToString(target)); + } + else { + reportError(ts.Diagnostics.Type_0_has_no_properties_in_common_with_type_1, typeToString(source), typeToString(target)); + } } return 0 /* False */; } @@ -30929,7 +31193,7 @@ var ts; if (overflow) { return 0 /* False */; } - var id = relation !== identityRelation || source.id < target.id ? source.id + "," + target.id : target.id + "," + source.id; + var id = getRelationKey(source, target, relation); var related = relation.get(id); if (related !== undefined) { if (reportErrors && related === 2 /* Failed */) { @@ -31411,6 +31675,11 @@ var ts; if (sourceInfo) { return indexInfoRelatedTo(sourceInfo, targetInfo, reportErrors); } + if (isGenericMappedType(source)) { + // A generic mapped type { [P in K]: T } is related to an index signature { [x: string]: U } + // if T is related to U. + return kind === 0 /* String */ && isRelatedTo(getTemplateTypeFromMappedType(source), targetInfo.type, reportErrors); + } if (isObjectLiteralType(source)) { var related = -1 /* True */; if (kind === 0 /* String */) { @@ -31444,8 +31713,8 @@ var ts; if (!sourceSignature.declaration || !targetSignature.declaration) { return true; } - var sourceAccessibility = ts.getModifierFlags(sourceSignature.declaration) & 24 /* NonPublicAccessibilityModifier */; - var targetAccessibility = ts.getModifierFlags(targetSignature.declaration) & 24 /* NonPublicAccessibilityModifier */; + var sourceAccessibility = ts.getSelectedModifierFlags(sourceSignature.declaration, 24 /* NonPublicAccessibilityModifier */); + var targetAccessibility = ts.getSelectedModifierFlags(targetSignature.declaration, 24 /* NonPublicAccessibilityModifier */); // A public, protected and private signature is assignable to a private signature. if (targetAccessibility === 8 /* Private */) { return true; @@ -31464,6 +31733,50 @@ var ts; return false; } } + function isUnconstrainedTypeParameter(type) { + return type.flags & 16384 /* TypeParameter */ && !getConstraintFromTypeParameter(type); + } + function isTypeReferenceWithGenericArguments(type) { + return getObjectFlags(type) & 4 /* Reference */ && ts.some(type.typeArguments, isUnconstrainedTypeParameter); + } + /** + * getTypeReferenceId(A) returns "111=0-12=1" + * where A.id=111 and number.id=12 + */ + function getTypeReferenceId(type, typeParameters) { + var result = "" + type.target.id; + for (var _i = 0, _a = type.typeArguments; _i < _a.length; _i++) { + var t = _a[_i]; + if (isUnconstrainedTypeParameter(t)) { + var index = ts.indexOf(typeParameters, t); + if (index < 0) { + index = typeParameters.length; + typeParameters.push(t); + } + result += "=" + index; + } + else { + result += "-" + t.id; + } + } + return result; + } + /** + * To improve caching, the relation key for two generic types uses the target's id plus ids of the type parameters. + * For other cases, the types ids are used. + */ + function getRelationKey(source, target, relation) { + if (relation === identityRelation && source.id > target.id) { + var temp = source; + source = target; + target = temp; + } + if (isTypeReferenceWithGenericArguments(source) && isTypeReferenceWithGenericArguments(target)) { + var typeParameters = []; + return getTypeReferenceId(source, typeParameters) + "," + getTypeReferenceId(target, typeParameters); + } + return source.id + "," + target.id; + } // Invoke the callback for each underlying property symbol of the given symbol and return the first // value that isn't undefined. function forEachProperty(prop, callback) { @@ -31509,7 +31822,7 @@ var ts; var symbol = type.symbol; if (symbol && symbol.flags & 32 /* Class */) { var declaration = getClassLikeDeclarationOfSymbol(symbol); - if (declaration && ts.getModifierFlags(declaration) & 128 /* Abstract */) { + if (declaration && ts.hasModifier(declaration, 128 /* Abstract */)) { return true; } } @@ -31960,13 +32273,14 @@ var ts; callback(getTypeAtPosition(source, i), getTypeAtPosition(target, i)); } } - function createInferenceContext(signature, flags, baseInferences) { + function createInferenceContext(signature, flags, compareTypes, baseInferences) { var inferences = baseInferences ? ts.map(baseInferences, cloneInferenceInfo) : ts.map(signature.typeParameters, createInferenceInfo); var context = mapper; context.mappedTypes = signature.typeParameters; context.signature = signature; context.inferences = inferences; context.flags = flags; + context.compareTypes = compareTypes || compareTypesAssignable; return context; function mapper(t) { for (var i = 0; i < inferences.length; i++) { @@ -32061,6 +32375,19 @@ var ts; return inference.candidates && getUnionType(inference.candidates, /*subtypeReduction*/ true); } } + function isPossiblyAssignableTo(source, target) { + var properties = getPropertiesOfObjectType(target); + for (var _i = 0, properties_5 = properties; _i < properties_5.length; _i++) { + var targetProp = properties_5[_i]; + if (!(targetProp.flags & (16777216 /* Optional */ | 4194304 /* Prototype */))) { + var sourceProp = getPropertyOfObjectType(source, targetProp.escapedName); + if (!sourceProp) { + return false; + } + } + } + return true; + } function inferTypes(inferences, originalSource, originalTarget, priority) { if (priority === void 0) { priority = 0; } var symbolStack; @@ -32257,15 +32584,19 @@ var ts; return; } } - inferFromProperties(source, target); - inferFromSignatures(source, target, 0 /* Call */); - inferFromSignatures(source, target, 1 /* Construct */); - inferFromIndexTypes(source, target); + // Infer from the members of source and target only if the two types are possibly related. We check + // in both directions because we may be inferring for a co-variant or a contra-variant position. + if (isPossiblyAssignableTo(source, target) || isPossiblyAssignableTo(target, source)) { + inferFromProperties(source, target); + inferFromSignatures(source, target, 0 /* Call */); + inferFromSignatures(source, target, 1 /* Construct */); + inferFromIndexTypes(source, target); + } } function inferFromProperties(source, target) { var properties = getPropertiesOfObjectType(target); - for (var _i = 0, properties_5 = properties; _i < properties_5.length; _i++) { - var targetProp = properties_5[_i]; + for (var _i = 0, properties_6 = properties; _i < properties_6.length; _i++) { + var targetProp = properties_6[_i]; var sourceProp = getPropertyOfObjectType(source, targetProp.escapedName); if (sourceProp) { inferFromTypes(getTypeOfSymbol(sourceProp), getTypeOfSymbol(targetProp)); @@ -32382,7 +32713,7 @@ var ts; var constraint = getConstraintOfTypeParameter(context.signature.typeParameters[index]); if (constraint) { var instantiatedConstraint = instantiateType(constraint, context); - if (!isTypeAssignableTo(inferredType, getTypeWithThisArgument(instantiatedConstraint, inferredType))) { + if (!context.compareTypes(inferredType, getTypeWithThisArgument(instantiatedConstraint, inferredType))) { inference.inferredType = inferredType = instantiatedConstraint; } } @@ -32440,16 +32771,6 @@ var ts; } return undefined; } - function getLeftmostIdentifierOrThis(node) { - switch (node.kind) { - case 71 /* Identifier */: - case 99 /* ThisKeyword */: - return node; - case 179 /* PropertyAccessExpression */: - return getLeftmostIdentifierOrThis(node.expression); - } - return undefined; - } function getBindingElementNameText(element) { if (element.parent.kind === 174 /* ObjectBindingPattern */) { var name = element.propertyName || element.name; @@ -32975,7 +33296,7 @@ var ts; parent.parent.operatorToken.kind === 58 /* EqualsToken */ && parent.parent.left === parent && !ts.isAssignmentTarget(parent.parent) && - isTypeAnyOrAllConstituentTypesHaveKind(getTypeOfExpression(parent.argumentExpression), 84 /* NumberLike */ | 2048 /* Undefined */); + isTypeAssignableToKind(getTypeOfExpression(parent.argumentExpression), 84 /* NumberLike */); return isLengthPushOrUnshift || isElementAssignment; } function maybeTypePredicateCall(node) { @@ -33143,7 +33464,7 @@ var ts; } else { var indexType = getTypeOfExpression(node.left.argumentExpression); - if (isTypeAnyOrAllConstituentTypesHaveKind(indexType, 84 /* NumberLike */ | 2048 /* Undefined */)) { + if (isTypeAssignableToKind(indexType, 84 /* NumberLike */)) { evolvedType_1 = addEvolvingArrayElementType(evolvedType_1, node.right); } } @@ -33978,7 +34299,7 @@ var ts; break; case 149 /* PropertyDeclaration */: case 148 /* PropertySignature */: - if (ts.getModifierFlags(container) & 32 /* Static */) { + if (ts.hasModifier(container, 32 /* Static */)) { error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_static_property_initializer); // do not return here so in case if lexical this is captured - it will be reflected in flags on NodeLinks } @@ -34081,7 +34402,7 @@ var ts; if (!isCallExpression && container.kind === 152 /* Constructor */) { checkThisBeforeSuper(node, container, ts.Diagnostics.super_must_be_called_before_accessing_a_property_of_super_in_the_constructor_of_a_derived_class); } - if ((ts.getModifierFlags(container) & 32 /* Static */) || isCallExpression) { + if (ts.hasModifier(container, 32 /* Static */) || isCallExpression) { nodeCheckFlag = 512 /* SuperStatic */; } else { @@ -34144,7 +34465,7 @@ var ts; // This helper creates an object with a "value" property that wraps the `super` property or indexed access for both get and set. // This is required for destructuring assignments, as a call expression cannot be used as the target of a destructuring assignment // while a property access can. - if (container.kind === 151 /* MethodDeclaration */ && ts.getModifierFlags(container) & 256 /* Async */) { + if (container.kind === 151 /* MethodDeclaration */ && ts.hasModifier(container, 256 /* Async */)) { if (ts.isSuperProperty(node.parent) && ts.isAssignmentTarget(node.parent)) { getNodeLinks(container).flags |= 4096 /* AsyncMethodWithSuperBinding */; } @@ -34202,7 +34523,7 @@ var ts; // - In a static member function or static member accessor // topmost container must be something that is directly nested in the class declaration\object literal expression if (ts.isClassLike(container.parent) || container.parent.kind === 178 /* ObjectLiteralExpression */) { - if (ts.getModifierFlags(container) & 32 /* Static */) { + if (ts.hasModifier(container, 32 /* Static */)) { return container.kind === 151 /* MethodDeclaration */ || container.kind === 150 /* MethodSignature */ || container.kind === 153 /* GetAccessor */ || @@ -34414,7 +34735,7 @@ var ts; // Otherwise, if the containing function is contextually typed by a function type with exactly one call signature // and that call signature is non-generic, return statements are contextually typed by the return type of the signature var signature = getContextualSignatureForFunctionLikeDeclaration(functionDecl); - if (signature) { + if (signature && !isResolvingReturnTypeOfSignature(signature)) { return getReturnTypeOfSignature(signature); } return undefined; @@ -34543,12 +34864,12 @@ var ts; } if (ts.isJsxAttribute(node.parent)) { // JSX expression is in JSX attribute - return getTypeOfPropertyOfType(attributesType, node.parent.name.escapedText); + return getTypeOfPropertyOfContextualType(attributesType, node.parent.name.escapedText); } else if (node.parent.kind === 249 /* JsxElement */) { // JSX expression is in children of JSX Element, we will look for an "children" atttribute (we get the name from JSX.ElementAttributesProperty) var jsxChildrenPropertyName = getJsxElementChildrenPropertyname(); - return jsxChildrenPropertyName && jsxChildrenPropertyName !== "" ? getTypeOfPropertyOfType(attributesType, jsxChildrenPropertyName) : anyType; + return jsxChildrenPropertyName && jsxChildrenPropertyName !== "" ? getTypeOfPropertyOfContextualType(attributesType, jsxChildrenPropertyName) : anyType; } else { // JSX expression is in JSX spread attribute @@ -34564,7 +34885,7 @@ var ts; if (!attributesType || isTypeAny(attributesType)) { return undefined; } - return getTypeOfPropertyOfType(attributesType, attribute.name.escapedText); + return getTypeOfPropertyOfContextualType(attributesType, attribute.name.escapedText); } else { return attributesType; @@ -34832,10 +35153,7 @@ var ts; function isNumericComputedName(name) { // It seems odd to consider an expression of type Any to result in a numeric name, // but this behavior is consistent with checkIndexedAccess - return isTypeAnyOrAllConstituentTypesHaveKind(checkComputedPropertyName(name), 84 /* NumberLike */); - } - function isTypeAnyOrAllConstituentTypesHaveKind(type, kind) { - return isTypeAny(type) || isTypeOfKind(type, kind); + return isTypeAssignableToKind(checkComputedPropertyName(name), 84 /* NumberLike */); } function isInfinityOrNaNString(name) { return name === "Infinity" || name === "-Infinity" || name === "NaN"; @@ -34870,7 +35188,9 @@ var ts; links.resolvedType = checkExpression(node.expression); // This will allow types number, string, symbol or any. It will also allow enums, the unknown // type, and any union of these types (like string | number). - if (!isTypeAnyOrAllConstituentTypesHaveKind(links.resolvedType, 84 /* NumberLike */ | 262178 /* StringLike */ | 512 /* ESSymbol */)) { + if (links.resolvedType.flags & 6144 /* Nullable */ || + !isTypeAssignableToKind(links.resolvedType, 262178 /* StringLike */ | 84 /* NumberLike */ | 512 /* ESSymbol */) && + !isTypeAssignableTo(links.resolvedType, getUnionType([stringType, numberType, esSymbolType]))) { error(node, ts.Diagnostics.A_computed_property_name_must_be_of_type_string_number_symbol_or_any); } else { @@ -35484,9 +35804,7 @@ var ts; * emptyObjectType if there is no "prop" in the element instance type */ function resolveCustomJsxElementAttributesType(openingLikeElement, shouldIncludeAllStatelessAttributesType, elementType, elementClassType) { - if (!elementType) { - elementType = checkExpression(openingLikeElement.tagName); - } + if (elementType === void 0) { elementType = checkExpression(openingLikeElement.tagName); } if (elementType.flags & 65536 /* Union */) { var types = elementType.types; return getUnionType(types.map(function (type) { @@ -35607,11 +35925,12 @@ var ts; */ function getCustomJsxElementAttributesType(node, shouldIncludeAllStatelessAttributesType) { var links = getNodeLinks(node); - if (!links.resolvedJsxElementAttributesType) { + var linkLocation = shouldIncludeAllStatelessAttributesType ? "resolvedJsxElementAllAttributesType" : "resolvedJsxElementAttributesType"; + if (!links[linkLocation]) { var elemClassType = getJsxGlobalElementClassType(); - return links.resolvedJsxElementAttributesType = resolveCustomJsxElementAttributesType(node, shouldIncludeAllStatelessAttributesType, /*elementType*/ undefined, elemClassType); + return links[linkLocation] = resolveCustomJsxElementAttributesType(node, shouldIncludeAllStatelessAttributesType, /*elementType*/ undefined, elemClassType); } - return links.resolvedJsxElementAttributesType; + return links[linkLocation]; } /** * Get all possible attributes type, especially from an overload stateless function component, of the given JSX opening-like element. @@ -35933,9 +36252,12 @@ var ts; } var prop = getPropertyOfType(apparentType, right.escapedText); if (!prop) { - var stringIndexType = getIndexTypeOfType(apparentType, 0 /* String */); - if (stringIndexType) { - return stringIndexType; + var indexInfo = getIndexInfoOfType(apparentType, 0 /* String */); + if (indexInfo && indexInfo.type) { + if (indexInfo.isReadonly && (ts.isAssignmentTarget(node) || ts.isDeleteTarget(node))) { + error(node, ts.Diagnostics.Index_signature_in_type_0_only_permits_reading, typeToString(apparentType)); + } + return indexInfo.type; } if (right.escapedText && !checkAndReportErrorForExtendingInterface(node)) { reportNonexistentProperty(right, type.flags & 16384 /* TypeParameter */ && type.isThisType ? apparentType : type); @@ -36084,7 +36406,7 @@ var ts; if (prop && noUnusedIdentifiers && (prop.flags & 106500 /* ClassMember */) && - prop.valueDeclaration && (ts.getModifierFlags(prop.valueDeclaration) & 8 /* Private */)) { + prop.valueDeclaration && ts.hasModifier(prop.valueDeclaration, 8 /* Private */)) { if (ts.getCheckFlags(prop) & 1 /* Instantiated */) { getSymbolLinks(prop).target.isReferenced = true; } @@ -36407,8 +36729,8 @@ var ts; return undefined; } // Instantiate a generic signature in the context of a non-generic signature (section 3.8.5 in TypeScript spec) - function instantiateSignatureInContextOf(signature, contextualSignature, contextualMapper) { - var context = createInferenceContext(signature, 1 /* InferUnionTypes */); + function instantiateSignatureInContextOf(signature, contextualSignature, contextualMapper, compareTypes) { + var context = createInferenceContext(signature, 1 /* InferUnionTypes */, compareTypes); forEachMatchingParameterType(contextualSignature, signature, function (source, target) { // Type parameters from outer context referenced by source type are fixed by instantiation of the source type inferTypes(context.inferences, instantiateType(source, contextualMapper || identityMapper), target); @@ -36780,7 +37102,7 @@ var ts; return getLiteralType(element.name.text); case 144 /* ComputedPropertyName */: var nameType = checkComputedPropertyName(element.name); - if (isTypeOfKind(nameType, 512 /* ESSymbol */)) { + if (isTypeAssignableToKind(nameType, 512 /* ESSymbol */)) { return nameType; } else { @@ -36921,9 +37243,10 @@ var ts; // // For a decorator, no arguments are susceptible to contextual typing due to the fact // decorators are applied to a declaration by the emitter, and not to an expression. + var isSingleNonGenericCandidate = candidates.length === 1 && !candidates[0].typeParameters; var excludeArgument; var excludeCount = 0; - if (!isDecorator) { + if (!isDecorator && !isSingleNonGenericCandidate) { // We do not need to call `getEffectiveArgumentCount` here as it only // applies when calculating the number of arguments for a decorator. for (var i = isTaggedTemplate ? 1 : 0; i < args.length; i++) { @@ -37068,6 +37391,17 @@ var ts; if (signatureHelpTrailingComma === void 0) { signatureHelpTrailingComma = false; } candidateForArgumentError = undefined; candidateForTypeArgumentError = undefined; + if (isSingleNonGenericCandidate) { + var candidate = candidates[0]; + if (!hasCorrectArity(node, args, candidate, signatureHelpTrailingComma)) { + return undefined; + } + if (!checkApplicableSignature(node, args, candidate, relation, excludeArgument, /*reportErrors*/ false)) { + candidateForArgumentError = candidate; + return undefined; + } + return candidate; + } for (var candidateIndex = 0; candidateIndex < candidates.length; candidateIndex++) { var originalCandidate = candidates[candidateIndex]; if (!hasCorrectArity(node, args, originalCandidate, signatureHelpTrailingComma)) { @@ -37230,7 +37564,7 @@ var ts; // In the case of a merged class-module or class-interface declaration, // only the class declaration node will have the Abstract flag set. var valueDecl = expressionType.symbol && getClassLikeDeclarationOfSymbol(expressionType.symbol); - if (valueDecl && ts.getModifierFlags(valueDecl) & 128 /* Abstract */) { + if (valueDecl && ts.hasModifier(valueDecl, 128 /* Abstract */)) { error(node, ts.Diagnostics.Cannot_create_an_instance_of_the_abstract_class_0, ts.declarationNameToString(ts.getNameOfDeclaration(valueDecl))); return resolveErrorCall(node); } @@ -37277,9 +37611,9 @@ var ts; return true; } var declaration = signature.declaration; - var modifiers = ts.getModifierFlags(declaration); + var modifiers = ts.getSelectedModifierFlags(declaration, 24 /* NonPublicAccessibilityModifier */); // Public constructor is accessible. - if (!(modifiers & 24 /* NonPublicAccessibilityModifier */)) { + if (!modifiers) { return true; } var declaringClassDeclaration = getClassLikeDeclarationOfSymbol(declaration.parent.symbol); @@ -37488,7 +37822,7 @@ var ts; */ function checkCallExpression(node) { // Grammar checking; stop grammar-checking if checkGrammarTypeArguments return true - checkGrammarTypeArguments(node, node.typeArguments) || checkGrammarArguments(node, node.arguments); + checkGrammarTypeArguments(node, node.typeArguments) || checkGrammarArguments(node.arguments); var signature = getResolvedSignature(node); if (node.expression.kind === 97 /* SuperKeyword */) { return voidType; @@ -37528,7 +37862,7 @@ var ts; } function checkImportCallExpression(node) { // Check grammar of dynamic import - checkGrammarArguments(node, node.arguments) || checkGrammarImportCallExpression(node); + checkGrammarArguments(node.arguments) || checkGrammarImportCallExpression(node); if (node.arguments.length === 0) { return createPromiseReturnType(node, anyType); } @@ -37546,11 +37880,33 @@ var ts; if (moduleSymbol) { var esModuleSymbol = resolveESModuleSymbol(moduleSymbol, specifier, /*dontRecursivelyResolve*/ true); if (esModuleSymbol) { - return createPromiseReturnType(node, getTypeOfSymbol(esModuleSymbol)); + return createPromiseReturnType(node, getTypeWithSyntheticDefaultImportType(getTypeOfSymbol(esModuleSymbol), esModuleSymbol)); } } return createPromiseReturnType(node, anyType); } + function getTypeWithSyntheticDefaultImportType(type, symbol) { + if (allowSyntheticDefaultImports && type && type !== unknownType) { + var synthType = type; + if (!synthType.syntheticType) { + if (!getPropertyOfType(type, "default" /* Default */)) { + var memberTable = ts.createSymbolTable(); + var newSymbol = createSymbol(2097152 /* Alias */, "default" /* Default */); + newSymbol.target = resolveSymbol(symbol); + memberTable.set("default" /* Default */, newSymbol); + var anonymousSymbol = createSymbol(2048 /* TypeLiteral */, "__type" /* Type */); + var defaultContainingObject = createAnonymousType(anonymousSymbol, memberTable, ts.emptyArray, ts.emptyArray, /*stringIndexInfo*/ undefined, /*numberIndexInfo*/ undefined); + anonymousSymbol.type = defaultContainingObject; + synthType.syntheticType = getIntersectionType([type, defaultContainingObject]); + } + else { + synthType.syntheticType = type; + } + } + return synthType.syntheticType; + } + return type; + } function isCommonJsRequire(node) { if (!ts.isRequireCall(node, /*checkArgumentIsStringLiteral*/ true)) { return false; @@ -37675,15 +38031,15 @@ var ts; } // When contextual typing assigns a type to a parameter that contains a binding pattern, we also need to push // the destructured type into the contained binding elements. - function assignBindingElementTypes(node) { - if (ts.isBindingPattern(node.name)) { - for (var _i = 0, _a = node.name.elements; _i < _a.length; _i++) { - var element = _a[_i]; - if (!ts.isOmittedExpression(element)) { - if (element.name.kind === 71 /* Identifier */) { - getSymbolLinks(getSymbolOfNode(element)).type = getTypeForBindingElement(element); - } - assignBindingElementTypes(element); + function assignBindingElementTypes(pattern) { + for (var _i = 0, _a = pattern.elements; _i < _a.length; _i++) { + var element = _a[_i]; + if (!ts.isOmittedExpression(element)) { + if (element.name.kind === 71 /* Identifier */) { + getSymbolLinks(getSymbolOfNode(element)).type = getTypeForBindingElement(element); + } + else { + assignBindingElementTypes(element.name); } } } @@ -37692,13 +38048,14 @@ var ts; var links = getSymbolLinks(parameter); if (!links.type) { links.type = contextualType; - var name = ts.getNameOfDeclaration(parameter.valueDeclaration); - // if inference didn't come up with anything but {}, fall back to the binding pattern if present. - if (links.type === emptyObjectType && - (name.kind === 174 /* ObjectBindingPattern */ || name.kind === 175 /* ArrayBindingPattern */)) { - links.type = getTypeFromBindingPattern(name); + var decl = parameter.valueDeclaration; + if (decl.name.kind !== 71 /* Identifier */) { + // if inference didn't come up with anything but {}, fall back to the binding pattern if present. + if (links.type === emptyObjectType) { + links.type = getTypeFromBindingPattern(decl.name); + } + assignBindingElementTypes(decl.name); } - assignBindingElementTypes(parameter.valueDeclaration); } } function createPromiseType(promisedType) { @@ -37934,16 +38291,16 @@ var ts; } function checkFunctionExpressionOrObjectLiteralMethod(node, checkMode) { ts.Debug.assert(node.kind !== 151 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); - // Grammar checking - var hasGrammarError = checkGrammarFunctionLikeDeclaration(node); - if (!hasGrammarError && node.kind === 186 /* FunctionExpression */) { - checkGrammarForGenerator(node); - } // The identityMapper object is used to indicate that function expressions are wildcards if (checkMode === 1 /* SkipContextSensitive */ && isContextSensitive(node)) { checkNodeDeferred(node); return anyFunctionType; } + // Grammar checking + var hasGrammarError = checkGrammarFunctionLikeDeclaration(node); + if (!hasGrammarError && node.kind === 186 /* FunctionExpression */) { + checkGrammarForGenerator(node); + } var links = getNodeLinks(node); var type = getTypeOfSymbol(node.symbol); // Check if function expression is contextually typed and assign parameter types if so. @@ -38028,7 +38385,7 @@ var ts; } } function checkArithmeticOperandType(operand, type, diagnostic) { - if (!isTypeAnyOrAllConstituentTypesHaveKind(type, 84 /* NumberLike */)) { + if (!isTypeAssignableToKind(type, 84 /* NumberLike */)) { error(operand, diagnostic); return false; } @@ -38129,8 +38486,13 @@ var ts; if (operandType === silentNeverType) { return silentNeverType; } - if (node.operator === 38 /* MinusToken */ && node.operand.kind === 8 /* NumericLiteral */) { - return getFreshTypeOfLiteralType(getLiteralType(-node.operand.text)); + if (node.operand.kind === 8 /* NumericLiteral */) { + if (node.operator === 38 /* MinusToken */) { + return getFreshTypeOfLiteralType(getLiteralType(-node.operand.text)); + } + else if (node.operator === 37 /* PlusToken */) { + return getFreshTypeOfLiteralType(getLiteralType(+node.operand.text)); + } } switch (node.operator) { case 37 /* PlusToken */: @@ -38186,33 +38548,22 @@ var ts; } return false; } - // Return true if type is of the given kind. A union type is of a given kind if all constituent types - // are of the given kind. An intersection type is of a given kind if at least one constituent type is - // of the given kind. - function isTypeOfKind(type, kind) { - if (type.flags & kind) { + function isTypeAssignableToKind(source, kind, strict) { + if (source.flags & kind) { return true; } - if (type.flags & 65536 /* Union */) { - var types = type.types; - for (var _i = 0, types_18 = types; _i < types_18.length; _i++) { - var t = types_18[_i]; - if (!isTypeOfKind(t, kind)) { - return false; - } - } - return true; + if (strict && source.flags & (1 /* Any */ | 1024 /* Void */ | 2048 /* Undefined */ | 4096 /* Null */)) { + return false; } - if (type.flags & 131072 /* Intersection */) { - var types = type.types; - for (var _a = 0, types_19 = types; _a < types_19.length; _a++) { - var t = types_19[_a]; - if (isTypeOfKind(t, kind)) { - return true; - } - } - } - return false; + return (kind & 84 /* NumberLike */ && isTypeAssignableTo(source, numberType)) || + (kind & 262178 /* StringLike */ && isTypeAssignableTo(source, stringType)) || + (kind & 136 /* BooleanLike */ && isTypeAssignableTo(source, booleanType)) || + (kind & 1024 /* Void */ && isTypeAssignableTo(source, voidType)) || + (kind & 8192 /* Never */ && isTypeAssignableTo(source, neverType)) || + (kind & 4096 /* Null */ && isTypeAssignableTo(source, nullType)) || + (kind & 2048 /* Undefined */ && isTypeAssignableTo(source, undefinedType)) || + (kind & 512 /* ESSymbol */ && isTypeAssignableTo(source, esSymbolType)) || + (kind & 16777216 /* NonPrimitive */ && isTypeAssignableTo(source, nonPrimitiveType)); } function isConstEnumObjectType(type) { return getObjectFlags(type) & 16 /* Anonymous */ && type.symbol && isConstEnumSymbol(type.symbol); @@ -38229,7 +38580,7 @@ var ts; // and the right operand to be of type Any, a subtype of the 'Function' interface type, or have a call or construct signature. // The result is always of the Boolean primitive type. // NOTE: do not raise error if leftType is unknown as related error was already reported - if (isTypeOfKind(leftType, 8190 /* Primitive */)) { + if (!isTypeAny(leftType) && isTypeAssignableToKind(leftType, 8190 /* Primitive */)) { error(left, ts.Diagnostics.The_left_hand_side_of_an_instanceof_expression_must_be_of_type_any_an_object_type_or_a_type_parameter); } // NOTE: do not raise error if right is unknown as related error was already reported @@ -38251,18 +38602,18 @@ var ts; // The in operator requires the left operand to be of type Any, the String primitive type, or the Number primitive type, // and the right operand to be of type Any, an object type, or a type parameter type. // The result is always of the Boolean primitive type. - if (!(isTypeComparableTo(leftType, stringType) || isTypeOfKind(leftType, 84 /* NumberLike */ | 512 /* ESSymbol */))) { + if (!(isTypeComparableTo(leftType, stringType) || isTypeAssignableToKind(leftType, 84 /* NumberLike */ | 512 /* ESSymbol */))) { error(left, ts.Diagnostics.The_left_hand_side_of_an_in_expression_must_be_of_type_any_string_number_or_symbol); } - if (!isTypeAnyOrAllConstituentTypesHaveKind(rightType, 32768 /* Object */ | 540672 /* TypeVariable */ | 16777216 /* NonPrimitive */)) { + if (!isTypeAssignableToKind(rightType, 16777216 /* NonPrimitive */ | 540672 /* TypeVariable */)) { error(right, ts.Diagnostics.The_right_hand_side_of_an_in_expression_must_be_of_type_any_an_object_type_or_a_type_parameter); } return booleanType; } function checkObjectLiteralAssignment(node, sourceType) { var properties = node.properties; - for (var _i = 0, properties_6 = properties; _i < properties_6.length; _i++) { - var p = properties_6[_i]; + for (var _i = 0, properties_7 = properties; _i < properties_7.length; _i++) { + var p = properties_7[_i]; checkObjectLiteralDestructuringPropertyAssignment(sourceType, p, properties); } return sourceType; @@ -38541,30 +38892,28 @@ var ts; if (leftType === silentNeverType || rightType === silentNeverType) { return silentNeverType; } - if (!isTypeOfKind(leftType, 1 /* Any */ | 262178 /* StringLike */) && !isTypeOfKind(rightType, 1 /* Any */ | 262178 /* StringLike */)) { + if (!isTypeAssignableToKind(leftType, 262178 /* StringLike */) && !isTypeAssignableToKind(rightType, 262178 /* StringLike */)) { leftType = checkNonNullType(leftType, left); rightType = checkNonNullType(rightType, right); } var resultType = void 0; - if (isTypeOfKind(leftType, 84 /* NumberLike */) && isTypeOfKind(rightType, 84 /* NumberLike */)) { + if (isTypeAssignableToKind(leftType, 84 /* NumberLike */, /*strict*/ true) && isTypeAssignableToKind(rightType, 84 /* NumberLike */, /*strict*/ true)) { // Operands of an enum type are treated as having the primitive type Number. // If both operands are of the Number primitive type, the result is of the Number primitive type. resultType = numberType; } - else { - if (isTypeOfKind(leftType, 262178 /* StringLike */) || isTypeOfKind(rightType, 262178 /* StringLike */)) { - // If one or both operands are of the String primitive type, the result is of the String primitive type. - resultType = stringType; - } - else if (isTypeAny(leftType) || isTypeAny(rightType)) { - // Otherwise, the result is of type Any. - // NOTE: unknown type here denotes error type. Old compiler treated this case as any type so do we. - resultType = leftType === unknownType || rightType === unknownType ? unknownType : anyType; - } - // Symbols are not allowed at all in arithmetic expressions - if (resultType && !checkForDisallowedESSymbolOperand(operator)) { - return resultType; - } + else if (isTypeAssignableToKind(leftType, 262178 /* StringLike */, /*strict*/ true) || isTypeAssignableToKind(rightType, 262178 /* StringLike */, /*strict*/ true)) { + // If one or both operands are of the String primitive type, the result is of the String primitive type. + resultType = stringType; + } + else if (isTypeAny(leftType) || isTypeAny(rightType)) { + // Otherwise, the result is of type Any. + // NOTE: unknown type here denotes error type. Old compiler treated this case as any type so do we. + resultType = leftType === unknownType || rightType === unknownType ? unknownType : anyType; + } + // Symbols are not allowed at all in arithmetic expressions + if (resultType && !checkForDisallowedESSymbolOperand(operator)) { + return resultType; } if (!resultType) { reportOperatorError(); @@ -38749,13 +39098,12 @@ var ts; return getBestChoiceType(type1, type2); } function checkLiteralExpression(node) { - if (node.kind === 8 /* NumericLiteral */) { - checkGrammarNumericLiteral(node); - } switch (node.kind) { + case 13 /* NoSubstitutionTemplateLiteral */: case 9 /* StringLiteral */: return getFreshTypeOfLiteralType(getLiteralType(node.text)); case 8 /* NumericLiteral */: + checkGrammarNumericLiteral(node); return getFreshTypeOfLiteralType(getLiteralType(+node.text)); case 101 /* TrueKeyword */: return trueType; @@ -38951,6 +39299,7 @@ var ts; return checkSuperExpression(node); case 95 /* NullKeyword */: return nullWideningType; + case 13 /* NoSubstitutionTemplateLiteral */: case 9 /* StringLiteral */: case 8 /* NumericLiteral */: case 101 /* TrueKeyword */: @@ -38958,8 +39307,6 @@ var ts; return checkLiteralExpression(node); case 196 /* TemplateExpression */: return checkTemplateExpression(node); - case 13 /* NoSubstitutionTemplateLiteral */: - return stringType; case 12 /* RegularExpressionLiteral */: return globalRegExpType; case 177 /* ArrayLiteralExpression */: @@ -39058,7 +39405,7 @@ var ts; checkGrammarDecorators(node) || checkGrammarModifiers(node); checkVariableLikeDeclaration(node); var func = ts.getContainingFunction(node); - if (ts.getModifierFlags(node) & 92 /* ParameterPropertyModifier */) { + if (ts.hasModifier(node, 92 /* ParameterPropertyModifier */)) { func = ts.getContainingFunction(node); if (!(func.kind === 152 /* Constructor */ && ts.nodeIsPresent(func.body))) { error(node, ts.Diagnostics.A_parameter_property_is_only_allowed_in_a_constructor_implementation); @@ -39264,7 +39611,7 @@ var ts; } } else { - var isStatic = ts.getModifierFlags(member) & 32 /* Static */; + var isStatic = ts.hasModifier(member, 32 /* Static */); var names = isStatic ? staticNames : instanceNames; var memberName = member.name && ts.getPropertyNameForPropertyNameNode(member.name); if (memberName) { @@ -39320,7 +39667,7 @@ var ts; for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; var memberNameNode = member.name; - var isStatic = ts.getModifierFlags(member) & 32 /* Static */; + var isStatic = ts.hasModifier(member, 32 /* Static */); if (isStatic && memberNameNode) { var memberName = ts.getPropertyNameForPropertyNameNode(memberNameNode); switch (memberName) { @@ -39418,7 +39765,7 @@ var ts; checkFunctionOrMethodDeclaration(node); // Abstract methods cannot have an implementation. // Extra checks are to avoid reporting multiple errors relating to the "abstractness" of the node. - if (ts.getModifierFlags(node) & 128 /* Abstract */ && node.body) { + if (ts.hasModifier(node, 128 /* Abstract */) && node.body) { error(node, ts.Diagnostics.Method_0_cannot_have_an_implementation_because_it_is_marked_abstract, ts.declarationNameToString(node.name)); } } @@ -39458,17 +39805,9 @@ var ts; } return ts.forEachChild(n, containsSuperCall); } - function markThisReferencesAsErrors(n) { - if (n.kind === 99 /* ThisKeyword */) { - error(n, ts.Diagnostics.this_cannot_be_referenced_in_current_location); - } - else if (n.kind !== 186 /* FunctionExpression */ && n.kind !== 228 /* FunctionDeclaration */) { - ts.forEachChild(n, markThisReferencesAsErrors); - } - } function isInstancePropertyWithInitializer(n) { return n.kind === 149 /* PropertyDeclaration */ && - !(ts.getModifierFlags(n) & 32 /* Static */) && + !ts.hasModifier(n, 32 /* Static */) && !!n.initializer; } // TS 1.0 spec (April 2014): 8.3.2 @@ -39488,8 +39827,8 @@ var ts; // - The containing class is a derived class. // - The constructor declares parameter properties // or the containing class declares instance member variables with initializers. - var superCallShouldBeFirst = ts.forEach(node.parent.members, isInstancePropertyWithInitializer) || - ts.forEach(node.parameters, function (p) { return ts.getModifierFlags(p) & 92 /* ParameterPropertyModifier */; }); + var superCallShouldBeFirst = ts.some(node.parent.members, isInstancePropertyWithInitializer) || + ts.some(node.parameters, function (p) { return ts.hasModifier(p, 92 /* ParameterPropertyModifier */); }); // Skip past any prologue directives to find the first statement // to ensure that it was a super call. if (superCallShouldBeFirst) { @@ -39540,10 +39879,12 @@ var ts; var otherKind = node.kind === 153 /* GetAccessor */ ? 154 /* SetAccessor */ : 153 /* GetAccessor */; var otherAccessor = ts.getDeclarationOfKind(node.symbol, otherKind); if (otherAccessor) { - if ((ts.getModifierFlags(node) & 28 /* AccessibilityModifier */) !== (ts.getModifierFlags(otherAccessor) & 28 /* AccessibilityModifier */)) { + var nodeFlags = ts.getModifierFlags(node); + var otherFlags = ts.getModifierFlags(otherAccessor); + if ((nodeFlags & 28 /* AccessibilityModifier */) !== (otherFlags & 28 /* AccessibilityModifier */)) { error(node.name, ts.Diagnostics.Getter_and_setter_accessors_do_not_agree_in_visibility); } - if (ts.hasModifier(node, 128 /* Abstract */) !== ts.hasModifier(otherAccessor, 128 /* Abstract */)) { + if ((nodeFlags & 128 /* Abstract */) !== (otherFlags & 128 /* Abstract */)) { error(node.name, ts.Diagnostics.Accessors_must_both_be_abstract_or_non_abstract); } // TypeScript 1.0 spec (April 2014): 4.5 @@ -39591,7 +39932,7 @@ var ts; function checkTypeReferenceNode(node) { checkGrammarTypeArguments(node, node.typeArguments); if (node.kind === 159 /* TypeReference */ && node.typeName.jsdocDotPos !== undefined && !ts.isInJavaScriptFile(node) && !ts.isInJSDoc(node)) { - grammarErrorAtPos(ts.getSourceFileOfNode(node), node.typeName.jsdocDotPos, 1, ts.Diagnostics.JSDoc_types_can_only_be_used_inside_documentation_comments); + grammarErrorAtPos(node, node.typeName.jsdocDotPos, 1, ts.Diagnostics.JSDoc_types_can_only_be_used_inside_documentation_comments); } var type = getTypeFromTypeReference(node); if (type !== unknownType) { @@ -39600,7 +39941,17 @@ var ts; ts.forEach(node.typeArguments, checkSourceElement); if (produceDiagnostics) { var symbol = getNodeLinks(node).resolvedSymbol; - var typeParameters = symbol.flags & 524288 /* TypeAlias */ ? getSymbolLinks(symbol).typeParameters : type.target.localTypeParameters; + if (!symbol) { + // There is no resolved symbol cached if the type resolved to a builtin + // via JSDoc type reference resolution (eg, Boolean became boolean), none + // of which are generic when they have no associated symbol + error(node, ts.Diagnostics.Type_0_is_not_generic, typeToString(type)); + return; + } + var typeParameters = symbol.flags & 524288 /* TypeAlias */ && getSymbolLinks(symbol).typeParameters; + if (!typeParameters && getObjectFlags(type) & 4 /* Reference */) { + typeParameters = type.target.localTypeParameters; + } checkTypeArgumentConstraints(typeParameters, node.typeArguments); } } @@ -39645,18 +39996,17 @@ var ts; if (isTypeAssignableTo(indexType, getIndexType(objectType))) { return type; } - // Check if we're indexing with a numeric type and the object type is a generic - // type with a constraint that has a numeric index signature. - if (maybeTypeOfKind(objectType, 540672 /* TypeVariable */) && isTypeOfKind(indexType, 84 /* NumberLike */)) { - var constraint = getBaseConstraintOfType(objectType); - if (constraint && getIndexInfoOfType(constraint, 1 /* Number */)) { - return type; - } + // Check if we're indexing with a numeric type and if either object or index types + // is a generic type with a constraint that has a numeric index signature. + if (getIndexInfoOfType(getApparentType(objectType), 1 /* Number */) && isTypeAssignableToKind(indexType, 84 /* NumberLike */)) { + return type; } error(accessNode, ts.Diagnostics.Type_0_cannot_be_used_to_index_type_1, typeToString(indexType), typeToString(objectType)); return type; } function checkIndexedAccessType(node) { + checkSourceElement(node.objectType); + checkSourceElement(node.indexType); checkIndexedAccessIndexType(getTypeFromIndexedAccessTypeNode(node), node); } function checkMappedType(node) { @@ -39667,7 +40017,7 @@ var ts; checkTypeAssignableTo(constraintType, stringType, node.typeParameter.constraint); } function isPrivateWithinAmbient(node) { - return (ts.getModifierFlags(node) & 8 /* Private */) && ts.isInAmbientContext(node); + return ts.hasModifier(node, 8 /* Private */) && ts.isInAmbientContext(node); } function getEffectiveDeclarationFlags(n, flagsToCheck) { var flags = ts.getCombinedModifierFlags(n); @@ -39767,13 +40117,13 @@ var ts; (ts.isComputedPropertyName(node.name) && ts.isComputedPropertyName(subsequentName) || !ts.isComputedPropertyName(node.name) && !ts.isComputedPropertyName(subsequentName) && ts.getEscapedTextOfIdentifierOrLiteral(node.name) === ts.getEscapedTextOfIdentifierOrLiteral(subsequentName))) { var reportError = (node.kind === 151 /* MethodDeclaration */ || node.kind === 150 /* MethodSignature */) && - (ts.getModifierFlags(node) & 32 /* Static */) !== (ts.getModifierFlags(subsequentNode) & 32 /* Static */); + ts.hasModifier(node, 32 /* Static */) !== ts.hasModifier(subsequentNode, 32 /* Static */); // we can get here in two cases // 1. mixed static and instance class members // 2. something with the same name was defined before the set of overloads that prevents them from merging // here we'll report error only for the first case since for second we should already report error in binder if (reportError) { - var diagnostic = ts.getModifierFlags(node) & 32 /* Static */ ? ts.Diagnostics.Function_overload_must_be_static : ts.Diagnostics.Function_overload_must_not_be_static; + var diagnostic = ts.hasModifier(node, 32 /* Static */) ? ts.Diagnostics.Function_overload_must_be_static : ts.Diagnostics.Function_overload_must_not_be_static; error(errorNode_1, diagnostic); } return; @@ -39791,7 +40141,7 @@ var ts; else { // Report different errors regarding non-consecutive blocks of declarations depending on whether // the node in question is abstract. - if (ts.getModifierFlags(node) & 128 /* Abstract */) { + if (ts.hasModifier(node, 128 /* Abstract */)) { error(errorNode, ts.Diagnostics.All_declarations_of_an_abstract_method_must_be_consecutive); } else { @@ -39801,8 +40151,8 @@ var ts; } var duplicateFunctionDeclaration = false; var multipleConstructorImplementation = false; - for (var _i = 0, declarations_5 = declarations; _i < declarations_5.length; _i++) { - var current = declarations_5[_i]; + for (var _i = 0, declarations_4 = declarations; _i < declarations_4.length; _i++) { + var current = declarations_4[_i]; var node = current; var inAmbientContext = ts.isInAmbientContext(node); var inAmbientContextOrInterface = node.parent.kind === 230 /* InterfaceDeclaration */ || node.parent.kind === 163 /* TypeLiteral */ || inAmbientContext; @@ -39859,7 +40209,7 @@ var ts; } // Abstract methods can't have an implementation -- in particular, they don't need one. if (lastSeenNonAmbientDeclaration && !lastSeenNonAmbientDeclaration.body && - !(ts.getModifierFlags(lastSeenNonAmbientDeclaration) & 128 /* Abstract */) && !lastSeenNonAmbientDeclaration.questionToken) { + !ts.hasModifier(lastSeenNonAmbientDeclaration, 128 /* Abstract */) && !lastSeenNonAmbientDeclaration.questionToken) { reportImplementationExpectedError(lastSeenNonAmbientDeclaration); } if (hasOverloads) { @@ -40426,7 +40776,7 @@ var ts; // checkFunctionOrConstructorSymbol wouldn't be called if we didnt ignore javascript function. var firstDeclaration = ts.find(localSymbol.declarations, // Get first non javascript function declaration - function (declaration) { return declaration.kind === node.kind && !ts.isSourceFileJavaScript(ts.getSourceFileOfNode(declaration)); }); + function (declaration) { return declaration.kind === node.kind && !(declaration.flags & 65536 /* JavaScriptFile */); }); // Only type check the symbol once if (node === firstDeclaration) { checkFunctionOrConstructorSymbol(localSymbol); @@ -40569,14 +40919,14 @@ var ts; for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; if (member.kind === 151 /* MethodDeclaration */ || member.kind === 149 /* PropertyDeclaration */) { - if (!member.symbol.isReferenced && ts.getModifierFlags(member) & 8 /* Private */) { + if (!member.symbol.isReferenced && ts.hasModifier(member, 8 /* Private */)) { error(member.name, ts.Diagnostics._0_is_declared_but_never_used, ts.unescapeLeadingUnderscores(member.symbol.escapedName)); } } else if (member.kind === 152 /* Constructor */) { for (var _b = 0, _c = member.parameters; _b < _c.length; _b++) { var parameter = _c[_b]; - if (!parameter.symbol.isReferenced && ts.getModifierFlags(parameter) & 8 /* Private */) { + if (!parameter.symbol.isReferenced && ts.hasModifier(parameter, 8 /* Private */)) { error(parameter.name, ts.Diagnostics.Property_0_is_declared_but_never_used, ts.unescapeLeadingUnderscores(parameter.symbol.escapedName)); } } @@ -40997,7 +41347,7 @@ var ts; 128 /* Abstract */ | 64 /* Readonly */ | 32 /* Static */; - return (ts.getModifierFlags(left) & interestingFlags) === (ts.getModifierFlags(right) & interestingFlags); + return ts.getSelectedModifierFlags(left, interestingFlags) === ts.getSelectedModifierFlags(right, interestingFlags); } function checkVariableDeclaration(node) { checkGrammarVariableDeclaration(node); @@ -41162,7 +41512,7 @@ var ts; } // unknownType is returned i.e. if node.expression is identifier whose name cannot be resolved // in this case error about missing name is already reported - do not report extra one - if (!isTypeAnyOrAllConstituentTypesHaveKind(rightType, 32768 /* Object */ | 540672 /* TypeVariable */ | 16777216 /* NonPrimitive */)) { + if (!isTypeAssignableToKind(rightType, 16777216 /* NonPrimitive */ | 540672 /* TypeVariable */)) { error(node.expression, ts.Diagnostics.The_right_hand_side_of_a_for_in_statement_must_be_of_type_any_an_object_type_or_a_type_parameter); } checkSourceElement(node.statement); @@ -41662,7 +42012,7 @@ var ts; // Only process instance properties with computed names here. // Static properties cannot be in conflict with indexers, // and properties with literal names were already checked. - if (!(ts.getModifierFlags(member) & 32 /* Static */) && ts.hasDynamicName(member)) { + if (!ts.hasModifier(member, 32 /* Static */) && ts.hasDynamicName(member)) { var propType = getTypeOfSymbol(member.symbol); checkIndexConstraintForProperty(member.symbol, propType, type, declaredStringIndexer, stringIndexType, 0 /* String */); checkIndexConstraintForProperty(member.symbol, propType, type, declaredNumberIndexer, numberIndexType, 1 /* Number */); @@ -41773,8 +42123,8 @@ var ts; if (!areTypeParametersIdentical(declarations, type.localTypeParameters)) { // Report an error on every conflicting declaration. var name = symbolToString(symbol); - for (var _i = 0, declarations_6 = declarations; _i < declarations_6.length; _i++) { - var declaration = declarations_6[_i]; + for (var _i = 0, declarations_5 = declarations; _i < declarations_5.length; _i++) { + var declaration = declarations_5[_i]; error(declaration.name, ts.Diagnostics.All_declarations_of_0_must_have_identical_type_parameters, name); } } @@ -41783,8 +42133,8 @@ var ts; function areTypeParametersIdentical(declarations, typeParameters) { var maxTypeArgumentCount = ts.length(typeParameters); var minTypeArgumentCount = getMinTypeArgumentCount(typeParameters); - for (var _i = 0, declarations_7 = declarations; _i < declarations_7.length; _i++) { - var declaration = declarations_7[_i]; + for (var _i = 0, declarations_6 = declarations; _i < declarations_6.length; _i++) { + var declaration = declarations_6[_i]; // If this declaration has too few or too many type parameters, we report an error var numTypeParameters = ts.length(declaration.typeParameters); if (numTypeParameters < minTypeArgumentCount || numTypeParameters > maxTypeArgumentCount) { @@ -41827,7 +42177,7 @@ var ts; registerForUnusedIdentifiersCheck(node); } function checkClassDeclaration(node) { - if (!node.name && !(ts.getModifierFlags(node) & 512 /* Default */)) { + if (!node.name && !ts.hasModifier(node, 512 /* Default */)) { grammarErrorOnFirstToken(node, ts.Diagnostics.A_class_declaration_without_the_default_modifier_must_have_a_name); } checkClassLikeDeclaration(node); @@ -41925,7 +42275,7 @@ var ts; var signatures = getSignaturesOfType(type, 1 /* Construct */); if (signatures.length) { var declaration = signatures[0].declaration; - if (declaration && ts.getModifierFlags(declaration) & 8 /* Private */) { + if (declaration && ts.hasModifier(declaration, 8 /* Private */)) { var typeClassDeclaration = getClassLikeDeclarationOfSymbol(type.symbol); if (!isNodeWithinClass(node, typeClassDeclaration)) { error(node, ts.Diagnostics.Cannot_extend_a_class_0_Class_constructor_is_marked_as_private, getFullyQualifiedName(type.symbol)); @@ -41981,7 +42331,7 @@ var ts; // 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 & 128 /* Abstract */ && (!derivedClassDecl || !(ts.getModifierFlags(derivedClassDecl) & 128 /* Abstract */))) { + if (baseDeclarationFlags & 128 /* Abstract */ && (!derivedClassDecl || !ts.hasModifier(derivedClassDecl, 128 /* Abstract */))) { if (derivedClassDecl.kind === 199 /* ClassExpression */) { error(derivedClassDecl, ts.Diagnostics.Non_abstract_class_expression_does_not_implement_inherited_abstract_member_0_from_class_1, symbolToString(baseProperty), typeToString(baseType)); } @@ -42032,8 +42382,8 @@ var ts; for (var _i = 0, baseTypes_2 = baseTypes; _i < baseTypes_2.length; _i++) { var base = baseTypes_2[_i]; var properties = getPropertiesOfType(getTypeWithThisArgument(base, type.thisType)); - for (var _a = 0, properties_7 = properties; _a < properties_7.length; _a++) { - var prop = properties_7[_a]; + for (var _a = 0, properties_8 = properties; _a < properties_8.length; _a++) { + var prop = properties_8[_a]; var existing = seen.get(prop.escapedName); if (!existing) { seen.set(prop.escapedName, { prop: prop, containingType: base }); @@ -42307,8 +42657,8 @@ var ts; } function getFirstNonAmbientClassOrFunctionDeclaration(symbol) { var declarations = symbol.declarations; - for (var _i = 0, declarations_8 = declarations; _i < declarations_8.length; _i++) { - var declaration = declarations_8[_i]; + for (var _i = 0, declarations_7 = declarations; _i < declarations_7.length; _i++) { + var declaration = declarations_7[_i]; if ((declaration.kind === 229 /* ClassDeclaration */ || (declaration.kind === 228 /* FunctionDeclaration */ && ts.nodeIsPresent(declaration.body))) && !ts.isInAmbientContext(declaration)) { @@ -42558,7 +42908,7 @@ var ts; // If we hit an import declaration in an illegal context, just bail out to avoid cascading errors. return; } - if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && ts.getModifierFlags(node) !== 0) { + if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && ts.hasModifiers(node)) { grammarErrorOnFirstToken(node, ts.Diagnostics.An_import_declaration_cannot_have_modifiers); } if (checkExternalImportOrExportDeclaration(node)) { @@ -42586,7 +42936,7 @@ var ts; checkGrammarDecorators(node) || checkGrammarModifiers(node); if (ts.isInternalModuleImportEqualsDeclaration(node) || checkExternalImportOrExportDeclaration(node)) { checkImportBinding(node); - if (ts.getModifierFlags(node) & 1 /* Export */) { + if (ts.hasModifier(node, 1 /* Export */)) { markExportAsReferenced(node); } if (ts.isInternalModuleImportEqualsDeclaration(node)) { @@ -42617,7 +42967,7 @@ var ts; // If we hit an export in an illegal context, just bail out to avoid cascading errors. return; } - if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && ts.getModifierFlags(node) !== 0) { + if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && ts.hasModifiers(node)) { grammarErrorOnFirstToken(node, ts.Diagnostics.An_export_declaration_cannot_have_modifiers); } if (!node.moduleSpecifier || checkExternalImportOrExportDeclaration(node)) { @@ -42682,7 +43032,7 @@ var ts; return; } // Grammar checking - if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && ts.getModifierFlags(node) !== 0) { + if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && ts.hasModifiers(node)) { grammarErrorOnFirstToken(node, ts.Diagnostics.An_export_assignment_cannot_have_modifiers); } if (node.expression.kind === 71 /* Identifier */) { @@ -42736,8 +43086,8 @@ var ts; return; } if (exportedDeclarationsCount > 1) { - for (var _i = 0, declarations_9 = declarations; _i < declarations_9.length; _i++) { - var declaration = declarations_9[_i]; + for (var _i = 0, declarations_8 = declarations; _i < declarations_8.length; _i++) { + var declaration = declarations_8[_i]; if (isNotOverload(declaration)) { diagnostics.add(ts.createDiagnosticForNode(declaration, ts.Diagnostics.Cannot_redeclare_exported_variable_0, ts.unescapeLeadingUnderscores(id))); } @@ -43046,7 +43396,7 @@ var ts; return []; } var symbols = ts.createSymbolTable(); - var memberFlags = 0 /* None */; + var isStatic = false; populateSymbols(); return symbolsToArray(symbols); function populateSymbols() { @@ -43075,7 +43425,7 @@ var ts; // add the type parameters into the symbol table // (type parameters of classDeclaration/classExpression and interface are in member property of the symbol. // Note: that the memberFlags come from previous iteration. - if (!(memberFlags & 32 /* Static */)) { + if (!isStatic) { copySymbols(getSymbolOfNode(location).members, meaning & 793064 /* Type */); } break; @@ -43089,7 +43439,7 @@ var ts; if (ts.introducesArgumentsExoticObject(location)) { copySymbol(argumentsSymbol, meaning); } - memberFlags = ts.getModifierFlags(location); + isStatic = ts.hasModifier(location, 32 /* Static */); location = location.parent; } copySymbols(globals, meaning); @@ -43351,12 +43701,7 @@ var ts; // index access if (node.parent.kind === 180 /* ElementAccessExpression */ && node.parent.argumentExpression === node) { var objectType = getTypeOfExpression(node.parent.expression); - if (objectType === unknownType) - return undefined; - var apparentType = getApparentType(objectType); - if (apparentType === unknownType) - return undefined; - return getPropertyOfType(apparentType, node.text); + return getPropertyOfType(objectType, node.text); } break; } @@ -43487,7 +43832,7 @@ var ts; */ function getParentTypeOfClassElement(node) { var classSymbol = getSymbolOfNode(node.parent); - return ts.getModifierFlags(node) & 32 /* Static */ + return ts.hasModifier(node, 32 /* Static */) ? getTypeOfSymbol(classSymbol) : getDeclaredTypeOfSymbol(classSymbol); } @@ -43769,13 +44114,13 @@ var ts; return strictNullChecks && !isOptionalParameter(parameter) && parameter.initializer && - !(ts.getModifierFlags(parameter) & 92 /* ParameterPropertyModifier */); + !ts.hasModifier(parameter, 92 /* ParameterPropertyModifier */); } function isOptionalUninitializedParameterProperty(parameter) { return strictNullChecks && isOptionalParameter(parameter) && !parameter.initializer && - !!(ts.getModifierFlags(parameter) & 92 /* ParameterPropertyModifier */); + ts.hasModifier(parameter, 92 /* ParameterPropertyModifier */); } function getNodeCheckFlags(node) { return getNodeLinks(node).flags; @@ -43835,22 +44180,22 @@ var ts; else if (type.flags & 1 /* Any */) { return ts.TypeReferenceSerializationKind.ObjectType; } - else if (isTypeOfKind(type, 1024 /* Void */ | 6144 /* Nullable */ | 8192 /* Never */)) { + else if (isTypeAssignableToKind(type, 1024 /* Void */ | 6144 /* Nullable */ | 8192 /* Never */)) { return ts.TypeReferenceSerializationKind.VoidNullableOrNeverType; } - else if (isTypeOfKind(type, 136 /* BooleanLike */)) { + else if (isTypeAssignableToKind(type, 136 /* BooleanLike */)) { return ts.TypeReferenceSerializationKind.BooleanType; } - else if (isTypeOfKind(type, 84 /* NumberLike */)) { + else if (isTypeAssignableToKind(type, 84 /* NumberLike */)) { return ts.TypeReferenceSerializationKind.NumberLikeType; } - else if (isTypeOfKind(type, 262178 /* StringLike */)) { + else if (isTypeAssignableToKind(type, 262178 /* StringLike */)) { return ts.TypeReferenceSerializationKind.StringLikeType; } else if (isTupleType(type)) { return ts.TypeReferenceSerializationKind.ArrayLikeType; } - else if (isTypeOfKind(type, 512 /* ESSymbol */)) { + else if (isTypeAssignableToKind(type, 512 /* ESSymbol */)) { return ts.TypeReferenceSerializationKind.ESSymbolType; } else if (isFunctionType(type)) { @@ -44346,7 +44691,7 @@ var ts; node.kind !== 154 /* SetAccessor */) { return grammarErrorOnNode(modifier, ts.Diagnostics.abstract_modifier_can_only_appear_on_a_class_method_or_property_declaration); } - if (!(node.parent.kind === 229 /* ClassDeclaration */ && ts.getModifierFlags(node.parent) & 128 /* Abstract */)) { + if (!(node.parent.kind === 229 /* ClassDeclaration */ && ts.hasModifier(node.parent, 128 /* Abstract */))) { return grammarErrorOnNode(modifier, ts.Diagnostics.Abstract_methods_can_only_appear_within_an_abstract_class); } if (flags & 32 /* Static */) { @@ -44469,8 +44814,7 @@ var ts; if (list && list.hasTrailingComma) { var start = list.end - ",".length; var end = list.end; - var sourceFile = ts.getSourceFileOfNode(list[0]); - return grammarErrorAtPos(sourceFile, start, end - start, ts.Diagnostics.Trailing_comma_not_allowed); + return grammarErrorAtPos(list[0], start, end - start, ts.Diagnostics.Trailing_comma_not_allowed); } } function checkGrammarTypeParameterList(typeParameters, file) { @@ -44547,7 +44891,7 @@ var ts; if (parameter.dotDotDotToken) { return grammarErrorOnNode(parameter.dotDotDotToken, ts.Diagnostics.An_index_signature_cannot_have_a_rest_parameter); } - if (ts.getModifierFlags(parameter) !== 0) { + if (ts.hasModifiers(parameter)) { return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_cannot_have_an_accessibility_modifier); } if (parameter.questionToken) { @@ -44582,19 +44926,18 @@ var ts; return checkGrammarForDisallowedTrailingComma(typeArguments) || checkGrammarForAtLeastOneTypeArgument(node, typeArguments); } - function checkGrammarForOmittedArgument(node, args) { + function checkGrammarForOmittedArgument(args) { if (args) { - var sourceFile = ts.getSourceFileOfNode(node); for (var _i = 0, args_5 = args; _i < args_5.length; _i++) { var arg = args_5[_i]; if (arg.kind === 200 /* OmittedExpression */) { - return grammarErrorAtPos(sourceFile, arg.pos, 0, ts.Diagnostics.Argument_expression_expected); + return grammarErrorAtPos(arg, arg.pos, 0, ts.Diagnostics.Argument_expression_expected); } } } } - function checkGrammarArguments(node, args) { - return checkGrammarForOmittedArgument(node, args); + function checkGrammarArguments(args) { + return checkGrammarForOmittedArgument(args); } function checkGrammarHeritageClause(node) { var types = node.types; @@ -44603,8 +44946,7 @@ var ts; } if (types && types.length === 0) { var listType = ts.tokenToString(node.token); - var sourceFile = ts.getSourceFileOfNode(node); - return grammarErrorAtPos(sourceFile, types.pos, 0, ts.Diagnostics._0_list_cannot_be_empty, listType); + return grammarErrorAtPos(node, types.pos, 0, ts.Diagnostics._0_list_cannot_be_empty, listType); } return ts.forEach(types, checkGrammarExpressionWithTypeArguments); } @@ -44850,10 +45192,10 @@ var ts; else if (ts.isInAmbientContext(accessor)) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.An_accessor_cannot_be_declared_in_an_ambient_context); } - else if (accessor.body === undefined && !(ts.getModifierFlags(accessor) & 128 /* Abstract */)) { - return grammarErrorAtPos(ts.getSourceFileOfNode(accessor), accessor.end - 1, ";".length, ts.Diagnostics._0_expected, "{"); + else if (accessor.body === undefined && !ts.hasModifier(accessor, 128 /* Abstract */)) { + return grammarErrorAtPos(accessor, accessor.end - 1, ";".length, ts.Diagnostics._0_expected, "{"); } - else if (accessor.body && ts.getModifierFlags(accessor) & 128 /* Abstract */) { + else if (accessor.body && ts.hasModifier(accessor, 128 /* Abstract */)) { return grammarErrorOnNode(accessor, ts.Diagnostics.An_abstract_accessor_cannot_have_an_implementation); } else if (accessor.typeParameters) { @@ -44910,7 +45252,7 @@ var ts; return true; } else if (node.body === undefined) { - return grammarErrorAtPos(ts.getSourceFileOfNode(node), node.end - 1, ";".length, ts.Diagnostics._0_expected, "{"); + return grammarErrorAtPos(node, node.end - 1, ";".length, ts.Diagnostics._0_expected, "{"); } } if (ts.isClassLike(node.parent)) { @@ -44991,7 +45333,7 @@ var ts; } if (node.initializer) { // Error on equals token which immediately precedes the initializer - return grammarErrorAtPos(ts.getSourceFileOfNode(node), node.initializer.pos - 1, 1, ts.Diagnostics.A_rest_element_cannot_have_an_initializer); + return grammarErrorAtPos(node, node.initializer.pos - 1, 1, ts.Diagnostics.A_rest_element_cannot_have_an_initializer); } } } @@ -45012,13 +45354,13 @@ var ts; else { // Error on equals token which immediate precedes the initializer var equalsTokenLength = "=".length; - return grammarErrorAtPos(ts.getSourceFileOfNode(node), node.initializer.pos - equalsTokenLength, equalsTokenLength, ts.Diagnostics.Initializers_are_not_allowed_in_ambient_contexts); + return grammarErrorAtPos(node, node.initializer.pos - equalsTokenLength, equalsTokenLength, ts.Diagnostics.Initializers_are_not_allowed_in_ambient_contexts); } } if (node.initializer && !(ts.isConst(node) && isStringOrNumberLiteralExpression(node.initializer))) { // Error on equals token which immediate precedes the initializer var equalsTokenLength = "=".length; - return grammarErrorAtPos(ts.getSourceFileOfNode(node), node.initializer.pos - equalsTokenLength, equalsTokenLength, ts.Diagnostics.Initializers_are_not_allowed_in_ambient_contexts); + return grammarErrorAtPos(node, node.initializer.pos - equalsTokenLength, equalsTokenLength, ts.Diagnostics.Initializers_are_not_allowed_in_ambient_contexts); } } else if (!node.initializer) { @@ -45081,7 +45423,7 @@ var ts; return true; } if (!declarationList.declarations.length) { - return grammarErrorAtPos(ts.getSourceFileOfNode(declarationList), declarations.pos, declarations.end - declarations.pos, ts.Diagnostics.Variable_declaration_list_cannot_be_empty); + return grammarErrorAtPos(declarationList, declarations.pos, declarations.end - declarations.pos, ts.Diagnostics.Variable_declaration_list_cannot_be_empty); } } function allowLetAndConstDeclarations(parent) { @@ -45127,7 +45469,8 @@ var ts; return true; } } - function grammarErrorAtPos(sourceFile, start, length, message, arg0, arg1, arg2) { + function grammarErrorAtPos(nodeForSourceFile, start, length, message, arg0, arg1, arg2) { + var sourceFile = ts.getSourceFileOfNode(nodeForSourceFile); if (!hasParseDiagnostics(sourceFile)) { diagnostics.add(ts.createFileDiagnostic(sourceFile, start, length, message, arg0, arg1, arg2)); return true; @@ -45142,7 +45485,7 @@ var ts; } function checkGrammarConstructorTypeParameters(node) { if (node.typeParameters) { - return grammarErrorAtPos(ts.getSourceFileOfNode(node), node.typeParameters.pos, node.typeParameters.end - node.typeParameters.pos, ts.Diagnostics.Type_parameters_cannot_appear_on_a_constructor_declaration); + return grammarErrorAtPos(node, node.typeParameters.pos, node.typeParameters.end - node.typeParameters.pos, ts.Diagnostics.Type_parameters_cannot_appear_on_a_constructor_declaration); } } function checkGrammarConstructorTypeAnnotation(node) { @@ -45196,7 +45539,7 @@ var ts; node.kind === 244 /* ExportDeclaration */ || node.kind === 243 /* ExportAssignment */ || node.kind === 236 /* NamespaceExportDeclaration */ || - ts.getModifierFlags(node) & (2 /* Ambient */ | 1 /* Export */ | 512 /* Default */)) { + ts.hasModifier(node, 2 /* Ambient */ | 1 /* Export */ | 512 /* Default */)) { return false; } return grammarErrorOnFirstToken(node, ts.Diagnostics.A_declare_modifier_is_required_for_a_top_level_declaration_in_a_d_ts_file); @@ -48142,7 +48485,7 @@ var ts; function createExpressionForAccessorDeclaration(properties, property, receiver, multiLine) { var _a = ts.getAllAccessorDeclarations(properties, property), firstAccessor = _a.firstAccessor, getAccessor = _a.getAccessor, setAccessor = _a.setAccessor; if (property === firstAccessor) { - var properties_8 = []; + var properties_9 = []; if (getAccessor) { var getterFunction = ts.createFunctionExpression(getAccessor.modifiers, /*asteriskToken*/ undefined, @@ -48152,7 +48495,7 @@ var ts; ts.setTextRange(getterFunction, getAccessor); ts.setOriginalNode(getterFunction, getAccessor); var getter = ts.createPropertyAssignment("get", getterFunction); - properties_8.push(getter); + properties_9.push(getter); } if (setAccessor) { var setterFunction = ts.createFunctionExpression(setAccessor.modifiers, @@ -48163,15 +48506,15 @@ var ts; ts.setTextRange(setterFunction, setAccessor); ts.setOriginalNode(setterFunction, setAccessor); var setter = ts.createPropertyAssignment("set", setterFunction); - properties_8.push(setter); + properties_9.push(setter); } - properties_8.push(ts.createPropertyAssignment("enumerable", ts.createTrue())); - properties_8.push(ts.createPropertyAssignment("configurable", ts.createTrue())); + properties_9.push(ts.createPropertyAssignment("enumerable", ts.createTrue())); + properties_9.push(ts.createPropertyAssignment("configurable", ts.createTrue())); var expression = ts.setTextRange(ts.createCall(ts.createPropertyAccess(ts.createIdentifier("Object"), "defineProperty"), /*typeArguments*/ undefined, [ receiver, createExpressionForPropertyName(property.name), - ts.createObjectLiteral(properties_8, multiLine) + ts.createObjectLiteral(properties_9, multiLine) ]), /*location*/ firstAccessor); return ts.aggregateTransformFlags(expression); @@ -50628,11 +50971,14 @@ var ts; : numElements, location), /*reuseIdentifierExpressions*/ false, location); } - else if (numElements !== 1 && (flattenContext.level < 1 /* ObjectRest */ || numElements === 0)) { + else if (numElements !== 1 && (flattenContext.level < 1 /* ObjectRest */ || numElements === 0) + || ts.every(elements, ts.isOmittedExpression)) { // For anything other than a single-element destructuring we need to generate a temporary // to ensure value is evaluated exactly once. Additionally, if we have zero elements // we need to emit *something* to ensure that in case a 'var' keyword was already emitted, // so in that case, we'll intentionally create that temporary. + // Or all the elements of the binding pattern are omitted expression such as "var [,] = [1,2]", + // then we will create temporary variable. var reuseIdentifierExpressions = !ts.isDeclarationBindingElement(parent) || numElements !== 0; value = ensureIdentifier(flattenContext, value, reuseIdentifierExpressions, location); } @@ -50919,7 +51265,16 @@ var ts; if (ts.hasModifier(node, 2 /* Ambient */)) { break; } - recordEmittedDeclarationInScope(node); + // Record these declarations provided that they have a name. + if (node.name) { + recordEmittedDeclarationInScope(node); + } + else { + // These nodes should always have names unless they are default-exports; + // however, class declaration parsing allows for undefined names, so syntactically invalid + // programs may also have an undefined name. + ts.Debug.assert(node.kind === 229 /* ClassDeclaration */ || ts.hasModifier(node, 512 /* Default */)); + } break; } } @@ -51748,8 +52103,8 @@ var ts; * @param receiver The receiver on which each property should be assigned. */ function addInitializedPropertyStatements(statements, properties, receiver) { - for (var _i = 0, properties_9 = properties; _i < properties_9.length; _i++) { - var property = properties_9[_i]; + for (var _i = 0, properties_10 = properties; _i < properties_10.length; _i++) { + var property = properties_10[_i]; var statement = ts.createStatement(transformInitializedProperty(property, receiver)); ts.setSourceMapRange(statement, ts.moveRangePastModifiers(property)); ts.setCommentRange(statement, property); @@ -51764,8 +52119,8 @@ var ts; */ function generateInitializedPropertyExpressions(properties, receiver) { var expressions = []; - for (var _i = 0, properties_10 = properties; _i < properties_10.length; _i++) { - var property = properties_10[_i]; + for (var _i = 0, properties_11 = properties; _i < properties_11.length; _i++) { + var property = properties_11[_i]; var expression = transformInitializedProperty(property, receiver); expression.startsOnNewLine = true; ts.setSourceMapRange(expression, ts.moveRangePastModifiers(property)); @@ -52928,33 +53283,30 @@ var ts; /** * Records that a declaration was emitted in the current scope, if it was the first * declaration for the provided symbol. - * - * NOTE: if there is ever a transformation above this one, we may not be able to rely - * on symbol names. */ function recordEmittedDeclarationInScope(node) { - var name = node.symbol && node.symbol.escapedName; - if (name) { - if (!currentScopeFirstDeclarationsOfName) { - currentScopeFirstDeclarationsOfName = ts.createUnderscoreEscapedMap(); - } - if (!currentScopeFirstDeclarationsOfName.has(name)) { - currentScopeFirstDeclarationsOfName.set(name, node); - } + if (!currentScopeFirstDeclarationsOfName) { + currentScopeFirstDeclarationsOfName = ts.createUnderscoreEscapedMap(); + } + var name = declaredNameInScope(node); + if (!currentScopeFirstDeclarationsOfName.has(name)) { + currentScopeFirstDeclarationsOfName.set(name, node); } } /** - * Determines whether a declaration is the first declaration with the same name emitted - * in the current scope. + * Determines whether a declaration is the first declaration with + * the same name emitted in the current scope. */ function isFirstEmittedDeclarationInScope(node) { if (currentScopeFirstDeclarationsOfName) { - var name = node.symbol && node.symbol.escapedName; - if (name) { - return currentScopeFirstDeclarationsOfName.get(name) === node; - } + var name = declaredNameInScope(node); + return currentScopeFirstDeclarationsOfName.get(name) === node; } - return false; + return true; + } + function declaredNameInScope(node) { + ts.Debug.assertNode(node.name, ts.isIdentifier); + return node.name.escapedText; } /** * Adds a leading VariableStatement for a enum or module declaration. @@ -53021,7 +53373,7 @@ var ts; if (!shouldEmitModuleDeclaration(node)) { return ts.createNotEmittedStatement(node); } - ts.Debug.assert(ts.isIdentifier(node.name), "TypeScript module should have an Identifier name."); + ts.Debug.assertNode(node.name, ts.isIdentifier, "A TypeScript namespace should have an Identifier name."); enableSubstitutionForNamespaceExports(); var statements = []; // We request to be advised when the printer is about to print this node. This allows @@ -54050,6 +54402,8 @@ var ts; return visitExpressionStatement(node); case 185 /* ParenthesizedExpression */: return visitParenthesizedExpression(node, noDestructuringValue); + case 260 /* CatchClause */: + return visitCatchClause(node); default: return ts.visitEachChild(node, visitor, context); } @@ -54130,6 +54484,12 @@ var ts; function visitParenthesizedExpression(node, noDestructuringValue) { return ts.visitEachChild(node, noDestructuringValue ? visitorNoDestructuringValue : visitor, context); } + function visitCatchClause(node) { + if (!node.variableDeclaration) { + return ts.updateCatchClause(node, ts.createVariableDeclaration(ts.createTempVariable(/*recordTempVariable*/ undefined)), ts.visitNode(node.block, visitor, ts.isBlock)); + } + return ts.visitEachChild(node, visitor, context); + } /** * Visits a BinaryExpression that contains a destructuring assignment. * @@ -54674,7 +55034,7 @@ var ts; objectProperties = ts.createAssignHelper(context, segments); } } - var element = ts.createExpressionForJsxElement(context.getEmitResolver().getJsxFactoryEntity(), compilerOptions.reactNamespace, tagName, objectProperties, ts.filter(ts.map(children, transformJsxChildToExpression), ts.isDefined), node, location); + var element = ts.createExpressionForJsxElement(context.getEmitResolver().getJsxFactoryEntity(), compilerOptions.reactNamespace, tagName, objectProperties, ts.mapDefined(children, transformJsxChildToExpression), node, location); if (isChild) { ts.startOnNewLine(element); } @@ -55378,7 +55738,7 @@ var ts; function shouldVisitNode(node) { return (node.transformFlags & 128 /* ContainsES2015 */) !== 0 || convertedLoopState !== undefined - || (hierarchyFacts & 4096 /* ConstructorWithCapturedSuper */ && ts.isStatement(node)) + || (hierarchyFacts & 4096 /* ConstructorWithCapturedSuper */ && (ts.isStatement(node) || (node.kind === 207 /* Block */))) || (ts.isIterationStatement(node, /*lookInLabeledStatements*/ false) && shouldConvertIterationStatementBody(node)) || isTypeScriptClassWrapper(node); } @@ -55733,10 +56093,12 @@ var ts; var outer = ts.createPartiallyEmittedExpression(inner); outer.end = ts.skipTrivia(currentText, node.pos); ts.setEmitFlags(outer, 1536 /* NoComments */); - return ts.createParen(ts.createCall(outer, + var result = ts.createParen(ts.createCall(outer, /*typeArguments*/ undefined, extendsClauseElement ? [ts.visitNode(extendsClauseElement.expression, visitor, ts.isExpression)] : [])); + ts.addSyntheticLeadingComment(result, 3 /* MultiLineCommentTrivia */, "* @class "); + return result; } /** * Transforms a ClassExpression or ClassDeclaration into a function body. @@ -56654,13 +57016,14 @@ var ts; ts.setTextRange(declarationList, node); ts.setCommentRange(declarationList, node); if (node.transformFlags & 8388608 /* ContainsBindingPattern */ - && (ts.isBindingPattern(node.declarations[0].name) - || ts.isBindingPattern(ts.lastOrUndefined(node.declarations).name))) { + && (ts.isBindingPattern(node.declarations[0].name) || ts.isBindingPattern(ts.lastOrUndefined(node.declarations).name))) { // If the first or last declaration is a binding pattern, we need to modify // the source map range for the declaration list. var firstDeclaration = ts.firstOrUndefined(declarations); - var lastDeclaration = ts.lastOrUndefined(declarations); - ts.setSourceMapRange(declarationList, ts.createRange(firstDeclaration.pos, lastDeclaration.end)); + if (firstDeclaration) { + var lastDeclaration = ts.lastOrUndefined(declarations); + ts.setSourceMapRange(declarationList, ts.createRange(firstDeclaration.pos, lastDeclaration.end)); + } } return declarationList; } @@ -57405,6 +57768,7 @@ var ts; function visitCatchClause(node) { var ancestorFacts = enterSubtree(4032 /* BlockScopeExcludes */, 0 /* BlockScopeIncludes */); var updated; + ts.Debug.assert(!!node.variableDeclaration, "Catch clause variable should always be present when downleveling ES2015."); if (ts.isBindingPattern(node.variableDeclaration.name)) { var temp = ts.createTempVariable(/*recordTempVariable*/ undefined); var newVariableDeclaration = ts.createVariableDeclaration(temp); @@ -59593,8 +59957,13 @@ var ts; } function transformAndEmitContinueStatement(node) { var label = findContinueTarget(node.label ? ts.unescapeLeadingUnderscores(node.label.escapedText) : undefined); - ts.Debug.assert(label > 0, "Expected continue statment to point to a valid Label."); - emitBreak(label, /*location*/ node); + if (label > 0) { + emitBreak(label, /*location*/ node); + } + else { + // invalid continue without a containing loop. Leave the node as is, per #17875. + emitStatement(node); + } } function visitContinueStatement(node) { if (inStatementContainingYield) { @@ -59607,8 +59976,13 @@ var ts; } function transformAndEmitBreakStatement(node) { var label = findBreakTarget(node.label ? ts.unescapeLeadingUnderscores(node.label.escapedText) : undefined); - ts.Debug.assert(label > 0, "Expected break statment to point to a valid Label."); - emitBreak(label, /*location*/ node); + if (label > 0) { + emitBreak(label, /*location*/ node); + } + else { + // invalid break without a containing loop, switch, or labeled statement. Leave the node as is, per #17875. + emitStatement(node); + } } function visitBreakStatement(node) { if (inStatementContainingYield) { @@ -59979,9 +60353,6 @@ var ts; var block = endBlock(); markLabel(block.endLabel); } - function isWithBlock(block) { - return block.kind === 1 /* With */; - } /** * Begins a code block for a generated `try` statement. */ @@ -60065,9 +60436,6 @@ var ts; emitNop(); exception.state = 3 /* Done */; } - function isExceptionBlock(block) { - return block.kind === 0 /* Exception */; - } /** * Begins a code block that supports `break` or `continue` statements that are defined in * the source tree and not from generated code. @@ -60218,23 +60586,24 @@ var ts; * @param labelText An optional name of a containing labeled statement. */ function findBreakTarget(labelText) { - ts.Debug.assert(blocks !== undefined); - if (labelText) { - for (var i = blockStack.length - 1; i >= 0; i--) { - var block = blockStack[i]; - if (supportsLabeledBreakOrContinue(block) && block.labelText === labelText) { - return block.breakLabel; - } - else if (supportsUnlabeledBreak(block) && hasImmediateContainingLabeledBlock(labelText, i - 1)) { - return block.breakLabel; + if (blockStack) { + if (labelText) { + for (var i = blockStack.length - 1; i >= 0; i--) { + var block = blockStack[i]; + if (supportsLabeledBreakOrContinue(block) && block.labelText === labelText) { + return block.breakLabel; + } + else if (supportsUnlabeledBreak(block) && hasImmediateContainingLabeledBlock(labelText, i - 1)) { + return block.breakLabel; + } } } - } - else { - for (var i = blockStack.length - 1; i >= 0; i--) { - var block = blockStack[i]; - if (supportsUnlabeledBreak(block)) { - return block.breakLabel; + else { + for (var i = blockStack.length - 1; i >= 0; i--) { + var block = blockStack[i]; + if (supportsUnlabeledBreak(block)) { + return block.breakLabel; + } } } } @@ -60246,20 +60615,21 @@ var ts; * @param labelText An optional name of a containing labeled statement. */ function findContinueTarget(labelText) { - ts.Debug.assert(blocks !== undefined); - if (labelText) { - for (var i = blockStack.length - 1; i >= 0; i--) { - var block = blockStack[i]; - if (supportsUnlabeledContinue(block) && hasImmediateContainingLabeledBlock(labelText, i - 1)) { - return block.continueLabel; + if (blockStack) { + if (labelText) { + for (var i = blockStack.length - 1; i >= 0; i--) { + var block = blockStack[i]; + if (supportsUnlabeledContinue(block) && hasImmediateContainingLabeledBlock(labelText, i - 1)) { + return block.continueLabel; + } } } - } - else { - for (var i = blockStack.length - 1; i >= 0; i--) { - var block = blockStack[i]; - if (supportsUnlabeledContinue(block)) { - return block.continueLabel; + else { + for (var i = blockStack.length - 1; i >= 0; i--) { + var block = blockStack[i]; + if (supportsUnlabeledContinue(block)) { + return block.continueLabel; + } } } } @@ -60301,7 +60671,7 @@ var ts; * @param location An optional source map location for the statement. */ function createInlineBreak(label, location) { - ts.Debug.assert(label > 0, "Invalid label: " + label); + ts.Debug.assertLessThan(0, label, "Invalid label"); return ts.setTextRange(ts.createReturn(ts.createArrayLiteral([ createInstruction(3 /* Break */), createLabel(label) @@ -60642,31 +61012,33 @@ var ts; for (; blockIndex < blockActions.length && blockOffsets[blockIndex] <= operationIndex; blockIndex++) { var block = blocks[blockIndex]; var blockAction = blockActions[blockIndex]; - if (isExceptionBlock(block)) { - if (blockAction === 0 /* Open */) { - if (!exceptionBlockStack) { - exceptionBlockStack = []; + switch (block.kind) { + case 0 /* Exception */: + if (blockAction === 0 /* Open */) { + if (!exceptionBlockStack) { + exceptionBlockStack = []; + } + if (!statements) { + statements = []; + } + exceptionBlockStack.push(currentExceptionBlock); + currentExceptionBlock = block; } - if (!statements) { - statements = []; + else if (blockAction === 1 /* Close */) { + currentExceptionBlock = exceptionBlockStack.pop(); } - exceptionBlockStack.push(currentExceptionBlock); - currentExceptionBlock = block; - } - else if (blockAction === 1 /* Close */) { - currentExceptionBlock = exceptionBlockStack.pop(); - } - } - else if (isWithBlock(block)) { - if (blockAction === 0 /* Open */) { - if (!withBlockStack) { - withBlockStack = []; + break; + case 1 /* With */: + if (blockAction === 0 /* Open */) { + if (!withBlockStack) { + withBlockStack = []; + } + withBlockStack.push(block); } - withBlockStack.push(block); - } - else if (blockAction === 1 /* Close */) { - withBlockStack.pop(); - } + else if (blockAction === 1 /* Close */) { + withBlockStack.pop(); + } + break; } } } @@ -64580,14 +64952,14 @@ var ts; writer.writeLine(); } } - function emitTrailingCommentsOfPosition(pos) { + function emitTrailingCommentsOfPosition(pos, prefixSpace) { if (disabled) { return; } if (extendedDiagnostics) { ts.performance.mark("beforeEmitTrailingCommentsOfPosition"); } - forEachTrailingCommentToEmit(pos, emitTrailingCommentOfPosition); + forEachTrailingCommentToEmit(pos, prefixSpace ? emitTrailingComment : emitTrailingCommentOfPosition); if (extendedDiagnostics) { ts.performance.measure("commentTime", "beforeEmitTrailingCommentsOfPosition"); } @@ -64676,17 +65048,7 @@ var ts; * @return true if the comment is a triple-slash comment else false */ function isTripleSlashComment(commentPos, commentEnd) { - // 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 (currentText.charCodeAt(commentPos + 1) === 47 /* slash */ && - commentPos + 2 < commentEnd && - currentText.charCodeAt(commentPos + 2) === 47 /* slash */) { - var textSubStr = currentText.substring(commentPos, commentEnd); - return textSubStr.match(ts.fullTripleSlashReferencePathRegEx) || - textSubStr.match(ts.fullTripleSlashAMDReferencePathRegEx) ? - true : false; - } - return false; + return ts.isRecognizedTripleSlashComment(currentText, commentPos, commentEnd); } } ts.createCommentWriter = createCommentWriter; @@ -64972,7 +65334,6 @@ var ts; errorNameNode = declaration.name; var format = 4 /* UseTypeOfFunction */ | 16384 /* WriteClassExpressionAsTypeLiteral */ | - 2048 /* UseTypeAliasValue */ | (shouldUseResolverType ? 8192 /* AddUndefined */ : 0); resolver.writeTypeOfDeclaration(declaration, enclosingDeclaration, format, writer); errorNameNode = undefined; @@ -64987,7 +65348,7 @@ var ts; } else { errorNameNode = signature.name; - resolver.writeReturnTypeOfSignatureDeclaration(signature, enclosingDeclaration, 4 /* UseTypeOfFunction */ | 2048 /* UseTypeAliasValue */ | 16384 /* WriteClassExpressionAsTypeLiteral */, writer); + resolver.writeReturnTypeOfSignatureDeclaration(signature, enclosingDeclaration, 4 /* UseTypeOfFunction */ | 16384 /* WriteClassExpressionAsTypeLiteral */, writer); errorNameNode = undefined; } } @@ -65225,7 +65586,7 @@ var ts; write(tempVarName); write(": "); writer.getSymbolAccessibilityDiagnostic = function () { return diagnostic; }; - resolver.writeTypeOfExpression(expr, enclosingDeclaration, 4 /* UseTypeOfFunction */ | 2048 /* UseTypeAliasValue */ | 16384 /* WriteClassExpressionAsTypeLiteral */, writer); + resolver.writeTypeOfExpression(expr, enclosingDeclaration, 4 /* UseTypeOfFunction */ | 16384 /* WriteClassExpressionAsTypeLiteral */, writer); write(";"); writeLine(); return tempVarName; @@ -65898,6 +66259,10 @@ var ts; return ts.forEach(node.declarationList.declarations, function (varDeclaration) { return resolver.isDeclarationVisible(varDeclaration); }); } function writeVariableStatement(node) { + // If binding pattern doesn't have name, then there is nothing to be emitted for declaration file i.e. const [,] = [1,2]. + if (ts.every(node.declarationList && node.declarationList.declarations, function (decl) { return decl.name && ts.isEmptyBindingPattern(decl.name); })) { + return; + } emitJsDocComments(node); emitModuleElementDeclarationFlags(node); if (ts.isLet(node.declarationList)) { @@ -67437,7 +67802,9 @@ var ts; if (!(ts.getEmitFlags(node) & 131072 /* NoIndentation */)) { var dotRangeStart = node.expression.end; var dotRangeEnd = ts.skipTrivia(currentSourceFile.text, node.expression.end) + 1; - var dotToken = { kind: 23 /* DotToken */, pos: dotRangeStart, end: dotRangeEnd }; + var dotToken = ts.createToken(23 /* DotToken */); + dotToken.pos = dotRangeStart; + dotToken.end = dotRangeEnd; indentBeforeDot = needsIndentation(node, node.expression, dotToken); indentAfterDot = needsIndentation(node, dotToken, node.name); } @@ -67566,7 +67933,9 @@ var ts; var indentAfterOperator = needsIndentation(node, node.operatorToken, node.right); emitExpression(node.left); increaseIndentIf(indentBeforeOperator, isCommaOperator ? " " : undefined); + emitLeadingCommentsOfPosition(node.operatorToken.pos); writeTokenNode(node.operatorToken); + emitTrailingCommentsOfPosition(node.operatorToken.end, /*prefixSpace*/ true); // Binary operators should have a space before the comment starts increaseIndentIf(indentAfterOperator, " "); emitExpression(node.right); decreaseIndentIf(indentBeforeOperator, indentAfterOperator); @@ -67760,8 +68129,19 @@ var ts; emitWithPrefix(" ", node.label); write(";"); } + function emitTokenWithComment(token, pos, contextNode) { + var node = contextNode && ts.getParseTreeNode(contextNode); + if (node && node.kind === contextNode.kind) { + pos = ts.skipTrivia(currentSourceFile.text, pos); + } + pos = writeToken(token, pos, /*contextNode*/ contextNode); + if (node && node.kind === contextNode.kind) { + emitTrailingCommentsOfPosition(pos, /*prefixSpace*/ true); + } + return pos; + } function emitReturnStatement(node) { - writeToken(96 /* ReturnKeyword */, node.pos, /*contextNode*/ node); + emitTokenWithComment(96 /* ReturnKeyword */, node.pos, /*contextNode*/ node); emitExpressionWithPrefix(" ", node.expression); write(";"); } @@ -68237,10 +68617,12 @@ var ts; function emitCatchClause(node) { var openParenPos = writeToken(74 /* CatchKeyword */, node.pos); write(" "); - writeToken(19 /* OpenParenToken */, openParenPos); - emit(node.variableDeclaration); - writeToken(20 /* CloseParenToken */, node.variableDeclaration ? node.variableDeclaration.end : openParenPos); - write(" "); + if (node.variableDeclaration) { + writeToken(19 /* OpenParenToken */, openParenPos); + emit(node.variableDeclaration); + writeToken(20 /* CloseParenToken */, node.variableDeclaration.end); + write(" "); + } emit(node.block); } // @@ -69520,6 +69902,14 @@ var ts; var loader_2 = function (typesRef, containingFile) { return ts.resolveTypeReferenceDirective(typesRef, containingFile, options, host).resolvedTypeReferenceDirective; }; resolveTypeReferenceDirectiveNamesWorker = function (typeReferenceDirectiveNames, containingFile) { return loadWithLocalCache(checkAllDefined(typeReferenceDirectiveNames), containingFile, loader_2); }; } + // Map from a stringified PackageId to the source file with that id. + // Only one source file may have a given packageId. Others become redirects (see createRedirectSourceFile). + // `packageIdToSourceFile` is only used while building the program, while `sourceFileToPackageName` and `isSourceFileTargetOfRedirect` are kept around. + var packageIdToSourceFile = ts.createMap(); + // Maps from a SourceFile's `.path` to the name of the package it was imported with. + var sourceFileToPackageName = ts.createMap(); + // See `sourceFileIsRedirectedTo`. + var redirectTargetsSet = ts.createMap(); var filesByName = ts.createMap(); // stores 'filename -> file association' ignoring case // used to track cases when two file names differ only in casing @@ -69588,6 +69978,8 @@ var ts; isSourceFileFromExternalLibrary: isSourceFileFromExternalLibrary, dropDiagnosticsProducingTypeChecker: dropDiagnosticsProducingTypeChecker, getSourceFileFromReference: getSourceFileFromReference, + sourceFileToPackageName: sourceFileToPackageName, + redirectTargetsSet: redirectTargetsSet, }; verifyCompilerOptions(); ts.performance.mark("afterProgram"); @@ -69780,17 +70172,57 @@ var ts; var filePaths = []; var modifiedSourceFiles = []; oldProgram.structureIsReused = 2 /* Completely */; - for (var _i = 0, _a = oldProgram.getSourceFiles(); _i < _a.length; _i++) { - var oldSourceFile = _a[_i]; + var oldSourceFiles = oldProgram.getSourceFiles(); + var SeenPackageName; + (function (SeenPackageName) { + SeenPackageName[SeenPackageName["Exists"] = 0] = "Exists"; + SeenPackageName[SeenPackageName["Modified"] = 1] = "Modified"; + })(SeenPackageName || (SeenPackageName = {})); + var seenPackageNames = ts.createMap(); + for (var _i = 0, oldSourceFiles_1 = oldSourceFiles; _i < oldSourceFiles_1.length; _i++) { + var oldSourceFile = oldSourceFiles_1[_i]; var newSourceFile = host.getSourceFileByPath ? host.getSourceFileByPath(oldSourceFile.fileName, oldSourceFile.path, options.target) : host.getSourceFile(oldSourceFile.fileName, options.target); if (!newSourceFile) { return oldProgram.structureIsReused = 0 /* Not */; } + ts.Debug.assert(!newSourceFile.redirectInfo, "Host should not return a redirect source file from `getSourceFile`"); + var fileChanged = void 0; + if (oldSourceFile.redirectInfo) { + // We got `newSourceFile` by path, so it is actually for the unredirected file. + // This lets us know if the unredirected file has changed. If it has we should break the redirect. + if (newSourceFile !== oldSourceFile.redirectInfo.unredirected) { + // Underlying file has changed. Might not redirect anymore. Must rebuild program. + return oldProgram.structureIsReused = 0 /* Not */; + } + fileChanged = false; + newSourceFile = oldSourceFile; // Use the redirect. + } + else if (oldProgram.redirectTargetsSet.has(oldSourceFile.path)) { + // If a redirected-to source file changes, the redirect may be broken. + if (newSourceFile !== oldSourceFile) { + return oldProgram.structureIsReused = 0 /* Not */; + } + fileChanged = false; + } + else { + fileChanged = newSourceFile !== oldSourceFile; + } newSourceFile.path = oldSourceFile.path; filePaths.push(newSourceFile.path); - if (oldSourceFile !== newSourceFile) { + var packageName = oldProgram.sourceFileToPackageName.get(oldSourceFile.path); + if (packageName !== undefined) { + // If there are 2 different source files for the same package name and at least one of them changes, + // they might become redirects. So we must rebuild the program. + var prevKind = seenPackageNames.get(packageName); + var newKind = fileChanged ? 1 /* Modified */ : 0 /* Exists */; + if ((prevKind !== undefined && newKind === 1 /* Modified */) || prevKind === 1 /* Modified */) { + return oldProgram.structureIsReused = 0 /* Not */; + } + seenPackageNames.set(packageName, newKind); + } + if (fileChanged) { // The `newSourceFile` object was created for the new program. if (oldSourceFile.hasNoDefaultLib !== newSourceFile.hasNoDefaultLib) { // value of no-default-lib has changed @@ -69831,8 +70263,8 @@ var ts; } modifiedFilePaths = modifiedSourceFiles.map(function (f) { return f.newFile.path; }); // try to verify results of module resolution - for (var _b = 0, modifiedSourceFiles_1 = modifiedSourceFiles; _b < modifiedSourceFiles_1.length; _b++) { - var _c = modifiedSourceFiles_1[_b], oldSourceFile = _c.oldFile, newSourceFile = _c.newFile; + for (var _a = 0, modifiedSourceFiles_1 = modifiedSourceFiles; _a < modifiedSourceFiles_1.length; _a++) { + var _b = modifiedSourceFiles_1[_a], oldSourceFile = _b.oldFile, newSourceFile = _b.newFile; var newSourceFilePath = ts.getNormalizedAbsolutePath(newSourceFile.fileName, currentDirectory); if (resolveModuleNamesWorker) { var moduleNames = ts.map(ts.concatenate(newSourceFile.imports, newSourceFile.moduleAugmentations), getTextOfLiteral); @@ -69875,8 +70307,8 @@ var ts; if (oldProgram.getMissingFilePaths().some(function (missingFilePath) { return host.fileExists(missingFilePath); })) { return oldProgram.structureIsReused = 1 /* SafeModules */; } - for (var _d = 0, _e = oldProgram.getMissingFilePaths(); _d < _e.length; _d++) { - var p = _e[_d]; + for (var _c = 0, _d = oldProgram.getMissingFilePaths(); _c < _d.length; _c++) { + var p = _d[_c]; filesByName.set(p, undefined); } // update fileName -> file mapping @@ -69885,11 +70317,13 @@ var ts; } files = newSourceFiles; fileProcessingDiagnostics = oldProgram.getFileProcessingDiagnostics(); - for (var _f = 0, modifiedSourceFiles_2 = modifiedSourceFiles; _f < modifiedSourceFiles_2.length; _f++) { - var modifiedFile = modifiedSourceFiles_2[_f]; + for (var _e = 0, modifiedSourceFiles_2 = modifiedSourceFiles; _e < modifiedSourceFiles_2.length; _e++) { + var modifiedFile = modifiedSourceFiles_2[_e]; fileProcessingDiagnostics.reattachFileDiagnostics(modifiedFile.newFile); } resolvedTypeReferenceDirectives = oldProgram.getResolvedTypeReferenceDirectives(); + sourceFileToPackageName = oldProgram.sourceFileToPackageName; + redirectTargetsSet = oldProgram.redirectTargetsSet; return oldProgram.structureIsReused = 2 /* Completely */; } function getEmitHost(writeFileCallback) { @@ -70436,7 +70870,7 @@ var ts; } /** This has side effects through `findSourceFile`. */ function processSourceFile(fileName, isDefaultLib, refFile, refPos, refEnd) { - getSourceFileFromReferenceWorker(fileName, function (fileName) { return findSourceFile(fileName, toPath(fileName), isDefaultLib, refFile, refPos, refEnd); }, function (diagnostic) { + getSourceFileFromReferenceWorker(fileName, function (fileName) { return findSourceFile(fileName, toPath(fileName), isDefaultLib, refFile, refPos, refEnd, /*packageId*/ undefined); }, function (diagnostic) { var args = []; for (var _i = 1; _i < arguments.length; _i++) { args[_i - 1] = arguments[_i]; @@ -70453,8 +70887,25 @@ var ts; fileProcessingDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.File_name_0_differs_from_already_included_file_name_1_only_in_casing, fileName, existingFileName)); } } + function createRedirectSourceFile(redirectTarget, unredirected, fileName, path) { + var redirect = Object.create(redirectTarget); + redirect.fileName = fileName; + redirect.path = path; + redirect.redirectInfo = { redirectTarget: redirectTarget, unredirected: unredirected }; + Object.defineProperties(redirect, { + id: { + get: function () { return this.redirectInfo.redirectTarget.id; }, + set: function (value) { this.redirectInfo.redirectTarget.id = value; }, + }, + symbol: { + get: function () { return this.redirectInfo.redirectTarget.symbol; }, + set: function (value) { this.redirectInfo.redirectTarget.symbol = value; }, + }, + }); + return redirect; + } // Get source file from normalized fileName - function findSourceFile(fileName, path, isDefaultLib, refFile, refPos, refEnd) { + function findSourceFile(fileName, path, isDefaultLib, refFile, refPos, refEnd, packageId) { if (filesByName.has(path)) { var file_1 = filesByName.get(path); // try to check if we've already seen this file but with a different casing in path @@ -70490,6 +70941,25 @@ var ts; fileProcessingDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_read_file_0_Colon_1, fileName, hostErrorMessage)); } }); + if (packageId) { + var packageIdKey = packageId.name + "@" + packageId.version; + var fileFromPackageId = packageIdToSourceFile.get(packageIdKey); + if (fileFromPackageId) { + // Some other SourceFile already exists with this package name and version. + // Instead of creating a duplicate, just redirect to the existing one. + var dupFile = createRedirectSourceFile(fileFromPackageId, file, fileName, path); + redirectTargetsSet.set(fileFromPackageId.path, true); + filesByName.set(path, dupFile); + sourceFileToPackageName.set(path, packageId.name); + files.push(dupFile); + return dupFile; + } + else if (file) { + // This is the first source file to have this packageId. + packageIdToSourceFile.set(packageIdKey, file); + sourceFileToPackageName.set(path, packageId.name); + } + } filesByName.set(path, file); if (file) { sourceFilesFoundSearchingNodeModules.set(path, currentNodeModulesDepth > 0); @@ -70630,7 +71100,7 @@ var ts; else if (shouldAddFile) { var path = toPath(resolvedFileName); var pos = ts.skipTrivia(file.text, file.imports[i].pos); - findSourceFile(resolvedFileName, path, /*isDefaultLib*/ false, file, pos, file.imports[i].end); + findSourceFile(resolvedFileName, path, /*isDefaultLib*/ false, file, pos, file.imports[i].end, resolution.packageId); } if (isFromNodeModulesSearch) { currentNodeModulesDepth--; @@ -70785,8 +71255,8 @@ var ts; } // there has to be common source directory if user specified --outdir || --sourceRoot // if user specified --mapRoot, there needs to be common source directory if there would be multiple files being emitted - if (options.outDir || - options.sourceRoot || + if (options.outDir || // there is --outDir specified + options.sourceRoot || // there is --sourceRoot specified options.mapRoot) { // Precalculate and cache the common source directory var dir = getCommonSourceDirectory(); @@ -71349,6 +71819,12 @@ var ts; category: ts.Diagnostics.Module_Resolution_Options, description: ts.Diagnostics.Allow_default_imports_from_modules_with_no_default_export_This_does_not_affect_code_emit_just_typechecking }, + { + name: "preserveSymlinks", + type: "boolean", + category: ts.Diagnostics.Module_Resolution_Options, + description: ts.Diagnostics.Do_not_resolve_the_real_path_of_symlinks, + }, // Source Maps { name: "sourceRoot", @@ -72006,7 +72482,7 @@ var ts; if (option && typeof option.type !== "string") { var customOption = option; // Validate custom option type - if (!customOption.type.has(text)) { + if (!customOption.type.has(text.toLowerCase())) { errors.push(createDiagnosticForInvalidCustomType(customOption, function (message, arg0, arg1) { return ts.createDiagnosticForNodeInSourceFile(sourceFile, valueExpression, message, arg0, arg1); })); } } @@ -72306,13 +72782,10 @@ var ts; } } else { - // If no includes were specified, exclude common package folders and the outDir - var specs = includeSpecs ? [] : ["node_modules", "bower_components", "jspm_packages"]; var outDir = raw["compilerOptions"] && raw["compilerOptions"]["outDir"]; if (outDir) { - specs.push(outDir); + excludeSpecs = [outDir]; } - excludeSpecs = specs; } if (fileNames === undefined && includeSpecs === undefined) { includeSpecs = ["**/*"]; @@ -72573,7 +73046,7 @@ var ts; return value; } else if (typeof option.type !== "string") { - return option.type.get(value); + return option.type.get(typeof value === "string" ? value.toLowerCase() : value); } return normalizeNonListOptionValue(option, basePath, value); } @@ -72748,23 +73221,13 @@ var ts; }; } function validateSpecs(specs, errors, allowTrailingRecursion, jsonSourceFile, specKey) { - var validSpecs = []; - for (var _i = 0, specs_1 = specs; _i < specs_1.length; _i++) { - var spec = specs_1[_i]; - if (!allowTrailingRecursion && invalidTrailingRecursionPattern.test(spec)) { - errors.push(createDiagnostic(ts.Diagnostics.File_specification_cannot_end_in_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0, spec)); + return specs.filter(function (spec) { + var diag = specToDiagnostic(spec, allowTrailingRecursion); + if (diag !== undefined) { + errors.push(createDiagnostic(diag, spec)); } - else if (invalidMultipleRecursionPatterns.test(spec)) { - errors.push(createDiagnostic(ts.Diagnostics.File_specification_cannot_contain_multiple_recursive_directory_wildcards_Asterisk_Asterisk_Colon_0, spec)); - } - else if (invalidDotDotAfterRecursiveWildcardPattern.test(spec)) { - errors.push(createDiagnostic(ts.Diagnostics.File_specification_cannot_contain_a_parent_directory_that_appears_after_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0, spec)); - } - else { - validSpecs.push(spec); - } - } - return validSpecs; + return diag === undefined; + }); function createDiagnostic(message, spec) { if (jsonSourceFile && jsonSourceFile.jsonObject) { for (var _i = 0, _a = ts.getPropertyAssignment(jsonSourceFile.jsonObject, specKey); _i < _a.length; _i++) { @@ -72782,6 +73245,17 @@ var ts; return ts.createCompilerDiagnostic(message, spec); } } + function specToDiagnostic(spec, allowTrailingRecursion) { + if (!allowTrailingRecursion && invalidTrailingRecursionPattern.test(spec)) { + return ts.Diagnostics.File_specification_cannot_end_in_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0; + } + else if (invalidMultipleRecursionPatterns.test(spec)) { + return ts.Diagnostics.File_specification_cannot_contain_multiple_recursive_directory_wildcards_Asterisk_Asterisk_Colon_0; + } + else if (invalidDotDotAfterRecursiveWildcardPattern.test(spec)) { + return ts.Diagnostics.File_specification_cannot_contain_a_parent_directory_that_appears_after_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0; + } + } /** * Gets directories in a set of include patterns that should be watched for changes. */ @@ -72945,7 +73419,7 @@ var ts; (function (ts) { var ScriptSnapshot; (function (ScriptSnapshot) { - var StringScriptSnapshot = (function () { + var StringScriptSnapshot = /** @class */ (function () { function StringScriptSnapshot(text) { this.text = text; } @@ -72969,7 +73443,7 @@ var ts; } ScriptSnapshot.fromString = fromString; })(ScriptSnapshot = ts.ScriptSnapshot || (ts.ScriptSnapshot = {})); - var TextChange = (function () { + var TextChange = /** @class */ (function () { function TextChange() { } return TextChange; @@ -73831,8 +74305,14 @@ var ts; } } ts.findNextToken = findNextToken; + /** + * Finds the rightmost token satisfying `token.end <= position`, + * excluding `JsxText` tokens containing only whitespace. + */ function findPrecedingToken(position, sourceFile, startNode, includeJsDoc) { - return find(startNode || sourceFile); + var result = find(startNode || sourceFile); + ts.Debug.assert(!(result && isWhiteSpaceOnlyJsxText(result))); + return result; function findRightmostToken(n) { if (ts.isToken(n)) { return n; @@ -73848,18 +74328,16 @@ var ts; var children = n.getChildren(); for (var i = 0; i < children.length; i++) { var child = children[i]; - // 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 === 10 /* JsxText */)) { + // Note that the span of a node's tokens is [node.getStart(...), node.end). + // Given that `position < child.end` and child has constituent tokens, we distinguish these cases: + // 1) `position` precedes `child`'s tokens or `child` has no tokens (ie: in a comment or whitespace preceding `child`): + // we need to find the last token in a previous child. + // 2) `position` is within the same span: we recurse on `child`. + if (position < child.end) { var start = child.getStart(sourceFile, includeJsDoc); - var lookInPreviousChild = (start >= position) || - (child.kind === 10 /* JsxText */ && start === child.end); // whitespace only JsxText + var lookInPreviousChild = (start >= position) || // cursor in the leading trivia + !nodeHasTokens(child) || + isWhiteSpaceOnlyJsxText(child); if (lookInPreviousChild) { // actual start of the node is past the position - previous token should be at the end of previous child var candidate = findRightmostChildNodeWithTokens(children, /*exclusiveStartPosition*/ i); @@ -73881,10 +74359,16 @@ var ts; return candidate && findRightmostToken(candidate); } } - /// finds last node that is considered as candidate for search (isCandidate(node) === true) starting from 'exclusiveStartPosition' + /** + * Finds the rightmost child to the left of `children[exclusiveStartPosition]` which is a non-all-whitespace token or has constituent tokens. + */ function findRightmostChildNodeWithTokens(children, exclusiveStartPosition) { for (var i = exclusiveStartPosition - 1; i >= 0; i--) { - if (nodeHasTokens(children[i])) { + var child = children[i]; + if (isWhiteSpaceOnlyJsxText(child)) { + ts.Debug.assert(i > 0, "`JsxText` tokens should not be the first child of `JsxElement | JsxSelfClosingElement`"); + } + else if (nodeHasTokens(children[i])) { return children[i]; } } @@ -73942,6 +74426,10 @@ var ts; return false; } ts.isInsideJsxElementOrAttribute = isInsideJsxElementOrAttribute; + function isWhiteSpaceOnlyJsxText(node) { + return ts.isJsxText(node) && node.containsOnlyWhiteSpaces; + } + ts.isWhiteSpaceOnlyJsxText = isWhiteSpaceOnlyJsxText; function isInTemplateString(sourceFile, position) { var token = getTokenAtPosition(sourceFile, position, /*includeJsDocComment*/ false); return ts.isTemplateLiteralKind(token.kind) && position > token.getStart(sourceFile); @@ -73954,39 +74442,9 @@ var ts; * @param predicate Additional predicate to test on the comment range. */ function isInComment(sourceFile, position, tokenAtPosition, predicate) { - if (tokenAtPosition === void 0) { tokenAtPosition = getTokenAtPosition(sourceFile, position, /*includeJsDocComment*/ false); } - return position <= tokenAtPosition.getStart(sourceFile) && - (isInCommentRange(ts.getLeadingCommentRanges(sourceFile.text, tokenAtPosition.pos)) || - isInCommentRange(ts.getTrailingCommentRanges(sourceFile.text, tokenAtPosition.pos))); - function isInCommentRange(commentRanges) { - return ts.forEach(commentRanges, function (c) { return isPositionInCommentRange(c, position, sourceFile.text) && (!predicate || predicate(c)); }); - } + return !!ts.formatting.getRangeOfEnclosingComment(sourceFile, position, /*onlyMultiLine*/ false, /*precedingToken*/ undefined, tokenAtPosition, predicate); } ts.isInComment = isInComment; - function isPositionInCommentRange(_a, position, text) { - var pos = _a.pos, end = _a.end, kind = _a.kind; - if (pos < position && position < end) { - return true; - } - else if (position === end) { - // The end marker of a single-line comment does not include the newline character. - // In the following case, we are inside a comment (^ denotes the cursor position): - // - // // asdf ^\n - // - // But for multi-line comments, we don't want to be inside the comment in the following case: - // - // /* asdf */^ - // - // Internally, we represent the end of the comment at the newline and closing '/', respectively. - return kind === 2 /* SingleLineCommentTrivia */ || - // true for unterminated multi-line comment - !(text.charCodeAt(end - 1) === 47 /* slash */ && text.charCodeAt(end - 2) === 42 /* asterisk */); - } - else { - return false; - } - } function hasDocComment(sourceFile, position) { var token = getTokenAtPosition(sourceFile, position, /*includeJsDocComment*/ false); // First, we have to see if this position actually landed in a comment. @@ -74000,7 +74458,7 @@ var ts; ts.hasDocComment = hasDocComment; function nodeHasTokens(n) { // If we have a token or node that has a non-zero width, it must have tokens. - // Note, that getWidth() does not take trivia into account. + // Note: getWidth() does not take trivia into account. return n.getWidth() !== 0; } function getNodeModifiers(node) { @@ -74357,6 +74815,7 @@ var ts; } ts.symbolToDisplayParts = symbolToDisplayParts; function signatureToDisplayParts(typechecker, signature, enclosingDeclaration, flags) { + flags |= 65536 /* UseAliasDefinedOutsideCurrentScope */; return mapToDisplayParts(function (writer) { typechecker.getSymbolDisplayBuilder().buildSignatureDisplay(signature, writer, enclosingDeclaration, flags); }); @@ -74666,11 +75125,11 @@ var ts; templateStack.pop(); } else { - ts.Debug.assert(token === 15 /* TemplateMiddle */, "Should have been a template middle. Was " + token); + ts.Debug.assertEqual(token, 15 /* TemplateMiddle */, "Should have been a template middle."); } } else { - ts.Debug.assert(lastTemplateStackToken === 17 /* OpenBraceToken */, "Should have been an open brace. Was: " + token); + ts.Debug.assertEqual(lastTemplateStackToken, 17 /* OpenBraceToken */, "Should have been an open brace"); templateStack.pop(); } } @@ -76652,7 +77111,7 @@ var ts; if (!typeForObject) return false; // In a binding pattern, get only known properties. Everywhere else we will get all possible properties. - typeMembers = typeChecker.getPropertiesOfType(typeForObject); + typeMembers = typeChecker.getPropertiesOfType(typeForObject).filter(function (symbol) { return !(ts.getDeclarationModifierFlagsFromSymbol(symbol) & 24 /* NonPublicAccessibilityModifier */); }); existingMembers = objectLikeContainer.elements; } } @@ -76916,11 +77375,11 @@ var ts; return containingNodeKind === 226 /* VariableDeclaration */ || containingNodeKind === 227 /* VariableDeclarationList */ || containingNodeKind === 208 /* VariableStatement */ || - containingNodeKind === 232 /* EnumDeclaration */ || + containingNodeKind === 232 /* EnumDeclaration */ || // enum a { foo, | isFunctionLikeButNotConstructor(containingNodeKind) || - containingNodeKind === 230 /* InterfaceDeclaration */ || - containingNodeKind === 175 /* ArrayBindingPattern */ || - containingNodeKind === 231 /* TypeAliasDeclaration */ || + containingNodeKind === 230 /* InterfaceDeclaration */ || // interface A undefined); => should get use to the declaration in file "./foo" + // + // function bar(onfulfilled: (value: T) => void) { //....} + // interface Test { + // pr/*destination*/op1: number + // } + // bar(({pr/*goto*/op1})=>{}); + if (ts.isPropertyName(node) && ts.isBindingElement(node.parent) && ts.isObjectBindingPattern(node.parent.parent) && + (node === (node.parent.propertyName || node.parent.name))) { + var type = typeChecker.getTypeAtLocation(node.parent.parent); + if (type) { + var propSymbols = ts.getPropertySymbolsFromType(type, node); + if (propSymbols) { + return ts.flatMap(propSymbols, function (propSymbol) { return getDefinitionFromSymbol(typeChecker, propSymbol, node); }); + } + } + } // If the current location we want to find its definition is in an object literal, try to get the contextual type for the // object literal, lookup the property symbol in the contextual type, and use this for goto-definition. // For example @@ -80614,12 +81104,20 @@ var ts; "crypto", "stream", "util", "assert", "tty", "domain", "constants", "process", "v8", "timers", "console" ]; - var nodeCoreModules = ts.arrayToMap(JsTyping.nodeCoreModuleList, function (x) { return x; }); + var nodeCoreModules = ts.arrayToSet(JsTyping.nodeCoreModuleList); function loadSafeList(host, safeListPath) { var result = ts.readConfigFile(safeListPath, function (path) { return host.readFile(path); }); return ts.createMapFromTemplate(result.config); } JsTyping.loadSafeList = loadSafeList; + function loadTypesMap(host, typesMapPath) { + var result = ts.readConfigFile(typesMapPath, function (path) { return host.readFile(path); }); + if (result.config) { + return ts.createMapFromTemplate(result.config.simpleMap); + } + return undefined; + } + JsTyping.loadTypesMap = loadTypesMap; /** * @param host is the object providing I/O related operations. * @param fileNames are the file names that belong to the same project @@ -80812,8 +81310,8 @@ var ts; if (!matches) { return; // continue to next named declarations } - for (var _i = 0, declarations_12 = declarations; _i < declarations_12.length; _i++) { - var declaration = declarations_12[_i]; + for (var _i = 0, declarations_11 = declarations; _i < declarations_11.length; _i++) { + var declaration = declarations_11[_i]; // It was a match! If the pattern has dots in it, then also see if the // declaration container matches as well. if (patternMatcher.patternContainsDots) { @@ -81549,13 +82047,18 @@ var ts; (function (ts) { var OutliningElementsCollector; (function (OutliningElementsCollector) { + var collapseText = "..."; + var maxDepth = 20; function collectElements(sourceFile, cancellationToken) { var elements = []; - var collapseText = "..."; - function addOutliningSpan(hintSpanNode, startElement, endElement, autoCollapse) { + var depth = 0; + walk(sourceFile); + return elements; + /** If useFullStart is true, then the collapsing span includes leading whitespace, including linebreaks. */ + function addOutliningSpan(hintSpanNode, startElement, endElement, autoCollapse, useFullStart) { if (hintSpanNode && startElement && endElement) { var span_13 = { - textSpan: ts.createTextSpanFromBounds(startElement.pos, endElement.end), + textSpan: ts.createTextSpanFromBounds(useFullStart ? startElement.getFullStart() : startElement.getStart(), endElement.getEnd()), hintSpan: ts.createTextSpanFromNode(hintSpanNode, sourceFile), bannerText: collapseText, autoCollapse: autoCollapse, @@ -81619,8 +82122,6 @@ var ts; function autoCollapse(node) { return ts.isFunctionBlock(node) && node.parent.kind !== 187 /* ArrowFunction */; } - var depth = 0; - var maxDepth = 20; function walk(n) { cancellationToken.throwIfCancellationRequested(); if (depth > maxDepth) { @@ -81633,8 +82134,8 @@ var ts; case 207 /* Block */: if (!ts.isFunctionBlock(n)) { var parent = n.parent; - var openBrace = ts.findChildOfKind(n, 17 /* OpenBraceToken */, sourceFile); - var closeBrace = ts.findChildOfKind(n, 18 /* CloseBraceToken */, sourceFile); + var openBrace_1 = ts.findChildOfKind(n, 17 /* OpenBraceToken */, sourceFile); + var closeBrace_1 = ts.findChildOfKind(n, 18 /* CloseBraceToken */, sourceFile); // Check if the block is standalone, or 'attached' to some parent statement. // If the latter, we want to collapse the block, but consider its hint span // to be the entire span of the parent. @@ -81646,20 +82147,20 @@ var ts; parent.kind === 213 /* WhileStatement */ || parent.kind === 220 /* WithStatement */ || parent.kind === 260 /* CatchClause */) { - addOutliningSpan(parent, openBrace, closeBrace, autoCollapse(n)); + addOutliningSpan(parent, openBrace_1, closeBrace_1, autoCollapse(n), /*useFullStart*/ true); break; } if (parent.kind === 224 /* TryStatement */) { // Could be the try-block, or the finally-block. var tryStatement = parent; if (tryStatement.tryBlock === n) { - addOutliningSpan(parent, openBrace, closeBrace, autoCollapse(n)); + addOutliningSpan(parent, openBrace_1, closeBrace_1, autoCollapse(n), /*useFullStart*/ true); break; } else if (tryStatement.finallyBlock === n) { var finallyKeyword = ts.findChildOfKind(tryStatement, 87 /* FinallyKeyword */, sourceFile); if (finallyKeyword) { - addOutliningSpan(finallyKeyword, openBrace, closeBrace, autoCollapse(n)); + addOutliningSpan(finallyKeyword, openBrace_1, closeBrace_1, autoCollapse(n), /*useFullStart*/ true); break; } } @@ -81678,33 +82179,38 @@ var ts; } // falls through case 234 /* ModuleBlock */: { - var openBrace = ts.findChildOfKind(n, 17 /* OpenBraceToken */, sourceFile); - var closeBrace = ts.findChildOfKind(n, 18 /* CloseBraceToken */, sourceFile); - addOutliningSpan(n.parent, openBrace, closeBrace, autoCollapse(n)); + var openBrace_2 = ts.findChildOfKind(n, 17 /* OpenBraceToken */, sourceFile); + var closeBrace_2 = ts.findChildOfKind(n, 18 /* CloseBraceToken */, sourceFile); + addOutliningSpan(n.parent, openBrace_2, closeBrace_2, autoCollapse(n), /*useFullStart*/ true); break; } case 229 /* ClassDeclaration */: case 230 /* InterfaceDeclaration */: case 232 /* EnumDeclaration */: - case 178 /* ObjectLiteralExpression */: case 235 /* CaseBlock */: { - var openBrace = ts.findChildOfKind(n, 17 /* OpenBraceToken */, sourceFile); - var closeBrace = ts.findChildOfKind(n, 18 /* CloseBraceToken */, sourceFile); - addOutliningSpan(n, openBrace, closeBrace, autoCollapse(n)); + var openBrace_3 = ts.findChildOfKind(n, 17 /* OpenBraceToken */, sourceFile); + var closeBrace_3 = ts.findChildOfKind(n, 18 /* CloseBraceToken */, sourceFile); + addOutliningSpan(n, openBrace_3, closeBrace_3, autoCollapse(n), /*useFullStart*/ true); break; } + // If the block has no leading keywords and is inside an array literal, + // we only want to collapse the span of the block. + // Otherwise, the collapsed section will include the end of the previous line. + case 178 /* ObjectLiteralExpression */: + var openBrace = ts.findChildOfKind(n, 17 /* OpenBraceToken */, sourceFile); + var closeBrace = ts.findChildOfKind(n, 18 /* CloseBraceToken */, sourceFile); + addOutliningSpan(n, openBrace, closeBrace, autoCollapse(n), /*useFullStart*/ !ts.isArrayLiteralExpression(n.parent)); + break; case 177 /* ArrayLiteralExpression */: var openBracket = ts.findChildOfKind(n, 21 /* OpenBracketToken */, sourceFile); var closeBracket = ts.findChildOfKind(n, 22 /* CloseBracketToken */, sourceFile); - addOutliningSpan(n, openBracket, closeBracket, autoCollapse(n)); + addOutliningSpan(n, openBracket, closeBracket, autoCollapse(n), /*useFullStart*/ !ts.isArrayLiteralExpression(n.parent)); break; } depth++; ts.forEachChild(n, walk); depth--; } - walk(sourceFile); - return elements; } OutliningElementsCollector.collectElements = collectElements; })(OutliningElementsCollector = ts.OutliningElementsCollector || (ts.OutliningElementsCollector = {})); @@ -82760,8 +83266,8 @@ var ts; var nameToDeclarations = sourceFile.getNamedDeclarations(); var declarations = nameToDeclarations.get(name.text); if (declarations) { - for (var _b = 0, declarations_13 = declarations; _b < declarations_13.length; _b++) { - var declaration = declarations_13[_b]; + for (var _b = 0, declarations_12 = declarations; _b < declarations_12.length; _b++) { + var declaration = declarations_12[_b]; var symbol = declaration.symbol; if (symbol) { var type = typeChecker.getTypeOfSymbolAtLocation(symbol, declaration); @@ -82820,7 +83326,9 @@ var ts; } var kind = invocation.typeArguments && invocation.typeArguments.pos === list.pos ? 0 /* TypeArguments */ : 1 /* CallArguments */; var argumentCount = getArgumentCount(list); - ts.Debug.assert(argumentIndex === 0 || argumentIndex < argumentCount, "argumentCount < argumentIndex, " + argumentCount + " < " + argumentIndex); + if (argumentIndex !== 0) { + ts.Debug.assertLessThan(argumentIndex, argumentCount); + } var argumentsSpan = getApplicableSpanForArguments(list, sourceFile); return { kind: kind, invocation: invocation, argumentsSpan: argumentsSpan, argumentIndex: argumentIndex, argumentCount: argumentCount }; } @@ -82942,7 +83450,9 @@ var ts; var argumentCount = tagExpression.template.kind === 13 /* NoSubstitutionTemplateLiteral */ ? 1 : tagExpression.template.templateSpans.length + 1; - ts.Debug.assert(argumentIndex === 0 || argumentIndex < argumentCount, "argumentCount < argumentIndex, " + argumentCount + " < " + argumentIndex); + if (argumentIndex !== 0) { + ts.Debug.assertLessThan(argumentIndex, argumentCount); + } return { kind: 2 /* TaggedTemplateArguments */, invocation: tagExpression, @@ -83060,7 +83570,9 @@ var ts; tags: candidateSignature.getJsDocTags() }; }); - ts.Debug.assert(argumentIndex === 0 || argumentIndex < argumentCount, "argumentCount < argumentIndex, " + argumentCount + " < " + argumentIndex); + if (argumentIndex !== 0) { + ts.Debug.assertLessThan(argumentIndex, argumentCount); + } var selectedItemIndex = candidates.indexOf(resolvedSignature); ts.Debug.assert(selectedItemIndex !== -1); // If candidates is non-empty it should always include bestSignature. We check for an empty candidates before calling this function. return { items: items, applicableSpan: applicableSpan, selectedItemIndex: selectedItemIndex, argumentIndex: argumentIndex, argumentCount: argumentCount }; @@ -83209,114 +83721,112 @@ var ts; } var signature = void 0; type = isThisExpression ? typeChecker.getTypeAtLocation(location) : typeChecker.getTypeOfSymbolAtLocation(symbol.exportSymbol || symbol, location); - if (type) { - if (location.parent && location.parent.kind === 179 /* PropertyAccessExpression */) { - var right = location.parent.name; - // Either the location is on the right of a property access, or on the left and the right is missing - if (right === location || (right && right.getFullWidth() === 0)) { - location = location.parent; + if (location.parent && location.parent.kind === 179 /* PropertyAccessExpression */) { + var right = location.parent.name; + // Either the location is on the right of a property access, or on the left and the right is missing + if (right === location || (right && right.getFullWidth() === 0)) { + location = location.parent; + } + } + // try get the call/construct signature from the type if it matches + var callExpressionLike = void 0; + if (ts.isCallOrNewExpression(location)) { + callExpressionLike = location; + } + else if (ts.isCallExpressionTarget(location) || ts.isNewExpressionTarget(location)) { + callExpressionLike = location.parent; + } + else if (location.parent && ts.isJsxOpeningLikeElement(location.parent) && ts.isFunctionLike(symbol.valueDeclaration)) { + callExpressionLike = location.parent; + } + if (callExpressionLike) { + var candidateSignatures = []; + signature = typeChecker.getResolvedSignature(callExpressionLike, candidateSignatures); + if (!signature && candidateSignatures.length) { + // Use the first candidate: + signature = candidateSignatures[0]; + } + var useConstructSignatures = callExpressionLike.kind === 182 /* NewExpression */ || (ts.isCallExpression(callExpressionLike) && callExpressionLike.expression.kind === 97 /* SuperKeyword */); + var allSignatures = useConstructSignatures ? type.getConstructSignatures() : type.getCallSignatures(); + if (!ts.contains(allSignatures, signature.target) && !ts.contains(allSignatures, signature)) { + // Get the first signature if there is one -- allSignatures may contain + // either the original signature or its target, so check for either + signature = allSignatures.length ? allSignatures[0] : undefined; + } + if (signature) { + if (useConstructSignatures && (symbolFlags & 32 /* Class */)) { + // Constructor + symbolKind = "constructor" /* constructorImplementationElement */; + addPrefixForAnyFunctionOrVar(type.symbol, symbolKind); } - } - // try get the call/construct signature from the type if it matches - var callExpressionLike = void 0; - if (ts.isCallOrNewExpression(location)) { - callExpressionLike = location; - } - else if (ts.isCallExpressionTarget(location) || ts.isNewExpressionTarget(location)) { - callExpressionLike = location.parent; - } - else if (location.parent && ts.isJsxOpeningLikeElement(location.parent) && ts.isFunctionLike(symbol.valueDeclaration)) { - callExpressionLike = location.parent; - } - if (callExpressionLike) { - var candidateSignatures = []; - signature = typeChecker.getResolvedSignature(callExpressionLike, candidateSignatures); - if (!signature && candidateSignatures.length) { - // Use the first candidate: - signature = candidateSignatures[0]; - } - var useConstructSignatures = callExpressionLike.kind === 182 /* NewExpression */ || (ts.isCallExpression(callExpressionLike) && callExpressionLike.expression.kind === 97 /* SuperKeyword */); - var allSignatures = useConstructSignatures ? type.getConstructSignatures() : type.getCallSignatures(); - if (!ts.contains(allSignatures, signature.target) && !ts.contains(allSignatures, signature)) { - // Get the first signature if there is one -- allSignatures may contain - // either the original signature or its target, so check for either - signature = allSignatures.length ? allSignatures[0] : undefined; - } - if (signature) { - if (useConstructSignatures && (symbolFlags & 32 /* Class */)) { - // Constructor - symbolKind = "constructor" /* constructorImplementationElement */; - addPrefixForAnyFunctionOrVar(type.symbol, symbolKind); + else if (symbolFlags & 2097152 /* Alias */) { + symbolKind = "alias" /* alias */; + pushTypePart(symbolKind); + displayParts.push(ts.spacePart()); + if (useConstructSignatures) { + displayParts.push(ts.keywordPart(94 /* NewKeyword */)); + displayParts.push(ts.spacePart()); } - else if (symbolFlags & 2097152 /* Alias */) { - symbolKind = "alias" /* alias */; - pushTypePart(symbolKind); + addFullSymbolName(symbol); + } + else { + addPrefixForAnyFunctionOrVar(symbol, symbolKind); + } + switch (symbolKind) { + case "JSX attribute" /* jsxAttribute */: + case "property" /* memberVariableElement */: + case "var" /* variableElement */: + case "const" /* constElement */: + case "let" /* letElement */: + case "parameter" /* parameterElement */: + case "local var" /* localVariableElement */: + // If it is call or construct signature of lambda's write type name + displayParts.push(ts.punctuationPart(56 /* ColonToken */)); displayParts.push(ts.spacePart()); if (useConstructSignatures) { displayParts.push(ts.keywordPart(94 /* NewKeyword */)); displayParts.push(ts.spacePart()); } - addFullSymbolName(symbol); - } - else { - addPrefixForAnyFunctionOrVar(symbol, symbolKind); - } - switch (symbolKind) { - case "JSX attribute" /* jsxAttribute */: - case "property" /* memberVariableElement */: - case "var" /* variableElement */: - case "const" /* constElement */: - case "let" /* letElement */: - case "parameter" /* parameterElement */: - case "local var" /* localVariableElement */: - // If it is call or construct signature of lambda's write type name - displayParts.push(ts.punctuationPart(56 /* ColonToken */)); - displayParts.push(ts.spacePart()); - if (useConstructSignatures) { - displayParts.push(ts.keywordPart(94 /* NewKeyword */)); - displayParts.push(ts.spacePart()); - } - if (!(type.flags & 32768 /* Object */ && type.objectFlags & 16 /* Anonymous */) && type.symbol) { - ts.addRange(displayParts, ts.symbolToDisplayParts(typeChecker, type.symbol, enclosingDeclaration, /*meaning*/ undefined, 1 /* WriteTypeParametersOrArguments */)); - } - addSignatureDisplayParts(signature, allSignatures, 16 /* WriteArrowStyleSignature */); - break; - default: - // Just signature - addSignatureDisplayParts(signature, allSignatures); - } - hasAddedSymbolInfo = true; + if (!(type.flags & 32768 /* Object */ && type.objectFlags & 16 /* Anonymous */) && type.symbol) { + ts.addRange(displayParts, ts.symbolToDisplayParts(typeChecker, type.symbol, enclosingDeclaration, /*meaning*/ undefined, 1 /* WriteTypeParametersOrArguments */)); + } + addSignatureDisplayParts(signature, allSignatures, 16 /* WriteArrowStyleSignature */); + break; + default: + // Just signature + addSignatureDisplayParts(signature, allSignatures); } + hasAddedSymbolInfo = true; } - else if ((ts.isNameOfFunctionDeclaration(location) && !(symbolFlags & 98304 /* Accessor */)) || - (location.kind === 123 /* ConstructorKeyword */ && location.parent.kind === 152 /* Constructor */)) { - // get the signature from the declaration and write it - var functionDeclaration_1 = location.parent; - // Use function declaration to write the signatures only if the symbol corresponding to this declaration - var locationIsSymbolDeclaration = ts.findDeclaration(symbol, function (declaration) { - return declaration === (location.kind === 123 /* ConstructorKeyword */ ? functionDeclaration_1.parent : functionDeclaration_1); - }); - if (locationIsSymbolDeclaration) { - var allSignatures = functionDeclaration_1.kind === 152 /* Constructor */ ? type.getNonNullableType().getConstructSignatures() : type.getNonNullableType().getCallSignatures(); - if (!typeChecker.isImplementationOfOverload(functionDeclaration_1)) { - signature = typeChecker.getSignatureFromDeclaration(functionDeclaration_1); - } - else { - signature = allSignatures[0]; - } - if (functionDeclaration_1.kind === 152 /* Constructor */) { - // show (constructor) Type(...) signature - symbolKind = "constructor" /* constructorImplementationElement */; - addPrefixForAnyFunctionOrVar(type.symbol, symbolKind); - } - else { - // (function/method) symbol(..signature) - addPrefixForAnyFunctionOrVar(functionDeclaration_1.kind === 155 /* CallSignature */ && - !(type.symbol.flags & 2048 /* TypeLiteral */ || type.symbol.flags & 4096 /* ObjectLiteral */) ? type.symbol : symbol, symbolKind); - } - addSignatureDisplayParts(signature, allSignatures); - hasAddedSymbolInfo = true; + } + else if ((ts.isNameOfFunctionDeclaration(location) && !(symbolFlags & 98304 /* Accessor */)) || // name of function declaration + (location.kind === 123 /* ConstructorKeyword */ && location.parent.kind === 152 /* Constructor */)) { + // get the signature from the declaration and write it + var functionDeclaration_1 = location.parent; + // Use function declaration to write the signatures only if the symbol corresponding to this declaration + var locationIsSymbolDeclaration = ts.find(symbol.declarations, function (declaration) { + return declaration === (location.kind === 123 /* ConstructorKeyword */ ? functionDeclaration_1.parent : functionDeclaration_1); + }); + if (locationIsSymbolDeclaration) { + var allSignatures = functionDeclaration_1.kind === 152 /* Constructor */ ? type.getNonNullableType().getConstructSignatures() : type.getNonNullableType().getCallSignatures(); + if (!typeChecker.isImplementationOfOverload(functionDeclaration_1)) { + signature = typeChecker.getSignatureFromDeclaration(functionDeclaration_1); } + else { + signature = allSignatures[0]; + } + if (functionDeclaration_1.kind === 152 /* Constructor */) { + // show (constructor) Type(...) signature + symbolKind = "constructor" /* constructorImplementationElement */; + addPrefixForAnyFunctionOrVar(type.symbol, symbolKind); + } + else { + // (function/method) symbol(..signature) + addPrefixForAnyFunctionOrVar(functionDeclaration_1.kind === 155 /* CallSignature */ && + !(type.symbol.flags & 2048 /* TypeLiteral */ || type.symbol.flags & 4096 /* ObjectLiteral */) ? type.symbol : symbol, symbolKind); + } + addSignatureDisplayParts(signature, allSignatures); + hasAddedSymbolInfo = true; } } } @@ -83502,7 +84012,9 @@ var ts; symbolFlags & 98304 /* Accessor */ || symbolKind === "method" /* memberFunctionElement */) { var allSignatures = type.getNonNullableType().getCallSignatures(); - addSignatureDisplayParts(allSignatures[0], allSignatures); + if (allSignatures.length) { + addSignatureDisplayParts(allSignatures[0], allSignatures); + } } } } @@ -83676,11 +84188,11 @@ var ts; getSourceFile: function (fileName) { return fileName === ts.normalizePath(inputFileName) ? sourceFile : undefined; }, writeFile: function (name, text) { if (ts.fileExtensionIs(name, ".map")) { - ts.Debug.assert(sourceMapText === undefined, "Unexpected multiple source map outputs for the file '" + name + "'"); + ts.Debug.assertEqual(sourceMapText, undefined, "Unexpected multiple source map outputs, file:", name); sourceMapText = text; } else { - ts.Debug.assert(outputText === undefined, "Unexpected multiple outputs for the file: '" + name + "'"); + ts.Debug.assertEqual(outputText, undefined, "Unexpected multiple outputs, file:", name); outputText = text; } }, @@ -84005,7 +84517,7 @@ var ts; (function (ts) { var formatting; (function (formatting) { - var FormattingContext = (function () { + var FormattingContext = /** @class */ (function () { function FormattingContext(sourceFile, formattingRequestKind, options) { this.sourceFile = sourceFile; this.formattingRequestKind = formattingRequestKind; @@ -84104,7 +84616,7 @@ var ts; (function (ts) { var formatting; (function (formatting) { - var Rule = (function () { + var Rule = /** @class */ (function () { function Rule(Descriptor, Operation, Flag) { if (Flag === void 0) { Flag = 0 /* None */; } this.Descriptor = Descriptor; @@ -84142,7 +84654,7 @@ var ts; (function (ts) { var formatting; (function (formatting) { - var RuleDescriptor = (function () { + var RuleDescriptor = /** @class */ (function () { function RuleDescriptor(LeftTokenRange, RightTokenRange) { this.LeftTokenRange = LeftTokenRange; this.RightTokenRange = RightTokenRange; @@ -84187,7 +84699,7 @@ var ts; (function (ts) { var formatting; (function (formatting) { - var RuleOperation = (function () { + var RuleOperation = /** @class */ (function () { function RuleOperation(Context, Action) { this.Context = Context; this.Action = Action; @@ -84213,7 +84725,7 @@ var ts; (function (ts) { var formatting; (function (formatting) { - var RuleOperationContext = (function () { + var RuleOperationContext = /** @class */ (function () { function RuleOperationContext() { var funcs = []; for (var _i = 0; _i < arguments.length; _i++) { @@ -84248,7 +84760,7 @@ var ts; (function (ts) { var formatting; (function (formatting) { - var Rules = (function () { + var Rules = /** @class */ (function () { function Rules() { /// /// Common Rules @@ -84407,6 +84919,7 @@ var ts; // Insert space after opening and before closing nonempty parenthesis this.SpaceAfterOpenParen = new formatting.Rule(formatting.RuleDescriptor.create3(19 /* OpenParenToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis"), Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); this.SpaceBeforeCloseParen = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 20 /* CloseParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis"), Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); + this.SpaceBetweenOpenParens = new formatting.Rule(formatting.RuleDescriptor.create1(19 /* OpenParenToken */, 19 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis"), Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); this.NoSpaceBetweenParens = new formatting.Rule(formatting.RuleDescriptor.create1(19 /* OpenParenToken */, 20 /* CloseParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); this.NoSpaceAfterOpenParen = new formatting.Rule(formatting.RuleDescriptor.create3(19 /* OpenParenToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis"), Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); this.NoSpaceBeforeCloseParen = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 20 /* CloseParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis"), Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); @@ -84486,7 +84999,7 @@ var ts; this.SpaceAfterComma, this.NoSpaceAfterComma, this.SpaceAfterAnonymousFunctionKeyword, this.NoSpaceAfterAnonymousFunctionKeyword, this.SpaceAfterKeywordInControl, this.NoSpaceAfterKeywordInControl, - this.SpaceAfterOpenParen, this.SpaceBeforeCloseParen, this.NoSpaceBetweenParens, this.NoSpaceAfterOpenParen, this.NoSpaceBeforeCloseParen, + this.SpaceAfterOpenParen, this.SpaceBeforeCloseParen, this.SpaceBetweenOpenParens, this.NoSpaceBetweenParens, this.NoSpaceAfterOpenParen, this.NoSpaceBeforeCloseParen, this.SpaceAfterOpenBracket, this.SpaceBeforeCloseBracket, this.NoSpaceBetweenBrackets, this.NoSpaceAfterOpenBracket, this.NoSpaceBeforeCloseBracket, this.SpaceAfterOpenBrace, this.SpaceBeforeCloseBrace, this.NoSpaceBetweenEmptyBraceBrackets, this.NoSpaceAfterOpenBrace, this.NoSpaceBeforeCloseBrace, this.SpaceAfterTemplateHeadAndMiddle, this.SpaceBeforeTemplateMiddleAndTail, this.NoSpaceAfterTemplateHeadAndMiddle, this.NoSpaceBeforeTemplateMiddleAndTail, @@ -84825,7 +85338,7 @@ var ts; (function (ts) { var formatting; (function (formatting) { - var RulesMap = (function () { + var RulesMap = /** @class */ (function () { function RulesMap() { this.map = []; this.mapRowLength = 0; @@ -84895,7 +85408,7 @@ var ts; RulesPosition[RulesPosition["NoContextRulesSpecific"] = MaskBitSize * 4] = "NoContextRulesSpecific"; RulesPosition[RulesPosition["NoContextRulesAny"] = MaskBitSize * 5] = "NoContextRulesAny"; })(RulesPosition = formatting.RulesPosition || (formatting.RulesPosition = {})); - var RulesBucketConstructionState = (function () { + var RulesBucketConstructionState = /** @class */ (function () { function RulesBucketConstructionState() { //// The Rules list contains all the inserted rules into a rulebucket in the following order: //// 1- Ignore rules with specific token combination @@ -84936,7 +85449,7 @@ var ts; return RulesBucketConstructionState; }()); formatting.RulesBucketConstructionState = RulesBucketConstructionState; - var RulesBucket = (function () { + var RulesBucket = /** @class */ (function () { function RulesBucket() { this.rules = []; } @@ -84985,7 +85498,7 @@ var ts; for (var token = 0 /* FirstToken */; token <= 142 /* LastToken */; token++) { allTokens.push(token); } - var TokenValuesAccess = (function () { + var TokenValuesAccess = /** @class */ (function () { function TokenValuesAccess(tokens) { if (tokens === void 0) { tokens = []; } this.tokens = tokens; @@ -84999,7 +85512,7 @@ var ts; TokenValuesAccess.prototype.isSpecific = function () { return true; }; return TokenValuesAccess; }()); - var TokenSingleValueAccess = (function () { + var TokenSingleValueAccess = /** @class */ (function () { function TokenSingleValueAccess(token) { this.token = token; } @@ -85012,7 +85525,7 @@ var ts; TokenSingleValueAccess.prototype.isSpecific = function () { return true; }; return TokenSingleValueAccess; }()); - var TokenAllAccess = (function () { + var TokenAllAccess = /** @class */ (function () { function TokenAllAccess() { } TokenAllAccess.prototype.GetTokens = function () { @@ -85027,7 +85540,7 @@ var ts; TokenAllAccess.prototype.isSpecific = function () { return false; }; return TokenAllAccess; }()); - var TokenAllExceptAccess = (function () { + var TokenAllExceptAccess = /** @class */ (function () { function TokenAllExceptAccess(except) { this.except = except; } @@ -85119,7 +85632,7 @@ var ts; (function (ts) { var formatting; (function (formatting) { - var RulesProvider = (function () { + var RulesProvider = /** @class */ (function () { function RulesProvider() { this.globalRules = new formatting.Rules(); var activeRules = this.globalRules.HighPriorityCommonRules.slice(0).concat(this.globalRules.UserConfigurableRules).concat(this.globalRules.LowPriorityCommonRules); @@ -85427,7 +85940,6 @@ var ts; function formatSpanWorker(originalRange, enclosingNode, initialIndentation, delta, formattingScanner, options, rulesProvider, requestKind, rangeContainsError, sourceFile) { // formatting context is used by rules provider var formattingContext = new formatting.FormattingContext(sourceFile, requestKind, options); - var previousRangeHasError; var previousRange; var previousParent; var previousRangeStartLine; @@ -85818,7 +86330,7 @@ var ts; function processRange(range, rangeStart, parent, contextNode, dynamicIndentation) { var rangeHasError = rangeContainsError(range); var lineAdded; - if (!rangeHasError && !previousRangeHasError) { + if (!rangeHasError) { if (!previousRange) { // trim whitespaces starting from the beginning of the span up to the current line var originalStart = sourceFile.getLineAndCharacterOfPosition(originalRange.pos); @@ -85832,7 +86344,6 @@ var ts; previousRange = range; previousParent = parent; previousRangeStartLine = rangeStart.line; - previousRangeHasError = rangeHasError; return lineAdded; } function processPair(currentItem, currentStartLine, currentParent, previousItem, previousStartLine, previousParent, contextNode, dynamicIndentation) { @@ -86038,6 +86549,51 @@ var ts; } } } + /** + * @param precedingToken pass `null` if preceding token was already computed and result was `undefined`. + */ + function getRangeOfEnclosingComment(sourceFile, position, onlyMultiLine, precedingToken, // tslint:disable-line:no-null-keyword + tokenAtPosition, predicate) { + if (tokenAtPosition === void 0) { tokenAtPosition = ts.getTokenAtPosition(sourceFile, position, /*includeJsDocComment*/ false); } + var tokenStart = tokenAtPosition.getStart(sourceFile); + if (tokenStart <= position && position < tokenAtPosition.getEnd()) { + return undefined; + } + if (precedingToken === undefined) { + precedingToken = ts.findPrecedingToken(position, sourceFile); + } + // Between two consecutive tokens, all comments are either trailing on the former + // or leading on the latter (and none are in both lists). + var trailingRangesOfPreviousToken = precedingToken && ts.getTrailingCommentRanges(sourceFile.text, precedingToken.end); + var leadingCommentRangesOfNextToken = ts.getLeadingCommentRangesOfNode(tokenAtPosition, sourceFile); + var commentRanges = trailingRangesOfPreviousToken && leadingCommentRangesOfNextToken ? + trailingRangesOfPreviousToken.concat(leadingCommentRangesOfNextToken) : + trailingRangesOfPreviousToken || leadingCommentRangesOfNextToken; + if (commentRanges) { + for (var _i = 0, commentRanges_1 = commentRanges; _i < commentRanges_1.length; _i++) { + var range = commentRanges_1[_i]; + // The end marker of a single-line comment does not include the newline character. + // With caret at `^`, in the following case, we are inside a comment (^ denotes the cursor position): + // + // // asdf ^\n + // + // But for closed multi-line comments, we don't want to be inside the comment in the following case: + // + // /* asdf */^ + // + // However, unterminated multi-line comments *do* contain their end. + // + // Internally, we represent the end of the comment at the newline and closing '/', respectively. + // + if ((range.pos < position && position < range.end || + position === range.end && (range.kind === 2 /* SingleLineCommentTrivia */ || position === sourceFile.getFullWidth()))) { + return (range.kind === 3 /* MultiLineCommentTrivia */ || !onlyMultiLine) && (!predicate || predicate(range)) ? range : undefined; + } + } + } + return undefined; + } + formatting.getRangeOfEnclosingComment = getRangeOfEnclosingComment; function getOpenTokenForList(node, list) { switch (node.kind) { case 152 /* Constructor */: @@ -86165,12 +86721,28 @@ var ts; return 0; } var precedingToken = ts.findPrecedingToken(position, sourceFile); + var enclosingCommentRange = formatting.getRangeOfEnclosingComment(sourceFile, position, /*onlyMultiLine*/ true, precedingToken || null); // tslint:disable-line:no-null-keyword + if (enclosingCommentRange) { + var previousLine = ts.getLineAndCharacterOfPosition(sourceFile, position).line - 1; + var commentStartLine = ts.getLineAndCharacterOfPosition(sourceFile, enclosingCommentRange.pos).line; + ts.Debug.assert(commentStartLine >= 0); + if (previousLine <= commentStartLine) { + return findFirstNonWhitespaceColumn(ts.getStartPositionOfLine(commentStartLine, sourceFile), position, sourceFile, options); + } + var startPostionOfLine = ts.getStartPositionOfLine(previousLine, sourceFile); + var _a = findFirstNonWhitespaceCharacterAndColumn(startPostionOfLine, position, sourceFile, options), column = _a.column, character = _a.character; + if (column === 0) { + return column; + } + var firstNonWhitespaceCharacterCode = sourceFile.text.charCodeAt(startPostionOfLine + character); + return firstNonWhitespaceCharacterCode === 42 /* asterisk */ ? column - 1 : column; + } if (!precedingToken) { return getBaseIndentation(options); } // no indentation in string \regex\template literals var precedingTokenIsLiteral = ts.isStringOrRegularExpressionOrTemplateLiteral(precedingToken.kind); - if (precedingTokenIsLiteral && precedingToken.getStart(sourceFile) <= position && precedingToken.end > position) { + if (precedingTokenIsLiteral && precedingToken.getStart(sourceFile) <= position && position < precedingToken.end) { return 0; } var lineAtPosition = sourceFile.getLineAndCharacterOfPosition(position).line; @@ -86473,13 +87045,13 @@ var ts; var lineStart = sourceFile.getPositionOfLineAndCharacter(lineAndCharacter.line, 0); return findFirstNonWhitespaceColumn(lineStart, lineStart + lineAndCharacter.character, sourceFile, options); } - /* - Character is the actual index of the character since the beginning of the line. - Column - position of the character after expanding tabs to spaces - "0\t2$" - value of 'character' for '$' is 3 - value of 'column' for '$' is 6 (assuming that tab size is 4) - */ + /** + * Character is the actual index of the character since the beginning of the line. + * Column - position of the character after expanding tabs to spaces. + * "0\t2$" + * value of 'character' for '$' is 3 + * value of 'column' for '$' is 6 (assuming that tab size is 4) + */ function findFirstNonWhitespaceCharacterAndColumn(startPos, endPos, sourceFile, options) { var character = 0; var column = 0; @@ -86633,6 +87205,12 @@ var ts; } return false; } + var ChangeKind; + (function (ChangeKind) { + ChangeKind[ChangeKind["Remove"] = 0] = "Remove"; + ChangeKind[ChangeKind["ReplaceWithSingleNode"] = 1] = "ReplaceWithSingleNode"; + ChangeKind[ChangeKind["ReplaceWithMultipleNodes"] = 2] = "ReplaceWithMultipleNodes"; + })(ChangeKind || (ChangeKind = {})); function getSeparatorCharacter(separator) { return ts.tokenToString(separator.kind); } @@ -86666,13 +87244,11 @@ var ts; } textChanges.getAdjustedStartPosition = getAdjustedStartPosition; function getAdjustedEndPosition(sourceFile, node, options) { - if (options.useNonAdjustedEndPosition) { + if (options.useNonAdjustedEndPosition || ts.isExpression(node)) { return node.getEnd(); } var end = node.getEnd(); var newEnd = ts.skipTrivia(sourceFile.text, end, /*stopAfterLineBreak*/ true); - // check if last character before newPos is linebreak - // if yes - considered all skipped trivia to be trailing trivia of the node return newEnd !== end && ts.isLineBreak(sourceFile.text.charCodeAt(newEnd - 1)) ? newEnd : end; @@ -86691,7 +87267,10 @@ var ts; } return s; } - var ChangeTracker = (function () { + function getNewlineKind(context) { + return context.newLineCharacter === "\n" ? 1 /* LineFeed */ : 0 /* CarriageReturnLineFeed */; + } + var ChangeTracker = /** @class */ (function () { function ChangeTracker(newLine, rulesProvider, validator) { this.newLine = newLine; this.rulesProvider = rulesProvider; @@ -86700,24 +87279,24 @@ var ts; this.newLineCharacter = ts.getNewLineCharacter({ newLine: newLine }); } ChangeTracker.fromCodeFixContext = function (context) { - return new ChangeTracker(context.newLineCharacter === "\n" ? 1 /* LineFeed */ : 0 /* CarriageReturnLineFeed */, context.rulesProvider); + return new ChangeTracker(getNewlineKind(context), context.rulesProvider); + }; + ChangeTracker.prototype.deleteRange = function (sourceFile, range) { + this.changes.push({ kind: ChangeKind.Remove, sourceFile: sourceFile, range: range }); + return this; }; ChangeTracker.prototype.deleteNode = function (sourceFile, node, options) { if (options === void 0) { options = {}; } var startPosition = getAdjustedStartPosition(sourceFile, node, options, Position.FullStart); var endPosition = getAdjustedEndPosition(sourceFile, node, options); - this.changes.push({ sourceFile: sourceFile, options: options, range: { pos: startPosition, end: endPosition } }); - return this; - }; - ChangeTracker.prototype.deleteRange = function (sourceFile, range) { - this.changes.push({ sourceFile: sourceFile, range: range }); + this.changes.push({ kind: ChangeKind.Remove, sourceFile: sourceFile, range: { pos: startPosition, end: endPosition } }); return this; }; ChangeTracker.prototype.deleteNodeRange = function (sourceFile, startNode, endNode, options) { if (options === void 0) { options = {}; } var startPosition = getAdjustedStartPosition(sourceFile, startNode, options, Position.FullStart); var endPosition = getAdjustedEndPosition(sourceFile, endNode, options); - this.changes.push({ sourceFile: sourceFile, options: options, range: { pos: startPosition, end: endPosition } }); + this.changes.push({ kind: ChangeKind.Remove, sourceFile: sourceFile, range: { pos: startPosition, end: endPosition } }); return this; }; ChangeTracker.prototype.deleteNodeInList = function (sourceFile, node) { @@ -86756,33 +87335,68 @@ var ts; }; ChangeTracker.prototype.replaceRange = function (sourceFile, range, newNode, options) { if (options === void 0) { options = {}; } - this.changes.push({ sourceFile: sourceFile, range: range, options: options, node: newNode }); + this.changes.push({ kind: ChangeKind.ReplaceWithSingleNode, sourceFile: sourceFile, range: range, options: options, node: newNode }); return this; }; ChangeTracker.prototype.replaceNode = function (sourceFile, oldNode, newNode, options) { if (options === void 0) { options = {}; } var startPosition = getAdjustedStartPosition(sourceFile, oldNode, options, Position.Start); var endPosition = getAdjustedEndPosition(sourceFile, oldNode, options); - this.changes.push({ sourceFile: sourceFile, options: options, useIndentationFromFile: true, node: newNode, range: { pos: startPosition, end: endPosition } }); - return this; + return this.replaceWithSingle(sourceFile, startPosition, endPosition, newNode, options); }; ChangeTracker.prototype.replaceNodeRange = function (sourceFile, startNode, endNode, newNode, options) { if (options === void 0) { options = {}; } var startPosition = getAdjustedStartPosition(sourceFile, startNode, options, Position.Start); var endPosition = getAdjustedEndPosition(sourceFile, endNode, options); - this.changes.push({ sourceFile: sourceFile, options: options, useIndentationFromFile: true, node: newNode, range: { pos: startPosition, end: endPosition } }); + return this.replaceWithSingle(sourceFile, startPosition, endPosition, newNode, options); + }; + ChangeTracker.prototype.replaceWithSingle = function (sourceFile, startPosition, endPosition, newNode, options) { + this.changes.push({ + kind: ChangeKind.ReplaceWithSingleNode, + sourceFile: sourceFile, + options: options, + node: newNode, + range: { pos: startPosition, end: endPosition } + }); return this; }; + ChangeTracker.prototype.replaceWithMultiple = function (sourceFile, startPosition, endPosition, newNodes, options) { + this.changes.push({ + kind: ChangeKind.ReplaceWithMultipleNodes, + sourceFile: sourceFile, + options: options, + nodes: newNodes, + range: { pos: startPosition, end: endPosition } + }); + return this; + }; + ChangeTracker.prototype.replaceNodeWithNodes = function (sourceFile, oldNode, newNodes, options) { + var startPosition = getAdjustedStartPosition(sourceFile, oldNode, options, Position.Start); + var endPosition = getAdjustedEndPosition(sourceFile, oldNode, options); + return this.replaceWithMultiple(sourceFile, startPosition, endPosition, newNodes, options); + }; + ChangeTracker.prototype.replaceNodesWithNodes = function (sourceFile, oldNodes, newNodes, options) { + var startPosition = getAdjustedStartPosition(sourceFile, oldNodes[0], options, Position.Start); + var endPosition = getAdjustedEndPosition(sourceFile, ts.lastOrUndefined(oldNodes), options); + return this.replaceWithMultiple(sourceFile, startPosition, endPosition, newNodes, options); + }; + ChangeTracker.prototype.replaceRangeWithNodes = function (sourceFile, range, newNodes, options) { + return this.replaceWithMultiple(sourceFile, range.pos, range.end, newNodes, options); + }; + ChangeTracker.prototype.replaceNodeRangeWithNodes = function (sourceFile, startNode, endNode, newNodes, options) { + var startPosition = getAdjustedStartPosition(sourceFile, startNode, options, Position.Start); + var endPosition = getAdjustedEndPosition(sourceFile, endNode, options); + return this.replaceWithMultiple(sourceFile, startPosition, endPosition, newNodes, options); + }; ChangeTracker.prototype.insertNodeAt = function (sourceFile, pos, newNode, options) { if (options === void 0) { options = {}; } - this.changes.push({ sourceFile: sourceFile, options: options, node: newNode, range: { pos: pos, end: pos } }); + this.changes.push({ kind: ChangeKind.ReplaceWithSingleNode, sourceFile: sourceFile, options: options, node: newNode, range: { pos: pos, end: pos } }); return this; }; ChangeTracker.prototype.insertNodeBefore = function (sourceFile, before, newNode, options) { if (options === void 0) { options = {}; } var startPosition = getAdjustedStartPosition(sourceFile, before, options, Position.Start); - this.changes.push({ sourceFile: sourceFile, options: options, useIndentationFromFile: true, node: newNode, range: { pos: startPosition, end: startPosition } }); - return this; + return this.replaceWithSingle(sourceFile, startPosition, startPosition, newNode, options); }; ChangeTracker.prototype.insertNodeAfter = function (sourceFile, after, newNode, options) { if (options === void 0) { options = {}; } @@ -86794,6 +87408,7 @@ var ts; // if not - insert semicolon to preserve the code from changing the meaning due to ASI if (sourceFile.text.charCodeAt(after.end - 1) !== 59 /* semicolon */) { this.changes.push({ + kind: ChangeKind.ReplaceWithSingleNode, sourceFile: sourceFile, options: {}, range: { pos: after.end, end: after.end }, @@ -86802,8 +87417,7 @@ var ts; } } var endPosition = getAdjustedEndPosition(sourceFile, after, options); - this.changes.push({ sourceFile: sourceFile, options: options, useIndentationFromFile: true, node: newNode, range: { pos: endPosition, end: endPosition } }); - return this; + return this.replaceWithSingle(sourceFile, endPosition, endPosition, newNode, options); }; /** * This function should be used to insert nodes in lists when nodes don't carry separators as the part of the node range, @@ -86869,10 +87483,10 @@ var ts; startPos = ts.getStartPositionOfLine(lineAndCharOfNextElement.line, sourceFile); } this.changes.push({ + kind: ChangeKind.ReplaceWithSingleNode, sourceFile: sourceFile, range: { pos: startPos, end: containingList[index + 1].getStart(sourceFile) }, node: newNode, - useIndentationFromFile: true, options: { prefix: prefix, // write separator and leading trivia of the next element as suffix @@ -86911,6 +87525,7 @@ var ts; if (multilineList) { // insert separator immediately following the 'after' node to preserve comments in trailing trivia this.changes.push({ + kind: ChangeKind.ReplaceWithSingleNode, sourceFile: sourceFile, range: { pos: end, end: end }, node: ts.createToken(separator), @@ -86924,6 +87539,7 @@ var ts; insertPos--; } this.changes.push({ + kind: ChangeKind.ReplaceWithSingleNode, sourceFile: sourceFile, range: { pos: insertPos, end: insertPos }, node: newNode, @@ -86932,6 +87548,7 @@ var ts; } else { this.changes.push({ + kind: ChangeKind.ReplaceWithSingleNode, sourceFile: sourceFile, range: { pos: end, end: end }, node: newNode, @@ -86973,34 +87590,46 @@ var ts; return ts.createTextSpanFromBounds(change.range.pos, change.range.end); }; ChangeTracker.prototype.computeNewText = function (change, sourceFile) { - if (!change.node) { + var _this = this; + if (change.kind === ChangeKind.Remove) { // deletion case return ""; } var options = change.options || {}; - var nonFormattedText = getNonformattedText(change.node, sourceFile, this.newLine); - if (this.validator) { - this.validator(nonFormattedText); - } - var formatOptions = this.rulesProvider.getFormatOptions(); + var text; var pos = change.range.pos; var posStartsLine = ts.getLineStartPositionForPosition(pos, sourceFile) === pos; - var initialIndentation = change.options.indentation !== undefined - ? change.options.indentation - : change.useIndentationFromFile - ? ts.formatting.SmartIndenter.getIndentation(change.range.pos, sourceFile, formatOptions, posStartsLine || (change.options.prefix === this.newLineCharacter)) - : 0; - var delta = change.options.delta !== undefined - ? change.options.delta - : ts.formatting.SmartIndenter.shouldIndentChildNode(change.node) - ? formatOptions.indentSize - : 0; - var text = applyFormatting(nonFormattedText, sourceFile, initialIndentation, delta, this.rulesProvider); + if (change.kind === ChangeKind.ReplaceWithMultipleNodes) { + var parts = change.nodes.map(function (n) { return _this.getFormattedTextOfNode(n, sourceFile, pos, options); }); + text = parts.join(change.options.nodeSeparator); + } + else { + ts.Debug.assert(change.kind === ChangeKind.ReplaceWithSingleNode, "change.kind === ReplaceWithSingleNode"); + text = this.getFormattedTextOfNode(change.node, sourceFile, pos, options); + } // strip initial indentation (spaces or tabs) if text will be inserted in the middle of the line - // however keep indentation if it is was forced - text = posStartsLine || change.options.indentation !== undefined ? text : text.replace(/^\s+/, ""); + text = (posStartsLine || options.indentation !== undefined) ? text : text.replace(/^\s+/, ""); return (options.prefix || "") + text + (options.suffix || ""); }; + ChangeTracker.prototype.getFormattedTextOfNode = function (node, sourceFile, pos, options) { + var nonformattedText = getNonformattedText(node, sourceFile, this.newLine); + if (this.validator) { + this.validator(nonformattedText); + } + var formatOptions = this.rulesProvider.getFormatOptions(); + var posStartsLine = ts.getLineStartPositionForPosition(pos, sourceFile) === pos; + var initialIndentation = options.indentation !== undefined + ? options.indentation + : (options.useIndentationFromFile !== false) + ? ts.formatting.SmartIndenter.getIndentation(pos, sourceFile, formatOptions, posStartsLine || (options.prefix === this.newLineCharacter)) + : 0; + var delta = options.delta !== undefined + ? options.delta + : ts.formatting.SmartIndenter.shouldIndentChildNode(node) + ? (formatOptions.indentSize || 0) + : 0; + return applyFormatting(nonformattedText, sourceFile, initialIndentation, delta, this.rulesProvider); + }; ChangeTracker.normalize = function (changes) { // order changes by start position var normalized = ts.stableSort(changes, function (a, b) { return a.range.pos - b.range.pos; }); @@ -87065,7 +87694,7 @@ var ts; nodeArray.end = getEnd(nodes); return nodeArray; } - var Writer = (function () { + var Writer = /** @class */ (function () { function Writer(newLine) { var _this = this; this.lastNonTriviaPosition = 0; @@ -87948,7 +88577,7 @@ var ts; ModuleSpecifierComparison[ModuleSpecifierComparison["Equal"] = 1] = "Equal"; ModuleSpecifierComparison[ModuleSpecifierComparison["Worse"] = 2] = "Worse"; })(ModuleSpecifierComparison || (ModuleSpecifierComparison = {})); - var ImportCodeActionMap = (function () { + var ImportCodeActionMap = /** @class */ (function () { function ImportCodeActionMap() { this.symbolIdToActionMap = []; } @@ -88061,7 +88690,7 @@ var ts; } else if (ts.isJsxOpeningLikeElement(token.parent) && token.parent.tagName === token) { // The error wasn't for the symbolAtLocation, it was for the JSX tag itself, which needs access to e.g. `React`. - symbol = checker.getAliasedSymbol(checker.resolveNameAtLocation(token, checker.getJsxNamespace(), 107455 /* Value */)); + symbol = checker.getAliasedSymbol(checker.resolveName(checker.getJsxNamespace(), token.parent.tagName, 107455 /* Value */)); symbolName = symbol.name; } else { @@ -88086,7 +88715,7 @@ var ts; if (localSymbol && localSymbol.escapedName === name && checkSymbolHasMeaning(localSymbol, currentTokenMeaning)) { // check if this symbol is already used var symbolId = getUniqueSymbolId(localSymbol); - symbolIdActionMap.addActions(symbolId, getCodeActionForImport(moduleSymbol, name, /*isDefault*/ true)); + symbolIdActionMap.addActions(symbolId, getCodeActionForImport(moduleSymbol, name, /*isNamespaceImport*/ true)); } } // "default" is a keyword and not a legal identifier for the import, so we don't expect it here @@ -88162,8 +88791,8 @@ var ts; var namespaceImportDeclaration; var namedImportDeclaration; var existingModuleSpecifier; - for (var _i = 0, declarations_14 = declarations; _i < declarations_14.length; _i++) { - var declaration = declarations_14[_i]; + for (var _i = 0, declarations_13 = declarations; _i < declarations_13.length; _i++) { + var declaration = declarations_13[_i]; if (declaration.kind === 238 /* ImportDeclaration */) { var namedBindings = declaration.importClause && declaration.importClause.namedBindings; if (namedBindings && namedBindings.kind === 240 /* NamespaceImport */) { @@ -88273,9 +88902,11 @@ var ts; : isNamespaceImport ? ts.createImportClause(/*name*/ undefined, ts.createNamespaceImport(ts.createIdentifier(symbolName))) : ts.createImportClause(/*name*/ undefined, ts.createNamedImports([ts.createImportSpecifier(/*propertyName*/ undefined, ts.createIdentifier(symbolName))])); - var importDecl = ts.createImportDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, importClause, ts.createLiteral(moduleSpecifierWithoutQuotes)); + var moduleSpecifierLiteral = ts.createLiteral(moduleSpecifierWithoutQuotes); + moduleSpecifierLiteral.singleQuote = getSingleQuoteStyleFromExistingImports(); + var importDecl = ts.createImportDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, importClause, moduleSpecifierLiteral); if (!lastImportDeclaration) { - changeTracker.insertNodeAt(sourceFile, sourceFile.getStart(), importDecl, { suffix: "" + context.newLineCharacter + context.newLineCharacter }); + changeTracker.insertNodeAt(sourceFile, getSourceFileImportLocation(sourceFile), importDecl, { suffix: "" + context.newLineCharacter + context.newLineCharacter }); } else { changeTracker.insertNodeAfter(sourceFile, lastImportDeclaration, importDecl, { suffix: context.newLineCharacter }); @@ -88284,6 +88915,46 @@ var ts; // between the only import statement and user code. Otherwise just insert the statement because chances // are there are already a new line seperating code and import statements. return createCodeAction(ts.Diagnostics.Import_0_from_1, [symbolName, "\"" + moduleSpecifierWithoutQuotes + "\""], changeTracker.getChanges(), "NewImport", moduleSpecifierWithoutQuotes); + function getSourceFileImportLocation(node) { + // For a source file, it is possible there are detached comments we should not skip + var text = node.text; + var ranges = ts.getLeadingCommentRanges(text, 0); + if (!ranges) + return 0; + var position = 0; + // However we should still skip a pinned comment at the top + if (ranges.length && ranges[0].kind === 3 /* MultiLineCommentTrivia */ && ts.isPinnedComment(text, ranges[0])) { + position = ranges[0].end + 1; + ranges = ranges.slice(1); + } + // As well as any triple slash references + for (var _i = 0, ranges_1 = ranges; _i < ranges_1.length; _i++) { + var range = ranges_1[_i]; + if (range.kind === 2 /* SingleLineCommentTrivia */ && ts.isRecognizedTripleSlashComment(node.text, range.pos, range.end)) { + position = range.end + 1; + continue; + } + break; + } + return position; + } + function getSingleQuoteStyleFromExistingImports() { + var firstModuleSpecifier = ts.forEach(sourceFile.statements, function (node) { + if (ts.isImportDeclaration(node) || ts.isExportDeclaration(node)) { + if (node.moduleSpecifier && ts.isStringLiteral(node.moduleSpecifier)) { + return node.moduleSpecifier; + } + } + else if (ts.isImportEqualsDeclaration(node)) { + if (ts.isExternalModuleReference(node.moduleReference) && ts.isStringLiteral(node.moduleReference.expression)) { + return node.moduleReference.expression; + } + } + }); + if (firstModuleSpecifier) { + return sourceFile.text.charCodeAt(firstModuleSpecifier.getStart()) === 39 /* singleQuote */; + } + } function getModuleSpecifierForNewImport() { var fileName = sourceFile.fileName; var moduleFileName = moduleSymbol.valueDeclaration.getSourceFile().fileName; @@ -88415,8 +89086,8 @@ var ts; } function getNodeModulePathParts(fullPath) { // If fullPath can't be valid module file within node_modules, returns undefined. - // Example of expected pattern: /base/path/node_modules/[otherpackage/node_modules/]package/[subdirectory/]file.js - // Returns indices: ^ ^ ^ ^ + // Example of expected pattern: /base/path/node_modules/[@scope/otherpackage/@otherscope/node_modules/]package/[subdirectory/]file.js + // Returns indices: ^ ^ ^ ^ var topLevelNodeModulesIndex = 0; var topLevelPackageNameIndex = 0; var packageRootIndex = 0; @@ -88425,7 +89096,8 @@ var ts; (function (States) { States[States["BeforeNodeModules"] = 0] = "BeforeNodeModules"; States[States["NodeModules"] = 1] = "NodeModules"; - States[States["PackageContent"] = 2] = "PackageContent"; + States[States["Scope"] = 2] = "Scope"; + States[States["PackageContent"] = 3] = "PackageContent"; })(States || (States = {})); var partStart = 0; var partEnd = 0; @@ -88442,15 +89114,21 @@ var ts; } break; case 1 /* NodeModules */: - packageRootIndex = partEnd; - state = 2 /* PackageContent */; + case 2 /* Scope */: + if (state === 1 /* NodeModules */ && fullPath.charAt(partStart + 1) === "@") { + state = 2 /* Scope */; + } + else { + packageRootIndex = partEnd; + state = 3 /* PackageContent */; + } break; - case 2 /* PackageContent */: + case 3 /* PackageContent */: if (fullPath.indexOf("/node_modules/", partStart) === partStart) { state = 1 /* NodeModules */; } else { - state = 2 /* PackageContent */; + state = 3 /* PackageContent */; } break; } @@ -88807,231 +89485,1208 @@ var ts; (function (ts) { var refactor; (function (refactor) { - var actionName = "convert"; - var convertFunctionToES6Class = { - name: "Convert to ES2015 class", - description: ts.Diagnostics.Convert_function_to_an_ES2015_class.message, - getEditsForAction: getEditsForAction, - getAvailableActions: getAvailableActions - }; - refactor.registerRefactor(convertFunctionToES6Class); - function getAvailableActions(context) { - if (!ts.isInJavaScriptFile(context.file)) { - return undefined; + var convertFunctionToES6Class; + (function (convertFunctionToES6Class_1) { + var actionName = "convert"; + var convertFunctionToES6Class = { + name: "Convert to ES2015 class", + description: ts.Diagnostics.Convert_function_to_an_ES2015_class.message, + getEditsForAction: getEditsForAction, + getAvailableActions: getAvailableActions + }; + refactor.registerRefactor(convertFunctionToES6Class); + function getAvailableActions(context) { + if (!ts.isInJavaScriptFile(context.file)) { + return undefined; + } + var start = context.startPosition; + var node = ts.getTokenAtPosition(context.file, start, /*includeJsDocComment*/ false); + var checker = context.program.getTypeChecker(); + var symbol = checker.getSymbolAtLocation(node); + if (symbol && ts.isDeclarationOfFunctionOrClassExpression(symbol)) { + symbol = symbol.valueDeclaration.initializer.symbol; + } + if (symbol && (symbol.flags & 16 /* Function */) && symbol.members && (symbol.members.size > 0)) { + return [ + { + name: convertFunctionToES6Class.name, + description: convertFunctionToES6Class.description, + actions: [ + { + description: convertFunctionToES6Class.description, + name: actionName + } + ] + } + ]; + } } - var start = context.startPosition; - var node = ts.getTokenAtPosition(context.file, start, /*includeJsDocComment*/ false); - var checker = context.program.getTypeChecker(); - var symbol = checker.getSymbolAtLocation(node); - if (symbol && ts.isDeclarationOfFunctionOrClassExpression(symbol)) { - symbol = symbol.valueDeclaration.initializer.symbol; - } - if (symbol && (symbol.flags & 16 /* Function */) && symbol.members && (symbol.members.size > 0)) { - return [ - { - name: convertFunctionToES6Class.name, - description: convertFunctionToES6Class.description, - actions: [ - { - description: convertFunctionToES6Class.description, - name: actionName - } - ] + function getEditsForAction(context, action) { + // Somehow wrong action got invoked? + if (actionName !== action) { + return undefined; + } + var start = context.startPosition; + var sourceFile = context.file; + var checker = context.program.getTypeChecker(); + var token = ts.getTokenAtPosition(sourceFile, start, /*includeJsDocComment*/ false); + var ctorSymbol = checker.getSymbolAtLocation(token); + var newLine = context.rulesProvider.getFormatOptions().newLineCharacter; + var deletedNodes = []; + var deletes = []; + if (!(ctorSymbol.flags & (16 /* Function */ | 3 /* Variable */))) { + return undefined; + } + var ctorDeclaration = ctorSymbol.valueDeclaration; + var changeTracker = ts.textChanges.ChangeTracker.fromCodeFixContext(context); + var precedingNode; + var newClassDeclaration; + switch (ctorDeclaration.kind) { + case 228 /* FunctionDeclaration */: + precedingNode = ctorDeclaration; + deleteNode(ctorDeclaration); + newClassDeclaration = createClassFromFunctionDeclaration(ctorDeclaration); + break; + case 226 /* VariableDeclaration */: + precedingNode = ctorDeclaration.parent.parent; + if (ctorDeclaration.parent.declarations.length === 1) { + deleteNode(precedingNode); + } + else { + deleteNode(ctorDeclaration, /*inList*/ true); + } + newClassDeclaration = createClassFromVariableDeclaration(ctorDeclaration); + break; + } + if (!newClassDeclaration) { + return undefined; + } + // Because the preceding node could be touched, we need to insert nodes before delete nodes. + changeTracker.insertNodeAfter(sourceFile, precedingNode, newClassDeclaration, { suffix: newLine }); + for (var _i = 0, deletes_1 = deletes; _i < deletes_1.length; _i++) { + var deleteCallback = deletes_1[_i]; + deleteCallback(); + } + return { + edits: changeTracker.getChanges() + }; + function deleteNode(node, inList) { + if (inList === void 0) { inList = false; } + if (deletedNodes.some(function (n) { return ts.isNodeDescendantOf(node, n); })) { + // Parent node has already been deleted; do nothing + return; } - ]; - } - } - function getEditsForAction(context, action) { - // Somehow wrong action got invoked? - if (actionName !== action) { - return undefined; - } - var start = context.startPosition; - var sourceFile = context.file; - var checker = context.program.getTypeChecker(); - var token = ts.getTokenAtPosition(sourceFile, start, /*includeJsDocComment*/ false); - var ctorSymbol = checker.getSymbolAtLocation(token); - var newLine = context.rulesProvider.getFormatOptions().newLineCharacter; - var deletedNodes = []; - var deletes = []; - if (!(ctorSymbol.flags & (16 /* Function */ | 3 /* Variable */))) { - return undefined; - } - var ctorDeclaration = ctorSymbol.valueDeclaration; - var changeTracker = ts.textChanges.ChangeTracker.fromCodeFixContext(context); - var precedingNode; - var newClassDeclaration; - switch (ctorDeclaration.kind) { - case 228 /* FunctionDeclaration */: - precedingNode = ctorDeclaration; - deleteNode(ctorDeclaration); - newClassDeclaration = createClassFromFunctionDeclaration(ctorDeclaration); - break; - case 226 /* VariableDeclaration */: - precedingNode = ctorDeclaration.parent.parent; - if (ctorDeclaration.parent.declarations.length === 1) { - deleteNode(precedingNode); + deletedNodes.push(node); + if (inList) { + deletes.push(function () { return changeTracker.deleteNodeInList(sourceFile, node); }); } else { - deleteNode(ctorDeclaration, /*inList*/ true); + deletes.push(function () { return changeTracker.deleteNode(sourceFile, node); }); } - newClassDeclaration = createClassFromVariableDeclaration(ctorDeclaration); - break; - } - if (!newClassDeclaration) { - return undefined; - } - // Because the preceding node could be touched, we need to insert nodes before delete nodes. - changeTracker.insertNodeAfter(sourceFile, precedingNode, newClassDeclaration, { suffix: newLine }); - for (var _i = 0, deletes_1 = deletes; _i < deletes_1.length; _i++) { - var deleteCallback = deletes_1[_i]; - deleteCallback(); - } - return { - edits: changeTracker.getChanges() - }; - function deleteNode(node, inList) { - if (inList === void 0) { inList = false; } - if (deletedNodes.some(function (n) { return ts.isNodeDescendantOf(node, n); })) { - // Parent node has already been deleted; do nothing - return; } - deletedNodes.push(node); - if (inList) { - deletes.push(function () { return changeTracker.deleteNodeInList(sourceFile, node); }); + function createClassElementsFromSymbol(symbol) { + var memberElements = []; + // all instance members are stored in the "member" array of symbol + if (symbol.members) { + symbol.members.forEach(function (member) { + var memberElement = createClassElement(member, /*modifiers*/ undefined); + if (memberElement) { + memberElements.push(memberElement); + } + }); + } + // all static members are stored in the "exports" array of symbol + if (symbol.exports) { + symbol.exports.forEach(function (member) { + var memberElement = createClassElement(member, [ts.createToken(115 /* StaticKeyword */)]); + if (memberElement) { + memberElements.push(memberElement); + } + }); + } + return memberElements; + function shouldConvertDeclaration(_target, source) { + // Right now the only thing we can convert are function expressions - other values shouldn't get + // transformed. We can update this once ES public class properties are available. + return ts.isFunctionLike(source); + } + function createClassElement(symbol, modifiers) { + // both properties and methods are bound as property symbols + if (!(symbol.flags & 4 /* Property */)) { + return; + } + var memberDeclaration = symbol.valueDeclaration; + var assignmentBinaryExpression = memberDeclaration.parent; + if (!shouldConvertDeclaration(memberDeclaration, assignmentBinaryExpression.right)) { + return; + } + // delete the entire statement if this expression is the sole expression to take care of the semicolon at the end + var nodeToDelete = assignmentBinaryExpression.parent && assignmentBinaryExpression.parent.kind === 210 /* ExpressionStatement */ + ? assignmentBinaryExpression.parent : assignmentBinaryExpression; + deleteNode(nodeToDelete); + if (!assignmentBinaryExpression.right) { + return ts.createProperty([], modifiers, symbol.name, /*questionToken*/ undefined, + /*type*/ undefined, /*initializer*/ undefined); + } + switch (assignmentBinaryExpression.right.kind) { + case 186 /* FunctionExpression */: { + var functionExpression = assignmentBinaryExpression.right; + var method = ts.createMethod(/*decorators*/ undefined, modifiers, /*asteriskToken*/ undefined, memberDeclaration.name, /*questionToken*/ undefined, + /*typeParameters*/ undefined, functionExpression.parameters, /*type*/ undefined, functionExpression.body); + copyComments(assignmentBinaryExpression, method); + return method; + } + case 187 /* ArrowFunction */: { + var arrowFunction = assignmentBinaryExpression.right; + var arrowFunctionBody = arrowFunction.body; + var bodyBlock = void 0; + // case 1: () => { return [1,2,3] } + if (arrowFunctionBody.kind === 207 /* Block */) { + bodyBlock = arrowFunctionBody; + } + else { + var expression = arrowFunctionBody; + bodyBlock = ts.createBlock([ts.createReturn(expression)]); + } + var method = ts.createMethod(/*decorators*/ undefined, modifiers, /*asteriskToken*/ undefined, memberDeclaration.name, /*questionToken*/ undefined, + /*typeParameters*/ undefined, arrowFunction.parameters, /*type*/ undefined, bodyBlock); + copyComments(assignmentBinaryExpression, method); + return method; + } + default: { + // Don't try to declare members in JavaScript files + if (ts.isSourceFileJavaScript(sourceFile)) { + return; + } + var prop = ts.createProperty(/*decorators*/ undefined, modifiers, memberDeclaration.name, /*questionToken*/ undefined, + /*type*/ undefined, assignmentBinaryExpression.right); + copyComments(assignmentBinaryExpression.parent, prop); + return prop; + } + } + } + } + function copyComments(sourceNode, targetNode) { + ts.forEachLeadingCommentRange(sourceFile.text, sourceNode.pos, function (pos, end, kind, htnl) { + if (kind === 3 /* MultiLineCommentTrivia */) { + // Remove leading /* + pos += 2; + // Remove trailing */ + end -= 2; + } + else { + // Remove leading // + pos += 2; + } + ts.addSyntheticLeadingComment(targetNode, kind, sourceFile.text.slice(pos, end), htnl); + }); + } + function createClassFromVariableDeclaration(node) { + var initializer = node.initializer; + if (!initializer || initializer.kind !== 186 /* FunctionExpression */) { + return undefined; + } + if (node.name.kind !== 71 /* Identifier */) { + return undefined; + } + var memberElements = createClassElementsFromSymbol(initializer.symbol); + if (initializer.body) { + memberElements.unshift(ts.createConstructor(/*decorators*/ undefined, /*modifiers*/ undefined, initializer.parameters, initializer.body)); + } + var cls = ts.createClassDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, node.name, + /*typeParameters*/ undefined, /*heritageClauses*/ undefined, memberElements); + // Don't call copyComments here because we'll already leave them in place + return cls; + } + function createClassFromFunctionDeclaration(node) { + var memberElements = createClassElementsFromSymbol(ctorSymbol); + if (node.body) { + memberElements.unshift(ts.createConstructor(/*decorators*/ undefined, /*modifiers*/ undefined, node.parameters, node.body)); + } + var cls = ts.createClassDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, node.name, + /*typeParameters*/ undefined, /*heritageClauses*/ undefined, memberElements); + // Don't call copyComments here because we'll already leave them in place + return cls; + } + } + })(convertFunctionToES6Class = refactor.convertFunctionToES6Class || (refactor.convertFunctionToES6Class = {})); + })(refactor = ts.refactor || (ts.refactor = {})); +})(ts || (ts = {})); +/// +/// +/* @internal */ +var ts; +(function (ts) { + var refactor; + (function (refactor) { + var extractMethod; + (function (extractMethod_1) { + var extractMethod = { + name: "Extract Method", + description: ts.Diagnostics.Extract_function.message, + getAvailableActions: getAvailableActions, + getEditsForAction: getEditsForAction, + }; + refactor.registerRefactor(extractMethod); + /** Compute the associated code actions */ + function getAvailableActions(context) { + var rangeToExtract = getRangeToExtract(context.file, { start: context.startPosition, length: context.endPosition - context.startPosition }); + var targetRange = rangeToExtract.targetRange; + if (targetRange === undefined) { + return undefined; + } + var extractions = getPossibleExtractions(targetRange, context); + if (extractions === undefined) { + // No extractions possible + return undefined; + } + var actions = []; + var usedNames = ts.createMap(); + var i = 0; + for (var _i = 0, extractions_1 = extractions; _i < extractions_1.length; _i++) { + var extr = extractions_1[_i]; + // Skip these since we don't have a way to report errors yet + if (extr.errors && extr.errors.length) { + continue; + } + // Don't issue refactorings with duplicated names. + // Scopes come back in "innermost first" order, so extractions will + // preferentially go into nearer scopes + var description = ts.formatStringFromArgs(ts.Diagnostics.Extract_function_into_0.message, [extr.scopeDescription]); + if (!usedNames.has(description)) { + usedNames.set(description, true); + actions.push({ + description: description, + name: "scope_" + i + }); + } + // *do* increment i anyway because we'll look for the i-th scope + // later when actually doing the refactoring if the user requests it + i++; + } + if (actions.length === 0) { + return undefined; + } + return [{ + name: extractMethod.name, + description: extractMethod.description, + inlineable: true, + actions: actions + }]; + } + function getEditsForAction(context, actionName) { + var length = context.endPosition === undefined ? 0 : context.endPosition - context.startPosition; + var rangeToExtract = getRangeToExtract(context.file, { start: context.startPosition, length: length }); + var targetRange = rangeToExtract.targetRange; + var parsedIndexMatch = /^scope_(\d+)$/.exec(actionName); + ts.Debug.assert(!!parsedIndexMatch, "Scope name should have matched the regexp"); + var index = +parsedIndexMatch[1]; + ts.Debug.assert(isFinite(index), "Expected to parse a finite number from the scope index"); + var extractions = getPossibleExtractions(targetRange, context, index); + // Scope is no longer valid from when the user issued the refactor (??) + ts.Debug.assert(extractions !== undefined, "The extraction went missing? How?"); + return ({ edits: extractions[0].changes }); + } + // Move these into diagnostic messages if they become user-facing + var Messages; + (function (Messages) { + function createMessage(message) { + return { message: message, code: 0, category: ts.DiagnosticCategory.Message, key: message }; + } + Messages.CannotExtractFunction = createMessage("Cannot extract function."); + Messages.StatementOrExpressionExpected = createMessage("Statement or expression expected."); + Messages.CannotExtractRangeContainingConditionalBreakOrContinueStatements = createMessage("Cannot extract range containing conditional break or continue statements."); + Messages.CannotExtractRangeContainingConditionalReturnStatement = createMessage("Cannot extract range containing conditional return statement."); + Messages.CannotExtractRangeContainingLabeledBreakOrContinueStatementWithTargetOutsideOfTheRange = createMessage("Cannot extract range containing labeled break or continue with target outside of the range."); + Messages.CannotExtractRangeThatContainsWritesToReferencesLocatedOutsideOfTheTargetRangeInGenerators = createMessage("Cannot extract range containing writes to references located outside of the target range in generators."); + Messages.TypeWillNotBeVisibleInTheNewScope = createMessage("Type will not visible in the new scope."); + Messages.FunctionWillNotBeVisibleInTheNewScope = createMessage("Function will not visible in the new scope."); + Messages.InsufficientSelection = createMessage("Select more than a single identifier."); + Messages.CannotExtractExportedEntity = createMessage("Cannot extract exported declaration"); + Messages.CannotCombineWritesAndReturns = createMessage("Cannot combine writes and returns"); + Messages.CannotExtractReadonlyPropertyInitializerOutsideConstructor = createMessage("Cannot move initialization of read-only class property outside of the constructor"); + Messages.CannotExtractAmbientBlock = createMessage("Cannot extract code from ambient contexts"); + })(Messages || (Messages = {})); + var RangeFacts; + (function (RangeFacts) { + RangeFacts[RangeFacts["None"] = 0] = "None"; + RangeFacts[RangeFacts["HasReturn"] = 1] = "HasReturn"; + RangeFacts[RangeFacts["IsGenerator"] = 2] = "IsGenerator"; + RangeFacts[RangeFacts["IsAsyncFunction"] = 4] = "IsAsyncFunction"; + RangeFacts[RangeFacts["UsesThis"] = 8] = "UsesThis"; + /** + * The range is in a function which needs the 'static' modifier in a class + */ + RangeFacts[RangeFacts["InStaticRegion"] = 16] = "InStaticRegion"; + })(RangeFacts = extractMethod_1.RangeFacts || (extractMethod_1.RangeFacts = {})); + /** + * getRangeToExtract takes a span inside a text file and returns either an expression or an array + * of statements representing the minimum set of nodes needed to extract the entire span. This + * process may fail, in which case a set of errors is returned instead (these are currently + * not shown to the user, but can be used by us diagnostically) + */ + function getRangeToExtract(sourceFile, span) { + var length = span.length || 0; + // Walk up starting from the the start position until we find a non-SourceFile node that subsumes the selected span. + // This may fail (e.g. you select two statements in the root of a source file) + var start = getParentNodeInSpan(ts.getTokenAtPosition(sourceFile, span.start, /*includeJsDocComment*/ false), sourceFile, span); + // Do the same for the ending position + var end = getParentNodeInSpan(ts.findTokenOnLeftOfPosition(sourceFile, ts.textSpanEnd(span)), sourceFile, span); + var declarations = []; + // We'll modify these flags as we walk the tree to collect data + // about what things need to be done as part of the extraction. + var rangeFacts = RangeFacts.None; + if (!start || !end) { + // cannot find either start or end node + return { errors: [ts.createFileDiagnostic(sourceFile, span.start, length, Messages.CannotExtractFunction)] }; + } + if (start.parent !== end.parent) { + // handle cases like 1 + [2 + 3] + 4 + // user selection is marked with []. + // in this case 2 + 3 does not belong to the same tree node + // instead the shape of the tree looks like this: + // + + // / \ + // + 4 + // / \ + // + 3 + // / \ + // 1 2 + // in this case there is no such one node that covers ends of selection and is located inside the selection + // to handle this we check if both start and end of the selection belong to some binary operation + // and start node is parented by the parent of the end node + // if this is the case - expand the selection to the entire parent of end node (in this case it will be [1 + 2 + 3] + 4) + var startParent = ts.skipParentheses(start.parent); + var endParent = ts.skipParentheses(end.parent); + if (ts.isBinaryExpression(startParent) && ts.isBinaryExpression(endParent) && ts.isNodeDescendantOf(startParent, endParent)) { + start = end = endParent; + } + else { + // start and end nodes belong to different subtrees + return createErrorResult(sourceFile, span.start, length, Messages.CannotExtractFunction); + } + } + if (start !== end) { + // start and end should be statements and parent should be either block or a source file + if (!isBlockLike(start.parent)) { + return createErrorResult(sourceFile, span.start, length, Messages.CannotExtractFunction); + } + var statements = []; + for (var _i = 0, _a = start.parent.statements; _i < _a.length; _i++) { + var statement = _a[_i]; + if (statement === start || statements.length) { + var errors = checkNode(statement); + if (errors) { + return { errors: errors }; + } + statements.push(statement); + } + if (statement === end) { + break; + } + } + return { targetRange: { range: statements, facts: rangeFacts, declarations: declarations } }; } else { - deletes.push(function () { return changeTracker.deleteNode(sourceFile, node); }); - } - } - function createClassElementsFromSymbol(symbol) { - var memberElements = []; - // all instance members are stored in the "member" array of symbol - if (symbol.members) { - symbol.members.forEach(function (member) { - var memberElement = createClassElement(member, /*modifiers*/ undefined); - if (memberElement) { - memberElements.push(memberElement); - } - }); - } - // all static members are stored in the "exports" array of symbol - if (symbol.exports) { - symbol.exports.forEach(function (member) { - var memberElement = createClassElement(member, [ts.createToken(115 /* StaticKeyword */)]); - if (memberElement) { - memberElements.push(memberElement); - } - }); - } - return memberElements; - function shouldConvertDeclaration(_target, source) { - // Right now the only thing we can convert are function expressions - other values shouldn't get - // transformed. We can update this once ES public class properties are available. - return ts.isFunctionLike(source); - } - function createClassElement(symbol, modifiers) { - // both properties and methods are bound as property symbols - if (!(symbol.flags & 4 /* Property */)) { - return; + // We have a single node (start) + var errors = checkRootNode(start) || checkNode(start); + if (errors) { + return { errors: errors }; } - var memberDeclaration = symbol.valueDeclaration; - var assignmentBinaryExpression = memberDeclaration.parent; - if (!shouldConvertDeclaration(memberDeclaration, assignmentBinaryExpression.right)) { - return; + // If our selection is the expression in an ExpressionStatement, expand + // the selection to include the enclosing Statement (this stops us + // from trying to care about the return value of the extracted function + // and eliminates double semicolon insertion in certain scenarios) + var range = ts.isStatement(start) + ? [start] + : start.parent && start.parent.kind === 210 /* ExpressionStatement */ + ? [start.parent] + : start; + return { targetRange: { range: range, facts: rangeFacts, declarations: declarations } }; + } + function createErrorResult(sourceFile, start, length, message) { + return { errors: [ts.createFileDiagnostic(sourceFile, start, length, message)] }; + } + function checkRootNode(node) { + if (ts.isIdentifier(node)) { + return [ts.createDiagnosticForNode(node, Messages.InsufficientSelection)]; } - // delete the entire statement if this expression is the sole expression to take care of the semicolon at the end - var nodeToDelete = assignmentBinaryExpression.parent && assignmentBinaryExpression.parent.kind === 210 /* ExpressionStatement */ - ? assignmentBinaryExpression.parent : assignmentBinaryExpression; - deleteNode(nodeToDelete); - if (!assignmentBinaryExpression.right) { - return ts.createProperty([], modifiers, symbol.name, /*questionToken*/ undefined, - /*type*/ undefined, /*initializer*/ undefined); + return undefined; + } + function checkForStaticContext(nodeToCheck, containingClass) { + var current = nodeToCheck; + while (current !== containingClass) { + if (current.kind === 149 /* PropertyDeclaration */) { + if (ts.hasModifier(current, 32 /* Static */)) { + rangeFacts |= RangeFacts.InStaticRegion; + } + break; + } + else if (current.kind === 146 /* Parameter */) { + var ctorOrMethod = ts.getContainingFunction(current); + if (ctorOrMethod.kind === 152 /* Constructor */) { + rangeFacts |= RangeFacts.InStaticRegion; + } + break; + } + else if (current.kind === 151 /* MethodDeclaration */) { + if (ts.hasModifier(current, 32 /* Static */)) { + rangeFacts |= RangeFacts.InStaticRegion; + } + } + current = current.parent; } - switch (assignmentBinaryExpression.right.kind) { - case 186 /* FunctionExpression */: { - var functionExpression = assignmentBinaryExpression.right; - var method = ts.createMethod(/*decorators*/ undefined, modifiers, /*asteriskToken*/ undefined, memberDeclaration.name, /*questionToken*/ undefined, - /*typeParameters*/ undefined, functionExpression.parameters, /*type*/ undefined, functionExpression.body); - copyComments(assignmentBinaryExpression, method); - return method; + } + // Verifies whether we can actually extract this node or not. + function checkNode(nodeToCheck) { + var PermittedJumps; + (function (PermittedJumps) { + PermittedJumps[PermittedJumps["None"] = 0] = "None"; + PermittedJumps[PermittedJumps["Break"] = 1] = "Break"; + PermittedJumps[PermittedJumps["Continue"] = 2] = "Continue"; + PermittedJumps[PermittedJumps["Return"] = 4] = "Return"; + })(PermittedJumps || (PermittedJumps = {})); + if (!ts.isStatement(nodeToCheck) && !(ts.isExpression(nodeToCheck) && isExtractableExpression(nodeToCheck))) { + return [ts.createDiagnosticForNode(nodeToCheck, Messages.StatementOrExpressionExpected)]; + } + if (ts.isInAmbientContext(nodeToCheck)) { + return [ts.createDiagnosticForNode(nodeToCheck, Messages.CannotExtractAmbientBlock)]; + } + // If we're in a class, see whether we're in a static region (static property initializer, static method, class constructor parameter default) + var containingClass = ts.getContainingClass(nodeToCheck); + if (containingClass) { + checkForStaticContext(nodeToCheck, containingClass); + } + var errors; + var permittedJumps = 4 /* Return */; + var seenLabels; + visit(nodeToCheck); + return errors; + function visit(node) { + if (errors) { + // already found an error - can stop now + return true; } - case 187 /* ArrowFunction */: { - var arrowFunction = assignmentBinaryExpression.right; - var arrowFunctionBody = arrowFunction.body; - var bodyBlock = void 0; - // case 1: () => { return [1,2,3] } - if (arrowFunctionBody.kind === 207 /* Block */) { - bodyBlock = arrowFunctionBody; + if (ts.isDeclaration(node)) { + var declaringNode = (node.kind === 226 /* VariableDeclaration */) ? node.parent.parent : node; + if (ts.hasModifier(declaringNode, 1 /* Export */)) { + (errors || (errors = [])).push(ts.createDiagnosticForNode(node, Messages.CannotExtractExportedEntity)); + return true; } - else { - var expression = arrowFunctionBody; - bodyBlock = ts.createBlock([ts.createReturn(expression)]); - } - var method = ts.createMethod(/*decorators*/ undefined, modifiers, /*asteriskToken*/ undefined, memberDeclaration.name, /*questionToken*/ undefined, - /*typeParameters*/ undefined, arrowFunction.parameters, /*type*/ undefined, bodyBlock); - copyComments(assignmentBinaryExpression, method); - return method; + declarations.push(node.symbol); } - default: { - // Don't try to declare members in JavaScript files - if (ts.isSourceFileJavaScript(sourceFile)) { - return; - } - var prop = ts.createProperty(/*decorators*/ undefined, modifiers, memberDeclaration.name, /*questionToken*/ undefined, - /*type*/ undefined, assignmentBinaryExpression.right); - copyComments(assignmentBinaryExpression.parent, prop); - return prop; + // Some things can't be extracted in certain situations + switch (node.kind) { + case 238 /* ImportDeclaration */: + (errors || (errors = [])).push(ts.createDiagnosticForNode(node, Messages.CannotExtractFunction)); + return true; + case 97 /* SuperKeyword */: + // For a super *constructor call*, we have to be extracting the entire class, + // but a super *method call* simply implies a 'this' reference + if (node.parent.kind === 181 /* CallExpression */) { + // Super constructor call + var containingClass_1 = ts.getContainingClass(node); + if (containingClass_1.pos < span.start || containingClass_1.end >= (span.start + span.length)) { + (errors || (errors = [])).push(ts.createDiagnosticForNode(node, Messages.CannotExtractFunction)); + return true; + } + } + else { + rangeFacts |= RangeFacts.UsesThis; + } + break; } + if (!node || ts.isFunctionLike(node) || ts.isClassLike(node)) { + switch (node.kind) { + case 228 /* FunctionDeclaration */: + case 229 /* ClassDeclaration */: + if (node.parent.kind === 265 /* SourceFile */ && node.parent.externalModuleIndicator === undefined) { + // You cannot extract global declarations + (errors || (errors = [])).push(ts.createDiagnosticForNode(node, Messages.FunctionWillNotBeVisibleInTheNewScope)); + } + break; + } + // do not dive into functions or classes + return false; + } + var savedPermittedJumps = permittedJumps; + if (node.parent) { + switch (node.parent.kind) { + case 211 /* IfStatement */: + if (node.parent.thenStatement === node || node.parent.elseStatement === node) { + // forbid all jumps inside thenStatement or elseStatement + permittedJumps = 0 /* None */; + } + break; + case 224 /* TryStatement */: + if (node.parent.tryBlock === node) { + // forbid all jumps inside try blocks + permittedJumps = 0 /* None */; + } + else if (node.parent.finallyBlock === node) { + // allow unconditional returns from finally blocks + permittedJumps = 4 /* Return */; + } + break; + case 260 /* CatchClause */: + if (node.parent.block === node) { + // forbid all jumps inside the block of catch clause + permittedJumps = 0 /* None */; + } + break; + case 257 /* CaseClause */: + if (node.expression !== node) { + // allow unlabeled break inside case clauses + permittedJumps |= 1 /* Break */; + } + break; + default: + if (ts.isIterationStatement(node.parent, /*lookInLabeledStatements*/ false)) { + if (node.parent.statement === node) { + // allow unlabeled break/continue inside loops + permittedJumps |= 1 /* Break */ | 2 /* Continue */; + } + } + break; + } + } + switch (node.kind) { + case 169 /* ThisType */: + case 99 /* ThisKeyword */: + rangeFacts |= RangeFacts.UsesThis; + break; + case 222 /* LabeledStatement */: + { + var label = node.label; + (seenLabels || (seenLabels = [])).push(label.escapedText); + ts.forEachChild(node, visit); + seenLabels.pop(); + break; + } + case 218 /* BreakStatement */: + case 217 /* ContinueStatement */: + { + var label = node.label; + if (label) { + if (!ts.contains(seenLabels, label.escapedText)) { + // attempts to jump to label that is not in range to be extracted + (errors || (errors = [])).push(ts.createDiagnosticForNode(node, Messages.CannotExtractRangeContainingLabeledBreakOrContinueStatementWithTargetOutsideOfTheRange)); + } + } + else { + if (!(permittedJumps & (218 /* BreakStatement */ ? 1 /* Break */ : 2 /* Continue */))) { + // attempt to break or continue in a forbidden context + (errors || (errors = [])).push(ts.createDiagnosticForNode(node, Messages.CannotExtractRangeContainingConditionalBreakOrContinueStatements)); + } + } + break; + } + case 191 /* AwaitExpression */: + rangeFacts |= RangeFacts.IsAsyncFunction; + break; + case 197 /* YieldExpression */: + rangeFacts |= RangeFacts.IsGenerator; + break; + case 219 /* ReturnStatement */: + if (permittedJumps & 4 /* Return */) { + rangeFacts |= RangeFacts.HasReturn; + } + else { + (errors || (errors = [])).push(ts.createDiagnosticForNode(node, Messages.CannotExtractRangeContainingConditionalReturnStatement)); + } + break; + default: + ts.forEachChild(node, visit); + break; + } + permittedJumps = savedPermittedJumps; } } } - function copyComments(sourceNode, targetNode) { - ts.forEachLeadingCommentRange(sourceFile.text, sourceNode.pos, function (pos, end, kind, htnl) { - if (kind === 3 /* MultiLineCommentTrivia */) { - // Remove leading /* - pos += 2; - // Remove trailing */ - end -= 2; + extractMethod_1.getRangeToExtract = getRangeToExtract; + function isValidExtractionTarget(node) { + // Note that we don't use isFunctionLike because we don't want to put the extracted closure *inside* a method + return (node.kind === 228 /* FunctionDeclaration */) || ts.isSourceFile(node) || ts.isModuleBlock(node) || ts.isClassLike(node); + } + /** + * Computes possible places we could extract the function into. For example, + * you may be able to extract into a class method *or* local closure *or* namespace function, + * depending on what's in the extracted body. + */ + function collectEnclosingScopes(range) { + var current = isReadonlyArray(range.range) ? ts.firstOrUndefined(range.range) : range.range; + if (range.facts & RangeFacts.UsesThis) { + // if range uses this as keyword or as type inside the class then it can only be extracted to a method of the containing class + var containingClass = ts.getContainingClass(current); + if (containingClass) { + return [containingClass]; + } + } + var start = current; + var scopes = undefined; + while (current) { + // We want to find the nearest parent where we can place an "equivalent" sibling to the node we're extracting out of. + // Walk up to the closest parent of a place where we can logically put a sibling: + // * Function declaration + // * Class declaration or expression + // * Module/namespace or source file + if (current !== start && isValidExtractionTarget(current)) { + (scopes = scopes || []).push(current); + } + // A function parameter's initializer is actually in the outer scope, not the function declaration + if (current && current.parent && current.parent.kind === 146 /* Parameter */) { + // Skip all the way to the outer scope of the function that declared this parameter + current = ts.findAncestor(current, function (parent) { return ts.isFunctionLike(parent); }).parent; } else { - // Remove leading // - pos += 2; + current = current.parent; } - ts.addSyntheticLeadingComment(targetNode, kind, sourceFile.text.slice(pos, end), htnl); + } + return scopes; + } + extractMethod_1.collectEnclosingScopes = collectEnclosingScopes; + /** + * Given a piece of text to extract ('targetRange'), computes a list of possible extractions. + * Each returned ExtractResultForScope corresponds to a possible target scope and is either a set of changes + * or an error explaining why we can't extract into that scope. + */ + function getPossibleExtractions(targetRange, context, requestedChangesIndex) { + if (requestedChangesIndex === void 0) { requestedChangesIndex = undefined; } + var sourceFile = context.file; + if (targetRange === undefined) { + return undefined; + } + var scopes = collectEnclosingScopes(targetRange); + if (scopes === undefined) { + return undefined; + } + var enclosingTextRange = getEnclosingTextRange(targetRange, sourceFile); + var _a = collectReadsAndWrites(targetRange, scopes, enclosingTextRange, sourceFile, context.program.getTypeChecker()), target = _a.target, usagesPerScope = _a.usagesPerScope, errorsPerScope = _a.errorsPerScope; + context.cancellationToken.throwIfCancellationRequested(); + if (requestedChangesIndex !== undefined) { + if (errorsPerScope[requestedChangesIndex].length) { + return undefined; + } + return [extractFunctionInScope(target, scopes[requestedChangesIndex], usagesPerScope[requestedChangesIndex], targetRange, context)]; + } + else { + return scopes.map(function (scope, i) { + var errors = errorsPerScope[i]; + if (errors.length) { + return { + scope: scope, + scopeDescription: getDescriptionForScope(scope), + errors: errors + }; + } + return { scope: scope, scopeDescription: getDescriptionForScope(scope) }; + }); + } + } + extractMethod_1.getPossibleExtractions = getPossibleExtractions; + function getDescriptionForScope(scope) { + if (ts.isFunctionLike(scope)) { + switch (scope.kind) { + case 152 /* Constructor */: + return "constructor"; + case 186 /* FunctionExpression */: + return scope.name + ? "function expression " + scope.name.getText() + : "anonymous function expression"; + case 228 /* FunctionDeclaration */: + return "function " + scope.name.getText(); + case 187 /* ArrowFunction */: + return "arrow function"; + case 151 /* MethodDeclaration */: + return "method " + scope.name.getText(); + case 153 /* GetAccessor */: + return "get " + scope.name.getText(); + case 154 /* SetAccessor */: + return "set " + scope.name.getText(); + } + } + else if (ts.isModuleBlock(scope)) { + return "namespace " + scope.parent.name.getText(); + } + else if (ts.isClassLike(scope)) { + return scope.kind === 229 /* ClassDeclaration */ + ? "class " + scope.name.text + : scope.name.text + ? "class expression " + scope.name.text + : "anonymous class expression"; + } + else if (ts.isSourceFile(scope)) { + return "file '" + scope.fileName + "'"; + } + else { + return "unknown"; + } + } + function getUniqueName(isNameOkay) { + var functionNameText = "newFunction"; + if (isNameOkay(functionNameText)) { + return functionNameText; + } + var i = 1; + while (!isNameOkay(functionNameText = "newFunction_" + i)) { + i++; + } + return functionNameText; + } + function extractFunctionInScope(node, scope, _a, range, context) { + var usagesInScope = _a.usages, substitutions = _a.substitutions; + var checker = context.program.getTypeChecker(); + // Make a unique name for the extracted function + var file = scope.getSourceFile(); + var functionNameText = getUniqueName(function (n) { return !file.identifiers.has(n); }); + var isJS = ts.isInJavaScriptFile(scope); + var functionName = ts.createIdentifier(functionNameText); + var functionReference = ts.createIdentifier(functionNameText); + var returnType = undefined; + var parameters = []; + var callArguments = []; + var writes; + usagesInScope.forEach(function (usage, name) { + var typeNode = undefined; + if (!isJS) { + var type = checker.getTypeOfSymbolAtLocation(usage.symbol, usage.node); + // Widen the type so we don't emit nonsense annotations like "function fn(x: 3) {" + type = checker.getBaseTypeOfLiteralType(type); + typeNode = checker.typeToTypeNode(type, node, ts.NodeBuilderFlags.NoTruncation); + } + var paramDecl = ts.createParameter( + /*decorators*/ undefined, + /*modifiers*/ undefined, + /*dotDotDotToken*/ undefined, + /*name*/ name, + /*questionToken*/ undefined, typeNode); + parameters.push(paramDecl); + if (usage.usage === 2 /* Write */) { + (writes || (writes = [])).push(usage); + } + callArguments.push(ts.createIdentifier(name)); }); + // Provide explicit return types for contexutally-typed functions + // to avoid problems when there are literal types present + if (ts.isExpression(node) && !isJS) { + var contextualType = checker.getContextualType(node); + returnType = checker.typeToTypeNode(contextualType); + } + var _b = transformFunctionBody(node), body = _b.body, returnValueProperty = _b.returnValueProperty; + var newFunction; + if (ts.isClassLike(scope)) { + // always create private method in TypeScript files + var modifiers = isJS ? [] : [ts.createToken(112 /* PrivateKeyword */)]; + if (range.facts & RangeFacts.InStaticRegion) { + modifiers.push(ts.createToken(115 /* StaticKeyword */)); + } + if (range.facts & RangeFacts.IsAsyncFunction) { + modifiers.push(ts.createToken(120 /* AsyncKeyword */)); + } + newFunction = ts.createMethod( + /*decorators*/ undefined, modifiers, range.facts & RangeFacts.IsGenerator ? ts.createToken(39 /* AsteriskToken */) : undefined, functionName, + /*questionToken*/ undefined, + /*typeParameters*/ [], parameters, returnType, body); + } + else { + newFunction = ts.createFunctionDeclaration( + /*decorators*/ undefined, range.facts & RangeFacts.IsAsyncFunction ? [ts.createToken(120 /* AsyncKeyword */)] : undefined, range.facts & RangeFacts.IsGenerator ? ts.createToken(39 /* AsteriskToken */) : undefined, functionName, + /*typeParameters*/ [], parameters, returnType, body); + } + var changeTracker = ts.textChanges.ChangeTracker.fromCodeFixContext(context); + // insert function at the end of the scope + changeTracker.insertNodeBefore(context.file, scope.getLastToken(), newFunction, { prefix: context.newLineCharacter, suffix: context.newLineCharacter }); + var newNodes = []; + // replace range with function call + var call = ts.createCall(ts.isClassLike(scope) ? ts.createPropertyAccess(range.facts & RangeFacts.InStaticRegion ? ts.createIdentifier(scope.name.getText()) : ts.createThis(), functionReference) : functionReference, + /*typeArguments*/ undefined, callArguments); + if (range.facts & RangeFacts.IsGenerator) { + call = ts.createYield(ts.createToken(39 /* AsteriskToken */), call); + } + if (range.facts & RangeFacts.IsAsyncFunction) { + call = ts.createAwait(call); + } + if (writes) { + if (returnValueProperty) { + // has both writes and return, need to create variable declaration to hold return value; + newNodes.push(ts.createVariableStatement( + /*modifiers*/ undefined, [ts.createVariableDeclaration(returnValueProperty, ts.createKeywordTypeNode(119 /* AnyKeyword */))])); + } + var assignments = getPropertyAssignmentsForWrites(writes); + if (returnValueProperty) { + assignments.unshift(ts.createShorthandPropertyAssignment(returnValueProperty)); + } + // propagate writes back + if (assignments.length === 1) { + if (returnValueProperty) { + newNodes.push(ts.createReturn(ts.createIdentifier(returnValueProperty))); + } + else { + newNodes.push(ts.createStatement(ts.createBinary(assignments[0].name, 58 /* EqualsToken */, call))); + } + } + else { + // emit e.g. + // { a, b, __return } = newFunction(a, b); + // return __return; + newNodes.push(ts.createStatement(ts.createBinary(ts.createObjectLiteral(assignments), 58 /* EqualsToken */, call))); + if (returnValueProperty) { + newNodes.push(ts.createReturn(ts.createIdentifier(returnValueProperty))); + } + } + } + else { + if (range.facts & RangeFacts.HasReturn) { + newNodes.push(ts.createReturn(call)); + } + else if (isReadonlyArray(range.range)) { + newNodes.push(ts.createStatement(call)); + } + else { + newNodes.push(call); + } + } + if (isReadonlyArray(range.range)) { + changeTracker.replaceNodesWithNodes(context.file, range.range, newNodes, { + nodeSeparator: context.newLineCharacter, + suffix: context.newLineCharacter // insert newline only when replacing statements + }); + } + else { + changeTracker.replaceNodeWithNodes(context.file, range.range, newNodes, { nodeSeparator: context.newLineCharacter }); + } + return { + scope: scope, + scopeDescription: getDescriptionForScope(scope), + changes: changeTracker.getChanges() + }; + function getPropertyAssignmentsForWrites(writes) { + return writes.map(function (w) { return ts.createShorthandPropertyAssignment(w.symbol.name); }); + } + function generateReturnValueProperty() { + return "__return"; + } + function transformFunctionBody(body) { + if (ts.isBlock(body) && !writes && substitutions.size === 0) { + // already block, no writes to propagate back, no substitutions - can use node as is + return { body: ts.createBlock(body.statements, /*multLine*/ true), returnValueProperty: undefined }; + } + var returnValueProperty; + var statements = ts.createNodeArray(ts.isBlock(body) ? body.statements.slice(0) : [ts.isStatement(body) ? body : ts.createReturn(body)]); + // rewrite body if either there are writes that should be propagated back via return statements or there are substitutions + if (writes || substitutions.size) { + var rewrittenStatements = ts.visitNodes(statements, visitor).slice(); + if (writes && !(range.facts & RangeFacts.HasReturn) && ts.isStatement(body)) { + // add return at the end to propagate writes back in case if control flow falls out of the function body + // it is ok to know that range has at least one return since it we only allow unconditional returns + var assignments = getPropertyAssignmentsForWrites(writes); + if (assignments.length === 1) { + rewrittenStatements.push(ts.createReturn(assignments[0].name)); + } + else { + rewrittenStatements.push(ts.createReturn(ts.createObjectLiteral(assignments))); + } + } + return { body: ts.createBlock(rewrittenStatements, /*multiLine*/ true), returnValueProperty: returnValueProperty }; + } + else { + return { body: ts.createBlock(statements, /*multiLine*/ true), returnValueProperty: undefined }; + } + function visitor(node) { + if (node.kind === 219 /* ReturnStatement */ && writes) { + var assignments = getPropertyAssignmentsForWrites(writes); + if (node.expression) { + if (!returnValueProperty) { + returnValueProperty = generateReturnValueProperty(); + } + assignments.unshift(ts.createPropertyAssignment(returnValueProperty, ts.visitNode(node.expression, visitor))); + } + if (assignments.length === 1) { + return ts.createReturn(assignments[0].name); + } + else { + return ts.createReturn(ts.createObjectLiteral(assignments)); + } + } + else { + var substitution = substitutions.get(ts.getNodeId(node).toString()); + return substitution || ts.visitEachChild(node, visitor, ts.nullTransformationContext); + } + } + } } - function createClassFromVariableDeclaration(node) { - var initializer = node.initializer; - if (!initializer || initializer.kind !== 186 /* FunctionExpression */) { + extractMethod_1.extractFunctionInScope = extractFunctionInScope; + function isReadonlyArray(v) { + return ts.isArray(v); + } + /** + * Produces a range that spans the entirety of nodes, given a selection + * that might start/end in the middle of nodes. + * + * For example, when the user makes a selection like this + * v---v + * var someThing = foo + bar; + * this returns ^-------^ + */ + function getEnclosingTextRange(targetRange, sourceFile) { + return isReadonlyArray(targetRange.range) + ? { pos: targetRange.range[0].getStart(sourceFile), end: targetRange.range[targetRange.range.length - 1].getEnd() } + : targetRange.range; + } + var Usage; + (function (Usage) { + // value should be passed to extracted method + Usage[Usage["Read"] = 1] = "Read"; + // value should be passed to extracted method and propagated back + Usage[Usage["Write"] = 2] = "Write"; + })(Usage || (Usage = {})); + function collectReadsAndWrites(targetRange, scopes, enclosingTextRange, sourceFile, checker) { + var usagesPerScope = []; + var substitutionsPerScope = []; + var errorsPerScope = []; + var visibleDeclarationsInExtractedRange = []; + // initialize results + for (var _i = 0, scopes_1 = scopes; _i < scopes_1.length; _i++) { + var _ = scopes_1[_i]; + usagesPerScope.push({ usages: ts.createMap(), substitutions: ts.createMap() }); + substitutionsPerScope.push(ts.createMap()); + errorsPerScope.push([]); + } + var seenUsages = ts.createMap(); + var target = isReadonlyArray(targetRange.range) ? ts.createBlock(targetRange.range) : targetRange.range; + var containingLexicalScopeOfExtraction = ts.isBlockScope(scopes[0], scopes[0].parent) ? scopes[0] : ts.getEnclosingBlockScopeContainer(scopes[0]); + collectUsages(target); + var _loop_8 = function (i) { + var hasWrite = false; + var readonlyClassPropertyWrite = undefined; + usagesPerScope[i].usages.forEach(function (value) { + if (value.usage === 2 /* Write */) { + hasWrite = true; + if (value.symbol.flags & 106500 /* ClassMember */ && + value.symbol.valueDeclaration && + ts.hasModifier(value.symbol.valueDeclaration, 64 /* Readonly */)) { + readonlyClassPropertyWrite = value.symbol.valueDeclaration; + } + } + }); + if (hasWrite && !isReadonlyArray(targetRange.range) && ts.isExpression(targetRange.range)) { + errorsPerScope[i].push(ts.createDiagnosticForNode(targetRange.range, Messages.CannotCombineWritesAndReturns)); + } + else if (readonlyClassPropertyWrite && i > 0) { + errorsPerScope[i].push(ts.createDiagnosticForNode(readonlyClassPropertyWrite, Messages.CannotCombineWritesAndReturns)); + } + }; + for (var i = 0; i < scopes.length; i++) { + _loop_8(i); + } + // If there are any declarations in the extracted block that are used in the same enclosing + // lexical scope, we can't move the extraction "up" as those declarations will become unreachable + if (visibleDeclarationsInExtractedRange.length) { + ts.forEachChild(containingLexicalScopeOfExtraction, checkForUsedDeclarations); + } + return { target: target, usagesPerScope: usagesPerScope, errorsPerScope: errorsPerScope }; + function collectUsages(node, valueUsage) { + if (valueUsage === void 0) { valueUsage = 1 /* Read */; } + if (ts.isDeclaration(node) && node.symbol) { + visibleDeclarationsInExtractedRange.push(node.symbol); + } + if (ts.isAssignmentExpression(node)) { + // use 'write' as default usage for values + collectUsages(node.left, 2 /* Write */); + collectUsages(node.right); + } + else if (ts.isUnaryExpressionWithWrite(node)) { + collectUsages(node.operand, 2 /* Write */); + } + else if (ts.isPropertyAccessExpression(node) || ts.isElementAccessExpression(node)) { + // use 'write' as default usage for values + ts.forEachChild(node, collectUsages); + } + else if (ts.isIdentifier(node)) { + if (!node.parent) { + return; + } + if (ts.isQualifiedName(node.parent) && node !== node.parent.left) { + return; + } + if (ts.isPropertyAccessExpression(node.parent) && node !== node.parent.expression) { + return; + } + recordUsage(node, valueUsage, /*isTypeNode*/ ts.isPartOfTypeNode(node)); + } + else { + ts.forEachChild(node, collectUsages); + } + } + function recordUsage(n, usage, isTypeNode) { + var symbolId = recordUsagebySymbol(n, usage, isTypeNode); + if (symbolId) { + for (var i = 0; i < scopes.length; i++) { + // push substitution from map to map to simplify rewriting + var substitition = substitutionsPerScope[i].get(symbolId); + if (substitition) { + usagesPerScope[i].substitutions.set(ts.getNodeId(n).toString(), substitition); + } + } + } + } + function recordUsagebySymbol(identifier, usage, isTypeName) { + var symbol = checker.getSymbolAtLocation(identifier); + if (!symbol) { + // cannot find symbol - do nothing + return undefined; + } + var symbolId = ts.getSymbolId(symbol).toString(); + var lastUsage = seenUsages.get(symbolId); + // there are two kinds of value usages + // - reads - if range contains a read from the value located outside of the range then value should be passed as a parameter + // - writes - if range contains a write to a value located outside the range the value should be passed as a parameter and + // returned as a return value + // 'write' case is a superset of 'read' so if we already have processed 'write' of some symbol there is not need to handle 'read' + // since all information is already recorded + if (lastUsage && lastUsage >= usage) { + return symbolId; + } + seenUsages.set(symbolId, usage); + if (lastUsage) { + // if we get here this means that we are trying to handle 'write' and 'read' was already processed + // walk scopes and update existing records. + for (var _i = 0, usagesPerScope_1 = usagesPerScope; _i < usagesPerScope_1.length; _i++) { + var perScope = usagesPerScope_1[_i]; + var prevEntry = perScope.usages.get(identifier.text); + if (prevEntry) { + perScope.usages.set(identifier.text, { usage: usage, symbol: symbol, node: identifier }); + } + } + return symbolId; + } + // find first declaration in this file + var declInFile = ts.find(symbol.getDeclarations(), function (d) { return d.getSourceFile() === sourceFile; }); + if (!declInFile) { + return undefined; + } + if (ts.rangeContainsRange(enclosingTextRange, declInFile)) { + // declaration is located in range to be extracted - do nothing + return undefined; + } + if (targetRange.facts & RangeFacts.IsGenerator && usage === 2 /* Write */) { + // this is write to a reference located outside of the target scope and range is extracted into generator + // currently this is unsupported scenario + for (var _a = 0, errorsPerScope_1 = errorsPerScope; _a < errorsPerScope_1.length; _a++) { + var errors = errorsPerScope_1[_a]; + errors.push(ts.createDiagnosticForNode(identifier, Messages.CannotExtractRangeThatContainsWritesToReferencesLocatedOutsideOfTheTargetRangeInGenerators)); + } + } + for (var i = 0; i < scopes.length; i++) { + var scope = scopes[i]; + var resolvedSymbol = checker.resolveName(symbol.name, scope, symbol.flags); + if (resolvedSymbol === symbol) { + continue; + } + if (!substitutionsPerScope[i].has(symbolId)) { + var substitution = tryReplaceWithQualifiedNameOrPropertyAccess(symbol.exportSymbol || symbol, scope, isTypeName); + if (substitution) { + substitutionsPerScope[i].set(symbolId, substitution); + } + else if (isTypeName) { + errorsPerScope[i].push(ts.createDiagnosticForNode(identifier, Messages.TypeWillNotBeVisibleInTheNewScope)); + } + else { + usagesPerScope[i].usages.set(identifier.text, { usage: usage, symbol: symbol, node: identifier }); + } + } + } + return symbolId; + } + function checkForUsedDeclarations(node) { + // If this node is entirely within the original extraction range, we don't need to do anything. + if (node === targetRange.range || (isReadonlyArray(targetRange.range) && targetRange.range.indexOf(node) >= 0)) { + return; + } + // Otherwise check and recurse. + var sym = checker.getSymbolAtLocation(node); + if (sym && visibleDeclarationsInExtractedRange.some(function (d) { return d === sym; })) { + for (var _i = 0, errorsPerScope_2 = errorsPerScope; _i < errorsPerScope_2.length; _i++) { + var scope = errorsPerScope_2[_i]; + scope.push(ts.createDiagnosticForNode(node, Messages.CannotExtractExportedEntity)); + } + return true; + } + else { + ts.forEachChild(node, checkForUsedDeclarations); + } + } + function tryReplaceWithQualifiedNameOrPropertyAccess(symbol, scopeDecl, isTypeNode) { + if (!symbol) { + return undefined; + } + if (symbol.getDeclarations().some(function (d) { return d.parent === scopeDecl; })) { + return ts.createIdentifier(symbol.name); + } + var prefix = tryReplaceWithQualifiedNameOrPropertyAccess(symbol.parent, scopeDecl, isTypeNode); + if (prefix === undefined) { + return undefined; + } + return isTypeNode ? ts.createQualifiedName(prefix, ts.createIdentifier(symbol.name)) : ts.createPropertyAccess(prefix, symbol.name); + } + } + function getParentNodeInSpan(node, file, span) { + if (!node) return undefined; + while (node.parent) { + if (ts.isSourceFile(node.parent) || !spanContainsNode(span, node.parent, file)) { + return node; + } + node = node.parent; } - if (node.name.kind !== 71 /* Identifier */) { - return undefined; - } - var memberElements = createClassElementsFromSymbol(initializer.symbol); - if (initializer.body) { - memberElements.unshift(ts.createConstructor(/*decorators*/ undefined, /*modifiers*/ undefined, initializer.parameters, initializer.body)); - } - var cls = ts.createClassDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, node.name, - /*typeParameters*/ undefined, /*heritageClauses*/ undefined, memberElements); - // Don't call copyComments here because we'll already leave them in place - return cls; } - function createClassFromFunctionDeclaration(node) { - var memberElements = createClassElementsFromSymbol(ctorSymbol); - if (node.body) { - memberElements.unshift(ts.createConstructor(/*decorators*/ undefined, /*modifiers*/ undefined, node.parameters, node.body)); - } - var cls = ts.createClassDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, node.name, - /*typeParameters*/ undefined, /*heritageClauses*/ undefined, memberElements); - // Don't call copyComments here because we'll already leave them in place - return cls; + function spanContainsNode(span, node, file) { + return ts.textSpanContainsPosition(span, node.getStart(file)) && + node.getEnd() <= ts.textSpanEnd(span); } - } + /** + * Computes whether or not a node represents an expression in a position where it could + * be extracted. + * The isExpression() in utilities.ts returns some false positives we need to handle, + * such as `import x from 'y'` -- the 'y' is a StringLiteral but is *not* an expression + * in the sense of something that you could extract on + */ + function isExtractableExpression(node) { + switch (node.parent.kind) { + case 264 /* EnumMember */: + return false; + } + switch (node.kind) { + case 9 /* StringLiteral */: + return node.parent.kind !== 238 /* ImportDeclaration */ && + node.parent.kind !== 242 /* ImportSpecifier */; + case 198 /* SpreadElement */: + case 174 /* ObjectBindingPattern */: + case 176 /* BindingElement */: + return false; + case 71 /* Identifier */: + return node.parent.kind !== 176 /* BindingElement */ && + node.parent.kind !== 242 /* ImportSpecifier */ && + node.parent.kind !== 246 /* ExportSpecifier */; + } + return true; + } + function isBlockLike(node) { + switch (node.kind) { + case 207 /* Block */: + case 265 /* SourceFile */: + case 234 /* ModuleBlock */: + case 257 /* CaseClause */: + return true; + default: + return false; + } + } + })(extractMethod = refactor.extractMethod || (refactor.extractMethod = {})); })(refactor = ts.refactor || (ts.refactor = {})); })(ts || (ts = {})); /// +/// /// /// /// @@ -89074,7 +90729,7 @@ var ts; node.parent = parent; return node; } - var NodeObject = (function () { + var NodeObject = /** @class */ (function () { function NodeObject(kind, pos, end) { this.pos = pos; this.end = end; @@ -89117,12 +90772,14 @@ var ts; ts.scanner.setTextPos(pos); while (pos < end) { var token = ts.scanner.scan(); - ts.Debug.assert(token !== 1 /* EndOfFileToken */); // Else it would infinitely loop var textPos = ts.scanner.getTextPos(); if (textPos <= end) { nodes.push(createNode(token, pos, textPos, this)); } pos = textPos; + if (token === 1 /* EndOfFileToken */) { + break; + } } return pos; }; @@ -89227,7 +90884,7 @@ var ts; }; return NodeObject; }()); - var TokenOrIdentifierObject = (function () { + var TokenOrIdentifierObject = /** @class */ (function () { function TokenOrIdentifierObject(pos, end) { // Set properties in same order as NodeObject this.pos = pos; @@ -89282,7 +90939,7 @@ var ts; }; return TokenOrIdentifierObject; }()); - var SymbolObject = (function () { + var SymbolObject = /** @class */ (function () { function SymbolObject(flags, name) { this.flags = flags; this.escapedName = name; @@ -89320,7 +90977,7 @@ var ts; }; return SymbolObject; }()); - var TokenObject = (function (_super) { + var TokenObject = /** @class */ (function (_super) { __extends(TokenObject, _super); function TokenObject(kind, pos, end) { var _this = _super.call(this, pos, end) || this; @@ -89329,7 +90986,7 @@ var ts; } return TokenObject; }(TokenOrIdentifierObject)); - var IdentifierObject = (function (_super) { + var IdentifierObject = /** @class */ (function (_super) { __extends(IdentifierObject, _super); function IdentifierObject(_kind, pos, end) { return _super.call(this, pos, end) || this; @@ -89344,7 +91001,7 @@ var ts; return IdentifierObject; }(TokenOrIdentifierObject)); IdentifierObject.prototype.kind = 71 /* Identifier */; - var TypeObject = (function () { + var TypeObject = /** @class */ (function () { function TypeObject(checker, flags) { this.checker = checker; this.flags = flags; @@ -89386,7 +91043,7 @@ var ts; }; return TypeObject; }()); - var SignatureObject = (function () { + var SignatureObject = /** @class */ (function () { function SignatureObject(checker) { this.checker = checker; } @@ -89416,7 +91073,7 @@ var ts; }; return SignatureObject; }()); - var SourceFileObject = (function (_super) { + var SourceFileObject = /** @class */ (function (_super) { __extends(SourceFileObject, _super); function SourceFileObject(kind, pos, end) { return _super.call(this, kind, pos, end) || this; @@ -89587,7 +91244,7 @@ var ts; }; return SourceFileObject; }(NodeObject)); - var SourceMapSourceObject = (function () { + var SourceMapSourceObject = /** @class */ (function () { function SourceMapSourceObject(fileName, text, skipTrivia) { this.fileName = fileName; this.text = text; @@ -89656,7 +91313,7 @@ var ts; // Cache host information about script Should be refreshed // at each language service public entry point, since we don't know when // the set of scripts handled by the host changes. - var HostCache = (function () { + var HostCache = /** @class */ (function () { function HostCache(host, getCanonicalFileName) { this.host = host; // script id => script index @@ -89718,7 +91375,7 @@ var ts; }; return HostCache; }()); - var SyntaxTreeCache = (function () { + var SyntaxTreeCache = /** @class */ (function () { function SyntaxTreeCache(host) { this.host = host; } @@ -89813,7 +91470,7 @@ var ts; return createLanguageServiceSourceFile(sourceFile.fileName, scriptSnapshot, sourceFile.languageVersion, version, /*setNodeParents*/ true, sourceFile.scriptKind); } ts.updateLanguageServiceSourceFile = updateLanguageServiceSourceFile; - var CancellationTokenObject = (function () { + var CancellationTokenObject = /** @class */ (function () { function CancellationTokenObject(cancellationToken) { this.cancellationToken = cancellationToken; } @@ -89829,7 +91486,7 @@ var ts; }()); /* @internal */ /** A cancellation that throttles calls to the host */ - var ThrottledCancellationToken = (function () { + var ThrottledCancellationToken = /** @class */ (function () { function ThrottledCancellationToken(hostCancellationToken, throttleWaitMilliseconds) { if (throttleWaitMilliseconds === void 0) { throttleWaitMilliseconds = 20; } this.hostCancellationToken = hostCancellationToken; @@ -89980,8 +91637,8 @@ var ts; if (program) { var oldSourceFiles = program.getSourceFiles(); var oldSettingsKey = documentRegistry.getKeyForCompilationSettings(oldSettings); - for (var _i = 0, oldSourceFiles_1 = oldSourceFiles; _i < oldSourceFiles_1.length; _i++) { - var oldSourceFile = oldSourceFiles_1[_i]; + for (var _i = 0, oldSourceFiles_2 = oldSourceFiles; _i < oldSourceFiles_2.length; _i++) { + var oldSourceFile = oldSourceFiles_2[_i]; if (!newProgram.getSourceFile(oldSourceFile.fileName) || shouldCreateNewSourceFiles) { documentRegistry.releaseDocumentWithKey(oldSourceFile.path, oldSettingsKey); } @@ -90038,7 +91695,7 @@ var ts; // We do not support the scenario where a host can modify a registered // file's script kind, i.e. in one project some file is treated as ".ts" // and in another as ".js" - ts.Debug.assert(hostFileInformation.scriptKind === oldSourceFile.scriptKind, "Registered script kind (" + oldSourceFile.scriptKind + ") should match new script kind (" + hostFileInformation.scriptKind + ") for file: " + path); + ts.Debug.assertEqual(hostFileInformation.scriptKind, oldSourceFile.scriptKind, "Registered script kind should match new script kind.", path); return documentRegistry.updateDocumentWithKey(fileName, path, newSettings, documentRegistryBucketKey, hostFileInformation.scriptSnapshot, hostFileInformation.version, hostFileInformation.scriptKind); } // We didn't already have the file. Fall through and acquire it from the registry. @@ -90447,17 +92104,19 @@ var ts; function getFormattingEditsAfterKeystroke(fileName, position, key, options) { var sourceFile = syntaxTreeCache.getCurrentSourceFile(fileName); var settings = toEditorSettings(options); - if (key === "{") { - return ts.formatting.formatOnOpeningCurly(position, sourceFile, getRuleProvider(settings), settings); - } - else if (key === "}") { - return ts.formatting.formatOnClosingCurly(position, sourceFile, getRuleProvider(settings), settings); - } - else if (key === ";") { - return ts.formatting.formatOnSemicolon(position, sourceFile, getRuleProvider(settings), settings); - } - else if (key === "\n") { - return ts.formatting.formatOnEnter(position, sourceFile, getRuleProvider(settings), settings); + if (!ts.isInComment(sourceFile, position)) { + if (key === "{") { + return ts.formatting.formatOnOpeningCurly(position, sourceFile, getRuleProvider(settings), settings); + } + else if (key === "}") { + return ts.formatting.formatOnClosingCurly(position, sourceFile, getRuleProvider(settings), settings); + } + else if (key === ";") { + return ts.formatting.formatOnSemicolon(position, sourceFile, getRuleProvider(settings), settings); + } + else if (key === "\n") { + return ts.formatting.formatOnEnter(position, sourceFile, getRuleProvider(settings), settings); + } } return []; } @@ -90504,6 +92163,11 @@ var ts; } return true; } + function getSpanOfEnclosingComment(fileName, position, onlyMultiLine) { + var sourceFile = syntaxTreeCache.getCurrentSourceFile(fileName); + var range = ts.formatting.getRangeOfEnclosingComment(sourceFile, position, onlyMultiLine); + return range && ts.createTextSpanFromRange(range); + } function getTodoComments(fileName, descriptors) { // Note: while getting todo comments seems like a syntactic operation, we actually // treat it as a semantic operation here. This is because we expect our host to call @@ -90693,6 +92357,7 @@ var ts; getFormattingEditsAfterKeystroke: getFormattingEditsAfterKeystroke, getDocCommentTemplateAtPosition: getDocCommentTemplateAtPosition, isValidBraceCompletionAtPosition: isValidBraceCompletionAtPosition, + getSpanOfEnclosingComment: getSpanOfEnclosingComment, getCodeFixesAtPosition: getCodeFixesAtPosition, getEmitOutput: getEmitOutput, getNonBoundSourceFile: getNonBoundSourceFile, @@ -90777,12 +92442,17 @@ var ts; function getPropertySymbolsFromContextualType(typeChecker, node) { var objectLiteral = node.parent; var contextualType = typeChecker.getContextualType(objectLiteral); - var name = ts.unescapeLeadingUnderscores(ts.getTextOfPropertyName(node.name)); - if (name && contextualType) { + return getPropertySymbolsFromType(contextualType, node.name); + } + ts.getPropertySymbolsFromContextualType = getPropertySymbolsFromContextualType; + /* @internal */ + function getPropertySymbolsFromType(type, propName) { + var name = ts.unescapeLeadingUnderscores(ts.getTextOfPropertyName(propName)); + if (name && type) { var result_10 = []; - var symbol = contextualType.getProperty(name); - if (contextualType.flags & 65536 /* Union */) { - ts.forEach(contextualType.types, function (t) { + var symbol = type.getProperty(name); + if (type.flags & 65536 /* Union */) { + ts.forEach(type.types, function (t) { var symbol = t.getProperty(name); if (symbol) { result_10.push(symbol); @@ -90797,7 +92467,7 @@ var ts; } return undefined; } - ts.getPropertySymbolsFromContextualType = getPropertySymbolsFromContextualType; + ts.getPropertySymbolsFromType = getPropertySymbolsFromType; function isArgumentOfElementAccessExpression(node) { return node && node.parent && @@ -91352,7 +93022,7 @@ var ts; } } function spanInOpenParenToken(node) { - if (node.parent.kind === 212 /* DoStatement */ || + if (node.parent.kind === 212 /* DoStatement */ || // Go to while keyword and do action instead node.parent.kind === 181 /* CallExpression */ || node.parent.kind === 182 /* NewExpression */) { return spanInPreviousNode(node); @@ -91471,7 +93141,7 @@ var ts; logger.log("*INTERNAL ERROR* - Exception in typescript services: " + err.message); } } - var ScriptSnapshotShimAdapter = (function () { + var ScriptSnapshotShimAdapter = /** @class */ (function () { function ScriptSnapshotShimAdapter(scriptSnapshotShim) { this.scriptSnapshotShim = scriptSnapshotShim; } @@ -91499,7 +93169,7 @@ var ts; }; return ScriptSnapshotShimAdapter; }()); - var LanguageServiceShimHostAdapter = (function () { + var LanguageServiceShimHostAdapter = /** @class */ (function () { function LanguageServiceShimHostAdapter(shimHost) { var _this = this; this.shimHost = shimHost; @@ -91623,7 +93293,7 @@ var ts; return LanguageServiceShimHostAdapter; }()); ts.LanguageServiceShimHostAdapter = LanguageServiceShimHostAdapter; - var CoreServicesShimHostAdapter = (function () { + var CoreServicesShimHostAdapter = /** @class */ (function () { function CoreServicesShimHostAdapter(shimHost) { var _this = this; this.shimHost = shimHost; @@ -91688,7 +93358,7 @@ var ts; return JSON.stringify({ error: err }); } } - var ShimBase = (function () { + var ShimBase = /** @class */ (function () { function ShimBase(factory) { this.factory = factory; factory.registerShim(this); @@ -91712,7 +93382,7 @@ var ts; code: diagnostic.code }; } - var LanguageServiceShimObject = (function (_super) { + var LanguageServiceShimObject = /** @class */ (function (_super) { __extends(LanguageServiceShimObject, _super); function LanguageServiceShimObject(factory, host, languageService) { var _this = _super.call(this, factory) || this; @@ -91878,6 +93548,10 @@ var ts; var _this = this; return this.forwardJSONCall("isValidBraceCompletionAtPosition('" + fileName + "', " + position + ", " + openingBrace + ")", function () { return _this.languageService.isValidBraceCompletionAtPosition(fileName, position, openingBrace); }); }; + LanguageServiceShimObject.prototype.getSpanOfEnclosingComment = function (fileName, position, onlyMultiLine) { + var _this = this; + return this.forwardJSONCall("getSpanOfEnclosingComment('" + fileName + "', " + position + ")", function () { return _this.languageService.getSpanOfEnclosingComment(fileName, position, onlyMultiLine); }); + }; /// GET SMART INDENT LanguageServiceShimObject.prototype.getIndentationAtPosition = function (fileName, position, options /*Services.EditorOptions*/) { var _this = this; @@ -91985,7 +93659,7 @@ var ts; function convertClassifications(classifications) { return { spans: classifications.spans.join(","), endOfLineState: classifications.endOfLineState }; } - var ClassifierShimObject = (function (_super) { + var ClassifierShimObject = /** @class */ (function (_super) { __extends(ClassifierShimObject, _super); function ClassifierShimObject(factory, logger) { var _this = _super.call(this, factory) || this; @@ -92012,7 +93686,7 @@ var ts; }; return ClassifierShimObject; }(ShimBase)); - var CoreServicesShimObject = (function (_super) { + var CoreServicesShimObject = /** @class */ (function (_super) { __extends(CoreServicesShimObject, _super); function CoreServicesShimObject(factory, logger, host) { var _this = _super.call(this, factory) || this; @@ -92119,7 +93793,7 @@ var ts; }; return CoreServicesShimObject; }(ShimBase)); - var TypeScriptServicesFactory = (function () { + var TypeScriptServicesFactory = /** @class */ (function () { function TypeScriptServicesFactory() { this._shims = []; } @@ -92200,4 +93874,6 @@ var TypeScript; // 'toolsVersion' gets consumed by the managed side, so it's not unused. // TODO: it should be moved into a namespace though. /* @internal */ -var toolsVersion = "2.5"; +var toolsVersion = "2.6"; + +//# sourceMappingURL=typescriptServices.js.map diff --git a/lib/typingsInstaller.js b/lib/typingsInstaller.js index 0aea3ef2359..5f69ba3ddcd 100644 --- a/lib/typingsInstaller.js +++ b/lib/typingsInstaller.js @@ -14,6 +14,14 @@ and limitations under the License. ***************************************************************************** */ "use strict"; +var __assign = (this && this.__assign) || Object.assign || function(t) { + for (var s, i = 1, n = arguments.length; i < n; i++) { + s = arguments[i]; + for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) + t[p] = s[p]; + } + return t; +}; var __extends = (this && this.__extends) || (function () { var extendStatics = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || @@ -26,12 +34,443 @@ var __extends = (this && this.__extends) || (function () { })(); var ts; (function (ts) { + var SyntaxKind; + (function (SyntaxKind) { + SyntaxKind[SyntaxKind["Unknown"] = 0] = "Unknown"; + SyntaxKind[SyntaxKind["EndOfFileToken"] = 1] = "EndOfFileToken"; + SyntaxKind[SyntaxKind["SingleLineCommentTrivia"] = 2] = "SingleLineCommentTrivia"; + SyntaxKind[SyntaxKind["MultiLineCommentTrivia"] = 3] = "MultiLineCommentTrivia"; + SyntaxKind[SyntaxKind["NewLineTrivia"] = 4] = "NewLineTrivia"; + SyntaxKind[SyntaxKind["WhitespaceTrivia"] = 5] = "WhitespaceTrivia"; + SyntaxKind[SyntaxKind["ShebangTrivia"] = 6] = "ShebangTrivia"; + SyntaxKind[SyntaxKind["ConflictMarkerTrivia"] = 7] = "ConflictMarkerTrivia"; + SyntaxKind[SyntaxKind["NumericLiteral"] = 8] = "NumericLiteral"; + SyntaxKind[SyntaxKind["StringLiteral"] = 9] = "StringLiteral"; + SyntaxKind[SyntaxKind["JsxText"] = 10] = "JsxText"; + SyntaxKind[SyntaxKind["JsxTextAllWhiteSpaces"] = 11] = "JsxTextAllWhiteSpaces"; + SyntaxKind[SyntaxKind["RegularExpressionLiteral"] = 12] = "RegularExpressionLiteral"; + SyntaxKind[SyntaxKind["NoSubstitutionTemplateLiteral"] = 13] = "NoSubstitutionTemplateLiteral"; + SyntaxKind[SyntaxKind["TemplateHead"] = 14] = "TemplateHead"; + SyntaxKind[SyntaxKind["TemplateMiddle"] = 15] = "TemplateMiddle"; + SyntaxKind[SyntaxKind["TemplateTail"] = 16] = "TemplateTail"; + SyntaxKind[SyntaxKind["OpenBraceToken"] = 17] = "OpenBraceToken"; + SyntaxKind[SyntaxKind["CloseBraceToken"] = 18] = "CloseBraceToken"; + SyntaxKind[SyntaxKind["OpenParenToken"] = 19] = "OpenParenToken"; + SyntaxKind[SyntaxKind["CloseParenToken"] = 20] = "CloseParenToken"; + SyntaxKind[SyntaxKind["OpenBracketToken"] = 21] = "OpenBracketToken"; + SyntaxKind[SyntaxKind["CloseBracketToken"] = 22] = "CloseBracketToken"; + SyntaxKind[SyntaxKind["DotToken"] = 23] = "DotToken"; + SyntaxKind[SyntaxKind["DotDotDotToken"] = 24] = "DotDotDotToken"; + SyntaxKind[SyntaxKind["SemicolonToken"] = 25] = "SemicolonToken"; + SyntaxKind[SyntaxKind["CommaToken"] = 26] = "CommaToken"; + SyntaxKind[SyntaxKind["LessThanToken"] = 27] = "LessThanToken"; + SyntaxKind[SyntaxKind["LessThanSlashToken"] = 28] = "LessThanSlashToken"; + SyntaxKind[SyntaxKind["GreaterThanToken"] = 29] = "GreaterThanToken"; + SyntaxKind[SyntaxKind["LessThanEqualsToken"] = 30] = "LessThanEqualsToken"; + SyntaxKind[SyntaxKind["GreaterThanEqualsToken"] = 31] = "GreaterThanEqualsToken"; + SyntaxKind[SyntaxKind["EqualsEqualsToken"] = 32] = "EqualsEqualsToken"; + SyntaxKind[SyntaxKind["ExclamationEqualsToken"] = 33] = "ExclamationEqualsToken"; + SyntaxKind[SyntaxKind["EqualsEqualsEqualsToken"] = 34] = "EqualsEqualsEqualsToken"; + SyntaxKind[SyntaxKind["ExclamationEqualsEqualsToken"] = 35] = "ExclamationEqualsEqualsToken"; + SyntaxKind[SyntaxKind["EqualsGreaterThanToken"] = 36] = "EqualsGreaterThanToken"; + SyntaxKind[SyntaxKind["PlusToken"] = 37] = "PlusToken"; + SyntaxKind[SyntaxKind["MinusToken"] = 38] = "MinusToken"; + SyntaxKind[SyntaxKind["AsteriskToken"] = 39] = "AsteriskToken"; + SyntaxKind[SyntaxKind["AsteriskAsteriskToken"] = 40] = "AsteriskAsteriskToken"; + SyntaxKind[SyntaxKind["SlashToken"] = 41] = "SlashToken"; + SyntaxKind[SyntaxKind["PercentToken"] = 42] = "PercentToken"; + SyntaxKind[SyntaxKind["PlusPlusToken"] = 43] = "PlusPlusToken"; + SyntaxKind[SyntaxKind["MinusMinusToken"] = 44] = "MinusMinusToken"; + SyntaxKind[SyntaxKind["LessThanLessThanToken"] = 45] = "LessThanLessThanToken"; + SyntaxKind[SyntaxKind["GreaterThanGreaterThanToken"] = 46] = "GreaterThanGreaterThanToken"; + SyntaxKind[SyntaxKind["GreaterThanGreaterThanGreaterThanToken"] = 47] = "GreaterThanGreaterThanGreaterThanToken"; + SyntaxKind[SyntaxKind["AmpersandToken"] = 48] = "AmpersandToken"; + SyntaxKind[SyntaxKind["BarToken"] = 49] = "BarToken"; + SyntaxKind[SyntaxKind["CaretToken"] = 50] = "CaretToken"; + SyntaxKind[SyntaxKind["ExclamationToken"] = 51] = "ExclamationToken"; + SyntaxKind[SyntaxKind["TildeToken"] = 52] = "TildeToken"; + SyntaxKind[SyntaxKind["AmpersandAmpersandToken"] = 53] = "AmpersandAmpersandToken"; + SyntaxKind[SyntaxKind["BarBarToken"] = 54] = "BarBarToken"; + SyntaxKind[SyntaxKind["QuestionToken"] = 55] = "QuestionToken"; + SyntaxKind[SyntaxKind["ColonToken"] = 56] = "ColonToken"; + SyntaxKind[SyntaxKind["AtToken"] = 57] = "AtToken"; + SyntaxKind[SyntaxKind["EqualsToken"] = 58] = "EqualsToken"; + SyntaxKind[SyntaxKind["PlusEqualsToken"] = 59] = "PlusEqualsToken"; + SyntaxKind[SyntaxKind["MinusEqualsToken"] = 60] = "MinusEqualsToken"; + SyntaxKind[SyntaxKind["AsteriskEqualsToken"] = 61] = "AsteriskEqualsToken"; + SyntaxKind[SyntaxKind["AsteriskAsteriskEqualsToken"] = 62] = "AsteriskAsteriskEqualsToken"; + SyntaxKind[SyntaxKind["SlashEqualsToken"] = 63] = "SlashEqualsToken"; + SyntaxKind[SyntaxKind["PercentEqualsToken"] = 64] = "PercentEqualsToken"; + SyntaxKind[SyntaxKind["LessThanLessThanEqualsToken"] = 65] = "LessThanLessThanEqualsToken"; + SyntaxKind[SyntaxKind["GreaterThanGreaterThanEqualsToken"] = 66] = "GreaterThanGreaterThanEqualsToken"; + SyntaxKind[SyntaxKind["GreaterThanGreaterThanGreaterThanEqualsToken"] = 67] = "GreaterThanGreaterThanGreaterThanEqualsToken"; + SyntaxKind[SyntaxKind["AmpersandEqualsToken"] = 68] = "AmpersandEqualsToken"; + SyntaxKind[SyntaxKind["BarEqualsToken"] = 69] = "BarEqualsToken"; + SyntaxKind[SyntaxKind["CaretEqualsToken"] = 70] = "CaretEqualsToken"; + SyntaxKind[SyntaxKind["Identifier"] = 71] = "Identifier"; + SyntaxKind[SyntaxKind["BreakKeyword"] = 72] = "BreakKeyword"; + SyntaxKind[SyntaxKind["CaseKeyword"] = 73] = "CaseKeyword"; + SyntaxKind[SyntaxKind["CatchKeyword"] = 74] = "CatchKeyword"; + SyntaxKind[SyntaxKind["ClassKeyword"] = 75] = "ClassKeyword"; + SyntaxKind[SyntaxKind["ConstKeyword"] = 76] = "ConstKeyword"; + SyntaxKind[SyntaxKind["ContinueKeyword"] = 77] = "ContinueKeyword"; + SyntaxKind[SyntaxKind["DebuggerKeyword"] = 78] = "DebuggerKeyword"; + SyntaxKind[SyntaxKind["DefaultKeyword"] = 79] = "DefaultKeyword"; + SyntaxKind[SyntaxKind["DeleteKeyword"] = 80] = "DeleteKeyword"; + SyntaxKind[SyntaxKind["DoKeyword"] = 81] = "DoKeyword"; + SyntaxKind[SyntaxKind["ElseKeyword"] = 82] = "ElseKeyword"; + SyntaxKind[SyntaxKind["EnumKeyword"] = 83] = "EnumKeyword"; + SyntaxKind[SyntaxKind["ExportKeyword"] = 84] = "ExportKeyword"; + SyntaxKind[SyntaxKind["ExtendsKeyword"] = 85] = "ExtendsKeyword"; + SyntaxKind[SyntaxKind["FalseKeyword"] = 86] = "FalseKeyword"; + SyntaxKind[SyntaxKind["FinallyKeyword"] = 87] = "FinallyKeyword"; + SyntaxKind[SyntaxKind["ForKeyword"] = 88] = "ForKeyword"; + SyntaxKind[SyntaxKind["FunctionKeyword"] = 89] = "FunctionKeyword"; + SyntaxKind[SyntaxKind["IfKeyword"] = 90] = "IfKeyword"; + SyntaxKind[SyntaxKind["ImportKeyword"] = 91] = "ImportKeyword"; + SyntaxKind[SyntaxKind["InKeyword"] = 92] = "InKeyword"; + SyntaxKind[SyntaxKind["InstanceOfKeyword"] = 93] = "InstanceOfKeyword"; + SyntaxKind[SyntaxKind["NewKeyword"] = 94] = "NewKeyword"; + SyntaxKind[SyntaxKind["NullKeyword"] = 95] = "NullKeyword"; + SyntaxKind[SyntaxKind["ReturnKeyword"] = 96] = "ReturnKeyword"; + SyntaxKind[SyntaxKind["SuperKeyword"] = 97] = "SuperKeyword"; + SyntaxKind[SyntaxKind["SwitchKeyword"] = 98] = "SwitchKeyword"; + SyntaxKind[SyntaxKind["ThisKeyword"] = 99] = "ThisKeyword"; + SyntaxKind[SyntaxKind["ThrowKeyword"] = 100] = "ThrowKeyword"; + SyntaxKind[SyntaxKind["TrueKeyword"] = 101] = "TrueKeyword"; + SyntaxKind[SyntaxKind["TryKeyword"] = 102] = "TryKeyword"; + SyntaxKind[SyntaxKind["TypeOfKeyword"] = 103] = "TypeOfKeyword"; + SyntaxKind[SyntaxKind["VarKeyword"] = 104] = "VarKeyword"; + SyntaxKind[SyntaxKind["VoidKeyword"] = 105] = "VoidKeyword"; + SyntaxKind[SyntaxKind["WhileKeyword"] = 106] = "WhileKeyword"; + SyntaxKind[SyntaxKind["WithKeyword"] = 107] = "WithKeyword"; + SyntaxKind[SyntaxKind["ImplementsKeyword"] = 108] = "ImplementsKeyword"; + SyntaxKind[SyntaxKind["InterfaceKeyword"] = 109] = "InterfaceKeyword"; + SyntaxKind[SyntaxKind["LetKeyword"] = 110] = "LetKeyword"; + SyntaxKind[SyntaxKind["PackageKeyword"] = 111] = "PackageKeyword"; + SyntaxKind[SyntaxKind["PrivateKeyword"] = 112] = "PrivateKeyword"; + SyntaxKind[SyntaxKind["ProtectedKeyword"] = 113] = "ProtectedKeyword"; + SyntaxKind[SyntaxKind["PublicKeyword"] = 114] = "PublicKeyword"; + SyntaxKind[SyntaxKind["StaticKeyword"] = 115] = "StaticKeyword"; + SyntaxKind[SyntaxKind["YieldKeyword"] = 116] = "YieldKeyword"; + SyntaxKind[SyntaxKind["AbstractKeyword"] = 117] = "AbstractKeyword"; + SyntaxKind[SyntaxKind["AsKeyword"] = 118] = "AsKeyword"; + SyntaxKind[SyntaxKind["AnyKeyword"] = 119] = "AnyKeyword"; + SyntaxKind[SyntaxKind["AsyncKeyword"] = 120] = "AsyncKeyword"; + SyntaxKind[SyntaxKind["AwaitKeyword"] = 121] = "AwaitKeyword"; + SyntaxKind[SyntaxKind["BooleanKeyword"] = 122] = "BooleanKeyword"; + SyntaxKind[SyntaxKind["ConstructorKeyword"] = 123] = "ConstructorKeyword"; + SyntaxKind[SyntaxKind["DeclareKeyword"] = 124] = "DeclareKeyword"; + SyntaxKind[SyntaxKind["GetKeyword"] = 125] = "GetKeyword"; + SyntaxKind[SyntaxKind["IsKeyword"] = 126] = "IsKeyword"; + SyntaxKind[SyntaxKind["KeyOfKeyword"] = 127] = "KeyOfKeyword"; + SyntaxKind[SyntaxKind["ModuleKeyword"] = 128] = "ModuleKeyword"; + SyntaxKind[SyntaxKind["NamespaceKeyword"] = 129] = "NamespaceKeyword"; + SyntaxKind[SyntaxKind["NeverKeyword"] = 130] = "NeverKeyword"; + SyntaxKind[SyntaxKind["ReadonlyKeyword"] = 131] = "ReadonlyKeyword"; + SyntaxKind[SyntaxKind["RequireKeyword"] = 132] = "RequireKeyword"; + SyntaxKind[SyntaxKind["NumberKeyword"] = 133] = "NumberKeyword"; + SyntaxKind[SyntaxKind["ObjectKeyword"] = 134] = "ObjectKeyword"; + SyntaxKind[SyntaxKind["SetKeyword"] = 135] = "SetKeyword"; + SyntaxKind[SyntaxKind["StringKeyword"] = 136] = "StringKeyword"; + SyntaxKind[SyntaxKind["SymbolKeyword"] = 137] = "SymbolKeyword"; + SyntaxKind[SyntaxKind["TypeKeyword"] = 138] = "TypeKeyword"; + SyntaxKind[SyntaxKind["UndefinedKeyword"] = 139] = "UndefinedKeyword"; + SyntaxKind[SyntaxKind["FromKeyword"] = 140] = "FromKeyword"; + SyntaxKind[SyntaxKind["GlobalKeyword"] = 141] = "GlobalKeyword"; + SyntaxKind[SyntaxKind["OfKeyword"] = 142] = "OfKeyword"; + SyntaxKind[SyntaxKind["QualifiedName"] = 143] = "QualifiedName"; + SyntaxKind[SyntaxKind["ComputedPropertyName"] = 144] = "ComputedPropertyName"; + SyntaxKind[SyntaxKind["TypeParameter"] = 145] = "TypeParameter"; + SyntaxKind[SyntaxKind["Parameter"] = 146] = "Parameter"; + SyntaxKind[SyntaxKind["Decorator"] = 147] = "Decorator"; + SyntaxKind[SyntaxKind["PropertySignature"] = 148] = "PropertySignature"; + SyntaxKind[SyntaxKind["PropertyDeclaration"] = 149] = "PropertyDeclaration"; + SyntaxKind[SyntaxKind["MethodSignature"] = 150] = "MethodSignature"; + SyntaxKind[SyntaxKind["MethodDeclaration"] = 151] = "MethodDeclaration"; + SyntaxKind[SyntaxKind["Constructor"] = 152] = "Constructor"; + SyntaxKind[SyntaxKind["GetAccessor"] = 153] = "GetAccessor"; + SyntaxKind[SyntaxKind["SetAccessor"] = 154] = "SetAccessor"; + SyntaxKind[SyntaxKind["CallSignature"] = 155] = "CallSignature"; + SyntaxKind[SyntaxKind["ConstructSignature"] = 156] = "ConstructSignature"; + SyntaxKind[SyntaxKind["IndexSignature"] = 157] = "IndexSignature"; + SyntaxKind[SyntaxKind["TypePredicate"] = 158] = "TypePredicate"; + SyntaxKind[SyntaxKind["TypeReference"] = 159] = "TypeReference"; + SyntaxKind[SyntaxKind["FunctionType"] = 160] = "FunctionType"; + SyntaxKind[SyntaxKind["ConstructorType"] = 161] = "ConstructorType"; + SyntaxKind[SyntaxKind["TypeQuery"] = 162] = "TypeQuery"; + SyntaxKind[SyntaxKind["TypeLiteral"] = 163] = "TypeLiteral"; + SyntaxKind[SyntaxKind["ArrayType"] = 164] = "ArrayType"; + SyntaxKind[SyntaxKind["TupleType"] = 165] = "TupleType"; + SyntaxKind[SyntaxKind["UnionType"] = 166] = "UnionType"; + SyntaxKind[SyntaxKind["IntersectionType"] = 167] = "IntersectionType"; + SyntaxKind[SyntaxKind["ParenthesizedType"] = 168] = "ParenthesizedType"; + SyntaxKind[SyntaxKind["ThisType"] = 169] = "ThisType"; + SyntaxKind[SyntaxKind["TypeOperator"] = 170] = "TypeOperator"; + SyntaxKind[SyntaxKind["IndexedAccessType"] = 171] = "IndexedAccessType"; + SyntaxKind[SyntaxKind["MappedType"] = 172] = "MappedType"; + SyntaxKind[SyntaxKind["LiteralType"] = 173] = "LiteralType"; + SyntaxKind[SyntaxKind["ObjectBindingPattern"] = 174] = "ObjectBindingPattern"; + SyntaxKind[SyntaxKind["ArrayBindingPattern"] = 175] = "ArrayBindingPattern"; + SyntaxKind[SyntaxKind["BindingElement"] = 176] = "BindingElement"; + SyntaxKind[SyntaxKind["ArrayLiteralExpression"] = 177] = "ArrayLiteralExpression"; + SyntaxKind[SyntaxKind["ObjectLiteralExpression"] = 178] = "ObjectLiteralExpression"; + SyntaxKind[SyntaxKind["PropertyAccessExpression"] = 179] = "PropertyAccessExpression"; + SyntaxKind[SyntaxKind["ElementAccessExpression"] = 180] = "ElementAccessExpression"; + SyntaxKind[SyntaxKind["CallExpression"] = 181] = "CallExpression"; + SyntaxKind[SyntaxKind["NewExpression"] = 182] = "NewExpression"; + SyntaxKind[SyntaxKind["TaggedTemplateExpression"] = 183] = "TaggedTemplateExpression"; + SyntaxKind[SyntaxKind["TypeAssertionExpression"] = 184] = "TypeAssertionExpression"; + SyntaxKind[SyntaxKind["ParenthesizedExpression"] = 185] = "ParenthesizedExpression"; + SyntaxKind[SyntaxKind["FunctionExpression"] = 186] = "FunctionExpression"; + SyntaxKind[SyntaxKind["ArrowFunction"] = 187] = "ArrowFunction"; + SyntaxKind[SyntaxKind["DeleteExpression"] = 188] = "DeleteExpression"; + SyntaxKind[SyntaxKind["TypeOfExpression"] = 189] = "TypeOfExpression"; + SyntaxKind[SyntaxKind["VoidExpression"] = 190] = "VoidExpression"; + SyntaxKind[SyntaxKind["AwaitExpression"] = 191] = "AwaitExpression"; + SyntaxKind[SyntaxKind["PrefixUnaryExpression"] = 192] = "PrefixUnaryExpression"; + SyntaxKind[SyntaxKind["PostfixUnaryExpression"] = 193] = "PostfixUnaryExpression"; + SyntaxKind[SyntaxKind["BinaryExpression"] = 194] = "BinaryExpression"; + SyntaxKind[SyntaxKind["ConditionalExpression"] = 195] = "ConditionalExpression"; + SyntaxKind[SyntaxKind["TemplateExpression"] = 196] = "TemplateExpression"; + SyntaxKind[SyntaxKind["YieldExpression"] = 197] = "YieldExpression"; + SyntaxKind[SyntaxKind["SpreadElement"] = 198] = "SpreadElement"; + SyntaxKind[SyntaxKind["ClassExpression"] = 199] = "ClassExpression"; + SyntaxKind[SyntaxKind["OmittedExpression"] = 200] = "OmittedExpression"; + SyntaxKind[SyntaxKind["ExpressionWithTypeArguments"] = 201] = "ExpressionWithTypeArguments"; + SyntaxKind[SyntaxKind["AsExpression"] = 202] = "AsExpression"; + SyntaxKind[SyntaxKind["NonNullExpression"] = 203] = "NonNullExpression"; + SyntaxKind[SyntaxKind["MetaProperty"] = 204] = "MetaProperty"; + SyntaxKind[SyntaxKind["TemplateSpan"] = 205] = "TemplateSpan"; + SyntaxKind[SyntaxKind["SemicolonClassElement"] = 206] = "SemicolonClassElement"; + SyntaxKind[SyntaxKind["Block"] = 207] = "Block"; + SyntaxKind[SyntaxKind["VariableStatement"] = 208] = "VariableStatement"; + SyntaxKind[SyntaxKind["EmptyStatement"] = 209] = "EmptyStatement"; + SyntaxKind[SyntaxKind["ExpressionStatement"] = 210] = "ExpressionStatement"; + SyntaxKind[SyntaxKind["IfStatement"] = 211] = "IfStatement"; + SyntaxKind[SyntaxKind["DoStatement"] = 212] = "DoStatement"; + SyntaxKind[SyntaxKind["WhileStatement"] = 213] = "WhileStatement"; + SyntaxKind[SyntaxKind["ForStatement"] = 214] = "ForStatement"; + SyntaxKind[SyntaxKind["ForInStatement"] = 215] = "ForInStatement"; + SyntaxKind[SyntaxKind["ForOfStatement"] = 216] = "ForOfStatement"; + SyntaxKind[SyntaxKind["ContinueStatement"] = 217] = "ContinueStatement"; + SyntaxKind[SyntaxKind["BreakStatement"] = 218] = "BreakStatement"; + SyntaxKind[SyntaxKind["ReturnStatement"] = 219] = "ReturnStatement"; + SyntaxKind[SyntaxKind["WithStatement"] = 220] = "WithStatement"; + SyntaxKind[SyntaxKind["SwitchStatement"] = 221] = "SwitchStatement"; + SyntaxKind[SyntaxKind["LabeledStatement"] = 222] = "LabeledStatement"; + SyntaxKind[SyntaxKind["ThrowStatement"] = 223] = "ThrowStatement"; + SyntaxKind[SyntaxKind["TryStatement"] = 224] = "TryStatement"; + SyntaxKind[SyntaxKind["DebuggerStatement"] = 225] = "DebuggerStatement"; + SyntaxKind[SyntaxKind["VariableDeclaration"] = 226] = "VariableDeclaration"; + SyntaxKind[SyntaxKind["VariableDeclarationList"] = 227] = "VariableDeclarationList"; + SyntaxKind[SyntaxKind["FunctionDeclaration"] = 228] = "FunctionDeclaration"; + SyntaxKind[SyntaxKind["ClassDeclaration"] = 229] = "ClassDeclaration"; + SyntaxKind[SyntaxKind["InterfaceDeclaration"] = 230] = "InterfaceDeclaration"; + SyntaxKind[SyntaxKind["TypeAliasDeclaration"] = 231] = "TypeAliasDeclaration"; + SyntaxKind[SyntaxKind["EnumDeclaration"] = 232] = "EnumDeclaration"; + SyntaxKind[SyntaxKind["ModuleDeclaration"] = 233] = "ModuleDeclaration"; + SyntaxKind[SyntaxKind["ModuleBlock"] = 234] = "ModuleBlock"; + SyntaxKind[SyntaxKind["CaseBlock"] = 235] = "CaseBlock"; + SyntaxKind[SyntaxKind["NamespaceExportDeclaration"] = 236] = "NamespaceExportDeclaration"; + SyntaxKind[SyntaxKind["ImportEqualsDeclaration"] = 237] = "ImportEqualsDeclaration"; + SyntaxKind[SyntaxKind["ImportDeclaration"] = 238] = "ImportDeclaration"; + SyntaxKind[SyntaxKind["ImportClause"] = 239] = "ImportClause"; + SyntaxKind[SyntaxKind["NamespaceImport"] = 240] = "NamespaceImport"; + SyntaxKind[SyntaxKind["NamedImports"] = 241] = "NamedImports"; + SyntaxKind[SyntaxKind["ImportSpecifier"] = 242] = "ImportSpecifier"; + SyntaxKind[SyntaxKind["ExportAssignment"] = 243] = "ExportAssignment"; + SyntaxKind[SyntaxKind["ExportDeclaration"] = 244] = "ExportDeclaration"; + SyntaxKind[SyntaxKind["NamedExports"] = 245] = "NamedExports"; + SyntaxKind[SyntaxKind["ExportSpecifier"] = 246] = "ExportSpecifier"; + SyntaxKind[SyntaxKind["MissingDeclaration"] = 247] = "MissingDeclaration"; + SyntaxKind[SyntaxKind["ExternalModuleReference"] = 248] = "ExternalModuleReference"; + SyntaxKind[SyntaxKind["JsxElement"] = 249] = "JsxElement"; + SyntaxKind[SyntaxKind["JsxSelfClosingElement"] = 250] = "JsxSelfClosingElement"; + SyntaxKind[SyntaxKind["JsxOpeningElement"] = 251] = "JsxOpeningElement"; + SyntaxKind[SyntaxKind["JsxClosingElement"] = 252] = "JsxClosingElement"; + SyntaxKind[SyntaxKind["JsxAttribute"] = 253] = "JsxAttribute"; + SyntaxKind[SyntaxKind["JsxAttributes"] = 254] = "JsxAttributes"; + SyntaxKind[SyntaxKind["JsxSpreadAttribute"] = 255] = "JsxSpreadAttribute"; + SyntaxKind[SyntaxKind["JsxExpression"] = 256] = "JsxExpression"; + SyntaxKind[SyntaxKind["CaseClause"] = 257] = "CaseClause"; + SyntaxKind[SyntaxKind["DefaultClause"] = 258] = "DefaultClause"; + SyntaxKind[SyntaxKind["HeritageClause"] = 259] = "HeritageClause"; + SyntaxKind[SyntaxKind["CatchClause"] = 260] = "CatchClause"; + SyntaxKind[SyntaxKind["PropertyAssignment"] = 261] = "PropertyAssignment"; + SyntaxKind[SyntaxKind["ShorthandPropertyAssignment"] = 262] = "ShorthandPropertyAssignment"; + SyntaxKind[SyntaxKind["SpreadAssignment"] = 263] = "SpreadAssignment"; + SyntaxKind[SyntaxKind["EnumMember"] = 264] = "EnumMember"; + SyntaxKind[SyntaxKind["SourceFile"] = 265] = "SourceFile"; + SyntaxKind[SyntaxKind["Bundle"] = 266] = "Bundle"; + SyntaxKind[SyntaxKind["JSDocTypeExpression"] = 267] = "JSDocTypeExpression"; + SyntaxKind[SyntaxKind["JSDocAllType"] = 268] = "JSDocAllType"; + SyntaxKind[SyntaxKind["JSDocUnknownType"] = 269] = "JSDocUnknownType"; + SyntaxKind[SyntaxKind["JSDocNullableType"] = 270] = "JSDocNullableType"; + SyntaxKind[SyntaxKind["JSDocNonNullableType"] = 271] = "JSDocNonNullableType"; + SyntaxKind[SyntaxKind["JSDocOptionalType"] = 272] = "JSDocOptionalType"; + SyntaxKind[SyntaxKind["JSDocFunctionType"] = 273] = "JSDocFunctionType"; + SyntaxKind[SyntaxKind["JSDocVariadicType"] = 274] = "JSDocVariadicType"; + SyntaxKind[SyntaxKind["JSDocComment"] = 275] = "JSDocComment"; + SyntaxKind[SyntaxKind["JSDocTag"] = 276] = "JSDocTag"; + SyntaxKind[SyntaxKind["JSDocAugmentsTag"] = 277] = "JSDocAugmentsTag"; + SyntaxKind[SyntaxKind["JSDocClassTag"] = 278] = "JSDocClassTag"; + SyntaxKind[SyntaxKind["JSDocParameterTag"] = 279] = "JSDocParameterTag"; + SyntaxKind[SyntaxKind["JSDocReturnTag"] = 280] = "JSDocReturnTag"; + SyntaxKind[SyntaxKind["JSDocTypeTag"] = 281] = "JSDocTypeTag"; + SyntaxKind[SyntaxKind["JSDocTemplateTag"] = 282] = "JSDocTemplateTag"; + SyntaxKind[SyntaxKind["JSDocTypedefTag"] = 283] = "JSDocTypedefTag"; + SyntaxKind[SyntaxKind["JSDocPropertyTag"] = 284] = "JSDocPropertyTag"; + SyntaxKind[SyntaxKind["JSDocTypeLiteral"] = 285] = "JSDocTypeLiteral"; + SyntaxKind[SyntaxKind["SyntaxList"] = 286] = "SyntaxList"; + SyntaxKind[SyntaxKind["NotEmittedStatement"] = 287] = "NotEmittedStatement"; + SyntaxKind[SyntaxKind["PartiallyEmittedExpression"] = 288] = "PartiallyEmittedExpression"; + SyntaxKind[SyntaxKind["CommaListExpression"] = 289] = "CommaListExpression"; + SyntaxKind[SyntaxKind["MergeDeclarationMarker"] = 290] = "MergeDeclarationMarker"; + SyntaxKind[SyntaxKind["EndOfDeclarationMarker"] = 291] = "EndOfDeclarationMarker"; + SyntaxKind[SyntaxKind["Count"] = 292] = "Count"; + SyntaxKind[SyntaxKind["FirstAssignment"] = 58] = "FirstAssignment"; + SyntaxKind[SyntaxKind["LastAssignment"] = 70] = "LastAssignment"; + SyntaxKind[SyntaxKind["FirstCompoundAssignment"] = 59] = "FirstCompoundAssignment"; + SyntaxKind[SyntaxKind["LastCompoundAssignment"] = 70] = "LastCompoundAssignment"; + SyntaxKind[SyntaxKind["FirstReservedWord"] = 72] = "FirstReservedWord"; + SyntaxKind[SyntaxKind["LastReservedWord"] = 107] = "LastReservedWord"; + SyntaxKind[SyntaxKind["FirstKeyword"] = 72] = "FirstKeyword"; + SyntaxKind[SyntaxKind["LastKeyword"] = 142] = "LastKeyword"; + SyntaxKind[SyntaxKind["FirstFutureReservedWord"] = 108] = "FirstFutureReservedWord"; + SyntaxKind[SyntaxKind["LastFutureReservedWord"] = 116] = "LastFutureReservedWord"; + SyntaxKind[SyntaxKind["FirstTypeNode"] = 158] = "FirstTypeNode"; + SyntaxKind[SyntaxKind["LastTypeNode"] = 173] = "LastTypeNode"; + SyntaxKind[SyntaxKind["FirstPunctuation"] = 17] = "FirstPunctuation"; + SyntaxKind[SyntaxKind["LastPunctuation"] = 70] = "LastPunctuation"; + SyntaxKind[SyntaxKind["FirstToken"] = 0] = "FirstToken"; + SyntaxKind[SyntaxKind["LastToken"] = 142] = "LastToken"; + SyntaxKind[SyntaxKind["FirstTriviaToken"] = 2] = "FirstTriviaToken"; + SyntaxKind[SyntaxKind["LastTriviaToken"] = 7] = "LastTriviaToken"; + SyntaxKind[SyntaxKind["FirstLiteralToken"] = 8] = "FirstLiteralToken"; + SyntaxKind[SyntaxKind["LastLiteralToken"] = 13] = "LastLiteralToken"; + SyntaxKind[SyntaxKind["FirstTemplateToken"] = 13] = "FirstTemplateToken"; + SyntaxKind[SyntaxKind["LastTemplateToken"] = 16] = "LastTemplateToken"; + SyntaxKind[SyntaxKind["FirstBinaryOperator"] = 27] = "FirstBinaryOperator"; + SyntaxKind[SyntaxKind["LastBinaryOperator"] = 70] = "LastBinaryOperator"; + SyntaxKind[SyntaxKind["FirstNode"] = 143] = "FirstNode"; + SyntaxKind[SyntaxKind["FirstJSDocNode"] = 267] = "FirstJSDocNode"; + SyntaxKind[SyntaxKind["LastJSDocNode"] = 285] = "LastJSDocNode"; + SyntaxKind[SyntaxKind["FirstJSDocTagNode"] = 276] = "FirstJSDocTagNode"; + SyntaxKind[SyntaxKind["LastJSDocTagNode"] = 285] = "LastJSDocTagNode"; + })(SyntaxKind = ts.SyntaxKind || (ts.SyntaxKind = {})); + var NodeFlags; + (function (NodeFlags) { + NodeFlags[NodeFlags["None"] = 0] = "None"; + NodeFlags[NodeFlags["Let"] = 1] = "Let"; + NodeFlags[NodeFlags["Const"] = 2] = "Const"; + NodeFlags[NodeFlags["NestedNamespace"] = 4] = "NestedNamespace"; + NodeFlags[NodeFlags["Synthesized"] = 8] = "Synthesized"; + NodeFlags[NodeFlags["Namespace"] = 16] = "Namespace"; + NodeFlags[NodeFlags["ExportContext"] = 32] = "ExportContext"; + NodeFlags[NodeFlags["ContainsThis"] = 64] = "ContainsThis"; + NodeFlags[NodeFlags["HasImplicitReturn"] = 128] = "HasImplicitReturn"; + NodeFlags[NodeFlags["HasExplicitReturn"] = 256] = "HasExplicitReturn"; + NodeFlags[NodeFlags["GlobalAugmentation"] = 512] = "GlobalAugmentation"; + NodeFlags[NodeFlags["HasAsyncFunctions"] = 1024] = "HasAsyncFunctions"; + NodeFlags[NodeFlags["DisallowInContext"] = 2048] = "DisallowInContext"; + NodeFlags[NodeFlags["YieldContext"] = 4096] = "YieldContext"; + NodeFlags[NodeFlags["DecoratorContext"] = 8192] = "DecoratorContext"; + NodeFlags[NodeFlags["AwaitContext"] = 16384] = "AwaitContext"; + NodeFlags[NodeFlags["ThisNodeHasError"] = 32768] = "ThisNodeHasError"; + NodeFlags[NodeFlags["JavaScriptFile"] = 65536] = "JavaScriptFile"; + NodeFlags[NodeFlags["ThisNodeOrAnySubNodesHasError"] = 131072] = "ThisNodeOrAnySubNodesHasError"; + NodeFlags[NodeFlags["HasAggregatedChildData"] = 262144] = "HasAggregatedChildData"; + NodeFlags[NodeFlags["PossiblyContainsDynamicImport"] = 524288] = "PossiblyContainsDynamicImport"; + NodeFlags[NodeFlags["JSDoc"] = 1048576] = "JSDoc"; + NodeFlags[NodeFlags["BlockScoped"] = 3] = "BlockScoped"; + NodeFlags[NodeFlags["ReachabilityCheckFlags"] = 384] = "ReachabilityCheckFlags"; + NodeFlags[NodeFlags["ReachabilityAndEmitFlags"] = 1408] = "ReachabilityAndEmitFlags"; + NodeFlags[NodeFlags["ContextFlags"] = 96256] = "ContextFlags"; + NodeFlags[NodeFlags["TypeExcludesFlags"] = 20480] = "TypeExcludesFlags"; + })(NodeFlags = ts.NodeFlags || (ts.NodeFlags = {})); + var ModifierFlags; + (function (ModifierFlags) { + ModifierFlags[ModifierFlags["None"] = 0] = "None"; + ModifierFlags[ModifierFlags["Export"] = 1] = "Export"; + ModifierFlags[ModifierFlags["Ambient"] = 2] = "Ambient"; + ModifierFlags[ModifierFlags["Public"] = 4] = "Public"; + ModifierFlags[ModifierFlags["Private"] = 8] = "Private"; + ModifierFlags[ModifierFlags["Protected"] = 16] = "Protected"; + ModifierFlags[ModifierFlags["Static"] = 32] = "Static"; + ModifierFlags[ModifierFlags["Readonly"] = 64] = "Readonly"; + ModifierFlags[ModifierFlags["Abstract"] = 128] = "Abstract"; + ModifierFlags[ModifierFlags["Async"] = 256] = "Async"; + ModifierFlags[ModifierFlags["Default"] = 512] = "Default"; + ModifierFlags[ModifierFlags["Const"] = 2048] = "Const"; + ModifierFlags[ModifierFlags["HasComputedFlags"] = 536870912] = "HasComputedFlags"; + ModifierFlags[ModifierFlags["AccessibilityModifier"] = 28] = "AccessibilityModifier"; + ModifierFlags[ModifierFlags["ParameterPropertyModifier"] = 92] = "ParameterPropertyModifier"; + ModifierFlags[ModifierFlags["NonPublicAccessibilityModifier"] = 24] = "NonPublicAccessibilityModifier"; + ModifierFlags[ModifierFlags["TypeScriptModifier"] = 2270] = "TypeScriptModifier"; + ModifierFlags[ModifierFlags["ExportDefault"] = 513] = "ExportDefault"; + })(ModifierFlags = ts.ModifierFlags || (ts.ModifierFlags = {})); + var JsxFlags; + (function (JsxFlags) { + JsxFlags[JsxFlags["None"] = 0] = "None"; + JsxFlags[JsxFlags["IntrinsicNamedElement"] = 1] = "IntrinsicNamedElement"; + JsxFlags[JsxFlags["IntrinsicIndexedElement"] = 2] = "IntrinsicIndexedElement"; + JsxFlags[JsxFlags["IntrinsicElement"] = 3] = "IntrinsicElement"; + })(JsxFlags = ts.JsxFlags || (ts.JsxFlags = {})); + var RelationComparisonResult; + (function (RelationComparisonResult) { + RelationComparisonResult[RelationComparisonResult["Succeeded"] = 1] = "Succeeded"; + RelationComparisonResult[RelationComparisonResult["Failed"] = 2] = "Failed"; + RelationComparisonResult[RelationComparisonResult["FailedAndReported"] = 3] = "FailedAndReported"; + })(RelationComparisonResult = ts.RelationComparisonResult || (ts.RelationComparisonResult = {})); + var GeneratedIdentifierKind; + (function (GeneratedIdentifierKind) { + GeneratedIdentifierKind[GeneratedIdentifierKind["None"] = 0] = "None"; + GeneratedIdentifierKind[GeneratedIdentifierKind["Auto"] = 1] = "Auto"; + GeneratedIdentifierKind[GeneratedIdentifierKind["Loop"] = 2] = "Loop"; + GeneratedIdentifierKind[GeneratedIdentifierKind["Unique"] = 3] = "Unique"; + GeneratedIdentifierKind[GeneratedIdentifierKind["Node"] = 4] = "Node"; + })(GeneratedIdentifierKind = ts.GeneratedIdentifierKind || (ts.GeneratedIdentifierKind = {})); + var NumericLiteralFlags; + (function (NumericLiteralFlags) { + NumericLiteralFlags[NumericLiteralFlags["None"] = 0] = "None"; + NumericLiteralFlags[NumericLiteralFlags["Scientific"] = 2] = "Scientific"; + NumericLiteralFlags[NumericLiteralFlags["Octal"] = 4] = "Octal"; + NumericLiteralFlags[NumericLiteralFlags["HexSpecifier"] = 8] = "HexSpecifier"; + NumericLiteralFlags[NumericLiteralFlags["BinarySpecifier"] = 16] = "BinarySpecifier"; + NumericLiteralFlags[NumericLiteralFlags["OctalSpecifier"] = 32] = "OctalSpecifier"; + NumericLiteralFlags[NumericLiteralFlags["BinaryOrOctalSpecifier"] = 48] = "BinaryOrOctalSpecifier"; + })(NumericLiteralFlags = ts.NumericLiteralFlags || (ts.NumericLiteralFlags = {})); + var FlowFlags; + (function (FlowFlags) { + FlowFlags[FlowFlags["Unreachable"] = 1] = "Unreachable"; + FlowFlags[FlowFlags["Start"] = 2] = "Start"; + FlowFlags[FlowFlags["BranchLabel"] = 4] = "BranchLabel"; + FlowFlags[FlowFlags["LoopLabel"] = 8] = "LoopLabel"; + FlowFlags[FlowFlags["Assignment"] = 16] = "Assignment"; + FlowFlags[FlowFlags["TrueCondition"] = 32] = "TrueCondition"; + FlowFlags[FlowFlags["FalseCondition"] = 64] = "FalseCondition"; + FlowFlags[FlowFlags["SwitchClause"] = 128] = "SwitchClause"; + FlowFlags[FlowFlags["ArrayMutation"] = 256] = "ArrayMutation"; + FlowFlags[FlowFlags["Referenced"] = 512] = "Referenced"; + FlowFlags[FlowFlags["Shared"] = 1024] = "Shared"; + FlowFlags[FlowFlags["PreFinally"] = 2048] = "PreFinally"; + FlowFlags[FlowFlags["AfterFinally"] = 4096] = "AfterFinally"; + FlowFlags[FlowFlags["Label"] = 12] = "Label"; + FlowFlags[FlowFlags["Condition"] = 96] = "Condition"; + })(FlowFlags = ts.FlowFlags || (ts.FlowFlags = {})); var OperationCanceledException = (function () { function OperationCanceledException() { } return OperationCanceledException; }()); ts.OperationCanceledException = OperationCanceledException; + var StructureIsReused; + (function (StructureIsReused) { + StructureIsReused[StructureIsReused["Not"] = 0] = "Not"; + StructureIsReused[StructureIsReused["SafeModules"] = 1] = "SafeModules"; + StructureIsReused[StructureIsReused["Completely"] = 2] = "Completely"; + })(StructureIsReused = ts.StructureIsReused || (ts.StructureIsReused = {})); var ExitStatus; (function (ExitStatus) { ExitStatus[ExitStatus["Success"] = 0] = "Success"; @@ -56,6 +495,47 @@ var ts; NodeBuilderFlags[NodeBuilderFlags["InObjectTypeLiteral"] = 1048576] = "InObjectTypeLiteral"; NodeBuilderFlags[NodeBuilderFlags["InTypeAlias"] = 8388608] = "InTypeAlias"; })(NodeBuilderFlags = ts.NodeBuilderFlags || (ts.NodeBuilderFlags = {})); + var TypeFormatFlags; + (function (TypeFormatFlags) { + TypeFormatFlags[TypeFormatFlags["None"] = 0] = "None"; + TypeFormatFlags[TypeFormatFlags["WriteArrayAsGenericType"] = 1] = "WriteArrayAsGenericType"; + TypeFormatFlags[TypeFormatFlags["UseTypeOfFunction"] = 4] = "UseTypeOfFunction"; + TypeFormatFlags[TypeFormatFlags["NoTruncation"] = 8] = "NoTruncation"; + TypeFormatFlags[TypeFormatFlags["WriteArrowStyleSignature"] = 16] = "WriteArrowStyleSignature"; + TypeFormatFlags[TypeFormatFlags["WriteOwnNameForAnyLike"] = 32] = "WriteOwnNameForAnyLike"; + TypeFormatFlags[TypeFormatFlags["WriteTypeArgumentsOfSignature"] = 64] = "WriteTypeArgumentsOfSignature"; + TypeFormatFlags[TypeFormatFlags["InElementType"] = 128] = "InElementType"; + TypeFormatFlags[TypeFormatFlags["UseFullyQualifiedType"] = 256] = "UseFullyQualifiedType"; + TypeFormatFlags[TypeFormatFlags["InFirstTypeArgument"] = 512] = "InFirstTypeArgument"; + TypeFormatFlags[TypeFormatFlags["InTypeAlias"] = 1024] = "InTypeAlias"; + TypeFormatFlags[TypeFormatFlags["SuppressAnyReturnType"] = 4096] = "SuppressAnyReturnType"; + TypeFormatFlags[TypeFormatFlags["AddUndefined"] = 8192] = "AddUndefined"; + TypeFormatFlags[TypeFormatFlags["WriteClassExpressionAsTypeLiteral"] = 16384] = "WriteClassExpressionAsTypeLiteral"; + TypeFormatFlags[TypeFormatFlags["InArrayType"] = 32768] = "InArrayType"; + TypeFormatFlags[TypeFormatFlags["UseAliasDefinedOutsideCurrentScope"] = 65536] = "UseAliasDefinedOutsideCurrentScope"; + })(TypeFormatFlags = ts.TypeFormatFlags || (ts.TypeFormatFlags = {})); + var SymbolFormatFlags; + (function (SymbolFormatFlags) { + SymbolFormatFlags[SymbolFormatFlags["None"] = 0] = "None"; + SymbolFormatFlags[SymbolFormatFlags["WriteTypeParametersOrArguments"] = 1] = "WriteTypeParametersOrArguments"; + SymbolFormatFlags[SymbolFormatFlags["UseOnlyExternalAliasing"] = 2] = "UseOnlyExternalAliasing"; + })(SymbolFormatFlags = ts.SymbolFormatFlags || (ts.SymbolFormatFlags = {})); + var SymbolAccessibility; + (function (SymbolAccessibility) { + SymbolAccessibility[SymbolAccessibility["Accessible"] = 0] = "Accessible"; + SymbolAccessibility[SymbolAccessibility["NotAccessible"] = 1] = "NotAccessible"; + SymbolAccessibility[SymbolAccessibility["CannotBeNamed"] = 2] = "CannotBeNamed"; + })(SymbolAccessibility = ts.SymbolAccessibility || (ts.SymbolAccessibility = {})); + var SyntheticSymbolKind; + (function (SyntheticSymbolKind) { + SyntheticSymbolKind[SyntheticSymbolKind["UnionOrIntersection"] = 0] = "UnionOrIntersection"; + SyntheticSymbolKind[SyntheticSymbolKind["Spread"] = 1] = "Spread"; + })(SyntheticSymbolKind = ts.SyntheticSymbolKind || (ts.SyntheticSymbolKind = {})); + var TypePredicateKind; + (function (TypePredicateKind) { + TypePredicateKind[TypePredicateKind["This"] = 0] = "This"; + TypePredicateKind[TypePredicateKind["Identifier"] = 1] = "Identifier"; + })(TypePredicateKind = ts.TypePredicateKind || (ts.TypePredicateKind = {})); var TypeReferenceSerializationKind; (function (TypeReferenceSerializationKind) { TypeReferenceSerializationKind[TypeReferenceSerializationKind["Unknown"] = 0] = "Unknown"; @@ -70,6 +550,230 @@ var ts; TypeReferenceSerializationKind[TypeReferenceSerializationKind["TypeWithCallSignature"] = 9] = "TypeWithCallSignature"; TypeReferenceSerializationKind[TypeReferenceSerializationKind["ObjectType"] = 10] = "ObjectType"; })(TypeReferenceSerializationKind = ts.TypeReferenceSerializationKind || (ts.TypeReferenceSerializationKind = {})); + var SymbolFlags; + (function (SymbolFlags) { + SymbolFlags[SymbolFlags["None"] = 0] = "None"; + SymbolFlags[SymbolFlags["FunctionScopedVariable"] = 1] = "FunctionScopedVariable"; + SymbolFlags[SymbolFlags["BlockScopedVariable"] = 2] = "BlockScopedVariable"; + SymbolFlags[SymbolFlags["Property"] = 4] = "Property"; + SymbolFlags[SymbolFlags["EnumMember"] = 8] = "EnumMember"; + SymbolFlags[SymbolFlags["Function"] = 16] = "Function"; + SymbolFlags[SymbolFlags["Class"] = 32] = "Class"; + SymbolFlags[SymbolFlags["Interface"] = 64] = "Interface"; + SymbolFlags[SymbolFlags["ConstEnum"] = 128] = "ConstEnum"; + SymbolFlags[SymbolFlags["RegularEnum"] = 256] = "RegularEnum"; + SymbolFlags[SymbolFlags["ValueModule"] = 512] = "ValueModule"; + SymbolFlags[SymbolFlags["NamespaceModule"] = 1024] = "NamespaceModule"; + SymbolFlags[SymbolFlags["TypeLiteral"] = 2048] = "TypeLiteral"; + SymbolFlags[SymbolFlags["ObjectLiteral"] = 4096] = "ObjectLiteral"; + SymbolFlags[SymbolFlags["Method"] = 8192] = "Method"; + SymbolFlags[SymbolFlags["Constructor"] = 16384] = "Constructor"; + SymbolFlags[SymbolFlags["GetAccessor"] = 32768] = "GetAccessor"; + SymbolFlags[SymbolFlags["SetAccessor"] = 65536] = "SetAccessor"; + SymbolFlags[SymbolFlags["Signature"] = 131072] = "Signature"; + SymbolFlags[SymbolFlags["TypeParameter"] = 262144] = "TypeParameter"; + SymbolFlags[SymbolFlags["TypeAlias"] = 524288] = "TypeAlias"; + SymbolFlags[SymbolFlags["ExportValue"] = 1048576] = "ExportValue"; + SymbolFlags[SymbolFlags["Alias"] = 2097152] = "Alias"; + SymbolFlags[SymbolFlags["Prototype"] = 4194304] = "Prototype"; + SymbolFlags[SymbolFlags["ExportStar"] = 8388608] = "ExportStar"; + SymbolFlags[SymbolFlags["Optional"] = 16777216] = "Optional"; + SymbolFlags[SymbolFlags["Transient"] = 33554432] = "Transient"; + SymbolFlags[SymbolFlags["Enum"] = 384] = "Enum"; + SymbolFlags[SymbolFlags["Variable"] = 3] = "Variable"; + SymbolFlags[SymbolFlags["Value"] = 107455] = "Value"; + SymbolFlags[SymbolFlags["Type"] = 793064] = "Type"; + SymbolFlags[SymbolFlags["Namespace"] = 1920] = "Namespace"; + SymbolFlags[SymbolFlags["Module"] = 1536] = "Module"; + SymbolFlags[SymbolFlags["Accessor"] = 98304] = "Accessor"; + SymbolFlags[SymbolFlags["FunctionScopedVariableExcludes"] = 107454] = "FunctionScopedVariableExcludes"; + SymbolFlags[SymbolFlags["BlockScopedVariableExcludes"] = 107455] = "BlockScopedVariableExcludes"; + SymbolFlags[SymbolFlags["ParameterExcludes"] = 107455] = "ParameterExcludes"; + SymbolFlags[SymbolFlags["PropertyExcludes"] = 0] = "PropertyExcludes"; + SymbolFlags[SymbolFlags["EnumMemberExcludes"] = 900095] = "EnumMemberExcludes"; + SymbolFlags[SymbolFlags["FunctionExcludes"] = 106927] = "FunctionExcludes"; + SymbolFlags[SymbolFlags["ClassExcludes"] = 899519] = "ClassExcludes"; + SymbolFlags[SymbolFlags["InterfaceExcludes"] = 792968] = "InterfaceExcludes"; + SymbolFlags[SymbolFlags["RegularEnumExcludes"] = 899327] = "RegularEnumExcludes"; + SymbolFlags[SymbolFlags["ConstEnumExcludes"] = 899967] = "ConstEnumExcludes"; + SymbolFlags[SymbolFlags["ValueModuleExcludes"] = 106639] = "ValueModuleExcludes"; + SymbolFlags[SymbolFlags["NamespaceModuleExcludes"] = 0] = "NamespaceModuleExcludes"; + SymbolFlags[SymbolFlags["MethodExcludes"] = 99263] = "MethodExcludes"; + SymbolFlags[SymbolFlags["GetAccessorExcludes"] = 41919] = "GetAccessorExcludes"; + SymbolFlags[SymbolFlags["SetAccessorExcludes"] = 74687] = "SetAccessorExcludes"; + SymbolFlags[SymbolFlags["TypeParameterExcludes"] = 530920] = "TypeParameterExcludes"; + SymbolFlags[SymbolFlags["TypeAliasExcludes"] = 793064] = "TypeAliasExcludes"; + SymbolFlags[SymbolFlags["AliasExcludes"] = 2097152] = "AliasExcludes"; + SymbolFlags[SymbolFlags["ModuleMember"] = 2623475] = "ModuleMember"; + SymbolFlags[SymbolFlags["ExportHasLocal"] = 944] = "ExportHasLocal"; + SymbolFlags[SymbolFlags["HasExports"] = 1952] = "HasExports"; + SymbolFlags[SymbolFlags["HasMembers"] = 6240] = "HasMembers"; + SymbolFlags[SymbolFlags["BlockScoped"] = 418] = "BlockScoped"; + SymbolFlags[SymbolFlags["PropertyOrAccessor"] = 98308] = "PropertyOrAccessor"; + SymbolFlags[SymbolFlags["ClassMember"] = 106500] = "ClassMember"; + SymbolFlags[SymbolFlags["Classifiable"] = 788448] = "Classifiable"; + })(SymbolFlags = ts.SymbolFlags || (ts.SymbolFlags = {})); + var EnumKind; + (function (EnumKind) { + EnumKind[EnumKind["Numeric"] = 0] = "Numeric"; + EnumKind[EnumKind["Literal"] = 1] = "Literal"; + })(EnumKind = ts.EnumKind || (ts.EnumKind = {})); + var CheckFlags; + (function (CheckFlags) { + CheckFlags[CheckFlags["Instantiated"] = 1] = "Instantiated"; + CheckFlags[CheckFlags["SyntheticProperty"] = 2] = "SyntheticProperty"; + CheckFlags[CheckFlags["SyntheticMethod"] = 4] = "SyntheticMethod"; + CheckFlags[CheckFlags["Readonly"] = 8] = "Readonly"; + CheckFlags[CheckFlags["Partial"] = 16] = "Partial"; + CheckFlags[CheckFlags["HasNonUniformType"] = 32] = "HasNonUniformType"; + CheckFlags[CheckFlags["ContainsPublic"] = 64] = "ContainsPublic"; + CheckFlags[CheckFlags["ContainsProtected"] = 128] = "ContainsProtected"; + CheckFlags[CheckFlags["ContainsPrivate"] = 256] = "ContainsPrivate"; + CheckFlags[CheckFlags["ContainsStatic"] = 512] = "ContainsStatic"; + CheckFlags[CheckFlags["Synthetic"] = 6] = "Synthetic"; + })(CheckFlags = ts.CheckFlags || (ts.CheckFlags = {})); + var InternalSymbolName; + (function (InternalSymbolName) { + InternalSymbolName["Call"] = "__call"; + InternalSymbolName["Constructor"] = "__constructor"; + InternalSymbolName["New"] = "__new"; + InternalSymbolName["Index"] = "__index"; + InternalSymbolName["ExportStar"] = "__export"; + InternalSymbolName["Global"] = "__global"; + InternalSymbolName["Missing"] = "__missing"; + InternalSymbolName["Type"] = "__type"; + InternalSymbolName["Object"] = "__object"; + InternalSymbolName["JSXAttributes"] = "__jsxAttributes"; + InternalSymbolName["Class"] = "__class"; + InternalSymbolName["Function"] = "__function"; + InternalSymbolName["Computed"] = "__computed"; + InternalSymbolName["Resolving"] = "__resolving__"; + InternalSymbolName["ExportEquals"] = "export="; + InternalSymbolName["Default"] = "default"; + })(InternalSymbolName = ts.InternalSymbolName || (ts.InternalSymbolName = {})); + var NodeCheckFlags; + (function (NodeCheckFlags) { + NodeCheckFlags[NodeCheckFlags["TypeChecked"] = 1] = "TypeChecked"; + NodeCheckFlags[NodeCheckFlags["LexicalThis"] = 2] = "LexicalThis"; + NodeCheckFlags[NodeCheckFlags["CaptureThis"] = 4] = "CaptureThis"; + NodeCheckFlags[NodeCheckFlags["CaptureNewTarget"] = 8] = "CaptureNewTarget"; + NodeCheckFlags[NodeCheckFlags["SuperInstance"] = 256] = "SuperInstance"; + NodeCheckFlags[NodeCheckFlags["SuperStatic"] = 512] = "SuperStatic"; + NodeCheckFlags[NodeCheckFlags["ContextChecked"] = 1024] = "ContextChecked"; + NodeCheckFlags[NodeCheckFlags["AsyncMethodWithSuper"] = 2048] = "AsyncMethodWithSuper"; + NodeCheckFlags[NodeCheckFlags["AsyncMethodWithSuperBinding"] = 4096] = "AsyncMethodWithSuperBinding"; + NodeCheckFlags[NodeCheckFlags["CaptureArguments"] = 8192] = "CaptureArguments"; + NodeCheckFlags[NodeCheckFlags["EnumValuesComputed"] = 16384] = "EnumValuesComputed"; + NodeCheckFlags[NodeCheckFlags["LexicalModuleMergesWithClass"] = 32768] = "LexicalModuleMergesWithClass"; + NodeCheckFlags[NodeCheckFlags["LoopWithCapturedBlockScopedBinding"] = 65536] = "LoopWithCapturedBlockScopedBinding"; + NodeCheckFlags[NodeCheckFlags["CapturedBlockScopedBinding"] = 131072] = "CapturedBlockScopedBinding"; + NodeCheckFlags[NodeCheckFlags["BlockScopedBindingInLoop"] = 262144] = "BlockScopedBindingInLoop"; + NodeCheckFlags[NodeCheckFlags["ClassWithBodyScopedClassBinding"] = 524288] = "ClassWithBodyScopedClassBinding"; + NodeCheckFlags[NodeCheckFlags["BodyScopedClassBinding"] = 1048576] = "BodyScopedClassBinding"; + NodeCheckFlags[NodeCheckFlags["NeedsLoopOutParameter"] = 2097152] = "NeedsLoopOutParameter"; + NodeCheckFlags[NodeCheckFlags["AssignmentsMarked"] = 4194304] = "AssignmentsMarked"; + NodeCheckFlags[NodeCheckFlags["ClassWithConstructorReference"] = 8388608] = "ClassWithConstructorReference"; + NodeCheckFlags[NodeCheckFlags["ConstructorReferenceInClass"] = 16777216] = "ConstructorReferenceInClass"; + })(NodeCheckFlags = ts.NodeCheckFlags || (ts.NodeCheckFlags = {})); + var TypeFlags; + (function (TypeFlags) { + TypeFlags[TypeFlags["Any"] = 1] = "Any"; + TypeFlags[TypeFlags["String"] = 2] = "String"; + TypeFlags[TypeFlags["Number"] = 4] = "Number"; + TypeFlags[TypeFlags["Boolean"] = 8] = "Boolean"; + TypeFlags[TypeFlags["Enum"] = 16] = "Enum"; + TypeFlags[TypeFlags["StringLiteral"] = 32] = "StringLiteral"; + TypeFlags[TypeFlags["NumberLiteral"] = 64] = "NumberLiteral"; + TypeFlags[TypeFlags["BooleanLiteral"] = 128] = "BooleanLiteral"; + TypeFlags[TypeFlags["EnumLiteral"] = 256] = "EnumLiteral"; + TypeFlags[TypeFlags["ESSymbol"] = 512] = "ESSymbol"; + TypeFlags[TypeFlags["Void"] = 1024] = "Void"; + TypeFlags[TypeFlags["Undefined"] = 2048] = "Undefined"; + TypeFlags[TypeFlags["Null"] = 4096] = "Null"; + TypeFlags[TypeFlags["Never"] = 8192] = "Never"; + TypeFlags[TypeFlags["TypeParameter"] = 16384] = "TypeParameter"; + TypeFlags[TypeFlags["Object"] = 32768] = "Object"; + TypeFlags[TypeFlags["Union"] = 65536] = "Union"; + TypeFlags[TypeFlags["Intersection"] = 131072] = "Intersection"; + TypeFlags[TypeFlags["Index"] = 262144] = "Index"; + TypeFlags[TypeFlags["IndexedAccess"] = 524288] = "IndexedAccess"; + TypeFlags[TypeFlags["FreshLiteral"] = 1048576] = "FreshLiteral"; + TypeFlags[TypeFlags["ContainsWideningType"] = 2097152] = "ContainsWideningType"; + TypeFlags[TypeFlags["ContainsObjectLiteral"] = 4194304] = "ContainsObjectLiteral"; + TypeFlags[TypeFlags["ContainsAnyFunctionType"] = 8388608] = "ContainsAnyFunctionType"; + TypeFlags[TypeFlags["NonPrimitive"] = 16777216] = "NonPrimitive"; + TypeFlags[TypeFlags["JsxAttributes"] = 33554432] = "JsxAttributes"; + TypeFlags[TypeFlags["Nullable"] = 6144] = "Nullable"; + TypeFlags[TypeFlags["Literal"] = 224] = "Literal"; + TypeFlags[TypeFlags["StringOrNumberLiteral"] = 96] = "StringOrNumberLiteral"; + TypeFlags[TypeFlags["DefinitelyFalsy"] = 7392] = "DefinitelyFalsy"; + TypeFlags[TypeFlags["PossiblyFalsy"] = 7406] = "PossiblyFalsy"; + TypeFlags[TypeFlags["Intrinsic"] = 16793231] = "Intrinsic"; + TypeFlags[TypeFlags["Primitive"] = 8190] = "Primitive"; + TypeFlags[TypeFlags["StringLike"] = 262178] = "StringLike"; + TypeFlags[TypeFlags["NumberLike"] = 84] = "NumberLike"; + TypeFlags[TypeFlags["BooleanLike"] = 136] = "BooleanLike"; + TypeFlags[TypeFlags["EnumLike"] = 272] = "EnumLike"; + TypeFlags[TypeFlags["UnionOrIntersection"] = 196608] = "UnionOrIntersection"; + TypeFlags[TypeFlags["StructuredType"] = 229376] = "StructuredType"; + TypeFlags[TypeFlags["StructuredOrTypeVariable"] = 1032192] = "StructuredOrTypeVariable"; + TypeFlags[TypeFlags["TypeVariable"] = 540672] = "TypeVariable"; + TypeFlags[TypeFlags["Narrowable"] = 17810175] = "Narrowable"; + TypeFlags[TypeFlags["NotUnionOrUnit"] = 16810497] = "NotUnionOrUnit"; + TypeFlags[TypeFlags["RequiresWidening"] = 6291456] = "RequiresWidening"; + TypeFlags[TypeFlags["PropagatingFlags"] = 14680064] = "PropagatingFlags"; + })(TypeFlags = ts.TypeFlags || (ts.TypeFlags = {})); + var ObjectFlags; + (function (ObjectFlags) { + ObjectFlags[ObjectFlags["Class"] = 1] = "Class"; + ObjectFlags[ObjectFlags["Interface"] = 2] = "Interface"; + ObjectFlags[ObjectFlags["Reference"] = 4] = "Reference"; + ObjectFlags[ObjectFlags["Tuple"] = 8] = "Tuple"; + ObjectFlags[ObjectFlags["Anonymous"] = 16] = "Anonymous"; + ObjectFlags[ObjectFlags["Mapped"] = 32] = "Mapped"; + ObjectFlags[ObjectFlags["Instantiated"] = 64] = "Instantiated"; + ObjectFlags[ObjectFlags["ObjectLiteral"] = 128] = "ObjectLiteral"; + ObjectFlags[ObjectFlags["EvolvingArray"] = 256] = "EvolvingArray"; + ObjectFlags[ObjectFlags["ObjectLiteralPatternWithComputedProperties"] = 512] = "ObjectLiteralPatternWithComputedProperties"; + ObjectFlags[ObjectFlags["ClassOrInterface"] = 3] = "ClassOrInterface"; + })(ObjectFlags = ts.ObjectFlags || (ts.ObjectFlags = {})); + var SignatureKind; + (function (SignatureKind) { + SignatureKind[SignatureKind["Call"] = 0] = "Call"; + SignatureKind[SignatureKind["Construct"] = 1] = "Construct"; + })(SignatureKind = ts.SignatureKind || (ts.SignatureKind = {})); + var IndexKind; + (function (IndexKind) { + IndexKind[IndexKind["String"] = 0] = "String"; + IndexKind[IndexKind["Number"] = 1] = "Number"; + })(IndexKind = ts.IndexKind || (ts.IndexKind = {})); + var InferencePriority; + (function (InferencePriority) { + InferencePriority[InferencePriority["NakedTypeVariable"] = 1] = "NakedTypeVariable"; + InferencePriority[InferencePriority["MappedType"] = 2] = "MappedType"; + InferencePriority[InferencePriority["ReturnType"] = 4] = "ReturnType"; + })(InferencePriority = ts.InferencePriority || (ts.InferencePriority = {})); + var InferenceFlags; + (function (InferenceFlags) { + InferenceFlags[InferenceFlags["InferUnionTypes"] = 1] = "InferUnionTypes"; + InferenceFlags[InferenceFlags["NoDefault"] = 2] = "NoDefault"; + InferenceFlags[InferenceFlags["AnyDefault"] = 4] = "AnyDefault"; + })(InferenceFlags = ts.InferenceFlags || (ts.InferenceFlags = {})); + var Ternary; + (function (Ternary) { + Ternary[Ternary["False"] = 0] = "False"; + Ternary[Ternary["Maybe"] = 1] = "Maybe"; + Ternary[Ternary["True"] = -1] = "True"; + })(Ternary = ts.Ternary || (ts.Ternary = {})); + var SpecialPropertyAssignmentKind; + (function (SpecialPropertyAssignmentKind) { + SpecialPropertyAssignmentKind[SpecialPropertyAssignmentKind["None"] = 0] = "None"; + SpecialPropertyAssignmentKind[SpecialPropertyAssignmentKind["ExportsProperty"] = 1] = "ExportsProperty"; + SpecialPropertyAssignmentKind[SpecialPropertyAssignmentKind["ModuleExports"] = 2] = "ModuleExports"; + SpecialPropertyAssignmentKind[SpecialPropertyAssignmentKind["PrototypeProperty"] = 3] = "PrototypeProperty"; + SpecialPropertyAssignmentKind[SpecialPropertyAssignmentKind["ThisProperty"] = 4] = "ThisProperty"; + SpecialPropertyAssignmentKind[SpecialPropertyAssignmentKind["Property"] = 5] = "Property"; + })(SpecialPropertyAssignmentKind = ts.SpecialPropertyAssignmentKind || (ts.SpecialPropertyAssignmentKind = {})); var DiagnosticCategory; (function (DiagnosticCategory) { DiagnosticCategory[DiagnosticCategory["Warning"] = 0] = "Warning"; @@ -91,6 +795,310 @@ var ts; ModuleKind[ModuleKind["ES2015"] = 5] = "ES2015"; ModuleKind[ModuleKind["ESNext"] = 6] = "ESNext"; })(ModuleKind = ts.ModuleKind || (ts.ModuleKind = {})); + var JsxEmit; + (function (JsxEmit) { + JsxEmit[JsxEmit["None"] = 0] = "None"; + JsxEmit[JsxEmit["Preserve"] = 1] = "Preserve"; + JsxEmit[JsxEmit["React"] = 2] = "React"; + JsxEmit[JsxEmit["ReactNative"] = 3] = "ReactNative"; + })(JsxEmit = ts.JsxEmit || (ts.JsxEmit = {})); + var NewLineKind; + (function (NewLineKind) { + NewLineKind[NewLineKind["CarriageReturnLineFeed"] = 0] = "CarriageReturnLineFeed"; + NewLineKind[NewLineKind["LineFeed"] = 1] = "LineFeed"; + })(NewLineKind = ts.NewLineKind || (ts.NewLineKind = {})); + var ScriptKind; + (function (ScriptKind) { + ScriptKind[ScriptKind["Unknown"] = 0] = "Unknown"; + ScriptKind[ScriptKind["JS"] = 1] = "JS"; + ScriptKind[ScriptKind["JSX"] = 2] = "JSX"; + ScriptKind[ScriptKind["TS"] = 3] = "TS"; + ScriptKind[ScriptKind["TSX"] = 4] = "TSX"; + ScriptKind[ScriptKind["External"] = 5] = "External"; + ScriptKind[ScriptKind["JSON"] = 6] = "JSON"; + })(ScriptKind = ts.ScriptKind || (ts.ScriptKind = {})); + var ScriptTarget; + (function (ScriptTarget) { + ScriptTarget[ScriptTarget["ES3"] = 0] = "ES3"; + ScriptTarget[ScriptTarget["ES5"] = 1] = "ES5"; + ScriptTarget[ScriptTarget["ES2015"] = 2] = "ES2015"; + ScriptTarget[ScriptTarget["ES2016"] = 3] = "ES2016"; + ScriptTarget[ScriptTarget["ES2017"] = 4] = "ES2017"; + ScriptTarget[ScriptTarget["ESNext"] = 5] = "ESNext"; + ScriptTarget[ScriptTarget["Latest"] = 5] = "Latest"; + })(ScriptTarget = ts.ScriptTarget || (ts.ScriptTarget = {})); + var LanguageVariant; + (function (LanguageVariant) { + LanguageVariant[LanguageVariant["Standard"] = 0] = "Standard"; + LanguageVariant[LanguageVariant["JSX"] = 1] = "JSX"; + })(LanguageVariant = ts.LanguageVariant || (ts.LanguageVariant = {})); + var DiagnosticStyle; + (function (DiagnosticStyle) { + DiagnosticStyle[DiagnosticStyle["Simple"] = 0] = "Simple"; + DiagnosticStyle[DiagnosticStyle["Pretty"] = 1] = "Pretty"; + })(DiagnosticStyle = ts.DiagnosticStyle || (ts.DiagnosticStyle = {})); + var WatchDirectoryFlags; + (function (WatchDirectoryFlags) { + WatchDirectoryFlags[WatchDirectoryFlags["None"] = 0] = "None"; + WatchDirectoryFlags[WatchDirectoryFlags["Recursive"] = 1] = "Recursive"; + })(WatchDirectoryFlags = ts.WatchDirectoryFlags || (ts.WatchDirectoryFlags = {})); + var CharacterCodes; + (function (CharacterCodes) { + CharacterCodes[CharacterCodes["nullCharacter"] = 0] = "nullCharacter"; + CharacterCodes[CharacterCodes["maxAsciiCharacter"] = 127] = "maxAsciiCharacter"; + CharacterCodes[CharacterCodes["lineFeed"] = 10] = "lineFeed"; + CharacterCodes[CharacterCodes["carriageReturn"] = 13] = "carriageReturn"; + CharacterCodes[CharacterCodes["lineSeparator"] = 8232] = "lineSeparator"; + CharacterCodes[CharacterCodes["paragraphSeparator"] = 8233] = "paragraphSeparator"; + CharacterCodes[CharacterCodes["nextLine"] = 133] = "nextLine"; + CharacterCodes[CharacterCodes["space"] = 32] = "space"; + CharacterCodes[CharacterCodes["nonBreakingSpace"] = 160] = "nonBreakingSpace"; + CharacterCodes[CharacterCodes["enQuad"] = 8192] = "enQuad"; + CharacterCodes[CharacterCodes["emQuad"] = 8193] = "emQuad"; + CharacterCodes[CharacterCodes["enSpace"] = 8194] = "enSpace"; + CharacterCodes[CharacterCodes["emSpace"] = 8195] = "emSpace"; + CharacterCodes[CharacterCodes["threePerEmSpace"] = 8196] = "threePerEmSpace"; + CharacterCodes[CharacterCodes["fourPerEmSpace"] = 8197] = "fourPerEmSpace"; + CharacterCodes[CharacterCodes["sixPerEmSpace"] = 8198] = "sixPerEmSpace"; + CharacterCodes[CharacterCodes["figureSpace"] = 8199] = "figureSpace"; + CharacterCodes[CharacterCodes["punctuationSpace"] = 8200] = "punctuationSpace"; + CharacterCodes[CharacterCodes["thinSpace"] = 8201] = "thinSpace"; + CharacterCodes[CharacterCodes["hairSpace"] = 8202] = "hairSpace"; + CharacterCodes[CharacterCodes["zeroWidthSpace"] = 8203] = "zeroWidthSpace"; + CharacterCodes[CharacterCodes["narrowNoBreakSpace"] = 8239] = "narrowNoBreakSpace"; + CharacterCodes[CharacterCodes["ideographicSpace"] = 12288] = "ideographicSpace"; + CharacterCodes[CharacterCodes["mathematicalSpace"] = 8287] = "mathematicalSpace"; + CharacterCodes[CharacterCodes["ogham"] = 5760] = "ogham"; + CharacterCodes[CharacterCodes["_"] = 95] = "_"; + CharacterCodes[CharacterCodes["$"] = 36] = "$"; + CharacterCodes[CharacterCodes["_0"] = 48] = "_0"; + CharacterCodes[CharacterCodes["_1"] = 49] = "_1"; + CharacterCodes[CharacterCodes["_2"] = 50] = "_2"; + CharacterCodes[CharacterCodes["_3"] = 51] = "_3"; + CharacterCodes[CharacterCodes["_4"] = 52] = "_4"; + CharacterCodes[CharacterCodes["_5"] = 53] = "_5"; + CharacterCodes[CharacterCodes["_6"] = 54] = "_6"; + CharacterCodes[CharacterCodes["_7"] = 55] = "_7"; + CharacterCodes[CharacterCodes["_8"] = 56] = "_8"; + CharacterCodes[CharacterCodes["_9"] = 57] = "_9"; + CharacterCodes[CharacterCodes["a"] = 97] = "a"; + CharacterCodes[CharacterCodes["b"] = 98] = "b"; + CharacterCodes[CharacterCodes["c"] = 99] = "c"; + CharacterCodes[CharacterCodes["d"] = 100] = "d"; + CharacterCodes[CharacterCodes["e"] = 101] = "e"; + CharacterCodes[CharacterCodes["f"] = 102] = "f"; + CharacterCodes[CharacterCodes["g"] = 103] = "g"; + CharacterCodes[CharacterCodes["h"] = 104] = "h"; + CharacterCodes[CharacterCodes["i"] = 105] = "i"; + CharacterCodes[CharacterCodes["j"] = 106] = "j"; + CharacterCodes[CharacterCodes["k"] = 107] = "k"; + CharacterCodes[CharacterCodes["l"] = 108] = "l"; + CharacterCodes[CharacterCodes["m"] = 109] = "m"; + CharacterCodes[CharacterCodes["n"] = 110] = "n"; + CharacterCodes[CharacterCodes["o"] = 111] = "o"; + CharacterCodes[CharacterCodes["p"] = 112] = "p"; + CharacterCodes[CharacterCodes["q"] = 113] = "q"; + CharacterCodes[CharacterCodes["r"] = 114] = "r"; + CharacterCodes[CharacterCodes["s"] = 115] = "s"; + CharacterCodes[CharacterCodes["t"] = 116] = "t"; + CharacterCodes[CharacterCodes["u"] = 117] = "u"; + CharacterCodes[CharacterCodes["v"] = 118] = "v"; + CharacterCodes[CharacterCodes["w"] = 119] = "w"; + CharacterCodes[CharacterCodes["x"] = 120] = "x"; + CharacterCodes[CharacterCodes["y"] = 121] = "y"; + CharacterCodes[CharacterCodes["z"] = 122] = "z"; + CharacterCodes[CharacterCodes["A"] = 65] = "A"; + CharacterCodes[CharacterCodes["B"] = 66] = "B"; + CharacterCodes[CharacterCodes["C"] = 67] = "C"; + CharacterCodes[CharacterCodes["D"] = 68] = "D"; + CharacterCodes[CharacterCodes["E"] = 69] = "E"; + CharacterCodes[CharacterCodes["F"] = 70] = "F"; + CharacterCodes[CharacterCodes["G"] = 71] = "G"; + CharacterCodes[CharacterCodes["H"] = 72] = "H"; + CharacterCodes[CharacterCodes["I"] = 73] = "I"; + CharacterCodes[CharacterCodes["J"] = 74] = "J"; + CharacterCodes[CharacterCodes["K"] = 75] = "K"; + CharacterCodes[CharacterCodes["L"] = 76] = "L"; + CharacterCodes[CharacterCodes["M"] = 77] = "M"; + CharacterCodes[CharacterCodes["N"] = 78] = "N"; + CharacterCodes[CharacterCodes["O"] = 79] = "O"; + CharacterCodes[CharacterCodes["P"] = 80] = "P"; + CharacterCodes[CharacterCodes["Q"] = 81] = "Q"; + CharacterCodes[CharacterCodes["R"] = 82] = "R"; + CharacterCodes[CharacterCodes["S"] = 83] = "S"; + CharacterCodes[CharacterCodes["T"] = 84] = "T"; + CharacterCodes[CharacterCodes["U"] = 85] = "U"; + CharacterCodes[CharacterCodes["V"] = 86] = "V"; + CharacterCodes[CharacterCodes["W"] = 87] = "W"; + CharacterCodes[CharacterCodes["X"] = 88] = "X"; + CharacterCodes[CharacterCodes["Y"] = 89] = "Y"; + CharacterCodes[CharacterCodes["Z"] = 90] = "Z"; + CharacterCodes[CharacterCodes["ampersand"] = 38] = "ampersand"; + CharacterCodes[CharacterCodes["asterisk"] = 42] = "asterisk"; + CharacterCodes[CharacterCodes["at"] = 64] = "at"; + CharacterCodes[CharacterCodes["backslash"] = 92] = "backslash"; + CharacterCodes[CharacterCodes["backtick"] = 96] = "backtick"; + CharacterCodes[CharacterCodes["bar"] = 124] = "bar"; + CharacterCodes[CharacterCodes["caret"] = 94] = "caret"; + CharacterCodes[CharacterCodes["closeBrace"] = 125] = "closeBrace"; + CharacterCodes[CharacterCodes["closeBracket"] = 93] = "closeBracket"; + CharacterCodes[CharacterCodes["closeParen"] = 41] = "closeParen"; + CharacterCodes[CharacterCodes["colon"] = 58] = "colon"; + CharacterCodes[CharacterCodes["comma"] = 44] = "comma"; + CharacterCodes[CharacterCodes["dot"] = 46] = "dot"; + CharacterCodes[CharacterCodes["doubleQuote"] = 34] = "doubleQuote"; + CharacterCodes[CharacterCodes["equals"] = 61] = "equals"; + CharacterCodes[CharacterCodes["exclamation"] = 33] = "exclamation"; + CharacterCodes[CharacterCodes["greaterThan"] = 62] = "greaterThan"; + CharacterCodes[CharacterCodes["hash"] = 35] = "hash"; + CharacterCodes[CharacterCodes["lessThan"] = 60] = "lessThan"; + CharacterCodes[CharacterCodes["minus"] = 45] = "minus"; + CharacterCodes[CharacterCodes["openBrace"] = 123] = "openBrace"; + CharacterCodes[CharacterCodes["openBracket"] = 91] = "openBracket"; + CharacterCodes[CharacterCodes["openParen"] = 40] = "openParen"; + CharacterCodes[CharacterCodes["percent"] = 37] = "percent"; + CharacterCodes[CharacterCodes["plus"] = 43] = "plus"; + CharacterCodes[CharacterCodes["question"] = 63] = "question"; + CharacterCodes[CharacterCodes["semicolon"] = 59] = "semicolon"; + CharacterCodes[CharacterCodes["singleQuote"] = 39] = "singleQuote"; + CharacterCodes[CharacterCodes["slash"] = 47] = "slash"; + CharacterCodes[CharacterCodes["tilde"] = 126] = "tilde"; + CharacterCodes[CharacterCodes["backspace"] = 8] = "backspace"; + CharacterCodes[CharacterCodes["formFeed"] = 12] = "formFeed"; + CharacterCodes[CharacterCodes["byteOrderMark"] = 65279] = "byteOrderMark"; + CharacterCodes[CharacterCodes["tab"] = 9] = "tab"; + CharacterCodes[CharacterCodes["verticalTab"] = 11] = "verticalTab"; + })(CharacterCodes = ts.CharacterCodes || (ts.CharacterCodes = {})); + var Extension; + (function (Extension) { + Extension["Ts"] = ".ts"; + Extension["Tsx"] = ".tsx"; + Extension["Dts"] = ".d.ts"; + Extension["Js"] = ".js"; + Extension["Jsx"] = ".jsx"; + })(Extension = ts.Extension || (ts.Extension = {})); + var TransformFlags; + (function (TransformFlags) { + TransformFlags[TransformFlags["None"] = 0] = "None"; + TransformFlags[TransformFlags["TypeScript"] = 1] = "TypeScript"; + TransformFlags[TransformFlags["ContainsTypeScript"] = 2] = "ContainsTypeScript"; + TransformFlags[TransformFlags["ContainsJsx"] = 4] = "ContainsJsx"; + TransformFlags[TransformFlags["ContainsESNext"] = 8] = "ContainsESNext"; + TransformFlags[TransformFlags["ContainsES2017"] = 16] = "ContainsES2017"; + TransformFlags[TransformFlags["ContainsES2016"] = 32] = "ContainsES2016"; + TransformFlags[TransformFlags["ES2015"] = 64] = "ES2015"; + TransformFlags[TransformFlags["ContainsES2015"] = 128] = "ContainsES2015"; + TransformFlags[TransformFlags["Generator"] = 256] = "Generator"; + TransformFlags[TransformFlags["ContainsGenerator"] = 512] = "ContainsGenerator"; + TransformFlags[TransformFlags["DestructuringAssignment"] = 1024] = "DestructuringAssignment"; + TransformFlags[TransformFlags["ContainsDestructuringAssignment"] = 2048] = "ContainsDestructuringAssignment"; + TransformFlags[TransformFlags["ContainsDecorators"] = 4096] = "ContainsDecorators"; + TransformFlags[TransformFlags["ContainsPropertyInitializer"] = 8192] = "ContainsPropertyInitializer"; + TransformFlags[TransformFlags["ContainsLexicalThis"] = 16384] = "ContainsLexicalThis"; + TransformFlags[TransformFlags["ContainsCapturedLexicalThis"] = 32768] = "ContainsCapturedLexicalThis"; + TransformFlags[TransformFlags["ContainsLexicalThisInComputedPropertyName"] = 65536] = "ContainsLexicalThisInComputedPropertyName"; + TransformFlags[TransformFlags["ContainsDefaultValueAssignments"] = 131072] = "ContainsDefaultValueAssignments"; + TransformFlags[TransformFlags["ContainsParameterPropertyAssignments"] = 262144] = "ContainsParameterPropertyAssignments"; + TransformFlags[TransformFlags["ContainsSpread"] = 524288] = "ContainsSpread"; + TransformFlags[TransformFlags["ContainsObjectSpread"] = 1048576] = "ContainsObjectSpread"; + TransformFlags[TransformFlags["ContainsRest"] = 524288] = "ContainsRest"; + TransformFlags[TransformFlags["ContainsObjectRest"] = 1048576] = "ContainsObjectRest"; + TransformFlags[TransformFlags["ContainsComputedPropertyName"] = 2097152] = "ContainsComputedPropertyName"; + TransformFlags[TransformFlags["ContainsBlockScopedBinding"] = 4194304] = "ContainsBlockScopedBinding"; + TransformFlags[TransformFlags["ContainsBindingPattern"] = 8388608] = "ContainsBindingPattern"; + TransformFlags[TransformFlags["ContainsYield"] = 16777216] = "ContainsYield"; + TransformFlags[TransformFlags["ContainsHoistedDeclarationOrCompletion"] = 33554432] = "ContainsHoistedDeclarationOrCompletion"; + TransformFlags[TransformFlags["ContainsDynamicImport"] = 67108864] = "ContainsDynamicImport"; + TransformFlags[TransformFlags["HasComputedFlags"] = 536870912] = "HasComputedFlags"; + TransformFlags[TransformFlags["AssertTypeScript"] = 3] = "AssertTypeScript"; + TransformFlags[TransformFlags["AssertJsx"] = 4] = "AssertJsx"; + TransformFlags[TransformFlags["AssertESNext"] = 8] = "AssertESNext"; + TransformFlags[TransformFlags["AssertES2017"] = 16] = "AssertES2017"; + TransformFlags[TransformFlags["AssertES2016"] = 32] = "AssertES2016"; + TransformFlags[TransformFlags["AssertES2015"] = 192] = "AssertES2015"; + TransformFlags[TransformFlags["AssertGenerator"] = 768] = "AssertGenerator"; + TransformFlags[TransformFlags["AssertDestructuringAssignment"] = 3072] = "AssertDestructuringAssignment"; + TransformFlags[TransformFlags["NodeExcludes"] = 536872257] = "NodeExcludes"; + TransformFlags[TransformFlags["ArrowFunctionExcludes"] = 601249089] = "ArrowFunctionExcludes"; + TransformFlags[TransformFlags["FunctionExcludes"] = 601281857] = "FunctionExcludes"; + TransformFlags[TransformFlags["ConstructorExcludes"] = 601015617] = "ConstructorExcludes"; + TransformFlags[TransformFlags["MethodOrAccessorExcludes"] = 601015617] = "MethodOrAccessorExcludes"; + TransformFlags[TransformFlags["ClassExcludes"] = 539358529] = "ClassExcludes"; + TransformFlags[TransformFlags["ModuleExcludes"] = 574674241] = "ModuleExcludes"; + TransformFlags[TransformFlags["TypeExcludes"] = -3] = "TypeExcludes"; + TransformFlags[TransformFlags["ObjectLiteralExcludes"] = 540087617] = "ObjectLiteralExcludes"; + TransformFlags[TransformFlags["ArrayLiteralOrCallOrNewExcludes"] = 537396545] = "ArrayLiteralOrCallOrNewExcludes"; + TransformFlags[TransformFlags["VariableDeclarationListExcludes"] = 546309441] = "VariableDeclarationListExcludes"; + TransformFlags[TransformFlags["ParameterExcludes"] = 536872257] = "ParameterExcludes"; + TransformFlags[TransformFlags["CatchClauseExcludes"] = 537920833] = "CatchClauseExcludes"; + TransformFlags[TransformFlags["BindingPatternExcludes"] = 537396545] = "BindingPatternExcludes"; + TransformFlags[TransformFlags["TypeScriptClassSyntaxMask"] = 274432] = "TypeScriptClassSyntaxMask"; + TransformFlags[TransformFlags["ES2015FunctionSyntaxMask"] = 163840] = "ES2015FunctionSyntaxMask"; + })(TransformFlags = ts.TransformFlags || (ts.TransformFlags = {})); + var EmitFlags; + (function (EmitFlags) { + EmitFlags[EmitFlags["SingleLine"] = 1] = "SingleLine"; + EmitFlags[EmitFlags["AdviseOnEmitNode"] = 2] = "AdviseOnEmitNode"; + EmitFlags[EmitFlags["NoSubstitution"] = 4] = "NoSubstitution"; + EmitFlags[EmitFlags["CapturesThis"] = 8] = "CapturesThis"; + EmitFlags[EmitFlags["NoLeadingSourceMap"] = 16] = "NoLeadingSourceMap"; + EmitFlags[EmitFlags["NoTrailingSourceMap"] = 32] = "NoTrailingSourceMap"; + EmitFlags[EmitFlags["NoSourceMap"] = 48] = "NoSourceMap"; + EmitFlags[EmitFlags["NoNestedSourceMaps"] = 64] = "NoNestedSourceMaps"; + EmitFlags[EmitFlags["NoTokenLeadingSourceMaps"] = 128] = "NoTokenLeadingSourceMaps"; + EmitFlags[EmitFlags["NoTokenTrailingSourceMaps"] = 256] = "NoTokenTrailingSourceMaps"; + EmitFlags[EmitFlags["NoTokenSourceMaps"] = 384] = "NoTokenSourceMaps"; + EmitFlags[EmitFlags["NoLeadingComments"] = 512] = "NoLeadingComments"; + EmitFlags[EmitFlags["NoTrailingComments"] = 1024] = "NoTrailingComments"; + EmitFlags[EmitFlags["NoComments"] = 1536] = "NoComments"; + EmitFlags[EmitFlags["NoNestedComments"] = 2048] = "NoNestedComments"; + EmitFlags[EmitFlags["HelperName"] = 4096] = "HelperName"; + EmitFlags[EmitFlags["ExportName"] = 8192] = "ExportName"; + EmitFlags[EmitFlags["LocalName"] = 16384] = "LocalName"; + EmitFlags[EmitFlags["InternalName"] = 32768] = "InternalName"; + EmitFlags[EmitFlags["Indented"] = 65536] = "Indented"; + EmitFlags[EmitFlags["NoIndentation"] = 131072] = "NoIndentation"; + EmitFlags[EmitFlags["AsyncFunctionBody"] = 262144] = "AsyncFunctionBody"; + EmitFlags[EmitFlags["ReuseTempVariableScope"] = 524288] = "ReuseTempVariableScope"; + EmitFlags[EmitFlags["CustomPrologue"] = 1048576] = "CustomPrologue"; + EmitFlags[EmitFlags["NoHoisting"] = 2097152] = "NoHoisting"; + EmitFlags[EmitFlags["HasEndOfDeclarationMarker"] = 4194304] = "HasEndOfDeclarationMarker"; + EmitFlags[EmitFlags["Iterator"] = 8388608] = "Iterator"; + EmitFlags[EmitFlags["NoAsciiEscaping"] = 16777216] = "NoAsciiEscaping"; + })(EmitFlags = ts.EmitFlags || (ts.EmitFlags = {})); + var ExternalEmitHelpers; + (function (ExternalEmitHelpers) { + ExternalEmitHelpers[ExternalEmitHelpers["Extends"] = 1] = "Extends"; + ExternalEmitHelpers[ExternalEmitHelpers["Assign"] = 2] = "Assign"; + ExternalEmitHelpers[ExternalEmitHelpers["Rest"] = 4] = "Rest"; + ExternalEmitHelpers[ExternalEmitHelpers["Decorate"] = 8] = "Decorate"; + ExternalEmitHelpers[ExternalEmitHelpers["Metadata"] = 16] = "Metadata"; + ExternalEmitHelpers[ExternalEmitHelpers["Param"] = 32] = "Param"; + ExternalEmitHelpers[ExternalEmitHelpers["Awaiter"] = 64] = "Awaiter"; + ExternalEmitHelpers[ExternalEmitHelpers["Generator"] = 128] = "Generator"; + ExternalEmitHelpers[ExternalEmitHelpers["Values"] = 256] = "Values"; + ExternalEmitHelpers[ExternalEmitHelpers["Read"] = 512] = "Read"; + ExternalEmitHelpers[ExternalEmitHelpers["Spread"] = 1024] = "Spread"; + ExternalEmitHelpers[ExternalEmitHelpers["Await"] = 2048] = "Await"; + ExternalEmitHelpers[ExternalEmitHelpers["AsyncGenerator"] = 4096] = "AsyncGenerator"; + ExternalEmitHelpers[ExternalEmitHelpers["AsyncDelegator"] = 8192] = "AsyncDelegator"; + ExternalEmitHelpers[ExternalEmitHelpers["AsyncValues"] = 16384] = "AsyncValues"; + ExternalEmitHelpers[ExternalEmitHelpers["ExportStar"] = 32768] = "ExportStar"; + ExternalEmitHelpers[ExternalEmitHelpers["ForOfIncludes"] = 256] = "ForOfIncludes"; + ExternalEmitHelpers[ExternalEmitHelpers["ForAwaitOfIncludes"] = 16384] = "ForAwaitOfIncludes"; + ExternalEmitHelpers[ExternalEmitHelpers["AsyncGeneratorIncludes"] = 6144] = "AsyncGeneratorIncludes"; + ExternalEmitHelpers[ExternalEmitHelpers["AsyncDelegatorIncludes"] = 26624] = "AsyncDelegatorIncludes"; + ExternalEmitHelpers[ExternalEmitHelpers["SpreadIncludes"] = 1536] = "SpreadIncludes"; + ExternalEmitHelpers[ExternalEmitHelpers["FirstEmitHelper"] = 1] = "FirstEmitHelper"; + ExternalEmitHelpers[ExternalEmitHelpers["LastEmitHelper"] = 32768] = "LastEmitHelper"; + })(ExternalEmitHelpers = ts.ExternalEmitHelpers || (ts.ExternalEmitHelpers = {})); + var EmitHint; + (function (EmitHint) { + EmitHint[EmitHint["SourceFile"] = 0] = "SourceFile"; + EmitHint[EmitHint["Expression"] = 1] = "Expression"; + EmitHint[EmitHint["IdentifierName"] = 2] = "IdentifierName"; + EmitHint[EmitHint["Unspecified"] = 3] = "Unspecified"; + })(EmitHint = ts.EmitHint || (ts.EmitHint = {})); })(ts || (ts = {})); var ts; (function (ts) { @@ -153,7 +1161,7 @@ var ts; })(ts || (ts = {})); var ts; (function (ts) { - ts.versionMajorMinor = "2.5"; + ts.versionMajorMinor = "2.6"; ts.version = ts.versionMajorMinor + ".0"; })(ts || (ts = {})); (function (ts) { @@ -267,6 +1275,12 @@ var ts; return getCanonicalFileName(nonCanonicalizedPath); } ts.toPath = toPath; + var Comparison; + (function (Comparison) { + Comparison[Comparison["LessThan"] = -1] = "LessThan"; + Comparison[Comparison["EqualTo"] = 0] = "EqualTo"; + Comparison[Comparison["GreaterThan"] = 1] = "GreaterThan"; + })(Comparison = ts.Comparison || (ts.Comparison = {})); function length(array) { return array ? array.length : 0; } @@ -438,10 +1452,9 @@ var ts; ts.removeWhere = removeWhere; function filterMutate(array, f) { var outIndex = 0; - for (var _i = 0, array_3 = array; _i < array_3.length; _i++) { - var item = array_3[_i]; - if (f(item)) { - array[outIndex] = item; + for (var i = 0; i < array.length; i++) { + if (f(array[i], i, array)) { + array[outIndex] = array[i]; outIndex++; } } @@ -487,8 +1500,8 @@ var ts; var result; if (array) { result = []; - for (var _i = 0, array_4 = array; _i < array_4.length; _i++) { - var v = array_4[_i]; + for (var _i = 0, array_3 = array; _i < array_3.length; _i++) { + var v = array_3[_i]; if (v) { if (isArray(v)) { addRange(result, v); @@ -558,11 +1571,13 @@ var ts; ts.sameFlatMap = sameFlatMap; function mapDefined(array, mapFn) { var result = []; - for (var i = 0; i < array.length; i++) { - var item = array[i]; - var mapped = mapFn(item, i); - if (mapped !== undefined) { - result.push(mapped); + if (array) { + for (var i = 0; i < array.length; i++) { + var item = array[i]; + var mapped = mapFn(item, i); + if (mapped !== undefined) { + result.push(mapped); + } } } return result; @@ -630,8 +1645,8 @@ var ts; function some(array, predicate) { if (array) { if (predicate) { - for (var _i = 0, array_5 = array; _i < array_5.length; _i++) { - var v = array_5[_i]; + for (var _i = 0, array_4 = array; _i < array_4.length; _i++) { + var v = array_4[_i]; if (predicate(v)) { return true; } @@ -656,8 +1671,8 @@ var ts; var result; if (array) { result = []; - loop: for (var _i = 0, array_6 = array; _i < array_6.length; _i++) { - var item = array_6[_i]; + loop: for (var _i = 0, array_5 = array; _i < array_5.length; _i++) { + var item = array_5[_i]; for (var _a = 0, result_1 = result; _a < result_1.length; _a++) { var res = result_1[_a]; if (areEqual ? areEqual(res, item) : res === item) { @@ -745,8 +1760,8 @@ var ts; ts.relativeComplement = relativeComplement; function sum(array, prop) { var result = 0; - for (var _i = 0, array_7 = array; _i < array_7.length; _i++) { - var v = array_7[_i]; + for (var _i = 0, array_6 = array; _i < array_6.length; _i++) { + var v = array_6[_i]; result += v[prop]; } return result; @@ -1006,8 +2021,8 @@ var ts; ts.equalOwnProperties = equalOwnProperties; function arrayToMap(array, makeKey, makeValue) { var result = createMap(); - for (var _i = 0, array_8 = array; _i < array_8.length; _i++) { - var value = array_8[_i]; + for (var _i = 0, array_7 = array; _i < array_7.length; _i++) { + var value = array_7[_i]; result.set(makeKey(value), makeValue ? makeValue(value) : value); } return result; @@ -1167,11 +2182,11 @@ var ts; ts.getLocaleSpecificMessage = getLocaleSpecificMessage; function createFileDiagnostic(file, start, length, message) { var end = start + length; - Debug.assert(start >= 0, "start must be non-negative, is " + start); - Debug.assert(length >= 0, "length must be non-negative, is " + length); + Debug.assertGreaterThanOrEqual(start, 0); + Debug.assertGreaterThanOrEqual(length, 0); if (file) { - Debug.assert(start <= file.text.length, "start must be within the bounds of the file. " + start + " > " + file.text.length); - Debug.assert(end <= file.text.length, "end must be the bounds of the file. " + end + " > " + file.text.length); + Debug.assertLessThanOrEqual(start, file.text.length); + Debug.assertLessThanOrEqual(end, file.text.length); } var text = getLocaleSpecificMessage(message); if (arguments.length > 4) { @@ -1380,19 +2395,23 @@ var ts; return normalized; } function normalizePath(path) { + return normalizePathAndParts(path).path; + } + ts.normalizePath = normalizePath; + function normalizePathAndParts(path) { path = normalizeSlashes(path); var rootLength = getRootLength(path); var root = path.substr(0, rootLength); - var normalized = getNormalizedParts(path, rootLength); - if (normalized.length) { - var joinedParts = root + normalized.join(ts.directorySeparator); - return pathEndsWithDirectorySeparator(path) ? joinedParts + ts.directorySeparator : joinedParts; + var parts = getNormalizedParts(path, rootLength); + if (parts.length) { + var joinedParts = root + parts.join(ts.directorySeparator); + return { path: pathEndsWithDirectorySeparator(path) ? joinedParts + ts.directorySeparator : joinedParts, parts: parts }; } else { - return root; + return { path: root, parts: parts }; } } - ts.normalizePath = normalizePath; + ts.normalizePathAndParts = normalizePathAndParts; function pathEndsWithDirectorySeparator(path) { return path.charCodeAt(path.length - 1) === directorySeparatorCharCode; } @@ -1655,8 +2674,28 @@ var ts; ts.fileExtensionIsOneOf = fileExtensionIsOneOf; var reservedCharacterPattern = /[^\w\s\/]/g; var wildcardCharCodes = [42, 63]; - var singleAsteriskRegexFragmentFiles = "([^./]|(\\.(?!min\\.js$))?)*"; - var singleAsteriskRegexFragmentOther = "[^/]*"; + ts.commonPackageFolders = ["node_modules", "bower_components", "jspm_packages"]; + var implicitExcludePathRegexPattern = "(?!(" + ts.commonPackageFolders.join("|") + ")(/|$))"; + var filesMatcher = { + singleAsteriskRegexFragment: "([^./]|(\\.(?!min\\.js$))?)*", + doubleAsteriskRegexFragment: "(/" + implicitExcludePathRegexPattern + "[^/.][^/]*)*?", + replaceWildcardCharacter: function (match) { return replaceWildcardCharacter(match, filesMatcher.singleAsteriskRegexFragment); } + }; + var directoriesMatcher = { + singleAsteriskRegexFragment: "[^/]*", + doubleAsteriskRegexFragment: "(/" + implicitExcludePathRegexPattern + "[^/.][^/]*)*?", + replaceWildcardCharacter: function (match) { return replaceWildcardCharacter(match, directoriesMatcher.singleAsteriskRegexFragment); } + }; + var excludeMatcher = { + singleAsteriskRegexFragment: "[^/]*", + doubleAsteriskRegexFragment: "(/.+?)?", + replaceWildcardCharacter: function (match) { return replaceWildcardCharacter(match, excludeMatcher.singleAsteriskRegexFragment); } + }; + var wildcardMatchers = { + files: filesMatcher, + directories: directoriesMatcher, + exclude: excludeMatcher + }; function getRegularExpressionForWildcard(specs, basePath, usage) { var patterns = getRegularExpressionsForWildcards(specs, basePath, usage); if (!patterns || !patterns.length) { @@ -1671,18 +2710,16 @@ var ts; if (specs === undefined || specs.length === 0) { return undefined; } - var replaceWildcardCharacter = usage === "files" ? replaceWildCardCharacterFiles : replaceWildCardCharacterOther; - var singleAsteriskRegexFragment = usage === "files" ? singleAsteriskRegexFragmentFiles : singleAsteriskRegexFragmentOther; - var doubleAsteriskRegexFragment = usage === "exclude" ? "(/.+?)?" : "(/[^/.][^/]*)*?"; return flatMap(specs, function (spec) { - return spec && getSubPatternFromSpec(spec, basePath, usage, singleAsteriskRegexFragment, doubleAsteriskRegexFragment, replaceWildcardCharacter); + return spec && getSubPatternFromSpec(spec, basePath, usage, wildcardMatchers[usage]); }); } function isImplicitGlob(lastPathComponent) { return !/[.*?]/.test(lastPathComponent); } ts.isImplicitGlob = isImplicitGlob; - function getSubPatternFromSpec(spec, basePath, usage, singleAsteriskRegexFragment, doubleAsteriskRegexFragment, replaceWildcardCharacter) { + function getSubPatternFromSpec(spec, basePath, usage, _a) { + var singleAsteriskRegexFragment = _a.singleAsteriskRegexFragment, doubleAsteriskRegexFragment = _a.doubleAsteriskRegexFragment, replaceWildcardCharacter = _a.replaceWildcardCharacter; var subpattern = ""; var hasRecursiveDirectoryWildcard = false; var hasWrittenComponent = false; @@ -1714,16 +2751,24 @@ var ts; subpattern += ts.directorySeparator; } if (usage !== "exclude") { + var componentPattern = ""; if (component.charCodeAt(0) === 42) { - subpattern += "([^./]" + singleAsteriskRegexFragment + ")?"; + componentPattern += "([^./]" + singleAsteriskRegexFragment + ")?"; component = component.substr(1); } else if (component.charCodeAt(0) === 63) { - subpattern += "[^./]"; + componentPattern += "[^./]"; component = component.substr(1); } + componentPattern += component.replace(reservedCharacterPattern, replaceWildcardCharacter); + if (componentPattern !== component) { + subpattern += implicitExcludePathRegexPattern; + } + subpattern += componentPattern; + } + else { + subpattern += component.replace(reservedCharacterPattern, replaceWildcardCharacter); } - subpattern += component.replace(reservedCharacterPattern, replaceWildcardCharacter); } hasWrittenComponent = true; } @@ -1733,12 +2778,6 @@ var ts; } return subpattern; } - function replaceWildCardCharacterFiles(match) { - return replaceWildcardCharacter(match, singleAsteriskRegexFragmentFiles); - } - function replaceWildCardCharacterOther(match) { - return replaceWildcardCharacter(match, singleAsteriskRegexFragmentOther); - } function replaceWildcardCharacter(match, singleAsteriskRegexFragment) { return match === "*" ? singleAsteriskRegexFragment : match === "?" ? "[^/]" : "\\" + match; } @@ -1875,14 +2914,7 @@ var ts; if (!extraFileExtensions || extraFileExtensions.length === 0 || !needAllExtensions) { return needAllExtensions ? allSupportedExtensions : ts.supportedTypeScriptExtensions; } - var extensions = allSupportedExtensions.slice(0); - for (var _i = 0, extraFileExtensions_1 = extraFileExtensions; _i < extraFileExtensions_1.length; _i++) { - var extInfo = extraFileExtensions_1[_i]; - if (extensions.indexOf(extInfo.extension) === -1) { - extensions.push(extInfo.extension); - } - } - return extensions; + return deduplicate(allSupportedExtensions.concat(extraFileExtensions.map(function (e) { return e.extension; }))); } ts.getSupportedExtensions = getSupportedExtensions; function hasJavaScriptFileExtension(fileName) { @@ -1906,6 +2938,13 @@ var ts; return false; } ts.isSupportedSourceFileName = isSupportedSourceFileName; + var ExtensionPriority; + (function (ExtensionPriority) { + ExtensionPriority[ExtensionPriority["TypeScriptFiles"] = 0] = "TypeScriptFiles"; + ExtensionPriority[ExtensionPriority["DeclarationAndJavaScriptFiles"] = 2] = "DeclarationAndJavaScriptFiles"; + ExtensionPriority[ExtensionPriority["Highest"] = 0] = "Highest"; + ExtensionPriority[ExtensionPriority["Lowest"] = 2] = "Lowest"; + })(ExtensionPriority = ts.ExtensionPriority || (ts.ExtensionPriority = {})); function getExtensionPriority(path, supportedExtensions) { for (var i = supportedExtensions.length - 1; i >= 0; i--) { if (fileExtensionIs(path, supportedExtensions[i])) { @@ -1999,6 +3038,13 @@ var ts; getSignatureConstructor: function () { return Signature; }, getSourceMapSourceConstructor: function () { return SourceMapSource; }, }; + var AssertionLevel; + (function (AssertionLevel) { + AssertionLevel[AssertionLevel["None"] = 0] = "None"; + AssertionLevel[AssertionLevel["Normal"] = 1] = "Normal"; + AssertionLevel[AssertionLevel["Aggressive"] = 2] = "Aggressive"; + AssertionLevel[AssertionLevel["VeryAggressive"] = 3] = "VeryAggressive"; + })(AssertionLevel = ts.AssertionLevel || (ts.AssertionLevel = {})); var Debug; (function (Debug) { Debug.currentAssertionLevel = 0; @@ -2010,12 +3056,37 @@ var ts; function assert(expression, message, verboseDebugInfo, stackCrawlMark) { if (!expression) { if (verboseDebugInfo) { - message += "\r\nVerbose Debug Information: " + verboseDebugInfo(); + message += "\r\nVerbose Debug Information: " + (typeof verboseDebugInfo === "string" ? verboseDebugInfo : verboseDebugInfo()); } fail(message ? "False expression: " + message : "False expression.", stackCrawlMark || assert); } } Debug.assert = assert; + function assertEqual(a, b, msg, msg2) { + if (a !== b) { + var message = msg ? msg2 ? msg + " " + msg2 : msg : ""; + fail("Expected " + a + " === " + b + ". " + message); + } + } + Debug.assertEqual = assertEqual; + function assertLessThan(a, b, msg) { + if (a >= b) { + fail("Expected " + a + " < " + b + ". " + (msg || "")); + } + } + Debug.assertLessThan = assertLessThan; + function assertLessThanOrEqual(a, b) { + if (a > b) { + fail("Expected " + a + " <= " + b); + } + } + Debug.assertLessThanOrEqual = assertLessThanOrEqual; + function assertGreaterThanOrEqual(a, b) { + if (a < b) { + fail("Expected " + a + " >= " + b); + } + } + Debug.assertGreaterThanOrEqual = assertGreaterThanOrEqual; function fail(message, stackCrawlMark) { debugger; var e = new Error(message ? "Debug Failure. " + message : "Debug Failure."); @@ -2150,6 +3221,10 @@ var ts; Debug.fail("File " + path + " has unknown extension."); } ts.extensionFromPath = extensionFromPath; + function isAnySupportedFileExtension(path) { + return tryGetExtensionFromPath(path) !== undefined; + } + ts.isAnySupportedFileExtension = isAnySupportedFileExtension; function tryGetExtensionFromPath(path) { return find(ts.supportedTypescriptExtensionsForExtractExtension, function (e) { return fileExtensionIs(path, e); }) || find(ts.supportedJavascriptExtensions, function (e) { return fileExtensionIs(path, e); }); } @@ -2161,6 +3236,12 @@ var ts; })(ts || (ts = {})); var ts; (function (ts) { + function setStackTraceLimit() { + if (Error.stackTraceLimit < 100) { + Error.stackTraceLimit = 100; + } + } + ts.setStackTraceLimit = setStackTraceLimit; var FileWatcherEventKind; (function (FileWatcherEventKind) { FileWatcherEventKind[FileWatcherEventKind["Created"] = 0] = "Created"; @@ -2210,7 +3291,7 @@ var ts; watcher.referenceCount += 1; return; } - watcher = _fs.watch(dirPath, { persistent: true }, function (eventName, relativeFileName) { return fileEventHandler(eventName, relativeFileName, dirPath); }); + watcher = _fs.watch(dirPath || ".", { persistent: true }, function (eventName, relativeFileName) { return fileEventHandler(eventName, relativeFileName, dirPath); }); watcher.referenceCount = 1; dirWatchers.set(dirPath, watcher); return; @@ -2334,6 +3415,11 @@ var ts; function readDirectory(path, extensions, excludes, includes, depth) { return ts.matchFiles(path, extensions, excludes, includes, useCaseSensitiveFileNames, process.cwd(), depth, getAccessibleFileSystemEntries); } + var FileSystemEntryKind; + (function (FileSystemEntryKind) { + FileSystemEntryKind[FileSystemEntryKind["File"] = 0] = "File"; + FileSystemEntryKind[FileSystemEntryKind["Directory"] = 1] = "Directory"; + })(FileSystemEntryKind || (FileSystemEntryKind = {})); function fileSystemEntryExists(path, entryKind) { try { var stat = _fs.statSync(path); @@ -3031,6 +4117,8 @@ var ts; Expected_at_least_0_arguments_but_got_a_minimum_of_1: diag(2557, ts.DiagnosticCategory.Error, "Expected_at_least_0_arguments_but_got_a_minimum_of_1_2557", "Expected at least {0} arguments, but got a minimum of {1}."), Expected_0_type_arguments_but_got_1: diag(2558, ts.DiagnosticCategory.Error, "Expected_0_type_arguments_but_got_1_2558", "Expected {0} type arguments, but got {1}."), Type_0_has_no_properties_in_common_with_type_1: diag(2559, ts.DiagnosticCategory.Error, "Type_0_has_no_properties_in_common_with_type_1_2559", "Type '{0}' has no properties in common with type '{1}'."), + Value_of_type_0_has_no_properties_in_common_with_type_1_Did_you_mean_to_call_it: diag(2560, ts.DiagnosticCategory.Error, "Value_of_type_0_has_no_properties_in_common_with_type_1_Did_you_mean_to_call_it_2560", "Value of type '{0}' has no properties in common with type '{1}'. Did you mean to call it?"), + Base_class_expressions_cannot_reference_class_type_parameters: diag(2561, ts.DiagnosticCategory.Error, "Base_class_expressions_cannot_reference_class_type_parameters_2561", "Base class expressions cannot reference class type parameters."), JSX_element_attributes_type_0_may_not_be_a_union_type: diag(2600, ts.DiagnosticCategory.Error, "JSX_element_attributes_type_0_may_not_be_a_union_type_2600", "JSX element attributes type '{0}' may not be a union type."), The_return_type_of_a_JSX_element_constructor_must_return_an_object_type: diag(2601, ts.DiagnosticCategory.Error, "The_return_type_of_a_JSX_element_constructor_must_return_an_object_type_2601", "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: diag(2602, ts.DiagnosticCategory.Error, "JSX_element_implicitly_has_type_any_because_the_global_type_JSX_Element_does_not_exist_2602", "JSX element implicitly has type 'any' because the global type 'JSX.Element' does not exist."), @@ -3218,6 +4306,7 @@ var ts; Do_not_emit_outputs: diag(6010, ts.DiagnosticCategory.Message, "Do_not_emit_outputs_6010", "Do not emit outputs."), Allow_default_imports_from_modules_with_no_default_export_This_does_not_affect_code_emit_just_typechecking: diag(6011, ts.DiagnosticCategory.Message, "Allow_default_imports_from_modules_with_no_default_export_This_does_not_affect_code_emit_just_typech_6011", "Allow default imports from modules with no default export. This does not affect code emit, just typechecking."), Skip_type_checking_of_declaration_files: diag(6012, ts.DiagnosticCategory.Message, "Skip_type_checking_of_declaration_files_6012", "Skip type checking of declaration files."), + Do_not_resolve_the_real_path_of_symlinks: diag(6013, ts.DiagnosticCategory.Message, "Do_not_resolve_the_real_path_of_symlinks_6013", "Do not resolve the real path of symlinks."), Specify_ECMAScript_target_version_Colon_ES3_default_ES5_ES2015_ES2016_ES2017_or_ESNEXT: diag(6015, ts.DiagnosticCategory.Message, "Specify_ECMAScript_target_version_Colon_ES3_default_ES5_ES2015_ES2016_ES2017_or_ESNEXT_6015", "Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', or 'ESNEXT'."), Specify_module_code_generation_Colon_none_commonjs_amd_system_umd_es2015_or_ESNext: diag(6016, ts.DiagnosticCategory.Message, "Specify_module_code_generation_Colon_none_commonjs_amd_system_umd_es2015_or_ESNext_6016", "Specify module code generation: 'none', commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'."), Print_this_message: diag(6017, ts.DiagnosticCategory.Message, "Print_this_message_6017", "Print this message."), @@ -3471,6 +4560,8 @@ var ts; Rewrite_as_the_indexed_access_type_0: diag(90026, ts.DiagnosticCategory.Message, "Rewrite_as_the_indexed_access_type_0_90026", "Rewrite as the indexed access type '{0}'."), Convert_function_to_an_ES2015_class: diag(95001, ts.DiagnosticCategory.Message, "Convert_function_to_an_ES2015_class_95001", "Convert function to an ES2015 class"), Convert_function_0_to_class: diag(95002, ts.DiagnosticCategory.Message, "Convert_function_0_to_class_95002", "Convert function '{0}' to class"), + Extract_function: diag(95003, ts.DiagnosticCategory.Message, "Extract_function_95003", "Extract function"), + Extract_function_into_0: diag(95004, ts.DiagnosticCategory.Message, "Extract_function_into_0_95004", "Extract function into '{0}'"), }; })(ts || (ts = {})); var ts; @@ -3491,19 +4582,6 @@ var ts; return undefined; } ts.getDeclarationOfKind = getDeclarationOfKind; - function findDeclaration(symbol, predicate) { - var declarations = symbol.declarations; - if (declarations) { - for (var _i = 0, declarations_2 = declarations; _i < declarations_2.length; _i++) { - var declaration = declarations_2[_i]; - if (predicate(declaration)) { - return declaration; - } - } - } - return undefined; - } - ts.findDeclaration = findDeclaration; var stringWriter = createSingleLineStringWriter(); var stringWriterAcquired = false; function createSingleLineStringWriter() { @@ -3566,9 +4644,13 @@ var ts; function moduleResolutionIsEqualTo(oldResolution, newResolution) { return oldResolution.isExternalLibraryImport === newResolution.isExternalLibraryImport && oldResolution.extension === newResolution.extension && - oldResolution.resolvedFileName === newResolution.resolvedFileName; + oldResolution.resolvedFileName === newResolution.resolvedFileName && + packageIdIsEqual(oldResolution.packageId, newResolution.packageId); } ts.moduleResolutionIsEqualTo = moduleResolutionIsEqualTo; + function packageIdIsEqual(a, b) { + return a === b || a && b && a.name === b.name && a.version === b.version; + } function typeDirectiveIsEqualTo(oldResolution, newResolution) { return oldResolution.resolvedFileName === newResolution.resolvedFileName && oldResolution.primary === newResolution.primary; } @@ -3633,14 +4715,6 @@ var ts; return file.fileName + "(" + (loc.line + 1) + "," + (loc.character + 1) + ")"; } ts.nodePosToString = nodePosToString; - function getStartPosOfNode(node) { - return node.pos; - } - ts.getStartPosOfNode = getStartPosOfNode; - function isDefined(value) { - return value !== undefined; - } - ts.isDefined = isDefined; function getEndLinePosition(line, sourceFile) { ts.Debug.assert(line >= 0); var lineStarts = ts.getLineStarts(sourceFile); @@ -3671,6 +4745,25 @@ var ts; return !nodeIsMissing(node); } ts.nodeIsPresent = nodeIsPresent; + function isRecognizedTripleSlashComment(text, commentPos, commentEnd) { + if (text.charCodeAt(commentPos + 1) === 47 && + commentPos + 2 < commentEnd && + text.charCodeAt(commentPos + 2) === 47) { + var textSubStr = text.substring(commentPos, commentEnd); + return textSubStr.match(ts.fullTripleSlashReferencePathRegEx) || + textSubStr.match(ts.fullTripleSlashAMDReferencePathRegEx) || + textSubStr.match(fullTripleSlashReferenceTypeReferenceDirectiveRegEx) || + textSubStr.match(defaultLibReferenceRegEx) ? + true : false; + } + return false; + } + ts.isRecognizedTripleSlashComment = isRecognizedTripleSlashComment; + function isPinnedComment(text, comment) { + return text.charCodeAt(comment.pos + 1) === 42 && + text.charCodeAt(comment.pos + 2) === 33; + } + ts.isPinnedComment = isPinnedComment; function getTokenPosOfNode(node, sourceFile, includeJsDoc) { if (nodeIsMissing(node)) { return node.pos; @@ -3727,15 +4820,20 @@ var ts; var escapeText = getEmitFlags(node) & 16777216 ? escapeString : escapeNonAsciiString; switch (node.kind) { case 9: - return '"' + escapeText(node.text) + '"'; + if (node.singleQuote) { + return "'" + escapeText(node.text, 39) + "'"; + } + else { + return '"' + escapeText(node.text, 34) + '"'; + } case 13: - return "`" + escapeText(node.text) + "`"; + return "`" + escapeText(node.text, 96) + "`"; case 14: - return "`" + escapeText(node.text) + "${"; + return "`" + escapeText(node.text, 96) + "${"; case 15: - return "}" + escapeText(node.text) + "${"; + return "}" + escapeText(node.text, 96) + "${"; case 16: - return "}" + escapeText(node.text) + "`"; + return "}" + escapeText(node.text, 96) + "`"; case 8: return node.text; } @@ -3987,13 +5085,9 @@ var ts; } ts.isPrologueDirective = isPrologueDirective; function getLeadingCommentRangesOfNode(node, sourceFileOfNode) { - return ts.getLeadingCommentRanges(sourceFileOfNode.text, node.pos); + return node.kind !== 10 ? ts.getLeadingCommentRanges(sourceFileOfNode.text, node.pos) : undefined; } ts.getLeadingCommentRangesOfNode = getLeadingCommentRangesOfNode; - function getLeadingCommentRangesOfNodeFromText(node, text) { - return ts.getLeadingCommentRanges(text, node.pos); - } - ts.getLeadingCommentRangesOfNodeFromText = getLeadingCommentRangesOfNodeFromText; function getJSDocCommentRanges(node, text) { var commentRanges = (node.kind === 146 || node.kind === 145 || @@ -4001,7 +5095,7 @@ var ts; node.kind === 187 || node.kind === 185) ? ts.concatenate(ts.getTrailingCommentRanges(text, node.pos), ts.getLeadingCommentRanges(text, node.pos)) : - getLeadingCommentRangesOfNodeFromText(node, text); + ts.getLeadingCommentRanges(text, node.pos); return ts.filter(commentRanges, function (comment) { return text.charCodeAt(comment.pos + 1) === 42 && text.charCodeAt(comment.pos + 2) === 42 && @@ -4010,8 +5104,9 @@ var ts; } ts.getJSDocCommentRanges = getJSDocCommentRanges; ts.fullTripleSlashReferencePathRegEx = /^(\/\/\/\s*/; - ts.fullTripleSlashReferenceTypeReferenceDirectiveRegEx = /^(\/\/\/\s*/; + var fullTripleSlashReferenceTypeReferenceDirectiveRegEx = /^(\/\/\/\s*/; ts.fullTripleSlashAMDReferencePathRegEx = /^(\/\/\/\s*/; + var defaultLibReferenceRegEx = /^(\/\/\/\s*/; function isPartOfTypeNode(node) { if (158 <= node.kind && node.kind <= 173) { return true; @@ -4238,21 +5333,11 @@ var ts; } ts.getPropertyAssignment = getPropertyAssignment; function getContainingFunction(node) { - while (true) { - node = node.parent; - if (!node || ts.isFunctionLike(node)) { - return node; - } - } + return ts.findAncestor(node.parent, ts.isFunctionLike); } ts.getContainingFunction = getContainingFunction; function getContainingClass(node) { - while (true) { - node = node.parent; - if (!node || ts.isClassLike(node)) { - return node; - } - } + return ts.findAncestor(node.parent, ts.isClassLike); } ts.getContainingClass = getContainingClass; function getThisContainer(node, includeArrowFunctions) { @@ -4859,6 +5944,12 @@ var ts; return node && node.dotDotDotToken !== undefined; } ts.isDeclaredRestParam = isDeclaredRestParam; + var AssignmentKind; + (function (AssignmentKind) { + AssignmentKind[AssignmentKind["None"] = 0] = "None"; + AssignmentKind[AssignmentKind["Definite"] = 1] = "Definite"; + AssignmentKind[AssignmentKind["Compound"] = 2] = "Compound"; + })(AssignmentKind = ts.AssignmentKind || (ts.AssignmentKind = {})); function getAssignmentTargetKind(node) { var parent = node.parent; while (true) { @@ -5056,14 +6147,14 @@ var ts; ts.getAncestor = getAncestor; function getFileReferenceFromReferencePath(comment, commentRange) { var simpleReferenceRegEx = /^\/\/\/\s*/gim; + var isNoDefaultLibRegEx = new RegExp(defaultLibReferenceRegEx.source, "gim"); if (simpleReferenceRegEx.test(comment)) { if (isNoDefaultLibRegEx.test(comment)) { return { isNoDefaultLib: true }; } else { var refMatchResult = ts.fullTripleSlashReferencePathRegEx.exec(comment); - var refLibResult = !refMatchResult && ts.fullTripleSlashReferenceTypeReferenceDirectiveRegEx.exec(comment); + var refLibResult = !refMatchResult && fullTripleSlashReferenceTypeReferenceDirectiveRegEx.exec(comment); var match = refMatchResult || refLibResult; if (match) { var pos = commentRange.pos + match[1].length + match[2].length; @@ -5094,6 +6185,14 @@ var ts; return 2 <= token && token <= 7; } ts.isTrivia = isTrivia; + var FunctionFlags; + (function (FunctionFlags) { + FunctionFlags[FunctionFlags["Normal"] = 0] = "Normal"; + FunctionFlags[FunctionFlags["Generator"] = 1] = "Generator"; + FunctionFlags[FunctionFlags["Async"] = 2] = "Async"; + FunctionFlags[FunctionFlags["Invalid"] = 4] = "Invalid"; + FunctionFlags[FunctionFlags["AsyncGenerator"] = 3] = "AsyncGenerator"; + })(FunctionFlags = ts.FunctionFlags || (ts.FunctionFlags = {})); function getFunctionFlags(node) { if (!node) { return 4; @@ -5244,10 +6343,11 @@ var ts; return ts.getParseTreeNode(sourceFile, ts.isSourceFile) || sourceFile; } ts.getOriginalSourceFile = getOriginalSourceFile; - function getOriginalSourceFiles(sourceFiles) { - return ts.sameMap(sourceFiles, getOriginalSourceFile); - } - ts.getOriginalSourceFiles = getOriginalSourceFiles; + var Associativity; + (function (Associativity) { + Associativity[Associativity["Left"] = 0] = "Left"; + Associativity[Associativity["Right"] = 1] = "Right"; + })(Associativity = ts.Associativity || (ts.Associativity = {})); function getExpressionAssociativity(expression) { var operator = getOperator(expression); var hasArguments = expression.kind === 182 && expression.arguments !== undefined; @@ -5481,7 +6581,9 @@ var ts; } } ts.createDiagnosticCollection = createDiagnosticCollection; - var escapedCharsRegExp = /[\\\"\u0000-\u001f\t\v\f\b\r\n\u2028\u2029\u0085]/g; + var doubleQuoteEscapedCharsRegExp = /[\\\"\u0000-\u001f\t\v\f\b\r\n\u2028\u2029\u0085]/g; + var singleQuoteEscapedCharsRegExp = /[\\\'\u0000-\u001f\t\v\f\b\r\n\u2028\u2029\u0085]/g; + var backtickQuoteEscapedCharsRegExp = /[\\\`\u0000-\u001f\t\v\f\b\r\n\u2028\u2029\u0085]/g; var escapedCharsMap = ts.createMapFromTemplate({ "\0": "\\0", "\t": "\\t", @@ -5492,11 +6594,16 @@ var ts; "\n": "\\n", "\\": "\\\\", "\"": "\\\"", + "\'": "\\\'", + "\`": "\\\`", "\u2028": "\\u2028", "\u2029": "\\u2029", "\u0085": "\\u0085" }); - function escapeString(s) { + function escapeString(s, quoteChar) { + var escapedCharsRegExp = quoteChar === 96 ? backtickQuoteEscapedCharsRegExp : + quoteChar === 39 ? singleQuoteEscapedCharsRegExp : + doubleQuoteEscapedCharsRegExp; return s.replace(escapedCharsRegExp, getReplacement); } ts.escapeString = escapeString; @@ -5514,8 +6621,8 @@ var ts; return "\\u" + paddedHexCode; } var nonAsciiCharacters = /[^\u0000-\u007F]/g; - function escapeNonAsciiString(s) { - s = escapeString(s); + function escapeNonAsciiString(s, quoteChar) { + s = escapeString(s, quoteChar); return nonAsciiCharacters.test(s) ? s.replace(nonAsciiCharacters, function (c) { return get16BitUnicodeEscapeSequence(c.charCodeAt(0)); }) : s; @@ -5856,7 +6963,7 @@ var ts; var currentDetachedCommentInfo; if (removeComments) { if (node.pos === 0) { - leadingComments = ts.filter(ts.getLeadingCommentRanges(text, node.pos), isPinnedComment); + leadingComments = ts.filter(ts.getLeadingCommentRanges(text, node.pos), isPinnedCommentLocal); } } else { @@ -5888,9 +6995,8 @@ var ts; } } return currentDetachedCommentInfo; - function isPinnedComment(comment) { - return text.charCodeAt(comment.pos + 1) === 42 && - text.charCodeAt(comment.pos + 2) === 33; + function isPinnedCommentLocal(comment) { + return isPinnedComment(text, comment); } } ts.emitDetachedComments = emitDetachedComments; @@ -5961,9 +7067,13 @@ var ts; } ts.hasModifiers = hasModifiers; function hasModifier(node, flags) { - return (getModifierFlags(node) & flags) !== 0; + return !!getSelectedModifierFlags(node, flags); } ts.hasModifier = hasModifier; + function getSelectedModifierFlags(node, flags) { + return getModifierFlags(node) & flags; + } + ts.getSelectedModifierFlags = getSelectedModifierFlags; function getModifierFlags(node) { if (node.modifierFlagsCache & 536870912) { return node.modifierFlagsCache & ~536870912; @@ -6039,21 +7149,6 @@ var ts; return false; } ts.isDestructuringAssignment = isDestructuringAssignment; - function isSupportedExpressionWithTypeArguments(node) { - return isSupportedExpressionWithTypeArgumentsRest(node.expression); - } - ts.isSupportedExpressionWithTypeArguments = isSupportedExpressionWithTypeArguments; - function isSupportedExpressionWithTypeArgumentsRest(node) { - if (node.kind === 71) { - return true; - } - else if (ts.isPropertyAccessExpression(node)) { - return isSupportedExpressionWithTypeArgumentsRest(node.expression); - } - else { - return false; - } - } function isExpressionWithTypeArgumentsInClassExtendsClause(node) { return tryGetClassExtendingExpressionWithTypeArguments(node) !== undefined; } @@ -6166,72 +7261,6 @@ var ts; return carriageReturnLineFeed; } ts.getNewLineCharacter = getNewLineCharacter; - function isSimpleExpression(node) { - return isSimpleExpressionWorker(node, 0); - } - ts.isSimpleExpression = isSimpleExpression; - function isSimpleExpressionWorker(node, depth) { - if (depth <= 5) { - var kind = node.kind; - if (kind === 9 - || kind === 8 - || kind === 12 - || kind === 13 - || kind === 71 - || kind === 99 - || kind === 97 - || kind === 101 - || kind === 86 - || kind === 95) { - return true; - } - else if (kind === 179) { - return isSimpleExpressionWorker(node.expression, depth + 1); - } - else if (kind === 180) { - return isSimpleExpressionWorker(node.expression, depth + 1) - && isSimpleExpressionWorker(node.argumentExpression, depth + 1); - } - else if (kind === 192 - || kind === 193) { - return isSimpleExpressionWorker(node.operand, depth + 1); - } - else if (kind === 194) { - return node.operatorToken.kind !== 40 - && isSimpleExpressionWorker(node.left, depth + 1) - && isSimpleExpressionWorker(node.right, depth + 1); - } - else if (kind === 195) { - return isSimpleExpressionWorker(node.condition, depth + 1) - && isSimpleExpressionWorker(node.whenTrue, depth + 1) - && isSimpleExpressionWorker(node.whenFalse, depth + 1); - } - else if (kind === 190 - || kind === 189 - || kind === 188) { - return isSimpleExpressionWorker(node.expression, depth + 1); - } - else if (kind === 177) { - return node.elements.length === 0; - } - else if (kind === 178) { - return node.properties.length === 0; - } - else if (kind === 181) { - if (!isSimpleExpressionWorker(node.expression, depth + 1)) { - return false; - } - for (var _i = 0, _a = node.arguments; _i < _a.length; _i++) { - var argument = _a[_i]; - if (!isSimpleExpressionWorker(argument, depth + 1)) { - return false; - } - } - return true; - } - } - return false; - } function formatEnum(value, enumObject, isFlags) { if (value === void 0) { value = 0; } var members = getEnumMembers(enumObject); @@ -6300,18 +7329,6 @@ var ts; return formatEnum(flags, ts.ObjectFlags, true); } ts.formatObjectFlags = formatObjectFlags; - function getRangePos(range) { - return range ? range.pos : -1; - } - ts.getRangePos = getRangePos; - function getRangeEnd(range) { - return range ? range.end : -1; - } - ts.getRangeEnd = getRangeEnd; - function movePos(pos, value) { - return ts.positionIsSynthesized(pos) ? -1 : pos + value; - } - ts.movePos = movePos; function createRange(pos, end) { return { pos: pos, end: end }; } @@ -6340,14 +7357,6 @@ var ts; return range.pos === range.end; } ts.isCollapsedRange = isCollapsedRange; - function collapseRangeToStart(range) { - return isCollapsedRange(range) ? range : moveRangeEnd(range, range.pos); - } - ts.collapseRangeToStart = collapseRangeToStart; - function collapseRangeToEnd(range) { - return isCollapsedRange(range) ? range : moveRangePos(range, range.end); - } - ts.collapseRangeToEnd = collapseRangeToEnd; function createTokenRange(pos, token) { return createRange(pos, pos + ts.tokenToString(token).length); } @@ -6400,22 +7409,6 @@ var ts; function isInitializedVariable(node) { return node.initializer !== undefined; } - function isMergedWithClass(node) { - if (node.symbol) { - for (var _i = 0, _a = node.symbol.declarations; _i < _a.length; _i++) { - var declaration = _a[_i]; - if (declaration.kind === 229 && declaration !== node) { - return true; - } - } - } - return false; - } - ts.isMergedWithClass = isMergedWithClass; - function isFirstDeclarationOfKind(node, kind) { - return node.symbol && getDeclarationOfKind(node.symbol, kind) === node; - } - ts.isFirstDeclarationOfKind = isFirstDeclarationOfKind; function isWatchSet(options) { return options.watch && options.hasOwnProperty("watch"); } @@ -6616,6 +7609,20 @@ var ts; return ts.hasModifier(node, 92) && node.parent.kind === 152 && ts.isClassLike(node.parent.parent); } ts.isParameterPropertyDeclaration = isParameterPropertyDeclaration; + function isEmptyBindingPattern(node) { + if (ts.isBindingPattern(node)) { + return ts.every(node.elements, isEmptyBindingElement); + } + return false; + } + ts.isEmptyBindingPattern = isEmptyBindingPattern; + function isEmptyBindingElement(node) { + if (ts.isOmittedExpression(node)) { + return true; + } + return isEmptyBindingPattern(node.name); + } + ts.isEmptyBindingElement = isEmptyBindingElement; function walkUpBindingElementsAndPatterns(node) { while (node && (node.kind === 176 || ts.isBindingPattern(node))) { node = node.parent; @@ -7696,6 +8703,18 @@ var ts; return isUnaryExpressionKind(ts.skipPartiallyEmittedExpressions(node).kind); } ts.isUnaryExpression = isUnaryExpression; + function isUnaryExpressionWithWrite(expr) { + switch (expr.kind) { + case 193: + return true; + case 192: + return expr.operator === 43 || + expr.operator === 44; + default: + return false; + } + } + ts.isUnaryExpressionWithWrite = isUnaryExpressionWithWrite; function isExpressionKind(kind) { return kind === 195 || kind === 197 @@ -7880,9 +8899,19 @@ var ts; var kind = node.kind; return isStatementKindButNotDeclarationKind(kind) || isDeclarationStatementKind(kind) - || kind === 207; + || isBlockStatement(node); } ts.isStatement = isStatement; + function isBlockStatement(node) { + if (node.kind !== 207) + return false; + if (node.parent !== undefined) { + if (node.parent.kind === 224 || node.parent.kind === 260) { + return false; + } + } + return !ts.isFunctionBlock(node); + } function isModuleReference(node) { var kind = node.kind; return kind === 248 @@ -9540,6 +10569,16 @@ var ts; })(ts || (ts = {})); var ts; (function (ts) { + var SignatureFlags; + (function (SignatureFlags) { + SignatureFlags[SignatureFlags["None"] = 0] = "None"; + SignatureFlags[SignatureFlags["Yield"] = 1] = "Yield"; + SignatureFlags[SignatureFlags["Await"] = 2] = "Await"; + SignatureFlags[SignatureFlags["Type"] = 4] = "Type"; + SignatureFlags[SignatureFlags["RequireCompleteParameterList"] = 8] = "RequireCompleteParameterList"; + SignatureFlags[SignatureFlags["IgnoreMissingOpenBrace"] = 16] = "IgnoreMissingOpenBrace"; + SignatureFlags[SignatureFlags["JSDoc"] = 32] = "JSDoc"; + })(SignatureFlags || (SignatureFlags = {})); var NodeConstructor; var TokenConstructor; var IdentifierConstructor; @@ -11377,11 +12416,31 @@ var ts; var node = parseTokenNode(); return token() === 23 ? undefined : node; } - function parseLiteralTypeNode() { + function parseLiteralTypeNode(negative) { var node = createNode(173); - node.literal = parseSimpleUnaryExpression(); - finishNode(node); - return node; + var unaryMinusExpression; + if (negative) { + unaryMinusExpression = createNode(192); + unaryMinusExpression.operator = 38; + nextToken(); + } + var expression; + switch (token()) { + case 9: + case 8: + expression = parseLiteralLikeNode(token()); + break; + case 101: + case 86: + expression = parseTokenNode(); + } + if (negative) { + unaryMinusExpression.operand = expression; + finishNode(unaryMinusExpression); + expression = unaryMinusExpression; + } + node.literal = expression; + return finishNode(node); } function nextTokenIsNumericLiteral() { return nextToken() === 8; @@ -11413,7 +12472,7 @@ var ts; case 86: return parseLiteralTypeNode(); case 38: - return lookAhead(nextTokenIsNumericLiteral) ? parseLiteralTypeNode() : parseTypeReference(); + return lookAhead(nextTokenIsNumericLiteral) ? parseLiteralTypeNode(true) : parseTypeReference(); case 105: case 95: return parseTokenNode(); @@ -11462,6 +12521,7 @@ var ts; case 101: case 86: case 134: + case 39: return true; case 38: return lookAhead(nextTokenIsNumericLiteral); @@ -11780,7 +12840,7 @@ var ts; if (!arrowFunction) { return undefined; } - var isAsync = !!(ts.getModifierFlags(arrowFunction) & 256); + var isAsync = ts.hasModifier(arrowFunction, 256); var lastToken = token(); arrowFunction.equalsGreaterThanToken = parseExpectedToken(36, false, ts.Diagnostics._0_expected, "=>"); arrowFunction.body = (lastToken === 36 || lastToken === 17) @@ -11896,7 +12956,7 @@ var ts; function parseParenthesizedArrowFunctionExpressionHead(allowAmbiguity) { var node = createNode(187); node.modifiers = parseModifiersForArrowFunction(); - var isAsync = (ts.getModifierFlags(node) & 256) ? 2 : 0; + var isAsync = ts.hasModifier(node, 256) ? 2 : 0; fillSignature(56, isAsync | (allowAmbiguity ? 0 : 8), node); if (!node.parameters) { return undefined; @@ -12629,7 +13689,7 @@ var ts; parseExpected(89); node.asteriskToken = parseOptionalToken(39); var isGenerator = node.asteriskToken ? 1 : 0; - var isAsync = (ts.getModifierFlags(node) & 256) ? 2 : 0; + var isAsync = ts.hasModifier(node, 256) ? 2 : 0; node.name = isGenerator && isAsync ? doInYieldAndAwaitContext(parseOptionalIdentifier) : isGenerator ? doInYieldContext(parseOptionalIdentifier) : @@ -12854,10 +13914,13 @@ var ts; function parseCatchClause() { var result = createNode(260); parseExpected(74); - if (parseExpected(19)) { + if (parseOptional(19)) { result.variableDeclaration = parseVariableDeclaration(); + parseExpected(20); + } + else { + result.variableDeclaration = undefined; } - parseExpected(20); result.block = parseBlock(false); return finishNode(result); } @@ -13861,6 +14924,39 @@ var ts; : undefined; }); } + var ParsingContext; + (function (ParsingContext) { + ParsingContext[ParsingContext["SourceElements"] = 0] = "SourceElements"; + ParsingContext[ParsingContext["BlockStatements"] = 1] = "BlockStatements"; + ParsingContext[ParsingContext["SwitchClauses"] = 2] = "SwitchClauses"; + ParsingContext[ParsingContext["SwitchClauseStatements"] = 3] = "SwitchClauseStatements"; + ParsingContext[ParsingContext["TypeMembers"] = 4] = "TypeMembers"; + ParsingContext[ParsingContext["ClassMembers"] = 5] = "ClassMembers"; + ParsingContext[ParsingContext["EnumMembers"] = 6] = "EnumMembers"; + ParsingContext[ParsingContext["HeritageClauseElement"] = 7] = "HeritageClauseElement"; + ParsingContext[ParsingContext["VariableDeclarations"] = 8] = "VariableDeclarations"; + ParsingContext[ParsingContext["ObjectBindingElements"] = 9] = "ObjectBindingElements"; + ParsingContext[ParsingContext["ArrayBindingElements"] = 10] = "ArrayBindingElements"; + ParsingContext[ParsingContext["ArgumentExpressions"] = 11] = "ArgumentExpressions"; + ParsingContext[ParsingContext["ObjectLiteralMembers"] = 12] = "ObjectLiteralMembers"; + ParsingContext[ParsingContext["JsxAttributes"] = 13] = "JsxAttributes"; + ParsingContext[ParsingContext["JsxChildren"] = 14] = "JsxChildren"; + ParsingContext[ParsingContext["ArrayLiteralMembers"] = 15] = "ArrayLiteralMembers"; + ParsingContext[ParsingContext["Parameters"] = 16] = "Parameters"; + ParsingContext[ParsingContext["RestProperties"] = 17] = "RestProperties"; + ParsingContext[ParsingContext["TypeParameters"] = 18] = "TypeParameters"; + ParsingContext[ParsingContext["TypeArguments"] = 19] = "TypeArguments"; + ParsingContext[ParsingContext["TupleElementTypes"] = 20] = "TupleElementTypes"; + ParsingContext[ParsingContext["HeritageClauses"] = 21] = "HeritageClauses"; + ParsingContext[ParsingContext["ImportOrExportSpecifiers"] = 22] = "ImportOrExportSpecifiers"; + ParsingContext[ParsingContext["Count"] = 23] = "Count"; + })(ParsingContext || (ParsingContext = {})); + var Tristate; + (function (Tristate) { + Tristate[Tristate["False"] = 0] = "False"; + Tristate[Tristate["True"] = 1] = "True"; + Tristate[Tristate["Unknown"] = 2] = "Unknown"; + })(Tristate || (Tristate = {})); var JSDocParser; (function (JSDocParser) { function parseJSDocTypeExpressionForTests(content, start, length) { @@ -13913,6 +15009,17 @@ var ts; var _a; } JSDocParser.parseJSDocComment = parseJSDocComment; + var JSDocState; + (function (JSDocState) { + JSDocState[JSDocState["BeginningOfLine"] = 0] = "BeginningOfLine"; + JSDocState[JSDocState["SawAsterisk"] = 1] = "SawAsterisk"; + JSDocState[JSDocState["SavingComments"] = 2] = "SavingComments"; + })(JSDocState || (JSDocState = {})); + var PropertyLikeParse; + (function (PropertyLikeParse) { + PropertyLikeParse[PropertyLikeParse["Property"] = 0] = "Property"; + PropertyLikeParse[PropertyLikeParse["Parameter"] = 1] = "Parameter"; + })(PropertyLikeParse || (PropertyLikeParse = {})); function parseJSDocCommentWorker(start, length) { var content = sourceText; start = start || 0; @@ -14545,8 +15652,8 @@ var ts; array._children = undefined; array.pos += delta; array.end += delta; - for (var _i = 0, array_9 = array; _i < array_9.length; _i++) { - var node = array_9[_i]; + for (var _i = 0, array_8 = array; _i < array_8.length; _i++) { + var node = array_8[_i]; visitNode(node); } } @@ -14618,8 +15725,8 @@ var ts; array.intersectsChange = true; array._children = undefined; adjustIntersectingElement(array, changeStart, changeRangeOldEnd, changeRangeNewEnd, delta); - for (var _i = 0, array_10 = array; _i < array_10.length; _i++) { - var node = array_10[_i]; + for (var _i = 0, array_9 = array; _i < array_9.length; _i++) { + var node = array_9[_i]; visitNode(node); } return; @@ -14767,6 +15874,10 @@ var ts; } } } + var InvalidPosition; + (function (InvalidPosition) { + InvalidPosition[InvalidPosition["Value"] = -1] = "Value"; + })(InvalidPosition || (InvalidPosition = {})); })(IncrementalParser || (IncrementalParser = {})); })(ts || (ts = {})); var ts; @@ -15131,6 +16242,12 @@ var ts; category: ts.Diagnostics.Module_Resolution_Options, description: ts.Diagnostics.Allow_default_imports_from_modules_with_no_default_export_This_does_not_affect_code_emit_just_typechecking }, + { + name: "preserveSymlinks", + type: "boolean", + category: ts.Diagnostics.Module_Resolution_Options, + description: ts.Diagnostics.Do_not_resolve_the_real_path_of_symlinks, + }, { name: "sourceRoot", type: "string", @@ -15742,7 +16859,7 @@ var ts; var text = valueExpression.text; if (option && typeof option.type !== "string") { var customOption = option; - if (!customOption.type.has(text)) { + if (!customOption.type.has(text.toLowerCase())) { errors.push(createDiagnosticForInvalidCustomType(customOption, function (message, arg0, arg1) { return ts.createDiagnosticForNodeInSourceFile(sourceFile, valueExpression, message, arg0, arg1); })); } } @@ -15993,12 +17110,10 @@ var ts; } } else { - var specs = includeSpecs ? [] : ["node_modules", "bower_components", "jspm_packages"]; var outDir = raw["compilerOptions"] && raw["compilerOptions"]["outDir"]; if (outDir) { - specs.push(outDir); + excludeSpecs = [outDir]; } - excludeSpecs = specs; } if (fileNames === undefined && includeSpecs === undefined) { includeSpecs = ["**/*"]; @@ -16249,7 +17364,7 @@ var ts; return value; } else if (typeof option.type !== "string") { - return option.type.get(value); + return option.type.get(typeof value === "string" ? value.toLowerCase() : value); } return normalizeNonListOptionValue(option, basePath, value); } @@ -16324,23 +17439,13 @@ var ts; }; } function validateSpecs(specs, errors, allowTrailingRecursion, jsonSourceFile, specKey) { - var validSpecs = []; - for (var _i = 0, specs_1 = specs; _i < specs_1.length; _i++) { - var spec = specs_1[_i]; - if (!allowTrailingRecursion && invalidTrailingRecursionPattern.test(spec)) { - errors.push(createDiagnostic(ts.Diagnostics.File_specification_cannot_end_in_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0, spec)); + return specs.filter(function (spec) { + var diag = specToDiagnostic(spec, allowTrailingRecursion); + if (diag !== undefined) { + errors.push(createDiagnostic(diag, spec)); } - else if (invalidMultipleRecursionPatterns.test(spec)) { - errors.push(createDiagnostic(ts.Diagnostics.File_specification_cannot_contain_multiple_recursive_directory_wildcards_Asterisk_Asterisk_Colon_0, spec)); - } - else if (invalidDotDotAfterRecursiveWildcardPattern.test(spec)) { - errors.push(createDiagnostic(ts.Diagnostics.File_specification_cannot_contain_a_parent_directory_that_appears_after_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0, spec)); - } - else { - validSpecs.push(spec); - } - } - return validSpecs; + return diag === undefined; + }); function createDiagnostic(message, spec) { if (jsonSourceFile && jsonSourceFile.jsonObject) { for (var _i = 0, _a = ts.getPropertyAssignment(jsonSourceFile.jsonObject, specKey); _i < _a.length; _i++) { @@ -16358,6 +17463,17 @@ var ts; return ts.createCompilerDiagnostic(message, spec); } } + function specToDiagnostic(spec, allowTrailingRecursion) { + if (!allowTrailingRecursion && invalidTrailingRecursionPattern.test(spec)) { + return ts.Diagnostics.File_specification_cannot_end_in_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0; + } + else if (invalidMultipleRecursionPatterns.test(spec)) { + return ts.Diagnostics.File_specification_cannot_contain_multiple_recursive_directory_wildcards_Asterisk_Asterisk_Colon_0; + } + else if (invalidDotDotAfterRecursiveWildcardPattern.test(spec)) { + return ts.Diagnostics.File_specification_cannot_contain_a_parent_directory_that_appears_after_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0; + } + } function getWildcardDirectories(include, exclude, path, useCaseSensitiveFileNames) { var rawExcludeRegex = ts.getRegularExpressionForWildcard(exclude, path, "exclude"); var excludeRegex = rawExcludeRegex && new RegExp(rawExcludeRegex, useCaseSensitiveFileNames ? "" : "i"); @@ -16482,12 +17598,20 @@ var ts; "crypto", "stream", "util", "assert", "tty", "domain", "constants", "process", "v8", "timers", "console" ]; - var nodeCoreModules = ts.arrayToMap(JsTyping.nodeCoreModuleList, function (x) { return x; }); + var nodeCoreModules = ts.arrayToSet(JsTyping.nodeCoreModuleList); function loadSafeList(host, safeListPath) { var result = ts.readConfigFile(safeListPath, function (path) { return host.readFile(path); }); return ts.createMapFromTemplate(result.config); } JsTyping.loadSafeList = loadSafeList; + function loadTypesMap(host, typesMapPath) { + var result = ts.readConfigFile(typesMapPath, function (path) { return host.readFile(path); }); + if (result.config) { + return ts.createMapFromTemplate(result.config.simpleMap); + } + return undefined; + } + JsTyping.loadTypesMap = loadTypesMap; function discoverTypings(host, log, fileNames, projectRootPath, safeList, packageNameToTypingLocation, typeAcquisition, unresolvedImports) { if (!typeAcquisition || !typeAcquisition.enable) { return { cachedTypingPaths: [], newTypingNames: [], filesToWatch: [] }; @@ -16639,6 +17763,7 @@ var ts; Arguments.LogFile = "--logFile"; Arguments.EnableTelemetry = "--enableTelemetry"; Arguments.TypingSafeListLocation = "--typingSafeListLocation"; + Arguments.TypesMapLocation = "--typesMapLocation"; Arguments.NpmLocation = "--npmLocation"; })(Arguments = server.Arguments || (server.Arguments = {})); function hasArgument(argumentName) { @@ -16664,6 +17789,12 @@ var ts; return compilerOptions.traceResolution && host.trace !== undefined; } ts.isTraceEnabled = isTraceEnabled; + function withPackageId(packageId, r) { + return r && { path: r.path, extension: r.ext, packageId: packageId }; + } + function noPackageId(r) { + return withPackageId(undefined, r); + } var Extensions; (function (Extensions) { Extensions[Extensions["TypeScript"] = 0] = "TypeScript"; @@ -16679,12 +17810,11 @@ var ts; } function createResolvedModuleWithFailedLookupLocations(resolved, isExternalLibraryImport, failedLookupLocations) { return { - resolvedModule: resolved && { resolvedFileName: resolved.path, extension: resolved.extension, isExternalLibraryImport: isExternalLibraryImport }, + resolvedModule: resolved && { resolvedFileName: resolved.path, extension: resolved.extension, isExternalLibraryImport: isExternalLibraryImport, packageId: resolved.packageId }, failedLookupLocations: failedLookupLocations }; } - function tryReadPackageJsonFields(readTypes, packageJsonPath, baseDirectory, state) { - var jsonContent = readJson(packageJsonPath, state.host); + function tryReadPackageJsonFields(readTypes, jsonContent, baseDirectory, state) { return readTypes ? tryReadFromField("typings") || tryReadFromField("types") : tryReadFromField("main"); function tryReadFromField(fieldName) { if (!ts.hasProperty(jsonContent, fieldName)) { @@ -16778,7 +17908,9 @@ var ts; } var resolvedTypeReferenceDirective; if (resolved) { - resolved = realpath(resolved, host, traceEnabled); + if (!options.preserveSymlinks) { + resolved = realPath(resolved, host, traceEnabled); + } if (traceEnabled) { trace(host, ts.Diagnostics.Type_reference_directive_0_was_successfully_resolved_to_1_primary_Colon_2, typeReferenceDirectiveName, resolved, primary); } @@ -17079,7 +18211,7 @@ var ts; if (extension !== undefined) { var path_1 = tryFile(candidate, failedLookupLocations, false, state); if (path_1 !== undefined) { - return { path: path_1, extension: extension }; + return { path: path_1, extension: extension, packageId: undefined }; } } return loader(extensions, candidate, failedLookupLocations, !directoryProbablyExists(ts.getDirectoryPath(candidate), state.host), state); @@ -17100,7 +18232,7 @@ var ts; function resolveJavaScriptModule(moduleName, initialDir, host) { var _a = nodeModuleNameResolverWorker(moduleName, initialDir, { moduleResolution: ts.ModuleResolutionKind.NodeJs, allowJs: true }, host, undefined, true), resolvedModule = _a.resolvedModule, failedLookupLocations = _a.failedLookupLocations; if (!resolvedModule) { - throw new Error("Could not resolve JS module " + moduleName + " starting at " + initialDir + ". Looked in: " + failedLookupLocations.join(", ")); + throw new Error("Could not resolve JS module '" + moduleName + "' starting at '" + initialDir + "'. Looked in: " + failedLookupLocations.join(", ")); } return resolvedModule.resolvedFileName; } @@ -17126,16 +18258,22 @@ var ts; trace(host, ts.Diagnostics.Loading_module_0_from_node_modules_folder_target_file_type_1, moduleName, Extensions[extensions]); } var resolved_1 = loadModuleFromNodeModules(extensions, moduleName, containingDirectory, failedLookupLocations, state, cache); - return resolved_1 && { value: resolved_1.value && { resolved: { path: realpath(resolved_1.value.path, host, traceEnabled), extension: resolved_1.value.extension }, isExternalLibraryImport: true } }; + if (!resolved_1) + return undefined; + var resolvedValue = resolved_1.value; + if (!compilerOptions.preserveSymlinks) { + resolvedValue = resolvedValue && __assign({}, resolved_1.value, { path: realPath(resolved_1.value.path, host, traceEnabled), extension: resolved_1.value.extension }); + } + return { value: resolvedValue && { resolved: resolvedValue, isExternalLibraryImport: true } }; } else { - var candidate = ts.normalizePath(ts.combinePaths(containingDirectory, moduleName)); + var _a = ts.normalizePathAndParts(ts.combinePaths(containingDirectory, moduleName)), candidate = _a.path, parts = _a.parts; var resolved_2 = nodeLoadModuleByRelativeName(extensions, candidate, failedLookupLocations, false, state, true); - return resolved_2 && toSearchResult({ resolved: resolved_2, isExternalLibraryImport: false }); + return resolved_2 && toSearchResult({ resolved: resolved_2, isExternalLibraryImport: ts.contains(parts, "node_modules") }); } } } - function realpath(path, host, traceEnabled) { + function realPath(path, host, traceEnabled) { if (!host.realpath) { return path; } @@ -17161,7 +18299,7 @@ var ts; } var resolvedFromFile = loadModuleFromFile(extensions, candidate, failedLookupLocations, onlyRecordFailures, state); if (resolvedFromFile) { - return resolvedFromFile; + return noPackageId(resolvedFromFile); } } if (!onlyRecordFailures) { @@ -17179,6 +18317,9 @@ var ts; return !host.directoryExists || host.directoryExists(directoryName); } ts.directoryProbablyExists = directoryProbablyExists; + function loadModuleFromFileNoPackageId(extensions, candidate, failedLookupLocations, onlyRecordFailures, state) { + return noPackageId(loadModuleFromFile(extensions, candidate, failedLookupLocations, onlyRecordFailures, state)); + } function loadModuleFromFile(extensions, candidate, failedLookupLocations, onlyRecordFailures, state) { var resolvedByAddingExtension = tryAddingExtensions(candidate, extensions, failedLookupLocations, onlyRecordFailures, state); if (resolvedByAddingExtension) { @@ -17208,9 +18349,9 @@ var ts; case Extensions.JavaScript: return tryExtension(".js") || tryExtension(".jsx"); } - function tryExtension(extension) { - var path = tryFile(candidate + extension, failedLookupLocations, onlyRecordFailures, state); - return path && { path: path, extension: extension }; + function tryExtension(ext) { + var path = tryFile(candidate + ext, failedLookupLocations, onlyRecordFailures, state); + return path && { path: path, ext: ext }; } } function tryFile(fileName, failedLookupLocations, onlyRecordFailures, state) { @@ -17233,12 +18374,20 @@ var ts; function loadNodeModuleFromDirectory(extensions, candidate, failedLookupLocations, onlyRecordFailures, state, considerPackageJson) { if (considerPackageJson === void 0) { considerPackageJson = true; } var directoryExists = !onlyRecordFailures && directoryProbablyExists(candidate, state.host); + var packageId; if (considerPackageJson) { var packageJsonPath = pathToPackageJson(candidate); if (directoryExists && state.host.fileExists(packageJsonPath)) { - var fromPackageJson = loadModuleFromPackageJson(packageJsonPath, extensions, candidate, failedLookupLocations, state); + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.Found_package_json_at_0, packageJsonPath); + } + var jsonContent = readJson(packageJsonPath, state.host); + if (typeof jsonContent.name === "string" && typeof jsonContent.version === "string") { + packageId = { name: jsonContent.name, version: jsonContent.version }; + } + var fromPackageJson = loadModuleFromPackageJson(jsonContent, extensions, candidate, failedLookupLocations, state); if (fromPackageJson) { - return fromPackageJson; + return withPackageId(packageId, fromPackageJson); } } else { @@ -17248,13 +18397,10 @@ var ts; failedLookupLocations.push(packageJsonPath); } } - return loadModuleFromFile(extensions, ts.combinePaths(candidate, "index"), failedLookupLocations, !directoryExists, state); + return withPackageId(packageId, loadModuleFromFile(extensions, ts.combinePaths(candidate, "index"), failedLookupLocations, !directoryExists, state)); } - function loadModuleFromPackageJson(packageJsonPath, extensions, candidate, failedLookupLocations, state) { - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.Found_package_json_at_0, packageJsonPath); - } - var file = tryReadPackageJsonFields(extensions !== Extensions.JavaScript, packageJsonPath, candidate, state); + function loadModuleFromPackageJson(jsonContent, extensions, candidate, failedLookupLocations, state) { + var file = tryReadPackageJsonFields(extensions !== Extensions.JavaScript, jsonContent, candidate, state); if (!file) { return undefined; } @@ -17270,11 +18416,15 @@ var ts; } } var nextExtensions = extensions === Extensions.DtsOnly ? Extensions.TypeScript : extensions; - return nodeLoadModuleByRelativeName(nextExtensions, file, failedLookupLocations, onlyRecordFailures, state, false); + var result = nodeLoadModuleByRelativeName(nextExtensions, file, failedLookupLocations, onlyRecordFailures, state, false); + if (result) { + ts.Debug.assert(result.packageId === undefined); + return { path: result.path, ext: result.extension }; + } } function resolvedIfExtensionMatches(extensions, path) { - var extension = ts.tryGetExtensionFromPath(path); - return extension !== undefined && extensionIsOk(extensions, extension) ? { path: path, extension: extension } : undefined; + var ext = ts.tryGetExtensionFromPath(path); + return ext !== undefined && extensionIsOk(extensions, ext) ? { path: path, ext: ext } : undefined; } function extensionIsOk(extensions, extension) { switch (extensions) { @@ -17291,7 +18441,7 @@ var ts; } function loadModuleFromNodeModulesFolder(extensions, moduleName, nodeModulesFolder, nodeModulesFolderExists, failedLookupLocations, state) { var candidate = ts.normalizePath(ts.combinePaths(nodeModulesFolder, moduleName)); - return loadModuleFromFile(extensions, candidate, failedLookupLocations, !nodeModulesFolderExists, state) || + return loadModuleFromFileNoPackageId(extensions, candidate, failedLookupLocations, !nodeModulesFolderExists, state) || loadNodeModuleFromDirectory(extensions, candidate, failedLookupLocations, !nodeModulesFolderExists, state); } function loadModuleFromNodeModules(extensions, moduleName, directory, failedLookupLocations, state, cache) { @@ -17365,7 +18515,7 @@ var ts; if (traceEnabled) { trace(host, ts.Diagnostics.Resolution_for_module_0_was_found_in_cache, moduleName); } - return { value: result.resolvedModule && { path: result.resolvedModule.resolvedFileName, extension: result.resolvedModule.extension } }; + return { value: result.resolvedModule && { path: result.resolvedModule.resolvedFileName, extension: result.resolvedModule.extension, packageId: result.resolvedModule.packageId } }; } } function classicNameResolver(moduleName, containingFile, compilerOptions, host, cache) { @@ -17376,7 +18526,7 @@ var ts; var resolved = tryResolve(Extensions.TypeScript) || tryResolve(Extensions.JavaScript); return createResolvedModuleWithFailedLookupLocations(resolved && resolved.value, false, failedLookupLocations); function tryResolve(extensions) { - var resolvedUsingSettings = tryLoadModuleUsingOptionalResolutionSettings(extensions, moduleName, containingDirectory, loadModuleFromFile, failedLookupLocations, state); + var resolvedUsingSettings = tryLoadModuleUsingOptionalResolutionSettings(extensions, moduleName, containingDirectory, loadModuleFromFileNoPackageId, failedLookupLocations, state); if (resolvedUsingSettings) { return { value: resolvedUsingSettings }; } @@ -17388,7 +18538,7 @@ var ts; return resolutionFromCache; } var searchName = ts.normalizePath(ts.combinePaths(directory, moduleName)); - return toSearchResult(loadModuleFromFile(extensions, searchName, failedLookupLocations, false, state)); + return toSearchResult(loadModuleFromFileNoPackageId(extensions, searchName, failedLookupLocations, false, state)); }); if (resolved_3) { return resolved_3; @@ -17399,7 +18549,7 @@ var ts; } else { var candidate = ts.normalizePath(ts.combinePaths(containingDirectory, moduleName)); - return toSearchResult(loadModuleFromFile(extensions, candidate, failedLookupLocations, false, state)); + return toSearchResult(loadModuleFromFileNoPackageId(extensions, candidate, failedLookupLocations, false, state)); } } } @@ -17488,11 +18638,12 @@ var ts; } typingsInstaller.validatePackageName = validatePackageName; var TypingsInstaller = (function () { - function TypingsInstaller(installTypingHost, globalCachePath, safeListPath, throttleLimit, log) { + function TypingsInstaller(installTypingHost, globalCachePath, safeListPath, typesMapLocation, throttleLimit, log) { if (log === void 0) { log = nullLog; } this.installTypingHost = installTypingHost; this.globalCachePath = globalCachePath; this.safeListPath = safeListPath; + this.typesMapLocation = typesMapLocation; this.throttleLimit = throttleLimit; this.log = log; this.packageNameToTypingLocation = ts.createMap(); @@ -17503,7 +18654,7 @@ var ts; this.installRunCount = 1; this.inFlightRequestCount = 0; if (this.log.isEnabled()) { - this.log.writeLine("Global cache location '" + globalCachePath + "', safe file path '" + safeListPath + "'"); + this.log.writeLine("Global cache location '" + globalCachePath + "', safe file path '" + safeListPath + "', types map path " + typesMapLocation); } this.processCacheLocation(this.globalCachePath); } @@ -17531,6 +18682,7 @@ var ts; } }; TypingsInstaller.prototype.install = function (req) { + var _this = this; if (this.log.isEnabled()) { this.log.writeLine("Got install request " + JSON.stringify(req)); } @@ -17541,9 +18693,9 @@ var ts; this.processCacheLocation(req.cachePath); } if (this.safeList === undefined) { - this.safeList = ts.JsTyping.loadSafeList(this.installTypingHost, this.safeListPath); + this.initializeSafeList(); } - var discoverTypingsResult = ts.JsTyping.discoverTypings(this.installTypingHost, this.log.isEnabled() ? this.log.writeLine : undefined, req.fileNames, req.projectRootPath, this.safeList, this.packageNameToTypingLocation, req.typeAcquisition, req.unresolvedImports); + var discoverTypingsResult = ts.JsTyping.discoverTypings(this.installTypingHost, this.log.isEnabled() ? (function (s) { return _this.log.writeLine(s); }) : undefined, req.fileNames, req.projectRootPath, this.safeList, this.packageNameToTypingLocation, req.typeAcquisition, req.unresolvedImports); if (this.log.isEnabled()) { this.log.writeLine("Finished typings discovery: " + JSON.stringify(discoverTypingsResult)); } @@ -17558,6 +18710,18 @@ var ts; } } }; + TypingsInstaller.prototype.initializeSafeList = function () { + if (this.typesMapLocation) { + var safeListFromMap = ts.JsTyping.loadTypesMap(this.installTypingHost, this.typesMapLocation); + if (safeListFromMap) { + this.log.writeLine("Loaded safelist from types map file '" + this.typesMapLocation + "'"); + this.safeList = safeListFromMap; + return; + } + this.log.writeLine("Failed to load safelist from types map file '" + this.typesMapLocation + "'"); + } + this.safeList = ts.JsTyping.loadSafeList(this.installTypingHost, this.safeListPath); + }; TypingsInstaller.prototype.processCacheLocation = function (cacheLocation) { if (this.log.isEnabled()) { this.log.writeLine("Processing cache location '" + cacheLocation + "'"); @@ -17727,14 +18891,15 @@ var ts; _this.sendResponse(_this.createSetTypings(req, currentlyCachedTypings.concat(installedTypingFiles))); } finally { - _this.sendResponse({ + var response = { kind: server.EventEndInstallTypes, eventId: requestId, projectName: req.projectName, packagesToInstall: scopedTypings, installSuccess: ok, typingsInstallerVersion: ts.version - }); + }; + _this.sendResponse(response); } }); }; @@ -17820,20 +18985,21 @@ var ts; var path = require("path"); var FileLog = (function () { function FileLog(logFile) { + var _this = this; this.logFile = logFile; this.logEnabled = true; + this.isEnabled = function () { + return _this.logEnabled && _this.logFile !== undefined; + }; + this.writeLine = function (text) { + try { + fs.appendFileSync(_this.logFile, text + ts.sys.newLine); + } + catch (e) { + _this.logEnabled = false; + } + }; } - FileLog.prototype.isEnabled = function () { - return this.logEnabled && this.logFile !== undefined; - }; - FileLog.prototype.writeLine = function (text) { - try { - fs.appendFileSync(this.logFile, text + ts.sys.newLine); - } - catch (e) { - this.logEnabled = false; - } - }; return FileLog; }()); function getDefaultNPMLocation(processName) { @@ -17868,8 +19034,8 @@ var ts; } var NodeTypingsInstaller = (function (_super) { __extends(NodeTypingsInstaller, _super); - function NodeTypingsInstaller(globalTypingsCacheLocation, typingSafeListLocation, npmLocation, throttleLimit, log) { - var _this = _super.call(this, ts.sys, globalTypingsCacheLocation, typingSafeListLocation ? ts.toPath(typingSafeListLocation, "", ts.createGetCanonicalFileName(ts.sys.useCaseSensitiveFileNames)) : ts.toPath("typingSafeList.json", __dirname, ts.createGetCanonicalFileName(ts.sys.useCaseSensitiveFileNames)), throttleLimit, log) || this; + function NodeTypingsInstaller(globalTypingsCacheLocation, typingSafeListLocation, typesMapLocation, npmLocation, throttleLimit, log) { + var _this = _super.call(this, ts.sys, globalTypingsCacheLocation, typingSafeListLocation ? ts.toPath(typingSafeListLocation, "", ts.createGetCanonicalFileName(ts.sys.useCaseSensitiveFileNames)) : ts.toPath("typingSafeList.json", __dirname, ts.createGetCanonicalFileName(ts.sys.useCaseSensitiveFileNames)), typesMapLocation ? ts.toPath(typesMapLocation, "", ts.createGetCanonicalFileName(ts.sys.useCaseSensitiveFileNames)) : ts.toPath("typesMap.json", __dirname, ts.createGetCanonicalFileName(ts.sys.useCaseSensitiveFileNames)), throttleLimit, log) || this; _this.npmPath = npmLocation !== undefined ? npmLocation : getDefaultNPMLocation(process.argv[0]); if (_this.npmPath.indexOf(" ") !== -1 && _this.npmPath[0] !== "\"") { _this.npmPath = "\"" + _this.npmPath + "\""; @@ -17884,7 +19050,7 @@ var ts; if (_this.log.isEnabled()) { _this.log.writeLine("Updating " + TypesRegistryPackageName + " npm package..."); } - _this.execSync(_this.npmPath + " install " + TypesRegistryPackageName, { cwd: globalTypingsCacheLocation, stdio: "ignore" }); + _this.execSync(_this.npmPath + " install --ignore-scripts " + TypesRegistryPackageName, { cwd: globalTypingsCacheLocation, stdio: "ignore" }); if (_this.log.isEnabled()) { _this.log.writeLine("Updated " + TypesRegistryPackageName + " npm package"); } @@ -17930,7 +19096,7 @@ var ts; if (this.log.isEnabled()) { this.log.writeLine("#" + requestId + " with arguments'" + JSON.stringify(args) + "'."); } - var command = this.npmPath + " install " + args.join(" ") + " --save-dev --user-agent=\"typesInstaller/" + ts.version + "\""; + var command = this.npmPath + " install --ignore-scripts " + args.join(" ") + " --save-dev --user-agent=\"typesInstaller/" + ts.version + "\""; var start = Date.now(); var stdout; var stderr; @@ -17954,6 +19120,7 @@ var ts; var logFilePath = server.findArgument(server.Arguments.LogFile); var globalTypingsCacheLocation = server.findArgument(server.Arguments.GlobalCacheLocation); var typingSafeListLocation = server.findArgument(server.Arguments.TypingSafeListLocation); + var typesMapLocation = server.findArgument(server.Arguments.TypesMapLocation); var npmLocation = server.findArgument(server.Arguments.NpmLocation); var log = new FileLog(logFilePath); if (log.isEnabled()) { @@ -17967,8 +19134,10 @@ var ts; } process.exit(0); }); - var installer = new NodeTypingsInstaller(globalTypingsCacheLocation, typingSafeListLocation, npmLocation, 5, log); + var installer = new NodeTypingsInstaller(globalTypingsCacheLocation, typingSafeListLocation, typesMapLocation, npmLocation, 5, log); installer.listen(); })(typingsInstaller = server.typingsInstaller || (server.typingsInstaller = {})); })(server = ts.server || (ts.server = {})); })(ts || (ts = {})); + +//# sourceMappingURL=typingsInstaller.js.map From 2fede097f30a8f893384ec60a72c70e0f32c163a Mon Sep 17 00:00:00 2001 From: Andy Date: Thu, 24 Aug 2017 08:03:05 -0700 Subject: [PATCH 132/370] Add helper functions for adding an item to an array only if it's not already contained (#17833) * Add helper functions for adding an item to an array only if it's not already contained * One more use of appendIfUnique --- src/compiler/checker.ts | 65 +++++++++-------------------------------- src/compiler/core.ts | 26 +++++++++++++++++ src/compiler/factory.ts | 8 ++--- 3 files changed, 42 insertions(+), 57 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 82f41bc31e6..4a07f349c9a 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -1881,10 +1881,9 @@ namespace ts { // The ES6 spec permits export * declarations in a module to circularly reference the module itself. For example, // module 'a' can 'export * from "b"' and 'b' can 'export * from "a"' without error. function visit(symbol: Symbol): SymbolTable { - if (!(symbol && symbol.flags & SymbolFlags.HasExports && !contains(visitedSymbols, symbol))) { + if (!(symbol && symbol.flags & SymbolFlags.HasExports && pushIfUnique(visitedSymbols, symbol))) { return; } - visitedSymbols.push(symbol); const symbols = cloneMap(symbol.exports); // All export * declarations are collected in an __export symbol by the binder const exportStars = symbol.exports.get(InternalSymbolName.ExportStar); @@ -2060,10 +2059,10 @@ namespace ts { } function getAccessibleSymbolChainFromSymbolTableWorker(symbols: SymbolTable, visitedSymbolTables: SymbolTable[]): Symbol[] { - if (contains(visitedSymbolTables, symbols)) { + if (!pushIfUnique(visitedSymbolTables, symbols)) { return undefined; } - visitedSymbolTables.push(symbols); + const result = trySymbolTable(symbols); visitedSymbolTables.pop(); return result; @@ -2276,14 +2275,7 @@ namespace ts { // since we will do the emitting later in trackSymbol. if (shouldComputeAliasToMakeVisible) { getNodeLinks(declaration).isVisible = true; - if (aliasesToMakeVisible) { - if (!contains(aliasesToMakeVisible, anyImportSyntax)) { - aliasesToMakeVisible.push(anyImportSyntax); - } - } - else { - aliasesToMakeVisible = [anyImportSyntax]; - } + aliasesToMakeVisible = appendIfUnique(aliasesToMakeVisible, anyImportSyntax); } return true; } @@ -3981,9 +3973,7 @@ namespace ts { forEach(declarations, declaration => { getNodeLinks(declaration).isVisible = true; const resultNode = getAnyImportSyntax(declaration) || declaration; - if (!contains(result, resultNode)) { - result.push(resultNode); - } + pushIfUnique(result, resultNode); if (isInternalModuleImportEqualsDeclaration(declaration)) { // Add the referenced top container visible @@ -4793,12 +4783,7 @@ namespace ts { function appendTypeParameters(typeParameters: TypeParameter[], declarations: ReadonlyArray): TypeParameter[] { for (const declaration of declarations) { const tp = getDeclaredTypeOfTypeParameter(getSymbolOfNode(declaration)); - if (!typeParameters) { - typeParameters = [tp]; - } - else if (!contains(typeParameters, tp)) { - typeParameters.push(tp); - } + typeParameters = appendIfUnique(typeParameters, tp); } return typeParameters; } @@ -5521,9 +5506,7 @@ namespace ts { if (!match) { return undefined; } - if (!contains(result, match)) { - (result || (result = [])).push(match); - } + result = appendIfUnique(result, match); } return result; } @@ -6073,12 +6056,7 @@ namespace ts { const modifiers = prop ? getDeclarationModifierFlagsFromSymbol(prop) : 0; if (prop && !(modifiers & excludeModifiers)) { commonFlags &= prop.flags; - if (!props) { - props = [prop]; - } - else if (!contains(props, prop)) { - props.push(prop); - } + props = appendIfUnique(props, prop); checkFlags |= (isReadonlySymbol(prop) ? CheckFlags.Readonly : 0) | (!(modifiers & ModifierFlags.NonPublicAccessibilityModifier) ? CheckFlags.ContainsPublic : 0) | (modifiers & ModifierFlags.Protected ? CheckFlags.ContainsProtected : 0) | @@ -6237,12 +6215,7 @@ namespace ts { let result: TypeParameter[]; forEach(getEffectiveTypeParameterDeclarations(declaration), node => { const tp = getDeclaredTypeOfTypeParameter(node.symbol); - if (!contains(result, tp)) { - if (!result) { - result = []; - } - result.push(tp); - } + result = appendIfUnique(result, tp); }); return result; } @@ -11715,9 +11688,7 @@ namespace ts { if (type === declaredType && declaredType === initialType) { return type; } - if (!contains(antecedentTypes, type)) { - antecedentTypes.push(type); - } + pushIfUnique(antecedentTypes, type); // If an antecedent type is not a subset of the declared type, we need to perform // subtype reduction. This happens when a "foreign" type is injected into the control // flow using the instanceof operator or a user defined type predicate. @@ -11783,9 +11754,7 @@ namespace ts { if (cached) { return cached; } - if (!contains(antecedentTypes, type)) { - antecedentTypes.push(type); - } + pushIfUnique(antecedentTypes, type); // If an antecedent type is not a subset of the declared type, we need to perform // subtype reduction. This happens when a "foreign" type is injected into the control // flow using the instanceof operator or a user defined type predicate. @@ -16826,9 +16795,7 @@ namespace ts { ? Diagnostics.Type_of_iterated_elements_of_a_yield_Asterisk_operand_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member : Diagnostics.Type_of_yield_operand_in_an_async_generator_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member); } - if (!contains(aggregatedTypes, type)) { - aggregatedTypes.push(type); - } + pushIfUnique(aggregatedTypes, type); } }); @@ -16880,9 +16847,7 @@ namespace ts { if (type.flags & TypeFlags.Never) { hasReturnOfTypeNever = true; } - else if (!contains(aggregatedTypes, type)) { - aggregatedTypes.push(type); - } + pushIfUnique(aggregatedTypes, type); } else { hasReturnWithNoExpression = true; @@ -16893,9 +16858,7 @@ namespace ts { return undefined; } if (strictNullChecks && aggregatedTypes.length && hasReturnWithNoExpression) { - if (!contains(aggregatedTypes, undefinedType)) { - aggregatedTypes.push(undefinedType); - } + pushIfUnique(aggregatedTypes, undefinedType); } return aggregatedTypes; } diff --git a/src/compiler/core.ts b/src/compiler/core.ts index eae2e5ee336..07824ab5d04 100644 --- a/src/compiler/core.ts +++ b/src/compiler/core.ts @@ -771,6 +771,32 @@ namespace ts { return to; } + /** + * @return Whether the value was added. + */ + export function pushIfUnique(array: T[], toAdd: T): boolean { + if (contains(array, toAdd)) { + return false; + } + else { + array.push(toAdd); + return true; + } + } + + /** + * Unlike `pushIfUnique`, this can take `undefined` as an input, and returns a new array. + */ + export function appendIfUnique(array: T[] | undefined, toAdd: T): T[] { + if (array) { + pushIfUnique(array, toAdd); + return array; + } + else { + return [toAdd]; + } + } + /** * Stable sort of an array. Elements equal to each other maintain their relative position in the array. */ diff --git a/src/compiler/factory.ts b/src/compiler/factory.ts index daec1bce1e8..1d92c0f5315 100644 --- a/src/compiler/factory.ts +++ b/src/compiler/factory.ts @@ -2636,9 +2636,7 @@ namespace ts { if (some(helpers)) { const emitNode = getOrCreateEmitNode(node); for (const helper of helpers) { - if (!contains(emitNode.helpers, helper)) { - emitNode.helpers = append(emitNode.helpers, helper); - } + emitNode.helpers = appendIfUnique(emitNode.helpers, helper); } } return node; @@ -2680,9 +2678,7 @@ namespace ts { const helper = sourceEmitHelpers[i]; if (predicate(helper)) { helpersRemoved++; - if (!contains(targetEmitNode.helpers, helper)) { - targetEmitNode.helpers = append(targetEmitNode.helpers, helper); - } + targetEmitNode.helpers = appendIfUnique(targetEmitNode.helpers, helper); } else if (helpersRemoved > 0) { sourceEmitHelpers[i - helpersRemoved] = helper; From a025192ac0d3aef3a2d422b46d1dece7a46b8df3 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Thu, 24 Aug 2017 08:56:20 -0700 Subject: [PATCH 133/370] Test:allow more jsdoc types in type parameter lists --- .../jsdocDisallowedInTypescript.errors.txt | 20 ++++++++++++++++++- .../reference/jsdocDisallowedInTypescript.js | 10 ++++++++++ .../jsdoc/jsdocDisallowedInTypescript.ts | 6 ++++++ 3 files changed, 35 insertions(+), 1 deletion(-) diff --git a/tests/baselines/reference/jsdocDisallowedInTypescript.errors.txt b/tests/baselines/reference/jsdocDisallowedInTypescript.errors.txt index 554b7af5822..d176e1aa22e 100644 --- a/tests/baselines/reference/jsdocDisallowedInTypescript.errors.txt +++ b/tests/baselines/reference/jsdocDisallowedInTypescript.errors.txt @@ -12,9 +12,13 @@ tests/cases/conformance/jsdoc/jsdocDisallowedInTypescript.ts(17,11): error TS802 tests/cases/conformance/jsdoc/jsdocDisallowedInTypescript.ts(18,17): error TS8020: JSDoc types can only be used inside documentation comments. tests/cases/conformance/jsdoc/jsdocDisallowedInTypescript.ts(19,5): error TS2322: Type 'undefined' is not assignable to type 'number | null'. tests/cases/conformance/jsdoc/jsdocDisallowedInTypescript.ts(19,17): error TS8020: JSDoc types can only be used inside documentation comments. +tests/cases/conformance/jsdoc/jsdocDisallowedInTypescript.ts(21,16): error TS8020: JSDoc types can only be used inside documentation comments. +tests/cases/conformance/jsdoc/jsdocDisallowedInTypescript.ts(22,16): error TS8020: JSDoc types can only be used inside documentation comments. +tests/cases/conformance/jsdoc/jsdocDisallowedInTypescript.ts(23,17): error TS8020: JSDoc types can only be used inside documentation comments. +tests/cases/conformance/jsdoc/jsdocDisallowedInTypescript.ts(24,17): error TS8020: JSDoc types can only be used inside documentation comments. -==== tests/cases/conformance/jsdoc/jsdocDisallowedInTypescript.ts (14 errors) ==== +==== tests/cases/conformance/jsdoc/jsdocDisallowedInTypescript.ts (18 errors) ==== // grammar error from checker var ara: Array. = [1,2,3]; ~ @@ -62,4 +66,18 @@ tests/cases/conformance/jsdoc/jsdocDisallowedInTypescript.ts(19,17): error TS802 !!! error TS2322: Type 'undefined' is not assignable to type 'number | null'. ~~~~~~~ !!! error TS8020: JSDoc types can only be used inside documentation comments. + + var nns: Array; + ~~~~~~~ +!!! error TS8020: JSDoc types can only be used inside documentation comments. + var dns: Array; + ~~~~~~~ +!!! error TS8020: JSDoc types can only be used inside documentation comments. + var anys: Array<*>; + ~ +!!! error TS8020: JSDoc types can only be used inside documentation comments. + var vars: Array<...number>; + ~~~~~~~~~ +!!! error TS8020: JSDoc types can only be used inside documentation comments. + \ No newline at end of file diff --git a/tests/baselines/reference/jsdocDisallowedInTypescript.js b/tests/baselines/reference/jsdocDisallowedInTypescript.js index 2785eca2073..1d7f6e01113 100644 --- a/tests/baselines/reference/jsdocDisallowedInTypescript.js +++ b/tests/baselines/reference/jsdocDisallowedInTypescript.js @@ -18,6 +18,12 @@ var variadic: ...boolean = [true, false, true]; var most: !string = 'definite'; var postfixdef: number! = 101; var postfixopt: number? = undefined; + +var nns: Array; +var dns: Array; +var anys: Array<*>; +var vars: Array<...number>; + //// [jsdocDisallowedInTypescript.js] @@ -40,3 +46,7 @@ var variadic = [true, false, true]; var most = 'definite'; var postfixdef = 101; var postfixopt = undefined; +var nns; +var dns; +var anys; +var vars; diff --git a/tests/cases/conformance/jsdoc/jsdocDisallowedInTypescript.ts b/tests/cases/conformance/jsdoc/jsdocDisallowedInTypescript.ts index 62ad39491d1..a8500e04bd6 100644 --- a/tests/cases/conformance/jsdoc/jsdocDisallowedInTypescript.ts +++ b/tests/cases/conformance/jsdoc/jsdocDisallowedInTypescript.ts @@ -19,3 +19,9 @@ var variadic: ...boolean = [true, false, true]; var most: !string = 'definite'; var postfixdef: number! = 101; var postfixopt: number? = undefined; + +var nns: Array; +var dns: Array; +var anys: Array<*>; +var vars: Array<...number>; + From 377ac06050e4270c19989ed5c58f808d3642a0d7 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Thu, 24 Aug 2017 08:56:36 -0700 Subject: [PATCH 134/370] Allow ! and ... as start-of-type tokens Which allows the rest of the jsdoc types to be used in type argument lists --- src/compiler/parser.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index 7486c7541be..360887f0b67 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -2722,6 +2722,8 @@ namespace ts { case SyntaxKind.ObjectKeyword: case SyntaxKind.AsteriskToken: case SyntaxKind.QuestionToken: + case SyntaxKind.ExclamationToken: + case SyntaxKind.DotDotDotToken: return true; case SyntaxKind.MinusToken: return lookAhead(nextTokenIsNumericLiteral); From e2141ad4694c3dc4d93388d5ee0d8bb0c7cbaa84 Mon Sep 17 00:00:00 2001 From: Andy Date: Thu, 24 Aug 2017 09:55:01 -0700 Subject: [PATCH 135/370] Mark some arrays as readonly (#17725) * Mark some arrays as readonly * Avoid unnecessary allocations and style changes * Fix lint --- src/compiler/comments.ts | 2 +- src/compiler/core.ts | 2 +- src/compiler/declarationEmitter.ts | 2 +- src/compiler/factory.ts | 4 +- src/compiler/program.ts | 40 +++++++++------- src/compiler/scanner.ts | 2 +- src/compiler/transformer.ts | 2 +- src/compiler/tsc.ts | 6 +-- src/compiler/types.ts | 44 ++++++++--------- src/compiler/utilities.ts | 2 +- src/harness/fourslash.ts | 7 +-- src/harness/harness.ts | 10 ++-- src/harness/projectsRunner.ts | 47 ++++++++++--------- src/harness/unittests/moduleResolution.ts | 2 +- src/harness/unittests/programMissingFiles.ts | 10 ++-- .../unittests/reuseProgramStructure.ts | 6 +-- src/server/session.ts | 2 +- src/services/findAllReferences.ts | 28 +++++------ src/services/goToDefinition.ts | 2 +- src/services/importTracker.ts | 14 +++--- src/services/navigateTo.ts | 2 +- src/services/services.ts | 15 +++--- src/services/shims.ts | 4 +- src/services/types.ts | 2 +- 24 files changed, 133 insertions(+), 124 deletions(-) diff --git a/src/compiler/comments.ts b/src/compiler/comments.ts index adf15c7e28d..025a4f36d26 100644 --- a/src/compiler/comments.ts +++ b/src/compiler/comments.ts @@ -21,7 +21,7 @@ namespace ts { let declarationListContainerEnd = -1; let currentSourceFile: SourceFile; let currentText: string; - let currentLineMap: number[]; + let currentLineMap: ReadonlyArray; let detachedCommentsInfo: { nodePos: number, detachedCommentEndPos: number}[]; let hasWrittenComment = false; let disabled: boolean = printerOptions.removeComments; diff --git a/src/compiler/core.ts b/src/compiler/core.ts index 07824ab5d04..6eb17f1fb78 100644 --- a/src/compiler/core.ts +++ b/src/compiler/core.ts @@ -715,7 +715,7 @@ namespace ts { return result; } - export function sum, K extends string>(array: T[], prop: K): number { + export function sum, K extends string>(array: ReadonlyArray, prop: K): number { let result = 0; for (const v of array) { // Note: we need the following type assertion because of GH #17069 diff --git a/src/compiler/declarationEmitter.ts b/src/compiler/declarationEmitter.ts index 47a3be6efea..3de20915029 100644 --- a/src/compiler/declarationEmitter.ts +++ b/src/compiler/declarationEmitter.ts @@ -60,7 +60,7 @@ namespace ts { let enclosingDeclaration: Node; let resultHasExternalModuleIndicator: boolean; let currentText: string; - let currentLineMap: number[]; + let currentLineMap: ReadonlyArray; let currentIdentifiers: Map; let isCurrentFileExternalModule: boolean; let reportedDeclarationError = false; diff --git a/src/compiler/factory.ts b/src/compiler/factory.ts index 1d92c0f5315..9d7f6c82a7a 100644 --- a/src/compiler/factory.ts +++ b/src/compiler/factory.ts @@ -2339,13 +2339,13 @@ namespace ts { : node; } - export function createBundle(sourceFiles: SourceFile[]) { + export function createBundle(sourceFiles: ReadonlyArray) { const node = createNode(SyntaxKind.Bundle); node.sourceFiles = sourceFiles; return node; } - export function updateBundle(node: Bundle, sourceFiles: SourceFile[]) { + export function updateBundle(node: Bundle, sourceFiles: ReadonlyArray) { if (node.sourceFiles !== sourceFiles) { return createBundle(sourceFiles); } diff --git a/src/compiler/program.ts b/src/compiler/program.ts index 305058285f9..800e2f9e619 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -205,13 +205,15 @@ namespace ts { } export function getPreEmitDiagnostics(program: Program, sourceFile?: SourceFile, cancellationToken?: CancellationToken): Diagnostic[] { - let diagnostics = program.getOptionsDiagnostics(cancellationToken).concat( - program.getSyntacticDiagnostics(sourceFile, cancellationToken), - program.getGlobalDiagnostics(cancellationToken), - program.getSemanticDiagnostics(sourceFile, cancellationToken)); + const diagnostics = [ + ...program.getOptionsDiagnostics(cancellationToken), + ...program.getSyntacticDiagnostics(sourceFile, cancellationToken), + ...program.getGlobalDiagnostics(cancellationToken), + ...program.getSemanticDiagnostics(sourceFile, cancellationToken) + ]; if (program.getCompilerOptions().declaration) { - diagnostics = diagnostics.concat(program.getDeclarationDiagnostics(sourceFile, cancellationToken)); + addRange(diagnostics, program.getDeclarationDiagnostics(sourceFile, cancellationToken)); } return sortAndDeduplicateDiagnostics(diagnostics); @@ -223,7 +225,7 @@ namespace ts { getNewLine(): string; } - export function formatDiagnostics(diagnostics: Diagnostic[], host: FormatDiagnosticsHost): string { + export function formatDiagnostics(diagnostics: ReadonlyArray, host: FormatDiagnosticsHost): string { let output = ""; for (const diagnostic of diagnostics) { @@ -399,7 +401,7 @@ namespace ts { * @param oldProgram - Reuses an old program structure. * @returns A 'Program' object. */ - export function createProgram(rootNames: string[], options: CompilerOptions, host?: CompilerHost, oldProgram?: Program): Program { + export function createProgram(rootNames: ReadonlyArray, options: CompilerOptions, host?: CompilerHost, oldProgram?: Program): Program { let program: Program; let files: SourceFile[] = []; let commonSourceDirectory: string; @@ -996,7 +998,7 @@ namespace ts { } function emitWorker(program: Program, sourceFile: SourceFile, writeFileCallback: WriteFileCallback, cancellationToken: CancellationToken, emitOnlyDtsFiles?: boolean, customTransformers?: CustomTransformers): EmitResult { - let declarationDiagnostics: Diagnostic[] = []; + let declarationDiagnostics: ReadonlyArray = []; if (options.noEmit) { return { diagnostics: declarationDiagnostics, sourceMaps: undefined, emittedFiles: undefined, emitSkipped: true }; @@ -1006,10 +1008,12 @@ namespace ts { // immediately bail out. Note that we pass 'undefined' for 'sourceFile' so that we // get any preEmit diagnostics, not just the ones if (options.noEmitOnError) { - const diagnostics = program.getOptionsDiagnostics(cancellationToken).concat( - program.getSyntacticDiagnostics(sourceFile, cancellationToken), - program.getGlobalDiagnostics(cancellationToken), - program.getSemanticDiagnostics(sourceFile, cancellationToken)); + const diagnostics = [ + ...program.getOptionsDiagnostics(cancellationToken), + ...program.getSyntacticDiagnostics(sourceFile, cancellationToken), + ...program.getGlobalDiagnostics(cancellationToken), + ...program.getSemanticDiagnostics(sourceFile, cancellationToken) + ]; if (diagnostics.length === 0 && program.getCompilerOptions().declaration) { declarationDiagnostics = program.getDeclarationDiagnostics(/*sourceFile*/ undefined, cancellationToken); @@ -1060,8 +1064,8 @@ namespace ts { function getDiagnosticsHelper( sourceFile: SourceFile, - getDiagnostics: (sourceFile: SourceFile, cancellationToken: CancellationToken) => Diagnostic[], - cancellationToken: CancellationToken): Diagnostic[] { + getDiagnostics: (sourceFile: SourceFile, cancellationToken: CancellationToken) => ReadonlyArray, + cancellationToken: CancellationToken): ReadonlyArray { if (sourceFile) { return getDiagnostics(sourceFile, cancellationToken); } @@ -1073,15 +1077,15 @@ namespace ts { })); } - function getSyntacticDiagnostics(sourceFile: SourceFile, cancellationToken: CancellationToken): Diagnostic[] { + function getSyntacticDiagnostics(sourceFile: SourceFile, cancellationToken: CancellationToken): ReadonlyArray { return getDiagnosticsHelper(sourceFile, getSyntacticDiagnosticsForFile, cancellationToken); } - function getSemanticDiagnostics(sourceFile: SourceFile, cancellationToken: CancellationToken): Diagnostic[] { + function getSemanticDiagnostics(sourceFile: SourceFile, cancellationToken: CancellationToken): ReadonlyArray { return getDiagnosticsHelper(sourceFile, getSemanticDiagnosticsForFile, cancellationToken); } - function getDeclarationDiagnostics(sourceFile: SourceFile, cancellationToken: CancellationToken): Diagnostic[] { + function getDeclarationDiagnostics(sourceFile: SourceFile, cancellationToken: CancellationToken): ReadonlyArray { const options = program.getCompilerOptions(); // collect diagnostics from the program only once if either no source file was specified or out/outFile is set (bundled emit) if (!sourceFile || options.out || options.outFile) { @@ -1092,7 +1096,7 @@ namespace ts { } } - function getSyntacticDiagnosticsForFile(sourceFile: SourceFile): Diagnostic[] { + function getSyntacticDiagnosticsForFile(sourceFile: SourceFile): ReadonlyArray { // For JavaScript files, we report semantic errors for using TypeScript-only // constructs from within a JavaScript file as syntactic errors. if (isSourceFileJavaScript(sourceFile)) { diff --git a/src/compiler/scanner.ts b/src/compiler/scanner.ts index 09defaaf773..a130d8427da 100644 --- a/src/compiler/scanner.ts +++ b/src/compiler/scanner.ts @@ -343,7 +343,7 @@ namespace ts { } /* @internal */ - export function getLineStarts(sourceFile: SourceFileLike): number[] { + export function getLineStarts(sourceFile: SourceFileLike): ReadonlyArray { return sourceFile.lineMap || (sourceFile.lineMap = computeLineStarts(sourceFile.text)); } diff --git a/src/compiler/transformer.ts b/src/compiler/transformer.ts index d61195ad74b..341c0c9cd45 100644 --- a/src/compiler/transformer.ts +++ b/src/compiler/transformer.ts @@ -92,7 +92,7 @@ namespace ts { * @param transforms An array of `TransformerFactory` callbacks. * @param allowDtsFiles A value indicating whether to allow the transformation of .d.ts files. */ - export function transformNodes(resolver: EmitResolver, host: EmitHost, options: CompilerOptions, nodes: T[], transformers: TransformerFactory[], allowDtsFiles: boolean): TransformationResult { + export function transformNodes(resolver: EmitResolver, host: EmitHost, options: CompilerOptions, nodes: ReadonlyArray, transformers: ReadonlyArray>, allowDtsFiles: boolean): TransformationResult { const enabledSyntaxKindFeatures = new Array(SyntaxKind.Count); let lexicalEnvironmentVariableDeclarations: VariableDeclaration[]; let lexicalEnvironmentFunctionDeclarations: FunctionDeclaration[]; diff --git a/src/compiler/tsc.ts b/src/compiler/tsc.ts index db25afe45b6..d5e584c7ac5 100644 --- a/src/compiler/tsc.ts +++ b/src/compiler/tsc.ts @@ -469,7 +469,7 @@ namespace ts { let diagnostics: Diagnostic[]; // First get and report any syntactic errors. - diagnostics = program.getSyntacticDiagnostics(); + diagnostics = program.getSyntacticDiagnostics().slice(); // If we didn't have any syntactic errors, then also try getting the global and // semantic errors. @@ -477,13 +477,13 @@ namespace ts { diagnostics = program.getOptionsDiagnostics().concat(program.getGlobalDiagnostics()); if (diagnostics.length === 0) { - diagnostics = program.getSemanticDiagnostics(); + diagnostics = program.getSemanticDiagnostics().slice(); } } // Otherwise, emit and report any errors we ran into. const emitOutput = program.emit(); - diagnostics = diagnostics.concat(emitOutput.diagnostics); + addRange(diagnostics, emitOutput.diagnostics); reportDiagnostics(sortAndDeduplicateDiagnostics(diagnostics), compilerHost); diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 8fe602ea6f9..fe18839b904 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -2254,7 +2254,7 @@ namespace ts { */ export interface SourceFileLike { readonly text: string; - lineMap: number[]; + lineMap: ReadonlyArray; } @@ -2286,16 +2286,16 @@ namespace ts { */ /* @internal */ redirectInfo?: RedirectInfo | undefined; - amdDependencies: AmdDependency[]; + amdDependencies: ReadonlyArray; moduleName: string; - referencedFiles: FileReference[]; - typeReferenceDirectives: FileReference[]; + referencedFiles: ReadonlyArray; + typeReferenceDirectives: ReadonlyArray; languageVariant: LanguageVariant; isDeclarationFile: boolean; // this map is used by transpiler to supply alternative names for dependencies (i.e. in case of bundling) /* @internal */ - renamedDependencies?: Map; + renamedDependencies?: ReadonlyMap; /** * lib.d.ts should have a reference comment like @@ -2331,12 +2331,12 @@ namespace ts { /* @internal */ jsDocDiagnostics?: Diagnostic[]; // Stores additional file-level diagnostics reported by the program - /* @internal */ additionalSyntacticDiagnostics?: Diagnostic[]; + /* @internal */ additionalSyntacticDiagnostics?: ReadonlyArray; // Stores a line map for the file. // This field should never be used directly to obtain line map, use getLineMap function instead. - /* @internal */ lineMap: number[]; - /* @internal */ classifiableNames?: UnderscoreEscapedMap; + /* @internal */ lineMap: ReadonlyArray; + /* @internal */ classifiableNames?: ReadonlyUnderscoreEscapedMap; // Stores a mapping 'external module reference text' -> 'resolved file name' | undefined // It is used to resolve module names in the checker. // Content of this field should never be used directly - use getResolvedModuleFileName/setResolvedModuleFileName functions instead @@ -2351,7 +2351,7 @@ namespace ts { export interface Bundle extends Node { kind: SyntaxKind.Bundle; - sourceFiles: SourceFile[]; + sourceFiles: ReadonlyArray; } export interface JsonSourceFile extends SourceFile { @@ -2398,19 +2398,19 @@ namespace ts { /** * Get a list of root file names that were passed to a 'createProgram' */ - getRootFileNames(): string[]; + getRootFileNames(): ReadonlyArray; /** * Get a list of files in the program */ - getSourceFiles(): SourceFile[]; + getSourceFiles(): ReadonlyArray; /** * Get a list of file names that were passed to 'createProgram' or referenced in a * program source file but could not be located. */ /* @internal */ - getMissingFilePaths(): Path[]; + getMissingFilePaths(): ReadonlyArray; /** * Emits the JavaScript and declaration files. If targetSourceFile is not specified, then @@ -2424,11 +2424,11 @@ namespace ts { */ emit(targetSourceFile?: SourceFile, writeFile?: WriteFileCallback, cancellationToken?: CancellationToken, emitOnlyDtsFiles?: boolean, customTransformers?: CustomTransformers): EmitResult; - getOptionsDiagnostics(cancellationToken?: CancellationToken): Diagnostic[]; - getGlobalDiagnostics(cancellationToken?: CancellationToken): Diagnostic[]; - getSyntacticDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): Diagnostic[]; - getSemanticDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): Diagnostic[]; - getDeclarationDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): Diagnostic[]; + getOptionsDiagnostics(cancellationToken?: CancellationToken): ReadonlyArray; + getGlobalDiagnostics(cancellationToken?: CancellationToken): ReadonlyArray; + getSyntacticDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): ReadonlyArray; + getSemanticDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): ReadonlyArray; + getDeclarationDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): ReadonlyArray; /** * Gets a type checker that can be used to semantically analyze source files in the program. @@ -2522,7 +2522,7 @@ namespace ts { export interface EmitResult { emitSkipped: boolean; /** Contains declaration emit diagnostics */ - diagnostics: Diagnostic[]; + diagnostics: ReadonlyArray; emittedFiles: string[]; // Array of files the compiler wrote to disk /* @internal */ sourceMaps: SourceMapData[]; // Array of sourceMapData if compiler emitted sourcemaps } @@ -2531,9 +2531,9 @@ namespace ts { export interface TypeCheckerHost { getCompilerOptions(): CompilerOptions; - getSourceFiles(): SourceFile[]; + getSourceFiles(): ReadonlyArray; getSourceFile(fileName: string): SourceFile; - getResolvedTypeReferenceDirectives(): Map; + getResolvedTypeReferenceDirectives(): ReadonlyMap; } export interface TypeChecker { @@ -4137,7 +4137,7 @@ namespace ts { export interface SourceMapSource { fileName: string; text: string; - /* @internal */ lineMap: number[]; + /* @internal */ lineMap: ReadonlyArray; skipTrivia?: (pos: number) => number; } @@ -4244,7 +4244,7 @@ namespace ts { /* @internal */ export interface EmitHost extends ScriptReferenceHost { - getSourceFiles(): SourceFile[]; + getSourceFiles(): ReadonlyArray; /* @internal */ isSourceFileFromExternalLibrary(file: SourceFile): boolean; diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index f1a8dfd676b..d906ab4f6b1 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -2572,7 +2572,7 @@ namespace ts { * @param host An EmitHost. * @param targetSourceFile An optional target source file to emit. */ - export function getSourceFilesToEmit(host: EmitHost, targetSourceFile?: SourceFile): SourceFile[] { + export function getSourceFilesToEmit(host: EmitHost, targetSourceFile?: SourceFile): ReadonlyArray { const options = host.getCompilerOptions(); const isSourceFileFromExternalLibrary = (file: SourceFile) => host.isSourceFileFromExternalLibrary(file); if (options.outFile || options.out) { diff --git a/src/harness/fourslash.ts b/src/harness/fourslash.ts index 32c9fb67da0..ab33fa87997 100644 --- a/src/harness/fourslash.ts +++ b/src/harness/fourslash.ts @@ -490,7 +490,8 @@ namespace FourSlash { } private getDiagnostics(fileName: string): ts.Diagnostic[] { - return this.languageService.getSyntacticDiagnostics(fileName).concat(this.languageService.getSemanticDiagnostics(fileName)); + return ts.concatenate(this.languageService.getSyntacticDiagnostics(fileName), + this.languageService.getSemanticDiagnostics(fileName)); } private getAllDiagnostics(): ts.Diagnostic[] { @@ -1148,7 +1149,7 @@ namespace FourSlash { this.testDiagnostics(expected, diagnostics); } - private testDiagnostics(expected: string, diagnostics: ts.Diagnostic[]) { + private testDiagnostics(expected: string, diagnostics: ReadonlyArray) { const realized = ts.realizeDiagnostics(diagnostics, "\r\n"); const actual = stringify(realized); assert.equal(actual, expected); @@ -1585,7 +1586,7 @@ namespace FourSlash { public printErrorList() { const syntacticErrors = this.languageService.getSyntacticDiagnostics(this.activeFile.fileName); const semanticErrors = this.languageService.getSemanticDiagnostics(this.activeFile.fileName); - const errorList = syntacticErrors.concat(semanticErrors); + const errorList = ts.concatenate(syntacticErrors, semanticErrors); Harness.IO.log(`Error list (${errorList.length} errors)`); if (errorList.length) { diff --git a/src/harness/harness.ts b/src/harness/harness.ts index bf5cde2bc48..9443844cf9a 100644 --- a/src/harness/harness.ts +++ b/src/harness/harness.ts @@ -207,7 +207,7 @@ namespace Utils { return a !== undefined && typeof a.pos === "number"; } - export function convertDiagnostics(diagnostics: ts.Diagnostic[]) { + export function convertDiagnostics(diagnostics: ReadonlyArray) { return diagnostics.map(convertDiagnostic); } @@ -337,7 +337,7 @@ namespace Utils { } } - export function assertDiagnosticsEquals(array1: ts.Diagnostic[], array2: ts.Diagnostic[]) { + export function assertDiagnosticsEquals(array1: ReadonlyArray, array2: ReadonlyArray) { if (array1 === array2) { return; } @@ -1284,12 +1284,12 @@ namespace Harness { return normalized; } - export function minimalDiagnosticsToString(diagnostics: ts.Diagnostic[]) { + export function minimalDiagnosticsToString(diagnostics: ReadonlyArray) { return ts.formatDiagnostics(diagnostics, { getCanonicalFileName, getCurrentDirectory: () => "", getNewLine: () => Harness.IO.newLine() }); } - export function getErrorBaseline(inputFiles: TestFile[], diagnostics: ts.Diagnostic[]) { - diagnostics.sort(ts.compareDiagnostics); + export function getErrorBaseline(inputFiles: ReadonlyArray, diagnostics: ReadonlyArray) { + diagnostics = diagnostics.slice().sort(ts.compareDiagnostics); let outputLines = ""; // Count up all errors that were found in files other than lib.d.ts so we don't miss any let totalErrorsReportedInNonLibraryFiles = 0; diff --git a/src/harness/projectsRunner.ts b/src/harness/projectsRunner.ts index 752767d9706..6c13261d757 100644 --- a/src/harness/projectsRunner.ts +++ b/src/harness/projectsRunner.ts @@ -5,7 +5,7 @@ interface ProjectRunnerTestCase { scenario: string; projectRoot: string; // project where it lives - this also is the current directory when compiling - inputFiles: string[]; // list of input files to be given to program + inputFiles: ReadonlyArray; // list of input files to be given to program resolveMapRoot?: boolean; // should we resolve this map root and give compiler the absolute disk path as map root? resolveSourceRoot?: boolean; // should we resolve this source root and give compiler the absolute disk path as map root? baselineCheck?: boolean; // Verify the baselines of output files, if this is false, we will write to output to the disk but there is no verification of baselines @@ -15,8 +15,8 @@ interface ProjectRunnerTestCase { interface ProjectRunnerTestCaseResolutionInfo extends ProjectRunnerTestCase { // Apart from actual test case the results of the resolution - resolvedInputFiles: string[]; // List of files that were asked to read by compiler - emittedFiles: string[]; // List of files that were emitted by the compiler + resolvedInputFiles: ReadonlyArray; // List of files that were asked to read by compiler + emittedFiles: ReadonlyArray; // List of files that were emitted by the compiler } interface BatchCompileProjectTestCaseEmittedFile extends Harness.Compiler.GeneratedFile { @@ -24,12 +24,12 @@ interface BatchCompileProjectTestCaseEmittedFile extends Harness.Compiler.Genera } interface CompileProjectFilesResult { - configFileSourceFiles: ts.SourceFile[]; + configFileSourceFiles: ReadonlyArray; moduleKind: ts.ModuleKind; program?: ts.Program; compilerOptions?: ts.CompilerOptions; - errors: ts.Diagnostic[]; - sourceMapData?: ts.SourceMapData[]; + errors: ReadonlyArray; + sourceMapData?: ReadonlyArray; } interface BatchCompileProjectTestCaseResult extends CompileProjectFilesResult { @@ -125,17 +125,17 @@ class ProjectRunner extends RunnerBase { return Harness.IO.resolvePath(testCase.projectRoot); } - function compileProjectFiles(moduleKind: ts.ModuleKind, configFileSourceFiles: ts.SourceFile[], - getInputFiles: () => string[], + function compileProjectFiles(moduleKind: ts.ModuleKind, configFileSourceFiles: ReadonlyArray, + getInputFiles: () => ReadonlyArray, getSourceFileTextImpl: (fileName: string) => string, writeFile: (fileName: string, data: string, writeByteOrderMark: boolean) => void, compilerOptions: ts.CompilerOptions): CompileProjectFilesResult { const program = ts.createProgram(getInputFiles(), compilerOptions, createCompilerHost()); - let errors = ts.getPreEmitDiagnostics(program); + const errors = ts.getPreEmitDiagnostics(program); const emitResult = program.emit(); - errors = ts.concatenate(errors, emitResult.diagnostics); + ts.addRange(errors, emitResult.diagnostics); const sourceMapData = emitResult.sourceMaps; // Clean up source map data that will be used in baselining @@ -235,7 +235,7 @@ class ProjectRunner extends RunnerBase { compilerOptions, sourceMapData: projectCompilerResult.sourceMapData, outputFiles, - errors: errors ? errors.concat(projectCompilerResult.errors) : projectCompilerResult.errors, + errors: errors ? ts.concatenate(errors, projectCompilerResult.errors) : projectCompilerResult.errors, }; function createCompilerOptions() { @@ -422,16 +422,21 @@ class ProjectRunner extends RunnerBase { } function getErrorsBaseline(compilerResult: CompileProjectFilesResult) { - const inputFiles = ts.map(compilerResult.configFileSourceFiles.concat( - compilerResult.program ? - ts.filter(compilerResult.program.getSourceFiles(), sourceFile => !Harness.isDefaultLibraryFile(sourceFile.fileName)) : - []), - (sourceFile): Harness.Compiler.TestFile => ({ - unitName: ts.isRootedDiskPath(sourceFile.fileName) ? - RunnerBase.removeFullPaths(sourceFile.fileName) : - sourceFile.fileName, - content: sourceFile.text - })); + const inputSourceFiles = compilerResult.configFileSourceFiles.slice(); + if (compilerResult.program) { + for (const sourceFile of compilerResult.program.getSourceFiles()) { + if (!Harness.isDefaultLibraryFile(sourceFile.fileName)) { + inputSourceFiles.push(sourceFile); + } + } + } + + const inputFiles = inputSourceFiles.map(sourceFile => ({ + unitName: ts.isRootedDiskPath(sourceFile.fileName) ? + RunnerBase.removeFullPaths(sourceFile.fileName) : + sourceFile.fileName, + content: sourceFile.text + })); return Harness.Compiler.getErrorBaseline(inputFiles, compilerResult.errors); } diff --git a/src/harness/unittests/moduleResolution.ts b/src/harness/unittests/moduleResolution.ts index 79aafb4986d..ed8dcf0c7b4 100644 --- a/src/harness/unittests/moduleResolution.ts +++ b/src/harness/unittests/moduleResolution.ts @@ -425,7 +425,7 @@ export = C; readFile: notImplemented }; const program = createProgram(rootFiles, options, host); - const diagnostics = sortAndDeduplicateDiagnostics(program.getSemanticDiagnostics().concat(program.getOptionsDiagnostics())); + const diagnostics = sortAndDeduplicateDiagnostics([...program.getSemanticDiagnostics(), ...program.getOptionsDiagnostics()]); assert.equal(diagnostics.length, diagnosticCodes.length, `Incorrect number of expected diagnostics, expected ${diagnosticCodes.length}, got '${Harness.Compiler.minimalDiagnosticsToString(diagnostics)}'`); for (let i = 0; i < diagnosticCodes.length; i++) { assert.equal(diagnostics[i].code, diagnosticCodes[i], `Expected diagnostic code ${diagnosticCodes[i]}, got '${diagnostics[i].code}': '${diagnostics[i].messageText}'`); diff --git a/src/harness/unittests/programMissingFiles.ts b/src/harness/unittests/programMissingFiles.ts index 668b684a250..ea644599de1 100644 --- a/src/harness/unittests/programMissingFiles.ts +++ b/src/harness/unittests/programMissingFiles.ts @@ -48,18 +48,18 @@ namespace ts { const program = createProgram(["./nonexistent.ts"], options, testCompilerHost); const missing = program.getMissingFilePaths(); assert.isDefined(missing); - assert.deepEqual(missing, ["d:/pretend/nonexistent.ts"]); // Absolute path + assert.deepEqual(missing, ["d:/pretend/nonexistent.ts" as Path]); // Absolute path }); it("handles multiple missing root files", () => { const program = createProgram(["./nonexistent0.ts", "./nonexistent1.ts"], options, testCompilerHost); - const missing = program.getMissingFilePaths().sort(); + const missing = program.getMissingFilePaths().slice().sort(); assert.deepEqual(missing, ["d:/pretend/nonexistent0.ts", "d:/pretend/nonexistent1.ts"]); }); it("handles a mix of present and missing root files", () => { const program = createProgram(["./nonexistent0.ts", emptyFileRelativePath, "./nonexistent1.ts"], options, testCompilerHost); - const missing = program.getMissingFilePaths().sort(); + const missing = program.getMissingFilePaths().slice().sort(); assert.deepEqual(missing, ["d:/pretend/nonexistent0.ts", "d:/pretend/nonexistent1.ts"]); }); @@ -67,7 +67,7 @@ namespace ts { const program = createProgram(["./nonexistent.ts", "./nonexistent.ts"], options, testCompilerHost); const missing = program.getMissingFilePaths(); assert.isDefined(missing); - assert.deepEqual(missing, ["d:/pretend/nonexistent.ts"]); + assert.deepEqual(missing, ["d:/pretend/nonexistent.ts" as Path]); }); it("normalizes file paths", () => { @@ -81,7 +81,7 @@ namespace ts { it("handles missing triple slash references", () => { const program = createProgram([referenceFileRelativePath], options, testCompilerHost); - const missing = program.getMissingFilePaths().sort(); + const missing = program.getMissingFilePaths().slice().sort(); assert.isDefined(missing); assert.deepEqual(missing, [ // From absolute reference diff --git a/src/harness/unittests/reuseProgramStructure.ts b/src/harness/unittests/reuseProgramStructure.ts index 5062f4c4b39..0c2a4a7052b 100644 --- a/src/harness/unittests/reuseProgramStructure.ts +++ b/src/harness/unittests/reuseProgramStructure.ts @@ -21,7 +21,7 @@ namespace ts { } interface ProgramWithSourceTexts extends Program { - sourceTexts?: NamedSourceText[]; + sourceTexts?: ReadonlyArray; host: TestCompilerHost; } @@ -106,7 +106,7 @@ namespace ts { return file; } - function createTestCompilerHost(texts: NamedSourceText[], target: ScriptTarget, oldProgram?: ProgramWithSourceTexts): TestCompilerHost { + function createTestCompilerHost(texts: ReadonlyArray, target: ScriptTarget, oldProgram?: ProgramWithSourceTexts): TestCompilerHost { const files = arrayToMap(texts, t => t.name, t => { if (oldProgram) { let oldFile = oldProgram.getSourceFile(t.name); @@ -162,7 +162,7 @@ namespace ts { return program; } - function updateProgram(oldProgram: ProgramWithSourceTexts, rootNames: string[], options: CompilerOptions, updater: (files: NamedSourceText[]) => void, newTexts?: NamedSourceText[]) { + function updateProgram(oldProgram: ProgramWithSourceTexts, rootNames: ReadonlyArray, options: CompilerOptions, updater: (files: NamedSourceText[]) => void, newTexts?: NamedSourceText[]) { if (!newTexts) { newTexts = (oldProgram).sourceTexts.slice(0); } diff --git a/src/server/session.ts b/src/server/session.ts index c5b69576811..0b3038a408d 100644 --- a/src/server/session.ts +++ b/src/server/session.ts @@ -425,7 +425,7 @@ namespace ts.server { private semanticCheck(file: NormalizedPath, project: Project) { try { - let diags: Diagnostic[] = []; + let diags: ReadonlyArray = emptyArray; if (!isDeclarationFileInJSOnlyNonConfiguredProject(project, file)) { diags = project.getLanguageService().getSemanticDiagnostics(file); } diff --git a/src/services/findAllReferences.ts b/src/services/findAllReferences.ts index ad26dae2115..4c8563b1b94 100644 --- a/src/services/findAllReferences.ts +++ b/src/services/findAllReferences.ts @@ -41,7 +41,7 @@ namespace ts.FindAllReferences { readonly implementations?: boolean; } - export function findReferencedSymbols(program: Program, cancellationToken: CancellationToken, sourceFiles: SourceFile[], sourceFile: SourceFile, position: number): ReferencedSymbol[] | undefined { + export function findReferencedSymbols(program: Program, cancellationToken: CancellationToken, sourceFiles: ReadonlyArray, sourceFile: SourceFile, position: number): ReferencedSymbol[] | undefined { const referencedSymbols = findAllReferencedSymbols(program, cancellationToken, sourceFiles, sourceFile, position); if (!referencedSymbols || !referencedSymbols.length) { @@ -60,7 +60,7 @@ namespace ts.FindAllReferences { return out; } - export function getImplementationsAtPosition(program: Program, cancellationToken: CancellationToken, sourceFiles: SourceFile[], sourceFile: SourceFile, position: number): ImplementationLocation[] { + export function getImplementationsAtPosition(program: Program, cancellationToken: CancellationToken, sourceFiles: ReadonlyArray, sourceFile: SourceFile, position: number): ImplementationLocation[] { // A node in a JSDoc comment can't have an implementation anyway. const node = getTouchingPropertyName(sourceFile, position, /*includeJsDocComment*/ false); const referenceEntries = getImplementationReferenceEntries(program, cancellationToken, sourceFiles, node); @@ -68,7 +68,7 @@ namespace ts.FindAllReferences { return map(referenceEntries, entry => toImplementationLocation(entry, checker)); } - function getImplementationReferenceEntries(program: Program, cancellationToken: CancellationToken, sourceFiles: SourceFile[], node: Node): Entry[] | undefined { + function getImplementationReferenceEntries(program: Program, cancellationToken: CancellationToken, sourceFiles: ReadonlyArray, node: Node): Entry[] | undefined { if (node.kind === SyntaxKind.SourceFile) { return undefined; } @@ -93,16 +93,16 @@ namespace ts.FindAllReferences { } } - export function findReferencedEntries(program: Program, cancellationToken: CancellationToken, sourceFiles: SourceFile[], sourceFile: SourceFile, position: number, options?: Options): ReferenceEntry[] | undefined { + export function findReferencedEntries(program: Program, cancellationToken: CancellationToken, sourceFiles: ReadonlyArray, sourceFile: SourceFile, position: number, options?: Options): ReferenceEntry[] | undefined { const x = flattenEntries(findAllReferencedSymbols(program, cancellationToken, sourceFiles, sourceFile, position, options)); return map(x, toReferenceEntry); } - export function getReferenceEntriesForNode(node: Node, program: Program, sourceFiles: SourceFile[], cancellationToken: CancellationToken, options: Options = {}): Entry[] | undefined { + export function getReferenceEntriesForNode(node: Node, program: Program, sourceFiles: ReadonlyArray, cancellationToken: CancellationToken, options: Options = {}): Entry[] | undefined { return flattenEntries(Core.getReferencedSymbolsForNode(node, program, sourceFiles, cancellationToken, options)); } - function findAllReferencedSymbols(program: Program, cancellationToken: CancellationToken, sourceFiles: SourceFile[], sourceFile: SourceFile, position: number, options?: Options): SymbolAndEntries[] | undefined { + function findAllReferencedSymbols(program: Program, cancellationToken: CancellationToken, sourceFiles: ReadonlyArray, sourceFile: SourceFile, position: number, options?: Options): SymbolAndEntries[] | undefined { const node = getTouchingPropertyName(sourceFile, position, /*includeJsDocComment*/ true); return Core.getReferencedSymbolsForNode(node, program, sourceFiles, cancellationToken, options); } @@ -264,7 +264,7 @@ namespace ts.FindAllReferences { /* @internal */ namespace ts.FindAllReferences.Core { /** Core find-all-references algorithm. Handles special cases before delegating to `getReferencedSymbolsForSymbol`. */ - export function getReferencedSymbolsForNode(node: Node, program: Program, sourceFiles: SourceFile[], cancellationToken: CancellationToken, options: Options = {}): SymbolAndEntries[] | undefined { + export function getReferencedSymbolsForNode(node: Node, program: Program, sourceFiles: ReadonlyArray, cancellationToken: CancellationToken, options: Options = {}): SymbolAndEntries[] | undefined { if (node.kind === ts.SyntaxKind.SourceFile) { return undefined; } @@ -313,7 +313,7 @@ namespace ts.FindAllReferences.Core { } } - function getReferencedSymbolsForModule(program: Program, symbol: Symbol, sourceFiles: SourceFile[]): SymbolAndEntries[] { + function getReferencedSymbolsForModule(program: Program, symbol: Symbol, sourceFiles: ReadonlyArray): SymbolAndEntries[] { Debug.assert(!!symbol.valueDeclaration); const references = findModuleReferences(program, sourceFiles, symbol).map(reference => { @@ -349,7 +349,7 @@ namespace ts.FindAllReferences.Core { } /** getReferencedSymbols for special node kinds. */ - function getReferencedSymbolsSpecial(node: Node, sourceFiles: SourceFile[], cancellationToken: CancellationToken): SymbolAndEntries[] | undefined { + function getReferencedSymbolsSpecial(node: Node, sourceFiles: ReadonlyArray, cancellationToken: CancellationToken): SymbolAndEntries[] | undefined { if (isTypeKeyword(node.kind)) { return getAllReferencesForKeyword(sourceFiles, node.kind, cancellationToken); } @@ -380,7 +380,7 @@ namespace ts.FindAllReferences.Core { } /** Core find-all-references algorithm for a normal symbol. */ - function getReferencedSymbolsForSymbol(symbol: Symbol, node: Node, sourceFiles: SourceFile[], checker: TypeChecker, cancellationToken: CancellationToken, options: Options): SymbolAndEntries[] { + function getReferencedSymbolsForSymbol(symbol: Symbol, node: Node, sourceFiles: ReadonlyArray, checker: TypeChecker, cancellationToken: CancellationToken, options: Options): SymbolAndEntries[] { symbol = skipPastExportOrImportSpecifier(symbol, node, checker); // Compute the meaning from the location and the symbol it references @@ -474,7 +474,7 @@ namespace ts.FindAllReferences.Core { readonly markSeenReExportRHS = nodeSeenTracker(); constructor( - readonly sourceFiles: SourceFile[], + readonly sourceFiles: ReadonlyArray, /** True if we're searching for constructor references. */ readonly isForConstructor: boolean, readonly checker: TypeChecker, @@ -759,7 +759,7 @@ namespace ts.FindAllReferences.Core { } } - function getAllReferencesForKeyword(sourceFiles: SourceFile[], keywordKind: ts.SyntaxKind, cancellationToken: CancellationToken): SymbolAndEntries[] { + function getAllReferencesForKeyword(sourceFiles: ReadonlyArray, keywordKind: ts.SyntaxKind, cancellationToken: CancellationToken): SymbolAndEntries[] { const references: NodeEntry[] = []; for (const sourceFile of sourceFiles) { cancellationToken.throwIfCancellationRequested(); @@ -1259,7 +1259,7 @@ namespace ts.FindAllReferences.Core { return [{ definition: { type: "symbol", symbol: searchSpaceNode.symbol, node: superKeyword }, references }]; } - function getReferencesForThisKeyword(thisOrSuperKeyword: Node, sourceFiles: SourceFile[], cancellationToken: CancellationToken): SymbolAndEntries[] { + function getReferencesForThisKeyword(thisOrSuperKeyword: Node, sourceFiles: ReadonlyArray, cancellationToken: CancellationToken): SymbolAndEntries[] { let searchSpaceNode = getThisContainer(thisOrSuperKeyword, /* includeArrowFunctions */ false); // Whether 'this' occurs in a static context within a class. @@ -1355,7 +1355,7 @@ namespace ts.FindAllReferences.Core { } } - function getReferencesForStringLiteral(node: StringLiteral, sourceFiles: SourceFile[], cancellationToken: CancellationToken): SymbolAndEntries[] { + function getReferencesForStringLiteral(node: StringLiteral, sourceFiles: ReadonlyArray, cancellationToken: CancellationToken): SymbolAndEntries[] { const references: NodeEntry[] = []; for (const sourceFile of sourceFiles) { diff --git a/src/services/goToDefinition.ts b/src/services/goToDefinition.ts index f60349e4ea5..cb2be7d484c 100644 --- a/src/services/goToDefinition.ts +++ b/src/services/goToDefinition.ts @@ -279,7 +279,7 @@ namespace ts.GoToDefinition { return createDefinitionInfo(decl, symbolKind, symbolName, containerName); } - function findReferenceInPosition(refs: FileReference[], pos: number): FileReference { + function findReferenceInPosition(refs: ReadonlyArray, pos: number): FileReference { for (const ref of refs) { if (ref.pos <= pos && pos <= ref.end) { return ref; diff --git a/src/services/importTracker.ts b/src/services/importTracker.ts index 1bbf175c7fe..d4301db2f83 100644 --- a/src/services/importTracker.ts +++ b/src/services/importTracker.ts @@ -7,12 +7,12 @@ namespace ts.FindAllReferences { /** For rename imports/exports `{ foo as bar }`, `foo` is not a local, so it may be added as a reference immediately without further searching. */ singleReferences: Identifier[]; /** List of source files that may (or may not) use the symbol via a namespace. (For UMD modules this is every file.) */ - indirectUsers: SourceFile[]; + indirectUsers: ReadonlyArray; } export type ImportTracker = (exportSymbol: Symbol, exportInfo: ExportInfo, isForRename: boolean) => ImportsResult; /** Creates the imports map and returns an ImportTracker that uses it. Call this lazily to avoid calling `getDirectImportsMap` unnecessarily. */ - export function createImportTracker(sourceFiles: SourceFile[], checker: TypeChecker, cancellationToken: CancellationToken): ImportTracker { + export function createImportTracker(sourceFiles: ReadonlyArray, checker: TypeChecker, cancellationToken: CancellationToken): ImportTracker { const allDirectImports = getDirectImportsMap(sourceFiles, checker, cancellationToken); return (exportSymbol, exportInfo, isForRename) => { const { directImports, indirectUsers } = getImportersForExport(sourceFiles, allDirectImports, exportInfo, checker, cancellationToken); @@ -38,12 +38,12 @@ namespace ts.FindAllReferences { /** Returns import statements that directly reference the exporting module, and a list of files that may access the module through a namespace. */ function getImportersForExport( - sourceFiles: SourceFile[], + sourceFiles: ReadonlyArray, allDirectImports: Map, { exportingModuleSymbol, exportKind }: ExportInfo, checker: TypeChecker, cancellationToken: CancellationToken - ): { directImports: Importer[], indirectUsers: SourceFile[] } { + ): { directImports: Importer[], indirectUsers: ReadonlyArray } { const markSeenDirectImport = nodeSeenTracker(); const markSeenIndirectUser = nodeSeenTracker(); const directImports: Importer[] = []; @@ -54,7 +54,7 @@ namespace ts.FindAllReferences { return { directImports, indirectUsers: getIndirectUsers() }; - function getIndirectUsers(): SourceFile[] { + function getIndirectUsers(): ReadonlyArray { if (isAvailableThroughGlobal) { // It has `export as namespace`, so anything could potentially use it. return sourceFiles; @@ -313,7 +313,7 @@ namespace ts.FindAllReferences { | { kind: "import", literal: StringLiteral } /** or */ | { kind: "reference", referencingFile: SourceFile, ref: FileReference }; - export function findModuleReferences(program: Program, sourceFiles: SourceFile[], searchModuleSymbol: Symbol): ModuleReference[] { + export function findModuleReferences(program: Program, sourceFiles: ReadonlyArray, searchModuleSymbol: Symbol): ModuleReference[] { const refs: ModuleReference[] = []; const checker = program.getTypeChecker(); for (const referencingFile of sourceFiles) { @@ -343,7 +343,7 @@ namespace ts.FindAllReferences { } /** Returns a map from a module symbol Id to all import statements that directly reference the module. */ - function getDirectImportsMap(sourceFiles: SourceFile[], checker: TypeChecker, cancellationToken: CancellationToken): Map { + function getDirectImportsMap(sourceFiles: ReadonlyArray, checker: TypeChecker, cancellationToken: CancellationToken): Map { const map = createMap(); for (const sourceFile of sourceFiles) { diff --git a/src/services/navigateTo.ts b/src/services/navigateTo.ts index 122ada09019..6d84769082d 100644 --- a/src/services/navigateTo.ts +++ b/src/services/navigateTo.ts @@ -2,7 +2,7 @@ namespace ts.NavigateTo { type RawNavigateToItem = { name: string; fileName: string; matchKind: PatternMatchKind; isCaseSensitive: boolean; declaration: Declaration }; - export function getNavigateToItems(sourceFiles: SourceFile[], checker: TypeChecker, cancellationToken: CancellationToken, searchValue: string, maxResultCount: number, excludeDtsFiles: boolean): NavigateToItem[] { + export function getNavigateToItems(sourceFiles: ReadonlyArray, checker: TypeChecker, cancellationToken: CancellationToken, searchValue: string, maxResultCount: number, excludeDtsFiles: boolean): NavigateToItem[] { const patternMatcher = createPatternMatcher(searchValue); let rawItems: RawNavigateToItem[] = []; diff --git a/src/services/services.ts b/src/services/services.ts index 7354e706cc9..bada7ff021d 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -495,7 +495,7 @@ namespace ts { public path: Path; public text: string; public scriptSnapshot: IScriptSnapshot; - public lineMap: number[]; + public lineMap: ReadonlyArray; public statements: NodeArray; public endOfFileToken: Token; @@ -545,7 +545,7 @@ namespace ts { return ts.getLineAndCharacterOfPosition(this, position); } - public getLineStarts(): number[] { + public getLineStarts(): ReadonlyArray { return getLineStarts(this); } @@ -1336,10 +1336,10 @@ namespace ts { } /// Diagnostics - function getSyntacticDiagnostics(fileName: string) { + function getSyntacticDiagnostics(fileName: string): Diagnostic[] { synchronizeHostData(); - return program.getSyntacticDiagnostics(getValidSourceFile(fileName), cancellationToken); + return program.getSyntacticDiagnostics(getValidSourceFile(fileName), cancellationToken).slice(); } /** @@ -1356,18 +1356,17 @@ namespace ts { const semanticDiagnostics = program.getSemanticDiagnostics(targetSourceFile, cancellationToken); if (!program.getCompilerOptions().declaration) { - return semanticDiagnostics; + return semanticDiagnostics.slice(); } // If '-d' is enabled, check for emitter error. One example of emitter error is export class implements non-export interface const declarationDiagnostics = program.getDeclarationDiagnostics(targetSourceFile, cancellationToken); - return concatenate(semanticDiagnostics, declarationDiagnostics); + return [...semanticDiagnostics, ...declarationDiagnostics]; } function getCompilerOptionsDiagnostics() { synchronizeHostData(); - return program.getOptionsDiagnostics(cancellationToken).concat( - program.getGlobalDiagnostics(cancellationToken)); + return [...program.getOptionsDiagnostics(cancellationToken), ...program.getGlobalDiagnostics(cancellationToken)]; } function getCompletionsAtPosition(fileName: string, position: number): CompletionInfo { diff --git a/src/services/shims.ts b/src/services/shims.ts index 40d4ff2e935..9851d8e6c89 100644 --- a/src/services/shims.ts +++ b/src/services/shims.ts @@ -568,7 +568,7 @@ namespace ts { } } - export function realizeDiagnostics(diagnostics: Diagnostic[], newLine: string): { message: string; start: number; length: number; category: string; code: number; }[] { + export function realizeDiagnostics(diagnostics: ReadonlyArray, newLine: string): { message: string; start: number; length: number; category: string; code: number; }[] { return diagnostics.map(d => realizeDiagnostic(d, newLine)); } @@ -641,7 +641,7 @@ namespace ts { }); } - private realizeDiagnostics(diagnostics: Diagnostic[]): { message: string; start: number; length: number; category: string; }[] { + private realizeDiagnostics(diagnostics: ReadonlyArray): { message: string; start: number; length: number; category: string; }[] { const newLine = getNewLineOrDefaultFromHost(this.host); return ts.realizeDiagnostics(diagnostics, newLine); } diff --git a/src/services/types.ts b/src/services/types.ts index f4f323b8e9f..609eaf11de5 100644 --- a/src/services/types.ts +++ b/src/services/types.ts @@ -68,7 +68,7 @@ namespace ts { getLineAndCharacterOfPosition(pos: number): LineAndCharacter; getLineEndOfPosition(pos: number): number; - getLineStarts(): number[]; + getLineStarts(): ReadonlyArray; getPositionOfLineAndCharacter(line: number, character: number): number; update(newText: string, textChangeRange: TextChangeRange): SourceFile; } From c4ed55459773092597d0dc1cb500bf176daa62d0 Mon Sep 17 00:00:00 2001 From: Andy Date: Thu, 24 Aug 2017 10:27:07 -0700 Subject: [PATCH 136/370] Simplify `isExpression` check (#17741) --- src/compiler/checker.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 4a07f349c9a..24a9a868c4a 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -15220,7 +15220,7 @@ namespace ts { // example, given a 'function wrap(cb: (x: T) => U): (x: T) => U' and a call expression // 'let f: (x: string) => number = wrap(s => s.length)', we infer from the declared type of 'f' to the // return type of 'wrap'. - if (isExpression(node)) { + if (node.kind !== SyntaxKind.Decorator) { const contextualType = getContextualType(node); if (contextualType) { // We clone the contextual mapper to avoid disturbing a resolution in progress for an From 610104bef8ab3493daa0595d099321556aad7b0d Mon Sep 17 00:00:00 2001 From: Ron Buckton Date: Thu, 24 Aug 2017 13:40:20 -0700 Subject: [PATCH 137/370] Switch to arrow for ts class wrapper IIFE --- src/compiler/factory.ts | 43 +++++++++++++- src/compiler/transformers/es2015.ts | 59 ++----------------- src/compiler/transformers/ts.ts | 5 +- src/compiler/types.ts | 1 + src/compiler/utilities.ts | 6 +- .../reference/decoratorOnClassMethod11.js | 1 + .../reference/decoratorOnClassMethod12.js | 1 + .../inferringClassMembersFromAssignments.js | 1 + tests/baselines/reference/superAccess2.js | 1 + ...thisInArrowFunctionInStaticInitializer1.js | 1 + .../reference/thisInConstructorParameter2.js | 1 + .../reference/thisInInvalidContexts.js | 1 + .../thisInInvalidContextsExternalModule.js | 1 + .../reference/thisInOuterClassBody.js | 1 + .../reference/typeOfThisInStaticMembers2.js | 1 + 15 files changed, 64 insertions(+), 60 deletions(-) diff --git a/src/compiler/factory.ts b/src/compiler/factory.ts index 9d7f6c82a7a..4492c3ed474 100644 --- a/src/compiler/factory.ts +++ b/src/compiler/factory.ts @@ -2372,6 +2372,24 @@ namespace ts { ); } + export function createImmediatelyInvokedArrowFunction(statements: Statement[]): CallExpression; + export function createImmediatelyInvokedArrowFunction(statements: Statement[], param: ParameterDeclaration, paramValue: Expression): CallExpression; + export function createImmediatelyInvokedArrowFunction(statements: Statement[], param?: ParameterDeclaration, paramValue?: Expression) { + return createCall( + createArrowFunction( + /*modifiers*/ undefined, + /*typeParameters*/ undefined, + /*parameters*/ param ? [param] : [], + /*type*/ undefined, + /*equalsGreaterThanToken*/ undefined, + createBlock(statements, /*multiLine*/ true) + ), + /*typeArguments*/ undefined, + /*argumentsArray*/ paramValue ? [paramValue] : [] + ); + } + + export function createComma(left: Expression, right: Expression) { return createBinary(left, SyntaxKind.CommaToken, right); } @@ -4036,8 +4054,31 @@ namespace ts { } } + /** + * Determines whether a node is a parenthesized expression that can be ignored when recreating outer expressions. + * + * A parenthesized expression can be ignored when all of the following are true: + * + * - It's `pos` and `end` are not -1 + * - It does not have a custom source map range + * - It does not have a custom comment range + * - It does not have synthetic leading or trailing comments + * + * If an outermost parenthesized expression is ignored, but the containing expression requires a parentheses around + * the expression to maintain precedence, a new parenthesized expression should be created automatically when + * the containing expression is created/updated. + */ + function isIgnorableParen(node: Expression) { + return node.kind === SyntaxKind.ParenthesizedExpression + && nodeIsSynthesized(node) + && nodeIsSynthesized(getSourceMapRange(node)) + && nodeIsSynthesized(getCommentRange(node)) + && !some(getSyntheticLeadingComments(node)) + && !some(getSyntheticTrailingComments(node)); + } + export function recreateOuterExpressions(outerExpression: Expression | undefined, innerExpression: Expression, kinds = OuterExpressionKinds.All): Expression { - if (outerExpression && isOuterExpression(outerExpression, kinds)) { + if (outerExpression && isOuterExpression(outerExpression, kinds) && !isIgnorableParen(outerExpression)) { return updateOuterExpression( outerExpression, recreateOuterExpressions(outerExpression.expression, innerExpression) diff --git a/src/compiler/transformers/es2015.ts b/src/compiler/transformers/es2015.ts index ce907d49bee..e9c84be5176 100644 --- a/src/compiler/transformers/es2015.ts +++ b/src/compiler/transformers/es2015.ts @@ -339,64 +339,12 @@ namespace ts { && !(node).expression; } - function isClassLikeVariableStatement(node: Node) { - if (!isVariableStatement(node)) return false; - const variable = singleOrUndefined((node).declarationList.declarations); - return variable - && variable.initializer - && isIdentifier(variable.name) - && (isClassLike(variable.initializer) - || (isAssignmentExpression(variable.initializer) - && isIdentifier(variable.initializer.left) - && isClassLike(variable.initializer.right))); - } - - function isTypeScriptClassWrapper(node: Node) { - const call = tryCast(node, isCallExpression); - if (!call || isParseTreeNode(call) || - some(call.typeArguments) || - some(call.arguments)) { - return false; - } - - const func = tryCast(skipOuterExpressions(call.expression), isFunctionExpression); - if (!func || isParseTreeNode(func) || - some(func.typeParameters) || - some(func.parameters) || - func.type || - !func.body) { - return false; - } - - const statements = func.body.statements; - if (statements.length < 2) { - return false; - } - - const firstStatement = statements[0]; - if (isParseTreeNode(firstStatement) || - !isClassLike(firstStatement) && - !isClassLikeVariableStatement(firstStatement)) { - return false; - } - - const lastStatement = elementAt(statements, -1); - const returnStatement = tryCast(isVariableStatement(lastStatement) ? elementAt(statements, -2) : lastStatement, isReturnStatement); - if (!returnStatement || - !returnStatement.expression || - !isIdentifier(skipOuterExpressions(returnStatement.expression))) { - return false; - } - - return true; - } - function shouldVisitNode(node: Node): boolean { return (node.transformFlags & TransformFlags.ContainsES2015) !== 0 || convertedLoopState !== undefined || (hierarchyFacts & HierarchyFacts.ConstructorWithCapturedSuper && (isStatement(node) || (node.kind === SyntaxKind.Block))) || (isIterationStatement(node, /*lookInLabeledStatements*/ false) && shouldConvertIterationStatementBody(node)) - || isTypeScriptClassWrapper(node); + || (getEmitFlags(node) & EmitFlags.TypeScriptClassWrapper) !== 0; } function visitor(node: Node): VisitResult { @@ -3308,13 +3256,14 @@ namespace ts { * @param node a CallExpression. */ function visitCallExpression(node: CallExpression) { - if (isTypeScriptClassWrapper(node)) { + if (getEmitFlags(node) & EmitFlags.TypeScriptClassWrapper) { return visitTypeScriptClassWrapper(node); } if (node.transformFlags & TransformFlags.ES2015) { return visitCallExpressionWithPotentialCapturedThisAssignment(node, /*assignToCapturedThis*/ true); } + return updateCall( node, visitNode(node.expression, callExpressionVisitor, isExpression), @@ -3357,7 +3306,7 @@ namespace ts { // We skip any outer expressions in a number of places to get to the innermost // expression, but we will restore them later to preserve comments and source maps. - const body = cast(skipOuterExpressions(node.expression), isFunctionExpression).body; + const body = cast(cast(skipOuterExpressions(node.expression), isArrowFunction).body, isBlock); // The class statements are the statements generated by visiting the first statement of the // body (1), while all other statements are added to remainingStatements (2) diff --git a/src/compiler/transformers/ts.ts b/src/compiler/transformers/ts.ts index 4c679ea1eee..71a3c7dcb7a 100644 --- a/src/compiler/transformers/ts.ts +++ b/src/compiler/transformers/ts.ts @@ -613,13 +613,16 @@ namespace ts { addRange(statements, context.endLexicalEnvironment()); + const iife = createImmediatelyInvokedArrowFunction(statements); + setEmitFlags(iife, EmitFlags.TypeScriptClassWrapper); + const varStatement = createVariableStatement( /*modifiers*/ undefined, createVariableDeclarationList([ createVariableDeclaration( getLocalName(node, /*allowComments*/ false, /*allowSourceMaps*/ false), /*type*/ undefined, - createImmediatelyInvokedFunctionExpression(statements) + iife ) ]) ); diff --git a/src/compiler/types.ts b/src/compiler/types.ts index fe18839b904..3ef38e0e4b7 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -4184,6 +4184,7 @@ namespace ts { HasEndOfDeclarationMarker = 1 << 22, // Declaration has an associated NotEmittedStatement to mark the end of the declaration Iterator = 1 << 23, // The expression to a `yield*` should be treated as an Iterator when down-leveling, not an Iterable. NoAsciiEscaping = 1 << 24, // When synthesizing nodes that lack an original node or textSourceNode, we want to write the text on the node with ASCII escaping substitutions. + /*@internal*/ TypeScriptClassWrapper = 1 << 25, // The node is an IIFE class wrapper created by the ts transform. } export interface EmitHelper { diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index d906ab4f6b1..de752faaf6a 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -2068,9 +2068,9 @@ namespace ts { || kind === SyntaxKind.SourceFile; } - export function nodeIsSynthesized(node: TextRange): boolean { - return positionIsSynthesized(node.pos) - || positionIsSynthesized(node.end); + export function nodeIsSynthesized(range: TextRange): boolean { + return positionIsSynthesized(range.pos) + || positionIsSynthesized(range.end); } export function getOriginalSourceFile(sourceFile: SourceFile) { diff --git a/tests/baselines/reference/decoratorOnClassMethod11.js b/tests/baselines/reference/decoratorOnClassMethod11.js index 2600681c647..e29c4076c91 100644 --- a/tests/baselines/reference/decoratorOnClassMethod11.js +++ b/tests/baselines/reference/decoratorOnClassMethod11.js @@ -17,6 +17,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key, }; var M; (function (M) { + var _this = this; var C = /** @class */ (function () { function C() { } diff --git a/tests/baselines/reference/decoratorOnClassMethod12.js b/tests/baselines/reference/decoratorOnClassMethod12.js index 494cb083a20..0063e0225bc 100644 --- a/tests/baselines/reference/decoratorOnClassMethod12.js +++ b/tests/baselines/reference/decoratorOnClassMethod12.js @@ -28,6 +28,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key, }; var M; (function (M) { + var _this = this; var S = /** @class */ (function () { function S() { } diff --git a/tests/baselines/reference/inferringClassMembersFromAssignments.js b/tests/baselines/reference/inferringClassMembersFromAssignments.js index 3fa72bce2cf..90f87734b2e 100644 --- a/tests/baselines/reference/inferringClassMembersFromAssignments.js +++ b/tests/baselines/reference/inferringClassMembersFromAssignments.js @@ -124,6 +124,7 @@ var stringOrNumberOrUndefined = C.inStaticNestedArrowFunction; //// [output.js] +var _this = this; var C = /** @class */ (function () { function C() { var _this = this; diff --git a/tests/baselines/reference/superAccess2.js b/tests/baselines/reference/superAccess2.js index de755361a16..d3aac217e22 100644 --- a/tests/baselines/reference/superAccess2.js +++ b/tests/baselines/reference/superAccess2.js @@ -35,6 +35,7 @@ var __extends = (this && this.__extends) || (function () { d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); +var _this = this; var P = /** @class */ (function () { function P() { } diff --git a/tests/baselines/reference/thisInArrowFunctionInStaticInitializer1.js b/tests/baselines/reference/thisInArrowFunctionInStaticInitializer1.js index 97e958ace5e..2d58fd455ac 100644 --- a/tests/baselines/reference/thisInArrowFunctionInStaticInitializer1.js +++ b/tests/baselines/reference/thisInArrowFunctionInStaticInitializer1.js @@ -9,6 +9,7 @@ class Vector { } //// [thisInArrowFunctionInStaticInitializer1.js] +var _this = this; function log(a) { } var Vector = /** @class */ (function () { function Vector() { diff --git a/tests/baselines/reference/thisInConstructorParameter2.js b/tests/baselines/reference/thisInConstructorParameter2.js index 6a27183800c..a5e4f4d8b57 100644 --- a/tests/baselines/reference/thisInConstructorParameter2.js +++ b/tests/baselines/reference/thisInConstructorParameter2.js @@ -10,6 +10,7 @@ class P { } //// [thisInConstructorParameter2.js] +var _this = this; var P = /** @class */ (function () { function P(z, zz) { if (z === void 0) { z = this; } diff --git a/tests/baselines/reference/thisInInvalidContexts.js b/tests/baselines/reference/thisInInvalidContexts.js index 635eff25cf4..1e24cc4d9e2 100644 --- a/tests/baselines/reference/thisInInvalidContexts.js +++ b/tests/baselines/reference/thisInInvalidContexts.js @@ -59,6 +59,7 @@ var __extends = (this && this.__extends) || (function () { d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); +var _this = this; //'this' in static member initializer var ErrClass1 = /** @class */ (function () { function ErrClass1() { diff --git a/tests/baselines/reference/thisInInvalidContextsExternalModule.js b/tests/baselines/reference/thisInInvalidContextsExternalModule.js index ea69a582730..daadace2cfa 100644 --- a/tests/baselines/reference/thisInInvalidContextsExternalModule.js +++ b/tests/baselines/reference/thisInInvalidContextsExternalModule.js @@ -60,6 +60,7 @@ var __extends = (this && this.__extends) || (function () { d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); +var _this = this; //'this' in static member initializer var ErrClass1 = /** @class */ (function () { function ErrClass1() { diff --git a/tests/baselines/reference/thisInOuterClassBody.js b/tests/baselines/reference/thisInOuterClassBody.js index 2b4e3a1aabd..d5bf689b49a 100644 --- a/tests/baselines/reference/thisInOuterClassBody.js +++ b/tests/baselines/reference/thisInOuterClassBody.js @@ -21,6 +21,7 @@ class Foo { } //// [thisInOuterClassBody.js] +var _this = this; var Foo = /** @class */ (function () { function Foo() { this.x = this; diff --git a/tests/baselines/reference/typeOfThisInStaticMembers2.js b/tests/baselines/reference/typeOfThisInStaticMembers2.js index 72243cdd3e6..1cfec3a3fa1 100644 --- a/tests/baselines/reference/typeOfThisInStaticMembers2.js +++ b/tests/baselines/reference/typeOfThisInStaticMembers2.js @@ -8,6 +8,7 @@ class C2 { } //// [typeOfThisInStaticMembers2.js] +var _this = this; var C = /** @class */ (function () { function C() { } From 5534899e2a0bd6d9e27177d7ab1fd94f06717082 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Thu, 24 Aug 2017 14:04:57 -0700 Subject: [PATCH 138/370] Allow string enums in element access Previously literal union types were disallowed to improve errors by printing `boolean` instead of `true | false`. But string enums are literal union types that should be allowed, so now only booleans are disallowed. --- src/compiler/checker.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 4a07f349c9a..08770fc8d80 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -7688,7 +7688,7 @@ namespace ts { } // In the following we resolve T[K] to the type of the property in T selected by K. const apparentObjectType = getApparentType(objectType); - if (indexType.flags & TypeFlags.Union && !(indexType.flags & TypeFlags.Primitive)) { + if (indexType.flags & TypeFlags.Union && !(indexType.flags & TypeFlags.Boolean)) { const propTypes: Type[] = []; for (const t of (indexType).types) { const propType = getPropertyTypeForIndexType(apparentObjectType, t, accessNode, /*cacheSymbol*/ false); From d7d69a16226408aefa78082fcefd7ae5a01ee9f0 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Thu, 24 Aug 2017 14:06:21 -0700 Subject: [PATCH 139/370] Test:string enum in element access --- .../reference/stringEnumInElementAccess01.js | 26 +++++++++++ .../stringEnumInElementAccess01.symbols | 40 +++++++++++++++++ .../stringEnumInElementAccess01.types | 44 +++++++++++++++++++ .../stringEnumInElementAccess01.ts | 16 +++++++ 4 files changed, 126 insertions(+) create mode 100644 tests/baselines/reference/stringEnumInElementAccess01.js create mode 100644 tests/baselines/reference/stringEnumInElementAccess01.symbols create mode 100644 tests/baselines/reference/stringEnumInElementAccess01.types create mode 100644 tests/cases/conformance/expressions/elementAccess/stringEnumInElementAccess01.ts diff --git a/tests/baselines/reference/stringEnumInElementAccess01.js b/tests/baselines/reference/stringEnumInElementAccess01.js new file mode 100644 index 00000000000..6dadb919a38 --- /dev/null +++ b/tests/baselines/reference/stringEnumInElementAccess01.js @@ -0,0 +1,26 @@ +//// [stringEnumInElementAccess01.ts] +enum E { + A = "a", + B = "b", + C = "c", +} + +interface Item { + a: string; + b: number; + c: boolean; +} + +declare const item: Item; +declare const e: E; +const snb: string | number | boolean = item[e]; + + +//// [stringEnumInElementAccess01.js] +var E; +(function (E) { + E["A"] = "a"; + E["B"] = "b"; + E["C"] = "c"; +})(E || (E = {})); +var snb = item[e]; diff --git a/tests/baselines/reference/stringEnumInElementAccess01.symbols b/tests/baselines/reference/stringEnumInElementAccess01.symbols new file mode 100644 index 00000000000..337edf1d594 --- /dev/null +++ b/tests/baselines/reference/stringEnumInElementAccess01.symbols @@ -0,0 +1,40 @@ +=== tests/cases/conformance/expressions/elementAccess/stringEnumInElementAccess01.ts === +enum E { +>E : Symbol(E, Decl(stringEnumInElementAccess01.ts, 0, 0)) + + A = "a", +>A : Symbol(E.A, Decl(stringEnumInElementAccess01.ts, 0, 8)) + + B = "b", +>B : Symbol(E.B, Decl(stringEnumInElementAccess01.ts, 1, 12)) + + C = "c", +>C : Symbol(E.C, Decl(stringEnumInElementAccess01.ts, 2, 12)) +} + +interface Item { +>Item : Symbol(Item, Decl(stringEnumInElementAccess01.ts, 4, 1)) + + a: string; +>a : Symbol(Item.a, Decl(stringEnumInElementAccess01.ts, 6, 16)) + + b: number; +>b : Symbol(Item.b, Decl(stringEnumInElementAccess01.ts, 7, 14)) + + c: boolean; +>c : Symbol(Item.c, Decl(stringEnumInElementAccess01.ts, 8, 14)) +} + +declare const item: Item; +>item : Symbol(item, Decl(stringEnumInElementAccess01.ts, 12, 13)) +>Item : Symbol(Item, Decl(stringEnumInElementAccess01.ts, 4, 1)) + +declare const e: E; +>e : Symbol(e, Decl(stringEnumInElementAccess01.ts, 13, 13)) +>E : Symbol(E, Decl(stringEnumInElementAccess01.ts, 0, 0)) + +const snb: string | number | boolean = item[e]; +>snb : Symbol(snb, Decl(stringEnumInElementAccess01.ts, 14, 5)) +>item : Symbol(item, Decl(stringEnumInElementAccess01.ts, 12, 13)) +>e : Symbol(e, Decl(stringEnumInElementAccess01.ts, 13, 13)) + diff --git a/tests/baselines/reference/stringEnumInElementAccess01.types b/tests/baselines/reference/stringEnumInElementAccess01.types new file mode 100644 index 00000000000..f0e878f7761 --- /dev/null +++ b/tests/baselines/reference/stringEnumInElementAccess01.types @@ -0,0 +1,44 @@ +=== tests/cases/conformance/expressions/elementAccess/stringEnumInElementAccess01.ts === +enum E { +>E : E + + A = "a", +>A : E.A +>"a" : "a" + + B = "b", +>B : E.B +>"b" : "b" + + C = "c", +>C : E.C +>"c" : "c" +} + +interface Item { +>Item : Item + + a: string; +>a : string + + b: number; +>b : number + + c: boolean; +>c : boolean +} + +declare const item: Item; +>item : Item +>Item : Item + +declare const e: E; +>e : E +>E : E + +const snb: string | number | boolean = item[e]; +>snb : string | number | boolean +>item[e] : string | number | boolean +>item : Item +>e : E + diff --git a/tests/cases/conformance/expressions/elementAccess/stringEnumInElementAccess01.ts b/tests/cases/conformance/expressions/elementAccess/stringEnumInElementAccess01.ts new file mode 100644 index 00000000000..2dc07cb0e4f --- /dev/null +++ b/tests/cases/conformance/expressions/elementAccess/stringEnumInElementAccess01.ts @@ -0,0 +1,16 @@ +// @noImplicitAny: true +enum E { + A = "a", + B = "b", + C = "c", +} + +interface Item { + a: string; + b: number; + c: boolean; +} + +declare const item: Item; +declare const e: E; +const snb: string | number | boolean = item[e]; From ccd0158c406727d7a1ec81bdc579e8c6e6607f9d Mon Sep 17 00:00:00 2001 From: Ron Buckton Date: Thu, 24 Aug 2017 15:06:06 -0700 Subject: [PATCH 140/370] Added additional test --- .../reference/asyncArrowInClassES5.js | 21 +++++++++++++++++++ .../reference/asyncArrowInClassES5.symbols | 12 +++++++++++ .../reference/asyncArrowInClassES5.types | 13 ++++++++++++ tests/cases/compiler/asyncArrowInClassES5.ts | 9 ++++++++ 4 files changed, 55 insertions(+) create mode 100644 tests/baselines/reference/asyncArrowInClassES5.js create mode 100644 tests/baselines/reference/asyncArrowInClassES5.symbols create mode 100644 tests/baselines/reference/asyncArrowInClassES5.types create mode 100644 tests/cases/compiler/asyncArrowInClassES5.ts diff --git a/tests/baselines/reference/asyncArrowInClassES5.js b/tests/baselines/reference/asyncArrowInClassES5.js new file mode 100644 index 00000000000..f0204f7319b --- /dev/null +++ b/tests/baselines/reference/asyncArrowInClassES5.js @@ -0,0 +1,21 @@ +//// [asyncArrowInClassES5.ts] +// https://github.com/Microsoft/TypeScript/issues/16924 +// Should capture `this` + +class Test { + static member = async (x: string) => { }; +} + + +//// [asyncArrowInClassES5.js] +// https://github.com/Microsoft/TypeScript/issues/16924 +// Should capture `this` +var _this = this; +var Test = /** @class */ (function () { + function Test() { + } + Test.member = function (x) { return __awaiter(_this, void 0, void 0, function () { return __generator(this, function (_a) { + return [2 /*return*/]; + }); }); }; + return Test; +}()); diff --git a/tests/baselines/reference/asyncArrowInClassES5.symbols b/tests/baselines/reference/asyncArrowInClassES5.symbols new file mode 100644 index 00000000000..a6cc9f75d6e --- /dev/null +++ b/tests/baselines/reference/asyncArrowInClassES5.symbols @@ -0,0 +1,12 @@ +=== tests/cases/compiler/asyncArrowInClassES5.ts === +// https://github.com/Microsoft/TypeScript/issues/16924 +// Should capture `this` + +class Test { +>Test : Symbol(Test, Decl(asyncArrowInClassES5.ts, 0, 0)) + + static member = async (x: string) => { }; +>member : Symbol(Test.member, Decl(asyncArrowInClassES5.ts, 3, 12)) +>x : Symbol(x, Decl(asyncArrowInClassES5.ts, 4, 27)) +} + diff --git a/tests/baselines/reference/asyncArrowInClassES5.types b/tests/baselines/reference/asyncArrowInClassES5.types new file mode 100644 index 00000000000..8da6d5d2eaf --- /dev/null +++ b/tests/baselines/reference/asyncArrowInClassES5.types @@ -0,0 +1,13 @@ +=== tests/cases/compiler/asyncArrowInClassES5.ts === +// https://github.com/Microsoft/TypeScript/issues/16924 +// Should capture `this` + +class Test { +>Test : Test + + static member = async (x: string) => { }; +>member : (x: string) => Promise +>async (x: string) => { } : (x: string) => Promise +>x : string +} + diff --git a/tests/cases/compiler/asyncArrowInClassES5.ts b/tests/cases/compiler/asyncArrowInClassES5.ts new file mode 100644 index 00000000000..2712372d357 --- /dev/null +++ b/tests/cases/compiler/asyncArrowInClassES5.ts @@ -0,0 +1,9 @@ +// @noEmitHelpers: true +// @lib: es2015 +// @target: es5 +// https://github.com/Microsoft/TypeScript/issues/16924 +// Should capture `this` + +class Test { + static member = async (x: string) => { }; +} From 2f1bd8cff91210584f5952e5228050aebb83122b Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Thu, 24 Aug 2017 15:52:04 -0700 Subject: [PATCH 141/370] Escape \0 followed by a number as a hex escape to avoid printing an octal literal (#18026) --- src/compiler/utilities.ts | 7 ++++++- ...uldNotPrintNullEscapesIntoOctalLiterals.js | 15 +++++++++++++++ ...tPrintNullEscapesIntoOctalLiterals.symbols | 8 ++++++++ ...NotPrintNullEscapesIntoOctalLiterals.types | 19 +++++++++++++++++++ ...uldNotPrintNullEscapesIntoOctalLiterals.ts | 6 ++++++ 5 files changed, 54 insertions(+), 1 deletion(-) create mode 100644 tests/baselines/reference/shouldNotPrintNullEscapesIntoOctalLiterals.js create mode 100644 tests/baselines/reference/shouldNotPrintNullEscapesIntoOctalLiterals.symbols create mode 100644 tests/baselines/reference/shouldNotPrintNullEscapesIntoOctalLiterals.types create mode 100644 tests/cases/compiler/shouldNotPrintNullEscapesIntoOctalLiterals.ts diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index d906ab4f6b1..6d53f9e8e99 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -2380,6 +2380,7 @@ namespace ts { "\u2029": "\\u2029", // paragraphSeparator "\u0085": "\\u0085" // nextLine }); + const escapedNullRegExp = /\\0[0-9]/g; /** * Based heavily on the abstract 'Quote'/'QuoteJSONString' operation from ECMA-262 (24.3.2.2), @@ -2391,7 +2392,11 @@ namespace ts { quoteChar === CharacterCodes.backtick ? backtickQuoteEscapedCharsRegExp : quoteChar === CharacterCodes.singleQuote ? singleQuoteEscapedCharsRegExp : doubleQuoteEscapedCharsRegExp; - return s.replace(escapedCharsRegExp, getReplacement); + return s.replace(escapedCharsRegExp, getReplacement).replace(escapedNullRegExp, nullReplacement); + } + + function nullReplacement(c: string) { + return "\\x00" + c.charAt(c.length - 1); } function getReplacement(c: string) { diff --git a/tests/baselines/reference/shouldNotPrintNullEscapesIntoOctalLiterals.js b/tests/baselines/reference/shouldNotPrintNullEscapesIntoOctalLiterals.js new file mode 100644 index 00000000000..4654558135c --- /dev/null +++ b/tests/baselines/reference/shouldNotPrintNullEscapesIntoOctalLiterals.js @@ -0,0 +1,15 @@ +//// [shouldNotPrintNullEscapesIntoOctalLiterals.ts] +"use strict"; +`\x001`; +`\u00001`; +`\u{00000000}1`; +`\u{000000}1`; +`\u{0}1`; + +//// [shouldNotPrintNullEscapesIntoOctalLiterals.js] +"use strict"; +"\x001"; +"\x001"; +"\x001"; +"\x001"; +"\x001"; diff --git a/tests/baselines/reference/shouldNotPrintNullEscapesIntoOctalLiterals.symbols b/tests/baselines/reference/shouldNotPrintNullEscapesIntoOctalLiterals.symbols new file mode 100644 index 00000000000..3ffb259aed0 --- /dev/null +++ b/tests/baselines/reference/shouldNotPrintNullEscapesIntoOctalLiterals.symbols @@ -0,0 +1,8 @@ +=== tests/cases/compiler/shouldNotPrintNullEscapesIntoOctalLiterals.ts === +"use strict"; +No type information for this code.`\x001`; +No type information for this code.`\u00001`; +No type information for this code.`\u{00000000}1`; +No type information for this code.`\u{000000}1`; +No type information for this code.`\u{0}1`; +No type information for this code. \ No newline at end of file diff --git a/tests/baselines/reference/shouldNotPrintNullEscapesIntoOctalLiterals.types b/tests/baselines/reference/shouldNotPrintNullEscapesIntoOctalLiterals.types new file mode 100644 index 00000000000..8f76e662558 --- /dev/null +++ b/tests/baselines/reference/shouldNotPrintNullEscapesIntoOctalLiterals.types @@ -0,0 +1,19 @@ +=== tests/cases/compiler/shouldNotPrintNullEscapesIntoOctalLiterals.ts === +"use strict"; +>"use strict" : "use strict" + +`\x001`; +>`\x001` : "\x001" + +`\u00001`; +>`\u00001` : "\x001" + +`\u{00000000}1`; +>`\u{00000000}1` : "\x001" + +`\u{000000}1`; +>`\u{000000}1` : "\x001" + +`\u{0}1`; +>`\u{0}1` : "\x001" + diff --git a/tests/cases/compiler/shouldNotPrintNullEscapesIntoOctalLiterals.ts b/tests/cases/compiler/shouldNotPrintNullEscapesIntoOctalLiterals.ts new file mode 100644 index 00000000000..fbbab43319a --- /dev/null +++ b/tests/cases/compiler/shouldNotPrintNullEscapesIntoOctalLiterals.ts @@ -0,0 +1,6 @@ +"use strict"; +`\x001`; +`\u00001`; +`\u{00000000}1`; +`\u{000000}1`; +`\u{0}1`; \ No newline at end of file From 336df751eab01595e451b0de6e5c9ecf551083b0 Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Thu, 24 Aug 2017 15:53:09 -0700 Subject: [PATCH 142/370] Fix issue #16803 do not error on getters/setters (#18031) --- src/compiler/checker.ts | 17 ++++++++++----- src/compiler/core.ts | 4 ++++ .../exportEqualsClassNoRedeclarationError.js | 19 +++++++++++++++++ ...ortEqualsClassNoRedeclarationError.symbols | 17 +++++++++++++++ ...xportEqualsClassNoRedeclarationError.types | 18 ++++++++++++++++ ...rtEqualsClassRedeclarationError.errors.txt | 21 +++++++++++++++++++ .../exportEqualsClassRedeclarationError.js | 21 +++++++++++++++++++ .../exportEqualsClassNoRedeclarationError.ts | 10 +++++++++ .../exportEqualsClassRedeclarationError.ts | 11 ++++++++++ 9 files changed, 133 insertions(+), 5 deletions(-) create mode 100644 tests/baselines/reference/exportEqualsClassNoRedeclarationError.js create mode 100644 tests/baselines/reference/exportEqualsClassNoRedeclarationError.symbols create mode 100644 tests/baselines/reference/exportEqualsClassNoRedeclarationError.types create mode 100644 tests/baselines/reference/exportEqualsClassRedeclarationError.errors.txt create mode 100644 tests/baselines/reference/exportEqualsClassRedeclarationError.js create mode 100644 tests/cases/compiler/exportEqualsClassNoRedeclarationError.ts create mode 100644 tests/cases/compiler/exportEqualsClassRedeclarationError.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 24a9a868c4a..21db77b5e39 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -497,6 +497,8 @@ namespace ts { const builtinGlobals = createSymbolTable(); builtinGlobals.set(undefinedSymbol.escapedName, undefinedSymbol); + const isNotOverloadAndNotAccessor = and(isNotOverload, isNotAccessor); + initializeTypeChecker(); return checker; @@ -22257,7 +22259,7 @@ namespace ts { if (flags & (SymbolFlags.Namespace | SymbolFlags.Interface | SymbolFlags.Enum)) { return; } - const exportedDeclarationsCount = countWhere(declarations, isNotOverload); + const exportedDeclarationsCount = countWhere(declarations, isNotOverloadAndNotAccessor); if (flags & SymbolFlags.TypeAlias && exportedDeclarationsCount <= 2) { // it is legal to merge type alias with other values // so count should be either 1 (just type alias) or 2 (type alias + merged value) @@ -22273,11 +22275,16 @@ namespace ts { }); links.exportsChecked = true; } + } - function isNotOverload(declaration: Declaration): boolean { - return (declaration.kind !== SyntaxKind.FunctionDeclaration && declaration.kind !== SyntaxKind.MethodDeclaration) || - !!(declaration as FunctionDeclaration).body; - } + function isNotAccessor(declaration: Declaration): boolean { + // Accessors check for their own matching duplicates, and in contexts where they are valid, there are already duplicate identifier checks + return !isAccessor(declaration); + } + + function isNotOverload(declaration: Declaration): boolean { + return (declaration.kind !== SyntaxKind.FunctionDeclaration && declaration.kind !== SyntaxKind.MethodDeclaration) || + !!(declaration as FunctionDeclaration).body; } function checkSourceElement(node: Node): void { diff --git a/src/compiler/core.ts b/src/compiler/core.ts index 6eb17f1fb78..f94ac9a75c5 100644 --- a/src/compiler/core.ts +++ b/src/compiler/core.ts @@ -2626,4 +2626,8 @@ namespace ts { export function isCheckJsEnabledForFile(sourceFile: SourceFile, compilerOptions: CompilerOptions) { return sourceFile.checkJsDirective ? sourceFile.checkJsDirective.enabled : compilerOptions.checkJs; } + + export function and(f: (arg: T) => boolean, g: (arg: T) => boolean) { + return (arg: T) => f(arg) && g(arg); + } } diff --git a/tests/baselines/reference/exportEqualsClassNoRedeclarationError.js b/tests/baselines/reference/exportEqualsClassNoRedeclarationError.js new file mode 100644 index 00000000000..834d10a48d6 --- /dev/null +++ b/tests/baselines/reference/exportEqualsClassNoRedeclarationError.js @@ -0,0 +1,19 @@ +//// [exportEqualsClassNoRedeclarationError.ts] +class SomeClass { + static get someProp(): number { + return 0; + } + + static set someProp(value: number) {} +} +export = SomeClass; + +//// [exportEqualsClassNoRedeclarationError.js] +"use strict"; +class SomeClass { + static get someProp() { + return 0; + } + static set someProp(value) { } +} +module.exports = SomeClass; diff --git a/tests/baselines/reference/exportEqualsClassNoRedeclarationError.symbols b/tests/baselines/reference/exportEqualsClassNoRedeclarationError.symbols new file mode 100644 index 00000000000..386efa1bdaa --- /dev/null +++ b/tests/baselines/reference/exportEqualsClassNoRedeclarationError.symbols @@ -0,0 +1,17 @@ +=== tests/cases/compiler/exportEqualsClassNoRedeclarationError.ts === +class SomeClass { +>SomeClass : Symbol(SomeClass, Decl(exportEqualsClassNoRedeclarationError.ts, 0, 0)) + + static get someProp(): number { +>someProp : Symbol(SomeClass.someProp, Decl(exportEqualsClassNoRedeclarationError.ts, 0, 17), Decl(exportEqualsClassNoRedeclarationError.ts, 3, 5)) + + return 0; + } + + static set someProp(value: number) {} +>someProp : Symbol(SomeClass.someProp, Decl(exportEqualsClassNoRedeclarationError.ts, 0, 17), Decl(exportEqualsClassNoRedeclarationError.ts, 3, 5)) +>value : Symbol(value, Decl(exportEqualsClassNoRedeclarationError.ts, 5, 24)) +} +export = SomeClass; +>SomeClass : Symbol(SomeClass, Decl(exportEqualsClassNoRedeclarationError.ts, 0, 0)) + diff --git a/tests/baselines/reference/exportEqualsClassNoRedeclarationError.types b/tests/baselines/reference/exportEqualsClassNoRedeclarationError.types new file mode 100644 index 00000000000..cba7b57a4e8 --- /dev/null +++ b/tests/baselines/reference/exportEqualsClassNoRedeclarationError.types @@ -0,0 +1,18 @@ +=== tests/cases/compiler/exportEqualsClassNoRedeclarationError.ts === +class SomeClass { +>SomeClass : SomeClass + + static get someProp(): number { +>someProp : number + + return 0; +>0 : 0 + } + + static set someProp(value: number) {} +>someProp : number +>value : number +} +export = SomeClass; +>SomeClass : SomeClass + diff --git a/tests/baselines/reference/exportEqualsClassRedeclarationError.errors.txt b/tests/baselines/reference/exportEqualsClassRedeclarationError.errors.txt new file mode 100644 index 00000000000..4eccf0cc1ca --- /dev/null +++ b/tests/baselines/reference/exportEqualsClassRedeclarationError.errors.txt @@ -0,0 +1,21 @@ +tests/cases/compiler/exportEqualsClassRedeclarationError.ts(2,16): error TS2300: Duplicate identifier 'someProp'. +tests/cases/compiler/exportEqualsClassRedeclarationError.ts(6,16): error TS2300: Duplicate identifier 'someProp'. +tests/cases/compiler/exportEqualsClassRedeclarationError.ts(7,16): error TS2300: Duplicate identifier 'someProp'. + + +==== tests/cases/compiler/exportEqualsClassRedeclarationError.ts (3 errors) ==== + class SomeClass { + static get someProp(): number { + ~~~~~~~~ +!!! error TS2300: Duplicate identifier 'someProp'. + return 0; + } + + static set someProp(value: number) {} + ~~~~~~~~ +!!! error TS2300: Duplicate identifier 'someProp'. + static set someProp(value: number) {} + ~~~~~~~~ +!!! error TS2300: Duplicate identifier 'someProp'. + } + export = SomeClass; \ No newline at end of file diff --git a/tests/baselines/reference/exportEqualsClassRedeclarationError.js b/tests/baselines/reference/exportEqualsClassRedeclarationError.js new file mode 100644 index 00000000000..f0134c46626 --- /dev/null +++ b/tests/baselines/reference/exportEqualsClassRedeclarationError.js @@ -0,0 +1,21 @@ +//// [exportEqualsClassRedeclarationError.ts] +class SomeClass { + static get someProp(): number { + return 0; + } + + static set someProp(value: number) {} + static set someProp(value: number) {} +} +export = SomeClass; + +//// [exportEqualsClassRedeclarationError.js] +"use strict"; +class SomeClass { + static get someProp() { + return 0; + } + static set someProp(value) { } + static set someProp(value) { } +} +module.exports = SomeClass; diff --git a/tests/cases/compiler/exportEqualsClassNoRedeclarationError.ts b/tests/cases/compiler/exportEqualsClassNoRedeclarationError.ts new file mode 100644 index 00000000000..0e5c5824111 --- /dev/null +++ b/tests/cases/compiler/exportEqualsClassNoRedeclarationError.ts @@ -0,0 +1,10 @@ +// @target: es6 +// @module: commonjs +class SomeClass { + static get someProp(): number { + return 0; + } + + static set someProp(value: number) {} +} +export = SomeClass; \ No newline at end of file diff --git a/tests/cases/compiler/exportEqualsClassRedeclarationError.ts b/tests/cases/compiler/exportEqualsClassRedeclarationError.ts new file mode 100644 index 00000000000..237aca399f0 --- /dev/null +++ b/tests/cases/compiler/exportEqualsClassRedeclarationError.ts @@ -0,0 +1,11 @@ +// @target: es6 +// @module: commonjs +class SomeClass { + static get someProp(): number { + return 0; + } + + static set someProp(value: number) {} + static set someProp(value: number) {} +} +export = SomeClass; \ No newline at end of file From f824e7214ddda789baa6379ff599c5f5012a42b6 Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Thu, 24 Aug 2017 16:48:11 -0700 Subject: [PATCH 143/370] Give mapped type properties a synthetic declaration name (#18023) * Escape symbol names which are not valid identifiers and wrap them in quotes * Pass forward type, do work in getNameOfSymbol * Minimal test * Fix nit --- src/compiler/checker.ts | 16 +++++++++++++++- src/compiler/types.ts | 1 + .../reference/declarationQuotedMembers.js | 17 +++++++++++++++++ .../reference/declarationQuotedMembers.symbols | 9 +++++++++ .../reference/declarationQuotedMembers.types | 9 +++++++++ .../cases/compiler/declarationQuotedMembers.ts | 3 +++ 6 files changed, 54 insertions(+), 1 deletion(-) create mode 100644 tests/baselines/reference/declarationQuotedMembers.js create mode 100644 tests/baselines/reference/declarationQuotedMembers.symbols create mode 100644 tests/baselines/reference/declarationQuotedMembers.types create mode 100644 tests/cases/compiler/declarationQuotedMembers.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 21db77b5e39..55d26bb48ea 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -3114,6 +3114,12 @@ namespace ts { return "(Anonymous function)"; } } + if ((symbol as TransientSymbol).syntheticLiteralTypeOrigin) { + const stringValue = (symbol as TransientSymbol).syntheticLiteralTypeOrigin.value; + if (!isIdentifierText(stringValue, compilerOptions.target)) { + return `"${escapeString(stringValue, CharacterCodes.doubleQuote)}"`; + } + } return unescapeLeadingUnderscores(symbol.escapedName); } @@ -5724,7 +5730,14 @@ namespace ts { } setStructuredTypeMembers(type, members, emptyArray, emptyArray, stringIndexInfo, undefined); - function addMemberForKeyType(t: Type, propertySymbol?: Symbol) { + function addMemberForKeyType(t: Type, propertySymbolOrIndex?: Symbol | number) { + let propertySymbol: Symbol; + // forEachType delegates to forEach, which calls with a numeric second argument + // the type system currently doesn't catch this incompatibility, so we annotate + // the function ourselves to indicate the runtime behavior and deal with it here + if (typeof propertySymbolOrIndex === "object") { + propertySymbol = propertySymbolOrIndex; + } // Create a mapper from T to the current iteration type constituent. Then, if the // mapped type is itself an instantiated type, combine the iteration mapper with the // instantiation mapper. @@ -5744,6 +5757,7 @@ namespace ts { prop.syntheticOrigin = propertySymbol; prop.declarations = propertySymbol.declarations; } + prop.syntheticLiteralTypeOrigin = t as StringLiteralType; members.set(propName, prop); } else if (t.flags & TypeFlags.String) { diff --git a/src/compiler/types.ts b/src/compiler/types.ts index fe18839b904..e3c8661deba 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -2972,6 +2972,7 @@ namespace ts { leftSpread?: Symbol; // Left source for synthetic spread property rightSpread?: Symbol; // Right source for synthetic spread property syntheticOrigin?: Symbol; // For a property on a mapped or spread type, points back to the original property + syntheticLiteralTypeOrigin?: StringLiteralType; // For a property on a mapped type, indicates the type whose text to use as the declaration name, instead of the symbol name isDiscriminantProperty?: boolean; // True if discriminant synthetic property resolvedExports?: SymbolTable; // Resolved exports of module exportsChecked?: boolean; // True if exports of external module have been checked diff --git a/tests/baselines/reference/declarationQuotedMembers.js b/tests/baselines/reference/declarationQuotedMembers.js new file mode 100644 index 00000000000..ab40231eb3e --- /dev/null +++ b/tests/baselines/reference/declarationQuotedMembers.js @@ -0,0 +1,17 @@ +//// [declarationQuotedMembers.ts] +export declare const mapped: { [K in 'a-b-c']: number } +export const example = mapped; + +//// [declarationQuotedMembers.js] +"use strict"; +exports.__esModule = true; +exports.example = exports.mapped; + + +//// [declarationQuotedMembers.d.ts] +export declare const mapped: { + [K in 'a-b-c']: number; +}; +export declare const example: { + "a-b-c": number; +}; diff --git a/tests/baselines/reference/declarationQuotedMembers.symbols b/tests/baselines/reference/declarationQuotedMembers.symbols new file mode 100644 index 00000000000..3bf1a2829b0 --- /dev/null +++ b/tests/baselines/reference/declarationQuotedMembers.symbols @@ -0,0 +1,9 @@ +=== tests/cases/compiler/declarationQuotedMembers.ts === +export declare const mapped: { [K in 'a-b-c']: number } +>mapped : Symbol(mapped, Decl(declarationQuotedMembers.ts, 0, 20)) +>K : Symbol(K, Decl(declarationQuotedMembers.ts, 0, 32)) + +export const example = mapped; +>example : Symbol(example, Decl(declarationQuotedMembers.ts, 1, 12)) +>mapped : Symbol(mapped, Decl(declarationQuotedMembers.ts, 0, 20)) + diff --git a/tests/baselines/reference/declarationQuotedMembers.types b/tests/baselines/reference/declarationQuotedMembers.types new file mode 100644 index 00000000000..c9f6c047b7e --- /dev/null +++ b/tests/baselines/reference/declarationQuotedMembers.types @@ -0,0 +1,9 @@ +=== tests/cases/compiler/declarationQuotedMembers.ts === +export declare const mapped: { [K in 'a-b-c']: number } +>mapped : { a-b-c: number; } +>K : K + +export const example = mapped; +>example : { a-b-c: number; } +>mapped : { a-b-c: number; } + diff --git a/tests/cases/compiler/declarationQuotedMembers.ts b/tests/cases/compiler/declarationQuotedMembers.ts new file mode 100644 index 00000000000..08bae2c3754 --- /dev/null +++ b/tests/cases/compiler/declarationQuotedMembers.ts @@ -0,0 +1,3 @@ +// @declaration: true +export declare const mapped: { [K in 'a-b-c']: number } +export const example = mapped; \ No newline at end of file From 643a7e7e3326a54ddf6fa590146ac8cfde4c6e98 Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Thu, 24 Aug 2017 17:08:57 -0700 Subject: [PATCH 144/370] Call dynamic import transform on expression used by export equal statement (#18028) * Call dynamic import transform on expression used by export equal statement * Use Debug.fail --- src/compiler/transformers/module/module.ts | 46 +++++++++++-------- .../importCallExpressionInExportEqualsAMD.js | 22 +++++++++ ...ortCallExpressionInExportEqualsAMD.symbols | 10 ++++ ...mportCallExpressionInExportEqualsAMD.types | 14 ++++++ .../importCallExpressionInExportEqualsCJS.js | 18 ++++++++ ...ortCallExpressionInExportEqualsCJS.symbols | 10 ++++ ...mportCallExpressionInExportEqualsCJS.types | 14 ++++++ .../importCallExpressionInExportEqualsUMD.js | 39 ++++++++++++++++ ...ortCallExpressionInExportEqualsUMD.symbols | 10 ++++ ...mportCallExpressionInExportEqualsUMD.types | 14 ++++++ .../importCallExpressionInExportEqualsAMD.ts | 9 ++++ .../importCallExpressionInExportEqualsCJS.ts | 9 ++++ .../importCallExpressionInExportEqualsUMD.ts | 9 ++++ 13 files changed, 204 insertions(+), 20 deletions(-) create mode 100644 tests/baselines/reference/importCallExpressionInExportEqualsAMD.js create mode 100644 tests/baselines/reference/importCallExpressionInExportEqualsAMD.symbols create mode 100644 tests/baselines/reference/importCallExpressionInExportEqualsAMD.types create mode 100644 tests/baselines/reference/importCallExpressionInExportEqualsCJS.js create mode 100644 tests/baselines/reference/importCallExpressionInExportEqualsCJS.symbols create mode 100644 tests/baselines/reference/importCallExpressionInExportEqualsCJS.types create mode 100644 tests/baselines/reference/importCallExpressionInExportEqualsUMD.js create mode 100644 tests/baselines/reference/importCallExpressionInExportEqualsUMD.symbols create mode 100644 tests/baselines/reference/importCallExpressionInExportEqualsUMD.types create mode 100644 tests/cases/conformance/dynamicImport/importCallExpressionInExportEqualsAMD.ts create mode 100644 tests/cases/conformance/dynamicImport/importCallExpressionInExportEqualsCJS.ts create mode 100644 tests/cases/conformance/dynamicImport/importCallExpressionInExportEqualsUMD.ts diff --git a/src/compiler/transformers/module/module.ts b/src/compiler/transformers/module/module.ts index a0f593e5111..23bae8714c8 100644 --- a/src/compiler/transformers/module/module.ts +++ b/src/compiler/transformers/module/module.ts @@ -430,26 +430,32 @@ namespace ts { */ function addExportEqualsIfNeeded(statements: Statement[], emitAsReturn: boolean) { if (currentModuleInfo.exportEquals) { - if (emitAsReturn) { - const statement = createReturn(currentModuleInfo.exportEquals.expression); - setTextRange(statement, currentModuleInfo.exportEquals); - setEmitFlags(statement, EmitFlags.NoTokenSourceMaps | EmitFlags.NoComments); - statements.push(statement); - } - else { - const statement = createStatement( - createAssignment( - createPropertyAccess( - createIdentifier("module"), - "exports" - ), - currentModuleInfo.exportEquals.expression - ) - ); + const expressionResult = importCallExpressionVisitor(currentModuleInfo.exportEquals.expression); + if (expressionResult) { + if (expressionResult instanceof Array) { + return Debug.fail("export= expression should never be replaced with multiple expressions!"); + } + if (emitAsReturn) { + const statement = createReturn(expressionResult); + setTextRange(statement, currentModuleInfo.exportEquals); + setEmitFlags(statement, EmitFlags.NoTokenSourceMaps | EmitFlags.NoComments); + statements.push(statement); + } + else { + const statement = createStatement( + createAssignment( + createPropertyAccess( + createIdentifier("module"), + "exports" + ), + expressionResult + ) + ); - setTextRange(statement, currentModuleInfo.exportEquals); - setEmitFlags(statement, EmitFlags.NoComments); - statements.push(statement); + setTextRange(statement, currentModuleInfo.exportEquals); + setEmitFlags(statement, EmitFlags.NoComments); + statements.push(statement); + } } } } @@ -497,7 +503,7 @@ namespace ts { } } - function importCallExpressionVisitor(node: Node): VisitResult { + function importCallExpressionVisitor(node: Expression): VisitResult { // This visitor does not need to descend into the tree if there is no dynamic import, // as export/import statements are only transformed at the top level of a file. if (!(node.transformFlags & TransformFlags.ContainsDynamicImport)) { diff --git a/tests/baselines/reference/importCallExpressionInExportEqualsAMD.js b/tests/baselines/reference/importCallExpressionInExportEqualsAMD.js new file mode 100644 index 00000000000..f2fda1fadd7 --- /dev/null +++ b/tests/baselines/reference/importCallExpressionInExportEqualsAMD.js @@ -0,0 +1,22 @@ +//// [tests/cases/conformance/dynamicImport/importCallExpressionInExportEqualsAMD.ts] //// + +//// [something.ts] +export = 42; + +//// [index.ts] +export = async function() { + const something = await import("./something"); +}; + +//// [something.js] +define(["require", "exports"], function (require, exports) { + "use strict"; + return 42; +}); +//// [index.js] +define(["require", "exports"], function (require, exports) { + "use strict"; + return async function () { + const something = await new Promise(function (resolve_1, reject_1) { require(["./something"], resolve_1, reject_1); }); + }; +}); diff --git a/tests/baselines/reference/importCallExpressionInExportEqualsAMD.symbols b/tests/baselines/reference/importCallExpressionInExportEqualsAMD.symbols new file mode 100644 index 00000000000..cd8d7d38041 --- /dev/null +++ b/tests/baselines/reference/importCallExpressionInExportEqualsAMD.symbols @@ -0,0 +1,10 @@ +=== tests/cases/conformance/dynamicImport/something.ts === +export = 42; +No type information for this code. +No type information for this code.=== tests/cases/conformance/dynamicImport/index.ts === +export = async function() { + const something = await import("./something"); +>something : Symbol(something, Decl(index.ts, 1, 9)) +>"./something" : Symbol("tests/cases/conformance/dynamicImport/something", Decl(something.ts, 0, 0)) + +}; diff --git a/tests/baselines/reference/importCallExpressionInExportEqualsAMD.types b/tests/baselines/reference/importCallExpressionInExportEqualsAMD.types new file mode 100644 index 00000000000..b590130d1cf --- /dev/null +++ b/tests/baselines/reference/importCallExpressionInExportEqualsAMD.types @@ -0,0 +1,14 @@ +=== tests/cases/conformance/dynamicImport/something.ts === +export = 42; +No type information for this code. +No type information for this code.=== tests/cases/conformance/dynamicImport/index.ts === +export = async function() { +>async function() { const something = await import("./something");} : () => Promise + + const something = await import("./something"); +>something : 42 +>await import("./something") : 42 +>import("./something") : Promise<42> +>"./something" : "./something" + +}; diff --git a/tests/baselines/reference/importCallExpressionInExportEqualsCJS.js b/tests/baselines/reference/importCallExpressionInExportEqualsCJS.js new file mode 100644 index 00000000000..5d7e2816116 --- /dev/null +++ b/tests/baselines/reference/importCallExpressionInExportEqualsCJS.js @@ -0,0 +1,18 @@ +//// [tests/cases/conformance/dynamicImport/importCallExpressionInExportEqualsCJS.ts] //// + +//// [something.ts] +export = 42; + +//// [index.ts] +export = async function() { + const something = await import("./something"); +}; + +//// [something.js] +"use strict"; +module.exports = 42; +//// [index.js] +"use strict"; +module.exports = async function () { + const something = await Promise.resolve().then(function () { return require("./something"); }); +}; diff --git a/tests/baselines/reference/importCallExpressionInExportEqualsCJS.symbols b/tests/baselines/reference/importCallExpressionInExportEqualsCJS.symbols new file mode 100644 index 00000000000..cd8d7d38041 --- /dev/null +++ b/tests/baselines/reference/importCallExpressionInExportEqualsCJS.symbols @@ -0,0 +1,10 @@ +=== tests/cases/conformance/dynamicImport/something.ts === +export = 42; +No type information for this code. +No type information for this code.=== tests/cases/conformance/dynamicImport/index.ts === +export = async function() { + const something = await import("./something"); +>something : Symbol(something, Decl(index.ts, 1, 9)) +>"./something" : Symbol("tests/cases/conformance/dynamicImport/something", Decl(something.ts, 0, 0)) + +}; diff --git a/tests/baselines/reference/importCallExpressionInExportEqualsCJS.types b/tests/baselines/reference/importCallExpressionInExportEqualsCJS.types new file mode 100644 index 00000000000..b590130d1cf --- /dev/null +++ b/tests/baselines/reference/importCallExpressionInExportEqualsCJS.types @@ -0,0 +1,14 @@ +=== tests/cases/conformance/dynamicImport/something.ts === +export = 42; +No type information for this code. +No type information for this code.=== tests/cases/conformance/dynamicImport/index.ts === +export = async function() { +>async function() { const something = await import("./something");} : () => Promise + + const something = await import("./something"); +>something : 42 +>await import("./something") : 42 +>import("./something") : Promise<42> +>"./something" : "./something" + +}; diff --git a/tests/baselines/reference/importCallExpressionInExportEqualsUMD.js b/tests/baselines/reference/importCallExpressionInExportEqualsUMD.js new file mode 100644 index 00000000000..e0c6e2a925f --- /dev/null +++ b/tests/baselines/reference/importCallExpressionInExportEqualsUMD.js @@ -0,0 +1,39 @@ +//// [tests/cases/conformance/dynamicImport/importCallExpressionInExportEqualsUMD.ts] //// + +//// [something.ts] +export = 42; + +//// [index.ts] +export = async function() { + const something = await import("./something"); +}; + +//// [something.js] +(function (factory) { + if (typeof module === "object" && typeof module.exports === "object") { + var v = factory(require, exports); + if (v !== undefined) module.exports = v; + } + else if (typeof define === "function" && define.amd) { + define(["require", "exports"], factory); + } +})(function (require, exports) { + "use strict"; + return 42; +}); +//// [index.js] +(function (factory) { + if (typeof module === "object" && typeof module.exports === "object") { + var v = factory(require, exports); + if (v !== undefined) module.exports = v; + } + else if (typeof define === "function" && define.amd) { + define(["require", "exports"], factory); + } +})(function (require, exports) { + "use strict"; + var __syncRequire = typeof module === "object" && typeof module.exports === "object"; + return async function () { + const something = await (__syncRequire ? Promise.resolve().then(function () { return require("./something"); }) : new Promise(function (resolve_1, reject_1) { require(["./something"], resolve_1, reject_1); })); + }; +}); diff --git a/tests/baselines/reference/importCallExpressionInExportEqualsUMD.symbols b/tests/baselines/reference/importCallExpressionInExportEqualsUMD.symbols new file mode 100644 index 00000000000..cd8d7d38041 --- /dev/null +++ b/tests/baselines/reference/importCallExpressionInExportEqualsUMD.symbols @@ -0,0 +1,10 @@ +=== tests/cases/conformance/dynamicImport/something.ts === +export = 42; +No type information for this code. +No type information for this code.=== tests/cases/conformance/dynamicImport/index.ts === +export = async function() { + const something = await import("./something"); +>something : Symbol(something, Decl(index.ts, 1, 9)) +>"./something" : Symbol("tests/cases/conformance/dynamicImport/something", Decl(something.ts, 0, 0)) + +}; diff --git a/tests/baselines/reference/importCallExpressionInExportEqualsUMD.types b/tests/baselines/reference/importCallExpressionInExportEqualsUMD.types new file mode 100644 index 00000000000..b590130d1cf --- /dev/null +++ b/tests/baselines/reference/importCallExpressionInExportEqualsUMD.types @@ -0,0 +1,14 @@ +=== tests/cases/conformance/dynamicImport/something.ts === +export = 42; +No type information for this code. +No type information for this code.=== tests/cases/conformance/dynamicImport/index.ts === +export = async function() { +>async function() { const something = await import("./something");} : () => Promise + + const something = await import("./something"); +>something : 42 +>await import("./something") : 42 +>import("./something") : Promise<42> +>"./something" : "./something" + +}; diff --git a/tests/cases/conformance/dynamicImport/importCallExpressionInExportEqualsAMD.ts b/tests/cases/conformance/dynamicImport/importCallExpressionInExportEqualsAMD.ts new file mode 100644 index 00000000000..77f348bd3fa --- /dev/null +++ b/tests/cases/conformance/dynamicImport/importCallExpressionInExportEqualsAMD.ts @@ -0,0 +1,9 @@ +// @module: amd +// @target: esnext +// @filename: something.ts +export = 42; + +// @filename: index.ts +export = async function() { + const something = await import("./something"); +}; \ No newline at end of file diff --git a/tests/cases/conformance/dynamicImport/importCallExpressionInExportEqualsCJS.ts b/tests/cases/conformance/dynamicImport/importCallExpressionInExportEqualsCJS.ts new file mode 100644 index 00000000000..efda80d4995 --- /dev/null +++ b/tests/cases/conformance/dynamicImport/importCallExpressionInExportEqualsCJS.ts @@ -0,0 +1,9 @@ +// @module: commonjs +// @target: esnext +// @filename: something.ts +export = 42; + +// @filename: index.ts +export = async function() { + const something = await import("./something"); +}; \ No newline at end of file diff --git a/tests/cases/conformance/dynamicImport/importCallExpressionInExportEqualsUMD.ts b/tests/cases/conformance/dynamicImport/importCallExpressionInExportEqualsUMD.ts new file mode 100644 index 00000000000..fc0865914fb --- /dev/null +++ b/tests/cases/conformance/dynamicImport/importCallExpressionInExportEqualsUMD.ts @@ -0,0 +1,9 @@ +// @module: umd +// @target: esnext +// @filename: something.ts +export = 42; + +// @filename: index.ts +export = async function() { + const something = await import("./something"); +}; \ No newline at end of file From 62eaaf92069dc450128cd93320db877460722fde Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Thu, 24 Aug 2017 17:12:42 -0700 Subject: [PATCH 145/370] Fix crash when attempting to merge an import with a local declaration (#18032) * There should be no crash when attempting to merge an import with a local declaration * Show symbol has actually merged within the module --- src/compiler/checker.ts | 2 + .../noCrashOnImportShadowing.errors.txt | 33 +++++++++++++ .../reference/noCrashOnImportShadowing.js | 46 +++++++++++++++++++ .../compiler/noCrashOnImportShadowing.ts | 25 ++++++++++ 4 files changed, 106 insertions(+) create mode 100644 tests/baselines/reference/noCrashOnImportShadowing.errors.txt create mode 100644 tests/baselines/reference/noCrashOnImportShadowing.js create mode 100644 tests/cases/compiler/noCrashOnImportShadowing.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 4bdfa4b7250..4405a31db28 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -19180,6 +19180,8 @@ namespace ts { : DeclarationSpaces.ExportNamespace; case SyntaxKind.ClassDeclaration: case SyntaxKind.EnumDeclaration: + // A NamespaceImport declares an Alias, which is allowed to merge with other values within the module + case SyntaxKind.NamespaceImport: return DeclarationSpaces.ExportType | DeclarationSpaces.ExportValue; case SyntaxKind.ImportEqualsDeclaration: let result = DeclarationSpaces.None; diff --git a/tests/baselines/reference/noCrashOnImportShadowing.errors.txt b/tests/baselines/reference/noCrashOnImportShadowing.errors.txt new file mode 100644 index 00000000000..c1d1dbcdef1 --- /dev/null +++ b/tests/baselines/reference/noCrashOnImportShadowing.errors.txt @@ -0,0 +1,33 @@ +tests/cases/compiler/index.ts(4,1): error TS2693: 'B' only refers to a type, but is being used as a value here. +tests/cases/compiler/index.ts(9,10): error TS2304: Cannot find name 'OriginalB'. + + +==== tests/cases/compiler/b.ts (0 errors) ==== + export const zzz = 123; + +==== tests/cases/compiler/a.ts (0 errors) ==== + import * as B from "./b"; + + interface B { + x: string; + } + + const x: B = { x: "" }; + B.zzz; + + export { B }; + +==== tests/cases/compiler/index.ts (2 errors) ==== + import { B } from "./a"; + + const x: B = { x: "" }; + B.zzz; + ~ +!!! error TS2693: 'B' only refers to a type, but is being used as a value here. + + import * as OriginalB from "./b"; + OriginalB.zzz; + + const y: OriginalB = x; + ~~~~~~~~~ +!!! error TS2304: Cannot find name 'OriginalB'. \ No newline at end of file diff --git a/tests/baselines/reference/noCrashOnImportShadowing.js b/tests/baselines/reference/noCrashOnImportShadowing.js new file mode 100644 index 00000000000..7ca2116954d --- /dev/null +++ b/tests/baselines/reference/noCrashOnImportShadowing.js @@ -0,0 +1,46 @@ +//// [tests/cases/compiler/noCrashOnImportShadowing.ts] //// + +//// [b.ts] +export const zzz = 123; + +//// [a.ts] +import * as B from "./b"; + +interface B { + x: string; +} + +const x: B = { x: "" }; +B.zzz; + +export { B }; + +//// [index.ts] +import { B } from "./a"; + +const x: B = { x: "" }; +B.zzz; + +import * as OriginalB from "./b"; +OriginalB.zzz; + +const y: OriginalB = x; + +//// [b.js] +"use strict"; +exports.__esModule = true; +exports.zzz = 123; +//// [a.js] +"use strict"; +exports.__esModule = true; +var B = require("./b"); +var x = { x: "" }; +B.zzz; +//// [index.js] +"use strict"; +exports.__esModule = true; +var x = { x: "" }; +B.zzz; +var OriginalB = require("./b"); +OriginalB.zzz; +var y = x; diff --git a/tests/cases/compiler/noCrashOnImportShadowing.ts b/tests/cases/compiler/noCrashOnImportShadowing.ts new file mode 100644 index 00000000000..69e8b6a0f8c --- /dev/null +++ b/tests/cases/compiler/noCrashOnImportShadowing.ts @@ -0,0 +1,25 @@ +// @filename: b.ts +export const zzz = 123; + +// @filename: a.ts +import * as B from "./b"; + +interface B { + x: string; +} + +const x: B = { x: "" }; +B.zzz; + +export { B }; + +// @filename: index.ts +import { B } from "./a"; + +const x: B = { x: "" }; +B.zzz; + +import * as OriginalB from "./b"; +OriginalB.zzz; + +const y: OriginalB = x; \ No newline at end of file From 616bb5fcf61bd9059147224b3aff3ec153fa0bd3 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Fri, 25 Aug 2017 07:10:53 -0700 Subject: [PATCH 146/370] Defer mapped type indexed access transformations --- src/compiler/checker.ts | 59 +++++++++++++++++------------------------ 1 file changed, 24 insertions(+), 35 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 4a07f349c9a..338af6b3ba3 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -5906,10 +5906,6 @@ namespace ts { } function getConstraintOfIndexedAccess(type: IndexedAccessType) { - const transformed = getTransformedIndexedAccessType(type); - if (transformed) { - return transformed; - } const baseObjectType = getBaseConstraintOfType(type.objectType); const baseIndexType = getBaseConstraintOfType(type.indexType); return baseObjectType || baseIndexType ? getIndexedAccessType(baseObjectType || type.objectType, baseIndexType || type.indexType) : undefined; @@ -7596,22 +7592,6 @@ namespace ts { return anyType; } - function getIndexedAccessForMappedType(type: MappedType, indexType: Type, accessNode?: ElementAccessExpression | IndexedAccessTypeNode) { - if (accessNode) { - // Check if the index type is assignable to 'keyof T' for the object type. - if (!isTypeAssignableTo(indexType, getIndexType(type))) { - error(accessNode, Diagnostics.Type_0_cannot_be_used_to_index_type_1, typeToString(indexType), typeToString(type)); - return unknownType; - } - if (accessNode.kind === SyntaxKind.ElementAccessExpression && isAssignmentTarget(accessNode) && type.declaration.readonlyToken) { - error(accessNode, Diagnostics.Index_signature_in_type_0_only_permits_reading, typeToString(type)); - } - } - const mapper = createTypeMapper([getTypeParameterFromMappedType(type)], [indexType]); - const templateMapper = type.mapper ? combineTypeMappers(type.mapper, mapper) : mapper; - return instantiateType(getTemplateTypeFromMappedType(type), templateMapper); - } - function isGenericObjectType(type: Type): boolean { return type.flags & TypeFlags.TypeVariable ? true : getObjectFlags(type) & ObjectFlags.Mapped ? isGenericIndexType(getConstraintTypeFromMappedType(type)) : @@ -7637,12 +7617,14 @@ namespace ts { return false; } - // Given an indexed access type T[K], if T is an intersection containing one or more generic types and one or - // more object types with only a string index signature, e.g. '(U & V & { [x: string]: D })[K]', return a - // transformed type of the form '(U & V)[K] | D'. This allows us to properly reason about higher order indexed - // access types with default property values as expressed by D. + // Transform an indexed access occurring in a read position to a simpler form. Return the simpler form, + // or undefined if no transformation is possible. function getTransformedIndexedAccessType(type: IndexedAccessType): Type { const objectType = type.objectType; + // Given an indexed access type T[K], if T is an intersection containing one or more generic types and one or + // more object types with only a string index signature, e.g. '(U & V & { [x: string]: D })[K]', return a + // transformed type of the form '(U & V)[K] | D'. This allows us to properly reason about higher order indexed + // access types with default property values as expressed by D. if (objectType.flags & TypeFlags.Intersection && isGenericObjectType(objectType) && some((objectType).types, isStringIndexOnlyType)) { const regularTypes: Type[] = []; const stringIndexTypes: Type[] = []; @@ -7659,20 +7641,23 @@ namespace ts { getIntersectionType(stringIndexTypes) ]); } + // If the object type is a mapped type { [P in K]: E }, where K is generic, instantiate E using a mapper + // that substitutes the index type for P. For example, for an index access { [P in K]: Box }[X], we + // construct the type Box. + if (isGenericMappedType(objectType)) { + const mapper = createTypeMapper([getTypeParameterFromMappedType(objectType)], [type.indexType]); + const objectTypeMapper = (objectType).mapper; + const templateMapper = objectTypeMapper ? combineTypeMappers(objectTypeMapper, mapper) : mapper; + return instantiateType(getTemplateTypeFromMappedType(objectType), templateMapper); + } return undefined; } function getIndexedAccessType(objectType: Type, indexType: Type, accessNode?: ElementAccessExpression | IndexedAccessTypeNode): Type { - // If the object type is a mapped type { [P in K]: E }, where K is generic, we instantiate E using a mapper - // that substitutes the index type for P. For example, for an index access { [P in K]: Box }[X], we - // construct the type Box. - if (isGenericMappedType(objectType)) { - return getIndexedAccessForMappedType(objectType, indexType, accessNode); - } - // Otherwise, if the index type is generic, or if the object type is generic and doesn't originate in an - // expression, we are performing a higher-order index access where we cannot meaningfully access the properties - // of the object type. Note that for a generic T and a non-generic K, we eagerly resolve T[K] if it originates - // in an expression. This is to preserve backwards compatibility. For example, an element access 'this["foo"]' + // If the index type is generic, or if the object type is generic and doesn't originate in an expression, + // we are performing a higher-order index access where we cannot meaningfully access the properties of the + // object type. Note that for a generic T and a non-generic K, we eagerly resolve T[K] if it originates in + // an expression. This is to preserve backwards compatibility. For example, an element access 'this["foo"]' // has always been resolved eagerly using the constraint type of 'this' at the given location. if (isGenericIndexType(indexType) || !(accessNode && accessNode.kind === SyntaxKind.ElementAccessExpression) && isGenericObjectType(objectType)) { if (objectType.flags & TypeFlags.Any) { @@ -9334,7 +9319,7 @@ namespace ts { else if (source.flags & TypeFlags.IndexedAccess) { // A type S[K] is related to a type T if A[K] is related to T, where K is string-like and // A is the apparent type of S. - const constraint = getConstraintOfType(source); + const constraint = getTransformedIndexedAccessType(source) || getConstraintOfIndexedAccess(source); if (constraint) { if (result = isRelatedTo(constraint, target, reportErrors)) { errorInfo = saveErrorInfo; @@ -18810,6 +18795,10 @@ namespace ts { const objectType = (type).objectType; const indexType = (type).indexType; if (isTypeAssignableTo(indexType, getIndexType(objectType))) { + if (accessNode.kind === SyntaxKind.ElementAccessExpression && isAssignmentTarget(accessNode) && + getObjectFlags(objectType) & ObjectFlags.Mapped && (objectType).declaration.readonlyToken) { + error(accessNode, Diagnostics.Index_signature_in_type_0_only_permits_reading, typeToString(objectType)); + } return type; } // Check if we're indexing with a numeric type and if either object or index types From 3d3ed04b2868f5b74a6326f1eec8988e98309aca Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Fri, 25 Aug 2017 08:49:34 -0700 Subject: [PATCH 147/370] Perform indexed access type transformations consistently --- src/compiler/checker.ts | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 338af6b3ba3..4d08292a9f2 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -5906,6 +5906,10 @@ namespace ts { } function getConstraintOfIndexedAccess(type: IndexedAccessType) { + const transformed = getTransformedIndexedAccessType(type); + if (transformed) { + return transformed; + } const baseObjectType = getBaseConstraintOfType(type.objectType); const baseIndexType = getBaseConstraintOfType(type.indexType); return baseObjectType || baseIndexType ? getIndexedAccessType(baseObjectType || type.objectType, baseIndexType || type.indexType) : undefined; @@ -7617,8 +7621,8 @@ namespace ts { return false; } - // Transform an indexed access occurring in a read position to a simpler form. Return the simpler form, - // or undefined if no transformation is possible. + // Transform an indexed access to a simpler form, if possible. Return the simpler form, or return + // undefined if no transformation is possible. function getTransformedIndexedAccessType(type: IndexedAccessType): Type { const objectType = type.objectType; // Given an indexed access type T[K], if T is an intersection containing one or more generic types and one or @@ -9279,7 +9283,7 @@ namespace ts { else if (target.flags & TypeFlags.IndexedAccess) { // A type S is related to a type T[K] if S is related to A[K], where K is string-like and // A is the apparent type of S. - const constraint = getConstraintOfType(target); + const constraint = getConstraintOfIndexedAccess(target); if (constraint) { if (result = isRelatedTo(source, constraint, reportErrors)) { errorInfo = saveErrorInfo; @@ -9319,7 +9323,7 @@ namespace ts { else if (source.flags & TypeFlags.IndexedAccess) { // A type S[K] is related to a type T if A[K] is related to T, where K is string-like and // A is the apparent type of S. - const constraint = getTransformedIndexedAccessType(source) || getConstraintOfIndexedAccess(source); + const constraint = getConstraintOfIndexedAccess(source); if (constraint) { if (result = isRelatedTo(constraint, target, reportErrors)) { errorInfo = saveErrorInfo; From cf998bf35095674a3cd7aa85b020d66ad5e3d7b8 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Fri, 25 Aug 2017 08:49:59 -0700 Subject: [PATCH 148/370] Accept new baselines --- .../isomorphicMappedTypeInference.types | 6 +- tests/baselines/reference/keyofAndForIn.types | 24 +- .../reference/keyofAndIndexedAccess.types | 2 +- .../mappedTypeRelationships.errors.txt | 206 +++++++++++------- tests/baselines/reference/mappedTypes4.types | 2 +- .../reference/typeGuardsTypeParameters.types | 8 +- 6 files changed, 154 insertions(+), 94 deletions(-) diff --git a/tests/baselines/reference/isomorphicMappedTypeInference.types b/tests/baselines/reference/isomorphicMappedTypeInference.types index c3414f46017..2e13f69c5eb 100644 --- a/tests/baselines/reference/isomorphicMappedTypeInference.types +++ b/tests/baselines/reference/isomorphicMappedTypeInference.types @@ -69,7 +69,7 @@ function boxify(obj: T): Boxified { result[k] = box(obj[k]); >result[k] = box(obj[k]) : Box ->result[k] : Box +>result[k] : Boxified[keyof T] >result : Boxified >k : keyof T >box(obj[k]) : Box @@ -107,7 +107,7 @@ function unboxify(obj: Boxified): T { >k : keyof T >unbox(obj[k]) : T[keyof T] >unbox : (x: Box) => T ->obj[k] : Box +>obj[k] : Boxified[keyof T] >obj : Boxified >k : keyof T } @@ -131,7 +131,7 @@ function assignBoxified(obj: Boxified, values: T) { obj[k].value = values[k]; >obj[k].value = values[k] : T[keyof T] >obj[k].value : T[keyof T] ->obj[k] : Box +>obj[k] : Boxified[keyof T] >obj : Boxified >k : keyof T >value : T[keyof T] diff --git a/tests/baselines/reference/keyofAndForIn.types b/tests/baselines/reference/keyofAndForIn.types index d20f1a57070..c4997c05bfe 100644 --- a/tests/baselines/reference/keyofAndForIn.types +++ b/tests/baselines/reference/keyofAndForIn.types @@ -27,8 +27,8 @@ function f1(obj: { [P in K]: T }, k: K) { >obj : { [P in K]: T; } let x1 = obj[k1]; ->x1 : T ->obj[k1] : T +>x1 : { [P in K]: T; }[K] +>obj[k1] : { [P in K]: T; }[K] >obj : { [P in K]: T; } >k1 : K } @@ -37,8 +37,8 @@ function f1(obj: { [P in K]: T }, k: K) { >obj : { [P in K]: T; } let x2 = obj[k2]; ->x2 : T ->obj[k2] : T +>x2 : { [P in K]: T; }[K] +>obj[k2] : { [P in K]: T; }[K] >obj : { [P in K]: T; } >k2 : K } @@ -70,8 +70,8 @@ function f2(obj: { [P in keyof T]: T[P] }, k: keyof T) { >obj : { [P in keyof T]: T[P]; } let x1 = obj[k1]; ->x1 : T[keyof T] ->obj[k1] : T[keyof T] +>x1 : { [P in keyof T]: T[P]; }[keyof T] +>obj[k1] : { [P in keyof T]: T[P]; }[keyof T] >obj : { [P in keyof T]: T[P]; } >k1 : keyof T } @@ -80,8 +80,8 @@ function f2(obj: { [P in keyof T]: T[P] }, k: keyof T) { >obj : { [P in keyof T]: T[P]; } let x2 = obj[k2]; ->x2 : T[keyof T] ->obj[k2] : T[keyof T] +>x2 : { [P in keyof T]: T[P]; }[keyof T] +>obj[k2] : { [P in keyof T]: T[P]; }[keyof T] >obj : { [P in keyof T]: T[P]; } >k2 : keyof T } @@ -115,8 +115,8 @@ function f3(obj: { [P in K]: T[P] }, k: K) { >obj : { [P in K]: T[P]; } let x1 = obj[k1]; ->x1 : T[K] ->obj[k1] : T[K] +>x1 : { [P in K]: T[P]; }[K] +>obj[k1] : { [P in K]: T[P]; }[K] >obj : { [P in K]: T[P]; } >k1 : K } @@ -125,8 +125,8 @@ function f3(obj: { [P in K]: T[P] }, k: K) { >obj : { [P in K]: T[P]; } let x2 = obj[k2]; ->x2 : T[K] ->obj[k2] : T[K] +>x2 : { [P in K]: T[P]; }[K] +>obj[k2] : { [P in K]: T[P]; }[K] >obj : { [P in K]: T[P]; } >k2 : K } diff --git a/tests/baselines/reference/keyofAndIndexedAccess.types b/tests/baselines/reference/keyofAndIndexedAccess.types index 671289527aa..25d79e3f4ff 100644 --- a/tests/baselines/reference/keyofAndIndexedAccess.types +++ b/tests/baselines/reference/keyofAndIndexedAccess.types @@ -2194,7 +2194,7 @@ class Form { this.childFormFactories[prop](value) >this.childFormFactories[prop](value) : Form ->this.childFormFactories[prop] : (v: T[K]) => Form +>this.childFormFactories[prop] : { [K in keyof T]: (v: T[K]) => Form; }[K] >this.childFormFactories : { [K in keyof T]: (v: T[K]) => Form; } >this : this >childFormFactories : { [K in keyof T]: (v: T[K]) => Form; } diff --git a/tests/baselines/reference/mappedTypeRelationships.errors.txt b/tests/baselines/reference/mappedTypeRelationships.errors.txt index a1e1455b419..1ea0c5a2612 100644 --- a/tests/baselines/reference/mappedTypeRelationships.errors.txt +++ b/tests/baselines/reference/mappedTypeRelationships.errors.txt @@ -26,17 +26,64 @@ tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(26,5): error TS2 Type 'T[string]' is not assignable to type 'U[string]'. Type 'T' is not assignable to type 'U'. tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(26,12): error TS2536: Type 'K' cannot be used to index type 'T'. -tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(30,5): error TS2322: Type 'T[keyof T] | undefined' is not assignable to type 'T[keyof T]'. - Type 'undefined' is not assignable to type 'T[keyof T]'. - Type 'undefined' is not assignable to type 'T[string]'. -tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(35,5): error TS2322: Type 'T[K] | undefined' is not assignable to type 'T[K]'. - Type 'undefined' is not assignable to type 'T[K]'. - Type 'undefined' is not assignable to type 'T[string]'. -tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(40,5): error TS2322: Type 'U[keyof T] | undefined' is not assignable to type 'T[keyof T]'. - Type 'undefined' is not assignable to type 'T[keyof T]'. - Type 'undefined' is not assignable to type 'T[string]'. -tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(41,5): error TS2322: Type 'T[keyof T]' is not assignable to type 'U[keyof T] | undefined'. - Type 'T[string]' is not assignable to type 'U[keyof T] | undefined'. +tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(30,5): error TS2322: Type 'Partial[keyof T]' is not assignable to type 'T[keyof T]'. + Type 'T[keyof T] | undefined' is not assignable to type 'T[keyof T]'. + Type 'undefined' is not assignable to type 'T[keyof T]'. + Type 'undefined' is not assignable to type 'T[string]'. + Type 'Partial[keyof T]' is not assignable to type 'T[string]'. + Type 'T[keyof T] | undefined' is not assignable to type 'T[string]'. + Type 'undefined' is not assignable to type 'T[string]'. +tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(35,5): error TS2322: Type 'Partial[K]' is not assignable to type 'T[K]'. + Type 'T[K] | undefined' is not assignable to type 'T[K]'. + Type 'undefined' is not assignable to type 'T[K]'. + Type 'undefined' is not assignable to type 'T[string]'. + Type 'Partial[K]' is not assignable to type 'T[string]'. + Type 'T[K] | undefined' is not assignable to type 'T[string]'. + Type 'undefined' is not assignable to type 'T[string]'. +tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(40,5): error TS2322: Type 'Partial[keyof T]' is not assignable to type 'T[keyof T]'. + Type 'U[keyof T] | undefined' is not assignable to type 'T[keyof T]'. + Type 'undefined' is not assignable to type 'T[keyof T]'. + Type 'undefined' is not assignable to type 'T[string]'. + Type 'Partial[keyof T]' is not assignable to type 'T[string]'. + Type 'U[keyof T] | undefined' is not assignable to type 'T[string]'. + Type 'undefined' is not assignable to type 'T[string]'. +tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(41,5): error TS2322: Type 'T[keyof T]' is not assignable to type 'Partial[keyof T]'. + Type 'T[string]' is not assignable to type 'Partial[keyof T]'. + Type 'T[string]' is not assignable to type 'U[keyof T] | undefined'. + Type 'T[string]' is not assignable to type 'U[keyof T]'. + Type 'T[keyof T]' is not assignable to type 'U[keyof T] | undefined'. + Type 'T[string]' is not assignable to type 'U[keyof T] | undefined'. + Type 'T[string]' is not assignable to type 'U[keyof T]'. + Type 'T[keyof T]' is not assignable to type 'U[keyof T]'. + Type 'T[string]' is not assignable to type 'U[keyof T]'. + Type 'T[string]' is not assignable to type 'U[string]'. + Type 'T[keyof T]' is not assignable to type 'U[string]'. + Type 'T[string]' is not assignable to type 'U[string]'. + Type 'T' is not assignable to type 'U'. +tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(45,5): error TS2322: Type 'Partial[K]' is not assignable to type 'T[K]'. + Type 'U[K] | undefined' is not assignable to type 'T[K]'. + Type 'undefined' is not assignable to type 'T[K]'. + Type 'undefined' is not assignable to type 'T[string]'. + Type 'Partial[K]' is not assignable to type 'T[string]'. + Type 'U[K] | undefined' is not assignable to type 'T[string]'. + Type 'undefined' is not assignable to type 'T[string]'. +tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(46,5): error TS2322: Type 'T[K]' is not assignable to type 'Partial[K]'. + Type 'T[string]' is not assignable to type 'Partial[K]'. + Type 'T[string]' is not assignable to type 'U[K] | undefined'. + Type 'T[string]' is not assignable to type 'U[K]'. + Type 'T[K]' is not assignable to type 'U[K] | undefined'. + Type 'T[string]' is not assignable to type 'U[K] | undefined'. + Type 'T[string]' is not assignable to type 'U[K]'. + Type 'T[K]' is not assignable to type 'U[K]'. + Type 'T[string]' is not assignable to type 'U[K]'. + Type 'T[string]' is not assignable to type 'U[string]'. + Type 'T[K]' is not assignable to type 'U[string]'. + Type 'T[string]' is not assignable to type 'U[string]'. + Type 'T' is not assignable to type 'U'. +tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(51,5): error TS2542: Index signature in type 'Readonly' only permits reading. +tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(56,5): error TS2542: Index signature in type 'Readonly' only permits reading. +tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(61,5): error TS2322: Type 'T[keyof T]' is not assignable to type 'Readonly[keyof T]'. + Type 'T[string]' is not assignable to type 'Readonly[keyof T]'. Type 'T[string]' is not assignable to type 'U[keyof T]'. Type 'T[keyof T]' is not assignable to type 'U[keyof T]'. Type 'T[string]' is not assignable to type 'U[keyof T]'. @@ -44,11 +91,9 @@ tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(41,5): error TS2 Type 'T[keyof T]' is not assignable to type 'U[string]'. Type 'T[string]' is not assignable to type 'U[string]'. Type 'T' is not assignable to type 'U'. -tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(45,5): error TS2322: Type 'U[K] | undefined' is not assignable to type 'T[K]'. - Type 'undefined' is not assignable to type 'T[K]'. - Type 'undefined' is not assignable to type 'T[string]'. -tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(46,5): error TS2322: Type 'T[K]' is not assignable to type 'U[K] | undefined'. - Type 'T[string]' is not assignable to type 'U[K] | undefined'. +tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(61,5): error TS2542: Index signature in type 'Readonly' only permits reading. +tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(66,5): error TS2322: Type 'T[K]' is not assignable to type 'Readonly[K]'. + Type 'T[string]' is not assignable to type 'Readonly[K]'. Type 'T[string]' is not assignable to type 'U[K]'. Type 'T[K]' is not assignable to type 'U[K]'. Type 'T[string]' is not assignable to type 'U[K]'. @@ -56,21 +101,6 @@ tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(46,5): error TS2 Type 'T[K]' is not assignable to type 'U[string]'. Type 'T[string]' is not assignable to type 'U[string]'. Type 'T' is not assignable to type 'U'. -tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(51,5): error TS2542: Index signature in type 'Readonly' only permits reading. -tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(56,5): error TS2542: Index signature in type 'Readonly' only permits reading. -tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(61,5): error TS2322: Type 'T[keyof T]' is not assignable to type 'U[keyof T]'. - Type 'T[string]' is not assignable to type 'U[keyof T]'. - Type 'T[string]' is not assignable to type 'U[string]'. - Type 'T[keyof T]' is not assignable to type 'U[string]'. - Type 'T[string]' is not assignable to type 'U[string]'. - Type 'T' is not assignable to type 'U'. -tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(61,5): error TS2542: Index signature in type 'Readonly' only permits reading. -tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(66,5): error TS2322: Type 'T[K]' is not assignable to type 'U[K]'. - Type 'T[string]' is not assignable to type 'U[K]'. - Type 'T[string]' is not assignable to type 'U[string]'. - Type 'T[K]' is not assignable to type 'U[string]'. - Type 'T[string]' is not assignable to type 'U[string]'. - Type 'T' is not assignable to type 'U'. tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(66,5): error TS2542: Index signature in type 'Readonly' only permits reading. tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(72,5): error TS2322: Type 'Partial' is not assignable to type 'T'. tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(78,5): error TS2322: Type 'Partial' is not assignable to type 'Partial'. @@ -168,57 +198,81 @@ tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(168,5): error TS function f10(x: T, y: Partial, k: keyof T) { x[k] = y[k]; // Error ~~~~ -!!! error TS2322: Type 'T[keyof T] | undefined' is not assignable to type 'T[keyof T]'. -!!! error TS2322: Type 'undefined' is not assignable to type 'T[keyof T]'. -!!! error TS2322: Type 'undefined' is not assignable to type 'T[string]'. +!!! error TS2322: Type 'Partial[keyof T]' is not assignable to type 'T[keyof T]'. +!!! error TS2322: Type 'T[keyof T] | undefined' is not assignable to type 'T[keyof T]'. +!!! error TS2322: Type 'undefined' is not assignable to type 'T[keyof T]'. +!!! error TS2322: Type 'undefined' is not assignable to type 'T[string]'. +!!! error TS2322: Type 'Partial[keyof T]' is not assignable to type 'T[string]'. +!!! error TS2322: Type 'T[keyof T] | undefined' is not assignable to type 'T[string]'. +!!! error TS2322: Type 'undefined' is not assignable to type 'T[string]'. y[k] = x[k]; } function f11(x: T, y: Partial, k: K) { x[k] = y[k]; // Error ~~~~ -!!! error TS2322: Type 'T[K] | undefined' is not assignable to type 'T[K]'. -!!! error TS2322: Type 'undefined' is not assignable to type 'T[K]'. -!!! error TS2322: Type 'undefined' is not assignable to type 'T[string]'. +!!! error TS2322: Type 'Partial[K]' is not assignable to type 'T[K]'. +!!! error TS2322: Type 'T[K] | undefined' is not assignable to type 'T[K]'. +!!! error TS2322: Type 'undefined' is not assignable to type 'T[K]'. +!!! error TS2322: Type 'undefined' is not assignable to type 'T[string]'. +!!! error TS2322: Type 'Partial[K]' is not assignable to type 'T[string]'. +!!! error TS2322: Type 'T[K] | undefined' is not assignable to type 'T[string]'. +!!! error TS2322: Type 'undefined' is not assignable to type 'T[string]'. y[k] = x[k]; } function f12(x: T, y: Partial, k: keyof T) { x[k] = y[k]; // Error ~~~~ -!!! error TS2322: Type 'U[keyof T] | undefined' is not assignable to type 'T[keyof T]'. -!!! error TS2322: Type 'undefined' is not assignable to type 'T[keyof T]'. -!!! error TS2322: Type 'undefined' is not assignable to type 'T[string]'. +!!! error TS2322: Type 'Partial[keyof T]' is not assignable to type 'T[keyof T]'. +!!! error TS2322: Type 'U[keyof T] | undefined' is not assignable to type 'T[keyof T]'. +!!! error TS2322: Type 'undefined' is not assignable to type 'T[keyof T]'. +!!! error TS2322: Type 'undefined' is not assignable to type 'T[string]'. +!!! error TS2322: Type 'Partial[keyof T]' is not assignable to type 'T[string]'. +!!! error TS2322: Type 'U[keyof T] | undefined' is not assignable to type 'T[string]'. +!!! error TS2322: Type 'undefined' is not assignable to type 'T[string]'. y[k] = x[k]; // Error ~~~~ -!!! error TS2322: Type 'T[keyof T]' is not assignable to type 'U[keyof T] | undefined'. -!!! error TS2322: Type 'T[string]' is not assignable to type 'U[keyof T] | undefined'. -!!! error TS2322: Type 'T[string]' is not assignable to type 'U[keyof T]'. -!!! error TS2322: Type 'T[keyof T]' is not assignable to type 'U[keyof T]'. -!!! error TS2322: Type 'T[string]' is not assignable to type 'U[keyof T]'. -!!! error TS2322: Type 'T[string]' is not assignable to type 'U[string]'. -!!! error TS2322: Type 'T[keyof T]' is not assignable to type 'U[string]'. -!!! error TS2322: Type 'T[string]' is not assignable to type 'U[string]'. -!!! error TS2322: Type 'T' is not assignable to type 'U'. +!!! error TS2322: Type 'T[keyof T]' is not assignable to type 'Partial[keyof T]'. +!!! error TS2322: Type 'T[string]' is not assignable to type 'Partial[keyof T]'. +!!! error TS2322: Type 'T[string]' is not assignable to type 'U[keyof T] | undefined'. +!!! error TS2322: Type 'T[string]' is not assignable to type 'U[keyof T]'. +!!! error TS2322: Type 'T[keyof T]' is not assignable to type 'U[keyof T] | undefined'. +!!! error TS2322: Type 'T[string]' is not assignable to type 'U[keyof T] | undefined'. +!!! error TS2322: Type 'T[string]' is not assignable to type 'U[keyof T]'. +!!! error TS2322: Type 'T[keyof T]' is not assignable to type 'U[keyof T]'. +!!! error TS2322: Type 'T[string]' is not assignable to type 'U[keyof T]'. +!!! error TS2322: Type 'T[string]' is not assignable to type 'U[string]'. +!!! error TS2322: Type 'T[keyof T]' is not assignable to type 'U[string]'. +!!! error TS2322: Type 'T[string]' is not assignable to type 'U[string]'. +!!! error TS2322: Type 'T' is not assignable to type 'U'. } function f13(x: T, y: Partial, k: K) { x[k] = y[k]; // Error ~~~~ -!!! error TS2322: Type 'U[K] | undefined' is not assignable to type 'T[K]'. -!!! error TS2322: Type 'undefined' is not assignable to type 'T[K]'. -!!! error TS2322: Type 'undefined' is not assignable to type 'T[string]'. +!!! error TS2322: Type 'Partial[K]' is not assignable to type 'T[K]'. +!!! error TS2322: Type 'U[K] | undefined' is not assignable to type 'T[K]'. +!!! error TS2322: Type 'undefined' is not assignable to type 'T[K]'. +!!! error TS2322: Type 'undefined' is not assignable to type 'T[string]'. +!!! error TS2322: Type 'Partial[K]' is not assignable to type 'T[string]'. +!!! error TS2322: Type 'U[K] | undefined' is not assignable to type 'T[string]'. +!!! error TS2322: Type 'undefined' is not assignable to type 'T[string]'. y[k] = x[k]; // Error ~~~~ -!!! error TS2322: Type 'T[K]' is not assignable to type 'U[K] | undefined'. -!!! error TS2322: Type 'T[string]' is not assignable to type 'U[K] | undefined'. -!!! error TS2322: Type 'T[string]' is not assignable to type 'U[K]'. -!!! error TS2322: Type 'T[K]' is not assignable to type 'U[K]'. -!!! error TS2322: Type 'T[string]' is not assignable to type 'U[K]'. -!!! error TS2322: Type 'T[string]' is not assignable to type 'U[string]'. -!!! error TS2322: Type 'T[K]' is not assignable to type 'U[string]'. -!!! error TS2322: Type 'T[string]' is not assignable to type 'U[string]'. -!!! error TS2322: Type 'T' is not assignable to type 'U'. +!!! error TS2322: Type 'T[K]' is not assignable to type 'Partial[K]'. +!!! error TS2322: Type 'T[string]' is not assignable to type 'Partial[K]'. +!!! error TS2322: Type 'T[string]' is not assignable to type 'U[K] | undefined'. +!!! error TS2322: Type 'T[string]' is not assignable to type 'U[K]'. +!!! error TS2322: Type 'T[K]' is not assignable to type 'U[K] | undefined'. +!!! error TS2322: Type 'T[string]' is not assignable to type 'U[K] | undefined'. +!!! error TS2322: Type 'T[string]' is not assignable to type 'U[K]'. +!!! error TS2322: Type 'T[K]' is not assignable to type 'U[K]'. +!!! error TS2322: Type 'T[string]' is not assignable to type 'U[K]'. +!!! error TS2322: Type 'T[string]' is not assignable to type 'U[string]'. +!!! error TS2322: Type 'T[K]' is not assignable to type 'U[string]'. +!!! error TS2322: Type 'T[string]' is not assignable to type 'U[string]'. +!!! error TS2322: Type 'T' is not assignable to type 'U'. } function f20(x: T, y: Readonly, k: keyof T) { @@ -239,12 +293,15 @@ tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(168,5): error TS x[k] = y[k]; y[k] = x[k]; // Error ~~~~ -!!! error TS2322: Type 'T[keyof T]' is not assignable to type 'U[keyof T]'. -!!! error TS2322: Type 'T[string]' is not assignable to type 'U[keyof T]'. -!!! error TS2322: Type 'T[string]' is not assignable to type 'U[string]'. -!!! error TS2322: Type 'T[keyof T]' is not assignable to type 'U[string]'. -!!! error TS2322: Type 'T[string]' is not assignable to type 'U[string]'. -!!! error TS2322: Type 'T' is not assignable to type 'U'. +!!! error TS2322: Type 'T[keyof T]' is not assignable to type 'Readonly[keyof T]'. +!!! error TS2322: Type 'T[string]' is not assignable to type 'Readonly[keyof T]'. +!!! error TS2322: Type 'T[string]' is not assignable to type 'U[keyof T]'. +!!! error TS2322: Type 'T[keyof T]' is not assignable to type 'U[keyof T]'. +!!! error TS2322: Type 'T[string]' is not assignable to type 'U[keyof T]'. +!!! error TS2322: Type 'T[string]' is not assignable to type 'U[string]'. +!!! error TS2322: Type 'T[keyof T]' is not assignable to type 'U[string]'. +!!! error TS2322: Type 'T[string]' is not assignable to type 'U[string]'. +!!! error TS2322: Type 'T' is not assignable to type 'U'. ~~~~ !!! error TS2542: Index signature in type 'Readonly' only permits reading. } @@ -253,12 +310,15 @@ tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(168,5): error TS x[k] = y[k]; y[k] = x[k]; // Error ~~~~ -!!! error TS2322: Type 'T[K]' is not assignable to type 'U[K]'. -!!! error TS2322: Type 'T[string]' is not assignable to type 'U[K]'. -!!! error TS2322: Type 'T[string]' is not assignable to type 'U[string]'. -!!! error TS2322: Type 'T[K]' is not assignable to type 'U[string]'. -!!! error TS2322: Type 'T[string]' is not assignable to type 'U[string]'. -!!! error TS2322: Type 'T' is not assignable to type 'U'. +!!! error TS2322: Type 'T[K]' is not assignable to type 'Readonly[K]'. +!!! error TS2322: Type 'T[string]' is not assignable to type 'Readonly[K]'. +!!! error TS2322: Type 'T[string]' is not assignable to type 'U[K]'. +!!! error TS2322: Type 'T[K]' is not assignable to type 'U[K]'. +!!! error TS2322: Type 'T[string]' is not assignable to type 'U[K]'. +!!! error TS2322: Type 'T[string]' is not assignable to type 'U[string]'. +!!! error TS2322: Type 'T[K]' is not assignable to type 'U[string]'. +!!! error TS2322: Type 'T[string]' is not assignable to type 'U[string]'. +!!! error TS2322: Type 'T' is not assignable to type 'U'. ~~~~ !!! error TS2542: Index signature in type 'Readonly' only permits reading. } diff --git a/tests/baselines/reference/mappedTypes4.types b/tests/baselines/reference/mappedTypes4.types index 30e7eb2431b..c003765d517 100644 --- a/tests/baselines/reference/mappedTypes4.types +++ b/tests/baselines/reference/mappedTypes4.types @@ -45,7 +45,7 @@ function boxify(obj: T): Boxified { result[k] = { value: obj[k] }; >result[k] = { value: obj[k] } : { value: T[keyof T]; } ->result[k] : Box +>result[k] : Boxified[keyof T] >result : Boxified >k : keyof T >{ value: obj[k] } : { value: T[keyof T]; } diff --git a/tests/baselines/reference/typeGuardsTypeParameters.types b/tests/baselines/reference/typeGuardsTypeParameters.types index 82a52a46b86..13fb9965235 100644 --- a/tests/baselines/reference/typeGuardsTypeParameters.types +++ b/tests/baselines/reference/typeGuardsTypeParameters.types @@ -84,15 +84,15 @@ function fun(item: { [P in keyof T]: T[P] }) { >item : { [P in keyof T]: T[P]; } const value = item[key]; ->value : T[keyof T] ->item[key] : T[keyof T] +>value : { [P in keyof T]: T[P]; }[keyof T] +>item[key] : { [P in keyof T]: T[P]; }[keyof T] >item : { [P in keyof T]: T[P]; } >key : keyof T if (typeof value === "string") { >typeof value === "string" : boolean >typeof value : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" ->value : T[keyof T] +>value : { [P in keyof T]: T[P]; }[keyof T] >"string" : "string" strings.push(value); @@ -100,7 +100,7 @@ function fun(item: { [P in keyof T]: T[P] }) { >strings.push : (...items: string[]) => number >strings : string[] >push : (...items: string[]) => number ->value : T[keyof T] & string +>value : { [P in keyof T]: T[P]; }[keyof T] & string } } } From e79d75a383f7d540eba2859ea4a5a1fb5f80e9e5 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Fri, 25 Aug 2017 08:55:43 -0700 Subject: [PATCH 149/370] Add regression test --- .../mappedTypeIndexedAccess.errors.txt | 49 +++++++++++++++++++ .../reference/mappedTypeIndexedAccess.js | 43 ++++++++++++++++ .../cases/compiler/mappedTypeIndexedAccess.ts | 29 +++++++++++ 3 files changed, 121 insertions(+) create mode 100644 tests/baselines/reference/mappedTypeIndexedAccess.errors.txt create mode 100644 tests/baselines/reference/mappedTypeIndexedAccess.js create mode 100644 tests/cases/compiler/mappedTypeIndexedAccess.ts diff --git a/tests/baselines/reference/mappedTypeIndexedAccess.errors.txt b/tests/baselines/reference/mappedTypeIndexedAccess.errors.txt new file mode 100644 index 00000000000..24eae941c61 --- /dev/null +++ b/tests/baselines/reference/mappedTypeIndexedAccess.errors.txt @@ -0,0 +1,49 @@ +tests/cases/compiler/mappedTypeIndexedAccess.ts(18,5): error TS2322: Type '{ key: "foo"; value: number; }' is not assignable to type '{ key: "foo"; value: string; } | { key: "bar"; value: number; }'. + Type '{ key: "foo"; value: number; }' is not assignable to type '{ key: "foo"; value: string; }'. + Types of property 'value' are incompatible. + Type 'number' is not assignable to type 'string'. +tests/cases/compiler/mappedTypeIndexedAccess.ts(24,5): error TS2322: Type '{ key: "foo"; value: number; }' is not assignable to type '{ key: "foo"; value: string; } | { key: "bar"; value: number; }'. + Type '{ key: "foo"; value: number; }' is not assignable to type '{ key: "foo"; value: string; }'. + Types of property 'value' are incompatible. + Type 'number' is not assignable to type 'string'. + + +==== tests/cases/compiler/mappedTypeIndexedAccess.ts (2 errors) ==== + // Repro from #15756 + + type Pairs = { + [TKey in keyof T]: { + key: TKey; + value: T[TKey]; + }; + }; + + type Pair = Pairs[keyof T]; + + type FooBar = { + foo: string; + bar: number; + }; + + // Error expected here + let pair1: Pair = { + ~~~~~ +!!! error TS2322: Type '{ key: "foo"; value: number; }' is not assignable to type '{ key: "foo"; value: string; } | { key: "bar"; value: number; }'. +!!! error TS2322: Type '{ key: "foo"; value: number; }' is not assignable to type '{ key: "foo"; value: string; }'. +!!! error TS2322: Types of property 'value' are incompatible. +!!! error TS2322: Type 'number' is not assignable to type 'string'. + key: "foo", + value: 3 + }; + + // Error expected here + let pair2: Pairs[keyof FooBar] = { + ~~~~~ +!!! error TS2322: Type '{ key: "foo"; value: number; }' is not assignable to type '{ key: "foo"; value: string; } | { key: "bar"; value: number; }'. +!!! error TS2322: Type '{ key: "foo"; value: number; }' is not assignable to type '{ key: "foo"; value: string; }'. +!!! error TS2322: Types of property 'value' are incompatible. +!!! error TS2322: Type 'number' is not assignable to type 'string'. + key: "foo", + value: 3 + }; + \ No newline at end of file diff --git a/tests/baselines/reference/mappedTypeIndexedAccess.js b/tests/baselines/reference/mappedTypeIndexedAccess.js new file mode 100644 index 00000000000..60af082a6b9 --- /dev/null +++ b/tests/baselines/reference/mappedTypeIndexedAccess.js @@ -0,0 +1,43 @@ +//// [mappedTypeIndexedAccess.ts] +// Repro from #15756 + +type Pairs = { + [TKey in keyof T]: { + key: TKey; + value: T[TKey]; + }; +}; + +type Pair = Pairs[keyof T]; + +type FooBar = { + foo: string; + bar: number; +}; + +// Error expected here +let pair1: Pair = { + key: "foo", + value: 3 +}; + +// Error expected here +let pair2: Pairs[keyof FooBar] = { + key: "foo", + value: 3 +}; + + +//// [mappedTypeIndexedAccess.js] +"use strict"; +// Repro from #15756 +// Error expected here +var pair1 = { + key: "foo", + value: 3 +}; +// Error expected here +var pair2 = { + key: "foo", + value: 3 +}; diff --git a/tests/cases/compiler/mappedTypeIndexedAccess.ts b/tests/cases/compiler/mappedTypeIndexedAccess.ts new file mode 100644 index 00000000000..5be08a96f63 --- /dev/null +++ b/tests/cases/compiler/mappedTypeIndexedAccess.ts @@ -0,0 +1,29 @@ +// @strict: true + +// Repro from #15756 + +type Pairs = { + [TKey in keyof T]: { + key: TKey; + value: T[TKey]; + }; +}; + +type Pair = Pairs[keyof T]; + +type FooBar = { + foo: string; + bar: number; +}; + +// Error expected here +let pair1: Pair = { + key: "foo", + value: 3 +}; + +// Error expected here +let pair2: Pairs[keyof FooBar] = { + key: "foo", + value: 3 +}; From 3a0ab74ed6d5201ac703089f72915d23ef15242e Mon Sep 17 00:00:00 2001 From: Andy Date: Fri, 25 Aug 2017 09:53:28 -0700 Subject: [PATCH 150/370] Test for action description of code actions, and simplify description for extracting method to file (#18030) * Test for action description of code actions, and simplify description for extracting method to file * Add unit test file missing from tsconfig.json (only affects gulp) and update tests * Use the actual number * Use "module scope" or "global scope" instead of "this file" --- src/compiler/diagnosticMessages.json | 2 +- src/harness/fourslash.ts | 47 +++++++++++++------ src/harness/tsconfig.json | 1 + src/services/refactors/extractMethod.ts | 18 +++---- .../reference/extractMethod/extractMethod1.js | 8 ++-- .../extractMethod/extractMethod10.js | 6 +-- .../extractMethod/extractMethod11.js | 6 +-- .../extractMethod/extractMethod12.js | 2 +- .../reference/extractMethod/extractMethod2.js | 8 ++-- .../reference/extractMethod/extractMethod3.js | 8 ++-- .../reference/extractMethod/extractMethod4.js | 8 ++-- .../reference/extractMethod/extractMethod5.js | 8 ++-- .../reference/extractMethod/extractMethod6.js | 8 ++-- .../reference/extractMethod/extractMethod7.js | 8 ++-- .../reference/extractMethod/extractMethod8.js | 8 ++-- .../reference/extractMethod/extractMethod9.js | 8 ++-- tests/cases/fourslash/extract-method1.ts | 7 ++- tests/cases/fourslash/extract-method10.ts | 9 +++- tests/cases/fourslash/extract-method13.ts | 12 ++++- tests/cases/fourslash/extract-method14.ts | 6 ++- tests/cases/fourslash/extract-method15.ts | 6 ++- tests/cases/fourslash/extract-method18.ts | 7 ++- tests/cases/fourslash/extract-method19.ts | 9 ++-- tests/cases/fourslash/extract-method2.ts | 7 ++- tests/cases/fourslash/extract-method21.ts | 6 ++- tests/cases/fourslash/extract-method24.ts | 6 ++- tests/cases/fourslash/extract-method25.ts | 6 ++- tests/cases/fourslash/extract-method3.ts | 2 +- tests/cases/fourslash/extract-method5.ts | 6 ++- tests/cases/fourslash/extract-method7.ts | 6 ++- tests/cases/fourslash/fourslash.ts | 4 +- 31 files changed, 163 insertions(+), 90 deletions(-) diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index 8121f036cea..9a3492e5c37 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -3696,7 +3696,7 @@ "code": 95003 }, - "Extract function into '{0}'": { + "Extract function into {0}": { "category": "Message", "code": 95004 } diff --git a/src/harness/fourslash.ts b/src/harness/fourslash.ts index ab33fa87997..3010fc53533 100644 --- a/src/harness/fourslash.ts +++ b/src/harness/fourslash.ts @@ -2761,20 +2761,25 @@ namespace FourSlash { }); } - public verifyRefactorAvailable(negative: boolean, name?: string, subName?: string) { + public verifyRefactorAvailable(negative: boolean, name: string, actionName?: string) { const selection = this.getSelection(); let refactors = this.languageService.getApplicableRefactors(this.activeFile.fileName, selection) || []; - if (name) { - refactors = refactors.filter(r => r.name === name && (subName === undefined || r.actions.some(a => a.name === subName))); - } + refactors = refactors.filter(r => r.name === name && (actionName === undefined || r.actions.some(a => a.name === actionName))); const isAvailable = refactors.length > 0; - if (negative && isAvailable) { - this.raiseError(`verifyApplicableRefactorAvailableForRange failed - expected no refactor but found some: ${refactors.map(r => r.name).join(", ")}`); + if (negative) { + if (isAvailable) { + this.raiseError(`verifyApplicableRefactorAvailableForRange failed - expected no refactor but found: ${refactors.map(r => r.name).join(", ")}`); + } } - else if (!negative && !isAvailable) { - this.raiseError(`verifyApplicableRefactorAvailableForRange failed - expected a refactor but found none.`); + else { + if (!isAvailable) { + this.raiseError(`verifyApplicableRefactorAvailableForRange failed - expected a refactor but found none.`); + } + if (refactors.length > 1) { + this.raiseError(`${refactors.length} available refactors both have name ${name} and action ${actionName}`); + } } } @@ -2794,14 +2799,22 @@ namespace FourSlash { } } - public applyRefactor(refactorName: string, actionName: string) { + public applyRefactor({ refactorName, actionName, actionDescription }: FourSlashInterface.ApplyRefactorOptions) { const range = this.getSelection(); const refactors = this.languageService.getApplicableRefactors(this.activeFile.fileName, range); - const refactor = ts.find(refactors, r => r.name === refactorName); + const refactor = refactors.find(r => r.name === refactorName); if (!refactor) { this.raiseError(`The expected refactor: ${refactorName} is not available at the marker location.`); } + const action = refactor.actions.find(a => a.name === actionName); + if (!action) { + this.raiseError(`The expected action: ${action} is not included in: ${refactor.actions.map(a => a.name)}`); + } + if (action.description !== actionDescription) { + this.raiseError(`Expected action description to be ${JSON.stringify(actionDescription)}, got: ${JSON.stringify(action.description)}`); + } + const editInfo = this.languageService.getEditsForRefactor(this.activeFile.fileName, this.formatCodeSettings, range, refactorName, actionName); for (const edit of editInfo.edits) { this.applyEdits(edit.fileName, edit.textChanges, /*isFormattingEdit*/ false); @@ -3682,8 +3695,8 @@ namespace FourSlashInterface { this.state.verifyApplicableRefactorAvailableForRange(this.negative); } - public refactorAvailable(name?: string, subName?: string) { - this.state.verifyRefactorAvailable(this.negative, name, subName); + public refactorAvailable(name: string, actionName?: string) { + this.state.verifyRefactorAvailable(this.negative, name, actionName); } } @@ -4081,8 +4094,8 @@ namespace FourSlashInterface { this.state.enableFormatting = false; } - public applyRefactor(refactorName: string, actionName: string) { - this.state.applyRefactor(refactorName, actionName); + public applyRefactor(options: ApplyRefactorOptions) { + this.state.applyRefactor(options); } } @@ -4295,4 +4308,10 @@ namespace FourSlashInterface { return { classificationType, text, textSpan }; } } + + export interface ApplyRefactorOptions { + refactorName: string; + actionName: string; + actionDescription: string; + } } diff --git a/src/harness/tsconfig.json b/src/harness/tsconfig.json index 9165e59cb0a..1469079bcaa 100644 --- a/src/harness/tsconfig.json +++ b/src/harness/tsconfig.json @@ -125,6 +125,7 @@ "./unittests/printer.ts", "./unittests/transform.ts", "./unittests/customTransforms.ts", + "./unittests/extractMethods.ts", "./unittests/textChanges.ts", "./unittests/telemetry.ts", "./unittests/programMissingFiles.ts" diff --git a/src/services/refactors/extractMethod.ts b/src/services/refactors/extractMethod.ts index 90e33041695..f32321aff2a 100644 --- a/src/services/refactors/extractMethod.ts +++ b/src/services/refactors/extractMethod.ts @@ -560,32 +560,32 @@ namespace ts.refactor.extractMethod { return "constructor"; case SyntaxKind.FunctionExpression: return scope.name - ? `function expression ${scope.name.getText()}` + ? `function expression ${scope.name.text}` : "anonymous function expression"; case SyntaxKind.FunctionDeclaration: - return `function ${scope.name.getText()}`; + return `function '${scope.name.text}'`; case SyntaxKind.ArrowFunction: return "arrow function"; case SyntaxKind.MethodDeclaration: - return `method ${scope.name.getText()}`; + return `method '${scope.name.getText()}`; case SyntaxKind.GetAccessor: - return `get ${scope.name.getText()}`; + return `'get ${scope.name.getText()}'`; case SyntaxKind.SetAccessor: - return `set ${scope.name.getText()}`; + return `'set ${scope.name.getText()}'`; } } else if (isModuleBlock(scope)) { - return `namespace ${scope.parent.name.getText()}`; + return `namespace '${scope.parent.name.getText()}'`; } else if (isClassLike(scope)) { return scope.kind === SyntaxKind.ClassDeclaration - ? `class ${scope.name.text}` + ? `class '${scope.name.text}'` : scope.name.text - ? `class expression ${scope.name.text}` + ? `class expression '${scope.name.text}'` : "anonymous class expression"; } else if (isSourceFile(scope)) { - return `file '${scope.fileName}'`; + return scope.externalModuleIndicator ? "module scope" : "global scope"; } else { return "unknown"; diff --git a/tests/baselines/reference/extractMethod/extractMethod1.js b/tests/baselines/reference/extractMethod/extractMethod1.js index 60c7e301616..10bf2648383 100644 --- a/tests/baselines/reference/extractMethod/extractMethod1.js +++ b/tests/baselines/reference/extractMethod/extractMethod1.js @@ -14,7 +14,7 @@ namespace A { } } } -==SCOPE::function a== +==SCOPE::function 'a'== namespace A { let x = 1; function foo() { @@ -34,7 +34,7 @@ namespace A { } } } -==SCOPE::namespace B== +==SCOPE::namespace 'B'== namespace A { let x = 1; function foo() { @@ -55,7 +55,7 @@ namespace A { } } } -==SCOPE::namespace A== +==SCOPE::namespace 'A'== namespace A { let x = 1; function foo() { @@ -76,7 +76,7 @@ namespace A { return a; } } -==SCOPE::file '/a.ts'== +==SCOPE::global scope== namespace A { let x = 1; function foo() { diff --git a/tests/baselines/reference/extractMethod/extractMethod10.js b/tests/baselines/reference/extractMethod/extractMethod10.js index 02923b7ab50..b2397744680 100644 --- a/tests/baselines/reference/extractMethod/extractMethod10.js +++ b/tests/baselines/reference/extractMethod/extractMethod10.js @@ -9,7 +9,7 @@ namespace A { } } } -==SCOPE::class C== +==SCOPE::class 'C'== namespace A { export interface I { x: number }; class C { @@ -24,7 +24,7 @@ namespace A { } } } -==SCOPE::namespace A== +==SCOPE::namespace 'A'== namespace A { export interface I { x: number }; class C { @@ -39,7 +39,7 @@ namespace A { return a1.x + 10; } } -==SCOPE::file '/a.ts'== +==SCOPE::global scope== namespace A { export interface I { x: number }; class C { diff --git a/tests/baselines/reference/extractMethod/extractMethod11.js b/tests/baselines/reference/extractMethod/extractMethod11.js index 77565e7b0a7..21392a07a7a 100644 --- a/tests/baselines/reference/extractMethod/extractMethod11.js +++ b/tests/baselines/reference/extractMethod/extractMethod11.js @@ -11,7 +11,7 @@ namespace A { } } } -==SCOPE::class C== +==SCOPE::class 'C'== namespace A { let y = 1; class C { @@ -30,7 +30,7 @@ namespace A { } } } -==SCOPE::namespace A== +==SCOPE::namespace 'A'== namespace A { let y = 1; class C { @@ -49,7 +49,7 @@ namespace A { return { __return: a1.x + 10, z }; } } -==SCOPE::file '/a.ts'== +==SCOPE::global scope== namespace A { let y = 1; class C { diff --git a/tests/baselines/reference/extractMethod/extractMethod12.js b/tests/baselines/reference/extractMethod/extractMethod12.js index 8ff6e130dad..7cebab5d3c5 100644 --- a/tests/baselines/reference/extractMethod/extractMethod12.js +++ b/tests/baselines/reference/extractMethod/extractMethod12.js @@ -13,7 +13,7 @@ namespace A { } } } -==SCOPE::class C== +==SCOPE::class 'C'== namespace A { let y = 1; class C { diff --git a/tests/baselines/reference/extractMethod/extractMethod2.js b/tests/baselines/reference/extractMethod/extractMethod2.js index 28c27993d71..3c0d2e7c7b0 100644 --- a/tests/baselines/reference/extractMethod/extractMethod2.js +++ b/tests/baselines/reference/extractMethod/extractMethod2.js @@ -12,7 +12,7 @@ namespace A { } } } -==SCOPE::function a== +==SCOPE::function 'a'== namespace A { let x = 1; function foo() { @@ -30,7 +30,7 @@ namespace A { } } } -==SCOPE::namespace B== +==SCOPE::namespace 'B'== namespace A { let x = 1; function foo() { @@ -48,7 +48,7 @@ namespace A { } } } -==SCOPE::namespace A== +==SCOPE::namespace 'A'== namespace A { let x = 1; function foo() { @@ -66,7 +66,7 @@ namespace A { return foo(); } } -==SCOPE::file '/a.ts'== +==SCOPE::global scope== namespace A { let x = 1; function foo() { diff --git a/tests/baselines/reference/extractMethod/extractMethod3.js b/tests/baselines/reference/extractMethod/extractMethod3.js index e5903ead181..cb28e2755e7 100644 --- a/tests/baselines/reference/extractMethod/extractMethod3.js +++ b/tests/baselines/reference/extractMethod/extractMethod3.js @@ -11,7 +11,7 @@ namespace A { } } } -==SCOPE::function a== +==SCOPE::function 'a'== namespace A { function foo() { } @@ -28,7 +28,7 @@ namespace A { } } } -==SCOPE::namespace B== +==SCOPE::namespace 'B'== namespace A { function foo() { } @@ -45,7 +45,7 @@ namespace A { } } } -==SCOPE::namespace A== +==SCOPE::namespace 'A'== namespace A { function foo() { } @@ -62,7 +62,7 @@ namespace A { return foo(); } } -==SCOPE::file '/a.ts'== +==SCOPE::global scope== namespace A { function foo() { } diff --git a/tests/baselines/reference/extractMethod/extractMethod4.js b/tests/baselines/reference/extractMethod/extractMethod4.js index 6b9e2eed099..07029b2d050 100644 --- a/tests/baselines/reference/extractMethod/extractMethod4.js +++ b/tests/baselines/reference/extractMethod/extractMethod4.js @@ -13,7 +13,7 @@ namespace A { } } } -==SCOPE::function a== +==SCOPE::function 'a'== namespace A { function foo() { } @@ -32,7 +32,7 @@ namespace A { } } } -==SCOPE::namespace B== +==SCOPE::namespace 'B'== namespace A { function foo() { } @@ -51,7 +51,7 @@ namespace A { } } } -==SCOPE::namespace A== +==SCOPE::namespace 'A'== namespace A { function foo() { } @@ -70,7 +70,7 @@ namespace A { return foo(); } } -==SCOPE::file '/a.ts'== +==SCOPE::global scope== namespace A { function foo() { } diff --git a/tests/baselines/reference/extractMethod/extractMethod5.js b/tests/baselines/reference/extractMethod/extractMethod5.js index cf63cb2a932..96a76e426b1 100644 --- a/tests/baselines/reference/extractMethod/extractMethod5.js +++ b/tests/baselines/reference/extractMethod/extractMethod5.js @@ -14,7 +14,7 @@ namespace A { } } } -==SCOPE::function a== +==SCOPE::function 'a'== namespace A { let x = 1; export function foo() { @@ -34,7 +34,7 @@ namespace A { } } } -==SCOPE::namespace B== +==SCOPE::namespace 'B'== namespace A { let x = 1; export function foo() { @@ -55,7 +55,7 @@ namespace A { } } } -==SCOPE::namespace A== +==SCOPE::namespace 'A'== namespace A { let x = 1; export function foo() { @@ -76,7 +76,7 @@ namespace A { return a; } } -==SCOPE::file '/a.ts'== +==SCOPE::global scope== namespace A { let x = 1; export function foo() { diff --git a/tests/baselines/reference/extractMethod/extractMethod6.js b/tests/baselines/reference/extractMethod/extractMethod6.js index 99f52e9febb..d1244ac9596 100644 --- a/tests/baselines/reference/extractMethod/extractMethod6.js +++ b/tests/baselines/reference/extractMethod/extractMethod6.js @@ -14,7 +14,7 @@ namespace A { } } } -==SCOPE::function a== +==SCOPE::function 'a'== namespace A { let x = 1; export function foo() { @@ -34,7 +34,7 @@ namespace A { } } } -==SCOPE::namespace B== +==SCOPE::namespace 'B'== namespace A { let x = 1; export function foo() { @@ -56,7 +56,7 @@ namespace A { } } } -==SCOPE::namespace A== +==SCOPE::namespace 'A'== namespace A { let x = 1; export function foo() { @@ -78,7 +78,7 @@ namespace A { return { __return: foo(), a }; } } -==SCOPE::file '/a.ts'== +==SCOPE::global scope== namespace A { let x = 1; export function foo() { diff --git a/tests/baselines/reference/extractMethod/extractMethod7.js b/tests/baselines/reference/extractMethod/extractMethod7.js index 09d5edaa2c0..da400d8b051 100644 --- a/tests/baselines/reference/extractMethod/extractMethod7.js +++ b/tests/baselines/reference/extractMethod/extractMethod7.js @@ -16,7 +16,7 @@ namespace A { } } } -==SCOPE::function a== +==SCOPE::function 'a'== namespace A { let x = 1; export namespace C { @@ -38,7 +38,7 @@ namespace A { } } } -==SCOPE::namespace B== +==SCOPE::namespace 'B'== namespace A { let x = 1; export namespace C { @@ -62,7 +62,7 @@ namespace A { } } } -==SCOPE::namespace A== +==SCOPE::namespace 'A'== namespace A { let x = 1; export namespace C { @@ -86,7 +86,7 @@ namespace A { return { __return: C.foo(), a }; } } -==SCOPE::file '/a.ts'== +==SCOPE::global scope== namespace A { let x = 1; export namespace C { diff --git a/tests/baselines/reference/extractMethod/extractMethod8.js b/tests/baselines/reference/extractMethod/extractMethod8.js index fe9cf2a92f0..d298387b902 100644 --- a/tests/baselines/reference/extractMethod/extractMethod8.js +++ b/tests/baselines/reference/extractMethod/extractMethod8.js @@ -8,7 +8,7 @@ namespace A { } } } -==SCOPE::function a== +==SCOPE::function 'a'== namespace A { let x = 1; namespace B { @@ -22,7 +22,7 @@ namespace A { } } } -==SCOPE::namespace B== +==SCOPE::namespace 'B'== namespace A { let x = 1; namespace B { @@ -36,7 +36,7 @@ namespace A { } } } -==SCOPE::namespace A== +==SCOPE::namespace 'A'== namespace A { let x = 1; namespace B { @@ -50,7 +50,7 @@ namespace A { return 1 + a1 + x; } } -==SCOPE::file '/a.ts'== +==SCOPE::global scope== namespace A { let x = 1; namespace B { diff --git a/tests/baselines/reference/extractMethod/extractMethod9.js b/tests/baselines/reference/extractMethod/extractMethod9.js index fcc5dcd23de..609e3535d57 100644 --- a/tests/baselines/reference/extractMethod/extractMethod9.js +++ b/tests/baselines/reference/extractMethod/extractMethod9.js @@ -8,7 +8,7 @@ namespace A { } } } -==SCOPE::function a== +==SCOPE::function 'a'== namespace A { export interface I { x: number }; namespace B { @@ -22,7 +22,7 @@ namespace A { } } } -==SCOPE::namespace B== +==SCOPE::namespace 'B'== namespace A { export interface I { x: number }; namespace B { @@ -36,7 +36,7 @@ namespace A { } } } -==SCOPE::namespace A== +==SCOPE::namespace 'A'== namespace A { export interface I { x: number }; namespace B { @@ -50,7 +50,7 @@ namespace A { return a1.x + 10; } } -==SCOPE::file '/a.ts'== +==SCOPE::global scope== namespace A { export interface I { x: number }; namespace B { diff --git a/tests/cases/fourslash/extract-method1.ts b/tests/cases/fourslash/extract-method1.ts index 7f5c2ac2d50..ff061295c8c 100644 --- a/tests/cases/fourslash/extract-method1.ts +++ b/tests/cases/fourslash/extract-method1.ts @@ -13,8 +13,11 @@ //// } goTo.select('start', 'end') -verify.refactorAvailable('Extract Method'); -edit.applyRefactor('Extract Method', "scope_0"); +edit.applyRefactor({ + refactorName: "Extract Method", + actionName: "scope_0", + actionDescription: "Extract function into class 'Foo'", +}); verify.currentFileContentIs( `class Foo { someMethod(m: number) { diff --git a/tests/cases/fourslash/extract-method10.ts b/tests/cases/fourslash/extract-method10.ts index 1a02bfa00f5..ffbee7350e2 100644 --- a/tests/cases/fourslash/extract-method10.ts +++ b/tests/cases/fourslash/extract-method10.ts @@ -1,6 +1,11 @@ /// -//// (x => x)(/*1*/x => x/*2*/)(1); +//// export {}; // Make this a module +//// (x => x)(/*1*/x => x/*2*/)(1); goTo.select('1', '2'); -edit.applyRefactor('Extract Method', 'scope_0'); +edit.applyRefactor({ + refactorName: "Extract Method", + actionName: 'scope_0', + actionDescription: "Extract function into module scope", +}); diff --git a/tests/cases/fourslash/extract-method13.ts b/tests/cases/fourslash/extract-method13.ts index b9b7c0096aa..14a146a80c5 100644 --- a/tests/cases/fourslash/extract-method13.ts +++ b/tests/cases/fourslash/extract-method13.ts @@ -10,10 +10,18 @@ //// } goTo.select('a', 'b'); -edit.applyRefactor('Extract Method', 'scope_0'); +edit.applyRefactor({ + refactorName: "Extract Method", + actionName: "scope_0", + actionDescription: "Extract function into class 'C'", +}); goTo.select('c', 'd'); -edit.applyRefactor('Extract Method', 'scope_0'); +edit.applyRefactor({ + refactorName: "Extract Method", + actionName: "scope_0", + actionDescription: "Extract function into class 'C'", +}); verify.currentFileContentIs(`class C { static j = C.newFunction_1(); diff --git a/tests/cases/fourslash/extract-method14.ts b/tests/cases/fourslash/extract-method14.ts index c8bab1b3a56..696bb664bd3 100644 --- a/tests/cases/fourslash/extract-method14.ts +++ b/tests/cases/fourslash/extract-method14.ts @@ -11,7 +11,11 @@ //// } goTo.select('a', 'b'); -edit.applyRefactor('Extract Method', 'scope_1'); +edit.applyRefactor({ + refactorName: "Extract Method", + actionName: "scope_1", + actionDescription: "Extract function into global scope", +}); verify.currentFileContentIs(`function foo() { var i = 10; var __return: any; diff --git a/tests/cases/fourslash/extract-method15.ts b/tests/cases/fourslash/extract-method15.ts index ef62bd3fd3f..93aa357cfee 100644 --- a/tests/cases/fourslash/extract-method15.ts +++ b/tests/cases/fourslash/extract-method15.ts @@ -9,7 +9,11 @@ //// } goTo.select('a', 'b'); -edit.applyRefactor('Extract Method', 'scope_1'); +edit.applyRefactor({ + refactorName: "Extract Method", + actionName: "scope_1", + actionDescription: "Extract function into global scope", +}); verify.currentFileContentIs(`function foo() { var i = 10; diff --git a/tests/cases/fourslash/extract-method18.ts b/tests/cases/fourslash/extract-method18.ts index 9d87979a1ed..d99d14bac73 100644 --- a/tests/cases/fourslash/extract-method18.ts +++ b/tests/cases/fourslash/extract-method18.ts @@ -9,8 +9,11 @@ //// } goTo.select('a', 'b') -verify.refactorAvailable('Extract Method'); -edit.applyRefactor('Extract Method', "scope_1"); +edit.applyRefactor({ + refactorName: "Extract Method", + actionName: "scope_1", + actionDescription: "Extract function into global scope", +}); verify.currentFileContentIs(`function fn() { const x = { m: 1 }; newFunction(x); diff --git a/tests/cases/fourslash/extract-method19.ts b/tests/cases/fourslash/extract-method19.ts index 54f79311cc7..e4fb3e6e111 100644 --- a/tests/cases/fourslash/extract-method19.ts +++ b/tests/cases/fourslash/extract-method19.ts @@ -5,12 +5,15 @@ //// function fn() { //// /*a*/console.log("hi");/*b*/ //// } -//// +//// //// function newFunction() { } goTo.select('a', 'b') -verify.refactorAvailable('Extract Method'); -edit.applyRefactor('Extract Method', "scope_0"); +edit.applyRefactor({ + refactorName: "Extract Method", + actionName: "scope_0", + actionDescription: "Extract function into function 'fn'", +}); verify.currentFileContentIs(`function fn() { newFunction_1(); diff --git a/tests/cases/fourslash/extract-method2.ts b/tests/cases/fourslash/extract-method2.ts index 0a4f346307b..508836c4199 100644 --- a/tests/cases/fourslash/extract-method2.ts +++ b/tests/cases/fourslash/extract-method2.ts @@ -10,8 +10,11 @@ //// } //// } goTo.select('start', 'end') -verify.refactorAvailable('Extract Method'); -edit.applyRefactor('Extract Method', "scope_2"); +edit.applyRefactor({ + refactorName: "Extract Method", + actionName: "scope_2", + actionDescription: "Extract function into global scope", +}); verify.currentFileContentIs( `namespace NS { class Q { diff --git a/tests/cases/fourslash/extract-method21.ts b/tests/cases/fourslash/extract-method21.ts index 0168daf5fcb..c32df5b5979 100644 --- a/tests/cases/fourslash/extract-method21.ts +++ b/tests/cases/fourslash/extract-method21.ts @@ -12,7 +12,11 @@ goTo.select('start', 'end') verify.refactorAvailable('Extract Method'); -edit.applyRefactor('Extract Method', "scope_0"); +edit.applyRefactor({ + refactorName: "Extract Method", + actionName: "scope_0", + actionDescription: "Extract function into class 'Foo'", +}); verify.currentFileContentIs(`class Foo { static method() { diff --git a/tests/cases/fourslash/extract-method24.ts b/tests/cases/fourslash/extract-method24.ts index 9eebc00316b..615cb2ac4d2 100644 --- a/tests/cases/fourslash/extract-method24.ts +++ b/tests/cases/fourslash/extract-method24.ts @@ -7,7 +7,11 @@ //// } goTo.select('a', 'b') -edit.applyRefactor('Extract Method', 'scope_1'); +edit.applyRefactor({ + refactorName: "Extract Method", + actionName: "scope_1", + actionDescription: "Extract function into global scope", +}); verify.currentFileContentIs(`function M() { let a = [1,2,3]; let x = 0; diff --git a/tests/cases/fourslash/extract-method25.ts b/tests/cases/fourslash/extract-method25.ts index ac7e7a23004..8585dd06fd4 100644 --- a/tests/cases/fourslash/extract-method25.ts +++ b/tests/cases/fourslash/extract-method25.ts @@ -8,7 +8,11 @@ //// } goTo.select('a', 'b') -edit.applyRefactor('Extract Method', 'scope_0'); +edit.applyRefactor({ + refactorName: "Extract Method", + actionName: "scope_0", + actionDescription: "Extract function into function 'fn'", +}); verify.currentFileContentIs(`function fn() { var q = newFunction() q[0]++ diff --git a/tests/cases/fourslash/extract-method3.ts b/tests/cases/fourslash/extract-method3.ts index af543121eeb..27a520d0555 100644 --- a/tests/cases/fourslash/extract-method3.ts +++ b/tests/cases/fourslash/extract-method3.ts @@ -10,7 +10,7 @@ //// } //// } -// Don't offer to to 'extract method' a single identifier +// Don't offer to 'extract method' a single identifier goTo.marker('a'); verify.not.refactorAvailable('Extract Method'); diff --git a/tests/cases/fourslash/extract-method5.ts b/tests/cases/fourslash/extract-method5.ts index ac09f92cc05..10294298b08 100644 --- a/tests/cases/fourslash/extract-method5.ts +++ b/tests/cases/fourslash/extract-method5.ts @@ -9,7 +9,11 @@ //// } goTo.select('start', 'end'); -edit.applyRefactor('Extract Method', 'scope_0'); +edit.applyRefactor({ + refactorName: "Extract Method", + actionName: "scope_0", + actionDescription: "Extract function into function 'f'", +}); verify.currentFileContentIs( `function f() { var x: 1 | 2 | 3 = newFunction(); diff --git a/tests/cases/fourslash/extract-method7.ts b/tests/cases/fourslash/extract-method7.ts index 4c95c6a551d..95c9cbe9897 100644 --- a/tests/cases/fourslash/extract-method7.ts +++ b/tests/cases/fourslash/extract-method7.ts @@ -7,7 +7,11 @@ //// } goTo.select('a', 'b'); -edit.applyRefactor('Extract Method', 'scope_0'); +edit.applyRefactor({ + refactorName: "Extract Method", + actionName: "scope_0", + actionDescription: "Extract function into global scope", +}); verify.currentFileContentIs(`function fn(x = newFunction()) { } function newFunction() { diff --git a/tests/cases/fourslash/fourslash.ts b/tests/cases/fourslash/fourslash.ts index abb2c38c6b4..652ed4812c0 100644 --- a/tests/cases/fourslash/fourslash.ts +++ b/tests/cases/fourslash/fourslash.ts @@ -159,7 +159,7 @@ declare namespace FourSlashInterface { codeFixDiagnosticsAvailableAtMarkers(markerNames: string[], diagnosticCode?: number): void; applicableRefactorAvailableForRange(): void; - refactorAvailable(name?: string, subName?: string); + refactorAvailable(name: string, actionName?: string); } class verify extends verifyNegatable { assertHasRanges(ranges: Range[]): void; @@ -310,7 +310,7 @@ declare namespace FourSlashInterface { enableFormatting(): void; disableFormatting(): void; - applyRefactor(refactorName: string, actionName: string): void; + applyRefactor(options: { refactorName: string, actionName: string, actionDescription: string }): void; } class debug { printCurrentParameterHelp(): void; From fe1242c8a902a2f530e5fb91b8f8f3e90bd4f4a6 Mon Sep 17 00:00:00 2001 From: Andy Date: Fri, 25 Aug 2017 09:53:56 -0700 Subject: [PATCH 151/370] Don't try to extract `import` to a method (#18025) --- src/compiler/utilities.ts | 117 ++++++++++-------- src/services/refactors/extractMethod.ts | 27 ++-- .../extract-method-not-for-import.ts | 10 ++ 3 files changed, 87 insertions(+), 67 deletions(-) create mode 100644 tests/cases/fourslash/extract-method-not-for-import.ts diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index 7462bf02adc..9f679011dd0 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -4951,54 +4951,60 @@ namespace ts { || kind === SyntaxKind.NoSubstitutionTemplateLiteral; } - function isLeftHandSideExpressionKind(kind: SyntaxKind): boolean { - return kind === SyntaxKind.PropertyAccessExpression - || kind === SyntaxKind.ElementAccessExpression - || kind === SyntaxKind.NewExpression - || kind === SyntaxKind.CallExpression - || kind === SyntaxKind.JsxElement - || kind === SyntaxKind.JsxSelfClosingElement - || kind === SyntaxKind.TaggedTemplateExpression - || kind === SyntaxKind.ArrayLiteralExpression - || kind === SyntaxKind.ParenthesizedExpression - || kind === SyntaxKind.ObjectLiteralExpression - || kind === SyntaxKind.ClassExpression - || kind === SyntaxKind.FunctionExpression - || kind === SyntaxKind.Identifier - || kind === SyntaxKind.RegularExpressionLiteral - || kind === SyntaxKind.NumericLiteral - || kind === SyntaxKind.StringLiteral - || kind === SyntaxKind.NoSubstitutionTemplateLiteral - || kind === SyntaxKind.TemplateExpression - || kind === SyntaxKind.FalseKeyword - || kind === SyntaxKind.NullKeyword - || kind === SyntaxKind.ThisKeyword - || kind === SyntaxKind.TrueKeyword - || kind === SyntaxKind.SuperKeyword - || kind === SyntaxKind.ImportKeyword - || kind === SyntaxKind.NonNullExpression - || kind === SyntaxKind.MetaProperty; - } - /* @internal */ export function isLeftHandSideExpression(node: Node): node is LeftHandSideExpression { - return isLeftHandSideExpressionKind(skipPartiallyEmittedExpressions(node).kind); - } - - function isUnaryExpressionKind(kind: SyntaxKind): boolean { - return kind === SyntaxKind.PrefixUnaryExpression - || kind === SyntaxKind.PostfixUnaryExpression - || kind === SyntaxKind.DeleteExpression - || kind === SyntaxKind.TypeOfExpression - || kind === SyntaxKind.VoidExpression - || kind === SyntaxKind.AwaitExpression - || kind === SyntaxKind.TypeAssertionExpression - || isLeftHandSideExpressionKind(kind); + switch (node.kind) { + case SyntaxKind.PropertyAccessExpression: + case SyntaxKind.ElementAccessExpression: + case SyntaxKind.NewExpression: + case SyntaxKind.CallExpression: + case SyntaxKind.JsxElement: + case SyntaxKind.JsxSelfClosingElement: + case SyntaxKind.TaggedTemplateExpression: + case SyntaxKind.ArrayLiteralExpression: + case SyntaxKind.ParenthesizedExpression: + case SyntaxKind.ObjectLiteralExpression: + case SyntaxKind.ClassExpression: + case SyntaxKind.FunctionExpression: + case SyntaxKind.Identifier: + case SyntaxKind.RegularExpressionLiteral: + case SyntaxKind.NumericLiteral: + case SyntaxKind.StringLiteral: + case SyntaxKind.NoSubstitutionTemplateLiteral: + case SyntaxKind.TemplateExpression: + case SyntaxKind.FalseKeyword: + case SyntaxKind.NullKeyword: + case SyntaxKind.ThisKeyword: + case SyntaxKind.TrueKeyword: + case SyntaxKind.SuperKeyword: + case SyntaxKind.NonNullExpression: + case SyntaxKind.MetaProperty: + return true; + case SyntaxKind.PartiallyEmittedExpression: + return isLeftHandSideExpression((node as PartiallyEmittedExpression).expression); + case SyntaxKind.ImportKeyword: + return node.parent.kind === SyntaxKind.CallExpression; + default: + return false; + } } /* @internal */ export function isUnaryExpression(node: Node): node is UnaryExpression { - return isUnaryExpressionKind(skipPartiallyEmittedExpressions(node).kind); + switch (node.kind) { + case SyntaxKind.PrefixUnaryExpression: + case SyntaxKind.PostfixUnaryExpression: + case SyntaxKind.DeleteExpression: + case SyntaxKind.TypeOfExpression: + case SyntaxKind.VoidExpression: + case SyntaxKind.AwaitExpression: + case SyntaxKind.TypeAssertionExpression: + return true; + case SyntaxKind.PartiallyEmittedExpression: + return isUnaryExpression((node as PartiallyEmittedExpression).expression); + default: + return isLeftHandSideExpression(node); + } } /* @internal */ @@ -5014,21 +5020,22 @@ namespace ts { } } - function isExpressionKind(kind: SyntaxKind) { - return kind === SyntaxKind.ConditionalExpression - || kind === SyntaxKind.YieldExpression - || kind === SyntaxKind.ArrowFunction - || kind === SyntaxKind.BinaryExpression - || kind === SyntaxKind.SpreadElement - || kind === SyntaxKind.AsExpression - || kind === SyntaxKind.OmittedExpression - || kind === SyntaxKind.CommaListExpression - || isUnaryExpressionKind(kind); - } - /* @internal */ export function isExpression(node: Node): node is Expression { - return isExpressionKind(skipPartiallyEmittedExpressions(node).kind); + switch (node.kind) { + case SyntaxKind.ConditionalExpression: + case SyntaxKind.YieldExpression: + case SyntaxKind.ArrowFunction: + case SyntaxKind.BinaryExpression: + case SyntaxKind.SpreadElement: + case SyntaxKind.AsExpression: + case SyntaxKind.OmittedExpression: + case SyntaxKind.CommaListExpression: + case SyntaxKind.PartiallyEmittedExpression: + return true; + default: + return isUnaryExpression(node); + } } export function isAssertionExpression(node: Node): node is AssertionExpression { diff --git a/src/services/refactors/extractMethod.ts b/src/services/refactors/extractMethod.ts index f32321aff2a..820212011a9 100644 --- a/src/services/refactors/extractMethod.ts +++ b/src/services/refactors/extractMethod.ts @@ -231,18 +231,7 @@ namespace ts.refactor.extractMethod { if (errors) { return { errors }; } - - // If our selection is the expression in an ExpressionStatement, expand - // the selection to include the enclosing Statement (this stops us - // from trying to care about the return value of the extracted function - // and eliminates double semicolon insertion in certain scenarios) - const range = isStatement(start) - ? [start] - : start.parent && start.parent.kind === SyntaxKind.ExpressionStatement - ? [start.parent as Statement] - : start as Expression; - - return { targetRange: { range, facts: rangeFacts, declarations } }; + return { targetRange: { range: getStatementOrExpressionRange(start), facts: rangeFacts, declarations } }; } function createErrorResult(sourceFile: SourceFile, start: number, length: number, message: DiagnosticMessage): RangeToExtract { @@ -459,6 +448,20 @@ namespace ts.refactor.extractMethod { } } + function getStatementOrExpressionRange(node: Node): Statement[] | Expression { + if (isStatement(node)) { + return [node]; + } + else if (isExpression(node)) { + // If our selection is the expression in an ExpressionStatement, expand + // the selection to include the enclosing Statement (this stops us + // from trying to care about the return value of the extracted function + // and eliminates double semicolon insertion in certain scenarios) + return isExpressionStatement(node.parent) ? [node.parent] : node; + } + return undefined; + } + function isValidExtractionTarget(node: Node): node is Scope { // Note that we don't use isFunctionLike because we don't want to put the extracted closure *inside* a method return (node.kind === SyntaxKind.FunctionDeclaration) || isSourceFile(node) || isModuleBlock(node) || isClassLike(node); diff --git a/tests/cases/fourslash/extract-method-not-for-import.ts b/tests/cases/fourslash/extract-method-not-for-import.ts new file mode 100644 index 00000000000..a72d793611d --- /dev/null +++ b/tests/cases/fourslash/extract-method-not-for-import.ts @@ -0,0 +1,10 @@ +/// + +// @Filename: /a.ts +////i/**/mport _ from "./b"; + +// @Filename: /b.ts +////export default function f() {} + +goTo.marker(""); +verify.not.refactorAvailable('Extract Method'); From bdfb92aebe304f8b75d9cd8dcda5f23898278244 Mon Sep 17 00:00:00 2001 From: Ron Buckton Date: Fri, 25 Aug 2017 14:17:48 -0700 Subject: [PATCH 152/370] Fix crash in name resolution with custom transforms and emitDecoratorMetadata --- src/compiler/checker.ts | 9 +++++++ src/compiler/transformers/ts.ts | 2 +- src/harness/unittests/customTransforms.ts | 23 ++++++++++++++-- .../customTransforms/before+decorators.js | 26 +++++++++++++++++++ 4 files changed, 57 insertions(+), 3 deletions(-) create mode 100644 tests/baselines/reference/customTransforms/before+decorators.js diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 4bdfa4b7250..79509804105 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -23508,6 +23508,15 @@ namespace ts { } function getTypeReferenceSerializationKind(typeName: EntityName, location?: Node): TypeReferenceSerializationKind { + // ensure both `typeName` and `location` are parse tree nodes. + typeName = getParseTreeNode(typeName, isEntityName); + if (!typeName) return TypeReferenceSerializationKind.Unknown; + + if (location) { + location = getParseTreeNode(location); + if (!location) return TypeReferenceSerializationKind.Unknown; + } + // Resolve the symbol as a value to ensure the type can be reached at runtime during emit. const valueSymbol = resolveEntityName(typeName, SymbolFlags.Value, /*ignoreErrors*/ true, /*dontResolveAlias*/ false, location); diff --git a/src/compiler/transformers/ts.ts b/src/compiler/transformers/ts.ts index 4c679ea1eee..a7942397391 100644 --- a/src/compiler/transformers/ts.ts +++ b/src/compiler/transformers/ts.ts @@ -1944,7 +1944,7 @@ namespace ts { const name = getMutableClone(node); name.flags &= ~NodeFlags.Synthesized; name.original = undefined; - name.parent = currentScope; + name.parent = getParseTreeNode(currentScope); // ensure the parent is set to a parse tree node. if (useFallback) { return createLogicalAnd( createStrictInequality( diff --git a/src/harness/unittests/customTransforms.ts b/src/harness/unittests/customTransforms.ts index 4b05ebb9ea7..f47bdad5d58 100644 --- a/src/harness/unittests/customTransforms.ts +++ b/src/harness/unittests/customTransforms.ts @@ -3,12 +3,11 @@ namespace ts { describe("customTransforms", () => { - function emitsCorrectly(name: string, sources: { file: string, text: string }[], customTransformers: CustomTransformers) { + function emitsCorrectly(name: string, sources: { file: string, text: string }[], customTransformers: CustomTransformers, options: CompilerOptions = {}) { it(name, () => { const roots = sources.map(source => createSourceFile(source.file, source.text, ScriptTarget.ES2015)); const fileMap = arrayToMap(roots, file => file.fileName); const outputs = createMap(); - const options: CompilerOptions = {}; const host: CompilerHost = { getSourceFile: (fileName) => fileMap.get(fileName), getDefaultLibFileName: () => "lib.d.ts", @@ -82,5 +81,25 @@ namespace ts { emitsCorrectly("before", sources, { before: [before] }); emitsCorrectly("after", sources, { after: [after] }); emitsCorrectly("both", sources, { before: [before], after: [after] }); + + emitsCorrectly("before+decorators", [{ + file: "source.ts", + text: ` + declare const dec: any; + class B {} + @dec export class C { constructor(b: B) { } } + 'change' + ` + }], {before: [ + context => node => visitNode(node, function visitor(node: Node): Node { + if (isStringLiteral(node) && node.text === "change") return createLiteral("changed"); + return visitEachChild(node, visitor, context); + }) + ]}, { + target: ScriptTarget.ES5, + module: ModuleKind.ES2015, + emitDecoratorMetadata: true, + experimentalDecorators: true + }); }); } \ No newline at end of file diff --git a/tests/baselines/reference/customTransforms/before+decorators.js b/tests/baselines/reference/customTransforms/before+decorators.js new file mode 100644 index 00000000000..ef705f0c9d8 --- /dev/null +++ b/tests/baselines/reference/customTransforms/before+decorators.js @@ -0,0 +1,26 @@ +// [source.js] +var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { + var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); + else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; + return c > 3 && r && Object.defineProperty(target, key, r), r; +}; +var __metadata = (this && this.__metadata) || function (k, v) { + if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); +}; +var B = /** @class */ (function () { + function B() { + } + return B; +}()); +var C = /** @class */ (function () { + function C(b) { + } + C = __decorate([ + dec, + __metadata("design:paramtypes", [B]) + ], C); + return C; +}()); +export { C }; +"changed"; From 38c3f67652587d50b9de59c0b13dc92c0c16c35f Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Fri, 25 Aug 2017 15:10:47 -0700 Subject: [PATCH 153/370] Visit destructuring computed names (#18052) --- src/compiler/transformers/destructuring.ts | 2 +- .../computerPropertiesInES5ShouldBeTransformed.js | 8 ++++++++ .../computerPropertiesInES5ShouldBeTransformed.symbols | 6 ++++++ .../computerPropertiesInES5ShouldBeTransformed.types | 8 ++++++++ .../computerPropertiesInES5ShouldBeTransformed.ts | 2 ++ 5 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 tests/baselines/reference/computerPropertiesInES5ShouldBeTransformed.js create mode 100644 tests/baselines/reference/computerPropertiesInES5ShouldBeTransformed.symbols create mode 100644 tests/baselines/reference/computerPropertiesInES5ShouldBeTransformed.types create mode 100644 tests/cases/compiler/computerPropertiesInES5ShouldBeTransformed.ts diff --git a/src/compiler/transformers/destructuring.ts b/src/compiler/transformers/destructuring.ts index 2249e577312..0fea3e41c87 100644 --- a/src/compiler/transformers/destructuring.ts +++ b/src/compiler/transformers/destructuring.ts @@ -409,7 +409,7 @@ namespace ts { */ function createDestructuringPropertyAccess(flattenContext: FlattenContext, value: Expression, propertyName: PropertyName): LeftHandSideExpression { if (isComputedPropertyName(propertyName)) { - const argumentExpression = ensureIdentifier(flattenContext, propertyName.expression, /*reuseIdentifierExpressions*/ false, /*location*/ propertyName); + const argumentExpression = ensureIdentifier(flattenContext, visitNode(propertyName.expression, flattenContext.visitor), /*reuseIdentifierExpressions*/ false, /*location*/ propertyName); return createElementAccess(value, argumentExpression); } else if (isStringOrNumericLiteral(propertyName)) { diff --git a/tests/baselines/reference/computerPropertiesInES5ShouldBeTransformed.js b/tests/baselines/reference/computerPropertiesInES5ShouldBeTransformed.js new file mode 100644 index 00000000000..973e9756425 --- /dev/null +++ b/tests/baselines/reference/computerPropertiesInES5ShouldBeTransformed.js @@ -0,0 +1,8 @@ +//// [computerPropertiesInES5ShouldBeTransformed.ts] +const b = ({ [`key`]: renamed }) => renamed; + +//// [computerPropertiesInES5ShouldBeTransformed.js] +var b = function (_a) { + var _b = "key", renamed = _a[_b]; + return renamed; +}; diff --git a/tests/baselines/reference/computerPropertiesInES5ShouldBeTransformed.symbols b/tests/baselines/reference/computerPropertiesInES5ShouldBeTransformed.symbols new file mode 100644 index 00000000000..c118c1d0eff --- /dev/null +++ b/tests/baselines/reference/computerPropertiesInES5ShouldBeTransformed.symbols @@ -0,0 +1,6 @@ +=== tests/cases/compiler/computerPropertiesInES5ShouldBeTransformed.ts === +const b = ({ [`key`]: renamed }) => renamed; +>b : Symbol(b, Decl(computerPropertiesInES5ShouldBeTransformed.ts, 0, 5)) +>renamed : Symbol(renamed, Decl(computerPropertiesInES5ShouldBeTransformed.ts, 0, 12)) +>renamed : Symbol(renamed, Decl(computerPropertiesInES5ShouldBeTransformed.ts, 0, 12)) + diff --git a/tests/baselines/reference/computerPropertiesInES5ShouldBeTransformed.types b/tests/baselines/reference/computerPropertiesInES5ShouldBeTransformed.types new file mode 100644 index 00000000000..b0e4e1424ac --- /dev/null +++ b/tests/baselines/reference/computerPropertiesInES5ShouldBeTransformed.types @@ -0,0 +1,8 @@ +=== tests/cases/compiler/computerPropertiesInES5ShouldBeTransformed.ts === +const b = ({ [`key`]: renamed }) => renamed; +>b : ({ [`key`]: renamed }: {}) => any +>({ [`key`]: renamed }) => renamed : ({ [`key`]: renamed }: {}) => any +>`key` : "key" +>renamed : any +>renamed : any + diff --git a/tests/cases/compiler/computerPropertiesInES5ShouldBeTransformed.ts b/tests/cases/compiler/computerPropertiesInES5ShouldBeTransformed.ts new file mode 100644 index 00000000000..42eb602989d --- /dev/null +++ b/tests/cases/compiler/computerPropertiesInES5ShouldBeTransformed.ts @@ -0,0 +1,2 @@ +// @target: es5 +const b = ({ [`key`]: renamed }) => renamed; \ No newline at end of file From 4d05bfdf4aa3aab07e696f34f0912ba93e01cc51 Mon Sep 17 00:00:00 2001 From: Andy Date: Fri, 25 Aug 2017 15:14:51 -0700 Subject: [PATCH 154/370] `moduleAugmentations` may contain an `Identifier` (#18009) * `moduleAugmentations` may contain an `Identifier` * Add comment * Rename function --- src/compiler/checker.ts | 7 ++++--- src/compiler/program.ts | 34 +++++++++++++++++++++------------- src/compiler/types.ts | 3 ++- 3 files changed, 27 insertions(+), 17 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index c7513deba56..088cb4bb851 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -640,7 +640,7 @@ namespace ts { }); } - function mergeModuleAugmentation(moduleName: LiteralExpression): void { + function mergeModuleAugmentation(moduleName: StringLiteral | Identifier): void { const moduleAugmentation = moduleName.parent; if (moduleAugmentation.symbol.declarations[0] !== moduleAugmentation) { // this is a combined symbol for multiple augmentations within the same file. @@ -672,7 +672,8 @@ namespace ts { mergeSymbol(mainModule, moduleAugmentation.symbol); } else { - error(moduleName, Diagnostics.Cannot_augment_module_0_because_it_resolves_to_a_non_module_entity, moduleName.text); + // moduleName will be a StringLiteral since this is not `declare global`. + error(moduleName, Diagnostics.Cannot_augment_module_0_because_it_resolves_to_a_non_module_entity, (moduleName as StringLiteral).text); } } } @@ -23800,7 +23801,7 @@ namespace ts { } // Initialize global symbol table - let augmentations: ReadonlyArray[]; + let augmentations: ReadonlyArray[]; for (const file of host.getSourceFiles()) { if (!isExternalOrCommonJsModule(file)) { mergeSymbolTable(globals, file.locals); diff --git a/src/compiler/program.ts b/src/compiler/program.ts index 800e2f9e619..ec220ad248e 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -890,7 +890,7 @@ namespace ts { for (const { oldFile: oldSourceFile, newFile: newSourceFile } of modifiedSourceFiles) { const newSourceFilePath = getNormalizedAbsolutePath(newSourceFile.fileName, currentDirectory); if (resolveModuleNamesWorker) { - const moduleNames = map(concatenate(newSourceFile.imports, newSourceFile.moduleAugmentations), getTextOfLiteral); + const moduleNames = getModuleNames(newSourceFile); const oldProgramState = { program: oldProgram, file: oldSourceFile, modifiedFilePaths }; const resolutions = resolveModuleNamesReusingOldState(moduleNames, newSourceFilePath, newSourceFile, oldProgramState); // ensure that module resolution results are still correct @@ -1434,12 +1434,10 @@ namespace ts { return a.fileName === b.fileName; } - function moduleNameIsEqualTo(a: LiteralExpression, b: LiteralExpression): boolean { - return a.text === b.text; - } - - function getTextOfLiteral(literal: LiteralExpression): string { - return literal.text; + function moduleNameIsEqualTo(a: StringLiteral | Identifier, b: StringLiteral | Identifier): boolean { + return a.kind === SyntaxKind.StringLiteral + ? b.kind === SyntaxKind.StringLiteral && a.text === b.text + : b.kind === SyntaxKind.Identifier && a.escapedText === b.escapedText; } function collectExternalModuleReferences(file: SourceFile): void { @@ -1452,7 +1450,7 @@ namespace ts { // file.imports may not be undefined if there exists dynamic import let imports: StringLiteral[]; - let moduleAugmentations: StringLiteral[]; + let moduleAugmentations: Array; let ambientModules: string[]; // If we are importing helpers, we need to add a synthetic reference to resolve the @@ -1481,7 +1479,7 @@ namespace ts { return; - function collectModuleReferences(node: Node, inAmbientModule: boolean): void { + function collectModuleReferences(node: Statement, inAmbientModule: boolean): void { switch (node.kind) { case SyntaxKind.ImportDeclaration: case SyntaxKind.ImportEqualsDeclaration: @@ -1503,8 +1501,8 @@ namespace ts { break; case SyntaxKind.ModuleDeclaration: if (isAmbientModule(node) && (inAmbientModule || hasModifier(node, ModifierFlags.Ambient) || file.isDeclarationFile)) { - const moduleName = (node).name; // TODO: GH#17347 - const nameText = ts.getTextOfIdentifierOrLiteral(moduleName); + const moduleName = (node).name; + const nameText = getTextOfIdentifierOrLiteral(moduleName); // Ambient module declarations can be interpreted as augmentations for some existing external modules. // This will happen in two cases: // - if current file is external module then module augmentation is a ambient module declaration defined in the top level scope @@ -1821,8 +1819,7 @@ namespace ts { collectExternalModuleReferences(file); if (file.imports.length || file.moduleAugmentations.length) { // Because global augmentation doesn't have string literal name, we can check for global augmentation as such. - const nonGlobalAugmentation = filter(file.moduleAugmentations, (moduleAugmentation) => moduleAugmentation.kind === SyntaxKind.StringLiteral); - const moduleNames = map(concatenate(file.imports, nonGlobalAugmentation), getTextOfLiteral); + const moduleNames = getModuleNames(file); const oldProgramState = { program: oldProgram, file, modifiedFilePaths }; const resolutions = resolveModuleNamesReusingOldState(moduleNames, getNormalizedAbsolutePath(file.fileName, currentDirectory), file, oldProgramState); Debug.assert(resolutions.length === moduleNames.length); @@ -2233,4 +2230,15 @@ namespace ts { Debug.assert(names.every(name => name !== undefined), "A name is undefined.", () => JSON.stringify(names)); return names; } + + function getModuleNames({ imports, moduleAugmentations }: SourceFile): string[] { + const res = imports.map(i => i.text); + for (const aug of moduleAugmentations) { + if (aug.kind === SyntaxKind.StringLiteral) { + res.push(aug.text); + } + // Do nothing if it's an Identifier; we don't need to do module resolution for `declare global`. + } + return res; + } } diff --git a/src/compiler/types.ts b/src/compiler/types.ts index f5cca6a6820..87ac4afbab1 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -2343,7 +2343,8 @@ namespace ts { /* @internal */ resolvedModules: Map; /* @internal */ resolvedTypeReferenceDirectiveNames: Map; /* @internal */ imports: ReadonlyArray; - /* @internal */ moduleAugmentations: ReadonlyArray; + // Identifier only if `declare global` + /* @internal */ moduleAugmentations: ReadonlyArray; /* @internal */ patternAmbientModules?: PatternAmbientModule[]; /* @internal */ ambientModuleNames: ReadonlyArray; /* @internal */ checkJsDirective: CheckJsDirective | undefined; From e73b10a304430d7022aca26623e1a286d69f7afe Mon Sep 17 00:00:00 2001 From: Andy Date: Fri, 25 Aug 2017 15:15:16 -0700 Subject: [PATCH 155/370] Use isPartOfExpression in extractMethod, not isExpression (#18047) * Use isPartOfExpression in extractMethod, not isExpression * Add whitespace --- src/compiler/utilities.ts | 33 ++++++++++++++++--------- src/services/refactors/extractMethod.ts | 6 ++--- 2 files changed, 25 insertions(+), 14 deletions(-) diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index 9f679011dd0..a32a82ecf10 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -4953,7 +4953,11 @@ namespace ts { /* @internal */ export function isLeftHandSideExpression(node: Node): node is LeftHandSideExpression { - switch (node.kind) { + return isLeftHandSideExpressionKind(skipPartiallyEmittedExpressions(node).kind); + } + + function isLeftHandSideExpressionKind(kind: SyntaxKind): boolean { + switch (kind) { case SyntaxKind.PropertyAccessExpression: case SyntaxKind.ElementAccessExpression: case SyntaxKind.NewExpression: @@ -4979,11 +4983,8 @@ namespace ts { case SyntaxKind.SuperKeyword: case SyntaxKind.NonNullExpression: case SyntaxKind.MetaProperty: + case SyntaxKind.ImportKeyword: // technically this is only an Expression if it's in a CallExpression return true; - case SyntaxKind.PartiallyEmittedExpression: - return isLeftHandSideExpression((node as PartiallyEmittedExpression).expression); - case SyntaxKind.ImportKeyword: - return node.parent.kind === SyntaxKind.CallExpression; default: return false; } @@ -4991,7 +4992,11 @@ namespace ts { /* @internal */ export function isUnaryExpression(node: Node): node is UnaryExpression { - switch (node.kind) { + return isUnaryExpressionKind(skipPartiallyEmittedExpressions(node).kind); + } + + function isUnaryExpressionKind(kind: SyntaxKind): boolean { + switch (kind) { case SyntaxKind.PrefixUnaryExpression: case SyntaxKind.PostfixUnaryExpression: case SyntaxKind.DeleteExpression: @@ -5000,10 +5005,8 @@ namespace ts { case SyntaxKind.AwaitExpression: case SyntaxKind.TypeAssertionExpression: return true; - case SyntaxKind.PartiallyEmittedExpression: - return isUnaryExpression((node as PartiallyEmittedExpression).expression); default: - return isLeftHandSideExpression(node); + return isLeftHandSideExpressionKind(kind); } } @@ -5021,8 +5024,16 @@ namespace ts { } /* @internal */ + /** + * Determines whether a node is an expression based only on its kind. + * Use `isPartOfExpression` if not in transforms. + */ export function isExpression(node: Node): node is Expression { - switch (node.kind) { + return isExpressionKind(skipPartiallyEmittedExpressions(node).kind); + } + + function isExpressionKind(kind: SyntaxKind): boolean { + switch (kind) { case SyntaxKind.ConditionalExpression: case SyntaxKind.YieldExpression: case SyntaxKind.ArrowFunction: @@ -5034,7 +5045,7 @@ namespace ts { case SyntaxKind.PartiallyEmittedExpression: return true; default: - return isUnaryExpression(node); + return isUnaryExpressionKind(kind); } } diff --git a/src/services/refactors/extractMethod.ts b/src/services/refactors/extractMethod.ts index 820212011a9..4fa22d24b8d 100644 --- a/src/services/refactors/extractMethod.ts +++ b/src/services/refactors/extractMethod.ts @@ -278,7 +278,7 @@ namespace ts.refactor.extractMethod { Continue = 1 << 1, Return = 1 << 2 } - if (!isStatement(nodeToCheck) && !(isExpression(nodeToCheck) && isExtractableExpression(nodeToCheck))) { + if (!isStatement(nodeToCheck) && !(isPartOfExpression(nodeToCheck) && isExtractableExpression(nodeToCheck))) { return [createDiagnosticForNode(nodeToCheck, Messages.StatementOrExpressionExpected)]; } @@ -452,12 +452,12 @@ namespace ts.refactor.extractMethod { if (isStatement(node)) { return [node]; } - else if (isExpression(node)) { + else if (isPartOfExpression(node)) { // If our selection is the expression in an ExpressionStatement, expand // the selection to include the enclosing Statement (this stops us // from trying to care about the return value of the extracted function // and eliminates double semicolon insertion in certain scenarios) - return isExpressionStatement(node.parent) ? [node.parent] : node; + return isExpressionStatement(node.parent) ? [node.parent] : node as Expression; } return undefined; } From a32d99dfc8da65565ea037e76770f0dd2711a735 Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Fri, 25 Aug 2017 18:22:03 -0700 Subject: [PATCH 156/370] Use visitNode (#18059) --- src/compiler/transformers/module/module.ts | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/compiler/transformers/module/module.ts b/src/compiler/transformers/module/module.ts index 23bae8714c8..493f5a43a1f 100644 --- a/src/compiler/transformers/module/module.ts +++ b/src/compiler/transformers/module/module.ts @@ -430,11 +430,8 @@ namespace ts { */ function addExportEqualsIfNeeded(statements: Statement[], emitAsReturn: boolean) { if (currentModuleInfo.exportEquals) { - const expressionResult = importCallExpressionVisitor(currentModuleInfo.exportEquals.expression); + const expressionResult = visitNode(currentModuleInfo.exportEquals.expression, importCallExpressionVisitor); if (expressionResult) { - if (expressionResult instanceof Array) { - return Debug.fail("export= expression should never be replaced with multiple expressions!"); - } if (emitAsReturn) { const statement = createReturn(expressionResult); setTextRange(statement, currentModuleInfo.exportEquals); From 884cadf0a3b5682e8f3b03a7c0ab11f4504957d0 Mon Sep 17 00:00:00 2001 From: Francois Wouts Date: Sun, 27 Aug 2017 22:03:56 +1000 Subject: [PATCH 157/370] Fix TypeScript printer bug when encountering regular expression literals See https://github.com/fwouts/sample-js-selfparsing/blob/typescriptbug/src/script.js to reproduce the bug. Not sure where to put tests for this, unfortunately! --- src/compiler/utilities.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index a32a82ecf10..197e91ac383 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -359,6 +359,7 @@ namespace ts { case SyntaxKind.TemplateTail: return "}" + escapeText(node.text, CharacterCodes.backtick) + "`"; case SyntaxKind.NumericLiteral: + case SyntaxKind.RegularExpressionLiteral: return node.text; } From 170bc6f519ca7e44b522cdf6ce8d7ccc95231736 Mon Sep 17 00:00:00 2001 From: Francois Wouts Date: Mon, 28 Aug 2017 08:14:08 +1000 Subject: [PATCH 158/370] Add test for #18071 --- src/harness/unittests/printer.ts | 3 +++ .../printerApi/printsFileCorrectly.regularExpressionLiteral.js | 1 + 2 files changed, 4 insertions(+) create mode 100644 tests/baselines/reference/printerApi/printsFileCorrectly.regularExpressionLiteral.js diff --git a/src/harness/unittests/printer.ts b/src/harness/unittests/printer.ts index 23e301f3669..825bfddbb4a 100644 --- a/src/harness/unittests/printer.ts +++ b/src/harness/unittests/printer.ts @@ -56,6 +56,9 @@ namespace ts { // github #14948 printsCorrectly("templateLiteral", {}, printer => printer.printFile(createSourceFile("source.ts", "let greeting = `Hi ${name}, how are you?`;", ScriptTarget.ES2017))); + + // github #18071 + printsCorrectly("regularExpressionLiteral", {}, printer => printer.printFile(createSourceFile("source.ts", "let regex = /abc/;", ScriptTarget.ES2017))); }); describe("printBundle", () => { diff --git a/tests/baselines/reference/printerApi/printsFileCorrectly.regularExpressionLiteral.js b/tests/baselines/reference/printerApi/printsFileCorrectly.regularExpressionLiteral.js new file mode 100644 index 00000000000..309f6899779 --- /dev/null +++ b/tests/baselines/reference/printerApi/printsFileCorrectly.regularExpressionLiteral.js @@ -0,0 +1 @@ +let regex = /abc/; From b21d3f03bd0f8db3c1152bf2ca8fc8dce95cbf0f Mon Sep 17 00:00:00 2001 From: Andy Hanson Date: Mon, 28 Aug 2017 07:48:43 -0700 Subject: [PATCH 159/370] Move browser-resolve to devDependencies --- package.json | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/package.json b/package.json index 8d28b6051c6..9e4b3234770 100644 --- a/package.json +++ b/package.json @@ -49,6 +49,7 @@ "@types/run-sequence": "latest", "@types/through2": "latest", "browserify": "latest", + "browser-resolve": "^1.11.2", "chai": "latest", "convert-source-map": "latest", "del": "latest", @@ -93,8 +94,5 @@ "fs": false, "os": false, "path": false - }, - "dependencies": { - "browser-resolve": "^1.11.2" } } From 117ef21bfcb9c5b4ebe28d20eaeca60477a7f912 Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Mon, 28 Aug 2017 10:23:41 -0700 Subject: [PATCH 160/370] Always use case-insensitive fs operartions for RWC (#18046) * Always use case-insensitive fs operartions for RWC * wrappedIO handles case sensitivity checks --- src/harness/loggedIO.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/harness/loggedIO.ts b/src/harness/loggedIO.ts index f113b9ddb9d..42519c729e5 100644 --- a/src/harness/loggedIO.ts +++ b/src/harness/loggedIO.ts @@ -70,6 +70,7 @@ interface IOLog { depth: number, result: ReadonlyArray, }[]; + useCaseSensitiveFileNames?: boolean; } interface PlaybackControl { @@ -151,7 +152,7 @@ namespace Playback { wrapper.startRecord = (fileNameBase) => { recordLogFileNameBase = fileNameBase; recordLog = createEmptyLog(); - + recordLog.useCaseSensitiveFileNames = typeof underlying.useCaseSensitiveFileNames === "function" ? underlying.useCaseSensitiveFileNames() : underlying.useCaseSensitiveFileNames; if (typeof underlying.args !== "function") { recordLog.arguments = underlying.args; } @@ -249,6 +250,8 @@ namespace Playback { } underlying.exit(exitCode); }; + + wrapper.useCaseSensitiveFileNames = () => !!recordLog.useCaseSensitiveFileNames; } function recordReplay(original: T, underlying: any) { From 8087206078f07f99f4e70f257661575e505ac293 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Mon, 28 Aug 2017 11:09:25 -0700 Subject: [PATCH 161/370] Explain boolean exception in getIndexedAccessType Booleans are not treated like other unions in order to skip straight to error reporting so that the error is reported with 'boolean' instead of 'true'. --- src/compiler/checker.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 8acecf57e50..69862a93d2f 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -7693,6 +7693,8 @@ namespace ts { return type; } // In the following we resolve T[K] to the type of the property in T selected by K. + // We treat boolean as different from other unions to improve errors; + // skipping straight to getPropertyTypeForIndexType gives errors with 'boolean' instead of 'true'. const apparentObjectType = getApparentType(objectType); if (indexType.flags & TypeFlags.Union && !(indexType.flags & TypeFlags.Boolean)) { const propTypes: Type[] = []; From bab287d252dd65035b72cc14a37b9ec09253e2c0 Mon Sep 17 00:00:00 2001 From: Andy Date: Mon, 28 Aug 2017 11:44:41 -0700 Subject: [PATCH 162/370] Simplify getAccessibleSymbolChain (#18053) --- src/compiler/checker.ts | 108 +++++++++++++++++++--------------------- 1 file changed, 50 insertions(+), 58 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 088cb4bb851..d671d0e558c 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -2056,12 +2056,15 @@ namespace ts { return rightMeaning === SymbolFlags.Value ? SymbolFlags.Value : SymbolFlags.Namespace; } - function getAccessibleSymbolChain(symbol: Symbol, enclosingDeclaration: Node, meaning: SymbolFlags, useOnlyExternalAliasing: boolean): Symbol[] { - function getAccessibleSymbolChainFromSymbolTable(symbols: SymbolTable) { - return getAccessibleSymbolChainFromSymbolTableWorker(symbols, []); + function getAccessibleSymbolChain(symbol: Symbol, enclosingDeclaration: Node, meaning: SymbolFlags, useOnlyExternalAliasing: boolean): Symbol[] | undefined { + if (!(symbol && !isPropertyOrMethodDeclarationSymbol(symbol))) { + return undefined; } - function getAccessibleSymbolChainFromSymbolTableWorker(symbols: SymbolTable, visitedSymbolTables: SymbolTable[]): Symbol[] { + const visitedSymbolTables: SymbolTable[] = []; + return forEachSymbolTableInScope(enclosingDeclaration, getAccessibleSymbolChainFromSymbolTable); + + function getAccessibleSymbolChainFromSymbolTable(symbols: SymbolTable): Symbol[] | undefined { if (!pushIfUnique(visitedSymbolTables, symbols)) { return undefined; } @@ -2069,62 +2072,51 @@ namespace ts { const result = trySymbolTable(symbols); visitedSymbolTables.pop(); return result; - - function canQualifySymbol(symbolFromSymbolTable: Symbol, meaning: SymbolFlags) { - // If the symbol is equivalent and doesn't need further qualification, this symbol is accessible - if (!needsQualification(symbolFromSymbolTable, enclosingDeclaration, meaning)) { - return true; - } - - // If symbol needs qualification, make sure that parent is accessible, if it is then this symbol is accessible too - const accessibleParent = getAccessibleSymbolChain(symbolFromSymbolTable.parent, enclosingDeclaration, getQualifiedLeftMeaning(meaning), useOnlyExternalAliasing); - return !!accessibleParent; - } - - function isAccessible(symbolFromSymbolTable: Symbol, resolvedAliasSymbol?: Symbol) { - if (symbol === (resolvedAliasSymbol || symbolFromSymbolTable)) { - // if the symbolFromSymbolTable is not external module (it could be if it was determined as ambient external module and would be in globals table) - // and if symbolFromSymbolTable or alias resolution matches the symbol, - // check the symbol can be qualified, it is only then this symbol is accessible - return !forEach(symbolFromSymbolTable.declarations, hasExternalModuleSymbol) && - canQualifySymbol(symbolFromSymbolTable, meaning); - } - } - - function trySymbolTable(symbols: SymbolTable) { - // If symbol is directly available by its name in the symbol table - if (isAccessible(symbols.get(symbol.escapedName))) { - return [symbol]; - } - - // Check if symbol is any of the alias - return forEachEntry(symbols, symbolFromSymbolTable => { - if (symbolFromSymbolTable.flags & SymbolFlags.Alias - && symbolFromSymbolTable.escapedName !== "export=" - && !getDeclarationOfKind(symbolFromSymbolTable, SyntaxKind.ExportSpecifier)) { - if (!useOnlyExternalAliasing || // We can use any type of alias to get the name - // Is this external alias, then use it to name - ts.forEach(symbolFromSymbolTable.declarations, isExternalModuleImportEqualsDeclaration)) { - - const resolvedImportedSymbol = resolveAlias(symbolFromSymbolTable); - if (isAccessible(symbolFromSymbolTable, resolvedImportedSymbol)) { - return [symbolFromSymbolTable]; - } - - // Look in the exported members, if we can find accessibleSymbolChain, symbol is accessible using this chain - // but only if the symbolFromSymbolTable can be qualified - const accessibleSymbolsFromExports = resolvedImportedSymbol.exports ? getAccessibleSymbolChainFromSymbolTableWorker(resolvedImportedSymbol.exports, visitedSymbolTables) : undefined; - if (accessibleSymbolsFromExports && canQualifySymbol(symbolFromSymbolTable, getQualifiedLeftMeaning(meaning))) { - return [symbolFromSymbolTable].concat(accessibleSymbolsFromExports); - } - } - } - }); - } } - if (symbol && !isPropertyOrMethodDeclarationSymbol(symbol)) { - return forEachSymbolTableInScope(enclosingDeclaration, getAccessibleSymbolChainFromSymbolTable); + function canQualifySymbol(symbolFromSymbolTable: Symbol, meaning: SymbolFlags) { + // If the symbol is equivalent and doesn't need further qualification, this symbol is accessible + return !needsQualification(symbolFromSymbolTable, enclosingDeclaration, meaning) || + // If symbol needs qualification, make sure that parent is accessible, if it is then this symbol is accessible too + !!getAccessibleSymbolChain(symbolFromSymbolTable.parent, enclosingDeclaration, getQualifiedLeftMeaning(meaning), useOnlyExternalAliasing); + } + + function isAccessible(symbolFromSymbolTable: Symbol, resolvedAliasSymbol?: Symbol) { + return symbol === (resolvedAliasSymbol || symbolFromSymbolTable) && + // if the symbolFromSymbolTable is not external module (it could be if it was determined as ambient external module and would be in globals table) + // and if symbolFromSymbolTable or alias resolution matches the symbol, + // check the symbol can be qualified, it is only then this symbol is accessible + !some(symbolFromSymbolTable.declarations, hasExternalModuleSymbol) && + canQualifySymbol(symbolFromSymbolTable, meaning); + } + + function trySymbolTable(symbols: SymbolTable) { + // If symbol is directly available by its name in the symbol table + if (isAccessible(symbols.get(symbol.escapedName))) { + return [symbol]; + } + + // Check if symbol is any of the alias + return forEachEntry(symbols, symbolFromSymbolTable => { + if (symbolFromSymbolTable.flags & SymbolFlags.Alias + && symbolFromSymbolTable.escapedName !== "export=" + && !getDeclarationOfKind(symbolFromSymbolTable, SyntaxKind.ExportSpecifier) + // If `!useOnlyExternalAliasing`, we can use any type of alias to get the name + && (!useOnlyExternalAliasing || some(symbolFromSymbolTable.declarations, isExternalModuleImportEqualsDeclaration))) { + + const resolvedImportedSymbol = resolveAlias(symbolFromSymbolTable); + if (isAccessible(symbolFromSymbolTable, resolvedImportedSymbol)) { + return [symbolFromSymbolTable]; + } + + // Look in the exported members, if we can find accessibleSymbolChain, symbol is accessible using this chain + // but only if the symbolFromSymbolTable can be qualified + const accessibleSymbolsFromExports = resolvedImportedSymbol.exports ? getAccessibleSymbolChainFromSymbolTable(resolvedImportedSymbol.exports) : undefined; + if (accessibleSymbolsFromExports && canQualifySymbol(symbolFromSymbolTable, getQualifiedLeftMeaning(meaning))) { + return [symbolFromSymbolTable].concat(accessibleSymbolsFromExports); + } + } + }); } } From 67f27161564beee44fb8665254bb35248a1d7dda Mon Sep 17 00:00:00 2001 From: Ryan Cavanaugh Date: Mon, 28 Aug 2017 13:32:20 -0700 Subject: [PATCH 163/370] Detect bad plugins and work around them --- src/server/project.ts | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/server/project.ts b/src/server/project.ts index 623c43e8d3a..4fb5ef78d75 100644 --- a/src/server/project.ts +++ b/src/server/project.ts @@ -999,16 +999,22 @@ namespace ts.server { if (this.projectService.globalPlugins) { // Enable global plugins with synthetic configuration entries for (const globalPluginName of this.projectService.globalPlugins) { + // Skip empty names from odd commandline parses + if (!globalPluginName) continue; + // Skip already-locally-loaded plugins if (options.plugins && options.plugins.some(p => p.name === globalPluginName)) continue; // Provide global: true so plugins can detect why they can't find their config + this.projectService.logger.info(`Loading global plugin ${globalPluginName}`); this.enablePlugin({ name: globalPluginName, global: true } as PluginImport, searchPaths); } } } private enablePlugin(pluginConfigEntry: PluginImport, searchPaths: string[]) { + this.projectService.logger.info(`Enabling plugin ${pluginConfigEntry.name} from candidate paths: ${searchPaths.join(",")}`); + const log = (message: string) => { this.projectService.logger.info(message); }; @@ -1020,7 +1026,7 @@ namespace ts.server { return; } } - this.projectService.logger.info(`Couldn't find ${pluginConfigEntry.name} anywhere in paths: ${searchPaths.join(",")}`); + this.projectService.logger.info(`Couldn't find ${pluginConfigEntry.name}`); } private enableProxy(pluginModuleFactory: PluginModuleFactory, configEntry: PluginImport) { @@ -1039,7 +1045,15 @@ namespace ts.server { }; const pluginModule = pluginModuleFactory({ typescript: ts }); - this.languageService = pluginModule.create(info); + const newLS = pluginModule.create(info); + for (const k of Object.keys(this.languageService)) { + if (!(k in newLS)) { + this.projectService.logger.info(`Plugin activation warning: Missing proxied method ${k} in created LS. Patching.`); + (newLS as any)[k] = (this.languageService as any)[k]; + } + } + this.projectService.logger.info(`Plugin validation succeded`); + this.languageService = newLS; this.plugins.push(pluginModule); } catch (e) { From 934da9fb39d36a4afa0121468847c88457fcfe1e Mon Sep 17 00:00:00 2001 From: Andy Date: Mon, 28 Aug 2017 15:03:34 -0700 Subject: [PATCH 164/370] Remove template strings in checker.ts (#18016) * Remove template strings in checker.ts * Inline function --- 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 bebd354d255..49b6e47d99d 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -3086,7 +3086,7 @@ namespace ts { } function literalTypeToString(type: LiteralType) { - return type.flags & TypeFlags.StringLiteral ? `"${escapeString((type).value)}"` : "" + (type).value; + return type.flags & TypeFlags.StringLiteral ? '"' + escapeString((type).value) + '"' : "" + (type).value; } function getNameOfSymbol(symbol: Symbol): string { @@ -6263,7 +6263,7 @@ namespace ts { if (isExternalModuleNameRelative(moduleName)) { return undefined; } - const symbol = getSymbol(globals, `"${moduleName}"` as __String, SymbolFlags.ValueModule); + const symbol = getSymbol(globals, '"' + moduleName + '"' as __String, SymbolFlags.ValueModule); // merged symbol is module declaration symbol combined with all augmentations return symbol && withAugmentations ? getMergedSymbol(symbol) : symbol; } @@ -15862,7 +15862,7 @@ namespace ts { min = Math.min(min, getMinTypeArgumentCount(sig.typeParameters)); max = Math.max(max, length(sig.typeParameters)); } - const paramCount = min < max ? `${min}-${max}` : min; + const paramCount = min < max ? min + "-" + max : min; diagnostics.add(createDiagnosticForNode(node, Diagnostics.Expected_0_type_arguments_but_got_1, paramCount, typeArguments.length)); } else if (args) { @@ -15875,7 +15875,7 @@ namespace ts { const hasRestParameter = some(signatures, sig => sig.hasRestParameter); const hasSpreadArgument = getSpreadArgumentIndex(args) > -1; const paramCount = hasRestParameter ? min : - min < max ? `${min}-${max}` : + min < max ? min + "-" + max : min; const argCount = args.length - (hasSpreadArgument ? 1 : 0); const error = hasRestParameter && hasSpreadArgument ? Diagnostics.Expected_at_least_0_arguments_but_got_a_minimum_of_1 : @@ -25089,7 +25089,7 @@ namespace ts { } if (diagnosticMessage) { const withMinus = isPrefixUnaryExpression(node.parent) && node.parent.operator === SyntaxKind.MinusToken; - const literal = `${withMinus ? "-" : ""}0o${node.text}`; + const literal = (withMinus ? "-" : "") + "0o" + node.text; return grammarErrorOnNode(withMinus ? node.parent : node, diagnosticMessage, literal); } } From 3ea031cf1cd8cbef03d02261bdc50e1b9a62276a Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Mon, 28 Aug 2017 15:45:21 -0700 Subject: [PATCH 165/370] Fix RWC - use replayLog, not recordLog (#18095) --- src/harness/loggedIO.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/harness/loggedIO.ts b/src/harness/loggedIO.ts index 42519c729e5..125283dcb22 100644 --- a/src/harness/loggedIO.ts +++ b/src/harness/loggedIO.ts @@ -251,7 +251,12 @@ namespace Playback { underlying.exit(exitCode); }; - wrapper.useCaseSensitiveFileNames = () => !!recordLog.useCaseSensitiveFileNames; + wrapper.useCaseSensitiveFileNames = () => { + if (replayLog !== undefined) { + return !!replayLog.useCaseSensitiveFileNames; + } + return typeof underlying.useCaseSensitiveFileNames === "function" ? underlying.useCaseSensitiveFileNames() : underlying.useCaseSensitiveFileNames; + }; } function recordReplay(original: T, underlying: any) { From 16ccb6637785724c2b215cb26ac2f7d727591130 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Mon, 28 Aug 2017 16:09:09 -0700 Subject: [PATCH 166/370] Provide jsdoc type code fixes for all variable-like decls This includes 3 SyntaxKinds I missed earlier: Parameter, PropertyDeclaration and PropertyAssignment. --- src/services/codefixes/fixJSDocTypes.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/services/codefixes/fixJSDocTypes.ts b/src/services/codefixes/fixJSDocTypes.ts index 249bc32dbf7..27c0edac628 100644 --- a/src/services/codefixes/fixJSDocTypes.ts +++ b/src/services/codefixes/fixJSDocTypes.ts @@ -8,11 +8,16 @@ namespace ts.codefix { function getActionsForJSDocTypes(context: CodeFixContext): CodeAction[] | undefined { const sourceFile = context.sourceFile; const node = getTokenAtPosition(sourceFile, context.span.start, /*includeJsDocComment*/ false); - const decl = ts.findAncestor(node, n => n.kind === SyntaxKind.VariableDeclaration); + const decl = ts.findAncestor(node, + n => n.kind === SyntaxKind.VariableDeclaration || + n.kind === SyntaxKind.Parameter || + n.kind === SyntaxKind.PropertyDeclaration || + n.kind === SyntaxKind.PropertyAssignment); if (!decl) return; const checker = context.program.getTypeChecker(); const jsdocType = (decl as VariableDeclaration).type; + if (!jsdocType) return; const original = getTextOfNode(jsdocType); const type = checker.getTypeFromTypeNode(jsdocType); const actions = [createAction(jsdocType, sourceFile.fileName, original, checker.typeToString(type, /*enclosingDeclaration*/ undefined, TypeFormatFlags.NoTruncation))]; From b082c27fbeb1b46b5a27838aba82edd64a50705e Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Mon, 28 Aug 2017 16:10:03 -0700 Subject: [PATCH 167/370] Test:jsdoc codefix for variable-like declarations --- tests/cases/fourslash/codeFixChangeJSDocSyntax10.ts | 5 +++++ tests/cases/fourslash/codeFixChangeJSDocSyntax11.ts | 5 +++++ tests/cases/fourslash/codeFixChangeJSDocSyntax12.ts | 6 ++++++ tests/cases/fourslash/codeFixChangeJSDocSyntax13.ts | 6 ++++++ 4 files changed, 22 insertions(+) create mode 100644 tests/cases/fourslash/codeFixChangeJSDocSyntax10.ts create mode 100644 tests/cases/fourslash/codeFixChangeJSDocSyntax11.ts create mode 100644 tests/cases/fourslash/codeFixChangeJSDocSyntax12.ts create mode 100644 tests/cases/fourslash/codeFixChangeJSDocSyntax13.ts diff --git a/tests/cases/fourslash/codeFixChangeJSDocSyntax10.ts b/tests/cases/fourslash/codeFixChangeJSDocSyntax10.ts new file mode 100644 index 00000000000..3e6754588fd --- /dev/null +++ b/tests/cases/fourslash/codeFixChangeJSDocSyntax10.ts @@ -0,0 +1,5 @@ +// @strict: true +/// +//// function f(x: [|number?|]) { +//// } +verify.rangeAfterCodeFix("number | null", /*includeWhiteSpace*/ false, /*errorCode*/ 8020, 0); diff --git a/tests/cases/fourslash/codeFixChangeJSDocSyntax11.ts b/tests/cases/fourslash/codeFixChangeJSDocSyntax11.ts new file mode 100644 index 00000000000..7ac80125775 --- /dev/null +++ b/tests/cases/fourslash/codeFixChangeJSDocSyntax11.ts @@ -0,0 +1,5 @@ +// @strict: true +/// +//// var f = function f(x: [|string?|]) { +//// } +verify.rangeAfterCodeFix("string | null | undefined", /*includeWhiteSpace*/ false, /*errorCode*/ 8020, 1); diff --git a/tests/cases/fourslash/codeFixChangeJSDocSyntax12.ts b/tests/cases/fourslash/codeFixChangeJSDocSyntax12.ts new file mode 100644 index 00000000000..37eb5df41ee --- /dev/null +++ b/tests/cases/fourslash/codeFixChangeJSDocSyntax12.ts @@ -0,0 +1,6 @@ +// @strict: true +/// +////class C { +//// p: [|*|] +////} +verify.rangeAfterCodeFix("any", /*includeWhiteSpace*/ false, /*errorCode*/ 8020, 0); diff --git a/tests/cases/fourslash/codeFixChangeJSDocSyntax13.ts b/tests/cases/fourslash/codeFixChangeJSDocSyntax13.ts new file mode 100644 index 00000000000..5b374b508f1 --- /dev/null +++ b/tests/cases/fourslash/codeFixChangeJSDocSyntax13.ts @@ -0,0 +1,6 @@ +// @strict: true +/// +////class C { +//// p: [|*|] = 12 +////} +verify.rangeAfterCodeFix("any", /*includeWhiteSpace*/ false, /*errorCode*/ 8020, 0); From 30b3cb0f682df870fe23f8b1196bab06de1380b6 Mon Sep 17 00:00:00 2001 From: Andy Date: Tue, 29 Aug 2017 07:53:22 -0700 Subject: [PATCH 168/370] Handle indexed access types in getSymbolAtLocation and findAllReferences (#17787) --- src/compiler/checker.ts | 20 ++++++++-- src/services/findAllReferences.ts | 4 +- src/services/rename.ts | 14 +++++-- src/services/utilities.ts | 38 +++++++++---------- .../findAllRefsIndexedAccessTypes.ts | 14 +++++++ 5 files changed, 60 insertions(+), 30 deletions(-) create mode 100644 tests/cases/fourslash/findAllRefsIndexedAccessTypes.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 49b6e47d99d..ed24e58096e 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -22905,7 +22905,7 @@ namespace ts { return undefined; } - function getSymbolAtLocation(node: Node) { + function getSymbolAtLocation(node: Node): Symbol | undefined { if (node.kind === SyntaxKind.SourceFile) { return isExternalModule(node) ? getMergedSymbol(node.symbol) : undefined; } @@ -22983,9 +22983,21 @@ namespace ts { case SyntaxKind.NumericLiteral: // index access - if (node.parent.kind === SyntaxKind.ElementAccessExpression && (node.parent).argumentExpression === node) { - const objectType = getTypeOfExpression((node.parent).expression); - return getPropertyOfType(objectType, (node).text as __String); + switch (node.parent.kind) { + case SyntaxKind.ElementAccessExpression: { + if ((node.parent).argumentExpression !== node) { + return undefined; + } + const objectType = getTypeOfExpression((node.parent).expression); + return getPropertyOfType(objectType, (node).text as __String); + } + case SyntaxKind.LiteralType: { + if (!isIndexedAccessTypeNode(node.parent.parent)) { + return undefined; + } + const objectType = getTypeFromTypeNode(node.parent.parent.objectType); + return getPropertyOfType(objectType, escapeLeadingUnderscores((node as StringLiteral | NumericLiteral).text)); + } } break; } diff --git a/src/services/findAllReferences.ts b/src/services/findAllReferences.ts index 4c8563b1b94..04d383748c8 100644 --- a/src/services/findAllReferences.ts +++ b/src/services/findAllReferences.ts @@ -748,11 +748,11 @@ namespace ts.FindAllReferences.Core { return (node as Identifier).text.length === searchSymbolName.length; case SyntaxKind.StringLiteral: - return (isLiteralNameOfPropertyDeclarationOrIndexAccess(node) || isNameOfExternalModuleImportOrDeclaration(node)) && + return (isLiteralNameOfPropertyDeclarationOrIndexAccess(node as StringLiteral) || isNameOfExternalModuleImportOrDeclaration(node)) && (node as StringLiteral).text.length === searchSymbolName.length; case SyntaxKind.NumericLiteral: - return isLiteralNameOfPropertyDeclarationOrIndexAccess(node) && (node as NumericLiteral).text.length === searchSymbolName.length; + return isLiteralNameOfPropertyDeclarationOrIndexAccess(node as NumericLiteral) && (node as NumericLiteral).text.length === searchSymbolName.length; default: return false; diff --git a/src/services/rename.ts b/src/services/rename.ts index 6091c0b2d03..8411e8200a3 100644 --- a/src/services/rename.ts +++ b/src/services/rename.ts @@ -89,9 +89,15 @@ namespace ts.Rename { } function nodeIsEligibleForRename(node: Node): boolean { - return node.kind === ts.SyntaxKind.Identifier || - node.kind === SyntaxKind.StringLiteral || - isLiteralNameOfPropertyDeclarationOrIndexAccess(node) || - isThis(node); + switch (node.kind) { + case SyntaxKind.Identifier: + case SyntaxKind.StringLiteral: + case SyntaxKind.ThisKeyword: + return true; + case SyntaxKind.NumericLiteral: + return isLiteralNameOfPropertyDeclarationOrIndexAccess(node as NumericLiteral); + default: + return false; + } } } diff --git a/src/services/utilities.ts b/src/services/utilities.ts index e8f01bb0785..c7f5b5909f0 100644 --- a/src/services/utilities.ts +++ b/src/services/utilities.ts @@ -244,27 +244,25 @@ namespace ts { isFunctionLike(node.parent) && (node.parent).name === node; } - export function isLiteralNameOfPropertyDeclarationOrIndexAccess(node: Node): boolean { - if (node.kind === SyntaxKind.StringLiteral || node.kind === SyntaxKind.NumericLiteral) { - switch (node.parent.kind) { - case SyntaxKind.PropertyDeclaration: - case SyntaxKind.PropertySignature: - case SyntaxKind.PropertyAssignment: - case SyntaxKind.EnumMember: - case SyntaxKind.MethodDeclaration: - case SyntaxKind.MethodSignature: - case SyntaxKind.GetAccessor: - case SyntaxKind.SetAccessor: - case SyntaxKind.ModuleDeclaration: - return getNameOfDeclaration(node.parent) === node; - case SyntaxKind.ElementAccessExpression: - return (node.parent).argumentExpression === node; - case SyntaxKind.ComputedPropertyName: - return true; - } + export function isLiteralNameOfPropertyDeclarationOrIndexAccess(node: StringLiteral | NumericLiteral): boolean { + switch (node.parent.kind) { + case SyntaxKind.PropertyDeclaration: + case SyntaxKind.PropertySignature: + case SyntaxKind.PropertyAssignment: + case SyntaxKind.EnumMember: + case SyntaxKind.MethodDeclaration: + case SyntaxKind.MethodSignature: + case SyntaxKind.GetAccessor: + case SyntaxKind.SetAccessor: + case SyntaxKind.ModuleDeclaration: + return getNameOfDeclaration(node.parent) === node; + case SyntaxKind.ElementAccessExpression: + return (node.parent).argumentExpression === node; + case SyntaxKind.ComputedPropertyName: + return true; + case SyntaxKind.LiteralType: + return node.parent.parent.kind === SyntaxKind.IndexedAccessType; } - - return false; } export function isExpressionOfExternalModuleImportEqualsDeclaration(node: Node) { diff --git a/tests/cases/fourslash/findAllRefsIndexedAccessTypes.ts b/tests/cases/fourslash/findAllRefsIndexedAccessTypes.ts new file mode 100644 index 00000000000..32f8207f27e --- /dev/null +++ b/tests/cases/fourslash/findAllRefsIndexedAccessTypes.ts @@ -0,0 +1,14 @@ +/// + +////interface I { +//// [|{| "isDefinition": true, "isWriteAccess": true |}0|]: number; +//// [|{| "isDefinition": true, "isWriteAccess": true |}s|]: string; +////} +////interface J { +//// a: I[[|0|]], +//// b: I["[|s|]"], +////} + +const [n0, s0, n1, s1] = test.ranges(); +verify.singleReferenceGroup("(property) I[0]: number", [n0, n1]); +verify.singleReferenceGroup("(property) I.s: string", [s0, s1]); From e3b14872400369f21f645d78b6f74e55eda01975 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Tue, 29 Aug 2017 09:00:17 -0700 Subject: [PATCH 169/370] Check all properties are present before checking types in relationships --- src/compiler/checker.ts | 35 +++++++++++++++++------------------ 1 file changed, 17 insertions(+), 18 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 49b6e47d99d..a38988d6c95 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -9424,21 +9424,20 @@ namespace ts { if (relation === identityRelation) { return propertiesIdenticalTo(source, target); } + const requireOptionalProperties = relation === subtypeRelation && !(getObjectFlags(source) & ObjectFlags.ObjectLiteral); + const unmatchedProperty = getUnmatchedProperty(source, target, requireOptionalProperties); + if (unmatchedProperty) { + if (reportErrors) { + reportError(Diagnostics.Property_0_is_missing_in_type_1, symbolToString(unmatchedProperty), typeToString(source)); + } + return Ternary.False; + } let result = Ternary.True; const properties = getPropertiesOfObjectType(target); - const requireOptionalProperties = relation === subtypeRelation && !(getObjectFlags(source) & ObjectFlags.ObjectLiteral); for (const targetProp of properties) { - const sourceProp = getPropertyOfType(source, targetProp.escapedName); - if (sourceProp !== targetProp) { - if (!sourceProp) { - if (!(targetProp.flags & SymbolFlags.Optional) || requireOptionalProperties) { - if (reportErrors) { - reportError(Diagnostics.Property_0_is_missing_in_type_1, symbolToString(targetProp), typeToString(source)); - } - return Ternary.False; - } - } - else if (!(targetProp.flags & SymbolFlags.Prototype)) { + if (!(targetProp.flags & SymbolFlags.Prototype)) { + const sourceProp = getPropertyOfType(source, targetProp.escapedName); + if (sourceProp && sourceProp !== targetProp) { const sourcePropFlags = getDeclarationModifierFlagsFromSymbol(sourceProp); const targetPropFlags = getDeclarationModifierFlagsFromSymbol(targetProp); if (sourcePropFlags & ModifierFlags.Private || targetPropFlags & ModifierFlags.Private) { @@ -10463,17 +10462,17 @@ namespace ts { } } - function isPossiblyAssignableTo(source: Type, target: Type) { + function getUnmatchedProperty(source: Type, target: Type, requireOptionalProperties: boolean) { const properties = getPropertiesOfObjectType(target); for (const targetProp of properties) { - if (!(targetProp.flags & (SymbolFlags.Optional | SymbolFlags.Prototype))) { - const sourceProp = getPropertyOfObjectType(source, targetProp.escapedName); + if (requireOptionalProperties || !(targetProp.flags & SymbolFlags.Optional)) { + const sourceProp = getPropertyOfType(source, targetProp.escapedName); if (!sourceProp) { - return false; + return targetProp; } } } - return true; + return undefined; } function inferTypes(inferences: InferenceInfo[], originalSource: Type, originalTarget: Type, priority: InferencePriority = 0) { @@ -10671,7 +10670,7 @@ namespace ts { } // Infer from the members of source and target only if the two types are possibly related. We check // in both directions because we may be inferring for a co-variant or a contra-variant position. - if (isPossiblyAssignableTo(source, target) || isPossiblyAssignableTo(target, source)) { + if (!getUnmatchedProperty(source, target, /*requireOptionalProperties*/ false) || !getUnmatchedProperty(target, source, /*requireOptionalProperties*/ false)) { inferFromProperties(source, target); inferFromSignatures(source, target, SignatureKind.Call); inferFromSignatures(source, target, SignatureKind.Construct); From 86930c9aab523eee0cedffa74f297bb41e2d12d2 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Tue, 29 Aug 2017 09:01:31 -0700 Subject: [PATCH 170/370] Accept new baselines --- .../arityAndOrderCompatibility01.errors.txt | 30 +++++++------------ ...lTypeWithUnionTypeObjectLiteral.errors.txt | 8 ++--- .../reference/promisePermutations.errors.txt | 12 ++------ .../reference/promisePermutations2.errors.txt | 12 ++------ .../reference/promisePermutations3.errors.txt | 20 +++---------- ...ponentWithDefaultTypeParameter2.errors.txt | 6 ++-- ...elessFunctionComponentOverload4.errors.txt | 12 +++----- 7 files changed, 26 insertions(+), 74 deletions(-) diff --git a/tests/baselines/reference/arityAndOrderCompatibility01.errors.txt b/tests/baselines/reference/arityAndOrderCompatibility01.errors.txt index a6a685069d6..5a367a4122f 100644 --- a/tests/baselines/reference/arityAndOrderCompatibility01.errors.txt +++ b/tests/baselines/reference/arityAndOrderCompatibility01.errors.txt @@ -3,14 +3,11 @@ tests/cases/conformance/types/tuple/arityAndOrderCompatibility01.ts(14,12): erro tests/cases/conformance/types/tuple/arityAndOrderCompatibility01.ts(15,5): error TS2461: Type '{ 0: string; 1: number; }' is not an array type. tests/cases/conformance/types/tuple/arityAndOrderCompatibility01.ts(15,12): error TS2460: Type '{ 0: string; 1: number; }' has no property '2'. tests/cases/conformance/types/tuple/arityAndOrderCompatibility01.ts(16,5): error TS2322: Type '[string, number]' is not assignable to type '[number, number, number]'. - Types of property '0' are incompatible. - Type 'string' is not assignable to type 'number'. + Property '2' is missing in type '[string, number]'. tests/cases/conformance/types/tuple/arityAndOrderCompatibility01.ts(17,5): error TS2322: Type 'StrNum' is not assignable to type '[number, number, number]'. - Types of property '0' are incompatible. - Type 'string' is not assignable to type 'number'. + Property '2' is missing in type 'StrNum'. tests/cases/conformance/types/tuple/arityAndOrderCompatibility01.ts(18,5): error TS2322: Type '{ 0: string; 1: number; }' is not assignable to type '[number, number, number]'. - Types of property '0' are incompatible. - Type 'string' is not assignable to type 'number'. + Property '2' is missing in type '{ 0: string; 1: number; }'. tests/cases/conformance/types/tuple/arityAndOrderCompatibility01.ts(19,5): error TS2322: Type '[string, number]' is not assignable to type '[string, number, number]'. Property '2' is missing in type '[string, number]'. tests/cases/conformance/types/tuple/arityAndOrderCompatibility01.ts(20,5): error TS2322: Type 'StrNum' is not assignable to type '[string, number, number]'. @@ -24,8 +21,7 @@ tests/cases/conformance/types/tuple/arityAndOrderCompatibility01.ts(23,5): error Types of property '0' are incompatible. Type 'string' is not assignable to type 'number'. tests/cases/conformance/types/tuple/arityAndOrderCompatibility01.ts(24,5): error TS2322: Type '{ 0: string; 1: number; }' is not assignable to type '[number]'. - Types of property '0' are incompatible. - Type 'string' is not assignable to type 'number'. + Property 'length' is missing in type '{ 0: string; 1: number; }'. tests/cases/conformance/types/tuple/arityAndOrderCompatibility01.ts(25,5): error TS2322: Type '[string, number]' is not assignable to type '[string]'. Types of property 'pop' are incompatible. Type '() => string | number' is not assignable to type '() => string'. @@ -44,8 +40,7 @@ tests/cases/conformance/types/tuple/arityAndOrderCompatibility01.ts(29,5): error Types of property '0' are incompatible. Type 'string' is not assignable to type 'number'. tests/cases/conformance/types/tuple/arityAndOrderCompatibility01.ts(30,5): error TS2322: Type '{ 0: string; 1: number; }' is not assignable to type '[number, string]'. - Types of property '0' are incompatible. - Type 'string' is not assignable to type 'number'. + Property 'length' is missing in type '{ 0: string; 1: number; }'. ==== tests/cases/conformance/types/tuple/arityAndOrderCompatibility01.ts (19 errors) ==== @@ -75,18 +70,15 @@ tests/cases/conformance/types/tuple/arityAndOrderCompatibility01.ts(30,5): error var j1: [number, number, number] = x; ~~ !!! error TS2322: Type '[string, number]' is not assignable to type '[number, number, number]'. -!!! error TS2322: Types of property '0' are incompatible. -!!! error TS2322: Type 'string' is not assignable to type 'number'. +!!! error TS2322: Property '2' is missing in type '[string, number]'. var j2: [number, number, number] = y; ~~ !!! error TS2322: Type 'StrNum' is not assignable to type '[number, number, number]'. -!!! error TS2322: Types of property '0' are incompatible. -!!! error TS2322: Type 'string' is not assignable to type 'number'. +!!! error TS2322: Property '2' is missing in type 'StrNum'. var j3: [number, number, number] = z; ~~ !!! error TS2322: Type '{ 0: string; 1: number; }' is not assignable to type '[number, number, number]'. -!!! error TS2322: Types of property '0' are incompatible. -!!! error TS2322: Type 'string' is not assignable to type 'number'. +!!! error TS2322: Property '2' is missing in type '{ 0: string; 1: number; }'. var k1: [string, number, number] = x; ~~ !!! error TS2322: Type '[string, number]' is not assignable to type '[string, number, number]'. @@ -112,8 +104,7 @@ tests/cases/conformance/types/tuple/arityAndOrderCompatibility01.ts(30,5): error var l3: [number] = z; ~~ !!! error TS2322: Type '{ 0: string; 1: number; }' is not assignable to type '[number]'. -!!! error TS2322: Types of property '0' are incompatible. -!!! error TS2322: Type 'string' is not assignable to type 'number'. +!!! error TS2322: Property 'length' is missing in type '{ 0: string; 1: number; }'. var m1: [string] = x; ~~ !!! error TS2322: Type '[string, number]' is not assignable to type '[string]'. @@ -144,8 +135,7 @@ tests/cases/conformance/types/tuple/arityAndOrderCompatibility01.ts(30,5): error var n3: [number, string] = z; ~~ !!! error TS2322: Type '{ 0: string; 1: number; }' is not assignable to type '[number, string]'. -!!! error TS2322: Types of property '0' are incompatible. -!!! error TS2322: Type 'string' is not assignable to type 'number'. +!!! error TS2322: Property 'length' is missing in type '{ 0: string; 1: number; }'. var o1: [string, number] = x; var o2: [string, number] = y; var o3: [string, number] = y; diff --git a/tests/baselines/reference/contextualTypeWithUnionTypeObjectLiteral.errors.txt b/tests/baselines/reference/contextualTypeWithUnionTypeObjectLiteral.errors.txt index 8be323f9af4..651d4f5381f 100644 --- a/tests/baselines/reference/contextualTypeWithUnionTypeObjectLiteral.errors.txt +++ b/tests/baselines/reference/contextualTypeWithUnionTypeObjectLiteral.errors.txt @@ -15,9 +15,7 @@ tests/cases/conformance/types/union/contextualTypeWithUnionTypeObjectLiteral.ts( Type 'string' is not assignable to type 'number'. tests/cases/conformance/types/union/contextualTypeWithUnionTypeObjectLiteral.ts(25,5): error TS2322: Type '{ prop: string | number; anotherP: string; }' is not assignable to type '{ prop: string; anotherP: string; } | { prop: number; anotherP1: number; }'. Type '{ prop: string | number; anotherP: string; }' is not assignable to type '{ prop: number; anotherP1: number; }'. - Types of property 'prop' are incompatible. - Type 'string | number' is not assignable to type 'number'. - Type 'string' is not assignable to type 'number'. + Property 'anotherP1' is missing in type '{ prop: string | number; anotherP: string; }'. tests/cases/conformance/types/union/contextualTypeWithUnionTypeObjectLiteral.ts(29,5): error TS2322: Type '{ prop: string | number; anotherP: string; anotherP1: number; }' is not assignable to type '{ prop: string; anotherP: string; } | { prop: number; anotherP1: number; }'. Type '{ prop: string | number; anotherP: string; anotherP1: number; }' is not assignable to type '{ prop: number; anotherP1: number; }'. Types of property 'prop' are incompatible. @@ -78,9 +76,7 @@ tests/cases/conformance/types/union/contextualTypeWithUnionTypeObjectLiteral.ts( ~~~~~~~~~~~~ !!! error TS2322: Type '{ prop: string | number; anotherP: string; }' is not assignable to type '{ prop: string; anotherP: string; } | { prop: number; anotherP1: number; }'. !!! error TS2322: Type '{ prop: string | number; anotherP: string; }' is not assignable to type '{ prop: number; anotherP1: number; }'. -!!! error TS2322: Types of property 'prop' are incompatible. -!!! error TS2322: Type 'string | number' is not assignable to type 'number'. -!!! error TS2322: Type 'string' is not assignable to type 'number'. +!!! error TS2322: Property 'anotherP1' is missing in type '{ prop: string | number; anotherP: string; }'. prop: strOrNumber, anotherP: str }; diff --git a/tests/baselines/reference/promisePermutations.errors.txt b/tests/baselines/reference/promisePermutations.errors.txt index a876345ffa1..32506d113b4 100644 --- a/tests/baselines/reference/promisePermutations.errors.txt +++ b/tests/baselines/reference/promisePermutations.errors.txt @@ -48,11 +48,7 @@ tests/cases/compiler/promisePermutations.ts(144,35): error TS2345: Argument of t Type 'IPromise' is not assignable to type 'IPromise'. tests/cases/compiler/promisePermutations.ts(152,36): error TS2345: Argument of type '(x: any) => IPromise' is not assignable to parameter of type '(error: any) => Promise'. Type 'IPromise' is not assignable to type 'Promise'. - Types of property 'then' are incompatible. - Type '{ (success?: (value: string) => IPromise, error?: (error: any) => IPromise, progress?: (progress: any) => void): IPromise; (success?: (value: string) => IPromise, error?: (error: any) => U, progress?: (progress: any) => void): IPromise; (success?: (value: string) => U, error?: (error: any) => IPromise, progress?: (progress: any) => void): IPromise; (success?: (value: string) => U, error?: (error: any) => U, progress?: (progress: any) => void): IPromise; }' is not assignable to type '{ (onfulfilled?: (value: number) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike): Promise; (success?: (value: number) => Promise, error?: (error: any) => Promise, progress?: (progress: any) => void): Promise; (success?: (value: number) => Promise, error?: (error: any) => U, progress?: (progress: any) => void): Promise; (success?: (value: number) => U, error?: (error: any) => Promise, progress?: (progress: any) => void): Promise; (success?: (value: number) => U, error?: (error: any) => U, progress?: (progress: any) => void): Promise; }'. - Types of parameters 'success' and 'onfulfilled' are incompatible. - Types of parameters 'value' and 'value' are incompatible. - Type 'string' is not assignable to type 'number'. + Property 'catch' is missing in type 'IPromise'. tests/cases/compiler/promisePermutations.ts(156,21): error TS2345: Argument of type '{ (x: number): IPromise; (x: string): IPromise; }' is not assignable to parameter of type '(value: number) => IPromise'. Type 'IPromise' is not assignable to type 'IPromise'. Type 'number' is not assignable to type 'string'. @@ -302,11 +298,7 @@ tests/cases/compiler/promisePermutations.ts(160,21): error TS2345: Argument of t ~~~~~~~~~ !!! error TS2345: Argument of type '(x: any) => IPromise' is not assignable to parameter of type '(error: any) => Promise'. !!! error TS2345: Type 'IPromise' is not assignable to type 'Promise'. -!!! error TS2345: Types of property 'then' are incompatible. -!!! error TS2345: Type '{ (success?: (value: string) => IPromise, error?: (error: any) => IPromise, progress?: (progress: any) => void): IPromise; (success?: (value: string) => IPromise, error?: (error: any) => U, progress?: (progress: any) => void): IPromise; (success?: (value: string) => U, error?: (error: any) => IPromise, progress?: (progress: any) => void): IPromise; (success?: (value: string) => U, error?: (error: any) => U, progress?: (progress: any) => void): IPromise; }' is not assignable to type '{ (onfulfilled?: (value: number) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike): Promise; (success?: (value: number) => Promise, error?: (error: any) => Promise, progress?: (progress: any) => void): Promise; (success?: (value: number) => Promise, error?: (error: any) => U, progress?: (progress: any) => void): Promise; (success?: (value: number) => U, error?: (error: any) => Promise, progress?: (progress: any) => void): Promise; (success?: (value: number) => U, error?: (error: any) => U, progress?: (progress: any) => void): Promise; }'. -!!! error TS2345: Types of parameters 'success' and 'onfulfilled' are incompatible. -!!! error TS2345: Types of parameters 'value' and 'value' are incompatible. -!!! error TS2345: Type 'string' is not assignable to type 'number'. +!!! error TS2345: Property 'catch' is missing in type 'IPromise'. var s10g = s10.then(testFunctionP, nIPromise, sIPromise).then(sPromise, sIPromise, sIPromise); // ok var r11: IPromise; diff --git a/tests/baselines/reference/promisePermutations2.errors.txt b/tests/baselines/reference/promisePermutations2.errors.txt index 871ee2ae2c3..f197507c0d2 100644 --- a/tests/baselines/reference/promisePermutations2.errors.txt +++ b/tests/baselines/reference/promisePermutations2.errors.txt @@ -48,11 +48,7 @@ tests/cases/compiler/promisePermutations2.ts(143,35): error TS2345: Argument of Type 'IPromise' is not assignable to type 'IPromise'. tests/cases/compiler/promisePermutations2.ts(151,36): error TS2345: Argument of type '(x: any) => IPromise' is not assignable to parameter of type '(error: any) => Promise'. Type 'IPromise' is not assignable to type 'Promise'. - Types of property 'then' are incompatible. - Type '{ (success?: (value: string) => IPromise, error?: (error: any) => IPromise, progress?: (progress: any) => void): IPromise; (success?: (value: string) => IPromise, error?: (error: any) => U, progress?: (progress: any) => void): IPromise; (success?: (value: string) => U, error?: (error: any) => IPromise, progress?: (progress: any) => void): IPromise; (success?: (value: string) => U, error?: (error: any) => U, progress?: (progress: any) => void): IPromise; }' is not assignable to type '{ (onfulfilled?: (value: number) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike): Promise; (success?: (value: number) => U, error?: (error: any) => U, progress?: (progress: any) => void): Promise; }'. - Types of parameters 'success' and 'onfulfilled' are incompatible. - Types of parameters 'value' and 'value' are incompatible. - Type 'string' is not assignable to type 'number'. + Property 'catch' is missing in type 'IPromise'. tests/cases/compiler/promisePermutations2.ts(155,21): error TS2345: Argument of type '{ (x: number): IPromise; (x: string): IPromise; }' is not assignable to parameter of type '(value: number) => IPromise'. Type 'IPromise' is not assignable to type 'IPromise'. Type 'number' is not assignable to type 'string'. @@ -301,11 +297,7 @@ tests/cases/compiler/promisePermutations2.ts(159,21): error TS2345: Argument of ~~~~~~~~~ !!! error TS2345: Argument of type '(x: any) => IPromise' is not assignable to parameter of type '(error: any) => Promise'. !!! error TS2345: Type 'IPromise' is not assignable to type 'Promise'. -!!! error TS2345: Types of property 'then' are incompatible. -!!! error TS2345: Type '{ (success?: (value: string) => IPromise, error?: (error: any) => IPromise, progress?: (progress: any) => void): IPromise; (success?: (value: string) => IPromise, error?: (error: any) => U, progress?: (progress: any) => void): IPromise; (success?: (value: string) => U, error?: (error: any) => IPromise, progress?: (progress: any) => void): IPromise; (success?: (value: string) => U, error?: (error: any) => U, progress?: (progress: any) => void): IPromise; }' is not assignable to type '{ (onfulfilled?: (value: number) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike): Promise; (success?: (value: number) => U, error?: (error: any) => U, progress?: (progress: any) => void): Promise; }'. -!!! error TS2345: Types of parameters 'success' and 'onfulfilled' are incompatible. -!!! error TS2345: Types of parameters 'value' and 'value' are incompatible. -!!! error TS2345: Type 'string' is not assignable to type 'number'. +!!! error TS2345: Property 'catch' is missing in type 'IPromise'. var s10g = s10.then(testFunctionP, nIPromise, sIPromise).then(sPromise, sIPromise, sIPromise); // ok var r11: IPromise; diff --git a/tests/baselines/reference/promisePermutations3.errors.txt b/tests/baselines/reference/promisePermutations3.errors.txt index 9d09559c5d3..da78e8d75ca 100644 --- a/tests/baselines/reference/promisePermutations3.errors.txt +++ b/tests/baselines/reference/promisePermutations3.errors.txt @@ -51,11 +51,7 @@ tests/cases/compiler/promisePermutations3.ts(143,35): error TS2345: Argument of Type 'IPromise' is not assignable to type 'IPromise'. tests/cases/compiler/promisePermutations3.ts(151,36): error TS2345: Argument of type '(x: any) => IPromise' is not assignable to parameter of type '(error: any) => Promise'. Type 'IPromise' is not assignable to type 'Promise'. - Types of property 'then' are incompatible. - Type '(success?: (value: string) => U, error?: (error: any) => U, progress?: (progress: any) => void) => IPromise' is not assignable to type '{ (onfulfilled?: (value: number) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike): Promise; (success?: (value: number) => Promise, error?: (error: any) => Promise, progress?: (progress: any) => void): Promise; (success?: (value: number) => Promise, error?: (error: any) => U, progress?: (progress: any) => void): Promise; (success?: (value: number) => U, error?: (error: any) => Promise, progress?: (progress: any) => void): Promise; (success?: (value: number) => U, error?: (error: any) => U, progress?: (progress: any) => void): Promise; }'. - Types of parameters 'success' and 'onfulfilled' are incompatible. - Types of parameters 'value' and 'value' are incompatible. - Type 'string' is not assignable to type 'number'. + Property 'catch' is missing in type 'IPromise'. tests/cases/compiler/promisePermutations3.ts(155,21): error TS2345: Argument of type '{ (x: number): IPromise; (x: string): IPromise; }' is not assignable to parameter of type '(value: number) => IPromise'. Type 'IPromise' is not assignable to type 'IPromise'. Type 'number' is not assignable to type 'string'. @@ -73,9 +69,7 @@ tests/cases/compiler/promisePermutations3.ts(159,21): error TS2345: Argument of Type 'number' is not assignable to type 'string'. tests/cases/compiler/promisePermutations3.ts(165,21): error TS2345: Argument of type '{ (x: T): IPromise; (x: T, y: T): Promise; }' is not assignable to parameter of type '(value: (x: any) => any) => Promise'. Type 'IPromise' is not assignable to type 'Promise'. - Types of property 'then' are incompatible. - Type '(success?: (value: any) => U, error?: (error: any) => U, progress?: (progress: any) => void) => IPromise' is not assignable to type '{ (onfulfilled?: (value: any) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike): Promise; (success?: (value: any) => Promise, error?: (error: any) => Promise, progress?: (progress: any) => void): Promise; (success?: (value: any) => Promise, error?: (error: any) => U, progress?: (progress: any) => void): Promise; (success?: (value: any) => U, error?: (error: any) => Promise, progress?: (progress: any) => void): Promise; (success?: (value: any) => U, error?: (error: any) => U, progress?: (progress: any) => void): Promise; }'. - Type 'IPromise' is not assignable to type 'Promise'. + Property 'catch' is missing in type 'IPromise'. ==== tests/cases/compiler/promisePermutations3.ts (35 errors) ==== @@ -313,11 +307,7 @@ tests/cases/compiler/promisePermutations3.ts(165,21): error TS2345: Argument of ~~~~~~~~~ !!! error TS2345: Argument of type '(x: any) => IPromise' is not assignable to parameter of type '(error: any) => Promise'. !!! error TS2345: Type 'IPromise' is not assignable to type 'Promise'. -!!! error TS2345: Types of property 'then' are incompatible. -!!! error TS2345: Type '(success?: (value: string) => U, error?: (error: any) => U, progress?: (progress: any) => void) => IPromise' is not assignable to type '{ (onfulfilled?: (value: number) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike): Promise; (success?: (value: number) => Promise, error?: (error: any) => Promise, progress?: (progress: any) => void): Promise; (success?: (value: number) => Promise, error?: (error: any) => U, progress?: (progress: any) => void): Promise; (success?: (value: number) => U, error?: (error: any) => Promise, progress?: (progress: any) => void): Promise; (success?: (value: number) => U, error?: (error: any) => U, progress?: (progress: any) => void): Promise; }'. -!!! error TS2345: Types of parameters 'success' and 'onfulfilled' are incompatible. -!!! error TS2345: Types of parameters 'value' and 'value' are incompatible. -!!! error TS2345: Type 'string' is not assignable to type 'number'. +!!! error TS2345: Property 'catch' is missing in type 'IPromise'. var s10g = s10.then(testFunctionP, nIPromise, sIPromise).then(sPromise, sIPromise, sIPromise); // ok var r11: IPromise; @@ -354,7 +344,5 @@ tests/cases/compiler/promisePermutations3.ts(165,21): error TS2345: Argument of ~~~~~~~~~~~~~~~ !!! error TS2345: Argument of type '{ (x: T): IPromise; (x: T, y: T): Promise; }' is not assignable to parameter of type '(value: (x: any) => any) => Promise'. !!! error TS2345: Type 'IPromise' is not assignable to type 'Promise'. -!!! error TS2345: Types of property 'then' are incompatible. -!!! error TS2345: Type '(success?: (value: any) => U, error?: (error: any) => U, progress?: (progress: any) => void) => IPromise' is not assignable to type '{ (onfulfilled?: (value: any) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike): Promise; (success?: (value: any) => Promise, error?: (error: any) => Promise, progress?: (progress: any) => void): Promise; (success?: (value: any) => Promise, error?: (error: any) => U, progress?: (progress: any) => void): Promise; (success?: (value: any) => U, error?: (error: any) => Promise, progress?: (progress: any) => void): Promise; (success?: (value: any) => U, error?: (error: any) => U, progress?: (progress: any) => void): Promise; }'. -!!! error TS2345: Type 'IPromise' is not assignable to type 'Promise'. +!!! error TS2345: Property 'catch' is missing in type 'IPromise'. var s12c = s12.then(testFunction12P, testFunction12, testFunction12); // ok \ No newline at end of file diff --git a/tests/baselines/reference/tsxReactComponentWithDefaultTypeParameter2.errors.txt b/tests/baselines/reference/tsxReactComponentWithDefaultTypeParameter2.errors.txt index 61d26c8afd6..af5024ae7fb 100644 --- a/tests/baselines/reference/tsxReactComponentWithDefaultTypeParameter2.errors.txt +++ b/tests/baselines/reference/tsxReactComponentWithDefaultTypeParameter2.errors.txt @@ -3,8 +3,7 @@ tests/cases/conformance/jsx/file.tsx(13,9): error TS2322: Type '{}' is not assig Property 'a' is missing in type '{}'. tests/cases/conformance/jsx/file.tsx(14,18): error TS2322: Type '{ a: "hi"; }' is not assignable to type 'IntrinsicAttributes & IntrinsicClassAttributes> & Prop & { children?: ReactNode; }'. Type '{ a: "hi"; }' is not assignable to type 'Prop'. - Types of property 'a' are incompatible. - Type '"hi"' is not assignable to type 'number'. + Property 'b' is missing in type '{ a: "hi"; }'. ==== tests/cases/conformance/jsx/file.tsx (2 errors) ==== @@ -29,5 +28,4 @@ tests/cases/conformance/jsx/file.tsx(14,18): error TS2322: Type '{ a: "hi"; }' i ~~~~~~ !!! error TS2322: Type '{ a: "hi"; }' is not assignable to type 'IntrinsicAttributes & IntrinsicClassAttributes> & Prop & { children?: ReactNode; }'. !!! error TS2322: Type '{ a: "hi"; }' is not assignable to type 'Prop'. -!!! error TS2322: Types of property 'a' are incompatible. -!!! error TS2322: Type '"hi"' is not assignable to type 'number'. \ No newline at end of file +!!! error TS2322: Property 'b' is missing in type '{ a: "hi"; }'. \ No newline at end of file diff --git a/tests/baselines/reference/tsxStatelessFunctionComponentOverload4.errors.txt b/tests/baselines/reference/tsxStatelessFunctionComponentOverload4.errors.txt index 4f717bfca96..f569e8d8b3d 100644 --- a/tests/baselines/reference/tsxStatelessFunctionComponentOverload4.errors.txt +++ b/tests/baselines/reference/tsxStatelessFunctionComponentOverload4.errors.txt @@ -30,12 +30,10 @@ tests/cases/conformance/jsx/file.tsx(34,29): error TS2322: Type '{ y1: "hello"; Type '"hello"' is not assignable to type 'boolean'. tests/cases/conformance/jsx/file.tsx(35,29): error TS2322: Type '{ y1: "hello"; y2: 1000; children: "hi"; }' is not assignable to type 'IntrinsicAttributes & { y1: boolean; y2?: number; y3: boolean; }'. Type '{ y1: "hello"; y2: 1000; children: "hi"; }' is not assignable to type '{ y1: boolean; y2?: number; y3: boolean; }'. - Types of property 'y1' are incompatible. - Type '"hello"' is not assignable to type 'boolean'. + Property 'y3' is missing in type '{ y1: "hello"; y2: 1000; children: "hi"; }'. tests/cases/conformance/jsx/file.tsx(36,29): error TS2322: Type '{ y1: "hello"; y2: 1000; children: string; }' is not assignable to type 'IntrinsicAttributes & { y1: boolean; y2?: number; y3: boolean; }'. Type '{ y1: "hello"; y2: 1000; children: string; }' is not assignable to type '{ y1: boolean; y2?: number; y3: boolean; }'. - Types of property 'y1' are incompatible. - Type '"hello"' is not assignable to type 'boolean'. + Property 'y3' is missing in type '{ y1: "hello"; y2: 1000; children: string; }'. ==== tests/cases/conformance/jsx/file.tsx (11 errors) ==== @@ -116,12 +114,10 @@ tests/cases/conformance/jsx/file.tsx(36,29): error TS2322: Type '{ y1: "hello"; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS2322: Type '{ y1: "hello"; y2: 1000; children: "hi"; }' is not assignable to type 'IntrinsicAttributes & { y1: boolean; y2?: number; y3: boolean; }'. !!! error TS2322: Type '{ y1: "hello"; y2: 1000; children: "hi"; }' is not assignable to type '{ y1: boolean; y2?: number; y3: boolean; }'. -!!! error TS2322: Types of property 'y1' are incompatible. -!!! error TS2322: Type '"hello"' is not assignable to type 'boolean'. +!!! error TS2322: Property 'y3' is missing in type '{ y1: "hello"; y2: 1000; children: "hi"; }'. const e4 = Hi ~~~~~~~~~~~~~~~~~~~~ !!! error TS2322: Type '{ y1: "hello"; y2: 1000; children: string; }' is not assignable to type 'IntrinsicAttributes & { y1: boolean; y2?: number; y3: boolean; }'. !!! error TS2322: Type '{ y1: "hello"; y2: 1000; children: string; }' is not assignable to type '{ y1: boolean; y2?: number; y3: boolean; }'. -!!! error TS2322: Types of property 'y1' are incompatible. -!!! error TS2322: Type '"hello"' is not assignable to type 'boolean'. +!!! error TS2322: Property 'y3' is missing in type '{ y1: "hello"; y2: 1000; children: string; }'. \ No newline at end of file From 7306b13f742752d2e064e68e6d9d317933929236 Mon Sep 17 00:00:00 2001 From: Andy Date: Tue, 29 Aug 2017 09:18:09 -0700 Subject: [PATCH 171/370] Don't issue a use-before-declared error for a property that exists in a superclass (#17910) * Don't issue a use-before-declared error for a property that exists in a superclass * Simplify isInPropertyInitializer * Respond to PR comments --- src/compiler/checker.ts | 70 ++++++++++----- ...useBeforeDeclaration_superClass.errors.txt | 34 +++++++ .../useBeforeDeclaration_superClass.js | 89 +++++++++++++++++++ .../useBeforeDeclaration_superClass.ts | 27 ++++++ 4 files changed, 198 insertions(+), 22 deletions(-) create mode 100644 tests/baselines/reference/useBeforeDeclaration_superClass.errors.txt create mode 100644 tests/baselines/reference/useBeforeDeclaration_superClass.js create mode 100644 tests/cases/compiler/useBeforeDeclaration_superClass.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index ed24e58096e..3f8406f3770 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -14671,18 +14671,8 @@ namespace ts { } return unknownType; } - if (prop.valueDeclaration) { - if (isInPropertyInitializer(node) && - !isBlockScopedNameDeclaredBeforeUse(prop.valueDeclaration, right)) { - error(right, Diagnostics.Block_scoped_variable_0_used_before_its_declaration, unescapeLeadingUnderscores(right.escapedText)); - } - if (prop.valueDeclaration.kind === SyntaxKind.ClassDeclaration && - node.parent && node.parent.kind !== SyntaxKind.TypeReference && - !isInAmbientContext(prop.valueDeclaration) && - !isBlockScopedNameDeclaredBeforeUse(prop.valueDeclaration, right)) { - error(right, Diagnostics.Class_0_used_before_its_declaration, unescapeLeadingUnderscores(right.escapedText)); - } - } + + checkPropertyNotUsedBeforeDeclaration(prop, node, right); markPropertyAsReferenced(prop); @@ -14712,6 +14702,52 @@ namespace ts { return assignmentKind ? getBaseTypeOfLiteralType(flowType) : flowType; } + function checkPropertyNotUsedBeforeDeclaration(prop: Symbol, node: PropertyAccessExpression | QualifiedName, right: Identifier): void { + const { valueDeclaration } = prop; + if (!valueDeclaration) { + return; + } + + if (findAncestor(node, node => node.kind === SyntaxKind.PropertyDeclaration ? true : isExpression(node) ? false : "quit") && + !isBlockScopedNameDeclaredBeforeUse(valueDeclaration, right) + && !isPropertyDeclaredInAncestorClass(prop)) { + error(right, Diagnostics.Block_scoped_variable_0_used_before_its_declaration, unescapeLeadingUnderscores(right.escapedText)); + } + else if (valueDeclaration.kind === SyntaxKind.ClassDeclaration && + node.parent.kind !== SyntaxKind.TypeReference && + !isInAmbientContext(valueDeclaration) && + !isBlockScopedNameDeclaredBeforeUse(valueDeclaration, right)) { + error(right, Diagnostics.Class_0_used_before_its_declaration, unescapeLeadingUnderscores(right.escapedText)); + } + } + + /** + * It's possible that "prop.valueDeclaration" is a local declaration, but the property was also declared in a superclass. + * In that case we won't consider it used before its declaration, because it gets its value from the superclass' declaration. + */ + function isPropertyDeclaredInAncestorClass(prop: Symbol): boolean { + let classType = getTypeOfSymbol(prop.parent) as InterfaceType; + while (true) { + classType = getSuperClass(classType); + if (!classType) { + return false; + } + const superProperty = getPropertyOfType(classType, prop.escapedName); + if (superProperty && superProperty.valueDeclaration) { + return true; + } + } + } + + function getSuperClass(classType: InterfaceType): InterfaceType | undefined { + const x = getBaseTypes(classType); + if (x.length === 0) { + return undefined; + } + Debug.assert(x.length === 1); + return x[0] as InterfaceType; + } + function reportNonexistentProperty(propNode: Identifier, containingType: Type) { let errorInfo: DiagnosticMessageChain; if (containingType.flags & TypeFlags.Union && !(containingType.flags & TypeFlags.Primitive)) { @@ -14832,16 +14868,6 @@ namespace ts { } } - function isInPropertyInitializer(node: Node): boolean { - while (node) { - if (node.parent && node.parent.kind === SyntaxKind.PropertyDeclaration && (node.parent as PropertyDeclaration).initializer === node) { - return true; - } - node = node.parent; - } - return false; - } - function isValidPropertyAccess(node: PropertyAccessExpression | QualifiedName, propertyName: __String): boolean { const left = node.kind === SyntaxKind.PropertyAccessExpression ? (node).expression diff --git a/tests/baselines/reference/useBeforeDeclaration_superClass.errors.txt b/tests/baselines/reference/useBeforeDeclaration_superClass.errors.txt new file mode 100644 index 00000000000..01d714d8e6f --- /dev/null +++ b/tests/baselines/reference/useBeforeDeclaration_superClass.errors.txt @@ -0,0 +1,34 @@ +tests/cases/compiler/useBeforeDeclaration_superClass.ts(25,18): error TS2448: Block-scoped variable 'x' used before its declaration. + + +==== tests/cases/compiler/useBeforeDeclaration_superClass.ts (1 errors) ==== + class C { + x = 0; + } + class D extends C { + // Not an error -- this will access the parent's initialized value for `x`, not the one on the child. + old_x = this.x; + x = 1; + } + + // Test that it works on chains of classes + class X { + x = 0; + } + class Y extends X {} + class Z extends Y { + old_x = this.x; + x = 1; + } + + // Interface doesn't count + interface I { + x: number; + } + class J implements I { + old_x = this.x; + ~ +!!! error TS2448: Block-scoped variable 'x' used before its declaration. + x = 1; + } + \ No newline at end of file diff --git a/tests/baselines/reference/useBeforeDeclaration_superClass.js b/tests/baselines/reference/useBeforeDeclaration_superClass.js new file mode 100644 index 00000000000..b2c2b7fb86e --- /dev/null +++ b/tests/baselines/reference/useBeforeDeclaration_superClass.js @@ -0,0 +1,89 @@ +//// [useBeforeDeclaration_superClass.ts] +class C { + x = 0; +} +class D extends C { + // Not an error -- this will access the parent's initialized value for `x`, not the one on the child. + old_x = this.x; + x = 1; +} + +// Test that it works on chains of classes +class X { + x = 0; +} +class Y extends X {} +class Z extends Y { + old_x = this.x; + x = 1; +} + +// Interface doesn't count +interface I { + x: number; +} +class J implements I { + old_x = this.x; + x = 1; +} + + +//// [useBeforeDeclaration_superClass.js] +var __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +var C = /** @class */ (function () { + function C() { + this.x = 0; + } + return C; +}()); +var D = /** @class */ (function (_super) { + __extends(D, _super); + function D() { + var _this = _super !== null && _super.apply(this, arguments) || this; + // Not an error -- this will access the parent's initialized value for `x`, not the one on the child. + _this.old_x = _this.x; + _this.x = 1; + return _this; + } + return D; +}(C)); +// Test that it works on chains of classes +var X = /** @class */ (function () { + function X() { + this.x = 0; + } + return X; +}()); +var Y = /** @class */ (function (_super) { + __extends(Y, _super); + function Y() { + return _super !== null && _super.apply(this, arguments) || this; + } + return Y; +}(X)); +var Z = /** @class */ (function (_super) { + __extends(Z, _super); + function Z() { + var _this = _super !== null && _super.apply(this, arguments) || this; + _this.old_x = _this.x; + _this.x = 1; + return _this; + } + return Z; +}(Y)); +var J = /** @class */ (function () { + function J() { + this.old_x = this.x; + this.x = 1; + } + return J; +}()); diff --git a/tests/cases/compiler/useBeforeDeclaration_superClass.ts b/tests/cases/compiler/useBeforeDeclaration_superClass.ts new file mode 100644 index 00000000000..3ab10a007f3 --- /dev/null +++ b/tests/cases/compiler/useBeforeDeclaration_superClass.ts @@ -0,0 +1,27 @@ +class C { + x = 0; +} +class D extends C { + // Not an error -- this will access the parent's initialized value for `x`, not the one on the child. + old_x = this.x; + x = 1; +} + +// Test that it works on chains of classes +class X { + x = 0; +} +class Y extends X {} +class Z extends Y { + old_x = this.x; + x = 1; +} + +// Interface doesn't count +interface I { + x: number; +} +class J implements I { + old_x = this.x; + x = 1; +} From 9daa70c47ef9ae4da9f7b8acb942d14f151f1d07 Mon Sep 17 00:00:00 2001 From: Andy Date: Tue, 29 Aug 2017 09:37:27 -0700 Subject: [PATCH 172/370] Revert "Handle indexed access types in getSymbolAtLocation and findAllReferences (#17787)" (#18111) This reverts commit 30b3cb0f682df870fe23f8b1196bab06de1380b6. --- src/compiler/checker.ts | 20 ++-------- src/services/findAllReferences.ts | 4 +- src/services/rename.ts | 14 ++----- src/services/utilities.ts | 38 ++++++++++--------- .../findAllRefsIndexedAccessTypes.ts | 14 ------- 5 files changed, 30 insertions(+), 60 deletions(-) delete mode 100644 tests/cases/fourslash/findAllRefsIndexedAccessTypes.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 3f8406f3770..74c830ac7a6 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -22931,7 +22931,7 @@ namespace ts { return undefined; } - function getSymbolAtLocation(node: Node): Symbol | undefined { + function getSymbolAtLocation(node: Node) { if (node.kind === SyntaxKind.SourceFile) { return isExternalModule(node) ? getMergedSymbol(node.symbol) : undefined; } @@ -23009,21 +23009,9 @@ namespace ts { case SyntaxKind.NumericLiteral: // index access - switch (node.parent.kind) { - case SyntaxKind.ElementAccessExpression: { - if ((node.parent).argumentExpression !== node) { - return undefined; - } - const objectType = getTypeOfExpression((node.parent).expression); - return getPropertyOfType(objectType, (node).text as __String); - } - case SyntaxKind.LiteralType: { - if (!isIndexedAccessTypeNode(node.parent.parent)) { - return undefined; - } - const objectType = getTypeFromTypeNode(node.parent.parent.objectType); - return getPropertyOfType(objectType, escapeLeadingUnderscores((node as StringLiteral | NumericLiteral).text)); - } + if (node.parent.kind === SyntaxKind.ElementAccessExpression && (node.parent).argumentExpression === node) { + const objectType = getTypeOfExpression((node.parent).expression); + return getPropertyOfType(objectType, (node).text as __String); } break; } diff --git a/src/services/findAllReferences.ts b/src/services/findAllReferences.ts index 04d383748c8..4c8563b1b94 100644 --- a/src/services/findAllReferences.ts +++ b/src/services/findAllReferences.ts @@ -748,11 +748,11 @@ namespace ts.FindAllReferences.Core { return (node as Identifier).text.length === searchSymbolName.length; case SyntaxKind.StringLiteral: - return (isLiteralNameOfPropertyDeclarationOrIndexAccess(node as StringLiteral) || isNameOfExternalModuleImportOrDeclaration(node)) && + return (isLiteralNameOfPropertyDeclarationOrIndexAccess(node) || isNameOfExternalModuleImportOrDeclaration(node)) && (node as StringLiteral).text.length === searchSymbolName.length; case SyntaxKind.NumericLiteral: - return isLiteralNameOfPropertyDeclarationOrIndexAccess(node as NumericLiteral) && (node as NumericLiteral).text.length === searchSymbolName.length; + return isLiteralNameOfPropertyDeclarationOrIndexAccess(node) && (node as NumericLiteral).text.length === searchSymbolName.length; default: return false; diff --git a/src/services/rename.ts b/src/services/rename.ts index 8411e8200a3..6091c0b2d03 100644 --- a/src/services/rename.ts +++ b/src/services/rename.ts @@ -89,15 +89,9 @@ namespace ts.Rename { } function nodeIsEligibleForRename(node: Node): boolean { - switch (node.kind) { - case SyntaxKind.Identifier: - case SyntaxKind.StringLiteral: - case SyntaxKind.ThisKeyword: - return true; - case SyntaxKind.NumericLiteral: - return isLiteralNameOfPropertyDeclarationOrIndexAccess(node as NumericLiteral); - default: - return false; - } + return node.kind === ts.SyntaxKind.Identifier || + node.kind === SyntaxKind.StringLiteral || + isLiteralNameOfPropertyDeclarationOrIndexAccess(node) || + isThis(node); } } diff --git a/src/services/utilities.ts b/src/services/utilities.ts index c7f5b5909f0..e8f01bb0785 100644 --- a/src/services/utilities.ts +++ b/src/services/utilities.ts @@ -244,25 +244,27 @@ namespace ts { isFunctionLike(node.parent) && (node.parent).name === node; } - export function isLiteralNameOfPropertyDeclarationOrIndexAccess(node: StringLiteral | NumericLiteral): boolean { - switch (node.parent.kind) { - case SyntaxKind.PropertyDeclaration: - case SyntaxKind.PropertySignature: - case SyntaxKind.PropertyAssignment: - case SyntaxKind.EnumMember: - case SyntaxKind.MethodDeclaration: - case SyntaxKind.MethodSignature: - case SyntaxKind.GetAccessor: - case SyntaxKind.SetAccessor: - case SyntaxKind.ModuleDeclaration: - return getNameOfDeclaration(node.parent) === node; - case SyntaxKind.ElementAccessExpression: - return (node.parent).argumentExpression === node; - case SyntaxKind.ComputedPropertyName: - return true; - case SyntaxKind.LiteralType: - return node.parent.parent.kind === SyntaxKind.IndexedAccessType; + export function isLiteralNameOfPropertyDeclarationOrIndexAccess(node: Node): boolean { + if (node.kind === SyntaxKind.StringLiteral || node.kind === SyntaxKind.NumericLiteral) { + switch (node.parent.kind) { + case SyntaxKind.PropertyDeclaration: + case SyntaxKind.PropertySignature: + case SyntaxKind.PropertyAssignment: + case SyntaxKind.EnumMember: + case SyntaxKind.MethodDeclaration: + case SyntaxKind.MethodSignature: + case SyntaxKind.GetAccessor: + case SyntaxKind.SetAccessor: + case SyntaxKind.ModuleDeclaration: + return getNameOfDeclaration(node.parent) === node; + case SyntaxKind.ElementAccessExpression: + return (node.parent).argumentExpression === node; + case SyntaxKind.ComputedPropertyName: + return true; + } } + + return false; } export function isExpressionOfExternalModuleImportEqualsDeclaration(node: Node) { diff --git a/tests/cases/fourslash/findAllRefsIndexedAccessTypes.ts b/tests/cases/fourslash/findAllRefsIndexedAccessTypes.ts deleted file mode 100644 index 32f8207f27e..00000000000 --- a/tests/cases/fourslash/findAllRefsIndexedAccessTypes.ts +++ /dev/null @@ -1,14 +0,0 @@ -/// - -////interface I { -//// [|{| "isDefinition": true, "isWriteAccess": true |}0|]: number; -//// [|{| "isDefinition": true, "isWriteAccess": true |}s|]: string; -////} -////interface J { -//// a: I[[|0|]], -//// b: I["[|s|]"], -////} - -const [n0, s0, n1, s1] = test.ranges(); -verify.singleReferenceGroup("(property) I[0]: number", [n0, n1]); -verify.singleReferenceGroup("(property) I.s: string", [s0, s1]); From 6168d6f074134ab1fda2021016c687e2199a9484 Mon Sep 17 00:00:00 2001 From: Andy Date: Tue, 29 Aug 2017 09:38:44 -0700 Subject: [PATCH 173/370] Inline checkLiteralExpression (#17720) --- src/compiler/checker.ts | 21 +++++---------------- 1 file changed, 5 insertions(+), 16 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 74c830ac7a6..d700505ca05 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -17850,21 +17850,6 @@ namespace ts { return getBestChoiceType(type1, type2); } - function checkLiteralExpression(node: LiteralExpression | Token): Type { - switch (node.kind) { - case SyntaxKind.NoSubstitutionTemplateLiteral: - case SyntaxKind.StringLiteral: - return getFreshTypeOfLiteralType(getLiteralType(node.text)); - case SyntaxKind.NumericLiteral: - checkGrammarNumericLiteral(node); - return getFreshTypeOfLiteralType(getLiteralType(+node.text)); - case SyntaxKind.TrueKeyword: - return trueType; - case SyntaxKind.FalseKeyword: - return falseType; - } - } - function checkTemplateExpression(node: TemplateExpression): Type { // We just want to check each expressions, but we are unconcerned with // the type of each expression, as any value may be coerced into a string. @@ -18077,10 +18062,14 @@ namespace ts { return nullWideningType; case SyntaxKind.NoSubstitutionTemplateLiteral: case SyntaxKind.StringLiteral: + return getFreshTypeOfLiteralType(getLiteralType((node as LiteralExpression).text)); case SyntaxKind.NumericLiteral: + checkGrammarNumericLiteral(node as NumericLiteral); + return getFreshTypeOfLiteralType(getLiteralType(+(node as NumericLiteral).text)); case SyntaxKind.TrueKeyword: + return trueType; case SyntaxKind.FalseKeyword: - return checkLiteralExpression(node as LiteralExpression); + return falseType; case SyntaxKind.TemplateExpression: return checkTemplateExpression(node); case SyntaxKind.RegularExpressionLiteral: From 78524c1b90db2a888438e6274be538aea64fb254 Mon Sep 17 00:00:00 2001 From: Andy Date: Tue, 29 Aug 2017 09:41:57 -0700 Subject: [PATCH 174/370] Avoid climbing ancestors in `getAnyImportSyntax` (#17832) --- src/compiler/checker.ts | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index d700505ca05..4101d093e2f 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -1351,13 +1351,18 @@ namespace ts { return parent && !!findAncestor(initial, n => n === stopAt || isFunctionLike(n) ? "quit" : n === parent); } - function getAnyImportSyntax(node: Node): AnyImportSyntax { - if (isAliasSymbolDeclaration(node)) { - if (node.kind === SyntaxKind.ImportEqualsDeclaration) { - return node; - } - - return findAncestor(node, isImportDeclaration); + function getAnyImportSyntax(node: Node): AnyImportSyntax | undefined { + switch (node.kind) { + case SyntaxKind.ImportEqualsDeclaration: + return node as ImportEqualsDeclaration; + case SyntaxKind.ImportClause: + return (node as ImportClause).parent; + case SyntaxKind.NamespaceImport: + return (node as NamespaceImport).parent.parent; + case SyntaxKind.ImportSpecifier: + return (node as ImportSpecifier).parent.parent.parent; + default: + return undefined; } } From 7ac43805149e779db04c4bf495a061cfb5b8ebee Mon Sep 17 00:00:00 2001 From: Andy Date: Tue, 29 Aug 2017 10:23:30 -0700 Subject: [PATCH 175/370] Use getPropertyOfObjectType to get a superclass property (#18113) --- src/compiler/checker.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 4101d093e2f..6373665b1ec 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -14737,7 +14737,7 @@ namespace ts { if (!classType) { return false; } - const superProperty = getPropertyOfType(classType, prop.escapedName); + const superProperty = getPropertyOfObjectType(classType, prop.escapedName); if (superProperty && superProperty.valueDeclaration) { return true; } From 2350d46e44924577312b38b2d5813504718e7e17 Mon Sep 17 00:00:00 2001 From: Andy Date: Tue, 29 Aug 2017 10:28:22 -0700 Subject: [PATCH 176/370] Simplify isContextSensitive (#17722) --- src/compiler/checker.ts | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 6373665b1ec..05b84a78d9f 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -8367,7 +8367,8 @@ namespace ts { switch (node.kind) { case SyntaxKind.FunctionExpression: case SyntaxKind.ArrowFunction: - return isContextSensitiveFunctionLikeDeclaration(node); + case SyntaxKind.MethodDeclaration: + return isContextSensitiveFunctionLikeDeclaration(node); case SyntaxKind.ObjectLiteralExpression: return forEach((node).properties, isContextSensitive); case SyntaxKind.ArrayLiteralExpression: @@ -8380,9 +8381,6 @@ namespace ts { (isContextSensitive((node).left) || isContextSensitive((node).right)); case SyntaxKind.PropertyAssignment: return isContextSensitive((node).initializer); - case SyntaxKind.MethodDeclaration: - case SyntaxKind.MethodSignature: - return isContextSensitiveFunctionLikeDeclaration(node); case SyntaxKind.ParenthesizedExpression: return isContextSensitive((node).expression); case SyntaxKind.JsxAttributes: From 63cb84f3d1e09fc62229945556b022432d0ccbc9 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Tue, 29 Aug 2017 10:38:16 -0700 Subject: [PATCH 177/370] Codefix jsdoc types for anything with a .type That means type parameters and type arguments are still not handled. --- src/services/codefixes/fixJSDocTypes.ts | 20 +++++++++++++++++-- .../fourslash/codeFixChangeJSDocSyntax14.ts | 5 +++++ .../fourslash/codeFixChangeJSDocSyntax15.ts | 5 +++++ .../fourslash/codeFixChangeJSDocSyntax16.ts | 4 ++++ .../fourslash/codeFixChangeJSDocSyntax17.ts | 3 +++ .../fourslash/codeFixChangeJSDocSyntax18.ts | 3 +++ .../fourslash/codeFixChangeJSDocSyntax19.ts | 3 +++ .../fourslash/codeFixChangeJSDocSyntax20.ts | 3 +++ .../fourslash/codeFixChangeJSDocSyntax21.ts | 3 +++ .../fourslash/codeFixChangeJSDocSyntax22.ts | 3 +++ .../fourslash/codeFixChangeJSDocSyntax23.ts | 6 ++++++ .../fourslash/codeFixChangeJSDocSyntax24.ts | 5 +++++ .../fourslash/codeFixChangeJSDocSyntax25.ts | 5 +++++ .../fourslash/codeFixChangeJSDocSyntax26.ts | 5 +++++ .../fourslash/codeFixChangeJSDocSyntax27.ts | 4 ++++ 15 files changed, 75 insertions(+), 2 deletions(-) create mode 100644 tests/cases/fourslash/codeFixChangeJSDocSyntax14.ts create mode 100644 tests/cases/fourslash/codeFixChangeJSDocSyntax15.ts create mode 100644 tests/cases/fourslash/codeFixChangeJSDocSyntax16.ts create mode 100644 tests/cases/fourslash/codeFixChangeJSDocSyntax17.ts create mode 100644 tests/cases/fourslash/codeFixChangeJSDocSyntax18.ts create mode 100644 tests/cases/fourslash/codeFixChangeJSDocSyntax19.ts create mode 100644 tests/cases/fourslash/codeFixChangeJSDocSyntax20.ts create mode 100644 tests/cases/fourslash/codeFixChangeJSDocSyntax21.ts create mode 100644 tests/cases/fourslash/codeFixChangeJSDocSyntax22.ts create mode 100644 tests/cases/fourslash/codeFixChangeJSDocSyntax23.ts create mode 100644 tests/cases/fourslash/codeFixChangeJSDocSyntax24.ts create mode 100644 tests/cases/fourslash/codeFixChangeJSDocSyntax25.ts create mode 100644 tests/cases/fourslash/codeFixChangeJSDocSyntax26.ts create mode 100644 tests/cases/fourslash/codeFixChangeJSDocSyntax27.ts diff --git a/src/services/codefixes/fixJSDocTypes.ts b/src/services/codefixes/fixJSDocTypes.ts index 27c0edac628..8d5cd562497 100644 --- a/src/services/codefixes/fixJSDocTypes.ts +++ b/src/services/codefixes/fixJSDocTypes.ts @@ -8,11 +8,27 @@ namespace ts.codefix { function getActionsForJSDocTypes(context: CodeFixContext): CodeAction[] | undefined { const sourceFile = context.sourceFile; const node = getTokenAtPosition(sourceFile, context.span.start, /*includeJsDocComment*/ false); + + // NOTE: Some locations are not handled yet: + // MappedTypeNode.typeParameters and SignatureDeclaration.typeParameters, as well as CallExpression.typeArguments const decl = ts.findAncestor(node, - n => n.kind === SyntaxKind.VariableDeclaration || + n => + n.kind === SyntaxKind.AsExpression || + n.kind === SyntaxKind.CallSignature || + n.kind === SyntaxKind.ConstructSignature || + n.kind === SyntaxKind.FunctionDeclaration || + n.kind === SyntaxKind.GetAccessor || + n.kind === SyntaxKind.IndexSignature || + n.kind === SyntaxKind.MappedType || + n.kind === SyntaxKind.MethodDeclaration || + n.kind === SyntaxKind.MethodSignature || n.kind === SyntaxKind.Parameter || n.kind === SyntaxKind.PropertyDeclaration || - n.kind === SyntaxKind.PropertyAssignment); + n.kind === SyntaxKind.PropertySignature || + n.kind === SyntaxKind.SetAccessor || + n.kind === SyntaxKind.TypeAliasDeclaration || + n.kind === SyntaxKind.TypeAssertionExpression || + n.kind === SyntaxKind.VariableDeclaration); if (!decl) return; const checker = context.program.getTypeChecker(); diff --git a/tests/cases/fourslash/codeFixChangeJSDocSyntax14.ts b/tests/cases/fourslash/codeFixChangeJSDocSyntax14.ts new file mode 100644 index 00000000000..69478fc3abc --- /dev/null +++ b/tests/cases/fourslash/codeFixChangeJSDocSyntax14.ts @@ -0,0 +1,5 @@ +// @strict: true +/// +//// var x = 12 as [|number?|]; + +verify.rangeAfterCodeFix("number | null", /*includeWhiteSpace*/ false, /*errorCode*/ 8020, 0); diff --git a/tests/cases/fourslash/codeFixChangeJSDocSyntax15.ts b/tests/cases/fourslash/codeFixChangeJSDocSyntax15.ts new file mode 100644 index 00000000000..9482830c19d --- /dev/null +++ b/tests/cases/fourslash/codeFixChangeJSDocSyntax15.ts @@ -0,0 +1,5 @@ +/// +//// var f = <[|function(number?): number|]>(x => x); + +// note: without --strict, number? --> number, not number | null +verify.rangeAfterCodeFix("(arg0: number) => number", /*includeWhiteSpace*/ false, /*errorCode*/ 8020, 0); diff --git a/tests/cases/fourslash/codeFixChangeJSDocSyntax16.ts b/tests/cases/fourslash/codeFixChangeJSDocSyntax16.ts new file mode 100644 index 00000000000..111aec1dce7 --- /dev/null +++ b/tests/cases/fourslash/codeFixChangeJSDocSyntax16.ts @@ -0,0 +1,4 @@ +/// +//// var f: { [K in keyof number]: [|*|] }; + +verify.rangeAfterCodeFix("any"); diff --git a/tests/cases/fourslash/codeFixChangeJSDocSyntax17.ts b/tests/cases/fourslash/codeFixChangeJSDocSyntax17.ts new file mode 100644 index 00000000000..6a3ce2ed3df --- /dev/null +++ b/tests/cases/fourslash/codeFixChangeJSDocSyntax17.ts @@ -0,0 +1,3 @@ +/// +//// declare function index(ix: number): [|*|]; +verify.rangeAfterCodeFix("any"); diff --git a/tests/cases/fourslash/codeFixChangeJSDocSyntax18.ts b/tests/cases/fourslash/codeFixChangeJSDocSyntax18.ts new file mode 100644 index 00000000000..30a3815516a --- /dev/null +++ b/tests/cases/fourslash/codeFixChangeJSDocSyntax18.ts @@ -0,0 +1,3 @@ +/// +//// var index: { (ix: number): [|?|] }; +verify.rangeAfterCodeFix("any"); diff --git a/tests/cases/fourslash/codeFixChangeJSDocSyntax19.ts b/tests/cases/fourslash/codeFixChangeJSDocSyntax19.ts new file mode 100644 index 00000000000..e6344881227 --- /dev/null +++ b/tests/cases/fourslash/codeFixChangeJSDocSyntax19.ts @@ -0,0 +1,3 @@ +/// +//// var index: { new (ix: number): [|?|] }; +verify.rangeAfterCodeFix("any"); diff --git a/tests/cases/fourslash/codeFixChangeJSDocSyntax20.ts b/tests/cases/fourslash/codeFixChangeJSDocSyntax20.ts new file mode 100644 index 00000000000..dc153730841 --- /dev/null +++ b/tests/cases/fourslash/codeFixChangeJSDocSyntax20.ts @@ -0,0 +1,3 @@ +/// +//// var index = { get p(): [|*|] { return 12 } }; +verify.rangeAfterCodeFix("any"); diff --git a/tests/cases/fourslash/codeFixChangeJSDocSyntax21.ts b/tests/cases/fourslash/codeFixChangeJSDocSyntax21.ts new file mode 100644 index 00000000000..442414e4577 --- /dev/null +++ b/tests/cases/fourslash/codeFixChangeJSDocSyntax21.ts @@ -0,0 +1,3 @@ +/// +//// var index = { set p(x: [|*|]) { } }; +verify.rangeAfterCodeFix("any"); diff --git a/tests/cases/fourslash/codeFixChangeJSDocSyntax22.ts b/tests/cases/fourslash/codeFixChangeJSDocSyntax22.ts new file mode 100644 index 00000000000..c575f1ca7ce --- /dev/null +++ b/tests/cases/fourslash/codeFixChangeJSDocSyntax22.ts @@ -0,0 +1,3 @@ +/// +//// var index: { [s: string]: [|*|] }; +verify.rangeAfterCodeFix("any"); diff --git a/tests/cases/fourslash/codeFixChangeJSDocSyntax23.ts b/tests/cases/fourslash/codeFixChangeJSDocSyntax23.ts new file mode 100644 index 00000000000..7ab70e18ee7 --- /dev/null +++ b/tests/cases/fourslash/codeFixChangeJSDocSyntax23.ts @@ -0,0 +1,6 @@ +/// +////class C { +//// m(): [|*|] { +//// } +////} +verify.rangeAfterCodeFix("any"); diff --git a/tests/cases/fourslash/codeFixChangeJSDocSyntax24.ts b/tests/cases/fourslash/codeFixChangeJSDocSyntax24.ts new file mode 100644 index 00000000000..7ea2d1f6faf --- /dev/null +++ b/tests/cases/fourslash/codeFixChangeJSDocSyntax24.ts @@ -0,0 +1,5 @@ +/// +////declare class C { +//// m(): [|*|]; +////} +verify.rangeAfterCodeFix("any"); diff --git a/tests/cases/fourslash/codeFixChangeJSDocSyntax25.ts b/tests/cases/fourslash/codeFixChangeJSDocSyntax25.ts new file mode 100644 index 00000000000..6486a70417e --- /dev/null +++ b/tests/cases/fourslash/codeFixChangeJSDocSyntax25.ts @@ -0,0 +1,5 @@ +/// +////declare class C { +//// p: [|*|]; +////} +verify.rangeAfterCodeFix("any"); diff --git a/tests/cases/fourslash/codeFixChangeJSDocSyntax26.ts b/tests/cases/fourslash/codeFixChangeJSDocSyntax26.ts new file mode 100644 index 00000000000..dc31f1dfffd --- /dev/null +++ b/tests/cases/fourslash/codeFixChangeJSDocSyntax26.ts @@ -0,0 +1,5 @@ +/// +////class C { +//// p: [|*|] = 12; +////} +verify.rangeAfterCodeFix("any"); diff --git a/tests/cases/fourslash/codeFixChangeJSDocSyntax27.ts b/tests/cases/fourslash/codeFixChangeJSDocSyntax27.ts new file mode 100644 index 00000000000..255976c7767 --- /dev/null +++ b/tests/cases/fourslash/codeFixChangeJSDocSyntax27.ts @@ -0,0 +1,4 @@ +// @strict: true +/// +////type T = [|...number?|]; +verify.rangeAfterCodeFix("(number | null)[]"); From 30802cda977f1a3f0ba2a0b7d6ff5280ac3ebddc Mon Sep 17 00:00:00 2001 From: Andrew Casey Date: Fri, 11 Aug 2017 16:14:48 -0700 Subject: [PATCH 178/370] Handle loose type parameters in Extract Method Known limitations: 1. If a type parameter on an inner symbol shadows a type parameter on an outer symbol, the generated code will be incorrect. We should either rename one or more type parameters or forbid the extraction. 2. Type arguments are always passed explicitly, even if they would be inferred correctly. --- src/compiler/types.ts | 15 +++ src/compiler/utilities.ts | 32 ++++++ src/services/refactors/extractMethod.ts | 135 ++++++++++++++++++++++-- 3 files changed, 175 insertions(+), 7 deletions(-) diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 87ac4afbab1..64444693acf 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -651,6 +651,20 @@ namespace ts { } export interface SignatureDeclaration extends NamedDeclaration { + kind: SyntaxKind.CallSignature + | SyntaxKind.ConstructSignature + | SyntaxKind.MethodSignature + | SyntaxKind.IndexSignature + | SyntaxKind.FunctionType + | SyntaxKind.ConstructorType + | SyntaxKind.JSDocFunctionType + | SyntaxKind.FunctionDeclaration + | SyntaxKind.MethodDeclaration + | SyntaxKind.Constructor + | SyntaxKind.GetAccessor + | SyntaxKind.SetAccessor + | SyntaxKind.FunctionExpression + | SyntaxKind.ArrowFunction; name?: PropertyName; typeParameters?: NodeArray; parameters: NodeArray; @@ -1816,6 +1830,7 @@ namespace ts { export type DeclarationWithTypeParameters = SignatureDeclaration | ClassLikeDeclaration | InterfaceDeclaration | TypeAliasDeclaration | JSDocTemplateTag; export interface ClassLikeDeclaration extends NamedDeclaration { + kind: SyntaxKind.ClassDeclaration | SyntaxKind.ClassExpression; name?: Identifier; typeParameters?: NodeArray; heritageClauses?: NodeArray; diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index 197e91ac383..2a07d2b6560 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -477,6 +477,38 @@ namespace ts { return false; } + /* @internal */ + export function isDeclarationWithTypeParameters(node: Node): node is DeclarationWithTypeParameters; + export function isDeclarationWithTypeParameters(node: DeclarationWithTypeParameters): node is DeclarationWithTypeParameters { + switch (node.kind) { + case SyntaxKind.CallSignature: + case SyntaxKind.ConstructSignature: + case SyntaxKind.MethodSignature: + case SyntaxKind.IndexSignature: + case SyntaxKind.FunctionType: + case SyntaxKind.ConstructorType: + case SyntaxKind.JSDocFunctionType: + case SyntaxKind.ClassDeclaration: + case SyntaxKind.ClassExpression: + case SyntaxKind.InterfaceDeclaration: + case SyntaxKind.TypeAliasDeclaration: + case SyntaxKind.JSDocTemplateTag: + case SyntaxKind.FunctionDeclaration: + case SyntaxKind.MethodDeclaration: + case SyntaxKind.Constructor: + case SyntaxKind.GetAccessor: + case SyntaxKind.SetAccessor: + case SyntaxKind.FunctionExpression: + case SyntaxKind.ArrowFunction: + return true; + default: + staticAssertNever(node); + return false; + } + } + + function staticAssertNever(_: never): void {} + // Gets the nearest enclosing block scope container that has the provided node // as a descendant, that is not the provided node. export function getEnclosingBlockScopeContainer(node: Node): Node { diff --git a/src/services/refactors/extractMethod.ts b/src/services/refactors/extractMethod.ts index 4fa22d24b8d..ff376026e52 100644 --- a/src/services/refactors/extractMethod.ts +++ b/src/services/refactors/extractMethod.ts @@ -610,7 +610,7 @@ namespace ts.refactor.extractMethod { export function extractFunctionInScope( node: Statement | Expression | Block, scope: Scope, - { usages: usagesInScope, substitutions }: ScopeUsages, + { usages: usagesInScope, typeParameterUsages, substitutions }: ScopeUsages, range: TargetRange, context: RefactorContext): ExtractResultForScope { @@ -652,7 +652,18 @@ namespace ts.refactor.extractMethod { callArguments.push(createIdentifier(name)); }); - // Provide explicit return types for contexutally-typed functions + const typeParametersAndDeclarations = arrayFrom(typeParameterUsages.values()).map(type => ({ type, declaration: getFirstDeclaration(type) })); + const sortedTypeParametersAndDeclarations = typeParametersAndDeclarations.sort(compareTypesByDeclarationOrder); + + const typeParameters: ReadonlyArray = sortedTypeParametersAndDeclarations.map(t => t.declaration as TypeParameterDeclaration); + + // Strictly speaking, we should check whether each name actually binds to the appropriate type + // parameter. In cases of shadowing, they may not. + const callTypeArguments: ReadonlyArray | undefined = typeParameters.length > 0 + ? typeParameters.map(decl => createTypeReferenceNode(decl.name, /*typeArguments*/ undefined)) + : undefined; + + // Provide explicit return types for contextually-typed functions // to avoid problems when there are literal types present if (isExpression(node) && !isJS) { const contextualType = checker.getContextualType(node); @@ -677,7 +688,7 @@ namespace ts.refactor.extractMethod { range.facts & RangeFacts.IsGenerator ? createToken(SyntaxKind.AsteriskToken) : undefined, functionName, /*questionToken*/ undefined, - /*typeParameters*/[], + typeParameters, parameters, returnType, body @@ -689,7 +700,7 @@ namespace ts.refactor.extractMethod { range.facts & RangeFacts.IsAsyncFunction ? [createToken(SyntaxKind.AsyncKeyword)] : undefined, range.facts & RangeFacts.IsGenerator ? createToken(SyntaxKind.AsteriskToken) : undefined, functionName, - /*typeParameters*/[], + typeParameters, parameters, returnType, body @@ -704,7 +715,7 @@ namespace ts.refactor.extractMethod { // replace range with function call let call: Expression = createCall( isClassLike(scope) ? createPropertyAccess(range.facts & RangeFacts.InStaticRegion ? createIdentifier(scope.name.getText()) : createThis(), functionReference) : functionReference, - /*typeArguments*/ undefined, + callTypeArguments, // Note that no attempt is made to take advantage of type argument inference callArguments); if (range.facts & RangeFacts.IsGenerator) { call = createYield(createToken(SyntaxKind.AsteriskToken), call); @@ -774,6 +785,51 @@ namespace ts.refactor.extractMethod { changes: changeTracker.getChanges() }; + function getFirstDeclaration(type: Type): Declaration | undefined { + let firstDeclaration = undefined; + + const symbol = type.symbol; + if (symbol && symbol.declarations) { + for (const declaration of symbol.declarations) { + if (firstDeclaration === undefined || declaration.pos < firstDeclaration.pos) { + firstDeclaration = declaration; + } + } + } + + return firstDeclaration; + } + + function compareTypesByDeclarationOrder( + {type: type1, declaration: declaration1}: {type: Type, declaration?: Declaration}, + {type: type2, declaration: declaration2}: {type: Type, declaration?: Declaration}) { + + if (declaration1) { + if (declaration2) { + const positionDiff = declaration1.pos - declaration2.pos; + if (positionDiff !== 0) { + return positionDiff; + } + } + else { + return 1; // Sort undeclared type parameters to the front. + } + } + else if (declaration2) { + return -1; // Sort undeclared type parameters to the front. + } + + const name1 = type1.symbol ? type1.symbol.getName() : ""; + const name2 = type2.symbol ? type2.symbol.getName() : ""; + const nameDiff = compareStrings(name1, name2); + if (nameDiff !== 0) { + return nameDiff; + } + + // IDs are guaranteed to be unique, so this ensures a total ordering. + return type1.id - type2.id; + } + function getPropertyAssignmentsForWrites(writes: UsageEntry[]) { return writes.map(w => createShorthandPropertyAssignment(w.symbol.name)); } @@ -867,6 +923,7 @@ namespace ts.refactor.extractMethod { export interface ScopeUsages { usages: Map; + typeParameterUsages: Map; // Key is type ID substitutions: Map; } @@ -877,6 +934,7 @@ namespace ts.refactor.extractMethod { sourceFile: SourceFile, checker: TypeChecker) { + const allTypeParameterUsages = createMap(); // Key is type ID const usagesPerScope: ScopeUsages[] = []; const substitutionsPerScope: Map[] = []; const errorsPerScope: Diagnostic[][] = []; @@ -884,7 +942,7 @@ namespace ts.refactor.extractMethod { // initialize results for (const _ of scopes) { - usagesPerScope.push({ usages: createMap(), substitutions: createMap() }); + usagesPerScope.push({ usages: createMap(), typeParameterUsages: createMap(), substitutions: createMap() }); substitutionsPerScope.push(createMap()); errorsPerScope.push([]); } @@ -892,8 +950,42 @@ namespace ts.refactor.extractMethod { const target = isReadonlyArray(targetRange.range) ? createBlock(targetRange.range) : targetRange.range; const containingLexicalScopeOfExtraction = isBlockScope(scopes[0], scopes[0].parent) ? scopes[0] : getEnclosingBlockScopeContainer(scopes[0]); + const unmodifiedNode = isReadonlyArray(targetRange.range) ? targetRange.range[0] : targetRange.range; + const inGenericContext = isInGenericContext(unmodifiedNode); + collectUsages(target); + if (allTypeParameterUsages.size > 0) { + const seenTypeParameterUsages = createMap(); // Key is type ID + + let i = 0; + for (let curr: Node = unmodifiedNode; curr !== undefined && i < scopes.length; curr = curr.parent) { + if (curr === scopes[i]) { + // Copy current contents of seenTypeParameterUsages into scope. + seenTypeParameterUsages.forEach((typeParameter, id) => { + usagesPerScope[i].typeParameterUsages.set(id, typeParameter); + }); + + i++; + } + + // Note that we add the current node's type parameters *after* updating the corresponding scope. + if (isDeclarationWithTypeParameters(curr) && curr.typeParameters) { + for (const typeParameterDecl of curr.typeParameters) { + const typeParameter = checker.getTypeAtLocation(typeParameterDecl) as TypeParameter; + if (allTypeParameterUsages.has(typeParameter.id.toString())) { + seenTypeParameterUsages.set(typeParameter.id.toString(), typeParameter); + } + } + } + } + + // If we didn't get through all the scopes, then there were some that weren't in our + // parent chain (impossible at time of writing). A conservative solution would be to + // copy allTypeParameterUsages into all remaining scopes. + Debug.assert(i === scopes.length); + } + for (let i = 0; i < scopes.length; i++) { let hasWrite = false; let readonlyClassPropertyWrite: Declaration | undefined = undefined; @@ -912,7 +1004,7 @@ namespace ts.refactor.extractMethod { errorsPerScope[i].push(createDiagnosticForNode(targetRange.range, Messages.CannotCombineWritesAndReturns)); } else if (readonlyClassPropertyWrite && i > 0) { - errorsPerScope[i].push(createDiagnosticForNode(readonlyClassPropertyWrite, Messages.CannotCombineWritesAndReturns)); + errorsPerScope[i].push(createDiagnosticForNode(readonlyClassPropertyWrite, Messages.CannotExtractReadonlyPropertyInitializerOutsideConstructor)); } } @@ -924,7 +1016,36 @@ namespace ts.refactor.extractMethod { return { target, usagesPerScope, errorsPerScope }; + function hasTypeParameters(node: Node) { + return isDeclarationWithTypeParameters(node) && + node.typeParameters !== undefined && + node.typeParameters.length > 0; + } + + function isInGenericContext(node: Node) { + for (; node; node = node.parent) { + if (hasTypeParameters(node)) { + return true; + } + } + + return false; + } + function collectUsages(node: Node, valueUsage = Usage.Read) { + if (inGenericContext) { + const type = checker.getTypeAtLocation(node); + + const symbolWalker = checker.getSymbolWalker(); + const {visitedTypes} = symbolWalker.walkType(type); + + for (const visitedType of visitedTypes) { + if (visitedType.flags & TypeFlags.TypeParameter) { + allTypeParameterUsages.set(visitedType.id.toString(), visitedType as TypeParameter); + } + } + } + if (isDeclaration(node) && node.symbol) { visibleDeclarationsInExtractedRange.push(node.symbol); } From b2cc7224836f498e8eb08b7841c3185c9707a3d3 Mon Sep 17 00:00:00 2001 From: Andrew Casey Date: Wed, 16 Aug 2017 15:44:46 -0700 Subject: [PATCH 179/370] Comment out headers in Extract Method baselines --- src/harness/unittests/extractMethods.ts | 4 ++-- .../reference/extractMethod/extractMethod1.js | 10 +++++----- .../reference/extractMethod/extractMethod10.js | 8 ++++---- .../reference/extractMethod/extractMethod11.js | 8 ++++---- .../reference/extractMethod/extractMethod12.js | 4 ++-- .../reference/extractMethod/extractMethod2.js | 10 +++++----- .../reference/extractMethod/extractMethod3.js | 10 +++++----- .../reference/extractMethod/extractMethod4.js | 10 +++++----- .../reference/extractMethod/extractMethod5.js | 10 +++++----- .../reference/extractMethod/extractMethod6.js | 10 +++++----- .../reference/extractMethod/extractMethod7.js | 10 +++++----- .../reference/extractMethod/extractMethod8.js | 10 +++++----- .../reference/extractMethod/extractMethod9.js | 10 +++++----- 13 files changed, 57 insertions(+), 57 deletions(-) diff --git a/src/harness/unittests/extractMethods.ts b/src/harness/unittests/extractMethods.ts index d096cd3d375..c148d6d58a5 100644 --- a/src/harness/unittests/extractMethods.ts +++ b/src/harness/unittests/extractMethods.ts @@ -577,11 +577,11 @@ namespace A { assert.equal(result.errors, undefined, "expect no errors"); const results = refactor.extractMethod.getPossibleExtractions(result.targetRange, context); const data: string[] = []; - data.push(`==ORIGINAL==`); + data.push(`// ==ORIGINAL==`); data.push(sourceFile.text); for (const r of results) { const changes = refactor.extractMethod.getPossibleExtractions(result.targetRange, context, results.indexOf(r))[0].changes; - data.push(`==SCOPE::${r.scopeDescription}==`); + data.push(`// ==SCOPE::${r.scopeDescription}==`); data.push(textChanges.applyChanges(sourceFile.text, changes[0].textChanges)); } return data.join(newLineCharacter); diff --git a/tests/baselines/reference/extractMethod/extractMethod1.js b/tests/baselines/reference/extractMethod/extractMethod1.js index 10bf2648383..bfe80cb6c9b 100644 --- a/tests/baselines/reference/extractMethod/extractMethod1.js +++ b/tests/baselines/reference/extractMethod/extractMethod1.js @@ -1,4 +1,4 @@ -==ORIGINAL== +// ==ORIGINAL== namespace A { let x = 1; function foo() { @@ -14,7 +14,7 @@ namespace A { } } } -==SCOPE::function 'a'== +// ==SCOPE::function 'a'== namespace A { let x = 1; function foo() { @@ -34,7 +34,7 @@ namespace A { } } } -==SCOPE::namespace 'B'== +// ==SCOPE::namespace 'B'== namespace A { let x = 1; function foo() { @@ -55,7 +55,7 @@ namespace A { } } } -==SCOPE::namespace 'A'== +// ==SCOPE::namespace 'A'== namespace A { let x = 1; function foo() { @@ -76,7 +76,7 @@ namespace A { return a; } } -==SCOPE::global scope== +// ==SCOPE::global scope== namespace A { let x = 1; function foo() { diff --git a/tests/baselines/reference/extractMethod/extractMethod10.js b/tests/baselines/reference/extractMethod/extractMethod10.js index b2397744680..97bd5cbd503 100644 --- a/tests/baselines/reference/extractMethod/extractMethod10.js +++ b/tests/baselines/reference/extractMethod/extractMethod10.js @@ -1,4 +1,4 @@ -==ORIGINAL== +// ==ORIGINAL== namespace A { export interface I { x: number }; class C { @@ -9,7 +9,7 @@ namespace A { } } } -==SCOPE::class 'C'== +// ==SCOPE::class 'C'== namespace A { export interface I { x: number }; class C { @@ -24,7 +24,7 @@ namespace A { } } } -==SCOPE::namespace 'A'== +// ==SCOPE::namespace 'A'== namespace A { export interface I { x: number }; class C { @@ -39,7 +39,7 @@ namespace A { return a1.x + 10; } } -==SCOPE::global scope== +// ==SCOPE::global scope== namespace A { export interface I { x: number }; class C { diff --git a/tests/baselines/reference/extractMethod/extractMethod11.js b/tests/baselines/reference/extractMethod/extractMethod11.js index 21392a07a7a..4999df4a706 100644 --- a/tests/baselines/reference/extractMethod/extractMethod11.js +++ b/tests/baselines/reference/extractMethod/extractMethod11.js @@ -1,4 +1,4 @@ -==ORIGINAL== +// ==ORIGINAL== namespace A { let y = 1; class C { @@ -11,7 +11,7 @@ namespace A { } } } -==SCOPE::class 'C'== +// ==SCOPE::class 'C'== namespace A { let y = 1; class C { @@ -30,7 +30,7 @@ namespace A { } } } -==SCOPE::namespace 'A'== +// ==SCOPE::namespace 'A'== namespace A { let y = 1; class C { @@ -49,7 +49,7 @@ namespace A { return { __return: a1.x + 10, z }; } } -==SCOPE::global scope== +// ==SCOPE::global scope== namespace A { let y = 1; class C { diff --git a/tests/baselines/reference/extractMethod/extractMethod12.js b/tests/baselines/reference/extractMethod/extractMethod12.js index 7cebab5d3c5..2b95a545ce1 100644 --- a/tests/baselines/reference/extractMethod/extractMethod12.js +++ b/tests/baselines/reference/extractMethod/extractMethod12.js @@ -1,4 +1,4 @@ -==ORIGINAL== +// ==ORIGINAL== namespace A { let y = 1; class C { @@ -13,7 +13,7 @@ namespace A { } } } -==SCOPE::class 'C'== +// ==SCOPE::class 'C'== namespace A { let y = 1; class C { diff --git a/tests/baselines/reference/extractMethod/extractMethod2.js b/tests/baselines/reference/extractMethod/extractMethod2.js index 3c0d2e7c7b0..3b61a98d001 100644 --- a/tests/baselines/reference/extractMethod/extractMethod2.js +++ b/tests/baselines/reference/extractMethod/extractMethod2.js @@ -1,4 +1,4 @@ -==ORIGINAL== +// ==ORIGINAL== namespace A { let x = 1; function foo() { @@ -12,7 +12,7 @@ namespace A { } } } -==SCOPE::function 'a'== +// ==SCOPE::function 'a'== namespace A { let x = 1; function foo() { @@ -30,7 +30,7 @@ namespace A { } } } -==SCOPE::namespace 'B'== +// ==SCOPE::namespace 'B'== namespace A { let x = 1; function foo() { @@ -48,7 +48,7 @@ namespace A { } } } -==SCOPE::namespace 'A'== +// ==SCOPE::namespace 'A'== namespace A { let x = 1; function foo() { @@ -66,7 +66,7 @@ namespace A { return foo(); } } -==SCOPE::global scope== +// ==SCOPE::global scope== namespace A { let x = 1; function foo() { diff --git a/tests/baselines/reference/extractMethod/extractMethod3.js b/tests/baselines/reference/extractMethod/extractMethod3.js index cb28e2755e7..0837fbfc10d 100644 --- a/tests/baselines/reference/extractMethod/extractMethod3.js +++ b/tests/baselines/reference/extractMethod/extractMethod3.js @@ -1,4 +1,4 @@ -==ORIGINAL== +// ==ORIGINAL== namespace A { function foo() { } @@ -11,7 +11,7 @@ namespace A { } } } -==SCOPE::function 'a'== +// ==SCOPE::function 'a'== namespace A { function foo() { } @@ -28,7 +28,7 @@ namespace A { } } } -==SCOPE::namespace 'B'== +// ==SCOPE::namespace 'B'== namespace A { function foo() { } @@ -45,7 +45,7 @@ namespace A { } } } -==SCOPE::namespace 'A'== +// ==SCOPE::namespace 'A'== namespace A { function foo() { } @@ -62,7 +62,7 @@ namespace A { return foo(); } } -==SCOPE::global scope== +// ==SCOPE::global scope== namespace A { function foo() { } diff --git a/tests/baselines/reference/extractMethod/extractMethod4.js b/tests/baselines/reference/extractMethod/extractMethod4.js index 07029b2d050..107f99e669b 100644 --- a/tests/baselines/reference/extractMethod/extractMethod4.js +++ b/tests/baselines/reference/extractMethod/extractMethod4.js @@ -1,4 +1,4 @@ -==ORIGINAL== +// ==ORIGINAL== namespace A { function foo() { } @@ -13,7 +13,7 @@ namespace A { } } } -==SCOPE::function 'a'== +// ==SCOPE::function 'a'== namespace A { function foo() { } @@ -32,7 +32,7 @@ namespace A { } } } -==SCOPE::namespace 'B'== +// ==SCOPE::namespace 'B'== namespace A { function foo() { } @@ -51,7 +51,7 @@ namespace A { } } } -==SCOPE::namespace 'A'== +// ==SCOPE::namespace 'A'== namespace A { function foo() { } @@ -70,7 +70,7 @@ namespace A { return foo(); } } -==SCOPE::global scope== +// ==SCOPE::global scope== namespace A { function foo() { } diff --git a/tests/baselines/reference/extractMethod/extractMethod5.js b/tests/baselines/reference/extractMethod/extractMethod5.js index 96a76e426b1..77b2f7b5545 100644 --- a/tests/baselines/reference/extractMethod/extractMethod5.js +++ b/tests/baselines/reference/extractMethod/extractMethod5.js @@ -1,4 +1,4 @@ -==ORIGINAL== +// ==ORIGINAL== namespace A { let x = 1; export function foo() { @@ -14,7 +14,7 @@ namespace A { } } } -==SCOPE::function 'a'== +// ==SCOPE::function 'a'== namespace A { let x = 1; export function foo() { @@ -34,7 +34,7 @@ namespace A { } } } -==SCOPE::namespace 'B'== +// ==SCOPE::namespace 'B'== namespace A { let x = 1; export function foo() { @@ -55,7 +55,7 @@ namespace A { } } } -==SCOPE::namespace 'A'== +// ==SCOPE::namespace 'A'== namespace A { let x = 1; export function foo() { @@ -76,7 +76,7 @@ namespace A { return a; } } -==SCOPE::global scope== +// ==SCOPE::global scope== namespace A { let x = 1; export function foo() { diff --git a/tests/baselines/reference/extractMethod/extractMethod6.js b/tests/baselines/reference/extractMethod/extractMethod6.js index d1244ac9596..3c8c0a99b70 100644 --- a/tests/baselines/reference/extractMethod/extractMethod6.js +++ b/tests/baselines/reference/extractMethod/extractMethod6.js @@ -1,4 +1,4 @@ -==ORIGINAL== +// ==ORIGINAL== namespace A { let x = 1; export function foo() { @@ -14,7 +14,7 @@ namespace A { } } } -==SCOPE::function 'a'== +// ==SCOPE::function 'a'== namespace A { let x = 1; export function foo() { @@ -34,7 +34,7 @@ namespace A { } } } -==SCOPE::namespace 'B'== +// ==SCOPE::namespace 'B'== namespace A { let x = 1; export function foo() { @@ -56,7 +56,7 @@ namespace A { } } } -==SCOPE::namespace 'A'== +// ==SCOPE::namespace 'A'== namespace A { let x = 1; export function foo() { @@ -78,7 +78,7 @@ namespace A { return { __return: foo(), a }; } } -==SCOPE::global scope== +// ==SCOPE::global scope== namespace A { let x = 1; export function foo() { diff --git a/tests/baselines/reference/extractMethod/extractMethod7.js b/tests/baselines/reference/extractMethod/extractMethod7.js index da400d8b051..3f1e25991bd 100644 --- a/tests/baselines/reference/extractMethod/extractMethod7.js +++ b/tests/baselines/reference/extractMethod/extractMethod7.js @@ -1,4 +1,4 @@ -==ORIGINAL== +// ==ORIGINAL== namespace A { let x = 1; export namespace C { @@ -16,7 +16,7 @@ namespace A { } } } -==SCOPE::function 'a'== +// ==SCOPE::function 'a'== namespace A { let x = 1; export namespace C { @@ -38,7 +38,7 @@ namespace A { } } } -==SCOPE::namespace 'B'== +// ==SCOPE::namespace 'B'== namespace A { let x = 1; export namespace C { @@ -62,7 +62,7 @@ namespace A { } } } -==SCOPE::namespace 'A'== +// ==SCOPE::namespace 'A'== namespace A { let x = 1; export namespace C { @@ -86,7 +86,7 @@ namespace A { return { __return: C.foo(), a }; } } -==SCOPE::global scope== +// ==SCOPE::global scope== namespace A { let x = 1; export namespace C { diff --git a/tests/baselines/reference/extractMethod/extractMethod8.js b/tests/baselines/reference/extractMethod/extractMethod8.js index d298387b902..e6d933ec309 100644 --- a/tests/baselines/reference/extractMethod/extractMethod8.js +++ b/tests/baselines/reference/extractMethod/extractMethod8.js @@ -1,4 +1,4 @@ -==ORIGINAL== +// ==ORIGINAL== namespace A { let x = 1; namespace B { @@ -8,7 +8,7 @@ namespace A { } } } -==SCOPE::function 'a'== +// ==SCOPE::function 'a'== namespace A { let x = 1; namespace B { @@ -22,7 +22,7 @@ namespace A { } } } -==SCOPE::namespace 'B'== +// ==SCOPE::namespace 'B'== namespace A { let x = 1; namespace B { @@ -36,7 +36,7 @@ namespace A { } } } -==SCOPE::namespace 'A'== +// ==SCOPE::namespace 'A'== namespace A { let x = 1; namespace B { @@ -50,7 +50,7 @@ namespace A { return 1 + a1 + x; } } -==SCOPE::global scope== +// ==SCOPE::global scope== namespace A { let x = 1; namespace B { diff --git a/tests/baselines/reference/extractMethod/extractMethod9.js b/tests/baselines/reference/extractMethod/extractMethod9.js index 609e3535d57..6d0672f11c1 100644 --- a/tests/baselines/reference/extractMethod/extractMethod9.js +++ b/tests/baselines/reference/extractMethod/extractMethod9.js @@ -1,4 +1,4 @@ -==ORIGINAL== +// ==ORIGINAL== namespace A { export interface I { x: number }; namespace B { @@ -8,7 +8,7 @@ namespace A { } } } -==SCOPE::function 'a'== +// ==SCOPE::function 'a'== namespace A { export interface I { x: number }; namespace B { @@ -22,7 +22,7 @@ namespace A { } } } -==SCOPE::namespace 'B'== +// ==SCOPE::namespace 'B'== namespace A { export interface I { x: number }; namespace B { @@ -36,7 +36,7 @@ namespace A { } } } -==SCOPE::namespace 'A'== +// ==SCOPE::namespace 'A'== namespace A { export interface I { x: number }; namespace B { @@ -50,7 +50,7 @@ namespace A { return a1.x + 10; } } -==SCOPE::global scope== +// ==SCOPE::global scope== namespace A { export interface I { x: number }; namespace B { From bf0333ae07a4088fb69c0b0509a585d3c51f66ef Mon Sep 17 00:00:00 2001 From: Andrew Casey Date: Wed, 16 Aug 2017 15:53:14 -0700 Subject: [PATCH 180/370] Delete unused baselines --- tests/baselines/reference/extractMethod1.js | 98 ---------------- tests/baselines/reference/extractMethod10.js | 70 ------------ tests/baselines/reference/extractMethod11.js | 86 -------------- tests/baselines/reference/extractMethod12.js | 36 ------ tests/baselines/reference/extractMethod2.js | 85 -------------- tests/baselines/reference/extractMethod3.js | 80 ------------- tests/baselines/reference/extractMethod4.js | 90 --------------- tests/baselines/reference/extractMethod5.js | 98 ---------------- tests/baselines/reference/extractMethod6.js | 101 ----------------- tests/baselines/reference/extractMethod7.js | 111 ------------------- tests/baselines/reference/extractMethod8.js | 57 ---------- tests/baselines/reference/extractMethod9.js | 65 ----------- 12 files changed, 977 deletions(-) delete mode 100644 tests/baselines/reference/extractMethod1.js delete mode 100644 tests/baselines/reference/extractMethod10.js delete mode 100644 tests/baselines/reference/extractMethod11.js delete mode 100644 tests/baselines/reference/extractMethod12.js delete mode 100644 tests/baselines/reference/extractMethod2.js delete mode 100644 tests/baselines/reference/extractMethod3.js delete mode 100644 tests/baselines/reference/extractMethod4.js delete mode 100644 tests/baselines/reference/extractMethod5.js delete mode 100644 tests/baselines/reference/extractMethod6.js delete mode 100644 tests/baselines/reference/extractMethod7.js delete mode 100644 tests/baselines/reference/extractMethod8.js delete mode 100644 tests/baselines/reference/extractMethod9.js diff --git a/tests/baselines/reference/extractMethod1.js b/tests/baselines/reference/extractMethod1.js deleted file mode 100644 index 699916b0dc2..00000000000 --- a/tests/baselines/reference/extractMethod1.js +++ /dev/null @@ -1,98 +0,0 @@ -==ORIGINAL== -namespace A { - let x = 1; - function foo() { - } - namespace B { - function a() { - let a = 1; - - let y = 5; - let z = x; - a = y; - foo(); - } - } -} -==SCOPE::function a== -namespace A { - let x = 1; - function foo() { - } - namespace B { - function a() { - let a = 1; - - newFunction(); - - function newFunction() { - let y = 5; - let z = x; - a = y; - foo(); - } - } - } -} -==SCOPE::namespace B== -namespace A { - let x = 1; - function foo() { - } - namespace B { - function a() { - let a = 1; - - ({ a } = newFunction(a)); - } - - function newFunction(a: any) { - let y = 5; - let z = x; - a = y; - foo(); - return { a }; - } - } -} -==SCOPE::namespace A== -namespace A { - let x = 1; - function foo() { - } - namespace B { - function a() { - let a = 1; - - ({ a } = newFunction(a)); - } - } - - function newFunction(a: any) { - let y = 5; - let z = x; - a = y; - foo(); - return { a }; - } -} -==SCOPE::file '/a.ts'== -namespace A { - let x = 1; - function foo() { - } - namespace B { - function a() { - let a = 1; - - ({ a } = newFunction(x, a, foo)); - } - } -} -function newFunction(x: any, a: any, foo: any) { - let y = 5; - let z = x; - a = y; - foo(); - return { a }; -} diff --git a/tests/baselines/reference/extractMethod10.js b/tests/baselines/reference/extractMethod10.js deleted file mode 100644 index e416a66e262..00000000000 --- a/tests/baselines/reference/extractMethod10.js +++ /dev/null @@ -1,70 +0,0 @@ -==ORIGINAL== -namespace A { - export interface I { x: number }; - class C { - a() { - let z = 1; - let a1: I = { x: 1 }; - return a1.x + 10; - } - } -} -==SCOPE::method a== -namespace A { - export interface I { x: number }; - class C { - a() { - let z = 1; - return newFunction(); - - function newFunction() { - let a1: I = { x: 1 }; - return a1.x + 10; - } - } - } -} -==SCOPE::class C== -namespace A { - export interface I { x: number }; - class C { - a() { - let z = 1; - return this.newFunction(); - } - - private newFunction() { - let a1: I = { x: 1 }; - return a1.x + 10; - } - } -} -==SCOPE::namespace A== -namespace A { - export interface I { x: number }; - class C { - a() { - let z = 1; - return newFunction(); - } - } - - function newFunction() { - let a1: I = { x: 1 }; - return a1.x + 10; - } -} -==SCOPE::file '/a.ts'== -namespace A { - export interface I { x: number }; - class C { - a() { - let z = 1; - return newFunction(); - } - } -} -function newFunction() { - let a1: A.I = { x: 1 }; - return a1.x + 10; -} diff --git a/tests/baselines/reference/extractMethod11.js b/tests/baselines/reference/extractMethod11.js deleted file mode 100644 index 4cbd31d4453..00000000000 --- a/tests/baselines/reference/extractMethod11.js +++ /dev/null @@ -1,86 +0,0 @@ -==ORIGINAL== -namespace A { - let y = 1; - class C { - a() { - let z = 1; - let a1 = { x: 1 }; - y = 10; - z = 42; - return a1.x + 10; - } - } -} -==SCOPE::method a== -namespace A { - let y = 1; - class C { - a() { - let z = 1; - return newFunction(); - - function newFunction() { - let a1 = { x: 1 }; - y = 10; - z = 42; - return a1.x + 10; - } - } - } -} -==SCOPE::class C== -namespace A { - let y = 1; - class C { - a() { - let z = 1; - var __return: any; - ({ z, __return } = this.newFunction(z)); - return __return; - } - - private newFunction(z: any) { - let a1 = { x: 1 }; - y = 10; - z = 42; - return { z, __return: a1.x + 10 }; - } - } -} -==SCOPE::namespace A== -namespace A { - let y = 1; - class C { - a() { - let z = 1; - var __return: any; - ({ z, __return } = newFunction(z)); - return __return; - } - } - - function newFunction(z: any) { - let a1 = { x: 1 }; - y = 10; - z = 42; - return { z, __return: a1.x + 10 }; - } -} -==SCOPE::file '/a.ts'== -namespace A { - let y = 1; - class C { - a() { - let z = 1; - var __return: any; - ({ y, z, __return } = newFunction(y, z)); - return __return; - } - } -} -function newFunction(y: any, z: any) { - let a1 = { x: 1 }; - y = 10; - z = 42; - return { y, z, __return: a1.x + 10 }; -} diff --git a/tests/baselines/reference/extractMethod12.js b/tests/baselines/reference/extractMethod12.js deleted file mode 100644 index da0788a937f..00000000000 --- a/tests/baselines/reference/extractMethod12.js +++ /dev/null @@ -1,36 +0,0 @@ -==ORIGINAL== -namespace A { - let y = 1; - class C { - b() {} - a() { - let z = 1; - let a1 = { x: 1 }; - y = 10; - z = 42; - this.b(); - return a1.x + 10; - } - } -} -==SCOPE::class C== -namespace A { - let y = 1; - class C { - b() {} - a() { - let z = 1; - var __return: any; - ({ z, __return } = this.newFunction(z)); - return __return; - } - - private newFunction(z: any) { - let a1 = { x: 1 }; - y = 10; - z = 42; - this.b(); - return { z, __return: a1.x + 10 }; - } - } -} \ No newline at end of file diff --git a/tests/baselines/reference/extractMethod2.js b/tests/baselines/reference/extractMethod2.js deleted file mode 100644 index a89fe52f2fb..00000000000 --- a/tests/baselines/reference/extractMethod2.js +++ /dev/null @@ -1,85 +0,0 @@ -==ORIGINAL== -namespace A { - let x = 1; - function foo() { - } - namespace B { - function a() { - - let y = 5; - let z = x; - return foo(); - } - } -} -==SCOPE::function a== -namespace A { - let x = 1; - function foo() { - } - namespace B { - function a() { - - return newFunction(); - - function newFunction() { - let y = 5; - let z = x; - return foo(); - } - } - } -} -==SCOPE::namespace B== -namespace A { - let x = 1; - function foo() { - } - namespace B { - function a() { - - return newFunction(); - } - - function newFunction() { - let y = 5; - let z = x; - return foo(); - } - } -} -==SCOPE::namespace A== -namespace A { - let x = 1; - function foo() { - } - namespace B { - function a() { - - return newFunction(); - } - } - - function newFunction() { - let y = 5; - let z = x; - return foo(); - } -} -==SCOPE::file '/a.ts'== -namespace A { - let x = 1; - function foo() { - } - namespace B { - function a() { - - return newFunction(x, foo); - } - } -} -function newFunction(x: any, foo: any) { - let y = 5; - let z = x; - return foo(); -} diff --git a/tests/baselines/reference/extractMethod3.js b/tests/baselines/reference/extractMethod3.js deleted file mode 100644 index 847e196130c..00000000000 --- a/tests/baselines/reference/extractMethod3.js +++ /dev/null @@ -1,80 +0,0 @@ -==ORIGINAL== -namespace A { - function foo() { - } - namespace B { - function* a(z: number) { - - let y = 5; - yield z; - return foo(); - } - } -} -==SCOPE::function a== -namespace A { - function foo() { - } - namespace B { - function* a(z: number) { - - return yield* newFunction(); - - function* newFunction() { - let y = 5; - yield z; - return foo(); - } - } - } -} -==SCOPE::namespace B== -namespace A { - function foo() { - } - namespace B { - function* a(z: number) { - - return yield* newFunction(z); - } - - function* newFunction(z: any) { - let y = 5; - yield z; - return foo(); - } - } -} -==SCOPE::namespace A== -namespace A { - function foo() { - } - namespace B { - function* a(z: number) { - - return yield* newFunction(z); - } - } - - function* newFunction(z: any) { - let y = 5; - yield z; - return foo(); - } -} -==SCOPE::file '/a.ts'== -namespace A { - function foo() { - } - namespace B { - function* a(z: number) { - - return yield* newFunction(z, foo); - } - } -} -function* newFunction(z: any, foo: any) { - let y = 5; - yield z; - return foo(); -} diff --git a/tests/baselines/reference/extractMethod4.js b/tests/baselines/reference/extractMethod4.js deleted file mode 100644 index 25f410eeecb..00000000000 --- a/tests/baselines/reference/extractMethod4.js +++ /dev/null @@ -1,90 +0,0 @@ -==ORIGINAL== -namespace A { - function foo() { - } - namespace B { - async function a(z: number, z1: any) { - - let y = 5; - if (z) { - await z1; - } - return foo(); - } - } -} -==SCOPE::function a== -namespace A { - function foo() { - } - namespace B { - async function a(z: number, z1: any) { - - return await newFunction(); - - async function newFunction() { - let y = 5; - if (z) { - await z1; - } - return foo(); - } - } - } -} -==SCOPE::namespace B== -namespace A { - function foo() { - } - namespace B { - async function a(z: number, z1: any) { - - return await newFunction(z, z1); - } - - async function newFunction(z: any, z1: any) { - let y = 5; - if (z) { - await z1; - } - return foo(); - } - } -} -==SCOPE::namespace A== -namespace A { - function foo() { - } - namespace B { - async function a(z: number, z1: any) { - - return await newFunction(z, z1); - } - } - - async function newFunction(z: any, z1: any) { - let y = 5; - if (z) { - await z1; - } - return foo(); - } -} -==SCOPE::file '/a.ts'== -namespace A { - function foo() { - } - namespace B { - async function a(z: number, z1: any) { - - return await newFunction(z, z1, foo); - } - } -} -async function newFunction(z: any, z1: any, foo: any) { - let y = 5; - if (z) { - await z1; - } - return foo(); -} diff --git a/tests/baselines/reference/extractMethod5.js b/tests/baselines/reference/extractMethod5.js deleted file mode 100644 index 135c4ed5f62..00000000000 --- a/tests/baselines/reference/extractMethod5.js +++ /dev/null @@ -1,98 +0,0 @@ -==ORIGINAL== -namespace A { - let x = 1; - export function foo() { - } - namespace B { - function a() { - let a = 1; - - let y = 5; - let z = x; - a = y; - foo(); - } - } -} -==SCOPE::function a== -namespace A { - let x = 1; - export function foo() { - } - namespace B { - function a() { - let a = 1; - - newFunction(); - - function newFunction() { - let y = 5; - let z = x; - a = y; - foo(); - } - } - } -} -==SCOPE::namespace B== -namespace A { - let x = 1; - export function foo() { - } - namespace B { - function a() { - let a = 1; - - ({ a } = newFunction(a)); - } - - function newFunction(a: any) { - let y = 5; - let z = x; - a = y; - foo(); - return { a }; - } - } -} -==SCOPE::namespace A== -namespace A { - let x = 1; - export function foo() { - } - namespace B { - function a() { - let a = 1; - - ({ a } = newFunction(a)); - } - } - - function newFunction(a: any) { - let y = 5; - let z = x; - a = y; - foo(); - return { a }; - } -} -==SCOPE::file '/a.ts'== -namespace A { - let x = 1; - export function foo() { - } - namespace B { - function a() { - let a = 1; - - ({ a } = newFunction(x, a)); - } - } -} -function newFunction(x: any, a: any) { - let y = 5; - let z = x; - a = y; - A.foo(); - return { a }; -} diff --git a/tests/baselines/reference/extractMethod6.js b/tests/baselines/reference/extractMethod6.js deleted file mode 100644 index 94fcc8e6e31..00000000000 --- a/tests/baselines/reference/extractMethod6.js +++ /dev/null @@ -1,101 +0,0 @@ -==ORIGINAL== -namespace A { - let x = 1; - export function foo() { - } - namespace B { - function a() { - let a = 1; - - let y = 5; - let z = x; - a = y; - return foo(); - } - } -} -==SCOPE::function a== -namespace A { - let x = 1; - export function foo() { - } - namespace B { - function a() { - let a = 1; - - return newFunction(); - - function newFunction() { - let y = 5; - let z = x; - a = y; - return foo(); - } - } - } -} -==SCOPE::namespace B== -namespace A { - let x = 1; - export function foo() { - } - namespace B { - function a() { - let a = 1; - - var __return: any; - ({ a, __return } = newFunction(a)); - return __return; - } - - function newFunction(a: any) { - let y = 5; - let z = x; - a = y; - return { a, __return: foo() }; - } - } -} -==SCOPE::namespace A== -namespace A { - let x = 1; - export function foo() { - } - namespace B { - function a() { - let a = 1; - - var __return: any; - ({ a, __return } = newFunction(a)); - return __return; - } - } - - function newFunction(a: any) { - let y = 5; - let z = x; - a = y; - return { a, __return: foo() }; - } -} -==SCOPE::file '/a.ts'== -namespace A { - let x = 1; - export function foo() { - } - namespace B { - function a() { - let a = 1; - - var __return: any; - ({ a, __return } = newFunction(x, a)); - return __return; - } - } -} -function newFunction(x: any, a: any) { - let y = 5; - let z = x; - a = y; - return { a, __return: A.foo() }; -} diff --git a/tests/baselines/reference/extractMethod7.js b/tests/baselines/reference/extractMethod7.js deleted file mode 100644 index c7c3cc8d77a..00000000000 --- a/tests/baselines/reference/extractMethod7.js +++ /dev/null @@ -1,111 +0,0 @@ -==ORIGINAL== -namespace A { - let x = 1; - export namespace C { - export function foo() { - } - } - namespace B { - function a() { - let a = 1; - - let y = 5; - let z = x; - a = y; - return C.foo(); - } - } -} -==SCOPE::function a== -namespace A { - let x = 1; - export namespace C { - export function foo() { - } - } - namespace B { - function a() { - let a = 1; - - return newFunction(); - - function newFunction() { - let y = 5; - let z = x; - a = y; - return C.foo(); - } - } - } -} -==SCOPE::namespace B== -namespace A { - let x = 1; - export namespace C { - export function foo() { - } - } - namespace B { - function a() { - let a = 1; - - var __return: any; - ({ a, __return } = newFunction(a)); - return __return; - } - - function newFunction(a: any) { - let y = 5; - let z = x; - a = y; - return { a, __return: C.foo() }; - } - } -} -==SCOPE::namespace A== -namespace A { - let x = 1; - export namespace C { - export function foo() { - } - } - namespace B { - function a() { - let a = 1; - - var __return: any; - ({ a, __return } = newFunction(a)); - return __return; - } - } - - function newFunction(a: any) { - let y = 5; - let z = x; - a = y; - return { a, __return: C.foo() }; - } -} -==SCOPE::file '/a.ts'== -namespace A { - let x = 1; - export namespace C { - export function foo() { - } - } - namespace B { - function a() { - let a = 1; - - var __return: any; - ({ a, __return } = newFunction(x, a)); - return __return; - } - } -} -function newFunction(x: any, a: any) { - let y = 5; - let z = x; - a = y; - return { a, __return: A.C.foo() }; -} diff --git a/tests/baselines/reference/extractMethod8.js b/tests/baselines/reference/extractMethod8.js deleted file mode 100644 index f030b0ea4af..00000000000 --- a/tests/baselines/reference/extractMethod8.js +++ /dev/null @@ -1,57 +0,0 @@ -==ORIGINAL== -namespace A { - let x = 1; - namespace B { - function a() { - let a1 = 1; - return 1 + a1 + x + 100; - } - } -} -==SCOPE::function a== -namespace A { - let x = 1; - namespace B { - function a() { - let a1 = 1; - return newFunction() + 100; - - function newFunction() { 1 + a1 + x; } - } - } -} -==SCOPE::namespace B== -namespace A { - let x = 1; - namespace B { - function a() { - let a1 = 1; - return newFunction(a1) + 100; - } - - function newFunction(a1: any) { 1 + a1 + x; } - } -} -==SCOPE::namespace A== -namespace A { - let x = 1; - namespace B { - function a() { - let a1 = 1; - return newFunction(a1) + 100; - } - } - - function newFunction(a1: any) { 1 + a1 + x; } -} -==SCOPE::file '/a.ts'== -namespace A { - let x = 1; - namespace B { - function a() { - let a1 = 1; - return newFunction(a1, x) + 100; - } - } -} -function newFunction(a1: any, x: any) { 1 + a1 + x; } diff --git a/tests/baselines/reference/extractMethod9.js b/tests/baselines/reference/extractMethod9.js deleted file mode 100644 index fcc5dcd23de..00000000000 --- a/tests/baselines/reference/extractMethod9.js +++ /dev/null @@ -1,65 +0,0 @@ -==ORIGINAL== -namespace A { - export interface I { x: number }; - namespace B { - function a() { - let a1: I = { x: 1 }; - return a1.x + 10; - } - } -} -==SCOPE::function a== -namespace A { - export interface I { x: number }; - namespace B { - function a() { - return newFunction(); - - function newFunction() { - let a1: I = { x: 1 }; - return a1.x + 10; - } - } - } -} -==SCOPE::namespace B== -namespace A { - export interface I { x: number }; - namespace B { - function a() { - return newFunction(); - } - - function newFunction() { - let a1: I = { x: 1 }; - return a1.x + 10; - } - } -} -==SCOPE::namespace A== -namespace A { - export interface I { x: number }; - namespace B { - function a() { - return newFunction(); - } - } - - function newFunction() { - let a1: I = { x: 1 }; - return a1.x + 10; - } -} -==SCOPE::file '/a.ts'== -namespace A { - export interface I { x: number }; - namespace B { - function a() { - return newFunction(); - } - } -} -function newFunction() { - let a1: A.I = { x: 1 }; - return a1.x + 10; -} From ee80019d1625a519088c0c93cfb7794b544522b2 Mon Sep 17 00:00:00 2001 From: Andrew Casey Date: Wed, 16 Aug 2017 15:53:41 -0700 Subject: [PATCH 181/370] Switch from .js to .ts so that baselines are syntactically valid --- src/harness/unittests/extractMethods.ts | 2 +- .../extractMethod/{extractMethod1.js => extractMethod1.ts} | 0 .../extractMethod/{extractMethod10.js => extractMethod10.ts} | 0 .../extractMethod/{extractMethod11.js => extractMethod11.ts} | 0 .../extractMethod/{extractMethod12.js => extractMethod12.ts} | 0 .../extractMethod/{extractMethod2.js => extractMethod2.ts} | 0 .../extractMethod/{extractMethod3.js => extractMethod3.ts} | 0 .../extractMethod/{extractMethod4.js => extractMethod4.ts} | 0 .../extractMethod/{extractMethod5.js => extractMethod5.ts} | 0 .../extractMethod/{extractMethod6.js => extractMethod6.ts} | 0 .../extractMethod/{extractMethod7.js => extractMethod7.ts} | 0 .../extractMethod/{extractMethod8.js => extractMethod8.ts} | 0 .../extractMethod/{extractMethod9.js => extractMethod9.ts} | 0 13 files changed, 1 insertion(+), 1 deletion(-) rename tests/baselines/reference/extractMethod/{extractMethod1.js => extractMethod1.ts} (100%) rename tests/baselines/reference/extractMethod/{extractMethod10.js => extractMethod10.ts} (100%) rename tests/baselines/reference/extractMethod/{extractMethod11.js => extractMethod11.ts} (100%) rename tests/baselines/reference/extractMethod/{extractMethod12.js => extractMethod12.ts} (100%) rename tests/baselines/reference/extractMethod/{extractMethod2.js => extractMethod2.ts} (100%) rename tests/baselines/reference/extractMethod/{extractMethod3.js => extractMethod3.ts} (100%) rename tests/baselines/reference/extractMethod/{extractMethod4.js => extractMethod4.ts} (100%) rename tests/baselines/reference/extractMethod/{extractMethod5.js => extractMethod5.ts} (100%) rename tests/baselines/reference/extractMethod/{extractMethod6.js => extractMethod6.ts} (100%) rename tests/baselines/reference/extractMethod/{extractMethod7.js => extractMethod7.ts} (100%) rename tests/baselines/reference/extractMethod/{extractMethod8.js => extractMethod8.ts} (100%) rename tests/baselines/reference/extractMethod/{extractMethod9.js => extractMethod9.ts} (100%) diff --git a/src/harness/unittests/extractMethods.ts b/src/harness/unittests/extractMethods.ts index c148d6d58a5..971d918cb33 100644 --- a/src/harness/unittests/extractMethods.ts +++ b/src/harness/unittests/extractMethods.ts @@ -550,7 +550,7 @@ namespace A { function testExtractMethod(caption: string, text: string) { it(caption, () => { - Harness.Baseline.runBaseline(`extractMethod/${caption}.js`, () => { + Harness.Baseline.runBaseline(`extractMethod/${caption}.ts`, () => { const t = extractTest(text); const selectionRange = t.ranges.get("selection"); if (!selectionRange) { diff --git a/tests/baselines/reference/extractMethod/extractMethod1.js b/tests/baselines/reference/extractMethod/extractMethod1.ts similarity index 100% rename from tests/baselines/reference/extractMethod/extractMethod1.js rename to tests/baselines/reference/extractMethod/extractMethod1.ts diff --git a/tests/baselines/reference/extractMethod/extractMethod10.js b/tests/baselines/reference/extractMethod/extractMethod10.ts similarity index 100% rename from tests/baselines/reference/extractMethod/extractMethod10.js rename to tests/baselines/reference/extractMethod/extractMethod10.ts diff --git a/tests/baselines/reference/extractMethod/extractMethod11.js b/tests/baselines/reference/extractMethod/extractMethod11.ts similarity index 100% rename from tests/baselines/reference/extractMethod/extractMethod11.js rename to tests/baselines/reference/extractMethod/extractMethod11.ts diff --git a/tests/baselines/reference/extractMethod/extractMethod12.js b/tests/baselines/reference/extractMethod/extractMethod12.ts similarity index 100% rename from tests/baselines/reference/extractMethod/extractMethod12.js rename to tests/baselines/reference/extractMethod/extractMethod12.ts diff --git a/tests/baselines/reference/extractMethod/extractMethod2.js b/tests/baselines/reference/extractMethod/extractMethod2.ts similarity index 100% rename from tests/baselines/reference/extractMethod/extractMethod2.js rename to tests/baselines/reference/extractMethod/extractMethod2.ts diff --git a/tests/baselines/reference/extractMethod/extractMethod3.js b/tests/baselines/reference/extractMethod/extractMethod3.ts similarity index 100% rename from tests/baselines/reference/extractMethod/extractMethod3.js rename to tests/baselines/reference/extractMethod/extractMethod3.ts diff --git a/tests/baselines/reference/extractMethod/extractMethod4.js b/tests/baselines/reference/extractMethod/extractMethod4.ts similarity index 100% rename from tests/baselines/reference/extractMethod/extractMethod4.js rename to tests/baselines/reference/extractMethod/extractMethod4.ts diff --git a/tests/baselines/reference/extractMethod/extractMethod5.js b/tests/baselines/reference/extractMethod/extractMethod5.ts similarity index 100% rename from tests/baselines/reference/extractMethod/extractMethod5.js rename to tests/baselines/reference/extractMethod/extractMethod5.ts diff --git a/tests/baselines/reference/extractMethod/extractMethod6.js b/tests/baselines/reference/extractMethod/extractMethod6.ts similarity index 100% rename from tests/baselines/reference/extractMethod/extractMethod6.js rename to tests/baselines/reference/extractMethod/extractMethod6.ts diff --git a/tests/baselines/reference/extractMethod/extractMethod7.js b/tests/baselines/reference/extractMethod/extractMethod7.ts similarity index 100% rename from tests/baselines/reference/extractMethod/extractMethod7.js rename to tests/baselines/reference/extractMethod/extractMethod7.ts diff --git a/tests/baselines/reference/extractMethod/extractMethod8.js b/tests/baselines/reference/extractMethod/extractMethod8.ts similarity index 100% rename from tests/baselines/reference/extractMethod/extractMethod8.js rename to tests/baselines/reference/extractMethod/extractMethod8.ts diff --git a/tests/baselines/reference/extractMethod/extractMethod9.js b/tests/baselines/reference/extractMethod/extractMethod9.ts similarity index 100% rename from tests/baselines/reference/extractMethod/extractMethod9.js rename to tests/baselines/reference/extractMethod/extractMethod9.ts From b09d2277b8d4797419738b29c97e5d682c6fe0f4 Mon Sep 17 00:00:00 2001 From: Andrew Casey Date: Wed, 16 Aug 2017 16:13:20 -0700 Subject: [PATCH 182/370] Test that in-scope type parameters are not passed explicitly --- src/harness/unittests/extractMethods.ts | 21 ++++++ .../extractMethod/extractMethod13.ts | 75 +++++++++++++++++++ 2 files changed, 96 insertions(+) create mode 100644 tests/baselines/reference/extractMethod/extractMethod13.ts diff --git a/src/harness/unittests/extractMethods.ts b/src/harness/unittests/extractMethods.ts index 971d918cb33..36f739113ab 100644 --- a/src/harness/unittests/extractMethods.ts +++ b/src/harness/unittests/extractMethods.ts @@ -544,6 +544,27 @@ namespace A { return a1.x + 10;|] } } +}`); + // The "b" type parameters aren't used and shouldn't be passed to the extracted function. + // Type parameters should be in syntactic order (i.e. in order or character offset from BOF). + // In all cases, we could use type inference, rather than passing explicit type arguments. + // Note the inclusion of arrow functions to ensure that some type parameters are not from + // targetable scopes. + testExtractMethod("extractMethod13", + `(u1a: U1a, u1b: U1b) => { + function F1(t1a: T1a, t1b: T1b) { + (u2a: U2a, u2b: U2b) => { + function F2(t2a: T2a, t2b: T2b) { + (u3a: U3a, u3b: U3b) => { + [#|t1a.toString(); + t2a.toString(); + u1a.toString(); + u2a.toString(); + u3a.toString();|] + } + } + } + } }`); }); diff --git a/tests/baselines/reference/extractMethod/extractMethod13.ts b/tests/baselines/reference/extractMethod/extractMethod13.ts new file mode 100644 index 00000000000..8f76dea88aa --- /dev/null +++ b/tests/baselines/reference/extractMethod/extractMethod13.ts @@ -0,0 +1,75 @@ +// ==ORIGINAL== +(u1a: U1a, u1b: U1b) => { + function F1(t1a: T1a, t1b: T1b) { + (u2a: U2a, u2b: U2b) => { + function F2(t2a: T2a, t2b: T2b) { + (u3a: U3a, u3b: U3b) => { + t1a.toString(); + t2a.toString(); + u1a.toString(); + u2a.toString(); + u3a.toString(); + } + } + } + } +} +// ==SCOPE::function 'F2'== +(u1a: U1a, u1b: U1b) => { + function F1(t1a: T1a, t1b: T1b) { + (u2a: U2a, u2b: U2b) => { + function F2(t2a: T2a, t2b: T2b) { + (u3a: U3a, u3b: U3b) => { + newFunction(u3a); + } + + function newFunction(u3a: U3a) { + t1a.toString(); + t2a.toString(); + u1a.toString(); + u2a.toString(); + u3a.toString(); + } + } + } + } +} +// ==SCOPE::function 'F1'== +(u1a: U1a, u1b: U1b) => { + function F1(t1a: T1a, t1b: T1b) { + (u2a: U2a, u2b: U2b) => { + function F2(t2a: T2a, t2b: T2b) { + (u3a: U3a, u3b: U3b) => { + newFunction(t2a, u2a, u3a); + } + } + } + + function newFunction(t2a: T2a, u2a: U2a, u3a: U3a) { + t1a.toString(); + t2a.toString(); + u1a.toString(); + u2a.toString(); + u3a.toString(); + } + } +} +// ==SCOPE::global scope== +(u1a: U1a, u1b: U1b) => { + function F1(t1a: T1a, t1b: T1b) { + (u2a: U2a, u2b: U2b) => { + function F2(t2a: T2a, t2b: T2b) { + (u3a: U3a, u3b: U3b) => { + newFunction(t1a, t2a, u1a, u2a, u3a); + } + } + } + } +} +function newFunction(t1a: T1a, t2a: T2a, u1a: U1a, u2a: U2a, u3a: U3a) { + t1a.toString(); + t2a.toString(); + u1a.toString(); + u2a.toString(); + u3a.toString(); +} From fe015ef30fde86ffa4c3eeb89ffe699b5d1eec52 Mon Sep 17 00:00:00 2001 From: Andrew Casey Date: Wed, 16 Aug 2017 16:35:53 -0700 Subject: [PATCH 183/370] Document failure to handle type parameter shadowing --- src/harness/unittests/extractMethods.ts | 9 +++++ .../extractMethod/extractMethod14.ts | 39 +++++++++++++++++++ 2 files changed, 48 insertions(+) create mode 100644 tests/baselines/reference/extractMethod/extractMethod14.ts diff --git a/src/harness/unittests/extractMethods.ts b/src/harness/unittests/extractMethods.ts index 36f739113ab..a7cc73b5b51 100644 --- a/src/harness/unittests/extractMethods.ts +++ b/src/harness/unittests/extractMethods.ts @@ -565,6 +565,15 @@ namespace A { } } } +}`); + // This test is descriptive, rather than normative. The current implementation + // doesn't handle type parameter shadowing. + testExtractMethod("extractMethod14", + `function F(t1: T) { + function F(t2: T) { + [#|t1.toString(); + t2.toString();|] + } }`); }); diff --git a/tests/baselines/reference/extractMethod/extractMethod14.ts b/tests/baselines/reference/extractMethod/extractMethod14.ts new file mode 100644 index 00000000000..38e4c380ebc --- /dev/null +++ b/tests/baselines/reference/extractMethod/extractMethod14.ts @@ -0,0 +1,39 @@ +// ==ORIGINAL== +function F(t1: T) { + function F(t2: T) { + t1.toString(); + t2.toString(); + } +} +// ==SCOPE::function 'F'== +function F(t1: T) { + function F(t2: T) { + newFunction(); + + function newFunction() { + t1.toString(); + t2.toString(); + } + } +} +// ==SCOPE::function 'F'== +function F(t1: T) { + function F(t2: T) { + newFunction(t2); + } + + function newFunction(t2: T) { + t1.toString(); + t2.toString(); + } +} +// ==SCOPE::global scope== +function F(t1: T) { + function F(t2: T) { + newFunction(t1, t2); + } +} +function newFunction(t1: T, t2: T) { + t1.toString(); + t2.toString(); +} From 0c8d85fbc4154487a5677fb95ecf717fb22bf7d8 Mon Sep 17 00:00:00 2001 From: Andrew Casey Date: Wed, 16 Aug 2017 16:54:57 -0700 Subject: [PATCH 184/370] Test that type parameters used in constraints are passed along --- src/harness/unittests/extractMethods.ts | 9 ++++- .../extractMethod/extractMethod15.ts | 35 +++++++++++++++++++ 2 files changed, 43 insertions(+), 1 deletion(-) create mode 100644 tests/baselines/reference/extractMethod/extractMethod15.ts diff --git a/src/harness/unittests/extractMethods.ts b/src/harness/unittests/extractMethods.ts index a7cc73b5b51..43984fc21b8 100644 --- a/src/harness/unittests/extractMethods.ts +++ b/src/harness/unittests/extractMethods.ts @@ -574,6 +574,13 @@ namespace A { [#|t1.toString(); t2.toString();|] } +}`); + // Confirm that the constraint is preserved. + testExtractMethod("extractMethod15", + `function F(t1: T) { + function F(t2: U) { + [#|t2.toString();|] + } }`); }); @@ -590,7 +597,7 @@ namespace A { path: "/a.ts", content: t.source }; - const host = projectSystem.createServerHost([f]); + const host = projectSystem.createServerHost([f, projectSystem.libFile]); const projectService = projectSystem.createProjectService(host); projectService.openClientFile(f.path); const program = projectService.inferredProjects[0].getLanguageService().getProgram(); diff --git a/tests/baselines/reference/extractMethod/extractMethod15.ts b/tests/baselines/reference/extractMethod/extractMethod15.ts new file mode 100644 index 00000000000..ba5b9b3ad01 --- /dev/null +++ b/tests/baselines/reference/extractMethod/extractMethod15.ts @@ -0,0 +1,35 @@ +// ==ORIGINAL== +function F(t1: T) { + function F(t2: U) { + t2.toString(); + } +} +// ==SCOPE::function 'F'== +function F(t1: T) { + function F(t2: U) { + newFunction(); + + function newFunction() { + t2.toString(); + } + } +} +// ==SCOPE::function 'F'== +function F(t1: T) { + function F(t2: U) { + newFunction(t2); + } + + function newFunction(t2: U) { + t2.toString(); + } +} +// ==SCOPE::global scope== +function F(t1: T) { + function F(t2: U) { + newFunction(t2); + } +} +function newFunction(t2: U) { + t2.toString(); +} From 01d7f0b699def1d9f9d3045bbe6fcb0c72079fb8 Mon Sep 17 00:00:00 2001 From: Andrew Casey Date: Wed, 16 Aug 2017 17:50:50 -0700 Subject: [PATCH 185/370] Test that the return type of the extracted method counts as usage --- src/harness/unittests/extractMethods.ts | 5 ++++ src/services/refactors/extractMethod.ts | 30 +++++++++++++------ .../extractMethod/extractMethod16.ts | 19 ++++++++++++ 3 files changed, 45 insertions(+), 9 deletions(-) create mode 100644 tests/baselines/reference/extractMethod/extractMethod16.ts diff --git a/src/harness/unittests/extractMethods.ts b/src/harness/unittests/extractMethods.ts index 43984fc21b8..7d7125c5025 100644 --- a/src/harness/unittests/extractMethods.ts +++ b/src/harness/unittests/extractMethods.ts @@ -581,6 +581,11 @@ namespace A { function F(t2: U) { [#|t2.toString();|] } +}`); + // Confirm that the contextual type of an extracted expression counts as a use. + testExtractMethod("extractMethod16", + `function F() { + const array: T[] = [#|[]|]; }`); }); diff --git a/src/services/refactors/extractMethod.ts b/src/services/refactors/extractMethod.ts index ff376026e52..b02cb607e04 100644 --- a/src/services/refactors/extractMethod.ts +++ b/src/services/refactors/extractMethod.ts @@ -946,6 +946,7 @@ namespace ts.refactor.extractMethod { substitutionsPerScope.push(createMap()); errorsPerScope.push([]); } + const seenUsages = createMap(); const target = isReadonlyArray(targetRange.range) ? createBlock(targetRange.range) : targetRange.range; const containingLexicalScopeOfExtraction = isBlockScope(scopes[0], scopes[0].parent) ? scopes[0] : getEnclosingBlockScopeContainer(scopes[0]); @@ -955,6 +956,14 @@ namespace ts.refactor.extractMethod { collectUsages(target); + // Unfortunately, this code takes advantage of the knowledge that the generated method + // will use the contextual type of an expression as the return type of the extracted + // method (and will therefore "use" all the types involved). + if (inGenericContext && !isReadonlyArray(targetRange.range)) { + const contextualType = checker.getContextualType(targetRange.range); + recordTypeParameterUsages(contextualType); + } + if (allTypeParameterUsages.size > 0) { const seenTypeParameterUsages = createMap(); // Key is type ID @@ -1032,18 +1041,21 @@ namespace ts.refactor.extractMethod { return false; } + function recordTypeParameterUsages(type: Type) { + const symbolWalker = checker.getSymbolWalker(); + const {visitedTypes} = symbolWalker.walkType(type); + + for (const visitedType of visitedTypes) { + if (visitedType.flags & TypeFlags.TypeParameter) { + allTypeParameterUsages.set(visitedType.id.toString(), visitedType as TypeParameter); + } + } + } + function collectUsages(node: Node, valueUsage = Usage.Read) { if (inGenericContext) { const type = checker.getTypeAtLocation(node); - - const symbolWalker = checker.getSymbolWalker(); - const {visitedTypes} = symbolWalker.walkType(type); - - for (const visitedType of visitedTypes) { - if (visitedType.flags & TypeFlags.TypeParameter) { - allTypeParameterUsages.set(visitedType.id.toString(), visitedType as TypeParameter); - } - } + recordTypeParameterUsages(type); } if (isDeclaration(node) && node.symbol) { diff --git a/tests/baselines/reference/extractMethod/extractMethod16.ts b/tests/baselines/reference/extractMethod/extractMethod16.ts new file mode 100644 index 00000000000..1ce88b93145 --- /dev/null +++ b/tests/baselines/reference/extractMethod/extractMethod16.ts @@ -0,0 +1,19 @@ +// ==ORIGINAL== +function F() { + const array: T[] = []; +} +// ==SCOPE::function 'F'== +function F() { + const array: T[] = newFunction(); + + function newFunction(): T[] { + return []; + } +} +// ==SCOPE::global scope== +function F() { + const array: T[] = newFunction(); +} +function newFunction(): T[] { + return []; +} From e08dce2c21a251e88e51db49d389ac12bcea3373 Mon Sep 17 00:00:00 2001 From: Andrew Casey Date: Thu, 17 Aug 2017 14:54:25 -0700 Subject: [PATCH 186/370] Test different parameters on classes and methods --- src/harness/unittests/extractMethods.ts | 14 +++++++++++ .../extractMethod/extractMethod17.ts | 25 +++++++++++++++++++ .../extractMethod/extractMethod18.ts | 25 +++++++++++++++++++ 3 files changed, 64 insertions(+) create mode 100644 tests/baselines/reference/extractMethod/extractMethod17.ts create mode 100644 tests/baselines/reference/extractMethod/extractMethod18.ts diff --git a/src/harness/unittests/extractMethods.ts b/src/harness/unittests/extractMethods.ts index 7d7125c5025..227f6b22b03 100644 --- a/src/harness/unittests/extractMethods.ts +++ b/src/harness/unittests/extractMethods.ts @@ -586,6 +586,20 @@ namespace A { testExtractMethod("extractMethod16", `function F() { const array: T[] = [#|[]|]; +}`); + // Class type parameter + testExtractMethod("extractMethod17", + `class C { + M(t1: T1, t2: T2) { + [#|t1.toString()|]; + } +}`); + // Method type parameter + testExtractMethod("extractMethod18", + `class C { + M(t1: T1, t2: T2) { + [#|t1.toString()|]; + } }`); }); diff --git a/tests/baselines/reference/extractMethod/extractMethod17.ts b/tests/baselines/reference/extractMethod/extractMethod17.ts new file mode 100644 index 00000000000..d800c79f3bd --- /dev/null +++ b/tests/baselines/reference/extractMethod/extractMethod17.ts @@ -0,0 +1,25 @@ +// ==ORIGINAL== +class C { + M(t1: T1, t2: T2) { + t1.toString(); + } +} +// ==SCOPE::class 'C'== +class C { + M(t1: T1, t2: T2) { + this.newFunction(t1); + } + + private newFunction(t1: T1) { + t1.toString(); + } +} +// ==SCOPE::global scope== +class C { + M(t1: T1, t2: T2) { + newFunction(t1); + } +} +function newFunction(t1: T1) { + t1.toString(); +} diff --git a/tests/baselines/reference/extractMethod/extractMethod18.ts b/tests/baselines/reference/extractMethod/extractMethod18.ts new file mode 100644 index 00000000000..ce6a90c3790 --- /dev/null +++ b/tests/baselines/reference/extractMethod/extractMethod18.ts @@ -0,0 +1,25 @@ +// ==ORIGINAL== +class C { + M(t1: T1, t2: T2) { + t1.toString(); + } +} +// ==SCOPE::class 'C'== +class C { + M(t1: T1, t2: T2) { + this.newFunction(t1); + } + + private newFunction(t1: T1) { + t1.toString(); + } +} +// ==SCOPE::global scope== +class C { + M(t1: T1, t2: T2) { + newFunction(t1); + } +} +function newFunction(t1: T1) { + t1.toString(); +} From c9f6bc60e2f345c59653aa40221cad8ca6f0a1dd Mon Sep 17 00:00:00 2001 From: Andrew Casey Date: Thu, 17 Aug 2017 15:14:36 -0700 Subject: [PATCH 187/370] Test coupling of type parameters --- src/harness/unittests/extractMethods.ts | 5 +++++ .../extractMethod/extractMethod19.ts | 19 +++++++++++++++++++ 2 files changed, 24 insertions(+) create mode 100644 tests/baselines/reference/extractMethod/extractMethod19.ts diff --git a/src/harness/unittests/extractMethods.ts b/src/harness/unittests/extractMethods.ts index 227f6b22b03..a7741a56f59 100644 --- a/src/harness/unittests/extractMethods.ts +++ b/src/harness/unittests/extractMethods.ts @@ -600,6 +600,11 @@ namespace A { M(t1: T1, t2: T2) { [#|t1.toString()|]; } +}`); + // Coupled constraints + testExtractMethod("extractMethod19", + `function F(v: V) { + [#|v.toString()|]; }`); }); diff --git a/tests/baselines/reference/extractMethod/extractMethod19.ts b/tests/baselines/reference/extractMethod/extractMethod19.ts new file mode 100644 index 00000000000..1bf25550172 --- /dev/null +++ b/tests/baselines/reference/extractMethod/extractMethod19.ts @@ -0,0 +1,19 @@ +// ==ORIGINAL== +function F(v: V) { + v.toString(); +} +// ==SCOPE::function 'F'== +function F(v: V) { + newFunction(); + + function newFunction() { + v.toString(); + } +} +// ==SCOPE::global scope== +function F(v: V) { + newFunction(v); +} +function newFunction(v: V) { + v.toString(); +} From a816079ddad974b7d62c1368767e60d72371311b Mon Sep 17 00:00:00 2001 From: Andrew Casey Date: Thu, 17 Aug 2017 16:24:44 -0700 Subject: [PATCH 188/370] Add perf comment --- src/services/refactors/extractMethod.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/services/refactors/extractMethod.ts b/src/services/refactors/extractMethod.ts index b02cb607e04..5e1a96aa1fb 100644 --- a/src/services/refactors/extractMethod.ts +++ b/src/services/refactors/extractMethod.ts @@ -1042,6 +1042,9 @@ namespace ts.refactor.extractMethod { } function recordTypeParameterUsages(type: Type) { + // PERF: This is potentially very expensive. `type` could be a library type with + // a lot of properties, each of which the walker will visit. Unfortunately, the + // solution isn't as trivial as filtering to user types because of (e.g.) Array. const symbolWalker = checker.getSymbolWalker(); const {visitedTypes} = symbolWalker.walkType(type); From 450c32ace01138fa4f28a7d5edd859c778b3f407 Mon Sep 17 00:00:00 2001 From: Andy Date: Tue, 29 Aug 2017 11:33:01 -0700 Subject: [PATCH 189/370] Add an ExpandingFlags const enum (#17740) * Add an ExpandingFlags const enum * Reformat --- src/compiler/checker.ts | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 05b84a78d9f..866fda18b03 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -8823,7 +8823,13 @@ namespace ts { let targetStack: Type[]; let maybeCount = 0; let depth = 0; - let expandingFlags = 0; + const enum ExpandingFlags { + None = 0, + Source = 1, + Target = 1 << 1, + Both = Source | Target, + } + let expandingFlags = ExpandingFlags.None; let overflow = false; let isIntersectionConstituent = false; @@ -9240,9 +9246,9 @@ namespace ts { targetStack[depth] = target; depth++; const saveExpandingFlags = expandingFlags; - if (!(expandingFlags & 1) && isDeeplyNestedType(source, sourceStack, depth)) expandingFlags |= 1; - if (!(expandingFlags & 2) && isDeeplyNestedType(target, targetStack, depth)) expandingFlags |= 2; - const result = expandingFlags !== 3 ? structuredTypeRelatedTo(source, target, reportErrors) : Ternary.Maybe; + if (!(expandingFlags & ExpandingFlags.Source) && isDeeplyNestedType(source, sourceStack, depth)) expandingFlags |= ExpandingFlags.Source; + if (!(expandingFlags & ExpandingFlags.Target) && isDeeplyNestedType(target, targetStack, depth)) expandingFlags |= ExpandingFlags.Target; + const result = expandingFlags !== ExpandingFlags.Both ? structuredTypeRelatedTo(source, target, reportErrors) : Ternary.Maybe; expandingFlags = saveExpandingFlags; depth--; if (result) { From 0e2d399c493712289df4a22dea1817a060dc379d Mon Sep 17 00:00:00 2001 From: Ryan Cavanaugh Date: Tue, 29 Aug 2017 13:29:56 -0700 Subject: [PATCH 190/370] Don't crash when a JS file appears in an inferred context --- .../unittests/tsserverProjectSystem.ts | 28 +++++++++++++++++-- src/server/editorServices.ts | 2 +- src/services/documentRegistry.ts | 20 ++++++------- 3 files changed, 35 insertions(+), 15 deletions(-) diff --git a/src/harness/unittests/tsserverProjectSystem.ts b/src/harness/unittests/tsserverProjectSystem.ts index fa0eef12919..c9a74310977 100644 --- a/src/harness/unittests/tsserverProjectSystem.ts +++ b/src/harness/unittests/tsserverProjectSystem.ts @@ -1774,6 +1774,28 @@ namespace ts.projectSystem { checkProjectActualFiles(projectService.externalProjects[0], [file1.path, file2.path, file3.path]); }); + it("regression test for crash in acquireOrUpdateDocument", () => { + const tsFile = { + fileName: "/a/b/file1.ts", + path: "/a/b/file1.ts", + content: "" + }; + const jsFile = { + path: "/a/b/file1.js", + content: "var x = 10;", + fileName: "/a/b/file1.js", + scriptKind: "JS" as "JS" + }; + + const host = createServerHost([]); + const projectService = createProjectService(host); + projectService.applyChangesInOpenFiles([tsFile], [], []); + const projs = projectService.synchronizeProjectList([]); + projectService.findProject(projs[0].info.projectName).getLanguageService().getNavigationBarItems(tsFile.fileName); + projectService.synchronizeProjectList([projs[0].info]); + projectService.applyChangesInOpenFiles([jsFile], [], []); + }); + it("config file is deleted", () => { const file1 = { path: "/a/b/f1.ts", @@ -1874,7 +1896,7 @@ namespace ts.projectSystem { // Open HTML file projectService.applyChangesInOpenFiles( - /*openFiles*/ [{ fileName: file2.path, hasMixedContent: true, scriptKind: ScriptKind.JS, content: `var hello = "hello";` }], + /*openFiles*/[{ fileName: file2.path, hasMixedContent: true, scriptKind: ScriptKind.JS, content: `var hello = "hello";` }], /*changedFiles*/ undefined, /*closedFiles*/ undefined); @@ -1891,7 +1913,7 @@ namespace ts.projectSystem { projectService.applyChangesInOpenFiles( /*openFiles*/ undefined, /*changedFiles*/ undefined, - /*closedFiles*/ [file2.path]); + /*closedFiles*/[file2.path]); // HTML file is still included in project checkNumberOfProjects(projectService, { configuredProjects: 1 }); @@ -3322,7 +3344,7 @@ namespace ts.projectSystem { const error1Result = session.executeCommand(dTsFile1GetErrRequest).response; assert.isTrue(error1Result.length === 0); - const dTsFile2GetErrRequest = makeSessionRequest( + const dTsFile2GetErrRequest = makeSessionRequest( CommandNames.SemanticDiagnosticsSync, { file: dTsFile2.path } ); diff --git a/src/server/editorServices.ts b/src/server/editorServices.ts index 22a025ae68f..d849226a35b 100644 --- a/src/server/editorServices.ts +++ b/src/server/editorServices.ts @@ -1648,7 +1648,7 @@ namespace ts.server { if (openFiles) { for (const file of openFiles) { const scriptInfo = this.getScriptInfo(file.fileName); - Debug.assert(!scriptInfo || !scriptInfo.isScriptOpen()); + Debug.assert(!scriptInfo || !scriptInfo.isScriptOpen(), "Script should not exist and not be open already"); const normalizedPath = scriptInfo ? scriptInfo.fileName : toNormalizedPath(file.fileName); this.openClientFileWithNormalizedPath(normalizedPath, file.content, tryConvertScriptKindName(file.scriptKind), file.hasMixedContent); } diff --git a/src/services/documentRegistry.ts b/src/services/documentRegistry.ts index bc01f2a96a6..0c3d4d1cb48 100644 --- a/src/services/documentRegistry.ts +++ b/src/services/documentRegistry.ts @@ -173,14 +173,12 @@ namespace ts { const bucket = getBucketForCompilationSettings(key, /*createIfMissing*/ true); let entry = bucket.get(path); if (!entry) { - Debug.assert(acquiring, "How could we be trying to update a document that the registry doesn't have?"); - // Have never seen this file with these settings. Create a new source file for it. const sourceFile = createLanguageServiceSourceFile(fileName, scriptSnapshot, compilationSettings.target, version, /*setNodeParents*/ false, scriptKind); entry = { sourceFile, - languageServiceRefCount: 0, + languageServiceRefCount: 1, owners: [] }; bucket.set(path, entry); @@ -193,15 +191,15 @@ namespace ts { entry.sourceFile = updateLanguageServiceSourceFile(entry.sourceFile, scriptSnapshot, version, scriptSnapshot.getChangeRange(entry.sourceFile.scriptSnapshot)); } - } - // If we're acquiring, then this is the first time this LS is asking for this document. - // Increase our ref count so we know there's another LS using the document. If we're - // not acquiring, then that means the LS is 'updating' the file instead, and that means - // it has already acquired the document previously. As such, we do not need to increase - // the ref count. - if (acquiring) { - entry.languageServiceRefCount++; + // If we're acquiring, then this is the first time this LS is asking for this document. + // Increase our ref count so we know there's another LS using the document. If we're + // not acquiring, then that means the LS is 'updating' the file instead, and that means + // it has already acquired the document previously. As such, we do not need to increase + // the ref count. + if (acquiring) { + entry.languageServiceRefCount++; + } } return entry.sourceFile; From 19c3a150e747fd9ecc01a122fc752510abb4c4db Mon Sep 17 00:00:00 2001 From: Andrew Casey Date: Tue, 29 Aug 2017 13:24:13 -0700 Subject: [PATCH 191/370] Allow cancellation during extract method's symbol walking --- src/services/refactors/extractMethod.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/services/refactors/extractMethod.ts b/src/services/refactors/extractMethod.ts index 5e1a96aa1fb..66ab0126aaa 100644 --- a/src/services/refactors/extractMethod.ts +++ b/src/services/refactors/extractMethod.ts @@ -531,7 +531,8 @@ namespace ts.refactor.extractMethod { scopes, enclosingTextRange, sourceFile, - context.program.getTypeChecker()); + context.program.getTypeChecker(), + context.cancellationToken); context.cancellationToken.throwIfCancellationRequested(); @@ -932,7 +933,8 @@ namespace ts.refactor.extractMethod { scopes: Scope[], enclosingTextRange: TextRange, sourceFile: SourceFile, - checker: TypeChecker) { + checker: TypeChecker, + cancellationToken: CancellationToken) { const allTypeParameterUsages = createMap(); // Key is type ID const usagesPerScope: ScopeUsages[] = []; @@ -1045,7 +1047,7 @@ namespace ts.refactor.extractMethod { // PERF: This is potentially very expensive. `type` could be a library type with // a lot of properties, each of which the walker will visit. Unfortunately, the // solution isn't as trivial as filtering to user types because of (e.g.) Array. - const symbolWalker = checker.getSymbolWalker(); + const symbolWalker = checker.getSymbolWalker(() => (cancellationToken.throwIfCancellationRequested(), true)); const {visitedTypes} = symbolWalker.walkType(type); for (const visitedType of visitedTypes) { From 3f090114fff2473e9b2ec8e340e7b3dba93266bd Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Wed, 30 Aug 2017 09:44:51 -0700 Subject: [PATCH 192/370] Optimize array operations to reduce memory footprint --- src/compiler/binder.ts | 6 ++- src/compiler/parser.ts | 114 +++++++++++++++++------------------------ 2 files changed, 51 insertions(+), 69 deletions(-) diff --git a/src/compiler/binder.ts b/src/compiler/binder.ts index a7e94da09d9..67782ece962 100644 --- a/src/compiler/binder.ts +++ b/src/compiler/binder.ts @@ -203,9 +203,11 @@ namespace ts { node.symbol = symbol; if (!symbol.declarations) { - symbol.declarations = []; + symbol.declarations = [node]; + } + else { + symbol.declarations.push(node); } - symbol.declarations.push(node); if (symbolFlags & SymbolFlags.HasExports && !symbol.exports) { symbol.exports = createSymbolTable(); diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index 7486c7541be..bf066b6143e 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -940,10 +940,6 @@ namespace ts { return scanner.getStartPos(); } - function getNodeEnd(): number { - return scanner.getStartPos(); - } - // Use this function to access the current token instead of reading the currentToken // variable. Since function results aren't narrowed in control flow analysis, this ensures // that the type checker doesn't make wrong assumptions about the type of the current @@ -1135,13 +1131,14 @@ namespace ts { new TokenConstructor(kind, pos, pos); } - function createNodeArray(elements?: T[], pos?: number): MutableNodeArray { - const array = >(elements || []); - if (!(pos >= 0)) { - pos = getNodePos(); - } + function createNodeArray(elements: T[], pos: number, end?: number): NodeArray { + // Since the element list of a node array is typically created by starting with an empty array and + // repeatedly calling push(), the list may not have the optimal memory layout. We invoke slice() for + // small arrays (1 to 4 elements) to give the VM a chance to allocate an optimal representation. + const length = elements.length; + const array = >(length >= 1 && length <= 4 ? elements.slice() : elements); array.pos = pos; - array.end = pos; + array.end = end === undefined ? scanner.getStartPos() : end; return array; } @@ -1527,12 +1524,13 @@ namespace ts { function parseList(kind: ParsingContext, parseElement: () => T): NodeArray { const saveParsingContext = parsingContext; parsingContext |= 1 << kind; - const result = createNodeArray(); + const list = []; + const listPos = getNodePos(); while (!isListTerminator(kind)) { if (isListElement(kind, /*inErrorRecovery*/ false)) { const element = parseListElement(kind, parseElement); - result.push(element); + list.push(element); continue; } @@ -1542,9 +1540,8 @@ namespace ts { } } - result.end = getNodeEnd(); parsingContext = saveParsingContext; - return result; + return createNodeArray(list, listPos); } function parseListElement(parsingContext: ParsingContext, parseElement: () => T): T { @@ -1874,13 +1871,14 @@ namespace ts { function parseDelimitedList(kind: ParsingContext, parseElement: () => T, considerSemicolonAsDelimiter?: boolean): NodeArray { const saveParsingContext = parsingContext; parsingContext |= 1 << kind; - const result = createNodeArray(); + const list = []; + const listPos = getNodePos(); let commaStart = -1; // Meaning the previous token was not a comma while (true) { if (isListElement(kind, /*inErrorRecovery*/ false)) { const startPos = scanner.getStartPos(); - result.push(parseListElement(kind, parseElement)); + list.push(parseListElement(kind, parseElement)); commaStart = scanner.getTokenPos(); if (parseOptional(SyntaxKind.CommaToken)) { @@ -1924,6 +1922,8 @@ namespace ts { } } + parsingContext = saveParsingContext; + const result = createNodeArray(list, listPos); // Recording the trailing comma is deliberately done after the previous // loop, and not just if we see a list terminator. This is because the list // may have ended incorrectly, but it is still important to know if there @@ -1933,14 +1933,11 @@ namespace ts { // Always preserve a trailing comma by marking it on the NodeArray result.hasTrailingComma = true; } - - result.end = getNodeEnd(); - parsingContext = saveParsingContext; return result; } function createMissingList(): NodeArray { - return createNodeArray(); + return createNodeArray([], getNodePos()); } function parseBracketedList(kind: ParsingContext, parseElement: () => T, open: SyntaxKind, close: SyntaxKind): NodeArray { @@ -2015,15 +2012,15 @@ namespace ts { template.head = parseTemplateHead(); Debug.assert(template.head.kind === SyntaxKind.TemplateHead, "Template head has wrong token kind"); - const templateSpans = createNodeArray(); + const list = []; + const listPos = getNodePos(); do { - templateSpans.push(parseTemplateSpan()); + list.push(parseTemplateSpan()); } - while (lastOrUndefined(templateSpans).literal.kind === SyntaxKind.TemplateMiddle); + while (lastOrUndefined(list).literal.kind === SyntaxKind.TemplateMiddle); - templateSpans.end = getNodeEnd(); - template.templateSpans = templateSpans; + template.templateSpans = createNodeArray(list, listPos); return finishNode(template); } @@ -2802,13 +2799,12 @@ namespace ts { parseOptional(operator); let type = parseConstituentType(); if (token() === operator) { - const types = createNodeArray([type], type.pos); + const types = [type]; while (parseOptional(operator)) { types.push(parseConstituentType()); } - types.end = getNodeEnd(); const node = createNode(kind, type.pos); - node.types = types; + node.types = createNodeArray(types, type.pos); type = finishNode(node); } return type; @@ -3174,8 +3170,7 @@ namespace ts { parameter.name = identifier; finishNode(parameter); - node.parameters = createNodeArray([parameter], parameter.pos); - node.parameters.end = parameter.end; + node.parameters = createNodeArray([parameter], parameter.pos, parameter.end); node.equalsGreaterThanToken = parseExpectedToken(SyntaxKind.EqualsGreaterThanToken, /*reportAtCurrentPosition*/ false, Diagnostics._0_expected, "=>"); node.body = parseArrowFunctionExpressionBody(/*isAsync*/ !!asyncModifier); @@ -4025,7 +4020,8 @@ namespace ts { } function parseJsxChildren(openingTagName: LeftHandSideExpression): NodeArray { - const result = createNodeArray(); + const list = []; + const listPos = getNodePos(); const saveParsingContext = parsingContext; parsingContext |= 1 << ParsingContext.JsxChildren; @@ -4046,15 +4042,13 @@ namespace ts { } const child = parseJsxChild(); if (child) { - result.push(child); + list.push(child); } } - result.end = scanner.getTokenPos(); - parsingContext = saveParsingContext; - return result; + return createNodeArray(list, listPos); } function parseJsxAttributes(): JsxAttributes { @@ -5447,27 +5441,19 @@ namespace ts { } function parseDecorators(): NodeArray { - let decorators: NodeArray & Decorator[]; + let list: Decorator[]; + const listPos = getNodePos(); while (true) { const decoratorStart = getNodePos(); if (!parseOptional(SyntaxKind.AtToken)) { break; } - const decorator = createNode(SyntaxKind.Decorator, decoratorStart); decorator.expression = doInDecoratorContext(parseLeftHandSideExpressionOrHigher); finishNode(decorator); - if (!decorators) { - decorators = createNodeArray([decorator], decoratorStart); - } - else { - decorators.push(decorator); - } + (list || (list = [])).push(decorator); } - if (decorators) { - decorators.end = getNodeEnd(); - } - return decorators; + return list && createNodeArray(list, listPos); } /* @@ -5478,7 +5464,8 @@ namespace ts { * In such situations, 'permitInvalidConstAsModifier' should be set to true. */ function parseModifiers(permitInvalidConstAsModifier?: boolean): NodeArray | undefined { - let modifiers: MutableNodeArray | undefined; + let list: Modifier[]; + const listPos = getNodePos(); while (true) { const modifierStart = scanner.getStartPos(); const modifierKind = token(); @@ -5497,17 +5484,9 @@ namespace ts { } const modifier = finishNode(createNode(modifierKind, modifierStart)); - if (!modifiers) { - modifiers = createNodeArray([modifier], modifierStart); - } - else { - modifiers.push(modifier); - } + (list || (list = [])).push(modifier); } - if (modifiers) { - modifiers.end = scanner.getStartPos(); - } - return modifiers; + return list && createNodeArray(list, listPos); } function parseModifiersForArrowFunction(): NodeArray { @@ -5518,9 +5497,7 @@ namespace ts { nextToken(); const modifier = finishNode(createNode(modifierKind, modifierStart)); modifiers = createNodeArray([modifier], modifierStart); - modifiers.end = scanner.getStartPos(); } - return modifiers; } @@ -6222,7 +6199,9 @@ namespace ts { Debug.assert(start <= end); Debug.assert(end <= content.length); - let tags: MutableNodeArray; + let tags: JSDocTag[]; + let tagsPos: number; + let tagsEnd: number; const comments: string[] = []; let result: JSDoc; @@ -6355,7 +6334,7 @@ namespace ts { function createJSDocComment(): JSDoc { const result = createNode(SyntaxKind.JSDocComment, start); - result.tags = tags; + result.tags = tags && createNodeArray(tags, tagsPos, tagsEnd); result.comment = comments.length ? comments.join("") : undefined; return finishNode(result, end); } @@ -6495,12 +6474,13 @@ namespace ts { tag.comment = comments.join(""); if (!tags) { - tags = createNodeArray([tag], tag.pos); + tags = [tag]; + tagsPos = tag.pos; } else { tags.push(tag); } - tags.end = tag.end; + tagsEnd = tag.end; } function tryParseTypeExpression(): JSDocTypeExpression | undefined { @@ -6800,7 +6780,8 @@ namespace ts { } // Type parameter list looks like '@template T,U,V' - const typeParameters = createNodeArray(); + const typeParameters = []; + const typeParametersPos = getNodePos(); while (true) { const name = parseJSDocIdentifierName(); @@ -6828,9 +6809,8 @@ namespace ts { const result = createNode(SyntaxKind.JSDocTemplateTag, atToken.pos); result.atToken = atToken; result.tagName = tagName; - result.typeParameters = typeParameters; + result.typeParameters = createNodeArray(typeParameters, typeParametersPos); finishNode(result); - typeParameters.end = result.end; return result; } From 2b4b629f9bfaad5275aed844491a1498efa9e3cd Mon Sep 17 00:00:00 2001 From: Andy Date: Wed, 30 Aug 2017 10:02:30 -0700 Subject: [PATCH 193/370] Remove `largeSource` argument to `convertMap.fromSource` (#18098) --- Gulpfile.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gulpfile.ts b/Gulpfile.ts index 4a03557270f..a3db20dfd8a 100644 --- a/Gulpfile.ts +++ b/Gulpfile.ts @@ -786,7 +786,7 @@ gulp.task("browserify", "Runs browserify on run.js to produce a file suitable fo const file = new Vinyl({ contents, path: bundlePath }); console.log(`Fixing sourcemaps for ${file.path}`); // assumes contents is a Buffer, since that's what browserify yields - const maps = convertMap.fromSource(stringContent, /*largeSource*/ true).toObject(); + const maps = convertMap.fromSource(stringContent).toObject(); delete maps.sourceRoot; maps.sources = maps.sources.map(s => path.resolve(s === "_stream_0.js" ? "built/local/_stream_0.js" : s)); // Strip browserify's inline comments away (could probably just let sorcery do this, but then we couldn't fix the paths) From 562abf333a00ccda97b58c779c88594b86ea4a36 Mon Sep 17 00:00:00 2001 From: Mohamed Hegazy Date: Wed, 30 Aug 2017 10:22:02 -0700 Subject: [PATCH 194/370] Follow up on #16223 cleaning up Array declarations (#18116) * Follow up on #16223, Remove generic signatures from Array, ReadOnlyArray and TypedArrays * Remove test * Accept baselines * Remove invalid `this: void` in callbacks * accept baselines --- src/lib/es2015.core.d.ts | 27 +- src/lib/es2015.iterable.d.ts | 64 +- src/lib/es5.d.ts | 18 +- ...ibrary_NoErrorDuplicateLibOptions1.symbols | 4 +- ...eLibrary_NoErrorDuplicateLibOptions1.types | 4 +- ...ibrary_NoErrorDuplicateLibOptions2.symbols | 4 +- ...eLibrary_NoErrorDuplicateLibOptions2.types | 4 +- ...larizeLibrary_TargetES5UsingES6Lib.symbols | 4 +- ...dularizeLibrary_TargetES5UsingES6Lib.types | 4 +- ...larizeLibrary_TargetES6UsingES6Lib.symbols | 4 +- ...dularizeLibrary_TargetES6UsingES6Lib.types | 4 +- ...eLibrary_UsingES5LibAndES6ArrayLib.symbols | 4 +- ...izeLibrary_UsingES5LibAndES6ArrayLib.types | 4 +- ...ibES6ArrayLibES6WellknownSymbolLib.symbols | 4 +- ...5LibES6ArrayLibES6WellknownSymbolLib.types | 4 +- .../thisTypeInNativeThisAssignableMethods.js | 709 ------ ...sTypeInNativeThisAssignableMethods.symbols | 1380 ------------ ...hisTypeInNativeThisAssignableMethods.types | 1931 ----------------- tests/baselines/reference/typedArrays.symbols | 144 +- tests/baselines/reference/typedArrays.types | 144 +- .../thisTypeInNativeThisAssignableMethods.ts | 398 ---- 21 files changed, 192 insertions(+), 4671 deletions(-) delete mode 100644 tests/baselines/reference/thisTypeInNativeThisAssignableMethods.js delete mode 100644 tests/baselines/reference/thisTypeInNativeThisAssignableMethods.symbols delete mode 100644 tests/baselines/reference/thisTypeInNativeThisAssignableMethods.types delete mode 100644 tests/cases/compiler/thisTypeInNativeThisAssignableMethods.ts diff --git a/src/lib/es2015.core.d.ts b/src/lib/es2015.core.d.ts index 9c84fc259c7..0deef59a47d 100644 --- a/src/lib/es2015.core.d.ts +++ b/src/lib/es2015.core.d.ts @@ -10,9 +10,7 @@ interface Array { * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - find(predicate: (this: void, value: T, index: number, obj: Array) => boolean): T | undefined; - find(predicate: (this: void, value: T, index: number, obj: Array) => boolean, thisArg: undefined): T | undefined; - find(predicate: (this: Z, value: T, index: number, obj: Array) => boolean, thisArg: Z): T | undefined; + find(predicate: (value: T, index: number, obj: Array) => boolean, thisArg?: any): T | undefined; /** * Returns the index of the first element in the array where predicate is true, and -1 @@ -23,9 +21,7 @@ interface Array { * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - findIndex(predicate: (this: void, value: T, index: number, obj: Array) => boolean): number; - findIndex(predicate: (this: void, value: T, index: number, obj: Array) => boolean, thisArg: undefined): number; - findIndex(predicate: (this: Z, value: T, index: number, obj: Array) => boolean, thisArg: Z): number; + findIndex(predicate: (value: T, index: number, obj: Array) => boolean, thisArg?: any): number; /** * Returns the this object after filling the section identified by start and end with value @@ -56,16 +52,7 @@ interface ArrayConstructor { * @param mapfn A mapping function to call on every element of the array. * @param thisArg Value of 'this' used to invoke the mapfn. */ - from(arrayLike: ArrayLike, mapfn: (this: void, v: T, k: number) => U): Array; - from(arrayLike: ArrayLike, mapfn: (this: void, v: T, k: number) => U, thisArg: undefined): Array; - from(arrayLike: ArrayLike, mapfn: (this: Z, v: T, k: number) => U, thisArg: Z): Array; - - - /** - * Creates an array from an array-like object. - * @param arrayLike An array-like object to convert to an array. - */ - from(arrayLike: ArrayLike): Array; + from(arrayLike: ArrayLike, mapfn?: (v: T, k: number) => U, thisArg?: any): Array; /** * Returns a new array from a set of elements. @@ -363,9 +350,7 @@ interface ReadonlyArray { * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - find(predicate: (this: void, value: T, index: number, obj: ReadonlyArray) => boolean): T | undefined; - find(predicate: (this: void, value: T, index: number, obj: ReadonlyArray) => boolean, thisArg: undefined): T | undefined; - find(predicate: (this: Z, value: T, index: number, obj: ReadonlyArray) => boolean, thisArg: Z): T | undefined; + find(predicate: (value: T, index: number, obj: ReadonlyArray) => boolean, thisArg?: any): T | undefined; /** * Returns the index of the first element in the array where predicate is true, and -1 @@ -376,9 +361,7 @@ interface ReadonlyArray { * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - findIndex(predicate: (this: void, value: T, index: number, obj: Array) => boolean): number; - findIndex(predicate: (this: void, value: T, index: number, obj: Array) => boolean, thisArg: undefined): number; - findIndex(predicate: (this: Z, value: T, index: number, obj: Array) => boolean, thisArg: Z): number; + findIndex(predicate: (value: T, index: number, obj: ReadonlyArray) => boolean, thisArg?: any): number; } interface RegExp { diff --git a/src/lib/es2015.iterable.d.ts b/src/lib/es2015.iterable.d.ts index 049b1898b9b..23e23510d3c 100644 --- a/src/lib/es2015.iterable.d.ts +++ b/src/lib/es2015.iterable.d.ts @@ -54,15 +54,7 @@ interface ArrayConstructor { * @param mapfn A mapping function to call on every element of the array. * @param thisArg Value of 'this' used to invoke the mapfn. */ - from(iterable: Iterable, mapfn: (this: void, v: T, k: number) => U): Array; - from(iterable: Iterable, mapfn: (this: void, v: T, k: number) => U, thisArg: undefined): Array; - from(iterable: Iterable, mapfn: (this: Z, v: T, k: number) => U, thisArg: Z): Array; - - /** - * Creates an array from an iterable object. - * @param iterable An iterable object to convert to an array. - */ - from(iterable: Iterable): Array; + from(iterable: Iterable, mapfn?: (v: T, k: number) => U, thisArg?: any): Array; } interface ReadonlyArray { @@ -246,11 +238,7 @@ interface Int8ArrayConstructor { * @param mapfn A mapping function to call on every element of the array. * @param thisArg Value of 'this' used to invoke the mapfn. */ - from(arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Int8Array; - from(arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Int8Array; - from(arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Int8Array; - - from(arrayLike: Iterable): Int8Array; + from(arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int8Array; } /** @@ -282,11 +270,7 @@ interface Uint8ArrayConstructor { * @param mapfn A mapping function to call on every element of the array. * @param thisArg Value of 'this' used to invoke the mapfn. */ - from(arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Uint8Array; - from(arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Uint8Array; - from(arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint8Array; - - from(arrayLike: Iterable): Uint8Array; + from(arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8Array; } /** @@ -321,11 +305,7 @@ interface Uint8ClampedArrayConstructor { * @param mapfn A mapping function to call on every element of the array. * @param thisArg Value of 'this' used to invoke the mapfn. */ - from(arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Uint8ClampedArray; - from(arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Uint8ClampedArray; - from(arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint8ClampedArray; - - from(arrayLike: Iterable): Uint8ClampedArray; + from(arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8ClampedArray; } /** @@ -359,11 +339,7 @@ interface Int16ArrayConstructor { * @param mapfn A mapping function to call on every element of the array. * @param thisArg Value of 'this' used to invoke the mapfn. */ - from(arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Int16Array; - from(arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Int16Array; - from(arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Int16Array; - - from(arrayLike: Iterable): Int16Array; + from(arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int16Array; } /** @@ -395,11 +371,7 @@ interface Uint16ArrayConstructor { * @param mapfn A mapping function to call on every element of the array. * @param thisArg Value of 'this' used to invoke the mapfn. */ - from(arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Uint16Array; - from(arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Uint16Array; - from(arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint16Array; - - from(arrayLike: Iterable): Uint16Array; + from(arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint16Array; } /** @@ -431,11 +403,7 @@ interface Int32ArrayConstructor { * @param mapfn A mapping function to call on every element of the array. * @param thisArg Value of 'this' used to invoke the mapfn. */ - from(arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Int32Array; - from(arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Int32Array; - from(arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Int32Array; - - from(arrayLike: Iterable): Int32Array; + from(arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int32Array; } /** @@ -467,11 +435,7 @@ interface Uint32ArrayConstructor { * @param mapfn A mapping function to call on every element of the array. * @param thisArg Value of 'this' used to invoke the mapfn. */ - from(arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Uint32Array; - from(arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Uint32Array; - from(arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint32Array; - - from(arrayLike: Iterable): Uint32Array; + from(arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint32Array; } /** @@ -503,11 +467,7 @@ interface Float32ArrayConstructor { * @param mapfn A mapping function to call on every element of the array. * @param thisArg Value of 'this' used to invoke the mapfn. */ - from(arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Float32Array; - from(arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Float32Array; - from(arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Float32Array; - - from(arrayLike: Iterable): Float32Array; + from(arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Float32Array; } /** @@ -539,9 +499,5 @@ interface Float64ArrayConstructor { * @param mapfn A mapping function to call on every element of the array. * @param thisArg Value of 'this' used to invoke the mapfn. */ - from(arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Float64Array; - from(arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Float64Array; - from(arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Float64Array; - - from(arrayLike: Iterable): Float64Array; + from(arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Float64Array; } diff --git a/src/lib/es5.d.ts b/src/lib/es5.d.ts index 32fb2f55b4d..4dae997ffb4 100644 --- a/src/lib/es5.d.ts +++ b/src/lib/es5.d.ts @@ -1635,7 +1635,7 @@ interface Int8Array { * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ - map(callbackfn: (this: void, value: number, index: number, array: Int8Array) => number, thisArg?: any): Int8Array; + map(callbackfn: (value: number, index: number, array: Int8Array) => number, thisArg?: any): Int8Array; /** * Calls the specified callback function for all the elements in an array. The return value of @@ -1902,7 +1902,7 @@ interface Uint8Array { * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ - map(callbackfn: (this: void, value: number, index: number, array: Uint8Array) => number, thisArg?: any): Uint8Array; + map(callbackfn: (value: number, index: number, array: Uint8Array) => number, thisArg?: any): Uint8Array; /** * Calls the specified callback function for all the elements in an array. The return value of @@ -2169,7 +2169,7 @@ interface Uint8ClampedArray { * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ - map(callbackfn: (this: void, value: number, index: number, array: Uint8ClampedArray) => number, thisArg?: any): Uint8ClampedArray; + map(callbackfn: (value: number, index: number, array: Uint8ClampedArray) => number, thisArg?: any): Uint8ClampedArray; /** * Calls the specified callback function for all the elements in an array. The return value of @@ -2366,7 +2366,7 @@ interface Int16Array { * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ - filter(callbackfn: (this: void, value: number, index: number, array: Int16Array) => any, thisArg?: any): Int16Array; + filter(callbackfn: (value: number, index: number, array: Int16Array) => any, thisArg?: any): Int16Array; /** * Returns the value of the first element in the array where predicate is true, and undefined @@ -2434,7 +2434,7 @@ interface Int16Array { * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ - map(callbackfn: (this: void, value: number, index: number, array: Int16Array) => number, thisArg?: any): Int16Array; + map(callbackfn: (value: number, index: number, array: Int16Array) => number, thisArg?: any): Int16Array; /** * Calls the specified callback function for all the elements in an array. The return value of @@ -2702,7 +2702,7 @@ interface Uint16Array { * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ - map(callbackfn: (this: void, value: number, index: number, array: Uint16Array) => number, thisArg?: any): Uint16Array; + map(callbackfn: (value: number, index: number, array: Uint16Array) => number, thisArg?: any): Uint16Array; /** * Calls the specified callback function for all the elements in an array. The return value of @@ -3235,7 +3235,7 @@ interface Uint32Array { * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ - map(callbackfn: (this: void, value: number, index: number, array: Uint32Array) => number, thisArg?: any): Uint32Array; + map(callbackfn: (value: number, index: number, array: Uint32Array) => number, thisArg?: any): Uint32Array; /** * Calls the specified callback function for all the elements in an array. The return value of @@ -3502,7 +3502,7 @@ interface Float32Array { * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ - map(callbackfn: (this: void, value: number, index: number, array: Float32Array) => number, thisArg?: any): Float32Array; + map(callbackfn: (value: number, index: number, array: Float32Array) => number, thisArg?: any): Float32Array; /** * Calls the specified callback function for all the elements in an array. The return value of @@ -3770,7 +3770,7 @@ interface Float64Array { * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ - map(callbackfn: (this: void, value: number, index: number, array: Float64Array) => number, thisArg?: any): Float64Array; + map(callbackfn: (value: number, index: number, array: Float64Array) => number, thisArg?: any): Float64Array; /** * Calls the specified callback function for all the elements in an array. The return value of diff --git a/tests/baselines/reference/modularizeLibrary_NoErrorDuplicateLibOptions1.symbols b/tests/baselines/reference/modularizeLibrary_NoErrorDuplicateLibOptions1.symbols index 52efbf5805d..6842ec9ae25 100644 --- a/tests/baselines/reference/modularizeLibrary_NoErrorDuplicateLibOptions1.symbols +++ b/tests/baselines/reference/modularizeLibrary_NoErrorDuplicateLibOptions1.symbols @@ -7,9 +7,9 @@ function f(x: number, y: number, z: number) { >z : Symbol(z, Decl(modularizeLibrary_NoErrorDuplicateLibOptions1.ts, 1, 32)) return Array.from(arguments); ->Array.from : Symbol(ArrayConstructor.from, Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --)) +>Array.from : Symbol(ArrayConstructor.from, Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --)) >Array : Symbol(Array, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) ->from : Symbol(ArrayConstructor.from, Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --)) +>from : Symbol(ArrayConstructor.from, Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --)) >arguments : Symbol(arguments) } diff --git a/tests/baselines/reference/modularizeLibrary_NoErrorDuplicateLibOptions1.types b/tests/baselines/reference/modularizeLibrary_NoErrorDuplicateLibOptions1.types index a77fcd223f4..4743391fcf1 100644 --- a/tests/baselines/reference/modularizeLibrary_NoErrorDuplicateLibOptions1.types +++ b/tests/baselines/reference/modularizeLibrary_NoErrorDuplicateLibOptions1.types @@ -8,9 +8,9 @@ function f(x: number, y: number, z: number) { return Array.from(arguments); >Array.from(arguments) : any[] ->Array.from : { (iterable: Iterable, mapfn: (this: void, v: T, k: number) => U): U[]; (iterable: Iterable, mapfn: (this: void, v: T, k: number) => U, thisArg: undefined): U[]; (iterable: Iterable, mapfn: (this: Z, v: T, k: number) => U, thisArg: Z): U[]; (iterable: Iterable): T[]; (arrayLike: ArrayLike, mapfn: (this: void, v: T, k: number) => U): U[]; (arrayLike: ArrayLike, mapfn: (this: void, v: T, k: number) => U, thisArg: undefined): U[]; (arrayLike: ArrayLike, mapfn: (this: Z, v: T, k: number) => U, thisArg: Z): U[]; (arrayLike: ArrayLike): T[]; } +>Array.from : { (iterable: Iterable, mapfn?: (v: T, k: number) => U, thisArg?: any): U[]; (arrayLike: ArrayLike, mapfn?: (v: T, k: number) => U, thisArg?: any): U[]; } >Array : ArrayConstructor ->from : { (iterable: Iterable, mapfn: (this: void, v: T, k: number) => U): U[]; (iterable: Iterable, mapfn: (this: void, v: T, k: number) => U, thisArg: undefined): U[]; (iterable: Iterable, mapfn: (this: Z, v: T, k: number) => U, thisArg: Z): U[]; (iterable: Iterable): T[]; (arrayLike: ArrayLike, mapfn: (this: void, v: T, k: number) => U): U[]; (arrayLike: ArrayLike, mapfn: (this: void, v: T, k: number) => U, thisArg: undefined): U[]; (arrayLike: ArrayLike, mapfn: (this: Z, v: T, k: number) => U, thisArg: Z): U[]; (arrayLike: ArrayLike): T[]; } +>from : { (iterable: Iterable, mapfn?: (v: T, k: number) => U, thisArg?: any): U[]; (arrayLike: ArrayLike, mapfn?: (v: T, k: number) => U, thisArg?: any): U[]; } >arguments : IArguments } diff --git a/tests/baselines/reference/modularizeLibrary_NoErrorDuplicateLibOptions2.symbols b/tests/baselines/reference/modularizeLibrary_NoErrorDuplicateLibOptions2.symbols index 4bdffff4f41..d9af41e6027 100644 --- a/tests/baselines/reference/modularizeLibrary_NoErrorDuplicateLibOptions2.symbols +++ b/tests/baselines/reference/modularizeLibrary_NoErrorDuplicateLibOptions2.symbols @@ -7,9 +7,9 @@ function f(x: number, y: number, z: number) { >z : Symbol(z, Decl(modularizeLibrary_NoErrorDuplicateLibOptions2.ts, 1, 32)) return Array.from(arguments); ->Array.from : Symbol(ArrayConstructor.from, Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --)) +>Array.from : Symbol(ArrayConstructor.from, Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --)) >Array : Symbol(Array, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) ->from : Symbol(ArrayConstructor.from, Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --)) +>from : Symbol(ArrayConstructor.from, Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --)) >arguments : Symbol(arguments) } diff --git a/tests/baselines/reference/modularizeLibrary_NoErrorDuplicateLibOptions2.types b/tests/baselines/reference/modularizeLibrary_NoErrorDuplicateLibOptions2.types index 6d5770659de..a700c1c03f6 100644 --- a/tests/baselines/reference/modularizeLibrary_NoErrorDuplicateLibOptions2.types +++ b/tests/baselines/reference/modularizeLibrary_NoErrorDuplicateLibOptions2.types @@ -8,9 +8,9 @@ function f(x: number, y: number, z: number) { return Array.from(arguments); >Array.from(arguments) : any[] ->Array.from : { (iterable: Iterable, mapfn: (this: void, v: T, k: number) => U): U[]; (iterable: Iterable, mapfn: (this: void, v: T, k: number) => U, thisArg: undefined): U[]; (iterable: Iterable, mapfn: (this: Z, v: T, k: number) => U, thisArg: Z): U[]; (iterable: Iterable): T[]; (arrayLike: ArrayLike, mapfn: (this: void, v: T, k: number) => U): U[]; (arrayLike: ArrayLike, mapfn: (this: void, v: T, k: number) => U, thisArg: undefined): U[]; (arrayLike: ArrayLike, mapfn: (this: Z, v: T, k: number) => U, thisArg: Z): U[]; (arrayLike: ArrayLike): T[]; } +>Array.from : { (iterable: Iterable, mapfn?: (v: T, k: number) => U, thisArg?: any): U[]; (arrayLike: ArrayLike, mapfn?: (v: T, k: number) => U, thisArg?: any): U[]; } >Array : ArrayConstructor ->from : { (iterable: Iterable, mapfn: (this: void, v: T, k: number) => U): U[]; (iterable: Iterable, mapfn: (this: void, v: T, k: number) => U, thisArg: undefined): U[]; (iterable: Iterable, mapfn: (this: Z, v: T, k: number) => U, thisArg: Z): U[]; (iterable: Iterable): T[]; (arrayLike: ArrayLike, mapfn: (this: void, v: T, k: number) => U): U[]; (arrayLike: ArrayLike, mapfn: (this: void, v: T, k: number) => U, thisArg: undefined): U[]; (arrayLike: ArrayLike, mapfn: (this: Z, v: T, k: number) => U, thisArg: Z): U[]; (arrayLike: ArrayLike): T[]; } +>from : { (iterable: Iterable, mapfn?: (v: T, k: number) => U, thisArg?: any): U[]; (arrayLike: ArrayLike, mapfn?: (v: T, k: number) => U, thisArg?: any): U[]; } >arguments : IArguments } diff --git a/tests/baselines/reference/modularizeLibrary_TargetES5UsingES6Lib.symbols b/tests/baselines/reference/modularizeLibrary_TargetES5UsingES6Lib.symbols index fd9714416ff..2ae943ab81d 100644 --- a/tests/baselines/reference/modularizeLibrary_TargetES5UsingES6Lib.symbols +++ b/tests/baselines/reference/modularizeLibrary_TargetES5UsingES6Lib.symbols @@ -7,9 +7,9 @@ function f(x: number, y: number, z: number) { >z : Symbol(z, Decl(modularizeLibrary_TargetES5UsingES6Lib.ts, 1, 32)) return Array.from(arguments); ->Array.from : Symbol(ArrayConstructor.from, Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --)) +>Array.from : Symbol(ArrayConstructor.from, Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --)) >Array : Symbol(Array, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) ->from : Symbol(ArrayConstructor.from, Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --)) +>from : Symbol(ArrayConstructor.from, Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --)) >arguments : Symbol(arguments) } diff --git a/tests/baselines/reference/modularizeLibrary_TargetES5UsingES6Lib.types b/tests/baselines/reference/modularizeLibrary_TargetES5UsingES6Lib.types index 9ca65cb9583..d51e87c8b9d 100644 --- a/tests/baselines/reference/modularizeLibrary_TargetES5UsingES6Lib.types +++ b/tests/baselines/reference/modularizeLibrary_TargetES5UsingES6Lib.types @@ -8,9 +8,9 @@ function f(x: number, y: number, z: number) { return Array.from(arguments); >Array.from(arguments) : any[] ->Array.from : { (iterable: Iterable, mapfn: (this: void, v: T, k: number) => U): U[]; (iterable: Iterable, mapfn: (this: void, v: T, k: number) => U, thisArg: undefined): U[]; (iterable: Iterable, mapfn: (this: Z, v: T, k: number) => U, thisArg: Z): U[]; (iterable: Iterable): T[]; (arrayLike: ArrayLike, mapfn: (this: void, v: T, k: number) => U): U[]; (arrayLike: ArrayLike, mapfn: (this: void, v: T, k: number) => U, thisArg: undefined): U[]; (arrayLike: ArrayLike, mapfn: (this: Z, v: T, k: number) => U, thisArg: Z): U[]; (arrayLike: ArrayLike): T[]; } +>Array.from : { (iterable: Iterable, mapfn?: (v: T, k: number) => U, thisArg?: any): U[]; (arrayLike: ArrayLike, mapfn?: (v: T, k: number) => U, thisArg?: any): U[]; } >Array : ArrayConstructor ->from : { (iterable: Iterable, mapfn: (this: void, v: T, k: number) => U): U[]; (iterable: Iterable, mapfn: (this: void, v: T, k: number) => U, thisArg: undefined): U[]; (iterable: Iterable, mapfn: (this: Z, v: T, k: number) => U, thisArg: Z): U[]; (iterable: Iterable): T[]; (arrayLike: ArrayLike, mapfn: (this: void, v: T, k: number) => U): U[]; (arrayLike: ArrayLike, mapfn: (this: void, v: T, k: number) => U, thisArg: undefined): U[]; (arrayLike: ArrayLike, mapfn: (this: Z, v: T, k: number) => U, thisArg: Z): U[]; (arrayLike: ArrayLike): T[]; } +>from : { (iterable: Iterable, mapfn?: (v: T, k: number) => U, thisArg?: any): U[]; (arrayLike: ArrayLike, mapfn?: (v: T, k: number) => U, thisArg?: any): U[]; } >arguments : IArguments } diff --git a/tests/baselines/reference/modularizeLibrary_TargetES6UsingES6Lib.symbols b/tests/baselines/reference/modularizeLibrary_TargetES6UsingES6Lib.symbols index 42aa9ad1d87..182daeefd1a 100644 --- a/tests/baselines/reference/modularizeLibrary_TargetES6UsingES6Lib.symbols +++ b/tests/baselines/reference/modularizeLibrary_TargetES6UsingES6Lib.symbols @@ -7,9 +7,9 @@ function f(x: number, y: number, z: number) { >z : Symbol(z, Decl(modularizeLibrary_TargetES6UsingES6Lib.ts, 1, 32)) return Array.from(arguments); ->Array.from : Symbol(ArrayConstructor.from, Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --)) +>Array.from : Symbol(ArrayConstructor.from, Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --)) >Array : Symbol(Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --)) ->from : Symbol(ArrayConstructor.from, Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --)) +>from : Symbol(ArrayConstructor.from, Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --)) >arguments : Symbol(arguments) } diff --git a/tests/baselines/reference/modularizeLibrary_TargetES6UsingES6Lib.types b/tests/baselines/reference/modularizeLibrary_TargetES6UsingES6Lib.types index 1120b471f36..8296220b36e 100644 --- a/tests/baselines/reference/modularizeLibrary_TargetES6UsingES6Lib.types +++ b/tests/baselines/reference/modularizeLibrary_TargetES6UsingES6Lib.types @@ -8,9 +8,9 @@ function f(x: number, y: number, z: number) { return Array.from(arguments); >Array.from(arguments) : any[] ->Array.from : { (iterable: Iterable, mapfn: (this: void, v: T, k: number) => U): U[]; (iterable: Iterable, mapfn: (this: void, v: T, k: number) => U, thisArg: undefined): U[]; (iterable: Iterable, mapfn: (this: Z, v: T, k: number) => U, thisArg: Z): U[]; (iterable: Iterable): T[]; (arrayLike: ArrayLike, mapfn: (this: void, v: T, k: number) => U): U[]; (arrayLike: ArrayLike, mapfn: (this: void, v: T, k: number) => U, thisArg: undefined): U[]; (arrayLike: ArrayLike, mapfn: (this: Z, v: T, k: number) => U, thisArg: Z): U[]; (arrayLike: ArrayLike): T[]; } +>Array.from : { (iterable: Iterable, mapfn?: (v: T, k: number) => U, thisArg?: any): U[]; (arrayLike: ArrayLike, mapfn?: (v: T, k: number) => U, thisArg?: any): U[]; } >Array : ArrayConstructor ->from : { (iterable: Iterable, mapfn: (this: void, v: T, k: number) => U): U[]; (iterable: Iterable, mapfn: (this: void, v: T, k: number) => U, thisArg: undefined): U[]; (iterable: Iterable, mapfn: (this: Z, v: T, k: number) => U, thisArg: Z): U[]; (iterable: Iterable): T[]; (arrayLike: ArrayLike, mapfn: (this: void, v: T, k: number) => U): U[]; (arrayLike: ArrayLike, mapfn: (this: void, v: T, k: number) => U, thisArg: undefined): U[]; (arrayLike: ArrayLike, mapfn: (this: Z, v: T, k: number) => U, thisArg: Z): U[]; (arrayLike: ArrayLike): T[]; } +>from : { (iterable: Iterable, mapfn?: (v: T, k: number) => U, thisArg?: any): U[]; (arrayLike: ArrayLike, mapfn?: (v: T, k: number) => U, thisArg?: any): U[]; } >arguments : IArguments } diff --git a/tests/baselines/reference/modularizeLibrary_UsingES5LibAndES6ArrayLib.symbols b/tests/baselines/reference/modularizeLibrary_UsingES5LibAndES6ArrayLib.symbols index bac3a49930d..a9f94d2e1ca 100644 --- a/tests/baselines/reference/modularizeLibrary_UsingES5LibAndES6ArrayLib.symbols +++ b/tests/baselines/reference/modularizeLibrary_UsingES5LibAndES6ArrayLib.symbols @@ -7,9 +7,9 @@ function f(x: number, y: number, z: number) { >z : Symbol(z, Decl(modularizeLibrary_UsingES5LibAndES6ArrayLib.ts, 1, 32)) return Array.from(arguments); ->Array.from : Symbol(ArrayConstructor.from, Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --)) +>Array.from : Symbol(ArrayConstructor.from, Decl(lib.es2015.core.d.ts, --, --)) >Array : Symbol(Array, Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) ->from : Symbol(ArrayConstructor.from, Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --)) +>from : Symbol(ArrayConstructor.from, Decl(lib.es2015.core.d.ts, --, --)) >arguments : Symbol(arguments) } diff --git a/tests/baselines/reference/modularizeLibrary_UsingES5LibAndES6ArrayLib.types b/tests/baselines/reference/modularizeLibrary_UsingES5LibAndES6ArrayLib.types index 3c3905c501f..7a3d1a8c7c3 100644 --- a/tests/baselines/reference/modularizeLibrary_UsingES5LibAndES6ArrayLib.types +++ b/tests/baselines/reference/modularizeLibrary_UsingES5LibAndES6ArrayLib.types @@ -8,9 +8,9 @@ function f(x: number, y: number, z: number) { return Array.from(arguments); >Array.from(arguments) : any[] ->Array.from : { (arrayLike: ArrayLike, mapfn: (this: void, v: T, k: number) => U): U[]; (arrayLike: ArrayLike, mapfn: (this: void, v: T, k: number) => U, thisArg: undefined): U[]; (arrayLike: ArrayLike, mapfn: (this: Z, v: T, k: number) => U, thisArg: Z): U[]; (arrayLike: ArrayLike): T[]; } +>Array.from : (arrayLike: ArrayLike, mapfn?: (v: T, k: number) => U, thisArg?: any) => U[] >Array : ArrayConstructor ->from : { (arrayLike: ArrayLike, mapfn: (this: void, v: T, k: number) => U): U[]; (arrayLike: ArrayLike, mapfn: (this: void, v: T, k: number) => U, thisArg: undefined): U[]; (arrayLike: ArrayLike, mapfn: (this: Z, v: T, k: number) => U, thisArg: Z): U[]; (arrayLike: ArrayLike): T[]; } +>from : (arrayLike: ArrayLike, mapfn?: (v: T, k: number) => U, thisArg?: any) => U[] >arguments : IArguments } diff --git a/tests/baselines/reference/modularizeLibrary_UsingES5LibES6ArrayLibES6WellknownSymbolLib.symbols b/tests/baselines/reference/modularizeLibrary_UsingES5LibES6ArrayLibES6WellknownSymbolLib.symbols index d63c8e72e68..7870c6362d3 100644 --- a/tests/baselines/reference/modularizeLibrary_UsingES5LibES6ArrayLibES6WellknownSymbolLib.symbols +++ b/tests/baselines/reference/modularizeLibrary_UsingES5LibES6ArrayLibES6WellknownSymbolLib.symbols @@ -6,9 +6,9 @@ function f(x: number, y: number, z: number) { >z : Symbol(z, Decl(modularizeLibrary_UsingES5LibES6ArrayLibES6WellknownSymbolLib.ts, 0, 32)) return Array.from(arguments); ->Array.from : Symbol(ArrayConstructor.from, Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --)) +>Array.from : Symbol(ArrayConstructor.from, Decl(lib.es2015.core.d.ts, --, --)) >Array : Symbol(Array, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) ->from : Symbol(ArrayConstructor.from, Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --)) +>from : Symbol(ArrayConstructor.from, Decl(lib.es2015.core.d.ts, --, --)) >arguments : Symbol(arguments) } diff --git a/tests/baselines/reference/modularizeLibrary_UsingES5LibES6ArrayLibES6WellknownSymbolLib.types b/tests/baselines/reference/modularizeLibrary_UsingES5LibES6ArrayLibES6WellknownSymbolLib.types index 3d4ba12fa63..1012cbad340 100644 --- a/tests/baselines/reference/modularizeLibrary_UsingES5LibES6ArrayLibES6WellknownSymbolLib.types +++ b/tests/baselines/reference/modularizeLibrary_UsingES5LibES6ArrayLibES6WellknownSymbolLib.types @@ -7,9 +7,9 @@ function f(x: number, y: number, z: number) { return Array.from(arguments); >Array.from(arguments) : any[] ->Array.from : { (arrayLike: ArrayLike, mapfn: (this: void, v: T, k: number) => U): U[]; (arrayLike: ArrayLike, mapfn: (this: void, v: T, k: number) => U, thisArg: undefined): U[]; (arrayLike: ArrayLike, mapfn: (this: Z, v: T, k: number) => U, thisArg: Z): U[]; (arrayLike: ArrayLike): T[]; } +>Array.from : (arrayLike: ArrayLike, mapfn?: (v: T, k: number) => U, thisArg?: any) => U[] >Array : ArrayConstructor ->from : { (arrayLike: ArrayLike, mapfn: (this: void, v: T, k: number) => U): U[]; (arrayLike: ArrayLike, mapfn: (this: void, v: T, k: number) => U, thisArg: undefined): U[]; (arrayLike: ArrayLike, mapfn: (this: Z, v: T, k: number) => U, thisArg: Z): U[]; (arrayLike: ArrayLike): T[]; } +>from : (arrayLike: ArrayLike, mapfn?: (v: T, k: number) => U, thisArg?: any) => U[] >arguments : IArguments } diff --git a/tests/baselines/reference/thisTypeInNativeThisAssignableMethods.js b/tests/baselines/reference/thisTypeInNativeThisAssignableMethods.js deleted file mode 100644 index fc4e6d78253..00000000000 --- a/tests/baselines/reference/thisTypeInNativeThisAssignableMethods.js +++ /dev/null @@ -1,709 +0,0 @@ -//// [thisTypeInNativeThisAssignableMethods.ts] -class A { - options: string[]; - - addOptions(options: string[]) { - if (!this.options) { - this.options = []; - } - options.forEach(function (item) { - this.options.push(item); - }, this); - return this; - } - - testUndefined(options: string[]) { - const undefinedArr: Array = [] - options.forEach(function () { - undefinedArr.push(this); - }); // case1 - options.forEach(function () { - undefinedArr.push(this); - }, undefined); // case2 - options.forEach(function () { - undefinedArr.push(this); - }, null); // case3 - - const arrLike = {} as ArrayLike - Array.from(arrLike, function (item) { - return this === undefined ? 2 : 1; - }, undefined) - - const iterLike = [] as Iterable - Array.from(iterLike, function (item) { - return this === undefined ? 2 : 1; - }, undefined) - } - - test(options: string[]) { - const thisObject = { - options: [] as string[] - }; - - options.find(function (val, index) { - return val === this.options[index]; - }, thisObject); - - options.findIndex(function (val, index) { - return val === this.options[index]; - }, thisObject); - - options.forEach(function (val, index) { - return val === this.options[index]; - }, thisObject); - - options.map(function (val, index) { - if (val === this.options[index]) - return this.options[index]; - }, thisObject); - - options.some(function (val, index) { - return val === this.options[index]; - }, thisObject); - - options.filter(function (val, index) { - return val === this.options[index]; - }, thisObject); - - options.every(function (val, index) { - return val === this.options[index]; - }, thisObject); - - const arrLike = {} as ArrayLike - Array.from(arrLike, function (item) { - return this.options[item].length - }, thisObject) - - const iterLike = [] as Iterable - Array.from(iterLike, function (item) { - return this.options[item].length - }, thisObject) - } - - test1(options: string[]) { - const thisObject = { - options: [] as ReadonlyArray - }; - - options.find(function (val, index) { - return val === this.options[index]; - }, thisObject); - - options.findIndex(function (val, index) { - return val === this.options[index]; - }, thisObject); - - options.forEach(function (val, index) { - return val === this.options[index]; - }, thisObject); - - options.map(function (val, index) { - if (val === this.options[index]) - return this.options[index]; - }, thisObject); - - options.some(function (val, index) { - return val === this.options[index]; - }, thisObject); - - options.filter(function (val, index) { - return val === this.options[index]; - }, thisObject); - - options.every(function (val, index) { - return val === this.options[index]; - }, thisObject); - } - - test2(options: Int8Array[]) { - const thisObject = { - options: [] as Int8Array[] - }; - - options.find(function (val, index) { - return val === this.options[index]; - }, thisObject); - - options.findIndex(function (val, index) { - return val === this.options[index]; - }, thisObject); - - options.forEach(function (val, index) { - return val === this.options[index]; - }, thisObject); - - options.map(function (val, index) { - if (val === this.options[index]) - return this.options[index]; - }, thisObject); - - options.some(function (val, index) { - return val === this.options[index]; - }, thisObject); - - options.filter(function (val, index) { - return val === this.options[index]; - }, thisObject); - - options.every(function (val, index) { - return val === this.options[index]; - }, thisObject); - } - - test3(options: Uint8Array[]) { - const thisObject = { - options: [] as Uint8Array[] - }; - - options.find(function (val, index) { - return val === this.options[index]; - }, thisObject); - - options.findIndex(function (val, index) { - return val === this.options[index]; - }, thisObject); - - options.forEach(function (val, index) { - return val === this.options[index]; - }, thisObject); - - options.map(function (val, index) { - if (val === this.options[index]) - return this.options[index]; - }, thisObject); - - options.some(function (val, index) { - return val === this.options[index]; - }, thisObject); - - options.filter(function (val, index) { - return val === this.options[index]; - }, thisObject); - - options.every(function (val, index) { - return val === this.options[index]; - }, thisObject); - } - - test4(options: Float32Array[]) { - const thisObject = { - options: [] as Float32Array[] - }; - - options.find(function (val, index) { - return val === this.options[index]; - }, thisObject); - - options.findIndex(function (val, index) { - return val === this.options[index]; - }, thisObject); - - options.forEach(function (val, index) { - return val === this.options[index]; - }, thisObject); - - options.map(function (val, index) { - if (val === this.options[index]) - return this.options[index]; - }, thisObject); - - options.some(function (val, index) { - return val === this.options[index]; - }, thisObject); - - options.filter(function (val, index) { - return val === this.options[index]; - }, thisObject); - - options.every(function (val, index) { - return val === this.options[index]; - }, thisObject); - } - - test5(options: Uint8ClampedArray[]) { - const thisObject = { - options: [] as Uint8ClampedArray[] - }; - - options.find(function (val, index) { - return val === this.options[index]; - }, thisObject); - - options.findIndex(function (val, index) { - return val === this.options[index]; - }, thisObject); - - options.forEach(function (val, index) { - return val === this.options[index]; - }, thisObject); - - options.map(function (val, index) { - if (val === this.options[index]) - return this.options[index]; - }, thisObject); - - options.some(function (val, index) { - return val === this.options[index]; - }, thisObject); - - options.filter(function (val, index) { - return val === this.options[index]; - }, thisObject); - - options.every(function (val, index) { - return val === this.options[index]; - }, thisObject); - } - - test6(options: Int16Array[]) { - const thisObject = { - options: [] as Int16Array[] - }; - - options.find(function (val, index) { - return val === this.options[index]; - }, thisObject); - - options.findIndex(function (val, index) { - return val === this.options[index]; - }, thisObject); - - options.forEach(function (val, index) { - return val === this.options[index]; - }, thisObject); - - options.map(function (val, index) { - if (val === this.options[index]) - return this.options[index]; - }, thisObject); - - options.some(function (val, index) { - return val === this.options[index]; - }, thisObject); - - options.filter(function (val, index) { - return val === this.options[index]; - }, thisObject); - - options.every(function (val, index) { - return val === this.options[index]; - }, thisObject); - } - - test7(options: Uint16Array[]) { - const thisObject = { - options: [] as Uint16Array[] - }; - - options.find(function (val, index) { - return val === this.options[index]; - }, thisObject); - - options.findIndex(function (val, index) { - return val === this.options[index]; - }, thisObject); - - options.forEach(function (val, index) { - return val === this.options[index]; - }, thisObject); - - options.map(function (val, index) { - if (val === this.options[index]) - return this.options[index]; - }, thisObject); - - options.some(function (val, index) { - return val === this.options[index]; - }, thisObject); - - options.filter(function (val, index) { - return val === this.options[index]; - }, thisObject); - - options.every(function (val, index) { - return val === this.options[index]; - }, thisObject); - } - - test8(options: Uint32Array[]) { - const thisObject = { - options: [] as Uint32Array[] - }; - - options.find(function (val, index) { - return val === this.options[index]; - }, thisObject); - - options.findIndex(function (val, index) { - return val === this.options[index]; - }, thisObject); - - options.forEach(function (val, index) { - return val === this.options[index]; - }, thisObject); - - options.map(function (val, index) { - if (val === this.options[index]) - return this.options[index]; - }, thisObject); - - options.some(function (val, index) { - return val === this.options[index]; - }, thisObject); - - options.filter(function (val, index) { - return val === this.options[index]; - }, thisObject); - - options.every(function (val, index) { - return val === this.options[index]; - }, thisObject); - } - - test9(options: Float64Array[]) { - const thisObject = { - options: [] as Float64Array[] - }; - - options.find(function (val, index) { - return val === this.options[index]; - }, thisObject); - - options.findIndex(function (val, index) { - return val === this.options[index]; - }, thisObject); - - options.forEach(function (val, index) { - return val === this.options[index]; - }, thisObject); - - options.map(function (val, index) { - if (val === this.options[index]) - return this.options[index]; - }, thisObject); - - options.some(function (val, index) { - return val === this.options[index]; - }, thisObject); - - options.filter(function (val, index) { - return val === this.options[index]; - }, thisObject); - - options.every(function (val, index) { - return val === this.options[index]; - }, thisObject); - } -} - - -//// [thisTypeInNativeThisAssignableMethods.js] -class A { - addOptions(options) { - if (!this.options) { - this.options = []; - } - options.forEach(function (item) { - this.options.push(item); - }, this); - return this; - } - testUndefined(options) { - const undefinedArr = []; - options.forEach(function () { - undefinedArr.push(this); - }); // case1 - options.forEach(function () { - undefinedArr.push(this); - }, undefined); // case2 - options.forEach(function () { - undefinedArr.push(this); - }, null); // case3 - const arrLike = {}; - Array.from(arrLike, function (item) { - return this === undefined ? 2 : 1; - }, undefined); - const iterLike = []; - Array.from(iterLike, function (item) { - return this === undefined ? 2 : 1; - }, undefined); - } - test(options) { - const thisObject = { - options: [] - }; - options.find(function (val, index) { - return val === this.options[index]; - }, thisObject); - options.findIndex(function (val, index) { - return val === this.options[index]; - }, thisObject); - options.forEach(function (val, index) { - return val === this.options[index]; - }, thisObject); - options.map(function (val, index) { - if (val === this.options[index]) - return this.options[index]; - }, thisObject); - options.some(function (val, index) { - return val === this.options[index]; - }, thisObject); - options.filter(function (val, index) { - return val === this.options[index]; - }, thisObject); - options.every(function (val, index) { - return val === this.options[index]; - }, thisObject); - const arrLike = {}; - Array.from(arrLike, function (item) { - return this.options[item].length; - }, thisObject); - const iterLike = []; - Array.from(iterLike, function (item) { - return this.options[item].length; - }, thisObject); - } - test1(options) { - const thisObject = { - options: [] - }; - options.find(function (val, index) { - return val === this.options[index]; - }, thisObject); - options.findIndex(function (val, index) { - return val === this.options[index]; - }, thisObject); - options.forEach(function (val, index) { - return val === this.options[index]; - }, thisObject); - options.map(function (val, index) { - if (val === this.options[index]) - return this.options[index]; - }, thisObject); - options.some(function (val, index) { - return val === this.options[index]; - }, thisObject); - options.filter(function (val, index) { - return val === this.options[index]; - }, thisObject); - options.every(function (val, index) { - return val === this.options[index]; - }, thisObject); - } - test2(options) { - const thisObject = { - options: [] - }; - options.find(function (val, index) { - return val === this.options[index]; - }, thisObject); - options.findIndex(function (val, index) { - return val === this.options[index]; - }, thisObject); - options.forEach(function (val, index) { - return val === this.options[index]; - }, thisObject); - options.map(function (val, index) { - if (val === this.options[index]) - return this.options[index]; - }, thisObject); - options.some(function (val, index) { - return val === this.options[index]; - }, thisObject); - options.filter(function (val, index) { - return val === this.options[index]; - }, thisObject); - options.every(function (val, index) { - return val === this.options[index]; - }, thisObject); - } - test3(options) { - const thisObject = { - options: [] - }; - options.find(function (val, index) { - return val === this.options[index]; - }, thisObject); - options.findIndex(function (val, index) { - return val === this.options[index]; - }, thisObject); - options.forEach(function (val, index) { - return val === this.options[index]; - }, thisObject); - options.map(function (val, index) { - if (val === this.options[index]) - return this.options[index]; - }, thisObject); - options.some(function (val, index) { - return val === this.options[index]; - }, thisObject); - options.filter(function (val, index) { - return val === this.options[index]; - }, thisObject); - options.every(function (val, index) { - return val === this.options[index]; - }, thisObject); - } - test4(options) { - const thisObject = { - options: [] - }; - options.find(function (val, index) { - return val === this.options[index]; - }, thisObject); - options.findIndex(function (val, index) { - return val === this.options[index]; - }, thisObject); - options.forEach(function (val, index) { - return val === this.options[index]; - }, thisObject); - options.map(function (val, index) { - if (val === this.options[index]) - return this.options[index]; - }, thisObject); - options.some(function (val, index) { - return val === this.options[index]; - }, thisObject); - options.filter(function (val, index) { - return val === this.options[index]; - }, thisObject); - options.every(function (val, index) { - return val === this.options[index]; - }, thisObject); - } - test5(options) { - const thisObject = { - options: [] - }; - options.find(function (val, index) { - return val === this.options[index]; - }, thisObject); - options.findIndex(function (val, index) { - return val === this.options[index]; - }, thisObject); - options.forEach(function (val, index) { - return val === this.options[index]; - }, thisObject); - options.map(function (val, index) { - if (val === this.options[index]) - return this.options[index]; - }, thisObject); - options.some(function (val, index) { - return val === this.options[index]; - }, thisObject); - options.filter(function (val, index) { - return val === this.options[index]; - }, thisObject); - options.every(function (val, index) { - return val === this.options[index]; - }, thisObject); - } - test6(options) { - const thisObject = { - options: [] - }; - options.find(function (val, index) { - return val === this.options[index]; - }, thisObject); - options.findIndex(function (val, index) { - return val === this.options[index]; - }, thisObject); - options.forEach(function (val, index) { - return val === this.options[index]; - }, thisObject); - options.map(function (val, index) { - if (val === this.options[index]) - return this.options[index]; - }, thisObject); - options.some(function (val, index) { - return val === this.options[index]; - }, thisObject); - options.filter(function (val, index) { - return val === this.options[index]; - }, thisObject); - options.every(function (val, index) { - return val === this.options[index]; - }, thisObject); - } - test7(options) { - const thisObject = { - options: [] - }; - options.find(function (val, index) { - return val === this.options[index]; - }, thisObject); - options.findIndex(function (val, index) { - return val === this.options[index]; - }, thisObject); - options.forEach(function (val, index) { - return val === this.options[index]; - }, thisObject); - options.map(function (val, index) { - if (val === this.options[index]) - return this.options[index]; - }, thisObject); - options.some(function (val, index) { - return val === this.options[index]; - }, thisObject); - options.filter(function (val, index) { - return val === this.options[index]; - }, thisObject); - options.every(function (val, index) { - return val === this.options[index]; - }, thisObject); - } - test8(options) { - const thisObject = { - options: [] - }; - options.find(function (val, index) { - return val === this.options[index]; - }, thisObject); - options.findIndex(function (val, index) { - return val === this.options[index]; - }, thisObject); - options.forEach(function (val, index) { - return val === this.options[index]; - }, thisObject); - options.map(function (val, index) { - if (val === this.options[index]) - return this.options[index]; - }, thisObject); - options.some(function (val, index) { - return val === this.options[index]; - }, thisObject); - options.filter(function (val, index) { - return val === this.options[index]; - }, thisObject); - options.every(function (val, index) { - return val === this.options[index]; - }, thisObject); - } - test9(options) { - const thisObject = { - options: [] - }; - options.find(function (val, index) { - return val === this.options[index]; - }, thisObject); - options.findIndex(function (val, index) { - return val === this.options[index]; - }, thisObject); - options.forEach(function (val, index) { - return val === this.options[index]; - }, thisObject); - options.map(function (val, index) { - if (val === this.options[index]) - return this.options[index]; - }, thisObject); - options.some(function (val, index) { - return val === this.options[index]; - }, thisObject); - options.filter(function (val, index) { - return val === this.options[index]; - }, thisObject); - options.every(function (val, index) { - return val === this.options[index]; - }, thisObject); - } -} diff --git a/tests/baselines/reference/thisTypeInNativeThisAssignableMethods.symbols b/tests/baselines/reference/thisTypeInNativeThisAssignableMethods.symbols deleted file mode 100644 index 2099b98c8b5..00000000000 --- a/tests/baselines/reference/thisTypeInNativeThisAssignableMethods.symbols +++ /dev/null @@ -1,1380 +0,0 @@ -=== tests/cases/compiler/thisTypeInNativeThisAssignableMethods.ts === -class A { ->A : Symbol(A, Decl(thisTypeInNativeThisAssignableMethods.ts, 0, 0)) - - options: string[]; ->options : Symbol(A.options, Decl(thisTypeInNativeThisAssignableMethods.ts, 0, 9)) - - addOptions(options: string[]) { ->addOptions : Symbol(A.addOptions, Decl(thisTypeInNativeThisAssignableMethods.ts, 1, 22)) ->options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 3, 15)) - - if (!this.options) { ->this.options : Symbol(A.options, Decl(thisTypeInNativeThisAssignableMethods.ts, 0, 9)) ->this : Symbol(A, Decl(thisTypeInNativeThisAssignableMethods.ts, 0, 0)) ->options : Symbol(A.options, Decl(thisTypeInNativeThisAssignableMethods.ts, 0, 9)) - - this.options = []; ->this.options : Symbol(A.options, Decl(thisTypeInNativeThisAssignableMethods.ts, 0, 9)) ->this : Symbol(A, Decl(thisTypeInNativeThisAssignableMethods.ts, 0, 0)) ->options : Symbol(A.options, Decl(thisTypeInNativeThisAssignableMethods.ts, 0, 9)) - } - options.forEach(function (item) { ->options.forEach : Symbol(Array.forEach, Decl(lib.es5.d.ts, --, --)) ->options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 3, 15)) ->forEach : Symbol(Array.forEach, Decl(lib.es5.d.ts, --, --)) ->item : Symbol(item, Decl(thisTypeInNativeThisAssignableMethods.ts, 7, 34)) - - this.options.push(item); ->item : Symbol(item, Decl(thisTypeInNativeThisAssignableMethods.ts, 7, 34)) - - }, this); ->this : Symbol(A, Decl(thisTypeInNativeThisAssignableMethods.ts, 0, 0)) - - return this; ->this : Symbol(A, Decl(thisTypeInNativeThisAssignableMethods.ts, 0, 0)) - } - - testUndefined(options: string[]) { ->testUndefined : Symbol(A.testUndefined, Decl(thisTypeInNativeThisAssignableMethods.ts, 11, 5)) ->options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 13, 18)) - - const undefinedArr: Array = [] ->undefinedArr : Symbol(undefinedArr, Decl(thisTypeInNativeThisAssignableMethods.ts, 14, 13)) ->Array : Symbol(Array, Decl(lib.es2016.array.include.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --)) - - options.forEach(function () { ->options.forEach : Symbol(Array.forEach, Decl(lib.es5.d.ts, --, --)) ->options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 13, 18)) ->forEach : Symbol(Array.forEach, Decl(lib.es5.d.ts, --, --)) - - undefinedArr.push(this); ->undefinedArr.push : Symbol(Array.push, Decl(lib.es5.d.ts, --, --)) ->undefinedArr : Symbol(undefinedArr, Decl(thisTypeInNativeThisAssignableMethods.ts, 14, 13)) ->push : Symbol(Array.push, Decl(lib.es5.d.ts, --, --)) - - }); // case1 - options.forEach(function () { ->options.forEach : Symbol(Array.forEach, Decl(lib.es5.d.ts, --, --)) ->options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 13, 18)) ->forEach : Symbol(Array.forEach, Decl(lib.es5.d.ts, --, --)) - - undefinedArr.push(this); ->undefinedArr.push : Symbol(Array.push, Decl(lib.es5.d.ts, --, --)) ->undefinedArr : Symbol(undefinedArr, Decl(thisTypeInNativeThisAssignableMethods.ts, 14, 13)) ->push : Symbol(Array.push, Decl(lib.es5.d.ts, --, --)) - - }, undefined); // case2 ->undefined : Symbol(undefined) - - options.forEach(function () { ->options.forEach : Symbol(Array.forEach, Decl(lib.es5.d.ts, --, --)) ->options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 13, 18)) ->forEach : Symbol(Array.forEach, Decl(lib.es5.d.ts, --, --)) - - undefinedArr.push(this); ->undefinedArr.push : Symbol(Array.push, Decl(lib.es5.d.ts, --, --)) ->undefinedArr : Symbol(undefinedArr, Decl(thisTypeInNativeThisAssignableMethods.ts, 14, 13)) ->push : Symbol(Array.push, Decl(lib.es5.d.ts, --, --)) - - }, null); // case3 - - const arrLike = {} as ArrayLike ->arrLike : Symbol(arrLike, Decl(thisTypeInNativeThisAssignableMethods.ts, 25, 13)) ->ArrayLike : Symbol(ArrayLike, Decl(lib.es5.d.ts, --, --)) - - Array.from(arrLike, function (item) { ->Array.from : Symbol(ArrayConstructor.from, Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --)) ->Array : Symbol(Array, Decl(lib.es2016.array.include.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --)) ->from : Symbol(ArrayConstructor.from, Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --)) ->arrLike : Symbol(arrLike, Decl(thisTypeInNativeThisAssignableMethods.ts, 25, 13)) ->item : Symbol(item, Decl(thisTypeInNativeThisAssignableMethods.ts, 26, 38)) - - return this === undefined ? 2 : 1; ->this : Symbol(this, Decl(lib.es2015.core.d.ts, --, --)) ->undefined : Symbol(undefined) - - }, undefined) ->undefined : Symbol(undefined) - - const iterLike = [] as Iterable ->iterLike : Symbol(iterLike, Decl(thisTypeInNativeThisAssignableMethods.ts, 30, 13)) ->Iterable : Symbol(Iterable, Decl(lib.es2015.iterable.d.ts, --, --)) - - Array.from(iterLike, function (item) { ->Array.from : Symbol(ArrayConstructor.from, Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --)) ->Array : Symbol(Array, Decl(lib.es2016.array.include.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --)) ->from : Symbol(ArrayConstructor.from, Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --)) ->iterLike : Symbol(iterLike, Decl(thisTypeInNativeThisAssignableMethods.ts, 30, 13)) ->item : Symbol(item, Decl(thisTypeInNativeThisAssignableMethods.ts, 31, 39)) - - return this === undefined ? 2 : 1; ->this : Symbol(this, Decl(lib.es2015.iterable.d.ts, --, --)) ->undefined : Symbol(undefined) - - }, undefined) ->undefined : Symbol(undefined) - } - - test(options: string[]) { ->test : Symbol(A.test, Decl(thisTypeInNativeThisAssignableMethods.ts, 34, 5)) ->options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 36, 9)) - - const thisObject = { ->thisObject : Symbol(thisObject, Decl(thisTypeInNativeThisAssignableMethods.ts, 37, 13)) - - options: [] as string[] ->options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 37, 28)) - - }; - - options.find(function (val, index) { ->options.find : Symbol(Array.find, Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --)) ->options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 36, 9)) ->find : Symbol(Array.find, Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --)) ->val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 41, 31)) ->index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 41, 35)) - - return val === this.options[index]; ->val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 41, 31)) ->this.options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 37, 28)) ->this : Symbol(this, Decl(lib.es2015.core.d.ts, --, --)) ->options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 37, 28)) ->index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 41, 35)) - - }, thisObject); ->thisObject : Symbol(thisObject, Decl(thisTypeInNativeThisAssignableMethods.ts, 37, 13)) - - options.findIndex(function (val, index) { ->options.findIndex : Symbol(Array.findIndex, Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --)) ->options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 36, 9)) ->findIndex : Symbol(Array.findIndex, Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --)) ->val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 45, 36)) ->index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 45, 40)) - - return val === this.options[index]; ->val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 45, 36)) ->this.options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 37, 28)) ->this : Symbol(this, Decl(lib.es2015.core.d.ts, --, --)) ->options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 37, 28)) ->index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 45, 40)) - - }, thisObject); ->thisObject : Symbol(thisObject, Decl(thisTypeInNativeThisAssignableMethods.ts, 37, 13)) - - options.forEach(function (val, index) { ->options.forEach : Symbol(Array.forEach, Decl(lib.es5.d.ts, --, --)) ->options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 36, 9)) ->forEach : Symbol(Array.forEach, Decl(lib.es5.d.ts, --, --)) ->val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 49, 34)) ->index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 49, 38)) - - return val === this.options[index]; ->val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 49, 34)) ->index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 49, 38)) - - }, thisObject); ->thisObject : Symbol(thisObject, Decl(thisTypeInNativeThisAssignableMethods.ts, 37, 13)) - - options.map(function (val, index) { ->options.map : Symbol(Array.map, Decl(lib.es5.d.ts, --, --)) ->options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 36, 9)) ->map : Symbol(Array.map, Decl(lib.es5.d.ts, --, --)) ->val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 53, 30)) ->index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 53, 34)) - - if (val === this.options[index]) ->val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 53, 30)) ->index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 53, 34)) - - return this.options[index]; ->index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 53, 34)) - - }, thisObject); ->thisObject : Symbol(thisObject, Decl(thisTypeInNativeThisAssignableMethods.ts, 37, 13)) - - options.some(function (val, index) { ->options.some : Symbol(Array.some, Decl(lib.es5.d.ts, --, --)) ->options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 36, 9)) ->some : Symbol(Array.some, Decl(lib.es5.d.ts, --, --)) ->val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 58, 31)) ->index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 58, 35)) - - return val === this.options[index]; ->val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 58, 31)) ->index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 58, 35)) - - }, thisObject); ->thisObject : Symbol(thisObject, Decl(thisTypeInNativeThisAssignableMethods.ts, 37, 13)) - - options.filter(function (val, index) { ->options.filter : Symbol(Array.filter, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) ->options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 36, 9)) ->filter : Symbol(Array.filter, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) ->val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 62, 33)) ->index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 62, 37)) - - return val === this.options[index]; ->val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 62, 33)) ->index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 62, 37)) - - }, thisObject); ->thisObject : Symbol(thisObject, Decl(thisTypeInNativeThisAssignableMethods.ts, 37, 13)) - - options.every(function (val, index) { ->options.every : Symbol(Array.every, Decl(lib.es5.d.ts, --, --)) ->options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 36, 9)) ->every : Symbol(Array.every, Decl(lib.es5.d.ts, --, --)) ->val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 66, 32)) ->index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 66, 36)) - - return val === this.options[index]; ->val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 66, 32)) ->index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 66, 36)) - - }, thisObject); ->thisObject : Symbol(thisObject, Decl(thisTypeInNativeThisAssignableMethods.ts, 37, 13)) - - const arrLike = {} as ArrayLike ->arrLike : Symbol(arrLike, Decl(thisTypeInNativeThisAssignableMethods.ts, 70, 13)) ->ArrayLike : Symbol(ArrayLike, Decl(lib.es5.d.ts, --, --)) - - Array.from(arrLike, function (item) { ->Array.from : Symbol(ArrayConstructor.from, Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --)) ->Array : Symbol(Array, Decl(lib.es2016.array.include.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --)) ->from : Symbol(ArrayConstructor.from, Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --)) ->arrLike : Symbol(arrLike, Decl(thisTypeInNativeThisAssignableMethods.ts, 70, 13)) ->item : Symbol(item, Decl(thisTypeInNativeThisAssignableMethods.ts, 71, 38)) - - return this.options[item].length ->this.options[item].length : Symbol(String.length, Decl(lib.es5.d.ts, --, --)) ->this.options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 37, 28)) ->this : Symbol(this, Decl(lib.es2015.core.d.ts, --, --)) ->options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 37, 28)) ->item : Symbol(item, Decl(thisTypeInNativeThisAssignableMethods.ts, 71, 38)) ->length : Symbol(String.length, Decl(lib.es5.d.ts, --, --)) - - }, thisObject) ->thisObject : Symbol(thisObject, Decl(thisTypeInNativeThisAssignableMethods.ts, 37, 13)) - - const iterLike = [] as Iterable ->iterLike : Symbol(iterLike, Decl(thisTypeInNativeThisAssignableMethods.ts, 75, 13)) ->Iterable : Symbol(Iterable, Decl(lib.es2015.iterable.d.ts, --, --)) - - Array.from(iterLike, function (item) { ->Array.from : Symbol(ArrayConstructor.from, Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --)) ->Array : Symbol(Array, Decl(lib.es2016.array.include.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --)) ->from : Symbol(ArrayConstructor.from, Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --)) ->iterLike : Symbol(iterLike, Decl(thisTypeInNativeThisAssignableMethods.ts, 75, 13)) ->item : Symbol(item, Decl(thisTypeInNativeThisAssignableMethods.ts, 76, 39)) - - return this.options[item].length ->this.options[item].length : Symbol(String.length, Decl(lib.es5.d.ts, --, --)) ->this.options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 37, 28)) ->this : Symbol(this, Decl(lib.es2015.iterable.d.ts, --, --)) ->options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 37, 28)) ->item : Symbol(item, Decl(thisTypeInNativeThisAssignableMethods.ts, 76, 39)) ->length : Symbol(String.length, Decl(lib.es5.d.ts, --, --)) - - }, thisObject) ->thisObject : Symbol(thisObject, Decl(thisTypeInNativeThisAssignableMethods.ts, 37, 13)) - } - - test1(options: string[]) { ->test1 : Symbol(A.test1, Decl(thisTypeInNativeThisAssignableMethods.ts, 79, 5)) ->options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 81, 10)) - - const thisObject = { ->thisObject : Symbol(thisObject, Decl(thisTypeInNativeThisAssignableMethods.ts, 82, 13)) - - options: [] as ReadonlyArray ->options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 82, 28)) ->ReadonlyArray : Symbol(ReadonlyArray, Decl(lib.es2016.array.include.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --)) - - }; - - options.find(function (val, index) { ->options.find : Symbol(Array.find, Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --)) ->options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 81, 10)) ->find : Symbol(Array.find, Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --)) ->val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 86, 31)) ->index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 86, 35)) - - return val === this.options[index]; ->val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 86, 31)) ->this.options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 82, 28)) ->this : Symbol(this, Decl(lib.es2015.core.d.ts, --, --)) ->options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 82, 28)) ->index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 86, 35)) - - }, thisObject); ->thisObject : Symbol(thisObject, Decl(thisTypeInNativeThisAssignableMethods.ts, 82, 13)) - - options.findIndex(function (val, index) { ->options.findIndex : Symbol(Array.findIndex, Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --)) ->options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 81, 10)) ->findIndex : Symbol(Array.findIndex, Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --)) ->val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 90, 36)) ->index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 90, 40)) - - return val === this.options[index]; ->val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 90, 36)) ->this.options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 82, 28)) ->this : Symbol(this, Decl(lib.es2015.core.d.ts, --, --)) ->options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 82, 28)) ->index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 90, 40)) - - }, thisObject); ->thisObject : Symbol(thisObject, Decl(thisTypeInNativeThisAssignableMethods.ts, 82, 13)) - - options.forEach(function (val, index) { ->options.forEach : Symbol(Array.forEach, Decl(lib.es5.d.ts, --, --)) ->options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 81, 10)) ->forEach : Symbol(Array.forEach, Decl(lib.es5.d.ts, --, --)) ->val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 94, 34)) ->index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 94, 38)) - - return val === this.options[index]; ->val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 94, 34)) ->index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 94, 38)) - - }, thisObject); ->thisObject : Symbol(thisObject, Decl(thisTypeInNativeThisAssignableMethods.ts, 82, 13)) - - options.map(function (val, index) { ->options.map : Symbol(Array.map, Decl(lib.es5.d.ts, --, --)) ->options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 81, 10)) ->map : Symbol(Array.map, Decl(lib.es5.d.ts, --, --)) ->val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 98, 30)) ->index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 98, 34)) - - if (val === this.options[index]) ->val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 98, 30)) ->index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 98, 34)) - - return this.options[index]; ->index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 98, 34)) - - }, thisObject); ->thisObject : Symbol(thisObject, Decl(thisTypeInNativeThisAssignableMethods.ts, 82, 13)) - - options.some(function (val, index) { ->options.some : Symbol(Array.some, Decl(lib.es5.d.ts, --, --)) ->options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 81, 10)) ->some : Symbol(Array.some, Decl(lib.es5.d.ts, --, --)) ->val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 103, 31)) ->index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 103, 35)) - - return val === this.options[index]; ->val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 103, 31)) ->index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 103, 35)) - - }, thisObject); ->thisObject : Symbol(thisObject, Decl(thisTypeInNativeThisAssignableMethods.ts, 82, 13)) - - options.filter(function (val, index) { ->options.filter : Symbol(Array.filter, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) ->options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 81, 10)) ->filter : Symbol(Array.filter, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) ->val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 107, 33)) ->index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 107, 37)) - - return val === this.options[index]; ->val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 107, 33)) ->index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 107, 37)) - - }, thisObject); ->thisObject : Symbol(thisObject, Decl(thisTypeInNativeThisAssignableMethods.ts, 82, 13)) - - options.every(function (val, index) { ->options.every : Symbol(Array.every, Decl(lib.es5.d.ts, --, --)) ->options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 81, 10)) ->every : Symbol(Array.every, Decl(lib.es5.d.ts, --, --)) ->val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 111, 32)) ->index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 111, 36)) - - return val === this.options[index]; ->val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 111, 32)) ->index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 111, 36)) - - }, thisObject); ->thisObject : Symbol(thisObject, Decl(thisTypeInNativeThisAssignableMethods.ts, 82, 13)) - } - - test2(options: Int8Array[]) { ->test2 : Symbol(A.test2, Decl(thisTypeInNativeThisAssignableMethods.ts, 114, 5)) ->options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 116, 10)) ->Int8Array : Symbol(Int8Array, Decl(lib.es2016.array.include.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) - - const thisObject = { ->thisObject : Symbol(thisObject, Decl(thisTypeInNativeThisAssignableMethods.ts, 117, 13)) - - options: [] as Int8Array[] ->options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 117, 28)) ->Int8Array : Symbol(Int8Array, Decl(lib.es2016.array.include.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) - - }; - - options.find(function (val, index) { ->options.find : Symbol(Array.find, Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --)) ->options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 116, 10)) ->find : Symbol(Array.find, Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --)) ->val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 121, 31)) ->index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 121, 35)) - - return val === this.options[index]; ->val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 121, 31)) ->this.options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 117, 28)) ->this : Symbol(this, Decl(lib.es2015.core.d.ts, --, --)) ->options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 117, 28)) ->index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 121, 35)) - - }, thisObject); ->thisObject : Symbol(thisObject, Decl(thisTypeInNativeThisAssignableMethods.ts, 117, 13)) - - options.findIndex(function (val, index) { ->options.findIndex : Symbol(Array.findIndex, Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --)) ->options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 116, 10)) ->findIndex : Symbol(Array.findIndex, Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --)) ->val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 125, 36)) ->index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 125, 40)) - - return val === this.options[index]; ->val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 125, 36)) ->this.options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 117, 28)) ->this : Symbol(this, Decl(lib.es2015.core.d.ts, --, --)) ->options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 117, 28)) ->index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 125, 40)) - - }, thisObject); ->thisObject : Symbol(thisObject, Decl(thisTypeInNativeThisAssignableMethods.ts, 117, 13)) - - options.forEach(function (val, index) { ->options.forEach : Symbol(Array.forEach, Decl(lib.es5.d.ts, --, --)) ->options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 116, 10)) ->forEach : Symbol(Array.forEach, Decl(lib.es5.d.ts, --, --)) ->val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 129, 34)) ->index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 129, 38)) - - return val === this.options[index]; ->val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 129, 34)) ->index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 129, 38)) - - }, thisObject); ->thisObject : Symbol(thisObject, Decl(thisTypeInNativeThisAssignableMethods.ts, 117, 13)) - - options.map(function (val, index) { ->options.map : Symbol(Array.map, Decl(lib.es5.d.ts, --, --)) ->options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 116, 10)) ->map : Symbol(Array.map, Decl(lib.es5.d.ts, --, --)) ->val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 133, 30)) ->index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 133, 34)) - - if (val === this.options[index]) ->val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 133, 30)) ->index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 133, 34)) - - return this.options[index]; ->index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 133, 34)) - - }, thisObject); ->thisObject : Symbol(thisObject, Decl(thisTypeInNativeThisAssignableMethods.ts, 117, 13)) - - options.some(function (val, index) { ->options.some : Symbol(Array.some, Decl(lib.es5.d.ts, --, --)) ->options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 116, 10)) ->some : Symbol(Array.some, Decl(lib.es5.d.ts, --, --)) ->val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 138, 31)) ->index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 138, 35)) - - return val === this.options[index]; ->val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 138, 31)) ->index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 138, 35)) - - }, thisObject); ->thisObject : Symbol(thisObject, Decl(thisTypeInNativeThisAssignableMethods.ts, 117, 13)) - - options.filter(function (val, index) { ->options.filter : Symbol(Array.filter, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) ->options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 116, 10)) ->filter : Symbol(Array.filter, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) ->val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 142, 33)) ->index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 142, 37)) - - return val === this.options[index]; ->val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 142, 33)) ->index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 142, 37)) - - }, thisObject); ->thisObject : Symbol(thisObject, Decl(thisTypeInNativeThisAssignableMethods.ts, 117, 13)) - - options.every(function (val, index) { ->options.every : Symbol(Array.every, Decl(lib.es5.d.ts, --, --)) ->options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 116, 10)) ->every : Symbol(Array.every, Decl(lib.es5.d.ts, --, --)) ->val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 146, 32)) ->index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 146, 36)) - - return val === this.options[index]; ->val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 146, 32)) ->index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 146, 36)) - - }, thisObject); ->thisObject : Symbol(thisObject, Decl(thisTypeInNativeThisAssignableMethods.ts, 117, 13)) - } - - test3(options: Uint8Array[]) { ->test3 : Symbol(A.test3, Decl(thisTypeInNativeThisAssignableMethods.ts, 149, 5)) ->options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 151, 10)) ->Uint8Array : Symbol(Uint8Array, Decl(lib.es2016.array.include.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) - - const thisObject = { ->thisObject : Symbol(thisObject, Decl(thisTypeInNativeThisAssignableMethods.ts, 152, 13)) - - options: [] as Uint8Array[] ->options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 152, 28)) ->Uint8Array : Symbol(Uint8Array, Decl(lib.es2016.array.include.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) - - }; - - options.find(function (val, index) { ->options.find : Symbol(Array.find, Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --)) ->options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 151, 10)) ->find : Symbol(Array.find, Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --)) ->val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 156, 31)) ->index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 156, 35)) - - return val === this.options[index]; ->val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 156, 31)) ->this.options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 152, 28)) ->this : Symbol(this, Decl(lib.es2015.core.d.ts, --, --)) ->options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 152, 28)) ->index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 156, 35)) - - }, thisObject); ->thisObject : Symbol(thisObject, Decl(thisTypeInNativeThisAssignableMethods.ts, 152, 13)) - - options.findIndex(function (val, index) { ->options.findIndex : Symbol(Array.findIndex, Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --)) ->options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 151, 10)) ->findIndex : Symbol(Array.findIndex, Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --)) ->val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 160, 36)) ->index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 160, 40)) - - return val === this.options[index]; ->val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 160, 36)) ->this.options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 152, 28)) ->this : Symbol(this, Decl(lib.es2015.core.d.ts, --, --)) ->options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 152, 28)) ->index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 160, 40)) - - }, thisObject); ->thisObject : Symbol(thisObject, Decl(thisTypeInNativeThisAssignableMethods.ts, 152, 13)) - - options.forEach(function (val, index) { ->options.forEach : Symbol(Array.forEach, Decl(lib.es5.d.ts, --, --)) ->options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 151, 10)) ->forEach : Symbol(Array.forEach, Decl(lib.es5.d.ts, --, --)) ->val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 164, 34)) ->index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 164, 38)) - - return val === this.options[index]; ->val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 164, 34)) ->index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 164, 38)) - - }, thisObject); ->thisObject : Symbol(thisObject, Decl(thisTypeInNativeThisAssignableMethods.ts, 152, 13)) - - options.map(function (val, index) { ->options.map : Symbol(Array.map, Decl(lib.es5.d.ts, --, --)) ->options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 151, 10)) ->map : Symbol(Array.map, Decl(lib.es5.d.ts, --, --)) ->val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 168, 30)) ->index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 168, 34)) - - if (val === this.options[index]) ->val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 168, 30)) ->index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 168, 34)) - - return this.options[index]; ->index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 168, 34)) - - }, thisObject); ->thisObject : Symbol(thisObject, Decl(thisTypeInNativeThisAssignableMethods.ts, 152, 13)) - - options.some(function (val, index) { ->options.some : Symbol(Array.some, Decl(lib.es5.d.ts, --, --)) ->options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 151, 10)) ->some : Symbol(Array.some, Decl(lib.es5.d.ts, --, --)) ->val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 173, 31)) ->index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 173, 35)) - - return val === this.options[index]; ->val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 173, 31)) ->index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 173, 35)) - - }, thisObject); ->thisObject : Symbol(thisObject, Decl(thisTypeInNativeThisAssignableMethods.ts, 152, 13)) - - options.filter(function (val, index) { ->options.filter : Symbol(Array.filter, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) ->options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 151, 10)) ->filter : Symbol(Array.filter, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) ->val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 177, 33)) ->index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 177, 37)) - - return val === this.options[index]; ->val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 177, 33)) ->index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 177, 37)) - - }, thisObject); ->thisObject : Symbol(thisObject, Decl(thisTypeInNativeThisAssignableMethods.ts, 152, 13)) - - options.every(function (val, index) { ->options.every : Symbol(Array.every, Decl(lib.es5.d.ts, --, --)) ->options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 151, 10)) ->every : Symbol(Array.every, Decl(lib.es5.d.ts, --, --)) ->val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 181, 32)) ->index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 181, 36)) - - return val === this.options[index]; ->val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 181, 32)) ->index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 181, 36)) - - }, thisObject); ->thisObject : Symbol(thisObject, Decl(thisTypeInNativeThisAssignableMethods.ts, 152, 13)) - } - - test4(options: Float32Array[]) { ->test4 : Symbol(A.test4, Decl(thisTypeInNativeThisAssignableMethods.ts, 184, 5)) ->options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 186, 10)) ->Float32Array : Symbol(Float32Array, Decl(lib.es2016.array.include.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) - - const thisObject = { ->thisObject : Symbol(thisObject, Decl(thisTypeInNativeThisAssignableMethods.ts, 187, 13)) - - options: [] as Float32Array[] ->options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 187, 28)) ->Float32Array : Symbol(Float32Array, Decl(lib.es2016.array.include.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) - - }; - - options.find(function (val, index) { ->options.find : Symbol(Array.find, Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --)) ->options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 186, 10)) ->find : Symbol(Array.find, Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --)) ->val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 191, 31)) ->index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 191, 35)) - - return val === this.options[index]; ->val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 191, 31)) ->this.options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 187, 28)) ->this : Symbol(this, Decl(lib.es2015.core.d.ts, --, --)) ->options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 187, 28)) ->index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 191, 35)) - - }, thisObject); ->thisObject : Symbol(thisObject, Decl(thisTypeInNativeThisAssignableMethods.ts, 187, 13)) - - options.findIndex(function (val, index) { ->options.findIndex : Symbol(Array.findIndex, Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --)) ->options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 186, 10)) ->findIndex : Symbol(Array.findIndex, Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --)) ->val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 195, 36)) ->index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 195, 40)) - - return val === this.options[index]; ->val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 195, 36)) ->this.options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 187, 28)) ->this : Symbol(this, Decl(lib.es2015.core.d.ts, --, --)) ->options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 187, 28)) ->index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 195, 40)) - - }, thisObject); ->thisObject : Symbol(thisObject, Decl(thisTypeInNativeThisAssignableMethods.ts, 187, 13)) - - options.forEach(function (val, index) { ->options.forEach : Symbol(Array.forEach, Decl(lib.es5.d.ts, --, --)) ->options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 186, 10)) ->forEach : Symbol(Array.forEach, Decl(lib.es5.d.ts, --, --)) ->val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 199, 34)) ->index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 199, 38)) - - return val === this.options[index]; ->val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 199, 34)) ->index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 199, 38)) - - }, thisObject); ->thisObject : Symbol(thisObject, Decl(thisTypeInNativeThisAssignableMethods.ts, 187, 13)) - - options.map(function (val, index) { ->options.map : Symbol(Array.map, Decl(lib.es5.d.ts, --, --)) ->options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 186, 10)) ->map : Symbol(Array.map, Decl(lib.es5.d.ts, --, --)) ->val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 203, 30)) ->index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 203, 34)) - - if (val === this.options[index]) ->val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 203, 30)) ->index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 203, 34)) - - return this.options[index]; ->index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 203, 34)) - - }, thisObject); ->thisObject : Symbol(thisObject, Decl(thisTypeInNativeThisAssignableMethods.ts, 187, 13)) - - options.some(function (val, index) { ->options.some : Symbol(Array.some, Decl(lib.es5.d.ts, --, --)) ->options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 186, 10)) ->some : Symbol(Array.some, Decl(lib.es5.d.ts, --, --)) ->val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 208, 31)) ->index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 208, 35)) - - return val === this.options[index]; ->val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 208, 31)) ->index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 208, 35)) - - }, thisObject); ->thisObject : Symbol(thisObject, Decl(thisTypeInNativeThisAssignableMethods.ts, 187, 13)) - - options.filter(function (val, index) { ->options.filter : Symbol(Array.filter, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) ->options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 186, 10)) ->filter : Symbol(Array.filter, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) ->val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 212, 33)) ->index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 212, 37)) - - return val === this.options[index]; ->val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 212, 33)) ->index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 212, 37)) - - }, thisObject); ->thisObject : Symbol(thisObject, Decl(thisTypeInNativeThisAssignableMethods.ts, 187, 13)) - - options.every(function (val, index) { ->options.every : Symbol(Array.every, Decl(lib.es5.d.ts, --, --)) ->options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 186, 10)) ->every : Symbol(Array.every, Decl(lib.es5.d.ts, --, --)) ->val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 216, 32)) ->index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 216, 36)) - - return val === this.options[index]; ->val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 216, 32)) ->index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 216, 36)) - - }, thisObject); ->thisObject : Symbol(thisObject, Decl(thisTypeInNativeThisAssignableMethods.ts, 187, 13)) - } - - test5(options: Uint8ClampedArray[]) { ->test5 : Symbol(A.test5, Decl(thisTypeInNativeThisAssignableMethods.ts, 219, 5)) ->options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 221, 10)) ->Uint8ClampedArray : Symbol(Uint8ClampedArray, Decl(lib.es2016.array.include.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) - - const thisObject = { ->thisObject : Symbol(thisObject, Decl(thisTypeInNativeThisAssignableMethods.ts, 222, 13)) - - options: [] as Uint8ClampedArray[] ->options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 222, 28)) ->Uint8ClampedArray : Symbol(Uint8ClampedArray, Decl(lib.es2016.array.include.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) - - }; - - options.find(function (val, index) { ->options.find : Symbol(Array.find, Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --)) ->options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 221, 10)) ->find : Symbol(Array.find, Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --)) ->val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 226, 31)) ->index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 226, 35)) - - return val === this.options[index]; ->val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 226, 31)) ->this.options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 222, 28)) ->this : Symbol(this, Decl(lib.es2015.core.d.ts, --, --)) ->options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 222, 28)) ->index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 226, 35)) - - }, thisObject); ->thisObject : Symbol(thisObject, Decl(thisTypeInNativeThisAssignableMethods.ts, 222, 13)) - - options.findIndex(function (val, index) { ->options.findIndex : Symbol(Array.findIndex, Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --)) ->options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 221, 10)) ->findIndex : Symbol(Array.findIndex, Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --)) ->val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 230, 36)) ->index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 230, 40)) - - return val === this.options[index]; ->val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 230, 36)) ->this.options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 222, 28)) ->this : Symbol(this, Decl(lib.es2015.core.d.ts, --, --)) ->options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 222, 28)) ->index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 230, 40)) - - }, thisObject); ->thisObject : Symbol(thisObject, Decl(thisTypeInNativeThisAssignableMethods.ts, 222, 13)) - - options.forEach(function (val, index) { ->options.forEach : Symbol(Array.forEach, Decl(lib.es5.d.ts, --, --)) ->options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 221, 10)) ->forEach : Symbol(Array.forEach, Decl(lib.es5.d.ts, --, --)) ->val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 234, 34)) ->index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 234, 38)) - - return val === this.options[index]; ->val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 234, 34)) ->index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 234, 38)) - - }, thisObject); ->thisObject : Symbol(thisObject, Decl(thisTypeInNativeThisAssignableMethods.ts, 222, 13)) - - options.map(function (val, index) { ->options.map : Symbol(Array.map, Decl(lib.es5.d.ts, --, --)) ->options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 221, 10)) ->map : Symbol(Array.map, Decl(lib.es5.d.ts, --, --)) ->val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 238, 30)) ->index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 238, 34)) - - if (val === this.options[index]) ->val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 238, 30)) ->index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 238, 34)) - - return this.options[index]; ->index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 238, 34)) - - }, thisObject); ->thisObject : Symbol(thisObject, Decl(thisTypeInNativeThisAssignableMethods.ts, 222, 13)) - - options.some(function (val, index) { ->options.some : Symbol(Array.some, Decl(lib.es5.d.ts, --, --)) ->options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 221, 10)) ->some : Symbol(Array.some, Decl(lib.es5.d.ts, --, --)) ->val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 243, 31)) ->index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 243, 35)) - - return val === this.options[index]; ->val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 243, 31)) ->index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 243, 35)) - - }, thisObject); ->thisObject : Symbol(thisObject, Decl(thisTypeInNativeThisAssignableMethods.ts, 222, 13)) - - options.filter(function (val, index) { ->options.filter : Symbol(Array.filter, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) ->options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 221, 10)) ->filter : Symbol(Array.filter, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) ->val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 247, 33)) ->index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 247, 37)) - - return val === this.options[index]; ->val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 247, 33)) ->index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 247, 37)) - - }, thisObject); ->thisObject : Symbol(thisObject, Decl(thisTypeInNativeThisAssignableMethods.ts, 222, 13)) - - options.every(function (val, index) { ->options.every : Symbol(Array.every, Decl(lib.es5.d.ts, --, --)) ->options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 221, 10)) ->every : Symbol(Array.every, Decl(lib.es5.d.ts, --, --)) ->val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 251, 32)) ->index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 251, 36)) - - return val === this.options[index]; ->val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 251, 32)) ->index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 251, 36)) - - }, thisObject); ->thisObject : Symbol(thisObject, Decl(thisTypeInNativeThisAssignableMethods.ts, 222, 13)) - } - - test6(options: Int16Array[]) { ->test6 : Symbol(A.test6, Decl(thisTypeInNativeThisAssignableMethods.ts, 254, 5)) ->options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 256, 10)) ->Int16Array : Symbol(Int16Array, Decl(lib.es2016.array.include.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) - - const thisObject = { ->thisObject : Symbol(thisObject, Decl(thisTypeInNativeThisAssignableMethods.ts, 257, 13)) - - options: [] as Int16Array[] ->options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 257, 28)) ->Int16Array : Symbol(Int16Array, Decl(lib.es2016.array.include.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) - - }; - - options.find(function (val, index) { ->options.find : Symbol(Array.find, Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --)) ->options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 256, 10)) ->find : Symbol(Array.find, Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --)) ->val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 261, 31)) ->index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 261, 35)) - - return val === this.options[index]; ->val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 261, 31)) ->this.options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 257, 28)) ->this : Symbol(this, Decl(lib.es2015.core.d.ts, --, --)) ->options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 257, 28)) ->index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 261, 35)) - - }, thisObject); ->thisObject : Symbol(thisObject, Decl(thisTypeInNativeThisAssignableMethods.ts, 257, 13)) - - options.findIndex(function (val, index) { ->options.findIndex : Symbol(Array.findIndex, Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --)) ->options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 256, 10)) ->findIndex : Symbol(Array.findIndex, Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --)) ->val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 265, 36)) ->index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 265, 40)) - - return val === this.options[index]; ->val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 265, 36)) ->this.options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 257, 28)) ->this : Symbol(this, Decl(lib.es2015.core.d.ts, --, --)) ->options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 257, 28)) ->index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 265, 40)) - - }, thisObject); ->thisObject : Symbol(thisObject, Decl(thisTypeInNativeThisAssignableMethods.ts, 257, 13)) - - options.forEach(function (val, index) { ->options.forEach : Symbol(Array.forEach, Decl(lib.es5.d.ts, --, --)) ->options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 256, 10)) ->forEach : Symbol(Array.forEach, Decl(lib.es5.d.ts, --, --)) ->val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 269, 34)) ->index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 269, 38)) - - return val === this.options[index]; ->val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 269, 34)) ->index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 269, 38)) - - }, thisObject); ->thisObject : Symbol(thisObject, Decl(thisTypeInNativeThisAssignableMethods.ts, 257, 13)) - - options.map(function (val, index) { ->options.map : Symbol(Array.map, Decl(lib.es5.d.ts, --, --)) ->options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 256, 10)) ->map : Symbol(Array.map, Decl(lib.es5.d.ts, --, --)) ->val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 273, 30)) ->index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 273, 34)) - - if (val === this.options[index]) ->val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 273, 30)) ->index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 273, 34)) - - return this.options[index]; ->index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 273, 34)) - - }, thisObject); ->thisObject : Symbol(thisObject, Decl(thisTypeInNativeThisAssignableMethods.ts, 257, 13)) - - options.some(function (val, index) { ->options.some : Symbol(Array.some, Decl(lib.es5.d.ts, --, --)) ->options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 256, 10)) ->some : Symbol(Array.some, Decl(lib.es5.d.ts, --, --)) ->val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 278, 31)) ->index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 278, 35)) - - return val === this.options[index]; ->val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 278, 31)) ->index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 278, 35)) - - }, thisObject); ->thisObject : Symbol(thisObject, Decl(thisTypeInNativeThisAssignableMethods.ts, 257, 13)) - - options.filter(function (val, index) { ->options.filter : Symbol(Array.filter, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) ->options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 256, 10)) ->filter : Symbol(Array.filter, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) ->val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 282, 33)) ->index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 282, 37)) - - return val === this.options[index]; ->val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 282, 33)) ->index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 282, 37)) - - }, thisObject); ->thisObject : Symbol(thisObject, Decl(thisTypeInNativeThisAssignableMethods.ts, 257, 13)) - - options.every(function (val, index) { ->options.every : Symbol(Array.every, Decl(lib.es5.d.ts, --, --)) ->options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 256, 10)) ->every : Symbol(Array.every, Decl(lib.es5.d.ts, --, --)) ->val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 286, 32)) ->index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 286, 36)) - - return val === this.options[index]; ->val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 286, 32)) ->index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 286, 36)) - - }, thisObject); ->thisObject : Symbol(thisObject, Decl(thisTypeInNativeThisAssignableMethods.ts, 257, 13)) - } - - test7(options: Uint16Array[]) { ->test7 : Symbol(A.test7, Decl(thisTypeInNativeThisAssignableMethods.ts, 289, 5)) ->options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 291, 10)) ->Uint16Array : Symbol(Uint16Array, Decl(lib.es2016.array.include.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) - - const thisObject = { ->thisObject : Symbol(thisObject, Decl(thisTypeInNativeThisAssignableMethods.ts, 292, 13)) - - options: [] as Uint16Array[] ->options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 292, 28)) ->Uint16Array : Symbol(Uint16Array, Decl(lib.es2016.array.include.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) - - }; - - options.find(function (val, index) { ->options.find : Symbol(Array.find, Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --)) ->options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 291, 10)) ->find : Symbol(Array.find, Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --)) ->val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 296, 31)) ->index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 296, 35)) - - return val === this.options[index]; ->val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 296, 31)) ->this.options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 292, 28)) ->this : Symbol(this, Decl(lib.es2015.core.d.ts, --, --)) ->options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 292, 28)) ->index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 296, 35)) - - }, thisObject); ->thisObject : Symbol(thisObject, Decl(thisTypeInNativeThisAssignableMethods.ts, 292, 13)) - - options.findIndex(function (val, index) { ->options.findIndex : Symbol(Array.findIndex, Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --)) ->options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 291, 10)) ->findIndex : Symbol(Array.findIndex, Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --)) ->val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 300, 36)) ->index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 300, 40)) - - return val === this.options[index]; ->val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 300, 36)) ->this.options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 292, 28)) ->this : Symbol(this, Decl(lib.es2015.core.d.ts, --, --)) ->options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 292, 28)) ->index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 300, 40)) - - }, thisObject); ->thisObject : Symbol(thisObject, Decl(thisTypeInNativeThisAssignableMethods.ts, 292, 13)) - - options.forEach(function (val, index) { ->options.forEach : Symbol(Array.forEach, Decl(lib.es5.d.ts, --, --)) ->options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 291, 10)) ->forEach : Symbol(Array.forEach, Decl(lib.es5.d.ts, --, --)) ->val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 304, 34)) ->index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 304, 38)) - - return val === this.options[index]; ->val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 304, 34)) ->index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 304, 38)) - - }, thisObject); ->thisObject : Symbol(thisObject, Decl(thisTypeInNativeThisAssignableMethods.ts, 292, 13)) - - options.map(function (val, index) { ->options.map : Symbol(Array.map, Decl(lib.es5.d.ts, --, --)) ->options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 291, 10)) ->map : Symbol(Array.map, Decl(lib.es5.d.ts, --, --)) ->val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 308, 30)) ->index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 308, 34)) - - if (val === this.options[index]) ->val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 308, 30)) ->index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 308, 34)) - - return this.options[index]; ->index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 308, 34)) - - }, thisObject); ->thisObject : Symbol(thisObject, Decl(thisTypeInNativeThisAssignableMethods.ts, 292, 13)) - - options.some(function (val, index) { ->options.some : Symbol(Array.some, Decl(lib.es5.d.ts, --, --)) ->options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 291, 10)) ->some : Symbol(Array.some, Decl(lib.es5.d.ts, --, --)) ->val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 313, 31)) ->index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 313, 35)) - - return val === this.options[index]; ->val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 313, 31)) ->index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 313, 35)) - - }, thisObject); ->thisObject : Symbol(thisObject, Decl(thisTypeInNativeThisAssignableMethods.ts, 292, 13)) - - options.filter(function (val, index) { ->options.filter : Symbol(Array.filter, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) ->options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 291, 10)) ->filter : Symbol(Array.filter, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) ->val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 317, 33)) ->index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 317, 37)) - - return val === this.options[index]; ->val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 317, 33)) ->index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 317, 37)) - - }, thisObject); ->thisObject : Symbol(thisObject, Decl(thisTypeInNativeThisAssignableMethods.ts, 292, 13)) - - options.every(function (val, index) { ->options.every : Symbol(Array.every, Decl(lib.es5.d.ts, --, --)) ->options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 291, 10)) ->every : Symbol(Array.every, Decl(lib.es5.d.ts, --, --)) ->val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 321, 32)) ->index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 321, 36)) - - return val === this.options[index]; ->val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 321, 32)) ->index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 321, 36)) - - }, thisObject); ->thisObject : Symbol(thisObject, Decl(thisTypeInNativeThisAssignableMethods.ts, 292, 13)) - } - - test8(options: Uint32Array[]) { ->test8 : Symbol(A.test8, Decl(thisTypeInNativeThisAssignableMethods.ts, 324, 5)) ->options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 326, 10)) ->Uint32Array : Symbol(Uint32Array, Decl(lib.es2016.array.include.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) - - const thisObject = { ->thisObject : Symbol(thisObject, Decl(thisTypeInNativeThisAssignableMethods.ts, 327, 13)) - - options: [] as Uint32Array[] ->options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 327, 28)) ->Uint32Array : Symbol(Uint32Array, Decl(lib.es2016.array.include.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) - - }; - - options.find(function (val, index) { ->options.find : Symbol(Array.find, Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --)) ->options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 326, 10)) ->find : Symbol(Array.find, Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --)) ->val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 331, 31)) ->index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 331, 35)) - - return val === this.options[index]; ->val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 331, 31)) ->this.options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 327, 28)) ->this : Symbol(this, Decl(lib.es2015.core.d.ts, --, --)) ->options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 327, 28)) ->index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 331, 35)) - - }, thisObject); ->thisObject : Symbol(thisObject, Decl(thisTypeInNativeThisAssignableMethods.ts, 327, 13)) - - options.findIndex(function (val, index) { ->options.findIndex : Symbol(Array.findIndex, Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --)) ->options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 326, 10)) ->findIndex : Symbol(Array.findIndex, Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --)) ->val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 335, 36)) ->index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 335, 40)) - - return val === this.options[index]; ->val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 335, 36)) ->this.options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 327, 28)) ->this : Symbol(this, Decl(lib.es2015.core.d.ts, --, --)) ->options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 327, 28)) ->index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 335, 40)) - - }, thisObject); ->thisObject : Symbol(thisObject, Decl(thisTypeInNativeThisAssignableMethods.ts, 327, 13)) - - options.forEach(function (val, index) { ->options.forEach : Symbol(Array.forEach, Decl(lib.es5.d.ts, --, --)) ->options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 326, 10)) ->forEach : Symbol(Array.forEach, Decl(lib.es5.d.ts, --, --)) ->val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 339, 34)) ->index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 339, 38)) - - return val === this.options[index]; ->val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 339, 34)) ->index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 339, 38)) - - }, thisObject); ->thisObject : Symbol(thisObject, Decl(thisTypeInNativeThisAssignableMethods.ts, 327, 13)) - - options.map(function (val, index) { ->options.map : Symbol(Array.map, Decl(lib.es5.d.ts, --, --)) ->options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 326, 10)) ->map : Symbol(Array.map, Decl(lib.es5.d.ts, --, --)) ->val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 343, 30)) ->index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 343, 34)) - - if (val === this.options[index]) ->val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 343, 30)) ->index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 343, 34)) - - return this.options[index]; ->index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 343, 34)) - - }, thisObject); ->thisObject : Symbol(thisObject, Decl(thisTypeInNativeThisAssignableMethods.ts, 327, 13)) - - options.some(function (val, index) { ->options.some : Symbol(Array.some, Decl(lib.es5.d.ts, --, --)) ->options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 326, 10)) ->some : Symbol(Array.some, Decl(lib.es5.d.ts, --, --)) ->val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 348, 31)) ->index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 348, 35)) - - return val === this.options[index]; ->val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 348, 31)) ->index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 348, 35)) - - }, thisObject); ->thisObject : Symbol(thisObject, Decl(thisTypeInNativeThisAssignableMethods.ts, 327, 13)) - - options.filter(function (val, index) { ->options.filter : Symbol(Array.filter, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) ->options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 326, 10)) ->filter : Symbol(Array.filter, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) ->val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 352, 33)) ->index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 352, 37)) - - return val === this.options[index]; ->val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 352, 33)) ->index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 352, 37)) - - }, thisObject); ->thisObject : Symbol(thisObject, Decl(thisTypeInNativeThisAssignableMethods.ts, 327, 13)) - - options.every(function (val, index) { ->options.every : Symbol(Array.every, Decl(lib.es5.d.ts, --, --)) ->options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 326, 10)) ->every : Symbol(Array.every, Decl(lib.es5.d.ts, --, --)) ->val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 356, 32)) ->index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 356, 36)) - - return val === this.options[index]; ->val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 356, 32)) ->index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 356, 36)) - - }, thisObject); ->thisObject : Symbol(thisObject, Decl(thisTypeInNativeThisAssignableMethods.ts, 327, 13)) - } - - test9(options: Float64Array[]) { ->test9 : Symbol(A.test9, Decl(thisTypeInNativeThisAssignableMethods.ts, 359, 5)) ->options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 361, 10)) ->Float64Array : Symbol(Float64Array, Decl(lib.es2016.array.include.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) - - const thisObject = { ->thisObject : Symbol(thisObject, Decl(thisTypeInNativeThisAssignableMethods.ts, 362, 13)) - - options: [] as Float64Array[] ->options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 362, 28)) ->Float64Array : Symbol(Float64Array, Decl(lib.es2016.array.include.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) - - }; - - options.find(function (val, index) { ->options.find : Symbol(Array.find, Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --)) ->options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 361, 10)) ->find : Symbol(Array.find, Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --)) ->val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 366, 31)) ->index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 366, 35)) - - return val === this.options[index]; ->val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 366, 31)) ->this.options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 362, 28)) ->this : Symbol(this, Decl(lib.es2015.core.d.ts, --, --)) ->options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 362, 28)) ->index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 366, 35)) - - }, thisObject); ->thisObject : Symbol(thisObject, Decl(thisTypeInNativeThisAssignableMethods.ts, 362, 13)) - - options.findIndex(function (val, index) { ->options.findIndex : Symbol(Array.findIndex, Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --)) ->options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 361, 10)) ->findIndex : Symbol(Array.findIndex, Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --)) ->val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 370, 36)) ->index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 370, 40)) - - return val === this.options[index]; ->val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 370, 36)) ->this.options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 362, 28)) ->this : Symbol(this, Decl(lib.es2015.core.d.ts, --, --)) ->options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 362, 28)) ->index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 370, 40)) - - }, thisObject); ->thisObject : Symbol(thisObject, Decl(thisTypeInNativeThisAssignableMethods.ts, 362, 13)) - - options.forEach(function (val, index) { ->options.forEach : Symbol(Array.forEach, Decl(lib.es5.d.ts, --, --)) ->options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 361, 10)) ->forEach : Symbol(Array.forEach, Decl(lib.es5.d.ts, --, --)) ->val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 374, 34)) ->index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 374, 38)) - - return val === this.options[index]; ->val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 374, 34)) ->index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 374, 38)) - - }, thisObject); ->thisObject : Symbol(thisObject, Decl(thisTypeInNativeThisAssignableMethods.ts, 362, 13)) - - options.map(function (val, index) { ->options.map : Symbol(Array.map, Decl(lib.es5.d.ts, --, --)) ->options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 361, 10)) ->map : Symbol(Array.map, Decl(lib.es5.d.ts, --, --)) ->val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 378, 30)) ->index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 378, 34)) - - if (val === this.options[index]) ->val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 378, 30)) ->index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 378, 34)) - - return this.options[index]; ->index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 378, 34)) - - }, thisObject); ->thisObject : Symbol(thisObject, Decl(thisTypeInNativeThisAssignableMethods.ts, 362, 13)) - - options.some(function (val, index) { ->options.some : Symbol(Array.some, Decl(lib.es5.d.ts, --, --)) ->options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 361, 10)) ->some : Symbol(Array.some, Decl(lib.es5.d.ts, --, --)) ->val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 383, 31)) ->index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 383, 35)) - - return val === this.options[index]; ->val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 383, 31)) ->index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 383, 35)) - - }, thisObject); ->thisObject : Symbol(thisObject, Decl(thisTypeInNativeThisAssignableMethods.ts, 362, 13)) - - options.filter(function (val, index) { ->options.filter : Symbol(Array.filter, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) ->options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 361, 10)) ->filter : Symbol(Array.filter, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) ->val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 387, 33)) ->index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 387, 37)) - - return val === this.options[index]; ->val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 387, 33)) ->index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 387, 37)) - - }, thisObject); ->thisObject : Symbol(thisObject, Decl(thisTypeInNativeThisAssignableMethods.ts, 362, 13)) - - options.every(function (val, index) { ->options.every : Symbol(Array.every, Decl(lib.es5.d.ts, --, --)) ->options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 361, 10)) ->every : Symbol(Array.every, Decl(lib.es5.d.ts, --, --)) ->val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 391, 32)) ->index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 391, 36)) - - return val === this.options[index]; ->val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 391, 32)) ->index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 391, 36)) - - }, thisObject); ->thisObject : Symbol(thisObject, Decl(thisTypeInNativeThisAssignableMethods.ts, 362, 13)) - } -} - diff --git a/tests/baselines/reference/thisTypeInNativeThisAssignableMethods.types b/tests/baselines/reference/thisTypeInNativeThisAssignableMethods.types deleted file mode 100644 index fecae87d4b1..00000000000 --- a/tests/baselines/reference/thisTypeInNativeThisAssignableMethods.types +++ /dev/null @@ -1,1931 +0,0 @@ -=== tests/cases/compiler/thisTypeInNativeThisAssignableMethods.ts === -class A { ->A : A - - options: string[]; ->options : string[] - - addOptions(options: string[]) { ->addOptions : (options: string[]) => this ->options : string[] - - if (!this.options) { ->!this.options : boolean ->this.options : string[] ->this : this ->options : string[] - - this.options = []; ->this.options = [] : undefined[] ->this.options : string[] ->this : this ->options : string[] ->[] : undefined[] - } - options.forEach(function (item) { ->options.forEach(function (item) { this.options.push(item); }, this) : void ->options.forEach : (callbackfn: (value: string, index: number, array: string[]) => void, thisArg?: any) => void ->options : string[] ->forEach : (callbackfn: (value: string, index: number, array: string[]) => void, thisArg?: any) => void ->function (item) { this.options.push(item); } : (item: string) => void ->item : string - - this.options.push(item); ->this.options.push(item) : any ->this.options.push : any ->this.options : any ->this : any ->options : any ->push : any ->item : string - - }, this); ->this : this - - return this; ->this : this - } - - testUndefined(options: string[]) { ->testUndefined : (options: string[]) => void ->options : string[] - - const undefinedArr: Array = [] ->undefinedArr : undefined[] ->Array : T[] ->[] : undefined[] - - options.forEach(function () { ->options.forEach(function () { undefinedArr.push(this); }) : void ->options.forEach : (callbackfn: (value: string, index: number, array: string[]) => void, thisArg?: any) => void ->options : string[] ->forEach : (callbackfn: (value: string, index: number, array: string[]) => void, thisArg?: any) => void ->function () { undefinedArr.push(this); } : () => void - - undefinedArr.push(this); ->undefinedArr.push(this) : number ->undefinedArr.push : (...items: undefined[]) => number ->undefinedArr : undefined[] ->push : (...items: undefined[]) => number ->this : any - - }); // case1 - options.forEach(function () { ->options.forEach(function () { undefinedArr.push(this); }, undefined) : void ->options.forEach : (callbackfn: (value: string, index: number, array: string[]) => void, thisArg?: any) => void ->options : string[] ->forEach : (callbackfn: (value: string, index: number, array: string[]) => void, thisArg?: any) => void ->function () { undefinedArr.push(this); } : () => void - - undefinedArr.push(this); ->undefinedArr.push(this) : number ->undefinedArr.push : (...items: undefined[]) => number ->undefinedArr : undefined[] ->push : (...items: undefined[]) => number ->this : any - - }, undefined); // case2 ->undefined : undefined - - options.forEach(function () { ->options.forEach(function () { undefinedArr.push(this); }, null) : void ->options.forEach : (callbackfn: (value: string, index: number, array: string[]) => void, thisArg?: any) => void ->options : string[] ->forEach : (callbackfn: (value: string, index: number, array: string[]) => void, thisArg?: any) => void ->function () { undefinedArr.push(this); } : () => void - - undefinedArr.push(this); ->undefinedArr.push(this) : number ->undefinedArr.push : (...items: undefined[]) => number ->undefinedArr : undefined[] ->push : (...items: undefined[]) => number ->this : any - - }, null); // case3 ->null : null - - const arrLike = {} as ArrayLike ->arrLike : ArrayLike ->{} as ArrayLike : ArrayLike ->{} : {} ->ArrayLike : ArrayLike - - Array.from(arrLike, function (item) { ->Array.from(arrLike, function (item) { return this === undefined ? 2 : 1; }, undefined) : (2 | 1)[] ->Array.from : { (iterable: Iterable, mapfn: (this: void, v: T, k: number) => U): U[]; (iterable: Iterable, mapfn: (this: void, v: T, k: number) => U, thisArg: undefined): U[]; (iterable: Iterable, mapfn: (this: Z, v: T, k: number) => U, thisArg: Z): U[]; (iterable: Iterable): T[]; (arrayLike: ArrayLike, mapfn: (this: void, v: T, k: number) => U): U[]; (arrayLike: ArrayLike, mapfn: (this: void, v: T, k: number) => U, thisArg: undefined): U[]; (arrayLike: ArrayLike, mapfn: (this: Z, v: T, k: number) => U, thisArg: Z): U[]; (arrayLike: ArrayLike): T[]; } ->Array : ArrayConstructor ->from : { (iterable: Iterable, mapfn: (this: void, v: T, k: number) => U): U[]; (iterable: Iterable, mapfn: (this: void, v: T, k: number) => U, thisArg: undefined): U[]; (iterable: Iterable, mapfn: (this: Z, v: T, k: number) => U, thisArg: Z): U[]; (iterable: Iterable): T[]; (arrayLike: ArrayLike, mapfn: (this: void, v: T, k: number) => U): U[]; (arrayLike: ArrayLike, mapfn: (this: void, v: T, k: number) => U, thisArg: undefined): U[]; (arrayLike: ArrayLike, mapfn: (this: Z, v: T, k: number) => U, thisArg: Z): U[]; (arrayLike: ArrayLike): T[]; } ->arrLike : ArrayLike ->function (item) { return this === undefined ? 2 : 1; } : (this: void, item: number) => 2 | 1 ->item : number - - return this === undefined ? 2 : 1; ->this === undefined ? 2 : 1 : 2 | 1 ->this === undefined : boolean ->this : void ->undefined : undefined ->2 : 2 ->1 : 1 - - }, undefined) ->undefined : undefined - - const iterLike = [] as Iterable ->iterLike : Iterable ->[] as Iterable : Iterable ->[] : undefined[] ->Iterable : Iterable - - Array.from(iterLike, function (item) { ->Array.from(iterLike, function (item) { return this === undefined ? 2 : 1; }, undefined) : (2 | 1)[] ->Array.from : { (iterable: Iterable, mapfn: (this: void, v: T, k: number) => U): U[]; (iterable: Iterable, mapfn: (this: void, v: T, k: number) => U, thisArg: undefined): U[]; (iterable: Iterable, mapfn: (this: Z, v: T, k: number) => U, thisArg: Z): U[]; (iterable: Iterable): T[]; (arrayLike: ArrayLike, mapfn: (this: void, v: T, k: number) => U): U[]; (arrayLike: ArrayLike, mapfn: (this: void, v: T, k: number) => U, thisArg: undefined): U[]; (arrayLike: ArrayLike, mapfn: (this: Z, v: T, k: number) => U, thisArg: Z): U[]; (arrayLike: ArrayLike): T[]; } ->Array : ArrayConstructor ->from : { (iterable: Iterable, mapfn: (this: void, v: T, k: number) => U): U[]; (iterable: Iterable, mapfn: (this: void, v: T, k: number) => U, thisArg: undefined): U[]; (iterable: Iterable, mapfn: (this: Z, v: T, k: number) => U, thisArg: Z): U[]; (iterable: Iterable): T[]; (arrayLike: ArrayLike, mapfn: (this: void, v: T, k: number) => U): U[]; (arrayLike: ArrayLike, mapfn: (this: void, v: T, k: number) => U, thisArg: undefined): U[]; (arrayLike: ArrayLike, mapfn: (this: Z, v: T, k: number) => U, thisArg: Z): U[]; (arrayLike: ArrayLike): T[]; } ->iterLike : Iterable ->function (item) { return this === undefined ? 2 : 1; } : (this: void, item: number) => 2 | 1 ->item : number - - return this === undefined ? 2 : 1; ->this === undefined ? 2 : 1 : 2 | 1 ->this === undefined : boolean ->this : void ->undefined : undefined ->2 : 2 ->1 : 1 - - }, undefined) ->undefined : undefined - } - - test(options: string[]) { ->test : (options: string[]) => void ->options : string[] - - const thisObject = { ->thisObject : { options: string[]; } ->{ options: [] as string[] } : { options: string[]; } - - options: [] as string[] ->options : string[] ->[] as string[] : string[] ->[] : undefined[] - - }; - - options.find(function (val, index) { ->options.find(function (val, index) { return val === this.options[index]; }, thisObject) : string ->options.find : { (predicate: (this: void, value: string, index: number, obj: string[]) => boolean): string; (predicate: (this: void, value: string, index: number, obj: string[]) => boolean, thisArg: undefined): string; (predicate: (this: Z, value: string, index: number, obj: string[]) => boolean, thisArg: Z): string; } ->options : string[] ->find : { (predicate: (this: void, value: string, index: number, obj: string[]) => boolean): string; (predicate: (this: void, value: string, index: number, obj: string[]) => boolean, thisArg: undefined): string; (predicate: (this: Z, value: string, index: number, obj: string[]) => boolean, thisArg: Z): string; } ->function (val, index) { return val === this.options[index]; } : (this: { options: string[]; }, val: string, index: number) => boolean ->val : string ->index : number - - return val === this.options[index]; ->val === this.options[index] : boolean ->val : string ->this.options[index] : string ->this.options : string[] ->this : { options: string[]; } ->options : string[] ->index : number - - }, thisObject); ->thisObject : { options: string[]; } - - options.findIndex(function (val, index) { ->options.findIndex(function (val, index) { return val === this.options[index]; }, thisObject) : number ->options.findIndex : { (predicate: (this: void, value: string, index: number, obj: string[]) => boolean): number; (predicate: (this: void, value: string, index: number, obj: string[]) => boolean, thisArg: undefined): number; (predicate: (this: Z, value: string, index: number, obj: string[]) => boolean, thisArg: Z): number; } ->options : string[] ->findIndex : { (predicate: (this: void, value: string, index: number, obj: string[]) => boolean): number; (predicate: (this: void, value: string, index: number, obj: string[]) => boolean, thisArg: undefined): number; (predicate: (this: Z, value: string, index: number, obj: string[]) => boolean, thisArg: Z): number; } ->function (val, index) { return val === this.options[index]; } : (this: { options: string[]; }, val: string, index: number) => boolean ->val : string ->index : number - - return val === this.options[index]; ->val === this.options[index] : boolean ->val : string ->this.options[index] : string ->this.options : string[] ->this : { options: string[]; } ->options : string[] ->index : number - - }, thisObject); ->thisObject : { options: string[]; } - - options.forEach(function (val, index) { ->options.forEach(function (val, index) { return val === this.options[index]; }, thisObject) : void ->options.forEach : (callbackfn: (value: string, index: number, array: string[]) => void, thisArg?: any) => void ->options : string[] ->forEach : (callbackfn: (value: string, index: number, array: string[]) => void, thisArg?: any) => void ->function (val, index) { return val === this.options[index]; } : (val: string, index: number) => boolean ->val : string ->index : number - - return val === this.options[index]; ->val === this.options[index] : boolean ->val : string ->this.options[index] : any ->this.options : any ->this : any ->options : any ->index : number - - }, thisObject); ->thisObject : { options: string[]; } - - options.map(function (val, index) { ->options.map(function (val, index) { if (val === this.options[index]) return this.options[index]; }, thisObject) : any[] ->options.map : (callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any) => U[] ->options : string[] ->map : (callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any) => U[] ->function (val, index) { if (val === this.options[index]) return this.options[index]; } : (val: string, index: number) => any ->val : string ->index : number - - if (val === this.options[index]) ->val === this.options[index] : boolean ->val : string ->this.options[index] : any ->this.options : any ->this : any ->options : any ->index : number - - return this.options[index]; ->this.options[index] : any ->this.options : any ->this : any ->options : any ->index : number - - }, thisObject); ->thisObject : { options: string[]; } - - options.some(function (val, index) { ->options.some(function (val, index) { return val === this.options[index]; }, thisObject) : boolean ->options.some : (callbackfn: (value: string, index: number, array: string[]) => boolean, thisArg?: any) => boolean ->options : string[] ->some : (callbackfn: (value: string, index: number, array: string[]) => boolean, thisArg?: any) => boolean ->function (val, index) { return val === this.options[index]; } : (val: string, index: number) => boolean ->val : string ->index : number - - return val === this.options[index]; ->val === this.options[index] : boolean ->val : string ->this.options[index] : any ->this.options : any ->this : any ->options : any ->index : number - - }, thisObject); ->thisObject : { options: string[]; } - - options.filter(function (val, index) { ->options.filter(function (val, index) { return val === this.options[index]; }, thisObject) : string[] ->options.filter : { (callbackfn: (value: string, index: number, array: string[]) => value is S, thisArg?: any): S[]; (callbackfn: (value: string, index: number, array: string[]) => any, thisArg?: any): string[]; } ->options : string[] ->filter : { (callbackfn: (value: string, index: number, array: string[]) => value is S, thisArg?: any): S[]; (callbackfn: (value: string, index: number, array: string[]) => any, thisArg?: any): string[]; } ->function (val, index) { return val === this.options[index]; } : (val: string, index: number) => boolean ->val : string ->index : number - - return val === this.options[index]; ->val === this.options[index] : boolean ->val : string ->this.options[index] : any ->this.options : any ->this : any ->options : any ->index : number - - }, thisObject); ->thisObject : { options: string[]; } - - options.every(function (val, index) { ->options.every(function (val, index) { return val === this.options[index]; }, thisObject) : boolean ->options.every : (callbackfn: (value: string, index: number, array: string[]) => boolean, thisArg?: any) => boolean ->options : string[] ->every : (callbackfn: (value: string, index: number, array: string[]) => boolean, thisArg?: any) => boolean ->function (val, index) { return val === this.options[index]; } : (val: string, index: number) => boolean ->val : string ->index : number - - return val === this.options[index]; ->val === this.options[index] : boolean ->val : string ->this.options[index] : any ->this.options : any ->this : any ->options : any ->index : number - - }, thisObject); ->thisObject : { options: string[]; } - - const arrLike = {} as ArrayLike ->arrLike : ArrayLike ->{} as ArrayLike : ArrayLike ->{} : {} ->ArrayLike : ArrayLike - - Array.from(arrLike, function (item) { ->Array.from(arrLike, function (item) { return this.options[item].length }, thisObject) : number[] ->Array.from : { (iterable: Iterable, mapfn: (this: void, v: T, k: number) => U): U[]; (iterable: Iterable, mapfn: (this: void, v: T, k: number) => U, thisArg: undefined): U[]; (iterable: Iterable, mapfn: (this: Z, v: T, k: number) => U, thisArg: Z): U[]; (iterable: Iterable): T[]; (arrayLike: ArrayLike, mapfn: (this: void, v: T, k: number) => U): U[]; (arrayLike: ArrayLike, mapfn: (this: void, v: T, k: number) => U, thisArg: undefined): U[]; (arrayLike: ArrayLike, mapfn: (this: Z, v: T, k: number) => U, thisArg: Z): U[]; (arrayLike: ArrayLike): T[]; } ->Array : ArrayConstructor ->from : { (iterable: Iterable, mapfn: (this: void, v: T, k: number) => U): U[]; (iterable: Iterable, mapfn: (this: void, v: T, k: number) => U, thisArg: undefined): U[]; (iterable: Iterable, mapfn: (this: Z, v: T, k: number) => U, thisArg: Z): U[]; (iterable: Iterable): T[]; (arrayLike: ArrayLike, mapfn: (this: void, v: T, k: number) => U): U[]; (arrayLike: ArrayLike, mapfn: (this: void, v: T, k: number) => U, thisArg: undefined): U[]; (arrayLike: ArrayLike, mapfn: (this: Z, v: T, k: number) => U, thisArg: Z): U[]; (arrayLike: ArrayLike): T[]; } ->arrLike : ArrayLike ->function (item) { return this.options[item].length } : (this: { options: string[]; }, item: number) => number ->item : number - - return this.options[item].length ->this.options[item].length : number ->this.options[item] : string ->this.options : string[] ->this : { options: string[]; } ->options : string[] ->item : number ->length : number - - }, thisObject) ->thisObject : { options: string[]; } - - const iterLike = [] as Iterable ->iterLike : Iterable ->[] as Iterable : Iterable ->[] : undefined[] ->Iterable : Iterable - - Array.from(iterLike, function (item) { ->Array.from(iterLike, function (item) { return this.options[item].length }, thisObject) : number[] ->Array.from : { (iterable: Iterable, mapfn: (this: void, v: T, k: number) => U): U[]; (iterable: Iterable, mapfn: (this: void, v: T, k: number) => U, thisArg: undefined): U[]; (iterable: Iterable, mapfn: (this: Z, v: T, k: number) => U, thisArg: Z): U[]; (iterable: Iterable): T[]; (arrayLike: ArrayLike, mapfn: (this: void, v: T, k: number) => U): U[]; (arrayLike: ArrayLike, mapfn: (this: void, v: T, k: number) => U, thisArg: undefined): U[]; (arrayLike: ArrayLike, mapfn: (this: Z, v: T, k: number) => U, thisArg: Z): U[]; (arrayLike: ArrayLike): T[]; } ->Array : ArrayConstructor ->from : { (iterable: Iterable, mapfn: (this: void, v: T, k: number) => U): U[]; (iterable: Iterable, mapfn: (this: void, v: T, k: number) => U, thisArg: undefined): U[]; (iterable: Iterable, mapfn: (this: Z, v: T, k: number) => U, thisArg: Z): U[]; (iterable: Iterable): T[]; (arrayLike: ArrayLike, mapfn: (this: void, v: T, k: number) => U): U[]; (arrayLike: ArrayLike, mapfn: (this: void, v: T, k: number) => U, thisArg: undefined): U[]; (arrayLike: ArrayLike, mapfn: (this: Z, v: T, k: number) => U, thisArg: Z): U[]; (arrayLike: ArrayLike): T[]; } ->iterLike : Iterable ->function (item) { return this.options[item].length } : (this: { options: string[]; }, item: number) => number ->item : number - - return this.options[item].length ->this.options[item].length : number ->this.options[item] : string ->this.options : string[] ->this : { options: string[]; } ->options : string[] ->item : number ->length : number - - }, thisObject) ->thisObject : { options: string[]; } - } - - test1(options: string[]) { ->test1 : (options: string[]) => void ->options : string[] - - const thisObject = { ->thisObject : { options: ReadonlyArray; } ->{ options: [] as ReadonlyArray } : { options: ReadonlyArray; } - - options: [] as ReadonlyArray ->options : ReadonlyArray ->[] as ReadonlyArray : ReadonlyArray ->[] : undefined[] ->ReadonlyArray : ReadonlyArray - - }; - - options.find(function (val, index) { ->options.find(function (val, index) { return val === this.options[index]; }, thisObject) : string ->options.find : { (predicate: (this: void, value: string, index: number, obj: string[]) => boolean): string; (predicate: (this: void, value: string, index: number, obj: string[]) => boolean, thisArg: undefined): string; (predicate: (this: Z, value: string, index: number, obj: string[]) => boolean, thisArg: Z): string; } ->options : string[] ->find : { (predicate: (this: void, value: string, index: number, obj: string[]) => boolean): string; (predicate: (this: void, value: string, index: number, obj: string[]) => boolean, thisArg: undefined): string; (predicate: (this: Z, value: string, index: number, obj: string[]) => boolean, thisArg: Z): string; } ->function (val, index) { return val === this.options[index]; } : (this: { options: ReadonlyArray; }, val: string, index: number) => boolean ->val : string ->index : number - - return val === this.options[index]; ->val === this.options[index] : boolean ->val : string ->this.options[index] : string ->this.options : ReadonlyArray ->this : { options: ReadonlyArray; } ->options : ReadonlyArray ->index : number - - }, thisObject); ->thisObject : { options: ReadonlyArray; } - - options.findIndex(function (val, index) { ->options.findIndex(function (val, index) { return val === this.options[index]; }, thisObject) : number ->options.findIndex : { (predicate: (this: void, value: string, index: number, obj: string[]) => boolean): number; (predicate: (this: void, value: string, index: number, obj: string[]) => boolean, thisArg: undefined): number; (predicate: (this: Z, value: string, index: number, obj: string[]) => boolean, thisArg: Z): number; } ->options : string[] ->findIndex : { (predicate: (this: void, value: string, index: number, obj: string[]) => boolean): number; (predicate: (this: void, value: string, index: number, obj: string[]) => boolean, thisArg: undefined): number; (predicate: (this: Z, value: string, index: number, obj: string[]) => boolean, thisArg: Z): number; } ->function (val, index) { return val === this.options[index]; } : (this: { options: ReadonlyArray; }, val: string, index: number) => boolean ->val : string ->index : number - - return val === this.options[index]; ->val === this.options[index] : boolean ->val : string ->this.options[index] : string ->this.options : ReadonlyArray ->this : { options: ReadonlyArray; } ->options : ReadonlyArray ->index : number - - }, thisObject); ->thisObject : { options: ReadonlyArray; } - - options.forEach(function (val, index) { ->options.forEach(function (val, index) { return val === this.options[index]; }, thisObject) : void ->options.forEach : (callbackfn: (value: string, index: number, array: string[]) => void, thisArg?: any) => void ->options : string[] ->forEach : (callbackfn: (value: string, index: number, array: string[]) => void, thisArg?: any) => void ->function (val, index) { return val === this.options[index]; } : (val: string, index: number) => boolean ->val : string ->index : number - - return val === this.options[index]; ->val === this.options[index] : boolean ->val : string ->this.options[index] : any ->this.options : any ->this : any ->options : any ->index : number - - }, thisObject); ->thisObject : { options: ReadonlyArray; } - - options.map(function (val, index) { ->options.map(function (val, index) { if (val === this.options[index]) return this.options[index]; }, thisObject) : any[] ->options.map : (callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any) => U[] ->options : string[] ->map : (callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any) => U[] ->function (val, index) { if (val === this.options[index]) return this.options[index]; } : (val: string, index: number) => any ->val : string ->index : number - - if (val === this.options[index]) ->val === this.options[index] : boolean ->val : string ->this.options[index] : any ->this.options : any ->this : any ->options : any ->index : number - - return this.options[index]; ->this.options[index] : any ->this.options : any ->this : any ->options : any ->index : number - - }, thisObject); ->thisObject : { options: ReadonlyArray; } - - options.some(function (val, index) { ->options.some(function (val, index) { return val === this.options[index]; }, thisObject) : boolean ->options.some : (callbackfn: (value: string, index: number, array: string[]) => boolean, thisArg?: any) => boolean ->options : string[] ->some : (callbackfn: (value: string, index: number, array: string[]) => boolean, thisArg?: any) => boolean ->function (val, index) { return val === this.options[index]; } : (val: string, index: number) => boolean ->val : string ->index : number - - return val === this.options[index]; ->val === this.options[index] : boolean ->val : string ->this.options[index] : any ->this.options : any ->this : any ->options : any ->index : number - - }, thisObject); ->thisObject : { options: ReadonlyArray; } - - options.filter(function (val, index) { ->options.filter(function (val, index) { return val === this.options[index]; }, thisObject) : string[] ->options.filter : { (callbackfn: (value: string, index: number, array: string[]) => value is S, thisArg?: any): S[]; (callbackfn: (value: string, index: number, array: string[]) => any, thisArg?: any): string[]; } ->options : string[] ->filter : { (callbackfn: (value: string, index: number, array: string[]) => value is S, thisArg?: any): S[]; (callbackfn: (value: string, index: number, array: string[]) => any, thisArg?: any): string[]; } ->function (val, index) { return val === this.options[index]; } : (val: string, index: number) => boolean ->val : string ->index : number - - return val === this.options[index]; ->val === this.options[index] : boolean ->val : string ->this.options[index] : any ->this.options : any ->this : any ->options : any ->index : number - - }, thisObject); ->thisObject : { options: ReadonlyArray; } - - options.every(function (val, index) { ->options.every(function (val, index) { return val === this.options[index]; }, thisObject) : boolean ->options.every : (callbackfn: (value: string, index: number, array: string[]) => boolean, thisArg?: any) => boolean ->options : string[] ->every : (callbackfn: (value: string, index: number, array: string[]) => boolean, thisArg?: any) => boolean ->function (val, index) { return val === this.options[index]; } : (val: string, index: number) => boolean ->val : string ->index : number - - return val === this.options[index]; ->val === this.options[index] : boolean ->val : string ->this.options[index] : any ->this.options : any ->this : any ->options : any ->index : number - - }, thisObject); ->thisObject : { options: ReadonlyArray; } - } - - test2(options: Int8Array[]) { ->test2 : (options: Int8Array[]) => void ->options : Int8Array[] ->Int8Array : Int8Array - - const thisObject = { ->thisObject : { options: Int8Array[]; } ->{ options: [] as Int8Array[] } : { options: Int8Array[]; } - - options: [] as Int8Array[] ->options : Int8Array[] ->[] as Int8Array[] : Int8Array[] ->[] : undefined[] ->Int8Array : Int8Array - - }; - - options.find(function (val, index) { ->options.find(function (val, index) { return val === this.options[index]; }, thisObject) : Int8Array ->options.find : { (predicate: (this: void, value: Int8Array, index: number, obj: Int8Array[]) => boolean): Int8Array; (predicate: (this: void, value: Int8Array, index: number, obj: Int8Array[]) => boolean, thisArg: undefined): Int8Array; (predicate: (this: Z, value: Int8Array, index: number, obj: Int8Array[]) => boolean, thisArg: Z): Int8Array; } ->options : Int8Array[] ->find : { (predicate: (this: void, value: Int8Array, index: number, obj: Int8Array[]) => boolean): Int8Array; (predicate: (this: void, value: Int8Array, index: number, obj: Int8Array[]) => boolean, thisArg: undefined): Int8Array; (predicate: (this: Z, value: Int8Array, index: number, obj: Int8Array[]) => boolean, thisArg: Z): Int8Array; } ->function (val, index) { return val === this.options[index]; } : (this: { options: Int8Array[]; }, val: Int8Array, index: number) => boolean ->val : Int8Array ->index : number - - return val === this.options[index]; ->val === this.options[index] : boolean ->val : Int8Array ->this.options[index] : Int8Array ->this.options : Int8Array[] ->this : { options: Int8Array[]; } ->options : Int8Array[] ->index : number - - }, thisObject); ->thisObject : { options: Int8Array[]; } - - options.findIndex(function (val, index) { ->options.findIndex(function (val, index) { return val === this.options[index]; }, thisObject) : number ->options.findIndex : { (predicate: (this: void, value: Int8Array, index: number, obj: Int8Array[]) => boolean): number; (predicate: (this: void, value: Int8Array, index: number, obj: Int8Array[]) => boolean, thisArg: undefined): number; (predicate: (this: Z, value: Int8Array, index: number, obj: Int8Array[]) => boolean, thisArg: Z): number; } ->options : Int8Array[] ->findIndex : { (predicate: (this: void, value: Int8Array, index: number, obj: Int8Array[]) => boolean): number; (predicate: (this: void, value: Int8Array, index: number, obj: Int8Array[]) => boolean, thisArg: undefined): number; (predicate: (this: Z, value: Int8Array, index: number, obj: Int8Array[]) => boolean, thisArg: Z): number; } ->function (val, index) { return val === this.options[index]; } : (this: { options: Int8Array[]; }, val: Int8Array, index: number) => boolean ->val : Int8Array ->index : number - - return val === this.options[index]; ->val === this.options[index] : boolean ->val : Int8Array ->this.options[index] : Int8Array ->this.options : Int8Array[] ->this : { options: Int8Array[]; } ->options : Int8Array[] ->index : number - - }, thisObject); ->thisObject : { options: Int8Array[]; } - - options.forEach(function (val, index) { ->options.forEach(function (val, index) { return val === this.options[index]; }, thisObject) : void ->options.forEach : (callbackfn: (value: Int8Array, index: number, array: Int8Array[]) => void, thisArg?: any) => void ->options : Int8Array[] ->forEach : (callbackfn: (value: Int8Array, index: number, array: Int8Array[]) => void, thisArg?: any) => void ->function (val, index) { return val === this.options[index]; } : (val: Int8Array, index: number) => boolean ->val : Int8Array ->index : number - - return val === this.options[index]; ->val === this.options[index] : boolean ->val : Int8Array ->this.options[index] : any ->this.options : any ->this : any ->options : any ->index : number - - }, thisObject); ->thisObject : { options: Int8Array[]; } - - options.map(function (val, index) { ->options.map(function (val, index) { if (val === this.options[index]) return this.options[index]; }, thisObject) : any[] ->options.map : (callbackfn: (value: Int8Array, index: number, array: Int8Array[]) => U, thisArg?: any) => U[] ->options : Int8Array[] ->map : (callbackfn: (value: Int8Array, index: number, array: Int8Array[]) => U, thisArg?: any) => U[] ->function (val, index) { if (val === this.options[index]) return this.options[index]; } : (val: Int8Array, index: number) => any ->val : Int8Array ->index : number - - if (val === this.options[index]) ->val === this.options[index] : boolean ->val : Int8Array ->this.options[index] : any ->this.options : any ->this : any ->options : any ->index : number - - return this.options[index]; ->this.options[index] : any ->this.options : any ->this : any ->options : any ->index : number - - }, thisObject); ->thisObject : { options: Int8Array[]; } - - options.some(function (val, index) { ->options.some(function (val, index) { return val === this.options[index]; }, thisObject) : boolean ->options.some : (callbackfn: (value: Int8Array, index: number, array: Int8Array[]) => boolean, thisArg?: any) => boolean ->options : Int8Array[] ->some : (callbackfn: (value: Int8Array, index: number, array: Int8Array[]) => boolean, thisArg?: any) => boolean ->function (val, index) { return val === this.options[index]; } : (val: Int8Array, index: number) => boolean ->val : Int8Array ->index : number - - return val === this.options[index]; ->val === this.options[index] : boolean ->val : Int8Array ->this.options[index] : any ->this.options : any ->this : any ->options : any ->index : number - - }, thisObject); ->thisObject : { options: Int8Array[]; } - - options.filter(function (val, index) { ->options.filter(function (val, index) { return val === this.options[index]; }, thisObject) : Int8Array[] ->options.filter : { (callbackfn: (value: Int8Array, index: number, array: Int8Array[]) => value is S, thisArg?: any): S[]; (callbackfn: (value: Int8Array, index: number, array: Int8Array[]) => any, thisArg?: any): Int8Array[]; } ->options : Int8Array[] ->filter : { (callbackfn: (value: Int8Array, index: number, array: Int8Array[]) => value is S, thisArg?: any): S[]; (callbackfn: (value: Int8Array, index: number, array: Int8Array[]) => any, thisArg?: any): Int8Array[]; } ->function (val, index) { return val === this.options[index]; } : (val: Int8Array, index: number) => boolean ->val : Int8Array ->index : number - - return val === this.options[index]; ->val === this.options[index] : boolean ->val : Int8Array ->this.options[index] : any ->this.options : any ->this : any ->options : any ->index : number - - }, thisObject); ->thisObject : { options: Int8Array[]; } - - options.every(function (val, index) { ->options.every(function (val, index) { return val === this.options[index]; }, thisObject) : boolean ->options.every : (callbackfn: (value: Int8Array, index: number, array: Int8Array[]) => boolean, thisArg?: any) => boolean ->options : Int8Array[] ->every : (callbackfn: (value: Int8Array, index: number, array: Int8Array[]) => boolean, thisArg?: any) => boolean ->function (val, index) { return val === this.options[index]; } : (val: Int8Array, index: number) => boolean ->val : Int8Array ->index : number - - return val === this.options[index]; ->val === this.options[index] : boolean ->val : Int8Array ->this.options[index] : any ->this.options : any ->this : any ->options : any ->index : number - - }, thisObject); ->thisObject : { options: Int8Array[]; } - } - - test3(options: Uint8Array[]) { ->test3 : (options: Uint8Array[]) => void ->options : Uint8Array[] ->Uint8Array : Uint8Array - - const thisObject = { ->thisObject : { options: Uint8Array[]; } ->{ options: [] as Uint8Array[] } : { options: Uint8Array[]; } - - options: [] as Uint8Array[] ->options : Uint8Array[] ->[] as Uint8Array[] : Uint8Array[] ->[] : undefined[] ->Uint8Array : Uint8Array - - }; - - options.find(function (val, index) { ->options.find(function (val, index) { return val === this.options[index]; }, thisObject) : Uint8Array ->options.find : { (predicate: (this: void, value: Uint8Array, index: number, obj: Uint8Array[]) => boolean): Uint8Array; (predicate: (this: void, value: Uint8Array, index: number, obj: Uint8Array[]) => boolean, thisArg: undefined): Uint8Array; (predicate: (this: Z, value: Uint8Array, index: number, obj: Uint8Array[]) => boolean, thisArg: Z): Uint8Array; } ->options : Uint8Array[] ->find : { (predicate: (this: void, value: Uint8Array, index: number, obj: Uint8Array[]) => boolean): Uint8Array; (predicate: (this: void, value: Uint8Array, index: number, obj: Uint8Array[]) => boolean, thisArg: undefined): Uint8Array; (predicate: (this: Z, value: Uint8Array, index: number, obj: Uint8Array[]) => boolean, thisArg: Z): Uint8Array; } ->function (val, index) { return val === this.options[index]; } : (this: { options: Uint8Array[]; }, val: Uint8Array, index: number) => boolean ->val : Uint8Array ->index : number - - return val === this.options[index]; ->val === this.options[index] : boolean ->val : Uint8Array ->this.options[index] : Uint8Array ->this.options : Uint8Array[] ->this : { options: Uint8Array[]; } ->options : Uint8Array[] ->index : number - - }, thisObject); ->thisObject : { options: Uint8Array[]; } - - options.findIndex(function (val, index) { ->options.findIndex(function (val, index) { return val === this.options[index]; }, thisObject) : number ->options.findIndex : { (predicate: (this: void, value: Uint8Array, index: number, obj: Uint8Array[]) => boolean): number; (predicate: (this: void, value: Uint8Array, index: number, obj: Uint8Array[]) => boolean, thisArg: undefined): number; (predicate: (this: Z, value: Uint8Array, index: number, obj: Uint8Array[]) => boolean, thisArg: Z): number; } ->options : Uint8Array[] ->findIndex : { (predicate: (this: void, value: Uint8Array, index: number, obj: Uint8Array[]) => boolean): number; (predicate: (this: void, value: Uint8Array, index: number, obj: Uint8Array[]) => boolean, thisArg: undefined): number; (predicate: (this: Z, value: Uint8Array, index: number, obj: Uint8Array[]) => boolean, thisArg: Z): number; } ->function (val, index) { return val === this.options[index]; } : (this: { options: Uint8Array[]; }, val: Uint8Array, index: number) => boolean ->val : Uint8Array ->index : number - - return val === this.options[index]; ->val === this.options[index] : boolean ->val : Uint8Array ->this.options[index] : Uint8Array ->this.options : Uint8Array[] ->this : { options: Uint8Array[]; } ->options : Uint8Array[] ->index : number - - }, thisObject); ->thisObject : { options: Uint8Array[]; } - - options.forEach(function (val, index) { ->options.forEach(function (val, index) { return val === this.options[index]; }, thisObject) : void ->options.forEach : (callbackfn: (value: Uint8Array, index: number, array: Uint8Array[]) => void, thisArg?: any) => void ->options : Uint8Array[] ->forEach : (callbackfn: (value: Uint8Array, index: number, array: Uint8Array[]) => void, thisArg?: any) => void ->function (val, index) { return val === this.options[index]; } : (val: Uint8Array, index: number) => boolean ->val : Uint8Array ->index : number - - return val === this.options[index]; ->val === this.options[index] : boolean ->val : Uint8Array ->this.options[index] : any ->this.options : any ->this : any ->options : any ->index : number - - }, thisObject); ->thisObject : { options: Uint8Array[]; } - - options.map(function (val, index) { ->options.map(function (val, index) { if (val === this.options[index]) return this.options[index]; }, thisObject) : any[] ->options.map : (callbackfn: (value: Uint8Array, index: number, array: Uint8Array[]) => U, thisArg?: any) => U[] ->options : Uint8Array[] ->map : (callbackfn: (value: Uint8Array, index: number, array: Uint8Array[]) => U, thisArg?: any) => U[] ->function (val, index) { if (val === this.options[index]) return this.options[index]; } : (val: Uint8Array, index: number) => any ->val : Uint8Array ->index : number - - if (val === this.options[index]) ->val === this.options[index] : boolean ->val : Uint8Array ->this.options[index] : any ->this.options : any ->this : any ->options : any ->index : number - - return this.options[index]; ->this.options[index] : any ->this.options : any ->this : any ->options : any ->index : number - - }, thisObject); ->thisObject : { options: Uint8Array[]; } - - options.some(function (val, index) { ->options.some(function (val, index) { return val === this.options[index]; }, thisObject) : boolean ->options.some : (callbackfn: (value: Uint8Array, index: number, array: Uint8Array[]) => boolean, thisArg?: any) => boolean ->options : Uint8Array[] ->some : (callbackfn: (value: Uint8Array, index: number, array: Uint8Array[]) => boolean, thisArg?: any) => boolean ->function (val, index) { return val === this.options[index]; } : (val: Uint8Array, index: number) => boolean ->val : Uint8Array ->index : number - - return val === this.options[index]; ->val === this.options[index] : boolean ->val : Uint8Array ->this.options[index] : any ->this.options : any ->this : any ->options : any ->index : number - - }, thisObject); ->thisObject : { options: Uint8Array[]; } - - options.filter(function (val, index) { ->options.filter(function (val, index) { return val === this.options[index]; }, thisObject) : Uint8Array[] ->options.filter : { (callbackfn: (value: Uint8Array, index: number, array: Uint8Array[]) => value is S, thisArg?: any): S[]; (callbackfn: (value: Uint8Array, index: number, array: Uint8Array[]) => any, thisArg?: any): Uint8Array[]; } ->options : Uint8Array[] ->filter : { (callbackfn: (value: Uint8Array, index: number, array: Uint8Array[]) => value is S, thisArg?: any): S[]; (callbackfn: (value: Uint8Array, index: number, array: Uint8Array[]) => any, thisArg?: any): Uint8Array[]; } ->function (val, index) { return val === this.options[index]; } : (val: Uint8Array, index: number) => boolean ->val : Uint8Array ->index : number - - return val === this.options[index]; ->val === this.options[index] : boolean ->val : Uint8Array ->this.options[index] : any ->this.options : any ->this : any ->options : any ->index : number - - }, thisObject); ->thisObject : { options: Uint8Array[]; } - - options.every(function (val, index) { ->options.every(function (val, index) { return val === this.options[index]; }, thisObject) : boolean ->options.every : (callbackfn: (value: Uint8Array, index: number, array: Uint8Array[]) => boolean, thisArg?: any) => boolean ->options : Uint8Array[] ->every : (callbackfn: (value: Uint8Array, index: number, array: Uint8Array[]) => boolean, thisArg?: any) => boolean ->function (val, index) { return val === this.options[index]; } : (val: Uint8Array, index: number) => boolean ->val : Uint8Array ->index : number - - return val === this.options[index]; ->val === this.options[index] : boolean ->val : Uint8Array ->this.options[index] : any ->this.options : any ->this : any ->options : any ->index : number - - }, thisObject); ->thisObject : { options: Uint8Array[]; } - } - - test4(options: Float32Array[]) { ->test4 : (options: Float32Array[]) => void ->options : Float32Array[] ->Float32Array : Float32Array - - const thisObject = { ->thisObject : { options: Float32Array[]; } ->{ options: [] as Float32Array[] } : { options: Float32Array[]; } - - options: [] as Float32Array[] ->options : Float32Array[] ->[] as Float32Array[] : Float32Array[] ->[] : undefined[] ->Float32Array : Float32Array - - }; - - options.find(function (val, index) { ->options.find(function (val, index) { return val === this.options[index]; }, thisObject) : Float32Array ->options.find : { (predicate: (this: void, value: Float32Array, index: number, obj: Float32Array[]) => boolean): Float32Array; (predicate: (this: void, value: Float32Array, index: number, obj: Float32Array[]) => boolean, thisArg: undefined): Float32Array; (predicate: (this: Z, value: Float32Array, index: number, obj: Float32Array[]) => boolean, thisArg: Z): Float32Array; } ->options : Float32Array[] ->find : { (predicate: (this: void, value: Float32Array, index: number, obj: Float32Array[]) => boolean): Float32Array; (predicate: (this: void, value: Float32Array, index: number, obj: Float32Array[]) => boolean, thisArg: undefined): Float32Array; (predicate: (this: Z, value: Float32Array, index: number, obj: Float32Array[]) => boolean, thisArg: Z): Float32Array; } ->function (val, index) { return val === this.options[index]; } : (this: { options: Float32Array[]; }, val: Float32Array, index: number) => boolean ->val : Float32Array ->index : number - - return val === this.options[index]; ->val === this.options[index] : boolean ->val : Float32Array ->this.options[index] : Float32Array ->this.options : Float32Array[] ->this : { options: Float32Array[]; } ->options : Float32Array[] ->index : number - - }, thisObject); ->thisObject : { options: Float32Array[]; } - - options.findIndex(function (val, index) { ->options.findIndex(function (val, index) { return val === this.options[index]; }, thisObject) : number ->options.findIndex : { (predicate: (this: void, value: Float32Array, index: number, obj: Float32Array[]) => boolean): number; (predicate: (this: void, value: Float32Array, index: number, obj: Float32Array[]) => boolean, thisArg: undefined): number; (predicate: (this: Z, value: Float32Array, index: number, obj: Float32Array[]) => boolean, thisArg: Z): number; } ->options : Float32Array[] ->findIndex : { (predicate: (this: void, value: Float32Array, index: number, obj: Float32Array[]) => boolean): number; (predicate: (this: void, value: Float32Array, index: number, obj: Float32Array[]) => boolean, thisArg: undefined): number; (predicate: (this: Z, value: Float32Array, index: number, obj: Float32Array[]) => boolean, thisArg: Z): number; } ->function (val, index) { return val === this.options[index]; } : (this: { options: Float32Array[]; }, val: Float32Array, index: number) => boolean ->val : Float32Array ->index : number - - return val === this.options[index]; ->val === this.options[index] : boolean ->val : Float32Array ->this.options[index] : Float32Array ->this.options : Float32Array[] ->this : { options: Float32Array[]; } ->options : Float32Array[] ->index : number - - }, thisObject); ->thisObject : { options: Float32Array[]; } - - options.forEach(function (val, index) { ->options.forEach(function (val, index) { return val === this.options[index]; }, thisObject) : void ->options.forEach : (callbackfn: (value: Float32Array, index: number, array: Float32Array[]) => void, thisArg?: any) => void ->options : Float32Array[] ->forEach : (callbackfn: (value: Float32Array, index: number, array: Float32Array[]) => void, thisArg?: any) => void ->function (val, index) { return val === this.options[index]; } : (val: Float32Array, index: number) => boolean ->val : Float32Array ->index : number - - return val === this.options[index]; ->val === this.options[index] : boolean ->val : Float32Array ->this.options[index] : any ->this.options : any ->this : any ->options : any ->index : number - - }, thisObject); ->thisObject : { options: Float32Array[]; } - - options.map(function (val, index) { ->options.map(function (val, index) { if (val === this.options[index]) return this.options[index]; }, thisObject) : any[] ->options.map : (callbackfn: (value: Float32Array, index: number, array: Float32Array[]) => U, thisArg?: any) => U[] ->options : Float32Array[] ->map : (callbackfn: (value: Float32Array, index: number, array: Float32Array[]) => U, thisArg?: any) => U[] ->function (val, index) { if (val === this.options[index]) return this.options[index]; } : (val: Float32Array, index: number) => any ->val : Float32Array ->index : number - - if (val === this.options[index]) ->val === this.options[index] : boolean ->val : Float32Array ->this.options[index] : any ->this.options : any ->this : any ->options : any ->index : number - - return this.options[index]; ->this.options[index] : any ->this.options : any ->this : any ->options : any ->index : number - - }, thisObject); ->thisObject : { options: Float32Array[]; } - - options.some(function (val, index) { ->options.some(function (val, index) { return val === this.options[index]; }, thisObject) : boolean ->options.some : (callbackfn: (value: Float32Array, index: number, array: Float32Array[]) => boolean, thisArg?: any) => boolean ->options : Float32Array[] ->some : (callbackfn: (value: Float32Array, index: number, array: Float32Array[]) => boolean, thisArg?: any) => boolean ->function (val, index) { return val === this.options[index]; } : (val: Float32Array, index: number) => boolean ->val : Float32Array ->index : number - - return val === this.options[index]; ->val === this.options[index] : boolean ->val : Float32Array ->this.options[index] : any ->this.options : any ->this : any ->options : any ->index : number - - }, thisObject); ->thisObject : { options: Float32Array[]; } - - options.filter(function (val, index) { ->options.filter(function (val, index) { return val === this.options[index]; }, thisObject) : Float32Array[] ->options.filter : { (callbackfn: (value: Float32Array, index: number, array: Float32Array[]) => value is S, thisArg?: any): S[]; (callbackfn: (value: Float32Array, index: number, array: Float32Array[]) => any, thisArg?: any): Float32Array[]; } ->options : Float32Array[] ->filter : { (callbackfn: (value: Float32Array, index: number, array: Float32Array[]) => value is S, thisArg?: any): S[]; (callbackfn: (value: Float32Array, index: number, array: Float32Array[]) => any, thisArg?: any): Float32Array[]; } ->function (val, index) { return val === this.options[index]; } : (val: Float32Array, index: number) => boolean ->val : Float32Array ->index : number - - return val === this.options[index]; ->val === this.options[index] : boolean ->val : Float32Array ->this.options[index] : any ->this.options : any ->this : any ->options : any ->index : number - - }, thisObject); ->thisObject : { options: Float32Array[]; } - - options.every(function (val, index) { ->options.every(function (val, index) { return val === this.options[index]; }, thisObject) : boolean ->options.every : (callbackfn: (value: Float32Array, index: number, array: Float32Array[]) => boolean, thisArg?: any) => boolean ->options : Float32Array[] ->every : (callbackfn: (value: Float32Array, index: number, array: Float32Array[]) => boolean, thisArg?: any) => boolean ->function (val, index) { return val === this.options[index]; } : (val: Float32Array, index: number) => boolean ->val : Float32Array ->index : number - - return val === this.options[index]; ->val === this.options[index] : boolean ->val : Float32Array ->this.options[index] : any ->this.options : any ->this : any ->options : any ->index : number - - }, thisObject); ->thisObject : { options: Float32Array[]; } - } - - test5(options: Uint8ClampedArray[]) { ->test5 : (options: Uint8ClampedArray[]) => void ->options : Uint8ClampedArray[] ->Uint8ClampedArray : Uint8ClampedArray - - const thisObject = { ->thisObject : { options: Uint8ClampedArray[]; } ->{ options: [] as Uint8ClampedArray[] } : { options: Uint8ClampedArray[]; } - - options: [] as Uint8ClampedArray[] ->options : Uint8ClampedArray[] ->[] as Uint8ClampedArray[] : Uint8ClampedArray[] ->[] : undefined[] ->Uint8ClampedArray : Uint8ClampedArray - - }; - - options.find(function (val, index) { ->options.find(function (val, index) { return val === this.options[index]; }, thisObject) : Uint8ClampedArray ->options.find : { (predicate: (this: void, value: Uint8ClampedArray, index: number, obj: Uint8ClampedArray[]) => boolean): Uint8ClampedArray; (predicate: (this: void, value: Uint8ClampedArray, index: number, obj: Uint8ClampedArray[]) => boolean, thisArg: undefined): Uint8ClampedArray; (predicate: (this: Z, value: Uint8ClampedArray, index: number, obj: Uint8ClampedArray[]) => boolean, thisArg: Z): Uint8ClampedArray; } ->options : Uint8ClampedArray[] ->find : { (predicate: (this: void, value: Uint8ClampedArray, index: number, obj: Uint8ClampedArray[]) => boolean): Uint8ClampedArray; (predicate: (this: void, value: Uint8ClampedArray, index: number, obj: Uint8ClampedArray[]) => boolean, thisArg: undefined): Uint8ClampedArray; (predicate: (this: Z, value: Uint8ClampedArray, index: number, obj: Uint8ClampedArray[]) => boolean, thisArg: Z): Uint8ClampedArray; } ->function (val, index) { return val === this.options[index]; } : (this: { options: Uint8ClampedArray[]; }, val: Uint8ClampedArray, index: number) => boolean ->val : Uint8ClampedArray ->index : number - - return val === this.options[index]; ->val === this.options[index] : boolean ->val : Uint8ClampedArray ->this.options[index] : Uint8ClampedArray ->this.options : Uint8ClampedArray[] ->this : { options: Uint8ClampedArray[]; } ->options : Uint8ClampedArray[] ->index : number - - }, thisObject); ->thisObject : { options: Uint8ClampedArray[]; } - - options.findIndex(function (val, index) { ->options.findIndex(function (val, index) { return val === this.options[index]; }, thisObject) : number ->options.findIndex : { (predicate: (this: void, value: Uint8ClampedArray, index: number, obj: Uint8ClampedArray[]) => boolean): number; (predicate: (this: void, value: Uint8ClampedArray, index: number, obj: Uint8ClampedArray[]) => boolean, thisArg: undefined): number; (predicate: (this: Z, value: Uint8ClampedArray, index: number, obj: Uint8ClampedArray[]) => boolean, thisArg: Z): number; } ->options : Uint8ClampedArray[] ->findIndex : { (predicate: (this: void, value: Uint8ClampedArray, index: number, obj: Uint8ClampedArray[]) => boolean): number; (predicate: (this: void, value: Uint8ClampedArray, index: number, obj: Uint8ClampedArray[]) => boolean, thisArg: undefined): number; (predicate: (this: Z, value: Uint8ClampedArray, index: number, obj: Uint8ClampedArray[]) => boolean, thisArg: Z): number; } ->function (val, index) { return val === this.options[index]; } : (this: { options: Uint8ClampedArray[]; }, val: Uint8ClampedArray, index: number) => boolean ->val : Uint8ClampedArray ->index : number - - return val === this.options[index]; ->val === this.options[index] : boolean ->val : Uint8ClampedArray ->this.options[index] : Uint8ClampedArray ->this.options : Uint8ClampedArray[] ->this : { options: Uint8ClampedArray[]; } ->options : Uint8ClampedArray[] ->index : number - - }, thisObject); ->thisObject : { options: Uint8ClampedArray[]; } - - options.forEach(function (val, index) { ->options.forEach(function (val, index) { return val === this.options[index]; }, thisObject) : void ->options.forEach : (callbackfn: (value: Uint8ClampedArray, index: number, array: Uint8ClampedArray[]) => void, thisArg?: any) => void ->options : Uint8ClampedArray[] ->forEach : (callbackfn: (value: Uint8ClampedArray, index: number, array: Uint8ClampedArray[]) => void, thisArg?: any) => void ->function (val, index) { return val === this.options[index]; } : (val: Uint8ClampedArray, index: number) => boolean ->val : Uint8ClampedArray ->index : number - - return val === this.options[index]; ->val === this.options[index] : boolean ->val : Uint8ClampedArray ->this.options[index] : any ->this.options : any ->this : any ->options : any ->index : number - - }, thisObject); ->thisObject : { options: Uint8ClampedArray[]; } - - options.map(function (val, index) { ->options.map(function (val, index) { if (val === this.options[index]) return this.options[index]; }, thisObject) : any[] ->options.map : (callbackfn: (value: Uint8ClampedArray, index: number, array: Uint8ClampedArray[]) => U, thisArg?: any) => U[] ->options : Uint8ClampedArray[] ->map : (callbackfn: (value: Uint8ClampedArray, index: number, array: Uint8ClampedArray[]) => U, thisArg?: any) => U[] ->function (val, index) { if (val === this.options[index]) return this.options[index]; } : (val: Uint8ClampedArray, index: number) => any ->val : Uint8ClampedArray ->index : number - - if (val === this.options[index]) ->val === this.options[index] : boolean ->val : Uint8ClampedArray ->this.options[index] : any ->this.options : any ->this : any ->options : any ->index : number - - return this.options[index]; ->this.options[index] : any ->this.options : any ->this : any ->options : any ->index : number - - }, thisObject); ->thisObject : { options: Uint8ClampedArray[]; } - - options.some(function (val, index) { ->options.some(function (val, index) { return val === this.options[index]; }, thisObject) : boolean ->options.some : (callbackfn: (value: Uint8ClampedArray, index: number, array: Uint8ClampedArray[]) => boolean, thisArg?: any) => boolean ->options : Uint8ClampedArray[] ->some : (callbackfn: (value: Uint8ClampedArray, index: number, array: Uint8ClampedArray[]) => boolean, thisArg?: any) => boolean ->function (val, index) { return val === this.options[index]; } : (val: Uint8ClampedArray, index: number) => boolean ->val : Uint8ClampedArray ->index : number - - return val === this.options[index]; ->val === this.options[index] : boolean ->val : Uint8ClampedArray ->this.options[index] : any ->this.options : any ->this : any ->options : any ->index : number - - }, thisObject); ->thisObject : { options: Uint8ClampedArray[]; } - - options.filter(function (val, index) { ->options.filter(function (val, index) { return val === this.options[index]; }, thisObject) : Uint8ClampedArray[] ->options.filter : { (callbackfn: (value: Uint8ClampedArray, index: number, array: Uint8ClampedArray[]) => value is S, thisArg?: any): S[]; (callbackfn: (value: Uint8ClampedArray, index: number, array: Uint8ClampedArray[]) => any, thisArg?: any): Uint8ClampedArray[]; } ->options : Uint8ClampedArray[] ->filter : { (callbackfn: (value: Uint8ClampedArray, index: number, array: Uint8ClampedArray[]) => value is S, thisArg?: any): S[]; (callbackfn: (value: Uint8ClampedArray, index: number, array: Uint8ClampedArray[]) => any, thisArg?: any): Uint8ClampedArray[]; } ->function (val, index) { return val === this.options[index]; } : (val: Uint8ClampedArray, index: number) => boolean ->val : Uint8ClampedArray ->index : number - - return val === this.options[index]; ->val === this.options[index] : boolean ->val : Uint8ClampedArray ->this.options[index] : any ->this.options : any ->this : any ->options : any ->index : number - - }, thisObject); ->thisObject : { options: Uint8ClampedArray[]; } - - options.every(function (val, index) { ->options.every(function (val, index) { return val === this.options[index]; }, thisObject) : boolean ->options.every : (callbackfn: (value: Uint8ClampedArray, index: number, array: Uint8ClampedArray[]) => boolean, thisArg?: any) => boolean ->options : Uint8ClampedArray[] ->every : (callbackfn: (value: Uint8ClampedArray, index: number, array: Uint8ClampedArray[]) => boolean, thisArg?: any) => boolean ->function (val, index) { return val === this.options[index]; } : (val: Uint8ClampedArray, index: number) => boolean ->val : Uint8ClampedArray ->index : number - - return val === this.options[index]; ->val === this.options[index] : boolean ->val : Uint8ClampedArray ->this.options[index] : any ->this.options : any ->this : any ->options : any ->index : number - - }, thisObject); ->thisObject : { options: Uint8ClampedArray[]; } - } - - test6(options: Int16Array[]) { ->test6 : (options: Int16Array[]) => void ->options : Int16Array[] ->Int16Array : Int16Array - - const thisObject = { ->thisObject : { options: Int16Array[]; } ->{ options: [] as Int16Array[] } : { options: Int16Array[]; } - - options: [] as Int16Array[] ->options : Int16Array[] ->[] as Int16Array[] : Int16Array[] ->[] : undefined[] ->Int16Array : Int16Array - - }; - - options.find(function (val, index) { ->options.find(function (val, index) { return val === this.options[index]; }, thisObject) : Int16Array ->options.find : { (predicate: (this: void, value: Int16Array, index: number, obj: Int16Array[]) => boolean): Int16Array; (predicate: (this: void, value: Int16Array, index: number, obj: Int16Array[]) => boolean, thisArg: undefined): Int16Array; (predicate: (this: Z, value: Int16Array, index: number, obj: Int16Array[]) => boolean, thisArg: Z): Int16Array; } ->options : Int16Array[] ->find : { (predicate: (this: void, value: Int16Array, index: number, obj: Int16Array[]) => boolean): Int16Array; (predicate: (this: void, value: Int16Array, index: number, obj: Int16Array[]) => boolean, thisArg: undefined): Int16Array; (predicate: (this: Z, value: Int16Array, index: number, obj: Int16Array[]) => boolean, thisArg: Z): Int16Array; } ->function (val, index) { return val === this.options[index]; } : (this: { options: Int16Array[]; }, val: Int16Array, index: number) => boolean ->val : Int16Array ->index : number - - return val === this.options[index]; ->val === this.options[index] : boolean ->val : Int16Array ->this.options[index] : Int16Array ->this.options : Int16Array[] ->this : { options: Int16Array[]; } ->options : Int16Array[] ->index : number - - }, thisObject); ->thisObject : { options: Int16Array[]; } - - options.findIndex(function (val, index) { ->options.findIndex(function (val, index) { return val === this.options[index]; }, thisObject) : number ->options.findIndex : { (predicate: (this: void, value: Int16Array, index: number, obj: Int16Array[]) => boolean): number; (predicate: (this: void, value: Int16Array, index: number, obj: Int16Array[]) => boolean, thisArg: undefined): number; (predicate: (this: Z, value: Int16Array, index: number, obj: Int16Array[]) => boolean, thisArg: Z): number; } ->options : Int16Array[] ->findIndex : { (predicate: (this: void, value: Int16Array, index: number, obj: Int16Array[]) => boolean): number; (predicate: (this: void, value: Int16Array, index: number, obj: Int16Array[]) => boolean, thisArg: undefined): number; (predicate: (this: Z, value: Int16Array, index: number, obj: Int16Array[]) => boolean, thisArg: Z): number; } ->function (val, index) { return val === this.options[index]; } : (this: { options: Int16Array[]; }, val: Int16Array, index: number) => boolean ->val : Int16Array ->index : number - - return val === this.options[index]; ->val === this.options[index] : boolean ->val : Int16Array ->this.options[index] : Int16Array ->this.options : Int16Array[] ->this : { options: Int16Array[]; } ->options : Int16Array[] ->index : number - - }, thisObject); ->thisObject : { options: Int16Array[]; } - - options.forEach(function (val, index) { ->options.forEach(function (val, index) { return val === this.options[index]; }, thisObject) : void ->options.forEach : (callbackfn: (value: Int16Array, index: number, array: Int16Array[]) => void, thisArg?: any) => void ->options : Int16Array[] ->forEach : (callbackfn: (value: Int16Array, index: number, array: Int16Array[]) => void, thisArg?: any) => void ->function (val, index) { return val === this.options[index]; } : (val: Int16Array, index: number) => boolean ->val : Int16Array ->index : number - - return val === this.options[index]; ->val === this.options[index] : boolean ->val : Int16Array ->this.options[index] : any ->this.options : any ->this : any ->options : any ->index : number - - }, thisObject); ->thisObject : { options: Int16Array[]; } - - options.map(function (val, index) { ->options.map(function (val, index) { if (val === this.options[index]) return this.options[index]; }, thisObject) : any[] ->options.map : (callbackfn: (value: Int16Array, index: number, array: Int16Array[]) => U, thisArg?: any) => U[] ->options : Int16Array[] ->map : (callbackfn: (value: Int16Array, index: number, array: Int16Array[]) => U, thisArg?: any) => U[] ->function (val, index) { if (val === this.options[index]) return this.options[index]; } : (val: Int16Array, index: number) => any ->val : Int16Array ->index : number - - if (val === this.options[index]) ->val === this.options[index] : boolean ->val : Int16Array ->this.options[index] : any ->this.options : any ->this : any ->options : any ->index : number - - return this.options[index]; ->this.options[index] : any ->this.options : any ->this : any ->options : any ->index : number - - }, thisObject); ->thisObject : { options: Int16Array[]; } - - options.some(function (val, index) { ->options.some(function (val, index) { return val === this.options[index]; }, thisObject) : boolean ->options.some : (callbackfn: (value: Int16Array, index: number, array: Int16Array[]) => boolean, thisArg?: any) => boolean ->options : Int16Array[] ->some : (callbackfn: (value: Int16Array, index: number, array: Int16Array[]) => boolean, thisArg?: any) => boolean ->function (val, index) { return val === this.options[index]; } : (val: Int16Array, index: number) => boolean ->val : Int16Array ->index : number - - return val === this.options[index]; ->val === this.options[index] : boolean ->val : Int16Array ->this.options[index] : any ->this.options : any ->this : any ->options : any ->index : number - - }, thisObject); ->thisObject : { options: Int16Array[]; } - - options.filter(function (val, index) { ->options.filter(function (val, index) { return val === this.options[index]; }, thisObject) : Int16Array[] ->options.filter : { (callbackfn: (value: Int16Array, index: number, array: Int16Array[]) => value is S, thisArg?: any): S[]; (callbackfn: (value: Int16Array, index: number, array: Int16Array[]) => any, thisArg?: any): Int16Array[]; } ->options : Int16Array[] ->filter : { (callbackfn: (value: Int16Array, index: number, array: Int16Array[]) => value is S, thisArg?: any): S[]; (callbackfn: (value: Int16Array, index: number, array: Int16Array[]) => any, thisArg?: any): Int16Array[]; } ->function (val, index) { return val === this.options[index]; } : (val: Int16Array, index: number) => boolean ->val : Int16Array ->index : number - - return val === this.options[index]; ->val === this.options[index] : boolean ->val : Int16Array ->this.options[index] : any ->this.options : any ->this : any ->options : any ->index : number - - }, thisObject); ->thisObject : { options: Int16Array[]; } - - options.every(function (val, index) { ->options.every(function (val, index) { return val === this.options[index]; }, thisObject) : boolean ->options.every : (callbackfn: (value: Int16Array, index: number, array: Int16Array[]) => boolean, thisArg?: any) => boolean ->options : Int16Array[] ->every : (callbackfn: (value: Int16Array, index: number, array: Int16Array[]) => boolean, thisArg?: any) => boolean ->function (val, index) { return val === this.options[index]; } : (val: Int16Array, index: number) => boolean ->val : Int16Array ->index : number - - return val === this.options[index]; ->val === this.options[index] : boolean ->val : Int16Array ->this.options[index] : any ->this.options : any ->this : any ->options : any ->index : number - - }, thisObject); ->thisObject : { options: Int16Array[]; } - } - - test7(options: Uint16Array[]) { ->test7 : (options: Uint16Array[]) => void ->options : Uint16Array[] ->Uint16Array : Uint16Array - - const thisObject = { ->thisObject : { options: Uint16Array[]; } ->{ options: [] as Uint16Array[] } : { options: Uint16Array[]; } - - options: [] as Uint16Array[] ->options : Uint16Array[] ->[] as Uint16Array[] : Uint16Array[] ->[] : undefined[] ->Uint16Array : Uint16Array - - }; - - options.find(function (val, index) { ->options.find(function (val, index) { return val === this.options[index]; }, thisObject) : Uint16Array ->options.find : { (predicate: (this: void, value: Uint16Array, index: number, obj: Uint16Array[]) => boolean): Uint16Array; (predicate: (this: void, value: Uint16Array, index: number, obj: Uint16Array[]) => boolean, thisArg: undefined): Uint16Array; (predicate: (this: Z, value: Uint16Array, index: number, obj: Uint16Array[]) => boolean, thisArg: Z): Uint16Array; } ->options : Uint16Array[] ->find : { (predicate: (this: void, value: Uint16Array, index: number, obj: Uint16Array[]) => boolean): Uint16Array; (predicate: (this: void, value: Uint16Array, index: number, obj: Uint16Array[]) => boolean, thisArg: undefined): Uint16Array; (predicate: (this: Z, value: Uint16Array, index: number, obj: Uint16Array[]) => boolean, thisArg: Z): Uint16Array; } ->function (val, index) { return val === this.options[index]; } : (this: { options: Uint16Array[]; }, val: Uint16Array, index: number) => boolean ->val : Uint16Array ->index : number - - return val === this.options[index]; ->val === this.options[index] : boolean ->val : Uint16Array ->this.options[index] : Uint16Array ->this.options : Uint16Array[] ->this : { options: Uint16Array[]; } ->options : Uint16Array[] ->index : number - - }, thisObject); ->thisObject : { options: Uint16Array[]; } - - options.findIndex(function (val, index) { ->options.findIndex(function (val, index) { return val === this.options[index]; }, thisObject) : number ->options.findIndex : { (predicate: (this: void, value: Uint16Array, index: number, obj: Uint16Array[]) => boolean): number; (predicate: (this: void, value: Uint16Array, index: number, obj: Uint16Array[]) => boolean, thisArg: undefined): number; (predicate: (this: Z, value: Uint16Array, index: number, obj: Uint16Array[]) => boolean, thisArg: Z): number; } ->options : Uint16Array[] ->findIndex : { (predicate: (this: void, value: Uint16Array, index: number, obj: Uint16Array[]) => boolean): number; (predicate: (this: void, value: Uint16Array, index: number, obj: Uint16Array[]) => boolean, thisArg: undefined): number; (predicate: (this: Z, value: Uint16Array, index: number, obj: Uint16Array[]) => boolean, thisArg: Z): number; } ->function (val, index) { return val === this.options[index]; } : (this: { options: Uint16Array[]; }, val: Uint16Array, index: number) => boolean ->val : Uint16Array ->index : number - - return val === this.options[index]; ->val === this.options[index] : boolean ->val : Uint16Array ->this.options[index] : Uint16Array ->this.options : Uint16Array[] ->this : { options: Uint16Array[]; } ->options : Uint16Array[] ->index : number - - }, thisObject); ->thisObject : { options: Uint16Array[]; } - - options.forEach(function (val, index) { ->options.forEach(function (val, index) { return val === this.options[index]; }, thisObject) : void ->options.forEach : (callbackfn: (value: Uint16Array, index: number, array: Uint16Array[]) => void, thisArg?: any) => void ->options : Uint16Array[] ->forEach : (callbackfn: (value: Uint16Array, index: number, array: Uint16Array[]) => void, thisArg?: any) => void ->function (val, index) { return val === this.options[index]; } : (val: Uint16Array, index: number) => boolean ->val : Uint16Array ->index : number - - return val === this.options[index]; ->val === this.options[index] : boolean ->val : Uint16Array ->this.options[index] : any ->this.options : any ->this : any ->options : any ->index : number - - }, thisObject); ->thisObject : { options: Uint16Array[]; } - - options.map(function (val, index) { ->options.map(function (val, index) { if (val === this.options[index]) return this.options[index]; }, thisObject) : any[] ->options.map : (callbackfn: (value: Uint16Array, index: number, array: Uint16Array[]) => U, thisArg?: any) => U[] ->options : Uint16Array[] ->map : (callbackfn: (value: Uint16Array, index: number, array: Uint16Array[]) => U, thisArg?: any) => U[] ->function (val, index) { if (val === this.options[index]) return this.options[index]; } : (val: Uint16Array, index: number) => any ->val : Uint16Array ->index : number - - if (val === this.options[index]) ->val === this.options[index] : boolean ->val : Uint16Array ->this.options[index] : any ->this.options : any ->this : any ->options : any ->index : number - - return this.options[index]; ->this.options[index] : any ->this.options : any ->this : any ->options : any ->index : number - - }, thisObject); ->thisObject : { options: Uint16Array[]; } - - options.some(function (val, index) { ->options.some(function (val, index) { return val === this.options[index]; }, thisObject) : boolean ->options.some : (callbackfn: (value: Uint16Array, index: number, array: Uint16Array[]) => boolean, thisArg?: any) => boolean ->options : Uint16Array[] ->some : (callbackfn: (value: Uint16Array, index: number, array: Uint16Array[]) => boolean, thisArg?: any) => boolean ->function (val, index) { return val === this.options[index]; } : (val: Uint16Array, index: number) => boolean ->val : Uint16Array ->index : number - - return val === this.options[index]; ->val === this.options[index] : boolean ->val : Uint16Array ->this.options[index] : any ->this.options : any ->this : any ->options : any ->index : number - - }, thisObject); ->thisObject : { options: Uint16Array[]; } - - options.filter(function (val, index) { ->options.filter(function (val, index) { return val === this.options[index]; }, thisObject) : Uint16Array[] ->options.filter : { (callbackfn: (value: Uint16Array, index: number, array: Uint16Array[]) => value is S, thisArg?: any): S[]; (callbackfn: (value: Uint16Array, index: number, array: Uint16Array[]) => any, thisArg?: any): Uint16Array[]; } ->options : Uint16Array[] ->filter : { (callbackfn: (value: Uint16Array, index: number, array: Uint16Array[]) => value is S, thisArg?: any): S[]; (callbackfn: (value: Uint16Array, index: number, array: Uint16Array[]) => any, thisArg?: any): Uint16Array[]; } ->function (val, index) { return val === this.options[index]; } : (val: Uint16Array, index: number) => boolean ->val : Uint16Array ->index : number - - return val === this.options[index]; ->val === this.options[index] : boolean ->val : Uint16Array ->this.options[index] : any ->this.options : any ->this : any ->options : any ->index : number - - }, thisObject); ->thisObject : { options: Uint16Array[]; } - - options.every(function (val, index) { ->options.every(function (val, index) { return val === this.options[index]; }, thisObject) : boolean ->options.every : (callbackfn: (value: Uint16Array, index: number, array: Uint16Array[]) => boolean, thisArg?: any) => boolean ->options : Uint16Array[] ->every : (callbackfn: (value: Uint16Array, index: number, array: Uint16Array[]) => boolean, thisArg?: any) => boolean ->function (val, index) { return val === this.options[index]; } : (val: Uint16Array, index: number) => boolean ->val : Uint16Array ->index : number - - return val === this.options[index]; ->val === this.options[index] : boolean ->val : Uint16Array ->this.options[index] : any ->this.options : any ->this : any ->options : any ->index : number - - }, thisObject); ->thisObject : { options: Uint16Array[]; } - } - - test8(options: Uint32Array[]) { ->test8 : (options: Uint32Array[]) => void ->options : Uint32Array[] ->Uint32Array : Uint32Array - - const thisObject = { ->thisObject : { options: Uint32Array[]; } ->{ options: [] as Uint32Array[] } : { options: Uint32Array[]; } - - options: [] as Uint32Array[] ->options : Uint32Array[] ->[] as Uint32Array[] : Uint32Array[] ->[] : undefined[] ->Uint32Array : Uint32Array - - }; - - options.find(function (val, index) { ->options.find(function (val, index) { return val === this.options[index]; }, thisObject) : Uint32Array ->options.find : { (predicate: (this: void, value: Uint32Array, index: number, obj: Uint32Array[]) => boolean): Uint32Array; (predicate: (this: void, value: Uint32Array, index: number, obj: Uint32Array[]) => boolean, thisArg: undefined): Uint32Array; (predicate: (this: Z, value: Uint32Array, index: number, obj: Uint32Array[]) => boolean, thisArg: Z): Uint32Array; } ->options : Uint32Array[] ->find : { (predicate: (this: void, value: Uint32Array, index: number, obj: Uint32Array[]) => boolean): Uint32Array; (predicate: (this: void, value: Uint32Array, index: number, obj: Uint32Array[]) => boolean, thisArg: undefined): Uint32Array; (predicate: (this: Z, value: Uint32Array, index: number, obj: Uint32Array[]) => boolean, thisArg: Z): Uint32Array; } ->function (val, index) { return val === this.options[index]; } : (this: { options: Uint32Array[]; }, val: Uint32Array, index: number) => boolean ->val : Uint32Array ->index : number - - return val === this.options[index]; ->val === this.options[index] : boolean ->val : Uint32Array ->this.options[index] : Uint32Array ->this.options : Uint32Array[] ->this : { options: Uint32Array[]; } ->options : Uint32Array[] ->index : number - - }, thisObject); ->thisObject : { options: Uint32Array[]; } - - options.findIndex(function (val, index) { ->options.findIndex(function (val, index) { return val === this.options[index]; }, thisObject) : number ->options.findIndex : { (predicate: (this: void, value: Uint32Array, index: number, obj: Uint32Array[]) => boolean): number; (predicate: (this: void, value: Uint32Array, index: number, obj: Uint32Array[]) => boolean, thisArg: undefined): number; (predicate: (this: Z, value: Uint32Array, index: number, obj: Uint32Array[]) => boolean, thisArg: Z): number; } ->options : Uint32Array[] ->findIndex : { (predicate: (this: void, value: Uint32Array, index: number, obj: Uint32Array[]) => boolean): number; (predicate: (this: void, value: Uint32Array, index: number, obj: Uint32Array[]) => boolean, thisArg: undefined): number; (predicate: (this: Z, value: Uint32Array, index: number, obj: Uint32Array[]) => boolean, thisArg: Z): number; } ->function (val, index) { return val === this.options[index]; } : (this: { options: Uint32Array[]; }, val: Uint32Array, index: number) => boolean ->val : Uint32Array ->index : number - - return val === this.options[index]; ->val === this.options[index] : boolean ->val : Uint32Array ->this.options[index] : Uint32Array ->this.options : Uint32Array[] ->this : { options: Uint32Array[]; } ->options : Uint32Array[] ->index : number - - }, thisObject); ->thisObject : { options: Uint32Array[]; } - - options.forEach(function (val, index) { ->options.forEach(function (val, index) { return val === this.options[index]; }, thisObject) : void ->options.forEach : (callbackfn: (value: Uint32Array, index: number, array: Uint32Array[]) => void, thisArg?: any) => void ->options : Uint32Array[] ->forEach : (callbackfn: (value: Uint32Array, index: number, array: Uint32Array[]) => void, thisArg?: any) => void ->function (val, index) { return val === this.options[index]; } : (val: Uint32Array, index: number) => boolean ->val : Uint32Array ->index : number - - return val === this.options[index]; ->val === this.options[index] : boolean ->val : Uint32Array ->this.options[index] : any ->this.options : any ->this : any ->options : any ->index : number - - }, thisObject); ->thisObject : { options: Uint32Array[]; } - - options.map(function (val, index) { ->options.map(function (val, index) { if (val === this.options[index]) return this.options[index]; }, thisObject) : any[] ->options.map : (callbackfn: (value: Uint32Array, index: number, array: Uint32Array[]) => U, thisArg?: any) => U[] ->options : Uint32Array[] ->map : (callbackfn: (value: Uint32Array, index: number, array: Uint32Array[]) => U, thisArg?: any) => U[] ->function (val, index) { if (val === this.options[index]) return this.options[index]; } : (val: Uint32Array, index: number) => any ->val : Uint32Array ->index : number - - if (val === this.options[index]) ->val === this.options[index] : boolean ->val : Uint32Array ->this.options[index] : any ->this.options : any ->this : any ->options : any ->index : number - - return this.options[index]; ->this.options[index] : any ->this.options : any ->this : any ->options : any ->index : number - - }, thisObject); ->thisObject : { options: Uint32Array[]; } - - options.some(function (val, index) { ->options.some(function (val, index) { return val === this.options[index]; }, thisObject) : boolean ->options.some : (callbackfn: (value: Uint32Array, index: number, array: Uint32Array[]) => boolean, thisArg?: any) => boolean ->options : Uint32Array[] ->some : (callbackfn: (value: Uint32Array, index: number, array: Uint32Array[]) => boolean, thisArg?: any) => boolean ->function (val, index) { return val === this.options[index]; } : (val: Uint32Array, index: number) => boolean ->val : Uint32Array ->index : number - - return val === this.options[index]; ->val === this.options[index] : boolean ->val : Uint32Array ->this.options[index] : any ->this.options : any ->this : any ->options : any ->index : number - - }, thisObject); ->thisObject : { options: Uint32Array[]; } - - options.filter(function (val, index) { ->options.filter(function (val, index) { return val === this.options[index]; }, thisObject) : Uint32Array[] ->options.filter : { (callbackfn: (value: Uint32Array, index: number, array: Uint32Array[]) => value is S, thisArg?: any): S[]; (callbackfn: (value: Uint32Array, index: number, array: Uint32Array[]) => any, thisArg?: any): Uint32Array[]; } ->options : Uint32Array[] ->filter : { (callbackfn: (value: Uint32Array, index: number, array: Uint32Array[]) => value is S, thisArg?: any): S[]; (callbackfn: (value: Uint32Array, index: number, array: Uint32Array[]) => any, thisArg?: any): Uint32Array[]; } ->function (val, index) { return val === this.options[index]; } : (val: Uint32Array, index: number) => boolean ->val : Uint32Array ->index : number - - return val === this.options[index]; ->val === this.options[index] : boolean ->val : Uint32Array ->this.options[index] : any ->this.options : any ->this : any ->options : any ->index : number - - }, thisObject); ->thisObject : { options: Uint32Array[]; } - - options.every(function (val, index) { ->options.every(function (val, index) { return val === this.options[index]; }, thisObject) : boolean ->options.every : (callbackfn: (value: Uint32Array, index: number, array: Uint32Array[]) => boolean, thisArg?: any) => boolean ->options : Uint32Array[] ->every : (callbackfn: (value: Uint32Array, index: number, array: Uint32Array[]) => boolean, thisArg?: any) => boolean ->function (val, index) { return val === this.options[index]; } : (val: Uint32Array, index: number) => boolean ->val : Uint32Array ->index : number - - return val === this.options[index]; ->val === this.options[index] : boolean ->val : Uint32Array ->this.options[index] : any ->this.options : any ->this : any ->options : any ->index : number - - }, thisObject); ->thisObject : { options: Uint32Array[]; } - } - - test9(options: Float64Array[]) { ->test9 : (options: Float64Array[]) => void ->options : Float64Array[] ->Float64Array : Float64Array - - const thisObject = { ->thisObject : { options: Float64Array[]; } ->{ options: [] as Float64Array[] } : { options: Float64Array[]; } - - options: [] as Float64Array[] ->options : Float64Array[] ->[] as Float64Array[] : Float64Array[] ->[] : undefined[] ->Float64Array : Float64Array - - }; - - options.find(function (val, index) { ->options.find(function (val, index) { return val === this.options[index]; }, thisObject) : Float64Array ->options.find : { (predicate: (this: void, value: Float64Array, index: number, obj: Float64Array[]) => boolean): Float64Array; (predicate: (this: void, value: Float64Array, index: number, obj: Float64Array[]) => boolean, thisArg: undefined): Float64Array; (predicate: (this: Z, value: Float64Array, index: number, obj: Float64Array[]) => boolean, thisArg: Z): Float64Array; } ->options : Float64Array[] ->find : { (predicate: (this: void, value: Float64Array, index: number, obj: Float64Array[]) => boolean): Float64Array; (predicate: (this: void, value: Float64Array, index: number, obj: Float64Array[]) => boolean, thisArg: undefined): Float64Array; (predicate: (this: Z, value: Float64Array, index: number, obj: Float64Array[]) => boolean, thisArg: Z): Float64Array; } ->function (val, index) { return val === this.options[index]; } : (this: { options: Float64Array[]; }, val: Float64Array, index: number) => boolean ->val : Float64Array ->index : number - - return val === this.options[index]; ->val === this.options[index] : boolean ->val : Float64Array ->this.options[index] : Float64Array ->this.options : Float64Array[] ->this : { options: Float64Array[]; } ->options : Float64Array[] ->index : number - - }, thisObject); ->thisObject : { options: Float64Array[]; } - - options.findIndex(function (val, index) { ->options.findIndex(function (val, index) { return val === this.options[index]; }, thisObject) : number ->options.findIndex : { (predicate: (this: void, value: Float64Array, index: number, obj: Float64Array[]) => boolean): number; (predicate: (this: void, value: Float64Array, index: number, obj: Float64Array[]) => boolean, thisArg: undefined): number; (predicate: (this: Z, value: Float64Array, index: number, obj: Float64Array[]) => boolean, thisArg: Z): number; } ->options : Float64Array[] ->findIndex : { (predicate: (this: void, value: Float64Array, index: number, obj: Float64Array[]) => boolean): number; (predicate: (this: void, value: Float64Array, index: number, obj: Float64Array[]) => boolean, thisArg: undefined): number; (predicate: (this: Z, value: Float64Array, index: number, obj: Float64Array[]) => boolean, thisArg: Z): number; } ->function (val, index) { return val === this.options[index]; } : (this: { options: Float64Array[]; }, val: Float64Array, index: number) => boolean ->val : Float64Array ->index : number - - return val === this.options[index]; ->val === this.options[index] : boolean ->val : Float64Array ->this.options[index] : Float64Array ->this.options : Float64Array[] ->this : { options: Float64Array[]; } ->options : Float64Array[] ->index : number - - }, thisObject); ->thisObject : { options: Float64Array[]; } - - options.forEach(function (val, index) { ->options.forEach(function (val, index) { return val === this.options[index]; }, thisObject) : void ->options.forEach : (callbackfn: (value: Float64Array, index: number, array: Float64Array[]) => void, thisArg?: any) => void ->options : Float64Array[] ->forEach : (callbackfn: (value: Float64Array, index: number, array: Float64Array[]) => void, thisArg?: any) => void ->function (val, index) { return val === this.options[index]; } : (val: Float64Array, index: number) => boolean ->val : Float64Array ->index : number - - return val === this.options[index]; ->val === this.options[index] : boolean ->val : Float64Array ->this.options[index] : any ->this.options : any ->this : any ->options : any ->index : number - - }, thisObject); ->thisObject : { options: Float64Array[]; } - - options.map(function (val, index) { ->options.map(function (val, index) { if (val === this.options[index]) return this.options[index]; }, thisObject) : any[] ->options.map : (callbackfn: (value: Float64Array, index: number, array: Float64Array[]) => U, thisArg?: any) => U[] ->options : Float64Array[] ->map : (callbackfn: (value: Float64Array, index: number, array: Float64Array[]) => U, thisArg?: any) => U[] ->function (val, index) { if (val === this.options[index]) return this.options[index]; } : (val: Float64Array, index: number) => any ->val : Float64Array ->index : number - - if (val === this.options[index]) ->val === this.options[index] : boolean ->val : Float64Array ->this.options[index] : any ->this.options : any ->this : any ->options : any ->index : number - - return this.options[index]; ->this.options[index] : any ->this.options : any ->this : any ->options : any ->index : number - - }, thisObject); ->thisObject : { options: Float64Array[]; } - - options.some(function (val, index) { ->options.some(function (val, index) { return val === this.options[index]; }, thisObject) : boolean ->options.some : (callbackfn: (value: Float64Array, index: number, array: Float64Array[]) => boolean, thisArg?: any) => boolean ->options : Float64Array[] ->some : (callbackfn: (value: Float64Array, index: number, array: Float64Array[]) => boolean, thisArg?: any) => boolean ->function (val, index) { return val === this.options[index]; } : (val: Float64Array, index: number) => boolean ->val : Float64Array ->index : number - - return val === this.options[index]; ->val === this.options[index] : boolean ->val : Float64Array ->this.options[index] : any ->this.options : any ->this : any ->options : any ->index : number - - }, thisObject); ->thisObject : { options: Float64Array[]; } - - options.filter(function (val, index) { ->options.filter(function (val, index) { return val === this.options[index]; }, thisObject) : Float64Array[] ->options.filter : { (callbackfn: (value: Float64Array, index: number, array: Float64Array[]) => value is S, thisArg?: any): S[]; (callbackfn: (value: Float64Array, index: number, array: Float64Array[]) => any, thisArg?: any): Float64Array[]; } ->options : Float64Array[] ->filter : { (callbackfn: (value: Float64Array, index: number, array: Float64Array[]) => value is S, thisArg?: any): S[]; (callbackfn: (value: Float64Array, index: number, array: Float64Array[]) => any, thisArg?: any): Float64Array[]; } ->function (val, index) { return val === this.options[index]; } : (val: Float64Array, index: number) => boolean ->val : Float64Array ->index : number - - return val === this.options[index]; ->val === this.options[index] : boolean ->val : Float64Array ->this.options[index] : any ->this.options : any ->this : any ->options : any ->index : number - - }, thisObject); ->thisObject : { options: Float64Array[]; } - - options.every(function (val, index) { ->options.every(function (val, index) { return val === this.options[index]; }, thisObject) : boolean ->options.every : (callbackfn: (value: Float64Array, index: number, array: Float64Array[]) => boolean, thisArg?: any) => boolean ->options : Float64Array[] ->every : (callbackfn: (value: Float64Array, index: number, array: Float64Array[]) => boolean, thisArg?: any) => boolean ->function (val, index) { return val === this.options[index]; } : (val: Float64Array, index: number) => boolean ->val : Float64Array ->index : number - - return val === this.options[index]; ->val === this.options[index] : boolean ->val : Float64Array ->this.options[index] : any ->this.options : any ->this : any ->options : any ->index : number - - }, thisObject); ->thisObject : { options: Float64Array[]; } - } -} - diff --git a/tests/baselines/reference/typedArrays.symbols b/tests/baselines/reference/typedArrays.symbols index f3f0aca48c3..1080fa39e89 100644 --- a/tests/baselines/reference/typedArrays.symbols +++ b/tests/baselines/reference/typedArrays.symbols @@ -166,65 +166,65 @@ function CreateIntegerTypedArraysFromArray2(obj:number[]) { typedArrays[0] = Int8Array.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 46, 7)) ->Int8Array.from : Symbol(Int8ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Int8Array.from : Symbol(Int8ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >Int8Array : Symbol(Int8Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) ->from : Symbol(Int8ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>from : Symbol(Int8ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >obj : Symbol(obj, Decl(typedArrays.ts, 45, 44)) typedArrays[1] = Uint8Array.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 46, 7)) ->Uint8Array.from : Symbol(Uint8ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Uint8Array.from : Symbol(Uint8ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >Uint8Array : Symbol(Uint8Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) ->from : Symbol(Uint8ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>from : Symbol(Uint8ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >obj : Symbol(obj, Decl(typedArrays.ts, 45, 44)) typedArrays[2] = Int16Array.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 46, 7)) ->Int16Array.from : Symbol(Int16ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Int16Array.from : Symbol(Int16ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >Int16Array : Symbol(Int16Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) ->from : Symbol(Int16ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>from : Symbol(Int16ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >obj : Symbol(obj, Decl(typedArrays.ts, 45, 44)) typedArrays[3] = Uint16Array.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 46, 7)) ->Uint16Array.from : Symbol(Uint16ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Uint16Array.from : Symbol(Uint16ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >Uint16Array : Symbol(Uint16Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) ->from : Symbol(Uint16ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>from : Symbol(Uint16ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >obj : Symbol(obj, Decl(typedArrays.ts, 45, 44)) typedArrays[4] = Int32Array.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 46, 7)) ->Int32Array.from : Symbol(Int32ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Int32Array.from : Symbol(Int32ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >Int32Array : Symbol(Int32Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) ->from : Symbol(Int32ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>from : Symbol(Int32ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >obj : Symbol(obj, Decl(typedArrays.ts, 45, 44)) typedArrays[5] = Uint32Array.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 46, 7)) ->Uint32Array.from : Symbol(Uint32ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Uint32Array.from : Symbol(Uint32ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >Uint32Array : Symbol(Uint32Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) ->from : Symbol(Uint32ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>from : Symbol(Uint32ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >obj : Symbol(obj, Decl(typedArrays.ts, 45, 44)) typedArrays[6] = Float32Array.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 46, 7)) ->Float32Array.from : Symbol(Float32ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Float32Array.from : Symbol(Float32ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >Float32Array : Symbol(Float32Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) ->from : Symbol(Float32ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>from : Symbol(Float32ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >obj : Symbol(obj, Decl(typedArrays.ts, 45, 44)) typedArrays[7] = Float64Array.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 46, 7)) ->Float64Array.from : Symbol(Float64ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Float64Array.from : Symbol(Float64ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >Float64Array : Symbol(Float64Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) ->from : Symbol(Float64ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>from : Symbol(Float64ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >obj : Symbol(obj, Decl(typedArrays.ts, 45, 44)) typedArrays[8] = Uint8ClampedArray.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 46, 7)) ->Uint8ClampedArray.from : Symbol(Uint8ClampedArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Uint8ClampedArray.from : Symbol(Uint8ClampedArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >Uint8ClampedArray : Symbol(Uint8ClampedArray, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) ->from : Symbol(Uint8ClampedArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>from : Symbol(Uint8ClampedArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >obj : Symbol(obj, Decl(typedArrays.ts, 45, 44)) return typedArrays; @@ -241,65 +241,65 @@ function CreateIntegerTypedArraysFromArrayLike(obj:ArrayLike) { typedArrays[0] = Int8Array.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 61, 7)) ->Int8Array.from : Symbol(Int8ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Int8Array.from : Symbol(Int8ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >Int8Array : Symbol(Int8Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) ->from : Symbol(Int8ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>from : Symbol(Int8ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >obj : Symbol(obj, Decl(typedArrays.ts, 60, 47)) typedArrays[1] = Uint8Array.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 61, 7)) ->Uint8Array.from : Symbol(Uint8ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Uint8Array.from : Symbol(Uint8ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >Uint8Array : Symbol(Uint8Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) ->from : Symbol(Uint8ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>from : Symbol(Uint8ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >obj : Symbol(obj, Decl(typedArrays.ts, 60, 47)) typedArrays[2] = Int16Array.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 61, 7)) ->Int16Array.from : Symbol(Int16ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Int16Array.from : Symbol(Int16ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >Int16Array : Symbol(Int16Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) ->from : Symbol(Int16ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>from : Symbol(Int16ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >obj : Symbol(obj, Decl(typedArrays.ts, 60, 47)) typedArrays[3] = Uint16Array.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 61, 7)) ->Uint16Array.from : Symbol(Uint16ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Uint16Array.from : Symbol(Uint16ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >Uint16Array : Symbol(Uint16Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) ->from : Symbol(Uint16ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>from : Symbol(Uint16ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >obj : Symbol(obj, Decl(typedArrays.ts, 60, 47)) typedArrays[4] = Int32Array.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 61, 7)) ->Int32Array.from : Symbol(Int32ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Int32Array.from : Symbol(Int32ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >Int32Array : Symbol(Int32Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) ->from : Symbol(Int32ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>from : Symbol(Int32ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >obj : Symbol(obj, Decl(typedArrays.ts, 60, 47)) typedArrays[5] = Uint32Array.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 61, 7)) ->Uint32Array.from : Symbol(Uint32ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Uint32Array.from : Symbol(Uint32ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >Uint32Array : Symbol(Uint32Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) ->from : Symbol(Uint32ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>from : Symbol(Uint32ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >obj : Symbol(obj, Decl(typedArrays.ts, 60, 47)) typedArrays[6] = Float32Array.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 61, 7)) ->Float32Array.from : Symbol(Float32ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Float32Array.from : Symbol(Float32ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >Float32Array : Symbol(Float32Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) ->from : Symbol(Float32ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>from : Symbol(Float32ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >obj : Symbol(obj, Decl(typedArrays.ts, 60, 47)) typedArrays[7] = Float64Array.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 61, 7)) ->Float64Array.from : Symbol(Float64ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Float64Array.from : Symbol(Float64ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >Float64Array : Symbol(Float64Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) ->from : Symbol(Float64ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>from : Symbol(Float64ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >obj : Symbol(obj, Decl(typedArrays.ts, 60, 47)) typedArrays[8] = Uint8ClampedArray.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 61, 7)) ->Uint8ClampedArray.from : Symbol(Uint8ClampedArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Uint8ClampedArray.from : Symbol(Uint8ClampedArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >Uint8ClampedArray : Symbol(Uint8ClampedArray, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) ->from : Symbol(Uint8ClampedArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>from : Symbol(Uint8ClampedArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >obj : Symbol(obj, Decl(typedArrays.ts, 60, 47)) return typedArrays; @@ -457,73 +457,73 @@ function CreateTypedArraysFromMapFn(obj:ArrayLike, mapFn: (n:number, v:n typedArrays[0] = Int8Array.from(obj, mapFn); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 106, 7)) ->Int8Array.from : Symbol(Int8ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Int8Array.from : Symbol(Int8ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >Int8Array : Symbol(Int8Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) ->from : Symbol(Int8ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>from : Symbol(Int8ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >obj : Symbol(obj, Decl(typedArrays.ts, 105, 36)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 105, 58)) typedArrays[1] = Uint8Array.from(obj, mapFn); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 106, 7)) ->Uint8Array.from : Symbol(Uint8ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Uint8Array.from : Symbol(Uint8ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >Uint8Array : Symbol(Uint8Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) ->from : Symbol(Uint8ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>from : Symbol(Uint8ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >obj : Symbol(obj, Decl(typedArrays.ts, 105, 36)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 105, 58)) typedArrays[2] = Int16Array.from(obj, mapFn); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 106, 7)) ->Int16Array.from : Symbol(Int16ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Int16Array.from : Symbol(Int16ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >Int16Array : Symbol(Int16Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) ->from : Symbol(Int16ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>from : Symbol(Int16ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >obj : Symbol(obj, Decl(typedArrays.ts, 105, 36)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 105, 58)) typedArrays[3] = Uint16Array.from(obj, mapFn); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 106, 7)) ->Uint16Array.from : Symbol(Uint16ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Uint16Array.from : Symbol(Uint16ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >Uint16Array : Symbol(Uint16Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) ->from : Symbol(Uint16ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>from : Symbol(Uint16ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >obj : Symbol(obj, Decl(typedArrays.ts, 105, 36)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 105, 58)) typedArrays[4] = Int32Array.from(obj, mapFn); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 106, 7)) ->Int32Array.from : Symbol(Int32ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Int32Array.from : Symbol(Int32ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >Int32Array : Symbol(Int32Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) ->from : Symbol(Int32ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>from : Symbol(Int32ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >obj : Symbol(obj, Decl(typedArrays.ts, 105, 36)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 105, 58)) typedArrays[5] = Uint32Array.from(obj, mapFn); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 106, 7)) ->Uint32Array.from : Symbol(Uint32ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Uint32Array.from : Symbol(Uint32ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >Uint32Array : Symbol(Uint32Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) ->from : Symbol(Uint32ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>from : Symbol(Uint32ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >obj : Symbol(obj, Decl(typedArrays.ts, 105, 36)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 105, 58)) typedArrays[6] = Float32Array.from(obj, mapFn); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 106, 7)) ->Float32Array.from : Symbol(Float32ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Float32Array.from : Symbol(Float32ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >Float32Array : Symbol(Float32Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) ->from : Symbol(Float32ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>from : Symbol(Float32ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >obj : Symbol(obj, Decl(typedArrays.ts, 105, 36)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 105, 58)) typedArrays[7] = Float64Array.from(obj, mapFn); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 106, 7)) ->Float64Array.from : Symbol(Float64ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Float64Array.from : Symbol(Float64ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >Float64Array : Symbol(Float64Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) ->from : Symbol(Float64ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>from : Symbol(Float64ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >obj : Symbol(obj, Decl(typedArrays.ts, 105, 36)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 105, 58)) typedArrays[8] = Uint8ClampedArray.from(obj, mapFn); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 106, 7)) ->Uint8ClampedArray.from : Symbol(Uint8ClampedArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Uint8ClampedArray.from : Symbol(Uint8ClampedArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >Uint8ClampedArray : Symbol(Uint8ClampedArray, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) ->from : Symbol(Uint8ClampedArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>from : Symbol(Uint8ClampedArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >obj : Symbol(obj, Decl(typedArrays.ts, 105, 36)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 105, 58)) @@ -545,81 +545,81 @@ function CreateTypedArraysFromThisObj(obj:ArrayLike, mapFn: (n:number, v typedArrays[0] = Int8Array.from(obj, mapFn, thisArg); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 121, 7)) ->Int8Array.from : Symbol(Int8ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Int8Array.from : Symbol(Int8ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >Int8Array : Symbol(Int8Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) ->from : Symbol(Int8ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>from : Symbol(Int8ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >obj : Symbol(obj, Decl(typedArrays.ts, 120, 38)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 120, 60)) >thisArg : Symbol(thisArg, Decl(typedArrays.ts, 120, 98)) typedArrays[1] = Uint8Array.from(obj, mapFn, thisArg); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 121, 7)) ->Uint8Array.from : Symbol(Uint8ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Uint8Array.from : Symbol(Uint8ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >Uint8Array : Symbol(Uint8Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) ->from : Symbol(Uint8ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>from : Symbol(Uint8ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >obj : Symbol(obj, Decl(typedArrays.ts, 120, 38)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 120, 60)) >thisArg : Symbol(thisArg, Decl(typedArrays.ts, 120, 98)) typedArrays[2] = Int16Array.from(obj, mapFn, thisArg); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 121, 7)) ->Int16Array.from : Symbol(Int16ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Int16Array.from : Symbol(Int16ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >Int16Array : Symbol(Int16Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) ->from : Symbol(Int16ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>from : Symbol(Int16ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >obj : Symbol(obj, Decl(typedArrays.ts, 120, 38)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 120, 60)) >thisArg : Symbol(thisArg, Decl(typedArrays.ts, 120, 98)) typedArrays[3] = Uint16Array.from(obj, mapFn, thisArg); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 121, 7)) ->Uint16Array.from : Symbol(Uint16ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Uint16Array.from : Symbol(Uint16ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >Uint16Array : Symbol(Uint16Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) ->from : Symbol(Uint16ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>from : Symbol(Uint16ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >obj : Symbol(obj, Decl(typedArrays.ts, 120, 38)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 120, 60)) >thisArg : Symbol(thisArg, Decl(typedArrays.ts, 120, 98)) typedArrays[4] = Int32Array.from(obj, mapFn, thisArg); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 121, 7)) ->Int32Array.from : Symbol(Int32ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Int32Array.from : Symbol(Int32ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >Int32Array : Symbol(Int32Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) ->from : Symbol(Int32ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>from : Symbol(Int32ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >obj : Symbol(obj, Decl(typedArrays.ts, 120, 38)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 120, 60)) >thisArg : Symbol(thisArg, Decl(typedArrays.ts, 120, 98)) typedArrays[5] = Uint32Array.from(obj, mapFn, thisArg); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 121, 7)) ->Uint32Array.from : Symbol(Uint32ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Uint32Array.from : Symbol(Uint32ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >Uint32Array : Symbol(Uint32Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) ->from : Symbol(Uint32ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>from : Symbol(Uint32ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >obj : Symbol(obj, Decl(typedArrays.ts, 120, 38)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 120, 60)) >thisArg : Symbol(thisArg, Decl(typedArrays.ts, 120, 98)) typedArrays[6] = Float32Array.from(obj, mapFn, thisArg); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 121, 7)) ->Float32Array.from : Symbol(Float32ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Float32Array.from : Symbol(Float32ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >Float32Array : Symbol(Float32Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) ->from : Symbol(Float32ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>from : Symbol(Float32ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >obj : Symbol(obj, Decl(typedArrays.ts, 120, 38)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 120, 60)) >thisArg : Symbol(thisArg, Decl(typedArrays.ts, 120, 98)) typedArrays[7] = Float64Array.from(obj, mapFn, thisArg); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 121, 7)) ->Float64Array.from : Symbol(Float64ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Float64Array.from : Symbol(Float64ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >Float64Array : Symbol(Float64Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) ->from : Symbol(Float64ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>from : Symbol(Float64ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >obj : Symbol(obj, Decl(typedArrays.ts, 120, 38)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 120, 60)) >thisArg : Symbol(thisArg, Decl(typedArrays.ts, 120, 98)) typedArrays[8] = Uint8ClampedArray.from(obj, mapFn, thisArg); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 121, 7)) ->Uint8ClampedArray.from : Symbol(Uint8ClampedArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Uint8ClampedArray.from : Symbol(Uint8ClampedArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >Uint8ClampedArray : Symbol(Uint8ClampedArray, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) ->from : Symbol(Uint8ClampedArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>from : Symbol(Uint8ClampedArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >obj : Symbol(obj, Decl(typedArrays.ts, 120, 38)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 120, 60)) >thisArg : Symbol(thisArg, Decl(typedArrays.ts, 120, 98)) diff --git a/tests/baselines/reference/typedArrays.types b/tests/baselines/reference/typedArrays.types index 99c7e433ea5..d283cfc353d 100644 --- a/tests/baselines/reference/typedArrays.types +++ b/tests/baselines/reference/typedArrays.types @@ -273,9 +273,9 @@ function CreateIntegerTypedArraysFromArray2(obj:number[]) { >typedArrays : any[] >0 : 0 >Int8Array.from(obj) : Int8Array ->Int8Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int8Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Int8Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Int8Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Int8Array; (arrayLike: Iterable): Int8Array; } +>Int8Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int8Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int8Array; } >Int8Array : Int8ArrayConstructor ->from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int8Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Int8Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Int8Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Int8Array; (arrayLike: Iterable): Int8Array; } +>from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int8Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int8Array; } >obj : number[] typedArrays[1] = Uint8Array.from(obj); @@ -284,9 +284,9 @@ function CreateIntegerTypedArraysFromArray2(obj:number[]) { >typedArrays : any[] >1 : 1 >Uint8Array.from(obj) : Uint8Array ->Uint8Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Uint8Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Uint8Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint8Array; (arrayLike: Iterable): Uint8Array; } +>Uint8Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8Array; } >Uint8Array : Uint8ArrayConstructor ->from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Uint8Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Uint8Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint8Array; (arrayLike: Iterable): Uint8Array; } +>from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8Array; } >obj : number[] typedArrays[2] = Int16Array.from(obj); @@ -295,9 +295,9 @@ function CreateIntegerTypedArraysFromArray2(obj:number[]) { >typedArrays : any[] >2 : 2 >Int16Array.from(obj) : Int16Array ->Int16Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int16Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Int16Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Int16Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Int16Array; (arrayLike: Iterable): Int16Array; } +>Int16Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int16Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int16Array; } >Int16Array : Int16ArrayConstructor ->from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int16Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Int16Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Int16Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Int16Array; (arrayLike: Iterable): Int16Array; } +>from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int16Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int16Array; } >obj : number[] typedArrays[3] = Uint16Array.from(obj); @@ -306,9 +306,9 @@ function CreateIntegerTypedArraysFromArray2(obj:number[]) { >typedArrays : any[] >3 : 3 >Uint16Array.from(obj) : Uint16Array ->Uint16Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint16Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Uint16Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Uint16Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint16Array; (arrayLike: Iterable): Uint16Array; } +>Uint16Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint16Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint16Array; } >Uint16Array : Uint16ArrayConstructor ->from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint16Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Uint16Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Uint16Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint16Array; (arrayLike: Iterable): Uint16Array; } +>from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint16Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint16Array; } >obj : number[] typedArrays[4] = Int32Array.from(obj); @@ -317,9 +317,9 @@ function CreateIntegerTypedArraysFromArray2(obj:number[]) { >typedArrays : any[] >4 : 4 >Int32Array.from(obj) : Int32Array ->Int32Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int32Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Int32Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Int32Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Int32Array; (arrayLike: Iterable): Int32Array; } +>Int32Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int32Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int32Array; } >Int32Array : Int32ArrayConstructor ->from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int32Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Int32Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Int32Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Int32Array; (arrayLike: Iterable): Int32Array; } +>from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int32Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int32Array; } >obj : number[] typedArrays[5] = Uint32Array.from(obj); @@ -328,9 +328,9 @@ function CreateIntegerTypedArraysFromArray2(obj:number[]) { >typedArrays : any[] >5 : 5 >Uint32Array.from(obj) : Uint32Array ->Uint32Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint32Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Uint32Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Uint32Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint32Array; (arrayLike: Iterable): Uint32Array; } +>Uint32Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint32Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint32Array; } >Uint32Array : Uint32ArrayConstructor ->from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint32Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Uint32Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Uint32Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint32Array; (arrayLike: Iterable): Uint32Array; } +>from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint32Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint32Array; } >obj : number[] typedArrays[6] = Float32Array.from(obj); @@ -339,9 +339,9 @@ function CreateIntegerTypedArraysFromArray2(obj:number[]) { >typedArrays : any[] >6 : 6 >Float32Array.from(obj) : Float32Array ->Float32Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Float32Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Float32Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Float32Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Float32Array; (arrayLike: Iterable): Float32Array; } +>Float32Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Float32Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Float32Array; } >Float32Array : Float32ArrayConstructor ->from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Float32Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Float32Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Float32Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Float32Array; (arrayLike: Iterable): Float32Array; } +>from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Float32Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Float32Array; } >obj : number[] typedArrays[7] = Float64Array.from(obj); @@ -350,9 +350,9 @@ function CreateIntegerTypedArraysFromArray2(obj:number[]) { >typedArrays : any[] >7 : 7 >Float64Array.from(obj) : Float64Array ->Float64Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Float64Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Float64Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Float64Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Float64Array; (arrayLike: Iterable): Float64Array; } +>Float64Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Float64Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Float64Array; } >Float64Array : Float64ArrayConstructor ->from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Float64Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Float64Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Float64Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Float64Array; (arrayLike: Iterable): Float64Array; } +>from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Float64Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Float64Array; } >obj : number[] typedArrays[8] = Uint8ClampedArray.from(obj); @@ -361,9 +361,9 @@ function CreateIntegerTypedArraysFromArray2(obj:number[]) { >typedArrays : any[] >8 : 8 >Uint8ClampedArray.from(obj) : Uint8ClampedArray ->Uint8ClampedArray.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8ClampedArray; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Uint8ClampedArray; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Uint8ClampedArray; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint8ClampedArray; (arrayLike: Iterable): Uint8ClampedArray; } +>Uint8ClampedArray.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8ClampedArray; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8ClampedArray; } >Uint8ClampedArray : Uint8ClampedArrayConstructor ->from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8ClampedArray; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Uint8ClampedArray; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Uint8ClampedArray; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint8ClampedArray; (arrayLike: Iterable): Uint8ClampedArray; } +>from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8ClampedArray; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8ClampedArray; } >obj : number[] return typedArrays; @@ -385,9 +385,9 @@ function CreateIntegerTypedArraysFromArrayLike(obj:ArrayLike) { >typedArrays : any[] >0 : 0 >Int8Array.from(obj) : Int8Array ->Int8Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int8Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Int8Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Int8Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Int8Array; (arrayLike: Iterable): Int8Array; } +>Int8Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int8Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int8Array; } >Int8Array : Int8ArrayConstructor ->from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int8Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Int8Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Int8Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Int8Array; (arrayLike: Iterable): Int8Array; } +>from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int8Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int8Array; } >obj : ArrayLike typedArrays[1] = Uint8Array.from(obj); @@ -396,9 +396,9 @@ function CreateIntegerTypedArraysFromArrayLike(obj:ArrayLike) { >typedArrays : any[] >1 : 1 >Uint8Array.from(obj) : Uint8Array ->Uint8Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Uint8Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Uint8Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint8Array; (arrayLike: Iterable): Uint8Array; } +>Uint8Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8Array; } >Uint8Array : Uint8ArrayConstructor ->from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Uint8Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Uint8Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint8Array; (arrayLike: Iterable): Uint8Array; } +>from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8Array; } >obj : ArrayLike typedArrays[2] = Int16Array.from(obj); @@ -407,9 +407,9 @@ function CreateIntegerTypedArraysFromArrayLike(obj:ArrayLike) { >typedArrays : any[] >2 : 2 >Int16Array.from(obj) : Int16Array ->Int16Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int16Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Int16Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Int16Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Int16Array; (arrayLike: Iterable): Int16Array; } +>Int16Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int16Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int16Array; } >Int16Array : Int16ArrayConstructor ->from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int16Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Int16Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Int16Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Int16Array; (arrayLike: Iterable): Int16Array; } +>from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int16Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int16Array; } >obj : ArrayLike typedArrays[3] = Uint16Array.from(obj); @@ -418,9 +418,9 @@ function CreateIntegerTypedArraysFromArrayLike(obj:ArrayLike) { >typedArrays : any[] >3 : 3 >Uint16Array.from(obj) : Uint16Array ->Uint16Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint16Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Uint16Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Uint16Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint16Array; (arrayLike: Iterable): Uint16Array; } +>Uint16Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint16Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint16Array; } >Uint16Array : Uint16ArrayConstructor ->from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint16Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Uint16Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Uint16Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint16Array; (arrayLike: Iterable): Uint16Array; } +>from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint16Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint16Array; } >obj : ArrayLike typedArrays[4] = Int32Array.from(obj); @@ -429,9 +429,9 @@ function CreateIntegerTypedArraysFromArrayLike(obj:ArrayLike) { >typedArrays : any[] >4 : 4 >Int32Array.from(obj) : Int32Array ->Int32Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int32Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Int32Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Int32Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Int32Array; (arrayLike: Iterable): Int32Array; } +>Int32Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int32Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int32Array; } >Int32Array : Int32ArrayConstructor ->from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int32Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Int32Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Int32Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Int32Array; (arrayLike: Iterable): Int32Array; } +>from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int32Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int32Array; } >obj : ArrayLike typedArrays[5] = Uint32Array.from(obj); @@ -440,9 +440,9 @@ function CreateIntegerTypedArraysFromArrayLike(obj:ArrayLike) { >typedArrays : any[] >5 : 5 >Uint32Array.from(obj) : Uint32Array ->Uint32Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint32Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Uint32Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Uint32Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint32Array; (arrayLike: Iterable): Uint32Array; } +>Uint32Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint32Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint32Array; } >Uint32Array : Uint32ArrayConstructor ->from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint32Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Uint32Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Uint32Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint32Array; (arrayLike: Iterable): Uint32Array; } +>from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint32Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint32Array; } >obj : ArrayLike typedArrays[6] = Float32Array.from(obj); @@ -451,9 +451,9 @@ function CreateIntegerTypedArraysFromArrayLike(obj:ArrayLike) { >typedArrays : any[] >6 : 6 >Float32Array.from(obj) : Float32Array ->Float32Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Float32Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Float32Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Float32Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Float32Array; (arrayLike: Iterable): Float32Array; } +>Float32Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Float32Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Float32Array; } >Float32Array : Float32ArrayConstructor ->from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Float32Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Float32Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Float32Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Float32Array; (arrayLike: Iterable): Float32Array; } +>from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Float32Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Float32Array; } >obj : ArrayLike typedArrays[7] = Float64Array.from(obj); @@ -462,9 +462,9 @@ function CreateIntegerTypedArraysFromArrayLike(obj:ArrayLike) { >typedArrays : any[] >7 : 7 >Float64Array.from(obj) : Float64Array ->Float64Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Float64Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Float64Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Float64Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Float64Array; (arrayLike: Iterable): Float64Array; } +>Float64Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Float64Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Float64Array; } >Float64Array : Float64ArrayConstructor ->from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Float64Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Float64Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Float64Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Float64Array; (arrayLike: Iterable): Float64Array; } +>from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Float64Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Float64Array; } >obj : ArrayLike typedArrays[8] = Uint8ClampedArray.from(obj); @@ -473,9 +473,9 @@ function CreateIntegerTypedArraysFromArrayLike(obj:ArrayLike) { >typedArrays : any[] >8 : 8 >Uint8ClampedArray.from(obj) : Uint8ClampedArray ->Uint8ClampedArray.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8ClampedArray; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Uint8ClampedArray; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Uint8ClampedArray; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint8ClampedArray; (arrayLike: Iterable): Uint8ClampedArray; } +>Uint8ClampedArray.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8ClampedArray; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8ClampedArray; } >Uint8ClampedArray : Uint8ClampedArrayConstructor ->from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8ClampedArray; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Uint8ClampedArray; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Uint8ClampedArray; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint8ClampedArray; (arrayLike: Iterable): Uint8ClampedArray; } +>from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8ClampedArray; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8ClampedArray; } >obj : ArrayLike return typedArrays; @@ -757,9 +757,9 @@ function CreateTypedArraysFromMapFn(obj:ArrayLike, mapFn: (n:number, v:n >typedArrays : any[] >0 : 0 >Int8Array.from(obj, mapFn) : Int8Array ->Int8Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int8Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Int8Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Int8Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Int8Array; (arrayLike: Iterable): Int8Array; } +>Int8Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int8Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int8Array; } >Int8Array : Int8ArrayConstructor ->from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int8Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Int8Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Int8Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Int8Array; (arrayLike: Iterable): Int8Array; } +>from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int8Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int8Array; } >obj : ArrayLike >mapFn : (n: number, v: number) => number @@ -769,9 +769,9 @@ function CreateTypedArraysFromMapFn(obj:ArrayLike, mapFn: (n:number, v:n >typedArrays : any[] >1 : 1 >Uint8Array.from(obj, mapFn) : Uint8Array ->Uint8Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Uint8Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Uint8Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint8Array; (arrayLike: Iterable): Uint8Array; } +>Uint8Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8Array; } >Uint8Array : Uint8ArrayConstructor ->from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Uint8Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Uint8Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint8Array; (arrayLike: Iterable): Uint8Array; } +>from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8Array; } >obj : ArrayLike >mapFn : (n: number, v: number) => number @@ -781,9 +781,9 @@ function CreateTypedArraysFromMapFn(obj:ArrayLike, mapFn: (n:number, v:n >typedArrays : any[] >2 : 2 >Int16Array.from(obj, mapFn) : Int16Array ->Int16Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int16Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Int16Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Int16Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Int16Array; (arrayLike: Iterable): Int16Array; } +>Int16Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int16Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int16Array; } >Int16Array : Int16ArrayConstructor ->from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int16Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Int16Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Int16Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Int16Array; (arrayLike: Iterable): Int16Array; } +>from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int16Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int16Array; } >obj : ArrayLike >mapFn : (n: number, v: number) => number @@ -793,9 +793,9 @@ function CreateTypedArraysFromMapFn(obj:ArrayLike, mapFn: (n:number, v:n >typedArrays : any[] >3 : 3 >Uint16Array.from(obj, mapFn) : Uint16Array ->Uint16Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint16Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Uint16Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Uint16Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint16Array; (arrayLike: Iterable): Uint16Array; } +>Uint16Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint16Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint16Array; } >Uint16Array : Uint16ArrayConstructor ->from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint16Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Uint16Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Uint16Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint16Array; (arrayLike: Iterable): Uint16Array; } +>from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint16Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint16Array; } >obj : ArrayLike >mapFn : (n: number, v: number) => number @@ -805,9 +805,9 @@ function CreateTypedArraysFromMapFn(obj:ArrayLike, mapFn: (n:number, v:n >typedArrays : any[] >4 : 4 >Int32Array.from(obj, mapFn) : Int32Array ->Int32Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int32Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Int32Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Int32Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Int32Array; (arrayLike: Iterable): Int32Array; } +>Int32Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int32Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int32Array; } >Int32Array : Int32ArrayConstructor ->from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int32Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Int32Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Int32Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Int32Array; (arrayLike: Iterable): Int32Array; } +>from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int32Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int32Array; } >obj : ArrayLike >mapFn : (n: number, v: number) => number @@ -817,9 +817,9 @@ function CreateTypedArraysFromMapFn(obj:ArrayLike, mapFn: (n:number, v:n >typedArrays : any[] >5 : 5 >Uint32Array.from(obj, mapFn) : Uint32Array ->Uint32Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint32Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Uint32Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Uint32Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint32Array; (arrayLike: Iterable): Uint32Array; } +>Uint32Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint32Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint32Array; } >Uint32Array : Uint32ArrayConstructor ->from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint32Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Uint32Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Uint32Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint32Array; (arrayLike: Iterable): Uint32Array; } +>from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint32Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint32Array; } >obj : ArrayLike >mapFn : (n: number, v: number) => number @@ -829,9 +829,9 @@ function CreateTypedArraysFromMapFn(obj:ArrayLike, mapFn: (n:number, v:n >typedArrays : any[] >6 : 6 >Float32Array.from(obj, mapFn) : Float32Array ->Float32Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Float32Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Float32Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Float32Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Float32Array; (arrayLike: Iterable): Float32Array; } +>Float32Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Float32Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Float32Array; } >Float32Array : Float32ArrayConstructor ->from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Float32Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Float32Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Float32Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Float32Array; (arrayLike: Iterable): Float32Array; } +>from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Float32Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Float32Array; } >obj : ArrayLike >mapFn : (n: number, v: number) => number @@ -841,9 +841,9 @@ function CreateTypedArraysFromMapFn(obj:ArrayLike, mapFn: (n:number, v:n >typedArrays : any[] >7 : 7 >Float64Array.from(obj, mapFn) : Float64Array ->Float64Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Float64Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Float64Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Float64Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Float64Array; (arrayLike: Iterable): Float64Array; } +>Float64Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Float64Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Float64Array; } >Float64Array : Float64ArrayConstructor ->from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Float64Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Float64Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Float64Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Float64Array; (arrayLike: Iterable): Float64Array; } +>from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Float64Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Float64Array; } >obj : ArrayLike >mapFn : (n: number, v: number) => number @@ -853,9 +853,9 @@ function CreateTypedArraysFromMapFn(obj:ArrayLike, mapFn: (n:number, v:n >typedArrays : any[] >8 : 8 >Uint8ClampedArray.from(obj, mapFn) : Uint8ClampedArray ->Uint8ClampedArray.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8ClampedArray; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Uint8ClampedArray; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Uint8ClampedArray; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint8ClampedArray; (arrayLike: Iterable): Uint8ClampedArray; } +>Uint8ClampedArray.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8ClampedArray; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8ClampedArray; } >Uint8ClampedArray : Uint8ClampedArrayConstructor ->from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8ClampedArray; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Uint8ClampedArray; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Uint8ClampedArray; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint8ClampedArray; (arrayLike: Iterable): Uint8ClampedArray; } +>from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8ClampedArray; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8ClampedArray; } >obj : ArrayLike >mapFn : (n: number, v: number) => number @@ -882,9 +882,9 @@ function CreateTypedArraysFromThisObj(obj:ArrayLike, mapFn: (n:number, v >typedArrays : any[] >0 : 0 >Int8Array.from(obj, mapFn, thisArg) : Int8Array ->Int8Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int8Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Int8Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Int8Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Int8Array; (arrayLike: Iterable): Int8Array; } +>Int8Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int8Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int8Array; } >Int8Array : Int8ArrayConstructor ->from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int8Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Int8Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Int8Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Int8Array; (arrayLike: Iterable): Int8Array; } +>from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int8Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int8Array; } >obj : ArrayLike >mapFn : (n: number, v: number) => number >thisArg : {} @@ -895,9 +895,9 @@ function CreateTypedArraysFromThisObj(obj:ArrayLike, mapFn: (n:number, v >typedArrays : any[] >1 : 1 >Uint8Array.from(obj, mapFn, thisArg) : Uint8Array ->Uint8Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Uint8Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Uint8Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint8Array; (arrayLike: Iterable): Uint8Array; } +>Uint8Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8Array; } >Uint8Array : Uint8ArrayConstructor ->from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Uint8Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Uint8Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint8Array; (arrayLike: Iterable): Uint8Array; } +>from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8Array; } >obj : ArrayLike >mapFn : (n: number, v: number) => number >thisArg : {} @@ -908,9 +908,9 @@ function CreateTypedArraysFromThisObj(obj:ArrayLike, mapFn: (n:number, v >typedArrays : any[] >2 : 2 >Int16Array.from(obj, mapFn, thisArg) : Int16Array ->Int16Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int16Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Int16Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Int16Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Int16Array; (arrayLike: Iterable): Int16Array; } +>Int16Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int16Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int16Array; } >Int16Array : Int16ArrayConstructor ->from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int16Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Int16Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Int16Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Int16Array; (arrayLike: Iterable): Int16Array; } +>from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int16Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int16Array; } >obj : ArrayLike >mapFn : (n: number, v: number) => number >thisArg : {} @@ -921,9 +921,9 @@ function CreateTypedArraysFromThisObj(obj:ArrayLike, mapFn: (n:number, v >typedArrays : any[] >3 : 3 >Uint16Array.from(obj, mapFn, thisArg) : Uint16Array ->Uint16Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint16Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Uint16Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Uint16Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint16Array; (arrayLike: Iterable): Uint16Array; } +>Uint16Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint16Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint16Array; } >Uint16Array : Uint16ArrayConstructor ->from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint16Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Uint16Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Uint16Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint16Array; (arrayLike: Iterable): Uint16Array; } +>from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint16Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint16Array; } >obj : ArrayLike >mapFn : (n: number, v: number) => number >thisArg : {} @@ -934,9 +934,9 @@ function CreateTypedArraysFromThisObj(obj:ArrayLike, mapFn: (n:number, v >typedArrays : any[] >4 : 4 >Int32Array.from(obj, mapFn, thisArg) : Int32Array ->Int32Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int32Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Int32Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Int32Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Int32Array; (arrayLike: Iterable): Int32Array; } +>Int32Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int32Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int32Array; } >Int32Array : Int32ArrayConstructor ->from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int32Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Int32Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Int32Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Int32Array; (arrayLike: Iterable): Int32Array; } +>from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int32Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int32Array; } >obj : ArrayLike >mapFn : (n: number, v: number) => number >thisArg : {} @@ -947,9 +947,9 @@ function CreateTypedArraysFromThisObj(obj:ArrayLike, mapFn: (n:number, v >typedArrays : any[] >5 : 5 >Uint32Array.from(obj, mapFn, thisArg) : Uint32Array ->Uint32Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint32Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Uint32Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Uint32Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint32Array; (arrayLike: Iterable): Uint32Array; } +>Uint32Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint32Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint32Array; } >Uint32Array : Uint32ArrayConstructor ->from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint32Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Uint32Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Uint32Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint32Array; (arrayLike: Iterable): Uint32Array; } +>from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint32Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint32Array; } >obj : ArrayLike >mapFn : (n: number, v: number) => number >thisArg : {} @@ -960,9 +960,9 @@ function CreateTypedArraysFromThisObj(obj:ArrayLike, mapFn: (n:number, v >typedArrays : any[] >6 : 6 >Float32Array.from(obj, mapFn, thisArg) : Float32Array ->Float32Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Float32Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Float32Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Float32Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Float32Array; (arrayLike: Iterable): Float32Array; } +>Float32Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Float32Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Float32Array; } >Float32Array : Float32ArrayConstructor ->from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Float32Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Float32Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Float32Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Float32Array; (arrayLike: Iterable): Float32Array; } +>from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Float32Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Float32Array; } >obj : ArrayLike >mapFn : (n: number, v: number) => number >thisArg : {} @@ -973,9 +973,9 @@ function CreateTypedArraysFromThisObj(obj:ArrayLike, mapFn: (n:number, v >typedArrays : any[] >7 : 7 >Float64Array.from(obj, mapFn, thisArg) : Float64Array ->Float64Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Float64Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Float64Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Float64Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Float64Array; (arrayLike: Iterable): Float64Array; } +>Float64Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Float64Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Float64Array; } >Float64Array : Float64ArrayConstructor ->from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Float64Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Float64Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Float64Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Float64Array; (arrayLike: Iterable): Float64Array; } +>from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Float64Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Float64Array; } >obj : ArrayLike >mapFn : (n: number, v: number) => number >thisArg : {} @@ -986,9 +986,9 @@ function CreateTypedArraysFromThisObj(obj:ArrayLike, mapFn: (n:number, v >typedArrays : any[] >8 : 8 >Uint8ClampedArray.from(obj, mapFn, thisArg) : Uint8ClampedArray ->Uint8ClampedArray.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8ClampedArray; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Uint8ClampedArray; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Uint8ClampedArray; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint8ClampedArray; (arrayLike: Iterable): Uint8ClampedArray; } +>Uint8ClampedArray.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8ClampedArray; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8ClampedArray; } >Uint8ClampedArray : Uint8ClampedArrayConstructor ->from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8ClampedArray; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Uint8ClampedArray; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Uint8ClampedArray; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint8ClampedArray; (arrayLike: Iterable): Uint8ClampedArray; } +>from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8ClampedArray; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8ClampedArray; } >obj : ArrayLike >mapFn : (n: number, v: number) => number >thisArg : {} diff --git a/tests/cases/compiler/thisTypeInNativeThisAssignableMethods.ts b/tests/cases/compiler/thisTypeInNativeThisAssignableMethods.ts deleted file mode 100644 index 17ff41c70a7..00000000000 --- a/tests/cases/compiler/thisTypeInNativeThisAssignableMethods.ts +++ /dev/null @@ -1,398 +0,0 @@ -// @target: ES2017 - -class A { - options: string[]; - - addOptions(options: string[]) { - if (!this.options) { - this.options = []; - } - options.forEach(function (item) { - this.options.push(item); - }, this); - return this; - } - - testUndefined(options: string[]) { - const undefinedArr: Array = [] - options.forEach(function () { - undefinedArr.push(this); - }); // case1 - options.forEach(function () { - undefinedArr.push(this); - }, undefined); // case2 - options.forEach(function () { - undefinedArr.push(this); - }, null); // case3 - - const arrLike = {} as ArrayLike - Array.from(arrLike, function (item) { - return this === undefined ? 2 : 1; - }, undefined) - - const iterLike = [] as Iterable - Array.from(iterLike, function (item) { - return this === undefined ? 2 : 1; - }, undefined) - } - - test(options: string[]) { - const thisObject = { - options: [] as string[] - }; - - options.find(function (val, index) { - return val === this.options[index]; - }, thisObject); - - options.findIndex(function (val, index) { - return val === this.options[index]; - }, thisObject); - - options.forEach(function (val, index) { - return val === this.options[index]; - }, thisObject); - - options.map(function (val, index) { - if (val === this.options[index]) - return this.options[index]; - }, thisObject); - - options.some(function (val, index) { - return val === this.options[index]; - }, thisObject); - - options.filter(function (val, index) { - return val === this.options[index]; - }, thisObject); - - options.every(function (val, index) { - return val === this.options[index]; - }, thisObject); - - const arrLike = {} as ArrayLike - Array.from(arrLike, function (item) { - return this.options[item].length - }, thisObject) - - const iterLike = [] as Iterable - Array.from(iterLike, function (item) { - return this.options[item].length - }, thisObject) - } - - test1(options: string[]) { - const thisObject = { - options: [] as ReadonlyArray - }; - - options.find(function (val, index) { - return val === this.options[index]; - }, thisObject); - - options.findIndex(function (val, index) { - return val === this.options[index]; - }, thisObject); - - options.forEach(function (val, index) { - return val === this.options[index]; - }, thisObject); - - options.map(function (val, index) { - if (val === this.options[index]) - return this.options[index]; - }, thisObject); - - options.some(function (val, index) { - return val === this.options[index]; - }, thisObject); - - options.filter(function (val, index) { - return val === this.options[index]; - }, thisObject); - - options.every(function (val, index) { - return val === this.options[index]; - }, thisObject); - } - - test2(options: Int8Array[]) { - const thisObject = { - options: [] as Int8Array[] - }; - - options.find(function (val, index) { - return val === this.options[index]; - }, thisObject); - - options.findIndex(function (val, index) { - return val === this.options[index]; - }, thisObject); - - options.forEach(function (val, index) { - return val === this.options[index]; - }, thisObject); - - options.map(function (val, index) { - if (val === this.options[index]) - return this.options[index]; - }, thisObject); - - options.some(function (val, index) { - return val === this.options[index]; - }, thisObject); - - options.filter(function (val, index) { - return val === this.options[index]; - }, thisObject); - - options.every(function (val, index) { - return val === this.options[index]; - }, thisObject); - } - - test3(options: Uint8Array[]) { - const thisObject = { - options: [] as Uint8Array[] - }; - - options.find(function (val, index) { - return val === this.options[index]; - }, thisObject); - - options.findIndex(function (val, index) { - return val === this.options[index]; - }, thisObject); - - options.forEach(function (val, index) { - return val === this.options[index]; - }, thisObject); - - options.map(function (val, index) { - if (val === this.options[index]) - return this.options[index]; - }, thisObject); - - options.some(function (val, index) { - return val === this.options[index]; - }, thisObject); - - options.filter(function (val, index) { - return val === this.options[index]; - }, thisObject); - - options.every(function (val, index) { - return val === this.options[index]; - }, thisObject); - } - - test4(options: Float32Array[]) { - const thisObject = { - options: [] as Float32Array[] - }; - - options.find(function (val, index) { - return val === this.options[index]; - }, thisObject); - - options.findIndex(function (val, index) { - return val === this.options[index]; - }, thisObject); - - options.forEach(function (val, index) { - return val === this.options[index]; - }, thisObject); - - options.map(function (val, index) { - if (val === this.options[index]) - return this.options[index]; - }, thisObject); - - options.some(function (val, index) { - return val === this.options[index]; - }, thisObject); - - options.filter(function (val, index) { - return val === this.options[index]; - }, thisObject); - - options.every(function (val, index) { - return val === this.options[index]; - }, thisObject); - } - - test5(options: Uint8ClampedArray[]) { - const thisObject = { - options: [] as Uint8ClampedArray[] - }; - - options.find(function (val, index) { - return val === this.options[index]; - }, thisObject); - - options.findIndex(function (val, index) { - return val === this.options[index]; - }, thisObject); - - options.forEach(function (val, index) { - return val === this.options[index]; - }, thisObject); - - options.map(function (val, index) { - if (val === this.options[index]) - return this.options[index]; - }, thisObject); - - options.some(function (val, index) { - return val === this.options[index]; - }, thisObject); - - options.filter(function (val, index) { - return val === this.options[index]; - }, thisObject); - - options.every(function (val, index) { - return val === this.options[index]; - }, thisObject); - } - - test6(options: Int16Array[]) { - const thisObject = { - options: [] as Int16Array[] - }; - - options.find(function (val, index) { - return val === this.options[index]; - }, thisObject); - - options.findIndex(function (val, index) { - return val === this.options[index]; - }, thisObject); - - options.forEach(function (val, index) { - return val === this.options[index]; - }, thisObject); - - options.map(function (val, index) { - if (val === this.options[index]) - return this.options[index]; - }, thisObject); - - options.some(function (val, index) { - return val === this.options[index]; - }, thisObject); - - options.filter(function (val, index) { - return val === this.options[index]; - }, thisObject); - - options.every(function (val, index) { - return val === this.options[index]; - }, thisObject); - } - - test7(options: Uint16Array[]) { - const thisObject = { - options: [] as Uint16Array[] - }; - - options.find(function (val, index) { - return val === this.options[index]; - }, thisObject); - - options.findIndex(function (val, index) { - return val === this.options[index]; - }, thisObject); - - options.forEach(function (val, index) { - return val === this.options[index]; - }, thisObject); - - options.map(function (val, index) { - if (val === this.options[index]) - return this.options[index]; - }, thisObject); - - options.some(function (val, index) { - return val === this.options[index]; - }, thisObject); - - options.filter(function (val, index) { - return val === this.options[index]; - }, thisObject); - - options.every(function (val, index) { - return val === this.options[index]; - }, thisObject); - } - - test8(options: Uint32Array[]) { - const thisObject = { - options: [] as Uint32Array[] - }; - - options.find(function (val, index) { - return val === this.options[index]; - }, thisObject); - - options.findIndex(function (val, index) { - return val === this.options[index]; - }, thisObject); - - options.forEach(function (val, index) { - return val === this.options[index]; - }, thisObject); - - options.map(function (val, index) { - if (val === this.options[index]) - return this.options[index]; - }, thisObject); - - options.some(function (val, index) { - return val === this.options[index]; - }, thisObject); - - options.filter(function (val, index) { - return val === this.options[index]; - }, thisObject); - - options.every(function (val, index) { - return val === this.options[index]; - }, thisObject); - } - - test9(options: Float64Array[]) { - const thisObject = { - options: [] as Float64Array[] - }; - - options.find(function (val, index) { - return val === this.options[index]; - }, thisObject); - - options.findIndex(function (val, index) { - return val === this.options[index]; - }, thisObject); - - options.forEach(function (val, index) { - return val === this.options[index]; - }, thisObject); - - options.map(function (val, index) { - if (val === this.options[index]) - return this.options[index]; - }, thisObject); - - options.some(function (val, index) { - return val === this.options[index]; - }, thisObject); - - options.filter(function (val, index) { - return val === this.options[index]; - }, thisObject); - - options.every(function (val, index) { - return val === this.options[index]; - }, thisObject); - } -} From 601c113d93baa282eaa14b1a4f6dfd229825c2b5 Mon Sep 17 00:00:00 2001 From: Andy Date: Wed, 30 Aug 2017 14:19:49 -0700 Subject: [PATCH 195/370] Handle indexed access types in getSymbolAtLocation and findAllReferences (#18149) * Handle indexed access types in getSymbolAtLocation and findAllReferences * Update baselines, simplify `const objectType` --- src/compiler/checker.ts | 17 +++++---- src/services/findAllReferences.ts | 4 +- src/services/rename.ts | 14 +++++-- src/services/utilities.ts | 38 +++++++++---------- ...pedReservedCompilerNamedIdentifier.symbols | 4 ++ .../underscoreEscapedNameInEnum.symbols | 1 + .../findAllRefsIndexedAccessTypes.ts | 14 +++++++ 7 files changed, 59 insertions(+), 33 deletions(-) create mode 100644 tests/cases/fourslash/findAllRefsIndexedAccessTypes.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 866fda18b03..ea88fd2a4b3 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -22929,7 +22929,7 @@ namespace ts { return undefined; } - function getSymbolAtLocation(node: Node) { + function getSymbolAtLocation(node: Node): Symbol | undefined { if (node.kind === SyntaxKind.SourceFile) { return isExternalModule(node) ? getMergedSymbol(node.symbol) : undefined; } @@ -23007,13 +23007,16 @@ namespace ts { case SyntaxKind.NumericLiteral: // index access - if (node.parent.kind === SyntaxKind.ElementAccessExpression && (node.parent).argumentExpression === node) { - const objectType = getTypeOfExpression((node.parent).expression); - return getPropertyOfType(objectType, (node).text as __String); - } - break; + const objectType = isElementAccessExpression(node.parent) + ? node.parent.argumentExpression === node ? getTypeOfExpression(node.parent.expression) : undefined + : isLiteralTypeNode(node.parent) && isIndexedAccessTypeNode(node.parent.parent) + ? getTypeFromTypeNode(node.parent.parent.objectType) + : undefined; + return objectType && getPropertyOfType(objectType, escapeLeadingUnderscores((node as StringLiteral | NumericLiteral).text)); + + default: + return undefined; } - return undefined; } function getShorthandAssignmentValueSymbol(location: Node): Symbol { diff --git a/src/services/findAllReferences.ts b/src/services/findAllReferences.ts index 4c8563b1b94..04d383748c8 100644 --- a/src/services/findAllReferences.ts +++ b/src/services/findAllReferences.ts @@ -748,11 +748,11 @@ namespace ts.FindAllReferences.Core { return (node as Identifier).text.length === searchSymbolName.length; case SyntaxKind.StringLiteral: - return (isLiteralNameOfPropertyDeclarationOrIndexAccess(node) || isNameOfExternalModuleImportOrDeclaration(node)) && + return (isLiteralNameOfPropertyDeclarationOrIndexAccess(node as StringLiteral) || isNameOfExternalModuleImportOrDeclaration(node)) && (node as StringLiteral).text.length === searchSymbolName.length; case SyntaxKind.NumericLiteral: - return isLiteralNameOfPropertyDeclarationOrIndexAccess(node) && (node as NumericLiteral).text.length === searchSymbolName.length; + return isLiteralNameOfPropertyDeclarationOrIndexAccess(node as NumericLiteral) && (node as NumericLiteral).text.length === searchSymbolName.length; default: return false; diff --git a/src/services/rename.ts b/src/services/rename.ts index 6091c0b2d03..8411e8200a3 100644 --- a/src/services/rename.ts +++ b/src/services/rename.ts @@ -89,9 +89,15 @@ namespace ts.Rename { } function nodeIsEligibleForRename(node: Node): boolean { - return node.kind === ts.SyntaxKind.Identifier || - node.kind === SyntaxKind.StringLiteral || - isLiteralNameOfPropertyDeclarationOrIndexAccess(node) || - isThis(node); + switch (node.kind) { + case SyntaxKind.Identifier: + case SyntaxKind.StringLiteral: + case SyntaxKind.ThisKeyword: + return true; + case SyntaxKind.NumericLiteral: + return isLiteralNameOfPropertyDeclarationOrIndexAccess(node as NumericLiteral); + default: + return false; + } } } diff --git a/src/services/utilities.ts b/src/services/utilities.ts index e8f01bb0785..c7f5b5909f0 100644 --- a/src/services/utilities.ts +++ b/src/services/utilities.ts @@ -244,27 +244,25 @@ namespace ts { isFunctionLike(node.parent) && (node.parent).name === node; } - export function isLiteralNameOfPropertyDeclarationOrIndexAccess(node: Node): boolean { - if (node.kind === SyntaxKind.StringLiteral || node.kind === SyntaxKind.NumericLiteral) { - switch (node.parent.kind) { - case SyntaxKind.PropertyDeclaration: - case SyntaxKind.PropertySignature: - case SyntaxKind.PropertyAssignment: - case SyntaxKind.EnumMember: - case SyntaxKind.MethodDeclaration: - case SyntaxKind.MethodSignature: - case SyntaxKind.GetAccessor: - case SyntaxKind.SetAccessor: - case SyntaxKind.ModuleDeclaration: - return getNameOfDeclaration(node.parent) === node; - case SyntaxKind.ElementAccessExpression: - return (node.parent).argumentExpression === node; - case SyntaxKind.ComputedPropertyName: - return true; - } + export function isLiteralNameOfPropertyDeclarationOrIndexAccess(node: StringLiteral | NumericLiteral): boolean { + switch (node.parent.kind) { + case SyntaxKind.PropertyDeclaration: + case SyntaxKind.PropertySignature: + case SyntaxKind.PropertyAssignment: + case SyntaxKind.EnumMember: + case SyntaxKind.MethodDeclaration: + case SyntaxKind.MethodSignature: + case SyntaxKind.GetAccessor: + case SyntaxKind.SetAccessor: + case SyntaxKind.ModuleDeclaration: + return getNameOfDeclaration(node.parent) === node; + case SyntaxKind.ElementAccessExpression: + return (node.parent).argumentExpression === node; + case SyntaxKind.ComputedPropertyName: + return true; + case SyntaxKind.LiteralType: + return node.parent.parent.kind === SyntaxKind.IndexedAccessType; } - - return false; } export function isExpressionOfExternalModuleImportEqualsDeclaration(node: Node) { diff --git a/tests/baselines/reference/escapedReservedCompilerNamedIdentifier.symbols b/tests/baselines/reference/escapedReservedCompilerNamedIdentifier.symbols index 9cdd59134cb..b629c5bd875 100644 --- a/tests/baselines/reference/escapedReservedCompilerNamedIdentifier.symbols +++ b/tests/baselines/reference/escapedReservedCompilerNamedIdentifier.symbols @@ -11,6 +11,7 @@ var o = { var b = o["__proto__"]; >b : Symbol(b, Decl(escapedReservedCompilerNamedIdentifier.ts, 5, 3)) >o : Symbol(o, Decl(escapedReservedCompilerNamedIdentifier.ts, 2, 3)) +>"__proto__" : Symbol("__proto__", Decl(escapedReservedCompilerNamedIdentifier.ts, 2, 9)) var o1 = { >o1 : Symbol(o1, Decl(escapedReservedCompilerNamedIdentifier.ts, 6, 3)) @@ -22,6 +23,7 @@ var o1 = { var b1 = o1["__proto__"]; >b1 : Symbol(b1, Decl(escapedReservedCompilerNamedIdentifier.ts, 9, 3)) >o1 : Symbol(o1, Decl(escapedReservedCompilerNamedIdentifier.ts, 6, 3)) +>"__proto__" : Symbol(__proto__, Decl(escapedReservedCompilerNamedIdentifier.ts, 6, 10)) // Triple underscores var ___proto__ = 10; @@ -35,6 +37,7 @@ var o2 = { var b2 = o2["___proto__"]; >b2 : Symbol(b2, Decl(escapedReservedCompilerNamedIdentifier.ts, 15, 3)) >o2 : Symbol(o2, Decl(escapedReservedCompilerNamedIdentifier.ts, 12, 3)) +>"___proto__" : Symbol("___proto__", Decl(escapedReservedCompilerNamedIdentifier.ts, 12, 10)) var o3 = { >o3 : Symbol(o3, Decl(escapedReservedCompilerNamedIdentifier.ts, 16, 3)) @@ -46,6 +49,7 @@ var o3 = { var b3 = o3["___proto__"]; >b3 : Symbol(b3, Decl(escapedReservedCompilerNamedIdentifier.ts, 19, 3)) >o3 : Symbol(o3, Decl(escapedReservedCompilerNamedIdentifier.ts, 16, 3)) +>"___proto__" : Symbol(___proto__, Decl(escapedReservedCompilerNamedIdentifier.ts, 16, 10)) // One underscore var _proto__ = 10; diff --git a/tests/baselines/reference/underscoreEscapedNameInEnum.symbols b/tests/baselines/reference/underscoreEscapedNameInEnum.symbols index 4546d844cd2..98e2a931cf8 100644 --- a/tests/baselines/reference/underscoreEscapedNameInEnum.symbols +++ b/tests/baselines/reference/underscoreEscapedNameInEnum.symbols @@ -6,5 +6,6 @@ enum E { bar = E["__foo"] + 1 >bar : Symbol(E.bar, Decl(underscoreEscapedNameInEnum.ts, 1, 16)) >E : Symbol(E, Decl(underscoreEscapedNameInEnum.ts, 0, 0)) +>"__foo" : Symbol(E["__foo"], Decl(underscoreEscapedNameInEnum.ts, 0, 8)) } diff --git a/tests/cases/fourslash/findAllRefsIndexedAccessTypes.ts b/tests/cases/fourslash/findAllRefsIndexedAccessTypes.ts new file mode 100644 index 00000000000..fdfb00439f6 --- /dev/null +++ b/tests/cases/fourslash/findAllRefsIndexedAccessTypes.ts @@ -0,0 +1,14 @@ +/// + +////interface I { +//// [|{| "isDefinition": true, "isWriteAccess": true |}0|]: number; +//// [|{| "isDefinition": true, "isWriteAccess": true |}s|]: string; +////} +////interface J { +//// a: I[[|0|]], +//// b: I["[|s|]"], +////} + +const [n0, s0, n1, s1] = test.ranges(); +verify.singleReferenceGroup("(property) I[0]: number", [n0, n1]); +verify.singleReferenceGroup("(property) I.s: string", [s0, s1]); From effa2597fa89ddca314f25e81c68ab848492e003 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Wed, 30 Aug 2017 16:22:16 -0700 Subject: [PATCH 196/370] Cache contextual type for || operator to avoid exponential compile time --- src/compiler/checker.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index ea88fd2a4b3..a73a29d648d 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -13059,7 +13059,7 @@ namespace ts { // expression has no contextual type, the right operand is contextually typed by the type of the left operand. let type = getContextualType(binaryExpression); if (!type && node === binaryExpression.right) { - type = getTypeOfExpression(binaryExpression.left); + type = getTypeOfExpression(binaryExpression.left, /*cache*/ true); } return type; } From 4c543230c6b01a755c362bad7255a655821fed31 Mon Sep 17 00:00:00 2001 From: Mohamed Hegazy Date: Wed, 30 Aug 2017 16:53:22 -0700 Subject: [PATCH 197/370] Update Authors.md --- .mailmap | 13 +++++++++++-- AUTHORS.md | 9 +++++++++ 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/.mailmap b/.mailmap index 97941bcdf5a..7ae5cb19818 100644 --- a/.mailmap +++ b/.mailmap @@ -17,6 +17,8 @@ Andy Hanson Andy Anil Anar Anton Tolmachev Anubha Mathur anubmat +Armando Aguirre +Arnaud Tournier Arnavion # Arnav Singh Arthur Ozga Arthur Ozga Arthur Ozga Arthur Ozga Arthur Ozga Asad Saeeduddin @@ -26,6 +28,7 @@ Bill Ticehurst Bill Ticehurst Ben Duffield Ben Mosher Benjamin Bock +Benjamin Lichtman uniqueiniquity Blake Embrey Bowden Kelly Brett Mayen @@ -59,6 +62,7 @@ Evan Sebastian Eyas # Eyas Sharaiha Fabian Cook falsandtru # @falsandtru +Filipe Silva flowmemo # @flowmemo Frank Wallis František Žiacik František Žiacik @@ -192,7 +196,7 @@ TruongSinh Tran-Nguyen vilicvane # Vilic Vane Vladimir Matveev vladima v2m Vadi Taslim -Wesley Wigham Wesley Wigham +Wesley Wigham Wesley Wigham Wesley Wigham York Yao york yao yaoyao Yuichi Nukiyama YuichiNukiyama Zev Spitz @@ -267,4 +271,9 @@ Reiner Dolp t_ # @t_ TravCav # @TravCav Vladimir Kurchatkin -William Orr \ No newline at end of file +William Orr +Francois Wouts +Jan Melcher Jan Melcher +Matt Mitchell +Maxwell Paul Brickner +Tycho Grouwstra \ No newline at end of file diff --git a/AUTHORS.md b/AUTHORS.md index 824c696ce4f..4f94a67f7dd 100644 --- a/AUTHORS.md +++ b/AUTHORS.md @@ -25,6 +25,8 @@ TypeScript is authored by: * Anton Khlynovskiy * Anton Tolmachev * Anubha Mathur +* Armando Aguirre +* Arnaud Tournier * Arnav Singh * Arthur Ozga * Asad Saeeduddin @@ -33,6 +35,7 @@ TypeScript is authored by: * Ben Duffield * Ben Mosher * Benjamin Bock +* Benjamin Lichtman * Benny Neugebauer * Bill Ticehurst * Blaine Bublitz @@ -85,7 +88,9 @@ TypeScript is authored by: * Eyas Sharaiha * Fabian Cook * @falsandtru +* Filipe Silva * @flowmemo +* Francois Wouts * Frank Wallis * Franklin Tse * František Žiacik @@ -112,6 +117,7 @@ TypeScript is authored by: * Jakub Młokosiewicz * James Henry * James Whitney +* Jan Melcher * Jason Freeman * Jason Jarrett * Jason Killian @@ -162,9 +168,11 @@ TypeScript is authored by: * Masahiro Wakame * Matt Bierner * Matt McCutchen +* Matt Mitchell * Mattias Buelens * Mattias Buelens * Max Deepfield +* Maxwell Paul Brickner * Micah Zoltu * Michael * Michael Bromley @@ -243,6 +251,7 @@ TypeScript is authored by: * Torben Fitschen * @TravCav * TruongSinh Tran-Nguyen +* Tycho Grouwstra * Vadi Taslim * Vidar Tonaas Fauske * Viktor Zozulyak From 42b66066f9f02a73145c90aa99eb690aa18ea3a5 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Wed, 30 Aug 2017 17:14:16 -0700 Subject: [PATCH 198/370] Add regression test --- .../reference/contextualTypeLogicalOr.js | 36 +++++ .../reference/contextualTypeLogicalOr.symbols | 48 ++++++ .../reference/contextualTypeLogicalOr.types | 139 ++++++++++++++++++ .../cases/compiler/contextualTypeLogicalOr.ts | 17 +++ 4 files changed, 240 insertions(+) create mode 100644 tests/baselines/reference/contextualTypeLogicalOr.js create mode 100644 tests/baselines/reference/contextualTypeLogicalOr.symbols create mode 100644 tests/baselines/reference/contextualTypeLogicalOr.types create mode 100644 tests/cases/compiler/contextualTypeLogicalOr.ts diff --git a/tests/baselines/reference/contextualTypeLogicalOr.js b/tests/baselines/reference/contextualTypeLogicalOr.js new file mode 100644 index 00000000000..cad10007fc4 --- /dev/null +++ b/tests/baselines/reference/contextualTypeLogicalOr.js @@ -0,0 +1,36 @@ +//// [contextualTypeLogicalOr.ts] +// Repro from #18005 + +let x = 123; +var a = + x && [1, 2, 3, 4] || + x && [1, 2, 3, 4] || + x && [1, 2, 3, 4] || + x && [1, 2, 3, 4] || + x && [1, 2, 3, 4] || + x && [1, 2, 3, 4] || + x && [1, 2, 3, 4] || + x && [1, 2, 3, 4] || + x && [1, 2, 3, 4] || + x && [1, 2, 3, 4] || + x && [1, 2, 3, 4] || + x && [1, 2, 3, 4] || + x && [1, 2, 3, 4]; + + +//// [contextualTypeLogicalOr.js] +// Repro from #18005 +var x = 123; +var a = x && [1, 2, 3, 4] || + x && [1, 2, 3, 4] || + x && [1, 2, 3, 4] || + x && [1, 2, 3, 4] || + x && [1, 2, 3, 4] || + x && [1, 2, 3, 4] || + x && [1, 2, 3, 4] || + x && [1, 2, 3, 4] || + x && [1, 2, 3, 4] || + x && [1, 2, 3, 4] || + x && [1, 2, 3, 4] || + x && [1, 2, 3, 4] || + x && [1, 2, 3, 4]; diff --git a/tests/baselines/reference/contextualTypeLogicalOr.symbols b/tests/baselines/reference/contextualTypeLogicalOr.symbols new file mode 100644 index 00000000000..56a73aec320 --- /dev/null +++ b/tests/baselines/reference/contextualTypeLogicalOr.symbols @@ -0,0 +1,48 @@ +=== tests/cases/compiler/contextualTypeLogicalOr.ts === +// Repro from #18005 + +let x = 123; +>x : Symbol(x, Decl(contextualTypeLogicalOr.ts, 2, 3)) + +var a = +>a : Symbol(a, Decl(contextualTypeLogicalOr.ts, 3, 3)) + + x && [1, 2, 3, 4] || +>x : Symbol(x, Decl(contextualTypeLogicalOr.ts, 2, 3)) + + x && [1, 2, 3, 4] || +>x : Symbol(x, Decl(contextualTypeLogicalOr.ts, 2, 3)) + + x && [1, 2, 3, 4] || +>x : Symbol(x, Decl(contextualTypeLogicalOr.ts, 2, 3)) + + x && [1, 2, 3, 4] || +>x : Symbol(x, Decl(contextualTypeLogicalOr.ts, 2, 3)) + + x && [1, 2, 3, 4] || +>x : Symbol(x, Decl(contextualTypeLogicalOr.ts, 2, 3)) + + x && [1, 2, 3, 4] || +>x : Symbol(x, Decl(contextualTypeLogicalOr.ts, 2, 3)) + + x && [1, 2, 3, 4] || +>x : Symbol(x, Decl(contextualTypeLogicalOr.ts, 2, 3)) + + x && [1, 2, 3, 4] || +>x : Symbol(x, Decl(contextualTypeLogicalOr.ts, 2, 3)) + + x && [1, 2, 3, 4] || +>x : Symbol(x, Decl(contextualTypeLogicalOr.ts, 2, 3)) + + x && [1, 2, 3, 4] || +>x : Symbol(x, Decl(contextualTypeLogicalOr.ts, 2, 3)) + + x && [1, 2, 3, 4] || +>x : Symbol(x, Decl(contextualTypeLogicalOr.ts, 2, 3)) + + x && [1, 2, 3, 4] || +>x : Symbol(x, Decl(contextualTypeLogicalOr.ts, 2, 3)) + + x && [1, 2, 3, 4]; +>x : Symbol(x, Decl(contextualTypeLogicalOr.ts, 2, 3)) + diff --git a/tests/baselines/reference/contextualTypeLogicalOr.types b/tests/baselines/reference/contextualTypeLogicalOr.types new file mode 100644 index 00000000000..7d380a2ace3 --- /dev/null +++ b/tests/baselines/reference/contextualTypeLogicalOr.types @@ -0,0 +1,139 @@ +=== tests/cases/compiler/contextualTypeLogicalOr.ts === +// Repro from #18005 + +let x = 123; +>x : number +>123 : 123 + +var a = +>a : number[] + + x && [1, 2, 3, 4] || +>x && [1, 2, 3, 4] || x && [1, 2, 3, 4] || x && [1, 2, 3, 4] || x && [1, 2, 3, 4] || x && [1, 2, 3, 4] || x && [1, 2, 3, 4] || x && [1, 2, 3, 4] || x && [1, 2, 3, 4] || x && [1, 2, 3, 4] || x && [1, 2, 3, 4] || x && [1, 2, 3, 4] || x && [1, 2, 3, 4] || x && [1, 2, 3, 4] : number[] +>x && [1, 2, 3, 4] || x && [1, 2, 3, 4] || x && [1, 2, 3, 4] || x && [1, 2, 3, 4] || x && [1, 2, 3, 4] || x && [1, 2, 3, 4] || x && [1, 2, 3, 4] || x && [1, 2, 3, 4] || x && [1, 2, 3, 4] || x && [1, 2, 3, 4] || x && [1, 2, 3, 4] || x && [1, 2, 3, 4] : number[] +>x && [1, 2, 3, 4] || x && [1, 2, 3, 4] || x && [1, 2, 3, 4] || x && [1, 2, 3, 4] || x && [1, 2, 3, 4] || x && [1, 2, 3, 4] || x && [1, 2, 3, 4] || x && [1, 2, 3, 4] || x && [1, 2, 3, 4] || x && [1, 2, 3, 4] || x && [1, 2, 3, 4] : number[] +>x && [1, 2, 3, 4] || x && [1, 2, 3, 4] || x && [1, 2, 3, 4] || x && [1, 2, 3, 4] || x && [1, 2, 3, 4] || x && [1, 2, 3, 4] || x && [1, 2, 3, 4] || x && [1, 2, 3, 4] || x && [1, 2, 3, 4] || x && [1, 2, 3, 4] : number[] +>x && [1, 2, 3, 4] || x && [1, 2, 3, 4] || x && [1, 2, 3, 4] || x && [1, 2, 3, 4] || x && [1, 2, 3, 4] || x && [1, 2, 3, 4] || x && [1, 2, 3, 4] || x && [1, 2, 3, 4] || x && [1, 2, 3, 4] : number[] +>x && [1, 2, 3, 4] || x && [1, 2, 3, 4] || x && [1, 2, 3, 4] || x && [1, 2, 3, 4] || x && [1, 2, 3, 4] || x && [1, 2, 3, 4] || x && [1, 2, 3, 4] || x && [1, 2, 3, 4] : number[] +>x && [1, 2, 3, 4] || x && [1, 2, 3, 4] || x && [1, 2, 3, 4] || x && [1, 2, 3, 4] || x && [1, 2, 3, 4] || x && [1, 2, 3, 4] || x && [1, 2, 3, 4] : number[] +>x && [1, 2, 3, 4] || x && [1, 2, 3, 4] || x && [1, 2, 3, 4] || x && [1, 2, 3, 4] || x && [1, 2, 3, 4] || x && [1, 2, 3, 4] : number[] +>x && [1, 2, 3, 4] || x && [1, 2, 3, 4] || x && [1, 2, 3, 4] || x && [1, 2, 3, 4] || x && [1, 2, 3, 4] : number[] +>x && [1, 2, 3, 4] || x && [1, 2, 3, 4] || x && [1, 2, 3, 4] || x && [1, 2, 3, 4] : number[] +>x && [1, 2, 3, 4] || x && [1, 2, 3, 4] || x && [1, 2, 3, 4] : number[] +>x && [1, 2, 3, 4] || x && [1, 2, 3, 4] : number[] +>x && [1, 2, 3, 4] : number[] +>x : number +>[1, 2, 3, 4] : number[] +>1 : 1 +>2 : 2 +>3 : 3 +>4 : 4 + + x && [1, 2, 3, 4] || +>x && [1, 2, 3, 4] : number[] +>x : number +>[1, 2, 3, 4] : number[] +>1 : 1 +>2 : 2 +>3 : 3 +>4 : 4 + + x && [1, 2, 3, 4] || +>x && [1, 2, 3, 4] : number[] +>x : number +>[1, 2, 3, 4] : number[] +>1 : 1 +>2 : 2 +>3 : 3 +>4 : 4 + + x && [1, 2, 3, 4] || +>x && [1, 2, 3, 4] : number[] +>x : number +>[1, 2, 3, 4] : number[] +>1 : 1 +>2 : 2 +>3 : 3 +>4 : 4 + + x && [1, 2, 3, 4] || +>x && [1, 2, 3, 4] : number[] +>x : number +>[1, 2, 3, 4] : number[] +>1 : 1 +>2 : 2 +>3 : 3 +>4 : 4 + + x && [1, 2, 3, 4] || +>x && [1, 2, 3, 4] : number[] +>x : number +>[1, 2, 3, 4] : number[] +>1 : 1 +>2 : 2 +>3 : 3 +>4 : 4 + + x && [1, 2, 3, 4] || +>x && [1, 2, 3, 4] : number[] +>x : number +>[1, 2, 3, 4] : number[] +>1 : 1 +>2 : 2 +>3 : 3 +>4 : 4 + + x && [1, 2, 3, 4] || +>x && [1, 2, 3, 4] : number[] +>x : number +>[1, 2, 3, 4] : number[] +>1 : 1 +>2 : 2 +>3 : 3 +>4 : 4 + + x && [1, 2, 3, 4] || +>x && [1, 2, 3, 4] : number[] +>x : number +>[1, 2, 3, 4] : number[] +>1 : 1 +>2 : 2 +>3 : 3 +>4 : 4 + + x && [1, 2, 3, 4] || +>x && [1, 2, 3, 4] : number[] +>x : number +>[1, 2, 3, 4] : number[] +>1 : 1 +>2 : 2 +>3 : 3 +>4 : 4 + + x && [1, 2, 3, 4] || +>x && [1, 2, 3, 4] : number[] +>x : number +>[1, 2, 3, 4] : number[] +>1 : 1 +>2 : 2 +>3 : 3 +>4 : 4 + + x && [1, 2, 3, 4] || +>x && [1, 2, 3, 4] : number[] +>x : number +>[1, 2, 3, 4] : number[] +>1 : 1 +>2 : 2 +>3 : 3 +>4 : 4 + + x && [1, 2, 3, 4]; +>x && [1, 2, 3, 4] : number[] +>x : number +>[1, 2, 3, 4] : number[] +>1 : 1 +>2 : 2 +>3 : 3 +>4 : 4 + diff --git a/tests/cases/compiler/contextualTypeLogicalOr.ts b/tests/cases/compiler/contextualTypeLogicalOr.ts new file mode 100644 index 00000000000..5ce48cb71cc --- /dev/null +++ b/tests/cases/compiler/contextualTypeLogicalOr.ts @@ -0,0 +1,17 @@ +// Repro from #18005 + +let x = 123; +var a = + x && [1, 2, 3, 4] || + x && [1, 2, 3, 4] || + x && [1, 2, 3, 4] || + x && [1, 2, 3, 4] || + x && [1, 2, 3, 4] || + x && [1, 2, 3, 4] || + x && [1, 2, 3, 4] || + x && [1, 2, 3, 4] || + x && [1, 2, 3, 4] || + x && [1, 2, 3, 4] || + x && [1, 2, 3, 4] || + x && [1, 2, 3, 4] || + x && [1, 2, 3, 4]; From 3e850156da8be9b6763abfe44d8e4062a07c0a9a Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Thu, 31 Aug 2017 10:15:42 -0700 Subject: [PATCH 199/370] Propagate isRestParameter through symbol instantiation (#18087) * Add repro from #17666 * Actually use repro from issue, propegate isRestParameter on instantiation --- src/compiler/checker.ts | 3 ++ .../reference/superNoModifiersCrash.js | 42 +++++++++++++++++++ .../reference/superNoModifiersCrash.symbols | 25 +++++++++++ .../reference/superNoModifiersCrash.types | 32 ++++++++++++++ tests/cases/compiler/superNoModifiersCrash.ts | 14 +++++++ 5 files changed, 116 insertions(+) create mode 100644 tests/baselines/reference/superNoModifiersCrash.js create mode 100644 tests/baselines/reference/superNoModifiersCrash.symbols create mode 100644 tests/baselines/reference/superNoModifiersCrash.types create mode 100644 tests/cases/compiler/superNoModifiersCrash.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index a73a29d648d..269666d7b94 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -8168,6 +8168,9 @@ namespace ts { if (symbol.valueDeclaration) { result.valueDeclaration = symbol.valueDeclaration; } + if ((symbol as TransientSymbol).isRestParameter) { + result.isRestParameter = (symbol as TransientSymbol).isRestParameter; + } return result; } diff --git a/tests/baselines/reference/superNoModifiersCrash.js b/tests/baselines/reference/superNoModifiersCrash.js new file mode 100644 index 00000000000..be9f6eb4481 --- /dev/null +++ b/tests/baselines/reference/superNoModifiersCrash.js @@ -0,0 +1,42 @@ +//// [File.js] +class Parent { + initialize() { + super.initialize(...arguments) + return this.asdf = '' + } + } + +class Child extends Parent { + initialize() { + } +} + +//// [File.js] +var __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +var Parent = /** @class */ (function () { + function Parent() { + } + Parent.prototype.initialize = function () { + _super.prototype.initialize.apply(this, arguments); + return this.asdf = ''; + }; + return Parent; +}()); +var Child = /** @class */ (function (_super) { + __extends(Child, _super); + function Child() { + return _super !== null && _super.apply(this, arguments) || this; + } + Child.prototype.initialize = function () { + }; + return Child; +}(Parent)); diff --git a/tests/baselines/reference/superNoModifiersCrash.symbols b/tests/baselines/reference/superNoModifiersCrash.symbols new file mode 100644 index 00000000000..59f56aaa59e --- /dev/null +++ b/tests/baselines/reference/superNoModifiersCrash.symbols @@ -0,0 +1,25 @@ +=== tests/cases/compiler/File.js === +class Parent { +>Parent : Symbol(Parent, Decl(File.js, 0, 0)) + + initialize() { +>initialize : Symbol(Parent.initialize, Decl(File.js, 0, 14)) + + super.initialize(...arguments) +>arguments : Symbol(arguments) + + return this.asdf = '' +>this.asdf : Symbol(Parent.asdf, Decl(File.js, 3, 14)) +>this : Symbol(Parent, Decl(File.js, 0, 0)) +>asdf : Symbol(Parent.asdf, Decl(File.js, 3, 14)) + } + } + +class Child extends Parent { +>Child : Symbol(Child, Decl(File.js, 5, 3)) +>Parent : Symbol(Parent, Decl(File.js, 0, 0)) + + initialize() { +>initialize : Symbol(Child.initialize, Decl(File.js, 7, 28)) + } +} diff --git a/tests/baselines/reference/superNoModifiersCrash.types b/tests/baselines/reference/superNoModifiersCrash.types new file mode 100644 index 00000000000..231e4a661bb --- /dev/null +++ b/tests/baselines/reference/superNoModifiersCrash.types @@ -0,0 +1,32 @@ +=== tests/cases/compiler/File.js === +class Parent { +>Parent : Parent + + initialize() { +>initialize : (...args: any[]) => string + + super.initialize(...arguments) +>super.initialize(...arguments) : any +>super.initialize : any +>super : any +>initialize : any +>...arguments : any +>arguments : IArguments + + return this.asdf = '' +>this.asdf = '' : "" +>this.asdf : string +>this : this +>asdf : string +>'' : "" + } + } + +class Child extends Parent { +>Child : Child +>Parent : Parent + + initialize() { +>initialize : () => void + } +} diff --git a/tests/cases/compiler/superNoModifiersCrash.ts b/tests/cases/compiler/superNoModifiersCrash.ts new file mode 100644 index 00000000000..4e83184364a --- /dev/null +++ b/tests/cases/compiler/superNoModifiersCrash.ts @@ -0,0 +1,14 @@ +// @allowjs: true +// @outDir: ../ +// @filename: File.js +class Parent { + initialize() { + super.initialize(...arguments) + return this.asdf = '' + } + } + +class Child extends Parent { + initialize() { + } +} \ No newline at end of file From 3d0c239bfd8c63172db75ed28ad9c2d6d39f372c Mon Sep 17 00:00:00 2001 From: Mohamed Hegazy Date: Thu, 31 Aug 2017 11:42:56 -0700 Subject: [PATCH 200/370] Update generated files (#18173) --- src/lib/dom.generated.d.ts | 4 ++-- src/lib/webworker.generated.d.ts | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/lib/dom.generated.d.ts b/src/lib/dom.generated.d.ts index feb38887ab9..d4ee81e4974 100644 --- a/src/lib/dom.generated.d.ts +++ b/src/lib/dom.generated.d.ts @@ -3885,7 +3885,7 @@ interface Headers { declare var Headers: { prototype: Headers; - new(init?: Headers | string[][]): Headers; + new(init?: Headers | string[][] | object): Headers; }; interface History { @@ -9514,7 +9514,7 @@ interface ServiceWorkerContainer extends EventTarget { oncontrollerchange: (this: ServiceWorkerContainer, ev: Event) => any; onmessage: (this: ServiceWorkerContainer, ev: ServiceWorkerMessageEvent) => any; readonly ready: Promise; - getRegistration(clientURL?: USVString): Promise; + getRegistration(): Promise; getRegistrations(): Promise; register(scriptURL: USVString, options?: RegistrationOptions): Promise; addEventListener(type: K, listener: (this: ServiceWorkerContainer, ev: ServiceWorkerContainerEventMap[K]) => any, useCapture?: boolean): void; diff --git a/src/lib/webworker.generated.d.ts b/src/lib/webworker.generated.d.ts index 38c0cfeefff..821a7edd886 100644 --- a/src/lib/webworker.generated.d.ts +++ b/src/lib/webworker.generated.d.ts @@ -470,7 +470,7 @@ interface Headers { declare var Headers: { prototype: Headers; - new(init?: Headers | string[][]): Headers; + new(init?: Headers | string[][] | object): Headers; }; interface IDBCursor { From c7b4ed3a91964915b953b34ad2ae72f36e7d6efe Mon Sep 17 00:00:00 2001 From: Matt Bierner Date: Thu, 31 Aug 2017 13:21:08 -0700 Subject: [PATCH 201/370] Fix extract method for anon class expressions (#18168) Check `scope.name` when trying to extract from an anon class --- src/harness/unittests/extractMethods.ts | 8 ++++++ src/services/refactors/extractMethod.ts | 2 +- .../extractMethod/extractMethod20.ts | 28 +++++++++++++++++++ 3 files changed, 37 insertions(+), 1 deletion(-) create mode 100644 tests/baselines/reference/extractMethod/extractMethod20.ts diff --git a/src/harness/unittests/extractMethods.ts b/src/harness/unittests/extractMethods.ts index a7741a56f59..c8b4b35ff1c 100644 --- a/src/harness/unittests/extractMethods.ts +++ b/src/harness/unittests/extractMethods.ts @@ -606,6 +606,14 @@ namespace A { `function F(v: V) { [#|v.toString()|]; }`); + + testExtractMethod("extractMethod20", + `const _ = class { + a() { + [#|let a1 = { x: 1 }; + return a1.x + 10;|] + } +}`); }); diff --git a/src/services/refactors/extractMethod.ts b/src/services/refactors/extractMethod.ts index 66ab0126aaa..1a96857b73e 100644 --- a/src/services/refactors/extractMethod.ts +++ b/src/services/refactors/extractMethod.ts @@ -584,7 +584,7 @@ namespace ts.refactor.extractMethod { else if (isClassLike(scope)) { return scope.kind === SyntaxKind.ClassDeclaration ? `class '${scope.name.text}'` - : scope.name.text + : scope.name && scope.name.text ? `class expression '${scope.name.text}'` : "anonymous class expression"; } diff --git a/tests/baselines/reference/extractMethod/extractMethod20.ts b/tests/baselines/reference/extractMethod/extractMethod20.ts new file mode 100644 index 00000000000..7c35caee30f --- /dev/null +++ b/tests/baselines/reference/extractMethod/extractMethod20.ts @@ -0,0 +1,28 @@ +// ==ORIGINAL== +const _ = class { + a() { + let a1 = { x: 1 }; + return a1.x + 10; + } +} +// ==SCOPE::anonymous class expression== +const _ = class { + a() { + return this.newFunction(); + } + + private newFunction() { + let a1 = { x: 1 }; + return a1.x + 10; + } +} +// ==SCOPE::global scope== +const _ = class { + a() { + return newFunction(); + } +} +function newFunction() { + let a1 = { x: 1 }; + return a1.x + 10; +} From c2168cb94a15879c917797b60734891e194ddca9 Mon Sep 17 00:00:00 2001 From: Armando Aguirre Date: Thu, 31 Aug 2017 14:05:41 -0700 Subject: [PATCH 202/370] Added logic to check for EOF when creating a missing node. --- src/compiler/parser.ts | 5 ++++- .../reference/conflictMarkerTrivia4.errors.txt | 8 ++++---- .../incompleteDottedExpressionAtEOF.errors.txt | 4 ++-- .../baselines/reference/jsxAndTypeAssertion.errors.txt | 10 ++++++++-- ...platesWithIncompleteTemplateExpressions4.errors.txt | 9 ++++++--- ...platesWithIncompleteTemplateExpressions5.errors.txt | 9 ++++++--- 6 files changed, 30 insertions(+), 15 deletions(-) diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index 7486c7541be..3e446ef4cc3 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -1208,7 +1208,10 @@ namespace ts { return finishNode(node); } - return createMissingNode(SyntaxKind.Identifier, /*reportAtCurrentPosition*/ false, diagnosticMessage || Diagnostics.Identifier_expected); + // Only for end of file because the error gets reported incorrectly on embedded script tags. + const reportAtCurrentPosition = token() === SyntaxKind.EndOfFileToken; + + return createMissingNode(SyntaxKind.Identifier, reportAtCurrentPosition, diagnosticMessage || Diagnostics.Identifier_expected); } function parseIdentifier(diagnosticMessage?: DiagnosticMessage): Identifier { diff --git a/tests/baselines/reference/conflictMarkerTrivia4.errors.txt b/tests/baselines/reference/conflictMarkerTrivia4.errors.txt index 476dbbce6ce..5ea1b27f7f0 100644 --- a/tests/baselines/reference/conflictMarkerTrivia4.errors.txt +++ b/tests/baselines/reference/conflictMarkerTrivia4.errors.txt @@ -1,14 +1,14 @@ tests/cases/compiler/conflictMarkerTrivia4.ts(1,12): error TS2304: Cannot find name 'div'. +tests/cases/compiler/conflictMarkerTrivia4.ts(1,16): error TS1109: Expression expected. tests/cases/compiler/conflictMarkerTrivia4.ts(2,1): error TS1185: Merge conflict marker encountered. -tests/cases/compiler/conflictMarkerTrivia4.ts(2,13): error TS1109: Expression expected. ==== tests/cases/compiler/conflictMarkerTrivia4.ts (3 errors) ==== const x =
~~~ !!! error TS2304: Cannot find name 'div'. + +!!! error TS1109: Expression expected. <<<<<<< HEAD ~~~~~~~ -!!! error TS1185: Merge conflict marker encountered. - -!!! error TS1109: Expression expected. \ No newline at end of file +!!! error TS1185: Merge conflict marker encountered. \ No newline at end of file diff --git a/tests/baselines/reference/incompleteDottedExpressionAtEOF.errors.txt b/tests/baselines/reference/incompleteDottedExpressionAtEOF.errors.txt index fe5d93ec6c1..02348777190 100644 --- a/tests/baselines/reference/incompleteDottedExpressionAtEOF.errors.txt +++ b/tests/baselines/reference/incompleteDottedExpressionAtEOF.errors.txt @@ -1,5 +1,5 @@ tests/cases/compiler/incompleteDottedExpressionAtEOF.ts(2,10): error TS2304: Cannot find name 'window'. -tests/cases/compiler/incompleteDottedExpressionAtEOF.ts(2,18): error TS1003: Identifier expected. +tests/cases/compiler/incompleteDottedExpressionAtEOF.ts(2,17): error TS1003: Identifier expected. ==== tests/cases/compiler/incompleteDottedExpressionAtEOF.ts (2 errors) ==== @@ -7,5 +7,5 @@ tests/cases/compiler/incompleteDottedExpressionAtEOF.ts(2,18): error TS1003: Ide var p2 = window. ~~~~~~ !!! error TS2304: Cannot find name 'window'. - + !!! error TS1003: Identifier expected. \ No newline at end of file diff --git a/tests/baselines/reference/jsxAndTypeAssertion.errors.txt b/tests/baselines/reference/jsxAndTypeAssertion.errors.txt index 5aa92086c37..d5df3915bf6 100644 --- a/tests/baselines/reference/jsxAndTypeAssertion.errors.txt +++ b/tests/baselines/reference/jsxAndTypeAssertion.errors.txt @@ -10,11 +10,13 @@ tests/cases/conformance/jsx/jsxAndTypeAssertion.tsx(14,45): error TS1005: '}' ex tests/cases/conformance/jsx/jsxAndTypeAssertion.tsx(18,2): error TS17008: JSX element 'foo' has no corresponding closing tag. tests/cases/conformance/jsx/jsxAndTypeAssertion.tsx(18,8): error TS17008: JSX element 'foo' has no corresponding closing tag. tests/cases/conformance/jsx/jsxAndTypeAssertion.tsx(18,13): error TS17008: JSX element 'foo' has no corresponding closing tag. +tests/cases/conformance/jsx/jsxAndTypeAssertion.tsx(18,83): error TS1109: Expression expected. tests/cases/conformance/jsx/jsxAndTypeAssertion.tsx(21,1): error TS1005: ':' expected. tests/cases/conformance/jsx/jsxAndTypeAssertion.tsx(21,1): error TS1005: ' Date: Fri, 1 Sep 2017 09:55:38 -0700 Subject: [PATCH 203/370] Expand type references recursively in cache key This means that `A>>` will include the keys for `B` and `C` now. --- src/compiler/checker.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 269666d7b94..22abe7cd57e 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -9782,8 +9782,8 @@ namespace ts { return type.flags & TypeFlags.TypeParameter && !getConstraintFromTypeParameter(type); } - function isTypeReferenceWithGenericArguments(type: Type) { - return getObjectFlags(type) & ObjectFlags.Reference && some((type).typeArguments, isUnconstrainedTypeParameter); + function isTypeReferenceWithGenericArguments(type: Type): type is TypeReference { + return getObjectFlags(type) & ObjectFlags.Reference && some((type).typeArguments, t => isUnconstrainedTypeParameter(t) || isTypeReferenceWithGenericArguments(t)); } /** @@ -9801,6 +9801,9 @@ namespace ts { } result += "=" + index; } + else if (isTypeReferenceWithGenericArguments(t)) { + result += "<" + getTypeReferenceId(t, typeParameters) + ">"; + } else { result += "-" + t.id; } @@ -10050,7 +10053,7 @@ namespace ts { getUnionType(types, /*subtypeReduction*/ true); } - function isArrayType(type: Type): boolean { + function isArrayType(type: Type): type is TypeReference { return getObjectFlags(type) & ObjectFlags.Reference && (type).target === globalArrayType; } From 7a4c3da23985bc456469c1eae6af20657b9eedec Mon Sep 17 00:00:00 2001 From: Andy Date: Fri, 1 Sep 2017 10:58:49 -0700 Subject: [PATCH 204/370] Simplify return type parsing (#18206) * Simplify return type parsing * Make control flow clearer --- src/compiler/core.ts | 4 +--- src/compiler/parser.ts | 30 ++++++++++++++++-------------- src/compiler/types.ts | 2 +- 3 files changed, 18 insertions(+), 18 deletions(-) diff --git a/src/compiler/core.ts b/src/compiler/core.ts index f94ac9a75c5..20f757c3df8 100644 --- a/src/compiler/core.ts +++ b/src/compiler/core.ts @@ -1316,14 +1316,12 @@ namespace ts { export function createFileDiagnostic(file: SourceFile, start: number, length: number, message: DiagnosticMessage, ...args: (string | number)[]): Diagnostic; export function createFileDiagnostic(file: SourceFile, start: number, length: number, message: DiagnosticMessage): Diagnostic { - const end = start + length; - Debug.assertGreaterThanOrEqual(start, 0); Debug.assertGreaterThanOrEqual(length, 0); if (file) { Debug.assertLessThanOrEqual(start, file.text.length); - Debug.assertLessThanOrEqual(end, file.text.length); + Debug.assertLessThanOrEqual(start + length, file.text.length); } let text = getLocaleSpecificMessage(message); diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index 7486c7541be..d3cbf38522a 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -2290,25 +2290,27 @@ namespace ts { signature.typeParameters = parseTypeParameters(); } signature.parameters = parseParameterList(flags); + signature.type = parseReturnType(returnToken, !!(flags & SignatureFlags.Type)); + } - const returnTokenRequired = returnToken === SyntaxKind.EqualsGreaterThanToken; - if (returnTokenRequired) { + function parseReturnType(returnToken: SyntaxKind.ColonToken | SyntaxKind.EqualsGreaterThanToken, isType: boolean): TypeNode | undefined { + return shouldParseReturnType(returnToken, isType) ? parseTypeOrTypePredicate() : undefined; + } + function shouldParseReturnType(returnToken: SyntaxKind.ColonToken | SyntaxKind.EqualsGreaterThanToken, isType: boolean): boolean { + if (returnToken === SyntaxKind.EqualsGreaterThanToken) { parseExpected(returnToken); - signature.type = parseTypeOrTypePredicate(); + return true; } - else if (parseOptional(returnToken)) { - signature.type = parseTypeOrTypePredicate(); + else if (parseOptional(SyntaxKind.ColonToken)) { + return true; } - else if (flags & SignatureFlags.Type) { - const start = scanner.getTokenPos(); - const length = scanner.getTextPos() - start; - const backwardToken = parseOptional(returnToken === SyntaxKind.ColonToken ? SyntaxKind.EqualsGreaterThanToken : SyntaxKind.ColonToken); - if (backwardToken) { - // This is easy to get backward, especially in type contexts, so parse the type anyway - signature.type = parseTypeOrTypePredicate(); - parseErrorAtPosition(start, length, Diagnostics._0_expected, tokenToString(returnToken)); - } + else if (isType && token() === SyntaxKind.EqualsGreaterThanToken) { + // This is easy to get backward, especially in type contexts, so parse the type anyway + parseErrorAtCurrentToken(Diagnostics._0_expected, tokenToString(SyntaxKind.ColonToken)); + nextToken(); + return true; } + return false; } function parseParameterList(flags: SignatureFlags) { diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 64444693acf..0d9bb8d50e8 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -668,7 +668,7 @@ namespace ts { name?: PropertyName; typeParameters?: NodeArray; parameters: NodeArray; - type?: TypeNode; + type: TypeNode | undefined; } export interface CallSignatureDeclaration extends SignatureDeclaration, TypeElement { From 520d7fff49d96ba71b9b441e25ff00c772070dff Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Fri, 1 Sep 2017 14:19:12 -0700 Subject: [PATCH 205/370] Add depth limit to recursive type reference id generation 4 is the limit. --- 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 22abe7cd57e..764307de7a9 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -9790,7 +9790,7 @@ namespace ts { * getTypeReferenceId(A) returns "111=0-12=1" * where A.id=111 and number.id=12 */ - function getTypeReferenceId(type: TypeReference, typeParameters: Type[]) { + function getTypeReferenceId(type: TypeReference, typeParameters: Type[], depth = 0) { let result = "" + type.target.id; for (const t of type.typeArguments) { if (isUnconstrainedTypeParameter(t)) { @@ -9801,8 +9801,8 @@ namespace ts { } result += "=" + index; } - else if (isTypeReferenceWithGenericArguments(t)) { - result += "<" + getTypeReferenceId(t, typeParameters) + ">"; + else if (depth < 4 && isTypeReferenceWithGenericArguments(t)) { + result += "<" + getTypeReferenceId(t, typeParameters, depth + 1) + ">"; } else { result += "-" + t.id; From b65ff647c1debc58aa66b20359d644f54048fd56 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Sat, 2 Sep 2017 10:27:48 -0700 Subject: [PATCH 206/370] Improved caching scheme for anonymous types --- src/compiler/checker.ts | 281 +++++++++++++--------------------- src/compiler/types.ts | 5 +- src/services/signatureHelp.ts | 2 +- 3 files changed, 107 insertions(+), 181 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 269666d7b94..7a9931f19a4 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -4794,22 +4794,39 @@ namespace ts { return typeParameters; } - // Appends the outer type parameters of a node to a set of type parameters and returns the resulting set. The function - // allocates a new array if the input type parameter set is undefined, but otherwise it modifies the set in-place and - // returns the same array. - function appendOuterTypeParameters(typeParameters: TypeParameter[], node: Node): TypeParameter[] { + // Return the outer type parameters of a node or undefined if the node has no outer type parameters. + function getOuterTypeParameters(node: Node, includeThisTypes?: boolean): TypeParameter[] { while (true) { node = node.parent; if (!node) { - return typeParameters; + return undefined; } - if (node.kind === SyntaxKind.ClassDeclaration || node.kind === SyntaxKind.ClassExpression || - node.kind === SyntaxKind.FunctionDeclaration || node.kind === SyntaxKind.FunctionExpression || - node.kind === SyntaxKind.MethodDeclaration || node.kind === SyntaxKind.ArrowFunction) { - const declarations = (node).typeParameters; - if (declarations) { - return appendTypeParameters(appendOuterTypeParameters(typeParameters, node), declarations); - } + switch (node.kind) { + case SyntaxKind.ClassDeclaration: + case SyntaxKind.ClassExpression: + case SyntaxKind.InterfaceDeclaration: + case SyntaxKind.CallSignature: + case SyntaxKind.ConstructSignature: + case SyntaxKind.MethodSignature: + case SyntaxKind.FunctionType: + case SyntaxKind.ConstructorType: + case SyntaxKind.JSDocFunctionType: + case SyntaxKind.FunctionDeclaration: + case SyntaxKind.MethodDeclaration: + case SyntaxKind.FunctionExpression: + case SyntaxKind.ArrowFunction: + case SyntaxKind.TypeAliasDeclaration: + case SyntaxKind.JSDocTemplateTag: + case SyntaxKind.MappedType: + const outerTypeParameters = getOuterTypeParameters(node, includeThisTypes); + if (node.kind === SyntaxKind.MappedType) { + return append(outerTypeParameters, getDeclaredTypeOfTypeParameter(getSymbolOfNode((node).typeParameter))); + } + const outerAndOwnTypeParameters = appendTypeParameters(outerTypeParameters, getEffectiveTypeParameterDeclarations(node) || emptyArray); + const thisType = includeThisTypes && + (node.kind === SyntaxKind.ClassDeclaration || node.kind === SyntaxKind.ClassExpression || node.kind === SyntaxKind.InterfaceDeclaration) && + getDeclaredTypeOfClassOrInterface(getSymbolOfNode(node)).thisType; + return thisType ? append(outerAndOwnTypeParameters, thisType) : outerAndOwnTypeParameters; } } } @@ -4817,7 +4834,7 @@ namespace ts { // The outer type parameters are those defined by enclosing generic classes, methods, or functions. function getOuterTypeParametersOfClassOrInterface(symbol: Symbol): TypeParameter[] { const declaration = symbol.flags & SymbolFlags.Class ? symbol.valueDeclaration : getDeclarationOfKind(symbol, SyntaxKind.InterfaceDeclaration); - return appendOuterTypeParameters(/*typeParameters*/ undefined, declaration); + return getOuterTypeParameters(declaration); } // The local type parameters are the combined set of type parameters from all declarations of the class, @@ -6800,7 +6817,7 @@ namespace ts { const id = getTypeListId(typeArguments); let instantiation = links.instantiations.get(id); if (!instantiation) { - links.instantiations.set(id, instantiation = instantiateTypeNoAlias(type, createTypeMapper(typeParameters, fillMissingTypeArguments(typeArguments, typeParameters, getMinTypeArgumentCount(typeParameters))))); + links.instantiations.set(id, instantiation = instantiateType(type, createTypeMapper(typeParameters, fillMissingTypeArguments(typeArguments, typeParameters, getMinTypeArgumentCount(typeParameters))))); } return instantiation; } @@ -8024,11 +8041,6 @@ namespace ts { return instantiateList(signatures, mapper, instantiateSignature); } - function instantiateCached(type: T, mapper: TypeMapper, instantiator: (item: T, mapper: TypeMapper) => T): T { - const instantiations = mapper.instantiations || (mapper.instantiations = []); - return instantiations[type.id] || (instantiations[type.id] = instantiator(type, mapper)); - } - function makeUnaryTypeMapper(source: Type, target: Type) { return (t: Type) => t === source ? target : t; } @@ -8050,11 +8062,9 @@ namespace ts { function createTypeMapper(sources: TypeParameter[], targets: Type[]): TypeMapper { Debug.assert(targets === undefined || sources.length === targets.length); - const mapper: TypeMapper = sources.length === 1 ? makeUnaryTypeMapper(sources[0], targets ? targets[0] : anyType) : + return sources.length === 1 ? makeUnaryTypeMapper(sources[0], targets ? targets[0] : anyType) : sources.length === 2 ? makeBinaryTypeMapper(sources[0], targets ? targets[0] : anyType, sources[1], targets ? targets[1] : anyType) : - makeArrayTypeMapper(sources, targets); - mapper.mappedTypes = sources; - return mapper; + makeArrayTypeMapper(sources, targets); } function createTypeEraser(sources: TypeParameter[]): TypeMapper { @@ -8065,10 +8075,8 @@ namespace ts { * Maps forward-references to later types parameters to the empty object type. * This is used during inference when instantiating type parameter defaults. */ - function createBackreferenceMapper(typeParameters: TypeParameter[], index: number) { - const mapper: TypeMapper = t => indexOf(typeParameters, t) >= index ? emptyObjectType : t; - mapper.mappedTypes = typeParameters; - return mapper; + function createBackreferenceMapper(typeParameters: TypeParameter[], index: number): TypeMapper { + return t => indexOf(typeParameters, t) >= index ? emptyObjectType : t; } function isInferenceContext(mapper: TypeMapper): mapper is InferenceContext { @@ -8086,15 +8094,11 @@ namespace ts { } function combineTypeMappers(mapper1: TypeMapper, mapper2: TypeMapper): TypeMapper { - const mapper: TypeMapper = t => instantiateType(mapper1(t), mapper2); - mapper.mappedTypes = concatenate(mapper1.mappedTypes, mapper2.mappedTypes); - return mapper; + return t => instantiateType(mapper1(t), mapper2); } - function createReplacementMapper(source: Type, target: Type, baseMapper: TypeMapper) { - const mapper: TypeMapper = t => t === source ? target : baseMapper(t); - mapper.mappedTypes = baseMapper.mappedTypes; - return mapper; + function createReplacementMapper(source: Type, target: Type, baseMapper: TypeMapper): TypeMapper { + return t => t === source ? target : baseMapper(t); } function cloneTypeParameter(typeParameter: TypeParameter): TypeParameter { @@ -8174,13 +8178,39 @@ namespace ts { return result; } - function instantiateAnonymousType(type: AnonymousType, mapper: TypeMapper): AnonymousType { - const result = createObjectType(ObjectFlags.Anonymous | ObjectFlags.Instantiated, type.symbol); - result.target = type.objectFlags & ObjectFlags.Instantiated ? type.target : type; - result.mapper = type.objectFlags & ObjectFlags.Instantiated ? combineTypeMappers(type.mapper, mapper) : mapper; - result.aliasSymbol = type.aliasSymbol; - result.aliasTypeArguments = instantiateTypes(type.aliasTypeArguments, mapper); - return result; + function getAnonymousTypeInstantiation(type: AnonymousType, mapper: TypeMapper) { + if (type.objectFlags & ObjectFlags.Instantiated) { + mapper = combineTypeMappers(type.mapper, mapper); + type = type.target; + } + const symbol = type.symbol; + const links = getSymbolLinks(symbol); + if (!links.typeParameters) { + // This first time an anonymous type is instantiated we compute and store a list of the type + // parameters that are in scope (and therefore potentially referenced). + const typeParameters = getOuterTypeParameters(symbol.declarations[0], /*includeThisTypes*/ true); + links.typeParameters = typeParameters || emptyArray; + if (typeParameters) { + links.instantiations = createMap(); + links.instantiations.set(getTypeListId(typeParameters), type); + } + } + const typeParameters = links.typeParameters; + if (typeParameters.length) { + // We are instantiating an anonymous type that has one or more type parameters in scope. Apply the + // mapper to the type parameters to produce the effective list of type arguments, and compute the + // instantiation cache key from the type IDs of the type arguments. + const typeArguments = map(typeParameters, mapper); + const id = getTypeListId(typeArguments); + let result = links.instantiations.get(id); + if (!result) { + const newMapper = createTypeMapper(typeParameters, typeArguments); + result = type.objectFlags & ObjectFlags.Mapped ? instantiateMappedType(type, newMapper) : instantiateAnonymousType(type, newMapper); + links.instantiations.set(id, result); + } + return result; + } + return type; } function instantiateMappedType(type: MappedType, mapper: TypeMapper): Type { @@ -8197,164 +8227,64 @@ namespace ts { if (typeVariable !== mappedTypeVariable) { return mapType(mappedTypeVariable, t => { if (isMappableType(t)) { - return instantiateMappedObjectType(type, createReplacementMapper(typeVariable, t, mapper)); + return instantiateAnonymousType(type, createReplacementMapper(typeVariable, t, mapper)); } return t; }); } } } - return instantiateMappedObjectType(type, mapper); + return instantiateAnonymousType(type, mapper); } function isMappableType(type: Type) { return type.flags & (TypeFlags.TypeParameter | TypeFlags.Object | TypeFlags.Intersection | TypeFlags.IndexedAccess); } - function instantiateMappedObjectType(type: MappedType, mapper: TypeMapper): Type { - const result = createObjectType(ObjectFlags.Mapped | ObjectFlags.Instantiated, type.symbol); - result.declaration = type.declaration; - result.mapper = type.mapper ? combineTypeMappers(type.mapper, mapper) : mapper; + function instantiateAnonymousType(type: AnonymousType, mapper: TypeMapper): AnonymousType { + const result = createObjectType(type.objectFlags | ObjectFlags.Instantiated, type.symbol); + if (type.objectFlags & ObjectFlags.Mapped) { + (result).declaration = (type).declaration; + } + result.target = type; + result.mapper = mapper; result.aliasSymbol = type.aliasSymbol; result.aliasTypeArguments = instantiateTypes(type.aliasTypeArguments, mapper); return result; } - function isSymbolInScopeOfMappedTypeParameter(symbol: Symbol, mapper: TypeMapper) { - if (!(symbol.declarations && symbol.declarations.length)) { - return false; - } - const mappedTypes = mapper.mappedTypes; - // Starting with the parent of the symbol's declaration, check if the mapper maps any of - // the type parameters introduced by enclosing declarations. We just pick the first - // declaration since multiple declarations will all have the same parent anyway. - return !!findAncestor(symbol.declarations[0], node => { - if (node.kind === SyntaxKind.ModuleDeclaration || node.kind === SyntaxKind.SourceFile) { - return "quit"; - } - switch (node.kind) { - case SyntaxKind.FunctionType: - case SyntaxKind.ConstructorType: - case SyntaxKind.FunctionDeclaration: - case SyntaxKind.MethodDeclaration: - case SyntaxKind.MethodSignature: - case SyntaxKind.Constructor: - case SyntaxKind.CallSignature: - case SyntaxKind.ConstructSignature: - case SyntaxKind.IndexSignature: - case SyntaxKind.GetAccessor: - case SyntaxKind.SetAccessor: - case SyntaxKind.FunctionExpression: - case SyntaxKind.ArrowFunction: - case SyntaxKind.ClassDeclaration: - case SyntaxKind.ClassExpression: - case SyntaxKind.InterfaceDeclaration: - case SyntaxKind.TypeAliasDeclaration: - const typeParameters = getEffectiveTypeParameterDeclarations(node as DeclarationWithTypeParameters); - if (typeParameters) { - for (const d of typeParameters) { - if (contains(mappedTypes, getDeclaredTypeOfTypeParameter(getSymbolOfNode(d)))) { - return true; - } - } - } - if (isClassLike(node) || node.kind === SyntaxKind.InterfaceDeclaration) { - const thisType = getDeclaredTypeOfClassOrInterface(getSymbolOfNode(node)).thisType; - if (thisType && contains(mappedTypes, thisType)) { - return true; - } - } - break; - case SyntaxKind.MappedType: - if (contains(mappedTypes, getDeclaredTypeOfTypeParameter(getSymbolOfNode((node).typeParameter)))) { - return true; - } - break; - case SyntaxKind.JSDocFunctionType: - const func = node as JSDocFunctionType; - for (const p of func.parameters) { - if (contains(mappedTypes, getTypeOfNode(p))) { - return true; - } - } - break; - } - }); - } - - function isTopLevelTypeAlias(symbol: Symbol) { - if (symbol.declarations && symbol.declarations.length) { - const parentKind = symbol.declarations[0].parent.kind; - return parentKind === SyntaxKind.SourceFile || parentKind === SyntaxKind.ModuleBlock; - } - return false; - } - function instantiateType(type: Type, mapper: TypeMapper): Type { if (type && mapper !== identityMapper) { - // If we are instantiating a type that has a top-level type alias, obtain the instantiation through - // the type alias instead in order to share instantiations for the same type arguments. This can - // dramatically reduce the number of structurally identical types we generate. Note that we can only - // perform this optimization for top-level type aliases. Consider: - // - // function f1(x: T) { - // type Foo = { x: X, t: T }; - // let obj: Foo = { x: x }; - // return obj; - // } - // function f2(x: U) { return f1(x); } - // let z = f2(42); - // - // Above, the declaration of f2 has an inferred return type that is an instantiation of f1's Foo - // equivalent to { x: U, t: U }. When instantiating this return type, we can't go back to Foo's - // cache because all cached instantiations are of the form { x: ???, t: T }, i.e. they have not been - // instantiated for T. Instead, we need to further instantiate the { x: U, t: U } form. - if (type.aliasSymbol && isTopLevelTypeAlias(type.aliasSymbol)) { - if (type.aliasTypeArguments) { - return getTypeAliasInstantiation(type.aliasSymbol, instantiateTypes(type.aliasTypeArguments, mapper)); + if (type.flags & TypeFlags.TypeParameter) { + return mapper(type); + } + if (type.flags & TypeFlags.Object) { + if ((type).objectFlags & ObjectFlags.Anonymous) { + // If the anonymous type originates in a declaration of a function, method, class, or + // interface, in an object type literal, or in an object literal expression, we may need + // to instantiate the type because it might reference a type parameter. + return type.symbol && type.symbol.flags & (SymbolFlags.Function | SymbolFlags.Method | SymbolFlags.Class | SymbolFlags.TypeLiteral | SymbolFlags.ObjectLiteral) && type.symbol.declarations ? + getAnonymousTypeInstantiation(type, mapper) : type; + } + if ((type).objectFlags & ObjectFlags.Mapped) { + return getAnonymousTypeInstantiation(type, mapper); + } + if ((type).objectFlags & ObjectFlags.Reference) { + return createTypeReference((type).target, instantiateTypes((type).typeArguments, mapper)); } - return type; } - return instantiateTypeNoAlias(type, mapper); - } - return type; - } - - function instantiateTypeNoAlias(type: Type, mapper: TypeMapper): Type { - if (type.flags & TypeFlags.TypeParameter) { - return mapper(type); - } - if (type.flags & TypeFlags.Object) { - if ((type).objectFlags & ObjectFlags.Anonymous) { - // If the anonymous type originates in a declaration of a function, method, class, or - // interface, in an object type literal, or in an object literal expression, we may need - // to instantiate the type because it might reference a type parameter. We skip instantiation - // if none of the type parameters that are in scope in the type's declaration are mapped by - // the given mapper, however we can only do that analysis if the type isn't itself an - // instantiation. - return type.symbol && - type.symbol.flags & (SymbolFlags.Function | SymbolFlags.Method | SymbolFlags.Class | SymbolFlags.TypeLiteral | SymbolFlags.ObjectLiteral) && - ((type).objectFlags & ObjectFlags.Instantiated || isSymbolInScopeOfMappedTypeParameter(type.symbol, mapper)) ? - instantiateCached(type, mapper, instantiateAnonymousType) : type; + if (type.flags & TypeFlags.Union && !(type.flags & TypeFlags.Primitive)) { + return getUnionType(instantiateTypes((type).types, mapper), /*subtypeReduction*/ false, type.aliasSymbol, instantiateTypes(type.aliasTypeArguments, mapper)); } - if ((type).objectFlags & ObjectFlags.Mapped) { - return instantiateCached(type, mapper, instantiateMappedType); + if (type.flags & TypeFlags.Intersection) { + return getIntersectionType(instantiateTypes((type).types, mapper), type.aliasSymbol, instantiateTypes(type.aliasTypeArguments, mapper)); } - if ((type).objectFlags & ObjectFlags.Reference) { - return createTypeReference((type).target, instantiateTypes((type).typeArguments, mapper)); + if (type.flags & TypeFlags.Index) { + return getIndexType(instantiateType((type).type, mapper)); + } + if (type.flags & TypeFlags.IndexedAccess) { + return getIndexedAccessType(instantiateType((type).objectType, mapper), instantiateType((type).indexType, mapper)); } - } - if (type.flags & TypeFlags.Union && !(type.flags & TypeFlags.Primitive)) { - return getUnionType(instantiateTypes((type).types, mapper), /*subtypeReduction*/ false, type.aliasSymbol, instantiateTypes(type.aliasTypeArguments, mapper)); - } - if (type.flags & TypeFlags.Intersection) { - return getIntersectionType(instantiateTypes((type).types, mapper), type.aliasSymbol, instantiateTypes(type.aliasTypeArguments, mapper)); - } - if (type.flags & TypeFlags.Index) { - return getIndexType(instantiateType((type).type, mapper)); - } - if (type.flags & TypeFlags.IndexedAccess) { - return getIndexedAccessType(instantiateType((type).objectType, mapper), instantiateType((type).indexType, mapper)); } return type; } @@ -10368,7 +10298,6 @@ namespace ts { function createInferenceContext(signature: Signature, flags: InferenceFlags, compareTypes?: TypeComparer, baseInferences?: InferenceInfo[]): InferenceContext { const inferences = baseInferences ? map(baseInferences, cloneInferenceInfo) : map(signature.typeParameters, createInferenceInfo); const context = mapper as InferenceContext; - context.mappedTypes = signature.typeParameters; context.signature = signature; context.inferences = inferences; context.flags = flags; diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 64444693acf..99afe5e6e4e 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -3331,13 +3331,12 @@ namespace ts { } /* @internal */ - export interface MappedType extends ObjectType { + export interface MappedType extends AnonymousType { declaration: MappedTypeNode; typeParameter?: TypeParameter; constraintType?: Type; templateType?: Type; modifiersType?: Type; - mapper?: TypeMapper; // Instantiation mapper } export interface EvolvingArrayType extends ObjectType { @@ -3469,8 +3468,6 @@ namespace ts { /* @internal */ export interface TypeMapper { (t: TypeParameter): Type; - mappedTypes?: TypeParameter[]; // Types mapped by this mapper - instantiations?: Type[]; // Cache of instantiations created using this type mapper. } export const enum InferencePriority { diff --git a/src/services/signatureHelp.ts b/src/services/signatureHelp.ts index 2976b0d28ee..10d5dda7966 100644 --- a/src/services/signatureHelp.ts +++ b/src/services/signatureHelp.ts @@ -373,7 +373,7 @@ namespace ts.SignatureHelp { isVariadic = false; // type parameter lists are not variadic prefixDisplayParts.push(punctuationPart(SyntaxKind.LessThanToken)); // Use `.mapper` to ensure we get the generic type arguments even if this is an instantiated version of the signature. - const typeParameters = candidateSignature.mapper ? candidateSignature.mapper.mappedTypes : candidateSignature.typeParameters; + const typeParameters = candidateSignature.typeParameters; // !!! candidateSignature.mapper ? candidateSignature.mapper.mappedTypes : candidateSignature.typeParameters; signatureHelpParameters = typeParameters && typeParameters.length > 0 ? map(typeParameters, createSignatureHelpParameterForTypeParameter) : emptyArray; suffixDisplayParts.push(punctuationPart(SyntaxKind.GreaterThanToken)); const parameterParts = mapToDisplayParts(writer => From 601a21c77b3af323b293cbcb3483936443bc50b7 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Sat, 2 Sep 2017 15:39:14 -0700 Subject: [PATCH 207/370] Fix signature help --- src/services/signatureHelp.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/services/signatureHelp.ts b/src/services/signatureHelp.ts index 10d5dda7966..7e8e748bb17 100644 --- a/src/services/signatureHelp.ts +++ b/src/services/signatureHelp.ts @@ -372,8 +372,7 @@ namespace ts.SignatureHelp { if (isTypeParameterList) { isVariadic = false; // type parameter lists are not variadic prefixDisplayParts.push(punctuationPart(SyntaxKind.LessThanToken)); - // Use `.mapper` to ensure we get the generic type arguments even if this is an instantiated version of the signature. - const typeParameters = candidateSignature.typeParameters; // !!! candidateSignature.mapper ? candidateSignature.mapper.mappedTypes : candidateSignature.typeParameters; + const typeParameters = (candidateSignature.target || candidateSignature).typeParameters; signatureHelpParameters = typeParameters && typeParameters.length > 0 ? map(typeParameters, createSignatureHelpParameterForTypeParameter) : emptyArray; suffixDisplayParts.push(punctuationPart(SyntaxKind.GreaterThanToken)); const parameterParts = mapToDisplayParts(writer => From 319617c5d8f7e496402b1ae746d0d9135bf880b4 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Sun, 3 Sep 2017 08:53:04 -0700 Subject: [PATCH 208/370] Optimize caching of type literals --- src/compiler/checker.ts | 46 +++++++++++++++++++++++++++-------------- 1 file changed, 31 insertions(+), 15 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 7a9931f19a4..112bbbf1c0a 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -8179,33 +8179,37 @@ namespace ts { } function getAnonymousTypeInstantiation(type: AnonymousType, mapper: TypeMapper) { - if (type.objectFlags & ObjectFlags.Instantiated) { - mapper = combineTypeMappers(type.mapper, mapper); - type = type.target; - } - const symbol = type.symbol; + const target = type.objectFlags & ObjectFlags.Instantiated ? type.target : type; + const symbol = target.symbol; const links = getSymbolLinks(symbol); - if (!links.typeParameters) { - // This first time an anonymous type is instantiated we compute and store a list of the type - // parameters that are in scope (and therefore potentially referenced). - const typeParameters = getOuterTypeParameters(symbol.declarations[0], /*includeThisTypes*/ true); - links.typeParameters = typeParameters || emptyArray; - if (typeParameters) { + let typeParameters = links.typeParameters; + if (!typeParameters) { + // The first time an anonymous type is instantiated we compute and store a list of the type + // parameters that are in scope (and therefore potentially referenced). For type literals that + // aren't the right hand side of a generic type alias declaration we optimize by reducing the + // set of type parameters to those that are actually referenced somewhere in the literal. + const declaration = symbol.declarations[0]; + const outerTypeParameters = getOuterTypeParameters(declaration, /*includeThisTypes*/ true) || emptyArray; + typeParameters = symbol.flags & SymbolFlags.TypeLiteral && !target.aliasTypeArguments ? + filter(outerTypeParameters, tp => isTypeParameterReferencedWithin(tp, declaration)) : + outerTypeParameters; + links.typeParameters = typeParameters; + if (typeParameters.length) { links.instantiations = createMap(); - links.instantiations.set(getTypeListId(typeParameters), type); + links.instantiations.set(getTypeListId(typeParameters), target); } } - const typeParameters = links.typeParameters; if (typeParameters.length) { // We are instantiating an anonymous type that has one or more type parameters in scope. Apply the // mapper to the type parameters to produce the effective list of type arguments, and compute the // instantiation cache key from the type IDs of the type arguments. - const typeArguments = map(typeParameters, mapper); + const combinedMapper = type.objectFlags & ObjectFlags.Instantiated ? combineTypeMappers(type.mapper, mapper) : mapper; + const typeArguments = map(typeParameters, combinedMapper); const id = getTypeListId(typeArguments); let result = links.instantiations.get(id); if (!result) { const newMapper = createTypeMapper(typeParameters, typeArguments); - result = type.objectFlags & ObjectFlags.Mapped ? instantiateMappedType(type, newMapper) : instantiateAnonymousType(type, newMapper); + result = target.objectFlags & ObjectFlags.Mapped ? instantiateMappedType(target, newMapper) : instantiateAnonymousType(target, newMapper); links.instantiations.set(id, result); } return result; @@ -8213,6 +8217,16 @@ namespace ts { return type; } + function isTypeParameterReferencedWithin(tp: TypeParameter, node: Node) { + return tp.isThisType ? forEachChild(node, checkThis) : forEachChild(node, checkIdentifier); + function checkThis(node: Node): boolean { + return node.kind === SyntaxKind.ThisType || forEachChild(node, checkThis); + } + function checkIdentifier(node: Node): boolean { + return node.kind === SyntaxKind.Identifier && isPartOfTypeNode(node) && getTypeFromTypeNode(node) === tp || forEachChild(node, checkIdentifier); + } + } + function instantiateMappedType(type: MappedType, mapper: TypeMapper): Type { // Check if we have a homomorphic mapped type, i.e. a type of the form { [P in keyof T]: X } for some // type variable T. If so, the mapped type is distributive over a union type and when T is instantiated @@ -10420,6 +10434,7 @@ namespace ts { function inferTypes(inferences: InferenceInfo[], originalSource: Type, originalTarget: Type, priority: InferencePriority = 0) { let symbolStack: Symbol[]; let visited: Map; + //sys.write(typeToString(originalSource) + " ==> " + typeToString(originalTarget) + "\n"); inferFromTypes(originalSource, originalTarget); function inferFromTypes(source: Type, target: Type) { @@ -10487,6 +10502,7 @@ namespace ts { const inference = getInferenceInfoForType(target); if (inference) { if (!inference.isFixed) { + //sys.write(" " + typeToString(source) + "\n"); if (!inference.candidates || priority < inference.priority) { inference.candidates = [source]; inference.priority = priority; From a0c40943feaa4afb1fbbe038d2cf5daf9d642f48 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Sun, 3 Sep 2017 08:53:19 -0700 Subject: [PATCH 209/370] Accept new baselines --- .../reference/functionConstraintSatisfaction2.errors.txt | 4 ---- tests/baselines/reference/limitDeepInstantiations.errors.txt | 4 ++-- tests/baselines/reference/promisePermutations.errors.txt | 2 -- tests/baselines/reference/promisePermutations2.errors.txt | 2 -- tests/baselines/reference/promisePermutations3.errors.txt | 2 -- 5 files changed, 2 insertions(+), 12 deletions(-) diff --git a/tests/baselines/reference/functionConstraintSatisfaction2.errors.txt b/tests/baselines/reference/functionConstraintSatisfaction2.errors.txt index f87312634f8..7558a97511f 100644 --- a/tests/baselines/reference/functionConstraintSatisfaction2.errors.txt +++ b/tests/baselines/reference/functionConstraintSatisfaction2.errors.txt @@ -22,8 +22,6 @@ tests/cases/conformance/types/typeParameters/typeArgumentLists/functionConstrain Type 'void' is not assignable to type 'string'. tests/cases/conformance/types/typeParameters/typeArgumentLists/functionConstraintSatisfaction2.ts(38,10): error TS2345: Argument of type 'U' is not assignable to parameter of type '(x: string) => string'. Type 'T' is not assignable to type '(x: string) => string'. - Type '() => void' is not assignable to type '(x: string) => string'. - Type 'void' is not assignable to type 'string'. ==== tests/cases/conformance/types/typeParameters/typeArgumentLists/functionConstraintSatisfaction2.ts (13 errors) ==== @@ -102,7 +100,5 @@ tests/cases/conformance/types/typeParameters/typeArgumentLists/functionConstrain ~ !!! error TS2345: Argument of type 'U' is not assignable to parameter of type '(x: string) => string'. !!! error TS2345: Type 'T' is not assignable to type '(x: string) => string'. -!!! error TS2345: Type '() => void' is not assignable to type '(x: string) => string'. -!!! error TS2345: Type 'void' is not assignable to type 'string'. } \ No newline at end of file diff --git a/tests/baselines/reference/limitDeepInstantiations.errors.txt b/tests/baselines/reference/limitDeepInstantiations.errors.txt index 330e5fbc8e4..70718199d2b 100644 --- a/tests/baselines/reference/limitDeepInstantiations.errors.txt +++ b/tests/baselines/reference/limitDeepInstantiations.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/limitDeepInstantiations.ts(3,35): error TS2550: Generic type instantiation is excessively deep and possibly infinite. +tests/cases/compiler/limitDeepInstantiations.ts(3,35): error TS2502: '"true"' is referenced directly or indirectly in its own type annotation. tests/cases/compiler/limitDeepInstantiations.ts(5,13): error TS2344: Type '"false"' does not satisfy the constraint '"true"'. @@ -7,7 +7,7 @@ tests/cases/compiler/limitDeepInstantiations.ts(5,13): error TS2344: Type '"fals type Foo = { "true": Foo> }[T]; ~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2550: Generic type instantiation is excessively deep and possibly infinite. +!!! error TS2502: '"true"' is referenced directly or indirectly in its own type annotation. let f1: Foo<"true", {}>; let f2: Foo<"false", {}>; ~~~~~~~ diff --git a/tests/baselines/reference/promisePermutations.errors.txt b/tests/baselines/reference/promisePermutations.errors.txt index a876345ffa1..c5527d5aa67 100644 --- a/tests/baselines/reference/promisePermutations.errors.txt +++ b/tests/baselines/reference/promisePermutations.errors.txt @@ -45,7 +45,6 @@ tests/cases/compiler/promisePermutations.ts(134,19): error TS2345: Argument of t tests/cases/compiler/promisePermutations.ts(137,33): error TS2345: Argument of type '(x: any) => IPromise' is not assignable to parameter of type '(error: any) => IPromise'. Type 'IPromise' is not assignable to type 'IPromise'. tests/cases/compiler/promisePermutations.ts(144,35): error TS2345: Argument of type '(x: any) => IPromise' is not assignable to parameter of type '(error: any) => IPromise'. - Type 'IPromise' is not assignable to type 'IPromise'. tests/cases/compiler/promisePermutations.ts(152,36): error TS2345: Argument of type '(x: any) => IPromise' is not assignable to parameter of type '(error: any) => Promise'. Type 'IPromise' is not assignable to type 'Promise'. Types of property 'then' are incompatible. @@ -290,7 +289,6 @@ tests/cases/compiler/promisePermutations.ts(160,21): error TS2345: Argument of t var r10d = r10.then(testFunction, sIPromise, nIPromise); // ok ~~~~~~~~~ !!! error TS2345: Argument of type '(x: any) => IPromise' is not assignable to parameter of type '(error: any) => IPromise'. -!!! error TS2345: Type 'IPromise' is not assignable to type 'IPromise'. var r10e = r10.then(testFunction, nIPromise, sIPromise).then(sIPromise, sIPromise, sIPromise); // ok var s10 = testFunction10P(x => x); var s10a = s10.then(testFunction10, testFunction10, testFunction10); // ok diff --git a/tests/baselines/reference/promisePermutations2.errors.txt b/tests/baselines/reference/promisePermutations2.errors.txt index 871ee2ae2c3..955063797c0 100644 --- a/tests/baselines/reference/promisePermutations2.errors.txt +++ b/tests/baselines/reference/promisePermutations2.errors.txt @@ -45,7 +45,6 @@ tests/cases/compiler/promisePermutations2.ts(133,19): error TS2345: Argument of tests/cases/compiler/promisePermutations2.ts(136,33): error TS2345: Argument of type '(x: any) => IPromise' is not assignable to parameter of type '(error: any) => IPromise'. Type 'IPromise' is not assignable to type 'IPromise'. tests/cases/compiler/promisePermutations2.ts(143,35): error TS2345: Argument of type '(x: any) => IPromise' is not assignable to parameter of type '(error: any) => IPromise'. - Type 'IPromise' is not assignable to type 'IPromise'. tests/cases/compiler/promisePermutations2.ts(151,36): error TS2345: Argument of type '(x: any) => IPromise' is not assignable to parameter of type '(error: any) => Promise'. Type 'IPromise' is not assignable to type 'Promise'. Types of property 'then' are incompatible. @@ -289,7 +288,6 @@ tests/cases/compiler/promisePermutations2.ts(159,21): error TS2345: Argument of var r10d = r10.then(testFunction, sIPromise, nIPromise); // error ~~~~~~~~~ !!! error TS2345: Argument of type '(x: any) => IPromise' is not assignable to parameter of type '(error: any) => IPromise'. -!!! error TS2345: Type 'IPromise' is not assignable to type 'IPromise'. var r10e = r10.then(testFunction, nIPromise, sIPromise).then(sIPromise, sIPromise, sIPromise); // ok var s10 = testFunction10P(x => x); var s10a = s10.then(testFunction10, testFunction10, testFunction10); // ok diff --git a/tests/baselines/reference/promisePermutations3.errors.txt b/tests/baselines/reference/promisePermutations3.errors.txt index 9d09559c5d3..89a4cffe688 100644 --- a/tests/baselines/reference/promisePermutations3.errors.txt +++ b/tests/baselines/reference/promisePermutations3.errors.txt @@ -48,7 +48,6 @@ tests/cases/compiler/promisePermutations3.ts(133,19): error TS2345: Argument of tests/cases/compiler/promisePermutations3.ts(136,33): error TS2345: Argument of type '(x: any) => IPromise' is not assignable to parameter of type '(error: any) => IPromise'. Type 'IPromise' is not assignable to type 'IPromise'. tests/cases/compiler/promisePermutations3.ts(143,35): error TS2345: Argument of type '(x: any) => IPromise' is not assignable to parameter of type '(error: any) => IPromise'. - Type 'IPromise' is not assignable to type 'IPromise'. tests/cases/compiler/promisePermutations3.ts(151,36): error TS2345: Argument of type '(x: any) => IPromise' is not assignable to parameter of type '(error: any) => Promise'. Type 'IPromise' is not assignable to type 'Promise'. Types of property 'then' are incompatible. @@ -301,7 +300,6 @@ tests/cases/compiler/promisePermutations3.ts(165,21): error TS2345: Argument of var r10d = r10.then(testFunction, sIPromise, nIPromise); // error ~~~~~~~~~ !!! error TS2345: Argument of type '(x: any) => IPromise' is not assignable to parameter of type '(error: any) => IPromise'. -!!! error TS2345: Type 'IPromise' is not assignable to type 'IPromise'. var r10e = r10.then(testFunction, nIPromise, sIPromise).then(sIPromise, sIPromise, sIPromise); // ok var s10 = testFunction10P(x => x); var s10a = s10.then(testFunction10, testFunction10, testFunction10); // ok From 82281d9910e9d5dd3289368dad63b18fb87dbc29 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Sun, 3 Sep 2017 11:00:03 -0700 Subject: [PATCH 210/370] Fix linting errors --- src/compiler/checker.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 112bbbf1c0a..42b15d1a0ac 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -10434,7 +10434,6 @@ namespace ts { function inferTypes(inferences: InferenceInfo[], originalSource: Type, originalTarget: Type, priority: InferencePriority = 0) { let symbolStack: Symbol[]; let visited: Map; - //sys.write(typeToString(originalSource) + " ==> " + typeToString(originalTarget) + "\n"); inferFromTypes(originalSource, originalTarget); function inferFromTypes(source: Type, target: Type) { @@ -10502,7 +10501,6 @@ namespace ts { const inference = getInferenceInfoForType(target); if (inference) { if (!inference.isFixed) { - //sys.write(" " + typeToString(source) + "\n"); if (!inference.candidates || priority < inference.priority) { inference.candidates = [source]; inference.priority = priority; From 3f5986f747b581c000481812d68d62cd6bfbda3a Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Mon, 4 Sep 2017 16:37:51 -0700 Subject: [PATCH 211/370] Disable control flow analysis in excessively large statement blocks --- src/compiler/checker.ts | 83 ++++++++++++++++++---------- src/compiler/diagnosticMessages.json | 4 ++ 2 files changed, 57 insertions(+), 30 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 9174aa3c023..c3e3473e3f8 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -334,6 +334,7 @@ namespace ts { let flowLoopStart = 0; let flowLoopCount = 0; let visitedFlowCount = 0; + let flowAnalysisDisabled = false; const emptyStringType = getLiteralType(""); const zeroType = getLiteralType(0); @@ -11487,6 +11488,10 @@ namespace ts { function getFlowTypeOfReference(reference: Node, declaredType: Type, initialType = declaredType, flowContainer?: Node, couldBeUninitialized?: boolean) { let key: string; + let flowLength = 0; + if (flowAnalysisDisabled) { + return unknownType; + } if (!reference.flowNode || !couldBeUninitialized && !(declaredType.flags & TypeFlags.Narrowable)) { return declaredType; } @@ -11504,60 +11509,72 @@ namespace ts { return resultType; function getTypeAtFlowNode(flow: FlowNode): FlowType { + const saveFlowLength = flowLength; while (true) { - if (flow.flags & FlowFlags.Shared) { + flowLength++; + if (flowLength === 5000) { + // The length of this particular control flow path is 5000 nodes or more. Rather than spending an + // excessive amount of time and possibly overflowing the call stack, we report an error and disable + // further control flow analysis in the containing function or module body. + flowAnalysisDisabled = true; + error(reference, Diagnostics.The_body_of_the_containing_function_or_module_is_too_large_for_control_flow_analysis); + return unknownType; + } + const flags = flow.flags; + if (flags & FlowFlags.Shared) { // We cache results of flow type resolution for shared nodes that were previously visited in // the same getFlowTypeOfReference invocation. A node is considered shared when it is the // antecedent of more than one node. for (let i = visitedFlowStart; i < visitedFlowCount; i++) { if (visitedFlowNodes[i] === flow) { + flowLength = saveFlowLength; return visitedFlowTypes[i]; } } } let type: FlowType; - if (flow.flags & FlowFlags.AfterFinally) { + if (flags & FlowFlags.AfterFinally) { // block flow edge: finally -> pre-try (for larger explanation check comment in binder.ts - bindTryStatement (flow).locked = true; type = getTypeAtFlowNode((flow).antecedent); (flow).locked = false; } - else if (flow.flags & FlowFlags.PreFinally) { + else if (flags & FlowFlags.PreFinally) { // locked pre-finally flows are filtered out in getTypeAtFlowBranchLabel // so here just redirect to antecedent flow = (flow).antecedent; continue; } - else if (flow.flags & FlowFlags.Assignment) { + else if (flags & FlowFlags.Assignment) { type = getTypeAtFlowAssignment(flow); if (!type) { flow = (flow).antecedent; continue; } } - else if (flow.flags & FlowFlags.Condition) { + else if (flags & FlowFlags.Condition) { type = getTypeAtFlowCondition(flow); } - else if (flow.flags & FlowFlags.SwitchClause) { + else if (flags & FlowFlags.SwitchClause) { type = getTypeAtSwitchClause(flow); } - else if (flow.flags & FlowFlags.Label) { + else if (flags & FlowFlags.Label) { if ((flow).antecedents.length === 1) { flow = (flow).antecedents[0]; continue; } - type = flow.flags & FlowFlags.BranchLabel ? + type = flags & FlowFlags.BranchLabel ? getTypeAtFlowBranchLabel(flow) : getTypeAtFlowLoopLabel(flow); } - else if (flow.flags & FlowFlags.ArrayMutation) { + else if (flags & FlowFlags.ArrayMutation) { type = getTypeAtFlowArrayMutation(flow); if (!type) { flow = (flow).antecedent; continue; } } - else if (flow.flags & FlowFlags.Start) { + else if (flags & FlowFlags.Start) { // Check if we should continue with the control flow of the containing function. const container = (flow).container; if (container && container !== flowContainer && reference.kind !== SyntaxKind.PropertyAccessExpression && reference.kind !== SyntaxKind.ThisKeyword) { @@ -11572,12 +11589,13 @@ namespace ts { // simply return the non-auto declared type to reduce follow-on errors. type = convertAutoToAny(declaredType); } - if (flow.flags & FlowFlags.Shared) { + if (flags & FlowFlags.Shared) { // Record visited node and the associated type in the cache. visitedFlowNodes[visitedFlowCount] = flow; visitedFlowTypes[visitedFlowCount] = type; visitedFlowCount++; } + flowLength = saveFlowLength; return type; } } @@ -11615,29 +11633,31 @@ namespace ts { } function getTypeAtFlowArrayMutation(flow: FlowArrayMutation): FlowType { - const node = flow.node; - const expr = node.kind === SyntaxKind.CallExpression ? - ((node).expression).expression : - ((node).left).expression; - if (isMatchingReference(reference, getReferenceCandidate(expr))) { - const flowType = getTypeAtFlowNode(flow.antecedent); - const type = getTypeFromFlowType(flowType); - if (getObjectFlags(type) & ObjectFlags.EvolvingArray) { - let evolvedType = type; - if (node.kind === SyntaxKind.CallExpression) { - for (const arg of (node).arguments) { - evolvedType = addEvolvingArrayElementType(evolvedType, arg); + if (declaredType === autoType || declaredType === autoArrayType) { + const node = flow.node; + const expr = node.kind === SyntaxKind.CallExpression ? + ((node).expression).expression : + ((node).left).expression; + if (isMatchingReference(reference, getReferenceCandidate(expr))) { + const flowType = getTypeAtFlowNode(flow.antecedent); + const type = getTypeFromFlowType(flowType); + if (getObjectFlags(type) & ObjectFlags.EvolvingArray) { + let evolvedType = type; + if (node.kind === SyntaxKind.CallExpression) { + for (const arg of (node).arguments) { + evolvedType = addEvolvingArrayElementType(evolvedType, arg); + } } - } - else { - const indexType = getTypeOfExpression(((node).left).argumentExpression); - if (isTypeAssignableToKind(indexType, TypeFlags.NumberLike)) { - evolvedType = addEvolvingArrayElementType(evolvedType, (node).right); + else { + const indexType = getTypeOfExpression(((node).left).argumentExpression); + if (isTypeAssignableToKind(indexType, TypeFlags.NumberLike)) { + evolvedType = addEvolvingArrayElementType(evolvedType, (node).right); + } } + return evolvedType === type ? flowType : createFlowType(evolvedType, isIncomplete(flowType)); } - return evolvedType === type ? flowType : createFlowType(evolvedType, isIncomplete(flowType)); + return flowType; } - return flowType; } return undefined; } @@ -19951,7 +19971,9 @@ namespace ts { if (node.kind === SyntaxKind.Block) { checkGrammarStatementInAmbientContext(node); } + const saveFlowAnalysisDisabled = flowAnalysisDisabled; forEach(node.statements, checkSourceElement); + flowAnalysisDisabled = saveFlowAnalysisDisabled; if (node.locals) { registerForUnusedIdentifiersCheck(node); } @@ -22541,6 +22563,7 @@ namespace ts { deferredNodes = []; deferredUnusedIdentifierNodes = produceDiagnostics && noUnusedIdentifiers ? [] : undefined; + flowAnalysisDisabled = false; forEach(node.statements, checkSourceElement); diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index 9a3492e5c37..b3668cc5acf 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -1920,6 +1920,10 @@ "category": "Error", "code": 2562 }, + "The body of the containing function or module is too large for control flow analysis.": { + "category": "Error", + "code": 2563 + }, "JSX element attributes type '{0}' may not be a union type.": { "category": "Error", "code": 2600 From 4f43ae207afe655f1dbda7fa0a732890fdf78313 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Mon, 4 Sep 2017 16:57:36 -0700 Subject: [PATCH 212/370] Add test --- .../largeControlFlowGraph.errors.txt | 10010 ++++++++ .../reference/largeControlFlowGraph.js | 20010 ++++++++++++++++ tests/cases/compiler/largeControlFlowGraph.ts | 10003 ++++++++ 3 files changed, 40023 insertions(+) create mode 100644 tests/baselines/reference/largeControlFlowGraph.errors.txt create mode 100644 tests/baselines/reference/largeControlFlowGraph.js create mode 100644 tests/cases/compiler/largeControlFlowGraph.ts diff --git a/tests/baselines/reference/largeControlFlowGraph.errors.txt b/tests/baselines/reference/largeControlFlowGraph.errors.txt new file mode 100644 index 00000000000..f9dad52c79f --- /dev/null +++ b/tests/baselines/reference/largeControlFlowGraph.errors.txt @@ -0,0 +1,10010 @@ +tests/cases/compiler/largeControlFlowGraph.ts(5003,1): error TS2563: The body of the containing function or module is too large for control flow analysis. + + +==== tests/cases/compiler/largeControlFlowGraph.ts (1 errors) ==== + // The control flow graph for the following statement block is 10000 nodes deep. Check that + // we gracefully handle this, possibly by issuing an error. + const data = []; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + ~~~~ +!!! error TS2563: The body of the containing function or module is too large for control flow analysis. + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + \ No newline at end of file diff --git a/tests/baselines/reference/largeControlFlowGraph.js b/tests/baselines/reference/largeControlFlowGraph.js new file mode 100644 index 00000000000..ee1edbe8984 --- /dev/null +++ b/tests/baselines/reference/largeControlFlowGraph.js @@ -0,0 +1,20010 @@ +//// [largeControlFlowGraph.ts] +// The control flow graph for the following statement block is 10000 nodes deep. Check that +// we gracefully handle this, possibly by issuing an error. +const data = []; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; + + +//// [largeControlFlowGraph.js] +// The control flow graph for the following statement block is 10000 nodes deep. Check that +// we gracefully handle this, possibly by issuing an error. +var data = []; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; diff --git a/tests/cases/compiler/largeControlFlowGraph.ts b/tests/cases/compiler/largeControlFlowGraph.ts new file mode 100644 index 00000000000..0503c80095b --- /dev/null +++ b/tests/cases/compiler/largeControlFlowGraph.ts @@ -0,0 +1,10003 @@ +// The control flow graph for the following statement block is 10000 nodes deep. Check that +// we gracefully handle this, possibly by issuing an error. +const data = []; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; From 2fc14d8ae81ceee5046f1be05c6d5536183d8ef9 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Tue, 5 Sep 2017 10:39:32 -0700 Subject: [PATCH 213/370] Remove added type predicates I forgot that 'f(x): x is T' implies that x is *not* T if f returns false. --- 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 85ac20b4114..8f1f4808741 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -9781,7 +9781,7 @@ namespace ts { return type.flags & TypeFlags.TypeParameter && !getConstraintFromTypeParameter(type); } - function isTypeReferenceWithGenericArguments(type: Type): type is TypeReference { + function isTypeReferenceWithGenericArguments(type: Type): boolean { return getObjectFlags(type) & ObjectFlags.Reference && some((type).typeArguments, t => isUnconstrainedTypeParameter(t) || isTypeReferenceWithGenericArguments(t)); } @@ -9801,7 +9801,7 @@ namespace ts { result += "=" + index; } else if (depth < 4 && isTypeReferenceWithGenericArguments(t)) { - result += "<" + getTypeReferenceId(t, typeParameters, depth + 1) + ">"; + result += "<" + getTypeReferenceId(t as TypeReference, typeParameters, depth + 1) + ">"; } else { result += "-" + t.id; @@ -10052,7 +10052,7 @@ namespace ts { getUnionType(types, /*subtypeReduction*/ true); } - function isArrayType(type: Type): type is TypeReference { + function isArrayType(type: Type): boolean { return getObjectFlags(type) & ObjectFlags.Reference && (type).target === globalArrayType; } From 3a164b955b11fb82025a8636d57d8a94740381f8 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Tue, 5 Sep 2017 12:55:18 -0700 Subject: [PATCH 214/370] Improve baseline of complexRecursiveCollections By adding @lib:es6, which gets rid of tons of bogus errors. The point of the test is compile time, but it's more confidence-inspiring to know that basic ES6 collections are getting resolved and typechecked too. --- .../complexRecursiveCollections.errors.txt | 287 +----------------- .../compiler/complexRecursiveCollections.ts | 1 + 2 files changed, 2 insertions(+), 286 deletions(-) diff --git a/tests/baselines/reference/complexRecursiveCollections.errors.txt b/tests/baselines/reference/complexRecursiveCollections.errors.txt index 38f66b7456a..495fca2e651 100644 --- a/tests/baselines/reference/complexRecursiveCollections.errors.txt +++ b/tests/baselines/reference/complexRecursiveCollections.errors.txt @@ -1,110 +1,15 @@ -tests/cases/compiler/immutable.d.ts(25,39): error TS2304: Cannot find name 'Iterable'. -tests/cases/compiler/immutable.d.ts(46,20): error TS2304: Cannot find name 'Iterable'. -tests/cases/compiler/immutable.d.ts(47,23): error TS2304: Cannot find name 'Iterable'. -tests/cases/compiler/immutable.d.ts(48,23): error TS2304: Cannot find name 'Iterable'. -tests/cases/compiler/immutable.d.ts(49,23): error TS2304: Cannot find name 'Iterable'. -tests/cases/compiler/immutable.d.ts(50,23): error TS2304: Cannot find name 'Iterable'. -tests/cases/compiler/immutable.d.ts(51,22): error TS2304: Cannot find name 'Iterable'. -tests/cases/compiler/immutable.d.ts(52,26): error TS2304: Cannot find name 'Iterable'. -tests/cases/compiler/immutable.d.ts(58,45): error TS2304: Cannot find name 'Iterable'. -tests/cases/compiler/immutable.d.ts(60,63): error TS2304: Cannot find name 'Iterable'. -tests/cases/compiler/immutable.d.ts(68,41): error TS2304: Cannot find name 'Iterable'. -tests/cases/compiler/immutable.d.ts(69,38): error TS2304: Cannot find name 'Iterable'. -tests/cases/compiler/immutable.d.ts(69,47): error TS2304: Cannot find name 'Iterable'. -tests/cases/compiler/immutable.d.ts(78,21): error TS2304: Cannot find name 'Iterable'. -tests/cases/compiler/immutable.d.ts(79,21): error TS2304: Cannot find name 'Iterable'. -tests/cases/compiler/immutable.d.ts(89,20): error TS2304: Cannot find name 'Iterable'. -tests/cases/compiler/immutable.d.ts(90,23): error TS2304: Cannot find name 'Iterable'. -tests/cases/compiler/immutable.d.ts(91,23): error TS2304: Cannot find name 'Iterable'. -tests/cases/compiler/immutable.d.ts(92,23): error TS2304: Cannot find name 'Iterable'. -tests/cases/compiler/immutable.d.ts(93,23): error TS2304: Cannot find name 'Iterable'. -tests/cases/compiler/immutable.d.ts(94,22): error TS2304: Cannot find name 'Iterable'. -tests/cases/compiler/immutable.d.ts(95,26): error TS2304: Cannot find name 'Iterable'. -tests/cases/compiler/immutable.d.ts(101,42): error TS2304: Cannot find name 'Iterable'. -tests/cases/compiler/immutable.d.ts(106,58): error TS2304: Cannot find name 'Iterable'. -tests/cases/compiler/immutable.d.ts(113,48): error TS2304: Cannot find name 'Iterable'. -tests/cases/compiler/immutable.d.ts(114,45): error TS2304: Cannot find name 'Iterable'. -tests/cases/compiler/immutable.d.ts(114,54): error TS2304: Cannot find name 'Iterable'. -tests/cases/compiler/immutable.d.ts(120,42): error TS2304: Cannot find name 'Iterable'. -tests/cases/compiler/immutable.d.ts(125,58): error TS2304: Cannot find name 'Iterable'. -tests/cases/compiler/immutable.d.ts(134,33): error TS2304: Cannot find name 'Iterable'. -tests/cases/compiler/immutable.d.ts(134,42): error TS2304: Cannot find name 'Iterable'. -tests/cases/compiler/immutable.d.ts(135,29): error TS2304: Cannot find name 'Iterable'. -tests/cases/compiler/immutable.d.ts(135,38): error TS2304: Cannot find name 'Iterable'. -tests/cases/compiler/immutable.d.ts(139,38): error TS2304: Cannot find name 'Iterable'. -tests/cases/compiler/immutable.d.ts(155,45): error TS2304: Cannot find name 'Iterable'. -tests/cases/compiler/immutable.d.ts(157,62): error TS2304: Cannot find name 'Iterable'. -tests/cases/compiler/immutable.d.ts(169,45): error TS2304: Cannot find name 'Iterable'. -tests/cases/compiler/immutable.d.ts(172,45): error TS2304: Cannot find name 'Iterable'. -tests/cases/compiler/immutable.d.ts(174,62): error TS2304: Cannot find name 'Iterable'. -tests/cases/compiler/immutable.d.ts(188,40): error TS2304: Cannot find name 'Iterable'. -tests/cases/compiler/immutable.d.ts(195,22): error TS2304: Cannot find name 'Iterable'. -tests/cases/compiler/immutable.d.ts(198,19): error TS2304: Cannot find name 'Iterable'. -tests/cases/compiler/immutable.d.ts(205,45): error TS2304: Cannot find name 'Iterable'. -tests/cases/compiler/immutable.d.ts(207,63): error TS2304: Cannot find name 'Iterable'. -tests/cases/compiler/immutable.d.ts(217,30): error TS2304: Cannot find name 'Iterable'. -tests/cases/compiler/immutable.d.ts(218,34): error TS2304: Cannot find name 'Iterable'. -tests/cases/compiler/immutable.d.ts(226,22): error TS2304: Cannot find name 'Iterable'. -tests/cases/compiler/immutable.d.ts(227,22): error TS2304: Cannot find name 'Iterable'. -tests/cases/compiler/immutable.d.ts(234,48): error TS2304: Cannot find name 'Iterable'. -tests/cases/compiler/immutable.d.ts(235,52): error TS2304: Cannot find name 'Iterable'. -tests/cases/compiler/immutable.d.ts(236,109): error TS2304: Cannot find name 'Iterable'. -tests/cases/compiler/immutable.d.ts(237,109): error TS2304: Cannot find name 'Iterable'. -tests/cases/compiler/immutable.d.ts(242,22): error TS2304: Cannot find name 'Iterable'. -tests/cases/compiler/immutable.d.ts(243,25): error TS2304: Cannot find name 'Iterable'. -tests/cases/compiler/immutable.d.ts(244,24): error TS2304: Cannot find name 'Iterable'. -tests/cases/compiler/immutable.d.ts(245,28): error TS2304: Cannot find name 'Iterable'. -tests/cases/compiler/immutable.d.ts(246,25): error TS2304: Cannot find name 'Iterable'. -tests/cases/compiler/immutable.d.ts(247,25): error TS2304: Cannot find name 'Iterable'. -tests/cases/compiler/immutable.d.ts(258,8): error TS2304: Cannot find name 'Symbol'. -tests/cases/compiler/immutable.d.ts(258,28): error TS2304: Cannot find name 'IterableIterator'. -tests/cases/compiler/immutable.d.ts(266,45): error TS2304: Cannot find name 'Iterable'. -tests/cases/compiler/immutable.d.ts(274,44): error TS2304: Cannot find name 'Iterable'. -tests/cases/compiler/immutable.d.ts(279,60): error TS2304: Cannot find name 'Iterable'. -tests/cases/compiler/immutable.d.ts(288,44): error TS2304: Cannot find name 'Iterable'. -tests/cases/compiler/immutable.d.ts(293,47): error TS2304: Cannot find name 'Iterable'. -tests/cases/compiler/immutable.d.ts(295,65): error TS2304: Cannot find name 'Iterable'. -tests/cases/compiler/immutable.d.ts(304,40): error TS2304: Cannot find name 'Iterable'. -tests/cases/compiler/immutable.d.ts(309,47): error TS2304: Cannot find name 'Iterable'. -tests/cases/compiler/immutable.d.ts(311,64): error TS2304: Cannot find name 'Iterable'. -tests/cases/compiler/immutable.d.ts(320,38): error TS2304: Cannot find name 'Iterable'. -tests/cases/compiler/immutable.d.ts(329,58): error TS2304: Cannot find name 'Iterable'. -tests/cases/compiler/immutable.d.ts(339,45): error TS2304: Cannot find name 'Iterable'. tests/cases/compiler/immutable.d.ts(341,22): error TS2430: Interface 'Keyed' incorrectly extends interface 'Collection'. Types of property 'toSeq' are incompatible. Type '() => Keyed' is not assignable to type '() => this'. Type 'Keyed' is not assignable to type 'this'. -tests/cases/compiler/immutable.d.ts(347,44): error TS2304: Cannot find name 'Iterable'. -tests/cases/compiler/immutable.d.ts(352,60): error TS2304: Cannot find name 'Iterable'. -tests/cases/compiler/immutable.d.ts(355,8): error TS2304: Cannot find name 'Symbol'. -tests/cases/compiler/immutable.d.ts(355,28): error TS2304: Cannot find name 'IterableIterator'. -tests/cases/compiler/immutable.d.ts(358,44): error TS2304: Cannot find name 'Iterable'. tests/cases/compiler/immutable.d.ts(359,22): error TS2430: Interface 'Indexed' incorrectly extends interface 'Collection'. Types of property 'toSeq' are incompatible. Type '() => Indexed' is not assignable to type '() => this'. Type 'Indexed' is not assignable to type 'this'. -tests/cases/compiler/immutable.d.ts(382,47): error TS2304: Cannot find name 'Iterable'. -tests/cases/compiler/immutable.d.ts(384,65): error TS2304: Cannot find name 'Iterable'. -tests/cases/compiler/immutable.d.ts(387,8): error TS2304: Cannot find name 'Symbol'. -tests/cases/compiler/immutable.d.ts(387,28): error TS2304: Cannot find name 'IterableIterator'. -tests/cases/compiler/immutable.d.ts(390,40): error TS2304: Cannot find name 'Iterable'. tests/cases/compiler/immutable.d.ts(391,22): error TS2430: Interface 'Set' incorrectly extends interface 'Collection'. Types of property 'toSeq' are incompatible. Type '() => Set' is not assignable to type '() => this'. Type 'Set' is not assignable to type 'this'. -tests/cases/compiler/immutable.d.ts(396,47): error TS2304: Cannot find name 'Iterable'. -tests/cases/compiler/immutable.d.ts(398,64): error TS2304: Cannot find name 'Iterable'. -tests/cases/compiler/immutable.d.ts(401,8): error TS2304: Cannot find name 'Symbol'. -tests/cases/compiler/immutable.d.ts(401,28): error TS2304: Cannot find name 'IterableIterator'. -tests/cases/compiler/immutable.d.ts(405,45): error TS2304: Cannot find name 'Iterable'. -tests/cases/compiler/immutable.d.ts(420,26): error TS2304: Cannot find name 'Iterable'. -tests/cases/compiler/immutable.d.ts(421,26): error TS2304: Cannot find name 'Iterable'. -tests/cases/compiler/immutable.d.ts(442,13): error TS2304: Cannot find name 'IterableIterator'. -tests/cases/compiler/immutable.d.ts(443,15): error TS2304: Cannot find name 'IterableIterator'. -tests/cases/compiler/immutable.d.ts(444,16): error TS2304: Cannot find name 'IterableIterator'. -tests/cases/compiler/immutable.d.ts(476,58): error TS2304: Cannot find name 'Iterable'. -tests/cases/compiler/immutable.d.ts(503,20): error TS2304: Cannot find name 'Iterable'. -tests/cases/compiler/immutable.d.ts(504,22): error TS2304: Cannot find name 'Iterable'. ==== tests/cases/compiler/complex.d.ts (0 errors) ==== @@ -128,7 +33,7 @@ tests/cases/compiler/immutable.d.ts(504,22): error TS2304: Cannot find name 'Ite flatMap(mapper: (value: T, key: void, iter: this) => Ara, context?: any): N2; toSeq(): N2; } -==== tests/cases/compiler/immutable.d.ts (98 errors) ==== +==== tests/cases/compiler/immutable.d.ts (3 errors) ==== // Test that complex recursive collections can pass the `extends` assignability check without // running out of memory. This bug was exposed in Typescript 2.4 when more generic signatures // started being checked. @@ -154,8 +59,6 @@ tests/cases/compiler/immutable.d.ts(504,22): error TS2304: Cannot find name 'Ite export function List(): List; export function List(): List; export function List(collection: Iterable): List; - ~~~~~~~~ -!!! error TS2304: Cannot find name 'Iterable'. export interface List extends Collection.Indexed { // Persistent changes set(index: number, value: T): List; @@ -177,38 +80,20 @@ tests/cases/compiler/immutable.d.ts(504,22): error TS2304: Cannot find name 'Ite setSize(size: number): List; // Deep persistent changes setIn(keyPath: Iterable, value: any): this; - ~~~~~~~~ -!!! error TS2304: Cannot find name 'Iterable'. deleteIn(keyPath: Iterable): this; - ~~~~~~~~ -!!! error TS2304: Cannot find name 'Iterable'. removeIn(keyPath: Iterable): this; - ~~~~~~~~ -!!! error TS2304: Cannot find name 'Iterable'. updateIn(keyPath: Iterable, notSetValue: any, updater: (value: any) => any): this; - ~~~~~~~~ -!!! error TS2304: Cannot find name 'Iterable'. updateIn(keyPath: Iterable, updater: (value: any) => any): this; - ~~~~~~~~ -!!! error TS2304: Cannot find name 'Iterable'. mergeIn(keyPath: Iterable, ...collections: Array): this; - ~~~~~~~~ -!!! error TS2304: Cannot find name 'Iterable'. mergeDeepIn(keyPath: Iterable, ...collections: Array): this; - ~~~~~~~~ -!!! error TS2304: Cannot find name 'Iterable'. // Transient changes withMutations(mutator: (mutable: this) => any): this; asMutable(): this; asImmutable(): this; // Sequence algorithms concat(...valuesOrCollections: Array | C>): List; - ~~~~~~~~ -!!! error TS2304: Cannot find name 'Iterable'. map(mapper: (value: T, key: number, iter: this) => M, context?: any): List; flatMap(mapper: (value: T, key: number, iter: this) => Iterable, context?: any): List; - ~~~~~~~~ -!!! error TS2304: Cannot find name 'Iterable'. filter(predicate: (value: T, index: number, iter: this) => value is F, context?: any): List; filter(predicate: (value: T, index: number, iter: this) => any, context?: any): this; } @@ -217,13 +102,7 @@ tests/cases/compiler/immutable.d.ts(504,22): error TS2304: Cannot find name 'Ite function of(...keyValues: Array): Map; } export function Map(collection: Iterable<[K, V]>): Map; - ~~~~~~~~ -!!! error TS2304: Cannot find name 'Iterable'. export function Map(collection: Iterable>): Map; - ~~~~~~~~ -!!! error TS2304: Cannot find name 'Iterable'. - ~~~~~~~~ -!!! error TS2304: Cannot find name 'Iterable'. export function Map(obj: {[key: string]: V}): Map; export function Map(): Map; export function Map(): Map; @@ -233,11 +112,7 @@ tests/cases/compiler/immutable.d.ts(504,22): error TS2304: Cannot find name 'Ite delete(key: K): this; remove(key: K): this; deleteAll(keys: Iterable): this; - ~~~~~~~~ -!!! error TS2304: Cannot find name 'Iterable'. removeAll(keys: Iterable): this; - ~~~~~~~~ -!!! error TS2304: Cannot find name 'Iterable'. clear(): this; update(key: K, notSetValue: V, updater: (value: V) => V): this; update(key: K, updater: (value: V) => V): this; @@ -248,41 +123,23 @@ tests/cases/compiler/immutable.d.ts(504,22): error TS2304: Cannot find name 'Ite mergeDeepWith(merger: (oldVal: V, newVal: V, key: K) => V, ...collections: Array | {[key: string]: V}>): this; // Deep persistent changes setIn(keyPath: Iterable, value: any): this; - ~~~~~~~~ -!!! error TS2304: Cannot find name 'Iterable'. deleteIn(keyPath: Iterable): this; - ~~~~~~~~ -!!! error TS2304: Cannot find name 'Iterable'. removeIn(keyPath: Iterable): this; - ~~~~~~~~ -!!! error TS2304: Cannot find name 'Iterable'. updateIn(keyPath: Iterable, notSetValue: any, updater: (value: any) => any): this; - ~~~~~~~~ -!!! error TS2304: Cannot find name 'Iterable'. updateIn(keyPath: Iterable, updater: (value: any) => any): this; - ~~~~~~~~ -!!! error TS2304: Cannot find name 'Iterable'. mergeIn(keyPath: Iterable, ...collections: Array): this; - ~~~~~~~~ -!!! error TS2304: Cannot find name 'Iterable'. mergeDeepIn(keyPath: Iterable, ...collections: Array): this; - ~~~~~~~~ -!!! error TS2304: Cannot find name 'Iterable'. // Transient changes withMutations(mutator: (mutable: this) => any): this; asMutable(): this; asImmutable(): this; // Sequence algorithms concat(...collections: Array>): Map; - ~~~~~~~~ -!!! error TS2304: Cannot find name 'Iterable'. concat(...collections: Array<{[key: string]: C}>): Map; map(mapper: (value: V, key: K, iter: this) => M, context?: any): Map; mapKeys(mapper: (key: K, value: V, iter: this) => M, context?: any): Map; mapEntries(mapper: (entry: [K, V], index: number, iter: this) => [KM, VM], context?: any): Map; flatMap(mapper: (value: V, key: K, iter: this) => Iterable, context?: any): Map; - ~~~~~~~~ -!!! error TS2304: Cannot find name 'Iterable'. filter(predicate: (value: V, key: K, iter: this) => value is F, context?: any): Map; filter(predicate: (value: V, key: K, iter: this) => any, context?: any): this; } @@ -290,28 +147,18 @@ tests/cases/compiler/immutable.d.ts(504,22): error TS2304: Cannot find name 'Ite function isOrderedMap(maybeOrderedMap: any): maybeOrderedMap is OrderedMap; } export function OrderedMap(collection: Iterable<[K, V]>): OrderedMap; - ~~~~~~~~ -!!! error TS2304: Cannot find name 'Iterable'. export function OrderedMap(collection: Iterable>): OrderedMap; - ~~~~~~~~ -!!! error TS2304: Cannot find name 'Iterable'. - ~~~~~~~~ -!!! error TS2304: Cannot find name 'Iterable'. export function OrderedMap(obj: {[key: string]: V}): OrderedMap; export function OrderedMap(): OrderedMap; export function OrderedMap(): OrderedMap; export interface OrderedMap extends Map { // Sequence algorithms concat(...collections: Array>): OrderedMap; - ~~~~~~~~ -!!! error TS2304: Cannot find name 'Iterable'. concat(...collections: Array<{[key: string]: C}>): OrderedMap; map(mapper: (value: V, key: K, iter: this) => M, context?: any): OrderedMap; mapKeys(mapper: (key: K, value: V, iter: this) => M, context?: any): OrderedMap; mapEntries(mapper: (entry: [K, V], index: number, iter: this) => [KM, VM], context?: any): OrderedMap; flatMap(mapper: (value: V, key: K, iter: this) => Iterable, context?: any): OrderedMap; - ~~~~~~~~ -!!! error TS2304: Cannot find name 'Iterable'. filter(predicate: (value: V, key: K, iter: this) => value is F, context?: any): OrderedMap; filter(predicate: (value: V, key: K, iter: this) => any, context?: any): this; } @@ -321,21 +168,11 @@ tests/cases/compiler/immutable.d.ts(504,22): error TS2304: Cannot find name 'Ite function fromKeys(iter: Collection): Set; function fromKeys(obj: {[key: string]: any}): Set; function intersect(sets: Iterable>): Set; - ~~~~~~~~ -!!! error TS2304: Cannot find name 'Iterable'. - ~~~~~~~~ -!!! error TS2304: Cannot find name 'Iterable'. function union(sets: Iterable>): Set; - ~~~~~~~~ -!!! error TS2304: Cannot find name 'Iterable'. - ~~~~~~~~ -!!! error TS2304: Cannot find name 'Iterable'. } export function Set(): Set; export function Set(): Set; export function Set(collection: Iterable): Set; - ~~~~~~~~ -!!! error TS2304: Cannot find name 'Iterable'. export interface Set extends Collection.Set { // Persistent changes add(value: T): this; @@ -352,12 +189,8 @@ tests/cases/compiler/immutable.d.ts(504,22): error TS2304: Cannot find name 'Ite asImmutable(): this; // Sequence algorithms concat(...valuesOrCollections: Array | C>): Set; - ~~~~~~~~ -!!! error TS2304: Cannot find name 'Iterable'. map(mapper: (value: T, key: never, iter: this) => M, context?: any): Set; flatMap(mapper: (value: T, key: never, iter: this) => Iterable, context?: any): Set; - ~~~~~~~~ -!!! error TS2304: Cannot find name 'Iterable'. filter(predicate: (value: T, key: never, iter: this) => value is F, context?: any): Set; filter(predicate: (value: T, key: never, iter: this) => any, context?: any): this; } @@ -370,17 +203,11 @@ tests/cases/compiler/immutable.d.ts(504,22): error TS2304: Cannot find name 'Ite export function OrderedSet(): OrderedSet; export function OrderedSet(): OrderedSet; export function OrderedSet(collection: Iterable): OrderedSet; - ~~~~~~~~ -!!! error TS2304: Cannot find name 'Iterable'. export interface OrderedSet extends Set { // Sequence algorithms concat(...valuesOrCollections: Array | C>): OrderedSet; - ~~~~~~~~ -!!! error TS2304: Cannot find name 'Iterable'. map(mapper: (value: T, key: never, iter: this) => M, context?: any): OrderedSet; flatMap(mapper: (value: T, key: never, iter: this) => Iterable, context?: any): OrderedSet; - ~~~~~~~~ -!!! error TS2304: Cannot find name 'Iterable'. filter(predicate: (value: T, key: never, iter: this) => value is F, context?: any): OrderedSet; filter(predicate: (value: T, key: never, iter: this) => any, context?: any): this; zip(...collections: Array>): OrderedSet; @@ -395,8 +222,6 @@ tests/cases/compiler/immutable.d.ts(504,22): error TS2304: Cannot find name 'Ite export function Stack(): Stack; export function Stack(): Stack; export function Stack(collection: Iterable): Stack; - ~~~~~~~~ -!!! error TS2304: Cannot find name 'Iterable'. export interface Stack extends Collection.Indexed { // Reading values peek(): T | undefined; @@ -404,13 +229,9 @@ tests/cases/compiler/immutable.d.ts(504,22): error TS2304: Cannot find name 'Ite clear(): Stack; unshift(...values: Array): Stack; unshiftAll(iter: Iterable): Stack; - ~~~~~~~~ -!!! error TS2304: Cannot find name 'Iterable'. shift(): Stack; push(...values: Array): Stack; pushAll(iter: Iterable): Stack; - ~~~~~~~~ -!!! error TS2304: Cannot find name 'Iterable'. pop(): Stack; // Transient changes withMutations(mutator: (mutable: this) => any): this; @@ -418,12 +239,8 @@ tests/cases/compiler/immutable.d.ts(504,22): error TS2304: Cannot find name 'Ite asImmutable(): this; // Sequence algorithms concat(...valuesOrCollections: Array | C>): Stack; - ~~~~~~~~ -!!! error TS2304: Cannot find name 'Iterable'. map(mapper: (value: T, key: number, iter: this) => M, context?: any): Stack; flatMap(mapper: (value: T, key: number, iter: this) => Iterable, context?: any): Stack; - ~~~~~~~~ -!!! error TS2304: Cannot find name 'Iterable'. filter(predicate: (value: T, index: number, iter: this) => value is F, context?: any): Set; filter(predicate: (value: T, index: number, iter: this) => any, context?: any): this; } @@ -434,11 +251,7 @@ tests/cases/compiler/immutable.d.ts(504,22): error TS2304: Cannot find name 'Ite export function getDescriptiveName(record: Instance): string; export interface Class { (values?: Partial | Iterable<[string, any]>): Instance & Readonly; - ~~~~~~~~ -!!! error TS2304: Cannot find name 'Iterable'. new (values?: Partial | Iterable<[string, any]>): Instance & Readonly; - ~~~~~~~~ -!!! error TS2304: Cannot find name 'Iterable'. } export interface Instance { readonly size: number; @@ -447,11 +260,7 @@ tests/cases/compiler/immutable.d.ts(504,22): error TS2304: Cannot find name 'Ite get(key: K): T[K]; // Reading deep values hasIn(keyPath: Iterable): boolean; - ~~~~~~~~ -!!! error TS2304: Cannot find name 'Iterable'. getIn(keyPath: Iterable): any; - ~~~~~~~~ -!!! error TS2304: Cannot find name 'Iterable'. // Value equality equals(other: any): boolean; hashCode(): number; @@ -459,39 +268,19 @@ tests/cases/compiler/immutable.d.ts(504,22): error TS2304: Cannot find name 'Ite set(key: K, value: T[K]): this; update(key: K, updater: (value: T[K]) => T[K]): this; merge(...collections: Array | Iterable<[string, any]>>): this; - ~~~~~~~~ -!!! error TS2304: Cannot find name 'Iterable'. mergeDeep(...collections: Array | Iterable<[string, any]>>): this; - ~~~~~~~~ -!!! error TS2304: Cannot find name 'Iterable'. mergeWith(merger: (oldVal: any, newVal: any, key: keyof T) => any, ...collections: Array | Iterable<[string, any]>>): this; - ~~~~~~~~ -!!! error TS2304: Cannot find name 'Iterable'. mergeDeepWith(merger: (oldVal: any, newVal: any, key: any) => any, ...collections: Array | Iterable<[string, any]>>): this; - ~~~~~~~~ -!!! error TS2304: Cannot find name 'Iterable'. delete(key: K): this; remove(key: K): this; clear(): this; // Deep persistent changes setIn(keyPath: Iterable, value: any): this; - ~~~~~~~~ -!!! error TS2304: Cannot find name 'Iterable'. updateIn(keyPath: Iterable, updater: (value: any) => any): this; - ~~~~~~~~ -!!! error TS2304: Cannot find name 'Iterable'. mergeIn(keyPath: Iterable, ...collections: Array): this; - ~~~~~~~~ -!!! error TS2304: Cannot find name 'Iterable'. mergeDeepIn(keyPath: Iterable, ...collections: Array): this; - ~~~~~~~~ -!!! error TS2304: Cannot find name 'Iterable'. deleteIn(keyPath: Iterable): this; - ~~~~~~~~ -!!! error TS2304: Cannot find name 'Iterable'. removeIn(keyPath: Iterable): this; - ~~~~~~~~ -!!! error TS2304: Cannot find name 'Iterable'. // Conversion to JavaScript types toJS(): { [K in keyof T]: any }; toJSON(): T; @@ -503,10 +292,6 @@ tests/cases/compiler/immutable.d.ts(504,22): error TS2304: Cannot find name 'Ite // Sequence algorithms toSeq(): Seq.Keyed; [Symbol.iterator](): IterableIterator<[keyof T, T[keyof T]]>; - ~~~~~~ -!!! error TS2304: Cannot find name 'Symbol'. - ~~~~~~~~~~~~~~~~ -!!! error TS2304: Cannot find name 'IterableIterator'. } } export function Record(defaultValues: T, name?: string): Record.Class; @@ -515,8 +300,6 @@ tests/cases/compiler/immutable.d.ts(504,22): error TS2304: Cannot find name 'Ite function of(...values: Array): Seq.Indexed; export module Keyed {} export function Keyed(collection: Iterable<[K, V]>): Seq.Keyed; - ~~~~~~~~ -!!! error TS2304: Cannot find name 'Iterable'. export function Keyed(obj: {[key: string]: V}): Seq.Keyed; export function Keyed(): Seq.Keyed; export function Keyed(): Seq.Keyed; @@ -525,15 +308,11 @@ tests/cases/compiler/immutable.d.ts(504,22): error TS2304: Cannot find name 'Ite toJSON(): { [key: string]: V }; toSeq(): this; concat(...collections: Array>): Seq.Keyed; - ~~~~~~~~ -!!! error TS2304: Cannot find name 'Iterable'. concat(...collections: Array<{[key: string]: C}>): Seq.Keyed; map(mapper: (value: V, key: K, iter: this) => M, context?: any): Seq.Keyed; mapKeys(mapper: (key: K, value: V, iter: this) => M, context?: any): Seq.Keyed; mapEntries(mapper: (entry: [K, V], index: number, iter: this) => [KM, VM], context?: any): Seq.Keyed; flatMap(mapper: (value: V, key: K, iter: this) => Iterable, context?: any): Seq.Keyed; - ~~~~~~~~ -!!! error TS2304: Cannot find name 'Iterable'. filter(predicate: (value: V, key: K, iter: this) => value is F, context?: any): Seq.Keyed; filter(predicate: (value: V, key: K, iter: this) => any, context?: any): this; } @@ -543,19 +322,13 @@ tests/cases/compiler/immutable.d.ts(504,22): error TS2304: Cannot find name 'Ite export function Indexed(): Seq.Indexed; export function Indexed(): Seq.Indexed; export function Indexed(collection: Iterable): Seq.Indexed; - ~~~~~~~~ -!!! error TS2304: Cannot find name 'Iterable'. export interface Indexed extends Seq, Collection.Indexed { toJS(): Array; toJSON(): Array; toSeq(): this; concat(...valuesOrCollections: Array | C>): Seq.Indexed; - ~~~~~~~~ -!!! error TS2304: Cannot find name 'Iterable'. map(mapper: (value: T, key: number, iter: this) => M, context?: any): Seq.Indexed; flatMap(mapper: (value: T, key: number, iter: this) => Iterable, context?: any): Seq.Indexed; - ~~~~~~~~ -!!! error TS2304: Cannot find name 'Iterable'. filter(predicate: (value: T, index: number, iter: this) => value is F, context?: any): Seq.Indexed; filter(predicate: (value: T, index: number, iter: this) => any, context?: any): this; } @@ -565,19 +338,13 @@ tests/cases/compiler/immutable.d.ts(504,22): error TS2304: Cannot find name 'Ite export function Set(): Seq.Set; export function Set(): Seq.Set; export function Set(collection: Iterable): Seq.Set; - ~~~~~~~~ -!!! error TS2304: Cannot find name 'Iterable'. export interface Set extends Seq, Collection.Set { toJS(): Array; toJSON(): Array; toSeq(): this; concat(...valuesOrCollections: Array | C>): Seq.Set; - ~~~~~~~~ -!!! error TS2304: Cannot find name 'Iterable'. map(mapper: (value: T, key: never, iter: this) => M, context?: any): Seq.Set; flatMap(mapper: (value: T, key: never, iter: this) => Iterable, context?: any): Seq.Set; - ~~~~~~~~ -!!! error TS2304: Cannot find name 'Iterable'. filter(predicate: (value: T, key: never, iter: this) => value is F, context?: any): Seq.Set; filter(predicate: (value: T, key: never, iter: this) => any, context?: any): this; } @@ -587,8 +354,6 @@ tests/cases/compiler/immutable.d.ts(504,22): error TS2304: Cannot find name 'Ite export function Seq(collection: Collection.Indexed): Seq.Indexed; export function Seq(collection: Collection.Set): Seq.Set; export function Seq(collection: Iterable): Seq.Indexed; - ~~~~~~~~ -!!! error TS2304: Cannot find name 'Iterable'. export function Seq(obj: {[key: string]: V}): Seq.Keyed; export function Seq(): Seq; export interface Seq extends Collection { @@ -598,8 +363,6 @@ tests/cases/compiler/immutable.d.ts(504,22): error TS2304: Cannot find name 'Ite // Sequence algorithms map(mapper: (value: V, key: K, iter: this) => M, context?: any): Seq; flatMap(mapper: (value: V, key: K, iter: this) => Iterable, context?: any): Seq; - ~~~~~~~~ -!!! error TS2304: Cannot find name 'Iterable'. filter(predicate: (value: V, key: K, iter: this) => value is F, context?: any): Seq; filter(predicate: (value: V, key: K, iter: this) => any, context?: any): this; } @@ -610,8 +373,6 @@ tests/cases/compiler/immutable.d.ts(504,22): error TS2304: Cannot find name 'Ite function isOrdered(maybeOrdered: any): boolean; export module Keyed {} export function Keyed(collection: Iterable<[K, V]>): Collection.Keyed; - ~~~~~~~~ -!!! error TS2304: Cannot find name 'Iterable'. export function Keyed(obj: {[key: string]: V}): Collection.Keyed; export interface Keyed extends Collection { ~~~~~ @@ -625,27 +386,17 @@ tests/cases/compiler/immutable.d.ts(504,22): error TS2304: Cannot find name 'Ite // Sequence functions flip(): this; concat(...collections: Array>): Collection.Keyed; - ~~~~~~~~ -!!! error TS2304: Cannot find name 'Iterable'. concat(...collections: Array<{[key: string]: C}>): Collection.Keyed; map(mapper: (value: V, key: K, iter: this) => M, context?: any): Collection.Keyed; mapKeys(mapper: (key: K, value: V, iter: this) => M, context?: any): Collection.Keyed; mapEntries(mapper: (entry: [K, V], index: number, iter: this) => [KM, VM], context?: any): Collection.Keyed; flatMap(mapper: (value: V, key: K, iter: this) => Iterable, context?: any): Collection.Keyed; - ~~~~~~~~ -!!! error TS2304: Cannot find name 'Iterable'. filter(predicate: (value: V, key: K, iter: this) => value is F, context?: any): Collection.Keyed; filter(predicate: (value: V, key: K, iter: this) => any, context?: any): this; [Symbol.iterator](): IterableIterator<[K, V]>; - ~~~~~~ -!!! error TS2304: Cannot find name 'Symbol'. - ~~~~~~~~~~~~~~~~ -!!! error TS2304: Cannot find name 'IterableIterator'. } export module Indexed {} export function Indexed(collection: Iterable): Collection.Indexed; - ~~~~~~~~ -!!! error TS2304: Cannot find name 'Iterable'. export interface Indexed extends Collection { ~~~~~~~ !!! error TS2430: Interface 'Indexed' incorrectly extends interface 'Collection'. @@ -675,24 +426,14 @@ tests/cases/compiler/immutable.d.ts(504,22): error TS2304: Cannot find name 'Ite findLastIndex(predicate: (value: T, index: number, iter: this) => boolean, context?: any): number; // Sequence algorithms concat(...valuesOrCollections: Array | C>): Collection.Indexed; - ~~~~~~~~ -!!! error TS2304: Cannot find name 'Iterable'. map(mapper: (value: T, key: number, iter: this) => M, context?: any): Collection.Indexed; flatMap(mapper: (value: T, key: number, iter: this) => Iterable, context?: any): Collection.Indexed; - ~~~~~~~~ -!!! error TS2304: Cannot find name 'Iterable'. filter(predicate: (value: T, index: number, iter: this) => value is F, context?: any): Collection.Indexed; filter(predicate: (value: T, index: number, iter: this) => any, context?: any): this; [Symbol.iterator](): IterableIterator; - ~~~~~~ -!!! error TS2304: Cannot find name 'Symbol'. - ~~~~~~~~~~~~~~~~ -!!! error TS2304: Cannot find name 'IterableIterator'. } export module Set {} export function Set(collection: Iterable): Collection.Set; - ~~~~~~~~ -!!! error TS2304: Cannot find name 'Iterable'. export interface Set extends Collection { ~~~ !!! error TS2430: Interface 'Set' incorrectly extends interface 'Collection'. @@ -704,25 +445,15 @@ tests/cases/compiler/immutable.d.ts(504,22): error TS2304: Cannot find name 'Ite toSeq(): Seq.Set; // Sequence algorithms concat(...valuesOrCollections: Array | C>): Collection.Set; - ~~~~~~~~ -!!! error TS2304: Cannot find name 'Iterable'. map(mapper: (value: T, key: never, iter: this) => M, context?: any): Collection.Set; flatMap(mapper: (value: T, key: never, iter: this) => Iterable, context?: any): Collection.Set; - ~~~~~~~~ -!!! error TS2304: Cannot find name 'Iterable'. filter(predicate: (value: T, key: never, iter: this) => value is F, context?: any): Collection.Set; filter(predicate: (value: T, key: never, iter: this) => any, context?: any): this; [Symbol.iterator](): IterableIterator; - ~~~~~~ -!!! error TS2304: Cannot find name 'Symbol'. - ~~~~~~~~~~~~~~~~ -!!! error TS2304: Cannot find name 'IterableIterator'. } } export function Collection>(collection: I): I; export function Collection(collection: Iterable): Collection.Indexed; - ~~~~~~~~ -!!! error TS2304: Cannot find name 'Iterable'. export function Collection(obj: {[key: string]: V}): Collection.Keyed; export interface Collection extends ValueObject { // Value equality @@ -738,11 +469,7 @@ tests/cases/compiler/immutable.d.ts(504,22): error TS2304: Cannot find name 'Ite last(): V | undefined; // Reading deep values getIn(searchKeyPath: Iterable, notSetValue?: any): any; - ~~~~~~~~ -!!! error TS2304: Cannot find name 'Iterable'. hasIn(searchKeyPath: Iterable): boolean; - ~~~~~~~~ -!!! error TS2304: Cannot find name 'Iterable'. // Persistent changes update(updater: (value: this) => R): R; // Conversion to JavaScript types @@ -764,14 +491,8 @@ tests/cases/compiler/immutable.d.ts(504,22): error TS2304: Cannot find name 'Ite toSetSeq(): Seq.Set; // Iterators keys(): IterableIterator; - ~~~~~~~~~~~~~~~~ -!!! error TS2304: Cannot find name 'IterableIterator'. values(): IterableIterator; - ~~~~~~~~~~~~~~~~ -!!! error TS2304: Cannot find name 'IterableIterator'. entries(): IterableIterator<[K, V]>; - ~~~~~~~~~~~~~~~~ -!!! error TS2304: Cannot find name 'IterableIterator'. // Collections (Seq) keySeq(): Seq.Indexed; valueSeq(): Seq.Indexed; @@ -804,8 +525,6 @@ tests/cases/compiler/immutable.d.ts(504,22): error TS2304: Cannot find name 'Ite flatten(depth?: number): Collection; flatten(shallow?: boolean): Collection; flatMap(mapper: (value: V, key: K, iter: this) => Iterable, context?: any): Collection; - ~~~~~~~~ -!!! error TS2304: Cannot find name 'Iterable'. // Reducing a value reduce(reducer: (reduction: R, value: V, key: K, iter: this) => R, initialReduction: R, context?: any): R; reduce(reducer: (reduction: V | R, value: V, key: K, iter: this) => R): R; @@ -833,11 +552,7 @@ tests/cases/compiler/immutable.d.ts(504,22): error TS2304: Cannot find name 'Ite minBy(comparatorValueMapper: (value: V, key: K, iter: this) => C, comparator?: (valueA: C, valueB: C) => number): V | undefined; // Comparison isSubset(iter: Iterable): boolean; - ~~~~~~~~ -!!! error TS2304: Cannot find name 'Iterable'. isSuperset(iter: Iterable): boolean; - ~~~~~~~~ -!!! error TS2304: Cannot find name 'Iterable'. readonly size: number; } } diff --git a/tests/cases/compiler/complexRecursiveCollections.ts b/tests/cases/compiler/complexRecursiveCollections.ts index a79b429f204..68054aac0f9 100644 --- a/tests/cases/compiler/complexRecursiveCollections.ts +++ b/tests/cases/compiler/complexRecursiveCollections.ts @@ -1,3 +1,4 @@ +// @lib: es6 // @Filename: complex.d.ts interface Ara { t: T } interface Collection { From 6ae761720e7c532185940166f0b9ea5afba89599 Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Tue, 5 Sep 2017 13:37:51 -0700 Subject: [PATCH 215/370] Add test for #14574 (#18024) --- tests/cases/fourslash/quickInfoForSyntaxErrorNoError.ts | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 tests/cases/fourslash/quickInfoForSyntaxErrorNoError.ts diff --git a/tests/cases/fourslash/quickInfoForSyntaxErrorNoError.ts b/tests/cases/fourslash/quickInfoForSyntaxErrorNoError.ts new file mode 100644 index 00000000000..147483cfe58 --- /dev/null +++ b/tests/cases/fourslash/quickInfoForSyntaxErrorNoError.ts @@ -0,0 +1,9 @@ +/// + +//// namespace X { +//// export = +//// } +//// X.add/*1*/ + +// verify there is no crash +verify.quickInfoAt("1", "any"); From 56f646eaff42446f435bd46777e27948fc8a62c8 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Tue, 5 Sep 2017 15:09:06 -0700 Subject: [PATCH 216/370] Make top-level getJSDoc* functions public * getJSDocParameterTags * getJSDocAugmentsTag * getJSDocClassTag * getJSDocClassTag * getJSDocTemplateTag * getJSDocReturnTag * getJSDocType * getJSDocReturnType --- src/compiler/utilities.ts | 142 ++++++++++++++++++++++++-------------- 1 file changed, 91 insertions(+), 51 deletions(-) diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index 2a07d2b6560..fe242190262 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -1495,15 +1495,6 @@ namespace ts { ((node as JSDocFunctionType).parameters[0].name as Identifier).escapedText === "new"; } - export function hasJSDocParameterTags(node: FunctionLikeDeclaration | SignatureDeclaration): boolean { - return !!getFirstJSDocTag(node, SyntaxKind.JSDocParameterTag); - } - - function getFirstJSDocTag(node: Node, kind: SyntaxKind): JSDocTag | undefined { - const tags = getJSDocTags(node); - return find(tags, doc => doc.kind === kind); - } - export function getAllJSDocs(node: Node): (JSDoc | JSDocTag)[] { if (isJSDocTypedefTag(node)) { return [node.parent]; @@ -1577,15 +1568,6 @@ namespace ts { } } - export function getJSDocParameterTags(param: ParameterDeclaration): JSDocParameterTag[] | undefined { - if (param.name && isIdentifier(param.name)) { - const name = param.name.escapedText; - return getJSDocTags(param.parent).filter((tag): tag is JSDocParameterTag => isJSDocParameterTag(tag) && isIdentifier(tag.name) && tag.name.escapedText === name) as JSDocParameterTag[]; - } - // a binding pattern doesn't have a name, so it's not possible to match it a jsdoc parameter, which is identified by name - return undefined; - } - /** Does the opposite of `getJSDocParameterTags`: given a JSDoc parameter, finds the parameter corresponding to it. */ export function getParameterSymbolFromJSDoc(node: JSDocParameterTag): Symbol | undefined { if (node.symbol) { @@ -1611,39 +1593,6 @@ namespace ts { return find(typeParameters, p => p.name.escapedText === name); } - export function getJSDocType(node: Node): TypeNode { - let tag: JSDocTypeTag | JSDocParameterTag = getFirstJSDocTag(node, SyntaxKind.JSDocTypeTag) as JSDocTypeTag; - if (!tag && node.kind === SyntaxKind.Parameter) { - const paramTags = getJSDocParameterTags(node as ParameterDeclaration); - if (paramTags) { - tag = find(paramTags, tag => !!tag.typeExpression); - } - } - - return tag && tag.typeExpression && tag.typeExpression.type; - } - - export function getJSDocAugmentsTag(node: Node): JSDocAugmentsTag { - return getFirstJSDocTag(node, SyntaxKind.JSDocAugmentsTag) as JSDocAugmentsTag; - } - - export function getJSDocClassTag(node: Node): JSDocClassTag { - return getFirstJSDocTag(node, SyntaxKind.JSDocClassTag) as JSDocClassTag; - } - - export function getJSDocReturnTag(node: Node): JSDocReturnTag { - return getFirstJSDocTag(node, SyntaxKind.JSDocReturnTag) as JSDocReturnTag; - } - - export function getJSDocReturnType(node: Node): TypeNode { - const returnTag = getJSDocReturnTag(node); - return returnTag && returnTag.typeExpression && returnTag.typeExpression.type; - } - - export function getJSDocTemplateTag(node: Node): JSDocTemplateTag { - return getFirstJSDocTag(node, SyntaxKind.JSDocTemplateTag) as JSDocTemplateTag; - } - export function hasRestParameter(s: SignatureDeclaration): boolean { return isRestParameter(lastOrUndefined(s.parameters)); } @@ -3983,6 +3932,97 @@ namespace ts { return (declaration as NamedDeclaration).name; } } + + /** + * Gets the JSDoc parameter tags for the node if present. + * + * @remarks Returns any JSDoc param tag that matches the provided + * parameter, whether a param tag on a containing function + * expression, or a param tag on a variable declaration whose + * initializer is the containing function. The tags closest to the + * node are returned first, so in the previous example, the param + * tag on the containing function expression would be first. + * + * Does not return tags for binding patterns, because JSDoc matches + * parameters by name and binding patterns do not have a name. + */ + export function getJSDocParameterTags(param: ParameterDeclaration): ReadonlyArray | undefined { + if (param.name && isIdentifier(param.name)) { + const name = param.name.escapedText; + return getJSDocTags(param.parent).filter((tag): tag is JSDocParameterTag => isJSDocParameterTag(tag) && isIdentifier(tag.name) && tag.name.escapedText === name) as JSDocParameterTag[]; + } + // a binding pattern doesn't have a name, so it's not possible to match it a JSDoc parameter, which is identified by name + return undefined; + } + + /** + * Return true if the node has JSDoc parameter tags. + * + * @remarks Includes parameter tags that are not directly on the node, + * for example on a variable declaration whose initializer is a function expression. + */ + export function hasJSDocParameterTags(node: FunctionLikeDeclaration | SignatureDeclaration): boolean { + return !!getFirstJSDocTag(node, SyntaxKind.JSDocParameterTag); + } + + /** Gets the JSDoc augments tag for the node if present */ + export function getJSDocAugmentsTag(node: Node): JSDocAugmentsTag | undefined { + return getFirstJSDocTag(node, SyntaxKind.JSDocAugmentsTag) as JSDocAugmentsTag; + } + + /** Gets the JSDoc class tag for the node if present */ + export function getJSDocClassTag(node: Node): JSDocClassTag | undefined { + return getFirstJSDocTag(node, SyntaxKind.JSDocClassTag) as JSDocClassTag; + } + + /** Gets the JSDoc template tag for the node if present */ + export function getJSDocTemplateTag(node: Node): JSDocTemplateTag | undefined { + return getFirstJSDocTag(node, SyntaxKind.JSDocTemplateTag) as JSDocTemplateTag; + } + + /** Gets the JSDoc return tag for the node if present */ + export function getJSDocReturnTag(node: Node): JSDocReturnTag | undefined { + return getFirstJSDocTag(node, SyntaxKind.JSDocReturnTag) as JSDocReturnTag; + } + + /** + * Gets the type node for the node if provided via JSDoc. + * + * @remarks The search includes any JSDoc param tag that relates + * to the provided parameter, for example a type tag on the + * parameter itself, or a param tag on a containing function + * expression, or a param tag on a variable declaration whose + * initializer is the containing function. The tags closest to the + * node are examined first, so in the previous example, the type + * tag directly on the node would be returned. + */ + export function getJSDocType(node: Node): TypeNode | undefined { + let tag: JSDocTypeTag | JSDocParameterTag = getFirstJSDocTag(node, SyntaxKind.JSDocTypeTag) as JSDocTypeTag; + if (!tag && node.kind === SyntaxKind.Parameter) { + const paramTags = getJSDocParameterTags(node as ParameterDeclaration); + if (paramTags) { + tag = find(paramTags, tag => !!tag.typeExpression); + } + } + + return tag && tag.typeExpression && tag.typeExpression.type; + } + + /** + * Gets the return type node for the node if provided via JSDoc's return tag. + * + * @remarks `getJSDocReturnTag` just gets the whole JSDoc tag. This function + * gets the type from inside the braces. */ + export function getJSDocReturnType(node: Node): TypeNode | undefined { + const returnTag = getJSDocReturnTag(node); + return returnTag && returnTag.typeExpression && returnTag.typeExpression.type; + } + + /* Get the first JSDoc tag of a specified kind, or undefined if not present. */ + function getFirstJSDocTag(node: Node, kind: SyntaxKind): JSDocTag | undefined { + const tags = getJSDocTags(node); + return find(tags, doc => doc.kind === kind); + } } // Simple node tests of the form `node.kind === SyntaxKind.Foo`. From 058d355caeab3b4058e1166974ecd8444383fce4 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Tue, 5 Sep 2017 15:22:17 -0700 Subject: [PATCH 217/370] Add getJSDocTypeTag to get `@type` tag --- src/compiler/utilities.ts | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index fe242190262..78eacee7d22 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -3975,14 +3975,19 @@ namespace ts { return getFirstJSDocTag(node, SyntaxKind.JSDocClassTag) as JSDocClassTag; } + /** Gets the JSDoc return tag for the node if present */ + export function getJSDocReturnTag(node: Node): JSDocReturnTag | undefined { + return getFirstJSDocTag(node, SyntaxKind.JSDocReturnTag) as JSDocReturnTag; + } + /** Gets the JSDoc template tag for the node if present */ export function getJSDocTemplateTag(node: Node): JSDocTemplateTag | undefined { return getFirstJSDocTag(node, SyntaxKind.JSDocTemplateTag) as JSDocTemplateTag; } - /** Gets the JSDoc return tag for the node if present */ - export function getJSDocReturnTag(node: Node): JSDocReturnTag | undefined { - return getFirstJSDocTag(node, SyntaxKind.JSDocReturnTag) as JSDocReturnTag; + /** Gets the JSDoc type tag for the node if present */ + export function getJSDocTypeTag(node: Node): JSDocTypeTag | undefined { + return getFirstJSDocTag(node, SyntaxKind.JSDocTypeTag) as JSDocTypeTag; } /** From 9c6765d5cf697b5cb2fcda3d21bb2c2985ecdaf9 Mon Sep 17 00:00:00 2001 From: Andrew Casey Date: Tue, 5 Sep 2017 15:47:54 -0700 Subject: [PATCH 218/370] Document ThrottledOperations.schedule --- src/server/utilities.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/server/utilities.ts b/src/server/utilities.ts index 700a1e12fee..cde6329bf07 100644 --- a/src/server/utilities.ts +++ b/src/server/utilities.ts @@ -179,6 +179,12 @@ namespace ts.server { constructor(private readonly host: ServerHost) { } + /** + * Wait `number` milliseconds and then invoke `cb`. If, while waiting, schedule + * is called again with the same `operationId`, cancel this operation in favor + * of the new one. (Note that the amount of time the canceled operation had been + * waiting does not affect the amount of time that the new operation waits.) + */ public schedule(operationId: string, delay: number, cb: () => void) { const pendingTimeout = this.pendingTimeouts.get(operationId); if (pendingTimeout) { From 95bf71f08c114dc22979cfbeed5f1bcddfc6bbbd Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Tue, 5 Sep 2017 17:17:04 -0700 Subject: [PATCH 219/370] Use canonicalized forms when comparing signatures --- src/compiler/checker.ts | 31 ++++++++++++++++++++++++++----- src/compiler/types.ts | 2 ++ 2 files changed, 28 insertions(+), 5 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index fa5441f6841..bf0d7655309 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -6632,11 +6632,31 @@ namespace ts { } function getErasedSignature(signature: Signature): Signature { - if (!signature.typeParameters) return signature; - if (!signature.erasedSignatureCache) { - signature.erasedSignatureCache = instantiateSignature(signature, createTypeEraser(signature.typeParameters), /*eraseTypeParameters*/ true); - } - return signature.erasedSignatureCache; + return signature.typeParameters ? + signature.erasedSignatureCache || (signature.erasedSignatureCache = createErasedSignature(signature)) : + signature; + } + + function createErasedSignature(signature: Signature) { + // Create an instantiation of the signature where all type arguments are the any type. + return instantiateSignature(signature, createTypeEraser(signature.typeParameters), /*eraseTypeParameters*/ true); + } + + function getCanonicalSignature(signature: Signature): Signature { + return signature.typeParameters ? + signature.canonicalSignatureCache || (signature.canonicalSignatureCache = createCanonicalSignature(signature)) : + signature; + } + + function createCanonicalSignature(signature: Signature) { + // Create an instantiation of the signature where each unconstrained type parameter is replaced with + // its original. When a generic class or interface is instantiated, each generic method in the class or + // interface is instantiated with a fresh set of cloned type parameters (which we need to handle scenarios + // where different generations of the same type parameter are in scope). This leads to a lot of new type + // identities, and potentially a lot of work comparing those identities, so here we create an instantiation + // that reverts back to the original type identities for all unconstrained type parameters. + const canonicalTypeArguments = map(signature.typeParameters, tp => tp.target && !getConstraintOfTypeParameter(tp.target) ? tp.target : tp); + return instantiateSignature(signature, createTypeMapper(signature.typeParameters, canonicalTypeArguments), /*eraseTypeParameters*/ true); } function getOrCreateTypeFromSignature(signature: Signature): ObjectType { @@ -8473,6 +8493,7 @@ namespace ts { return Ternary.False; } + target = getCanonicalSignature(target); if (source.typeParameters) { source = instantiateSignatureInContextOf(source, target, /*contextualMapper*/ undefined, compareTypes); } diff --git a/src/compiler/types.ts b/src/compiler/types.ts index e2d9977f302..9d5bbf5b08e 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -3447,6 +3447,8 @@ namespace ts { /* @internal */ erasedSignatureCache?: Signature; // Erased version of signature (deferred) /* @internal */ + canonicalSignatureCache?: Signature; // Canonical version of signature (deferred) + /* @internal */ isolatedSignatureType?: ObjectType; // A manufactured type that just contains the signature for purposes of signature comparison /* @internal */ typePredicate?: TypePredicate; From 482e802e83598da9bb3c02adb7af71cffa2331aa Mon Sep 17 00:00:00 2001 From: Andrew Casey Date: Tue, 5 Sep 2017 16:00:19 -0700 Subject: [PATCH 220/370] Limit the number of unanswered typings installer requests If we send them all at once, we (apparently) hit a buffer limit in the node IPC channel and both TS Server and the typings installer become unresponsive. --- src/server/server.ts | 62 ++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 57 insertions(+), 5 deletions(-) diff --git a/src/server/server.ts b/src/server/server.ts index f70e2d0faf7..7f6daa92d5e 100644 --- a/src/server/server.ts +++ b/src/server/server.ts @@ -236,25 +236,35 @@ namespace ts.server { return `${d.getHours()}:${d.getMinutes()}:${d.getSeconds()}.${d.getMilliseconds()}`; } + interface QueuedOperation { + operationId: string; + operation: () => void; + } + class NodeTypingsInstaller implements ITypingsInstaller { private installer: NodeChildProcess; private installerPidReported = false; private socket: NodeSocket; private projectService: ProjectService; - private throttledOperations: ThrottledOperations; private eventSender: EventSender; + private activeRequestCount = 0; + private requestQueue: QueuedOperation[] = []; + private requestMap = createMap(); // Maps operation ID to newest requestQueue entry with that ID + + private static readonly maxActiveRequestCount = 10; + private static readonly requestDelayMillis = 100; + constructor( private readonly telemetryEnabled: boolean, private readonly logger: server.Logger, - host: ServerHost, + private readonly host: ServerHost, eventPort: number, readonly globalTypingsCacheLocation: string, readonly typingSafeListLocation: string, readonly typesMapLocation: string, private readonly npmLocation: string | undefined, private newLine: string) { - this.throttledOperations = new ThrottledOperations(host); if (eventPort) { const s = net.connect({ port: eventPort }, () => { this.socket = s; @@ -338,12 +348,26 @@ namespace ts.server { this.logger.info(`Scheduling throttled operation: ${JSON.stringify(request)}`); } } - this.throttledOperations.schedule(project.getProjectName(), /*ms*/ 250, () => { + + const operationId = project.getProjectName(); + const operation = () => { if (this.logger.hasLevel(LogLevel.verbose)) { this.logger.info(`Sending request: ${JSON.stringify(request)}`); } this.installer.send(request); - }); + }; + const queuedRequest: QueuedOperation = { operationId, operation }; + + if (this.activeRequestCount < NodeTypingsInstaller.maxActiveRequestCount) { + this.scheduleRequest(queuedRequest); + } + else { + if (this.logger.hasLevel(LogLevel.verbose)) { + this.logger.info(`Deferring request for: ${operationId}`); + } + this.requestQueue.push(queuedRequest); + this.requestMap.set(operationId, queuedRequest); + } } private handleMessage(response: SetTypings | InvalidateCachedTypings | BeginInstallTypes | EndInstallTypes | InitializationFailedResponse) { @@ -404,11 +428,39 @@ namespace ts.server { return; } + if (this.activeRequestCount > 0) { + this.activeRequestCount--; + } + else { + Debug.fail("Received too many responses"); + } + + while (this.requestQueue.length > 0) { + const queuedRequest = this.requestQueue.shift(); + if (this.requestMap.get(queuedRequest.operationId) == queuedRequest) { + this.requestMap.delete(queuedRequest.operationId); + this.scheduleRequest(queuedRequest); + break; + } + + if (this.logger.hasLevel(LogLevel.verbose)) { + this.logger.info(`Skipping defunct request for: ${queuedRequest.operationId}`); + } + } + this.projectService.updateTypingsForProject(response); if (response.kind === ActionSet && this.socket) { this.sendEvent(0, "setTypings", response); } } + + private scheduleRequest(request: QueuedOperation) { + if(this.logger.hasLevel(LogLevel.verbose)) { + this.logger.info(`Scheduling request for: ${request.operationId}`); + } + this.activeRequestCount++; + this.host.setTimeout(request.operation, NodeTypingsInstaller.requestDelayMillis); + } } class IOSession extends Session { From be7be5955bcafc9b27359dca0083d46fd58b6bd7 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Wed, 6 Sep 2017 09:41:05 -0700 Subject: [PATCH 221/370] Make getJSDocTags public too --- src/compiler/utilities.ts | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index 78eacee7d22..1b19fc738e8 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -1502,16 +1502,7 @@ namespace ts { return getJSDocCommentsAndTags(node); } - export function getJSDocTags(node: Node): ReadonlyArray | undefined { - let tags = node.jsDocCache; - // If cache is 'null', that means we did the work of searching for JSDoc tags and came up with nothing. - if (tags === undefined) { - node.jsDocCache = tags = flatMap(getJSDocCommentsAndTags(node), j => isJSDoc(j) ? j.tags : j); - } - return tags; - } - - function getJSDocCommentsAndTags(node: Node): (JSDoc | JSDocTag)[] { + export function getJSDocCommentsAndTags(node: Node): (JSDoc | JSDocTag)[] { let result: Array | undefined; getJSDocCommentsAndTagsWorker(node); return result || emptyArray; @@ -4023,11 +4014,22 @@ namespace ts { return returnTag && returnTag.typeExpression && returnTag.typeExpression.type; } - /* Get the first JSDoc tag of a specified kind, or undefined if not present. */ + /** Get all JSDoc tags related to a node, including those on parent nodes. */ + export function getJSDocTags(node: Node): ReadonlyArray | undefined { + let tags = node.jsDocCache; + // If cache is 'null', that means we did the work of searching for JSDoc tags and came up with nothing. + if (tags === undefined) { + node.jsDocCache = tags = flatMap(getJSDocCommentsAndTags(node), j => isJSDoc(j) ? j.tags : j); + } + return tags; + } + + /** Get the first JSDoc tag of a specified kind, or undefined if not present. */ function getFirstJSDocTag(node: Node, kind: SyntaxKind): JSDocTag | undefined { const tags = getJSDocTags(node); return find(tags, doc => doc.kind === kind); } + } // Simple node tests of the form `node.kind === SyntaxKind.Foo`. From fc163300435e4dce17312fe5b7a74ade4d621afb Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Wed, 6 Sep 2017 09:48:00 -0700 Subject: [PATCH 222/370] Minor changes --- src/compiler/checker.ts | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index bf0d7655309..1bbd710e327 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -6654,9 +6654,8 @@ namespace ts { // interface is instantiated with a fresh set of cloned type parameters (which we need to handle scenarios // where different generations of the same type parameter are in scope). This leads to a lot of new type // identities, and potentially a lot of work comparing those identities, so here we create an instantiation - // that reverts back to the original type identities for all unconstrained type parameters. - const canonicalTypeArguments = map(signature.typeParameters, tp => tp.target && !getConstraintOfTypeParameter(tp.target) ? tp.target : tp); - return instantiateSignature(signature, createTypeMapper(signature.typeParameters, canonicalTypeArguments), /*eraseTypeParameters*/ true); + // that uses the original type identities for all unconstrained type parameters. + return getSignatureInstantiation(signature, map(signature.typeParameters, tp => tp.target && !getConstraintOfTypeParameter(tp.target) ? tp.target : tp)); } function getOrCreateTypeFromSignature(signature: Signature): ObjectType { @@ -8493,8 +8492,8 @@ namespace ts { return Ternary.False; } - target = getCanonicalSignature(target); - if (source.typeParameters) { + if (source.typeParameters && source.typeParameters !== target.typeParameters) { + target = getCanonicalSignature(target); source = instantiateSignatureInContextOf(source, target, /*contextualMapper*/ undefined, compareTypes); } From 0f73a0a2443573d7677aeb85145f317c2e8be9ca Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Wed, 6 Sep 2017 09:50:25 -0700 Subject: [PATCH 223/370] Fix jsdoc lint --- src/compiler/utilities.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index 1b19fc738e8..a6ae7925a53 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -4008,7 +4008,8 @@ namespace ts { * Gets the return type node for the node if provided via JSDoc's return tag. * * @remarks `getJSDocReturnTag` just gets the whole JSDoc tag. This function - * gets the type from inside the braces. */ + * gets the type from inside the braces. + */ export function getJSDocReturnType(node: Node): TypeNode | undefined { const returnTag = getJSDocReturnTag(node); return returnTag && returnTag.typeExpression && returnTag.typeExpression.type; From 8055e7f40b80edee4b66f73fa990bf5ba0aa5f4c Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Wed, 6 Sep 2017 10:13:34 -0700 Subject: [PATCH 224/370] Test new JSDoc surface area --- tests/baselines/reference/APISample_jsdoc.js | 212 +++++++++++++++++++ tests/cases/compiler/APISample_jsdoc.ts | 116 ++++++++++ 2 files changed, 328 insertions(+) create mode 100644 tests/baselines/reference/APISample_jsdoc.js create mode 100644 tests/cases/compiler/APISample_jsdoc.ts diff --git a/tests/baselines/reference/APISample_jsdoc.js b/tests/baselines/reference/APISample_jsdoc.js new file mode 100644 index 00000000000..c74e188f38b --- /dev/null +++ b/tests/baselines/reference/APISample_jsdoc.js @@ -0,0 +1,212 @@ +//// [APISample_jsdoc.ts] +/* + * Note: This test is a public API sample. The original sources can be found + * at: https://github.com/YousefED/typescript-json-schema + * https://github.com/vega/ts-json-schema-generator + * Please log a "breaking change" issue for any API breaking change affecting this issue + */ + +declare var console: any; + +import * as ts from "typescript"; + +// excerpted from https://github.com/YousefED/typescript-json-schema +// (converted from a method and modified; for example, `this: any` to compensate, among other changes) +function parseCommentsIntoDefinition(this: any, + symbol: ts.Symbol, + definition: {description?: string, [s: string]: string | undefined}, + otherAnnotations: { [s: string]: true}): void { + if (!symbol) { + return; + } + + // the comments for a symbol + let comments = symbol.getDocumentationComment(); + + if (comments.length) { + definition.description = comments.map(comment => comment.kind === "lineBreak" ? comment.text : comment.text.trim().replace(/\r\n/g, "\n")).join(""); + } + + // jsdocs are separate from comments + const jsdocs = symbol.getJsDocTags(); + jsdocs.forEach(doc => { + // if we have @TJS-... annotations, we have to parse them + const { name, text } = doc; + if (this.userValidationKeywords[name]) { + definition[name] = this.parseValue(text); + } else { + // special annotations + otherAnnotations[doc.name] = true; + } + }); +} + + +// excerpted from https://github.com/vega/ts-json-schema-generator +export interface Annotations { + [name: string]: any; +} +function getAnnotations(this: any, node: ts.Node): Annotations | undefined { + const symbol: ts.Symbol = (node as any).symbol; + if (!symbol) { + return undefined; + } + + const jsDocTags: ts.JSDocTagInfo[] = symbol.getJsDocTags(); + if (!jsDocTags || !jsDocTags.length) { + return undefined; + } + + const annotations: Annotations = jsDocTags.reduce((result: Annotations, jsDocTag: ts.JSDocTagInfo) => { + const value = this.parseJsDocTag(jsDocTag); + if (value !== undefined) { + result[jsDocTag.name] = value; + } + + return result; + }, {}); + return Object.keys(annotations).length ? annotations : undefined; +} + +// these examples are artificial and mostly nonsensical +function parseSpecificTags(node: ts.Node) { + if (node.kind === ts.SyntaxKind.Parameter) { + return ts.getJSDocParameterTags(node as ts.ParameterDeclaration); + } + if (node.kind === ts.SyntaxKind.FunctionDeclaration) { + const func = node as ts.FunctionDeclaration; + if (ts.hasJSDocParameterTags(func)) { + const flat: ts.JSDocTag[] = []; + for (const tags of func.parameters.map(ts.getJSDocParameterTags)) { + if (tags) flat.push(...tags); + } + return flat; + } + } +} + +function getReturnTypeFromJSDoc(node: ts.Node) { + if (node.kind === ts.SyntaxKind.FunctionDeclaration) { + return ts.getJSDocReturnType(node); + } + let type = ts.getJSDocType(node); + if (type && type.kind === ts.SyntaxKind.FunctionType) { + return (type as ts.FunctionTypeNode).type; + } +} + +function getAllTags(node: ts.Node) { + ts.getJSDocTags(node); +} + +function getSomeOtherTags(node: ts.Node) { + const tags: (ts.JSDocTag | undefined)[] = []; + tags.push(ts.getJSDocAugmentsTag(node)); + tags.push(ts.getJSDocClassTag(node)); + tags.push(ts.getJSDocReturnTag(node)); + const type = ts.getJSDocTypeTag(node); + if (type) { + tags.push(type); + } + tags.push(ts.getJSDocTemplateTag(node)); + return tags; +} + + +//// [APISample_jsdoc.js] +"use strict"; +/* + * Note: This test is a public API sample. The original sources can be found + * at: https://github.com/YousefED/typescript-json-schema + * https://github.com/vega/ts-json-schema-generator + * Please log a "breaking change" issue for any API breaking change affecting this issue + */ +exports.__esModule = true; +var ts = require("typescript"); +// excerpted from https://github.com/YousefED/typescript-json-schema +// (converted from a method and modified; for example, `this: any` to compensate, among other changes) +function parseCommentsIntoDefinition(symbol, definition, otherAnnotations) { + var _this = this; + if (!symbol) { + return; + } + // the comments for a symbol + var comments = symbol.getDocumentationComment(); + if (comments.length) { + definition.description = comments.map(function (comment) { return comment.kind === "lineBreak" ? comment.text : comment.text.trim().replace(/\r\n/g, "\n"); }).join(""); + } + // jsdocs are separate from comments + var jsdocs = symbol.getJsDocTags(); + jsdocs.forEach(function (doc) { + // if we have @TJS-... annotations, we have to parse them + var name = doc.name, text = doc.text; + if (_this.userValidationKeywords[name]) { + definition[name] = _this.parseValue(text); + } + else { + // special annotations + otherAnnotations[doc.name] = true; + } + }); +} +function getAnnotations(node) { + var _this = this; + var symbol = node.symbol; + if (!symbol) { + return undefined; + } + var jsDocTags = symbol.getJsDocTags(); + if (!jsDocTags || !jsDocTags.length) { + return undefined; + } + var annotations = jsDocTags.reduce(function (result, jsDocTag) { + var value = _this.parseJsDocTag(jsDocTag); + if (value !== undefined) { + result[jsDocTag.name] = value; + } + return result; + }, {}); + return Object.keys(annotations).length ? annotations : undefined; +} +// these examples are artificial and mostly nonsensical +function parseSpecificTags(node) { + if (node.kind === ts.SyntaxKind.Parameter) { + return ts.getJSDocParameterTags(node); + } + if (node.kind === ts.SyntaxKind.FunctionDeclaration) { + var func = node; + if (ts.hasJSDocParameterTags(func)) { + var flat = []; + for (var _i = 0, _a = func.parameters.map(ts.getJSDocParameterTags); _i < _a.length; _i++) { + var tags = _a[_i]; + if (tags) + flat.push.apply(flat, tags); + } + return flat; + } + } +} +function getReturnTypeFromJSDoc(node) { + if (node.kind === ts.SyntaxKind.FunctionDeclaration) { + return ts.getJSDocReturnType(node); + } + var type = ts.getJSDocType(node); + if (type && type.kind === ts.SyntaxKind.FunctionType) { + return type.type; + } +} +function getAllTags(node) { + ts.getJSDocTags(node); +} +function getSomeOtherTags(node) { + var tags = []; + tags.push(ts.getJSDocAugmentsTag(node)); + tags.push(ts.getJSDocClassTag(node)); + tags.push(ts.getJSDocReturnTag(node)); + var type = ts.getJSDocTypeTag(node); + if (type) { + tags.push(type); + } + tags.push(ts.getJSDocTemplateTag(node)); + return tags; +} diff --git a/tests/cases/compiler/APISample_jsdoc.ts b/tests/cases/compiler/APISample_jsdoc.ts new file mode 100644 index 00000000000..70b814ffff4 --- /dev/null +++ b/tests/cases/compiler/APISample_jsdoc.ts @@ -0,0 +1,116 @@ +// @module: commonjs +// @includebuiltfile: typescript_standalone.d.ts +// @strict:true + +/* + * Note: This test is a public API sample. The original sources can be found + * at: https://github.com/YousefED/typescript-json-schema + * https://github.com/vega/ts-json-schema-generator + * Please log a "breaking change" issue for any API breaking change affecting this issue + */ + +declare var console: any; + +import * as ts from "typescript"; + +// excerpted from https://github.com/YousefED/typescript-json-schema +// (converted from a method and modified; for example, `this: any` to compensate, among other changes) +function parseCommentsIntoDefinition(this: any, + symbol: ts.Symbol, + definition: {description?: string, [s: string]: string | undefined}, + otherAnnotations: { [s: string]: true}): void { + if (!symbol) { + return; + } + + // the comments for a symbol + let comments = symbol.getDocumentationComment(); + + if (comments.length) { + definition.description = comments.map(comment => comment.kind === "lineBreak" ? comment.text : comment.text.trim().replace(/\r\n/g, "\n")).join(""); + } + + // jsdocs are separate from comments + const jsdocs = symbol.getJsDocTags(); + jsdocs.forEach(doc => { + // if we have @TJS-... annotations, we have to parse them + const { name, text } = doc; + if (this.userValidationKeywords[name]) { + definition[name] = this.parseValue(text); + } else { + // special annotations + otherAnnotations[doc.name] = true; + } + }); +} + + +// excerpted from https://github.com/vega/ts-json-schema-generator +export interface Annotations { + [name: string]: any; +} +function getAnnotations(this: any, node: ts.Node): Annotations | undefined { + const symbol: ts.Symbol = (node as any).symbol; + if (!symbol) { + return undefined; + } + + const jsDocTags: ts.JSDocTagInfo[] = symbol.getJsDocTags(); + if (!jsDocTags || !jsDocTags.length) { + return undefined; + } + + const annotations: Annotations = jsDocTags.reduce((result: Annotations, jsDocTag: ts.JSDocTagInfo) => { + const value = this.parseJsDocTag(jsDocTag); + if (value !== undefined) { + result[jsDocTag.name] = value; + } + + return result; + }, {}); + return Object.keys(annotations).length ? annotations : undefined; +} + +// these examples are artificial and mostly nonsensical +function parseSpecificTags(node: ts.Node) { + if (node.kind === ts.SyntaxKind.Parameter) { + return ts.getJSDocParameterTags(node as ts.ParameterDeclaration); + } + if (node.kind === ts.SyntaxKind.FunctionDeclaration) { + const func = node as ts.FunctionDeclaration; + if (ts.hasJSDocParameterTags(func)) { + const flat: ts.JSDocTag[] = []; + for (const tags of func.parameters.map(ts.getJSDocParameterTags)) { + if (tags) flat.push(...tags); + } + return flat; + } + } +} + +function getReturnTypeFromJSDoc(node: ts.Node) { + if (node.kind === ts.SyntaxKind.FunctionDeclaration) { + return ts.getJSDocReturnType(node); + } + let type = ts.getJSDocType(node); + if (type && type.kind === ts.SyntaxKind.FunctionType) { + return (type as ts.FunctionTypeNode).type; + } +} + +function getAllTags(node: ts.Node) { + ts.getJSDocTags(node); +} + +function getSomeOtherTags(node: ts.Node) { + const tags: (ts.JSDocTag | undefined)[] = []; + tags.push(ts.getJSDocAugmentsTag(node)); + tags.push(ts.getJSDocClassTag(node)); + tags.push(ts.getJSDocReturnTag(node)); + const type = ts.getJSDocTypeTag(node); + if (type) { + tags.push(type); + } + tags.push(ts.getJSDocTemplateTag(node)); + return tags; +} From 7c69dd84b9996d631cd0ad47bf97a496dec18b17 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Wed, 6 Sep 2017 13:11:35 -0700 Subject: [PATCH 225/370] Disable lookahead in isStartOfParameter/isStartOfType --- src/compiler/core.ts | 2 +- src/compiler/parser.ts | 15 +++++++++++---- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/src/compiler/core.ts b/src/compiler/core.ts index 20f757c3df8..a9138e0ab5c 100644 --- a/src/compiler/core.ts +++ b/src/compiler/core.ts @@ -1283,7 +1283,7 @@ namespace ts { args[i] = arguments[i]; } - return t => reduceLeft<(t: T) => T, T>(args, (u, f) => f(u), t); + return t => reduceLeft(args, (u, f) => f(u), t); } else if (d) { return t => d(c(b(a(t)))); diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index 71c7d3aac49..e4847517252 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -2237,7 +2237,14 @@ namespace ts { return token() === SyntaxKind.DotDotDotToken || isIdentifierOrPattern() || isModifierKind(token()) || - token() === SyntaxKind.AtToken || isStartOfType(); + token() === SyntaxKind.AtToken || + // a jsdoc parameter can start directly with a type, but shouldn't look ahead + // in order to avoid confusion between parenthesized types and arrow functions + // eg + // declare function f(cb: function(number): void): void; + // vs + // f((n) => console.log(n)); + isStartOfType(/*disableLookahead*/ true); } function parseParameter(): ParameterDeclaration { @@ -2698,7 +2705,7 @@ namespace ts { } } - function isStartOfType(): boolean { + function isStartOfType(disableLookahead?: boolean): boolean { switch (token()) { case SyntaxKind.AnyKeyword: case SyntaxKind.StringKeyword: @@ -2728,11 +2735,11 @@ namespace ts { case SyntaxKind.DotDotDotToken: return true; case SyntaxKind.MinusToken: - return lookAhead(nextTokenIsNumericLiteral); + return !disableLookahead && lookAhead(nextTokenIsNumericLiteral); case SyntaxKind.OpenParenToken: // Only consider '(' the start of a type if followed by ')', '...', an identifier, a modifier, // or something that starts a type. We don't want to consider things like '(1)' a type. - return lookAhead(isStartOfParenthesizedOrFunctionType); + return !disableLookahead && lookAhead(isStartOfParenthesizedOrFunctionType); default: return isIdentifier(); } From 36607e1bde77ba57bb09023ded321f18516abaf5 Mon Sep 17 00:00:00 2001 From: Andy Date: Wed, 6 Sep 2017 14:39:53 -0700 Subject: [PATCH 226/370] Allow quoted names in completions (#18162) * Allow quoted names in completions * Don't allow string literal completions if not in an object literal; and use string literals for number keys * Add TODO --- src/harness/fourslash.ts | 14 ++++-- src/services/completions.ts | 46 +++++++++++-------- ...nForQuotedPropertyInPropertyAssignment1.ts | 11 +---- ...nForQuotedPropertyInPropertyAssignment2.ts | 11 +---- ...nForQuotedPropertyInPropertyAssignment3.ts | 15 ++---- .../completionListInvalidMemberNames.ts | 15 ++---- .../completionListInvalidMemberNames2.ts | 9 ++-- ...entifiers-should-not-show-in-completion.ts | 10 +--- tests/cases/fourslash/fourslash.ts | 2 +- 9 files changed, 57 insertions(+), 76 deletions(-) diff --git a/src/harness/fourslash.ts b/src/harness/fourslash.ts index 3010fc53533..c224fd210ea 100644 --- a/src/harness/fourslash.ts +++ b/src/harness/fourslash.ts @@ -762,7 +762,7 @@ namespace FourSlash { } } - public verifyCompletionsAt(markerName: string, expected: string[]) { + public verifyCompletionsAt(markerName: string, expected: string[], options?: FourSlashInterface.CompletionsAtOptions) { this.goToMarker(markerName); const actualCompletions = this.getCompletionListAtCaret(); @@ -770,6 +770,10 @@ namespace FourSlash { this.raiseError(`No completions at position '${this.currentCaretPosition}'.`); } + if (options && options.isNewIdentifierLocation !== undefined && actualCompletions.isNewIdentifierLocation !== options.isNewIdentifierLocation) { + this.raiseError(`Expected 'isNewIdentifierLocation' to be ${options.isNewIdentifierLocation}, got ${actualCompletions.isNewIdentifierLocation}`); + } + const actual = actualCompletions.entries; if (actual.length !== expected.length) { @@ -3705,8 +3709,8 @@ namespace FourSlashInterface { super(state); } - public completionsAt(markerName: string, completions: string[]) { - this.state.verifyCompletionsAt(markerName, completions); + public completionsAt(markerName: string, completions: string[], options?: CompletionsAtOptions) { + this.state.verifyCompletionsAt(markerName, completions, options); } public quickInfoIs(expectedText: string, expectedDocumentation?: string) { @@ -4314,4 +4318,8 @@ namespace FourSlashInterface { actionName: string; actionDescription: string; } + + export interface CompletionsAtOptions { + isNewIdentifierLocation?: boolean; + } } diff --git a/src/services/completions.ts b/src/services/completions.ts index fde07aa78f6..300ade2da48 100644 --- a/src/services/completions.ts +++ b/src/services/completions.ts @@ -24,7 +24,7 @@ namespace ts.Completions { return undefined; } - const { symbols, isGlobalCompletion, isMemberCompletion, isNewIdentifierLocation, location, request, keywordFilters } = completionData; + const { symbols, isGlobalCompletion, isMemberCompletion, allowStringLiteral, isNewIdentifierLocation, location, request, keywordFilters } = completionData; if (sourceFile.languageVariant === LanguageVariant.JSX && location && location.parent && location.parent.kind === SyntaxKind.JsxClosingElement) { @@ -56,7 +56,7 @@ namespace ts.Completions { const entries: CompletionEntry[] = []; if (isSourceFileJavaScript(sourceFile)) { - const uniqueNames = getCompletionEntriesFromSymbols(symbols, entries, location, /*performCharacterChecks*/ true, typeChecker, compilerOptions.target, log); + const uniqueNames = getCompletionEntriesFromSymbols(symbols, entries, location, /*performCharacterChecks*/ true, typeChecker, compilerOptions.target, log, allowStringLiteral); getJavaScriptCompletionEntries(sourceFile, location.pos, uniqueNames, compilerOptions.target, entries); } else { @@ -64,7 +64,7 @@ namespace ts.Completions { return undefined; } - getCompletionEntriesFromSymbols(symbols, entries, location, /*performCharacterChecks*/ true, typeChecker, compilerOptions.target, log); + getCompletionEntriesFromSymbols(symbols, entries, location, /*performCharacterChecks*/ true, typeChecker, compilerOptions.target, log, allowStringLiteral); } // TODO add filter for keyword based on type/value/namespace and also location @@ -97,7 +97,7 @@ namespace ts.Completions { } uniqueNames.set(realName, true); - const displayName = getCompletionEntryDisplayName(realName, target, /*performCharacterChecks*/ true); + const displayName = getCompletionEntryDisplayName(realName, target, /*performCharacterChecks*/ true, /*allowStringLiteral*/ false); if (displayName) { entries.push({ name: displayName, @@ -109,11 +109,11 @@ namespace ts.Completions { }); } - function createCompletionEntry(symbol: Symbol, location: Node, performCharacterChecks: boolean, typeChecker: TypeChecker, target: ScriptTarget): CompletionEntry { + function createCompletionEntry(symbol: Symbol, location: Node, performCharacterChecks: boolean, typeChecker: TypeChecker, target: ScriptTarget, allowStringLiteral: boolean): CompletionEntry { // Try to get a valid display name for this symbol, if we could not find one, then ignore it. // We would like to only show things that can be added after a dot, so for instance numeric properties can // not be accessed with a dot (a.1 <- invalid) - const displayName = getCompletionEntryDisplayNameForSymbol(symbol, target, performCharacterChecks); + const displayName = getCompletionEntryDisplayNameForSymbol(symbol, target, performCharacterChecks, allowStringLiteral); if (!displayName) { return undefined; } @@ -134,12 +134,12 @@ namespace ts.Completions { }; } - function getCompletionEntriesFromSymbols(symbols: Symbol[], entries: Push, location: Node, performCharacterChecks: boolean, typeChecker: TypeChecker, target: ScriptTarget, log: Log): Map { + function getCompletionEntriesFromSymbols(symbols: Symbol[], entries: Push, location: Node, performCharacterChecks: boolean, typeChecker: TypeChecker, target: ScriptTarget, log: Log, allowStringLiteral: boolean): Map { const start = timestamp(); const uniqueNames = createMap(); if (symbols) { for (const symbol of symbols) { - const entry = createCompletionEntry(symbol, location, performCharacterChecks, typeChecker, target); + const entry = createCompletionEntry(symbol, location, performCharacterChecks, typeChecker, target, allowStringLiteral); if (entry) { const id = entry.name; if (!uniqueNames.has(id)) { @@ -224,7 +224,7 @@ namespace ts.Completions { const type = typeChecker.getContextualType((element.parent)); const entries: CompletionEntry[] = []; if (type) { - getCompletionEntriesFromSymbols(type.getApparentProperties(), entries, element, /*performCharacterChecks*/ false, typeChecker, target, log); + getCompletionEntriesFromSymbols(type.getApparentProperties(), entries, element, /*performCharacterChecks*/ false, typeChecker, target, log, /*allowStringLiteral*/ true); if (entries.length) { return { isGlobalCompletion: false, isMemberCompletion: true, isNewIdentifierLocation: true, entries }; } @@ -253,7 +253,7 @@ namespace ts.Completions { const type = typeChecker.getTypeAtLocation(node.expression); const entries: CompletionEntry[] = []; if (type) { - getCompletionEntriesFromSymbols(type.getApparentProperties(), entries, node, /*performCharacterChecks*/ false, typeChecker, target, log); + getCompletionEntriesFromSymbols(type.getApparentProperties(), entries, node, /*performCharacterChecks*/ false, typeChecker, target, log, /*allowStringLiteral*/ true); if (entries.length) { return { isGlobalCompletion: false, isMemberCompletion: true, isNewIdentifierLocation: true, entries }; } @@ -302,13 +302,13 @@ namespace ts.Completions { // Compute all the completion symbols again. const completionData = getCompletionData(typeChecker, log, sourceFile, position); if (completionData) { - const { symbols, location } = completionData; + const { symbols, location, allowStringLiteral } = completionData; // Find the symbol with the matching entry name. // We don't need to perform character checks here because we're only comparing the // name against 'entryName' (which is known to be good), not building a new // completion entry. - const symbol = forEach(symbols, s => getCompletionEntryDisplayNameForSymbol(s, compilerOptions.target, /*performCharacterChecks*/ false) === entryName ? s : undefined); + const symbol = forEach(symbols, s => getCompletionEntryDisplayNameForSymbol(s, compilerOptions.target, /*performCharacterChecks*/ false, allowStringLiteral) === entryName ? s : undefined); if (symbol) { const { displayParts, documentation, symbolKind, tags } = SymbolDisplay.getSymbolDisplayPartsDocumentationAndSymbolKind(typeChecker, symbol, sourceFile, location, location, SemanticMeaning.All); @@ -345,17 +345,22 @@ namespace ts.Completions { export function getCompletionEntrySymbol(typeChecker: TypeChecker, log: (message: string) => void, compilerOptions: CompilerOptions, sourceFile: SourceFile, position: number, entryName: string): Symbol | undefined { // Compute all the completion symbols again. const completionData = getCompletionData(typeChecker, log, sourceFile, position); + if (!completionData) { + return undefined; + } + const { symbols, allowStringLiteral } = completionData; // Find the symbol with the matching entry name. // We don't need to perform character checks here because we're only comparing the // name against 'entryName' (which is known to be good), not building a new // completion entry. - return completionData && forEach(completionData.symbols, s => getCompletionEntryDisplayNameForSymbol(s, compilerOptions.target, /*performCharacterChecks*/ false) === entryName ? s : undefined); + return forEach(symbols, s => getCompletionEntryDisplayNameForSymbol(s, compilerOptions.target, /*performCharacterChecks*/ false, allowStringLiteral) === entryName ? s : undefined); } interface CompletionData { symbols: Symbol[]; isGlobalCompletion: boolean; isMemberCompletion: boolean; + allowStringLiteral: boolean; isNewIdentifierLocation: boolean; location: Node; isRightOfDot: boolean; @@ -436,7 +441,7 @@ namespace ts.Completions { } if (request) { - return { symbols: undefined, isGlobalCompletion: false, isMemberCompletion: false, isNewIdentifierLocation: false, location: undefined, isRightOfDot: false, request, keywordFilters: KeywordCompletionFilters.None }; + return { symbols: undefined, isGlobalCompletion: false, isMemberCompletion: false, allowStringLiteral: false, isNewIdentifierLocation: false, location: undefined, isRightOfDot: false, request, keywordFilters: KeywordCompletionFilters.None }; } if (!insideJsDocTagTypeExpression) { @@ -534,6 +539,7 @@ namespace ts.Completions { const semanticStart = timestamp(); let isGlobalCompletion = false; let isMemberCompletion: boolean; + let allowStringLiteral = false; let isNewIdentifierLocation: boolean; let keywordFilters = KeywordCompletionFilters.None; let symbols: Symbol[] = []; @@ -573,7 +579,7 @@ namespace ts.Completions { log("getCompletionData: Semantic work: " + (timestamp() - semanticStart)); - return { symbols, isGlobalCompletion, isMemberCompletion, isNewIdentifierLocation, location, isRightOfDot: (isRightOfDot || isRightOfOpenTag), request, keywordFilters }; + return { symbols, isGlobalCompletion, isMemberCompletion, allowStringLiteral, isNewIdentifierLocation, location, isRightOfDot: (isRightOfDot || isRightOfOpenTag), request, keywordFilters }; type JSDocTagWithTypeExpression = JSDocAugmentsTag | JSDocParameterTag | JSDocPropertyTag | JSDocReturnTag | JSDocTypeTag | JSDocTypedefTag; @@ -961,6 +967,7 @@ namespace ts.Completions { function tryGetObjectLikeCompletionSymbols(objectLikeContainer: ObjectLiteralExpression | ObjectBindingPattern): boolean { // We're looking up possible property names from contextual/inferred/declared type. isMemberCompletion = true; + allowStringLiteral = true; let typeMembers: Symbol[]; let existingMembers: ReadonlyArray; @@ -1609,7 +1616,7 @@ namespace ts.Completions { * * @return undefined if the name is of external module */ - function getCompletionEntryDisplayNameForSymbol(symbol: Symbol, target: ScriptTarget, performCharacterChecks: boolean): string | undefined { + function getCompletionEntryDisplayNameForSymbol(symbol: Symbol, target: ScriptTarget, performCharacterChecks: boolean, allowStringLiteral: boolean): string | undefined { const name = symbol.name; if (!name) return undefined; @@ -1623,20 +1630,21 @@ namespace ts.Completions { } } - return getCompletionEntryDisplayName(name, target, performCharacterChecks); + return getCompletionEntryDisplayName(name, target, performCharacterChecks, allowStringLiteral); } /** * Get a displayName from a given for completion list, performing any necessary quotes stripping * and checking whether the name is valid identifier name. */ - function getCompletionEntryDisplayName(name: string, target: ScriptTarget, performCharacterChecks: boolean): string { + function getCompletionEntryDisplayName(name: string, target: ScriptTarget, performCharacterChecks: boolean, allowStringLiteral: boolean): string { // If the user entered name for the symbol was quoted, removing the quotes is not enough, as the name could be an // invalid identifier name. We need to check if whatever was inside the quotes is actually a valid identifier name. // e.g "b a" is valid quoted name but when we strip off the quotes, it is invalid. // We, thus, need to check if whatever was inside the quotes is actually a valid identifier name. if (performCharacterChecks && !isIdentifierText(name, target)) { - return undefined; + // TODO: GH#18169 + return allowStringLiteral ? JSON.stringify(name) : undefined; } return name; diff --git a/tests/cases/fourslash/completionForQuotedPropertyInPropertyAssignment1.ts b/tests/cases/fourslash/completionForQuotedPropertyInPropertyAssignment1.ts index 15f5901113b..ab218cea93d 100644 --- a/tests/cases/fourslash/completionForQuotedPropertyInPropertyAssignment1.ts +++ b/tests/cases/fourslash/completionForQuotedPropertyInPropertyAssignment1.ts @@ -13,12 +13,5 @@ //// '/*1*/': '' //// } -goTo.marker('0'); -verify.completionListContains("jspm"); -verify.completionListAllowsNewIdentifier(); -verify.completionListCount(1); - -goTo.marker('1'); -verify.completionListContains("jspm:dev"); -verify.completionListAllowsNewIdentifier(); -verify.completionListCount(4); +verify.completionsAt("0", ["jspm", '"jspm:browser"', '"jspm:dev"', '"jspm:node"'], { isNewIdentifierLocation: true }); +verify.completionsAt("1", ["jspm", "jspm:browser", "jspm:dev", "jspm:node"], { isNewIdentifierLocation: true }); diff --git a/tests/cases/fourslash/completionForQuotedPropertyInPropertyAssignment2.ts b/tests/cases/fourslash/completionForQuotedPropertyInPropertyAssignment2.ts index 1d20b57e2a1..66ba4ada241 100644 --- a/tests/cases/fourslash/completionForQuotedPropertyInPropertyAssignment2.ts +++ b/tests/cases/fourslash/completionForQuotedPropertyInPropertyAssignment2.ts @@ -19,12 +19,5 @@ //// } //// } -goTo.marker('0'); -verify.completionListContains("jspm"); -verify.completionListAllowsNewIdentifier(); -verify.completionListCount(1); - -goTo.marker('1'); -verify.completionListContains("jspm:dev"); -verify.completionListAllowsNewIdentifier(); -verify.completionListCount(4); +verify.completionsAt("0", ["jspm", '"jspm:browser"', '"jspm:dev"', '"jspm:node"'], { isNewIdentifierLocation: true }); +verify.completionsAt("1", ["jspm", "jspm:browser", "jspm:dev", "jspm:node"], { isNewIdentifierLocation: true }); diff --git a/tests/cases/fourslash/completionForQuotedPropertyInPropertyAssignment3.ts b/tests/cases/fourslash/completionForQuotedPropertyInPropertyAssignment3.ts index 764011d90c1..1ab9aa4a8cf 100644 --- a/tests/cases/fourslash/completionForQuotedPropertyInPropertyAssignment3.ts +++ b/tests/cases/fourslash/completionForQuotedPropertyInPropertyAssignment3.ts @@ -4,7 +4,7 @@ //// jspm: string; //// 'jspm:browser': string; //// } = { -//// /*0*/: "", +//// /*0*/: "", //// } //// let configFiles2: { @@ -12,15 +12,8 @@ //// 'jspm:browser': string; //// } = { //// jspm: "", -//// '/*1*/': "" +//// '/*1*/': "" //// } -goTo.marker('0'); -verify.completionListContains("jspm"); -verify.completionListAllowsNewIdentifier(); -verify.completionListCount(1); - -goTo.marker('1'); -verify.completionListContains("jspm:browser"); -verify.completionListAllowsNewIdentifier(); -verify.completionListCount(2); +verify.completionsAt("0", ["jspm", '"jspm:browser"'], { isNewIdentifierLocation: true }); +verify.completionsAt("1", ["jspm", "jspm:browser"], { isNewIdentifierLocation: true }); diff --git a/tests/cases/fourslash/completionListInvalidMemberNames.ts b/tests/cases/fourslash/completionListInvalidMemberNames.ts index e0a65bfca4d..8e62ba2fb67 100644 --- a/tests/cases/fourslash/completionListInvalidMemberNames.ts +++ b/tests/cases/fourslash/completionListInvalidMemberNames.ts @@ -11,15 +11,8 @@ //// "\u0031\u0062": "invalid unicode identifer name (1b)" ////}; //// -////x./**/ +////x./*a*/; +////x["/*b*/"]; -goTo.marker(); - -verify.completionListContains("bar"); -verify.completionListContains("break"); -verify.completionListContains("any"); -verify.completionListContains("$"); -verify.completionListContains("b"); - -// Nothing else should show up -verify.completionListCount(5); +verify.completionsAt("a", ["bar", "break", "any", "$", "b"]); +verify.completionsAt("b", ["foo ", "bar", "break", "any", "#", "$", "b", "\u0031\u0062"]); diff --git a/tests/cases/fourslash/completionListInvalidMemberNames2.ts b/tests/cases/fourslash/completionListInvalidMemberNames2.ts index 6b25cf1f5d9..753f9bbcb30 100644 --- a/tests/cases/fourslash/completionListInvalidMemberNames2.ts +++ b/tests/cases/fourslash/completionListInvalidMemberNames2.ts @@ -3,9 +3,8 @@ ////enum Foo { //// X, Y, '☆' ////} -////var x = Foo./**/ +////Foo./*a*/; +////Foo["/*b*/"]; -goTo.marker(); -verify.completionListContains("X"); -verify.completionListContains("Y"); -verify.completionListCount(2); \ No newline at end of file +verify.completionsAt("a", ["X", "Y"]); +verify.completionsAt("b", ["X", "Y", "☆"]); diff --git a/tests/cases/fourslash/completion_enum-members-with-invalid-identifiers-should-not-show-in-completion.ts b/tests/cases/fourslash/completion_enum-members-with-invalid-identifiers-should-not-show-in-completion.ts index d01856a54fb..6d5b3167198 100644 --- a/tests/cases/fourslash/completion_enum-members-with-invalid-identifiers-should-not-show-in-completion.ts +++ b/tests/cases/fourslash/completion_enum-members-with-invalid-identifiers-should-not-show-in-completion.ts @@ -7,13 +7,7 @@ //// a, //// b //// } -//// +//// //// e./**/ -goTo.marker(); -verify.not.completionListContains('1'); -verify.not.completionListContains('"1"'); -verify.not.completionListContains('2'); -verify.not.completionListContains('3'); -verify.completionListContains('a'); -verify.completionListContains('b'); \ No newline at end of file +verify.completionsAt("", ["a", "b"]); diff --git a/tests/cases/fourslash/fourslash.ts b/tests/cases/fourslash/fourslash.ts index 652ed4812c0..5150fa16ae9 100644 --- a/tests/cases/fourslash/fourslash.ts +++ b/tests/cases/fourslash/fourslash.ts @@ -164,7 +164,7 @@ declare namespace FourSlashInterface { class verify extends verifyNegatable { assertHasRanges(ranges: Range[]): void; caretAtMarker(markerName?: string): void; - completionsAt(markerName: string, completions: string[]): void; + completionsAt(markerName: string, completions: string[], options?: { isNewIdentifierLocation?: boolean }): void; indentationIs(numberOfSpaces: number): void; indentationAtPositionIs(fileName: string, position: number, numberOfSpaces: number, indentStyle?: ts.IndentStyle, baseIndentSize?: number): void; textAtCaretIs(text: string): void; From 73eff819b589c9a8fdf0e9e866221fa15fe3f885 Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Wed, 6 Sep 2017 14:44:29 -0700 Subject: [PATCH 227/370] Fix 18224 (#18259) * Probably fix 18224 * Corrected test --- src/compiler/checker.ts | 2 +- tests/baselines/reference/jsdocTypecastNoTypeNoCrash.js | 8 ++++++++ .../reference/jsdocTypecastNoTypeNoCrash.symbols | 8 ++++++++ .../baselines/reference/jsdocTypecastNoTypeNoCrash.types | 9 +++++++++ tests/cases/compiler/jsdocTypecastNoTypeNoCrash.ts | 5 +++++ 5 files changed, 31 insertions(+), 1 deletion(-) create mode 100644 tests/baselines/reference/jsdocTypecastNoTypeNoCrash.js create mode 100644 tests/baselines/reference/jsdocTypecastNoTypeNoCrash.symbols create mode 100644 tests/baselines/reference/jsdocTypecastNoTypeNoCrash.types create mode 100644 tests/cases/compiler/jsdocTypecastNoTypeNoCrash.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 1bbd710e327..9fcd0b593f8 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -18017,7 +18017,7 @@ namespace ts { function checkParenthesizedExpression(node: ParenthesizedExpression, checkMode?: CheckMode): Type { if (isInJavaScriptFile(node) && node.jsDoc) { - const typecasts = flatMap(node.jsDoc, doc => filter(doc.tags, tag => tag.kind === SyntaxKind.JSDocTypeTag)); + const typecasts = flatMap(node.jsDoc, doc => filter(doc.tags, tag => tag.kind === SyntaxKind.JSDocTypeTag && !!(tag as JSDocTypeTag).typeExpression && !!(tag as JSDocTypeTag).typeExpression.type)); if (typecasts && typecasts.length) { // We should have already issued an error if there were multiple type jsdocs const cast = typecasts[0] as JSDocTypeTag; diff --git a/tests/baselines/reference/jsdocTypecastNoTypeNoCrash.js b/tests/baselines/reference/jsdocTypecastNoTypeNoCrash.js new file mode 100644 index 00000000000..06c7924440b --- /dev/null +++ b/tests/baselines/reference/jsdocTypecastNoTypeNoCrash.js @@ -0,0 +1,8 @@ +//// [index.js] +function Foo() {} +const a = /* @type string */(Foo); + + +//// [index.js] +function Foo() { } +var a = (Foo); diff --git a/tests/baselines/reference/jsdocTypecastNoTypeNoCrash.symbols b/tests/baselines/reference/jsdocTypecastNoTypeNoCrash.symbols new file mode 100644 index 00000000000..7a9d98e39ec --- /dev/null +++ b/tests/baselines/reference/jsdocTypecastNoTypeNoCrash.symbols @@ -0,0 +1,8 @@ +=== tests/cases/compiler/index.js === +function Foo() {} +>Foo : Symbol(Foo, Decl(index.js, 0, 0)) + +const a = /* @type string */(Foo); +>a : Symbol(a, Decl(index.js, 1, 5)) +>Foo : Symbol(Foo, Decl(index.js, 0, 0)) + diff --git a/tests/baselines/reference/jsdocTypecastNoTypeNoCrash.types b/tests/baselines/reference/jsdocTypecastNoTypeNoCrash.types new file mode 100644 index 00000000000..590940b51ff --- /dev/null +++ b/tests/baselines/reference/jsdocTypecastNoTypeNoCrash.types @@ -0,0 +1,9 @@ +=== tests/cases/compiler/index.js === +function Foo() {} +>Foo : () => void + +const a = /* @type string */(Foo); +>a : () => void +>(Foo) : () => void +>Foo : () => void + diff --git a/tests/cases/compiler/jsdocTypecastNoTypeNoCrash.ts b/tests/cases/compiler/jsdocTypecastNoTypeNoCrash.ts new file mode 100644 index 00000000000..8c5e52d34f0 --- /dev/null +++ b/tests/cases/compiler/jsdocTypecastNoTypeNoCrash.ts @@ -0,0 +1,5 @@ +// @allowJS: true +// @outDir: ./out +// @filename: index.js +function Foo() {} +const a = /* @type string */(Foo); From 697c4d33530646440dd8c22d75523761da23549b Mon Sep 17 00:00:00 2001 From: Andy Date: Wed, 6 Sep 2017 14:46:47 -0700 Subject: [PATCH 228/370] Add `debugName` property to `Rule` (#18289) --- src/services/formatting/rule.ts | 14 +++++--------- src/services/formatting/rules.ts | 22 ++++++++++------------ src/services/formatting/rulesProvider.ts | 10 +--------- 3 files changed, 16 insertions(+), 30 deletions(-) diff --git a/src/services/formatting/rule.ts b/src/services/formatting/rule.ts index 543295f364f..10987c745c2 100644 --- a/src/services/formatting/rule.ts +++ b/src/services/formatting/rule.ts @@ -3,16 +3,12 @@ /* @internal */ namespace ts.formatting { export class Rule { + // Used for debugging to identify each rule based on the property name it's assigned to. + public debugName?: string; constructor( - public Descriptor: RuleDescriptor, - public Operation: RuleOperation, - public Flag: RuleFlags = RuleFlags.None) { - } - - public toString() { - return "[desc=" + this.Descriptor + "," + - "operation=" + this.Operation + "," + - "flag=" + this.Flag + "]"; + readonly Descriptor: RuleDescriptor, + readonly Operation: RuleOperation, + readonly Flag: RuleFlags = RuleFlags.None) { } } } \ No newline at end of file diff --git a/src/services/formatting/rules.ts b/src/services/formatting/rules.ts index 2daf8d9d284..07c2804ee83 100644 --- a/src/services/formatting/rules.ts +++ b/src/services/formatting/rules.ts @@ -3,18 +3,6 @@ /* @internal */ namespace ts.formatting { export class Rules { - public getRuleName(rule: Rule) { - const o: ts.MapLike = this; - for (const name in o) { - if (o[name] === rule) { - return name; - } - } - throw new Error("Unknown rule"); - } - - [name: string]: any; - public IgnoreBeforeComment: Rule; public IgnoreAfterLineComment: Rule; @@ -569,6 +557,16 @@ namespace ts.formatting { this.SpaceAfterSemicolon, this.SpaceBetweenStatements, this.SpaceAfterTryFinally ]; + + if (Debug.isDebugging) { + const o: ts.MapLike = this; + for (const name in o) { + const rule = o[name]; + if (rule instanceof Rule) { + rule.debugName = name; + } + } + } } /// diff --git a/src/services/formatting/rulesProvider.ts b/src/services/formatting/rulesProvider.ts index 790bce054b0..1dd7acbdc64 100644 --- a/src/services/formatting/rulesProvider.ts +++ b/src/services/formatting/rulesProvider.ts @@ -9,18 +9,10 @@ namespace ts.formatting { constructor() { this.globalRules = new Rules(); - const activeRules = this.globalRules.HighPriorityCommonRules.slice(0).concat(this.globalRules.UserConfigurableRules).concat(this.globalRules.LowPriorityCommonRules); + const activeRules = this.globalRules.HighPriorityCommonRules.concat(this.globalRules.UserConfigurableRules).concat(this.globalRules.LowPriorityCommonRules); this.rulesMap = RulesMap.create(activeRules); } - public getRuleName(rule: Rule): string { - return this.globalRules.getRuleName(rule); - } - - public getRuleByName(name: string): Rule { - return this.globalRules[name]; - } - public getRulesMap() { return this.rulesMap; } From 0b1bad8421c2a252e89731d056649fe7673414e3 Mon Sep 17 00:00:00 2001 From: Andrew Casey Date: Wed, 6 Sep 2017 15:44:00 -0700 Subject: [PATCH 229/370] Fix lint issues --- src/server/server.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/server/server.ts b/src/server/server.ts index 7f6daa92d5e..96368fb9e54 100644 --- a/src/server/server.ts +++ b/src/server/server.ts @@ -437,7 +437,7 @@ namespace ts.server { while (this.requestQueue.length > 0) { const queuedRequest = this.requestQueue.shift(); - if (this.requestMap.get(queuedRequest.operationId) == queuedRequest) { + if (this.requestMap.get(queuedRequest.operationId) === queuedRequest) { this.requestMap.delete(queuedRequest.operationId); this.scheduleRequest(queuedRequest); break; @@ -455,7 +455,7 @@ namespace ts.server { } private scheduleRequest(request: QueuedOperation) { - if(this.logger.hasLevel(LogLevel.verbose)) { + if (this.logger.hasLevel(LogLevel.verbose)) { this.logger.info(`Scheduling request for: ${request.operationId}`); } this.activeRequestCount++; From 9692ce86db3fb81c31c64c7716b9afe2c6cd4128 Mon Sep 17 00:00:00 2001 From: Andrew Casey Date: Wed, 6 Sep 2017 15:46:59 -0700 Subject: [PATCH 230/370] Add explanatory comment --- src/server/server.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/server/server.ts b/src/server/server.ts index 96368fb9e54..6b6535c8cac 100644 --- a/src/server/server.ts +++ b/src/server/server.ts @@ -251,6 +251,11 @@ namespace ts.server { private requestQueue: QueuedOperation[] = []; private requestMap = createMap(); // Maps operation ID to newest requestQueue entry with that ID + // This number is essentially arbitrary. Processing more than one typings request + // at a time makes sense, but having too many in the pipe results in a hang + // (see https://github.com/nodejs/node/issues/7657). + // It would be preferable to base our limit on the amount of space left in the + // buffer, but we have yet to find a way to retrieve that value. private static readonly maxActiveRequestCount = 10; private static readonly requestDelayMillis = 100; From a5c2eac2ee533fa3e71a6be3e5d320107e2614e8 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Wed, 6 Sep 2017 15:54:14 -0700 Subject: [PATCH 231/370] Test:disable lookahead in isStartOfParameter --- src/compiler/parser.ts | 6 ------ ...arrowfunctionsOptionalArgsErrors2.errors.txt | 17 +++++++++++++---- .../fatarrowfunctionsOptionalArgsErrors2.js | 6 ++---- .../baselines/reference/parser512325.errors.txt | 17 +++++++++++++---- tests/baselines/reference/parser512325.js | 6 ++---- .../parserArrowFunctionExpression5.errors.txt | 15 +++++++++++++++ .../reference/parserArrowFunctionExpression5.js | 10 ++++++++++ .../parserArrowFunctionExpression5.ts | 5 +++++ 8 files changed, 60 insertions(+), 22 deletions(-) create mode 100644 tests/baselines/reference/parserArrowFunctionExpression5.errors.txt create mode 100644 tests/baselines/reference/parserArrowFunctionExpression5.js create mode 100644 tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/parserArrowFunctionExpression5.ts diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index e4847517252..1740bad2d34 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -2238,12 +2238,6 @@ namespace ts { isIdentifierOrPattern() || isModifierKind(token()) || token() === SyntaxKind.AtToken || - // a jsdoc parameter can start directly with a type, but shouldn't look ahead - // in order to avoid confusion between parenthesized types and arrow functions - // eg - // declare function f(cb: function(number): void): void; - // vs - // f((n) => console.log(n)); isStartOfType(/*disableLookahead*/ true); } diff --git a/tests/baselines/reference/fatarrowfunctionsOptionalArgsErrors2.errors.txt b/tests/baselines/reference/fatarrowfunctionsOptionalArgsErrors2.errors.txt index 51db9c7391e..b435e7773f5 100644 --- a/tests/baselines/reference/fatarrowfunctionsOptionalArgsErrors2.errors.txt +++ b/tests/baselines/reference/fatarrowfunctionsOptionalArgsErrors2.errors.txt @@ -1,7 +1,10 @@ -tests/cases/compiler/fatarrowfunctionsOptionalArgsErrors2.ts(1,15): error TS1003: Identifier expected. +tests/cases/compiler/fatarrowfunctionsOptionalArgsErrors2.ts(1,12): error TS2304: Cannot find name 'a'. +tests/cases/compiler/fatarrowfunctionsOptionalArgsErrors2.ts(1,12): error TS2695: Left side of comma operator is unused and has no side effects. tests/cases/compiler/fatarrowfunctionsOptionalArgsErrors2.ts(1,16): error TS2304: Cannot find name 'b'. tests/cases/compiler/fatarrowfunctionsOptionalArgsErrors2.ts(1,16): error TS2695: Left side of comma operator is unused and has no side effects. tests/cases/compiler/fatarrowfunctionsOptionalArgsErrors2.ts(1,19): error TS2304: Cannot find name 'c'. +tests/cases/compiler/fatarrowfunctionsOptionalArgsErrors2.ts(1,23): error TS1005: ';' expected. +tests/cases/compiler/fatarrowfunctionsOptionalArgsErrors2.ts(1,26): error TS2304: Cannot find name 'a'. tests/cases/compiler/fatarrowfunctionsOptionalArgsErrors2.ts(1,28): error TS2304: Cannot find name 'b'. tests/cases/compiler/fatarrowfunctionsOptionalArgsErrors2.ts(1,30): error TS2304: Cannot find name 'c'. tests/cases/compiler/fatarrowfunctionsOptionalArgsErrors2.ts(2,12): error TS2695: Left side of comma operator is unused and has no side effects. @@ -18,16 +21,22 @@ tests/cases/compiler/fatarrowfunctionsOptionalArgsErrors2.ts(4,17): error TS1005 tests/cases/compiler/fatarrowfunctionsOptionalArgsErrors2.ts(4,20): error TS2304: Cannot find name 'a'. -==== tests/cases/compiler/fatarrowfunctionsOptionalArgsErrors2.ts (18 errors) ==== +==== tests/cases/compiler/fatarrowfunctionsOptionalArgsErrors2.ts (21 errors) ==== var tt1 = (a, (b, c)) => a+b+c; - ~ -!!! error TS1003: Identifier expected. + ~ +!!! error TS2304: Cannot find name 'a'. + ~ +!!! error TS2695: Left side of comma operator is unused and has no side effects. ~ !!! error TS2304: Cannot find name 'b'. ~ !!! error TS2695: Left side of comma operator is unused and has no side effects. ~ !!! error TS2304: Cannot find name 'c'. + ~~ +!!! error TS1005: ';' expected. + ~ +!!! error TS2304: Cannot find name 'a'. ~ !!! error TS2304: Cannot find name 'b'. ~ diff --git a/tests/baselines/reference/fatarrowfunctionsOptionalArgsErrors2.js b/tests/baselines/reference/fatarrowfunctionsOptionalArgsErrors2.js index a1c68ea4476..b51003b62df 100644 --- a/tests/baselines/reference/fatarrowfunctionsOptionalArgsErrors2.js +++ b/tests/baselines/reference/fatarrowfunctionsOptionalArgsErrors2.js @@ -5,10 +5,8 @@ var tt2 = ((a), b, c) => a+b+c; var tt3 = ((a)) => a; //// [fatarrowfunctionsOptionalArgsErrors2.js] -var tt1 = function (a, ) { - if ( === void 0) { = (b, c); } - return a + b + c; -}; +var tt1 = (a, (b, c)); +a + b + c; var tt2 = ((a), b, c); a + b + c; var tt3 = ((a)); diff --git a/tests/baselines/reference/parser512325.errors.txt b/tests/baselines/reference/parser512325.errors.txt index f54d9f2110a..e6a47fbf226 100644 --- a/tests/baselines/reference/parser512325.errors.txt +++ b/tests/baselines/reference/parser512325.errors.txt @@ -1,21 +1,30 @@ -tests/cases/conformance/parser/ecmascript5/RegressionTests/parser512325.ts(1,14): error TS1003: Identifier expected. +tests/cases/conformance/parser/ecmascript5/RegressionTests/parser512325.ts(1,11): error TS2304: Cannot find name 'a'. +tests/cases/conformance/parser/ecmascript5/RegressionTests/parser512325.ts(1,11): error TS2695: Left side of comma operator is unused and has no side effects. tests/cases/conformance/parser/ecmascript5/RegressionTests/parser512325.ts(1,15): error TS2304: Cannot find name 'b'. tests/cases/conformance/parser/ecmascript5/RegressionTests/parser512325.ts(1,15): error TS2695: Left side of comma operator is unused and has no side effects. tests/cases/conformance/parser/ecmascript5/RegressionTests/parser512325.ts(1,18): error TS2304: Cannot find name 'c'. +tests/cases/conformance/parser/ecmascript5/RegressionTests/parser512325.ts(1,22): error TS1005: ';' expected. +tests/cases/conformance/parser/ecmascript5/RegressionTests/parser512325.ts(1,25): error TS2304: Cannot find name 'a'. tests/cases/conformance/parser/ecmascript5/RegressionTests/parser512325.ts(1,27): error TS2304: Cannot find name 'b'. tests/cases/conformance/parser/ecmascript5/RegressionTests/parser512325.ts(1,29): error TS2304: Cannot find name 'c'. -==== tests/cases/conformance/parser/ecmascript5/RegressionTests/parser512325.ts (6 errors) ==== +==== tests/cases/conformance/parser/ecmascript5/RegressionTests/parser512325.ts (9 errors) ==== var tt = (a, (b, c)) => a+b+c; - ~ -!!! error TS1003: Identifier expected. + ~ +!!! error TS2304: Cannot find name 'a'. + ~ +!!! error TS2695: Left side of comma operator is unused and has no side effects. ~ !!! error TS2304: Cannot find name 'b'. ~ !!! error TS2695: Left side of comma operator is unused and has no side effects. ~ !!! error TS2304: Cannot find name 'c'. + ~~ +!!! error TS1005: ';' expected. + ~ +!!! error TS2304: Cannot find name 'a'. ~ !!! error TS2304: Cannot find name 'b'. ~ diff --git a/tests/baselines/reference/parser512325.js b/tests/baselines/reference/parser512325.js index 75af6b9f39a..14cbcddd86b 100644 --- a/tests/baselines/reference/parser512325.js +++ b/tests/baselines/reference/parser512325.js @@ -2,7 +2,5 @@ var tt = (a, (b, c)) => a+b+c; //// [parser512325.js] -var tt = function (a, ) { - if ( === void 0) { = (b, c); } - return a + b + c; -}; +var tt = (a, (b, c)); +a + b + c; diff --git a/tests/baselines/reference/parserArrowFunctionExpression5.errors.txt b/tests/baselines/reference/parserArrowFunctionExpression5.errors.txt new file mode 100644 index 00000000000..220c4d42279 --- /dev/null +++ b/tests/baselines/reference/parserArrowFunctionExpression5.errors.txt @@ -0,0 +1,15 @@ +tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/parserArrowFunctionExpression5.ts(1,2): error TS2304: Cannot find name 'bar'. +tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/parserArrowFunctionExpression5.ts(1,6): error TS2304: Cannot find name 'x'. + + +==== tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/parserArrowFunctionExpression5.ts (2 errors) ==== + (bar(x, + ~~~ +!!! error TS2304: Cannot find name 'bar'. + ~ +!!! error TS2304: Cannot find name 'x'. + () => {}, + () => {} + ) + ) + \ No newline at end of file diff --git a/tests/baselines/reference/parserArrowFunctionExpression5.js b/tests/baselines/reference/parserArrowFunctionExpression5.js new file mode 100644 index 00000000000..b25d77a4b02 --- /dev/null +++ b/tests/baselines/reference/parserArrowFunctionExpression5.js @@ -0,0 +1,10 @@ +//// [parserArrowFunctionExpression5.ts] +(bar(x, + () => {}, + () => {} + ) +) + + +//// [parserArrowFunctionExpression5.js] +(bar(x, function () { }, function () { })); diff --git a/tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/parserArrowFunctionExpression5.ts b/tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/parserArrowFunctionExpression5.ts new file mode 100644 index 00000000000..d4ab2adefba --- /dev/null +++ b/tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/parserArrowFunctionExpression5.ts @@ -0,0 +1,5 @@ +(bar(x, + () => {}, + () => {} + ) +) From 5c779b1edbc17d03491fee4e73b9c4d9a45cd2eb Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Wed, 6 Sep 2017 21:56:16 -0700 Subject: [PATCH 232/370] Allow singleline string writer to be recursively used (#18297) * Allow singleline string writer to be recursively used * Add unit test exposing issue * Fix lints --- Jakefile.js | 1 + src/compiler/utilities.ts | 6 +-- src/harness/tsconfig.json | 1 + src/harness/unittests/languageService.ts | 49 ++++++++++++++++++++++++ 4 files changed, 53 insertions(+), 4 deletions(-) create mode 100644 src/harness/unittests/languageService.ts diff --git a/Jakefile.js b/Jakefile.js index b3e18e8cb1a..ad853238111 100644 --- a/Jakefile.js +++ b/Jakefile.js @@ -143,6 +143,7 @@ var harnessSources = harnessCoreSources.concat([ "customTransforms.ts", "programMissingFiles.ts", "symbolWalker.ts", + "languageService.ts", ].map(function (f) { return path.join(unittestsDirectory, f); })).concat([ diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index 2a07d2b6560..725070c02bf 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -32,7 +32,6 @@ namespace ts { } const stringWriter = createSingleLineStringWriter(); - let stringWriterAcquired = false; function createSingleLineStringWriter(): StringSymbolWriter { let str = ""; @@ -62,15 +61,14 @@ namespace ts { } export function usingSingleLineStringWriter(action: (writer: StringSymbolWriter) => void): string { + const oldString = stringWriter.string(); try { - Debug.assert(!stringWriterAcquired); - stringWriterAcquired = true; action(stringWriter); return stringWriter.string(); } finally { stringWriter.clear(); - stringWriterAcquired = false; + stringWriter.writeKeyword(oldString); } } diff --git a/src/harness/tsconfig.json b/src/harness/tsconfig.json index 1469079bcaa..bd7c9bc2ffa 100644 --- a/src/harness/tsconfig.json +++ b/src/harness/tsconfig.json @@ -128,6 +128,7 @@ "./unittests/extractMethods.ts", "./unittests/textChanges.ts", "./unittests/telemetry.ts", + "./unittests/languageService.ts", "./unittests/programMissingFiles.ts" ] } diff --git a/src/harness/unittests/languageService.ts b/src/harness/unittests/languageService.ts new file mode 100644 index 00000000000..9c838845c20 --- /dev/null +++ b/src/harness/unittests/languageService.ts @@ -0,0 +1,49 @@ +/// + +namespace ts { + describe("languageService", () => { + const files: {[index: string]: string} = { + "foo.ts": `import Vue from "./vue"; +import Component from "./vue-class-component"; +import { vueTemplateHtml } from "./variables"; + +@Component({ + template: vueTemplateHtml, +}) +class Carousel extends Vue { +}`, + "variables.ts": `export const vueTemplateHtml = \`
\`;`, + "vue.d.ts": `export namespace Vue { export type Config = { template: string }; }`, + "vue-class-component.d.ts": `import Vue from "./vue"; +export function Component(x: Config): any;` +}; + it("should be able to create a language service which can respond to deinition requests without throwing", () => { + const languageService = ts.createLanguageService({ + getCompilationSettings() { + return {}; + }, + getScriptFileNames() { + return ["foo.ts", "variables.ts", "vue.d.ts", "vue-class-component.d.ts"]; + }, + getScriptVersion(_fileName) { + return ""; + }, + getScriptSnapshot(fileName) { + if (fileName === ".ts") { + return ts.ScriptSnapshot.fromString(""); + } + return ts.ScriptSnapshot.fromString(files[fileName] || ""); + }, + getCurrentDirectory: () => ".", + getDefaultLibFileName(options) { + return ts.getDefaultLibFilePath(options); + }, + fileExists: noop as any, + readFile: noop as any, + readDirectory: noop as any, + }); + const definitions = languageService.getDefinitionAtPosition("foo.ts", 160); // 160 is the latter `vueTemplateHtml` position + expect(definitions).to.exist; + }); + }); +} \ No newline at end of file From ed61d2d803a99e8891fa306face099a6a4290b29 Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Wed, 6 Sep 2017 21:58:04 -0700 Subject: [PATCH 233/370] Emit updated export declarations when transformed from export * (#18017) * Failing test for missing transform output * dont elide all export stars * Remove comment from test * Refuse to perform ellision on transformed nodes --- src/compiler/transformers/ts.ts | 20 +++++++- src/harness/unittests/transform.ts | 49 +++++++++++++++---- ...sformsCorrectly.transformAwayExportStar.js | 1 + 3 files changed, 60 insertions(+), 10 deletions(-) create mode 100644 tests/baselines/reference/transformApi/transformsCorrectly.transformAwayExportStar.js diff --git a/src/compiler/transformers/ts.ts b/src/compiler/transformers/ts.ts index 692c758bc75..42c25ca34a5 100644 --- a/src/compiler/transformers/ts.ts +++ b/src/compiler/transformers/ts.ts @@ -208,6 +208,24 @@ namespace ts { * @param node The node to visit. */ function sourceElementVisitorWorker(node: Node): VisitResult { + switch (node.kind) { + case SyntaxKind.ImportDeclaration: + case SyntaxKind.ImportEqualsDeclaration: + case SyntaxKind.ExportAssignment: + case SyntaxKind.ExportDeclaration: + return visitEllidableStatement(node); + default: + return visitorWorker(node); + } + } + + function visitEllidableStatement(node: ImportDeclaration | ImportEqualsDeclaration | ExportAssignment | ExportDeclaration): VisitResult { + const parsed = getParseTreeNode(node); + if (parsed !== node) { + // If the node has been transformed by a `before` transformer, perform no ellision on it + // As the type information we would attempt to lookup to perform ellision is potentially unavailable for the synthesized nodes + return node; + } switch (node.kind) { case SyntaxKind.ImportDeclaration: return visitImportDeclaration(node); @@ -218,7 +236,7 @@ namespace ts { case SyntaxKind.ExportDeclaration: return visitExportDeclaration(node); default: - return visitorWorker(node); + Debug.fail("Unhandled ellided statement"); } } diff --git a/src/harness/unittests/transform.ts b/src/harness/unittests/transform.ts index 27e41a96dfc..bcdca3e3b60 100644 --- a/src/harness/unittests/transform.ts +++ b/src/harness/unittests/transform.ts @@ -57,7 +57,7 @@ namespace ts { testBaseline("types", () => { return transformSourceFile(`let a: () => void`, [ - context => file => visitNode(file, function visitor(node: Node): VisitResult { + context => file => visitNode(file, function visitor(node: Node): VisitResult { return visitEachChild(node, visitor, context); }) ]); @@ -91,14 +91,14 @@ namespace ts { class C { foo = 10; static bar = 20 } namespace C { export let x = 10; } `, { - transformers: { - before: [forceNamespaceRewrite], - }, - compilerOptions: { - target: ts.ScriptTarget.ESNext, - newLine: NewLineKind.CarriageReturnLineFeed, - } - }).outputText; + transformers: { + before: [forceNamespaceRewrite], + }, + compilerOptions: { + target: ts.ScriptTarget.ESNext, + newLine: NewLineKind.CarriageReturnLineFeed, + } + }).outputText; }); testBaseline("synthesizedClassAndNamespaceCombination", () => { @@ -138,6 +138,37 @@ namespace ts { } }; } + + testBaseline("transformAwayExportStar", () => { + return ts.transpileModule("export * from './helper';", { + transformers: { + before: [expandExportStar], + }, + compilerOptions: { + target: ts.ScriptTarget.ESNext, + newLine: NewLineKind.CarriageReturnLineFeed, + } + }).outputText; + + function expandExportStar(context: ts.TransformationContext) { + return (sourceFile: ts.SourceFile): ts.SourceFile => { + return visitNode(sourceFile); + + function visitNode(node: T): T { + if (node.kind === ts.SyntaxKind.ExportDeclaration) { + const ed = node as ts.Node as ts.ExportDeclaration; + const exports = [{ name: "x" }]; + const exportSpecifiers = exports.map(e => ts.createExportSpecifier(e.name, e.name)); + const exportClause = ts.createNamedExports(exportSpecifiers); + const newEd = ts.updateExportDeclaration(ed, ed.decorators, ed.modifiers, exportClause, ed.moduleSpecifier); + + return newEd as ts.Node as T; + } + return ts.visitEachChild(node, visitNode, context); + } + }; + } + }); }); } diff --git a/tests/baselines/reference/transformApi/transformsCorrectly.transformAwayExportStar.js b/tests/baselines/reference/transformApi/transformsCorrectly.transformAwayExportStar.js new file mode 100644 index 00000000000..7a05a90c1f8 --- /dev/null +++ b/tests/baselines/reference/transformApi/transformsCorrectly.transformAwayExportStar.js @@ -0,0 +1 @@ +export { x as x } from './helper'; From 72884b8f27abb8bfe8d8ec0f4368d09f1a4c80bf Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Wed, 6 Sep 2017 21:59:06 -0700 Subject: [PATCH 234/370] Emit comments on system export default expressions on the surrounding export call epxression instead (#17970) --- src/compiler/emitter.ts | 2 +- src/compiler/transformers/module/system.ts | 3 ++- .../systemDefaultExportCommentValidity.js | 20 +++++++++++++++++++ ...systemDefaultExportCommentValidity.symbols | 8 ++++++++ .../systemDefaultExportCommentValidity.types | 9 +++++++++ .../systemDefaultExportCommentValidity.ts | 5 +++++ 6 files changed, 45 insertions(+), 2 deletions(-) create mode 100644 tests/baselines/reference/systemDefaultExportCommentValidity.js create mode 100644 tests/baselines/reference/systemDefaultExportCommentValidity.symbols create mode 100644 tests/baselines/reference/systemDefaultExportCommentValidity.types create mode 100644 tests/cases/compiler/systemDefaultExportCommentValidity.ts diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index 5444c618353..166e4751983 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -2519,7 +2519,7 @@ namespace ts { // 2 // /* end of element 2 */ // ]; - if (previousSibling && delimiter && previousSibling.end !== parentNode.end) { + if (previousSibling && delimiter && previousSibling.end !== parentNode.end && !(getEmitFlags(previousSibling) & EmitFlags.NoTrailingComments)) { emitLeadingCommentsOfPosition(previousSibling.end); } diff --git a/src/compiler/transformers/module/system.ts b/src/compiler/transformers/module/system.ts index e1c239736d5..8c47ec82f70 100644 --- a/src/compiler/transformers/module/system.ts +++ b/src/compiler/transformers/module/system.ts @@ -1132,7 +1132,8 @@ namespace ts { */ function createExportExpression(name: Identifier | StringLiteral, value: Expression) { const exportName = isIdentifier(name) ? createLiteral(name) : name; - return createCall(exportFunction, /*typeArguments*/ undefined, [exportName, value]); + setEmitFlags(value, getEmitFlags(value) | EmitFlags.NoComments); + return setCommentRange(createCall(exportFunction, /*typeArguments*/ undefined, [exportName, value]), value); } // diff --git a/tests/baselines/reference/systemDefaultExportCommentValidity.js b/tests/baselines/reference/systemDefaultExportCommentValidity.js new file mode 100644 index 00000000000..a56110b0de9 --- /dev/null +++ b/tests/baselines/reference/systemDefaultExportCommentValidity.js @@ -0,0 +1,20 @@ +//// [systemDefaultExportCommentValidity.ts] +const Home = {} + +export default Home +// There is intentionally no semicolon on the prior line, this comment should not break emit + +//// [systemDefaultExportCommentValidity.js] +System.register([], function (exports_1, context_1) { + "use strict"; + var __moduleName = context_1 && context_1.id; + var Home; + return { + setters: [], + execute: function () { + Home = {}; + exports_1("default", Home); + // There is intentionally no semicolon on the prior line, this comment should not break emit + } + }; +}); diff --git a/tests/baselines/reference/systemDefaultExportCommentValidity.symbols b/tests/baselines/reference/systemDefaultExportCommentValidity.symbols new file mode 100644 index 00000000000..39abe3a6685 --- /dev/null +++ b/tests/baselines/reference/systemDefaultExportCommentValidity.symbols @@ -0,0 +1,8 @@ +=== tests/cases/compiler/systemDefaultExportCommentValidity.ts === +const Home = {} +>Home : Symbol(Home, Decl(systemDefaultExportCommentValidity.ts, 0, 5)) + +export default Home +>Home : Symbol(Home, Decl(systemDefaultExportCommentValidity.ts, 0, 5)) + +// There is intentionally no semicolon on the prior line, this comment should not break emit diff --git a/tests/baselines/reference/systemDefaultExportCommentValidity.types b/tests/baselines/reference/systemDefaultExportCommentValidity.types new file mode 100644 index 00000000000..d8b89394ed6 --- /dev/null +++ b/tests/baselines/reference/systemDefaultExportCommentValidity.types @@ -0,0 +1,9 @@ +=== tests/cases/compiler/systemDefaultExportCommentValidity.ts === +const Home = {} +>Home : {} +>{} : {} + +export default Home +>Home : {} + +// There is intentionally no semicolon on the prior line, this comment should not break emit diff --git a/tests/cases/compiler/systemDefaultExportCommentValidity.ts b/tests/cases/compiler/systemDefaultExportCommentValidity.ts new file mode 100644 index 00000000000..df1d0283978 --- /dev/null +++ b/tests/cases/compiler/systemDefaultExportCommentValidity.ts @@ -0,0 +1,5 @@ +// @module: system +const Home = {} + +export default Home +// There is intentionally no semicolon on the prior line, this comment should not break emit \ No newline at end of file From c3e090695ec59cd79536ea892f4351fbb3674489 Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Wed, 6 Sep 2017 22:07:30 -0700 Subject: [PATCH 235/370] Do not consider UMD alias symbols as visible within external modules (#18049) * Do not consider UMD alias symbols as visible within external modules in the symbol writer * Minimal repro --- src/compiler/checker.ts | 5 ++++ .../reference/exportAsNamespace.d.types | 2 +- ...mportShouldNotBeElidedInDeclarationEmit.js | 26 +++++++++++++++++++ ...ShouldNotBeElidedInDeclarationEmit.symbols | 23 ++++++++++++++++ ...rtShouldNotBeElidedInDeclarationEmit.types | 24 +++++++++++++++++ .../reference/umd-augmentation-1.types | 2 +- .../reference/umd-augmentation-2.types | 2 +- .../reference/umd-augmentation-3.symbols | 2 +- .../reference/umd-augmentation-3.types | 4 +-- .../reference/umd-augmentation-4.symbols | 2 +- .../reference/umd-augmentation-4.types | 4 +-- tests/baselines/reference/umd1.types | 2 +- tests/baselines/reference/umd3.types | 2 +- tests/baselines/reference/umd4.types | 2 +- .../reference/umdGlobalConflict.types | 2 +- ...mportShouldNotBeElidedInDeclarationEmit.ts | 12 +++++++++ 16 files changed, 103 insertions(+), 13 deletions(-) create mode 100644 tests/baselines/reference/importShouldNotBeElidedInDeclarationEmit.js create mode 100644 tests/baselines/reference/importShouldNotBeElidedInDeclarationEmit.symbols create mode 100644 tests/baselines/reference/importShouldNotBeElidedInDeclarationEmit.types create mode 100644 tests/cases/compiler/importShouldNotBeElidedInDeclarationEmit.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 9fcd0b593f8..e7e66ed5f2d 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -2095,6 +2095,10 @@ namespace ts { canQualifySymbol(symbolFromSymbolTable, meaning); } + function isUMDExportSymbol(symbol: Symbol) { + return symbol && symbol.declarations && symbol.declarations[0] && isNamespaceExportDeclaration(symbol.declarations[0]); + } + function trySymbolTable(symbols: SymbolTable) { // If symbol is directly available by its name in the symbol table if (isAccessible(symbols.get(symbol.escapedName))) { @@ -2106,6 +2110,7 @@ namespace ts { if (symbolFromSymbolTable.flags & SymbolFlags.Alias && symbolFromSymbolTable.escapedName !== "export=" && !getDeclarationOfKind(symbolFromSymbolTable, SyntaxKind.ExportSpecifier) + && !(isUMDExportSymbol(symbolFromSymbolTable) && isExternalModule(getSourceFileOfNode(enclosingDeclaration))) // If `!useOnlyExternalAliasing`, we can use any type of alias to get the name && (!useOnlyExternalAliasing || some(symbolFromSymbolTable.declarations, isExternalModuleImportEqualsDeclaration))) { diff --git a/tests/baselines/reference/exportAsNamespace.d.types b/tests/baselines/reference/exportAsNamespace.d.types index 706857bf8ed..4952cb8863b 100644 --- a/tests/baselines/reference/exportAsNamespace.d.types +++ b/tests/baselines/reference/exportAsNamespace.d.types @@ -5,5 +5,5 @@ export var X; >X : any export as namespace N ->N : typeof N +>N : typeof "tests/cases/compiler/exportAsNamespace" diff --git a/tests/baselines/reference/importShouldNotBeElidedInDeclarationEmit.js b/tests/baselines/reference/importShouldNotBeElidedInDeclarationEmit.js new file mode 100644 index 00000000000..a1316dbdd46 --- /dev/null +++ b/tests/baselines/reference/importShouldNotBeElidedInDeclarationEmit.js @@ -0,0 +1,26 @@ +//// [tests/cases/compiler/importShouldNotBeElidedInDeclarationEmit.ts] //// + +//// [umd.d.ts] +export as namespace UMD; + +export type Thing = { + a: number; +} + +export declare function makeThing(): Thing; +//// [index.ts] +import { makeThing } from "umd"; +export const thing = makeThing(); + + +//// [index.js] +"use strict"; +exports.__esModule = true; +var umd_1 = require("umd"); +exports.thing = umd_1.makeThing(); + + +//// [index.d.ts] +export declare const thing: { + a: number; +}; diff --git a/tests/baselines/reference/importShouldNotBeElidedInDeclarationEmit.symbols b/tests/baselines/reference/importShouldNotBeElidedInDeclarationEmit.symbols new file mode 100644 index 00000000000..4ac0f4928b0 --- /dev/null +++ b/tests/baselines/reference/importShouldNotBeElidedInDeclarationEmit.symbols @@ -0,0 +1,23 @@ +=== tests/cases/compiler/node_modules/umd.d.ts === +export as namespace UMD; +>UMD : Symbol(UMD, Decl(umd.d.ts, 0, 0)) + +export type Thing = { +>Thing : Symbol(Thing, Decl(umd.d.ts, 0, 24)) + + a: number; +>a : Symbol(a, Decl(umd.d.ts, 2, 21)) +} + +export declare function makeThing(): Thing; +>makeThing : Symbol(makeThing, Decl(umd.d.ts, 4, 1)) +>Thing : Symbol(Thing, Decl(umd.d.ts, 0, 24)) + +=== tests/cases/compiler/index.ts === +import { makeThing } from "umd"; +>makeThing : Symbol(makeThing, Decl(index.ts, 0, 8)) + +export const thing = makeThing(); +>thing : Symbol(thing, Decl(index.ts, 1, 12)) +>makeThing : Symbol(makeThing, Decl(index.ts, 0, 8)) + diff --git a/tests/baselines/reference/importShouldNotBeElidedInDeclarationEmit.types b/tests/baselines/reference/importShouldNotBeElidedInDeclarationEmit.types new file mode 100644 index 00000000000..2531654f80b --- /dev/null +++ b/tests/baselines/reference/importShouldNotBeElidedInDeclarationEmit.types @@ -0,0 +1,24 @@ +=== tests/cases/compiler/node_modules/umd.d.ts === +export as namespace UMD; +>UMD : typeof "tests/cases/compiler/node_modules/umd" + +export type Thing = { +>Thing : Thing + + a: number; +>a : number +} + +export declare function makeThing(): Thing; +>makeThing : () => Thing +>Thing : Thing + +=== tests/cases/compiler/index.ts === +import { makeThing } from "umd"; +>makeThing : () => { a: number; } + +export const thing = makeThing(); +>thing : { a: number; } +>makeThing() : { a: number; } +>makeThing : () => { a: number; } + diff --git a/tests/baselines/reference/umd-augmentation-1.types b/tests/baselines/reference/umd-augmentation-1.types index 5324e58f68e..9d89e0c4537 100644 --- a/tests/baselines/reference/umd-augmentation-1.types +++ b/tests/baselines/reference/umd-augmentation-1.types @@ -47,7 +47,7 @@ var t = p.x; === tests/cases/conformance/externalModules/node_modules/math2d/index.d.ts === export as namespace Math2d; ->Math2d : typeof Math2d +>Math2d : typeof "tests/cases/conformance/externalModules/node_modules/math2d/index" export interface Point { >Point : Point diff --git a/tests/baselines/reference/umd-augmentation-2.types b/tests/baselines/reference/umd-augmentation-2.types index 4ead8d611ca..b8d04ecd643 100644 --- a/tests/baselines/reference/umd-augmentation-2.types +++ b/tests/baselines/reference/umd-augmentation-2.types @@ -45,7 +45,7 @@ var t = p.x; === tests/cases/conformance/externalModules/node_modules/math2d/index.d.ts === export as namespace Math2d; ->Math2d : typeof Math2d +>Math2d : typeof "tests/cases/conformance/externalModules/node_modules/math2d/index" export interface Point { >Point : Point diff --git a/tests/baselines/reference/umd-augmentation-3.symbols b/tests/baselines/reference/umd-augmentation-3.symbols index acb2f471faf..7cbe3ac803b 100644 --- a/tests/baselines/reference/umd-augmentation-3.symbols +++ b/tests/baselines/reference/umd-augmentation-3.symbols @@ -44,7 +44,7 @@ export = M2D; >M2D : Symbol(M2D, Decl(index.d.ts, 2, 13)) declare namespace M2D { ->M2D : Symbol(Math2d, Decl(index.d.ts, 2, 13), Decl(math2d-augment.d.ts, 0, 33)) +>M2D : Symbol(M2D, Decl(index.d.ts, 2, 13), Decl(math2d-augment.d.ts, 0, 33)) interface Point { >Point : Symbol(Point, Decl(index.d.ts, 4, 23)) diff --git a/tests/baselines/reference/umd-augmentation-3.types b/tests/baselines/reference/umd-augmentation-3.types index 4802d159e18..5efafd780a0 100644 --- a/tests/baselines/reference/umd-augmentation-3.types +++ b/tests/baselines/reference/umd-augmentation-3.types @@ -47,13 +47,13 @@ var t = p.x; === tests/cases/conformance/externalModules/node_modules/math2d/index.d.ts === export as namespace Math2d; ->Math2d : typeof Math2d +>Math2d : typeof M2D export = M2D; >M2D : typeof M2D declare namespace M2D { ->M2D : typeof Math2d +>M2D : typeof M2D interface Point { >Point : Point diff --git a/tests/baselines/reference/umd-augmentation-4.symbols b/tests/baselines/reference/umd-augmentation-4.symbols index 12696ab51f7..eabb2e15898 100644 --- a/tests/baselines/reference/umd-augmentation-4.symbols +++ b/tests/baselines/reference/umd-augmentation-4.symbols @@ -42,7 +42,7 @@ export = M2D; >M2D : Symbol(M2D, Decl(index.d.ts, 2, 13)) declare namespace M2D { ->M2D : Symbol(Math2d, Decl(index.d.ts, 2, 13), Decl(math2d-augment.d.ts, 0, 33)) +>M2D : Symbol(M2D, Decl(index.d.ts, 2, 13), Decl(math2d-augment.d.ts, 0, 33)) interface Point { >Point : Symbol(Point, Decl(index.d.ts, 4, 23)) diff --git a/tests/baselines/reference/umd-augmentation-4.types b/tests/baselines/reference/umd-augmentation-4.types index 324de384183..f71928f5afc 100644 --- a/tests/baselines/reference/umd-augmentation-4.types +++ b/tests/baselines/reference/umd-augmentation-4.types @@ -45,13 +45,13 @@ var t = p.x; === tests/cases/conformance/externalModules/node_modules/math2d/index.d.ts === export as namespace Math2d; ->Math2d : typeof Math2d +>Math2d : typeof M2D export = M2D; >M2D : typeof M2D declare namespace M2D { ->M2D : typeof Math2d +>M2D : typeof M2D interface Point { >Point : Point diff --git a/tests/baselines/reference/umd1.types b/tests/baselines/reference/umd1.types index 9ccc0d2cd8e..b84aaf3ad70 100644 --- a/tests/baselines/reference/umd1.types +++ b/tests/baselines/reference/umd1.types @@ -30,5 +30,5 @@ export interface Thing { n: typeof x } >x : number export as namespace Foo; ->Foo : typeof Foo +>Foo : typeof "tests/cases/conformance/externalModules/foo" diff --git a/tests/baselines/reference/umd3.types b/tests/baselines/reference/umd3.types index ab7978545ba..ef54806a174 100644 --- a/tests/baselines/reference/umd3.types +++ b/tests/baselines/reference/umd3.types @@ -32,5 +32,5 @@ export interface Thing { n: typeof x } >x : number export as namespace Foo; ->Foo : typeof Foo +>Foo : typeof "tests/cases/conformance/externalModules/foo" diff --git a/tests/baselines/reference/umd4.types b/tests/baselines/reference/umd4.types index c9144af7a18..3b6ebfa6ca7 100644 --- a/tests/baselines/reference/umd4.types +++ b/tests/baselines/reference/umd4.types @@ -32,5 +32,5 @@ export interface Thing { n: typeof x } >x : number export as namespace Foo; ->Foo : typeof Foo +>Foo : typeof "tests/cases/conformance/externalModules/foo" diff --git a/tests/baselines/reference/umdGlobalConflict.types b/tests/baselines/reference/umdGlobalConflict.types index d23d42e702a..0bb26b47918 100644 --- a/tests/baselines/reference/umdGlobalConflict.types +++ b/tests/baselines/reference/umdGlobalConflict.types @@ -1,6 +1,6 @@ === tests/cases/compiler/v1/index.d.ts === export as namespace Alpha; ->Alpha : typeof Alpha +>Alpha : typeof "tests/cases/compiler/v1/index" export var x: string; >x : string diff --git a/tests/cases/compiler/importShouldNotBeElidedInDeclarationEmit.ts b/tests/cases/compiler/importShouldNotBeElidedInDeclarationEmit.ts new file mode 100644 index 00000000000..a6d77a51567 --- /dev/null +++ b/tests/cases/compiler/importShouldNotBeElidedInDeclarationEmit.ts @@ -0,0 +1,12 @@ +// @declaration: true +// @filename: node_modules/umd.d.ts +export as namespace UMD; + +export type Thing = { + a: number; +} + +export declare function makeThing(): Thing; +// @filename: index.ts +import { makeThing } from "umd"; +export const thing = makeThing(); From 72cbc12c9a5cb49ff331f3a3828a83c4ae4c5991 Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Wed, 6 Sep 2017 22:08:42 -0700 Subject: [PATCH 236/370] Allow undefined/null to override all parameters (#18058) --- src/compiler/commandLineParser.ts | 32 ++++++++++------ src/compiler/types.ts | 2 +- .../unittests/configurationExtension.ts | 37 ++++++++++++++++++- 3 files changed, 58 insertions(+), 13 deletions(-) diff --git a/src/compiler/commandLineParser.ts b/src/compiler/commandLineParser.ts index c92d147f9a9..dc9c2ad35ed 100644 --- a/src/compiler/commandLineParser.ts +++ b/src/compiler/commandLineParser.ts @@ -1057,7 +1057,7 @@ namespace ts { errors.push(createDiagnosticForNodeInSourceFile(sourceFile, element.name, extraKeyDiagnosticMessage, keyText)); } const value = convertPropertyValueToJson(element.initializer, option); - if (typeof keyText !== "undefined" && typeof value !== "undefined") { + if (typeof keyText !== "undefined") { result[keyText] = value; // Notify key value set, if user asked for it if (jsonConversionNotifier && @@ -1104,7 +1104,7 @@ namespace ts { return false; case SyntaxKind.NullKeyword: - reportInvalidOptionValue(!!option); + reportInvalidOptionValue(option && option.name === "extends"); // "extends" is the only option we don't allow null/undefined for return null; // tslint:disable-line:no-null-keyword case SyntaxKind.StringLiteral: @@ -1189,6 +1189,7 @@ namespace ts { function isCompilerOptionsValue(option: CommandLineOption, value: any): value is CompilerOptionsValue { if (option) { + if (isNullOrUndefined(value)) return true; // All options are undefinable/nullable if (option.type === "list") { return isArray(value); } @@ -1379,6 +1380,11 @@ namespace ts { } } + function isNullOrUndefined(x: any): x is null | undefined { + // tslint:disable-next-line:no-null-keyword + return x === undefined || x === null; + } + /** * Parse the contents of a config file from json or json source file (tsconfig.json). * @param json The contents of the config file to parse @@ -1419,7 +1425,7 @@ namespace ts { function getFileNames(): ExpandResult { let fileNames: ReadonlyArray; - if (hasProperty(raw, "files")) { + if (hasProperty(raw, "files") && !isNullOrUndefined(raw["files"])) { if (isArray(raw["files"])) { fileNames = >raw["files"]; if (fileNames.length === 0) { @@ -1432,7 +1438,7 @@ namespace ts { } let includeSpecs: ReadonlyArray; - if (hasProperty(raw, "include")) { + if (hasProperty(raw, "include") && !isNullOrUndefined(raw["include"])) { if (isArray(raw["include"])) { includeSpecs = >raw["include"]; } @@ -1442,7 +1448,7 @@ namespace ts { } let excludeSpecs: ReadonlyArray; - if (hasProperty(raw, "exclude")) { + if (hasProperty(raw, "exclude") && !isNullOrUndefined(raw["exclude"])) { if (isArray(raw["exclude"])) { excludeSpecs = >raw["exclude"]; } @@ -1461,7 +1467,7 @@ namespace ts { includeSpecs = ["**/*"]; } - const result = matchFileNames(fileNames, includeSpecs, excludeSpecs, basePath, options, host, errors, extraFileExtensions, sourceFile); + const result = matchFileNames(fileNames, includeSpecs, excludeSpecs, configFileName ? getDirectoryPath(toPath(configFileName, basePath, createGetCanonicalFileName(host.useCaseSensitiveFileNames))) : basePath, options, host, errors, extraFileExtensions, sourceFile); if (result.fileNames.length === 0 && !hasProperty(raw, "files") && resolutionStack.length === 0) { errors.push( @@ -1552,7 +1558,7 @@ namespace ts { host: ParseConfigHost, basePath: string, getCanonicalFileName: (fileName: string) => string, - configFileName: string, + configFileName: string | undefined, errors: Push ): ParsedTsconfig { if (hasProperty(json, "excludes")) { @@ -1571,7 +1577,8 @@ namespace ts { errors.push(createCompilerDiagnostic(Diagnostics.Compiler_option_0_requires_a_value_of_type_1, "extends", "string")); } else { - extendedConfigPath = getExtendsConfigPath(json.extends, host, basePath, getCanonicalFileName, errors, createCompilerDiagnostic); + const newBase = configFileName ? getDirectoryPath(toPath(configFileName, basePath, getCanonicalFileName)) : basePath; + extendedConfigPath = getExtendsConfigPath(json.extends, host, newBase, getCanonicalFileName, errors, createCompilerDiagnostic); } } return { raw: json, options, typeAcquisition, extendedConfigPath }; @@ -1582,7 +1589,7 @@ namespace ts { host: ParseConfigHost, basePath: string, getCanonicalFileName: (fileName: string) => string, - configFileName: string, + configFileName: string | undefined, errors: Push ): ParsedTsconfig { const options = getDefaultCompilerOptions(configFileName); @@ -1603,10 +1610,11 @@ namespace ts { onSetValidOptionKeyValueInRoot(key: string, _keyNode: PropertyName, value: CompilerOptionsValue, valueNode: Expression) { switch (key) { case "extends": + const newBase = configFileName ? getDirectoryPath(toPath(configFileName, basePath, getCanonicalFileName)) : basePath; extendedConfigPath = getExtendsConfigPath( value, host, - basePath, + newBase, getCanonicalFileName, errors, (message, arg0) => @@ -1803,6 +1811,7 @@ namespace ts { } function normalizeOptionValue(option: CommandLineOption, basePath: string, value: any): CompilerOptionsValue { + if (isNullOrUndefined(value)) return undefined; if (option.type === "list") { const listOption = option; if (listOption.element.isFilePath || typeof listOption.element.type !== "string") { @@ -1827,6 +1836,7 @@ namespace ts { } function convertJsonOptionOfCustomType(opt: CommandLineOptionOfCustomType, value: string, errors: Push) { + if (isNullOrUndefined(value)) return undefined; const key = value.toLowerCase(); const val = opt.type.get(key); if (val !== undefined) { @@ -1977,7 +1987,7 @@ namespace ts { // remove a literal file. if (fileNames) { for (const fileName of fileNames) { - const file = combinePaths(basePath, fileName); + const file = getNormalizedAbsolutePath(fileName, basePath); literalFileMap.set(keyMapper(file), file); } } diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 9d5bbf5b08e..b9d8d7a6319 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -3583,7 +3583,7 @@ namespace ts { name: string; } - export type CompilerOptionsValue = string | number | boolean | (string | number)[] | string[] | MapLike | PluginImport[]; + export type CompilerOptionsValue = string | number | boolean | (string | number)[] | string[] | MapLike | PluginImport[] | null | undefined; export interface CompilerOptions { /*@internal*/ all?: boolean; diff --git a/src/harness/unittests/configurationExtension.ts b/src/harness/unittests/configurationExtension.ts index 2d50d2cb2af..b46d98f1524 100644 --- a/src/harness/unittests/configurationExtension.ts +++ b/src/harness/unittests/configurationExtension.ts @@ -78,6 +78,23 @@ namespace ts { }, include: ["../supplemental.*"] }, + "/dev/configs/third.json": { + extends: "./second", + compilerOptions: { + // tslint:disable-next-line:no-null-keyword + module: null + }, + include: ["../supplemental.*"] + }, + "/dev/configs/fourth.json": { + extends: "./third", + compilerOptions: { + module: "system" + }, + // tslint:disable-next-line:no-null-keyword + include: null, + files: ["../main.ts"] + }, "/dev/extends.json": { extends: 42 }, "/dev/extends2.json": { extends: "configs/base" }, "/dev/main.ts": "", @@ -106,7 +123,7 @@ namespace ts { } } - describe("Configuration Extension", () => { + describe("configurationExtension", () => { forEach<[string, string, Utils.MockParseConfigHost], void>([ ["under a case insensitive host", caseInsensitiveBasePath, caseInsensitiveHost], ["under a case sensitive host", caseSensitiveBasePath, caseSensitiveHost] @@ -206,6 +223,24 @@ namespace ts { category: DiagnosticCategory.Error, messageText: `A path in an 'extends' option must be relative or rooted, but 'configs/base' is not.` }]); + + testSuccess("can overwrite compiler options using extended 'null'", "configs/third.json", { + allowJs: true, + noImplicitAny: true, + strictNullChecks: true, + module: undefined // Technically, this is distinct from the key never being set; but within the compiler we don't make the distinction + }, [ + combinePaths(basePath, "supplemental.ts") + ]); + + testSuccess("can overwrite top-level options using extended 'null'", "configs/fourth.json", { + allowJs: true, + noImplicitAny: true, + strictNullChecks: true, + module: ModuleKind.System + }, [ + combinePaths(basePath, "main.ts") + ]); }); }); }); From 53b5abe5bbb88edaaa6634999e7f1c6480262b63 Mon Sep 17 00:00:00 2001 From: Andy Date: Thu, 7 Sep 2017 07:19:00 -0700 Subject: [PATCH 237/370] Update `fromCodeFixContext` (#18290) --- .../correctQualifiedNameToIndexedAccessType.ts | 2 +- src/services/codefixes/fixAddMissingMember.ts | 10 +++++----- .../codefixes/fixClassSuperMustPrecedeThisAccess.ts | 2 +- .../codefixes/fixConstructorForDerivedNeedSuperCall.ts | 2 +- .../codefixes/fixExtendsInterfaceBecomesImplements.ts | 2 +- .../codefixes/fixForgottenThisPropertyAccess.ts | 2 +- src/services/codefixes/fixUnusedIdentifier.ts | 10 +++++----- src/services/codefixes/helpers.ts | 2 +- src/services/codefixes/importFixes.ts | 2 +- src/services/refactors/convertFunctionToEs6Class.ts | 2 +- src/services/refactors/extractMethod.ts | 2 +- src/services/textChanges.ts | 2 +- 12 files changed, 20 insertions(+), 20 deletions(-) diff --git a/src/services/codefixes/correctQualifiedNameToIndexedAccessType.ts b/src/services/codefixes/correctQualifiedNameToIndexedAccessType.ts index 3087d73276d..e18190d6f6a 100644 --- a/src/services/codefixes/correctQualifiedNameToIndexedAccessType.ts +++ b/src/services/codefixes/correctQualifiedNameToIndexedAccessType.ts @@ -15,7 +15,7 @@ namespace ts.codefix { const replacement = createIndexedAccessTypeNode( createTypeReferenceNode(qualifiedName.left, /*typeArguments*/ undefined), createLiteralTypeNode(createLiteral(rightText))); - const changeTracker = textChanges.ChangeTracker.fromCodeFixContext(context); + const changeTracker = textChanges.ChangeTracker.fromContext(context); changeTracker.replaceNode(sourceFile, qualifiedName, replacement); return [{ diff --git a/src/services/codefixes/fixAddMissingMember.ts b/src/services/codefixes/fixAddMissingMember.ts index 1587b47c01b..97e209fe89a 100644 --- a/src/services/codefixes/fixAddMissingMember.ts +++ b/src/services/codefixes/fixAddMissingMember.ts @@ -87,7 +87,7 @@ namespace ts.codefix { createPropertyAccess(createIdentifier(className), tokenName), createIdentifier("undefined"))); - const staticInitializationChangeTracker = textChanges.ChangeTracker.fromCodeFixContext(context); + const staticInitializationChangeTracker = textChanges.ChangeTracker.fromContext(context); staticInitializationChangeTracker.insertNodeAfter( classDeclarationSourceFile, classDeclaration, @@ -111,7 +111,7 @@ namespace ts.codefix { createPropertyAccess(createThis(), tokenName), createIdentifier("undefined"))); - const propertyInitializationChangeTracker = textChanges.ChangeTracker.fromCodeFixContext(context); + const propertyInitializationChangeTracker = textChanges.ChangeTracker.fromContext(context); propertyInitializationChangeTracker.insertNodeAt( classDeclarationSourceFile, classConstructor.body.getEnd() - 1, @@ -153,7 +153,7 @@ namespace ts.codefix { /*questionToken*/ undefined, typeNode, /*initializer*/ undefined); - const propertyChangeTracker = textChanges.ChangeTracker.fromCodeFixContext(context); + const propertyChangeTracker = textChanges.ChangeTracker.fromContext(context); propertyChangeTracker.insertNodeAfter(classDeclarationSourceFile, classOpenBrace, property, { suffix: context.newLineCharacter }); (actions || (actions = [])).push({ @@ -178,7 +178,7 @@ namespace ts.codefix { [indexingParameter], typeNode); - const indexSignatureChangeTracker = textChanges.ChangeTracker.fromCodeFixContext(context); + const indexSignatureChangeTracker = textChanges.ChangeTracker.fromContext(context); indexSignatureChangeTracker.insertNodeAfter(classDeclarationSourceFile, classOpenBrace, indexSignature, { suffix: context.newLineCharacter }); actions.push({ @@ -195,7 +195,7 @@ namespace ts.codefix { const callExpression = token.parent.parent; const methodDeclaration = createMethodFromCallExpression(callExpression, tokenName, includeTypeScriptSyntax, makeStatic); - const methodDeclarationChangeTracker = textChanges.ChangeTracker.fromCodeFixContext(context); + const methodDeclarationChangeTracker = textChanges.ChangeTracker.fromContext(context); methodDeclarationChangeTracker.insertNodeAfter(classDeclarationSourceFile, classOpenBrace, methodDeclaration, { suffix: context.newLineCharacter }); return { description: formatStringFromArgs(getLocaleSpecificMessage(makeStatic ? diff --git a/src/services/codefixes/fixClassSuperMustPrecedeThisAccess.ts b/src/services/codefixes/fixClassSuperMustPrecedeThisAccess.ts index 937afee340e..bc92cd8e0d1 100644 --- a/src/services/codefixes/fixClassSuperMustPrecedeThisAccess.ts +++ b/src/services/codefixes/fixClassSuperMustPrecedeThisAccess.ts @@ -26,7 +26,7 @@ namespace ts.codefix { } } } - const changeTracker = textChanges.ChangeTracker.fromCodeFixContext(context); + const changeTracker = textChanges.ChangeTracker.fromContext(context); changeTracker.insertNodeAfter(sourceFile, getOpenBrace(constructor, sourceFile), superCall, { suffix: context.newLineCharacter }); changeTracker.deleteNode(sourceFile, superCall); diff --git a/src/services/codefixes/fixConstructorForDerivedNeedSuperCall.ts b/src/services/codefixes/fixConstructorForDerivedNeedSuperCall.ts index 517a79e39bd..24f44a877b3 100644 --- a/src/services/codefixes/fixConstructorForDerivedNeedSuperCall.ts +++ b/src/services/codefixes/fixConstructorForDerivedNeedSuperCall.ts @@ -10,7 +10,7 @@ namespace ts.codefix { return undefined; } - const changeTracker = textChanges.ChangeTracker.fromCodeFixContext(context); + const changeTracker = textChanges.ChangeTracker.fromContext(context); const superCall = createStatement(createCall(createSuper(), /*typeArguments*/ undefined, /*argumentsArray*/ emptyArray)); changeTracker.insertNodeAfter(sourceFile, getOpenBrace(token.parent, sourceFile), superCall, { suffix: context.newLineCharacter }); diff --git a/src/services/codefixes/fixExtendsInterfaceBecomesImplements.ts b/src/services/codefixes/fixExtendsInterfaceBecomesImplements.ts index d23f61d0f92..57bf2dd2795 100644 --- a/src/services/codefixes/fixExtendsInterfaceBecomesImplements.ts +++ b/src/services/codefixes/fixExtendsInterfaceBecomesImplements.ts @@ -21,7 +21,7 @@ namespace ts.codefix { return undefined; } - const changeTracker = textChanges.ChangeTracker.fromCodeFixContext(context); + const changeTracker = textChanges.ChangeTracker.fromContext(context); changeTracker.replaceNode(sourceFile, extendsToken, createToken(SyntaxKind.ImplementsKeyword)); // We replace existing keywords with commas. diff --git a/src/services/codefixes/fixForgottenThisPropertyAccess.ts b/src/services/codefixes/fixForgottenThisPropertyAccess.ts index 6925b557755..5ac4f035f73 100644 --- a/src/services/codefixes/fixForgottenThisPropertyAccess.ts +++ b/src/services/codefixes/fixForgottenThisPropertyAccess.ts @@ -8,7 +8,7 @@ namespace ts.codefix { if (token.kind !== SyntaxKind.Identifier) { return undefined; } - const changeTracker = textChanges.ChangeTracker.fromCodeFixContext(context); + const changeTracker = textChanges.ChangeTracker.fromContext(context); changeTracker.replaceNode(sourceFile, token, createPropertyAccess(createThis(), token)); return [{ diff --git a/src/services/codefixes/fixUnusedIdentifier.ts b/src/services/codefixes/fixUnusedIdentifier.ts index 18491aaba26..530a4543ec4 100644 --- a/src/services/codefixes/fixUnusedIdentifier.ts +++ b/src/services/codefixes/fixUnusedIdentifier.ts @@ -175,23 +175,23 @@ namespace ts.codefix { } function deleteNode(n: Node) { - return makeChange(textChanges.ChangeTracker.fromCodeFixContext(context).deleteNode(sourceFile, n)); + return makeChange(textChanges.ChangeTracker.fromContext(context).deleteNode(sourceFile, n)); } function deleteRange(range: TextRange) { - return makeChange(textChanges.ChangeTracker.fromCodeFixContext(context).deleteRange(sourceFile, range)); + return makeChange(textChanges.ChangeTracker.fromContext(context).deleteRange(sourceFile, range)); } function deleteNodeInList(n: Node) { - return makeChange(textChanges.ChangeTracker.fromCodeFixContext(context).deleteNodeInList(sourceFile, n)); + return makeChange(textChanges.ChangeTracker.fromContext(context).deleteNodeInList(sourceFile, n)); } function deleteNodeRange(start: Node, end: Node) { - return makeChange(textChanges.ChangeTracker.fromCodeFixContext(context).deleteNodeRange(sourceFile, start, end)); + return makeChange(textChanges.ChangeTracker.fromContext(context).deleteNodeRange(sourceFile, start, end)); } function replaceNode(n: Node, newNode: Node) { - return makeChange(textChanges.ChangeTracker.fromCodeFixContext(context).replaceNode(sourceFile, n, newNode)); + return makeChange(textChanges.ChangeTracker.fromContext(context).replaceNode(sourceFile, n, newNode)); } function makeChange(changeTracker: textChanges.ChangeTracker): CodeAction { diff --git a/src/services/codefixes/helpers.ts b/src/services/codefixes/helpers.ts index 7b69e12a19a..685c6832f13 100644 --- a/src/services/codefixes/helpers.ts +++ b/src/services/codefixes/helpers.ts @@ -4,7 +4,7 @@ namespace ts.codefix { export function newNodesToChanges(newNodes: Node[], insertAfter: Node, context: CodeFixContext) { const sourceFile = context.sourceFile; - const changeTracker = textChanges.ChangeTracker.fromCodeFixContext(context); + const changeTracker = textChanges.ChangeTracker.fromContext(context); for (const newNode of newNodes) { changeTracker.insertNodeAfter(sourceFile, insertAfter, newNode, { suffix: context.newLineCharacter }); diff --git a/src/services/codefixes/importFixes.ts b/src/services/codefixes/importFixes.ts index d0b52184031..99b677ebd3d 100644 --- a/src/services/codefixes/importFixes.ts +++ b/src/services/codefixes/importFixes.ts @@ -692,7 +692,7 @@ namespace ts.codefix { } function createChangeTracker() { - return textChanges.ChangeTracker.fromCodeFixContext(context); + return textChanges.ChangeTracker.fromContext(context); } function createCodeAction( diff --git a/src/services/refactors/convertFunctionToEs6Class.ts b/src/services/refactors/convertFunctionToEs6Class.ts index bf0e4e22658..40ef4ed2a2e 100644 --- a/src/services/refactors/convertFunctionToEs6Class.ts +++ b/src/services/refactors/convertFunctionToEs6Class.ts @@ -63,7 +63,7 @@ namespace ts.refactor.convertFunctionToES6Class { } const ctorDeclaration = ctorSymbol.valueDeclaration; - const changeTracker = textChanges.ChangeTracker.fromCodeFixContext(context as { newLineCharacter: string, rulesProvider: formatting.RulesProvider }); + const changeTracker = textChanges.ChangeTracker.fromContext(context); let precedingNode: Node; let newClassDeclaration: ClassDeclaration; diff --git a/src/services/refactors/extractMethod.ts b/src/services/refactors/extractMethod.ts index 1a96857b73e..6fe664e6c81 100644 --- a/src/services/refactors/extractMethod.ts +++ b/src/services/refactors/extractMethod.ts @@ -708,7 +708,7 @@ namespace ts.refactor.extractMethod { ); } - const changeTracker = textChanges.ChangeTracker.fromCodeFixContext(context); + const changeTracker = textChanges.ChangeTracker.fromContext(context); // insert function at the end of the scope changeTracker.insertNodeBefore(context.file, scope.getLastToken(), newFunction, { prefix: context.newLineCharacter, suffix: context.newLineCharacter }); diff --git a/src/services/textChanges.ts b/src/services/textChanges.ts index 6462b64e226..7909d2d3adb 100644 --- a/src/services/textChanges.ts +++ b/src/services/textChanges.ts @@ -186,7 +186,7 @@ namespace ts.textChanges { private changes: Change[] = []; private readonly newLineCharacter: string; - public static fromCodeFixContext(context: { newLineCharacter: string, rulesProvider?: formatting.RulesProvider }) { + public static fromContext(context: RefactorContext | CodeFixContext) { return new ChangeTracker(getNewlineKind(context), context.rulesProvider); } From 8c714c3651c7c3b7a2a0ba37f59835bf3b68e439 Mon Sep 17 00:00:00 2001 From: Andy Date: Thu, 7 Sep 2017 07:21:47 -0700 Subject: [PATCH 238/370] Support special JS property assignments in doc comment templates (#18193) --- src/harness/fourslash.ts | 12 +- src/services/jsDoc.ts | 111 ++++++++++-------- .../docCommentTemplateClassDecl01.ts | 22 +--- .../docCommentTemplateClassDeclMethods01.ts | 32 ++--- .../docCommentTemplateClassDeclMethods02.ts | 25 +--- .../docCommentTemplateConstructor01.ts | 22 +--- .../fourslash/docCommentTemplateEmptyFile.ts | 3 +- ...ocCommentTemplateFunctionWithParameters.ts | 6 +- .../docCommentTemplateInMultiLineComment.ts | 3 +- .../docCommentTemplateInSingleLineComment.ts | 4 +- .../docCommentTemplateIndentation.ts | 11 +- ...ommentTemplateInsideFunctionDeclaration.ts | 4 +- ...mentTemplateJsSpecialPropertyAssignment.ts | 20 ++++ ...ocCommentTemplateNamespacesAndModules01.ts | 30 +---- ...ocCommentTemplateNamespacesAndModules02.ts | 28 +---- ...ocCommentTemplateObjectLiteralMethods01.ts | 23 +--- .../fourslash/docCommentTemplateRegex.ts | 4 +- .../docCommentTemplateVariableStatements01.ts | 32 ++--- .../docCommentTemplateVariableStatements02.ts | 24 +--- .../docCommentTemplateVariableStatements03.ts | 46 +++----- tests/cases/fourslash/fourslash.ts | 4 +- 21 files changed, 157 insertions(+), 309 deletions(-) create mode 100644 tests/cases/fourslash/docCommentTemplateJsSpecialPropertyAssignment.ts diff --git a/src/harness/fourslash.ts b/src/harness/fourslash.ts index c224fd210ea..598cfc2fd7e 100644 --- a/src/harness/fourslash.ts +++ b/src/harness/fourslash.ts @@ -2414,7 +2414,7 @@ namespace FourSlash { } } - public verifyDocCommentTemplate(expected?: ts.TextInsertion) { + public verifyDocCommentTemplate(expected: ts.TextInsertion | undefined) { const name = "verifyDocCommentTemplate"; const actual = this.languageService.getDocCommentTemplateAtPosition(this.activeFile.fileName, this.currentCaretPosition); @@ -3908,12 +3908,14 @@ namespace FourSlashInterface { this.state.verifyNoMatchingBracePosition(bracePosition); } - public DocCommentTemplate(expectedText: string, expectedOffset: number, empty?: boolean) { - this.state.verifyDocCommentTemplate(empty ? undefined : { newText: expectedText, caretOffset: expectedOffset }); + public docCommentTemplateAt(marker: string | FourSlash.Marker, expectedOffset: number, expectedText: string) { + this.state.goToMarker(marker); + this.state.verifyDocCommentTemplate({ newText: expectedText.replace(/\r?\n/g, "\r\n"), caretOffset: expectedOffset }); } - public noDocCommentTemplate() { - this.DocCommentTemplate(/*expectedText*/ undefined, /*expectedOffset*/ undefined, /*empty*/ true); + public noDocCommentTemplateAt(marker: string | FourSlash.Marker) { + this.state.goToMarker(marker); + this.state.verifyDocCommentTemplate(/*expected*/ undefined); } public rangeAfterCodeFix(expectedText: string, includeWhiteSpace?: boolean, errorCode?: number, index?: number): void { diff --git a/src/services/jsDoc.ts b/src/services/jsDoc.ts index ee3ae7c868f..a135a9e8eef 100644 --- a/src/services/jsDoc.ts +++ b/src/services/jsDoc.ts @@ -173,38 +173,15 @@ namespace ts.JsDoc { return undefined; } - // TODO: add support for: - // - enums/enum members - // - interfaces - // - property declarations - // - potentially property assignments - let commentOwner: Node; - findOwner: for (commentOwner = tokenAtPos; commentOwner; commentOwner = commentOwner.parent) { - switch (commentOwner.kind) { - case SyntaxKind.FunctionDeclaration: - case SyntaxKind.MethodDeclaration: - case SyntaxKind.Constructor: - case SyntaxKind.ClassDeclaration: - case SyntaxKind.VariableStatement: - break findOwner; - case SyntaxKind.SourceFile: - return undefined; - case SyntaxKind.ModuleDeclaration: - // If in walking up the tree, we hit a a nested namespace declaration, - // then we must be somewhere within a dotted namespace name; however we don't - // want to give back a JSDoc template for the 'b' or 'c' in 'namespace a.b.c { }'. - if (commentOwner.parent.kind === SyntaxKind.ModuleDeclaration) { - return undefined; - } - break findOwner; - } + const commentOwnerInfo = getCommentOwnerInfo(tokenAtPos); + if (!commentOwnerInfo) { + return undefined; } - - if (!commentOwner || commentOwner.getStart() < position) { + const { commentOwner, parameters } = commentOwnerInfo; + if (commentOwner.getStart() < position) { return undefined; } - const parameters = getParametersForJsDocOwningNode(commentOwner); const posLineAndChar = sourceFile.getLineAndCharacterOfPosition(position); const lineStart = sourceFile.getLineStarts()[posLineAndChar.line]; @@ -213,16 +190,18 @@ namespace ts.JsDoc { const isJavaScriptFile = hasJavaScriptFileExtension(sourceFile.fileName); let docParams = ""; - for (let i = 0; i < parameters.length; i++) { - const currentName = parameters[i].name; - const paramName = currentName.kind === SyntaxKind.Identifier ? - (currentName).escapedText : - "param" + i; - if (isJavaScriptFile) { - docParams += `${indentationStr} * @param {any} ${paramName}${newLine}`; - } - else { - docParams += `${indentationStr} * @param ${paramName}${newLine}`; + if (parameters) { + for (let i = 0; i < parameters.length; i++) { + const currentName = parameters[i].name; + const paramName = currentName.kind === SyntaxKind.Identifier ? + (currentName).escapedText : + "param" + i; + if (isJavaScriptFile) { + docParams += `${indentationStr} * @param {any} ${paramName}${newLine}`; + } + else { + docParams += `${indentationStr} * @param ${paramName}${newLine}`; + } } } @@ -244,21 +223,55 @@ namespace ts.JsDoc { return { newText: result, caretOffset: preamble.length }; } - function getParametersForJsDocOwningNode(commentOwner: Node): ReadonlyArray { - if (isFunctionLike(commentOwner)) { - return commentOwner.parameters; - } + interface CommentOwnerInfo { + readonly commentOwner: Node; + readonly parameters?: ReadonlyArray; + } + function getCommentOwnerInfo(tokenAtPos: Node): CommentOwnerInfo | undefined { + // TODO: add support for: + // - enums/enum members + // - interfaces + // - property declarations + // - potentially property assignments + for (let commentOwner = tokenAtPos; commentOwner; commentOwner = commentOwner.parent) { + switch (commentOwner.kind) { + case SyntaxKind.FunctionDeclaration: + case SyntaxKind.MethodDeclaration: + case SyntaxKind.Constructor: + const { parameters } = commentOwner as FunctionDeclaration | MethodDeclaration | ConstructorDeclaration; + return { commentOwner, parameters }; - if (commentOwner.kind === SyntaxKind.VariableStatement) { - const varStatement = commentOwner; - const varDeclarations = varStatement.declarationList.declarations; + case SyntaxKind.ClassDeclaration: + return { commentOwner }; - if (varDeclarations.length === 1 && varDeclarations[0].initializer) { - return getParametersFromRightHandSideOfAssignment(varDeclarations[0].initializer); + case SyntaxKind.VariableStatement: { + const varStatement = commentOwner; + const varDeclarations = varStatement.declarationList.declarations; + const parameters = varDeclarations.length === 1 && varDeclarations[0].initializer + ? getParametersFromRightHandSideOfAssignment(varDeclarations[0].initializer) + : undefined; + return { commentOwner, parameters }; + } + + case SyntaxKind.SourceFile: + return undefined; + + case SyntaxKind.ModuleDeclaration: + // If in walking up the tree, we hit a a nested namespace declaration, + // then we must be somewhere within a dotted namespace name; however we don't + // want to give back a JSDoc template for the 'b' or 'c' in 'namespace a.b.c { }'. + return commentOwner.parent.kind === SyntaxKind.ModuleDeclaration ? undefined : { commentOwner }; + + case SyntaxKind.BinaryExpression: { + const be = commentOwner as BinaryExpression; + if (getSpecialPropertyAssignmentKind(be) === ts.SpecialPropertyAssignmentKind.None) { + return undefined; + } + const parameters = isFunctionLike(be.right) ? be.right.parameters : emptyArray; + return { commentOwner, parameters }; + } } } - - return emptyArray; } /** diff --git a/tests/cases/fourslash/docCommentTemplateClassDecl01.ts b/tests/cases/fourslash/docCommentTemplateClassDecl01.ts index 958a8c60fa4..5a96f20d2e2 100644 --- a/tests/cases/fourslash/docCommentTemplateClassDecl01.ts +++ b/tests/cases/fourslash/docCommentTemplateClassDecl01.ts @@ -1,23 +1,5 @@ /// -const CRLF = "\r\n"; -/** - * @returns the given value with '\n' normalized to '\r\n' and with no leading newline - */ -function useCRLFAndStripLeadingNewline(str: string): string { - str = str.replace(/\r?\n/g, CRLF); - if (str.indexOf(CRLF) === 0) { - str = str.slice(CRLF.length); - } - return str; -} - -function confirmNormalizedJsDoc(markerName: string, newTextOffset: number, template: string): void { - goTo.marker(markerName); - const normalized = useCRLFAndStripLeadingNewline(template); - verify.DocCommentTemplate(normalized, newTextOffset); -} - /////*decl*/class C { //// private p; //// constructor(a, b, c, d); @@ -29,8 +11,8 @@ function confirmNormalizedJsDoc(markerName: string, newTextOffset: number, templ //// } ////} -confirmNormalizedJsDoc("decl", /*newTextOffset*/ 8, ` -/** +verify.docCommentTemplateAt("decl", /*newTextOffset*/ 8, +`/** * */ `); diff --git a/tests/cases/fourslash/docCommentTemplateClassDeclMethods01.ts b/tests/cases/fourslash/docCommentTemplateClassDeclMethods01.ts index da407b632ef..ef4c82e7df7 100644 --- a/tests/cases/fourslash/docCommentTemplateClassDeclMethods01.ts +++ b/tests/cases/fourslash/docCommentTemplateClassDeclMethods01.ts @@ -1,23 +1,5 @@ /// -const CRLF = "\r\n"; -/** - * @returns the given value with '\n' normalized to '\r\n' and with no leading newline - */ -function useCRLFAndStripLeadingNewline(str: string): string { - str = str.replace(/\r?\n/g, CRLF); - if (str.indexOf(CRLF) === 0) { - str = str.slice(CRLF.length); - } - return str; -} - -function confirmNormalizedJsDoc(markerName: string, indentation: number, template: string): void { - goTo.marker(markerName); - const normalized = useCRLFAndStripLeadingNewline(template); - verify.DocCommentTemplate(normalized, indentation); -} - const enum Indentation { Standard = 8, Indented = 12, @@ -34,26 +16,26 @@ const enum Indentation { //// } ////} -confirmNormalizedJsDoc("0", Indentation.Standard, ` -/** +verify.docCommentTemplateAt("0", Indentation.Standard, +`/** * */`); -confirmNormalizedJsDoc("1", Indentation.Indented, +verify.docCommentTemplateAt("1", Indentation.Indented, `/** * */`); -confirmNormalizedJsDoc("2", Indentation.Indented, +verify.docCommentTemplateAt("2", Indentation.Indented, `/** * * @param a */ `); -confirmNormalizedJsDoc("3", Indentation.Indented, +verify.docCommentTemplateAt("3", Indentation.Indented, `/** * * @param a @@ -61,7 +43,7 @@ confirmNormalizedJsDoc("3", Indentation.Indented, */ `); -confirmNormalizedJsDoc("4", Indentation.Indented, +verify.docCommentTemplateAt("4", Indentation.Indented, `/** * * @param a @@ -69,7 +51,7 @@ confirmNormalizedJsDoc("4", Indentation.Indented, * @param param2 */`); -confirmNormalizedJsDoc("5", Indentation.Indented, +verify.docCommentTemplateAt("5", Indentation.Indented, `/** * * @param a diff --git a/tests/cases/fourslash/docCommentTemplateClassDeclMethods02.ts b/tests/cases/fourslash/docCommentTemplateClassDeclMethods02.ts index 99392cf3855..28da24d381a 100644 --- a/tests/cases/fourslash/docCommentTemplateClassDeclMethods02.ts +++ b/tests/cases/fourslash/docCommentTemplateClassDeclMethods02.ts @@ -1,28 +1,9 @@ /// -const CRLF = "\r\n"; -/** - * @returns the given value with '\n' normalized to '\r\n' and with no leading newline - */ -function useCRLFAndStripLeadingNewline(str: string): string { - str = str.replace(/\r?\n/g, CRLF); - if (str.indexOf(CRLF) === 0) { - str = str.slice(CRLF.length); - } - return str; -} - -function confirmNormalizedJsDoc(markerName: string, indentation: number, template: string): void { - goTo.marker(markerName); - const normalized = useCRLFAndStripLeadingNewline(template); - verify.DocCommentTemplate(normalized, indentation); -} - const enum Indentation { Indented = 12, } - ////class C { //// /*0*/ //// [Symbol.iterator]() { @@ -32,15 +13,15 @@ const enum Indentation { //// [1 + 2 + 3 + Math.rand()](x: number, y: string, z = true) { } ////} -confirmNormalizedJsDoc("0", Indentation.Indented, +verify.docCommentTemplateAt("0", Indentation.Indented, `/** * */`); -confirmNormalizedJsDoc("1", Indentation.Indented, +verify.docCommentTemplateAt("1", Indentation.Indented, `/** * * @param x * @param y * @param z - */`); \ No newline at end of file + */`); diff --git a/tests/cases/fourslash/docCommentTemplateConstructor01.ts b/tests/cases/fourslash/docCommentTemplateConstructor01.ts index b26ece7a5e6..6c9eedb773d 100644 --- a/tests/cases/fourslash/docCommentTemplateConstructor01.ts +++ b/tests/cases/fourslash/docCommentTemplateConstructor01.ts @@ -1,23 +1,5 @@ /// -const CRLF = "\r\n"; -/** - * @returns the given value with '\n' normalized to '\r\n' and with no leading newline - */ -function useCRLFAndStripLeadingNewline(str: string): string { - str = str.replace(/\r?\n/g, CRLF); - if (str.indexOf(CRLF) === 0) { - str = str.slice(CRLF.length); - } - return str; -} - -function confirmNormalizedJsDoc(markerName: string, newTextOffset: number, template: string): void { - goTo.marker(markerName); - const normalized = useCRLFAndStripLeadingNewline(template); - verify.DocCommentTemplate(normalized, newTextOffset); -} - ////class C { //// private p; //// /*0*/ @@ -32,7 +14,7 @@ function confirmNormalizedJsDoc(markerName: string, newTextOffset: number, templ ////} const newTextOffset = 12; -confirmNormalizedJsDoc("0", /*newTextOffset*/ newTextOffset, +verify.docCommentTemplateAt("0", /*newTextOffset*/ newTextOffset, `/** * * @param a @@ -41,7 +23,7 @@ confirmNormalizedJsDoc("0", /*newTextOffset*/ newTextOffset, * @param d */`); -confirmNormalizedJsDoc("1", /*newTextOffset*/ newTextOffset, +verify.docCommentTemplateAt("1", /*newTextOffset*/ newTextOffset, `/** * * @param a diff --git a/tests/cases/fourslash/docCommentTemplateEmptyFile.ts b/tests/cases/fourslash/docCommentTemplateEmptyFile.ts index 76e888ea2cb..f04653dc328 100644 --- a/tests/cases/fourslash/docCommentTemplateEmptyFile.ts +++ b/tests/cases/fourslash/docCommentTemplateEmptyFile.ts @@ -3,5 +3,4 @@ // @Filename: emptyFile.ts /////*0*/ -goTo.marker("0"); -verify.noDocCommentTemplate(); \ No newline at end of file +verify.noDocCommentTemplateAt("0"); diff --git a/tests/cases/fourslash/docCommentTemplateFunctionWithParameters.ts b/tests/cases/fourslash/docCommentTemplateFunctionWithParameters.ts index f4410d5d454..b1955d98417 100644 --- a/tests/cases/fourslash/docCommentTemplateFunctionWithParameters.ts +++ b/tests/cases/fourslash/docCommentTemplateFunctionWithParameters.ts @@ -11,7 +11,5 @@ const noIndentOffset = 8; const oneIndentOffset = noIndentOffset + 4; goTo.marker("0"); -verify.DocCommentTemplate(noIndentScaffolding, noIndentOffset); - -goTo.marker("1"); -verify.DocCommentTemplate(oneIndentScaffolding, oneIndentOffset); \ No newline at end of file +verify.docCommentTemplateAt("0", noIndentOffset, noIndentScaffolding); +verify.docCommentTemplateAt("1", oneIndentOffset, oneIndentScaffolding); diff --git a/tests/cases/fourslash/docCommentTemplateInMultiLineComment.ts b/tests/cases/fourslash/docCommentTemplateInMultiLineComment.ts index 131f722a9af..6e749782c7d 100644 --- a/tests/cases/fourslash/docCommentTemplateInMultiLineComment.ts +++ b/tests/cases/fourslash/docCommentTemplateInMultiLineComment.ts @@ -3,5 +3,4 @@ // @Filename: justAComment.ts //// /* /*0*/ */ -goTo.marker("0"); -verify.noDocCommentTemplate(); \ No newline at end of file +verify.noDocCommentTemplateAt("0"); diff --git a/tests/cases/fourslash/docCommentTemplateInSingleLineComment.ts b/tests/cases/fourslash/docCommentTemplateInSingleLineComment.ts index 65e9c17014e..b60fff2d590 100644 --- a/tests/cases/fourslash/docCommentTemplateInSingleLineComment.ts +++ b/tests/cases/fourslash/docCommentTemplateInSingleLineComment.ts @@ -8,4 +8,6 @@ //// // We also want to check EOF handling at the end of a comment //// // /*2*/ -goTo.eachMarker(() => verify.noDocCommentTemplate()); +for (const marker of test.markers()) { + verify.noDocCommentTemplateAt(marker); +} diff --git a/tests/cases/fourslash/docCommentTemplateIndentation.ts b/tests/cases/fourslash/docCommentTemplateIndentation.ts index 3f84a73b81f..c3015a6d9dd 100644 --- a/tests/cases/fourslash/docCommentTemplateIndentation.ts +++ b/tests/cases/fourslash/docCommentTemplateIndentation.ts @@ -12,11 +12,6 @@ const noIndentOffset = 8; const oneIndentOffset = noIndentOffset + 4; const twoIndentOffset = oneIndentOffset + 4; -goTo.marker("0"); -verify.DocCommentTemplate(noIndentEmptyScaffolding, noIndentOffset); - -goTo.marker("1"); -verify.DocCommentTemplate(oneIndentEmptyScaffolding, oneIndentOffset); - -goTo.marker("2"); -verify.DocCommentTemplate(twoIndentEmptyScaffolding, twoIndentOffset); +verify.docCommentTemplateAt("0", noIndentOffset, noIndentEmptyScaffolding); +verify.docCommentTemplateAt("1", oneIndentOffset, oneIndentEmptyScaffolding); +verify.docCommentTemplateAt("2", twoIndentOffset, twoIndentEmptyScaffolding); diff --git a/tests/cases/fourslash/docCommentTemplateInsideFunctionDeclaration.ts b/tests/cases/fourslash/docCommentTemplateInsideFunctionDeclaration.ts index dd58a1bfd5f..e0ebc00dc39 100644 --- a/tests/cases/fourslash/docCommentTemplateInsideFunctionDeclaration.ts +++ b/tests/cases/fourslash/docCommentTemplateInsideFunctionDeclaration.ts @@ -3,4 +3,6 @@ // @Filename: functionDecl.ts ////f/*0*/unction /*1*/foo/*2*/(/*3*/) /*4*/{ /*5*/} -goTo.eachMarker(() => verify.noDocCommentTemplate()); +for (const marker of test.markers()) { + verify.noDocCommentTemplateAt(marker); +} diff --git a/tests/cases/fourslash/docCommentTemplateJsSpecialPropertyAssignment.ts b/tests/cases/fourslash/docCommentTemplateJsSpecialPropertyAssignment.ts new file mode 100644 index 00000000000..6a15ce133e4 --- /dev/null +++ b/tests/cases/fourslash/docCommentTemplateJsSpecialPropertyAssignment.ts @@ -0,0 +1,20 @@ +/// + +// @Filename: /a.js +/////*0*/module.exports = function(a) {}; +////const myNamespace = {}; +/////*1*/myNamespace.myExport = function(x) {}; + +verify.docCommentTemplateAt("0", 8, +`/** + * + * @param {any} a + */ +`); + +verify.docCommentTemplateAt("1", 8, +`/** + * + * @param {any} x + */ +`); diff --git a/tests/cases/fourslash/docCommentTemplateNamespacesAndModules01.ts b/tests/cases/fourslash/docCommentTemplateNamespacesAndModules01.ts index 4d9fb987be5..e7e52fd5e94 100644 --- a/tests/cases/fourslash/docCommentTemplateNamespacesAndModules01.ts +++ b/tests/cases/fourslash/docCommentTemplateNamespacesAndModules01.ts @@ -1,23 +1,5 @@ /// -const CRLF = "\r\n"; -/** - * @returns the given value with '\n' normalized to '\r\n' and with no leading newline - */ -function useCRLFAndStripLeadingNewline(str: string): string { - str = str.replace(/\r?\n/g, CRLF); - if (str.indexOf(CRLF) === 0) { - str = str.slice(CRLF.length); - } - return str; -} - -function confirmNormalizedJsDoc(markerName: string, charOffset: number, template: string): void { - goTo.marker(markerName); - const normalized = useCRLFAndStripLeadingNewline(template); - verify.DocCommentTemplate(normalized, charOffset); -} - /////*namespaceN*/ ////namespace n { ////} @@ -30,17 +12,17 @@ function confirmNormalizedJsDoc(markerName: string, charOffset: number, template ////module "ambientModule" { ////} -confirmNormalizedJsDoc("namespaceN", /*indentation*/ 8, ` -/** +verify.docCommentTemplateAt("namespaceN", /*indentation*/ 8, +`/** * */`); -confirmNormalizedJsDoc("namespaceM", /*indentation*/ 8, ` -/** +verify.docCommentTemplateAt("namespaceM", /*indentation*/ 8, +`/** * */`); -confirmNormalizedJsDoc("namespaceM", /*indentation*/ 8, ` -/** +verify.docCommentTemplateAt("namespaceM", /*indentation*/ 8, +`/** * */`); diff --git a/tests/cases/fourslash/docCommentTemplateNamespacesAndModules02.ts b/tests/cases/fourslash/docCommentTemplateNamespacesAndModules02.ts index e59b16d6163..dad2e9745a9 100644 --- a/tests/cases/fourslash/docCommentTemplateNamespacesAndModules02.ts +++ b/tests/cases/fourslash/docCommentTemplateNamespacesAndModules02.ts @@ -1,36 +1,16 @@ /// -const CRLF = "\r\n"; -/** - * @returns the given value with '\n' normalized to '\r\n' and with no leading newline - */ -function useCRLFAndStripLeadingNewline(str: string): string { - str = str.replace(/\r?\n/g, CRLF); - if (str.indexOf(CRLF) === 0) { - str = str.slice(CRLF.length); - } - return str; -} - -function confirmNormalizedJsDoc(markerName: string, charOffset: number, template: string): void { - goTo.marker(markerName); - const normalized = useCRLFAndStripLeadingNewline(template); - verify.DocCommentTemplate(normalized, charOffset); -} - /////*top*/ ////namespace n1. //// /*n2*/ n2. //// /*n3*/ n3 { ////} -confirmNormalizedJsDoc("top", /*indentation*/ 8, ` -/** +verify.docCommentTemplateAt("top", /*indentation*/ 8, +`/** * */`); -goTo.marker("n2"); -verify.noDocCommentTemplate(); +verify.noDocCommentTemplateAt("n2"); -goTo.marker("n3"); -verify.noDocCommentTemplate(); \ No newline at end of file +verify.noDocCommentTemplateAt("n3"); diff --git a/tests/cases/fourslash/docCommentTemplateObjectLiteralMethods01.ts b/tests/cases/fourslash/docCommentTemplateObjectLiteralMethods01.ts index 4af1b60c698..2ae77d4afac 100644 --- a/tests/cases/fourslash/docCommentTemplateObjectLiteralMethods01.ts +++ b/tests/cases/fourslash/docCommentTemplateObjectLiteralMethods01.ts @@ -1,28 +1,9 @@ /// -const CRLF = "\r\n"; -/** - * @returns the given value with '\n' normalized to '\r\n' and with no leading newline - */ -function useCRLFAndStripLeadingNewline(str: string): string { - str = str.replace(/\r?\n/g, CRLF); - if (str.indexOf(CRLF) === 0) { - str = str.slice(CRLF.length); - } - return str; -} - -function confirmNormalizedJsDoc(markerName: string, indentation: number, template: string): void { - goTo.marker(markerName); - const normalized = useCRLFAndStripLeadingNewline(template); - verify.DocCommentTemplate(normalized, indentation); -} - const enum Indentation { Indented = 12, } - ////var x = { //// /*0*/ //// foo() { @@ -32,12 +13,12 @@ const enum Indentation { //// [1 + 2 + 3 + Math.rand()](x: number, y: string, z = true) { } ////} -confirmNormalizedJsDoc("0", Indentation.Indented, +verify.docCommentTemplateAt("0", Indentation.Indented, `/** * */`); -confirmNormalizedJsDoc("1", Indentation.Indented, +verify.docCommentTemplateAt("1", Indentation.Indented, `/** * * @param x diff --git a/tests/cases/fourslash/docCommentTemplateRegex.ts b/tests/cases/fourslash/docCommentTemplateRegex.ts index 62d200dee10..685c1ca5aef 100644 --- a/tests/cases/fourslash/docCommentTemplateRegex.ts +++ b/tests/cases/fourslash/docCommentTemplateRegex.ts @@ -3,4 +3,6 @@ // @Filename: regex.ts ////var regex = /*0*///*1*/asdf/*2*/ /*3*///*4*/; -goTo.eachMarker(() => verify.noDocCommentTemplate()); +for (const marker of test.markers()) { + verify.noDocCommentTemplateAt(marker); +} diff --git a/tests/cases/fourslash/docCommentTemplateVariableStatements01.ts b/tests/cases/fourslash/docCommentTemplateVariableStatements01.ts index b901919fa1f..b6243652167 100644 --- a/tests/cases/fourslash/docCommentTemplateVariableStatements01.ts +++ b/tests/cases/fourslash/docCommentTemplateVariableStatements01.ts @@ -1,23 +1,5 @@ /// -const CRLF = "\r\n"; -/** - * @returns the given value with '\n' normalized to '\r\n' and with no leading newline - */ -function useCRLFAndStripLeadingNewline(str: string): string { - str = str.replace(/\r?\n/g, CRLF); - if (str.indexOf(CRLF) === 0) { - str = str.slice(CRLF.length); - } - return str; -} - -function confirmNormalizedJsDoc(markerName: string, newTextOffset: number, template: string): void { - goTo.marker(markerName); - const normalized = useCRLFAndStripLeadingNewline(template); - verify.DocCommentTemplate(normalized, newTextOffset); -} - /////*a*/ ////var a = 10; //// @@ -46,23 +28,23 @@ function confirmNormalizedJsDoc(markerName: string, newTextOffset: number, templ //// } ////} -for (const varName of "abcd".split("")) { - confirmNormalizedJsDoc(varName, /*newTextOffset*/ 8, ` -/** +for (const varName of ["a", "b", "c", "d"]) { + verify.docCommentTemplateAt(varName, /*newTextOffset*/ 8, +`/** * */`); } -confirmNormalizedJsDoc("e", /*newTextOffset*/ 8, ` -/** +verify.docCommentTemplateAt("e", /*newTextOffset*/ 8, +`/** * * @param x * @param y * @param z */`); -confirmNormalizedJsDoc("f", /*newTextOffset*/ 8, ` -/** +verify.docCommentTemplateAt("f", /*newTextOffset*/ 8, +`/** * * @param a * @param b diff --git a/tests/cases/fourslash/docCommentTemplateVariableStatements02.ts b/tests/cases/fourslash/docCommentTemplateVariableStatements02.ts index 9339e703570..f22e361f63f 100644 --- a/tests/cases/fourslash/docCommentTemplateVariableStatements02.ts +++ b/tests/cases/fourslash/docCommentTemplateVariableStatements02.ts @@ -1,23 +1,5 @@ /// -const CRLF = "\r\n"; -/** - * @returns the given value with '\n' normalized to '\r\n' and with no leading newline - */ -function useCRLFAndStripLeadingNewline(str: string): string { - str = str.replace(/\r?\n/g, CRLF); - if (str.indexOf(CRLF) === 0) { - str = str.slice(CRLF.length); - } - return str; -} - -function confirmNormalizedJsDoc(markerName: string, newTextOffset: number, template: string): void { - goTo.marker(markerName); - const normalized = useCRLFAndStripLeadingNewline(template); - verify.DocCommentTemplate(normalized, newTextOffset); -} - /////*a*/ ////var a1 = 10, a2 = 20; //// @@ -46,9 +28,9 @@ function confirmNormalizedJsDoc(markerName: string, newTextOffset: number, templ //// bar: "20" ////}, f2 = null; -for (const varName of "abcdef".split("")) { - confirmNormalizedJsDoc(varName, /*newTextOffset*/ 8, ` -/** +for (const varName of ["a", "b", "c", "d", "e", "f"]) { + verify.docCommentTemplateAt(varName, /*newTextOffset*/ 8, +`/** * */`); } diff --git a/tests/cases/fourslash/docCommentTemplateVariableStatements03.ts b/tests/cases/fourslash/docCommentTemplateVariableStatements03.ts index e473cb798b7..195553098f0 100644 --- a/tests/cases/fourslash/docCommentTemplateVariableStatements03.ts +++ b/tests/cases/fourslash/docCommentTemplateVariableStatements03.ts @@ -1,23 +1,5 @@ /// -const CRLF = "\r\n"; -/** - * @returns the given value with '\n' normalized to '\r\n' and with no leading newline - */ -function useCRLFAndStripLeadingNewline(str: string): string { - str = str.replace(/\r?\n/g, CRLF); - if (str.indexOf(CRLF) === 0) { - str = str.slice(CRLF.length); - } - return str; -} - -function confirmNormalizedJsDoc(markerName: string, newTextOffset: number, template: string): void { - goTo.marker(markerName); - const normalized = useCRLFAndStripLeadingNewline(template); - verify.DocCommentTemplate(normalized, newTextOffset); -} - /////*a*/ ////var a = x => x //// @@ -47,44 +29,44 @@ function confirmNormalizedJsDoc(markerName: string, newTextOffset: number, templ //// } ////})) -confirmNormalizedJsDoc("a", /*newTextOffset*/ 8, ` -/** +verify.docCommentTemplateAt("a", /*newTextOffset*/ 8, +`/** * * @param x */`); -confirmNormalizedJsDoc("b", /*newTextOffset*/ 8, ` -/** +verify.docCommentTemplateAt("b", /*newTextOffset*/ 8, +`/** * * @param x * @param y * @param z */`); -confirmNormalizedJsDoc("c", /*newTextOffset*/ 8, ` -/** +verify.docCommentTemplateAt("c", /*newTextOffset*/ 8, +`/** * * @param x */`); -confirmNormalizedJsDoc("d", /*newTextOffset*/ 8, ` -/** +verify.docCommentTemplateAt("d", /*newTextOffset*/ 8, +`/** * */`); -confirmNormalizedJsDoc("e", /*newTextOffset*/ 8, ` -/** +verify.docCommentTemplateAt("e", /*newTextOffset*/ 8, +`/** * * @param param0 */`); -confirmNormalizedJsDoc("f", /*newTextOffset*/ 8, ` -/** +verify.docCommentTemplateAt("f", /*newTextOffset*/ 8, +`/** * */`); -confirmNormalizedJsDoc("g", /*newTextOffset*/ 8, ` -/** +verify.docCommentTemplateAt("g", /*newTextOffset*/ 8, +`/** * * @param x */`); \ No newline at end of file diff --git a/tests/cases/fourslash/fourslash.ts b/tests/cases/fourslash/fourslash.ts index 5150fa16ae9..119780872e9 100644 --- a/tests/cases/fourslash/fourslash.ts +++ b/tests/cases/fourslash/fourslash.ts @@ -242,8 +242,8 @@ declare namespace FourSlashInterface { todoCommentsInCurrentFile(descriptors: string[]): void; matchingBracePositionInCurrentFile(bracePosition: number, expectedMatchPosition: number): void; noMatchingBracePositionInCurrentFile(bracePosition: number): void; - DocCommentTemplate(expectedText: string, expectedOffset: number, empty?: boolean): void; - noDocCommentTemplate(): void; + docCommentTemplateAt(markerName: string | FourSlashInterface.Marker, expectedOffset: number, expectedText: string): void; + noDocCommentTemplateAt(markerName: string | FourSlashInterface.Marker): void; rangeAfterCodeFix(expectedText: string, includeWhiteSpace?: boolean, errorCode?: number, index?: number): void; fileAfterApplyingRefactorAtMarker(markerName: string, expectedContent: string, refactorNameToApply: string, actionName: string, formattingOptions?: FormatCodeOptions): void; rangeIs(expectedText: string, includeWhiteSpace?: boolean): void; From 0434fe797a0fe0b63f117dc811912e8312e62365 Mon Sep 17 00:00:00 2001 From: Andy Date: Thu, 7 Sep 2017 07:22:39 -0700 Subject: [PATCH 239/370] Get quickInfo from a contextual type if possible (#18119) --- src/compiler/types.ts | 3 ++ src/services/services.ts | 17 ++++++++++- tests/cases/fourslash/contextualTyping.ts | 28 +++++++++---------- .../fourslash/quickInfoFromContextualType.ts | 10 +++++++ .../quickInfoOnClassMergedWithFunction.ts | 22 +++++++-------- tests/cases/fourslash/quickInfoTypeError.ts | 4 +-- 6 files changed, 56 insertions(+), 28 deletions(-) create mode 100644 tests/cases/fourslash/quickInfoFromContextualType.ts diff --git a/src/compiler/types.ts b/src/compiler/types.ts index b9d8d7a6319..83fc699c844 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -744,6 +744,7 @@ namespace ts { ; export interface PropertyAssignment extends ObjectLiteralElement { + parent: ObjectLiteralExpression; kind: SyntaxKind.PropertyAssignment; name: PropertyName; questionToken?: QuestionToken; @@ -751,6 +752,7 @@ namespace ts { } export interface ShorthandPropertyAssignment extends ObjectLiteralElement { + parent: ObjectLiteralExpression; kind: SyntaxKind.ShorthandPropertyAssignment; name: Identifier; questionToken?: QuestionToken; @@ -761,6 +763,7 @@ namespace ts { } export interface SpreadAssignment extends ObjectLiteralElement { + parent: ObjectLiteralExpression; kind: SyntaxKind.SpreadAssignment; expression: Expression; } diff --git a/src/services/services.ts b/src/services/services.ts index bada7ff021d..c22229fd089 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -1398,7 +1398,7 @@ namespace ts { } const typeChecker = program.getTypeChecker(); - const symbol = typeChecker.getSymbolAtLocation(node); + const symbol = getSymbolAtLocationForQuickInfo(node, typeChecker); if (!symbol || typeChecker.isUnknownSymbol(symbol)) { // Try getting just type at this position and show @@ -1437,6 +1437,21 @@ namespace ts { }; } + function getSymbolAtLocationForQuickInfo(node: Node, checker: TypeChecker): Symbol | undefined { + if ((isIdentifier(node) || isStringLiteral(node)) + && isPropertyAssignment(node.parent) + && node.parent.name === node) { + const type = checker.getContextualType(node.parent.parent); + if (type) { + const property = checker.getPropertyOfType(type, getTextOfIdentifierOrLiteral(node)); + if (property) { + return property; + } + } + } + return checker.getSymbolAtLocation(node); + } + /// Goto definition function getDefinitionAtPosition(fileName: string, position: number): DefinitionInfo[] { synchronizeHostData(); diff --git a/tests/cases/fourslash/contextualTyping.ts b/tests/cases/fourslash/contextualTyping.ts index 7819db20d92..9e9bce6dfaa 100644 --- a/tests/cases/fourslash/contextualTyping.ts +++ b/tests/cases/fourslash/contextualTyping.ts @@ -32,7 +32,7 @@ ////var /*13*/c3t5: (n: number) => IFoo = function(/*14*/n) { return ({}) }; ////var /*15*/c3t6: (n: number, s: string) => IFoo = function(/*16*/n, /*17*/s) { return ({}) }; ////var /*18*/c3t7: { -//// (n: number): number; +//// (n: number): number; //// (s1: string): number; ////}; ////var /*20*/c3t8: (n: number, s: string) => number = function(/*21*/n) { return n; }; @@ -79,7 +79,7 @@ //// t5: (n: number) => IFoo; //// t6: (n: number, s: string) => IFoo; //// t7: { -//// (n: number, s: string): number; +//// (n: number, s: string): number; //// //(s1: string, s2: string): number; //// }; //// t8: (n: number, s: string) => number; @@ -98,7 +98,7 @@ //// t5: (n: number) => IFoo; //// t6: (n: number, s: string) => IFoo; //// t7: { -//// (n: number, s: string): number; +//// (n: number, s: string): number; //// //(s1: string, s2: string): number; //// }; //// t8: (n: number, s: string) => number; @@ -152,7 +152,7 @@ ////var /*80*/c12t5 = <(n: number) => IFoo> function(/*81*/n) { return ({}) }; ////var /*82*/c12t6 = <(n: number, s: string) => IFoo> function(/*83*/n, /*84*/s) { return ({}) }; ////var /*85*/c12t7 = <{ -//// (n: number, s: string): number; +//// (n: number, s: string): number; //// //(s1: string, s2: string): number; ////}> function(n:number) { return n }; ////var /*86*/c12t8 = <(n: number, s: string) => number> function (/*87*/n) { return n; }; @@ -221,13 +221,13 @@ verify.quickInfos({ 25: "(parameter) n: number", 26: "(parameter) s: string", 27: "var c3t12: IBar", - 28: "(property) foo: IFoo", + 28: "(property) IBar.foo: IFoo", 29: "var c3t13: IFoo", - 30: "(property) f: (i: number, s: string) => string", + 30: "(method) IFoo.f(i: number, s: string): string", 31: "(parameter) i: number", 32: "(parameter) s: string", 33: "var c3t14: IFoo", - 34: "(property) a: undefined[]", + 34: "(property) IFoo.a: number[]", 35: "(property) C4T5.foo: (i: number, s: string) => string", 36: "(parameter) i: number", 37: "(parameter) s: string", @@ -257,13 +257,13 @@ verify.quickInfos({ 61: "(parameter) n: number", 62: "(parameter) s: string", 63: "(property) t12: IBar", - 64: "(property) foo: IFoo", + 64: "(property) IBar.foo: IFoo", 65: "(property) t13: IFoo", - 66: "(property) f: (i: number, s: string) => string", + 66: "(method) IFoo.f(i: number, s: string): string", 67: "(parameter) i: number", 68: "(parameter) s: string", 69: "(property) t14: IFoo", - 70: "(property) a: undefined[]", + 70: "(property) IFoo.a: number[]", 71: "(parameter) n: number", 72: "var c10t5: () => (n: number) => IFoo", 73: "(parameter) n: number", @@ -287,13 +287,13 @@ verify.quickInfos({ 91: "(parameter) n: number", 92: "(parameter) s: string", 93: "var c12t12: IBar", - 94: "(property) foo: IFoo", + 94: "(property) IBar.foo: IFoo", 95: "var c12t13: IFoo", - 96: "(property) f: (i: number, s: string) => string", + 96: "(method) IFoo.f(i: number, s: string): string", 97: "(parameter) i: number", 98: "(parameter) s: string", 99: "var c12t14: IFoo", - 100: "(property) a: undefined[]", + 100: "(property) IFoo.a: number[]", 101: "function EF1(a: number, b: number): number", 102: "(parameter) a: any", 103: "(parameter) b: any", @@ -302,7 +302,7 @@ verify.quickInfos({ 112: "(method) Point.add(dx: number, dy: number): Point", 113: "(parameter) dx: number", 114: "(parameter) dy: number", - 115: "(property) add: (dx: number, dy: number) => Point", + 115: "(method) Point.add(dx: number, dy: number): Point", 116: "(parameter) dx: number", 117: "(parameter) dy: number" }); diff --git a/tests/cases/fourslash/quickInfoFromContextualType.ts b/tests/cases/fourslash/quickInfoFromContextualType.ts new file mode 100644 index 00000000000..020681cd022 --- /dev/null +++ b/tests/cases/fourslash/quickInfoFromContextualType.ts @@ -0,0 +1,10 @@ +/// + +// @Filename: quickInfoExportAssignmentOfGenericInterface_0.ts +////interface I { +//// /** Documentation */ +//// x: number; +////} +////const i: I = { /**/x: 0 }; + +verify.quickInfoAt("", "(property) I.x: number", "Documentation "); diff --git a/tests/cases/fourslash/quickInfoOnClassMergedWithFunction.ts b/tests/cases/fourslash/quickInfoOnClassMergedWithFunction.ts index ef735fdfe3f..4a4f4e5fc17 100644 --- a/tests/cases/fourslash/quickInfoOnClassMergedWithFunction.ts +++ b/tests/cases/fourslash/quickInfoOnClassMergedWithFunction.ts @@ -1,16 +1,16 @@ /// ////module Test { -//// class Mocked { -//// myProp: string; -//// } -//// class Tester { -//// willThrowError() { -//// Mocked = Mocked || function () { // => Error: Invalid left-hand side of assignment expression. -//// return { /**/myProp: "test" }; -//// }; -//// } -//// } +//// class Mocked { +//// myProp: string; +//// } +//// class Tester { +//// willThrowError() { +//// Mocked = Mocked || function () { // => Error: Invalid left-hand side of assignment expression. +//// return { /**/myProp: "test" }; +//// }; +//// } +//// } ////} -verify.quickInfoAt("", "(property) myProp: string"); \ No newline at end of file +verify.quickInfoAt("", "(property) myProp: string"); diff --git a/tests/cases/fourslash/quickInfoTypeError.ts b/tests/cases/fourslash/quickInfoTypeError.ts index 7e0c9b20303..a4fa64e49d6 100644 --- a/tests/cases/fourslash/quickInfoTypeError.ts +++ b/tests/cases/fourslash/quickInfoTypeError.ts @@ -5,6 +5,6 @@ //// f() {} ////}); -// The symbol indicates that this is a funciton, but the type is `any`. +// The symbol indicates that this is a function, but the type is `any`. // Regression test that we don't crash (by trying to get signatures from `any`). -verify.quickInfoAt("", "(method) f"); +verify.quickInfoAt("", "(method) f(): void"); From 23f793fc3e804b43c2c6f6781913f025fe396221 Mon Sep 17 00:00:00 2001 From: Andy Date: Thu, 7 Sep 2017 07:23:06 -0700 Subject: [PATCH 240/370] findAllReferences: Handle root symbols of binding element property symbol (#17738) --- src/services/findAllReferences.ts | 78 +++++++++++-------- .../findAllRefsDestructureGeneric.ts | 15 ++++ ...OccurrencesIsDefinitionOfBindingPattern.ts | 11 ++- 3 files changed, 67 insertions(+), 37 deletions(-) create mode 100644 tests/cases/fourslash/findAllRefsDestructureGeneric.ts diff --git a/src/services/findAllReferences.ts b/src/services/findAllReferences.ts index 04d383748c8..2de7eeb0210 100644 --- a/src/services/findAllReferences.ts +++ b/src/services/findAllReferences.ts @@ -1435,22 +1435,27 @@ namespace ts.FindAllReferences.Core { const bindingElementPropertySymbol = getPropertySymbolOfObjectBindingPatternWithoutPropertyName(symbol, checker); if (bindingElementPropertySymbol) { result.push(bindingElementPropertySymbol); + addRootSymbols(bindingElementPropertySymbol); } - // If this is a union property, add all the symbols from all its source symbols in all unioned types. - // If the symbol is an instantiation from a another symbol (e.g. widened symbol) , add the root the list - for (const rootSymbol of checker.getRootSymbols(symbol)) { - if (rootSymbol !== symbol) { - result.push(rootSymbol); - } - - // Add symbol of properties/methods of the same name in base classes and implemented interfaces definitions - if (!implementations && rootSymbol.parent && rootSymbol.parent.flags & (SymbolFlags.Class | SymbolFlags.Interface)) { - getPropertySymbolsFromBaseTypes(rootSymbol.parent, rootSymbol.name, result, /*previousIterationSymbolsCache*/ createSymbolTable(), checker); - } - } + addRootSymbols(symbol); return result; + + function addRootSymbols(sym: Symbol): void { + // If this is a union property, add all the symbols from all its source symbols in all unioned types. + // If the symbol is an instantiation from a another symbol (e.g. widened symbol) , add the root the list + for (const rootSymbol of checker.getRootSymbols(sym)) { + if (rootSymbol !== sym) { + result.push(rootSymbol); + } + + // Add symbol of properties/methods of the same name in base classes and implemented interfaces definitions + if (!implementations && rootSymbol.parent && rootSymbol.parent.flags & (SymbolFlags.Class | SymbolFlags.Interface)) { + getPropertySymbolsFromBaseTypes(rootSymbol.parent, rootSymbol.name, result, /*previousIterationSymbolsCache*/ createSymbolTable(), checker); + } + } + } } /** @@ -1542,34 +1547,39 @@ namespace ts.FindAllReferences.Core { // then include the binding element in the related symbols // let { a } : { a }; const bindingElementPropertySymbol = getPropertySymbolOfObjectBindingPatternWithoutPropertyName(referenceSymbol, state.checker); - if (bindingElementPropertySymbol && search.includes(bindingElementPropertySymbol)) { - return bindingElementPropertySymbol; + if (bindingElementPropertySymbol) { + const fromBindingElement = findRootSymbol(bindingElementPropertySymbol); + if (fromBindingElement) return fromBindingElement; } - // Unwrap symbols to get to the root (e.g. transient symbols as a result of widening) - // Or a union property, use its underlying unioned symbols - return forEach(state.checker.getRootSymbols(referenceSymbol), rootSymbol => { - // if it is in the list, then we are done - if (search.includes(rootSymbol)) { - return rootSymbol; - } + return findRootSymbol(referenceSymbol); - // Finally, try all properties with the same name in any type the containing type extended or implemented, and - // see if any is in the list. If we were passed a parent symbol, only include types that are subtypes of the - // parent symbol - if (rootSymbol.parent && rootSymbol.parent.flags & (SymbolFlags.Class | SymbolFlags.Interface)) { - // Parents will only be defined if implementations is true - if (search.parents && !some(search.parents, parent => explicitlyInheritsFrom(rootSymbol.parent, parent, state.inheritsFromCache, state.checker))) { - return undefined; + function findRootSymbol(sym: Symbol): Symbol | undefined { + // Unwrap symbols to get to the root (e.g. transient symbols as a result of widening) + // Or a union property, use its underlying unioned symbols + return forEach(state.checker.getRootSymbols(sym), rootSymbol => { + // if it is in the list, then we are done + if (search.includes(rootSymbol)) { + return rootSymbol; } - const result: Symbol[] = []; - getPropertySymbolsFromBaseTypes(rootSymbol.parent, rootSymbol.name, result, /*previousIterationSymbolsCache*/ createSymbolTable(), state.checker); - return find(result, search.includes); - } + // Finally, try all properties with the same name in any type the containing type extended or implemented, and + // see if any is in the list. If we were passed a parent symbol, only include types that are subtypes of the + // parent symbol + if (rootSymbol.parent && rootSymbol.parent.flags & (SymbolFlags.Class | SymbolFlags.Interface)) { + // Parents will only be defined if implementations is true + if (search.parents && !some(search.parents, parent => explicitlyInheritsFrom(rootSymbol.parent, parent, state.inheritsFromCache, state.checker))) { + return undefined; + } - return undefined; - }); + const result: Symbol[] = []; + getPropertySymbolsFromBaseTypes(rootSymbol.parent, rootSymbol.name, result, /*previousIterationSymbolsCache*/ createSymbolTable(), state.checker); + return find(result, search.includes); + } + + return undefined; + }); + } } function getNameFromObjectLiteralElement(node: ObjectLiteralElement): string { diff --git a/tests/cases/fourslash/findAllRefsDestructureGeneric.ts b/tests/cases/fourslash/findAllRefsDestructureGeneric.ts new file mode 100644 index 00000000000..f3d4635cebd --- /dev/null +++ b/tests/cases/fourslash/findAllRefsDestructureGeneric.ts @@ -0,0 +1,15 @@ +/// + +////interface I { +//// [|{| "isWriteAccess": true, "isDefinition": true |}x|]: boolean; +////} +////declare const i: I; +////const { [|{| "isWriteAccess": true, "isDefinition": true |}x|] } = i; + +const [r0, r1] = test.ranges(); + +verify.referenceGroups(r0, [{ definition: "(property) I.x: boolean", ranges: [r0, r1] }]); +verify.referenceGroups(r1, [ + { definition: "(property) I.x: boolean", ranges: [r0] }, + { definition: "const x: boolean", ranges: [r1] } +]); diff --git a/tests/cases/fourslash/getOccurrencesIsDefinitionOfBindingPattern.ts b/tests/cases/fourslash/getOccurrencesIsDefinitionOfBindingPattern.ts index 7725b2e94f8..58814b45e99 100644 --- a/tests/cases/fourslash/getOccurrencesIsDefinitionOfBindingPattern.ts +++ b/tests/cases/fourslash/getOccurrencesIsDefinitionOfBindingPattern.ts @@ -1,5 +1,10 @@ /// -////const { [|{| "isWriteAccess": true, "isDefinition": true |}x|], y } = { x: 1, y: 2 }; -////const z = [|{| "isDefinition": false |}x|]; +////const { [|{| "isWriteAccess": true, "isDefinition": true |}x|], y } = { [|{| "isWriteAccess": true, "isDefinition": true |}x|]: 1, y: 2 }; +////const z = [|x|]; -verify.singleReferenceGroup("const x: number"); +const [r0, r1, r2] = test.ranges(); +verify.referenceGroups([r0, r2], [ + { definition: "const x: number", ranges: [r0, r2] }, + { definition: "(property) x: number", ranges: [r1] }, +]); +verify.referenceGroups(r1, [{ definition: "(property) x: number", ranges: [r0, r1, r2] }]); From 817c329667947afd780a69551b93fb4224e331dc Mon Sep 17 00:00:00 2001 From: Andy Date: Thu, 7 Sep 2017 07:23:53 -0700 Subject: [PATCH 241/370] getFormattingScanner: Ensure scanner is closed, and avoid global variables (#18293) --- src/services/formatting/formatting.ts | 14 +++++------ src/services/formatting/formattingScanner.ts | 25 +++++++------------- 2 files changed, 14 insertions(+), 25 deletions(-) diff --git a/src/services/formatting/formatting.ts b/src/services/formatting/formatting.ts index 83f87483194..443ce13d6a4 100644 --- a/src/services/formatting/formatting.ts +++ b/src/services/formatting/formatting.ts @@ -339,17 +339,17 @@ namespace ts.formatting { /* @internal */ export function formatNodeGivenIndentation(node: Node, sourceFileLike: SourceFileLike, languageVariant: LanguageVariant, initialIndentation: number, delta: number, rulesProvider: RulesProvider): TextChange[] { const range = { pos: 0, end: sourceFileLike.text.length }; - return formatSpanWorker( + return getFormattingScanner(sourceFileLike.text, languageVariant, range.pos, range.end, scanner => formatSpanWorker( range, node, initialIndentation, delta, - getFormattingScanner(sourceFileLike.text, languageVariant, range.pos, range.end), + scanner, rulesProvider.getFormatOptions(), rulesProvider, FormattingRequestKind.FormatSelection, _ => false, // assume that node does not have any errors - sourceFileLike); + sourceFileLike)); } function formatNodeLines(node: Node, sourceFile: SourceFile, options: FormatCodeSettings, rulesProvider: RulesProvider, requestKind: FormattingRequestKind): TextChange[] { @@ -372,17 +372,17 @@ namespace ts.formatting { requestKind: FormattingRequestKind): TextChange[] { // find the smallest node that fully wraps the range and compute the initial indentation for the node const enclosingNode = findEnclosingNode(originalRange, sourceFile); - return formatSpanWorker( + return getFormattingScanner(sourceFile.text, sourceFile.languageVariant, getScanStartPosition(enclosingNode, originalRange, sourceFile), originalRange.end, scanner => formatSpanWorker( originalRange, enclosingNode, SmartIndenter.getIndentationForNode(enclosingNode, originalRange, sourceFile, options), getOwnOrInheritedDelta(enclosingNode, options, sourceFile), - getFormattingScanner(sourceFile.text, sourceFile.languageVariant, getScanStartPosition(enclosingNode, originalRange, sourceFile), originalRange.end), + scanner, options, rulesProvider, requestKind, prepareRangeContainsErrorFunction(sourceFile.parseDiagnostics, originalRange), - sourceFile); + sourceFile)); } function formatSpanWorker(originalRange: TextRange, @@ -427,8 +427,6 @@ namespace ts.formatting { } } - formattingScanner.close(); - return edits; // local functions diff --git a/src/services/formatting/formattingScanner.ts b/src/services/formatting/formattingScanner.ts index 52df6477ed0..9b4e1be323b 100644 --- a/src/services/formatting/formattingScanner.ts +++ b/src/services/formatting/formattingScanner.ts @@ -6,11 +6,6 @@ namespace ts.formatting { const standardScanner = createScanner(ScriptTarget.Latest, /*skipTrivia*/ false, LanguageVariant.Standard); const jsxScanner = createScanner(ScriptTarget.Latest, /*skipTrivia*/ false, LanguageVariant.JSX); - /** - * Scanner that is currently used for formatting - */ - let scanner: Scanner; - export interface FormattingScanner { advance(): void; isOnToken(): boolean; @@ -18,7 +13,6 @@ namespace ts.formatting { getCurrentLeadingTrivia(): TextRangeWithKind[]; lastTrailingTriviaWasNewLine(): boolean; skipToEndOf(node: Node): void; - close(): void; } const enum ScanAction { @@ -30,9 +24,8 @@ namespace ts.formatting { RescanJsxText, } - export function getFormattingScanner(text: string, languageVariant: LanguageVariant, startPos: number, endPos: number): FormattingScanner { - Debug.assert(scanner === undefined, "Scanner should be undefined"); - scanner = languageVariant === LanguageVariant.JSX ? jsxScanner : standardScanner; + export function getFormattingScanner(text: string, languageVariant: LanguageVariant, startPos: number, endPos: number, cb: (scanner: FormattingScanner) => T): T { + const scanner = languageVariant === LanguageVariant.JSX ? jsxScanner : standardScanner; scanner.setText(text); scanner.setTextPos(startPos); @@ -45,21 +38,19 @@ namespace ts.formatting { let lastScanAction: ScanAction | undefined; let lastTokenInfo: TokenInfo | undefined; - return { + const res = cb({ advance, readTokenInfo, isOnToken, getCurrentLeadingTrivia: () => leadingTrivia, lastTrailingTriviaWasNewLine: () => wasNewLine, skipToEndOf, - close: () => { - Debug.assert(scanner !== undefined); + }); - lastTokenInfo = undefined; - scanner.setText(undefined); - scanner = undefined; - } - }; + lastTokenInfo = undefined; + scanner.setText(undefined); + + return res; function advance(): void { Debug.assert(scanner !== undefined, "Scanner should be present"); From b3c87aa919a24196e95ab1f5552ca19fcf3be247 Mon Sep 17 00:00:00 2001 From: Andy Date: Thu, 7 Sep 2017 07:26:22 -0700 Subject: [PATCH 242/370] Support find-all-references for `default` keyword (#17992) * Support find-all-references for anonymous default exports * Also handle re-exported default exports * Add test for using `export =` with `--allowSyntheticDefaultExports` --- src/compiler/checker.ts | 3 + src/services/findAllReferences.ts | 11 ++- src/services/importTracker.ts | 69 +++++++++++-------- .../findAllRefsForDefaultExport04.ts | 21 ++++-- .../findAllRefsForDefaultExportAnonymous.ts | 22 ++++++ .../findAllRefsForDefaultExport_reExport.ts | 30 ++++++++ ...t_reExport_allowSyntheticDefaultImports.ts | 32 +++++++++ tests/cases/fourslash/findAllRefsReExports.ts | 15 ++-- 8 files changed, 159 insertions(+), 44 deletions(-) create mode 100644 tests/cases/fourslash/findAllRefsForDefaultExportAnonymous.ts create mode 100644 tests/cases/fourslash/findAllRefsForDefaultExport_reExport.ts create mode 100644 tests/cases/fourslash/findAllRefsForDefaultExport_reExport_allowSyntheticDefaultImports.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index e7e66ed5f2d..1c8bc7846d0 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -22987,6 +22987,9 @@ namespace ts { : undefined; return objectType && getPropertyOfType(objectType, escapeLeadingUnderscores((node as StringLiteral | NumericLiteral).text)); + case SyntaxKind.DefaultKeyword: + return getSymbolOfNode(node.parent); + default: return undefined; } diff --git a/src/services/findAllReferences.ts b/src/services/findAllReferences.ts index 2de7eeb0210..b12b0f85fda 100644 --- a/src/services/findAllReferences.ts +++ b/src/services/findAllReferences.ts @@ -176,7 +176,9 @@ namespace ts.FindAllReferences { fileName: node.getSourceFile().fileName, textSpan: getTextSpan(node), isWriteAccess: isWriteAccess(node), - isDefinition: isAnyDeclarationName(node) || isLiteralComputedPropertyDeclarationName(node), + isDefinition: node.kind === SyntaxKind.DefaultKeyword + || isAnyDeclarationName(node) + || isLiteralComputedPropertyDeclarationName(node), isInString }; } @@ -243,7 +245,7 @@ namespace ts.FindAllReferences { /** A node is considered a writeAccess iff it is a name of a declaration or a target of an assignment */ function isWriteAccess(node: Node): boolean { - if (isAnyDeclarationName(node)) { + if (node.kind === SyntaxKind.DefaultKeyword || isAnyDeclarationName(node)) { return true; } @@ -743,7 +745,7 @@ namespace ts.FindAllReferences.Core { function isValidReferencePosition(node: Node, searchSymbolName: string): boolean { // Compare the length so we filter out strict superstrings of the symbol we are looking for - switch (node && node.kind) { + switch (node.kind) { case SyntaxKind.Identifier: return (node as Identifier).text.length === searchSymbolName.length; @@ -754,6 +756,9 @@ namespace ts.FindAllReferences.Core { case SyntaxKind.NumericLiteral: return isLiteralNameOfPropertyDeclarationOrIndexAccess(node as NumericLiteral) && (node as NumericLiteral).text.length === searchSymbolName.length; + case SyntaxKind.DefaultKeyword: + return "default".length === searchSymbolName.length; + default: return false; } diff --git a/src/services/importTracker.ts b/src/services/importTracker.ts index d4301db2f83..65b504e7bd8 100644 --- a/src/services/importTracker.ts +++ b/src/services/importTracker.ts @@ -180,7 +180,6 @@ namespace ts.FindAllReferences { * But re-exports will be placed in 'singleReferences' since they cannot be locally referenced. */ function getSearchesFromDirectImports(directImports: Importer[], exportSymbol: Symbol, exportKind: ExportKind, checker: TypeChecker, isForRename: boolean): Pick { - const exportName = exportSymbol.escapedName; const importSearches: Array<[Identifier, Symbol]> = []; const singleReferences: Identifier[] = []; function addSearch(location: Identifier, symbol: Symbol): void { @@ -218,12 +217,11 @@ namespace ts.FindAllReferences { return; } - if (!decl.importClause) { + const { importClause } = decl; + if (!importClause) { return; } - const { importClause } = decl; - const { namedBindings } = importClause; if (namedBindings && namedBindings.kind === SyntaxKind.NamespaceImport) { handleNamespaceImportLike(namedBindings.name); @@ -245,7 +243,6 @@ namespace ts.FindAllReferences { // 'default' might be accessed as a named import `{ default as foo }`. if (!isForRename && exportKind === ExportKind.Default) { - Debug.assert(exportName === "default"); searchForNamedImport(namedBindings as NamedImports | undefined); } } @@ -258,36 +255,43 @@ namespace ts.FindAllReferences { */ function handleNamespaceImportLike(importName: Identifier): void { // Don't rename an import that already has a different name than the export. - if (exportKind === ExportKind.ExportEquals && (!isForRename || importName.escapedText === exportName)) { + if (exportKind === ExportKind.ExportEquals && (!isForRename || isNameMatch(importName.escapedText))) { addSearch(importName, checker.getSymbolAtLocation(importName)); } } function searchForNamedImport(namedBindings: NamedImportsOrExports | undefined): void { - if (namedBindings) { - for (const element of namedBindings.elements) { - const { name, propertyName } = element; - if ((propertyName || name).escapedText !== exportName) { - continue; - } + if (!namedBindings) { + return; + } - if (propertyName) { - // This is `import { foo as bar } from "./a"` or `export { foo as bar } from "./a"`. `foo` isn't a local in the file, so just add it as a single reference. - singleReferences.push(propertyName); - if (!isForRename) { // If renaming `foo`, don't touch `bar`, just `foo`. - // Search locally for `bar`. - addSearch(name, checker.getSymbolAtLocation(name)); - } - } - else { - const localSymbol = element.kind === SyntaxKind.ExportSpecifier && element.propertyName - ? checker.getExportSpecifierLocalTargetSymbol(element) // For re-exporting under a different name, we want to get the re-exported symbol. - : checker.getSymbolAtLocation(name); - addSearch(name, localSymbol); + for (const element of namedBindings.elements) { + const { name, propertyName } = element; + if (!isNameMatch((propertyName || name).escapedText)) { + continue; + } + + if (propertyName) { + // This is `import { foo as bar } from "./a"` or `export { foo as bar } from "./a"`. `foo` isn't a local in the file, so just add it as a single reference. + singleReferences.push(propertyName); + if (!isForRename) { // If renaming `foo`, don't touch `bar`, just `foo`. + // Search locally for `bar`. + addSearch(name, checker.getSymbolAtLocation(name)); } } + else { + const localSymbol = element.kind === SyntaxKind.ExportSpecifier && element.propertyName + ? checker.getExportSpecifierLocalTargetSymbol(element) // For re-exporting under a different name, we want to get the re-exported symbol. + : checker.getSymbolAtLocation(name); + addSearch(name, localSymbol); + } } } + + function isNameMatch(name: __String): boolean { + // Use name of "default" even in `export =` case because we may have allowSyntheticDefaultImports + return name === exportSymbol.escapedName || exportKind !== ExportKind.Named && name === "default"; + } } /** Returns 'true' is the namespace 'name' is re-exported from this module, and 'false' if it is only used locally. */ @@ -413,7 +417,7 @@ namespace ts.FindAllReferences { case SyntaxKind.ExternalModuleReference: return (decl as ExternalModuleReference).parent; default: - Debug.fail(`Unexpected module specifier parent: ${decl.kind}`); + Debug.fail("Unexpected module specifier parent: " + decl.kind); } } @@ -468,11 +472,11 @@ namespace ts.FindAllReferences { return exportInfo(symbol, getExportKindForDeclaration(exportNode)); } } - // If we are in `export = a;`, `parent` is the export assignment. + // If we are in `export = a;` or `export default a;`, `parent` is the export assignment. else if (isExportAssignment(parent)) { return getExportAssignmentExport(parent); } - // If we are in `export = class A {};` at `A`, `parent.parent` is the export assignment. + // If we are in `export = class A {};` (or `export = class A {};`) at `A`, `parent.parent` is the export assignment. else if (isExportAssignment(parent.parent)) { return getExportAssignmentExport(parent.parent); } @@ -489,7 +493,8 @@ namespace ts.FindAllReferences { // Get the symbol for the `export =` node; its parent is the module it's the export of. const exportingModuleSymbol = ex.symbol.parent; Debug.assert(!!exportingModuleSymbol); - return { kind: ImportExport.Export, symbol, exportInfo: { exportingModuleSymbol, exportKind: ExportKind.ExportEquals } }; + const exportKind = ex.isExportEquals ? ExportKind.ExportEquals : ExportKind.Default; + return { kind: ImportExport.Export, symbol, exportInfo: { exportingModuleSymbol, exportKind } }; } function getSpecialPropertyExport(node: ts.BinaryExpression, useLhsSymbol: boolean): ExportedSymbol | undefined { @@ -525,7 +530,11 @@ namespace ts.FindAllReferences { importedSymbol = getExportEqualsLocalSymbol(importedSymbol, checker); } - if (symbolName(importedSymbol) === symbol.escapedName) { // If this is a rename import, do not continue searching. + // If the import has a different name than the export, do not continue searching. + // If `importedName` is undefined, do continue searching as the export is anonymous. + // (All imports returned from this function will be ignored anyway if we are in rename and this is a not a named export.) + const importedName = symbolName(importedSymbol); + if (importedName === undefined || importedName === "default" || importedName === symbol.escapedName) { return { kind: ImportExport.Import, symbol: importedSymbol, ...isImport }; } } diff --git a/tests/cases/fourslash/findAllRefsForDefaultExport04.ts b/tests/cases/fourslash/findAllRefsForDefaultExport04.ts index c8fdb0a6149..1b5eb7a282d 100644 --- a/tests/cases/fourslash/findAllRefsForDefaultExport04.ts +++ b/tests/cases/fourslash/findAllRefsForDefaultExport04.ts @@ -2,15 +2,24 @@ // @Filename: /a.ts ////const [|{| "isWriteAccess": true, "isDefinition": true |}a|] = 0; -////export default [|a|]; +////export [|{| "isWriteAccess": true, "isDefinition": true |}default|] [|a|]; // @Filename: /b.ts ////import [|{| "isWriteAccess": true, "isDefinition": true |}a|] from "./a"; ////[|a|]; -const [r0, r1, r2, r3] = test.ranges(); -verify.referenceGroups([r0, r1], [ - { definition: "const a: 0", ranges: [r0, r1] }, - { definition: "import a", ranges: [r2, r3] } +const [r0, r1, r2, r3, r4] = test.ranges(); +verify.referenceGroups([r0, r2], [ + { definition: "const a: 0", ranges: [r0, r2] }, + { definition: "import a", ranges: [r3, r4] } +]); +verify.referenceGroups(r1, [ + // TODO:GH#17990 + { definition: "import default", ranges: [r1] }, + { definition: "import a", ranges: [r3, r4] }, +]); +verify.referenceGroups([r3, r4], [ + { definition: "import a", ranges: [r3, r4] }, + // TODO:GH#17990 + { definition: "import default", ranges: [r1] }, ]); -verify.singleReferenceGroup("import a", [r2, r3]); diff --git a/tests/cases/fourslash/findAllRefsForDefaultExportAnonymous.ts b/tests/cases/fourslash/findAllRefsForDefaultExportAnonymous.ts new file mode 100644 index 00000000000..3beb5b59424 --- /dev/null +++ b/tests/cases/fourslash/findAllRefsForDefaultExportAnonymous.ts @@ -0,0 +1,22 @@ +/// + +// @Filename: /a.ts +////export [|{| "isWriteAccess": true, "isDefinition": true |}default|] function() {} + +// @Filename: /b.ts +////import [|{| "isWriteAccess": true, "isDefinition": true |}f|] from "./a"; + +const [r0, r1] = test.ranges(); +verify.referenceGroups(r0, [ + { definition: "function default(): void", ranges: [r0] }, + { definition: "import f", ranges: [r1] }, +]); +verify.referenceGroups(r1, [ + { definition: "import f", ranges: [r1] }, + { definition: "function default(): void", ranges: [r0] }, +]); + +// Verify that it doesn't try to rename "default" +goTo.rangeStart(r0); +verify.renameInfoFailed(); +verify.renameLocations(r1, [r1]); diff --git a/tests/cases/fourslash/findAllRefsForDefaultExport_reExport.ts b/tests/cases/fourslash/findAllRefsForDefaultExport_reExport.ts new file mode 100644 index 00000000000..401db1a8033 --- /dev/null +++ b/tests/cases/fourslash/findAllRefsForDefaultExport_reExport.ts @@ -0,0 +1,30 @@ +/// + +// @Filename: /export.ts +////const [|{| "isWriteAccess": true, "isDefinition": true |}foo|] = 1; +////export default [|foo|]; + +// @Filename: /re-export.ts +////export { [|{| "isWriteAccess": true, "isDefinition": true |}default|] } from "./export"; + +// @Filename: /re-export-dep.ts +////import [|{| "isWriteAccess": true, "isDefinition": true |}fooDefault|] from "./re-export"; + +verify.noErrors(); + +const [r0, r1, r2, r3] = test.ranges(); +verify.referenceGroups([r0, r1], [ + { definition: "const foo: 1", ranges: [r0, r1] }, + { definition: "import default", ranges: [r2], }, + { definition: "import fooDefault", ranges: [r3] }, +]); +verify.referenceGroups(r2, [ + { definition: "import default", ranges: [r2] }, + { definition: "import fooDefault", ranges: [r3] }, + { definition: "const foo: 1", ranges: [r0, r1] }, +]); +verify.referenceGroups(r3, [ + { definition: "import fooDefault", ranges: [r3] }, + { definition: "import default", ranges: [r2] }, + { definition: "const foo: 1", ranges: [r0, r1] }, +]); diff --git a/tests/cases/fourslash/findAllRefsForDefaultExport_reExport_allowSyntheticDefaultImports.ts b/tests/cases/fourslash/findAllRefsForDefaultExport_reExport_allowSyntheticDefaultImports.ts new file mode 100644 index 00000000000..26a05f2e12e --- /dev/null +++ b/tests/cases/fourslash/findAllRefsForDefaultExport_reExport_allowSyntheticDefaultImports.ts @@ -0,0 +1,32 @@ +/// + +// @allowSyntheticDefaultImports: true + +// @Filename: /export.ts +////const [|{| "isWriteAccess": true, "isDefinition": true |}foo|] = 1; +////export = [|foo|]; + +// @Filename: /re-export.ts +////export { [|{| "isWriteAccess": true, "isDefinition": true |}default|] } from "./export"; + +// @Filename: /re-export-dep.ts +////import [|{| "isWriteAccess": true, "isDefinition": true |}fooDefault|] from "./re-export"; + +verify.noErrors(); + +const [r0, r1, r2, r3] = test.ranges(); +verify.referenceGroups([r0, r1], [ + { definition: "const foo: 1", ranges: [r0, r1] }, + { definition: "import default", ranges: [r2], }, + { definition: "import fooDefault", ranges: [r3] }, +]); +verify.referenceGroups(r2, [ + { definition: "import default", ranges: [r2] }, + { definition: "import fooDefault", ranges: [r3] }, + { definition: "const foo: 1", ranges: [r0, r1] }, +]); +verify.referenceGroups(r3, [ + { definition: "import fooDefault", ranges: [r3] }, + { definition: "import default", ranges: [r2] }, + { definition: "const foo: 1", ranges: [r0, r1] }, +]); diff --git a/tests/cases/fourslash/findAllRefsReExports.ts b/tests/cases/fourslash/findAllRefsReExports.ts index a4cced049b9..e9936867604 100644 --- a/tests/cases/fourslash/findAllRefsReExports.ts +++ b/tests/cases/fourslash/findAllRefsReExports.ts @@ -39,14 +39,19 @@ verify.referenceGroups(bar2, [{ ...eBar, definition: "(alias) bar(): void\nimpor verify.referenceGroups([defaultC], [c, d, eBoom, eBaz, eBang]); verify.referenceGroups(defaultD, [d, eBoom, a, b, eBar,c, eBaz, eBang]); verify.referenceGroups(defaultE, [c, d, eBoom, eBaz, eBang]); -verify.referenceGroups(baz0, [eBaz]); -verify.referenceGroups(baz1, [{ ...eBaz, definition: "(alias) baz(): void\nimport baz" }]); +verify.referenceGroups(baz0, [eBaz, c, d, eBoom, eBang]); +verify.referenceGroups(baz1, [ + { ...eBaz, definition: "(alias) baz(): void\nimport baz" }, + c, d, eBoom, eBang, +]); verify.referenceGroups(bang0, [eBang]); verify.referenceGroups(bang1, [{ ...eBang, definition: "(alias) bang(): void\nimport bang" }]); - -verify.referenceGroups(boom0, [eBoom]); -verify.referenceGroups(boom1, [{ ...eBoom, definition: "(alias) boom(): void\nimport boom" }]); +verify.referenceGroups(boom0, [eBoom, d, a, b, eBar, c, eBaz, eBang]); +verify.referenceGroups(boom1, [ + { ...eBoom, definition: "(alias) boom(): void\nimport boom" }, + d, a, b, eBar, c, eBaz, eBang, +]); test.rangesByText().forEach((ranges, text) => { if (text === "default") { From b533b24686d5f2c799e2c5edf6283243b6a8d2df Mon Sep 17 00:00:00 2001 From: Andy Date: Thu, 7 Sep 2017 07:28:12 -0700 Subject: [PATCH 243/370] extractMethod: Don't try to extract a single token (#18090) * extractMethod: Don't try to extract a single token * Update tests --- src/services/refactors/extractMethod.ts | 4 ++-- tests/cases/fourslash/extract-method-not-for-token.ts | 6 ++++++ tests/cases/fourslash/extract-method13.ts | 8 ++++---- tests/cases/fourslash/extract-method5.ts | 5 +++-- tests/cases/fourslash/extract-method7.ts | 4 ++-- 5 files changed, 17 insertions(+), 10 deletions(-) create mode 100644 tests/cases/fourslash/extract-method-not-for-token.ts diff --git a/src/services/refactors/extractMethod.ts b/src/services/refactors/extractMethod.ts index 6fe664e6c81..b76ab9376dc 100644 --- a/src/services/refactors/extractMethod.ts +++ b/src/services/refactors/extractMethod.ts @@ -95,7 +95,7 @@ namespace ts.refactor.extractMethod { export const CannotExtractRangeThatContainsWritesToReferencesLocatedOutsideOfTheTargetRangeInGenerators: DiagnosticMessage = createMessage("Cannot extract range containing writes to references located outside of the target range in generators."); export const TypeWillNotBeVisibleInTheNewScope = createMessage("Type will not visible in the new scope."); export const FunctionWillNotBeVisibleInTheNewScope = createMessage("Function will not visible in the new scope."); - export const InsufficientSelection = createMessage("Select more than a single identifier."); + export const InsufficientSelection = createMessage("Select more than a single token."); export const CannotExtractExportedEntity = createMessage("Cannot extract exported declaration"); export const CannotCombineWritesAndReturns = createMessage("Cannot combine writes and returns"); export const CannotExtractReadonlyPropertyInitializerOutsideConstructor = createMessage("Cannot move initialization of read-only class property outside of the constructor"); @@ -239,7 +239,7 @@ namespace ts.refactor.extractMethod { } function checkRootNode(node: Node): Diagnostic[] | undefined { - if (isIdentifier(node)) { + if (isToken(node)) { return [createDiagnosticForNode(node, Messages.InsufficientSelection)]; } return undefined; diff --git a/tests/cases/fourslash/extract-method-not-for-token.ts b/tests/cases/fourslash/extract-method-not-for-token.ts new file mode 100644 index 00000000000..756716441cd --- /dev/null +++ b/tests/cases/fourslash/extract-method-not-for-token.ts @@ -0,0 +1,6 @@ +/// + +////"/**/foo"; + +goTo.marker(""); +verify.not.refactorAvailable('Extract Method'); diff --git a/tests/cases/fourslash/extract-method13.ts b/tests/cases/fourslash/extract-method13.ts index 14a146a80c5..94ad86e4399 100644 --- a/tests/cases/fourslash/extract-method13.ts +++ b/tests/cases/fourslash/extract-method13.ts @@ -4,8 +4,8 @@ // Also checks that we correctly find non-conflicting names in static contexts. //// class C { -//// static j = /*c*/100/*d*/; -//// constructor(q: string = /*a*/"hello"/*b*/) { +//// static j = /*c*/1 + 1/*d*/; +//// constructor(q: string = /*a*/"a" + "b"/*b*/) { //// } //// } @@ -29,10 +29,10 @@ verify.currentFileContentIs(`class C { } private static newFunction(): string { - return "hello"; + return "a" + "b"; } private static newFunction_1() { - return 100; + return 1 + 1; } }`); \ No newline at end of file diff --git a/tests/cases/fourslash/extract-method5.ts b/tests/cases/fourslash/extract-method5.ts index 10294298b08..d1e70d10716 100644 --- a/tests/cases/fourslash/extract-method5.ts +++ b/tests/cases/fourslash/extract-method5.ts @@ -5,7 +5,7 @@ // annotation in the extracted function //// function f() { -//// var x: 1 | 2 | 3 = /*start*/2/*end*/; +//// var x: 1 | 2 | 3 = /*start*/1 + 1 === 2 ? 1 : 2/*end*/; //// } goTo.select('start', 'end'); @@ -14,11 +14,12 @@ edit.applyRefactor({ actionName: "scope_0", actionDescription: "Extract function into function 'f'", }); +// TODO: GH#18091 (fix formatting to use `2 ? 1 :` and not `2?1:`) verify.currentFileContentIs( `function f() { var x: 1 | 2 | 3 = newFunction(); function newFunction(): 1 | 2 | 3 { - return 2; + return 1 + 1 === 2?1: 2; } }`); \ No newline at end of file diff --git a/tests/cases/fourslash/extract-method7.ts b/tests/cases/fourslash/extract-method7.ts index 95c9cbe9897..d10c7c3136e 100644 --- a/tests/cases/fourslash/extract-method7.ts +++ b/tests/cases/fourslash/extract-method7.ts @@ -3,7 +3,7 @@ // You cannot extract a function initializer into the function's body. // The innermost scope (scope_0) is the sibling of the function, not the function itself. -//// function fn(x = /*a*/3/*b*/) { +//// function fn(x = /*a*/1 + 1/*b*/) { //// } goTo.select('a', 'b'); @@ -15,6 +15,6 @@ edit.applyRefactor({ verify.currentFileContentIs(`function fn(x = newFunction()) { } function newFunction() { - return 3; + return 1 + 1; } `); From 7541c705bfe9fd3247f5a3471b45c727d5484bca Mon Sep 17 00:00:00 2001 From: Andy Date: Thu, 7 Sep 2017 07:45:11 -0700 Subject: [PATCH 244/370] Support navTo for special assignment kinds (#18154) * Support navTo for special assignment kinds * Return ScriptElementKind.unknown --- src/compiler/core.ts | 2 ++ src/services/services.ts | 6 +++++ src/services/utilities.ts | 22 +++++++++++++++++++ ...avigationItemsSpecialPropertyAssignment.ts | 20 +++++++++++++++++ 4 files changed, 50 insertions(+) create mode 100644 tests/cases/fourslash/navigationItemsSpecialPropertyAssignment.ts diff --git a/src/compiler/core.ts b/src/compiler/core.ts index 20f757c3df8..f7ff8c27bf7 100644 --- a/src/compiler/core.ts +++ b/src/compiler/core.ts @@ -2628,4 +2628,6 @@ namespace ts { export function and(f: (arg: T) => boolean, g: (arg: T) => boolean) { return (arg: T) => f(arg) && g(arg); } + + export function assertTypeIsNever(_: never): void {} } diff --git a/src/services/services.ts b/src/services/services.ts index c22229fd089..e0e3bea79ff 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -722,6 +722,12 @@ namespace ts { } break; + case SyntaxKind.BinaryExpression: + if (getSpecialPropertyAssignmentKind(node as BinaryExpression) !== SpecialPropertyAssignmentKind.None) { + addDeclaration(node as BinaryExpression); + } + // falls through + default: forEachChild(node, visit); } diff --git a/src/services/utilities.ts b/src/services/utilities.ts index c7f5b5909f0..c3a1d5d571d 100644 --- a/src/services/utilities.ts +++ b/src/services/utilities.ts @@ -343,6 +343,28 @@ namespace ts { return ScriptElementKind.alias; case SyntaxKind.JSDocTypedefTag: return ScriptElementKind.typeElement; + case SyntaxKind.BinaryExpression: + const kind = getSpecialPropertyAssignmentKind(node as BinaryExpression); + const { right } = node as BinaryExpression; + switch (kind) { + case SpecialPropertyAssignmentKind.None: + return ScriptElementKind.unknown; + case SpecialPropertyAssignmentKind.ExportsProperty: + case SpecialPropertyAssignmentKind.ModuleExports: + const rightKind = getNodeKind(right); + return rightKind === ScriptElementKind.unknown ? ScriptElementKind.constElement : rightKind; + case SpecialPropertyAssignmentKind.PrototypeProperty: + return ScriptElementKind.memberFunctionElement; // instance method + case SpecialPropertyAssignmentKind.ThisProperty: + return ScriptElementKind.memberVariableElement; // property + case SpecialPropertyAssignmentKind.Property: + // static method / property + return isFunctionExpression(right) ? ScriptElementKind.memberFunctionElement : ScriptElementKind.memberVariableElement; + default: { + assertTypeIsNever(kind); + return ScriptElementKind.unknown; + } + } default: return ScriptElementKind.unknown; } diff --git a/tests/cases/fourslash/navigationItemsSpecialPropertyAssignment.ts b/tests/cases/fourslash/navigationItemsSpecialPropertyAssignment.ts new file mode 100644 index 00000000000..4618d34b954 --- /dev/null +++ b/tests/cases/fourslash/navigationItemsSpecialPropertyAssignment.ts @@ -0,0 +1,20 @@ +/// + +// @allowJs: true +// @Filename: /a.js +////exports.{| "name": "x", "kind": "const" |}x = 0; +////exports.{| "name": "y", "kind": "function" |}y = function() {}; +////function Cls() { +//// this.{| "name": "prop", "kind": "property" |}prop = 0; +////} +////Cls.{| "name": "staticMethod", "kind": "method" |}staticMethod = function() {}; +////Cls.{| "name": "staticProperty", "kind": "property" |}staticProperty = 0; +////Cls.prototype.{| "name": "instance", "kind": "method" |}instance = function() {}; + +for (const marker of test.markers()) { + verify.navigationItemsListContains( + marker.data.name, + marker.data.kind, + marker.data.name, + "exact"); +} From 90d9f3d4ba2b45c28fa3361725002f31c75d8403 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Thu, 7 Sep 2017 09:07:59 -0700 Subject: [PATCH 245/370] Rename isStartOfType parameter used by isStartOfParameter --- src/compiler/parser.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index 1740bad2d34..d25bb3efd50 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -2238,7 +2238,7 @@ namespace ts { isIdentifierOrPattern() || isModifierKind(token()) || token() === SyntaxKind.AtToken || - isStartOfType(/*disableLookahead*/ true); + isStartOfType(/*inStartOfParameter*/ true); } function parseParameter(): ParameterDeclaration { @@ -2699,7 +2699,7 @@ namespace ts { } } - function isStartOfType(disableLookahead?: boolean): boolean { + function isStartOfType(inStartOfParameter?: boolean): boolean { switch (token()) { case SyntaxKind.AnyKeyword: case SyntaxKind.StringKeyword: @@ -2729,11 +2729,11 @@ namespace ts { case SyntaxKind.DotDotDotToken: return true; case SyntaxKind.MinusToken: - return !disableLookahead && lookAhead(nextTokenIsNumericLiteral); + return !inStartOfParameter && lookAhead(nextTokenIsNumericLiteral); case SyntaxKind.OpenParenToken: // Only consider '(' the start of a type if followed by ')', '...', an identifier, a modifier, // or something that starts a type. We don't want to consider things like '(1)' a type. - return !disableLookahead && lookAhead(isStartOfParenthesizedOrFunctionType); + return !inStartOfParameter && lookAhead(isStartOfParenthesizedOrFunctionType); default: return isIdentifier(); } From be0633825cd4c82c279dd8f6ee8d432e0b757521 Mon Sep 17 00:00:00 2001 From: Andy Date: Thu, 7 Sep 2017 09:13:46 -0700 Subject: [PATCH 246/370] Don't provide string literal completions for string enums (#18288) * Don't provide string literal completions for string enums * Rename test --- src/services/completions.ts | 2 +- ...tringLiteralCompletionsForStringEnumContextualType.ts | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) create mode 100644 tests/cases/fourslash/stringLiteralCompletionsForStringEnumContextualType.ts diff --git a/src/services/completions.ts b/src/services/completions.ts index 300ade2da48..97998ec724b 100644 --- a/src/services/completions.ts +++ b/src/services/completions.ts @@ -284,7 +284,7 @@ namespace ts.Completions { addStringLiteralCompletionsFromType(t, result, typeChecker, uniques); } } - else if (type.flags & TypeFlags.StringLiteral) { + else if (type.flags & TypeFlags.StringLiteral && !(type.flags & TypeFlags.EnumLiteral)) { const name = (type).value; if (!uniques.has(name)) { uniques.set(name, true); diff --git a/tests/cases/fourslash/stringLiteralCompletionsForStringEnumContextualType.ts b/tests/cases/fourslash/stringLiteralCompletionsForStringEnumContextualType.ts new file mode 100644 index 00000000000..664bfbac369 --- /dev/null +++ b/tests/cases/fourslash/stringLiteralCompletionsForStringEnumContextualType.ts @@ -0,0 +1,9 @@ +/// + +////const enum E { +//// A = "A", +////} +////const e: E = "/**/"; + +goTo.marker(""); +verify.completionListIsEmpty(); From 193f4be355168145ede3a8186b9b7ff13339c3ca Mon Sep 17 00:00:00 2001 From: Andy Date: Thu, 7 Sep 2017 09:14:59 -0700 Subject: [PATCH 247/370] Enable interface-over-type-literal lint rule (#17733) --- src/compiler/checker.ts | 2 +- src/harness/unittests/convertTypeAcquisitionFromJson.ts | 2 +- src/server/protocol.ts | 8 ++++---- src/server/typingsInstaller/typingsInstaller.ts | 4 ++-- src/services/navigateTo.ts | 8 +++++++- src/services/types.ts | 9 ++++----- tslint.json | 1 + 7 files changed, 20 insertions(+), 14 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 1c8bc7846d0..b7f0894d284 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -21516,7 +21516,7 @@ namespace ts { return true; } - type InheritanceInfoMap = { prop: Symbol; containingType: Type }; + interface InheritanceInfoMap { prop: Symbol; containingType: Type; } const seen = createUnderscoreEscapedMap(); forEach(resolveDeclaredMembers(type).declaredProperties, p => { seen.set(p.escapedName, { prop: p, containingType: type }); }); let ok = true; diff --git a/src/harness/unittests/convertTypeAcquisitionFromJson.ts b/src/harness/unittests/convertTypeAcquisitionFromJson.ts index aae4ee38382..67646de3680 100644 --- a/src/harness/unittests/convertTypeAcquisitionFromJson.ts +++ b/src/harness/unittests/convertTypeAcquisitionFromJson.ts @@ -2,7 +2,7 @@ /// namespace ts { - type ExpectedResult = { typeAcquisition: TypeAcquisition, errors: Diagnostic[] }; + interface ExpectedResult { typeAcquisition: TypeAcquisition; errors: Diagnostic[]; } describe("convertTypeAcquisitionFromJson", () => { function assertTypeAcquisition(json: any, configFileName: string, expectedResult: ExpectedResult) { assertTypeAcquisitionWithJson(json, configFileName, expectedResult); diff --git a/src/server/protocol.ts b/src/server/protocol.ts index 37bf79837c9..3fdbd8fd7f7 100644 --- a/src/server/protocol.ts +++ b/src/server/protocol.ts @@ -466,7 +466,7 @@ namespace ts.server.protocol { * Represents a single refactoring action - for example, the "Extract Method..." refactor might * offer several actions, each corresponding to a surround class or closure to extract into. */ - export type RefactorActionInfo = { + export interface RefactorActionInfo { /** * The programmatic name of the refactoring action */ @@ -478,7 +478,7 @@ namespace ts.server.protocol { * so this description should make sense by itself if the parent is inlineable=true */ description: string; - }; + } export interface GetEditsForRefactorRequest extends Request { command: CommandTypes.GetEditsForRefactor; @@ -501,7 +501,7 @@ namespace ts.server.protocol { body?: RefactorEditInfo; } - export type RefactorEditInfo = { + export interface RefactorEditInfo { edits: FileCodeEdits[]; /** @@ -510,7 +510,7 @@ namespace ts.server.protocol { */ renameLocation?: Location; renameFilename?: string; - }; + } /** * Request for the available codefixes at a specific position. diff --git a/src/server/typingsInstaller/typingsInstaller.ts b/src/server/typingsInstaller/typingsInstaller.ts index c6423bc3c7b..3eae0755747 100644 --- a/src/server/typingsInstaller/typingsInstaller.ts +++ b/src/server/typingsInstaller/typingsInstaller.ts @@ -73,12 +73,12 @@ namespace ts.server.typingsInstaller { } export type RequestCompletedAction = (success: boolean) => void; - type PendingRequest = { + interface PendingRequest { requestId: number; args: string[]; cwd: string; onRequestCompleted: RequestCompletedAction; - }; + } export abstract class TypingsInstaller { private readonly packageNameToTypingLocation: Map = createMap(); diff --git a/src/services/navigateTo.ts b/src/services/navigateTo.ts index 6d84769082d..ec7b011456f 100644 --- a/src/services/navigateTo.ts +++ b/src/services/navigateTo.ts @@ -1,6 +1,12 @@ /* @internal */ namespace ts.NavigateTo { - type RawNavigateToItem = { name: string; fileName: string; matchKind: PatternMatchKind; isCaseSensitive: boolean; declaration: Declaration }; + interface RawNavigateToItem { + name: string; + fileName: string; + matchKind: PatternMatchKind; + isCaseSensitive: boolean; + declaration: Declaration; + } export function getNavigateToItems(sourceFiles: ReadonlyArray, checker: TypeChecker, cancellationToken: CancellationToken, searchValue: string, maxResultCount: number, excludeDtsFiles: boolean): NavigateToItem[] { const patternMatcher = createPatternMatcher(searchValue); diff --git a/src/services/types.ts b/src/services/types.ts index 609eaf11de5..8a23bfec1c5 100644 --- a/src/services/types.ts +++ b/src/services/types.ts @@ -394,7 +394,7 @@ namespace ts { * Represents a single refactoring action - for example, the "Extract Method..." refactor might * offer several actions, each corresponding to a surround class or closure to extract into. */ - export type RefactorActionInfo = { + export interface RefactorActionInfo { /** * The programmatic name of the refactoring action */ @@ -406,18 +406,17 @@ namespace ts { * so this description should make sense by itself if the parent is inlineable=true */ description: string; - }; + } /** * A set of edits to make in response to a refactor action, plus an optional * location where renaming should be invoked from */ - export type RefactorEditInfo = { + export interface RefactorEditInfo { edits: FileTextChanges[]; renameFilename?: string; renameLocation?: number; - }; - + } export interface TextInsertion { newText: string; diff --git a/tslint.json b/tslint.json index de60ad7683a..30e71eb5e0d 100644 --- a/tslint.json +++ b/tslint.json @@ -11,6 +11,7 @@ "indent": [true, "spaces" ], + "interface-over-type-literal": true, "jsdoc-format": true, "linebreak-style": [true, "CRLF"], "next-line": [true, From 59aa29b85470809af10616aa92a2df460ac3b4c6 Mon Sep 17 00:00:00 2001 From: Taras Mankovski Date: Thu, 7 Sep 2017 21:45:07 +0530 Subject: [PATCH 248/370] Added only the source file (#18175) --- src/lib/es2017.object.d.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/lib/es2017.object.d.ts b/src/lib/es2017.object.d.ts index 1f090a8fef2..1d8a52da758 100644 --- a/src/lib/es2017.object.d.ts +++ b/src/lib/es2017.object.d.ts @@ -22,4 +22,10 @@ interface ObjectConstructor { * @param o Object that contains the properties and methods. This can be an object that you created or an existing Document Object Model (DOM) object. */ entries(o: any): [string, any][]; + + /** + * Returns an object containing all own property descriptors of an object + * @param o Object that contains the properties and methods. This can be an object that you created or an existing Document Object Model (DOM) object. + */ + getOwnPropertyDescriptors(o: T): {[P in keyof T]: TypedPropertyDescriptor} & { [x: string]: PropertyDescriptor }; } From 7b12b7955873fb0a937e3538b8fee2460fd63c64 Mon Sep 17 00:00:00 2001 From: Adrian Leonhard Date: Thu, 7 Sep 2017 18:17:47 +0200 Subject: [PATCH 249/370] ts.server.ProjectService.closeConfiguredProject returns true on success. (#18180) Fixes #17892 The if condition around the return value of that method in closeExternalProject indicates that this was the expected behavior. --- src/server/editorServices.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/server/editorServices.ts b/src/server/editorServices.ts index d849226a35b..3f5b76ae39d 100644 --- a/src/server/editorServices.ts +++ b/src/server/editorServices.ts @@ -1686,11 +1686,13 @@ namespace ts.server { } } - private closeConfiguredProject(configFile: NormalizedPath): void { + private closeConfiguredProject(configFile: NormalizedPath): boolean { const configuredProject = this.findConfiguredProjectByProjectName(configFile); if (configuredProject && configuredProject.deleteOpenRef() === 0) { this.removeProject(configuredProject); + return true; } + return false; } closeExternalProject(uncheckedFileName: string, suppressRefresh = false): void { From a8dfdf2fa111c709cb4d1262ad559e70efaec6c5 Mon Sep 17 00:00:00 2001 From: Klaus Meinhardt Date: Thu, 7 Sep 2017 18:22:26 +0200 Subject: [PATCH 250/370] Add and fix some AST Node parent types (#18200) --- src/compiler/types.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 83fc699c844..6c48fc90f0e 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -636,6 +636,7 @@ namespace ts { export interface Decorator extends Node { kind: SyntaxKind.Decorator; + parent?: NamedDeclaration; expression: LeftHandSideExpression; } @@ -765,6 +766,7 @@ namespace ts { export interface SpreadAssignment extends ObjectLiteralElement { parent: ObjectLiteralExpression; kind: SyntaxKind.SpreadAssignment; + parent?: ObjectLiteralExpression; expression: Expression; } @@ -781,7 +783,7 @@ namespace ts { export interface VariableLikeDeclaration extends NamedDeclaration { propertyName?: PropertyName; dotDotDotToken?: DotDotDotToken; - name?: DeclarationName; // May be missing for ParameterDeclaration, see comment there + name: DeclarationName; questionToken?: QuestionToken; type?: TypeNode; initializer?: Expression; @@ -945,6 +947,7 @@ namespace ts { export interface TypePredicateNode extends TypeNode { kind: SyntaxKind.TypePredicate; + parent?: SignatureDeclaration; parameterName: Identifier | ThisTypeNode; type: TypeNode; } @@ -1001,7 +1004,6 @@ namespace ts { export interface MappedTypeNode extends TypeNode, Declaration { kind: SyntaxKind.MappedType; - parent?: TypeAliasDeclaration; readonlyToken?: ReadonlyToken; typeParameter: TypeParameterDeclaration; questionToken?: QuestionToken; @@ -1453,6 +1455,7 @@ namespace ts { export interface SpreadElement extends Expression { kind: SyntaxKind.SpreadElement; + parent?: ArrayLiteralExpression | CallExpression | NewExpression; expression: Expression; } From c82881f36ef412cacfe62e3394284e34cd9c4388 Mon Sep 17 00:00:00 2001 From: Mohamed Hegazy Date: Thu, 7 Sep 2017 09:36:31 -0700 Subject: [PATCH 251/370] Fix build break --- src/compiler/types.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 6c48fc90f0e..75e1cb05bc9 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -766,7 +766,6 @@ namespace ts { export interface SpreadAssignment extends ObjectLiteralElement { parent: ObjectLiteralExpression; kind: SyntaxKind.SpreadAssignment; - parent?: ObjectLiteralExpression; expression: Expression; } From 69933bd4d134250247175b00acc8e1e371331a7e Mon Sep 17 00:00:00 2001 From: Klaus Meinhardt Date: Thu, 7 Sep 2017 18:46:58 +0200 Subject: [PATCH 252/370] expose isExternalModuleNameRelative and moduleHasNonRelativeName (#17971) * expose isExternalModuleNameRelative and moduleHasNonRelativeName Fixes: #17890 * only expose isExternalModuleNameRelative --- src/compiler/core.ts | 29 +++++++++-------------------- 1 file changed, 9 insertions(+), 20 deletions(-) diff --git a/src/compiler/core.ts b/src/compiler/core.ts index f7ff8c27bf7..c76cd24f1b0 100644 --- a/src/compiler/core.ts +++ b/src/compiler/core.ts @@ -9,6 +9,15 @@ namespace ts { export const version = `${versionMajorMinor}.0`; } +namespace ts { + export function isExternalModuleNameRelative(moduleName: string): boolean { + // TypeScript 1.0 spec (April 2014): 11.2.1 + // An external module name is "relative" if the first term is "." or "..". + // Update: We also consider a path like `C:\foo.ts` "relative" because we do not search for it in `node_modules` or treat it as an ambient module. + return pathIsRelative(moduleName) || isRootedDiskPath(moduleName); + } +} + /* @internal */ namespace ts { @@ -40,7 +49,6 @@ namespace ts { return new MapCtr() as UnderscoreEscapedMap; } - /* @internal */ export function createSymbolTable(symbols?: ReadonlyArray): SymbolTable { const result = createMap() as SymbolTable; if (symbols) { @@ -1604,18 +1612,10 @@ namespace ts { return path && !isRootedDiskPath(path) && path.indexOf("://") !== -1; } - /* @internal */ export function pathIsRelative(path: string): boolean { return /^\.\.?($|[\\/])/.test(path); } - export function isExternalModuleNameRelative(moduleName: string): boolean { - // TypeScript 1.0 spec (April 2014): 11.2.1 - // An external module name is "relative" if the first term is "." or "..". - // Update: We also consider a path like `C:\foo.ts` "relative" because we do not search for it in `node_modules` or treat it as an ambient module. - return pathIsRelative(moduleName) || isRootedDiskPath(moduleName); - } - /** @deprecated Use `!isExternalModuleNameRelative(moduleName)` instead. */ export function moduleHasNonRelativeName(moduleName: string): boolean { return !isExternalModuleNameRelative(moduleName); @@ -1639,7 +1639,6 @@ namespace ts { return moduleResolution; } - /* @internal */ export function hasZeroOrOneAsteriskCharacter(str: string): boolean { let seenAsterisk = false; for (let i = 0; i < str.length; i++) { @@ -1864,17 +1863,14 @@ namespace ts { return true; } - /* @internal */ export function startsWith(str: string, prefix: string): boolean { return str.lastIndexOf(prefix, 0) === 0; } - /* @internal */ export function removePrefix(str: string, prefix: string): string { return startsWith(str, prefix) ? str.substr(prefix.length) : str; } - /* @internal */ export function endsWith(str: string, suffix: string): boolean { const expectedPos = str.length - suffix.length; return expectedPos >= 0 && str.indexOf(suffix, expectedPos) === expectedPos; @@ -1888,7 +1884,6 @@ namespace ts { return path.length > extension.length && endsWith(path, extension); } - /* @internal */ export function fileExtensionIsOneOf(path: string, extensions: ReadonlyArray): boolean { for (const extension of extensions) { if (fileExtensionIs(path, extension)) { @@ -1905,7 +1900,6 @@ namespace ts { const reservedCharacterPattern = /[^\w\s\/]/g; const wildcardCharCodes = [CharacterCodes.asterisk, CharacterCodes.question]; - /* @internal */ export const commonPackageFolders: ReadonlyArray = ["node_modules", "bower_components", "jspm_packages"]; const implicitExcludePathRegexPattern = `(?!(${commonPackageFolders.join("|")})(/|$))`; @@ -2523,7 +2517,6 @@ namespace ts { * Return an exact match if possible, or a pattern match, or undefined. * (These are verified by verifyCompilerOptions to have 0 or 1 "*" characters.) */ - /* @internal */ export function matchPatternOrExact(patternStrings: ReadonlyArray, candidate: string): string | Pattern | undefined { const patterns: Pattern[] = []; for (const patternString of patternStrings) { @@ -2540,7 +2533,6 @@ namespace ts { return findBestPatternMatch(patterns, _ => _, candidate); } - /* @internal */ export function patternText({prefix, suffix}: Pattern): string { return `${prefix}*${suffix}`; } @@ -2549,14 +2541,12 @@ namespace ts { * Given that candidate matches pattern, returns the text matching the '*'. * E.g.: matchedText(tryParsePattern("foo*baz"), "foobarbaz") === "bar" */ - /* @internal */ export function matchedText(pattern: Pattern, candidate: string): string { Debug.assert(isPatternMatch(pattern, candidate)); return candidate.substr(pattern.prefix.length, candidate.length - pattern.suffix.length); } /** Return the object corresponding to the best pattern to match `candidate`. */ - /* @internal */ export function findBestPatternMatch(values: ReadonlyArray, getPattern: (value: T) => Pattern, candidate: string): T | undefined { let matchedValue: T | undefined = undefined; // use length of prefix as betterness criteria @@ -2579,7 +2569,6 @@ namespace ts { endsWith(candidate, suffix); } - /* @internal */ export function tryParsePattern(pattern: string): Pattern | undefined { // This should be verified outside of here and a proper error thrown. Debug.assert(hasZeroOrOneAsteriskCharacter(pattern)); From 39d0590869de4d94a16f9aa06334698d76fef5f9 Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Thu, 7 Sep 2017 09:54:50 -0700 Subject: [PATCH 253/370] Adds comment --- src/harness/unittests/languageService.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/harness/unittests/languageService.ts b/src/harness/unittests/languageService.ts index 9c838845c20..fd0a95c167f 100644 --- a/src/harness/unittests/languageService.ts +++ b/src/harness/unittests/languageService.ts @@ -17,6 +17,8 @@ class Carousel extends Vue { "vue-class-component.d.ts": `import Vue from "./vue"; export function Component(x: Config): any;` }; + // Regression test for GH #18245 - bug in single line comment writer caused a debug assertion when attempting + // to write an alias to a module's default export was referrenced across files and had no default export it("should be able to create a language service which can respond to deinition requests without throwing", () => { const languageService = ts.createLanguageService({ getCompilationSettings() { From c1f2afd64587042dc8094bb12ecdbde9d1731523 Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Thu, 7 Sep 2017 10:28:58 -0700 Subject: [PATCH 254/370] Add typedef declaration space, unify typedef name gathering (#18172) * Add typedef declaration space, unify typedef name gathering, strengthen errorUnusedLocal * Bonus round: make jsdoc presence way mroe typesafe * Be exhaustive in nameForNamelessJSDocTypedef * Remove nonrequired casts * Replace more casts with guards * Cannot be internal * Debug.fail returns never, assert never no longer needs unreachable throw to satisfy checker * Rename type * Add replacement message as in 18287 --- src/compiler/binder.ts | 17 +-- src/compiler/checker.ts | 9 +- src/compiler/core.ts | 6 +- src/compiler/parser.ts | 16 +- src/compiler/types.ts | 143 +++++++++++------- src/compiler/utilities.ts | 82 +++++++++- src/services/classifier.ts | 3 +- src/services/completions.ts | 2 +- src/services/navigationBar.ts | 14 +- src/services/services.ts | 2 +- .../reference/jsdocTypedefNoCrash.js | 13 ++ .../reference/jsdocTypedefNoCrash.symbols | 8 + .../reference/jsdocTypedefNoCrash.types | 9 ++ .../reference/jsdocTypedefNoCrash2.errors.txt | 12 ++ .../reference/jsdocTypedefNoCrash2.js | 14 ++ tests/cases/compiler/jsdocTypedefNoCrash.ts | 9 ++ tests/cases/compiler/jsdocTypedefNoCrash2.ts | 11 ++ 17 files changed, 279 insertions(+), 91 deletions(-) create mode 100644 tests/baselines/reference/jsdocTypedefNoCrash.js create mode 100644 tests/baselines/reference/jsdocTypedefNoCrash.symbols create mode 100644 tests/baselines/reference/jsdocTypedefNoCrash.types create mode 100644 tests/baselines/reference/jsdocTypedefNoCrash2.errors.txt create mode 100644 tests/baselines/reference/jsdocTypedefNoCrash2.js create mode 100644 tests/cases/compiler/jsdocTypedefNoCrash.ts create mode 100644 tests/cases/compiler/jsdocTypedefNoCrash2.ts diff --git a/src/compiler/binder.ts b/src/compiler/binder.ts index a7e94da09d9..d6d253e1d77 100644 --- a/src/compiler/binder.ts +++ b/src/compiler/binder.ts @@ -282,17 +282,8 @@ namespace ts { const index = indexOf(functionType.parameters, node); return "arg" + index as __String; case SyntaxKind.JSDocTypedefTag: - const parentNode = node.parent && node.parent.parent; - let nameFromParentNode: __String; - if (parentNode && parentNode.kind === SyntaxKind.VariableStatement) { - if ((parentNode).declarationList.declarations.length > 0) { - const nameIdentifier = (parentNode).declarationList.declarations[0].name; - if (isIdentifier(nameIdentifier)) { - nameFromParentNode = nameIdentifier.escapedText; - } - } - } - return nameFromParentNode; + const name = getNameOfJSDocTypedef(node as JSDocTypedefTag); + return typeof name !== "undefined" ? name.escapedText : undefined; } } @@ -598,7 +589,7 @@ namespace ts { // Binding of JsDocComment should be done before the current block scope container changes. // because the scope of JsDocComment should not be affected by whether the current node is a // container or not. - if (node.jsDoc) { + if (hasJSDocNodes(node)) { if (isInJavaScriptFile(node)) { for (const j of node.jsDoc) { bind(j); @@ -1931,7 +1922,7 @@ namespace ts { } function bindJSDocTypedefTagIfAny(node: Node) { - if (!node.jsDoc) { + if (!hasJSDocNodes(node)) { return; } diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index b7f0894d284..91653c140c8 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -19158,6 +19158,8 @@ namespace ts { switch (d.kind) { case SyntaxKind.InterfaceDeclaration: case SyntaxKind.TypeAliasDeclaration: + // A jsdoc typedef is, by definition, a type alias + case SyntaxKind.JSDocTypedefTag: return DeclarationSpaces.ExportType; case SyntaxKind.ModuleDeclaration: return isAmbientModule(d) || getModuleInstanceState(d) !== ModuleInstanceState.NonInstantiated @@ -19827,7 +19829,7 @@ namespace ts { } } else if (compilerOptions.noUnusedLocals) { - forEach(local.declarations, d => errorUnusedLocal(getNameOfDeclaration(d) || d, unescapeLeadingUnderscores(local.escapedName))); + forEach(local.declarations, d => errorUnusedLocal(d, unescapeLeadingUnderscores(local.escapedName))); } } }); @@ -19842,7 +19844,8 @@ namespace ts { return false; } - function errorUnusedLocal(node: Node, name: string) { + function errorUnusedLocal(declaration: Declaration, name: string) { + const node = getNameOfDeclaration(declaration) || declaration; if (isIdentifierThatStartsWithUnderScore(node)) { const declaration = getRootDeclaration(node.parent); if (declaration.kind === SyntaxKind.VariableDeclaration && isForInOrOfStatement(declaration.parent.parent)) { @@ -19909,7 +19912,7 @@ namespace ts { if (!local.isReferenced && !local.exportSymbol) { for (const declaration of local.declarations) { if (!isAmbientModule(declaration)) { - errorUnusedLocal(getNameOfDeclaration(declaration), unescapeLeadingUnderscores(local.escapedName)); + errorUnusedLocal(declaration, unescapeLeadingUnderscores(local.escapedName)); } } } diff --git a/src/compiler/core.ts b/src/compiler/core.ts index c76cd24f1b0..2c0416c0711 100644 --- a/src/compiler/core.ts +++ b/src/compiler/core.ts @@ -2441,7 +2441,7 @@ namespace ts { } } - export function fail(message?: string, stackCrawlMark?: Function): void { + export function fail(message?: string, stackCrawlMark?: Function): never { debugger; const e = new Error(message ? `Debug Failure. ${message}` : "Debug Failure."); if ((Error).captureStackTrace) { @@ -2450,6 +2450,10 @@ namespace ts { throw e; } + export function assertNever(member: never, message?: string, stackCrawlMark?: Function): never { + return fail(message || `Illegal value: ${member}`, stackCrawlMark || assertNever); + } + export function getFunctionName(func: Function) { if (typeof func !== "function") { return ""; diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index 71c7d3aac49..e30d5dbe1e4 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -729,7 +729,7 @@ namespace ts { } - function addJSDocComment(node: T): T { + function addJSDocComment(node: T): T { const comments = getJSDocCommentRanges(node, sourceFile.text); if (comments) { for (const comment of comments) { @@ -768,7 +768,7 @@ namespace ts { const saveParent = parent; parent = n; forEachChild(n, visitNode); - if (n.jsDoc) { + if (hasJSDocNodes(n)) { for (const jsDoc of n.jsDoc) { jsDoc.parent = n; parent = jsDoc; @@ -2158,7 +2158,7 @@ namespace ts { const result = createNode(SyntaxKind.JSDocFunctionType); nextToken(); fillSignature(SyntaxKind.ColonToken, SignatureFlags.Type | SignatureFlags.JSDoc, result); - return finishNode(result); + return addJSDocComment(finishNode(result)); } const node = createNode(SyntaxKind.TypeReference); node.typeName = parseIdentifierName(); @@ -2365,7 +2365,7 @@ namespace ts { parseSemicolon(); } - function parseSignatureMember(kind: SyntaxKind): CallSignatureDeclaration | ConstructSignatureDeclaration { + function parseSignatureMember(kind: SyntaxKind.CallSignature | SyntaxKind.ConstructSignature): CallSignatureDeclaration | ConstructSignatureDeclaration { const node = createNode(kind); if (kind === SyntaxKind.ConstructSignature) { parseExpected(SyntaxKind.NewKeyword); @@ -2445,7 +2445,7 @@ namespace ts { node.parameters = parseBracketedList(ParsingContext.Parameters, parseParameter, SyntaxKind.OpenBracketToken, SyntaxKind.CloseBracketToken); node.type = parseTypeAnnotation(); parseTypeMemberSemicolon(); - return finishNode(node); + return addJSDocComment(finishNode(node)); } function parsePropertyOrMethodSignature(fullStart: number, modifiers: NodeArray): PropertySignature | MethodSignature { @@ -2605,7 +2605,7 @@ namespace ts { parseExpected(SyntaxKind.NewKeyword); } fillSignature(SyntaxKind.EqualsGreaterThanToken, SignatureFlags.Type, node); - return finishNode(node); + return addJSDocComment(finishNode(node)); } function parseKeywordAndNoDot(): TypeNode | undefined { @@ -6182,7 +6182,7 @@ namespace ts { return jsDoc ? { jsDoc, diagnostics } : undefined; } - export function parseJSDocComment(parent: Node, start: number, length: number): JSDoc { + export function parseJSDocComment(parent: HasJSDoc, start: number, length: number): JSDoc { const saveToken = currentToken; const saveParseDiagnosticsLength = parseDiagnostics.length; const saveParseErrorBeforeNextFinishedNode = parseErrorBeforeNextFinishedNode; @@ -6997,7 +6997,7 @@ namespace ts { } forEachChild(node, visitNode, visitArray); - if (node.jsDoc) { + if (hasJSDocNodes(node)) { for (const jsDocComment of node.jsDoc) { forEachChild(jsDocComment, visitNode, visitArray); } diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 75e1cb05bc9..55baf9763c2 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -516,8 +516,6 @@ namespace ts { parent?: Node; // Parent node (initialized by binding) /* @internal */ original?: Node; // The original node if this is an updated node. /* @internal */ startsOnNewLine?: boolean; // Whether a synthesized node should start on a new line (used by transforms). - /* @internal */ jsDoc?: JSDoc[]; // JSDoc that directly precedes this node - /* @internal */ jsDocCache?: ReadonlyArray; // Cache for getJSDocTags /* @internal */ symbol?: Symbol; // Symbol declared by node (initialized by binding) /* @internal */ locals?: SymbolTable; // Locals associated with node (initialized by binding) /* @internal */ nextContainer?: Node; // Next container in declaration order (initialized by binding) @@ -528,6 +526,44 @@ namespace ts { /* @internal */ contextualMapper?: TypeMapper; // Mapper for contextual type } + export interface JSDocContainer { + /* @internal */ jsDoc?: JSDoc[]; // JSDoc that directly precedes this node + /* @internal */ jsDocCache?: ReadonlyArray; // Cache for getJSDocTags + } + + export type HasJSDoc = + | ParameterDeclaration + | CallSignatureDeclaration + | ConstructSignatureDeclaration + | MethodSignature + | PropertySignature + | ArrowFunction + | ParenthesizedExpression + | SpreadAssignment + | ShorthandPropertyAssignment + | PropertyAssignment + | FunctionExpression + | LabeledStatement + | ExpressionStatement + | VariableStatement + | FunctionDeclaration + | ConstructorDeclaration + | MethodDeclaration + | PropertyDeclaration + | AccessorDeclaration + | ClassLikeDeclaration + | InterfaceDeclaration + | TypeAliasDeclaration + | EnumMember + | EnumDeclaration + | ModuleDeclaration + | ImportEqualsDeclaration + | IndexSignatureDeclaration + | FunctionTypeNode + | ConstructorTypeNode + | JSDocFunctionType + | EndOfFileToken; + /* @internal */ export type MutableNodeArray = NodeArray & T[]; @@ -546,7 +582,7 @@ namespace ts { export type EqualsToken = Token; export type AsteriskToken = Token; export type EqualsGreaterThanToken = Token; - export type EndOfFileToken = Token; + export type EndOfFileToken = Token & JSDocContainer; export type AtToken = Token; export type ReadonlyToken = Token; export type AwaitKeywordToken = Token; @@ -651,32 +687,34 @@ namespace ts { expression?: Expression; } - export interface SignatureDeclaration extends NamedDeclaration { - kind: SyntaxKind.CallSignature - | SyntaxKind.ConstructSignature - | SyntaxKind.MethodSignature - | SyntaxKind.IndexSignature - | SyntaxKind.FunctionType - | SyntaxKind.ConstructorType - | SyntaxKind.JSDocFunctionType - | SyntaxKind.FunctionDeclaration - | SyntaxKind.MethodDeclaration - | SyntaxKind.Constructor - | SyntaxKind.GetAccessor - | SyntaxKind.SetAccessor - | SyntaxKind.FunctionExpression - | SyntaxKind.ArrowFunction; + export interface SignatureDeclarationBase extends NamedDeclaration, JSDocContainer { + kind: SignatureDeclaration["kind"]; name?: PropertyName; typeParameters?: NodeArray; parameters: NodeArray; type: TypeNode | undefined; } - export interface CallSignatureDeclaration extends SignatureDeclaration, TypeElement { + export type SignatureDeclaration = + | CallSignatureDeclaration + | ConstructSignatureDeclaration + | MethodSignature + | IndexSignatureDeclaration + | FunctionTypeNode + | ConstructorTypeNode + | JSDocFunctionType + | FunctionDeclaration + | MethodDeclaration + | ConstructorDeclaration + | AccessorDeclaration + | FunctionExpression + | ArrowFunction; + + export interface CallSignatureDeclaration extends SignatureDeclarationBase, TypeElement { kind: SyntaxKind.CallSignature; } - export interface ConstructSignatureDeclaration extends SignatureDeclaration, TypeElement { + export interface ConstructSignatureDeclaration extends SignatureDeclarationBase, TypeElement { kind: SyntaxKind.ConstructSignature; } @@ -696,7 +734,7 @@ namespace ts { declarations: NodeArray; } - export interface ParameterDeclaration extends NamedDeclaration { + export interface ParameterDeclaration extends NamedDeclaration, JSDocContainer { kind: SyntaxKind.Parameter; parent?: SignatureDeclaration; dotDotDotToken?: DotDotDotToken; // Present on rest parameter @@ -715,7 +753,7 @@ namespace ts { initializer?: Expression; // Optional initializer } - export interface PropertySignature extends TypeElement { + export interface PropertySignature extends TypeElement, JSDocContainer { kind: SyntaxKind.PropertySignature; name: PropertyName; // Declared property name questionToken?: QuestionToken; // Present on optional property @@ -723,7 +761,7 @@ namespace ts { initializer?: Expression; // Optional initializer } - export interface PropertyDeclaration extends ClassElement { + export interface PropertyDeclaration extends ClassElement, JSDocContainer { kind: SyntaxKind.PropertyDeclaration; questionToken?: QuestionToken; // Present for use with reporting a grammar error name: PropertyName; @@ -744,7 +782,7 @@ namespace ts { | AccessorDeclaration ; - export interface PropertyAssignment extends ObjectLiteralElement { + export interface PropertyAssignment extends ObjectLiteralElement, JSDocContainer { parent: ObjectLiteralExpression; kind: SyntaxKind.PropertyAssignment; name: PropertyName; @@ -752,7 +790,7 @@ namespace ts { initializer: Expression; } - export interface ShorthandPropertyAssignment extends ObjectLiteralElement { + export interface ShorthandPropertyAssignment extends ObjectLiteralElement, JSDocContainer { parent: ObjectLiteralExpression; kind: SyntaxKind.ShorthandPropertyAssignment; name: Identifier; @@ -763,7 +801,7 @@ namespace ts { objectAssignmentInitializer?: Expression; } - export interface SpreadAssignment extends ObjectLiteralElement { + export interface SpreadAssignment extends ObjectLiteralElement, JSDocContainer { parent: ObjectLiteralExpression; kind: SyntaxKind.SpreadAssignment; expression: Expression; @@ -816,7 +854,7 @@ namespace ts { * - MethodDeclaration * - AccessorDeclaration */ - export interface FunctionLikeDeclarationBase extends SignatureDeclaration { + export interface FunctionLikeDeclarationBase extends SignatureDeclarationBase { _functionLikeDeclarationBrand: any; asteriskToken?: AsteriskToken; @@ -847,7 +885,7 @@ namespace ts { body?: FunctionBody; } - export interface MethodSignature extends SignatureDeclaration, TypeElement { + export interface MethodSignature extends SignatureDeclarationBase, TypeElement { kind: SyntaxKind.MethodSignature; name: PropertyName; } @@ -861,13 +899,13 @@ namespace ts { // Because of this, it may be necessary to determine what sort of MethodDeclaration you have // at later stages of the compiler pipeline. In that case, you can either check the parent kind // of the method, or use helpers like isObjectLiteralMethodDeclaration - export interface MethodDeclaration extends FunctionLikeDeclarationBase, ClassElement, ObjectLiteralElement { + export interface MethodDeclaration extends FunctionLikeDeclarationBase, ClassElement, ObjectLiteralElement, JSDocContainer { kind: SyntaxKind.MethodDeclaration; name: PropertyName; body?: FunctionBody; } - export interface ConstructorDeclaration extends FunctionLikeDeclarationBase, ClassElement { + export interface ConstructorDeclaration extends FunctionLikeDeclarationBase, ClassElement, JSDocContainer { kind: SyntaxKind.Constructor; parent?: ClassDeclaration | ClassExpression; body?: FunctionBody; @@ -881,7 +919,7 @@ namespace ts { // See the comment on MethodDeclaration for the intuition behind GetAccessorDeclaration being a // ClassElement and an ObjectLiteralElement. - export interface GetAccessorDeclaration extends FunctionLikeDeclarationBase, ClassElement, ObjectLiteralElement { + export interface GetAccessorDeclaration extends FunctionLikeDeclarationBase, ClassElement, ObjectLiteralElement, JSDocContainer { kind: SyntaxKind.GetAccessor; parent?: ClassDeclaration | ClassExpression | ObjectLiteralExpression; name: PropertyName; @@ -890,7 +928,7 @@ namespace ts { // See the comment on MethodDeclaration for the intuition behind SetAccessorDeclaration being a // ClassElement and an ObjectLiteralElement. - export interface SetAccessorDeclaration extends FunctionLikeDeclarationBase, ClassElement, ObjectLiteralElement { + export interface SetAccessorDeclaration extends FunctionLikeDeclarationBase, ClassElement, ObjectLiteralElement, JSDocContainer { kind: SyntaxKind.SetAccessor; parent?: ClassDeclaration | ClassExpression | ObjectLiteralExpression; name: PropertyName; @@ -899,7 +937,7 @@ namespace ts { export type AccessorDeclaration = GetAccessorDeclaration | SetAccessorDeclaration; - export interface IndexSignatureDeclaration extends SignatureDeclaration, ClassElement, TypeElement { + export interface IndexSignatureDeclaration extends SignatureDeclarationBase, ClassElement, TypeElement { kind: SyntaxKind.IndexSignature; parent?: ClassDeclaration | ClassExpression | InterfaceDeclaration | TypeLiteralNode; } @@ -928,11 +966,11 @@ namespace ts { export type FunctionOrConstructorTypeNode = FunctionTypeNode | ConstructorTypeNode; - export interface FunctionTypeNode extends TypeNode, SignatureDeclaration { + export interface FunctionTypeNode extends TypeNode, SignatureDeclarationBase { kind: SyntaxKind.FunctionType; } - export interface ConstructorTypeNode extends TypeNode, SignatureDeclaration { + export interface ConstructorTypeNode extends TypeNode, SignatureDeclarationBase { kind: SyntaxKind.ConstructorType; } @@ -1355,13 +1393,13 @@ namespace ts { export type FunctionBody = Block; export type ConciseBody = FunctionBody | Expression; - export interface FunctionExpression extends PrimaryExpression, FunctionLikeDeclarationBase { + export interface FunctionExpression extends PrimaryExpression, FunctionLikeDeclarationBase, JSDocContainer { kind: SyntaxKind.FunctionExpression; name?: Identifier; body: FunctionBody; // Required, whereas the member inherited from FunctionDeclaration is optional } - export interface ArrowFunction extends Expression, FunctionLikeDeclarationBase { + export interface ArrowFunction extends Expression, FunctionLikeDeclarationBase, JSDocContainer { kind: SyntaxKind.ArrowFunction; equalsGreaterThanToken: EqualsGreaterThanToken; body: ConciseBody; @@ -1440,7 +1478,7 @@ namespace ts { literal: TemplateMiddle | TemplateTail; } - export interface ParenthesizedExpression extends PrimaryExpression { + export interface ParenthesizedExpression extends PrimaryExpression, JSDocContainer { kind: SyntaxKind.ParenthesizedExpression; expression: Expression; } @@ -1696,12 +1734,12 @@ namespace ts { /*@internal*/ multiLine?: boolean; } - export interface VariableStatement extends Statement { + export interface VariableStatement extends Statement, JSDocContainer { kind: SyntaxKind.VariableStatement; declarationList: VariableDeclarationList; } - export interface ExpressionStatement extends Statement { + export interface ExpressionStatement extends Statement, JSDocContainer { kind: SyntaxKind.ExpressionStatement; expression: Expression; } @@ -1807,7 +1845,7 @@ namespace ts { export type CaseOrDefaultClause = CaseClause | DefaultClause; - export interface LabeledStatement extends Statement { + export interface LabeledStatement extends Statement, JSDocContainer { kind: SyntaxKind.LabeledStatement; label: Identifier; statement: Statement; @@ -1834,7 +1872,7 @@ namespace ts { export type DeclarationWithTypeParameters = SignatureDeclaration | ClassLikeDeclaration | InterfaceDeclaration | TypeAliasDeclaration | JSDocTemplateTag; - export interface ClassLikeDeclaration extends NamedDeclaration { + export interface ClassLikeDeclarationBase extends NamedDeclaration, JSDocContainer { kind: SyntaxKind.ClassDeclaration | SyntaxKind.ClassExpression; name?: Identifier; typeParameters?: NodeArray; @@ -1842,15 +1880,17 @@ namespace ts { members: NodeArray; } - export interface ClassDeclaration extends ClassLikeDeclaration, DeclarationStatement { + export interface ClassDeclaration extends ClassLikeDeclarationBase, DeclarationStatement { kind: SyntaxKind.ClassDeclaration; name?: Identifier; } - export interface ClassExpression extends ClassLikeDeclaration, PrimaryExpression { + export interface ClassExpression extends ClassLikeDeclarationBase, PrimaryExpression { kind: SyntaxKind.ClassExpression; } + export type ClassLikeDeclaration = ClassDeclaration | ClassExpression; + export interface ClassElement extends NamedDeclaration { _classElementBrand: any; name?: PropertyName; @@ -1862,7 +1902,7 @@ namespace ts { questionToken?: QuestionToken; } - export interface InterfaceDeclaration extends DeclarationStatement { + export interface InterfaceDeclaration extends DeclarationStatement, JSDocContainer { kind: SyntaxKind.InterfaceDeclaration; name: Identifier; typeParameters?: NodeArray; @@ -1877,14 +1917,14 @@ namespace ts { types: NodeArray; } - export interface TypeAliasDeclaration extends DeclarationStatement { + export interface TypeAliasDeclaration extends DeclarationStatement, JSDocContainer { kind: SyntaxKind.TypeAliasDeclaration; name: Identifier; typeParameters?: NodeArray; type: TypeNode; } - export interface EnumMember extends NamedDeclaration { + export interface EnumMember extends NamedDeclaration, JSDocContainer { kind: SyntaxKind.EnumMember; parent?: EnumDeclaration; // This does include ComputedPropertyName, but the parser will give an error @@ -1893,7 +1933,7 @@ namespace ts { initializer?: Expression; } - export interface EnumDeclaration extends DeclarationStatement { + export interface EnumDeclaration extends DeclarationStatement, JSDocContainer { kind: SyntaxKind.EnumDeclaration; name: Identifier; members: NodeArray; @@ -1903,7 +1943,7 @@ namespace ts { export type ModuleBody = NamespaceBody | JSDocNamespaceBody; - export interface ModuleDeclaration extends DeclarationStatement { + export interface ModuleDeclaration extends DeclarationStatement, JSDocContainer { kind: SyntaxKind.ModuleDeclaration; parent?: ModuleBody | SourceFile; name: ModuleName; @@ -1937,7 +1977,7 @@ namespace ts { * - import x = require("mod"); * - import x = M.x; */ - export interface ImportEqualsDeclaration extends DeclarationStatement { + export interface ImportEqualsDeclaration extends DeclarationStatement, JSDocContainer { kind: SyntaxKind.ImportEqualsDeclaration; parent?: SourceFile | ModuleBlock; name: Identifier; @@ -2090,7 +2130,7 @@ namespace ts { type: TypeNode; } - export interface JSDocFunctionType extends JSDocType, SignatureDeclaration { + export interface JSDocFunctionType extends JSDocType, SignatureDeclarationBase { kind: SyntaxKind.JSDocFunctionType; } @@ -2103,6 +2143,7 @@ namespace ts { export interface JSDoc extends Node { kind: SyntaxKind.JSDocComment; + parent?: HasJSDoc; tags: NodeArray | undefined; comment: string | undefined; } diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index 725070c02bf..11c30a2d8ab 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -277,7 +277,7 @@ namespace ts { return skipTrivia((sourceFile || getSourceFileOfNode(node)).text, node.pos, /*stopAfterLineBreak*/ false, /*stopAtComments*/ true); } - if (includeJsDoc && node.jsDoc && node.jsDoc.length > 0) { + if (includeJsDoc && hasJSDocNodes(node)) { return getTokenPosOfNode(node.jsDoc[0]); } @@ -1510,10 +1510,10 @@ namespace ts { } export function getJSDocTags(node: Node): ReadonlyArray | undefined { - let tags = node.jsDocCache; + let tags = (node as JSDocContainer).jsDocCache; // If cache is 'null', that means we did the work of searching for JSDoc tags and came up with nothing. if (tags === undefined) { - node.jsDocCache = tags = flatMap(getJSDocCommentsAndTags(node), j => isJSDoc(j) ? j.tags : j); + (node as JSDocContainer).jsDocCache = tags = flatMap(getJSDocCommentsAndTags(node), j => isJSDoc(j) ? j.tags : j); } return tags; } @@ -1567,11 +1567,13 @@ namespace ts { result = addRange(result, getJSDocParameterTags(node as ParameterDeclaration)); } - if (isVariableLike(node) && node.initializer) { + if (isVariableLike(node) && node.initializer && hasJSDocNodes(node.initializer)) { result = addRange(result, node.initializer.jsDoc); } - result = addRange(result, node.jsDoc); + if (hasJSDocNodes(node)) { + result = addRange(result, node.jsDoc); + } } } @@ -3958,7 +3960,66 @@ namespace ts { return id; } - export function getNameOfDeclaration(declaration: Declaration): DeclarationName | undefined { + /** + * A JSDocTypedef tag has an _optional_ name field - if a name is not directly present, we should + * attempt to draw the name from the node the declaration is on (as that declaration is what its' symbol + * will be merged with) + */ + function nameForNamelessJSDocTypedef(declaration: JSDocTypedefTag): Identifier | undefined { + const hostNode = declaration.parent.parent; + if (!hostNode) { + return undefined; + } + // Covers classes, functions - any named declaration host node + if (isDeclaration(hostNode)) { + return getDeclarationIdentifier(hostNode); + } + // Covers remaining cases + switch (hostNode.kind) { + case SyntaxKind.VariableStatement: + if ((hostNode as VariableStatement).declarationList && + (hostNode as VariableStatement).declarationList.declarations[0]) { + return getDeclarationIdentifier((hostNode as VariableStatement).declarationList.declarations[0]); + } + return undefined; + case SyntaxKind.ExpressionStatement: + const expr = (hostNode as ExpressionStatement).expression; + switch (expr.kind) { + case SyntaxKind.PropertyAccessExpression: + return (expr as PropertyAccessExpression).name; + case SyntaxKind.ElementAccessExpression: + const arg = (expr as ElementAccessExpression).argumentExpression; + if (isIdentifier(arg)) { + return arg; + } + } + return undefined; + case SyntaxKind.EndOfFileToken: + return undefined; + case SyntaxKind.ParenthesizedExpression: { + return getDeclarationIdentifier(hostNode.expression); + } + case SyntaxKind.LabeledStatement: { + if (isDeclaration(hostNode.statement) || isExpression(hostNode.statement)) { + return getDeclarationIdentifier(hostNode.statement); + } + return undefined; + } + default: + Debug.assertNever(hostNode, "Found typedef tag attached to node which it should not be!"); + } + } + + function getDeclarationIdentifier(node: Declaration | Expression) { + const name = getNameOfDeclaration(node); + return isIdentifier(name) ? name : undefined; + } + + export function getNameOfJSDocTypedef(declaration: JSDocTypedefTag): Identifier | undefined { + return declaration.name || nameForNamelessJSDocTypedef(declaration as JSDocTypedefTag); + } + + export function getNameOfDeclaration(declaration: Declaration | Expression): DeclarationName | undefined { if (!declaration) { return undefined; } @@ -3977,6 +4038,9 @@ namespace ts { return undefined; } } + else if (declaration.kind === SyntaxKind.JSDocTypedefTag) { + return getNameOfJSDocTypedef(declaration as JSDocTypedefTag); + } else { return (declaration as NamedDeclaration).name; } @@ -5365,4 +5429,10 @@ namespace ts { export function isJSDocTag(node: Node): boolean { return node.kind >= SyntaxKind.FirstJSDocTagNode && node.kind <= SyntaxKind.LastJSDocTagNode; } + + /** True if has jsdoc nodes attached to it. */ + /* @internal */ + export function hasJSDocNodes(node: Node): node is HasJSDoc { + return !!(node as JSDocContainer).jsDoc && (node as JSDocContainer).jsDoc.length > 0; + } } diff --git a/src/services/classifier.ts b/src/services/classifier.ts index 4552d8bf985..18eec066ea2 100644 --- a/src/services/classifier.ts +++ b/src/services/classifier.ts @@ -699,7 +699,8 @@ namespace ts { // specially. const docCommentAndDiagnostics = parseIsolatedJSDocComment(sourceFile.text, start, width); if (docCommentAndDiagnostics && docCommentAndDiagnostics.jsDoc) { - docCommentAndDiagnostics.jsDoc.parent = token; + // TODO: This should be predicated on `token["kind"]` being compatible with `HasJSDoc["kind"]` + docCommentAndDiagnostics.jsDoc.parent = token as HasJSDoc; classifyJSDocComment(docCommentAndDiagnostics.jsDoc); return; } diff --git a/src/services/completions.ts b/src/services/completions.ts index 97998ec724b..15a20798508 100644 --- a/src/services/completions.ts +++ b/src/services/completions.ts @@ -1739,7 +1739,7 @@ namespace ts.Completions { /** Get the corresponding JSDocTag node if the position is in a jsDoc comment */ function getJsDocTagAtPosition(node: Node, position: number): JSDocTag | undefined { - const { jsDoc } = getJsDocHavingNode(node); + const { jsDoc } = getJsDocHavingNode(node) as JSDocContainer; if (!jsDoc) return undefined; for (const { pos, end, tags } of jsDoc) { diff --git a/src/services/navigationBar.ts b/src/services/navigationBar.ts index 35357b9331a..f7ed515a18f 100644 --- a/src/services/navigationBar.ts +++ b/src/services/navigationBar.ts @@ -263,13 +263,15 @@ namespace ts.NavigationBar { break; default: - forEach(node.jsDoc, jsDoc => { - forEach(jsDoc.tags, tag => { - if (tag.kind === SyntaxKind.JSDocTypedefTag) { - addLeafNode(tag); - } + if (hasJSDocNodes(node)) { + forEach(node.jsDoc, jsDoc => { + forEach(jsDoc.tags, tag => { + if (tag.kind === SyntaxKind.JSDocTypedefTag) { + addLeafNode(tag); + } + }); }); - }); + } forEachChild(node, addChildrenRecursively); } diff --git a/src/services/services.ts b/src/services/services.ts index e0e3bea79ff..1feafdd55f5 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -2111,7 +2111,7 @@ namespace ts { } forEachChild(node, walk); - if (node.jsDoc) { + if (hasJSDocNodes(node)) { for (const jsDoc of node.jsDoc) { forEachChild(jsDoc, walk); } diff --git a/tests/baselines/reference/jsdocTypedefNoCrash.js b/tests/baselines/reference/jsdocTypedefNoCrash.js new file mode 100644 index 00000000000..803f6b1bb85 --- /dev/null +++ b/tests/baselines/reference/jsdocTypedefNoCrash.js @@ -0,0 +1,13 @@ +//// [export.js] +/** + * @typedef {{ + * }} + */ +export const foo = 5; + +//// [export.js] +/** + * @typedef {{ + * }} + */ +export const foo = 5; diff --git a/tests/baselines/reference/jsdocTypedefNoCrash.symbols b/tests/baselines/reference/jsdocTypedefNoCrash.symbols new file mode 100644 index 00000000000..8724c9da8d1 --- /dev/null +++ b/tests/baselines/reference/jsdocTypedefNoCrash.symbols @@ -0,0 +1,8 @@ +=== tests/cases/compiler/export.js === +/** + * @typedef {{ + * }} + */ +export const foo = 5; +>foo : Symbol(foo, Decl(export.js, 4, 12)) + diff --git a/tests/baselines/reference/jsdocTypedefNoCrash.types b/tests/baselines/reference/jsdocTypedefNoCrash.types new file mode 100644 index 00000000000..e05c4421a79 --- /dev/null +++ b/tests/baselines/reference/jsdocTypedefNoCrash.types @@ -0,0 +1,9 @@ +=== tests/cases/compiler/export.js === +/** + * @typedef {{ + * }} + */ +export const foo = 5; +>foo : 5 +>5 : 5 + diff --git a/tests/baselines/reference/jsdocTypedefNoCrash2.errors.txt b/tests/baselines/reference/jsdocTypedefNoCrash2.errors.txt new file mode 100644 index 00000000000..6c4a15e5947 --- /dev/null +++ b/tests/baselines/reference/jsdocTypedefNoCrash2.errors.txt @@ -0,0 +1,12 @@ +tests/cases/compiler/export.js(1,13): error TS8008: 'type aliases' can only be used in a .ts file. + + +==== tests/cases/compiler/export.js (1 errors) ==== + export type foo = 5; + ~~~ +!!! error TS8008: 'type aliases' can only be used in a .ts file. + /** + * @typedef {{ + * }} + */ + export const foo = 5; \ No newline at end of file diff --git a/tests/baselines/reference/jsdocTypedefNoCrash2.js b/tests/baselines/reference/jsdocTypedefNoCrash2.js new file mode 100644 index 00000000000..397ca973d1e --- /dev/null +++ b/tests/baselines/reference/jsdocTypedefNoCrash2.js @@ -0,0 +1,14 @@ +//// [export.js] +export type foo = 5; +/** + * @typedef {{ + * }} + */ +export const foo = 5; + +//// [export.js] +/** + * @typedef {{ + * }} + */ +export const foo = 5; diff --git a/tests/cases/compiler/jsdocTypedefNoCrash.ts b/tests/cases/compiler/jsdocTypedefNoCrash.ts new file mode 100644 index 00000000000..cb8f5df09ef --- /dev/null +++ b/tests/cases/compiler/jsdocTypedefNoCrash.ts @@ -0,0 +1,9 @@ +// @target: es6 +// @allowJs: true +// @outDir: ./dist +// @filename: export.js +/** + * @typedef {{ + * }} + */ +export const foo = 5; \ No newline at end of file diff --git a/tests/cases/compiler/jsdocTypedefNoCrash2.ts b/tests/cases/compiler/jsdocTypedefNoCrash2.ts new file mode 100644 index 00000000000..d41fb62e446 --- /dev/null +++ b/tests/cases/compiler/jsdocTypedefNoCrash2.ts @@ -0,0 +1,11 @@ +// @target: es6 +// @allowJs: true +// @outDir: ./dist +// @filename: export.js + +export type foo = 5; +/** + * @typedef {{ + * }} + */ +export const foo = 5; \ No newline at end of file From de313ff1bd11daf484aa421a5d9fde954b8e6fc7 Mon Sep 17 00:00:00 2001 From: Alex Chugaev Date: Thu, 7 Sep 2017 20:58:05 +0300 Subject: [PATCH 255/370] Object.getOwnPropertyDescriptor() returns 'undefined' if property descriptor not found. (#18148) --- src/lib/es2015.core.d.ts | 2 +- src/lib/es2015.reflect.d.ts | 2 +- src/lib/es5.d.ts | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/lib/es2015.core.d.ts b/src/lib/es2015.core.d.ts index 0deef59a47d..42d3d1543a0 100644 --- a/src/lib/es2015.core.d.ts +++ b/src/lib/es2015.core.d.ts @@ -327,7 +327,7 @@ interface ObjectConstructor { * @param o Object that contains the property. * @param p Name of the property. */ - getOwnPropertyDescriptor(o: any, propertyKey: PropertyKey): PropertyDescriptor; + getOwnPropertyDescriptor(o: any, propertyKey: PropertyKey): PropertyDescriptor | undefined; /** * Adds a property to an object, or modifies attributes of an existing property. diff --git a/src/lib/es2015.reflect.d.ts b/src/lib/es2015.reflect.d.ts index 83755e4c791..aab3da993dc 100644 --- a/src/lib/es2015.reflect.d.ts +++ b/src/lib/es2015.reflect.d.ts @@ -4,7 +4,7 @@ declare namespace Reflect { function defineProperty(target: object, propertyKey: PropertyKey, attributes: PropertyDescriptor): boolean; function deleteProperty(target: object, propertyKey: PropertyKey): boolean; function get(target: object, propertyKey: PropertyKey, receiver?: any): any; - function getOwnPropertyDescriptor(target: object, propertyKey: PropertyKey): PropertyDescriptor; + function getOwnPropertyDescriptor(target: object, propertyKey: PropertyKey): PropertyDescriptor | undefined; function getPrototypeOf(target: object): object; function has(target: object, propertyKey: PropertyKey): boolean; function isExtensible(target: object): boolean; diff --git a/src/lib/es5.d.ts b/src/lib/es5.d.ts index 4dae997ffb4..6033a8fd989 100644 --- a/src/lib/es5.d.ts +++ b/src/lib/es5.d.ts @@ -127,7 +127,7 @@ interface ObjectConstructor { * @param o Object that contains the property. * @param p Name of the property. */ - getOwnPropertyDescriptor(o: any, p: string): PropertyDescriptor; + getOwnPropertyDescriptor(o: any, p: string): PropertyDescriptor | undefined; /** * Returns the names of the own properties of an object. The own properties of an object are those that are defined directly From 097b094082827c2055a401686a4b5aec30afbfe6 Mon Sep 17 00:00:00 2001 From: Andrew Casey Date: Thu, 7 Sep 2017 10:58:50 -0700 Subject: [PATCH 256/370] Don't get typings for projects with disabled language services --- src/server/project.ts | 41 ++++++++++++++++++++--------------------- 1 file changed, 20 insertions(+), 21 deletions(-) diff --git a/src/server/project.ts b/src/server/project.ts index 623c43e8d3a..c8e9e1b4833 100644 --- a/src/server/project.ts +++ b/src/server/project.ts @@ -547,33 +547,32 @@ namespace ts.server { this.cachedUnresolvedImportsPerFile.remove(file); } - // 1. no changes in structure, no changes in unresolved imports - do nothing - // 2. no changes in structure, unresolved imports were changed - collect unresolved imports for all files - // (can reuse cached imports for files that were not changed) - // 3. new files were added/removed, but compilation settings stays the same - collect unresolved imports for all new/modified files - // (can reuse cached imports for files that were not changed) - // 4. compilation settings were changed in the way that might affect module resolution - drop all caches and collect all data from the scratch - let unresolvedImports: SortedReadonlyArray; - if (hasChanges || changedFiles.length) { - const result: string[] = []; - for (const sourceFile of this.program.getSourceFiles()) { - this.extractUnresolvedImportsFromSourceFile(sourceFile, result); - } - this.lastCachedUnresolvedImportsList = toDeduplicatedSortedArray(result); - } - unresolvedImports = this.lastCachedUnresolvedImportsList; - - const cachedTypings = this.projectService.typingsCache.getTypingsForProject(this, unresolvedImports, hasChanges); - if (this.setTypings(cachedTypings)) { - hasChanges = this.updateGraphWorker() || hasChanges; - } - // update builder only if language service is enabled // otherwise tell it to drop its internal state if (this.languageServiceEnabled) { + // 1. no changes in structure, no changes in unresolved imports - do nothing + // 2. no changes in structure, unresolved imports were changed - collect unresolved imports for all files + // (can reuse cached imports for files that were not changed) + // 3. new files were added/removed, but compilation settings stays the same - collect unresolved imports for all new/modified files + // (can reuse cached imports for files that were not changed) + // 4. compilation settings were changed in the way that might affect module resolution - drop all caches and collect all data from the scratch + if (hasChanges || changedFiles.length) { + const result: string[] = []; + for (const sourceFile of this.program.getSourceFiles()) { + this.extractUnresolvedImportsFromSourceFile(sourceFile, result); + } + this.lastCachedUnresolvedImportsList = toDeduplicatedSortedArray(result); + } + + const cachedTypings = this.projectService.typingsCache.getTypingsForProject(this, this.lastCachedUnresolvedImportsList, hasChanges); + if (this.setTypings(cachedTypings)) { + hasChanges = this.updateGraphWorker() || hasChanges; + } + this.builder.onProjectUpdateGraph(); } else { + this.lastCachedUnresolvedImportsList = undefined; this.builder.clear(); } From ac58751b6239aeb2c4a980644c4db48ee4bf3c27 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Thu, 7 Sep 2017 11:30:38 -0700 Subject: [PATCH 257/370] Object literals computed property names allow literal-typed expressions --- src/compiler/checker.ts | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index b7f0894d284..d33fc9ced56 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -13526,6 +13526,7 @@ namespace ts { for (let i = 0; i < node.properties.length; i++) { const memberDecl = node.properties[i]; let member = memberDecl.symbol; + let literalName: __String | undefined; if (memberDecl.kind === SyntaxKind.PropertyAssignment || memberDecl.kind === SyntaxKind.ShorthandPropertyAssignment || isObjectLiteralMethod(memberDecl)) { @@ -13536,6 +13537,12 @@ namespace ts { let type: Type; if (memberDecl.kind === SyntaxKind.PropertyAssignment) { + if (memberDecl.name.kind === SyntaxKind.ComputedPropertyName) { + const t = checkComputedPropertyName(memberDecl.name); + if (t.flags & TypeFlags.Literal) { + literalName = escapeLeadingUnderscores("" + (t as LiteralType).value); + } + } type = checkPropertyAssignment(memberDecl, checkMode); } else if (memberDecl.kind === SyntaxKind.MethodDeclaration) { @@ -13552,7 +13559,7 @@ namespace ts { } typeFlags |= type.flags; - const prop = createSymbol(SymbolFlags.Property | member.flags, member.escapedName); + const prop = createSymbol(SymbolFlags.Property | member.flags, literalName || member.escapedName); 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. @@ -13562,7 +13569,7 @@ namespace ts { if (isOptional) { prop.flags |= SymbolFlags.Optional; } - if (hasDynamicName(memberDecl)) { + if (!literalName && hasDynamicName(memberDecl)) { patternWithComputedProperties = true; } } @@ -13620,7 +13627,7 @@ namespace ts { checkNodeDeferred(memberDecl); } - if (hasDynamicName(memberDecl)) { + if (!literalName && hasDynamicName(memberDecl)) { if (isNumericName(memberDecl.name)) { hasComputedNumberProperty = true; } From 3c5b2a5e9d43c3f8b0f92e61208775ad9ffb5c05 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Thu, 7 Sep 2017 11:41:13 -0700 Subject: [PATCH 258/370] Test Literal-typed computed property names in obj literals --- .../computedPropertyNames46_ES5.types | 4 +- .../computedPropertyNames46_ES6.types | 4 +- .../computedPropertyNames47_ES5.types | 4 +- .../computedPropertyNames47_ES6.types | 4 +- .../computedPropertyNames48_ES5.types | 4 +- .../computedPropertyNames48_ES6.types | 4 +- .../computedPropertyNames4_ES5.types | 4 +- .../computedPropertyNames4_ES6.types | 4 +- .../computedPropertyNames7_ES5.types | 4 +- .../computedPropertyNames7_ES6.types | 4 +- .../objectLiteralEnumPropertyNames.js | 108 +++++++++++ .../objectLiteralEnumPropertyNames.symbols | 144 ++++++++++++++ .../objectLiteralEnumPropertyNames.types | 177 ++++++++++++++++++ .../objectLiteralEnumPropertyNames.ts | 52 +++++ 14 files changed, 501 insertions(+), 20 deletions(-) create mode 100644 tests/baselines/reference/objectLiteralEnumPropertyNames.js create mode 100644 tests/baselines/reference/objectLiteralEnumPropertyNames.symbols create mode 100644 tests/baselines/reference/objectLiteralEnumPropertyNames.types create mode 100644 tests/cases/compiler/objectLiteralEnumPropertyNames.ts diff --git a/tests/baselines/reference/computedPropertyNames46_ES5.types b/tests/baselines/reference/computedPropertyNames46_ES5.types index 7ea3ffda244..e90d1a6c498 100644 --- a/tests/baselines/reference/computedPropertyNames46_ES5.types +++ b/tests/baselines/reference/computedPropertyNames46_ES5.types @@ -1,7 +1,7 @@ === tests/cases/conformance/es6/computedProperties/computedPropertyNames46_ES5.ts === var o = { ->o : { [x: number]: number; } ->{ ["" || 0]: 0} : { [x: number]: number; } +>o : { ["" || 0]: number; } +>{ ["" || 0]: 0} : { ["" || 0]: number; } ["" || 0]: 0 >"" || 0 : 0 diff --git a/tests/baselines/reference/computedPropertyNames46_ES6.types b/tests/baselines/reference/computedPropertyNames46_ES6.types index 3914f6facef..34aac7489c9 100644 --- a/tests/baselines/reference/computedPropertyNames46_ES6.types +++ b/tests/baselines/reference/computedPropertyNames46_ES6.types @@ -1,7 +1,7 @@ === tests/cases/conformance/es6/computedProperties/computedPropertyNames46_ES6.ts === var o = { ->o : { [x: number]: number; } ->{ ["" || 0]: 0} : { [x: number]: number; } +>o : { ["" || 0]: number; } +>{ ["" || 0]: 0} : { ["" || 0]: number; } ["" || 0]: 0 >"" || 0 : 0 diff --git a/tests/baselines/reference/computedPropertyNames47_ES5.types b/tests/baselines/reference/computedPropertyNames47_ES5.types index 137f3d63d38..9c01db09846 100644 --- a/tests/baselines/reference/computedPropertyNames47_ES5.types +++ b/tests/baselines/reference/computedPropertyNames47_ES5.types @@ -8,8 +8,8 @@ enum E2 { x } >x : E2 var o = { ->o : { [x: number]: number; } ->{ [E1.x || E2.x]: 0} : { [x: number]: number; } +>o : { [E1.x || E2.x]: number; } +>{ [E1.x || E2.x]: 0} : { [E1.x || E2.x]: number; } [E1.x || E2.x]: 0 >E1.x || E2.x : E2 diff --git a/tests/baselines/reference/computedPropertyNames47_ES6.types b/tests/baselines/reference/computedPropertyNames47_ES6.types index 04c18df83a7..c2e65523e46 100644 --- a/tests/baselines/reference/computedPropertyNames47_ES6.types +++ b/tests/baselines/reference/computedPropertyNames47_ES6.types @@ -8,8 +8,8 @@ enum E2 { x } >x : E2 var o = { ->o : { [x: number]: number; } ->{ [E1.x || E2.x]: 0} : { [x: number]: number; } +>o : { [E1.x || E2.x]: number; } +>{ [E1.x || E2.x]: 0} : { [E1.x || E2.x]: number; } [E1.x || E2.x]: 0 >E1.x || E2.x : E2 diff --git a/tests/baselines/reference/computedPropertyNames48_ES5.types b/tests/baselines/reference/computedPropertyNames48_ES5.types index 545dc641434..25818fff967 100644 --- a/tests/baselines/reference/computedPropertyNames48_ES5.types +++ b/tests/baselines/reference/computedPropertyNames48_ES5.types @@ -28,7 +28,7 @@ extractIndexer({ extractIndexer({ >extractIndexer({ [E.x]: ""}) : string >extractIndexer : (p: { [n: number]: T; }) => T ->{ [E.x]: ""} : { [x: number]: string; } +>{ [E.x]: ""} : { [E.x]: string; } [E.x]: "" >E.x : E @@ -41,7 +41,7 @@ extractIndexer({ extractIndexer({ >extractIndexer({ ["" || 0]: ""}) : string >extractIndexer : (p: { [n: number]: T; }) => T ->{ ["" || 0]: ""} : { [x: number]: string; } +>{ ["" || 0]: ""} : { ["" || 0]: string; } ["" || 0]: "" >"" || 0 : 0 diff --git a/tests/baselines/reference/computedPropertyNames48_ES6.types b/tests/baselines/reference/computedPropertyNames48_ES6.types index 0f352b57d24..65f93239f30 100644 --- a/tests/baselines/reference/computedPropertyNames48_ES6.types +++ b/tests/baselines/reference/computedPropertyNames48_ES6.types @@ -28,7 +28,7 @@ extractIndexer({ extractIndexer({ >extractIndexer({ [E.x]: ""}) : string >extractIndexer : (p: { [n: number]: T; }) => T ->{ [E.x]: ""} : { [x: number]: string; } +>{ [E.x]: ""} : { [E.x]: string; } [E.x]: "" >E.x : E @@ -41,7 +41,7 @@ extractIndexer({ extractIndexer({ >extractIndexer({ ["" || 0]: ""}) : string >extractIndexer : (p: { [n: number]: T; }) => T ->{ ["" || 0]: ""} : { [x: number]: string; } +>{ ["" || 0]: ""} : { ["" || 0]: string; } ["" || 0]: "" >"" || 0 : 0 diff --git a/tests/baselines/reference/computedPropertyNames4_ES5.types b/tests/baselines/reference/computedPropertyNames4_ES5.types index fc883aa2833..f0e105be4a7 100644 --- a/tests/baselines/reference/computedPropertyNames4_ES5.types +++ b/tests/baselines/reference/computedPropertyNames4_ES5.types @@ -9,8 +9,8 @@ var a: any; >a : any var v = { ->v : { [x: string]: string | number; [x: number]: string | number; [""]: number; [0]: number; } ->{ [s]: 0, [n]: n, [s + s]: 1, [s + n]: 2, [+s]: s, [""]: 0, [0]: 0, [a]: 1, [true]: 0, [`hello bye`]: 0, [`hello ${a} bye`]: 0} : { [x: string]: string | number; [x: number]: string | number; [""]: number; [0]: number; } +>v : { [x: string]: string | number; [x: number]: string | number; [""]: number; [0]: number; [`hello bye`]: number; } +>{ [s]: 0, [n]: n, [s + s]: 1, [s + n]: 2, [+s]: s, [""]: 0, [0]: 0, [a]: 1, [true]: 0, [`hello bye`]: 0, [`hello ${a} bye`]: 0} : { [x: string]: string | number; [x: number]: string | number; [""]: number; [0]: number; [`hello bye`]: number; } [s]: 0, >s : string diff --git a/tests/baselines/reference/computedPropertyNames4_ES6.types b/tests/baselines/reference/computedPropertyNames4_ES6.types index 5704841b97f..178eca88a72 100644 --- a/tests/baselines/reference/computedPropertyNames4_ES6.types +++ b/tests/baselines/reference/computedPropertyNames4_ES6.types @@ -9,8 +9,8 @@ var a: any; >a : any var v = { ->v : { [x: string]: string | number; [x: number]: string | number; [""]: number; [0]: number; } ->{ [s]: 0, [n]: n, [s + s]: 1, [s + n]: 2, [+s]: s, [""]: 0, [0]: 0, [a]: 1, [true]: 0, [`hello bye`]: 0, [`hello ${a} bye`]: 0} : { [x: string]: string | number; [x: number]: string | number; [""]: number; [0]: number; } +>v : { [x: string]: string | number; [x: number]: string | number; [""]: number; [0]: number; [`hello bye`]: number; } +>{ [s]: 0, [n]: n, [s + s]: 1, [s + n]: 2, [+s]: s, [""]: 0, [0]: 0, [a]: 1, [true]: 0, [`hello bye`]: 0, [`hello ${a} bye`]: 0} : { [x: string]: string | number; [x: number]: string | number; [""]: number; [0]: number; [`hello bye`]: number; } [s]: 0, >s : string diff --git a/tests/baselines/reference/computedPropertyNames7_ES5.types b/tests/baselines/reference/computedPropertyNames7_ES5.types index fbc070e3951..01c0117bd02 100644 --- a/tests/baselines/reference/computedPropertyNames7_ES5.types +++ b/tests/baselines/reference/computedPropertyNames7_ES5.types @@ -6,8 +6,8 @@ enum E { >member : E } var v = { ->v : { [x: number]: number; } ->{ [E.member]: 0} : { [x: number]: number; } +>v : { [E.member]: number; } +>{ [E.member]: 0} : { [E.member]: number; } [E.member]: 0 >E.member : E diff --git a/tests/baselines/reference/computedPropertyNames7_ES6.types b/tests/baselines/reference/computedPropertyNames7_ES6.types index f8f1dd7f791..80433c94ab3 100644 --- a/tests/baselines/reference/computedPropertyNames7_ES6.types +++ b/tests/baselines/reference/computedPropertyNames7_ES6.types @@ -6,8 +6,8 @@ enum E { >member : E } var v = { ->v : { [x: number]: number; } ->{ [E.member]: 0} : { [x: number]: number; } +>v : { [E.member]: number; } +>{ [E.member]: 0} : { [E.member]: number; } [E.member]: 0 >E.member : E diff --git a/tests/baselines/reference/objectLiteralEnumPropertyNames.js b/tests/baselines/reference/objectLiteralEnumPropertyNames.js new file mode 100644 index 00000000000..4a6f7128159 --- /dev/null +++ b/tests/baselines/reference/objectLiteralEnumPropertyNames.js @@ -0,0 +1,108 @@ +//// [objectLiteralEnumPropertyNames.ts] +// Fixes #16887 +enum Strs { + A = 'a', + B = 'b' +} +type TestStrs = { [key in Strs]: string } +const x: TestStrs = { + [Strs.A]: 'xo', + [Strs.B]: 'xe' +} +const ux = { + [Strs.A]: 'xo', + [Strs.B]: 'xe' +} +const y: TestStrs = { + ['a']: 'yo', + ['b']: 'ye' +} +const a = 'a'; +const b = 'b'; +const z: TestStrs = { + [a]: 'zo', + [b]: 'ze' +} +const uz = { + [a]: 'zo', + [b]: 'ze' +} + +enum Nums { + A, + B +} +type TestNums = { 0: number, 1: number } +const n: TestNums = { + [Nums.A]: 1, + [Nums.B]: 2 +} +const un = { + [Nums.A]: 3, + [Nums.B]: 4 +} +const an = 0; +const bn = 1; +const m: TestNums = { + [an]: 5, + [bn]: 6 +} +const um = { + [an]: 7, + [bn]: 8 +} + + +//// [objectLiteralEnumPropertyNames.js] +// Fixes #16887 +var Strs; +(function (Strs) { + Strs["A"] = "a"; + Strs["B"] = "b"; +})(Strs || (Strs = {})); +var x = (_a = {}, + _a[Strs.A] = 'xo', + _a[Strs.B] = 'xe', + _a); +var ux = (_b = {}, + _b[Strs.A] = 'xo', + _b[Strs.B] = 'xe', + _b); +var y = (_c = {}, + _c['a'] = 'yo', + _c['b'] = 'ye', + _c); +var a = 'a'; +var b = 'b'; +var z = (_d = {}, + _d[a] = 'zo', + _d[b] = 'ze', + _d); +var uz = (_e = {}, + _e[a] = 'zo', + _e[b] = 'ze', + _e); +var Nums; +(function (Nums) { + Nums[Nums["A"] = 0] = "A"; + Nums[Nums["B"] = 1] = "B"; +})(Nums || (Nums = {})); +var n = (_f = {}, + _f[Nums.A] = 1, + _f[Nums.B] = 2, + _f); +var un = (_g = {}, + _g[Nums.A] = 3, + _g[Nums.B] = 4, + _g); +var an = 0; +var bn = 1; +var m = (_h = {}, + _h[an] = 5, + _h[bn] = 6, + _h); +var um = (_j = {}, + _j[an] = 7, + _j[bn] = 8, + _j); +var _a, _b, _c, _d, _e, _f, _g, _h, _j; diff --git a/tests/baselines/reference/objectLiteralEnumPropertyNames.symbols b/tests/baselines/reference/objectLiteralEnumPropertyNames.symbols new file mode 100644 index 00000000000..594af3c3f99 --- /dev/null +++ b/tests/baselines/reference/objectLiteralEnumPropertyNames.symbols @@ -0,0 +1,144 @@ +=== tests/cases/compiler/objectLiteralEnumPropertyNames.ts === +// Fixes #16887 +enum Strs { +>Strs : Symbol(Strs, Decl(objectLiteralEnumPropertyNames.ts, 0, 0)) + + A = 'a', +>A : Symbol(Strs.A, Decl(objectLiteralEnumPropertyNames.ts, 1, 11)) + + B = 'b' +>B : Symbol(Strs.B, Decl(objectLiteralEnumPropertyNames.ts, 2, 12)) +} +type TestStrs = { [key in Strs]: string } +>TestStrs : Symbol(TestStrs, Decl(objectLiteralEnumPropertyNames.ts, 4, 1)) +>key : Symbol(key, Decl(objectLiteralEnumPropertyNames.ts, 5, 19)) +>Strs : Symbol(Strs, Decl(objectLiteralEnumPropertyNames.ts, 0, 0)) + +const x: TestStrs = { +>x : Symbol(x, Decl(objectLiteralEnumPropertyNames.ts, 6, 5)) +>TestStrs : Symbol(TestStrs, Decl(objectLiteralEnumPropertyNames.ts, 4, 1)) + + [Strs.A]: 'xo', +>Strs.A : Symbol(Strs.A, Decl(objectLiteralEnumPropertyNames.ts, 1, 11)) +>Strs : Symbol(Strs, Decl(objectLiteralEnumPropertyNames.ts, 0, 0)) +>A : Symbol(Strs.A, Decl(objectLiteralEnumPropertyNames.ts, 1, 11)) + + [Strs.B]: 'xe' +>Strs.B : Symbol(Strs.B, Decl(objectLiteralEnumPropertyNames.ts, 2, 12)) +>Strs : Symbol(Strs, Decl(objectLiteralEnumPropertyNames.ts, 0, 0)) +>B : Symbol(Strs.B, Decl(objectLiteralEnumPropertyNames.ts, 2, 12)) +} +const ux = { +>ux : Symbol(ux, Decl(objectLiteralEnumPropertyNames.ts, 10, 5)) + + [Strs.A]: 'xo', +>Strs.A : Symbol(Strs.A, Decl(objectLiteralEnumPropertyNames.ts, 1, 11)) +>Strs : Symbol(Strs, Decl(objectLiteralEnumPropertyNames.ts, 0, 0)) +>A : Symbol(Strs.A, Decl(objectLiteralEnumPropertyNames.ts, 1, 11)) + + [Strs.B]: 'xe' +>Strs.B : Symbol(Strs.B, Decl(objectLiteralEnumPropertyNames.ts, 2, 12)) +>Strs : Symbol(Strs, Decl(objectLiteralEnumPropertyNames.ts, 0, 0)) +>B : Symbol(Strs.B, Decl(objectLiteralEnumPropertyNames.ts, 2, 12)) +} +const y: TestStrs = { +>y : Symbol(y, Decl(objectLiteralEnumPropertyNames.ts, 14, 5)) +>TestStrs : Symbol(TestStrs, Decl(objectLiteralEnumPropertyNames.ts, 4, 1)) + + ['a']: 'yo', +>'a' : Symbol(['a'], Decl(objectLiteralEnumPropertyNames.ts, 14, 21)) + + ['b']: 'ye' +>'b' : Symbol(['b'], Decl(objectLiteralEnumPropertyNames.ts, 15, 16)) +} +const a = 'a'; +>a : Symbol(a, Decl(objectLiteralEnumPropertyNames.ts, 18, 5)) + +const b = 'b'; +>b : Symbol(b, Decl(objectLiteralEnumPropertyNames.ts, 19, 5)) + +const z: TestStrs = { +>z : Symbol(z, Decl(objectLiteralEnumPropertyNames.ts, 20, 5)) +>TestStrs : Symbol(TestStrs, Decl(objectLiteralEnumPropertyNames.ts, 4, 1)) + + [a]: 'zo', +>a : Symbol(a, Decl(objectLiteralEnumPropertyNames.ts, 18, 5)) + + [b]: 'ze' +>b : Symbol(b, Decl(objectLiteralEnumPropertyNames.ts, 19, 5)) +} +const uz = { +>uz : Symbol(uz, Decl(objectLiteralEnumPropertyNames.ts, 24, 5)) + + [a]: 'zo', +>a : Symbol(a, Decl(objectLiteralEnumPropertyNames.ts, 18, 5)) + + [b]: 'ze' +>b : Symbol(b, Decl(objectLiteralEnumPropertyNames.ts, 19, 5)) +} + +enum Nums { +>Nums : Symbol(Nums, Decl(objectLiteralEnumPropertyNames.ts, 27, 1)) + + A, +>A : Symbol(Nums.A, Decl(objectLiteralEnumPropertyNames.ts, 29, 11)) + + B +>B : Symbol(Nums.B, Decl(objectLiteralEnumPropertyNames.ts, 30, 6)) +} +type TestNums = { 0: number, 1: number } +>TestNums : Symbol(TestNums, Decl(objectLiteralEnumPropertyNames.ts, 32, 1)) + +const n: TestNums = { +>n : Symbol(n, Decl(objectLiteralEnumPropertyNames.ts, 34, 5)) +>TestNums : Symbol(TestNums, Decl(objectLiteralEnumPropertyNames.ts, 32, 1)) + + [Nums.A]: 1, +>Nums.A : Symbol(Nums.A, Decl(objectLiteralEnumPropertyNames.ts, 29, 11)) +>Nums : Symbol(Nums, Decl(objectLiteralEnumPropertyNames.ts, 27, 1)) +>A : Symbol(Nums.A, Decl(objectLiteralEnumPropertyNames.ts, 29, 11)) + + [Nums.B]: 2 +>Nums.B : Symbol(Nums.B, Decl(objectLiteralEnumPropertyNames.ts, 30, 6)) +>Nums : Symbol(Nums, Decl(objectLiteralEnumPropertyNames.ts, 27, 1)) +>B : Symbol(Nums.B, Decl(objectLiteralEnumPropertyNames.ts, 30, 6)) +} +const un = { +>un : Symbol(un, Decl(objectLiteralEnumPropertyNames.ts, 38, 5)) + + [Nums.A]: 3, +>Nums.A : Symbol(Nums.A, Decl(objectLiteralEnumPropertyNames.ts, 29, 11)) +>Nums : Symbol(Nums, Decl(objectLiteralEnumPropertyNames.ts, 27, 1)) +>A : Symbol(Nums.A, Decl(objectLiteralEnumPropertyNames.ts, 29, 11)) + + [Nums.B]: 4 +>Nums.B : Symbol(Nums.B, Decl(objectLiteralEnumPropertyNames.ts, 30, 6)) +>Nums : Symbol(Nums, Decl(objectLiteralEnumPropertyNames.ts, 27, 1)) +>B : Symbol(Nums.B, Decl(objectLiteralEnumPropertyNames.ts, 30, 6)) +} +const an = 0; +>an : Symbol(an, Decl(objectLiteralEnumPropertyNames.ts, 42, 5)) + +const bn = 1; +>bn : Symbol(bn, Decl(objectLiteralEnumPropertyNames.ts, 43, 5)) + +const m: TestNums = { +>m : Symbol(m, Decl(objectLiteralEnumPropertyNames.ts, 44, 5)) +>TestNums : Symbol(TestNums, Decl(objectLiteralEnumPropertyNames.ts, 32, 1)) + + [an]: 5, +>an : Symbol(an, Decl(objectLiteralEnumPropertyNames.ts, 42, 5)) + + [bn]: 6 +>bn : Symbol(bn, Decl(objectLiteralEnumPropertyNames.ts, 43, 5)) +} +const um = { +>um : Symbol(um, Decl(objectLiteralEnumPropertyNames.ts, 48, 5)) + + [an]: 7, +>an : Symbol(an, Decl(objectLiteralEnumPropertyNames.ts, 42, 5)) + + [bn]: 8 +>bn : Symbol(bn, Decl(objectLiteralEnumPropertyNames.ts, 43, 5)) +} + diff --git a/tests/baselines/reference/objectLiteralEnumPropertyNames.types b/tests/baselines/reference/objectLiteralEnumPropertyNames.types new file mode 100644 index 00000000000..460d96bc56d --- /dev/null +++ b/tests/baselines/reference/objectLiteralEnumPropertyNames.types @@ -0,0 +1,177 @@ +=== tests/cases/compiler/objectLiteralEnumPropertyNames.ts === +// Fixes #16887 +enum Strs { +>Strs : Strs + + A = 'a', +>A : Strs.A +>'a' : "a" + + B = 'b' +>B : Strs.B +>'b' : "b" +} +type TestStrs = { [key in Strs]: string } +>TestStrs : TestStrs +>key : key +>Strs : Strs + +const x: TestStrs = { +>x : TestStrs +>TestStrs : TestStrs +>{ [Strs.A]: 'xo', [Strs.B]: 'xe'} : { [Strs.A]: string; [Strs.B]: string; } + + [Strs.A]: 'xo', +>Strs.A : Strs.A +>Strs : typeof Strs +>A : Strs.A +>'xo' : "xo" + + [Strs.B]: 'xe' +>Strs.B : Strs.B +>Strs : typeof Strs +>B : Strs.B +>'xe' : "xe" +} +const ux = { +>ux : { [Strs.A]: string; [Strs.B]: string; } +>{ [Strs.A]: 'xo', [Strs.B]: 'xe'} : { [Strs.A]: string; [Strs.B]: string; } + + [Strs.A]: 'xo', +>Strs.A : Strs.A +>Strs : typeof Strs +>A : Strs.A +>'xo' : "xo" + + [Strs.B]: 'xe' +>Strs.B : Strs.B +>Strs : typeof Strs +>B : Strs.B +>'xe' : "xe" +} +const y: TestStrs = { +>y : TestStrs +>TestStrs : TestStrs +>{ ['a']: 'yo', ['b']: 'ye'} : { ['a']: string; ['b']: string; } + + ['a']: 'yo', +>'a' : "a" +>'yo' : "yo" + + ['b']: 'ye' +>'b' : "b" +>'ye' : "ye" +} +const a = 'a'; +>a : "a" +>'a' : "a" + +const b = 'b'; +>b : "b" +>'b' : "b" + +const z: TestStrs = { +>z : TestStrs +>TestStrs : TestStrs +>{ [a]: 'zo', [b]: 'ze'} : { [a]: string; [b]: string; } + + [a]: 'zo', +>a : "a" +>'zo' : "zo" + + [b]: 'ze' +>b : "b" +>'ze' : "ze" +} +const uz = { +>uz : { [a]: string; [b]: string; } +>{ [a]: 'zo', [b]: 'ze'} : { [a]: string; [b]: string; } + + [a]: 'zo', +>a : "a" +>'zo' : "zo" + + [b]: 'ze' +>b : "b" +>'ze' : "ze" +} + +enum Nums { +>Nums : Nums + + A, +>A : Nums.A + + B +>B : Nums.B +} +type TestNums = { 0: number, 1: number } +>TestNums : TestNums + +const n: TestNums = { +>n : TestNums +>TestNums : TestNums +>{ [Nums.A]: 1, [Nums.B]: 2} : { [Nums.A]: number; [Nums.B]: number; } + + [Nums.A]: 1, +>Nums.A : Nums.A +>Nums : typeof Nums +>A : Nums.A +>1 : 1 + + [Nums.B]: 2 +>Nums.B : Nums.B +>Nums : typeof Nums +>B : Nums.B +>2 : 2 +} +const un = { +>un : { [Nums.A]: number; [Nums.B]: number; } +>{ [Nums.A]: 3, [Nums.B]: 4} : { [Nums.A]: number; [Nums.B]: number; } + + [Nums.A]: 3, +>Nums.A : Nums.A +>Nums : typeof Nums +>A : Nums.A +>3 : 3 + + [Nums.B]: 4 +>Nums.B : Nums.B +>Nums : typeof Nums +>B : Nums.B +>4 : 4 +} +const an = 0; +>an : 0 +>0 : 0 + +const bn = 1; +>bn : 1 +>1 : 1 + +const m: TestNums = { +>m : TestNums +>TestNums : TestNums +>{ [an]: 5, [bn]: 6} : { [an]: number; [bn]: number; } + + [an]: 5, +>an : 0 +>5 : 5 + + [bn]: 6 +>bn : 1 +>6 : 6 +} +const um = { +>um : { [an]: number; [bn]: number; } +>{ [an]: 7, [bn]: 8} : { [an]: number; [bn]: number; } + + [an]: 7, +>an : 0 +>7 : 7 + + [bn]: 8 +>bn : 1 +>8 : 8 +} + diff --git a/tests/cases/compiler/objectLiteralEnumPropertyNames.ts b/tests/cases/compiler/objectLiteralEnumPropertyNames.ts new file mode 100644 index 00000000000..0f698d9c51d --- /dev/null +++ b/tests/cases/compiler/objectLiteralEnumPropertyNames.ts @@ -0,0 +1,52 @@ +// Fixes #16887 +enum Strs { + A = 'a', + B = 'b' +} +type TestStrs = { [key in Strs]: string } +const x: TestStrs = { + [Strs.A]: 'xo', + [Strs.B]: 'xe' +} +const ux = { + [Strs.A]: 'xo', + [Strs.B]: 'xe' +} +const y: TestStrs = { + ['a']: 'yo', + ['b']: 'ye' +} +const a = 'a'; +const b = 'b'; +const z: TestStrs = { + [a]: 'zo', + [b]: 'ze' +} +const uz = { + [a]: 'zo', + [b]: 'ze' +} + +enum Nums { + A, + B +} +type TestNums = { 0: number, 1: number } +const n: TestNums = { + [Nums.A]: 1, + [Nums.B]: 2 +} +const un = { + [Nums.A]: 3, + [Nums.B]: 4 +} +const an = 0; +const bn = 1; +const m: TestNums = { + [an]: 5, + [bn]: 6 +} +const um = { + [an]: 7, + [bn]: 8 +} From 727facb55c9dc2f5e924d1303d82fb3e63264dd3 Mon Sep 17 00:00:00 2001 From: Stas Vilchik Date: Thu, 7 Sep 2017 21:15:28 +0200 Subject: [PATCH 259/370] fix initialization of shouldCreateNewSourceFiles (#17686) --- src/services/services.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/services/services.ts b/src/services/services.ts index 1feafdd55f5..197f76b607f 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -1143,7 +1143,7 @@ namespace ts { oldSettings.noResolve !== newSettings.noResolve || oldSettings.jsx !== newSettings.jsx || oldSettings.allowJs !== newSettings.allowJs || - oldSettings.disableSizeLimit !== oldSettings.disableSizeLimit || + oldSettings.disableSizeLimit !== newSettings.disableSizeLimit || oldSettings.baseUrl !== newSettings.baseUrl || !equalOwnProperties(oldSettings.paths, newSettings.paths)); From de940af23bdf88893cad7eb3e163335d03ae44d9 Mon Sep 17 00:00:00 2001 From: Zeeshan Ahmed Date: Thu, 7 Sep 2017 12:20:56 -0700 Subject: [PATCH 260/370] Update README.md (#17714) --- README.md | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 23829a74d39..4cd1efe2fb0 100644 --- a/README.md +++ b/README.md @@ -12,13 +12,13 @@ For the latest stable version: -``` +```bash npm install -g typescript ``` For our nightly builds: -``` +```bash npm install -g typescript@next ``` @@ -50,26 +50,26 @@ In order to build the TypeScript compiler, ensure that you have [Git](https://gi Clone a copy of the repo: -``` +```bash git clone https://github.com/Microsoft/TypeScript.git ``` Change to the TypeScript directory: -``` +```bash cd TypeScript ``` Install Gulp tools and dev dependencies: -``` +```bash npm install -g gulp npm install ``` Use one of the following to build and test: -``` +```bash gulp local # Build the compiler into built/local gulp clean # Delete the built compiler gulp LKG # Replace the last known good with the built one. @@ -88,7 +88,7 @@ gulp help # List the above commands. ## Usage -```shell +```bash node built/local/tsc.js hello.ts ``` From b29e0c9e3ab247199eed6b69674a2c992c3a05a6 Mon Sep 17 00:00:00 2001 From: Mohamed Hegazy Date: Thu, 7 Sep 2017 12:21:33 -0700 Subject: [PATCH 261/370] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 4cd1efe2fb0..fd9926d2dfa 100644 --- a/README.md +++ b/README.md @@ -69,7 +69,7 @@ npm install Use one of the following to build and test: -```bash +``` gulp local # Build the compiler into built/local gulp clean # Delete the built compiler gulp LKG # Replace the last known good with the built one. From 6695255d8610a475260cded3535b00fddc2f32eb Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Thu, 7 Sep 2017 12:26:23 -0700 Subject: [PATCH 262/370] Allow trailing newline to have fake position (#18298) * Actually support baselining pretty in the harness * Test case from 18216 * Use host newline in formatDiagnosticsWithColorAndContext * Merge statements --- src/compiler/program.ts | 16 ++++++++-------- src/compiler/scanner.ts | 2 +- src/harness/compilerRunner.ts | 2 +- src/harness/harness.ts | 13 +++++++------ .../prettyContextNotDebugAssertion.errors.txt | 12 ++++++++++++ .../reference/prettyContextNotDebugAssertion.js | 7 +++++++ .../compiler/prettyContextNotDebugAssertion.ts | 3 +++ 7 files changed, 39 insertions(+), 16 deletions(-) create mode 100644 tests/baselines/reference/prettyContextNotDebugAssertion.errors.txt create mode 100644 tests/baselines/reference/prettyContextNotDebugAssertion.js create mode 100644 tests/cases/compiler/prettyContextNotDebugAssertion.ts diff --git a/src/compiler/program.ts b/src/compiler/program.ts index ec220ad248e..7932c6874d9 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -268,7 +268,7 @@ namespace ts { return s; } - export function formatDiagnosticsWithColorAndContext(diagnostics: Diagnostic[], host: FormatDiagnosticsHost): string { + export function formatDiagnosticsWithColorAndContext(diagnostics: ReadonlyArray, host: FormatDiagnosticsHost): string { let output = ""; for (const diagnostic of diagnostics) { if (diagnostic.file) { @@ -284,12 +284,12 @@ namespace ts { gutterWidth = Math.max(ellipsis.length, gutterWidth); } - output += sys.newLine; + output += host.getNewLine(); for (let i = firstLine; i <= lastLine; i++) { // If the error spans over 5 lines, we'll only show the first 2 and last 2 lines, // so we'll skip ahead to the second-to-last line. if (hasMoreThanFiveLines && firstLine + 1 < i && i < lastLine - 1) { - output += formatAndReset(padLeft(ellipsis, gutterWidth), gutterStyleSequence) + gutterSeparator + sys.newLine; + output += formatAndReset(padLeft(ellipsis, gutterWidth), gutterStyleSequence) + gutterSeparator + host.getNewLine(); i = lastLine - 1; } @@ -301,7 +301,7 @@ namespace ts { // Output the gutter and the actual contents of the line. output += formatAndReset(padLeft(i + 1 + "", gutterWidth), gutterStyleSequence) + gutterSeparator; - output += lineContent + sys.newLine; + output += lineContent + host.getNewLine(); // Output the gutter and the error span for the line using tildes. output += formatAndReset(padLeft("", gutterWidth), gutterStyleSequence) + gutterSeparator; @@ -323,17 +323,17 @@ namespace ts { } output += resetEscapeSequence; - output += sys.newLine; + output += host.getNewLine(); } - output += sys.newLine; + output += host.getNewLine(); output += `${ relativeFileName }(${ firstLine + 1 },${ firstLineChar + 1 }): `; } const categoryColor = getCategoryFormat(diagnostic.category); const category = DiagnosticCategory[diagnostic.category].toLowerCase(); - output += `${ formatAndReset(category, categoryColor) } TS${ diagnostic.code }: ${ flattenDiagnosticMessageText(diagnostic.messageText, sys.newLine) }`; - output += sys.newLine; + output += `${ formatAndReset(category, categoryColor) } TS${ diagnostic.code }: ${ flattenDiagnosticMessageText(diagnostic.messageText, host.getNewLine()) }`; + output += host.getNewLine(); } return output; } diff --git a/src/compiler/scanner.ts b/src/compiler/scanner.ts index a130d8427da..c9c14198279 100644 --- a/src/compiler/scanner.ts +++ b/src/compiler/scanner.ts @@ -337,7 +337,7 @@ namespace ts { Debug.assert(res < lineStarts[line + 1]); } else if (debugText !== undefined) { - Debug.assert(res < debugText.length); + Debug.assert(res <= debugText.length); // Allow single character overflow for trailing newline } return res; } diff --git a/src/harness/compilerRunner.ts b/src/harness/compilerRunner.ts index 170a23e34f2..a600c7dd857 100644 --- a/src/harness/compilerRunner.ts +++ b/src/harness/compilerRunner.ts @@ -141,7 +141,7 @@ class CompilerBaselineRunner extends RunnerBase { // check errors it("Correct errors for " + fileName, () => { - Harness.Compiler.doErrorBaseline(justName, tsConfigFiles.concat(toBeCompiled, otherFiles), result.errors); + Harness.Compiler.doErrorBaseline(justName, tsConfigFiles.concat(toBeCompiled, otherFiles), result.errors, !!options.pretty); }); it (`Correct module resolution tracing for ${fileName}`, () => { diff --git a/src/harness/harness.ts b/src/harness/harness.ts index 9443844cf9a..2fc1aac2d83 100644 --- a/src/harness/harness.ts +++ b/src/harness/harness.ts @@ -1284,11 +1284,12 @@ namespace Harness { return normalized; } - export function minimalDiagnosticsToString(diagnostics: ReadonlyArray) { - return ts.formatDiagnostics(diagnostics, { getCanonicalFileName, getCurrentDirectory: () => "", getNewLine: () => Harness.IO.newLine() }); + export function minimalDiagnosticsToString(diagnostics: ReadonlyArray, pretty?: boolean) { + const host = { getCanonicalFileName, getCurrentDirectory: () => "", getNewLine: () => Harness.IO.newLine() }; + return (pretty ? ts.formatDiagnosticsWithColorAndContext : ts.formatDiagnostics)(diagnostics, host); } - export function getErrorBaseline(inputFiles: ReadonlyArray, diagnostics: ReadonlyArray) { + export function getErrorBaseline(inputFiles: ReadonlyArray, diagnostics: ReadonlyArray, pretty?: boolean) { diagnostics = diagnostics.slice().sort(ts.compareDiagnostics); let outputLines = ""; // Count up all errors that were found in files other than lib.d.ts so we don't miss any @@ -1408,18 +1409,18 @@ namespace Harness { // Verify we didn't miss any errors in total assert.equal(totalErrorsReportedInNonLibraryFiles + numLibraryDiagnostics + numTest262HarnessDiagnostics, diagnostics.length, "total number of errors"); - return minimalDiagnosticsToString(diagnostics) + + return minimalDiagnosticsToString(diagnostics, pretty) + Harness.IO.newLine() + Harness.IO.newLine() + outputLines; } - export function doErrorBaseline(baselinePath: string, inputFiles: TestFile[], errors: ts.Diagnostic[]) { + export function doErrorBaseline(baselinePath: string, inputFiles: TestFile[], errors: ts.Diagnostic[], pretty?: boolean) { Harness.Baseline.runBaseline(baselinePath.replace(/\.tsx?$/, ".errors.txt"), (): string => { if (!errors || (errors.length === 0)) { /* tslint:disable:no-null-keyword */ return null; /* tslint:enable:no-null-keyword */ } - return getErrorBaseline(inputFiles, errors); + return getErrorBaseline(inputFiles, errors, pretty); }); } diff --git a/tests/baselines/reference/prettyContextNotDebugAssertion.errors.txt b/tests/baselines/reference/prettyContextNotDebugAssertion.errors.txt new file mode 100644 index 00000000000..7b7e3fea3e3 --- /dev/null +++ b/tests/baselines/reference/prettyContextNotDebugAssertion.errors.txt @@ -0,0 +1,12 @@ + +2 +   + +tests/cases/compiler/index.ts(2,1): error TS1005: '}' expected. + + +==== tests/cases/compiler/index.ts (1 errors) ==== + if (true) { + + +!!! error TS1005: '}' expected. \ No newline at end of file diff --git a/tests/baselines/reference/prettyContextNotDebugAssertion.js b/tests/baselines/reference/prettyContextNotDebugAssertion.js new file mode 100644 index 00000000000..1051f76864c --- /dev/null +++ b/tests/baselines/reference/prettyContextNotDebugAssertion.js @@ -0,0 +1,7 @@ +//// [index.ts] +if (true) { + + +//// [index.js] +if (true) { +} diff --git a/tests/cases/compiler/prettyContextNotDebugAssertion.ts b/tests/cases/compiler/prettyContextNotDebugAssertion.ts new file mode 100644 index 00000000000..d65b02d472f --- /dev/null +++ b/tests/cases/compiler/prettyContextNotDebugAssertion.ts @@ -0,0 +1,3 @@ +// @pretty: true +// @filename: index.ts +if (true) { From 508cde0ea12a86668d8c893a0356cf2c7320619a Mon Sep 17 00:00:00 2001 From: Andy Date: Thu, 7 Sep 2017 12:39:13 -0700 Subject: [PATCH 263/370] Document assignment to aliasSymbol in getUnionTypeFromSortedList (#17434) * Document assignment to aliasSymbol in getUnionTypeFromSortedList * Update wording --- src/compiler/checker.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 91653c140c8..8547fc7e176 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -7435,6 +7435,12 @@ namespace ts { type = createType(TypeFlags.Union | propagatedFlags); unionTypes.set(id, type); type.types = types; + /* + Note: This is the alias symbol (or lack thereof) that we see when we first encounter this union type. + For aliases of identical unions, eg `type T = A | B; type U = A | B`, the symbol of the first alias encountered is the aliasSymbol. + (In the language service, the order may depend on the order in which a user takes actions, such as hovering over symbols.) + It's important that we create equivalent union types only once, so that's an unfortunate side effect. + */ type.aliasSymbol = aliasSymbol; type.aliasTypeArguments = aliasTypeArguments; } @@ -7528,7 +7534,7 @@ namespace ts { type = createType(TypeFlags.Intersection | propagatedFlags); intersectionTypes.set(id, type); type.types = typeSet; - type.aliasSymbol = aliasSymbol; + type.aliasSymbol = aliasSymbol; // See comment in `getUnionTypeFromSortedList`. type.aliasTypeArguments = aliasTypeArguments; } return type; From 1b5a0aed93f617d63627cb6d7c5c104d4f4dfdc9 Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Thu, 7 Sep 2017 12:47:09 -0700 Subject: [PATCH 264/370] Update pretty baseline changed by #17675 (#18320) --- .../reference/prettyContextNotDebugAssertion.errors.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/baselines/reference/prettyContextNotDebugAssertion.errors.txt b/tests/baselines/reference/prettyContextNotDebugAssertion.errors.txt index 7b7e3fea3e3..9cac1423f3f 100644 --- a/tests/baselines/reference/prettyContextNotDebugAssertion.errors.txt +++ b/tests/baselines/reference/prettyContextNotDebugAssertion.errors.txt @@ -1,6 +1,6 @@ -2 -   +2 +   tests/cases/compiler/index.ts(2,1): error TS1005: '}' expected. From ed4e2e6e3b66e43ce3e4807be342f3b235e0bb73 Mon Sep 17 00:00:00 2001 From: Andy Date: Thu, 7 Sep 2017 14:30:19 -0700 Subject: [PATCH 265/370] Ensure that emitter calls callbacks (#18284) * Ensure that emitter calls calbacks * Move new parameter to end of parameters * Fix for ConditionalExpression * Make suggested changes to emitter * Fix parameter ordering * Respond to minor comments * Remove potentially expensive assertion * More emitter cleanup --- src/compiler/emitter.ts | 123 ++++++++-------- src/compiler/factory.ts | 60 +++++++- src/compiler/transformers/es2017.ts | 3 +- src/compiler/transformers/esnext.ts | 3 +- src/compiler/transformers/ts.ts | 3 +- src/compiler/types.ts | 9 +- src/compiler/utilities.ts | 3 +- src/compiler/visitor.ts | 3 + src/services/formatting/formatting.ts | 1 + src/services/refactors/extractMethod.ts | 6 +- src/services/textChanges.ts | 28 ++-- .../reference/extractMethod/extractMethod4.ts | 24 ++-- .../sourceMapValidationStatements.js.map | 2 +- ...ourceMapValidationStatements.sourcemap.txt | 132 +++++++++++------- .../ternaryExpressionSourceMap.js.map | 2 +- .../ternaryExpressionSourceMap.sourcemap.txt | 90 ++++++------ ...ypeGuardsInRightOperandOfAndAndOperator.js | 2 + .../typeGuardsInRightOperandOfOrOrOperator.js | 2 + .../fourslash/extract-method-formatting.ts | 24 ++++ tests/cases/fourslash/extract-method5.ts | 2 +- 20 files changed, 325 insertions(+), 197 deletions(-) create mode 100644 tests/cases/fourslash/extract-method-formatting.ts diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index 166e4751983..5abeecd4107 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -406,6 +406,14 @@ namespace ts { setWriter(/*output*/ undefined); } + // TODO: Should this just be `emit`? + // See https://github.com/Microsoft/TypeScript/pull/18284#discussion_r137611034 + function emitIfPresent(node: Node | undefined) { + if (node) { + emit(node); + } + } + function emit(node: Node) { pipelineEmitWithNotification(EmitHint.Unspecified, node); } @@ -451,6 +459,7 @@ namespace ts { case EmitHint.SourceFile: return pipelineEmitSourceFile(node); case EmitHint.IdentifierName: return pipelineEmitIdentifierName(node); case EmitHint.Expression: return pipelineEmitExpression(node); + case EmitHint.MappedTypeParameter: return emitMappedTypeParameter(cast(node, isTypeParameterDeclaration)); case EmitHint.Unspecified: return pipelineEmitUnspecified(node); } } @@ -465,6 +474,12 @@ namespace ts { emitIdentifier(node); } + function emitMappedTypeParameter(node: TypeParameterDeclaration): void { + emit(node.name); + write(" in "); + emit(node.constraint); + } + function pipelineEmitUnspecified(node: Node): void { const kind = node.kind; @@ -898,9 +913,9 @@ namespace ts { function emitParameter(node: ParameterDeclaration) { emitDecorators(node, node.decorators); emitModifiers(node, node.modifiers); - writeIfPresent(node.dotDotDotToken, "..."); + emitIfPresent(node.dotDotDotToken); emit(node.name); - writeIfPresent(node.questionToken, "?"); + emitIfPresent(node.questionToken); emitWithPrefix(": ", node.type); emitExpressionWithPrefix(" = ", node.initializer); } @@ -918,7 +933,7 @@ namespace ts { emitDecorators(node, node.decorators); emitModifiers(node, node.modifiers); emit(node.name); - writeIfPresent(node.questionToken, "?"); + emitIfPresent(node.questionToken); emitWithPrefix(": ", node.type); write(";"); } @@ -927,7 +942,7 @@ namespace ts { emitDecorators(node, node.decorators); emitModifiers(node, node.modifiers); emit(node.name); - writeIfPresent(node.questionToken, "?"); + emitIfPresent(node.questionToken); emitWithPrefix(": ", node.type); emitExpressionWithPrefix(" = ", node.initializer); write(";"); @@ -937,7 +952,7 @@ namespace ts { emitDecorators(node, node.decorators); emitModifiers(node, node.modifiers); emit(node.name); - writeIfPresent(node.questionToken, "?"); + emitIfPresent(node.questionToken); emitTypeParameters(node, node.typeParameters); emitParameters(node, node.parameters); emitWithPrefix(": ", node.type); @@ -947,9 +962,9 @@ namespace ts { function emitMethodDeclaration(node: MethodDeclaration) { emitDecorators(node, node.decorators); emitModifiers(node, node.modifiers); - writeIfPresent(node.asteriskToken, "*"); + emitIfPresent(node.asteriskToken); emit(node.name); - writeIfPresent(node.questionToken, "?"); + emitIfPresent(node.questionToken); emitSignatureAndBody(node, emitSignatureHead); } @@ -1035,10 +1050,8 @@ namespace ts { function emitTypeLiteral(node: TypeLiteralNode) { write("{"); - // If the literal is empty, do not add spaces between braces. - if (node.members.length > 0) { - emitList(node, node.members, getEmitFlags(node) & EmitFlags.SingleLine ? ListFormat.SingleLineTypeLiteralMembers : ListFormat.MultiLineTypeLiteralMembers); - } + const flags = getEmitFlags(node) & EmitFlags.SingleLine ? ListFormat.SingleLineTypeLiteralMembers : ListFormat.MultiLineTypeLiteralMembers; + emitList(node, node.members, flags | ListFormat.NoSpaceIfEmpty); write("}"); } @@ -1094,13 +1107,16 @@ namespace ts { writeLine(); increaseIndent(); } - writeIfPresent(node.readonlyToken, "readonly "); + if (node.readonlyToken) { + emit(node.readonlyToken); + write(" "); + } + write("["); - emit(node.typeParameter.name); - write(" in "); - emit(node.typeParameter.constraint); + pipelineEmitWithNotification(EmitHint.MappedTypeParameter, node.typeParameter); write("]"); - writeIfPresent(node.questionToken, "?"); + + emitIfPresent(node.questionToken); write(": "); emit(node.type); write(";"); @@ -1148,7 +1164,7 @@ namespace ts { function emitBindingElement(node: BindingElement) { emitWithSuffix(node.propertyName, ": "); - writeIfPresent(node.dotDotDotToken, "..."); + emitIfPresent(node.dotDotDotToken); emit(node.name); emitExpressionWithPrefix(" = ", node.initializer); } @@ -1159,33 +1175,22 @@ namespace ts { function emitArrayLiteralExpression(node: ArrayLiteralExpression) { const elements = node.elements; - if (elements.length === 0) { - write("[]"); - } - else { - const preferNewLine = node.multiLine ? ListFormat.PreferNewLine : ListFormat.None; - emitExpressionList(node, elements, ListFormat.ArrayLiteralExpressionElements | preferNewLine); - } + const preferNewLine = node.multiLine ? ListFormat.PreferNewLine : ListFormat.None; + emitExpressionList(node, elements, ListFormat.ArrayLiteralExpressionElements | preferNewLine); } function emitObjectLiteralExpression(node: ObjectLiteralExpression) { - const properties = node.properties; - if (properties.length === 0) { - write("{}"); + const indentedFlag = getEmitFlags(node) & EmitFlags.Indented; + if (indentedFlag) { + increaseIndent(); } - else { - const indentedFlag = getEmitFlags(node) & EmitFlags.Indented; - if (indentedFlag) { - increaseIndent(); - } - const preferNewLine = node.multiLine ? ListFormat.PreferNewLine : ListFormat.None; - const allowTrailingComma = currentSourceFile.languageVersion >= ScriptTarget.ES5 ? ListFormat.AllowTrailingComma : ListFormat.None; - emitList(node, properties, ListFormat.ObjectLiteralExpressionProperties | allowTrailingComma | preferNewLine); + const preferNewLine = node.multiLine ? ListFormat.PreferNewLine : ListFormat.None; + const allowTrailingComma = currentSourceFile.languageVersion >= ScriptTarget.ES5 ? ListFormat.AllowTrailingComma : ListFormat.None; + emitList(node, node.properties, ListFormat.ObjectLiteralExpressionProperties | allowTrailingComma | preferNewLine); - if (indentedFlag) { - decreaseIndent(); - } + if (indentedFlag) { + decreaseIndent(); } } @@ -1286,7 +1291,8 @@ namespace ts { emitTypeParameters(node, node.typeParameters); emitParametersForArrow(node, node.parameters); emitWithPrefix(": ", node.type); - write(" =>"); + write(" "); + emit(node.equalsGreaterThanToken); } function emitDeleteExpression(node: DeleteExpression) { @@ -1364,13 +1370,13 @@ namespace ts { emitExpression(node.condition); increaseIndentIf(indentBeforeQuestion, " "); - write("?"); + emit(node.questionToken); increaseIndentIf(indentAfterQuestion, " "); emitExpression(node.whenTrue); decreaseIndentIf(indentBeforeQuestion, indentAfterQuestion); increaseIndentIf(indentBeforeColon, " "); - write(":"); + emit(node.colonToken); increaseIndentIf(indentAfterColon, " "); emitExpression(node.whenFalse); decreaseIndentIf(indentBeforeColon, indentAfterColon); @@ -1382,7 +1388,8 @@ namespace ts { } function emitYieldExpression(node: YieldExpression) { - write(node.asteriskToken ? "yield*" : "yield"); + write("yield"); + emit(node.asteriskToken); emitExpressionWithPrefix(" ", node.expression); } @@ -1662,7 +1669,9 @@ namespace ts { function emitFunctionDeclarationOrExpression(node: FunctionDeclaration | FunctionExpression) { emitDecorators(node, node.decorators); emitModifiers(node, node.modifiers); - write(node.asteriskToken ? "function* " : "function "); + write("function"); + emitIfPresent(node.asteriskToken); + write(" "); emitIdentifierName(node.name); emitSignatureAndBody(node, emitSignatureHead); } @@ -2068,9 +2077,7 @@ namespace ts { function emitJsxExpression(node: JsxExpression) { if (node.expression) { write("{"); - if (node.dotDotDotToken) { - write("..."); - } + emitIfPresent(node.dotDotDotToken); emitExpression(node.expression); write("}"); } @@ -2128,13 +2135,12 @@ namespace ts { emitTrailingCommentsOfPosition(statements.pos); } + let format = ListFormat.CaseOrDefaultClauseStatements; if (emitAsSingleStatement) { write(" "); - emit(statements[0]); - } - else { - emitList(parentNode, statements, ListFormat.CaseOrDefaultClauseStatements); + format &= ~(ListFormat.MultiLine | ListFormat.Indented); } + emitList(parentNode, statements, format); } function emitHeritageClause(node: HeritageClause) { @@ -2384,7 +2390,7 @@ namespace ts { function emitParametersForArrow(parentNode: FunctionTypeNode | ArrowFunction, parameters: NodeArray) { if (canEmitSimpleArrowHead(parentNode, parameters)) { - emit(parameters[0]); + emitList(parentNode, parameters, ListFormat.Parameters & ~ListFormat.Parenthesis); } else { emitParameters(parentNode, parameters); @@ -2427,7 +2433,7 @@ namespace ts { if (format & ListFormat.MultiLine) { writeLine(); } - else if (format & ListFormat.SpaceBetweenBraces) { + else if (format & ListFormat.SpaceBetweenBraces && !(format & ListFormat.NoSpaceIfEmpty)) { write(" "); } } @@ -2568,12 +2574,6 @@ namespace ts { } } - function writeIfPresent(node: Node, text: string) { - if (node) { - write(text); - } - } - function writeToken(token: SyntaxKind, pos: number, contextNode?: Node) { return onEmitSourceMapOfToken ? onEmitSourceMapOfToken(contextNode, token, pos, writeTokenText) @@ -2584,7 +2584,7 @@ namespace ts { if (onBeforeEmitToken) { onBeforeEmitToken(node); } - writeTokenText(node.kind); + write(tokenToString(node.kind)); if (onAfterEmitToken) { onAfterEmitToken(node); } @@ -3107,6 +3107,9 @@ namespace ts { NoTrailingNewLine = 1 << 16, // Do not emit a trailing NewLine for a MultiLine list. NoInterveningComments = 1 << 17, // Do not emit comments between each node + NoSpaceIfEmpty = 1 << 18, // If the literal is empty, do not add spaces between braces. + SingleElement = 1 << 19, + // Precomputed Formats Modifiers = SingleLine | SpaceBetweenSiblings | NoInterveningComments, HeritageClauses = SingleLine | SpaceBetweenSiblings, @@ -3118,7 +3121,7 @@ namespace ts { IntersectionTypeConstituents = AmpersandDelimited | SpaceBetweenSiblings | SingleLine, ObjectBindingPatternElements = SingleLine | AllowTrailingComma | SpaceBetweenBraces | CommaDelimited | SpaceBetweenSiblings, ArrayBindingPatternElements = SingleLine | AllowTrailingComma | CommaDelimited | SpaceBetweenSiblings, - ObjectLiteralExpressionProperties = PreserveLines | CommaDelimited | SpaceBetweenSiblings | SpaceBetweenBraces | Indented | Braces, + ObjectLiteralExpressionProperties = PreserveLines | CommaDelimited | SpaceBetweenSiblings | SpaceBetweenBraces | Indented | Braces | NoSpaceIfEmpty, ArrayLiteralExpressionElements = PreserveLines | CommaDelimited | SpaceBetweenSiblings | AllowTrailingComma | Indented | SquareBrackets, CommaListElements = CommaDelimited | SpaceBetweenSiblings | SingleLine, CallExpressionArguments = CommaDelimited | SpaceBetweenSiblings | SingleLine | Parenthesis, diff --git a/src/compiler/factory.ts b/src/compiler/factory.ts index 4492c3ed474..2bf6d6e879d 100644 --- a/src/compiler/factory.ts +++ b/src/compiler/factory.ts @@ -281,7 +281,7 @@ namespace ts { || node.questionToken !== questionToken || node.type !== type || node.initializer !== initializer - ? updateNode(createParameter(decorators, modifiers, dotDotDotToken, name, node.questionToken, type, initializer), node) + ? updateNode(createParameter(decorators, modifiers, dotDotDotToken, name, questionToken, type, initializer), node) : node; } @@ -1016,19 +1016,49 @@ namespace ts { return node; } + /* @deprecated */ export function updateArrowFunction( + node: ArrowFunction, + modifiers: ReadonlyArray | undefined, + typeParameters: ReadonlyArray | undefined, + parameters: ReadonlyArray, + type: TypeNode | undefined, + body: ConciseBody): ArrowFunction; export function updateArrowFunction( node: ArrowFunction, modifiers: ReadonlyArray | undefined, typeParameters: ReadonlyArray | undefined, parameters: ReadonlyArray, type: TypeNode | undefined, - body: ConciseBody) { + equalsGreaterThanToken: Token, + body: ConciseBody): ArrowFunction; + export function updateArrowFunction( + node: ArrowFunction, + modifiers: ReadonlyArray | undefined, + typeParameters: ReadonlyArray | undefined, + parameters: ReadonlyArray, + type: TypeNode | undefined, + equalsGreaterThanTokenOrBody: Token | ConciseBody, + bodyOrUndefined?: ConciseBody, + ): ArrowFunction { + let equalsGreaterThanToken: Token; + let body: ConciseBody; + if (bodyOrUndefined === undefined) { + equalsGreaterThanToken = node.equalsGreaterThanToken; + body = cast(equalsGreaterThanTokenOrBody, isConciseBody); + } + else { + equalsGreaterThanToken = cast(equalsGreaterThanTokenOrBody, (n): n is Token => + n.kind === SyntaxKind.EqualsGreaterThanToken); + body = bodyOrUndefined; + } + return node.modifiers !== modifiers || node.typeParameters !== typeParameters || node.parameters !== parameters || node.type !== type + || node.equalsGreaterThanToken !== equalsGreaterThanToken || node.body !== body - ? updateNode(createArrowFunction(modifiers, typeParameters, parameters, type, node.equalsGreaterThanToken, body), node) + ? updateNode(createArrowFunction(modifiers, typeParameters, parameters, type, equalsGreaterThanToken, body), node) : node; } @@ -1135,11 +1165,31 @@ namespace ts { return node; } - export function updateConditional(node: ConditionalExpression, condition: Expression, whenTrue: Expression, whenFalse: Expression) { + /* @deprecated */ export function updateConditional( + node: ConditionalExpression, + condition: Expression, + whenTrue: Expression, + whenFalse: Expression): ConditionalExpression; + export function updateConditional( + node: ConditionalExpression, + condition: Expression, + questionToken: Token, + whenTrue: Expression, + colonToken: Token, + whenFalse: Expression): ConditionalExpression; + export function updateConditional(node: ConditionalExpression, condition: Expression, ...args: any[]) { + if (args.length === 2) { + const [whenTrue, whenFalse] = args; + return updateConditional(node, condition, node.questionToken, whenTrue, node.colonToken, whenFalse); + } + Debug.assert(args.length === 4); + const [questionToken, whenTrue, colonToken, whenFalse] = args; return node.condition !== condition + || node.questionToken !== questionToken || node.whenTrue !== whenTrue + || node.colonToken !== colonToken || node.whenFalse !== whenFalse - ? updateNode(createConditional(condition, node.questionToken, whenTrue, node.colonToken, whenFalse), node) + ? updateNode(createConditional(condition, questionToken, whenTrue, colonToken, whenFalse), node) : node; } diff --git a/src/compiler/transformers/es2017.ts b/src/compiler/transformers/es2017.ts index 43058358ee5..85a44e35983 100644 --- a/src/compiler/transformers/es2017.ts +++ b/src/compiler/transformers/es2017.ts @@ -197,9 +197,10 @@ namespace ts { /*typeParameters*/ undefined, visitParameterList(node.parameters, visitor, context), /*type*/ undefined, + node.equalsGreaterThanToken, getFunctionFlags(node) & FunctionFlags.Async ? transformAsyncFunctionBody(node) - : visitFunctionBody(node.body, visitor, context) + : visitFunctionBody(node.body, visitor, context), ); } diff --git a/src/compiler/transformers/esnext.ts b/src/compiler/transformers/esnext.ts index 3bdcc9e9ee7..0fca09b4540 100644 --- a/src/compiler/transformers/esnext.ts +++ b/src/compiler/transformers/esnext.ts @@ -595,7 +595,8 @@ namespace ts { /*typeParameters*/ undefined, visitParameterList(node.parameters, visitor, context), /*type*/ undefined, - transformFunctionBody(node) + node.equalsGreaterThanToken, + transformFunctionBody(node), ); enclosingFunctionFlags = savedEnclosingFunctionFlags; return updated; diff --git a/src/compiler/transformers/ts.ts b/src/compiler/transformers/ts.ts index 42c25ca34a5..ebce55aa7e5 100644 --- a/src/compiler/transformers/ts.ts +++ b/src/compiler/transformers/ts.ts @@ -2309,7 +2309,8 @@ namespace ts { /*typeParameters*/ undefined, visitParameterList(node.parameters, visitor, context), /*type*/ undefined, - visitFunctionBody(node.body, visitor, context) + node.equalsGreaterThanToken, + visitFunctionBody(node.body, visitor, context), ); return updated; } diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 55baf9763c2..1b5a0164585 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -4299,10 +4299,11 @@ namespace ts { } export const enum EmitHint { - SourceFile, // Emitting a SourceFile - Expression, // Emitting an Expression - IdentifierName, // Emitting an IdentifierName - Unspecified, // Emitting an otherwise unspecified node + SourceFile, // Emitting a SourceFile + Expression, // Emitting an Expression + IdentifierName, // Emitting an IdentifierName + MappedTypeParameter, // Emitting a TypeParameterDeclaration inside of a MappedTypeNode + Unspecified, // Emitting an otherwise unspecified node } /* @internal */ diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index 11c30a2d8ab..160d81d04da 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -4728,8 +4728,7 @@ namespace ts { /* @internal */ export function isNodeArray(array: ReadonlyArray): array is NodeArray { - return array.hasOwnProperty("pos") - && array.hasOwnProperty("end"); + return array.hasOwnProperty("pos") && array.hasOwnProperty("end"); } // Literals diff --git a/src/compiler/visitor.ts b/src/compiler/visitor.ts index 1ce42199372..7d46630e227 100644 --- a/src/compiler/visitor.ts +++ b/src/compiler/visitor.ts @@ -488,6 +488,7 @@ namespace ts { nodesVisitor((node).typeParameters, visitor, isTypeParameterDeclaration), visitParameterList((node).parameters, visitor, context, nodesVisitor), visitNode((node).type, visitor, isTypeNode), + visitNode((node).equalsGreaterThanToken, visitor, isToken), visitFunctionBody((node).body, visitor, context)); case SyntaxKind.DeleteExpression: @@ -523,7 +524,9 @@ namespace ts { case SyntaxKind.ConditionalExpression: return updateConditional(node, visitNode((node).condition, visitor, isExpression), + visitNode((node).questionToken, visitor, isToken), visitNode((node).whenTrue, visitor, isExpression), + visitNode((node).colonToken, visitor, isToken), visitNode((node).whenFalse, visitor, isExpression)); case SyntaxKind.TemplateExpression: diff --git a/src/services/formatting/formatting.ts b/src/services/formatting/formatting.ts index 443ce13d6a4..5f26990d3a4 100644 --- a/src/services/formatting/formatting.ts +++ b/src/services/formatting/formatting.ts @@ -726,6 +726,7 @@ namespace ts.formatting { parent: Node, parentStartLine: number, parentDynamicIndentation: DynamicIndentation): void { + Debug.assert(isNodeArray(nodes)); const listStartToken = getOpenTokenForList(parent, nodes); const listEndToken = getCloseTokenForOpenToken(listStartToken); diff --git a/src/services/refactors/extractMethod.ts b/src/services/refactors/extractMethod.ts index b76ab9376dc..25a995dc231 100644 --- a/src/services/refactors/extractMethod.ts +++ b/src/services/refactors/extractMethod.ts @@ -656,11 +656,13 @@ namespace ts.refactor.extractMethod { const typeParametersAndDeclarations = arrayFrom(typeParameterUsages.values()).map(type => ({ type, declaration: getFirstDeclaration(type) })); const sortedTypeParametersAndDeclarations = typeParametersAndDeclarations.sort(compareTypesByDeclarationOrder); - const typeParameters: ReadonlyArray = sortedTypeParametersAndDeclarations.map(t => t.declaration as TypeParameterDeclaration); + const typeParameters: ReadonlyArray | undefined = sortedTypeParametersAndDeclarations.length === 0 + ? undefined + : sortedTypeParametersAndDeclarations.map(t => t.declaration as TypeParameterDeclaration); // Strictly speaking, we should check whether each name actually binds to the appropriate type // parameter. In cases of shadowing, they may not. - const callTypeArguments: ReadonlyArray | undefined = typeParameters.length > 0 + const callTypeArguments: ReadonlyArray | undefined = typeParameters !== undefined ? typeParameters.map(decl => createTypeReferenceNode(decl.name, /*typeArguments*/ undefined)) : undefined; diff --git a/src/services/textChanges.ts b/src/services/textChanges.ts index 7909d2d3adb..42c1d1e9a4f 100644 --- a/src/services/textChanges.ts +++ b/src/services/textChanges.ts @@ -5,19 +5,25 @@ namespace ts.textChanges { * Currently for simplicity we store recovered positions on the node itself. * It can be changed to side-table later if we decide that current design is too invasive. */ - function getPos(n: TextRange) { - return (n)["__pos"]; + function getPos(n: TextRange): number { + const result = (n)["__pos"]; + Debug.assert(typeof result === "number"); + return result; } - function setPos(n: TextRange, pos: number) { + function setPos(n: TextRange, pos: number): void { + Debug.assert(typeof pos === "number"); (n)["__pos"] = pos; } - function getEnd(n: TextRange) { - return (n)["__end"]; + function getEnd(n: TextRange): number { + const result = (n)["__end"]; + Debug.assert(typeof result === "number"); + return result; } - function setEnd(n: TextRange, end: number) { + function setEnd(n: TextRange, end: number): void { + Debug.assert(typeof end === "number"); (n)["__end"] = end; } @@ -582,7 +588,7 @@ namespace ts.textChanges { readonly node: Node; } - export function getNonformattedText(node: Node, sourceFile: SourceFile | undefined, newLine: NewLineKind): NonFormattedText { + function getNonformattedText(node: Node, sourceFile: SourceFile | undefined, newLine: NewLineKind): NonFormattedText { const options = { newLine, target: sourceFile && sourceFile.languageVersion }; const writer = new Writer(getNewLineCharacter(options)); const printer = createPrinter(options, writer); @@ -590,7 +596,7 @@ namespace ts.textChanges { return { text: writer.getText(), node: assignPositionsToNode(node) }; } - export function applyFormatting(nonFormattedText: NonFormattedText, sourceFile: SourceFile, initialIndentation: number, delta: number, rulesProvider: formatting.RulesProvider) { + function applyFormatting(nonFormattedText: NonFormattedText, sourceFile: SourceFile, initialIndentation: number, delta: number, rulesProvider: formatting.RulesProvider) { const lineMap = computeLineStarts(nonFormattedText.text); const file: SourceFileLike = { text: nonFormattedText.text, @@ -616,14 +622,10 @@ namespace ts.textChanges { function assignPositionsToNode(node: Node): Node { const visited = visitEachChild(node, assignPositionsToNode, nullTransformationContext, assignPositionsToNodeArray, assignPositionsToNode); // create proxy node for non synthesized nodes - const newNode = nodeIsSynthesized(visited) - ? visited - : (Proxy.prototype = visited, new (Proxy)()); + const newNode = nodeIsSynthesized(visited) ? visited : Object.create(visited) as Node; newNode.pos = getPos(node); newNode.end = getEnd(node); return newNode; - - function Proxy() { } } function assignPositionsToNodeArray(nodes: NodeArray, visitor: Visitor, test?: (node: Node) => boolean, start?: number, count?: number) { diff --git a/tests/baselines/reference/extractMethod/extractMethod4.ts b/tests/baselines/reference/extractMethod/extractMethod4.ts index 107f99e669b..4e9811501f4 100644 --- a/tests/baselines/reference/extractMethod/extractMethod4.ts +++ b/tests/baselines/reference/extractMethod/extractMethod4.ts @@ -24,9 +24,9 @@ namespace A { async function newFunction() { let y = 5; - if(z) { - await z1; - } + if (z) { + await z1; + } return foo(); } } @@ -44,9 +44,9 @@ namespace A { async function newFunction(z: number, z1: any) { let y = 5; - if(z) { - await z1; - } + if (z) { + await z1; + } return foo(); } } @@ -64,9 +64,9 @@ namespace A { async function newFunction(z: number, z1: any) { let y = 5; - if(z) { - await z1; - } + if (z) { + await z1; + } return foo(); } } @@ -83,8 +83,8 @@ namespace A { } async function newFunction(z: number, z1: any, foo: () => void) { let y = 5; - if(z) { - await z1; -} + if (z) { + await z1; + } return foo(); } diff --git a/tests/baselines/reference/sourceMapValidationStatements.js.map b/tests/baselines/reference/sourceMapValidationStatements.js.map index 5841f329e5e..40d65e0106c 100644 --- a/tests/baselines/reference/sourceMapValidationStatements.js.map +++ b/tests/baselines/reference/sourceMapValidationStatements.js.map @@ -1,2 +1,2 @@ //// [sourceMapValidationStatements.js.map] -{"version":3,"file":"sourceMapValidationStatements.js","sourceRoot":"","sources":["sourceMapValidationStatements.ts"],"names":[],"mappings":"AAAA;IACI,IAAI,CAAC,CAAC;IACN,IAAI,CAAC,GAAG,CAAC,CAAC;IACV,GAAG,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,EAAE,EAAE,CAAC;QAC1B,CAAC,IAAI,CAAC,CAAC;QACP,CAAC,IAAI,CAAC,CAAC;IACX,CAAC;IACD,EAAE,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC;QACT,CAAC,IAAI,CAAC,CAAC;IACX,CAAC;IAAC,IAAI,CAAC,CAAC;QACJ,CAAC,IAAI,EAAE,CAAC;QACR,CAAC,EAAE,CAAC;IACR,CAAC;IACD,IAAI,CAAC,GAAG;QACJ,CAAC;QACD,CAAC;QACD,CAAC;KACJ,CAAC;IACF,IAAI,GAAG,GAAG;QACN,CAAC,EAAE,CAAC;QACJ,CAAC,EAAE,OAAO;KACb,CAAC;IACF,GAAG,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QACd,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;QACb,IAAI,CAAC,GAAG,EAAE,CAAC;IACf,CAAC;IACD,IAAI,CAAC;QACD,GAAG,CAAC,CAAC,GAAG,MAAM,CAAC;IACnB,CAAC;IAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QACT,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC;YACb,GAAG,CAAC,CAAC,GAAG,EAAE,CAAC;QACf,CAAC;QAAC,IAAI,CAAC,CAAC;YACJ,GAAG,CAAC,CAAC,GAAG,KAAK,CAAC;QAClB,CAAC;IACL,CAAC;IACD,IAAI,CAAC;QACD,MAAM,IAAI,KAAK,EAAE,CAAC;IACtB,CAAC;IAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;QACV,IAAI,CAAC,GAAG,EAAE,CAAC;IACf,CAAC;YAAS,CAAC;QACP,CAAC,GAAG,EAAE,CAAC;IACX,CAAC;IACD,MAAM,GAAG,EAAE,CAAC;QACR,CAAC,GAAG,CAAC,CAAC;QACN,CAAC,GAAG,EAAE,CAAC;IACX,CAAC;IACD,MAAM,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;QACZ,KAAK,CAAC,EAAE,CAAC;YACL,CAAC,EAAE,CAAC;YACJ,KAAK,CAAC;QAEV,CAAC;QACD,KAAK,CAAC,EAAE,CAAC;YACL,CAAC,EAAE,CAAC;YACJ,KAAK,CAAC;QAEV,CAAC;QACD,SAAS,CAAC;YACN,CAAC,IAAI,CAAC,CAAC;YACP,CAAC,GAAG,EAAE,CAAC;YACP,KAAK,CAAC;QAEV,CAAC;IACL,CAAC;IACD,OAAO,CAAC,GAAG,EAAE,EAAE,CAAC;QACZ,CAAC,EAAE,CAAC;IACR,CAAC;IACD,GAAG,CAAC;QACA,CAAC,EAAE,CAAC;IACR,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAC;IACf,CAAC,GAAG,CAAC,CAAC;IACN,IAAI,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IACjC,CAAC,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IACzB,CAAC,KAAK,CAAC,CAAC;IACR,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC;IACX,IAAI,CAAC,GAAG,CAAC,CAAC;IACV,MAAM,CAAC;AACX,CAAC;AACD,IAAI,CAAC,GAAG;IACJ,IAAI,CAAC,GAAG,EAAE,CAAC;IACX,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;AACd,CAAC,CAAC;AACF,CAAC,EAAE,CAAC"} \ No newline at end of file +{"version":3,"file":"sourceMapValidationStatements.js","sourceRoot":"","sources":["sourceMapValidationStatements.ts"],"names":[],"mappings":"AAAA;IACI,IAAI,CAAC,CAAC;IACN,IAAI,CAAC,GAAG,CAAC,CAAC;IACV,GAAG,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,EAAE,EAAE,CAAC;QAC1B,CAAC,IAAI,CAAC,CAAC;QACP,CAAC,IAAI,CAAC,CAAC;IACX,CAAC;IACD,EAAE,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC;QACT,CAAC,IAAI,CAAC,CAAC;IACX,CAAC;IAAC,IAAI,CAAC,CAAC;QACJ,CAAC,IAAI,EAAE,CAAC;QACR,CAAC,EAAE,CAAC;IACR,CAAC;IACD,IAAI,CAAC,GAAG;QACJ,CAAC;QACD,CAAC;QACD,CAAC;KACJ,CAAC;IACF,IAAI,GAAG,GAAG;QACN,CAAC,EAAE,CAAC;QACJ,CAAC,EAAE,OAAO;KACb,CAAC;IACF,GAAG,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QACd,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;QACb,IAAI,CAAC,GAAG,EAAE,CAAC;IACf,CAAC;IACD,IAAI,CAAC;QACD,GAAG,CAAC,CAAC,GAAG,MAAM,CAAC;IACnB,CAAC;IAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QACT,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC;YACb,GAAG,CAAC,CAAC,GAAG,EAAE,CAAC;QACf,CAAC;QAAC,IAAI,CAAC,CAAC;YACJ,GAAG,CAAC,CAAC,GAAG,KAAK,CAAC;QAClB,CAAC;IACL,CAAC;IACD,IAAI,CAAC;QACD,MAAM,IAAI,KAAK,EAAE,CAAC;IACtB,CAAC;IAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;QACV,IAAI,CAAC,GAAG,EAAE,CAAC;IACf,CAAC;YAAS,CAAC;QACP,CAAC,GAAG,EAAE,CAAC;IACX,CAAC;IACD,MAAM,GAAG,EAAE,CAAC;QACR,CAAC,GAAG,CAAC,CAAC;QACN,CAAC,GAAG,EAAE,CAAC;IACX,CAAC;IACD,MAAM,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;QACZ,KAAK,CAAC,EAAE,CAAC;YACL,CAAC,EAAE,CAAC;YACJ,KAAK,CAAC;QAEV,CAAC;QACD,KAAK,CAAC,EAAE,CAAC;YACL,CAAC,EAAE,CAAC;YACJ,KAAK,CAAC;QAEV,CAAC;QACD,SAAS,CAAC;YACN,CAAC,IAAI,CAAC,CAAC;YACP,CAAC,GAAG,EAAE,CAAC;YACP,KAAK,CAAC;QAEV,CAAC;IACL,CAAC;IACD,OAAO,CAAC,GAAG,EAAE,EAAE,CAAC;QACZ,CAAC,EAAE,CAAC;IACR,CAAC;IACD,GAAG,CAAC;QACA,CAAC,EAAE,CAAC;IACR,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAC;IACf,CAAC,GAAG,CAAC,CAAC;IACN,IAAI,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;IACjC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;IACzB,CAAC,KAAK,CAAC,CAAC;IACR,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC;IACX,IAAI,CAAC,GAAG,CAAC,CAAC;IACV,MAAM,CAAC;AACX,CAAC;AACD,IAAI,CAAC,GAAG;IACJ,IAAI,CAAC,GAAG,EAAE,CAAC;IACX,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;AACd,CAAC,CAAC;AACF,CAAC,EAAE,CAAC"} \ No newline at end of file diff --git a/tests/baselines/reference/sourceMapValidationStatements.sourcemap.txt b/tests/baselines/reference/sourceMapValidationStatements.sourcemap.txt index 7c5c5bfcfeb..aec7eaafc06 100644 --- a/tests/baselines/reference/sourceMapValidationStatements.sourcemap.txt +++ b/tests/baselines/reference/sourceMapValidationStatements.sourcemap.txt @@ -1251,15 +1251,19 @@ sourceFile:sourceMapValidationStatements.ts 7 > ^^^^ 8 > ^ 9 > ^ -10> ^^^ -11> ^ -12> ^^^ -13> ^ -14> ^^^ -15> ^ -16> ^^^ -17> ^ -18> ^ +10> ^ +11> ^ +12> ^ +13> ^ +14> ^^^ +15> ^ +16> ^ +17> ^ +18> ^ +19> ^ +20> ^^^ +21> ^ +22> ^ 1-> > 2 > var @@ -1270,15 +1274,19 @@ sourceFile:sourceMapValidationStatements.ts 7 > == 8 > 1 9 > ) -10> ? -11> x -12> + -13> 1 -14> : -15> x -16> - -17> 1 -18> ; +10> +11> ? +12> +13> x +14> + +15> 1 +16> +17> : +18> +19> x +20> - +21> 1 +22> ; 1->Emitted(74, 5) Source(72, 5) + SourceIndex(0) 2 >Emitted(74, 9) Source(72, 9) + SourceIndex(0) 3 >Emitted(74, 10) Source(72, 10) + SourceIndex(0) @@ -1288,15 +1296,19 @@ sourceFile:sourceMapValidationStatements.ts 7 >Emitted(74, 19) Source(72, 19) + SourceIndex(0) 8 >Emitted(74, 20) Source(72, 20) + SourceIndex(0) 9 >Emitted(74, 21) Source(72, 21) + SourceIndex(0) -10>Emitted(74, 24) Source(72, 24) + SourceIndex(0) -11>Emitted(74, 25) Source(72, 25) + SourceIndex(0) -12>Emitted(74, 28) Source(72, 28) + SourceIndex(0) -13>Emitted(74, 29) Source(72, 29) + SourceIndex(0) -14>Emitted(74, 32) Source(72, 32) + SourceIndex(0) -15>Emitted(74, 33) Source(72, 33) + SourceIndex(0) -16>Emitted(74, 36) Source(72, 36) + SourceIndex(0) -17>Emitted(74, 37) Source(72, 37) + SourceIndex(0) -18>Emitted(74, 38) Source(72, 38) + SourceIndex(0) +10>Emitted(74, 22) Source(72, 22) + SourceIndex(0) +11>Emitted(74, 23) Source(72, 23) + SourceIndex(0) +12>Emitted(74, 24) Source(72, 24) + SourceIndex(0) +13>Emitted(74, 25) Source(72, 25) + SourceIndex(0) +14>Emitted(74, 28) Source(72, 28) + SourceIndex(0) +15>Emitted(74, 29) Source(72, 29) + SourceIndex(0) +16>Emitted(74, 30) Source(72, 30) + SourceIndex(0) +17>Emitted(74, 31) Source(72, 31) + SourceIndex(0) +18>Emitted(74, 32) Source(72, 32) + SourceIndex(0) +19>Emitted(74, 33) Source(72, 33) + SourceIndex(0) +20>Emitted(74, 36) Source(72, 36) + SourceIndex(0) +21>Emitted(74, 37) Source(72, 37) + SourceIndex(0) +22>Emitted(74, 38) Source(72, 38) + SourceIndex(0) --- >>> (x == 1) ? x + 1 : x - 1; 1 >^^^^ @@ -1305,15 +1317,19 @@ sourceFile:sourceMapValidationStatements.ts 4 > ^^^^ 5 > ^ 6 > ^ -7 > ^^^ -8 > ^ -9 > ^^^ -10> ^ -11> ^^^ -12> ^ -13> ^^^ -14> ^ -15> ^ +7 > ^ +8 > ^ +9 > ^ +10> ^ +11> ^^^ +12> ^ +13> ^ +14> ^ +15> ^ +16> ^ +17> ^^^ +18> ^ +19> ^ 1 > > 2 > ( @@ -1321,30 +1337,38 @@ sourceFile:sourceMapValidationStatements.ts 4 > == 5 > 1 6 > ) -7 > ? -8 > x -9 > + -10> 1 -11> : -12> x -13> - -14> 1 -15> ; +7 > +8 > ? +9 > +10> x +11> + +12> 1 +13> +14> : +15> +16> x +17> - +18> 1 +19> ; 1 >Emitted(75, 5) Source(73, 5) + SourceIndex(0) 2 >Emitted(75, 6) Source(73, 6) + SourceIndex(0) 3 >Emitted(75, 7) Source(73, 7) + SourceIndex(0) 4 >Emitted(75, 11) Source(73, 11) + SourceIndex(0) 5 >Emitted(75, 12) Source(73, 12) + SourceIndex(0) 6 >Emitted(75, 13) Source(73, 13) + SourceIndex(0) -7 >Emitted(75, 16) Source(73, 16) + SourceIndex(0) -8 >Emitted(75, 17) Source(73, 17) + SourceIndex(0) -9 >Emitted(75, 20) Source(73, 20) + SourceIndex(0) -10>Emitted(75, 21) Source(73, 21) + SourceIndex(0) -11>Emitted(75, 24) Source(73, 24) + SourceIndex(0) -12>Emitted(75, 25) Source(73, 25) + SourceIndex(0) -13>Emitted(75, 28) Source(73, 28) + SourceIndex(0) -14>Emitted(75, 29) Source(73, 29) + SourceIndex(0) -15>Emitted(75, 30) Source(73, 30) + SourceIndex(0) +7 >Emitted(75, 14) Source(73, 14) + SourceIndex(0) +8 >Emitted(75, 15) Source(73, 15) + SourceIndex(0) +9 >Emitted(75, 16) Source(73, 16) + SourceIndex(0) +10>Emitted(75, 17) Source(73, 17) + SourceIndex(0) +11>Emitted(75, 20) Source(73, 20) + SourceIndex(0) +12>Emitted(75, 21) Source(73, 21) + SourceIndex(0) +13>Emitted(75, 22) Source(73, 22) + SourceIndex(0) +14>Emitted(75, 23) Source(73, 23) + SourceIndex(0) +15>Emitted(75, 24) Source(73, 24) + SourceIndex(0) +16>Emitted(75, 25) Source(73, 25) + SourceIndex(0) +17>Emitted(75, 28) Source(73, 28) + SourceIndex(0) +18>Emitted(75, 29) Source(73, 29) + SourceIndex(0) +19>Emitted(75, 30) Source(73, 30) + SourceIndex(0) --- >>> x === 1; 1 >^^^^ diff --git a/tests/baselines/reference/ternaryExpressionSourceMap.js.map b/tests/baselines/reference/ternaryExpressionSourceMap.js.map index 9340c972274..27160910378 100644 --- a/tests/baselines/reference/ternaryExpressionSourceMap.js.map +++ b/tests/baselines/reference/ternaryExpressionSourceMap.js.map @@ -1,2 +1,2 @@ //// [ternaryExpressionSourceMap.js.map] -{"version":3,"file":"ternaryExpressionSourceMap.js","sourceRoot":"","sources":["ternaryExpressionSourceMap.ts"],"names":[],"mappings":"AAAA,IAAI,CAAC,GAAG,CAAC,CAAC;AACV,IAAI,GAAG,GAAG,CAAC,GAAG,cAAM,OAAA,CAAC,EAAD,CAAC,GAAG,cAAM,OAAA,CAAC,EAAD,CAAC,CAAC"} \ No newline at end of file +{"version":3,"file":"ternaryExpressionSourceMap.js","sourceRoot":"","sources":["ternaryExpressionSourceMap.ts"],"names":[],"mappings":"AAAA,IAAI,CAAC,GAAG,CAAC,CAAC;AACV,IAAI,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC,cAAM,OAAA,CAAC,EAAD,CAAC,CAAC,CAAC,CAAC,cAAM,OAAA,CAAC,EAAD,CAAC,CAAC"} \ No newline at end of file diff --git a/tests/baselines/reference/ternaryExpressionSourceMap.sourcemap.txt b/tests/baselines/reference/ternaryExpressionSourceMap.sourcemap.txt index d46e703e357..87e3ce02304 100644 --- a/tests/baselines/reference/ternaryExpressionSourceMap.sourcemap.txt +++ b/tests/baselines/reference/ternaryExpressionSourceMap.sourcemap.txt @@ -35,55 +35,67 @@ sourceFile:ternaryExpressionSourceMap.ts 3 > ^^^ 4 > ^^^ 5 > ^ -6 > ^^^ -7 > ^^^^^^^^^^^^^^ -8 > ^^^^^^^ -9 > ^ -10> ^^ -11> ^ -12> ^^^ -13> ^^^^^^^^^^^^^^ -14> ^^^^^^^ -15> ^ -16> ^^ -17> ^ -18> ^ +6 > ^ +7 > ^ +8 > ^ +9 > ^^^^^^^^^^^^^^ +10> ^^^^^^^ +11> ^ +12> ^^ +13> ^ +14> ^ +15> ^ +16> ^ +17> ^^^^^^^^^^^^^^ +18> ^^^^^^^ +19> ^ +20> ^^ +21> ^ +22> ^ 1-> > 2 >var 3 > foo 4 > = 5 > x -6 > ? -7 > () => -8 > -9 > 0 -10> -11> 0 -12> : -13> () => -14> -15> 0 -16> -17> 0 -18> ; +6 > +7 > ? +8 > +9 > () => +10> +11> 0 +12> +13> 0 +14> +15> : +16> +17> () => +18> +19> 0 +20> +21> 0 +22> ; 1->Emitted(2, 1) Source(2, 1) + SourceIndex(0) 2 >Emitted(2, 5) Source(2, 5) + SourceIndex(0) 3 >Emitted(2, 8) Source(2, 8) + SourceIndex(0) 4 >Emitted(2, 11) Source(2, 11) + SourceIndex(0) 5 >Emitted(2, 12) Source(2, 12) + SourceIndex(0) -6 >Emitted(2, 15) Source(2, 15) + SourceIndex(0) -7 >Emitted(2, 29) Source(2, 21) + SourceIndex(0) -8 >Emitted(2, 36) Source(2, 21) + SourceIndex(0) -9 >Emitted(2, 37) Source(2, 22) + SourceIndex(0) -10>Emitted(2, 39) Source(2, 21) + SourceIndex(0) -11>Emitted(2, 40) Source(2, 22) + SourceIndex(0) -12>Emitted(2, 43) Source(2, 25) + SourceIndex(0) -13>Emitted(2, 57) Source(2, 31) + SourceIndex(0) -14>Emitted(2, 64) Source(2, 31) + SourceIndex(0) -15>Emitted(2, 65) Source(2, 32) + SourceIndex(0) -16>Emitted(2, 67) Source(2, 31) + SourceIndex(0) -17>Emitted(2, 68) Source(2, 32) + SourceIndex(0) -18>Emitted(2, 69) Source(2, 33) + SourceIndex(0) +6 >Emitted(2, 13) Source(2, 13) + SourceIndex(0) +7 >Emitted(2, 14) Source(2, 14) + SourceIndex(0) +8 >Emitted(2, 15) Source(2, 15) + SourceIndex(0) +9 >Emitted(2, 29) Source(2, 21) + SourceIndex(0) +10>Emitted(2, 36) Source(2, 21) + SourceIndex(0) +11>Emitted(2, 37) Source(2, 22) + SourceIndex(0) +12>Emitted(2, 39) Source(2, 21) + SourceIndex(0) +13>Emitted(2, 40) Source(2, 22) + SourceIndex(0) +14>Emitted(2, 41) Source(2, 23) + SourceIndex(0) +15>Emitted(2, 42) Source(2, 24) + SourceIndex(0) +16>Emitted(2, 43) Source(2, 25) + SourceIndex(0) +17>Emitted(2, 57) Source(2, 31) + SourceIndex(0) +18>Emitted(2, 64) Source(2, 31) + SourceIndex(0) +19>Emitted(2, 65) Source(2, 32) + SourceIndex(0) +20>Emitted(2, 67) Source(2, 31) + SourceIndex(0) +21>Emitted(2, 68) Source(2, 32) + SourceIndex(0) +22>Emitted(2, 69) Source(2, 33) + SourceIndex(0) --- >>>//# sourceMappingURL=ternaryExpressionSourceMap.js.map \ No newline at end of file diff --git a/tests/baselines/reference/typeGuardsInRightOperandOfAndAndOperator.js b/tests/baselines/reference/typeGuardsInRightOperandOfAndAndOperator.js index be1c497e3ea..5483f314fb9 100644 --- a/tests/baselines/reference/typeGuardsInRightOperandOfAndAndOperator.js +++ b/tests/baselines/reference/typeGuardsInRightOperandOfAndAndOperator.js @@ -85,6 +85,8 @@ function foo7(x) { return typeof x !== "string" && ((z = x) // number | boolean && (typeof x === "number" + // change value of x ? ((x = 10) && x.toString()) // x is number + // do not change value : ((y = x) && x.toString()))); // x is boolean } diff --git a/tests/baselines/reference/typeGuardsInRightOperandOfOrOrOperator.js b/tests/baselines/reference/typeGuardsInRightOperandOfOrOrOperator.js index a8d66dc5fa2..c3143999d3a 100644 --- a/tests/baselines/reference/typeGuardsInRightOperandOfOrOrOperator.js +++ b/tests/baselines/reference/typeGuardsInRightOperandOfOrOrOperator.js @@ -87,6 +87,8 @@ function foo7(x) { return typeof x === "string" || ((z = x) // number | boolean || (typeof x === "number" + // change value of x ? ((x = 10) && x.toString()) // number | boolean | string + // do not change value : ((y = x) && x.toString()))); // number | boolean | string } diff --git a/tests/cases/fourslash/extract-method-formatting.ts b/tests/cases/fourslash/extract-method-formatting.ts new file mode 100644 index 00000000000..1342e5632e8 --- /dev/null +++ b/tests/cases/fourslash/extract-method-formatting.ts @@ -0,0 +1,24 @@ +/// + +////function f(x: number): number { +//// /*start*/switch (x) {case 0: +////return 0;}/*end*/ +////} + +goTo.select('start', 'end') +edit.applyRefactor({ + refactorName: "Extract Method", + actionName: "scope_1", + actionDescription: "Extract function into global scope", +}); +verify.currentFileContentIs( +`function f(x: number): number { + return newFunction(x); +} +function newFunction(x: number) { + switch (x) { + case 0: + return 0; + } +} +`); diff --git a/tests/cases/fourslash/extract-method5.ts b/tests/cases/fourslash/extract-method5.ts index d1e70d10716..8b0bd4fec6d 100644 --- a/tests/cases/fourslash/extract-method5.ts +++ b/tests/cases/fourslash/extract-method5.ts @@ -20,6 +20,6 @@ verify.currentFileContentIs( var x: 1 | 2 | 3 = newFunction(); function newFunction(): 1 | 2 | 3 { - return 1 + 1 === 2?1: 2; + return 1 + 1 === 2 ? 1 : 2; } }`); \ No newline at end of file From 2e027789606a7b5bcd015cf1173823ed8f83023b Mon Sep 17 00:00:00 2001 From: Andy Date: Thu, 7 Sep 2017 14:31:20 -0700 Subject: [PATCH 266/370] When loading a module from node_modules, get packageId even in the `loadModuleFromFile` case (#18185) * When loading a module from node_modules, get packageId even in the `loadModuleFromFile` case * Support packageId for too --- src/compiler/moduleNameResolver.ts | 103 +++++++++++------- src/compiler/program.ts | 14 +-- src/compiler/types.ts | 6 + src/compiler/utilities.ts | 2 +- src/harness/unittests/moduleResolution.ts | 31 +++--- .../unittests/reuseProgramStructure.ts | 20 ++-- .../unittests/tsserverProjectSystem.ts | 2 +- ...icatePackage_packageIdIncludesSubModule.js | 22 ++++ ...Package_packageIdIncludesSubModule.symbols | 20 ++++ ...tePackage_packageIdIncludesSubModule.types | 20 ++++ .../duplicatePackage_referenceTypes.js | 31 ++++++ .../duplicatePackage_referenceTypes.symbols | 33 ++++++ .../duplicatePackage_referenceTypes.types | 33 ++++++ .../reference/duplicatePackage_subModule.js | 34 ++++++ .../duplicatePackage_subModule.symbols | 38 +++++++ .../duplicatePackage_subModule.types | 38 +++++++ .../reference/library-reference-11.trace.json | 2 +- .../reference/library-reference-12.trace.json | 2 +- .../reference/library-reference-3.trace.json | 2 +- .../reference/library-reference-4.trace.json | 8 +- .../reference/library-reference-5.trace.json | 8 +- .../reference/library-reference-7.trace.json | 2 +- ...brary-reference-scoped-packages.trace.json | 2 +- ...NodeModuleJsDepthDefaultsToZero.trace.json | 4 +- ...lutionWithExtensions_unexpected.trace.json | 4 +- ...utionWithExtensions_unexpected2.trace.json | 4 +- ...thExtensions_withAmbientPresent.trace.json | 4 +- .../moduleResolutionWithSymlinks.trace.json | 2 +- ...onWithSymlinks_preserveSymlinks.trace.json | 10 +- ...tionWithSymlinks_referenceTypes.trace.json | 6 +- ...solutionWithSymlinks_withOutDir.trace.json | 2 +- .../reference/packageJsonMain.trace.json | 12 +- .../packageJsonMain_isNonRecursive.trace.json | 4 +- ...pingBasedModuleResolution3_node.trace.json | 2 +- ...pingBasedModuleResolution4_node.trace.json | 2 +- .../reference/scopedPackages.trace.json | 5 +- .../scopedPackagesClassic.trace.json | 2 +- .../reference/typingsLookup4.trace.json | 8 +- .../reference/typingsLookupAmd.trace.json | 4 +- ...icatePackage_packageIdIncludesSubModule.ts | 17 +++ .../duplicatePackage_referenceTypes.ts | 24 ++++ .../compiler/duplicatePackage_subModule.ts | 27 +++++ 42 files changed, 493 insertions(+), 123 deletions(-) create mode 100644 tests/baselines/reference/duplicatePackage_packageIdIncludesSubModule.js create mode 100644 tests/baselines/reference/duplicatePackage_packageIdIncludesSubModule.symbols create mode 100644 tests/baselines/reference/duplicatePackage_packageIdIncludesSubModule.types create mode 100644 tests/baselines/reference/duplicatePackage_referenceTypes.js create mode 100644 tests/baselines/reference/duplicatePackage_referenceTypes.symbols create mode 100644 tests/baselines/reference/duplicatePackage_referenceTypes.types create mode 100644 tests/baselines/reference/duplicatePackage_subModule.js create mode 100644 tests/baselines/reference/duplicatePackage_subModule.symbols create mode 100644 tests/baselines/reference/duplicatePackage_subModule.types create mode 100644 tests/cases/compiler/duplicatePackage_packageIdIncludesSubModule.ts create mode 100644 tests/cases/compiler/duplicatePackage_referenceTypes.ts create mode 100644 tests/cases/compiler/duplicatePackage_subModule.ts diff --git a/src/compiler/moduleNameResolver.ts b/src/compiler/moduleNameResolver.ts index 5fdac504896..ddffe876d80 100644 --- a/src/compiler/moduleNameResolver.ts +++ b/src/compiler/moduleNameResolver.ts @@ -51,13 +51,17 @@ namespace ts { DtsOnly /** Only '.d.ts' */ } + interface PathAndPackageId { + readonly fileName: string; + readonly packageId: PackageId; + } /** Used with `Extensions.DtsOnly` to extract the path from TypeScript results. */ - function resolvedTypeScriptOnly(resolved: Resolved | undefined): string | undefined { + function resolvedTypeScriptOnly(resolved: Resolved | undefined): PathAndPackageId | undefined { if (!resolved) { return undefined; } Debug.assert(extensionIsTypeScript(resolved.extension)); - return resolved.path; + return { fileName: resolved.path, packageId: resolved.packageId }; } function createResolvedModuleWithFailedLookupLocations(resolved: Resolved | undefined, isExternalLibraryImport: boolean, failedLookupLocations: string[]): ResolvedModuleWithFailedLookupLocations { @@ -201,18 +205,18 @@ namespace ts { let resolvedTypeReferenceDirective: ResolvedTypeReferenceDirective | undefined; if (resolved) { if (!options.preserveSymlinks) { - resolved = realPath(resolved, host, traceEnabled); + resolved = { ...resolved, fileName: realPath(resolved.fileName, host, traceEnabled) }; } if (traceEnabled) { - trace(host, Diagnostics.Type_reference_directive_0_was_successfully_resolved_to_1_primary_Colon_2, typeReferenceDirectiveName, resolved, primary); + trace(host, Diagnostics.Type_reference_directive_0_was_successfully_resolved_to_1_primary_Colon_2, typeReferenceDirectiveName, resolved.fileName, primary); } - resolvedTypeReferenceDirective = { primary, resolvedFileName: resolved }; + resolvedTypeReferenceDirective = { primary, resolvedFileName: resolved.fileName, packageId: resolved.packageId }; } return { resolvedTypeReferenceDirective, failedLookupLocations }; - function primaryLookup(): string | undefined { + function primaryLookup(): PathAndPackageId | undefined { // Check primary library paths if (typeRoots && typeRoots.length) { if (traceEnabled) { @@ -237,8 +241,8 @@ namespace ts { } } - function secondaryLookup(): string | undefined { - let resolvedFile: string; + function secondaryLookup(): PathAndPackageId | undefined { + let resolvedFile: PathAndPackageId; const initialLocationForSecondaryLookup = containingFile && getDirectoryPath(containingFile); if (initialLocationForSecondaryLookup !== undefined) { @@ -675,7 +679,7 @@ namespace ts { if (extension !== undefined) { const path = tryFile(candidate, failedLookupLocations, /*onlyRecordFailures*/ false, state); if (path !== undefined) { - return { path, extension, packageId: undefined }; + return noPackageId({ path, ext: extension }); } } @@ -875,38 +879,49 @@ namespace ts { return undefined; } - function loadNodeModuleFromDirectory(extensions: Extensions, candidate: string, failedLookupLocations: Push, onlyRecordFailures: boolean, state: ModuleResolutionState, considerPackageJson = true): Resolved | undefined { - const directoryExists = !onlyRecordFailures && directoryProbablyExists(candidate, state.host); + function loadNodeModuleFromDirectory(extensions: Extensions, candidate: string, failedLookupLocations: Push, onlyRecordFailures: boolean, state: ModuleResolutionState, considerPackageJson = true) { + const { packageJsonContent, packageId } = considerPackageJson + ? getPackageJsonInfo(candidate, "", failedLookupLocations, onlyRecordFailures, state) + : { packageJsonContent: undefined, packageId: undefined }; + return withPackageId(packageId, loadNodeModuleFromDirectoryWorker(extensions, candidate, failedLookupLocations, onlyRecordFailures, state, packageJsonContent)); + } - let packageId: PackageId | undefined; - - if (considerPackageJson) { - const packageJsonPath = pathToPackageJson(candidate); - if (directoryExists && state.host.fileExists(packageJsonPath)) { - if (state.traceEnabled) { - trace(state.host, Diagnostics.Found_package_json_at_0, packageJsonPath); - } - const jsonContent = readJson(packageJsonPath, state.host); - - if (typeof jsonContent.name === "string" && typeof jsonContent.version === "string") { - packageId = { name: jsonContent.name, version: jsonContent.version }; - } - - const fromPackageJson = loadModuleFromPackageJson(jsonContent, extensions, candidate, failedLookupLocations, state); - if (fromPackageJson) { - return withPackageId(packageId, fromPackageJson); - } - } - else { - if (directoryExists && state.traceEnabled) { - trace(state.host, Diagnostics.File_0_does_not_exist, packageJsonPath); - } - // record package json as one of failed lookup locations - in the future if this file will appear it will invalidate resolution results - failedLookupLocations.push(packageJsonPath); - } + function loadNodeModuleFromDirectoryWorker(extensions: Extensions, candidate: string, failedLookupLocations: Push, onlyRecordFailures: boolean, state: ModuleResolutionState, packageJsonContent: PackageJson | undefined): PathAndExtension | undefined { + const fromPackageJson = packageJsonContent && loadModuleFromPackageJson(packageJsonContent, extensions, candidate, failedLookupLocations, state); + if (fromPackageJson) { + return fromPackageJson; } + const directoryExists = !onlyRecordFailures && directoryProbablyExists(candidate, state.host); + return loadModuleFromFile(extensions, combinePaths(candidate, "index"), failedLookupLocations, !directoryExists, state); + } - return withPackageId(packageId, loadModuleFromFile(extensions, combinePaths(candidate, "index"), failedLookupLocations, !directoryExists, state)); + function getPackageJsonInfo( + nodeModuleDirectory: string, + subModuleName: string, + failedLookupLocations: Push, + onlyRecordFailures: boolean, + { host, traceEnabled }: ModuleResolutionState, + ): { packageJsonContent: PackageJson | undefined, packageId: PackageId | undefined } { + const directoryExists = !onlyRecordFailures && directoryProbablyExists(nodeModuleDirectory, host); + const packageJsonPath = pathToPackageJson(nodeModuleDirectory); + if (directoryExists && host.fileExists(packageJsonPath)) { + if (traceEnabled) { + trace(host, Diagnostics.Found_package_json_at_0, packageJsonPath); + } + const packageJsonContent = readJson(packageJsonPath, host); + const packageId: PackageId = typeof packageJsonContent.name === "string" && typeof packageJsonContent.version === "string" + ? { name: packageJsonContent.name, subModuleName, version: packageJsonContent.version } + : undefined; + return { packageJsonContent, packageId }; + } + else { + if (directoryExists && traceEnabled) { + trace(host, Diagnostics.File_0_does_not_exist, packageJsonPath); + } + // record package json as one of failed lookup locations - in the future if this file will appear it will invalidate resolution results + failedLookupLocations.push(packageJsonPath); + return { packageJsonContent: undefined, packageId: undefined }; + } } function loadModuleFromPackageJson(jsonContent: PackageJson, extensions: Extensions, candidate: string, failedLookupLocations: Push, state: ModuleResolutionState): PathAndExtension | undefined { @@ -961,10 +976,18 @@ namespace ts { } function loadModuleFromNodeModulesFolder(extensions: Extensions, moduleName: string, nodeModulesFolder: string, nodeModulesFolderExists: boolean, failedLookupLocations: Push, state: ModuleResolutionState): Resolved | undefined { + const { top, rest } = getNameOfTopDirectory(moduleName); + const packageRootPath = combinePaths(nodeModulesFolder, top); + const { packageJsonContent, packageId } = getPackageJsonInfo(packageRootPath, rest, failedLookupLocations, !nodeModulesFolderExists, state); const candidate = normalizePath(combinePaths(nodeModulesFolder, moduleName)); + const pathAndExtension = loadModuleFromFile(extensions, candidate, failedLookupLocations, !nodeModulesFolderExists, state) || + loadNodeModuleFromDirectoryWorker(extensions, candidate, failedLookupLocations, !nodeModulesFolderExists, state, packageJsonContent); + return withPackageId(packageId, pathAndExtension); + } - return loadModuleFromFileNoPackageId(extensions, candidate, failedLookupLocations, !nodeModulesFolderExists, state) || - loadNodeModuleFromDirectory(extensions, candidate, failedLookupLocations, !nodeModulesFolderExists, state); + function getNameOfTopDirectory(name: string): { top: string, rest: string } { + const idx = name.indexOf(directorySeparator); + return idx === -1 ? { top: name, rest: "" } : { top: name.slice(0, idx), rest: name.slice(idx + 1) }; } function loadModuleFromNodeModules(extensions: Extensions, moduleName: string, directory: string, failedLookupLocations: Push, state: ModuleResolutionState, cache: NonRelativeModuleNameResolutionCache): SearchResult { diff --git a/src/compiler/program.ts b/src/compiler/program.ts index 89c23598c58..00e933d680a 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -1427,7 +1427,7 @@ namespace ts { } function processRootFile(fileName: string, isDefaultLib: boolean) { - processSourceFile(normalizePath(fileName), isDefaultLib); + processSourceFile(normalizePath(fileName), isDefaultLib, /*packageId*/ undefined); } function fileReferenceIsEqualTo(a: FileReference, b: FileReference): boolean { @@ -1591,9 +1591,9 @@ namespace ts { } /** This has side effects through `findSourceFile`. */ - function processSourceFile(fileName: string, isDefaultLib: boolean, refFile?: SourceFile, refPos?: number, refEnd?: number): void { + function processSourceFile(fileName: string, isDefaultLib: boolean, packageId: PackageId | undefined, refFile?: SourceFile, refPos?: number, refEnd?: number): void { getSourceFileFromReferenceWorker(fileName, - fileName => findSourceFile(fileName, toPath(fileName), isDefaultLib, refFile, refPos, refEnd, /*packageId*/ undefined), + fileName => findSourceFile(fileName, toPath(fileName), isDefaultLib, refFile, refPos, refEnd, packageId), (diagnostic, ...args) => { fileProcessingDiagnostics.add(refFile !== undefined && refEnd !== undefined && refPos !== undefined ? createFileDiagnostic(refFile, refPos, refEnd - refPos, diagnostic, ...args) @@ -1675,7 +1675,7 @@ namespace ts { }); if (packageId) { - const packageIdKey = `${packageId.name}@${packageId.version}`; + const packageIdKey = `${packageId.name}/${packageId.subModuleName}@${packageId.version}`; const fileFromPackageId = packageIdToSourceFile.get(packageIdKey); if (fileFromPackageId) { // Some other SourceFile already exists with this package name and version. @@ -1735,7 +1735,7 @@ namespace ts { function processReferencedFiles(file: SourceFile, isDefaultLib: boolean) { forEach(file.referencedFiles, ref => { const referencedFileName = resolveTripleslashReference(ref.fileName, file.fileName); - processSourceFile(referencedFileName, isDefaultLib, file, ref.pos, ref.end); + processSourceFile(referencedFileName, isDefaultLib, /*packageId*/ undefined, file, ref.pos, ref.end); }); } @@ -1766,7 +1766,7 @@ namespace ts { if (resolvedTypeReferenceDirective) { if (resolvedTypeReferenceDirective.primary) { // resolved from the primary path - processSourceFile(resolvedTypeReferenceDirective.resolvedFileName, /*isDefaultLib*/ false, refFile, refPos, refEnd); + processSourceFile(resolvedTypeReferenceDirective.resolvedFileName, /*isDefaultLib*/ false, resolvedTypeReferenceDirective.packageId, refFile, refPos, refEnd); } else { // If we already resolved to this file, it must have been a secondary reference. Check file contents @@ -1789,7 +1789,7 @@ namespace ts { } else { // First resolution of this library - processSourceFile(resolvedTypeReferenceDirective.resolvedFileName, /*isDefaultLib*/ false, refFile, refPos, refEnd); + processSourceFile(resolvedTypeReferenceDirective.resolvedFileName, /*isDefaultLib*/ false, resolvedTypeReferenceDirective.packageId, refFile, refPos, refEnd); } } } diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 1b5a0164585..c9ba56506a4 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -4055,6 +4055,11 @@ namespace ts { * If accessing a non-index file, this should include its name e.g. "foo/bar". */ name: string; + /** + * Name of a submodule within this package. + * May be "". + */ + subModuleName: string; /** Version of the package, e.g. "1.2.3" */ version: string; } @@ -4078,6 +4083,7 @@ namespace ts { primary: boolean; // The location of the .d.ts file we located, or undefined if resolution failed resolvedFileName?: string; + packageId?: PackageId; } export interface ResolvedTypeReferenceDirectiveWithFailedLookupLocations { diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index 160d81d04da..06b8437f76b 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -104,7 +104,7 @@ namespace ts { } function packageIdIsEqual(a: PackageId | undefined, b: PackageId | undefined): boolean { - return a === b || a && b && a.name === b.name && a.version === b.version; + return a === b || a && b && a.name === b.name && a.subModuleName === b.subModuleName && a.version === b.version; } export function typeDirectiveIsEqualTo(oldResolution: ResolvedTypeReferenceDirective, newResolution: ResolvedTypeReferenceDirective): boolean { diff --git a/src/harness/unittests/moduleResolution.ts b/src/harness/unittests/moduleResolution.ts index ed8dcf0c7b4..0acbe9450bb 100644 --- a/src/harness/unittests/moduleResolution.ts +++ b/src/harness/unittests/moduleResolution.ts @@ -198,33 +198,34 @@ namespace ts { const moduleFile = { name: "/a/b/node_modules/foo.ts" }; const resolution = nodeModuleNameResolver("foo", containingFile.name, {}, createModuleResolutionHost(hasDirectoryExists, containingFile, moduleFile)); checkResolvedModuleWithFailedLookupLocations(resolution, createResolvedModule(moduleFile.name, /*isExternalLibraryImport*/ true), [ + "/a/b/c/d/node_modules/foo/package.json", "/a/b/c/d/node_modules/foo.ts", "/a/b/c/d/node_modules/foo.tsx", "/a/b/c/d/node_modules/foo.d.ts", - "/a/b/c/d/node_modules/foo/package.json", "/a/b/c/d/node_modules/foo/index.ts", "/a/b/c/d/node_modules/foo/index.tsx", "/a/b/c/d/node_modules/foo/index.d.ts", - "/a/b/c/d/node_modules/@types/foo.d.ts", "/a/b/c/d/node_modules/@types/foo/package.json", + "/a/b/c/d/node_modules/@types/foo.d.ts", "/a/b/c/d/node_modules/@types/foo/index.d.ts", + "/a/b/c/node_modules/foo/package.json", "/a/b/c/node_modules/foo.ts", "/a/b/c/node_modules/foo.tsx", "/a/b/c/node_modules/foo.d.ts", - "/a/b/c/node_modules/foo/package.json", "/a/b/c/node_modules/foo/index.ts", "/a/b/c/node_modules/foo/index.tsx", "/a/b/c/node_modules/foo/index.d.ts", - "/a/b/c/node_modules/@types/foo.d.ts", "/a/b/c/node_modules/@types/foo/package.json", + "/a/b/c/node_modules/@types/foo.d.ts", "/a/b/c/node_modules/@types/foo/index.d.ts", + "/a/b/node_modules/foo/package.json", ]); } }); @@ -250,52 +251,52 @@ namespace ts { const moduleFile: File = { name: "/a/node_modules/foo/index.d.ts" }; const resolution = nodeModuleNameResolver("foo", containingFile.name, {}, createModuleResolutionHost(hasDirectoryExists, containingFile, moduleFile)); checkResolvedModuleWithFailedLookupLocations(resolution, createResolvedModule(moduleFile.name, /*isExternalLibraryImport*/ true), [ + "/a/node_modules/b/c/node_modules/d/node_modules/foo/package.json", "/a/node_modules/b/c/node_modules/d/node_modules/foo.ts", "/a/node_modules/b/c/node_modules/d/node_modules/foo.tsx", "/a/node_modules/b/c/node_modules/d/node_modules/foo.d.ts", - "/a/node_modules/b/c/node_modules/d/node_modules/foo/package.json", "/a/node_modules/b/c/node_modules/d/node_modules/foo/index.ts", "/a/node_modules/b/c/node_modules/d/node_modules/foo/index.tsx", "/a/node_modules/b/c/node_modules/d/node_modules/foo/index.d.ts", - "/a/node_modules/b/c/node_modules/d/node_modules/@types/foo.d.ts", "/a/node_modules/b/c/node_modules/d/node_modules/@types/foo/package.json", + "/a/node_modules/b/c/node_modules/d/node_modules/@types/foo.d.ts", "/a/node_modules/b/c/node_modules/d/node_modules/@types/foo/index.d.ts", + "/a/node_modules/b/c/node_modules/foo/package.json", "/a/node_modules/b/c/node_modules/foo.ts", "/a/node_modules/b/c/node_modules/foo.tsx", "/a/node_modules/b/c/node_modules/foo.d.ts", - "/a/node_modules/b/c/node_modules/foo/package.json", "/a/node_modules/b/c/node_modules/foo/index.ts", "/a/node_modules/b/c/node_modules/foo/index.tsx", "/a/node_modules/b/c/node_modules/foo/index.d.ts", - "/a/node_modules/b/c/node_modules/@types/foo.d.ts", "/a/node_modules/b/c/node_modules/@types/foo/package.json", + "/a/node_modules/b/c/node_modules/@types/foo.d.ts", "/a/node_modules/b/c/node_modules/@types/foo/index.d.ts", + "/a/node_modules/b/node_modules/foo/package.json", "/a/node_modules/b/node_modules/foo.ts", "/a/node_modules/b/node_modules/foo.tsx", "/a/node_modules/b/node_modules/foo.d.ts", - "/a/node_modules/b/node_modules/foo/package.json", "/a/node_modules/b/node_modules/foo/index.ts", "/a/node_modules/b/node_modules/foo/index.tsx", "/a/node_modules/b/node_modules/foo/index.d.ts", - "/a/node_modules/b/node_modules/@types/foo.d.ts", "/a/node_modules/b/node_modules/@types/foo/package.json", + "/a/node_modules/b/node_modules/@types/foo.d.ts", "/a/node_modules/b/node_modules/@types/foo/index.d.ts", + "/a/node_modules/foo/package.json", "/a/node_modules/foo.ts", "/a/node_modules/foo.tsx", "/a/node_modules/foo.d.ts", - "/a/node_modules/foo/package.json", "/a/node_modules/foo/index.ts", "/a/node_modules/foo/index.tsx" @@ -707,21 +708,23 @@ import b = require("./moduleB"); "/root/generated/file6/index.d.ts", // fallback to standard node behavior + "/root/folder1/node_modules/file6/package.json", + // load from file "/root/folder1/node_modules/file6.ts", "/root/folder1/node_modules/file6.tsx", "/root/folder1/node_modules/file6.d.ts", // load from folder - "/root/folder1/node_modules/file6/package.json", "/root/folder1/node_modules/file6/index.ts", "/root/folder1/node_modules/file6/index.tsx", "/root/folder1/node_modules/file6/index.d.ts", - "/root/folder1/node_modules/@types/file6.d.ts", - "/root/folder1/node_modules/@types/file6/package.json", + "/root/folder1/node_modules/@types/file6.d.ts", "/root/folder1/node_modules/@types/file6/index.d.ts", + + "/root/node_modules/file6/package.json", // success on /root/node_modules/file6.ts ], /*isExternalLibraryImport*/ true); diff --git a/src/harness/unittests/reuseProgramStructure.ts b/src/harness/unittests/reuseProgramStructure.ts index 0c2a4a7052b..8c8c1034677 100644 --- a/src/harness/unittests/reuseProgramStructure.ts +++ b/src/harness/unittests/reuseProgramStructure.ts @@ -441,20 +441,20 @@ namespace ts { "======== Resolving module 'a' from 'file1.ts'. ========", "Explicitly specified module resolution kind: 'NodeJs'.", "Loading module 'a' from 'node_modules' folder, target file type 'TypeScript'.", + "File 'node_modules/a/package.json' does not exist.", "File 'node_modules/a.ts' does not exist.", "File 'node_modules/a.tsx' does not exist.", "File 'node_modules/a.d.ts' does not exist.", - "File 'node_modules/a/package.json' does not exist.", "File 'node_modules/a/index.ts' does not exist.", "File 'node_modules/a/index.tsx' does not exist.", "File 'node_modules/a/index.d.ts' does not exist.", - "File 'node_modules/@types/a.d.ts' does not exist.", "File 'node_modules/@types/a/package.json' does not exist.", + "File 'node_modules/@types/a.d.ts' does not exist.", "File 'node_modules/@types/a/index.d.ts' does not exist.", "Loading module 'a' from 'node_modules' folder, target file type 'JavaScript'.", + "File 'node_modules/a/package.json' does not exist.", "File 'node_modules/a.js' does not exist.", "File 'node_modules/a.jsx' does not exist.", - "File 'node_modules/a/package.json' does not exist.", "File 'node_modules/a/index.js' does not exist.", "File 'node_modules/a/index.jsx' does not exist.", "======== Module name 'a' was not resolved. ========" @@ -474,10 +474,10 @@ namespace ts { "======== Resolving module 'a' from 'file1.ts'. ========", "Explicitly specified module resolution kind: 'NodeJs'.", "Loading module 'a' from 'node_modules' folder, target file type 'TypeScript'.", + "File 'node_modules/a/package.json' does not exist.", "File 'node_modules/a.ts' does not exist.", "File 'node_modules/a.tsx' does not exist.", "File 'node_modules/a.d.ts' does not exist.", - "File 'node_modules/a/package.json' does not exist.", "File 'node_modules/a/index.ts' does not exist.", "File 'node_modules/a/index.tsx' does not exist.", "File 'node_modules/a/index.d.ts' exist - use it as a name resolution result.", @@ -510,14 +510,14 @@ namespace ts { "File '/fs.ts' does not exist.", "File '/fs.tsx' does not exist.", "File '/fs.d.ts' does not exist.", - "File '/a/b/node_modules/@types/fs.d.ts' does not exist.", "File '/a/b/node_modules/@types/fs/package.json' does not exist.", + "File '/a/b/node_modules/@types/fs.d.ts' does not exist.", "File '/a/b/node_modules/@types/fs/index.d.ts' does not exist.", - "File '/a/node_modules/@types/fs.d.ts' does not exist.", "File '/a/node_modules/@types/fs/package.json' does not exist.", + "File '/a/node_modules/@types/fs.d.ts' does not exist.", "File '/a/node_modules/@types/fs/index.d.ts' does not exist.", - "File '/node_modules/@types/fs.d.ts' does not exist.", "File '/node_modules/@types/fs/package.json' does not exist.", + "File '/node_modules/@types/fs.d.ts' does not exist.", "File '/node_modules/@types/fs/index.d.ts' does not exist.", "File '/a/b/fs.js' does not exist.", "File '/a/b/fs.jsx' does not exist.", @@ -552,14 +552,14 @@ namespace ts { "File '/fs.ts' does not exist.", "File '/fs.tsx' does not exist.", "File '/fs.d.ts' does not exist.", - "File '/a/b/node_modules/@types/fs.d.ts' does not exist.", "File '/a/b/node_modules/@types/fs/package.json' does not exist.", + "File '/a/b/node_modules/@types/fs.d.ts' does not exist.", "File '/a/b/node_modules/@types/fs/index.d.ts' does not exist.", - "File '/a/node_modules/@types/fs.d.ts' does not exist.", "File '/a/node_modules/@types/fs/package.json' does not exist.", + "File '/a/node_modules/@types/fs.d.ts' does not exist.", "File '/a/node_modules/@types/fs/index.d.ts' does not exist.", - "File '/node_modules/@types/fs.d.ts' does not exist.", "File '/node_modules/@types/fs/package.json' does not exist.", + "File '/node_modules/@types/fs.d.ts' does not exist.", "File '/node_modules/@types/fs/index.d.ts' does not exist.", "File '/a/b/fs.js' does not exist.", "File '/a/b/fs.jsx' does not exist.", diff --git a/src/harness/unittests/tsserverProjectSystem.ts b/src/harness/unittests/tsserverProjectSystem.ts index c9a74310977..651dbae7142 100644 --- a/src/harness/unittests/tsserverProjectSystem.ts +++ b/src/harness/unittests/tsserverProjectSystem.ts @@ -2510,8 +2510,8 @@ namespace ts.projectSystem { "======== Module name 'lib' was not resolved. ========", `Auto discovery for typings is enabled in project '${proj.getProjectName()}'. Running extra resolution pass for module 'lib' using cache location '/a/cache'.`, "File '/a/cache/node_modules/lib.d.ts' does not exist.", - "File '/a/cache/node_modules/@types/lib.d.ts' does not exist.", "File '/a/cache/node_modules/@types/lib/package.json' does not exist.", + "File '/a/cache/node_modules/@types/lib.d.ts' does not exist.", "File '/a/cache/node_modules/@types/lib/index.d.ts' exist - use it as a name resolution result.", ]); checkProjectActualFiles(proj, [file1.path, lib.path]); diff --git a/tests/baselines/reference/duplicatePackage_packageIdIncludesSubModule.js b/tests/baselines/reference/duplicatePackage_packageIdIncludesSubModule.js new file mode 100644 index 00000000000..9817641484e --- /dev/null +++ b/tests/baselines/reference/duplicatePackage_packageIdIncludesSubModule.js @@ -0,0 +1,22 @@ +//// [tests/cases/compiler/duplicatePackage_packageIdIncludesSubModule.ts] //// + +//// [Foo.d.ts] +export default class Foo { + protected source: boolean; +} + +//// [Bar.d.ts] +// This is *not* the same! +export const x: number; + +//// [package.json] +{ "name": "foo", "version": "1.2.3" } + +//// [index.ts] +import Foo from "foo/Foo"; +import { x } from "foo/Bar"; + + +//// [index.js] +"use strict"; +exports.__esModule = true; diff --git a/tests/baselines/reference/duplicatePackage_packageIdIncludesSubModule.symbols b/tests/baselines/reference/duplicatePackage_packageIdIncludesSubModule.symbols new file mode 100644 index 00000000000..2174580394b --- /dev/null +++ b/tests/baselines/reference/duplicatePackage_packageIdIncludesSubModule.symbols @@ -0,0 +1,20 @@ +=== /index.ts === +import Foo from "foo/Foo"; +>Foo : Symbol(Foo, Decl(index.ts, 0, 6)) + +import { x } from "foo/Bar"; +>x : Symbol(x, Decl(index.ts, 1, 8)) + +=== /node_modules/foo/Foo.d.ts === +export default class Foo { +>Foo : Symbol(Foo, Decl(Foo.d.ts, 0, 0)) + + protected source: boolean; +>source : Symbol(Foo.source, Decl(Foo.d.ts, 0, 26)) +} + +=== /node_modules/foo/Bar.d.ts === +// This is *not* the same! +export const x: number; +>x : Symbol(x, Decl(Bar.d.ts, 1, 12)) + diff --git a/tests/baselines/reference/duplicatePackage_packageIdIncludesSubModule.types b/tests/baselines/reference/duplicatePackage_packageIdIncludesSubModule.types new file mode 100644 index 00000000000..8b0501d46c3 --- /dev/null +++ b/tests/baselines/reference/duplicatePackage_packageIdIncludesSubModule.types @@ -0,0 +1,20 @@ +=== /index.ts === +import Foo from "foo/Foo"; +>Foo : typeof Foo + +import { x } from "foo/Bar"; +>x : number + +=== /node_modules/foo/Foo.d.ts === +export default class Foo { +>Foo : Foo + + protected source: boolean; +>source : boolean +} + +=== /node_modules/foo/Bar.d.ts === +// This is *not* the same! +export const x: number; +>x : number + diff --git a/tests/baselines/reference/duplicatePackage_referenceTypes.js b/tests/baselines/reference/duplicatePackage_referenceTypes.js new file mode 100644 index 00000000000..2abd8090e07 --- /dev/null +++ b/tests/baselines/reference/duplicatePackage_referenceTypes.js @@ -0,0 +1,31 @@ +//// [tests/cases/compiler/duplicatePackage_referenceTypes.ts] //// + +//// [index.d.ts] +/// +import { Foo } from "foo"; +export const foo: Foo; + +//// [index.d.ts] +export class Foo { private x; } + +//// [package.json] +{ "name": "foo", "version": "1.2.3" } + +//// [index.d.ts] +export class Foo { private x; } + +//// [package.json] +{ "name": "foo", "version": "1.2.3" } + +//// [index.ts] +import * as a from "a"; +import { Foo } from "foo"; + +let foo: Foo = a.foo; + + +//// [index.js] +"use strict"; +exports.__esModule = true; +var a = require("a"); +var foo = a.foo; diff --git a/tests/baselines/reference/duplicatePackage_referenceTypes.symbols b/tests/baselines/reference/duplicatePackage_referenceTypes.symbols new file mode 100644 index 00000000000..164da1c61d0 --- /dev/null +++ b/tests/baselines/reference/duplicatePackage_referenceTypes.symbols @@ -0,0 +1,33 @@ +=== /index.ts === +import * as a from "a"; +>a : Symbol(a, Decl(index.ts, 0, 6)) + +import { Foo } from "foo"; +>Foo : Symbol(Foo, Decl(index.ts, 1, 8)) + +let foo: Foo = a.foo; +>foo : Symbol(foo, Decl(index.ts, 3, 3)) +>Foo : Symbol(Foo, Decl(index.ts, 1, 8)) +>a.foo : Symbol(a.foo, Decl(index.d.ts, 2, 12)) +>a : Symbol(a, Decl(index.ts, 0, 6)) +>foo : Symbol(a.foo, Decl(index.d.ts, 2, 12)) + +=== /node_modules/a/index.d.ts === +/// +import { Foo } from "foo"; +>Foo : Symbol(Foo, Decl(index.d.ts, 1, 8)) + +export const foo: Foo; +>foo : Symbol(foo, Decl(index.d.ts, 2, 12)) +>Foo : Symbol(Foo, Decl(index.d.ts, 1, 8)) + +=== /node_modules/a/node_modules/foo/index.d.ts === +export class Foo { private x; } +>Foo : Symbol(Foo, Decl(index.d.ts, 0, 0)) +>x : Symbol(Foo.x, Decl(index.d.ts, 0, 18)) + +=== /node_modules/@types/foo/index.d.ts === +export class Foo { private x; } +>Foo : Symbol(Foo, Decl(index.d.ts, 0, 0)) +>x : Symbol(Foo.x, Decl(index.d.ts, 0, 18)) + diff --git a/tests/baselines/reference/duplicatePackage_referenceTypes.types b/tests/baselines/reference/duplicatePackage_referenceTypes.types new file mode 100644 index 00000000000..b7159e299f0 --- /dev/null +++ b/tests/baselines/reference/duplicatePackage_referenceTypes.types @@ -0,0 +1,33 @@ +=== /index.ts === +import * as a from "a"; +>a : typeof a + +import { Foo } from "foo"; +>Foo : typeof Foo + +let foo: Foo = a.foo; +>foo : Foo +>Foo : Foo +>a.foo : Foo +>a : typeof a +>foo : Foo + +=== /node_modules/a/index.d.ts === +/// +import { Foo } from "foo"; +>Foo : typeof Foo + +export const foo: Foo; +>foo : Foo +>Foo : Foo + +=== /node_modules/a/node_modules/foo/index.d.ts === +export class Foo { private x; } +>Foo : Foo +>x : any + +=== /node_modules/@types/foo/index.d.ts === +export class Foo { private x; } +>Foo : Foo +>x : any + diff --git a/tests/baselines/reference/duplicatePackage_subModule.js b/tests/baselines/reference/duplicatePackage_subModule.js new file mode 100644 index 00000000000..0a5793a79a2 --- /dev/null +++ b/tests/baselines/reference/duplicatePackage_subModule.js @@ -0,0 +1,34 @@ +//// [tests/cases/compiler/duplicatePackage_subModule.ts] //// + +//// [index.d.ts] +import Foo from "foo/Foo"; +export const o: Foo; + +//// [Foo.d.ts] +export default class Foo { + protected source: boolean; +} + +//// [package.json] +{ "name": "foo", "version": "1.2.3" } + +//// [Foo.d.ts] +export default class Foo { + protected source: boolean; +} + +//// [package.json] +{ "name": "foo", "version": "1.2.3" } + +//// [index.ts] +import Foo from "foo/Foo"; +import * as a from "a"; + +const o: Foo = a.o; + + +//// [index.js] +"use strict"; +exports.__esModule = true; +var a = require("a"); +var o = a.o; diff --git a/tests/baselines/reference/duplicatePackage_subModule.symbols b/tests/baselines/reference/duplicatePackage_subModule.symbols new file mode 100644 index 00000000000..538cd0d827d --- /dev/null +++ b/tests/baselines/reference/duplicatePackage_subModule.symbols @@ -0,0 +1,38 @@ +=== /index.ts === +import Foo from "foo/Foo"; +>Foo : Symbol(Foo, Decl(index.ts, 0, 6)) + +import * as a from "a"; +>a : Symbol(a, Decl(index.ts, 1, 6)) + +const o: Foo = a.o; +>o : Symbol(o, Decl(index.ts, 3, 5)) +>Foo : Symbol(Foo, Decl(index.ts, 0, 6)) +>a.o : Symbol(a.o, Decl(index.d.ts, 1, 12)) +>a : Symbol(a, Decl(index.ts, 1, 6)) +>o : Symbol(a.o, Decl(index.d.ts, 1, 12)) + +=== /node_modules/a/index.d.ts === +import Foo from "foo/Foo"; +>Foo : Symbol(Foo, Decl(index.d.ts, 0, 6)) + +export const o: Foo; +>o : Symbol(o, Decl(index.d.ts, 1, 12)) +>Foo : Symbol(Foo, Decl(index.d.ts, 0, 6)) + +=== /node_modules/a/node_modules/foo/Foo.d.ts === +export default class Foo { +>Foo : Symbol(Foo, Decl(Foo.d.ts, 0, 0)) + + protected source: boolean; +>source : Symbol(Foo.source, Decl(Foo.d.ts, 0, 26)) +} + +=== /node_modules/foo/Foo.d.ts === +export default class Foo { +>Foo : Symbol(Foo, Decl(Foo.d.ts, 0, 0)) + + protected source: boolean; +>source : Symbol(Foo.source, Decl(Foo.d.ts, 0, 26)) +} + diff --git a/tests/baselines/reference/duplicatePackage_subModule.types b/tests/baselines/reference/duplicatePackage_subModule.types new file mode 100644 index 00000000000..047f16d37ab --- /dev/null +++ b/tests/baselines/reference/duplicatePackage_subModule.types @@ -0,0 +1,38 @@ +=== /index.ts === +import Foo from "foo/Foo"; +>Foo : typeof Foo + +import * as a from "a"; +>a : typeof a + +const o: Foo = a.o; +>o : Foo +>Foo : Foo +>a.o : Foo +>a : typeof a +>o : Foo + +=== /node_modules/a/index.d.ts === +import Foo from "foo/Foo"; +>Foo : typeof Foo + +export const o: Foo; +>o : Foo +>Foo : Foo + +=== /node_modules/a/node_modules/foo/Foo.d.ts === +export default class Foo { +>Foo : Foo + + protected source: boolean; +>source : boolean +} + +=== /node_modules/foo/Foo.d.ts === +export default class Foo { +>Foo : Foo + + protected source: boolean; +>source : boolean +} + diff --git a/tests/baselines/reference/library-reference-11.trace.json b/tests/baselines/reference/library-reference-11.trace.json index 053dc497065..ef99bb8912f 100644 --- a/tests/baselines/reference/library-reference-11.trace.json +++ b/tests/baselines/reference/library-reference-11.trace.json @@ -3,8 +3,8 @@ "Root directory cannot be determined, skipping primary search paths.", "Looking up in 'node_modules' folder, initial location '/a/b'.", "Directory '/a/b/node_modules' does not exist, skipping all lookups in it.", - "File '/a/node_modules/jquery.d.ts' does not exist.", "Found 'package.json' at '/a/node_modules/jquery/package.json'.", + "File '/a/node_modules/jquery.d.ts' does not exist.", "'package.json' has 'typings' field 'jquery.d.ts' that references '/a/node_modules/jquery/jquery.d.ts'.", "File '/a/node_modules/jquery/jquery.d.ts' exist - use it as a name resolution result.", "Resolving real path for '/a/node_modules/jquery/jquery.d.ts', result '/a/node_modules/jquery/jquery.d.ts'.", diff --git a/tests/baselines/reference/library-reference-12.trace.json b/tests/baselines/reference/library-reference-12.trace.json index d990709cac8..22b1232d30b 100644 --- a/tests/baselines/reference/library-reference-12.trace.json +++ b/tests/baselines/reference/library-reference-12.trace.json @@ -3,8 +3,8 @@ "Root directory cannot be determined, skipping primary search paths.", "Looking up in 'node_modules' folder, initial location '/a/b'.", "Directory '/a/b/node_modules' does not exist, skipping all lookups in it.", - "File '/a/node_modules/jquery.d.ts' does not exist.", "Found 'package.json' at '/a/node_modules/jquery/package.json'.", + "File '/a/node_modules/jquery.d.ts' does not exist.", "'package.json' does not have a 'typings' field.", "'package.json' has 'types' field 'dist/jquery.d.ts' that references '/a/node_modules/jquery/dist/jquery.d.ts'.", "File '/a/node_modules/jquery/dist/jquery.d.ts' exist - use it as a name resolution result.", diff --git a/tests/baselines/reference/library-reference-3.trace.json b/tests/baselines/reference/library-reference-3.trace.json index 22747738c10..5b084f13738 100644 --- a/tests/baselines/reference/library-reference-3.trace.json +++ b/tests/baselines/reference/library-reference-3.trace.json @@ -2,8 +2,8 @@ "======== Resolving type reference directive 'jquery', containing file '/src/consumer.ts', root directory not set. ========", "Root directory cannot be determined, skipping primary search paths.", "Looking up in 'node_modules' folder, initial location '/src'.", - "File '/src/node_modules/jquery.d.ts' does not exist.", "File '/src/node_modules/jquery/package.json' does not exist.", + "File '/src/node_modules/jquery.d.ts' does not exist.", "File '/src/node_modules/jquery/index.d.ts' exist - use it as a name resolution result.", "Resolving real path for '/src/node_modules/jquery/index.d.ts', result '/src/node_modules/jquery/index.d.ts'.", "======== Type reference directive 'jquery' was successfully resolved to '/src/node_modules/jquery/index.d.ts', primary: false. ========" diff --git a/tests/baselines/reference/library-reference-4.trace.json b/tests/baselines/reference/library-reference-4.trace.json index 03fdfa0e863..ceeb754bb0b 100644 --- a/tests/baselines/reference/library-reference-4.trace.json +++ b/tests/baselines/reference/library-reference-4.trace.json @@ -3,8 +3,8 @@ "Resolving with primary search path '/src'.", "Looking up in 'node_modules' folder, initial location '/src'.", "Directory '/src/node_modules' does not exist, skipping all lookups in it.", - "File '/node_modules/foo.d.ts' does not exist.", "File '/node_modules/foo/package.json' does not exist.", + "File '/node_modules/foo.d.ts' does not exist.", "File '/node_modules/foo/index.d.ts' exist - use it as a name resolution result.", "Resolving real path for '/node_modules/foo/index.d.ts', result '/node_modules/foo/index.d.ts'.", "======== Type reference directive 'foo' was successfully resolved to '/node_modules/foo/index.d.ts', primary: false. ========", @@ -12,24 +12,24 @@ "Resolving with primary search path '/src'.", "Looking up in 'node_modules' folder, initial location '/src'.", "Directory '/src/node_modules' does not exist, skipping all lookups in it.", - "File '/node_modules/bar.d.ts' does not exist.", "File '/node_modules/bar/package.json' does not exist.", + "File '/node_modules/bar.d.ts' does not exist.", "File '/node_modules/bar/index.d.ts' exist - use it as a name resolution result.", "Resolving real path for '/node_modules/bar/index.d.ts', result '/node_modules/bar/index.d.ts'.", "======== Type reference directive 'bar' was successfully resolved to '/node_modules/bar/index.d.ts', primary: false. ========", "======== Resolving type reference directive 'alpha', containing file '/node_modules/foo/index.d.ts', root directory '/src'. ========", "Resolving with primary search path '/src'.", "Looking up in 'node_modules' folder, initial location '/node_modules/foo'.", - "File '/node_modules/foo/node_modules/alpha.d.ts' does not exist.", "File '/node_modules/foo/node_modules/alpha/package.json' does not exist.", + "File '/node_modules/foo/node_modules/alpha.d.ts' does not exist.", "File '/node_modules/foo/node_modules/alpha/index.d.ts' exist - use it as a name resolution result.", "Resolving real path for '/node_modules/foo/node_modules/alpha/index.d.ts', result '/node_modules/foo/node_modules/alpha/index.d.ts'.", "======== Type reference directive 'alpha' was successfully resolved to '/node_modules/foo/node_modules/alpha/index.d.ts', primary: false. ========", "======== Resolving type reference directive 'alpha', containing file '/node_modules/bar/index.d.ts', root directory '/src'. ========", "Resolving with primary search path '/src'.", "Looking up in 'node_modules' folder, initial location '/node_modules/bar'.", - "File '/node_modules/bar/node_modules/alpha.d.ts' does not exist.", "File '/node_modules/bar/node_modules/alpha/package.json' does not exist.", + "File '/node_modules/bar/node_modules/alpha.d.ts' does not exist.", "File '/node_modules/bar/node_modules/alpha/index.d.ts' exist - use it as a name resolution result.", "Resolving real path for '/node_modules/bar/node_modules/alpha/index.d.ts', result '/node_modules/bar/node_modules/alpha/index.d.ts'.", "======== Type reference directive 'alpha' was successfully resolved to '/node_modules/bar/node_modules/alpha/index.d.ts', primary: false. ========" diff --git a/tests/baselines/reference/library-reference-5.trace.json b/tests/baselines/reference/library-reference-5.trace.json index cb14078670a..0cac2a8fec6 100644 --- a/tests/baselines/reference/library-reference-5.trace.json +++ b/tests/baselines/reference/library-reference-5.trace.json @@ -4,8 +4,8 @@ "Directory 'types' does not exist, skipping all lookups in it.", "Looking up in 'node_modules' folder, initial location '/src'.", "Directory '/src/node_modules' does not exist, skipping all lookups in it.", - "File '/node_modules/foo.d.ts' does not exist.", "File '/node_modules/foo/package.json' does not exist.", + "File '/node_modules/foo.d.ts' does not exist.", "File '/node_modules/foo/index.d.ts' exist - use it as a name resolution result.", "Resolving real path for '/node_modules/foo/index.d.ts', result '/node_modules/foo/index.d.ts'.", "======== Type reference directive 'foo' was successfully resolved to '/node_modules/foo/index.d.ts', primary: false. ========", @@ -14,8 +14,8 @@ "Directory 'types' does not exist, skipping all lookups in it.", "Looking up in 'node_modules' folder, initial location '/src'.", "Directory '/src/node_modules' does not exist, skipping all lookups in it.", - "File '/node_modules/bar.d.ts' does not exist.", "File '/node_modules/bar/package.json' does not exist.", + "File '/node_modules/bar.d.ts' does not exist.", "File '/node_modules/bar/index.d.ts' exist - use it as a name resolution result.", "Resolving real path for '/node_modules/bar/index.d.ts', result '/node_modules/bar/index.d.ts'.", "======== Type reference directive 'bar' was successfully resolved to '/node_modules/bar/index.d.ts', primary: false. ========", @@ -23,8 +23,8 @@ "Resolving with primary search path 'types'.", "Directory 'types' does not exist, skipping all lookups in it.", "Looking up in 'node_modules' folder, initial location '/node_modules/foo'.", - "File '/node_modules/foo/node_modules/alpha.d.ts' does not exist.", "File '/node_modules/foo/node_modules/alpha/package.json' does not exist.", + "File '/node_modules/foo/node_modules/alpha.d.ts' does not exist.", "File '/node_modules/foo/node_modules/alpha/index.d.ts' exist - use it as a name resolution result.", "Resolving real path for '/node_modules/foo/node_modules/alpha/index.d.ts', result '/node_modules/foo/node_modules/alpha/index.d.ts'.", "======== Type reference directive 'alpha' was successfully resolved to '/node_modules/foo/node_modules/alpha/index.d.ts', primary: false. ========", @@ -32,8 +32,8 @@ "Resolving with primary search path 'types'.", "Directory 'types' does not exist, skipping all lookups in it.", "Looking up in 'node_modules' folder, initial location '/node_modules/bar'.", - "File '/node_modules/bar/node_modules/alpha.d.ts' does not exist.", "File '/node_modules/bar/node_modules/alpha/package.json' does not exist.", + "File '/node_modules/bar/node_modules/alpha.d.ts' does not exist.", "File '/node_modules/bar/node_modules/alpha/index.d.ts' exist - use it as a name resolution result.", "Resolving real path for '/node_modules/bar/node_modules/alpha/index.d.ts', result '/node_modules/bar/node_modules/alpha/index.d.ts'.", "======== Type reference directive 'alpha' was successfully resolved to '/node_modules/bar/node_modules/alpha/index.d.ts', primary: false. ========" diff --git a/tests/baselines/reference/library-reference-7.trace.json b/tests/baselines/reference/library-reference-7.trace.json index 22747738c10..5b084f13738 100644 --- a/tests/baselines/reference/library-reference-7.trace.json +++ b/tests/baselines/reference/library-reference-7.trace.json @@ -2,8 +2,8 @@ "======== Resolving type reference directive 'jquery', containing file '/src/consumer.ts', root directory not set. ========", "Root directory cannot be determined, skipping primary search paths.", "Looking up in 'node_modules' folder, initial location '/src'.", - "File '/src/node_modules/jquery.d.ts' does not exist.", "File '/src/node_modules/jquery/package.json' does not exist.", + "File '/src/node_modules/jquery.d.ts' does not exist.", "File '/src/node_modules/jquery/index.d.ts' exist - use it as a name resolution result.", "Resolving real path for '/src/node_modules/jquery/index.d.ts', result '/src/node_modules/jquery/index.d.ts'.", "======== Type reference directive 'jquery' was successfully resolved to '/src/node_modules/jquery/index.d.ts', primary: false. ========" diff --git a/tests/baselines/reference/library-reference-scoped-packages.trace.json b/tests/baselines/reference/library-reference-scoped-packages.trace.json index 54dcf95fe50..cfc88198201 100644 --- a/tests/baselines/reference/library-reference-scoped-packages.trace.json +++ b/tests/baselines/reference/library-reference-scoped-packages.trace.json @@ -4,8 +4,8 @@ "Directory 'types/@beep' does not exist, skipping all lookups in it.", "Looking up in 'node_modules' folder, initial location '/'.", "Scoped package detected, looking in 'beep__boop'", - "File '/node_modules/@types/beep__boop.d.ts' does not exist.", "File '/node_modules/@types/beep__boop/package.json' does not exist.", + "File '/node_modules/@types/beep__boop.d.ts' does not exist.", "File '/node_modules/@types/beep__boop/index.d.ts' exist - use it as a name resolution result.", "Resolving real path for '/node_modules/@types/beep__boop/index.d.ts', result '/node_modules/@types/beep__boop/index.d.ts'.", "======== Type reference directive '@beep/boop' was successfully resolved to '/node_modules/@types/beep__boop/index.d.ts', primary: false. ========" diff --git a/tests/baselines/reference/maxNodeModuleJsDepthDefaultsToZero.trace.json b/tests/baselines/reference/maxNodeModuleJsDepthDefaultsToZero.trace.json index 46f03d1e8c4..56bbee705bf 100644 --- a/tests/baselines/reference/maxNodeModuleJsDepthDefaultsToZero.trace.json +++ b/tests/baselines/reference/maxNodeModuleJsDepthDefaultsToZero.trace.json @@ -2,18 +2,18 @@ "======== Resolving module 'shortid' from '/index.ts'. ========", "Explicitly specified module resolution kind: 'NodeJs'.", "Loading module 'shortid' from 'node_modules' folder, target file type 'TypeScript'.", + "File '/node_modules/shortid/package.json' does not exist.", "File '/node_modules/shortid.ts' does not exist.", "File '/node_modules/shortid.tsx' does not exist.", "File '/node_modules/shortid.d.ts' does not exist.", - "File '/node_modules/shortid/package.json' does not exist.", "File '/node_modules/shortid/index.ts' does not exist.", "File '/node_modules/shortid/index.tsx' does not exist.", "File '/node_modules/shortid/index.d.ts' does not exist.", "Directory '/node_modules/@types' does not exist, skipping all lookups in it.", "Loading module 'shortid' from 'node_modules' folder, target file type 'JavaScript'.", + "File '/node_modules/shortid/package.json' does not exist.", "File '/node_modules/shortid.js' does not exist.", "File '/node_modules/shortid.jsx' does not exist.", - "File '/node_modules/shortid/package.json' does not exist.", "File '/node_modules/shortid/index.js' exist - use it as a name resolution result.", "Resolving real path for '/node_modules/shortid/index.js', result '/node_modules/shortid/index.js'.", "======== Module name 'shortid' was successfully resolved to '/node_modules/shortid/index.js'. ========" diff --git a/tests/baselines/reference/moduleResolutionWithExtensions_unexpected.trace.json b/tests/baselines/reference/moduleResolutionWithExtensions_unexpected.trace.json index 8c820e07e48..b619535487b 100644 --- a/tests/baselines/reference/moduleResolutionWithExtensions_unexpected.trace.json +++ b/tests/baselines/reference/moduleResolutionWithExtensions_unexpected.trace.json @@ -2,10 +2,10 @@ "======== Resolving module 'normalize.css' from '/a.ts'. ========", "Module resolution kind is not specified, using 'NodeJs'.", "Loading module 'normalize.css' from 'node_modules' folder, target file type 'TypeScript'.", + "Found 'package.json' at '/node_modules/normalize.css/package.json'.", "File '/node_modules/normalize.css.ts' does not exist.", "File '/node_modules/normalize.css.tsx' does not exist.", "File '/node_modules/normalize.css.d.ts' does not exist.", - "Found 'package.json' at '/node_modules/normalize.css/package.json'.", "'package.json' does not have a 'typings' field.", "'package.json' does not have a 'types' field.", "File '/node_modules/normalize.css/index.ts' does not exist.", @@ -13,9 +13,9 @@ "File '/node_modules/normalize.css/index.d.ts' does not exist.", "Directory '/node_modules/@types' does not exist, skipping all lookups in it.", "Loading module 'normalize.css' from 'node_modules' folder, target file type 'JavaScript'.", + "Found 'package.json' at '/node_modules/normalize.css/package.json'.", "File '/node_modules/normalize.css.js' does not exist.", "File '/node_modules/normalize.css.jsx' does not exist.", - "Found 'package.json' at '/node_modules/normalize.css/package.json'.", "'package.json' has 'main' field 'normalize.css' that references '/node_modules/normalize.css/normalize.css'.", "File '/node_modules/normalize.css/normalize.css' exist - use it as a name resolution result.", "File '/node_modules/normalize.css/normalize.css' has an unsupported extension, so skipping it.", diff --git a/tests/baselines/reference/moduleResolutionWithExtensions_unexpected2.trace.json b/tests/baselines/reference/moduleResolutionWithExtensions_unexpected2.trace.json index 3632a5c2242..50e7fa685a6 100644 --- a/tests/baselines/reference/moduleResolutionWithExtensions_unexpected2.trace.json +++ b/tests/baselines/reference/moduleResolutionWithExtensions_unexpected2.trace.json @@ -2,10 +2,10 @@ "======== Resolving module 'foo' from '/a.ts'. ========", "Module resolution kind is not specified, using 'NodeJs'.", "Loading module 'foo' from 'node_modules' folder, target file type 'TypeScript'.", + "Found 'package.json' at '/node_modules/foo/package.json'.", "File '/node_modules/foo.ts' does not exist.", "File '/node_modules/foo.tsx' does not exist.", "File '/node_modules/foo.d.ts' does not exist.", - "Found 'package.json' at '/node_modules/foo/package.json'.", "'package.json' does not have a 'typings' field.", "'package.json' has 'types' field 'foo.js' that references '/node_modules/foo/foo.js'.", "File '/node_modules/foo/foo.js' exist - use it as a name resolution result.", @@ -24,9 +24,9 @@ "File '/node_modules/foo/index.d.ts' does not exist.", "Directory '/node_modules/@types' does not exist, skipping all lookups in it.", "Loading module 'foo' from 'node_modules' folder, target file type 'JavaScript'.", + "Found 'package.json' at '/node_modules/foo/package.json'.", "File '/node_modules/foo.js' does not exist.", "File '/node_modules/foo.jsx' does not exist.", - "Found 'package.json' at '/node_modules/foo/package.json'.", "'package.json' does not have a 'main' field.", "File '/node_modules/foo/index.js' does not exist.", "File '/node_modules/foo/index.jsx' does not exist.", diff --git a/tests/baselines/reference/moduleResolutionWithExtensions_withAmbientPresent.trace.json b/tests/baselines/reference/moduleResolutionWithExtensions_withAmbientPresent.trace.json index 6cfdb8b567e..9a0d5e095a5 100644 --- a/tests/baselines/reference/moduleResolutionWithExtensions_withAmbientPresent.trace.json +++ b/tests/baselines/reference/moduleResolutionWithExtensions_withAmbientPresent.trace.json @@ -2,18 +2,18 @@ "======== Resolving module 'js' from '/a.ts'. ========", "Module resolution kind is not specified, using 'NodeJs'.", "Loading module 'js' from 'node_modules' folder, target file type 'TypeScript'.", + "File '/node_modules/js/package.json' does not exist.", "File '/node_modules/js.ts' does not exist.", "File '/node_modules/js.tsx' does not exist.", "File '/node_modules/js.d.ts' does not exist.", - "File '/node_modules/js/package.json' does not exist.", "File '/node_modules/js/index.ts' does not exist.", "File '/node_modules/js/index.tsx' does not exist.", "File '/node_modules/js/index.d.ts' does not exist.", "Directory '/node_modules/@types' does not exist, skipping all lookups in it.", "Loading module 'js' from 'node_modules' folder, target file type 'JavaScript'.", + "File '/node_modules/js/package.json' does not exist.", "File '/node_modules/js.js' does not exist.", "File '/node_modules/js.jsx' does not exist.", - "File '/node_modules/js/package.json' does not exist.", "File '/node_modules/js/index.js' exist - use it as a name resolution result.", "Resolving real path for '/node_modules/js/index.js', result '/node_modules/js/index.js'.", "======== Module name 'js' was successfully resolved to '/node_modules/js/index.js'. ========" diff --git a/tests/baselines/reference/moduleResolutionWithSymlinks.trace.json b/tests/baselines/reference/moduleResolutionWithSymlinks.trace.json index 2dd33953680..19e44e72d61 100644 --- a/tests/baselines/reference/moduleResolutionWithSymlinks.trace.json +++ b/tests/baselines/reference/moduleResolutionWithSymlinks.trace.json @@ -20,10 +20,10 @@ "======== Resolving module 'library-a' from '/src/library-b/index.ts'. ========", "Module resolution kind is not specified, using 'NodeJs'.", "Loading module 'library-a' from 'node_modules' folder, target file type 'TypeScript'.", + "File '/src/library-b/node_modules/library-a/package.json' does not exist.", "File '/src/library-b/node_modules/library-a.ts' does not exist.", "File '/src/library-b/node_modules/library-a.tsx' does not exist.", "File '/src/library-b/node_modules/library-a.d.ts' does not exist.", - "File '/src/library-b/node_modules/library-a/package.json' does not exist.", "File '/src/library-b/node_modules/library-a/index.ts' exist - use it as a name resolution result.", "Resolving real path for '/src/library-b/node_modules/library-a/index.ts', result '/src/library-a/index.ts'.", "======== Module name 'library-a' was successfully resolved to '/src/library-a/index.ts'. ========" diff --git a/tests/baselines/reference/moduleResolutionWithSymlinks_preserveSymlinks.trace.json b/tests/baselines/reference/moduleResolutionWithSymlinks_preserveSymlinks.trace.json index 837b740ffee..73e6a1df996 100644 --- a/tests/baselines/reference/moduleResolutionWithSymlinks_preserveSymlinks.trace.json +++ b/tests/baselines/reference/moduleResolutionWithSymlinks_preserveSymlinks.trace.json @@ -2,18 +2,18 @@ "======== Resolving type reference directive 'linked', containing file '/app/app.ts', root directory not set. ========", "Root directory cannot be determined, skipping primary search paths.", "Looking up in 'node_modules' folder, initial location '/app'.", - "File '/app/node_modules/linked.d.ts' does not exist.", "File '/app/node_modules/linked/package.json' does not exist.", + "File '/app/node_modules/linked.d.ts' does not exist.", "File '/app/node_modules/linked/index.d.ts' exist - use it as a name resolution result.", "======== Type reference directive 'linked' was successfully resolved to '/app/node_modules/linked/index.d.ts', primary: false. ========", "======== Resolving module 'real' from '/app/node_modules/linked/index.d.ts'. ========", "Explicitly specified module resolution kind: 'NodeJs'.", "Loading module 'real' from 'node_modules' folder, target file type 'TypeScript'.", "Directory '/app/node_modules/linked/node_modules' does not exist, skipping all lookups in it.", + "File '/app/node_modules/real/package.json' does not exist.", "File '/app/node_modules/real.ts' does not exist.", "File '/app/node_modules/real.tsx' does not exist.", "File '/app/node_modules/real.d.ts' does not exist.", - "File '/app/node_modules/real/package.json' does not exist.", "File '/app/node_modules/real/index.ts' does not exist.", "File '/app/node_modules/real/index.tsx' does not exist.", "File '/app/node_modules/real/index.d.ts' exist - use it as a name resolution result.", @@ -21,10 +21,10 @@ "======== Resolving module 'linked' from '/app/app.ts'. ========", "Explicitly specified module resolution kind: 'NodeJs'.", "Loading module 'linked' from 'node_modules' folder, target file type 'TypeScript'.", + "File '/app/node_modules/linked/package.json' does not exist.", "File '/app/node_modules/linked.ts' does not exist.", "File '/app/node_modules/linked.tsx' does not exist.", "File '/app/node_modules/linked.d.ts' does not exist.", - "File '/app/node_modules/linked/package.json' does not exist.", "File '/app/node_modules/linked/index.ts' does not exist.", "File '/app/node_modules/linked/index.tsx' does not exist.", "File '/app/node_modules/linked/index.d.ts' exist - use it as a name resolution result.", @@ -32,10 +32,10 @@ "======== Resolving module 'linked2' from '/app/app.ts'. ========", "Explicitly specified module resolution kind: 'NodeJs'.", "Loading module 'linked2' from 'node_modules' folder, target file type 'TypeScript'.", + "File '/app/node_modules/linked2/package.json' does not exist.", "File '/app/node_modules/linked2.ts' does not exist.", "File '/app/node_modules/linked2.tsx' does not exist.", "File '/app/node_modules/linked2.d.ts' does not exist.", - "File '/app/node_modules/linked2/package.json' does not exist.", "File '/app/node_modules/linked2/index.ts' does not exist.", "File '/app/node_modules/linked2/index.tsx' does not exist.", "File '/app/node_modules/linked2/index.d.ts' exist - use it as a name resolution result.", @@ -44,10 +44,10 @@ "Explicitly specified module resolution kind: 'NodeJs'.", "Loading module 'real' from 'node_modules' folder, target file type 'TypeScript'.", "Directory '/app/node_modules/linked2/node_modules' does not exist, skipping all lookups in it.", + "File '/app/node_modules/real/package.json' does not exist.", "File '/app/node_modules/real.ts' does not exist.", "File '/app/node_modules/real.tsx' does not exist.", "File '/app/node_modules/real.d.ts' does not exist.", - "File '/app/node_modules/real/package.json' does not exist.", "File '/app/node_modules/real/index.ts' does not exist.", "File '/app/node_modules/real/index.tsx' does not exist.", "File '/app/node_modules/real/index.d.ts' exist - use it as a name resolution result.", diff --git a/tests/baselines/reference/moduleResolutionWithSymlinks_referenceTypes.trace.json b/tests/baselines/reference/moduleResolutionWithSymlinks_referenceTypes.trace.json index 65d89ed7458..48be1a4cda8 100644 --- a/tests/baselines/reference/moduleResolutionWithSymlinks_referenceTypes.trace.json +++ b/tests/baselines/reference/moduleResolutionWithSymlinks_referenceTypes.trace.json @@ -3,8 +3,8 @@ "Root directory cannot be determined, skipping primary search paths.", "Looking up in 'node_modules' folder, initial location '/'.", "File '/node_modules/library-a.d.ts' does not exist.", - "File '/node_modules/@types/library-a.d.ts' does not exist.", "File '/node_modules/@types/library-a/package.json' does not exist.", + "File '/node_modules/@types/library-a.d.ts' does not exist.", "File '/node_modules/@types/library-a/index.d.ts' exist - use it as a name resolution result.", "Resolving real path for '/node_modules/@types/library-a/index.d.ts', result '/node_modules/@types/library-a/index.d.ts'.", "======== Type reference directive 'library-a' was successfully resolved to '/node_modules/@types/library-a/index.d.ts', primary: false. ========", @@ -12,8 +12,8 @@ "Root directory cannot be determined, skipping primary search paths.", "Looking up in 'node_modules' folder, initial location '/'.", "File '/node_modules/library-b.d.ts' does not exist.", - "File '/node_modules/@types/library-b.d.ts' does not exist.", "File '/node_modules/@types/library-b/package.json' does not exist.", + "File '/node_modules/@types/library-b.d.ts' does not exist.", "File '/node_modules/@types/library-b/index.d.ts' exist - use it as a name resolution result.", "Resolving real path for '/node_modules/@types/library-b/index.d.ts', result '/node_modules/@types/library-b/index.d.ts'.", "======== Type reference directive 'library-b' was successfully resolved to '/node_modules/@types/library-b/index.d.ts', primary: false. ========", @@ -21,8 +21,8 @@ "Root directory cannot be determined, skipping primary search paths.", "Looking up in 'node_modules' folder, initial location '/node_modules/@types/library-b'.", "File '/node_modules/@types/library-b/node_modules/library-a.d.ts' does not exist.", - "File '/node_modules/@types/library-b/node_modules/@types/library-a.d.ts' does not exist.", "File '/node_modules/@types/library-b/node_modules/@types/library-a/package.json' does not exist.", + "File '/node_modules/@types/library-b/node_modules/@types/library-a.d.ts' does not exist.", "File '/node_modules/@types/library-b/node_modules/@types/library-a/index.d.ts' exist - use it as a name resolution result.", "Resolving real path for '/node_modules/@types/library-b/node_modules/@types/library-a/index.d.ts', result '/node_modules/@types/library-a/index.d.ts'.", "======== Type reference directive 'library-a' was successfully resolved to '/node_modules/@types/library-a/index.d.ts', primary: false. ========" diff --git a/tests/baselines/reference/moduleResolutionWithSymlinks_withOutDir.trace.json b/tests/baselines/reference/moduleResolutionWithSymlinks_withOutDir.trace.json index 2dd33953680..19e44e72d61 100644 --- a/tests/baselines/reference/moduleResolutionWithSymlinks_withOutDir.trace.json +++ b/tests/baselines/reference/moduleResolutionWithSymlinks_withOutDir.trace.json @@ -20,10 +20,10 @@ "======== Resolving module 'library-a' from '/src/library-b/index.ts'. ========", "Module resolution kind is not specified, using 'NodeJs'.", "Loading module 'library-a' from 'node_modules' folder, target file type 'TypeScript'.", + "File '/src/library-b/node_modules/library-a/package.json' does not exist.", "File '/src/library-b/node_modules/library-a.ts' does not exist.", "File '/src/library-b/node_modules/library-a.tsx' does not exist.", "File '/src/library-b/node_modules/library-a.d.ts' does not exist.", - "File '/src/library-b/node_modules/library-a/package.json' does not exist.", "File '/src/library-b/node_modules/library-a/index.ts' exist - use it as a name resolution result.", "Resolving real path for '/src/library-b/node_modules/library-a/index.ts', result '/src/library-a/index.ts'.", "======== Module name 'library-a' was successfully resolved to '/src/library-a/index.ts'. ========" diff --git a/tests/baselines/reference/packageJsonMain.trace.json b/tests/baselines/reference/packageJsonMain.trace.json index 08daccbe479..842f70c3a02 100644 --- a/tests/baselines/reference/packageJsonMain.trace.json +++ b/tests/baselines/reference/packageJsonMain.trace.json @@ -2,10 +2,10 @@ "======== Resolving module 'foo' from '/a.ts'. ========", "Module resolution kind is not specified, using 'NodeJs'.", "Loading module 'foo' from 'node_modules' folder, target file type 'TypeScript'.", + "Found 'package.json' at '/node_modules/foo/package.json'.", "File '/node_modules/foo.ts' does not exist.", "File '/node_modules/foo.tsx' does not exist.", "File '/node_modules/foo.d.ts' does not exist.", - "Found 'package.json' at '/node_modules/foo/package.json'.", "'package.json' does not have a 'typings' field.", "'package.json' does not have a 'types' field.", "File '/node_modules/foo/index.ts' does not exist.", @@ -13,9 +13,9 @@ "File '/node_modules/foo/index.d.ts' does not exist.", "Directory '/node_modules/@types' does not exist, skipping all lookups in it.", "Loading module 'foo' from 'node_modules' folder, target file type 'JavaScript'.", + "Found 'package.json' at '/node_modules/foo/package.json'.", "File '/node_modules/foo.js' does not exist.", "File '/node_modules/foo.jsx' does not exist.", - "Found 'package.json' at '/node_modules/foo/package.json'.", "'package.json' has 'main' field 'oof' that references '/node_modules/foo/oof'.", "File '/node_modules/foo/oof' does not exist.", "Loading module as file / folder, candidate module location '/node_modules/foo/oof', target file type 'JavaScript'.", @@ -25,10 +25,10 @@ "======== Resolving module 'bar' from '/a.ts'. ========", "Module resolution kind is not specified, using 'NodeJs'.", "Loading module 'bar' from 'node_modules' folder, target file type 'TypeScript'.", + "Found 'package.json' at '/node_modules/bar/package.json'.", "File '/node_modules/bar.ts' does not exist.", "File '/node_modules/bar.tsx' does not exist.", "File '/node_modules/bar.d.ts' does not exist.", - "Found 'package.json' at '/node_modules/bar/package.json'.", "'package.json' does not have a 'typings' field.", "'package.json' does not have a 'types' field.", "File '/node_modules/bar/index.ts' does not exist.", @@ -36,9 +36,9 @@ "File '/node_modules/bar/index.d.ts' does not exist.", "Directory '/node_modules/@types' does not exist, skipping all lookups in it.", "Loading module 'bar' from 'node_modules' folder, target file type 'JavaScript'.", + "Found 'package.json' at '/node_modules/bar/package.json'.", "File '/node_modules/bar.js' does not exist.", "File '/node_modules/bar.jsx' does not exist.", - "Found 'package.json' at '/node_modules/bar/package.json'.", "'package.json' has 'main' field 'rab.js' that references '/node_modules/bar/rab.js'.", "File '/node_modules/bar/rab.js' exist - use it as a name resolution result.", "Resolving real path for '/node_modules/bar/rab.js', result '/node_modules/bar/rab.js'.", @@ -46,10 +46,10 @@ "======== Resolving module 'baz' from '/a.ts'. ========", "Module resolution kind is not specified, using 'NodeJs'.", "Loading module 'baz' from 'node_modules' folder, target file type 'TypeScript'.", + "Found 'package.json' at '/node_modules/baz/package.json'.", "File '/node_modules/baz.ts' does not exist.", "File '/node_modules/baz.tsx' does not exist.", "File '/node_modules/baz.d.ts' does not exist.", - "Found 'package.json' at '/node_modules/baz/package.json'.", "'package.json' does not have a 'typings' field.", "'package.json' does not have a 'types' field.", "File '/node_modules/baz/index.ts' does not exist.", @@ -57,9 +57,9 @@ "File '/node_modules/baz/index.d.ts' does not exist.", "Directory '/node_modules/@types' does not exist, skipping all lookups in it.", "Loading module 'baz' from 'node_modules' folder, target file type 'JavaScript'.", + "Found 'package.json' at '/node_modules/baz/package.json'.", "File '/node_modules/baz.js' does not exist.", "File '/node_modules/baz.jsx' does not exist.", - "Found 'package.json' at '/node_modules/baz/package.json'.", "'package.json' has 'main' field 'zab' that references '/node_modules/baz/zab'.", "File '/node_modules/baz/zab' does not exist.", "Loading module as file / folder, candidate module location '/node_modules/baz/zab', target file type 'JavaScript'.", diff --git a/tests/baselines/reference/packageJsonMain_isNonRecursive.trace.json b/tests/baselines/reference/packageJsonMain_isNonRecursive.trace.json index 53e1ad25605..763c86730ba 100644 --- a/tests/baselines/reference/packageJsonMain_isNonRecursive.trace.json +++ b/tests/baselines/reference/packageJsonMain_isNonRecursive.trace.json @@ -2,10 +2,10 @@ "======== Resolving module 'foo' from '/a.ts'. ========", "Module resolution kind is not specified, using 'NodeJs'.", "Loading module 'foo' from 'node_modules' folder, target file type 'TypeScript'.", + "Found 'package.json' at '/node_modules/foo/package.json'.", "File '/node_modules/foo.ts' does not exist.", "File '/node_modules/foo.tsx' does not exist.", "File '/node_modules/foo.d.ts' does not exist.", - "Found 'package.json' at '/node_modules/foo/package.json'.", "'package.json' does not have a 'typings' field.", "'package.json' does not have a 'types' field.", "File '/node_modules/foo/index.ts' does not exist.", @@ -13,9 +13,9 @@ "File '/node_modules/foo/index.d.ts' does not exist.", "Directory '/node_modules/@types' does not exist, skipping all lookups in it.", "Loading module 'foo' from 'node_modules' folder, target file type 'JavaScript'.", + "Found 'package.json' at '/node_modules/foo/package.json'.", "File '/node_modules/foo.js' does not exist.", "File '/node_modules/foo.jsx' does not exist.", - "Found 'package.json' at '/node_modules/foo/package.json'.", "'package.json' has 'main' field 'oof' that references '/node_modules/foo/oof'.", "File '/node_modules/foo/oof' does not exist.", "Loading module as file / folder, candidate module location '/node_modules/foo/oof', target file type 'JavaScript'.", diff --git a/tests/baselines/reference/pathMappingBasedModuleResolution3_node.trace.json b/tests/baselines/reference/pathMappingBasedModuleResolution3_node.trace.json index 6ac06e1dda1..ef2cb3b367f 100644 --- a/tests/baselines/reference/pathMappingBasedModuleResolution3_node.trace.json +++ b/tests/baselines/reference/pathMappingBasedModuleResolution3_node.trace.json @@ -23,10 +23,10 @@ "Loading module 'file4' from 'node_modules' folder, target file type 'TypeScript'.", "Directory 'c:/root/folder2/node_modules' does not exist, skipping all lookups in it.", "Directory 'c:/root/node_modules' does not exist, skipping all lookups in it.", + "File 'c:/node_modules/file4/package.json' does not exist.", "File 'c:/node_modules/file4.ts' does not exist.", "File 'c:/node_modules/file4.tsx' does not exist.", "File 'c:/node_modules/file4.d.ts' does not exist.", - "File 'c:/node_modules/file4/package.json' does not exist.", "File 'c:/node_modules/file4/index.ts' does not exist.", "File 'c:/node_modules/file4/index.tsx' does not exist.", "File 'c:/node_modules/file4/index.d.ts' exist - use it as a name resolution result.", diff --git a/tests/baselines/reference/pathMappingBasedModuleResolution4_node.trace.json b/tests/baselines/reference/pathMappingBasedModuleResolution4_node.trace.json index 6ac06e1dda1..ef2cb3b367f 100644 --- a/tests/baselines/reference/pathMappingBasedModuleResolution4_node.trace.json +++ b/tests/baselines/reference/pathMappingBasedModuleResolution4_node.trace.json @@ -23,10 +23,10 @@ "Loading module 'file4' from 'node_modules' folder, target file type 'TypeScript'.", "Directory 'c:/root/folder2/node_modules' does not exist, skipping all lookups in it.", "Directory 'c:/root/node_modules' does not exist, skipping all lookups in it.", + "File 'c:/node_modules/file4/package.json' does not exist.", "File 'c:/node_modules/file4.ts' does not exist.", "File 'c:/node_modules/file4.tsx' does not exist.", "File 'c:/node_modules/file4.d.ts' does not exist.", - "File 'c:/node_modules/file4/package.json' does not exist.", "File 'c:/node_modules/file4/index.ts' does not exist.", "File 'c:/node_modules/file4/index.tsx' does not exist.", "File 'c:/node_modules/file4/index.d.ts' exist - use it as a name resolution result.", diff --git a/tests/baselines/reference/scopedPackages.trace.json b/tests/baselines/reference/scopedPackages.trace.json index 20df3bec172..a2b8af48266 100644 --- a/tests/baselines/reference/scopedPackages.trace.json +++ b/tests/baselines/reference/scopedPackages.trace.json @@ -2,10 +2,10 @@ "======== Resolving module '@cow/boy' from '/a.ts'. ========", "Module resolution kind is not specified, using 'NodeJs'.", "Loading module '@cow/boy' from 'node_modules' folder, target file type 'TypeScript'.", + "File '/node_modules/@cow/package.json' does not exist.", "File '/node_modules/@cow/boy.ts' does not exist.", "File '/node_modules/@cow/boy.tsx' does not exist.", "File '/node_modules/@cow/boy.d.ts' does not exist.", - "File '/node_modules/@cow/boy/package.json' does not exist.", "File '/node_modules/@cow/boy/index.ts' does not exist.", "File '/node_modules/@cow/boy/index.tsx' does not exist.", "File '/node_modules/@cow/boy/index.d.ts' exist - use it as a name resolution result.", @@ -15,8 +15,8 @@ "Module resolution kind is not specified, using 'NodeJs'.", "Loading module '@be/bop' from 'node_modules' folder, target file type 'TypeScript'.", "Scoped package detected, looking in 'be__bop'", - "File '/node_modules/@types/be__bop.d.ts' does not exist.", "File '/node_modules/@types/be__bop/package.json' does not exist.", + "File '/node_modules/@types/be__bop.d.ts' does not exist.", "File '/node_modules/@types/be__bop/index.d.ts' exist - use it as a name resolution result.", "Resolving real path for '/node_modules/@types/be__bop/index.d.ts', result '/node_modules/@types/be__bop/index.d.ts'.", "======== Module name '@be/bop' was successfully resolved to '/node_modules/@types/be__bop/index.d.ts'. ========", @@ -24,6 +24,7 @@ "Module resolution kind is not specified, using 'NodeJs'.", "Loading module '@be/bop/e/z' from 'node_modules' folder, target file type 'TypeScript'.", "Scoped package detected, looking in 'be__bop/e/z'", + "File '/node_modules/@types/be__bop/package.json' does not exist.", "File '/node_modules/@types/be__bop/e/z.d.ts' exist - use it as a name resolution result.", "Resolving real path for '/node_modules/@types/be__bop/e/z.d.ts', result '/node_modules/@types/be__bop/e/z.d.ts'.", "======== Module name '@be/bop/e/z' was successfully resolved to '/node_modules/@types/be__bop/e/z.d.ts'. ========" diff --git a/tests/baselines/reference/scopedPackagesClassic.trace.json b/tests/baselines/reference/scopedPackagesClassic.trace.json index c58c7d2ed10..b28156d1c33 100644 --- a/tests/baselines/reference/scopedPackagesClassic.trace.json +++ b/tests/baselines/reference/scopedPackagesClassic.trace.json @@ -2,8 +2,8 @@ "======== Resolving module '@see/saw' from '/a.ts'. ========", "Explicitly specified module resolution kind: 'Classic'.", "Scoped package detected, looking in 'see__saw'", - "File '/node_modules/@types/see__saw.d.ts' does not exist.", "File '/node_modules/@types/see__saw/package.json' does not exist.", + "File '/node_modules/@types/see__saw.d.ts' does not exist.", "File '/node_modules/@types/see__saw/index.d.ts' exist - use it as a name resolution result.", "======== Module name '@see/saw' was successfully resolved to '/node_modules/@types/see__saw/index.d.ts'. ========" ] \ No newline at end of file diff --git a/tests/baselines/reference/typingsLookup4.trace.json b/tests/baselines/reference/typingsLookup4.trace.json index d2087308d8e..133ea49c22a 100644 --- a/tests/baselines/reference/typingsLookup4.trace.json +++ b/tests/baselines/reference/typingsLookup4.trace.json @@ -5,8 +5,8 @@ "File '/node_modules/jquery.ts' does not exist.", "File '/node_modules/jquery.tsx' does not exist.", "File '/node_modules/jquery.d.ts' does not exist.", - "File '/node_modules/@types/jquery.d.ts' does not exist.", "Found 'package.json' at '/node_modules/@types/jquery/package.json'.", + "File '/node_modules/@types/jquery.d.ts' does not exist.", "'package.json' has 'typings' field 'jquery.d.ts' that references '/node_modules/@types/jquery/jquery.d.ts'.", "File '/node_modules/@types/jquery/jquery.d.ts' exist - use it as a name resolution result.", "Resolving real path for '/node_modules/@types/jquery/jquery.d.ts', result '/node_modules/@types/jquery/jquery.d.ts'.", @@ -17,8 +17,8 @@ "File '/node_modules/kquery.ts' does not exist.", "File '/node_modules/kquery.tsx' does not exist.", "File '/node_modules/kquery.d.ts' does not exist.", - "File '/node_modules/@types/kquery.d.ts' does not exist.", "Found 'package.json' at '/node_modules/@types/kquery/package.json'.", + "File '/node_modules/@types/kquery.d.ts' does not exist.", "'package.json' has 'typings' field 'kquery' that references '/node_modules/@types/kquery/kquery'.", "File '/node_modules/@types/kquery/kquery' does not exist.", "Loading module as file / folder, candidate module location '/node_modules/@types/kquery/kquery', target file type 'TypeScript'.", @@ -33,8 +33,8 @@ "File '/node_modules/lquery.ts' does not exist.", "File '/node_modules/lquery.tsx' does not exist.", "File '/node_modules/lquery.d.ts' does not exist.", - "File '/node_modules/@types/lquery.d.ts' does not exist.", "Found 'package.json' at '/node_modules/@types/lquery/package.json'.", + "File '/node_modules/@types/lquery.d.ts' does not exist.", "'package.json' has 'typings' field 'lquery' that references '/node_modules/@types/lquery/lquery'.", "File '/node_modules/@types/lquery/lquery' does not exist.", "Loading module as file / folder, candidate module location '/node_modules/@types/lquery/lquery', target file type 'TypeScript'.", @@ -47,8 +47,8 @@ "File '/node_modules/mquery.ts' does not exist.", "File '/node_modules/mquery.tsx' does not exist.", "File '/node_modules/mquery.d.ts' does not exist.", - "File '/node_modules/@types/mquery.d.ts' does not exist.", "Found 'package.json' at '/node_modules/@types/mquery/package.json'.", + "File '/node_modules/@types/mquery.d.ts' does not exist.", "'package.json' has 'typings' field 'mquery' that references '/node_modules/@types/mquery/mquery'.", "File '/node_modules/@types/mquery/mquery' does not exist.", "Loading module as file / folder, candidate module location '/node_modules/@types/mquery/mquery', target file type 'TypeScript'.", diff --git a/tests/baselines/reference/typingsLookupAmd.trace.json b/tests/baselines/reference/typingsLookupAmd.trace.json index ca64cf8fdf4..f18f63e7597 100644 --- a/tests/baselines/reference/typingsLookupAmd.trace.json +++ b/tests/baselines/reference/typingsLookupAmd.trace.json @@ -11,8 +11,8 @@ "File '/b.tsx' does not exist.", "File '/b.d.ts' does not exist.", "Directory '/x/y/node_modules' does not exist, skipping all lookups in it.", - "File '/x/node_modules/@types/b.d.ts' does not exist.", "File '/x/node_modules/@types/b/package.json' does not exist.", + "File '/x/node_modules/@types/b.d.ts' does not exist.", "File '/x/node_modules/@types/b/index.d.ts' exist - use it as a name resolution result.", "======== Module name 'b' was successfully resolved to '/x/node_modules/@types/b/index.d.ts'. ========", "======== Resolving module 'a' from '/x/node_modules/@types/b/index.d.ts'. ========", @@ -35,8 +35,8 @@ "Directory '/x/node_modules/@types/b/node_modules' does not exist, skipping all lookups in it.", "Directory '/x/node_modules/@types/node_modules' does not exist, skipping all lookups in it.", "File '/x/node_modules/@types/a.d.ts' does not exist.", - "File '/node_modules/@types/a.d.ts' does not exist.", "File '/node_modules/@types/a/package.json' does not exist.", + "File '/node_modules/@types/a.d.ts' does not exist.", "File '/node_modules/@types/a/index.d.ts' exist - use it as a name resolution result.", "======== Module name 'a' was successfully resolved to '/node_modules/@types/a/index.d.ts'. ========", "======== Resolving type reference directive 'a', containing file '/__inferred type names__.ts', root directory '/node_modules/@types'. ========", diff --git a/tests/cases/compiler/duplicatePackage_packageIdIncludesSubModule.ts b/tests/cases/compiler/duplicatePackage_packageIdIncludesSubModule.ts new file mode 100644 index 00000000000..19f56ed1325 --- /dev/null +++ b/tests/cases/compiler/duplicatePackage_packageIdIncludesSubModule.ts @@ -0,0 +1,17 @@ +// @noImplicitReferences: true + +// @Filename: /node_modules/foo/Foo.d.ts +export default class Foo { + protected source: boolean; +} + +// @Filename: /node_modules/foo/Bar.d.ts +// This is *not* the same! +export const x: number; + +// @Filename: /node_modules/foo/package.json +{ "name": "foo", "version": "1.2.3" } + +// @Filename: /index.ts +import Foo from "foo/Foo"; +import { x } from "foo/Bar"; diff --git a/tests/cases/compiler/duplicatePackage_referenceTypes.ts b/tests/cases/compiler/duplicatePackage_referenceTypes.ts new file mode 100644 index 00000000000..c6534fff70c --- /dev/null +++ b/tests/cases/compiler/duplicatePackage_referenceTypes.ts @@ -0,0 +1,24 @@ +// @noImplicitReferences: true + +// @Filename: /node_modules/a/index.d.ts +/// +import { Foo } from "foo"; +export const foo: Foo; + +// @Filename: /node_modules/a/node_modules/foo/index.d.ts +export class Foo { private x; } + +// @Filename: /node_modules/a/node_modules/foo/package.json +{ "name": "foo", "version": "1.2.3" } + +// @Filename: /node_modules/@types/foo/index.d.ts +export class Foo { private x; } + +// @Filename: /node_modules/@types/foo/package.json +{ "name": "foo", "version": "1.2.3" } + +// @Filename: /index.ts +import * as a from "a"; +import { Foo } from "foo"; + +let foo: Foo = a.foo; diff --git a/tests/cases/compiler/duplicatePackage_subModule.ts b/tests/cases/compiler/duplicatePackage_subModule.ts new file mode 100644 index 00000000000..4c704772eaf --- /dev/null +++ b/tests/cases/compiler/duplicatePackage_subModule.ts @@ -0,0 +1,27 @@ +// @noImplicitReferences: true + +// @Filename: /node_modules/a/index.d.ts +import Foo from "foo/Foo"; +export const o: Foo; + +// @Filename: /node_modules/a/node_modules/foo/Foo.d.ts +export default class Foo { + protected source: boolean; +} + +// @Filename: /node_modules/a/node_modules/foo/package.json +{ "name": "foo", "version": "1.2.3" } + +// @Filename: /node_modules/foo/Foo.d.ts +export default class Foo { + protected source: boolean; +} + +// @Filename: /node_modules/foo/package.json +{ "name": "foo", "version": "1.2.3" } + +// @Filename: /index.ts +import Foo from "foo/Foo"; +import * as a from "a"; + +const o: Foo = a.o; From 0e50da62c47368e7141301d0cf4e9cc105497ef2 Mon Sep 17 00:00:00 2001 From: Andrew Casey Date: Wed, 30 Aug 2017 13:11:21 -0700 Subject: [PATCH 267/370] Handle the combination of a write and a void return When the return type is void, there's no `returnValueProperty`, but that doesn't mean we don't need a `return` at the call site. Fixes #18140. --- src/harness/unittests/extractMethods.ts | 7 +++++ src/services/refactors/extractMethod.ts | 4 +++ .../extractMethod/extractMethod21.ts | 26 +++++++++++++++++++ 3 files changed, 37 insertions(+) create mode 100644 tests/baselines/reference/extractMethod/extractMethod21.ts diff --git a/src/harness/unittests/extractMethods.ts b/src/harness/unittests/extractMethods.ts index c8b4b35ff1c..6fe57895725 100644 --- a/src/harness/unittests/extractMethods.ts +++ b/src/harness/unittests/extractMethods.ts @@ -613,6 +613,13 @@ namespace A { [#|let a1 = { x: 1 }; return a1.x + 10;|] } +}`); + // Write + void return + testExtractMethod("extractMethod21", + `function foo() { + let x = 10; + [#|x++; + return;|] }`); }); diff --git a/src/services/refactors/extractMethod.ts b/src/services/refactors/extractMethod.ts index 25a995dc231..c497b126759 100644 --- a/src/services/refactors/extractMethod.ts +++ b/src/services/refactors/extractMethod.ts @@ -748,6 +748,10 @@ namespace ts.refactor.extractMethod { } else { newNodes.push(createStatement(createBinary(assignments[0].name, SyntaxKind.EqualsToken, call))); + + if (range.facts & RangeFacts.HasReturn) { + newNodes.push(createReturn()); + } } } else { diff --git a/tests/baselines/reference/extractMethod/extractMethod21.ts b/tests/baselines/reference/extractMethod/extractMethod21.ts new file mode 100644 index 00000000000..4b73a6ed3c7 --- /dev/null +++ b/tests/baselines/reference/extractMethod/extractMethod21.ts @@ -0,0 +1,26 @@ +// ==ORIGINAL== +function foo() { + let x = 10; + x++; + return; +} +// ==SCOPE::function 'foo'== +function foo() { + let x = 10; + return newFunction(); + + function newFunction() { + x++; + return; + } +} +// ==SCOPE::global scope== +function foo() { + let x = 10; + x = newFunction(x); + return; +} +function newFunction(x: number) { + x++; + return x; +} From 27f9cdb1aec60c60ed2af52c2e4f470f6ee7dcbe Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Thu, 7 Sep 2017 15:54:24 -0700 Subject: [PATCH 268/370] Explicitly avoid canonicalizing paths during configuration handling (#18316) * Explicitly avoid canonicalizing paths during configuration handling * Extract usage of identity in commandLineParser into single function, use identity in checker --- src/compiler/checker.ts | 5 +---- src/compiler/commandLineParser.ts | 12 +++++++++--- src/compiler/core.ts | 3 +++ 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 1b05b69ef52..9c72a064b11 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -58,6 +58,7 @@ namespace ts { let symbolInstantiationDepth = 0; const emptySymbols = createSymbolTable(); + const identityMapper: (type: Type) => Type = identity; const compilerOptions = host.getCompilerOptions(); const languageVersion = getEmitScriptTarget(compilerOptions); @@ -8119,10 +8120,6 @@ namespace ts { mapper; } - function identityMapper(type: Type): Type { - return type; - } - function combineTypeMappers(mapper1: TypeMapper, mapper2: TypeMapper): TypeMapper { return t => instantiateType(mapper1(t), mapper2); } diff --git a/src/compiler/commandLineParser.ts b/src/compiler/commandLineParser.ts index dc9c2ad35ed..54e5ee1d01d 100644 --- a/src/compiler/commandLineParser.ts +++ b/src/compiler/commandLineParser.ts @@ -1385,6 +1385,12 @@ namespace ts { return x === undefined || x === null; } + function directoryOfCombinedPath(fileName: string, basePath: string) { + // Use the `identity` function to avoid canonicalizing the path, as it must remain noncanonical + // until consistient casing errors are reported + return getDirectoryPath(toPath(fileName, basePath, identity)); + } + /** * Parse the contents of a config file from json or json source file (tsconfig.json). * @param json The contents of the config file to parse @@ -1467,7 +1473,7 @@ namespace ts { includeSpecs = ["**/*"]; } - const result = matchFileNames(fileNames, includeSpecs, excludeSpecs, configFileName ? getDirectoryPath(toPath(configFileName, basePath, createGetCanonicalFileName(host.useCaseSensitiveFileNames))) : basePath, options, host, errors, extraFileExtensions, sourceFile); + const result = matchFileNames(fileNames, includeSpecs, excludeSpecs, configFileName ? directoryOfCombinedPath(configFileName, basePath) : basePath, options, host, errors, extraFileExtensions, sourceFile); if (result.fileNames.length === 0 && !hasProperty(raw, "files") && resolutionStack.length === 0) { errors.push( @@ -1577,7 +1583,7 @@ namespace ts { errors.push(createCompilerDiagnostic(Diagnostics.Compiler_option_0_requires_a_value_of_type_1, "extends", "string")); } else { - const newBase = configFileName ? getDirectoryPath(toPath(configFileName, basePath, getCanonicalFileName)) : basePath; + const newBase = configFileName ? directoryOfCombinedPath(configFileName, basePath) : basePath; extendedConfigPath = getExtendsConfigPath(json.extends, host, newBase, getCanonicalFileName, errors, createCompilerDiagnostic); } } @@ -1610,7 +1616,7 @@ namespace ts { onSetValidOptionKeyValueInRoot(key: string, _keyNode: PropertyName, value: CompilerOptionsValue, valueNode: Expression) { switch (key) { case "extends": - const newBase = configFileName ? getDirectoryPath(toPath(configFileName, basePath, getCanonicalFileName)) : basePath; + const newBase = configFileName ? directoryOfCombinedPath(configFileName, basePath) : basePath; extendedConfigPath = getExtendsConfigPath( value, host, diff --git a/src/compiler/core.ts b/src/compiler/core.ts index 8ad12a14011..f5e2a4069e4 100644 --- a/src/compiler/core.ts +++ b/src/compiler/core.ts @@ -1228,6 +1228,9 @@ namespace ts { /** Does nothing. */ export function noop(): void {} + /** Returns its argument. */ + export function identity(x: T) { return x; } + /** Throws an error because a function is not implemented. */ export function notImplemented(): never { throw new Error("Not implemented"); From 4885560cb4a12c41f172c1bfdeedea806400b3e3 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Thu, 7 Sep 2017 16:02:00 -0700 Subject: [PATCH 269/370] Eliminate intersections of unit types in union types --- src/compiler/checker.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 91653c140c8..379bc3377d2 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -7302,7 +7302,11 @@ namespace ts { if (flags & TypeFlags.Null) typeSet.containsNull = true; if (!(flags & TypeFlags.ContainsWideningType)) typeSet.containsNonWideningType = true; } - else if (!(flags & TypeFlags.Never)) { + else if (!(flags & TypeFlags.Never || flags & TypeFlags.Intersection && every((type).types, isUnitType))) { + // We ignore 'never' types in unions. Likewise, we ignore intersections of unit types as they are + // another form of 'never' (in that they have an empty value domain). We could in theory turn + // intersections of unit types into 'never' upon construction, but deferring the reduction makes it + // easier to reason about their origin. if (flags & TypeFlags.String) typeSet.containsString = true; if (flags & TypeFlags.Number) typeSet.containsNumber = true; if (flags & TypeFlags.StringOrNumberLiteral) typeSet.containsStringOrNumberLiteral = true; From 9d11fbb9b9c4e7fbbc4a54d1b95d41e28e13ea42 Mon Sep 17 00:00:00 2001 From: Andrew Casey Date: Wed, 30 Aug 2017 13:25:35 -0700 Subject: [PATCH 270/370] Correct permitted jumps check --- src/services/refactors/extractMethod.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/services/refactors/extractMethod.ts b/src/services/refactors/extractMethod.ts index c497b126759..e4fd0e85dc2 100644 --- a/src/services/refactors/extractMethod.ts +++ b/src/services/refactors/extractMethod.ts @@ -417,7 +417,7 @@ namespace ts.refactor.extractMethod { } } else { - if (!(permittedJumps & (SyntaxKind.BreakStatement ? PermittedJumps.Break : PermittedJumps.Continue))) { + if (!(permittedJumps & (node.kind === SyntaxKind.BreakStatement ? PermittedJumps.Break : PermittedJumps.Continue))) { // attempt to break or continue in a forbidden context (errors || (errors = [])).push(createDiagnosticForNode(node, Messages.CannotExtractRangeContainingConditionalBreakOrContinueStatements)); } From a81fa7a801c7eff1865bcc2cd451bfc618ce832b Mon Sep 17 00:00:00 2001 From: Andrew Casey Date: Wed, 30 Aug 2017 13:55:18 -0700 Subject: [PATCH 271/370] Make permittedJumps a parameter to eliminate save-restore pattern --- src/services/refactors/extractMethod.ts | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/services/refactors/extractMethod.ts b/src/services/refactors/extractMethod.ts index e4fd0e85dc2..b73613350a8 100644 --- a/src/services/refactors/extractMethod.ts +++ b/src/services/refactors/extractMethod.ts @@ -293,14 +293,13 @@ namespace ts.refactor.extractMethod { } let errors: Diagnostic[]; - let permittedJumps = PermittedJumps.Return; let seenLabels: Array<__String>; - visit(nodeToCheck); + visit(nodeToCheck, PermittedJumps.Return); return errors; - function visit(node: Node) { + function visit(node: Node, permittedJumps: PermittedJumps) { if (errors) { // already found an error - can stop now return true; @@ -351,7 +350,6 @@ namespace ts.refactor.extractMethod { // do not dive into functions or classes return false; } - const savedPermittedJumps = permittedJumps; if (node.parent) { switch (node.parent.kind) { case SyntaxKind.IfStatement: @@ -402,7 +400,7 @@ namespace ts.refactor.extractMethod { { const label = (node).label; (seenLabels || (seenLabels = [])).push(label.escapedText); - forEachChild(node, visit); + forEachChild(node, child => visit(child, permittedJumps)); seenLabels.pop(); break; } @@ -439,11 +437,10 @@ namespace ts.refactor.extractMethod { } break; default: - forEachChild(node, visit); + forEachChild(node, child => visit(child, permittedJumps)); break; } - permittedJumps = savedPermittedJumps; } } } From e3808b65d4291c982cba374d336d65b1be87fae2 Mon Sep 17 00:00:00 2001 From: Andrew Casey Date: Wed, 30 Aug 2017 14:23:11 -0700 Subject: [PATCH 272/370] Simplify and correct PermittedJumps computation 1. It was looking at the parent which wasn't guaranteed to be in the extracted range. 2. It was checking direct, rather than indirect containment - apparently to avoid applying the rules to certain expressions (which can't contain jumps anyway, unless they're in anonymous functions, in which case they're fine). Fixes #18144 --- src/harness/unittests/extractMethods.ts | 35 ++++++++++ src/services/refactors/extractMethod.ts | 64 ++++++++----------- .../extractMethod/extractMethod22.ts | 31 +++++++++ 3 files changed, 91 insertions(+), 39 deletions(-) create mode 100644 tests/baselines/reference/extractMethod/extractMethod22.ts diff --git a/src/harness/unittests/extractMethods.ts b/src/harness/unittests/extractMethods.ts index 6fe57895725..02ddbf4cae3 100644 --- a/src/harness/unittests/extractMethods.ts +++ b/src/harness/unittests/extractMethods.ts @@ -378,6 +378,32 @@ namespace A { "Cannot extract range containing conditional return statement." ]); + testExtractRangeFailed("extractRangeFailed7", + ` +function test(x: number) { + while (x) { + x--; + [#|break;|] + } +} + `, + [ + "Cannot extract range containing conditional break or continue statements." + ]); + + testExtractRangeFailed("extractRangeFailed8", + ` +function test(x: number) { + switch (x) { + case 1: + [#|break;|] + } +} + `, + [ + "Cannot extract range containing conditional break or continue statements." + ]); + testExtractMethod("extractMethod1", `namespace A { let x = 1; @@ -620,6 +646,15 @@ namespace A { let x = 10; [#|x++; return;|] +}`); + // Write + void return + testExtractMethod("extractMethod22", + `function test() { + try { + } + finally { + [#|return 1;|] + } }`); }); diff --git a/src/services/refactors/extractMethod.ts b/src/services/refactors/extractMethod.ts index b73613350a8..c0031f26cc8 100644 --- a/src/services/refactors/extractMethod.ts +++ b/src/services/refactors/extractMethod.ts @@ -350,45 +350,31 @@ namespace ts.refactor.extractMethod { // do not dive into functions or classes return false; } - if (node.parent) { - switch (node.parent.kind) { - case SyntaxKind.IfStatement: - if ((node.parent).thenStatement === node || (node.parent).elseStatement === node) { - // forbid all jumps inside thenStatement or elseStatement - permittedJumps = PermittedJumps.None; - } - break; - case SyntaxKind.TryStatement: - if ((node.parent).tryBlock === node) { - // forbid all jumps inside try blocks - permittedJumps = PermittedJumps.None; - } - else if ((node.parent).finallyBlock === node) { - // allow unconditional returns from finally blocks - permittedJumps = PermittedJumps.Return; - } - break; - case SyntaxKind.CatchClause: - if ((node.parent).block === node) { - // forbid all jumps inside the block of catch clause - permittedJumps = PermittedJumps.None; - } - break; - case SyntaxKind.CaseClause: - if ((node).expression !== node) { - // allow unlabeled break inside case clauses - permittedJumps |= PermittedJumps.Break; - } - break; - default: - if (isIterationStatement(node.parent, /*lookInLabeledStatements*/ false)) { - if ((node.parent).statement === node) { - // allow unlabeled break/continue inside loops - permittedJumps |= PermittedJumps.Break | PermittedJumps.Continue; - } - } - break; - } + + switch (node.kind) { + case SyntaxKind.IfStatement: + permittedJumps = PermittedJumps.None; + break; + case SyntaxKind.TryStatement: + // forbid all jumps inside try blocks + permittedJumps = PermittedJumps.None; + break; + case SyntaxKind.Block: + if (node.parent && node.parent.kind === SyntaxKind.TryStatement && (node).finallyBlock === node) { + // allow unconditional returns from finally blocks + permittedJumps = PermittedJumps.Return; + } + break; + case SyntaxKind.CaseClause: + // allow unlabeled break inside case clauses + permittedJumps |= PermittedJumps.Break; + break; + default: + if (isIterationStatement(node, /*lookInLabeledStatements*/ false)) { + // allow unlabeled break/continue inside loops + permittedJumps |= PermittedJumps.Break | PermittedJumps.Continue; + } + break; } switch (node.kind) { diff --git a/tests/baselines/reference/extractMethod/extractMethod22.ts b/tests/baselines/reference/extractMethod/extractMethod22.ts new file mode 100644 index 00000000000..7603c01681f --- /dev/null +++ b/tests/baselines/reference/extractMethod/extractMethod22.ts @@ -0,0 +1,31 @@ +// ==ORIGINAL== +function test() { + try { + } + finally { + return 1; + } +} +// ==SCOPE::function 'test'== +function test() { + try { + } + finally { + return newFunction(); + } + + function newFunction() { + return 1; + } +} +// ==SCOPE::global scope== +function test() { + try { + } + finally { + return newFunction(); + } +} +function newFunction() { + return 1; +} From 73bc0c9796ce2e294e8b0fa1a1dec46da1268187 Mon Sep 17 00:00:00 2001 From: Andrew Casey Date: Wed, 30 Aug 2017 14:36:20 -0700 Subject: [PATCH 273/370] Correct copied comment --- src/harness/unittests/extractMethods.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/harness/unittests/extractMethods.ts b/src/harness/unittests/extractMethods.ts index 02ddbf4cae3..75404d12bf0 100644 --- a/src/harness/unittests/extractMethods.ts +++ b/src/harness/unittests/extractMethods.ts @@ -647,7 +647,7 @@ function test(x: number) { [#|x++; return;|] }`); - // Write + void return + // Return in finally block testExtractMethod("extractMethod22", `function test() { try { From baefdd2ccb21542b7aeab8b6f825e45c516566da Mon Sep 17 00:00:00 2001 From: Andrew Casey Date: Thu, 7 Sep 2017 15:36:32 -0700 Subject: [PATCH 274/370] Revert "Make permittedJumps a parameter to eliminate save-restore pattern" This reverts commit 57906fe90e8efd2fb285fcb67f018c0438ba06dd. --- src/services/refactors/extractMethod.ts | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/services/refactors/extractMethod.ts b/src/services/refactors/extractMethod.ts index c0031f26cc8..83908def444 100644 --- a/src/services/refactors/extractMethod.ts +++ b/src/services/refactors/extractMethod.ts @@ -293,13 +293,14 @@ namespace ts.refactor.extractMethod { } let errors: Diagnostic[]; + let permittedJumps = PermittedJumps.Return; let seenLabels: Array<__String>; - visit(nodeToCheck, PermittedJumps.Return); + visit(nodeToCheck); return errors; - function visit(node: Node, permittedJumps: PermittedJumps) { + function visit(node: Node) { if (errors) { // already found an error - can stop now return true; @@ -350,6 +351,7 @@ namespace ts.refactor.extractMethod { // do not dive into functions or classes return false; } + const savedPermittedJumps = permittedJumps; switch (node.kind) { case SyntaxKind.IfStatement: @@ -386,7 +388,7 @@ namespace ts.refactor.extractMethod { { const label = (node).label; (seenLabels || (seenLabels = [])).push(label.escapedText); - forEachChild(node, child => visit(child, permittedJumps)); + forEachChild(node, visit); seenLabels.pop(); break; } @@ -423,10 +425,11 @@ namespace ts.refactor.extractMethod { } break; default: - forEachChild(node, child => visit(child, permittedJumps)); + forEachChild(node, visit); break; } + permittedJumps = savedPermittedJumps; } } } From 7aac67b9b4d42e4bdaa872c267465a268f0bd7a4 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Thu, 7 Sep 2017 16:22:16 -0700 Subject: [PATCH 275/370] Test: parsing of two-line @typedef jsdoc --- tests/baselines/reference/jsdocTwoLineTypedef.js | 10 ++++++++++ tests/baselines/reference/jsdocTwoLineTypedef.symbols | 9 +++++++++ tests/baselines/reference/jsdocTwoLineTypedef.types | 9 +++++++++ tests/cases/conformance/jsdoc/jsdocTwoLineTypedef.ts | 6 ++++++ 4 files changed, 34 insertions(+) create mode 100644 tests/baselines/reference/jsdocTwoLineTypedef.js create mode 100644 tests/baselines/reference/jsdocTwoLineTypedef.symbols create mode 100644 tests/baselines/reference/jsdocTwoLineTypedef.types create mode 100644 tests/cases/conformance/jsdoc/jsdocTwoLineTypedef.ts diff --git a/tests/baselines/reference/jsdocTwoLineTypedef.js b/tests/baselines/reference/jsdocTwoLineTypedef.js new file mode 100644 index 00000000000..b48d6a89a21 --- /dev/null +++ b/tests/baselines/reference/jsdocTwoLineTypedef.js @@ -0,0 +1,10 @@ +//// [jsdocTwoLineTypedef.ts] +// Regression from #18301 +/** + * @typedef LoadCallback + * @type {function} + */ +type LoadCallback = void; + + +//// [jsdocTwoLineTypedef.js] diff --git a/tests/baselines/reference/jsdocTwoLineTypedef.symbols b/tests/baselines/reference/jsdocTwoLineTypedef.symbols new file mode 100644 index 00000000000..80a69e5f52c --- /dev/null +++ b/tests/baselines/reference/jsdocTwoLineTypedef.symbols @@ -0,0 +1,9 @@ +=== tests/cases/conformance/jsdoc/jsdocTwoLineTypedef.ts === +// Regression from #18301 +/** + * @typedef LoadCallback + * @type {function} + */ +type LoadCallback = void; +>LoadCallback : Symbol(LoadCallback, Decl(jsdocTwoLineTypedef.ts, 0, 0)) + diff --git a/tests/baselines/reference/jsdocTwoLineTypedef.types b/tests/baselines/reference/jsdocTwoLineTypedef.types new file mode 100644 index 00000000000..5e0d05b3feb --- /dev/null +++ b/tests/baselines/reference/jsdocTwoLineTypedef.types @@ -0,0 +1,9 @@ +=== tests/cases/conformance/jsdoc/jsdocTwoLineTypedef.ts === +// Regression from #18301 +/** + * @typedef LoadCallback + * @type {function} + */ +type LoadCallback = void; +>LoadCallback : void + diff --git a/tests/cases/conformance/jsdoc/jsdocTwoLineTypedef.ts b/tests/cases/conformance/jsdoc/jsdocTwoLineTypedef.ts new file mode 100644 index 00000000000..2a7ad0d7dbf --- /dev/null +++ b/tests/cases/conformance/jsdoc/jsdocTwoLineTypedef.ts @@ -0,0 +1,6 @@ +// Regression from #18301 +/** + * @typedef LoadCallback + * @type {function} + */ +type LoadCallback = void; From fb5e8c611083c92f9744847957d2014d65025e6b Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Thu, 7 Sep 2017 16:37:13 -0700 Subject: [PATCH 276/370] Fix forEachChild's visit of JSDocTypedefTag Also remove JSDocTypeLiteral.jsdocTypeTag, which made no sense since it was only useful when storing information for its parent `@typedef` tag. --- src/compiler/parser.ts | 16 +++++++++------- src/compiler/types.ts | 1 - 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index b0782b6707a..f81254572b7 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -438,8 +438,10 @@ namespace ts { visitNode(cbNode, (node).typeExpression); } case SyntaxKind.JSDocTypeLiteral: - for (const tag of (node as JSDocTypeLiteral).jsDocPropertyTags) { - visitNode(cbNode, tag); + if ((node as JSDocTypeLiteral).jsDocPropertyTags) { + for (const tag of (node as JSDocTypeLiteral).jsDocPropertyTags) { + visitNode(cbNode, tag); + } } return; case SyntaxKind.PartiallyEmittedExpression: @@ -6672,19 +6674,18 @@ namespace ts { if (!typeExpression || isObjectOrObjectArrayTypeReference(typeExpression.type)) { let child: JSDocTypeTag | JSDocPropertyTag | false; let jsdocTypeLiteral: JSDocTypeLiteral; - let alreadyHasTypeTag = false; + let childTypeTag: JSDocTypeTag; const start = scanner.getStartPos(); while (child = tryParse(() => parseChildParameterOrPropertyTag(PropertyLikeParse.Property))) { if (!jsdocTypeLiteral) { jsdocTypeLiteral = createNode(SyntaxKind.JSDocTypeLiteral, start); } if (child.kind === SyntaxKind.JSDocTypeTag) { - if (alreadyHasTypeTag) { + if (childTypeTag) { break; } else { - jsdocTypeLiteral.jsDocTypeTag = child; - alreadyHasTypeTag = true; + childTypeTag = child; } } else { @@ -6698,7 +6699,8 @@ namespace ts { if (typeExpression && typeExpression.type.kind === SyntaxKind.ArrayType) { jsdocTypeLiteral.isArrayType = true; } - typedefTag.typeExpression = finishNode(jsdocTypeLiteral); + const useChildTypeTagAsType = childTypeTag && !isObjectOrObjectArrayTypeReference(childTypeTag.typeExpression.type); + typedefTag.typeExpression = useChildTypeTagAsType ? childTypeTag.typeExpression : finishNode(jsdocTypeLiteral); } } diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 55baf9763c2..3a3736a5ceb 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -2211,7 +2211,6 @@ namespace ts { export interface JSDocTypeLiteral extends JSDocType { kind: SyntaxKind.JSDocTypeLiteral; jsDocPropertyTags?: ReadonlyArray; - jsDocTypeTag?: JSDocTypeTag; /** If true, then this type literal represents an *array* of its type. */ isArrayType?: boolean; } From 7d5b5e957ece7c3062bfe7478ed760dd4ee6d389 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Thu, 7 Sep 2017 16:38:17 -0700 Subject: [PATCH 277/370] Update baselines --- ...sCorrectly.typedefTagWithChildrenTags.json | 32 ------------------- 1 file changed, 32 deletions(-) diff --git a/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.typedefTagWithChildrenTags.json b/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.typedefTagWithChildrenTags.json index f0e42ae6325..08d270286b9 100644 --- a/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.typedefTagWithChildrenTags.json +++ b/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.typedefTagWithChildrenTags.json @@ -34,38 +34,6 @@ "kind": "JSDocTypeLiteral", "pos": 26, "end": 98, - "jsDocTypeTag": { - "kind": "JSDocTypeTag", - "pos": 28, - "end": 42, - "atToken": { - "kind": "AtToken", - "pos": 28, - "end": 29 - }, - "tagName": { - "kind": "Identifier", - "pos": 29, - "end": 33, - "escapedText": "type" - }, - "typeExpression": { - "kind": "JSDocTypeExpression", - "pos": 34, - "end": 42, - "type": { - "kind": "TypeReference", - "pos": 35, - "end": 41, - "typeName": { - "kind": "Identifier", - "pos": 35, - "end": 41, - "escapedText": "Object" - } - } - } - }, "jsDocPropertyTags": [ { "kind": "JSDocPropertyTag", From 9eecf8ca56e504874e64e5a9fb221c7c78adeb5f Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Fri, 8 Sep 2017 06:35:14 -0700 Subject: [PATCH 278/370] Report error on first token of excessively large function or module body --- src/compiler/checker.ts | 21 +++++++++++++-------- src/compiler/diagnosticMessages.json | 2 +- src/compiler/utilities.ts | 5 +++++ 3 files changed, 19 insertions(+), 9 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index c3e3473e3f8..06e21e18501 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -11486,6 +11486,13 @@ namespace ts { return false; } + function reportFlowControlError(node: Node) { + const block = findAncestor(node, isFunctionOrModuleBlock); + const sourceFile = getSourceFileOfNode(node); + const span = getSpanOfTokenAtPosition(sourceFile, block.statements.pos); + diagnostics.add(createFileDiagnostic(sourceFile, span.start, span.length, Diagnostics.The_containing_function_or_module_body_is_too_large_for_control_flow_analysis)); + } + function getFlowTypeOfReference(reference: Node, declaredType: Type, initialType = declaredType, flowContainer?: Node, couldBeUninitialized?: boolean) { let key: string; let flowLength = 0; @@ -11509,15 +11516,15 @@ namespace ts { return resultType; function getTypeAtFlowNode(flow: FlowNode): FlowType { - const saveFlowLength = flowLength; + flowLength++; while (true) { flowLength++; - if (flowLength === 5000) { - // The length of this particular control flow path is 5000 nodes or more. Rather than spending an - // excessive amount of time and possibly overflowing the call stack, we report an error and disable - // further control flow analysis in the containing function or module body. + if (flowLength >= 5000) { + // We have visited as many as 5000 nodes through as many as 2500 recursive invocations. Rather than + // spending an excessive amount of time and possibly overflowing the call stack, we report an error + // and disable further control flow analysis in the containing function or module body. flowAnalysisDisabled = true; - error(reference, Diagnostics.The_body_of_the_containing_function_or_module_is_too_large_for_control_flow_analysis); + reportFlowControlError(reference); return unknownType; } const flags = flow.flags; @@ -11527,7 +11534,6 @@ namespace ts { // antecedent of more than one node. for (let i = visitedFlowStart; i < visitedFlowCount; i++) { if (visitedFlowNodes[i] === flow) { - flowLength = saveFlowLength; return visitedFlowTypes[i]; } } @@ -11595,7 +11601,6 @@ namespace ts { visitedFlowTypes[visitedFlowCount] = type; visitedFlowCount++; } - flowLength = saveFlowLength; return type; } } diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index b3668cc5acf..5cfa5f12731 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -1920,7 +1920,7 @@ "category": "Error", "code": 2562 }, - "The body of the containing function or module is too large for control flow analysis.": { + "The containing function or module body is too large for control flow analysis.": { "category": "Error", "code": 2563 }, diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index 2a07d2b6560..7c3dce15448 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -4790,6 +4790,11 @@ namespace ts { return false; } + /* @internal */ + export function isFunctionOrModuleBlock(node: Node): boolean { + return isSourceFile(node) || isModuleBlock(node) || isBlock(node) && isFunctionLike(node.parent); + } + // Classes export function isClassElement(node: Node): node is ClassElement { const kind = node.kind; From 4ee7d3aeb20949dc30108236310aaf4cd7c91613 Mon Sep 17 00:00:00 2001 From: Andy Date: Fri, 8 Sep 2017 07:18:37 -0700 Subject: [PATCH 279/370] Remove unnecessary check in emitNodeList (#18327) --- src/compiler/emitter.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index 5abeecd4107..8788e0c02f4 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -2415,7 +2415,7 @@ namespace ts { return; } - const isEmpty = isUndefined || children.length === 0 || start >= children.length || count === 0; + const isEmpty = isUndefined || start >= children.length || count === 0; if (isEmpty && format & ListFormat.OptionalIfEmpty) { return; } From cab05ddd3fe70661a3c30bf2a912a444e9d4be55 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Fri, 8 Sep 2017 08:33:17 -0700 Subject: [PATCH 280/370] Inline variable to aid control flow --- src/compiler/parser.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index f81254572b7..826f41d6bed 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -6699,8 +6699,9 @@ namespace ts { if (typeExpression && typeExpression.type.kind === SyntaxKind.ArrayType) { jsdocTypeLiteral.isArrayType = true; } - const useChildTypeTagAsType = childTypeTag && !isObjectOrObjectArrayTypeReference(childTypeTag.typeExpression.type); - typedefTag.typeExpression = useChildTypeTagAsType ? childTypeTag.typeExpression : finishNode(jsdocTypeLiteral); + typedefTag.typeExpression = childTypeTag && !isObjectOrObjectArrayTypeReference(childTypeTag.typeExpression.type) ? + childTypeTag.typeExpression : + finishNode(jsdocTypeLiteral); } } From 37d320d0c813298eac473a5678cd64947edeb391 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Fri, 8 Sep 2017 14:19:18 -0700 Subject: [PATCH 281/370] Rename visitedFlowXXX to sharedFlowXXX --- src/compiler/checker.ts | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 06e21e18501..521ce94ee3a 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -333,7 +333,7 @@ namespace ts { let flowLoopStart = 0; let flowLoopCount = 0; - let visitedFlowCount = 0; + let sharedFlowCount = 0; let flowAnalysisDisabled = false; const emptyStringType = getLiteralType(""); @@ -352,8 +352,8 @@ namespace ts { const flowLoopNodes: FlowNode[] = []; const flowLoopKeys: string[] = []; const flowLoopTypes: Type[][] = []; - const visitedFlowNodes: FlowNode[] = []; - const visitedFlowTypes: FlowType[] = []; + const sharedFlowNodes: FlowNode[] = []; + const sharedFlowTypes: FlowType[] = []; const potentialThisCollisions: Node[] = []; const potentialNewTargetCollisions: Node[] = []; const awaitedTypeStack: number[] = []; @@ -11502,9 +11502,9 @@ namespace ts { if (!reference.flowNode || !couldBeUninitialized && !(declaredType.flags & TypeFlags.Narrowable)) { return declaredType; } - const visitedFlowStart = visitedFlowCount; + const sharedFlowStart = sharedFlowCount; const evolvedType = getTypeFromFlowType(getTypeAtFlowNode(reference.flowNode)); - visitedFlowCount = visitedFlowStart; + sharedFlowCount = sharedFlowStart; // When the reference is 'x' in an 'x.length', 'x.push(value)', 'x.unshift(value)' or x[n] = value' operation, // we give type 'any[]' to 'x' instead of using the type determined by control flow analysis such that operations // on empty arrays are possible without implicit any errors and new element types can be inferred without @@ -11532,9 +11532,9 @@ namespace ts { // We cache results of flow type resolution for shared nodes that were previously visited in // the same getFlowTypeOfReference invocation. A node is considered shared when it is the // antecedent of more than one node. - for (let i = visitedFlowStart; i < visitedFlowCount; i++) { - if (visitedFlowNodes[i] === flow) { - return visitedFlowTypes[i]; + for (let i = sharedFlowStart; i < sharedFlowCount; i++) { + if (sharedFlowNodes[i] === flow) { + return sharedFlowTypes[i]; } } } @@ -11597,9 +11597,9 @@ namespace ts { } if (flags & FlowFlags.Shared) { // Record visited node and the associated type in the cache. - visitedFlowNodes[visitedFlowCount] = flow; - visitedFlowTypes[visitedFlowCount] = type; - visitedFlowCount++; + sharedFlowNodes[sharedFlowCount] = flow; + sharedFlowTypes[sharedFlowCount] = type; + sharedFlowCount++; } return type; } From 26903552fe3ec570161b8478f11472e55e415e1c Mon Sep 17 00:00:00 2001 From: Andrew Casey Date: Fri, 8 Sep 2017 13:07:32 -0700 Subject: [PATCH 282/370] Improve insertion position of extracted methods Old: End of target scope New: Before the first non-constructor function following the extracted range in the target scope --- src/compiler/utilities.ts | 2 +- src/services/refactors/extractMethod.ts | 43 +++++++++++++++++++++-- tests/cases/fourslash/extract-method13.ts | 18 +++++++--- 3 files changed, 56 insertions(+), 7 deletions(-) diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index 06b8437f76b..3d24dfc1670 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -505,7 +505,7 @@ namespace ts { } } - function staticAssertNever(_: never): void {} + export function staticAssertNever(_: never): void {} // Gets the nearest enclosing block scope container that has the provided node // as a descendant, that is not the provided node. diff --git a/src/services/refactors/extractMethod.ts b/src/services/refactors/extractMethod.ts index 83908def444..50da5fccf10 100644 --- a/src/services/refactors/extractMethod.ts +++ b/src/services/refactors/extractMethod.ts @@ -697,8 +697,14 @@ namespace ts.refactor.extractMethod { } const changeTracker = textChanges.ChangeTracker.fromContext(context); - // insert function at the end of the scope - changeTracker.insertNodeBefore(context.file, scope.getLastToken(), newFunction, { prefix: context.newLineCharacter, suffix: context.newLineCharacter }); + const minInsertionPos = (isReadonlyArray(range.range) ? lastOrUndefined(range.range) : range.range).end; + const nodeToInsertBefore = getNodeToInsertBefore(minInsertionPos, scope); + if (nodeToInsertBefore) { + changeTracker.insertNodeBefore(context.file, nodeToInsertBefore, newFunction, { suffix: context.newLineCharacter + context.newLineCharacter }); + } + else { + changeTracker.insertNodeBefore(context.file, scope.getLastToken(), newFunction, { prefix: context.newLineCharacter, suffix: context.newLineCharacter }); + } const newNodes: Node[] = []; // replace range with function call @@ -831,6 +837,39 @@ namespace ts.refactor.extractMethod { return "__return"; } + function getStatementsOrClassElements(scope: Scope): ReadonlyArray | ReadonlyArray { + if (isFunctionLike(scope)) { + const body = scope.body; + if (isBlock(body)) { + return body.statements; + } + } + else if (isModuleBlock(scope) || isSourceFile(scope)) { + return scope.statements; + } + else if (isClassLike(scope)) { + return scope.members; + } + else { + staticAssertNever(scope); + } + + return emptyArray; + } + + /** + * If `scope` contains a function after `minPos`, then return the first such function. + * Otherwise, return `undefined`. + */ + function getNodeToInsertBefore(minPos: number, scope: Scope): Node | undefined { + const children = getStatementsOrClassElements(scope); + for (const child of children) { + if (child.pos >= minPos && isFunctionLike(child) && !isConstructorDeclaration(child)) { + return child; + } + } + } + function transformFunctionBody(body: Node) { if (isBlock(body) && !writes && substitutions.size === 0) { // already block, no writes to propagate back, no substitutions - can use node as is diff --git a/tests/cases/fourslash/extract-method13.ts b/tests/cases/fourslash/extract-method13.ts index 94ad86e4399..c000ff27a1f 100644 --- a/tests/cases/fourslash/extract-method13.ts +++ b/tests/cases/fourslash/extract-method13.ts @@ -16,6 +16,16 @@ edit.applyRefactor({ actionDescription: "Extract function into class 'C'", }); +verify.currentFileContentIs(`class C { + static j = 1 + 1; + constructor(q: string = C.newFunction()) { + } + + private static newFunction(): string { + return "a" + "b"; + } +}`); + goTo.select('c', 'd'); edit.applyRefactor({ refactorName: "Extract Method", @@ -28,11 +38,11 @@ verify.currentFileContentIs(`class C { constructor(q: string = C.newFunction()) { } - private static newFunction(): string { - return "a" + "b"; - } - private static newFunction_1() { return 1 + 1; } + + private static newFunction(): string { + return "a" + "b"; + } }`); \ No newline at end of file From 409d6597ebde2fce5673c9704907e339c8a5dc2d Mon Sep 17 00:00:00 2001 From: Andy Date: Fri, 8 Sep 2017 14:22:44 -0700 Subject: [PATCH 283/370] Add `never` helper function (#18287) * Add `never` helper function * Move to Debug.assertNever, keep old messages --- 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 9c72a064b11..aa5fbd6421c 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -1687,7 +1687,7 @@ namespace ts { undefined; } else { - Debug.fail("Unknown entity name kind."); + Debug.assertNever(name, "Unknown entity name kind."); } Debug.assert((getCheckFlags(symbol) & CheckFlags.Instantiated) === 0, "Should never get an instantiated symbol here."); return (symbol.flags & meaning) || dontResolveAlias ? symbol : resolveAlias(symbol); @@ -16357,7 +16357,7 @@ namespace ts { // This code-path is called by language service return resolveStatelessJsxOpeningLikeElement(node, checkExpression((node).tagName), candidatesOutArray); } - Debug.fail("Branch in 'resolveSignature' should be unreachable."); + Debug.assertNever(node, "Branch in 'resolveSignature' should be unreachable."); } /** @@ -24535,7 +24535,7 @@ namespace ts { currentKind = SetAccessor; } else { - Debug.fail("Unexpected syntax kind:" + (prop).kind); + Debug.assertNever(prop, "Unexpected syntax kind:" + (prop).kind); } const effectiveName = getPropertyNameForPropertyNameNode(name); From 25268ce3682486e6d1d24d45f4f616a3b28db612 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Fri, 8 Sep 2017 14:24:32 -0700 Subject: [PATCH 284/370] Separate counters for stack depth and visited flow nodes --- src/compiler/checker.ts | 34 +++++++++++++++++++++------------- 1 file changed, 21 insertions(+), 13 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 521ce94ee3a..f5d75ccd569 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -334,7 +334,7 @@ namespace ts { let flowLoopStart = 0; let flowLoopCount = 0; let sharedFlowCount = 0; - let flowAnalysisDisabled = false; + let flowNodeCount = 0; const emptyStringType = getLiteralType(""); const zeroType = getLiteralType(0); @@ -11495,8 +11495,8 @@ namespace ts { function getFlowTypeOfReference(reference: Node, declaredType: Type, initialType = declaredType, flowContainer?: Node, couldBeUninitialized?: boolean) { let key: string; - let flowLength = 0; - if (flowAnalysisDisabled) { + let flowDepth = 0; + if (flowNodeCount < 0) { return unknownType; } if (!reference.flowNode || !couldBeUninitialized && !(declaredType.flags & TypeFlags.Narrowable)) { @@ -11516,14 +11516,14 @@ namespace ts { return resultType; function getTypeAtFlowNode(flow: FlowNode): FlowType { - flowLength++; + flowDepth++; while (true) { - flowLength++; - if (flowLength >= 5000) { - // We have visited as many as 5000 nodes through as many as 2500 recursive invocations. Rather than - // spending an excessive amount of time and possibly overflowing the call stack, we report an error + flowNodeCount++; + if (flowDepth >= 2500 || flowNodeCount >= 100000000) { + // We have made over 2500 recursive invocations or visited over 100M flow nodes. Rather than + // overflowing the call stack or spending an excessive amount of time, we report an error // and disable further control flow analysis in the containing function or module body. - flowAnalysisDisabled = true; + flowNodeCount = -1; reportFlowControlError(reference); return unknownType; } @@ -11534,6 +11534,7 @@ namespace ts { // antecedent of more than one node. for (let i = sharedFlowStart; i < sharedFlowCount; i++) { if (sharedFlowNodes[i] === flow) { + flowDepth--; return sharedFlowTypes[i]; } } @@ -11601,6 +11602,7 @@ namespace ts { sharedFlowTypes[sharedFlowCount] = type; sharedFlowCount++; } + flowDepth--; return type; } } @@ -19976,9 +19978,15 @@ namespace ts { if (node.kind === SyntaxKind.Block) { checkGrammarStatementInAmbientContext(node); } - const saveFlowAnalysisDisabled = flowAnalysisDisabled; - forEach(node.statements, checkSourceElement); - flowAnalysisDisabled = saveFlowAnalysisDisabled; + if (isFunctionOrModuleBlock(node)) { + const saveFlowNodeCount = flowNodeCount; + flowNodeCount = 0; + forEach(node.statements, checkSourceElement); + flowNodeCount = saveFlowNodeCount; + } + else { + forEach(node.statements, checkSourceElement); + } if (node.locals) { registerForUnusedIdentifiersCheck(node); } @@ -22568,7 +22576,7 @@ namespace ts { deferredNodes = []; deferredUnusedIdentifierNodes = produceDiagnostics && noUnusedIdentifiers ? [] : undefined; - flowAnalysisDisabled = false; + flowNodeCount = 0; forEach(node.statements, checkSourceElement); From e77425f9846dcdf500af3ffcb00c236fce864106 Mon Sep 17 00:00:00 2001 From: Andrew Casey Date: Fri, 8 Sep 2017 14:36:21 -0700 Subject: [PATCH 285/370] Delete staticAssertNever in favor of assertTypeIsNever --- src/compiler/utilities.ts | 4 +--- src/services/refactors/extractMethod.ts | 2 +- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index 3d24dfc1670..c75977d1ee2 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -500,13 +500,11 @@ namespace ts { case SyntaxKind.ArrowFunction: return true; default: - staticAssertNever(node); + assertTypeIsNever(node); return false; } } - export function staticAssertNever(_: never): void {} - // Gets the nearest enclosing block scope container that has the provided node // as a descendant, that is not the provided node. export function getEnclosingBlockScopeContainer(node: Node): Node { diff --git a/src/services/refactors/extractMethod.ts b/src/services/refactors/extractMethod.ts index 50da5fccf10..383302889bc 100644 --- a/src/services/refactors/extractMethod.ts +++ b/src/services/refactors/extractMethod.ts @@ -851,7 +851,7 @@ namespace ts.refactor.extractMethod { return scope.members; } else { - staticAssertNever(scope); + assertTypeIsNever(scope); } return emptyArray; From c671c3ac06af37c949bb0886c2a0f3582ba749c2 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Fri, 8 Sep 2017 15:51:11 -0700 Subject: [PATCH 286/370] Only track flow analysis stack depth --- src/compiler/checker.ts | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 9970aa0b3ed..53c2177a70a 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -335,7 +335,7 @@ namespace ts { let flowLoopStart = 0; let flowLoopCount = 0; let sharedFlowCount = 0; - let flowNodeCount = 0; + let flowAnalysisDisabled = false; const emptyStringType = getLiteralType(""); const zeroType = getLiteralType(0); @@ -11470,7 +11470,7 @@ namespace ts { function getFlowTypeOfReference(reference: Node, declaredType: Type, initialType = declaredType, flowContainer?: Node, couldBeUninitialized?: boolean) { let key: string; let flowDepth = 0; - if (flowNodeCount < 0) { + if (flowAnalysisDisabled) { return unknownType; } if (!reference.flowNode || !couldBeUninitialized && !(declaredType.flags & TypeFlags.Narrowable)) { @@ -11490,17 +11490,15 @@ namespace ts { return resultType; function getTypeAtFlowNode(flow: FlowNode): FlowType { + if (flowDepth === 2500) { + // We have made 2500 recursive invocations. To avoid overflowing the call stack we report an error + // and disable further control flow analysis in the containing function or module body. + flowAnalysisDisabled = true; + reportFlowControlError(reference); + return unknownType; + } flowDepth++; while (true) { - flowNodeCount++; - if (flowDepth >= 2500 || flowNodeCount >= 100000000) { - // We have made over 2500 recursive invocations or visited over 100M flow nodes. Rather than - // overflowing the call stack or spending an excessive amount of time, we report an error - // and disable further control flow analysis in the containing function or module body. - flowNodeCount = -1; - reportFlowControlError(reference); - return unknownType; - } const flags = flow.flags; if (flags & FlowFlags.Shared) { // We cache results of flow type resolution for shared nodes that were previously visited in @@ -19963,10 +19961,9 @@ namespace ts { checkGrammarStatementInAmbientContext(node); } if (isFunctionOrModuleBlock(node)) { - const saveFlowNodeCount = flowNodeCount; - flowNodeCount = 0; + const saveFlowAnalysisDisabled = flowAnalysisDisabled; forEach(node.statements, checkSourceElement); - flowNodeCount = saveFlowNodeCount; + flowAnalysisDisabled = saveFlowAnalysisDisabled; } else { forEach(node.statements, checkSourceElement); @@ -22560,7 +22557,7 @@ namespace ts { deferredNodes = []; deferredUnusedIdentifierNodes = produceDiagnostics && noUnusedIdentifiers ? [] : undefined; - flowNodeCount = 0; + flowAnalysisDisabled = false; forEach(node.statements, checkSourceElement); From 4ba50aadb0a08965f115b5bcc9cf13e0d20a2034 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Fri, 8 Sep 2017 15:51:25 -0700 Subject: [PATCH 287/370] Update test --- tests/cases/compiler/largeControlFlowGraph.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/cases/compiler/largeControlFlowGraph.ts b/tests/cases/compiler/largeControlFlowGraph.ts index 0503c80095b..6cd64530718 100644 --- a/tests/cases/compiler/largeControlFlowGraph.ts +++ b/tests/cases/compiler/largeControlFlowGraph.ts @@ -1,3 +1,5 @@ +// @strict: true + // The control flow graph for the following statement block is 10000 nodes deep. Check that // we gracefully handle this, possibly by issuing an error. const data = []; From c646971cecfe27235c0b07e3bb9d7f868fc0c7f9 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Fri, 8 Sep 2017 15:52:02 -0700 Subject: [PATCH 288/370] Accept new baselines --- tests/baselines/reference/largeControlFlowGraph.errors.txt | 6 +++--- tests/baselines/reference/largeControlFlowGraph.js | 1 + 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/tests/baselines/reference/largeControlFlowGraph.errors.txt b/tests/baselines/reference/largeControlFlowGraph.errors.txt index f9dad52c79f..23095c25f74 100644 --- a/tests/baselines/reference/largeControlFlowGraph.errors.txt +++ b/tests/baselines/reference/largeControlFlowGraph.errors.txt @@ -1,10 +1,12 @@ -tests/cases/compiler/largeControlFlowGraph.ts(5003,1): error TS2563: The body of the containing function or module is too large for control flow analysis. +tests/cases/compiler/largeControlFlowGraph.ts(3,1): error TS2563: The containing function or module body is too large for control flow analysis. ==== tests/cases/compiler/largeControlFlowGraph.ts (1 errors) ==== // The control flow graph for the following statement block is 10000 nodes deep. Check that // we gracefully handle this, possibly by issuing an error. const data = []; + ~~~~~ +!!! error TS2563: The containing function or module body is too large for control flow analysis. data[0] = 0; data[0] = 0; data[0] = 0; @@ -5005,8 +5007,6 @@ tests/cases/compiler/largeControlFlowGraph.ts(5003,1): error TS2563: The body of data[0] = 0; data[0] = 0; data[0] = 0; - ~~~~ -!!! error TS2563: The body of the containing function or module is too large for control flow analysis. data[0] = 0; data[0] = 0; data[0] = 0; diff --git a/tests/baselines/reference/largeControlFlowGraph.js b/tests/baselines/reference/largeControlFlowGraph.js index ee1edbe8984..6476cbc11d2 100644 --- a/tests/baselines/reference/largeControlFlowGraph.js +++ b/tests/baselines/reference/largeControlFlowGraph.js @@ -10005,6 +10005,7 @@ data[0] = 0; //// [largeControlFlowGraph.js] +"use strict"; // The control flow graph for the following statement block is 10000 nodes deep. Check that // we gracefully handle this, possibly by issuing an error. var data = []; From 62899d10cddc58aea83e32a695141ca1dde66dd4 Mon Sep 17 00:00:00 2001 From: Andrew Casey Date: Fri, 8 Sep 2017 16:45:47 -0700 Subject: [PATCH 289/370] Add simple baseline tests for insertion positions --- src/harness/unittests/extractMethods.ts | 58 ++++++++++++++++++- .../extractMethod/extractMethod23.ts | 43 ++++++++++++++ .../extractMethod/extractMethod24.ts | 43 ++++++++++++++ .../extractMethod/extractMethod25.ts | 26 +++++++++ .../extractMethod/extractMethod26.ts | 31 ++++++++++ .../extractMethod/extractMethod27.ts | 34 +++++++++++ .../extractMethod/extractMethod28.ts | 34 +++++++++++ 7 files changed, 267 insertions(+), 2 deletions(-) create mode 100644 tests/baselines/reference/extractMethod/extractMethod23.ts create mode 100644 tests/baselines/reference/extractMethod/extractMethod24.ts create mode 100644 tests/baselines/reference/extractMethod/extractMethod25.ts create mode 100644 tests/baselines/reference/extractMethod/extractMethod26.ts create mode 100644 tests/baselines/reference/extractMethod/extractMethod27.ts create mode 100644 tests/baselines/reference/extractMethod/extractMethod28.ts diff --git a/src/harness/unittests/extractMethods.ts b/src/harness/unittests/extractMethods.ts index 75404d12bf0..edcc80cd57c 100644 --- a/src/harness/unittests/extractMethods.ts +++ b/src/harness/unittests/extractMethods.ts @@ -224,7 +224,7 @@ namespace ts { testExtractRange(` function f() { while (true) { - [#| + [#| if (x) { return; } |] @@ -234,7 +234,7 @@ namespace ts { testExtractRange(` function f() { while (true) { - [#| + [#| [$|if (x) { } return;|] @@ -655,6 +655,60 @@ function test(x: number) { finally { [#|return 1;|] } +}`); + // Extraction position - namespace + testExtractMethod("extractMethod23", + `namespace NS { + function M1() { } + function M2() { + [#|return 1;|] + } + function M3() { } +}`); + // Extraction position - function + testExtractMethod("extractMethod24", + `function Outer() { + function M1() { } + function M2() { + [#|return 1;|] + } + function M3() { } +}`); + // Extraction position - file + testExtractMethod("extractMethod25", + `function M1() { } +function M2() { + [#|return 1;|] +} +function M3() { }`); + // Extraction position - class without ctor + testExtractMethod("extractMethod26", + `class C { + M1() { } + M2() { + [#|return 1;|] + } + M3() { } +}`); + // Extraction position - class with ctor in middle + testExtractMethod("extractMethod27", + `class C { + M1() { } + M2() { + [#|return 1;|] + } + constructor() { } + M3() { } +}`); + // Extraction position - class with ctor at end + testExtractMethod("extractMethod28", + `class C { + M1() { } + M2() { + [#|return 1;|] + } + M3() { } + constructor() { } }`); }); diff --git a/tests/baselines/reference/extractMethod/extractMethod23.ts b/tests/baselines/reference/extractMethod/extractMethod23.ts new file mode 100644 index 00000000000..8bc3db86cc1 --- /dev/null +++ b/tests/baselines/reference/extractMethod/extractMethod23.ts @@ -0,0 +1,43 @@ +// ==ORIGINAL== +namespace NS { + function M1() { } + function M2() { + return 1; + } + function M3() { } +} +// ==SCOPE::function 'M2'== +namespace NS { + function M1() { } + function M2() { + return newFunction(); + + function newFunction() { + return 1; + } + } + function M3() { } +} +// ==SCOPE::namespace 'NS'== +namespace NS { + function M1() { } + function M2() { + return newFunction(); + } + function newFunction() { + return 1; + } + + function M3() { } +} +// ==SCOPE::global scope== +namespace NS { + function M1() { } + function M2() { + return newFunction(); + } + function M3() { } +} +function newFunction() { + return 1; +} diff --git a/tests/baselines/reference/extractMethod/extractMethod24.ts b/tests/baselines/reference/extractMethod/extractMethod24.ts new file mode 100644 index 00000000000..ec6d6cd3f12 --- /dev/null +++ b/tests/baselines/reference/extractMethod/extractMethod24.ts @@ -0,0 +1,43 @@ +// ==ORIGINAL== +function Outer() { + function M1() { } + function M2() { + return 1; + } + function M3() { } +} +// ==SCOPE::function 'M2'== +function Outer() { + function M1() { } + function M2() { + return newFunction(); + + function newFunction() { + return 1; + } + } + function M3() { } +} +// ==SCOPE::function 'Outer'== +function Outer() { + function M1() { } + function M2() { + return newFunction(); + } + function newFunction() { + return 1; + } + + function M3() { } +} +// ==SCOPE::global scope== +function Outer() { + function M1() { } + function M2() { + return newFunction(); + } + function M3() { } +} +function newFunction() { + return 1; +} diff --git a/tests/baselines/reference/extractMethod/extractMethod25.ts b/tests/baselines/reference/extractMethod/extractMethod25.ts new file mode 100644 index 00000000000..a7a971315a1 --- /dev/null +++ b/tests/baselines/reference/extractMethod/extractMethod25.ts @@ -0,0 +1,26 @@ +// ==ORIGINAL== +function M1() { } +function M2() { + return 1; +} +function M3() { } +// ==SCOPE::function 'M2'== +function M1() { } +function M2() { + return newFunction(); + + function newFunction() { + return 1; + } +} +function M3() { } +// ==SCOPE::global scope== +function M1() { } +function M2() { + return newFunction(); +} +function newFunction() { + return 1; +} + +function M3() { } \ No newline at end of file diff --git a/tests/baselines/reference/extractMethod/extractMethod26.ts b/tests/baselines/reference/extractMethod/extractMethod26.ts new file mode 100644 index 00000000000..d0619ea9b0a --- /dev/null +++ b/tests/baselines/reference/extractMethod/extractMethod26.ts @@ -0,0 +1,31 @@ +// ==ORIGINAL== +class C { + M1() { } + M2() { + return 1; + } + M3() { } +} +// ==SCOPE::class 'C'== +class C { + M1() { } + M2() { + return this.newFunction(); + } + private newFunction() { + return 1; + } + + M3() { } +} +// ==SCOPE::global scope== +class C { + M1() { } + M2() { + return newFunction(); + } + M3() { } +} +function newFunction() { + return 1; +} diff --git a/tests/baselines/reference/extractMethod/extractMethod27.ts b/tests/baselines/reference/extractMethod/extractMethod27.ts new file mode 100644 index 00000000000..9f1f1e84a77 --- /dev/null +++ b/tests/baselines/reference/extractMethod/extractMethod27.ts @@ -0,0 +1,34 @@ +// ==ORIGINAL== +class C { + M1() { } + M2() { + return 1; + } + constructor() { } + M3() { } +} +// ==SCOPE::class 'C'== +class C { + M1() { } + M2() { + return this.newFunction(); + } + constructor() { } + private newFunction() { + return 1; + } + + M3() { } +} +// ==SCOPE::global scope== +class C { + M1() { } + M2() { + return newFunction(); + } + constructor() { } + M3() { } +} +function newFunction() { + return 1; +} diff --git a/tests/baselines/reference/extractMethod/extractMethod28.ts b/tests/baselines/reference/extractMethod/extractMethod28.ts new file mode 100644 index 00000000000..9b97e581548 --- /dev/null +++ b/tests/baselines/reference/extractMethod/extractMethod28.ts @@ -0,0 +1,34 @@ +// ==ORIGINAL== +class C { + M1() { } + M2() { + return 1; + } + M3() { } + constructor() { } +} +// ==SCOPE::class 'C'== +class C { + M1() { } + M2() { + return this.newFunction(); + } + private newFunction() { + return 1; + } + + M3() { } + constructor() { } +} +// ==SCOPE::global scope== +class C { + M1() { } + M2() { + return newFunction(); + } + M3() { } + constructor() { } +} +function newFunction() { + return 1; +} From 018c645913425dfdaadf99bbfb014ca05e6076d5 Mon Sep 17 00:00:00 2001 From: Andy Date: Sat, 9 Sep 2017 05:52:08 -0700 Subject: [PATCH 290/370] In import code fix, don't treat a re-export as an import (#18341) --- src/services/codefixes/importFixes.ts | 30 +++++++------------ .../fourslash/importNameCodeFixReExport.ts | 16 ++++++++++ 2 files changed, 27 insertions(+), 19 deletions(-) create mode 100644 tests/cases/fourslash/importNameCodeFixReExport.ts diff --git a/src/services/codefixes/importFixes.ts b/src/services/codefixes/importFixes.ts index 99b677ebd3d..96f4b7ad4b5 100644 --- a/src/services/codefixes/importFixes.ts +++ b/src/services/codefixes/importFixes.ts @@ -133,7 +133,7 @@ namespace ts.codefix { const symbolIdActionMap = new ImportCodeActionMap(); // this is a module id -> module import declaration map - const cachedImportDeclarations: (ImportDeclaration | ImportEqualsDeclaration)[][] = []; + const cachedImportDeclarations: AnyImportSyntax[][] = []; let lastImportDeclaration: Node; const currentTokenMeaning = getMeaningFromLocation(token); @@ -199,28 +199,20 @@ namespace ts.codefix { return cached; } - const existingDeclarations: (ImportDeclaration | ImportEqualsDeclaration)[] = []; - for (const importModuleSpecifier of sourceFile.imports) { - const importSymbol = checker.getSymbolAtLocation(importModuleSpecifier); - if (importSymbol === moduleSymbol) { - existingDeclarations.push(getImportDeclaration(importModuleSpecifier)); - } - } + const existingDeclarations = mapDefined(sourceFile.imports, importModuleSpecifier => + checker.getSymbolAtLocation(importModuleSpecifier) === moduleSymbol ? getImportDeclaration(importModuleSpecifier) : undefined); cachedImportDeclarations[moduleSymbolId] = existingDeclarations; return existingDeclarations; - function getImportDeclaration(moduleSpecifier: LiteralExpression) { - let node: Node = moduleSpecifier; - while (node) { - if (node.kind === SyntaxKind.ImportDeclaration) { - return node; - } - if (node.kind === SyntaxKind.ImportEqualsDeclaration) { - return node; - } - node = node.parent; + function getImportDeclaration({ parent }: LiteralExpression): AnyImportSyntax { + switch (parent.kind) { + case SyntaxKind.ImportDeclaration: + return parent as ImportDeclaration; + case SyntaxKind.ExternalModuleReference: + return (parent as ExternalModuleReference).parent; + default: + return undefined; } - return undefined; } } diff --git a/tests/cases/fourslash/importNameCodeFixReExport.ts b/tests/cases/fourslash/importNameCodeFixReExport.ts new file mode 100644 index 00000000000..c77d32cc458 --- /dev/null +++ b/tests/cases/fourslash/importNameCodeFixReExport.ts @@ -0,0 +1,16 @@ +/// + +// Test that we are not fooled by a re-export existing in the file already + +// @Filename: /a.ts +////export const x = 0"; + +// @Filename: /b.ts +////[|export { x } from "./a"; +////x;|] + +goTo.file("/b.ts"); +verify.rangeAfterCodeFix(`import { x } from "./a"; + +export { x } from "./a"; +x;`, /*includeWhiteSpace*/ true); From e51e91dd2c372a9d8e6cead2589c30fbe488c333 Mon Sep 17 00:00:00 2001 From: Andy Date: Sat, 9 Sep 2017 05:52:52 -0700 Subject: [PATCH 291/370] Change wording of scope description (#18342) --- src/compiler/diagnosticMessages.json | 2 +- src/compiler/utilities.ts | 27 +++++-- src/services/refactors/extractMethod.ts | 75 ++++++++++--------- .../reference/extractMethod/extractMethod1.ts | 8 +- .../extractMethod/extractMethod10.ts | 6 +- .../extractMethod/extractMethod11.ts | 6 +- .../extractMethod/extractMethod12.ts | 2 +- .../extractMethod/extractMethod13.ts | 6 +- .../extractMethod/extractMethod14.ts | 6 +- .../extractMethod/extractMethod15.ts | 6 +- .../extractMethod/extractMethod16.ts | 4 +- .../extractMethod/extractMethod17.ts | 4 +- .../extractMethod/extractMethod18.ts | 4 +- .../extractMethod/extractMethod19.ts | 4 +- .../reference/extractMethod/extractMethod2.ts | 8 +- .../extractMethod/extractMethod20.ts | 4 +- .../extractMethod/extractMethod21.ts | 4 +- .../extractMethod/extractMethod22.ts | 4 +- .../reference/extractMethod/extractMethod3.ts | 8 +- .../reference/extractMethod/extractMethod4.ts | 8 +- .../reference/extractMethod/extractMethod5.ts | 8 +- .../reference/extractMethod/extractMethod6.ts | 8 +- .../reference/extractMethod/extractMethod7.ts | 8 +- .../reference/extractMethod/extractMethod8.ts | 8 +- .../reference/extractMethod/extractMethod9.ts | 8 +- .../fourslash/extract-method-formatting.ts | 2 +- tests/cases/fourslash/extract-method1.ts | 2 +- tests/cases/fourslash/extract-method10.ts | 2 +- tests/cases/fourslash/extract-method13.ts | 4 +- tests/cases/fourslash/extract-method14.ts | 2 +- tests/cases/fourslash/extract-method15.ts | 2 +- tests/cases/fourslash/extract-method18.ts | 2 +- tests/cases/fourslash/extract-method19.ts | 2 +- tests/cases/fourslash/extract-method2.ts | 2 +- tests/cases/fourslash/extract-method21.ts | 2 +- tests/cases/fourslash/extract-method24.ts | 2 +- tests/cases/fourslash/extract-method25.ts | 2 +- tests/cases/fourslash/extract-method5.ts | 2 +- tests/cases/fourslash/extract-method7.ts | 2 +- 39 files changed, 140 insertions(+), 126 deletions(-) diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index 9a3492e5c37..c7713839ce3 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -3696,7 +3696,7 @@ "code": 95003 }, - "Extract function into {0}": { + "Extract to {0}": { "category": "Message", "code": 95004 } diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index 06b8437f76b..d88966e4481 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -4829,16 +4829,29 @@ namespace ts { } /* @internal */ - export function isFunctionLikeKind(kind: SyntaxKind): boolean { + export function isFunctionLikeDeclaration(node: Node): node is FunctionLikeDeclaration { + return node && isFunctionLikeDeclarationKind(node.kind); + } + + function isFunctionLikeDeclarationKind(kind: SyntaxKind): boolean { switch (kind) { - case SyntaxKind.Constructor: - case SyntaxKind.FunctionExpression: case SyntaxKind.FunctionDeclaration: - case SyntaxKind.ArrowFunction: case SyntaxKind.MethodDeclaration: - case SyntaxKind.MethodSignature: + case SyntaxKind.Constructor: case SyntaxKind.GetAccessor: case SyntaxKind.SetAccessor: + case SyntaxKind.FunctionExpression: + case SyntaxKind.ArrowFunction: + return true; + default: + return false; + } + } + + /* @internal */ + export function isFunctionLikeKind(kind: SyntaxKind): boolean { + switch (kind) { + case SyntaxKind.MethodSignature: case SyntaxKind.CallSignature: case SyntaxKind.ConstructSignature: case SyntaxKind.IndexSignature: @@ -4846,9 +4859,9 @@ namespace ts { case SyntaxKind.JSDocFunctionType: case SyntaxKind.ConstructorType: return true; + default: + return isFunctionLikeDeclarationKind(kind); } - - return false; } // Classes diff --git a/src/services/refactors/extractMethod.ts b/src/services/refactors/extractMethod.ts index 83908def444..8521e2fac0b 100644 --- a/src/services/refactors/extractMethod.ts +++ b/src/services/refactors/extractMethod.ts @@ -40,7 +40,7 @@ namespace ts.refactor.extractMethod { // Don't issue refactorings with duplicated names. // Scopes come back in "innermost first" order, so extractions will // preferentially go into nearer scopes - const description = formatStringFromArgs(Diagnostics.Extract_function_into_0.message, [extr.scopeDescription]); + const description = formatStringFromArgs(Diagnostics.Extract_to_0.message, [extr.scopeDescription]); if (!usedNames.has(description)) { usedNames.set(description, true); actions.push({ @@ -543,44 +543,45 @@ namespace ts.refactor.extractMethod { } } - function getDescriptionForScope(scope: Scope) { - if (isFunctionLike(scope)) { - switch (scope.kind) { - case SyntaxKind.Constructor: - return "constructor"; - case SyntaxKind.FunctionExpression: - return scope.name - ? `function expression ${scope.name.text}` - : "anonymous function expression"; - case SyntaxKind.FunctionDeclaration: - return `function '${scope.name.text}'`; - case SyntaxKind.ArrowFunction: - return "arrow function"; - case SyntaxKind.MethodDeclaration: - return `method '${scope.name.getText()}`; - case SyntaxKind.GetAccessor: - return `'get ${scope.name.getText()}'`; - case SyntaxKind.SetAccessor: - return `'set ${scope.name.getText()}'`; - } - } - else if (isModuleBlock(scope)) { - return `namespace '${scope.parent.name.getText()}'`; - } - else if (isClassLike(scope)) { - return scope.kind === SyntaxKind.ClassDeclaration - ? `class '${scope.name.text}'` - : scope.name && scope.name.text - ? `class expression '${scope.name.text}'` - : "anonymous class expression"; - } - else if (isSourceFile(scope)) { - return scope.externalModuleIndicator ? "module scope" : "global scope"; - } - else { - return "unknown"; + function getDescriptionForScope(scope: Scope): string { + return isFunctionLikeDeclaration(scope) + ? `inner function in ${getDescriptionForFunctionLikeDeclaration(scope)}` + : isClassLike(scope) + ? `method in ${getDescriptionForClassLikeDeclaration(scope)}` + : `function in ${getDescriptionForModuleLikeDeclaration(scope)}`; + } + function getDescriptionForFunctionLikeDeclaration(scope: FunctionLikeDeclaration): string { + switch (scope.kind) { + case SyntaxKind.Constructor: + return "constructor"; + case SyntaxKind.FunctionExpression: + return scope.name + ? `function expression '${scope.name.text}'` + : "anonymous function expression"; + case SyntaxKind.FunctionDeclaration: + return `function '${scope.name.text}'`; + case SyntaxKind.ArrowFunction: + return "arrow function"; + case SyntaxKind.MethodDeclaration: + return `method '${scope.name.getText()}`; + case SyntaxKind.GetAccessor: + return `'get ${scope.name.getText()}'`; + case SyntaxKind.SetAccessor: + return `'set ${scope.name.getText()}'`; + default: + Debug.assertNever(scope); } } + function getDescriptionForClassLikeDeclaration(scope: ClassLikeDeclaration): string { + return scope.kind === SyntaxKind.ClassDeclaration + ? `class '${scope.name.text}'` + : scope.name ? `class expression '${scope.name.text}'` : "anonymous class expression"; + } + function getDescriptionForModuleLikeDeclaration(scope: SourceFile | ModuleBlock): string { + return scope.kind === SyntaxKind.ModuleBlock + ? `namespace '${scope.parent.name.getText()}'` + : scope.externalModuleIndicator ? "module scope" : "global scope"; + } function getUniqueName(isNameOkay: (name: string) => boolean) { let functionNameText = "newFunction"; diff --git a/tests/baselines/reference/extractMethod/extractMethod1.ts b/tests/baselines/reference/extractMethod/extractMethod1.ts index bfe80cb6c9b..660380c1253 100644 --- a/tests/baselines/reference/extractMethod/extractMethod1.ts +++ b/tests/baselines/reference/extractMethod/extractMethod1.ts @@ -14,7 +14,7 @@ namespace A { } } } -// ==SCOPE::function 'a'== +// ==SCOPE::inner function in function 'a'== namespace A { let x = 1; function foo() { @@ -34,7 +34,7 @@ namespace A { } } } -// ==SCOPE::namespace 'B'== +// ==SCOPE::function in namespace 'B'== namespace A { let x = 1; function foo() { @@ -55,7 +55,7 @@ namespace A { } } } -// ==SCOPE::namespace 'A'== +// ==SCOPE::function in namespace 'A'== namespace A { let x = 1; function foo() { @@ -76,7 +76,7 @@ namespace A { return a; } } -// ==SCOPE::global scope== +// ==SCOPE::function in global scope== namespace A { let x = 1; function foo() { diff --git a/tests/baselines/reference/extractMethod/extractMethod10.ts b/tests/baselines/reference/extractMethod/extractMethod10.ts index 97bd5cbd503..13108a08131 100644 --- a/tests/baselines/reference/extractMethod/extractMethod10.ts +++ b/tests/baselines/reference/extractMethod/extractMethod10.ts @@ -9,7 +9,7 @@ namespace A { } } } -// ==SCOPE::class 'C'== +// ==SCOPE::method in class 'C'== namespace A { export interface I { x: number }; class C { @@ -24,7 +24,7 @@ namespace A { } } } -// ==SCOPE::namespace 'A'== +// ==SCOPE::function in namespace 'A'== namespace A { export interface I { x: number }; class C { @@ -39,7 +39,7 @@ namespace A { return a1.x + 10; } } -// ==SCOPE::global scope== +// ==SCOPE::function in global scope== namespace A { export interface I { x: number }; class C { diff --git a/tests/baselines/reference/extractMethod/extractMethod11.ts b/tests/baselines/reference/extractMethod/extractMethod11.ts index 4999df4a706..5a2e0da826a 100644 --- a/tests/baselines/reference/extractMethod/extractMethod11.ts +++ b/tests/baselines/reference/extractMethod/extractMethod11.ts @@ -11,7 +11,7 @@ namespace A { } } } -// ==SCOPE::class 'C'== +// ==SCOPE::method in class 'C'== namespace A { let y = 1; class C { @@ -30,7 +30,7 @@ namespace A { } } } -// ==SCOPE::namespace 'A'== +// ==SCOPE::function in namespace 'A'== namespace A { let y = 1; class C { @@ -49,7 +49,7 @@ namespace A { return { __return: a1.x + 10, z }; } } -// ==SCOPE::global scope== +// ==SCOPE::function in global scope== namespace A { let y = 1; class C { diff --git a/tests/baselines/reference/extractMethod/extractMethod12.ts b/tests/baselines/reference/extractMethod/extractMethod12.ts index 2b95a545ce1..98428a67bd0 100644 --- a/tests/baselines/reference/extractMethod/extractMethod12.ts +++ b/tests/baselines/reference/extractMethod/extractMethod12.ts @@ -13,7 +13,7 @@ namespace A { } } } -// ==SCOPE::class 'C'== +// ==SCOPE::method in class 'C'== namespace A { let y = 1; class C { diff --git a/tests/baselines/reference/extractMethod/extractMethod13.ts b/tests/baselines/reference/extractMethod/extractMethod13.ts index 8f76dea88aa..44968ac4dcf 100644 --- a/tests/baselines/reference/extractMethod/extractMethod13.ts +++ b/tests/baselines/reference/extractMethod/extractMethod13.ts @@ -14,7 +14,7 @@ } } } -// ==SCOPE::function 'F2'== +// ==SCOPE::inner function in function 'F2'== (u1a: U1a, u1b: U1b) => { function F1(t1a: T1a, t1b: T1b) { (u2a: U2a, u2b: U2b) => { @@ -34,7 +34,7 @@ } } } -// ==SCOPE::function 'F1'== +// ==SCOPE::inner function in function 'F1'== (u1a: U1a, u1b: U1b) => { function F1(t1a: T1a, t1b: T1b) { (u2a: U2a, u2b: U2b) => { @@ -54,7 +54,7 @@ } } } -// ==SCOPE::global scope== +// ==SCOPE::function in global scope== (u1a: U1a, u1b: U1b) => { function F1(t1a: T1a, t1b: T1b) { (u2a: U2a, u2b: U2b) => { diff --git a/tests/baselines/reference/extractMethod/extractMethod14.ts b/tests/baselines/reference/extractMethod/extractMethod14.ts index 38e4c380ebc..4db0e748907 100644 --- a/tests/baselines/reference/extractMethod/extractMethod14.ts +++ b/tests/baselines/reference/extractMethod/extractMethod14.ts @@ -5,7 +5,7 @@ function F(t1: T) { t2.toString(); } } -// ==SCOPE::function 'F'== +// ==SCOPE::inner function in function 'F'== function F(t1: T) { function F(t2: T) { newFunction(); @@ -16,7 +16,7 @@ function F(t1: T) { } } } -// ==SCOPE::function 'F'== +// ==SCOPE::inner function in function 'F'== function F(t1: T) { function F(t2: T) { newFunction(t2); @@ -27,7 +27,7 @@ function F(t1: T) { t2.toString(); } } -// ==SCOPE::global scope== +// ==SCOPE::function in global scope== function F(t1: T) { function F(t2: T) { newFunction(t1, t2); diff --git a/tests/baselines/reference/extractMethod/extractMethod15.ts b/tests/baselines/reference/extractMethod/extractMethod15.ts index ba5b9b3ad01..7d1c8aa4507 100644 --- a/tests/baselines/reference/extractMethod/extractMethod15.ts +++ b/tests/baselines/reference/extractMethod/extractMethod15.ts @@ -4,7 +4,7 @@ function F(t1: T) { t2.toString(); } } -// ==SCOPE::function 'F'== +// ==SCOPE::inner function in function 'F'== function F(t1: T) { function F(t2: U) { newFunction(); @@ -14,7 +14,7 @@ function F(t1: T) { } } } -// ==SCOPE::function 'F'== +// ==SCOPE::inner function in function 'F'== function F(t1: T) { function F(t2: U) { newFunction(t2); @@ -24,7 +24,7 @@ function F(t1: T) { t2.toString(); } } -// ==SCOPE::global scope== +// ==SCOPE::function in global scope== function F(t1: T) { function F(t2: U) { newFunction(t2); diff --git a/tests/baselines/reference/extractMethod/extractMethod16.ts b/tests/baselines/reference/extractMethod/extractMethod16.ts index 1ce88b93145..2ecb0703660 100644 --- a/tests/baselines/reference/extractMethod/extractMethod16.ts +++ b/tests/baselines/reference/extractMethod/extractMethod16.ts @@ -2,7 +2,7 @@ function F() { const array: T[] = []; } -// ==SCOPE::function 'F'== +// ==SCOPE::inner function in function 'F'== function F() { const array: T[] = newFunction(); @@ -10,7 +10,7 @@ function F() { return []; } } -// ==SCOPE::global scope== +// ==SCOPE::function in global scope== function F() { const array: T[] = newFunction(); } diff --git a/tests/baselines/reference/extractMethod/extractMethod17.ts b/tests/baselines/reference/extractMethod/extractMethod17.ts index d800c79f3bd..d0401b6b472 100644 --- a/tests/baselines/reference/extractMethod/extractMethod17.ts +++ b/tests/baselines/reference/extractMethod/extractMethod17.ts @@ -4,7 +4,7 @@ class C { t1.toString(); } } -// ==SCOPE::class 'C'== +// ==SCOPE::method in class 'C'== class C { M(t1: T1, t2: T2) { this.newFunction(t1); @@ -14,7 +14,7 @@ class C { t1.toString(); } } -// ==SCOPE::global scope== +// ==SCOPE::function in global scope== class C { M(t1: T1, t2: T2) { newFunction(t1); diff --git a/tests/baselines/reference/extractMethod/extractMethod18.ts b/tests/baselines/reference/extractMethod/extractMethod18.ts index ce6a90c3790..85ef9a5d5c0 100644 --- a/tests/baselines/reference/extractMethod/extractMethod18.ts +++ b/tests/baselines/reference/extractMethod/extractMethod18.ts @@ -4,7 +4,7 @@ class C { t1.toString(); } } -// ==SCOPE::class 'C'== +// ==SCOPE::method in class 'C'== class C { M(t1: T1, t2: T2) { this.newFunction(t1); @@ -14,7 +14,7 @@ class C { t1.toString(); } } -// ==SCOPE::global scope== +// ==SCOPE::function in global scope== class C { M(t1: T1, t2: T2) { newFunction(t1); diff --git a/tests/baselines/reference/extractMethod/extractMethod19.ts b/tests/baselines/reference/extractMethod/extractMethod19.ts index 1bf25550172..80d3c61d1ee 100644 --- a/tests/baselines/reference/extractMethod/extractMethod19.ts +++ b/tests/baselines/reference/extractMethod/extractMethod19.ts @@ -2,7 +2,7 @@ function F(v: V) { v.toString(); } -// ==SCOPE::function 'F'== +// ==SCOPE::inner function in function 'F'== function F(v: V) { newFunction(); @@ -10,7 +10,7 @@ function F(v: V) { v.toString(); } } -// ==SCOPE::global scope== +// ==SCOPE::function in global scope== function F(v: V) { newFunction(v); } diff --git a/tests/baselines/reference/extractMethod/extractMethod2.ts b/tests/baselines/reference/extractMethod/extractMethod2.ts index 3b61a98d001..17ca6a6ba22 100644 --- a/tests/baselines/reference/extractMethod/extractMethod2.ts +++ b/tests/baselines/reference/extractMethod/extractMethod2.ts @@ -12,7 +12,7 @@ namespace A { } } } -// ==SCOPE::function 'a'== +// ==SCOPE::inner function in function 'a'== namespace A { let x = 1; function foo() { @@ -30,7 +30,7 @@ namespace A { } } } -// ==SCOPE::namespace 'B'== +// ==SCOPE::function in namespace 'B'== namespace A { let x = 1; function foo() { @@ -48,7 +48,7 @@ namespace A { } } } -// ==SCOPE::namespace 'A'== +// ==SCOPE::function in namespace 'A'== namespace A { let x = 1; function foo() { @@ -66,7 +66,7 @@ namespace A { return foo(); } } -// ==SCOPE::global scope== +// ==SCOPE::function in global scope== namespace A { let x = 1; function foo() { diff --git a/tests/baselines/reference/extractMethod/extractMethod20.ts b/tests/baselines/reference/extractMethod/extractMethod20.ts index 7c35caee30f..7d65bfca1a9 100644 --- a/tests/baselines/reference/extractMethod/extractMethod20.ts +++ b/tests/baselines/reference/extractMethod/extractMethod20.ts @@ -5,7 +5,7 @@ const _ = class { return a1.x + 10; } } -// ==SCOPE::anonymous class expression== +// ==SCOPE::method in anonymous class expression== const _ = class { a() { return this.newFunction(); @@ -16,7 +16,7 @@ const _ = class { return a1.x + 10; } } -// ==SCOPE::global scope== +// ==SCOPE::function in global scope== const _ = class { a() { return newFunction(); diff --git a/tests/baselines/reference/extractMethod/extractMethod21.ts b/tests/baselines/reference/extractMethod/extractMethod21.ts index 4b73a6ed3c7..6fb5fc43155 100644 --- a/tests/baselines/reference/extractMethod/extractMethod21.ts +++ b/tests/baselines/reference/extractMethod/extractMethod21.ts @@ -4,7 +4,7 @@ function foo() { x++; return; } -// ==SCOPE::function 'foo'== +// ==SCOPE::inner function in function 'foo'== function foo() { let x = 10; return newFunction(); @@ -14,7 +14,7 @@ function foo() { return; } } -// ==SCOPE::global scope== +// ==SCOPE::function in global scope== function foo() { let x = 10; x = newFunction(x); diff --git a/tests/baselines/reference/extractMethod/extractMethod22.ts b/tests/baselines/reference/extractMethod/extractMethod22.ts index 7603c01681f..1bb76ef67ba 100644 --- a/tests/baselines/reference/extractMethod/extractMethod22.ts +++ b/tests/baselines/reference/extractMethod/extractMethod22.ts @@ -6,7 +6,7 @@ function test() { return 1; } } -// ==SCOPE::function 'test'== +// ==SCOPE::inner function in function 'test'== function test() { try { } @@ -18,7 +18,7 @@ function test() { return 1; } } -// ==SCOPE::global scope== +// ==SCOPE::function in global scope== function test() { try { } diff --git a/tests/baselines/reference/extractMethod/extractMethod3.ts b/tests/baselines/reference/extractMethod/extractMethod3.ts index 0837fbfc10d..0d8481c9841 100644 --- a/tests/baselines/reference/extractMethod/extractMethod3.ts +++ b/tests/baselines/reference/extractMethod/extractMethod3.ts @@ -11,7 +11,7 @@ namespace A { } } } -// ==SCOPE::function 'a'== +// ==SCOPE::inner function in function 'a'== namespace A { function foo() { } @@ -28,7 +28,7 @@ namespace A { } } } -// ==SCOPE::namespace 'B'== +// ==SCOPE::function in namespace 'B'== namespace A { function foo() { } @@ -45,7 +45,7 @@ namespace A { } } } -// ==SCOPE::namespace 'A'== +// ==SCOPE::function in namespace 'A'== namespace A { function foo() { } @@ -62,7 +62,7 @@ namespace A { return foo(); } } -// ==SCOPE::global scope== +// ==SCOPE::function in global scope== namespace A { function foo() { } diff --git a/tests/baselines/reference/extractMethod/extractMethod4.ts b/tests/baselines/reference/extractMethod/extractMethod4.ts index 4e9811501f4..4f6a5d85f89 100644 --- a/tests/baselines/reference/extractMethod/extractMethod4.ts +++ b/tests/baselines/reference/extractMethod/extractMethod4.ts @@ -13,7 +13,7 @@ namespace A { } } } -// ==SCOPE::function 'a'== +// ==SCOPE::inner function in function 'a'== namespace A { function foo() { } @@ -32,7 +32,7 @@ namespace A { } } } -// ==SCOPE::namespace 'B'== +// ==SCOPE::function in namespace 'B'== namespace A { function foo() { } @@ -51,7 +51,7 @@ namespace A { } } } -// ==SCOPE::namespace 'A'== +// ==SCOPE::function in namespace 'A'== namespace A { function foo() { } @@ -70,7 +70,7 @@ namespace A { return foo(); } } -// ==SCOPE::global scope== +// ==SCOPE::function in global scope== namespace A { function foo() { } diff --git a/tests/baselines/reference/extractMethod/extractMethod5.ts b/tests/baselines/reference/extractMethod/extractMethod5.ts index 77b2f7b5545..10ff0005f73 100644 --- a/tests/baselines/reference/extractMethod/extractMethod5.ts +++ b/tests/baselines/reference/extractMethod/extractMethod5.ts @@ -14,7 +14,7 @@ namespace A { } } } -// ==SCOPE::function 'a'== +// ==SCOPE::inner function in function 'a'== namespace A { let x = 1; export function foo() { @@ -34,7 +34,7 @@ namespace A { } } } -// ==SCOPE::namespace 'B'== +// ==SCOPE::function in namespace 'B'== namespace A { let x = 1; export function foo() { @@ -55,7 +55,7 @@ namespace A { } } } -// ==SCOPE::namespace 'A'== +// ==SCOPE::function in namespace 'A'== namespace A { let x = 1; export function foo() { @@ -76,7 +76,7 @@ namespace A { return a; } } -// ==SCOPE::global scope== +// ==SCOPE::function in global scope== namespace A { let x = 1; export function foo() { diff --git a/tests/baselines/reference/extractMethod/extractMethod6.ts b/tests/baselines/reference/extractMethod/extractMethod6.ts index 3c8c0a99b70..40135e6ec97 100644 --- a/tests/baselines/reference/extractMethod/extractMethod6.ts +++ b/tests/baselines/reference/extractMethod/extractMethod6.ts @@ -14,7 +14,7 @@ namespace A { } } } -// ==SCOPE::function 'a'== +// ==SCOPE::inner function in function 'a'== namespace A { let x = 1; export function foo() { @@ -34,7 +34,7 @@ namespace A { } } } -// ==SCOPE::namespace 'B'== +// ==SCOPE::function in namespace 'B'== namespace A { let x = 1; export function foo() { @@ -56,7 +56,7 @@ namespace A { } } } -// ==SCOPE::namespace 'A'== +// ==SCOPE::function in namespace 'A'== namespace A { let x = 1; export function foo() { @@ -78,7 +78,7 @@ namespace A { return { __return: foo(), a }; } } -// ==SCOPE::global scope== +// ==SCOPE::function in global scope== namespace A { let x = 1; export function foo() { diff --git a/tests/baselines/reference/extractMethod/extractMethod7.ts b/tests/baselines/reference/extractMethod/extractMethod7.ts index 3f1e25991bd..d01532da796 100644 --- a/tests/baselines/reference/extractMethod/extractMethod7.ts +++ b/tests/baselines/reference/extractMethod/extractMethod7.ts @@ -16,7 +16,7 @@ namespace A { } } } -// ==SCOPE::function 'a'== +// ==SCOPE::inner function in function 'a'== namespace A { let x = 1; export namespace C { @@ -38,7 +38,7 @@ namespace A { } } } -// ==SCOPE::namespace 'B'== +// ==SCOPE::function in namespace 'B'== namespace A { let x = 1; export namespace C { @@ -62,7 +62,7 @@ namespace A { } } } -// ==SCOPE::namespace 'A'== +// ==SCOPE::function in namespace 'A'== namespace A { let x = 1; export namespace C { @@ -86,7 +86,7 @@ namespace A { return { __return: C.foo(), a }; } } -// ==SCOPE::global scope== +// ==SCOPE::function in global scope== namespace A { let x = 1; export namespace C { diff --git a/tests/baselines/reference/extractMethod/extractMethod8.ts b/tests/baselines/reference/extractMethod/extractMethod8.ts index e6d933ec309..d59ca5dc238 100644 --- a/tests/baselines/reference/extractMethod/extractMethod8.ts +++ b/tests/baselines/reference/extractMethod/extractMethod8.ts @@ -8,7 +8,7 @@ namespace A { } } } -// ==SCOPE::function 'a'== +// ==SCOPE::inner function in function 'a'== namespace A { let x = 1; namespace B { @@ -22,7 +22,7 @@ namespace A { } } } -// ==SCOPE::namespace 'B'== +// ==SCOPE::function in namespace 'B'== namespace A { let x = 1; namespace B { @@ -36,7 +36,7 @@ namespace A { } } } -// ==SCOPE::namespace 'A'== +// ==SCOPE::function in namespace 'A'== namespace A { let x = 1; namespace B { @@ -50,7 +50,7 @@ namespace A { return 1 + a1 + x; } } -// ==SCOPE::global scope== +// ==SCOPE::function in global scope== namespace A { let x = 1; namespace B { diff --git a/tests/baselines/reference/extractMethod/extractMethod9.ts b/tests/baselines/reference/extractMethod/extractMethod9.ts index 6d0672f11c1..342e3c10eee 100644 --- a/tests/baselines/reference/extractMethod/extractMethod9.ts +++ b/tests/baselines/reference/extractMethod/extractMethod9.ts @@ -8,7 +8,7 @@ namespace A { } } } -// ==SCOPE::function 'a'== +// ==SCOPE::inner function in function 'a'== namespace A { export interface I { x: number }; namespace B { @@ -22,7 +22,7 @@ namespace A { } } } -// ==SCOPE::namespace 'B'== +// ==SCOPE::function in namespace 'B'== namespace A { export interface I { x: number }; namespace B { @@ -36,7 +36,7 @@ namespace A { } } } -// ==SCOPE::namespace 'A'== +// ==SCOPE::function in namespace 'A'== namespace A { export interface I { x: number }; namespace B { @@ -50,7 +50,7 @@ namespace A { return a1.x + 10; } } -// ==SCOPE::global scope== +// ==SCOPE::function in global scope== namespace A { export interface I { x: number }; namespace B { diff --git a/tests/cases/fourslash/extract-method-formatting.ts b/tests/cases/fourslash/extract-method-formatting.ts index 1342e5632e8..a346ad3bbd9 100644 --- a/tests/cases/fourslash/extract-method-formatting.ts +++ b/tests/cases/fourslash/extract-method-formatting.ts @@ -9,7 +9,7 @@ goTo.select('start', 'end') edit.applyRefactor({ refactorName: "Extract Method", actionName: "scope_1", - actionDescription: "Extract function into global scope", + actionDescription: "Extract to function in global scope", }); verify.currentFileContentIs( `function f(x: number): number { diff --git a/tests/cases/fourslash/extract-method1.ts b/tests/cases/fourslash/extract-method1.ts index ff061295c8c..64dffc15a90 100644 --- a/tests/cases/fourslash/extract-method1.ts +++ b/tests/cases/fourslash/extract-method1.ts @@ -16,7 +16,7 @@ goTo.select('start', 'end') edit.applyRefactor({ refactorName: "Extract Method", actionName: "scope_0", - actionDescription: "Extract function into class 'Foo'", + actionDescription: "Extract to method in class 'Foo'", }); verify.currentFileContentIs( `class Foo { diff --git a/tests/cases/fourslash/extract-method10.ts b/tests/cases/fourslash/extract-method10.ts index ffbee7350e2..73ef3029e24 100644 --- a/tests/cases/fourslash/extract-method10.ts +++ b/tests/cases/fourslash/extract-method10.ts @@ -7,5 +7,5 @@ goTo.select('1', '2'); edit.applyRefactor({ refactorName: "Extract Method", actionName: 'scope_0', - actionDescription: "Extract function into module scope", + actionDescription: "Extract to function in module scope", }); diff --git a/tests/cases/fourslash/extract-method13.ts b/tests/cases/fourslash/extract-method13.ts index 94ad86e4399..707921546c5 100644 --- a/tests/cases/fourslash/extract-method13.ts +++ b/tests/cases/fourslash/extract-method13.ts @@ -13,14 +13,14 @@ goTo.select('a', 'b'); edit.applyRefactor({ refactorName: "Extract Method", actionName: "scope_0", - actionDescription: "Extract function into class 'C'", + actionDescription: "Extract to method in class 'C'", }); goTo.select('c', 'd'); edit.applyRefactor({ refactorName: "Extract Method", actionName: "scope_0", - actionDescription: "Extract function into class 'C'", + actionDescription: "Extract to method in class 'C'", }); verify.currentFileContentIs(`class C { diff --git a/tests/cases/fourslash/extract-method14.ts b/tests/cases/fourslash/extract-method14.ts index 696bb664bd3..770ed3d0fcb 100644 --- a/tests/cases/fourslash/extract-method14.ts +++ b/tests/cases/fourslash/extract-method14.ts @@ -14,7 +14,7 @@ goTo.select('a', 'b'); edit.applyRefactor({ refactorName: "Extract Method", actionName: "scope_1", - actionDescription: "Extract function into global scope", + actionDescription: "Extract to function in global scope", }); verify.currentFileContentIs(`function foo() { var i = 10; diff --git a/tests/cases/fourslash/extract-method15.ts b/tests/cases/fourslash/extract-method15.ts index 93aa357cfee..8d3db633b11 100644 --- a/tests/cases/fourslash/extract-method15.ts +++ b/tests/cases/fourslash/extract-method15.ts @@ -12,7 +12,7 @@ goTo.select('a', 'b'); edit.applyRefactor({ refactorName: "Extract Method", actionName: "scope_1", - actionDescription: "Extract function into global scope", + actionDescription: "Extract to function in global scope", }); verify.currentFileContentIs(`function foo() { diff --git a/tests/cases/fourslash/extract-method18.ts b/tests/cases/fourslash/extract-method18.ts index d99d14bac73..6d4d06ca7bf 100644 --- a/tests/cases/fourslash/extract-method18.ts +++ b/tests/cases/fourslash/extract-method18.ts @@ -12,7 +12,7 @@ goTo.select('a', 'b') edit.applyRefactor({ refactorName: "Extract Method", actionName: "scope_1", - actionDescription: "Extract function into global scope", + actionDescription: "Extract to function in global scope", }); verify.currentFileContentIs(`function fn() { const x = { m: 1 }; diff --git a/tests/cases/fourslash/extract-method19.ts b/tests/cases/fourslash/extract-method19.ts index e4fb3e6e111..da999fcc093 100644 --- a/tests/cases/fourslash/extract-method19.ts +++ b/tests/cases/fourslash/extract-method19.ts @@ -12,7 +12,7 @@ goTo.select('a', 'b') edit.applyRefactor({ refactorName: "Extract Method", actionName: "scope_0", - actionDescription: "Extract function into function 'fn'", + actionDescription: "Extract to inner function in function 'fn'", }); verify.currentFileContentIs(`function fn() { newFunction_1(); diff --git a/tests/cases/fourslash/extract-method2.ts b/tests/cases/fourslash/extract-method2.ts index 508836c4199..021716b6e48 100644 --- a/tests/cases/fourslash/extract-method2.ts +++ b/tests/cases/fourslash/extract-method2.ts @@ -13,7 +13,7 @@ goTo.select('start', 'end') edit.applyRefactor({ refactorName: "Extract Method", actionName: "scope_2", - actionDescription: "Extract function into global scope", + actionDescription: "Extract to function in global scope", }); verify.currentFileContentIs( `namespace NS { diff --git a/tests/cases/fourslash/extract-method21.ts b/tests/cases/fourslash/extract-method21.ts index c32df5b5979..f19d4b05912 100644 --- a/tests/cases/fourslash/extract-method21.ts +++ b/tests/cases/fourslash/extract-method21.ts @@ -15,7 +15,7 @@ verify.refactorAvailable('Extract Method'); edit.applyRefactor({ refactorName: "Extract Method", actionName: "scope_0", - actionDescription: "Extract function into class 'Foo'", + actionDescription: "Extract to method in class 'Foo'", }); verify.currentFileContentIs(`class Foo { diff --git a/tests/cases/fourslash/extract-method24.ts b/tests/cases/fourslash/extract-method24.ts index 615cb2ac4d2..e5f923bb80d 100644 --- a/tests/cases/fourslash/extract-method24.ts +++ b/tests/cases/fourslash/extract-method24.ts @@ -10,7 +10,7 @@ goTo.select('a', 'b') edit.applyRefactor({ refactorName: "Extract Method", actionName: "scope_1", - actionDescription: "Extract function into global scope", + actionDescription: "Extract to function in global scope", }); verify.currentFileContentIs(`function M() { let a = [1,2,3]; diff --git a/tests/cases/fourslash/extract-method25.ts b/tests/cases/fourslash/extract-method25.ts index 8585dd06fd4..d18d0691e61 100644 --- a/tests/cases/fourslash/extract-method25.ts +++ b/tests/cases/fourslash/extract-method25.ts @@ -11,7 +11,7 @@ goTo.select('a', 'b') edit.applyRefactor({ refactorName: "Extract Method", actionName: "scope_0", - actionDescription: "Extract function into function 'fn'", + actionDescription: "Extract to inner function in function 'fn'", }); verify.currentFileContentIs(`function fn() { var q = newFunction() diff --git a/tests/cases/fourslash/extract-method5.ts b/tests/cases/fourslash/extract-method5.ts index 8b0bd4fec6d..014dfb35d08 100644 --- a/tests/cases/fourslash/extract-method5.ts +++ b/tests/cases/fourslash/extract-method5.ts @@ -12,7 +12,7 @@ goTo.select('start', 'end'); edit.applyRefactor({ refactorName: "Extract Method", actionName: "scope_0", - actionDescription: "Extract function into function 'f'", + actionDescription: "Extract to inner function in function 'f'", }); // TODO: GH#18091 (fix formatting to use `2 ? 1 :` and not `2?1:`) verify.currentFileContentIs( diff --git a/tests/cases/fourslash/extract-method7.ts b/tests/cases/fourslash/extract-method7.ts index d10c7c3136e..d8459bf77ad 100644 --- a/tests/cases/fourslash/extract-method7.ts +++ b/tests/cases/fourslash/extract-method7.ts @@ -10,7 +10,7 @@ goTo.select('a', 'b'); edit.applyRefactor({ refactorName: "Extract Method", actionName: "scope_0", - actionDescription: "Extract function into global scope", + actionDescription: "Extract to function in global scope", }); verify.currentFileContentIs(`function fn(x = newFunction()) { } From f40f0db6766b06ce60832be7835b074897521192 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Sat, 9 Sep 2017 12:43:39 -0700 Subject: [PATCH 292/370] Preserve intersections on the source side in type inference --- 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 aa5fbd6421c..411b085508b 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -10578,7 +10578,7 @@ namespace ts { priority = savePriority; } } - else if (source.flags & TypeFlags.UnionOrIntersection) { + else if (source.flags & TypeFlags.Union) { // Source is a union or intersection type, infer from each constituent type const sourceTypes = (source).types; for (const sourceType of sourceTypes) { @@ -10587,7 +10587,7 @@ namespace ts { } else { source = getApparentType(source); - if (source.flags & TypeFlags.Object) { + if (source.flags & (TypeFlags.Object | TypeFlags.Intersection)) { const key = source.id + "," + target.id; if (visited && visited.get(key)) { return; @@ -10667,7 +10667,7 @@ namespace ts { function inferFromProperties(source: Type, target: Type) { const properties = getPropertiesOfObjectType(target); for (const targetProp of properties) { - const sourceProp = getPropertyOfObjectType(source, targetProp.escapedName); + const sourceProp = getPropertyOfType(source, targetProp.escapedName); if (sourceProp) { inferFromTypes(getTypeOfSymbol(sourceProp), getTypeOfSymbol(targetProp)); } From c6af0015a3639bbd50b7f347ed15d1408be7b945 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Sat, 9 Sep 2017 12:52:10 -0700 Subject: [PATCH 293/370] Fix fourslash tests --- tests/cases/fourslash/tsxQuickInfo6.ts | 2 +- tests/cases/fourslash/tsxQuickInfo7.ts | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/cases/fourslash/tsxQuickInfo6.ts b/tests/cases/fourslash/tsxQuickInfo6.ts index e125336e513..515928b7734 100644 --- a/tests/cases/fourslash/tsxQuickInfo6.ts +++ b/tests/cases/fourslash/tsxQuickInfo6.ts @@ -15,5 +15,5 @@ verify.quickInfos({ 1: "function ComponentSpecific(l: {\n prop: number;\n}): any", - 2: "function ComponentSpecific(l: {\n prop: number;\n}): any" + 2: "function ComponentSpecific(l: {\n prop: number & \"hello\";\n}): any" }); diff --git a/tests/cases/fourslash/tsxQuickInfo7.ts b/tests/cases/fourslash/tsxQuickInfo7.ts index d0ec1916b43..72de1128049 100644 --- a/tests/cases/fourslash/tsxQuickInfo7.ts +++ b/tests/cases/fourslash/tsxQuickInfo7.ts @@ -24,6 +24,6 @@ verify.quickInfos({ 3: "function OverloadComponent(attr: {\n b: string;\n a: boolean;\n}): any (+2 overloads)", 4: "function OverloadComponent(attr: {\n b: number;\n a?: string;\n \"ignore-prop\": boolean;\n}): any (+2 overloads)", 5: "function OverloadComponent(): any (+2 overloads)", - 6: "function OverloadComponent(attr: {\n b: string;\n a: boolean;\n}): any (+2 overloads)", - 7: "function OverloadComponent(attr: {\n b: number;\n a: boolean;\n}): any (+2 overloads)", + 6: "function OverloadComponent(attr: {\n b: string & number;\n a: boolean;\n}): any (+2 overloads)", + 7: "function OverloadComponent(attr: {\n b: number & string;\n a: boolean;\n}): any (+2 overloads)", }); From 9871c04e54a60c70680b44afad28ee8a2020366d Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Sat, 9 Sep 2017 13:06:28 -0700 Subject: [PATCH 294/370] Add tests --- .../reference/intersectionTypeInference2.js | 23 +++++++ .../intersectionTypeInference2.symbols | 56 +++++++++++++++++ .../intersectionTypeInference2.types | 62 +++++++++++++++++++ .../intersectionTypeInference2.ts | 15 +++++ 4 files changed, 156 insertions(+) create mode 100644 tests/baselines/reference/intersectionTypeInference2.js create mode 100644 tests/baselines/reference/intersectionTypeInference2.symbols create mode 100644 tests/baselines/reference/intersectionTypeInference2.types create mode 100644 tests/cases/conformance/types/intersection/intersectionTypeInference2.ts diff --git a/tests/baselines/reference/intersectionTypeInference2.js b/tests/baselines/reference/intersectionTypeInference2.js new file mode 100644 index 00000000000..804b8d85206 --- /dev/null +++ b/tests/baselines/reference/intersectionTypeInference2.js @@ -0,0 +1,23 @@ +//// [intersectionTypeInference2.ts] +declare function f(x: { prop: T }): T; + +declare const a: { prop: string } & { prop: number }; +declare const b: { prop: string & number }; + +f(a); // string & number +f(b); // string & number + +// Repro from #18354 + +declare function f2(obj: {[K in keyof T]: T[K]}, key: Key): T[Key]; + +declare const obj: { a: string } & { b: string }; +f2(obj, 'a'); +f2(obj, 'b'); + + +//// [intersectionTypeInference2.js] +f(a); // string & number +f(b); // string & number +f2(obj, 'a'); +f2(obj, 'b'); diff --git a/tests/baselines/reference/intersectionTypeInference2.symbols b/tests/baselines/reference/intersectionTypeInference2.symbols new file mode 100644 index 00000000000..b04de204de1 --- /dev/null +++ b/tests/baselines/reference/intersectionTypeInference2.symbols @@ -0,0 +1,56 @@ +=== tests/cases/conformance/types/intersection/intersectionTypeInference2.ts === +declare function f(x: { prop: T }): T; +>f : Symbol(f, Decl(intersectionTypeInference2.ts, 0, 0)) +>T : Symbol(T, Decl(intersectionTypeInference2.ts, 0, 19)) +>x : Symbol(x, Decl(intersectionTypeInference2.ts, 0, 22)) +>prop : Symbol(prop, Decl(intersectionTypeInference2.ts, 0, 26)) +>T : Symbol(T, Decl(intersectionTypeInference2.ts, 0, 19)) +>T : Symbol(T, Decl(intersectionTypeInference2.ts, 0, 19)) + +declare const a: { prop: string } & { prop: number }; +>a : Symbol(a, Decl(intersectionTypeInference2.ts, 2, 13)) +>prop : Symbol(prop, Decl(intersectionTypeInference2.ts, 2, 18)) +>prop : Symbol(prop, Decl(intersectionTypeInference2.ts, 2, 37)) + +declare const b: { prop: string & number }; +>b : Symbol(b, Decl(intersectionTypeInference2.ts, 3, 13)) +>prop : Symbol(prop, Decl(intersectionTypeInference2.ts, 3, 18)) + +f(a); // string & number +>f : Symbol(f, Decl(intersectionTypeInference2.ts, 0, 0)) +>a : Symbol(a, Decl(intersectionTypeInference2.ts, 2, 13)) + +f(b); // string & number +>f : Symbol(f, Decl(intersectionTypeInference2.ts, 0, 0)) +>b : Symbol(b, Decl(intersectionTypeInference2.ts, 3, 13)) + +// Repro from #18354 + +declare function f2(obj: {[K in keyof T]: T[K]}, key: Key): T[Key]; +>f2 : Symbol(f2, Decl(intersectionTypeInference2.ts, 6, 5)) +>T : Symbol(T, Decl(intersectionTypeInference2.ts, 10, 20)) +>Key : Symbol(Key, Decl(intersectionTypeInference2.ts, 10, 22)) +>T : Symbol(T, Decl(intersectionTypeInference2.ts, 10, 20)) +>obj : Symbol(obj, Decl(intersectionTypeInference2.ts, 10, 44)) +>K : Symbol(K, Decl(intersectionTypeInference2.ts, 10, 51)) +>T : Symbol(T, Decl(intersectionTypeInference2.ts, 10, 20)) +>T : Symbol(T, Decl(intersectionTypeInference2.ts, 10, 20)) +>K : Symbol(K, Decl(intersectionTypeInference2.ts, 10, 51)) +>key : Symbol(key, Decl(intersectionTypeInference2.ts, 10, 72)) +>Key : Symbol(Key, Decl(intersectionTypeInference2.ts, 10, 22)) +>T : Symbol(T, Decl(intersectionTypeInference2.ts, 10, 20)) +>Key : Symbol(Key, Decl(intersectionTypeInference2.ts, 10, 22)) + +declare const obj: { a: string } & { b: string }; +>obj : Symbol(obj, Decl(intersectionTypeInference2.ts, 12, 13)) +>a : Symbol(a, Decl(intersectionTypeInference2.ts, 12, 20)) +>b : Symbol(b, Decl(intersectionTypeInference2.ts, 12, 36)) + +f2(obj, 'a'); +>f2 : Symbol(f2, Decl(intersectionTypeInference2.ts, 6, 5)) +>obj : Symbol(obj, Decl(intersectionTypeInference2.ts, 12, 13)) + +f2(obj, 'b'); +>f2 : Symbol(f2, Decl(intersectionTypeInference2.ts, 6, 5)) +>obj : Symbol(obj, Decl(intersectionTypeInference2.ts, 12, 13)) + diff --git a/tests/baselines/reference/intersectionTypeInference2.types b/tests/baselines/reference/intersectionTypeInference2.types new file mode 100644 index 00000000000..41e1b3483c8 --- /dev/null +++ b/tests/baselines/reference/intersectionTypeInference2.types @@ -0,0 +1,62 @@ +=== tests/cases/conformance/types/intersection/intersectionTypeInference2.ts === +declare function f(x: { prop: T }): T; +>f : (x: { prop: T; }) => T +>T : T +>x : { prop: T; } +>prop : T +>T : T +>T : T + +declare const a: { prop: string } & { prop: number }; +>a : { prop: string; } & { prop: number; } +>prop : string +>prop : number + +declare const b: { prop: string & number }; +>b : { prop: string & number; } +>prop : string & number + +f(a); // string & number +>f(a) : string & number +>f : (x: { prop: T; }) => T +>a : { prop: string; } & { prop: number; } + +f(b); // string & number +>f(b) : string & number +>f : (x: { prop: T; }) => T +>b : { prop: string & number; } + +// Repro from #18354 + +declare function f2(obj: {[K in keyof T]: T[K]}, key: Key): T[Key]; +>f2 : (obj: { [K in keyof T]: T[K]; }, key: Key) => T[Key] +>T : T +>Key : Key +>T : T +>obj : { [K in keyof T]: T[K]; } +>K : K +>T : T +>T : T +>K : K +>key : Key +>Key : Key +>T : T +>Key : Key + +declare const obj: { a: string } & { b: string }; +>obj : { a: string; } & { b: string; } +>a : string +>b : string + +f2(obj, 'a'); +>f2(obj, 'a') : string +>f2 : (obj: { [K in keyof T]: T[K]; }, key: Key) => T[Key] +>obj : { a: string; } & { b: string; } +>'a' : "a" + +f2(obj, 'b'); +>f2(obj, 'b') : string +>f2 : (obj: { [K in keyof T]: T[K]; }, key: Key) => T[Key] +>obj : { a: string; } & { b: string; } +>'b' : "b" + diff --git a/tests/cases/conformance/types/intersection/intersectionTypeInference2.ts b/tests/cases/conformance/types/intersection/intersectionTypeInference2.ts new file mode 100644 index 00000000000..d32441cfee8 --- /dev/null +++ b/tests/cases/conformance/types/intersection/intersectionTypeInference2.ts @@ -0,0 +1,15 @@ +declare function f(x: { prop: T }): T; + +declare const a: { prop: string } & { prop: number }; +declare const b: { prop: string & number }; + +f(a); // string & number +f(b); // string & number + +// Repro from #18354 + +declare function f2(obj: {[K in keyof T]: T[K]}, key: Key): T[Key]; + +declare const obj: { a: string } & { b: string }; +f2(obj, 'a'); +f2(obj, 'b'); From dc8d47c51d794f681896e18c92347353b1deb864 Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Sat, 9 Sep 2017 15:56:11 -0700 Subject: [PATCH 295/370] Remove bisect.cmd, remove reference to missing dts, update usage (#18353) --- scripts/bisect-test.ts | 10 ++++++---- scripts/bisect.cmd | 30 ------------------------------ 2 files changed, 6 insertions(+), 34 deletions(-) delete mode 100644 scripts/bisect.cmd diff --git a/scripts/bisect-test.ts b/scripts/bisect-test.ts index 93a516bc899..948b272470f 100644 --- a/scripts/bisect-test.ts +++ b/scripts/bisect-test.ts @@ -1,5 +1,7 @@ -/// - +/** + * You should have ts-node installed globally before executing this, probably! + * Otherwise you'll need to compile this script before you start bisecting! + */ import cp = require('child_process'); import fs = require('fs'); @@ -42,8 +44,8 @@ jake.on('close', jakeExitCode => { }); } else { console.log('Unknown command line arguments.'); - console.log('Usage (compile errors): git bisect run scripts\bisect.js "foo.ts --module amd" compiles'); - console.log('Usage (emit check): git bisect run scripts\bisect.js bar.ts emits bar.js "_this = this"'); + console.log('Usage (compile errors): git bisect run ts-node scripts\bisect-test.ts "../failure.ts --module amd" !compiles'); + console.log('Usage (emit check): git bisect run ts-node scripts\bisect-test.ts bar.ts emits bar.js "_this = this"'); // Aborts the 'git bisect run' process process.exit(-1); } diff --git a/scripts/bisect.cmd b/scripts/bisect.cmd deleted file mode 100644 index 148722665d4..00000000000 --- a/scripts/bisect.cmd +++ /dev/null @@ -1,30 +0,0 @@ -echo off -IF NOT EXIST scripts\bisect.cmd GOTO :wrongdir -IF "%1" == "" GOTO :usage -IF "%1" == "GO" GOTO :run -GOTO :copy - -:usage -echo Usage: bisect GoodCommit BadCommit test.ts compiles -echo Usage: bisect GoodCommit BadCommit test.ts emits test.js "var x = 3" -GOTO :eof - -:copy -copy scripts\bisect.cmd scripts\bisect-fresh.cmd -scripts\bisect-fresh GO %* -GOTO :eof - -:run -call jake local -node built/local/tsc.js scripts/bisect-test.ts --module commonjs -git bisect start %2 %3 -git bisect run node scripts/bisect-test.js %4 %5 %6 %7 -del scripts\bisect-test.js -del scripts\bisect-fresh.cmd -GOTO :eof - -:wrongdir -@echo Run this file from the repo folder, not the scripts folder -GOTO :eof - -:eof \ No newline at end of file From eb80799ef0e2e47d8a1ae74f395d1fcadd263340 Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Sat, 9 Sep 2017 16:30:06 -0700 Subject: [PATCH 296/370] Care about esnext where we look for es2015 (#18331) * Care about esnext where we look for es2015 * Update diagnostic message to be more agnostic --- src/compiler/checker.ts | 12 ++-- src/compiler/diagnosticMessages.json | 4 +- src/compiler/factory.ts | 3 +- src/compiler/transformers/ts.ts | 3 +- .../reference/es6ExportAssignment.errors.txt | 4 +- .../reference/es6ExportAssignment2.errors.txt | 4 +- .../reference/es6ExportEquals.errors.txt | 4 +- .../es6ImportEqualsDeclaration.errors.txt | 8 +-- .../baselines/reference/es6modulekind.symbols | 2 +- tests/baselines/reference/es6modulekind.types | 2 +- .../es6modulekindWithES2015Target.symbols | 2 +- .../es6modulekindWithES2015Target.types | 2 +- .../es6modulekindWithES5Target.symbols | 2 +- .../es6modulekindWithES5Target.types | 2 +- .../es6modulekindWithES5Target10.errors.txt | 12 ++-- .../es6modulekindWithES5Target11.symbols | 2 +- .../es6modulekindWithES5Target11.types | 2 +- .../es6modulekindWithES5Target12.symbols | 2 +- .../es6modulekindWithES5Target12.types | 2 +- .../es6modulekindWithES5Target2.symbols | 2 +- .../es6modulekindWithES5Target2.types | 2 +- .../es6modulekindWithES5Target3.symbols | 2 +- .../es6modulekindWithES5Target3.types | 2 +- .../es6modulekindWithES5Target4.symbols | 2 +- .../es6modulekindWithES5Target4.types | 2 +- .../es6modulekindWithES5Target5.symbols | 2 +- .../es6modulekindWithES5Target5.types | 2 +- .../es6modulekindWithES5Target6.symbols | 2 +- .../es6modulekindWithES5Target6.types | 2 +- .../es6modulekindWithES5Target7.symbols | 2 +- .../es6modulekindWithES5Target7.types | 2 +- .../es6modulekindWithES5Target8.symbols | 2 +- .../es6modulekindWithES5Target8.types | 2 +- .../es6modulekindWithES5Target9.errors.txt | 12 ++-- tests/baselines/reference/esnextmodulekind.js | 22 ++++++ .../reference/esnextmodulekind.symbols | 15 ++++ .../reference/esnextmodulekind.types | 16 +++++ .../esnextmodulekindWithES2015Target.js | 22 ++++++ .../esnextmodulekindWithES2015Target.symbols | 15 ++++ .../esnextmodulekindWithES2015Target.types | 16 +++++ .../esnextmodulekindWithES5Target.js | 57 +++++++++++++++ .../esnextmodulekindWithES5Target.symbols | 46 ++++++++++++ .../esnextmodulekindWithES5Target.types | 50 +++++++++++++ ...esnextmodulekindWithES5Target10.errors.txt | 18 +++++ .../esnextmodulekindWithES5Target10.js | 9 +++ .../esnextmodulekindWithES5Target11.js | 32 +++++++++ .../esnextmodulekindWithES5Target11.symbols | 26 +++++++ .../esnextmodulekindWithES5Target11.types | 28 ++++++++ .../esnextmodulekindWithES5Target12.js | 70 +++++++++++++++++++ .../esnextmodulekindWithES5Target12.symbols | 61 ++++++++++++++++ .../esnextmodulekindWithES5Target12.types | 68 ++++++++++++++++++ .../esnextmodulekindWithES5Target2.js | 18 +++++ .../esnextmodulekindWithES5Target2.symbols | 14 ++++ .../esnextmodulekindWithES5Target2.types | 16 +++++ .../esnextmodulekindWithES5Target3.js | 28 ++++++++ .../esnextmodulekindWithES5Target3.symbols | 20 ++++++ .../esnextmodulekindWithES5Target3.types | 22 ++++++ .../esnextmodulekindWithES5Target4.js | 11 +++ .../esnextmodulekindWithES5Target4.symbols | 7 ++ .../esnextmodulekindWithES5Target4.types | 7 ++ .../esnextmodulekindWithES5Target5.js | 18 +++++ .../esnextmodulekindWithES5Target5.symbols | 14 ++++ .../esnextmodulekindWithES5Target5.types | 14 ++++ .../esnextmodulekindWithES5Target6.js | 24 +++++++ .../esnextmodulekindWithES5Target6.symbols | 16 +++++ .../esnextmodulekindWithES5Target6.types | 18 +++++ .../esnextmodulekindWithES5Target7.js | 15 ++++ .../esnextmodulekindWithES5Target7.symbols | 15 ++++ .../esnextmodulekindWithES5Target7.types | 16 +++++ .../esnextmodulekindWithES5Target8.js | 7 ++ .../esnextmodulekindWithES5Target8.symbols | 7 ++ .../esnextmodulekindWithES5Target8.types | 9 +++ .../esnextmodulekindWithES5Target9.errors.txt | 36 ++++++++++ .../esnextmodulekindWithES5Target9.js | 30 ++++++++ .../externalModules/es6}/es6modulekind.ts | 0 .../es6}/es6modulekindWithES2015Target.ts | 0 .../es6}/es6modulekindWithES5Target.ts | 0 .../es6}/es6modulekindWithES5Target10.ts | 0 .../es6}/es6modulekindWithES5Target11.ts | 0 .../es6}/es6modulekindWithES5Target12.ts | 0 .../es6}/es6modulekindWithES5Target2.ts | 0 .../es6}/es6modulekindWithES5Target3.ts | 0 .../es6}/es6modulekindWithES5Target4.ts | 0 .../es6}/es6modulekindWithES5Target5.ts | 0 .../es6}/es6modulekindWithES5Target6.ts | 0 .../es6}/es6modulekindWithES5Target7.ts | 0 .../es6}/es6modulekindWithES5Target8.ts | 0 .../es6}/es6modulekindWithES5Target9.ts | 0 .../esnext/esnextmodulekind.ts | 17 +++++ .../esnextmodulekindWithES2015Target.ts | 17 +++++ .../esnext/esnextmodulekindWithES5Target.ts | 22 ++++++ .../esnext/esnextmodulekindWithES5Target10.ts | 9 +++ .../esnext/esnextmodulekindWithES5Target11.ts | 12 ++++ .../esnext/esnextmodulekindWithES5Target12.ts | 39 +++++++++++ .../esnext/esnextmodulekindWithES5Target2.ts | 8 +++ .../esnext/esnextmodulekindWithES5Target3.ts | 12 ++++ .../esnext/esnextmodulekindWithES5Target4.ts | 5 ++ .../esnext/esnextmodulekindWithES5Target5.ts | 11 +++ .../esnext/esnextmodulekindWithES5Target6.ts | 11 +++ .../esnext/esnextmodulekindWithES5Target7.ts | 10 +++ .../esnext/esnextmodulekindWithES5Target8.ts | 5 ++ .../esnext/esnextmodulekindWithES5Target9.ts | 20 ++++++ 102 files changed, 1209 insertions(+), 56 deletions(-) create mode 100644 tests/baselines/reference/esnextmodulekind.js create mode 100644 tests/baselines/reference/esnextmodulekind.symbols create mode 100644 tests/baselines/reference/esnextmodulekind.types create mode 100644 tests/baselines/reference/esnextmodulekindWithES2015Target.js create mode 100644 tests/baselines/reference/esnextmodulekindWithES2015Target.symbols create mode 100644 tests/baselines/reference/esnextmodulekindWithES2015Target.types create mode 100644 tests/baselines/reference/esnextmodulekindWithES5Target.js create mode 100644 tests/baselines/reference/esnextmodulekindWithES5Target.symbols create mode 100644 tests/baselines/reference/esnextmodulekindWithES5Target.types create mode 100644 tests/baselines/reference/esnextmodulekindWithES5Target10.errors.txt create mode 100644 tests/baselines/reference/esnextmodulekindWithES5Target10.js create mode 100644 tests/baselines/reference/esnextmodulekindWithES5Target11.js create mode 100644 tests/baselines/reference/esnextmodulekindWithES5Target11.symbols create mode 100644 tests/baselines/reference/esnextmodulekindWithES5Target11.types create mode 100644 tests/baselines/reference/esnextmodulekindWithES5Target12.js create mode 100644 tests/baselines/reference/esnextmodulekindWithES5Target12.symbols create mode 100644 tests/baselines/reference/esnextmodulekindWithES5Target12.types create mode 100644 tests/baselines/reference/esnextmodulekindWithES5Target2.js create mode 100644 tests/baselines/reference/esnextmodulekindWithES5Target2.symbols create mode 100644 tests/baselines/reference/esnextmodulekindWithES5Target2.types create mode 100644 tests/baselines/reference/esnextmodulekindWithES5Target3.js create mode 100644 tests/baselines/reference/esnextmodulekindWithES5Target3.symbols create mode 100644 tests/baselines/reference/esnextmodulekindWithES5Target3.types create mode 100644 tests/baselines/reference/esnextmodulekindWithES5Target4.js create mode 100644 tests/baselines/reference/esnextmodulekindWithES5Target4.symbols create mode 100644 tests/baselines/reference/esnextmodulekindWithES5Target4.types create mode 100644 tests/baselines/reference/esnextmodulekindWithES5Target5.js create mode 100644 tests/baselines/reference/esnextmodulekindWithES5Target5.symbols create mode 100644 tests/baselines/reference/esnextmodulekindWithES5Target5.types create mode 100644 tests/baselines/reference/esnextmodulekindWithES5Target6.js create mode 100644 tests/baselines/reference/esnextmodulekindWithES5Target6.symbols create mode 100644 tests/baselines/reference/esnextmodulekindWithES5Target6.types create mode 100644 tests/baselines/reference/esnextmodulekindWithES5Target7.js create mode 100644 tests/baselines/reference/esnextmodulekindWithES5Target7.symbols create mode 100644 tests/baselines/reference/esnextmodulekindWithES5Target7.types create mode 100644 tests/baselines/reference/esnextmodulekindWithES5Target8.js create mode 100644 tests/baselines/reference/esnextmodulekindWithES5Target8.symbols create mode 100644 tests/baselines/reference/esnextmodulekindWithES5Target8.types create mode 100644 tests/baselines/reference/esnextmodulekindWithES5Target9.errors.txt create mode 100644 tests/baselines/reference/esnextmodulekindWithES5Target9.js rename tests/cases/{compiler => conformance/externalModules/es6}/es6modulekind.ts (100%) rename tests/cases/{compiler => conformance/externalModules/es6}/es6modulekindWithES2015Target.ts (100%) rename tests/cases/{compiler => conformance/externalModules/es6}/es6modulekindWithES5Target.ts (100%) rename tests/cases/{compiler => conformance/externalModules/es6}/es6modulekindWithES5Target10.ts (100%) rename tests/cases/{compiler => conformance/externalModules/es6}/es6modulekindWithES5Target11.ts (100%) rename tests/cases/{compiler => conformance/externalModules/es6}/es6modulekindWithES5Target12.ts (100%) rename tests/cases/{compiler => conformance/externalModules/es6}/es6modulekindWithES5Target2.ts (100%) rename tests/cases/{compiler => conformance/externalModules/es6}/es6modulekindWithES5Target3.ts (100%) rename tests/cases/{compiler => conformance/externalModules/es6}/es6modulekindWithES5Target4.ts (100%) rename tests/cases/{compiler => conformance/externalModules/es6}/es6modulekindWithES5Target5.ts (100%) rename tests/cases/{compiler => conformance/externalModules/es6}/es6modulekindWithES5Target6.ts (100%) rename tests/cases/{compiler => conformance/externalModules/es6}/es6modulekindWithES5Target7.ts (100%) rename tests/cases/{compiler => conformance/externalModules/es6}/es6modulekindWithES5Target8.ts (100%) rename tests/cases/{compiler => conformance/externalModules/es6}/es6modulekindWithES5Target9.ts (100%) create mode 100644 tests/cases/conformance/externalModules/esnext/esnextmodulekind.ts create mode 100644 tests/cases/conformance/externalModules/esnext/esnextmodulekindWithES2015Target.ts create mode 100644 tests/cases/conformance/externalModules/esnext/esnextmodulekindWithES5Target.ts create mode 100644 tests/cases/conformance/externalModules/esnext/esnextmodulekindWithES5Target10.ts create mode 100644 tests/cases/conformance/externalModules/esnext/esnextmodulekindWithES5Target11.ts create mode 100644 tests/cases/conformance/externalModules/esnext/esnextmodulekindWithES5Target12.ts create mode 100644 tests/cases/conformance/externalModules/esnext/esnextmodulekindWithES5Target2.ts create mode 100644 tests/cases/conformance/externalModules/esnext/esnextmodulekindWithES5Target3.ts create mode 100644 tests/cases/conformance/externalModules/esnext/esnextmodulekindWithES5Target4.ts create mode 100644 tests/cases/conformance/externalModules/esnext/esnextmodulekindWithES5Target5.ts create mode 100644 tests/cases/conformance/externalModules/esnext/esnextmodulekindWithES5Target6.ts create mode 100644 tests/cases/conformance/externalModules/esnext/esnextmodulekindWithES5Target7.ts create mode 100644 tests/cases/conformance/externalModules/esnext/esnextmodulekindWithES5Target8.ts create mode 100644 tests/cases/conformance/externalModules/esnext/esnextmodulekindWithES5Target9.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index aa5fbd6421c..ff5d1c661e8 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -22149,9 +22149,9 @@ namespace ts { } } else { - if (modulekind === ModuleKind.ES2015 && !isInAmbientContext(node)) { + if (modulekind >= ModuleKind.ES2015 && !isInAmbientContext(node)) { // Import equals declaration is deprecated in es6 or above - grammarErrorOnNode(node, Diagnostics.Import_assignment_cannot_be_used_when_targeting_ECMAScript_2015_modules_Consider_using_import_Asterisk_as_ns_from_mod_import_a_from_mod_import_d_from_mod_or_another_module_format_instead); + grammarErrorOnNode(node, Diagnostics.Import_assignment_cannot_be_used_when_targeting_ECMAScript_modules_Consider_using_import_Asterisk_as_ns_from_mod_import_a_from_mod_import_d_from_mod_or_another_module_format_instead); } } } @@ -22187,7 +22187,7 @@ namespace ts { error(node.moduleSpecifier, Diagnostics.Module_0_uses_export_and_cannot_be_used_with_export_Asterisk, symbolToString(moduleSymbol)); } - if (modulekind !== ModuleKind.System && modulekind !== ModuleKind.ES2015) { + if (modulekind !== ModuleKind.System && modulekind !== ModuleKind.ES2015 && modulekind !== ModuleKind.ESNext) { checkExternalEmitHelpers(node, ExternalEmitHelpers.ExportStar); } } @@ -22249,9 +22249,9 @@ namespace ts { checkExternalModuleExports(container); if (node.isExportEquals && !isInAmbientContext(node)) { - if (modulekind === ModuleKind.ES2015) { + if (modulekind >= ModuleKind.ES2015) { // export assignment is not supported in es6 modules - grammarErrorOnNode(node, Diagnostics.Export_assignment_cannot_be_used_when_targeting_ECMAScript_2015_modules_Consider_using_export_default_or_another_module_format_instead); + grammarErrorOnNode(node, Diagnostics.Export_assignment_cannot_be_used_when_targeting_ECMAScript_modules_Consider_using_export_default_or_another_module_format_instead); } else if (modulekind === ModuleKind.System) { // system modules does not support export assignment @@ -24851,7 +24851,7 @@ namespace ts { } } - if (compilerOptions.module !== ModuleKind.ES2015 && compilerOptions.module !== ModuleKind.System && !compilerOptions.noEmit && + if (compilerOptions.module !== ModuleKind.ES2015 && compilerOptions.module !== ModuleKind.ESNext && compilerOptions.module !== ModuleKind.System && !compilerOptions.noEmit && !isInAmbientContext(node.parent.parent) && hasModifier(node.parent.parent, ModifierFlags.Export)) { checkESModuleMarker(node.name); } diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index c7713839ce3..14fb7499f8f 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -627,11 +627,11 @@ "category": "Error", "code": 1200 }, - "Import assignment cannot be used when targeting ECMAScript 2015 modules. Consider using 'import * as ns from \"mod\"', 'import {a} from \"mod\"', 'import d from \"mod\"', or another module format instead.": { + "Import assignment cannot be used when targeting ECMAScript modules. Consider using 'import * as ns from \"mod\"', 'import {a} from \"mod\"', 'import d from \"mod\"', or another module format instead.": { "category": "Error", "code": 1202 }, - "Export assignment cannot be used when targeting ECMAScript 2015 modules. Consider using 'export default' or another module format instead.": { + "Export assignment cannot be used when targeting ECMAScript modules. Consider using 'export default' or another module format instead.": { "category": "Error", "code": 1203 }, diff --git a/src/compiler/factory.ts b/src/compiler/factory.ts index 2bf6d6e879d..0369be30076 100644 --- a/src/compiler/factory.ts +++ b/src/compiler/factory.ts @@ -4158,7 +4158,8 @@ namespace ts { const moduleKind = getEmitModuleKind(compilerOptions); let create = hasExportStarsToExportValues && moduleKind !== ModuleKind.System - && moduleKind !== ModuleKind.ES2015; + && moduleKind !== ModuleKind.ES2015 + && moduleKind !== ModuleKind.ESNext; if (!create) { const helpers = getEmitHelpers(node); if (helpers) { diff --git a/src/compiler/transformers/ts.ts b/src/compiler/transformers/ts.ts index ebce55aa7e5..8640c642675 100644 --- a/src/compiler/transformers/ts.ts +++ b/src/compiler/transformers/ts.ts @@ -521,7 +521,7 @@ namespace ts { function visitSourceFile(node: SourceFile) { const alwaysStrict = (compilerOptions.alwaysStrict === undefined ? compilerOptions.strict : compilerOptions.alwaysStrict) && - !(isExternalModule(node) && moduleKind === ModuleKind.ES2015); + !(isExternalModule(node) && moduleKind >= ModuleKind.ES2015); return updateSourceFileNode( node, visitLexicalEnvironment(node.statements, sourceElementVisitor, context, /*start*/ 0, alwaysStrict)); @@ -2665,6 +2665,7 @@ namespace ts { return isExportOfNamespace(node) || (isExternalModuleExport(node) && moduleKind !== ModuleKind.ES2015 + && moduleKind !== ModuleKind.ESNext && moduleKind !== ModuleKind.System); } diff --git a/tests/baselines/reference/es6ExportAssignment.errors.txt b/tests/baselines/reference/es6ExportAssignment.errors.txt index 55a150f47ad..eea3299f56e 100644 --- a/tests/baselines/reference/es6ExportAssignment.errors.txt +++ b/tests/baselines/reference/es6ExportAssignment.errors.txt @@ -1,8 +1,8 @@ -tests/cases/compiler/es6ExportAssignment.ts(2,1): error TS1203: Export assignment cannot be used when targeting ECMAScript 2015 modules. Consider using 'export default' or another module format instead. +tests/cases/compiler/es6ExportAssignment.ts(2,1): error TS1203: Export assignment cannot be used when targeting ECMAScript modules. Consider using 'export default' or another module format instead. ==== tests/cases/compiler/es6ExportAssignment.ts (1 errors) ==== var a = 10; export = a; ~~~~~~~~~~~ -!!! error TS1203: Export assignment cannot be used when targeting ECMAScript 2015 modules. Consider using 'export default' or another module format instead. \ No newline at end of file +!!! error TS1203: Export assignment cannot be used when targeting ECMAScript modules. Consider using 'export default' or another module format instead. \ No newline at end of file diff --git a/tests/baselines/reference/es6ExportAssignment2.errors.txt b/tests/baselines/reference/es6ExportAssignment2.errors.txt index 9065f9ba6ce..c735da428cb 100644 --- a/tests/baselines/reference/es6ExportAssignment2.errors.txt +++ b/tests/baselines/reference/es6ExportAssignment2.errors.txt @@ -1,11 +1,11 @@ -tests/cases/compiler/a.ts(2,1): error TS1203: Export assignment cannot be used when targeting ECMAScript 2015 modules. Consider using 'export default' or another module format instead. +tests/cases/compiler/a.ts(2,1): error TS1203: Export assignment cannot be used when targeting ECMAScript modules. Consider using 'export default' or another module format instead. ==== tests/cases/compiler/a.ts (1 errors) ==== var a = 10; export = a; // Error: export = not allowed in ES6 ~~~~~~~~~~~ -!!! error TS1203: Export assignment cannot be used when targeting ECMAScript 2015 modules. Consider using 'export default' or another module format instead. +!!! error TS1203: Export assignment cannot be used when targeting ECMAScript modules. Consider using 'export default' or another module format instead. ==== tests/cases/compiler/b.ts (0 errors) ==== import * as a from "a"; diff --git a/tests/baselines/reference/es6ExportEquals.errors.txt b/tests/baselines/reference/es6ExportEquals.errors.txt index fa6e8519918..05f093db853 100644 --- a/tests/baselines/reference/es6ExportEquals.errors.txt +++ b/tests/baselines/reference/es6ExportEquals.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/es6ExportEquals.ts(3,1): error TS1203: Export assignment cannot be used when targeting ECMAScript 2015 modules. Consider using 'export default' or another module format instead. +tests/cases/compiler/es6ExportEquals.ts(3,1): error TS1203: Export assignment cannot be used when targeting ECMAScript modules. Consider using 'export default' or another module format instead. tests/cases/compiler/es6ExportEquals.ts(3,1): error TS2309: An export assignment cannot be used in a module with other exported elements. @@ -7,7 +7,7 @@ tests/cases/compiler/es6ExportEquals.ts(3,1): error TS2309: An export assignment export = f; ~~~~~~~~~~~ -!!! error TS1203: Export assignment cannot be used when targeting ECMAScript 2015 modules. Consider using 'export default' or another module format instead. +!!! error TS1203: Export assignment cannot be used when targeting ECMAScript modules. Consider using 'export default' or another module format instead. ~~~~~~~~~~~ !!! error TS2309: An export assignment cannot be used in a module with other exported elements. \ No newline at end of file diff --git a/tests/baselines/reference/es6ImportEqualsDeclaration.errors.txt b/tests/baselines/reference/es6ImportEqualsDeclaration.errors.txt index 37870a2a366..696c71950cd 100644 --- a/tests/baselines/reference/es6ImportEqualsDeclaration.errors.txt +++ b/tests/baselines/reference/es6ImportEqualsDeclaration.errors.txt @@ -1,14 +1,14 @@ -tests/cases/compiler/client.ts(1,1): error TS1202: Import assignment cannot be used when targeting ECMAScript 2015 modules. Consider using 'import * as ns from "mod"', 'import {a} from "mod"', 'import d from "mod"', or another module format instead. -tests/cases/compiler/server.ts(2,1): error TS1203: Export assignment cannot be used when targeting ECMAScript 2015 modules. Consider using 'export default' or another module format instead. +tests/cases/compiler/client.ts(1,1): error TS1202: Import assignment cannot be used when targeting ECMAScript modules. Consider using 'import * as ns from "mod"', 'import {a} from "mod"', 'import d from "mod"', or another module format instead. +tests/cases/compiler/server.ts(2,1): error TS1203: Export assignment cannot be used when targeting ECMAScript modules. Consider using 'export default' or another module format instead. ==== tests/cases/compiler/client.ts (1 errors) ==== import a = require("server"); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS1202: Import assignment cannot be used when targeting ECMAScript 2015 modules. Consider using 'import * as ns from "mod"', 'import {a} from "mod"', 'import d from "mod"', or another module format instead. +!!! error TS1202: Import assignment cannot be used when targeting ECMAScript modules. Consider using 'import * as ns from "mod"', 'import {a} from "mod"', 'import d from "mod"', or another module format instead. ==== tests/cases/compiler/server.ts (1 errors) ==== var a = 10; export = a; ~~~~~~~~~~~ -!!! error TS1203: Export assignment cannot be used when targeting ECMAScript 2015 modules. Consider using 'export default' or another module format instead. +!!! error TS1203: Export assignment cannot be used when targeting ECMAScript modules. Consider using 'export default' or another module format instead. \ No newline at end of file diff --git a/tests/baselines/reference/es6modulekind.symbols b/tests/baselines/reference/es6modulekind.symbols index cc563db6826..185969969a1 100644 --- a/tests/baselines/reference/es6modulekind.symbols +++ b/tests/baselines/reference/es6modulekind.symbols @@ -1,4 +1,4 @@ -=== tests/cases/compiler/es6modulekind.ts === +=== tests/cases/conformance/externalModules/es6/es6modulekind.ts === export default class A >A : Symbol(A, Decl(es6modulekind.ts, 0, 0)) { diff --git a/tests/baselines/reference/es6modulekind.types b/tests/baselines/reference/es6modulekind.types index a8b6fa077f0..4b150f00729 100644 --- a/tests/baselines/reference/es6modulekind.types +++ b/tests/baselines/reference/es6modulekind.types @@ -1,4 +1,4 @@ -=== tests/cases/compiler/es6modulekind.ts === +=== tests/cases/conformance/externalModules/es6/es6modulekind.ts === export default class A >A : A { diff --git a/tests/baselines/reference/es6modulekindWithES2015Target.symbols b/tests/baselines/reference/es6modulekindWithES2015Target.symbols index b7cf2e19c74..9c9f1e904ad 100644 --- a/tests/baselines/reference/es6modulekindWithES2015Target.symbols +++ b/tests/baselines/reference/es6modulekindWithES2015Target.symbols @@ -1,4 +1,4 @@ -=== tests/cases/compiler/es6modulekindWithES2015Target.ts === +=== tests/cases/conformance/externalModules/es6/es6modulekindWithES2015Target.ts === export default class A >A : Symbol(A, Decl(es6modulekindWithES2015Target.ts, 0, 0)) { diff --git a/tests/baselines/reference/es6modulekindWithES2015Target.types b/tests/baselines/reference/es6modulekindWithES2015Target.types index 018d06e0745..46f44784d74 100644 --- a/tests/baselines/reference/es6modulekindWithES2015Target.types +++ b/tests/baselines/reference/es6modulekindWithES2015Target.types @@ -1,4 +1,4 @@ -=== tests/cases/compiler/es6modulekindWithES2015Target.ts === +=== tests/cases/conformance/externalModules/es6/es6modulekindWithES2015Target.ts === export default class A >A : A { diff --git a/tests/baselines/reference/es6modulekindWithES5Target.symbols b/tests/baselines/reference/es6modulekindWithES5Target.symbols index edba44a2223..2b91794b97e 100644 --- a/tests/baselines/reference/es6modulekindWithES5Target.symbols +++ b/tests/baselines/reference/es6modulekindWithES5Target.symbols @@ -1,4 +1,4 @@ -=== tests/cases/compiler/es6modulekindWithES5Target.ts === +=== tests/cases/conformance/externalModules/es6/es6modulekindWithES5Target.ts === export class C { >C : Symbol(C, Decl(es6modulekindWithES5Target.ts, 0, 0)) diff --git a/tests/baselines/reference/es6modulekindWithES5Target.types b/tests/baselines/reference/es6modulekindWithES5Target.types index 018114be43d..9d9b7704552 100644 --- a/tests/baselines/reference/es6modulekindWithES5Target.types +++ b/tests/baselines/reference/es6modulekindWithES5Target.types @@ -1,4 +1,4 @@ -=== tests/cases/compiler/es6modulekindWithES5Target.ts === +=== tests/cases/conformance/externalModules/es6/es6modulekindWithES5Target.ts === export class C { >C : C diff --git a/tests/baselines/reference/es6modulekindWithES5Target10.errors.txt b/tests/baselines/reference/es6modulekindWithES5Target10.errors.txt index 16dfab25794..d4164e56491 100644 --- a/tests/baselines/reference/es6modulekindWithES5Target10.errors.txt +++ b/tests/baselines/reference/es6modulekindWithES5Target10.errors.txt @@ -1,12 +1,12 @@ -tests/cases/compiler/es6modulekindWithES5Target10.ts(1,1): error TS1202: Import assignment cannot be used when targeting ECMAScript 2015 modules. Consider using 'import * as ns from "mod"', 'import {a} from "mod"', 'import d from "mod"', or another module format instead. -tests/cases/compiler/es6modulekindWithES5Target10.ts(1,20): error TS2307: Cannot find module 'mod'. -tests/cases/compiler/es6modulekindWithES5Target10.ts(6,1): error TS1203: Export assignment cannot be used when targeting ECMAScript 2015 modules. Consider using 'export default' or another module format instead. +tests/cases/conformance/externalModules/es6/es6modulekindWithES5Target10.ts(1,1): error TS1202: Import assignment cannot be used when targeting ECMAScript modules. Consider using 'import * as ns from "mod"', 'import {a} from "mod"', 'import d from "mod"', or another module format instead. +tests/cases/conformance/externalModules/es6/es6modulekindWithES5Target10.ts(1,20): error TS2307: Cannot find module 'mod'. +tests/cases/conformance/externalModules/es6/es6modulekindWithES5Target10.ts(6,1): error TS1203: Export assignment cannot be used when targeting ECMAScript modules. Consider using 'export default' or another module format instead. -==== tests/cases/compiler/es6modulekindWithES5Target10.ts (3 errors) ==== +==== tests/cases/conformance/externalModules/es6/es6modulekindWithES5Target10.ts (3 errors) ==== import i = require("mod"); // Error; ~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS1202: Import assignment cannot be used when targeting ECMAScript 2015 modules. Consider using 'import * as ns from "mod"', 'import {a} from "mod"', 'import d from "mod"', or another module format instead. +!!! error TS1202: Import assignment cannot be used when targeting ECMAScript modules. Consider using 'import * as ns from "mod"', 'import {a} from "mod"', 'import d from "mod"', or another module format instead. ~~~~~ !!! error TS2307: Cannot find module 'mod'. @@ -15,4 +15,4 @@ tests/cases/compiler/es6modulekindWithES5Target10.ts(6,1): error TS1203: Export } export = N; // Error ~~~~~~~~~~~ -!!! error TS1203: Export assignment cannot be used when targeting ECMAScript 2015 modules. Consider using 'export default' or another module format instead. \ No newline at end of file +!!! error TS1203: Export assignment cannot be used when targeting ECMAScript modules. Consider using 'export default' or another module format instead. \ No newline at end of file diff --git a/tests/baselines/reference/es6modulekindWithES5Target11.symbols b/tests/baselines/reference/es6modulekindWithES5Target11.symbols index 39c351a0e5e..429a3982c10 100644 --- a/tests/baselines/reference/es6modulekindWithES5Target11.symbols +++ b/tests/baselines/reference/es6modulekindWithES5Target11.symbols @@ -1,4 +1,4 @@ -=== tests/cases/compiler/es6modulekindWithES5Target11.ts === +=== tests/cases/conformance/externalModules/es6/es6modulekindWithES5Target11.ts === declare function foo(...args: any[]): any; >foo : Symbol(foo, Decl(es6modulekindWithES5Target11.ts, 0, 0)) >args : Symbol(args, Decl(es6modulekindWithES5Target11.ts, 0, 21)) diff --git a/tests/baselines/reference/es6modulekindWithES5Target11.types b/tests/baselines/reference/es6modulekindWithES5Target11.types index 497d8e0af78..9ace8e2d37d 100644 --- a/tests/baselines/reference/es6modulekindWithES5Target11.types +++ b/tests/baselines/reference/es6modulekindWithES5Target11.types @@ -1,4 +1,4 @@ -=== tests/cases/compiler/es6modulekindWithES5Target11.ts === +=== tests/cases/conformance/externalModules/es6/es6modulekindWithES5Target11.ts === declare function foo(...args: any[]): any; >foo : (...args: any[]) => any >args : any[] diff --git a/tests/baselines/reference/es6modulekindWithES5Target12.symbols b/tests/baselines/reference/es6modulekindWithES5Target12.symbols index a16baab08ce..dd8746ecad3 100644 --- a/tests/baselines/reference/es6modulekindWithES5Target12.symbols +++ b/tests/baselines/reference/es6modulekindWithES5Target12.symbols @@ -1,4 +1,4 @@ -=== tests/cases/compiler/es6modulekindWithES5Target12.ts === +=== tests/cases/conformance/externalModules/es6/es6modulekindWithES5Target12.ts === export class C { >C : Symbol(C, Decl(es6modulekindWithES5Target12.ts, 0, 0), Decl(es6modulekindWithES5Target12.ts, 1, 1)) } diff --git a/tests/baselines/reference/es6modulekindWithES5Target12.types b/tests/baselines/reference/es6modulekindWithES5Target12.types index 7d38adb3f46..ecb29ca021a 100644 --- a/tests/baselines/reference/es6modulekindWithES5Target12.types +++ b/tests/baselines/reference/es6modulekindWithES5Target12.types @@ -1,4 +1,4 @@ -=== tests/cases/compiler/es6modulekindWithES5Target12.ts === +=== tests/cases/conformance/externalModules/es6/es6modulekindWithES5Target12.ts === export class C { >C : C } diff --git a/tests/baselines/reference/es6modulekindWithES5Target2.symbols b/tests/baselines/reference/es6modulekindWithES5Target2.symbols index 66f1375e6e5..ff0f5c4388e 100644 --- a/tests/baselines/reference/es6modulekindWithES5Target2.symbols +++ b/tests/baselines/reference/es6modulekindWithES5Target2.symbols @@ -1,4 +1,4 @@ -=== tests/cases/compiler/es6modulekindWithES5Target2.ts === +=== tests/cases/conformance/externalModules/es6/es6modulekindWithES5Target2.ts === export default class C { >C : Symbol(C, Decl(es6modulekindWithES5Target2.ts, 0, 0)) diff --git a/tests/baselines/reference/es6modulekindWithES5Target2.types b/tests/baselines/reference/es6modulekindWithES5Target2.types index 6540471c890..d120f0c5b56 100644 --- a/tests/baselines/reference/es6modulekindWithES5Target2.types +++ b/tests/baselines/reference/es6modulekindWithES5Target2.types @@ -1,4 +1,4 @@ -=== tests/cases/compiler/es6modulekindWithES5Target2.ts === +=== tests/cases/conformance/externalModules/es6/es6modulekindWithES5Target2.ts === export default class C { >C : C diff --git a/tests/baselines/reference/es6modulekindWithES5Target3.symbols b/tests/baselines/reference/es6modulekindWithES5Target3.symbols index cc0b1ecc89d..8dc8b658a28 100644 --- a/tests/baselines/reference/es6modulekindWithES5Target3.symbols +++ b/tests/baselines/reference/es6modulekindWithES5Target3.symbols @@ -1,4 +1,4 @@ -=== tests/cases/compiler/es6modulekindWithES5Target3.ts === +=== tests/cases/conformance/externalModules/es6/es6modulekindWithES5Target3.ts === declare function foo(...args: any[]): any; >foo : Symbol(foo, Decl(es6modulekindWithES5Target3.ts, 0, 0)) >args : Symbol(args, Decl(es6modulekindWithES5Target3.ts, 0, 21)) diff --git a/tests/baselines/reference/es6modulekindWithES5Target3.types b/tests/baselines/reference/es6modulekindWithES5Target3.types index d2cc641b732..f7059999daf 100644 --- a/tests/baselines/reference/es6modulekindWithES5Target3.types +++ b/tests/baselines/reference/es6modulekindWithES5Target3.types @@ -1,4 +1,4 @@ -=== tests/cases/compiler/es6modulekindWithES5Target3.ts === +=== tests/cases/conformance/externalModules/es6/es6modulekindWithES5Target3.ts === declare function foo(...args: any[]): any; >foo : (...args: any[]) => any >args : any[] diff --git a/tests/baselines/reference/es6modulekindWithES5Target4.symbols b/tests/baselines/reference/es6modulekindWithES5Target4.symbols index f7ff2d07016..4b672f1f3f1 100644 --- a/tests/baselines/reference/es6modulekindWithES5Target4.symbols +++ b/tests/baselines/reference/es6modulekindWithES5Target4.symbols @@ -1,4 +1,4 @@ -=== tests/cases/compiler/es6modulekindWithES5Target4.ts === +=== tests/cases/conformance/externalModules/es6/es6modulekindWithES5Target4.ts === class E { } >E : Symbol(E, Decl(es6modulekindWithES5Target4.ts, 0, 0)) diff --git a/tests/baselines/reference/es6modulekindWithES5Target4.types b/tests/baselines/reference/es6modulekindWithES5Target4.types index 20bea4e397b..4429c443d36 100644 --- a/tests/baselines/reference/es6modulekindWithES5Target4.types +++ b/tests/baselines/reference/es6modulekindWithES5Target4.types @@ -1,4 +1,4 @@ -=== tests/cases/compiler/es6modulekindWithES5Target4.ts === +=== tests/cases/conformance/externalModules/es6/es6modulekindWithES5Target4.ts === class E { } >E : E diff --git a/tests/baselines/reference/es6modulekindWithES5Target5.symbols b/tests/baselines/reference/es6modulekindWithES5Target5.symbols index d4401b86d6b..cc6833f753b 100644 --- a/tests/baselines/reference/es6modulekindWithES5Target5.symbols +++ b/tests/baselines/reference/es6modulekindWithES5Target5.symbols @@ -1,4 +1,4 @@ -=== tests/cases/compiler/es6modulekindWithES5Target5.ts === +=== tests/cases/conformance/externalModules/es6/es6modulekindWithES5Target5.ts === export enum E1 { >E1 : Symbol(E1, Decl(es6modulekindWithES5Target5.ts, 0, 0)) diff --git a/tests/baselines/reference/es6modulekindWithES5Target5.types b/tests/baselines/reference/es6modulekindWithES5Target5.types index 5abe6f5b165..b5e69598788 100644 --- a/tests/baselines/reference/es6modulekindWithES5Target5.types +++ b/tests/baselines/reference/es6modulekindWithES5Target5.types @@ -1,4 +1,4 @@ -=== tests/cases/compiler/es6modulekindWithES5Target5.ts === +=== tests/cases/conformance/externalModules/es6/es6modulekindWithES5Target5.ts === export enum E1 { >E1 : E1 diff --git a/tests/baselines/reference/es6modulekindWithES5Target6.symbols b/tests/baselines/reference/es6modulekindWithES5Target6.symbols index b07af7462ba..6f17707b708 100644 --- a/tests/baselines/reference/es6modulekindWithES5Target6.symbols +++ b/tests/baselines/reference/es6modulekindWithES5Target6.symbols @@ -1,4 +1,4 @@ -=== tests/cases/compiler/es6modulekindWithES5Target6.ts === +=== tests/cases/conformance/externalModules/es6/es6modulekindWithES5Target6.ts === export function f1(d = 0) { >f1 : Symbol(f1, Decl(es6modulekindWithES5Target6.ts, 0, 0)) >d : Symbol(d, Decl(es6modulekindWithES5Target6.ts, 0, 19)) diff --git a/tests/baselines/reference/es6modulekindWithES5Target6.types b/tests/baselines/reference/es6modulekindWithES5Target6.types index 5296f4730b3..611edc9bbaa 100644 --- a/tests/baselines/reference/es6modulekindWithES5Target6.types +++ b/tests/baselines/reference/es6modulekindWithES5Target6.types @@ -1,4 +1,4 @@ -=== tests/cases/compiler/es6modulekindWithES5Target6.ts === +=== tests/cases/conformance/externalModules/es6/es6modulekindWithES5Target6.ts === export function f1(d = 0) { >f1 : (d?: number) => void >d : number diff --git a/tests/baselines/reference/es6modulekindWithES5Target7.symbols b/tests/baselines/reference/es6modulekindWithES5Target7.symbols index bcc89efaeab..0cdb72fcc54 100644 --- a/tests/baselines/reference/es6modulekindWithES5Target7.symbols +++ b/tests/baselines/reference/es6modulekindWithES5Target7.symbols @@ -1,4 +1,4 @@ -=== tests/cases/compiler/es6modulekindWithES5Target7.ts === +=== tests/cases/conformance/externalModules/es6/es6modulekindWithES5Target7.ts === export namespace N { >N : Symbol(N, Decl(es6modulekindWithES5Target7.ts, 0, 0)) diff --git a/tests/baselines/reference/es6modulekindWithES5Target7.types b/tests/baselines/reference/es6modulekindWithES5Target7.types index 0e534b85c54..5a386abe7e6 100644 --- a/tests/baselines/reference/es6modulekindWithES5Target7.types +++ b/tests/baselines/reference/es6modulekindWithES5Target7.types @@ -1,4 +1,4 @@ -=== tests/cases/compiler/es6modulekindWithES5Target7.ts === +=== tests/cases/conformance/externalModules/es6/es6modulekindWithES5Target7.ts === export namespace N { >N : typeof N diff --git a/tests/baselines/reference/es6modulekindWithES5Target8.symbols b/tests/baselines/reference/es6modulekindWithES5Target8.symbols index 1a5e54ce96d..a487c30a444 100644 --- a/tests/baselines/reference/es6modulekindWithES5Target8.symbols +++ b/tests/baselines/reference/es6modulekindWithES5Target8.symbols @@ -1,4 +1,4 @@ -=== tests/cases/compiler/es6modulekindWithES5Target8.ts === +=== tests/cases/conformance/externalModules/es6/es6modulekindWithES5Target8.ts === export const c = 0; >c : Symbol(c, Decl(es6modulekindWithES5Target8.ts, 0, 12)) diff --git a/tests/baselines/reference/es6modulekindWithES5Target8.types b/tests/baselines/reference/es6modulekindWithES5Target8.types index 4bfea977016..8a91f27b10d 100644 --- a/tests/baselines/reference/es6modulekindWithES5Target8.types +++ b/tests/baselines/reference/es6modulekindWithES5Target8.types @@ -1,4 +1,4 @@ -=== tests/cases/compiler/es6modulekindWithES5Target8.ts === +=== tests/cases/conformance/externalModules/es6/es6modulekindWithES5Target8.ts === export const c = 0; >c : 0 >0 : 0 diff --git a/tests/baselines/reference/es6modulekindWithES5Target9.errors.txt b/tests/baselines/reference/es6modulekindWithES5Target9.errors.txt index af941e65bbe..10351e92529 100644 --- a/tests/baselines/reference/es6modulekindWithES5Target9.errors.txt +++ b/tests/baselines/reference/es6modulekindWithES5Target9.errors.txt @@ -1,11 +1,11 @@ -tests/cases/compiler/es6modulekindWithES5Target9.ts(1,15): error TS2307: Cannot find module 'mod'. -tests/cases/compiler/es6modulekindWithES5Target9.ts(3,17): error TS2307: Cannot find module 'mod'. -tests/cases/compiler/es6modulekindWithES5Target9.ts(5,20): error TS2307: Cannot find module 'mod'. -tests/cases/compiler/es6modulekindWithES5Target9.ts(13,15): error TS2307: Cannot find module 'mod'. -tests/cases/compiler/es6modulekindWithES5Target9.ts(15,17): error TS2307: Cannot find module 'mod'. +tests/cases/conformance/externalModules/es6/es6modulekindWithES5Target9.ts(1,15): error TS2307: Cannot find module 'mod'. +tests/cases/conformance/externalModules/es6/es6modulekindWithES5Target9.ts(3,17): error TS2307: Cannot find module 'mod'. +tests/cases/conformance/externalModules/es6/es6modulekindWithES5Target9.ts(5,20): error TS2307: Cannot find module 'mod'. +tests/cases/conformance/externalModules/es6/es6modulekindWithES5Target9.ts(13,15): error TS2307: Cannot find module 'mod'. +tests/cases/conformance/externalModules/es6/es6modulekindWithES5Target9.ts(15,17): error TS2307: Cannot find module 'mod'. -==== tests/cases/compiler/es6modulekindWithES5Target9.ts (5 errors) ==== +==== tests/cases/conformance/externalModules/es6/es6modulekindWithES5Target9.ts (5 errors) ==== import d from "mod"; ~~~~~ !!! error TS2307: Cannot find module 'mod'. diff --git a/tests/baselines/reference/esnextmodulekind.js b/tests/baselines/reference/esnextmodulekind.js new file mode 100644 index 00000000000..073c319c861 --- /dev/null +++ b/tests/baselines/reference/esnextmodulekind.js @@ -0,0 +1,22 @@ +//// [esnextmodulekind.ts] +export default class A +{ + constructor () + { + + } + + public B() + { + return 42; + } +} + +//// [esnextmodulekind.js] +export default class A { + constructor() { + } + B() { + return 42; + } +} diff --git a/tests/baselines/reference/esnextmodulekind.symbols b/tests/baselines/reference/esnextmodulekind.symbols new file mode 100644 index 00000000000..5cd1de6716b --- /dev/null +++ b/tests/baselines/reference/esnextmodulekind.symbols @@ -0,0 +1,15 @@ +=== tests/cases/conformance/externalModules/esnext/esnextmodulekind.ts === +export default class A +>A : Symbol(A, Decl(esnextmodulekind.ts, 0, 0)) +{ + constructor () + { + + } + + public B() +>B : Symbol(A.B, Decl(esnextmodulekind.ts, 5, 5)) + { + return 42; + } +} diff --git a/tests/baselines/reference/esnextmodulekind.types b/tests/baselines/reference/esnextmodulekind.types new file mode 100644 index 00000000000..a4e66e350b7 --- /dev/null +++ b/tests/baselines/reference/esnextmodulekind.types @@ -0,0 +1,16 @@ +=== tests/cases/conformance/externalModules/esnext/esnextmodulekind.ts === +export default class A +>A : A +{ + constructor () + { + + } + + public B() +>B : () => number + { + return 42; +>42 : 42 + } +} diff --git a/tests/baselines/reference/esnextmodulekindWithES2015Target.js b/tests/baselines/reference/esnextmodulekindWithES2015Target.js new file mode 100644 index 00000000000..fbaf4625244 --- /dev/null +++ b/tests/baselines/reference/esnextmodulekindWithES2015Target.js @@ -0,0 +1,22 @@ +//// [esnextmodulekindWithES2015Target.ts] +export default class A +{ + constructor () + { + + } + + public B() + { + return 42; + } +} + +//// [esnextmodulekindWithES2015Target.js] +export default class A { + constructor() { + } + B() { + return 42; + } +} diff --git a/tests/baselines/reference/esnextmodulekindWithES2015Target.symbols b/tests/baselines/reference/esnextmodulekindWithES2015Target.symbols new file mode 100644 index 00000000000..68909c42291 --- /dev/null +++ b/tests/baselines/reference/esnextmodulekindWithES2015Target.symbols @@ -0,0 +1,15 @@ +=== tests/cases/conformance/externalModules/esnext/esnextmodulekindWithES2015Target.ts === +export default class A +>A : Symbol(A, Decl(esnextmodulekindWithES2015Target.ts, 0, 0)) +{ + constructor () + { + + } + + public B() +>B : Symbol(A.B, Decl(esnextmodulekindWithES2015Target.ts, 5, 5)) + { + return 42; + } +} diff --git a/tests/baselines/reference/esnextmodulekindWithES2015Target.types b/tests/baselines/reference/esnextmodulekindWithES2015Target.types new file mode 100644 index 00000000000..647d40731e8 --- /dev/null +++ b/tests/baselines/reference/esnextmodulekindWithES2015Target.types @@ -0,0 +1,16 @@ +=== tests/cases/conformance/externalModules/esnext/esnextmodulekindWithES2015Target.ts === +export default class A +>A : A +{ + constructor () + { + + } + + public B() +>B : () => number + { + return 42; +>42 : 42 + } +} diff --git a/tests/baselines/reference/esnextmodulekindWithES5Target.js b/tests/baselines/reference/esnextmodulekindWithES5Target.js new file mode 100644 index 00000000000..061dd3e4050 --- /dev/null +++ b/tests/baselines/reference/esnextmodulekindWithES5Target.js @@ -0,0 +1,57 @@ +//// [esnextmodulekindWithES5Target.ts] +export class C { + static s = 0; + p = 1; + method() { } +} +export { C as C2 }; + +declare function foo(...args: any[]): any; +@foo +export class D { + static s = 0; + p = 1; + method() { } +} +export { D as D2 }; + +class E { } +export {E}; + + +//// [esnextmodulekindWithES5Target.js] +var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { + var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); + else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; + return c > 3 && r && Object.defineProperty(target, key, r), r; +}; +var C = /** @class */ (function () { + function C() { + this.p = 1; + } + C.prototype.method = function () { }; + C.s = 0; + return C; +}()); +export { C }; +export { C as C2 }; +var D = /** @class */ (function () { + function D() { + this.p = 1; + } + D.prototype.method = function () { }; + D.s = 0; + D = __decorate([ + foo + ], D); + return D; +}()); +export { D }; +export { D as D2 }; +var E = /** @class */ (function () { + function E() { + } + return E; +}()); +export { E }; diff --git a/tests/baselines/reference/esnextmodulekindWithES5Target.symbols b/tests/baselines/reference/esnextmodulekindWithES5Target.symbols new file mode 100644 index 00000000000..ae548754ae2 --- /dev/null +++ b/tests/baselines/reference/esnextmodulekindWithES5Target.symbols @@ -0,0 +1,46 @@ +=== tests/cases/conformance/externalModules/esnext/esnextmodulekindWithES5Target.ts === +export class C { +>C : Symbol(C, Decl(esnextmodulekindWithES5Target.ts, 0, 0)) + + static s = 0; +>s : Symbol(C.s, Decl(esnextmodulekindWithES5Target.ts, 0, 16)) + + p = 1; +>p : Symbol(C.p, Decl(esnextmodulekindWithES5Target.ts, 1, 17)) + + method() { } +>method : Symbol(C.method, Decl(esnextmodulekindWithES5Target.ts, 2, 10)) +} +export { C as C2 }; +>C : Symbol(C2, Decl(esnextmodulekindWithES5Target.ts, 5, 8)) +>C2 : Symbol(C2, Decl(esnextmodulekindWithES5Target.ts, 5, 8)) + +declare function foo(...args: any[]): any; +>foo : Symbol(foo, Decl(esnextmodulekindWithES5Target.ts, 5, 19)) +>args : Symbol(args, Decl(esnextmodulekindWithES5Target.ts, 7, 21)) + +@foo +>foo : Symbol(foo, Decl(esnextmodulekindWithES5Target.ts, 5, 19)) + +export class D { +>D : Symbol(D, Decl(esnextmodulekindWithES5Target.ts, 7, 42)) + + static s = 0; +>s : Symbol(D.s, Decl(esnextmodulekindWithES5Target.ts, 9, 16)) + + p = 1; +>p : Symbol(D.p, Decl(esnextmodulekindWithES5Target.ts, 10, 17)) + + method() { } +>method : Symbol(D.method, Decl(esnextmodulekindWithES5Target.ts, 11, 10)) +} +export { D as D2 }; +>D : Symbol(D2, Decl(esnextmodulekindWithES5Target.ts, 14, 8)) +>D2 : Symbol(D2, Decl(esnextmodulekindWithES5Target.ts, 14, 8)) + +class E { } +>E : Symbol(E, Decl(esnextmodulekindWithES5Target.ts, 14, 19)) + +export {E}; +>E : Symbol(E, Decl(esnextmodulekindWithES5Target.ts, 17, 8)) + diff --git a/tests/baselines/reference/esnextmodulekindWithES5Target.types b/tests/baselines/reference/esnextmodulekindWithES5Target.types new file mode 100644 index 00000000000..89b35314e86 --- /dev/null +++ b/tests/baselines/reference/esnextmodulekindWithES5Target.types @@ -0,0 +1,50 @@ +=== tests/cases/conformance/externalModules/esnext/esnextmodulekindWithES5Target.ts === +export class C { +>C : C + + static s = 0; +>s : number +>0 : 0 + + p = 1; +>p : number +>1 : 1 + + method() { } +>method : () => void +} +export { C as C2 }; +>C : typeof C +>C2 : typeof C + +declare function foo(...args: any[]): any; +>foo : (...args: any[]) => any +>args : any[] + +@foo +>foo : (...args: any[]) => any + +export class D { +>D : D + + static s = 0; +>s : number +>0 : 0 + + p = 1; +>p : number +>1 : 1 + + method() { } +>method : () => void +} +export { D as D2 }; +>D : typeof D +>D2 : typeof D + +class E { } +>E : E + +export {E}; +>E : typeof E + diff --git a/tests/baselines/reference/esnextmodulekindWithES5Target10.errors.txt b/tests/baselines/reference/esnextmodulekindWithES5Target10.errors.txt new file mode 100644 index 00000000000..4793bc650ad --- /dev/null +++ b/tests/baselines/reference/esnextmodulekindWithES5Target10.errors.txt @@ -0,0 +1,18 @@ +tests/cases/conformance/externalModules/esnext/esnextmodulekindWithES5Target10.ts(1,1): error TS1202: Import assignment cannot be used when targeting ECMAScript modules. Consider using 'import * as ns from "mod"', 'import {a} from "mod"', 'import d from "mod"', or another module format instead. +tests/cases/conformance/externalModules/esnext/esnextmodulekindWithES5Target10.ts(1,20): error TS2307: Cannot find module 'mod'. +tests/cases/conformance/externalModules/esnext/esnextmodulekindWithES5Target10.ts(6,1): error TS1203: Export assignment cannot be used when targeting ECMAScript modules. Consider using 'export default' or another module format instead. + + +==== tests/cases/conformance/externalModules/esnext/esnextmodulekindWithES5Target10.ts (3 errors) ==== + import i = require("mod"); // Error; + ~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS1202: Import assignment cannot be used when targeting ECMAScript modules. Consider using 'import * as ns from "mod"', 'import {a} from "mod"', 'import d from "mod"', or another module format instead. + ~~~~~ +!!! error TS2307: Cannot find module 'mod'. + + + namespace N { + } + export = N; // Error + ~~~~~~~~~~~ +!!! error TS1203: Export assignment cannot be used when targeting ECMAScript modules. Consider using 'export default' or another module format instead. \ No newline at end of file diff --git a/tests/baselines/reference/esnextmodulekindWithES5Target10.js b/tests/baselines/reference/esnextmodulekindWithES5Target10.js new file mode 100644 index 00000000000..e68e1d72b98 --- /dev/null +++ b/tests/baselines/reference/esnextmodulekindWithES5Target10.js @@ -0,0 +1,9 @@ +//// [esnextmodulekindWithES5Target10.ts] +import i = require("mod"); // Error; + + +namespace N { +} +export = N; // Error + +//// [esnextmodulekindWithES5Target10.js] diff --git a/tests/baselines/reference/esnextmodulekindWithES5Target11.js b/tests/baselines/reference/esnextmodulekindWithES5Target11.js new file mode 100644 index 00000000000..58b18c4e829 --- /dev/null +++ b/tests/baselines/reference/esnextmodulekindWithES5Target11.js @@ -0,0 +1,32 @@ +//// [esnextmodulekindWithES5Target11.ts] +declare function foo(...args: any[]): any; +@foo +export default class C { + static x() { return C.y; } + static y = 1 + p = 1; + method() { } +} + +//// [esnextmodulekindWithES5Target11.js] +var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { + var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); + else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; + return c > 3 && r && Object.defineProperty(target, key, r), r; +}; +var C = /** @class */ (function () { + function C() { + this.p = 1; + } + C_1 = C; + C.x = function () { return C_1.y; }; + C.prototype.method = function () { }; + C.y = 1; + C = C_1 = __decorate([ + foo + ], C); + return C; + var C_1; +}()); +export default C; diff --git a/tests/baselines/reference/esnextmodulekindWithES5Target11.symbols b/tests/baselines/reference/esnextmodulekindWithES5Target11.symbols new file mode 100644 index 00000000000..c7261964049 --- /dev/null +++ b/tests/baselines/reference/esnextmodulekindWithES5Target11.symbols @@ -0,0 +1,26 @@ +=== tests/cases/conformance/externalModules/esnext/esnextmodulekindWithES5Target11.ts === +declare function foo(...args: any[]): any; +>foo : Symbol(foo, Decl(esnextmodulekindWithES5Target11.ts, 0, 0)) +>args : Symbol(args, Decl(esnextmodulekindWithES5Target11.ts, 0, 21)) + +@foo +>foo : Symbol(foo, Decl(esnextmodulekindWithES5Target11.ts, 0, 0)) + +export default class C { +>C : Symbol(C, Decl(esnextmodulekindWithES5Target11.ts, 0, 42)) + + static x() { return C.y; } +>x : Symbol(C.x, Decl(esnextmodulekindWithES5Target11.ts, 2, 24)) +>C.y : Symbol(C.y, Decl(esnextmodulekindWithES5Target11.ts, 3, 30)) +>C : Symbol(C, Decl(esnextmodulekindWithES5Target11.ts, 0, 42)) +>y : Symbol(C.y, Decl(esnextmodulekindWithES5Target11.ts, 3, 30)) + + static y = 1 +>y : Symbol(C.y, Decl(esnextmodulekindWithES5Target11.ts, 3, 30)) + + p = 1; +>p : Symbol(C.p, Decl(esnextmodulekindWithES5Target11.ts, 4, 16)) + + method() { } +>method : Symbol(C.method, Decl(esnextmodulekindWithES5Target11.ts, 5, 10)) +} diff --git a/tests/baselines/reference/esnextmodulekindWithES5Target11.types b/tests/baselines/reference/esnextmodulekindWithES5Target11.types new file mode 100644 index 00000000000..733ae8c55f9 --- /dev/null +++ b/tests/baselines/reference/esnextmodulekindWithES5Target11.types @@ -0,0 +1,28 @@ +=== tests/cases/conformance/externalModules/esnext/esnextmodulekindWithES5Target11.ts === +declare function foo(...args: any[]): any; +>foo : (...args: any[]) => any +>args : any[] + +@foo +>foo : (...args: any[]) => any + +export default class C { +>C : C + + static x() { return C.y; } +>x : () => number +>C.y : number +>C : typeof C +>y : number + + static y = 1 +>y : number +>1 : 1 + + p = 1; +>p : number +>1 : 1 + + method() { } +>method : () => void +} diff --git a/tests/baselines/reference/esnextmodulekindWithES5Target12.js b/tests/baselines/reference/esnextmodulekindWithES5Target12.js new file mode 100644 index 00000000000..72d85ba1450 --- /dev/null +++ b/tests/baselines/reference/esnextmodulekindWithES5Target12.js @@ -0,0 +1,70 @@ +//// [esnextmodulekindWithES5Target12.ts] +export class C { +} + +export namespace C { + export const x = 1; +} + +export enum E { + w = 1 +} + +export enum E { + x = 2 +} + +export namespace E { + export const y = 1; +} + +export namespace E { + export const z = 1; +} + +export namespace N { +} + +export namespace N { + export const x = 1; +} + +export function F() { +} + +export namespace F { + export const x = 1; +} + +//// [esnextmodulekindWithES5Target12.js] +var C = /** @class */ (function () { + function C() { + } + return C; +}()); +export { C }; +(function (C) { + C.x = 1; +})(C || (C = {})); +export var E; +(function (E) { + E[E["w"] = 1] = "w"; +})(E || (E = {})); +(function (E) { + E[E["x"] = 2] = "x"; +})(E || (E = {})); +(function (E) { + E.y = 1; +})(E || (E = {})); +(function (E) { + E.z = 1; +})(E || (E = {})); +export var N; +(function (N) { + N.x = 1; +})(N || (N = {})); +export function F() { +} +(function (F) { + F.x = 1; +})(F || (F = {})); diff --git a/tests/baselines/reference/esnextmodulekindWithES5Target12.symbols b/tests/baselines/reference/esnextmodulekindWithES5Target12.symbols new file mode 100644 index 00000000000..f28d6cb4158 --- /dev/null +++ b/tests/baselines/reference/esnextmodulekindWithES5Target12.symbols @@ -0,0 +1,61 @@ +=== tests/cases/conformance/externalModules/esnext/esnextmodulekindWithES5Target12.ts === +export class C { +>C : Symbol(C, Decl(esnextmodulekindWithES5Target12.ts, 0, 0), Decl(esnextmodulekindWithES5Target12.ts, 1, 1)) +} + +export namespace C { +>C : Symbol(C, Decl(esnextmodulekindWithES5Target12.ts, 0, 0), Decl(esnextmodulekindWithES5Target12.ts, 1, 1)) + + export const x = 1; +>x : Symbol(x, Decl(esnextmodulekindWithES5Target12.ts, 4, 16)) +} + +export enum E { +>E : Symbol(E, Decl(esnextmodulekindWithES5Target12.ts, 5, 1), Decl(esnextmodulekindWithES5Target12.ts, 9, 1), Decl(esnextmodulekindWithES5Target12.ts, 13, 1), Decl(esnextmodulekindWithES5Target12.ts, 17, 1)) + + w = 1 +>w : Symbol(E.w, Decl(esnextmodulekindWithES5Target12.ts, 7, 15)) +} + +export enum E { +>E : Symbol(E, Decl(esnextmodulekindWithES5Target12.ts, 5, 1), Decl(esnextmodulekindWithES5Target12.ts, 9, 1), Decl(esnextmodulekindWithES5Target12.ts, 13, 1), Decl(esnextmodulekindWithES5Target12.ts, 17, 1)) + + x = 2 +>x : Symbol(E.x, Decl(esnextmodulekindWithES5Target12.ts, 11, 15)) +} + +export namespace E { +>E : Symbol(E, Decl(esnextmodulekindWithES5Target12.ts, 5, 1), Decl(esnextmodulekindWithES5Target12.ts, 9, 1), Decl(esnextmodulekindWithES5Target12.ts, 13, 1), Decl(esnextmodulekindWithES5Target12.ts, 17, 1)) + + export const y = 1; +>y : Symbol(y, Decl(esnextmodulekindWithES5Target12.ts, 16, 16)) +} + +export namespace E { +>E : Symbol(E, Decl(esnextmodulekindWithES5Target12.ts, 5, 1), Decl(esnextmodulekindWithES5Target12.ts, 9, 1), Decl(esnextmodulekindWithES5Target12.ts, 13, 1), Decl(esnextmodulekindWithES5Target12.ts, 17, 1)) + + export const z = 1; +>z : Symbol(z, Decl(esnextmodulekindWithES5Target12.ts, 20, 16)) +} + +export namespace N { +>N : Symbol(N, Decl(esnextmodulekindWithES5Target12.ts, 21, 1), Decl(esnextmodulekindWithES5Target12.ts, 24, 1)) +} + +export namespace N { +>N : Symbol(N, Decl(esnextmodulekindWithES5Target12.ts, 21, 1), Decl(esnextmodulekindWithES5Target12.ts, 24, 1)) + + export const x = 1; +>x : Symbol(x, Decl(esnextmodulekindWithES5Target12.ts, 27, 16)) +} + +export function F() { +>F : Symbol(F, Decl(esnextmodulekindWithES5Target12.ts, 28, 1), Decl(esnextmodulekindWithES5Target12.ts, 31, 1)) +} + +export namespace F { +>F : Symbol(F, Decl(esnextmodulekindWithES5Target12.ts, 28, 1), Decl(esnextmodulekindWithES5Target12.ts, 31, 1)) + + export const x = 1; +>x : Symbol(x, Decl(esnextmodulekindWithES5Target12.ts, 34, 16)) +} diff --git a/tests/baselines/reference/esnextmodulekindWithES5Target12.types b/tests/baselines/reference/esnextmodulekindWithES5Target12.types new file mode 100644 index 00000000000..608cf700cfd --- /dev/null +++ b/tests/baselines/reference/esnextmodulekindWithES5Target12.types @@ -0,0 +1,68 @@ +=== tests/cases/conformance/externalModules/esnext/esnextmodulekindWithES5Target12.ts === +export class C { +>C : C +} + +export namespace C { +>C : typeof C + + export const x = 1; +>x : 1 +>1 : 1 +} + +export enum E { +>E : E + + w = 1 +>w : E.w +>1 : 1 +} + +export enum E { +>E : E + + x = 2 +>x : E.x +>2 : 2 +} + +export namespace E { +>E : typeof E + + export const y = 1; +>y : 1 +>1 : 1 +} + +export namespace E { +>E : typeof E + + export const z = 1; +>z : 1 +>1 : 1 +} + +export namespace N { +>N : typeof N +} + +export namespace N { +>N : typeof N + + export const x = 1; +>x : 1 +>1 : 1 +} + +export function F() { +>F : typeof F +} + +export namespace F { +>F : typeof F + + export const x = 1; +>x : 1 +>1 : 1 +} diff --git a/tests/baselines/reference/esnextmodulekindWithES5Target2.js b/tests/baselines/reference/esnextmodulekindWithES5Target2.js new file mode 100644 index 00000000000..dd2a0b301a3 --- /dev/null +++ b/tests/baselines/reference/esnextmodulekindWithES5Target2.js @@ -0,0 +1,18 @@ +//// [esnextmodulekindWithES5Target2.ts] +export default class C { + static s = 0; + p = 1; + method() { } +} + + +//// [esnextmodulekindWithES5Target2.js] +var C = /** @class */ (function () { + function C() { + this.p = 1; + } + C.prototype.method = function () { }; + C.s = 0; + return C; +}()); +export default C; diff --git a/tests/baselines/reference/esnextmodulekindWithES5Target2.symbols b/tests/baselines/reference/esnextmodulekindWithES5Target2.symbols new file mode 100644 index 00000000000..c1626775f65 --- /dev/null +++ b/tests/baselines/reference/esnextmodulekindWithES5Target2.symbols @@ -0,0 +1,14 @@ +=== tests/cases/conformance/externalModules/esnext/esnextmodulekindWithES5Target2.ts === +export default class C { +>C : Symbol(C, Decl(esnextmodulekindWithES5Target2.ts, 0, 0)) + + static s = 0; +>s : Symbol(C.s, Decl(esnextmodulekindWithES5Target2.ts, 0, 24)) + + p = 1; +>p : Symbol(C.p, Decl(esnextmodulekindWithES5Target2.ts, 1, 17)) + + method() { } +>method : Symbol(C.method, Decl(esnextmodulekindWithES5Target2.ts, 2, 10)) +} + diff --git a/tests/baselines/reference/esnextmodulekindWithES5Target2.types b/tests/baselines/reference/esnextmodulekindWithES5Target2.types new file mode 100644 index 00000000000..165ef17ced9 --- /dev/null +++ b/tests/baselines/reference/esnextmodulekindWithES5Target2.types @@ -0,0 +1,16 @@ +=== tests/cases/conformance/externalModules/esnext/esnextmodulekindWithES5Target2.ts === +export default class C { +>C : C + + static s = 0; +>s : number +>0 : 0 + + p = 1; +>p : number +>1 : 1 + + method() { } +>method : () => void +} + diff --git a/tests/baselines/reference/esnextmodulekindWithES5Target3.js b/tests/baselines/reference/esnextmodulekindWithES5Target3.js new file mode 100644 index 00000000000..e46e7c1bcac --- /dev/null +++ b/tests/baselines/reference/esnextmodulekindWithES5Target3.js @@ -0,0 +1,28 @@ +//// [esnextmodulekindWithES5Target3.ts] +declare function foo(...args: any[]): any; +@foo +export default class D { + static s = 0; + p = 1; + method() { } +} + +//// [esnextmodulekindWithES5Target3.js] +var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { + var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); + else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; + return c > 3 && r && Object.defineProperty(target, key, r), r; +}; +var D = /** @class */ (function () { + function D() { + this.p = 1; + } + D.prototype.method = function () { }; + D.s = 0; + D = __decorate([ + foo + ], D); + return D; +}()); +export default D; diff --git a/tests/baselines/reference/esnextmodulekindWithES5Target3.symbols b/tests/baselines/reference/esnextmodulekindWithES5Target3.symbols new file mode 100644 index 00000000000..3c34e0f2d81 --- /dev/null +++ b/tests/baselines/reference/esnextmodulekindWithES5Target3.symbols @@ -0,0 +1,20 @@ +=== tests/cases/conformance/externalModules/esnext/esnextmodulekindWithES5Target3.ts === +declare function foo(...args: any[]): any; +>foo : Symbol(foo, Decl(esnextmodulekindWithES5Target3.ts, 0, 0)) +>args : Symbol(args, Decl(esnextmodulekindWithES5Target3.ts, 0, 21)) + +@foo +>foo : Symbol(foo, Decl(esnextmodulekindWithES5Target3.ts, 0, 0)) + +export default class D { +>D : Symbol(D, Decl(esnextmodulekindWithES5Target3.ts, 0, 42)) + + static s = 0; +>s : Symbol(D.s, Decl(esnextmodulekindWithES5Target3.ts, 2, 24)) + + p = 1; +>p : Symbol(D.p, Decl(esnextmodulekindWithES5Target3.ts, 3, 17)) + + method() { } +>method : Symbol(D.method, Decl(esnextmodulekindWithES5Target3.ts, 4, 10)) +} diff --git a/tests/baselines/reference/esnextmodulekindWithES5Target3.types b/tests/baselines/reference/esnextmodulekindWithES5Target3.types new file mode 100644 index 00000000000..15a6ba1ce5f --- /dev/null +++ b/tests/baselines/reference/esnextmodulekindWithES5Target3.types @@ -0,0 +1,22 @@ +=== tests/cases/conformance/externalModules/esnext/esnextmodulekindWithES5Target3.ts === +declare function foo(...args: any[]): any; +>foo : (...args: any[]) => any +>args : any[] + +@foo +>foo : (...args: any[]) => any + +export default class D { +>D : D + + static s = 0; +>s : number +>0 : 0 + + p = 1; +>p : number +>1 : 1 + + method() { } +>method : () => void +} diff --git a/tests/baselines/reference/esnextmodulekindWithES5Target4.js b/tests/baselines/reference/esnextmodulekindWithES5Target4.js new file mode 100644 index 00000000000..c31286cd30e --- /dev/null +++ b/tests/baselines/reference/esnextmodulekindWithES5Target4.js @@ -0,0 +1,11 @@ +//// [esnextmodulekindWithES5Target4.ts] +class E { } +export default E; + +//// [esnextmodulekindWithES5Target4.js] +var E = /** @class */ (function () { + function E() { + } + return E; +}()); +export default E; diff --git a/tests/baselines/reference/esnextmodulekindWithES5Target4.symbols b/tests/baselines/reference/esnextmodulekindWithES5Target4.symbols new file mode 100644 index 00000000000..06ac0dc56e5 --- /dev/null +++ b/tests/baselines/reference/esnextmodulekindWithES5Target4.symbols @@ -0,0 +1,7 @@ +=== tests/cases/conformance/externalModules/esnext/esnextmodulekindWithES5Target4.ts === +class E { } +>E : Symbol(E, Decl(esnextmodulekindWithES5Target4.ts, 0, 0)) + +export default E; +>E : Symbol(E, Decl(esnextmodulekindWithES5Target4.ts, 0, 0)) + diff --git a/tests/baselines/reference/esnextmodulekindWithES5Target4.types b/tests/baselines/reference/esnextmodulekindWithES5Target4.types new file mode 100644 index 00000000000..b9ed448e9b8 --- /dev/null +++ b/tests/baselines/reference/esnextmodulekindWithES5Target4.types @@ -0,0 +1,7 @@ +=== tests/cases/conformance/externalModules/esnext/esnextmodulekindWithES5Target4.ts === +class E { } +>E : E + +export default E; +>E : E + diff --git a/tests/baselines/reference/esnextmodulekindWithES5Target5.js b/tests/baselines/reference/esnextmodulekindWithES5Target5.js new file mode 100644 index 00000000000..178a6c366f8 --- /dev/null +++ b/tests/baselines/reference/esnextmodulekindWithES5Target5.js @@ -0,0 +1,18 @@ +//// [esnextmodulekindWithES5Target5.ts] +export enum E1 { + value1 +} + +export const enum E2 { + value1 +} + +//// [esnextmodulekindWithES5Target5.js] +export var E1; +(function (E1) { + E1[E1["value1"] = 0] = "value1"; +})(E1 || (E1 = {})); +export var E2; +(function (E2) { + E2[E2["value1"] = 0] = "value1"; +})(E2 || (E2 = {})); diff --git a/tests/baselines/reference/esnextmodulekindWithES5Target5.symbols b/tests/baselines/reference/esnextmodulekindWithES5Target5.symbols new file mode 100644 index 00000000000..26db8dab610 --- /dev/null +++ b/tests/baselines/reference/esnextmodulekindWithES5Target5.symbols @@ -0,0 +1,14 @@ +=== tests/cases/conformance/externalModules/esnext/esnextmodulekindWithES5Target5.ts === +export enum E1 { +>E1 : Symbol(E1, Decl(esnextmodulekindWithES5Target5.ts, 0, 0)) + + value1 +>value1 : Symbol(E1.value1, Decl(esnextmodulekindWithES5Target5.ts, 0, 16)) +} + +export const enum E2 { +>E2 : Symbol(E2, Decl(esnextmodulekindWithES5Target5.ts, 2, 1)) + + value1 +>value1 : Symbol(E2.value1, Decl(esnextmodulekindWithES5Target5.ts, 4, 22)) +} diff --git a/tests/baselines/reference/esnextmodulekindWithES5Target5.types b/tests/baselines/reference/esnextmodulekindWithES5Target5.types new file mode 100644 index 00000000000..c838a953ef9 --- /dev/null +++ b/tests/baselines/reference/esnextmodulekindWithES5Target5.types @@ -0,0 +1,14 @@ +=== tests/cases/conformance/externalModules/esnext/esnextmodulekindWithES5Target5.ts === +export enum E1 { +>E1 : E1 + + value1 +>value1 : E1 +} + +export const enum E2 { +>E2 : E2 + + value1 +>value1 : E2 +} diff --git a/tests/baselines/reference/esnextmodulekindWithES5Target6.js b/tests/baselines/reference/esnextmodulekindWithES5Target6.js new file mode 100644 index 00000000000..85a87acacef --- /dev/null +++ b/tests/baselines/reference/esnextmodulekindWithES5Target6.js @@ -0,0 +1,24 @@ +//// [esnextmodulekindWithES5Target6.ts] +export function f1(d = 0) { +} + +export function f2(...arg) { +} + +export default function f3(d = 0) { +} + + +//// [esnextmodulekindWithES5Target6.js] +export function f1(d) { + if (d === void 0) { d = 0; } +} +export function f2() { + var arg = []; + for (var _i = 0; _i < arguments.length; _i++) { + arg[_i] = arguments[_i]; + } +} +export default function f3(d) { + if (d === void 0) { d = 0; } +} diff --git a/tests/baselines/reference/esnextmodulekindWithES5Target6.symbols b/tests/baselines/reference/esnextmodulekindWithES5Target6.symbols new file mode 100644 index 00000000000..a77b1691a05 --- /dev/null +++ b/tests/baselines/reference/esnextmodulekindWithES5Target6.symbols @@ -0,0 +1,16 @@ +=== tests/cases/conformance/externalModules/esnext/esnextmodulekindWithES5Target6.ts === +export function f1(d = 0) { +>f1 : Symbol(f1, Decl(esnextmodulekindWithES5Target6.ts, 0, 0)) +>d : Symbol(d, Decl(esnextmodulekindWithES5Target6.ts, 0, 19)) +} + +export function f2(...arg) { +>f2 : Symbol(f2, Decl(esnextmodulekindWithES5Target6.ts, 1, 1)) +>arg : Symbol(arg, Decl(esnextmodulekindWithES5Target6.ts, 3, 19)) +} + +export default function f3(d = 0) { +>f3 : Symbol(f3, Decl(esnextmodulekindWithES5Target6.ts, 4, 1)) +>d : Symbol(d, Decl(esnextmodulekindWithES5Target6.ts, 6, 27)) +} + diff --git a/tests/baselines/reference/esnextmodulekindWithES5Target6.types b/tests/baselines/reference/esnextmodulekindWithES5Target6.types new file mode 100644 index 00000000000..ac826125710 --- /dev/null +++ b/tests/baselines/reference/esnextmodulekindWithES5Target6.types @@ -0,0 +1,18 @@ +=== tests/cases/conformance/externalModules/esnext/esnextmodulekindWithES5Target6.ts === +export function f1(d = 0) { +>f1 : (d?: number) => void +>d : number +>0 : 0 +} + +export function f2(...arg) { +>f2 : (...arg: any[]) => void +>arg : any[] +} + +export default function f3(d = 0) { +>f3 : (d?: number) => void +>d : number +>0 : 0 +} + diff --git a/tests/baselines/reference/esnextmodulekindWithES5Target7.js b/tests/baselines/reference/esnextmodulekindWithES5Target7.js new file mode 100644 index 00000000000..be9e6984f42 --- /dev/null +++ b/tests/baselines/reference/esnextmodulekindWithES5Target7.js @@ -0,0 +1,15 @@ +//// [esnextmodulekindWithES5Target7.ts] +export namespace N { + var x = 0; +} + +export namespace N2 { + export interface I { } +} + + +//// [esnextmodulekindWithES5Target7.js] +export var N; +(function (N) { + var x = 0; +})(N || (N = {})); diff --git a/tests/baselines/reference/esnextmodulekindWithES5Target7.symbols b/tests/baselines/reference/esnextmodulekindWithES5Target7.symbols new file mode 100644 index 00000000000..bf23ed8e3c5 --- /dev/null +++ b/tests/baselines/reference/esnextmodulekindWithES5Target7.symbols @@ -0,0 +1,15 @@ +=== tests/cases/conformance/externalModules/esnext/esnextmodulekindWithES5Target7.ts === +export namespace N { +>N : Symbol(N, Decl(esnextmodulekindWithES5Target7.ts, 0, 0)) + + var x = 0; +>x : Symbol(x, Decl(esnextmodulekindWithES5Target7.ts, 1, 7)) +} + +export namespace N2 { +>N2 : Symbol(N2, Decl(esnextmodulekindWithES5Target7.ts, 2, 1)) + + export interface I { } +>I : Symbol(I, Decl(esnextmodulekindWithES5Target7.ts, 4, 21)) +} + diff --git a/tests/baselines/reference/esnextmodulekindWithES5Target7.types b/tests/baselines/reference/esnextmodulekindWithES5Target7.types new file mode 100644 index 00000000000..6d0887adf69 --- /dev/null +++ b/tests/baselines/reference/esnextmodulekindWithES5Target7.types @@ -0,0 +1,16 @@ +=== tests/cases/conformance/externalModules/esnext/esnextmodulekindWithES5Target7.ts === +export namespace N { +>N : typeof N + + var x = 0; +>x : number +>0 : 0 +} + +export namespace N2 { +>N2 : any + + export interface I { } +>I : I +} + diff --git a/tests/baselines/reference/esnextmodulekindWithES5Target8.js b/tests/baselines/reference/esnextmodulekindWithES5Target8.js new file mode 100644 index 00000000000..6a73cbb6b6c --- /dev/null +++ b/tests/baselines/reference/esnextmodulekindWithES5Target8.js @@ -0,0 +1,7 @@ +//// [esnextmodulekindWithES5Target8.ts] +export const c = 0; +export let l = 1; + +//// [esnextmodulekindWithES5Target8.js] +export var c = 0; +export var l = 1; diff --git a/tests/baselines/reference/esnextmodulekindWithES5Target8.symbols b/tests/baselines/reference/esnextmodulekindWithES5Target8.symbols new file mode 100644 index 00000000000..a2fa5496c97 --- /dev/null +++ b/tests/baselines/reference/esnextmodulekindWithES5Target8.symbols @@ -0,0 +1,7 @@ +=== tests/cases/conformance/externalModules/esnext/esnextmodulekindWithES5Target8.ts === +export const c = 0; +>c : Symbol(c, Decl(esnextmodulekindWithES5Target8.ts, 0, 12)) + +export let l = 1; +>l : Symbol(l, Decl(esnextmodulekindWithES5Target8.ts, 1, 10)) + diff --git a/tests/baselines/reference/esnextmodulekindWithES5Target8.types b/tests/baselines/reference/esnextmodulekindWithES5Target8.types new file mode 100644 index 00000000000..deb60c9c0df --- /dev/null +++ b/tests/baselines/reference/esnextmodulekindWithES5Target8.types @@ -0,0 +1,9 @@ +=== tests/cases/conformance/externalModules/esnext/esnextmodulekindWithES5Target8.ts === +export const c = 0; +>c : 0 +>0 : 0 + +export let l = 1; +>l : number +>1 : 1 + diff --git a/tests/baselines/reference/esnextmodulekindWithES5Target9.errors.txt b/tests/baselines/reference/esnextmodulekindWithES5Target9.errors.txt new file mode 100644 index 00000000000..cccb20f9659 --- /dev/null +++ b/tests/baselines/reference/esnextmodulekindWithES5Target9.errors.txt @@ -0,0 +1,36 @@ +tests/cases/conformance/externalModules/esnext/esnextmodulekindWithES5Target9.ts(1,15): error TS2307: Cannot find module 'mod'. +tests/cases/conformance/externalModules/esnext/esnextmodulekindWithES5Target9.ts(3,17): error TS2307: Cannot find module 'mod'. +tests/cases/conformance/externalModules/esnext/esnextmodulekindWithES5Target9.ts(5,20): error TS2307: Cannot find module 'mod'. +tests/cases/conformance/externalModules/esnext/esnextmodulekindWithES5Target9.ts(13,15): error TS2307: Cannot find module 'mod'. +tests/cases/conformance/externalModules/esnext/esnextmodulekindWithES5Target9.ts(15,17): error TS2307: Cannot find module 'mod'. + + +==== tests/cases/conformance/externalModules/esnext/esnextmodulekindWithES5Target9.ts (5 errors) ==== + import d from "mod"; + ~~~~~ +!!! error TS2307: Cannot find module 'mod'. + + import {a} from "mod"; + ~~~~~ +!!! error TS2307: Cannot find module 'mod'. + + import * as M from "mod"; + ~~~~~ +!!! error TS2307: Cannot find module 'mod'. + + export {a}; + + export {M}; + + export {d}; + + export * from "mod"; + ~~~~~ +!!! error TS2307: Cannot find module 'mod'. + + export {b} from "mod" + ~~~~~ +!!! error TS2307: Cannot find module 'mod'. + + export default d; + \ No newline at end of file diff --git a/tests/baselines/reference/esnextmodulekindWithES5Target9.js b/tests/baselines/reference/esnextmodulekindWithES5Target9.js new file mode 100644 index 00000000000..65197694501 --- /dev/null +++ b/tests/baselines/reference/esnextmodulekindWithES5Target9.js @@ -0,0 +1,30 @@ +//// [esnextmodulekindWithES5Target9.ts] +import d from "mod"; + +import {a} from "mod"; + +import * as M from "mod"; + +export {a}; + +export {M}; + +export {d}; + +export * from "mod"; + +export {b} from "mod" + +export default d; + + +//// [esnextmodulekindWithES5Target9.js] +import d from "mod"; +import { a } from "mod"; +import * as M from "mod"; +export { a }; +export { M }; +export { d }; +export * from "mod"; +export { b } from "mod"; +export default d; diff --git a/tests/cases/compiler/es6modulekind.ts b/tests/cases/conformance/externalModules/es6/es6modulekind.ts similarity index 100% rename from tests/cases/compiler/es6modulekind.ts rename to tests/cases/conformance/externalModules/es6/es6modulekind.ts diff --git a/tests/cases/compiler/es6modulekindWithES2015Target.ts b/tests/cases/conformance/externalModules/es6/es6modulekindWithES2015Target.ts similarity index 100% rename from tests/cases/compiler/es6modulekindWithES2015Target.ts rename to tests/cases/conformance/externalModules/es6/es6modulekindWithES2015Target.ts diff --git a/tests/cases/compiler/es6modulekindWithES5Target.ts b/tests/cases/conformance/externalModules/es6/es6modulekindWithES5Target.ts similarity index 100% rename from tests/cases/compiler/es6modulekindWithES5Target.ts rename to tests/cases/conformance/externalModules/es6/es6modulekindWithES5Target.ts diff --git a/tests/cases/compiler/es6modulekindWithES5Target10.ts b/tests/cases/conformance/externalModules/es6/es6modulekindWithES5Target10.ts similarity index 100% rename from tests/cases/compiler/es6modulekindWithES5Target10.ts rename to tests/cases/conformance/externalModules/es6/es6modulekindWithES5Target10.ts diff --git a/tests/cases/compiler/es6modulekindWithES5Target11.ts b/tests/cases/conformance/externalModules/es6/es6modulekindWithES5Target11.ts similarity index 100% rename from tests/cases/compiler/es6modulekindWithES5Target11.ts rename to tests/cases/conformance/externalModules/es6/es6modulekindWithES5Target11.ts diff --git a/tests/cases/compiler/es6modulekindWithES5Target12.ts b/tests/cases/conformance/externalModules/es6/es6modulekindWithES5Target12.ts similarity index 100% rename from tests/cases/compiler/es6modulekindWithES5Target12.ts rename to tests/cases/conformance/externalModules/es6/es6modulekindWithES5Target12.ts diff --git a/tests/cases/compiler/es6modulekindWithES5Target2.ts b/tests/cases/conformance/externalModules/es6/es6modulekindWithES5Target2.ts similarity index 100% rename from tests/cases/compiler/es6modulekindWithES5Target2.ts rename to tests/cases/conformance/externalModules/es6/es6modulekindWithES5Target2.ts diff --git a/tests/cases/compiler/es6modulekindWithES5Target3.ts b/tests/cases/conformance/externalModules/es6/es6modulekindWithES5Target3.ts similarity index 100% rename from tests/cases/compiler/es6modulekindWithES5Target3.ts rename to tests/cases/conformance/externalModules/es6/es6modulekindWithES5Target3.ts diff --git a/tests/cases/compiler/es6modulekindWithES5Target4.ts b/tests/cases/conformance/externalModules/es6/es6modulekindWithES5Target4.ts similarity index 100% rename from tests/cases/compiler/es6modulekindWithES5Target4.ts rename to tests/cases/conformance/externalModules/es6/es6modulekindWithES5Target4.ts diff --git a/tests/cases/compiler/es6modulekindWithES5Target5.ts b/tests/cases/conformance/externalModules/es6/es6modulekindWithES5Target5.ts similarity index 100% rename from tests/cases/compiler/es6modulekindWithES5Target5.ts rename to tests/cases/conformance/externalModules/es6/es6modulekindWithES5Target5.ts diff --git a/tests/cases/compiler/es6modulekindWithES5Target6.ts b/tests/cases/conformance/externalModules/es6/es6modulekindWithES5Target6.ts similarity index 100% rename from tests/cases/compiler/es6modulekindWithES5Target6.ts rename to tests/cases/conformance/externalModules/es6/es6modulekindWithES5Target6.ts diff --git a/tests/cases/compiler/es6modulekindWithES5Target7.ts b/tests/cases/conformance/externalModules/es6/es6modulekindWithES5Target7.ts similarity index 100% rename from tests/cases/compiler/es6modulekindWithES5Target7.ts rename to tests/cases/conformance/externalModules/es6/es6modulekindWithES5Target7.ts diff --git a/tests/cases/compiler/es6modulekindWithES5Target8.ts b/tests/cases/conformance/externalModules/es6/es6modulekindWithES5Target8.ts similarity index 100% rename from tests/cases/compiler/es6modulekindWithES5Target8.ts rename to tests/cases/conformance/externalModules/es6/es6modulekindWithES5Target8.ts diff --git a/tests/cases/compiler/es6modulekindWithES5Target9.ts b/tests/cases/conformance/externalModules/es6/es6modulekindWithES5Target9.ts similarity index 100% rename from tests/cases/compiler/es6modulekindWithES5Target9.ts rename to tests/cases/conformance/externalModules/es6/es6modulekindWithES5Target9.ts diff --git a/tests/cases/conformance/externalModules/esnext/esnextmodulekind.ts b/tests/cases/conformance/externalModules/esnext/esnextmodulekind.ts new file mode 100644 index 00000000000..59b61f742b4 --- /dev/null +++ b/tests/cases/conformance/externalModules/esnext/esnextmodulekind.ts @@ -0,0 +1,17 @@ +// @target: ES6 +// @sourcemap: false +// @declaration: false +// @module: esnext + +export default class A +{ + constructor () + { + + } + + public B() + { + return 42; + } +} \ No newline at end of file diff --git a/tests/cases/conformance/externalModules/esnext/esnextmodulekindWithES2015Target.ts b/tests/cases/conformance/externalModules/esnext/esnextmodulekindWithES2015Target.ts new file mode 100644 index 00000000000..aaf79e6607d --- /dev/null +++ b/tests/cases/conformance/externalModules/esnext/esnextmodulekindWithES2015Target.ts @@ -0,0 +1,17 @@ +// @target: es2015 +// @sourcemap: false +// @declaration: false +// @module: es6 + +export default class A +{ + constructor () + { + + } + + public B() + { + return 42; + } +} \ No newline at end of file diff --git a/tests/cases/conformance/externalModules/esnext/esnextmodulekindWithES5Target.ts b/tests/cases/conformance/externalModules/esnext/esnextmodulekindWithES5Target.ts new file mode 100644 index 00000000000..98c38ee6e3a --- /dev/null +++ b/tests/cases/conformance/externalModules/esnext/esnextmodulekindWithES5Target.ts @@ -0,0 +1,22 @@ +// @target: es5 +// @module: esnext +// @experimentalDecorators: true + +export class C { + static s = 0; + p = 1; + method() { } +} +export { C as C2 }; + +declare function foo(...args: any[]): any; +@foo +export class D { + static s = 0; + p = 1; + method() { } +} +export { D as D2 }; + +class E { } +export {E}; diff --git a/tests/cases/conformance/externalModules/esnext/esnextmodulekindWithES5Target10.ts b/tests/cases/conformance/externalModules/esnext/esnextmodulekindWithES5Target10.ts new file mode 100644 index 00000000000..2505870ed8e --- /dev/null +++ b/tests/cases/conformance/externalModules/esnext/esnextmodulekindWithES5Target10.ts @@ -0,0 +1,9 @@ +// @target: es5 +// @module: esnext + +import i = require("mod"); // Error; + + +namespace N { +} +export = N; // Error \ No newline at end of file diff --git a/tests/cases/conformance/externalModules/esnext/esnextmodulekindWithES5Target11.ts b/tests/cases/conformance/externalModules/esnext/esnextmodulekindWithES5Target11.ts new file mode 100644 index 00000000000..29f883acd68 --- /dev/null +++ b/tests/cases/conformance/externalModules/esnext/esnextmodulekindWithES5Target11.ts @@ -0,0 +1,12 @@ +// @target: es5 +// @module: esnext +// @experimentalDecorators: true + +declare function foo(...args: any[]): any; +@foo +export default class C { + static x() { return C.y; } + static y = 1 + p = 1; + method() { } +} \ No newline at end of file diff --git a/tests/cases/conformance/externalModules/esnext/esnextmodulekindWithES5Target12.ts b/tests/cases/conformance/externalModules/esnext/esnextmodulekindWithES5Target12.ts new file mode 100644 index 00000000000..93c29f88ae5 --- /dev/null +++ b/tests/cases/conformance/externalModules/esnext/esnextmodulekindWithES5Target12.ts @@ -0,0 +1,39 @@ +// @target: es5 +// @module: esnext + +export class C { +} + +export namespace C { + export const x = 1; +} + +export enum E { + w = 1 +} + +export enum E { + x = 2 +} + +export namespace E { + export const y = 1; +} + +export namespace E { + export const z = 1; +} + +export namespace N { +} + +export namespace N { + export const x = 1; +} + +export function F() { +} + +export namespace F { + export const x = 1; +} \ No newline at end of file diff --git a/tests/cases/conformance/externalModules/esnext/esnextmodulekindWithES5Target2.ts b/tests/cases/conformance/externalModules/esnext/esnextmodulekindWithES5Target2.ts new file mode 100644 index 00000000000..3b94c938cd1 --- /dev/null +++ b/tests/cases/conformance/externalModules/esnext/esnextmodulekindWithES5Target2.ts @@ -0,0 +1,8 @@ +// @target: es5 +// @module: esnext + +export default class C { + static s = 0; + p = 1; + method() { } +} diff --git a/tests/cases/conformance/externalModules/esnext/esnextmodulekindWithES5Target3.ts b/tests/cases/conformance/externalModules/esnext/esnextmodulekindWithES5Target3.ts new file mode 100644 index 00000000000..6726db916e5 --- /dev/null +++ b/tests/cases/conformance/externalModules/esnext/esnextmodulekindWithES5Target3.ts @@ -0,0 +1,12 @@ +// @target: es5 +// @module: esnext +// @experimentalDecorators: true + + +declare function foo(...args: any[]): any; +@foo +export default class D { + static s = 0; + p = 1; + method() { } +} \ No newline at end of file diff --git a/tests/cases/conformance/externalModules/esnext/esnextmodulekindWithES5Target4.ts b/tests/cases/conformance/externalModules/esnext/esnextmodulekindWithES5Target4.ts new file mode 100644 index 00000000000..090ecc64305 --- /dev/null +++ b/tests/cases/conformance/externalModules/esnext/esnextmodulekindWithES5Target4.ts @@ -0,0 +1,5 @@ +// @target: es5 +// @module: esnext + +class E { } +export default E; \ No newline at end of file diff --git a/tests/cases/conformance/externalModules/esnext/esnextmodulekindWithES5Target5.ts b/tests/cases/conformance/externalModules/esnext/esnextmodulekindWithES5Target5.ts new file mode 100644 index 00000000000..9dd83fd45db --- /dev/null +++ b/tests/cases/conformance/externalModules/esnext/esnextmodulekindWithES5Target5.ts @@ -0,0 +1,11 @@ +// @target: es5 +// @module: esnext +// @preserveConstEnums: true + +export enum E1 { + value1 +} + +export const enum E2 { + value1 +} \ No newline at end of file diff --git a/tests/cases/conformance/externalModules/esnext/esnextmodulekindWithES5Target6.ts b/tests/cases/conformance/externalModules/esnext/esnextmodulekindWithES5Target6.ts new file mode 100644 index 00000000000..2c53a8a9254 --- /dev/null +++ b/tests/cases/conformance/externalModules/esnext/esnextmodulekindWithES5Target6.ts @@ -0,0 +1,11 @@ +// @target: es5 +// @module: esnext + +export function f1(d = 0) { +} + +export function f2(...arg) { +} + +export default function f3(d = 0) { +} diff --git a/tests/cases/conformance/externalModules/esnext/esnextmodulekindWithES5Target7.ts b/tests/cases/conformance/externalModules/esnext/esnextmodulekindWithES5Target7.ts new file mode 100644 index 00000000000..4d22faba173 --- /dev/null +++ b/tests/cases/conformance/externalModules/esnext/esnextmodulekindWithES5Target7.ts @@ -0,0 +1,10 @@ +// @target: es5 +// @module: esnext + +export namespace N { + var x = 0; +} + +export namespace N2 { + export interface I { } +} diff --git a/tests/cases/conformance/externalModules/esnext/esnextmodulekindWithES5Target8.ts b/tests/cases/conformance/externalModules/esnext/esnextmodulekindWithES5Target8.ts new file mode 100644 index 00000000000..530f4c88c39 --- /dev/null +++ b/tests/cases/conformance/externalModules/esnext/esnextmodulekindWithES5Target8.ts @@ -0,0 +1,5 @@ +// @target: es5 +// @module: esnext + +export const c = 0; +export let l = 1; \ No newline at end of file diff --git a/tests/cases/conformance/externalModules/esnext/esnextmodulekindWithES5Target9.ts b/tests/cases/conformance/externalModules/esnext/esnextmodulekindWithES5Target9.ts new file mode 100644 index 00000000000..d91d6399ad3 --- /dev/null +++ b/tests/cases/conformance/externalModules/esnext/esnextmodulekindWithES5Target9.ts @@ -0,0 +1,20 @@ +// @target: es5 +// @module: esnext + +import d from "mod"; + +import {a} from "mod"; + +import * as M from "mod"; + +export {a}; + +export {M}; + +export {d}; + +export * from "mod"; + +export {b} from "mod" + +export default d; From 63d746bc4c5f3cee42e65462705a038e4a7412fa Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Mon, 11 Sep 2017 10:24:27 -0700 Subject: [PATCH 297/370] Higher order inference for mapped, index and lookup types --- src/compiler/checker.ts | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index ff5d1c661e8..4f2f065f4f3 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -10386,7 +10386,7 @@ namespace ts { // results for union and intersection types for performance reasons. function couldContainTypeVariables(type: Type): boolean { const objectFlags = getObjectFlags(type); - return !!(type.flags & TypeFlags.TypeVariable || + return !!(type.flags & (TypeFlags.TypeVariable | TypeFlags.Index) || objectFlags & ObjectFlags.Reference && forEach((type).typeArguments, couldContainTypeVariables) || objectFlags & ObjectFlags.Anonymous && type.symbol && type.symbol.flags & (SymbolFlags.Function | SymbolFlags.Method | SymbolFlags.TypeLiteral | SymbolFlags.Class) || objectFlags & ObjectFlags.Mapped || @@ -10554,6 +10554,13 @@ namespace ts { inferFromTypes(sourceTypes[i], targetTypes[i]); } } + else if (source.flags & TypeFlags.Index && target.flags & TypeFlags.Index) { + inferFromTypes((source).type, (target).type); + } + else if (source.flags & TypeFlags.IndexedAccess && target.flags & TypeFlags.IndexedAccess) { + inferFromTypes((source).objectType, (target).objectType); + inferFromTypes((source).indexType, (target).indexType); + } else if (target.flags & TypeFlags.UnionOrIntersection) { const targetTypes = (target).types; let typeVariableCount = 0; @@ -10627,6 +10634,12 @@ namespace ts { } function inferFromObjectTypes(source: Type, target: Type) { + if (isGenericMappedType(source) && isGenericMappedType(target)) { + // The source and target types are generic types { [P in S]: X } and { [P in T]: Y }, so we infer + // from S to T and from X to Y. + inferFromTypes(getConstraintTypeFromMappedType(source), getConstraintTypeFromMappedType(target)); + inferFromTypes(getTemplateTypeFromMappedType(source), getTemplateTypeFromMappedType(target)); + } if (getObjectFlags(target) & ObjectFlags.Mapped) { const constraintType = getConstraintTypeFromMappedType(target); if (constraintType.flags & TypeFlags.Index) { From 0823eba8a3257b80df68494ac0d534ac9b6bd16b Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Mon, 11 Sep 2017 10:38:46 -0700 Subject: [PATCH 298/370] Add tests --- .../higherOrderMappedIndexLookupInference.js | 43 ++++++++ ...herOrderMappedIndexLookupInference.symbols | 98 +++++++++++++++++ ...igherOrderMappedIndexLookupInference.types | 104 ++++++++++++++++++ .../higherOrderMappedIndexLookupInference.ts | 25 +++++ 4 files changed, 270 insertions(+) create mode 100644 tests/baselines/reference/higherOrderMappedIndexLookupInference.js create mode 100644 tests/baselines/reference/higherOrderMappedIndexLookupInference.symbols create mode 100644 tests/baselines/reference/higherOrderMappedIndexLookupInference.types create mode 100644 tests/cases/compiler/higherOrderMappedIndexLookupInference.ts diff --git a/tests/baselines/reference/higherOrderMappedIndexLookupInference.js b/tests/baselines/reference/higherOrderMappedIndexLookupInference.js new file mode 100644 index 00000000000..e8e09a59713 --- /dev/null +++ b/tests/baselines/reference/higherOrderMappedIndexLookupInference.js @@ -0,0 +1,43 @@ +//// [higherOrderMappedIndexLookupInference.ts] +// @strict + +function f1(a: () => keyof T, b: () => keyof U) { + a = b; + b = a; +} + +function f2(a: () => T[K], b: () => U[L]) { + a = b; + b = a; +} + +function f3(a: () => { [K in keyof T]: T[K] }, b: () => { [K in keyof U]: U[K] }) { + a = b; + b = a; +} + +// Repro from #18338 + +type IdMapped = { [K in keyof T]: T[K] } + +declare const f: () => IdMapped; +declare const g: () => { [K in keyof U]: U[K] }; + +const h: typeof g = f; + + +//// [higherOrderMappedIndexLookupInference.js] +// @strict +function f1(a, b) { + a = b; + b = a; +} +function f2(a, b) { + a = b; + b = a; +} +function f3(a, b) { + a = b; + b = a; +} +var h = f; diff --git a/tests/baselines/reference/higherOrderMappedIndexLookupInference.symbols b/tests/baselines/reference/higherOrderMappedIndexLookupInference.symbols new file mode 100644 index 00000000000..44ecb1e6d02 --- /dev/null +++ b/tests/baselines/reference/higherOrderMappedIndexLookupInference.symbols @@ -0,0 +1,98 @@ +=== tests/cases/compiler/higherOrderMappedIndexLookupInference.ts === +// @strict + +function f1(a: () => keyof T, b: () => keyof U) { +>f1 : Symbol(f1, Decl(higherOrderMappedIndexLookupInference.ts, 0, 0)) +>a : Symbol(a, Decl(higherOrderMappedIndexLookupInference.ts, 2, 12)) +>T : Symbol(T, Decl(higherOrderMappedIndexLookupInference.ts, 2, 16)) +>T : Symbol(T, Decl(higherOrderMappedIndexLookupInference.ts, 2, 16)) +>b : Symbol(b, Decl(higherOrderMappedIndexLookupInference.ts, 2, 32)) +>U : Symbol(U, Decl(higherOrderMappedIndexLookupInference.ts, 2, 37)) +>U : Symbol(U, Decl(higherOrderMappedIndexLookupInference.ts, 2, 37)) + + a = b; +>a : Symbol(a, Decl(higherOrderMappedIndexLookupInference.ts, 2, 12)) +>b : Symbol(b, Decl(higherOrderMappedIndexLookupInference.ts, 2, 32)) + + b = a; +>b : Symbol(b, Decl(higherOrderMappedIndexLookupInference.ts, 2, 32)) +>a : Symbol(a, Decl(higherOrderMappedIndexLookupInference.ts, 2, 12)) +} + +function f2(a: () => T[K], b: () => U[L]) { +>f2 : Symbol(f2, Decl(higherOrderMappedIndexLookupInference.ts, 5, 1)) +>a : Symbol(a, Decl(higherOrderMappedIndexLookupInference.ts, 7, 12)) +>T : Symbol(T, Decl(higherOrderMappedIndexLookupInference.ts, 7, 16)) +>K : Symbol(K, Decl(higherOrderMappedIndexLookupInference.ts, 7, 18)) +>T : Symbol(T, Decl(higherOrderMappedIndexLookupInference.ts, 7, 16)) +>T : Symbol(T, Decl(higherOrderMappedIndexLookupInference.ts, 7, 16)) +>K : Symbol(K, Decl(higherOrderMappedIndexLookupInference.ts, 7, 18)) +>b : Symbol(b, Decl(higherOrderMappedIndexLookupInference.ts, 7, 48)) +>U : Symbol(U, Decl(higherOrderMappedIndexLookupInference.ts, 7, 53)) +>L : Symbol(L, Decl(higherOrderMappedIndexLookupInference.ts, 7, 55)) +>U : Symbol(U, Decl(higherOrderMappedIndexLookupInference.ts, 7, 53)) +>U : Symbol(U, Decl(higherOrderMappedIndexLookupInference.ts, 7, 53)) +>L : Symbol(L, Decl(higherOrderMappedIndexLookupInference.ts, 7, 55)) + + a = b; +>a : Symbol(a, Decl(higherOrderMappedIndexLookupInference.ts, 7, 12)) +>b : Symbol(b, Decl(higherOrderMappedIndexLookupInference.ts, 7, 48)) + + b = a; +>b : Symbol(b, Decl(higherOrderMappedIndexLookupInference.ts, 7, 48)) +>a : Symbol(a, Decl(higherOrderMappedIndexLookupInference.ts, 7, 12)) +} + +function f3(a: () => { [K in keyof T]: T[K] }, b: () => { [K in keyof U]: U[K] }) { +>f3 : Symbol(f3, Decl(higherOrderMappedIndexLookupInference.ts, 10, 1)) +>a : Symbol(a, Decl(higherOrderMappedIndexLookupInference.ts, 12, 12)) +>T : Symbol(T, Decl(higherOrderMappedIndexLookupInference.ts, 12, 16)) +>K : Symbol(K, Decl(higherOrderMappedIndexLookupInference.ts, 12, 27)) +>T : Symbol(T, Decl(higherOrderMappedIndexLookupInference.ts, 12, 16)) +>T : Symbol(T, Decl(higherOrderMappedIndexLookupInference.ts, 12, 16)) +>K : Symbol(K, Decl(higherOrderMappedIndexLookupInference.ts, 12, 27)) +>b : Symbol(b, Decl(higherOrderMappedIndexLookupInference.ts, 12, 49)) +>U : Symbol(U, Decl(higherOrderMappedIndexLookupInference.ts, 12, 54)) +>K : Symbol(K, Decl(higherOrderMappedIndexLookupInference.ts, 12, 65)) +>U : Symbol(U, Decl(higherOrderMappedIndexLookupInference.ts, 12, 54)) +>U : Symbol(U, Decl(higherOrderMappedIndexLookupInference.ts, 12, 54)) +>K : Symbol(K, Decl(higherOrderMappedIndexLookupInference.ts, 12, 65)) + + a = b; +>a : Symbol(a, Decl(higherOrderMappedIndexLookupInference.ts, 12, 12)) +>b : Symbol(b, Decl(higherOrderMappedIndexLookupInference.ts, 12, 49)) + + b = a; +>b : Symbol(b, Decl(higherOrderMappedIndexLookupInference.ts, 12, 49)) +>a : Symbol(a, Decl(higherOrderMappedIndexLookupInference.ts, 12, 12)) +} + +// Repro from #18338 + +type IdMapped = { [K in keyof T]: T[K] } +>IdMapped : Symbol(IdMapped, Decl(higherOrderMappedIndexLookupInference.ts, 15, 1)) +>T : Symbol(T, Decl(higherOrderMappedIndexLookupInference.ts, 19, 14)) +>K : Symbol(K, Decl(higherOrderMappedIndexLookupInference.ts, 19, 22)) +>T : Symbol(T, Decl(higherOrderMappedIndexLookupInference.ts, 19, 14)) +>T : Symbol(T, Decl(higherOrderMappedIndexLookupInference.ts, 19, 14)) +>K : Symbol(K, Decl(higherOrderMappedIndexLookupInference.ts, 19, 22)) + +declare const f: () => IdMapped; +>f : Symbol(f, Decl(higherOrderMappedIndexLookupInference.ts, 21, 13)) +>T : Symbol(T, Decl(higherOrderMappedIndexLookupInference.ts, 21, 18)) +>IdMapped : Symbol(IdMapped, Decl(higherOrderMappedIndexLookupInference.ts, 15, 1)) +>T : Symbol(T, Decl(higherOrderMappedIndexLookupInference.ts, 21, 18)) + +declare const g: () => { [K in keyof U]: U[K] }; +>g : Symbol(g, Decl(higherOrderMappedIndexLookupInference.ts, 22, 13)) +>U : Symbol(U, Decl(higherOrderMappedIndexLookupInference.ts, 22, 18)) +>K : Symbol(K, Decl(higherOrderMappedIndexLookupInference.ts, 22, 29)) +>U : Symbol(U, Decl(higherOrderMappedIndexLookupInference.ts, 22, 18)) +>U : Symbol(U, Decl(higherOrderMappedIndexLookupInference.ts, 22, 18)) +>K : Symbol(K, Decl(higherOrderMappedIndexLookupInference.ts, 22, 29)) + +const h: typeof g = f; +>h : Symbol(h, Decl(higherOrderMappedIndexLookupInference.ts, 24, 5)) +>g : Symbol(g, Decl(higherOrderMappedIndexLookupInference.ts, 22, 13)) +>f : Symbol(f, Decl(higherOrderMappedIndexLookupInference.ts, 21, 13)) + diff --git a/tests/baselines/reference/higherOrderMappedIndexLookupInference.types b/tests/baselines/reference/higherOrderMappedIndexLookupInference.types new file mode 100644 index 00000000000..f1c2b0aa17b --- /dev/null +++ b/tests/baselines/reference/higherOrderMappedIndexLookupInference.types @@ -0,0 +1,104 @@ +=== tests/cases/compiler/higherOrderMappedIndexLookupInference.ts === +// @strict + +function f1(a: () => keyof T, b: () => keyof U) { +>f1 : (a: () => keyof T, b: () => keyof U) => void +>a : () => keyof T +>T : T +>T : T +>b : () => keyof U +>U : U +>U : U + + a = b; +>a = b : () => keyof U +>a : () => keyof T +>b : () => keyof U + + b = a; +>b = a : () => keyof T +>b : () => keyof U +>a : () => keyof T +} + +function f2(a: () => T[K], b: () => U[L]) { +>f2 : (a: () => T[K], b: () => U[L]) => void +>a : () => T[K] +>T : T +>K : K +>T : T +>T : T +>K : K +>b : () => U[L] +>U : U +>L : L +>U : U +>U : U +>L : L + + a = b; +>a = b : () => U[L] +>a : () => T[K] +>b : () => U[L] + + b = a; +>b = a : () => T[K] +>b : () => U[L] +>a : () => T[K] +} + +function f3(a: () => { [K in keyof T]: T[K] }, b: () => { [K in keyof U]: U[K] }) { +>f3 : (a: () => { [K in keyof T]: T[K]; }, b: () => { [K in keyof U]: U[K]; }) => void +>a : () => { [K in keyof T]: T[K]; } +>T : T +>K : K +>T : T +>T : T +>K : K +>b : () => { [K in keyof U]: U[K]; } +>U : U +>K : K +>U : U +>U : U +>K : K + + a = b; +>a = b : () => { [K in keyof U]: U[K]; } +>a : () => { [K in keyof T]: T[K]; } +>b : () => { [K in keyof U]: U[K]; } + + b = a; +>b = a : () => { [K in keyof T]: T[K]; } +>b : () => { [K in keyof U]: U[K]; } +>a : () => { [K in keyof T]: T[K]; } +} + +// Repro from #18338 + +type IdMapped = { [K in keyof T]: T[K] } +>IdMapped : IdMapped +>T : T +>K : K +>T : T +>T : T +>K : K + +declare const f: () => IdMapped; +>f : () => IdMapped +>T : T +>IdMapped : IdMapped +>T : T + +declare const g: () => { [K in keyof U]: U[K] }; +>g : () => { [K in keyof U]: U[K]; } +>U : U +>K : K +>U : U +>U : U +>K : K + +const h: typeof g = f; +>h : () => { [K in keyof U]: U[K]; } +>g : () => { [K in keyof U]: U[K]; } +>f : () => IdMapped + diff --git a/tests/cases/compiler/higherOrderMappedIndexLookupInference.ts b/tests/cases/compiler/higherOrderMappedIndexLookupInference.ts new file mode 100644 index 00000000000..96156283915 --- /dev/null +++ b/tests/cases/compiler/higherOrderMappedIndexLookupInference.ts @@ -0,0 +1,25 @@ +// @strict + +function f1(a: () => keyof T, b: () => keyof U) { + a = b; + b = a; +} + +function f2(a: () => T[K], b: () => U[L]) { + a = b; + b = a; +} + +function f3(a: () => { [K in keyof T]: T[K] }, b: () => { [K in keyof U]: U[K] }) { + a = b; + b = a; +} + +// Repro from #18338 + +type IdMapped = { [K in keyof T]: T[K] } + +declare const f: () => IdMapped; +declare const g: () => { [K in keyof U]: U[K] }; + +const h: typeof g = f; From 6c2fe29a72e8ad8d9ca178eeafe8d9bfa7a5b6bc Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Mon, 11 Sep 2017 11:02:11 -0700 Subject: [PATCH 299/370] Accept new baselines --- tests/baselines/reference/keyofAndIndexedAccess.types | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/baselines/reference/keyofAndIndexedAccess.types b/tests/baselines/reference/keyofAndIndexedAccess.types index 25d79e3f4ff..4bd5bb4e3c4 100644 --- a/tests/baselines/reference/keyofAndIndexedAccess.types +++ b/tests/baselines/reference/keyofAndIndexedAccess.types @@ -205,7 +205,7 @@ type Q40 = (Shape | Options)["visible"]; // boolean | "yes" | "no" >Options : Options type Q41 = (Shape & Options)["visible"]; // true & "yes" | true & "no" | false & "yes" | false & "no" ->Q41 : (true & "yes") | (true & "no") | (false & "yes") | (false & "no") +>Q41 : never >Shape : Shape >Options : Options From 2fdb5b8659bbf909a90f11d1e31b43bbe0da934c Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Mon, 11 Sep 2017 11:16:01 -0700 Subject: [PATCH 300/370] assignContextualParameterTypes handles arguments object Previously, it would crash — the arguments object is a transient symbol with no declaration, and `getEffectiveTypeAnnotationNode` does not accept `undefined`. --- src/compiler/checker.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index ff5d1c661e8..b8b2e8edb82 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -16665,8 +16665,9 @@ namespace ts { } } if (signature.hasRestParameter && isRestParameterIndex(context, signature.parameters.length - 1)) { + // parameter might be a transient symbol generated by use of `arguments` in the function body. const parameter = lastOrUndefined(signature.parameters); - if (!getEffectiveTypeAnnotationNode(parameter.valueDeclaration)) { + if (isTransientSymbol(parameter) || !getEffectiveTypeAnnotationNode(parameter.valueDeclaration)) { const contextualParameterType = getTypeOfSymbol(lastOrUndefined(context.parameters)); assignTypeToParameterAndFixTypeParameters(parameter, contextualParameterType); } From 4e04a740f884d71668754efc4b0064976fe45773 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Mon, 11 Sep 2017 11:17:14 -0700 Subject: [PATCH 301/370] Test:contextual typing of arguments obj in JS files --- .../contextuallyTypeArgumentsKeyword.symbols | 14 ++++++++++++++ .../contextuallyTypeArgumentsKeyword.types | 18 ++++++++++++++++++ .../contextuallyTypeArgumentsKeyword.ts | 11 +++++++++++ 3 files changed, 43 insertions(+) create mode 100644 tests/baselines/reference/contextuallyTypeArgumentsKeyword.symbols create mode 100644 tests/baselines/reference/contextuallyTypeArgumentsKeyword.types create mode 100644 tests/cases/compiler/contextuallyTypeArgumentsKeyword.ts diff --git a/tests/baselines/reference/contextuallyTypeArgumentsKeyword.symbols b/tests/baselines/reference/contextuallyTypeArgumentsKeyword.symbols new file mode 100644 index 00000000000..556c362f27e --- /dev/null +++ b/tests/baselines/reference/contextuallyTypeArgumentsKeyword.symbols @@ -0,0 +1,14 @@ +=== tests/cases/compiler/foo.js === +// Repro for #16585 +const x = { +>x : Symbol(x, Decl(foo.js, 1, 5)) + + bar() { +>bar : Symbol(bar, Decl(foo.js, 1, 11)) + + setTimeout(function() { arguments }, 0); +>setTimeout : Symbol(setTimeout, Decl(lib.dom.d.ts, --, --), Decl(lib.dom.d.ts, --, --)) +>arguments : Symbol(arguments) + } +} + diff --git a/tests/baselines/reference/contextuallyTypeArgumentsKeyword.types b/tests/baselines/reference/contextuallyTypeArgumentsKeyword.types new file mode 100644 index 00000000000..2f90f47f370 --- /dev/null +++ b/tests/baselines/reference/contextuallyTypeArgumentsKeyword.types @@ -0,0 +1,18 @@ +=== tests/cases/compiler/foo.js === +// Repro for #16585 +const x = { +>x : { [x: string]: any; bar(): void; } +>{ bar() { setTimeout(function() { arguments }, 0); }} : { [x: string]: any; bar(): void; } + + bar() { +>bar : () => void + + setTimeout(function() { arguments }, 0); +>setTimeout(function() { arguments }, 0) : number +>setTimeout : { (handler: (...args: any[]) => void, timeout: number): number; (handler: any, timeout?: any, ...args: any[]): number; } +>function() { arguments } : (...args: any[]) => void +>arguments : IArguments +>0 : 0 + } +} + diff --git a/tests/cases/compiler/contextuallyTypeArgumentsKeyword.ts b/tests/cases/compiler/contextuallyTypeArgumentsKeyword.ts new file mode 100644 index 00000000000..9421e70c4e8 --- /dev/null +++ b/tests/cases/compiler/contextuallyTypeArgumentsKeyword.ts @@ -0,0 +1,11 @@ +// @noEmit: true +// @allowJs: true +// @checkJs: true +// @lib: es2017, dom +// @Filename: foo.js +// Repro for #16585 +const x = { + bar() { + setTimeout(function() { arguments }, 0); + } +} From 29d5e4daddc3a97ec81b338b6a3a5ae1892288fe Mon Sep 17 00:00:00 2001 From: Herrington Darkholme Date: Tue, 12 Sep 2017 02:21:35 +0800 Subject: [PATCH 302/370] fix #18225, fix error message on abstract class instance (#18368) * fix #18225, fix error message on abstract class instance abstract class check should be inside constructor call * add new test and accept baseline --- src/compiler/checker.ts | 20 +++++++++---------- .../reference/newAbstractInstance.errors.txt | 10 ++++++++++ .../reference/newAbstractInstance.js | 13 ++++++++++++ tests/cases/compiler/newAbstractInstance.ts | 3 +++ 4 files changed, 36 insertions(+), 10 deletions(-) create mode 100644 tests/baselines/reference/newAbstractInstance.errors.txt create mode 100644 tests/baselines/reference/newAbstractInstance.js create mode 100644 tests/cases/compiler/newAbstractInstance.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index ff5d1c661e8..66ae64e199b 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -16128,16 +16128,6 @@ namespace ts { return resolveErrorCall(node); } - // If the expression is a class of abstract type, then it cannot be instantiated. - // 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. - const valueDecl = expressionType.symbol && getClassLikeDeclarationOfSymbol(expressionType.symbol); - if (valueDecl && hasModifier(valueDecl, ModifierFlags.Abstract)) { - error(node, Diagnostics.Cannot_create_an_instance_of_the_abstract_class_0, declarationNameToString(getNameOfDeclaration(valueDecl))); - return resolveErrorCall(node); - } - // TS 1.0 spec: 4.11 // If expressionType is of type Any, Args can be any argument // list and the result of the operation is of type Any. @@ -16157,6 +16147,16 @@ namespace ts { if (!isConstructorAccessible(node, constructSignatures[0])) { return resolveErrorCall(node); } + // If the expression is a class of abstract type, then it cannot be instantiated. + // 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. + const valueDecl = expressionType.symbol && getClassLikeDeclarationOfSymbol(expressionType.symbol); + if (valueDecl && hasModifier(valueDecl, ModifierFlags.Abstract)) { + error(node, Diagnostics.Cannot_create_an_instance_of_the_abstract_class_0, declarationNameToString(getNameOfDeclaration(valueDecl))); + return resolveErrorCall(node); + } + return resolveCall(node, constructSignatures, candidatesOutArray); } diff --git a/tests/baselines/reference/newAbstractInstance.errors.txt b/tests/baselines/reference/newAbstractInstance.errors.txt new file mode 100644 index 00000000000..13a5aff9df3 --- /dev/null +++ b/tests/baselines/reference/newAbstractInstance.errors.txt @@ -0,0 +1,10 @@ +tests/cases/compiler/newAbstractInstance.ts(3,1): error TS2351: Cannot use 'new' with an expression whose type lacks a call or construct signature. + + +==== tests/cases/compiler/newAbstractInstance.ts (1 errors) ==== + abstract class B { } + declare const b: B; + new b(); + ~~~~~~~ +!!! error TS2351: Cannot use 'new' with an expression whose type lacks a call or construct signature. + \ No newline at end of file diff --git a/tests/baselines/reference/newAbstractInstance.js b/tests/baselines/reference/newAbstractInstance.js new file mode 100644 index 00000000000..4a84b42cc20 --- /dev/null +++ b/tests/baselines/reference/newAbstractInstance.js @@ -0,0 +1,13 @@ +//// [newAbstractInstance.ts] +abstract class B { } +declare const b: B; +new b(); + + +//// [newAbstractInstance.js] +var B = /** @class */ (function () { + function B() { + } + return B; +}()); +new b(); diff --git a/tests/cases/compiler/newAbstractInstance.ts b/tests/cases/compiler/newAbstractInstance.ts new file mode 100644 index 00000000000..f686aafa005 --- /dev/null +++ b/tests/cases/compiler/newAbstractInstance.ts @@ -0,0 +1,3 @@ +abstract class B { } +declare const b: B; +new b(); From 1ee3b651418b6a4813f21970f4685f7ca1587827 Mon Sep 17 00:00:00 2001 From: Thomas den Hollander Date: Mon, 11 Sep 2017 20:22:46 +0200 Subject: [PATCH 303/370] Change typed array signatures (#18367) --- src/lib/es5.d.ts | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/src/lib/es5.d.ts b/src/lib/es5.d.ts index 6033a8fd989..820a90554ea 100644 --- a/src/lib/es5.d.ts +++ b/src/lib/es5.d.ts @@ -1744,8 +1744,8 @@ interface Int8Array { interface Int8ArrayConstructor { readonly prototype: Int8Array; new(length: number): Int8Array; - new(array: ArrayLike): Int8Array; - new(buffer: ArrayBufferLike, byteOffset?: number, length?: number): Int8Array; + new(arrayOrArrayBuffer: ArrayLike | ArrayBufferLike): Int8Array; + new(buffer: ArrayBufferLike, byteOffset: number, length?: number): Int8Array; /** * The size in bytes of each element in the array. @@ -2012,8 +2012,8 @@ interface Uint8Array { interface Uint8ArrayConstructor { readonly prototype: Uint8Array; new(length: number): Uint8Array; - new(array: ArrayLike): Uint8Array; - new(buffer: ArrayBufferLike, byteOffset?: number, length?: number): Uint8Array; + new(arrayOrArrayBuffer: ArrayLike | ArrayBufferLike): Uint8Array; + new(buffer: ArrayBufferLike, byteOffset: number, length?: number): Uint8Array; /** * The size in bytes of each element in the array. @@ -2279,8 +2279,8 @@ interface Uint8ClampedArray { interface Uint8ClampedArrayConstructor { readonly prototype: Uint8ClampedArray; new(length: number): Uint8ClampedArray; - new(array: ArrayLike): Uint8ClampedArray; - new(buffer: ArrayBufferLike, byteOffset?: number, length?: number): Uint8ClampedArray; + new(arrayOrArrayBuffer: ArrayLike | ArrayBufferLike): Uint8ClampedArray; + new(buffer: ArrayBufferLike, byteOffset: number, length?: number): Uint8ClampedArray; /** * The size in bytes of each element in the array. @@ -2544,8 +2544,8 @@ interface Int16Array { interface Int16ArrayConstructor { readonly prototype: Int16Array; new(length: number): Int16Array; - new(array: ArrayLike): Int16Array; - new(buffer: ArrayBufferLike, byteOffset?: number, length?: number): Int16Array; + new(arrayOrArrayBuffer: ArrayLike | ArrayBufferLike): Int16Array; + new(buffer: ArrayBufferLike, byteOffset: number, length?: number): Int16Array; /** * The size in bytes of each element in the array. @@ -2812,8 +2812,8 @@ interface Uint16Array { interface Uint16ArrayConstructor { readonly prototype: Uint16Array; new(length: number): Uint16Array; - new(array: ArrayLike): Uint16Array; - new(buffer: ArrayBufferLike, byteOffset?: number, length?: number): Uint16Array; + new(arrayOrArrayBuffer: ArrayLike | ArrayBufferLike): Uint16Array; + new(buffer: ArrayBufferLike, byteOffset: number, length?: number): Uint16Array; /** * The size in bytes of each element in the array. @@ -3079,8 +3079,8 @@ interface Int32Array { interface Int32ArrayConstructor { readonly prototype: Int32Array; new(length: number): Int32Array; - new(array: ArrayLike): Int32Array; - new(buffer: ArrayBufferLike, byteOffset?: number, length?: number): Int32Array; + new(arrayOrArrayBuffer: ArrayLike | ArrayBufferLike): Int32Array; + new(buffer: ArrayBufferLike, byteOffset: number, length?: number): Int32Array; /** * The size in bytes of each element in the array. @@ -3345,8 +3345,8 @@ interface Uint32Array { interface Uint32ArrayConstructor { readonly prototype: Uint32Array; new(length: number): Uint32Array; - new(array: ArrayLike): Uint32Array; - new(buffer: ArrayBufferLike, byteOffset?: number, length?: number): Uint32Array; + new(arrayOrArrayBuffer: ArrayLike | ArrayBufferLike): Uint32Array; + new(buffer: ArrayBufferLike, byteOffset: number, length?: number): Uint32Array; /** * The size in bytes of each element in the array. @@ -3612,8 +3612,8 @@ interface Float32Array { interface Float32ArrayConstructor { readonly prototype: Float32Array; new(length: number): Float32Array; - new(array: ArrayLike): Float32Array; - new(buffer: ArrayBufferLike, byteOffset?: number, length?: number): Float32Array; + new(arrayOrArrayBuffer: ArrayLike | ArrayBufferLike): Float32Array; + new(buffer: ArrayBufferLike, byteOffset: number, length?: number): Float32Array; /** * The size in bytes of each element in the array. @@ -3880,8 +3880,8 @@ interface Float64Array { interface Float64ArrayConstructor { readonly prototype: Float64Array; new(length: number): Float64Array; - new(array: ArrayLike): Float64Array; - new(buffer: ArrayBufferLike, byteOffset?: number, length?: number): Float64Array; + new(arrayOrArrayBuffer: ArrayLike | ArrayBufferLike): Float64Array; + new(buffer: ArrayBufferLike, byteOffset: number, length?: number): Float64Array; /** * The size in bytes of each element in the array. From 403f585622192d2ebf53196354b87cf467ea1908 Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Tue, 12 Sep 2017 10:43:24 -0700 Subject: [PATCH 304/370] enclosingDeclaration can be undefined within getAccessibleSymbolChain (#18400) --- 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 c87062a212f..c169dcb83ca 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -2063,7 +2063,7 @@ namespace ts { return rightMeaning === SymbolFlags.Value ? SymbolFlags.Value : SymbolFlags.Namespace; } - function getAccessibleSymbolChain(symbol: Symbol, enclosingDeclaration: Node, meaning: SymbolFlags, useOnlyExternalAliasing: boolean): Symbol[] | undefined { + function getAccessibleSymbolChain(symbol: Symbol, enclosingDeclaration: Node | undefined, meaning: SymbolFlags, useOnlyExternalAliasing: boolean): Symbol[] | undefined { if (!(symbol && !isPropertyOrMethodDeclarationSymbol(symbol))) { return undefined; } @@ -2112,7 +2112,7 @@ namespace ts { if (symbolFromSymbolTable.flags & SymbolFlags.Alias && symbolFromSymbolTable.escapedName !== "export=" && !getDeclarationOfKind(symbolFromSymbolTable, SyntaxKind.ExportSpecifier) - && !(isUMDExportSymbol(symbolFromSymbolTable) && isExternalModule(getSourceFileOfNode(enclosingDeclaration))) + && !(isUMDExportSymbol(symbolFromSymbolTable) && enclosingDeclaration && isExternalModule(getSourceFileOfNode(enclosingDeclaration))) // If `!useOnlyExternalAliasing`, we can use any type of alias to get the name && (!useOnlyExternalAliasing || some(symbolFromSymbolTable.declarations, isExternalModuleImportEqualsDeclaration))) { @@ -2132,7 +2132,7 @@ namespace ts { } } - function needsQualification(symbol: Symbol, enclosingDeclaration: Node, meaning: SymbolFlags) { + function needsQualification(symbol: Symbol, enclosingDeclaration: Node | undefined, meaning: SymbolFlags) { let qualify = false; forEachSymbolTableInScope(enclosingDeclaration, symbolTable => { // If symbol of this name is not available in the symbol table we are ok From 4c4316da722840a66a2412201e258feeae7cff14 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Tue, 12 Sep 2017 14:01:05 -0700 Subject: [PATCH 305/370] Fail spec parsing lambdas on parameter missing a = Fail speculative parsing of arrow function expressions whenever it has a parameter with an initialiser that is missing '='. Ordinarily this is allowed for better error recovery in the language service, but for speculative parsing, the errors can compound. When the initialiser is an error, and when the '=>' is missing (which is also allowed), what is putatively an arrow function may actually be something else. For example, `(a / 8) + function () { }` is currently parsed as if someone had intended to write `(a = /8)+function()/) => { }` but they forgot the `=` of the initialiser, the `=>` of the lambda, forgot to close the regular expression, and mistakenly inserted a newline right after the regular expression. --- src/compiler/parser.ts | 39 +++++++++---------- .../parserArrowFunctionExpression5.symbols | 15 +++++++ .../parserArrowFunctionExpression5.types | 25 ++++++++++++ ...gularExpressionDivideAmbiguity7.errors.txt | 12 ++++++ ...parserRegularExpressionDivideAmbiguity7.js | 8 ++++ .../parserArrowFunctionExpression6.ts | 3 ++ ...parserRegularExpressionDivideAmbiguity7.ts | 2 + 7 files changed, 84 insertions(+), 20 deletions(-) create mode 100644 tests/baselines/reference/parserArrowFunctionExpression5.symbols create mode 100644 tests/baselines/reference/parserArrowFunctionExpression5.types create mode 100644 tests/baselines/reference/parserRegularExpressionDivideAmbiguity7.errors.txt create mode 100644 tests/baselines/reference/parserRegularExpressionDivideAmbiguity7.js create mode 100644 tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/parserArrowFunctionExpression6.ts create mode 100644 tests/cases/conformance/parser/ecmascript5/RegularExpressions/parserRegularExpressionDivideAmbiguity7.ts diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index 63f1696832b..eaddab96b5c 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -2240,7 +2240,7 @@ namespace ts { isStartOfType(/*inStartOfParameter*/ true); } - function parseParameter(): ParameterDeclaration { + function parseParameter(requireEqualsToken?: boolean): ParameterDeclaration { const node = createNode(SyntaxKind.Parameter); if (token() === SyntaxKind.ThisKeyword) { node.name = createIdentifier(/*isIdentifier*/ true); @@ -2269,19 +2269,11 @@ namespace ts { node.questionToken = parseOptionalToken(SyntaxKind.QuestionToken); node.type = parseParameterType(); - node.initializer = parseBindingElementInitializer(/*inParameter*/ true); + node.initializer = parseInitializer(/*inParameter*/ true, requireEqualsToken); return addJSDocComment(finishNode(node)); } - function parseBindingElementInitializer(inParameter: boolean) { - return inParameter ? parseParameterInitializer() : parseNonParameterInitializer(); - } - - function parseParameterInitializer() { - return parseInitializer(/*inParameter*/ true); - } - function fillSignature( returnToken: SyntaxKind.ColonToken | SyntaxKind.EqualsGreaterThanToken, flags: SignatureFlags, @@ -2334,7 +2326,8 @@ namespace ts { setYieldContext(!!(flags & SignatureFlags.Yield)); setAwaitContext(!!(flags & SignatureFlags.Await)); - const result = parseDelimitedList(ParsingContext.Parameters, flags & SignatureFlags.JSDoc ? parseJSDocParameter : parseParameter); + const result = parseDelimitedList(ParsingContext.Parameters, + flags & SignatureFlags.JSDoc ? parseJSDocParameter : () => parseParameter(!!(flags & SignatureFlags.RequireCompleteParameterList))); setYieldContext(savedYieldContext); setAwaitContext(savedAwaitContext); @@ -3017,7 +3010,7 @@ namespace ts { return expr; } - function parseInitializer(inParameter: boolean): Expression { + function parseInitializer(inParameter: boolean, requireEqualsToken?: boolean): Expression { if (token() !== SyntaxKind.EqualsToken) { // It's not uncommon during typing for the user to miss writing the '=' token. Check if // there is no newline after the last token and if we're on an expression. If so, parse @@ -3032,11 +3025,18 @@ namespace ts { // do not try to parse initializer return undefined; } + if (inParameter && requireEqualsToken) { + // this occurs with speculative parsing of lambdas, so try to consume the initializer, + // but signal that the parameter was missing the equals sign so it can abort if it wants + parseAssignmentExpressionOrHigher(); + const result = createNode(SyntaxKind.Identifier, scanner.getStartPos()) as Identifier; + result.escapedText = "= not found" as __String; + return result; + } } // Initializer[In, Yield] : // = AssignmentExpression[?In, ?Yield] - parseExpected(SyntaxKind.EqualsToken); return parseAssignmentExpressionOrHigher(); } @@ -3351,8 +3351,7 @@ namespace ts { function tryParseAsyncSimpleArrowFunctionExpression(): ArrowFunction | undefined { // We do a check here so that we won't be doing unnecessarily call to "lookAhead" if (token() === SyntaxKind.AsyncKeyword) { - const isUnParenthesizedAsyncArrowFunction = lookAhead(isUnParenthesizedAsyncArrowFunctionWorker); - if (isUnParenthesizedAsyncArrowFunction === Tristate.True) { + if (lookAhead(isUnParenthesizedAsyncArrowFunctionWorker) === Tristate.True) { const asyncModifier = parseModifiersForArrowFunction(); const expr = parseBinaryExpressionOrHigher(/*precedence*/ 0); return parseSimpleArrowFunctionExpression(expr, asyncModifier); @@ -3386,7 +3385,6 @@ namespace ts { const node = createNode(SyntaxKind.ArrowFunction); node.modifiers = parseModifiersForArrowFunction(); const isAsync = hasModifier(node, ModifierFlags.Async) ? SignatureFlags.Await : SignatureFlags.None; - // Arrow functions are never generators. // // If we're speculatively parsing a signature for a parenthesized arrow function, then @@ -3409,7 +3407,8 @@ namespace ts { // - "a ? (b): c" will have "(b):" parsed as a signature with a return type annotation. // // So we need just a bit of lookahead to ensure that it can only be a signature. - if (!allowAmbiguity && token() !== SyntaxKind.EqualsGreaterThanToken && token() !== SyntaxKind.OpenBraceToken) { + if (!allowAmbiguity && ((token() !== SyntaxKind.EqualsGreaterThanToken && token() !== SyntaxKind.OpenBraceToken) || + find(node.parameters, p => p.initializer && ts.isIdentifier(p.initializer) && p.initializer.escapedText === "= not found"))) { // Returning undefined here will cause our caller to rewind to where we started from. return undefined; } @@ -5158,7 +5157,7 @@ namespace ts { const node = createNode(SyntaxKind.BindingElement); node.dotDotDotToken = parseOptionalToken(SyntaxKind.DotDotDotToken); node.name = parseIdentifierOrPattern(); - node.initializer = parseBindingElementInitializer(/*inParameter*/ false); + node.initializer = parseInitializer(/*inParameter*/ false); return finishNode(node); } @@ -5175,7 +5174,7 @@ namespace ts { node.propertyName = propertyName; node.name = parseIdentifierOrPattern(); } - node.initializer = parseBindingElementInitializer(/*inParameter*/ false); + node.initializer = parseInitializer(/*inParameter*/ false); return finishNode(node); } @@ -5214,7 +5213,7 @@ namespace ts { node.name = parseIdentifierOrPattern(); node.type = parseTypeAnnotation(); if (!isInOrOfKeyword(token())) { - node.initializer = parseInitializer(/*inParameter*/ false); + node.initializer = parseNonParameterInitializer(); } return finishNode(node); } diff --git a/tests/baselines/reference/parserArrowFunctionExpression5.symbols b/tests/baselines/reference/parserArrowFunctionExpression5.symbols new file mode 100644 index 00000000000..d2b369c70de --- /dev/null +++ b/tests/baselines/reference/parserArrowFunctionExpression5.symbols @@ -0,0 +1,15 @@ +=== tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/parserArrowFunctionExpression5.ts === +function foo(q: string, b: number) { +>foo : Symbol(foo, Decl(parserArrowFunctionExpression5.ts, 0, 0)) +>q : Symbol(q, Decl(parserArrowFunctionExpression5.ts, 0, 13)) +>b : Symbol(b, Decl(parserArrowFunctionExpression5.ts, 0, 23)) + + return true ? (q ? true : false) : (b = q.length, function() { }); +>q : Symbol(q, Decl(parserArrowFunctionExpression5.ts, 0, 13)) +>b : Symbol(b, Decl(parserArrowFunctionExpression5.ts, 0, 23)) +>q.length : Symbol(String.length, Decl(lib.d.ts, --, --)) +>q : Symbol(q, Decl(parserArrowFunctionExpression5.ts, 0, 13)) +>length : Symbol(String.length, Decl(lib.d.ts, --, --)) + +}; + diff --git a/tests/baselines/reference/parserArrowFunctionExpression5.types b/tests/baselines/reference/parserArrowFunctionExpression5.types new file mode 100644 index 00000000000..ea9d9395fc0 --- /dev/null +++ b/tests/baselines/reference/parserArrowFunctionExpression5.types @@ -0,0 +1,25 @@ +=== tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/parserArrowFunctionExpression5.ts === +function foo(q: string, b: number) { +>foo : (q: string, b: number) => boolean | (() => void) +>q : string +>b : number + + return true ? (q ? true : false) : (b = q.length, function() { }); +>true ? (q ? true : false) : (b = q.length, function() { }) : boolean | (() => void) +>true : true +>(q ? true : false) : boolean +>q ? true : false : boolean +>q : string +>true : true +>false : false +>(b = q.length, function() { }) : () => void +>b = q.length, function() { } : () => void +>b = q.length : number +>b : number +>q.length : number +>q : string +>length : number +>function() { } : () => void + +}; + diff --git a/tests/baselines/reference/parserRegularExpressionDivideAmbiguity7.errors.txt b/tests/baselines/reference/parserRegularExpressionDivideAmbiguity7.errors.txt new file mode 100644 index 00000000000..4ec2f5358f7 --- /dev/null +++ b/tests/baselines/reference/parserRegularExpressionDivideAmbiguity7.errors.txt @@ -0,0 +1,12 @@ +tests/cases/conformance/parser/ecmascript5/RegularExpressions/parserRegularExpressionDivideAmbiguity7.ts(1,2): error TS2304: Cannot find name 'a'. +tests/cases/conformance/parser/ecmascript5/RegularExpressions/parserRegularExpressionDivideAmbiguity7.ts(2,3): error TS1005: ';' expected. + + +==== tests/cases/conformance/parser/ecmascript5/RegularExpressions/parserRegularExpressionDivideAmbiguity7.ts (2 errors) ==== + (a/8 + ~ +!!! error TS2304: Cannot find name 'a'. + ){} + ~ +!!! error TS1005: ';' expected. + \ No newline at end of file diff --git a/tests/baselines/reference/parserRegularExpressionDivideAmbiguity7.js b/tests/baselines/reference/parserRegularExpressionDivideAmbiguity7.js new file mode 100644 index 00000000000..e2af8b6f5b7 --- /dev/null +++ b/tests/baselines/reference/parserRegularExpressionDivideAmbiguity7.js @@ -0,0 +1,8 @@ +//// [parserRegularExpressionDivideAmbiguity7.ts] +(a/8 + ){} + + +//// [parserRegularExpressionDivideAmbiguity7.js] +(a / 8); +{ } diff --git a/tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/parserArrowFunctionExpression6.ts b/tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/parserArrowFunctionExpression6.ts new file mode 100644 index 00000000000..d4af97ddf7d --- /dev/null +++ b/tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/parserArrowFunctionExpression6.ts @@ -0,0 +1,3 @@ +function foo(q: string, b: number) { + return true ? (q ? true : false) : (b = q.length, function() { }); +}; diff --git a/tests/cases/conformance/parser/ecmascript5/RegularExpressions/parserRegularExpressionDivideAmbiguity7.ts b/tests/cases/conformance/parser/ecmascript5/RegularExpressions/parserRegularExpressionDivideAmbiguity7.ts new file mode 100644 index 00000000000..54f19f7964e --- /dev/null +++ b/tests/cases/conformance/parser/ecmascript5/RegularExpressions/parserRegularExpressionDivideAmbiguity7.ts @@ -0,0 +1,2 @@ +(a/8 + ){} From d8ace9ddfbc923d782e5ae7142c20f8c1debbc78 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Tue, 12 Sep 2017 14:41:51 -0700 Subject: [PATCH 306/370] Don't parse param init when = is required but missing Makes another test case pass that was taking exponential time to parse, because now it notices that the = is not present and doesn't even try to parse the initialiser expression. --- src/compiler/parser.ts | 5 +- ...parserRegularExpressionDivideAmbiguity6.js | 46 ++ ...rRegularExpressionDivideAmbiguity6.symbols | 172 ++++++ ...serRegularExpressionDivideAmbiguity6.types | 498 ++++++++++++++++++ ...parserRegularExpressionDivideAmbiguity6.ts | 21 + 5 files changed, 739 insertions(+), 3 deletions(-) create mode 100644 tests/baselines/reference/parserRegularExpressionDivideAmbiguity6.js create mode 100644 tests/baselines/reference/parserRegularExpressionDivideAmbiguity6.symbols create mode 100644 tests/baselines/reference/parserRegularExpressionDivideAmbiguity6.types create mode 100644 tests/cases/conformance/parser/ecmascript5/RegularExpressions/parserRegularExpressionDivideAmbiguity6.ts diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index eaddab96b5c..6d6b757f6e9 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -3026,9 +3026,8 @@ namespace ts { return undefined; } if (inParameter && requireEqualsToken) { - // this occurs with speculative parsing of lambdas, so try to consume the initializer, - // but signal that the parameter was missing the equals sign so it can abort if it wants - parseAssignmentExpressionOrHigher(); + // = is required when speculatively parsing arrow function parameters, + // so return a fake initializer as a signal that the equals token was missing const result = createNode(SyntaxKind.Identifier, scanner.getStartPos()) as Identifier; result.escapedText = "= not found" as __String; return result; diff --git a/tests/baselines/reference/parserRegularExpressionDivideAmbiguity6.js b/tests/baselines/reference/parserRegularExpressionDivideAmbiguity6.js new file mode 100644 index 00000000000..dfcecd0b383 --- /dev/null +++ b/tests/baselines/reference/parserRegularExpressionDivideAmbiguity6.js @@ -0,0 +1,46 @@ +//// [parserRegularExpressionDivideAmbiguity6.ts] +function c255lsqr8h(a7, a6, a5, a4, a3, a2, a1, a0) { + let r = []; + let v; + r[0] = (v = a0*a0) & 0xFFFF; + r[1] = (v = ((v / 0x10000) | 0) + 2*a0*a1) & 0xFFFF; + r[2] = (v = ((v / 0x10000) | 0) + 2*a0*a2 + a1*a1) & 0xFFFF; + r[3] = (v = ((v / 0x10000) | 0) + 2*a0*a3 + 2*a1*a2) & 0xFFFF; + r[4] = (v = ((v / 0x10000) | 0) + 2*a0*a4 + 2*a1*a3 + a2*a2) & 0xFFFF; + r[5] = (v = ((v / 0x10000) | 0) + 2*a0*a5 + 2*a1*a4 + 2*a2*a3) & 0xFFFF; + r[6] = (v = ((v / 0x10000) | 0) + 2*a0*a6 + 2*a1*a5 + 2*a2*a4 + a3*a3) & 0xFFFF; + r[7] = (v = ((v / 0x10000) | 0) + 2*a0*a7 + 2*a1*a6 + 2*a2*a5 + 2*a3*a4) & 0xFFFF; + r[8] = (v = ((v / 0x10000) | 0) + 2*a1*a7 + 2*a2*a6 + 2*a3*a5 + a4*a4) & 0xFFFF; + r[9] = (v = ((v / 0x10000) | 0) + 2*a2*a7 + 2*a3*a6 + 2*a4*a5) & 0xFFFF; + r[10] = (v = ((v / 0x10000) | 0) + 2*a3*a7 + 2*a4*a6 + a5*a5) & 0xFFFF; + r[11] = (v = ((v / 0x10000) | 0) + 2*a4*a7 + 2*a5*a6) & 0xFFFF; + r[12] = (v = ((v / 0x10000) | 0) + 2*a5*a7 + a6*a6) & 0xFFFF; + r[13] = (v = ((v / 0x10000) | 0) + 2*a6*a7) & 0xFFFF; + r[14] = (v = ((v / 0x10000) | 0) + a7*a7) & 0xFFFF; + r[15] = ((v / 0x10000) | 0); + return r; +} + + +//// [parserRegularExpressionDivideAmbiguity6.js] +function c255lsqr8h(a7, a6, a5, a4, a3, a2, a1, a0) { + var r = []; + var v; + r[0] = (v = a0 * a0) & 0xFFFF; + r[1] = (v = ((v / 0x10000) | 0) + 2 * a0 * a1) & 0xFFFF; + r[2] = (v = ((v / 0x10000) | 0) + 2 * a0 * a2 + a1 * a1) & 0xFFFF; + r[3] = (v = ((v / 0x10000) | 0) + 2 * a0 * a3 + 2 * a1 * a2) & 0xFFFF; + r[4] = (v = ((v / 0x10000) | 0) + 2 * a0 * a4 + 2 * a1 * a3 + a2 * a2) & 0xFFFF; + r[5] = (v = ((v / 0x10000) | 0) + 2 * a0 * a5 + 2 * a1 * a4 + 2 * a2 * a3) & 0xFFFF; + r[6] = (v = ((v / 0x10000) | 0) + 2 * a0 * a6 + 2 * a1 * a5 + 2 * a2 * a4 + a3 * a3) & 0xFFFF; + r[7] = (v = ((v / 0x10000) | 0) + 2 * a0 * a7 + 2 * a1 * a6 + 2 * a2 * a5 + 2 * a3 * a4) & 0xFFFF; + r[8] = (v = ((v / 0x10000) | 0) + 2 * a1 * a7 + 2 * a2 * a6 + 2 * a3 * a5 + a4 * a4) & 0xFFFF; + r[9] = (v = ((v / 0x10000) | 0) + 2 * a2 * a7 + 2 * a3 * a6 + 2 * a4 * a5) & 0xFFFF; + r[10] = (v = ((v / 0x10000) | 0) + 2 * a3 * a7 + 2 * a4 * a6 + a5 * a5) & 0xFFFF; + r[11] = (v = ((v / 0x10000) | 0) + 2 * a4 * a7 + 2 * a5 * a6) & 0xFFFF; + r[12] = (v = ((v / 0x10000) | 0) + 2 * a5 * a7 + a6 * a6) & 0xFFFF; + r[13] = (v = ((v / 0x10000) | 0) + 2 * a6 * a7) & 0xFFFF; + r[14] = (v = ((v / 0x10000) | 0) + a7 * a7) & 0xFFFF; + r[15] = ((v / 0x10000) | 0); + return r; +} diff --git a/tests/baselines/reference/parserRegularExpressionDivideAmbiguity6.symbols b/tests/baselines/reference/parserRegularExpressionDivideAmbiguity6.symbols new file mode 100644 index 00000000000..3ae02bb1888 --- /dev/null +++ b/tests/baselines/reference/parserRegularExpressionDivideAmbiguity6.symbols @@ -0,0 +1,172 @@ +=== tests/cases/conformance/parser/ecmascript5/RegularExpressions/parserRegularExpressionDivideAmbiguity6.ts === +function c255lsqr8h(a7, a6, a5, a4, a3, a2, a1, a0) { +>c255lsqr8h : Symbol(c255lsqr8h, Decl(parserRegularExpressionDivideAmbiguity6.ts, 0, 0)) +>a7 : Symbol(a7, Decl(parserRegularExpressionDivideAmbiguity6.ts, 0, 20)) +>a6 : Symbol(a6, Decl(parserRegularExpressionDivideAmbiguity6.ts, 0, 23)) +>a5 : Symbol(a5, Decl(parserRegularExpressionDivideAmbiguity6.ts, 0, 27)) +>a4 : Symbol(a4, Decl(parserRegularExpressionDivideAmbiguity6.ts, 0, 31)) +>a3 : Symbol(a3, Decl(parserRegularExpressionDivideAmbiguity6.ts, 0, 35)) +>a2 : Symbol(a2, Decl(parserRegularExpressionDivideAmbiguity6.ts, 0, 39)) +>a1 : Symbol(a1, Decl(parserRegularExpressionDivideAmbiguity6.ts, 0, 43)) +>a0 : Symbol(a0, Decl(parserRegularExpressionDivideAmbiguity6.ts, 0, 47)) + + let r = []; +>r : Symbol(r, Decl(parserRegularExpressionDivideAmbiguity6.ts, 1, 7)) + + let v; +>v : Symbol(v, Decl(parserRegularExpressionDivideAmbiguity6.ts, 2, 7)) + + r[0] = (v = a0*a0) & 0xFFFF; +>r : Symbol(r, Decl(parserRegularExpressionDivideAmbiguity6.ts, 1, 7)) +>v : Symbol(v, Decl(parserRegularExpressionDivideAmbiguity6.ts, 2, 7)) +>a0 : Symbol(a0, Decl(parserRegularExpressionDivideAmbiguity6.ts, 0, 47)) +>a0 : Symbol(a0, Decl(parserRegularExpressionDivideAmbiguity6.ts, 0, 47)) + + r[1] = (v = ((v / 0x10000) | 0) + 2*a0*a1) & 0xFFFF; +>r : Symbol(r, Decl(parserRegularExpressionDivideAmbiguity6.ts, 1, 7)) +>v : Symbol(v, Decl(parserRegularExpressionDivideAmbiguity6.ts, 2, 7)) +>v : Symbol(v, Decl(parserRegularExpressionDivideAmbiguity6.ts, 2, 7)) +>a0 : Symbol(a0, Decl(parserRegularExpressionDivideAmbiguity6.ts, 0, 47)) +>a1 : Symbol(a1, Decl(parserRegularExpressionDivideAmbiguity6.ts, 0, 43)) + + r[2] = (v = ((v / 0x10000) | 0) + 2*a0*a2 + a1*a1) & 0xFFFF; +>r : Symbol(r, Decl(parserRegularExpressionDivideAmbiguity6.ts, 1, 7)) +>v : Symbol(v, Decl(parserRegularExpressionDivideAmbiguity6.ts, 2, 7)) +>v : Symbol(v, Decl(parserRegularExpressionDivideAmbiguity6.ts, 2, 7)) +>a0 : Symbol(a0, Decl(parserRegularExpressionDivideAmbiguity6.ts, 0, 47)) +>a2 : Symbol(a2, Decl(parserRegularExpressionDivideAmbiguity6.ts, 0, 39)) +>a1 : Symbol(a1, Decl(parserRegularExpressionDivideAmbiguity6.ts, 0, 43)) +>a1 : Symbol(a1, Decl(parserRegularExpressionDivideAmbiguity6.ts, 0, 43)) + + r[3] = (v = ((v / 0x10000) | 0) + 2*a0*a3 + 2*a1*a2) & 0xFFFF; +>r : Symbol(r, Decl(parserRegularExpressionDivideAmbiguity6.ts, 1, 7)) +>v : Symbol(v, Decl(parserRegularExpressionDivideAmbiguity6.ts, 2, 7)) +>v : Symbol(v, Decl(parserRegularExpressionDivideAmbiguity6.ts, 2, 7)) +>a0 : Symbol(a0, Decl(parserRegularExpressionDivideAmbiguity6.ts, 0, 47)) +>a3 : Symbol(a3, Decl(parserRegularExpressionDivideAmbiguity6.ts, 0, 35)) +>a1 : Symbol(a1, Decl(parserRegularExpressionDivideAmbiguity6.ts, 0, 43)) +>a2 : Symbol(a2, Decl(parserRegularExpressionDivideAmbiguity6.ts, 0, 39)) + + r[4] = (v = ((v / 0x10000) | 0) + 2*a0*a4 + 2*a1*a3 + a2*a2) & 0xFFFF; +>r : Symbol(r, Decl(parserRegularExpressionDivideAmbiguity6.ts, 1, 7)) +>v : Symbol(v, Decl(parserRegularExpressionDivideAmbiguity6.ts, 2, 7)) +>v : Symbol(v, Decl(parserRegularExpressionDivideAmbiguity6.ts, 2, 7)) +>a0 : Symbol(a0, Decl(parserRegularExpressionDivideAmbiguity6.ts, 0, 47)) +>a4 : Symbol(a4, Decl(parserRegularExpressionDivideAmbiguity6.ts, 0, 31)) +>a1 : Symbol(a1, Decl(parserRegularExpressionDivideAmbiguity6.ts, 0, 43)) +>a3 : Symbol(a3, Decl(parserRegularExpressionDivideAmbiguity6.ts, 0, 35)) +>a2 : Symbol(a2, Decl(parserRegularExpressionDivideAmbiguity6.ts, 0, 39)) +>a2 : Symbol(a2, Decl(parserRegularExpressionDivideAmbiguity6.ts, 0, 39)) + + r[5] = (v = ((v / 0x10000) | 0) + 2*a0*a5 + 2*a1*a4 + 2*a2*a3) & 0xFFFF; +>r : Symbol(r, Decl(parserRegularExpressionDivideAmbiguity6.ts, 1, 7)) +>v : Symbol(v, Decl(parserRegularExpressionDivideAmbiguity6.ts, 2, 7)) +>v : Symbol(v, Decl(parserRegularExpressionDivideAmbiguity6.ts, 2, 7)) +>a0 : Symbol(a0, Decl(parserRegularExpressionDivideAmbiguity6.ts, 0, 47)) +>a5 : Symbol(a5, Decl(parserRegularExpressionDivideAmbiguity6.ts, 0, 27)) +>a1 : Symbol(a1, Decl(parserRegularExpressionDivideAmbiguity6.ts, 0, 43)) +>a4 : Symbol(a4, Decl(parserRegularExpressionDivideAmbiguity6.ts, 0, 31)) +>a2 : Symbol(a2, Decl(parserRegularExpressionDivideAmbiguity6.ts, 0, 39)) +>a3 : Symbol(a3, Decl(parserRegularExpressionDivideAmbiguity6.ts, 0, 35)) + + r[6] = (v = ((v / 0x10000) | 0) + 2*a0*a6 + 2*a1*a5 + 2*a2*a4 + a3*a3) & 0xFFFF; +>r : Symbol(r, Decl(parserRegularExpressionDivideAmbiguity6.ts, 1, 7)) +>v : Symbol(v, Decl(parserRegularExpressionDivideAmbiguity6.ts, 2, 7)) +>v : Symbol(v, Decl(parserRegularExpressionDivideAmbiguity6.ts, 2, 7)) +>a0 : Symbol(a0, Decl(parserRegularExpressionDivideAmbiguity6.ts, 0, 47)) +>a6 : Symbol(a6, Decl(parserRegularExpressionDivideAmbiguity6.ts, 0, 23)) +>a1 : Symbol(a1, Decl(parserRegularExpressionDivideAmbiguity6.ts, 0, 43)) +>a5 : Symbol(a5, Decl(parserRegularExpressionDivideAmbiguity6.ts, 0, 27)) +>a2 : Symbol(a2, Decl(parserRegularExpressionDivideAmbiguity6.ts, 0, 39)) +>a4 : Symbol(a4, Decl(parserRegularExpressionDivideAmbiguity6.ts, 0, 31)) +>a3 : Symbol(a3, Decl(parserRegularExpressionDivideAmbiguity6.ts, 0, 35)) +>a3 : Symbol(a3, Decl(parserRegularExpressionDivideAmbiguity6.ts, 0, 35)) + + r[7] = (v = ((v / 0x10000) | 0) + 2*a0*a7 + 2*a1*a6 + 2*a2*a5 + 2*a3*a4) & 0xFFFF; +>r : Symbol(r, Decl(parserRegularExpressionDivideAmbiguity6.ts, 1, 7)) +>v : Symbol(v, Decl(parserRegularExpressionDivideAmbiguity6.ts, 2, 7)) +>v : Symbol(v, Decl(parserRegularExpressionDivideAmbiguity6.ts, 2, 7)) +>a0 : Symbol(a0, Decl(parserRegularExpressionDivideAmbiguity6.ts, 0, 47)) +>a7 : Symbol(a7, Decl(parserRegularExpressionDivideAmbiguity6.ts, 0, 20)) +>a1 : Symbol(a1, Decl(parserRegularExpressionDivideAmbiguity6.ts, 0, 43)) +>a6 : Symbol(a6, Decl(parserRegularExpressionDivideAmbiguity6.ts, 0, 23)) +>a2 : Symbol(a2, Decl(parserRegularExpressionDivideAmbiguity6.ts, 0, 39)) +>a5 : Symbol(a5, Decl(parserRegularExpressionDivideAmbiguity6.ts, 0, 27)) +>a3 : Symbol(a3, Decl(parserRegularExpressionDivideAmbiguity6.ts, 0, 35)) +>a4 : Symbol(a4, Decl(parserRegularExpressionDivideAmbiguity6.ts, 0, 31)) + + r[8] = (v = ((v / 0x10000) | 0) + 2*a1*a7 + 2*a2*a6 + 2*a3*a5 + a4*a4) & 0xFFFF; +>r : Symbol(r, Decl(parserRegularExpressionDivideAmbiguity6.ts, 1, 7)) +>v : Symbol(v, Decl(parserRegularExpressionDivideAmbiguity6.ts, 2, 7)) +>v : Symbol(v, Decl(parserRegularExpressionDivideAmbiguity6.ts, 2, 7)) +>a1 : Symbol(a1, Decl(parserRegularExpressionDivideAmbiguity6.ts, 0, 43)) +>a7 : Symbol(a7, Decl(parserRegularExpressionDivideAmbiguity6.ts, 0, 20)) +>a2 : Symbol(a2, Decl(parserRegularExpressionDivideAmbiguity6.ts, 0, 39)) +>a6 : Symbol(a6, Decl(parserRegularExpressionDivideAmbiguity6.ts, 0, 23)) +>a3 : Symbol(a3, Decl(parserRegularExpressionDivideAmbiguity6.ts, 0, 35)) +>a5 : Symbol(a5, Decl(parserRegularExpressionDivideAmbiguity6.ts, 0, 27)) +>a4 : Symbol(a4, Decl(parserRegularExpressionDivideAmbiguity6.ts, 0, 31)) +>a4 : Symbol(a4, Decl(parserRegularExpressionDivideAmbiguity6.ts, 0, 31)) + + r[9] = (v = ((v / 0x10000) | 0) + 2*a2*a7 + 2*a3*a6 + 2*a4*a5) & 0xFFFF; +>r : Symbol(r, Decl(parserRegularExpressionDivideAmbiguity6.ts, 1, 7)) +>v : Symbol(v, Decl(parserRegularExpressionDivideAmbiguity6.ts, 2, 7)) +>v : Symbol(v, Decl(parserRegularExpressionDivideAmbiguity6.ts, 2, 7)) +>a2 : Symbol(a2, Decl(parserRegularExpressionDivideAmbiguity6.ts, 0, 39)) +>a7 : Symbol(a7, Decl(parserRegularExpressionDivideAmbiguity6.ts, 0, 20)) +>a3 : Symbol(a3, Decl(parserRegularExpressionDivideAmbiguity6.ts, 0, 35)) +>a6 : Symbol(a6, Decl(parserRegularExpressionDivideAmbiguity6.ts, 0, 23)) +>a4 : Symbol(a4, Decl(parserRegularExpressionDivideAmbiguity6.ts, 0, 31)) +>a5 : Symbol(a5, Decl(parserRegularExpressionDivideAmbiguity6.ts, 0, 27)) + + r[10] = (v = ((v / 0x10000) | 0) + 2*a3*a7 + 2*a4*a6 + a5*a5) & 0xFFFF; +>r : Symbol(r, Decl(parserRegularExpressionDivideAmbiguity6.ts, 1, 7)) +>v : Symbol(v, Decl(parserRegularExpressionDivideAmbiguity6.ts, 2, 7)) +>v : Symbol(v, Decl(parserRegularExpressionDivideAmbiguity6.ts, 2, 7)) +>a3 : Symbol(a3, Decl(parserRegularExpressionDivideAmbiguity6.ts, 0, 35)) +>a7 : Symbol(a7, Decl(parserRegularExpressionDivideAmbiguity6.ts, 0, 20)) +>a4 : Symbol(a4, Decl(parserRegularExpressionDivideAmbiguity6.ts, 0, 31)) +>a6 : Symbol(a6, Decl(parserRegularExpressionDivideAmbiguity6.ts, 0, 23)) +>a5 : Symbol(a5, Decl(parserRegularExpressionDivideAmbiguity6.ts, 0, 27)) +>a5 : Symbol(a5, Decl(parserRegularExpressionDivideAmbiguity6.ts, 0, 27)) + + r[11] = (v = ((v / 0x10000) | 0) + 2*a4*a7 + 2*a5*a6) & 0xFFFF; +>r : Symbol(r, Decl(parserRegularExpressionDivideAmbiguity6.ts, 1, 7)) +>v : Symbol(v, Decl(parserRegularExpressionDivideAmbiguity6.ts, 2, 7)) +>v : Symbol(v, Decl(parserRegularExpressionDivideAmbiguity6.ts, 2, 7)) +>a4 : Symbol(a4, Decl(parserRegularExpressionDivideAmbiguity6.ts, 0, 31)) +>a7 : Symbol(a7, Decl(parserRegularExpressionDivideAmbiguity6.ts, 0, 20)) +>a5 : Symbol(a5, Decl(parserRegularExpressionDivideAmbiguity6.ts, 0, 27)) +>a6 : Symbol(a6, Decl(parserRegularExpressionDivideAmbiguity6.ts, 0, 23)) + + r[12] = (v = ((v / 0x10000) | 0) + 2*a5*a7 + a6*a6) & 0xFFFF; +>r : Symbol(r, Decl(parserRegularExpressionDivideAmbiguity6.ts, 1, 7)) +>v : Symbol(v, Decl(parserRegularExpressionDivideAmbiguity6.ts, 2, 7)) +>v : Symbol(v, Decl(parserRegularExpressionDivideAmbiguity6.ts, 2, 7)) +>a5 : Symbol(a5, Decl(parserRegularExpressionDivideAmbiguity6.ts, 0, 27)) +>a7 : Symbol(a7, Decl(parserRegularExpressionDivideAmbiguity6.ts, 0, 20)) +>a6 : Symbol(a6, Decl(parserRegularExpressionDivideAmbiguity6.ts, 0, 23)) +>a6 : Symbol(a6, Decl(parserRegularExpressionDivideAmbiguity6.ts, 0, 23)) + + r[13] = (v = ((v / 0x10000) | 0) + 2*a6*a7) & 0xFFFF; +>r : Symbol(r, Decl(parserRegularExpressionDivideAmbiguity6.ts, 1, 7)) +>v : Symbol(v, Decl(parserRegularExpressionDivideAmbiguity6.ts, 2, 7)) +>v : Symbol(v, Decl(parserRegularExpressionDivideAmbiguity6.ts, 2, 7)) +>a6 : Symbol(a6, Decl(parserRegularExpressionDivideAmbiguity6.ts, 0, 23)) +>a7 : Symbol(a7, Decl(parserRegularExpressionDivideAmbiguity6.ts, 0, 20)) + + r[14] = (v = ((v / 0x10000) | 0) + a7*a7) & 0xFFFF; +>r : Symbol(r, Decl(parserRegularExpressionDivideAmbiguity6.ts, 1, 7)) +>v : Symbol(v, Decl(parserRegularExpressionDivideAmbiguity6.ts, 2, 7)) +>v : Symbol(v, Decl(parserRegularExpressionDivideAmbiguity6.ts, 2, 7)) +>a7 : Symbol(a7, Decl(parserRegularExpressionDivideAmbiguity6.ts, 0, 20)) +>a7 : Symbol(a7, Decl(parserRegularExpressionDivideAmbiguity6.ts, 0, 20)) + + r[15] = ((v / 0x10000) | 0); +>r : Symbol(r, Decl(parserRegularExpressionDivideAmbiguity6.ts, 1, 7)) +>v : Symbol(v, Decl(parserRegularExpressionDivideAmbiguity6.ts, 2, 7)) + + return r; +>r : Symbol(r, Decl(parserRegularExpressionDivideAmbiguity6.ts, 1, 7)) +} + diff --git a/tests/baselines/reference/parserRegularExpressionDivideAmbiguity6.types b/tests/baselines/reference/parserRegularExpressionDivideAmbiguity6.types new file mode 100644 index 00000000000..50c3d2f92ad --- /dev/null +++ b/tests/baselines/reference/parserRegularExpressionDivideAmbiguity6.types @@ -0,0 +1,498 @@ +=== tests/cases/conformance/parser/ecmascript5/RegularExpressions/parserRegularExpressionDivideAmbiguity6.ts === +function c255lsqr8h(a7, a6, a5, a4, a3, a2, a1, a0) { +>c255lsqr8h : (a7: any, a6: any, a5: any, a4: any, a3: any, a2: any, a1: any, a0: any) => any[] +>a7 : any +>a6 : any +>a5 : any +>a4 : any +>a3 : any +>a2 : any +>a1 : any +>a0 : any + + let r = []; +>r : any[] +>[] : undefined[] + + let v; +>v : any + + r[0] = (v = a0*a0) & 0xFFFF; +>r[0] = (v = a0*a0) & 0xFFFF : number +>r[0] : any +>r : any[] +>0 : 0 +>(v = a0*a0) & 0xFFFF : number +>(v = a0*a0) : number +>v = a0*a0 : number +>v : any +>a0*a0 : number +>a0 : any +>a0 : any +>0xFFFF : 65535 + + r[1] = (v = ((v / 0x10000) | 0) + 2*a0*a1) & 0xFFFF; +>r[1] = (v = ((v / 0x10000) | 0) + 2*a0*a1) & 0xFFFF : number +>r[1] : any +>r : any[] +>1 : 1 +>(v = ((v / 0x10000) | 0) + 2*a0*a1) & 0xFFFF : number +>(v = ((v / 0x10000) | 0) + 2*a0*a1) : number +>v = ((v / 0x10000) | 0) + 2*a0*a1 : number +>v : any +>((v / 0x10000) | 0) + 2*a0*a1 : number +>((v / 0x10000) | 0) : number +>(v / 0x10000) | 0 : number +>(v / 0x10000) : number +>v / 0x10000 : number +>v : any +>0x10000 : 65536 +>0 : 0 +>2*a0*a1 : number +>2*a0 : number +>2 : 2 +>a0 : any +>a1 : any +>0xFFFF : 65535 + + r[2] = (v = ((v / 0x10000) | 0) + 2*a0*a2 + a1*a1) & 0xFFFF; +>r[2] = (v = ((v / 0x10000) | 0) + 2*a0*a2 + a1*a1) & 0xFFFF : number +>r[2] : any +>r : any[] +>2 : 2 +>(v = ((v / 0x10000) | 0) + 2*a0*a2 + a1*a1) & 0xFFFF : number +>(v = ((v / 0x10000) | 0) + 2*a0*a2 + a1*a1) : number +>v = ((v / 0x10000) | 0) + 2*a0*a2 + a1*a1 : number +>v : any +>((v / 0x10000) | 0) + 2*a0*a2 + a1*a1 : number +>((v / 0x10000) | 0) + 2*a0*a2 : number +>((v / 0x10000) | 0) : number +>(v / 0x10000) | 0 : number +>(v / 0x10000) : number +>v / 0x10000 : number +>v : any +>0x10000 : 65536 +>0 : 0 +>2*a0*a2 : number +>2*a0 : number +>2 : 2 +>a0 : any +>a2 : any +>a1*a1 : number +>a1 : any +>a1 : any +>0xFFFF : 65535 + + r[3] = (v = ((v / 0x10000) | 0) + 2*a0*a3 + 2*a1*a2) & 0xFFFF; +>r[3] = (v = ((v / 0x10000) | 0) + 2*a0*a3 + 2*a1*a2) & 0xFFFF : number +>r[3] : any +>r : any[] +>3 : 3 +>(v = ((v / 0x10000) | 0) + 2*a0*a3 + 2*a1*a2) & 0xFFFF : number +>(v = ((v / 0x10000) | 0) + 2*a0*a3 + 2*a1*a2) : number +>v = ((v / 0x10000) | 0) + 2*a0*a3 + 2*a1*a2 : number +>v : any +>((v / 0x10000) | 0) + 2*a0*a3 + 2*a1*a2 : number +>((v / 0x10000) | 0) + 2*a0*a3 : number +>((v / 0x10000) | 0) : number +>(v / 0x10000) | 0 : number +>(v / 0x10000) : number +>v / 0x10000 : number +>v : any +>0x10000 : 65536 +>0 : 0 +>2*a0*a3 : number +>2*a0 : number +>2 : 2 +>a0 : any +>a3 : any +>2*a1*a2 : number +>2*a1 : number +>2 : 2 +>a1 : any +>a2 : any +>0xFFFF : 65535 + + r[4] = (v = ((v / 0x10000) | 0) + 2*a0*a4 + 2*a1*a3 + a2*a2) & 0xFFFF; +>r[4] = (v = ((v / 0x10000) | 0) + 2*a0*a4 + 2*a1*a3 + a2*a2) & 0xFFFF : number +>r[4] : any +>r : any[] +>4 : 4 +>(v = ((v / 0x10000) | 0) + 2*a0*a4 + 2*a1*a3 + a2*a2) & 0xFFFF : number +>(v = ((v / 0x10000) | 0) + 2*a0*a4 + 2*a1*a3 + a2*a2) : number +>v = ((v / 0x10000) | 0) + 2*a0*a4 + 2*a1*a3 + a2*a2 : number +>v : any +>((v / 0x10000) | 0) + 2*a0*a4 + 2*a1*a3 + a2*a2 : number +>((v / 0x10000) | 0) + 2*a0*a4 + 2*a1*a3 : number +>((v / 0x10000) | 0) + 2*a0*a4 : number +>((v / 0x10000) | 0) : number +>(v / 0x10000) | 0 : number +>(v / 0x10000) : number +>v / 0x10000 : number +>v : any +>0x10000 : 65536 +>0 : 0 +>2*a0*a4 : number +>2*a0 : number +>2 : 2 +>a0 : any +>a4 : any +>2*a1*a3 : number +>2*a1 : number +>2 : 2 +>a1 : any +>a3 : any +>a2*a2 : number +>a2 : any +>a2 : any +>0xFFFF : 65535 + + r[5] = (v = ((v / 0x10000) | 0) + 2*a0*a5 + 2*a1*a4 + 2*a2*a3) & 0xFFFF; +>r[5] = (v = ((v / 0x10000) | 0) + 2*a0*a5 + 2*a1*a4 + 2*a2*a3) & 0xFFFF : number +>r[5] : any +>r : any[] +>5 : 5 +>(v = ((v / 0x10000) | 0) + 2*a0*a5 + 2*a1*a4 + 2*a2*a3) & 0xFFFF : number +>(v = ((v / 0x10000) | 0) + 2*a0*a5 + 2*a1*a4 + 2*a2*a3) : number +>v = ((v / 0x10000) | 0) + 2*a0*a5 + 2*a1*a4 + 2*a2*a3 : number +>v : any +>((v / 0x10000) | 0) + 2*a0*a5 + 2*a1*a4 + 2*a2*a3 : number +>((v / 0x10000) | 0) + 2*a0*a5 + 2*a1*a4 : number +>((v / 0x10000) | 0) + 2*a0*a5 : number +>((v / 0x10000) | 0) : number +>(v / 0x10000) | 0 : number +>(v / 0x10000) : number +>v / 0x10000 : number +>v : any +>0x10000 : 65536 +>0 : 0 +>2*a0*a5 : number +>2*a0 : number +>2 : 2 +>a0 : any +>a5 : any +>2*a1*a4 : number +>2*a1 : number +>2 : 2 +>a1 : any +>a4 : any +>2*a2*a3 : number +>2*a2 : number +>2 : 2 +>a2 : any +>a3 : any +>0xFFFF : 65535 + + r[6] = (v = ((v / 0x10000) | 0) + 2*a0*a6 + 2*a1*a5 + 2*a2*a4 + a3*a3) & 0xFFFF; +>r[6] = (v = ((v / 0x10000) | 0) + 2*a0*a6 + 2*a1*a5 + 2*a2*a4 + a3*a3) & 0xFFFF : number +>r[6] : any +>r : any[] +>6 : 6 +>(v = ((v / 0x10000) | 0) + 2*a0*a6 + 2*a1*a5 + 2*a2*a4 + a3*a3) & 0xFFFF : number +>(v = ((v / 0x10000) | 0) + 2*a0*a6 + 2*a1*a5 + 2*a2*a4 + a3*a3) : number +>v = ((v / 0x10000) | 0) + 2*a0*a6 + 2*a1*a5 + 2*a2*a4 + a3*a3 : number +>v : any +>((v / 0x10000) | 0) + 2*a0*a6 + 2*a1*a5 + 2*a2*a4 + a3*a3 : number +>((v / 0x10000) | 0) + 2*a0*a6 + 2*a1*a5 + 2*a2*a4 : number +>((v / 0x10000) | 0) + 2*a0*a6 + 2*a1*a5 : number +>((v / 0x10000) | 0) + 2*a0*a6 : number +>((v / 0x10000) | 0) : number +>(v / 0x10000) | 0 : number +>(v / 0x10000) : number +>v / 0x10000 : number +>v : any +>0x10000 : 65536 +>0 : 0 +>2*a0*a6 : number +>2*a0 : number +>2 : 2 +>a0 : any +>a6 : any +>2*a1*a5 : number +>2*a1 : number +>2 : 2 +>a1 : any +>a5 : any +>2*a2*a4 : number +>2*a2 : number +>2 : 2 +>a2 : any +>a4 : any +>a3*a3 : number +>a3 : any +>a3 : any +>0xFFFF : 65535 + + r[7] = (v = ((v / 0x10000) | 0) + 2*a0*a7 + 2*a1*a6 + 2*a2*a5 + 2*a3*a4) & 0xFFFF; +>r[7] = (v = ((v / 0x10000) | 0) + 2*a0*a7 + 2*a1*a6 + 2*a2*a5 + 2*a3*a4) & 0xFFFF : number +>r[7] : any +>r : any[] +>7 : 7 +>(v = ((v / 0x10000) | 0) + 2*a0*a7 + 2*a1*a6 + 2*a2*a5 + 2*a3*a4) & 0xFFFF : number +>(v = ((v / 0x10000) | 0) + 2*a0*a7 + 2*a1*a6 + 2*a2*a5 + 2*a3*a4) : number +>v = ((v / 0x10000) | 0) + 2*a0*a7 + 2*a1*a6 + 2*a2*a5 + 2*a3*a4 : number +>v : any +>((v / 0x10000) | 0) + 2*a0*a7 + 2*a1*a6 + 2*a2*a5 + 2*a3*a4 : number +>((v / 0x10000) | 0) + 2*a0*a7 + 2*a1*a6 + 2*a2*a5 : number +>((v / 0x10000) | 0) + 2*a0*a7 + 2*a1*a6 : number +>((v / 0x10000) | 0) + 2*a0*a7 : number +>((v / 0x10000) | 0) : number +>(v / 0x10000) | 0 : number +>(v / 0x10000) : number +>v / 0x10000 : number +>v : any +>0x10000 : 65536 +>0 : 0 +>2*a0*a7 : number +>2*a0 : number +>2 : 2 +>a0 : any +>a7 : any +>2*a1*a6 : number +>2*a1 : number +>2 : 2 +>a1 : any +>a6 : any +>2*a2*a5 : number +>2*a2 : number +>2 : 2 +>a2 : any +>a5 : any +>2*a3*a4 : number +>2*a3 : number +>2 : 2 +>a3 : any +>a4 : any +>0xFFFF : 65535 + + r[8] = (v = ((v / 0x10000) | 0) + 2*a1*a7 + 2*a2*a6 + 2*a3*a5 + a4*a4) & 0xFFFF; +>r[8] = (v = ((v / 0x10000) | 0) + 2*a1*a7 + 2*a2*a6 + 2*a3*a5 + a4*a4) & 0xFFFF : number +>r[8] : any +>r : any[] +>8 : 8 +>(v = ((v / 0x10000) | 0) + 2*a1*a7 + 2*a2*a6 + 2*a3*a5 + a4*a4) & 0xFFFF : number +>(v = ((v / 0x10000) | 0) + 2*a1*a7 + 2*a2*a6 + 2*a3*a5 + a4*a4) : number +>v = ((v / 0x10000) | 0) + 2*a1*a7 + 2*a2*a6 + 2*a3*a5 + a4*a4 : number +>v : any +>((v / 0x10000) | 0) + 2*a1*a7 + 2*a2*a6 + 2*a3*a5 + a4*a4 : number +>((v / 0x10000) | 0) + 2*a1*a7 + 2*a2*a6 + 2*a3*a5 : number +>((v / 0x10000) | 0) + 2*a1*a7 + 2*a2*a6 : number +>((v / 0x10000) | 0) + 2*a1*a7 : number +>((v / 0x10000) | 0) : number +>(v / 0x10000) | 0 : number +>(v / 0x10000) : number +>v / 0x10000 : number +>v : any +>0x10000 : 65536 +>0 : 0 +>2*a1*a7 : number +>2*a1 : number +>2 : 2 +>a1 : any +>a7 : any +>2*a2*a6 : number +>2*a2 : number +>2 : 2 +>a2 : any +>a6 : any +>2*a3*a5 : number +>2*a3 : number +>2 : 2 +>a3 : any +>a5 : any +>a4*a4 : number +>a4 : any +>a4 : any +>0xFFFF : 65535 + + r[9] = (v = ((v / 0x10000) | 0) + 2*a2*a7 + 2*a3*a6 + 2*a4*a5) & 0xFFFF; +>r[9] = (v = ((v / 0x10000) | 0) + 2*a2*a7 + 2*a3*a6 + 2*a4*a5) & 0xFFFF : number +>r[9] : any +>r : any[] +>9 : 9 +>(v = ((v / 0x10000) | 0) + 2*a2*a7 + 2*a3*a6 + 2*a4*a5) & 0xFFFF : number +>(v = ((v / 0x10000) | 0) + 2*a2*a7 + 2*a3*a6 + 2*a4*a5) : number +>v = ((v / 0x10000) | 0) + 2*a2*a7 + 2*a3*a6 + 2*a4*a5 : number +>v : any +>((v / 0x10000) | 0) + 2*a2*a7 + 2*a3*a6 + 2*a4*a5 : number +>((v / 0x10000) | 0) + 2*a2*a7 + 2*a3*a6 : number +>((v / 0x10000) | 0) + 2*a2*a7 : number +>((v / 0x10000) | 0) : number +>(v / 0x10000) | 0 : number +>(v / 0x10000) : number +>v / 0x10000 : number +>v : any +>0x10000 : 65536 +>0 : 0 +>2*a2*a7 : number +>2*a2 : number +>2 : 2 +>a2 : any +>a7 : any +>2*a3*a6 : number +>2*a3 : number +>2 : 2 +>a3 : any +>a6 : any +>2*a4*a5 : number +>2*a4 : number +>2 : 2 +>a4 : any +>a5 : any +>0xFFFF : 65535 + + r[10] = (v = ((v / 0x10000) | 0) + 2*a3*a7 + 2*a4*a6 + a5*a5) & 0xFFFF; +>r[10] = (v = ((v / 0x10000) | 0) + 2*a3*a7 + 2*a4*a6 + a5*a5) & 0xFFFF : number +>r[10] : any +>r : any[] +>10 : 10 +>(v = ((v / 0x10000) | 0) + 2*a3*a7 + 2*a4*a6 + a5*a5) & 0xFFFF : number +>(v = ((v / 0x10000) | 0) + 2*a3*a7 + 2*a4*a6 + a5*a5) : number +>v = ((v / 0x10000) | 0) + 2*a3*a7 + 2*a4*a6 + a5*a5 : number +>v : any +>((v / 0x10000) | 0) + 2*a3*a7 + 2*a4*a6 + a5*a5 : number +>((v / 0x10000) | 0) + 2*a3*a7 + 2*a4*a6 : number +>((v / 0x10000) | 0) + 2*a3*a7 : number +>((v / 0x10000) | 0) : number +>(v / 0x10000) | 0 : number +>(v / 0x10000) : number +>v / 0x10000 : number +>v : any +>0x10000 : 65536 +>0 : 0 +>2*a3*a7 : number +>2*a3 : number +>2 : 2 +>a3 : any +>a7 : any +>2*a4*a6 : number +>2*a4 : number +>2 : 2 +>a4 : any +>a6 : any +>a5*a5 : number +>a5 : any +>a5 : any +>0xFFFF : 65535 + + r[11] = (v = ((v / 0x10000) | 0) + 2*a4*a7 + 2*a5*a6) & 0xFFFF; +>r[11] = (v = ((v / 0x10000) | 0) + 2*a4*a7 + 2*a5*a6) & 0xFFFF : number +>r[11] : any +>r : any[] +>11 : 11 +>(v = ((v / 0x10000) | 0) + 2*a4*a7 + 2*a5*a6) & 0xFFFF : number +>(v = ((v / 0x10000) | 0) + 2*a4*a7 + 2*a5*a6) : number +>v = ((v / 0x10000) | 0) + 2*a4*a7 + 2*a5*a6 : number +>v : any +>((v / 0x10000) | 0) + 2*a4*a7 + 2*a5*a6 : number +>((v / 0x10000) | 0) + 2*a4*a7 : number +>((v / 0x10000) | 0) : number +>(v / 0x10000) | 0 : number +>(v / 0x10000) : number +>v / 0x10000 : number +>v : any +>0x10000 : 65536 +>0 : 0 +>2*a4*a7 : number +>2*a4 : number +>2 : 2 +>a4 : any +>a7 : any +>2*a5*a6 : number +>2*a5 : number +>2 : 2 +>a5 : any +>a6 : any +>0xFFFF : 65535 + + r[12] = (v = ((v / 0x10000) | 0) + 2*a5*a7 + a6*a6) & 0xFFFF; +>r[12] = (v = ((v / 0x10000) | 0) + 2*a5*a7 + a6*a6) & 0xFFFF : number +>r[12] : any +>r : any[] +>12 : 12 +>(v = ((v / 0x10000) | 0) + 2*a5*a7 + a6*a6) & 0xFFFF : number +>(v = ((v / 0x10000) | 0) + 2*a5*a7 + a6*a6) : number +>v = ((v / 0x10000) | 0) + 2*a5*a7 + a6*a6 : number +>v : any +>((v / 0x10000) | 0) + 2*a5*a7 + a6*a6 : number +>((v / 0x10000) | 0) + 2*a5*a7 : number +>((v / 0x10000) | 0) : number +>(v / 0x10000) | 0 : number +>(v / 0x10000) : number +>v / 0x10000 : number +>v : any +>0x10000 : 65536 +>0 : 0 +>2*a5*a7 : number +>2*a5 : number +>2 : 2 +>a5 : any +>a7 : any +>a6*a6 : number +>a6 : any +>a6 : any +>0xFFFF : 65535 + + r[13] = (v = ((v / 0x10000) | 0) + 2*a6*a7) & 0xFFFF; +>r[13] = (v = ((v / 0x10000) | 0) + 2*a6*a7) & 0xFFFF : number +>r[13] : any +>r : any[] +>13 : 13 +>(v = ((v / 0x10000) | 0) + 2*a6*a7) & 0xFFFF : number +>(v = ((v / 0x10000) | 0) + 2*a6*a7) : number +>v = ((v / 0x10000) | 0) + 2*a6*a7 : number +>v : any +>((v / 0x10000) | 0) + 2*a6*a7 : number +>((v / 0x10000) | 0) : number +>(v / 0x10000) | 0 : number +>(v / 0x10000) : number +>v / 0x10000 : number +>v : any +>0x10000 : 65536 +>0 : 0 +>2*a6*a7 : number +>2*a6 : number +>2 : 2 +>a6 : any +>a7 : any +>0xFFFF : 65535 + + r[14] = (v = ((v / 0x10000) | 0) + a7*a7) & 0xFFFF; +>r[14] = (v = ((v / 0x10000) | 0) + a7*a7) & 0xFFFF : number +>r[14] : any +>r : any[] +>14 : 14 +>(v = ((v / 0x10000) | 0) + a7*a7) & 0xFFFF : number +>(v = ((v / 0x10000) | 0) + a7*a7) : number +>v = ((v / 0x10000) | 0) + a7*a7 : number +>v : any +>((v / 0x10000) | 0) + a7*a7 : number +>((v / 0x10000) | 0) : number +>(v / 0x10000) | 0 : number +>(v / 0x10000) : number +>v / 0x10000 : number +>v : any +>0x10000 : 65536 +>0 : 0 +>a7*a7 : number +>a7 : any +>a7 : any +>0xFFFF : 65535 + + r[15] = ((v / 0x10000) | 0); +>r[15] = ((v / 0x10000) | 0) : number +>r[15] : any +>r : any[] +>15 : 15 +>((v / 0x10000) | 0) : number +>(v / 0x10000) | 0 : number +>(v / 0x10000) : number +>v / 0x10000 : number +>v : any +>0x10000 : 65536 +>0 : 0 + + return r; +>r : any[] +} + diff --git a/tests/cases/conformance/parser/ecmascript5/RegularExpressions/parserRegularExpressionDivideAmbiguity6.ts b/tests/cases/conformance/parser/ecmascript5/RegularExpressions/parserRegularExpressionDivideAmbiguity6.ts new file mode 100644 index 00000000000..e2e742fd6bf --- /dev/null +++ b/tests/cases/conformance/parser/ecmascript5/RegularExpressions/parserRegularExpressionDivideAmbiguity6.ts @@ -0,0 +1,21 @@ +function c255lsqr8h(a7, a6, a5, a4, a3, a2, a1, a0) { + let r = []; + let v; + r[0] = (v = a0*a0) & 0xFFFF; + r[1] = (v = ((v / 0x10000) | 0) + 2*a0*a1) & 0xFFFF; + r[2] = (v = ((v / 0x10000) | 0) + 2*a0*a2 + a1*a1) & 0xFFFF; + r[3] = (v = ((v / 0x10000) | 0) + 2*a0*a3 + 2*a1*a2) & 0xFFFF; + r[4] = (v = ((v / 0x10000) | 0) + 2*a0*a4 + 2*a1*a3 + a2*a2) & 0xFFFF; + r[5] = (v = ((v / 0x10000) | 0) + 2*a0*a5 + 2*a1*a4 + 2*a2*a3) & 0xFFFF; + r[6] = (v = ((v / 0x10000) | 0) + 2*a0*a6 + 2*a1*a5 + 2*a2*a4 + a3*a3) & 0xFFFF; + r[7] = (v = ((v / 0x10000) | 0) + 2*a0*a7 + 2*a1*a6 + 2*a2*a5 + 2*a3*a4) & 0xFFFF; + r[8] = (v = ((v / 0x10000) | 0) + 2*a1*a7 + 2*a2*a6 + 2*a3*a5 + a4*a4) & 0xFFFF; + r[9] = (v = ((v / 0x10000) | 0) + 2*a2*a7 + 2*a3*a6 + 2*a4*a5) & 0xFFFF; + r[10] = (v = ((v / 0x10000) | 0) + 2*a3*a7 + 2*a4*a6 + a5*a5) & 0xFFFF; + r[11] = (v = ((v / 0x10000) | 0) + 2*a4*a7 + 2*a5*a6) & 0xFFFF; + r[12] = (v = ((v / 0x10000) | 0) + 2*a5*a7 + a6*a6) & 0xFFFF; + r[13] = (v = ((v / 0x10000) | 0) + 2*a6*a7) & 0xFFFF; + r[14] = (v = ((v / 0x10000) | 0) + a7*a7) & 0xFFFF; + r[15] = ((v / 0x10000) | 0); + return r; +} From 74ecef418dcf795c483bffb14b97159acd496313 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Tue, 12 Sep 2017 14:43:56 -0700 Subject: [PATCH 307/370] Add missed baselines --- .../parserArrowFunctionExpression6.js | 11 ++++++++ .../parserArrowFunctionExpression6.symbols | 15 +++++++++++ .../parserArrowFunctionExpression6.types | 25 +++++++++++++++++++ 3 files changed, 51 insertions(+) create mode 100644 tests/baselines/reference/parserArrowFunctionExpression6.js create mode 100644 tests/baselines/reference/parserArrowFunctionExpression6.symbols create mode 100644 tests/baselines/reference/parserArrowFunctionExpression6.types diff --git a/tests/baselines/reference/parserArrowFunctionExpression6.js b/tests/baselines/reference/parserArrowFunctionExpression6.js new file mode 100644 index 00000000000..1de3035cc76 --- /dev/null +++ b/tests/baselines/reference/parserArrowFunctionExpression6.js @@ -0,0 +1,11 @@ +//// [parserArrowFunctionExpression6.ts] +function foo(q: string, b: number) { + return true ? (q ? true : false) : (b = q.length, function() { }); +}; + + +//// [parserArrowFunctionExpression6.js] +function foo(q, b) { + return true ? (q ? true : false) : (b = q.length, function () { }); +} +; diff --git a/tests/baselines/reference/parserArrowFunctionExpression6.symbols b/tests/baselines/reference/parserArrowFunctionExpression6.symbols new file mode 100644 index 00000000000..9b3afdbb950 --- /dev/null +++ b/tests/baselines/reference/parserArrowFunctionExpression6.symbols @@ -0,0 +1,15 @@ +=== tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/parserArrowFunctionExpression6.ts === +function foo(q: string, b: number) { +>foo : Symbol(foo, Decl(parserArrowFunctionExpression6.ts, 0, 0)) +>q : Symbol(q, Decl(parserArrowFunctionExpression6.ts, 0, 13)) +>b : Symbol(b, Decl(parserArrowFunctionExpression6.ts, 0, 23)) + + return true ? (q ? true : false) : (b = q.length, function() { }); +>q : Symbol(q, Decl(parserArrowFunctionExpression6.ts, 0, 13)) +>b : Symbol(b, Decl(parserArrowFunctionExpression6.ts, 0, 23)) +>q.length : Symbol(String.length, Decl(lib.d.ts, --, --)) +>q : Symbol(q, Decl(parserArrowFunctionExpression6.ts, 0, 13)) +>length : Symbol(String.length, Decl(lib.d.ts, --, --)) + +}; + diff --git a/tests/baselines/reference/parserArrowFunctionExpression6.types b/tests/baselines/reference/parserArrowFunctionExpression6.types new file mode 100644 index 00000000000..6cc4f16e216 --- /dev/null +++ b/tests/baselines/reference/parserArrowFunctionExpression6.types @@ -0,0 +1,25 @@ +=== tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/parserArrowFunctionExpression6.ts === +function foo(q: string, b: number) { +>foo : (q: string, b: number) => boolean | (() => void) +>q : string +>b : number + + return true ? (q ? true : false) : (b = q.length, function() { }); +>true ? (q ? true : false) : (b = q.length, function() { }) : boolean | (() => void) +>true : true +>(q ? true : false) : boolean +>q ? true : false : boolean +>q : string +>true : true +>false : false +>(b = q.length, function() { }) : () => void +>b = q.length, function() { } : () => void +>b = q.length : number +>b : number +>q.length : number +>q : string +>length : number +>function() { } : () => void + +}; + From ece4e4f701813855371e8302a1ac82c3a65a5f70 Mon Sep 17 00:00:00 2001 From: Andrew Casey Date: Tue, 12 Sep 2017 18:11:12 -0700 Subject: [PATCH 308/370] Fix fourslash baselines 40e459117aeb0b792a23d6805af884b594dd42c4 was out of date in a way that didn't register as a conflict. --- tests/baselines/reference/extractMethod/extractMethod23.ts | 6 +++--- tests/baselines/reference/extractMethod/extractMethod24.ts | 6 +++--- tests/baselines/reference/extractMethod/extractMethod25.ts | 4 ++-- tests/baselines/reference/extractMethod/extractMethod26.ts | 4 ++-- tests/baselines/reference/extractMethod/extractMethod27.ts | 4 ++-- tests/baselines/reference/extractMethod/extractMethod28.ts | 4 ++-- 6 files changed, 14 insertions(+), 14 deletions(-) diff --git a/tests/baselines/reference/extractMethod/extractMethod23.ts b/tests/baselines/reference/extractMethod/extractMethod23.ts index 8bc3db86cc1..0c56434447e 100644 --- a/tests/baselines/reference/extractMethod/extractMethod23.ts +++ b/tests/baselines/reference/extractMethod/extractMethod23.ts @@ -6,7 +6,7 @@ namespace NS { } function M3() { } } -// ==SCOPE::function 'M2'== +// ==SCOPE::inner function in function 'M2'== namespace NS { function M1() { } function M2() { @@ -18,7 +18,7 @@ namespace NS { } function M3() { } } -// ==SCOPE::namespace 'NS'== +// ==SCOPE::function in namespace 'NS'== namespace NS { function M1() { } function M2() { @@ -30,7 +30,7 @@ namespace NS { function M3() { } } -// ==SCOPE::global scope== +// ==SCOPE::function in global scope== namespace NS { function M1() { } function M2() { diff --git a/tests/baselines/reference/extractMethod/extractMethod24.ts b/tests/baselines/reference/extractMethod/extractMethod24.ts index ec6d6cd3f12..0b33289708f 100644 --- a/tests/baselines/reference/extractMethod/extractMethod24.ts +++ b/tests/baselines/reference/extractMethod/extractMethod24.ts @@ -6,7 +6,7 @@ function Outer() { } function M3() { } } -// ==SCOPE::function 'M2'== +// ==SCOPE::inner function in function 'M2'== function Outer() { function M1() { } function M2() { @@ -18,7 +18,7 @@ function Outer() { } function M3() { } } -// ==SCOPE::function 'Outer'== +// ==SCOPE::inner function in function 'Outer'== function Outer() { function M1() { } function M2() { @@ -30,7 +30,7 @@ function Outer() { function M3() { } } -// ==SCOPE::global scope== +// ==SCOPE::function in global scope== function Outer() { function M1() { } function M2() { diff --git a/tests/baselines/reference/extractMethod/extractMethod25.ts b/tests/baselines/reference/extractMethod/extractMethod25.ts index a7a971315a1..c77ec1abbfd 100644 --- a/tests/baselines/reference/extractMethod/extractMethod25.ts +++ b/tests/baselines/reference/extractMethod/extractMethod25.ts @@ -4,7 +4,7 @@ function M2() { return 1; } function M3() { } -// ==SCOPE::function 'M2'== +// ==SCOPE::inner function in function 'M2'== function M1() { } function M2() { return newFunction(); @@ -14,7 +14,7 @@ function M2() { } } function M3() { } -// ==SCOPE::global scope== +// ==SCOPE::function in global scope== function M1() { } function M2() { return newFunction(); diff --git a/tests/baselines/reference/extractMethod/extractMethod26.ts b/tests/baselines/reference/extractMethod/extractMethod26.ts index d0619ea9b0a..84dc82f7fed 100644 --- a/tests/baselines/reference/extractMethod/extractMethod26.ts +++ b/tests/baselines/reference/extractMethod/extractMethod26.ts @@ -6,7 +6,7 @@ class C { } M3() { } } -// ==SCOPE::class 'C'== +// ==SCOPE::method in class 'C'== class C { M1() { } M2() { @@ -18,7 +18,7 @@ class C { M3() { } } -// ==SCOPE::global scope== +// ==SCOPE::function in global scope== class C { M1() { } M2() { diff --git a/tests/baselines/reference/extractMethod/extractMethod27.ts b/tests/baselines/reference/extractMethod/extractMethod27.ts index 9f1f1e84a77..ce21f1e1fed 100644 --- a/tests/baselines/reference/extractMethod/extractMethod27.ts +++ b/tests/baselines/reference/extractMethod/extractMethod27.ts @@ -7,7 +7,7 @@ class C { constructor() { } M3() { } } -// ==SCOPE::class 'C'== +// ==SCOPE::method in class 'C'== class C { M1() { } M2() { @@ -20,7 +20,7 @@ class C { M3() { } } -// ==SCOPE::global scope== +// ==SCOPE::function in global scope== class C { M1() { } M2() { diff --git a/tests/baselines/reference/extractMethod/extractMethod28.ts b/tests/baselines/reference/extractMethod/extractMethod28.ts index 9b97e581548..e3d0fc3b9ea 100644 --- a/tests/baselines/reference/extractMethod/extractMethod28.ts +++ b/tests/baselines/reference/extractMethod/extractMethod28.ts @@ -7,7 +7,7 @@ class C { M3() { } constructor() { } } -// ==SCOPE::class 'C'== +// ==SCOPE::method in class 'C'== class C { M1() { } M2() { @@ -20,7 +20,7 @@ class C { M3() { } constructor() { } } -// ==SCOPE::global scope== +// ==SCOPE::function in global scope== class C { M1() { } M2() { From a02aaf2625342f101fe1a4c94c5ac0ceb9a2cff1 Mon Sep 17 00:00:00 2001 From: Andrew Casey Date: Tue, 12 Sep 2017 18:07:25 -0700 Subject: [PATCH 309/370] Forbid extraction of empty spans --- src/harness/unittests/extractMethods.ts | 6 ++++++ src/services/refactors/extractMethod.ts | 5 +++++ 2 files changed, 11 insertions(+) diff --git a/src/harness/unittests/extractMethods.ts b/src/harness/unittests/extractMethods.ts index edcc80cd57c..d0ce38126d8 100644 --- a/src/harness/unittests/extractMethods.ts +++ b/src/harness/unittests/extractMethods.ts @@ -404,6 +404,12 @@ function test(x: number) { "Cannot extract range containing conditional break or continue statements." ]); + testExtractRangeFailed("extractRangeFailed9", + `var x = ([#||]1 + 2);`, + [ + "Statement or expression expected." + ]); + testExtractMethod("extractMethod1", `namespace A { let x = 1; diff --git a/src/services/refactors/extractMethod.ts b/src/services/refactors/extractMethod.ts index b0554138134..fc3abc2f367 100644 --- a/src/services/refactors/extractMethod.ts +++ b/src/services/refactors/extractMethod.ts @@ -162,6 +162,11 @@ namespace ts.refactor.extractMethod { */ export function getRangeToExtract(sourceFile: SourceFile, span: TextSpan): RangeToExtract { const length = span.length || 0; + + if (length === 0) { + return { errors: [createFileDiagnostic(sourceFile, span.start, length, Messages.StatementOrExpressionExpected)] }; + } + // Walk up starting from the the start position until we find a non-SourceFile node that subsumes the selected span. // This may fail (e.g. you select two statements in the root of a source file) let start = getParentNodeInSpan(getTokenAtPosition(sourceFile, span.start, /*includeJsDocComment*/ false), sourceFile, span); From 78f4cbe53c8696d6f8b23424fcfd666c7d71ba01 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Wed, 13 Sep 2017 06:37:59 -0700 Subject: [PATCH 310/370] Add tests --- .../intersectionOfUnionOfUnitTypes.js | 47 ++++++ .../intersectionOfUnionOfUnitTypes.symbols | 156 ++++++++++++++++++ .../intersectionOfUnionOfUnitTypes.types | 156 ++++++++++++++++++ .../intersectionOfUnionOfUnitTypes.ts | 24 +++ 4 files changed, 383 insertions(+) create mode 100644 tests/baselines/reference/intersectionOfUnionOfUnitTypes.js create mode 100644 tests/baselines/reference/intersectionOfUnionOfUnitTypes.symbols create mode 100644 tests/baselines/reference/intersectionOfUnionOfUnitTypes.types create mode 100644 tests/cases/conformance/types/intersection/intersectionOfUnionOfUnitTypes.ts diff --git a/tests/baselines/reference/intersectionOfUnionOfUnitTypes.js b/tests/baselines/reference/intersectionOfUnionOfUnitTypes.js new file mode 100644 index 00000000000..09a2ab974f4 --- /dev/null +++ b/tests/baselines/reference/intersectionOfUnionOfUnitTypes.js @@ -0,0 +1,47 @@ +//// [intersectionOfUnionOfUnitTypes.ts] +// @strict + +const enum E { A, B, C, D, E, F } + +let x0: ('a' | 'b' | 'c') & ('a' | 'b' | 'c'); // 'a' | 'b' | 'c' +let x1: ('a' | 'b' | 'c') & ('b' | 'c' | 'd'); // 'b' | 'c' +let x2: ('a' | 'b' | 'c') & ('c' | 'd' | 'e'); // 'c' +let x3: ('a' | 'b' | 'c') & ('d' | 'e' | 'f'); // never +let x4: ('a' | 'b' | 'c') & ('b' | 'c' | 'd') & ('c' | 'd' | 'e'); // 'c' +let x5: ('a' | 'b' | 'c') & ('b' | 'c' | 'd') & ('c' | 'd' | 'e') & ('d' | 'e' | 'f'); // never + +let y0: (0 | 1 | 2) & (0 | 1 | 2); // 0 | 1 | 2 +let y1: (0 | 1 | 2) & (1 | 2 | 3); // 1 | 2 +let y2: (0 | 1 | 2) & (2 | 3 | 4); // 2 +let y3: (0 | 1 | 2) & (3 | 4 | 5); // never +let y4: (0 | 1 | 2) & (1 | 2 | 3) & (2 | 3 | 4); // 2 +let y5: (0 | 1 | 2) & (1 | 2 | 3) & (2 | 3 | 4) & (3 | 4 | 5); // never + +let z0: (E.A | E.B | E.C) & (E.A | E.B | E.C); // E.A | E.B | E.C +let z1: (E.A | E.B | E.C) & (E.B | E.C | E.D); // E.B | E.C +let z2: (E.A | E.B | E.C) & (E.C | E.D | E.E); // E.C +let z3: (E.A | E.B | E.C) & (E.D | E.E | E.F); // never +let z4: (E.A | E.B | E.C) & (E.B | E.C | E.D) & (E.C | E.D | E.E); // E.C +let z5: (E.A | E.B | E.C) & (E.B | E.C | E.D) & (E.C | E.D | E.E) & (E.D | E.E | E.F); // never + + +//// [intersectionOfUnionOfUnitTypes.js] +// @strict +var x0; // 'a' | 'b' | 'c' +var x1; // 'b' | 'c' +var x2; // 'c' +var x3; // never +var x4; // 'c' +var x5; // never +var y0; // 0 | 1 | 2 +var y1; // 1 | 2 +var y2; // 2 +var y3; // never +var y4; // 2 +var y5; // never +var z0; // E.A | E.B | E.C +var z1; // E.B | E.C +var z2; // E.C +var z3; // never +var z4; // E.C +var z5; // never diff --git a/tests/baselines/reference/intersectionOfUnionOfUnitTypes.symbols b/tests/baselines/reference/intersectionOfUnionOfUnitTypes.symbols new file mode 100644 index 00000000000..6f5f70bd290 --- /dev/null +++ b/tests/baselines/reference/intersectionOfUnionOfUnitTypes.symbols @@ -0,0 +1,156 @@ +=== tests/cases/conformance/types/intersection/intersectionOfUnionOfUnitTypes.ts === +// @strict + +const enum E { A, B, C, D, E, F } +>E : Symbol(E, Decl(intersectionOfUnionOfUnitTypes.ts, 0, 0)) +>A : Symbol(E.A, Decl(intersectionOfUnionOfUnitTypes.ts, 2, 14)) +>B : Symbol(E.B, Decl(intersectionOfUnionOfUnitTypes.ts, 2, 17)) +>C : Symbol(E.C, Decl(intersectionOfUnionOfUnitTypes.ts, 2, 20)) +>D : Symbol(E.D, Decl(intersectionOfUnionOfUnitTypes.ts, 2, 23)) +>E : Symbol(E.E, Decl(intersectionOfUnionOfUnitTypes.ts, 2, 26)) +>F : Symbol(E.F, Decl(intersectionOfUnionOfUnitTypes.ts, 2, 29)) + +let x0: ('a' | 'b' | 'c') & ('a' | 'b' | 'c'); // 'a' | 'b' | 'c' +>x0 : Symbol(x0, Decl(intersectionOfUnionOfUnitTypes.ts, 4, 3)) + +let x1: ('a' | 'b' | 'c') & ('b' | 'c' | 'd'); // 'b' | 'c' +>x1 : Symbol(x1, Decl(intersectionOfUnionOfUnitTypes.ts, 5, 3)) + +let x2: ('a' | 'b' | 'c') & ('c' | 'd' | 'e'); // 'c' +>x2 : Symbol(x2, Decl(intersectionOfUnionOfUnitTypes.ts, 6, 3)) + +let x3: ('a' | 'b' | 'c') & ('d' | 'e' | 'f'); // never +>x3 : Symbol(x3, Decl(intersectionOfUnionOfUnitTypes.ts, 7, 3)) + +let x4: ('a' | 'b' | 'c') & ('b' | 'c' | 'd') & ('c' | 'd' | 'e'); // 'c' +>x4 : Symbol(x4, Decl(intersectionOfUnionOfUnitTypes.ts, 8, 3)) + +let x5: ('a' | 'b' | 'c') & ('b' | 'c' | 'd') & ('c' | 'd' | 'e') & ('d' | 'e' | 'f'); // never +>x5 : Symbol(x5, Decl(intersectionOfUnionOfUnitTypes.ts, 9, 3)) + +let y0: (0 | 1 | 2) & (0 | 1 | 2); // 0 | 1 | 2 +>y0 : Symbol(y0, Decl(intersectionOfUnionOfUnitTypes.ts, 11, 3)) + +let y1: (0 | 1 | 2) & (1 | 2 | 3); // 1 | 2 +>y1 : Symbol(y1, Decl(intersectionOfUnionOfUnitTypes.ts, 12, 3)) + +let y2: (0 | 1 | 2) & (2 | 3 | 4); // 2 +>y2 : Symbol(y2, Decl(intersectionOfUnionOfUnitTypes.ts, 13, 3)) + +let y3: (0 | 1 | 2) & (3 | 4 | 5); // never +>y3 : Symbol(y3, Decl(intersectionOfUnionOfUnitTypes.ts, 14, 3)) + +let y4: (0 | 1 | 2) & (1 | 2 | 3) & (2 | 3 | 4); // 2 +>y4 : Symbol(y4, Decl(intersectionOfUnionOfUnitTypes.ts, 15, 3)) + +let y5: (0 | 1 | 2) & (1 | 2 | 3) & (2 | 3 | 4) & (3 | 4 | 5); // never +>y5 : Symbol(y5, Decl(intersectionOfUnionOfUnitTypes.ts, 16, 3)) + +let z0: (E.A | E.B | E.C) & (E.A | E.B | E.C); // E.A | E.B | E.C +>z0 : Symbol(z0, Decl(intersectionOfUnionOfUnitTypes.ts, 18, 3)) +>E : Symbol(E, Decl(intersectionOfUnionOfUnitTypes.ts, 0, 0)) +>A : Symbol(E.A, Decl(intersectionOfUnionOfUnitTypes.ts, 2, 14)) +>E : Symbol(E, Decl(intersectionOfUnionOfUnitTypes.ts, 0, 0)) +>B : Symbol(E.B, Decl(intersectionOfUnionOfUnitTypes.ts, 2, 17)) +>E : Symbol(E, Decl(intersectionOfUnionOfUnitTypes.ts, 0, 0)) +>C : Symbol(E.C, Decl(intersectionOfUnionOfUnitTypes.ts, 2, 20)) +>E : Symbol(E, Decl(intersectionOfUnionOfUnitTypes.ts, 0, 0)) +>A : Symbol(E.A, Decl(intersectionOfUnionOfUnitTypes.ts, 2, 14)) +>E : Symbol(E, Decl(intersectionOfUnionOfUnitTypes.ts, 0, 0)) +>B : Symbol(E.B, Decl(intersectionOfUnionOfUnitTypes.ts, 2, 17)) +>E : Symbol(E, Decl(intersectionOfUnionOfUnitTypes.ts, 0, 0)) +>C : Symbol(E.C, Decl(intersectionOfUnionOfUnitTypes.ts, 2, 20)) + +let z1: (E.A | E.B | E.C) & (E.B | E.C | E.D); // E.B | E.C +>z1 : Symbol(z1, Decl(intersectionOfUnionOfUnitTypes.ts, 19, 3)) +>E : Symbol(E, Decl(intersectionOfUnionOfUnitTypes.ts, 0, 0)) +>A : Symbol(E.A, Decl(intersectionOfUnionOfUnitTypes.ts, 2, 14)) +>E : Symbol(E, Decl(intersectionOfUnionOfUnitTypes.ts, 0, 0)) +>B : Symbol(E.B, Decl(intersectionOfUnionOfUnitTypes.ts, 2, 17)) +>E : Symbol(E, Decl(intersectionOfUnionOfUnitTypes.ts, 0, 0)) +>C : Symbol(E.C, Decl(intersectionOfUnionOfUnitTypes.ts, 2, 20)) +>E : Symbol(E, Decl(intersectionOfUnionOfUnitTypes.ts, 0, 0)) +>B : Symbol(E.B, Decl(intersectionOfUnionOfUnitTypes.ts, 2, 17)) +>E : Symbol(E, Decl(intersectionOfUnionOfUnitTypes.ts, 0, 0)) +>C : Symbol(E.C, Decl(intersectionOfUnionOfUnitTypes.ts, 2, 20)) +>E : Symbol(E, Decl(intersectionOfUnionOfUnitTypes.ts, 0, 0)) +>D : Symbol(E.D, Decl(intersectionOfUnionOfUnitTypes.ts, 2, 23)) + +let z2: (E.A | E.B | E.C) & (E.C | E.D | E.E); // E.C +>z2 : Symbol(z2, Decl(intersectionOfUnionOfUnitTypes.ts, 20, 3)) +>E : Symbol(E, Decl(intersectionOfUnionOfUnitTypes.ts, 0, 0)) +>A : Symbol(E.A, Decl(intersectionOfUnionOfUnitTypes.ts, 2, 14)) +>E : Symbol(E, Decl(intersectionOfUnionOfUnitTypes.ts, 0, 0)) +>B : Symbol(E.B, Decl(intersectionOfUnionOfUnitTypes.ts, 2, 17)) +>E : Symbol(E, Decl(intersectionOfUnionOfUnitTypes.ts, 0, 0)) +>C : Symbol(E.C, Decl(intersectionOfUnionOfUnitTypes.ts, 2, 20)) +>E : Symbol(E, Decl(intersectionOfUnionOfUnitTypes.ts, 0, 0)) +>C : Symbol(E.C, Decl(intersectionOfUnionOfUnitTypes.ts, 2, 20)) +>E : Symbol(E, Decl(intersectionOfUnionOfUnitTypes.ts, 0, 0)) +>D : Symbol(E.D, Decl(intersectionOfUnionOfUnitTypes.ts, 2, 23)) +>E : Symbol(E, Decl(intersectionOfUnionOfUnitTypes.ts, 0, 0)) +>E : Symbol(E.E, Decl(intersectionOfUnionOfUnitTypes.ts, 2, 26)) + +let z3: (E.A | E.B | E.C) & (E.D | E.E | E.F); // never +>z3 : Symbol(z3, Decl(intersectionOfUnionOfUnitTypes.ts, 21, 3)) +>E : Symbol(E, Decl(intersectionOfUnionOfUnitTypes.ts, 0, 0)) +>A : Symbol(E.A, Decl(intersectionOfUnionOfUnitTypes.ts, 2, 14)) +>E : Symbol(E, Decl(intersectionOfUnionOfUnitTypes.ts, 0, 0)) +>B : Symbol(E.B, Decl(intersectionOfUnionOfUnitTypes.ts, 2, 17)) +>E : Symbol(E, Decl(intersectionOfUnionOfUnitTypes.ts, 0, 0)) +>C : Symbol(E.C, Decl(intersectionOfUnionOfUnitTypes.ts, 2, 20)) +>E : Symbol(E, Decl(intersectionOfUnionOfUnitTypes.ts, 0, 0)) +>D : Symbol(E.D, Decl(intersectionOfUnionOfUnitTypes.ts, 2, 23)) +>E : Symbol(E, Decl(intersectionOfUnionOfUnitTypes.ts, 0, 0)) +>E : Symbol(E.E, Decl(intersectionOfUnionOfUnitTypes.ts, 2, 26)) +>E : Symbol(E, Decl(intersectionOfUnionOfUnitTypes.ts, 0, 0)) +>F : Symbol(E.F, Decl(intersectionOfUnionOfUnitTypes.ts, 2, 29)) + +let z4: (E.A | E.B | E.C) & (E.B | E.C | E.D) & (E.C | E.D | E.E); // E.C +>z4 : Symbol(z4, Decl(intersectionOfUnionOfUnitTypes.ts, 22, 3)) +>E : Symbol(E, Decl(intersectionOfUnionOfUnitTypes.ts, 0, 0)) +>A : Symbol(E.A, Decl(intersectionOfUnionOfUnitTypes.ts, 2, 14)) +>E : Symbol(E, Decl(intersectionOfUnionOfUnitTypes.ts, 0, 0)) +>B : Symbol(E.B, Decl(intersectionOfUnionOfUnitTypes.ts, 2, 17)) +>E : Symbol(E, Decl(intersectionOfUnionOfUnitTypes.ts, 0, 0)) +>C : Symbol(E.C, Decl(intersectionOfUnionOfUnitTypes.ts, 2, 20)) +>E : Symbol(E, Decl(intersectionOfUnionOfUnitTypes.ts, 0, 0)) +>B : Symbol(E.B, Decl(intersectionOfUnionOfUnitTypes.ts, 2, 17)) +>E : Symbol(E, Decl(intersectionOfUnionOfUnitTypes.ts, 0, 0)) +>C : Symbol(E.C, Decl(intersectionOfUnionOfUnitTypes.ts, 2, 20)) +>E : Symbol(E, Decl(intersectionOfUnionOfUnitTypes.ts, 0, 0)) +>D : Symbol(E.D, Decl(intersectionOfUnionOfUnitTypes.ts, 2, 23)) +>E : Symbol(E, Decl(intersectionOfUnionOfUnitTypes.ts, 0, 0)) +>C : Symbol(E.C, Decl(intersectionOfUnionOfUnitTypes.ts, 2, 20)) +>E : Symbol(E, Decl(intersectionOfUnionOfUnitTypes.ts, 0, 0)) +>D : Symbol(E.D, Decl(intersectionOfUnionOfUnitTypes.ts, 2, 23)) +>E : Symbol(E, Decl(intersectionOfUnionOfUnitTypes.ts, 0, 0)) +>E : Symbol(E.E, Decl(intersectionOfUnionOfUnitTypes.ts, 2, 26)) + +let z5: (E.A | E.B | E.C) & (E.B | E.C | E.D) & (E.C | E.D | E.E) & (E.D | E.E | E.F); // never +>z5 : Symbol(z5, Decl(intersectionOfUnionOfUnitTypes.ts, 23, 3)) +>E : Symbol(E, Decl(intersectionOfUnionOfUnitTypes.ts, 0, 0)) +>A : Symbol(E.A, Decl(intersectionOfUnionOfUnitTypes.ts, 2, 14)) +>E : Symbol(E, Decl(intersectionOfUnionOfUnitTypes.ts, 0, 0)) +>B : Symbol(E.B, Decl(intersectionOfUnionOfUnitTypes.ts, 2, 17)) +>E : Symbol(E, Decl(intersectionOfUnionOfUnitTypes.ts, 0, 0)) +>C : Symbol(E.C, Decl(intersectionOfUnionOfUnitTypes.ts, 2, 20)) +>E : Symbol(E, Decl(intersectionOfUnionOfUnitTypes.ts, 0, 0)) +>B : Symbol(E.B, Decl(intersectionOfUnionOfUnitTypes.ts, 2, 17)) +>E : Symbol(E, Decl(intersectionOfUnionOfUnitTypes.ts, 0, 0)) +>C : Symbol(E.C, Decl(intersectionOfUnionOfUnitTypes.ts, 2, 20)) +>E : Symbol(E, Decl(intersectionOfUnionOfUnitTypes.ts, 0, 0)) +>D : Symbol(E.D, Decl(intersectionOfUnionOfUnitTypes.ts, 2, 23)) +>E : Symbol(E, Decl(intersectionOfUnionOfUnitTypes.ts, 0, 0)) +>C : Symbol(E.C, Decl(intersectionOfUnionOfUnitTypes.ts, 2, 20)) +>E : Symbol(E, Decl(intersectionOfUnionOfUnitTypes.ts, 0, 0)) +>D : Symbol(E.D, Decl(intersectionOfUnionOfUnitTypes.ts, 2, 23)) +>E : Symbol(E, Decl(intersectionOfUnionOfUnitTypes.ts, 0, 0)) +>E : Symbol(E.E, Decl(intersectionOfUnionOfUnitTypes.ts, 2, 26)) +>E : Symbol(E, Decl(intersectionOfUnionOfUnitTypes.ts, 0, 0)) +>D : Symbol(E.D, Decl(intersectionOfUnionOfUnitTypes.ts, 2, 23)) +>E : Symbol(E, Decl(intersectionOfUnionOfUnitTypes.ts, 0, 0)) +>E : Symbol(E.E, Decl(intersectionOfUnionOfUnitTypes.ts, 2, 26)) +>E : Symbol(E, Decl(intersectionOfUnionOfUnitTypes.ts, 0, 0)) +>F : Symbol(E.F, Decl(intersectionOfUnionOfUnitTypes.ts, 2, 29)) + diff --git a/tests/baselines/reference/intersectionOfUnionOfUnitTypes.types b/tests/baselines/reference/intersectionOfUnionOfUnitTypes.types new file mode 100644 index 00000000000..aa7fa0074ed --- /dev/null +++ b/tests/baselines/reference/intersectionOfUnionOfUnitTypes.types @@ -0,0 +1,156 @@ +=== tests/cases/conformance/types/intersection/intersectionOfUnionOfUnitTypes.ts === +// @strict + +const enum E { A, B, C, D, E, F } +>E : E +>A : E.A +>B : E.B +>C : E.C +>D : E.D +>E : E.E +>F : E.F + +let x0: ('a' | 'b' | 'c') & ('a' | 'b' | 'c'); // 'a' | 'b' | 'c' +>x0 : "a" | "b" | "c" + +let x1: ('a' | 'b' | 'c') & ('b' | 'c' | 'd'); // 'b' | 'c' +>x1 : "b" | "c" + +let x2: ('a' | 'b' | 'c') & ('c' | 'd' | 'e'); // 'c' +>x2 : "c" + +let x3: ('a' | 'b' | 'c') & ('d' | 'e' | 'f'); // never +>x3 : never + +let x4: ('a' | 'b' | 'c') & ('b' | 'c' | 'd') & ('c' | 'd' | 'e'); // 'c' +>x4 : "c" + +let x5: ('a' | 'b' | 'c') & ('b' | 'c' | 'd') & ('c' | 'd' | 'e') & ('d' | 'e' | 'f'); // never +>x5 : never + +let y0: (0 | 1 | 2) & (0 | 1 | 2); // 0 | 1 | 2 +>y0 : 0 | 1 | 2 + +let y1: (0 | 1 | 2) & (1 | 2 | 3); // 1 | 2 +>y1 : 1 | 2 + +let y2: (0 | 1 | 2) & (2 | 3 | 4); // 2 +>y2 : 2 + +let y3: (0 | 1 | 2) & (3 | 4 | 5); // never +>y3 : never + +let y4: (0 | 1 | 2) & (1 | 2 | 3) & (2 | 3 | 4); // 2 +>y4 : 2 + +let y5: (0 | 1 | 2) & (1 | 2 | 3) & (2 | 3 | 4) & (3 | 4 | 5); // never +>y5 : never + +let z0: (E.A | E.B | E.C) & (E.A | E.B | E.C); // E.A | E.B | E.C +>z0 : E.A | E.B | E.C +>E : any +>A : E.A +>E : any +>B : E.B +>E : any +>C : E.C +>E : any +>A : E.A +>E : any +>B : E.B +>E : any +>C : E.C + +let z1: (E.A | E.B | E.C) & (E.B | E.C | E.D); // E.B | E.C +>z1 : E.B | E.C +>E : any +>A : E.A +>E : any +>B : E.B +>E : any +>C : E.C +>E : any +>B : E.B +>E : any +>C : E.C +>E : any +>D : E.D + +let z2: (E.A | E.B | E.C) & (E.C | E.D | E.E); // E.C +>z2 : E.C +>E : any +>A : E.A +>E : any +>B : E.B +>E : any +>C : E.C +>E : any +>C : E.C +>E : any +>D : E.D +>E : any +>E : E.E + +let z3: (E.A | E.B | E.C) & (E.D | E.E | E.F); // never +>z3 : never +>E : any +>A : E.A +>E : any +>B : E.B +>E : any +>C : E.C +>E : any +>D : E.D +>E : any +>E : E.E +>E : any +>F : E.F + +let z4: (E.A | E.B | E.C) & (E.B | E.C | E.D) & (E.C | E.D | E.E); // E.C +>z4 : E.C +>E : any +>A : E.A +>E : any +>B : E.B +>E : any +>C : E.C +>E : any +>B : E.B +>E : any +>C : E.C +>E : any +>D : E.D +>E : any +>C : E.C +>E : any +>D : E.D +>E : any +>E : E.E + +let z5: (E.A | E.B | E.C) & (E.B | E.C | E.D) & (E.C | E.D | E.E) & (E.D | E.E | E.F); // never +>z5 : never +>E : any +>A : E.A +>E : any +>B : E.B +>E : any +>C : E.C +>E : any +>B : E.B +>E : any +>C : E.C +>E : any +>D : E.D +>E : any +>C : E.C +>E : any +>D : E.D +>E : any +>E : E.E +>E : any +>D : E.D +>E : any +>E : E.E +>E : any +>F : E.F + diff --git a/tests/cases/conformance/types/intersection/intersectionOfUnionOfUnitTypes.ts b/tests/cases/conformance/types/intersection/intersectionOfUnionOfUnitTypes.ts new file mode 100644 index 00000000000..28492b1d94b --- /dev/null +++ b/tests/cases/conformance/types/intersection/intersectionOfUnionOfUnitTypes.ts @@ -0,0 +1,24 @@ +// @strict + +const enum E { A, B, C, D, E, F } + +let x0: ('a' | 'b' | 'c') & ('a' | 'b' | 'c'); // 'a' | 'b' | 'c' +let x1: ('a' | 'b' | 'c') & ('b' | 'c' | 'd'); // 'b' | 'c' +let x2: ('a' | 'b' | 'c') & ('c' | 'd' | 'e'); // 'c' +let x3: ('a' | 'b' | 'c') & ('d' | 'e' | 'f'); // never +let x4: ('a' | 'b' | 'c') & ('b' | 'c' | 'd') & ('c' | 'd' | 'e'); // 'c' +let x5: ('a' | 'b' | 'c') & ('b' | 'c' | 'd') & ('c' | 'd' | 'e') & ('d' | 'e' | 'f'); // never + +let y0: (0 | 1 | 2) & (0 | 1 | 2); // 0 | 1 | 2 +let y1: (0 | 1 | 2) & (1 | 2 | 3); // 1 | 2 +let y2: (0 | 1 | 2) & (2 | 3 | 4); // 2 +let y3: (0 | 1 | 2) & (3 | 4 | 5); // never +let y4: (0 | 1 | 2) & (1 | 2 | 3) & (2 | 3 | 4); // 2 +let y5: (0 | 1 | 2) & (1 | 2 | 3) & (2 | 3 | 4) & (3 | 4 | 5); // never + +let z0: (E.A | E.B | E.C) & (E.A | E.B | E.C); // E.A | E.B | E.C +let z1: (E.A | E.B | E.C) & (E.B | E.C | E.D); // E.B | E.C +let z2: (E.A | E.B | E.C) & (E.C | E.D | E.E); // E.C +let z3: (E.A | E.B | E.C) & (E.D | E.E | E.F); // never +let z4: (E.A | E.B | E.C) & (E.B | E.C | E.D) & (E.C | E.D | E.E); // E.C +let z5: (E.A | E.B | E.C) & (E.B | E.C | E.D) & (E.C | E.D | E.E) & (E.D | E.E | E.F); // never From c3199c7772010bfab3c5b7da2d0d2a2cc4010871 Mon Sep 17 00:00:00 2001 From: Andy Date: Wed, 13 Sep 2017 09:02:10 -0700 Subject: [PATCH 311/370] extractMethod: Support renameLocation (#18050) * extractMethod: Support renameLocation * Add tslint disable * Properly analyze list of changes to always get a correct rename location * Update test * Ensure name is really unique * Improvements to test code * Respond to PR comments --- src/harness/fourslash.ts | 38 +- src/harness/unittests/extractMethods.ts | 7 +- src/server/client.ts | 4 +- .../refactors/convertFunctionToEs6Class.ts | 4 +- src/services/refactors/extractMethod.ts | 397 +++++++++--------- src/services/types.ts | 4 +- .../reference/extractMethod/extractMethod1.ts | 8 +- .../extractMethod/extractMethod10.ts | 6 +- .../extractMethod/extractMethod11.ts | 6 +- .../extractMethod/extractMethod12.ts | 2 +- .../extractMethod/extractMethod13.ts | 6 +- .../extractMethod/extractMethod14.ts | 6 +- .../extractMethod/extractMethod15.ts | 6 +- .../extractMethod/extractMethod16.ts | 4 +- .../extractMethod/extractMethod17.ts | 4 +- .../extractMethod/extractMethod18.ts | 4 +- .../extractMethod/extractMethod19.ts | 4 +- .../reference/extractMethod/extractMethod2.ts | 8 +- .../extractMethod/extractMethod20.ts | 4 +- .../extractMethod/extractMethod21.ts | 4 +- .../extractMethod/extractMethod22.ts | 4 +- .../extractMethod/extractMethod23.ts | 6 +- .../extractMethod/extractMethod24.ts | 6 +- .../extractMethod/extractMethod25.ts | 4 +- .../extractMethod/extractMethod26.ts | 4 +- .../extractMethod/extractMethod27.ts | 4 +- .../extractMethod/extractMethod28.ts | 4 +- .../reference/extractMethod/extractMethod3.ts | 8 +- .../reference/extractMethod/extractMethod4.ts | 8 +- .../reference/extractMethod/extractMethod5.ts | 8 +- .../reference/extractMethod/extractMethod6.ts | 8 +- .../reference/extractMethod/extractMethod7.ts | 8 +- .../reference/extractMethod/extractMethod8.ts | 8 +- .../reference/extractMethod/extractMethod9.ts | 8 +- .../fourslash/extract-method-formatting.ts | 9 +- .../fourslash/extract-method-uniqueName.ts | 20 + tests/cases/fourslash/extract-method1.ts | 8 +- tests/cases/fourslash/extract-method10.ts | 7 + tests/cases/fourslash/extract-method13.ts | 20 +- tests/cases/fourslash/extract-method14.ts | 9 +- tests/cases/fourslash/extract-method15.ts | 10 +- tests/cases/fourslash/extract-method18.ts | 9 +- tests/cases/fourslash/extract-method19.ts | 9 +- tests/cases/fourslash/extract-method2.ts | 8 +- tests/cases/fourslash/extract-method21.ts | 10 +- tests/cases/fourslash/extract-method24.ts | 9 +- tests/cases/fourslash/extract-method25.ts | 9 +- tests/cases/fourslash/extract-method5.ts | 9 +- tests/cases/fourslash/extract-method7.ts | 7 +- tests/cases/fourslash/fourslash.ts | 2 +- 50 files changed, 431 insertions(+), 338 deletions(-) create mode 100644 tests/cases/fourslash/extract-method-uniqueName.ts diff --git a/src/harness/fourslash.ts b/src/harness/fourslash.ts index 598cfc2fd7e..d89a4677ef9 100644 --- a/src/harness/fourslash.ts +++ b/src/harness/fourslash.ts @@ -2758,11 +2758,11 @@ namespace FourSlash { } } - private getSelection() { - return ({ + private getSelection(): ts.TextRange { + return { pos: this.currentCaretPosition, end: this.selectionEnd === -1 ? this.currentCaretPosition : this.selectionEnd - }); + }; } public verifyRefactorAvailable(negative: boolean, name: string, actionName?: string) { @@ -2803,7 +2803,7 @@ namespace FourSlash { } } - public applyRefactor({ refactorName, actionName, actionDescription }: FourSlashInterface.ApplyRefactorOptions) { + public applyRefactor({ refactorName, actionName, actionDescription, newContent: newContentWithRenameMarker }: FourSlashInterface.ApplyRefactorOptions) { const range = this.getSelection(); const refactors = this.languageService.getApplicableRefactors(this.activeFile.fileName, range); const refactor = refactors.find(r => r.name === refactorName); @@ -2823,6 +2823,35 @@ namespace FourSlash { for (const edit of editInfo.edits) { this.applyEdits(edit.fileName, edit.textChanges, /*isFormattingEdit*/ false); } + + const { renamePosition, newContent } = parseNewContent(); + + this.verifyCurrentFileContent(newContent); + + if (renamePosition === undefined) { + if (editInfo.renameLocation !== undefined) { + this.raiseError(`Did not expect a rename location, got ${editInfo.renameLocation}`); + } + } + else { + // TODO: test editInfo.renameFilename value + assert.isDefined(editInfo.renameFilename); + if (renamePosition !== editInfo.renameLocation) { + this.raiseError(`Expected rename position of ${renamePosition}, but got ${editInfo.renameLocation}`); + } + } + + function parseNewContent(): { renamePosition: number | undefined, newContent: string } { + const renamePosition = newContentWithRenameMarker.indexOf("/*RENAME*/"); + if (renamePosition === -1) { + return { renamePosition: undefined, newContent: newContentWithRenameMarker }; + } + else { + const newContent = newContentWithRenameMarker.slice(0, renamePosition) + newContentWithRenameMarker.slice(renamePosition + "/*RENAME*/".length); + return { renamePosition, newContent }; + } + } + } public verifyFileAfterApplyingRefactorAtMarker( @@ -4319,6 +4348,7 @@ namespace FourSlashInterface { refactorName: string; actionName: string; actionDescription: string; + newContent: string; } export interface CompletionsAtOptions { diff --git a/src/harness/unittests/extractMethods.ts b/src/harness/unittests/extractMethods.ts index edcc80cd57c..c836698aeb4 100644 --- a/src/harness/unittests/extractMethods.ts +++ b/src/harness/unittests/extractMethods.ts @@ -745,9 +745,12 @@ function M3() { }`); data.push(`// ==ORIGINAL==`); data.push(sourceFile.text); for (const r of results) { - const changes = refactor.extractMethod.getPossibleExtractions(result.targetRange, context, results.indexOf(r))[0].changes; + const { renameLocation, edits } = refactor.extractMethod.getExtractionAtIndex(result.targetRange, context, results.indexOf(r)); + assert.lengthOf(edits, 1); data.push(`// ==SCOPE::${r.scopeDescription}==`); - data.push(textChanges.applyChanges(sourceFile.text, changes[0].textChanges)); + const newText = textChanges.applyChanges(sourceFile.text, edits[0].textChanges); + const newTextWithRename = newText.slice(0, renameLocation) + "/*RENAME*/" + newText.slice(renameLocation); + data.push(newTextWithRename); } return data.join(newLineCharacter); }); diff --git a/src/server/client.ts b/src/server/client.ts index 4acd862a89a..0ffac42dae4 100644 --- a/src/server/client.ts +++ b/src/server/client.ts @@ -586,9 +586,7 @@ namespace ts.server { const response = this.processResponse(request); if (!response.body) { - return { - edits: [] - }; + return { edits: [], renameFilename: undefined, renameLocation: undefined }; } const edits: FileTextChanges[] = this.convertCodeEditsToTextChanges(response.body.edits); diff --git a/src/services/refactors/convertFunctionToEs6Class.ts b/src/services/refactors/convertFunctionToEs6Class.ts index 40ef4ed2a2e..e4cd1a42083 100644 --- a/src/services/refactors/convertFunctionToEs6Class.ts +++ b/src/services/refactors/convertFunctionToEs6Class.ts @@ -97,7 +97,9 @@ namespace ts.refactor.convertFunctionToES6Class { } return { - edits: changeTracker.getChanges() + edits: changeTracker.getChanges(), + renameFilename: undefined, + renameLocation: undefined, }; function deleteNode(node: Node, inList = false) { diff --git a/src/services/refactors/extractMethod.ts b/src/services/refactors/extractMethod.ts index b0554138134..7b5e1e40c7e 100644 --- a/src/services/refactors/extractMethod.ts +++ b/src/services/refactors/extractMethod.ts @@ -31,16 +31,16 @@ namespace ts.refactor.extractMethod { const usedNames: Map = createMap(); let i = 0; - for (const extr of extractions) { + for (const { scopeDescription, errors } of extractions) { // Skip these since we don't have a way to report errors yet - if (extr.errors && extr.errors.length) { + if (errors.length) { continue; } // Don't issue refactorings with duplicated names. // Scopes come back in "innermost first" order, so extractions will // preferentially go into nearer scopes - const description = formatStringFromArgs(Diagnostics.Extract_to_0.message, [extr.scopeDescription]); + const description = formatStringFromArgs(Diagnostics.Extract_to_0.message, [scopeDescription]); if (!usedNames.has(description)) { usedNames.set(description, true); actions.push({ @@ -75,10 +75,7 @@ namespace ts.refactor.extractMethod { const index = +parsedIndexMatch[1]; Debug.assert(isFinite(index), "Expected to parse a finite number from the scope index"); - const extractions = getPossibleExtractions(targetRange, context, index); - // Scope is no longer valid from when the user issued the refactor (??) - Debug.assert(extractions !== undefined, "The extraction went missing? How?"); - return ({ edits: extractions[0].changes }); + return getExtractionAtIndex(targetRange, context, index); } // Move these into diagnostic messages if they become user-facing @@ -102,7 +99,7 @@ namespace ts.refactor.extractMethod { export const CannotExtractAmbientBlock = createMessage("Cannot extract code from ambient contexts"); } - export enum RangeFacts { + enum RangeFacts { None = 0, HasReturn = 1 << 0, IsGenerator = 1 << 1, @@ -117,7 +114,7 @@ namespace ts.refactor.extractMethod { /** * Represents an expression or a list of statements that should be extracted with some extra information */ - export interface TargetRange { + interface TargetRange { readonly range: Expression | Statement[]; readonly facts: RangeFacts; /** @@ -130,7 +127,7 @@ namespace ts.refactor.extractMethod { /** * Result of 'getRangeToExtract' operation: contains either a range or a list of errors */ - export type RangeToExtract = { + type RangeToExtract = { readonly targetRange?: never; readonly errors: ReadonlyArray; } | { @@ -141,18 +138,7 @@ namespace ts.refactor.extractMethod { /* * Scopes that can store newly extracted method */ - export type Scope = FunctionLikeDeclaration | SourceFile | ModuleBlock | ClassLikeDeclaration; - - /** - * Result of 'extractRange' operation for a specific scope. - * Stores either a list of changes that should be applied to extract a range or a list of errors - */ - export interface ExtractResultForScope { - readonly scope: Scope; - readonly scopeDescription: string; - readonly changes?: FileTextChanges[]; - readonly errors?: Diagnostic[]; - } + type Scope = FunctionLikeDeclaration | SourceFile | ModuleBlock | ClassLikeDeclaration; /** * getRangeToExtract takes a span inside a text file and returns either an expression or an array @@ -160,6 +146,7 @@ namespace ts.refactor.extractMethod { * process may fail, in which case a set of errors is returned instead (these are currently * not shown to the user, but can be used by us diagnostically) */ + // exported only for tests export function getRangeToExtract(sourceFile: SourceFile, span: TextSpan): RangeToExtract { const length = span.length || 0; // Walk up starting from the the start position until we find a non-SourceFile node that subsumes the selected span. @@ -458,7 +445,7 @@ namespace ts.refactor.extractMethod { * you may be able to extract into a class method *or* local closure *or* namespace function, * depending on what's in the extracted body. */ - export function collectEnclosingScopes(range: TargetRange): Scope[] | undefined { + function collectEnclosingScopes(range: TargetRange): Scope[] | undefined { let current: Node = isReadonlyArray(range.range) ? firstOrUndefined(range.range) : range.range; if (range.facts & RangeFacts.UsesThis) { // if range uses this as keyword or as type inside the class then it can only be extracted to a method of the containing class @@ -494,12 +481,32 @@ namespace ts.refactor.extractMethod { return scopes; } + // exported only for tests + export function getExtractionAtIndex(targetRange: TargetRange, context: RefactorContext, requestedChangesIndex: number): RefactorEditInfo { + const { scopes, readsAndWrites: { target, usagesPerScope, errorsPerScope } } = getPossibleExtractionsWorker(targetRange, context); + Debug.assert(!errorsPerScope[requestedChangesIndex].length, "The extraction went missing? How?"); + context.cancellationToken.throwIfCancellationRequested(); + return extractFunctionInScope(target, scopes[requestedChangesIndex], usagesPerScope[requestedChangesIndex], targetRange, context); + } + + interface PossibleExtraction { + readonly scopeDescription: string; + readonly errors: ReadonlyArray; + } /** * Given a piece of text to extract ('targetRange'), computes a list of possible extractions. * Each returned ExtractResultForScope corresponds to a possible target scope and is either a set of changes * or an error explaining why we can't extract into that scope. */ - export function getPossibleExtractions(targetRange: TargetRange, context: RefactorContext, requestedChangesIndex: number = undefined): ReadonlyArray | undefined { + // exported only for tests + export function getPossibleExtractions(targetRange: TargetRange, context: RefactorContext): ReadonlyArray | undefined { + const { scopes, readsAndWrites: { errorsPerScope } } = getPossibleExtractionsWorker(targetRange, context); + // Need the inner type annotation to avoid https://github.com/Microsoft/TypeScript/issues/7547 + return scopes.map((scope, i): PossibleExtraction => + ({ scopeDescription: getDescriptionForScope(scope), errors: errorsPerScope[i] })); + } + + function getPossibleExtractionsWorker(targetRange: TargetRange, context: RefactorContext): { readonly scopes: Scope[], readonly readsAndWrites: ReadsAndWrites } { const { file: sourceFile } = context; if (targetRange === undefined) { @@ -512,35 +519,14 @@ namespace ts.refactor.extractMethod { } const enclosingTextRange = getEnclosingTextRange(targetRange, sourceFile); - const { target, usagesPerScope, errorsPerScope } = collectReadsAndWrites( + const readsAndWrites = collectReadsAndWrites( targetRange, scopes, enclosingTextRange, sourceFile, context.program.getTypeChecker(), context.cancellationToken); - - context.cancellationToken.throwIfCancellationRequested(); - - if (requestedChangesIndex !== undefined) { - if (errorsPerScope[requestedChangesIndex].length) { - return undefined; - } - return [extractFunctionInScope(target, scopes[requestedChangesIndex], usagesPerScope[requestedChangesIndex], targetRange, context)]; - } - else { - return scopes.map((scope, i) => { - const errors = errorsPerScope[i]; - if (errors.length) { - return { - scope, - scopeDescription: getDescriptionForScope(scope), - errors - }; - } - return { scope, scopeDescription: getDescriptionForScope(scope) }; - }); - } + return { scopes, readsAndWrites }; } function getDescriptionForScope(scope: Scope): string { @@ -583,34 +569,33 @@ namespace ts.refactor.extractMethod { : scope.externalModuleIndicator ? "module scope" : "global scope"; } - function getUniqueName(isNameOkay: (name: string) => boolean) { + function getUniqueName(fileText: string): string { let functionNameText = "newFunction"; - if (isNameOkay(functionNameText)) { - return functionNameText; - } - let i = 1; - while (!isNameOkay(functionNameText = `newFunction_${i}`)) { - i++; + for (let i = 1; fileText.indexOf(functionNameText) !== -1; i++) { + functionNameText = `newFunction_${i}`; } return functionNameText; } - export function extractFunctionInScope( + /** + * Result of 'extractRange' operation for a specific scope. + * Stores either a list of changes that should be applied to extract a range or a list of errors + */ + function extractFunctionInScope( node: Statement | Expression | Block, scope: Scope, { usages: usagesInScope, typeParameterUsages, substitutions }: ScopeUsages, range: TargetRange, - context: RefactorContext): ExtractResultForScope { + context: RefactorContext): RefactorEditInfo { const checker = context.program.getTypeChecker(); // Make a unique name for the extracted function const file = scope.getSourceFile(); - const functionNameText: string = getUniqueName(n => !file.identifiers.has(n)); + const functionNameText = getUniqueName(file.text); const isJS = isInJavaScriptFile(scope); - const functionName = createIdentifier(functionNameText as string); - const functionReference = createIdentifier(functionNameText as string); + const functionName = createIdentifier(functionNameText); let returnType: TypeNode = undefined; const parameters: ParameterDeclaration[] = []; @@ -660,7 +645,7 @@ namespace ts.refactor.extractMethod { returnType = checker.typeToTypeNode(contextualType); } - const { body, returnValueProperty } = transformFunctionBody(node); + const { body, returnValueProperty } = transformFunctionBody(node, writes, substitutions, !!(range.facts & RangeFacts.HasReturn)); let newFunction: MethodDeclaration | FunctionDeclaration; if (isClassLike(scope)) { @@ -709,8 +694,10 @@ namespace ts.refactor.extractMethod { const newNodes: Node[] = []; // replace range with function call + const called = getCalledExpression(scope, range, functionNameText); + let call: Expression = createCall( - isClassLike(scope) ? createPropertyAccess(range.facts & RangeFacts.InStaticRegion ? createIdentifier(scope.name.getText()) : createThis(), functionReference) : functionReference, + called, callTypeArguments, // Note that no attempt is made to take advantage of type argument inference callArguments); if (range.facts & RangeFacts.IsGenerator) { @@ -779,147 +766,174 @@ namespace ts.refactor.extractMethod { changeTracker.replaceNodeWithNodes(context.file, range.range, newNodes, { nodeSeparator: context.newLineCharacter }); } - return { - scope, - scopeDescription: getDescriptionForScope(scope), - changes: changeTracker.getChanges() - }; + const edits = changeTracker.getChanges(); + const renameRange = isReadonlyArray(range.range) ? range.range[0] : range.range; - function getFirstDeclaration(type: Type): Declaration | undefined { - let firstDeclaration = undefined; + const renameFilename = renameRange.getSourceFile().fileName; + const renameLocation = getRenameLocation(edits, renameFilename, functionNameText); + return { renameFilename, renameLocation, edits }; + } - const symbol = type.symbol; - if (symbol && symbol.declarations) { - for (const declaration of symbol.declarations) { - if (firstDeclaration === undefined || declaration.pos < firstDeclaration.pos) { - firstDeclaration = declaration; - } + function getRenameLocation(edits: ReadonlyArray, renameFilename: string, functionNameText: string): number { + let delta = 0; + for (const { fileName, textChanges } of edits) { + Debug.assert(fileName === renameFilename); + for (const change of textChanges) { + const { span, newText } = change; + // TODO(acasey): We are assuming that the call expression comes before the function declaration, + // because we want the new cursor to be on the call expression, + // which is closer to where the user was before extracting the function. + const index = newText.indexOf(functionNameText); + if (index !== -1) { + return span.start + delta + index; + } + delta += newText.length - span.length; + } + } + throw new Error(); // Didn't find the text we inserted? + } + + function getFirstDeclaration(type: Type): Declaration | undefined { + let firstDeclaration = undefined; + + const symbol = type.symbol; + if (symbol && symbol.declarations) { + for (const declaration of symbol.declarations) { + if (firstDeclaration === undefined || declaration.pos < firstDeclaration.pos) { + firstDeclaration = declaration; } } - - return firstDeclaration; } - function compareTypesByDeclarationOrder( - {type: type1, declaration: declaration1}: {type: Type, declaration?: Declaration}, - {type: type2, declaration: declaration2}: {type: Type, declaration?: Declaration}) { + return firstDeclaration; + } - if (declaration1) { - if (declaration2) { - const positionDiff = declaration1.pos - declaration2.pos; - if (positionDiff !== 0) { - return positionDiff; - } + function compareTypesByDeclarationOrder( + {type: type1, declaration: declaration1}: {type: Type, declaration?: Declaration}, + {type: type2, declaration: declaration2}: {type: Type, declaration?: Declaration}) { + + if (declaration1) { + if (declaration2) { + const positionDiff = declaration1.pos - declaration2.pos; + if (positionDiff !== 0) { + return positionDiff; } - else { - return 1; // Sort undeclared type parameters to the front. - } - } - else if (declaration2) { - return -1; // Sort undeclared type parameters to the front. - } - - const name1 = type1.symbol ? type1.symbol.getName() : ""; - const name2 = type2.symbol ? type2.symbol.getName() : ""; - const nameDiff = compareStrings(name1, name2); - if (nameDiff !== 0) { - return nameDiff; - } - - // IDs are guaranteed to be unique, so this ensures a total ordering. - return type1.id - type2.id; - } - - function getPropertyAssignmentsForWrites(writes: UsageEntry[]) { - return writes.map(w => createShorthandPropertyAssignment(w.symbol.name)); - } - - function generateReturnValueProperty() { - return "__return"; - } - - function getStatementsOrClassElements(scope: Scope): ReadonlyArray | ReadonlyArray { - if (isFunctionLike(scope)) { - const body = scope.body; - if (isBlock(body)) { - return body.statements; - } - } - else if (isModuleBlock(scope) || isSourceFile(scope)) { - return scope.statements; - } - else if (isClassLike(scope)) { - return scope.members; } else { - assertTypeIsNever(scope); - } - - return emptyArray; - } - - /** - * If `scope` contains a function after `minPos`, then return the first such function. - * Otherwise, return `undefined`. - */ - function getNodeToInsertBefore(minPos: number, scope: Scope): Node | undefined { - const children = getStatementsOrClassElements(scope); - for (const child of children) { - if (child.pos >= minPos && isFunctionLike(child) && !isConstructorDeclaration(child)) { - return child; - } + return 1; // Sort undeclared type parameters to the front. } } + else if (declaration2) { + return -1; // Sort undeclared type parameters to the front. + } - function transformFunctionBody(body: Node) { - if (isBlock(body) && !writes && substitutions.size === 0) { - // already block, no writes to propagate back, no substitutions - can use node as is - return { body: createBlock(body.statements, /*multLine*/ true), returnValueProperty: undefined }; - } - let returnValueProperty: string; - const statements = createNodeArray(isBlock(body) ? body.statements.slice(0) : [isStatement(body) ? body : createReturn(body)]); - // rewrite body if either there are writes that should be propagated back via return statements or there are substitutions - if (writes || substitutions.size) { - const rewrittenStatements = visitNodes(statements, visitor).slice(); - if (writes && !(range.facts & RangeFacts.HasReturn) && isStatement(body)) { - // add return at the end to propagate writes back in case if control flow falls out of the function body - // it is ok to know that range has at least one return since it we only allow unconditional returns - const assignments = getPropertyAssignmentsForWrites(writes); - if (assignments.length === 1) { - rewrittenStatements.push(createReturn(assignments[0].name)); - } - else { - rewrittenStatements.push(createReturn(createObjectLiteral(assignments))); - } - } - return { body: createBlock(rewrittenStatements, /*multiLine*/ true), returnValueProperty }; - } - else { - return { body: createBlock(statements, /*multiLine*/ true), returnValueProperty: undefined }; - } + const name1 = type1.symbol ? type1.symbol.getName() : ""; + const name2 = type2.symbol ? type2.symbol.getName() : ""; + const nameDiff = compareStrings(name1, name2); + if (nameDiff !== 0) { + return nameDiff; + } - function visitor(node: Node): VisitResult { - if (node.kind === SyntaxKind.ReturnStatement && writes) { - const assignments: ObjectLiteralElementLike[] = getPropertyAssignmentsForWrites(writes); - if ((node).expression) { - if (!returnValueProperty) { - returnValueProperty = generateReturnValueProperty(); - } - assignments.unshift(createPropertyAssignment(returnValueProperty, visitNode((node).expression, visitor))); - } - if (assignments.length === 1) { - return createReturn(assignments[0].name as Expression); - } - else { - return createReturn(createObjectLiteral(assignments)); - } + // IDs are guaranteed to be unique, so this ensures a total ordering. + return type1.id - type2.id; + } + + function getCalledExpression(scope: Node, range: TargetRange, functionNameText: string): Expression { + const functionReference = createIdentifier(functionNameText); + if (isClassLike(scope)) { + const lhs = range.facts & RangeFacts.InStaticRegion ? createIdentifier(scope.name.text) : createThis(); + return createPropertyAccess(lhs, functionReference); + } + else { + return functionReference; + } + } + + function transformFunctionBody(body: Node, writes: ReadonlyArray, substitutions: ReadonlyMap, hasReturn: boolean): { body: Block, returnValueProperty: string } { + if (isBlock(body) && !writes && substitutions.size === 0) { + // already block, no writes to propagate back, no substitutions - can use node as is + return { body: createBlock(body.statements, /*multLine*/ true), returnValueProperty: undefined }; + } + let returnValueProperty: string; + const statements = createNodeArray(isBlock(body) ? body.statements.slice(0) : [isStatement(body) ? body : createReturn(body)]); + // rewrite body if either there are writes that should be propagated back via return statements or there are substitutions + if (writes || substitutions.size) { + const rewrittenStatements = visitNodes(statements, visitor).slice(); + if (writes && !hasReturn && isStatement(body)) { + // add return at the end to propagate writes back in case if control flow falls out of the function body + // it is ok to know that range has at least one return since it we only allow unconditional returns + const assignments = getPropertyAssignmentsForWrites(writes); + if (assignments.length === 1) { + rewrittenStatements.push(createReturn(assignments[0].name)); } else { - const substitution = substitutions.get(getNodeId(node).toString()); - return substitution || visitEachChild(node, visitor, nullTransformationContext); + rewrittenStatements.push(createReturn(createObjectLiteral(assignments))); } } + return { body: createBlock(rewrittenStatements, /*multiLine*/ true), returnValueProperty }; } + else { + return { body: createBlock(statements, /*multiLine*/ true), returnValueProperty: undefined }; + } + + function visitor(node: Node): VisitResult { + if (node.kind === SyntaxKind.ReturnStatement && writes) { + const assignments: ObjectLiteralElementLike[] = getPropertyAssignmentsForWrites(writes); + if ((node).expression) { + if (!returnValueProperty) { + returnValueProperty = "__return"; + } + assignments.unshift(createPropertyAssignment(returnValueProperty, visitNode((node).expression, visitor))); + } + if (assignments.length === 1) { + return createReturn(assignments[0].name as Expression); + } + else { + return createReturn(createObjectLiteral(assignments)); + } + } + else { + const substitution = substitutions.get(getNodeId(node).toString()); + return substitution || visitEachChild(node, visitor, nullTransformationContext); + } + } + } + + function getStatementsOrClassElements(scope: Scope): ReadonlyArray | ReadonlyArray { + if (isFunctionLike(scope)) { + const body = scope.body; + if (isBlock(body)) { + return body.statements; + } + } + else if (isModuleBlock(scope) || isSourceFile(scope)) { + return scope.statements; + } + else if (isClassLike(scope)) { + return scope.members; + } + else { + assertTypeIsNever(scope); + } + + return emptyArray; + } + + /** + * If `scope` contains a function after `minPos`, then return the first such function. + * Otherwise, return `undefined`. + */ + function getNodeToInsertBefore(minPos: number, scope: Scope): Node | undefined { + const children = getStatementsOrClassElements(scope); + for (const child of children) { + if (child.pos >= minPos && isFunctionLike(child) && !isConstructorDeclaration(child)) { + return child; + } + } + } + + function getPropertyAssignmentsForWrites(writes: ReadonlyArray): ShorthandPropertyAssignment[] { + return writes.map(w => createShorthandPropertyAssignment(w.symbol.name)); } function isReadonlyArray(v: any): v is ReadonlyArray { @@ -948,25 +962,30 @@ namespace ts.refactor.extractMethod { Write = 2 } - export interface UsageEntry { + interface UsageEntry { readonly usage: Usage; readonly symbol: Symbol; readonly node: Node; } - export interface ScopeUsages { - usages: Map; - typeParameterUsages: Map; // Key is type ID - substitutions: Map; + interface ScopeUsages { + readonly usages: Map; + readonly typeParameterUsages: Map; // Key is type ID + readonly substitutions: Map; } + interface ReadsAndWrites { + readonly target: Expression | Block; + readonly usagesPerScope: ReadonlyArray; + readonly errorsPerScope: ReadonlyArray>; + } function collectReadsAndWrites( targetRange: TargetRange, scopes: Scope[], enclosingTextRange: TextRange, sourceFile: SourceFile, checker: TypeChecker, - cancellationToken: CancellationToken) { + cancellationToken: CancellationToken): ReadsAndWrites { const allTypeParameterUsages = createMap(); // Key is type ID const usagesPerScope: ScopeUsages[] = []; diff --git a/src/services/types.ts b/src/services/types.ts index 8a23bfec1c5..a971995f050 100644 --- a/src/services/types.ts +++ b/src/services/types.ts @@ -414,8 +414,8 @@ namespace ts { */ export interface RefactorEditInfo { edits: FileTextChanges[]; - renameFilename?: string; - renameLocation?: number; + renameFilename: string | undefined; + renameLocation: number | undefined; } export interface TextInsertion { diff --git a/tests/baselines/reference/extractMethod/extractMethod1.ts b/tests/baselines/reference/extractMethod/extractMethod1.ts index 660380c1253..86c28b5f4d2 100644 --- a/tests/baselines/reference/extractMethod/extractMethod1.ts +++ b/tests/baselines/reference/extractMethod/extractMethod1.ts @@ -23,7 +23,7 @@ namespace A { function a() { let a = 1; - newFunction(); + /*RENAME*/newFunction(); function newFunction() { let y = 5; @@ -43,7 +43,7 @@ namespace A { function a() { let a = 1; - a = newFunction(a); + a = /*RENAME*/newFunction(a); } function newFunction(a: number) { @@ -64,7 +64,7 @@ namespace A { function a() { let a = 1; - a = newFunction(a); + a = /*RENAME*/newFunction(a); } } @@ -85,7 +85,7 @@ namespace A { function a() { let a = 1; - a = newFunction(x, a, foo); + a = /*RENAME*/newFunction(x, a, foo); } } } diff --git a/tests/baselines/reference/extractMethod/extractMethod10.ts b/tests/baselines/reference/extractMethod/extractMethod10.ts index 13108a08131..e3eb73b661e 100644 --- a/tests/baselines/reference/extractMethod/extractMethod10.ts +++ b/tests/baselines/reference/extractMethod/extractMethod10.ts @@ -15,7 +15,7 @@ namespace A { class C { a() { let z = 1; - return this.newFunction(); + return this./*RENAME*/newFunction(); } private newFunction() { @@ -30,7 +30,7 @@ namespace A { class C { a() { let z = 1; - return newFunction(); + return /*RENAME*/newFunction(); } } @@ -45,7 +45,7 @@ namespace A { class C { a() { let z = 1; - return newFunction(); + return /*RENAME*/newFunction(); } } } diff --git a/tests/baselines/reference/extractMethod/extractMethod11.ts b/tests/baselines/reference/extractMethod/extractMethod11.ts index 5a2e0da826a..43fdd75b76f 100644 --- a/tests/baselines/reference/extractMethod/extractMethod11.ts +++ b/tests/baselines/reference/extractMethod/extractMethod11.ts @@ -18,7 +18,7 @@ namespace A { a() { let z = 1; var __return: any; - ({ __return, z } = this.newFunction(z)); + ({ __return, z } = this./*RENAME*/newFunction(z)); return __return; } @@ -37,7 +37,7 @@ namespace A { a() { let z = 1; var __return: any; - ({ __return, z } = newFunction(z)); + ({ __return, z } = /*RENAME*/newFunction(z)); return __return; } } @@ -56,7 +56,7 @@ namespace A { a() { let z = 1; var __return: any; - ({ __return, y, z } = newFunction(y, z)); + ({ __return, y, z } = /*RENAME*/newFunction(y, z)); return __return; } } diff --git a/tests/baselines/reference/extractMethod/extractMethod12.ts b/tests/baselines/reference/extractMethod/extractMethod12.ts index 98428a67bd0..2f3082cf280 100644 --- a/tests/baselines/reference/extractMethod/extractMethod12.ts +++ b/tests/baselines/reference/extractMethod/extractMethod12.ts @@ -21,7 +21,7 @@ namespace A { a() { let z = 1; var __return: any; - ({ __return, z } = this.newFunction(z)); + ({ __return, z } = this./*RENAME*/newFunction(z)); return __return; } diff --git a/tests/baselines/reference/extractMethod/extractMethod13.ts b/tests/baselines/reference/extractMethod/extractMethod13.ts index 44968ac4dcf..121d7eeecfa 100644 --- a/tests/baselines/reference/extractMethod/extractMethod13.ts +++ b/tests/baselines/reference/extractMethod/extractMethod13.ts @@ -20,7 +20,7 @@ (u2a: U2a, u2b: U2b) => { function F2(t2a: T2a, t2b: T2b) { (u3a: U3a, u3b: U3b) => { - newFunction(u3a); + /*RENAME*/newFunction(u3a); } function newFunction(u3a: U3a) { @@ -40,7 +40,7 @@ (u2a: U2a, u2b: U2b) => { function F2(t2a: T2a, t2b: T2b) { (u3a: U3a, u3b: U3b) => { - newFunction(t2a, u2a, u3a); + /*RENAME*/newFunction(t2a, u2a, u3a); } } } @@ -60,7 +60,7 @@ (u2a: U2a, u2b: U2b) => { function F2(t2a: T2a, t2b: T2b) { (u3a: U3a, u3b: U3b) => { - newFunction(t1a, t2a, u1a, u2a, u3a); + /*RENAME*/newFunction(t1a, t2a, u1a, u2a, u3a); } } } diff --git a/tests/baselines/reference/extractMethod/extractMethod14.ts b/tests/baselines/reference/extractMethod/extractMethod14.ts index 4db0e748907..d3dcded2c42 100644 --- a/tests/baselines/reference/extractMethod/extractMethod14.ts +++ b/tests/baselines/reference/extractMethod/extractMethod14.ts @@ -8,7 +8,7 @@ function F(t1: T) { // ==SCOPE::inner function in function 'F'== function F(t1: T) { function F(t2: T) { - newFunction(); + /*RENAME*/newFunction(); function newFunction() { t1.toString(); @@ -19,7 +19,7 @@ function F(t1: T) { // ==SCOPE::inner function in function 'F'== function F(t1: T) { function F(t2: T) { - newFunction(t2); + /*RENAME*/newFunction(t2); } function newFunction(t2: T) { @@ -30,7 +30,7 @@ function F(t1: T) { // ==SCOPE::function in global scope== function F(t1: T) { function F(t2: T) { - newFunction(t1, t2); + /*RENAME*/newFunction(t1, t2); } } function newFunction(t1: T, t2: T) { diff --git a/tests/baselines/reference/extractMethod/extractMethod15.ts b/tests/baselines/reference/extractMethod/extractMethod15.ts index 7d1c8aa4507..50516445c87 100644 --- a/tests/baselines/reference/extractMethod/extractMethod15.ts +++ b/tests/baselines/reference/extractMethod/extractMethod15.ts @@ -7,7 +7,7 @@ function F(t1: T) { // ==SCOPE::inner function in function 'F'== function F(t1: T) { function F(t2: U) { - newFunction(); + /*RENAME*/newFunction(); function newFunction() { t2.toString(); @@ -17,7 +17,7 @@ function F(t1: T) { // ==SCOPE::inner function in function 'F'== function F(t1: T) { function F(t2: U) { - newFunction(t2); + /*RENAME*/newFunction(t2); } function newFunction(t2: U) { @@ -27,7 +27,7 @@ function F(t1: T) { // ==SCOPE::function in global scope== function F(t1: T) { function F(t2: U) { - newFunction(t2); + /*RENAME*/newFunction(t2); } } function newFunction(t2: U) { diff --git a/tests/baselines/reference/extractMethod/extractMethod16.ts b/tests/baselines/reference/extractMethod/extractMethod16.ts index 2ecb0703660..e58bbf576c6 100644 --- a/tests/baselines/reference/extractMethod/extractMethod16.ts +++ b/tests/baselines/reference/extractMethod/extractMethod16.ts @@ -4,7 +4,7 @@ function F() { } // ==SCOPE::inner function in function 'F'== function F() { - const array: T[] = newFunction(); + const array: T[] = /*RENAME*/newFunction(); function newFunction(): T[] { return []; @@ -12,7 +12,7 @@ function F() { } // ==SCOPE::function in global scope== function F() { - const array: T[] = newFunction(); + const array: T[] = /*RENAME*/newFunction(); } function newFunction(): T[] { return []; diff --git a/tests/baselines/reference/extractMethod/extractMethod17.ts b/tests/baselines/reference/extractMethod/extractMethod17.ts index d0401b6b472..f79abcca792 100644 --- a/tests/baselines/reference/extractMethod/extractMethod17.ts +++ b/tests/baselines/reference/extractMethod/extractMethod17.ts @@ -7,7 +7,7 @@ class C { // ==SCOPE::method in class 'C'== class C { M(t1: T1, t2: T2) { - this.newFunction(t1); + this./*RENAME*/newFunction(t1); } private newFunction(t1: T1) { @@ -17,7 +17,7 @@ class C { // ==SCOPE::function in global scope== class C { M(t1: T1, t2: T2) { - newFunction(t1); + /*RENAME*/newFunction(t1); } } function newFunction(t1: T1) { diff --git a/tests/baselines/reference/extractMethod/extractMethod18.ts b/tests/baselines/reference/extractMethod/extractMethod18.ts index 85ef9a5d5c0..122eced75d5 100644 --- a/tests/baselines/reference/extractMethod/extractMethod18.ts +++ b/tests/baselines/reference/extractMethod/extractMethod18.ts @@ -7,7 +7,7 @@ class C { // ==SCOPE::method in class 'C'== class C { M(t1: T1, t2: T2) { - this.newFunction(t1); + this./*RENAME*/newFunction(t1); } private newFunction(t1: T1) { @@ -17,7 +17,7 @@ class C { // ==SCOPE::function in global scope== class C { M(t1: T1, t2: T2) { - newFunction(t1); + /*RENAME*/newFunction(t1); } } function newFunction(t1: T1) { diff --git a/tests/baselines/reference/extractMethod/extractMethod19.ts b/tests/baselines/reference/extractMethod/extractMethod19.ts index 80d3c61d1ee..61d35f97db5 100644 --- a/tests/baselines/reference/extractMethod/extractMethod19.ts +++ b/tests/baselines/reference/extractMethod/extractMethod19.ts @@ -4,7 +4,7 @@ function F(v: V) { } // ==SCOPE::inner function in function 'F'== function F(v: V) { - newFunction(); + /*RENAME*/newFunction(); function newFunction() { v.toString(); @@ -12,7 +12,7 @@ function F(v: V) { } // ==SCOPE::function in global scope== function F(v: V) { - newFunction(v); + /*RENAME*/newFunction(v); } function newFunction(v: V) { v.toString(); diff --git a/tests/baselines/reference/extractMethod/extractMethod2.ts b/tests/baselines/reference/extractMethod/extractMethod2.ts index 17ca6a6ba22..b83cc6f32c6 100644 --- a/tests/baselines/reference/extractMethod/extractMethod2.ts +++ b/tests/baselines/reference/extractMethod/extractMethod2.ts @@ -20,7 +20,7 @@ namespace A { namespace B { function a() { - return newFunction(); + return /*RENAME*/newFunction(); function newFunction() { let y = 5; @@ -38,7 +38,7 @@ namespace A { namespace B { function a() { - return newFunction(); + return /*RENAME*/newFunction(); } function newFunction() { @@ -56,7 +56,7 @@ namespace A { namespace B { function a() { - return newFunction(); + return /*RENAME*/newFunction(); } } @@ -74,7 +74,7 @@ namespace A { namespace B { function a() { - return newFunction(x, foo); + return /*RENAME*/newFunction(x, foo); } } } diff --git a/tests/baselines/reference/extractMethod/extractMethod20.ts b/tests/baselines/reference/extractMethod/extractMethod20.ts index 7d65bfca1a9..6e0148e0991 100644 --- a/tests/baselines/reference/extractMethod/extractMethod20.ts +++ b/tests/baselines/reference/extractMethod/extractMethod20.ts @@ -8,7 +8,7 @@ const _ = class { // ==SCOPE::method in anonymous class expression== const _ = class { a() { - return this.newFunction(); + return this./*RENAME*/newFunction(); } private newFunction() { @@ -19,7 +19,7 @@ const _ = class { // ==SCOPE::function in global scope== const _ = class { a() { - return newFunction(); + return /*RENAME*/newFunction(); } } function newFunction() { diff --git a/tests/baselines/reference/extractMethod/extractMethod21.ts b/tests/baselines/reference/extractMethod/extractMethod21.ts index 6fb5fc43155..2c4ffd1bdb8 100644 --- a/tests/baselines/reference/extractMethod/extractMethod21.ts +++ b/tests/baselines/reference/extractMethod/extractMethod21.ts @@ -7,7 +7,7 @@ function foo() { // ==SCOPE::inner function in function 'foo'== function foo() { let x = 10; - return newFunction(); + return /*RENAME*/newFunction(); function newFunction() { x++; @@ -17,7 +17,7 @@ function foo() { // ==SCOPE::function in global scope== function foo() { let x = 10; - x = newFunction(x); + x = /*RENAME*/newFunction(x); return; } function newFunction(x: number) { diff --git a/tests/baselines/reference/extractMethod/extractMethod22.ts b/tests/baselines/reference/extractMethod/extractMethod22.ts index 1bb76ef67ba..990bfdf0575 100644 --- a/tests/baselines/reference/extractMethod/extractMethod22.ts +++ b/tests/baselines/reference/extractMethod/extractMethod22.ts @@ -11,7 +11,7 @@ function test() { try { } finally { - return newFunction(); + return /*RENAME*/newFunction(); } function newFunction() { @@ -23,7 +23,7 @@ function test() { try { } finally { - return newFunction(); + return /*RENAME*/newFunction(); } } function newFunction() { diff --git a/tests/baselines/reference/extractMethod/extractMethod23.ts b/tests/baselines/reference/extractMethod/extractMethod23.ts index 0c56434447e..b9bc4264ea6 100644 --- a/tests/baselines/reference/extractMethod/extractMethod23.ts +++ b/tests/baselines/reference/extractMethod/extractMethod23.ts @@ -10,7 +10,7 @@ namespace NS { namespace NS { function M1() { } function M2() { - return newFunction(); + return /*RENAME*/newFunction(); function newFunction() { return 1; @@ -22,7 +22,7 @@ namespace NS { namespace NS { function M1() { } function M2() { - return newFunction(); + return /*RENAME*/newFunction(); } function newFunction() { return 1; @@ -34,7 +34,7 @@ namespace NS { namespace NS { function M1() { } function M2() { - return newFunction(); + return /*RENAME*/newFunction(); } function M3() { } } diff --git a/tests/baselines/reference/extractMethod/extractMethod24.ts b/tests/baselines/reference/extractMethod/extractMethod24.ts index 0b33289708f..a9dc25d32ea 100644 --- a/tests/baselines/reference/extractMethod/extractMethod24.ts +++ b/tests/baselines/reference/extractMethod/extractMethod24.ts @@ -10,7 +10,7 @@ function Outer() { function Outer() { function M1() { } function M2() { - return newFunction(); + return /*RENAME*/newFunction(); function newFunction() { return 1; @@ -22,7 +22,7 @@ function Outer() { function Outer() { function M1() { } function M2() { - return newFunction(); + return /*RENAME*/newFunction(); } function newFunction() { return 1; @@ -34,7 +34,7 @@ function Outer() { function Outer() { function M1() { } function M2() { - return newFunction(); + return /*RENAME*/newFunction(); } function M3() { } } diff --git a/tests/baselines/reference/extractMethod/extractMethod25.ts b/tests/baselines/reference/extractMethod/extractMethod25.ts index c77ec1abbfd..dc376781346 100644 --- a/tests/baselines/reference/extractMethod/extractMethod25.ts +++ b/tests/baselines/reference/extractMethod/extractMethod25.ts @@ -7,7 +7,7 @@ function M3() { } // ==SCOPE::inner function in function 'M2'== function M1() { } function M2() { - return newFunction(); + return /*RENAME*/newFunction(); function newFunction() { return 1; @@ -17,7 +17,7 @@ function M3() { } // ==SCOPE::function in global scope== function M1() { } function M2() { - return newFunction(); + return /*RENAME*/newFunction(); } function newFunction() { return 1; diff --git a/tests/baselines/reference/extractMethod/extractMethod26.ts b/tests/baselines/reference/extractMethod/extractMethod26.ts index 84dc82f7fed..b49e8ab9508 100644 --- a/tests/baselines/reference/extractMethod/extractMethod26.ts +++ b/tests/baselines/reference/extractMethod/extractMethod26.ts @@ -10,7 +10,7 @@ class C { class C { M1() { } M2() { - return this.newFunction(); + return this./*RENAME*/newFunction(); } private newFunction() { return 1; @@ -22,7 +22,7 @@ class C { class C { M1() { } M2() { - return newFunction(); + return /*RENAME*/newFunction(); } M3() { } } diff --git a/tests/baselines/reference/extractMethod/extractMethod27.ts b/tests/baselines/reference/extractMethod/extractMethod27.ts index ce21f1e1fed..0ec214bb5ed 100644 --- a/tests/baselines/reference/extractMethod/extractMethod27.ts +++ b/tests/baselines/reference/extractMethod/extractMethod27.ts @@ -11,7 +11,7 @@ class C { class C { M1() { } M2() { - return this.newFunction(); + return this./*RENAME*/newFunction(); } constructor() { } private newFunction() { @@ -24,7 +24,7 @@ class C { class C { M1() { } M2() { - return newFunction(); + return /*RENAME*/newFunction(); } constructor() { } M3() { } diff --git a/tests/baselines/reference/extractMethod/extractMethod28.ts b/tests/baselines/reference/extractMethod/extractMethod28.ts index e3d0fc3b9ea..ab6ce220bd7 100644 --- a/tests/baselines/reference/extractMethod/extractMethod28.ts +++ b/tests/baselines/reference/extractMethod/extractMethod28.ts @@ -11,7 +11,7 @@ class C { class C { M1() { } M2() { - return this.newFunction(); + return this./*RENAME*/newFunction(); } private newFunction() { return 1; @@ -24,7 +24,7 @@ class C { class C { M1() { } M2() { - return newFunction(); + return /*RENAME*/newFunction(); } M3() { } constructor() { } diff --git a/tests/baselines/reference/extractMethod/extractMethod3.ts b/tests/baselines/reference/extractMethod/extractMethod3.ts index 0d8481c9841..0af79791fe7 100644 --- a/tests/baselines/reference/extractMethod/extractMethod3.ts +++ b/tests/baselines/reference/extractMethod/extractMethod3.ts @@ -18,7 +18,7 @@ namespace A { namespace B { function* a(z: number) { - return yield* newFunction(); + return yield* /*RENAME*/newFunction(); function* newFunction() { let y = 5; @@ -35,7 +35,7 @@ namespace A { namespace B { function* a(z: number) { - return yield* newFunction(z); + return yield* /*RENAME*/newFunction(z); } function* newFunction(z: number) { @@ -52,7 +52,7 @@ namespace A { namespace B { function* a(z: number) { - return yield* newFunction(z); + return yield* /*RENAME*/newFunction(z); } } @@ -69,7 +69,7 @@ namespace A { namespace B { function* a(z: number) { - return yield* newFunction(z, foo); + return yield* /*RENAME*/newFunction(z, foo); } } } diff --git a/tests/baselines/reference/extractMethod/extractMethod4.ts b/tests/baselines/reference/extractMethod/extractMethod4.ts index 4f6a5d85f89..e0a636135d4 100644 --- a/tests/baselines/reference/extractMethod/extractMethod4.ts +++ b/tests/baselines/reference/extractMethod/extractMethod4.ts @@ -20,7 +20,7 @@ namespace A { namespace B { async function a(z: number, z1: any) { - return await newFunction(); + return await /*RENAME*/newFunction(); async function newFunction() { let y = 5; @@ -39,7 +39,7 @@ namespace A { namespace B { async function a(z: number, z1: any) { - return await newFunction(z, z1); + return await /*RENAME*/newFunction(z, z1); } async function newFunction(z: number, z1: any) { @@ -58,7 +58,7 @@ namespace A { namespace B { async function a(z: number, z1: any) { - return await newFunction(z, z1); + return await /*RENAME*/newFunction(z, z1); } } @@ -77,7 +77,7 @@ namespace A { namespace B { async function a(z: number, z1: any) { - return await newFunction(z, z1, foo); + return await /*RENAME*/newFunction(z, z1, foo); } } } diff --git a/tests/baselines/reference/extractMethod/extractMethod5.ts b/tests/baselines/reference/extractMethod/extractMethod5.ts index 10ff0005f73..fc15f6762e5 100644 --- a/tests/baselines/reference/extractMethod/extractMethod5.ts +++ b/tests/baselines/reference/extractMethod/extractMethod5.ts @@ -23,7 +23,7 @@ namespace A { function a() { let a = 1; - newFunction(); + /*RENAME*/newFunction(); function newFunction() { let y = 5; @@ -43,7 +43,7 @@ namespace A { function a() { let a = 1; - a = newFunction(a); + a = /*RENAME*/newFunction(a); } function newFunction(a: number) { @@ -64,7 +64,7 @@ namespace A { function a() { let a = 1; - a = newFunction(a); + a = /*RENAME*/newFunction(a); } } @@ -85,7 +85,7 @@ namespace A { function a() { let a = 1; - a = newFunction(x, a); + a = /*RENAME*/newFunction(x, a); } } } diff --git a/tests/baselines/reference/extractMethod/extractMethod6.ts b/tests/baselines/reference/extractMethod/extractMethod6.ts index 40135e6ec97..37112b80e9e 100644 --- a/tests/baselines/reference/extractMethod/extractMethod6.ts +++ b/tests/baselines/reference/extractMethod/extractMethod6.ts @@ -23,7 +23,7 @@ namespace A { function a() { let a = 1; - return newFunction(); + return /*RENAME*/newFunction(); function newFunction() { let y = 5; @@ -44,7 +44,7 @@ namespace A { let a = 1; var __return: any; - ({ __return, a } = newFunction(a)); + ({ __return, a } = /*RENAME*/newFunction(a)); return __return; } @@ -66,7 +66,7 @@ namespace A { let a = 1; var __return: any; - ({ __return, a } = newFunction(a)); + ({ __return, a } = /*RENAME*/newFunction(a)); return __return; } } @@ -88,7 +88,7 @@ namespace A { let a = 1; var __return: any; - ({ __return, a } = newFunction(x, a)); + ({ __return, a } = /*RENAME*/newFunction(x, a)); return __return; } } diff --git a/tests/baselines/reference/extractMethod/extractMethod7.ts b/tests/baselines/reference/extractMethod/extractMethod7.ts index d01532da796..8859b7b4fdd 100644 --- a/tests/baselines/reference/extractMethod/extractMethod7.ts +++ b/tests/baselines/reference/extractMethod/extractMethod7.ts @@ -27,7 +27,7 @@ namespace A { function a() { let a = 1; - return newFunction(); + return /*RENAME*/newFunction(); function newFunction() { let y = 5; @@ -50,7 +50,7 @@ namespace A { let a = 1; var __return: any; - ({ __return, a } = newFunction(a)); + ({ __return, a } = /*RENAME*/newFunction(a)); return __return; } @@ -74,7 +74,7 @@ namespace A { let a = 1; var __return: any; - ({ __return, a } = newFunction(a)); + ({ __return, a } = /*RENAME*/newFunction(a)); return __return; } } @@ -98,7 +98,7 @@ namespace A { let a = 1; var __return: any; - ({ __return, a } = newFunction(x, a)); + ({ __return, a } = /*RENAME*/newFunction(x, a)); return __return; } } diff --git a/tests/baselines/reference/extractMethod/extractMethod8.ts b/tests/baselines/reference/extractMethod/extractMethod8.ts index d59ca5dc238..cb06470d385 100644 --- a/tests/baselines/reference/extractMethod/extractMethod8.ts +++ b/tests/baselines/reference/extractMethod/extractMethod8.ts @@ -14,7 +14,7 @@ namespace A { namespace B { function a() { let a1 = 1; - return newFunction() + 100; + return /*RENAME*/newFunction() + 100; function newFunction() { return 1 + a1 + x; @@ -28,7 +28,7 @@ namespace A { namespace B { function a() { let a1 = 1; - return newFunction(a1) + 100; + return /*RENAME*/newFunction(a1) + 100; } function newFunction(a1: number) { @@ -42,7 +42,7 @@ namespace A { namespace B { function a() { let a1 = 1; - return newFunction(a1) + 100; + return /*RENAME*/newFunction(a1) + 100; } } @@ -56,7 +56,7 @@ namespace A { namespace B { function a() { let a1 = 1; - return newFunction(a1, x) + 100; + return /*RENAME*/newFunction(a1, x) + 100; } } } diff --git a/tests/baselines/reference/extractMethod/extractMethod9.ts b/tests/baselines/reference/extractMethod/extractMethod9.ts index 342e3c10eee..022dab82363 100644 --- a/tests/baselines/reference/extractMethod/extractMethod9.ts +++ b/tests/baselines/reference/extractMethod/extractMethod9.ts @@ -13,7 +13,7 @@ namespace A { export interface I { x: number }; namespace B { function a() { - return newFunction(); + return /*RENAME*/newFunction(); function newFunction() { let a1: I = { x: 1 }; @@ -27,7 +27,7 @@ namespace A { export interface I { x: number }; namespace B { function a() { - return newFunction(); + return /*RENAME*/newFunction(); } function newFunction() { @@ -41,7 +41,7 @@ namespace A { export interface I { x: number }; namespace B { function a() { - return newFunction(); + return /*RENAME*/newFunction(); } } @@ -55,7 +55,7 @@ namespace A { export interface I { x: number }; namespace B { function a() { - return newFunction(); + return /*RENAME*/newFunction(); } } } diff --git a/tests/cases/fourslash/extract-method-formatting.ts b/tests/cases/fourslash/extract-method-formatting.ts index a346ad3bbd9..e4193fd8db3 100644 --- a/tests/cases/fourslash/extract-method-formatting.ts +++ b/tests/cases/fourslash/extract-method-formatting.ts @@ -10,10 +10,8 @@ edit.applyRefactor({ refactorName: "Extract Method", actionName: "scope_1", actionDescription: "Extract to function in global scope", -}); -verify.currentFileContentIs( -`function f(x: number): number { - return newFunction(x); + newContent: `function f(x: number): number { + return /*RENAME*/newFunction(x); } function newFunction(x: number) { switch (x) { @@ -21,4 +19,5 @@ function newFunction(x: number) { return 0; } } -`); +` +}); diff --git a/tests/cases/fourslash/extract-method-uniqueName.ts b/tests/cases/fourslash/extract-method-uniqueName.ts new file mode 100644 index 00000000000..44f026ae8a8 --- /dev/null +++ b/tests/cases/fourslash/extract-method-uniqueName.ts @@ -0,0 +1,20 @@ +/// + +////// newFunction +/////*start*/1 + 1/*end*/; + +goTo.select('start', 'end') +edit.applyRefactor({ + refactorName: "Extract Method", + actionName: "scope_0", + actionDescription: "Extract to function in global scope", + newContent: +`// newFunction +/*RENAME*/newFunction_1(); + +function newFunction_1() { + // newFunction + 1 + 1; +} +` +}); diff --git a/tests/cases/fourslash/extract-method1.ts b/tests/cases/fourslash/extract-method1.ts index 64dffc15a90..a8d421923b1 100644 --- a/tests/cases/fourslash/extract-method1.ts +++ b/tests/cases/fourslash/extract-method1.ts @@ -17,11 +17,10 @@ edit.applyRefactor({ refactorName: "Extract Method", actionName: "scope_0", actionDescription: "Extract to method in class 'Foo'", -}); -verify.currentFileContentIs( + newContent: `class Foo { someMethod(m: number) { - this.newFunction(m); + this./*RENAME*/newFunction(m); var q = 10; return q; } @@ -33,4 +32,5 @@ verify.currentFileContentIs( var z = y + x; console.log(z); } -}`); +}` +}); diff --git a/tests/cases/fourslash/extract-method10.ts b/tests/cases/fourslash/extract-method10.ts index 73ef3029e24..215196d6c51 100644 --- a/tests/cases/fourslash/extract-method10.ts +++ b/tests/cases/fourslash/extract-method10.ts @@ -8,4 +8,11 @@ edit.applyRefactor({ refactorName: "Extract Method", actionName: 'scope_0', actionDescription: "Extract to function in module scope", + newContent: +`export {}; // Make this a module +(x => x)(/*RENAME*/newFunction())(1); +function newFunction(): (x: any) => any { + return x => x; +} +` }); diff --git a/tests/cases/fourslash/extract-method13.ts b/tests/cases/fourslash/extract-method13.ts index fa84ec4fb62..274753fd5cd 100644 --- a/tests/cases/fourslash/extract-method13.ts +++ b/tests/cases/fourslash/extract-method13.ts @@ -14,6 +14,16 @@ edit.applyRefactor({ refactorName: "Extract Method", actionName: "scope_0", actionDescription: "Extract to method in class 'C'", + newContent: +`class C { + static j = 1 + 1; + constructor(q: string = C./*RENAME*/newFunction()) { + } + + private static newFunction(): string { + return "a" + "b"; + } +}` }); verify.currentFileContentIs(`class C { @@ -31,10 +41,9 @@ edit.applyRefactor({ refactorName: "Extract Method", actionName: "scope_0", actionDescription: "Extract to method in class 'C'", -}); - -verify.currentFileContentIs(`class C { - static j = C.newFunction_1(); + newContent: +`class C { + static j = C./*RENAME*/newFunction_1(); constructor(q: string = C.newFunction()) { } @@ -45,4 +54,5 @@ verify.currentFileContentIs(`class C { private static newFunction(): string { return "a" + "b"; } -}`); \ No newline at end of file +}` +}); diff --git a/tests/cases/fourslash/extract-method14.ts b/tests/cases/fourslash/extract-method14.ts index 770ed3d0fcb..27a561743c6 100644 --- a/tests/cases/fourslash/extract-method14.ts +++ b/tests/cases/fourslash/extract-method14.ts @@ -15,14 +15,15 @@ edit.applyRefactor({ refactorName: "Extract Method", actionName: "scope_1", actionDescription: "Extract to function in global scope", -}); -verify.currentFileContentIs(`function foo() { + newContent: +`function foo() { var i = 10; var __return: any; - ({ __return, i } = newFunction(i)); + ({ __return, i } = n/*RENAME*/ewFunction(i)); return __return; } function newFunction(i) { return { __return: i++, i }; } -`); \ No newline at end of file +` +}); diff --git a/tests/cases/fourslash/extract-method15.ts b/tests/cases/fourslash/extract-method15.ts index 8d3db633b11..c3db3186cdf 100644 --- a/tests/cases/fourslash/extract-method15.ts +++ b/tests/cases/fourslash/extract-method15.ts @@ -13,14 +13,14 @@ edit.applyRefactor({ refactorName: "Extract Method", actionName: "scope_1", actionDescription: "Extract to function in global scope", -}); - -verify.currentFileContentIs(`function foo() { + newContent: +`function foo() { var i = 10; - i = newFunction(i); + i = /*RENAME*/newFunction(i); } function newFunction(i: number) { i++; return i; } -`); +` +}); diff --git a/tests/cases/fourslash/extract-method18.ts b/tests/cases/fourslash/extract-method18.ts index 6d4d06ca7bf..8ff1cc3028d 100644 --- a/tests/cases/fourslash/extract-method18.ts +++ b/tests/cases/fourslash/extract-method18.ts @@ -13,12 +13,13 @@ edit.applyRefactor({ refactorName: "Extract Method", actionName: "scope_1", actionDescription: "Extract to function in global scope", -}); -verify.currentFileContentIs(`function fn() { + newContent: +`function fn() { const x = { m: 1 }; - newFunction(x); + /*RENAME*/newFunction(x); } function newFunction(x: { m: number; }) { x.m = 3; } -`); +` +}); diff --git a/tests/cases/fourslash/extract-method19.ts b/tests/cases/fourslash/extract-method19.ts index da999fcc093..56d6b02560f 100644 --- a/tests/cases/fourslash/extract-method19.ts +++ b/tests/cases/fourslash/extract-method19.ts @@ -13,13 +13,14 @@ edit.applyRefactor({ refactorName: "Extract Method", actionName: "scope_0", actionDescription: "Extract to inner function in function 'fn'", -}); -verify.currentFileContentIs(`function fn() { - newFunction_1(); + newContent: +`function fn() { + /*RENAME*/newFunction_1(); function newFunction_1() { console.log("hi"); } } -function newFunction() { }`); +function newFunction() { }` +}); diff --git a/tests/cases/fourslash/extract-method2.ts b/tests/cases/fourslash/extract-method2.ts index 021716b6e48..6fbe7394c2f 100644 --- a/tests/cases/fourslash/extract-method2.ts +++ b/tests/cases/fourslash/extract-method2.ts @@ -14,18 +14,18 @@ edit.applyRefactor({ refactorName: "Extract Method", actionName: "scope_2", actionDescription: "Extract to function in global scope", -}); -verify.currentFileContentIs( + newContent: `namespace NS { class Q { foo() { console.log('100'); const m = 10, j = "hello", k = {x: "what"}; - const q = newFunction(m, j, k); + const q = /*RENAME*/newFunction(m, j, k); } } } function newFunction(m: number, j: string, k: { x: string; }) { return m + j + k; } -`); +` +}); diff --git a/tests/cases/fourslash/extract-method21.ts b/tests/cases/fourslash/extract-method21.ts index f19d4b05912..8e3baf61949 100644 --- a/tests/cases/fourslash/extract-method21.ts +++ b/tests/cases/fourslash/extract-method21.ts @@ -16,14 +16,14 @@ edit.applyRefactor({ refactorName: "Extract Method", actionName: "scope_0", actionDescription: "Extract to method in class 'Foo'", -}); - -verify.currentFileContentIs(`class Foo { + newContent: +`class Foo { static method() { - return Foo.newFunction(); + return Foo./*RENAME*/newFunction(); } private static newFunction() { return 1; } -}`); \ No newline at end of file +}` +}); diff --git a/tests/cases/fourslash/extract-method24.ts b/tests/cases/fourslash/extract-method24.ts index e5f923bb80d..5706c5c7a54 100644 --- a/tests/cases/fourslash/extract-method24.ts +++ b/tests/cases/fourslash/extract-method24.ts @@ -11,13 +11,14 @@ edit.applyRefactor({ refactorName: "Extract Method", actionName: "scope_1", actionDescription: "Extract to function in global scope", -}); -verify.currentFileContentIs(`function M() { + newContent: +`function M() { let a = [1,2,3]; let x = 0; - console.log(newFunction(a, x)); + console.log(/*RENAME*/newFunction(a, x)); } function newFunction(a: number[], x: number): any { return a[x]; } -`); \ No newline at end of file +` +}); diff --git a/tests/cases/fourslash/extract-method25.ts b/tests/cases/fourslash/extract-method25.ts index d18d0691e61..4fb2193adf3 100644 --- a/tests/cases/fourslash/extract-method25.ts +++ b/tests/cases/fourslash/extract-method25.ts @@ -12,12 +12,13 @@ edit.applyRefactor({ refactorName: "Extract Method", actionName: "scope_0", actionDescription: "Extract to inner function in function 'fn'", -}); -verify.currentFileContentIs(`function fn() { - var q = newFunction() + newContent: +`function fn() { + var q = /*RENAME*/newFunction() q[0]++ function newFunction() { return [0]; } -}`); +}` +}); diff --git a/tests/cases/fourslash/extract-method5.ts b/tests/cases/fourslash/extract-method5.ts index 014dfb35d08..b27d9a8209b 100644 --- a/tests/cases/fourslash/extract-method5.ts +++ b/tests/cases/fourslash/extract-method5.ts @@ -13,13 +13,12 @@ edit.applyRefactor({ refactorName: "Extract Method", actionName: "scope_0", actionDescription: "Extract to inner function in function 'f'", -}); -// TODO: GH#18091 (fix formatting to use `2 ? 1 :` and not `2?1:`) -verify.currentFileContentIs( + newContent: `function f() { - var x: 1 | 2 | 3 = newFunction(); + var x: 1 | 2 | 3 = /*RENAME*/newFunction(); function newFunction(): 1 | 2 | 3 { return 1 + 1 === 2 ? 1 : 2; } -}`); \ No newline at end of file +}` +}); diff --git a/tests/cases/fourslash/extract-method7.ts b/tests/cases/fourslash/extract-method7.ts index d8459bf77ad..c28e12dce8c 100644 --- a/tests/cases/fourslash/extract-method7.ts +++ b/tests/cases/fourslash/extract-method7.ts @@ -11,10 +11,11 @@ edit.applyRefactor({ refactorName: "Extract Method", actionName: "scope_0", actionDescription: "Extract to function in global scope", -}); -verify.currentFileContentIs(`function fn(x = newFunction()) { + newContent: +`function fn(x = /*RENAME*/newFunction()) { } function newFunction() { return 1 + 1; } -`); +` +}); diff --git a/tests/cases/fourslash/fourslash.ts b/tests/cases/fourslash/fourslash.ts index 119780872e9..7901d9550cb 100644 --- a/tests/cases/fourslash/fourslash.ts +++ b/tests/cases/fourslash/fourslash.ts @@ -310,7 +310,7 @@ declare namespace FourSlashInterface { enableFormatting(): void; disableFormatting(): void; - applyRefactor(options: { refactorName: string, actionName: string, actionDescription: string }): void; + applyRefactor(options: { refactorName: string, actionName: string, actionDescription: string, newContent: string }): void; } class debug { printCurrentParameterHelp(): void; From 2a70bf51589c4312a9329bce68cb2b5c9876e613 Mon Sep 17 00:00:00 2001 From: Andy Date: Wed, 13 Sep 2017 09:02:33 -0700 Subject: [PATCH 312/370] Don't count a write-only reference as a use (#17752) * Don't count a write-only reference as a use * Split isWriteAccess to isWriteOnlyAccess and isReadOnlyAccess * Update "unusedParameterUsedInTypeOf" to use "b" * Update diagnostic messages: "is never used" -> "its value is never read" * Use a WriteKind enum * Rename enum and move documentation to enum members --- src/compiler/checker.ts | 102 ++++++++++-------- src/compiler/diagnosticMessages.json | 4 +- src/compiler/transformers/es2017.ts | 7 -- src/compiler/transformers/generators.ts | 4 - src/compiler/tsc.ts | 3 +- src/compiler/utilities.ts | 40 +++++++ src/harness/compilerRunner.ts | 18 ---- src/harness/unittests/compileOnSave.ts | 11 -- src/harness/unittests/typingsInstaller.ts | 2 - src/server/server.ts | 3 +- src/services/codefixes/fixUnusedIdentifier.ts | 4 +- src/services/findAllReferences.ts | 21 +--- src/services/preProcess.ts | 2 - .../reference/extendsUntypedModule.errors.txt | 4 +- .../noUnusedLocals_selfReference.errors.txt | 12 +-- .../noUnusedLocals_writeOnly.errors.txt | 16 +++ .../reference/noUnusedLocals_writeOnly.js | 22 ++++ ...oUnusedLocals_writeOnlyProperty.errors.txt | 13 +++ .../noUnusedLocals_writeOnlyProperty.js | 18 ++++ .../unusedClassesinModule1.errors.txt | 4 +- .../unusedClassesinNamespace1.errors.txt | 4 +- .../unusedClassesinNamespace2.errors.txt | 4 +- .../unusedClassesinNamespace4.errors.txt | 4 +- .../unusedClassesinNamespace5.errors.txt | 4 +- .../unusedDestructuringParameters.errors.txt | 8 +- .../unusedFunctionsinNamespaces1.errors.txt | 4 +- .../unusedFunctionsinNamespaces2.errors.txt | 4 +- .../unusedFunctionsinNamespaces3.errors.txt | 8 +- .../unusedFunctionsinNamespaces4.errors.txt | 4 +- .../unusedFunctionsinNamespaces5.errors.txt | 8 +- .../unusedFunctionsinNamespaces6.errors.txt | 4 +- .../unusedIdentifiersConsolidated1.errors.txt | 69 ++++++------ .../reference/unusedImports1.errors.txt | 4 +- .../reference/unusedImports10.errors.txt | 4 +- .../reference/unusedImports12.errors.txt | 20 ++-- .../reference/unusedImports2.errors.txt | 4 +- .../reference/unusedImports3.errors.txt | 4 +- .../reference/unusedImports4.errors.txt | 4 +- .../reference/unusedImports5.errors.txt | 4 +- .../reference/unusedImports6.errors.txt | 4 +- .../reference/unusedImports7.errors.txt | 4 +- .../reference/unusedImports8.errors.txt | 4 +- .../reference/unusedImports9.errors.txt | 4 +- .../unusedInterfaceinNamespace1.errors.txt | 4 +- .../unusedInterfaceinNamespace2.errors.txt | 4 +- .../unusedInterfaceinNamespace3.errors.txt | 4 +- .../unusedLocalsAndObjectSpread.errors.txt | 8 +- .../unusedLocalsAndObjectSpread2.errors.txt | 12 +-- .../unusedLocalsAndParameters.errors.txt | 84 +++++++-------- ...LocalsAndParametersTypeAliases2.errors.txt | 12 +-- .../unusedLocalsInMethod1.errors.txt | 4 +- .../unusedLocalsInMethod2.errors.txt | 9 +- .../unusedLocalsInMethod3.errors.txt | 9 +- ...ationWithinFunctionDeclaration1.errors.txt | 25 +++-- ...ationWithinFunctionDeclaration2.errors.txt | 28 ++--- ...rationWithinFunctionExpression1.errors.txt | 25 +++-- ...rationWithinFunctionExpression2.errors.txt | 28 ++--- ...ssionWithinFunctionDeclaration1.errors.txt | 25 +++-- ...ssionWithinFunctionDeclaration2.errors.txt | 28 ++--- ...essionWithinFunctionExpression1.errors.txt | 25 +++-- ...essionWithinFunctionExpression2.errors.txt | 28 ++--- ...sedLocalsStartingWithUnderscore.errors.txt | 4 +- .../unusedLocalsinConstructor1.errors.txt | 4 +- .../unusedLocalsinConstructor2.errors.txt | 4 +- .../reference/unusedModuleInModule.errors.txt | 4 +- ...dMultipleParameter1InContructor.errors.txt | 13 ++- ...eParameter1InFunctionExpression.errors.txt | 13 ++- ...dMultipleParameter2InContructor.errors.txt | 17 +-- ...eParameter2InFunctionExpression.errors.txt | 17 +-- ...arameters1InFunctionDeclaration.errors.txt | 13 ++- ...eParameters1InMethodDeclaration.errors.txt | 13 ++- ...arameters2InFunctionDeclaration.errors.txt | 17 +-- ...eParameters2InMethodDeclaration.errors.txt | 17 +-- .../unusedNamespaceInModule.errors.txt | 4 +- .../unusedNamespaceInNamespace.errors.txt | 4 +- .../unusedParameterProperty1.errors.txt | 9 +- .../unusedParameterProperty2.errors.txt | 9 +- .../reference/unusedParameterUsedInTypeOf.js | 4 +- .../unusedParameterUsedInTypeOf.symbols | 2 +- .../unusedParameterUsedInTypeOf.types | 5 +- .../unusedParametersInLambda1.errors.txt | 4 +- .../unusedParametersInLambda2.errors.txt | 4 +- .../unusedParametersWithUnderscore.errors.txt | 24 ++--- .../unusedParametersinConstructor1.errors.txt | 4 +- .../unusedParametersinConstructor2.errors.txt | 4 +- .../unusedParametersinConstructor3.errors.txt | 8 +- .../unusedPrivateMethodInClass1.errors.txt | 9 +- .../unusedPrivateMethodInClass2.errors.txt | 16 ++- .../unusedPrivateMethodInClass3.errors.txt | 19 +++- .../unusedPrivateMethodInClass4.errors.txt | 15 ++- .../unusedPrivateVariableInClass1.errors.txt | 4 +- .../unusedPrivateVariableInClass2.errors.txt | 8 +- .../unusedPrivateVariableInClass3.errors.txt | 8 +- .../unusedPrivateVariableInClass4.errors.txt | 6 +- .../unusedPrivateVariableInClass4.js | 4 +- .../unusedPrivateVariableInClass5.errors.txt | 6 +- .../unusedPrivateVariableInClass5.js | 4 +- .../reference/unusedSetterInClass.errors.txt | 13 +++ ...usedSingleParameterInContructor.errors.txt | 8 +- ...eParameterInFunctionDeclaration.errors.txt | 8 +- ...leParameterInFunctionExpression.errors.txt | 8 +- ...gleParameterInMethodDeclaration.errors.txt | 8 +- .../reference/unusedSwitchStatment.errors.txt | 17 +-- .../unusedTypeParameterInFunction1.errors.txt | 4 +- .../unusedTypeParameterInFunction2.errors.txt | 4 +- .../unusedTypeParameterInFunction3.errors.txt | 4 +- .../unusedTypeParameterInFunction4.errors.txt | 4 +- ...unusedTypeParameterInInterface1.errors.txt | 4 +- ...unusedTypeParameterInInterface2.errors.txt | 4 +- .../unusedTypeParameterInLambda1.errors.txt | 4 +- .../unusedTypeParameterInLambda2.errors.txt | 4 +- .../unusedTypeParameterInLambda3.errors.txt | 4 +- .../unusedTypeParameterInMethod1.errors.txt | 4 +- .../unusedTypeParameterInMethod2.errors.txt | 4 +- .../unusedTypeParameterInMethod3.errors.txt | 4 +- .../unusedTypeParameterInMethod4.errors.txt | 4 +- .../unusedTypeParameterInMethod5.errors.txt | 4 +- .../unusedTypeParameters1.errors.txt | 4 +- .../unusedTypeParameters10.errors.txt | 4 +- .../unusedTypeParameters2.errors.txt | 4 +- .../unusedTypeParameters3.errors.txt | 8 +- .../unusedTypeParameters4.errors.txt | 4 +- .../unusedTypeParameters5.errors.txt | 4 +- .../unusedTypeParameters8.errors.txt | 4 +- .../unusedVariablesinBlocks1.errors.txt | 9 +- .../unusedVariablesinBlocks2.errors.txt | 9 +- .../unusedVariablesinForLoop.errors.txt | 4 +- .../unusedVariablesinForLoop2.errors.txt | 4 +- .../unusedVariablesinForLoop3.errors.txt | 4 +- .../unusedVariablesinForLoop4.errors.txt | 4 +- .../unusedVariablesinModules1.errors.txt | 4 +- .../unusedVariablesinNamespaces1.errors.txt | 4 +- .../unusedVariablesinNamespaces2.errors.txt | 4 +- .../unusedVariablesinNamespaces3.errors.txt | 4 +- .../compiler/noUnusedLocals_writeOnly.ts | 12 +++ .../noUnusedLocals_writeOnlyProperty.ts | 8 ++ .../compiler/unusedParameterUsedInTypeOf.ts | 2 +- .../compiler/unusedPrivateVariableInClass4.ts | 2 +- .../compiler/unusedPrivateVariableInClass5.ts | 2 +- ...indAllRefsParameterPropertyDeclaration1.ts | 2 +- ...indAllRefsParameterPropertyDeclaration2.ts | 2 +- ...indAllRefsParameterPropertyDeclaration3.ts | 2 +- tests/cases/fourslash/localGetReferences.ts | 14 +-- ...referenceInParameterPropertyDeclaration.ts | 6 +- .../fourslash/referencesForClassLocal.ts | 4 +- .../fourslash/referencesForClassParameter.ts | 4 +- .../cases/fourslash/referencesForOverrides.ts | 2 +- tests/cases/fourslash/referencesForStatic.ts | 4 +- ...eferencesForStringLiteralPropertyNames4.ts | 2 +- tests/cases/fourslash/remoteGetReferences.ts | 12 +-- .../fourslash/unusedLocalsInFunction4.ts | 3 +- .../fourslash/unusedLocalsInMethodFS1.ts | 4 +- .../fourslash/unusedLocalsInMethodFS2.ts | 2 +- .../fourslash/unusedParameterInFunction2.ts | 2 +- .../fourslash/unusedParameterInFunction4.ts | 3 +- .../fourslash/unusedVariableInNamespace2.ts | 3 +- .../fourslash/unusedVariableInNamespace3.ts | 3 +- 157 files changed, 826 insertions(+), 651 deletions(-) create mode 100644 tests/baselines/reference/noUnusedLocals_writeOnly.errors.txt create mode 100644 tests/baselines/reference/noUnusedLocals_writeOnly.js create mode 100644 tests/baselines/reference/noUnusedLocals_writeOnlyProperty.errors.txt create mode 100644 tests/baselines/reference/noUnusedLocals_writeOnlyProperty.js create mode 100644 tests/baselines/reference/unusedSetterInClass.errors.txt create mode 100644 tests/cases/compiler/noUnusedLocals_writeOnly.ts create mode 100644 tests/cases/compiler/noUnusedLocals_writeOnlyProperty.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index c169dcb83ca..5c6a8b59119 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -230,7 +230,7 @@ namespace ts { getSuggestionForNonexistentSymbol: (location, name, meaning) => unescapeLeadingUnderscores(getSuggestionForNonexistentSymbol(location, escapeLeadingUnderscores(name), meaning)), getBaseConstraintOfType, resolveName(name, location, meaning) { - return resolveName(location, escapeLeadingUnderscores(name), meaning, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined); + return resolveName(location, escapeLeadingUnderscores(name), meaning, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false); }, getJsxNamespace: () => unescapeLeadingUnderscores(getJsxNamespace()), }; @@ -865,17 +865,22 @@ namespace ts { } } - // Resolve a given name for a given meaning at a given location. An error is reported if the name was not found and - // the nameNotFoundMessage argument is not undefined. Returns the resolved symbol, or undefined if no symbol with - // the given name can be found. + /** + * Resolve a given name for a given meaning at a given location. An error is reported if the name was not found and + * the nameNotFoundMessage argument is not undefined. Returns the resolved symbol, or undefined if no symbol with + * the given name can be found. + * + * @param isUse If true, this will count towards --noUnusedLocals / --noUnusedParameters. + */ function resolveName( location: Node | undefined, name: __String, meaning: SymbolFlags, nameNotFoundMessage: DiagnosticMessage | undefined, nameArg: __String | Identifier, + isUse: boolean, suggestedNameNotFoundMessage?: DiagnosticMessage): Symbol { - return resolveNameHelper(location, name, meaning, nameNotFoundMessage, nameArg, getSymbol, suggestedNameNotFoundMessage); + return resolveNameHelper(location, name, meaning, nameNotFoundMessage, nameArg, isUse, getSymbol, suggestedNameNotFoundMessage); } function resolveNameHelper( @@ -884,6 +889,7 @@ namespace ts { meaning: SymbolFlags, nameNotFoundMessage: DiagnosticMessage, nameArg: __String | Identifier, + isUse: boolean, lookup: typeof getSymbol, suggestedNameNotFoundMessage?: DiagnosticMessage): Symbol { const originalLocation = location; // needed for did-you-mean error reporting, which gathers candidates starting from the original location @@ -1114,7 +1120,7 @@ namespace ts { // We just climbed up parents looking for the name, meaning that we started in a descendant node of `lastLocation`. // If `result === lastLocation.symbol`, that means that we are somewhere inside `lastLocation` looking up a name, and resolving to `lastLocation` itself. // That means that this is a self-reference of `lastLocation`, and shouldn't count this when considering whether `lastLocation` is used. - if (result && nameNotFoundMessage && noUnusedIdentifiers && result !== lastLocation.symbol) { + if (isUse && result && nameNotFoundMessage && noUnusedIdentifiers && result !== lastLocation.symbol) { result.isReferenced = true; } @@ -1267,7 +1273,7 @@ namespace ts { function checkAndReportErrorForUsingTypeAsNamespace(errorLocation: Node, name: __String, meaning: SymbolFlags): boolean { if (meaning === SymbolFlags.Namespace) { - const symbol = resolveSymbol(resolveName(errorLocation, name, SymbolFlags.Type & ~SymbolFlags.Value, /*nameNotFoundMessage*/undefined, /*nameArg*/ undefined)); + const symbol = resolveSymbol(resolveName(errorLocation, name, SymbolFlags.Type & ~SymbolFlags.Value, /*nameNotFoundMessage*/undefined, /*nameArg*/ undefined, /*isUse*/ false)); const parent = errorLocation.parent; if (symbol) { if (isQualifiedName(parent)) { @@ -1298,7 +1304,7 @@ namespace ts { error(errorLocation, Diagnostics._0_only_refers_to_a_type_but_is_being_used_as_a_value_here, unescapeLeadingUnderscores(name)); return true; } - const symbol = resolveSymbol(resolveName(errorLocation, name, SymbolFlags.Type & ~SymbolFlags.Value, /*nameNotFoundMessage*/undefined, /*nameArg*/ undefined)); + const symbol = resolveSymbol(resolveName(errorLocation, name, SymbolFlags.Type & ~SymbolFlags.Value, /*nameNotFoundMessage*/undefined, /*nameArg*/ undefined, /*isUse*/ false)); if (symbol && !(symbol.flags & SymbolFlags.NamespaceModule)) { error(errorLocation, Diagnostics._0_only_refers_to_a_type_but_is_being_used_as_a_value_here, unescapeLeadingUnderscores(name)); return true; @@ -1309,14 +1315,14 @@ namespace ts { function checkAndReportErrorForUsingNamespaceModuleAsValue(errorLocation: Node, name: __String, meaning: SymbolFlags): boolean { if (meaning & (SymbolFlags.Value & ~SymbolFlags.NamespaceModule & ~SymbolFlags.Type)) { - const symbol = resolveSymbol(resolveName(errorLocation, name, SymbolFlags.NamespaceModule & ~SymbolFlags.Value, /*nameNotFoundMessage*/undefined, /*nameArg*/ undefined)); + const symbol = resolveSymbol(resolveName(errorLocation, name, SymbolFlags.NamespaceModule & ~SymbolFlags.Value, /*nameNotFoundMessage*/undefined, /*nameArg*/ undefined, /*isUse*/ false)); if (symbol) { error(errorLocation, Diagnostics.Cannot_use_namespace_0_as_a_value, unescapeLeadingUnderscores(name)); return true; } } else if (meaning & (SymbolFlags.Type & ~SymbolFlags.NamespaceModule & ~SymbolFlags.Value)) { - const symbol = resolveSymbol(resolveName(errorLocation, name, SymbolFlags.NamespaceModule & ~SymbolFlags.Type, /*nameNotFoundMessage*/undefined, /*nameArg*/ undefined)); + const symbol = resolveSymbol(resolveName(errorLocation, name, SymbolFlags.NamespaceModule & ~SymbolFlags.Type, /*nameNotFoundMessage*/undefined, /*nameArg*/ undefined, /*isUse*/ false)); if (symbol) { error(errorLocation, Diagnostics.Cannot_use_namespace_0_as_a_type, unescapeLeadingUnderscores(name)); return true; @@ -1640,7 +1646,7 @@ namespace ts { if (name.kind === SyntaxKind.Identifier) { const message = meaning === SymbolFlags.Namespace ? Diagnostics.Cannot_find_namespace_0 : Diagnostics.Cannot_find_name_0; - symbol = resolveName(location || name, name.escapedText, meaning, ignoreErrors ? undefined : message, name); + symbol = resolveName(location || name, name.escapedText, meaning, ignoreErrors ? undefined : message, name, /*isUse*/ true); if (!symbol) { return undefined; } @@ -2314,7 +2320,7 @@ namespace ts { } const firstIdentifier = getFirstIdentifier(entityName); - const symbol = resolveName(enclosingDeclaration, firstIdentifier.escapedText, meaning, /*nodeNotFoundErrorMessage*/ undefined, /*nameArg*/ undefined); + const symbol = resolveName(enclosingDeclaration, firstIdentifier.escapedText, meaning, /*nodeNotFoundErrorMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false); // Verify if the symbol is accessible return (symbol && hasVisibleDeclarations(symbol, /*shouldComputeAliasToMakeVisible*/ true)) || { @@ -3971,7 +3977,7 @@ namespace ts { function collectLinkedAliases(node: Identifier): Node[] { let exportSymbol: Symbol; if (node.parent && node.parent.kind === SyntaxKind.ExportAssignment) { - exportSymbol = resolveName(node.parent, node.escapedText, SymbolFlags.Value | SymbolFlags.Type | SymbolFlags.Namespace | SymbolFlags.Alias, Diagnostics.Cannot_find_name_0, node); + exportSymbol = resolveName(node.parent, node.escapedText, SymbolFlags.Value | SymbolFlags.Type | SymbolFlags.Namespace | SymbolFlags.Alias, Diagnostics.Cannot_find_name_0, node, /*isUse*/ false); } else if (node.parent.kind === SyntaxKind.ExportSpecifier) { exportSymbol = getTargetOfExportSpecifier(node.parent, SymbolFlags.Value | SymbolFlags.Type | SymbolFlags.Namespace | SymbolFlags.Alias); @@ -3993,7 +3999,7 @@ namespace ts { const internalModuleReference = (declaration).moduleReference; const firstIdentifier = getFirstIdentifier(internalModuleReference); const importSymbol = resolveName(declaration, firstIdentifier.escapedText, SymbolFlags.Value | SymbolFlags.Type | SymbolFlags.Namespace, - undefined, undefined); + undefined, undefined, /*isUse*/ false); if (importSymbol) { buildVisibleNodeList(importSymbol.declarations); } @@ -6408,7 +6414,7 @@ namespace ts { let paramSymbol = param.symbol; // Include parameter symbol instead of property symbol in the signature if (paramSymbol && !!(paramSymbol.flags & SymbolFlags.Property) && !isBindingPattern(param.name)) { - const resolvedSymbol = resolveName(param, paramSymbol.escapedName, SymbolFlags.Value, undefined, undefined); + const resolvedSymbol = resolveName(param, paramSymbol.escapedName, SymbolFlags.Value, undefined, undefined, /*isUse*/ false); paramSymbol = resolvedSymbol; } if (i === 0 && paramSymbol.escapedName === "this") { @@ -7085,7 +7091,8 @@ namespace ts { } function getGlobalSymbol(name: __String, meaning: SymbolFlags, diagnostic: DiagnosticMessage): Symbol { - return resolveName(undefined, name, meaning, diagnostic, name); + // Don't track references for global symbols anyway, so value if `isReference` is arbitrary + return resolveName(undefined, name, meaning, diagnostic, name, /*isUse*/ false); } function getGlobalType(name: __String, arity: 0, reportErrors: boolean): ObjectType; @@ -10832,7 +10839,15 @@ namespace ts { function getResolvedSymbol(node: Identifier): Symbol { const links = getNodeLinks(node); if (!links.resolvedSymbol) { - links.resolvedSymbol = !nodeIsMissing(node) && resolveName(node, node.escapedText, SymbolFlags.Value | SymbolFlags.ExportValue, Diagnostics.Cannot_find_name_0, node, Diagnostics.Cannot_find_name_0_Did_you_mean_1) || unknownSymbol; + links.resolvedSymbol = !nodeIsMissing(node) && + resolveName( + node, + node.escapedText, + SymbolFlags.Value | SymbolFlags.ExportValue, + Diagnostics.Cannot_find_name_0, + node, + !isWriteOnlyAccess(node), + Diagnostics.Cannot_find_name_0_Did_you_mean_1) || unknownSymbol; } return links.resolvedSymbol; } @@ -14428,7 +14443,7 @@ namespace ts { // And if there is no reactNamespace/jsxFactory's symbol in scope when targeting React emit, we should issue an error. const reactRefErr = diagnostics && compilerOptions.jsx === JsxEmit.React ? Diagnostics.Cannot_find_name_0 : undefined; const reactNamespace = getJsxNamespace(); - const reactSym = resolveName(node.tagName, reactNamespace, SymbolFlags.Value, reactRefErr, reactNamespace); + const reactSym = resolveName(node.tagName, reactNamespace, SymbolFlags.Value, reactRefErr, reactNamespace, /*isUse*/ true); if (reactSym) { // Mark local symbol as referenced here because it might not have been marked // if jsx emit was not react as there wont be error being emitted @@ -14704,7 +14719,7 @@ namespace ts { checkPropertyNotUsedBeforeDeclaration(prop, node, right); - markPropertyAsReferenced(prop); + markPropertyAsReferenced(prop, node); getNodeLinks(node).resolvedSymbol = prop; @@ -14804,7 +14819,7 @@ namespace ts { } function getSuggestionForNonexistentSymbol(location: Node, name: __String, meaning: SymbolFlags): __String { - const result = resolveNameHelper(location, name, meaning, /*nameNotFoundMessage*/ undefined, name, (symbols, name, meaning) => { + const result = resolveNameHelper(location, name, meaning, /*nameNotFoundMessage*/ undefined, name, /*isUse*/ false, (symbols, name, meaning) => { const symbol = getSymbol(symbols, name, meaning); if (symbol) { // Sometimes the symbol is found when location is a return type of a function: `typeof x` and `x` is declared in the body of the function @@ -14884,11 +14899,12 @@ namespace ts { return bestCandidate; } - function markPropertyAsReferenced(prop: Symbol) { + function markPropertyAsReferenced(prop: Symbol, nodeForCheckWriteOnly: Node | undefined) { if (prop && noUnusedIdentifiers && (prop.flags & SymbolFlags.ClassMember) && - prop.valueDeclaration && hasModifier(prop.valueDeclaration, ModifierFlags.Private)) { + prop.valueDeclaration && hasModifier(prop.valueDeclaration, ModifierFlags.Private) + && !(nodeForCheckWriteOnly && isWriteOnlyAccess(nodeForCheckWriteOnly))) { if (getCheckFlags(prop) & CheckFlags.Instantiated) { getSymbolLinks(prop).target.isReferenced = true; } @@ -15153,7 +15169,6 @@ namespace ts { let argCount: number; // Apparent number of arguments we will have in this call let typeArguments: NodeArray; // Type arguments (undefined if none) let callIsIncomplete: boolean; // In incomplete call we want to be lenient when we have too few arguments - let isDecorator: boolean; let spreadArgIndex = -1; if (isJsxOpeningLikeElement(node)) { @@ -15187,7 +15202,6 @@ namespace ts { } } else if (node.kind === SyntaxKind.Decorator) { - isDecorator = true; typeArguments = undefined; argCount = getEffectiveArgumentCount(node, /*args*/ undefined, signature); } @@ -16582,7 +16596,7 @@ namespace ts { } // Make sure require is not a local function if (!isIdentifier(node.expression)) throw Debug.fail(); - const resolvedRequire = resolveName(node.expression, node.expression.escapedText, SymbolFlags.Value, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined); + const resolvedRequire = resolveName(node.expression, node.expression.escapedText, SymbolFlags.Value, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ true); if (!resolvedRequire) { // project does not contain symbol named 'require' - assume commonjs require return true; @@ -19579,8 +19593,11 @@ namespace ts { } function markEntityNameOrEntityExpressionAsReference(typeName: EntityNameOrEntityNameExpression) { - const rootName = typeName && getFirstIdentifier(typeName); - const rootSymbol = rootName && resolveName(rootName, rootName.escapedText, (typeName.kind === SyntaxKind.Identifier ? SymbolFlags.Type : SymbolFlags.Namespace) | SymbolFlags.Alias, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined); + if (!typeName) return; + + const rootName = getFirstIdentifier(typeName); + const meaning = (typeName.kind === SyntaxKind.Identifier ? SymbolFlags.Type : SymbolFlags.Namespace) | SymbolFlags.Alias; + const rootSymbol = resolveName(rootName, rootName.escapedText, meaning, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isRefernce*/ true); if (rootSymbol && rootSymbol.flags & SymbolFlags.Alias && symbolIsValue(rootSymbol) @@ -19874,7 +19891,7 @@ namespace ts { !isParameterPropertyDeclaration(parameter) && !parameterIsThisKeyword(parameter) && !parameterNameStartsWithUnderscore(name)) { - error(name, Diagnostics._0_is_declared_but_never_used, unescapeLeadingUnderscores(local.escapedName)); + error(name, Diagnostics._0_is_declared_but_its_value_is_never_read, unescapeLeadingUnderscores(local.escapedName)); } } else if (compilerOptions.noUnusedLocals) { @@ -19903,7 +19920,7 @@ namespace ts { } if (!isRemovedPropertyFromObjectSpread(node.kind === SyntaxKind.Identifier ? node.parent : node)) { - error(node, Diagnostics._0_is_declared_but_never_used, name); + error(node, Diagnostics._0_is_declared_but_its_value_is_never_read, name); } } @@ -19921,13 +19938,13 @@ namespace ts { for (const member of node.members) { if (member.kind === SyntaxKind.MethodDeclaration || member.kind === SyntaxKind.PropertyDeclaration) { if (!member.symbol.isReferenced && hasModifier(member, ModifierFlags.Private)) { - error(member.name, Diagnostics._0_is_declared_but_never_used, unescapeLeadingUnderscores(member.symbol.escapedName)); + error(member.name, Diagnostics._0_is_declared_but_its_value_is_never_read, unescapeLeadingUnderscores(member.symbol.escapedName)); } } else if (member.kind === SyntaxKind.Constructor) { for (const parameter of (member).parameters) { if (!parameter.symbol.isReferenced && hasModifier(parameter, ModifierFlags.Private)) { - error(parameter.name, Diagnostics.Property_0_is_declared_but_never_used, unescapeLeadingUnderscores(parameter.symbol.escapedName)); + error(parameter.name, Diagnostics.Property_0_is_declared_but_its_value_is_never_read, unescapeLeadingUnderscores(parameter.symbol.escapedName)); } } } @@ -19948,7 +19965,7 @@ namespace ts { } for (const typeParameter of node.typeParameters) { if (!getMergedSymbol(typeParameter.symbol).isReferenced) { - error(typeParameter.name, Diagnostics._0_is_declared_but_never_used, unescapeLeadingUnderscores(typeParameter.symbol.escapedName)); + error(typeParameter.name, Diagnostics._0_is_declared_but_its_value_is_never_read, unescapeLeadingUnderscores(typeParameter.symbol.escapedName)); } } } @@ -20179,7 +20196,7 @@ namespace ts { const symbol = getSymbolOfNode(node); if (symbol.flags & SymbolFlags.FunctionScopedVariable) { if (!isIdentifier(node.name)) throw Debug.fail(); - const localDeclarationSymbol = resolveName(node, node.name.escapedText, SymbolFlags.Variable, /*nodeNotFoundErrorMessage*/ undefined, /*nameArg*/ undefined); + const localDeclarationSymbol = resolveName(node, node.name.escapedText, SymbolFlags.Variable, /*nodeNotFoundErrorMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false); if (localDeclarationSymbol && localDeclarationSymbol !== symbol && localDeclarationSymbol.flags & SymbolFlags.BlockScopedVariable) { @@ -20234,7 +20251,7 @@ namespace ts { else if (n.kind === SyntaxKind.Identifier) { // check FunctionLikeDeclaration.locals (stores parameters\function local variable) // if it contains entry with a specified name - const symbol = resolveName(n, (n).escapedText, SymbolFlags.Value | SymbolFlags.Alias, /*nameNotFoundMessage*/undefined, /*nameArg*/undefined); + const symbol = resolveName(n, (n).escapedText, SymbolFlags.Value | SymbolFlags.Alias, /*nameNotFoundMessage*/undefined, /*nameArg*/undefined, /*isUse*/ false); if (!symbol || symbol === unknownSymbol || !symbol.valueDeclaration) { return; } @@ -20318,7 +20335,7 @@ namespace ts { const parentType = getTypeForBindingElementParent(parent); const name = node.propertyName || node.name; const property = getPropertyOfType(parentType, getTextOfPropertyName(name)); - markPropertyAsReferenced(property); + markPropertyAsReferenced(property, /*nodeForCheckWriteOnly*/ undefined); // A destructuring is never a write-only reference. if (parent.initializer && property) { checkPropertyAccessibility(parent, parent.initializer, parentType, property); } @@ -22254,7 +22271,7 @@ namespace ts { const exportedName = node.propertyName || node.name; // find immediate value referenced by exported name (SymbolFlags.Alias is set so we don't chase down aliases) const symbol = resolveName(exportedName, exportedName.escapedText, SymbolFlags.Value | SymbolFlags.Type | SymbolFlags.Namespace | SymbolFlags.Alias, - /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined); + /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ true); if (symbol && (symbol === undefinedSymbol || isGlobalSourceFile(getDeclarationContainer(symbol.declarations[0])))) { error(exportedName, Diagnostics.Cannot_export_0_Only_local_declarations_can_be_exported_from_a_module, unescapeLeadingUnderscores(exportedName.escapedText)); } @@ -23359,7 +23376,7 @@ namespace ts { const container = getEnclosingBlockScopeContainer(symbol.valueDeclaration); if (isStatementWithLocals(container)) { const nodeLinks = getNodeLinks(symbol.valueDeclaration); - if (!!resolveName(container.parent, symbol.escapedName, SymbolFlags.Value, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined)) { + if (resolveName(container.parent, symbol.escapedName, SymbolFlags.Value, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false)) { // redeclaration - always should be renamed links.isDeclarationWithCollidingName = true; } @@ -23669,7 +23686,7 @@ namespace ts { } } - return resolveName(location, reference.escapedText, SymbolFlags.Value | SymbolFlags.ExportValue | SymbolFlags.Alias, /*nodeNotFoundMessage*/ undefined, /*nameArg*/ undefined); + return resolveName(location, reference.escapedText, SymbolFlags.Value | SymbolFlags.ExportValue | SymbolFlags.Alias, /*nodeNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ true); } function getReferencedValueDeclaration(reference: Identifier): Declaration { @@ -23992,7 +24009,7 @@ namespace ts { return quickResult; } - let lastStatic: Node, lastPrivate: Node, lastProtected: Node, lastDeclare: Node, lastAsync: Node, lastReadonly: Node; + let lastStatic: Node, lastDeclare: Node, lastAsync: Node, lastReadonly: Node; let flags = ModifierFlags.None; for (const modifier of node.modifiers) { if (modifier.kind !== SyntaxKind.ReadonlyKeyword) { @@ -24014,13 +24031,6 @@ namespace ts { case SyntaxKind.PrivateKeyword: const text = visibilityToString(modifierToFlag(modifier.kind)); - if (modifier.kind === SyntaxKind.ProtectedKeyword) { - lastProtected = modifier; - } - else if (modifier.kind === SyntaxKind.PrivateKeyword) { - lastPrivate = modifier; - } - if (flags & ModifierFlags.AccessibilityModifier) { return grammarErrorOnNode(modifier, Diagnostics.Accessibility_modifier_already_seen); } diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index 9c0b549da50..af7f6d6c949 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -3102,7 +3102,7 @@ "category": "Message", "code": 6132 }, - "'{0}' is declared but never used.": { + "'{0}' is declared but its value is never read.": { "category": "Error", "code": 6133 }, @@ -3122,7 +3122,7 @@ "category": "Error", "code": 6137 }, - "Property '{0}' is declared but never used.": { + "Property '{0}' is declared but its value is never read.": { "category": "Error", "code": 6138 }, diff --git a/src/compiler/transformers/es2017.ts b/src/compiler/transformers/es2017.ts index 85a44e35983..90c9063c140 100644 --- a/src/compiler/transformers/es2017.ts +++ b/src/compiler/transformers/es2017.ts @@ -21,9 +21,6 @@ namespace ts { const compilerOptions = context.getCompilerOptions(); const languageVersion = getEmitScriptTarget(compilerOptions); - // These variables contain state that changes as we descend into the tree. - let currentSourceFile: SourceFile; - /** * Keeps track of whether expression substitution has been enabled for specific edge cases. * They are persisted between each SourceFile transformation and should not be reset. @@ -51,12 +48,8 @@ namespace ts { return node; } - currentSourceFile = node; - const visited = visitEachChild(node, visitor, context); addEmitHelpers(visited, context.readEmitHelpers()); - - currentSourceFile = undefined; return visited; } diff --git a/src/compiler/transformers/generators.ts b/src/compiler/transformers/generators.ts index 20195adeef4..06ecae3a63f 100644 --- a/src/compiler/transformers/generators.ts +++ b/src/compiler/transformers/generators.ts @@ -244,7 +244,6 @@ namespace ts { const previousOnSubstituteNode = context.onSubstituteNode; context.onSubstituteNode = onSubstituteNode; - let currentSourceFile: SourceFile; let renamedCatchVariables: Map; let renamedCatchVariableDeclarations: Identifier[]; @@ -300,12 +299,9 @@ namespace ts { return node; } - currentSourceFile = node; const visited = visitEachChild(node, visitor, context); addEmitHelpers(visited, context.readEmitHelpers()); - - currentSourceFile = undefined; return visited; } diff --git a/src/compiler/tsc.ts b/src/compiler/tsc.ts index d5e584c7ac5..b109b166f5c 100644 --- a/src/compiler/tsc.ts +++ b/src/compiler/tsc.ts @@ -100,7 +100,6 @@ namespace ts { const commandLine = parseCommandLine(args); let configFileName: string; // Configuration file name (if any) let cachedConfigFileText: string; // Cached configuration file text, used for reparsing (if any) - let configFileWatcher: FileWatcher; // Configuration file watcher let directoryWatcher: FileWatcher; // Directory watcher to monitor source file addition/removal let cachedProgram: Program; // Program cached from last compilation let rootFileNames: string[]; // Root fileNames for compilation @@ -189,7 +188,7 @@ namespace ts { return sys.exit(ExitStatus.DiagnosticsPresent_OutputsSkipped); } if (configFileName) { - configFileWatcher = sys.watchFile(configFileName, configFileChanged); + sys.watchFile(configFileName, configFileChanged); } if (sys.watchDirectory && configFileName) { const directory = ts.getDirectoryPath(configFileName); diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index 31e03672281..64d5bcaac62 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -3502,6 +3502,46 @@ namespace ts { export function getCombinedLocalAndExportSymbolFlags(symbol: Symbol): SymbolFlags { return symbol.exportSymbol ? symbol.exportSymbol.flags | symbol.flags : symbol.flags; } + + export function isWriteOnlyAccess(node: Node) { + return accessKind(node) === AccessKind.Write; + } + + export function isWriteAccess(node: Node) { + return accessKind(node) !== AccessKind.Read; + } + + const enum AccessKind { + /** Only reads from a variable. */ + Read, + /** Only writes to a variable without using the result. E.g.: `x++;`. */ + Write, + /** Writes to a variable and uses the result as an expression. E.g.: `f(x++);`. */ + ReadWrite + } + function accessKind(node: Node): AccessKind { + const { parent } = node; + if (!parent) return AccessKind.Read; + + switch (parent.kind) { + case SyntaxKind.PostfixUnaryExpression: + case SyntaxKind.PrefixUnaryExpression: + const { operator } = parent as PrefixUnaryExpression | PostfixUnaryExpression; + return operator === SyntaxKind.PlusPlusToken || operator === SyntaxKind.MinusMinusToken ? writeOrReadWrite() : AccessKind.Read; + case SyntaxKind.BinaryExpression: + const { left, operatorToken } = parent as BinaryExpression; + return left === node && isAssignmentOperator(operatorToken.kind) ? writeOrReadWrite() : AccessKind.Read; + case SyntaxKind.PropertyAccessExpression: + return (parent as PropertyAccessExpression).name !== node ? AccessKind.Read : accessKind(parent); + default: + return AccessKind.Read; + } + + function writeOrReadWrite(): AccessKind { + // If grandparent is not an ExpressionStatement, this is used as an expression in addition to having a side effect. + return parent.parent && parent.parent.kind === SyntaxKind.ExpressionStatement ? AccessKind.Write : AccessKind.ReadWrite; + } + } } namespace ts { diff --git a/src/harness/compilerRunner.ts b/src/harness/compilerRunner.ts index a600c7dd857..dc3aa64c6ac 100644 --- a/src/harness/compilerRunner.ts +++ b/src/harness/compilerRunner.ts @@ -11,19 +11,13 @@ const enum CompilerTestType { class CompilerBaselineRunner extends RunnerBase { private basePath = "tests/cases"; private testSuiteName: TestRunnerKind; - private errors: boolean; private emit: boolean; - private decl: boolean; - private output: boolean; public options: string; constructor(public testType: CompilerTestType) { super(); - this.errors = true; this.emit = true; - this.decl = true; - this.output = true; if (testType === CompilerTestType.Conformance) { this.testSuiteName = "conformance"; } @@ -214,26 +208,14 @@ class CompilerBaselineRunner extends RunnerBase { private parseOptions() { if (this.options && this.options.length > 0) { - this.errors = false; this.emit = false; - this.decl = false; - this.output = false; const opts = this.options.split(","); for (let i = 0; i < opts.length; i++) { switch (opts[i]) { - case "error": - this.errors = true; - break; case "emit": this.emit = true; break; - case "decl": - this.decl = true; - break; - case "output": - this.output = true; - break; default: throw new Error("unsupported flag"); } diff --git a/src/harness/unittests/compileOnSave.ts b/src/harness/unittests/compileOnSave.ts index e4b84e848c6..1545390de8d 100644 --- a/src/harness/unittests/compileOnSave.ts +++ b/src/harness/unittests/compileOnSave.ts @@ -55,7 +55,6 @@ namespace ts.projectSystem { let configFile: FileOrFolder; let changeModuleFile1ShapeRequest1: server.protocol.Request; let changeModuleFile1InternalRequest1: server.protocol.Request; - let changeModuleFile1ShapeRequest2: server.protocol.Request; // A compile on save affected file request using file1 let moduleFile1FileListRequest: server.protocol.Request; @@ -112,16 +111,6 @@ namespace ts.projectSystem { insertString: `var T1: number;` }); - // Change the content of file1 to `export var T: number;export function Foo() { };` - changeModuleFile1ShapeRequest2 = makeSessionRequest(CommandNames.Change, { - file: moduleFile1.path, - line: 1, - offset: 1, - endLine: 1, - endOffset: 1, - insertString: `export var T2: number;` - }); - moduleFile1FileListRequest = makeSessionRequest(CommandNames.CompileOnSaveAffectedFileList, { file: moduleFile1.path, projectFileName: configFile.path }); }); diff --git a/src/harness/unittests/typingsInstaller.ts b/src/harness/unittests/typingsInstaller.ts index de8ceb7f984..df0c1dd9095 100644 --- a/src/harness/unittests/typingsInstaller.ts +++ b/src/harness/unittests/typingsInstaller.ts @@ -366,13 +366,11 @@ namespace ts.projectSystem { }; const host = createServerHost([file1, file2]); - let enqueueIsCalled = false; const installer = new (class extends Installer { constructor() { super(host, { typesRegistry: createTypesRegistry("jquery") }); } enqueueInstallTypingsRequest(project: server.Project, typeAcquisition: TypeAcquisition, unresolvedImports: server.SortedReadonlyArray) { - enqueueIsCalled = true; super.enqueueInstallTypingsRequest(project, typeAcquisition, unresolvedImports); } installWorker(_requestId: number, _args: string[], _cwd: string, cb: TI.RequestCompletedAction): void { diff --git a/src/server/server.ts b/src/server/server.ts index 6b6535c8cac..f031d5f0cfc 100644 --- a/src/server/server.ts +++ b/src/server/server.ts @@ -585,7 +585,6 @@ namespace ts.server { function createPollingWatchedFileSet(interval = 2500, chunkSize = 30) { const watchedFiles: WatchedFile[] = []; let nextFileToCheck = 0; - let watchTimer: any; return { getModifiedTime, poll, startWatchTimer, addFile, removeFile }; function getModifiedTime(fileName: string): Date { @@ -622,7 +621,7 @@ namespace ts.server { // stat due to inconsistencies of fs.watch // and efficiency of stat on modern filesystems function startWatchTimer() { - watchTimer = setInterval(() => { + setInterval(() => { let count = 0; let nextToCheck = nextFileToCheck; let firstCheck = -1; diff --git a/src/services/codefixes/fixUnusedIdentifier.ts b/src/services/codefixes/fixUnusedIdentifier.ts index 530a4543ec4..090aefbb8ca 100644 --- a/src/services/codefixes/fixUnusedIdentifier.ts +++ b/src/services/codefixes/fixUnusedIdentifier.ts @@ -2,8 +2,8 @@ namespace ts.codefix { registerCodeFix({ errorCodes: [ - Diagnostics._0_is_declared_but_never_used.code, - Diagnostics.Property_0_is_declared_but_never_used.code + Diagnostics._0_is_declared_but_its_value_is_never_read.code, + Diagnostics.Property_0_is_declared_but_its_value_is_never_read.code ], getCodeActions: (context: CodeFixContext) => { const sourceFile = context.sourceFile; diff --git a/src/services/findAllReferences.ts b/src/services/findAllReferences.ts index b12b0f85fda..80194c5649b 100644 --- a/src/services/findAllReferences.ts +++ b/src/services/findAllReferences.ts @@ -175,7 +175,7 @@ namespace ts.FindAllReferences { return { fileName: node.getSourceFile().fileName, textSpan: getTextSpan(node), - isWriteAccess: isWriteAccess(node), + isWriteAccess: isWriteAccessForReference(node), isDefinition: node.kind === SyntaxKind.DefaultKeyword || isAnyDeclarationName(node) || isLiteralComputedPropertyDeclarationName(node), @@ -224,7 +224,7 @@ namespace ts.FindAllReferences { const { node, isInString } = entry; const fileName = entry.node.getSourceFile().fileName; - const writeAccess = isWriteAccess(node); + const writeAccess = isWriteAccessForReference(node); const span: HighlightSpan = { textSpan: getTextSpan(node), kind: writeAccess ? HighlightSpanKind.writtenReference : HighlightSpanKind.reference, @@ -244,21 +244,8 @@ namespace ts.FindAllReferences { } /** A node is considered a writeAccess iff it is a name of a declaration or a target of an assignment */ - function isWriteAccess(node: Node): boolean { - if (node.kind === SyntaxKind.DefaultKeyword || isAnyDeclarationName(node)) { - return true; - } - - const { parent } = node; - switch (parent && parent.kind) { - case SyntaxKind.PostfixUnaryExpression: - case SyntaxKind.PrefixUnaryExpression: - return true; - case SyntaxKind.BinaryExpression: - return (parent).left === node && isAssignmentOperator((parent).operatorToken.kind); - default: - return false; - } + function isWriteAccessForReference(node: Node): boolean { + return node.kind === SyntaxKind.DefaultKeyword || isAnyDeclarationName(node) || isWriteAccess(node); } } diff --git a/src/services/preProcess.ts b/src/services/preProcess.ts index 106759a3a28..8f6a468be64 100644 --- a/src/services/preProcess.ts +++ b/src/services/preProcess.ts @@ -273,13 +273,11 @@ namespace ts { // skip open bracket token = nextToken(); - let i = 0; // scan until ']' or EOF while (token !== SyntaxKind.CloseBracketToken && token !== SyntaxKind.EndOfFileToken) { // record string literals as module names if (token === SyntaxKind.StringLiteral) { recordModuleName(); - i++; } token = nextToken(); diff --git a/tests/baselines/reference/extendsUntypedModule.errors.txt b/tests/baselines/reference/extendsUntypedModule.errors.txt index 4667f16b74a..8df9e8a1c36 100644 --- a/tests/baselines/reference/extendsUntypedModule.errors.txt +++ b/tests/baselines/reference/extendsUntypedModule.errors.txt @@ -1,11 +1,11 @@ -/a.ts(2,8): error TS6133: 'Bar' is declared but never used. +/a.ts(2,8): error TS6133: 'Bar' is declared but its value is never read. ==== /a.ts (1 errors) ==== import Foo from "foo"; import Bar from "bar"; // error: unused ~~~ -!!! error TS6133: 'Bar' is declared but never used. +!!! error TS6133: 'Bar' is declared but its value is never read. export class A extends Foo { } ==== /node_modules/foo/index.js (0 errors) ==== diff --git a/tests/baselines/reference/noUnusedLocals_selfReference.errors.txt b/tests/baselines/reference/noUnusedLocals_selfReference.errors.txt index af40081e71c..e4a0d478cb4 100644 --- a/tests/baselines/reference/noUnusedLocals_selfReference.errors.txt +++ b/tests/baselines/reference/noUnusedLocals_selfReference.errors.txt @@ -1,6 +1,6 @@ -tests/cases/compiler/noUnusedLocals_selfReference.ts(3,10): error TS6133: 'f' is declared but never used. -tests/cases/compiler/noUnusedLocals_selfReference.ts(4,7): error TS6133: 'C' is declared but never used. -tests/cases/compiler/noUnusedLocals_selfReference.ts(7,6): error TS6133: 'E' is declared but never used. +tests/cases/compiler/noUnusedLocals_selfReference.ts(3,10): error TS6133: 'f' is declared but its value is never read. +tests/cases/compiler/noUnusedLocals_selfReference.ts(4,7): error TS6133: 'C' is declared but its value is never read. +tests/cases/compiler/noUnusedLocals_selfReference.ts(7,6): error TS6133: 'E' is declared but its value is never read. ==== tests/cases/compiler/noUnusedLocals_selfReference.ts (3 errors) ==== @@ -8,15 +8,15 @@ tests/cases/compiler/noUnusedLocals_selfReference.ts(7,6): error TS6133: 'E' is function f() { f; } ~ -!!! error TS6133: 'f' is declared but never used. +!!! error TS6133: 'f' is declared but its value is never read. class C { ~ -!!! error TS6133: 'C' is declared but never used. +!!! error TS6133: 'C' is declared but its value is never read. m() { C; } } enum E { A = 0, B = E.A } ~ -!!! error TS6133: 'E' is declared but never used. +!!! error TS6133: 'E' is declared but its value is never read. // Does not detect mutual recursion. function g() { D; } diff --git a/tests/baselines/reference/noUnusedLocals_writeOnly.errors.txt b/tests/baselines/reference/noUnusedLocals_writeOnly.errors.txt new file mode 100644 index 00000000000..355bec02eb9 --- /dev/null +++ b/tests/baselines/reference/noUnusedLocals_writeOnly.errors.txt @@ -0,0 +1,16 @@ +tests/cases/compiler/noUnusedLocals_writeOnly.ts(1,12): error TS6133: 'x' is declared but its value is never read. + + +==== tests/cases/compiler/noUnusedLocals_writeOnly.ts (1 errors) ==== + function f(x = 0) { + ~ +!!! error TS6133: 'x' is declared but its value is never read. + x = 1; + x++; + x /= 2; + + let y = 0; + // This is a write access to y, but not a write-*only* access. + f(y++); + } + \ No newline at end of file diff --git a/tests/baselines/reference/noUnusedLocals_writeOnly.js b/tests/baselines/reference/noUnusedLocals_writeOnly.js new file mode 100644 index 00000000000..40529f690cd --- /dev/null +++ b/tests/baselines/reference/noUnusedLocals_writeOnly.js @@ -0,0 +1,22 @@ +//// [noUnusedLocals_writeOnly.ts] +function f(x = 0) { + x = 1; + x++; + x /= 2; + + let y = 0; + // This is a write access to y, but not a write-*only* access. + f(y++); +} + + +//// [noUnusedLocals_writeOnly.js] +function f(x) { + if (x === void 0) { x = 0; } + x = 1; + x++; + x /= 2; + var y = 0; + // This is a write access to y, but not a write-*only* access. + f(y++); +} diff --git a/tests/baselines/reference/noUnusedLocals_writeOnlyProperty.errors.txt b/tests/baselines/reference/noUnusedLocals_writeOnlyProperty.errors.txt new file mode 100644 index 00000000000..3f947c71473 --- /dev/null +++ b/tests/baselines/reference/noUnusedLocals_writeOnlyProperty.errors.txt @@ -0,0 +1,13 @@ +tests/cases/compiler/noUnusedLocals_writeOnlyProperty.ts(2,13): error TS6133: 'x' is declared but its value is never read. + + +==== tests/cases/compiler/noUnusedLocals_writeOnlyProperty.ts (1 errors) ==== + class C { + private x; + ~ +!!! error TS6133: 'x' is declared but its value is never read. + m() { + this.x = 0; + } + } + \ No newline at end of file diff --git a/tests/baselines/reference/noUnusedLocals_writeOnlyProperty.js b/tests/baselines/reference/noUnusedLocals_writeOnlyProperty.js new file mode 100644 index 00000000000..1ac4efa8dde --- /dev/null +++ b/tests/baselines/reference/noUnusedLocals_writeOnlyProperty.js @@ -0,0 +1,18 @@ +//// [noUnusedLocals_writeOnlyProperty.ts] +class C { + private x; + m() { + this.x = 0; + } +} + + +//// [noUnusedLocals_writeOnlyProperty.js] +var C = /** @class */ (function () { + function C() { + } + C.prototype.m = function () { + this.x = 0; + }; + return C; +}()); diff --git a/tests/baselines/reference/unusedClassesinModule1.errors.txt b/tests/baselines/reference/unusedClassesinModule1.errors.txt index b3e8c3009cd..b7d0da8fc2d 100644 --- a/tests/baselines/reference/unusedClassesinModule1.errors.txt +++ b/tests/baselines/reference/unusedClassesinModule1.errors.txt @@ -1,11 +1,11 @@ -tests/cases/compiler/unusedClassesinModule1.ts(2,11): error TS6133: 'Calculator' is declared but never used. +tests/cases/compiler/unusedClassesinModule1.ts(2,11): error TS6133: 'Calculator' is declared but its value is never read. ==== tests/cases/compiler/unusedClassesinModule1.ts (1 errors) ==== module A { class Calculator { ~~~~~~~~~~ -!!! error TS6133: 'Calculator' is declared but never used. +!!! error TS6133: 'Calculator' is declared but its value is never read. public handelChar() { } } diff --git a/tests/baselines/reference/unusedClassesinNamespace1.errors.txt b/tests/baselines/reference/unusedClassesinNamespace1.errors.txt index 57f3e003242..2df9f918e7d 100644 --- a/tests/baselines/reference/unusedClassesinNamespace1.errors.txt +++ b/tests/baselines/reference/unusedClassesinNamespace1.errors.txt @@ -1,11 +1,11 @@ -tests/cases/compiler/unusedClassesinNamespace1.ts(2,11): error TS6133: 'c1' is declared but never used. +tests/cases/compiler/unusedClassesinNamespace1.ts(2,11): error TS6133: 'c1' is declared but its value is never read. ==== tests/cases/compiler/unusedClassesinNamespace1.ts (1 errors) ==== namespace Validation { class c1 { ~~ -!!! error TS6133: 'c1' is declared but never used. +!!! error TS6133: 'c1' is declared but its value is never read. } } \ No newline at end of file diff --git a/tests/baselines/reference/unusedClassesinNamespace2.errors.txt b/tests/baselines/reference/unusedClassesinNamespace2.errors.txt index e8f9c659d0d..2425ea02e51 100644 --- a/tests/baselines/reference/unusedClassesinNamespace2.errors.txt +++ b/tests/baselines/reference/unusedClassesinNamespace2.errors.txt @@ -1,11 +1,11 @@ -tests/cases/compiler/unusedClassesinNamespace2.ts(2,11): error TS6133: 'c1' is declared but never used. +tests/cases/compiler/unusedClassesinNamespace2.ts(2,11): error TS6133: 'c1' is declared but its value is never read. ==== tests/cases/compiler/unusedClassesinNamespace2.ts (1 errors) ==== namespace Validation { class c1 { ~~ -!!! error TS6133: 'c1' is declared but never used. +!!! error TS6133: 'c1' is declared but its value is never read. } diff --git a/tests/baselines/reference/unusedClassesinNamespace4.errors.txt b/tests/baselines/reference/unusedClassesinNamespace4.errors.txt index b2ddfe3f3f6..719689fbca3 100644 --- a/tests/baselines/reference/unusedClassesinNamespace4.errors.txt +++ b/tests/baselines/reference/unusedClassesinNamespace4.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/unusedClassesinNamespace4.ts(10,11): error TS6133: 'c3' is declared but never used. +tests/cases/compiler/unusedClassesinNamespace4.ts(10,11): error TS6133: 'c3' is declared but its value is never read. ==== tests/cases/compiler/unusedClassesinNamespace4.ts (1 errors) ==== @@ -13,7 +13,7 @@ tests/cases/compiler/unusedClassesinNamespace4.ts(10,11): error TS6133: 'c3' is class c3 extends c1 { ~~ -!!! error TS6133: 'c3' is declared but never used. +!!! error TS6133: 'c3' is declared but its value is never read. } } \ No newline at end of file diff --git a/tests/baselines/reference/unusedClassesinNamespace5.errors.txt b/tests/baselines/reference/unusedClassesinNamespace5.errors.txt index 29c08c9a107..7f7f5cf1b7a 100644 --- a/tests/baselines/reference/unusedClassesinNamespace5.errors.txt +++ b/tests/baselines/reference/unusedClassesinNamespace5.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/unusedClassesinNamespace5.ts(10,11): error TS6133: 'c3' is declared but never used. +tests/cases/compiler/unusedClassesinNamespace5.ts(10,11): error TS6133: 'c3' is declared but its value is never read. ==== tests/cases/compiler/unusedClassesinNamespace5.ts (1 errors) ==== @@ -13,7 +13,7 @@ tests/cases/compiler/unusedClassesinNamespace5.ts(10,11): error TS6133: 'c3' is class c3 { ~~ -!!! error TS6133: 'c3' is declared but never used. +!!! error TS6133: 'c3' is declared but its value is never read. public x: c1; } } \ No newline at end of file diff --git a/tests/baselines/reference/unusedDestructuringParameters.errors.txt b/tests/baselines/reference/unusedDestructuringParameters.errors.txt index b6814df6b7a..24a7b3838cd 100644 --- a/tests/baselines/reference/unusedDestructuringParameters.errors.txt +++ b/tests/baselines/reference/unusedDestructuringParameters.errors.txt @@ -1,15 +1,15 @@ -tests/cases/compiler/unusedDestructuringParameters.ts(1,13): error TS6133: 'a' is declared but never used. -tests/cases/compiler/unusedDestructuringParameters.ts(3,14): error TS6133: 'a' is declared but never used. +tests/cases/compiler/unusedDestructuringParameters.ts(1,13): error TS6133: 'a' is declared but its value is never read. +tests/cases/compiler/unusedDestructuringParameters.ts(3,14): error TS6133: 'a' is declared but its value is never read. ==== tests/cases/compiler/unusedDestructuringParameters.ts (2 errors) ==== const f = ([a]) => { }; ~ -!!! error TS6133: 'a' is declared but never used. +!!! error TS6133: 'a' is declared but its value is never read. f([1]); const f2 = ({a}) => { }; ~ -!!! error TS6133: 'a' is declared but never used. +!!! error TS6133: 'a' is declared but its value is never read. f2({ a: 10 }); const f3 = ([_]) => { }; f3([10]); \ No newline at end of file diff --git a/tests/baselines/reference/unusedFunctionsinNamespaces1.errors.txt b/tests/baselines/reference/unusedFunctionsinNamespaces1.errors.txt index 6d59137b4b7..202977c6fb7 100644 --- a/tests/baselines/reference/unusedFunctionsinNamespaces1.errors.txt +++ b/tests/baselines/reference/unusedFunctionsinNamespaces1.errors.txt @@ -1,10 +1,10 @@ -tests/cases/compiler/unusedFunctionsinNamespaces1.ts(2,14): error TS6133: 'function1' is declared but never used. +tests/cases/compiler/unusedFunctionsinNamespaces1.ts(2,14): error TS6133: 'function1' is declared but its value is never read. ==== tests/cases/compiler/unusedFunctionsinNamespaces1.ts (1 errors) ==== namespace Validation { function function1() { ~~~~~~~~~ -!!! error TS6133: 'function1' is declared but never used. +!!! error TS6133: 'function1' is declared but its value is never read. } } \ No newline at end of file diff --git a/tests/baselines/reference/unusedFunctionsinNamespaces2.errors.txt b/tests/baselines/reference/unusedFunctionsinNamespaces2.errors.txt index 68fffcc4f51..eec94fee215 100644 --- a/tests/baselines/reference/unusedFunctionsinNamespaces2.errors.txt +++ b/tests/baselines/reference/unusedFunctionsinNamespaces2.errors.txt @@ -1,10 +1,10 @@ -tests/cases/compiler/unusedFunctionsinNamespaces2.ts(2,9): error TS6133: 'function1' is declared but never used. +tests/cases/compiler/unusedFunctionsinNamespaces2.ts(2,9): error TS6133: 'function1' is declared but its value is never read. ==== tests/cases/compiler/unusedFunctionsinNamespaces2.ts (1 errors) ==== namespace Validation { var function1 = function() { ~~~~~~~~~ -!!! error TS6133: 'function1' is declared but never used. +!!! error TS6133: 'function1' is declared but its value is never read. } } \ No newline at end of file diff --git a/tests/baselines/reference/unusedFunctionsinNamespaces3.errors.txt b/tests/baselines/reference/unusedFunctionsinNamespaces3.errors.txt index 0046d4eb116..8761ec400b1 100644 --- a/tests/baselines/reference/unusedFunctionsinNamespaces3.errors.txt +++ b/tests/baselines/reference/unusedFunctionsinNamespaces3.errors.txt @@ -1,13 +1,13 @@ -tests/cases/compiler/unusedFunctionsinNamespaces3.ts(2,9): error TS6133: 'function1' is declared but never used. -tests/cases/compiler/unusedFunctionsinNamespaces3.ts(2,30): error TS6133: 'param1' is declared but never used. +tests/cases/compiler/unusedFunctionsinNamespaces3.ts(2,9): error TS6133: 'function1' is declared but its value is never read. +tests/cases/compiler/unusedFunctionsinNamespaces3.ts(2,30): error TS6133: 'param1' is declared but its value is never read. ==== tests/cases/compiler/unusedFunctionsinNamespaces3.ts (2 errors) ==== namespace Validation { var function1 = function(param1:string) { ~~~~~~~~~ -!!! error TS6133: 'function1' is declared but never used. +!!! error TS6133: 'function1' is declared but its value is never read. ~~~~~~ -!!! error TS6133: 'param1' is declared but never used. +!!! error TS6133: 'param1' is declared but its value is never read. } } \ No newline at end of file diff --git a/tests/baselines/reference/unusedFunctionsinNamespaces4.errors.txt b/tests/baselines/reference/unusedFunctionsinNamespaces4.errors.txt index c012f671427..feb8f8158db 100644 --- a/tests/baselines/reference/unusedFunctionsinNamespaces4.errors.txt +++ b/tests/baselines/reference/unusedFunctionsinNamespaces4.errors.txt @@ -1,11 +1,11 @@ -tests/cases/compiler/unusedFunctionsinNamespaces4.ts(2,9): error TS6133: 'function1' is declared but never used. +tests/cases/compiler/unusedFunctionsinNamespaces4.ts(2,9): error TS6133: 'function1' is declared but its value is never read. ==== tests/cases/compiler/unusedFunctionsinNamespaces4.ts (1 errors) ==== namespace Validation { var function1 = function() { ~~~~~~~~~ -!!! error TS6133: 'function1' is declared but never used. +!!! error TS6133: 'function1' is declared but its value is never read. } export function function2() { diff --git a/tests/baselines/reference/unusedFunctionsinNamespaces5.errors.txt b/tests/baselines/reference/unusedFunctionsinNamespaces5.errors.txt index 0c7a6321922..8f7f617e559 100644 --- a/tests/baselines/reference/unusedFunctionsinNamespaces5.errors.txt +++ b/tests/baselines/reference/unusedFunctionsinNamespaces5.errors.txt @@ -1,5 +1,5 @@ -tests/cases/compiler/unusedFunctionsinNamespaces5.ts(9,14): error TS6133: 'function3' is declared but never used. -tests/cases/compiler/unusedFunctionsinNamespaces5.ts(13,14): error TS6133: 'function4' is declared but never used. +tests/cases/compiler/unusedFunctionsinNamespaces5.ts(9,14): error TS6133: 'function3' is declared but its value is never read. +tests/cases/compiler/unusedFunctionsinNamespaces5.ts(13,14): error TS6133: 'function4' is declared but its value is never read. ==== tests/cases/compiler/unusedFunctionsinNamespaces5.ts (2 errors) ==== @@ -13,13 +13,13 @@ tests/cases/compiler/unusedFunctionsinNamespaces5.ts(13,14): error TS6133: 'func function function3() { ~~~~~~~~~ -!!! error TS6133: 'function3' is declared but never used. +!!! error TS6133: 'function3' is declared but its value is never read. function1(); } function function4() { ~~~~~~~~~ -!!! error TS6133: 'function4' is declared but never used. +!!! error TS6133: 'function4' is declared but its value is never read. } } \ No newline at end of file diff --git a/tests/baselines/reference/unusedFunctionsinNamespaces6.errors.txt b/tests/baselines/reference/unusedFunctionsinNamespaces6.errors.txt index a3ab17655b2..de5f7ae4d87 100644 --- a/tests/baselines/reference/unusedFunctionsinNamespaces6.errors.txt +++ b/tests/baselines/reference/unusedFunctionsinNamespaces6.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/unusedFunctionsinNamespaces6.ts(13,14): error TS6133: 'function4' is declared but never used. +tests/cases/compiler/unusedFunctionsinNamespaces6.ts(13,14): error TS6133: 'function4' is declared but its value is never read. ==== tests/cases/compiler/unusedFunctionsinNamespaces6.ts (1 errors) ==== @@ -16,7 +16,7 @@ tests/cases/compiler/unusedFunctionsinNamespaces6.ts(13,14): error TS6133: 'func function function4() { ~~~~~~~~~ -!!! error TS6133: 'function4' is declared but never used. +!!! error TS6133: 'function4' is declared but its value is never read. } diff --git a/tests/baselines/reference/unusedIdentifiersConsolidated1.errors.txt b/tests/baselines/reference/unusedIdentifiersConsolidated1.errors.txt index 51db8356293..c327dc4b19b 100644 --- a/tests/baselines/reference/unusedIdentifiersConsolidated1.errors.txt +++ b/tests/baselines/reference/unusedIdentifiersConsolidated1.errors.txt @@ -1,55 +1,58 @@ -tests/cases/compiler/unusedIdentifiersConsolidated1.ts(1,18): error TS6133: 'person' is declared but never used. -tests/cases/compiler/unusedIdentifiersConsolidated1.ts(2,9): error TS6133: 'unused' is declared but never used. -tests/cases/compiler/unusedIdentifiersConsolidated1.ts(5,32): error TS6133: 'unusedtypeparameter' is declared but never used. -tests/cases/compiler/unusedIdentifiersConsolidated1.ts(6,13): error TS6133: 'unusedprivatevariable' is declared but never used. -tests/cases/compiler/unusedIdentifiersConsolidated1.ts(11,17): error TS6133: 'message' is declared but never used. -tests/cases/compiler/unusedIdentifiersConsolidated1.ts(12,13): error TS6133: 'unused2' is declared but never used. -tests/cases/compiler/unusedIdentifiersConsolidated1.ts(16,20): error TS6133: 'person' is declared but never used. -tests/cases/compiler/unusedIdentifiersConsolidated1.ts(17,13): error TS6133: 'unused' is declared but never used. -tests/cases/compiler/unusedIdentifiersConsolidated1.ts(24,13): error TS6133: 'unUsedPrivateFunction' is declared but never used. -tests/cases/compiler/unusedIdentifiersConsolidated1.ts(37,11): error TS6133: 'numberRegexp' is declared but never used. -tests/cases/compiler/unusedIdentifiersConsolidated1.ts(44,17): error TS6133: 'unUsedPrivateFunction' is declared but never used. -tests/cases/compiler/unusedIdentifiersConsolidated1.ts(57,15): error TS6133: 'usedLocallyInterface2' is declared but never used. -tests/cases/compiler/unusedIdentifiersConsolidated1.ts(64,11): error TS6133: 'dummy' is declared but never used. -tests/cases/compiler/unusedIdentifiersConsolidated1.ts(67,15): error TS6133: 'unusedInterface' is declared but never used. -tests/cases/compiler/unusedIdentifiersConsolidated1.ts(79,11): error TS6133: 'class3' is declared but never used. -tests/cases/compiler/unusedIdentifiersConsolidated1.ts(99,15): error TS6133: 'interface5' is declared but never used. +tests/cases/compiler/unusedIdentifiersConsolidated1.ts(1,18): error TS6133: 'person' is declared but its value is never read. +tests/cases/compiler/unusedIdentifiersConsolidated1.ts(2,9): error TS6133: 'unused' is declared but its value is never read. +tests/cases/compiler/unusedIdentifiersConsolidated1.ts(5,32): error TS6133: 'unusedtypeparameter' is declared but its value is never read. +tests/cases/compiler/unusedIdentifiersConsolidated1.ts(6,13): error TS6133: 'unusedprivatevariable' is declared but its value is never read. +tests/cases/compiler/unusedIdentifiersConsolidated1.ts(7,13): error TS6133: 'greeting' is declared but its value is never read. +tests/cases/compiler/unusedIdentifiersConsolidated1.ts(11,17): error TS6133: 'message' is declared but its value is never read. +tests/cases/compiler/unusedIdentifiersConsolidated1.ts(12,13): error TS6133: 'unused2' is declared but its value is never read. +tests/cases/compiler/unusedIdentifiersConsolidated1.ts(16,20): error TS6133: 'person' is declared but its value is never read. +tests/cases/compiler/unusedIdentifiersConsolidated1.ts(17,13): error TS6133: 'unused' is declared but its value is never read. +tests/cases/compiler/unusedIdentifiersConsolidated1.ts(24,13): error TS6133: 'unUsedPrivateFunction' is declared but its value is never read. +tests/cases/compiler/unusedIdentifiersConsolidated1.ts(37,11): error TS6133: 'numberRegexp' is declared but its value is never read. +tests/cases/compiler/unusedIdentifiersConsolidated1.ts(44,17): error TS6133: 'unUsedPrivateFunction' is declared but its value is never read. +tests/cases/compiler/unusedIdentifiersConsolidated1.ts(57,15): error TS6133: 'usedLocallyInterface2' is declared but its value is never read. +tests/cases/compiler/unusedIdentifiersConsolidated1.ts(64,11): error TS6133: 'dummy' is declared but its value is never read. +tests/cases/compiler/unusedIdentifiersConsolidated1.ts(67,15): error TS6133: 'unusedInterface' is declared but its value is never read. +tests/cases/compiler/unusedIdentifiersConsolidated1.ts(79,11): error TS6133: 'class3' is declared but its value is never read. +tests/cases/compiler/unusedIdentifiersConsolidated1.ts(99,15): error TS6133: 'interface5' is declared but its value is never read. -==== tests/cases/compiler/unusedIdentifiersConsolidated1.ts (16 errors) ==== +==== tests/cases/compiler/unusedIdentifiersConsolidated1.ts (17 errors) ==== function greeter(person: string) { ~~~~~~ -!!! error TS6133: 'person' is declared but never used. +!!! error TS6133: 'person' is declared but its value is never read. var unused = 20; ~~~~~~ -!!! error TS6133: 'unused' is declared but never used. +!!! error TS6133: 'unused' is declared but its value is never read. } class Dummy { ~~~~~~~~~~~~~~~~~~~ -!!! error TS6133: 'unusedtypeparameter' is declared but never used. +!!! error TS6133: 'unusedtypeparameter' is declared but its value is never read. private unusedprivatevariable: string; ~~~~~~~~~~~~~~~~~~~~~ -!!! error TS6133: 'unusedprivatevariable' is declared but never used. +!!! error TS6133: 'unusedprivatevariable' is declared but its value is never read. private greeting: string; + ~~~~~~~~ +!!! error TS6133: 'greeting' is declared but its value is never read. public unusedpublicvariable: string; public typedvariable: usedtypeparameter; constructor(message: string) { ~~~~~~~ -!!! error TS6133: 'message' is declared but never used. +!!! error TS6133: 'message' is declared but its value is never read. var unused2 = 22; ~~~~~~~ -!!! error TS6133: 'unused2' is declared but never used. +!!! error TS6133: 'unused2' is declared but its value is never read. this.greeting = "Dummy Message"; } public greeter(person: string) { ~~~~~~ -!!! error TS6133: 'person' is declared but never used. +!!! error TS6133: 'person' is declared but its value is never read. var unused = 20; ~~~~~~ -!!! error TS6133: 'unused' is declared but never used. +!!! error TS6133: 'unused' is declared but its value is never read. this.usedPrivateFunction(); } @@ -58,7 +61,7 @@ tests/cases/compiler/unusedIdentifiersConsolidated1.ts(99,15): error TS6133: 'in private unUsedPrivateFunction() { ~~~~~~~~~~~~~~~~~~~~~ -!!! error TS6133: 'unUsedPrivateFunction' is declared but never used. +!!! error TS6133: 'unUsedPrivateFunction' is declared but its value is never read. } } @@ -73,7 +76,7 @@ tests/cases/compiler/unusedIdentifiersConsolidated1.ts(99,15): error TS6133: 'in const lettersRegexp = /^[A-Za-z]+$/; const numberRegexp = /^[0-9]+$/; ~~~~~~~~~~~~ -!!! error TS6133: 'numberRegexp' is declared but never used. +!!! error TS6133: 'numberRegexp' is declared but its value is never read. export class LettersOnlyValidator implements StringValidator { isAcceptable(s2: string) { @@ -82,7 +85,7 @@ tests/cases/compiler/unusedIdentifiersConsolidated1.ts(99,15): error TS6133: 'in private unUsedPrivateFunction() { ~~~~~~~~~~~~~~~~~~~~~ -!!! error TS6133: 'unUsedPrivateFunction' is declared but never used. +!!! error TS6133: 'unUsedPrivateFunction' is declared but its value is never read. } } @@ -97,7 +100,7 @@ tests/cases/compiler/unusedIdentifiersConsolidated1.ts(99,15): error TS6133: 'in interface usedLocallyInterface2 { ~~~~~~~~~~~~~~~~~~~~~ -!!! error TS6133: 'usedLocallyInterface2' is declared but never used. +!!! error TS6133: 'usedLocallyInterface2' is declared but its value is never read. someFunction(s1: string): void; } @@ -106,12 +109,12 @@ tests/cases/compiler/unusedIdentifiersConsolidated1.ts(99,15): error TS6133: 'in class dummy implements usedLocallyInterface { ~~~~~ -!!! error TS6133: 'dummy' is declared but never used. +!!! error TS6133: 'dummy' is declared but its value is never read. } interface unusedInterface { ~~~~~~~~~~~~~~~ -!!! error TS6133: 'unusedInterface' is declared but never used. +!!! error TS6133: 'unusedInterface' is declared but its value is never read. } } @@ -125,7 +128,7 @@ tests/cases/compiler/unusedIdentifiersConsolidated1.ts(99,15): error TS6133: 'in class class3 { ~~~~~~ -!!! error TS6133: 'class3' is declared but never used. +!!! error TS6133: 'class3' is declared but its value is never read. } export class class4 { @@ -147,6 +150,6 @@ tests/cases/compiler/unusedIdentifiersConsolidated1.ts(99,15): error TS6133: 'in interface interface5 { ~~~~~~~~~~ -!!! error TS6133: 'interface5' is declared but never used. +!!! error TS6133: 'interface5' is declared but its value is never read. } } \ No newline at end of file diff --git a/tests/baselines/reference/unusedImports1.errors.txt b/tests/baselines/reference/unusedImports1.errors.txt index ad5d52a861e..36963513146 100644 --- a/tests/baselines/reference/unusedImports1.errors.txt +++ b/tests/baselines/reference/unusedImports1.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/file2.ts(1,9): error TS6133: 'Calculator' is declared but never used. +tests/cases/compiler/file2.ts(1,9): error TS6133: 'Calculator' is declared but its value is never read. ==== tests/cases/compiler/file1.ts (0 errors) ==== @@ -9,4 +9,4 @@ tests/cases/compiler/file2.ts(1,9): error TS6133: 'Calculator' is declared but n ==== tests/cases/compiler/file2.ts (1 errors) ==== import {Calculator} from "./file1" ~~~~~~~~~~ -!!! error TS6133: 'Calculator' is declared but never used. \ No newline at end of file +!!! error TS6133: 'Calculator' is declared but its value is never read. \ No newline at end of file diff --git a/tests/baselines/reference/unusedImports10.errors.txt b/tests/baselines/reference/unusedImports10.errors.txt index 916f9f8e46d..b9688a01185 100644 --- a/tests/baselines/reference/unusedImports10.errors.txt +++ b/tests/baselines/reference/unusedImports10.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/unusedImports10.ts(9,12): error TS6133: 'a' is declared but never used. +tests/cases/compiler/unusedImports10.ts(9,12): error TS6133: 'a' is declared but its value is never read. ==== tests/cases/compiler/unusedImports10.ts (1 errors) ==== @@ -12,5 +12,5 @@ tests/cases/compiler/unusedImports10.ts(9,12): error TS6133: 'a' is declared but module B { import a = A; ~ -!!! error TS6133: 'a' is declared but never used. +!!! error TS6133: 'a' is declared but its value is never read. } \ No newline at end of file diff --git a/tests/baselines/reference/unusedImports12.errors.txt b/tests/baselines/reference/unusedImports12.errors.txt index 7c4e581bf2f..56df4edc5e3 100644 --- a/tests/baselines/reference/unusedImports12.errors.txt +++ b/tests/baselines/reference/unusedImports12.errors.txt @@ -1,25 +1,25 @@ -tests/cases/compiler/a.ts(1,10): error TS6133: 'Member' is declared but never used. -tests/cases/compiler/a.ts(2,8): error TS6133: 'd' is declared but never used. -tests/cases/compiler/a.ts(2,23): error TS6133: 'M' is declared but never used. -tests/cases/compiler/a.ts(3,13): error TS6133: 'ns' is declared but never used. -tests/cases/compiler/a.ts(4,8): error TS6133: 'r' is declared but never used. +tests/cases/compiler/a.ts(1,10): error TS6133: 'Member' is declared but its value is never read. +tests/cases/compiler/a.ts(2,8): error TS6133: 'd' is declared but its value is never read. +tests/cases/compiler/a.ts(2,23): error TS6133: 'M' is declared but its value is never read. +tests/cases/compiler/a.ts(3,13): error TS6133: 'ns' is declared but its value is never read. +tests/cases/compiler/a.ts(4,8): error TS6133: 'r' is declared but its value is never read. ==== tests/cases/compiler/a.ts (5 errors) ==== import { Member } from './b'; ~~~~~~ -!!! error TS6133: 'Member' is declared but never used. +!!! error TS6133: 'Member' is declared but its value is never read. import d, { Member as M } from './b'; ~ -!!! error TS6133: 'd' is declared but never used. +!!! error TS6133: 'd' is declared but its value is never read. ~ -!!! error TS6133: 'M' is declared but never used. +!!! error TS6133: 'M' is declared but its value is never read. import * as ns from './b'; ~~ -!!! error TS6133: 'ns' is declared but never used. +!!! error TS6133: 'ns' is declared but its value is never read. import r = require("./b"); ~ -!!! error TS6133: 'r' is declared but never used. +!!! error TS6133: 'r' is declared but its value is never read. ==== tests/cases/compiler/b.ts (0 errors) ==== export class Member {} diff --git a/tests/baselines/reference/unusedImports2.errors.txt b/tests/baselines/reference/unusedImports2.errors.txt index 6755a432b48..c037eea2f51 100644 --- a/tests/baselines/reference/unusedImports2.errors.txt +++ b/tests/baselines/reference/unusedImports2.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/file2.ts(2,9): error TS6133: 'test' is declared but never used. +tests/cases/compiler/file2.ts(2,9): error TS6133: 'test' is declared but its value is never read. ==== tests/cases/compiler/file1.ts (0 errors) ==== @@ -14,7 +14,7 @@ tests/cases/compiler/file2.ts(2,9): error TS6133: 'test' is declared but never u import {Calculator} from "./file1" import {test} from "./file1" ~~~~ -!!! error TS6133: 'test' is declared but never used. +!!! error TS6133: 'test' is declared but its value is never read. var x = new Calculator(); x.handleChar(); \ No newline at end of file diff --git a/tests/baselines/reference/unusedImports3.errors.txt b/tests/baselines/reference/unusedImports3.errors.txt index b63087466fe..5271d72cf77 100644 --- a/tests/baselines/reference/unusedImports3.errors.txt +++ b/tests/baselines/reference/unusedImports3.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/file2.ts(1,9): error TS6133: 'Calculator' is declared but never used. +tests/cases/compiler/file2.ts(1,9): error TS6133: 'Calculator' is declared but its value is never read. ==== tests/cases/compiler/file1.ts (0 errors) ==== @@ -17,7 +17,7 @@ tests/cases/compiler/file2.ts(1,9): error TS6133: 'Calculator' is declared but n ==== tests/cases/compiler/file2.ts (1 errors) ==== import {Calculator, test, test2} from "./file1" ~~~~~~~~~~ -!!! error TS6133: 'Calculator' is declared but never used. +!!! error TS6133: 'Calculator' is declared but its value is never read. test(); test2(); \ No newline at end of file diff --git a/tests/baselines/reference/unusedImports4.errors.txt b/tests/baselines/reference/unusedImports4.errors.txt index c57bc534137..7f475e2967e 100644 --- a/tests/baselines/reference/unusedImports4.errors.txt +++ b/tests/baselines/reference/unusedImports4.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/file2.ts(1,21): error TS6133: 'test' is declared but never used. +tests/cases/compiler/file2.ts(1,21): error TS6133: 'test' is declared but its value is never read. ==== tests/cases/compiler/file1.ts (0 errors) ==== @@ -17,7 +17,7 @@ tests/cases/compiler/file2.ts(1,21): error TS6133: 'test' is declared but never ==== tests/cases/compiler/file2.ts (1 errors) ==== import {Calculator, test, test2} from "./file1" ~~~~ -!!! error TS6133: 'test' is declared but never used. +!!! error TS6133: 'test' is declared but its value is never read. var x = new Calculator(); x.handleChar(); diff --git a/tests/baselines/reference/unusedImports5.errors.txt b/tests/baselines/reference/unusedImports5.errors.txt index 10fc097237c..4b433db9b7c 100644 --- a/tests/baselines/reference/unusedImports5.errors.txt +++ b/tests/baselines/reference/unusedImports5.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/file2.ts(1,27): error TS6133: 'test2' is declared but never used. +tests/cases/compiler/file2.ts(1,27): error TS6133: 'test2' is declared but its value is never read. ==== tests/cases/compiler/file1.ts (0 errors) ==== @@ -17,7 +17,7 @@ tests/cases/compiler/file2.ts(1,27): error TS6133: 'test2' is declared but never ==== tests/cases/compiler/file2.ts (1 errors) ==== import {Calculator, test, test2} from "./file1" ~~~~~ -!!! error TS6133: 'test2' is declared but never used. +!!! error TS6133: 'test2' is declared but its value is never read. var x = new Calculator(); x.handleChar(); diff --git a/tests/baselines/reference/unusedImports6.errors.txt b/tests/baselines/reference/unusedImports6.errors.txt index ed9b9c43ee8..28b2d1a2875 100644 --- a/tests/baselines/reference/unusedImports6.errors.txt +++ b/tests/baselines/reference/unusedImports6.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/file2.ts(1,8): error TS6133: 'd' is declared but never used. +tests/cases/compiler/file2.ts(1,8): error TS6133: 'd' is declared but its value is never read. ==== tests/cases/compiler/file1.ts (0 errors) ==== @@ -17,7 +17,7 @@ tests/cases/compiler/file2.ts(1,8): error TS6133: 'd' is declared but never used ==== tests/cases/compiler/file2.ts (1 errors) ==== import d from "./file1" ~ -!!! error TS6133: 'd' is declared but never used. +!!! error TS6133: 'd' is declared but its value is never read. diff --git a/tests/baselines/reference/unusedImports7.errors.txt b/tests/baselines/reference/unusedImports7.errors.txt index ac3a82a7f4d..9482a2c6f47 100644 --- a/tests/baselines/reference/unusedImports7.errors.txt +++ b/tests/baselines/reference/unusedImports7.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/file2.ts(1,13): error TS6133: 'n' is declared but never used. +tests/cases/compiler/file2.ts(1,13): error TS6133: 'n' is declared but its value is never read. ==== tests/cases/compiler/file1.ts (0 errors) ==== @@ -17,6 +17,6 @@ tests/cases/compiler/file2.ts(1,13): error TS6133: 'n' is declared but never use ==== tests/cases/compiler/file2.ts (1 errors) ==== import * as n from "./file1" ~ -!!! error TS6133: 'n' is declared but never used. +!!! error TS6133: 'n' is declared but its value is never read. \ No newline at end of file diff --git a/tests/baselines/reference/unusedImports8.errors.txt b/tests/baselines/reference/unusedImports8.errors.txt index 1c9d7a5ae8c..a6cbaae8ff6 100644 --- a/tests/baselines/reference/unusedImports8.errors.txt +++ b/tests/baselines/reference/unusedImports8.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/file2.ts(1,50): error TS6133: 't2' is declared but never used. +tests/cases/compiler/file2.ts(1,50): error TS6133: 't2' is declared but its value is never read. ==== tests/cases/compiler/file1.ts (0 errors) ==== @@ -17,7 +17,7 @@ tests/cases/compiler/file2.ts(1,50): error TS6133: 't2' is declared but never us ==== tests/cases/compiler/file2.ts (1 errors) ==== import {Calculator as calc, test as t1, test2 as t2} from "./file1" ~~ -!!! error TS6133: 't2' is declared but never used. +!!! error TS6133: 't2' is declared but its value is never read. var x = new calc(); x.handleChar(); diff --git a/tests/baselines/reference/unusedImports9.errors.txt b/tests/baselines/reference/unusedImports9.errors.txt index d46f0b68284..2452962b289 100644 --- a/tests/baselines/reference/unusedImports9.errors.txt +++ b/tests/baselines/reference/unusedImports9.errors.txt @@ -1,10 +1,10 @@ -tests/cases/compiler/file2.ts(1,8): error TS6133: 'c' is declared but never used. +tests/cases/compiler/file2.ts(1,8): error TS6133: 'c' is declared but its value is never read. ==== tests/cases/compiler/file2.ts (1 errors) ==== import c = require('./file1') ~ -!!! error TS6133: 'c' is declared but never used. +!!! error TS6133: 'c' is declared but its value is never read. ==== tests/cases/compiler/file1.ts (0 errors) ==== export class Calculator { handleChar() {} diff --git a/tests/baselines/reference/unusedInterfaceinNamespace1.errors.txt b/tests/baselines/reference/unusedInterfaceinNamespace1.errors.txt index eac7c6301df..613852735de 100644 --- a/tests/baselines/reference/unusedInterfaceinNamespace1.errors.txt +++ b/tests/baselines/reference/unusedInterfaceinNamespace1.errors.txt @@ -1,11 +1,11 @@ -tests/cases/compiler/unusedInterfaceinNamespace1.ts(2,15): error TS6133: 'i1' is declared but never used. +tests/cases/compiler/unusedInterfaceinNamespace1.ts(2,15): error TS6133: 'i1' is declared but its value is never read. ==== tests/cases/compiler/unusedInterfaceinNamespace1.ts (1 errors) ==== namespace Validation { interface i1 { ~~ -!!! error TS6133: 'i1' is declared but never used. +!!! error TS6133: 'i1' is declared but its value is never read. } } \ No newline at end of file diff --git a/tests/baselines/reference/unusedInterfaceinNamespace2.errors.txt b/tests/baselines/reference/unusedInterfaceinNamespace2.errors.txt index 1e8ea56ea0e..9ce75e393fe 100644 --- a/tests/baselines/reference/unusedInterfaceinNamespace2.errors.txt +++ b/tests/baselines/reference/unusedInterfaceinNamespace2.errors.txt @@ -1,11 +1,11 @@ -tests/cases/compiler/unusedInterfaceinNamespace2.ts(2,15): error TS6133: 'i1' is declared but never used. +tests/cases/compiler/unusedInterfaceinNamespace2.ts(2,15): error TS6133: 'i1' is declared but its value is never read. ==== tests/cases/compiler/unusedInterfaceinNamespace2.ts (1 errors) ==== namespace Validation { interface i1 { ~~ -!!! error TS6133: 'i1' is declared but never used. +!!! error TS6133: 'i1' is declared but its value is never read. } diff --git a/tests/baselines/reference/unusedInterfaceinNamespace3.errors.txt b/tests/baselines/reference/unusedInterfaceinNamespace3.errors.txt index 519244e4c5d..b1b1cbb9b86 100644 --- a/tests/baselines/reference/unusedInterfaceinNamespace3.errors.txt +++ b/tests/baselines/reference/unusedInterfaceinNamespace3.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/unusedInterfaceinNamespace3.ts(10,15): error TS6133: 'i3' is declared but never used. +tests/cases/compiler/unusedInterfaceinNamespace3.ts(10,15): error TS6133: 'i3' is declared but its value is never read. ==== tests/cases/compiler/unusedInterfaceinNamespace3.ts (1 errors) ==== @@ -13,7 +13,7 @@ tests/cases/compiler/unusedInterfaceinNamespace3.ts(10,15): error TS6133: 'i3' i interface i3 extends i1 { ~~ -!!! error TS6133: 'i3' is declared but never used. +!!! error TS6133: 'i3' is declared but its value is never read. } } \ No newline at end of file diff --git a/tests/baselines/reference/unusedLocalsAndObjectSpread.errors.txt b/tests/baselines/reference/unusedLocalsAndObjectSpread.errors.txt index 4dfd37f7668..c3f89f32488 100644 --- a/tests/baselines/reference/unusedLocalsAndObjectSpread.errors.txt +++ b/tests/baselines/reference/unusedLocalsAndObjectSpread.errors.txt @@ -1,5 +1,5 @@ -tests/cases/compiler/unusedLocalsAndObjectSpread.ts(20,18): error TS6133: 'bar' is declared but never used. -tests/cases/compiler/unusedLocalsAndObjectSpread.ts(27,21): error TS6133: 'bar' is declared but never used. +tests/cases/compiler/unusedLocalsAndObjectSpread.ts(20,18): error TS6133: 'bar' is declared but its value is never read. +tests/cases/compiler/unusedLocalsAndObjectSpread.ts(27,21): error TS6133: 'bar' is declared but its value is never read. ==== tests/cases/compiler/unusedLocalsAndObjectSpread.ts (2 errors) ==== @@ -24,7 +24,7 @@ tests/cases/compiler/unusedLocalsAndObjectSpread.ts(27,21): error TS6133: 'bar' // 'a' is declared but never used const {a, ...bar} = foo; // bar should be unused ~~~ -!!! error TS6133: 'bar' is declared but never used. +!!! error TS6133: 'bar' is declared but its value is never read. //console.log(bar); } @@ -33,7 +33,7 @@ tests/cases/compiler/unusedLocalsAndObjectSpread.ts(27,21): error TS6133: 'bar' // '_' is declared but never used const {a: _, ...bar} = foo; // bar should be unused ~~~ -!!! error TS6133: 'bar' is declared but never used. +!!! error TS6133: 'bar' is declared but its value is never read. //console.log(bar); } \ No newline at end of file diff --git a/tests/baselines/reference/unusedLocalsAndObjectSpread2.errors.txt b/tests/baselines/reference/unusedLocalsAndObjectSpread2.errors.txt index 57d265e3b7e..2e29bf04608 100644 --- a/tests/baselines/reference/unusedLocalsAndObjectSpread2.errors.txt +++ b/tests/baselines/reference/unusedLocalsAndObjectSpread2.errors.txt @@ -1,6 +1,6 @@ -tests/cases/compiler/unusedLocalsAndObjectSpread2.ts(5,6): error TS6133: 'rest' is declared but never used. -tests/cases/compiler/unusedLocalsAndObjectSpread2.ts(8,10): error TS6133: 'foo' is declared but never used. -tests/cases/compiler/unusedLocalsAndObjectSpread2.ts(12,8): error TS6133: 'rest' is declared but never used. +tests/cases/compiler/unusedLocalsAndObjectSpread2.ts(5,6): error TS6133: 'rest' is declared but its value is never read. +tests/cases/compiler/unusedLocalsAndObjectSpread2.ts(8,10): error TS6133: 'foo' is declared but its value is never read. +tests/cases/compiler/unusedLocalsAndObjectSpread2.ts(12,8): error TS6133: 'rest' is declared but its value is never read. ==== tests/cases/compiler/unusedLocalsAndObjectSpread2.ts (3 errors) ==== @@ -10,18 +10,18 @@ tests/cases/compiler/unusedLocalsAndObjectSpread2.ts(12,8): error TS6133: 'rest' active: _a, // here! ...rest, ~~~~ -!!! error TS6133: 'rest' is declared but never used. +!!! error TS6133: 'rest' is declared but its value is never read. } = props; function foo() { ~~~ -!!! error TS6133: 'foo' is declared but never used. +!!! error TS6133: 'foo' is declared but its value is never read. const { children, active: _a, ...rest, ~~~~ -!!! error TS6133: 'rest' is declared but never used. +!!! error TS6133: 'rest' is declared but its value is never read. } = props; } diff --git a/tests/baselines/reference/unusedLocalsAndParameters.errors.txt b/tests/baselines/reference/unusedLocalsAndParameters.errors.txt index 2416b29c216..01fcdd4f225 100644 --- a/tests/baselines/reference/unusedLocalsAndParameters.errors.txt +++ b/tests/baselines/reference/unusedLocalsAndParameters.errors.txt @@ -1,27 +1,27 @@ -tests/cases/compiler/unusedLocalsAndParameters.ts(4,12): error TS6133: 'a' is declared but never used. -tests/cases/compiler/unusedLocalsAndParameters.ts(9,22): error TS6133: 'a' is declared but never used. -tests/cases/compiler/unusedLocalsAndParameters.ts(15,5): error TS6133: 'farrow' is declared but never used. -tests/cases/compiler/unusedLocalsAndParameters.ts(15,15): error TS6133: 'a' is declared but never used. -tests/cases/compiler/unusedLocalsAndParameters.ts(18,7): error TS6133: 'C' is declared but never used. -tests/cases/compiler/unusedLocalsAndParameters.ts(20,12): error TS6133: 'a' is declared but never used. +tests/cases/compiler/unusedLocalsAndParameters.ts(4,12): error TS6133: 'a' is declared but its value is never read. +tests/cases/compiler/unusedLocalsAndParameters.ts(9,22): error TS6133: 'a' is declared but its value is never read. +tests/cases/compiler/unusedLocalsAndParameters.ts(15,5): error TS6133: 'farrow' is declared but its value is never read. +tests/cases/compiler/unusedLocalsAndParameters.ts(15,15): error TS6133: 'a' is declared but its value is never read. +tests/cases/compiler/unusedLocalsAndParameters.ts(18,7): error TS6133: 'C' is declared but its value is never read. +tests/cases/compiler/unusedLocalsAndParameters.ts(20,12): error TS6133: 'a' is declared but its value is never read. tests/cases/compiler/unusedLocalsAndParameters.ts(23,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. -tests/cases/compiler/unusedLocalsAndParameters.ts(23,11): error TS6133: 'v' is declared but never used. -tests/cases/compiler/unusedLocalsAndParameters.ts(27,5): error TS6133: 'E' is declared but never used. -tests/cases/compiler/unusedLocalsAndParameters.ts(29,12): error TS6133: 'a' is declared but never used. +tests/cases/compiler/unusedLocalsAndParameters.ts(23,11): error TS6133: 'v' is declared but its value is never read. +tests/cases/compiler/unusedLocalsAndParameters.ts(27,5): error TS6133: 'E' is declared but its value is never read. +tests/cases/compiler/unusedLocalsAndParameters.ts(29,12): error TS6133: 'a' is declared but its value is never read. tests/cases/compiler/unusedLocalsAndParameters.ts(32,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. -tests/cases/compiler/unusedLocalsAndParameters.ts(32,11): error TS6133: 'v' is declared but never used. -tests/cases/compiler/unusedLocalsAndParameters.ts(38,12): error TS6133: 'a' is declared but never used. +tests/cases/compiler/unusedLocalsAndParameters.ts(32,11): error TS6133: 'v' is declared but its value is never read. +tests/cases/compiler/unusedLocalsAndParameters.ts(38,12): error TS6133: 'a' is declared but its value is never read. tests/cases/compiler/unusedLocalsAndParameters.ts(41,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. -tests/cases/compiler/unusedLocalsAndParameters.ts(41,11): error TS6133: 'v' is declared but never used. -tests/cases/compiler/unusedLocalsAndParameters.ts(48,10): error TS6133: 'i' is declared but never used. -tests/cases/compiler/unusedLocalsAndParameters.ts(52,10): error TS6133: 'i' is declared but never used. -tests/cases/compiler/unusedLocalsAndParameters.ts(56,17): error TS6133: 'n' is declared but never used. -tests/cases/compiler/unusedLocalsAndParameters.ts(63,11): error TS6133: 'c' is declared but never used. -tests/cases/compiler/unusedLocalsAndParameters.ts(68,11): error TS6133: 'a' is declared but never used. -tests/cases/compiler/unusedLocalsAndParameters.ts(71,11): error TS6133: 'c' is declared but never used. -tests/cases/compiler/unusedLocalsAndParameters.ts(74,11): error TS6133: 'c' is declared but never used. -tests/cases/compiler/unusedLocalsAndParameters.ts(79,11): error TS6133: 'N' is declared but never used. -tests/cases/compiler/unusedLocalsAndParameters.ts(80,9): error TS6133: 'x' is declared but never used. +tests/cases/compiler/unusedLocalsAndParameters.ts(41,11): error TS6133: 'v' is declared but its value is never read. +tests/cases/compiler/unusedLocalsAndParameters.ts(48,10): error TS6133: 'i' is declared but its value is never read. +tests/cases/compiler/unusedLocalsAndParameters.ts(52,10): error TS6133: 'i' is declared but its value is never read. +tests/cases/compiler/unusedLocalsAndParameters.ts(56,17): error TS6133: 'n' is declared but its value is never read. +tests/cases/compiler/unusedLocalsAndParameters.ts(63,11): error TS6133: 'c' is declared but its value is never read. +tests/cases/compiler/unusedLocalsAndParameters.ts(68,11): error TS6133: 'a' is declared but its value is never read. +tests/cases/compiler/unusedLocalsAndParameters.ts(71,11): error TS6133: 'c' is declared but its value is never read. +tests/cases/compiler/unusedLocalsAndParameters.ts(74,11): error TS6133: 'c' is declared but its value is never read. +tests/cases/compiler/unusedLocalsAndParameters.ts(79,11): error TS6133: 'N' is declared but its value is never read. +tests/cases/compiler/unusedLocalsAndParameters.ts(80,9): error TS6133: 'x' is declared but its value is never read. ==== tests/cases/compiler/unusedLocalsAndParameters.ts (24 errors) ==== @@ -30,14 +30,14 @@ tests/cases/compiler/unusedLocalsAndParameters.ts(80,9): error TS6133: 'x' is de // function declaration paramter function f(a) { ~ -!!! error TS6133: 'a' is declared but never used. +!!! error TS6133: 'a' is declared but its value is never read. } f(0); // function expression paramter var fexp = function (a) { ~ -!!! error TS6133: 'a' is declared but never used. +!!! error TS6133: 'a' is declared but its value is never read. }; fexp(0); @@ -45,42 +45,42 @@ tests/cases/compiler/unusedLocalsAndParameters.ts(80,9): error TS6133: 'x' is de // arrow function paramter var farrow = (a) => { ~~~~~~ -!!! error TS6133: 'farrow' is declared but never used. +!!! error TS6133: 'farrow' is declared but its value is never read. ~ -!!! error TS6133: 'a' is declared but never used. +!!! error TS6133: 'a' is declared but its value is never read. }; class C { ~ -!!! error TS6133: 'C' is declared but never used. +!!! error TS6133: 'C' is declared but its value is never read. // Method declaration paramter method(a) { ~ -!!! error TS6133: 'a' is declared but never used. +!!! error TS6133: 'a' is declared but its value is never read. } // Accessor declaration paramter set x(v: number) { ~ !!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. ~ -!!! error TS6133: 'v' is declared but never used. +!!! error TS6133: 'v' is declared but its value is never read. } } var E = class { ~ -!!! error TS6133: 'E' is declared but never used. +!!! error TS6133: 'E' is declared but its value is never read. // Method declaration paramter method(a) { ~ -!!! error TS6133: 'a' is declared but never used. +!!! error TS6133: 'a' is declared but its value is never read. } // Accessor declaration paramter set x(v: number) { ~ !!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. ~ -!!! error TS6133: 'v' is declared but never used. +!!! error TS6133: 'v' is declared but its value is never read. } } @@ -88,14 +88,14 @@ tests/cases/compiler/unusedLocalsAndParameters.ts(80,9): error TS6133: 'x' is de // Object literal method declaration paramter method(a) { ~ -!!! error TS6133: 'a' is declared but never used. +!!! error TS6133: 'a' is declared but its value is never read. }, // Accessor declaration paramter set x(v: number) { ~ !!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. ~ -!!! error TS6133: 'v' is declared but never used. +!!! error TS6133: 'v' is declared but its value is never read. } }; @@ -104,19 +104,19 @@ tests/cases/compiler/unusedLocalsAndParameters.ts(80,9): error TS6133: 'x' is de // in a for..in statment for (let i in o) { ~ -!!! error TS6133: 'i' is declared but never used. +!!! error TS6133: 'i' is declared but its value is never read. } // in a for..of statment for (let i of [1, 2, 3]) { ~ -!!! error TS6133: 'i' is declared but never used. +!!! error TS6133: 'i' is declared but its value is never read. } // in a for. statment for (let i = 0, n; i < 10; i++) { ~ -!!! error TS6133: 'n' is declared but never used. +!!! error TS6133: 'n' is declared but its value is never read. } // in a block @@ -125,34 +125,34 @@ tests/cases/compiler/unusedLocalsAndParameters.ts(80,9): error TS6133: 'x' is de if (condition) { const c = 0; ~ -!!! error TS6133: 'c' is declared but never used. +!!! error TS6133: 'c' is declared but its value is never read. } // in try/catch/finally try { const a = 0; ~ -!!! error TS6133: 'a' is declared but never used. +!!! error TS6133: 'a' is declared but its value is never read. } catch (e) { const c = 1; ~ -!!! error TS6133: 'c' is declared but never used. +!!! error TS6133: 'c' is declared but its value is never read. } finally { const c = 0; ~ -!!! error TS6133: 'c' is declared but never used. +!!! error TS6133: 'c' is declared but its value is never read. } // in a namespace namespace N { ~ -!!! error TS6133: 'N' is declared but never used. +!!! error TS6133: 'N' is declared but its value is never read. var x; ~ -!!! error TS6133: 'x' is declared but never used. +!!! error TS6133: 'x' is declared but its value is never read. } \ No newline at end of file diff --git a/tests/baselines/reference/unusedLocalsAndParametersTypeAliases2.errors.txt b/tests/baselines/reference/unusedLocalsAndParametersTypeAliases2.errors.txt index e5c6f476480..e30dc92d394 100644 --- a/tests/baselines/reference/unusedLocalsAndParametersTypeAliases2.errors.txt +++ b/tests/baselines/reference/unusedLocalsAndParametersTypeAliases2.errors.txt @@ -1,21 +1,21 @@ -tests/cases/compiler/unusedLocalsAndParametersTypeAliases2.ts(2,6): error TS6133: 'handler1' is declared but never used. -tests/cases/compiler/unusedLocalsAndParametersTypeAliases2.ts(5,10): error TS6133: 'foo' is declared but never used. -tests/cases/compiler/unusedLocalsAndParametersTypeAliases2.ts(6,10): error TS6133: 'handler2' is declared but never used. +tests/cases/compiler/unusedLocalsAndParametersTypeAliases2.ts(2,6): error TS6133: 'handler1' is declared but its value is never read. +tests/cases/compiler/unusedLocalsAndParametersTypeAliases2.ts(5,10): error TS6133: 'foo' is declared but its value is never read. +tests/cases/compiler/unusedLocalsAndParametersTypeAliases2.ts(6,10): error TS6133: 'handler2' is declared but its value is never read. ==== tests/cases/compiler/unusedLocalsAndParametersTypeAliases2.ts (3 errors) ==== // unused type handler1 = () => void; ~~~~~~~~ -!!! error TS6133: 'handler1' is declared but never used. +!!! error TS6133: 'handler1' is declared but its value is never read. function foo() { ~~~ -!!! error TS6133: 'foo' is declared but never used. +!!! error TS6133: 'foo' is declared but its value is never read. type handler2 = () => void; ~~~~~~~~ -!!! error TS6133: 'handler2' is declared but never used. +!!! error TS6133: 'handler2' is declared but its value is never read. foo(); } diff --git a/tests/baselines/reference/unusedLocalsInMethod1.errors.txt b/tests/baselines/reference/unusedLocalsInMethod1.errors.txt index 8406a009324..53802457794 100644 --- a/tests/baselines/reference/unusedLocalsInMethod1.errors.txt +++ b/tests/baselines/reference/unusedLocalsInMethod1.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/unusedLocalsInMethod1.ts(3,13): error TS6133: 'x' is declared but never used. +tests/cases/compiler/unusedLocalsInMethod1.ts(3,13): error TS6133: 'x' is declared but its value is never read. ==== tests/cases/compiler/unusedLocalsInMethod1.ts (1 errors) ==== @@ -6,6 +6,6 @@ tests/cases/compiler/unusedLocalsInMethod1.ts(3,13): error TS6133: 'x' is declar public function1() { var x = 10; ~ -!!! error TS6133: 'x' is declared but never used. +!!! error TS6133: 'x' is declared but its value is never read. } } \ No newline at end of file diff --git a/tests/baselines/reference/unusedLocalsInMethod2.errors.txt b/tests/baselines/reference/unusedLocalsInMethod2.errors.txt index 9aaa52ceee1..2aec1afb13a 100644 --- a/tests/baselines/reference/unusedLocalsInMethod2.errors.txt +++ b/tests/baselines/reference/unusedLocalsInMethod2.errors.txt @@ -1,12 +1,15 @@ -tests/cases/compiler/unusedLocalsInMethod2.ts(3,13): error TS6133: 'x' is declared but never used. +tests/cases/compiler/unusedLocalsInMethod2.ts(3,13): error TS6133: 'x' is declared but its value is never read. +tests/cases/compiler/unusedLocalsInMethod2.ts(3,16): error TS6133: 'y' is declared but its value is never read. -==== tests/cases/compiler/unusedLocalsInMethod2.ts (1 errors) ==== +==== tests/cases/compiler/unusedLocalsInMethod2.ts (2 errors) ==== class greeter { public function1() { var x, y = 10; ~ -!!! error TS6133: 'x' is declared but never used. +!!! error TS6133: 'x' is declared but its value is never read. + ~ +!!! error TS6133: 'y' is declared but its value is never read. y++; } } \ No newline at end of file diff --git a/tests/baselines/reference/unusedLocalsInMethod3.errors.txt b/tests/baselines/reference/unusedLocalsInMethod3.errors.txt index 3486f9d894e..6e34814457b 100644 --- a/tests/baselines/reference/unusedLocalsInMethod3.errors.txt +++ b/tests/baselines/reference/unusedLocalsInMethod3.errors.txt @@ -1,12 +1,15 @@ -tests/cases/compiler/unusedLocalsInMethod3.ts(3,13): error TS6133: 'x' is declared but never used. +tests/cases/compiler/unusedLocalsInMethod3.ts(3,13): error TS6133: 'x' is declared but its value is never read. +tests/cases/compiler/unusedLocalsInMethod3.ts(3,16): error TS6133: 'y' is declared but its value is never read. -==== tests/cases/compiler/unusedLocalsInMethod3.ts (1 errors) ==== +==== tests/cases/compiler/unusedLocalsInMethod3.ts (2 errors) ==== class greeter { public function1() { var x, y; ~ -!!! error TS6133: 'x' is declared but never used. +!!! error TS6133: 'x' is declared but its value is never read. + ~ +!!! error TS6133: 'y' is declared but its value is never read. y = 1; } } \ No newline at end of file diff --git a/tests/baselines/reference/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration1.errors.txt b/tests/baselines/reference/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration1.errors.txt index f3ace8acc9a..da5bc7382e3 100644 --- a/tests/baselines/reference/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration1.errors.txt +++ b/tests/baselines/reference/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration1.errors.txt @@ -1,25 +1,28 @@ -tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration1.ts(1,18): error TS6133: 'person' is declared but never used. -tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration1.ts(2,9): error TS6133: 'unused' is declared but never used. -tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration1.ts(3,14): error TS6133: 'maker' is declared but never used. -tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration1.ts(3,20): error TS6133: 'child' is declared but never used. -tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration1.ts(4,13): error TS6133: 'unused2' is declared but never used. +tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration1.ts(1,18): error TS6133: 'person' is declared but its value is never read. +tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration1.ts(1,34): error TS6133: 'person2' is declared but its value is never read. +tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration1.ts(2,9): error TS6133: 'unused' is declared but its value is never read. +tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration1.ts(3,14): error TS6133: 'maker' is declared but its value is never read. +tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration1.ts(3,20): error TS6133: 'child' is declared but its value is never read. +tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration1.ts(4,13): error TS6133: 'unused2' is declared but its value is never read. -==== tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration1.ts (5 errors) ==== +==== tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration1.ts (6 errors) ==== function greeter(person: string, person2: string) { ~~~~~~ -!!! error TS6133: 'person' is declared but never used. +!!! error TS6133: 'person' is declared but its value is never read. + ~~~~~~~ +!!! error TS6133: 'person2' is declared but its value is never read. var unused = 20; ~~~~~~ -!!! error TS6133: 'unused' is declared but never used. +!!! error TS6133: 'unused' is declared but its value is never read. function maker(child: string): void { ~~~~~ -!!! error TS6133: 'maker' is declared but never used. +!!! error TS6133: 'maker' is declared but its value is never read. ~~~~~ -!!! error TS6133: 'child' is declared but never used. +!!! error TS6133: 'child' is declared but its value is never read. var unused2 = 22; ~~~~~~~ -!!! error TS6133: 'unused2' is declared but never used. +!!! error TS6133: 'unused2' is declared but its value is never read. } person2 = "dummy value"; } \ No newline at end of file diff --git a/tests/baselines/reference/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration2.errors.txt b/tests/baselines/reference/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration2.errors.txt index aacf8b9889f..e5326d2c41f 100644 --- a/tests/baselines/reference/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration2.errors.txt +++ b/tests/baselines/reference/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration2.errors.txt @@ -1,34 +1,34 @@ -tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration2.ts(1,18): error TS6133: 'person' is declared but never used. -tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration2.ts(2,9): error TS6133: 'unused' is declared but never used. -tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration2.ts(3,14): error TS6133: 'maker' is declared but never used. -tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration2.ts(3,20): error TS6133: 'child' is declared but never used. -tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration2.ts(4,13): error TS6133: 'unused2' is declared but never used. -tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration2.ts(6,21): error TS6133: 'child2' is declared but never used. -tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration2.ts(7,13): error TS6133: 'unused3' is declared but never used. +tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration2.ts(1,18): error TS6133: 'person' is declared but its value is never read. +tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration2.ts(2,9): error TS6133: 'unused' is declared but its value is never read. +tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration2.ts(3,14): error TS6133: 'maker' is declared but its value is never read. +tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration2.ts(3,20): error TS6133: 'child' is declared but its value is never read. +tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration2.ts(4,13): error TS6133: 'unused2' is declared but its value is never read. +tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration2.ts(6,21): error TS6133: 'child2' is declared but its value is never read. +tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration2.ts(7,13): error TS6133: 'unused3' is declared but its value is never read. ==== tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration2.ts (7 errors) ==== function greeter(person: string, person2: string) { ~~~~~~ -!!! error TS6133: 'person' is declared but never used. +!!! error TS6133: 'person' is declared but its value is never read. var unused = 20; ~~~~~~ -!!! error TS6133: 'unused' is declared but never used. +!!! error TS6133: 'unused' is declared but its value is never read. function maker(child: string): void { ~~~~~ -!!! error TS6133: 'maker' is declared but never used. +!!! error TS6133: 'maker' is declared but its value is never read. ~~~~~ -!!! error TS6133: 'child' is declared but never used. +!!! error TS6133: 'child' is declared but its value is never read. var unused2 = 22; ~~~~~~~ -!!! error TS6133: 'unused2' is declared but never used. +!!! error TS6133: 'unused2' is declared but its value is never read. } function maker2(child2: string): void { ~~~~~~ -!!! error TS6133: 'child2' is declared but never used. +!!! error TS6133: 'child2' is declared but its value is never read. var unused3 = 23; ~~~~~~~ -!!! error TS6133: 'unused3' is declared but never used. +!!! error TS6133: 'unused3' is declared but its value is never read. } maker2(person2); } \ No newline at end of file diff --git a/tests/baselines/reference/unusedLocalsOnFunctionDeclarationWithinFunctionExpression1.errors.txt b/tests/baselines/reference/unusedLocalsOnFunctionDeclarationWithinFunctionExpression1.errors.txt index b8ebdd2ad75..ac9b5c8632c 100644 --- a/tests/baselines/reference/unusedLocalsOnFunctionDeclarationWithinFunctionExpression1.errors.txt +++ b/tests/baselines/reference/unusedLocalsOnFunctionDeclarationWithinFunctionExpression1.errors.txt @@ -1,25 +1,28 @@ -tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionExpression1.ts(1,25): error TS6133: 'person' is declared but never used. -tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionExpression1.ts(2,9): error TS6133: 'unused' is declared but never used. -tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionExpression1.ts(3,14): error TS6133: 'maker' is declared but never used. -tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionExpression1.ts(3,20): error TS6133: 'child' is declared but never used. -tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionExpression1.ts(4,13): error TS6133: 'unused2' is declared but never used. +tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionExpression1.ts(1,25): error TS6133: 'person' is declared but its value is never read. +tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionExpression1.ts(1,41): error TS6133: 'person2' is declared but its value is never read. +tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionExpression1.ts(2,9): error TS6133: 'unused' is declared but its value is never read. +tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionExpression1.ts(3,14): error TS6133: 'maker' is declared but its value is never read. +tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionExpression1.ts(3,20): error TS6133: 'child' is declared but its value is never read. +tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionExpression1.ts(4,13): error TS6133: 'unused2' is declared but its value is never read. -==== tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionExpression1.ts (5 errors) ==== +==== tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionExpression1.ts (6 errors) ==== var greeter = function (person: string, person2: string) { ~~~~~~ -!!! error TS6133: 'person' is declared but never used. +!!! error TS6133: 'person' is declared but its value is never read. + ~~~~~~~ +!!! error TS6133: 'person2' is declared but its value is never read. var unused = 20; ~~~~~~ -!!! error TS6133: 'unused' is declared but never used. +!!! error TS6133: 'unused' is declared but its value is never read. function maker(child: string): void { ~~~~~ -!!! error TS6133: 'maker' is declared but never used. +!!! error TS6133: 'maker' is declared but its value is never read. ~~~~~ -!!! error TS6133: 'child' is declared but never used. +!!! error TS6133: 'child' is declared but its value is never read. var unused2 = 22; ~~~~~~~ -!!! error TS6133: 'unused2' is declared but never used. +!!! error TS6133: 'unused2' is declared but its value is never read. } person2 = "dummy value"; } \ No newline at end of file diff --git a/tests/baselines/reference/unusedLocalsOnFunctionDeclarationWithinFunctionExpression2.errors.txt b/tests/baselines/reference/unusedLocalsOnFunctionDeclarationWithinFunctionExpression2.errors.txt index b405993b0f5..c709d189d17 100644 --- a/tests/baselines/reference/unusedLocalsOnFunctionDeclarationWithinFunctionExpression2.errors.txt +++ b/tests/baselines/reference/unusedLocalsOnFunctionDeclarationWithinFunctionExpression2.errors.txt @@ -1,34 +1,34 @@ -tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionExpression2.ts(1,25): error TS6133: 'person' is declared but never used. -tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionExpression2.ts(2,9): error TS6133: 'unused' is declared but never used. -tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionExpression2.ts(3,14): error TS6133: 'maker' is declared but never used. -tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionExpression2.ts(3,20): error TS6133: 'child' is declared but never used. -tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionExpression2.ts(4,13): error TS6133: 'unused2' is declared but never used. -tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionExpression2.ts(6,21): error TS6133: 'child2' is declared but never used. -tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionExpression2.ts(7,13): error TS6133: 'unused3' is declared but never used. +tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionExpression2.ts(1,25): error TS6133: 'person' is declared but its value is never read. +tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionExpression2.ts(2,9): error TS6133: 'unused' is declared but its value is never read. +tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionExpression2.ts(3,14): error TS6133: 'maker' is declared but its value is never read. +tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionExpression2.ts(3,20): error TS6133: 'child' is declared but its value is never read. +tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionExpression2.ts(4,13): error TS6133: 'unused2' is declared but its value is never read. +tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionExpression2.ts(6,21): error TS6133: 'child2' is declared but its value is never read. +tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionExpression2.ts(7,13): error TS6133: 'unused3' is declared but its value is never read. ==== tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionExpression2.ts (7 errors) ==== var greeter = function (person: string, person2: string) { ~~~~~~ -!!! error TS6133: 'person' is declared but never used. +!!! error TS6133: 'person' is declared but its value is never read. var unused = 20; ~~~~~~ -!!! error TS6133: 'unused' is declared but never used. +!!! error TS6133: 'unused' is declared but its value is never read. function maker(child: string): void { ~~~~~ -!!! error TS6133: 'maker' is declared but never used. +!!! error TS6133: 'maker' is declared but its value is never read. ~~~~~ -!!! error TS6133: 'child' is declared but never used. +!!! error TS6133: 'child' is declared but its value is never read. var unused2 = 22; ~~~~~~~ -!!! error TS6133: 'unused2' is declared but never used. +!!! error TS6133: 'unused2' is declared but its value is never read. } function maker2(child2: string): void { ~~~~~~ -!!! error TS6133: 'child2' is declared but never used. +!!! error TS6133: 'child2' is declared but its value is never read. var unused3 = 23; ~~~~~~~ -!!! error TS6133: 'unused3' is declared but never used. +!!! error TS6133: 'unused3' is declared but its value is never read. } maker2(person2); } \ No newline at end of file diff --git a/tests/baselines/reference/unusedLocalsOnFunctionExpressionWithinFunctionDeclaration1.errors.txt b/tests/baselines/reference/unusedLocalsOnFunctionExpressionWithinFunctionDeclaration1.errors.txt index 094ed3d338c..b68f8dbc94c 100644 --- a/tests/baselines/reference/unusedLocalsOnFunctionExpressionWithinFunctionDeclaration1.errors.txt +++ b/tests/baselines/reference/unusedLocalsOnFunctionExpressionWithinFunctionDeclaration1.errors.txt @@ -1,25 +1,28 @@ -tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionDeclaration1.ts(1,18): error TS6133: 'person' is declared but never used. -tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionDeclaration1.ts(2,9): error TS6133: 'unused' is declared but never used. -tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionDeclaration1.ts(3,9): error TS6133: 'maker' is declared but never used. -tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionDeclaration1.ts(3,27): error TS6133: 'child' is declared but never used. -tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionDeclaration1.ts(4,13): error TS6133: 'unused2' is declared but never used. +tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionDeclaration1.ts(1,18): error TS6133: 'person' is declared but its value is never read. +tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionDeclaration1.ts(1,34): error TS6133: 'person2' is declared but its value is never read. +tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionDeclaration1.ts(2,9): error TS6133: 'unused' is declared but its value is never read. +tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionDeclaration1.ts(3,9): error TS6133: 'maker' is declared but its value is never read. +tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionDeclaration1.ts(3,27): error TS6133: 'child' is declared but its value is never read. +tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionDeclaration1.ts(4,13): error TS6133: 'unused2' is declared but its value is never read. -==== tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionDeclaration1.ts (5 errors) ==== +==== tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionDeclaration1.ts (6 errors) ==== function greeter(person: string, person2: string) { ~~~~~~ -!!! error TS6133: 'person' is declared but never used. +!!! error TS6133: 'person' is declared but its value is never read. + ~~~~~~~ +!!! error TS6133: 'person2' is declared but its value is never read. var unused = 20; ~~~~~~ -!!! error TS6133: 'unused' is declared but never used. +!!! error TS6133: 'unused' is declared but its value is never read. var maker = function (child: string): void { ~~~~~ -!!! error TS6133: 'maker' is declared but never used. +!!! error TS6133: 'maker' is declared but its value is never read. ~~~~~ -!!! error TS6133: 'child' is declared but never used. +!!! error TS6133: 'child' is declared but its value is never read. var unused2 = 22; ~~~~~~~ -!!! error TS6133: 'unused2' is declared but never used. +!!! error TS6133: 'unused2' is declared but its value is never read. } person2 = "dummy value"; } \ No newline at end of file diff --git a/tests/baselines/reference/unusedLocalsOnFunctionExpressionWithinFunctionDeclaration2.errors.txt b/tests/baselines/reference/unusedLocalsOnFunctionExpressionWithinFunctionDeclaration2.errors.txt index a9887731ce3..58e9c46047c 100644 --- a/tests/baselines/reference/unusedLocalsOnFunctionExpressionWithinFunctionDeclaration2.errors.txt +++ b/tests/baselines/reference/unusedLocalsOnFunctionExpressionWithinFunctionDeclaration2.errors.txt @@ -1,34 +1,34 @@ -tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionDeclaration2.ts(1,18): error TS6133: 'person' is declared but never used. -tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionDeclaration2.ts(2,9): error TS6133: 'unused' is declared but never used. -tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionDeclaration2.ts(3,9): error TS6133: 'maker' is declared but never used. -tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionDeclaration2.ts(3,26): error TS6133: 'child' is declared but never used. -tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionDeclaration2.ts(4,13): error TS6133: 'unused2' is declared but never used. -tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionDeclaration2.ts(6,27): error TS6133: 'child2' is declared but never used. -tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionDeclaration2.ts(7,13): error TS6133: 'unused3' is declared but never used. +tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionDeclaration2.ts(1,18): error TS6133: 'person' is declared but its value is never read. +tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionDeclaration2.ts(2,9): error TS6133: 'unused' is declared but its value is never read. +tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionDeclaration2.ts(3,9): error TS6133: 'maker' is declared but its value is never read. +tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionDeclaration2.ts(3,26): error TS6133: 'child' is declared but its value is never read. +tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionDeclaration2.ts(4,13): error TS6133: 'unused2' is declared but its value is never read. +tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionDeclaration2.ts(6,27): error TS6133: 'child2' is declared but its value is never read. +tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionDeclaration2.ts(7,13): error TS6133: 'unused3' is declared but its value is never read. ==== tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionDeclaration2.ts (7 errors) ==== function greeter(person: string, person2: string) { ~~~~~~ -!!! error TS6133: 'person' is declared but never used. +!!! error TS6133: 'person' is declared but its value is never read. var unused = 20; ~~~~~~ -!!! error TS6133: 'unused' is declared but never used. +!!! error TS6133: 'unused' is declared but its value is never read. var maker = function(child: string): void { ~~~~~ -!!! error TS6133: 'maker' is declared but never used. +!!! error TS6133: 'maker' is declared but its value is never read. ~~~~~ -!!! error TS6133: 'child' is declared but never used. +!!! error TS6133: 'child' is declared but its value is never read. var unused2 = 22; ~~~~~~~ -!!! error TS6133: 'unused2' is declared but never used. +!!! error TS6133: 'unused2' is declared but its value is never read. } var maker2 = function(child2: string): void { ~~~~~~ -!!! error TS6133: 'child2' is declared but never used. +!!! error TS6133: 'child2' is declared but its value is never read. var unused3 = 23; ~~~~~~~ -!!! error TS6133: 'unused3' is declared but never used. +!!! error TS6133: 'unused3' is declared but its value is never read. } maker2(person2); } \ No newline at end of file diff --git a/tests/baselines/reference/unusedLocalsOnFunctionExpressionWithinFunctionExpression1.errors.txt b/tests/baselines/reference/unusedLocalsOnFunctionExpressionWithinFunctionExpression1.errors.txt index 3ff247c3423..35f63193f48 100644 --- a/tests/baselines/reference/unusedLocalsOnFunctionExpressionWithinFunctionExpression1.errors.txt +++ b/tests/baselines/reference/unusedLocalsOnFunctionExpressionWithinFunctionExpression1.errors.txt @@ -1,25 +1,28 @@ -tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionExpression1.ts(1,25): error TS6133: 'person' is declared but never used. -tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionExpression1.ts(2,9): error TS6133: 'unused' is declared but never used. -tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionExpression1.ts(3,9): error TS6133: 'maker' is declared but never used. -tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionExpression1.ts(3,27): error TS6133: 'child' is declared but never used. -tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionExpression1.ts(4,13): error TS6133: 'unused2' is declared but never used. +tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionExpression1.ts(1,25): error TS6133: 'person' is declared but its value is never read. +tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionExpression1.ts(1,41): error TS6133: 'person2' is declared but its value is never read. +tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionExpression1.ts(2,9): error TS6133: 'unused' is declared but its value is never read. +tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionExpression1.ts(3,9): error TS6133: 'maker' is declared but its value is never read. +tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionExpression1.ts(3,27): error TS6133: 'child' is declared but its value is never read. +tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionExpression1.ts(4,13): error TS6133: 'unused2' is declared but its value is never read. -==== tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionExpression1.ts (5 errors) ==== +==== tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionExpression1.ts (6 errors) ==== var greeter = function (person: string, person2: string) { ~~~~~~ -!!! error TS6133: 'person' is declared but never used. +!!! error TS6133: 'person' is declared but its value is never read. + ~~~~~~~ +!!! error TS6133: 'person2' is declared but its value is never read. var unused = 20; ~~~~~~ -!!! error TS6133: 'unused' is declared but never used. +!!! error TS6133: 'unused' is declared but its value is never read. var maker = function (child: string): void { ~~~~~ -!!! error TS6133: 'maker' is declared but never used. +!!! error TS6133: 'maker' is declared but its value is never read. ~~~~~ -!!! error TS6133: 'child' is declared but never used. +!!! error TS6133: 'child' is declared but its value is never read. var unused2 = 22; ~~~~~~~ -!!! error TS6133: 'unused2' is declared but never used. +!!! error TS6133: 'unused2' is declared but its value is never read. } person2 = "dummy value"; } \ No newline at end of file diff --git a/tests/baselines/reference/unusedLocalsOnFunctionExpressionWithinFunctionExpression2.errors.txt b/tests/baselines/reference/unusedLocalsOnFunctionExpressionWithinFunctionExpression2.errors.txt index e5097afa44b..57fb73eb6ca 100644 --- a/tests/baselines/reference/unusedLocalsOnFunctionExpressionWithinFunctionExpression2.errors.txt +++ b/tests/baselines/reference/unusedLocalsOnFunctionExpressionWithinFunctionExpression2.errors.txt @@ -1,34 +1,34 @@ -tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionExpression2.ts(1,25): error TS6133: 'person' is declared but never used. -tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionExpression2.ts(2,9): error TS6133: 'unused' is declared but never used. -tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionExpression2.ts(3,9): error TS6133: 'maker' is declared but never used. -tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionExpression2.ts(3,27): error TS6133: 'child' is declared but never used. -tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionExpression2.ts(4,13): error TS6133: 'unused2' is declared but never used. -tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionExpression2.ts(6,28): error TS6133: 'child2' is declared but never used. -tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionExpression2.ts(7,13): error TS6133: 'unused3' is declared but never used. +tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionExpression2.ts(1,25): error TS6133: 'person' is declared but its value is never read. +tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionExpression2.ts(2,9): error TS6133: 'unused' is declared but its value is never read. +tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionExpression2.ts(3,9): error TS6133: 'maker' is declared but its value is never read. +tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionExpression2.ts(3,27): error TS6133: 'child' is declared but its value is never read. +tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionExpression2.ts(4,13): error TS6133: 'unused2' is declared but its value is never read. +tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionExpression2.ts(6,28): error TS6133: 'child2' is declared but its value is never read. +tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionExpression2.ts(7,13): error TS6133: 'unused3' is declared but its value is never read. ==== tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionExpression2.ts (7 errors) ==== var greeter = function (person: string, person2: string) { ~~~~~~ -!!! error TS6133: 'person' is declared but never used. +!!! error TS6133: 'person' is declared but its value is never read. var unused = 20; ~~~~~~ -!!! error TS6133: 'unused' is declared but never used. +!!! error TS6133: 'unused' is declared but its value is never read. var maker = function (child: string): void { ~~~~~ -!!! error TS6133: 'maker' is declared but never used. +!!! error TS6133: 'maker' is declared but its value is never read. ~~~~~ -!!! error TS6133: 'child' is declared but never used. +!!! error TS6133: 'child' is declared but its value is never read. var unused2 = 22; ~~~~~~~ -!!! error TS6133: 'unused2' is declared but never used. +!!! error TS6133: 'unused2' is declared but its value is never read. } var maker2 = function (child2: string): void { ~~~~~~ -!!! error TS6133: 'child2' is declared but never used. +!!! error TS6133: 'child2' is declared but its value is never read. var unused3 = 23; ~~~~~~~ -!!! error TS6133: 'unused3' is declared but never used. +!!! error TS6133: 'unused3' is declared but its value is never read. } maker2(person2); } \ No newline at end of file diff --git a/tests/baselines/reference/unusedLocalsStartingWithUnderscore.errors.txt b/tests/baselines/reference/unusedLocalsStartingWithUnderscore.errors.txt index 32f2acfe78b..b8a0a50fea6 100644 --- a/tests/baselines/reference/unusedLocalsStartingWithUnderscore.errors.txt +++ b/tests/baselines/reference/unusedLocalsStartingWithUnderscore.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/unusedLocalsStartingWithUnderscore.ts(6,9): error TS6133: '_' is declared but never used. +tests/cases/compiler/unusedLocalsStartingWithUnderscore.ts(6,9): error TS6133: '_' is declared but its value is never read. ==== tests/cases/compiler/unusedLocalsStartingWithUnderscore.ts (1 errors) ==== @@ -9,7 +9,7 @@ tests/cases/compiler/unusedLocalsStartingWithUnderscore.ts(6,9): error TS6133: ' namespace M { let _; ~ -!!! error TS6133: '_' is declared but never used. +!!! error TS6133: '_' is declared but its value is never read. for (const _ of []) { } for (const _ in []) { } diff --git a/tests/baselines/reference/unusedLocalsinConstructor1.errors.txt b/tests/baselines/reference/unusedLocalsinConstructor1.errors.txt index 4831c09f40d..b0eb68286b5 100644 --- a/tests/baselines/reference/unusedLocalsinConstructor1.errors.txt +++ b/tests/baselines/reference/unusedLocalsinConstructor1.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/unusedLocalsinConstructor1.ts(3,13): error TS6133: 'unused' is declared but never used. +tests/cases/compiler/unusedLocalsinConstructor1.ts(3,13): error TS6133: 'unused' is declared but its value is never read. ==== tests/cases/compiler/unusedLocalsinConstructor1.ts (1 errors) ==== @@ -6,6 +6,6 @@ tests/cases/compiler/unusedLocalsinConstructor1.ts(3,13): error TS6133: 'unused' constructor() { var unused = 20; ~~~~~~ -!!! error TS6133: 'unused' is declared but never used. +!!! error TS6133: 'unused' is declared but its value is never read. } } \ No newline at end of file diff --git a/tests/baselines/reference/unusedLocalsinConstructor2.errors.txt b/tests/baselines/reference/unusedLocalsinConstructor2.errors.txt index 83127b6ecd9..32fb8bfccc8 100644 --- a/tests/baselines/reference/unusedLocalsinConstructor2.errors.txt +++ b/tests/baselines/reference/unusedLocalsinConstructor2.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/unusedLocalsinConstructor2.ts(3,13): error TS6133: 'unused' is declared but never used. +tests/cases/compiler/unusedLocalsinConstructor2.ts(3,13): error TS6133: 'unused' is declared but its value is never read. ==== tests/cases/compiler/unusedLocalsinConstructor2.ts (1 errors) ==== @@ -6,7 +6,7 @@ tests/cases/compiler/unusedLocalsinConstructor2.ts(3,13): error TS6133: 'unused' constructor() { var unused = 20; ~~~~~~ -!!! error TS6133: 'unused' is declared but never used. +!!! error TS6133: 'unused' is declared but its value is never read. var used = "dummy"; used = used + "second part"; } diff --git a/tests/baselines/reference/unusedModuleInModule.errors.txt b/tests/baselines/reference/unusedModuleInModule.errors.txt index c558e7446fe..bd8040ce590 100644 --- a/tests/baselines/reference/unusedModuleInModule.errors.txt +++ b/tests/baselines/reference/unusedModuleInModule.errors.txt @@ -1,9 +1,9 @@ -tests/cases/compiler/unusedModuleInModule.ts(2,12): error TS6133: 'B' is declared but never used. +tests/cases/compiler/unusedModuleInModule.ts(2,12): error TS6133: 'B' is declared but its value is never read. ==== tests/cases/compiler/unusedModuleInModule.ts (1 errors) ==== module A { module B {} ~ -!!! error TS6133: 'B' is declared but never used. +!!! error TS6133: 'B' is declared but its value is never read. } \ No newline at end of file diff --git a/tests/baselines/reference/unusedMultipleParameter1InContructor.errors.txt b/tests/baselines/reference/unusedMultipleParameter1InContructor.errors.txt index 5c2ccfc29e0..59a5af15888 100644 --- a/tests/baselines/reference/unusedMultipleParameter1InContructor.errors.txt +++ b/tests/baselines/reference/unusedMultipleParameter1InContructor.errors.txt @@ -1,15 +1,18 @@ -tests/cases/compiler/unusedMultipleParameter1InContructor.ts(2,17): error TS6133: 'person' is declared but never used. -tests/cases/compiler/unusedMultipleParameter1InContructor.ts(3,13): error TS6133: 'unused' is declared but never used. +tests/cases/compiler/unusedMultipleParameter1InContructor.ts(2,17): error TS6133: 'person' is declared but its value is never read. +tests/cases/compiler/unusedMultipleParameter1InContructor.ts(2,33): error TS6133: 'person2' is declared but its value is never read. +tests/cases/compiler/unusedMultipleParameter1InContructor.ts(3,13): error TS6133: 'unused' is declared but its value is never read. -==== tests/cases/compiler/unusedMultipleParameter1InContructor.ts (2 errors) ==== +==== tests/cases/compiler/unusedMultipleParameter1InContructor.ts (3 errors) ==== class Dummy { constructor(person: string, person2: string) { ~~~~~~ -!!! error TS6133: 'person' is declared but never used. +!!! error TS6133: 'person' is declared but its value is never read. + ~~~~~~~ +!!! error TS6133: 'person2' is declared but its value is never read. var unused = 20; ~~~~~~ -!!! error TS6133: 'unused' is declared but never used. +!!! error TS6133: 'unused' is declared but its value is never read. person2 = "Dummy value"; } } \ No newline at end of file diff --git a/tests/baselines/reference/unusedMultipleParameter1InFunctionExpression.errors.txt b/tests/baselines/reference/unusedMultipleParameter1InFunctionExpression.errors.txt index 1405f9aae2c..26bc6f2c859 100644 --- a/tests/baselines/reference/unusedMultipleParameter1InFunctionExpression.errors.txt +++ b/tests/baselines/reference/unusedMultipleParameter1InFunctionExpression.errors.txt @@ -1,13 +1,16 @@ -tests/cases/compiler/unusedMultipleParameter1InFunctionExpression.ts(1,21): error TS6133: 'person' is declared but never used. -tests/cases/compiler/unusedMultipleParameter1InFunctionExpression.ts(2,9): error TS6133: 'unused' is declared but never used. +tests/cases/compiler/unusedMultipleParameter1InFunctionExpression.ts(1,21): error TS6133: 'person' is declared but its value is never read. +tests/cases/compiler/unusedMultipleParameter1InFunctionExpression.ts(1,37): error TS6133: 'person2' is declared but its value is never read. +tests/cases/compiler/unusedMultipleParameter1InFunctionExpression.ts(2,9): error TS6133: 'unused' is declared but its value is never read. -==== tests/cases/compiler/unusedMultipleParameter1InFunctionExpression.ts (2 errors) ==== +==== tests/cases/compiler/unusedMultipleParameter1InFunctionExpression.ts (3 errors) ==== var func = function(person: string, person2: string) { ~~~~~~ -!!! error TS6133: 'person' is declared but never used. +!!! error TS6133: 'person' is declared but its value is never read. + ~~~~~~~ +!!! error TS6133: 'person2' is declared but its value is never read. var unused = 20; ~~~~~~ -!!! error TS6133: 'unused' is declared but never used. +!!! error TS6133: 'unused' is declared but its value is never read. person2 = "Dummy value"; } \ No newline at end of file diff --git a/tests/baselines/reference/unusedMultipleParameter2InContructor.errors.txt b/tests/baselines/reference/unusedMultipleParameter2InContructor.errors.txt index 9c28c969d3a..0279c8912f0 100644 --- a/tests/baselines/reference/unusedMultipleParameter2InContructor.errors.txt +++ b/tests/baselines/reference/unusedMultipleParameter2InContructor.errors.txt @@ -1,18 +1,21 @@ -tests/cases/compiler/unusedMultipleParameter2InContructor.ts(2,17): error TS6133: 'person' is declared but never used. -tests/cases/compiler/unusedMultipleParameter2InContructor.ts(2,50): error TS6133: 'person3' is declared but never used. -tests/cases/compiler/unusedMultipleParameter2InContructor.ts(3,13): error TS6133: 'unused' is declared but never used. +tests/cases/compiler/unusedMultipleParameter2InContructor.ts(2,17): error TS6133: 'person' is declared but its value is never read. +tests/cases/compiler/unusedMultipleParameter2InContructor.ts(2,33): error TS6133: 'person2' is declared but its value is never read. +tests/cases/compiler/unusedMultipleParameter2InContructor.ts(2,50): error TS6133: 'person3' is declared but its value is never read. +tests/cases/compiler/unusedMultipleParameter2InContructor.ts(3,13): error TS6133: 'unused' is declared but its value is never read. -==== tests/cases/compiler/unusedMultipleParameter2InContructor.ts (3 errors) ==== +==== tests/cases/compiler/unusedMultipleParameter2InContructor.ts (4 errors) ==== class Dummy { constructor(person: string, person2: string, person3: string) { ~~~~~~ -!!! error TS6133: 'person' is declared but never used. +!!! error TS6133: 'person' is declared but its value is never read. + ~~~~~~~ +!!! error TS6133: 'person2' is declared but its value is never read. ~~~~~~~ -!!! error TS6133: 'person3' is declared but never used. +!!! error TS6133: 'person3' is declared but its value is never read. var unused = 20; ~~~~~~ -!!! error TS6133: 'unused' is declared but never used. +!!! error TS6133: 'unused' is declared but its value is never read. person2 = "Dummy value"; } } \ No newline at end of file diff --git a/tests/baselines/reference/unusedMultipleParameter2InFunctionExpression.errors.txt b/tests/baselines/reference/unusedMultipleParameter2InFunctionExpression.errors.txt index 98bc39e16fb..a2dccf10132 100644 --- a/tests/baselines/reference/unusedMultipleParameter2InFunctionExpression.errors.txt +++ b/tests/baselines/reference/unusedMultipleParameter2InFunctionExpression.errors.txt @@ -1,16 +1,19 @@ -tests/cases/compiler/unusedMultipleParameter2InFunctionExpression.ts(1,21): error TS6133: 'person' is declared but never used. -tests/cases/compiler/unusedMultipleParameter2InFunctionExpression.ts(1,54): error TS6133: 'person3' is declared but never used. -tests/cases/compiler/unusedMultipleParameter2InFunctionExpression.ts(2,9): error TS6133: 'unused' is declared but never used. +tests/cases/compiler/unusedMultipleParameter2InFunctionExpression.ts(1,21): error TS6133: 'person' is declared but its value is never read. +tests/cases/compiler/unusedMultipleParameter2InFunctionExpression.ts(1,37): error TS6133: 'person2' is declared but its value is never read. +tests/cases/compiler/unusedMultipleParameter2InFunctionExpression.ts(1,54): error TS6133: 'person3' is declared but its value is never read. +tests/cases/compiler/unusedMultipleParameter2InFunctionExpression.ts(2,9): error TS6133: 'unused' is declared but its value is never read. -==== tests/cases/compiler/unusedMultipleParameter2InFunctionExpression.ts (3 errors) ==== +==== tests/cases/compiler/unusedMultipleParameter2InFunctionExpression.ts (4 errors) ==== var func = function(person: string, person2: string, person3: string) { ~~~~~~ -!!! error TS6133: 'person' is declared but never used. +!!! error TS6133: 'person' is declared but its value is never read. + ~~~~~~~ +!!! error TS6133: 'person2' is declared but its value is never read. ~~~~~~~ -!!! error TS6133: 'person3' is declared but never used. +!!! error TS6133: 'person3' is declared but its value is never read. var unused = 20; ~~~~~~ -!!! error TS6133: 'unused' is declared but never used. +!!! error TS6133: 'unused' is declared but its value is never read. person2 = "Dummy value"; } \ No newline at end of file diff --git a/tests/baselines/reference/unusedMultipleParameters1InFunctionDeclaration.errors.txt b/tests/baselines/reference/unusedMultipleParameters1InFunctionDeclaration.errors.txt index 38e6a8bbcd9..77dd37f96f9 100644 --- a/tests/baselines/reference/unusedMultipleParameters1InFunctionDeclaration.errors.txt +++ b/tests/baselines/reference/unusedMultipleParameters1InFunctionDeclaration.errors.txt @@ -1,13 +1,16 @@ -tests/cases/compiler/unusedMultipleParameters1InFunctionDeclaration.ts(1,18): error TS6133: 'person' is declared but never used. -tests/cases/compiler/unusedMultipleParameters1InFunctionDeclaration.ts(2,9): error TS6133: 'unused' is declared but never used. +tests/cases/compiler/unusedMultipleParameters1InFunctionDeclaration.ts(1,18): error TS6133: 'person' is declared but its value is never read. +tests/cases/compiler/unusedMultipleParameters1InFunctionDeclaration.ts(1,34): error TS6133: 'person2' is declared but its value is never read. +tests/cases/compiler/unusedMultipleParameters1InFunctionDeclaration.ts(2,9): error TS6133: 'unused' is declared but its value is never read. -==== tests/cases/compiler/unusedMultipleParameters1InFunctionDeclaration.ts (2 errors) ==== +==== tests/cases/compiler/unusedMultipleParameters1InFunctionDeclaration.ts (3 errors) ==== function greeter(person: string, person2: string) { ~~~~~~ -!!! error TS6133: 'person' is declared but never used. +!!! error TS6133: 'person' is declared but its value is never read. + ~~~~~~~ +!!! error TS6133: 'person2' is declared but its value is never read. var unused = 20; ~~~~~~ -!!! error TS6133: 'unused' is declared but never used. +!!! error TS6133: 'unused' is declared but its value is never read. person2 = "dummy value"; } \ No newline at end of file diff --git a/tests/baselines/reference/unusedMultipleParameters1InMethodDeclaration.errors.txt b/tests/baselines/reference/unusedMultipleParameters1InMethodDeclaration.errors.txt index e3e75de1fbd..58cfcee24dc 100644 --- a/tests/baselines/reference/unusedMultipleParameters1InMethodDeclaration.errors.txt +++ b/tests/baselines/reference/unusedMultipleParameters1InMethodDeclaration.errors.txt @@ -1,15 +1,18 @@ -tests/cases/compiler/unusedMultipleParameters1InMethodDeclaration.ts(2,20): error TS6133: 'person' is declared but never used. -tests/cases/compiler/unusedMultipleParameters1InMethodDeclaration.ts(3,13): error TS6133: 'unused' is declared but never used. +tests/cases/compiler/unusedMultipleParameters1InMethodDeclaration.ts(2,20): error TS6133: 'person' is declared but its value is never read. +tests/cases/compiler/unusedMultipleParameters1InMethodDeclaration.ts(2,36): error TS6133: 'person2' is declared but its value is never read. +tests/cases/compiler/unusedMultipleParameters1InMethodDeclaration.ts(3,13): error TS6133: 'unused' is declared but its value is never read. -==== tests/cases/compiler/unusedMultipleParameters1InMethodDeclaration.ts (2 errors) ==== +==== tests/cases/compiler/unusedMultipleParameters1InMethodDeclaration.ts (3 errors) ==== class Dummy { public greeter(person: string, person2: string) { ~~~~~~ -!!! error TS6133: 'person' is declared but never used. +!!! error TS6133: 'person' is declared but its value is never read. + ~~~~~~~ +!!! error TS6133: 'person2' is declared but its value is never read. var unused = 20; ~~~~~~ -!!! error TS6133: 'unused' is declared but never used. +!!! error TS6133: 'unused' is declared but its value is never read. person2 = "dummy value"; } } \ No newline at end of file diff --git a/tests/baselines/reference/unusedMultipleParameters2InFunctionDeclaration.errors.txt b/tests/baselines/reference/unusedMultipleParameters2InFunctionDeclaration.errors.txt index 39e21691460..6f34c67054f 100644 --- a/tests/baselines/reference/unusedMultipleParameters2InFunctionDeclaration.errors.txt +++ b/tests/baselines/reference/unusedMultipleParameters2InFunctionDeclaration.errors.txt @@ -1,16 +1,19 @@ -tests/cases/compiler/unusedMultipleParameters2InFunctionDeclaration.ts(1,18): error TS6133: 'person' is declared but never used. -tests/cases/compiler/unusedMultipleParameters2InFunctionDeclaration.ts(1,51): error TS6133: 'person3' is declared but never used. -tests/cases/compiler/unusedMultipleParameters2InFunctionDeclaration.ts(2,9): error TS6133: 'unused' is declared but never used. +tests/cases/compiler/unusedMultipleParameters2InFunctionDeclaration.ts(1,18): error TS6133: 'person' is declared but its value is never read. +tests/cases/compiler/unusedMultipleParameters2InFunctionDeclaration.ts(1,34): error TS6133: 'person2' is declared but its value is never read. +tests/cases/compiler/unusedMultipleParameters2InFunctionDeclaration.ts(1,51): error TS6133: 'person3' is declared but its value is never read. +tests/cases/compiler/unusedMultipleParameters2InFunctionDeclaration.ts(2,9): error TS6133: 'unused' is declared but its value is never read. -==== tests/cases/compiler/unusedMultipleParameters2InFunctionDeclaration.ts (3 errors) ==== +==== tests/cases/compiler/unusedMultipleParameters2InFunctionDeclaration.ts (4 errors) ==== function greeter(person: string, person2: string, person3: string) { ~~~~~~ -!!! error TS6133: 'person' is declared but never used. +!!! error TS6133: 'person' is declared but its value is never read. + ~~~~~~~ +!!! error TS6133: 'person2' is declared but its value is never read. ~~~~~~~ -!!! error TS6133: 'person3' is declared but never used. +!!! error TS6133: 'person3' is declared but its value is never read. var unused = 20; ~~~~~~ -!!! error TS6133: 'unused' is declared but never used. +!!! error TS6133: 'unused' is declared but its value is never read. person2 = "dummy value"; } \ No newline at end of file diff --git a/tests/baselines/reference/unusedMultipleParameters2InMethodDeclaration.errors.txt b/tests/baselines/reference/unusedMultipleParameters2InMethodDeclaration.errors.txt index 32496974c6b..6779fb83aec 100644 --- a/tests/baselines/reference/unusedMultipleParameters2InMethodDeclaration.errors.txt +++ b/tests/baselines/reference/unusedMultipleParameters2InMethodDeclaration.errors.txt @@ -1,18 +1,21 @@ -tests/cases/compiler/unusedMultipleParameters2InMethodDeclaration.ts(2,20): error TS6133: 'person' is declared but never used. -tests/cases/compiler/unusedMultipleParameters2InMethodDeclaration.ts(2,53): error TS6133: 'person3' is declared but never used. -tests/cases/compiler/unusedMultipleParameters2InMethodDeclaration.ts(3,13): error TS6133: 'unused' is declared but never used. +tests/cases/compiler/unusedMultipleParameters2InMethodDeclaration.ts(2,20): error TS6133: 'person' is declared but its value is never read. +tests/cases/compiler/unusedMultipleParameters2InMethodDeclaration.ts(2,36): error TS6133: 'person2' is declared but its value is never read. +tests/cases/compiler/unusedMultipleParameters2InMethodDeclaration.ts(2,53): error TS6133: 'person3' is declared but its value is never read. +tests/cases/compiler/unusedMultipleParameters2InMethodDeclaration.ts(3,13): error TS6133: 'unused' is declared but its value is never read. -==== tests/cases/compiler/unusedMultipleParameters2InMethodDeclaration.ts (3 errors) ==== +==== tests/cases/compiler/unusedMultipleParameters2InMethodDeclaration.ts (4 errors) ==== class Dummy { public greeter(person: string, person2: string, person3: string) { ~~~~~~ -!!! error TS6133: 'person' is declared but never used. +!!! error TS6133: 'person' is declared but its value is never read. + ~~~~~~~ +!!! error TS6133: 'person2' is declared but its value is never read. ~~~~~~~ -!!! error TS6133: 'person3' is declared but never used. +!!! error TS6133: 'person3' is declared but its value is never read. var unused = 20; ~~~~~~ -!!! error TS6133: 'unused' is declared but never used. +!!! error TS6133: 'unused' is declared but its value is never read. person2 = "dummy value"; } } \ No newline at end of file diff --git a/tests/baselines/reference/unusedNamespaceInModule.errors.txt b/tests/baselines/reference/unusedNamespaceInModule.errors.txt index 3d722a113ea..afc118b094a 100644 --- a/tests/baselines/reference/unusedNamespaceInModule.errors.txt +++ b/tests/baselines/reference/unusedNamespaceInModule.errors.txt @@ -1,10 +1,10 @@ -tests/cases/compiler/unusedNamespaceInModule.ts(2,15): error TS6133: 'B' is declared but never used. +tests/cases/compiler/unusedNamespaceInModule.ts(2,15): error TS6133: 'B' is declared but its value is never read. ==== tests/cases/compiler/unusedNamespaceInModule.ts (1 errors) ==== module A { namespace B { } ~ -!!! error TS6133: 'B' is declared but never used. +!!! error TS6133: 'B' is declared but its value is never read. export namespace C {} } \ No newline at end of file diff --git a/tests/baselines/reference/unusedNamespaceInNamespace.errors.txt b/tests/baselines/reference/unusedNamespaceInNamespace.errors.txt index 1bf7d15d3c2..ff031f5af41 100644 --- a/tests/baselines/reference/unusedNamespaceInNamespace.errors.txt +++ b/tests/baselines/reference/unusedNamespaceInNamespace.errors.txt @@ -1,10 +1,10 @@ -tests/cases/compiler/unusedNamespaceInNamespace.ts(2,15): error TS6133: 'B' is declared but never used. +tests/cases/compiler/unusedNamespaceInNamespace.ts(2,15): error TS6133: 'B' is declared but its value is never read. ==== tests/cases/compiler/unusedNamespaceInNamespace.ts (1 errors) ==== namespace A { namespace B { } ~ -!!! error TS6133: 'B' is declared but never used. +!!! error TS6133: 'B' is declared but its value is never read. export namespace C {} } \ No newline at end of file diff --git a/tests/baselines/reference/unusedParameterProperty1.errors.txt b/tests/baselines/reference/unusedParameterProperty1.errors.txt index fb400332c0d..ba9bb4af3ae 100644 --- a/tests/baselines/reference/unusedParameterProperty1.errors.txt +++ b/tests/baselines/reference/unusedParameterProperty1.errors.txt @@ -1,12 +1,15 @@ -tests/cases/compiler/unusedParameterProperty1.ts(2,25): error TS6138: Property 'used' is declared but never used. +tests/cases/compiler/unusedParameterProperty1.ts(2,25): error TS6138: Property 'used' is declared but its value is never read. +tests/cases/compiler/unusedParameterProperty1.ts(3,13): error TS6133: 'foge' is declared but its value is never read. -==== tests/cases/compiler/unusedParameterProperty1.ts (1 errors) ==== +==== tests/cases/compiler/unusedParameterProperty1.ts (2 errors) ==== class A { constructor(private used: string) { ~~~~ -!!! error TS6138: Property 'used' is declared but never used. +!!! error TS6138: Property 'used' is declared but its value is never read. let foge = used; + ~~~~ +!!! error TS6133: 'foge' is declared but its value is never read. foge += ""; } } diff --git a/tests/baselines/reference/unusedParameterProperty2.errors.txt b/tests/baselines/reference/unusedParameterProperty2.errors.txt index 9fa8c4c79f8..853b459c772 100644 --- a/tests/baselines/reference/unusedParameterProperty2.errors.txt +++ b/tests/baselines/reference/unusedParameterProperty2.errors.txt @@ -1,12 +1,15 @@ -tests/cases/compiler/unusedParameterProperty2.ts(2,25): error TS6138: Property 'used' is declared but never used. +tests/cases/compiler/unusedParameterProperty2.ts(2,25): error TS6138: Property 'used' is declared but its value is never read. +tests/cases/compiler/unusedParameterProperty2.ts(3,13): error TS6133: 'foge' is declared but its value is never read. -==== tests/cases/compiler/unusedParameterProperty2.ts (1 errors) ==== +==== tests/cases/compiler/unusedParameterProperty2.ts (2 errors) ==== class A { constructor(private used) { ~~~~ -!!! error TS6138: Property 'used' is declared but never used. +!!! error TS6138: Property 'used' is declared but its value is never read. let foge = used; + ~~~~ +!!! error TS6133: 'foge' is declared but its value is never read. foge += ""; } } diff --git a/tests/baselines/reference/unusedParameterUsedInTypeOf.js b/tests/baselines/reference/unusedParameterUsedInTypeOf.js index 544057eb4d1..42639a7398e 100644 --- a/tests/baselines/reference/unusedParameterUsedInTypeOf.js +++ b/tests/baselines/reference/unusedParameterUsedInTypeOf.js @@ -1,9 +1,9 @@ //// [unusedParameterUsedInTypeOf.ts] function f1 (a: number, b: typeof a) { - b++; + return b; } //// [unusedParameterUsedInTypeOf.js] function f1(a, b) { - b++; + return b; } diff --git a/tests/baselines/reference/unusedParameterUsedInTypeOf.symbols b/tests/baselines/reference/unusedParameterUsedInTypeOf.symbols index 9479eb8af01..c2bc4a126ef 100644 --- a/tests/baselines/reference/unusedParameterUsedInTypeOf.symbols +++ b/tests/baselines/reference/unusedParameterUsedInTypeOf.symbols @@ -5,6 +5,6 @@ function f1 (a: number, b: typeof a) { >b : Symbol(b, Decl(unusedParameterUsedInTypeOf.ts, 0, 23)) >a : Symbol(a, Decl(unusedParameterUsedInTypeOf.ts, 0, 13)) - b++; + return b; >b : Symbol(b, Decl(unusedParameterUsedInTypeOf.ts, 0, 23)) } diff --git a/tests/baselines/reference/unusedParameterUsedInTypeOf.types b/tests/baselines/reference/unusedParameterUsedInTypeOf.types index d8f181cc07b..8e0cef7962b 100644 --- a/tests/baselines/reference/unusedParameterUsedInTypeOf.types +++ b/tests/baselines/reference/unusedParameterUsedInTypeOf.types @@ -1,11 +1,10 @@ === tests/cases/compiler/unusedParameterUsedInTypeOf.ts === function f1 (a: number, b: typeof a) { ->f1 : (a: number, b: number) => void +>f1 : (a: number, b: number) => number >a : number >b : number >a : number - b++; ->b++ : number + return b; >b : number } diff --git a/tests/baselines/reference/unusedParametersInLambda1.errors.txt b/tests/baselines/reference/unusedParametersInLambda1.errors.txt index a5a58045c5a..94ca0e83cf9 100644 --- a/tests/baselines/reference/unusedParametersInLambda1.errors.txt +++ b/tests/baselines/reference/unusedParametersInLambda1.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/unusedParametersInLambda1.ts(3,17): error TS6133: 'X' is declared but never used. +tests/cases/compiler/unusedParametersInLambda1.ts(3,17): error TS6133: 'X' is declared but its value is never read. ==== tests/cases/compiler/unusedParametersInLambda1.ts (1 errors) ==== @@ -6,7 +6,7 @@ tests/cases/compiler/unusedParametersInLambda1.ts(3,17): error TS6133: 'X' is de public f1() { return (X) => { ~ -!!! error TS6133: 'X' is declared but never used. +!!! error TS6133: 'X' is declared but its value is never read. } } } \ No newline at end of file diff --git a/tests/baselines/reference/unusedParametersInLambda2.errors.txt b/tests/baselines/reference/unusedParametersInLambda2.errors.txt index 055e0cbeb63..16f4c3f2640 100644 --- a/tests/baselines/reference/unusedParametersInLambda2.errors.txt +++ b/tests/baselines/reference/unusedParametersInLambda2.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/unusedParametersInLambda2.ts(3,17): error TS6133: 'X' is declared but never used. +tests/cases/compiler/unusedParametersInLambda2.ts(3,17): error TS6133: 'X' is declared but its value is never read. ==== tests/cases/compiler/unusedParametersInLambda2.ts (1 errors) ==== @@ -6,7 +6,7 @@ tests/cases/compiler/unusedParametersInLambda2.ts(3,17): error TS6133: 'X' is de public f1() { return (X, Y) => { ~ -!!! error TS6133: 'X' is declared but never used. +!!! error TS6133: 'X' is declared but its value is never read. Y; } } diff --git a/tests/baselines/reference/unusedParametersWithUnderscore.errors.txt b/tests/baselines/reference/unusedParametersWithUnderscore.errors.txt index 136c3c0e367..841e8ec95fd 100644 --- a/tests/baselines/reference/unusedParametersWithUnderscore.errors.txt +++ b/tests/baselines/reference/unusedParametersWithUnderscore.errors.txt @@ -1,21 +1,21 @@ -tests/cases/compiler/unusedParametersWithUnderscore.ts(1,12): error TS6133: 'a' is declared but never used. -tests/cases/compiler/unusedParametersWithUnderscore.ts(1,19): error TS6133: 'c' is declared but never used. -tests/cases/compiler/unusedParametersWithUnderscore.ts(1,27): error TS6133: 'd' is declared but never used. -tests/cases/compiler/unusedParametersWithUnderscore.ts(1,29): error TS6133: 'e___' is declared but never used. -tests/cases/compiler/unusedParametersWithUnderscore.ts(11,16): error TS6133: 'arg' is declared but never used. -tests/cases/compiler/unusedParametersWithUnderscore.ts(17,13): error TS6133: 'arg' is declared but never used. +tests/cases/compiler/unusedParametersWithUnderscore.ts(1,12): error TS6133: 'a' is declared but its value is never read. +tests/cases/compiler/unusedParametersWithUnderscore.ts(1,19): error TS6133: 'c' is declared but its value is never read. +tests/cases/compiler/unusedParametersWithUnderscore.ts(1,27): error TS6133: 'd' is declared but its value is never read. +tests/cases/compiler/unusedParametersWithUnderscore.ts(1,29): error TS6133: 'e___' is declared but its value is never read. +tests/cases/compiler/unusedParametersWithUnderscore.ts(11,16): error TS6133: 'arg' is declared but its value is never read. +tests/cases/compiler/unusedParametersWithUnderscore.ts(17,13): error TS6133: 'arg' is declared but its value is never read. ==== tests/cases/compiler/unusedParametersWithUnderscore.ts (6 errors) ==== function f(a, _b, c, ___, d,e___, _f) { ~ -!!! error TS6133: 'a' is declared but never used. +!!! error TS6133: 'a' is declared but its value is never read. ~ -!!! error TS6133: 'c' is declared but never used. +!!! error TS6133: 'c' is declared but its value is never read. ~ -!!! error TS6133: 'd' is declared but never used. +!!! error TS6133: 'd' is declared but its value is never read. ~~~~ -!!! error TS6133: 'e___' is declared but never used. +!!! error TS6133: 'e___' is declared but its value is never read. } @@ -27,7 +27,7 @@ tests/cases/compiler/unusedParametersWithUnderscore.ts(17,13): error TS6133: 'ar function f4(...arg) { ~~~ -!!! error TS6133: 'arg' is declared but never used. +!!! error TS6133: 'arg' is declared but its value is never read. } function f5(..._arg) { @@ -35,7 +35,7 @@ tests/cases/compiler/unusedParametersWithUnderscore.ts(17,13): error TS6133: 'ar function f6(arg?, _arg?) { ~~~ -!!! error TS6133: 'arg' is declared but never used. +!!! error TS6133: 'arg' is declared but its value is never read. } var f7 = _ => undefined; diff --git a/tests/baselines/reference/unusedParametersinConstructor1.errors.txt b/tests/baselines/reference/unusedParametersinConstructor1.errors.txt index c505cc96f2f..a68bdccdc31 100644 --- a/tests/baselines/reference/unusedParametersinConstructor1.errors.txt +++ b/tests/baselines/reference/unusedParametersinConstructor1.errors.txt @@ -1,10 +1,10 @@ -tests/cases/compiler/unusedParametersinConstructor1.ts(2,17): error TS6133: 'param1' is declared but never used. +tests/cases/compiler/unusedParametersinConstructor1.ts(2,17): error TS6133: 'param1' is declared but its value is never read. ==== tests/cases/compiler/unusedParametersinConstructor1.ts (1 errors) ==== class greeter { constructor(param1: string) { ~~~~~~ -!!! error TS6133: 'param1' is declared but never used. +!!! error TS6133: 'param1' is declared but its value is never read. } } \ No newline at end of file diff --git a/tests/baselines/reference/unusedParametersinConstructor2.errors.txt b/tests/baselines/reference/unusedParametersinConstructor2.errors.txt index f1c7bf1b49a..67cf295edda 100644 --- a/tests/baselines/reference/unusedParametersinConstructor2.errors.txt +++ b/tests/baselines/reference/unusedParametersinConstructor2.errors.txt @@ -1,11 +1,11 @@ -tests/cases/compiler/unusedParametersinConstructor2.ts(2,17): error TS6133: 'param1' is declared but never used. +tests/cases/compiler/unusedParametersinConstructor2.ts(2,17): error TS6133: 'param1' is declared but its value is never read. ==== tests/cases/compiler/unusedParametersinConstructor2.ts (1 errors) ==== class greeter { constructor(param1: string, param2: string) { ~~~~~~ -!!! error TS6133: 'param1' is declared but never used. +!!! error TS6133: 'param1' is declared but its value is never read. param2 = param2 + "dummy value"; } } \ No newline at end of file diff --git a/tests/baselines/reference/unusedParametersinConstructor3.errors.txt b/tests/baselines/reference/unusedParametersinConstructor3.errors.txt index 1e79539d342..ca88555f45c 100644 --- a/tests/baselines/reference/unusedParametersinConstructor3.errors.txt +++ b/tests/baselines/reference/unusedParametersinConstructor3.errors.txt @@ -1,14 +1,14 @@ -tests/cases/compiler/unusedParametersinConstructor3.ts(2,17): error TS6133: 'param1' is declared but never used. -tests/cases/compiler/unusedParametersinConstructor3.ts(2,49): error TS6133: 'param3' is declared but never used. +tests/cases/compiler/unusedParametersinConstructor3.ts(2,17): error TS6133: 'param1' is declared but its value is never read. +tests/cases/compiler/unusedParametersinConstructor3.ts(2,49): error TS6133: 'param3' is declared but its value is never read. ==== tests/cases/compiler/unusedParametersinConstructor3.ts (2 errors) ==== class greeter { constructor(param1: string, param2: string, param3: string) { ~~~~~~ -!!! error TS6133: 'param1' is declared but never used. +!!! error TS6133: 'param1' is declared but its value is never read. ~~~~~~ -!!! error TS6133: 'param3' is declared but never used. +!!! error TS6133: 'param3' is declared but its value is never read. param2 = param2 + "dummy value"; } } \ No newline at end of file diff --git a/tests/baselines/reference/unusedPrivateMethodInClass1.errors.txt b/tests/baselines/reference/unusedPrivateMethodInClass1.errors.txt index 7271fd48d70..110155a2734 100644 --- a/tests/baselines/reference/unusedPrivateMethodInClass1.errors.txt +++ b/tests/baselines/reference/unusedPrivateMethodInClass1.errors.txt @@ -1,12 +1,15 @@ -tests/cases/compiler/unusedPrivateMethodInClass1.ts(2,13): error TS6133: 'function1' is declared but never used. +tests/cases/compiler/unusedPrivateMethodInClass1.ts(2,13): error TS6133: 'function1' is declared but its value is never read. +tests/cases/compiler/unusedPrivateMethodInClass1.ts(3,13): error TS6133: 'y' is declared but its value is never read. -==== tests/cases/compiler/unusedPrivateMethodInClass1.ts (1 errors) ==== +==== tests/cases/compiler/unusedPrivateMethodInClass1.ts (2 errors) ==== class greeter { private function1() { ~~~~~~~~~ -!!! error TS6133: 'function1' is declared but never used. +!!! error TS6133: 'function1' is declared but its value is never read. var y = 10; + ~ +!!! error TS6133: 'y' is declared but its value is never read. y++; } } \ No newline at end of file diff --git a/tests/baselines/reference/unusedPrivateMethodInClass2.errors.txt b/tests/baselines/reference/unusedPrivateMethodInClass2.errors.txt index ee52b95765f..16873219a6c 100644 --- a/tests/baselines/reference/unusedPrivateMethodInClass2.errors.txt +++ b/tests/baselines/reference/unusedPrivateMethodInClass2.errors.txt @@ -1,20 +1,26 @@ -tests/cases/compiler/unusedPrivateMethodInClass2.ts(2,13): error TS6133: 'function1' is declared but never used. -tests/cases/compiler/unusedPrivateMethodInClass2.ts(7,13): error TS6133: 'function2' is declared but never used. +tests/cases/compiler/unusedPrivateMethodInClass2.ts(2,13): error TS6133: 'function1' is declared but its value is never read. +tests/cases/compiler/unusedPrivateMethodInClass2.ts(3,13): error TS6133: 'y' is declared but its value is never read. +tests/cases/compiler/unusedPrivateMethodInClass2.ts(7,13): error TS6133: 'function2' is declared but its value is never read. +tests/cases/compiler/unusedPrivateMethodInClass2.ts(8,13): error TS6133: 'y' is declared but its value is never read. -==== tests/cases/compiler/unusedPrivateMethodInClass2.ts (2 errors) ==== +==== tests/cases/compiler/unusedPrivateMethodInClass2.ts (4 errors) ==== class greeter { private function1() { ~~~~~~~~~ -!!! error TS6133: 'function1' is declared but never used. +!!! error TS6133: 'function1' is declared but its value is never read. var y = 10; + ~ +!!! error TS6133: 'y' is declared but its value is never read. y++; } private function2() { ~~~~~~~~~ -!!! error TS6133: 'function2' is declared but never used. +!!! error TS6133: 'function2' is declared but its value is never read. var y = 10; + ~ +!!! error TS6133: 'y' is declared but its value is never read. y++; } } \ No newline at end of file diff --git a/tests/baselines/reference/unusedPrivateMethodInClass3.errors.txt b/tests/baselines/reference/unusedPrivateMethodInClass3.errors.txt index 87bc63dd87f..492492836d0 100644 --- a/tests/baselines/reference/unusedPrivateMethodInClass3.errors.txt +++ b/tests/baselines/reference/unusedPrivateMethodInClass3.errors.txt @@ -1,25 +1,34 @@ -tests/cases/compiler/unusedPrivateMethodInClass3.ts(2,13): error TS6133: 'function1' is declared but never used. -tests/cases/compiler/unusedPrivateMethodInClass3.ts(7,13): error TS6133: 'function2' is declared but never used. +tests/cases/compiler/unusedPrivateMethodInClass3.ts(2,13): error TS6133: 'function1' is declared but its value is never read. +tests/cases/compiler/unusedPrivateMethodInClass3.ts(3,13): error TS6133: 'y' is declared but its value is never read. +tests/cases/compiler/unusedPrivateMethodInClass3.ts(7,13): error TS6133: 'function2' is declared but its value is never read. +tests/cases/compiler/unusedPrivateMethodInClass3.ts(8,13): error TS6133: 'y' is declared but its value is never read. +tests/cases/compiler/unusedPrivateMethodInClass3.ts(13,13): error TS6133: 'y' is declared but its value is never read. -==== tests/cases/compiler/unusedPrivateMethodInClass3.ts (2 errors) ==== +==== tests/cases/compiler/unusedPrivateMethodInClass3.ts (5 errors) ==== class greeter { private function1() { ~~~~~~~~~ -!!! error TS6133: 'function1' is declared but never used. +!!! error TS6133: 'function1' is declared but its value is never read. var y = 10; + ~ +!!! error TS6133: 'y' is declared but its value is never read. y++; } private function2() { ~~~~~~~~~ -!!! error TS6133: 'function2' is declared but never used. +!!! error TS6133: 'function2' is declared but its value is never read. var y = 10; + ~ +!!! error TS6133: 'y' is declared but its value is never read. y++; } public function3() { var y = 10; + ~ +!!! error TS6133: 'y' is declared but its value is never read. y++; } } \ No newline at end of file diff --git a/tests/baselines/reference/unusedPrivateMethodInClass4.errors.txt b/tests/baselines/reference/unusedPrivateMethodInClass4.errors.txt index 8709a83374e..bcf8a5d25c7 100644 --- a/tests/baselines/reference/unusedPrivateMethodInClass4.errors.txt +++ b/tests/baselines/reference/unusedPrivateMethodInClass4.errors.txt @@ -1,22 +1,31 @@ -tests/cases/compiler/unusedPrivateMethodInClass4.ts(2,13): error TS6133: 'function1' is declared but never used. +tests/cases/compiler/unusedPrivateMethodInClass4.ts(2,13): error TS6133: 'function1' is declared but its value is never read. +tests/cases/compiler/unusedPrivateMethodInClass4.ts(3,13): error TS6133: 'y' is declared but its value is never read. +tests/cases/compiler/unusedPrivateMethodInClass4.ts(8,13): error TS6133: 'y' is declared but its value is never read. +tests/cases/compiler/unusedPrivateMethodInClass4.ts(13,13): error TS6133: 'y' is declared but its value is never read. -==== tests/cases/compiler/unusedPrivateMethodInClass4.ts (1 errors) ==== +==== tests/cases/compiler/unusedPrivateMethodInClass4.ts (4 errors) ==== class greeter { private function1() { ~~~~~~~~~ -!!! error TS6133: 'function1' is declared but never used. +!!! error TS6133: 'function1' is declared but its value is never read. var y = 10; + ~ +!!! error TS6133: 'y' is declared but its value is never read. y++; } private function2() { var y = 10; + ~ +!!! error TS6133: 'y' is declared but its value is never read. y++; } public function3() { var y = 10; + ~ +!!! error TS6133: 'y' is declared but its value is never read. y++; this.function2(); } diff --git a/tests/baselines/reference/unusedPrivateVariableInClass1.errors.txt b/tests/baselines/reference/unusedPrivateVariableInClass1.errors.txt index 68033811c15..08ebd8d1656 100644 --- a/tests/baselines/reference/unusedPrivateVariableInClass1.errors.txt +++ b/tests/baselines/reference/unusedPrivateVariableInClass1.errors.txt @@ -1,9 +1,9 @@ -tests/cases/compiler/unusedPrivateVariableInClass1.ts(2,13): error TS6133: 'x' is declared but never used. +tests/cases/compiler/unusedPrivateVariableInClass1.ts(2,13): error TS6133: 'x' is declared but its value is never read. ==== tests/cases/compiler/unusedPrivateVariableInClass1.ts (1 errors) ==== class greeter { private x: string; ~ -!!! error TS6133: 'x' is declared but never used. +!!! error TS6133: 'x' is declared but its value is never read. } \ No newline at end of file diff --git a/tests/baselines/reference/unusedPrivateVariableInClass2.errors.txt b/tests/baselines/reference/unusedPrivateVariableInClass2.errors.txt index 922263e0c5f..d13c7f0b6b5 100644 --- a/tests/baselines/reference/unusedPrivateVariableInClass2.errors.txt +++ b/tests/baselines/reference/unusedPrivateVariableInClass2.errors.txt @@ -1,13 +1,13 @@ -tests/cases/compiler/unusedPrivateVariableInClass2.ts(2,13): error TS6133: 'x' is declared but never used. -tests/cases/compiler/unusedPrivateVariableInClass2.ts(3,13): error TS6133: 'y' is declared but never used. +tests/cases/compiler/unusedPrivateVariableInClass2.ts(2,13): error TS6133: 'x' is declared but its value is never read. +tests/cases/compiler/unusedPrivateVariableInClass2.ts(3,13): error TS6133: 'y' is declared but its value is never read. ==== tests/cases/compiler/unusedPrivateVariableInClass2.ts (2 errors) ==== class greeter { private x: string; ~ -!!! error TS6133: 'x' is declared but never used. +!!! error TS6133: 'x' is declared but its value is never read. private y: string; ~ -!!! error TS6133: 'y' is declared but never used. +!!! error TS6133: 'y' is declared but its value is never read. } \ No newline at end of file diff --git a/tests/baselines/reference/unusedPrivateVariableInClass3.errors.txt b/tests/baselines/reference/unusedPrivateVariableInClass3.errors.txt index 686b5317436..ffa32a1c2c0 100644 --- a/tests/baselines/reference/unusedPrivateVariableInClass3.errors.txt +++ b/tests/baselines/reference/unusedPrivateVariableInClass3.errors.txt @@ -1,14 +1,14 @@ -tests/cases/compiler/unusedPrivateVariableInClass3.ts(2,13): error TS6133: 'x' is declared but never used. -tests/cases/compiler/unusedPrivateVariableInClass3.ts(3,13): error TS6133: 'y' is declared but never used. +tests/cases/compiler/unusedPrivateVariableInClass3.ts(2,13): error TS6133: 'x' is declared but its value is never read. +tests/cases/compiler/unusedPrivateVariableInClass3.ts(3,13): error TS6133: 'y' is declared but its value is never read. ==== tests/cases/compiler/unusedPrivateVariableInClass3.ts (2 errors) ==== class greeter { private x: string; ~ -!!! error TS6133: 'x' is declared but never used. +!!! error TS6133: 'x' is declared but its value is never read. private y: string; ~ -!!! error TS6133: 'y' is declared but never used. +!!! error TS6133: 'y' is declared but its value is never read. public z: string; } \ No newline at end of file diff --git a/tests/baselines/reference/unusedPrivateVariableInClass4.errors.txt b/tests/baselines/reference/unusedPrivateVariableInClass4.errors.txt index 5586b628c50..33c3f7237af 100644 --- a/tests/baselines/reference/unusedPrivateVariableInClass4.errors.txt +++ b/tests/baselines/reference/unusedPrivateVariableInClass4.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/unusedPrivateVariableInClass4.ts(3,13): error TS6133: 'y' is declared but never used. +tests/cases/compiler/unusedPrivateVariableInClass4.ts(3,13): error TS6133: 'y' is declared but its value is never read. ==== tests/cases/compiler/unusedPrivateVariableInClass4.ts (1 errors) ==== @@ -6,10 +6,10 @@ tests/cases/compiler/unusedPrivateVariableInClass4.ts(3,13): error TS6133: 'y' i private x: string; private y: string; ~ -!!! error TS6133: 'y' is declared but never used. +!!! error TS6133: 'y' is declared but its value is never read. public z: string; public method1() { - this.x = "dummy value"; + this.x; } } \ No newline at end of file diff --git a/tests/baselines/reference/unusedPrivateVariableInClass4.js b/tests/baselines/reference/unusedPrivateVariableInClass4.js index 21c910f702c..e782b0791aa 100644 --- a/tests/baselines/reference/unusedPrivateVariableInClass4.js +++ b/tests/baselines/reference/unusedPrivateVariableInClass4.js @@ -5,7 +5,7 @@ class greeter { public z: string; public method1() { - this.x = "dummy value"; + this.x; } } @@ -14,7 +14,7 @@ var greeter = /** @class */ (function () { function greeter() { } greeter.prototype.method1 = function () { - this.x = "dummy value"; + this.x; }; return greeter; }()); diff --git a/tests/baselines/reference/unusedPrivateVariableInClass5.errors.txt b/tests/baselines/reference/unusedPrivateVariableInClass5.errors.txt index 9379b84ce82..96c4f74f956 100644 --- a/tests/baselines/reference/unusedPrivateVariableInClass5.errors.txt +++ b/tests/baselines/reference/unusedPrivateVariableInClass5.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/unusedPrivateVariableInClass5.ts(3,13): error TS6133: 'y' is declared but never used. +tests/cases/compiler/unusedPrivateVariableInClass5.ts(3,13): error TS6133: 'y' is declared but its value is never read. ==== tests/cases/compiler/unusedPrivateVariableInClass5.ts (1 errors) ==== @@ -6,10 +6,10 @@ tests/cases/compiler/unusedPrivateVariableInClass5.ts(3,13): error TS6133: 'y' i private x: string; private y: string; ~ -!!! error TS6133: 'y' is declared but never used. +!!! error TS6133: 'y' is declared but its value is never read. public z: string; constructor() { - this.x = "dummy value"; + this.x; } } \ No newline at end of file diff --git a/tests/baselines/reference/unusedPrivateVariableInClass5.js b/tests/baselines/reference/unusedPrivateVariableInClass5.js index a0ad7bf0021..4d000350197 100644 --- a/tests/baselines/reference/unusedPrivateVariableInClass5.js +++ b/tests/baselines/reference/unusedPrivateVariableInClass5.js @@ -5,14 +5,14 @@ class greeter { public z: string; constructor() { - this.x = "dummy value"; + this.x; } } //// [unusedPrivateVariableInClass5.js] var greeter = /** @class */ (function () { function greeter() { - this.x = "dummy value"; + this.x; } return greeter; }()); diff --git a/tests/baselines/reference/unusedSetterInClass.errors.txt b/tests/baselines/reference/unusedSetterInClass.errors.txt new file mode 100644 index 00000000000..d7cd764b293 --- /dev/null +++ b/tests/baselines/reference/unusedSetterInClass.errors.txt @@ -0,0 +1,13 @@ +tests/cases/compiler/unusedSetterInClass.ts(2,13): error TS6133: '_fullName' is declared but its value is never read. + + +==== tests/cases/compiler/unusedSetterInClass.ts (1 errors) ==== + class Employee { + private _fullName: string; + ~~~~~~~~~ +!!! error TS6133: '_fullName' is declared but its value is never read. + + set fullName(newName: string) { + this._fullName = newName; + } + } \ No newline at end of file diff --git a/tests/baselines/reference/unusedSingleParameterInContructor.errors.txt b/tests/baselines/reference/unusedSingleParameterInContructor.errors.txt index c963394abca..7a8976b664d 100644 --- a/tests/baselines/reference/unusedSingleParameterInContructor.errors.txt +++ b/tests/baselines/reference/unusedSingleParameterInContructor.errors.txt @@ -1,14 +1,14 @@ -tests/cases/compiler/unusedSingleParameterInContructor.ts(2,17): error TS6133: 'person' is declared but never used. -tests/cases/compiler/unusedSingleParameterInContructor.ts(3,13): error TS6133: 'unused' is declared but never used. +tests/cases/compiler/unusedSingleParameterInContructor.ts(2,17): error TS6133: 'person' is declared but its value is never read. +tests/cases/compiler/unusedSingleParameterInContructor.ts(3,13): error TS6133: 'unused' is declared but its value is never read. ==== tests/cases/compiler/unusedSingleParameterInContructor.ts (2 errors) ==== class Dummy { constructor(person: string) { ~~~~~~ -!!! error TS6133: 'person' is declared but never used. +!!! error TS6133: 'person' is declared but its value is never read. var unused = 20; ~~~~~~ -!!! error TS6133: 'unused' is declared but never used. +!!! error TS6133: 'unused' is declared but its value is never read. } } \ No newline at end of file diff --git a/tests/baselines/reference/unusedSingleParameterInFunctionDeclaration.errors.txt b/tests/baselines/reference/unusedSingleParameterInFunctionDeclaration.errors.txt index 374f963802f..f02dc30f455 100644 --- a/tests/baselines/reference/unusedSingleParameterInFunctionDeclaration.errors.txt +++ b/tests/baselines/reference/unusedSingleParameterInFunctionDeclaration.errors.txt @@ -1,12 +1,12 @@ -tests/cases/compiler/unusedSingleParameterInFunctionDeclaration.ts(1,18): error TS6133: 'person' is declared but never used. -tests/cases/compiler/unusedSingleParameterInFunctionDeclaration.ts(2,9): error TS6133: 'unused' is declared but never used. +tests/cases/compiler/unusedSingleParameterInFunctionDeclaration.ts(1,18): error TS6133: 'person' is declared but its value is never read. +tests/cases/compiler/unusedSingleParameterInFunctionDeclaration.ts(2,9): error TS6133: 'unused' is declared but its value is never read. ==== tests/cases/compiler/unusedSingleParameterInFunctionDeclaration.ts (2 errors) ==== function greeter(person: string) { ~~~~~~ -!!! error TS6133: 'person' is declared but never used. +!!! error TS6133: 'person' is declared but its value is never read. var unused = 20; ~~~~~~ -!!! error TS6133: 'unused' is declared but never used. +!!! error TS6133: 'unused' is declared but its value is never read. } \ No newline at end of file diff --git a/tests/baselines/reference/unusedSingleParameterInFunctionExpression.errors.txt b/tests/baselines/reference/unusedSingleParameterInFunctionExpression.errors.txt index 4adb424b3d4..a63003422ca 100644 --- a/tests/baselines/reference/unusedSingleParameterInFunctionExpression.errors.txt +++ b/tests/baselines/reference/unusedSingleParameterInFunctionExpression.errors.txt @@ -1,12 +1,12 @@ -tests/cases/compiler/unusedSingleParameterInFunctionExpression.ts(1,21): error TS6133: 'person' is declared but never used. -tests/cases/compiler/unusedSingleParameterInFunctionExpression.ts(2,9): error TS6133: 'unused' is declared but never used. +tests/cases/compiler/unusedSingleParameterInFunctionExpression.ts(1,21): error TS6133: 'person' is declared but its value is never read. +tests/cases/compiler/unusedSingleParameterInFunctionExpression.ts(2,9): error TS6133: 'unused' is declared but its value is never read. ==== tests/cases/compiler/unusedSingleParameterInFunctionExpression.ts (2 errors) ==== var func = function(person: string) { ~~~~~~ -!!! error TS6133: 'person' is declared but never used. +!!! error TS6133: 'person' is declared but its value is never read. var unused = 20; ~~~~~~ -!!! error TS6133: 'unused' is declared but never used. +!!! error TS6133: 'unused' is declared but its value is never read. } \ No newline at end of file diff --git a/tests/baselines/reference/unusedSingleParameterInMethodDeclaration.errors.txt b/tests/baselines/reference/unusedSingleParameterInMethodDeclaration.errors.txt index 903e4d87668..717b41e4d2a 100644 --- a/tests/baselines/reference/unusedSingleParameterInMethodDeclaration.errors.txt +++ b/tests/baselines/reference/unusedSingleParameterInMethodDeclaration.errors.txt @@ -1,14 +1,14 @@ -tests/cases/compiler/unusedSingleParameterInMethodDeclaration.ts(2,20): error TS6133: 'person' is declared but never used. -tests/cases/compiler/unusedSingleParameterInMethodDeclaration.ts(3,13): error TS6133: 'unused' is declared but never used. +tests/cases/compiler/unusedSingleParameterInMethodDeclaration.ts(2,20): error TS6133: 'person' is declared but its value is never read. +tests/cases/compiler/unusedSingleParameterInMethodDeclaration.ts(3,13): error TS6133: 'unused' is declared but its value is never read. ==== tests/cases/compiler/unusedSingleParameterInMethodDeclaration.ts (2 errors) ==== class Dummy { public greeter(person: string) { ~~~~~~ -!!! error TS6133: 'person' is declared but never used. +!!! error TS6133: 'person' is declared but its value is never read. var unused = 20; ~~~~~~ -!!! error TS6133: 'unused' is declared but never used. +!!! error TS6133: 'unused' is declared but its value is never read. } } \ No newline at end of file diff --git a/tests/baselines/reference/unusedSwitchStatment.errors.txt b/tests/baselines/reference/unusedSwitchStatment.errors.txt index f47cad32eba..29dc18b5d9a 100644 --- a/tests/baselines/reference/unusedSwitchStatment.errors.txt +++ b/tests/baselines/reference/unusedSwitchStatment.errors.txt @@ -1,29 +1,30 @@ tests/cases/compiler/unusedSwitchStatment.ts(2,10): error TS2678: Type '0' is not comparable to type '1'. -tests/cases/compiler/unusedSwitchStatment.ts(3,13): error TS6133: 'x' is declared but never used. -tests/cases/compiler/unusedSwitchStatment.ts(6,15): error TS6133: 'c' is declared but never used. -tests/cases/compiler/unusedSwitchStatment.ts(9,13): error TS6133: 'z' is declared but never used. +tests/cases/compiler/unusedSwitchStatment.ts(3,13): error TS6133: 'x' is declared but its value is never read. +tests/cases/compiler/unusedSwitchStatment.ts(6,15): error TS6133: 'c' is declared but its value is never read. +tests/cases/compiler/unusedSwitchStatment.ts(9,13): error TS6133: 'z' is declared but its value is never read. tests/cases/compiler/unusedSwitchStatment.ts(14,10): error TS2678: Type '0' is not comparable to type '2'. +tests/cases/compiler/unusedSwitchStatment.ts(15,13): error TS6133: 'x' is declared but its value is never read. tests/cases/compiler/unusedSwitchStatment.ts(16,10): error TS2678: Type '1' is not comparable to type '2'. -==== tests/cases/compiler/unusedSwitchStatment.ts (6 errors) ==== +==== tests/cases/compiler/unusedSwitchStatment.ts (7 errors) ==== switch (1) { case 0: ~ !!! error TS2678: Type '0' is not comparable to type '1'. let x; ~ -!!! error TS6133: 'x' is declared but never used. +!!! error TS6133: 'x' is declared but its value is never read. break; case 1: const c = 1; ~ -!!! error TS6133: 'c' is declared but never used. +!!! error TS6133: 'c' is declared but its value is never read. break; default: let z = 2; ~ -!!! error TS6133: 'z' is declared but never used. +!!! error TS6133: 'z' is declared but its value is never read. } @@ -32,6 +33,8 @@ tests/cases/compiler/unusedSwitchStatment.ts(16,10): error TS2678: Type '1' is n ~ !!! error TS2678: Type '0' is not comparable to type '2'. let x; + ~ +!!! error TS6133: 'x' is declared but its value is never read. case 1: ~ !!! error TS2678: Type '1' is not comparable to type '2'. diff --git a/tests/baselines/reference/unusedTypeParameterInFunction1.errors.txt b/tests/baselines/reference/unusedTypeParameterInFunction1.errors.txt index 7ecdae21390..93af5cf16b6 100644 --- a/tests/baselines/reference/unusedTypeParameterInFunction1.errors.txt +++ b/tests/baselines/reference/unusedTypeParameterInFunction1.errors.txt @@ -1,9 +1,9 @@ -tests/cases/compiler/unusedTypeParameterInFunction1.ts(1,13): error TS6133: 'T' is declared but never used. +tests/cases/compiler/unusedTypeParameterInFunction1.ts(1,13): error TS6133: 'T' is declared but its value is never read. ==== tests/cases/compiler/unusedTypeParameterInFunction1.ts (1 errors) ==== function f1() { ~ -!!! error TS6133: 'T' is declared but never used. +!!! error TS6133: 'T' is declared but its value is never read. } \ No newline at end of file diff --git a/tests/baselines/reference/unusedTypeParameterInFunction2.errors.txt b/tests/baselines/reference/unusedTypeParameterInFunction2.errors.txt index 06926092f2b..848f242be19 100644 --- a/tests/baselines/reference/unusedTypeParameterInFunction2.errors.txt +++ b/tests/baselines/reference/unusedTypeParameterInFunction2.errors.txt @@ -1,10 +1,10 @@ -tests/cases/compiler/unusedTypeParameterInFunction2.ts(1,16): error TS6133: 'Y' is declared but never used. +tests/cases/compiler/unusedTypeParameterInFunction2.ts(1,16): error TS6133: 'Y' is declared but its value is never read. ==== tests/cases/compiler/unusedTypeParameterInFunction2.ts (1 errors) ==== function f1() { ~ -!!! error TS6133: 'Y' is declared but never used. +!!! error TS6133: 'Y' is declared but its value is never read. var a: X; a; } \ No newline at end of file diff --git a/tests/baselines/reference/unusedTypeParameterInFunction3.errors.txt b/tests/baselines/reference/unusedTypeParameterInFunction3.errors.txt index 5eb2f012f5e..3acdc7b523b 100644 --- a/tests/baselines/reference/unusedTypeParameterInFunction3.errors.txt +++ b/tests/baselines/reference/unusedTypeParameterInFunction3.errors.txt @@ -1,10 +1,10 @@ -tests/cases/compiler/unusedTypeParameterInFunction3.ts(1,16): error TS6133: 'Y' is declared but never used. +tests/cases/compiler/unusedTypeParameterInFunction3.ts(1,16): error TS6133: 'Y' is declared but its value is never read. ==== tests/cases/compiler/unusedTypeParameterInFunction3.ts (1 errors) ==== function f1() { ~ -!!! error TS6133: 'Y' is declared but never used. +!!! error TS6133: 'Y' is declared but its value is never read. var a: X; var b: Z; a; diff --git a/tests/baselines/reference/unusedTypeParameterInFunction4.errors.txt b/tests/baselines/reference/unusedTypeParameterInFunction4.errors.txt index 7ff8090f3c3..82eaffa100a 100644 --- a/tests/baselines/reference/unusedTypeParameterInFunction4.errors.txt +++ b/tests/baselines/reference/unusedTypeParameterInFunction4.errors.txt @@ -1,10 +1,10 @@ -tests/cases/compiler/unusedTypeParameterInFunction4.ts(1,13): error TS6133: 'X' is declared but never used. +tests/cases/compiler/unusedTypeParameterInFunction4.ts(1,13): error TS6133: 'X' is declared but its value is never read. ==== tests/cases/compiler/unusedTypeParameterInFunction4.ts (1 errors) ==== function f1() { ~ -!!! error TS6133: 'X' is declared but never used. +!!! error TS6133: 'X' is declared but its value is never read. var a: Y; var b: Z; a; diff --git a/tests/baselines/reference/unusedTypeParameterInInterface1.errors.txt b/tests/baselines/reference/unusedTypeParameterInInterface1.errors.txt index d1aa6fc03da..f0796d8fcd7 100644 --- a/tests/baselines/reference/unusedTypeParameterInInterface1.errors.txt +++ b/tests/baselines/reference/unusedTypeParameterInInterface1.errors.txt @@ -1,9 +1,9 @@ -tests/cases/compiler/unusedTypeParameterInInterface1.ts(1,15): error TS6133: 'T' is declared but never used. +tests/cases/compiler/unusedTypeParameterInInterface1.ts(1,15): error TS6133: 'T' is declared but its value is never read. ==== tests/cases/compiler/unusedTypeParameterInInterface1.ts (1 errors) ==== interface int { ~ -!!! error TS6133: 'T' is declared but never used. +!!! error TS6133: 'T' is declared but its value is never read. } \ No newline at end of file diff --git a/tests/baselines/reference/unusedTypeParameterInInterface2.errors.txt b/tests/baselines/reference/unusedTypeParameterInInterface2.errors.txt index c36cffdca41..1fa66c920a8 100644 --- a/tests/baselines/reference/unusedTypeParameterInInterface2.errors.txt +++ b/tests/baselines/reference/unusedTypeParameterInInterface2.errors.txt @@ -1,10 +1,10 @@ -tests/cases/compiler/unusedTypeParameterInInterface2.ts(1,18): error TS6133: 'U' is declared but never used. +tests/cases/compiler/unusedTypeParameterInInterface2.ts(1,18): error TS6133: 'U' is declared but its value is never read. ==== tests/cases/compiler/unusedTypeParameterInInterface2.ts (1 errors) ==== interface int { ~ -!!! error TS6133: 'U' is declared but never used. +!!! error TS6133: 'U' is declared but its value is never read. f1(a: T): string; c: V; } \ No newline at end of file diff --git a/tests/baselines/reference/unusedTypeParameterInLambda1.errors.txt b/tests/baselines/reference/unusedTypeParameterInLambda1.errors.txt index 687e0809f97..144ee86a0f5 100644 --- a/tests/baselines/reference/unusedTypeParameterInLambda1.errors.txt +++ b/tests/baselines/reference/unusedTypeParameterInLambda1.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/unusedTypeParameterInLambda1.ts(3,17): error TS6133: 'T' is declared but never used. +tests/cases/compiler/unusedTypeParameterInLambda1.ts(3,17): error TS6133: 'T' is declared but its value is never read. ==== tests/cases/compiler/unusedTypeParameterInLambda1.ts (1 errors) ==== @@ -6,7 +6,7 @@ tests/cases/compiler/unusedTypeParameterInLambda1.ts(3,17): error TS6133: 'T' is public f1() { return () => { ~ -!!! error TS6133: 'T' is declared but never used. +!!! error TS6133: 'T' is declared but its value is never read. } } diff --git a/tests/baselines/reference/unusedTypeParameterInLambda2.errors.txt b/tests/baselines/reference/unusedTypeParameterInLambda2.errors.txt index bdadc908059..c185808338e 100644 --- a/tests/baselines/reference/unusedTypeParameterInLambda2.errors.txt +++ b/tests/baselines/reference/unusedTypeParameterInLambda2.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/unusedTypeParameterInLambda2.ts(3,17): error TS6133: 'T' is declared but never used. +tests/cases/compiler/unusedTypeParameterInLambda2.ts(3,17): error TS6133: 'T' is declared but its value is never read. ==== tests/cases/compiler/unusedTypeParameterInLambda2.ts (1 errors) ==== @@ -6,7 +6,7 @@ tests/cases/compiler/unusedTypeParameterInLambda2.ts(3,17): error TS6133: 'T' is public f1() { return () => { ~ -!!! error TS6133: 'T' is declared but never used. +!!! error TS6133: 'T' is declared but its value is never read. var a: X; a; } diff --git a/tests/baselines/reference/unusedTypeParameterInLambda3.errors.txt b/tests/baselines/reference/unusedTypeParameterInLambda3.errors.txt index 5477f611e72..8b6f98ef681 100644 --- a/tests/baselines/reference/unusedTypeParameterInLambda3.errors.txt +++ b/tests/baselines/reference/unusedTypeParameterInLambda3.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/unusedTypeParameterInLambda3.ts(5,15): error TS6133: 'U' is declared but never used. +tests/cases/compiler/unusedTypeParameterInLambda3.ts(5,15): error TS6133: 'U' is declared but its value is never read. ==== tests/cases/compiler/unusedTypeParameterInLambda3.ts (1 errors) ==== @@ -8,5 +8,5 @@ tests/cases/compiler/unusedTypeParameterInLambda3.ts(5,15): error TS6133: 'U' is var y: new (a:T)=>void; ~ -!!! error TS6133: 'U' is declared but never used. +!!! error TS6133: 'U' is declared but its value is never read. \ No newline at end of file diff --git a/tests/baselines/reference/unusedTypeParameterInMethod1.errors.txt b/tests/baselines/reference/unusedTypeParameterInMethod1.errors.txt index eab59fddec2..dcf6fda8254 100644 --- a/tests/baselines/reference/unusedTypeParameterInMethod1.errors.txt +++ b/tests/baselines/reference/unusedTypeParameterInMethod1.errors.txt @@ -1,11 +1,11 @@ -tests/cases/compiler/unusedTypeParameterInMethod1.ts(2,15): error TS6133: 'X' is declared but never used. +tests/cases/compiler/unusedTypeParameterInMethod1.ts(2,15): error TS6133: 'X' is declared but its value is never read. ==== tests/cases/compiler/unusedTypeParameterInMethod1.ts (1 errors) ==== class A { public f1() { ~ -!!! error TS6133: 'X' is declared but never used. +!!! error TS6133: 'X' is declared but its value is never read. var a: Y; var b: Z; a; diff --git a/tests/baselines/reference/unusedTypeParameterInMethod2.errors.txt b/tests/baselines/reference/unusedTypeParameterInMethod2.errors.txt index 219d5f99e61..9e5936a2bc4 100644 --- a/tests/baselines/reference/unusedTypeParameterInMethod2.errors.txt +++ b/tests/baselines/reference/unusedTypeParameterInMethod2.errors.txt @@ -1,11 +1,11 @@ -tests/cases/compiler/unusedTypeParameterInMethod2.ts(2,18): error TS6133: 'Y' is declared but never used. +tests/cases/compiler/unusedTypeParameterInMethod2.ts(2,18): error TS6133: 'Y' is declared but its value is never read. ==== tests/cases/compiler/unusedTypeParameterInMethod2.ts (1 errors) ==== class A { public f1() { ~ -!!! error TS6133: 'Y' is declared but never used. +!!! error TS6133: 'Y' is declared but its value is never read. var a: X; var b: Z; a; diff --git a/tests/baselines/reference/unusedTypeParameterInMethod3.errors.txt b/tests/baselines/reference/unusedTypeParameterInMethod3.errors.txt index f9257169897..102cd56f281 100644 --- a/tests/baselines/reference/unusedTypeParameterInMethod3.errors.txt +++ b/tests/baselines/reference/unusedTypeParameterInMethod3.errors.txt @@ -1,11 +1,11 @@ -tests/cases/compiler/unusedTypeParameterInMethod3.ts(2,21): error TS6133: 'Z' is declared but never used. +tests/cases/compiler/unusedTypeParameterInMethod3.ts(2,21): error TS6133: 'Z' is declared but its value is never read. ==== tests/cases/compiler/unusedTypeParameterInMethod3.ts (1 errors) ==== class A { public f1() { ~ -!!! error TS6133: 'Z' is declared but never used. +!!! error TS6133: 'Z' is declared but its value is never read. var a: X; var b: Y; a; diff --git a/tests/baselines/reference/unusedTypeParameterInMethod4.errors.txt b/tests/baselines/reference/unusedTypeParameterInMethod4.errors.txt index ab2dbbc868e..bb121372e91 100644 --- a/tests/baselines/reference/unusedTypeParameterInMethod4.errors.txt +++ b/tests/baselines/reference/unusedTypeParameterInMethod4.errors.txt @@ -1,11 +1,11 @@ -tests/cases/compiler/unusedTypeParameterInMethod4.ts(2,15): error TS6133: 'X' is declared but never used. +tests/cases/compiler/unusedTypeParameterInMethod4.ts(2,15): error TS6133: 'X' is declared but its value is never read. ==== tests/cases/compiler/unusedTypeParameterInMethod4.ts (1 errors) ==== class A { public f1() { ~ -!!! error TS6133: 'X' is declared but never used. +!!! error TS6133: 'X' is declared but its value is never read. } } \ No newline at end of file diff --git a/tests/baselines/reference/unusedTypeParameterInMethod5.errors.txt b/tests/baselines/reference/unusedTypeParameterInMethod5.errors.txt index 6bc5f88407c..7afa26fd323 100644 --- a/tests/baselines/reference/unusedTypeParameterInMethod5.errors.txt +++ b/tests/baselines/reference/unusedTypeParameterInMethod5.errors.txt @@ -1,11 +1,11 @@ -tests/cases/compiler/unusedTypeParameterInMethod5.ts(2,26): error TS6133: 'X' is declared but never used. +tests/cases/compiler/unusedTypeParameterInMethod5.ts(2,26): error TS6133: 'X' is declared but its value is never read. ==== tests/cases/compiler/unusedTypeParameterInMethod5.ts (1 errors) ==== class A { public f1 = function() { ~ -!!! error TS6133: 'X' is declared but never used. +!!! error TS6133: 'X' is declared but its value is never read. } } \ No newline at end of file diff --git a/tests/baselines/reference/unusedTypeParameters1.errors.txt b/tests/baselines/reference/unusedTypeParameters1.errors.txt index 0868ebbe9be..3a6222497f0 100644 --- a/tests/baselines/reference/unusedTypeParameters1.errors.txt +++ b/tests/baselines/reference/unusedTypeParameters1.errors.txt @@ -1,9 +1,9 @@ -tests/cases/compiler/unusedTypeParameters1.ts(1,15): error TS6133: 'typeparameter1' is declared but never used. +tests/cases/compiler/unusedTypeParameters1.ts(1,15): error TS6133: 'typeparameter1' is declared but its value is never read. ==== tests/cases/compiler/unusedTypeParameters1.ts (1 errors) ==== class greeter { ~~~~~~~~~~~~~~ -!!! error TS6133: 'typeparameter1' is declared but never used. +!!! error TS6133: 'typeparameter1' is declared but its value is never read. } \ No newline at end of file diff --git a/tests/baselines/reference/unusedTypeParameters10.errors.txt b/tests/baselines/reference/unusedTypeParameters10.errors.txt index 7bfd5676df3..2e76b39ab96 100644 --- a/tests/baselines/reference/unusedTypeParameters10.errors.txt +++ b/tests/baselines/reference/unusedTypeParameters10.errors.txt @@ -1,9 +1,9 @@ -tests/cases/compiler/unusedTypeParameters10.ts(1,12): error TS6133: 'T' is declared but never used. +tests/cases/compiler/unusedTypeParameters10.ts(1,12): error TS6133: 'T' is declared but its value is never read. ==== tests/cases/compiler/unusedTypeParameters10.ts (1 errors) ==== type Alias = { }; ~ -!!! error TS6133: 'T' is declared but never used. +!!! error TS6133: 'T' is declared but its value is never read. type Alias2 = { x: T }; \ No newline at end of file diff --git a/tests/baselines/reference/unusedTypeParameters2.errors.txt b/tests/baselines/reference/unusedTypeParameters2.errors.txt index 97335fc6ecf..0ce28313c75 100644 --- a/tests/baselines/reference/unusedTypeParameters2.errors.txt +++ b/tests/baselines/reference/unusedTypeParameters2.errors.txt @@ -1,10 +1,10 @@ -tests/cases/compiler/unusedTypeParameters2.ts(1,15): error TS6133: 'typeparameter1' is declared but never used. +tests/cases/compiler/unusedTypeParameters2.ts(1,15): error TS6133: 'typeparameter1' is declared but its value is never read. ==== tests/cases/compiler/unusedTypeParameters2.ts (1 errors) ==== class greeter { ~~~~~~~~~~~~~~ -!!! error TS6133: 'typeparameter1' is declared but never used. +!!! error TS6133: 'typeparameter1' is declared but its value is never read. private x: typeparameter2; public function1() { diff --git a/tests/baselines/reference/unusedTypeParameters3.errors.txt b/tests/baselines/reference/unusedTypeParameters3.errors.txt index 31840f2cc42..6f5797365a2 100644 --- a/tests/baselines/reference/unusedTypeParameters3.errors.txt +++ b/tests/baselines/reference/unusedTypeParameters3.errors.txt @@ -1,13 +1,13 @@ -tests/cases/compiler/unusedTypeParameters3.ts(1,15): error TS6133: 'typeparameter1' is declared but never used. -tests/cases/compiler/unusedTypeParameters3.ts(1,47): error TS6133: 'typeparameter3' is declared but never used. +tests/cases/compiler/unusedTypeParameters3.ts(1,15): error TS6133: 'typeparameter1' is declared but its value is never read. +tests/cases/compiler/unusedTypeParameters3.ts(1,47): error TS6133: 'typeparameter3' is declared but its value is never read. ==== tests/cases/compiler/unusedTypeParameters3.ts (2 errors) ==== class greeter { ~~~~~~~~~~~~~~ -!!! error TS6133: 'typeparameter1' is declared but never used. +!!! error TS6133: 'typeparameter1' is declared but its value is never read. ~~~~~~~~~~~~~~ -!!! error TS6133: 'typeparameter3' is declared but never used. +!!! error TS6133: 'typeparameter3' is declared but its value is never read. private x: typeparameter2; public function1() { diff --git a/tests/baselines/reference/unusedTypeParameters4.errors.txt b/tests/baselines/reference/unusedTypeParameters4.errors.txt index 149c764895c..3e56c270f43 100644 --- a/tests/baselines/reference/unusedTypeParameters4.errors.txt +++ b/tests/baselines/reference/unusedTypeParameters4.errors.txt @@ -1,9 +1,9 @@ -tests/cases/compiler/unusedTypeParameters4.ts(2,13): error TS6133: 'U' is declared but never used. +tests/cases/compiler/unusedTypeParameters4.ts(2,13): error TS6133: 'U' is declared but its value is never read. ==== tests/cases/compiler/unusedTypeParameters4.ts (1 errors) ==== var x: { new (a: T): void; ~ -!!! error TS6133: 'U' is declared but never used. +!!! error TS6133: 'U' is declared but its value is never read. } \ No newline at end of file diff --git a/tests/baselines/reference/unusedTypeParameters5.errors.txt b/tests/baselines/reference/unusedTypeParameters5.errors.txt index ed19d33fd97..069caedf0dd 100644 --- a/tests/baselines/reference/unusedTypeParameters5.errors.txt +++ b/tests/baselines/reference/unusedTypeParameters5.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/unusedTypeParameters5.ts(6,16): error TS6133: 'K' is declared but never used. +tests/cases/compiler/unusedTypeParameters5.ts(6,16): error TS6133: 'K' is declared but its value is never read. ==== tests/cases/compiler/unusedTypeParameters5.ts (1 errors) ==== @@ -9,5 +9,5 @@ tests/cases/compiler/unusedTypeParameters5.ts(6,16): error TS6133: 'K' is declar var x: { new (a: T): A; ~ -!!! error TS6133: 'K' is declared but never used. +!!! error TS6133: 'K' is declared but its value is never read. } \ No newline at end of file diff --git a/tests/baselines/reference/unusedTypeParameters8.errors.txt b/tests/baselines/reference/unusedTypeParameters8.errors.txt index 5b466a9b806..e1381ec0002 100644 --- a/tests/baselines/reference/unusedTypeParameters8.errors.txt +++ b/tests/baselines/reference/unusedTypeParameters8.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/b.ts(1,13): error TS6133: 'T' is declared but never used. +tests/cases/compiler/b.ts(1,13): error TS6133: 'T' is declared but its value is never read. ==== tests/cases/compiler/a.ts (0 errors) ==== @@ -7,4 +7,4 @@ tests/cases/compiler/b.ts(1,13): error TS6133: 'T' is declared but never used. ==== tests/cases/compiler/b.ts (1 errors) ==== interface C { } ~ -!!! error TS6133: 'T' is declared but never used. \ No newline at end of file +!!! error TS6133: 'T' is declared but its value is never read. \ No newline at end of file diff --git a/tests/baselines/reference/unusedVariablesinBlocks1.errors.txt b/tests/baselines/reference/unusedVariablesinBlocks1.errors.txt index e1906041a89..1fa2e52b3f3 100644 --- a/tests/baselines/reference/unusedVariablesinBlocks1.errors.txt +++ b/tests/baselines/reference/unusedVariablesinBlocks1.errors.txt @@ -1,13 +1,16 @@ -tests/cases/compiler/unusedVariablesinBlocks1.ts(2,9): error TS6133: 'x' is declared but never used. +tests/cases/compiler/unusedVariablesinBlocks1.ts(2,9): error TS6133: 'x' is declared but its value is never read. +tests/cases/compiler/unusedVariablesinBlocks1.ts(4,13): error TS6133: 'x' is declared but its value is never read. -==== tests/cases/compiler/unusedVariablesinBlocks1.ts (1 errors) ==== +==== tests/cases/compiler/unusedVariablesinBlocks1.ts (2 errors) ==== function f1 () { let x = 10; ~ -!!! error TS6133: 'x' is declared but never used. +!!! error TS6133: 'x' is declared but its value is never read. { let x = 11; + ~ +!!! error TS6133: 'x' is declared but its value is never read. x++; } } \ No newline at end of file diff --git a/tests/baselines/reference/unusedVariablesinBlocks2.errors.txt b/tests/baselines/reference/unusedVariablesinBlocks2.errors.txt index 610b379d607..f9c83abca18 100644 --- a/tests/baselines/reference/unusedVariablesinBlocks2.errors.txt +++ b/tests/baselines/reference/unusedVariablesinBlocks2.errors.txt @@ -1,13 +1,16 @@ -tests/cases/compiler/unusedVariablesinBlocks2.ts(4,13): error TS6133: 'x' is declared but never used. +tests/cases/compiler/unusedVariablesinBlocks2.ts(2,9): error TS6133: 'x' is declared but its value is never read. +tests/cases/compiler/unusedVariablesinBlocks2.ts(4,13): error TS6133: 'x' is declared but its value is never read. -==== tests/cases/compiler/unusedVariablesinBlocks2.ts (1 errors) ==== +==== tests/cases/compiler/unusedVariablesinBlocks2.ts (2 errors) ==== function f1 () { let x = 10; + ~ +!!! error TS6133: 'x' is declared but its value is never read. { let x = 11; ~ -!!! error TS6133: 'x' is declared but never used. +!!! error TS6133: 'x' is declared but its value is never read. } x++; } \ No newline at end of file diff --git a/tests/baselines/reference/unusedVariablesinForLoop.errors.txt b/tests/baselines/reference/unusedVariablesinForLoop.errors.txt index 74f1450b6f7..1385f1e2327 100644 --- a/tests/baselines/reference/unusedVariablesinForLoop.errors.txt +++ b/tests/baselines/reference/unusedVariablesinForLoop.errors.txt @@ -1,11 +1,11 @@ -tests/cases/compiler/unusedVariablesinForLoop.ts(2,13): error TS6133: 'i' is declared but never used. +tests/cases/compiler/unusedVariablesinForLoop.ts(2,13): error TS6133: 'i' is declared but its value is never read. ==== tests/cases/compiler/unusedVariablesinForLoop.ts (1 errors) ==== function f1 () { for(var i = 0; ;) { ~ -!!! error TS6133: 'i' is declared but never used. +!!! error TS6133: 'i' is declared but its value is never read. } } \ No newline at end of file diff --git a/tests/baselines/reference/unusedVariablesinForLoop2.errors.txt b/tests/baselines/reference/unusedVariablesinForLoop2.errors.txt index d42f71286a0..bdd4706854a 100644 --- a/tests/baselines/reference/unusedVariablesinForLoop2.errors.txt +++ b/tests/baselines/reference/unusedVariablesinForLoop2.errors.txt @@ -1,11 +1,11 @@ -tests/cases/compiler/unusedVariablesinForLoop2.ts(2,16): error TS6133: 'elem' is declared but never used. +tests/cases/compiler/unusedVariablesinForLoop2.ts(2,16): error TS6133: 'elem' is declared but its value is never read. ==== tests/cases/compiler/unusedVariablesinForLoop2.ts (1 errors) ==== function f1 () { for (const elem in ["a", "b", "c"]) { ~~~~ -!!! error TS6133: 'elem' is declared but never used. +!!! error TS6133: 'elem' is declared but its value is never read. } } \ No newline at end of file diff --git a/tests/baselines/reference/unusedVariablesinForLoop3.errors.txt b/tests/baselines/reference/unusedVariablesinForLoop3.errors.txt index ec3e96584e2..a2a9d273200 100644 --- a/tests/baselines/reference/unusedVariablesinForLoop3.errors.txt +++ b/tests/baselines/reference/unusedVariablesinForLoop3.errors.txt @@ -1,11 +1,11 @@ -tests/cases/compiler/unusedVariablesinForLoop3.ts(2,16): error TS6133: 'elem' is declared but never used. +tests/cases/compiler/unusedVariablesinForLoop3.ts(2,16): error TS6133: 'elem' is declared but its value is never read. ==== tests/cases/compiler/unusedVariablesinForLoop3.ts (1 errors) ==== function f1 () { for (const elem of ["a", "b", "c"]) { ~~~~ -!!! error TS6133: 'elem' is declared but never used. +!!! error TS6133: 'elem' is declared but its value is never read. } } \ No newline at end of file diff --git a/tests/baselines/reference/unusedVariablesinForLoop4.errors.txt b/tests/baselines/reference/unusedVariablesinForLoop4.errors.txt index c20a6c1ba20..df6ffe9934b 100644 --- a/tests/baselines/reference/unusedVariablesinForLoop4.errors.txt +++ b/tests/baselines/reference/unusedVariablesinForLoop4.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/unusedVariablesinForLoop4.ts(4,13): error TS6133: 'x' is declared but never used. +tests/cases/compiler/unusedVariablesinForLoop4.ts(4,13): error TS6133: 'x' is declared but its value is never read. ==== tests/cases/compiler/unusedVariablesinForLoop4.ts (1 errors) ==== @@ -7,6 +7,6 @@ tests/cases/compiler/unusedVariablesinForLoop4.ts(4,13): error TS6133: 'x' is de elem; var x = 20; ~ -!!! error TS6133: 'x' is declared but never used. +!!! error TS6133: 'x' is declared but its value is never read. } } \ No newline at end of file diff --git a/tests/baselines/reference/unusedVariablesinModules1.errors.txt b/tests/baselines/reference/unusedVariablesinModules1.errors.txt index 7a8704a89ca..0421c9ff2b0 100644 --- a/tests/baselines/reference/unusedVariablesinModules1.errors.txt +++ b/tests/baselines/reference/unusedVariablesinModules1.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/unusedVariablesinModules1.ts(3,5): error TS6133: 'x' is declared but never used. +tests/cases/compiler/unusedVariablesinModules1.ts(3,5): error TS6133: 'x' is declared but its value is never read. ==== tests/cases/compiler/unusedVariablesinModules1.ts (1 errors) ==== @@ -6,6 +6,6 @@ tests/cases/compiler/unusedVariablesinModules1.ts(3,5): error TS6133: 'x' is dec var x: string; ~ -!!! error TS6133: 'x' is declared but never used. +!!! error TS6133: 'x' is declared but its value is never read. export var y: string; \ No newline at end of file diff --git a/tests/baselines/reference/unusedVariablesinNamespaces1.errors.txt b/tests/baselines/reference/unusedVariablesinNamespaces1.errors.txt index 25c06c216fb..8ba5fc3c39a 100644 --- a/tests/baselines/reference/unusedVariablesinNamespaces1.errors.txt +++ b/tests/baselines/reference/unusedVariablesinNamespaces1.errors.txt @@ -1,9 +1,9 @@ -tests/cases/compiler/unusedVariablesinNamespaces1.ts(2,11): error TS6133: 'lettersRegexp' is declared but never used. +tests/cases/compiler/unusedVariablesinNamespaces1.ts(2,11): error TS6133: 'lettersRegexp' is declared but its value is never read. ==== tests/cases/compiler/unusedVariablesinNamespaces1.ts (1 errors) ==== namespace Validation { const lettersRegexp = /^[A-Za-z]+$/; ~~~~~~~~~~~~~ -!!! error TS6133: 'lettersRegexp' is declared but never used. +!!! error TS6133: 'lettersRegexp' is declared but its value is never read. } \ No newline at end of file diff --git a/tests/baselines/reference/unusedVariablesinNamespaces2.errors.txt b/tests/baselines/reference/unusedVariablesinNamespaces2.errors.txt index a3af55498dc..df5fa298266 100644 --- a/tests/baselines/reference/unusedVariablesinNamespaces2.errors.txt +++ b/tests/baselines/reference/unusedVariablesinNamespaces2.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/unusedVariablesinNamespaces2.ts(3,11): error TS6133: 'numberRegexp' is declared but never used. +tests/cases/compiler/unusedVariablesinNamespaces2.ts(3,11): error TS6133: 'numberRegexp' is declared but its value is never read. ==== tests/cases/compiler/unusedVariablesinNamespaces2.ts (1 errors) ==== @@ -6,7 +6,7 @@ tests/cases/compiler/unusedVariablesinNamespaces2.ts(3,11): error TS6133: 'numbe const lettersRegexp = /^[A-Za-z]+$/; const numberRegexp = /^[0-9]+$/; ~~~~~~~~~~~~ -!!! error TS6133: 'numberRegexp' is declared but never used. +!!! error TS6133: 'numberRegexp' is declared but its value is never read. export class LettersOnlyValidator { isAcceptable(s2: string) { diff --git a/tests/baselines/reference/unusedVariablesinNamespaces3.errors.txt b/tests/baselines/reference/unusedVariablesinNamespaces3.errors.txt index 64d94a86ade..b1c7644019a 100644 --- a/tests/baselines/reference/unusedVariablesinNamespaces3.errors.txt +++ b/tests/baselines/reference/unusedVariablesinNamespaces3.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/unusedVariablesinNamespaces3.ts(3,11): error TS6133: 'numberRegexp' is declared but never used. +tests/cases/compiler/unusedVariablesinNamespaces3.ts(3,11): error TS6133: 'numberRegexp' is declared but its value is never read. ==== tests/cases/compiler/unusedVariablesinNamespaces3.ts (1 errors) ==== @@ -6,7 +6,7 @@ tests/cases/compiler/unusedVariablesinNamespaces3.ts(3,11): error TS6133: 'numbe const lettersRegexp = /^[A-Za-z]+$/; const numberRegexp = /^[0-9]+$/; ~~~~~~~~~~~~ -!!! error TS6133: 'numberRegexp' is declared but never used. +!!! error TS6133: 'numberRegexp' is declared but its value is never read. export const anotherUnusedVariable = "Dummy value"; export class LettersOnlyValidator { diff --git a/tests/cases/compiler/noUnusedLocals_writeOnly.ts b/tests/cases/compiler/noUnusedLocals_writeOnly.ts new file mode 100644 index 00000000000..228a7e0b6b0 --- /dev/null +++ b/tests/cases/compiler/noUnusedLocals_writeOnly.ts @@ -0,0 +1,12 @@ +// @noUnusedLocals: true +// @noUnusedParameters: true + +function f(x = 0) { + x = 1; + x++; + x /= 2; + + let y = 0; + // This is a write access to y, but not a write-*only* access. + f(y++); +} diff --git a/tests/cases/compiler/noUnusedLocals_writeOnlyProperty.ts b/tests/cases/compiler/noUnusedLocals_writeOnlyProperty.ts new file mode 100644 index 00000000000..84e005afd54 --- /dev/null +++ b/tests/cases/compiler/noUnusedLocals_writeOnlyProperty.ts @@ -0,0 +1,8 @@ +// @noUnusedLocals: true + +class C { + private x; + m() { + this.x = 0; + } +} diff --git a/tests/cases/compiler/unusedParameterUsedInTypeOf.ts b/tests/cases/compiler/unusedParameterUsedInTypeOf.ts index b69b2412314..f1cf83d56c4 100644 --- a/tests/cases/compiler/unusedParameterUsedInTypeOf.ts +++ b/tests/cases/compiler/unusedParameterUsedInTypeOf.ts @@ -3,5 +3,5 @@ //@noUnusedParameters:true function f1 (a: number, b: typeof a) { - b++; + return b; } \ No newline at end of file diff --git a/tests/cases/compiler/unusedPrivateVariableInClass4.ts b/tests/cases/compiler/unusedPrivateVariableInClass4.ts index 23598d5a491..e737d9ac477 100644 --- a/tests/cases/compiler/unusedPrivateVariableInClass4.ts +++ b/tests/cases/compiler/unusedPrivateVariableInClass4.ts @@ -7,6 +7,6 @@ class greeter { public z: string; public method1() { - this.x = "dummy value"; + this.x; } } \ No newline at end of file diff --git a/tests/cases/compiler/unusedPrivateVariableInClass5.ts b/tests/cases/compiler/unusedPrivateVariableInClass5.ts index 51e64afca1d..4234f16bdbc 100644 --- a/tests/cases/compiler/unusedPrivateVariableInClass5.ts +++ b/tests/cases/compiler/unusedPrivateVariableInClass5.ts @@ -7,6 +7,6 @@ class greeter { public z: string; constructor() { - this.x = "dummy value"; + this.x; } } \ No newline at end of file diff --git a/tests/cases/fourslash/findAllRefsParameterPropertyDeclaration1.ts b/tests/cases/fourslash/findAllRefsParameterPropertyDeclaration1.ts index fa1254118a1..89bb40b6830 100644 --- a/tests/cases/fourslash/findAllRefsParameterPropertyDeclaration1.ts +++ b/tests/cases/fourslash/findAllRefsParameterPropertyDeclaration1.ts @@ -3,7 +3,7 @@ //// class Foo { //// constructor(private [|{| "isWriteAccess": true, "isDefinition": true |}privateParam|]: number) { //// let localPrivate = [|privateParam|]; -//// this.[|privateParam|] += 10; +//// this.[|{| "isWriteAccess": true |}privateParam|] += 10; //// } //// } diff --git a/tests/cases/fourslash/findAllRefsParameterPropertyDeclaration2.ts b/tests/cases/fourslash/findAllRefsParameterPropertyDeclaration2.ts index 45d814f909e..519ca74c5c4 100644 --- a/tests/cases/fourslash/findAllRefsParameterPropertyDeclaration2.ts +++ b/tests/cases/fourslash/findAllRefsParameterPropertyDeclaration2.ts @@ -3,7 +3,7 @@ //// class Foo { //// constructor(public [|{| "isWriteAccess": true, "isDefinition": true |}publicParam|]: number) { //// let localPublic = [|publicParam|]; -//// this.[|publicParam|] += 10; +//// this.[|{| "isWriteAccess": true |}publicParam|] += 10; //// } //// } diff --git a/tests/cases/fourslash/findAllRefsParameterPropertyDeclaration3.ts b/tests/cases/fourslash/findAllRefsParameterPropertyDeclaration3.ts index 3520fecb8ad..7addc2ba7a0 100644 --- a/tests/cases/fourslash/findAllRefsParameterPropertyDeclaration3.ts +++ b/tests/cases/fourslash/findAllRefsParameterPropertyDeclaration3.ts @@ -3,7 +3,7 @@ //// class Foo { //// constructor(protected [|{| "isWriteAccess": true, "isDefinition": true |}protectedParam|]: number) { //// let localProtected = [|protectedParam|]; -//// this.[|protectedParam|] += 10; +//// this.[|{| "isWriteAccess": true |}protectedParam|] += 10; //// } //// } diff --git a/tests/cases/fourslash/localGetReferences.ts b/tests/cases/fourslash/localGetReferences.ts index 4648471648a..a434a6b0820 100644 --- a/tests/cases/fourslash/localGetReferences.ts +++ b/tests/cases/fourslash/localGetReferences.ts @@ -14,10 +14,10 @@ //// constructor (public [|{| "isWriteAccess": true, "isDefinition": true |}clsParam|]: number) { //// //Increments //// [|{| "isWriteAccess": true |}globalVar|]++; -//// this.[|clsVar|]++; -//// fooCls.[|clsSVar|]++; +//// this.[|{| "isWriteAccess": true |}clsVar|]++; +//// fooCls.[|{| "isWriteAccess": true |}clsSVar|]++; //// // References to a class parameter. -//// this.[|clsParam|]++; +//// this.[|{| "isWriteAccess": true |}clsParam|]++; //// modTest.modVar++; //// } ////} @@ -28,7 +28,7 @@ //// var [|{| "isWriteAccess": true, "isDefinition": true |}fnVar|] = 1; //// //// //Increments -//// fooCls.[|clsSVar|]++; +//// fooCls.[|{| "isWriteAccess": true |}clsSVar|]++; //// [|{| "isWriteAccess": true |}globalVar|]++; //// modTest.modVar++; //// [|{| "isWriteAccess": true |}fnVar|]++; @@ -43,7 +43,7 @@ //// //// //Increments //// [|{| "isWriteAccess": true |}globalVar|]++; -//// fooCls.[|clsSVar|]++; +//// fooCls.[|{| "isWriteAccess": true |}clsSVar|]++; //// modVar++; //// //// class testCls { @@ -55,7 +55,7 @@ //// //// //Increments //// [|{| "isWriteAccess": true |}globalVar|]++; -//// fooCls.[|clsSVar|]++; +//// fooCls.[|{| "isWriteAccess": true |}clsSVar|]++; //// modVar++; //// } //// @@ -74,7 +74,7 @@ ////[|foo|]([|globalVar|]); //// //////Increments -////fooCls.[|clsSVar|]++; +////fooCls.[|{| "isWriteAccess": true |}clsSVar|]++; ////modTest.modVar++; ////[|{| "isWriteAccess": true |}globalVar|] = [|globalVar|] + [|globalVar|]; //// diff --git a/tests/cases/fourslash/referenceInParameterPropertyDeclaration.ts b/tests/cases/fourslash/referenceInParameterPropertyDeclaration.ts index 79bf6172863..63494352ff4 100644 --- a/tests/cases/fourslash/referenceInParameterPropertyDeclaration.ts +++ b/tests/cases/fourslash/referenceInParameterPropertyDeclaration.ts @@ -7,13 +7,13 @@ //// protected [|{| "isWriteAccess": true, "isDefinition": true, "type": "boolean" |}protectedParam|]: boolean) { //// //// let localPrivate = [|privateParam|]; -//// this.[|privateParam|] += 10; +//// this.[|{| "isWriteAccess": true |}privateParam|] += 10; //// //// let localPublic = [|publicParam|]; -//// this.[|publicParam|] += " Hello!"; +//// this.[|{| "isWriteAccess": true |}publicParam|] += " Hello!"; //// //// let localProtected = [|protectedParam|]; -//// this.[|protectedParam|] = false; +//// this.[|{| "isWriteAccess": true |}protectedParam|] = false; //// } //// } diff --git a/tests/cases/fourslash/referencesForClassLocal.ts b/tests/cases/fourslash/referencesForClassLocal.ts index 4108c060a39..9e2576413f2 100644 --- a/tests/cases/fourslash/referencesForClassLocal.ts +++ b/tests/cases/fourslash/referencesForClassLocal.ts @@ -8,11 +8,11 @@ //// private [|{| "isWriteAccess": true, "isDefinition": true |}n|] = 0; //// //// public bar() { -//// this.[|n|] = 9; +//// this.[|{| "isWriteAccess": true |}n|] = 9; //// } //// //// constructor() { -//// this.[|n|] = 4; +//// this.[|{| "isWriteAccess": true |}n|] = 4; //// } //// //// public bar2() { diff --git a/tests/cases/fourslash/referencesForClassParameter.ts b/tests/cases/fourslash/referencesForClassParameter.ts index e1a33dc5ac4..24eb9e5496e 100644 --- a/tests/cases/fourslash/referencesForClassParameter.ts +++ b/tests/cases/fourslash/referencesForClassParameter.ts @@ -11,13 +11,13 @@ //// } //// //// public f(p) { -//// this.[|p|] = p; +//// this.[|{| "isWriteAccess": true |}p|] = p; //// } //// ////} //// ////var n = new foo(undefined); -////n.[|p|] = null; +////n.[|{| "isWriteAccess": true |}p|] = null; const ranges = test.ranges(); const [r0, r1, r2] = ranges; diff --git a/tests/cases/fourslash/referencesForOverrides.ts b/tests/cases/fourslash/referencesForOverrides.ts index 5ce6bc5ed04..a3cfffa8bd4 100644 --- a/tests/cases/fourslash/referencesForOverrides.ts +++ b/tests/cases/fourslash/referencesForOverrides.ts @@ -70,7 +70,7 @@ //// w.[|icfoo|](); //// //// var z = new Test.BarBlah(); -//// z.[|field|] = ""; +//// z.[|{| "isWriteAccess": true |}field|] = ""; //// z.[|method|](); //// } ////} diff --git a/tests/cases/fourslash/referencesForStatic.ts b/tests/cases/fourslash/referencesForStatic.ts index 17c33daac32..1c82d2fde6c 100644 --- a/tests/cases/fourslash/referencesForStatic.ts +++ b/tests/cases/fourslash/referencesForStatic.ts @@ -9,7 +9,7 @@ //// static [|{| "isWriteAccess": true, "isDefinition": true |}n|] = ''; //// //// public bar() { -//// foo.[|n|] = "'"; +//// foo.[|{| "isWriteAccess": true |}n|] = "'"; //// if(foo.[|n|]) { //// var x = foo.[|n|]; //// } @@ -19,7 +19,7 @@ ////class foo2 { //// private x = foo.[|n|]; //// constructor() { -//// foo.[|n|] = x; +//// foo.[|{| "isWriteAccess": true |}n|] = x; //// } //// //// function b(n) { diff --git a/tests/cases/fourslash/referencesForStringLiteralPropertyNames4.ts b/tests/cases/fourslash/referencesForStringLiteralPropertyNames4.ts index 4293435de1d..c289a17c91c 100644 --- a/tests/cases/fourslash/referencesForStringLiteralPropertyNames4.ts +++ b/tests/cases/fourslash/referencesForStringLiteralPropertyNames4.ts @@ -2,7 +2,7 @@ ////var x = { "[|{| "isWriteAccess": true, "isDefinition": true |}someProperty|]": 0 } ////x["[|someProperty|]"] = 3; -////x.[|someProperty|] = 5; +////x.[|{| "isWriteAccess": true |}someProperty|] = 5; const ranges = test.ranges(); const [r0, r1, r2] = ranges; diff --git a/tests/cases/fourslash/remoteGetReferences.ts b/tests/cases/fourslash/remoteGetReferences.ts index 292864f9ed4..a09e3fb3b01 100644 --- a/tests/cases/fourslash/remoteGetReferences.ts +++ b/tests/cases/fourslash/remoteGetReferences.ts @@ -93,7 +93,7 @@ ////remotefoo([|remoteglobalVar|]); //// //////Increments -////[|remotefooCls|].[|remoteclsSVar|]++; +////[|remotefooCls|].[|{| "isWriteAccess": true |}remoteclsSVar|]++; ////remotemodTest.remotemodVar++; ////[|{| "isWriteAccess": true |}remoteglobalVar|] = [|remoteglobalVar|] + [|remoteglobalVar|]; //// @@ -129,8 +129,8 @@ //// constructor(public remoteclsParam: number) { //// //Increments //// [|{| "isWriteAccess": true |}remoteglobalVar|]++; -//// this.[|remoteclsVar|]++; -//// [|remotefooCls|].[|remoteclsSVar|]++; +//// this.[|{| "isWriteAccess": true |}remoteclsVar|]++; +//// [|remotefooCls|].[|{| "isWriteAccess": true |}remoteclsSVar|]++; //// this.remoteclsParam++; //// remotemodTest.remotemodVar++; //// } @@ -141,7 +141,7 @@ //// var remotefnVar = 1; //// //// //Increments -//// [|remotefooCls|].[|remoteclsSVar|]++; +//// [|remotefooCls|].[|{| "isWriteAccess": true |}remoteclsSVar|]++; //// [|{| "isWriteAccess": true |}remoteglobalVar|]++; //// remotemodTest.remotemodVar++; //// remotefnVar++; @@ -156,7 +156,7 @@ //// //// //Increments //// [|{| "isWriteAccess": true |}remoteglobalVar|]++; -//// [|remotefooCls|].[|remoteclsSVar|]++; +//// [|remotefooCls|].[|{| "isWriteAccess": true |}remoteclsSVar|]++; //// remotemodVar++; //// //// class remotetestCls { @@ -168,7 +168,7 @@ //// //// //Increments //// [|{| "isWriteAccess": true |}remoteglobalVar|]++; -//// [|remotefooCls|].[|remoteclsSVar|]++; +//// [|remotefooCls|].[|{| "isWriteAccess": true |}remoteclsSVar|]++; //// remotemodVar++; //// } //// diff --git a/tests/cases/fourslash/unusedLocalsInFunction4.ts b/tests/cases/fourslash/unusedLocalsInFunction4.ts index a458d6d824c..62d128ea9e7 100644 --- a/tests/cases/fourslash/unusedLocalsInFunction4.ts +++ b/tests/cases/fourslash/unusedLocalsInFunction4.ts @@ -3,8 +3,7 @@ // @noUnusedLocals: true ////function greeter() { //// [| var x,y = 0,z = 1; |] -//// y++; -//// z++; +//// use(y, z); ////} verify.rangeAfterCodeFix("var y = 0,z = 1;"); diff --git a/tests/cases/fourslash/unusedLocalsInMethodFS1.ts b/tests/cases/fourslash/unusedLocalsInMethodFS1.ts index dc73ab86663..ecfb7455276 100644 --- a/tests/cases/fourslash/unusedLocalsInMethodFS1.ts +++ b/tests/cases/fourslash/unusedLocalsInMethodFS1.ts @@ -4,8 +4,8 @@ // @noUnusedParameters: true ////class greeter { //// public function1() { -//// [| var /*0*/x,/*1*/ y = 10; |] -//// y++; +//// [| var /*0*/x,/*1*/ y = 10; |] +//// use(y); //// } ////} diff --git a/tests/cases/fourslash/unusedLocalsInMethodFS2.ts b/tests/cases/fourslash/unusedLocalsInMethodFS2.ts index 012bf87a222..d06e803bf7f 100644 --- a/tests/cases/fourslash/unusedLocalsInMethodFS2.ts +++ b/tests/cases/fourslash/unusedLocalsInMethodFS2.ts @@ -5,7 +5,7 @@ ////class greeter { //// public function1() { //// [| var x, y; |] -//// y = 1; +//// use(y); //// } ////} diff --git a/tests/cases/fourslash/unusedParameterInFunction2.ts b/tests/cases/fourslash/unusedParameterInFunction2.ts index 81e73450622..6d1a772b0a8 100644 --- a/tests/cases/fourslash/unusedParameterInFunction2.ts +++ b/tests/cases/fourslash/unusedParameterInFunction2.ts @@ -2,7 +2,7 @@ // @noUnusedParameters: true ////function [|greeter(x,y)|] { -//// x++; +//// use(x); ////} verify.rangeAfterCodeFix("greeter(x)", /*includeWhiteSpace*/ false, /*errorCode*/ undefined, /*index*/ 0); \ No newline at end of file diff --git a/tests/cases/fourslash/unusedParameterInFunction4.ts b/tests/cases/fourslash/unusedParameterInFunction4.ts index 4ea96b3bd18..e3ee2585384 100644 --- a/tests/cases/fourslash/unusedParameterInFunction4.ts +++ b/tests/cases/fourslash/unusedParameterInFunction4.ts @@ -2,8 +2,7 @@ // @noUnusedParameters: true ////[|function greeter(x,y,z) |] { -//// x++; -//// z++; +//// use(x, z); ////} verify.rangeAfterCodeFix("function greeter(x,z)", /*includeWhiteSpace*/ false, /*errorCode*/ undefined, /*index*/ 0); \ No newline at end of file diff --git a/tests/cases/fourslash/unusedVariableInNamespace2.ts b/tests/cases/fourslash/unusedVariableInNamespace2.ts index 992c229014a..61fc3ec137c 100644 --- a/tests/cases/fourslash/unusedVariableInNamespace2.ts +++ b/tests/cases/fourslash/unusedVariableInNamespace2.ts @@ -4,8 +4,7 @@ ////namespace greeter { //// [|let a = "dummy entry", b, c = 0;|] //// export function function1() { -//// a = "dummy"; -//// c++; +//// use(a, c); //// } ////} diff --git a/tests/cases/fourslash/unusedVariableInNamespace3.ts b/tests/cases/fourslash/unusedVariableInNamespace3.ts index 0039036b2f8..7d2f3d251f3 100644 --- a/tests/cases/fourslash/unusedVariableInNamespace3.ts +++ b/tests/cases/fourslash/unusedVariableInNamespace3.ts @@ -4,8 +4,7 @@ ////namespace greeter { //// [|let a = "dummy entry", b, c = 0;|] //// export function function1() { -//// a = "dummy"; -//// b = 0; +//// use(a, b); //// } ////} From d762f55199ec652520b6a695f3957f9ed4da881b Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Wed, 13 Sep 2017 09:23:57 -0700 Subject: [PATCH 313/370] Fix:Instantiate javascript constructor signatures getSignatureInstantation takes a parameter that tells whether the signature comes from Javascript and therefore is allowed to pass fewer than the required number of type arguments. (Defaults are chosen if this is the case.) Previously, getInstantiatedConstructorsForTypeArguments forgot to provide this argument, and constructors with insufficient type arguments would cause a crash because getSignatureInstantiation would not know to fill in the missing type arguments. --- src/compiler/checker.ts | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index c169dcb83ca..2375d52a6e9 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -4902,7 +4902,7 @@ namespace ts { function getInstantiatedConstructorsForTypeArguments(type: Type, typeArgumentNodes: ReadonlyArray, location: Node): Signature[] { const signatures = getConstructorsForTypeArguments(type, typeArgumentNodes, location); const typeArguments = map(typeArgumentNodes, getTypeFromTypeNode); - return sameMap(signatures, sig => some(sig.typeParameters) ? getSignatureInstantiation(sig, typeArguments) : sig); + return sameMap(signatures, sig => some(sig.typeParameters) ? getSignatureInstantiation(sig, typeArguments, isInJavaScriptFile(location)) : sig); } /** @@ -5498,7 +5498,7 @@ namespace ts { const minTypeArgumentCount = getMinTypeArgumentCount(baseSig.typeParameters); const typeParamCount = length(baseSig.typeParameters); if ((isJavaScript || typeArgCount >= minTypeArgumentCount) && typeArgCount <= typeParamCount) { - const sig = typeParamCount ? createSignatureInstantiation(baseSig, fillMissingTypeArguments(typeArguments, baseSig.typeParameters, minTypeArgumentCount, baseTypeNode)) : cloneSignature(baseSig); + const sig = typeParamCount ? createSignatureInstantiation(baseSig, fillMissingTypeArguments(typeArguments, baseSig.typeParameters, minTypeArgumentCount, isJavaScript)) : cloneSignature(baseSig); sig.typeParameters = classType.localTypeParameters; sig.resolvedReturnType = classType; result.push(sig); @@ -6361,11 +6361,10 @@ namespace ts { * @param typeParameters The requested type parameters. * @param minTypeArgumentCount The minimum number of required type arguments. */ - function fillMissingTypeArguments(typeArguments: Type[] | undefined, typeParameters: TypeParameter[] | undefined, minTypeArgumentCount: number, location?: Node) { + function fillMissingTypeArguments(typeArguments: Type[] | undefined, typeParameters: TypeParameter[] | undefined, minTypeArgumentCount: number, isJavaScript?: boolean) { const numTypeParameters = length(typeParameters); if (numTypeParameters) { const numTypeArguments = length(typeArguments); - const isJavaScript = isInJavaScriptFile(location); if ((isJavaScript || numTypeArguments >= minTypeArgumentCount) && numTypeArguments <= numTypeParameters) { if (!typeArguments) { typeArguments = []; @@ -6623,8 +6622,8 @@ namespace ts { return anyType; } - function getSignatureInstantiation(signature: Signature, typeArguments: Type[]): Signature { - typeArguments = fillMissingTypeArguments(typeArguments, signature.typeParameters, getMinTypeArgumentCount(signature.typeParameters)); + function getSignatureInstantiation(signature: Signature, typeArguments: Type[], isJavascript?: boolean): Signature { + typeArguments = fillMissingTypeArguments(typeArguments, signature.typeParameters, getMinTypeArgumentCount(signature.typeParameters), isJavascript); const instantiations = signature.instantiations || (signature.instantiations = createMap()); const id = getTypeListId(typeArguments); let instantiation = instantiations.get(id); @@ -6813,7 +6812,8 @@ namespace ts { if (typeParameters) { const numTypeArguments = length(node.typeArguments); const minTypeArgumentCount = getMinTypeArgumentCount(typeParameters); - if (!isInJavaScriptFile(node) && (numTypeArguments < minTypeArgumentCount || numTypeArguments > typeParameters.length)) { + const isJavascript = isInJavaScriptFile(node); + if (!isJavascript && (numTypeArguments < minTypeArgumentCount || numTypeArguments > typeParameters.length)) { error(node, minTypeArgumentCount === typeParameters.length ? Diagnostics.Generic_type_0_requires_1_type_argument_s @@ -6826,7 +6826,7 @@ namespace ts { // In a type reference, the outer type parameters of the referenced class or interface are automatically // supplied as type arguments and the type reference only specifies arguments for the local type parameters // of the class or interface. - const typeArguments = concatenate(type.outerTypeParameters, fillMissingTypeArguments(typeArgs, typeParameters, minTypeArgumentCount, node)); + const typeArguments = concatenate(type.outerTypeParameters, fillMissingTypeArguments(typeArgs, typeParameters, minTypeArgumentCount, isJavascript)); return createTypeReference(type, typeArguments); } if (node.typeArguments) { From 014f7ba8280d0cfa3936ebacb018c4b6d2407d91 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Wed, 13 Sep 2017 09:26:20 -0700 Subject: [PATCH 314/370] Test:javascript signature instantiation w/insufficient type args --- ...ssingTypeArgsOnJSConstructCalls.errors.txt | 48 +++++++++++++++++++ ...fillInMissingTypeArgsOnJSConstructCalls.ts | 27 +++++++++++ 2 files changed, 75 insertions(+) create mode 100644 tests/baselines/reference/fillInMissingTypeArgsOnJSConstructCalls.errors.txt create mode 100644 tests/cases/compiler/fillInMissingTypeArgsOnJSConstructCalls.ts diff --git a/tests/baselines/reference/fillInMissingTypeArgsOnJSConstructCalls.errors.txt b/tests/baselines/reference/fillInMissingTypeArgsOnJSConstructCalls.errors.txt new file mode 100644 index 00000000000..966e3e35613 --- /dev/null +++ b/tests/baselines/reference/fillInMissingTypeArgsOnJSConstructCalls.errors.txt @@ -0,0 +1,48 @@ +tests/cases/compiler/BaseB.js(2,24): error TS8004: 'type parameter declarations' can only be used in a .ts file. +tests/cases/compiler/BaseB.js(2,25): error TS1005: ',' expected. +tests/cases/compiler/BaseB.js(3,14): error TS2304: Cannot find name 'Class'. +tests/cases/compiler/BaseB.js(3,14): error TS8010: 'types' can only be used in a .ts file. +tests/cases/compiler/BaseB.js(4,25): error TS2304: Cannot find name 'Class'. +tests/cases/compiler/BaseB.js(4,25): error TS8010: 'types' can only be used in a .ts file. +tests/cases/compiler/SubB.js(3,41): error TS8011: 'type arguments' can only be used in a .ts file. + + +==== tests/cases/compiler/BaseA.js (0 errors) ==== + // regression test for #18254 + export default class BaseA { + } +==== tests/cases/compiler/SubA.js (0 errors) ==== + import BaseA from './BaseA'; + export default class SubA extends BaseA { + } +==== tests/cases/compiler/BaseB.js (6 errors) ==== + import BaseA from './BaseA'; + export default class B { + ~~~~~~~~ +!!! error TS8004: 'type parameter declarations' can only be used in a .ts file. + ~ +!!! error TS1005: ',' expected. + _AClass: Class; + ~~~~~ +!!! error TS2304: Cannot find name 'Class'. + ~~~~~~~~ +!!! error TS8010: 'types' can only be used in a .ts file. + constructor(AClass: Class) { + ~~~~~ +!!! error TS2304: Cannot find name 'Class'. + ~~~~~~~~ +!!! error TS8010: 'types' can only be used in a .ts file. + this._AClass = AClass; + } + } +==== tests/cases/compiler/SubB.js (1 errors) ==== + import SubA from './SubA'; + import BaseB from './BaseB'; + export default class SubB extends BaseB { + ~~~~ +!!! error TS8011: 'type arguments' can only be used in a .ts file. + constructor() { + super(SubA); + } + } + \ No newline at end of file diff --git a/tests/cases/compiler/fillInMissingTypeArgsOnJSConstructCalls.ts b/tests/cases/compiler/fillInMissingTypeArgsOnJSConstructCalls.ts new file mode 100644 index 00000000000..8ef0f903189 --- /dev/null +++ b/tests/cases/compiler/fillInMissingTypeArgsOnJSConstructCalls.ts @@ -0,0 +1,27 @@ +// @allowJs: true +// @checkJs: true +// @noEmit: true +// regression test for #18254 +// @Filename: BaseA.js +export default class BaseA { +} +// @Filename: SubA.js +import BaseA from './BaseA'; +export default class SubA extends BaseA { +} +// @Filename: BaseB.js +import BaseA from './BaseA'; +export default class B { + _AClass: Class; + constructor(AClass: Class) { + this._AClass = AClass; + } +} +// @Filename: SubB.js +import SubA from './SubA'; +import BaseB from './BaseB'; +export default class SubB extends BaseB { + constructor() { + super(SubA); + } +} From 5d51a42030bce430b3bed523da9520f97287d82f Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Wed, 13 Sep 2017 10:26:11 -0700 Subject: [PATCH 315/370] Use createMissingNode for sentinel node --- src/compiler/parser.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index 6d6b757f6e9..8912480d541 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -3028,7 +3028,7 @@ namespace ts { if (inParameter && requireEqualsToken) { // = is required when speculatively parsing arrow function parameters, // so return a fake initializer as a signal that the equals token was missing - const result = createNode(SyntaxKind.Identifier, scanner.getStartPos()) as Identifier; + const result = createMissingNode(SyntaxKind.Identifier, /*reportAtCurrentPosition*/ true, Diagnostics._0_expected, "=") as Identifier; result.escapedText = "= not found" as __String; return result; } From a1d1a2219b7d16a262af9eb52eaa242bc46ef657 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Wed, 13 Sep 2017 10:44:11 -0700 Subject: [PATCH 316/370] Make isJavascript parameters required This is a bit wordy, but will probably prevent bugs similar to #18254 in the future. --- src/compiler/checker.ts | 27 ++++++++++++++++----------- src/compiler/utilities.ts | 4 ++-- 2 files changed, 18 insertions(+), 13 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 2375d52a6e9..0ee3d549d48 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -6361,7 +6361,7 @@ namespace ts { * @param typeParameters The requested type parameters. * @param minTypeArgumentCount The minimum number of required type arguments. */ - function fillMissingTypeArguments(typeArguments: Type[] | undefined, typeParameters: TypeParameter[] | undefined, minTypeArgumentCount: number, isJavaScript?: boolean) { + function fillMissingTypeArguments(typeArguments: Type[] | undefined, typeParameters: TypeParameter[] | undefined, minTypeArgumentCount: number, isJavaScript: boolean) { const numTypeParameters = length(typeParameters); if (numTypeParameters) { const numTypeArguments = length(typeArguments); @@ -6622,7 +6622,7 @@ namespace ts { return anyType; } - function getSignatureInstantiation(signature: Signature, typeArguments: Type[], isJavascript?: boolean): Signature { + function getSignatureInstantiation(signature: Signature, typeArguments: Type[], isJavascript: boolean): Signature { typeArguments = fillMissingTypeArguments(typeArguments, signature.typeParameters, getMinTypeArgumentCount(signature.typeParameters), isJavascript); const instantiations = signature.instantiations || (signature.instantiations = createMap()); const id = getTypeListId(typeArguments); @@ -6661,7 +6661,10 @@ namespace ts { // where different generations of the same type parameter are in scope). This leads to a lot of new type // identities, and potentially a lot of work comparing those identities, so here we create an instantiation // that uses the original type identities for all unconstrained type parameters. - return getSignatureInstantiation(signature, map(signature.typeParameters, tp => tp.target && !getConstraintOfTypeParameter(tp.target) ? tp.target : tp)); + return getSignatureInstantiation( + signature, + map(signature.typeParameters, tp => tp.target && !getConstraintOfTypeParameter(tp.target) ? tp.target : tp), + isInJavaScriptFile(signature.declaration)); } function getOrCreateTypeFromSignature(signature: Signature): ObjectType { @@ -6843,7 +6846,7 @@ namespace ts { const id = getTypeListId(typeArguments); let instantiation = links.instantiations.get(id); if (!instantiation) { - links.instantiations.set(id, instantiation = instantiateType(type, createTypeMapper(typeParameters, fillMissingTypeArguments(typeArguments, typeParameters, getMinTypeArgumentCount(typeParameters))))); + links.instantiations.set(id, instantiation = instantiateType(type, createTypeMapper(typeParameters, fillMissingTypeArguments(typeArguments, typeParameters, getMinTypeArgumentCount(typeParameters), isInJavaScriptFile(symbol.valueDeclaration))))); } return instantiation; } @@ -13999,8 +14002,9 @@ namespace ts { const instantiatedSignatures = []; for (const signature of signatures) { if (signature.typeParameters) { - const typeArguments = fillMissingTypeArguments(/*typeArguments*/ undefined, signature.typeParameters, /*minTypeArgumentCount*/ 0); - instantiatedSignatures.push(getSignatureInstantiation(signature, typeArguments)); + const isJavascript = isInJavaScriptFile(node); + const typeArguments = fillMissingTypeArguments(/*typeArguments*/ undefined, signature.typeParameters, /*minTypeArgumentCount*/ 0, isJavascript); + instantiatedSignatures.push(getSignatureInstantiation(signature, typeArguments, isJavascript)); } else { instantiatedSignatures.push(signature); @@ -15257,7 +15261,7 @@ namespace ts { if (!contextualMapper) { inferTypes(context.inferences, getReturnTypeOfSignature(contextualSignature), getReturnTypeOfSignature(signature), InferencePriority.ReturnType); } - return getSignatureInstantiation(signature, getInferredTypes(context)); + return getSignatureInstantiation(signature, getInferredTypes(context), isInJavaScriptFile(contextualSignature.declaration)); } function inferTypeArguments(node: CallLikeExpression, signature: Signature, args: ReadonlyArray, excludeArgument: boolean[], context: InferenceContext): Type[] { @@ -15292,7 +15296,7 @@ namespace ts { // Above, the type of the 'value' parameter is inferred to be 'A'. const contextualSignature = getSingleCallSignature(instantiatedType); const inferenceSourceType = contextualSignature && contextualSignature.typeParameters ? - getOrCreateTypeFromSignature(getSignatureInstantiation(contextualSignature, contextualSignature.typeParameters)) : + getOrCreateTypeFromSignature(getSignatureInstantiation(contextualSignature, contextualSignature.typeParameters, isInJavaScriptFile(node))) : instantiatedType; const inferenceTargetType = getReturnTypeOfSignature(signature); // Inferences made from return types have lower priority than all other inferences. @@ -16008,8 +16012,9 @@ namespace ts { candidate = originalCandidate; if (candidate.typeParameters) { let typeArgumentTypes: Type[]; + const isJavascript = isInJavaScriptFile(candidate.declaration); if (typeArguments) { - typeArgumentTypes = fillMissingTypeArguments(map(typeArguments, getTypeFromTypeNode), candidate.typeParameters, getMinTypeArgumentCount(candidate.typeParameters)); + typeArgumentTypes = fillMissingTypeArguments(map(typeArguments, getTypeFromTypeNode), candidate.typeParameters, getMinTypeArgumentCount(candidate.typeParameters), isJavascript); if (!checkTypeArguments(candidate, typeArguments, typeArgumentTypes, /*reportErrors*/ false)) { candidateForTypeArgumentError = originalCandidate; break; @@ -16018,7 +16023,7 @@ namespace ts { else { typeArgumentTypes = inferTypeArguments(node, candidate, args, excludeArgument, inferenceContext); } - candidate = getSignatureInstantiation(candidate, typeArgumentTypes); + candidate = getSignatureInstantiation(candidate, typeArgumentTypes, isJavascript); } if (!checkApplicableSignature(node, args, candidate, relation, excludeArgument, /*reportErrors*/ false)) { candidateForArgumentError = candidate; @@ -18782,7 +18787,7 @@ namespace ts { const constraint = getConstraintOfTypeParameter(typeParameters[i]); if (constraint) { if (!typeArguments) { - typeArguments = fillMissingTypeArguments(map(typeArgumentNodes, getTypeFromTypeNode), typeParameters, minTypeArgumentCount); + typeArguments = fillMissingTypeArguments(map(typeArgumentNodes, getTypeFromTypeNode), typeParameters, minTypeArgumentCount, isInJavaScriptFile(typeArgumentNodes[i])); mapper = createTypeMapper(typeParameters, typeArguments); } const typeArgument = typeArguments[i]; diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index ee450344827..7eaf99c68e2 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -1325,11 +1325,11 @@ namespace ts { return isInJavaScriptFile(file); } - export function isInJavaScriptFile(node: Node): boolean { + export function isInJavaScriptFile(node: Node | undefined): boolean { return node && !!(node.flags & NodeFlags.JavaScriptFile); } - export function isInJSDoc(node: Node): boolean { + export function isInJSDoc(node: Node | undefined): boolean { return node && !!(node.flags & NodeFlags.JSDoc); } From c64beb90dfb513cbc24ed4a4a52b242196f0c2a3 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Wed, 13 Sep 2017 11:52:10 -0700 Subject: [PATCH 317/370] Remove intersections of object and nullable types from union types --- src/compiler/checker.ts | 20 ++++++++++++++++++-- src/compiler/types.ts | 1 + 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 379bc3377d2..bdebfcef47a 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -7289,6 +7289,22 @@ namespace ts { return binarySearchTypes(types, type) >= 0; } + // Return true if the given intersection type contains (a) more than one unit type or (b) an object + // type and a nullable type (null or undefined). + function isEmptyIntersectionType(type: IntersectionType) { + let combined: TypeFlags = 0; + for (const t of type.types) { + if (t.flags & TypeFlags.Unit && combined & TypeFlags.Unit) { + return true; + } + combined |= t.flags; + if (combined & TypeFlags.Nullable && combined & (TypeFlags.Object | TypeFlags.NonPrimitive)) { + return true; + } + } + return false; + } + function addTypeToUnion(typeSet: TypeSet, type: Type) { const flags = type.flags; if (flags & TypeFlags.Union) { @@ -7302,7 +7318,7 @@ namespace ts { if (flags & TypeFlags.Null) typeSet.containsNull = true; if (!(flags & TypeFlags.ContainsWideningType)) typeSet.containsNonWideningType = true; } - else if (!(flags & TypeFlags.Never || flags & TypeFlags.Intersection && every((type).types, isUnitType))) { + else if (!(flags & TypeFlags.Never || flags & TypeFlags.Intersection && isEmptyIntersectionType(type))) { // We ignore 'never' types in unions. Likewise, we ignore intersections of unit types as they are // another form of 'never' (in that they have an empty value domain). We could in theory turn // intersections of unit types into 'never' upon construction, but deferring the reduction makes it @@ -10041,7 +10057,7 @@ namespace ts { } function isUnitType(type: Type): boolean { - return (type.flags & (TypeFlags.Literal | TypeFlags.Undefined | TypeFlags.Null)) !== 0; + return !!(type.flags & TypeFlags.Unit); } function isLiteralType(type: Type): boolean { diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 55baf9763c2..efae0b50784 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -3217,6 +3217,7 @@ namespace ts { /* @internal */ Nullable = Undefined | Null, Literal = StringLiteral | NumberLiteral | BooleanLiteral, + Unit = Literal | Nullable, StringOrNumberLiteral = StringLiteral | NumberLiteral, /* @internal */ DefinitelyFalsy = StringLiteral | NumberLiteral | BooleanLiteral | Void | Undefined | Null, From 0ac942f7ab89ccbe42af987425237f3a271b32a3 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Wed, 13 Sep 2017 11:52:21 -0700 Subject: [PATCH 318/370] Update test --- tests/cases/compiler/restUnion2.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/cases/compiler/restUnion2.ts b/tests/cases/compiler/restUnion2.ts index 83d94e03a73..21f912cb2fb 100644 --- a/tests/cases/compiler/restUnion2.ts +++ b/tests/cases/compiler/restUnion2.ts @@ -14,6 +14,6 @@ declare const nullAndUndefinedUnion: null | undefined; var rest4: { }; var {...rest4 } = nullAndUndefinedUnion; -declare const unionWithIntersection: ({ n: number } & { s: string }) & undefined | null; +declare const unionWithIntersection: ({ n: number } & { s: string }) & undefined; var rest5: { n: number, s: string }; var {...rest5 } = unionWithIntersection; \ No newline at end of file From b20d631ba235ae176d12fe95006535b637357e01 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Wed, 13 Sep 2017 11:52:51 -0700 Subject: [PATCH 319/370] Accept new baselines --- tests/baselines/reference/restUnion2.js | 2 +- tests/baselines/reference/restUnion2.symbols | 2 +- tests/baselines/reference/restUnion2.types | 7 +++---- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/tests/baselines/reference/restUnion2.js b/tests/baselines/reference/restUnion2.js index 71f4b06cfef..382b7bb2bc9 100644 --- a/tests/baselines/reference/restUnion2.js +++ b/tests/baselines/reference/restUnion2.js @@ -13,7 +13,7 @@ declare const nullAndUndefinedUnion: null | undefined; var rest4: { }; var {...rest4 } = nullAndUndefinedUnion; -declare const unionWithIntersection: ({ n: number } & { s: string }) & undefined | null; +declare const unionWithIntersection: ({ n: number } & { s: string }) & undefined; var rest5: { n: number, s: string }; var {...rest5 } = unionWithIntersection; diff --git a/tests/baselines/reference/restUnion2.symbols b/tests/baselines/reference/restUnion2.symbols index 54ac47f0694..2728285f5ef 100644 --- a/tests/baselines/reference/restUnion2.symbols +++ b/tests/baselines/reference/restUnion2.symbols @@ -35,7 +35,7 @@ var {...rest4 } = nullAndUndefinedUnion; >rest4 : Symbol(rest4, Decl(restUnion2.ts, 11, 3), Decl(restUnion2.ts, 12, 5)) >nullAndUndefinedUnion : Symbol(nullAndUndefinedUnion, Decl(restUnion2.ts, 10, 13)) -declare const unionWithIntersection: ({ n: number } & { s: string }) & undefined | null; +declare const unionWithIntersection: ({ n: number } & { s: string }) & undefined; >unionWithIntersection : Symbol(unionWithIntersection, Decl(restUnion2.ts, 14, 13)) >n : Symbol(n, Decl(restUnion2.ts, 14, 39)) >s : Symbol(s, Decl(restUnion2.ts, 14, 55)) diff --git a/tests/baselines/reference/restUnion2.types b/tests/baselines/reference/restUnion2.types index 03c8d577e66..029192a9ac4 100644 --- a/tests/baselines/reference/restUnion2.types +++ b/tests/baselines/reference/restUnion2.types @@ -37,11 +37,10 @@ var {...rest4 } = nullAndUndefinedUnion; >rest4 : {} >nullAndUndefinedUnion : null | undefined -declare const unionWithIntersection: ({ n: number } & { s: string }) & undefined | null; ->unionWithIntersection : ({ n: number; } & { s: string; } & undefined) | null +declare const unionWithIntersection: ({ n: number } & { s: string }) & undefined; +>unionWithIntersection : { n: number; } & { s: string; } & undefined >n : number >s : string ->null : null var rest5: { n: number, s: string }; >rest5 : { n: number; s: string; } @@ -50,5 +49,5 @@ var rest5: { n: number, s: string }; var {...rest5 } = unionWithIntersection; >rest5 : { n: number; s: string; } ->unionWithIntersection : ({ n: number; } & { s: string; } & undefined) | null +>unionWithIntersection : { n: number; } & { s: string; } & undefined From 34576c2521b3cc12b88e73fde33b100220110013 Mon Sep 17 00:00:00 2001 From: Andrew Casey Date: Fri, 8 Sep 2017 18:37:15 -0700 Subject: [PATCH 320/370] Call getShorthandAssignmentValueSymbol rather than getSymbolAtLocation ...for shorthand property assignment names when collecting usages. --- src/harness/unittests/extractMethods.ts | 19 ++++++ src/services/refactors/extractMethod.ts | 6 +- .../extractMethod/extractMethod29.ts | 62 +++++++++++++++++++ 3 files changed, 86 insertions(+), 1 deletion(-) create mode 100644 tests/baselines/reference/extractMethod/extractMethod29.ts diff --git a/src/harness/unittests/extractMethods.ts b/src/harness/unittests/extractMethods.ts index c836698aeb4..bfd7519449d 100644 --- a/src/harness/unittests/extractMethods.ts +++ b/src/harness/unittests/extractMethods.ts @@ -709,6 +709,25 @@ function M3() { }`); } M3() { } constructor() { } +}`); + // Shorthand property names + testExtractMethod("extractMethod29", + `interface UnaryExpression { + kind: "Unary"; + operator: string; + operand: any; +} + +function parseUnaryExpression(operator: string): UnaryExpression { + [#|return { + kind: "Unary", + operator, + operand: parsePrimaryExpression(), + };|] +} + +function parsePrimaryExpression(): any { + throw "Not implemented"; }`); }); diff --git a/src/services/refactors/extractMethod.ts b/src/services/refactors/extractMethod.ts index 7b5e1e40c7e..5749c2b71d5 100644 --- a/src/services/refactors/extractMethod.ts +++ b/src/services/refactors/extractMethod.ts @@ -1161,7 +1161,11 @@ namespace ts.refactor.extractMethod { } function recordUsagebySymbol(identifier: Identifier, usage: Usage, isTypeName: boolean) { - const symbol = checker.getSymbolAtLocation(identifier); + // If the identifier is both a property name and its value, we're only interested in its value + // (since the name is a declaration and will be included in the extracted range). + const symbol = identifier.parent && isShorthandPropertyAssignment(identifier.parent) && identifier.parent.name === identifier + ? checker.getShorthandAssignmentValueSymbol(identifier.parent) + : checker.getSymbolAtLocation(identifier); if (!symbol) { // cannot find symbol - do nothing return undefined; diff --git a/tests/baselines/reference/extractMethod/extractMethod29.ts b/tests/baselines/reference/extractMethod/extractMethod29.ts new file mode 100644 index 00000000000..aa7004d254e --- /dev/null +++ b/tests/baselines/reference/extractMethod/extractMethod29.ts @@ -0,0 +1,62 @@ +// ==ORIGINAL== +interface UnaryExpression { + kind: "Unary"; + operator: string; + operand: any; +} + +function parseUnaryExpression(operator: string): UnaryExpression { + return { + kind: "Unary", + operator, + operand: parsePrimaryExpression(), + }; +} + +function parsePrimaryExpression(): any { + throw "Not implemented"; +} +// ==SCOPE::inner function in function 'parseUnaryExpression'== +interface UnaryExpression { + kind: "Unary"; + operator: string; + operand: any; +} + +function parseUnaryExpression(operator: string): UnaryExpression { + return /*RENAME*/newFunction(); + + function newFunction() { + return { + kind: "Unary", + operator, + operand: parsePrimaryExpression(), + }; + } +} + +function parsePrimaryExpression(): any { + throw "Not implemented"; +} +// ==SCOPE::function in global scope== +interface UnaryExpression { + kind: "Unary"; + operator: string; + operand: any; +} + +function parseUnaryExpression(operator: string): UnaryExpression { + return /*RENAME*/newFunction(operator); +} + +function newFunction(operator: string) { + return { + kind: "Unary", + operator, + operand: parsePrimaryExpression(), + }; +} + +function parsePrimaryExpression(): any { + throw "Not implemented"; +} \ No newline at end of file From 255951c270b10627b3dfcef0aa55a25a0fd0a7d1 Mon Sep 17 00:00:00 2001 From: Andrew Casey Date: Tue, 12 Sep 2017 16:51:13 -0700 Subject: [PATCH 321/370] Stop preventing extraction when a type parameter wouldn't bind ...correctly in a containing scope. It's not an issue because we'll just declare a corresponding type parameter on the extracted function and pass the original as a type argument. Fixes #18142 --- src/harness/unittests/extractMethods.ts | 5 +++++ src/services/refactors/extractMethod.ts | 6 +++++- .../extractMethod/extractMethod30.ts | 19 +++++++++++++++++++ 3 files changed, 29 insertions(+), 1 deletion(-) create mode 100644 tests/baselines/reference/extractMethod/extractMethod30.ts diff --git a/src/harness/unittests/extractMethods.ts b/src/harness/unittests/extractMethods.ts index bfd7519449d..86ee5354a5c 100644 --- a/src/harness/unittests/extractMethods.ts +++ b/src/harness/unittests/extractMethods.ts @@ -728,6 +728,11 @@ function parseUnaryExpression(operator: string): UnaryExpression { function parsePrimaryExpression(): any { throw "Not implemented"; +}`); + // Type parameter as declared type + testExtractMethod("extractMethod30", + `function F() { + [#|let t: T;|] }`); }); diff --git a/src/services/refactors/extractMethod.ts b/src/services/refactors/extractMethod.ts index 5749c2b71d5..eed49524656 100644 --- a/src/services/refactors/extractMethod.ts +++ b/src/services/refactors/extractMethod.ts @@ -1222,7 +1222,11 @@ namespace ts.refactor.extractMethod { substitutionsPerScope[i].set(symbolId, substitution); } else if (isTypeName) { - errorsPerScope[i].push(createDiagnosticForNode(identifier, Messages.TypeWillNotBeVisibleInTheNewScope)); + // If the symbol is a type parameter that won't be in scope, we'll pass it as a type argument + // so there's no problem. + if (!(symbol.flags & SymbolFlags.TypeParameter)) { + errorsPerScope[i].push(createDiagnosticForNode(identifier, Messages.TypeWillNotBeVisibleInTheNewScope)); + } } else { usagesPerScope[i].usages.set(identifier.text as string, { usage, symbol, node: identifier }); diff --git a/tests/baselines/reference/extractMethod/extractMethod30.ts b/tests/baselines/reference/extractMethod/extractMethod30.ts new file mode 100644 index 00000000000..67dc1208abc --- /dev/null +++ b/tests/baselines/reference/extractMethod/extractMethod30.ts @@ -0,0 +1,19 @@ +// ==ORIGINAL== +function F() { + let t: T; +} +// ==SCOPE::inner function in function 'F'== +function F() { + /*RENAME*/newFunction(); + + function newFunction() { + let t: T; + } +} +// ==SCOPE::function in global scope== +function F() { + /*RENAME*/newFunction(); +} +function newFunction() { + let t: T; +} From e2d94a2922a605fa14f6ae3864595d084d362540 Mon Sep 17 00:00:00 2001 From: Andrew Casey Date: Wed, 13 Sep 2017 12:50:41 -0700 Subject: [PATCH 322/370] Only introduce return properties at the top level ...not in nested functions. --- src/harness/unittests/extractMethods.ts | 27 +++++++++++ src/services/refactors/extractMethod.ts | 9 +++- .../extractMethod/extractMethod31.ts | 45 ++++++++++++++++++ .../extractMethod/extractMethod32.ts | 46 +++++++++++++++++++ 4 files changed, 125 insertions(+), 2 deletions(-) create mode 100644 tests/baselines/reference/extractMethod/extractMethod31.ts create mode 100644 tests/baselines/reference/extractMethod/extractMethod32.ts diff --git a/src/harness/unittests/extractMethods.ts b/src/harness/unittests/extractMethods.ts index 86ee5354a5c..956ceb78e02 100644 --- a/src/harness/unittests/extractMethods.ts +++ b/src/harness/unittests/extractMethods.ts @@ -733,6 +733,33 @@ function parsePrimaryExpression(): any { testExtractMethod("extractMethod30", `function F() { [#|let t: T;|] +}`); + // Return in nested function + testExtractMethod("extractMethod31", + `namespace N { + + export const value = 1; + + () => { + var f: () => number; + [#|f = function (): number { + return value; + }|] + } +}`); + // Return in nested class + testExtractMethod("extractMethod32", + `namespace N { + + export const value = 1; + + () => { + [#|var c = class { + M() { + return value; + } + }|] + } }`); }); diff --git a/src/services/refactors/extractMethod.ts b/src/services/refactors/extractMethod.ts index eed49524656..2410ce8cee5 100644 --- a/src/services/refactors/extractMethod.ts +++ b/src/services/refactors/extractMethod.ts @@ -855,6 +855,7 @@ namespace ts.refactor.extractMethod { return { body: createBlock(body.statements, /*multLine*/ true), returnValueProperty: undefined }; } let returnValueProperty: string; + let ignoreReturns = false; const statements = createNodeArray(isBlock(body) ? body.statements.slice(0) : [isStatement(body) ? body : createReturn(body)]); // rewrite body if either there are writes that should be propagated back via return statements or there are substitutions if (writes || substitutions.size) { @@ -877,7 +878,7 @@ namespace ts.refactor.extractMethod { } function visitor(node: Node): VisitResult { - if (node.kind === SyntaxKind.ReturnStatement && writes) { + if (!ignoreReturns && node.kind === SyntaxKind.ReturnStatement && writes) { const assignments: ObjectLiteralElementLike[] = getPropertyAssignmentsForWrites(writes); if ((node).expression) { if (!returnValueProperty) { @@ -893,8 +894,12 @@ namespace ts.refactor.extractMethod { } } else { + const oldIgnoreReturns = ignoreReturns; + ignoreReturns = ignoreReturns || isFunctionLike(node) || isClassLike(node); const substitution = substitutions.get(getNodeId(node).toString()); - return substitution || visitEachChild(node, visitor, nullTransformationContext); + const result = substitution || visitEachChild(node, visitor, nullTransformationContext); + ignoreReturns = oldIgnoreReturns; + return result; } } } diff --git a/tests/baselines/reference/extractMethod/extractMethod31.ts b/tests/baselines/reference/extractMethod/extractMethod31.ts new file mode 100644 index 00000000000..754814dcc26 --- /dev/null +++ b/tests/baselines/reference/extractMethod/extractMethod31.ts @@ -0,0 +1,45 @@ +// ==ORIGINAL== +namespace N { + + export const value = 1; + + () => { + var f: () => number; + f = function (): number { + return value; + } + } +} +// ==SCOPE::function in namespace 'N'== +namespace N { + + export const value = 1; + + () => { + var f: () => number; + f = /*RENAME*/newFunction(f); + } + + function newFunction(f: () => number) { + f = function(): number { + return value; + }; + return f; + } +} +// ==SCOPE::function in global scope== +namespace N { + + export const value = 1; + + () => { + var f: () => number; + f = /*RENAME*/newFunction(f); + } +} +function newFunction(f: () => number) { + f = function(): number { + return N.value; + }; + return f; +} diff --git a/tests/baselines/reference/extractMethod/extractMethod32.ts b/tests/baselines/reference/extractMethod/extractMethod32.ts new file mode 100644 index 00000000000..b9b870a08fa --- /dev/null +++ b/tests/baselines/reference/extractMethod/extractMethod32.ts @@ -0,0 +1,46 @@ +// ==ORIGINAL== +namespace N { + + export const value = 1; + + () => { + var c = class { + M() { + return value; + } + } + } +} +// ==SCOPE::function in namespace 'N'== +namespace N { + + export const value = 1; + + () => { + /*RENAME*/newFunction(); + } + + function newFunction() { + var c = class { + M() { + return value; + } + }; + } +} +// ==SCOPE::function in global scope== +namespace N { + + export const value = 1; + + () => { + /*RENAME*/newFunction(); + } +} +function newFunction() { + var c = class { + M() { + return N.value; + } + }; +} From 60f1d4573d8166fc369887ca4b96bf04d2d5b782 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Wed, 13 Sep 2017 14:04:14 -0700 Subject: [PATCH 323/370] Allow booleans in spread types Special-case types produced by `bool && expr` with the type `false | T`. This spreads `Partial` instead of `false | T`. --- src/compiler/checker.ts | 44 +++++++++++++++++++++++++++++++++++++---- 1 file changed, 40 insertions(+), 4 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 5c6a8b59119..287311e6433 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -7832,12 +7832,25 @@ namespace ts { return left; } if (left.flags & TypeFlags.Union) { - return mapType(left, t => getSpreadType(t, right)); + // if the union is `false | T` make all the properties of T optional + const wl = getPartialTypeFromFalseUnion(left as UnionType); + if (wl) { + left = wl; + } + else { + return mapType(left, t => getSpreadType(t, right)); + } } if (right.flags & TypeFlags.Union) { - return mapType(right, t => getSpreadType(left, t)); + const wr = getPartialTypeFromFalseUnion(right as UnionType); + if (wr) { + right = wr; + } + else { + return mapType(right, t => getSpreadType(left, t)); + } } - if (right.flags & TypeFlags.NonPrimitive) { + if (right.flags & (TypeFlags.NonPrimitive | TypeFlags.BooleanLike)) { return emptyObjectType; } @@ -7908,6 +7921,29 @@ namespace ts { return prop.flags & SymbolFlags.Method && find(prop.declarations, decl => isClassLike(decl.parent)); } + function getPartialTypeFromFalseUnion(type: UnionType): Type | undefined { + if (type.types.length === 2) { + const i = type.types.indexOf(falseType); + if (i > -1) { + const members = createSymbolTable(); + const other = type.types[i === 0 ? 1 : 0]; + for (const prop of getPropertiesOfType(other)) { + if (prop.flags & SymbolFlags.Optional) { + members.set(prop.escapedName, prop); + } + else { + const result = createSymbol(prop.flags | SymbolFlags.Optional, prop.escapedName); + result.type = getUnionType([getTypeOfSymbol(prop), undefinedType]); + result.declarations = prop.declarations; + result.syntheticOrigin = prop; + members.set(prop.escapedName, result); + } + } + return createAnonymousType(undefined, members, emptyArray, emptyArray, getIndexInfoOfType(other, IndexKind.String), getIndexInfoOfType(other, IndexKind.Number)); + } + } + } + function createLiteralType(flags: TypeFlags, value: string | number, symbol: Symbol) { const type = createType(flags); type.symbol = symbol; @@ -13749,7 +13785,7 @@ namespace ts { } function isValidSpreadType(type: Type): boolean { - return !!(type.flags & (TypeFlags.Any | TypeFlags.Null | TypeFlags.Undefined | TypeFlags.NonPrimitive) || + return !!(type.flags & (TypeFlags.Any | TypeFlags.Nullable | TypeFlags.NonPrimitive | TypeFlags.BooleanLike) || type.flags & TypeFlags.Object && !isGenericMappedType(type) || type.flags & TypeFlags.UnionOrIntersection && !forEach((type).types, t => !isValidSpreadType(t))); } From 9cddd1aca2de5eec903b2cbdb5d812ab68e2ef94 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Wed, 13 Sep 2017 14:06:15 -0700 Subject: [PATCH 324/370] Update spread tests for booleans in spread types --- tests/baselines/reference/objectSpread.js | 65 +++--- .../baselines/reference/objectSpread.symbols | 201 ++++++++++-------- tests/baselines/reference/objectSpread.types | 80 ++++--- .../reference/objectSpreadNegative.errors.txt | 26 +-- .../reference/objectSpreadNegative.js | 6 - .../conformance/types/spread/objectSpread.ts | 38 ++-- .../types/spread/objectSpreadNegative.ts | 3 - 7 files changed, 236 insertions(+), 183 deletions(-) diff --git a/tests/baselines/reference/objectSpread.js b/tests/baselines/reference/objectSpread.js index e05837c32d5..11b904a4806 100644 --- a/tests/baselines/reference/objectSpread.js +++ b/tests/baselines/reference/objectSpread.js @@ -38,6 +38,13 @@ getter.a = 12; // functions result in { } let spreadFunc = { ...(function () { }) }; +// boolean && T results in Partial +function conditionalSpread(b: boolean) : { x?: number | undefined, y?: number | undefined } { + return { ...b && { x: 1, y: 2 } }; +} +// other booleans result in { } +let spreadBool = { ... true } + // any results in any let anything: any; let spreadAny = { ...anything }; @@ -60,21 +67,23 @@ let changeTypeBoth: { a: string, b: number } = { ...o, ...swap }; // optional -let definiteBoolean: { sn: boolean }; -let definiteString: { sn: string }; -let optionalString: { sn?: string }; -let optionalNumber: { sn?: number }; -let optionalUnionStops: { sn: string | number | boolean } = { ...definiteBoolean, ...definiteString, ...optionalNumber }; -let optionalUnionDuplicates: { sn: string | number } = { ...definiteBoolean, ...definiteString, ...optionalString, ...optionalNumber }; -let allOptional: { sn?: string | number } = { ...optionalString, ...optionalNumber }; +function container( + definiteBoolean: { sn: boolean }, + definiteString: { sn: string }, + optionalString: { sn?: string }, + optionalNumber: { sn?: number }) { + let optionalUnionStops: { sn: string | number | boolean } = { ...definiteBoolean, ...definiteString, ...optionalNumber }; + let optionalUnionDuplicates: { sn: string | number } = { ...definiteBoolean, ...definiteString, ...optionalString, ...optionalNumber }; + let allOptional: { sn?: string | number } = { ...optionalString, ...optionalNumber }; -// computed property -let computedFirst: { a: number, b: string, "before everything": number } = - { ['before everything']: 12, ...o, b: 'yes' } -let computedMiddle: { a: number, b: string, c: boolean, "in the middle": number } = - { ...o, ['in the middle']: 13, b: 'maybe?', ...o2 } -let computedAfter: { a: number, b: string, "at the end": number } = - { ...o, b: 'yeah', ['at the end']: 14 } + // computed property + let computedFirst: { a: number, b: string, "before everything": number } = + { ['before everything']: 12, ...o, b: 'yes' } + let computedMiddle: { a: number, b: string, c: boolean, "in the middle": number } = + { ...o, ['in the middle']: 13, b: 'maybe?', ...o2 } + let computedAfter: { a: number, b: string, "at the end": number } = + { ...o, b: 'yeah', ['at the end']: 14 } +} // shortcut syntax let a = 12; let shortCutted: { a: number, b: string } = { ...o, a } @@ -114,6 +123,12 @@ var getter = __assign({}, op, { c: 7 }); getter.a = 12; // functions result in { } var spreadFunc = __assign({}, (function () { })); +// boolean && T results in Partial +function conditionalSpread(b) { + return __assign({}, b && { x: 1, y: 2 }); +} +// other booleans result in { } +var spreadBool = __assign({}, true); // any results in any var anything; var spreadAny = __assign({}, anything); @@ -135,20 +150,18 @@ var changeTypeAfter = __assign({}, o, { a: 'wrong type?' }); var changeTypeBefore = __assign({ a: 'wrong type?' }, o); var changeTypeBoth = __assign({}, o, swap); // optional -var definiteBoolean; -var definiteString; -var optionalString; -var optionalNumber; -var optionalUnionStops = __assign({}, definiteBoolean, definiteString, optionalNumber); -var optionalUnionDuplicates = __assign({}, definiteBoolean, definiteString, optionalString, optionalNumber); -var allOptional = __assign({}, optionalString, optionalNumber); -// computed property -var computedFirst = __assign((_a = {}, _a['before everything'] = 12, _a), o, { b: 'yes' }); -var computedMiddle = __assign({}, o, (_b = {}, _b['in the middle'] = 13, _b.b = 'maybe?', _b), o2); -var computedAfter = __assign({}, o, (_c = { b: 'yeah' }, _c['at the end'] = 14, _c)); +function container(definiteBoolean, definiteString, optionalString, optionalNumber) { + var optionalUnionStops = __assign({}, definiteBoolean, definiteString, optionalNumber); + var optionalUnionDuplicates = __assign({}, definiteBoolean, definiteString, optionalString, optionalNumber); + var allOptional = __assign({}, optionalString, optionalNumber); + // computed property + var computedFirst = __assign((_a = {}, _a['before everything'] = 12, _a), o, { b: 'yes' }); + var computedMiddle = __assign({}, o, (_b = {}, _b['in the middle'] = 13, _b.b = 'maybe?', _b), o2); + var computedAfter = __assign({}, o, (_c = { b: 'yeah' }, _c['at the end'] = 14, _c)); + var _a, _b, _c; +} // shortcut syntax var a = 12; var shortCutted = __assign({}, o, { a: a }); // non primitive var spreadNonPrimitive = __assign({}, {}); -var _a, _b, _c; diff --git a/tests/baselines/reference/objectSpread.symbols b/tests/baselines/reference/objectSpread.symbols index 1ec2520e166..0c5e8a4c5a8 100644 --- a/tests/baselines/reference/objectSpread.symbols +++ b/tests/baselines/reference/objectSpread.symbols @@ -169,154 +169,173 @@ getter.a = 12; let spreadFunc = { ...(function () { }) }; >spreadFunc : Symbol(spreadFunc, Decl(objectSpread.ts, 37, 3)) +// boolean && T results in Partial +function conditionalSpread(b: boolean) : { x?: number | undefined, y?: number | undefined } { +>conditionalSpread : Symbol(conditionalSpread, Decl(objectSpread.ts, 37, 42)) +>b : Symbol(b, Decl(objectSpread.ts, 40, 27)) +>x : Symbol(x, Decl(objectSpread.ts, 40, 42)) +>y : Symbol(y, Decl(objectSpread.ts, 40, 66)) + + return { ...b && { x: 1, y: 2 } }; +>b : Symbol(b, Decl(objectSpread.ts, 40, 27)) +>x : Symbol(x, Decl(objectSpread.ts, 41, 22)) +>y : Symbol(y, Decl(objectSpread.ts, 41, 28)) +} +// other booleans result in { } +let spreadBool = { ... true } +>spreadBool : Symbol(spreadBool, Decl(objectSpread.ts, 44, 3)) + // any results in any let anything: any; ->anything : Symbol(anything, Decl(objectSpread.ts, 40, 3)) +>anything : Symbol(anything, Decl(objectSpread.ts, 47, 3)) let spreadAny = { ...anything }; ->spreadAny : Symbol(spreadAny, Decl(objectSpread.ts, 41, 3)) ->anything : Symbol(anything, Decl(objectSpread.ts, 40, 3)) +>spreadAny : Symbol(spreadAny, Decl(objectSpread.ts, 48, 3)) +>anything : Symbol(anything, Decl(objectSpread.ts, 47, 3)) // methods are not enumerable class C { p = 1; m() { } } ->C : Symbol(C, Decl(objectSpread.ts, 41, 32)) ->p : Symbol(C.p, Decl(objectSpread.ts, 44, 9)) ->m : Symbol(C.m, Decl(objectSpread.ts, 44, 16)) +>C : Symbol(C, Decl(objectSpread.ts, 48, 32)) +>p : Symbol(C.p, Decl(objectSpread.ts, 51, 9)) +>m : Symbol(C.m, Decl(objectSpread.ts, 51, 16)) let c: C = new C() ->c : Symbol(c, Decl(objectSpread.ts, 45, 3)) ->C : Symbol(C, Decl(objectSpread.ts, 41, 32)) ->C : Symbol(C, Decl(objectSpread.ts, 41, 32)) +>c : Symbol(c, Decl(objectSpread.ts, 52, 3)) +>C : Symbol(C, Decl(objectSpread.ts, 48, 32)) +>C : Symbol(C, Decl(objectSpread.ts, 48, 32)) let spreadC: { p: number } = { ...c } ->spreadC : Symbol(spreadC, Decl(objectSpread.ts, 46, 3)) ->p : Symbol(p, Decl(objectSpread.ts, 46, 14)) ->c : Symbol(c, Decl(objectSpread.ts, 45, 3)) +>spreadC : Symbol(spreadC, Decl(objectSpread.ts, 53, 3)) +>p : Symbol(p, Decl(objectSpread.ts, 53, 14)) +>c : Symbol(c, Decl(objectSpread.ts, 52, 3)) // own methods are enumerable let cplus: { p: number, plus(): void } = { ...c, plus() { return this.p + 1; } }; ->cplus : Symbol(cplus, Decl(objectSpread.ts, 49, 3)) ->p : Symbol(p, Decl(objectSpread.ts, 49, 12)) ->plus : Symbol(plus, Decl(objectSpread.ts, 49, 23)) ->c : Symbol(c, Decl(objectSpread.ts, 45, 3)) ->plus : Symbol(plus, Decl(objectSpread.ts, 49, 48)) +>cplus : Symbol(cplus, Decl(objectSpread.ts, 56, 3)) +>p : Symbol(p, Decl(objectSpread.ts, 56, 12)) +>plus : Symbol(plus, Decl(objectSpread.ts, 56, 23)) +>c : Symbol(c, Decl(objectSpread.ts, 52, 3)) +>plus : Symbol(plus, Decl(objectSpread.ts, 56, 48)) cplus.plus(); ->cplus.plus : Symbol(plus, Decl(objectSpread.ts, 49, 23)) ->cplus : Symbol(cplus, Decl(objectSpread.ts, 49, 3)) ->plus : Symbol(plus, Decl(objectSpread.ts, 49, 23)) +>cplus.plus : Symbol(plus, Decl(objectSpread.ts, 56, 23)) +>cplus : Symbol(cplus, Decl(objectSpread.ts, 56, 3)) +>plus : Symbol(plus, Decl(objectSpread.ts, 56, 23)) // new field's type conflicting with existing field is OK let changeTypeAfter: { a: string, b: string } = ->changeTypeAfter : Symbol(changeTypeAfter, Decl(objectSpread.ts, 53, 3)) ->a : Symbol(a, Decl(objectSpread.ts, 53, 22)) ->b : Symbol(b, Decl(objectSpread.ts, 53, 33)) +>changeTypeAfter : Symbol(changeTypeAfter, Decl(objectSpread.ts, 60, 3)) +>a : Symbol(a, Decl(objectSpread.ts, 60, 22)) +>b : Symbol(b, Decl(objectSpread.ts, 60, 33)) { ...o, a: 'wrong type?' } >o : Symbol(o, Decl(objectSpread.ts, 0, 3)) ->a : Symbol(a, Decl(objectSpread.ts, 54, 11)) +>a : Symbol(a, Decl(objectSpread.ts, 61, 11)) let changeTypeBefore: { a: number, b: string } = ->changeTypeBefore : Symbol(changeTypeBefore, Decl(objectSpread.ts, 55, 3)) ->a : Symbol(a, Decl(objectSpread.ts, 55, 23)) ->b : Symbol(b, Decl(objectSpread.ts, 55, 34)) +>changeTypeBefore : Symbol(changeTypeBefore, Decl(objectSpread.ts, 62, 3)) +>a : Symbol(a, Decl(objectSpread.ts, 62, 23)) +>b : Symbol(b, Decl(objectSpread.ts, 62, 34)) { a: 'wrong type?', ...o }; ->a : Symbol(a, Decl(objectSpread.ts, 56, 5)) +>a : Symbol(a, Decl(objectSpread.ts, 63, 5)) >o : Symbol(o, Decl(objectSpread.ts, 0, 3)) let changeTypeBoth: { a: string, b: number } = ->changeTypeBoth : Symbol(changeTypeBoth, Decl(objectSpread.ts, 57, 3)) ->a : Symbol(a, Decl(objectSpread.ts, 57, 21)) ->b : Symbol(b, Decl(objectSpread.ts, 57, 32)) +>changeTypeBoth : Symbol(changeTypeBoth, Decl(objectSpread.ts, 64, 3)) +>a : Symbol(a, Decl(objectSpread.ts, 64, 21)) +>b : Symbol(b, Decl(objectSpread.ts, 64, 32)) { ...o, ...swap }; >o : Symbol(o, Decl(objectSpread.ts, 0, 3)) >swap : Symbol(swap, Decl(objectSpread.ts, 2, 3)) // optional -let definiteBoolean: { sn: boolean }; ->definiteBoolean : Symbol(definiteBoolean, Decl(objectSpread.ts, 61, 3)) ->sn : Symbol(sn, Decl(objectSpread.ts, 61, 22)) +function container( +>container : Symbol(container, Decl(objectSpread.ts, 65, 22)) -let definiteString: { sn: string }; ->definiteString : Symbol(definiteString, Decl(objectSpread.ts, 62, 3)) ->sn : Symbol(sn, Decl(objectSpread.ts, 62, 21)) + definiteBoolean: { sn: boolean }, +>definiteBoolean : Symbol(definiteBoolean, Decl(objectSpread.ts, 68, 19)) +>sn : Symbol(sn, Decl(objectSpread.ts, 69, 22)) -let optionalString: { sn?: string }; ->optionalString : Symbol(optionalString, Decl(objectSpread.ts, 63, 3)) ->sn : Symbol(sn, Decl(objectSpread.ts, 63, 21)) + definiteString: { sn: string }, +>definiteString : Symbol(definiteString, Decl(objectSpread.ts, 69, 37)) +>sn : Symbol(sn, Decl(objectSpread.ts, 70, 21)) -let optionalNumber: { sn?: number }; ->optionalNumber : Symbol(optionalNumber, Decl(objectSpread.ts, 64, 3)) ->sn : Symbol(sn, Decl(objectSpread.ts, 64, 21)) + optionalString: { sn?: string }, +>optionalString : Symbol(optionalString, Decl(objectSpread.ts, 70, 35)) +>sn : Symbol(sn, Decl(objectSpread.ts, 71, 21)) -let optionalUnionStops: { sn: string | number | boolean } = { ...definiteBoolean, ...definiteString, ...optionalNumber }; ->optionalUnionStops : Symbol(optionalUnionStops, Decl(objectSpread.ts, 65, 3)) ->sn : Symbol(sn, Decl(objectSpread.ts, 65, 25)) ->definiteBoolean : Symbol(definiteBoolean, Decl(objectSpread.ts, 61, 3)) ->definiteString : Symbol(definiteString, Decl(objectSpread.ts, 62, 3)) ->optionalNumber : Symbol(optionalNumber, Decl(objectSpread.ts, 64, 3)) + optionalNumber: { sn?: number }) { +>optionalNumber : Symbol(optionalNumber, Decl(objectSpread.ts, 71, 36)) +>sn : Symbol(sn, Decl(objectSpread.ts, 72, 21)) -let optionalUnionDuplicates: { sn: string | number } = { ...definiteBoolean, ...definiteString, ...optionalString, ...optionalNumber }; ->optionalUnionDuplicates : Symbol(optionalUnionDuplicates, Decl(objectSpread.ts, 66, 3)) ->sn : Symbol(sn, Decl(objectSpread.ts, 66, 30)) ->definiteBoolean : Symbol(definiteBoolean, Decl(objectSpread.ts, 61, 3)) ->definiteString : Symbol(definiteString, Decl(objectSpread.ts, 62, 3)) ->optionalString : Symbol(optionalString, Decl(objectSpread.ts, 63, 3)) ->optionalNumber : Symbol(optionalNumber, Decl(objectSpread.ts, 64, 3)) + let optionalUnionStops: { sn: string | number | boolean } = { ...definiteBoolean, ...definiteString, ...optionalNumber }; +>optionalUnionStops : Symbol(optionalUnionStops, Decl(objectSpread.ts, 73, 7)) +>sn : Symbol(sn, Decl(objectSpread.ts, 73, 29)) +>definiteBoolean : Symbol(definiteBoolean, Decl(objectSpread.ts, 68, 19)) +>definiteString : Symbol(definiteString, Decl(objectSpread.ts, 69, 37)) +>optionalNumber : Symbol(optionalNumber, Decl(objectSpread.ts, 71, 36)) -let allOptional: { sn?: string | number } = { ...optionalString, ...optionalNumber }; ->allOptional : Symbol(allOptional, Decl(objectSpread.ts, 67, 3)) ->sn : Symbol(sn, Decl(objectSpread.ts, 67, 18)) ->optionalString : Symbol(optionalString, Decl(objectSpread.ts, 63, 3)) ->optionalNumber : Symbol(optionalNumber, Decl(objectSpread.ts, 64, 3)) + let optionalUnionDuplicates: { sn: string | number } = { ...definiteBoolean, ...definiteString, ...optionalString, ...optionalNumber }; +>optionalUnionDuplicates : Symbol(optionalUnionDuplicates, Decl(objectSpread.ts, 74, 7)) +>sn : Symbol(sn, Decl(objectSpread.ts, 74, 34)) +>definiteBoolean : Symbol(definiteBoolean, Decl(objectSpread.ts, 68, 19)) +>definiteString : Symbol(definiteString, Decl(objectSpread.ts, 69, 37)) +>optionalString : Symbol(optionalString, Decl(objectSpread.ts, 70, 35)) +>optionalNumber : Symbol(optionalNumber, Decl(objectSpread.ts, 71, 36)) -// computed property -let computedFirst: { a: number, b: string, "before everything": number } = ->computedFirst : Symbol(computedFirst, Decl(objectSpread.ts, 70, 3)) ->a : Symbol(a, Decl(objectSpread.ts, 70, 20)) ->b : Symbol(b, Decl(objectSpread.ts, 70, 31)) + let allOptional: { sn?: string | number } = { ...optionalString, ...optionalNumber }; +>allOptional : Symbol(allOptional, Decl(objectSpread.ts, 75, 7)) +>sn : Symbol(sn, Decl(objectSpread.ts, 75, 22)) +>optionalString : Symbol(optionalString, Decl(objectSpread.ts, 70, 35)) +>optionalNumber : Symbol(optionalNumber, Decl(objectSpread.ts, 71, 36)) - { ['before everything']: 12, ...o, b: 'yes' } ->'before everything' : Symbol(['before everything'], Decl(objectSpread.ts, 71, 5)) + // computed property + let computedFirst: { a: number, b: string, "before everything": number } = +>computedFirst : Symbol(computedFirst, Decl(objectSpread.ts, 78, 7)) +>a : Symbol(a, Decl(objectSpread.ts, 78, 24)) +>b : Symbol(b, Decl(objectSpread.ts, 78, 35)) + + { ['before everything']: 12, ...o, b: 'yes' } +>'before everything' : Symbol(['before everything'], Decl(objectSpread.ts, 79, 9)) >o : Symbol(o, Decl(objectSpread.ts, 0, 3)) ->b : Symbol(b, Decl(objectSpread.ts, 71, 38)) +>b : Symbol(b, Decl(objectSpread.ts, 79, 42)) -let computedMiddle: { a: number, b: string, c: boolean, "in the middle": number } = ->computedMiddle : Symbol(computedMiddle, Decl(objectSpread.ts, 72, 3)) ->a : Symbol(a, Decl(objectSpread.ts, 72, 21)) ->b : Symbol(b, Decl(objectSpread.ts, 72, 32)) ->c : Symbol(c, Decl(objectSpread.ts, 72, 43)) + let computedMiddle: { a: number, b: string, c: boolean, "in the middle": number } = +>computedMiddle : Symbol(computedMiddle, Decl(objectSpread.ts, 80, 7)) +>a : Symbol(a, Decl(objectSpread.ts, 80, 25)) +>b : Symbol(b, Decl(objectSpread.ts, 80, 36)) +>c : Symbol(c, Decl(objectSpread.ts, 80, 47)) - { ...o, ['in the middle']: 13, b: 'maybe?', ...o2 } + { ...o, ['in the middle']: 13, b: 'maybe?', ...o2 } >o : Symbol(o, Decl(objectSpread.ts, 0, 3)) ->'in the middle' : Symbol(['in the middle'], Decl(objectSpread.ts, 73, 11)) ->b : Symbol(b, Decl(objectSpread.ts, 73, 34)) +>'in the middle' : Symbol(['in the middle'], Decl(objectSpread.ts, 81, 15)) +>b : Symbol(b, Decl(objectSpread.ts, 81, 38)) >o2 : Symbol(o2, Decl(objectSpread.ts, 1, 3)) -let computedAfter: { a: number, b: string, "at the end": number } = ->computedAfter : Symbol(computedAfter, Decl(objectSpread.ts, 74, 3)) ->a : Symbol(a, Decl(objectSpread.ts, 74, 20)) ->b : Symbol(b, Decl(objectSpread.ts, 74, 31)) + let computedAfter: { a: number, b: string, "at the end": number } = +>computedAfter : Symbol(computedAfter, Decl(objectSpread.ts, 82, 7)) +>a : Symbol(a, Decl(objectSpread.ts, 82, 24)) +>b : Symbol(b, Decl(objectSpread.ts, 82, 35)) - { ...o, b: 'yeah', ['at the end']: 14 } + { ...o, b: 'yeah', ['at the end']: 14 } >o : Symbol(o, Decl(objectSpread.ts, 0, 3)) ->b : Symbol(b, Decl(objectSpread.ts, 75, 11)) ->'at the end' : Symbol(['at the end'], Decl(objectSpread.ts, 75, 22)) - +>b : Symbol(b, Decl(objectSpread.ts, 83, 15)) +>'at the end' : Symbol(['at the end'], Decl(objectSpread.ts, 83, 26)) +} // shortcut syntax let a = 12; ->a : Symbol(a, Decl(objectSpread.ts, 77, 3)) +>a : Symbol(a, Decl(objectSpread.ts, 86, 3)) let shortCutted: { a: number, b: string } = { ...o, a } ->shortCutted : Symbol(shortCutted, Decl(objectSpread.ts, 78, 3)) ->a : Symbol(a, Decl(objectSpread.ts, 78, 18)) ->b : Symbol(b, Decl(objectSpread.ts, 78, 29)) +>shortCutted : Symbol(shortCutted, Decl(objectSpread.ts, 87, 3)) +>a : Symbol(a, Decl(objectSpread.ts, 87, 18)) +>b : Symbol(b, Decl(objectSpread.ts, 87, 29)) >o : Symbol(o, Decl(objectSpread.ts, 0, 3)) ->a : Symbol(a, Decl(objectSpread.ts, 78, 51)) +>a : Symbol(a, Decl(objectSpread.ts, 87, 51)) // non primitive let spreadNonPrimitive = { ...{}}; ->spreadNonPrimitive : Symbol(spreadNonPrimitive, Decl(objectSpread.ts, 80, 3)) +>spreadNonPrimitive : Symbol(spreadNonPrimitive, Decl(objectSpread.ts, 89, 3)) diff --git a/tests/baselines/reference/objectSpread.types b/tests/baselines/reference/objectSpread.types index 7bac35119ed..d696ed9ac7c 100644 --- a/tests/baselines/reference/objectSpread.types +++ b/tests/baselines/reference/objectSpread.types @@ -230,6 +230,29 @@ let spreadFunc = { ...(function () { }) }; >(function () { }) : () => void >function () { } : () => void +// boolean && T results in Partial +function conditionalSpread(b: boolean) : { x?: number | undefined, y?: number | undefined } { +>conditionalSpread : (b: boolean) => { x?: number | undefined; y?: number | undefined; } +>b : boolean +>x : number | undefined +>y : number | undefined + + return { ...b && { x: 1, y: 2 } }; +>{ ...b && { x: 1, y: 2 } } : { x?: number | undefined; y?: number | undefined; } +>b && { x: 1, y: 2 } : false | { x: number; y: number; } +>b : boolean +>{ x: 1, y: 2 } : { x: number; y: number; } +>x : number +>1 : 1 +>y : number +>2 : 2 +} +// other booleans result in { } +let spreadBool = { ... true } +>spreadBool : {} +>{ ... true } : {} +>true : true + // any results in any let anything: any; >anything : any @@ -312,53 +335,56 @@ let changeTypeBoth: { a: string, b: number } = >swap : { a: string; b: number; } // optional -let definiteBoolean: { sn: boolean }; +function container( +>container : (definiteBoolean: { sn: boolean; }, definiteString: { sn: string; }, optionalString: { sn?: string | undefined; }, optionalNumber: { sn?: number | undefined; }) => void + + definiteBoolean: { sn: boolean }, >definiteBoolean : { sn: boolean; } >sn : boolean -let definiteString: { sn: string }; + definiteString: { sn: string }, >definiteString : { sn: string; } >sn : string -let optionalString: { sn?: string }; ->optionalString : { sn?: string; } ->sn : string + optionalString: { sn?: string }, +>optionalString : { sn?: string | undefined; } +>sn : string | undefined -let optionalNumber: { sn?: number }; ->optionalNumber : { sn?: number; } ->sn : number + optionalNumber: { sn?: number }) { +>optionalNumber : { sn?: number | undefined; } +>sn : number | undefined -let optionalUnionStops: { sn: string | number | boolean } = { ...definiteBoolean, ...definiteString, ...optionalNumber }; + let optionalUnionStops: { sn: string | number | boolean } = { ...definiteBoolean, ...definiteString, ...optionalNumber }; >optionalUnionStops : { sn: string | number | boolean; } >sn : string | number | boolean >{ ...definiteBoolean, ...definiteString, ...optionalNumber } : { sn: string | number; } >definiteBoolean : { sn: boolean; } >definiteString : { sn: string; } ->optionalNumber : { sn?: number; } +>optionalNumber : { sn?: number | undefined; } -let optionalUnionDuplicates: { sn: string | number } = { ...definiteBoolean, ...definiteString, ...optionalString, ...optionalNumber }; + let optionalUnionDuplicates: { sn: string | number } = { ...definiteBoolean, ...definiteString, ...optionalString, ...optionalNumber }; >optionalUnionDuplicates : { sn: string | number; } >sn : string | number >{ ...definiteBoolean, ...definiteString, ...optionalString, ...optionalNumber } : { sn: string | number; } >definiteBoolean : { sn: boolean; } >definiteString : { sn: string; } ->optionalString : { sn?: string; } ->optionalNumber : { sn?: number; } +>optionalString : { sn?: string | undefined; } +>optionalNumber : { sn?: number | undefined; } -let allOptional: { sn?: string | number } = { ...optionalString, ...optionalNumber }; ->allOptional : { sn?: string | number; } ->sn : string | number ->{ ...optionalString, ...optionalNumber } : { sn?: string | number; } ->optionalString : { sn?: string; } ->optionalNumber : { sn?: number; } + let allOptional: { sn?: string | number } = { ...optionalString, ...optionalNumber }; +>allOptional : { sn?: string | number | undefined; } +>sn : string | number | undefined +>{ ...optionalString, ...optionalNumber } : { sn?: string | number | undefined; } +>optionalString : { sn?: string | undefined; } +>optionalNumber : { sn?: number | undefined; } -// computed property -let computedFirst: { a: number, b: string, "before everything": number } = + // computed property + let computedFirst: { a: number, b: string, "before everything": number } = >computedFirst : { a: number; b: string; "before everything": number; } >a : number >b : string - { ['before everything']: 12, ...o, b: 'yes' } + { ['before everything']: 12, ...o, b: 'yes' } >{ ['before everything']: 12, ...o, b: 'yes' } : { b: string; a: number; ['before everything']: number; } >'before everything' : "before everything" >12 : 12 @@ -366,13 +392,13 @@ let computedFirst: { a: number, b: string, "before everything": number } = >b : string >'yes' : "yes" -let computedMiddle: { a: number, b: string, c: boolean, "in the middle": number } = + let computedMiddle: { a: number, b: string, c: boolean, "in the middle": number } = >computedMiddle : { a: number; b: string; c: boolean; "in the middle": number; } >a : number >b : string >c : boolean - { ...o, ['in the middle']: 13, b: 'maybe?', ...o2 } + { ...o, ['in the middle']: 13, b: 'maybe?', ...o2 } >{ ...o, ['in the middle']: 13, b: 'maybe?', ...o2 } : { b: string; c: boolean; ['in the middle']: number; a: number; } >o : { a: number; b: string; } >'in the middle' : "in the middle" @@ -381,19 +407,19 @@ let computedMiddle: { a: number, b: string, c: boolean, "in the middle": number >'maybe?' : "maybe?" >o2 : { b: string; c: boolean; } -let computedAfter: { a: number, b: string, "at the end": number } = + let computedAfter: { a: number, b: string, "at the end": number } = >computedAfter : { a: number; b: string; "at the end": number; } >a : number >b : string - { ...o, b: 'yeah', ['at the end']: 14 } + { ...o, b: 'yeah', ['at the end']: 14 } >{ ...o, b: 'yeah', ['at the end']: 14 } : { b: string; ['at the end']: number; a: number; } >o : { a: number; b: string; } >b : string >'yeah' : "yeah" >'at the end' : "at the end" >14 : 14 - +} // shortcut syntax let a = 12; >a : number diff --git a/tests/baselines/reference/objectSpreadNegative.errors.txt b/tests/baselines/reference/objectSpreadNegative.errors.txt index a9381a0dcb1..14eba9d6f2a 100644 --- a/tests/baselines/reference/objectSpreadNegative.errors.txt +++ b/tests/baselines/reference/objectSpreadNegative.errors.txt @@ -9,23 +9,22 @@ tests/cases/conformance/types/spread/objectSpreadNegative.ts(28,36): error TS230 tests/cases/conformance/types/spread/objectSpreadNegative.ts(28,53): error TS2300: Duplicate identifier 'b'. tests/cases/conformance/types/spread/objectSpreadNegative.ts(32,19): error TS2698: Spread types may only be created from object types. tests/cases/conformance/types/spread/objectSpreadNegative.ts(33,19): error TS2698: Spread types may only be created from object types. -tests/cases/conformance/types/spread/objectSpreadNegative.ts(35,20): error TS2698: Spread types may only be created from object types. -tests/cases/conformance/types/spread/objectSpreadNegative.ts(37,19): error TS2698: Spread types may only be created from object types. -tests/cases/conformance/types/spread/objectSpreadNegative.ts(42,1): error TS2349: Cannot invoke an expression whose type lacks a call signature. Type '{}' has no compatible call signatures. -tests/cases/conformance/types/spread/objectSpreadNegative.ts(46,12): error TS2339: Property 'b' does not exist on type '{}'. -tests/cases/conformance/types/spread/objectSpreadNegative.ts(52,9): error TS2339: Property 'm' does not exist on type '{ p: number; }'. -tests/cases/conformance/types/spread/objectSpreadNegative.ts(57,11): error TS2339: Property 'a' does not exist on type '{}'. +tests/cases/conformance/types/spread/objectSpreadNegative.ts(34,19): error TS2698: Spread types may only be created from object types. +tests/cases/conformance/types/spread/objectSpreadNegative.ts(39,1): error TS2349: Cannot invoke an expression whose type lacks a call signature. Type '{}' has no compatible call signatures. +tests/cases/conformance/types/spread/objectSpreadNegative.ts(43,12): error TS2339: Property 'b' does not exist on type '{}'. +tests/cases/conformance/types/spread/objectSpreadNegative.ts(49,9): error TS2339: Property 'm' does not exist on type '{ p: number; }'. +tests/cases/conformance/types/spread/objectSpreadNegative.ts(54,11): error TS2339: Property 'a' does not exist on type '{}'. +tests/cases/conformance/types/spread/objectSpreadNegative.ts(58,14): error TS2698: Spread types may only be created from object types. tests/cases/conformance/types/spread/objectSpreadNegative.ts(61,14): error TS2698: Spread types may only be created from object types. -tests/cases/conformance/types/spread/objectSpreadNegative.ts(64,14): error TS2698: Spread types may only be created from object types. -tests/cases/conformance/types/spread/objectSpreadNegative.ts(78,37): error TS2322: Type '{ a: string; b: string; extra: string; }' is not assignable to type 'A'. +tests/cases/conformance/types/spread/objectSpreadNegative.ts(75,37): error TS2322: Type '{ a: string; b: string; extra: string; }' is not assignable to type 'A'. Object literal may only specify known properties, and 'extra' does not exist in type 'A'. -tests/cases/conformance/types/spread/objectSpreadNegative.ts(81,7): error TS2322: Type '{ a: string; b: string; extra: string; }' is not assignable to type 'A'. +tests/cases/conformance/types/spread/objectSpreadNegative.ts(78,7): error TS2322: Type '{ a: string; b: string; extra: string; }' is not assignable to type 'A'. Object literal may only specify known properties, and 'extra' does not exist in type 'A'. -tests/cases/conformance/types/spread/objectSpreadNegative.ts(83,7): error TS2322: Type '{ a: string; b: string; extra: string; }' is not assignable to type 'A'. +tests/cases/conformance/types/spread/objectSpreadNegative.ts(80,7): error TS2322: Type '{ a: string; b: string; extra: string; }' is not assignable to type 'A'. Object literal may only specify known properties, and 'extra' does not exist in type 'A'. -==== tests/cases/conformance/types/spread/objectSpreadNegative.ts (19 errors) ==== +==== tests/cases/conformance/types/spread/objectSpreadNegative.ts (18 errors) ==== let o = { a: 1, b: 'no' } /// private propagates @@ -78,11 +77,6 @@ tests/cases/conformance/types/spread/objectSpreadNegative.ts(83,7): error TS2322 let spreadSum = { ...1 + 1 }; ~~~~~~~~ !!! error TS2698: Spread types may only be created from object types. - spreadSum.toFixed(); // error, no methods from number - let spreadBool = { ...false }; - ~~~~~~~~ -!!! error TS2698: Spread types may only be created from object types. - spreadBool.valueOf(); // error, what were you thinking? let spreadStr = { ...'foo' }; ~~~~~~~~ !!! error TS2698: Spread types may only be created from object types. diff --git a/tests/baselines/reference/objectSpreadNegative.js b/tests/baselines/reference/objectSpreadNegative.js index aab8ffc4e91..6e82a19acbc 100644 --- a/tests/baselines/reference/objectSpreadNegative.js +++ b/tests/baselines/reference/objectSpreadNegative.js @@ -32,9 +32,6 @@ let duplicatedSpread = { ...o, ...o } // primitives are not allowed let spreadNum = { ...12 }; let spreadSum = { ...1 + 1 }; -spreadSum.toFixed(); // error, no methods from number -let spreadBool = { ...false }; -spreadBool.valueOf(); // error, what were you thinking? let spreadStr = { ...'foo' }; spreadStr.length; // error, no 'length' spreadStr.charAt(1); // error, no methods either @@ -124,9 +121,6 @@ var duplicatedSpread = __assign({}, o, o); // primitives are not allowed var spreadNum = __assign({}, 12); var spreadSum = __assign({}, 1 + 1); -spreadSum.toFixed(); // error, no methods from number -var spreadBool = __assign({}, false); -spreadBool.valueOf(); // error, what were you thinking? var spreadStr = __assign({}, 'foo'); spreadStr.length; // error, no 'length' spreadStr.charAt(1); // error, no methods either diff --git a/tests/cases/conformance/types/spread/objectSpread.ts b/tests/cases/conformance/types/spread/objectSpread.ts index 59b93bdd9e4..378c5558fc5 100644 --- a/tests/cases/conformance/types/spread/objectSpread.ts +++ b/tests/cases/conformance/types/spread/objectSpread.ts @@ -1,3 +1,4 @@ +// @strictNullChecks: true // @target: es5 let o = { a: 1, b: 'no' } let o2 = { b: 'yes', c: true } @@ -38,6 +39,13 @@ getter.a = 12; // functions result in { } let spreadFunc = { ...(function () { }) }; +// boolean && T results in Partial +function conditionalSpread(b: boolean) : { x?: number | undefined, y?: number | undefined } { + return { ...b && { x: 1, y: 2 } }; +} +// other booleans result in { } +let spreadBool = { ... true } + // any results in any let anything: any; let spreadAny = { ...anything }; @@ -60,21 +68,23 @@ let changeTypeBoth: { a: string, b: number } = { ...o, ...swap }; // optional -let definiteBoolean: { sn: boolean }; -let definiteString: { sn: string }; -let optionalString: { sn?: string }; -let optionalNumber: { sn?: number }; -let optionalUnionStops: { sn: string | number | boolean } = { ...definiteBoolean, ...definiteString, ...optionalNumber }; -let optionalUnionDuplicates: { sn: string | number } = { ...definiteBoolean, ...definiteString, ...optionalString, ...optionalNumber }; -let allOptional: { sn?: string | number } = { ...optionalString, ...optionalNumber }; +function container( + definiteBoolean: { sn: boolean }, + definiteString: { sn: string }, + optionalString: { sn?: string }, + optionalNumber: { sn?: number }) { + let optionalUnionStops: { sn: string | number | boolean } = { ...definiteBoolean, ...definiteString, ...optionalNumber }; + let optionalUnionDuplicates: { sn: string | number } = { ...definiteBoolean, ...definiteString, ...optionalString, ...optionalNumber }; + let allOptional: { sn?: string | number } = { ...optionalString, ...optionalNumber }; -// computed property -let computedFirst: { a: number, b: string, "before everything": number } = - { ['before everything']: 12, ...o, b: 'yes' } -let computedMiddle: { a: number, b: string, c: boolean, "in the middle": number } = - { ...o, ['in the middle']: 13, b: 'maybe?', ...o2 } -let computedAfter: { a: number, b: string, "at the end": number } = - { ...o, b: 'yeah', ['at the end']: 14 } + // computed property + let computedFirst: { a: number, b: string, "before everything": number } = + { ['before everything']: 12, ...o, b: 'yes' } + let computedMiddle: { a: number, b: string, c: boolean, "in the middle": number } = + { ...o, ['in the middle']: 13, b: 'maybe?', ...o2 } + let computedAfter: { a: number, b: string, "at the end": number } = + { ...o, b: 'yeah', ['at the end']: 14 } +} // shortcut syntax let a = 12; let shortCutted: { a: number, b: string } = { ...o, a } diff --git a/tests/cases/conformance/types/spread/objectSpreadNegative.ts b/tests/cases/conformance/types/spread/objectSpreadNegative.ts index fced7706c96..beb9ff265b4 100644 --- a/tests/cases/conformance/types/spread/objectSpreadNegative.ts +++ b/tests/cases/conformance/types/spread/objectSpreadNegative.ts @@ -32,9 +32,6 @@ let duplicatedSpread = { ...o, ...o } // primitives are not allowed let spreadNum = { ...12 }; let spreadSum = { ...1 + 1 }; -spreadSum.toFixed(); // error, no methods from number -let spreadBool = { ...false }; -spreadBool.valueOf(); // error, what were you thinking? let spreadStr = { ...'foo' }; spreadStr.length; // error, no 'length' spreadStr.charAt(1); // error, no methods either From d951c14052b077cef3b8d1d6ef83c89f766c6d47 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Wed, 13 Sep 2017 14:56:15 -0700 Subject: [PATCH 325/370] Allow all possibly falsy types in spreads And update tests to reflect that --- src/compiler/checker.ts | 10 +- tests/baselines/reference/objectSpread.js | 34 ++- .../baselines/reference/objectSpread.symbols | 230 +++++++++++------- tests/baselines/reference/objectSpread.types | 86 ++++++- .../reference/objectSpreadNegative.errors.txt | 17 +- .../objectSpreadNegativeParse.errors.txt | 5 +- .../conformance/types/spread/objectSpread.ts | 20 +- 7 files changed, 296 insertions(+), 106 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 287311e6433..ff796879071 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -7850,7 +7850,7 @@ namespace ts { return mapType(right, t => getSpreadType(left, t)); } } - if (right.flags & (TypeFlags.NonPrimitive | TypeFlags.BooleanLike)) { + if (right.flags & (TypeFlags.NonPrimitive | TypeFlags.BooleanLike | TypeFlags.NumberLike | TypeFlags.StringLike)) { return emptyObjectType; } @@ -7923,7 +7923,11 @@ namespace ts { function getPartialTypeFromFalseUnion(type: UnionType): Type | undefined { if (type.types.length === 2) { - const i = type.types.indexOf(falseType); + // getFalsyFlagsOfTypes + // getTypeFacts + const i = Math.max(type.types.indexOf(falseType), + type.types.indexOf(zeroType), + type.types.indexOf(emptyStringType)); if (i > -1) { const members = createSymbolTable(); const other = type.types[i === 0 ? 1 : 0]; @@ -13785,7 +13789,7 @@ namespace ts { } function isValidSpreadType(type: Type): boolean { - return !!(type.flags & (TypeFlags.Any | TypeFlags.Nullable | TypeFlags.NonPrimitive | TypeFlags.BooleanLike) || + return !!(type.flags & (TypeFlags.Any | TypeFlags.PossiblyFalsy | TypeFlags.NonPrimitive) || type.flags & TypeFlags.Object && !isGenericMappedType(type) || type.flags & TypeFlags.UnionOrIntersection && !forEach((type).types, t => !isValidSpreadType(t))); } diff --git a/tests/baselines/reference/objectSpread.js b/tests/baselines/reference/objectSpread.js index 11b904a4806..7eab2da265f 100644 --- a/tests/baselines/reference/objectSpread.js +++ b/tests/baselines/reference/objectSpread.js @@ -39,9 +39,27 @@ getter.a = 12; let spreadFunc = { ...(function () { }) }; // boolean && T results in Partial -function conditionalSpread(b: boolean) : { x?: number | undefined, y?: number | undefined } { +function conditionalSpreadBoolean(b: boolean) : { x?: number | undefined, y?: number | undefined } { return { ...b && { x: 1, y: 2 } }; } +function conditionalSpreadNumber(nt: number): { x?: number | undefined, y: number } { + let o = { x: 12, y: 13 } + o = { + ...o, + ...nt && { x: nt } + } + let o2 = { ...nt && { x: nt }} + return o; +} +function conditionalSpreadString(st: string): { x?: string | undefined, y: number } { + let o = { x: 'hi', y: 13 } + o = { + ...o, + ...st && { x: st } + } + let o2 = { ...st && { x: st }} + return o; +} // other booleans result in { } let spreadBool = { ... true } @@ -124,9 +142,21 @@ getter.a = 12; // functions result in { } var spreadFunc = __assign({}, (function () { })); // boolean && T results in Partial -function conditionalSpread(b) { +function conditionalSpreadBoolean(b) { return __assign({}, b && { x: 1, y: 2 }); } +function conditionalSpreadNumber(nt) { + var o = { x: 12, y: 13 }; + o = __assign({}, o, nt && { x: nt }); + var o2 = __assign({}, nt && { x: nt }); + return o; +} +function conditionalSpreadString(st) { + var o = { x: 'hi', y: 13 }; + o = __assign({}, o, st && { x: st }); + var o2 = __assign({}, st && { x: st }); + return o; +} // other booleans result in { } var spreadBool = __assign({}, true); // any results in any diff --git a/tests/baselines/reference/objectSpread.symbols b/tests/baselines/reference/objectSpread.symbols index 0c5e8a4c5a8..9f257870a0b 100644 --- a/tests/baselines/reference/objectSpread.symbols +++ b/tests/baselines/reference/objectSpread.symbols @@ -170,81 +170,143 @@ let spreadFunc = { ...(function () { }) }; >spreadFunc : Symbol(spreadFunc, Decl(objectSpread.ts, 37, 3)) // boolean && T results in Partial -function conditionalSpread(b: boolean) : { x?: number | undefined, y?: number | undefined } { ->conditionalSpread : Symbol(conditionalSpread, Decl(objectSpread.ts, 37, 42)) ->b : Symbol(b, Decl(objectSpread.ts, 40, 27)) ->x : Symbol(x, Decl(objectSpread.ts, 40, 42)) ->y : Symbol(y, Decl(objectSpread.ts, 40, 66)) +function conditionalSpreadBoolean(b: boolean) : { x?: number | undefined, y?: number | undefined } { +>conditionalSpreadBoolean : Symbol(conditionalSpreadBoolean, Decl(objectSpread.ts, 37, 42)) +>b : Symbol(b, Decl(objectSpread.ts, 40, 34)) +>x : Symbol(x, Decl(objectSpread.ts, 40, 49)) +>y : Symbol(y, Decl(objectSpread.ts, 40, 73)) return { ...b && { x: 1, y: 2 } }; ->b : Symbol(b, Decl(objectSpread.ts, 40, 27)) +>b : Symbol(b, Decl(objectSpread.ts, 40, 34)) >x : Symbol(x, Decl(objectSpread.ts, 41, 22)) >y : Symbol(y, Decl(objectSpread.ts, 41, 28)) } +function conditionalSpreadNumber(nt: number): { x?: number | undefined, y: number } { +>conditionalSpreadNumber : Symbol(conditionalSpreadNumber, Decl(objectSpread.ts, 42, 1)) +>nt : Symbol(nt, Decl(objectSpread.ts, 43, 33)) +>x : Symbol(x, Decl(objectSpread.ts, 43, 47)) +>y : Symbol(y, Decl(objectSpread.ts, 43, 71)) + + let o = { x: 12, y: 13 } +>o : Symbol(o, Decl(objectSpread.ts, 44, 7)) +>x : Symbol(x, Decl(objectSpread.ts, 44, 13)) +>y : Symbol(y, Decl(objectSpread.ts, 44, 20)) + + o = { +>o : Symbol(o, Decl(objectSpread.ts, 44, 7)) + + ...o, +>o : Symbol(o, Decl(objectSpread.ts, 44, 7)) + + ...nt && { x: nt } +>nt : Symbol(nt, Decl(objectSpread.ts, 43, 33)) +>x : Symbol(x, Decl(objectSpread.ts, 47, 18)) +>nt : Symbol(nt, Decl(objectSpread.ts, 43, 33)) + } + let o2 = { ...nt && { x: nt }} +>o2 : Symbol(o2, Decl(objectSpread.ts, 49, 7)) +>nt : Symbol(nt, Decl(objectSpread.ts, 43, 33)) +>x : Symbol(x, Decl(objectSpread.ts, 49, 25)) +>nt : Symbol(nt, Decl(objectSpread.ts, 43, 33)) + + return o; +>o : Symbol(o, Decl(objectSpread.ts, 44, 7)) +} +function conditionalSpreadString(st: string): { x?: string | undefined, y: number } { +>conditionalSpreadString : Symbol(conditionalSpreadString, Decl(objectSpread.ts, 51, 1)) +>st : Symbol(st, Decl(objectSpread.ts, 52, 33)) +>x : Symbol(x, Decl(objectSpread.ts, 52, 47)) +>y : Symbol(y, Decl(objectSpread.ts, 52, 71)) + + let o = { x: 'hi', y: 13 } +>o : Symbol(o, Decl(objectSpread.ts, 53, 7)) +>x : Symbol(x, Decl(objectSpread.ts, 53, 13)) +>y : Symbol(y, Decl(objectSpread.ts, 53, 22)) + + o = { +>o : Symbol(o, Decl(objectSpread.ts, 53, 7)) + + ...o, +>o : Symbol(o, Decl(objectSpread.ts, 53, 7)) + + ...st && { x: st } +>st : Symbol(st, Decl(objectSpread.ts, 52, 33)) +>x : Symbol(x, Decl(objectSpread.ts, 56, 18)) +>st : Symbol(st, Decl(objectSpread.ts, 52, 33)) + } + let o2 = { ...st && { x: st }} +>o2 : Symbol(o2, Decl(objectSpread.ts, 58, 7)) +>st : Symbol(st, Decl(objectSpread.ts, 52, 33)) +>x : Symbol(x, Decl(objectSpread.ts, 58, 25)) +>st : Symbol(st, Decl(objectSpread.ts, 52, 33)) + + return o; +>o : Symbol(o, Decl(objectSpread.ts, 53, 7)) +} // other booleans result in { } let spreadBool = { ... true } ->spreadBool : Symbol(spreadBool, Decl(objectSpread.ts, 44, 3)) +>spreadBool : Symbol(spreadBool, Decl(objectSpread.ts, 62, 3)) // any results in any let anything: any; ->anything : Symbol(anything, Decl(objectSpread.ts, 47, 3)) +>anything : Symbol(anything, Decl(objectSpread.ts, 65, 3)) let spreadAny = { ...anything }; ->spreadAny : Symbol(spreadAny, Decl(objectSpread.ts, 48, 3)) ->anything : Symbol(anything, Decl(objectSpread.ts, 47, 3)) +>spreadAny : Symbol(spreadAny, Decl(objectSpread.ts, 66, 3)) +>anything : Symbol(anything, Decl(objectSpread.ts, 65, 3)) // methods are not enumerable class C { p = 1; m() { } } ->C : Symbol(C, Decl(objectSpread.ts, 48, 32)) ->p : Symbol(C.p, Decl(objectSpread.ts, 51, 9)) ->m : Symbol(C.m, Decl(objectSpread.ts, 51, 16)) +>C : Symbol(C, Decl(objectSpread.ts, 66, 32)) +>p : Symbol(C.p, Decl(objectSpread.ts, 69, 9)) +>m : Symbol(C.m, Decl(objectSpread.ts, 69, 16)) let c: C = new C() ->c : Symbol(c, Decl(objectSpread.ts, 52, 3)) ->C : Symbol(C, Decl(objectSpread.ts, 48, 32)) ->C : Symbol(C, Decl(objectSpread.ts, 48, 32)) +>c : Symbol(c, Decl(objectSpread.ts, 70, 3)) +>C : Symbol(C, Decl(objectSpread.ts, 66, 32)) +>C : Symbol(C, Decl(objectSpread.ts, 66, 32)) let spreadC: { p: number } = { ...c } ->spreadC : Symbol(spreadC, Decl(objectSpread.ts, 53, 3)) ->p : Symbol(p, Decl(objectSpread.ts, 53, 14)) ->c : Symbol(c, Decl(objectSpread.ts, 52, 3)) +>spreadC : Symbol(spreadC, Decl(objectSpread.ts, 71, 3)) +>p : Symbol(p, Decl(objectSpread.ts, 71, 14)) +>c : Symbol(c, Decl(objectSpread.ts, 70, 3)) // own methods are enumerable let cplus: { p: number, plus(): void } = { ...c, plus() { return this.p + 1; } }; ->cplus : Symbol(cplus, Decl(objectSpread.ts, 56, 3)) ->p : Symbol(p, Decl(objectSpread.ts, 56, 12)) ->plus : Symbol(plus, Decl(objectSpread.ts, 56, 23)) ->c : Symbol(c, Decl(objectSpread.ts, 52, 3)) ->plus : Symbol(plus, Decl(objectSpread.ts, 56, 48)) +>cplus : Symbol(cplus, Decl(objectSpread.ts, 74, 3)) +>p : Symbol(p, Decl(objectSpread.ts, 74, 12)) +>plus : Symbol(plus, Decl(objectSpread.ts, 74, 23)) +>c : Symbol(c, Decl(objectSpread.ts, 70, 3)) +>plus : Symbol(plus, Decl(objectSpread.ts, 74, 48)) cplus.plus(); ->cplus.plus : Symbol(plus, Decl(objectSpread.ts, 56, 23)) ->cplus : Symbol(cplus, Decl(objectSpread.ts, 56, 3)) ->plus : Symbol(plus, Decl(objectSpread.ts, 56, 23)) +>cplus.plus : Symbol(plus, Decl(objectSpread.ts, 74, 23)) +>cplus : Symbol(cplus, Decl(objectSpread.ts, 74, 3)) +>plus : Symbol(plus, Decl(objectSpread.ts, 74, 23)) // new field's type conflicting with existing field is OK let changeTypeAfter: { a: string, b: string } = ->changeTypeAfter : Symbol(changeTypeAfter, Decl(objectSpread.ts, 60, 3)) ->a : Symbol(a, Decl(objectSpread.ts, 60, 22)) ->b : Symbol(b, Decl(objectSpread.ts, 60, 33)) +>changeTypeAfter : Symbol(changeTypeAfter, Decl(objectSpread.ts, 78, 3)) +>a : Symbol(a, Decl(objectSpread.ts, 78, 22)) +>b : Symbol(b, Decl(objectSpread.ts, 78, 33)) { ...o, a: 'wrong type?' } >o : Symbol(o, Decl(objectSpread.ts, 0, 3)) ->a : Symbol(a, Decl(objectSpread.ts, 61, 11)) +>a : Symbol(a, Decl(objectSpread.ts, 79, 11)) let changeTypeBefore: { a: number, b: string } = ->changeTypeBefore : Symbol(changeTypeBefore, Decl(objectSpread.ts, 62, 3)) ->a : Symbol(a, Decl(objectSpread.ts, 62, 23)) ->b : Symbol(b, Decl(objectSpread.ts, 62, 34)) +>changeTypeBefore : Symbol(changeTypeBefore, Decl(objectSpread.ts, 80, 3)) +>a : Symbol(a, Decl(objectSpread.ts, 80, 23)) +>b : Symbol(b, Decl(objectSpread.ts, 80, 34)) { a: 'wrong type?', ...o }; ->a : Symbol(a, Decl(objectSpread.ts, 63, 5)) +>a : Symbol(a, Decl(objectSpread.ts, 81, 5)) >o : Symbol(o, Decl(objectSpread.ts, 0, 3)) let changeTypeBoth: { a: string, b: number } = ->changeTypeBoth : Symbol(changeTypeBoth, Decl(objectSpread.ts, 64, 3)) ->a : Symbol(a, Decl(objectSpread.ts, 64, 21)) ->b : Symbol(b, Decl(objectSpread.ts, 64, 32)) +>changeTypeBoth : Symbol(changeTypeBoth, Decl(objectSpread.ts, 82, 3)) +>a : Symbol(a, Decl(objectSpread.ts, 82, 21)) +>b : Symbol(b, Decl(objectSpread.ts, 82, 32)) { ...o, ...swap }; >o : Symbol(o, Decl(objectSpread.ts, 0, 3)) @@ -252,90 +314,90 @@ let changeTypeBoth: { a: string, b: number } = // optional function container( ->container : Symbol(container, Decl(objectSpread.ts, 65, 22)) +>container : Symbol(container, Decl(objectSpread.ts, 83, 22)) definiteBoolean: { sn: boolean }, ->definiteBoolean : Symbol(definiteBoolean, Decl(objectSpread.ts, 68, 19)) ->sn : Symbol(sn, Decl(objectSpread.ts, 69, 22)) +>definiteBoolean : Symbol(definiteBoolean, Decl(objectSpread.ts, 86, 19)) +>sn : Symbol(sn, Decl(objectSpread.ts, 87, 22)) definiteString: { sn: string }, ->definiteString : Symbol(definiteString, Decl(objectSpread.ts, 69, 37)) ->sn : Symbol(sn, Decl(objectSpread.ts, 70, 21)) +>definiteString : Symbol(definiteString, Decl(objectSpread.ts, 87, 37)) +>sn : Symbol(sn, Decl(objectSpread.ts, 88, 21)) optionalString: { sn?: string }, ->optionalString : Symbol(optionalString, Decl(objectSpread.ts, 70, 35)) ->sn : Symbol(sn, Decl(objectSpread.ts, 71, 21)) +>optionalString : Symbol(optionalString, Decl(objectSpread.ts, 88, 35)) +>sn : Symbol(sn, Decl(objectSpread.ts, 89, 21)) optionalNumber: { sn?: number }) { ->optionalNumber : Symbol(optionalNumber, Decl(objectSpread.ts, 71, 36)) ->sn : Symbol(sn, Decl(objectSpread.ts, 72, 21)) +>optionalNumber : Symbol(optionalNumber, Decl(objectSpread.ts, 89, 36)) +>sn : Symbol(sn, Decl(objectSpread.ts, 90, 21)) let optionalUnionStops: { sn: string | number | boolean } = { ...definiteBoolean, ...definiteString, ...optionalNumber }; ->optionalUnionStops : Symbol(optionalUnionStops, Decl(objectSpread.ts, 73, 7)) ->sn : Symbol(sn, Decl(objectSpread.ts, 73, 29)) ->definiteBoolean : Symbol(definiteBoolean, Decl(objectSpread.ts, 68, 19)) ->definiteString : Symbol(definiteString, Decl(objectSpread.ts, 69, 37)) ->optionalNumber : Symbol(optionalNumber, Decl(objectSpread.ts, 71, 36)) +>optionalUnionStops : Symbol(optionalUnionStops, Decl(objectSpread.ts, 91, 7)) +>sn : Symbol(sn, Decl(objectSpread.ts, 91, 29)) +>definiteBoolean : Symbol(definiteBoolean, Decl(objectSpread.ts, 86, 19)) +>definiteString : Symbol(definiteString, Decl(objectSpread.ts, 87, 37)) +>optionalNumber : Symbol(optionalNumber, Decl(objectSpread.ts, 89, 36)) let optionalUnionDuplicates: { sn: string | number } = { ...definiteBoolean, ...definiteString, ...optionalString, ...optionalNumber }; ->optionalUnionDuplicates : Symbol(optionalUnionDuplicates, Decl(objectSpread.ts, 74, 7)) ->sn : Symbol(sn, Decl(objectSpread.ts, 74, 34)) ->definiteBoolean : Symbol(definiteBoolean, Decl(objectSpread.ts, 68, 19)) ->definiteString : Symbol(definiteString, Decl(objectSpread.ts, 69, 37)) ->optionalString : Symbol(optionalString, Decl(objectSpread.ts, 70, 35)) ->optionalNumber : Symbol(optionalNumber, Decl(objectSpread.ts, 71, 36)) +>optionalUnionDuplicates : Symbol(optionalUnionDuplicates, Decl(objectSpread.ts, 92, 7)) +>sn : Symbol(sn, Decl(objectSpread.ts, 92, 34)) +>definiteBoolean : Symbol(definiteBoolean, Decl(objectSpread.ts, 86, 19)) +>definiteString : Symbol(definiteString, Decl(objectSpread.ts, 87, 37)) +>optionalString : Symbol(optionalString, Decl(objectSpread.ts, 88, 35)) +>optionalNumber : Symbol(optionalNumber, Decl(objectSpread.ts, 89, 36)) let allOptional: { sn?: string | number } = { ...optionalString, ...optionalNumber }; ->allOptional : Symbol(allOptional, Decl(objectSpread.ts, 75, 7)) ->sn : Symbol(sn, Decl(objectSpread.ts, 75, 22)) ->optionalString : Symbol(optionalString, Decl(objectSpread.ts, 70, 35)) ->optionalNumber : Symbol(optionalNumber, Decl(objectSpread.ts, 71, 36)) +>allOptional : Symbol(allOptional, Decl(objectSpread.ts, 93, 7)) +>sn : Symbol(sn, Decl(objectSpread.ts, 93, 22)) +>optionalString : Symbol(optionalString, Decl(objectSpread.ts, 88, 35)) +>optionalNumber : Symbol(optionalNumber, Decl(objectSpread.ts, 89, 36)) // computed property let computedFirst: { a: number, b: string, "before everything": number } = ->computedFirst : Symbol(computedFirst, Decl(objectSpread.ts, 78, 7)) ->a : Symbol(a, Decl(objectSpread.ts, 78, 24)) ->b : Symbol(b, Decl(objectSpread.ts, 78, 35)) +>computedFirst : Symbol(computedFirst, Decl(objectSpread.ts, 96, 7)) +>a : Symbol(a, Decl(objectSpread.ts, 96, 24)) +>b : Symbol(b, Decl(objectSpread.ts, 96, 35)) { ['before everything']: 12, ...o, b: 'yes' } ->'before everything' : Symbol(['before everything'], Decl(objectSpread.ts, 79, 9)) +>'before everything' : Symbol(['before everything'], Decl(objectSpread.ts, 97, 9)) >o : Symbol(o, Decl(objectSpread.ts, 0, 3)) ->b : Symbol(b, Decl(objectSpread.ts, 79, 42)) +>b : Symbol(b, Decl(objectSpread.ts, 97, 42)) let computedMiddle: { a: number, b: string, c: boolean, "in the middle": number } = ->computedMiddle : Symbol(computedMiddle, Decl(objectSpread.ts, 80, 7)) ->a : Symbol(a, Decl(objectSpread.ts, 80, 25)) ->b : Symbol(b, Decl(objectSpread.ts, 80, 36)) ->c : Symbol(c, Decl(objectSpread.ts, 80, 47)) +>computedMiddle : Symbol(computedMiddle, Decl(objectSpread.ts, 98, 7)) +>a : Symbol(a, Decl(objectSpread.ts, 98, 25)) +>b : Symbol(b, Decl(objectSpread.ts, 98, 36)) +>c : Symbol(c, Decl(objectSpread.ts, 98, 47)) { ...o, ['in the middle']: 13, b: 'maybe?', ...o2 } >o : Symbol(o, Decl(objectSpread.ts, 0, 3)) ->'in the middle' : Symbol(['in the middle'], Decl(objectSpread.ts, 81, 15)) ->b : Symbol(b, Decl(objectSpread.ts, 81, 38)) +>'in the middle' : Symbol(['in the middle'], Decl(objectSpread.ts, 99, 15)) +>b : Symbol(b, Decl(objectSpread.ts, 99, 38)) >o2 : Symbol(o2, Decl(objectSpread.ts, 1, 3)) let computedAfter: { a: number, b: string, "at the end": number } = ->computedAfter : Symbol(computedAfter, Decl(objectSpread.ts, 82, 7)) ->a : Symbol(a, Decl(objectSpread.ts, 82, 24)) ->b : Symbol(b, Decl(objectSpread.ts, 82, 35)) +>computedAfter : Symbol(computedAfter, Decl(objectSpread.ts, 100, 7)) +>a : Symbol(a, Decl(objectSpread.ts, 100, 24)) +>b : Symbol(b, Decl(objectSpread.ts, 100, 35)) { ...o, b: 'yeah', ['at the end']: 14 } >o : Symbol(o, Decl(objectSpread.ts, 0, 3)) ->b : Symbol(b, Decl(objectSpread.ts, 83, 15)) ->'at the end' : Symbol(['at the end'], Decl(objectSpread.ts, 83, 26)) +>b : Symbol(b, Decl(objectSpread.ts, 101, 15)) +>'at the end' : Symbol(['at the end'], Decl(objectSpread.ts, 101, 26)) } // shortcut syntax let a = 12; ->a : Symbol(a, Decl(objectSpread.ts, 86, 3)) +>a : Symbol(a, Decl(objectSpread.ts, 104, 3)) let shortCutted: { a: number, b: string } = { ...o, a } ->shortCutted : Symbol(shortCutted, Decl(objectSpread.ts, 87, 3)) ->a : Symbol(a, Decl(objectSpread.ts, 87, 18)) ->b : Symbol(b, Decl(objectSpread.ts, 87, 29)) +>shortCutted : Symbol(shortCutted, Decl(objectSpread.ts, 105, 3)) +>a : Symbol(a, Decl(objectSpread.ts, 105, 18)) +>b : Symbol(b, Decl(objectSpread.ts, 105, 29)) >o : Symbol(o, Decl(objectSpread.ts, 0, 3)) ->a : Symbol(a, Decl(objectSpread.ts, 87, 51)) +>a : Symbol(a, Decl(objectSpread.ts, 105, 51)) // non primitive let spreadNonPrimitive = { ...{}}; ->spreadNonPrimitive : Symbol(spreadNonPrimitive, Decl(objectSpread.ts, 89, 3)) +>spreadNonPrimitive : Symbol(spreadNonPrimitive, Decl(objectSpread.ts, 107, 3)) diff --git a/tests/baselines/reference/objectSpread.types b/tests/baselines/reference/objectSpread.types index d696ed9ac7c..10d8af02440 100644 --- a/tests/baselines/reference/objectSpread.types +++ b/tests/baselines/reference/objectSpread.types @@ -231,8 +231,8 @@ let spreadFunc = { ...(function () { }) }; >function () { } : () => void // boolean && T results in Partial -function conditionalSpread(b: boolean) : { x?: number | undefined, y?: number | undefined } { ->conditionalSpread : (b: boolean) => { x?: number | undefined; y?: number | undefined; } +function conditionalSpreadBoolean(b: boolean) : { x?: number | undefined, y?: number | undefined } { +>conditionalSpreadBoolean : (b: boolean) => { x?: number | undefined; y?: number | undefined; } >b : boolean >x : number | undefined >y : number | undefined @@ -247,6 +247,88 @@ function conditionalSpread(b: boolean) : { x?: number | undefined, y?: number | >y : number >2 : 2 } +function conditionalSpreadNumber(nt: number): { x?: number | undefined, y: number } { +>conditionalSpreadNumber : (nt: number) => { x?: number | undefined; y: number; } +>nt : number +>x : number | undefined +>y : number + + let o = { x: 12, y: 13 } +>o : { x: number; y: number; } +>{ x: 12, y: 13 } : { x: number; y: number; } +>x : number +>12 : 12 +>y : number +>13 : 13 + + o = { +>o = { ...o, ...nt && { x: nt } } : { x: number; y: number; } +>o : { x: number; y: number; } +>{ ...o, ...nt && { x: nt } } : { x: number; y: number; } + + ...o, +>o : { x: number; y: number; } + + ...nt && { x: nt } +>nt && { x: nt } : 0 | { x: number; } +>nt : number +>{ x: nt } : { x: number; } +>x : number +>nt : number + } + let o2 = { ...nt && { x: nt }} +>o2 : { x?: number | undefined; } +>{ ...nt && { x: nt }} : { x?: number | undefined; } +>nt && { x: nt } : 0 | { x: number; } +>nt : number +>{ x: nt } : { x: number; } +>x : number +>nt : number + + return o; +>o : { x: number; y: number; } +} +function conditionalSpreadString(st: string): { x?: string | undefined, y: number } { +>conditionalSpreadString : (st: string) => { x?: string | undefined; y: number; } +>st : string +>x : string | undefined +>y : number + + let o = { x: 'hi', y: 13 } +>o : { x: string; y: number; } +>{ x: 'hi', y: 13 } : { x: string; y: number; } +>x : string +>'hi' : "hi" +>y : number +>13 : 13 + + o = { +>o = { ...o, ...st && { x: st } } : { x: string; y: number; } +>o : { x: string; y: number; } +>{ ...o, ...st && { x: st } } : { x: string; y: number; } + + ...o, +>o : { x: string; y: number; } + + ...st && { x: st } +>st && { x: st } : "" | { x: string; } +>st : string +>{ x: st } : { x: string; } +>x : string +>st : string + } + let o2 = { ...st && { x: st }} +>o2 : { x?: string | undefined; } +>{ ...st && { x: st }} : { x?: string | undefined; } +>st && { x: st } : "" | { x: string; } +>st : string +>{ x: st } : { x: string; } +>x : string +>st : string + + return o; +>o : { x: string; y: number; } +} // other booleans result in { } let spreadBool = { ... true } >spreadBool : {} diff --git a/tests/baselines/reference/objectSpreadNegative.errors.txt b/tests/baselines/reference/objectSpreadNegative.errors.txt index 14eba9d6f2a..305c149841b 100644 --- a/tests/baselines/reference/objectSpreadNegative.errors.txt +++ b/tests/baselines/reference/objectSpreadNegative.errors.txt @@ -7,9 +7,8 @@ tests/cases/conformance/types/spread/objectSpreadNegative.ts(25,1): error TS2322 Property 's' is missing in type '{ b: boolean; }'. tests/cases/conformance/types/spread/objectSpreadNegative.ts(28,36): error TS2300: Duplicate identifier 'b'. tests/cases/conformance/types/spread/objectSpreadNegative.ts(28,53): error TS2300: Duplicate identifier 'b'. -tests/cases/conformance/types/spread/objectSpreadNegative.ts(32,19): error TS2698: Spread types may only be created from object types. -tests/cases/conformance/types/spread/objectSpreadNegative.ts(33,19): error TS2698: Spread types may only be created from object types. -tests/cases/conformance/types/spread/objectSpreadNegative.ts(34,19): error TS2698: Spread types may only be created from object types. +tests/cases/conformance/types/spread/objectSpreadNegative.ts(35,11): error TS2339: Property 'length' does not exist on type '{}'. +tests/cases/conformance/types/spread/objectSpreadNegative.ts(36,11): error TS2339: Property 'charAt' does not exist on type '{}'. tests/cases/conformance/types/spread/objectSpreadNegative.ts(39,1): error TS2349: Cannot invoke an expression whose type lacks a call signature. Type '{}' has no compatible call signatures. tests/cases/conformance/types/spread/objectSpreadNegative.ts(43,12): error TS2339: Property 'b' does not exist on type '{}'. tests/cases/conformance/types/spread/objectSpreadNegative.ts(49,9): error TS2339: Property 'm' does not exist on type '{ p: number; }'. @@ -24,7 +23,7 @@ tests/cases/conformance/types/spread/objectSpreadNegative.ts(80,7): error TS2322 Object literal may only specify known properties, and 'extra' does not exist in type 'A'. -==== tests/cases/conformance/types/spread/objectSpreadNegative.ts (18 errors) ==== +==== tests/cases/conformance/types/spread/objectSpreadNegative.ts (17 errors) ==== let o = { a: 1, b: 'no' } /// private propagates @@ -72,16 +71,14 @@ tests/cases/conformance/types/spread/objectSpreadNegative.ts(80,7): error TS2322 // primitives are not allowed let spreadNum = { ...12 }; - ~~~~~ -!!! error TS2698: Spread types may only be created from object types. let spreadSum = { ...1 + 1 }; - ~~~~~~~~ -!!! error TS2698: Spread types may only be created from object types. let spreadStr = { ...'foo' }; - ~~~~~~~~ -!!! error TS2698: Spread types may only be created from object types. spreadStr.length; // error, no 'length' + ~~~~~~ +!!! error TS2339: Property 'length' does not exist on type '{}'. spreadStr.charAt(1); // error, no methods either + ~~~~~~ +!!! error TS2339: Property 'charAt' does not exist on type '{}'. // functions are skipped let spreadFunc = { ...function () { } } spreadFunc(); // error, no call signature diff --git a/tests/baselines/reference/objectSpreadNegativeParse.errors.txt b/tests/baselines/reference/objectSpreadNegativeParse.errors.txt index b37200c4f02..41651fb1d1c 100644 --- a/tests/baselines/reference/objectSpreadNegativeParse.errors.txt +++ b/tests/baselines/reference/objectSpreadNegativeParse.errors.txt @@ -1,6 +1,5 @@ tests/cases/conformance/types/spread/objectSpreadNegativeParse.ts(1,15): error TS2304: Cannot find name 'o'. tests/cases/conformance/types/spread/objectSpreadNegativeParse.ts(1,18): error TS1109: Expression expected. -tests/cases/conformance/types/spread/objectSpreadNegativeParse.ts(2,12): error TS2698: Spread types may only be created from object types. tests/cases/conformance/types/spread/objectSpreadNegativeParse.ts(2,15): error TS1109: Expression expected. tests/cases/conformance/types/spread/objectSpreadNegativeParse.ts(2,16): error TS2304: Cannot find name 'o'. tests/cases/conformance/types/spread/objectSpreadNegativeParse.ts(3,15): error TS2304: Cannot find name 'matchMedia'. @@ -10,15 +9,13 @@ tests/cases/conformance/types/spread/objectSpreadNegativeParse.ts(4,16): error T tests/cases/conformance/types/spread/objectSpreadNegativeParse.ts(4,20): error TS1005: ',' expected. -==== tests/cases/conformance/types/spread/objectSpreadNegativeParse.ts (10 errors) ==== +==== tests/cases/conformance/types/spread/objectSpreadNegativeParse.ts (9 errors) ==== let o7 = { ...o? }; ~ !!! error TS2304: Cannot find name 'o'. ~ !!! error TS1109: Expression expected. let o8 = { ...*o }; - ~~~~~ -!!! error TS2698: Spread types may only be created from object types. ~ !!! error TS1109: Expression expected. ~ diff --git a/tests/cases/conformance/types/spread/objectSpread.ts b/tests/cases/conformance/types/spread/objectSpread.ts index 378c5558fc5..566c9eb0384 100644 --- a/tests/cases/conformance/types/spread/objectSpread.ts +++ b/tests/cases/conformance/types/spread/objectSpread.ts @@ -40,9 +40,27 @@ getter.a = 12; let spreadFunc = { ...(function () { }) }; // boolean && T results in Partial -function conditionalSpread(b: boolean) : { x?: number | undefined, y?: number | undefined } { +function conditionalSpreadBoolean(b: boolean) : { x?: number | undefined, y?: number | undefined } { return { ...b && { x: 1, y: 2 } }; } +function conditionalSpreadNumber(nt: number): { x?: number | undefined, y: number } { + let o = { x: 12, y: 13 } + o = { + ...o, + ...nt && { x: nt } + } + let o2 = { ...nt && { x: nt }} + return o; +} +function conditionalSpreadString(st: string): { x?: string | undefined, y: number } { + let o = { x: 'hi', y: 13 } + o = { + ...o, + ...st && { x: st } + } + let o2 = { ...st && { x: st }} + return o; +} // other booleans result in { } let spreadBool = { ... true } From fbdb14833ad2865bec8a8df173bafbcef04f2910 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Wed, 13 Sep 2017 14:58:35 -0700 Subject: [PATCH 326/370] Improve naming of getPartialTypeFromFalsyUnion --- 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 ff796879071..e4696363ebb 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -7833,7 +7833,7 @@ namespace ts { } if (left.flags & TypeFlags.Union) { // if the union is `false | T` make all the properties of T optional - const wl = getPartialTypeFromFalseUnion(left as UnionType); + const wl = getPartialTypeFromFalsyUnion(left as UnionType); if (wl) { left = wl; } @@ -7842,7 +7842,7 @@ namespace ts { } } if (right.flags & TypeFlags.Union) { - const wr = getPartialTypeFromFalseUnion(right as UnionType); + const wr = getPartialTypeFromFalsyUnion(right as UnionType); if (wr) { right = wr; } @@ -7921,7 +7921,7 @@ namespace ts { return prop.flags & SymbolFlags.Method && find(prop.declarations, decl => isClassLike(decl.parent)); } - function getPartialTypeFromFalseUnion(type: UnionType): Type | undefined { + function getPartialTypeFromFalsyUnion(type: UnionType): Type | undefined { if (type.types.length === 2) { // getFalsyFlagsOfTypes // getTypeFacts From d2e2faad5c9e48af39d2775063e1d599c8083113 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Wed, 13 Sep 2017 15:13:34 -0700 Subject: [PATCH 327/370] Update tests and baselines --- .../reference/objectSpreadNegative.errors.txt | 26 ++++---- .../reference/objectSpreadNegative.js | 8 +-- .../restInvalidArgumentType.errors.txt | 63 +++---------------- .../reference/restInvalidArgumentType.js | 46 +------------- .../spreadInvalidArgumentType.errors.txt | 62 +++--------------- .../reference/spreadInvalidArgumentType.js | 45 +------------ .../cases/compiler/restInvalidArgumentType.ts | 25 +------- .../compiler/spreadInvalidArgumentType.ts | 24 +------ .../types/spread/objectSpreadNegative.ts | 4 +- 9 files changed, 41 insertions(+), 262 deletions(-) diff --git a/tests/baselines/reference/objectSpreadNegative.errors.txt b/tests/baselines/reference/objectSpreadNegative.errors.txt index 305c149841b..39639af545e 100644 --- a/tests/baselines/reference/objectSpreadNegative.errors.txt +++ b/tests/baselines/reference/objectSpreadNegative.errors.txt @@ -7,20 +7,20 @@ tests/cases/conformance/types/spread/objectSpreadNegative.ts(25,1): error TS2322 Property 's' is missing in type '{ b: boolean; }'. tests/cases/conformance/types/spread/objectSpreadNegative.ts(28,36): error TS2300: Duplicate identifier 'b'. tests/cases/conformance/types/spread/objectSpreadNegative.ts(28,53): error TS2300: Duplicate identifier 'b'. -tests/cases/conformance/types/spread/objectSpreadNegative.ts(35,11): error TS2339: Property 'length' does not exist on type '{}'. -tests/cases/conformance/types/spread/objectSpreadNegative.ts(36,11): error TS2339: Property 'charAt' does not exist on type '{}'. -tests/cases/conformance/types/spread/objectSpreadNegative.ts(39,1): error TS2349: Cannot invoke an expression whose type lacks a call signature. Type '{}' has no compatible call signatures. -tests/cases/conformance/types/spread/objectSpreadNegative.ts(43,12): error TS2339: Property 'b' does not exist on type '{}'. -tests/cases/conformance/types/spread/objectSpreadNegative.ts(49,9): error TS2339: Property 'm' does not exist on type '{ p: number; }'. -tests/cases/conformance/types/spread/objectSpreadNegative.ts(54,11): error TS2339: Property 'a' does not exist on type '{}'. -tests/cases/conformance/types/spread/objectSpreadNegative.ts(58,14): error TS2698: Spread types may only be created from object types. -tests/cases/conformance/types/spread/objectSpreadNegative.ts(61,14): error TS2698: Spread types may only be created from object types. -tests/cases/conformance/types/spread/objectSpreadNegative.ts(75,37): error TS2322: Type '{ a: string; b: string; extra: string; }' is not assignable to type 'A'. +tests/cases/conformance/types/spread/objectSpreadNegative.ts(33,11): error TS2339: Property 'length' does not exist on type '{}'. +tests/cases/conformance/types/spread/objectSpreadNegative.ts(34,11): error TS2339: Property 'charAt' does not exist on type '{}'. +tests/cases/conformance/types/spread/objectSpreadNegative.ts(37,1): error TS2349: Cannot invoke an expression whose type lacks a call signature. Type '{}' has no compatible call signatures. +tests/cases/conformance/types/spread/objectSpreadNegative.ts(41,12): error TS2339: Property 'b' does not exist on type '{}'. +tests/cases/conformance/types/spread/objectSpreadNegative.ts(47,9): error TS2339: Property 'm' does not exist on type '{ p: number; }'. +tests/cases/conformance/types/spread/objectSpreadNegative.ts(52,11): error TS2339: Property 'a' does not exist on type '{}'. +tests/cases/conformance/types/spread/objectSpreadNegative.ts(56,14): error TS2698: Spread types may only be created from object types. +tests/cases/conformance/types/spread/objectSpreadNegative.ts(59,14): error TS2698: Spread types may only be created from object types. +tests/cases/conformance/types/spread/objectSpreadNegative.ts(73,37): error TS2322: Type '{ a: string; b: string; extra: string; }' is not assignable to type 'A'. + Object literal may only specify known properties, and 'extra' does not exist in type 'A'. +tests/cases/conformance/types/spread/objectSpreadNegative.ts(76,7): error TS2322: Type '{ a: string; b: string; extra: string; }' is not assignable to type 'A'. Object literal may only specify known properties, and 'extra' does not exist in type 'A'. tests/cases/conformance/types/spread/objectSpreadNegative.ts(78,7): error TS2322: Type '{ a: string; b: string; extra: string; }' is not assignable to type 'A'. Object literal may only specify known properties, and 'extra' does not exist in type 'A'. -tests/cases/conformance/types/spread/objectSpreadNegative.ts(80,7): error TS2322: Type '{ a: string; b: string; extra: string; }' is not assignable to type 'A'. - Object literal may only specify known properties, and 'extra' does not exist in type 'A'. ==== tests/cases/conformance/types/spread/objectSpreadNegative.ts (17 errors) ==== @@ -69,9 +69,7 @@ tests/cases/conformance/types/spread/objectSpreadNegative.ts(80,7): error TS2322 !!! error TS2300: Duplicate identifier 'b'. let duplicatedSpread = { ...o, ...o } - // primitives are not allowed - let spreadNum = { ...12 }; - let spreadSum = { ...1 + 1 }; + // primitives are skipped let spreadStr = { ...'foo' }; spreadStr.length; // error, no 'length' ~~~~~~ diff --git a/tests/baselines/reference/objectSpreadNegative.js b/tests/baselines/reference/objectSpreadNegative.js index 6e82a19acbc..41502dc028d 100644 --- a/tests/baselines/reference/objectSpreadNegative.js +++ b/tests/baselines/reference/objectSpreadNegative.js @@ -29,9 +29,7 @@ spread = b; // error, missing 's' let duplicated = { b: 'bad', ...o, b: 'bad', ...o2, b: 'bad' } let duplicatedSpread = { ...o, ...o } -// primitives are not allowed -let spreadNum = { ...12 }; -let spreadSum = { ...1 + 1 }; +// primitives are skipped let spreadStr = { ...'foo' }; spreadStr.length; // error, no 'length' spreadStr.charAt(1); // error, no methods either @@ -118,9 +116,7 @@ spread = b; // error, missing 's' // literal repeats are not allowed, but spread repeats are fine var duplicated = __assign({ b: 'bad' }, o, { b: 'bad' }, o2, { b: 'bad' }); var duplicatedSpread = __assign({}, o, o); -// primitives are not allowed -var spreadNum = __assign({}, 12); -var spreadSum = __assign({}, 1 + 1); +// primitives are skipped var spreadStr = __assign({}, 'foo'); spreadStr.length; // error, no 'length' spreadStr.charAt(1); // error, no methods either diff --git a/tests/baselines/reference/restInvalidArgumentType.errors.txt b/tests/baselines/reference/restInvalidArgumentType.errors.txt index fff2c7b3563..44577d5a24e 100644 --- a/tests/baselines/reference/restInvalidArgumentType.errors.txt +++ b/tests/baselines/reference/restInvalidArgumentType.errors.txt @@ -1,22 +1,13 @@ -tests/cases/compiler/restInvalidArgumentType.ts(31,13): error TS2700: Rest types may only be created from object types. -tests/cases/compiler/restInvalidArgumentType.ts(33,13): error TS2700: Rest types may only be created from object types. -tests/cases/compiler/restInvalidArgumentType.ts(35,13): error TS2700: Rest types may only be created from object types. -tests/cases/compiler/restInvalidArgumentType.ts(36,13): error TS2700: Rest types may only be created from object types. -tests/cases/compiler/restInvalidArgumentType.ts(38,13): error TS2700: Rest types may only be created from object types. -tests/cases/compiler/restInvalidArgumentType.ts(41,13): error TS2700: Rest types may only be created from object types. -tests/cases/compiler/restInvalidArgumentType.ts(42,13): error TS2700: Rest types may only be created from object types. -tests/cases/compiler/restInvalidArgumentType.ts(44,13): error TS2700: Rest types may only be created from object types. -tests/cases/compiler/restInvalidArgumentType.ts(45,13): error TS2700: Rest types may only be created from object types. -tests/cases/compiler/restInvalidArgumentType.ts(47,13): error TS2700: Rest types may only be created from object types. -tests/cases/compiler/restInvalidArgumentType.ts(48,13): error TS2700: Rest types may only be created from object types. -tests/cases/compiler/restInvalidArgumentType.ts(55,13): error TS2700: Rest types may only be created from object types. -tests/cases/compiler/restInvalidArgumentType.ts(56,13): error TS2700: Rest types may only be created from object types. -tests/cases/compiler/restInvalidArgumentType.ts(58,13): error TS2700: Rest types may only be created from object types. +tests/cases/compiler/restInvalidArgumentType.ts(18,13): error TS2700: Rest types may only be created from object types. +tests/cases/compiler/restInvalidArgumentType.ts(20,13): error TS2700: Rest types may only be created from object types. +tests/cases/compiler/restInvalidArgumentType.ts(22,13): error TS2700: Rest types may only be created from object types. +tests/cases/compiler/restInvalidArgumentType.ts(23,13): error TS2700: Rest types may only be created from object types. +tests/cases/compiler/restInvalidArgumentType.ts(25,13): error TS2700: Rest types may only be created from object types. +tests/cases/compiler/restInvalidArgumentType.ts(28,13): error TS2700: Rest types may only be created from object types. +tests/cases/compiler/restInvalidArgumentType.ts(30,13): error TS2700: Rest types may only be created from object types. -==== tests/cases/compiler/restInvalidArgumentType.ts (14 errors) ==== - enum E { v1, v2 }; - +==== tests/cases/compiler/restInvalidArgumentType.ts (7 errors) ==== function f(p1: T, p2: T[]) { var t: T; @@ -27,24 +18,13 @@ tests/cases/compiler/restInvalidArgumentType.ts(58,13): error TS2700: Rest types var mapped: {[P in "b"]: T[P]}; var union_generic: T | { a: number }; - var union_primitive: { a: number } | number; - var intersection_generic: T & { a: number }; - var intersection_premitive: { a: number } | string; - - var num: number; - var str: number; var u: undefined; var n: null; var a: any; - var literal_string: "string"; - var literal_number: 42; - - var e: E; - var {...r1} = p1; // Error, generic type paramterre ~~ !!! error TS2700: Rest types may only be created from object types. @@ -68,37 +48,14 @@ tests/cases/compiler/restInvalidArgumentType.ts(58,13): error TS2700: Rest types var {...r8} = union_generic; // Error, union with generic type parameter ~~ !!! error TS2700: Rest types may only be created from object types. - var {...r9} = union_primitive; // Error, union with generic type parameter - ~~ -!!! error TS2700: Rest types may only be created from object types. var {...r10} = intersection_generic; // Error, intersection with generic type parameter ~~~ !!! error TS2700: Rest types may only be created from object types. - var {...r11} = intersection_premitive; // Error, intersection with generic type parameter - ~~~ -!!! error TS2700: Rest types may only be created from object types. - - var {...r12} = num; // Error - ~~~ -!!! error TS2700: Rest types may only be created from object types. - var {...r13} = str; // Error - ~~~ -!!! error TS2700: Rest types may only be created from object types. var {...r14} = u; // OK var {...r15} = n; // OK var {...r16} = a; // OK - - var {...r17} = literal_string; // Error - ~~~ -!!! error TS2700: Rest types may only be created from object types. - var {...r18} = literal_number; // Error - ~~~ -!!! error TS2700: Rest types may only be created from object types. - - var {...r19} = e; // Error, enum - ~~~ -!!! error TS2700: Rest types may only be created from object types. - } \ No newline at end of file + } + \ No newline at end of file diff --git a/tests/baselines/reference/restInvalidArgumentType.js b/tests/baselines/reference/restInvalidArgumentType.js index 48e4e11e805..81bcfb63a17 100644 --- a/tests/baselines/reference/restInvalidArgumentType.js +++ b/tests/baselines/reference/restInvalidArgumentType.js @@ -1,6 +1,4 @@ //// [restInvalidArgumentType.ts] -enum E { v1, v2 }; - function f(p1: T, p2: T[]) { var t: T; @@ -11,24 +9,13 @@ function f(p1: T, p2: T[]) { var mapped: {[P in "b"]: T[P]}; var union_generic: T | { a: number }; - var union_primitive: { a: number } | number; - var intersection_generic: T & { a: number }; - var intersection_premitive: { a: number } | string; - - var num: number; - var str: number; var u: undefined; var n: null; var a: any; - var literal_string: "string"; - var literal_number: 42; - - var e: E; - var {...r1} = p1; // Error, generic type paramterre var {...r2} = p2; // OK var {...r3} = t; // Error, generic type paramter @@ -40,24 +27,15 @@ function f(p1: T, p2: T[]) { var {...r7} = mapped; // OK, non-generic mapped type var {...r8} = union_generic; // Error, union with generic type parameter - var {...r9} = union_primitive; // Error, union with generic type parameter var {...r10} = intersection_generic; // Error, intersection with generic type parameter - var {...r11} = intersection_premitive; // Error, intersection with generic type parameter - - var {...r12} = num; // Error - var {...r13} = str; // Error var {...r14} = u; // OK var {...r15} = n; // OK var {...r16} = a; // OK - - var {...r17} = literal_string; // Error - var {...r18} = literal_number; // Error - - var {...r19} = e; // Error, enum -} +} + //// [restInvalidArgumentType.js] var __rest = (this && this.__rest) || function (s, e) { @@ -69,12 +47,6 @@ var __rest = (this && this.__rest) || function (s, e) { t[p[i]] = s[p[i]]; return t; }; -var E; -(function (E) { - E[E["v1"] = 0] = "v1"; - E[E["v2"] = 1] = "v2"; -})(E || (E = {})); -; function f(p1, p2) { var t; var i; @@ -82,17 +54,10 @@ function f(p1, p2) { var mapped_generic; var mapped; var union_generic; - var union_primitive; var intersection_generic; - var intersection_premitive; - var num; - var str; var u; var n; var a; - var literal_string; - var literal_number; - var e; var r1 = __rest(p1, []); // Error, generic type paramterre var r2 = __rest(p2, []); // OK var r3 = __rest(t, []); // Error, generic type paramter @@ -101,15 +66,8 @@ function f(p1, p2) { var r6 = __rest(mapped_generic, []); // Error, generic mapped object type var r7 = __rest(mapped, []); // OK, non-generic mapped type var r8 = __rest(union_generic, []); // Error, union with generic type parameter - var r9 = __rest(union_primitive, []); // Error, union with generic type parameter var r10 = __rest(intersection_generic, []); // Error, intersection with generic type parameter - var r11 = __rest(intersection_premitive, []); // Error, intersection with generic type parameter - var r12 = __rest(num, []); // Error - var r13 = __rest(str, []); // Error var r14 = __rest(u, []); // OK var r15 = __rest(n, []); // OK var r16 = __rest(a, []); // OK - var r17 = __rest(literal_string, []); // Error - var r18 = __rest(literal_number, []); // Error - var r19 = __rest(e, []); // Error, enum } diff --git a/tests/baselines/reference/spreadInvalidArgumentType.errors.txt b/tests/baselines/reference/spreadInvalidArgumentType.errors.txt index 5088390f9ee..5b48e24ad0d 100644 --- a/tests/baselines/reference/spreadInvalidArgumentType.errors.txt +++ b/tests/baselines/reference/spreadInvalidArgumentType.errors.txt @@ -1,22 +1,13 @@ -tests/cases/compiler/spreadInvalidArgumentType.ts(31,16): error TS2698: Spread types may only be created from object types. -tests/cases/compiler/spreadInvalidArgumentType.ts(33,16): error TS2698: Spread types may only be created from object types. -tests/cases/compiler/spreadInvalidArgumentType.ts(35,16): error TS2698: Spread types may only be created from object types. -tests/cases/compiler/spreadInvalidArgumentType.ts(36,16): error TS2698: Spread types may only be created from object types. -tests/cases/compiler/spreadInvalidArgumentType.ts(38,16): error TS2698: Spread types may only be created from object types. -tests/cases/compiler/spreadInvalidArgumentType.ts(41,16): error TS2698: Spread types may only be created from object types. -tests/cases/compiler/spreadInvalidArgumentType.ts(42,16): error TS2698: Spread types may only be created from object types. -tests/cases/compiler/spreadInvalidArgumentType.ts(44,17): error TS2698: Spread types may only be created from object types. -tests/cases/compiler/spreadInvalidArgumentType.ts(45,17): error TS2698: Spread types may only be created from object types. -tests/cases/compiler/spreadInvalidArgumentType.ts(47,17): error TS2698: Spread types may only be created from object types. -tests/cases/compiler/spreadInvalidArgumentType.ts(48,17): error TS2698: Spread types may only be created from object types. -tests/cases/compiler/spreadInvalidArgumentType.ts(55,17): error TS2698: Spread types may only be created from object types. -tests/cases/compiler/spreadInvalidArgumentType.ts(56,17): error TS2698: Spread types may only be created from object types. -tests/cases/compiler/spreadInvalidArgumentType.ts(58,17): error TS2698: Spread types may only be created from object types. +tests/cases/compiler/spreadInvalidArgumentType.ts(19,16): error TS2698: Spread types may only be created from object types. +tests/cases/compiler/spreadInvalidArgumentType.ts(21,16): error TS2698: Spread types may only be created from object types. +tests/cases/compiler/spreadInvalidArgumentType.ts(23,16): error TS2698: Spread types may only be created from object types. +tests/cases/compiler/spreadInvalidArgumentType.ts(24,16): error TS2698: Spread types may only be created from object types. +tests/cases/compiler/spreadInvalidArgumentType.ts(26,16): error TS2698: Spread types may only be created from object types. +tests/cases/compiler/spreadInvalidArgumentType.ts(29,16): error TS2698: Spread types may only be created from object types. +tests/cases/compiler/spreadInvalidArgumentType.ts(31,17): error TS2698: Spread types may only be created from object types. -==== tests/cases/compiler/spreadInvalidArgumentType.ts (14 errors) ==== - enum E { v1, v2 }; - +==== tests/cases/compiler/spreadInvalidArgumentType.ts (7 errors) ==== function f(p1: T, p2: T[]) { var t: T; @@ -27,24 +18,14 @@ tests/cases/compiler/spreadInvalidArgumentType.ts(58,17): error TS2698: Spread t var mapped: {[P in "b"]: T[P]}; var union_generic: T | { a: number }; - var union_primitive: { a: number } | number; var intersection_generic: T & { a: number }; - var intersection_premitive: { a: number } | string; - - var num: number; - var str: number; var u: undefined; var n: null; var a: any; - var literal_string: "string"; - var literal_number: 42; - - var e: E; - var o1 = { ...p1 }; // Error, generic type paramterre ~~~~~ !!! error TS2698: Spread types may only be created from object types. @@ -68,37 +49,14 @@ tests/cases/compiler/spreadInvalidArgumentType.ts(58,17): error TS2698: Spread t var o8 = { ...union_generic }; // Error, union with generic type parameter ~~~~~~~~~~~~~~~~ !!! error TS2698: Spread types may only be created from object types. - var o9 = { ...union_primitive }; // Error, union with generic type parameter - ~~~~~~~~~~~~~~~~~~ -!!! error TS2698: Spread types may only be created from object types. var o10 = { ...intersection_generic }; // Error, intersection with generic type parameter ~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS2698: Spread types may only be created from object types. - var o11 = { ...intersection_premitive }; // Error, intersection with generic type parameter - ~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2698: Spread types may only be created from object types. - - var o12 = { ...num }; // Error - ~~~~~~ -!!! error TS2698: Spread types may only be created from object types. - var o13 = { ...str }; // Error - ~~~~~~ -!!! error TS2698: Spread types may only be created from object types. var o14 = { ...u }; // OK var o15 = { ...n }; // OK var o16 = { ...a }; // OK - - var o17 = { ...literal_string }; // Error - ~~~~~~~~~~~~~~~~~ -!!! error TS2698: Spread types may only be created from object types. - var o18 = { ...literal_number }; // Error - ~~~~~~~~~~~~~~~~~ -!!! error TS2698: Spread types may only be created from object types. - - var o19 = { ...e }; // Error, enum - ~~~~ -!!! error TS2698: Spread types may only be created from object types. - } \ No newline at end of file + } + \ No newline at end of file diff --git a/tests/baselines/reference/spreadInvalidArgumentType.js b/tests/baselines/reference/spreadInvalidArgumentType.js index 26f958f224d..aa42419e59a 100644 --- a/tests/baselines/reference/spreadInvalidArgumentType.js +++ b/tests/baselines/reference/spreadInvalidArgumentType.js @@ -1,6 +1,4 @@ //// [spreadInvalidArgumentType.ts] -enum E { v1, v2 }; - function f(p1: T, p2: T[]) { var t: T; @@ -11,24 +9,14 @@ function f(p1: T, p2: T[]) { var mapped: {[P in "b"]: T[P]}; var union_generic: T | { a: number }; - var union_primitive: { a: number } | number; var intersection_generic: T & { a: number }; - var intersection_premitive: { a: number } | string; - - var num: number; - var str: number; var u: undefined; var n: null; var a: any; - var literal_string: "string"; - var literal_number: 42; - - var e: E; - var o1 = { ...p1 }; // Error, generic type paramterre var o2 = { ...p2 }; // OK var o3 = { ...t }; // Error, generic type paramter @@ -40,24 +28,15 @@ function f(p1: T, p2: T[]) { var o7 = { ...mapped }; // OK, non-generic mapped type var o8 = { ...union_generic }; // Error, union with generic type parameter - var o9 = { ...union_primitive }; // Error, union with generic type parameter var o10 = { ...intersection_generic }; // Error, intersection with generic type parameter - var o11 = { ...intersection_premitive }; // Error, intersection with generic type parameter - - var o12 = { ...num }; // Error - var o13 = { ...str }; // Error var o14 = { ...u }; // OK var o15 = { ...n }; // OK var o16 = { ...a }; // OK - - var o17 = { ...literal_string }; // Error - var o18 = { ...literal_number }; // Error - - var o19 = { ...e }; // Error, enum -} +} + //// [spreadInvalidArgumentType.js] var __assign = (this && this.__assign) || Object.assign || function(t) { @@ -68,12 +47,6 @@ var __assign = (this && this.__assign) || Object.assign || function(t) { } return t; }; -var E; -(function (E) { - E[E["v1"] = 0] = "v1"; - E[E["v2"] = 1] = "v2"; -})(E || (E = {})); -; function f(p1, p2) { var t; var i; @@ -81,17 +54,10 @@ function f(p1, p2) { var mapped_generic; var mapped; var union_generic; - var union_primitive; var intersection_generic; - var intersection_premitive; - var num; - var str; var u; var n; var a; - var literal_string; - var literal_number; - var e; var o1 = __assign({}, p1); // Error, generic type paramterre var o2 = __assign({}, p2); // OK var o3 = __assign({}, t); // Error, generic type paramter @@ -100,15 +66,8 @@ function f(p1, p2) { var o6 = __assign({}, mapped_generic); // Error, generic mapped object type var o7 = __assign({}, mapped); // OK, non-generic mapped type var o8 = __assign({}, union_generic); // Error, union with generic type parameter - var o9 = __assign({}, union_primitive); // Error, union with generic type parameter var o10 = __assign({}, intersection_generic); // Error, intersection with generic type parameter - var o11 = __assign({}, intersection_premitive); // Error, intersection with generic type parameter - var o12 = __assign({}, num); // Error - var o13 = __assign({}, str); // Error var o14 = __assign({}, u); // OK var o15 = __assign({}, n); // OK var o16 = __assign({}, a); // OK - var o17 = __assign({}, literal_string); // Error - var o18 = __assign({}, literal_number); // Error - var o19 = __assign({}, e); // Error, enum } diff --git a/tests/cases/compiler/restInvalidArgumentType.ts b/tests/cases/compiler/restInvalidArgumentType.ts index 488f546e231..2d50903328f 100644 --- a/tests/cases/compiler/restInvalidArgumentType.ts +++ b/tests/cases/compiler/restInvalidArgumentType.ts @@ -1,5 +1,3 @@ -enum E { v1, v2 }; - function f(p1: T, p2: T[]) { var t: T; @@ -10,24 +8,13 @@ function f(p1: T, p2: T[]) { var mapped: {[P in "b"]: T[P]}; var union_generic: T | { a: number }; - var union_primitive: { a: number } | number; - var intersection_generic: T & { a: number }; - var intersection_premitive: { a: number } | string; - - var num: number; - var str: number; var u: undefined; var n: null; var a: any; - var literal_string: "string"; - var literal_number: 42; - - var e: E; - var {...r1} = p1; // Error, generic type paramterre var {...r2} = p2; // OK var {...r3} = t; // Error, generic type paramter @@ -39,21 +26,11 @@ function f(p1: T, p2: T[]) { var {...r7} = mapped; // OK, non-generic mapped type var {...r8} = union_generic; // Error, union with generic type parameter - var {...r9} = union_primitive; // Error, union with generic type parameter var {...r10} = intersection_generic; // Error, intersection with generic type parameter - var {...r11} = intersection_premitive; // Error, intersection with generic type parameter - - var {...r12} = num; // Error - var {...r13} = str; // Error var {...r14} = u; // OK var {...r15} = n; // OK var {...r16} = a; // OK - - var {...r17} = literal_string; // Error - var {...r18} = literal_number; // Error - - var {...r19} = e; // Error, enum -} \ No newline at end of file +} diff --git a/tests/cases/compiler/spreadInvalidArgumentType.ts b/tests/cases/compiler/spreadInvalidArgumentType.ts index 2ac6aa921f4..bf7365e8ab0 100644 --- a/tests/cases/compiler/spreadInvalidArgumentType.ts +++ b/tests/cases/compiler/spreadInvalidArgumentType.ts @@ -1,5 +1,3 @@ -enum E { v1, v2 }; - function f(p1: T, p2: T[]) { var t: T; @@ -10,24 +8,14 @@ function f(p1: T, p2: T[]) { var mapped: {[P in "b"]: T[P]}; var union_generic: T | { a: number }; - var union_primitive: { a: number } | number; var intersection_generic: T & { a: number }; - var intersection_premitive: { a: number } | string; - - var num: number; - var str: number; var u: undefined; var n: null; var a: any; - var literal_string: "string"; - var literal_number: 42; - - var e: E; - var o1 = { ...p1 }; // Error, generic type paramterre var o2 = { ...p2 }; // OK var o3 = { ...t }; // Error, generic type paramter @@ -39,21 +27,11 @@ function f(p1: T, p2: T[]) { var o7 = { ...mapped }; // OK, non-generic mapped type var o8 = { ...union_generic }; // Error, union with generic type parameter - var o9 = { ...union_primitive }; // Error, union with generic type parameter var o10 = { ...intersection_generic }; // Error, intersection with generic type parameter - var o11 = { ...intersection_premitive }; // Error, intersection with generic type parameter - - var o12 = { ...num }; // Error - var o13 = { ...str }; // Error var o14 = { ...u }; // OK var o15 = { ...n }; // OK var o16 = { ...a }; // OK - - var o17 = { ...literal_string }; // Error - var o18 = { ...literal_number }; // Error - - var o19 = { ...e }; // Error, enum -} \ No newline at end of file +} diff --git a/tests/cases/conformance/types/spread/objectSpreadNegative.ts b/tests/cases/conformance/types/spread/objectSpreadNegative.ts index beb9ff265b4..8fe9174f759 100644 --- a/tests/cases/conformance/types/spread/objectSpreadNegative.ts +++ b/tests/cases/conformance/types/spread/objectSpreadNegative.ts @@ -29,9 +29,7 @@ spread = b; // error, missing 's' let duplicated = { b: 'bad', ...o, b: 'bad', ...o2, b: 'bad' } let duplicatedSpread = { ...o, ...o } -// primitives are not allowed -let spreadNum = { ...12 }; -let spreadSum = { ...1 + 1 }; +// primitives are skipped let spreadStr = { ...'foo' }; spreadStr.length; // error, no 'length' spreadStr.charAt(1); // error, no methods either From ae1752e10d65c5401be051e90ed452415a69c3a8 Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Wed, 13 Sep 2017 15:16:03 -0700 Subject: [PATCH 328/370] Actually be able to run RWC tests in parallel (#18453) --- src/harness/runner.ts | 4 ++-- src/harness/rwcRunner.ts | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/harness/runner.ts b/src/harness/runner.ts index 4653e440f11..6e1f91b21af 100644 --- a/src/harness/runner.ts +++ b/src/harness/runner.ts @@ -216,8 +216,8 @@ if (taskConfigsFolder) { for (let i = 0; i < workerCount; i++) { const config = workerConfigs[i]; - // use last worker to run unit tests - config.runUnitTests = i === workerCount - 1; + // use last worker to run unit tests if we're not just running a single specific runner + config.runUnitTests = runners.length !== 1 && i === workerCount - 1; Harness.IO.writeFile(ts.combinePaths(taskConfigsFolder, `task-config${i}.json`), JSON.stringify(workerConfigs[i])); } } diff --git a/src/harness/rwcRunner.ts b/src/harness/rwcRunner.ts index cddb9b19d4a..b3ef80b2a31 100644 --- a/src/harness/rwcRunner.ts +++ b/src/harness/rwcRunner.ts @@ -263,7 +263,7 @@ class RWCRunner extends RunnerBase { */ public initializeTests(): void { // Read in and evaluate the test list - const testList = this.enumerateTestFiles(); + const testList = this.tests && this.tests.length ? this.tests : this.enumerateTestFiles(); for (let i = 0; i < testList.length; i++) { this.runTest(testList[i]); } From cf53743bd696de5b3a3eff71a13b799c8e390ea7 Mon Sep 17 00:00:00 2001 From: Andy Date: Thu, 14 Sep 2017 07:59:53 -0700 Subject: [PATCH 329/370] In `isInPropertyInitializer`, don't bail out at a `PropertyAssignment` (#18449) --- src/compiler/checker.ts | 16 +++++++++++++++- ...reDeclaration_propertyAssignment.errors.txt | 11 +++++++++++ .../useBeforeDeclaration_propertyAssignment.js | 18 ++++++++++++++++++ .../useBeforeDeclaration_propertyAssignment.ts | 4 ++++ 4 files changed, 48 insertions(+), 1 deletion(-) create mode 100644 tests/baselines/reference/useBeforeDeclaration_propertyAssignment.errors.txt create mode 100644 tests/baselines/reference/useBeforeDeclaration_propertyAssignment.js create mode 100644 tests/cases/compiler/useBeforeDeclaration_propertyAssignment.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 5c6a8b59119..1fae08328b3 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -14753,7 +14753,7 @@ namespace ts { return; } - if (findAncestor(node, node => node.kind === SyntaxKind.PropertyDeclaration ? true : isExpression(node) ? false : "quit") && + if (isInPropertyInitializer(node) && !isBlockScopedNameDeclaredBeforeUse(valueDeclaration, right) && !isPropertyDeclaredInAncestorClass(prop)) { error(right, Diagnostics.Block_scoped_variable_0_used_before_its_declaration, unescapeLeadingUnderscores(right.escapedText)); @@ -14766,6 +14766,20 @@ namespace ts { } } + function isInPropertyInitializer(node: Node): boolean { + return !!findAncestor(node, node => { + switch (node.kind) { + case SyntaxKind.PropertyDeclaration: + return true; + case SyntaxKind.PropertyAssignment: + // We might be in `a = { b: this.b }`, so keep looking. See `tests/cases/compiler/useBeforeDeclaration_propertyAssignment.ts`. + return false; + default: + return isPartOfExpression(node) ? false : "quit"; + } + }); + } + /** * It's possible that "prop.valueDeclaration" is a local declaration, but the property was also declared in a superclass. * In that case we won't consider it used before its declaration, because it gets its value from the superclass' declaration. diff --git a/tests/baselines/reference/useBeforeDeclaration_propertyAssignment.errors.txt b/tests/baselines/reference/useBeforeDeclaration_propertyAssignment.errors.txt new file mode 100644 index 00000000000..f237fd07c80 --- /dev/null +++ b/tests/baselines/reference/useBeforeDeclaration_propertyAssignment.errors.txt @@ -0,0 +1,11 @@ +tests/cases/compiler/useBeforeDeclaration_propertyAssignment.ts(2,27): error TS2448: Block-scoped variable 'b' used before its declaration. + + +==== tests/cases/compiler/useBeforeDeclaration_propertyAssignment.ts (1 errors) ==== + export class C { + public a = { b: this.b }; + ~ +!!! error TS2448: Block-scoped variable 'b' used before its declaration. + private b = 0; + } + \ No newline at end of file diff --git a/tests/baselines/reference/useBeforeDeclaration_propertyAssignment.js b/tests/baselines/reference/useBeforeDeclaration_propertyAssignment.js new file mode 100644 index 00000000000..e34604e0a4e --- /dev/null +++ b/tests/baselines/reference/useBeforeDeclaration_propertyAssignment.js @@ -0,0 +1,18 @@ +//// [useBeforeDeclaration_propertyAssignment.ts] +export class C { + public a = { b: this.b }; + private b = 0; +} + + +//// [useBeforeDeclaration_propertyAssignment.js] +"use strict"; +exports.__esModule = true; +var C = /** @class */ (function () { + function C() { + this.a = { b: this.b }; + this.b = 0; + } + return C; +}()); +exports.C = C; diff --git a/tests/cases/compiler/useBeforeDeclaration_propertyAssignment.ts b/tests/cases/compiler/useBeforeDeclaration_propertyAssignment.ts new file mode 100644 index 00000000000..bdd84473c57 --- /dev/null +++ b/tests/cases/compiler/useBeforeDeclaration_propertyAssignment.ts @@ -0,0 +1,4 @@ +export class C { + public a = { b: this.b }; + private b = 0; +} From d96dfeb708bfec850031a85cc197dfd5732bd52a Mon Sep 17 00:00:00 2001 From: Andy Date: Thu, 14 Sep 2017 08:23:50 -0700 Subject: [PATCH 330/370] Don't normalize whitespace in fourslash tests (#18447) * Don't normalize whitespace in fourslash tests * Only render whitespace when the diff is text-only --- src/harness/fourslash.ts | 93 +++++++++---------- src/harness/harness.ts | 3 +- src/harness/harnessLanguageService.ts | 2 +- src/server/client.ts | 3 +- src/server/protocol.ts | 1 + src/server/session.ts | 2 +- src/services/services.ts | 2 +- src/services/textChanges.ts | 6 +- .../fourslash/codeFixAddMissingMember5.ts | 3 +- .../fourslash/codeFixAddMissingMember7.ts | 3 +- .../cases/fourslash/codeFixSuperAfterThis.ts | 5 +- tests/cases/fourslash/codeFixSuperCall.ts | 3 +- tests/cases/fourslash/extract-method14.ts | 2 +- .../fourslash/formatConflictDiff3Marker1.ts | 18 ++-- .../cases/fourslash/formatConflictMarker1.ts | 14 +-- .../fourslash/importNameCodeFixReExport.ts | 5 +- 16 files changed, 82 insertions(+), 83 deletions(-) diff --git a/src/harness/fourslash.ts b/src/harness/fourslash.ts index d89a4677ef9..fb5e9e0354e 100644 --- a/src/harness/fourslash.ts +++ b/src/harness/fourslash.ts @@ -22,10 +22,6 @@ namespace FourSlash { ts.disableIncrementalParsing = false; - function normalizeNewLines(s: string) { - return s.replace(/\r\n/g, "\n"); - } - // Represents a parsed source file with metadata export interface FourSlashFile { // The contents of the file (with markers, etc stripped out) @@ -364,7 +360,7 @@ namespace FourSlash { baseIndentSize: 0, indentSize: 4, tabSize: 4, - newLineCharacter: Harness.IO.newLine(), + newLineCharacter: "\n", convertTabsToSpaces: true, indentStyle: ts.IndentStyle.Smart, insertSpaceAfterCommaDelimiter: true, @@ -1603,7 +1599,7 @@ namespace FourSlash { } } - public printCurrentFileState(makeWhitespaceVisible: boolean, makeCaretVisible: boolean) { + public printCurrentFileState(showWhitespace: boolean, makeCaretVisible: boolean) { for (const file of this.testData.files) { const active = (this.activeFile === file); Harness.IO.log(`=== Script (${file.fileName}) ${(active ? "(active, cursor at |)" : "")} ===`); @@ -1611,8 +1607,8 @@ namespace FourSlash { if (active) { content = content.substr(0, this.currentCaretPosition) + (makeCaretVisible ? "|" : "") + content.substr(this.currentCaretPosition); } - if (makeWhitespaceVisible) { - content = TestState.makeWhitespaceVisible(content); + if (showWhitespace) { + content = makeWhitespaceVisible(content); } Harness.IO.log(content); } @@ -2128,10 +2124,8 @@ namespace FourSlash { public verifyCurrentFileContent(text: string) { const actual = this.getFileContent(this.activeFile.fileName); - if (normalizeNewLines(actual) !== normalizeNewLines(text)) { - throw new Error("verifyCurrentFileContent\n" + - "\tExpected: \"" + TestState.makeWhitespaceVisible(text) + "\"\n" + - "\t Actual: \"" + TestState.makeWhitespaceVisible(actual) + "\""); + if (actual !== text) { + throw new Error(`verifyCurrentFileContent failed:\n${showTextDiff(text, actual)}`); } } @@ -2305,11 +2299,11 @@ namespace FourSlash { const actualText = this.rangeText(ranges[0]); const result = includeWhiteSpace - ? normalizeNewLines(actualText) === normalizeNewLines(expectedText) + ? actualText === expectedText : this.removeWhitespace(actualText) === this.removeWhitespace(expectedText); if (!result) { - this.raiseError(`Actual text doesn't match expected text. Actual:\n'${actualText}'\nExpected:\n'${expectedText}'`); + this.raiseError(`Actual range text doesn't match expected text.\n${showTextDiff(expectedText, actualText)}`); } } @@ -2403,15 +2397,19 @@ namespace FourSlash { const originalContent = scriptInfo.content; for (const codeFix of codeFixes) { this.applyEdits(codeFix.changes[0].fileName, codeFix.changes[0].textChanges, /*isFormattingEdit*/ false); - actualTextArray.push(this.normalizeNewlines(this.rangeText(ranges[0]))); + let text = this.rangeText(ranges[0]); + // TODO:GH#18445 (remove this line to see errors in many `importNameCodeFix` tests) + text = text.replace(/\r\n/g, "\n"); + actualTextArray.push(text); scriptInfo.updateContent(originalContent); } - const sortedExpectedArray = ts.map(expectedTextArray, str => this.normalizeNewlines(str)).sort(); + const sortedExpectedArray = expectedTextArray.sort(); const sortedActualArray = actualTextArray.sort(); - if (!ts.arrayIsEqualTo(sortedExpectedArray, sortedActualArray)) { - this.raiseError( - `Actual text array doesn't match expected text array. \nActual: \n'${sortedActualArray.join("\n\n")}'\n---\nExpected: \n'${sortedExpectedArray.join("\n\n")}'`); - } + ts.zipWith(sortedExpectedArray, sortedActualArray, (expected, actual, index) => { + if (expected !== actual) { + this.raiseError(`Import fix at index ${index} doesn't match.\n${showTextDiff(expected, actual)}`); + } + }); } public verifyDocCommentTemplate(expected: ts.TextInsertion | undefined) { @@ -2431,7 +2429,7 @@ namespace FourSlash { } if (actual.newText !== expected.newText) { - this.raiseError(`${name} failed - expected insertion:\n"${this.clarifyNewlines(expected.newText)}"\nactual insertion:\n"${this.clarifyNewlines(actual.newText)}"`); + this.raiseError(`${name} failed for expected insertion.\n${showTextDiff(expected.newText, actual.newText)}`); } if (actual.caretOffset !== expected.caretOffset) { @@ -2440,17 +2438,6 @@ namespace FourSlash { } } - private clarifyNewlines(str: string) { - return str.replace(/\r?\n/g, lineEnding => { - const representation = lineEnding === "\r\n" ? "CRLF" : "LF"; - return "# - " + representation + lineEnding; - }); - } - - private normalizeNewlines(str: string) { - return str.replace(/\r?\n/g, "\n"); - } - public verifyBraceCompletionAtPosition(negative: boolean, openingBrace: string) { const openBraceMap = ts.createMapFromTemplate({ @@ -2878,8 +2865,8 @@ namespace FourSlash { } const actualContent = this.getFileContent(this.activeFile.fileName); - if (this.normalizeNewlines(actualContent) !== this.normalizeNewlines(expectedContent)) { - this.raiseError(`verifyFileAfterApplyingRefactors failed: expected:\n${expectedContent}\nactual:\n${actualContent}`); + if (actualContent !== expectedContent) { + this.raiseError(`verifyFileAfterApplyingRefactors failed:\n${showTextDiff(expectedContent, actualContent)}`); } } @@ -3014,10 +3001,6 @@ namespace FourSlash { } } - private static makeWhitespaceVisible(text: string) { - return text.replace(/ /g, "\u00B7").replace(/\r/g, "\u00B6").replace(/\n/g, "\u2193\n").replace(/\t/g, "\u2192\ "); - } - public setCancelled(numberOfCalls: number): void { this.cancellationToken.setCancelled(numberOfCalls); } @@ -3319,12 +3302,7 @@ ${code} let column = 1; const flush = (lastSafeCharIndex: number) => { - if (lastSafeCharIndex === undefined) { - output = output + content.substr(lastNormalCharPosition); - } - else { - output = output + content.substr(lastNormalCharPosition, lastSafeCharIndex - lastNormalCharPosition); - } + output = output + content.substr(lastNormalCharPosition, lastSafeCharIndex === undefined ? undefined : lastSafeCharIndex - lastNormalCharPosition); }; if (content.length > 0) { @@ -3511,6 +3489,27 @@ ${code} function toArray(x: T | T[]): T[] { return ts.isArray(x) ? x : [x]; } + + function makeWhitespaceVisible(text: string) { + return text.replace(/ /g, "\u00B7").replace(/\r/g, "\u00B6").replace(/\n/g, "\u2193\n").replace(/\t/g, "\u2192\ "); + } + + function showTextDiff(expected: string, actual: string): string { + // Only show whitespace if the difference is whitespace-only. + if (differOnlyByWhitespace(expected, actual)) { + expected = makeWhitespaceVisible(expected); + actual = makeWhitespaceVisible(actual); + } + return `Expected:\n${expected}\nActual:${actual}`; + } + + function differOnlyByWhitespace(a: string, b: string) { + return stripWhitespace(a) === stripWhitespace(b); + } + + function stripWhitespace(s: string): string { + return s.replace(/\s/g, ""); + } } namespace FourSlashInterface { @@ -4143,15 +4142,15 @@ namespace FourSlashInterface { } public printCurrentFileState() { - this.state.printCurrentFileState(/*makeWhitespaceVisible*/ false, /*makeCaretVisible*/ true); + this.state.printCurrentFileState(/*showWhitespace*/ false, /*makeCaretVisible*/ true); } public printCurrentFileStateWithWhitespace() { - this.state.printCurrentFileState(/*makeWhitespaceVisible*/ true, /*makeCaretVisible*/ true); + this.state.printCurrentFileState(/*showWhitespace*/ true, /*makeCaretVisible*/ true); } public printCurrentFileStateWithoutCaret() { - this.state.printCurrentFileState(/*makeWhitespaceVisible*/ false, /*makeCaretVisible*/ false); + this.state.printCurrentFileState(/*showWhitespace*/ false, /*makeCaretVisible*/ false); } public printCurrentQuickInfo() { diff --git a/src/harness/harness.ts b/src/harness/harness.ts index 2fc1aac2d83..8344be36753 100644 --- a/src/harness/harness.ts +++ b/src/harness/harness.ts @@ -500,7 +500,8 @@ namespace Harness { export let IO: IO; // harness always uses one kind of new line - const harnessNewLine = "\r\n"; + // But note that `parseTestData` in `fourslash.ts` uses "\n" + export const harnessNewLine = "\r\n"; // Root for file paths that are stored in a virtual file system export const virtualFileSystemRoot = "/"; diff --git a/src/harness/harnessLanguageService.ts b/src/harness/harnessLanguageService.ts index 78da05570d8..23bc08108c7 100644 --- a/src/harness/harnessLanguageService.ts +++ b/src/harness/harnessLanguageService.ts @@ -130,7 +130,7 @@ namespace Harness.LanguageService { } public getNewLine(): string { - return "\r\n"; + return harnessNewLine; } public getFilenames(): string[] { diff --git a/src/server/client.ts b/src/server/client.ts index 0ffac42dae4..9e472a83e2b 100644 --- a/src/server/client.ts +++ b/src/server/client.ts @@ -573,7 +573,7 @@ namespace ts.server { getEditsForRefactor( fileName: string, - _formatOptions: FormatCodeSettings, + formatOptions: FormatCodeSettings, positionOrRange: number | TextRange, refactorName: string, actionName: string): RefactorEditInfo { @@ -581,6 +581,7 @@ namespace ts.server { const args = this.createFileLocationOrRangeRequestArgs(positionOrRange, fileName) as protocol.GetEditsForRefactorRequestArgs; args.refactor = refactorName; args.action = actionName; + args.formatOptions = formatOptions; const request = this.processRequest(CommandNames.GetEditsForRefactor, args); const response = this.processResponse(request); diff --git a/src/server/protocol.ts b/src/server/protocol.ts index 3fdbd8fd7f7..1740f8ae0ba 100644 --- a/src/server/protocol.ts +++ b/src/server/protocol.ts @@ -494,6 +494,7 @@ namespace ts.server.protocol { refactor: string; /* The 'name' property from the refactoring action */ action: string; + formatOptions: FormatCodeSettings, }; diff --git a/src/server/session.ts b/src/server/session.ts index 0b3038a408d..2d773d6f467 100644 --- a/src/server/session.ts +++ b/src/server/session.ts @@ -1488,7 +1488,7 @@ namespace ts.server { const result = project.getLanguageService().getEditsForRefactor( file, - this.projectService.getFormatCodeOptions(), + convertFormatOptions(args.formatOptions), position || textRange, args.refactor, args.action diff --git a/src/services/services.ts b/src/services/services.ts index 197f76b607f..bdd0eb41e4f 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -2019,7 +2019,7 @@ namespace ts { startPosition, endPosition, program: getProgram(), - newLineCharacter: host.getNewLine(), + newLineCharacter: formatOptions ? formatOptions.newLineCharacter : host.getNewLine(), rulesProvider: getRuleProvider(formatOptions), cancellationToken }; diff --git a/src/services/textChanges.ts b/src/services/textChanges.ts index 42c1d1e9a4f..f3ad7df1607 100644 --- a/src/services/textChanges.ts +++ b/src/services/textChanges.ts @@ -184,16 +184,12 @@ namespace ts.textChanges { return s; } - function getNewlineKind(context: { newLineCharacter: string }) { - return context.newLineCharacter === "\n" ? NewLineKind.LineFeed : NewLineKind.CarriageReturnLineFeed; - } - export class ChangeTracker { private changes: Change[] = []; private readonly newLineCharacter: string; public static fromContext(context: RefactorContext | CodeFixContext) { - return new ChangeTracker(getNewlineKind(context), context.rulesProvider); + return new ChangeTracker(context.newLineCharacter === "\n" ? NewLineKind.LineFeed : NewLineKind.CarriageReturnLineFeed, context.rulesProvider); } constructor( diff --git a/tests/cases/fourslash/codeFixAddMissingMember5.ts b/tests/cases/fourslash/codeFixAddMissingMember5.ts index db893cb61d3..44b11c5141b 100644 --- a/tests/cases/fourslash/codeFixAddMissingMember5.ts +++ b/tests/cases/fourslash/codeFixAddMissingMember5.ts @@ -17,5 +17,4 @@ verify.currentFileContentIs(`class C { ()=>{ this.foo === 10 }; } } -C.foo = undefined; -`); \ No newline at end of file +C.foo = undefined;` + "\r\n"); // TODO: GH#18445 diff --git a/tests/cases/fourslash/codeFixAddMissingMember7.ts b/tests/cases/fourslash/codeFixAddMissingMember7.ts index 8ac7f2b5aff..7690023815c 100644 --- a/tests/cases/fourslash/codeFixAddMissingMember7.ts +++ b/tests/cases/fourslash/codeFixAddMissingMember7.ts @@ -13,5 +13,4 @@ verify.getAndApplyCodeFix(/*errorCode*/ undefined, /*index*/ 2) verify.currentFileContentIs(`class C { static p = ()=>{ this.foo === 10 }; } -C.foo = undefined; -`); +C.foo = undefined;` + "\r\n"); // TODO: GH#18445 diff --git a/tests/cases/fourslash/codeFixSuperAfterThis.ts b/tests/cases/fourslash/codeFixSuperAfterThis.ts index 55b44b07881..a4db2c909fd 100644 --- a/tests/cases/fourslash/codeFixSuperAfterThis.ts +++ b/tests/cases/fourslash/codeFixSuperAfterThis.ts @@ -9,7 +9,8 @@ //// super(); //// |]} ////} +// TODO: GH#18445 verify.rangeAfterCodeFix(` - super(); + super();\r this.a = 12; - `, /*includeWhiteSpace*/ true); \ No newline at end of file + `, /*includeWhiteSpace*/ true); diff --git a/tests/cases/fourslash/codeFixSuperCall.ts b/tests/cases/fourslash/codeFixSuperCall.ts index f7584050a15..28f7d34a2bd 100644 --- a/tests/cases/fourslash/codeFixSuperCall.ts +++ b/tests/cases/fourslash/codeFixSuperCall.ts @@ -6,6 +6,7 @@ //// constructor() {[| //// |]} ////} +// TODO: GH#18445 verify.rangeAfterCodeFix(` - super(); + super();\r `, /*includeWhitespace*/ true); diff --git a/tests/cases/fourslash/extract-method14.ts b/tests/cases/fourslash/extract-method14.ts index 27a561743c6..e2b58a36450 100644 --- a/tests/cases/fourslash/extract-method14.ts +++ b/tests/cases/fourslash/extract-method14.ts @@ -19,7 +19,7 @@ edit.applyRefactor({ `function foo() { var i = 10; var __return: any; - ({ __return, i } = n/*RENAME*/ewFunction(i)); + ({ __return, i } = /*RENAME*/newFunction(i)); return __return; } function newFunction(i) { diff --git a/tests/cases/fourslash/formatConflictDiff3Marker1.ts b/tests/cases/fourslash/formatConflictDiff3Marker1.ts index f6492a6f60c..188fe5b0dd2 100644 --- a/tests/cases/fourslash/formatConflictDiff3Marker1.ts +++ b/tests/cases/fourslash/formatConflictDiff3Marker1.ts @@ -11,12 +11,12 @@ ////} format.document(); -verify.currentFileContentIs("class C {\r\n\ -<<<<<<< HEAD\r\n\ - v = 1;\r\n\ -||||||| merged common ancestors\r\n\ -v = 3;\r\n\ -=======\r\n\ -v = 2;\r\n\ ->>>>>>> Branch - a\r\n\ -}"); \ No newline at end of file +verify.currentFileContentIs(`class C { +<<<<<<< HEAD + v = 1; +||||||| merged common ancestors +v = 3; +======= +v = 2; +>>>>>>> Branch - a +}`); diff --git a/tests/cases/fourslash/formatConflictMarker1.ts b/tests/cases/fourslash/formatConflictMarker1.ts index c0e2dbc4f69..413206dc893 100644 --- a/tests/cases/fourslash/formatConflictMarker1.ts +++ b/tests/cases/fourslash/formatConflictMarker1.ts @@ -9,10 +9,10 @@ ////} format.document(); -verify.currentFileContentIs("class C {\r\n\ -<<<<<<< HEAD\r\n\ - v = 1;\r\n\ -=======\r\n\ -v = 2;\r\n\ ->>>>>>> Branch - a\r\n\ -}"); \ No newline at end of file +verify.currentFileContentIs(`class C { +<<<<<<< HEAD + v = 1; +======= +v = 2; +>>>>>>> Branch - a +}`); diff --git a/tests/cases/fourslash/importNameCodeFixReExport.ts b/tests/cases/fourslash/importNameCodeFixReExport.ts index c77d32cc458..eb1c1a91343 100644 --- a/tests/cases/fourslash/importNameCodeFixReExport.ts +++ b/tests/cases/fourslash/importNameCodeFixReExport.ts @@ -10,7 +10,8 @@ ////x;|] goTo.file("/b.ts"); -verify.rangeAfterCodeFix(`import { x } from "./a"; - +// TODO:GH#18445 +verify.rangeAfterCodeFix(`import { x } from "./a";\r +\r export { x } from "./a"; x;`, /*includeWhiteSpace*/ true); From 76eab54ab7b73027651cc4551346476e7e0f1443 Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Thu, 14 Sep 2017 11:11:54 -0700 Subject: [PATCH 331/370] Add error for using generalized expressions with export assignments in ambient contexts (#18444) --- src/compiler/checker.ts | 4 ++ src/compiler/diagnosticMessages.json | 4 ++ .../ambientExportDefaultErrors.errors.txt | 41 +++++++++++++++++++ .../reference/ambientExportDefaultErrors.js | 39 ++++++++++++++++++ .../baselines/reference/es5-commonjs7.symbols | 4 +- tests/baselines/reference/es5-commonjs7.types | 4 +- tests/baselines/reference/typeAliasExport.js | 2 +- .../reference/typeAliasExport.symbols | 4 +- .../baselines/reference/typeAliasExport.types | 4 +- .../compiler/ambientExportDefaultErrors.ts | 27 ++++++++++++ tests/cases/compiler/es5-commonjs7.ts | 2 +- tests/cases/compiler/typeAliasExport.ts | 2 +- 12 files changed, 130 insertions(+), 7 deletions(-) create mode 100644 tests/baselines/reference/ambientExportDefaultErrors.errors.txt create mode 100644 tests/baselines/reference/ambientExportDefaultErrors.js create mode 100644 tests/cases/compiler/ambientExportDefaultErrors.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index eb662cbd382..1957ebf23bb 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -22345,6 +22345,10 @@ namespace ts { checkExternalModuleExports(container); + if (isInAmbientContext(node) && !isEntityNameExpression(node.expression)) { + grammarErrorOnNode(node.expression, Diagnostics.The_expression_of_an_export_assignment_must_be_an_identifier_or_qualified_name_in_an_ambient_context); + } + if (node.isExportEquals && !isInAmbientContext(node)) { if (modulekind >= ModuleKind.ES2015) { // export assignment is not supported in es6 modules diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index af7f6d6c949..8a76ddcda9a 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -2212,6 +2212,10 @@ "category": "Error", "code": 2713 }, + "The expression of an export assignment must be an identifier or qualified name in an ambient context.": { + "category": "Error", + "code": 2714 + }, "Import declaration '{0}' is using private name '{1}'.": { "category": "Error", diff --git a/tests/baselines/reference/ambientExportDefaultErrors.errors.txt b/tests/baselines/reference/ambientExportDefaultErrors.errors.txt new file mode 100644 index 00000000000..246ff5147b2 --- /dev/null +++ b/tests/baselines/reference/ambientExportDefaultErrors.errors.txt @@ -0,0 +1,41 @@ +tests/cases/compiler/foo.d.ts(1,16): error TS2714: The expression of an export assignment must be an identifier or qualified name in an ambient context. +tests/cases/compiler/foo2.d.ts(1,10): error TS2714: The expression of an export assignment must be an identifier or qualified name in an ambient context. +tests/cases/compiler/indirection.d.ts(3,20): error TS2714: The expression of an export assignment must be an identifier or qualified name in an ambient context. +tests/cases/compiler/indirection2.d.ts(3,14): error TS2714: The expression of an export assignment must be an identifier or qualified name in an ambient context. + + +==== tests/cases/compiler/consumer.ts (0 errors) ==== + /// + /// + import "indirect"; + import "foo"; + import "indirect2"; + import "foo2"; +==== tests/cases/compiler/foo.d.ts (1 errors) ==== + export default 2 + 2; + ~~~~~ +!!! error TS2714: The expression of an export assignment must be an identifier or qualified name in an ambient context. + export as namespace Foo; + +==== tests/cases/compiler/foo2.d.ts (1 errors) ==== + export = 2 + 2; + ~~~~~ +!!! error TS2714: The expression of an export assignment must be an identifier or qualified name in an ambient context. + export as namespace Foo2; + +==== tests/cases/compiler/indirection.d.ts (1 errors) ==== + /// + declare module "indirect" { + export default typeof Foo.default; + ~~~~~~~~~~~~~~~~~~ +!!! error TS2714: The expression of an export assignment must be an identifier or qualified name in an ambient context. + } + +==== tests/cases/compiler/indirection2.d.ts (1 errors) ==== + /// + declare module "indirect2" { + export = typeof Foo2; + ~~~~~~~~~~~ +!!! error TS2714: The expression of an export assignment must be an identifier or qualified name in an ambient context. + } + \ No newline at end of file diff --git a/tests/baselines/reference/ambientExportDefaultErrors.js b/tests/baselines/reference/ambientExportDefaultErrors.js new file mode 100644 index 00000000000..3d8d2bf65f9 --- /dev/null +++ b/tests/baselines/reference/ambientExportDefaultErrors.js @@ -0,0 +1,39 @@ +//// [tests/cases/compiler/ambientExportDefaultErrors.ts] //// + +//// [foo.d.ts] +export default 2 + 2; +export as namespace Foo; + +//// [foo2.d.ts] +export = 2 + 2; +export as namespace Foo2; + +//// [indirection.d.ts] +/// +declare module "indirect" { + export default typeof Foo.default; +} + +//// [indirection2.d.ts] +/// +declare module "indirect2" { + export = typeof Foo2; +} + +//// [consumer.ts] +/// +/// +import "indirect"; +import "foo"; +import "indirect2"; +import "foo2"; + +//// [consumer.js] +"use strict"; +exports.__esModule = true; +/// +/// +require("indirect"); +require("foo"); +require("indirect2"); +require("foo2"); diff --git a/tests/baselines/reference/es5-commonjs7.symbols b/tests/baselines/reference/es5-commonjs7.symbols index 0ac992e7db9..ed8247a6878 100644 --- a/tests/baselines/reference/es5-commonjs7.symbols +++ b/tests/baselines/reference/es5-commonjs7.symbols @@ -1,5 +1,7 @@ === tests/cases/compiler/test.d.ts === -export default "test"; +export default undefined; +>undefined : Symbol(default) + export var __esModule; >__esModule : Symbol(__esModule, Decl(test.d.ts, 1, 10)) diff --git a/tests/baselines/reference/es5-commonjs7.types b/tests/baselines/reference/es5-commonjs7.types index 60d9f9b6c62..5b6c3f1e816 100644 --- a/tests/baselines/reference/es5-commonjs7.types +++ b/tests/baselines/reference/es5-commonjs7.types @@ -1,5 +1,7 @@ === tests/cases/compiler/test.d.ts === -export default "test"; +export default undefined; +>undefined : undefined + export var __esModule; >__esModule : any diff --git a/tests/baselines/reference/typeAliasExport.js b/tests/baselines/reference/typeAliasExport.js index fa864f571ea..dca14cea38e 100644 --- a/tests/baselines/reference/typeAliasExport.js +++ b/tests/baselines/reference/typeAliasExport.js @@ -1,6 +1,6 @@ //// [typeAliasExport.ts] declare module "a" { - export default 0 + export default undefined export var a; export type a = typeof a; } diff --git a/tests/baselines/reference/typeAliasExport.symbols b/tests/baselines/reference/typeAliasExport.symbols index 1f580b03011..e019ca7a10b 100644 --- a/tests/baselines/reference/typeAliasExport.symbols +++ b/tests/baselines/reference/typeAliasExport.symbols @@ -1,6 +1,8 @@ === tests/cases/compiler/typeAliasExport.ts === declare module "a" { - export default 0 + export default undefined +>undefined : Symbol(default) + export var a; >a : Symbol(a, Decl(typeAliasExport.ts, 2, 12), Decl(typeAliasExport.ts, 2, 15)) diff --git a/tests/baselines/reference/typeAliasExport.types b/tests/baselines/reference/typeAliasExport.types index afa26073061..e9a7b92c3e7 100644 --- a/tests/baselines/reference/typeAliasExport.types +++ b/tests/baselines/reference/typeAliasExport.types @@ -1,6 +1,8 @@ === tests/cases/compiler/typeAliasExport.ts === declare module "a" { - export default 0 + export default undefined +>undefined : undefined + export var a; >a : any diff --git a/tests/cases/compiler/ambientExportDefaultErrors.ts b/tests/cases/compiler/ambientExportDefaultErrors.ts new file mode 100644 index 00000000000..589af41333a --- /dev/null +++ b/tests/cases/compiler/ambientExportDefaultErrors.ts @@ -0,0 +1,27 @@ +// @filename: foo.d.ts +export default 2 + 2; +export as namespace Foo; + +// @filename: foo2.d.ts +export = 2 + 2; +export as namespace Foo2; + +// @filename: indirection.d.ts +/// +declare module "indirect" { + export default typeof Foo.default; +} + +// @filename: indirection2.d.ts +/// +declare module "indirect2" { + export = typeof Foo2; +} + +// @filename: consumer.ts +/// +/// +import "indirect"; +import "foo"; +import "indirect2"; +import "foo2"; \ No newline at end of file diff --git a/tests/cases/compiler/es5-commonjs7.ts b/tests/cases/compiler/es5-commonjs7.ts index 384feb22638..0ad10c1822d 100644 --- a/tests/cases/compiler/es5-commonjs7.ts +++ b/tests/cases/compiler/es5-commonjs7.ts @@ -4,5 +4,5 @@ // @module: commonjs // @filename: test.d.ts -export default "test"; +export default undefined; export var __esModule; diff --git a/tests/cases/compiler/typeAliasExport.ts b/tests/cases/compiler/typeAliasExport.ts index 706b731f0ab..914deba40b5 100644 --- a/tests/cases/compiler/typeAliasExport.ts +++ b/tests/cases/compiler/typeAliasExport.ts @@ -1,5 +1,5 @@ declare module "a" { - export default 0 + export default undefined export var a; export type a = typeof a; } \ No newline at end of file From 6e512a495f235fed8d1a0a10b619e181c2ef2a5c Mon Sep 17 00:00:00 2001 From: Andy Date: Thu, 14 Sep 2017 11:16:21 -0700 Subject: [PATCH 332/370] extractMethod: Don't try to extract an ExpressionStatement consisting of a single token (#18450) * extractMethod: Don't try to extract an ExpressionStatement consisting of a single token * Move to unit test --- src/harness/unittests/extractMethods.ts | 2 ++ src/services/refactors/extractMethod.ts | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/harness/unittests/extractMethods.ts b/src/harness/unittests/extractMethods.ts index 5cab0289d67..ca77af61c75 100644 --- a/src/harness/unittests/extractMethods.ts +++ b/src/harness/unittests/extractMethods.ts @@ -410,6 +410,8 @@ function test(x: number) { "Statement or expression expected." ]); + testExtractRangeFailed("extract-method-not-for-token-expression-statement", `[#|a|]`, ["Select more than a single token."]); + testExtractMethod("extractMethod1", `namespace A { let x = 1; diff --git a/src/services/refactors/extractMethod.ts b/src/services/refactors/extractMethod.ts index 4c24d22a2f3..9ea3d9d11bd 100644 --- a/src/services/refactors/extractMethod.ts +++ b/src/services/refactors/extractMethod.ts @@ -231,7 +231,7 @@ namespace ts.refactor.extractMethod { } function checkRootNode(node: Node): Diagnostic[] | undefined { - if (isToken(node)) { + if (isToken(isExpressionStatement(node) ? node.expression : node)) { return [createDiagnosticForNode(node, Messages.InsufficientSelection)]; } return undefined; From 18653a5c5d31e08973520bcbf65d81872ac56923 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Thu, 14 Sep 2017 11:18:48 -0700 Subject: [PATCH 333/370] Use removeDefinitelyFalsyTypes for building partial type --- src/compiler/checker.ts | 13 ++-- tests/baselines/reference/spreadUnion2.js | 10 +-- .../baselines/reference/spreadUnion2.symbols | 24 ++++--- tests/baselines/reference/spreadUnion2.types | 66 +++++++++---------- .../reference/spreadUnion3.errors.txt | 12 ++-- .../conformance/types/spread/spreadUnion2.ts | 10 +-- 6 files changed, 63 insertions(+), 72 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index c8b0100a02e..a7c98f657dc 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -7923,15 +7923,10 @@ namespace ts { function getPartialTypeFromFalsyUnion(type: UnionType): Type | undefined { if (type.types.length === 2) { - // getFalsyFlagsOfTypes - // getTypeFacts - const i = Math.max(type.types.indexOf(falseType), - type.types.indexOf(zeroType), - type.types.indexOf(emptyStringType)); - if (i > -1) { + const truthy = removeDefinitelyFalsyTypes(type); + if (truthy !== type) { const members = createSymbolTable(); - const other = type.types[i === 0 ? 1 : 0]; - for (const prop of getPropertiesOfType(other)) { + for (const prop of getPropertiesOfType(truthy)) { if (prop.flags & SymbolFlags.Optional) { members.set(prop.escapedName, prop); } @@ -7943,7 +7938,7 @@ namespace ts { members.set(prop.escapedName, result); } } - return createAnonymousType(undefined, members, emptyArray, emptyArray, getIndexInfoOfType(other, IndexKind.String), getIndexInfoOfType(other, IndexKind.Number)); + return createAnonymousType(undefined, members, emptyArray, emptyArray, getIndexInfoOfType(truthy, IndexKind.String), getIndexInfoOfType(truthy, IndexKind.Number)); } } } diff --git a/tests/baselines/reference/spreadUnion2.js b/tests/baselines/reference/spreadUnion2.js index 6e49770617a..48b12731817 100644 --- a/tests/baselines/reference/spreadUnion2.js +++ b/tests/baselines/reference/spreadUnion2.js @@ -3,20 +3,20 @@ declare const undefinedUnion: { a: number } | undefined; declare const nullUnion: { b: number } | null; declare const nullAndUndefinedUnion: null | undefined; -var o1: {} | { a: number }; +var o1: { a?: number | undefined }; var o1 = { ...undefinedUnion }; -var o2: {} | { b: number }; +var o2: { b?: number | undefined }; var o2 = { ...nullUnion }; -var o3: {} | { b: number } | { a: number } | { a: number, b: number }; +var o3: { a?: number | undefined, b?: number | undefined }; var o3 = { ...undefinedUnion, ...nullUnion }; var o3 = { ...nullUnion, ...undefinedUnion }; -var o4: {} | { a: number }; +var o4: { a?: number | undefined }; var o4 = { ...undefinedUnion, ...undefinedUnion }; -var o5: {} | { b: number }; +var o5: { b?: number | undefined }; var o5 = { ...nullUnion, ...nullUnion }; var o6 = { ...nullAndUndefinedUnion, ...nullAndUndefinedUnion }; diff --git a/tests/baselines/reference/spreadUnion2.symbols b/tests/baselines/reference/spreadUnion2.symbols index c4d1f19b6d9..841bce12e42 100644 --- a/tests/baselines/reference/spreadUnion2.symbols +++ b/tests/baselines/reference/spreadUnion2.symbols @@ -10,28 +10,26 @@ declare const nullUnion: { b: number } | null; declare const nullAndUndefinedUnion: null | undefined; >nullAndUndefinedUnion : Symbol(nullAndUndefinedUnion, Decl(spreadUnion2.ts, 2, 13)) -var o1: {} | { a: number }; +var o1: { a?: number | undefined }; >o1 : Symbol(o1, Decl(spreadUnion2.ts, 4, 3), Decl(spreadUnion2.ts, 5, 3)) ->a : Symbol(a, Decl(spreadUnion2.ts, 4, 14)) +>a : Symbol(a, Decl(spreadUnion2.ts, 4, 9)) var o1 = { ...undefinedUnion }; >o1 : Symbol(o1, Decl(spreadUnion2.ts, 4, 3), Decl(spreadUnion2.ts, 5, 3)) >undefinedUnion : Symbol(undefinedUnion, Decl(spreadUnion2.ts, 0, 13)) -var o2: {} | { b: number }; +var o2: { b?: number | undefined }; >o2 : Symbol(o2, Decl(spreadUnion2.ts, 7, 3), Decl(spreadUnion2.ts, 8, 3)) ->b : Symbol(b, Decl(spreadUnion2.ts, 7, 14)) +>b : Symbol(b, Decl(spreadUnion2.ts, 7, 9)) var o2 = { ...nullUnion }; >o2 : Symbol(o2, Decl(spreadUnion2.ts, 7, 3), Decl(spreadUnion2.ts, 8, 3)) >nullUnion : Symbol(nullUnion, Decl(spreadUnion2.ts, 1, 13)) -var o3: {} | { b: number } | { a: number } | { a: number, b: number }; +var o3: { a?: number | undefined, b?: number | undefined }; >o3 : Symbol(o3, Decl(spreadUnion2.ts, 10, 3), Decl(spreadUnion2.ts, 11, 3), Decl(spreadUnion2.ts, 12, 3)) ->b : Symbol(b, Decl(spreadUnion2.ts, 10, 14)) ->a : Symbol(a, Decl(spreadUnion2.ts, 10, 30)) ->a : Symbol(a, Decl(spreadUnion2.ts, 10, 46)) ->b : Symbol(b, Decl(spreadUnion2.ts, 10, 57)) +>a : Symbol(a, Decl(spreadUnion2.ts, 10, 9)) +>b : Symbol(b, Decl(spreadUnion2.ts, 10, 33)) var o3 = { ...undefinedUnion, ...nullUnion }; >o3 : Symbol(o3, Decl(spreadUnion2.ts, 10, 3), Decl(spreadUnion2.ts, 11, 3), Decl(spreadUnion2.ts, 12, 3)) @@ -43,18 +41,18 @@ var o3 = { ...nullUnion, ...undefinedUnion }; >nullUnion : Symbol(nullUnion, Decl(spreadUnion2.ts, 1, 13)) >undefinedUnion : Symbol(undefinedUnion, Decl(spreadUnion2.ts, 0, 13)) -var o4: {} | { a: number }; +var o4: { a?: number | undefined }; >o4 : Symbol(o4, Decl(spreadUnion2.ts, 14, 3), Decl(spreadUnion2.ts, 15, 3)) ->a : Symbol(a, Decl(spreadUnion2.ts, 14, 14)) +>a : Symbol(a, Decl(spreadUnion2.ts, 14, 9)) var o4 = { ...undefinedUnion, ...undefinedUnion }; >o4 : Symbol(o4, Decl(spreadUnion2.ts, 14, 3), Decl(spreadUnion2.ts, 15, 3)) >undefinedUnion : Symbol(undefinedUnion, Decl(spreadUnion2.ts, 0, 13)) >undefinedUnion : Symbol(undefinedUnion, Decl(spreadUnion2.ts, 0, 13)) -var o5: {} | { b: number }; +var o5: { b?: number | undefined }; >o5 : Symbol(o5, Decl(spreadUnion2.ts, 17, 3), Decl(spreadUnion2.ts, 18, 3)) ->b : Symbol(b, Decl(spreadUnion2.ts, 17, 14)) +>b : Symbol(b, Decl(spreadUnion2.ts, 17, 9)) var o5 = { ...nullUnion, ...nullUnion }; >o5 : Symbol(o5, Decl(spreadUnion2.ts, 17, 3), Decl(spreadUnion2.ts, 18, 3)) diff --git a/tests/baselines/reference/spreadUnion2.types b/tests/baselines/reference/spreadUnion2.types index ea3364f296b..50f79cc7745 100644 --- a/tests/baselines/reference/spreadUnion2.types +++ b/tests/baselines/reference/spreadUnion2.types @@ -12,71 +12,69 @@ declare const nullAndUndefinedUnion: null | undefined; >nullAndUndefinedUnion : null | undefined >null : null -var o1: {} | { a: number }; ->o1 : {} | { a: number; } ->a : number +var o1: { a?: number | undefined }; +>o1 : { a?: number | undefined; } +>a : number | undefined var o1 = { ...undefinedUnion }; ->o1 : {} | { a: number; } ->{ ...undefinedUnion } : {} | { a: number; } +>o1 : { a?: number | undefined; } +>{ ...undefinedUnion } : { a?: number | undefined; } >undefinedUnion : { a: number; } | undefined -var o2: {} | { b: number }; ->o2 : {} | { b: number; } ->b : number +var o2: { b?: number | undefined }; +>o2 : { b?: number | undefined; } +>b : number | undefined var o2 = { ...nullUnion }; ->o2 : {} | { b: number; } ->{ ...nullUnion } : {} | { b: number; } +>o2 : { b?: number | undefined; } +>{ ...nullUnion } : { b?: number | undefined; } >nullUnion : { b: number; } | null -var o3: {} | { b: number } | { a: number } | { a: number, b: number }; ->o3 : {} | { b: number; } | { a: number; } | { a: number; b: number; } ->b : number ->a : number ->a : number ->b : number +var o3: { a?: number | undefined, b?: number | undefined }; +>o3 : { a?: number | undefined; b?: number | undefined; } +>a : number | undefined +>b : number | undefined var o3 = { ...undefinedUnion, ...nullUnion }; ->o3 : {} | { b: number; } | { a: number; } | { a: number; b: number; } ->{ ...undefinedUnion, ...nullUnion } : {} | { b: number; } | { a: number; } | { b: number; a: number; } +>o3 : { a?: number | undefined; b?: number | undefined; } +>{ ...undefinedUnion, ...nullUnion } : { b?: number | undefined; a?: number | undefined; } >undefinedUnion : { a: number; } | undefined >nullUnion : { b: number; } | null var o3 = { ...nullUnion, ...undefinedUnion }; ->o3 : {} | { b: number; } | { a: number; } | { a: number; b: number; } ->{ ...nullUnion, ...undefinedUnion } : {} | { a: number; } | { b: number; } | { a: number; b: number; } +>o3 : { a?: number | undefined; b?: number | undefined; } +>{ ...nullUnion, ...undefinedUnion } : { a?: number | undefined; b?: number | undefined; } >nullUnion : { b: number; } | null >undefinedUnion : { a: number; } | undefined -var o4: {} | { a: number }; ->o4 : {} | { a: number; } ->a : number +var o4: { a?: number | undefined }; +>o4 : { a?: number | undefined; } +>a : number | undefined var o4 = { ...undefinedUnion, ...undefinedUnion }; ->o4 : {} | { a: number; } ->{ ...undefinedUnion, ...undefinedUnion } : {} | { a: number; } | { a: number; } | { a: number; } +>o4 : { a?: number | undefined; } +>{ ...undefinedUnion, ...undefinedUnion } : { a?: number | undefined; } >undefinedUnion : { a: number; } | undefined >undefinedUnion : { a: number; } | undefined -var o5: {} | { b: number }; ->o5 : {} | { b: number; } ->b : number +var o5: { b?: number | undefined }; +>o5 : { b?: number | undefined; } +>b : number | undefined var o5 = { ...nullUnion, ...nullUnion }; ->o5 : {} | { b: number; } ->{ ...nullUnion, ...nullUnion } : {} | { b: number; } | { b: number; } | { b: number; } +>o5 : { b?: number | undefined; } +>{ ...nullUnion, ...nullUnion } : { b?: number | undefined; } >nullUnion : { b: number; } | null >nullUnion : { b: number; } | null var o6 = { ...nullAndUndefinedUnion, ...nullAndUndefinedUnion }; ->o6 : {} | {} | {} | {} ->{ ...nullAndUndefinedUnion, ...nullAndUndefinedUnion } : {} | {} | {} | {} +>o6 : {} +>{ ...nullAndUndefinedUnion, ...nullAndUndefinedUnion } : {} >nullAndUndefinedUnion : null | undefined >nullAndUndefinedUnion : null | undefined var o7 = { ...nullAndUndefinedUnion }; ->o7 : {} | {} ->{ ...nullAndUndefinedUnion } : {} | {} +>o7 : {} +>{ ...nullAndUndefinedUnion } : {} >nullAndUndefinedUnion : null | undefined diff --git a/tests/baselines/reference/spreadUnion3.errors.txt b/tests/baselines/reference/spreadUnion3.errors.txt index 5f5b620685c..f3fa2da7597 100644 --- a/tests/baselines/reference/spreadUnion3.errors.txt +++ b/tests/baselines/reference/spreadUnion3.errors.txt @@ -1,6 +1,6 @@ -tests/cases/conformance/types/spread/spreadUnion3.ts(2,5): error TS2322: Type '{ y: number; } | { y: string; }' is not assignable to type '{ y: string; }'. - Type '{ y: number; }' is not assignable to type '{ y: string; }'. - Types of property 'y' are incompatible. +tests/cases/conformance/types/spread/spreadUnion3.ts(2,5): error TS2322: Type '{ y: string | number; }' is not assignable to type '{ y: string; }'. + Types of property 'y' are incompatible. + Type 'string | number' is not assignable to type 'string'. Type 'number' is not assignable to type 'string'. tests/cases/conformance/types/spread/spreadUnion3.ts(9,23): error TS2339: Property 'a' does not exist on type '{} | {} | { a: number; }'. Property 'a' does not exist on type '{}'. @@ -10,9 +10,9 @@ tests/cases/conformance/types/spread/spreadUnion3.ts(9,23): error TS2339: Proper function f(x: { y: string } | undefined): { y: string } { return { y: 123, ...x } // y: string | number ~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2322: Type '{ y: number; } | { y: string; }' is not assignable to type '{ y: string; }'. -!!! error TS2322: Type '{ y: number; }' is not assignable to type '{ y: string; }'. -!!! error TS2322: Types of property 'y' are incompatible. +!!! error TS2322: Type '{ y: string | number; }' is not assignable to type '{ y: string; }'. +!!! error TS2322: Types of property 'y' are incompatible. +!!! error TS2322: Type 'string | number' is not assignable to type 'string'. !!! error TS2322: Type 'number' is not assignable to type 'string'. } f(undefined) diff --git a/tests/cases/conformance/types/spread/spreadUnion2.ts b/tests/cases/conformance/types/spread/spreadUnion2.ts index e2f72879915..17abdd4006a 100644 --- a/tests/cases/conformance/types/spread/spreadUnion2.ts +++ b/tests/cases/conformance/types/spread/spreadUnion2.ts @@ -4,20 +4,20 @@ declare const undefinedUnion: { a: number } | undefined; declare const nullUnion: { b: number } | null; declare const nullAndUndefinedUnion: null | undefined; -var o1: {} | { a: number }; +var o1: { a?: number | undefined }; var o1 = { ...undefinedUnion }; -var o2: {} | { b: number }; +var o2: { b?: number | undefined }; var o2 = { ...nullUnion }; -var o3: {} | { b: number } | { a: number } | { a: number, b: number }; +var o3: { a?: number | undefined, b?: number | undefined }; var o3 = { ...undefinedUnion, ...nullUnion }; var o3 = { ...nullUnion, ...undefinedUnion }; -var o4: {} | { a: number }; +var o4: { a?: number | undefined }; var o4 = { ...undefinedUnion, ...undefinedUnion }; -var o5: {} | { b: number }; +var o5: { b?: number | undefined }; var o5 = { ...nullUnion, ...nullUnion }; var o6 = { ...nullAndUndefinedUnion, ...nullAndUndefinedUnion }; From e91af7d30dcc44942ef2afbb2483d28532c2c5b3 Mon Sep 17 00:00:00 2001 From: Andy Date: Thu, 14 Sep 2017 11:19:54 -0700 Subject: [PATCH 334/370] Allow template string with no substitutions to be used as a string literal type (#18452) --- src/compiler/factory.ts | 4 ++-- src/compiler/parser.ts | 14 ++++---------- src/compiler/types.ts | 2 +- .../noSubstitutionTemplateStringLiteralTypes.js | 6 ++++++ ...oSubstitutionTemplateStringLiteralTypes.symbols | 4 ++++ .../noSubstitutionTemplateStringLiteralTypes.types | 6 ++++++ .../noSubstitutionTemplateStringLiteralTypes.ts | 1 + 7 files changed, 24 insertions(+), 13 deletions(-) create mode 100644 tests/baselines/reference/noSubstitutionTemplateStringLiteralTypes.js create mode 100644 tests/baselines/reference/noSubstitutionTemplateStringLiteralTypes.symbols create mode 100644 tests/baselines/reference/noSubstitutionTemplateStringLiteralTypes.types create mode 100644 tests/cases/compiler/noSubstitutionTemplateStringLiteralTypes.ts diff --git a/src/compiler/factory.ts b/src/compiler/factory.ts index 0369be30076..7252a9f0c1d 100644 --- a/src/compiler/factory.ts +++ b/src/compiler/factory.ts @@ -773,13 +773,13 @@ namespace ts { : node; } - export function createLiteralTypeNode(literal: Expression) { + export function createLiteralTypeNode(literal: LiteralTypeNode["literal"]) { const node = createSynthesizedNode(SyntaxKind.LiteralType) as LiteralTypeNode; node.literal = literal; return node; } - export function updateLiteralTypeNode(node: LiteralTypeNode, literal: Expression) { + export function updateLiteralTypeNode(node: LiteralTypeNode, literal: LiteralTypeNode["literal"]) { return node.literal !== literal ? updateNode(createLiteralTypeNode(literal), node) : node; diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index 63f1696832b..275e83cfac2 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -2621,16 +2621,9 @@ namespace ts { unaryMinusExpression.operator = SyntaxKind.MinusToken; nextToken(); } - let expression: UnaryExpression; - switch (token()) { - case SyntaxKind.StringLiteral: - case SyntaxKind.NumericLiteral: - expression = parseLiteralLikeNode(token()) as LiteralExpression; - break; - case SyntaxKind.TrueKeyword: - case SyntaxKind.FalseKeyword: - expression = parseTokenNode(); - } + let expression: BooleanLiteral | LiteralExpression | PrefixUnaryExpression = token() === SyntaxKind.TrueKeyword || token() === SyntaxKind.FalseKeyword + ? parseTokenNode() + : parseLiteralLikeNode(token()) as LiteralExpression; if (negative) { unaryMinusExpression.operand = expression; finishNode(unaryMinusExpression); @@ -2666,6 +2659,7 @@ namespace ts { return parseJSDocNodeWithType(SyntaxKind.JSDocVariadicType); case SyntaxKind.ExclamationToken: return parseJSDocNodeWithType(SyntaxKind.JSDocNonNullableType); + case SyntaxKind.NoSubstitutionTemplateLiteral: case SyntaxKind.StringLiteral: case SyntaxKind.NumericLiteral: case SyntaxKind.TrueKeyword: diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 7c073b45dfb..64cd32e0a0b 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -1049,7 +1049,7 @@ namespace ts { export interface LiteralTypeNode extends TypeNode { kind: SyntaxKind.LiteralType; - literal: Expression; + literal: BooleanLiteral | LiteralExpression | PrefixUnaryExpression; } export interface StringLiteral extends LiteralExpression { diff --git a/tests/baselines/reference/noSubstitutionTemplateStringLiteralTypes.js b/tests/baselines/reference/noSubstitutionTemplateStringLiteralTypes.js new file mode 100644 index 00000000000..0c702a113b1 --- /dev/null +++ b/tests/baselines/reference/noSubstitutionTemplateStringLiteralTypes.js @@ -0,0 +1,6 @@ +//// [noSubstitutionTemplateStringLiteralTypes.ts] +const x: `foo` = "foo"; + + +//// [noSubstitutionTemplateStringLiteralTypes.js] +var x = "foo"; diff --git a/tests/baselines/reference/noSubstitutionTemplateStringLiteralTypes.symbols b/tests/baselines/reference/noSubstitutionTemplateStringLiteralTypes.symbols new file mode 100644 index 00000000000..c5ee4025663 --- /dev/null +++ b/tests/baselines/reference/noSubstitutionTemplateStringLiteralTypes.symbols @@ -0,0 +1,4 @@ +=== tests/cases/compiler/noSubstitutionTemplateStringLiteralTypes.ts === +const x: `foo` = "foo"; +>x : Symbol(x, Decl(noSubstitutionTemplateStringLiteralTypes.ts, 0, 5)) + diff --git a/tests/baselines/reference/noSubstitutionTemplateStringLiteralTypes.types b/tests/baselines/reference/noSubstitutionTemplateStringLiteralTypes.types new file mode 100644 index 00000000000..2274e703ddc --- /dev/null +++ b/tests/baselines/reference/noSubstitutionTemplateStringLiteralTypes.types @@ -0,0 +1,6 @@ +=== tests/cases/compiler/noSubstitutionTemplateStringLiteralTypes.ts === +const x: `foo` = "foo"; +>x : "foo" +>`foo` : "foo" +>"foo" : "foo" + diff --git a/tests/cases/compiler/noSubstitutionTemplateStringLiteralTypes.ts b/tests/cases/compiler/noSubstitutionTemplateStringLiteralTypes.ts new file mode 100644 index 00000000000..994262c5b10 --- /dev/null +++ b/tests/cases/compiler/noSubstitutionTemplateStringLiteralTypes.ts @@ -0,0 +1 @@ +const x: `foo` = "foo"; From 3062c6309b58ccaad26df200f30f55dfe0cbb11e Mon Sep 17 00:00:00 2001 From: Andy Date: Thu, 14 Sep 2017 12:36:29 -0700 Subject: [PATCH 335/370] Simplify some code in `getSymbolAtLocation` (#18470) --- src/compiler/checker.ts | 16 +++--- src/compiler/utilities.ts | 103 ++++++++++++++++++++------------------ 2 files changed, 62 insertions(+), 57 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 1957ebf23bb..7835a5e3e72 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -7996,7 +7996,7 @@ namespace ts { return unknownType; } - function getTypeFromThisTypeNode(node: TypeNode): Type { + function getTypeFromThisTypeNode(node: ThisExpression | ThisTypeNode): Type { const links = getNodeLinks(node); if (!links.resolvedType) { links.resolvedType = getThisType(node); @@ -8030,7 +8030,7 @@ namespace ts { return node.flags & NodeFlags.JavaScriptFile ? anyType : nonPrimitiveType; case SyntaxKind.ThisType: case SyntaxKind.ThisKeyword: - return getTypeFromThisTypeNode(node); + return getTypeFromThisTypeNode(node as ThisExpression | ThisTypeNode); case SyntaxKind.LiteralType: return getTypeFromLiteralTypeNode(node); case SyntaxKind.TypeReference: @@ -23065,14 +23065,16 @@ namespace ts { return sig.thisParameter; } } + if (isInExpressionContext(node)) { + return checkExpression(node as Expression).symbol; + } // falls through - case SyntaxKind.SuperKeyword: - const type = isPartOfExpression(node) ? getTypeOfExpression(node) : getTypeFromTypeNode(node); - return type.symbol; - case SyntaxKind.ThisType: - return getTypeFromTypeNode(node).symbol; + return getTypeFromThisTypeNode(node as ThisExpression | ThisTypeNode).symbol; + + case SyntaxKind.SuperKeyword: + return checkExpression(node as Expression).symbol; case SyntaxKind.ConstructorKeyword: // constructor keyword for an overload, should take us to the definition if it exist diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index 64d5bcaac62..47cf2038f03 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -1253,57 +1253,60 @@ namespace ts { case SyntaxKind.NumericLiteral: case SyntaxKind.StringLiteral: case SyntaxKind.ThisKeyword: - const parent = node.parent; - switch (parent.kind) { - case SyntaxKind.VariableDeclaration: - case SyntaxKind.Parameter: - case SyntaxKind.PropertyDeclaration: - case SyntaxKind.PropertySignature: - case SyntaxKind.EnumMember: - case SyntaxKind.PropertyAssignment: - case SyntaxKind.BindingElement: - return (parent).initializer === node; - case SyntaxKind.ExpressionStatement: - case SyntaxKind.IfStatement: - case SyntaxKind.DoStatement: - case SyntaxKind.WhileStatement: - case SyntaxKind.ReturnStatement: - case SyntaxKind.WithStatement: - case SyntaxKind.SwitchStatement: - case SyntaxKind.CaseClause: - case SyntaxKind.ThrowStatement: - return (parent).expression === node; - case SyntaxKind.ForStatement: - const forStatement = parent; - return (forStatement.initializer === node && forStatement.initializer.kind !== SyntaxKind.VariableDeclarationList) || - forStatement.condition === node || - forStatement.incrementor === node; - case SyntaxKind.ForInStatement: - case SyntaxKind.ForOfStatement: - const forInStatement = parent; - return (forInStatement.initializer === node && forInStatement.initializer.kind !== SyntaxKind.VariableDeclarationList) || - forInStatement.expression === node; - case SyntaxKind.TypeAssertionExpression: - case SyntaxKind.AsExpression: - return node === (parent).expression; - case SyntaxKind.TemplateSpan: - return node === (parent).expression; - case SyntaxKind.ComputedPropertyName: - return node === (parent).expression; - case SyntaxKind.Decorator: - case SyntaxKind.JsxExpression: - case SyntaxKind.JsxSpreadAttribute: - case SyntaxKind.SpreadAssignment: - return true; - case SyntaxKind.ExpressionWithTypeArguments: - return (parent).expression === node && isExpressionWithTypeArgumentsInClassExtendsClause(parent); - default: - if (isPartOfExpression(parent)) { - return true; - } - } + return isInExpressionContext(node); + default: + return false; + } + } + + export function isInExpressionContext(node: Node): boolean { + const parent = node.parent; + switch (parent.kind) { + case SyntaxKind.VariableDeclaration: + case SyntaxKind.Parameter: + case SyntaxKind.PropertyDeclaration: + case SyntaxKind.PropertySignature: + case SyntaxKind.EnumMember: + case SyntaxKind.PropertyAssignment: + case SyntaxKind.BindingElement: + return (parent).initializer === node; + case SyntaxKind.ExpressionStatement: + case SyntaxKind.IfStatement: + case SyntaxKind.DoStatement: + case SyntaxKind.WhileStatement: + case SyntaxKind.ReturnStatement: + case SyntaxKind.WithStatement: + case SyntaxKind.SwitchStatement: + case SyntaxKind.CaseClause: + case SyntaxKind.ThrowStatement: + return (parent).expression === node; + case SyntaxKind.ForStatement: + const forStatement = parent; + return (forStatement.initializer === node && forStatement.initializer.kind !== SyntaxKind.VariableDeclarationList) || + forStatement.condition === node || + forStatement.incrementor === node; + case SyntaxKind.ForInStatement: + case SyntaxKind.ForOfStatement: + const forInStatement = parent; + return (forInStatement.initializer === node && forInStatement.initializer.kind !== SyntaxKind.VariableDeclarationList) || + forInStatement.expression === node; + case SyntaxKind.TypeAssertionExpression: + case SyntaxKind.AsExpression: + return node === (parent).expression; + case SyntaxKind.TemplateSpan: + return node === (parent).expression; + case SyntaxKind.ComputedPropertyName: + return node === (parent).expression; + case SyntaxKind.Decorator: + case SyntaxKind.JsxExpression: + case SyntaxKind.JsxSpreadAttribute: + case SyntaxKind.SpreadAssignment: + return true; + case SyntaxKind.ExpressionWithTypeArguments: + return (parent).expression === node && isExpressionWithTypeArgumentsInClassExtendsClause(parent); + default: + return isPartOfExpression(parent); } - return false; } export function isExternalModuleImportEqualsDeclaration(node: Node) { From d1e2242ee4e7b3224b1c129868cd0947449186c7 Mon Sep 17 00:00:00 2001 From: Andy Date: Thu, 14 Sep 2017 12:36:55 -0700 Subject: [PATCH 336/370] Allow to access `exports` from inside a commonjs module (#17745) * Allow to access `exports` from inside a commonjs module * Don't contextually type `this` in `exports.f = function() { ... }` * Update test --- src/compiler/checker.ts | 26 ++++++- .../reference/commonjsAccessExports.symbols | 30 ++++++++ .../reference/commonjsAccessExports.types | 39 ++++++++++ ...ileCompilationExternalPackageError.symbols | 1 + ...sFileCompilationExternalPackageError.types | 6 +- .../reference/moduleExportAlias.symbols | 27 +++++++ .../reference/moduleExportAlias.types | 76 +++++++++---------- ...solution_explicitNodeModulesImport.symbols | 1 + ...Resolution_explicitNodeModulesImport.types | 6 +- .../typeFromParamTagForFunction.symbols | 2 + .../typeFromParamTagForFunction.types | 12 +-- .../untypedModuleImport_allowJs.symbols | 1 + .../untypedModuleImport_allowJs.types | 6 +- tests/cases/compiler/commonjsAccessExports.ts | 18 +++++ 14 files changed, 194 insertions(+), 57 deletions(-) create mode 100644 tests/baselines/reference/commonjsAccessExports.symbols create mode 100644 tests/baselines/reference/commonjsAccessExports.types create mode 100644 tests/cases/compiler/commonjsAccessExports.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 7835a5e3e72..5a8ecc2e83d 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -1125,6 +1125,13 @@ namespace ts { } if (!result) { + if (lastLocation) { + Debug.assert(lastLocation.kind === SyntaxKind.SourceFile); + if ((lastLocation as SourceFile).commonJsModuleIndicator && name === "exports") { + return lastLocation.symbol; + } + } + result = lookup(globals, name, meaning); } @@ -12885,7 +12892,8 @@ namespace ts { } } } - if (noImplicitThis || isInJavaScriptFile(func)) { + const inJs = isInJavaScriptFile(func); + if (noImplicitThis || inJs) { const containingLiteral = getContainingObjectLiteral(func); if (containingLiteral) { // We have an object literal method. Check if the containing object literal has a contextual type @@ -12912,10 +12920,20 @@ namespace ts { } // In an assignment of the form 'obj.xxx = function(...)' or 'obj[xxx] = function(...)', the // contextual type for 'this' is 'obj'. - if (func.parent.kind === SyntaxKind.BinaryExpression && (func.parent).operatorToken.kind === SyntaxKind.EqualsToken) { - const target = (func.parent).left; + const { parent } = func; + if (parent.kind === SyntaxKind.BinaryExpression && (parent).operatorToken.kind === SyntaxKind.EqualsToken) { + const target = (parent).left; if (target.kind === SyntaxKind.PropertyAccessExpression || target.kind === SyntaxKind.ElementAccessExpression) { - return checkExpressionCached((target).expression); + const { expression } = target as PropertyAccessExpression | ElementAccessExpression; + // Don't contextually type `this` as `exports` in `exports.Point = function(x, y) { this.x = x; this.y = y; }` + if (inJs && isIdentifier(expression)) { + const sourceFile = getSourceFileOfNode(parent); + if (sourceFile.commonJsModuleIndicator && getResolvedSymbol(expression) === sourceFile.symbol) { + return undefined; + } + } + + return checkExpressionCached(expression); } } } diff --git a/tests/baselines/reference/commonjsAccessExports.symbols b/tests/baselines/reference/commonjsAccessExports.symbols new file mode 100644 index 00000000000..dce61803408 --- /dev/null +++ b/tests/baselines/reference/commonjsAccessExports.symbols @@ -0,0 +1,30 @@ +=== /a.js === +exports.x = 0; +>exports.x : Symbol(x, Decl(a.js, 0, 0)) +>exports : Symbol(x, Decl(a.js, 0, 0)) +>x : Symbol(x, Decl(a.js, 0, 0)) + +exports.x; +>exports.x : Symbol(x, Decl(a.js, 0, 0)) +>exports : Symbol("/a", Decl(a.js, 0, 0)) +>x : Symbol(x, Decl(a.js, 0, 0)) + +// Works nested +{ + // 'exports' does not provide a contextual type to a function-class + exports.Cls = function() { +>exports.Cls : Symbol(Cls, Decl(a.js, 4, 1)) +>exports : Symbol(Cls, Decl(a.js, 4, 1)) +>Cls : Symbol(Cls, Decl(a.js, 4, 1)) + + this.x = 0; +>x : Symbol((Anonymous function).x, Decl(a.js, 6, 30)) + } +} + +const instance = new exports.Cls(); +>instance : Symbol(instance, Decl(a.js, 11, 5)) +>exports.Cls : Symbol(Cls, Decl(a.js, 4, 1)) +>exports : Symbol("/a", Decl(a.js, 0, 0)) +>Cls : Symbol(Cls, Decl(a.js, 4, 1)) + diff --git a/tests/baselines/reference/commonjsAccessExports.types b/tests/baselines/reference/commonjsAccessExports.types new file mode 100644 index 00000000000..61d57d4b2cc --- /dev/null +++ b/tests/baselines/reference/commonjsAccessExports.types @@ -0,0 +1,39 @@ +=== /a.js === +exports.x = 0; +>exports.x = 0 : 0 +>exports.x : number +>exports : typeof "/a" +>x : number +>0 : 0 + +exports.x; +>exports.x : number +>exports : typeof "/a" +>x : number + +// Works nested +{ + // 'exports' does not provide a contextual type to a function-class + exports.Cls = function() { +>exports.Cls = function() { this.x = 0; } : () => void +>exports.Cls : () => void +>exports : typeof "/a" +>Cls : () => void +>function() { this.x = 0; } : () => void + + this.x = 0; +>this.x = 0 : 0 +>this.x : any +>this : any +>x : any +>0 : 0 + } +} + +const instance = new exports.Cls(); +>instance : { x: number; } +>new exports.Cls() : { x: number; } +>exports.Cls : () => void +>exports : typeof "/a" +>Cls : () => void + diff --git a/tests/baselines/reference/jsFileCompilationExternalPackageError.symbols b/tests/baselines/reference/jsFileCompilationExternalPackageError.symbols index 7663b2fcedf..ed03884c653 100644 --- a/tests/baselines/reference/jsFileCompilationExternalPackageError.symbols +++ b/tests/baselines/reference/jsFileCompilationExternalPackageError.symbols @@ -17,6 +17,7 @@ var a = 10; === tests/cases/compiler/node_modules/c.js === exports.a = 10; +>exports.a : Symbol(a, Decl(c.js, 0, 0)) >exports : Symbol(a, Decl(c.js, 0, 0)) >a : Symbol(a, Decl(c.js, 0, 0)) diff --git a/tests/baselines/reference/jsFileCompilationExternalPackageError.types b/tests/baselines/reference/jsFileCompilationExternalPackageError.types index c41a24fcffd..82418aeeb28 100644 --- a/tests/baselines/reference/jsFileCompilationExternalPackageError.types +++ b/tests/baselines/reference/jsFileCompilationExternalPackageError.types @@ -21,9 +21,9 @@ var a = 10; === tests/cases/compiler/node_modules/c.js === exports.a = 10; >exports.a = 10 : 10 ->exports.a : any ->exports : any ->a : any +>exports.a : number +>exports : typeof "tests/cases/compiler/node_modules/c" +>a : number >10 : 10 c = 10; diff --git a/tests/baselines/reference/moduleExportAlias.symbols b/tests/baselines/reference/moduleExportAlias.symbols index ed480a0033c..9e2e0e554d2 100644 --- a/tests/baselines/reference/moduleExportAlias.symbols +++ b/tests/baselines/reference/moduleExportAlias.symbols @@ -106,11 +106,15 @@ b.func20; === tests/cases/conformance/salsa/b.js === var exportsAlias = exports; >exportsAlias : Symbol(exportsAlias, Decl(b.js, 0, 3)) +>exports : Symbol("tests/cases/conformance/salsa/b", Decl(b.js, 0, 0)) exportsAlias.func1 = function () { }; +>exportsAlias.func1 : Symbol(func1, Decl(b.js, 0, 27)) >exportsAlias : Symbol(exportsAlias, Decl(b.js, 0, 3)) +>func1 : Symbol(func1, Decl(b.js, 0, 27)) exports.func2 = function () { }; +>exports.func2 : Symbol(func2, Decl(b.js, 1, 37)) >exports : Symbol(func2, Decl(b.js, 1, 37)) >func2 : Symbol(func2, Decl(b.js, 1, 37)) @@ -126,15 +130,19 @@ module.exports.func4 = function () { }; var multipleDeclarationAlias1 = exports = module.exports; >multipleDeclarationAlias1 : Symbol(multipleDeclarationAlias1, Decl(b.js, 8, 3)) +>exports : Symbol("tests/cases/conformance/salsa/b", Decl(b.js, 0, 0)) multipleDeclarationAlias1.func5 = function () { }; >multipleDeclarationAlias1 : Symbol(multipleDeclarationAlias1, Decl(b.js, 8, 3)) var multipleDeclarationAlias2 = module.exports = exports; >multipleDeclarationAlias2 : Symbol(multipleDeclarationAlias2, Decl(b.js, 11, 3)) +>exports : Symbol("tests/cases/conformance/salsa/b", Decl(b.js, 0, 0)) multipleDeclarationAlias2.func6 = function () { }; +>multipleDeclarationAlias2.func6 : Symbol(func6, Decl(b.js, 11, 57)) >multipleDeclarationAlias2 : Symbol(multipleDeclarationAlias2, Decl(b.js, 11, 3)) +>func6 : Symbol(func6, Decl(b.js, 11, 57)) var someOtherVariable; >someOtherVariable : Symbol(someOtherVariable, Decl(b.js, 14, 3)) @@ -142,9 +150,12 @@ var someOtherVariable; var multipleDeclarationAlias3 = someOtherVariable = exports; >multipleDeclarationAlias3 : Symbol(multipleDeclarationAlias3, Decl(b.js, 15, 3)) >someOtherVariable : Symbol(someOtherVariable, Decl(b.js, 14, 3)) +>exports : Symbol("tests/cases/conformance/salsa/b", Decl(b.js, 0, 0)) multipleDeclarationAlias3.func7 = function () { }; +>multipleDeclarationAlias3.func7 : Symbol(func7, Decl(b.js, 15, 60)) >multipleDeclarationAlias3 : Symbol(multipleDeclarationAlias3, Decl(b.js, 15, 3)) +>func7 : Symbol(func7, Decl(b.js, 15, 60)) var multipleDeclarationAlias4 = someOtherVariable = module.exports; >multipleDeclarationAlias4 : Symbol(multipleDeclarationAlias4, Decl(b.js, 18, 3)) @@ -155,20 +166,24 @@ multipleDeclarationAlias4.func8 = function () { }; var multipleDeclarationAlias5 = module.exports = exports = {}; >multipleDeclarationAlias5 : Symbol(multipleDeclarationAlias5, Decl(b.js, 21, 3)) +>exports : Symbol("tests/cases/conformance/salsa/b", Decl(b.js, 0, 0)) multipleDeclarationAlias5.func9 = function () { }; >multipleDeclarationAlias5 : Symbol(multipleDeclarationAlias5, Decl(b.js, 21, 3)) var multipleDeclarationAlias6 = exports = module.exports = {}; >multipleDeclarationAlias6 : Symbol(multipleDeclarationAlias6, Decl(b.js, 24, 3)) +>exports : Symbol("tests/cases/conformance/salsa/b", Decl(b.js, 0, 0)) multipleDeclarationAlias6.func10 = function () { }; >multipleDeclarationAlias6 : Symbol(multipleDeclarationAlias6, Decl(b.js, 24, 3)) exports = module.exports = someOtherVariable = {}; +>exports : Symbol("tests/cases/conformance/salsa/b", Decl(b.js, 0, 0)) >someOtherVariable : Symbol(someOtherVariable, Decl(b.js, 14, 3)) exports.func11 = function () { }; +>exports.func11 : Symbol(func11, Decl(b.js, 27, 50), Decl(b.js, 31, 50)) >exports : Symbol(func11, Decl(b.js, 27, 50), Decl(b.js, 31, 50)) >func11 : Symbol(func11, Decl(b.js, 27, 50), Decl(b.js, 31, 50)) @@ -177,9 +192,11 @@ module.exports.func12 = function () { }; >func12 : Symbol(func12, Decl(b.js, 28, 33), Decl(b.js, 32, 33)) exports = module.exports = someOtherVariable = {}; +>exports : Symbol("tests/cases/conformance/salsa/b", Decl(b.js, 0, 0)) >someOtherVariable : Symbol(someOtherVariable, Decl(b.js, 14, 3)) exports.func11 = function () { }; +>exports.func11 : Symbol(func11, Decl(b.js, 27, 50), Decl(b.js, 31, 50)) >exports : Symbol(func11, Decl(b.js, 27, 50), Decl(b.js, 31, 50)) >func11 : Symbol(func11, Decl(b.js, 27, 50), Decl(b.js, 31, 50)) @@ -188,7 +205,10 @@ module.exports.func12 = function () { }; >func12 : Symbol(func12, Decl(b.js, 28, 33), Decl(b.js, 32, 33)) exports = module.exports = {}; +>exports : Symbol("tests/cases/conformance/salsa/b", Decl(b.js, 0, 0)) + exports.func13 = function () { }; +>exports.func13 : Symbol(func13, Decl(b.js, 35, 30)) >exports : Symbol(func13, Decl(b.js, 35, 30)) >func13 : Symbol(func13, Decl(b.js, 35, 30)) @@ -197,7 +217,10 @@ module.exports.func14 = function () { }; >func14 : Symbol(func14, Decl(b.js, 36, 33)) exports = module.exports = {}; +>exports : Symbol("tests/cases/conformance/salsa/b", Decl(b.js, 0, 0)) + exports.func15 = function () { }; +>exports.func15 : Symbol(func15, Decl(b.js, 39, 30)) >exports : Symbol(func15, Decl(b.js, 39, 30)) >func15 : Symbol(func15, Decl(b.js, 39, 30)) @@ -206,7 +229,10 @@ module.exports.func16 = function () { }; >func16 : Symbol(func16, Decl(b.js, 40, 33)) module.exports = exports = {}; +>exports : Symbol("tests/cases/conformance/salsa/b", Decl(b.js, 0, 0)) + exports.func17 = function () { }; +>exports.func17 : Symbol(func17, Decl(b.js, 43, 30)) >exports : Symbol(func17, Decl(b.js, 43, 30)) >func17 : Symbol(func17, Decl(b.js, 43, 30)) @@ -216,6 +242,7 @@ module.exports.func18 = function () { }; module.exports = {}; exports.func19 = function () { }; +>exports.func19 : Symbol(func19, Decl(b.js, 47, 20)) >exports : Symbol(func19, Decl(b.js, 47, 20)) >func19 : Symbol(func19, Decl(b.js, 47, 20)) diff --git a/tests/baselines/reference/moduleExportAlias.types b/tests/baselines/reference/moduleExportAlias.types index ccf8e5d7a24..b1eedf8c2ab 100644 --- a/tests/baselines/reference/moduleExportAlias.types +++ b/tests/baselines/reference/moduleExportAlias.types @@ -105,21 +105,21 @@ b.func20; === tests/cases/conformance/salsa/b.js === var exportsAlias = exports; ->exportsAlias : any ->exports : any +>exportsAlias : typeof "tests/cases/conformance/salsa/b" +>exports : typeof "tests/cases/conformance/salsa/b" exportsAlias.func1 = function () { }; >exportsAlias.func1 = function () { } : () => void ->exportsAlias.func1 : any ->exportsAlias : any ->func1 : any +>exportsAlias.func1 : () => void +>exportsAlias : typeof "tests/cases/conformance/salsa/b" +>func1 : () => void >function () { } : () => void exports.func2 = function () { }; >exports.func2 = function () { } : () => void ->exports.func2 : any ->exports : any ->func2 : any +>exports.func2 : () => void +>exports : typeof "tests/cases/conformance/salsa/b" +>func2 : () => void >function () { } : () => void var moduleExportsAlias = module.exports; @@ -160,34 +160,34 @@ multipleDeclarationAlias1.func5 = function () { }; >function () { } : () => void var multipleDeclarationAlias2 = module.exports = exports; ->multipleDeclarationAlias2 : any ->module.exports = exports : any +>multipleDeclarationAlias2 : typeof "tests/cases/conformance/salsa/b" +>module.exports = exports : typeof "tests/cases/conformance/salsa/b" >module.exports : any >module : any >exports : any ->exports : any +>exports : typeof "tests/cases/conformance/salsa/b" multipleDeclarationAlias2.func6 = function () { }; >multipleDeclarationAlias2.func6 = function () { } : () => void ->multipleDeclarationAlias2.func6 : any ->multipleDeclarationAlias2 : any ->func6 : any +>multipleDeclarationAlias2.func6 : () => void +>multipleDeclarationAlias2 : typeof "tests/cases/conformance/salsa/b" +>func6 : () => void >function () { } : () => void var someOtherVariable; >someOtherVariable : any var multipleDeclarationAlias3 = someOtherVariable = exports; ->multipleDeclarationAlias3 : any ->someOtherVariable = exports : any +>multipleDeclarationAlias3 : typeof "tests/cases/conformance/salsa/b" +>someOtherVariable = exports : typeof "tests/cases/conformance/salsa/b" >someOtherVariable : any ->exports : any +>exports : typeof "tests/cases/conformance/salsa/b" multipleDeclarationAlias3.func7 = function () { }; >multipleDeclarationAlias3.func7 = function () { } : () => void ->multipleDeclarationAlias3.func7 : any ->multipleDeclarationAlias3 : any ->func7 : any +>multipleDeclarationAlias3.func7 : () => void +>multipleDeclarationAlias3 : typeof "tests/cases/conformance/salsa/b" +>func7 : () => void >function () { } : () => void var multipleDeclarationAlias4 = someOtherVariable = module.exports; @@ -252,9 +252,9 @@ exports = module.exports = someOtherVariable = {}; exports.func11 = function () { }; >exports.func11 = function () { } : () => void ->exports.func11 : any ->exports : any ->func11 : any +>exports.func11 : () => void +>exports : typeof "tests/cases/conformance/salsa/b" +>func11 : () => void >function () { } : () => void module.exports.func12 = function () { }; @@ -279,9 +279,9 @@ exports = module.exports = someOtherVariable = {}; exports.func11 = function () { }; >exports.func11 = function () { } : () => void ->exports.func11 : any ->exports : any ->func11 : any +>exports.func11 : () => void +>exports : typeof "tests/cases/conformance/salsa/b" +>func11 : () => void >function () { } : () => void module.exports.func12 = function () { }; @@ -304,9 +304,9 @@ exports = module.exports = {}; exports.func13 = function () { }; >exports.func13 = function () { } : () => void ->exports.func13 : any ->exports : any ->func13 : any +>exports.func13 : () => void +>exports : typeof "tests/cases/conformance/salsa/b" +>func13 : () => void >function () { } : () => void module.exports.func14 = function () { }; @@ -329,9 +329,9 @@ exports = module.exports = {}; exports.func15 = function () { }; >exports.func15 = function () { } : () => void ->exports.func15 : any ->exports : any ->func15 : any +>exports.func15 : () => void +>exports : typeof "tests/cases/conformance/salsa/b" +>func15 : () => void >function () { } : () => void module.exports.func16 = function () { }; @@ -354,9 +354,9 @@ module.exports = exports = {}; exports.func17 = function () { }; >exports.func17 = function () { } : () => void ->exports.func17 : any ->exports : any ->func17 : any +>exports.func17 : () => void +>exports : typeof "tests/cases/conformance/salsa/b" +>func17 : () => void >function () { } : () => void module.exports.func18 = function () { }; @@ -377,9 +377,9 @@ module.exports = {}; exports.func19 = function () { }; >exports.func19 = function () { } : () => void ->exports.func19 : any ->exports : any ->func19 : any +>exports.func19 : () => void +>exports : typeof "tests/cases/conformance/salsa/b" +>func19 : () => void >function () { } : () => void module.exports.func20 = function () { }; diff --git a/tests/baselines/reference/moduleResolution_explicitNodeModulesImport.symbols b/tests/baselines/reference/moduleResolution_explicitNodeModulesImport.symbols index b635ba2c7c7..b091b2d4ab2 100644 --- a/tests/baselines/reference/moduleResolution_explicitNodeModulesImport.symbols +++ b/tests/baselines/reference/moduleResolution_explicitNodeModulesImport.symbols @@ -4,6 +4,7 @@ import { x } from "../node_modules/foo"; === /node_modules/foo/index.js === exports.x = 0; +>exports.x : Symbol(x, Decl(index.js, 0, 0)) >exports : Symbol(x, Decl(index.js, 0, 0)) >x : Symbol(x, Decl(index.js, 0, 0)) diff --git a/tests/baselines/reference/moduleResolution_explicitNodeModulesImport.types b/tests/baselines/reference/moduleResolution_explicitNodeModulesImport.types index ca7541d2140..fe7d74c914c 100644 --- a/tests/baselines/reference/moduleResolution_explicitNodeModulesImport.types +++ b/tests/baselines/reference/moduleResolution_explicitNodeModulesImport.types @@ -5,8 +5,8 @@ import { x } from "../node_modules/foo"; === /node_modules/foo/index.js === exports.x = 0; >exports.x = 0 : 0 ->exports.x : any ->exports : any ->x : any +>exports.x : number +>exports : typeof "/node_modules/foo/index" +>x : number >0 : 0 diff --git a/tests/baselines/reference/typeFromParamTagForFunction.symbols b/tests/baselines/reference/typeFromParamTagForFunction.symbols index 0df0dfdc206..5bacb93cc7a 100644 --- a/tests/baselines/reference/typeFromParamTagForFunction.symbols +++ b/tests/baselines/reference/typeFromParamTagForFunction.symbols @@ -9,6 +9,7 @@ declare var module: any, exports: any; === tests/cases/conformance/salsa/a-ext.js === exports.A = function () { +>exports.A : Symbol(A, Decl(a-ext.js, 0, 0)) >exports : Symbol(A, Decl(a-ext.js, 0, 0)) >A : Symbol(A, Decl(a-ext.js, 0, 0)) @@ -33,6 +34,7 @@ function a(p) { p.x; } === tests/cases/conformance/salsa/b-ext.js === exports.B = class { +>exports.B : Symbol(B, Decl(b-ext.js, 0, 0)) >exports : Symbol(B, Decl(b-ext.js, 0, 0)) >B : Symbol(B, Decl(b-ext.js, 0, 0)) diff --git a/tests/baselines/reference/typeFromParamTagForFunction.types b/tests/baselines/reference/typeFromParamTagForFunction.types index c1e16ddb33d..98bd1682455 100644 --- a/tests/baselines/reference/typeFromParamTagForFunction.types +++ b/tests/baselines/reference/typeFromParamTagForFunction.types @@ -10,9 +10,9 @@ declare var module: any, exports: any; === tests/cases/conformance/salsa/a-ext.js === exports.A = function () { >exports.A = function () { this.x = 1;} : () => void ->exports.A : any ->exports : any ->A : any +>exports.A : () => void +>exports : typeof "tests/cases/conformance/salsa/a-ext" +>A : () => void >function () { this.x = 1;} : () => void this.x = 1; @@ -42,9 +42,9 @@ function a(p) { p.x; } === tests/cases/conformance/salsa/b-ext.js === exports.B = class { >exports.B = class { constructor() { this.x = 1; }} : typeof (Anonymous class) ->exports.B : any ->exports : any ->B : any +>exports.B : typeof (Anonymous class) +>exports : typeof "tests/cases/conformance/salsa/b-ext" +>B : typeof (Anonymous class) >class { constructor() { this.x = 1; }} : typeof (Anonymous class) constructor() { diff --git a/tests/baselines/reference/untypedModuleImport_allowJs.symbols b/tests/baselines/reference/untypedModuleImport_allowJs.symbols index d660e811630..1076590e009 100644 --- a/tests/baselines/reference/untypedModuleImport_allowJs.symbols +++ b/tests/baselines/reference/untypedModuleImport_allowJs.symbols @@ -11,6 +11,7 @@ foo.bar(); // Same as untypedModuleImport.ts but with --allowJs, so the package will actually be typed. exports.default = { bar() { return 0; } } +>exports.default : Symbol(default, Decl(index.js, 0, 0)) >exports : Symbol(default, Decl(index.js, 0, 0)) >default : Symbol(default, Decl(index.js, 0, 0)) >bar : Symbol(bar, Decl(index.js, 2, 19)) diff --git a/tests/baselines/reference/untypedModuleImport_allowJs.types b/tests/baselines/reference/untypedModuleImport_allowJs.types index 108ba60ccb3..2a854ce9d23 100644 --- a/tests/baselines/reference/untypedModuleImport_allowJs.types +++ b/tests/baselines/reference/untypedModuleImport_allowJs.types @@ -13,9 +13,9 @@ foo.bar(); exports.default = { bar() { return 0; } } >exports.default = { bar() { return 0; } } : { [x: string]: any; bar(): number; } ->exports.default : any ->exports : any ->default : any +>exports.default : { [x: string]: any; bar(): number; } +>exports : typeof "/node_modules/foo/index" +>default : { [x: string]: any; bar(): number; } >{ bar() { return 0; } } : { [x: string]: any; bar(): number; } >bar : () => number >0 : 0 diff --git a/tests/cases/compiler/commonjsAccessExports.ts b/tests/cases/compiler/commonjsAccessExports.ts new file mode 100644 index 00000000000..961be3f5a23 --- /dev/null +++ b/tests/cases/compiler/commonjsAccessExports.ts @@ -0,0 +1,18 @@ +// @module: commonjs +// @allowJs: true +// @checkJs: true +// @noEmit: true + +// @Filename: /a.js +exports.x = 0; +exports.x; + +// Works nested +{ + // 'exports' does not provide a contextual type to a function-class + exports.Cls = function() { + this.x = 0; + } +} + +const instance = new exports.Cls(); From 89eb06e47534a962902928161836ed959ed9d3b1 Mon Sep 17 00:00:00 2001 From: Andy Date: Thu, 14 Sep 2017 12:37:38 -0700 Subject: [PATCH 337/370] For completions of union, exclude types with methods (#18124) For completions of union, exclude arrays --- src/compiler/checker.ts | 29 +++++++++---------- src/compiler/types.ts | 3 +- src/services/completions.ts | 18 +++++++++++- .../cases/fourslash/completionListOfUnion.ts | 2 +- tests/cases/fourslash/completionsUnion.ts | 8 +++++ 5 files changed, 41 insertions(+), 19 deletions(-) create mode 100644 tests/cases/fourslash/completionsUnion.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 5a8ecc2e83d..25fff43bab7 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -225,7 +225,8 @@ namespace ts { return tryFindAmbientModule(moduleName, /*withAugmentations*/ false); }, getApparentType, - getAllPossiblePropertiesOfType, + isArrayLikeType, + getAllPossiblePropertiesOfTypes, getSuggestionForNonexistentProperty: (node, type) => unescapeLeadingUnderscores(getSuggestionForNonexistentProperty(node, type)), getSuggestionForNonexistentSymbol: (location, name, meaning) => unescapeLeadingUnderscores(getSuggestionForNonexistentSymbol(location, escapeLeadingUnderscores(name), meaning)), getBaseConstraintOfType, @@ -5925,25 +5926,21 @@ namespace ts { getPropertiesOfObjectType(type); } - function getAllPossiblePropertiesOfType(type: Type): Symbol[] { - if (type.flags & TypeFlags.Union) { - const props = createSymbolTable(); - for (const memberType of (type as UnionType).types) { - if (memberType.flags & TypeFlags.Primitive) { - continue; - } + function getAllPossiblePropertiesOfTypes(types: Type[]): Symbol[] { + const unionType = getUnionType(types); + if (!(unionType.flags & TypeFlags.Union)) { + return getPropertiesOfType(unionType); + } - for (const { escapedName } of getPropertiesOfType(memberType)) { - if (!props.has(escapedName)) { - props.set(escapedName, createUnionOrIntersectionProperty(type as UnionType, escapedName)); - } + const props = createSymbolTable(); + for (const memberType of types) { + for (const { escapedName } of getPropertiesOfType(memberType)) { + if (!props.has(escapedName)) { + props.set(escapedName, createUnionOrIntersectionProperty(unionType as UnionType, escapedName)); } } - return arrayFrom(props.values()); - } - else { - return getPropertiesOfType(type); } + return arrayFrom(props.values()); } function getConstraintOfType(type: TypeVariable | UnionOrIntersectionType): Type { diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 64cd32e0a0b..66a31864f56 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -2703,7 +2703,8 @@ namespace ts { * So for `{ a } | { b }`, this will include both `a` and `b`. * Does not include properties of primitive types. */ - /* @internal */ getAllPossiblePropertiesOfType(type: Type): Symbol[]; + /* @internal */ isArrayLikeType(type: Type): boolean; + /* @internal */ getAllPossiblePropertiesOfTypes(type: ReadonlyArray): Symbol[]; /* @internal */ resolveName(name: string, location: Node, meaning: SymbolFlags): Symbol | undefined; /* @internal */ getJsxNamespace(): string; } diff --git a/src/services/completions.ts b/src/services/completions.ts index 15a20798508..e271ef12104 100644 --- a/src/services/completions.ts +++ b/src/services/completions.ts @@ -978,7 +978,7 @@ namespace ts.Completions { isNewIdentifierLocation = true; const typeForObject = typeChecker.getContextualType(objectLikeContainer); if (!typeForObject) return false; - typeMembers = typeChecker.getAllPossiblePropertiesOfType(typeForObject); + typeMembers = getPropertiesForCompletion(typeForObject, typeChecker); existingMembers = (objectLikeContainer).properties; } else { @@ -1766,4 +1766,20 @@ namespace ts.Completions { return node.parent; } } + + /** + * Gets all properties on a type, but if that type is a union of several types, + * tries to only include those types which declare properties, not methods. + * This ensures that we don't try providing completions for all the methods on e.g. Array. + */ + function getPropertiesForCompletion(type: Type, checker: TypeChecker): Symbol[] { + if (!(type.flags & TypeFlags.Union)) { + return checker.getPropertiesOfType(type); + } + + const { types } = type as UnionType; + const filteredTypes = types.filter(memberType => !(memberType.flags & TypeFlags.Primitive || checker.isArrayLikeType(memberType))); + // If there are no property-only types, just provide completions for every type as usual. + return checker.getAllPossiblePropertiesOfTypes(filteredTypes); + } } diff --git a/tests/cases/fourslash/completionListOfUnion.ts b/tests/cases/fourslash/completionListOfUnion.ts index 5ffaf89e5b3..c323c83d054 100644 --- a/tests/cases/fourslash/completionListOfUnion.ts +++ b/tests/cases/fourslash/completionListOfUnion.ts @@ -16,5 +16,5 @@ verify.completionListContains("b", "(property) b: number | boolean"); verify.completionListContains("c", "(property) c: string"); goTo.marker("f"); -verify.completionListContains("a", "(property) a: number"); +verify.completionListContains("a", "(property) I.a: number"); // Also contains array members diff --git a/tests/cases/fourslash/completionsUnion.ts b/tests/cases/fourslash/completionsUnion.ts new file mode 100644 index 00000000000..ed449936680 --- /dev/null +++ b/tests/cases/fourslash/completionsUnion.ts @@ -0,0 +1,8 @@ +/// + +////interface I { x: number; } +////interface Many extends ReadonlyArray { extra: number; } +////const x: I | I[] | Many = { /**/ }; + +// We specifically filter out any array-like types. +verify.completionsAt("", ["x"]); From 8dc66e4665e6aa7c3c822e066bb1c59e72fa7591 Mon Sep 17 00:00:00 2001 From: Andy Date: Thu, 14 Sep 2017 12:38:17 -0700 Subject: [PATCH 338/370] Cleanup navTo (#18150) --- src/services/navigateTo.ts | 286 ++++++++++++++++----------------- src/services/patternMatcher.ts | 4 +- 2 files changed, 144 insertions(+), 146 deletions(-) diff --git a/src/services/navigateTo.ts b/src/services/navigateTo.ts index ec7b011456f..7fa177b6a30 100644 --- a/src/services/navigateTo.ts +++ b/src/services/navigateTo.ts @@ -21,185 +21,183 @@ namespace ts.NavigateTo { } forEachEntry(sourceFile.getNamedDeclarations(), (declarations, name) => { - if (declarations) { - // First do a quick check to see if the name of the declaration matches the - // last portion of the (possibly) dotted name they're searching for. - let matches = patternMatcher.getMatchesForLastSegmentOfPattern(name); - - if (!matches) { - return; // continue to next named declarations - } - - for (const declaration of declarations) { - // It was a match! If the pattern has dots in it, then also see if the - // declaration container matches as well. - if (patternMatcher.patternContainsDots) { - const containers = getContainers(declaration); - if (!containers) { - return true; // Break out of named declarations and go to the next source file. - } - - matches = patternMatcher.getMatches(containers, name); - - if (!matches) { - return; // continue to next named declarations - } - } - - const fileName = sourceFile.fileName; - const matchKind = bestMatchKind(matches); - rawItems.push({ name, fileName, matchKind, isCaseSensitive: allMatchesAreCaseSensitive(matches), declaration }); - } - } + getItemsFromNamedDeclaration(patternMatcher, name, declarations, checker, sourceFile.fileName, rawItems); }); } - // Remove imports when the imported declaration is already in the list and has the same name. - rawItems = filter(rawItems, item => { - const decl = item.declaration; - if (decl.kind === SyntaxKind.ImportClause || decl.kind === SyntaxKind.ImportSpecifier || decl.kind === SyntaxKind.ImportEqualsDeclaration) { - const importer = checker.getSymbolAtLocation((decl as NamedDeclaration).name); - const imported = checker.getAliasedSymbol(importer); - return importer.escapedName !== imported.escapedName; - } - else { - return true; - } - }); - rawItems.sort(compareNavigateToItems); if (maxResultCount !== undefined) { rawItems = rawItems.slice(0, maxResultCount); } + return rawItems.map(createNavigateToItem); + } - const items = map(rawItems, createNavigateToItem); + function getItemsFromNamedDeclaration(patternMatcher: PatternMatcher, name: string, declarations: ReadonlyArray, checker: TypeChecker, fileName: string, rawItems: Push): void { + // First do a quick check to see if the name of the declaration matches the + // last portion of the (possibly) dotted name they're searching for. + const matches = patternMatcher.getMatchesForLastSegmentOfPattern(name); - return items; + if (!matches) { + return; // continue to next named declarations + } - function allMatchesAreCaseSensitive(matches: PatternMatch[]): boolean { - Debug.assert(matches.length > 0); + for (const declaration of declarations) { + if (!shouldKeepItem(declaration, checker)) { + continue; + } - // This is a case sensitive match, only if all the submatches were case sensitive. - for (const match of matches) { - if (!match.isCaseSensitive) { + // It was a match! If the pattern has dots in it, then also see if the + // declaration container matches as well. + let containerMatches = matches; + if (patternMatcher.patternContainsDots) { + containerMatches = patternMatcher.getMatches(getContainers(declaration), name); + if (!containerMatches) { + continue; + } + } + + const matchKind = bestMatchKind(containerMatches); + const isCaseSensitive = allMatchesAreCaseSensitive(containerMatches); + rawItems.push({ name, fileName, matchKind, isCaseSensitive, declaration }); + } + } + + function shouldKeepItem(declaration: Declaration, checker: ts.TypeChecker): boolean { + switch (declaration.kind) { + case SyntaxKind.ImportClause: + case SyntaxKind.ImportSpecifier: + case SyntaxKind.ImportEqualsDeclaration: + const importer = checker.getSymbolAtLocation((declaration as ImportClause | ImportSpecifier | ImportEqualsDeclaration).name); + const imported = checker.getAliasedSymbol(importer); + return importer.escapedName !== imported.escapedName; + default: + return true; + } + } + + function allMatchesAreCaseSensitive(matches: ReadonlyArray): boolean { + Debug.assert(matches.length > 0); + + // This is a case sensitive match, only if all the submatches were case sensitive. + for (const match of matches) { + if (!match.isCaseSensitive) { + return false; + } + } + + return true; + } + + function tryAddSingleDeclarationName(declaration: Declaration, containers: string[]): boolean { + if (declaration) { + const name = getNameOfDeclaration(declaration); + if (name) { + const text = getTextOfIdentifierOrLiteral(name as (Identifier | LiteralExpression)); + if (text !== undefined) { + containers.unshift(text); + } + else if (name.kind === SyntaxKind.ComputedPropertyName) { + return tryAddComputedPropertyName((name).expression, containers, /*includeLastPortion*/ true); + } + else { + // Don't know how to add this. return false; } } + } + return true; + } + + // Only added the names of computed properties if they're simple dotted expressions, like: + // + // [X.Y.Z]() { } + function tryAddComputedPropertyName(expression: Expression, containers: string[], includeLastPortion: boolean): boolean { + const text = getTextOfIdentifierOrLiteral(expression as LiteralExpression); + if (text !== undefined) { + if (includeLastPortion) { + containers.unshift(text); + } return true; } - function tryAddSingleDeclarationName(declaration: Declaration, containers: string[]) { - if (declaration) { - const name = getNameOfDeclaration(declaration); - if (name) { - const text = getTextOfIdentifierOrLiteral(name as (Identifier | LiteralExpression)); - if (text !== undefined) { - containers.unshift(text); - } - else if (name.kind === SyntaxKind.ComputedPropertyName) { - return tryAddComputedPropertyName((name).expression, containers, /*includeLastPortion*/ true); - } - else { - // Don't know how to add this. - return false; - } - } + if (expression.kind === SyntaxKind.PropertyAccessExpression) { + const propertyAccess = expression; + if (includeLastPortion) { + containers.unshift(propertyAccess.name.text); } - return true; + return tryAddComputedPropertyName(propertyAccess.expression, containers, /*includeLastPortion*/ true); } - // Only added the names of computed properties if they're simple dotted expressions, like: - // - // [X.Y.Z]() { } - function tryAddComputedPropertyName(expression: Expression, containers: string[], includeLastPortion: boolean): boolean { - const text = getTextOfIdentifierOrLiteral(expression as LiteralExpression); - if (text !== undefined) { - if (includeLastPortion) { - containers.unshift(text); - } - return true; + return false; + } + + function getContainers(declaration: Declaration): string[] { + const containers: string[] = []; + + // First, if we started with a computed property name, then add all but the last + // portion into the container array. + const name = getNameOfDeclaration(declaration); + if (name.kind === SyntaxKind.ComputedPropertyName) { + if (!tryAddComputedPropertyName((name).expression, containers, /*includeLastPortion*/ false)) { + return undefined; } - - if (expression.kind === SyntaxKind.PropertyAccessExpression) { - const propertyAccess = expression; - if (includeLastPortion) { - containers.unshift(propertyAccess.name.text); - } - - return tryAddComputedPropertyName(propertyAccess.expression, containers, /*includeLastPortion*/ true); - } - - return false; } - function getContainers(declaration: Declaration) { - const containers: string[] = []; + // Now, walk up our containers, adding all their names to the container array. + declaration = getContainerNode(declaration); - // First, if we started with a computed property name, then add all but the last - // portion into the container array. - const name = getNameOfDeclaration(declaration); - if (name.kind === SyntaxKind.ComputedPropertyName) { - if (!tryAddComputedPropertyName((name).expression, containers, /*includeLastPortion*/ false)) { - return undefined; - } + while (declaration) { + if (!tryAddSingleDeclarationName(declaration, containers)) { + return undefined; } - // Now, walk up our containers, adding all their names to the container array. declaration = getContainerNode(declaration); + } - while (declaration) { - if (!tryAddSingleDeclarationName(declaration, containers)) { - return undefined; - } + return containers; + } - declaration = getContainerNode(declaration); + function bestMatchKind(matches: ReadonlyArray): PatternMatchKind { + Debug.assert(matches.length > 0); + let bestMatchKind = PatternMatchKind.camelCase; + + for (const match of matches) { + const kind = match.kind; + if (kind < bestMatchKind) { + bestMatchKind = kind; } - - return containers; } - function bestMatchKind(matches: PatternMatch[]) { - Debug.assert(matches.length > 0); - let bestMatchKind = PatternMatchKind.camelCase; + return bestMatchKind; + } - for (const match of matches) { - const kind = match.kind; - if (kind < bestMatchKind) { - bestMatchKind = kind; - } - } + function compareNavigateToItems(i1: RawNavigateToItem, i2: RawNavigateToItem): number { + // TODO(cyrusn): get the gamut of comparisons that VS already uses here. + // Right now we just sort by kind first, and then by name of the item. + // We first sort case insensitively. So "Aaa" will come before "bar". + // Then we sort case sensitively, so "aaa" will come before "Aaa". + return i1.matchKind - i2.matchKind || + ts.compareStringsCaseInsensitive(i1.name, i2.name) || + ts.compareStrings(i1.name, i2.name); + } - return bestMatchKind; - } - - function compareNavigateToItems(i1: RawNavigateToItem, i2: RawNavigateToItem) { - // TODO(cyrusn): get the gamut of comparisons that VS already uses here. - // Right now we just sort by kind first, and then by name of the item. - // We first sort case insensitively. So "Aaa" will come before "bar". - // Then we sort case sensitively, so "aaa" will come before "Aaa". - return i1.matchKind - i2.matchKind || - ts.compareStringsCaseInsensitive(i1.name, i2.name) || - ts.compareStrings(i1.name, i2.name); - } - - function createNavigateToItem(rawItem: RawNavigateToItem): NavigateToItem { - const declaration = rawItem.declaration; - const container = getContainerNode(declaration); - const containerName = container && getNameOfDeclaration(container); - return { - name: rawItem.name, - kind: getNodeKind(declaration), - kindModifiers: getNodeModifiers(declaration), - matchKind: PatternMatchKind[rawItem.matchKind], - isCaseSensitive: rawItem.isCaseSensitive, - fileName: rawItem.fileName, - textSpan: createTextSpanFromNode(declaration), - // TODO(jfreeman): What should be the containerName when the container has a computed name? - containerName: containerName ? (containerName).text : "", - containerKind: containerName ? getNodeKind(container) : ScriptElementKind.unknown - }; - } + function createNavigateToItem(rawItem: RawNavigateToItem): NavigateToItem { + const declaration = rawItem.declaration; + const container = getContainerNode(declaration); + const containerName = container && getNameOfDeclaration(container); + return { + name: rawItem.name, + kind: getNodeKind(declaration), + kindModifiers: getNodeModifiers(declaration), + matchKind: PatternMatchKind[rawItem.matchKind], + isCaseSensitive: rawItem.isCaseSensitive, + fileName: rawItem.fileName, + textSpan: createTextSpanFromNode(declaration), + // TODO(jfreeman): What should be the containerName when the container has a computed name? + containerName: containerName ? (containerName).text : "", + containerKind: containerName ? getNodeKind(container) : ScriptElementKind.unknown + }; } } diff --git a/src/services/patternMatcher.ts b/src/services/patternMatcher.ts index 396e53810ce..04f9d906d35 100644 --- a/src/services/patternMatcher.ts +++ b/src/services/patternMatcher.ts @@ -47,7 +47,7 @@ namespace ts { // Fully checks a candidate, with an dotted container, against the search pattern. // The candidate must match the last part of the search pattern, and the dotted container // must match the preceding segments of the pattern. - getMatches(candidateContainers: string[], candidate: string): PatternMatch[]; + getMatches(candidateContainers: string[], candidate: string): PatternMatch[] | undefined; // Whether or not the pattern contained dots or not. Clients can use this to determine // If they should call getMatches, or if getMatchesForLastSegmentOfPattern is sufficient. @@ -139,7 +139,7 @@ namespace ts { return matchSegment(candidate, lastOrUndefined(dotSeparatedSegments)); } - function getMatches(candidateContainers: string[], candidate: string): PatternMatch[] { + function getMatches(candidateContainers: string[], candidate: string): PatternMatch[] | undefined { if (skipMatch(candidate)) { return undefined; } From 0de1b2301ebeccc4ce4c85ca8110bf4ffcb41b05 Mon Sep 17 00:00:00 2001 From: Andy Date: Thu, 14 Sep 2017 12:38:48 -0700 Subject: [PATCH 339/370] Cleanup getDiagnosticsForProject (#18151) --- src/server/session.ts | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/server/session.ts b/src/server/session.ts index 2d773d6f467..e6ba78b81c9 100644 --- a/src/server/session.ts +++ b/src/server/session.ts @@ -1609,7 +1609,10 @@ namespace ts.server { } // No need to analyze lib.d.ts - let fileNamesInProject = fileNames.filter(value => value.indexOf("lib.d.ts") < 0); + const fileNamesInProject = fileNames.filter(value => value.indexOf("lib.d.ts") < 0); + if (fileNamesInProject.length === 0) { + return; + } // Sort the file name list to make the recently touched files come first const highPriorityFiles: NormalizedPath[] = []; @@ -1625,7 +1628,7 @@ namespace ts.server { else { const info = this.projectService.getScriptInfo(fileNameInProject); if (!info.isScriptOpen()) { - if (fileNameInProject.indexOf(Extension.Dts) > 0) { + if (fileExtensionIs(fileNameInProject, Extension.Dts)) { veryLowPriorityFiles.push(fileNameInProject); } else { @@ -1638,14 +1641,11 @@ namespace ts.server { } } - fileNamesInProject = highPriorityFiles.concat(mediumPriorityFiles).concat(lowPriorityFiles).concat(veryLowPriorityFiles); - - if (fileNamesInProject.length > 0) { - const checkList = fileNamesInProject.map(fileName => ({ fileName, project })); - // Project level error analysis runs on background files too, therefore - // doesn't require the file to be opened - this.updateErrorCheck(next, checkList, delay, /*requireOpen*/ false); - } + const sortedFiles = [...highPriorityFiles, ...mediumPriorityFiles, ...lowPriorityFiles, ...veryLowPriorityFiles]; + const checkList = sortedFiles.map(fileName => ({ fileName, project })); + // Project level error analysis runs on background files too, therefore + // doesn't require the file to be opened + this.updateErrorCheck(next, checkList, delay, /*requireOpen*/ false); } getCanonicalFileName(fileName: string) { From 1ab67c0f222f79e4e380febcd7bd8988aa3c92d5 Mon Sep 17 00:00:00 2001 From: Armando Aguirre Date: Thu, 14 Sep 2017 12:48:04 -0700 Subject: [PATCH 340/370] Fixed sourceFiles type error --- src/services/services.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/services/services.ts b/src/services/services.ts index 9cb7d6638b9..90f9acd82ea 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -1543,7 +1543,7 @@ namespace ts { } } else { - sourceFiles = program.getSourceFiles(); + sourceFiles = program.getSourceFiles().slice(); } return FindAllReferences.findReferencedEntries(program, cancellationToken, sourceFiles, getValidSourceFile(fileName), position, options); From 66abcb9166bce8a897389d56b7760139fe77f665 Mon Sep 17 00:00:00 2001 From: Andy Date: Thu, 14 Sep 2017 13:03:12 -0700 Subject: [PATCH 341/370] Handle undefined `symbol.declarations` in `cloneSymbol` (#18474) --- src/compiler/checker.ts | 2 +- .../mergedClassWithNamespacePrototype.errors.txt | 15 +++++++++++++++ .../mergedClassWithNamespacePrototype.js | 14 ++++++++++++++ .../compiler/mergedClassWithNamespacePrototype.ts | 9 +++++++++ 4 files changed, 39 insertions(+), 1 deletion(-) create mode 100644 tests/baselines/reference/mergedClassWithNamespacePrototype.errors.txt create mode 100644 tests/baselines/reference/mergedClassWithNamespacePrototype.js create mode 100644 tests/cases/compiler/mergedClassWithNamespacePrototype.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 25fff43bab7..28c9fb25af9 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -578,7 +578,7 @@ namespace ts { function cloneSymbol(symbol: Symbol): Symbol { const result = createSymbol(symbol.flags, symbol.escapedName); - result.declarations = symbol.declarations.slice(0); + result.declarations = symbol.declarations ? symbol.declarations.slice() : []; result.parent = symbol.parent; if (symbol.valueDeclaration) result.valueDeclaration = symbol.valueDeclaration; if (symbol.constEnumOnlyModule) result.constEnumOnlyModule = true; diff --git a/tests/baselines/reference/mergedClassWithNamespacePrototype.errors.txt b/tests/baselines/reference/mergedClassWithNamespacePrototype.errors.txt new file mode 100644 index 00000000000..5c1d4ec5026 --- /dev/null +++ b/tests/baselines/reference/mergedClassWithNamespacePrototype.errors.txt @@ -0,0 +1,15 @@ +/b.ts(2,15): error TS2300: Duplicate identifier 'prototype'. + + +==== /a.d.ts (0 errors) ==== + declare class Foo {} + +==== /b.ts (1 errors) ==== + declare namespace Foo { + namespace prototype { + ~~~~~~~~~ +!!! error TS2300: Duplicate identifier 'prototype'. + function f(): void; + } + } + \ No newline at end of file diff --git a/tests/baselines/reference/mergedClassWithNamespacePrototype.js b/tests/baselines/reference/mergedClassWithNamespacePrototype.js new file mode 100644 index 00000000000..fbacd3b8baa --- /dev/null +++ b/tests/baselines/reference/mergedClassWithNamespacePrototype.js @@ -0,0 +1,14 @@ +//// [tests/cases/compiler/mergedClassWithNamespacePrototype.ts] //// + +//// [a.d.ts] +declare class Foo {} + +//// [b.ts] +declare namespace Foo { + namespace prototype { + function f(): void; + } +} + + +//// [b.js] diff --git a/tests/cases/compiler/mergedClassWithNamespacePrototype.ts b/tests/cases/compiler/mergedClassWithNamespacePrototype.ts new file mode 100644 index 00000000000..e4b086ffd27 --- /dev/null +++ b/tests/cases/compiler/mergedClassWithNamespacePrototype.ts @@ -0,0 +1,9 @@ +// @Filename: /a.d.ts +declare class Foo {} + +// @Filename: /b.ts +declare namespace Foo { + namespace prototype { + function f(): void; + } +} From 0747b33038878f011dbad9ff53cdcdc9285d5213 Mon Sep 17 00:00:00 2001 From: Andy Date: Thu, 14 Sep 2017 14:30:50 -0700 Subject: [PATCH 342/370] Fixes to emit / format for codeFix (#18484) --- src/compiler/emitter.ts | 6 +++++ src/harness/fourslash.ts | 2 +- src/services/formatting/rules.ts | 5 ++-- .../fourslash/convertFunctionToEs6Class3.ts | 4 +-- ...nvertFunctionToEs6Class_emptySwitchCase.ts | 25 +++++++++++++++++++ ...ToEs6Class_objectLiteralInArrowFunction.ts | 21 ++++++++++++++++ 6 files changed, 57 insertions(+), 6 deletions(-) create mode 100644 tests/cases/fourslash/convertFunctionToEs6Class_emptySwitchCase.ts create mode 100644 tests/cases/fourslash/convertFunctionToEs6Class_objectLiteralInArrowFunction.ts diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index 8788e0c02f4..2c6eef3672f 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -2417,6 +2417,12 @@ namespace ts { const isEmpty = isUndefined || start >= children.length || count === 0; if (isEmpty && format & ListFormat.OptionalIfEmpty) { + if (onBeforeEmitNodeArray) { + onBeforeEmitNodeArray(children); + } + if (onAfterEmitNodeArray) { + onAfterEmitNodeArray(children); + } return; } diff --git a/src/harness/fourslash.ts b/src/harness/fourslash.ts index fb5e9e0354e..64e25e0eb9a 100644 --- a/src/harness/fourslash.ts +++ b/src/harness/fourslash.ts @@ -3500,7 +3500,7 @@ ${code} expected = makeWhitespaceVisible(expected); actual = makeWhitespaceVisible(actual); } - return `Expected:\n${expected}\nActual:${actual}`; + return `Expected:\n${expected}\nActual:\n${actual}`; } function differOnlyByWhitespace(a: string, b: string) { diff --git a/src/services/formatting/rules.ts b/src/services/formatting/rules.ts index 07c2804ee83..d41d9dfbfd8 100644 --- a/src/services/formatting/rules.ts +++ b/src/services/formatting/rules.ts @@ -755,9 +755,8 @@ namespace ts.formatting { return true; case SyntaxKind.Block: { const blockParent = context.currentTokenParent.parent; - if (blockParent.kind !== SyntaxKind.ArrowFunction && - blockParent.kind !== SyntaxKind.FunctionExpression - ) { + // In a codefix scenario, we can't rely on parents being set. So just always return true. + if (!blockParent || blockParent.kind !== SyntaxKind.ArrowFunction && blockParent.kind !== SyntaxKind.FunctionExpression) { return true; } } diff --git a/tests/cases/fourslash/convertFunctionToEs6Class3.ts b/tests/cases/fourslash/convertFunctionToEs6Class3.ts index bb48ffadec2..fec4dd8edfa 100644 --- a/tests/cases/fourslash/convertFunctionToEs6Class3.ts +++ b/tests/cases/fourslash/convertFunctionToEs6Class3.ts @@ -2,14 +2,14 @@ // @allowNonTsExtensions: true // @Filename: test123.js -//// [|var bar = 10, /*1*/foo = function() { }; +//// var bar = 10, /*1*/foo = function() { }; //// /*2*/foo.prototype.instanceMethod1 = function() { return "this is name"; }; //// /*3*/foo.prototype.instanceMethod2 = () => { return "this is name"; }; //// /*4*/foo.prototype.instanceProp1 = "hello"; //// /*5*/foo.prototype.instanceProp2 = undefined; //// /*6*/foo.staticProp = "world"; //// /*7*/foo.staticMethod1 = function() { return "this is static name"; }; -//// /*8*/foo.staticMethod2 = () => "this is static name";|] +//// /*8*/foo.staticMethod2 = () => "this is static name"; ['1', '2', '3', '4', '5', '6', '7', '8'].forEach(m => verify.applicableRefactorAvailableAtMarker(m)); diff --git a/tests/cases/fourslash/convertFunctionToEs6Class_emptySwitchCase.ts b/tests/cases/fourslash/convertFunctionToEs6Class_emptySwitchCase.ts new file mode 100644 index 00000000000..90bd48784ce --- /dev/null +++ b/tests/cases/fourslash/convertFunctionToEs6Class_emptySwitchCase.ts @@ -0,0 +1,25 @@ +/// + +// @allowNonTsExtensions: true +// @Filename: /a.js +////function /**/MyClass() { +////} +////MyClass.prototype.f = function(x) { +//// switch (x) { +//// case 0: +//// } +////} + +verify.applicableRefactorAvailableAtMarker(""); +verify.fileAfterApplyingRefactorAtMarker("", +`class MyClass { + constructor() { + } + f(x) { + switch (x) { + case 0: + } + } +} +`, +'Convert to ES2015 class', 'convert'); diff --git a/tests/cases/fourslash/convertFunctionToEs6Class_objectLiteralInArrowFunction.ts b/tests/cases/fourslash/convertFunctionToEs6Class_objectLiteralInArrowFunction.ts new file mode 100644 index 00000000000..0bbbf4e0024 --- /dev/null +++ b/tests/cases/fourslash/convertFunctionToEs6Class_objectLiteralInArrowFunction.ts @@ -0,0 +1,21 @@ +/// + +// @allowNonTsExtensions: true +// @Filename: /a.js +////function /**/MyClass() { +////} +////MyClass.prototype.foo = function() { +//// ({ bar: () => { } }) +////} + +verify.applicableRefactorAvailableAtMarker(""); +verify.fileAfterApplyingRefactorAtMarker("", +`class MyClass { + constructor() { + } + foo() { + ({ bar: () => { } }); + } +} +`, +'Convert to ES2015 class', 'convert'); From e1ede37ec7ff3b9be794432ada0b470cca82c647 Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Thu, 14 Sep 2017 14:41:56 -0700 Subject: [PATCH 343/370] Add name to amd definition in umd module if present (#18479) --- src/compiler/transformers/module/module.ts | 3 +++ tests/baselines/reference/umdNamedAmdMode.js | 19 +++++++++++++++++++ .../reference/umdNamedAmdMode.symbols | 5 +++++ .../baselines/reference/umdNamedAmdMode.types | 6 ++++++ tests/cases/compiler/umdNamedAmdMode.ts | 4 ++++ 5 files changed, 37 insertions(+) create mode 100644 tests/baselines/reference/umdNamedAmdMode.js create mode 100644 tests/baselines/reference/umdNamedAmdMode.symbols create mode 100644 tests/baselines/reference/umdNamedAmdMode.types create mode 100644 tests/cases/compiler/umdNamedAmdMode.ts diff --git a/src/compiler/transformers/module/module.ts b/src/compiler/transformers/module/module.ts index 493f5a43a1f..08c1fccfe16 100644 --- a/src/compiler/transformers/module/module.ts +++ b/src/compiler/transformers/module/module.ts @@ -200,6 +200,7 @@ namespace ts { */ function transformUMDModule(node: SourceFile) { const { aliasedModuleNames, unaliasedModuleNames, importAliasNames } = collectAsynchronousDependencies(node, /*includeNonAmdDependencies*/ false); + const moduleName = tryGetModuleNameFromFile(node, host, compilerOptions); const umdHeader = createFunctionExpression( /*modifiers*/ undefined, /*asteriskToken*/ undefined, @@ -260,6 +261,8 @@ namespace ts { createIdentifier("define"), /*typeArguments*/ undefined, [ + // Add the module name (if provided). + ...(moduleName ? [moduleName] : []), createArrayLiteral([ createLiteral("require"), createLiteral("exports"), diff --git a/tests/baselines/reference/umdNamedAmdMode.js b/tests/baselines/reference/umdNamedAmdMode.js new file mode 100644 index 00000000000..eff0384b575 --- /dev/null +++ b/tests/baselines/reference/umdNamedAmdMode.js @@ -0,0 +1,19 @@ +//// [main.ts] +/// +export const a = 1; + +//// [main.js] +(function (factory) { + if (typeof module === "object" && typeof module.exports === "object") { + var v = factory(require, exports); + if (v !== undefined) module.exports = v; + } + else if (typeof define === "function" && define.amd) { + define("a", ["require", "exports"], factory); + } +})(function (require, exports) { + "use strict"; + exports.__esModule = true; + /// + exports.a = 1; +}); diff --git a/tests/baselines/reference/umdNamedAmdMode.symbols b/tests/baselines/reference/umdNamedAmdMode.symbols new file mode 100644 index 00000000000..73ad766e50b --- /dev/null +++ b/tests/baselines/reference/umdNamedAmdMode.symbols @@ -0,0 +1,5 @@ +=== tests/cases/compiler/main.ts === +/// +export const a = 1; +>a : Symbol(a, Decl(main.ts, 1, 12)) + diff --git a/tests/baselines/reference/umdNamedAmdMode.types b/tests/baselines/reference/umdNamedAmdMode.types new file mode 100644 index 00000000000..f8f2d131fc2 --- /dev/null +++ b/tests/baselines/reference/umdNamedAmdMode.types @@ -0,0 +1,6 @@ +=== tests/cases/compiler/main.ts === +/// +export const a = 1; +>a : 1 +>1 : 1 + diff --git a/tests/cases/compiler/umdNamedAmdMode.ts b/tests/cases/compiler/umdNamedAmdMode.ts new file mode 100644 index 00000000000..d18e1427443 --- /dev/null +++ b/tests/cases/compiler/umdNamedAmdMode.ts @@ -0,0 +1,4 @@ +// @module: umd +// @filename: main.ts +/// +export const a = 1; \ No newline at end of file From c522f379b20b2be70873ca6b61dd8be7be1c76bf Mon Sep 17 00:00:00 2001 From: Andy Date: Thu, 14 Sep 2017 15:02:32 -0700 Subject: [PATCH 344/370] Update assertion: symbol in union type may be a Function (#18483) --- src/services/symbolDisplay.ts | 3 ++- .../cases/fourslash/quickInfoUnionOfNamespaces.ts | 15 +++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 tests/cases/fourslash/quickInfoUnionOfNamespaces.ts diff --git a/src/services/symbolDisplay.ts b/src/services/symbolDisplay.ts index 05c451cc3f3..ad8e7ddf975 100644 --- a/src/services/symbolDisplay.ts +++ b/src/services/symbolDisplay.ts @@ -61,7 +61,8 @@ namespace ts.SymbolDisplay { if (rootSymbolFlags & (SymbolFlags.PropertyOrAccessor | SymbolFlags.Variable)) { return ScriptElementKind.memberVariableElement; } - Debug.assert(!!(rootSymbolFlags & SymbolFlags.Method)); + // May be a Function if this was from `typeof N` with `namespace N { function f();. }`. + Debug.assert(!!(rootSymbolFlags & (SymbolFlags.Method | SymbolFlags.Function))); }); if (!unionPropertyKind) { // If this was union of all methods, diff --git a/tests/cases/fourslash/quickInfoUnionOfNamespaces.ts b/tests/cases/fourslash/quickInfoUnionOfNamespaces.ts new file mode 100644 index 00000000000..9b2431092e7 --- /dev/null +++ b/tests/cases/fourslash/quickInfoUnionOfNamespaces.ts @@ -0,0 +1,15 @@ +// See GH#18461 + +/// + +////declare const x: typeof A | typeof B; +////x./**/f; +//// +////namespace A { +//// export function f() {} +////} +////namespace B { +//// export function f() {} +////} + +verify.quickInfoAt("", "(method) f(): void"); From d1c4754b37fb49e3f3d9f73dcc8fc6810a1e081e Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Thu, 14 Sep 2017 15:42:06 -0700 Subject: [PATCH 345/370] Better-scheduled parallel tests (#18462) * Out with the old... * Brave new world * Throttle console output * Batches test messages on large inputs initially * Move parallel runner code into seperate files --- Gulpfile.ts | 31 +-- Jakefile.js | 40 ++-- scripts/mocha-none-reporter.js | 26 --- scripts/mocha-parallel.js | 405 --------------------------------- src/harness/parallel/host.ts | 376 ++++++++++++++++++++++++++++++ src/harness/parallel/shared.ts | 14 ++ src/harness/parallel/worker.ts | 123 ++++++++++ src/harness/runner.ts | 224 +++++++++--------- src/harness/tsconfig.json | 3 + 9 files changed, 650 insertions(+), 592 deletions(-) delete mode 100644 scripts/mocha-none-reporter.js delete mode 100644 scripts/mocha-parallel.js create mode 100644 src/harness/parallel/host.ts create mode 100644 src/harness/parallel/shared.ts create mode 100644 src/harness/parallel/worker.ts diff --git a/Gulpfile.ts b/Gulpfile.ts index a3db20dfd8a..676d07ec570 100644 --- a/Gulpfile.ts +++ b/Gulpfile.ts @@ -31,8 +31,6 @@ import merge2 = require("merge2"); import * as os from "os"; import fold = require("travis-fold"); const gulp = helpMaker(originalGulp); -const mochaParallel = require("./scripts/mocha-parallel.js"); -const {runTestsInParallel} = mochaParallel; Error.stackTraceLimit = 1000; @@ -668,26 +666,9 @@ function runConsoleTests(defaultReporter: string, runInParallel: boolean, done: } else { // run task to load all tests and partition them between workers - const args = []; - args.push("-R", "min"); - if (colors) { - args.push("--colors"); - } - else { - args.push("--no-colors"); - } - args.push(run); setNodeEnvToDevelopment(); - runTestsInParallel(taskConfigsFolder, run, { testTimeout, noColors: colors === " --no-colors " }, function(err) { - // last worker clean everything and runs linter in case if there were no errors - del(taskConfigsFolder).then(() => { - if (!err) { - lintThenFinish(); - } - else { - finish(err); - } - }); + exec(host, [run], lintThenFinish, function(e, status) { + finish(e, status); }); } }); @@ -711,7 +692,7 @@ function runConsoleTests(defaultReporter: string, runInParallel: boolean, done: function finish(error?: any, errorStatus?: number) { restoreSavedNodeEnv(); - deleteTemporaryProjectOutput().then(() => { + deleteTestConfig().then(deleteTemporaryProjectOutput).then(() => { if (error !== undefined || errorStatus !== undefined) { failWithStatus(error, errorStatus); } @@ -720,6 +701,10 @@ function runConsoleTests(defaultReporter: string, runInParallel: boolean, done: } }); } + + function deleteTestConfig() { + return del("test.config"); + } } gulp.task("runtests-parallel", "Runs all the tests in parallel using the built run.js file. Optional arguments are: --t[ests]=category1|category2|... --d[ebug]=true.", ["build-rules", "tests"], (done) => { @@ -836,7 +821,7 @@ function cleanTestDirs(done: (e?: any) => void) { // used to pass data from jake command line directly to run.js function writeTestConfigFile(tests: string, light: boolean, taskConfigsFolder?: string, workerCount?: number, stackTraceLimit?: string) { - const testConfigContents = JSON.stringify({ test: tests ? [tests] : undefined, light, workerCount, stackTraceLimit, taskConfigsFolder }); + const testConfigContents = JSON.stringify({ test: tests ? [tests] : undefined, light, workerCount, stackTraceLimit, taskConfigsFolder, noColor: !cmdLineOptions["colors"] }); console.log("Running tests with config: " + testConfigContents); fs.writeFileSync("test.config", testConfigContents); } diff --git a/Jakefile.js b/Jakefile.js index ad853238111..39e9e8a0421 100644 --- a/Jakefile.js +++ b/Jakefile.js @@ -1,11 +1,11 @@ // This file contains the build logic for the public repo +// @ts-check var fs = require("fs"); var os = require("os"); var path = require("path"); var child_process = require("child_process"); var fold = require("travis-fold"); -var runTestsInParallel = require("./scripts/mocha-parallel").runTestsInParallel; var ts = require("./lib/typescript"); @@ -38,7 +38,7 @@ else if (process.env.PATH !== undefined) { function filesFromConfig(configPath) { var configText = fs.readFileSync(configPath).toString(); - var config = ts.parseConfigFileTextToJson(configPath, configText, /*stripComments*/ true); + var config = ts.parseConfigFileTextToJson(configPath, configText); if (config.error) { throw new Error(diagnosticsToString([config.error])); } @@ -104,6 +104,9 @@ var harnessCoreSources = [ "loggedIO.ts", "rwcRunner.ts", "test262Runner.ts", + "./parallel/shared.ts", + "./parallel/host.ts", + "./parallel/worker.ts", "runner.ts" ].map(function (f) { return path.join(harnessDirectory, f); @@ -596,7 +599,7 @@ file(typesMapOutputPath, function() { var content = fs.readFileSync(path.join(serverDirectory, 'typesMap.json')); // Validate that it's valid JSON try { - JSON.parse(content); + JSON.parse(content.toString()); } catch (e) { console.log("Parse error in typesMap.json: " + e); } @@ -740,7 +743,7 @@ desc("Builds the test infrastructure using the built compiler"); task("tests", ["local", run].concat(libraryTargets)); function exec(cmd, completeHandler, errorHandler) { - var ex = jake.createExec([cmd], { windowsVerbatimArguments: true }); + var ex = jake.createExec([cmd], { windowsVerbatimArguments: true, interactive: true }); // Add listeners for output and error ex.addListener("stdout", function (output) { process.stdout.write(output); @@ -783,13 +786,14 @@ function cleanTestDirs() { } // used to pass data from jake command line directly to run.js -function writeTestConfigFile(tests, light, taskConfigsFolder, workerCount, stackTraceLimit) { +function writeTestConfigFile(tests, light, taskConfigsFolder, workerCount, stackTraceLimit, colors) { var testConfigContents = JSON.stringify({ test: tests ? [tests] : undefined, light: light, workerCount: workerCount, taskConfigsFolder: taskConfigsFolder, - stackTraceLimit: stackTraceLimit + stackTraceLimit: stackTraceLimit, + noColor: !colors }); fs.writeFileSync('test.config', testConfigContents); } @@ -831,7 +835,7 @@ function runConsoleTests(defaultReporter, runInParallel) { } if (tests || light || taskConfigsFolder) { - writeTestConfigFile(tests, light, taskConfigsFolder, workerCount, stackTraceLimit); + writeTestConfigFile(tests, light, taskConfigsFolder, workerCount, stackTraceLimit, colors); } if (tests && tests.toLocaleLowerCase() === "rwc") { @@ -894,19 +898,15 @@ function runConsoleTests(defaultReporter, runInParallel) { var savedNodeEnv = process.env.NODE_ENV; process.env.NODE_ENV = "development"; var startTime = mark(); - runTestsInParallel(taskConfigsFolder, run, { testTimeout: testTimeout, noColors: !colors }, function (err) { + exec(host + " " + run, function () { process.env.NODE_ENV = savedNodeEnv; measure(startTime); - // last worker clean everything and runs linter in case if there were no errors - deleteTemporaryProjectOutput(); - jake.rmRf(taskConfigsFolder); - if (err) { - fail(err); - } - else { - runLinter(); - complete(); - } + runLinter(); + finish(); + }, function (e, status) { + process.env.NODE_ENV = savedNodeEnv; + measure(startTime); + finish(status); }); } @@ -969,8 +969,8 @@ desc("Runs the tests using the built run.js file like 'jake runtests'. Syntax is task("runtests-browser", ["browserify", nodeServerOutFile], function () { cleanTestDirs(); host = "node"; - browser = process.env.browser || process.env.b || (os.platform() === "linux" ? "chrome" : "IE"); - tests = process.env.test || process.env.tests || process.env.t; + var browser = process.env.browser || process.env.b || (os.platform() === "linux" ? "chrome" : "IE"); + var tests = process.env.test || process.env.tests || process.env.t; var light = process.env.light || false; var testConfigFile = 'test.config'; if (fs.existsSync(testConfigFile)) { diff --git a/scripts/mocha-none-reporter.js b/scripts/mocha-none-reporter.js deleted file mode 100644 index 5787b0c042e..00000000000 --- a/scripts/mocha-none-reporter.js +++ /dev/null @@ -1,26 +0,0 @@ -/** - * Module dependencies. - */ - -var Base = require('mocha').reporters.Base; - -/** - * Expose `None`. - */ - -exports = module.exports = None; - -/** - * Initialize a new `None` test reporter. - * - * @api public - * @param {Runner} runner - */ -function None(runner) { - Base.call(this); -} - -/** - * Inherit from `Base.prototype`. - */ -None.prototype.__proto__ = Base.prototype; diff --git a/scripts/mocha-parallel.js b/scripts/mocha-parallel.js deleted file mode 100644 index 6a54c018e9a..00000000000 --- a/scripts/mocha-parallel.js +++ /dev/null @@ -1,405 +0,0 @@ -var tty = require("tty") - , readline = require("readline") - , fs = require("fs") - , path = require("path") - , child_process = require("child_process") - , os = require("os") - , mocha = require("mocha") - , Base = mocha.reporters.Base - , color = Base.color - , cursor = Base.cursor - , ms = require("mocha/lib/ms"); - -var isatty = tty.isatty(1) && tty.isatty(2); -var tapRangePattern = /^(\d+)\.\.(\d+)(?:$|\r\n?|\n)/; -var tapTestPattern = /^(not\sok|ok)\s+(\d+)\s+(?:-\s+)?(.*)$/; -var tapCommentPattern = /^#(?: (tests|pass|fail) (\d+)$)?/; - -exports.runTestsInParallel = runTestsInParallel; -exports.ProgressBars = ProgressBars; - -function runTestsInParallel(taskConfigsFolder, run, options, cb) { - if (options === undefined) options = { }; - - return discoverTests(run, options, function (error) { - if (error) { - return cb(error); - } - - return runTests(taskConfigsFolder, run, options, cb); - }); -} - -function discoverTests(run, options, cb) { - console.log("Discovering tests..."); - - var cmd = "mocha -R " + require.resolve("./mocha-none-reporter.js") + " " + run; - var p = spawnProcess(cmd); - p.on("exit", function (status) { - if (status) { - cb(new Error("Process exited with code " + status)); - } - else { - cb(); - } - }); -} - -function runTests(taskConfigsFolder, run, options, cb) { - var configFiles = fs.readdirSync(taskConfigsFolder); - var numPartitions = configFiles.length; - if (numPartitions <= 0) { - cb(); - return; - } - - console.log("Running tests on " + numPartitions + " threads..."); - - var partitions = Array(numPartitions); - var progressBars = new ProgressBars(); - progressBars.enable(); - - var counter = numPartitions; - configFiles.forEach(runTestsInPartition); - - function runTestsInPartition(file, index) { - var partition = { - file: path.join(taskConfigsFolder, file), - tests: 0, - passed: 0, - failed: 0, - completed: 0, - current: undefined, - start: undefined, - end: undefined, - catastrophicError: "", - failures: [] - }; - partitions[index] = partition; - - // Set up the progress bar. - updateProgress(0); - - // Start the background process. - var cmd = "mocha -t " + (options.testTimeout || 20000) + " -R tap --no-colors " + run + " --config='" + partition.file + "'"; - var p = spawnProcess(cmd); - var rl = readline.createInterface({ - input: p.stdout, - terminal: false - }); - - var rlError = readline.createInterface({ - input: p.stderr, - terminal: false - }); - - rl.on("line", onmessage); - rlError.on("line", onErrorMessage); - p.on("exit", onexit) - - function onErrorMessage(line) { - partition.catastrophicError += line + os.EOL; - } - - function onmessage(line) { - if (partition.start === undefined) { - partition.start = Date.now(); - } - - var rangeMatch = tapRangePattern.exec(line); - if (rangeMatch) { - partition.tests = parseInt(rangeMatch[2]); - return; - } - - var testMatch = tapTestPattern.exec(line); - if (testMatch) { - var test = { - result: testMatch[1], - id: parseInt(testMatch[2]), - name: testMatch[3], - output: [] - }; - - partition.current = test; - partition.completed++; - - if (test.result === "ok") { - partition.passed++; - } - else { - partition.failed++; - partition.failures.push(test); - } - - var progress = partition.completed / partition.tests; - if (progress < 1) { - updateProgress(progress); - } - - return; - } - - var commentMatch = tapCommentPattern.exec(line); - if (commentMatch) { - switch (commentMatch[1]) { - case "tests": - partition.current = undefined; - partition.tests = parseInt(commentMatch[2]); - break; - - case "pass": - partition.passed = parseInt(commentMatch[2]); - break; - - case "fail": - partition.failed = parseInt(commentMatch[2]); - break; - } - - return; - } - - if (partition.current) { - partition.current.output.push(line); - } - } - - function onexit(code) { - if (partition.end === undefined) { - partition.end = Date.now(); - } - - partition.duration = partition.end - partition.start; - var isPartitionFail = partition.failed || code !== 0; - var summaryColor = isPartitionFail ? "fail" : "green"; - var summarySymbol = isPartitionFail ? Base.symbols.err : Base.symbols.ok; - - var summaryTests = (isPartitionFail ? partition.passed + "/" + partition.tests : partition.passed) + " passing"; - var summaryDuration = "(" + ms(partition.duration) + ")"; - var savedUseColors = Base.useColors; - Base.useColors = !options.noColors; - - var summary = color(summaryColor, summarySymbol + " " + summaryTests) + " " + color("light", summaryDuration); - Base.useColors = savedUseColors; - - updateProgress(1, summary); - - signal(); - } - - function updateProgress(percentComplete, title) { - var progressColor = "pending"; - if (partition.failed) { - progressColor = "fail"; - } - - progressBars.update( - index, - percentComplete, - progressColor, - title - ); - } - } - - function signal() { - counter--; - - if (counter <= 0) { - var reporter = new Base(), - stats = reporter.stats, - failures = reporter.failures; - - var duration = 0; - var catastrophicError = ""; - for (var i = 0; i < numPartitions; i++) { - var partition = partitions[i]; - stats.passes += partition.passed; - stats.failures += partition.failed; - stats.tests += partition.tests; - duration += partition.duration; - if (partition.catastrophicError !== "") { - // Partition is written out to a temporary file as a JSON object. - // Below is an example of how the partition JSON object looks like - // { - // "light":false, - // "tasks":[ - // { - // "runner":"compiler", - // "files":["tests/cases/compiler/es6ImportNamedImportParsingError.ts"] - // } - // ], - // "runUnitTests":false - // } - var jsonText = fs.readFileSync(partition.file); - var configObj = JSON.parse(jsonText); - if (configObj.tasks && configObj.tasks[0]) { - catastrophicError += "Error from one or more of these files: " + configObj.tasks[0].files + os.EOL; - catastrophicError += partition.catastrophicError; - catastrophicError += os.EOL; - } - } - for (var j = 0; j < partition.failures.length; j++) { - var failure = partition.failures[j]; - failures.push(makeMochaTest(failure)); - } - } - - stats.duration = duration; - progressBars.disable(); - - if (options.noColors) { - var savedUseColors = Base.useColors; - Base.useColors = false; - reporter.epilogue(); - Base.useColors = savedUseColors; - } - else { - reporter.epilogue(); - } - - if (catastrophicError !== "") { - return cb(new Error(catastrophicError)); - } - if (stats.failures) { - return cb(new Error("Test failures reported: " + stats.failures)); - } - else { - return cb(); - } - } - } - - function makeMochaTest(test) { - return { - fullTitle: function() { - return test.name; - }, - err: { - message: test.output[0], - stack: test.output.join(os.EOL) - } - }; - } -} - -var nodeModulesPathPrefix = path.resolve("./node_modules/.bin/") + path.delimiter; -if (process.env.path !== undefined) { - process.env.path = nodeModulesPathPrefix + process.env.path; -} else if (process.env.PATH !== undefined) { - process.env.PATH = nodeModulesPathPrefix + process.env.PATH; -} - -function spawnProcess(cmd, options) { - var shell = process.platform === "win32" ? "cmd" : "/bin/sh"; - var prefix = process.platform === "win32" ? "/c" : "-c"; - return child_process.spawn(shell, [prefix, cmd], { windowsVerbatimArguments: true }); -} - -function ProgressBars(options) { - if (!options) options = {}; - var open = options.open || '['; - var close = options.close || ']'; - var complete = options.complete || '▬'; - var incomplete = options.incomplete || Base.symbols.dot; - var maxWidth = Math.floor(Base.window.width * .30) - open.length - close.length - 2; - var width = minMax(options.width || maxWidth, 10, maxWidth); - this._options = { - open: open, - complete: complete, - incomplete: incomplete, - close: close, - width: width - }; - - this._progressBars = []; - this._lineCount = 0; - this._enabled = false; -} -ProgressBars.prototype = { - enable: function () { - if (!this._enabled) { - process.stdout.write(os.EOL); - this._enabled = true; - } - }, - disable: function () { - if (this._enabled) { - process.stdout.write(os.EOL); - this._enabled = false; - } - }, - update: function (index, percentComplete, color, title) { - percentComplete = minMax(percentComplete, 0, 1); - - var progressBar = this._progressBars[index] || (this._progressBars[index] = { }); - var width = this._options.width; - var n = Math.floor(width * percentComplete); - var i = width - n; - if (n === progressBar.lastN && title === progressBar.title && color === progressBar.progressColor) { - return; - } - - progressBar.lastN = n; - progressBar.title = title; - progressBar.progressColor = color; - - var progress = " "; - progress += this._color('progress', this._options.open); - progress += this._color(color, fill(this._options.complete, n)); - progress += this._color('progress', fill(this._options.incomplete, i)); - progress += this._color('progress', this._options.close); - - if (title) { - progress += this._color('progress', ' ' + title); - } - - if (progressBar.text !== progress) { - progressBar.text = progress; - this._render(index); - } - }, - _render: function (index) { - if (!this._enabled || !isatty) { - return; - } - - cursor.hide(); - readline.moveCursor(process.stdout, -process.stdout.columns, -this._lineCount); - var lineCount = 0; - var numProgressBars = this._progressBars.length; - for (var i = 0; i < numProgressBars; i++) { - if (i === index) { - readline.clearLine(process.stdout, 1); - process.stdout.write(this._progressBars[i].text + os.EOL); - } - else { - readline.moveCursor(process.stdout, -process.stdout.columns, +1); - } - - lineCount++; - } - - this._lineCount = lineCount; - cursor.show(); - }, - _color: function (type, text) { - return type && !this._options.noColors ? color(type, text) : text; - } -}; - -function fill(ch, size) { - var s = ""; - while (s.length < size) { - s += ch; - } - - return s.length > size ? s.substr(0, size) : s; -} - -function minMax(value, min, max) { - if (value < min) return min; - if (value > max) return max; - return value; -} \ No newline at end of file diff --git a/src/harness/parallel/host.ts b/src/harness/parallel/host.ts new file mode 100644 index 00000000000..58e794bbc7d --- /dev/null +++ b/src/harness/parallel/host.ts @@ -0,0 +1,376 @@ +// tslint:disable-next-line +var describe: Mocha.IContextDefinition; // If launched without mocha for parallel mode, we still need a global describe visible to satisfy the parsing of the unit tests +// tslint:disable-next-line +var it: Mocha.ITestDefinition; +namespace Harness.Parallel.Host { + + interface ChildProcessPartial { + send(message: any, callback?: (error: Error) => void): boolean; + on(event: "error", listener: (err: Error) => void): this; + on(event: "exit", listener: (code: number, signal: string) => void): this; + on(event: "message", listener: (message: any) => void): this; + disconnect(): void; + } + + interface ProgressBarsOptions { + open: string; + close: string; + complete: string; + incomplete: string; + width: number; + noColors: boolean; + } + interface ProgressBar { + lastN?: number; + title?: string; + progressColor?: string; + text?: string; + } + + export function start() { + console.log("Discovering tests..."); + const discoverStart = +(new Date()); + const { statSync }: { statSync(path: string): { size: number }; } = require("fs"); + const tasks: { runner: TestRunnerKind, file: string, size: number }[] = []; + let totalSize = 0; + for (const runner of runners) { + const files = runner.enumerateTestFiles(); + for (const file of files) { + const size = statSync(file).size; + tasks.push({ runner: runner.kind(), file, size }); + totalSize += size; + } + } + tasks.sort((a, b) => a.size - b.size); + const batchSize = (totalSize / workerCount) * 0.9; + console.log(`Discovered ${tasks.length} test files in ${+(new Date()) - discoverStart}ms.`); + console.log(`Starting to run tests using ${workerCount} threads...`); + const { fork }: { fork(modulePath: string, args?: string[], options?: {}): ChildProcessPartial; } = require("child_process"); + + const totalFiles = tasks.length; + let passingFiles = 0; + let failingFiles = 0; + let errorResults: ErrorInfo[] = []; + let totalPassing = 0; + const startTime = Date.now(); + + const progressBars = new ProgressBars({ noColors }); + const progressUpdateInterval = 1 / progressBars._options.width; + let nextProgress = progressUpdateInterval; + + const workers: ChildProcessPartial[] = []; + for (let i = 0; i < workerCount; i++) { + // TODO: Just send the config over the IPC channel or in the command line arguments + const config: TestConfig = { light: Harness.lightMode, listenForWork: true, runUnitTests: runners.length === 1 ? false : i === workerCount - 1 }; + const configPath = ts.combinePaths(taskConfigsFolder, `task-config${i}.json`); + Harness.IO.writeFile(configPath, JSON.stringify(config)); + const child = fork(__filename, [`--config="${configPath}"`]); + child.on("error", err => { + child.disconnect(); + console.error("Unexpected error in child process:"); + console.error(err); + return process.exit(2); + }); + child.on("exit", (code, _signal) => { + if (code !== 0) { + console.error("Test worker process exited with nonzero exit code!"); + return process.exit(2); + } + }); + child.on("message", (data: ParallelClientMessage) => { + switch (data.type) { + case "error": { + child.disconnect(); + console.error(`Test worker encounted unexpected error and was forced to close: + Message: ${data.payload.error} + Stack: ${data.payload.stack}`); + return process.exit(2); + } + case "progress": + case "result": { + totalPassing += data.payload.passing; + if (data.payload.errors.length) { + errorResults = errorResults.concat(data.payload.errors); + failingFiles++; + } + else { + passingFiles++; + } + + const progress = (failingFiles + passingFiles) / totalFiles; + if (progress >= nextProgress) { + while (nextProgress < progress) { + nextProgress += progressUpdateInterval; + } + updateProgress(progress, errorResults.length ? `${errorResults.length} failing` : `${totalPassing} passing`, errorResults.length ? "fail" : undefined); + } + + if (failingFiles + passingFiles === totalFiles) { + // Done. Finished every task and collected results. + child.send({ type: "close" }); + child.disconnect(); + return outputFinalResult(); + } + if (tasks.length === 0) { + // No more tasks to distribute + child.send({ type: "close" }); + child.disconnect(); + return; + } + if (data.type === "result") { + child.send({ type: "test", payload: tasks.pop() }); + } + } + } + }); + workers.push(child); + } + + // It's only really worth doing an initial batching if there are a ton of files to go through + if (totalFiles > 1000) { + console.log("Batching initial test lists..."); + const batches: { runner: TestRunnerKind, file: string, size: number }[][] = new Array(workerCount); + const doneBatching = new Array(workerCount); + batcher: while (true) { + for (let i = 0; i < workerCount; i++) { + if (tasks.length === 0) { + // TODO: This indicates a particularly suboptimal packing + break batcher; + } + if (doneBatching[i]) { + continue; + } + if (!batches[i]) { + batches[i] = []; + } + const total = batches[i].reduce((p, c) => p + c.size, 0); + if (total >= batchSize && !doneBatching[i]) { + doneBatching[i] = true; + continue; + } + batches[i].push(tasks.pop()); + } + for (let j = 0; j < workerCount; j++) { + if (!doneBatching[j]) { + continue; + } + } + break; + } + console.log(`Batched into ${workerCount} groups with approximate total file sizes of ${Math.floor(batchSize)} bytes in each group.`); + for (const worker of workers) { + const action: ParallelBatchMessage = { type: "batch", payload: batches.pop() }; + if (!action.payload[0]) { + throw new Error(`Tried to send invalid message ${action}`); + } + worker.send(action); + } + } + else { + for (let i = 0; i < workerCount; i++) { + workers[i].send({ type: "test", payload: tasks.pop() }); + } + } + + progressBars.enable(); + updateProgress(0); + let duration: number; + + const ms = require("mocha/lib/ms"); + function completeBar() { + const isPartitionFail = failingFiles !== 0; + const summaryColor = isPartitionFail ? "fail" : "green"; + const summarySymbol = isPartitionFail ? Base.symbols.err : Base.symbols.ok; + + const summaryTests = (isPartitionFail ? totalPassing + "/" + (errorResults.length + totalPassing) : totalPassing) + " passing"; + const summaryDuration = "(" + ms(duration) + ")"; + const savedUseColors = Base.useColors; + Base.useColors = !noColors; + + const summary = color(summaryColor, summarySymbol + " " + summaryTests) + " " + color("light", summaryDuration); + Base.useColors = savedUseColors; + + updateProgress(1, summary); + } + + function updateProgress(percentComplete: number, title?: string, titleColor?: string) { + let progressColor = "pending"; + if (failingFiles) { + progressColor = "fail"; + } + + progressBars.update( + 0, + percentComplete, + progressColor, + title, + titleColor + ); + } + + function outputFinalResult() { + duration = Date.now() - startTime; + completeBar(); + progressBars.disable(); + + const reporter = new Base(); + const stats = reporter.stats; + const failures = reporter.failures; + stats.passes = totalPassing; + stats.failures = errorResults.length; + stats.tests = totalPassing + errorResults.length; + stats.duration = duration; + for (let j = 0; j < errorResults.length; j++) { + const failure = errorResults[j]; + failures.push(makeMochaTest(failure)); + } + if (noColors) { + const savedUseColors = Base.useColors; + Base.useColors = false; + reporter.epilogue(); + Base.useColors = savedUseColors; + } + else { + reporter.epilogue(); + } + + process.exit(errorResults.length); + } + + function makeMochaTest(test: ErrorInfo) { + return { + fullTitle: () => { + return test.name; + }, + err: { + message: test.error, + stack: test.stack + } + }; + } + + describe = ts.noop as any; // Disable unit tests + + return; + } + + const Mocha = require("mocha"); + const Base = Mocha.reporters.Base; + const color = Base.color; + const cursor = Base.cursor; + const readline = require("readline"); + const os = require("os"); + const tty: { isatty(x: number): boolean } = require("tty"); + const isatty = tty.isatty(1) && tty.isatty(2); + class ProgressBars { + public readonly _options: Readonly; + private _enabled: boolean; + private _lineCount: number; + private _progressBars: ProgressBar[]; + constructor(options?: Partial) { + if (!options) options = {}; + const open = options.open || "["; + const close = options.close || "]"; + const complete = options.complete || "▬"; + const incomplete = options.incomplete || Base.symbols.dot; + const maxWidth = Base.window.width - open.length - close.length - 30; + const width = minMax(options.width || maxWidth, 10, maxWidth); + this._options = { + open, + complete, + incomplete, + close, + width, + noColors: options.noColors || false + }; + + this._progressBars = []; + this._lineCount = 0; + this._enabled = false; + } + enable() { + if (!this._enabled) { + process.stdout.write(os.EOL); + this._enabled = true; + } + } + disable() { + if (this._enabled) { + process.stdout.write(os.EOL); + this._enabled = false; + } + } + update(index: number, percentComplete: number, color: string, title: string, titleColor?: string) { + percentComplete = minMax(percentComplete, 0, 1); + + const progressBar = this._progressBars[index] || (this._progressBars[index] = { }); + const width = this._options.width; + const n = Math.floor(width * percentComplete); + const i = width - n; + if (n === progressBar.lastN && title === progressBar.title && color === progressBar.progressColor) { + return; + } + + progressBar.lastN = n; + progressBar.title = title; + progressBar.progressColor = color; + + let progress = " "; + progress += this._color("progress", this._options.open); + progress += this._color(color, fill(this._options.complete, n)); + progress += this._color("progress", fill(this._options.incomplete, i)); + progress += this._color("progress", this._options.close); + + if (title) { + progress += this._color(titleColor || "progress", " " + title); + } + + if (progressBar.text !== progress) { + progressBar.text = progress; + this._render(index); + } + } + private _render(index: number) { + if (!this._enabled || !isatty) { + return; + } + + cursor.hide(); + readline.moveCursor(process.stdout, -process.stdout.columns, -this._lineCount); + let lineCount = 0; + const numProgressBars = this._progressBars.length; + for (let i = 0; i < numProgressBars; i++) { + if (i === index) { + readline.clearLine(process.stdout, 1); + process.stdout.write(this._progressBars[i].text + os.EOL); + } + else { + readline.moveCursor(process.stdout, -process.stdout.columns, +1); + } + + lineCount++; + } + + this._lineCount = lineCount; + cursor.show(); + } + private _color(type: string, text: string) { + return type && !this._options.noColors ? color(type, text) : text; + } + } + + function fill(ch: string, size: number) { + let s = ""; + while (s.length < size) { + s += ch; + } + + return s.length > size ? s.substr(0, size) : s; + } + + function minMax(value: number, min: number, max: number) { + if (value < min) return min; + if (value > max) return max; + return value; + } +} \ No newline at end of file diff --git a/src/harness/parallel/shared.ts b/src/harness/parallel/shared.ts new file mode 100644 index 00000000000..ebfe3278849 --- /dev/null +++ b/src/harness/parallel/shared.ts @@ -0,0 +1,14 @@ +/// +/// +namespace Harness.Parallel { + export type ParallelTestMessage = { type: "test", payload: { runner: TestRunnerKind, file: string } } | never; + export type ParallelBatchMessage = { type: "batch", payload: ParallelTestMessage["payload"][] } | never; + export type ParallelCloseMessage = { type: "close" } | never; + export type ParallelHostMessage = ParallelTestMessage | ParallelCloseMessage | ParallelBatchMessage; + + export type ParallelErrorMessage = { type: "error", payload: { error: string, stack: string } } | never; + export type ErrorInfo = ParallelErrorMessage["payload"] & { name: string }; + export type ParallelResultMessage = { type: "result", payload: { passing: number, errors: ErrorInfo[] } } | never; + export type ParallelBatchProgressMessage = { type: "progress", payload: ParallelResultMessage["payload"] } | never; + export type ParallelClientMessage = ParallelErrorMessage | ParallelResultMessage | ParallelBatchProgressMessage; +} \ No newline at end of file diff --git a/src/harness/parallel/worker.ts b/src/harness/parallel/worker.ts new file mode 100644 index 00000000000..34f89d37f13 --- /dev/null +++ b/src/harness/parallel/worker.ts @@ -0,0 +1,123 @@ +namespace Harness.Parallel.Worker { + let errors: ErrorInfo[] = []; + let passing = 0; + function resetShimHarnessAndExecute(runner: RunnerBase) { + errors = []; + passing = 0; + runner.initializeTests(); + return { errors, passing }; + } + + function shimMochaHarness() { + (global as any).before = undefined; + (global as any).after = undefined; + (global as any).beforeEach = undefined; + let beforeEachFunc: Function; + describe = ((_name, callback) => { + const fakeContext: Mocha.ISuiteCallbackContext = { + retries() { return this; }, + slow() { return this; }, + timeout() { return this; }, + }; + (before as any) = (cb: Function) => cb(); + let afterFunc: Function; + (after as any) = (cb: Function) => afterFunc = cb; + const savedBeforeEach = beforeEachFunc; + (beforeEach as any) = (cb: Function) => beforeEachFunc = cb; + callback.call(fakeContext); + afterFunc && afterFunc(); + afterFunc = undefined; + beforeEachFunc = savedBeforeEach; + }) as Mocha.IContextDefinition; + it = ((name, callback) => { + const fakeContext: Mocha.ITestCallbackContext = { + skip() { return this; }, + timeout() { return this; }, + retries() { return this; }, + slow() { return this; }, + }; + // TODO: If we ever start using async test completions, polyfill the `done` parameter/promise return handling + if (beforeEachFunc) { + try { + beforeEachFunc(); + } + catch (error) { + errors.push({ error: error.message, stack: error.stack, name }); + return; + } + } + try { + callback.call(fakeContext); + } + catch (error) { + errors.push({ error: error.message, stack: error.stack, name }); + return; + } + passing++; + }) as Mocha.ITestDefinition; + } + + export function start() { + let initialized = false; + const runners = ts.createMap(); + process.on("message", (data: ParallelHostMessage) => { + if (!initialized) { + initialized = true; + shimMochaHarness(); + } + switch (data.type) { + case "test": + const { runner, file } = data.payload; + if (!runner) { + console.error(data); + } + const message: ParallelResultMessage = { type: "result", payload: handleTest(runner, file) }; + process.send(message); + break; + case "close": + process.exit(0); + break; + case "batch": { + const items = data.payload; + for (let i = 0; i < items.length; i++) { + const { runner, file } = items[i]; + if (!runner) { + console.error(data); + } + let message: ParallelBatchProgressMessage | ParallelResultMessage; + const payload = handleTest(runner, file); + if (i === (items.length - 1)) { + message = { type: "result", payload }; + } + else { + message = { type: "progress", payload }; + } + process.send(message); + } + break; + } + } + }); + process.on("uncaughtException", error => { + const message: ParallelErrorMessage = { type: "error", payload: { error: error.message, stack: error.stack } }; + process.send(message); + }); + if (!runUnitTests) { + // ensure unit tests do not get run + describe = ts.noop as any; + } + else { + initialized = true; + shimMochaHarness(); + } + + function handleTest(runner: TestRunnerKind, file: string) { + if (!runners.has(runner)) { + runners.set(runner, createRunner(runner)); + } + const instance = runners.get(runner); + instance.tests = [file]; + return resetShimHarnessAndExecute(instance); + } + } +} \ No newline at end of file diff --git a/src/harness/runner.ts b/src/harness/runner.ts index 6e1f91b21af..0b361e7fc9e 100644 --- a/src/harness/runner.ts +++ b/src/harness/runner.ts @@ -19,6 +19,7 @@ /// /// /// +/// let runners: RunnerBase[] = []; let iterations = 1; @@ -59,6 +60,7 @@ function createRunner(kind: TestRunnerKind): RunnerBase { case "test262": return new Test262BaselineRunner(); } + ts.Debug.fail(`Unknown runner kind ${kind}`); } if (Harness.IO.tryEnableSourceMapsForHost && /^development$/i.test(Harness.IO.getEnvironmentVariable("NODE_ENV"))) { @@ -81,15 +83,17 @@ let testConfigContent = let taskConfigsFolder: string; let workerCount: number; let runUnitTests = true; +let noColors = false; interface TestConfig { light?: boolean; taskConfigsFolder?: string; + listenForWork?: boolean; workerCount?: number; stackTraceLimit?: number | "full"; - tasks?: TaskSet[]; test?: string[]; runUnitTests?: boolean; + noColors?: boolean; } interface TaskSet { @@ -97,138 +101,122 @@ interface TaskSet { files: string[]; } -if (testConfigContent !== "") { - const testConfig = JSON.parse(testConfigContent); - if (testConfig.light) { - Harness.lightMode = true; - } - if (testConfig.taskConfigsFolder) { - taskConfigsFolder = testConfig.taskConfigsFolder; - } - if (testConfig.runUnitTests !== undefined) { - runUnitTests = testConfig.runUnitTests; - } - if (testConfig.workerCount) { - workerCount = testConfig.workerCount; - } - if (testConfig.tasks) { - for (const taskSet of testConfig.tasks) { - const runner = createRunner(taskSet.runner); - for (const file of taskSet.files) { - runner.addTest(file); - } - runners.push(runner); +function handleTestConfig() { + if (testConfigContent !== "") { + const testConfig = JSON.parse(testConfigContent); + if (testConfig.light) { + Harness.lightMode = true; } - } - - if (testConfig.stackTraceLimit === "full") { - (Error).stackTraceLimit = Infinity; - } - else if ((+testConfig.stackTraceLimit | 0) > 0) { - (Error).stackTraceLimit = testConfig.stackTraceLimit; - } - - if (testConfig.test && testConfig.test.length > 0) { - for (const option of testConfig.test) { - if (!option) { - continue; - } - - switch (option) { - case "compiler": - runners.push(new CompilerBaselineRunner(CompilerTestType.Conformance)); - runners.push(new CompilerBaselineRunner(CompilerTestType.Regressions)); - runners.push(new ProjectRunner()); - break; - case "conformance": - runners.push(new CompilerBaselineRunner(CompilerTestType.Conformance)); - break; - case "project": - runners.push(new ProjectRunner()); - break; - case "fourslash": - runners.push(new FourSlashRunner(FourSlashTestType.Native)); - break; - case "fourslash-shims": - runners.push(new FourSlashRunner(FourSlashTestType.Shims)); - break; - case "fourslash-shims-pp": - runners.push(new FourSlashRunner(FourSlashTestType.ShimsWithPreprocess)); - break; - case "fourslash-server": - runners.push(new FourSlashRunner(FourSlashTestType.Server)); - break; - case "fourslash-generated": - runners.push(new GeneratedFourslashRunner(FourSlashTestType.Native)); - break; - case "rwc": - runners.push(new RWCRunner()); - break; - case "test262": - runners.push(new Test262BaselineRunner()); - break; - } + if (testConfig.runUnitTests !== undefined) { + runUnitTests = testConfig.runUnitTests; + } + if (testConfig.workerCount) { + workerCount = +testConfig.workerCount; + } + if (testConfig.taskConfigsFolder) { + taskConfigsFolder = testConfig.taskConfigsFolder; + } + if (testConfig.noColors !== undefined) { + noColors = testConfig.noColors; } - } -} -if (runners.length === 0) { - // compiler - runners.push(new CompilerBaselineRunner(CompilerTestType.Conformance)); - runners.push(new CompilerBaselineRunner(CompilerTestType.Regressions)); + if (testConfig.stackTraceLimit === "full") { + (Error).stackTraceLimit = Infinity; + } + else if ((+testConfig.stackTraceLimit | 0) > 0) { + (Error).stackTraceLimit = testConfig.stackTraceLimit; + } + if (testConfig.listenForWork) { + return true; + } - // TODO: project tests don't work in the browser yet - if (Utils.getExecutionEnvironment() !== Utils.ExecutionEnvironment.Browser) { - runners.push(new ProjectRunner()); - } + if (testConfig.test && testConfig.test.length > 0) { + for (const option of testConfig.test) { + if (!option) { + continue; + } - // language services - runners.push(new FourSlashRunner(FourSlashTestType.Native)); - runners.push(new FourSlashRunner(FourSlashTestType.Shims)); - runners.push(new FourSlashRunner(FourSlashTestType.ShimsWithPreprocess)); - runners.push(new FourSlashRunner(FourSlashTestType.Server)); - // runners.push(new GeneratedFourslashRunner()); -} - -if (taskConfigsFolder) { - // this instance of mocha should only partition work but not run actual tests - runUnitTests = false; - const workerConfigs: TestConfig[] = []; - for (let i = 0; i < workerCount; i++) { - // pass light mode settings to workers - workerConfigs.push({ light: Harness.lightMode, tasks: [] }); - } - - for (const runner of runners) { - const files = runner.enumerateTestFiles(); - const chunkSize = Math.floor(files.length / workerCount) + 1; // add extra 1 to prevent missing tests due to rounding - for (let i = 0; i < workerCount; i++) { - const startPos = i * chunkSize; - const len = Math.min(chunkSize, files.length - startPos); - if (len > 0) { - workerConfigs[i].tasks.push({ - runner: runner.kind(), - files: files.slice(startPos, startPos + len) - }); + switch (option) { + case "compiler": + runners.push(new CompilerBaselineRunner(CompilerTestType.Conformance)); + runners.push(new CompilerBaselineRunner(CompilerTestType.Regressions)); + runners.push(new ProjectRunner()); + break; + case "conformance": + runners.push(new CompilerBaselineRunner(CompilerTestType.Conformance)); + break; + case "project": + runners.push(new ProjectRunner()); + break; + case "fourslash": + runners.push(new FourSlashRunner(FourSlashTestType.Native)); + break; + case "fourslash-shims": + runners.push(new FourSlashRunner(FourSlashTestType.Shims)); + break; + case "fourslash-shims-pp": + runners.push(new FourSlashRunner(FourSlashTestType.ShimsWithPreprocess)); + break; + case "fourslash-server": + runners.push(new FourSlashRunner(FourSlashTestType.Server)); + break; + case "fourslash-generated": + runners.push(new GeneratedFourslashRunner(FourSlashTestType.Native)); + break; + case "rwc": + runners.push(new RWCRunner()); + break; + case "test262": + runners.push(new Test262BaselineRunner()); + break; + } } } } - for (let i = 0; i < workerCount; i++) { - const config = workerConfigs[i]; - // use last worker to run unit tests if we're not just running a single specific runner - config.runUnitTests = runners.length !== 1 && i === workerCount - 1; - Harness.IO.writeFile(ts.combinePaths(taskConfigsFolder, `task-config${i}.json`), JSON.stringify(workerConfigs[i])); + if (runners.length === 0) { + // compiler + runners.push(new CompilerBaselineRunner(CompilerTestType.Conformance)); + runners.push(new CompilerBaselineRunner(CompilerTestType.Regressions)); + + // TODO: project tests don"t work in the browser yet + if (Utils.getExecutionEnvironment() !== Utils.ExecutionEnvironment.Browser) { + runners.push(new ProjectRunner()); + } + + // language services + runners.push(new FourSlashRunner(FourSlashTestType.Native)); + runners.push(new FourSlashRunner(FourSlashTestType.Shims)); + runners.push(new FourSlashRunner(FourSlashTestType.ShimsWithPreprocess)); + runners.push(new FourSlashRunner(FourSlashTestType.Server)); + // runners.push(new GeneratedFourslashRunner()); } } -else { + +function beginTests() { if (ts.Debug.isDebugging) { ts.Debug.enableDebugInfo(); } runTests(runners); + + if (!runUnitTests) { + // patch `describe` to skip unit tests + describe = ts.noop as any; + } } -if (!runUnitTests) { - // patch `describe` to skip unit tests - describe = ts.noop as any; + +function startTestEnvironment() { + const isWorker = handleTestConfig(); + if (Utils.getExecutionEnvironment() !== Utils.ExecutionEnvironment.Browser) { + if (isWorker) { + return Harness.Parallel.Worker.start(); + } + else if (taskConfigsFolder && workerCount && workerCount > 1) { + return Harness.Parallel.Host.start(); + } + } + beginTests(); } + +startTestEnvironment(); diff --git a/src/harness/tsconfig.json b/src/harness/tsconfig.json index bd7c9bc2ffa..c6e78138638 100644 --- a/src/harness/tsconfig.json +++ b/src/harness/tsconfig.json @@ -92,6 +92,9 @@ "loggedIO.ts", "rwcRunner.ts", "test262Runner.ts", + "./parallel/shared.ts", + "./parallel/host.ts", + "./parallel/worker.ts", "runner.ts", "../server/protocol.ts", "../server/session.ts", From f3411d4361300081151db3ba51fe706bfa97c347 Mon Sep 17 00:00:00 2001 From: Andrew Casey Date: Thu, 14 Sep 2017 15:35:47 -0700 Subject: [PATCH 346/370] Only decrement activeRequestCount on SetTypings responses InvalidateCache responses are triggered by file watchers, rather than by requests. --- src/server/server.ts | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/src/server/server.ts b/src/server/server.ts index f031d5f0cfc..fe83e879433 100644 --- a/src/server/server.ts +++ b/src/server/server.ts @@ -433,23 +433,25 @@ namespace ts.server { return; } - if (this.activeRequestCount > 0) { - this.activeRequestCount--; - } - else { - Debug.fail("Received too many responses"); - } - - while (this.requestQueue.length > 0) { - const queuedRequest = this.requestQueue.shift(); - if (this.requestMap.get(queuedRequest.operationId) === queuedRequest) { - this.requestMap.delete(queuedRequest.operationId); - this.scheduleRequest(queuedRequest); - break; + if (response.kind === ActionSet) { + if (this.activeRequestCount > 0) { + this.activeRequestCount--; + } + else { + Debug.fail("Received too many responses"); } - if (this.logger.hasLevel(LogLevel.verbose)) { - this.logger.info(`Skipping defunct request for: ${queuedRequest.operationId}`); + while (this.requestQueue.length > 0) { + const queuedRequest = this.requestQueue.shift(); + if (this.requestMap.get(queuedRequest.operationId) === queuedRequest) { + this.requestMap.delete(queuedRequest.operationId); + this.scheduleRequest(queuedRequest); + break; + } + + if (this.logger.hasLevel(LogLevel.verbose)) { + this.logger.info(`Skipping defunct request for: ${queuedRequest.operationId}`); + } } } From fd4a8d1516e5e5ae8c0c8b7f47ed4191a1799e68 Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Thu, 14 Sep 2017 16:22:14 -0700 Subject: [PATCH 347/370] Let the RWC harness iterate over files instead of building one big file (#18416) * Let the RWC harness iterate over files instead of building one big file * Handle duplicated-only-in-case outputs better in the type baseliner * Always lowercase output names * Move common code into helper function * Always write .delete for missing files even if there were errors --- Jakefile.js | 6 +- src/harness/harness.ts | 196 +++++++++++++++++++++++++++++++-------- src/harness/rwcRunner.ts | 30 +++--- 3 files changed, 177 insertions(+), 55 deletions(-) diff --git a/Jakefile.js b/Jakefile.js index 39e9e8a0421..6fd2f549015 100644 --- a/Jakefile.js +++ b/Jakefile.js @@ -769,15 +769,16 @@ function exec(cmd, completeHandler, errorHandler) { ex.run(); } +const del = require("del"); function cleanTestDirs() { // Clean the local baselines directory if (fs.existsSync(localBaseline)) { - jake.rmRf(localBaseline); + del.sync(localBaseline); } // Clean the local Rwc baselines directory if (fs.existsSync(localRwcBaseline)) { - jake.rmRf(localRwcBaseline); + del.sync(localRwcBaseline); } jake.mkdirP(localRwcBaseline); @@ -1042,6 +1043,7 @@ function acceptBaseline(sourceFolder, targetFolder) { if (fs.existsSync(target)) { fs.unlinkSync(target); } + jake.mkdirP(path.dirname(target)); fs.renameSync(path.join(sourceFolder, filename), target); } } diff --git a/src/harness/harness.ts b/src/harness/harness.ts index 8344be36753..7a6c061c6d4 100644 --- a/src/harness/harness.ts +++ b/src/harness/harness.ts @@ -1291,11 +1291,25 @@ namespace Harness { } export function getErrorBaseline(inputFiles: ReadonlyArray, diagnostics: ReadonlyArray, pretty?: boolean) { + let outputLines = ""; + const gen = iterateErrorBaseline(inputFiles, diagnostics, pretty); + for (let {done, value} = gen.next(); !done; { done, value } = gen.next()) { + const [, content] = value; + outputLines += content; + } + return outputLines; + } + + export const diagnosticSummaryMarker = "__diagnosticSummary"; + export const globalErrorsMarker = "__globalErrors"; + export function *iterateErrorBaseline(inputFiles: ReadonlyArray, diagnostics: ReadonlyArray, pretty?: boolean): IterableIterator<[string, string, number]> { diagnostics = diagnostics.slice().sort(ts.compareDiagnostics); let outputLines = ""; // Count up all errors that were found in files other than lib.d.ts so we don't miss any let totalErrorsReportedInNonLibraryFiles = 0; + let errorsReported = 0; + let firstLine = true; function newLine() { if (firstLine) { @@ -1314,6 +1328,7 @@ namespace Harness { .filter(s => s.length > 0) .map(s => "!!! " + ts.DiagnosticCategory[error.category].toLowerCase() + " TS" + error.code + ": " + s); errLines.forEach(e => outputLines += (newLine() + e)); + errorsReported++; // 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) @@ -1325,12 +1340,18 @@ namespace Harness { } } + yield [diagnosticSummaryMarker, minimalDiagnosticsToString(diagnostics, pretty) + Harness.IO.newLine() + Harness.IO.newLine(), diagnostics.length]; + // Report global errors const globalErrors = diagnostics.filter(err => !err.file); globalErrors.forEach(outputErrorText); + yield [globalErrorsMarker, outputLines, errorsReported]; + outputLines = ""; + errorsReported = 0; // 'merge' the lines of each input file with any errors associated with it - inputFiles.filter(f => f.content !== undefined).forEach(inputFile => { + const dupeCase = ts.createMap(); + for (const inputFile of inputFiles.filter(f => f.content !== undefined)) { // Filter down to the errors in the file const fileErrors = diagnostics.filter(e => { const errFn = e.file; @@ -1396,7 +1417,10 @@ namespace Harness { // Verify we didn't miss any errors in this file assert.equal(markedErrorCount, fileErrors.length, "count of errors in " + inputFile.unitName); - }); + yield [checkDuplicatedFileName(inputFile.unitName, dupeCase), outputLines, errorsReported]; + outputLines = ""; + errorsReported = 0; + } const numLibraryDiagnostics = ts.countWhere(diagnostics, diagnostic => { return diagnostic.file && (isDefaultLibraryFile(diagnostic.file.fileName) || isBuiltFile(diagnostic.file.fileName)); @@ -1409,9 +1433,6 @@ namespace Harness { // Verify we didn't miss any errors in total assert.equal(totalErrorsReportedInNonLibraryFiles + numLibraryDiagnostics + numTest262HarnessDiagnostics, diagnostics.length, "total number of errors"); - - return minimalDiagnosticsToString(diagnostics, pretty) + - Harness.IO.newLine() + Harness.IO.newLine() + outputLines; } export function doErrorBaseline(baselinePath: string, inputFiles: TestFile[], errors: ts.Diagnostic[], pretty?: boolean) { @@ -1425,7 +1446,7 @@ namespace Harness { }); } - export function doTypeAndSymbolBaseline(baselinePath: string, result: CompilerResult, allFiles: {unitName: string, content: string}[], opts?: Harness.Baseline.BaselineOptions) { + export function doTypeAndSymbolBaseline(baselinePath: string, result: CompilerResult, allFiles: {unitName: string, content: string}[], opts?: Harness.Baseline.BaselineOptions, multifile?: boolean) { if (result.errors.length !== 0) { return; } @@ -1486,24 +1507,42 @@ namespace Harness { return; function checkBaseLines(isSymbolBaseLine: boolean) { - const fullBaseLine = generateBaseLine(fullResults, isSymbolBaseLine); - const fullExtension = isSymbolBaseLine ? ".symbols" : ".types"; - // When calling this function from rwc-runner, the baselinePath will have no extension. // As rwc test- file is stored in json which ".json" will get stripped off. // When calling this function from compiler-runner, the baselinePath will then has either ".ts" or ".tsx" extension const outputFileName = ts.endsWith(baselinePath, ts.Extension.Ts) || ts.endsWith(baselinePath, ts.Extension.Tsx) ? - baselinePath.replace(/\.tsx?/, fullExtension) : baselinePath.concat(fullExtension); - Harness.Baseline.runBaseline(outputFileName, () => fullBaseLine, opts); + baselinePath.replace(/\.tsx?/, "") : baselinePath; + + if (!multifile) { + const fullBaseLine = generateBaseLine(fullResults, isSymbolBaseLine); + Harness.Baseline.runBaseline(outputFileName + fullExtension, () => fullBaseLine, opts); + } + else { + Harness.Baseline.runMultifileBaseline(outputFileName, fullExtension, () => { + return iterateBaseLine(fullResults, isSymbolBaseLine); + }, opts); + } } function generateBaseLine(typeWriterResults: ts.Map, isSymbolBaseline: boolean): string { - const typeLines: string[] = []; - const typeMap: { [fileName: string]: { [lineNum: number]: string[]; } } = {}; + let result = ""; + const gen = iterateBaseLine(typeWriterResults, isSymbolBaseline); + for (let {done, value} = gen.next(); !done; { done, value } = gen.next()) { + const [, content] = value; + result += content; + } + return result; + } - allFiles.forEach(file => { + function *iterateBaseLine(typeWriterResults: ts.Map, isSymbolBaseline: boolean): IterableIterator<[string, string]> { + let typeLines = ""; + const typeMap: { [fileName: string]: { [lineNum: number]: string[]; } } = {}; + const dupeCase = ts.createMap(); + + for (const file of allFiles) { const codeLines = file.content.split("\n"); + const key = file.unitName; typeWriterResults.get(file.unitName).forEach(result => { if (isSymbolBaseline && !result.symbol) { return; @@ -1511,42 +1550,42 @@ namespace Harness { const typeOrSymbolString = isSymbolBaseline ? result.symbol : result.type; const formattedLine = result.sourceText.replace(/\r?\n/g, "") + " : " + typeOrSymbolString; - if (!typeMap[file.unitName]) { - typeMap[file.unitName] = {}; + if (!typeMap[key]) { + typeMap[key] = {}; } let typeInfo = [formattedLine]; - const existingTypeInfo = typeMap[file.unitName][result.line]; + const existingTypeInfo = typeMap[key][result.line]; if (existingTypeInfo) { typeInfo = existingTypeInfo.concat(typeInfo); } - typeMap[file.unitName][result.line] = typeInfo; + typeMap[key][result.line] = typeInfo; }); - typeLines.push("=== " + file.unitName + " ===\r\n"); + typeLines += "=== " + file.unitName + " ===\r\n"; for (let i = 0; i < codeLines.length; i++) { const currentCodeLine = codeLines[i]; - typeLines.push(currentCodeLine + "\r\n"); - if (typeMap[file.unitName]) { - const typeInfo = typeMap[file.unitName][i]; + typeLines += currentCodeLine + "\r\n"; + if (typeMap[key]) { + const typeInfo = typeMap[key][i]; if (typeInfo) { typeInfo.forEach(ty => { - typeLines.push(">" + ty + "\r\n"); + typeLines += ">" + ty + "\r\n"; }); if (i + 1 < codeLines.length && (codeLines[i + 1].match(/^\s*[{|}]\s*$/) || codeLines[i + 1].trim() === "")) { } else { - typeLines.push("\r\n"); + typeLines += "\r\n"; } } } else { - typeLines.push("No type information for this code."); + typeLines += "No type information for this code."; } } - }); - - return typeLines.join(""); + yield [checkDuplicatedFileName(file.unitName, dupeCase), typeLines]; + typeLines = ""; + } } } @@ -1642,24 +1681,29 @@ namespace Harness { } export function collateOutputs(outputFiles: Harness.Compiler.GeneratedFile[]): string { - // Collect, test, and sort the fileNames - outputFiles.sort((a, b) => ts.compareStrings(cleanName(a.fileName), cleanName(b.fileName))); - + const gen = iterateOutputs(outputFiles); // Emit them let result = ""; - for (const outputFile of outputFiles) { + for (let {done, value} = gen.next(); !done; { done, value } = gen.next()) { // Some extra spacing if this isn't the first file if (result.length) { result += "\r\n\r\n"; } - // FileName header + content - result += "/*====== " + outputFile.fileName + " ======*/\r\n"; - - result += outputFile.code; + const [, content] = value; + result += content; } - return result; + } + + export function *iterateOutputs(outputFiles: Harness.Compiler.GeneratedFile[]): IterableIterator<[string, string]> { + // Collect, test, and sort the fileNames + outputFiles.sort((a, b) => ts.compareStrings(cleanName(a.fileName), cleanName(b.fileName))); + const dupeCase = ts.createMap(); + // Yield them + for (const outputFile of outputFiles) { + yield [checkDuplicatedFileName(outputFile.fileName, dupeCase), "/*====== " + outputFile.fileName + " ======*/\r\n" + outputFile.code]; + } function cleanName(fn: string) { const lastSlash = ts.normalizeSlashes(fn).lastIndexOf("/"); @@ -1667,6 +1711,24 @@ namespace Harness { } } + function checkDuplicatedFileName(resultName: string, dupeCase: ts.Map): string { + resultName = sanitizeTestFilePath(resultName); + if (dupeCase.has(resultName)) { + // A different baseline filename should be manufactured if the names differ only in case, for windows compat + const count = 1 + dupeCase.get(resultName); + dupeCase.set(resultName, count); + resultName = `${resultName}.dupe${count}`; + } + else { + dupeCase.set(resultName, 0); + } + return resultName; + } + + function sanitizeTestFilePath(name: string) { + return ts.normalizeSlashes(name.replace(/[\^<>:"|?*%]/g, "_")).replace(/\.\.\//g, "__dotdot/").toLowerCase(); + } + // This does not need to exist strictly speaking, but many tests will need to be updated if it's removed export function compileString(_code: string, _unitName: string, _callback: (result: CompilerResult) => void) { // NEWTODO: Re-implement 'compileString' @@ -2004,6 +2066,66 @@ namespace Harness { const comparison = compareToBaseline(actual, relativeFileName, opts); writeComparison(comparison.expected, comparison.actual, relativeFileName, actualFileName); } + + export function runMultifileBaseline(relativeFileBase: string, extension: string, generateContent: () => IterableIterator<[string, string, number]> | IterableIterator<[string, string]>, opts?: BaselineOptions, referencedExtensions?: string[]): void { + const gen = generateContent(); + const writtenFiles = ts.createMap(); + const canonicalize = ts.createGetCanonicalFileName(/*caseSensitive*/ false); // This is done so tests work on windows _and_ linux + /* tslint:disable-next-line:no-null-keyword */ + const errors: Error[] = []; + if (gen !== null) { + for (let {done, value} = gen.next(); !done; { done, value } = gen.next()) { + const [name, content, count] = value as [string, string, number | undefined]; + if (count === 0) continue; // Allow error reporter to skip writing files without errors + const relativeFileName = ts.combinePaths(relativeFileBase, name) + extension; + const actualFileName = localPath(relativeFileName, opts && opts.Baselinefolder, opts && opts.Subfolder); + const actual = content; + const comparison = compareToBaseline(actual, relativeFileName, opts); + try { + writeComparison(comparison.expected, comparison.actual, relativeFileName, actualFileName); + } + catch (e) { + errors.push(e); + } + const path = ts.toPath(relativeFileName, "", canonicalize); + writtenFiles.set(path, true); + } + } + + const referenceDir = referencePath(relativeFileBase, opts && opts.Baselinefolder, opts && opts.Subfolder); + let existing = Harness.IO.readDirectory(referenceDir, referencedExtensions || [extension]); + if (extension === ".ts" || referencedExtensions && referencedExtensions.indexOf(".ts") > -1 && referencedExtensions.indexOf(".d.ts") === -1) { + // special-case and filter .d.ts out of .ts results + existing = existing.filter(f => !ts.endsWith(f, ".d.ts")); + } + const missing: string[] = []; + for (const name of existing) { + const localCopy = name.substring(referenceDir.length - relativeFileBase.length); + const path = ts.toPath(localCopy, "", canonicalize); + if (!writtenFiles.has(path)) { + missing.push(localCopy); + } + } + if (missing.length) { + for (const file of missing) { + IO.writeFile(localPath(file + ".delete", opts && opts.Baselinefolder, opts && opts.Subfolder), ""); + } + } + + if (errors.length || missing.length) { + let errorMsg = ""; + if (errors.length) { + errorMsg += `The baseline for ${relativeFileBase} has changed:${"\n " + errors.map(e => e.message).join("\n ")}`; + } + if (errors.length && missing.length) { + errorMsg += "\n"; + } + if (missing.length) { + errorMsg += `Baseline missing files:${"\n " + missing.join("\n ") + "\n"}Written:${"\n " + ts.arrayFrom(writtenFiles.keys()).join("\n ")}`; + } + throw new Error(errorMsg); + } + } } export function isDefaultLibraryFile(filePath: string): boolean { diff --git a/src/harness/rwcRunner.ts b/src/harness/rwcRunner.ts index b3ef80b2a31..1f398118c06 100644 --- a/src/harness/rwcRunner.ts +++ b/src/harness/rwcRunner.ts @@ -170,29 +170,29 @@ namespace RWC { it("has the expected emitted code", () => { - Harness.Baseline.runBaseline(`${baseName}.output.js`, () => { - return Harness.Compiler.collateOutputs(compilerResult.files); - }, baselineOpts); + Harness.Baseline.runMultifileBaseline(baseName, "", () => { + return Harness.Compiler.iterateOutputs(compilerResult.files); + }, baselineOpts, [".js", ".jsx"]); }); it("has the expected declaration file content", () => { - Harness.Baseline.runBaseline(`${baseName}.d.ts`, () => { + Harness.Baseline.runMultifileBaseline(baseName, "", () => { if (!compilerResult.declFilesCode.length) { return null; } - return Harness.Compiler.collateOutputs(compilerResult.declFilesCode); - }, baselineOpts); + return Harness.Compiler.iterateOutputs(compilerResult.declFilesCode); + }, baselineOpts, [".d.ts"]); }); it("has the expected source maps", () => { - Harness.Baseline.runBaseline(`${baseName}.map`, () => { + Harness.Baseline.runMultifileBaseline(baseName, "", () => { if (!compilerResult.sourceMaps.length) { return null; } - return Harness.Compiler.collateOutputs(compilerResult.sourceMaps); - }, baselineOpts); + return Harness.Compiler.iterateOutputs(compilerResult.sourceMaps); + }, baselineOpts, [".map"]); }); /*it("has correct source map record", () => { @@ -204,14 +204,14 @@ namespace RWC { });*/ it("has the expected errors", () => { - Harness.Baseline.runBaseline(`${baseName}.errors.txt`, () => { + Harness.Baseline.runMultifileBaseline(baseName, ".errors.txt", () => { if (compilerResult.errors.length === 0) { return null; } // Do not include the library in the baselines to avoid noise const baselineFiles = tsconfigFiles.concat(inputFiles, otherFiles).filter(f => !Harness.isDefaultLibraryFile(f.unitName)); const errors = compilerResult.errors.filter(e => !e.file || !Harness.isDefaultLibraryFile(e.file.fileName)); - return Harness.Compiler.getErrorBaseline(baselineFiles, errors); + return Harness.Compiler.iterateErrorBaseline(baselineFiles, errors); }, baselineOpts); }); @@ -220,14 +220,14 @@ namespace RWC { Harness.Compiler.doTypeAndSymbolBaseline(baseName, compilerResult, inputFiles .concat(otherFiles) .filter(file => !!compilerResult.program.getSourceFile(file.unitName)) - .filter(e => !Harness.isDefaultLibraryFile(e.unitName)), baselineOpts); + .filter(e => !Harness.isDefaultLibraryFile(e.unitName)), baselineOpts, /*multifile*/ true); }); // Ideally, a generated declaration file will have no errors. But we allow generated // declaration file errors as part of the baseline. it("has the expected errors in generated declaration files", () => { if (compilerOptions.declaration && !compilerResult.errors.length) { - Harness.Baseline.runBaseline(`${baseName}.dts.errors.txt`, () => { + Harness.Baseline.runMultifileBaseline(baseName, ".dts.errors.txt", () => { if (compilerResult.errors.length === 0) { return null; } @@ -239,9 +239,7 @@ namespace RWC { compilerResult = undefined; const declFileCompilationResult = Harness.Compiler.compileDeclarationFiles(declContext); - return Harness.Compiler.minimalDiagnosticsToString(declFileCompilationResult.declResult.errors) + - Harness.IO.newLine() + Harness.IO.newLine() + - Harness.Compiler.getErrorBaseline(tsconfigFiles.concat(declFileCompilationResult.declInputFiles, declFileCompilationResult.declOtherFiles), declFileCompilationResult.declResult.errors); + return Harness.Compiler.iterateErrorBaseline(tsconfigFiles.concat(declFileCompilationResult.declInputFiles, declFileCompilationResult.declOtherFiles), declFileCompilationResult.declResult.errors); }, baselineOpts); } }); From 0b76e43977d21267350b3f4834604b816bba6382 Mon Sep 17 00:00:00 2001 From: Andy Hanson Date: Fri, 15 Sep 2017 07:21:38 -0700 Subject: [PATCH 348/370] Make formatOptions optional in GetEditsForRefactorRequestArgs --- src/server/protocol.ts | 2 +- src/server/session.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/server/protocol.ts b/src/server/protocol.ts index 1740f8ae0ba..44862c738cc 100644 --- a/src/server/protocol.ts +++ b/src/server/protocol.ts @@ -494,7 +494,7 @@ namespace ts.server.protocol { refactor: string; /* The 'name' property from the refactoring action */ action: string; - formatOptions: FormatCodeSettings, + formatOptions?: FormatCodeSettings, }; diff --git a/src/server/session.ts b/src/server/session.ts index e6ba78b81c9..02eb76eeae8 100644 --- a/src/server/session.ts +++ b/src/server/session.ts @@ -1488,7 +1488,7 @@ namespace ts.server { const result = project.getLanguageService().getEditsForRefactor( file, - convertFormatOptions(args.formatOptions), + args.formatOptions ? convertFormatOptions(args.formatOptions) : this.projectService.getFormatCodeOptions(), position || textRange, args.refactor, args.action From 95594e3ef3fe525bf8d61e6c15b24b951394d817 Mon Sep 17 00:00:00 2001 From: Vakhurin Sergey Date: Fri, 15 Sep 2017 19:12:35 +0300 Subject: [PATCH 349/370] Fixed formatting for multiline initialization of object and class members (#18494) --- src/services/formatting/smartIndenter.ts | 2 ++ tests/cases/fourslash/formattingOnClasses.ts | 8 +++++++- tests/cases/fourslash/formattingOnInvalidCodes.ts | 6 +++--- tests/cases/fourslash/formattingOnObjectLiteral.ts | 4 ++-- 4 files changed, 14 insertions(+), 6 deletions(-) diff --git a/src/services/formatting/smartIndenter.ts b/src/services/formatting/smartIndenter.ts index 4de2e5765e5..4943c566e0b 100644 --- a/src/services/formatting/smartIndenter.ts +++ b/src/services/formatting/smartIndenter.ts @@ -505,6 +505,8 @@ namespace ts.formatting { case SyntaxKind.NamedImports: case SyntaxKind.ExportSpecifier: case SyntaxKind.ImportSpecifier: + case SyntaxKind.PropertyAssignment: + case SyntaxKind.PropertyDeclaration: return true; } return false; diff --git a/tests/cases/fourslash/formattingOnClasses.ts b/tests/cases/fourslash/formattingOnClasses.ts index 0c259dae2ec..7371ea8c66b 100644 --- a/tests/cases/fourslash/formattingOnClasses.ts +++ b/tests/cases/fourslash/formattingOnClasses.ts @@ -79,7 +79,9 @@ /////*62*/ } /////*63*/ protected bar ( ) { } /////*64*/ protected static bar2 ( ) { } -/////*65*/} +/////*65*/ private pv4 : number = +/////*66*/ {}; +/////*END*/} format.document(); goTo.marker("1"); verify.currentLineContentIs("class a {"); @@ -210,4 +212,8 @@ verify.currentLineContentIs(" protected bar() { }"); goTo.marker("64"); verify.currentLineContentIs(" protected static bar2() { }"); goTo.marker("65"); +verify.currentLineContentIs(" private pv4: number ="); +goTo.marker("66"); +verify.currentLineContentIs(" {};"); +goTo.marker("END"); verify.currentLineContentIs("}"); \ No newline at end of file diff --git a/tests/cases/fourslash/formattingOnInvalidCodes.ts b/tests/cases/fourslash/formattingOnInvalidCodes.ts index c5d71020249..d4bc0f8c879 100644 --- a/tests/cases/fourslash/formattingOnInvalidCodes.ts +++ b/tests/cases/fourslash/formattingOnInvalidCodes.ts @@ -238,7 +238,7 @@ verify.currentLineContentIs(" {"); goTo.marker("69"); verify.currentLineContentIs(" 'student':"); goTo.marker("70"); -verify.currentLineContentIs(" { 'id': '1', 'name': 'Linda Jones', 'legacySkill': 'Access, VB 5.0' }"); +verify.currentLineContentIs(" { 'id': '1', 'name': 'Linda Jones', 'legacySkill': 'Access, VB 5.0' }"); goTo.marker("71"); verify.currentLineContentIs(" },"); goTo.marker("72"); @@ -246,7 +246,7 @@ verify.currentLineContentIs(" {"); goTo.marker("73"); verify.currentLineContentIs(" 'student':"); goTo.marker("74"); -verify.currentLineContentIs(" { 'id': '2', 'name': 'Adam Davidson', 'legacySkill': 'Cobol,MainFrame' }"); +verify.currentLineContentIs(" { 'id': '2', 'name': 'Adam Davidson', 'legacySkill': 'Cobol,MainFrame' }"); goTo.marker("75"); verify.currentLineContentIs(" },"); goTo.marker("76"); @@ -254,7 +254,7 @@ verify.currentLineContentIs(" {"); goTo.marker("77"); verify.currentLineContentIs(" 'student':"); goTo.marker("78"); -verify.currentLineContentIs(" { 'id': '3', 'name': 'Charles Boyer', 'legacySkill': 'HTML, XML' }"); +verify.currentLineContentIs(" { 'id': '3', 'name': 'Charles Boyer', 'legacySkill': 'HTML, XML' }"); goTo.marker("79"); verify.currentLineContentIs(" }"); goTo.marker("80"); diff --git a/tests/cases/fourslash/formattingOnObjectLiteral.ts b/tests/cases/fourslash/formattingOnObjectLiteral.ts index 5b8d5f9cb52..7b302d55378 100644 --- a/tests/cases/fourslash/formattingOnObjectLiteral.ts +++ b/tests/cases/fourslash/formattingOnObjectLiteral.ts @@ -72,11 +72,11 @@ verify.currentLineContentIs("var x2 = {"); goTo.marker("21"); verify.currentLineContentIs(" foo:"); goTo.marker("22"); -verify.currentLineContentIs(" 3,"); +verify.currentLineContentIs(" 3,"); goTo.marker("23"); verify.currentLineContentIs(" 'bar':"); goTo.marker("24"); -verify.currentLineContentIs(" { a: 1, b: 2 }"); +verify.currentLineContentIs(" { a: 1, b: 2 }"); goTo.marker("25"); verify.currentLineContentIs("};"); goTo.marker("26"); From 9c6f65175b281438fe5ac935262bb4e3ba5f3c73 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Fri, 15 Sep 2017 10:05:14 -0700 Subject: [PATCH 350/370] Refactor truthy-spread-union creation for performance Only create properties once, only if needed, and don't create an intermediate anonymous type. The code is also inlined with the rest of `getSpreadType`. --- src/compiler/checker.ts | 62 +++++++++++++++-------------------------- 1 file changed, 23 insertions(+), 39 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index a7c98f657dc..2dbf8b9253f 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -7822,6 +7822,7 @@ namespace ts { * and right = the new element to be spread. */ function getSpreadType(left: Type, right: Type): Type { + let truthyRight: Type; if (left.flags & TypeFlags.Any || right.flags & TypeFlags.Any) { return anyType; } @@ -7832,25 +7833,18 @@ namespace ts { return left; } if (left.flags & TypeFlags.Union) { - // if the union is `false | T` make all the properties of T optional - const wl = getPartialTypeFromFalsyUnion(left as UnionType); - if (wl) { - left = wl; - } - else { - return mapType(left, t => getSpreadType(t, right)); - } + return mapType(left, t => getSpreadType(t, right)); } if (right.flags & TypeFlags.Union) { - const wr = getPartialTypeFromFalsyUnion(right as UnionType); - if (wr) { - right = wr; - } - else { + truthyRight = getTruthyTypeFromFalsyUnion(right as UnionType); + if (!truthyRight || truthyRight.flags & TypeFlags.Union) { return mapType(right, t => getSpreadType(left, t)); } + else { + right = truthyRight; + } } - if (right.flags & (TypeFlags.NonPrimitive | TypeFlags.BooleanLike | TypeFlags.NumberLike | TypeFlags.StringLike)) { + if (right.flags & (TypeFlags.NonPrimitive | TypeFlags.BooleanLike | TypeFlags.NumberLike | TypeFlags.StringLike | TypeFlags.EnumLike)) { return emptyObjectType; } @@ -7875,9 +7869,10 @@ namespace ts { skippedPrivateMembers.set(rightProp.escapedName, true); } else if (!isClassMethod(rightProp) && !isSetterWithoutGetter) { - members.set(rightProp.escapedName, getNonReadonlySymbol(rightProp)); + members.set(rightProp.escapedName, getSymbolOfSpreadProperty(rightProp, !!truthyRight)); } } + for (const leftProp of getPropertiesOfType(left)) { if (leftProp.flags & SymbolFlags.SetAccessor && !(leftProp.flags & SymbolFlags.GetAccessor) || skippedPrivateMembers.has(leftProp.escapedName) @@ -7899,19 +7894,22 @@ namespace ts { } } else { - members.set(leftProp.escapedName, getNonReadonlySymbol(leftProp)); + members.set(leftProp.escapedName, getSymbolOfSpreadProperty(leftProp, /*makeOptional*/ false)); } } return createAnonymousType(undefined, members, emptyArray, emptyArray, stringIndexInfo, numberIndexInfo); } - function getNonReadonlySymbol(prop: Symbol) { - if (!isReadonlySymbol(prop)) { + function getSymbolOfSpreadProperty(prop: Symbol, makeOptional: boolean) { + if (!isReadonlySymbol(prop) && (!makeOptional || prop.flags & SymbolFlags.Optional)) { return prop; } - const flags = SymbolFlags.Property | (prop.flags & SymbolFlags.Optional); + const flags = SymbolFlags.Property | (makeOptional ? SymbolFlags.Optional : prop.flags & SymbolFlags.Optional); const result = createSymbol(flags, prop.escapedName); result.type = getTypeOfSymbol(prop); + if (makeOptional) { + result.type = getUnionType([result.type, undefinedType]); + } result.declarations = prop.declarations; result.syntheticOrigin = prop; return result; @@ -7921,25 +7919,10 @@ namespace ts { return prop.flags & SymbolFlags.Method && find(prop.declarations, decl => isClassLike(decl.parent)); } - function getPartialTypeFromFalsyUnion(type: UnionType): Type | undefined { - if (type.types.length === 2) { - const truthy = removeDefinitelyFalsyTypes(type); - if (truthy !== type) { - const members = createSymbolTable(); - for (const prop of getPropertiesOfType(truthy)) { - if (prop.flags & SymbolFlags.Optional) { - members.set(prop.escapedName, prop); - } - else { - const result = createSymbol(prop.flags | SymbolFlags.Optional, prop.escapedName); - result.type = getUnionType([getTypeOfSymbol(prop), undefinedType]); - result.declarations = prop.declarations; - result.syntheticOrigin = prop; - members.set(prop.escapedName, result); - } - } - return createAnonymousType(undefined, members, emptyArray, emptyArray, getIndexInfoOfType(truthy, IndexKind.String), getIndexInfoOfType(truthy, IndexKind.Number)); - } + function getTruthyTypeFromFalsyUnion(type: UnionType): Type | undefined { + const truthy = removeDefinitelyFalsyTypes(type); + if (truthy !== type) { + return truthy; } } @@ -13784,7 +13767,8 @@ namespace ts { } function isValidSpreadType(type: Type): boolean { - return !!(type.flags & (TypeFlags.Any | TypeFlags.PossiblyFalsy | TypeFlags.NonPrimitive) || + return !!(type.flags & (TypeFlags.Any | TypeFlags.NonPrimitive) || + getFalsyFlags(type) & TypeFlags.DefinitelyFalsy && isValidSpreadType(removeDefinitelyFalsyTypes(type)) || type.flags & TypeFlags.Object && !isGenericMappedType(type) || type.flags & TypeFlags.UnionOrIntersection && !forEach((type).types, t => !isValidSpreadType(t))); } From f97d5fa11d594762b4863d297a72ec4d038e4e99 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Fri, 15 Sep 2017 10:06:58 -0700 Subject: [PATCH 351/370] Update tests with improved spread-falsy-union rules --- tests/baselines/reference/objectSpread.js | 42 ++- .../baselines/reference/objectSpread.symbols | 299 ++++++++++-------- tests/baselines/reference/objectSpread.types | 114 +++++-- .../reference/objectSpreadNegative.errors.txt | 49 ++- .../reference/objectSpreadNegative.js | 16 +- .../objectSpreadNegativeParse.errors.txt | 5 +- .../restInvalidArgumentType.errors.txt | 65 +++- .../reference/restInvalidArgumentType.js | 48 ++- tests/baselines/reference/restUnion2.js | 14 +- tests/baselines/reference/restUnion2.symbols | 25 -- tests/baselines/reference/restUnion2.types | 27 -- .../baselines/reference/restUnion3.errors.txt | 17 + tests/baselines/reference/restUnion3.js | 25 ++ .../spreadInvalidArgumentType.errors.txt | 72 ++++- .../reference/spreadInvalidArgumentType.js | 53 +++- tests/baselines/reference/spreadUnion2.js | 5 - .../baselines/reference/spreadUnion2.symbols | 45 +-- tests/baselines/reference/spreadUnion2.types | 14 - .../reference/spreadUnion3.errors.txt | 23 +- tests/baselines/reference/spreadUnion3.js | 7 + .../cases/compiler/restInvalidArgumentType.ts | 24 +- tests/cases/compiler/restUnion2.ts | 9 - tests/cases/compiler/restUnion3.ts | 8 + .../compiler/spreadInvalidArgumentType.ts | 29 +- .../conformance/types/spread/objectSpread.ts | 28 +- .../types/spread/objectSpreadNegative.ts | 8 +- .../conformance/types/spread/spreadUnion2.ts | 3 - .../conformance/types/spread/spreadUnion3.ts | 5 + 28 files changed, 707 insertions(+), 372 deletions(-) create mode 100644 tests/baselines/reference/restUnion3.errors.txt create mode 100644 tests/baselines/reference/restUnion3.js create mode 100644 tests/cases/compiler/restUnion3.ts diff --git a/tests/baselines/reference/objectSpread.js b/tests/baselines/reference/objectSpread.js index 7eab2da265f..eea39c8e773 100644 --- a/tests/baselines/reference/objectSpread.js +++ b/tests/baselines/reference/objectSpread.js @@ -38,12 +38,26 @@ getter.a = 12; // functions result in { } let spreadFunc = { ...(function () { }) }; -// boolean && T results in Partial -function conditionalSpreadBoolean(b: boolean) : { x?: number | undefined, y?: number | undefined } { - return { ...b && { x: 1, y: 2 } }; +type Header = { head: string, body: string, authToken: string } +function from16326(this: { header: Header }, header: Header, authToken: string): Header { + return { + ...this.header, + ...header, + ...authToken && { authToken } + } } -function conditionalSpreadNumber(nt: number): { x?: number | undefined, y: number } { +// boolean && T results in Partial +function conditionalSpreadBoolean(b: boolean) : { x: number, y: number } { let o = { x: 12, y: 13 } + o = { + ...o, + ...b && { x: 14 } + } + let o2 = { ...b && { x: 21 }} + return o; +} +function conditionalSpreadNumber(nt: number): { x: number, y: number } { + let o = { x: 15, y: 16 } o = { ...o, ...nt && { x: nt } @@ -51,8 +65,8 @@ function conditionalSpreadNumber(nt: number): { x?: number | undefined, y: numbe let o2 = { ...nt && { x: nt }} return o; } -function conditionalSpreadString(st: string): { x?: string | undefined, y: number } { - let o = { x: 'hi', y: 13 } +function conditionalSpreadString(st: string): { x: string, y: number } { + let o = { x: 'hi', y: 17 } o = { ...o, ...st && { x: st } @@ -60,8 +74,6 @@ function conditionalSpreadString(st: string): { x?: string | undefined, y: numbe let o2 = { ...st && { x: st }} return o; } -// other booleans result in { } -let spreadBool = { ... true } // any results in any let anything: any; @@ -141,24 +153,28 @@ var getter = __assign({}, op, { c: 7 }); getter.a = 12; // functions result in { } var spreadFunc = __assign({}, (function () { })); +function from16326(header, authToken) { + return __assign({}, this.header, header, authToken && { authToken: authToken }); +} // boolean && T results in Partial function conditionalSpreadBoolean(b) { - return __assign({}, b && { x: 1, y: 2 }); + var o = { x: 12, y: 13 }; + o = __assign({}, o, b && { x: 14 }); + var o2 = __assign({}, b && { x: 21 }); + return o; } function conditionalSpreadNumber(nt) { - var o = { x: 12, y: 13 }; + var o = { x: 15, y: 16 }; o = __assign({}, o, nt && { x: nt }); var o2 = __assign({}, nt && { x: nt }); return o; } function conditionalSpreadString(st) { - var o = { x: 'hi', y: 13 }; + var o = { x: 'hi', y: 17 }; o = __assign({}, o, st && { x: st }); var o2 = __assign({}, st && { x: st }); return o; } -// other booleans result in { } -var spreadBool = __assign({}, true); // any results in any var anything; var spreadAny = __assign({}, anything); diff --git a/tests/baselines/reference/objectSpread.symbols b/tests/baselines/reference/objectSpread.symbols index 9f257870a0b..0cb15d4ea7a 100644 --- a/tests/baselines/reference/objectSpread.symbols +++ b/tests/baselines/reference/objectSpread.symbols @@ -169,144 +169,189 @@ getter.a = 12; let spreadFunc = { ...(function () { }) }; >spreadFunc : Symbol(spreadFunc, Decl(objectSpread.ts, 37, 3)) -// boolean && T results in Partial -function conditionalSpreadBoolean(b: boolean) : { x?: number | undefined, y?: number | undefined } { ->conditionalSpreadBoolean : Symbol(conditionalSpreadBoolean, Decl(objectSpread.ts, 37, 42)) ->b : Symbol(b, Decl(objectSpread.ts, 40, 34)) ->x : Symbol(x, Decl(objectSpread.ts, 40, 49)) ->y : Symbol(y, Decl(objectSpread.ts, 40, 73)) +type Header = { head: string, body: string, authToken: string } +>Header : Symbol(Header, Decl(objectSpread.ts, 37, 42)) +>head : Symbol(head, Decl(objectSpread.ts, 39, 15)) +>body : Symbol(body, Decl(objectSpread.ts, 39, 29)) +>authToken : Symbol(authToken, Decl(objectSpread.ts, 39, 43)) - return { ...b && { x: 1, y: 2 } }; ->b : Symbol(b, Decl(objectSpread.ts, 40, 34)) ->x : Symbol(x, Decl(objectSpread.ts, 41, 22)) ->y : Symbol(y, Decl(objectSpread.ts, 41, 28)) +function from16326(this: { header: Header }, header: Header, authToken: string): Header { +>from16326 : Symbol(from16326, Decl(objectSpread.ts, 39, 63)) +>this : Symbol(this, Decl(objectSpread.ts, 40, 19)) +>header : Symbol(header, Decl(objectSpread.ts, 40, 26)) +>Header : Symbol(Header, Decl(objectSpread.ts, 37, 42)) +>header : Symbol(header, Decl(objectSpread.ts, 40, 44)) +>Header : Symbol(Header, Decl(objectSpread.ts, 37, 42)) +>authToken : Symbol(authToken, Decl(objectSpread.ts, 40, 60)) +>Header : Symbol(Header, Decl(objectSpread.ts, 37, 42)) + + return { + ...this.header, +>this.header : Symbol(header, Decl(objectSpread.ts, 40, 26)) +>this : Symbol(this, Decl(objectSpread.ts, 40, 19)) +>header : Symbol(header, Decl(objectSpread.ts, 40, 26)) + + ...header, +>header : Symbol(header, Decl(objectSpread.ts, 40, 44)) + + ...authToken && { authToken } +>authToken : Symbol(authToken, Decl(objectSpread.ts, 40, 60)) +>authToken : Symbol(authToken, Decl(objectSpread.ts, 44, 25)) + } } -function conditionalSpreadNumber(nt: number): { x?: number | undefined, y: number } { ->conditionalSpreadNumber : Symbol(conditionalSpreadNumber, Decl(objectSpread.ts, 42, 1)) ->nt : Symbol(nt, Decl(objectSpread.ts, 43, 33)) ->x : Symbol(x, Decl(objectSpread.ts, 43, 47)) ->y : Symbol(y, Decl(objectSpread.ts, 43, 71)) +// boolean && T results in Partial +function conditionalSpreadBoolean(b: boolean) : { x: number, y: number } { +>conditionalSpreadBoolean : Symbol(conditionalSpreadBoolean, Decl(objectSpread.ts, 46, 1)) +>b : Symbol(b, Decl(objectSpread.ts, 48, 34)) +>x : Symbol(x, Decl(objectSpread.ts, 48, 49)) +>y : Symbol(y, Decl(objectSpread.ts, 48, 60)) let o = { x: 12, y: 13 } ->o : Symbol(o, Decl(objectSpread.ts, 44, 7)) ->x : Symbol(x, Decl(objectSpread.ts, 44, 13)) ->y : Symbol(y, Decl(objectSpread.ts, 44, 20)) +>o : Symbol(o, Decl(objectSpread.ts, 49, 7)) +>x : Symbol(x, Decl(objectSpread.ts, 49, 13)) +>y : Symbol(y, Decl(objectSpread.ts, 49, 20)) o = { ->o : Symbol(o, Decl(objectSpread.ts, 44, 7)) +>o : Symbol(o, Decl(objectSpread.ts, 49, 7)) ...o, ->o : Symbol(o, Decl(objectSpread.ts, 44, 7)) +>o : Symbol(o, Decl(objectSpread.ts, 49, 7)) + + ...b && { x: 14 } +>b : Symbol(b, Decl(objectSpread.ts, 48, 34)) +>x : Symbol(x, Decl(objectSpread.ts, 52, 17)) + } + let o2 = { ...b && { x: 21 }} +>o2 : Symbol(o2, Decl(objectSpread.ts, 54, 7)) +>b : Symbol(b, Decl(objectSpread.ts, 48, 34)) +>x : Symbol(x, Decl(objectSpread.ts, 54, 24)) + + return o; +>o : Symbol(o, Decl(objectSpread.ts, 49, 7)) +} +function conditionalSpreadNumber(nt: number): { x: number, y: number } { +>conditionalSpreadNumber : Symbol(conditionalSpreadNumber, Decl(objectSpread.ts, 56, 1)) +>nt : Symbol(nt, Decl(objectSpread.ts, 57, 33)) +>x : Symbol(x, Decl(objectSpread.ts, 57, 47)) +>y : Symbol(y, Decl(objectSpread.ts, 57, 58)) + + let o = { x: 15, y: 16 } +>o : Symbol(o, Decl(objectSpread.ts, 58, 7)) +>x : Symbol(x, Decl(objectSpread.ts, 58, 13)) +>y : Symbol(y, Decl(objectSpread.ts, 58, 20)) + + o = { +>o : Symbol(o, Decl(objectSpread.ts, 58, 7)) + + ...o, +>o : Symbol(o, Decl(objectSpread.ts, 58, 7)) ...nt && { x: nt } ->nt : Symbol(nt, Decl(objectSpread.ts, 43, 33)) ->x : Symbol(x, Decl(objectSpread.ts, 47, 18)) ->nt : Symbol(nt, Decl(objectSpread.ts, 43, 33)) +>nt : Symbol(nt, Decl(objectSpread.ts, 57, 33)) +>x : Symbol(x, Decl(objectSpread.ts, 61, 18)) +>nt : Symbol(nt, Decl(objectSpread.ts, 57, 33)) } let o2 = { ...nt && { x: nt }} ->o2 : Symbol(o2, Decl(objectSpread.ts, 49, 7)) ->nt : Symbol(nt, Decl(objectSpread.ts, 43, 33)) ->x : Symbol(x, Decl(objectSpread.ts, 49, 25)) ->nt : Symbol(nt, Decl(objectSpread.ts, 43, 33)) +>o2 : Symbol(o2, Decl(objectSpread.ts, 63, 7)) +>nt : Symbol(nt, Decl(objectSpread.ts, 57, 33)) +>x : Symbol(x, Decl(objectSpread.ts, 63, 25)) +>nt : Symbol(nt, Decl(objectSpread.ts, 57, 33)) return o; ->o : Symbol(o, Decl(objectSpread.ts, 44, 7)) +>o : Symbol(o, Decl(objectSpread.ts, 58, 7)) } -function conditionalSpreadString(st: string): { x?: string | undefined, y: number } { ->conditionalSpreadString : Symbol(conditionalSpreadString, Decl(objectSpread.ts, 51, 1)) ->st : Symbol(st, Decl(objectSpread.ts, 52, 33)) ->x : Symbol(x, Decl(objectSpread.ts, 52, 47)) ->y : Symbol(y, Decl(objectSpread.ts, 52, 71)) +function conditionalSpreadString(st: string): { x: string, y: number } { +>conditionalSpreadString : Symbol(conditionalSpreadString, Decl(objectSpread.ts, 65, 1)) +>st : Symbol(st, Decl(objectSpread.ts, 66, 33)) +>x : Symbol(x, Decl(objectSpread.ts, 66, 47)) +>y : Symbol(y, Decl(objectSpread.ts, 66, 58)) - let o = { x: 'hi', y: 13 } ->o : Symbol(o, Decl(objectSpread.ts, 53, 7)) ->x : Symbol(x, Decl(objectSpread.ts, 53, 13)) ->y : Symbol(y, Decl(objectSpread.ts, 53, 22)) + let o = { x: 'hi', y: 17 } +>o : Symbol(o, Decl(objectSpread.ts, 67, 7)) +>x : Symbol(x, Decl(objectSpread.ts, 67, 13)) +>y : Symbol(y, Decl(objectSpread.ts, 67, 22)) o = { ->o : Symbol(o, Decl(objectSpread.ts, 53, 7)) +>o : Symbol(o, Decl(objectSpread.ts, 67, 7)) ...o, ->o : Symbol(o, Decl(objectSpread.ts, 53, 7)) +>o : Symbol(o, Decl(objectSpread.ts, 67, 7)) ...st && { x: st } ->st : Symbol(st, Decl(objectSpread.ts, 52, 33)) ->x : Symbol(x, Decl(objectSpread.ts, 56, 18)) ->st : Symbol(st, Decl(objectSpread.ts, 52, 33)) +>st : Symbol(st, Decl(objectSpread.ts, 66, 33)) +>x : Symbol(x, Decl(objectSpread.ts, 70, 18)) +>st : Symbol(st, Decl(objectSpread.ts, 66, 33)) } let o2 = { ...st && { x: st }} ->o2 : Symbol(o2, Decl(objectSpread.ts, 58, 7)) ->st : Symbol(st, Decl(objectSpread.ts, 52, 33)) ->x : Symbol(x, Decl(objectSpread.ts, 58, 25)) ->st : Symbol(st, Decl(objectSpread.ts, 52, 33)) +>o2 : Symbol(o2, Decl(objectSpread.ts, 72, 7)) +>st : Symbol(st, Decl(objectSpread.ts, 66, 33)) +>x : Symbol(x, Decl(objectSpread.ts, 72, 25)) +>st : Symbol(st, Decl(objectSpread.ts, 66, 33)) return o; ->o : Symbol(o, Decl(objectSpread.ts, 53, 7)) +>o : Symbol(o, Decl(objectSpread.ts, 67, 7)) } -// other booleans result in { } -let spreadBool = { ... true } ->spreadBool : Symbol(spreadBool, Decl(objectSpread.ts, 62, 3)) // any results in any let anything: any; ->anything : Symbol(anything, Decl(objectSpread.ts, 65, 3)) +>anything : Symbol(anything, Decl(objectSpread.ts, 77, 3)) let spreadAny = { ...anything }; ->spreadAny : Symbol(spreadAny, Decl(objectSpread.ts, 66, 3)) ->anything : Symbol(anything, Decl(objectSpread.ts, 65, 3)) +>spreadAny : Symbol(spreadAny, Decl(objectSpread.ts, 78, 3)) +>anything : Symbol(anything, Decl(objectSpread.ts, 77, 3)) // methods are not enumerable class C { p = 1; m() { } } ->C : Symbol(C, Decl(objectSpread.ts, 66, 32)) ->p : Symbol(C.p, Decl(objectSpread.ts, 69, 9)) ->m : Symbol(C.m, Decl(objectSpread.ts, 69, 16)) +>C : Symbol(C, Decl(objectSpread.ts, 78, 32)) +>p : Symbol(C.p, Decl(objectSpread.ts, 81, 9)) +>m : Symbol(C.m, Decl(objectSpread.ts, 81, 16)) let c: C = new C() ->c : Symbol(c, Decl(objectSpread.ts, 70, 3)) ->C : Symbol(C, Decl(objectSpread.ts, 66, 32)) ->C : Symbol(C, Decl(objectSpread.ts, 66, 32)) +>c : Symbol(c, Decl(objectSpread.ts, 82, 3)) +>C : Symbol(C, Decl(objectSpread.ts, 78, 32)) +>C : Symbol(C, Decl(objectSpread.ts, 78, 32)) let spreadC: { p: number } = { ...c } ->spreadC : Symbol(spreadC, Decl(objectSpread.ts, 71, 3)) ->p : Symbol(p, Decl(objectSpread.ts, 71, 14)) ->c : Symbol(c, Decl(objectSpread.ts, 70, 3)) +>spreadC : Symbol(spreadC, Decl(objectSpread.ts, 83, 3)) +>p : Symbol(p, Decl(objectSpread.ts, 83, 14)) +>c : Symbol(c, Decl(objectSpread.ts, 82, 3)) // own methods are enumerable let cplus: { p: number, plus(): void } = { ...c, plus() { return this.p + 1; } }; ->cplus : Symbol(cplus, Decl(objectSpread.ts, 74, 3)) ->p : Symbol(p, Decl(objectSpread.ts, 74, 12)) ->plus : Symbol(plus, Decl(objectSpread.ts, 74, 23)) ->c : Symbol(c, Decl(objectSpread.ts, 70, 3)) ->plus : Symbol(plus, Decl(objectSpread.ts, 74, 48)) +>cplus : Symbol(cplus, Decl(objectSpread.ts, 86, 3)) +>p : Symbol(p, Decl(objectSpread.ts, 86, 12)) +>plus : Symbol(plus, Decl(objectSpread.ts, 86, 23)) +>c : Symbol(c, Decl(objectSpread.ts, 82, 3)) +>plus : Symbol(plus, Decl(objectSpread.ts, 86, 48)) cplus.plus(); ->cplus.plus : Symbol(plus, Decl(objectSpread.ts, 74, 23)) ->cplus : Symbol(cplus, Decl(objectSpread.ts, 74, 3)) ->plus : Symbol(plus, Decl(objectSpread.ts, 74, 23)) +>cplus.plus : Symbol(plus, Decl(objectSpread.ts, 86, 23)) +>cplus : Symbol(cplus, Decl(objectSpread.ts, 86, 3)) +>plus : Symbol(plus, Decl(objectSpread.ts, 86, 23)) // new field's type conflicting with existing field is OK let changeTypeAfter: { a: string, b: string } = ->changeTypeAfter : Symbol(changeTypeAfter, Decl(objectSpread.ts, 78, 3)) ->a : Symbol(a, Decl(objectSpread.ts, 78, 22)) ->b : Symbol(b, Decl(objectSpread.ts, 78, 33)) +>changeTypeAfter : Symbol(changeTypeAfter, Decl(objectSpread.ts, 90, 3)) +>a : Symbol(a, Decl(objectSpread.ts, 90, 22)) +>b : Symbol(b, Decl(objectSpread.ts, 90, 33)) { ...o, a: 'wrong type?' } >o : Symbol(o, Decl(objectSpread.ts, 0, 3)) ->a : Symbol(a, Decl(objectSpread.ts, 79, 11)) +>a : Symbol(a, Decl(objectSpread.ts, 91, 11)) let changeTypeBefore: { a: number, b: string } = ->changeTypeBefore : Symbol(changeTypeBefore, Decl(objectSpread.ts, 80, 3)) ->a : Symbol(a, Decl(objectSpread.ts, 80, 23)) ->b : Symbol(b, Decl(objectSpread.ts, 80, 34)) +>changeTypeBefore : Symbol(changeTypeBefore, Decl(objectSpread.ts, 92, 3)) +>a : Symbol(a, Decl(objectSpread.ts, 92, 23)) +>b : Symbol(b, Decl(objectSpread.ts, 92, 34)) { a: 'wrong type?', ...o }; ->a : Symbol(a, Decl(objectSpread.ts, 81, 5)) +>a : Symbol(a, Decl(objectSpread.ts, 93, 5)) >o : Symbol(o, Decl(objectSpread.ts, 0, 3)) let changeTypeBoth: { a: string, b: number } = ->changeTypeBoth : Symbol(changeTypeBoth, Decl(objectSpread.ts, 82, 3)) ->a : Symbol(a, Decl(objectSpread.ts, 82, 21)) ->b : Symbol(b, Decl(objectSpread.ts, 82, 32)) +>changeTypeBoth : Symbol(changeTypeBoth, Decl(objectSpread.ts, 94, 3)) +>a : Symbol(a, Decl(objectSpread.ts, 94, 21)) +>b : Symbol(b, Decl(objectSpread.ts, 94, 32)) { ...o, ...swap }; >o : Symbol(o, Decl(objectSpread.ts, 0, 3)) @@ -314,90 +359,90 @@ let changeTypeBoth: { a: string, b: number } = // optional function container( ->container : Symbol(container, Decl(objectSpread.ts, 83, 22)) +>container : Symbol(container, Decl(objectSpread.ts, 95, 22)) definiteBoolean: { sn: boolean }, ->definiteBoolean : Symbol(definiteBoolean, Decl(objectSpread.ts, 86, 19)) ->sn : Symbol(sn, Decl(objectSpread.ts, 87, 22)) +>definiteBoolean : Symbol(definiteBoolean, Decl(objectSpread.ts, 98, 19)) +>sn : Symbol(sn, Decl(objectSpread.ts, 99, 22)) definiteString: { sn: string }, ->definiteString : Symbol(definiteString, Decl(objectSpread.ts, 87, 37)) ->sn : Symbol(sn, Decl(objectSpread.ts, 88, 21)) +>definiteString : Symbol(definiteString, Decl(objectSpread.ts, 99, 37)) +>sn : Symbol(sn, Decl(objectSpread.ts, 100, 21)) optionalString: { sn?: string }, ->optionalString : Symbol(optionalString, Decl(objectSpread.ts, 88, 35)) ->sn : Symbol(sn, Decl(objectSpread.ts, 89, 21)) +>optionalString : Symbol(optionalString, Decl(objectSpread.ts, 100, 35)) +>sn : Symbol(sn, Decl(objectSpread.ts, 101, 21)) optionalNumber: { sn?: number }) { ->optionalNumber : Symbol(optionalNumber, Decl(objectSpread.ts, 89, 36)) ->sn : Symbol(sn, Decl(objectSpread.ts, 90, 21)) +>optionalNumber : Symbol(optionalNumber, Decl(objectSpread.ts, 101, 36)) +>sn : Symbol(sn, Decl(objectSpread.ts, 102, 21)) let optionalUnionStops: { sn: string | number | boolean } = { ...definiteBoolean, ...definiteString, ...optionalNumber }; ->optionalUnionStops : Symbol(optionalUnionStops, Decl(objectSpread.ts, 91, 7)) ->sn : Symbol(sn, Decl(objectSpread.ts, 91, 29)) ->definiteBoolean : Symbol(definiteBoolean, Decl(objectSpread.ts, 86, 19)) ->definiteString : Symbol(definiteString, Decl(objectSpread.ts, 87, 37)) ->optionalNumber : Symbol(optionalNumber, Decl(objectSpread.ts, 89, 36)) +>optionalUnionStops : Symbol(optionalUnionStops, Decl(objectSpread.ts, 103, 7)) +>sn : Symbol(sn, Decl(objectSpread.ts, 103, 29)) +>definiteBoolean : Symbol(definiteBoolean, Decl(objectSpread.ts, 98, 19)) +>definiteString : Symbol(definiteString, Decl(objectSpread.ts, 99, 37)) +>optionalNumber : Symbol(optionalNumber, Decl(objectSpread.ts, 101, 36)) let optionalUnionDuplicates: { sn: string | number } = { ...definiteBoolean, ...definiteString, ...optionalString, ...optionalNumber }; ->optionalUnionDuplicates : Symbol(optionalUnionDuplicates, Decl(objectSpread.ts, 92, 7)) ->sn : Symbol(sn, Decl(objectSpread.ts, 92, 34)) ->definiteBoolean : Symbol(definiteBoolean, Decl(objectSpread.ts, 86, 19)) ->definiteString : Symbol(definiteString, Decl(objectSpread.ts, 87, 37)) ->optionalString : Symbol(optionalString, Decl(objectSpread.ts, 88, 35)) ->optionalNumber : Symbol(optionalNumber, Decl(objectSpread.ts, 89, 36)) +>optionalUnionDuplicates : Symbol(optionalUnionDuplicates, Decl(objectSpread.ts, 104, 7)) +>sn : Symbol(sn, Decl(objectSpread.ts, 104, 34)) +>definiteBoolean : Symbol(definiteBoolean, Decl(objectSpread.ts, 98, 19)) +>definiteString : Symbol(definiteString, Decl(objectSpread.ts, 99, 37)) +>optionalString : Symbol(optionalString, Decl(objectSpread.ts, 100, 35)) +>optionalNumber : Symbol(optionalNumber, Decl(objectSpread.ts, 101, 36)) let allOptional: { sn?: string | number } = { ...optionalString, ...optionalNumber }; ->allOptional : Symbol(allOptional, Decl(objectSpread.ts, 93, 7)) ->sn : Symbol(sn, Decl(objectSpread.ts, 93, 22)) ->optionalString : Symbol(optionalString, Decl(objectSpread.ts, 88, 35)) ->optionalNumber : Symbol(optionalNumber, Decl(objectSpread.ts, 89, 36)) +>allOptional : Symbol(allOptional, Decl(objectSpread.ts, 105, 7)) +>sn : Symbol(sn, Decl(objectSpread.ts, 105, 22)) +>optionalString : Symbol(optionalString, Decl(objectSpread.ts, 100, 35)) +>optionalNumber : Symbol(optionalNumber, Decl(objectSpread.ts, 101, 36)) // computed property let computedFirst: { a: number, b: string, "before everything": number } = ->computedFirst : Symbol(computedFirst, Decl(objectSpread.ts, 96, 7)) ->a : Symbol(a, Decl(objectSpread.ts, 96, 24)) ->b : Symbol(b, Decl(objectSpread.ts, 96, 35)) +>computedFirst : Symbol(computedFirst, Decl(objectSpread.ts, 108, 7)) +>a : Symbol(a, Decl(objectSpread.ts, 108, 24)) +>b : Symbol(b, Decl(objectSpread.ts, 108, 35)) { ['before everything']: 12, ...o, b: 'yes' } ->'before everything' : Symbol(['before everything'], Decl(objectSpread.ts, 97, 9)) +>'before everything' : Symbol(['before everything'], Decl(objectSpread.ts, 109, 9)) >o : Symbol(o, Decl(objectSpread.ts, 0, 3)) ->b : Symbol(b, Decl(objectSpread.ts, 97, 42)) +>b : Symbol(b, Decl(objectSpread.ts, 109, 42)) let computedMiddle: { a: number, b: string, c: boolean, "in the middle": number } = ->computedMiddle : Symbol(computedMiddle, Decl(objectSpread.ts, 98, 7)) ->a : Symbol(a, Decl(objectSpread.ts, 98, 25)) ->b : Symbol(b, Decl(objectSpread.ts, 98, 36)) ->c : Symbol(c, Decl(objectSpread.ts, 98, 47)) +>computedMiddle : Symbol(computedMiddle, Decl(objectSpread.ts, 110, 7)) +>a : Symbol(a, Decl(objectSpread.ts, 110, 25)) +>b : Symbol(b, Decl(objectSpread.ts, 110, 36)) +>c : Symbol(c, Decl(objectSpread.ts, 110, 47)) { ...o, ['in the middle']: 13, b: 'maybe?', ...o2 } >o : Symbol(o, Decl(objectSpread.ts, 0, 3)) ->'in the middle' : Symbol(['in the middle'], Decl(objectSpread.ts, 99, 15)) ->b : Symbol(b, Decl(objectSpread.ts, 99, 38)) +>'in the middle' : Symbol(['in the middle'], Decl(objectSpread.ts, 111, 15)) +>b : Symbol(b, Decl(objectSpread.ts, 111, 38)) >o2 : Symbol(o2, Decl(objectSpread.ts, 1, 3)) let computedAfter: { a: number, b: string, "at the end": number } = ->computedAfter : Symbol(computedAfter, Decl(objectSpread.ts, 100, 7)) ->a : Symbol(a, Decl(objectSpread.ts, 100, 24)) ->b : Symbol(b, Decl(objectSpread.ts, 100, 35)) +>computedAfter : Symbol(computedAfter, Decl(objectSpread.ts, 112, 7)) +>a : Symbol(a, Decl(objectSpread.ts, 112, 24)) +>b : Symbol(b, Decl(objectSpread.ts, 112, 35)) { ...o, b: 'yeah', ['at the end']: 14 } >o : Symbol(o, Decl(objectSpread.ts, 0, 3)) ->b : Symbol(b, Decl(objectSpread.ts, 101, 15)) ->'at the end' : Symbol(['at the end'], Decl(objectSpread.ts, 101, 26)) +>b : Symbol(b, Decl(objectSpread.ts, 113, 15)) +>'at the end' : Symbol(['at the end'], Decl(objectSpread.ts, 113, 26)) } // shortcut syntax let a = 12; ->a : Symbol(a, Decl(objectSpread.ts, 104, 3)) +>a : Symbol(a, Decl(objectSpread.ts, 116, 3)) let shortCutted: { a: number, b: string } = { ...o, a } ->shortCutted : Symbol(shortCutted, Decl(objectSpread.ts, 105, 3)) ->a : Symbol(a, Decl(objectSpread.ts, 105, 18)) ->b : Symbol(b, Decl(objectSpread.ts, 105, 29)) +>shortCutted : Symbol(shortCutted, Decl(objectSpread.ts, 117, 3)) +>a : Symbol(a, Decl(objectSpread.ts, 117, 18)) +>b : Symbol(b, Decl(objectSpread.ts, 117, 29)) >o : Symbol(o, Decl(objectSpread.ts, 0, 3)) ->a : Symbol(a, Decl(objectSpread.ts, 105, 51)) +>a : Symbol(a, Decl(objectSpread.ts, 117, 51)) // non primitive let spreadNonPrimitive = { ...{}}; ->spreadNonPrimitive : Symbol(spreadNonPrimitive, Decl(objectSpread.ts, 107, 3)) +>spreadNonPrimitive : Symbol(spreadNonPrimitive, Decl(objectSpread.ts, 119, 3)) diff --git a/tests/baselines/reference/objectSpread.types b/tests/baselines/reference/objectSpread.types index 10d8af02440..da24a558d51 100644 --- a/tests/baselines/reference/objectSpread.types +++ b/tests/baselines/reference/objectSpread.types @@ -230,27 +230,45 @@ let spreadFunc = { ...(function () { }) }; >(function () { }) : () => void >function () { } : () => void -// boolean && T results in Partial -function conditionalSpreadBoolean(b: boolean) : { x?: number | undefined, y?: number | undefined } { ->conditionalSpreadBoolean : (b: boolean) => { x?: number | undefined; y?: number | undefined; } ->b : boolean ->x : number | undefined ->y : number | undefined +type Header = { head: string, body: string, authToken: string } +>Header : Header +>head : string +>body : string +>authToken : string - return { ...b && { x: 1, y: 2 } }; ->{ ...b && { x: 1, y: 2 } } : { x?: number | undefined; y?: number | undefined; } ->b && { x: 1, y: 2 } : false | { x: number; y: number; } ->b : boolean ->{ x: 1, y: 2 } : { x: number; y: number; } ->x : number ->1 : 1 ->y : number ->2 : 2 +function from16326(this: { header: Header }, header: Header, authToken: string): Header { +>from16326 : (this: { header: Header; }, header: Header, authToken: string) => Header +>this : { header: Header; } +>header : Header +>Header : Header +>header : Header +>Header : Header +>authToken : string +>Header : Header + + return { +>{ ...this.header, ...header, ...authToken && { authToken } } : { authToken: string; head: string; body: string; } + + ...this.header, +>this.header : Header +>this : { header: Header; } +>header : Header + + ...header, +>header : Header + + ...authToken && { authToken } +>authToken && { authToken } : "" | { authToken: string; } +>authToken : string +>{ authToken } : { authToken: string; } +>authToken : string + } } -function conditionalSpreadNumber(nt: number): { x?: number | undefined, y: number } { ->conditionalSpreadNumber : (nt: number) => { x?: number | undefined; y: number; } ->nt : number ->x : number | undefined +// boolean && T results in Partial +function conditionalSpreadBoolean(b: boolean) : { x: number, y: number } { +>conditionalSpreadBoolean : (b: boolean) => { x: number; y: number; } +>b : boolean +>x : number >y : number let o = { x: 12, y: 13 } @@ -261,6 +279,47 @@ function conditionalSpreadNumber(nt: number): { x?: number | undefined, y: numbe >y : number >13 : 13 + o = { +>o = { ...o, ...b && { x: 14 } } : { x: number; y: number; } +>o : { x: number; y: number; } +>{ ...o, ...b && { x: 14 } } : { x: number; y: number; } + + ...o, +>o : { x: number; y: number; } + + ...b && { x: 14 } +>b && { x: 14 } : false | { x: number; } +>b : boolean +>{ x: 14 } : { x: number; } +>x : number +>14 : 14 + } + let o2 = { ...b && { x: 21 }} +>o2 : { x?: number | undefined; } +>{ ...b && { x: 21 }} : { x?: number | undefined; } +>b && { x: 21 } : false | { x: number; } +>b : boolean +>{ x: 21 } : { x: number; } +>x : number +>21 : 21 + + return o; +>o : { x: number; y: number; } +} +function conditionalSpreadNumber(nt: number): { x: number, y: number } { +>conditionalSpreadNumber : (nt: number) => { x: number; y: number; } +>nt : number +>x : number +>y : number + + let o = { x: 15, y: 16 } +>o : { x: number; y: number; } +>{ x: 15, y: 16 } : { x: number; y: number; } +>x : number +>15 : 15 +>y : number +>16 : 16 + o = { >o = { ...o, ...nt && { x: nt } } : { x: number; y: number; } >o : { x: number; y: number; } @@ -288,19 +347,19 @@ function conditionalSpreadNumber(nt: number): { x?: number | undefined, y: numbe return o; >o : { x: number; y: number; } } -function conditionalSpreadString(st: string): { x?: string | undefined, y: number } { ->conditionalSpreadString : (st: string) => { x?: string | undefined; y: number; } +function conditionalSpreadString(st: string): { x: string, y: number } { +>conditionalSpreadString : (st: string) => { x: string; y: number; } >st : string ->x : string | undefined +>x : string >y : number - let o = { x: 'hi', y: 13 } + let o = { x: 'hi', y: 17 } >o : { x: string; y: number; } ->{ x: 'hi', y: 13 } : { x: string; y: number; } +>{ x: 'hi', y: 17 } : { x: string; y: number; } >x : string >'hi' : "hi" >y : number ->13 : 13 +>17 : 17 o = { >o = { ...o, ...st && { x: st } } : { x: string; y: number; } @@ -329,11 +388,6 @@ function conditionalSpreadString(st: string): { x?: string | undefined, y: numbe return o; >o : { x: string; y: number; } } -// other booleans result in { } -let spreadBool = { ... true } ->spreadBool : {} ->{ ... true } : {} ->true : true // any results in any let anything: any; diff --git a/tests/baselines/reference/objectSpreadNegative.errors.txt b/tests/baselines/reference/objectSpreadNegative.errors.txt index 39639af545e..92225755c71 100644 --- a/tests/baselines/reference/objectSpreadNegative.errors.txt +++ b/tests/baselines/reference/objectSpreadNegative.errors.txt @@ -7,23 +7,26 @@ tests/cases/conformance/types/spread/objectSpreadNegative.ts(25,1): error TS2322 Property 's' is missing in type '{ b: boolean; }'. tests/cases/conformance/types/spread/objectSpreadNegative.ts(28,36): error TS2300: Duplicate identifier 'b'. tests/cases/conformance/types/spread/objectSpreadNegative.ts(28,53): error TS2300: Duplicate identifier 'b'. -tests/cases/conformance/types/spread/objectSpreadNegative.ts(33,11): error TS2339: Property 'length' does not exist on type '{}'. -tests/cases/conformance/types/spread/objectSpreadNegative.ts(34,11): error TS2339: Property 'charAt' does not exist on type '{}'. -tests/cases/conformance/types/spread/objectSpreadNegative.ts(37,1): error TS2349: Cannot invoke an expression whose type lacks a call signature. Type '{}' has no compatible call signatures. -tests/cases/conformance/types/spread/objectSpreadNegative.ts(41,12): error TS2339: Property 'b' does not exist on type '{}'. -tests/cases/conformance/types/spread/objectSpreadNegative.ts(47,9): error TS2339: Property 'm' does not exist on type '{ p: number; }'. -tests/cases/conformance/types/spread/objectSpreadNegative.ts(52,11): error TS2339: Property 'a' does not exist on type '{}'. -tests/cases/conformance/types/spread/objectSpreadNegative.ts(56,14): error TS2698: Spread types may only be created from object types. -tests/cases/conformance/types/spread/objectSpreadNegative.ts(59,14): error TS2698: Spread types may only be created from object types. -tests/cases/conformance/types/spread/objectSpreadNegative.ts(73,37): error TS2322: Type '{ a: string; b: string; extra: string; }' is not assignable to type 'A'. +tests/cases/conformance/types/spread/objectSpreadNegative.ts(32,19): error TS2698: Spread types may only be created from object types. +tests/cases/conformance/types/spread/objectSpreadNegative.ts(33,19): error TS2698: Spread types may only be created from object types. +tests/cases/conformance/types/spread/objectSpreadNegative.ts(34,20): error TS2698: Spread types may only be created from object types. +tests/cases/conformance/types/spread/objectSpreadNegative.ts(36,20): error TS2698: Spread types may only be created from object types. +tests/cases/conformance/types/spread/objectSpreadNegative.ts(38,19): error TS2698: Spread types may only be created from object types. +tests/cases/conformance/types/spread/objectSpreadNegative.ts(43,1): error TS2349: Cannot invoke an expression whose type lacks a call signature. Type '{}' has no compatible call signatures. +tests/cases/conformance/types/spread/objectSpreadNegative.ts(47,12): error TS2339: Property 'b' does not exist on type '{}'. +tests/cases/conformance/types/spread/objectSpreadNegative.ts(53,9): error TS2339: Property 'm' does not exist on type '{ p: number; }'. +tests/cases/conformance/types/spread/objectSpreadNegative.ts(58,11): error TS2339: Property 'a' does not exist on type '{}'. +tests/cases/conformance/types/spread/objectSpreadNegative.ts(62,14): error TS2698: Spread types may only be created from object types. +tests/cases/conformance/types/spread/objectSpreadNegative.ts(65,14): error TS2698: Spread types may only be created from object types. +tests/cases/conformance/types/spread/objectSpreadNegative.ts(79,37): error TS2322: Type '{ a: string; b: string; extra: string; }' is not assignable to type 'A'. Object literal may only specify known properties, and 'extra' does not exist in type 'A'. -tests/cases/conformance/types/spread/objectSpreadNegative.ts(76,7): error TS2322: Type '{ a: string; b: string; extra: string; }' is not assignable to type 'A'. +tests/cases/conformance/types/spread/objectSpreadNegative.ts(82,7): error TS2322: Type '{ a: string; b: string; extra: string; }' is not assignable to type 'A'. Object literal may only specify known properties, and 'extra' does not exist in type 'A'. -tests/cases/conformance/types/spread/objectSpreadNegative.ts(78,7): error TS2322: Type '{ a: string; b: string; extra: string; }' is not assignable to type 'A'. +tests/cases/conformance/types/spread/objectSpreadNegative.ts(84,7): error TS2322: Type '{ a: string; b: string; extra: string; }' is not assignable to type 'A'. Object literal may only specify known properties, and 'extra' does not exist in type 'A'. -==== tests/cases/conformance/types/spread/objectSpreadNegative.ts (17 errors) ==== +==== tests/cases/conformance/types/spread/objectSpreadNegative.ts (20 errors) ==== let o = { a: 1, b: 'no' } /// private propagates @@ -69,14 +72,26 @@ tests/cases/conformance/types/spread/objectSpreadNegative.ts(78,7): error TS2322 !!! error TS2300: Duplicate identifier 'b'. let duplicatedSpread = { ...o, ...o } - // primitives are skipped + // primitives are not allowed, except for falsy ones + let spreadNum = { ...12 }; + ~~~~~ +!!! error TS2698: Spread types may only be created from object types. + let spreadSum = { ...1 + 1 }; + ~~~~~~~~ +!!! error TS2698: Spread types may only be created from object types. + let spreadZero = { ...0 }; + ~~~~ +!!! error TS2698: Spread types may only be created from object types. + spreadZero.toFixed(); // error, no methods even from a falsy number + let spreadBool = { ...true }; + ~~~~~~~ +!!! error TS2698: Spread types may only be created from object types. + spreadBool.valueOf(); let spreadStr = { ...'foo' }; + ~~~~~~~~ +!!! error TS2698: Spread types may only be created from object types. spreadStr.length; // error, no 'length' - ~~~~~~ -!!! error TS2339: Property 'length' does not exist on type '{}'. spreadStr.charAt(1); // error, no methods either - ~~~~~~ -!!! error TS2339: Property 'charAt' does not exist on type '{}'. // functions are skipped let spreadFunc = { ...function () { } } spreadFunc(); // error, no call signature diff --git a/tests/baselines/reference/objectSpreadNegative.js b/tests/baselines/reference/objectSpreadNegative.js index 41502dc028d..7e6720b9b16 100644 --- a/tests/baselines/reference/objectSpreadNegative.js +++ b/tests/baselines/reference/objectSpreadNegative.js @@ -29,7 +29,13 @@ spread = b; // error, missing 's' let duplicated = { b: 'bad', ...o, b: 'bad', ...o2, b: 'bad' } let duplicatedSpread = { ...o, ...o } -// primitives are skipped +// primitives are not allowed, except for falsy ones +let spreadNum = { ...12 }; +let spreadSum = { ...1 + 1 }; +let spreadZero = { ...0 }; +spreadZero.toFixed(); // error, no methods even from a falsy number +let spreadBool = { ...true }; +spreadBool.valueOf(); let spreadStr = { ...'foo' }; spreadStr.length; // error, no 'length' spreadStr.charAt(1); // error, no methods either @@ -116,7 +122,13 @@ spread = b; // error, missing 's' // literal repeats are not allowed, but spread repeats are fine var duplicated = __assign({ b: 'bad' }, o, { b: 'bad' }, o2, { b: 'bad' }); var duplicatedSpread = __assign({}, o, o); -// primitives are skipped +// primitives are not allowed, except for falsy ones +var spreadNum = __assign({}, 12); +var spreadSum = __assign({}, 1 + 1); +var spreadZero = __assign({}, 0); +spreadZero.toFixed(); // error, no methods even from a falsy number +var spreadBool = __assign({}, true); +spreadBool.valueOf(); var spreadStr = __assign({}, 'foo'); spreadStr.length; // error, no 'length' spreadStr.charAt(1); // error, no methods either diff --git a/tests/baselines/reference/objectSpreadNegativeParse.errors.txt b/tests/baselines/reference/objectSpreadNegativeParse.errors.txt index 41651fb1d1c..b37200c4f02 100644 --- a/tests/baselines/reference/objectSpreadNegativeParse.errors.txt +++ b/tests/baselines/reference/objectSpreadNegativeParse.errors.txt @@ -1,5 +1,6 @@ tests/cases/conformance/types/spread/objectSpreadNegativeParse.ts(1,15): error TS2304: Cannot find name 'o'. tests/cases/conformance/types/spread/objectSpreadNegativeParse.ts(1,18): error TS1109: Expression expected. +tests/cases/conformance/types/spread/objectSpreadNegativeParse.ts(2,12): error TS2698: Spread types may only be created from object types. tests/cases/conformance/types/spread/objectSpreadNegativeParse.ts(2,15): error TS1109: Expression expected. tests/cases/conformance/types/spread/objectSpreadNegativeParse.ts(2,16): error TS2304: Cannot find name 'o'. tests/cases/conformance/types/spread/objectSpreadNegativeParse.ts(3,15): error TS2304: Cannot find name 'matchMedia'. @@ -9,13 +10,15 @@ tests/cases/conformance/types/spread/objectSpreadNegativeParse.ts(4,16): error T tests/cases/conformance/types/spread/objectSpreadNegativeParse.ts(4,20): error TS1005: ',' expected. -==== tests/cases/conformance/types/spread/objectSpreadNegativeParse.ts (9 errors) ==== +==== tests/cases/conformance/types/spread/objectSpreadNegativeParse.ts (10 errors) ==== let o7 = { ...o? }; ~ !!! error TS2304: Cannot find name 'o'. ~ !!! error TS1109: Expression expected. let o8 = { ...*o }; + ~~~~~ +!!! error TS2698: Spread types may only be created from object types. ~ !!! error TS1109: Expression expected. ~ diff --git a/tests/baselines/reference/restInvalidArgumentType.errors.txt b/tests/baselines/reference/restInvalidArgumentType.errors.txt index 44577d5a24e..0cc4faea557 100644 --- a/tests/baselines/reference/restInvalidArgumentType.errors.txt +++ b/tests/baselines/reference/restInvalidArgumentType.errors.txt @@ -1,13 +1,24 @@ -tests/cases/compiler/restInvalidArgumentType.ts(18,13): error TS2700: Rest types may only be created from object types. -tests/cases/compiler/restInvalidArgumentType.ts(20,13): error TS2700: Rest types may only be created from object types. -tests/cases/compiler/restInvalidArgumentType.ts(22,13): error TS2700: Rest types may only be created from object types. -tests/cases/compiler/restInvalidArgumentType.ts(23,13): error TS2700: Rest types may only be created from object types. -tests/cases/compiler/restInvalidArgumentType.ts(25,13): error TS2700: Rest types may only be created from object types. -tests/cases/compiler/restInvalidArgumentType.ts(28,13): error TS2700: Rest types may only be created from object types. +tests/cases/compiler/restInvalidArgumentType.ts(27,13): error TS2700: Rest types may only be created from object types. +tests/cases/compiler/restInvalidArgumentType.ts(29,13): error TS2700: Rest types may only be created from object types. tests/cases/compiler/restInvalidArgumentType.ts(30,13): error TS2700: Rest types may only be created from object types. +tests/cases/compiler/restInvalidArgumentType.ts(31,13): error TS2700: Rest types may only be created from object types. +tests/cases/compiler/restInvalidArgumentType.ts(33,13): error TS2700: Rest types may only be created from object types. +tests/cases/compiler/restInvalidArgumentType.ts(36,13): error TS2700: Rest types may only be created from object types. +tests/cases/compiler/restInvalidArgumentType.ts(37,13): error TS2700: Rest types may only be created from object types. +tests/cases/compiler/restInvalidArgumentType.ts(39,13): error TS2700: Rest types may only be created from object types. +tests/cases/compiler/restInvalidArgumentType.ts(40,13): error TS2700: Rest types may only be created from object types. +tests/cases/compiler/restInvalidArgumentType.ts(42,13): error TS2700: Rest types may only be created from object types. +tests/cases/compiler/restInvalidArgumentType.ts(43,13): error TS2700: Rest types may only be created from object types. +tests/cases/compiler/restInvalidArgumentType.ts(45,13): error TS2700: Rest types may only be created from object types. +tests/cases/compiler/restInvalidArgumentType.ts(46,13): error TS2700: Rest types may only be created from object types. +tests/cases/compiler/restInvalidArgumentType.ts(50,13): error TS2700: Rest types may only be created from object types. +tests/cases/compiler/restInvalidArgumentType.ts(51,13): error TS2700: Rest types may only be created from object types. +tests/cases/compiler/restInvalidArgumentType.ts(53,13): error TS2700: Rest types may only be created from object types. -==== tests/cases/compiler/restInvalidArgumentType.ts (7 errors) ==== +==== tests/cases/compiler/restInvalidArgumentType.ts (16 errors) ==== + enum E { v1, v2 }; + function f(p1: T, p2: T[]) { var t: T; @@ -18,7 +29,14 @@ tests/cases/compiler/restInvalidArgumentType.ts(30,13): error TS2700: Rest types var mapped: {[P in "b"]: T[P]}; var union_generic: T | { a: number }; + var union_primitive: { a: number } | number; var intersection_generic: T & { a: number }; + var intersection_primitive: { a: number } & string; + var num: number; + var str: string; + var literal_string: "string"; + var literal_number: 42; + var e: E; var u: undefined; var n: null; @@ -32,7 +50,6 @@ tests/cases/compiler/restInvalidArgumentType.ts(30,13): error TS2700: Rest types var {...r3} = t; // Error, generic type paramter ~~ !!! error TS2700: Rest types may only be created from object types. - var {...r4} = i; // Error, index access ~~ !!! error TS2700: Rest types may only be created from object types. @@ -48,14 +65,42 @@ tests/cases/compiler/restInvalidArgumentType.ts(30,13): error TS2700: Rest types var {...r8} = union_generic; // Error, union with generic type parameter ~~ !!! error TS2700: Rest types may only be created from object types. + var {...r9} = union_primitive; // Error, union with generic type parameter + ~~ +!!! error TS2700: Rest types may only be created from object types. var {...r10} = intersection_generic; // Error, intersection with generic type parameter ~~~ !!! error TS2700: Rest types may only be created from object types. + var {...r11} = intersection_primitive; // Error, intersection with generic type parameter + ~~~ +!!! error TS2700: Rest types may only be created from object types. - var {...r14} = u; // OK - var {...r15} = n; // OK + var {...r12} = num; // Error + ~~~ +!!! error TS2700: Rest types may only be created from object types. + var {...r13} = str; // Error + ~~~ +!!! error TS2700: Rest types may only be created from object types. + + var {...r14} = u; // error, undefined-only not allowed + ~~~ +!!! error TS2700: Rest types may only be created from object types. + var {...r15} = n; // error, null-only not allowed + ~~~ +!!! error TS2700: Rest types may only be created from object types. var {...r16} = a; // OK + + var {...r17} = literal_string; // Error + ~~~ +!!! error TS2700: Rest types may only be created from object types. + var {...r18} = literal_number; // Error + ~~~ +!!! error TS2700: Rest types may only be created from object types. + + var {...r19} = e; // Error, enum + ~~~ +!!! error TS2700: Rest types may only be created from object types. } \ No newline at end of file diff --git a/tests/baselines/reference/restInvalidArgumentType.js b/tests/baselines/reference/restInvalidArgumentType.js index 81bcfb63a17..75b52a8c6e8 100644 --- a/tests/baselines/reference/restInvalidArgumentType.js +++ b/tests/baselines/reference/restInvalidArgumentType.js @@ -1,4 +1,6 @@ //// [restInvalidArgumentType.ts] +enum E { v1, v2 }; + function f(p1: T, p2: T[]) { var t: T; @@ -9,7 +11,14 @@ function f(p1: T, p2: T[]) { var mapped: {[P in "b"]: T[P]}; var union_generic: T | { a: number }; + var union_primitive: { a: number } | number; var intersection_generic: T & { a: number }; + var intersection_primitive: { a: number } & string; + var num: number; + var str: string; + var literal_string: "string"; + var literal_number: 42; + var e: E; var u: undefined; var n: null; @@ -19,7 +28,6 @@ function f(p1: T, p2: T[]) { var {...r1} = p1; // Error, generic type paramterre var {...r2} = p2; // OK var {...r3} = t; // Error, generic type paramter - var {...r4} = i; // Error, index access var {...r5} = k; // Error, index @@ -27,13 +35,23 @@ function f(p1: T, p2: T[]) { var {...r7} = mapped; // OK, non-generic mapped type var {...r8} = union_generic; // Error, union with generic type parameter + var {...r9} = union_primitive; // Error, union with generic type parameter var {...r10} = intersection_generic; // Error, intersection with generic type parameter + var {...r11} = intersection_primitive; // Error, intersection with generic type parameter - var {...r14} = u; // OK - var {...r15} = n; // OK + var {...r12} = num; // Error + var {...r13} = str; // Error + + var {...r14} = u; // error, undefined-only not allowed + var {...r15} = n; // error, null-only not allowed var {...r16} = a; // OK + + var {...r17} = literal_string; // Error + var {...r18} = literal_number; // Error + + var {...r19} = e; // Error, enum } @@ -47,6 +65,12 @@ var __rest = (this && this.__rest) || function (s, e) { t[p[i]] = s[p[i]]; return t; }; +var E; +(function (E) { + E[E["v1"] = 0] = "v1"; + E[E["v2"] = 1] = "v2"; +})(E || (E = {})); +; function f(p1, p2) { var t; var i; @@ -54,7 +78,14 @@ function f(p1, p2) { var mapped_generic; var mapped; var union_generic; + var union_primitive; var intersection_generic; + var intersection_primitive; + var num; + var str; + var literal_string; + var literal_number; + var e; var u; var n; var a; @@ -66,8 +97,15 @@ function f(p1, p2) { var r6 = __rest(mapped_generic, []); // Error, generic mapped object type var r7 = __rest(mapped, []); // OK, non-generic mapped type var r8 = __rest(union_generic, []); // Error, union with generic type parameter + var r9 = __rest(union_primitive, []); // Error, union with generic type parameter var r10 = __rest(intersection_generic, []); // Error, intersection with generic type parameter - var r14 = __rest(u, []); // OK - var r15 = __rest(n, []); // OK + var r11 = __rest(intersection_primitive, []); // Error, intersection with generic type parameter + var r12 = __rest(num, []); // Error + var r13 = __rest(str, []); // Error + var r14 = __rest(u, []); // error, undefined-only not allowed + var r15 = __rest(n, []); // error, null-only not allowed var r16 = __rest(a, []); // OK + var r17 = __rest(literal_string, []); // Error + var r18 = __rest(literal_number, []); // Error + var r19 = __rest(e, []); // Error, enum } diff --git a/tests/baselines/reference/restUnion2.js b/tests/baselines/reference/restUnion2.js index 71f4b06cfef..437ea780193 100644 --- a/tests/baselines/reference/restUnion2.js +++ b/tests/baselines/reference/restUnion2.js @@ -7,15 +7,7 @@ var {...rest2 } = undefinedUnion; declare const nullUnion: { n: number } | null; var rest3: { n: number }; var {...rest3 } = nullUnion; - - -declare const nullAndUndefinedUnion: null | undefined; -var rest4: { }; -var {...rest4 } = nullAndUndefinedUnion; - -declare const unionWithIntersection: ({ n: number } & { s: string }) & undefined | null; -var rest5: { n: number, s: string }; -var {...rest5 } = unionWithIntersection; + //// [restUnion2.js] var __rest = (this && this.__rest) || function (s, e) { @@ -31,7 +23,3 @@ var rest2; var rest2 = __rest(undefinedUnion, []); var rest3; var rest3 = __rest(nullUnion, []); -var rest4; -var rest4 = __rest(nullAndUndefinedUnion, []); -var rest5; -var rest5 = __rest(unionWithIntersection, []); diff --git a/tests/baselines/reference/restUnion2.symbols b/tests/baselines/reference/restUnion2.symbols index 54ac47f0694..c6c34511b17 100644 --- a/tests/baselines/reference/restUnion2.symbols +++ b/tests/baselines/reference/restUnion2.symbols @@ -24,28 +24,3 @@ var {...rest3 } = nullUnion; >rest3 : Symbol(rest3, Decl(restUnion2.ts, 6, 3), Decl(restUnion2.ts, 7, 5)) >nullUnion : Symbol(nullUnion, Decl(restUnion2.ts, 5, 13)) - -declare const nullAndUndefinedUnion: null | undefined; ->nullAndUndefinedUnion : Symbol(nullAndUndefinedUnion, Decl(restUnion2.ts, 10, 13)) - -var rest4: { }; ->rest4 : Symbol(rest4, Decl(restUnion2.ts, 11, 3), Decl(restUnion2.ts, 12, 5)) - -var {...rest4 } = nullAndUndefinedUnion; ->rest4 : Symbol(rest4, Decl(restUnion2.ts, 11, 3), Decl(restUnion2.ts, 12, 5)) ->nullAndUndefinedUnion : Symbol(nullAndUndefinedUnion, Decl(restUnion2.ts, 10, 13)) - -declare const unionWithIntersection: ({ n: number } & { s: string }) & undefined | null; ->unionWithIntersection : Symbol(unionWithIntersection, Decl(restUnion2.ts, 14, 13)) ->n : Symbol(n, Decl(restUnion2.ts, 14, 39)) ->s : Symbol(s, Decl(restUnion2.ts, 14, 55)) - -var rest5: { n: number, s: string }; ->rest5 : Symbol(rest5, Decl(restUnion2.ts, 15, 3), Decl(restUnion2.ts, 16, 5)) ->n : Symbol(n, Decl(restUnion2.ts, 15, 12)) ->s : Symbol(s, Decl(restUnion2.ts, 15, 23)) - -var {...rest5 } = unionWithIntersection; ->rest5 : Symbol(rest5, Decl(restUnion2.ts, 15, 3), Decl(restUnion2.ts, 16, 5)) ->unionWithIntersection : Symbol(unionWithIntersection, Decl(restUnion2.ts, 14, 13)) - diff --git a/tests/baselines/reference/restUnion2.types b/tests/baselines/reference/restUnion2.types index 03c8d577e66..0e464930b07 100644 --- a/tests/baselines/reference/restUnion2.types +++ b/tests/baselines/reference/restUnion2.types @@ -25,30 +25,3 @@ var {...rest3 } = nullUnion; >rest3 : { n: number; } >nullUnion : { n: number; } | null - -declare const nullAndUndefinedUnion: null | undefined; ->nullAndUndefinedUnion : null | undefined ->null : null - -var rest4: { }; ->rest4 : {} - -var {...rest4 } = nullAndUndefinedUnion; ->rest4 : {} ->nullAndUndefinedUnion : null | undefined - -declare const unionWithIntersection: ({ n: number } & { s: string }) & undefined | null; ->unionWithIntersection : ({ n: number; } & { s: string; } & undefined) | null ->n : number ->s : string ->null : null - -var rest5: { n: number, s: string }; ->rest5 : { n: number; s: string; } ->n : number ->s : string - -var {...rest5 } = unionWithIntersection; ->rest5 : { n: number; s: string; } ->unionWithIntersection : ({ n: number; } & { s: string; } & undefined) | null - diff --git a/tests/baselines/reference/restUnion3.errors.txt b/tests/baselines/reference/restUnion3.errors.txt new file mode 100644 index 00000000000..a960ad4a33b --- /dev/null +++ b/tests/baselines/reference/restUnion3.errors.txt @@ -0,0 +1,17 @@ +tests/cases/compiler/restUnion3.ts(3,9): error TS2700: Rest types may only be created from object types. +tests/cases/compiler/restUnion3.ts(7,9): error TS2700: Rest types may only be created from object types. + + +==== tests/cases/compiler/restUnion3.ts (2 errors) ==== + declare const nullAndUndefinedUnion: null | undefined; + var rest4: { }; + var {...rest4 } = nullAndUndefinedUnion; + ~~~~~ +!!! error TS2700: Rest types may only be created from object types. + + declare const unionWithIntersection: ({ n: number } & { s: string }) & undefined | null; + var rest5: { n: number, s: string }; + var {...rest5 } = unionWithIntersection; + ~~~~~ +!!! error TS2700: Rest types may only be created from object types. + \ No newline at end of file diff --git a/tests/baselines/reference/restUnion3.js b/tests/baselines/reference/restUnion3.js new file mode 100644 index 00000000000..f10bd7ed0a7 --- /dev/null +++ b/tests/baselines/reference/restUnion3.js @@ -0,0 +1,25 @@ +//// [restUnion3.ts] +declare const nullAndUndefinedUnion: null | undefined; +var rest4: { }; +var {...rest4 } = nullAndUndefinedUnion; + +declare const unionWithIntersection: ({ n: number } & { s: string }) & undefined | null; +var rest5: { n: number, s: string }; +var {...rest5 } = unionWithIntersection; + + +//// [restUnion3.js] +"use strict"; +var __rest = (this && this.__rest) || function (s, e) { + var t = {}; + for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) + t[p] = s[p]; + if (s != null && typeof Object.getOwnPropertySymbols === "function") + for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) if (e.indexOf(p[i]) < 0) + t[p[i]] = s[p[i]]; + return t; +}; +var rest4; +var rest4 = __rest(nullAndUndefinedUnion, []); +var rest5; +var rest5 = __rest(unionWithIntersection, []); diff --git a/tests/baselines/reference/spreadInvalidArgumentType.errors.txt b/tests/baselines/reference/spreadInvalidArgumentType.errors.txt index 5b48e24ad0d..4c1aa286aad 100644 --- a/tests/baselines/reference/spreadInvalidArgumentType.errors.txt +++ b/tests/baselines/reference/spreadInvalidArgumentType.errors.txt @@ -1,13 +1,24 @@ -tests/cases/compiler/spreadInvalidArgumentType.ts(19,16): error TS2698: Spread types may only be created from object types. -tests/cases/compiler/spreadInvalidArgumentType.ts(21,16): error TS2698: Spread types may only be created from object types. -tests/cases/compiler/spreadInvalidArgumentType.ts(23,16): error TS2698: Spread types may only be created from object types. -tests/cases/compiler/spreadInvalidArgumentType.ts(24,16): error TS2698: Spread types may only be created from object types. -tests/cases/compiler/spreadInvalidArgumentType.ts(26,16): error TS2698: Spread types may only be created from object types. -tests/cases/compiler/spreadInvalidArgumentType.ts(29,16): error TS2698: Spread types may only be created from object types. -tests/cases/compiler/spreadInvalidArgumentType.ts(31,17): error TS2698: Spread types may only be created from object types. +tests/cases/compiler/spreadInvalidArgumentType.ts(30,16): error TS2698: Spread types may only be created from object types. +tests/cases/compiler/spreadInvalidArgumentType.ts(32,16): error TS2698: Spread types may only be created from object types. +tests/cases/compiler/spreadInvalidArgumentType.ts(33,16): error TS2698: Spread types may only be created from object types. +tests/cases/compiler/spreadInvalidArgumentType.ts(34,16): error TS2698: Spread types may only be created from object types. +tests/cases/compiler/spreadInvalidArgumentType.ts(35,16): error TS2698: Spread types may only be created from object types. +tests/cases/compiler/spreadInvalidArgumentType.ts(38,16): error TS2698: Spread types may only be created from object types. +tests/cases/compiler/spreadInvalidArgumentType.ts(39,16): error TS2698: Spread types may only be created from object types. +tests/cases/compiler/spreadInvalidArgumentType.ts(41,17): error TS2698: Spread types may only be created from object types. +tests/cases/compiler/spreadInvalidArgumentType.ts(42,17): error TS2698: Spread types may only be created from object types. +tests/cases/compiler/spreadInvalidArgumentType.ts(44,17): error TS2698: Spread types may only be created from object types. +tests/cases/compiler/spreadInvalidArgumentType.ts(45,17): error TS2698: Spread types may only be created from object types. +tests/cases/compiler/spreadInvalidArgumentType.ts(47,17): error TS2698: Spread types may only be created from object types. +tests/cases/compiler/spreadInvalidArgumentType.ts(48,17): error TS2698: Spread types may only be created from object types. +tests/cases/compiler/spreadInvalidArgumentType.ts(52,17): error TS2698: Spread types may only be created from object types. +tests/cases/compiler/spreadInvalidArgumentType.ts(53,17): error TS2698: Spread types may only be created from object types. +tests/cases/compiler/spreadInvalidArgumentType.ts(55,17): error TS2698: Spread types may only be created from object types. -==== tests/cases/compiler/spreadInvalidArgumentType.ts (7 errors) ==== +==== tests/cases/compiler/spreadInvalidArgumentType.ts (16 errors) ==== + enum E { v1, v2 }; + function f(p1: T, p2: T[]) { var t: T; @@ -18,14 +29,23 @@ tests/cases/compiler/spreadInvalidArgumentType.ts(31,17): error TS2698: Spread t var mapped: {[P in "b"]: T[P]}; var union_generic: T | { a: number }; + var union_primitive: { a: number } | number; var intersection_generic: T & { a: number }; + var intersection_primitive: { a: number } | string; + + var num: number; + var str: number; + var literal_string: "string"; + var literal_number: 42; var u: undefined; var n: null; - var a: any; + + var e: E; + var o1 = { ...p1 }; // Error, generic type paramterre ~~~~~ !!! error TS2698: Spread types may only be created from object types. @@ -33,14 +53,12 @@ tests/cases/compiler/spreadInvalidArgumentType.ts(31,17): error TS2698: Spread t var o3 = { ...t }; // Error, generic type paramter ~~~~ !!! error TS2698: Spread types may only be created from object types. - var o4 = { ...i }; // Error, index access ~~~~ !!! error TS2698: Spread types may only be created from object types. var o5 = { ...k }; // Error, index ~~~~ !!! error TS2698: Spread types may only be created from object types. - var o6 = { ...mapped_generic }; // Error, generic mapped object type ~~~~~~~~~~~~~~~~~ !!! error TS2698: Spread types may only be created from object types. @@ -49,14 +67,42 @@ tests/cases/compiler/spreadInvalidArgumentType.ts(31,17): error TS2698: Spread t var o8 = { ...union_generic }; // Error, union with generic type parameter ~~~~~~~~~~~~~~~~ !!! error TS2698: Spread types may only be created from object types. + var o9 = { ...union_primitive }; // Error, union with generic type parameter + ~~~~~~~~~~~~~~~~~~ +!!! error TS2698: Spread types may only be created from object types. var o10 = { ...intersection_generic }; // Error, intersection with generic type parameter ~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS2698: Spread types may only be created from object types. + var o11 = { ...intersection_primitive }; // Error, intersection with generic type parameter + ~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2698: Spread types may only be created from object types. - var o14 = { ...u }; // OK - var o15 = { ...n }; // OK + var o12 = { ...num }; // Error + ~~~~~~ +!!! error TS2698: Spread types may only be created from object types. + var o13 = { ...str }; // Error + ~~~~~~ +!!! error TS2698: Spread types may only be created from object types. + + var o14 = { ...u }; // error, undefined-only not allowed + ~~~~ +!!! error TS2698: Spread types may only be created from object types. + var o15 = { ...n }; // error, null-only not allowed + ~~~~ +!!! error TS2698: Spread types may only be created from object types. var o16 = { ...a }; // OK + + var o17 = { ...literal_string }; // Error + ~~~~~~~~~~~~~~~~~ +!!! error TS2698: Spread types may only be created from object types. + var o18 = { ...literal_number }; // Error + ~~~~~~~~~~~~~~~~~ +!!! error TS2698: Spread types may only be created from object types. + + var o19 = { ...e }; // Error, enum + ~~~~ +!!! error TS2698: Spread types may only be created from object types. } \ No newline at end of file diff --git a/tests/baselines/reference/spreadInvalidArgumentType.js b/tests/baselines/reference/spreadInvalidArgumentType.js index aa42419e59a..7aa04616fd1 100644 --- a/tests/baselines/reference/spreadInvalidArgumentType.js +++ b/tests/baselines/reference/spreadInvalidArgumentType.js @@ -1,4 +1,6 @@ //// [spreadInvalidArgumentType.ts] +enum E { v1, v2 }; + function f(p1: T, p2: T[]) { var t: T; @@ -9,32 +11,49 @@ function f(p1: T, p2: T[]) { var mapped: {[P in "b"]: T[P]}; var union_generic: T | { a: number }; + var union_primitive: { a: number } | number; var intersection_generic: T & { a: number }; + var intersection_primitive: { a: number } | string; + + var num: number; + var str: number; + var literal_string: "string"; + var literal_number: 42; var u: undefined; var n: null; - var a: any; + + var e: E; + var o1 = { ...p1 }; // Error, generic type paramterre var o2 = { ...p2 }; // OK var o3 = { ...t }; // Error, generic type paramter - var o4 = { ...i }; // Error, index access var o5 = { ...k }; // Error, index - var o6 = { ...mapped_generic }; // Error, generic mapped object type var o7 = { ...mapped }; // OK, non-generic mapped type var o8 = { ...union_generic }; // Error, union with generic type parameter + var o9 = { ...union_primitive }; // Error, union with generic type parameter var o10 = { ...intersection_generic }; // Error, intersection with generic type parameter + var o11 = { ...intersection_primitive }; // Error, intersection with generic type parameter - var o14 = { ...u }; // OK - var o15 = { ...n }; // OK + var o12 = { ...num }; // Error + var o13 = { ...str }; // Error + + var o14 = { ...u }; // error, undefined-only not allowed + var o15 = { ...n }; // error, null-only not allowed var o16 = { ...a }; // OK + + var o17 = { ...literal_string }; // Error + var o18 = { ...literal_number }; // Error + + var o19 = { ...e }; // Error, enum } @@ -47,6 +66,12 @@ var __assign = (this && this.__assign) || Object.assign || function(t) { } return t; }; +var E; +(function (E) { + E[E["v1"] = 0] = "v1"; + E[E["v2"] = 1] = "v2"; +})(E || (E = {})); +; function f(p1, p2) { var t; var i; @@ -54,10 +79,17 @@ function f(p1, p2) { var mapped_generic; var mapped; var union_generic; + var union_primitive; var intersection_generic; + var intersection_primitive; + var num; + var str; + var literal_string; + var literal_number; var u; var n; var a; + var e; var o1 = __assign({}, p1); // Error, generic type paramterre var o2 = __assign({}, p2); // OK var o3 = __assign({}, t); // Error, generic type paramter @@ -66,8 +98,15 @@ function f(p1, p2) { var o6 = __assign({}, mapped_generic); // Error, generic mapped object type var o7 = __assign({}, mapped); // OK, non-generic mapped type var o8 = __assign({}, union_generic); // Error, union with generic type parameter + var o9 = __assign({}, union_primitive); // Error, union with generic type parameter var o10 = __assign({}, intersection_generic); // Error, intersection with generic type parameter - var o14 = __assign({}, u); // OK - var o15 = __assign({}, n); // OK + var o11 = __assign({}, intersection_primitive); // Error, intersection with generic type parameter + var o12 = __assign({}, num); // Error + var o13 = __assign({}, str); // Error + var o14 = __assign({}, u); // error, undefined-only not allowed + var o15 = __assign({}, n); // error, null-only not allowed var o16 = __assign({}, a); // OK + var o17 = __assign({}, literal_string); // Error + var o18 = __assign({}, literal_number); // Error + var o19 = __assign({}, e); // Error, enum } diff --git a/tests/baselines/reference/spreadUnion2.js b/tests/baselines/reference/spreadUnion2.js index 48b12731817..662b7cd3e46 100644 --- a/tests/baselines/reference/spreadUnion2.js +++ b/tests/baselines/reference/spreadUnion2.js @@ -1,7 +1,6 @@ //// [spreadUnion2.ts] declare const undefinedUnion: { a: number } | undefined; declare const nullUnion: { b: number } | null; -declare const nullAndUndefinedUnion: null | undefined; var o1: { a?: number | undefined }; var o1 = { ...undefinedUnion }; @@ -19,8 +18,6 @@ var o4 = { ...undefinedUnion, ...undefinedUnion }; var o5: { b?: number | undefined }; var o5 = { ...nullUnion, ...nullUnion }; -var o6 = { ...nullAndUndefinedUnion, ...nullAndUndefinedUnion }; -var o7 = { ...nullAndUndefinedUnion }; //// [spreadUnion2.js] @@ -43,5 +40,3 @@ var o4; var o4 = __assign({}, undefinedUnion, undefinedUnion); var o5; var o5 = __assign({}, nullUnion, nullUnion); -var o6 = __assign({}, nullAndUndefinedUnion, nullAndUndefinedUnion); -var o7 = __assign({}, nullAndUndefinedUnion); diff --git a/tests/baselines/reference/spreadUnion2.symbols b/tests/baselines/reference/spreadUnion2.symbols index 841bce12e42..2cc91f2980b 100644 --- a/tests/baselines/reference/spreadUnion2.symbols +++ b/tests/baselines/reference/spreadUnion2.symbols @@ -7,64 +7,53 @@ declare const nullUnion: { b: number } | null; >nullUnion : Symbol(nullUnion, Decl(spreadUnion2.ts, 1, 13)) >b : Symbol(b, Decl(spreadUnion2.ts, 1, 26)) -declare const nullAndUndefinedUnion: null | undefined; ->nullAndUndefinedUnion : Symbol(nullAndUndefinedUnion, Decl(spreadUnion2.ts, 2, 13)) - var o1: { a?: number | undefined }; ->o1 : Symbol(o1, Decl(spreadUnion2.ts, 4, 3), Decl(spreadUnion2.ts, 5, 3)) ->a : Symbol(a, Decl(spreadUnion2.ts, 4, 9)) +>o1 : Symbol(o1, Decl(spreadUnion2.ts, 3, 3), Decl(spreadUnion2.ts, 4, 3)) +>a : Symbol(a, Decl(spreadUnion2.ts, 3, 9)) var o1 = { ...undefinedUnion }; ->o1 : Symbol(o1, Decl(spreadUnion2.ts, 4, 3), Decl(spreadUnion2.ts, 5, 3)) +>o1 : Symbol(o1, Decl(spreadUnion2.ts, 3, 3), Decl(spreadUnion2.ts, 4, 3)) >undefinedUnion : Symbol(undefinedUnion, Decl(spreadUnion2.ts, 0, 13)) var o2: { b?: number | undefined }; ->o2 : Symbol(o2, Decl(spreadUnion2.ts, 7, 3), Decl(spreadUnion2.ts, 8, 3)) ->b : Symbol(b, Decl(spreadUnion2.ts, 7, 9)) +>o2 : Symbol(o2, Decl(spreadUnion2.ts, 6, 3), Decl(spreadUnion2.ts, 7, 3)) +>b : Symbol(b, Decl(spreadUnion2.ts, 6, 9)) var o2 = { ...nullUnion }; ->o2 : Symbol(o2, Decl(spreadUnion2.ts, 7, 3), Decl(spreadUnion2.ts, 8, 3)) +>o2 : Symbol(o2, Decl(spreadUnion2.ts, 6, 3), Decl(spreadUnion2.ts, 7, 3)) >nullUnion : Symbol(nullUnion, Decl(spreadUnion2.ts, 1, 13)) var o3: { a?: number | undefined, b?: number | undefined }; ->o3 : Symbol(o3, Decl(spreadUnion2.ts, 10, 3), Decl(spreadUnion2.ts, 11, 3), Decl(spreadUnion2.ts, 12, 3)) ->a : Symbol(a, Decl(spreadUnion2.ts, 10, 9)) ->b : Symbol(b, Decl(spreadUnion2.ts, 10, 33)) +>o3 : Symbol(o3, Decl(spreadUnion2.ts, 9, 3), Decl(spreadUnion2.ts, 10, 3), Decl(spreadUnion2.ts, 11, 3)) +>a : Symbol(a, Decl(spreadUnion2.ts, 9, 9)) +>b : Symbol(b, Decl(spreadUnion2.ts, 9, 33)) var o3 = { ...undefinedUnion, ...nullUnion }; ->o3 : Symbol(o3, Decl(spreadUnion2.ts, 10, 3), Decl(spreadUnion2.ts, 11, 3), Decl(spreadUnion2.ts, 12, 3)) +>o3 : Symbol(o3, Decl(spreadUnion2.ts, 9, 3), Decl(spreadUnion2.ts, 10, 3), Decl(spreadUnion2.ts, 11, 3)) >undefinedUnion : Symbol(undefinedUnion, Decl(spreadUnion2.ts, 0, 13)) >nullUnion : Symbol(nullUnion, Decl(spreadUnion2.ts, 1, 13)) var o3 = { ...nullUnion, ...undefinedUnion }; ->o3 : Symbol(o3, Decl(spreadUnion2.ts, 10, 3), Decl(spreadUnion2.ts, 11, 3), Decl(spreadUnion2.ts, 12, 3)) +>o3 : Symbol(o3, Decl(spreadUnion2.ts, 9, 3), Decl(spreadUnion2.ts, 10, 3), Decl(spreadUnion2.ts, 11, 3)) >nullUnion : Symbol(nullUnion, Decl(spreadUnion2.ts, 1, 13)) >undefinedUnion : Symbol(undefinedUnion, Decl(spreadUnion2.ts, 0, 13)) var o4: { a?: number | undefined }; ->o4 : Symbol(o4, Decl(spreadUnion2.ts, 14, 3), Decl(spreadUnion2.ts, 15, 3)) ->a : Symbol(a, Decl(spreadUnion2.ts, 14, 9)) +>o4 : Symbol(o4, Decl(spreadUnion2.ts, 13, 3), Decl(spreadUnion2.ts, 14, 3)) +>a : Symbol(a, Decl(spreadUnion2.ts, 13, 9)) var o4 = { ...undefinedUnion, ...undefinedUnion }; ->o4 : Symbol(o4, Decl(spreadUnion2.ts, 14, 3), Decl(spreadUnion2.ts, 15, 3)) +>o4 : Symbol(o4, Decl(spreadUnion2.ts, 13, 3), Decl(spreadUnion2.ts, 14, 3)) >undefinedUnion : Symbol(undefinedUnion, Decl(spreadUnion2.ts, 0, 13)) >undefinedUnion : Symbol(undefinedUnion, Decl(spreadUnion2.ts, 0, 13)) var o5: { b?: number | undefined }; ->o5 : Symbol(o5, Decl(spreadUnion2.ts, 17, 3), Decl(spreadUnion2.ts, 18, 3)) ->b : Symbol(b, Decl(spreadUnion2.ts, 17, 9)) +>o5 : Symbol(o5, Decl(spreadUnion2.ts, 16, 3), Decl(spreadUnion2.ts, 17, 3)) +>b : Symbol(b, Decl(spreadUnion2.ts, 16, 9)) var o5 = { ...nullUnion, ...nullUnion }; ->o5 : Symbol(o5, Decl(spreadUnion2.ts, 17, 3), Decl(spreadUnion2.ts, 18, 3)) +>o5 : Symbol(o5, Decl(spreadUnion2.ts, 16, 3), Decl(spreadUnion2.ts, 17, 3)) >nullUnion : Symbol(nullUnion, Decl(spreadUnion2.ts, 1, 13)) >nullUnion : Symbol(nullUnion, Decl(spreadUnion2.ts, 1, 13)) -var o6 = { ...nullAndUndefinedUnion, ...nullAndUndefinedUnion }; ->o6 : Symbol(o6, Decl(spreadUnion2.ts, 20, 3)) ->nullAndUndefinedUnion : Symbol(nullAndUndefinedUnion, Decl(spreadUnion2.ts, 2, 13)) ->nullAndUndefinedUnion : Symbol(nullAndUndefinedUnion, Decl(spreadUnion2.ts, 2, 13)) - -var o7 = { ...nullAndUndefinedUnion }; ->o7 : Symbol(o7, Decl(spreadUnion2.ts, 21, 3)) ->nullAndUndefinedUnion : Symbol(nullAndUndefinedUnion, Decl(spreadUnion2.ts, 2, 13)) diff --git a/tests/baselines/reference/spreadUnion2.types b/tests/baselines/reference/spreadUnion2.types index 50f79cc7745..ccf587af591 100644 --- a/tests/baselines/reference/spreadUnion2.types +++ b/tests/baselines/reference/spreadUnion2.types @@ -8,10 +8,6 @@ declare const nullUnion: { b: number } | null; >b : number >null : null -declare const nullAndUndefinedUnion: null | undefined; ->nullAndUndefinedUnion : null | undefined ->null : null - var o1: { a?: number | undefined }; >o1 : { a?: number | undefined; } >a : number | undefined @@ -67,14 +63,4 @@ var o5 = { ...nullUnion, ...nullUnion }; >nullUnion : { b: number; } | null >nullUnion : { b: number; } | null -var o6 = { ...nullAndUndefinedUnion, ...nullAndUndefinedUnion }; ->o6 : {} ->{ ...nullAndUndefinedUnion, ...nullAndUndefinedUnion } : {} ->nullAndUndefinedUnion : null | undefined ->nullAndUndefinedUnion : null | undefined - -var o7 = { ...nullAndUndefinedUnion }; ->o7 : {} ->{ ...nullAndUndefinedUnion } : {} ->nullAndUndefinedUnion : null | undefined diff --git a/tests/baselines/reference/spreadUnion3.errors.txt b/tests/baselines/reference/spreadUnion3.errors.txt index f3fa2da7597..24d864d96fe 100644 --- a/tests/baselines/reference/spreadUnion3.errors.txt +++ b/tests/baselines/reference/spreadUnion3.errors.txt @@ -2,11 +2,13 @@ tests/cases/conformance/types/spread/spreadUnion3.ts(2,5): error TS2322: Type '{ Types of property 'y' are incompatible. Type 'string | number' is not assignable to type 'string'. Type 'number' is not assignable to type 'string'. -tests/cases/conformance/types/spread/spreadUnion3.ts(9,23): error TS2339: Property 'a' does not exist on type '{} | {} | { a: number; }'. - Property 'a' does not exist on type '{}'. +tests/cases/conformance/types/spread/spreadUnion3.ts(9,9): error TS2322: Type 'number | undefined' is not assignable to type 'number'. + Type 'undefined' is not assignable to type 'number'. +tests/cases/conformance/types/spread/spreadUnion3.ts(17,11): error TS2698: Spread types may only be created from object types. +tests/cases/conformance/types/spread/spreadUnion3.ts(18,11): error TS2698: Spread types may only be created from object types. -==== tests/cases/conformance/types/spread/spreadUnion3.ts (2 errors) ==== +==== tests/cases/conformance/types/spread/spreadUnion3.ts (4 errors) ==== function f(x: { y: string } | undefined): { y: string } { return { y: 123, ...x } // y: string | number ~~~~~~~~~~~~~~~~~~~~~~~ @@ -21,11 +23,20 @@ tests/cases/conformance/types/spread/spreadUnion3.ts(9,23): error TS2339: Proper function g(t?: { a: number } | null): void { let b = { ...t }; let c: number = b.a; // might not have 'a' - ~ -!!! error TS2339: Property 'a' does not exist on type '{} | {} | { a: number; }'. -!!! error TS2339: Property 'a' does not exist on type '{}'. + ~ +!!! error TS2322: Type 'number | undefined' is not assignable to type 'number'. +!!! error TS2322: Type 'undefined' is not assignable to type 'number'. } g() g(undefined) g(null) + + // spreading nothing but null and undefined is not allowed + declare const nullAndUndefinedUnion: null | undefined; + var x = { ...nullAndUndefinedUnion, ...nullAndUndefinedUnion }; + ~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2698: Spread types may only be created from object types. + var y = { ...nullAndUndefinedUnion }; + ~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2698: Spread types may only be created from object types. \ No newline at end of file diff --git a/tests/baselines/reference/spreadUnion3.js b/tests/baselines/reference/spreadUnion3.js index 2aaf9efeb78..253c2998b9d 100644 --- a/tests/baselines/reference/spreadUnion3.js +++ b/tests/baselines/reference/spreadUnion3.js @@ -12,6 +12,11 @@ function g(t?: { a: number } | null): void { g() g(undefined) g(null) + +// spreading nothing but null and undefined is not allowed +declare const nullAndUndefinedUnion: null | undefined; +var x = { ...nullAndUndefinedUnion, ...nullAndUndefinedUnion }; +var y = { ...nullAndUndefinedUnion }; //// [spreadUnion3.js] @@ -34,3 +39,5 @@ function g(t) { g(); g(undefined); g(null); +var x = __assign({}, nullAndUndefinedUnion, nullAndUndefinedUnion); +var y = __assign({}, nullAndUndefinedUnion); diff --git a/tests/cases/compiler/restInvalidArgumentType.ts b/tests/cases/compiler/restInvalidArgumentType.ts index 2d50903328f..db372fbd4af 100644 --- a/tests/cases/compiler/restInvalidArgumentType.ts +++ b/tests/cases/compiler/restInvalidArgumentType.ts @@ -1,3 +1,5 @@ +enum E { v1, v2 }; + function f(p1: T, p2: T[]) { var t: T; @@ -8,7 +10,14 @@ function f(p1: T, p2: T[]) { var mapped: {[P in "b"]: T[P]}; var union_generic: T | { a: number }; + var union_primitive: { a: number } | number; var intersection_generic: T & { a: number }; + var intersection_primitive: { a: number } & string; + var num: number; + var str: string; + var literal_string: "string"; + var literal_number: 42; + var e: E; var u: undefined; var n: null; @@ -18,7 +27,6 @@ function f(p1: T, p2: T[]) { var {...r1} = p1; // Error, generic type paramterre var {...r2} = p2; // OK var {...r3} = t; // Error, generic type paramter - var {...r4} = i; // Error, index access var {...r5} = k; // Error, index @@ -26,11 +34,21 @@ function f(p1: T, p2: T[]) { var {...r7} = mapped; // OK, non-generic mapped type var {...r8} = union_generic; // Error, union with generic type parameter + var {...r9} = union_primitive; // Error, union with generic type parameter var {...r10} = intersection_generic; // Error, intersection with generic type parameter + var {...r11} = intersection_primitive; // Error, intersection with generic type parameter - var {...r14} = u; // OK - var {...r15} = n; // OK + var {...r12} = num; // Error + var {...r13} = str; // Error + + var {...r14} = u; // error, undefined-only not allowed + var {...r15} = n; // error, null-only not allowed var {...r16} = a; // OK + + var {...r17} = literal_string; // Error + var {...r18} = literal_number; // Error + + var {...r19} = e; // Error, enum } diff --git a/tests/cases/compiler/restUnion2.ts b/tests/cases/compiler/restUnion2.ts index 83d94e03a73..9ae6503fb13 100644 --- a/tests/cases/compiler/restUnion2.ts +++ b/tests/cases/compiler/restUnion2.ts @@ -8,12 +8,3 @@ var {...rest2 } = undefinedUnion; declare const nullUnion: { n: number } | null; var rest3: { n: number }; var {...rest3 } = nullUnion; - - -declare const nullAndUndefinedUnion: null | undefined; -var rest4: { }; -var {...rest4 } = nullAndUndefinedUnion; - -declare const unionWithIntersection: ({ n: number } & { s: string }) & undefined | null; -var rest5: { n: number, s: string }; -var {...rest5 } = unionWithIntersection; \ No newline at end of file diff --git a/tests/cases/compiler/restUnion3.ts b/tests/cases/compiler/restUnion3.ts new file mode 100644 index 00000000000..313d83d282d --- /dev/null +++ b/tests/cases/compiler/restUnion3.ts @@ -0,0 +1,8 @@ +// @strict: true +declare const nullAndUndefinedUnion: null | undefined; +var rest4: { }; +var {...rest4 } = nullAndUndefinedUnion; + +declare const unionWithIntersection: ({ n: number } & { s: string }) & undefined | null; +var rest5: { n: number, s: string }; +var {...rest5 } = unionWithIntersection; diff --git a/tests/cases/compiler/spreadInvalidArgumentType.ts b/tests/cases/compiler/spreadInvalidArgumentType.ts index bf7365e8ab0..f18e73b31ef 100644 --- a/tests/cases/compiler/spreadInvalidArgumentType.ts +++ b/tests/cases/compiler/spreadInvalidArgumentType.ts @@ -1,3 +1,5 @@ +enum E { v1, v2 }; + function f(p1: T, p2: T[]) { var t: T; @@ -8,30 +10,47 @@ function f(p1: T, p2: T[]) { var mapped: {[P in "b"]: T[P]}; var union_generic: T | { a: number }; + var union_primitive: { a: number } | number; var intersection_generic: T & { a: number }; + var intersection_primitive: { a: number } | string; + + var num: number; + var str: number; + var literal_string: "string"; + var literal_number: 42; var u: undefined; var n: null; - var a: any; + + var e: E; + var o1 = { ...p1 }; // Error, generic type paramterre var o2 = { ...p2 }; // OK var o3 = { ...t }; // Error, generic type paramter - var o4 = { ...i }; // Error, index access var o5 = { ...k }; // Error, index - var o6 = { ...mapped_generic }; // Error, generic mapped object type var o7 = { ...mapped }; // OK, non-generic mapped type var o8 = { ...union_generic }; // Error, union with generic type parameter + var o9 = { ...union_primitive }; // Error, union with generic type parameter var o10 = { ...intersection_generic }; // Error, intersection with generic type parameter + var o11 = { ...intersection_primitive }; // Error, intersection with generic type parameter - var o14 = { ...u }; // OK - var o15 = { ...n }; // OK + var o12 = { ...num }; // Error + var o13 = { ...str }; // Error + + var o14 = { ...u }; // error, undefined-only not allowed + var o15 = { ...n }; // error, null-only not allowed var o16 = { ...a }; // OK + + var o17 = { ...literal_string }; // Error + var o18 = { ...literal_number }; // Error + + var o19 = { ...e }; // Error, enum } diff --git a/tests/cases/conformance/types/spread/objectSpread.ts b/tests/cases/conformance/types/spread/objectSpread.ts index 566c9eb0384..c7cf5e49eed 100644 --- a/tests/cases/conformance/types/spread/objectSpread.ts +++ b/tests/cases/conformance/types/spread/objectSpread.ts @@ -39,12 +39,26 @@ getter.a = 12; // functions result in { } let spreadFunc = { ...(function () { }) }; -// boolean && T results in Partial -function conditionalSpreadBoolean(b: boolean) : { x?: number | undefined, y?: number | undefined } { - return { ...b && { x: 1, y: 2 } }; +type Header = { head: string, body: string, authToken: string } +function from16326(this: { header: Header }, header: Header, authToken: string): Header { + return { + ...this.header, + ...header, + ...authToken && { authToken } + } } -function conditionalSpreadNumber(nt: number): { x?: number | undefined, y: number } { +// boolean && T results in Partial +function conditionalSpreadBoolean(b: boolean) : { x: number, y: number } { let o = { x: 12, y: 13 } + o = { + ...o, + ...b && { x: 14 } + } + let o2 = { ...b && { x: 21 }} + return o; +} +function conditionalSpreadNumber(nt: number): { x: number, y: number } { + let o = { x: 15, y: 16 } o = { ...o, ...nt && { x: nt } @@ -52,8 +66,8 @@ function conditionalSpreadNumber(nt: number): { x?: number | undefined, y: numbe let o2 = { ...nt && { x: nt }} return o; } -function conditionalSpreadString(st: string): { x?: string | undefined, y: number } { - let o = { x: 'hi', y: 13 } +function conditionalSpreadString(st: string): { x: string, y: number } { + let o = { x: 'hi', y: 17 } o = { ...o, ...st && { x: st } @@ -61,8 +75,6 @@ function conditionalSpreadString(st: string): { x?: string | undefined, y: numbe let o2 = { ...st && { x: st }} return o; } -// other booleans result in { } -let spreadBool = { ... true } // any results in any let anything: any; diff --git a/tests/cases/conformance/types/spread/objectSpreadNegative.ts b/tests/cases/conformance/types/spread/objectSpreadNegative.ts index 8fe9174f759..b6e7c5b88c9 100644 --- a/tests/cases/conformance/types/spread/objectSpreadNegative.ts +++ b/tests/cases/conformance/types/spread/objectSpreadNegative.ts @@ -29,7 +29,13 @@ spread = b; // error, missing 's' let duplicated = { b: 'bad', ...o, b: 'bad', ...o2, b: 'bad' } let duplicatedSpread = { ...o, ...o } -// primitives are skipped +// primitives are not allowed, except for falsy ones +let spreadNum = { ...12 }; +let spreadSum = { ...1 + 1 }; +let spreadZero = { ...0 }; +spreadZero.toFixed(); // error, no methods even from a falsy number +let spreadBool = { ...true }; +spreadBool.valueOf(); let spreadStr = { ...'foo' }; spreadStr.length; // error, no 'length' spreadStr.charAt(1); // error, no methods either diff --git a/tests/cases/conformance/types/spread/spreadUnion2.ts b/tests/cases/conformance/types/spread/spreadUnion2.ts index 17abdd4006a..549441be411 100644 --- a/tests/cases/conformance/types/spread/spreadUnion2.ts +++ b/tests/cases/conformance/types/spread/spreadUnion2.ts @@ -2,7 +2,6 @@ declare const undefinedUnion: { a: number } | undefined; declare const nullUnion: { b: number } | null; -declare const nullAndUndefinedUnion: null | undefined; var o1: { a?: number | undefined }; var o1 = { ...undefinedUnion }; @@ -20,5 +19,3 @@ var o4 = { ...undefinedUnion, ...undefinedUnion }; var o5: { b?: number | undefined }; var o5 = { ...nullUnion, ...nullUnion }; -var o6 = { ...nullAndUndefinedUnion, ...nullAndUndefinedUnion }; -var o7 = { ...nullAndUndefinedUnion }; diff --git a/tests/cases/conformance/types/spread/spreadUnion3.ts b/tests/cases/conformance/types/spread/spreadUnion3.ts index c16acbdf7d3..42ad1a1c652 100644 --- a/tests/cases/conformance/types/spread/spreadUnion3.ts +++ b/tests/cases/conformance/types/spread/spreadUnion3.ts @@ -12,3 +12,8 @@ function g(t?: { a: number } | null): void { g() g(undefined) g(null) + +// spreading nothing but null and undefined is not allowed +declare const nullAndUndefinedUnion: null | undefined; +var x = { ...nullAndUndefinedUnion, ...nullAndUndefinedUnion }; +var y = { ...nullAndUndefinedUnion }; From 0197357e31007a1ff63290253a9ee269c5f96542 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Fri, 15 Sep 2017 10:28:13 -0700 Subject: [PATCH 352/370] Remove mistakenly added test file Intended for a different PR --- .../narrowContextualTypeOfObjectLiteral2.ts | 21 ------------------- 1 file changed, 21 deletions(-) delete mode 100644 tests/cases/compiler/narrowContextualTypeOfObjectLiteral2.ts diff --git a/tests/cases/compiler/narrowContextualTypeOfObjectLiteral2.ts b/tests/cases/compiler/narrowContextualTypeOfObjectLiteral2.ts deleted file mode 100644 index 2a199b74bd7..00000000000 --- a/tests/cases/compiler/narrowContextualTypeOfObjectLiteral2.ts +++ /dev/null @@ -1,21 +0,0 @@ -interface X { - type1: 'x'; - value: string; -} - -interface Y { - type2: 'y'; - value: 'none' | 'done'; -} - -function foo(bar: X | Y) { } - -foo({ - type2: 'y', - value: 'done', -}); -// you could do this (amybe) by noting that -// (1) the argument is a fresh object literal -// (2) of X | Y, the object literal is only assignable to Y -// - you can do *that* cheaply (ie, symbolically) just by throwing out types -// that are missing one of the fields in the object literal From 74139186ed6db214dcae39b019f5d29fc245a77a Mon Sep 17 00:00:00 2001 From: Andrew Casey Date: Fri, 15 Sep 2017 10:28:20 -0700 Subject: [PATCH 353/370] Re-enable extraction of single tokens Now that we explicitly prevent extraction of empty spans. --- src/services/refactors/extractMethod.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/services/refactors/extractMethod.ts b/src/services/refactors/extractMethod.ts index 9ea3d9d11bd..3b8ea19a9f0 100644 --- a/src/services/refactors/extractMethod.ts +++ b/src/services/refactors/extractMethod.ts @@ -92,7 +92,7 @@ namespace ts.refactor.extractMethod { export const CannotExtractRangeThatContainsWritesToReferencesLocatedOutsideOfTheTargetRangeInGenerators: DiagnosticMessage = createMessage("Cannot extract range containing writes to references located outside of the target range in generators."); export const TypeWillNotBeVisibleInTheNewScope = createMessage("Type will not visible in the new scope."); export const FunctionWillNotBeVisibleInTheNewScope = createMessage("Function will not visible in the new scope."); - export const InsufficientSelection = createMessage("Select more than a single token."); + export const InsufficientSelection = createMessage("Select more than a single identifier."); export const CannotExtractExportedEntity = createMessage("Cannot extract exported declaration"); export const CannotCombineWritesAndReturns = createMessage("Cannot combine writes and returns"); export const CannotExtractReadonlyPropertyInitializerOutsideConstructor = createMessage("Cannot move initialization of read-only class property outside of the constructor"); @@ -231,7 +231,7 @@ namespace ts.refactor.extractMethod { } function checkRootNode(node: Node): Diagnostic[] | undefined { - if (isToken(isExpressionStatement(node) ? node.expression : node)) { + if (isIdentifier(isExpressionStatement(node) ? node.expression : node)) { return [createDiagnosticForNode(node, Messages.InsufficientSelection)]; } return undefined; From 7781245f1e9994c992161699d5f832d5131d2753 Mon Sep 17 00:00:00 2001 From: uniqueiniquity Date: Fri, 15 Sep 2017 10:38:05 -0700 Subject: [PATCH 354/370] Move RegionRange to private scope --- src/compiler/types.ts | 4 ---- src/services/outliningElementsCollector.ts | 4 ++++ 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 4bf180c595a..608bc779042 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -2037,10 +2037,6 @@ namespace ts { end: -1; } - export interface RegionRange extends TextRange { - name?: string; - } - // represents a top level: { type } expression in a JSDoc comment. export interface JSDocTypeExpression extends TypeNode { kind: SyntaxKind.JSDocTypeExpression; diff --git a/src/services/outliningElementsCollector.ts b/src/services/outliningElementsCollector.ts index d4f70d52eda..20456b5241b 100644 --- a/src/services/outliningElementsCollector.ts +++ b/src/services/outliningElementsCollector.ts @@ -6,6 +6,10 @@ namespace ts.OutliningElementsCollector { const regionStart = new RegExp("^//\\s*#region(\\s+.*)?$"); const regionEnd = new RegExp("^//\\s*#endregion(\\s|$)"); + interface RegionRange extends TextRange { + name?: string; + } + export function collectElements(sourceFile: SourceFile, cancellationToken: CancellationToken): OutliningSpan[] { const elements: OutliningSpan[] = []; let depth = 0; From abd4f58824e2c3b09a486dfcfe2b5f42bc33e938 Mon Sep 17 00:00:00 2001 From: Andrew Casey Date: Fri, 15 Sep 2017 10:45:15 -0700 Subject: [PATCH 355/370] Restore single-token tests --- ...d-not-for-token.ts => extract-method-not-for-empty.ts} | 0 tests/cases/fourslash/extract-method13.ts | 8 ++++---- tests/cases/fourslash/extract-method7.ts | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) rename tests/cases/fourslash/{extract-method-not-for-token.ts => extract-method-not-for-empty.ts} (100%) diff --git a/tests/cases/fourslash/extract-method-not-for-token.ts b/tests/cases/fourslash/extract-method-not-for-empty.ts similarity index 100% rename from tests/cases/fourslash/extract-method-not-for-token.ts rename to tests/cases/fourslash/extract-method-not-for-empty.ts diff --git a/tests/cases/fourslash/extract-method13.ts b/tests/cases/fourslash/extract-method13.ts index 274753fd5cd..409b5f890ad 100644 --- a/tests/cases/fourslash/extract-method13.ts +++ b/tests/cases/fourslash/extract-method13.ts @@ -5,7 +5,7 @@ //// class C { //// static j = /*c*/1 + 1/*d*/; -//// constructor(q: string = /*a*/"a" + "b"/*b*/) { +//// constructor(q: string = /*a*/"hello"/*b*/) { //// } //// } @@ -21,7 +21,7 @@ edit.applyRefactor({ } private static newFunction(): string { - return "a" + "b"; + return "hello"; } }` }); @@ -32,7 +32,7 @@ verify.currentFileContentIs(`class C { } private static newFunction(): string { - return "a" + "b"; + return "hello"; } }`); @@ -52,7 +52,7 @@ edit.applyRefactor({ } private static newFunction(): string { - return "a" + "b"; + return "hello"; } }` }); diff --git a/tests/cases/fourslash/extract-method7.ts b/tests/cases/fourslash/extract-method7.ts index c28e12dce8c..0ce39c5a309 100644 --- a/tests/cases/fourslash/extract-method7.ts +++ b/tests/cases/fourslash/extract-method7.ts @@ -3,7 +3,7 @@ // You cannot extract a function initializer into the function's body. // The innermost scope (scope_0) is the sibling of the function, not the function itself. -//// function fn(x = /*a*/1 + 1/*b*/) { +//// function fn(x = /*a*/3/*b*/) { //// } goTo.select('a', 'b'); @@ -15,7 +15,7 @@ edit.applyRefactor({ `function fn(x = /*RENAME*/newFunction()) { } function newFunction() { - return 1 + 1; + return 3; } ` }); From 11333a7bc2599d6bb761936f7b5522a9b844a1e9 Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Fri, 15 Sep 2017 10:45:20 -0700 Subject: [PATCH 356/370] Conditional declaration (#18506) --- src/harness/parallel/host.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/harness/parallel/host.ts b/src/harness/parallel/host.ts index 58e794bbc7d..a3a1ec8082b 100644 --- a/src/harness/parallel/host.ts +++ b/src/harness/parallel/host.ts @@ -1,7 +1,7 @@ -// tslint:disable-next-line -var describe: Mocha.IContextDefinition; // If launched without mocha for parallel mode, we still need a global describe visible to satisfy the parsing of the unit tests -// tslint:disable-next-line -var it: Mocha.ITestDefinition; +if (typeof describe === "undefined") { + (global as any).describe = undefined; // If launched without mocha for parallel mode, we still need a global describe visible to satisfy the parsing of the unit tests + (global as any).it = undefined; +} namespace Harness.Parallel.Host { interface ChildProcessPartial { From 965a4d5aeb61610c97a8fec1e0cc2e7d9980e51e Mon Sep 17 00:00:00 2001 From: Andrew Casey Date: Fri, 15 Sep 2017 11:33:05 -0700 Subject: [PATCH 357/370] Restructure handling to TI messages to enforce exhaustiveness --- src/server/server.ts | 160 +++++++++++++++++++++++-------------------- 1 file changed, 86 insertions(+), 74 deletions(-) diff --git a/src/server/server.ts b/src/server/server.ts index fe83e879433..8849b5f3a8d 100644 --- a/src/server/server.ts +++ b/src/server/server.ts @@ -380,84 +380,96 @@ namespace ts.server { this.logger.info(`Received response: ${JSON.stringify(response)}`); } - if (response.kind === EventInitializationFailed) { - if (!this.eventSender) { - return; - } - const body: protocol.TypesInstallerInitializationFailedEventBody = { - message: response.message - }; - const eventName: protocol.TypesInstallerInitializationFailedEventName = "typesInstallerInitializationFailed"; - this.eventSender.event(body, eventName); - return; - } - - if (response.kind === EventBeginInstallTypes) { - if (!this.eventSender) { - return; - } - const body: protocol.BeginInstallTypesEventBody = { - eventId: response.eventId, - packages: response.packagesToInstall, - }; - const eventName: protocol.BeginInstallTypesEventName = "beginInstallTypes"; - this.eventSender.event(body, eventName); - - return; - } - - if (response.kind === EventEndInstallTypes) { - if (!this.eventSender) { - return; - } - if (this.telemetryEnabled) { - const body: protocol.TypingsInstalledTelemetryEventBody = { - telemetryEventName: "typingsInstalled", - payload: { - installedPackages: response.packagesToInstall.join(","), - installSuccess: response.installSuccess, - typingsInstallerVersion: response.typingsInstallerVersion - } - }; - const eventName: protocol.TelemetryEventName = "telemetry"; - this.eventSender.event(body, eventName); - } - - const body: protocol.EndInstallTypesEventBody = { - eventId: response.eventId, - packages: response.packagesToInstall, - success: response.installSuccess, - }; - const eventName: protocol.EndInstallTypesEventName = "endInstallTypes"; - this.eventSender.event(body, eventName); - return; - } - - if (response.kind === ActionSet) { - if (this.activeRequestCount > 0) { - this.activeRequestCount--; - } - else { - Debug.fail("Received too many responses"); - } - - while (this.requestQueue.length > 0) { - const queuedRequest = this.requestQueue.shift(); - if (this.requestMap.get(queuedRequest.operationId) === queuedRequest) { - this.requestMap.delete(queuedRequest.operationId); - this.scheduleRequest(queuedRequest); + switch (response.kind) { + case EventInitializationFailed: + { + if (!this.eventSender) { break; } - - if (this.logger.hasLevel(LogLevel.verbose)) { - this.logger.info(`Skipping defunct request for: ${queuedRequest.operationId}`); - } + const body: protocol.TypesInstallerInitializationFailedEventBody = { + message: response.message + }; + const eventName: protocol.TypesInstallerInitializationFailedEventName = "typesInstallerInitializationFailed"; + this.eventSender.event(body, eventName); + break; } - } + case EventBeginInstallTypes: + { + if (!this.eventSender) { + break; + } + const body: protocol.BeginInstallTypesEventBody = { + eventId: response.eventId, + packages: response.packagesToInstall, + }; + const eventName: protocol.BeginInstallTypesEventName = "beginInstallTypes"; + this.eventSender.event(body, eventName); + break; + } + case EventEndInstallTypes: + { + if (!this.eventSender) { + break; + } + if (this.telemetryEnabled) { + const body: protocol.TypingsInstalledTelemetryEventBody = { + telemetryEventName: "typingsInstalled", + payload: { + installedPackages: response.packagesToInstall.join(","), + installSuccess: response.installSuccess, + typingsInstallerVersion: response.typingsInstallerVersion + } + }; + const eventName: protocol.TelemetryEventName = "telemetry"; + this.eventSender.event(body, eventName); + } - this.projectService.updateTypingsForProject(response); - if (response.kind === ActionSet && this.socket) { - this.sendEvent(0, "setTypings", response); + const body: protocol.EndInstallTypesEventBody = { + eventId: response.eventId, + packages: response.packagesToInstall, + success: response.installSuccess, + }; + const eventName: protocol.EndInstallTypesEventName = "endInstallTypes"; + this.eventSender.event(body, eventName); + break; + } + case ActionInvalidate: + { + this.projectService.updateTypingsForProject(response); + break; + } + case ActionSet: + { + if (this.activeRequestCount > 0) { + this.activeRequestCount--; + } + else { + Debug.fail("Received too many responses"); + } + + while (this.requestQueue.length > 0) { + const queuedRequest = this.requestQueue.shift(); + if (this.requestMap.get(queuedRequest.operationId) === queuedRequest) { + this.requestMap.delete(queuedRequest.operationId); + this.scheduleRequest(queuedRequest); + break; + } + + if (this.logger.hasLevel(LogLevel.verbose)) { + this.logger.info(`Skipping defunct request for: ${queuedRequest.operationId}`); + } + } + + this.projectService.updateTypingsForProject(response); + + if (this.socket) { + this.sendEvent(0, "setTypings", response); + } + + break; + } + default: + assertTypeIsNever(response); } } From 7ba140445d7cde3effd76d52ec6538339a741a52 Mon Sep 17 00:00:00 2001 From: Andrew Casey Date: Fri, 15 Sep 2017 13:58:49 -0700 Subject: [PATCH 358/370] Fix broken test --- src/harness/unittests/extractMethods.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/harness/unittests/extractMethods.ts b/src/harness/unittests/extractMethods.ts index ca77af61c75..6d8eed3b8b0 100644 --- a/src/harness/unittests/extractMethods.ts +++ b/src/harness/unittests/extractMethods.ts @@ -410,7 +410,7 @@ function test(x: number) { "Statement or expression expected." ]); - testExtractRangeFailed("extract-method-not-for-token-expression-statement", `[#|a|]`, ["Select more than a single token."]); + testExtractRangeFailed("extract-method-not-for-token-expression-statement", `[#|a|]`, ["Select more than a single identifier."]); testExtractMethod("extractMethod1", `namespace A { From 3dfeb2d0f4274169e2974abe52e4213d666304d3 Mon Sep 17 00:00:00 2001 From: uniqueiniquity Date: Fri, 15 Sep 2017 15:33:34 -0700 Subject: [PATCH 359/370] Combine and simplify regex --- src/services/outliningElementsCollector.ts | 63 ++++++------------- .../fourslash/getOutliningSpansForRegions.ts | 5 ++ 2 files changed, 24 insertions(+), 44 deletions(-) diff --git a/src/services/outliningElementsCollector.ts b/src/services/outliningElementsCollector.ts index 20456b5241b..e215663372b 100644 --- a/src/services/outliningElementsCollector.ts +++ b/src/services/outliningElementsCollector.ts @@ -3,8 +3,7 @@ namespace ts.OutliningElementsCollector { const collapseText = "..."; const maxDepth = 20; const defaultLabel = "#region"; - const regionStart = new RegExp("^//\\s*#region(\\s+.*)?$"); - const regionEnd = new RegExp("^//\\s*#endregion(\\s|$)"); + const regionMatch = new RegExp("^\\s*//\\s*(#region|#endregion)(?:\\s+(.*))?$"); interface RegionRange extends TextRange { name?: string; @@ -111,55 +110,31 @@ namespace ts.OutliningElementsCollector { return isFunctionBlock(node) && node.parent.kind !== SyntaxKind.ArrowFunction; } - function getRegionName(start: number, end: number) { - if (!isInComment(sourceFile, start)) { - const comment = sourceFile.text.substring(start, end).trim(); - const result = comment.match(regionStart); - - if (result && result.length > 0) { - const label = result.pop(); - if (label) { - return label.trim(); - } - else { - return defaultLabel; - } - } - } - return ""; - } - - function isRegionEnd(start: number, end: number) { - if (!isInComment(sourceFile, start)) { - const comment = sourceFile.text.substring(start, end).trim(); - return !!comment.match(regionEnd); - } - return false; - } - function gatherRegions(): void { const lineStarts = sourceFile.getLineStarts(); for (let i = 0; i < lineStarts.length; i++) { const currentLineStart = lineStarts[i]; const lineEnd = lineStarts[i + 1] - 1 || sourceFile.getEnd(); + const comment = sourceFile.text.substring(currentLineStart, lineEnd); + const result = comment.match(regionMatch); - const name = getRegionName(currentLineStart, lineEnd); - if (name) { - const start = sourceFile.getFullText().indexOf("//", currentLineStart); - const region: RegionRange = { - pos: start, - end: lineEnd, - name, - }; - regions.push(region); - } - else if (isRegionEnd(currentLineStart, lineEnd)) { - const region = regions.pop(); - - if (region) { - region.end = lineEnd; - addOutliningSpanRegions(region); + if (result && !isInComment(sourceFile, currentLineStart)) { + if (result[1] === "#region") { + const start = sourceFile.getFullText().indexOf("//", currentLineStart); + const region: RegionRange = { + pos: start, + end: lineEnd, + name: result[2] || defaultLabel, + }; + regions.push(region); + } + else { + const region = regions.pop(); + if (region) { + region.end = lineEnd; + addOutliningSpanRegions(region); + } } } } diff --git a/tests/cases/fourslash/getOutliningSpansForRegions.ts b/tests/cases/fourslash/getOutliningSpansForRegions.ts index 151526c6b99..fcd71e29ef1 100644 --- a/tests/cases/fourslash/getOutliningSpansForRegions.ts +++ b/tests/cases/fourslash/getOutliningSpansForRegions.ts @@ -5,6 +5,11 @@ //// ////// #endregion|] //// +////// region without label with trailing spaces +////[|// #region +//// +////// #endregion|] +//// ////// region with label ////[|// #region label1 //// From cb8d9d6143c2d50b79e330599acff88ec20ac0b1 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Fri, 15 Sep 2017 16:11:41 -0700 Subject: [PATCH 360/370] Revert spread-falsy-union/fix spread of primitive Turns out partialising falsy unions wasn't needed -- I was just returning the wrong thing when spreading primitives. --- src/compiler/checker.ts | 36 ++++-------- tests/baselines/reference/objectSpread.types | 30 +++++----- .../reference/objectSpreadNegative.errors.txt | 4 +- tests/baselines/reference/spreadUnion2.js | 10 ++-- .../baselines/reference/spreadUnion2.symbols | 24 ++++---- tests/baselines/reference/spreadUnion2.types | 58 ++++++++++--------- .../reference/spreadUnion3.errors.txt | 22 +++---- .../conformance/types/spread/spreadUnion2.ts | 10 ++-- 8 files changed, 92 insertions(+), 102 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 1b55c592784..62d44d160a7 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -7846,7 +7846,6 @@ namespace ts { * and right = the new element to be spread. */ function getSpreadType(left: Type, right: Type): Type { - let truthyRight: Type; if (left.flags & TypeFlags.Any || right.flags & TypeFlags.Any) { return anyType; } @@ -7860,16 +7859,13 @@ namespace ts { return mapType(left, t => getSpreadType(t, right)); } if (right.flags & TypeFlags.Union) { - truthyRight = getTruthyTypeFromFalsyUnion(right as UnionType); - if (!truthyRight || truthyRight.flags & TypeFlags.Union) { - return mapType(right, t => getSpreadType(left, t)); - } - else { - right = truthyRight; - } + return mapType(right, t => getSpreadType(left, t)); } - if (right.flags & (TypeFlags.NonPrimitive | TypeFlags.BooleanLike | TypeFlags.NumberLike | TypeFlags.StringLike | TypeFlags.EnumLike)) { - return emptyObjectType; + if (right.flags & TypeFlags.NonPrimitive) { + return nonPrimitiveType; + } + if (right.flags & (TypeFlags.BooleanLike | TypeFlags.NumberLike | TypeFlags.StringLike | TypeFlags.EnumLike)) { + return left; } const members = createSymbolTable(); @@ -7893,7 +7889,7 @@ namespace ts { skippedPrivateMembers.set(rightProp.escapedName, true); } else if (!isClassMethod(rightProp) && !isSetterWithoutGetter) { - members.set(rightProp.escapedName, getSymbolOfSpreadProperty(rightProp, !!truthyRight)); + members.set(rightProp.escapedName, getNonReadonlySymbol(rightProp)); } } @@ -7918,22 +7914,19 @@ namespace ts { } } else { - members.set(leftProp.escapedName, getSymbolOfSpreadProperty(leftProp, /*makeOptional*/ false)); + members.set(leftProp.escapedName, getNonReadonlySymbol(leftProp)); } } return createAnonymousType(undefined, members, emptyArray, emptyArray, stringIndexInfo, numberIndexInfo); } - function getSymbolOfSpreadProperty(prop: Symbol, makeOptional: boolean) { - if (!isReadonlySymbol(prop) && (!makeOptional || prop.flags & SymbolFlags.Optional)) { + function getNonReadonlySymbol(prop: Symbol) { + if (!isReadonlySymbol(prop)) { return prop; } - const flags = SymbolFlags.Property | (makeOptional ? SymbolFlags.Optional : prop.flags & SymbolFlags.Optional); + const flags = SymbolFlags.Property | (prop.flags & SymbolFlags.Optional); const result = createSymbol(flags, prop.escapedName); result.type = getTypeOfSymbol(prop); - if (makeOptional) { - result.type = getUnionType([result.type, undefinedType]); - } result.declarations = prop.declarations; result.syntheticOrigin = prop; return result; @@ -7943,13 +7936,6 @@ namespace ts { return prop.flags & SymbolFlags.Method && find(prop.declarations, decl => isClassLike(decl.parent)); } - function getTruthyTypeFromFalsyUnion(type: UnionType): Type | undefined { - const truthy = removeDefinitelyFalsyTypes(type); - if (truthy !== type) { - return truthy; - } - } - function createLiteralType(flags: TypeFlags, value: string | number, symbol: Symbol) { const type = createType(flags); type.symbol = symbol; diff --git a/tests/baselines/reference/objectSpread.types b/tests/baselines/reference/objectSpread.types index da24a558d51..0caef49f439 100644 --- a/tests/baselines/reference/objectSpread.types +++ b/tests/baselines/reference/objectSpread.types @@ -247,7 +247,7 @@ function from16326(this: { header: Header }, header: Header, authToken: string): >Header : Header return { ->{ ...this.header, ...header, ...authToken && { authToken } } : { authToken: string; head: string; body: string; } +>{ ...this.header, ...header, ...authToken && { authToken } } : { head: string; body: string; authToken: string; } | { authToken: string; head: string; body: string; } ...this.header, >this.header : Header @@ -280,9 +280,9 @@ function conditionalSpreadBoolean(b: boolean) : { x: number, y: number } { >13 : 13 o = { ->o = { ...o, ...b && { x: 14 } } : { x: number; y: number; } +>o = { ...o, ...b && { x: 14 } } : { x: number; y: number; } | { x: number; y: number; } >o : { x: number; y: number; } ->{ ...o, ...b && { x: 14 } } : { x: number; y: number; } +>{ ...o, ...b && { x: 14 } } : { x: number; y: number; } | { x: number; y: number; } ...o, >o : { x: number; y: number; } @@ -295,8 +295,8 @@ function conditionalSpreadBoolean(b: boolean) : { x: number, y: number } { >14 : 14 } let o2 = { ...b && { x: 21 }} ->o2 : { x?: number | undefined; } ->{ ...b && { x: 21 }} : { x?: number | undefined; } +>o2 : {} | { x: number; } +>{ ...b && { x: 21 }} : {} | { x: number; } >b && { x: 21 } : false | { x: number; } >b : boolean >{ x: 21 } : { x: number; } @@ -321,9 +321,9 @@ function conditionalSpreadNumber(nt: number): { x: number, y: number } { >16 : 16 o = { ->o = { ...o, ...nt && { x: nt } } : { x: number; y: number; } +>o = { ...o, ...nt && { x: nt } } : { x: number; y: number; } | { x: number; y: number; } >o : { x: number; y: number; } ->{ ...o, ...nt && { x: nt } } : { x: number; y: number; } +>{ ...o, ...nt && { x: nt } } : { x: number; y: number; } | { x: number; y: number; } ...o, >o : { x: number; y: number; } @@ -336,8 +336,8 @@ function conditionalSpreadNumber(nt: number): { x: number, y: number } { >nt : number } let o2 = { ...nt && { x: nt }} ->o2 : { x?: number | undefined; } ->{ ...nt && { x: nt }} : { x?: number | undefined; } +>o2 : {} | { x: number; } +>{ ...nt && { x: nt }} : {} | { x: number; } >nt && { x: nt } : 0 | { x: number; } >nt : number >{ x: nt } : { x: number; } @@ -362,9 +362,9 @@ function conditionalSpreadString(st: string): { x: string, y: number } { >17 : 17 o = { ->o = { ...o, ...st && { x: st } } : { x: string; y: number; } +>o = { ...o, ...st && { x: st } } : { x: string; y: number; } | { x: string; y: number; } >o : { x: string; y: number; } ->{ ...o, ...st && { x: st } } : { x: string; y: number; } +>{ ...o, ...st && { x: st } } : { x: string; y: number; } | { x: string; y: number; } ...o, >o : { x: string; y: number; } @@ -377,8 +377,8 @@ function conditionalSpreadString(st: string): { x: string, y: number } { >st : string } let o2 = { ...st && { x: st }} ->o2 : { x?: string | undefined; } ->{ ...st && { x: st }} : { x?: string | undefined; } +>o2 : {} | { x: string; } +>{ ...st && { x: st }} : {} | { x: string; } >st && { x: st } : "" | { x: string; } >st : string >{ x: st } : { x: string; } @@ -571,8 +571,8 @@ let shortCutted: { a: number, b: string } = { ...o, a } // non primitive let spreadNonPrimitive = { ...{}}; ->spreadNonPrimitive : {} ->{ ...{}} : {} +>spreadNonPrimitive : object +>{ ...{}} : object >{} : object >{} : {} diff --git a/tests/baselines/reference/objectSpreadNegative.errors.txt b/tests/baselines/reference/objectSpreadNegative.errors.txt index 92225755c71..5b78f10f281 100644 --- a/tests/baselines/reference/objectSpreadNegative.errors.txt +++ b/tests/baselines/reference/objectSpreadNegative.errors.txt @@ -15,7 +15,7 @@ tests/cases/conformance/types/spread/objectSpreadNegative.ts(38,19): error TS269 tests/cases/conformance/types/spread/objectSpreadNegative.ts(43,1): error TS2349: Cannot invoke an expression whose type lacks a call signature. Type '{}' has no compatible call signatures. tests/cases/conformance/types/spread/objectSpreadNegative.ts(47,12): error TS2339: Property 'b' does not exist on type '{}'. tests/cases/conformance/types/spread/objectSpreadNegative.ts(53,9): error TS2339: Property 'm' does not exist on type '{ p: number; }'. -tests/cases/conformance/types/spread/objectSpreadNegative.ts(58,11): error TS2339: Property 'a' does not exist on type '{}'. +tests/cases/conformance/types/spread/objectSpreadNegative.ts(58,11): error TS2339: Property 'a' does not exist on type 'object'. tests/cases/conformance/types/spread/objectSpreadNegative.ts(62,14): error TS2698: Spread types may only be created from object types. tests/cases/conformance/types/spread/objectSpreadNegative.ts(65,14): error TS2698: Spread types may only be created from object types. tests/cases/conformance/types/spread/objectSpreadNegative.ts(79,37): error TS2322: Type '{ a: string; b: string; extra: string; }' is not assignable to type 'A'. @@ -117,7 +117,7 @@ tests/cases/conformance/types/spread/objectSpreadNegative.ts(84,7): error TS2322 let spreadObj = { ...obj }; spreadObj.a; // error 'a' is not in {} ~ -!!! error TS2339: Property 'a' does not exist on type '{}'. +!!! error TS2339: Property 'a' does not exist on type 'object'. // generics function f(t: T, u: U) { diff --git a/tests/baselines/reference/spreadUnion2.js b/tests/baselines/reference/spreadUnion2.js index 662b7cd3e46..0ae63266da3 100644 --- a/tests/baselines/reference/spreadUnion2.js +++ b/tests/baselines/reference/spreadUnion2.js @@ -2,20 +2,20 @@ declare const undefinedUnion: { a: number } | undefined; declare const nullUnion: { b: number } | null; -var o1: { a?: number | undefined }; +var o1: {} | { a: number }; var o1 = { ...undefinedUnion }; -var o2: { b?: number | undefined }; +var o2: {} | { b: number }; var o2 = { ...nullUnion }; -var o3: { a?: number | undefined, b?: number | undefined }; +var o3: {} | { a: number } | { b: number } | { a: number, b: number }; var o3 = { ...undefinedUnion, ...nullUnion }; var o3 = { ...nullUnion, ...undefinedUnion }; -var o4: { a?: number | undefined }; +var o4: {} | { a: number }; var o4 = { ...undefinedUnion, ...undefinedUnion }; -var o5: { b?: number | undefined }; +var o5: {} | { b: number }; var o5 = { ...nullUnion, ...nullUnion }; diff --git a/tests/baselines/reference/spreadUnion2.symbols b/tests/baselines/reference/spreadUnion2.symbols index 2cc91f2980b..72e373d862d 100644 --- a/tests/baselines/reference/spreadUnion2.symbols +++ b/tests/baselines/reference/spreadUnion2.symbols @@ -7,26 +7,28 @@ declare const nullUnion: { b: number } | null; >nullUnion : Symbol(nullUnion, Decl(spreadUnion2.ts, 1, 13)) >b : Symbol(b, Decl(spreadUnion2.ts, 1, 26)) -var o1: { a?: number | undefined }; +var o1: {} | { a: number }; >o1 : Symbol(o1, Decl(spreadUnion2.ts, 3, 3), Decl(spreadUnion2.ts, 4, 3)) ->a : Symbol(a, Decl(spreadUnion2.ts, 3, 9)) +>a : Symbol(a, Decl(spreadUnion2.ts, 3, 14)) var o1 = { ...undefinedUnion }; >o1 : Symbol(o1, Decl(spreadUnion2.ts, 3, 3), Decl(spreadUnion2.ts, 4, 3)) >undefinedUnion : Symbol(undefinedUnion, Decl(spreadUnion2.ts, 0, 13)) -var o2: { b?: number | undefined }; +var o2: {} | { b: number }; >o2 : Symbol(o2, Decl(spreadUnion2.ts, 6, 3), Decl(spreadUnion2.ts, 7, 3)) ->b : Symbol(b, Decl(spreadUnion2.ts, 6, 9)) +>b : Symbol(b, Decl(spreadUnion2.ts, 6, 14)) var o2 = { ...nullUnion }; >o2 : Symbol(o2, Decl(spreadUnion2.ts, 6, 3), Decl(spreadUnion2.ts, 7, 3)) >nullUnion : Symbol(nullUnion, Decl(spreadUnion2.ts, 1, 13)) -var o3: { a?: number | undefined, b?: number | undefined }; +var o3: {} | { a: number } | { b: number } | { a: number, b: number }; >o3 : Symbol(o3, Decl(spreadUnion2.ts, 9, 3), Decl(spreadUnion2.ts, 10, 3), Decl(spreadUnion2.ts, 11, 3)) ->a : Symbol(a, Decl(spreadUnion2.ts, 9, 9)) ->b : Symbol(b, Decl(spreadUnion2.ts, 9, 33)) +>a : Symbol(a, Decl(spreadUnion2.ts, 9, 14)) +>b : Symbol(b, Decl(spreadUnion2.ts, 9, 30)) +>a : Symbol(a, Decl(spreadUnion2.ts, 9, 46)) +>b : Symbol(b, Decl(spreadUnion2.ts, 9, 57)) var o3 = { ...undefinedUnion, ...nullUnion }; >o3 : Symbol(o3, Decl(spreadUnion2.ts, 9, 3), Decl(spreadUnion2.ts, 10, 3), Decl(spreadUnion2.ts, 11, 3)) @@ -38,18 +40,18 @@ var o3 = { ...nullUnion, ...undefinedUnion }; >nullUnion : Symbol(nullUnion, Decl(spreadUnion2.ts, 1, 13)) >undefinedUnion : Symbol(undefinedUnion, Decl(spreadUnion2.ts, 0, 13)) -var o4: { a?: number | undefined }; +var o4: {} | { a: number }; >o4 : Symbol(o4, Decl(spreadUnion2.ts, 13, 3), Decl(spreadUnion2.ts, 14, 3)) ->a : Symbol(a, Decl(spreadUnion2.ts, 13, 9)) +>a : Symbol(a, Decl(spreadUnion2.ts, 13, 14)) var o4 = { ...undefinedUnion, ...undefinedUnion }; >o4 : Symbol(o4, Decl(spreadUnion2.ts, 13, 3), Decl(spreadUnion2.ts, 14, 3)) >undefinedUnion : Symbol(undefinedUnion, Decl(spreadUnion2.ts, 0, 13)) >undefinedUnion : Symbol(undefinedUnion, Decl(spreadUnion2.ts, 0, 13)) -var o5: { b?: number | undefined }; +var o5: {} | { b: number }; >o5 : Symbol(o5, Decl(spreadUnion2.ts, 16, 3), Decl(spreadUnion2.ts, 17, 3)) ->b : Symbol(b, Decl(spreadUnion2.ts, 16, 9)) +>b : Symbol(b, Decl(spreadUnion2.ts, 16, 14)) var o5 = { ...nullUnion, ...nullUnion }; >o5 : Symbol(o5, Decl(spreadUnion2.ts, 16, 3), Decl(spreadUnion2.ts, 17, 3)) diff --git a/tests/baselines/reference/spreadUnion2.types b/tests/baselines/reference/spreadUnion2.types index ccf587af591..5077949bc97 100644 --- a/tests/baselines/reference/spreadUnion2.types +++ b/tests/baselines/reference/spreadUnion2.types @@ -8,58 +8,60 @@ declare const nullUnion: { b: number } | null; >b : number >null : null -var o1: { a?: number | undefined }; ->o1 : { a?: number | undefined; } ->a : number | undefined +var o1: {} | { a: number }; +>o1 : {} | { a: number; } +>a : number var o1 = { ...undefinedUnion }; ->o1 : { a?: number | undefined; } ->{ ...undefinedUnion } : { a?: number | undefined; } +>o1 : {} | { a: number; } +>{ ...undefinedUnion } : {} | { a: number; } >undefinedUnion : { a: number; } | undefined -var o2: { b?: number | undefined }; ->o2 : { b?: number | undefined; } ->b : number | undefined +var o2: {} | { b: number }; +>o2 : {} | { b: number; } +>b : number var o2 = { ...nullUnion }; ->o2 : { b?: number | undefined; } ->{ ...nullUnion } : { b?: number | undefined; } +>o2 : {} | { b: number; } +>{ ...nullUnion } : {} | { b: number; } >nullUnion : { b: number; } | null -var o3: { a?: number | undefined, b?: number | undefined }; ->o3 : { a?: number | undefined; b?: number | undefined; } ->a : number | undefined ->b : number | undefined +var o3: {} | { a: number } | { b: number } | { a: number, b: number }; +>o3 : {} | { a: number; } | { b: number; } | { a: number; b: number; } +>a : number +>b : number +>a : number +>b : number var o3 = { ...undefinedUnion, ...nullUnion }; ->o3 : { a?: number | undefined; b?: number | undefined; } ->{ ...undefinedUnion, ...nullUnion } : { b?: number | undefined; a?: number | undefined; } +>o3 : {} | { a: number; } | { b: number; } | { a: number; b: number; } +>{ ...undefinedUnion, ...nullUnion } : {} | { b: number; } | { a: number; } | { b: number; a: number; } >undefinedUnion : { a: number; } | undefined >nullUnion : { b: number; } | null var o3 = { ...nullUnion, ...undefinedUnion }; ->o3 : { a?: number | undefined; b?: number | undefined; } ->{ ...nullUnion, ...undefinedUnion } : { a?: number | undefined; b?: number | undefined; } +>o3 : {} | { a: number; } | { b: number; } | { a: number; b: number; } +>{ ...nullUnion, ...undefinedUnion } : {} | { a: number; } | { b: number; } | { a: number; b: number; } >nullUnion : { b: number; } | null >undefinedUnion : { a: number; } | undefined -var o4: { a?: number | undefined }; ->o4 : { a?: number | undefined; } ->a : number | undefined +var o4: {} | { a: number }; +>o4 : {} | { a: number; } +>a : number var o4 = { ...undefinedUnion, ...undefinedUnion }; ->o4 : { a?: number | undefined; } ->{ ...undefinedUnion, ...undefinedUnion } : { a?: number | undefined; } +>o4 : {} | { a: number; } +>{ ...undefinedUnion, ...undefinedUnion } : {} | { a: number; } | { a: number; } | { a: number; } >undefinedUnion : { a: number; } | undefined >undefinedUnion : { a: number; } | undefined -var o5: { b?: number | undefined }; ->o5 : { b?: number | undefined; } ->b : number | undefined +var o5: {} | { b: number }; +>o5 : {} | { b: number; } +>b : number var o5 = { ...nullUnion, ...nullUnion }; ->o5 : { b?: number | undefined; } ->{ ...nullUnion, ...nullUnion } : { b?: number | undefined; } +>o5 : {} | { b: number; } +>{ ...nullUnion, ...nullUnion } : {} | { b: number; } | { b: number; } | { b: number; } >nullUnion : { b: number; } | null >nullUnion : { b: number; } | null diff --git a/tests/baselines/reference/spreadUnion3.errors.txt b/tests/baselines/reference/spreadUnion3.errors.txt index 24d864d96fe..b7c59697946 100644 --- a/tests/baselines/reference/spreadUnion3.errors.txt +++ b/tests/baselines/reference/spreadUnion3.errors.txt @@ -1,9 +1,9 @@ -tests/cases/conformance/types/spread/spreadUnion3.ts(2,5): error TS2322: Type '{ y: string | number; }' is not assignable to type '{ y: string; }'. - Types of property 'y' are incompatible. - Type 'string | number' is not assignable to type 'string'. +tests/cases/conformance/types/spread/spreadUnion3.ts(2,5): error TS2322: Type '{ y: number; } | { y: string; }' is not assignable to type '{ y: string; }'. + Type '{ y: number; }' is not assignable to type '{ y: string; }'. + Types of property 'y' are incompatible. Type 'number' is not assignable to type 'string'. -tests/cases/conformance/types/spread/spreadUnion3.ts(9,9): error TS2322: Type 'number | undefined' is not assignable to type 'number'. - Type 'undefined' is not assignable to type 'number'. +tests/cases/conformance/types/spread/spreadUnion3.ts(9,23): error TS2339: Property 'a' does not exist on type '{} | {} | { a: number; }'. + Property 'a' does not exist on type '{}'. tests/cases/conformance/types/spread/spreadUnion3.ts(17,11): error TS2698: Spread types may only be created from object types. tests/cases/conformance/types/spread/spreadUnion3.ts(18,11): error TS2698: Spread types may only be created from object types. @@ -12,9 +12,9 @@ tests/cases/conformance/types/spread/spreadUnion3.ts(18,11): error TS2698: Sprea function f(x: { y: string } | undefined): { y: string } { return { y: 123, ...x } // y: string | number ~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2322: Type '{ y: string | number; }' is not assignable to type '{ y: string; }'. -!!! error TS2322: Types of property 'y' are incompatible. -!!! error TS2322: Type 'string | number' is not assignable to type 'string'. +!!! error TS2322: Type '{ y: number; } | { y: string; }' is not assignable to type '{ y: string; }'. +!!! error TS2322: Type '{ y: number; }' is not assignable to type '{ y: string; }'. +!!! error TS2322: Types of property 'y' are incompatible. !!! error TS2322: Type 'number' is not assignable to type 'string'. } f(undefined) @@ -23,9 +23,9 @@ tests/cases/conformance/types/spread/spreadUnion3.ts(18,11): error TS2698: Sprea function g(t?: { a: number } | null): void { let b = { ...t }; let c: number = b.a; // might not have 'a' - ~ -!!! error TS2322: Type 'number | undefined' is not assignable to type 'number'. -!!! error TS2322: Type 'undefined' is not assignable to type 'number'. + ~ +!!! error TS2339: Property 'a' does not exist on type '{} | {} | { a: number; }'. +!!! error TS2339: Property 'a' does not exist on type '{}'. } g() g(undefined) diff --git a/tests/cases/conformance/types/spread/spreadUnion2.ts b/tests/cases/conformance/types/spread/spreadUnion2.ts index 549441be411..5fbca1d4bf2 100644 --- a/tests/cases/conformance/types/spread/spreadUnion2.ts +++ b/tests/cases/conformance/types/spread/spreadUnion2.ts @@ -3,19 +3,19 @@ declare const undefinedUnion: { a: number } | undefined; declare const nullUnion: { b: number } | null; -var o1: { a?: number | undefined }; +var o1: {} | { a: number }; var o1 = { ...undefinedUnion }; -var o2: { b?: number | undefined }; +var o2: {} | { b: number }; var o2 = { ...nullUnion }; -var o3: { a?: number | undefined, b?: number | undefined }; +var o3: {} | { a: number } | { b: number } | { a: number, b: number }; var o3 = { ...undefinedUnion, ...nullUnion }; var o3 = { ...nullUnion, ...undefinedUnion }; -var o4: { a?: number | undefined }; +var o4: {} | { a: number }; var o4 = { ...undefinedUnion, ...undefinedUnion }; -var o5: { b?: number | undefined }; +var o5: {} | { b: number }; var o5 = { ...nullUnion, ...nullUnion }; From 484bd2082ee8f92d4d604ae610afe654ff9ab8b1 Mon Sep 17 00:00:00 2001 From: uniqueiniquity Date: Fri, 15 Sep 2017 16:15:32 -0700 Subject: [PATCH 361/370] Refactored out RegionRange --- src/services/outliningElementsCollector.ts | 35 +++++++--------------- 1 file changed, 11 insertions(+), 24 deletions(-) diff --git a/src/services/outliningElementsCollector.ts b/src/services/outliningElementsCollector.ts index e215663372b..f5c9754cea8 100644 --- a/src/services/outliningElementsCollector.ts +++ b/src/services/outliningElementsCollector.ts @@ -5,14 +5,10 @@ namespace ts.OutliningElementsCollector { const defaultLabel = "#region"; const regionMatch = new RegExp("^\\s*//\\s*(#region|#endregion)(?:\\s+(.*))?$"); - interface RegionRange extends TextRange { - name?: string; - } - export function collectElements(sourceFile: SourceFile, cancellationToken: CancellationToken): OutliningSpan[] { const elements: OutliningSpan[] = []; let depth = 0; - const regions: RegionRange[] = []; + const regions: OutliningSpan[] = []; walk(sourceFile); gatherRegions(); @@ -43,19 +39,6 @@ namespace ts.OutliningElementsCollector { } } - function addOutliningSpanRegions(regionSpan: RegionRange) { - if (regionSpan) { - const textSpan = createTextSpanFromRange(regionSpan); - const span: OutliningSpan = { - textSpan, - hintSpan: textSpan, - bannerText: regionSpan.name, - autoCollapse: false, - }; - elements.push(span); - } - } - function addOutliningForLeadingCommentsForNode(n: Node) { const comments = ts.getLeadingCommentRangesOfNode(n, sourceFile); @@ -122,18 +105,22 @@ namespace ts.OutliningElementsCollector { if (result && !isInComment(sourceFile, currentLineStart)) { if (result[1] === "#region") { const start = sourceFile.getFullText().indexOf("//", currentLineStart); - const region: RegionRange = { - pos: start, - end: lineEnd, - name: result[2] || defaultLabel, + const textSpan = createTextSpanFromBounds(start, lineEnd); + const region: OutliningSpan = { + textSpan, + hintSpan: textSpan, + bannerText: result[2] || defaultLabel, + autoCollapse: false }; regions.push(region); } else { const region = regions.pop(); if (region) { - region.end = lineEnd; - addOutliningSpanRegions(region); + const newTextSpan = createTextSpanFromBounds(region.textSpan.start, lineEnd); + region.textSpan = newTextSpan; + region.hintSpan = newTextSpan; + elements.push(region); } } } From e5c43cddb74406cf3df59f672ce99ca866ffd83d Mon Sep 17 00:00:00 2001 From: uniqueiniquity Date: Fri, 15 Sep 2017 16:47:59 -0700 Subject: [PATCH 362/370] Remove extra OutliningSpan and simplify regex --- src/services/outliningElementsCollector.ts | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/services/outliningElementsCollector.ts b/src/services/outliningElementsCollector.ts index f5c9754cea8..03ae0529ca9 100644 --- a/src/services/outliningElementsCollector.ts +++ b/src/services/outliningElementsCollector.ts @@ -3,7 +3,7 @@ namespace ts.OutliningElementsCollector { const collapseText = "..."; const maxDepth = 20; const defaultLabel = "#region"; - const regionMatch = new RegExp("^\\s*//\\s*(#region|#endregion)(?:\\s+(.*))?$"); + const regionMatch = new RegExp("^\\s*//\\s*#(end)?region(?:\\s+(.*))?$"); export function collectElements(sourceFile: SourceFile, cancellationToken: CancellationToken): OutliningSpan[] { const elements: OutliningSpan[] = []; @@ -103,7 +103,7 @@ namespace ts.OutliningElementsCollector { const result = comment.match(regionMatch); if (result && !isInComment(sourceFile, currentLineStart)) { - if (result[1] === "#region") { + if (!result[1]) { const start = sourceFile.getFullText().indexOf("//", currentLineStart); const textSpan = createTextSpanFromBounds(start, lineEnd); const region: OutliningSpan = { @@ -117,9 +117,8 @@ namespace ts.OutliningElementsCollector { else { const region = regions.pop(); if (region) { - const newTextSpan = createTextSpanFromBounds(region.textSpan.start, lineEnd); - region.textSpan = newTextSpan; - region.hintSpan = newTextSpan; + region.textSpan.length = lineEnd - region.textSpan.start; + region.hintSpan.length = lineEnd - region.textSpan.start; elements.push(region); } } From 79e12eb48b33e0fbcf0c9e85dd27e41a0de2bf00 Mon Sep 17 00:00:00 2001 From: Andy Date: Mon, 18 Sep 2017 10:05:44 -0700 Subject: [PATCH 363/370] Ensure that emitter calls callbacks for empty blocks (#18547) --- src/compiler/emitter.ts | 51 ++++++------------- .../convertToEs6Class_emptyCatchClause.ts | 20 ++++++++ .../extract-method-empty-namespace.ts | 22 ++++++++ 3 files changed, 57 insertions(+), 36 deletions(-) create mode 100644 tests/cases/fourslash/convertToEs6Class_emptyCatchClause.ts create mode 100644 tests/cases/fourslash/extract-method-empty-namespace.ts diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index 2c6eef3672f..502329bbd84 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -1440,29 +1440,18 @@ namespace ts { // function emitBlock(node: Block) { - if (isSingleLineEmptyBlock(node)) { - writeToken(SyntaxKind.OpenBraceToken, node.pos, /*contextNode*/ node); - write(" "); - writeToken(SyntaxKind.CloseBraceToken, node.statements.end, /*contextNode*/ node); - } - else { - writeToken(SyntaxKind.OpenBraceToken, node.pos, /*contextNode*/ node); - emitBlockStatements(node); - // We have to call emitLeadingComments explicitly here because otherwise leading comments of the close brace token will not be emitted - increaseIndent(); - emitLeadingCommentsOfPosition(node.statements.end); - decreaseIndent(); - writeToken(SyntaxKind.CloseBraceToken, node.statements.end, /*contextNode*/ node); - } + writeToken(SyntaxKind.OpenBraceToken, node.pos, /*contextNode*/ node); + emitBlockStatements(node, /*forceSingleLine*/ !node.multiLine && isEmptyBlock(node)); + // We have to call emitLeadingComments explicitly here because otherwise leading comments of the close brace token will not be emitted + increaseIndent(); + emitLeadingCommentsOfPosition(node.statements.end); + decreaseIndent(); + writeToken(SyntaxKind.CloseBraceToken, node.statements.end, /*contextNode*/ node); } - function emitBlockStatements(node: BlockLike) { - if (getEmitFlags(node) & EmitFlags.SingleLine) { - emitList(node, node.statements, ListFormat.SingleLineBlockStatements); - } - else { - emitList(node, node.statements, ListFormat.MultiLineBlockStatements); - } + function emitBlockStatements(node: BlockLike, forceSingleLine: boolean) { + const format = forceSingleLine || getEmitFlags(node) & EmitFlags.SingleLine ? ListFormat.SingleLineBlockStatements : ListFormat.MultiLineBlockStatements; + emitList(node, node.statements, format); } function emitVariableStatement(node: VariableStatement) { @@ -1889,16 +1878,11 @@ namespace ts { } function emitModuleBlock(node: ModuleBlock) { - if (isEmptyBlock(node)) { - write("{ }"); - } - else { - pushNameGenerationScope(); - write("{"); - emitBlockStatements(node); - write("}"); - popNameGenerationScope(); - } + pushNameGenerationScope(); + write("{"); + emitBlockStatements(node, /*forceSingleLine*/ isEmptyBlock(node)); + write("}"); + popNameGenerationScope(); } function emitCaseBlock(node: CaseBlock) { @@ -2762,11 +2746,6 @@ namespace ts { && !rangeEndIsOnSameLineAsRangeStart(node1, node2, currentSourceFile); } - function isSingleLineEmptyBlock(block: Block) { - return !block.multiLine - && isEmptyBlock(block); - } - function isEmptyBlock(block: BlockLike) { return block.statements.length === 0 && rangeEndIsOnSameLineAsRangeStart(block, block, currentSourceFile); diff --git a/tests/cases/fourslash/convertToEs6Class_emptyCatchClause.ts b/tests/cases/fourslash/convertToEs6Class_emptyCatchClause.ts new file mode 100644 index 00000000000..e9027178aa7 --- /dev/null +++ b/tests/cases/fourslash/convertToEs6Class_emptyCatchClause.ts @@ -0,0 +1,20 @@ +/// + +// @allowNonTsExtensions: true +// @Filename: /a.js +////function /**/MyClass() {} +////MyClass.prototype.foo = function() { +//// try {} catch() {} +////} + +verify.applicableRefactorAvailableAtMarker(""); +verify.fileAfterApplyingRefactorAtMarker("", +`class MyClass { + constructor() { } + foo() { + try { } + catch () { } + } +} +`, +'Convert to ES2015 class', 'convert'); diff --git a/tests/cases/fourslash/extract-method-empty-namespace.ts b/tests/cases/fourslash/extract-method-empty-namespace.ts new file mode 100644 index 00000000000..9da3faaf927 --- /dev/null +++ b/tests/cases/fourslash/extract-method-empty-namespace.ts @@ -0,0 +1,22 @@ +/// + +// TODO: GH#18546 +// For now this tests that at least we don't crash. + +////function f() { +//// /*start*/namespace N {}/*end*/ +////} + +goTo.select('start', 'end') +edit.applyRefactor({ + refactorName: "Extract Method", + actionName: "scope_1", + actionDescription: "Extract to function in global scope", + newContent: `function f() { + /*RENAME*/newFunction(N); +} +function newFunction(N: any) { + namespace N { } +} +` +}); From fe0ba0c743fb967ec456caf0c758ca991bff4c88 Mon Sep 17 00:00:00 2001 From: Ivan Enderlin Date: Mon, 18 Sep 2017 11:21:33 -0700 Subject: [PATCH 364/370] fix: Add missing opening quote (#18534) And thank you for this tool! --- src/compiler/diagnosticMessages.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index 8a76ddcda9a..e273950424c 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -2686,7 +2686,7 @@ "category": "Message", "code": 6015 }, - "Specify module code generation: 'none', commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'.": { + "Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'.": { "category": "Message", "code": 6016 }, From 8c2d79caa673bab04a0a2ab6ee387518270b5bfe Mon Sep 17 00:00:00 2001 From: Adrian Leonhard Date: Mon, 18 Sep 2017 21:12:08 +0200 Subject: [PATCH 365/370] TypedArrays: fixed find and findIndex callback param obj type. (#18493) Fixes #18425. --- src/lib/es5.d.ts | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/src/lib/es5.d.ts b/src/lib/es5.d.ts index 820a90554ea..e08534d8ba9 100644 --- a/src/lib/es5.d.ts +++ b/src/lib/es5.d.ts @@ -1577,7 +1577,7 @@ interface Int8Array { * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number | undefined; + find(predicate: (value: number, index: number, obj: Int8Array) => boolean, thisArg?: any): number | undefined; /** * Returns the index of the first element in the array where predicate is true, and -1 @@ -1588,7 +1588,7 @@ interface Int8Array { * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - findIndex(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; + findIndex(predicate: (value: number, index: number, obj: Int8Array) => boolean, thisArg?: any): number; /** * Performs the specified action for each element in an array. @@ -1844,7 +1844,7 @@ interface Uint8Array { * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number | undefined; + find(predicate: (value: number, index: number, obj: Uint8Array) => boolean, thisArg?: any): number | undefined; /** * Returns the index of the first element in the array where predicate is true, and -1 @@ -1855,7 +1855,7 @@ interface Uint8Array { * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - findIndex(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; + findIndex(predicate: (value: number, index: number, obj: Uint8Array) => boolean, thisArg?: any): number; /** * Performs the specified action for each element in an array. @@ -2111,7 +2111,7 @@ interface Uint8ClampedArray { * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number | undefined; + find(predicate: (value: number, index: number, obj: Uint8ClampedArray) => boolean, thisArg?: any): number | undefined; /** * Returns the index of the first element in the array where predicate is true, and -1 @@ -2122,7 +2122,7 @@ interface Uint8ClampedArray { * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - findIndex(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; + findIndex(predicate: (value: number, index: number, obj: Uint8ClampedArray) => boolean, thisArg?: any): number; /** * Performs the specified action for each element in an array. @@ -2377,7 +2377,7 @@ interface Int16Array { * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number | undefined; + find(predicate: (value: number, index: number, obj: Int16Array) => boolean, thisArg?: any): number | undefined; /** * Returns the index of the first element in the array where predicate is true, and -1 @@ -2388,7 +2388,7 @@ interface Int16Array { * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - findIndex(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; + findIndex(predicate: (value: number, index: number, obj: Int16Array) => boolean, thisArg?: any): number; /** * Performs the specified action for each element in an array. @@ -2644,7 +2644,7 @@ interface Uint16Array { * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number | undefined; + find(predicate: (value: number, index: number, obj: Uint16Array) => boolean, thisArg?: any): number | undefined; /** * Returns the index of the first element in the array where predicate is true, and -1 @@ -2655,7 +2655,7 @@ interface Uint16Array { * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - findIndex(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; + findIndex(predicate: (value: number, index: number, obj: Uint16Array) => boolean, thisArg?: any): number; /** * Performs the specified action for each element in an array. @@ -2911,7 +2911,7 @@ interface Int32Array { * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number | undefined; + find(predicate: (value: number, index: number, obj: Int32Array) => boolean, thisArg?: any): number | undefined; /** * Returns the index of the first element in the array where predicate is true, and -1 @@ -2922,7 +2922,7 @@ interface Int32Array { * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - findIndex(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; + findIndex(predicate: (value: number, index: number, obj: Int32Array) => boolean, thisArg?: any): number; /** * Performs the specified action for each element in an array. @@ -3178,7 +3178,7 @@ interface Uint32Array { * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number | undefined; + find(predicate: (value: number, index: number, obj: Uint32Array) => boolean, thisArg?: any): number | undefined; /** * Returns the index of the first element in the array where predicate is true, and -1 @@ -3189,7 +3189,7 @@ interface Uint32Array { * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - findIndex(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; + findIndex(predicate: (value: number, index: number, obj: Uint32Array) => boolean, thisArg?: any): number; /** * Performs the specified action for each element in an array. @@ -3444,7 +3444,7 @@ interface Float32Array { * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number | undefined; + find(predicate: (value: number, index: number, obj: Float32Array) => boolean, thisArg?: any): number | undefined; /** * Returns the index of the first element in the array where predicate is true, and -1 @@ -3455,7 +3455,7 @@ interface Float32Array { * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - findIndex(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; + findIndex(predicate: (value: number, index: number, obj: Float32Array) => boolean, thisArg?: any): number; /** * Performs the specified action for each element in an array. @@ -3712,7 +3712,7 @@ interface Float64Array { * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number | undefined; + find(predicate: (value: number, index: number, obj: Float64Array) => boolean, thisArg?: any): number | undefined; /** * Returns the index of the first element in the array where predicate is true, and -1 @@ -3723,7 +3723,7 @@ interface Float64Array { * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - findIndex(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; + findIndex(predicate: (value: number, index: number, obj: Float64Array) => boolean, thisArg?: any): number; /** * Performs the specified action for each element in an array. From 49a73a96860ed7b425eb846e76e2c6bdf3bcbff8 Mon Sep 17 00:00:00 2001 From: Adrian Leonhard Date: Mon, 18 Sep 2017 22:34:03 +0200 Subject: [PATCH 366/370] Removed duplicated JSDoc for TypedArrays and ArrayBuffer. (#18555) I left the docs in es5.d.ts, as that seems to be the main file. Fixes #15883 --- src/lib/es2015.iterable.d.ts | 36 ------------------------ src/lib/es2015.symbol.wellknown.d.ts | 42 ---------------------------- 2 files changed, 78 deletions(-) diff --git a/src/lib/es2015.iterable.d.ts b/src/lib/es2015.iterable.d.ts index 23e23510d3c..896d6526147 100644 --- a/src/lib/es2015.iterable.d.ts +++ b/src/lib/es2015.iterable.d.ts @@ -209,10 +209,6 @@ interface String { [Symbol.iterator](): IterableIterator; } -/** - * A typed array of 8-bit integer values. The contents are initialized to 0. If the requested - * number of bytes could not be allocated an exception is raised. - */ interface Int8Array { [Symbol.iterator](): IterableIterator; /** @@ -241,10 +237,6 @@ interface Int8ArrayConstructor { from(arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int8Array; } -/** - * A typed array of 8-bit unsigned integer values. The contents are initialized to 0. If the - * requested number of bytes could not be allocated an exception is raised. - */ interface Uint8Array { [Symbol.iterator](): IterableIterator; /** @@ -273,10 +265,6 @@ interface Uint8ArrayConstructor { from(arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8Array; } -/** - * A typed array of 8-bit unsigned integer (clamped) values. The contents are initialized to 0. - * If the requested number of bytes could not be allocated an exception is raised. - */ interface Uint8ClampedArray { [Symbol.iterator](): IterableIterator; /** @@ -308,10 +296,6 @@ interface Uint8ClampedArrayConstructor { from(arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8ClampedArray; } -/** - * A typed array of 16-bit signed integer values. The contents are initialized to 0. If the - * requested number of bytes could not be allocated an exception is raised. - */ interface Int16Array { [Symbol.iterator](): IterableIterator; /** @@ -342,10 +326,6 @@ interface Int16ArrayConstructor { from(arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int16Array; } -/** - * A typed array of 16-bit unsigned integer values. The contents are initialized to 0. If the - * requested number of bytes could not be allocated an exception is raised. - */ interface Uint16Array { [Symbol.iterator](): IterableIterator; /** @@ -374,10 +354,6 @@ interface Uint16ArrayConstructor { from(arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint16Array; } -/** - * A typed array of 32-bit signed integer values. The contents are initialized to 0. If the - * requested number of bytes could not be allocated an exception is raised. - */ interface Int32Array { [Symbol.iterator](): IterableIterator; /** @@ -406,10 +382,6 @@ interface Int32ArrayConstructor { from(arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int32Array; } -/** - * A typed array of 32-bit unsigned integer values. The contents are initialized to 0. If the - * requested number of bytes could not be allocated an exception is raised. - */ interface Uint32Array { [Symbol.iterator](): IterableIterator; /** @@ -438,10 +410,6 @@ interface Uint32ArrayConstructor { from(arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint32Array; } -/** - * A typed array of 32-bit float values. The contents are initialized to 0. If the requested number - * of bytes could not be allocated an exception is raised. - */ interface Float32Array { [Symbol.iterator](): IterableIterator; /** @@ -470,10 +438,6 @@ interface Float32ArrayConstructor { from(arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Float32Array; } -/** - * A typed array of 64-bit float values. The contents are initialized to 0. If the requested - * number of bytes could not be allocated an exception is raised. - */ interface Float64Array { [Symbol.iterator](): IterableIterator; /** diff --git a/src/lib/es2015.symbol.wellknown.d.ts b/src/lib/es2015.symbol.wellknown.d.ts index b7c2610e652..268570ff232 100644 --- a/src/lib/es2015.symbol.wellknown.d.ts +++ b/src/lib/es2015.symbol.wellknown.d.ts @@ -240,12 +240,6 @@ interface String { split(splitter: { [Symbol.split](string: string, limit?: number): string[]; }, limit?: number): string[]; } -/** - * Represents a raw buffer of binary data, which is used to store data for the - * different typed arrays. ArrayBuffers cannot be read from or written to directly, - * but can be passed to a typed array or DataView Object to interpret the raw - * buffer as needed. - */ interface ArrayBuffer { readonly [Symbol.toStringTag]: "ArrayBuffer"; } @@ -254,74 +248,38 @@ interface DataView { readonly [Symbol.toStringTag]: "DataView"; } -/** - * A typed array of 8-bit integer values. The contents are initialized to 0. If the requested - * number of bytes could not be allocated an exception is raised. - */ interface Int8Array { readonly [Symbol.toStringTag]: "Int8Array"; } -/** - * A typed array of 8-bit unsigned integer values. The contents are initialized to 0. If the - * requested number of bytes could not be allocated an exception is raised. - */ interface Uint8Array { readonly [Symbol.toStringTag]: "UInt8Array"; } -/** - * A typed array of 8-bit unsigned integer (clamped) values. The contents are initialized to 0. - * If the requested number of bytes could not be allocated an exception is raised. - */ interface Uint8ClampedArray { readonly [Symbol.toStringTag]: "Uint8ClampedArray"; } -/** - * A typed array of 16-bit signed integer values. The contents are initialized to 0. If the - * requested number of bytes could not be allocated an exception is raised. - */ interface Int16Array { readonly [Symbol.toStringTag]: "Int16Array"; } -/** - * A typed array of 16-bit unsigned integer values. The contents are initialized to 0. If the - * requested number of bytes could not be allocated an exception is raised. - */ interface Uint16Array { readonly [Symbol.toStringTag]: "Uint16Array"; } -/** - * A typed array of 32-bit signed integer values. The contents are initialized to 0. If the - * requested number of bytes could not be allocated an exception is raised. - */ interface Int32Array { readonly [Symbol.toStringTag]: "Int32Array"; } -/** - * A typed array of 32-bit unsigned integer values. The contents are initialized to 0. If the - * requested number of bytes could not be allocated an exception is raised. - */ interface Uint32Array { readonly [Symbol.toStringTag]: "Uint32Array"; } -/** - * A typed array of 32-bit float values. The contents are initialized to 0. If the requested number - * of bytes could not be allocated an exception is raised. - */ interface Float32Array { readonly [Symbol.toStringTag]: "Float32Array"; } -/** - * A typed array of 64-bit float values. The contents are initialized to 0. If the requested - * number of bytes could not be allocated an exception is raised. - */ interface Float64Array { readonly [Symbol.toStringTag]: "Float64Array"; } From 21bbee4044b792bd835423dbb3db6608ae492d24 Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Mon, 18 Sep 2017 13:41:37 -0700 Subject: [PATCH 367/370] init progressbar dependencies within host start to avoid execution in a browser context (#18554) --- src/harness/parallel/host.ts | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/src/harness/parallel/host.ts b/src/harness/parallel/host.ts index a3a1ec8082b..92e21b5ada3 100644 --- a/src/harness/parallel/host.ts +++ b/src/harness/parallel/host.ts @@ -28,6 +28,7 @@ namespace Harness.Parallel.Host { } export function start() { + initializeProgressBarsDependencies(); console.log("Discovering tests..."); const discoverStart = +(new Date()); const { statSync }: { statSync(path: string): { size: number }; } = require("fs"); @@ -254,14 +255,26 @@ namespace Harness.Parallel.Host { return; } - const Mocha = require("mocha"); - const Base = Mocha.reporters.Base; - const color = Base.color; - const cursor = Base.cursor; - const readline = require("readline"); - const os = require("os"); - const tty: { isatty(x: number): boolean } = require("tty"); - const isatty = tty.isatty(1) && tty.isatty(2); + let Mocha: any; + let Base: any; + let color: any; + let cursor: any; + let readline: any; + let os: any; + let tty: { isatty(x: number): boolean }; + let isatty: boolean; + + function initializeProgressBarsDependencies() { + Mocha = require("mocha"); + Base = Mocha.reporters.Base; + color = Base.color; + cursor = Base.cursor; + readline = require("readline"); + os = require("os"); + tty = require("tty"); + isatty = tty.isatty(1) && tty.isatty(2); + } + class ProgressBars { public readonly _options: Readonly; private _enabled: boolean; From af49c60a2cb415e9481dec58285c497bd7f49fed Mon Sep 17 00:00:00 2001 From: Andrew Casey Date: Mon, 18 Sep 2017 19:12:06 -0700 Subject: [PATCH 368/370] Stop requiring that the full range of a declaration fall within the selection Fixes #18546 --- src/harness/unittests/extractMethods.ts | 5 +++++ src/services/refactors/extractMethod.ts | 2 +- .../extractMethod/extractMethod33.ts | 19 +++++++++++++++++++ .../extract-method-empty-namespace.ts | 7 ++----- 4 files changed, 27 insertions(+), 6 deletions(-) create mode 100644 tests/baselines/reference/extractMethod/extractMethod33.ts diff --git a/src/harness/unittests/extractMethods.ts b/src/harness/unittests/extractMethods.ts index 6d8eed3b8b0..190cd1d5be0 100644 --- a/src/harness/unittests/extractMethods.ts +++ b/src/harness/unittests/extractMethods.ts @@ -768,6 +768,11 @@ function parsePrimaryExpression(): any { } }|] } +}`); + // Selection excludes leading trivia of declaration + testExtractMethod("extractMethod33", + `function F() { + [#|function G() { }|] }`); }); diff --git a/src/services/refactors/extractMethod.ts b/src/services/refactors/extractMethod.ts index 3b8ea19a9f0..8551ea2eddc 100644 --- a/src/services/refactors/extractMethod.ts +++ b/src/services/refactors/extractMethod.ts @@ -1209,7 +1209,7 @@ namespace ts.refactor.extractMethod { if (!declInFile) { return undefined; } - if (rangeContainsRange(enclosingTextRange, declInFile)) { + if (rangeContainsStartEnd(enclosingTextRange, declInFile.getStart(), declInFile.end)) { // declaration is located in range to be extracted - do nothing return undefined; } diff --git a/tests/baselines/reference/extractMethod/extractMethod33.ts b/tests/baselines/reference/extractMethod/extractMethod33.ts new file mode 100644 index 00000000000..79a6626a535 --- /dev/null +++ b/tests/baselines/reference/extractMethod/extractMethod33.ts @@ -0,0 +1,19 @@ +// ==ORIGINAL== +function F() { + function G() { } +} +// ==SCOPE::inner function in function 'F'== +function F() { + /*RENAME*/newFunction(); + + function newFunction() { + function G() { } + } +} +// ==SCOPE::function in global scope== +function F() { + /*RENAME*/newFunction(); +} +function newFunction() { + function G() { } +} diff --git a/tests/cases/fourslash/extract-method-empty-namespace.ts b/tests/cases/fourslash/extract-method-empty-namespace.ts index 9da3faaf927..3a29992350d 100644 --- a/tests/cases/fourslash/extract-method-empty-namespace.ts +++ b/tests/cases/fourslash/extract-method-empty-namespace.ts @@ -1,8 +1,5 @@ /// -// TODO: GH#18546 -// For now this tests that at least we don't crash. - ////function f() { //// /*start*/namespace N {}/*end*/ ////} @@ -13,9 +10,9 @@ edit.applyRefactor({ actionName: "scope_1", actionDescription: "Extract to function in global scope", newContent: `function f() { - /*RENAME*/newFunction(N); + /*RENAME*/newFunction(); } -function newFunction(N: any) { +function newFunction() { namespace N { } } ` From 951974dff61c9c70d817dba50f7bc777a97409ba Mon Sep 17 00:00:00 2001 From: Andy Date: Tue, 19 Sep 2017 08:27:31 -0700 Subject: [PATCH 369/370] Use `find` array helper (#18557) * Use `find` array helper * Provide explicit type argument to `find` --- src/services/refactors/extractMethod.ts | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/services/refactors/extractMethod.ts b/src/services/refactors/extractMethod.ts index 3b8ea19a9f0..8e97b145aac 100644 --- a/src/services/refactors/extractMethod.ts +++ b/src/services/refactors/extractMethod.ts @@ -934,12 +934,8 @@ namespace ts.refactor.extractMethod { * Otherwise, return `undefined`. */ function getNodeToInsertBefore(minPos: number, scope: Scope): Node | undefined { - const children = getStatementsOrClassElements(scope); - for (const child of children) { - if (child.pos >= minPos && isFunctionLike(child) && !isConstructorDeclaration(child)) { - return child; - } - } + return find(getStatementsOrClassElements(scope), child => + child.pos >= minPos && isFunctionLike(child) && !isConstructorDeclaration(child)); } function getPropertyAssignmentsForWrites(writes: ReadonlyArray): ShorthandPropertyAssignment[] { From 0ae42ea3def8cab3405e55927320d9dbc2ebfcd9 Mon Sep 17 00:00:00 2001 From: Andy Date: Tue, 19 Sep 2017 12:42:29 -0700 Subject: [PATCH 370/370] Allow relative imports of '.js' files when `--noImplicitAny` is disabled (#18489) * Allow relative imports of '.js' files when `--noImplicitAny` is disabled * Update baselines, and don't ignore a diagnostic about missing JSX --- src/compiler/checker.ts | 4 ++-- src/compiler/diagnosticMessages.json | 4 ---- src/compiler/program.ts | 12 +++++++++--- ...eResolutionWithExtensions_notSupported.errors.txt | 11 ++++------- .../moduleResolutionWithExtensions_notSupported.js | 6 +++--- ...ResolutionWithExtensions_notSupported3.errors.txt | 12 ------------ .../moduleResolutionWithExtensions_notSupported3.js | 2 +- ...uleResolutionWithExtensions_notSupported3.symbols | 4 ++++ ...oduleResolutionWithExtensions_notSupported3.types | 4 ++++ .../moduleResolution_relativeImportJsFile.js | 12 ++++++++++++ .../moduleResolution_relativeImportJsFile.symbols | 4 ++++ .../moduleResolution_relativeImportJsFile.types | 4 ++++ ...ion_relativeImportJsFile_noImplicitAny.errors.txt | 11 +++++++++++ ...eResolution_relativeImportJsFile_noImplicitAny.js | 12 ++++++++++++ .../moduleResolutionWithExtensions_notSupported.ts | 6 +++--- .../moduleResolutionWithExtensions_notSupported3.ts | 2 +- .../moduleResolution_relativeImportJsFile.ts | 7 +++++++ ...eResolution_relativeImportJsFile_noImplicitAny.ts | 8 ++++++++ .../untypedModuleImport_noLocalImports.ts | 9 --------- 19 files changed, 89 insertions(+), 45 deletions(-) delete mode 100644 tests/baselines/reference/moduleResolutionWithExtensions_notSupported3.errors.txt create mode 100644 tests/baselines/reference/moduleResolutionWithExtensions_notSupported3.symbols create mode 100644 tests/baselines/reference/moduleResolutionWithExtensions_notSupported3.types create mode 100644 tests/baselines/reference/moduleResolution_relativeImportJsFile.js create mode 100644 tests/baselines/reference/moduleResolution_relativeImportJsFile.symbols create mode 100644 tests/baselines/reference/moduleResolution_relativeImportJsFile.types create mode 100644 tests/baselines/reference/moduleResolution_relativeImportJsFile_noImplicitAny.errors.txt create mode 100644 tests/baselines/reference/moduleResolution_relativeImportJsFile_noImplicitAny.js create mode 100644 tests/cases/compiler/moduleResolution_relativeImportJsFile.ts create mode 100644 tests/cases/compiler/moduleResolution_relativeImportJsFile_noImplicitAny.ts delete mode 100644 tests/cases/conformance/moduleResolution/untypedModuleImport_noLocalImports.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 70bf20cdbf6..98b7a9d044f 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -1759,13 +1759,13 @@ namespace ts { } // May be an untyped module. If so, ignore resolutionDiagnostic. - if (resolvedModule && resolvedModule.isExternalLibraryImport && !extensionIsTypeScript(resolvedModule.extension)) { + if (resolvedModule && !extensionIsTypeScript(resolvedModule.extension) && resolutionDiagnostic === undefined || resolutionDiagnostic === Diagnostics.Could_not_find_a_declaration_file_for_module_0_1_implicitly_has_an_any_type) { if (isForAugmentation) { const diag = Diagnostics.Invalid_module_name_in_augmentation_Module_0_resolves_to_an_untyped_module_at_1_which_cannot_be_augmented; error(errorNode, diag, moduleReference, resolvedModule.resolvedFileName); } else if (noImplicitAny && moduleNotFoundError) { - let errorInfo = chainDiagnosticMessages(/*details*/ undefined, + let errorInfo = !resolvedModule.isExternalLibraryImport ? undefined : chainDiagnosticMessages(/*details*/ undefined, Diagnostics.Try_npm_install_types_Slash_0_if_it_exists_or_add_a_new_declaration_d_ts_file_containing_declare_module_0, moduleReference); errorInfo = chainDiagnosticMessages(errorInfo, diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index e273950424c..662e87d3159 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -3146,10 +3146,6 @@ "category": "Error", "code": 6142 }, - "Module '{0}' was resolved to '{1}', but '--allowJs' is not set.": { - "category": "Error", - "code": 6143 - }, "Module '{0}' was resolved as locally declared ambient module in file '{1}'.": { "category": "Message", "code": 6144 diff --git a/src/compiler/program.ts b/src/compiler/program.ts index f18d396e9dd..fe0b4c4de36 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -1846,7 +1846,8 @@ namespace ts { } const isFromNodeModulesSearch = resolution.isExternalLibraryImport; - const isJsFileFromNodeModules = isFromNodeModulesSearch && !extensionIsTypeScript(resolution.extension); + const isJsFile = !extensionIsTypeScript(resolution.extension); + const isJsFileFromNodeModules = isFromNodeModulesSearch && isJsFile; const resolvedFileName = resolution.resolvedFileName; if (isFromNodeModulesSearch) { @@ -1861,7 +1862,12 @@ namespace ts { const elideImport = isJsFileFromNodeModules && currentNodeModulesDepth > maxNodeModuleJsDepth; // Don't add the file if it has a bad extension (e.g. 'tsx' if we don't have '--allowJs') // This may still end up being an untyped module -- the file won't be included but imports will be allowed. - const shouldAddFile = resolvedFileName && !getResolutionDiagnostic(options, resolution) && !options.noResolve && i < file.imports.length && !elideImport; + const shouldAddFile = resolvedFileName + && !getResolutionDiagnostic(options, resolution) + && !options.noResolve + && i < file.imports.length + && !elideImport + && !(isJsFile && !options.allowJs); if (elideImport) { modulesWithElidedImports.set(file.path, true); @@ -2236,7 +2242,7 @@ namespace ts { return options.jsx ? undefined : Diagnostics.Module_0_was_resolved_to_1_but_jsx_is_not_set; } function needAllowJs() { - return options.allowJs ? undefined : Diagnostics.Module_0_was_resolved_to_1_but_allowJs_is_not_set; + return options.allowJs || !options.noImplicitAny ? undefined : Diagnostics.Could_not_find_a_declaration_file_for_module_0_1_implicitly_has_an_any_type; } } diff --git a/tests/baselines/reference/moduleResolutionWithExtensions_notSupported.errors.txt b/tests/baselines/reference/moduleResolutionWithExtensions_notSupported.errors.txt index 958837f7a0b..991b83bc306 100644 --- a/tests/baselines/reference/moduleResolutionWithExtensions_notSupported.errors.txt +++ b/tests/baselines/reference/moduleResolutionWithExtensions_notSupported.errors.txt @@ -1,18 +1,15 @@ /a.ts(1,17): error TS6142: Module './tsx' was resolved to '/tsx.tsx', but '--jsx' is not set. /a.ts(2,17): error TS6142: Module './jsx' was resolved to '/jsx.jsx', but '--jsx' is not set. -/a.ts(3,16): error TS6143: Module './js' was resolved to '/js.js', but '--allowJs' is not set. -==== /a.ts (3 errors) ==== - import tsx from "./tsx"; +==== /a.ts (2 errors) ==== + import tsx from "./tsx"; // Not allowed. ~~~~~~~ !!! error TS6142: Module './tsx' was resolved to '/tsx.tsx', but '--jsx' is not set. - import jsx from "./jsx"; + import jsx from "./jsx"; // Not allowed. ~~~~~~~ !!! error TS6142: Module './jsx' was resolved to '/jsx.jsx', but '--jsx' is not set. - import js from "./js"; - ~~~~~~ -!!! error TS6143: Module './js' was resolved to '/js.js', but '--allowJs' is not set. + import js from "./js"; // OK because it's an untyped module. ==== /tsx.tsx (0 errors) ==== diff --git a/tests/baselines/reference/moduleResolutionWithExtensions_notSupported.js b/tests/baselines/reference/moduleResolutionWithExtensions_notSupported.js index eb6057f9693..6771a977b35 100644 --- a/tests/baselines/reference/moduleResolutionWithExtensions_notSupported.js +++ b/tests/baselines/reference/moduleResolutionWithExtensions_notSupported.js @@ -7,9 +7,9 @@ //// [js.js] //// [a.ts] -import tsx from "./tsx"; -import jsx from "./jsx"; -import js from "./js"; +import tsx from "./tsx"; // Not allowed. +import jsx from "./jsx"; // Not allowed. +import js from "./js"; // OK because it's an untyped module. //// [a.js] diff --git a/tests/baselines/reference/moduleResolutionWithExtensions_notSupported3.errors.txt b/tests/baselines/reference/moduleResolutionWithExtensions_notSupported3.errors.txt deleted file mode 100644 index 45e058bae54..00000000000 --- a/tests/baselines/reference/moduleResolutionWithExtensions_notSupported3.errors.txt +++ /dev/null @@ -1,12 +0,0 @@ -/a.ts(1,17): error TS6143: Module './jsx' was resolved to '/jsx.jsx', but '--allowJs' is not set. - - -==== /a.ts (1 errors) ==== - import jsx from "./jsx"; - ~~~~~~~ -!!! error TS6143: Module './jsx' was resolved to '/jsx.jsx', but '--allowJs' is not set. - -==== /jsx.jsx (0 errors) ==== - // Test the error message if we have `--jsx` but not `--allowJw`. - - \ No newline at end of file diff --git a/tests/baselines/reference/moduleResolutionWithExtensions_notSupported3.js b/tests/baselines/reference/moduleResolutionWithExtensions_notSupported3.js index ca0fa6ca402..1c8a2537e0f 100644 --- a/tests/baselines/reference/moduleResolutionWithExtensions_notSupported3.js +++ b/tests/baselines/reference/moduleResolutionWithExtensions_notSupported3.js @@ -1,7 +1,7 @@ //// [tests/cases/compiler/moduleResolutionWithExtensions_notSupported3.ts] //// //// [jsx.jsx] -// Test the error message if we have `--jsx` but not `--allowJw`. +// If we have "--jsx" set and not "--allowJs", it's an implicit-any module. //// [a.ts] diff --git a/tests/baselines/reference/moduleResolutionWithExtensions_notSupported3.symbols b/tests/baselines/reference/moduleResolutionWithExtensions_notSupported3.symbols new file mode 100644 index 00000000000..071936029fa --- /dev/null +++ b/tests/baselines/reference/moduleResolutionWithExtensions_notSupported3.symbols @@ -0,0 +1,4 @@ +=== /a.ts === +import jsx from "./jsx"; +>jsx : Symbol(jsx, Decl(a.ts, 0, 6)) + diff --git a/tests/baselines/reference/moduleResolutionWithExtensions_notSupported3.types b/tests/baselines/reference/moduleResolutionWithExtensions_notSupported3.types new file mode 100644 index 00000000000..70fe2e49dbf --- /dev/null +++ b/tests/baselines/reference/moduleResolutionWithExtensions_notSupported3.types @@ -0,0 +1,4 @@ +=== /a.ts === +import jsx from "./jsx"; +>jsx : any + diff --git a/tests/baselines/reference/moduleResolution_relativeImportJsFile.js b/tests/baselines/reference/moduleResolution_relativeImportJsFile.js new file mode 100644 index 00000000000..94984a414e2 --- /dev/null +++ b/tests/baselines/reference/moduleResolution_relativeImportJsFile.js @@ -0,0 +1,12 @@ +//// [tests/cases/compiler/moduleResolution_relativeImportJsFile.ts] //// + +//// [b.js] +export const x = 0; + +//// [a.ts] +import * as b from "./b"; + + +//// [a.js] +"use strict"; +exports.__esModule = true; diff --git a/tests/baselines/reference/moduleResolution_relativeImportJsFile.symbols b/tests/baselines/reference/moduleResolution_relativeImportJsFile.symbols new file mode 100644 index 00000000000..693e1501a11 --- /dev/null +++ b/tests/baselines/reference/moduleResolution_relativeImportJsFile.symbols @@ -0,0 +1,4 @@ +=== /src/a.ts === +import * as b from "./b"; +>b : Symbol(b, Decl(a.ts, 0, 6)) + diff --git a/tests/baselines/reference/moduleResolution_relativeImportJsFile.types b/tests/baselines/reference/moduleResolution_relativeImportJsFile.types new file mode 100644 index 00000000000..051c4dad861 --- /dev/null +++ b/tests/baselines/reference/moduleResolution_relativeImportJsFile.types @@ -0,0 +1,4 @@ +=== /src/a.ts === +import * as b from "./b"; +>b : any + diff --git a/tests/baselines/reference/moduleResolution_relativeImportJsFile_noImplicitAny.errors.txt b/tests/baselines/reference/moduleResolution_relativeImportJsFile_noImplicitAny.errors.txt new file mode 100644 index 00000000000..e3d36d4334c --- /dev/null +++ b/tests/baselines/reference/moduleResolution_relativeImportJsFile_noImplicitAny.errors.txt @@ -0,0 +1,11 @@ +/src/a.ts(1,20): error TS7016: Could not find a declaration file for module './b'. '/src/b.js' implicitly has an 'any' type. + + +==== /src/a.ts (1 errors) ==== + import * as b from "./b"; + ~~~~~ +!!! error TS7016: Could not find a declaration file for module './b'. '/src/b.js' implicitly has an 'any' type. + +==== /src/b.js (0 errors) ==== + export const x = 0; + \ No newline at end of file diff --git a/tests/baselines/reference/moduleResolution_relativeImportJsFile_noImplicitAny.js b/tests/baselines/reference/moduleResolution_relativeImportJsFile_noImplicitAny.js new file mode 100644 index 00000000000..28b512b91a4 --- /dev/null +++ b/tests/baselines/reference/moduleResolution_relativeImportJsFile_noImplicitAny.js @@ -0,0 +1,12 @@ +//// [tests/cases/compiler/moduleResolution_relativeImportJsFile_noImplicitAny.ts] //// + +//// [b.js] +export const x = 0; + +//// [a.ts] +import * as b from "./b"; + + +//// [a.js] +"use strict"; +exports.__esModule = true; diff --git a/tests/cases/compiler/moduleResolutionWithExtensions_notSupported.ts b/tests/cases/compiler/moduleResolutionWithExtensions_notSupported.ts index 58b039ad8c2..931c1291e48 100644 --- a/tests/cases/compiler/moduleResolutionWithExtensions_notSupported.ts +++ b/tests/cases/compiler/moduleResolutionWithExtensions_notSupported.ts @@ -8,6 +8,6 @@ // @Filename: /js.js // @Filename: /a.ts -import tsx from "./tsx"; -import jsx from "./jsx"; -import js from "./js"; +import tsx from "./tsx"; // Not allowed. +import jsx from "./jsx"; // Not allowed. +import js from "./js"; // OK because it's an untyped module. diff --git a/tests/cases/compiler/moduleResolutionWithExtensions_notSupported3.ts b/tests/cases/compiler/moduleResolutionWithExtensions_notSupported3.ts index e06f603377c..b665f6932d7 100644 --- a/tests/cases/compiler/moduleResolutionWithExtensions_notSupported3.ts +++ b/tests/cases/compiler/moduleResolutionWithExtensions_notSupported3.ts @@ -1,7 +1,7 @@ // @noImplicitReferences: true // @jsx: preserve // @traceResolution: true -// Test the error message if we have `--jsx` but not `--allowJw`. +// If we have "--jsx" set and not "--allowJs", it's an implicit-any module. // @Filename: /jsx.jsx diff --git a/tests/cases/compiler/moduleResolution_relativeImportJsFile.ts b/tests/cases/compiler/moduleResolution_relativeImportJsFile.ts new file mode 100644 index 00000000000..41b6831d582 --- /dev/null +++ b/tests/cases/compiler/moduleResolution_relativeImportJsFile.ts @@ -0,0 +1,7 @@ +// @noImplicitReferences: true + +// @Filename: /src/b.js +export const x = 0; + +// @Filename: /src/a.ts +import * as b from "./b"; diff --git a/tests/cases/compiler/moduleResolution_relativeImportJsFile_noImplicitAny.ts b/tests/cases/compiler/moduleResolution_relativeImportJsFile_noImplicitAny.ts new file mode 100644 index 00000000000..cf89af925c3 --- /dev/null +++ b/tests/cases/compiler/moduleResolution_relativeImportJsFile_noImplicitAny.ts @@ -0,0 +1,8 @@ +// @noImplicitReferences: true +// @noImplicitAny: true + +// @Filename: /src/b.js +export const x = 0; + +// @Filename: /src/a.ts +import * as b from "./b"; diff --git a/tests/cases/conformance/moduleResolution/untypedModuleImport_noLocalImports.ts b/tests/cases/conformance/moduleResolution/untypedModuleImport_noLocalImports.ts deleted file mode 100644 index 8313628e6d7..00000000000 --- a/tests/cases/conformance/moduleResolution/untypedModuleImport_noLocalImports.ts +++ /dev/null @@ -1,9 +0,0 @@ -// @noImplicitReferences: true -// @currentDirectory: / -// This tests that untyped module imports don't happen with local imports. - -// @filename: /foo.js -This file is not processed. - -// @filename: /a.ts -import * as foo from "./foo";