From 7d9b22eea011a260a51fd91f7c97f89b7737244a Mon Sep 17 00:00:00 2001 From: Andrew Branch Date: Thu, 26 Sep 2019 13:23:29 -0700 Subject: [PATCH 1/4] Add semicolon preference to formatter options (#33402) * Add UserPreferences for semicolons * Prototype formatter semicolon removal * Implement semicolon insertion * Fix existing tests * Start adding tests * Fix some edge cases of semicolon deletion * Fix semicolon removal before comments * Fix indentation * Test on checker * Replace semicolon-omitting writer with formatter preference * Fix writing new nodes, update protocol * Rename option * Really fix formatting synthetic nodes * Fix refactoring misses * Un-update submodules gahhhh * Update APIs * Update for ESLint * Revert accidental test change * De-kludge deduplication of EOF processing * Omit last element semicolon from single-line object-like types * Revert "Omit last element semicolon from single-line object-like types" This reverts commit 5625cb023743215d4721bf07b2d41f831399977d. * Fix straggler test * Add test for leading semicolon class members * Rename a lot of stuff for clarity * Invert some boolean logic --- src/compiler/core.ts | 30 +- src/compiler/utilities.ts | 20 +- src/harness/fourslash.ts | 34 +- src/server/protocol.ts | 7 + src/services/codefixes/importFixes.ts | 2 +- src/services/formatting/formatting.ts | 117 ++++-- src/services/formatting/formattingContext.ts | 2 +- src/services/formatting/formattingScanner.ts | 34 +- src/services/formatting/rule.ts | 17 +- src/services/formatting/rules.ts | 344 +++++++++++------- src/services/formatting/rulesMap.ts | 48 ++- src/services/getEditsForFileRename.ts | 4 +- src/services/organizeImports.ts | 4 +- src/services/services.ts | 4 +- src/services/textChanges.ts | 23 +- src/services/types.ts | 12 + src/services/utilities.ts | 81 ++++- .../reference/api/tsserverlibrary.d.ts | 12 + tests/baselines/reference/api/typescript.d.ts | 6 + .../codeFixInferFromCallInAssignment.ts | 2 +- .../codeFixInferFromFunctionUsage.ts | 2 +- tests/cases/fourslash/extract-method28.ts | 20 + tests/cases/fourslash/extract-method29.ts | 20 + tests/cases/fourslash/extract-method30.ts | 20 + tests/cases/fourslash/formatAddSemicolons1.ts | 53 +++ .../fourslash/formatRemoveSemicolons1.ts | 77 ++++ .../fourslash/formatRemoveSemicolons2.ts | 27 ++ .../fourslash/formatRemoveSemicolons3.ts | 11 + tests/cases/fourslash/fourslash.ts | 41 ++- 29 files changed, 817 insertions(+), 257 deletions(-) create mode 100644 tests/cases/fourslash/extract-method28.ts create mode 100644 tests/cases/fourslash/extract-method29.ts create mode 100644 tests/cases/fourslash/extract-method30.ts create mode 100644 tests/cases/fourslash/formatAddSemicolons1.ts create mode 100644 tests/cases/fourslash/formatRemoveSemicolons1.ts create mode 100644 tests/cases/fourslash/formatRemoveSemicolons2.ts create mode 100644 tests/cases/fourslash/formatRemoveSemicolons3.ts diff --git a/src/compiler/core.ts b/src/compiler/core.ts index 0a3f0ff674918..73e0261670fd5 100644 --- a/src/compiler/core.ts +++ b/src/compiler/core.ts @@ -329,6 +329,21 @@ namespace ts { return undefined; } + /** + * Like `forEach`, but iterates in reverse order. + */ + export function forEachRight(array: readonly T[] | undefined, callback: (element: T, index: number) => U | undefined): U | undefined { + if (array) { + for (let i = array.length - 1; i >= 0; i--) { + const result = callback(array[i], i); + if (result) { + return result; + } + } + } + return undefined; + } + /** Like `forEach`, but suitable for use with numbers and strings (which may be falsy). */ export function firstDefined(array: readonly T[] | undefined, callback: (element: T, index: number) => U | undefined): U | undefined { if (array === undefined) { @@ -2159,8 +2174,19 @@ namespace ts { return (arg: T) => f(arg) && g(arg); } - export function or(f: (arg: T) => boolean, g: (arg: T) => boolean): (arg: T) => boolean { - return arg => f(arg) || g(arg); + export function or(...fs: ((arg: T) => boolean)[]): (arg: T) => boolean { + return arg => { + for (const f of fs) { + if (f(arg)) { + return true; + } + } + return false; + }; + } + + export function not(fn: (...args: T) => boolean): (...args: T) => boolean { + return (...args) => !fn(...args); } export function assertType(_: T): void { } diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index 6b48cb80625ee..63c6bb301b4e6 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -3380,11 +3380,7 @@ namespace ts { }; } - export interface TrailingSemicolonDeferringWriter extends EmitTextWriter { - resetPendingTrailingSemicolon(): void; - } - - export function getTrailingSemicolonDeferringWriter(writer: EmitTextWriter): TrailingSemicolonDeferringWriter { + export function getTrailingSemicolonDeferringWriter(writer: EmitTextWriter): EmitTextWriter { let pendingTrailingSemicolon = false; function commitPendingTrailingSemicolon() { @@ -3451,20 +3447,6 @@ namespace ts { commitPendingTrailingSemicolon(); writer.decreaseIndent(); }, - resetPendingTrailingSemicolon() { - pendingTrailingSemicolon = false; - } - }; - } - - export function getTrailingSemicolonOmittingWriter(writer: EmitTextWriter): EmitTextWriter { - const deferringWriter = getTrailingSemicolonDeferringWriter(writer); - return { - ...deferringWriter, - writeLine() { - deferringWriter.resetPendingTrailingSemicolon(); - writer.writeLine(); - }, }; } diff --git a/src/harness/fourslash.ts b/src/harness/fourslash.ts index cf01109bb9af5..5ae2976f051c8 100644 --- a/src/harness/fourslash.ts +++ b/src/harness/fourslash.ts @@ -1683,7 +1683,7 @@ namespace FourSlash { if (this.enableFormatting) { const edits = this.languageService.getFormattingEditsAfterKeystroke(this.activeFile.fileName, offset, ch, this.formatCodeSettings); if (edits.length) { - offset += this.applyEdits(this.activeFile.fileName, edits, /*isFormattingEdit*/ true); + offset += this.applyEdits(this.activeFile.fileName, edits); } } } @@ -1756,7 +1756,7 @@ namespace FourSlash { if (this.enableFormatting) { const edits = this.languageService.getFormattingEditsAfterKeystroke(this.activeFile.fileName, offset, ch, this.formatCodeSettings); if (edits.length) { - offset += this.applyEdits(this.activeFile.fileName, edits, /*isFormattingEdit*/ true); + offset += this.applyEdits(this.activeFile.fileName, edits); } } } @@ -1775,7 +1775,7 @@ namespace FourSlash { if (this.enableFormatting) { const edits = this.languageService.getFormattingEditsForRange(this.activeFile.fileName, start, offset, this.formatCodeSettings); if (edits.length) { - this.applyEdits(this.activeFile.fileName, edits, /*isFormattingEdit*/ true); + this.applyEdits(this.activeFile.fileName, edits); } } @@ -1810,9 +1810,7 @@ namespace FourSlash { * @returns The number of characters added to the file as a result of the edits. * May be negative. */ - private applyEdits(fileName: string, edits: readonly ts.TextChange[], isFormattingEdit: boolean): number { - // Get a snapshot of the content of the file so we can make sure any formatting edits didn't destroy non-whitespace characters - const oldContent = this.getFileContent(fileName); + private applyEdits(fileName: string, edits: readonly ts.TextChange[]): number { let runningOffset = 0; forEachTextChange(edits, edit => { @@ -1833,14 +1831,6 @@ namespace FourSlash { runningOffset += editDelta; }); - if (isFormattingEdit) { - const newContent = this.getFileContent(fileName); - - if (this.removeWhitespace(newContent) !== this.removeWhitespace(oldContent)) { - this.raiseError("Formatting operation destroyed non-whitespace content"); - } - } - return runningOffset; } @@ -1856,17 +1846,17 @@ namespace FourSlash { public formatDocument() { const edits = this.languageService.getFormattingEditsForDocument(this.activeFile.fileName, this.formatCodeSettings); - this.applyEdits(this.activeFile.fileName, edits, /*isFormattingEdit*/ true); + this.applyEdits(this.activeFile.fileName, edits); } public formatSelection(start: number, end: number) { const edits = this.languageService.getFormattingEditsForRange(this.activeFile.fileName, start, end, this.formatCodeSettings); - this.applyEdits(this.activeFile.fileName, edits, /*isFormattingEdit*/ true); + this.applyEdits(this.activeFile.fileName, edits); } public formatOnType(pos: number, key: string) { const edits = this.languageService.getFormattingEditsAfterKeystroke(this.activeFile.fileName, pos, key, this.formatCodeSettings); - this.applyEdits(this.activeFile.fileName, edits, /*isFormattingEdit*/ true); + this.applyEdits(this.activeFile.fileName, edits); } private editScriptAndUpdateMarkers(fileName: string, editStart: number, editEnd: number, newText: string) { @@ -2414,7 +2404,7 @@ namespace FourSlash { if (options.applyChanges) { for (const change of action.changes) { - this.applyEdits(change.fileName, change.textChanges, /*isFormattingEdit*/ false); + this.applyEdits(change.fileName, change.textChanges); } this.verifyNewContentAfterChange(options, action.changes.map(c => c.fileName)); } @@ -2497,7 +2487,7 @@ namespace FourSlash { private applyChanges(changes: readonly ts.FileTextChanges[]): void { for (const change of changes) { - this.applyEdits(change.fileName, change.textChanges, /*isFormattingEdit*/ false); + this.applyEdits(change.fileName, change.textChanges); } } @@ -2525,7 +2515,7 @@ namespace FourSlash { ts.Debug.assert(codeFix.changes.length === 1); const change = ts.first(codeFix.changes); ts.Debug.assert(change.fileName === fileName); - this.applyEdits(change.fileName, change.textChanges, /*isFormattingEdit*/ false); + this.applyEdits(change.fileName, change.textChanges); const text = range ? this.rangeText(range) : this.getFileContent(this.activeFile.fileName); actualTextArray.push(text); scriptInfo.updateContent(originalContent); @@ -2929,7 +2919,7 @@ namespace FourSlash { const editInfo = this.languageService.getEditsForRefactor(this.activeFile.fileName, this.formatCodeSettings, range, refactorName, actionName, ts.emptyOptions)!; for (const edit of editInfo.edits) { - this.applyEdits(edit.fileName, edit.textChanges, /*isFormattingEdit*/ false); + this.applyEdits(edit.fileName, edit.textChanges); } let renameFilename: string | undefined; @@ -3045,7 +3035,7 @@ namespace FourSlash { const editInfo = this.languageService.getEditsForRefactor(marker.fileName, formattingOptions, marker.position, refactorNameToApply, actionName, ts.emptyOptions)!; for (const edit of editInfo.edits) { - this.applyEdits(edit.fileName, edit.textChanges, /*isFormattingEdit*/ false); + this.applyEdits(edit.fileName, edit.textChanges); } const actualContent = this.getFileContent(marker.fileName); diff --git a/src/server/protocol.ts b/src/server/protocol.ts index 0674f1c142de3..0ec27a3a2bb38 100644 --- a/src/server/protocol.ts +++ b/src/server/protocol.ts @@ -2956,6 +2956,12 @@ namespace ts.server.protocol { Smart = "Smart", } + export enum SemicolonPreference { + Ignore = "ignore", + Insert = "insert", + Remove = "remove", + } + export interface EditorSettings { baseIndentSize?: number; indentSize?: number; @@ -2982,6 +2988,7 @@ namespace ts.server.protocol { placeOpenBraceOnNewLineForFunctions?: boolean; placeOpenBraceOnNewLineForControlBlocks?: boolean; insertSpaceBeforeTypeAnnotation?: boolean; + semicolons?: SemicolonPreference; } export interface UserPreferences { diff --git a/src/services/codefixes/importFixes.ts b/src/services/codefixes/importFixes.ts index 4ae8b3466fb05..7dfb14661563a 100644 --- a/src/services/codefixes/importFixes.ts +++ b/src/services/codefixes/importFixes.ts @@ -169,7 +169,7 @@ namespace ts.codefix { // We sort the best codefixes first, so taking `first` is best for completions. const moduleSpecifier = first(getNewImportInfos(program, sourceFile, position, exportInfos, host, preferences)).moduleSpecifier; const fix = first(getFixForImport(exportInfos, symbolName, position, program, sourceFile, host, preferences)); - return { moduleSpecifier, codeAction: codeFixActionToCodeAction(codeActionForFix({ host, formatContext }, sourceFile, symbolName, fix, getQuotePreference(sourceFile, preferences))) }; + return { moduleSpecifier, codeAction: codeFixActionToCodeAction(codeActionForFix({ host, formatContext, preferences }, sourceFile, symbolName, fix, getQuotePreference(sourceFile, preferences))) }; } function codeFixActionToCodeAction({ description, changes, commands }: CodeFixAction): CodeAction { diff --git a/src/services/formatting/formatting.ts b/src/services/formatting/formatting.ts index f9b0d752db706..6895ddc96b9b7 100644 --- a/src/services/formatting/formatting.ts +++ b/src/services/formatting/formatting.ts @@ -2,16 +2,14 @@ namespace ts.formatting { export interface FormatContext { readonly options: FormatCodeSettings; - readonly getRule: RulesMap; + readonly getRules: RulesMap; } - export interface TextRangeWithKind extends TextRange { - kind: SyntaxKind; + export interface TextRangeWithKind extends TextRange { + kind: T; } - export interface TextRangeWithTriviaKind extends TextRange { - kind: TriviaKind; - } + export type TextRangeWithTriviaKind = TextRangeWithKind; export interface TokenInfo { leadingTrivia: TextRangeWithTriviaKind[] | undefined; @@ -19,6 +17,16 @@ namespace ts.formatting { trailingTrivia: TextRangeWithTriviaKind[] | undefined; } + export function createTextRangeWithKind(pos: number, end: number, kind: T): TextRangeWithKind { + const textRangeWithKind: TextRangeWithKind = { pos, end, kind }; + if (Debug.isDebugging) { + Object.defineProperty(textRangeWithKind, "__debugKind", { + get: () => Debug.formatSyntaxKind(kind), + }); + } + return textRangeWithKind; + } + const enum Constants { Unknown = -1 } @@ -386,7 +394,7 @@ namespace ts.formatting { initialIndentation: number, delta: number, formattingScanner: FormattingScanner, - { options, getRule }: FormatContext, + { options, getRules }: FormatContext, requestKind: FormattingRequestKind, rangeContainsError: (r: TextRange) => boolean, sourceFile: SourceFileLike): TextChange[] { @@ -469,7 +477,7 @@ namespace ts.formatting { parent: Node, parentDynamicIndentation: DynamicIndentation, effectiveParentStartLine: number - ): { indentation: number, delta: number } { + ): { indentation: number, delta: number; } { const delta = SmartIndenter.shouldIndentChildNode(options, node) ? options.indentSize! : 0; if (effectiveParentStartLine === startLine) { @@ -644,6 +652,21 @@ namespace ts.formatting { consumeTokenAndAdvanceScanner(tokenInfo, node, nodeDynamicIndentation, node); } + if (!node.parent && formattingScanner.isOnEOF()) { + const token = formattingScanner.readEOFTokenRange(); + if (token.end <= node.end && previousRange) { + processPair( + token, + sourceFile.getLineAndCharacterOfPosition(token.pos).line, + node, + previousRange, + previousRangeStartLine, + previousParent, + contextNode, + nodeDynamicIndentation); + } + } + function processChildNode( child: Node, inheritedIndentation: number, @@ -938,37 +961,41 @@ namespace ts.formatting { formattingContext.updateContext(previousItem, previousParent, currentItem, currentParent, contextNode); - const rule = getRule(formattingContext); + const rules = getRules(formattingContext); - let trimTrailingWhitespaces: boolean; + let trimTrailingWhitespaces = false; let lineAction = LineAction.None; - if (rule) { - lineAction = applyRuleEdits(rule, previousItem, previousStartLine, currentItem, currentStartLine); - switch (lineAction) { - case LineAction.LineRemoved: - // Handle the case where the next line is moved to be the end of this line. - // In this case we don't indent the next line in the next pass. - if (currentParent.getStart(sourceFile) === currentItem.pos) { - dynamicIndentation.recomputeIndentation(/*lineAddedByFormatting*/ false); - } - break; - case LineAction.LineAdded: - // Handle the case where token2 is moved to the new line. - // In this case we indent token2 in the next pass but we set - // sameLineIndent flag to notify the indenter that the indentation is within the line. - if (currentParent.getStart(sourceFile) === currentItem.pos) { - dynamicIndentation.recomputeIndentation(/*lineAddedByFormatting*/ true); - } - break; - default: - Debug.assert(lineAction === LineAction.None); - } + if (rules) { + // Apply rules in reverse order so that higher priority rules (which are first in the array) + // win in a conflict with lower priority rules. + forEachRight(rules, rule => { + lineAction = applyRuleEdits(rule, previousItem, previousStartLine, currentItem, currentStartLine); + switch (lineAction) { + case LineAction.LineRemoved: + // Handle the case where the next line is moved to be the end of this line. + // In this case we don't indent the next line in the next pass. + if (currentParent.getStart(sourceFile) === currentItem.pos) { + dynamicIndentation.recomputeIndentation(/*lineAddedByFormatting*/ false); + } + break; + case LineAction.LineAdded: + // Handle the case where token2 is moved to the new line. + // In this case we indent token2 in the next pass but we set + // sameLineIndent flag to notify the indenter that the indentation is within the line. + if (currentParent.getStart(sourceFile) === currentItem.pos) { + dynamicIndentation.recomputeIndentation(/*lineAddedByFormatting*/ true); + } + break; + default: + Debug.assert(lineAction === LineAction.None); + } - // We need to trim trailing whitespace between the tokens if they were on different lines, and no rule was applied to put them on the same line - trimTrailingWhitespaces = !(rule.action & RuleAction.Delete) && rule.flags !== RuleFlags.CanDeleteNewLines; + // We need to trim trailing whitespace between the tokens if they were on different lines, and no rule was applied to put them on the same line + trimTrailingWhitespaces = !(rule.action & RuleAction.DeleteSpace) && rule.flags !== RuleFlags.CanDeleteNewLines; + }); } else { - trimTrailingWhitespaces = true; + trimTrailingWhitespaces = currentItem.kind !== SyntaxKind.EndOfFileToken; } if (currentStartLine !== previousStartLine && trimTrailingWhitespaces) { @@ -1130,6 +1157,12 @@ namespace ts.formatting { } } + function recordInsert(start: number, text: string) { + if (text) { + edits.push(createTextChangeFromStartLength(start, 0, text)); + } + } + function applyRuleEdits(rule: Rule, previousRange: TextRangeWithKind, previousStartLine: number, @@ -1138,17 +1171,20 @@ namespace ts.formatting { ): LineAction { const onLaterLine = currentStartLine !== previousStartLine; switch (rule.action) { - case RuleAction.Ignore: + case RuleAction.StopProcessingSpaceActions: // no action required return LineAction.None; - case RuleAction.Delete: + case RuleAction.DeleteSpace: if (previousRange.end !== currentRange.pos) { // delete characters starting from t1.end up to t2.pos exclusive recordDelete(previousRange.end, currentRange.pos - previousRange.end); return onLaterLine ? LineAction.LineRemoved : LineAction.None; } break; - case RuleAction.NewLine: + case RuleAction.DeleteToken: + recordDelete(previousRange.pos, previousRange.end - previousRange.pos); + break; + case RuleAction.InsertNewLine: // exit early if we on different lines and rule cannot change number of newlines // if line1 and line2 are on subsequent lines then no edits are required - ok to exit // if line1 and line2 are separated with more than one newline - ok to exit since we cannot delete extra new lines @@ -1163,7 +1199,7 @@ namespace ts.formatting { return onLaterLine ? LineAction.None : LineAction.LineAdded; } break; - case RuleAction.Space: + case RuleAction.InsertSpace: // exit early if we on different lines and rule cannot change number of newlines if (rule.flags !== RuleFlags.CanDeleteNewLines && previousStartLine !== currentStartLine) { return LineAction.None; @@ -1174,6 +1210,9 @@ namespace ts.formatting { recordReplace(previousRange.end, currentRange.pos - previousRange.end, " "); return onLaterLine ? LineAction.LineRemoved : LineAction.None; } + break; + case RuleAction.InsertTrailingSemicolon: + recordInsert(previousRange.end, ";"); } return LineAction.None; } @@ -1271,7 +1310,7 @@ namespace ts.formatting { return SyntaxKind.Unknown; } - let internedSizes: { tabSize: number; indentSize: number }; + let internedSizes: { tabSize: number; indentSize: number; }; let internedTabsIndentation: string[] | undefined; let internedSpacesIndentation: string[] | undefined; diff --git a/src/services/formatting/formattingContext.ts b/src/services/formatting/formattingContext.ts index e5a1ff5d4ac8f..df479acdf4e35 100644 --- a/src/services/formatting/formattingContext.ts +++ b/src/services/formatting/formattingContext.ts @@ -99,4 +99,4 @@ namespace ts.formatting { return false; } } -} \ No newline at end of file +} diff --git a/src/services/formatting/formattingScanner.ts b/src/services/formatting/formattingScanner.ts index c1e97e636d093..3e6c2a9c9ff5c 100644 --- a/src/services/formatting/formattingScanner.ts +++ b/src/services/formatting/formattingScanner.ts @@ -6,7 +6,9 @@ namespace ts.formatting { export interface FormattingScanner { advance(): void; isOnToken(): boolean; + isOnEOF(): boolean; readTokenInfo(n: Node): TokenInfo; + readEOFTokenRange(): TextRangeWithKind; getCurrentLeadingTrivia(): TextRangeWithKind[] | undefined; lastTrailingTriviaWasNewLine(): boolean; skipToEndOf(node: Node): void; @@ -38,7 +40,9 @@ namespace ts.formatting { const res = cb({ advance, readTokenInfo, + readEOFTokenRange, isOnToken, + isOnEOF, getCurrentLeadingTrivia: () => leadingTrivia, lastTrailingTriviaWasNewLine: () => wasNewLine, skipToEndOf, @@ -164,11 +168,11 @@ namespace ts.formatting { let currentToken = getNextToken(n, expectedScanAction); - const token: TextRangeWithKind = { - pos: scanner.getStartPos(), - end: scanner.getTextPos(), - kind: currentToken - }; + const token = createTextRangeWithKind( + scanner.getStartPos(), + scanner.getTextPos(), + currentToken, + ); // consume trailing trivia if (trailingTrivia) { @@ -179,11 +183,11 @@ namespace ts.formatting { if (!isTrivia(currentToken)) { break; } - const trivia: TextRangeWithTriviaKind = { - pos: scanner.getStartPos(), - end: scanner.getTextPos(), - kind: currentToken - }; + const trivia = createTextRangeWithKind( + scanner.getStartPos(), + scanner.getTextPos(), + currentToken, + ); if (!trailingTrivia) { trailingTrivia = []; @@ -243,12 +247,22 @@ namespace ts.formatting { return token; } + function readEOFTokenRange(): TextRangeWithKind { + Debug.assert(isOnEOF()); + return createTextRangeWithKind(scanner.getStartPos(), scanner.getTextPos(), SyntaxKind.EndOfFileToken); + } + function isOnToken(): boolean { const current = lastTokenInfo ? lastTokenInfo.token.kind : scanner.getToken(); const startPos = lastTokenInfo ? lastTokenInfo.token.pos : scanner.getStartPos(); return startPos < endPos && current !== SyntaxKind.EndOfFileToken && !isTrivia(current); } + function isOnEOF(): boolean { + const current = lastTokenInfo ? lastTokenInfo.token.kind : scanner.getToken(); + return current === SyntaxKind.EndOfFileToken; + } + // when containing node in the tree is token // but its kind differs from the kind that was returned by the scanner, // then kind needs to be fixed. This might happen in cases diff --git a/src/services/formatting/rule.ts b/src/services/formatting/rule.ts index a35489523241c..ef98461738891 100644 --- a/src/services/formatting/rule.ts +++ b/src/services/formatting/rule.ts @@ -12,10 +12,17 @@ namespace ts.formatting { export const anyContext: readonly ContextPredicate[] = emptyArray; export const enum RuleAction { - Ignore = 1 << 0, - Space = 1 << 1, - NewLine = 1 << 2, - Delete = 1 << 3, + StopProcessingSpaceActions = 1 << 0, + StopProcessingTokenActions = 1 << 1, + InsertSpace = 1 << 2, + InsertNewLine = 1 << 3, + DeleteSpace = 1 << 4, + DeleteToken = 1 << 5, + InsertTrailingSemicolon = 1 << 6, + + StopAction = StopProcessingSpaceActions | StopProcessingTokenActions, + ModifySpaceAction = InsertSpace | InsertNewLine | DeleteSpace, + ModifyTokenAction = DeleteToken | InsertTrailingSemicolon, } export const enum RuleFlags { @@ -27,4 +34,4 @@ namespace ts.formatting { readonly tokens: readonly SyntaxKind[]; readonly isSpecific: boolean; } -} \ No newline at end of file +} diff --git a/src/services/formatting/rules.ts b/src/services/formatting/rules.ts index 670048eb737a8..75720555f5248 100644 --- a/src/services/formatting/rules.ts +++ b/src/services/formatting/rules.ts @@ -9,7 +9,9 @@ namespace ts.formatting { export function getAllRules(): RuleSpec[] { const allTokens: SyntaxKind[] = []; for (let token = SyntaxKind.FirstToken; token <= SyntaxKind.LastToken; token++) { - allTokens.push(token); + if (token !== SyntaxKind.EndOfFileToken) { + allTokens.push(token); + } } function anyTokenExcept(...tokens: SyntaxKind[]): TokenRange { return { tokens: allTokens.filter(t => !tokens.some(t2 => t2 === t)), isSpecific: false }; @@ -17,6 +19,7 @@ namespace ts.formatting { const anyToken: TokenRange = { tokens: allTokens, isSpecific: false }; const anyTokenIncludingMultilineComments = tokenRangeFrom([...allTokens, SyntaxKind.MultiLineCommentTrivia]); + const anyTokenIncludingEOF = tokenRangeFrom([...allTokens, SyntaxKind.EndOfFileToken]); const keywords = tokenRangeFromRange(SyntaxKind.FirstKeyword, SyntaxKind.LastKeyword); const binaryOperators = tokenRangeFromRange(SyntaxKind.FirstBinaryOperator, SyntaxKind.LastBinaryOperator); const binaryKeywordOperators = [SyntaxKind.InKeyword, SyntaxKind.InstanceOfKeyword, SyntaxKind.OfKeyword, SyntaxKind.AsKeyword, SyntaxKind.IsKeyword]; @@ -44,103 +47,103 @@ namespace ts.formatting { // These rules are higher in priority than user-configurable const highPriorityCommonRules = [ // Leave comments alone - rule("IgnoreBeforeComment", anyToken, comments, anyContext, RuleAction.Ignore), - rule("IgnoreAfterLineComment", SyntaxKind.SingleLineCommentTrivia, anyToken, anyContext, RuleAction.Ignore), + rule("IgnoreBeforeComment", anyToken, comments, anyContext, RuleAction.StopProcessingSpaceActions), + rule("IgnoreAfterLineComment", SyntaxKind.SingleLineCommentTrivia, anyToken, anyContext, RuleAction.StopProcessingSpaceActions), - rule("NotSpaceBeforeColon", anyToken, SyntaxKind.ColonToken, [isNonJsxSameLineTokenContext, isNotBinaryOpContext, isNotTypeAnnotationContext], RuleAction.Delete), - rule("SpaceAfterColon", SyntaxKind.ColonToken, anyToken, [isNonJsxSameLineTokenContext, isNotBinaryOpContext], RuleAction.Space), - rule("NoSpaceBeforeQuestionMark", anyToken, SyntaxKind.QuestionToken, [isNonJsxSameLineTokenContext, isNotBinaryOpContext], RuleAction.Delete), + rule("NotSpaceBeforeColon", anyToken, SyntaxKind.ColonToken, [isNonJsxSameLineTokenContext, isNotBinaryOpContext, isNotTypeAnnotationContext], RuleAction.DeleteSpace), + rule("SpaceAfterColon", SyntaxKind.ColonToken, anyToken, [isNonJsxSameLineTokenContext, isNotBinaryOpContext], RuleAction.InsertSpace), + rule("NoSpaceBeforeQuestionMark", anyToken, SyntaxKind.QuestionToken, [isNonJsxSameLineTokenContext, isNotBinaryOpContext], RuleAction.DeleteSpace), // insert space after '?' only when it is used in conditional operator - rule("SpaceAfterQuestionMarkInConditionalOperator", SyntaxKind.QuestionToken, anyToken, [isNonJsxSameLineTokenContext, isConditionalOperatorContext], RuleAction.Space), + rule("SpaceAfterQuestionMarkInConditionalOperator", SyntaxKind.QuestionToken, anyToken, [isNonJsxSameLineTokenContext, isConditionalOperatorContext], RuleAction.InsertSpace), // in other cases there should be no space between '?' and next token - rule("NoSpaceAfterQuestionMark", SyntaxKind.QuestionToken, anyToken, [isNonJsxSameLineTokenContext], RuleAction.Delete), + rule("NoSpaceAfterQuestionMark", SyntaxKind.QuestionToken, anyToken, [isNonJsxSameLineTokenContext], RuleAction.DeleteSpace), - rule("NoSpaceBeforeDot", anyToken, SyntaxKind.DotToken, [isNonJsxSameLineTokenContext], RuleAction.Delete), - rule("NoSpaceAfterDot", SyntaxKind.DotToken, anyToken, [isNonJsxSameLineTokenContext], RuleAction.Delete), + rule("NoSpaceBeforeDot", anyToken, SyntaxKind.DotToken, [isNonJsxSameLineTokenContext], RuleAction.DeleteSpace), + rule("NoSpaceAfterDot", SyntaxKind.DotToken, anyToken, [isNonJsxSameLineTokenContext], RuleAction.DeleteSpace), - rule("NoSpaceBetweenImportParenInImportType", SyntaxKind.ImportKeyword, SyntaxKind.OpenParenToken, [isNonJsxSameLineTokenContext, isImportTypeContext], RuleAction.Delete), + rule("NoSpaceBetweenImportParenInImportType", SyntaxKind.ImportKeyword, SyntaxKind.OpenParenToken, [isNonJsxSameLineTokenContext, isImportTypeContext], RuleAction.DeleteSpace), // Special handling of unary operators. // Prefix operators generally shouldn't have a space between // them and their target unary expression. - rule("NoSpaceAfterUnaryPrefixOperator", unaryPrefixOperators, unaryPrefixExpressions, [isNonJsxSameLineTokenContext, isNotBinaryOpContext], RuleAction.Delete), - rule("NoSpaceAfterUnaryPreincrementOperator", SyntaxKind.PlusPlusToken, unaryPreincrementExpressions, [isNonJsxSameLineTokenContext], RuleAction.Delete), - rule("NoSpaceAfterUnaryPredecrementOperator", SyntaxKind.MinusMinusToken, unaryPredecrementExpressions, [isNonJsxSameLineTokenContext], RuleAction.Delete), - rule("NoSpaceBeforeUnaryPostincrementOperator", unaryPostincrementExpressions, SyntaxKind.PlusPlusToken, [isNonJsxSameLineTokenContext], RuleAction.Delete), - rule("NoSpaceBeforeUnaryPostdecrementOperator", unaryPostdecrementExpressions, SyntaxKind.MinusMinusToken, [isNonJsxSameLineTokenContext], RuleAction.Delete), + rule("NoSpaceAfterUnaryPrefixOperator", unaryPrefixOperators, unaryPrefixExpressions, [isNonJsxSameLineTokenContext, isNotBinaryOpContext], RuleAction.DeleteSpace), + rule("NoSpaceAfterUnaryPreincrementOperator", SyntaxKind.PlusPlusToken, unaryPreincrementExpressions, [isNonJsxSameLineTokenContext], RuleAction.DeleteSpace), + rule("NoSpaceAfterUnaryPredecrementOperator", SyntaxKind.MinusMinusToken, unaryPredecrementExpressions, [isNonJsxSameLineTokenContext], RuleAction.DeleteSpace), + rule("NoSpaceBeforeUnaryPostincrementOperator", unaryPostincrementExpressions, SyntaxKind.PlusPlusToken, [isNonJsxSameLineTokenContext], RuleAction.DeleteSpace), + rule("NoSpaceBeforeUnaryPostdecrementOperator", unaryPostdecrementExpressions, SyntaxKind.MinusMinusToken, [isNonJsxSameLineTokenContext], RuleAction.DeleteSpace), // More unary operator special-casing. // DevDiv 181814: Be careful when removing leading whitespace // around unary operators. Examples: // 1 - -2 --X--> 1--2 // a + ++b --X--> a+++b - rule("SpaceAfterPostincrementWhenFollowedByAdd", SyntaxKind.PlusPlusToken, SyntaxKind.PlusToken, [isNonJsxSameLineTokenContext, isBinaryOpContext], RuleAction.Space), - rule("SpaceAfterAddWhenFollowedByUnaryPlus", SyntaxKind.PlusToken, SyntaxKind.PlusToken, [isNonJsxSameLineTokenContext, isBinaryOpContext], RuleAction.Space), - rule("SpaceAfterAddWhenFollowedByPreincrement", SyntaxKind.PlusToken, SyntaxKind.PlusPlusToken, [isNonJsxSameLineTokenContext, isBinaryOpContext], RuleAction.Space), - rule("SpaceAfterPostdecrementWhenFollowedBySubtract", SyntaxKind.MinusMinusToken, SyntaxKind.MinusToken, [isNonJsxSameLineTokenContext, isBinaryOpContext], RuleAction.Space), - rule("SpaceAfterSubtractWhenFollowedByUnaryMinus", SyntaxKind.MinusToken, SyntaxKind.MinusToken, [isNonJsxSameLineTokenContext, isBinaryOpContext], RuleAction.Space), - rule("SpaceAfterSubtractWhenFollowedByPredecrement", SyntaxKind.MinusToken, SyntaxKind.MinusMinusToken, [isNonJsxSameLineTokenContext, isBinaryOpContext], RuleAction.Space), - - rule("NoSpaceAfterCloseBrace", SyntaxKind.CloseBraceToken, [SyntaxKind.CommaToken, SyntaxKind.SemicolonToken], [isNonJsxSameLineTokenContext], RuleAction.Delete), + rule("SpaceAfterPostincrementWhenFollowedByAdd", SyntaxKind.PlusPlusToken, SyntaxKind.PlusToken, [isNonJsxSameLineTokenContext, isBinaryOpContext], RuleAction.InsertSpace), + rule("SpaceAfterAddWhenFollowedByUnaryPlus", SyntaxKind.PlusToken, SyntaxKind.PlusToken, [isNonJsxSameLineTokenContext, isBinaryOpContext], RuleAction.InsertSpace), + rule("SpaceAfterAddWhenFollowedByPreincrement", SyntaxKind.PlusToken, SyntaxKind.PlusPlusToken, [isNonJsxSameLineTokenContext, isBinaryOpContext], RuleAction.InsertSpace), + rule("SpaceAfterPostdecrementWhenFollowedBySubtract", SyntaxKind.MinusMinusToken, SyntaxKind.MinusToken, [isNonJsxSameLineTokenContext, isBinaryOpContext], RuleAction.InsertSpace), + rule("SpaceAfterSubtractWhenFollowedByUnaryMinus", SyntaxKind.MinusToken, SyntaxKind.MinusToken, [isNonJsxSameLineTokenContext, isBinaryOpContext], RuleAction.InsertSpace), + rule("SpaceAfterSubtractWhenFollowedByPredecrement", SyntaxKind.MinusToken, SyntaxKind.MinusMinusToken, [isNonJsxSameLineTokenContext, isBinaryOpContext], RuleAction.InsertSpace), + + rule("NoSpaceAfterCloseBrace", SyntaxKind.CloseBraceToken, [SyntaxKind.CommaToken, SyntaxKind.SemicolonToken], [isNonJsxSameLineTokenContext], RuleAction.DeleteSpace), // For functions and control block place } on a new line [multi-line rule] - rule("NewLineBeforeCloseBraceInBlockContext", anyTokenIncludingMultilineComments, SyntaxKind.CloseBraceToken, [isMultilineBlockContext], RuleAction.NewLine), + rule("NewLineBeforeCloseBraceInBlockContext", anyTokenIncludingMultilineComments, SyntaxKind.CloseBraceToken, [isMultilineBlockContext], RuleAction.InsertNewLine), // Space/new line after }. - rule("SpaceAfterCloseBrace", SyntaxKind.CloseBraceToken, anyTokenExcept(SyntaxKind.CloseParenToken), [isNonJsxSameLineTokenContext, isAfterCodeBlockContext], RuleAction.Space), + rule("SpaceAfterCloseBrace", SyntaxKind.CloseBraceToken, anyTokenExcept(SyntaxKind.CloseParenToken), [isNonJsxSameLineTokenContext, isAfterCodeBlockContext], RuleAction.InsertSpace), // Special case for (}, else) and (}, while) since else & while tokens are not part of the tree which makes SpaceAfterCloseBrace rule not applied // Also should not apply to }) - rule("SpaceBetweenCloseBraceAndElse", SyntaxKind.CloseBraceToken, SyntaxKind.ElseKeyword, [isNonJsxSameLineTokenContext], RuleAction.Space), - rule("SpaceBetweenCloseBraceAndWhile", SyntaxKind.CloseBraceToken, SyntaxKind.WhileKeyword, [isNonJsxSameLineTokenContext], RuleAction.Space), - rule("NoSpaceBetweenEmptyBraceBrackets", SyntaxKind.OpenBraceToken, SyntaxKind.CloseBraceToken, [isNonJsxSameLineTokenContext, isObjectContext], RuleAction.Delete), + rule("SpaceBetweenCloseBraceAndElse", SyntaxKind.CloseBraceToken, SyntaxKind.ElseKeyword, [isNonJsxSameLineTokenContext], RuleAction.InsertSpace), + rule("SpaceBetweenCloseBraceAndWhile", SyntaxKind.CloseBraceToken, SyntaxKind.WhileKeyword, [isNonJsxSameLineTokenContext], RuleAction.InsertSpace), + rule("NoSpaceBetweenEmptyBraceBrackets", SyntaxKind.OpenBraceToken, SyntaxKind.CloseBraceToken, [isNonJsxSameLineTokenContext, isObjectContext], RuleAction.DeleteSpace), // Add a space after control dec context if the next character is an open bracket ex: 'if (false)[a, b] = [1, 2];' -> 'if (false) [a, b] = [1, 2];' - rule("SpaceAfterConditionalClosingParen", SyntaxKind.CloseParenToken, SyntaxKind.OpenBracketToken, [isControlDeclContext], RuleAction.Space), + rule("SpaceAfterConditionalClosingParen", SyntaxKind.CloseParenToken, SyntaxKind.OpenBracketToken, [isControlDeclContext], RuleAction.InsertSpace), - rule("NoSpaceBetweenFunctionKeywordAndStar", SyntaxKind.FunctionKeyword, SyntaxKind.AsteriskToken, [isFunctionDeclarationOrFunctionExpressionContext], RuleAction.Delete), - rule("SpaceAfterStarInGeneratorDeclaration", SyntaxKind.AsteriskToken, SyntaxKind.Identifier, [isFunctionDeclarationOrFunctionExpressionContext], RuleAction.Space), + rule("NoSpaceBetweenFunctionKeywordAndStar", SyntaxKind.FunctionKeyword, SyntaxKind.AsteriskToken, [isFunctionDeclarationOrFunctionExpressionContext], RuleAction.DeleteSpace), + rule("SpaceAfterStarInGeneratorDeclaration", SyntaxKind.AsteriskToken, SyntaxKind.Identifier, [isFunctionDeclarationOrFunctionExpressionContext], RuleAction.InsertSpace), - rule("SpaceAfterFunctionInFuncDecl", SyntaxKind.FunctionKeyword, anyToken, [isFunctionDeclContext], RuleAction.Space), + rule("SpaceAfterFunctionInFuncDecl", SyntaxKind.FunctionKeyword, anyToken, [isFunctionDeclContext], RuleAction.InsertSpace), // Insert new line after { and before } in multi-line contexts. - rule("NewLineAfterOpenBraceInBlockContext", SyntaxKind.OpenBraceToken, anyToken, [isMultilineBlockContext], RuleAction.NewLine), + rule("NewLineAfterOpenBraceInBlockContext", SyntaxKind.OpenBraceToken, anyToken, [isMultilineBlockContext], RuleAction.InsertNewLine), // For get/set members, we check for (identifier,identifier) since get/set don't have tokens and they are represented as just an identifier token. // Though, we do extra check on the context to make sure we are dealing with get/set node. Example: // get x() {} // set x(val) {} - rule("SpaceAfterGetSetInMember", [SyntaxKind.GetKeyword, SyntaxKind.SetKeyword], SyntaxKind.Identifier, [isFunctionDeclContext], RuleAction.Space), + rule("SpaceAfterGetSetInMember", [SyntaxKind.GetKeyword, SyntaxKind.SetKeyword], SyntaxKind.Identifier, [isFunctionDeclContext], RuleAction.InsertSpace), - rule("NoSpaceBetweenYieldKeywordAndStar", SyntaxKind.YieldKeyword, SyntaxKind.AsteriskToken, [isNonJsxSameLineTokenContext, isYieldOrYieldStarWithOperand], RuleAction.Delete), - rule("SpaceBetweenYieldOrYieldStarAndOperand", [SyntaxKind.YieldKeyword, SyntaxKind.AsteriskToken], anyToken, [isNonJsxSameLineTokenContext, isYieldOrYieldStarWithOperand], RuleAction.Space), + rule("NoSpaceBetweenYieldKeywordAndStar", SyntaxKind.YieldKeyword, SyntaxKind.AsteriskToken, [isNonJsxSameLineTokenContext, isYieldOrYieldStarWithOperand], RuleAction.DeleteSpace), + rule("SpaceBetweenYieldOrYieldStarAndOperand", [SyntaxKind.YieldKeyword, SyntaxKind.AsteriskToken], anyToken, [isNonJsxSameLineTokenContext, isYieldOrYieldStarWithOperand], RuleAction.InsertSpace), - rule("NoSpaceBetweenReturnAndSemicolon", SyntaxKind.ReturnKeyword, SyntaxKind.SemicolonToken, [isNonJsxSameLineTokenContext], RuleAction.Delete), - rule("SpaceAfterCertainKeywords", [SyntaxKind.VarKeyword, SyntaxKind.ThrowKeyword, SyntaxKind.NewKeyword, SyntaxKind.DeleteKeyword, SyntaxKind.ReturnKeyword, SyntaxKind.TypeOfKeyword, SyntaxKind.AwaitKeyword], anyToken, [isNonJsxSameLineTokenContext], RuleAction.Space), - rule("SpaceAfterLetConstInVariableDeclaration", [SyntaxKind.LetKeyword, SyntaxKind.ConstKeyword], anyToken, [isNonJsxSameLineTokenContext, isStartOfVariableDeclarationList], RuleAction.Space), - rule("NoSpaceBeforeOpenParenInFuncCall", anyToken, SyntaxKind.OpenParenToken, [isNonJsxSameLineTokenContext, isFunctionCallOrNewContext, isPreviousTokenNotComma], RuleAction.Delete), + rule("NoSpaceBetweenReturnAndSemicolon", SyntaxKind.ReturnKeyword, SyntaxKind.SemicolonToken, [isNonJsxSameLineTokenContext], RuleAction.DeleteSpace), + rule("SpaceAfterCertainKeywords", [SyntaxKind.VarKeyword, SyntaxKind.ThrowKeyword, SyntaxKind.NewKeyword, SyntaxKind.DeleteKeyword, SyntaxKind.ReturnKeyword, SyntaxKind.TypeOfKeyword, SyntaxKind.AwaitKeyword], anyToken, [isNonJsxSameLineTokenContext], RuleAction.InsertSpace), + rule("SpaceAfterLetConstInVariableDeclaration", [SyntaxKind.LetKeyword, SyntaxKind.ConstKeyword], anyToken, [isNonJsxSameLineTokenContext, isStartOfVariableDeclarationList], RuleAction.InsertSpace), + rule("NoSpaceBeforeOpenParenInFuncCall", anyToken, SyntaxKind.OpenParenToken, [isNonJsxSameLineTokenContext, isFunctionCallOrNewContext, isPreviousTokenNotComma], RuleAction.DeleteSpace), // Special case for binary operators (that are keywords). For these we have to add a space and shouldn't follow any user options. - rule("SpaceBeforeBinaryKeywordOperator", anyToken, binaryKeywordOperators, [isNonJsxSameLineTokenContext, isBinaryOpContext], RuleAction.Space), - rule("SpaceAfterBinaryKeywordOperator", binaryKeywordOperators, anyToken, [isNonJsxSameLineTokenContext, isBinaryOpContext], RuleAction.Space), + rule("SpaceBeforeBinaryKeywordOperator", anyToken, binaryKeywordOperators, [isNonJsxSameLineTokenContext, isBinaryOpContext], RuleAction.InsertSpace), + rule("SpaceAfterBinaryKeywordOperator", binaryKeywordOperators, anyToken, [isNonJsxSameLineTokenContext, isBinaryOpContext], RuleAction.InsertSpace), - rule("SpaceAfterVoidOperator", SyntaxKind.VoidKeyword, anyToken, [isNonJsxSameLineTokenContext, isVoidOpContext], RuleAction.Space), + rule("SpaceAfterVoidOperator", SyntaxKind.VoidKeyword, anyToken, [isNonJsxSameLineTokenContext, isVoidOpContext], RuleAction.InsertSpace), // Async-await - rule("SpaceBetweenAsyncAndOpenParen", SyntaxKind.AsyncKeyword, SyntaxKind.OpenParenToken, [isArrowFunctionContext, isNonJsxSameLineTokenContext], RuleAction.Space), - rule("SpaceBetweenAsyncAndFunctionKeyword", SyntaxKind.AsyncKeyword, SyntaxKind.FunctionKeyword, [isNonJsxSameLineTokenContext], RuleAction.Space), + rule("SpaceBetweenAsyncAndOpenParen", SyntaxKind.AsyncKeyword, SyntaxKind.OpenParenToken, [isArrowFunctionContext, isNonJsxSameLineTokenContext], RuleAction.InsertSpace), + rule("SpaceBetweenAsyncAndFunctionKeyword", SyntaxKind.AsyncKeyword, SyntaxKind.FunctionKeyword, [isNonJsxSameLineTokenContext], RuleAction.InsertSpace), // Template string - rule("NoSpaceBetweenTagAndTemplateString", [SyntaxKind.Identifier, SyntaxKind.CloseParenToken], [SyntaxKind.NoSubstitutionTemplateLiteral, SyntaxKind.TemplateHead], [isNonJsxSameLineTokenContext], RuleAction.Delete), + rule("NoSpaceBetweenTagAndTemplateString", [SyntaxKind.Identifier, SyntaxKind.CloseParenToken], [SyntaxKind.NoSubstitutionTemplateLiteral, SyntaxKind.TemplateHead], [isNonJsxSameLineTokenContext], RuleAction.DeleteSpace), // JSX opening elements - rule("SpaceBeforeJsxAttribute", anyToken, SyntaxKind.Identifier, [isNextTokenParentJsxAttribute, isNonJsxSameLineTokenContext], RuleAction.Space), - rule("SpaceBeforeSlashInJsxOpeningElement", anyToken, SyntaxKind.SlashToken, [isJsxSelfClosingElementContext, isNonJsxSameLineTokenContext], RuleAction.Space), - rule("NoSpaceBeforeGreaterThanTokenInJsxOpeningElement", SyntaxKind.SlashToken, SyntaxKind.GreaterThanToken, [isJsxSelfClosingElementContext, isNonJsxSameLineTokenContext], RuleAction.Delete), - rule("NoSpaceBeforeEqualInJsxAttribute", anyToken, SyntaxKind.EqualsToken, [isJsxAttributeContext, isNonJsxSameLineTokenContext], RuleAction.Delete), - rule("NoSpaceAfterEqualInJsxAttribute", SyntaxKind.EqualsToken, anyToken, [isJsxAttributeContext, isNonJsxSameLineTokenContext], RuleAction.Delete), + rule("SpaceBeforeJsxAttribute", anyToken, SyntaxKind.Identifier, [isNextTokenParentJsxAttribute, isNonJsxSameLineTokenContext], RuleAction.InsertSpace), + rule("SpaceBeforeSlashInJsxOpeningElement", anyToken, SyntaxKind.SlashToken, [isJsxSelfClosingElementContext, isNonJsxSameLineTokenContext], RuleAction.InsertSpace), + rule("NoSpaceBeforeGreaterThanTokenInJsxOpeningElement", SyntaxKind.SlashToken, SyntaxKind.GreaterThanToken, [isJsxSelfClosingElementContext, isNonJsxSameLineTokenContext], RuleAction.DeleteSpace), + rule("NoSpaceBeforeEqualInJsxAttribute", anyToken, SyntaxKind.EqualsToken, [isJsxAttributeContext, isNonJsxSameLineTokenContext], RuleAction.DeleteSpace), + rule("NoSpaceAfterEqualInJsxAttribute", SyntaxKind.EqualsToken, anyToken, [isJsxAttributeContext, isNonJsxSameLineTokenContext], RuleAction.DeleteSpace), // TypeScript-specific rules // Use of module as a function call. e.g.: import m2 = module("m2"); - rule("NoSpaceAfterModuleImport", [SyntaxKind.ModuleKeyword, SyntaxKind.RequireKeyword], SyntaxKind.OpenParenToken, [isNonJsxSameLineTokenContext], RuleAction.Delete), + rule("NoSpaceAfterModuleImport", [SyntaxKind.ModuleKeyword, SyntaxKind.RequireKeyword], SyntaxKind.OpenParenToken, [isNonJsxSameLineTokenContext], RuleAction.DeleteSpace), // Add a space around certain TypeScript keywords rule( "SpaceAfterCertainTypeScriptKeywords", @@ -171,41 +174,41 @@ namespace ts.formatting { ], anyToken, [isNonJsxSameLineTokenContext], - RuleAction.Space), + RuleAction.InsertSpace), rule( "SpaceBeforeCertainTypeScriptKeywords", anyToken, [SyntaxKind.ExtendsKeyword, SyntaxKind.ImplementsKeyword, SyntaxKind.FromKeyword], [isNonJsxSameLineTokenContext], - RuleAction.Space), + RuleAction.InsertSpace), // Treat string literals in module names as identifiers, and add a space between the literal and the opening Brace braces, e.g.: module "m2" { - rule("SpaceAfterModuleName", SyntaxKind.StringLiteral, SyntaxKind.OpenBraceToken, [isModuleDeclContext], RuleAction.Space), + rule("SpaceAfterModuleName", SyntaxKind.StringLiteral, SyntaxKind.OpenBraceToken, [isModuleDeclContext], RuleAction.InsertSpace), // Lambda expressions - rule("SpaceBeforeArrow", anyToken, SyntaxKind.EqualsGreaterThanToken, [isNonJsxSameLineTokenContext], RuleAction.Space), - rule("SpaceAfterArrow", SyntaxKind.EqualsGreaterThanToken, anyToken, [isNonJsxSameLineTokenContext], RuleAction.Space), + rule("SpaceBeforeArrow", anyToken, SyntaxKind.EqualsGreaterThanToken, [isNonJsxSameLineTokenContext], RuleAction.InsertSpace), + rule("SpaceAfterArrow", SyntaxKind.EqualsGreaterThanToken, anyToken, [isNonJsxSameLineTokenContext], RuleAction.InsertSpace), // Optional parameters and let args - rule("NoSpaceAfterEllipsis", SyntaxKind.DotDotDotToken, SyntaxKind.Identifier, [isNonJsxSameLineTokenContext], RuleAction.Delete), - rule("NoSpaceAfterOptionalParameters", SyntaxKind.QuestionToken, [SyntaxKind.CloseParenToken, SyntaxKind.CommaToken], [isNonJsxSameLineTokenContext, isNotBinaryOpContext], RuleAction.Delete), + rule("NoSpaceAfterEllipsis", SyntaxKind.DotDotDotToken, SyntaxKind.Identifier, [isNonJsxSameLineTokenContext], RuleAction.DeleteSpace), + rule("NoSpaceAfterOptionalParameters", SyntaxKind.QuestionToken, [SyntaxKind.CloseParenToken, SyntaxKind.CommaToken], [isNonJsxSameLineTokenContext, isNotBinaryOpContext], RuleAction.DeleteSpace), // Remove spaces in empty interface literals. e.g.: x: {} - rule("NoSpaceBetweenEmptyInterfaceBraceBrackets", SyntaxKind.OpenBraceToken, SyntaxKind.CloseBraceToken, [isNonJsxSameLineTokenContext, isObjectTypeContext], RuleAction.Delete), + rule("NoSpaceBetweenEmptyInterfaceBraceBrackets", SyntaxKind.OpenBraceToken, SyntaxKind.CloseBraceToken, [isNonJsxSameLineTokenContext, isObjectTypeContext], RuleAction.DeleteSpace), // generics and type assertions - rule("NoSpaceBeforeOpenAngularBracket", typeNames, SyntaxKind.LessThanToken, [isNonJsxSameLineTokenContext, isTypeArgumentOrParameterOrAssertionContext], RuleAction.Delete), - rule("NoSpaceBetweenCloseParenAndAngularBracket", SyntaxKind.CloseParenToken, SyntaxKind.LessThanToken, [isNonJsxSameLineTokenContext, isTypeArgumentOrParameterOrAssertionContext], RuleAction.Delete), - rule("NoSpaceAfterOpenAngularBracket", SyntaxKind.LessThanToken, anyToken, [isNonJsxSameLineTokenContext, isTypeArgumentOrParameterOrAssertionContext], RuleAction.Delete), - rule("NoSpaceBeforeCloseAngularBracket", anyToken, SyntaxKind.GreaterThanToken, [isNonJsxSameLineTokenContext, isTypeArgumentOrParameterOrAssertionContext], RuleAction.Delete), + rule("NoSpaceBeforeOpenAngularBracket", typeNames, SyntaxKind.LessThanToken, [isNonJsxSameLineTokenContext, isTypeArgumentOrParameterOrAssertionContext], RuleAction.DeleteSpace), + rule("NoSpaceBetweenCloseParenAndAngularBracket", SyntaxKind.CloseParenToken, SyntaxKind.LessThanToken, [isNonJsxSameLineTokenContext, isTypeArgumentOrParameterOrAssertionContext], RuleAction.DeleteSpace), + rule("NoSpaceAfterOpenAngularBracket", SyntaxKind.LessThanToken, anyToken, [isNonJsxSameLineTokenContext, isTypeArgumentOrParameterOrAssertionContext], RuleAction.DeleteSpace), + rule("NoSpaceBeforeCloseAngularBracket", anyToken, SyntaxKind.GreaterThanToken, [isNonJsxSameLineTokenContext, isTypeArgumentOrParameterOrAssertionContext], RuleAction.DeleteSpace), rule("NoSpaceAfterCloseAngularBracket", SyntaxKind.GreaterThanToken, [SyntaxKind.OpenParenToken, SyntaxKind.OpenBracketToken, SyntaxKind.GreaterThanToken, SyntaxKind.CommaToken], [isNonJsxSameLineTokenContext, isTypeArgumentOrParameterOrAssertionContext, isNotFunctionDeclContext /*To prevent an interference with the SpaceBeforeOpenParenInFuncDecl rule*/], - RuleAction.Delete), + RuleAction.DeleteSpace), // decorators - rule("SpaceBeforeAt", [SyntaxKind.CloseParenToken, SyntaxKind.Identifier], SyntaxKind.AtToken, [isNonJsxSameLineTokenContext], RuleAction.Space), - rule("NoSpaceAfterAt", SyntaxKind.AtToken, anyToken, [isNonJsxSameLineTokenContext], RuleAction.Delete), + rule("SpaceBeforeAt", [SyntaxKind.CloseParenToken, SyntaxKind.Identifier], SyntaxKind.AtToken, [isNonJsxSameLineTokenContext], RuleAction.InsertSpace), + rule("NoSpaceAfterAt", SyntaxKind.AtToken, anyToken, [isNonJsxSameLineTokenContext], RuleAction.DeleteSpace), // Insert space after @ in decorator rule("SpaceAfterDecorator", anyToken, @@ -225,111 +228,113 @@ namespace ts.formatting { SyntaxKind.AsteriskToken, ], [isEndOfDecoratorContextOnSameLine], - RuleAction.Space), + RuleAction.InsertSpace), - rule("NoSpaceBeforeNonNullAssertionOperator", anyToken, SyntaxKind.ExclamationToken, [isNonJsxSameLineTokenContext, isNonNullAssertionContext], RuleAction.Delete), - rule("NoSpaceAfterNewKeywordOnConstructorSignature", SyntaxKind.NewKeyword, SyntaxKind.OpenParenToken, [isNonJsxSameLineTokenContext, isConstructorSignatureContext], RuleAction.Delete), - rule("SpaceLessThanAndNonJSXTypeAnnotation", SyntaxKind.LessThanToken, SyntaxKind.LessThanToken, [isNonJsxSameLineTokenContext], RuleAction.Space), + rule("NoSpaceBeforeNonNullAssertionOperator", anyToken, SyntaxKind.ExclamationToken, [isNonJsxSameLineTokenContext, isNonNullAssertionContext], RuleAction.DeleteSpace), + rule("NoSpaceAfterNewKeywordOnConstructorSignature", SyntaxKind.NewKeyword, SyntaxKind.OpenParenToken, [isNonJsxSameLineTokenContext, isConstructorSignatureContext], RuleAction.DeleteSpace), + rule("SpaceLessThanAndNonJSXTypeAnnotation", SyntaxKind.LessThanToken, SyntaxKind.LessThanToken, [isNonJsxSameLineTokenContext], RuleAction.InsertSpace), ]; // These rules are applied after high priority const userConfigurableRules = [ // Treat constructor as an identifier in a function declaration, and remove spaces between constructor and following left parentheses - rule("SpaceAfterConstructor", SyntaxKind.ConstructorKeyword, SyntaxKind.OpenParenToken, [isOptionEnabled("insertSpaceAfterConstructor"), isNonJsxSameLineTokenContext], RuleAction.Space), - rule("NoSpaceAfterConstructor", SyntaxKind.ConstructorKeyword, SyntaxKind.OpenParenToken, [isOptionDisabledOrUndefined("insertSpaceAfterConstructor"), isNonJsxSameLineTokenContext], RuleAction.Delete), + rule("SpaceAfterConstructor", SyntaxKind.ConstructorKeyword, SyntaxKind.OpenParenToken, [isOptionEnabled("insertSpaceAfterConstructor"), isNonJsxSameLineTokenContext], RuleAction.InsertSpace), + rule("NoSpaceAfterConstructor", SyntaxKind.ConstructorKeyword, SyntaxKind.OpenParenToken, [isOptionDisabledOrUndefined("insertSpaceAfterConstructor"), isNonJsxSameLineTokenContext], RuleAction.DeleteSpace), - rule("SpaceAfterComma", SyntaxKind.CommaToken, anyToken, [isOptionEnabled("insertSpaceAfterCommaDelimiter"), isNonJsxSameLineTokenContext, isNonJsxElementOrFragmentContext, isNextTokenNotCloseBracket], RuleAction.Space), - rule("NoSpaceAfterComma", SyntaxKind.CommaToken, anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterCommaDelimiter"), isNonJsxSameLineTokenContext, isNonJsxElementOrFragmentContext], RuleAction.Delete), + rule("SpaceAfterComma", SyntaxKind.CommaToken, anyToken, [isOptionEnabled("insertSpaceAfterCommaDelimiter"), isNonJsxSameLineTokenContext, isNonJsxElementOrFragmentContext, isNextTokenNotCloseBracket], RuleAction.InsertSpace), + rule("NoSpaceAfterComma", SyntaxKind.CommaToken, anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterCommaDelimiter"), isNonJsxSameLineTokenContext, isNonJsxElementOrFragmentContext], RuleAction.DeleteSpace), // Insert space after function keyword for anonymous functions - rule("SpaceAfterAnonymousFunctionKeyword", [SyntaxKind.FunctionKeyword, SyntaxKind.AsteriskToken], SyntaxKind.OpenParenToken, [isOptionEnabled("insertSpaceAfterFunctionKeywordForAnonymousFunctions"), isFunctionDeclContext], RuleAction.Space), - rule("NoSpaceAfterAnonymousFunctionKeyword", [SyntaxKind.FunctionKeyword, SyntaxKind.AsteriskToken], SyntaxKind.OpenParenToken, [isOptionDisabledOrUndefined("insertSpaceAfterFunctionKeywordForAnonymousFunctions"), isFunctionDeclContext], RuleAction.Delete), + rule("SpaceAfterAnonymousFunctionKeyword", [SyntaxKind.FunctionKeyword, SyntaxKind.AsteriskToken], SyntaxKind.OpenParenToken, [isOptionEnabled("insertSpaceAfterFunctionKeywordForAnonymousFunctions"), isFunctionDeclContext], RuleAction.InsertSpace), + rule("NoSpaceAfterAnonymousFunctionKeyword", [SyntaxKind.FunctionKeyword, SyntaxKind.AsteriskToken], SyntaxKind.OpenParenToken, [isOptionDisabledOrUndefined("insertSpaceAfterFunctionKeywordForAnonymousFunctions"), isFunctionDeclContext], RuleAction.DeleteSpace), // Insert space after keywords in control flow statements - rule("SpaceAfterKeywordInControl", keywords, SyntaxKind.OpenParenToken, [isOptionEnabled("insertSpaceAfterKeywordsInControlFlowStatements"), isControlDeclContext], RuleAction.Space), - rule("NoSpaceAfterKeywordInControl", keywords, SyntaxKind.OpenParenToken, [isOptionDisabledOrUndefined("insertSpaceAfterKeywordsInControlFlowStatements"), isControlDeclContext], RuleAction.Delete), + rule("SpaceAfterKeywordInControl", keywords, SyntaxKind.OpenParenToken, [isOptionEnabled("insertSpaceAfterKeywordsInControlFlowStatements"), isControlDeclContext], RuleAction.InsertSpace), + rule("NoSpaceAfterKeywordInControl", keywords, SyntaxKind.OpenParenToken, [isOptionDisabledOrUndefined("insertSpaceAfterKeywordsInControlFlowStatements"), isControlDeclContext], RuleAction.DeleteSpace), // Insert space after opening and before closing nonempty parenthesis - rule("SpaceAfterOpenParen", SyntaxKind.OpenParenToken, anyToken, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis"), isNonJsxSameLineTokenContext], RuleAction.Space), - rule("SpaceBeforeCloseParen", anyToken, SyntaxKind.CloseParenToken, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis"), isNonJsxSameLineTokenContext], RuleAction.Space), - rule("SpaceBetweenOpenParens", SyntaxKind.OpenParenToken, SyntaxKind.OpenParenToken, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis"), isNonJsxSameLineTokenContext], RuleAction.Space), - rule("NoSpaceBetweenParens", SyntaxKind.OpenParenToken, SyntaxKind.CloseParenToken, [isNonJsxSameLineTokenContext], RuleAction.Delete), - rule("NoSpaceAfterOpenParen", SyntaxKind.OpenParenToken, anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis"), isNonJsxSameLineTokenContext], RuleAction.Delete), - rule("NoSpaceBeforeCloseParen", anyToken, SyntaxKind.CloseParenToken, [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis"), isNonJsxSameLineTokenContext], RuleAction.Delete), + rule("SpaceAfterOpenParen", SyntaxKind.OpenParenToken, anyToken, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis"), isNonJsxSameLineTokenContext], RuleAction.InsertSpace), + rule("SpaceBeforeCloseParen", anyToken, SyntaxKind.CloseParenToken, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis"), isNonJsxSameLineTokenContext], RuleAction.InsertSpace), + rule("SpaceBetweenOpenParens", SyntaxKind.OpenParenToken, SyntaxKind.OpenParenToken, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis"), isNonJsxSameLineTokenContext], RuleAction.InsertSpace), + rule("NoSpaceBetweenParens", SyntaxKind.OpenParenToken, SyntaxKind.CloseParenToken, [isNonJsxSameLineTokenContext], RuleAction.DeleteSpace), + rule("NoSpaceAfterOpenParen", SyntaxKind.OpenParenToken, anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis"), isNonJsxSameLineTokenContext], RuleAction.DeleteSpace), + rule("NoSpaceBeforeCloseParen", anyToken, SyntaxKind.CloseParenToken, [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis"), isNonJsxSameLineTokenContext], RuleAction.DeleteSpace), // Insert space after opening and before closing nonempty brackets - rule("SpaceAfterOpenBracket", SyntaxKind.OpenBracketToken, anyToken, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets"), isNonJsxSameLineTokenContext], RuleAction.Space), - rule("SpaceBeforeCloseBracket", anyToken, SyntaxKind.CloseBracketToken, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets"), isNonJsxSameLineTokenContext], RuleAction.Space), - rule("NoSpaceBetweenBrackets", SyntaxKind.OpenBracketToken, SyntaxKind.CloseBracketToken, [isNonJsxSameLineTokenContext], RuleAction.Delete), - rule("NoSpaceAfterOpenBracket", SyntaxKind.OpenBracketToken, anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets"), isNonJsxSameLineTokenContext], RuleAction.Delete), - rule("NoSpaceBeforeCloseBracket", anyToken, SyntaxKind.CloseBracketToken, [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets"), isNonJsxSameLineTokenContext], RuleAction.Delete), + rule("SpaceAfterOpenBracket", SyntaxKind.OpenBracketToken, anyToken, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets"), isNonJsxSameLineTokenContext], RuleAction.InsertSpace), + rule("SpaceBeforeCloseBracket", anyToken, SyntaxKind.CloseBracketToken, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets"), isNonJsxSameLineTokenContext], RuleAction.InsertSpace), + rule("NoSpaceBetweenBrackets", SyntaxKind.OpenBracketToken, SyntaxKind.CloseBracketToken, [isNonJsxSameLineTokenContext], RuleAction.DeleteSpace), + rule("NoSpaceAfterOpenBracket", SyntaxKind.OpenBracketToken, anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets"), isNonJsxSameLineTokenContext], RuleAction.DeleteSpace), + rule("NoSpaceBeforeCloseBracket", anyToken, SyntaxKind.CloseBracketToken, [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets"), isNonJsxSameLineTokenContext], RuleAction.DeleteSpace), // Insert a space after { and before } in single-line contexts, but remove space from empty object literals {}. - rule("SpaceAfterOpenBrace", SyntaxKind.OpenBraceToken, anyToken, [isOptionEnabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces"), isBraceWrappedContext], RuleAction.Space), - rule("SpaceBeforeCloseBrace", anyToken, SyntaxKind.CloseBraceToken, [isOptionEnabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces"), isBraceWrappedContext], RuleAction.Space), - rule("NoSpaceBetweenEmptyBraceBrackets", SyntaxKind.OpenBraceToken, SyntaxKind.CloseBraceToken, [isNonJsxSameLineTokenContext, isObjectContext], RuleAction.Delete), - rule("NoSpaceAfterOpenBrace", SyntaxKind.OpenBraceToken, anyToken, [isOptionDisabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces"), isNonJsxSameLineTokenContext], RuleAction.Delete), - rule("NoSpaceBeforeCloseBrace", anyToken, SyntaxKind.CloseBraceToken, [isOptionDisabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces"), isNonJsxSameLineTokenContext], RuleAction.Delete), + rule("SpaceAfterOpenBrace", SyntaxKind.OpenBraceToken, anyToken, [isOptionEnabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces"), isBraceWrappedContext], RuleAction.InsertSpace), + rule("SpaceBeforeCloseBrace", anyToken, SyntaxKind.CloseBraceToken, [isOptionEnabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces"), isBraceWrappedContext], RuleAction.InsertSpace), + rule("NoSpaceBetweenEmptyBraceBrackets", SyntaxKind.OpenBraceToken, SyntaxKind.CloseBraceToken, [isNonJsxSameLineTokenContext, isObjectContext], RuleAction.DeleteSpace), + rule("NoSpaceAfterOpenBrace", SyntaxKind.OpenBraceToken, anyToken, [isOptionDisabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces"), isNonJsxSameLineTokenContext], RuleAction.DeleteSpace), + rule("NoSpaceBeforeCloseBrace", anyToken, SyntaxKind.CloseBraceToken, [isOptionDisabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces"), isNonJsxSameLineTokenContext], RuleAction.DeleteSpace), // Insert space after opening and before closing template string braces - rule("SpaceAfterTemplateHeadAndMiddle", [SyntaxKind.TemplateHead, SyntaxKind.TemplateMiddle], anyToken, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces"), isNonJsxSameLineTokenContext], RuleAction.Space), - rule("SpaceBeforeTemplateMiddleAndTail", anyToken, [SyntaxKind.TemplateMiddle, SyntaxKind.TemplateTail], [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces"), isNonJsxSameLineTokenContext], RuleAction.Space), - rule("NoSpaceAfterTemplateHeadAndMiddle", [SyntaxKind.TemplateHead, SyntaxKind.TemplateMiddle], anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces"), isNonJsxSameLineTokenContext], RuleAction.Delete), - rule("NoSpaceBeforeTemplateMiddleAndTail", anyToken, [SyntaxKind.TemplateMiddle, SyntaxKind.TemplateTail], [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces"), isNonJsxSameLineTokenContext], RuleAction.Delete), + rule("SpaceAfterTemplateHeadAndMiddle", [SyntaxKind.TemplateHead, SyntaxKind.TemplateMiddle], anyToken, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces"), isNonJsxSameLineTokenContext], RuleAction.InsertSpace), + rule("SpaceBeforeTemplateMiddleAndTail", anyToken, [SyntaxKind.TemplateMiddle, SyntaxKind.TemplateTail], [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces"), isNonJsxSameLineTokenContext], RuleAction.InsertSpace), + rule("NoSpaceAfterTemplateHeadAndMiddle", [SyntaxKind.TemplateHead, SyntaxKind.TemplateMiddle], anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces"), isNonJsxSameLineTokenContext], RuleAction.DeleteSpace), + rule("NoSpaceBeforeTemplateMiddleAndTail", anyToken, [SyntaxKind.TemplateMiddle, SyntaxKind.TemplateTail], [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces"), isNonJsxSameLineTokenContext], RuleAction.DeleteSpace), // No space after { and before } in JSX expression - rule("SpaceAfterOpenBraceInJsxExpression", SyntaxKind.OpenBraceToken, anyToken, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces"), isNonJsxSameLineTokenContext, isJsxExpressionContext], RuleAction.Space), - rule("SpaceBeforeCloseBraceInJsxExpression", anyToken, SyntaxKind.CloseBraceToken, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces"), isNonJsxSameLineTokenContext, isJsxExpressionContext], RuleAction.Space), - rule("NoSpaceAfterOpenBraceInJsxExpression", SyntaxKind.OpenBraceToken, anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces"), isNonJsxSameLineTokenContext, isJsxExpressionContext], RuleAction.Delete), - rule("NoSpaceBeforeCloseBraceInJsxExpression", anyToken, SyntaxKind.CloseBraceToken, [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces"), isNonJsxSameLineTokenContext, isJsxExpressionContext], RuleAction.Delete), + rule("SpaceAfterOpenBraceInJsxExpression", SyntaxKind.OpenBraceToken, anyToken, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces"), isNonJsxSameLineTokenContext, isJsxExpressionContext], RuleAction.InsertSpace), + rule("SpaceBeforeCloseBraceInJsxExpression", anyToken, SyntaxKind.CloseBraceToken, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces"), isNonJsxSameLineTokenContext, isJsxExpressionContext], RuleAction.InsertSpace), + rule("NoSpaceAfterOpenBraceInJsxExpression", SyntaxKind.OpenBraceToken, anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces"), isNonJsxSameLineTokenContext, isJsxExpressionContext], RuleAction.DeleteSpace), + rule("NoSpaceBeforeCloseBraceInJsxExpression", anyToken, SyntaxKind.CloseBraceToken, [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces"), isNonJsxSameLineTokenContext, isJsxExpressionContext], RuleAction.DeleteSpace), // Insert space after semicolon in for statement - rule("SpaceAfterSemicolonInFor", SyntaxKind.SemicolonToken, anyToken, [isOptionEnabled("insertSpaceAfterSemicolonInForStatements"), isNonJsxSameLineTokenContext, isForContext], RuleAction.Space), - rule("NoSpaceAfterSemicolonInFor", SyntaxKind.SemicolonToken, anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterSemicolonInForStatements"), isNonJsxSameLineTokenContext, isForContext], RuleAction.Delete), + rule("SpaceAfterSemicolonInFor", SyntaxKind.SemicolonToken, anyToken, [isOptionEnabled("insertSpaceAfterSemicolonInForStatements"), isNonJsxSameLineTokenContext, isForContext], RuleAction.InsertSpace), + rule("NoSpaceAfterSemicolonInFor", SyntaxKind.SemicolonToken, anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterSemicolonInForStatements"), isNonJsxSameLineTokenContext, isForContext], RuleAction.DeleteSpace), // Insert space before and after binary operators - rule("SpaceBeforeBinaryOperator", anyToken, binaryOperators, [isOptionEnabled("insertSpaceBeforeAndAfterBinaryOperators"), isNonJsxSameLineTokenContext, isBinaryOpContext], RuleAction.Space), - rule("SpaceAfterBinaryOperator", binaryOperators, anyToken, [isOptionEnabled("insertSpaceBeforeAndAfterBinaryOperators"), isNonJsxSameLineTokenContext, isBinaryOpContext], RuleAction.Space), - rule("NoSpaceBeforeBinaryOperator", anyToken, binaryOperators, [isOptionDisabledOrUndefined("insertSpaceBeforeAndAfterBinaryOperators"), isNonJsxSameLineTokenContext, isBinaryOpContext], RuleAction.Delete), - rule("NoSpaceAfterBinaryOperator", binaryOperators, anyToken, [isOptionDisabledOrUndefined("insertSpaceBeforeAndAfterBinaryOperators"), isNonJsxSameLineTokenContext, isBinaryOpContext], RuleAction.Delete), + rule("SpaceBeforeBinaryOperator", anyToken, binaryOperators, [isOptionEnabled("insertSpaceBeforeAndAfterBinaryOperators"), isNonJsxSameLineTokenContext, isBinaryOpContext], RuleAction.InsertSpace), + rule("SpaceAfterBinaryOperator", binaryOperators, anyToken, [isOptionEnabled("insertSpaceBeforeAndAfterBinaryOperators"), isNonJsxSameLineTokenContext, isBinaryOpContext], RuleAction.InsertSpace), + rule("NoSpaceBeforeBinaryOperator", anyToken, binaryOperators, [isOptionDisabledOrUndefined("insertSpaceBeforeAndAfterBinaryOperators"), isNonJsxSameLineTokenContext, isBinaryOpContext], RuleAction.DeleteSpace), + rule("NoSpaceAfterBinaryOperator", binaryOperators, anyToken, [isOptionDisabledOrUndefined("insertSpaceBeforeAndAfterBinaryOperators"), isNonJsxSameLineTokenContext, isBinaryOpContext], RuleAction.DeleteSpace), - rule("SpaceBeforeOpenParenInFuncDecl", anyToken, SyntaxKind.OpenParenToken, [isOptionEnabled("insertSpaceBeforeFunctionParenthesis"), isNonJsxSameLineTokenContext, isFunctionDeclContext], RuleAction.Space), - rule("NoSpaceBeforeOpenParenInFuncDecl", anyToken, SyntaxKind.OpenParenToken, [isOptionDisabledOrUndefined("insertSpaceBeforeFunctionParenthesis"), isNonJsxSameLineTokenContext, isFunctionDeclContext], RuleAction.Delete), + rule("SpaceBeforeOpenParenInFuncDecl", anyToken, SyntaxKind.OpenParenToken, [isOptionEnabled("insertSpaceBeforeFunctionParenthesis"), isNonJsxSameLineTokenContext, isFunctionDeclContext], RuleAction.InsertSpace), + rule("NoSpaceBeforeOpenParenInFuncDecl", anyToken, SyntaxKind.OpenParenToken, [isOptionDisabledOrUndefined("insertSpaceBeforeFunctionParenthesis"), isNonJsxSameLineTokenContext, isFunctionDeclContext], RuleAction.DeleteSpace), // Open Brace braces after control block - rule("NewLineBeforeOpenBraceInControl", controlOpenBraceLeftTokenRange, SyntaxKind.OpenBraceToken, [isOptionEnabled("placeOpenBraceOnNewLineForControlBlocks"), isControlDeclContext, isBeforeMultilineBlockContext], RuleAction.NewLine, RuleFlags.CanDeleteNewLines), + rule("NewLineBeforeOpenBraceInControl", controlOpenBraceLeftTokenRange, SyntaxKind.OpenBraceToken, [isOptionEnabled("placeOpenBraceOnNewLineForControlBlocks"), isControlDeclContext, isBeforeMultilineBlockContext], RuleAction.InsertNewLine, RuleFlags.CanDeleteNewLines), // Open Brace braces after function // TypeScript: Function can have return types, which can be made of tons of different token kinds - rule("NewLineBeforeOpenBraceInFunction", functionOpenBraceLeftTokenRange, SyntaxKind.OpenBraceToken, [isOptionEnabled("placeOpenBraceOnNewLineForFunctions"), isFunctionDeclContext, isBeforeMultilineBlockContext], RuleAction.NewLine, RuleFlags.CanDeleteNewLines), + rule("NewLineBeforeOpenBraceInFunction", functionOpenBraceLeftTokenRange, SyntaxKind.OpenBraceToken, [isOptionEnabled("placeOpenBraceOnNewLineForFunctions"), isFunctionDeclContext, isBeforeMultilineBlockContext], RuleAction.InsertNewLine, RuleFlags.CanDeleteNewLines), // Open Brace braces after TypeScript module/class/interface - rule("NewLineBeforeOpenBraceInTypeScriptDeclWithBlock", typeScriptOpenBraceLeftTokenRange, SyntaxKind.OpenBraceToken, [isOptionEnabled("placeOpenBraceOnNewLineForFunctions"), isTypeScriptDeclWithBlockContext, isBeforeMultilineBlockContext], RuleAction.NewLine, RuleFlags.CanDeleteNewLines), + rule("NewLineBeforeOpenBraceInTypeScriptDeclWithBlock", typeScriptOpenBraceLeftTokenRange, SyntaxKind.OpenBraceToken, [isOptionEnabled("placeOpenBraceOnNewLineForFunctions"), isTypeScriptDeclWithBlockContext, isBeforeMultilineBlockContext], RuleAction.InsertNewLine, RuleFlags.CanDeleteNewLines), - rule("SpaceAfterTypeAssertion", SyntaxKind.GreaterThanToken, anyToken, [isOptionEnabled("insertSpaceAfterTypeAssertion"), isNonJsxSameLineTokenContext, isTypeAssertionContext], RuleAction.Space), - rule("NoSpaceAfterTypeAssertion", SyntaxKind.GreaterThanToken, anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterTypeAssertion"), isNonJsxSameLineTokenContext, isTypeAssertionContext], RuleAction.Delete), + rule("SpaceAfterTypeAssertion", SyntaxKind.GreaterThanToken, anyToken, [isOptionEnabled("insertSpaceAfterTypeAssertion"), isNonJsxSameLineTokenContext, isTypeAssertionContext], RuleAction.InsertSpace), + rule("NoSpaceAfterTypeAssertion", SyntaxKind.GreaterThanToken, anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterTypeAssertion"), isNonJsxSameLineTokenContext, isTypeAssertionContext], RuleAction.DeleteSpace), - rule("SpaceBeforeTypeAnnotation", anyToken, SyntaxKind.ColonToken, [isOptionEnabled("insertSpaceBeforeTypeAnnotation"), isNonJsxSameLineTokenContext, isTypeAnnotationContext], RuleAction.Space), - rule("NoSpaceBeforeTypeAnnotation", anyToken, SyntaxKind.ColonToken, [isOptionDisabledOrUndefined("insertSpaceBeforeTypeAnnotation"), isNonJsxSameLineTokenContext, isTypeAnnotationContext], RuleAction.Delete), + rule("SpaceBeforeTypeAnnotation", anyToken, SyntaxKind.ColonToken, [isOptionEnabled("insertSpaceBeforeTypeAnnotation"), isNonJsxSameLineTokenContext, isTypeAnnotationContext], RuleAction.InsertSpace), + rule("NoSpaceBeforeTypeAnnotation", anyToken, SyntaxKind.ColonToken, [isOptionDisabledOrUndefined("insertSpaceBeforeTypeAnnotation"), isNonJsxSameLineTokenContext, isTypeAnnotationContext], RuleAction.DeleteSpace), + rule("NoOptionalSemicolon", SyntaxKind.SemicolonToken, anyTokenIncludingEOF, [optionEquals("semicolons", SemicolonPreference.Remove), isSemicolonDeletionContext], RuleAction.DeleteToken), + rule("OptionalSemicolon", anyToken, anyTokenIncludingEOF, [optionEquals("semicolons", SemicolonPreference.Insert), isSemicolonInsertionContext], RuleAction.InsertTrailingSemicolon), ]; // These rules are lower in priority than user-configurable. Rules earlier in this list have priority over rules later in the list. const lowPriorityCommonRules = [ // Space after keyword but not before ; or : or ? - rule("NoSpaceBeforeSemicolon", anyToken, SyntaxKind.SemicolonToken, [isNonJsxSameLineTokenContext], RuleAction.Delete), + rule("NoSpaceBeforeSemicolon", anyToken, SyntaxKind.SemicolonToken, [isNonJsxSameLineTokenContext], RuleAction.DeleteSpace), - rule("SpaceBeforeOpenBraceInControl", controlOpenBraceLeftTokenRange, SyntaxKind.OpenBraceToken, [isOptionDisabledOrUndefinedOrTokensOnSameLine("placeOpenBraceOnNewLineForControlBlocks"), isControlDeclContext, isNotFormatOnEnter, isSameLineTokenOrBeforeBlockContext], RuleAction.Space, RuleFlags.CanDeleteNewLines), - rule("SpaceBeforeOpenBraceInFunction", functionOpenBraceLeftTokenRange, SyntaxKind.OpenBraceToken, [isOptionDisabledOrUndefinedOrTokensOnSameLine("placeOpenBraceOnNewLineForFunctions"), isFunctionDeclContext, isBeforeBlockContext, isNotFormatOnEnter, isSameLineTokenOrBeforeBlockContext], RuleAction.Space, RuleFlags.CanDeleteNewLines), - rule("SpaceBeforeOpenBraceInTypeScriptDeclWithBlock", typeScriptOpenBraceLeftTokenRange, SyntaxKind.OpenBraceToken, [isOptionDisabledOrUndefinedOrTokensOnSameLine("placeOpenBraceOnNewLineForFunctions"), isTypeScriptDeclWithBlockContext, isNotFormatOnEnter, isSameLineTokenOrBeforeBlockContext], RuleAction.Space, RuleFlags.CanDeleteNewLines), + rule("SpaceBeforeOpenBraceInControl", controlOpenBraceLeftTokenRange, SyntaxKind.OpenBraceToken, [isOptionDisabledOrUndefinedOrTokensOnSameLine("placeOpenBraceOnNewLineForControlBlocks"), isControlDeclContext, isNotFormatOnEnter, isSameLineTokenOrBeforeBlockContext], RuleAction.InsertSpace, RuleFlags.CanDeleteNewLines), + rule("SpaceBeforeOpenBraceInFunction", functionOpenBraceLeftTokenRange, SyntaxKind.OpenBraceToken, [isOptionDisabledOrUndefinedOrTokensOnSameLine("placeOpenBraceOnNewLineForFunctions"), isFunctionDeclContext, isBeforeBlockContext, isNotFormatOnEnter, isSameLineTokenOrBeforeBlockContext], RuleAction.InsertSpace, RuleFlags.CanDeleteNewLines), + rule("SpaceBeforeOpenBraceInTypeScriptDeclWithBlock", typeScriptOpenBraceLeftTokenRange, SyntaxKind.OpenBraceToken, [isOptionDisabledOrUndefinedOrTokensOnSameLine("placeOpenBraceOnNewLineForFunctions"), isTypeScriptDeclWithBlockContext, isNotFormatOnEnter, isSameLineTokenOrBeforeBlockContext], RuleAction.InsertSpace, RuleFlags.CanDeleteNewLines), - rule("NoSpaceBeforeComma", anyToken, SyntaxKind.CommaToken, [isNonJsxSameLineTokenContext], RuleAction.Delete), + rule("NoSpaceBeforeComma", anyToken, SyntaxKind.CommaToken, [isNonJsxSameLineTokenContext], RuleAction.DeleteSpace), // No space before and after indexer `x[]` - rule("NoSpaceBeforeOpenBracket", anyTokenExcept(SyntaxKind.AsyncKeyword, SyntaxKind.CaseKeyword), SyntaxKind.OpenBracketToken, [isNonJsxSameLineTokenContext], RuleAction.Delete), - rule("NoSpaceAfterCloseBracket", SyntaxKind.CloseBracketToken, anyToken, [isNonJsxSameLineTokenContext, isNotBeforeBlockInFunctionDeclarationContext], RuleAction.Delete), - rule("SpaceAfterSemicolon", SyntaxKind.SemicolonToken, anyToken, [isNonJsxSameLineTokenContext], RuleAction.Space), + rule("NoSpaceBeforeOpenBracket", anyTokenExcept(SyntaxKind.AsyncKeyword, SyntaxKind.CaseKeyword), SyntaxKind.OpenBracketToken, [isNonJsxSameLineTokenContext], RuleAction.DeleteSpace), + rule("NoSpaceAfterCloseBracket", SyntaxKind.CloseBracketToken, anyToken, [isNonJsxSameLineTokenContext, isNotBeforeBlockInFunctionDeclarationContext], RuleAction.DeleteSpace), + rule("SpaceAfterSemicolon", SyntaxKind.SemicolonToken, anyToken, [isNonJsxSameLineTokenContext], RuleAction.InsertSpace), // Remove extra space between for and await - rule("SpaceBetweenForAndAwaitKeyword", SyntaxKind.ForKeyword, SyntaxKind.AwaitKeyword, [isNonJsxSameLineTokenContext], RuleAction.Space), + rule("SpaceBetweenForAndAwaitKeyword", SyntaxKind.ForKeyword, SyntaxKind.AwaitKeyword, [isNonJsxSameLineTokenContext], RuleAction.InsertSpace), // Add a space between statements. All keywords except (do,else,case) has open/close parens after them. // So, we have a rule to add a space for [),Any], [do,Any], [else,Any], and [case,Any] @@ -338,9 +343,9 @@ namespace ts.formatting { [SyntaxKind.CloseParenToken, SyntaxKind.DoKeyword, SyntaxKind.ElseKeyword, SyntaxKind.CaseKeyword], anyToken, [isNonJsxSameLineTokenContext, isNonJsxElementOrFragmentContext, isNotForContext], - RuleAction.Space), + RuleAction.InsertSpace), // This low-pri rule takes care of "try {" and "finally {" in case the rule SpaceBeforeOpenBraceInControl didn't execute on FormatOnEnter. - rule("SpaceAfterTryFinally", [SyntaxKind.TryKeyword, SyntaxKind.FinallyKeyword], SyntaxKind.OpenBraceToken, [isNonJsxSameLineTokenContext], RuleAction.Space), + rule("SpaceAfterTryFinally", [SyntaxKind.TryKeyword, SyntaxKind.FinallyKeyword], SyntaxKind.OpenBraceToken, [isNonJsxSameLineTokenContext], RuleAction.InsertSpace), ]; return [ @@ -395,6 +400,10 @@ namespace ts.formatting { /// Contexts /// + function optionEquals(optionName: K, optionValue: FormatCodeSettings[K]): (context: FormattingContext) => boolean { + return (context) => context.options && context.options[optionName] === optionValue; + } + function isOptionEnabled(optionName: keyof FormatCodeSettings): (context: FormattingContext) => boolean { return (context) => context.options && context.options.hasOwnProperty(optionName) && !!context.options[optionName]; } @@ -780,4 +789,79 @@ namespace ts.formatting { function isNonNullAssertionContext(context: FormattingContext): boolean { return context.contextNode.kind === SyntaxKind.NonNullExpression; } + + function isSemicolonDeletionContext(context: FormattingContext): boolean { + let nextTokenKind = context.nextTokenSpan.kind; + let nextTokenStart = context.nextTokenSpan.pos; + if (isTrivia(nextTokenKind)) { + const nextRealToken = context.nextTokenParent === context.currentTokenParent + ? findNextToken( + context.currentTokenParent, + findAncestor(context.currentTokenParent, a => !a.parent)!, + context.sourceFile) + : context.nextTokenParent.getFirstToken(context.sourceFile); + if (!nextRealToken) { + return true; + } + nextTokenKind = nextRealToken.kind; + nextTokenStart = nextRealToken.getStart(context.sourceFile); + } + + const startLine = context.sourceFile.getLineAndCharacterOfPosition(context.currentTokenSpan.pos).line; + const endLine = context.sourceFile.getLineAndCharacterOfPosition(nextTokenStart).line; + if (startLine === endLine) { + return nextTokenKind === SyntaxKind.CloseBraceToken + || nextTokenKind === SyntaxKind.EndOfFileToken; + } + + if (nextTokenKind === SyntaxKind.SemicolonClassElement || + nextTokenKind === SyntaxKind.SemicolonToken + ) { + return false; + } + + if (context.contextNode.kind === SyntaxKind.InterfaceDeclaration || + context.contextNode.kind === SyntaxKind.TypeAliasDeclaration + ) { + // Can’t remove semicolon after `foo`; it would parse as a method declaration: + // + // interface I { + // foo; + // (): void + // } + return !isPropertySignature(context.currentTokenParent) + || !!context.currentTokenParent.type + || nextTokenKind !== SyntaxKind.OpenParenToken; + } + + if (isPropertyDeclaration(context.currentTokenParent)) { + return !context.currentTokenParent.initializer; + } + + return context.currentTokenParent.kind !== SyntaxKind.ForStatement + && context.currentTokenParent.kind !== SyntaxKind.EmptyStatement + && context.currentTokenParent.kind !== SyntaxKind.SemicolonClassElement + && nextTokenKind !== SyntaxKind.OpenBracketToken + && nextTokenKind !== SyntaxKind.OpenParenToken + && nextTokenKind !== SyntaxKind.PlusToken + && nextTokenKind !== SyntaxKind.MinusToken + && nextTokenKind !== SyntaxKind.SlashToken + && nextTokenKind !== SyntaxKind.RegularExpressionLiteral + && nextTokenKind !== SyntaxKind.CommaToken + && nextTokenKind !== SyntaxKind.TemplateExpression + && nextTokenKind !== SyntaxKind.TemplateHead + && nextTokenKind !== SyntaxKind.NoSubstitutionTemplateLiteral + && nextTokenKind !== SyntaxKind.DotToken; + } + + function isSemicolonInsertionContext(context: FormattingContext): boolean { + const contextAncestor = findAncestor(context.currentTokenParent, ancestor => { + if (ancestor.end !== context.currentTokenSpan.end) { + return "quit"; + } + return syntaxMayBeASICandidate(ancestor.kind); + }); + + return !!contextAncestor && isASICandidate(contextAncestor, context.sourceFile); + } } diff --git a/src/services/formatting/rulesMap.ts b/src/services/formatting/rulesMap.ts index 9c57fa8f8c8ab..f466b397d20dd 100644 --- a/src/services/formatting/rulesMap.ts +++ b/src/services/formatting/rulesMap.ts @@ -1,7 +1,7 @@ /* @internal */ namespace ts.formatting { export function getFormatContext(options: FormatCodeSettings): FormatContext { - return { options, getRule: getRulesMap() }; + return { options, getRules: getRulesMap() }; } let rulesMapCache: RulesMap | undefined; @@ -13,12 +13,46 @@ namespace ts.formatting { return rulesMapCache; } - export type RulesMap = (context: FormattingContext) => Rule | undefined; + /** + * For a given rule action, gets a mask of other rule actions that + * cannot be applied at the same position. + */ + function getRuleActionExclusion(ruleAction: RuleAction): RuleAction { + let mask: RuleAction = 0; + if (ruleAction & RuleAction.StopProcessingSpaceActions) { + mask |= RuleAction.ModifySpaceAction; + } + if (ruleAction & RuleAction.StopProcessingTokenActions) { + mask |= RuleAction.ModifyTokenAction; + } + if (ruleAction & RuleAction.ModifySpaceAction) { + mask |= RuleAction.ModifySpaceAction; + } + if (ruleAction & RuleAction.ModifyTokenAction) { + mask |= RuleAction.ModifyTokenAction; + } + return mask; + } + + export type RulesMap = (context: FormattingContext) => readonly Rule[] | undefined; function createRulesMap(rules: readonly RuleSpec[]): RulesMap { const map = buildMap(rules); return context => { const bucket = map[getRuleBucketIndex(context.currentTokenSpan.kind, context.nextTokenSpan.kind)]; - return bucket && find(bucket, rule => every(rule.context, c => c(context))); + if (bucket) { + const rules: Rule[] = []; + let ruleActionMask: RuleAction = 0; + for (const rule of bucket) { + const acceptRuleActions = ~getRuleActionExclusion(ruleActionMask); + if (rule.action & acceptRuleActions && every(rule.context, c => c(context))) { + rules.push(rule); + ruleActionMask |= rule.action; + } + } + if (rules.length) { + return rules; + } + } }; } @@ -54,8 +88,8 @@ namespace ts.formatting { const mapRowLength = SyntaxKind.LastToken + 1; enum RulesPosition { - IgnoreRulesSpecific = 0, - IgnoreRulesAny = maskBitSize * 1, + StopRulesSpecific = 0, + StopRulesAny = maskBitSize * 1, ContextRulesSpecific = maskBitSize * 2, ContextRulesAny = maskBitSize * 3, NoContextRulesSpecific = maskBitSize * 4, @@ -78,8 +112,8 @@ namespace ts.formatting { // In order to insert a rule to the end of sub-bucket (3), we get the index by adding // the values in the bitmap segments 3rd, 2nd, and 1st. function addRule(rules: Rule[], rule: Rule, specificTokens: boolean, constructionState: number[], rulesBucketIndex: number): void { - const position = rule.action === RuleAction.Ignore ? - specificTokens ? RulesPosition.IgnoreRulesSpecific : RulesPosition.IgnoreRulesAny : + const position = rule.action & RuleAction.StopAction ? + specificTokens ? RulesPosition.StopRulesSpecific : RulesPosition.StopRulesAny : rule.context !== anyContext ? specificTokens ? RulesPosition.ContextRulesSpecific : RulesPosition.ContextRulesAny : specificTokens ? RulesPosition.NoContextRulesSpecific : RulesPosition.NoContextRulesAny; diff --git a/src/services/getEditsForFileRename.ts b/src/services/getEditsForFileRename.ts index e2428eeaade1d..9ab8410f51aeb 100644 --- a/src/services/getEditsForFileRename.ts +++ b/src/services/getEditsForFileRename.ts @@ -6,14 +6,14 @@ namespace ts { newFileOrDirPath: string, host: LanguageServiceHost, formatContext: formatting.FormatContext, - _preferences: UserPreferences, + preferences: UserPreferences, sourceMapper: SourceMapper, ): readonly FileTextChanges[] { const useCaseSensitiveFileNames = hostUsesCaseSensitiveFileNames(host); const getCanonicalFileName = createGetCanonicalFileName(useCaseSensitiveFileNames); const oldToNew = getPathUpdater(oldFileOrDirPath, newFileOrDirPath, getCanonicalFileName, sourceMapper); const newToOld = getPathUpdater(newFileOrDirPath, oldFileOrDirPath, getCanonicalFileName, sourceMapper); - return textChanges.ChangeTracker.with({ host, formatContext }, changeTracker => { + return textChanges.ChangeTracker.with({ host, formatContext, preferences }, changeTracker => { updateTsconfigFiles(program, changeTracker, oldToNew, oldFileOrDirPath, newFileOrDirPath, host.getCurrentDirectory(), useCaseSensitiveFileNames); updateImports(program, changeTracker, oldToNew, newToOld, host, getCanonicalFileName); }); diff --git a/src/services/organizeImports.ts b/src/services/organizeImports.ts index bf4545dbbd04b..6db5c9eeadc8c 100644 --- a/src/services/organizeImports.ts +++ b/src/services/organizeImports.ts @@ -12,10 +12,10 @@ namespace ts.OrganizeImports { formatContext: formatting.FormatContext, host: LanguageServiceHost, program: Program, - _preferences: UserPreferences, + preferences: UserPreferences, ) { - const changeTracker = textChanges.ChangeTracker.fromContext({ host, formatContext }); + const changeTracker = textChanges.ChangeTracker.fromContext({ host, formatContext, preferences }); const coalesceAndOrganizeImports = (importGroup: readonly ImportDeclaration[]) => coalesceImports(removeUnusedImports(importGroup, sourceFile, program)); diff --git a/src/services/services.ts b/src/services/services.ts index fb5c35d8f5d48..d9445256ae2c0 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -99,7 +99,7 @@ namespace ts { return this._children || (this._children = createChildren(this, sourceFile)); } - public getFirstToken(sourceFile?: SourceFile): Node | undefined { + public getFirstToken(sourceFile?: SourceFileLike): Node | undefined { this.assertHasRealPosition(); const children = this.getChildren(sourceFile); if (!children.length) { @@ -112,7 +112,7 @@ namespace ts { child.getFirstToken(sourceFile); } - public getLastToken(sourceFile?: SourceFile): Node | undefined { + public getLastToken(sourceFile?: SourceFileLike): Node | undefined { this.assertHasRealPosition(); const children = this.getChildren(sourceFile); diff --git a/src/services/textChanges.ts b/src/services/textChanges.ts index e57b17247ccb1..03e7a1c458d33 100644 --- a/src/services/textChanges.ts +++ b/src/services/textChanges.ts @@ -218,6 +218,7 @@ namespace ts.textChanges { export interface TextChangesContext { host: LanguageServiceHost; formatContext: formatting.FormatContext; + preferences: UserPreferences; } export type TypeAnnotatable = SignatureDeclaration | VariableDeclaration | ParameterDeclaration | PropertyDeclaration | PropertySignature; @@ -831,28 +832,36 @@ namespace ts.textChanges { return (options.prefix || "") + noIndent + (options.suffix || ""); } + function getFormatCodeSettingsForWriting({ options }: formatting.FormatContext, sourceFile: SourceFile): FormatCodeSettings { + const shouldAutoDetectSemicolonPreference = !options.semicolons || options.semicolons === SemicolonPreference.Ignore; + const shouldRemoveSemicolons = options.semicolons === SemicolonPreference.Remove || shouldAutoDetectSemicolonPreference && !probablyUsesSemicolons(sourceFile); + return { + ...options, + semicolons: shouldRemoveSemicolons ? SemicolonPreference.Remove : SemicolonPreference.Ignore, + }; + } + /** Note: this may mutate `nodeIn`. */ function getFormattedTextOfNode(nodeIn: Node, sourceFile: SourceFile, pos: number, { indentation, prefix, delta }: InsertNodeOptions, newLineCharacter: string, formatContext: formatting.FormatContext, validate: ValidateNonFormattedText | undefined): string { const { node, text } = getNonformattedText(nodeIn, sourceFile, newLineCharacter); if (validate) validate(node, text); - const { options: formatOptions } = formatContext; + const formatOptions = getFormatCodeSettingsForWriting(formatContext, sourceFile); const initialIndentation = indentation !== undefined ? indentation : formatting.SmartIndenter.getIndentation(pos, sourceFile, formatOptions, prefix === newLineCharacter || getLineStartPositionForPosition(pos, sourceFile) === pos); if (delta === undefined) { - delta = formatting.SmartIndenter.shouldIndentChildNode(formatContext.options, nodeIn) ? (formatOptions.indentSize || 0) : 0; + delta = formatting.SmartIndenter.shouldIndentChildNode(formatOptions, nodeIn) ? (formatOptions.indentSize || 0) : 0; } const file: SourceFileLike = { text, getLineAndCharacterOfPosition(pos) { return getLineAndCharacterOfPosition(this, pos); } }; - const changes = formatting.formatNodeGivenIndentation(node, file, sourceFile.languageVariant, initialIndentation, delta, formatContext); + const changes = formatting.formatNodeGivenIndentation(node, file, sourceFile.languageVariant, initialIndentation, delta, { ...formatContext, options: formatOptions }); return applyChanges(text, changes); } /** Note: output node may be mutated input node. */ export function getNonformattedText(node: Node, sourceFile: SourceFile | undefined, newLineCharacter: string): { text: string, node: Node } { - const omitTrailingSemicolon = !!sourceFile && !probablyUsesSemicolons(sourceFile); - const writer = createWriter(newLineCharacter, omitTrailingSemicolon); + const writer = createWriter(newLineCharacter); const newLine = newLineCharacter === "\n" ? NewLineKind.LineFeed : NewLineKind.CarriageReturnLineFeed; createPrinter({ newLine, neverAsciiEscape: true }, writer).writeNode(EmitHint.Unspecified, node, sourceFile, writer); return { text: writer.getText(), node: assignPositionsToNode(node) }; @@ -894,11 +903,11 @@ namespace ts.textChanges { interface TextChangesWriter extends EmitTextWriter, PrintHandlers {} - function createWriter(newLine: string, omitTrailingSemicolon?: boolean): TextChangesWriter { + function createWriter(newLine: string): TextChangesWriter { let lastNonTriviaPosition = 0; - const writer = omitTrailingSemicolon ? getTrailingSemicolonOmittingWriter(createTextWriter(newLine)) : createTextWriter(newLine); + const writer = createTextWriter(newLine); const onEmitNode: PrintHandlers["onEmitNode"] = (hint, node, printCallback) => { if (node) { setPos(node, lastNonTriviaPosition); diff --git a/src/services/types.ts b/src/services/types.ts index d77007f045df0..c138e727a1b5d 100644 --- a/src/services/types.ts +++ b/src/services/types.ts @@ -17,7 +17,11 @@ namespace ts { getFullText(sourceFile?: SourceFile): string; getText(sourceFile?: SourceFile): string; getFirstToken(sourceFile?: SourceFile): Node | undefined; + /* @internal */ + getFirstToken(sourceFile?: SourceFileLike): Node | undefined; // eslint-disable-line @typescript-eslint/unified-signatures getLastToken(sourceFile?: SourceFile): Node | undefined; + /* @internal */ + getLastToken(sourceFile?: SourceFileLike): Node | undefined; // eslint-disable-line @typescript-eslint/unified-signatures // See ts.forEachChild for documentation. forEachChild(cbNode: (node: Node) => T | undefined, cbNodeArray?: (nodes: NodeArray) => T | undefined): T | undefined; } @@ -680,6 +684,12 @@ namespace ts { Smart = 2, } + export enum SemicolonPreference { + Ignore = "ignore", + Insert = "insert", + Remove = "remove", + } + /* @deprecated - consider using EditorSettings instead */ export interface EditorOptions { BaseIndentSize?: number; @@ -738,6 +748,7 @@ namespace ts { readonly placeOpenBraceOnNewLineForControlBlocks?: boolean; readonly insertSpaceBeforeTypeAnnotation?: boolean; readonly indentMultiLineObjectLiteralBeginningOnBlankLine?: boolean; + readonly semicolons?: SemicolonPreference; } export function getDefaultFormatCodeSettings(newLineCharacter?: string): FormatCodeSettings { @@ -761,6 +772,7 @@ namespace ts { insertSpaceBeforeFunctionParenthesis: false, placeOpenBraceOnNewLineForFunctions: false, placeOpenBraceOnNewLineForControlBlocks: false, + semicolons: SemicolonPreference.Ignore, }; } diff --git a/src/services/utilities.ts b/src/services/utilities.ts index 91b0a7a19914b..5f59cef602bb3 100644 --- a/src/services/utilities.ts +++ b/src/services/utilities.ts @@ -749,7 +749,7 @@ namespace ts { return findPrecedingToken(position, file); } - export function findNextToken(previousToken: Node, parent: Node, sourceFile: SourceFile): Node | undefined { + export function findNextToken(previousToken: Node, parent: Node, sourceFile: SourceFileLike): Node | undefined { return find(parent); function find(n: Node): Node | undefined { @@ -757,7 +757,7 @@ namespace ts { // this is token that starts at the end of previous token - return it return n; } - return firstDefined(n.getChildren(), child => { + return firstDefined(n.getChildren(sourceFile), child => { const shouldDiveInChildNode = // previous token is enclosed somewhere in the child (child.pos <= previousToken.pos && child.end > previousToken.end) || @@ -1989,7 +1989,27 @@ namespace ts { return typeIsAccessible ? res : undefined; } - export function syntaxUsuallyHasTrailingSemicolon(kind: SyntaxKind) { + export function syntaxRequiresTrailingCommaOrSemicolonOrASI(kind: SyntaxKind) { + return kind === SyntaxKind.CallSignature + || kind === SyntaxKind.ConstructSignature + || kind === SyntaxKind.IndexSignature + || kind === SyntaxKind.PropertySignature + || kind === SyntaxKind.MethodSignature; + } + + export function syntaxRequiresTrailingFunctionBlockOrSemicolonOrASI(kind: SyntaxKind) { + return kind === SyntaxKind.FunctionDeclaration + || kind === SyntaxKind.Constructor + || kind === SyntaxKind.MethodDeclaration + || kind === SyntaxKind.GetAccessor + || kind === SyntaxKind.SetAccessor; + } + + export function syntaxRequiresTrailingModuleBlockOrSemicolonOrASI(kind: SyntaxKind) { + return kind === SyntaxKind.ModuleDeclaration; + } + + export function syntaxRequiresTrailingSemicolonOrASI(kind: SyntaxKind) { return kind === SyntaxKind.VariableStatement || kind === SyntaxKind.ExpressionStatement || kind === SyntaxKind.DoStatement @@ -2002,7 +2022,58 @@ namespace ts { || kind === SyntaxKind.TypeAliasDeclaration || kind === SyntaxKind.ImportDeclaration || kind === SyntaxKind.ImportEqualsDeclaration - || kind === SyntaxKind.ExportDeclaration; + || kind === SyntaxKind.ExportDeclaration + || kind === SyntaxKind.NamespaceExportDeclaration + || kind === SyntaxKind.ExportAssignment; + } + + export const syntaxMayBeASICandidate = or( + syntaxRequiresTrailingCommaOrSemicolonOrASI, + syntaxRequiresTrailingFunctionBlockOrSemicolonOrASI, + syntaxRequiresTrailingModuleBlockOrSemicolonOrASI, + syntaxRequiresTrailingSemicolonOrASI); + + export function isASICandidate(node: Node, sourceFile: SourceFileLike): boolean { + const lastToken = node.getLastToken(sourceFile); + if (lastToken && lastToken.kind === SyntaxKind.SemicolonToken) { + return false; + } + + if (syntaxRequiresTrailingCommaOrSemicolonOrASI(node.kind)) { + if (lastToken && lastToken.kind === SyntaxKind.CommaToken) { + return false; + } + } + else if (syntaxRequiresTrailingModuleBlockOrSemicolonOrASI(node.kind)) { + const lastChild = last(node.getChildren(sourceFile)); + if (lastChild && isModuleBlock(lastChild)) { + return false; + } + } + else if (syntaxRequiresTrailingFunctionBlockOrSemicolonOrASI(node.kind)) { + const lastChild = last(node.getChildren(sourceFile)); + if (lastChild && isFunctionBlock(lastChild)) { + return false; + } + } + else if (!syntaxRequiresTrailingSemicolonOrASI(node.kind)) { + return false; + } + + // See comment in parser’s `parseDoStatement` + if (node.kind === SyntaxKind.DoStatement) { + return true; + } + + const topNode = findAncestor(node, ancestor => !ancestor.parent)!; + const nextToken = findNextToken(node, topNode, sourceFile); + if (!nextToken || nextToken.kind === SyntaxKind.CloseBraceToken) { + return true; + } + + const startLine = sourceFile.getLineAndCharacterOfPosition(node.getEnd()).line; + const endLine = sourceFile.getLineAndCharacterOfPosition(nextToken.getStart(sourceFile)).line; + return startLine !== endLine; } export function probablyUsesSemicolons(sourceFile: SourceFile): boolean { @@ -2010,7 +2081,7 @@ namespace ts { let withoutSemicolon = 0; const nStatementsToObserve = 5; forEachChild(sourceFile, function visit(node): boolean | undefined { - if (syntaxUsuallyHasTrailingSemicolon(node.kind)) { + if (syntaxRequiresTrailingSemicolonOrASI(node.kind)) { const lastToken = node.getLastToken(sourceFile); if (lastToken && lastToken.kind === SyntaxKind.SemicolonToken) { withSemicolon++; diff --git a/tests/baselines/reference/api/tsserverlibrary.d.ts b/tests/baselines/reference/api/tsserverlibrary.d.ts index 390ba29da27e7..865785947f506 100644 --- a/tests/baselines/reference/api/tsserverlibrary.d.ts +++ b/tests/baselines/reference/api/tsserverlibrary.d.ts @@ -5298,6 +5298,11 @@ declare namespace ts { Block = 1, Smart = 2 } + enum SemicolonPreference { + Ignore = "ignore", + Insert = "insert", + Remove = "remove" + } interface EditorOptions { BaseIndentSize?: number; IndentSize: number; @@ -5350,6 +5355,7 @@ declare namespace ts { readonly placeOpenBraceOnNewLineForControlBlocks?: boolean; readonly insertSpaceBeforeTypeAnnotation?: boolean; readonly indentMultiLineObjectLiteralBeginningOnBlankLine?: boolean; + readonly semicolons?: SemicolonPreference; } function getDefaultFormatCodeSettings(newLineCharacter?: string): FormatCodeSettings; interface DefinitionInfo extends DocumentSpan { @@ -8197,6 +8203,11 @@ declare namespace ts.server.protocol { Block = "Block", Smart = "Smart" } + enum SemicolonPreference { + Ignore = "ignore", + Insert = "insert", + Remove = "remove" + } interface EditorSettings { baseIndentSize?: number; indentSize?: number; @@ -8222,6 +8233,7 @@ declare namespace ts.server.protocol { placeOpenBraceOnNewLineForFunctions?: boolean; placeOpenBraceOnNewLineForControlBlocks?: boolean; insertSpaceBeforeTypeAnnotation?: boolean; + semicolons?: SemicolonPreference; } interface UserPreferences { readonly disableSuggestions?: boolean; diff --git a/tests/baselines/reference/api/typescript.d.ts b/tests/baselines/reference/api/typescript.d.ts index 594a83ce0b57c..d8f3cdfab56c0 100644 --- a/tests/baselines/reference/api/typescript.d.ts +++ b/tests/baselines/reference/api/typescript.d.ts @@ -5298,6 +5298,11 @@ declare namespace ts { Block = 1, Smart = 2 } + enum SemicolonPreference { + Ignore = "ignore", + Insert = "insert", + Remove = "remove" + } interface EditorOptions { BaseIndentSize?: number; IndentSize: number; @@ -5350,6 +5355,7 @@ declare namespace ts { readonly placeOpenBraceOnNewLineForControlBlocks?: boolean; readonly insertSpaceBeforeTypeAnnotation?: boolean; readonly indentMultiLineObjectLiteralBeginningOnBlankLine?: boolean; + readonly semicolons?: SemicolonPreference; } function getDefaultFormatCodeSettings(newLineCharacter?: string): FormatCodeSettings; interface DefinitionInfo extends DocumentSpan { diff --git a/tests/cases/fourslash/codeFixInferFromCallInAssignment.ts b/tests/cases/fourslash/codeFixInferFromCallInAssignment.ts index 85e1d3bc50952..5eb564b830573 100644 --- a/tests/cases/fourslash/codeFixInferFromCallInAssignment.ts +++ b/tests/cases/fourslash/codeFixInferFromCallInAssignment.ts @@ -6,4 +6,4 @@ //// return result //// } -verify.rangeAfterCodeFix("app: { use: (arg0: string) => any; }"); +verify.rangeAfterCodeFix("app: { use: (arg0: string) => any }"); diff --git a/tests/cases/fourslash/codeFixInferFromFunctionUsage.ts b/tests/cases/fourslash/codeFixInferFromFunctionUsage.ts index f2dbad67b4b7d..31068469b4db9 100644 --- a/tests/cases/fourslash/codeFixInferFromFunctionUsage.ts +++ b/tests/cases/fourslash/codeFixInferFromFunctionUsage.ts @@ -2,7 +2,7 @@ // @noImplicitAny: true ////function wrap( [| arr |] ) { -//// arr.other(function (a: number, b: number) { return a < b ? -1 : 1 }) +//// arr.other(function (a: number, b: number) { return a < b ? -1 : 1 }); //// } // https://github.com/Microsoft/TypeScript/issues/29330 diff --git a/tests/cases/fourslash/extract-method28.ts b/tests/cases/fourslash/extract-method28.ts new file mode 100644 index 0000000000000..a1e1189102c3f --- /dev/null +++ b/tests/cases/fourslash/extract-method28.ts @@ -0,0 +1,20 @@ +/// + +/////*a*/console.log(0) // +////console.log(0)/*b*/ + +format.setFormatOptions({ ...format.copyFormatOptions(), semicolons: ts.SemicolonPreference.Insert }); +goTo.select("a", "b"); +edit.applyRefactor({ + refactorName: "Extract Symbol", + actionName: "function_scope_0", + actionDescription: "Extract to function in global scope", + newContent: +`/*RENAME*/newFunction(); + +function newFunction() { + console.log(0); // + console.log(0); +} +` +}); diff --git a/tests/cases/fourslash/extract-method29.ts b/tests/cases/fourslash/extract-method29.ts new file mode 100644 index 0000000000000..a7f83e65340be --- /dev/null +++ b/tests/cases/fourslash/extract-method29.ts @@ -0,0 +1,20 @@ +/// + +/////*a*/console.log(0); // +////console.log(0);/*b*/ + +format.setFormatOptions({ ...format.copyFormatOptions(), semicolons: ts.SemicolonPreference.Remove }); +goTo.select("a", "b"); +edit.applyRefactor({ + refactorName: "Extract Symbol", + actionName: "function_scope_0", + actionDescription: "Extract to function in global scope", + newContent: +`/*RENAME*/newFunction() + +function newFunction() { + console.log(0) // + console.log(0) +} +` +}); diff --git a/tests/cases/fourslash/extract-method30.ts b/tests/cases/fourslash/extract-method30.ts new file mode 100644 index 0000000000000..cf2c87e5c3f88 --- /dev/null +++ b/tests/cases/fourslash/extract-method30.ts @@ -0,0 +1,20 @@ +/// + +/////*a*/console.log(0) // +////console.log(0)/*b*/ + +format.setFormatOptions({ ...format.copyFormatOptions(), semicolons: ts.SemicolonPreference.Ignore }); +goTo.select("a", "b"); +edit.applyRefactor({ + refactorName: "Extract Symbol", + actionName: "function_scope_0", + actionDescription: "Extract to function in global scope", + newContent: +`/*RENAME*/newFunction() + +function newFunction() { + console.log(0) // + console.log(0) +} +` +}); diff --git a/tests/cases/fourslash/formatAddSemicolons1.ts b/tests/cases/fourslash/formatAddSemicolons1.ts new file mode 100644 index 0000000000000..304ec32f8baf4 --- /dev/null +++ b/tests/cases/fourslash/formatAddSemicolons1.ts @@ -0,0 +1,53 @@ +/// + +////console.log(1) +////console.log(2) +////const x = function() { } +////for (let i = 0; i < 1; i++) { +//// 1 +//// 2 +////} +////do { } while (false) console.log(3) +////function f() { } +////class C { +//// ["one"] = {} +//// ["two"] +//// three: string +//// m() { } +//// ;["three"] = {} +//// ;["four"] +////} +////enum E { +//// C +////} +////type M = { [K in keyof T]: any } +////declare module 'foo' { } +////declare module 'bar' +////type T = { x: string, y: number } + +format.setFormatOptions({ ...format.copyFormatOptions(), semicolons: ts.SemicolonPreference.Insert }); +format.document(); +verify.currentFileContentIs(`console.log(1); +console.log(2); +const x = function() { }; +for (let i = 0; i < 1; i++) { + 1; + 2; +} +do { } while (false); console.log(3); +function f() { } +class C { + ["one"] = {} + ["two"]; + three: string; + m() { } + ;["three"] = {} + ;["four"]; +} +enum E { + C +} +type M = { [K in keyof T]: any }; +declare module 'foo' { } +declare module 'bar'; +type T = { x: string, y: number; };`); diff --git a/tests/cases/fourslash/formatRemoveSemicolons1.ts b/tests/cases/fourslash/formatRemoveSemicolons1.ts new file mode 100644 index 0000000000000..b80ecee7edb2d --- /dev/null +++ b/tests/cases/fourslash/formatRemoveSemicolons1.ts @@ -0,0 +1,77 @@ +/// + +////; (function f() { })(); +////const a = 3; +////+ 4; +////const b = 3 +////+ 4; +////const c = 3 + +////4; +////class C { +//// prop; +//// ["p"]; +//// zero: void; +//// ["one"] = {}; +//// ["two"]; +//// ; +////} +////a; +////`b`; +////b; +////(3); +////4; +//// / regex /; +////; +////[]; +/////** blah */[0]; +////interface I { +//// new; +//// (); +//// foo; +//// (); +////} +////type T = { +//// new; +//// (); +//// foo; +//// (); +////} + +format.setFormatOptions({ ...format.copyFormatOptions(), semicolons: ts.SemicolonPreference.Remove }); +format.document(); +verify.currentFileContentIs(`; (function f() { })() +const a = 3; ++ 4 +const b = 3 + + 4 +const c = 3 + + 4 +class C { + prop + ["p"] + zero: void + ["one"] = {}; + ["two"]; + ; +} +a; +\`b\` +b; +(3) +4; +/ regex /; +; +[]; +/** blah */[0] +interface I { + new; + () + foo; + () +} +type T = { + new; + () + foo; + () +}`); \ No newline at end of file diff --git a/tests/cases/fourslash/formatRemoveSemicolons2.ts b/tests/cases/fourslash/formatRemoveSemicolons2.ts new file mode 100644 index 0000000000000..268a217e03231 --- /dev/null +++ b/tests/cases/fourslash/formatRemoveSemicolons2.ts @@ -0,0 +1,27 @@ +/// + +////namespace ts { +//// let x = 0; +//// // +//// interface I { +//// a: string; +//// /** @internal */ +//// b: string; +//// } +//// let y = 0; // +////} +////let z = 0; // + +format.setFormatOptions({ ...format.copyFormatOptions(), semicolons: ts.SemicolonPreference.Remove }); +format.document(); +verify.currentFileContentIs(`namespace ts { + let x = 0 + // + interface I { + a: string + /** @internal */ + b: string + } + let y = 0 // +} +let z = 0 //`); diff --git a/tests/cases/fourslash/formatRemoveSemicolons3.ts b/tests/cases/fourslash/formatRemoveSemicolons3.ts new file mode 100644 index 0000000000000..0987e088d5dda --- /dev/null +++ b/tests/cases/fourslash/formatRemoveSemicolons3.ts @@ -0,0 +1,11 @@ +/// + +////(type).declaredProperties = getNamedMembers(members); +////// Start with signatures at empty array in case of recursive types +////(type).declaredCallSignatures = emptyArray; + +format.setFormatOptions({ ...format.copyFormatOptions(), semicolons: ts.SemicolonPreference.Remove }); +format.document(); +verify.currentFileContentIs(`(type).declaredProperties = getNamedMembers(members); +// Start with signatures at empty array in case of recursive types +(type).declaredCallSignatures = emptyArray`); \ No newline at end of file diff --git a/tests/cases/fourslash/fourslash.ts b/tests/cases/fourslash/fourslash.ts index d64bc0a86617f..a1d4cab5a4da5 100644 --- a/tests/cases/fourslash/fourslash.ts +++ b/tests/cases/fourslash/fourslash.ts @@ -66,6 +66,12 @@ declare module ts { Smart = 2, } + enum SemicolonPreference { + Ignore = "ignore", + Insert = "insert", + Remove = "remove", + } + interface OutputFile { name: string; writeByteOrderMark: boolean; @@ -96,6 +102,11 @@ declare namespace FourSlashInterface { position: number; data?: any; } + enum IndentStyle { + None = 0, + Block = 1, + Smart = 2, + } interface EditorOptions { BaseIndentSize?: number, IndentSize: number; @@ -103,6 +114,14 @@ declare namespace FourSlashInterface { NewLineCharacter: string; ConvertTabsToSpaces: boolean; } + interface EditorSettings { + baseIndentSize?: number; + indentSize?: number; + tabSize?: number; + newLineCharacter?: string; + convertTabsToSpaces?: boolean; + indentStyle?: IndentStyle; + } interface FormatCodeOptions extends EditorOptions { InsertSpaceAfterCommaDelimiter: boolean; InsertSpaceAfterSemicolonInForStatements: boolean; @@ -119,6 +138,26 @@ declare namespace FourSlashInterface { insertSpaceBeforeTypeAnnotation: boolean; [s: string]: boolean | number | string | undefined; } + interface FormatCodeSettings extends EditorSettings { + readonly insertSpaceAfterCommaDelimiter?: boolean; + readonly insertSpaceAfterSemicolonInForStatements?: boolean; + readonly insertSpaceBeforeAndAfterBinaryOperators?: boolean; + readonly insertSpaceAfterConstructor?: boolean; + readonly insertSpaceAfterKeywordsInControlFlowStatements?: boolean; + readonly insertSpaceAfterFunctionKeywordForAnonymousFunctions?: boolean; + readonly insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis?: boolean; + readonly insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets?: boolean; + readonly insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces?: boolean; + readonly insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces?: boolean; + readonly insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces?: boolean; + readonly insertSpaceAfterTypeAssertion?: boolean; + readonly insertSpaceBeforeFunctionParenthesis?: boolean; + readonly placeOpenBraceOnNewLineForFunctions?: boolean; + readonly placeOpenBraceOnNewLineForControlBlocks?: boolean; + readonly insertSpaceBeforeTypeAnnotation?: boolean; + readonly indentMultiLineObjectLiteralBeginningOnBlankLine?: boolean; + readonly semicolons?: ts.SemicolonPreference; + } interface Range { fileName: string; pos: number; @@ -375,7 +414,7 @@ declare namespace FourSlashInterface { class format { document(): void; copyFormatOptions(): FormatCodeOptions; - setFormatOptions(options: FormatCodeOptions): any; + setFormatOptions(options: FormatCodeOptions | FormatCodeSettings): any; selection(startMarker: string, endMarker: string): void; onType(posMarker: string, key: string): void; setOption(name: keyof FormatCodeOptions, value: number | string | boolean): void; From 500a0df6f3a66dbf0717a1564e510527476ad32d Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com> Date: Thu, 26 Sep 2019 13:25:05 -0700 Subject: [PATCH 2/4] Add useDefineForClassFields flag for Set -> Define property declaration (#33509) * Disallow property/accessor overrides Unless the base property or accessor is abstract * Disallow uninitialised property overrides This causes quite a few test breaks. We'll probably want to revert many of them by switching to the upcoming `declare x: number` syntax. * Updates from design review + fix ancient bug 1. Don't error when overriding properties from interfaces. 2. Fix error when overriding methods with other things. This had no tests so I assume that the code was always dead and never worked. * Need to add a couple of errors and squash one Will update after checking out other branch for a minute * Everything works so far Need to test properties initialised in constructor * Check for constructor initialisation * change error wording * Improve error wording * Add codefix to add missing 'declare' * Always emit accessors in .d.ts files * Allow 'declare' on any uninitialised property decl * Undo code moves * Let sleeping dogs lie * Correctly set NodeFlags.Ambient And simplify redundant parts of check. * Remove more unneeded code * Update baselines * Update baselines * Update baselines * Ignore this-property assignments * Fix base-in-interface check * Do not error when base parent is interface * Fix base interface check * Add missed baselines * Fix check * Fix new errors in services * Fix new errors in services * Fix errors in testRunner * Add flag and turn off errors when on * Structure of new emit is correct, fake content It is 'hi'. * Basically right emit * Fix one last unitialised property declaration * Haha no I missed another one * Fix whitespace back to CRLF * Minor fix and code cleanup * New test case * Fix bug in isInitializedProperty * Updates from design meeting. 1. Change flag name to useDefineForClassFields (and flip polarity). 2. Forbid ES3 + useDefineForClassFields (since there is no defineProperty). 3. Forbid overriding an abstract property-with-initializer with an accessor. * Update baselines * Object.defineProperty for methods too Using code from Ron from his upcoming refactor of the factory functions. * Update slow baselines * Improve error message * Update src/compiler/transformers/utilities.ts Co-Authored-By: Andrew Branch * Add test of computed properties * Remove done TODO --- src/compiler/checker.ts | 60 ++- src/compiler/commandLineParser.ts | 7 + src/compiler/diagnosticMessages.json | 38 +- src/compiler/factory.ts | 48 +- src/compiler/parser.ts | 12 +- src/compiler/program.ts | 4 + src/compiler/transformers/classFields.ts | 38 +- src/compiler/transformers/declarations.ts | 75 +-- src/compiler/transformers/es2015.ts | 21 +- src/compiler/transformers/ts.ts | 2 +- src/compiler/transformers/utilities.ts | 36 +- src/compiler/types.ts | 11 + src/compiler/utilities.ts | 1 - src/server/protocol.ts | 1 + .../codefixes/addMissingDeclareProperty.ts | 34 ++ src/services/services.ts | 6 +- src/services/tsconfig.json | 1 + src/testRunner/parallel/host.ts | 6 +- src/testRunner/unittests/tsserver/helpers.ts | 8 +- src/testRunner/unittests/tsserver/symLinks.ts | 6 +- .../accessorsOverrideMethod.errors.txt | 13 + .../reference/accessorsOverrideMethod.js | 16 + .../reference/accessorsOverrideMethod.symbols | 15 + .../reference/accessorsOverrideMethod.types | 17 + .../accessorsOverrideProperty.errors.txt | 24 + .../reference/accessorsOverrideProperty.js | 32 ++ .../accessorsOverrideProperty.symbols | 42 ++ .../reference/accessorsOverrideProperty.types | 47 ++ .../accessorsOverrideProperty2.errors.txt | 18 + .../reference/accessorsOverrideProperty2.js | 24 + .../accessorsOverrideProperty2.symbols | 36 ++ .../accessorsOverrideProperty2.types | 42 ++ .../accessorsOverrideProperty3.errors.txt | 15 + .../reference/accessorsOverrideProperty3.js | 17 + .../accessorsOverrideProperty3.symbols | 29 ++ .../accessorsOverrideProperty3.types | 31 ++ .../accessorsOverrideProperty4.errors.txt | 15 + .../reference/accessorsOverrideProperty4.js | 17 + .../accessorsOverrideProperty4.symbols | 29 ++ .../accessorsOverrideProperty4.types | 31 ++ .../reference/accessorsOverrideProperty5.js | 19 + .../accessorsOverrideProperty5.symbols | 26 + .../accessorsOverrideProperty5.types | 22 + .../reference/accessorsOverrideProperty6.js | 39 ++ .../accessorsOverrideProperty6.symbols | 42 ++ .../accessorsOverrideProperty6.types | 47 ++ .../accessorsOverrideProperty7.errors.txt | 13 + .../reference/accessorsOverrideProperty7.js | 47 ++ .../accessorsOverrideProperty7.symbols | 15 + .../accessorsOverrideProperty7.types | 17 + .../reference/api/tsserverlibrary.d.ts | 2 + tests/baselines/reference/api/typescript.d.ts | 1 + .../checkJsFiles_noErrorLocation.errors.txt | 25 + ...lassExpressionPropertyModifiers.errors.txt | 6 +- tests/baselines/reference/classdecl.js | 7 +- .../reference/commentsClassMembers.js | 44 +- .../reference/commentsInheritance.js | 12 +- .../reference/commentsdoNotEmitComments.js | 3 +- .../reference/commentsemitComments.js | 3 +- .../baselines/reference/declFileAccessors.js | 44 +- .../reference/declFilePrivateStatic.js | 8 +- ...eTypeAnnotationVisibilityErrorAccessors.js | 36 +- .../declarationEmitClassMemberNameConflict.js | 4 +- .../declarationEmitProtectedMembers.js | 9 +- .../baselines/reference/definePropertyES5.js | 50 ++ .../reference/definePropertyES5.symbols | 25 + .../reference/definePropertyES5.types | 29 ++ .../definePropertyOutputES3.errors.txt | 9 + .../reference/definePropertyOutputES3.js | 18 + .../reference/definePropertyOutputES3.symbols | 8 + .../reference/definePropertyOutputES3.types | 9 + ...ninitializedPropertyDeclaration.errors.txt | 88 ++++ ...derivedUninitializedPropertyDeclaration.js | 182 +++++++ ...edUninitializedPropertyDeclaration.symbols | 149 ++++++ ...ivedUninitializedPropertyDeclaration.types | 152 ++++++ .../baselines/reference/dynamicNamesErrors.js | 8 +- tests/baselines/reference/giant.js | 24 +- ...illegalModifiersOnClassElements.errors.txt | 6 +- ...eMemberAccessorOverridingMethod.errors.txt | 20 + ...eMemberPropertyOverridingMethod.errors.txt | 15 + .../isDeclarationVisibleNodeKinds.js | 4 +- tests/baselines/reference/moduledecl.js | 4 +- .../reference/overrideInterfaceProperty.js | 31 ++ .../overrideInterfaceProperty.symbols | 49 ++ .../reference/overrideInterfaceProperty.types | 36 ++ ...arserMemberFunctionDeclaration5.errors.txt | 5 +- ...arserMemberVariableDeclaration5.errors.txt | 9 - .../reference/privacyAccessorDeclFile.js | 324 ++++++------- .../privacyCannotNameAccessorDeclFile.js | 24 +- tests/baselines/reference/properties.js | 3 +- .../propertyOverridesAccessors.errors.txt | 24 + .../reference/propertyOverridesAccessors.js | 55 +++ .../propertyOverridesAccessors.symbols | 42 ++ .../propertyOverridesAccessors.types | 47 ++ .../propertyOverridesAccessors2.errors.txt | 18 + .../reference/propertyOverridesAccessors2.js | 24 + .../propertyOverridesAccessors2.symbols | 36 ++ .../propertyOverridesAccessors2.types | 42 ++ .../propertyOverridesAccessors3.errors.txt | 30 ++ .../reference/propertyOverridesAccessors3.js | 45 ++ .../propertyOverridesAccessors3.symbols | 65 +++ .../propertyOverridesAccessors3.types | 73 +++ .../propertyOverridesAccessors4.errors.txt | 14 + .../reference/propertyOverridesAccessors4.js | 38 ++ .../propertyOverridesAccessors4.symbols | 19 + .../propertyOverridesAccessors4.types | 20 + .../propertyOverridesAccessors5.errors.txt | 15 + .../reference/propertyOverridesAccessors5.js | 22 + .../propertyOverridesAccessors5.symbols | 19 + .../propertyOverridesAccessors5.types | 21 + .../propertyOverridesMethod.errors.txt | 13 + .../reference/propertyOverridesMethod.js | 16 + .../reference/propertyOverridesMethod.symbols | 15 + .../reference/propertyOverridesMethod.types | 17 + .../propertyOverridingPrototype.errors.txt | 16 + .../reference/readonlyInDeclarationFile.js | 30 +- .../useDefineForClassFields/tsconfig.json | 5 + .../reference/symbolDeclarationEmit11.js | 3 +- .../reference/symbolDeclarationEmit12.js | 4 +- .../reference/symbolDeclarationEmit13.js | 4 +- .../reference/symbolDeclarationEmit14.js | 4 +- .../reference/symbolDeclarationEmit4.js | 3 +- .../thisPropertyOverridesAccessors.symbols | 28 ++ .../thisPropertyOverridesAccessors.types | 32 ++ .../stripInternal.js | 37 +- .../stripInternal.js | 402 ++++++++-------- .../initial-build/stripInternal.js | 405 ++++++++-------- ...en-one-two-three-are-prepended-in-order.js | 371 ++++++++------- ...en-one-two-three-are-prepended-in-order.js | 37 +- ...en-one-two-three-are-prepended-in-order.js | 37 +- ...en-one-two-three-are-prepended-in-order.js | 37 +- ...en-one-two-three-are-prepended-in-order.js | 37 +- ...en-one-two-three-are-prepended-in-order.js | 368 ++++++++------- ...en-one-two-three-are-prepended-in-order.js | 368 ++++++++------- ...en-one-two-three-are-prepended-in-order.js | 370 ++++++++------- ...en-one-two-three-are-prepended-in-order.js | 371 ++++++++------- .../stripInternal-jsdoc-style-comment.js | 371 ++++++++------- ...en-one-two-three-are-prepended-in-order.js | 443 ++++++++++-------- ...-jsdoc-style-with-comments-emit-enabled.js | 443 ++++++++++-------- ...en-one-two-three-are-prepended-in-order.js | 371 ++++++++------- ...en-one-two-three-are-prepended-in-order.js | 373 ++++++++------- ...tripInternal-with-comments-emit-enabled.js | 373 ++++++++------- .../initial-build/stripInternal.js | 371 ++++++++------- .../reference/typeGuardOfFormThisMember.js | 5 +- .../typeGuardOfFormThisMemberErrors.js | 5 +- .../uniqueSymbolsDeclarationsErrors.js | 6 +- .../accessorsOverrideMethod.ts | 8 + .../accessorsOverrideProperty.ts | 16 + .../accessorsOverrideProperty2.ts | 13 + .../accessorsOverrideProperty3.ts | 10 + .../accessorsOverrideProperty4.ts | 10 + .../accessorsOverrideProperty5.ts | 11 + .../accessorsOverrideProperty6.ts | 16 + .../accessorsOverrideProperty7.ts | 8 + .../definePropertyES5.ts | 10 + .../definePropertyOutputES3.ts | 5 + ...derivedUninitializedPropertyDeclaration.ts | 67 +++ .../overrideInterfaceProperty.ts | 18 + .../propertyOverridesAccessors.ts | 16 + .../propertyOverridesAccessors2.ts | 13 + .../propertyOverridesAccessors3.ts | 25 + .../propertyOverridesAccessors4.ts | 9 + .../propertyOverridesAccessors5.ts | 10 + .../propertyOverridesMethod.ts | 8 + .../thisPropertyOverridesAccessors.ts | 17 + .../codeFixAddMissingDeclareProperty.ts | 19 + .../codeFixAddMissingDeclareProperty2.ts | 26 + ...erivedTypeIndexerWithGenericConstraints.ts | 2 +- tests/cases/fourslash/incompatibleOverride.ts | 6 +- .../squiggleIllegalSubclassOverride.ts | 4 +- 170 files changed, 6500 insertions(+), 3004 deletions(-) create mode 100644 src/services/codefixes/addMissingDeclareProperty.ts create mode 100644 tests/baselines/reference/accessorsOverrideMethod.errors.txt create mode 100644 tests/baselines/reference/accessorsOverrideMethod.js create mode 100644 tests/baselines/reference/accessorsOverrideMethod.symbols create mode 100644 tests/baselines/reference/accessorsOverrideMethod.types create mode 100644 tests/baselines/reference/accessorsOverrideProperty.errors.txt create mode 100644 tests/baselines/reference/accessorsOverrideProperty.js create mode 100644 tests/baselines/reference/accessorsOverrideProperty.symbols create mode 100644 tests/baselines/reference/accessorsOverrideProperty.types create mode 100644 tests/baselines/reference/accessorsOverrideProperty2.errors.txt create mode 100644 tests/baselines/reference/accessorsOverrideProperty2.js create mode 100644 tests/baselines/reference/accessorsOverrideProperty2.symbols create mode 100644 tests/baselines/reference/accessorsOverrideProperty2.types create mode 100644 tests/baselines/reference/accessorsOverrideProperty3.errors.txt create mode 100644 tests/baselines/reference/accessorsOverrideProperty3.js create mode 100644 tests/baselines/reference/accessorsOverrideProperty3.symbols create mode 100644 tests/baselines/reference/accessorsOverrideProperty3.types create mode 100644 tests/baselines/reference/accessorsOverrideProperty4.errors.txt create mode 100644 tests/baselines/reference/accessorsOverrideProperty4.js create mode 100644 tests/baselines/reference/accessorsOverrideProperty4.symbols create mode 100644 tests/baselines/reference/accessorsOverrideProperty4.types create mode 100644 tests/baselines/reference/accessorsOverrideProperty5.js create mode 100644 tests/baselines/reference/accessorsOverrideProperty5.symbols create mode 100644 tests/baselines/reference/accessorsOverrideProperty5.types create mode 100644 tests/baselines/reference/accessorsOverrideProperty6.js create mode 100644 tests/baselines/reference/accessorsOverrideProperty6.symbols create mode 100644 tests/baselines/reference/accessorsOverrideProperty6.types create mode 100644 tests/baselines/reference/accessorsOverrideProperty7.errors.txt create mode 100644 tests/baselines/reference/accessorsOverrideProperty7.js create mode 100644 tests/baselines/reference/accessorsOverrideProperty7.symbols create mode 100644 tests/baselines/reference/accessorsOverrideProperty7.types create mode 100644 tests/baselines/reference/checkJsFiles_noErrorLocation.errors.txt create mode 100644 tests/baselines/reference/definePropertyES5.js create mode 100644 tests/baselines/reference/definePropertyES5.symbols create mode 100644 tests/baselines/reference/definePropertyES5.types create mode 100644 tests/baselines/reference/definePropertyOutputES3.errors.txt create mode 100644 tests/baselines/reference/definePropertyOutputES3.js create mode 100644 tests/baselines/reference/definePropertyOutputES3.symbols create mode 100644 tests/baselines/reference/definePropertyOutputES3.types create mode 100644 tests/baselines/reference/derivedUninitializedPropertyDeclaration.errors.txt create mode 100644 tests/baselines/reference/derivedUninitializedPropertyDeclaration.js create mode 100644 tests/baselines/reference/derivedUninitializedPropertyDeclaration.symbols create mode 100644 tests/baselines/reference/derivedUninitializedPropertyDeclaration.types create mode 100644 tests/baselines/reference/inheritanceMemberAccessorOverridingMethod.errors.txt create mode 100644 tests/baselines/reference/inheritanceMemberPropertyOverridingMethod.errors.txt create mode 100644 tests/baselines/reference/overrideInterfaceProperty.js create mode 100644 tests/baselines/reference/overrideInterfaceProperty.symbols create mode 100644 tests/baselines/reference/overrideInterfaceProperty.types delete mode 100644 tests/baselines/reference/parserMemberVariableDeclaration5.errors.txt create mode 100644 tests/baselines/reference/propertyOverridesAccessors.errors.txt create mode 100644 tests/baselines/reference/propertyOverridesAccessors.js create mode 100644 tests/baselines/reference/propertyOverridesAccessors.symbols create mode 100644 tests/baselines/reference/propertyOverridesAccessors.types create mode 100644 tests/baselines/reference/propertyOverridesAccessors2.errors.txt create mode 100644 tests/baselines/reference/propertyOverridesAccessors2.js create mode 100644 tests/baselines/reference/propertyOverridesAccessors2.symbols create mode 100644 tests/baselines/reference/propertyOverridesAccessors2.types create mode 100644 tests/baselines/reference/propertyOverridesAccessors3.errors.txt create mode 100644 tests/baselines/reference/propertyOverridesAccessors3.js create mode 100644 tests/baselines/reference/propertyOverridesAccessors3.symbols create mode 100644 tests/baselines/reference/propertyOverridesAccessors3.types create mode 100644 tests/baselines/reference/propertyOverridesAccessors4.errors.txt create mode 100644 tests/baselines/reference/propertyOverridesAccessors4.js create mode 100644 tests/baselines/reference/propertyOverridesAccessors4.symbols create mode 100644 tests/baselines/reference/propertyOverridesAccessors4.types create mode 100644 tests/baselines/reference/propertyOverridesAccessors5.errors.txt create mode 100644 tests/baselines/reference/propertyOverridesAccessors5.js create mode 100644 tests/baselines/reference/propertyOverridesAccessors5.symbols create mode 100644 tests/baselines/reference/propertyOverridesAccessors5.types create mode 100644 tests/baselines/reference/propertyOverridesMethod.errors.txt create mode 100644 tests/baselines/reference/propertyOverridesMethod.js create mode 100644 tests/baselines/reference/propertyOverridesMethod.symbols create mode 100644 tests/baselines/reference/propertyOverridesMethod.types create mode 100644 tests/baselines/reference/propertyOverridingPrototype.errors.txt create mode 100644 tests/baselines/reference/showConfig/Shows tsconfig for single option/useDefineForClassFields/tsconfig.json create mode 100644 tests/baselines/reference/thisPropertyOverridesAccessors.symbols create mode 100644 tests/baselines/reference/thisPropertyOverridesAccessors.types create mode 100644 tests/cases/conformance/classes/propertyMemberDeclarations/accessorsOverrideMethod.ts create mode 100644 tests/cases/conformance/classes/propertyMemberDeclarations/accessorsOverrideProperty.ts create mode 100644 tests/cases/conformance/classes/propertyMemberDeclarations/accessorsOverrideProperty2.ts create mode 100644 tests/cases/conformance/classes/propertyMemberDeclarations/accessorsOverrideProperty3.ts create mode 100644 tests/cases/conformance/classes/propertyMemberDeclarations/accessorsOverrideProperty4.ts create mode 100644 tests/cases/conformance/classes/propertyMemberDeclarations/accessorsOverrideProperty5.ts create mode 100644 tests/cases/conformance/classes/propertyMemberDeclarations/accessorsOverrideProperty6.ts create mode 100644 tests/cases/conformance/classes/propertyMemberDeclarations/accessorsOverrideProperty7.ts create mode 100644 tests/cases/conformance/classes/propertyMemberDeclarations/definePropertyES5.ts create mode 100644 tests/cases/conformance/classes/propertyMemberDeclarations/definePropertyOutputES3.ts create mode 100644 tests/cases/conformance/classes/propertyMemberDeclarations/derivedUninitializedPropertyDeclaration.ts create mode 100644 tests/cases/conformance/classes/propertyMemberDeclarations/overrideInterfaceProperty.ts create mode 100644 tests/cases/conformance/classes/propertyMemberDeclarations/propertyOverridesAccessors.ts create mode 100644 tests/cases/conformance/classes/propertyMemberDeclarations/propertyOverridesAccessors2.ts create mode 100644 tests/cases/conformance/classes/propertyMemberDeclarations/propertyOverridesAccessors3.ts create mode 100644 tests/cases/conformance/classes/propertyMemberDeclarations/propertyOverridesAccessors4.ts create mode 100644 tests/cases/conformance/classes/propertyMemberDeclarations/propertyOverridesAccessors5.ts create mode 100644 tests/cases/conformance/classes/propertyMemberDeclarations/propertyOverridesMethod.ts create mode 100644 tests/cases/conformance/classes/propertyMemberDeclarations/thisPropertyOverridesAccessors.ts create mode 100644 tests/cases/fourslash/codeFixAddMissingDeclareProperty.ts create mode 100644 tests/cases/fourslash/codeFixAddMissingDeclareProperty2.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 7f3c1cfc43d16..f180f9e544b6a 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -29904,7 +29904,6 @@ namespace ts { } function checkKindsOfPropertyMemberOverrides(type: InterfaceType, baseType: BaseType): void { - // TypeScript 1.0 spec (April 2014): 8.2.3 // A derived class inherits all members from its base class it doesn't override. // Inheritance means that a derived class implicitly contains all non - overridden members of the base class. @@ -29938,7 +29937,6 @@ namespace ts { // type declaration, derived and base resolve to the same symbol even in the case of generic classes. if (derived === base) { // derived class inherits base without override/redeclaration - const derivedClassDecl = getClassLikeDeclarationOfSymbol(type.symbol)!; // It is an error to inherit an abstract member without implementing it or being declared abstract. @@ -29975,14 +29973,53 @@ namespace ts { continue; } - if (isPrototypeProperty(base) || base.flags & SymbolFlags.PropertyOrAccessor && derived.flags & SymbolFlags.PropertyOrAccessor) { - // method is overridden with method or property/accessor is overridden with property/accessor - correct case - continue; - } - let errorMessage: DiagnosticMessage; - if (isPrototypeProperty(base)) { - if (derived.flags & SymbolFlags.Accessor) { + const basePropertyFlags = base.flags & SymbolFlags.PropertyOrAccessor; + const derivedPropertyFlags = derived.flags & SymbolFlags.PropertyOrAccessor; + if (basePropertyFlags && derivedPropertyFlags) { + // property/accessor is overridden with property/accessor + if (!compilerOptions.useDefineForClassFields + || baseDeclarationFlags & ModifierFlags.Abstract && !(base.valueDeclaration && isPropertyDeclaration(base.valueDeclaration) && base.valueDeclaration.initializer) + || base.valueDeclaration && base.valueDeclaration.parent.kind === SyntaxKind.InterfaceDeclaration + || derived.valueDeclaration && isBinaryExpression(derived.valueDeclaration)) { + // when the base property is abstract or from an interface, base/derived flags don't need to match + // same when the derived property is from an assignment + continue; + } + if (basePropertyFlags !== SymbolFlags.Property && derivedPropertyFlags === SymbolFlags.Property) { + errorMessage = Diagnostics.Class_0_defines_instance_member_accessor_1_but_extended_class_2_defines_it_as_instance_member_property; + } + else if (basePropertyFlags === SymbolFlags.Property && derivedPropertyFlags !== SymbolFlags.Property) { + errorMessage = Diagnostics.Class_0_defines_instance_member_property_1_but_extended_class_2_defines_it_as_instance_member_accessor; + } + else { + const uninitialized = find(derived.declarations, d => d.kind === SyntaxKind.PropertyDeclaration && !(d as PropertyDeclaration).initializer); + if (uninitialized + && !(derived.flags & SymbolFlags.Transient) + && !(baseDeclarationFlags & ModifierFlags.Abstract) + && !(derivedDeclarationFlags & ModifierFlags.Abstract) + && !derived.declarations.some(d => d.flags & NodeFlags.Ambient)) { + const constructor = findConstructorDeclaration(getClassLikeDeclarationOfSymbol(type.symbol)!); + const propName = (uninitialized as PropertyDeclaration).name; + if ((uninitialized as PropertyDeclaration).exclamationToken + || !constructor + || !isIdentifier(propName) + || !strictNullChecks + || !isPropertyInitializedInConstructor(propName, type, constructor)) { + const errorMessage = Diagnostics.Property_0_will_overwrite_the_base_property_in_1_If_this_is_intentional_add_an_initializer_Otherwise_add_a_declare_modifier_or_remove_the_redundant_declaration; + error(getNameOfDeclaration(derived.valueDeclaration) || derived.valueDeclaration, errorMessage, symbolToString(base), typeToString(baseType)); + } + } + // correct case + continue; + } + } + else if (isPrototypeProperty(base)) { + if (isPrototypeProperty(derived)) { + // method is overridden with method -- correct case + continue; + } + else if (derived.flags & SymbolFlags.Accessor) { errorMessage = Diagnostics.Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_accessor; } else { @@ -30044,6 +30081,9 @@ namespace ts { } const constructor = findConstructorDeclaration(node); for (const member of node.members) { + if (getModifierFlags(member) & ModifierFlags.Ambient) { + continue; + } if (isInstancePropertyWithoutInitializer(member)) { const propName = (member).name; if (isIdentifier(propName)) { @@ -32970,7 +33010,7 @@ namespace ts { else if (flags & ModifierFlags.Async) { return grammarErrorOnNode(modifier, Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "async"); } - else if (isClassLike(node.parent)) { + else if (isClassLike(node.parent) && !isPropertyDeclaration(node)) { return grammarErrorOnNode(modifier, Diagnostics._0_modifier_cannot_appear_on_a_class_element, "declare"); } else if (node.kind === SyntaxKind.Parameter) { diff --git a/src/compiler/commandLineParser.ts b/src/compiler/commandLineParser.ts index fd0d428d54bae..8e0a5b8d10af1 100644 --- a/src/compiler/commandLineParser.ts +++ b/src/compiler/commandLineParser.ts @@ -873,6 +873,13 @@ namespace ts { category: Diagnostics.Advanced_Options, description: Diagnostics.Disable_strict_checking_of_generic_signatures_in_function_types, }, + { + name: "useDefineForClassFields", + type: "boolean", + affectsSemanticDiagnostics: true, + category: Diagnostics.Advanced_Options, + description: Diagnostics.Emit_class_fields_with_Define_instead_of_Set, + }, { name: "keyofStringsOnly", type: "boolean", diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index 87052c4e7cdb2..78700a9476cef 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -2233,6 +2233,19 @@ "category": "Error", "code": 2609 }, + "Class '{0}' defines instance member accessor '{1}', but extended class '{2}' defines it as instance member property.": { + "category": "Error", + "code": 2610 + }, + "Class '{0}' defines instance member property '{1}', but extended class '{2}' defines it as instance member accessor.": { + "category": "Error", + "code": 2611 + }, + "Property '{0}' will overwrite the base property in '{1}'. If this is intentional, add an initializer. Otherwise, add a 'declare' modifier or remove the redundant declaration.": { + "category": "Error", + "code": 2612 + }, + "Cannot augment module '{0}' with value exports because it resolves to a non-module entity.": { "category": "Error", "code": 2649 @@ -3112,6 +3125,10 @@ "category": "Error", "code": 5047 }, + "Option '{0}' cannot be specified when option 'target' is 'ES3'.": { + "category": "Error", + "code": 5048 + }, "Option '{0} can only be used when either option '--inlineSourceMap' or option '--sourceMap' is provided.": { "category": "Error", "code": 5051 @@ -3966,6 +3983,10 @@ "Conflicts are in this file.": { "category": "Message", "code": 6201 + }, + "Project references may not form a circular graph. Cycle detected: {0}": { + "category": "Error", + "code": 6202 }, "'{0}' was also declared here.": { "category": "Message", @@ -4043,6 +4064,10 @@ "category": "Message", "code": 6221 }, + "Emit class fields with Define instead of Set.": { + "category": "Message", + "code": 6222 + }, "Projects to reference": { "category": "Message", @@ -4052,10 +4077,7 @@ "category": "Message", "code": 6302 }, - "Project references may not form a circular graph. Cycle detected: {0}": { - "category": "Error", - "code": 6202 - }, + "Composite projects may not disable declaration emit.": { "category": "Error", "code": 6304 @@ -5180,6 +5202,14 @@ "category": "Message", "code": 95093 }, + "Prefix with 'declare'": { + "category": "Message", + "code": 95094 + }, + "Prefix all incorrect property declarations with 'declare'": { + "category": "Message", + "code": 95095 + }, "No value exists in scope for the shorthand property '{0}'. Either declare one or provide an initializer.": { "category": "Error", diff --git a/src/compiler/factory.ts b/src/compiler/factory.ts index bd2dcbee6f188..a4f780185e91e 100644 --- a/src/compiler/factory.ts +++ b/src/compiler/factory.ts @@ -484,6 +484,47 @@ namespace ts { return node; } + function createMethodCall(object: Expression, methodName: string | Identifier, argumentsList: readonly Expression[]) { + return createCall( + createPropertyAccess(object, asName(methodName)), + /*typeArguments*/ undefined, + argumentsList + ); + } + + function createGlobalMethodCall(globalObjectName: string, methodName: string, argumentsList: readonly Expression[]) { + return createMethodCall(createIdentifier(globalObjectName), methodName, argumentsList); + } + + /* @internal */ + export function createObjectDefinePropertyCall(target: Expression, propertyName: string | Expression, attributes: Expression) { + return createGlobalMethodCall("Object", "defineProperty", [target, asExpression(propertyName), attributes]); + } + + function tryAddPropertyAssignment(properties: Push, propertyName: string, expression: Expression | undefined) { + if (expression) { + properties.push(createPropertyAssignment(propertyName, expression)); + return true; + } + return false; + } + + /* @internal */ + export function createPropertyDescriptor(attributes: PropertyDescriptorAttributes, singleLine?: boolean) { + const properties: PropertyAssignment[] = []; + tryAddPropertyAssignment(properties, "enumerable", asExpression(attributes.enumerable)); + tryAddPropertyAssignment(properties, "configurable", asExpression(attributes.configurable)); + + let isData = tryAddPropertyAssignment(properties, "writable", asExpression(attributes.writable)); + isData = tryAddPropertyAssignment(properties, "value", attributes.value) || isData; + + let isAccessor = tryAddPropertyAssignment(properties, "get", attributes.get); + isAccessor = tryAddPropertyAssignment(properties, "set", attributes.set) || isAccessor; + + Debug.assert(!(isData && isAccessor), "A PropertyDescriptor may not be both an accessor descriptor and a data descriptor."); + return createObjectLiteral(properties, !singleLine); + } + export function updateMethod( node: MethodDeclaration, decorators: readonly Decorator[] | undefined, @@ -3146,8 +3187,11 @@ namespace ts { return isString(name) ? createIdentifier(name) : name; } - function asExpression(value: string | number | Expression) { - return isString(value) || typeof value === "number" ? createLiteral(value) : value; + function asExpression(value: string | number | boolean | T): T | StringLiteral | NumericLiteral | BooleanLiteral { + return typeof value === "string" ? createStringLiteral(value) : + typeof value === "number" ? createNumericLiteral(""+value) : + typeof value === "boolean" ? value ? createTrue() : createFalse() : + value; } function asNodeArray(array: readonly T[]): NodeArray; diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index edaa7ebeaebaa..bad247b175dca 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -5995,8 +5995,16 @@ namespace ts { token() === SyntaxKind.NumericLiteral || token() === SyntaxKind.AsteriskToken || token() === SyntaxKind.OpenBracketToken) { - - return parsePropertyOrMethodDeclaration(node); + const isAmbient = node.modifiers && some(node.modifiers, isDeclareModifier); + if (isAmbient) { + for (const m of node.modifiers!) { + m.flags |= NodeFlags.Ambient; + } + return doInsideOfContext(NodeFlags.Ambient, () => parsePropertyOrMethodDeclaration(node as PropertyDeclaration | MethodDeclaration)); + } + else { + return parsePropertyOrMethodDeclaration(node as PropertyDeclaration | MethodDeclaration); + } } if (node.decorators || node.modifiers) { diff --git a/src/compiler/program.ts b/src/compiler/program.ts index 04c2c8d2c770b..9bc91e423a4f2 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -3073,6 +3073,10 @@ namespace ts { } } + if (options.useDefineForClassFields && languageVersion === ScriptTarget.ES3) { + createDiagnosticForOptionName(Diagnostics.Option_0_cannot_be_specified_when_option_target_is_ES3, "useDefineForClassFields"); + } + if (!options.noEmit && options.allowJs && getEmitDeclarations(options)) { createDiagnosticForOptionName(Diagnostics.Option_0_cannot_be_specified_with_option_1, "allowJs", getEmitDeclarationOptionName(options)); } diff --git a/src/compiler/transformers/classFields.ts b/src/compiler/transformers/classFields.ts index 37473d9bb20ec..1424d29336945 100644 --- a/src/compiler/transformers/classFields.ts +++ b/src/compiler/transformers/classFields.ts @@ -44,7 +44,9 @@ namespace ts { return chainBundle(transformSourceFile); function transformSourceFile(node: SourceFile) { - if (node.isDeclarationFile) { + const options = context.getCompilerOptions(); + if (node.isDeclarationFile + || options.useDefineForClassFields && options.target === ScriptTarget.ESNext) { return node; } const visited = visitEachChild(node, visitor, context); @@ -172,9 +174,9 @@ namespace ts { // From ES6 specification: // HasLexicalDeclaration (N) : Determines if the argument identifier has a binding in this environment record that was created using // a lexical declaration such as a LexicalDeclaration or a ClassDeclaration. - const staticProperties = getInitializedProperties(node, /*isStatic*/ true); + const staticProperties = getProperties(node, /*requireInitializer*/ true, /*isStatic*/ true); if (some(staticProperties)) { - addInitializedPropertyStatements(statements, staticProperties, getInternalName(node)); + addPropertyStatements(statements, staticProperties, getInternalName(node)); } return statements; @@ -196,7 +198,7 @@ namespace ts { // these statements after the class expression variable statement. const isDecoratedClassDeclaration = isClassDeclaration(getOriginalNode(node)); - const staticProperties = getInitializedProperties(node, /*isStatic*/ true); + const staticProperties = getProperties(node, /*requireInitializer*/ true, /*isStatic*/ true); const extendsClauseElement = getEffectiveBaseTypeNode(node); const isDerivedClass = !!(extendsClauseElement && skipOuterExpressions(extendsClauseElement.expression).kind !== SyntaxKind.NullKeyword); @@ -220,7 +222,7 @@ namespace ts { pendingExpressions = savedPendingExpressions; if (pendingStatements && some(staticProperties)) { - addInitializedPropertyStatements(pendingStatements, staticProperties, getInternalName(node)); + addPropertyStatements(pendingStatements, staticProperties, getInternalName(node)); } return classExpression; } @@ -266,8 +268,8 @@ namespace ts { function transformConstructor(node: ClassDeclaration | ClassExpression, isDerivedClass: boolean) { const constructor = visitNode(getFirstConstructorWithBody(node), visitor, isConstructorDeclaration); - const containsPropertyInitializer = forEach(node.members, isInitializedProperty); - if (!containsPropertyInitializer) { + const containsProperty = forEach(node.members, m => isInitializedProperty(m, /*requireInitializer*/ !context.getCompilerOptions().useDefineForClassFields)); + if (!containsProperty) { return constructor; } const parameters = visitParameterList(constructor ? constructor.parameters : undefined, visitor, context); @@ -292,7 +294,7 @@ namespace ts { } function transformConstructorBody(node: ClassDeclaration | ClassExpression, constructor: ConstructorDeclaration | undefined, isDerivedClass: boolean) { - const properties = getInitializedProperties(node, /*isStatic*/ false); + const properties = getProperties(node, /*requireInitializer*/ !context.getCompilerOptions().useDefineForClassFields, /*isStatic*/ false); // Only generate synthetic constructor when there are property initializers to move. if (!constructor && !some(properties)) { @@ -349,7 +351,7 @@ namespace ts { indexOfFirstStatement += parameterPropertyDeclarationCount; } } - addInitializedPropertyStatements(statements, properties, createThis()); + addPropertyStatements(statements, properties, createThis()); // Add existing statements, skipping the initial super call. if (constructor) { @@ -376,7 +378,7 @@ namespace ts { * @param properties An array of property declarations to transform. * @param receiver The receiver on which each property should be assigned. */ - function addInitializedPropertyStatements(statements: Statement[], properties: readonly PropertyDeclaration[], receiver: LeftHandSideExpression) { + function addPropertyStatements(statements: Statement[], properties: readonly PropertyDeclaration[], receiver: LeftHandSideExpression) { for (const property of properties) { const statement = createExpressionStatement(transformInitializedProperty(property, receiver)); setSourceMapRange(statement, moveRangePastModifiers(property)); @@ -414,13 +416,23 @@ namespace ts { */ function transformInitializedProperty(property: PropertyDeclaration, receiver: LeftHandSideExpression) { // We generate a name here in order to reuse the value cached by the relocated computed name expression (which uses the same generated name) + const emitAssignment = !context.getCompilerOptions().useDefineForClassFields; const propertyName = isComputedPropertyName(property.name) && !isSimpleInlineableExpression(property.name.expression) ? updateComputedPropertyName(property.name, getGeneratedNameForNode(property.name)) : property.name; - const initializer = visitNode(property.initializer, visitor, isExpression); - const memberAccess = createMemberAccessForPropertyName(receiver, propertyName, /*location*/ propertyName); - return createAssignment(memberAccess, initializer); + const initializer = property.initializer || emitAssignment ? visitNode(property.initializer, visitor, isExpression) : createVoidZero(); + if (emitAssignment) { + const memberAccess = createMemberAccessForPropertyName(receiver, propertyName, /*location*/ propertyName); + return createAssignment(memberAccess, initializer); + } + else { + const name = isComputedPropertyName(propertyName) ? propertyName.expression + : isIdentifier(propertyName) ? createStringLiteral(unescapeLeadingUnderscores(propertyName.escapedText)) + : propertyName; + const descriptor = createPropertyDescriptor({ value: initializer, configurable: true, writable: true, enumerable: true }); + return createObjectDefinePropertyCall(receiver, name, descriptor); + } } function enableSubstitutionForClassAliases() { diff --git a/src/compiler/transformers/declarations.ts b/src/compiler/transformers/declarations.ts index 2b2a75e3c24c3..add17449edf3d 100644 --- a/src/compiler/transformers/declarations.ts +++ b/src/compiler/transformers/declarations.ts @@ -86,7 +86,6 @@ namespace ts { let emittedImports: readonly AnyImportSyntax[] | undefined; // must be declared in container so it can be `undefined` while transformer's first pass const resolver = context.getEmitResolver(); const options = context.getCompilerOptions(); - const newLine = getNewLineCharacter(options); const { noResolve, stripInternal } = options; return transformRoot; @@ -861,35 +860,25 @@ namespace ts { return cleanup(sig); } case SyntaxKind.GetAccessor: { - // For now, only emit class accessors as accessors if they were already declared in an ambient context. - if (input.flags & NodeFlags.Ambient) { - const isPrivate = hasModifier(input, ModifierFlags.Private); - const accessorType = getTypeAnnotationFromAllAccessorDeclarations(input, resolver.getAllAccessorDeclarations(input)); - return cleanup(updateGetAccessor( - input, - /*decorators*/ undefined, - ensureModifiers(input), - input.name, - updateAccessorParamsList(input, isPrivate), - !isPrivate ? ensureType(input, accessorType) : undefined, - /*body*/ undefined)); - } - const newNode = ensureAccessor(input); - return cleanup(newNode); + const isPrivate = hasModifier(input, ModifierFlags.Private); + const accessorType = getTypeAnnotationFromAllAccessorDeclarations(input, resolver.getAllAccessorDeclarations(input)); + return cleanup(updateGetAccessor( + input, + /*decorators*/ undefined, + ensureModifiers(input), + input.name, + updateAccessorParamsList(input, isPrivate), + !isPrivate ? ensureType(input, accessorType) : undefined, + /*body*/ undefined)); } case SyntaxKind.SetAccessor: { - // For now, only emit class accessors as accessors if they were already declared in an ambient context. - if (input.flags & NodeFlags.Ambient) { - return cleanup(updateSetAccessor( - input, - /*decorators*/ undefined, - ensureModifiers(input), - input.name, - updateAccessorParamsList(input, hasModifier(input, ModifierFlags.Private)), - /*body*/ undefined)); - } - const newNode = ensureAccessor(input); - return cleanup(newNode); + return cleanup(updateSetAccessor( + input, + /*decorators*/ undefined, + ensureModifiers(input), + input.name, + updateAccessorParamsList(input, hasModifier(input, ModifierFlags.Private)), + /*body*/ undefined)); } case SyntaxKind.PropertyDeclaration: return cleanup(updateProperty( @@ -1462,36 +1451,6 @@ namespace ts { return accessorType; } - function ensureAccessor(node: AccessorDeclaration): PropertyDeclaration | undefined { - const accessors = resolver.getAllAccessorDeclarations(node); - if (node.kind !== accessors.firstAccessor.kind) { - return; - } - const accessorType = getTypeAnnotationFromAllAccessorDeclarations(node, accessors); - const prop = createProperty(/*decorators*/ undefined, maskModifiers(node, /*mask*/ undefined, (!accessors.setAccessor) ? ModifierFlags.Readonly : ModifierFlags.None), node.name, node.questionToken, ensureType(node, accessorType), /*initializer*/ undefined); - const leadingsSyntheticCommentRanges = accessors.secondAccessor && getLeadingCommentRangesOfNode(accessors.secondAccessor, currentSourceFile); - if (leadingsSyntheticCommentRanges) { - for (const range of leadingsSyntheticCommentRanges) { - if (range.kind === SyntaxKind.MultiLineCommentTrivia) { - let text = currentSourceFile.text.slice(range.pos + 2, range.end - 2); - const lines = text.split(/\r\n?|\n/g); - if (lines.length > 1) { - const lastLines = lines.slice(1); - const indentation = guessIndentation(lastLines); - text = [lines[0], ...map(lastLines, l => l.slice(indentation))].join(newLine); - } - addSyntheticLeadingComment( - prop, - range.kind, - text, - range.hasTrailingNewLine - ); - } - } - } - return prop; - } - function transformHeritageClauses(nodes: NodeArray | undefined) { return createNodeArray(filter(map(nodes, clause => updateHeritageClause(clause, visitNodes(createNodeArray(filter(clause.types, t => { return isEntityNameExpression(t.expression) || (clause.token === SyntaxKind.ExtendsKeyword && t.expression.kind === SyntaxKind.NullKeyword); diff --git a/src/compiler/transformers/es2015.ts b/src/compiler/transformers/es2015.ts index 2a50943cb8082..2684b1acdd554 100644 --- a/src/compiler/transformers/es2015.ts +++ b/src/compiler/transformers/es2015.ts @@ -1591,17 +1591,22 @@ namespace ts { function transformClassMethodDeclarationToStatement(receiver: LeftHandSideExpression, member: MethodDeclaration, container: Node) { const commentRange = getCommentRange(member); const sourceMapRange = getSourceMapRange(member); - const memberName = createMemberAccessForPropertyName(receiver, visitNode(member.name, visitor, isPropertyName), /*location*/ member.name); const memberFunction = transformFunctionLikeToExpression(member, /*location*/ member, /*name*/ undefined, container); + let e: Expression; + if (context.getCompilerOptions().useDefineForClassFields) { + const propertyName = visitNode(member.name, visitor, isPropertyName); + const name = isComputedPropertyName(propertyName) ? propertyName.expression + : isIdentifier(propertyName) ? createStringLiteral(unescapeLeadingUnderscores(propertyName.escapedText)) + : propertyName; + e = createObjectDefinePropertyCall(receiver, name, createPropertyDescriptor({ value: memberFunction, enumerable: false, writable: true, configurable: true })); + } + else { + const memberName = createMemberAccessForPropertyName(receiver, visitNode(member.name, visitor, isPropertyName), /*location*/ member.name); + e = createAssignment(memberName, memberFunction); + } setEmitFlags(memberFunction, EmitFlags.NoComments); setSourceMapRange(memberFunction, sourceMapRange); - - const statement = setTextRange( - createExpressionStatement( - createAssignment(memberName, memberFunction) - ), - /*location*/ member - ); + const statement = setTextRange(createExpressionStatement(e), /*location*/ member); setOriginalNode(statement, member); setCommentRange(statement, commentRange); diff --git a/src/compiler/transformers/ts.ts b/src/compiler/transformers/ts.ts index 06b3fb53ec180..ddb545f0eb575 100644 --- a/src/compiler/transformers/ts.ts +++ b/src/compiler/transformers/ts.ts @@ -610,7 +610,7 @@ namespace ts { return visitEachChild(node, visitor, context); } - const staticProperties = getInitializedProperties(node, /*isStatic*/ true); + const staticProperties = getProperties(node, /*requireInitializer*/ true, /*isStatic*/ true); const facts = getClassFacts(node, staticProperties); if (facts & ClassFacts.UseImmediatelyInvokedFunctionExpression) { diff --git a/src/compiler/transformers/utilities.ts b/src/compiler/transformers/utilities.ts index de4400a24f45d..e2029ff7b602e 100644 --- a/src/compiler/transformers/utilities.ts +++ b/src/compiler/transformers/utilities.ts @@ -297,41 +297,29 @@ namespace ts { } /** - * Gets all property declarations with initializers on either the static or instance side of a class. + * Gets all the static or all the instance property declarations of a class * * @param node The class node. * @param isStatic A value indicating whether to get properties from the static or instance side of the class. */ - export function getInitializedProperties(node: ClassExpression | ClassDeclaration, isStatic: boolean): readonly PropertyDeclaration[] { - return filter(node.members, isStatic ? isStaticInitializedProperty : isInstanceInitializedProperty); + export function getProperties(node: ClassExpression | ClassDeclaration, requireInitializer: boolean, isStatic: boolean): readonly PropertyDeclaration[] { + return filter(node.members, m => isInitializedOrStaticProperty(m, requireInitializer, isStatic)) as PropertyDeclaration[]; } /** - * Gets a value indicating whether a class element is a static property declaration with an initializer. + * Is a class element either a static or an instance property declaration with an initializer? * * @param member The class element node. + * @param isStatic A value indicating whether the member should be a static or instance member. */ - export function isStaticInitializedProperty(member: ClassElement): member is PropertyDeclaration & { initializer: Expression; } { - return isInitializedProperty(member) && hasStaticModifier(member); + function isInitializedOrStaticProperty(member: ClassElement, requireInitializer: boolean, isStatic: boolean) { + return isPropertyDeclaration(member) + && (!!member.initializer || !requireInitializer) + && hasStaticModifier(member) === isStatic; } - /** - * Gets a value indicating whether a class element is an instance property declaration with an initializer. - * - * @param member The class element node. - */ - export function isInstanceInitializedProperty(member: ClassElement): member is PropertyDeclaration & { initializer: Expression; } { - return isInitializedProperty(member) && !hasStaticModifier(member); + export function isInitializedProperty(member: ClassElement, requireInitializer: boolean): member is PropertyDeclaration { + return isPropertyDeclaration(member) && (!!member.initializer || !requireInitializer); } - /** - * Gets a value indicating whether a class element is either a static or an instance property declaration with an initializer. - * - * @param member The class element node. - * @param isStatic A value indicating whether the member should be a static or instance member. - */ - export function isInitializedProperty(member: ClassElement): member is PropertyDeclaration & { initializer: Expression; } { - return member.kind === SyntaxKind.PropertyDeclaration - && (member).initializer !== undefined; - } -} \ No newline at end of file +} diff --git a/src/compiler/types.ts b/src/compiler/types.ts index a10b42b849534..28d5fdbb1c967 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -4870,6 +4870,7 @@ namespace ts { /*@internal*/ watch?: boolean; esModuleInterop?: boolean; /* @internal */ showConfig?: boolean; + useDefineForClassFields?: boolean; [option: string]: CompilerOptionsValue | TsConfigSourceFile | undefined; } @@ -5572,6 +5573,16 @@ namespace ts { readonly redirectTargetsMap: RedirectTargetsMap; } + /* @internal */ + export interface PropertyDescriptorAttributes { + enumerable?: boolean | Expression; + configurable?: boolean | Expression; + writable?: boolean | Expression; + value?: Expression; + get?: Expression; + set?: Expression; + } + export interface TransformationContext { /*@internal*/ getEmitResolver(): EmitResolver; /*@internal*/ getEmitHost(): EmitHost; diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index 63c6bb301b4e6..a00b7c2d7ad97 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -3956,7 +3956,6 @@ namespace ts { } export function getModifierFlagsNoCache(node: Node): ModifierFlags { - let flags = ModifierFlags.None; if (node.modifiers) { for (const modifier of node.modifiers) { diff --git a/src/server/protocol.ts b/src/server/protocol.ts index 0ec27a3a2bb38..01c8434228f9d 100644 --- a/src/server/protocol.ts +++ b/src/server/protocol.ts @@ -3074,6 +3074,7 @@ namespace ts.server.protocol { strictNullChecks?: boolean; suppressExcessPropertyErrors?: boolean; suppressImplicitAnyIndexErrors?: boolean; + useDefineForClassFields?: boolean; target?: ScriptTarget | ts.ScriptTarget; traceResolution?: boolean; resolveJsonModule?: boolean; diff --git a/src/services/codefixes/addMissingDeclareProperty.ts b/src/services/codefixes/addMissingDeclareProperty.ts new file mode 100644 index 0000000000000..e08929b9dd132 --- /dev/null +++ b/src/services/codefixes/addMissingDeclareProperty.ts @@ -0,0 +1,34 @@ +/* @internal */ +namespace ts.codefix { + const fixId = "addMissingDeclareProperty"; + const errorCodes = [ + Diagnostics.Property_0_will_overwrite_the_base_property_in_1_If_this_is_intentional_add_an_initializer_Otherwise_add_a_declare_modifier_or_remove_the_redundant_declaration.code, + ]; + + registerCodeFix({ + errorCodes, + getCodeActions: (context) => { + const changes = textChanges.ChangeTracker.with(context, t => makeChange(t, context.sourceFile, context.span.start)); + if (changes.length > 0) { + return [createCodeFixAction(fixId, changes, Diagnostics.Prefix_with_declare, fixId, Diagnostics.Prefix_all_incorrect_property_declarations_with_declare)]; + } + }, + fixIds: [fixId], + getAllCodeActions: context => { + const fixedNodes = new NodeSet(); + return codeFixAll(context, errorCodes, (changes, diag) => makeChange(changes, diag.file, diag.start, fixedNodes)); + }, + }); + + function makeChange(changeTracker: textChanges.ChangeTracker, sourceFile: SourceFile, pos: number, fixedNodes?: NodeSet) { + const token = getTokenAtPosition(sourceFile, pos); + if (!isIdentifier(token)) { + return; + } + const declaration = token.parent; + if (declaration.kind === SyntaxKind.PropertyDeclaration && + (!fixedNodes || fixedNodes.tryAdd(declaration))) { + changeTracker.insertModifierBefore(sourceFile, SyntaxKind.DeclareKeyword, declaration); + } + } +} diff --git a/src/services/services.ts b/src/services/services.ts index d9445256ae2c0..20506e3417321 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -339,7 +339,6 @@ namespace ts { } class TokenObject extends TokenOrIdentifierObject implements Token { - public symbol!: Symbol; public kind: TKind; constructor(kind: TKind, pos: number, end: number) { @@ -349,9 +348,8 @@ namespace ts { } class IdentifierObject extends TokenOrIdentifierObject implements Identifier { - public kind!: SyntaxKind.Identifier; + public kind: SyntaxKind.Identifier = SyntaxKind.Identifier; public escapedText!: __String; - public symbol!: Symbol; public autoGenerateFlags!: GeneratedIdentifierFlags; _primaryExpressionBrand: any; _memberExpressionBrand: any; @@ -541,7 +539,7 @@ namespace ts { } class SourceFileObject extends NodeObject implements SourceFile { - public kind!: SyntaxKind.SourceFile; + public kind: SyntaxKind.SourceFile = SyntaxKind.SourceFile; public _declarationBrand: any; public fileName!: string; public path!: Path; diff --git a/src/services/tsconfig.json b/src/services/tsconfig.json index b90607b0a85a3..5c0e39f9f6564 100644 --- a/src/services/tsconfig.json +++ b/src/services/tsconfig.json @@ -47,6 +47,7 @@ "codefixes/addConvertToUnknownForNonOverlappingTypes.ts", "codefixes/addMissingAwait.ts", "codefixes/addMissingConst.ts", + "codefixes/addMissingDeclareProperty.ts", "codefixes/addMissingInvocationForDecorator.ts", "codefixes/addNameToNamelessParameter.ts", "codefixes/annotateWithTypeFromJSDoc.ts", diff --git a/src/testRunner/parallel/host.ts b/src/testRunner/parallel/host.ts index 56fa17dd9e1ce..89264224c13a6 100644 --- a/src/testRunner/parallel/host.ts +++ b/src/testRunner/parallel/host.ts @@ -24,9 +24,7 @@ namespace Harness.Parallel.Host { let totalCost = 0; class RemoteSuite extends Mocha.Suite { - suites!: RemoteSuite[]; suiteMap = ts.createMap(); - tests!: RemoteTest[]; constructor(title: string) { super(title); this.pending = false; @@ -529,10 +527,10 @@ namespace Harness.Parallel.Host { function replaySuite(runner: Mocha.Runner, suite: RemoteSuite) { runner.emit("suite", suite); for (const test of suite.tests) { - replayTest(runner, test); + replayTest(runner, test as RemoteTest); } for (const child of suite.suites) { - replaySuite(runner, child); + replaySuite(runner, child as RemoteSuite); } runner.emit("suite end", suite); } diff --git a/src/testRunner/unittests/tsserver/helpers.ts b/src/testRunner/unittests/tsserver/helpers.ts index a8c79d0b60347..71280330e8cd7 100644 --- a/src/testRunner/unittests/tsserver/helpers.ts +++ b/src/testRunner/unittests/tsserver/helpers.ts @@ -292,7 +292,7 @@ namespace ts.projectSystem { export class TestSession extends server.Session { private seq = 0; public events: protocol.Event[] = []; - public host!: TestServerHost; + public testhost: TestServerHost = this.host as TestServerHost; getProjectService() { return this.projectService; @@ -320,7 +320,7 @@ namespace ts.projectSystem { public clearMessages() { clear(this.events); - this.host.clearOutput(); + this.testhost.clearOutput(); } } @@ -721,8 +721,8 @@ namespace ts.projectSystem { const events = session.events; assert.deepEqual(events[index], expectedEvent, `Expected ${JSON.stringify(expectedEvent)} at ${index} in ${JSON.stringify(events)}`); - const outputs = session.host.getOutput(); - assert.equal(outputs[index], server.formatMessage(expectedEvent, nullLogger, Utils.byteLength, session.host.newLine)); + const outputs = session.testhost.getOutput(); + assert.equal(outputs[index], server.formatMessage(expectedEvent, nullLogger, Utils.byteLength, session.testhost.newLine)); if (isMostRecent) { assert.strictEqual(events.length, index + 1, JSON.stringify(events)); diff --git a/src/testRunner/unittests/tsserver/symLinks.ts b/src/testRunner/unittests/tsserver/symLinks.ts index c264bc2a6df09..54b7cb3fab427 100644 --- a/src/testRunner/unittests/tsserver/symLinks.ts +++ b/src/testRunner/unittests/tsserver/symLinks.ts @@ -159,7 +159,7 @@ new C();` } }); - const host = session.host; + const host = session.testhost; host.checkTimeoutQueueLengthAndRun(1); checkErrorMessage(session, "syntaxDiag", { file: recognizersDateTimeSrcFile.path, diagnostics: [] }); @@ -219,7 +219,7 @@ new C();` const projectService = session.getProjectService(); const project = projectService.configuredProjects.get(recognizerDateTimeTsconfigPath)!; checkProjectActualFiles(project, filesInProjectWithResolvedModule); - verifyWatchedFilesAndDirectories(session.host, filesInProjectWithResolvedModule, watchedDirectoriesWithResolvedModule, nonRecursiveWatchedDirectories); + verifyWatchedFilesAndDirectories(session.testhost, filesInProjectWithResolvedModule, watchedDirectoriesWithResolvedModule, nonRecursiveWatchedDirectories); verifyErrors(session, []); } @@ -227,7 +227,7 @@ new C();` const projectService = session.getProjectService(); const project = projectService.configuredProjects.get(recognizerDateTimeTsconfigPath)!; checkProjectActualFiles(project, filesInProjectWithUnresolvedModule); - verifyWatchedFilesAndDirectories(session.host, filesInProjectWithUnresolvedModule, watchedDirectoriesWithUnresolvedModule, nonRecursiveWatchedDirectories); + verifyWatchedFilesAndDirectories(session.testhost, filesInProjectWithUnresolvedModule, watchedDirectoriesWithUnresolvedModule, nonRecursiveWatchedDirectories); const startOffset = recognizersDateTimeSrcFile.content.indexOf('"') + 1; verifyErrors(session, [ createDiagnostic({ line: 1, offset: startOffset }, { line: 1, offset: startOffset + moduleNameInFile.length }, Diagnostics.Cannot_find_module_0, [moduleName]) diff --git a/tests/baselines/reference/accessorsOverrideMethod.errors.txt b/tests/baselines/reference/accessorsOverrideMethod.errors.txt new file mode 100644 index 0000000000000..2ff047d49be36 --- /dev/null +++ b/tests/baselines/reference/accessorsOverrideMethod.errors.txt @@ -0,0 +1,13 @@ +tests/cases/conformance/classes/propertyMemberDeclarations/accessorsOverrideMethod.ts(5,9): error TS2423: Class 'A' defines instance member function 'm', but extended class 'B' defines it as instance member accessor. + + +==== tests/cases/conformance/classes/propertyMemberDeclarations/accessorsOverrideMethod.ts (1 errors) ==== + class A { + m() { } + } + class B extends A { + get m() { return () => 1 } + ~ +!!! error TS2423: Class 'A' defines instance member function 'm', but extended class 'B' defines it as instance member accessor. + } + \ No newline at end of file diff --git a/tests/baselines/reference/accessorsOverrideMethod.js b/tests/baselines/reference/accessorsOverrideMethod.js new file mode 100644 index 0000000000000..0b7d62391909b --- /dev/null +++ b/tests/baselines/reference/accessorsOverrideMethod.js @@ -0,0 +1,16 @@ +//// [accessorsOverrideMethod.ts] +class A { + m() { } +} +class B extends A { + get m() { return () => 1 } +} + + +//// [accessorsOverrideMethod.js] +class A { + m() { } +} +class B extends A { + get m() { return () => 1; } +} diff --git a/tests/baselines/reference/accessorsOverrideMethod.symbols b/tests/baselines/reference/accessorsOverrideMethod.symbols new file mode 100644 index 0000000000000..d447c137acff4 --- /dev/null +++ b/tests/baselines/reference/accessorsOverrideMethod.symbols @@ -0,0 +1,15 @@ +=== tests/cases/conformance/classes/propertyMemberDeclarations/accessorsOverrideMethod.ts === +class A { +>A : Symbol(A, Decl(accessorsOverrideMethod.ts, 0, 0)) + + m() { } +>m : Symbol(A.m, Decl(accessorsOverrideMethod.ts, 0, 9)) +} +class B extends A { +>B : Symbol(B, Decl(accessorsOverrideMethod.ts, 2, 1)) +>A : Symbol(A, Decl(accessorsOverrideMethod.ts, 0, 0)) + + get m() { return () => 1 } +>m : Symbol(B.m, Decl(accessorsOverrideMethod.ts, 3, 19)) +} + diff --git a/tests/baselines/reference/accessorsOverrideMethod.types b/tests/baselines/reference/accessorsOverrideMethod.types new file mode 100644 index 0000000000000..a8781ae41a99b --- /dev/null +++ b/tests/baselines/reference/accessorsOverrideMethod.types @@ -0,0 +1,17 @@ +=== tests/cases/conformance/classes/propertyMemberDeclarations/accessorsOverrideMethod.ts === +class A { +>A : A + + m() { } +>m : () => void +} +class B extends A { +>B : B +>A : A + + get m() { return () => 1 } +>m : () => number +>() => 1 : () => number +>1 : 1 +} + diff --git a/tests/baselines/reference/accessorsOverrideProperty.errors.txt b/tests/baselines/reference/accessorsOverrideProperty.errors.txt new file mode 100644 index 0000000000000..cda030610b543 --- /dev/null +++ b/tests/baselines/reference/accessorsOverrideProperty.errors.txt @@ -0,0 +1,24 @@ +tests/cases/conformance/classes/propertyMemberDeclarations/accessorsOverrideProperty.ts(5,9): error TS2611: Class 'A' defines instance member property 'p', but extended class 'B' defines it as instance member accessor. +tests/cases/conformance/classes/propertyMemberDeclarations/accessorsOverrideProperty.ts(12,9): error TS2611: Class 'C' defines instance member property 'p', but extended class 'D' defines it as instance member accessor. + + +==== tests/cases/conformance/classes/propertyMemberDeclarations/accessorsOverrideProperty.ts (2 errors) ==== + class A { + p = 'yep' + } + class B extends A { + get p() { return 'oh no' } // error + ~ +!!! error TS2611: Class 'A' defines instance member property 'p', but extended class 'B' defines it as instance member accessor. + } + class C { + p = 101 + } + class D extends C { + _secret = 11 + get p() { return this._secret } // error + ~ +!!! error TS2611: Class 'C' defines instance member property 'p', but extended class 'D' defines it as instance member accessor. + set p(value) { this._secret = value } // error + } + \ No newline at end of file diff --git a/tests/baselines/reference/accessorsOverrideProperty.js b/tests/baselines/reference/accessorsOverrideProperty.js new file mode 100644 index 0000000000000..5e9b94457ca41 --- /dev/null +++ b/tests/baselines/reference/accessorsOverrideProperty.js @@ -0,0 +1,32 @@ +//// [accessorsOverrideProperty.ts] +class A { + p = 'yep' +} +class B extends A { + get p() { return 'oh no' } // error +} +class C { + p = 101 +} +class D extends C { + _secret = 11 + get p() { return this._secret } // error + set p(value) { this._secret = value } // error +} + + +//// [accessorsOverrideProperty.js] +class A { + p = 'yep'; +} +class B extends A { + get p() { return 'oh no'; } // error +} +class C { + p = 101; +} +class D extends C { + _secret = 11; + get p() { return this._secret; } // error + set p(value) { this._secret = value; } // error +} diff --git a/tests/baselines/reference/accessorsOverrideProperty.symbols b/tests/baselines/reference/accessorsOverrideProperty.symbols new file mode 100644 index 0000000000000..702417679a316 --- /dev/null +++ b/tests/baselines/reference/accessorsOverrideProperty.symbols @@ -0,0 +1,42 @@ +=== tests/cases/conformance/classes/propertyMemberDeclarations/accessorsOverrideProperty.ts === +class A { +>A : Symbol(A, Decl(accessorsOverrideProperty.ts, 0, 0)) + + p = 'yep' +>p : Symbol(A.p, Decl(accessorsOverrideProperty.ts, 0, 9)) +} +class B extends A { +>B : Symbol(B, Decl(accessorsOverrideProperty.ts, 2, 1)) +>A : Symbol(A, Decl(accessorsOverrideProperty.ts, 0, 0)) + + get p() { return 'oh no' } // error +>p : Symbol(B.p, Decl(accessorsOverrideProperty.ts, 3, 19)) +} +class C { +>C : Symbol(C, Decl(accessorsOverrideProperty.ts, 5, 1)) + + p = 101 +>p : Symbol(C.p, Decl(accessorsOverrideProperty.ts, 6, 9)) +} +class D extends C { +>D : Symbol(D, Decl(accessorsOverrideProperty.ts, 8, 1)) +>C : Symbol(C, Decl(accessorsOverrideProperty.ts, 5, 1)) + + _secret = 11 +>_secret : Symbol(D._secret, Decl(accessorsOverrideProperty.ts, 9, 19)) + + get p() { return this._secret } // error +>p : Symbol(D.p, Decl(accessorsOverrideProperty.ts, 10, 17), Decl(accessorsOverrideProperty.ts, 11, 35)) +>this._secret : Symbol(D._secret, Decl(accessorsOverrideProperty.ts, 9, 19)) +>this : Symbol(D, Decl(accessorsOverrideProperty.ts, 8, 1)) +>_secret : Symbol(D._secret, Decl(accessorsOverrideProperty.ts, 9, 19)) + + set p(value) { this._secret = value } // error +>p : Symbol(D.p, Decl(accessorsOverrideProperty.ts, 10, 17), Decl(accessorsOverrideProperty.ts, 11, 35)) +>value : Symbol(value, Decl(accessorsOverrideProperty.ts, 12, 10)) +>this._secret : Symbol(D._secret, Decl(accessorsOverrideProperty.ts, 9, 19)) +>this : Symbol(D, Decl(accessorsOverrideProperty.ts, 8, 1)) +>_secret : Symbol(D._secret, Decl(accessorsOverrideProperty.ts, 9, 19)) +>value : Symbol(value, Decl(accessorsOverrideProperty.ts, 12, 10)) +} + diff --git a/tests/baselines/reference/accessorsOverrideProperty.types b/tests/baselines/reference/accessorsOverrideProperty.types new file mode 100644 index 0000000000000..4e3021e70243f --- /dev/null +++ b/tests/baselines/reference/accessorsOverrideProperty.types @@ -0,0 +1,47 @@ +=== tests/cases/conformance/classes/propertyMemberDeclarations/accessorsOverrideProperty.ts === +class A { +>A : A + + p = 'yep' +>p : string +>'yep' : "yep" +} +class B extends A { +>B : B +>A : A + + get p() { return 'oh no' } // error +>p : string +>'oh no' : "oh no" +} +class C { +>C : C + + p = 101 +>p : number +>101 : 101 +} +class D extends C { +>D : D +>C : C + + _secret = 11 +>_secret : number +>11 : 11 + + get p() { return this._secret } // error +>p : number +>this._secret : number +>this : this +>_secret : number + + set p(value) { this._secret = value } // error +>p : number +>value : number +>this._secret = value : number +>this._secret : number +>this : this +>_secret : number +>value : number +} + diff --git a/tests/baselines/reference/accessorsOverrideProperty2.errors.txt b/tests/baselines/reference/accessorsOverrideProperty2.errors.txt new file mode 100644 index 0000000000000..ee26b16f7c906 --- /dev/null +++ b/tests/baselines/reference/accessorsOverrideProperty2.errors.txt @@ -0,0 +1,18 @@ +tests/cases/conformance/classes/propertyMemberDeclarations/accessorsOverrideProperty2.ts(6,7): error TS2611: Class 'Base' defines instance member property 'x', but extended class 'Derived' defines it as instance member accessor. + + +==== tests/cases/conformance/classes/propertyMemberDeclarations/accessorsOverrideProperty2.ts (1 errors) ==== + class Base { + x = 1; + } + + class Derived extends Base { + get x() { return 2; } // should be an error + ~ +!!! error TS2611: Class 'Base' defines instance member property 'x', but extended class 'Derived' defines it as instance member accessor. + set x(value) { console.log(`x was set to ${value}`); } + } + + const obj = new Derived(); // nothing printed + console.log(obj.x); // 1 + \ No newline at end of file diff --git a/tests/baselines/reference/accessorsOverrideProperty2.js b/tests/baselines/reference/accessorsOverrideProperty2.js new file mode 100644 index 0000000000000..e16ae60363e36 --- /dev/null +++ b/tests/baselines/reference/accessorsOverrideProperty2.js @@ -0,0 +1,24 @@ +//// [accessorsOverrideProperty2.ts] +class Base { + x = 1; +} + +class Derived extends Base { + get x() { return 2; } // should be an error + set x(value) { console.log(`x was set to ${value}`); } +} + +const obj = new Derived(); // nothing printed +console.log(obj.x); // 1 + + +//// [accessorsOverrideProperty2.js] +class Base { + x = 1; +} +class Derived extends Base { + get x() { return 2; } // should be an error + set x(value) { console.log(`x was set to ${value}`); } +} +const obj = new Derived(); // nothing printed +console.log(obj.x); // 1 diff --git a/tests/baselines/reference/accessorsOverrideProperty2.symbols b/tests/baselines/reference/accessorsOverrideProperty2.symbols new file mode 100644 index 0000000000000..eab967402566b --- /dev/null +++ b/tests/baselines/reference/accessorsOverrideProperty2.symbols @@ -0,0 +1,36 @@ +=== tests/cases/conformance/classes/propertyMemberDeclarations/accessorsOverrideProperty2.ts === +class Base { +>Base : Symbol(Base, Decl(accessorsOverrideProperty2.ts, 0, 0)) + + x = 1; +>x : Symbol(Base.x, Decl(accessorsOverrideProperty2.ts, 0, 12)) +} + +class Derived extends Base { +>Derived : Symbol(Derived, Decl(accessorsOverrideProperty2.ts, 2, 1)) +>Base : Symbol(Base, Decl(accessorsOverrideProperty2.ts, 0, 0)) + + get x() { return 2; } // should be an error +>x : Symbol(Derived.x, Decl(accessorsOverrideProperty2.ts, 4, 28), Decl(accessorsOverrideProperty2.ts, 5, 23)) + + set x(value) { console.log(`x was set to ${value}`); } +>x : Symbol(Derived.x, Decl(accessorsOverrideProperty2.ts, 4, 28), Decl(accessorsOverrideProperty2.ts, 5, 23)) +>value : Symbol(value, Decl(accessorsOverrideProperty2.ts, 6, 8)) +>console.log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --)) +>console : Symbol(console, Decl(lib.dom.d.ts, --, --)) +>log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --)) +>value : Symbol(value, Decl(accessorsOverrideProperty2.ts, 6, 8)) +} + +const obj = new Derived(); // nothing printed +>obj : Symbol(obj, Decl(accessorsOverrideProperty2.ts, 9, 5)) +>Derived : Symbol(Derived, Decl(accessorsOverrideProperty2.ts, 2, 1)) + +console.log(obj.x); // 1 +>console.log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --)) +>console : Symbol(console, Decl(lib.dom.d.ts, --, --)) +>log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --)) +>obj.x : Symbol(Derived.x, Decl(accessorsOverrideProperty2.ts, 4, 28), Decl(accessorsOverrideProperty2.ts, 5, 23)) +>obj : Symbol(obj, Decl(accessorsOverrideProperty2.ts, 9, 5)) +>x : Symbol(Derived.x, Decl(accessorsOverrideProperty2.ts, 4, 28), Decl(accessorsOverrideProperty2.ts, 5, 23)) + diff --git a/tests/baselines/reference/accessorsOverrideProperty2.types b/tests/baselines/reference/accessorsOverrideProperty2.types new file mode 100644 index 0000000000000..f094ab56040e0 --- /dev/null +++ b/tests/baselines/reference/accessorsOverrideProperty2.types @@ -0,0 +1,42 @@ +=== tests/cases/conformance/classes/propertyMemberDeclarations/accessorsOverrideProperty2.ts === +class Base { +>Base : Base + + x = 1; +>x : number +>1 : 1 +} + +class Derived extends Base { +>Derived : Derived +>Base : Base + + get x() { return 2; } // should be an error +>x : number +>2 : 2 + + set x(value) { console.log(`x was set to ${value}`); } +>x : number +>value : number +>console.log(`x was set to ${value}`) : void +>console.log : (message?: any, ...optionalParams: any[]) => void +>console : Console +>log : (message?: any, ...optionalParams: any[]) => void +>`x was set to ${value}` : string +>value : number +} + +const obj = new Derived(); // nothing printed +>obj : Derived +>new Derived() : Derived +>Derived : typeof Derived + +console.log(obj.x); // 1 +>console.log(obj.x) : void +>console.log : (message?: any, ...optionalParams: any[]) => void +>console : Console +>log : (message?: any, ...optionalParams: any[]) => void +>obj.x : number +>obj : Derived +>x : number + diff --git a/tests/baselines/reference/accessorsOverrideProperty3.errors.txt b/tests/baselines/reference/accessorsOverrideProperty3.errors.txt new file mode 100644 index 0000000000000..129af97f9b573 --- /dev/null +++ b/tests/baselines/reference/accessorsOverrideProperty3.errors.txt @@ -0,0 +1,15 @@ +tests/cases/conformance/classes/propertyMemberDeclarations/accessorsOverrideProperty3.ts(6,9): error TS2611: Class 'Animal' defines instance member property 'sound', but extended class 'Lion' defines it as instance member accessor. + + +==== tests/cases/conformance/classes/propertyMemberDeclarations/accessorsOverrideProperty3.ts (1 errors) ==== + declare class Animal { + sound: string + } + class Lion extends Animal { + _sound = 'grrr' + get sound() { return this._sound } // error here + ~~~~~ +!!! error TS2611: Class 'Animal' defines instance member property 'sound', but extended class 'Lion' defines it as instance member accessor. + set sound(val) { this._sound = val } + } + \ No newline at end of file diff --git a/tests/baselines/reference/accessorsOverrideProperty3.js b/tests/baselines/reference/accessorsOverrideProperty3.js new file mode 100644 index 0000000000000..2b061298ab9a3 --- /dev/null +++ b/tests/baselines/reference/accessorsOverrideProperty3.js @@ -0,0 +1,17 @@ +//// [accessorsOverrideProperty3.ts] +declare class Animal { + sound: string +} +class Lion extends Animal { + _sound = 'grrr' + get sound() { return this._sound } // error here + set sound(val) { this._sound = val } +} + + +//// [accessorsOverrideProperty3.js] +class Lion extends Animal { + _sound = 'grrr'; + get sound() { return this._sound; } // error here + set sound(val) { this._sound = val; } +} diff --git a/tests/baselines/reference/accessorsOverrideProperty3.symbols b/tests/baselines/reference/accessorsOverrideProperty3.symbols new file mode 100644 index 0000000000000..f34923d36aad3 --- /dev/null +++ b/tests/baselines/reference/accessorsOverrideProperty3.symbols @@ -0,0 +1,29 @@ +=== tests/cases/conformance/classes/propertyMemberDeclarations/accessorsOverrideProperty3.ts === +declare class Animal { +>Animal : Symbol(Animal, Decl(accessorsOverrideProperty3.ts, 0, 0)) + + sound: string +>sound : Symbol(Animal.sound, Decl(accessorsOverrideProperty3.ts, 0, 22)) +} +class Lion extends Animal { +>Lion : Symbol(Lion, Decl(accessorsOverrideProperty3.ts, 2, 1)) +>Animal : Symbol(Animal, Decl(accessorsOverrideProperty3.ts, 0, 0)) + + _sound = 'grrr' +>_sound : Symbol(Lion._sound, Decl(accessorsOverrideProperty3.ts, 3, 27)) + + get sound() { return this._sound } // error here +>sound : Symbol(Lion.sound, Decl(accessorsOverrideProperty3.ts, 4, 19), Decl(accessorsOverrideProperty3.ts, 5, 38)) +>this._sound : Symbol(Lion._sound, Decl(accessorsOverrideProperty3.ts, 3, 27)) +>this : Symbol(Lion, Decl(accessorsOverrideProperty3.ts, 2, 1)) +>_sound : Symbol(Lion._sound, Decl(accessorsOverrideProperty3.ts, 3, 27)) + + set sound(val) { this._sound = val } +>sound : Symbol(Lion.sound, Decl(accessorsOverrideProperty3.ts, 4, 19), Decl(accessorsOverrideProperty3.ts, 5, 38)) +>val : Symbol(val, Decl(accessorsOverrideProperty3.ts, 6, 14)) +>this._sound : Symbol(Lion._sound, Decl(accessorsOverrideProperty3.ts, 3, 27)) +>this : Symbol(Lion, Decl(accessorsOverrideProperty3.ts, 2, 1)) +>_sound : Symbol(Lion._sound, Decl(accessorsOverrideProperty3.ts, 3, 27)) +>val : Symbol(val, Decl(accessorsOverrideProperty3.ts, 6, 14)) +} + diff --git a/tests/baselines/reference/accessorsOverrideProperty3.types b/tests/baselines/reference/accessorsOverrideProperty3.types new file mode 100644 index 0000000000000..6fa0efd42f5a6 --- /dev/null +++ b/tests/baselines/reference/accessorsOverrideProperty3.types @@ -0,0 +1,31 @@ +=== tests/cases/conformance/classes/propertyMemberDeclarations/accessorsOverrideProperty3.ts === +declare class Animal { +>Animal : Animal + + sound: string +>sound : string +} +class Lion extends Animal { +>Lion : Lion +>Animal : Animal + + _sound = 'grrr' +>_sound : string +>'grrr' : "grrr" + + get sound() { return this._sound } // error here +>sound : string +>this._sound : string +>this : this +>_sound : string + + set sound(val) { this._sound = val } +>sound : string +>val : string +>this._sound = val : string +>this._sound : string +>this : this +>_sound : string +>val : string +} + diff --git a/tests/baselines/reference/accessorsOverrideProperty4.errors.txt b/tests/baselines/reference/accessorsOverrideProperty4.errors.txt new file mode 100644 index 0000000000000..ca69ba6074425 --- /dev/null +++ b/tests/baselines/reference/accessorsOverrideProperty4.errors.txt @@ -0,0 +1,15 @@ +tests/cases/conformance/classes/propertyMemberDeclarations/accessorsOverrideProperty4.ts(6,9): error TS2611: Class 'Animal' defines instance member property 'sound', but extended class 'Lion' defines it as instance member accessor. + + +==== tests/cases/conformance/classes/propertyMemberDeclarations/accessorsOverrideProperty4.ts (1 errors) ==== + declare class Animal { + sound: string; + } + class Lion extends Animal { + _sound = 'roar' + get sound(): string { return this._sound } + ~~~~~ +!!! error TS2611: Class 'Animal' defines instance member property 'sound', but extended class 'Lion' defines it as instance member accessor. + set sound(val: string) { this._sound = val } + } + \ No newline at end of file diff --git a/tests/baselines/reference/accessorsOverrideProperty4.js b/tests/baselines/reference/accessorsOverrideProperty4.js new file mode 100644 index 0000000000000..28a0af827b7eb --- /dev/null +++ b/tests/baselines/reference/accessorsOverrideProperty4.js @@ -0,0 +1,17 @@ +//// [accessorsOverrideProperty4.ts] +declare class Animal { + sound: string; +} +class Lion extends Animal { + _sound = 'roar' + get sound(): string { return this._sound } + set sound(val: string) { this._sound = val } +} + + +//// [accessorsOverrideProperty4.js] +class Lion extends Animal { + _sound = 'roar'; + get sound() { return this._sound; } + set sound(val) { this._sound = val; } +} diff --git a/tests/baselines/reference/accessorsOverrideProperty4.symbols b/tests/baselines/reference/accessorsOverrideProperty4.symbols new file mode 100644 index 0000000000000..d51646d1ce558 --- /dev/null +++ b/tests/baselines/reference/accessorsOverrideProperty4.symbols @@ -0,0 +1,29 @@ +=== tests/cases/conformance/classes/propertyMemberDeclarations/accessorsOverrideProperty4.ts === +declare class Animal { +>Animal : Symbol(Animal, Decl(accessorsOverrideProperty4.ts, 0, 0)) + + sound: string; +>sound : Symbol(Animal.sound, Decl(accessorsOverrideProperty4.ts, 0, 22)) +} +class Lion extends Animal { +>Lion : Symbol(Lion, Decl(accessorsOverrideProperty4.ts, 2, 1)) +>Animal : Symbol(Animal, Decl(accessorsOverrideProperty4.ts, 0, 0)) + + _sound = 'roar' +>_sound : Symbol(Lion._sound, Decl(accessorsOverrideProperty4.ts, 3, 27)) + + get sound(): string { return this._sound } +>sound : Symbol(Lion.sound, Decl(accessorsOverrideProperty4.ts, 4, 19), Decl(accessorsOverrideProperty4.ts, 5, 46)) +>this._sound : Symbol(Lion._sound, Decl(accessorsOverrideProperty4.ts, 3, 27)) +>this : Symbol(Lion, Decl(accessorsOverrideProperty4.ts, 2, 1)) +>_sound : Symbol(Lion._sound, Decl(accessorsOverrideProperty4.ts, 3, 27)) + + set sound(val: string) { this._sound = val } +>sound : Symbol(Lion.sound, Decl(accessorsOverrideProperty4.ts, 4, 19), Decl(accessorsOverrideProperty4.ts, 5, 46)) +>val : Symbol(val, Decl(accessorsOverrideProperty4.ts, 6, 14)) +>this._sound : Symbol(Lion._sound, Decl(accessorsOverrideProperty4.ts, 3, 27)) +>this : Symbol(Lion, Decl(accessorsOverrideProperty4.ts, 2, 1)) +>_sound : Symbol(Lion._sound, Decl(accessorsOverrideProperty4.ts, 3, 27)) +>val : Symbol(val, Decl(accessorsOverrideProperty4.ts, 6, 14)) +} + diff --git a/tests/baselines/reference/accessorsOverrideProperty4.types b/tests/baselines/reference/accessorsOverrideProperty4.types new file mode 100644 index 0000000000000..e553e5f37f05d --- /dev/null +++ b/tests/baselines/reference/accessorsOverrideProperty4.types @@ -0,0 +1,31 @@ +=== tests/cases/conformance/classes/propertyMemberDeclarations/accessorsOverrideProperty4.ts === +declare class Animal { +>Animal : Animal + + sound: string; +>sound : string +} +class Lion extends Animal { +>Lion : Lion +>Animal : Animal + + _sound = 'roar' +>_sound : string +>'roar' : "roar" + + get sound(): string { return this._sound } +>sound : string +>this._sound : string +>this : this +>_sound : string + + set sound(val: string) { this._sound = val } +>sound : string +>val : string +>this._sound = val : string +>this._sound : string +>this : this +>_sound : string +>val : string +} + diff --git a/tests/baselines/reference/accessorsOverrideProperty5.js b/tests/baselines/reference/accessorsOverrideProperty5.js new file mode 100644 index 0000000000000..fb7cee0630b67 --- /dev/null +++ b/tests/baselines/reference/accessorsOverrideProperty5.js @@ -0,0 +1,19 @@ +//// [accessorsOverrideProperty5.ts] +interface I { + p: number +} +interface B extends I { } +class B { } +class C extends B { + get p() { return 1 } + set p(value) { } +} + + +//// [accessorsOverrideProperty5.js] +class B { +} +class C extends B { + get p() { return 1; } + set p(value) { } +} diff --git a/tests/baselines/reference/accessorsOverrideProperty5.symbols b/tests/baselines/reference/accessorsOverrideProperty5.symbols new file mode 100644 index 0000000000000..b048d8bbc928d --- /dev/null +++ b/tests/baselines/reference/accessorsOverrideProperty5.symbols @@ -0,0 +1,26 @@ +=== tests/cases/conformance/classes/propertyMemberDeclarations/accessorsOverrideProperty5.ts === +interface I { +>I : Symbol(I, Decl(accessorsOverrideProperty5.ts, 0, 0)) + + p: number +>p : Symbol(I.p, Decl(accessorsOverrideProperty5.ts, 0, 13)) +} +interface B extends I { } +>B : Symbol(B, Decl(accessorsOverrideProperty5.ts, 2, 1), Decl(accessorsOverrideProperty5.ts, 3, 25)) +>I : Symbol(I, Decl(accessorsOverrideProperty5.ts, 0, 0)) + +class B { } +>B : Symbol(B, Decl(accessorsOverrideProperty5.ts, 2, 1), Decl(accessorsOverrideProperty5.ts, 3, 25)) + +class C extends B { +>C : Symbol(C, Decl(accessorsOverrideProperty5.ts, 4, 11)) +>B : Symbol(B, Decl(accessorsOverrideProperty5.ts, 2, 1), Decl(accessorsOverrideProperty5.ts, 3, 25)) + + get p() { return 1 } +>p : Symbol(C.p, Decl(accessorsOverrideProperty5.ts, 5, 19), Decl(accessorsOverrideProperty5.ts, 6, 24)) + + set p(value) { } +>p : Symbol(C.p, Decl(accessorsOverrideProperty5.ts, 5, 19), Decl(accessorsOverrideProperty5.ts, 6, 24)) +>value : Symbol(value, Decl(accessorsOverrideProperty5.ts, 7, 10)) +} + diff --git a/tests/baselines/reference/accessorsOverrideProperty5.types b/tests/baselines/reference/accessorsOverrideProperty5.types new file mode 100644 index 0000000000000..2032d3fa6ae50 --- /dev/null +++ b/tests/baselines/reference/accessorsOverrideProperty5.types @@ -0,0 +1,22 @@ +=== tests/cases/conformance/classes/propertyMemberDeclarations/accessorsOverrideProperty5.ts === +interface I { + p: number +>p : number +} +interface B extends I { } +class B { } +>B : B + +class C extends B { +>C : C +>B : B + + get p() { return 1 } +>p : number +>1 : 1 + + set p(value) { } +>p : number +>value : number +} + diff --git a/tests/baselines/reference/accessorsOverrideProperty6.js b/tests/baselines/reference/accessorsOverrideProperty6.js new file mode 100644 index 0000000000000..3cd61062c8626 --- /dev/null +++ b/tests/baselines/reference/accessorsOverrideProperty6.js @@ -0,0 +1,39 @@ +//// [accessorsOverrideProperty6.ts] +class A { + p = 'yep' +} +class B extends A { + get p() { return 'oh no' } // error +} +class C { + p = 101 +} +class D extends C { + _secret = 11 + get p() { return this._secret } // error + set p(value) { this._secret = value } // error +} + + +//// [accessorsOverrideProperty6.js] +class A { + constructor() { + this.p = 'yep'; + } +} +class B extends A { + get p() { return 'oh no'; } // error +} +class C { + constructor() { + this.p = 101; + } +} +class D extends C { + constructor() { + super(...arguments); + this._secret = 11; + } + get p() { return this._secret; } // error + set p(value) { this._secret = value; } // error +} diff --git a/tests/baselines/reference/accessorsOverrideProperty6.symbols b/tests/baselines/reference/accessorsOverrideProperty6.symbols new file mode 100644 index 0000000000000..19f93b02630bc --- /dev/null +++ b/tests/baselines/reference/accessorsOverrideProperty6.symbols @@ -0,0 +1,42 @@ +=== tests/cases/conformance/classes/propertyMemberDeclarations/accessorsOverrideProperty6.ts === +class A { +>A : Symbol(A, Decl(accessorsOverrideProperty6.ts, 0, 0)) + + p = 'yep' +>p : Symbol(A.p, Decl(accessorsOverrideProperty6.ts, 0, 9)) +} +class B extends A { +>B : Symbol(B, Decl(accessorsOverrideProperty6.ts, 2, 1)) +>A : Symbol(A, Decl(accessorsOverrideProperty6.ts, 0, 0)) + + get p() { return 'oh no' } // error +>p : Symbol(B.p, Decl(accessorsOverrideProperty6.ts, 3, 19)) +} +class C { +>C : Symbol(C, Decl(accessorsOverrideProperty6.ts, 5, 1)) + + p = 101 +>p : Symbol(C.p, Decl(accessorsOverrideProperty6.ts, 6, 9)) +} +class D extends C { +>D : Symbol(D, Decl(accessorsOverrideProperty6.ts, 8, 1)) +>C : Symbol(C, Decl(accessorsOverrideProperty6.ts, 5, 1)) + + _secret = 11 +>_secret : Symbol(D._secret, Decl(accessorsOverrideProperty6.ts, 9, 19)) + + get p() { return this._secret } // error +>p : Symbol(D.p, Decl(accessorsOverrideProperty6.ts, 10, 17), Decl(accessorsOverrideProperty6.ts, 11, 35)) +>this._secret : Symbol(D._secret, Decl(accessorsOverrideProperty6.ts, 9, 19)) +>this : Symbol(D, Decl(accessorsOverrideProperty6.ts, 8, 1)) +>_secret : Symbol(D._secret, Decl(accessorsOverrideProperty6.ts, 9, 19)) + + set p(value) { this._secret = value } // error +>p : Symbol(D.p, Decl(accessorsOverrideProperty6.ts, 10, 17), Decl(accessorsOverrideProperty6.ts, 11, 35)) +>value : Symbol(value, Decl(accessorsOverrideProperty6.ts, 12, 10)) +>this._secret : Symbol(D._secret, Decl(accessorsOverrideProperty6.ts, 9, 19)) +>this : Symbol(D, Decl(accessorsOverrideProperty6.ts, 8, 1)) +>_secret : Symbol(D._secret, Decl(accessorsOverrideProperty6.ts, 9, 19)) +>value : Symbol(value, Decl(accessorsOverrideProperty6.ts, 12, 10)) +} + diff --git a/tests/baselines/reference/accessorsOverrideProperty6.types b/tests/baselines/reference/accessorsOverrideProperty6.types new file mode 100644 index 0000000000000..594dbd372adef --- /dev/null +++ b/tests/baselines/reference/accessorsOverrideProperty6.types @@ -0,0 +1,47 @@ +=== tests/cases/conformance/classes/propertyMemberDeclarations/accessorsOverrideProperty6.ts === +class A { +>A : A + + p = 'yep' +>p : string +>'yep' : "yep" +} +class B extends A { +>B : B +>A : A + + get p() { return 'oh no' } // error +>p : string +>'oh no' : "oh no" +} +class C { +>C : C + + p = 101 +>p : number +>101 : 101 +} +class D extends C { +>D : D +>C : C + + _secret = 11 +>_secret : number +>11 : 11 + + get p() { return this._secret } // error +>p : number +>this._secret : number +>this : this +>_secret : number + + set p(value) { this._secret = value } // error +>p : number +>value : number +>this._secret = value : number +>this._secret : number +>this : this +>_secret : number +>value : number +} + diff --git a/tests/baselines/reference/accessorsOverrideProperty7.errors.txt b/tests/baselines/reference/accessorsOverrideProperty7.errors.txt new file mode 100644 index 0000000000000..5ebeafe443d1b --- /dev/null +++ b/tests/baselines/reference/accessorsOverrideProperty7.errors.txt @@ -0,0 +1,13 @@ +tests/cases/conformance/classes/propertyMemberDeclarations/accessorsOverrideProperty7.ts(5,9): error TS2611: Class 'A' defines instance member property 'p', but extended class 'B' defines it as instance member accessor. + + +==== tests/cases/conformance/classes/propertyMemberDeclarations/accessorsOverrideProperty7.ts (1 errors) ==== + abstract class A { + abstract p = 'yep' + } + class B extends A { + get p() { return 'oh no' } // error + ~ +!!! error TS2611: Class 'A' defines instance member property 'p', but extended class 'B' defines it as instance member accessor. + } + \ No newline at end of file diff --git a/tests/baselines/reference/accessorsOverrideProperty7.js b/tests/baselines/reference/accessorsOverrideProperty7.js new file mode 100644 index 0000000000000..5c5b0de250708 --- /dev/null +++ b/tests/baselines/reference/accessorsOverrideProperty7.js @@ -0,0 +1,47 @@ +//// [accessorsOverrideProperty7.ts] +abstract class A { + abstract p = 'yep' +} +class B extends A { + get p() { return 'oh no' } // error +} + + +//// [accessorsOverrideProperty7.js] +var __extends = (this && this.__extends) || (function () { + var extendStatics = function (d, b) { + 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 extendStatics(d, b); + }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +var A = /** @class */ (function () { + function A() { + Object.defineProperty(this, "p", { + enumerable: true, + configurable: true, + writable: true, + value: 'yep' + }); + } + return A; +}()); +var B = /** @class */ (function (_super) { + __extends(B, _super); + function B() { + return _super !== null && _super.apply(this, arguments) || this; + } + Object.defineProperty(B.prototype, "p", { + get: function () { return 'oh no'; } // error + , + enumerable: true, + configurable: true + }); + return B; +}(A)); diff --git a/tests/baselines/reference/accessorsOverrideProperty7.symbols b/tests/baselines/reference/accessorsOverrideProperty7.symbols new file mode 100644 index 0000000000000..0ca99ab7abd6f --- /dev/null +++ b/tests/baselines/reference/accessorsOverrideProperty7.symbols @@ -0,0 +1,15 @@ +=== tests/cases/conformance/classes/propertyMemberDeclarations/accessorsOverrideProperty7.ts === +abstract class A { +>A : Symbol(A, Decl(accessorsOverrideProperty7.ts, 0, 0)) + + abstract p = 'yep' +>p : Symbol(A.p, Decl(accessorsOverrideProperty7.ts, 0, 18)) +} +class B extends A { +>B : Symbol(B, Decl(accessorsOverrideProperty7.ts, 2, 1)) +>A : Symbol(A, Decl(accessorsOverrideProperty7.ts, 0, 0)) + + get p() { return 'oh no' } // error +>p : Symbol(B.p, Decl(accessorsOverrideProperty7.ts, 3, 19)) +} + diff --git a/tests/baselines/reference/accessorsOverrideProperty7.types b/tests/baselines/reference/accessorsOverrideProperty7.types new file mode 100644 index 0000000000000..6e52715a3da6f --- /dev/null +++ b/tests/baselines/reference/accessorsOverrideProperty7.types @@ -0,0 +1,17 @@ +=== tests/cases/conformance/classes/propertyMemberDeclarations/accessorsOverrideProperty7.ts === +abstract class A { +>A : A + + abstract p = 'yep' +>p : string +>'yep' : "yep" +} +class B extends A { +>B : B +>A : A + + get p() { return 'oh no' } // error +>p : string +>'oh no' : "oh no" +} + diff --git a/tests/baselines/reference/api/tsserverlibrary.d.ts b/tests/baselines/reference/api/tsserverlibrary.d.ts index 865785947f506..3d055b9336aba 100644 --- a/tests/baselines/reference/api/tsserverlibrary.d.ts +++ b/tests/baselines/reference/api/tsserverlibrary.d.ts @@ -2637,6 +2637,7 @@ declare namespace ts { /** Paths used to compute primary types search locations */ typeRoots?: string[]; esModuleInterop?: boolean; + useDefineForClassFields?: boolean; [option: string]: CompilerOptionsValue | TsConfigSourceFile | undefined; } export interface TypeAcquisition { @@ -8317,6 +8318,7 @@ declare namespace ts.server.protocol { strictNullChecks?: boolean; suppressExcessPropertyErrors?: boolean; suppressImplicitAnyIndexErrors?: boolean; + useDefineForClassFields?: boolean; target?: ScriptTarget | ts.ScriptTarget; traceResolution?: boolean; resolveJsonModule?: boolean; diff --git a/tests/baselines/reference/api/typescript.d.ts b/tests/baselines/reference/api/typescript.d.ts index d8f3cdfab56c0..3bd00d6f2ebe5 100644 --- a/tests/baselines/reference/api/typescript.d.ts +++ b/tests/baselines/reference/api/typescript.d.ts @@ -2637,6 +2637,7 @@ declare namespace ts { /** Paths used to compute primary types search locations */ typeRoots?: string[]; esModuleInterop?: boolean; + useDefineForClassFields?: boolean; [option: string]: CompilerOptionsValue | TsConfigSourceFile | undefined; } export interface TypeAcquisition { diff --git a/tests/baselines/reference/checkJsFiles_noErrorLocation.errors.txt b/tests/baselines/reference/checkJsFiles_noErrorLocation.errors.txt new file mode 100644 index 0000000000000..d9104608284a9 --- /dev/null +++ b/tests/baselines/reference/checkJsFiles_noErrorLocation.errors.txt @@ -0,0 +1,25 @@ +tests/cases/compiler/a.js(14,10): error TS2424: Class 'A' defines instance member function 'foo', but extended class 'B' defines it as instance member property. + + +==== tests/cases/compiler/a.js (1 errors) ==== + // @ts-check + class A { + constructor() { + + } + foo() { + return 4; + } + } + + class B extends A { + constructor() { + super(); + this.foo = () => 3; + ~~~ +!!! error TS2424: Class 'A' defines instance member function 'foo', but extended class 'B' defines it as instance member property. + } + } + + const i = new B(); + i.foo(); \ No newline at end of file diff --git a/tests/baselines/reference/classExpressionPropertyModifiers.errors.txt b/tests/baselines/reference/classExpressionPropertyModifiers.errors.txt index f4b3fed7e5458..cb01d6561260f 100644 --- a/tests/baselines/reference/classExpressionPropertyModifiers.errors.txt +++ b/tests/baselines/reference/classExpressionPropertyModifiers.errors.txt @@ -1,12 +1,12 @@ -tests/cases/compiler/classExpressionPropertyModifiers.ts(2,5): error TS1031: 'declare' modifier cannot appear on a class element. +tests/cases/compiler/classExpressionPropertyModifiers.ts(2,36): error TS1039: Initializers are not allowed in ambient contexts. tests/cases/compiler/classExpressionPropertyModifiers.ts(3,5): error TS1031: 'export' modifier cannot appear on a class element. ==== tests/cases/compiler/classExpressionPropertyModifiers.ts (2 errors) ==== const a = class Cat { declare [Symbol.toStringTag] = "uh"; - ~~~~~~~ -!!! error TS1031: 'declare' modifier cannot appear on a class element. + ~~~~ +!!! error TS1039: Initializers are not allowed in ambient contexts. export foo = 1; ~~~~~~ !!! error TS1031: 'export' modifier cannot appear on a class element. diff --git a/tests/baselines/reference/classdecl.js b/tests/baselines/reference/classdecl.js index 42dd8b7d114ab..43d67d0cb1110 100644 --- a/tests/baselines/reference/classdecl.js +++ b/tests/baselines/reference/classdecl.js @@ -218,13 +218,14 @@ declare class a { constructor(s: string); pgF(): void; pv: any; - d: number; - static readonly p2: { + get d(): number; + set d(a: number); + static get p2(): { x: number; y: number; }; private static d2; - private static readonly p3; + private static get p3(); private pv3; private foo; } diff --git a/tests/baselines/reference/commentsClassMembers.js b/tests/baselines/reference/commentsClassMembers.js index 9918b0758ae40..bba4b44fc6023 100644 --- a/tests/baselines/reference/commentsClassMembers.js +++ b/tests/baselines/reference/commentsClassMembers.js @@ -486,15 +486,17 @@ declare class c1 { /** sum with property*/ p2(/** number to add*/ b: number): number; /** getter property*/ + get p3(): number; /** setter property*/ - p3: number; + set p3(/** this is value*/ value: number); /** pp1 is property of c1*/ private pp1; /** sum with property*/ private pp2; /** getter property*/ + private get pp3(); /** setter property*/ - private pp3; + private set pp3(value); /** Constructor method*/ constructor(); /** s1 is static property of c1*/ @@ -502,49 +504,59 @@ declare class c1 { /** static sum with property*/ static s2(/** number to add*/ b: number): number; /** static getter property*/ + static get s3(): number; /** setter property*/ - static s3: number; + static set s3(/** this is value*/ value: number); nc_p1: number; nc_p2(b: number): number; - nc_p3: number; + get nc_p3(): number; + set nc_p3(value: number); private nc_pp1; private nc_pp2; - private nc_pp3; + private get nc_pp3(); + private set nc_pp3(value); static nc_s1: number; static nc_s2(b: number): number; - static nc_s3: number; + static get nc_s3(): number; + static set nc_s3(value: number); a_p1: number; a_p2(b: number): number; - a_p3: number; + get a_p3(): number; + set a_p3(value: number); private a_pp1; private a_pp2; - private a_pp3; + private get a_pp3(); + private set a_pp3(value); static a_s1: number; static a_s2(b: number): number; - static a_s3: number; + static get a_s3(): number; + static set a_s3(value: number); /** p1 is property of c1 */ b_p1: number; /** sum with property */ b_p2(b: number): number; /** getter property */ + get b_p3(): number; /** setter property */ - b_p3: number; + set b_p3(value: number); /** pp1 is property of c1 */ private b_pp1; /** sum with property */ private b_pp2; /** getter property */ + private get b_pp3(); /** setter property */ - private b_pp3; + private set b_pp3(value); /** s1 is static property of c1 */ static b_s1: number; /** static sum with property */ static b_s2(b: number): number; /** static getter property */ + static get b_s3(): number; /** setter property */ - static b_s3: number; + static set b_s3(value: number); } declare var i1: c1; declare var i1_p: number; @@ -567,11 +579,11 @@ declare var i1_c: typeof c1; declare class cProperties { private val; /** getter only property*/ - readonly p1: number; - readonly nc_p1: number; + get p1(): number; + get nc_p1(): number; /**setter only property*/ - p2: number; - nc_p2: number; + set p2(value: number); + set nc_p2(value: number); x: number; private y; } diff --git a/tests/baselines/reference/commentsInheritance.js b/tests/baselines/reference/commentsInheritance.js index 58e243301b4e2..9779df371a2ec 100644 --- a/tests/baselines/reference/commentsInheritance.js +++ b/tests/baselines/reference/commentsInheritance.js @@ -323,19 +323,19 @@ declare class c2 { /** c2 c2_f1*/ c2_f1(): void; /** c2 c2_prop*/ - readonly c2_prop: number; + get c2_prop(): number; c2_nc_p1: number; c2_nc_f1(): void; - readonly c2_nc_prop: number; + get c2_nc_prop(): number; /** c2 p1*/ p1: number; /** c2 f1*/ f1(): void; /** c2 prop*/ - readonly prop: number; + get prop(): number; nc_p1: number; nc_f1(): void; - readonly nc_prop: number; + get nc_prop(): number; /** c2 constructor*/ constructor(a: number); } @@ -346,10 +346,10 @@ declare class c3 extends c2 { /** c3 f1*/ f1(): void; /** c3 prop*/ - readonly prop: number; + get prop(): number; nc_p1: number; nc_f1(): void; - readonly nc_prop: number; + get nc_prop(): number; } declare var c2_i: c2; declare var c3_i: c3; diff --git a/tests/baselines/reference/commentsdoNotEmitComments.js b/tests/baselines/reference/commentsdoNotEmitComments.js index ae7442f109a64..865ae43c4de22 100644 --- a/tests/baselines/reference/commentsdoNotEmitComments.js +++ b/tests/baselines/reference/commentsdoNotEmitComments.js @@ -144,7 +144,8 @@ declare class c { constructor(); b: number; myFoo(): number; - prop1: number; + get prop1(): number; + set prop1(val: number); foo1(a: number): string; foo1(b: string): string; } diff --git a/tests/baselines/reference/commentsemitComments.js b/tests/baselines/reference/commentsemitComments.js index dd8f3608cf33f..8bfb1c59c9abd 100644 --- a/tests/baselines/reference/commentsemitComments.js +++ b/tests/baselines/reference/commentsemitComments.js @@ -160,8 +160,9 @@ declare class c { /** function comment */ myFoo(): number; /** getter comment*/ + get prop1(): number; /** setter comment*/ - prop1: number; + set prop1(val: number); /** overload signature1*/ foo1(a: number): string; /** Overload signature 2*/ diff --git a/tests/baselines/reference/declFileAccessors.js b/tests/baselines/reference/declFileAccessors.js index c6175ec7ede0a..103f86d688e69 100644 --- a/tests/baselines/reference/declFileAccessors.js +++ b/tests/baselines/reference/declFileAccessors.js @@ -273,35 +273,47 @@ var c2 = /** @class */ (function () { /** This is comment for c1*/ export declare class c1 { /** getter property*/ + get p3(): number; /** setter property*/ - p3: number; + set p3(/** this is value*/ value: number); /** private getter property*/ + private get pp3(); /** private setter property*/ - private pp3; + private set pp3(value); /** static getter property*/ + static get s3(): number; /** setter property*/ - static s3: number; - nc_p3: number; - private nc_pp3; - static nc_s3: string; - readonly onlyGetter: number; - onlySetter: number; + static set s3(/** this is value*/ value: number); + get nc_p3(): number; + set nc_p3(value: number); + private get nc_pp3(); + private set nc_pp3(value); + static get nc_s3(): string; + static set nc_s3(value: string); + get onlyGetter(): number; + set onlySetter(value: number); } //// [declFileAccessors_1.d.ts] /** This is comment for c2 - the global class*/ declare class c2 { /** getter property*/ + get p3(): number; /** setter property*/ - p3: number; + set p3(/** this is value*/ value: number); /** private getter property*/ + private get pp3(); /** private setter property*/ - private pp3; + private set pp3(value); /** static getter property*/ + static get s3(): number; /** setter property*/ - static s3: number; - nc_p3: number; - private nc_pp3; - static nc_s3: string; - readonly onlyGetter: number; - onlySetter: number; + static set s3(/** this is value*/ value: number); + get nc_p3(): number; + set nc_p3(value: number); + private get nc_pp3(); + private set nc_pp3(value); + static get nc_s3(): string; + static set nc_s3(value: string); + get onlyGetter(): number; + set onlySetter(value: number); } diff --git a/tests/baselines/reference/declFilePrivateStatic.js b/tests/baselines/reference/declFilePrivateStatic.js index 67469327265b5..9dd2adc8c59ef 100644 --- a/tests/baselines/reference/declFilePrivateStatic.js +++ b/tests/baselines/reference/declFilePrivateStatic.js @@ -51,8 +51,8 @@ declare class C { static y: number; private static a; static b(): void; - private static readonly c; - static readonly d: number; - private static e; - static f: any; + private static get c(); + static get d(): number; + private static set e(value); + static set f(v: any); } diff --git a/tests/baselines/reference/declFileTypeAnnotationVisibilityErrorAccessors.js b/tests/baselines/reference/declFileTypeAnnotationVisibilityErrorAccessors.js index 6018176153396..598ac67c20ed5 100644 --- a/tests/baselines/reference/declFileTypeAnnotationVisibilityErrorAccessors.js +++ b/tests/baselines/reference/declFileTypeAnnotationVisibilityErrorAccessors.js @@ -271,21 +271,27 @@ declare module m { } } export class c { - readonly foo1: private1; - readonly foo2: private1; - foo3: private1; - foo4: private1; - foo5: private1; - readonly foo11: public1; - readonly foo12: public1; - foo13: public1; - foo14: public1; - foo15: public1; - readonly foo111: m2.public2; - readonly foo112: m2.public2; - foo113: m2.public2; - foo114: m2.public2; - foo115: m2.public2; + get foo1(): private1; + get foo2(): private1; + set foo3(param: private1); + get foo4(): private1; + set foo4(param: private1); + get foo5(): private1; + set foo5(param: private1); + get foo11(): public1; + get foo12(): public1; + set foo13(param: public1); + get foo14(): public1; + set foo14(param: public1); + get foo15(): public1; + set foo15(param: public1); + get foo111(): m2.public2; + get foo112(): m2.public2; + set foo113(param: m2.public2); + get foo114(): m2.public2; + set foo114(param: m2.public2); + get foo115(): m2.public2; + set foo115(param: m2.public2); } export {}; } diff --git a/tests/baselines/reference/declarationEmitClassMemberNameConflict.js b/tests/baselines/reference/declarationEmitClassMemberNameConflict.js index 77732ea94f889..43523aba38f0e 100644 --- a/tests/baselines/reference/declarationEmitClassMemberNameConflict.js +++ b/tests/baselines/reference/declarationEmitClassMemberNameConflict.js @@ -103,10 +103,10 @@ export declare class C2 { bar(): (t: typeof C2) => void; } export declare class C3 { - readonly C3: number; + get C3(): number; bar(): (t: typeof C3) => void; } export declare class C4 { - C4: any; + set C4(v: any); bar(): (t: typeof C4) => void; } diff --git a/tests/baselines/reference/declarationEmitProtectedMembers.js b/tests/baselines/reference/declarationEmitProtectedMembers.js index fb0a9cb933914..e0a2b40ffd50c 100644 --- a/tests/baselines/reference/declarationEmitProtectedMembers.js +++ b/tests/baselines/reference/declarationEmitProtectedMembers.js @@ -138,11 +138,12 @@ var C4 = /** @class */ (function () { declare class C1 { protected x: number; protected f(): number; - protected accessor: number; + protected set accessor(a: number); + protected get accessor(): number; protected static sx: number; protected static sf(): number; - protected static staticSetter: number; - protected static readonly staticGetter: number; + protected static set staticSetter(a: number); + protected static get staticGetter(): number; } declare class C2 extends C1 { protected f(): number; @@ -153,7 +154,7 @@ declare class C3 extends C2 { static sx: number; f(): number; static sf(): number; - static readonly staticGetter: number; + static get staticGetter(): number; } declare class C4 { protected a: number; diff --git a/tests/baselines/reference/definePropertyES5.js b/tests/baselines/reference/definePropertyES5.js new file mode 100644 index 0000000000000..a0bc4a64db48a --- /dev/null +++ b/tests/baselines/reference/definePropertyES5.js @@ -0,0 +1,50 @@ +//// [definePropertyES5.ts] +var x: "p" = "p" +class A { + a = 12 + b + ["computed"] = 13 + ;[x] = 14 + m() { } +} + + +//// [definePropertyES5.js] +var _a; +var x = "p"; +var A = /** @class */ (function () { + function A() { + Object.defineProperty(this, "a", { + enumerable: true, + configurable: true, + writable: true, + value: 12 + }); + Object.defineProperty(this, "b", { + enumerable: true, + configurable: true, + writable: true, + value: void 0 + }); + Object.defineProperty(this, "computed", { + enumerable: true, + configurable: true, + writable: true, + value: 13 + }); + Object.defineProperty(this, _a, { + enumerable: true, + configurable: true, + writable: true, + value: 14 + }); + } + Object.defineProperty(A.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, + value: function () { } + }); + return A; +}()); +_a = x; diff --git a/tests/baselines/reference/definePropertyES5.symbols b/tests/baselines/reference/definePropertyES5.symbols new file mode 100644 index 0000000000000..f9afa02868793 --- /dev/null +++ b/tests/baselines/reference/definePropertyES5.symbols @@ -0,0 +1,25 @@ +=== tests/cases/conformance/classes/propertyMemberDeclarations/definePropertyES5.ts === +var x: "p" = "p" +>x : Symbol(x, Decl(definePropertyES5.ts, 0, 3)) + +class A { +>A : Symbol(A, Decl(definePropertyES5.ts, 0, 16)) + + a = 12 +>a : Symbol(A.a, Decl(definePropertyES5.ts, 1, 9)) + + b +>b : Symbol(A.b, Decl(definePropertyES5.ts, 2, 10)) + + ["computed"] = 13 +>["computed"] : Symbol(A["computed"], Decl(definePropertyES5.ts, 3, 5)) +>"computed" : Symbol(A["computed"], Decl(definePropertyES5.ts, 3, 5)) + + ;[x] = 14 +>[x] : Symbol(A[x], Decl(definePropertyES5.ts, 5, 5)) +>x : Symbol(x, Decl(definePropertyES5.ts, 0, 3)) + + m() { } +>m : Symbol(A.m, Decl(definePropertyES5.ts, 5, 13)) +} + diff --git a/tests/baselines/reference/definePropertyES5.types b/tests/baselines/reference/definePropertyES5.types new file mode 100644 index 0000000000000..3f82787c13a34 --- /dev/null +++ b/tests/baselines/reference/definePropertyES5.types @@ -0,0 +1,29 @@ +=== tests/cases/conformance/classes/propertyMemberDeclarations/definePropertyES5.ts === +var x: "p" = "p" +>x : "p" +>"p" : "p" + +class A { +>A : A + + a = 12 +>a : number +>12 : 12 + + b +>b : any + + ["computed"] = 13 +>["computed"] : number +>"computed" : "computed" +>13 : 13 + + ;[x] = 14 +>[x] : number +>x : "p" +>14 : 14 + + m() { } +>m : () => void +} + diff --git a/tests/baselines/reference/definePropertyOutputES3.errors.txt b/tests/baselines/reference/definePropertyOutputES3.errors.txt new file mode 100644 index 0000000000000..c527477922545 --- /dev/null +++ b/tests/baselines/reference/definePropertyOutputES3.errors.txt @@ -0,0 +1,9 @@ +error TS5048: Option 'useDefineForClassFields' cannot be specified when option 'target' is 'ES3'. + + +!!! error TS5048: Option 'useDefineForClassFields' cannot be specified when option 'target' is 'ES3'. +==== tests/cases/conformance/classes/propertyMemberDeclarations/definePropertyOutputES3.ts (0 errors) ==== + class A { + a = 12 + } + \ No newline at end of file diff --git a/tests/baselines/reference/definePropertyOutputES3.js b/tests/baselines/reference/definePropertyOutputES3.js new file mode 100644 index 0000000000000..038a8818e0fda --- /dev/null +++ b/tests/baselines/reference/definePropertyOutputES3.js @@ -0,0 +1,18 @@ +//// [definePropertyOutputES3.ts] +class A { + a = 12 +} + + +//// [definePropertyOutputES3.js] +var A = /** @class */ (function () { + function A() { + Object.defineProperty(this, "a", { + enumerable: true, + configurable: true, + writable: true, + value: 12 + }); + } + return A; +}()); diff --git a/tests/baselines/reference/definePropertyOutputES3.symbols b/tests/baselines/reference/definePropertyOutputES3.symbols new file mode 100644 index 0000000000000..d41600cd523b8 --- /dev/null +++ b/tests/baselines/reference/definePropertyOutputES3.symbols @@ -0,0 +1,8 @@ +=== tests/cases/conformance/classes/propertyMemberDeclarations/definePropertyOutputES3.ts === +class A { +>A : Symbol(A, Decl(definePropertyOutputES3.ts, 0, 0)) + + a = 12 +>a : Symbol(A.a, Decl(definePropertyOutputES3.ts, 0, 9)) +} + diff --git a/tests/baselines/reference/definePropertyOutputES3.types b/tests/baselines/reference/definePropertyOutputES3.types new file mode 100644 index 0000000000000..5912a50934371 --- /dev/null +++ b/tests/baselines/reference/definePropertyOutputES3.types @@ -0,0 +1,9 @@ +=== tests/cases/conformance/classes/propertyMemberDeclarations/definePropertyOutputES3.ts === +class A { +>A : A + + a = 12 +>a : number +>12 : 12 +} + diff --git a/tests/baselines/reference/derivedUninitializedPropertyDeclaration.errors.txt b/tests/baselines/reference/derivedUninitializedPropertyDeclaration.errors.txt new file mode 100644 index 0000000000000..f657e335a48cf --- /dev/null +++ b/tests/baselines/reference/derivedUninitializedPropertyDeclaration.errors.txt @@ -0,0 +1,88 @@ +tests/cases/conformance/classes/propertyMemberDeclarations/derivedUninitializedPropertyDeclaration.ts(12,21): error TS1255: A definite assignment assertion '!' is not permitted in this context. +tests/cases/conformance/classes/propertyMemberDeclarations/derivedUninitializedPropertyDeclaration.ts(15,5): error TS1031: 'declare' modifier cannot appear on a class element. +tests/cases/conformance/classes/propertyMemberDeclarations/derivedUninitializedPropertyDeclaration.ts(15,17): error TS1183: An implementation cannot be declared in ambient contexts. +tests/cases/conformance/classes/propertyMemberDeclarations/derivedUninitializedPropertyDeclaration.ts(17,24): error TS1039: Initializers are not allowed in ambient contexts. +tests/cases/conformance/classes/propertyMemberDeclarations/derivedUninitializedPropertyDeclaration.ts(24,5): error TS2564: Property 'p' has no initializer and is not definitely assigned in the constructor. +tests/cases/conformance/classes/propertyMemberDeclarations/derivedUninitializedPropertyDeclaration.ts(27,5): error TS2564: Property 'p' has no initializer and is not definitely assigned in the constructor. + + +==== tests/cases/conformance/classes/propertyMemberDeclarations/derivedUninitializedPropertyDeclaration.ts (6 errors) ==== + class A { + property = 'x'; + m() { return 1 } + } + class B extends A { + property: any; // error + } + class BD extends A { + declare property: any; // ok because it's implicitly initialised + } + class BDBang extends A { + declare property!: any; // ! is not allowed, this is an ambient declaration + ~ +!!! error TS1255: A definite assignment assertion '!' is not permitted in this context. + } + class BOther extends A { + declare m() { return 2 } // not allowed on methods + ~~~~~~~ +!!! error TS1031: 'declare' modifier cannot appear on a class element. + ~ +!!! error TS1183: An implementation cannot be declared in ambient contexts. + declare nonce: any; // ok, even though it's not in the base + declare property = 'y' // initialiser not allowed with declare + ~~~ +!!! error TS1039: Initializers are not allowed in ambient contexts. + } + class U { + declare nonce: any; // ok, even though there's no base + } + + class C { + p: string; + ~ +!!! error TS2564: Property 'p' has no initializer and is not definitely assigned in the constructor. + } + class D extends C { + p: 'hi'; // error + ~ +!!! error TS2564: Property 'p' has no initializer and is not definitely assigned in the constructor. + } + class DD extends C { + declare p: 'bye'; // ok + } + + + declare class E { + p1: string + p2: string + } + class F extends E { + p1!: 'z' + declare p2: 'alpha' + } + + class G extends E { + p1: 'z' + constructor() { + super() + this.p1 = 'z' + } + } + + abstract class H extends E { + abstract p1: 'a' | 'b' | 'c' + declare abstract p2: 'a' | 'b' | 'c' + } + + interface I { + q: number + } + interface J extends I { } + class J { + r = 5 + } + class K extends J { + q!: 1 | 2 | 3 // ok, extends a property from an interface + r!: 4 | 5 // error, from class + } + \ No newline at end of file diff --git a/tests/baselines/reference/derivedUninitializedPropertyDeclaration.js b/tests/baselines/reference/derivedUninitializedPropertyDeclaration.js new file mode 100644 index 0000000000000..471cd5bbf1d18 --- /dev/null +++ b/tests/baselines/reference/derivedUninitializedPropertyDeclaration.js @@ -0,0 +1,182 @@ +//// [derivedUninitializedPropertyDeclaration.ts] +class A { + property = 'x'; + m() { return 1 } +} +class B extends A { + property: any; // error +} +class BD extends A { + declare property: any; // ok because it's implicitly initialised +} +class BDBang extends A { + declare property!: any; // ! is not allowed, this is an ambient declaration +} +class BOther extends A { + declare m() { return 2 } // not allowed on methods + declare nonce: any; // ok, even though it's not in the base + declare property = 'y' // initialiser not allowed with declare +} +class U { + declare nonce: any; // ok, even though there's no base +} + +class C { + p: string; +} +class D extends C { + p: 'hi'; // error +} +class DD extends C { + declare p: 'bye'; // ok +} + + +declare class E { + p1: string + p2: string +} +class F extends E { + p1!: 'z' + declare p2: 'alpha' +} + +class G extends E { + p1: 'z' + constructor() { + super() + this.p1 = 'z' + } +} + +abstract class H extends E { + abstract p1: 'a' | 'b' | 'c' + declare abstract p2: 'a' | 'b' | 'c' +} + +interface I { + q: number +} +interface J extends I { } +class J { + r = 5 +} +class K extends J { + q!: 1 | 2 | 3 // ok, extends a property from an interface + r!: 4 | 5 // error, from class +} + + +//// [derivedUninitializedPropertyDeclaration.js] +"use strict"; +var __extends = (this && this.__extends) || (function () { + var extendStatics = function (d, b) { + 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 extendStatics(d, b); + }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +var A = /** @class */ (function () { + function A() { + this.property = 'x'; + } + A.prototype.m = function () { return 1; }; + return A; +}()); +var B = /** @class */ (function (_super) { + __extends(B, _super); + function B() { + return _super !== null && _super.apply(this, arguments) || this; + } + return B; +}(A)); +var BD = /** @class */ (function (_super) { + __extends(BD, _super); + function BD() { + return _super !== null && _super.apply(this, arguments) || this; + } + return BD; +}(A)); +var BDBang = /** @class */ (function (_super) { + __extends(BDBang, _super); + function BDBang() { + return _super !== null && _super.apply(this, arguments) || this; + } + return BDBang; +}(A)); +var BOther = /** @class */ (function (_super) { + __extends(BOther, _super); + function BOther() { + var _this = _super !== null && _super.apply(this, arguments) || this; + _this.property = 'y'; // initialiser not allowed with declare + return _this; + } + BOther.prototype.m = function () { return 2; }; // not allowed on methods + return BOther; +}(A)); +var U = /** @class */ (function () { + function U() { + } + return U; +}()); +var C = /** @class */ (function () { + function C() { + } + return C; +}()); +var D = /** @class */ (function (_super) { + __extends(D, _super); + function D() { + return _super !== null && _super.apply(this, arguments) || this; + } + return D; +}(C)); +var DD = /** @class */ (function (_super) { + __extends(DD, _super); + function DD() { + return _super !== null && _super.apply(this, arguments) || this; + } + return DD; +}(C)); +var F = /** @class */ (function (_super) { + __extends(F, _super); + function F() { + return _super !== null && _super.apply(this, arguments) || this; + } + return F; +}(E)); +var G = /** @class */ (function (_super) { + __extends(G, _super); + function G() { + var _this = _super.call(this) || this; + _this.p1 = 'z'; + return _this; + } + return G; +}(E)); +var H = /** @class */ (function (_super) { + __extends(H, _super); + function H() { + return _super !== null && _super.apply(this, arguments) || this; + } + return H; +}(E)); +var J = /** @class */ (function () { + function J() { + this.r = 5; + } + return J; +}()); +var K = /** @class */ (function (_super) { + __extends(K, _super); + function K() { + return _super !== null && _super.apply(this, arguments) || this; + } + return K; +}(J)); diff --git a/tests/baselines/reference/derivedUninitializedPropertyDeclaration.symbols b/tests/baselines/reference/derivedUninitializedPropertyDeclaration.symbols new file mode 100644 index 0000000000000..87e912887042a --- /dev/null +++ b/tests/baselines/reference/derivedUninitializedPropertyDeclaration.symbols @@ -0,0 +1,149 @@ +=== tests/cases/conformance/classes/propertyMemberDeclarations/derivedUninitializedPropertyDeclaration.ts === +class A { +>A : Symbol(A, Decl(derivedUninitializedPropertyDeclaration.ts, 0, 0)) + + property = 'x'; +>property : Symbol(A.property, Decl(derivedUninitializedPropertyDeclaration.ts, 0, 9)) + + m() { return 1 } +>m : Symbol(A.m, Decl(derivedUninitializedPropertyDeclaration.ts, 1, 19)) +} +class B extends A { +>B : Symbol(B, Decl(derivedUninitializedPropertyDeclaration.ts, 3, 1)) +>A : Symbol(A, Decl(derivedUninitializedPropertyDeclaration.ts, 0, 0)) + + property: any; // error +>property : Symbol(B.property, Decl(derivedUninitializedPropertyDeclaration.ts, 4, 19)) +} +class BD extends A { +>BD : Symbol(BD, Decl(derivedUninitializedPropertyDeclaration.ts, 6, 1)) +>A : Symbol(A, Decl(derivedUninitializedPropertyDeclaration.ts, 0, 0)) + + declare property: any; // ok because it's implicitly initialised +>property : Symbol(BD.property, Decl(derivedUninitializedPropertyDeclaration.ts, 7, 20)) +} +class BDBang extends A { +>BDBang : Symbol(BDBang, Decl(derivedUninitializedPropertyDeclaration.ts, 9, 1)) +>A : Symbol(A, Decl(derivedUninitializedPropertyDeclaration.ts, 0, 0)) + + declare property!: any; // ! is not allowed, this is an ambient declaration +>property : Symbol(BDBang.property, Decl(derivedUninitializedPropertyDeclaration.ts, 10, 24)) +} +class BOther extends A { +>BOther : Symbol(BOther, Decl(derivedUninitializedPropertyDeclaration.ts, 12, 1)) +>A : Symbol(A, Decl(derivedUninitializedPropertyDeclaration.ts, 0, 0)) + + declare m() { return 2 } // not allowed on methods +>m : Symbol(BOther.m, Decl(derivedUninitializedPropertyDeclaration.ts, 13, 24)) + + declare nonce: any; // ok, even though it's not in the base +>nonce : Symbol(BOther.nonce, Decl(derivedUninitializedPropertyDeclaration.ts, 14, 28)) + + declare property = 'y' // initialiser not allowed with declare +>property : Symbol(BOther.property, Decl(derivedUninitializedPropertyDeclaration.ts, 15, 23)) +} +class U { +>U : Symbol(U, Decl(derivedUninitializedPropertyDeclaration.ts, 17, 1)) + + declare nonce: any; // ok, even though there's no base +>nonce : Symbol(U.nonce, Decl(derivedUninitializedPropertyDeclaration.ts, 18, 9)) +} + +class C { +>C : Symbol(C, Decl(derivedUninitializedPropertyDeclaration.ts, 20, 1)) + + p: string; +>p : Symbol(C.p, Decl(derivedUninitializedPropertyDeclaration.ts, 22, 9)) +} +class D extends C { +>D : Symbol(D, Decl(derivedUninitializedPropertyDeclaration.ts, 24, 1)) +>C : Symbol(C, Decl(derivedUninitializedPropertyDeclaration.ts, 20, 1)) + + p: 'hi'; // error +>p : Symbol(D.p, Decl(derivedUninitializedPropertyDeclaration.ts, 25, 19)) +} +class DD extends C { +>DD : Symbol(DD, Decl(derivedUninitializedPropertyDeclaration.ts, 27, 1)) +>C : Symbol(C, Decl(derivedUninitializedPropertyDeclaration.ts, 20, 1)) + + declare p: 'bye'; // ok +>p : Symbol(DD.p, Decl(derivedUninitializedPropertyDeclaration.ts, 28, 20)) +} + + +declare class E { +>E : Symbol(E, Decl(derivedUninitializedPropertyDeclaration.ts, 30, 1)) + + p1: string +>p1 : Symbol(E.p1, Decl(derivedUninitializedPropertyDeclaration.ts, 33, 17)) + + p2: string +>p2 : Symbol(E.p2, Decl(derivedUninitializedPropertyDeclaration.ts, 34, 14)) +} +class F extends E { +>F : Symbol(F, Decl(derivedUninitializedPropertyDeclaration.ts, 36, 1)) +>E : Symbol(E, Decl(derivedUninitializedPropertyDeclaration.ts, 30, 1)) + + p1!: 'z' +>p1 : Symbol(F.p1, Decl(derivedUninitializedPropertyDeclaration.ts, 37, 19)) + + declare p2: 'alpha' +>p2 : Symbol(F.p2, Decl(derivedUninitializedPropertyDeclaration.ts, 38, 12)) +} + +class G extends E { +>G : Symbol(G, Decl(derivedUninitializedPropertyDeclaration.ts, 40, 1)) +>E : Symbol(E, Decl(derivedUninitializedPropertyDeclaration.ts, 30, 1)) + + p1: 'z' +>p1 : Symbol(G.p1, Decl(derivedUninitializedPropertyDeclaration.ts, 42, 19)) + + constructor() { + super() +>super : Symbol(E, Decl(derivedUninitializedPropertyDeclaration.ts, 30, 1)) + + this.p1 = 'z' +>this.p1 : Symbol(G.p1, Decl(derivedUninitializedPropertyDeclaration.ts, 42, 19)) +>this : Symbol(G, Decl(derivedUninitializedPropertyDeclaration.ts, 40, 1)) +>p1 : Symbol(G.p1, Decl(derivedUninitializedPropertyDeclaration.ts, 42, 19)) + } +} + +abstract class H extends E { +>H : Symbol(H, Decl(derivedUninitializedPropertyDeclaration.ts, 48, 1)) +>E : Symbol(E, Decl(derivedUninitializedPropertyDeclaration.ts, 30, 1)) + + abstract p1: 'a' | 'b' | 'c' +>p1 : Symbol(H.p1, Decl(derivedUninitializedPropertyDeclaration.ts, 50, 28)) + + declare abstract p2: 'a' | 'b' | 'c' +>p2 : Symbol(H.p2, Decl(derivedUninitializedPropertyDeclaration.ts, 51, 32)) +} + +interface I { +>I : Symbol(I, Decl(derivedUninitializedPropertyDeclaration.ts, 53, 1)) + + q: number +>q : Symbol(I.q, Decl(derivedUninitializedPropertyDeclaration.ts, 55, 13)) +} +interface J extends I { } +>J : Symbol(J, Decl(derivedUninitializedPropertyDeclaration.ts, 57, 1), Decl(derivedUninitializedPropertyDeclaration.ts, 58, 25)) +>I : Symbol(I, Decl(derivedUninitializedPropertyDeclaration.ts, 53, 1)) + +class J { +>J : Symbol(J, Decl(derivedUninitializedPropertyDeclaration.ts, 57, 1), Decl(derivedUninitializedPropertyDeclaration.ts, 58, 25)) + + r = 5 +>r : Symbol(J.r, Decl(derivedUninitializedPropertyDeclaration.ts, 59, 9)) +} +class K extends J { +>K : Symbol(K, Decl(derivedUninitializedPropertyDeclaration.ts, 61, 1)) +>J : Symbol(J, Decl(derivedUninitializedPropertyDeclaration.ts, 57, 1), Decl(derivedUninitializedPropertyDeclaration.ts, 58, 25)) + + q!: 1 | 2 | 3 // ok, extends a property from an interface +>q : Symbol(K.q, Decl(derivedUninitializedPropertyDeclaration.ts, 62, 19)) + + r!: 4 | 5 // error, from class +>r : Symbol(K.r, Decl(derivedUninitializedPropertyDeclaration.ts, 63, 17)) +} + diff --git a/tests/baselines/reference/derivedUninitializedPropertyDeclaration.types b/tests/baselines/reference/derivedUninitializedPropertyDeclaration.types new file mode 100644 index 0000000000000..d9c96f0c9fc07 --- /dev/null +++ b/tests/baselines/reference/derivedUninitializedPropertyDeclaration.types @@ -0,0 +1,152 @@ +=== tests/cases/conformance/classes/propertyMemberDeclarations/derivedUninitializedPropertyDeclaration.ts === +class A { +>A : A + + property = 'x'; +>property : string +>'x' : "x" + + m() { return 1 } +>m : () => number +>1 : 1 +} +class B extends A { +>B : B +>A : A + + property: any; // error +>property : any +} +class BD extends A { +>BD : BD +>A : A + + declare property: any; // ok because it's implicitly initialised +>property : any +} +class BDBang extends A { +>BDBang : BDBang +>A : A + + declare property!: any; // ! is not allowed, this is an ambient declaration +>property : any +} +class BOther extends A { +>BOther : BOther +>A : A + + declare m() { return 2 } // not allowed on methods +>m : () => number +>2 : 2 + + declare nonce: any; // ok, even though it's not in the base +>nonce : any + + declare property = 'y' // initialiser not allowed with declare +>property : string +>'y' : "y" +} +class U { +>U : U + + declare nonce: any; // ok, even though there's no base +>nonce : any +} + +class C { +>C : C + + p: string; +>p : string +} +class D extends C { +>D : D +>C : C + + p: 'hi'; // error +>p : "hi" +} +class DD extends C { +>DD : DD +>C : C + + declare p: 'bye'; // ok +>p : "bye" +} + + +declare class E { +>E : E + + p1: string +>p1 : string + + p2: string +>p2 : string +} +class F extends E { +>F : F +>E : E + + p1!: 'z' +>p1 : "z" + + declare p2: 'alpha' +>p2 : "alpha" +} + +class G extends E { +>G : G +>E : E + + p1: 'z' +>p1 : "z" + + constructor() { + super() +>super() : void +>super : typeof E + + this.p1 = 'z' +>this.p1 = 'z' : "z" +>this.p1 : "z" +>this : this +>p1 : "z" +>'z' : "z" + } +} + +abstract class H extends E { +>H : H +>E : E + + abstract p1: 'a' | 'b' | 'c' +>p1 : "a" | "b" | "c" + + declare abstract p2: 'a' | 'b' | 'c' +>p2 : "a" | "b" | "c" +} + +interface I { + q: number +>q : number +} +interface J extends I { } +class J { +>J : J + + r = 5 +>r : number +>5 : 5 +} +class K extends J { +>K : K +>J : J + + q!: 1 | 2 | 3 // ok, extends a property from an interface +>q : 1 | 2 | 3 + + r!: 4 | 5 // error, from class +>r : 5 | 4 +} + diff --git a/tests/baselines/reference/dynamicNamesErrors.js b/tests/baselines/reference/dynamicNamesErrors.js index ff6bdec604f31..8433527d73fd6 100644 --- a/tests/baselines/reference/dynamicNamesErrors.js +++ b/tests/baselines/reference/dynamicNamesErrors.js @@ -101,12 +101,12 @@ export interface InterfaceMemberVisibility { export declare class ClassMemberVisibility { static [x]: number; static [y](): number; - static readonly [z]: number; - static [w]: number; + static get [z](): number; + static set [w](value: number); [x]: number; [y](): number; - readonly [z]: number; - [w]: number; + get [z](): number; + set [w](value: number); } export declare type ObjectTypeVisibility = { [x]: number; diff --git a/tests/baselines/reference/giant.js b/tests/baselines/reference/giant.js index 85686faa01e98..9adf046d8cfc2 100644 --- a/tests/baselines/reference/giant.js +++ b/tests/baselines/reference/giant.js @@ -1120,19 +1120,19 @@ export declare class eC { pF(): void; private rF; pgF(): void; - readonly pgF: any; + get pgF(): any; psF(param: any): void; - psF: any; + set psF(param: any); private rgF; - private readonly rgF; - private rsF; + private get rgF(); private rsF; + private set rsF(value); static tV: any; static tF(): void; static tsF(param: any): void; - static tsF: any; + static set tsF(param: any); static tgF(): void; - static readonly tgF: any; + static get tgF(): any; } export interface eI { (): any; @@ -1172,19 +1172,19 @@ export declare module eM { pF(): void; private rF; pgF(): void; - readonly pgF: any; + get pgF(): any; psF(param: any): void; - psF: any; + set psF(param: any); private rgF; - private readonly rgF; - private rsF; + private get rgF(); private rsF; + private set rsF(value); static tV: any; static tF(): void; static tsF(param: any): void; - static tsF: any; + static set tsF(param: any); static tgF(): void; - static readonly tgF: any; + static get tgF(): any; } interface eI { (): any; diff --git a/tests/baselines/reference/illegalModifiersOnClassElements.errors.txt b/tests/baselines/reference/illegalModifiersOnClassElements.errors.txt index eb373ad2fae07..99ba043b52a80 100644 --- a/tests/baselines/reference/illegalModifiersOnClassElements.errors.txt +++ b/tests/baselines/reference/illegalModifiersOnClassElements.errors.txt @@ -1,12 +1,12 @@ -tests/cases/compiler/illegalModifiersOnClassElements.ts(2,5): error TS1031: 'declare' modifier cannot appear on a class element. +tests/cases/compiler/illegalModifiersOnClassElements.ts(2,19): error TS1039: Initializers are not allowed in ambient contexts. tests/cases/compiler/illegalModifiersOnClassElements.ts(3,5): error TS1031: 'export' modifier cannot appear on a class element. ==== tests/cases/compiler/illegalModifiersOnClassElements.ts (2 errors) ==== class C { declare foo = 1; - ~~~~~~~ -!!! error TS1031: 'declare' modifier cannot appear on a class element. + ~ +!!! error TS1039: Initializers are not allowed in ambient contexts. export bar = 1; ~~~~~~ !!! error TS1031: 'export' modifier cannot appear on a class element. diff --git a/tests/baselines/reference/inheritanceMemberAccessorOverridingMethod.errors.txt b/tests/baselines/reference/inheritanceMemberAccessorOverridingMethod.errors.txt new file mode 100644 index 0000000000000..52ae20032e628 --- /dev/null +++ b/tests/baselines/reference/inheritanceMemberAccessorOverridingMethod.errors.txt @@ -0,0 +1,20 @@ +tests/cases/compiler/inheritanceMemberAccessorOverridingMethod.ts(8,9): error TS2423: Class 'a' defines instance member function 'x', but extended class 'b' defines it as instance member accessor. + + +==== tests/cases/compiler/inheritanceMemberAccessorOverridingMethod.ts (1 errors) ==== + class a { + x() { + return "20"; + } + } + + class b extends a { + get x() { + ~ +!!! error TS2423: Class 'a' defines instance member function 'x', but extended class 'b' defines it as instance member accessor. + return () => "20"; + } + set x(aValue) { + + } + } \ No newline at end of file diff --git a/tests/baselines/reference/inheritanceMemberPropertyOverridingMethod.errors.txt b/tests/baselines/reference/inheritanceMemberPropertyOverridingMethod.errors.txt new file mode 100644 index 0000000000000..2b56866b22b33 --- /dev/null +++ b/tests/baselines/reference/inheritanceMemberPropertyOverridingMethod.errors.txt @@ -0,0 +1,15 @@ +tests/cases/compiler/inheritanceMemberPropertyOverridingMethod.ts(8,5): error TS2424: Class 'a' defines instance member function 'x', but extended class 'b' defines it as instance member property. + + +==== tests/cases/compiler/inheritanceMemberPropertyOverridingMethod.ts (1 errors) ==== + class a { + x() { + return "20"; + } + } + + class b extends a { + x: () => string; + ~ +!!! error TS2424: Class 'a' defines instance member function 'x', but extended class 'b' defines it as instance member property. + } \ No newline at end of file diff --git a/tests/baselines/reference/isDeclarationVisibleNodeKinds.js b/tests/baselines/reference/isDeclarationVisibleNodeKinds.js index 83a926ab7d2eb..40f5e59083c0c 100644 --- a/tests/baselines/reference/isDeclarationVisibleNodeKinds.js +++ b/tests/baselines/reference/isDeclarationVisibleNodeKinds.js @@ -184,7 +184,7 @@ declare module schema { } declare module schema { class T { - readonly createValidator9: (data: T) => T; - createValidator10: (data: T) => T; + get createValidator9(): (data: T) => T; + set createValidator10(v: (data: T) => T); } } diff --git a/tests/baselines/reference/moduledecl.js b/tests/baselines/reference/moduledecl.js index de7a5434e4df6..9672b980929b0 100644 --- a/tests/baselines/reference/moduledecl.js +++ b/tests/baselines/reference/moduledecl.js @@ -457,10 +457,10 @@ declare module exportTests { class C3_public { private getC2_private; private setC2_private; - private readonly c2; + private get c2(); getC1_public(): C1_public; setC1_public(arg: C1_public): void; - readonly c1: C1_public; + get c1(): C1_public; } } declare module mAmbient { diff --git a/tests/baselines/reference/overrideInterfaceProperty.js b/tests/baselines/reference/overrideInterfaceProperty.js new file mode 100644 index 0000000000000..0c1029b0c1129 --- /dev/null +++ b/tests/baselines/reference/overrideInterfaceProperty.js @@ -0,0 +1,31 @@ +//// [overrideInterfaceProperty.ts] +interface Mup { + readonly size: number; +} +interface MupConstructor { + new(): Mup; + new(entries?: readonly (readonly [K, V])[] | null): Mup; + readonly prototype: Mup; +} +declare var Mup: MupConstructor; + +class Sizz extends Mup { + // ok, because Mup is an interface + get size() { return 0 } +} +class Kasizz extends Mup { + size = -1 +} + + +//// [overrideInterfaceProperty.js] +class Sizz extends Mup { + // ok, because Mup is an interface + get size() { return 0; } +} +class Kasizz extends Mup { + constructor() { + super(...arguments); + this.size = -1; + } +} diff --git a/tests/baselines/reference/overrideInterfaceProperty.symbols b/tests/baselines/reference/overrideInterfaceProperty.symbols new file mode 100644 index 0000000000000..37f0f99a1070a --- /dev/null +++ b/tests/baselines/reference/overrideInterfaceProperty.symbols @@ -0,0 +1,49 @@ +=== tests/cases/conformance/classes/propertyMemberDeclarations/overrideInterfaceProperty.ts === +interface Mup { +>Mup : Symbol(Mup, Decl(overrideInterfaceProperty.ts, 0, 0), Decl(overrideInterfaceProperty.ts, 8, 11)) +>K : Symbol(K, Decl(overrideInterfaceProperty.ts, 0, 14)) +>V : Symbol(V, Decl(overrideInterfaceProperty.ts, 0, 16)) + + readonly size: number; +>size : Symbol(Mup.size, Decl(overrideInterfaceProperty.ts, 0, 21)) +} +interface MupConstructor { +>MupConstructor : Symbol(MupConstructor, Decl(overrideInterfaceProperty.ts, 2, 1)) + + new(): Mup; +>Mup : Symbol(Mup, Decl(overrideInterfaceProperty.ts, 0, 0), Decl(overrideInterfaceProperty.ts, 8, 11)) + + new(entries?: readonly (readonly [K, V])[] | null): Mup; +>K : Symbol(K, Decl(overrideInterfaceProperty.ts, 5, 8)) +>V : Symbol(V, Decl(overrideInterfaceProperty.ts, 5, 10)) +>entries : Symbol(entries, Decl(overrideInterfaceProperty.ts, 5, 14)) +>K : Symbol(K, Decl(overrideInterfaceProperty.ts, 5, 8)) +>V : Symbol(V, Decl(overrideInterfaceProperty.ts, 5, 10)) +>Mup : Symbol(Mup, Decl(overrideInterfaceProperty.ts, 0, 0), Decl(overrideInterfaceProperty.ts, 8, 11)) +>K : Symbol(K, Decl(overrideInterfaceProperty.ts, 5, 8)) +>V : Symbol(V, Decl(overrideInterfaceProperty.ts, 5, 10)) + + readonly prototype: Mup; +>prototype : Symbol(MupConstructor.prototype, Decl(overrideInterfaceProperty.ts, 5, 72)) +>Mup : Symbol(Mup, Decl(overrideInterfaceProperty.ts, 0, 0), Decl(overrideInterfaceProperty.ts, 8, 11)) +} +declare var Mup: MupConstructor; +>Mup : Symbol(Mup, Decl(overrideInterfaceProperty.ts, 0, 0), Decl(overrideInterfaceProperty.ts, 8, 11)) +>MupConstructor : Symbol(MupConstructor, Decl(overrideInterfaceProperty.ts, 2, 1)) + +class Sizz extends Mup { +>Sizz : Symbol(Sizz, Decl(overrideInterfaceProperty.ts, 8, 32)) +>Mup : Symbol(Mup, Decl(overrideInterfaceProperty.ts, 0, 0), Decl(overrideInterfaceProperty.ts, 8, 11)) + + // ok, because Mup is an interface + get size() { return 0 } +>size : Symbol(Sizz.size, Decl(overrideInterfaceProperty.ts, 10, 24)) +} +class Kasizz extends Mup { +>Kasizz : Symbol(Kasizz, Decl(overrideInterfaceProperty.ts, 13, 1)) +>Mup : Symbol(Mup, Decl(overrideInterfaceProperty.ts, 0, 0), Decl(overrideInterfaceProperty.ts, 8, 11)) + + size = -1 +>size : Symbol(Kasizz.size, Decl(overrideInterfaceProperty.ts, 14, 26)) +} + diff --git a/tests/baselines/reference/overrideInterfaceProperty.types b/tests/baselines/reference/overrideInterfaceProperty.types new file mode 100644 index 0000000000000..69bf70e7358d5 --- /dev/null +++ b/tests/baselines/reference/overrideInterfaceProperty.types @@ -0,0 +1,36 @@ +=== tests/cases/conformance/classes/propertyMemberDeclarations/overrideInterfaceProperty.ts === +interface Mup { + readonly size: number; +>size : number +} +interface MupConstructor { + new(): Mup; + new(entries?: readonly (readonly [K, V])[] | null): Mup; +>entries : readonly (readonly [K, V])[] +>null : null + + readonly prototype: Mup; +>prototype : Mup +} +declare var Mup: MupConstructor; +>Mup : MupConstructor + +class Sizz extends Mup { +>Sizz : Sizz +>Mup : Mup + + // ok, because Mup is an interface + get size() { return 0 } +>size : number +>0 : 0 +} +class Kasizz extends Mup { +>Kasizz : Kasizz +>Mup : Mup + + size = -1 +>size : number +>-1 : -1 +>1 : 1 +} + diff --git a/tests/baselines/reference/parserMemberFunctionDeclaration5.errors.txt b/tests/baselines/reference/parserMemberFunctionDeclaration5.errors.txt index dc19cb0f8550a..402355919a031 100644 --- a/tests/baselines/reference/parserMemberFunctionDeclaration5.errors.txt +++ b/tests/baselines/reference/parserMemberFunctionDeclaration5.errors.txt @@ -1,9 +1,12 @@ tests/cases/conformance/parser/ecmascript5/MemberFunctionDeclarations/parserMemberFunctionDeclaration5.ts(2,5): error TS1031: 'declare' modifier cannot appear on a class element. +tests/cases/conformance/parser/ecmascript5/MemberFunctionDeclarations/parserMemberFunctionDeclaration5.ts(2,19): error TS1183: An implementation cannot be declared in ambient contexts. -==== tests/cases/conformance/parser/ecmascript5/MemberFunctionDeclarations/parserMemberFunctionDeclaration5.ts (1 errors) ==== +==== tests/cases/conformance/parser/ecmascript5/MemberFunctionDeclarations/parserMemberFunctionDeclaration5.ts (2 errors) ==== class C { declare Foo() { } ~~~~~~~ !!! error TS1031: 'declare' modifier cannot appear on a class element. + ~ +!!! error TS1183: An implementation cannot be declared in ambient contexts. } \ No newline at end of file diff --git a/tests/baselines/reference/parserMemberVariableDeclaration5.errors.txt b/tests/baselines/reference/parserMemberVariableDeclaration5.errors.txt deleted file mode 100644 index 2b2ea9664ceb4..0000000000000 --- a/tests/baselines/reference/parserMemberVariableDeclaration5.errors.txt +++ /dev/null @@ -1,9 +0,0 @@ -tests/cases/conformance/parser/ecmascript5/MemberVariableDeclarations/parserMemberVariableDeclaration5.ts(2,3): error TS1031: 'declare' modifier cannot appear on a class element. - - -==== tests/cases/conformance/parser/ecmascript5/MemberVariableDeclarations/parserMemberVariableDeclaration5.ts (1 errors) ==== - class C { - declare Foo; - ~~~~~~~ -!!! error TS1031: 'declare' modifier cannot appear on a class element. - } \ No newline at end of file diff --git a/tests/baselines/reference/privacyAccessorDeclFile.js b/tests/baselines/reference/privacyAccessorDeclFile.js index a7eb6296f5c8e..1c84bd63749d6 100644 --- a/tests/baselines/reference/privacyAccessorDeclFile.js +++ b/tests/baselines/reference/privacyAccessorDeclFile.js @@ -3562,46 +3562,46 @@ declare class privateClass { export declare class publicClass { } export declare class publicClassWithWithPrivateGetAccessorTypes { - static readonly myPublicStaticMethod: privateClass; - private static readonly myPrivateStaticMethod; - readonly myPublicMethod: privateClass; - private readonly myPrivateMethod; - static readonly myPublicStaticMethod1: privateClass; - private static readonly myPrivateStaticMethod1; - readonly myPublicMethod1: privateClass; - private readonly myPrivateMethod1; + static get myPublicStaticMethod(): privateClass; + private static get myPrivateStaticMethod(); + get myPublicMethod(): privateClass; + private get myPrivateMethod(); + static get myPublicStaticMethod1(): privateClass; + private static get myPrivateStaticMethod1(); + get myPublicMethod1(): privateClass; + private get myPrivateMethod1(); } export declare class publicClassWithWithPublicGetAccessorTypes { - static readonly myPublicStaticMethod: publicClass; - private static readonly myPrivateStaticMethod; - readonly myPublicMethod: publicClass; - private readonly myPrivateMethod; - static readonly myPublicStaticMethod1: publicClass; - private static readonly myPrivateStaticMethod1; - readonly myPublicMethod1: publicClass; - private readonly myPrivateMethod1; + static get myPublicStaticMethod(): publicClass; + private static get myPrivateStaticMethod(); + get myPublicMethod(): publicClass; + private get myPrivateMethod(); + static get myPublicStaticMethod1(): publicClass; + private static get myPrivateStaticMethod1(); + get myPublicMethod1(): publicClass; + private get myPrivateMethod1(); } export declare class publicClassWithWithPrivateSetAccessorTypes { - static myPublicStaticMethod: privateClass; - private static myPrivateStaticMethod; - myPublicMethod: privateClass; - private myPrivateMethod; + static set myPublicStaticMethod(param: privateClass); + private static set myPrivateStaticMethod(value); + set myPublicMethod(param: privateClass); + private set myPrivateMethod(value); } export declare class publicClassWithWithPublicSetAccessorTypes { - static myPublicStaticMethod: publicClass; - private static myPrivateStaticMethod; - myPublicMethod: publicClass; - private myPrivateMethod; + static set myPublicStaticMethod(param: publicClass); + private static set myPrivateStaticMethod(value); + set myPublicMethod(param: publicClass); + private set myPrivateMethod(value); } export declare class publicClassWithPrivateModuleGetAccessorTypes { - static readonly myPublicStaticMethod: privateModule.publicClass; - readonly myPublicMethod: privateModule.publicClass; - static readonly myPublicStaticMethod1: privateModule.publicClass; - readonly myPublicMethod1: privateModule.publicClass; + static get myPublicStaticMethod(): privateModule.publicClass; + get myPublicMethod(): privateModule.publicClass; + static get myPublicStaticMethod1(): privateModule.publicClass; + get myPublicMethod1(): privateModule.publicClass; } export declare class publicClassWithPrivateModuleSetAccessorTypes { - static myPublicStaticMethod: privateModule.publicClass; - myPublicMethod: privateModule.publicClass; + static set myPublicStaticMethod(param: privateModule.publicClass); + set myPublicMethod(param: privateModule.publicClass); } export declare module publicModule { class privateClass { @@ -3609,46 +3609,46 @@ export declare module publicModule { export class publicClass { } export class publicClassWithWithPrivateGetAccessorTypes { - static readonly myPublicStaticMethod: privateClass; - private static readonly myPrivateStaticMethod; - readonly myPublicMethod: privateClass; - private readonly myPrivateMethod; - static readonly myPublicStaticMethod1: privateClass; - private static readonly myPrivateStaticMethod1; - readonly myPublicMethod1: privateClass; - private readonly myPrivateMethod1; + static get myPublicStaticMethod(): privateClass; + private static get myPrivateStaticMethod(); + get myPublicMethod(): privateClass; + private get myPrivateMethod(); + static get myPublicStaticMethod1(): privateClass; + private static get myPrivateStaticMethod1(); + get myPublicMethod1(): privateClass; + private get myPrivateMethod1(); } export class publicClassWithWithPublicGetAccessorTypes { - static readonly myPublicStaticMethod: publicClass; - private static readonly myPrivateStaticMethod; - readonly myPublicMethod: publicClass; - private readonly myPrivateMethod; - static readonly myPublicStaticMethod1: publicClass; - private static readonly myPrivateStaticMethod1; - readonly myPublicMethod1: publicClass; - private readonly myPrivateMethod1; + static get myPublicStaticMethod(): publicClass; + private static get myPrivateStaticMethod(); + get myPublicMethod(): publicClass; + private get myPrivateMethod(); + static get myPublicStaticMethod1(): publicClass; + private static get myPrivateStaticMethod1(); + get myPublicMethod1(): publicClass; + private get myPrivateMethod1(); } export class publicClassWithWithPrivateSetAccessorTypes { - static myPublicStaticMethod: privateClass; - private static myPrivateStaticMethod; - myPublicMethod: privateClass; - private myPrivateMethod; + static set myPublicStaticMethod(param: privateClass); + private static set myPrivateStaticMethod(value); + set myPublicMethod(param: privateClass); + private set myPrivateMethod(value); } export class publicClassWithWithPublicSetAccessorTypes { - static myPublicStaticMethod: publicClass; - private static myPrivateStaticMethod; - myPublicMethod: publicClass; - private myPrivateMethod; + static set myPublicStaticMethod(param: publicClass); + private static set myPrivateStaticMethod(value); + set myPublicMethod(param: publicClass); + private set myPrivateMethod(value); } export class publicClassWithPrivateModuleGetAccessorTypes { - static readonly myPublicStaticMethod: privateModule.publicClass; - readonly myPublicMethod: privateModule.publicClass; - static readonly myPublicStaticMethod1: privateModule.publicClass; - readonly myPublicMethod1: privateModule.publicClass; + static get myPublicStaticMethod(): privateModule.publicClass; + get myPublicMethod(): privateModule.publicClass; + static get myPublicStaticMethod1(): privateModule.publicClass; + get myPublicMethod1(): privateModule.publicClass; } export class publicClassWithPrivateModuleSetAccessorTypes { - static myPublicStaticMethod: privateModule.publicClass; - myPublicMethod: privateModule.publicClass; + static set myPublicStaticMethod(param: privateModule.publicClass); + set myPublicMethod(param: privateModule.publicClass); } export {}; } @@ -3658,46 +3658,46 @@ declare module privateModule { export class publicClass { } export class publicClassWithWithPrivateGetAccessorTypes { - static readonly myPublicStaticMethod: privateClass; - private static readonly myPrivateStaticMethod; - readonly myPublicMethod: privateClass; - private readonly myPrivateMethod; - static readonly myPublicStaticMethod1: privateClass; - private static readonly myPrivateStaticMethod1; - readonly myPublicMethod1: privateClass; - private readonly myPrivateMethod1; + static get myPublicStaticMethod(): privateClass; + private static get myPrivateStaticMethod(); + get myPublicMethod(): privateClass; + private get myPrivateMethod(); + static get myPublicStaticMethod1(): privateClass; + private static get myPrivateStaticMethod1(); + get myPublicMethod1(): privateClass; + private get myPrivateMethod1(); } export class publicClassWithWithPublicGetAccessorTypes { - static readonly myPublicStaticMethod: publicClass; - private static readonly myPrivateStaticMethod; - readonly myPublicMethod: publicClass; - private readonly myPrivateMethod; - static readonly myPublicStaticMethod1: publicClass; - private static readonly myPrivateStaticMethod1; - readonly myPublicMethod1: publicClass; - private readonly myPrivateMethod1; + static get myPublicStaticMethod(): publicClass; + private static get myPrivateStaticMethod(); + get myPublicMethod(): publicClass; + private get myPrivateMethod(); + static get myPublicStaticMethod1(): publicClass; + private static get myPrivateStaticMethod1(); + get myPublicMethod1(): publicClass; + private get myPrivateMethod1(); } export class publicClassWithWithPrivateSetAccessorTypes { - static myPublicStaticMethod: privateClass; - private static myPrivateStaticMethod; - myPublicMethod: privateClass; - private myPrivateMethod; + static set myPublicStaticMethod(param: privateClass); + private static set myPrivateStaticMethod(value); + set myPublicMethod(param: privateClass); + private set myPrivateMethod(value); } export class publicClassWithWithPublicSetAccessorTypes { - static myPublicStaticMethod: publicClass; - private static myPrivateStaticMethod; - myPublicMethod: publicClass; - private myPrivateMethod; + static set myPublicStaticMethod(param: publicClass); + private static set myPrivateStaticMethod(value); + set myPublicMethod(param: publicClass); + private set myPrivateMethod(value); } export class publicClassWithPrivateModuleGetAccessorTypes { - static readonly myPublicStaticMethod: privateModule.publicClass; - readonly myPublicMethod: privateModule.publicClass; - static readonly myPublicStaticMethod1: publicClass; - readonly myPublicMethod1: publicClass; + static get myPublicStaticMethod(): privateModule.publicClass; + get myPublicMethod(): privateModule.publicClass; + static get myPublicStaticMethod1(): publicClass; + get myPublicMethod1(): publicClass; } export class publicClassWithPrivateModuleSetAccessorTypes { - static myPublicStaticMethod: privateModule.publicClass; - myPublicMethod: privateModule.publicClass; + static set myPublicStaticMethod(param: privateModule.publicClass); + set myPublicMethod(param: privateModule.publicClass); } export {}; } @@ -3706,20 +3706,20 @@ export {}; declare class publicClassInGlobal { } declare class publicClassInGlobalWithPublicGetAccessorTypes { - static readonly myPublicStaticMethod: publicClassInGlobal; - private static readonly myPrivateStaticMethod; - readonly myPublicMethod: publicClassInGlobal; - private readonly myPrivateMethod; - static readonly myPublicStaticMethod1: publicClassInGlobal; - private static readonly myPrivateStaticMethod1; - readonly myPublicMethod1: publicClassInGlobal; - private readonly myPrivateMethod1; + static get myPublicStaticMethod(): publicClassInGlobal; + private static get myPrivateStaticMethod(); + get myPublicMethod(): publicClassInGlobal; + private get myPrivateMethod(); + static get myPublicStaticMethod1(): publicClassInGlobal; + private static get myPrivateStaticMethod1(); + get myPublicMethod1(): publicClassInGlobal; + private get myPrivateMethod1(); } declare class publicClassInGlobalWithWithPublicSetAccessorTypes { - static myPublicStaticMethod: publicClassInGlobal; - private static myPrivateStaticMethod; - myPublicMethod: publicClassInGlobal; - private myPrivateMethod; + static set myPublicStaticMethod(param: publicClassInGlobal); + private static set myPrivateStaticMethod(value); + set myPublicMethod(param: publicClassInGlobal); + private set myPrivateMethod(value); } declare module publicModuleInGlobal { class privateClass { @@ -3732,90 +3732,90 @@ declare module publicModuleInGlobal { export class publicClass { } export class publicClassWithWithPrivateGetAccessorTypes { - static readonly myPublicStaticMethod: privateClass; - private static readonly myPrivateStaticMethod; - readonly myPublicMethod: privateClass; - private readonly myPrivateMethod; - static readonly myPublicStaticMethod1: privateClass; - private static readonly myPrivateStaticMethod1; - readonly myPublicMethod1: privateClass; - private readonly myPrivateMethod1; + static get myPublicStaticMethod(): privateClass; + private static get myPrivateStaticMethod(); + get myPublicMethod(): privateClass; + private get myPrivateMethod(); + static get myPublicStaticMethod1(): privateClass; + private static get myPrivateStaticMethod1(); + get myPublicMethod1(): privateClass; + private get myPrivateMethod1(); } export class publicClassWithWithPublicGetAccessorTypes { - static readonly myPublicStaticMethod: publicClass; - private static readonly myPrivateStaticMethod; - readonly myPublicMethod: publicClass; - private readonly myPrivateMethod; - static readonly myPublicStaticMethod1: publicClass; - private static readonly myPrivateStaticMethod1; - readonly myPublicMethod1: publicClass; - private readonly myPrivateMethod1; + static get myPublicStaticMethod(): publicClass; + private static get myPrivateStaticMethod(); + get myPublicMethod(): publicClass; + private get myPrivateMethod(); + static get myPublicStaticMethod1(): publicClass; + private static get myPrivateStaticMethod1(); + get myPublicMethod1(): publicClass; + private get myPrivateMethod1(); } export class publicClassWithWithPrivateSetAccessorTypes { - static myPublicStaticMethod: privateClass; - private static myPrivateStaticMethod; - myPublicMethod: privateClass; - private myPrivateMethod; + static set myPublicStaticMethod(param: privateClass); + private static set myPrivateStaticMethod(value); + set myPublicMethod(param: privateClass); + private set myPrivateMethod(value); } export class publicClassWithWithPublicSetAccessorTypes { - static myPublicStaticMethod: publicClass; - private static myPrivateStaticMethod; - myPublicMethod: publicClass; - private myPrivateMethod; + static set myPublicStaticMethod(param: publicClass); + private static set myPrivateStaticMethod(value); + set myPublicMethod(param: publicClass); + private set myPrivateMethod(value); } export class publicClassWithPrivateModuleGetAccessorTypes { - static readonly myPublicStaticMethod: privateModule.publicClass; - readonly myPublicMethod: privateModule.publicClass; - static readonly myPublicStaticMethod1: publicClass; - readonly myPublicMethod1: publicClass; + static get myPublicStaticMethod(): privateModule.publicClass; + get myPublicMethod(): privateModule.publicClass; + static get myPublicStaticMethod1(): publicClass; + get myPublicMethod1(): publicClass; } export class publicClassWithPrivateModuleSetAccessorTypes { - static myPublicStaticMethod: privateModule.publicClass; - myPublicMethod: privateModule.publicClass; + static set myPublicStaticMethod(param: privateModule.publicClass); + set myPublicMethod(param: privateModule.publicClass); } export {}; } export class publicClassWithWithPrivateGetAccessorTypes { - static readonly myPublicStaticMethod: privateClass; - private static readonly myPrivateStaticMethod; - readonly myPublicMethod: privateClass; - private readonly myPrivateMethod; - static readonly myPublicStaticMethod1: privateClass; - private static readonly myPrivateStaticMethod1; - readonly myPublicMethod1: privateClass; - private readonly myPrivateMethod1; + static get myPublicStaticMethod(): privateClass; + private static get myPrivateStaticMethod(); + get myPublicMethod(): privateClass; + private get myPrivateMethod(); + static get myPublicStaticMethod1(): privateClass; + private static get myPrivateStaticMethod1(); + get myPublicMethod1(): privateClass; + private get myPrivateMethod1(); } export class publicClassWithWithPublicGetAccessorTypes { - static readonly myPublicStaticMethod: publicClass; - private static readonly myPrivateStaticMethod; - readonly myPublicMethod: publicClass; - private readonly myPrivateMethod; - static readonly myPublicStaticMethod1: publicClass; - private static readonly myPrivateStaticMethod1; - readonly myPublicMethod1: publicClass; - private readonly myPrivateMethod1; + static get myPublicStaticMethod(): publicClass; + private static get myPrivateStaticMethod(); + get myPublicMethod(): publicClass; + private get myPrivateMethod(); + static get myPublicStaticMethod1(): publicClass; + private static get myPrivateStaticMethod1(); + get myPublicMethod1(): publicClass; + private get myPrivateMethod1(); } export class publicClassWithWithPrivateSetAccessorTypes { - static myPublicStaticMethod: privateClass; - private static myPrivateStaticMethod; - myPublicMethod: privateClass; - private myPrivateMethod; + static set myPublicStaticMethod(param: privateClass); + private static set myPrivateStaticMethod(value); + set myPublicMethod(param: privateClass); + private set myPrivateMethod(value); } export class publicClassWithWithPublicSetAccessorTypes { - static myPublicStaticMethod: publicClass; - private static myPrivateStaticMethod; - myPublicMethod: publicClass; - private myPrivateMethod; + static set myPublicStaticMethod(param: publicClass); + private static set myPrivateStaticMethod(value); + set myPublicMethod(param: publicClass); + private set myPrivateMethod(value); } export class publicClassWithPrivateModuleGetAccessorTypes { - static readonly myPublicStaticMethod: privateModule.publicClass; - readonly myPublicMethod: privateModule.publicClass; - static readonly myPublicStaticMethod1: privateModule.publicClass; - readonly myPublicMethod1: privateModule.publicClass; + static get myPublicStaticMethod(): privateModule.publicClass; + get myPublicMethod(): privateModule.publicClass; + static get myPublicStaticMethod1(): privateModule.publicClass; + get myPublicMethod1(): privateModule.publicClass; } export class publicClassWithPrivateModuleSetAccessorTypes { - static myPublicStaticMethod: privateModule.publicClass; - myPublicMethod: privateModule.publicClass; + static set myPublicStaticMethod(param: privateModule.publicClass); + set myPublicMethod(param: privateModule.publicClass); } export {}; } diff --git a/tests/baselines/reference/privacyCannotNameAccessorDeclFile.js b/tests/baselines/reference/privacyCannotNameAccessorDeclFile.js index 42f7639986913..e0dc38bcfcd58 100644 --- a/tests/baselines/reference/privacyCannotNameAccessorDeclFile.js +++ b/tests/baselines/reference/privacyCannotNameAccessorDeclFile.js @@ -417,18 +417,18 @@ export declare function createExportedWidget4(): Widgets1.SpecializedGlobalWidge //// [privacyCannotNameAccessorDeclFile_consumer.d.ts] /// export declare class publicClassWithWithPrivateGetAccessorTypes { - static readonly myPublicStaticMethod: import("./privacyCannotNameAccessorDeclFile_Widgets").Widget1; - private static readonly myPrivateStaticMethod; - readonly myPublicMethod: import("./privacyCannotNameAccessorDeclFile_Widgets").Widget1; - private readonly myPrivateMethod; - static readonly myPublicStaticMethod1: import("GlobalWidgets").Widget3; - private static readonly myPrivateStaticMethod1; - readonly myPublicMethod1: import("GlobalWidgets").Widget3; - private readonly myPrivateMethod1; + static get myPublicStaticMethod(): import("./privacyCannotNameAccessorDeclFile_Widgets").Widget1; + private static get myPrivateStaticMethod(); + get myPublicMethod(): import("./privacyCannotNameAccessorDeclFile_Widgets").Widget1; + private get myPrivateMethod(); + static get myPublicStaticMethod1(): import("GlobalWidgets").Widget3; + private static get myPrivateStaticMethod1(); + get myPublicMethod1(): import("GlobalWidgets").Widget3; + private get myPrivateMethod1(); } export declare class publicClassWithPrivateModuleGetAccessorTypes { - static readonly myPublicStaticMethod: import("./privacyCannotNameAccessorDeclFile_Widgets").SpecializedWidget.Widget2; - readonly myPublicMethod: import("./privacyCannotNameAccessorDeclFile_Widgets").SpecializedWidget.Widget2; - static readonly myPublicStaticMethod1: import("GlobalWidgets").SpecializedGlobalWidget.Widget4; - readonly myPublicMethod1: import("GlobalWidgets").SpecializedGlobalWidget.Widget4; + static get myPublicStaticMethod(): import("./privacyCannotNameAccessorDeclFile_Widgets").SpecializedWidget.Widget2; + get myPublicMethod(): import("./privacyCannotNameAccessorDeclFile_Widgets").SpecializedWidget.Widget2; + static get myPublicStaticMethod1(): import("GlobalWidgets").SpecializedGlobalWidget.Widget4; + get myPublicMethod1(): import("GlobalWidgets").SpecializedGlobalWidget.Widget4; } diff --git a/tests/baselines/reference/properties.js b/tests/baselines/reference/properties.js index 0b81d7671cdbb..27688f5837578 100644 --- a/tests/baselines/reference/properties.js +++ b/tests/baselines/reference/properties.js @@ -32,5 +32,6 @@ var MyClass = /** @class */ (function () { //// [properties.d.ts] declare class MyClass { - Count: number; + get Count(): number; + set Count(value: number); } diff --git a/tests/baselines/reference/propertyOverridesAccessors.errors.txt b/tests/baselines/reference/propertyOverridesAccessors.errors.txt new file mode 100644 index 0000000000000..dcacf16696d48 --- /dev/null +++ b/tests/baselines/reference/propertyOverridesAccessors.errors.txt @@ -0,0 +1,24 @@ +tests/cases/conformance/classes/propertyMemberDeclarations/propertyOverridesAccessors.ts(5,5): error TS2610: Class 'A' defines instance member accessor 'p', but extended class 'B' defines it as instance member property. +tests/cases/conformance/classes/propertyMemberDeclarations/propertyOverridesAccessors.ts(13,5): error TS2610: Class 'C' defines instance member accessor 'p', but extended class 'D' defines it as instance member property. + + +==== tests/cases/conformance/classes/propertyMemberDeclarations/propertyOverridesAccessors.ts (2 errors) ==== + class A { + get p() { return 'oh no' } + } + class B extends A { + p = 'yep' // error + ~ +!!! error TS2610: Class 'A' defines instance member accessor 'p', but extended class 'B' defines it as instance member property. + } + class C { + _secret = 11 + get p() { return this._secret } + set p(value) { this._secret = value } + } + class D extends C { + p = 101 // error + ~ +!!! error TS2610: Class 'C' defines instance member accessor 'p', but extended class 'D' defines it as instance member property. + } + \ No newline at end of file diff --git a/tests/baselines/reference/propertyOverridesAccessors.js b/tests/baselines/reference/propertyOverridesAccessors.js new file mode 100644 index 0000000000000..d9cc40acc6f39 --- /dev/null +++ b/tests/baselines/reference/propertyOverridesAccessors.js @@ -0,0 +1,55 @@ +//// [propertyOverridesAccessors.ts] +class A { + get p() { return 'oh no' } +} +class B extends A { + p = 'yep' // error +} +class C { + _secret = 11 + get p() { return this._secret } + set p(value) { this._secret = value } +} +class D extends C { + p = 101 // error +} + + +//// [propertyOverridesAccessors.js] +class A { + get p() { return 'oh no'; } +} +class B extends A { + constructor() { + super(...arguments); + Object.defineProperty(this, "p", { + enumerable: true, + configurable: true, + writable: true, + value: 'yep' + }); // error + } +} +class C { + constructor() { + Object.defineProperty(this, "_secret", { + enumerable: true, + configurable: true, + writable: true, + value: 11 + }); + } + get p() { return this._secret; } + set p(value) { this._secret = value; } +} +class D extends C { + constructor() { + super(...arguments); + Object.defineProperty(this, "p", { + enumerable: true, + configurable: true, + writable: true, + value: 101 + }); // error + } +} diff --git a/tests/baselines/reference/propertyOverridesAccessors.symbols b/tests/baselines/reference/propertyOverridesAccessors.symbols new file mode 100644 index 0000000000000..e365fedad0a2e --- /dev/null +++ b/tests/baselines/reference/propertyOverridesAccessors.symbols @@ -0,0 +1,42 @@ +=== tests/cases/conformance/classes/propertyMemberDeclarations/propertyOverridesAccessors.ts === +class A { +>A : Symbol(A, Decl(propertyOverridesAccessors.ts, 0, 0)) + + get p() { return 'oh no' } +>p : Symbol(A.p, Decl(propertyOverridesAccessors.ts, 0, 9)) +} +class B extends A { +>B : Symbol(B, Decl(propertyOverridesAccessors.ts, 2, 1)) +>A : Symbol(A, Decl(propertyOverridesAccessors.ts, 0, 0)) + + p = 'yep' // error +>p : Symbol(B.p, Decl(propertyOverridesAccessors.ts, 3, 19)) +} +class C { +>C : Symbol(C, Decl(propertyOverridesAccessors.ts, 5, 1)) + + _secret = 11 +>_secret : Symbol(C._secret, Decl(propertyOverridesAccessors.ts, 6, 9)) + + get p() { return this._secret } +>p : Symbol(C.p, Decl(propertyOverridesAccessors.ts, 7, 16), Decl(propertyOverridesAccessors.ts, 8, 35)) +>this._secret : Symbol(C._secret, Decl(propertyOverridesAccessors.ts, 6, 9)) +>this : Symbol(C, Decl(propertyOverridesAccessors.ts, 5, 1)) +>_secret : Symbol(C._secret, Decl(propertyOverridesAccessors.ts, 6, 9)) + + set p(value) { this._secret = value } +>p : Symbol(C.p, Decl(propertyOverridesAccessors.ts, 7, 16), Decl(propertyOverridesAccessors.ts, 8, 35)) +>value : Symbol(value, Decl(propertyOverridesAccessors.ts, 9, 10)) +>this._secret : Symbol(C._secret, Decl(propertyOverridesAccessors.ts, 6, 9)) +>this : Symbol(C, Decl(propertyOverridesAccessors.ts, 5, 1)) +>_secret : Symbol(C._secret, Decl(propertyOverridesAccessors.ts, 6, 9)) +>value : Symbol(value, Decl(propertyOverridesAccessors.ts, 9, 10)) +} +class D extends C { +>D : Symbol(D, Decl(propertyOverridesAccessors.ts, 10, 1)) +>C : Symbol(C, Decl(propertyOverridesAccessors.ts, 5, 1)) + + p = 101 // error +>p : Symbol(D.p, Decl(propertyOverridesAccessors.ts, 11, 19)) +} + diff --git a/tests/baselines/reference/propertyOverridesAccessors.types b/tests/baselines/reference/propertyOverridesAccessors.types new file mode 100644 index 0000000000000..9ffec6e8fe68d --- /dev/null +++ b/tests/baselines/reference/propertyOverridesAccessors.types @@ -0,0 +1,47 @@ +=== tests/cases/conformance/classes/propertyMemberDeclarations/propertyOverridesAccessors.ts === +class A { +>A : A + + get p() { return 'oh no' } +>p : string +>'oh no' : "oh no" +} +class B extends A { +>B : B +>A : A + + p = 'yep' // error +>p : string +>'yep' : "yep" +} +class C { +>C : C + + _secret = 11 +>_secret : number +>11 : 11 + + get p() { return this._secret } +>p : number +>this._secret : number +>this : this +>_secret : number + + set p(value) { this._secret = value } +>p : number +>value : number +>this._secret = value : number +>this._secret : number +>this : this +>_secret : number +>value : number +} +class D extends C { +>D : D +>C : C + + p = 101 // error +>p : number +>101 : 101 +} + diff --git a/tests/baselines/reference/propertyOverridesAccessors2.errors.txt b/tests/baselines/reference/propertyOverridesAccessors2.errors.txt new file mode 100644 index 0000000000000..0c91d3b9f7f7a --- /dev/null +++ b/tests/baselines/reference/propertyOverridesAccessors2.errors.txt @@ -0,0 +1,18 @@ +tests/cases/conformance/classes/propertyMemberDeclarations/propertyOverridesAccessors2.ts(7,3): error TS2610: Class 'Base' defines instance member accessor 'x', but extended class 'Derived' defines it as instance member property. + + +==== tests/cases/conformance/classes/propertyMemberDeclarations/propertyOverridesAccessors2.ts (1 errors) ==== + class Base { + get x() { return 2; } + set x(value) { console.log(`x was set to ${value}`); } + } + + class Derived extends Base { + x = 1; + ~ +!!! error TS2610: Class 'Base' defines instance member accessor 'x', but extended class 'Derived' defines it as instance member property. + } + + const obj = new Derived(); // prints 'x was set to 1' + console.log(obj.x); // 2 + \ No newline at end of file diff --git a/tests/baselines/reference/propertyOverridesAccessors2.js b/tests/baselines/reference/propertyOverridesAccessors2.js new file mode 100644 index 0000000000000..bbd8e0fbecf3f --- /dev/null +++ b/tests/baselines/reference/propertyOverridesAccessors2.js @@ -0,0 +1,24 @@ +//// [propertyOverridesAccessors2.ts] +class Base { + get x() { return 2; } + set x(value) { console.log(`x was set to ${value}`); } +} + +class Derived extends Base { + x = 1; +} + +const obj = new Derived(); // prints 'x was set to 1' +console.log(obj.x); // 2 + + +//// [propertyOverridesAccessors2.js] +class Base { + get x() { return 2; } + set x(value) { console.log(`x was set to ${value}`); } +} +class Derived extends Base { + x = 1; +} +const obj = new Derived(); // prints 'x was set to 1' +console.log(obj.x); // 2 diff --git a/tests/baselines/reference/propertyOverridesAccessors2.symbols b/tests/baselines/reference/propertyOverridesAccessors2.symbols new file mode 100644 index 0000000000000..fd26e67e69bf0 --- /dev/null +++ b/tests/baselines/reference/propertyOverridesAccessors2.symbols @@ -0,0 +1,36 @@ +=== tests/cases/conformance/classes/propertyMemberDeclarations/propertyOverridesAccessors2.ts === +class Base { +>Base : Symbol(Base, Decl(propertyOverridesAccessors2.ts, 0, 0)) + + get x() { return 2; } +>x : Symbol(Base.x, Decl(propertyOverridesAccessors2.ts, 0, 12), Decl(propertyOverridesAccessors2.ts, 1, 23)) + + set x(value) { console.log(`x was set to ${value}`); } +>x : Symbol(Base.x, Decl(propertyOverridesAccessors2.ts, 0, 12), Decl(propertyOverridesAccessors2.ts, 1, 23)) +>value : Symbol(value, Decl(propertyOverridesAccessors2.ts, 2, 8)) +>console.log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --)) +>console : Symbol(console, Decl(lib.dom.d.ts, --, --)) +>log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --)) +>value : Symbol(value, Decl(propertyOverridesAccessors2.ts, 2, 8)) +} + +class Derived extends Base { +>Derived : Symbol(Derived, Decl(propertyOverridesAccessors2.ts, 3, 1)) +>Base : Symbol(Base, Decl(propertyOverridesAccessors2.ts, 0, 0)) + + x = 1; +>x : Symbol(Derived.x, Decl(propertyOverridesAccessors2.ts, 5, 28)) +} + +const obj = new Derived(); // prints 'x was set to 1' +>obj : Symbol(obj, Decl(propertyOverridesAccessors2.ts, 9, 5)) +>Derived : Symbol(Derived, Decl(propertyOverridesAccessors2.ts, 3, 1)) + +console.log(obj.x); // 2 +>console.log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --)) +>console : Symbol(console, Decl(lib.dom.d.ts, --, --)) +>log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --)) +>obj.x : Symbol(Derived.x, Decl(propertyOverridesAccessors2.ts, 5, 28)) +>obj : Symbol(obj, Decl(propertyOverridesAccessors2.ts, 9, 5)) +>x : Symbol(Derived.x, Decl(propertyOverridesAccessors2.ts, 5, 28)) + diff --git a/tests/baselines/reference/propertyOverridesAccessors2.types b/tests/baselines/reference/propertyOverridesAccessors2.types new file mode 100644 index 0000000000000..5db511e968184 --- /dev/null +++ b/tests/baselines/reference/propertyOverridesAccessors2.types @@ -0,0 +1,42 @@ +=== tests/cases/conformance/classes/propertyMemberDeclarations/propertyOverridesAccessors2.ts === +class Base { +>Base : Base + + get x() { return 2; } +>x : number +>2 : 2 + + set x(value) { console.log(`x was set to ${value}`); } +>x : number +>value : number +>console.log(`x was set to ${value}`) : void +>console.log : (message?: any, ...optionalParams: any[]) => void +>console : Console +>log : (message?: any, ...optionalParams: any[]) => void +>`x was set to ${value}` : string +>value : number +} + +class Derived extends Base { +>Derived : Derived +>Base : Base + + x = 1; +>x : number +>1 : 1 +} + +const obj = new Derived(); // prints 'x was set to 1' +>obj : Derived +>new Derived() : Derived +>Derived : typeof Derived + +console.log(obj.x); // 2 +>console.log(obj.x) : void +>console.log : (message?: any, ...optionalParams: any[]) => void +>console : Console +>log : (message?: any, ...optionalParams: any[]) => void +>obj.x : number +>obj : Derived +>x : number + diff --git a/tests/baselines/reference/propertyOverridesAccessors3.errors.txt b/tests/baselines/reference/propertyOverridesAccessors3.errors.txt new file mode 100644 index 0000000000000..523a0f6db3d08 --- /dev/null +++ b/tests/baselines/reference/propertyOverridesAccessors3.errors.txt @@ -0,0 +1,30 @@ +tests/cases/conformance/classes/propertyMemberDeclarations/propertyOverridesAccessors3.ts(19,5): error TS2610: Class 'Animal' defines instance member accessor 'sound', but extended class 'Lion' defines it as instance member property. + + +==== tests/cases/conformance/classes/propertyMemberDeclarations/propertyOverridesAccessors3.ts (1 errors) ==== + class Animal { + _sound = 'rustling noise in the bushes' + + get sound() { return this._sound } + set sound(val) { + this._sound = val; + /* some important code here, perhaps tracking known sounds, etc */ + } + + makeSound() { + console.log(this._sound) + } + } + + const a = new Animal + a.makeSound() // 'rustling noise in the bushes' + + class Lion extends Animal { + sound = 'RAWR!' // error here + ~~~~~ +!!! error TS2610: Class 'Animal' defines instance member accessor 'sound', but extended class 'Lion' defines it as instance member property. + } + + const lion = new Lion + lion.makeSound() // with [[Define]]: Expected "RAWR!" but got "rustling noise in the bushes" + \ No newline at end of file diff --git a/tests/baselines/reference/propertyOverridesAccessors3.js b/tests/baselines/reference/propertyOverridesAccessors3.js new file mode 100644 index 0000000000000..ff96cdd19abd7 --- /dev/null +++ b/tests/baselines/reference/propertyOverridesAccessors3.js @@ -0,0 +1,45 @@ +//// [propertyOverridesAccessors3.ts] +class Animal { + _sound = 'rustling noise in the bushes' + + get sound() { return this._sound } + set sound(val) { + this._sound = val; + /* some important code here, perhaps tracking known sounds, etc */ + } + + makeSound() { + console.log(this._sound) + } +} + +const a = new Animal +a.makeSound() // 'rustling noise in the bushes' + +class Lion extends Animal { + sound = 'RAWR!' // error here +} + +const lion = new Lion +lion.makeSound() // with [[Define]]: Expected "RAWR!" but got "rustling noise in the bushes" + + +//// [propertyOverridesAccessors3.js] +class Animal { + _sound = 'rustling noise in the bushes'; + get sound() { return this._sound; } + set sound(val) { + this._sound = val; + /* some important code here, perhaps tracking known sounds, etc */ + } + makeSound() { + console.log(this._sound); + } +} +const a = new Animal; +a.makeSound(); // 'rustling noise in the bushes' +class Lion extends Animal { + sound = 'RAWR!'; // error here +} +const lion = new Lion; +lion.makeSound(); // with [[Define]]: Expected "RAWR!" but got "rustling noise in the bushes" diff --git a/tests/baselines/reference/propertyOverridesAccessors3.symbols b/tests/baselines/reference/propertyOverridesAccessors3.symbols new file mode 100644 index 0000000000000..801b6ca3c9810 --- /dev/null +++ b/tests/baselines/reference/propertyOverridesAccessors3.symbols @@ -0,0 +1,65 @@ +=== tests/cases/conformance/classes/propertyMemberDeclarations/propertyOverridesAccessors3.ts === +class Animal { +>Animal : Symbol(Animal, Decl(propertyOverridesAccessors3.ts, 0, 0)) + + _sound = 'rustling noise in the bushes' +>_sound : Symbol(Animal._sound, Decl(propertyOverridesAccessors3.ts, 0, 14)) + + get sound() { return this._sound } +>sound : Symbol(Animal.sound, Decl(propertyOverridesAccessors3.ts, 1, 43), Decl(propertyOverridesAccessors3.ts, 3, 38)) +>this._sound : Symbol(Animal._sound, Decl(propertyOverridesAccessors3.ts, 0, 14)) +>this : Symbol(Animal, Decl(propertyOverridesAccessors3.ts, 0, 0)) +>_sound : Symbol(Animal._sound, Decl(propertyOverridesAccessors3.ts, 0, 14)) + + set sound(val) { +>sound : Symbol(Animal.sound, Decl(propertyOverridesAccessors3.ts, 1, 43), Decl(propertyOverridesAccessors3.ts, 3, 38)) +>val : Symbol(val, Decl(propertyOverridesAccessors3.ts, 4, 14)) + + this._sound = val; +>this._sound : Symbol(Animal._sound, Decl(propertyOverridesAccessors3.ts, 0, 14)) +>this : Symbol(Animal, Decl(propertyOverridesAccessors3.ts, 0, 0)) +>_sound : Symbol(Animal._sound, Decl(propertyOverridesAccessors3.ts, 0, 14)) +>val : Symbol(val, Decl(propertyOverridesAccessors3.ts, 4, 14)) + + /* some important code here, perhaps tracking known sounds, etc */ + } + + makeSound() { +>makeSound : Symbol(Animal.makeSound, Decl(propertyOverridesAccessors3.ts, 7, 5)) + + console.log(this._sound) +>console.log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --)) +>console : Symbol(console, Decl(lib.dom.d.ts, --, --)) +>log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --)) +>this._sound : Symbol(Animal._sound, Decl(propertyOverridesAccessors3.ts, 0, 14)) +>this : Symbol(Animal, Decl(propertyOverridesAccessors3.ts, 0, 0)) +>_sound : Symbol(Animal._sound, Decl(propertyOverridesAccessors3.ts, 0, 14)) + } +} + +const a = new Animal +>a : Symbol(a, Decl(propertyOverridesAccessors3.ts, 14, 5)) +>Animal : Symbol(Animal, Decl(propertyOverridesAccessors3.ts, 0, 0)) + +a.makeSound() // 'rustling noise in the bushes' +>a.makeSound : Symbol(Animal.makeSound, Decl(propertyOverridesAccessors3.ts, 7, 5)) +>a : Symbol(a, Decl(propertyOverridesAccessors3.ts, 14, 5)) +>makeSound : Symbol(Animal.makeSound, Decl(propertyOverridesAccessors3.ts, 7, 5)) + +class Lion extends Animal { +>Lion : Symbol(Lion, Decl(propertyOverridesAccessors3.ts, 15, 13)) +>Animal : Symbol(Animal, Decl(propertyOverridesAccessors3.ts, 0, 0)) + + sound = 'RAWR!' // error here +>sound : Symbol(Lion.sound, Decl(propertyOverridesAccessors3.ts, 17, 27)) +} + +const lion = new Lion +>lion : Symbol(lion, Decl(propertyOverridesAccessors3.ts, 21, 5)) +>Lion : Symbol(Lion, Decl(propertyOverridesAccessors3.ts, 15, 13)) + +lion.makeSound() // with [[Define]]: Expected "RAWR!" but got "rustling noise in the bushes" +>lion.makeSound : Symbol(Animal.makeSound, Decl(propertyOverridesAccessors3.ts, 7, 5)) +>lion : Symbol(lion, Decl(propertyOverridesAccessors3.ts, 21, 5)) +>makeSound : Symbol(Animal.makeSound, Decl(propertyOverridesAccessors3.ts, 7, 5)) + diff --git a/tests/baselines/reference/propertyOverridesAccessors3.types b/tests/baselines/reference/propertyOverridesAccessors3.types new file mode 100644 index 0000000000000..b7ea64087c7a8 --- /dev/null +++ b/tests/baselines/reference/propertyOverridesAccessors3.types @@ -0,0 +1,73 @@ +=== tests/cases/conformance/classes/propertyMemberDeclarations/propertyOverridesAccessors3.ts === +class Animal { +>Animal : Animal + + _sound = 'rustling noise in the bushes' +>_sound : string +>'rustling noise in the bushes' : "rustling noise in the bushes" + + get sound() { return this._sound } +>sound : string +>this._sound : string +>this : this +>_sound : string + + set sound(val) { +>sound : string +>val : string + + this._sound = val; +>this._sound = val : string +>this._sound : string +>this : this +>_sound : string +>val : string + + /* some important code here, perhaps tracking known sounds, etc */ + } + + makeSound() { +>makeSound : () => void + + console.log(this._sound) +>console.log(this._sound) : void +>console.log : (message?: any, ...optionalParams: any[]) => void +>console : Console +>log : (message?: any, ...optionalParams: any[]) => void +>this._sound : string +>this : this +>_sound : string + } +} + +const a = new Animal +>a : Animal +>new Animal : Animal +>Animal : typeof Animal + +a.makeSound() // 'rustling noise in the bushes' +>a.makeSound() : void +>a.makeSound : () => void +>a : Animal +>makeSound : () => void + +class Lion extends Animal { +>Lion : Lion +>Animal : Animal + + sound = 'RAWR!' // error here +>sound : string +>'RAWR!' : "RAWR!" +} + +const lion = new Lion +>lion : Lion +>new Lion : Lion +>Lion : typeof Lion + +lion.makeSound() // with [[Define]]: Expected "RAWR!" but got "rustling noise in the bushes" +>lion.makeSound() : void +>lion.makeSound : () => void +>lion : Lion +>makeSound : () => void + diff --git a/tests/baselines/reference/propertyOverridesAccessors4.errors.txt b/tests/baselines/reference/propertyOverridesAccessors4.errors.txt new file mode 100644 index 0000000000000..c437e05b28280 --- /dev/null +++ b/tests/baselines/reference/propertyOverridesAccessors4.errors.txt @@ -0,0 +1,14 @@ +tests/cases/conformance/classes/propertyMemberDeclarations/propertyOverridesAccessors4.ts(6,5): error TS2610: Class 'Animal' defines instance member accessor 'sound', but extended class 'Lion' defines it as instance member property. + + +==== tests/cases/conformance/classes/propertyMemberDeclarations/propertyOverridesAccessors4.ts (1 errors) ==== + declare class Animal { + get sound(): string + set sound(val: string) + } + class Lion extends Animal { + sound = 'RAWR!' // error here + ~~~~~ +!!! error TS2610: Class 'Animal' defines instance member accessor 'sound', but extended class 'Lion' defines it as instance member property. + } + \ No newline at end of file diff --git a/tests/baselines/reference/propertyOverridesAccessors4.js b/tests/baselines/reference/propertyOverridesAccessors4.js new file mode 100644 index 0000000000000..1c284e6aa497c --- /dev/null +++ b/tests/baselines/reference/propertyOverridesAccessors4.js @@ -0,0 +1,38 @@ +//// [propertyOverridesAccessors4.ts] +declare class Animal { + get sound(): string + set sound(val: string) +} +class Lion extends Animal { + sound = 'RAWR!' // error here +} + + +//// [propertyOverridesAccessors4.js] +var __extends = (this && this.__extends) || (function () { + var extendStatics = function (d, b) { + 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 extendStatics(d, b); + }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +var Lion = /** @class */ (function (_super) { + __extends(Lion, _super); + function Lion() { + var _this = _super !== null && _super.apply(this, arguments) || this; + Object.defineProperty(_this, "sound", { + enumerable: true, + configurable: true, + writable: true, + value: 'RAWR!' + }); // error here + return _this; + } + return Lion; +}(Animal)); diff --git a/tests/baselines/reference/propertyOverridesAccessors4.symbols b/tests/baselines/reference/propertyOverridesAccessors4.symbols new file mode 100644 index 0000000000000..d7097e1d528cd --- /dev/null +++ b/tests/baselines/reference/propertyOverridesAccessors4.symbols @@ -0,0 +1,19 @@ +=== tests/cases/conformance/classes/propertyMemberDeclarations/propertyOverridesAccessors4.ts === +declare class Animal { +>Animal : Symbol(Animal, Decl(propertyOverridesAccessors4.ts, 0, 0)) + + get sound(): string +>sound : Symbol(Animal.sound, Decl(propertyOverridesAccessors4.ts, 0, 22), Decl(propertyOverridesAccessors4.ts, 1, 23)) + + set sound(val: string) +>sound : Symbol(Animal.sound, Decl(propertyOverridesAccessors4.ts, 0, 22), Decl(propertyOverridesAccessors4.ts, 1, 23)) +>val : Symbol(val, Decl(propertyOverridesAccessors4.ts, 2, 14)) +} +class Lion extends Animal { +>Lion : Symbol(Lion, Decl(propertyOverridesAccessors4.ts, 3, 1)) +>Animal : Symbol(Animal, Decl(propertyOverridesAccessors4.ts, 0, 0)) + + sound = 'RAWR!' // error here +>sound : Symbol(Lion.sound, Decl(propertyOverridesAccessors4.ts, 4, 27)) +} + diff --git a/tests/baselines/reference/propertyOverridesAccessors4.types b/tests/baselines/reference/propertyOverridesAccessors4.types new file mode 100644 index 0000000000000..5701f76127bd6 --- /dev/null +++ b/tests/baselines/reference/propertyOverridesAccessors4.types @@ -0,0 +1,20 @@ +=== tests/cases/conformance/classes/propertyMemberDeclarations/propertyOverridesAccessors4.ts === +declare class Animal { +>Animal : Animal + + get sound(): string +>sound : string + + set sound(val: string) +>sound : string +>val : string +} +class Lion extends Animal { +>Lion : Lion +>Animal : Animal + + sound = 'RAWR!' // error here +>sound : string +>'RAWR!' : "RAWR!" +} + diff --git a/tests/baselines/reference/propertyOverridesAccessors5.errors.txt b/tests/baselines/reference/propertyOverridesAccessors5.errors.txt new file mode 100644 index 0000000000000..5028138995693 --- /dev/null +++ b/tests/baselines/reference/propertyOverridesAccessors5.errors.txt @@ -0,0 +1,15 @@ +tests/cases/conformance/classes/propertyMemberDeclarations/propertyOverridesAccessors5.ts(5,24): error TS2610: Class 'A' defines instance member accessor 'p', but extended class 'B' defines it as instance member property. + + +==== tests/cases/conformance/classes/propertyMemberDeclarations/propertyOverridesAccessors5.ts (1 errors) ==== + class A { + get p() { return 'oh no' } + } + class B extends A { + constructor(public p: string) { + ~ +!!! error TS2610: Class 'A' defines instance member accessor 'p', but extended class 'B' defines it as instance member property. + super() + } + } + \ No newline at end of file diff --git a/tests/baselines/reference/propertyOverridesAccessors5.js b/tests/baselines/reference/propertyOverridesAccessors5.js new file mode 100644 index 0000000000000..76e1296627074 --- /dev/null +++ b/tests/baselines/reference/propertyOverridesAccessors5.js @@ -0,0 +1,22 @@ +//// [propertyOverridesAccessors5.ts] +class A { + get p() { return 'oh no' } +} +class B extends A { + constructor(public p: string) { + super() + } +} + + +//// [propertyOverridesAccessors5.js] +class A { + get p() { return 'oh no'; } +} +class B extends A { + p; + constructor(p) { + super(); + this.p = p; + } +} diff --git a/tests/baselines/reference/propertyOverridesAccessors5.symbols b/tests/baselines/reference/propertyOverridesAccessors5.symbols new file mode 100644 index 0000000000000..289021c0c7fb5 --- /dev/null +++ b/tests/baselines/reference/propertyOverridesAccessors5.symbols @@ -0,0 +1,19 @@ +=== tests/cases/conformance/classes/propertyMemberDeclarations/propertyOverridesAccessors5.ts === +class A { +>A : Symbol(A, Decl(propertyOverridesAccessors5.ts, 0, 0)) + + get p() { return 'oh no' } +>p : Symbol(A.p, Decl(propertyOverridesAccessors5.ts, 0, 9)) +} +class B extends A { +>B : Symbol(B, Decl(propertyOverridesAccessors5.ts, 2, 1)) +>A : Symbol(A, Decl(propertyOverridesAccessors5.ts, 0, 0)) + + constructor(public p: string) { +>p : Symbol(B.p, Decl(propertyOverridesAccessors5.ts, 4, 16)) + + super() +>super : Symbol(A, Decl(propertyOverridesAccessors5.ts, 0, 0)) + } +} + diff --git a/tests/baselines/reference/propertyOverridesAccessors5.types b/tests/baselines/reference/propertyOverridesAccessors5.types new file mode 100644 index 0000000000000..ebbe10d4b01e9 --- /dev/null +++ b/tests/baselines/reference/propertyOverridesAccessors5.types @@ -0,0 +1,21 @@ +=== tests/cases/conformance/classes/propertyMemberDeclarations/propertyOverridesAccessors5.ts === +class A { +>A : A + + get p() { return 'oh no' } +>p : string +>'oh no' : "oh no" +} +class B extends A { +>B : B +>A : A + + constructor(public p: string) { +>p : string + + super() +>super() : void +>super : typeof A + } +} + diff --git a/tests/baselines/reference/propertyOverridesMethod.errors.txt b/tests/baselines/reference/propertyOverridesMethod.errors.txt new file mode 100644 index 0000000000000..aaee2d48cf658 --- /dev/null +++ b/tests/baselines/reference/propertyOverridesMethod.errors.txt @@ -0,0 +1,13 @@ +tests/cases/conformance/classes/propertyMemberDeclarations/propertyOverridesMethod.ts(5,5): error TS2424: Class 'A' defines instance member function 'm', but extended class 'B' defines it as instance member property. + + +==== tests/cases/conformance/classes/propertyMemberDeclarations/propertyOverridesMethod.ts (1 errors) ==== + class A { + m() { } + } + class B extends A { + m = () => 1 + ~ +!!! error TS2424: Class 'A' defines instance member function 'm', but extended class 'B' defines it as instance member property. + } + \ No newline at end of file diff --git a/tests/baselines/reference/propertyOverridesMethod.js b/tests/baselines/reference/propertyOverridesMethod.js new file mode 100644 index 0000000000000..f78971a38f7cf --- /dev/null +++ b/tests/baselines/reference/propertyOverridesMethod.js @@ -0,0 +1,16 @@ +//// [propertyOverridesMethod.ts] +class A { + m() { } +} +class B extends A { + m = () => 1 +} + + +//// [propertyOverridesMethod.js] +class A { + m() { } +} +class B extends A { + m = () => 1; +} diff --git a/tests/baselines/reference/propertyOverridesMethod.symbols b/tests/baselines/reference/propertyOverridesMethod.symbols new file mode 100644 index 0000000000000..960aab6cb5612 --- /dev/null +++ b/tests/baselines/reference/propertyOverridesMethod.symbols @@ -0,0 +1,15 @@ +=== tests/cases/conformance/classes/propertyMemberDeclarations/propertyOverridesMethod.ts === +class A { +>A : Symbol(A, Decl(propertyOverridesMethod.ts, 0, 0)) + + m() { } +>m : Symbol(A.m, Decl(propertyOverridesMethod.ts, 0, 9)) +} +class B extends A { +>B : Symbol(B, Decl(propertyOverridesMethod.ts, 2, 1)) +>A : Symbol(A, Decl(propertyOverridesMethod.ts, 0, 0)) + + m = () => 1 +>m : Symbol(B.m, Decl(propertyOverridesMethod.ts, 3, 19)) +} + diff --git a/tests/baselines/reference/propertyOverridesMethod.types b/tests/baselines/reference/propertyOverridesMethod.types new file mode 100644 index 0000000000000..13fcda01a853d --- /dev/null +++ b/tests/baselines/reference/propertyOverridesMethod.types @@ -0,0 +1,17 @@ +=== tests/cases/conformance/classes/propertyMemberDeclarations/propertyOverridesMethod.ts === +class A { +>A : A + + m() { } +>m : () => void +} +class B extends A { +>B : B +>A : A + + m = () => 1 +>m : () => number +>() => 1 : () => number +>1 : 1 +} + diff --git a/tests/baselines/reference/propertyOverridingPrototype.errors.txt b/tests/baselines/reference/propertyOverridingPrototype.errors.txt new file mode 100644 index 0000000000000..a585f7999f603 --- /dev/null +++ b/tests/baselines/reference/propertyOverridingPrototype.errors.txt @@ -0,0 +1,16 @@ +tests/cases/compiler/propertyOverridingPrototype.ts(7,5): error TS2424: Class 'Base' defines instance member function 'foo', but extended class 'Derived' defines it as instance member property. + + +==== tests/cases/compiler/propertyOverridingPrototype.ts (1 errors) ==== + class Base { + foo() { + } + } + + class Derived extends Base { + foo: () => { }; + ~~~ +!!! error TS2424: Class 'Base' defines instance member function 'foo', but extended class 'Derived' defines it as instance member property. + } + + \ No newline at end of file diff --git a/tests/baselines/reference/readonlyInDeclarationFile.js b/tests/baselines/reference/readonlyInDeclarationFile.js index 667d2582f100d..7419e27c013b5 100644 --- a/tests/baselines/reference/readonlyInDeclarationFile.js +++ b/tests/baselines/reference/readonlyInDeclarationFile.js @@ -149,21 +149,27 @@ declare class C { private readonly a1; protected readonly a2: number; readonly a3: number; - private readonly b1; - protected readonly b2: number; - readonly b3: number; - private c1; - protected c2: number; - c3: number; + private get b1(); + protected get b2(): number; + get b3(): number; + private get c1(); + private set c1(value); + protected get c2(): number; + protected set c2(value: number); + get c3(): number; + set c3(value: number); private static readonly s1; protected static readonly s2: number; static readonly s3: number; - private static readonly t1; - protected static readonly t2: number; - static readonly t3: number; - private static u1; - protected static u2: number; - static u3: number; + private static get t1(); + protected static get t2(): number; + static get t3(): number; + private static get u1(); + private static set u1(value); + protected static get u2(): number; + protected static set u2(value: number); + static get u3(): number; + static set u3(value: number); } declare var z: { readonly a: string; diff --git a/tests/baselines/reference/showConfig/Shows tsconfig for single option/useDefineForClassFields/tsconfig.json b/tests/baselines/reference/showConfig/Shows tsconfig for single option/useDefineForClassFields/tsconfig.json new file mode 100644 index 0000000000000..608714e952871 --- /dev/null +++ b/tests/baselines/reference/showConfig/Shows tsconfig for single option/useDefineForClassFields/tsconfig.json @@ -0,0 +1,5 @@ +{ + "compilerOptions": { + "useDefineForClassFields": true + } +} diff --git a/tests/baselines/reference/symbolDeclarationEmit11.js b/tests/baselines/reference/symbolDeclarationEmit11.js index 25af4c4306475..b0cd9cfddbd5b 100644 --- a/tests/baselines/reference/symbolDeclarationEmit11.js +++ b/tests/baselines/reference/symbolDeclarationEmit11.js @@ -19,5 +19,6 @@ C[Symbol.iterator] = 0; declare class C { static [Symbol.iterator]: number; static [Symbol.isConcatSpreadable](): void; - static [Symbol.toPrimitive]: string; + static get [Symbol.toPrimitive](): string; + static set [Symbol.toPrimitive](x: string); } diff --git a/tests/baselines/reference/symbolDeclarationEmit12.js b/tests/baselines/reference/symbolDeclarationEmit12.js index 0b2034e045000..5d9f70334d44e 100644 --- a/tests/baselines/reference/symbolDeclarationEmit12.js +++ b/tests/baselines/reference/symbolDeclarationEmit12.js @@ -35,8 +35,8 @@ declare module M { [Symbol.iterator]: I; [Symbol.toPrimitive](x: I): void; [Symbol.isConcatSpreadable](): I; - readonly [Symbol.toPrimitive]: any; - [Symbol.toPrimitive]: I; + get [Symbol.toPrimitive](): any; + set [Symbol.toPrimitive](x: I); } export {}; } diff --git a/tests/baselines/reference/symbolDeclarationEmit13.js b/tests/baselines/reference/symbolDeclarationEmit13.js index bbd2c15cfcd1a..dc00d00fc9828 100644 --- a/tests/baselines/reference/symbolDeclarationEmit13.js +++ b/tests/baselines/reference/symbolDeclarationEmit13.js @@ -13,6 +13,6 @@ class C { //// [symbolDeclarationEmit13.d.ts] declare class C { - readonly [Symbol.toPrimitive]: string; - [Symbol.toStringTag]: any; + get [Symbol.toPrimitive](): string; + set [Symbol.toStringTag](x: any); } diff --git a/tests/baselines/reference/symbolDeclarationEmit14.js b/tests/baselines/reference/symbolDeclarationEmit14.js index d4ae3eeb43c35..f79c4e254f03b 100644 --- a/tests/baselines/reference/symbolDeclarationEmit14.js +++ b/tests/baselines/reference/symbolDeclarationEmit14.js @@ -13,6 +13,6 @@ class C { //// [symbolDeclarationEmit14.d.ts] declare class C { - readonly [Symbol.toPrimitive]: string; - readonly [Symbol.toStringTag]: string; + get [Symbol.toPrimitive](): string; + get [Symbol.toStringTag](): string; } diff --git a/tests/baselines/reference/symbolDeclarationEmit4.js b/tests/baselines/reference/symbolDeclarationEmit4.js index 75680aacb66fa..fb3099ec49dbd 100644 --- a/tests/baselines/reference/symbolDeclarationEmit4.js +++ b/tests/baselines/reference/symbolDeclarationEmit4.js @@ -13,5 +13,6 @@ class C { //// [symbolDeclarationEmit4.d.ts] declare class C { - [Symbol.toPrimitive]: string; + get [Symbol.toPrimitive](): string; + set [Symbol.toPrimitive](x: string); } diff --git a/tests/baselines/reference/thisPropertyOverridesAccessors.symbols b/tests/baselines/reference/thisPropertyOverridesAccessors.symbols new file mode 100644 index 0000000000000..40cec9f184709 --- /dev/null +++ b/tests/baselines/reference/thisPropertyOverridesAccessors.symbols @@ -0,0 +1,28 @@ +=== tests/cases/conformance/classes/propertyMemberDeclarations/foo.ts === +class Foo { +>Foo : Symbol(Foo, Decl(foo.ts, 0, 0)) + + get p() { return 1 } +>p : Symbol(Foo.p, Decl(foo.ts, 0, 11), Decl(foo.ts, 1, 24)) + + set p(value) { } +>p : Symbol(Foo.p, Decl(foo.ts, 0, 11), Decl(foo.ts, 1, 24)) +>value : Symbol(value, Decl(foo.ts, 2, 10)) +} + +=== tests/cases/conformance/classes/propertyMemberDeclarations/bar.js === +class Bar extends Foo { +>Bar : Symbol(Bar, Decl(bar.js, 0, 0)) +>Foo : Symbol(Foo, Decl(foo.ts, 0, 0)) + + constructor() { + super() +>super : Symbol(Foo, Decl(foo.ts, 0, 0)) + + this.p = 2 +>this.p : Symbol(Bar.p, Decl(bar.js, 2, 15)) +>this : Symbol(Bar, Decl(bar.js, 0, 0)) +>p : Symbol(Bar.p, Decl(bar.js, 2, 15)) + } +} + diff --git a/tests/baselines/reference/thisPropertyOverridesAccessors.types b/tests/baselines/reference/thisPropertyOverridesAccessors.types new file mode 100644 index 0000000000000..c242351dbd2b2 --- /dev/null +++ b/tests/baselines/reference/thisPropertyOverridesAccessors.types @@ -0,0 +1,32 @@ +=== tests/cases/conformance/classes/propertyMemberDeclarations/foo.ts === +class Foo { +>Foo : Foo + + get p() { return 1 } +>p : number +>1 : 1 + + set p(value) { } +>p : number +>value : number +} + +=== tests/cases/conformance/classes/propertyMemberDeclarations/bar.js === +class Bar extends Foo { +>Bar : Bar +>Foo : Foo + + constructor() { + super() +>super() : void +>super : typeof Foo + + this.p = 2 +>this.p = 2 : 2 +>this.p : number +>this : this +>p : number +>2 : 2 + } +} + diff --git a/tests/baselines/reference/tsbuild/amdModulesWithOut/incremental-declaration-doesnt-change/stripInternal.js b/tests/baselines/reference/tsbuild/amdModulesWithOut/incremental-declaration-doesnt-change/stripInternal.js index 6f6ca38435a80..375dd74392659 100644 --- a/tests/baselines/reference/tsbuild/amdModulesWithOut/incremental-declaration-doesnt-change/stripInternal.js +++ b/tests/baselines/reference/tsbuild/amdModulesWithOut/incremental-declaration-doesnt-change/stripInternal.js @@ -3552,32 +3552,32 @@ sourceFile:global.ts }, { "pos": 108, - "end": 212, + "end": 233, "kind": "internal" }, { - "pos": 214, - "end": 253, + "pos": 235, + "end": 274, "kind": "text" }, { - "pos": 253, - "end": 721, + "pos": 274, + "end": 742, "kind": "internal" }, { - "pos": 723, - "end": 730, + "pos": 744, + "end": 751, "kind": "text" }, { - "pos": 730, - "end": 1219, + "pos": 751, + "end": 1240, "kind": "internal" }, { - "pos": 1221, - "end": 1312, + "pos": 1242, + "end": 1333, "kind": "text" } ] @@ -3708,18 +3708,19 @@ declare module "file1" { export class normalC { ---------------------------------------------------------------------- -internal: (108-212) +internal: (108-233) constructor(); prop: string; method(): void; - /*@internal*/ c: number; + get c(): number; + set c(val: number); ---------------------------------------------------------------------- -text: (214-253) +text: (235-274) } export namespace normalN { ---------------------------------------------------------------------- -internal: (253-721) +internal: (274-742) class C { } function foo(): void; @@ -3740,11 +3741,11 @@ internal: (253-721) c = 2 } ---------------------------------------------------------------------- -text: (723-730) +text: (744-751) } ---------------------------------------------------------------------- -internal: (730-1219) +internal: (751-1240) export class internalC { } export function internalfoo(): void; @@ -3765,7 +3766,7 @@ internal: (730-1219) c = 2 } ---------------------------------------------------------------------- -text: (1221-1312) +text: (1242-1333) } declare module "file2" { export const y = 20; diff --git a/tests/baselines/reference/tsbuild/amdModulesWithOut/incremental-headers-change-without-dts-changes/stripInternal.js b/tests/baselines/reference/tsbuild/amdModulesWithOut/incremental-headers-change-without-dts-changes/stripInternal.js index 544b25a544dac..e371045db9a52 100644 --- a/tests/baselines/reference/tsbuild/amdModulesWithOut/incremental-headers-change-without-dts-changes/stripInternal.js +++ b/tests/baselines/reference/tsbuild/amdModulesWithOut/incremental-headers-change-without-dts-changes/stripInternal.js @@ -2090,7 +2090,7 @@ export namespace normalN { //// [/src/lib/module.d.ts] file written with same contents //// [/src/lib/module.d.ts.map] -{"version":3,"file":"module.d.ts","sourceRoot":"","sources":["file0.ts","file1.ts","file2.ts","global.ts"],"names":[],"mappings":"AAAc,QAAA,MAAM,MAAM,KAAK,CAAC;;ICAlB,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC;IAClC,MAAM,OAAO,OAAO;;QAEF,IAAI,EAAE,MAAM,CAAC;QACb,MAAM;sBACF,CAAC,EACM,MAAM;KAClC;IACD,MAAM,WAAW,OAAO,CAAC;QACP,MAAa,CAAC;SAAI;QAClB,SAAgB,GAAG,SAAK;QACxB,UAAiB,aAAa,CAAC;YAAE,MAAa,CAAC;aAAG;SAAE;QACpD,UAAiB,SAAS,CAAC,SAAS,CAAC;YAAE,MAAa,SAAS;aAAG;SAAE;QAClE,MAAM,QAAQ,UAAU,GAAG,aAAa,CAAC,CAAC,CAAC;QAC3C,KAAY,YAAY,GAAG,SAAS,CAAC;QAC9B,MAAM,aAAa,KAAK,CAAC;QAChC,KAAY,YAAY;YAAG,CAAC,IAAA;YAAE,CAAC,IAAA;YAAE,CAAC,IAAA;SAAE;KACrD;IACa,MAAM,OAAO,SAAS;KAAG;IACzB,MAAM,UAAU,WAAW,SAAK;IAChC,MAAM,WAAW,iBAAiB,CAAC;QAAE,MAAa,SAAS;SAAG;KAAE;IAChE,MAAM,WAAW,aAAa,CAAC,SAAS,CAAC;QAAE,MAAa,SAAS;SAAG;KAAE;IACtE,MAAM,QAAQ,cAAc,GAAG,iBAAiB,CAAC,SAAS,CAAC;IAC3D,MAAM,MAAM,YAAY,GAAG,SAAS,CAAC;IACrC,MAAM,CAAC,MAAM,aAAa,KAAK,CAAC;IAChC,MAAM,MAAM,YAAY;QAAG,CAAC,IAAA;QAAE,CAAC,IAAA;QAAE,CAAC,IAAA;KAAE;;;ICzBlD,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC;;ACApB,QAAA,MAAM,WAAW,KAAK,CAAC"} +{"version":3,"file":"module.d.ts","sourceRoot":"","sources":["file0.ts","file1.ts","file2.ts","global.ts"],"names":[],"mappings":"AAAc,QAAA,MAAM,MAAM,KAAK,CAAC;;ICAlB,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC;IAClC,MAAM,OAAO,OAAO;;QAEF,IAAI,EAAE,MAAM,CAAC;QACb,MAAM;QACN,IAAI,CAAC,IACM,MAAM,CADK;QACtB,IAAI,CAAC,CAAC,KAAK,MAAM,EAAK;KACvC;IACD,MAAM,WAAW,OAAO,CAAC;QACP,MAAa,CAAC;SAAI;QAClB,SAAgB,GAAG,SAAK;QACxB,UAAiB,aAAa,CAAC;YAAE,MAAa,CAAC;aAAG;SAAE;QACpD,UAAiB,SAAS,CAAC,SAAS,CAAC;YAAE,MAAa,SAAS;aAAG;SAAE;QAClE,MAAM,QAAQ,UAAU,GAAG,aAAa,CAAC,CAAC,CAAC;QAC3C,KAAY,YAAY,GAAG,SAAS,CAAC;QAC9B,MAAM,aAAa,KAAK,CAAC;QAChC,KAAY,YAAY;YAAG,CAAC,IAAA;YAAE,CAAC,IAAA;YAAE,CAAC,IAAA;SAAE;KACrD;IACa,MAAM,OAAO,SAAS;KAAG;IACzB,MAAM,UAAU,WAAW,SAAK;IAChC,MAAM,WAAW,iBAAiB,CAAC;QAAE,MAAa,SAAS;SAAG;KAAE;IAChE,MAAM,WAAW,aAAa,CAAC,SAAS,CAAC;QAAE,MAAa,SAAS;SAAG;KAAE;IACtE,MAAM,QAAQ,cAAc,GAAG,iBAAiB,CAAC,SAAS,CAAC;IAC3D,MAAM,MAAM,YAAY,GAAG,SAAS,CAAC;IACrC,MAAM,CAAC,MAAM,aAAa,KAAK,CAAC;IAChC,MAAM,MAAM,YAAY;QAAG,CAAC,IAAA;QAAE,CAAC,IAAA;QAAE,CAAC,IAAA;KAAE;;;ICzBlD,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC;;ACApB,QAAA,MAAM,WAAW,KAAK,CAAC"} //// [/src/lib/module.d.ts.map.baseline.txt] =================================================================== @@ -2191,35 +2191,66 @@ sourceFile:file1.ts >>> method(): void; 1->^^^^^^^^ 2 > ^^^^^^ -3 > ^^^^^^^^^^^^^^^^^^^-> +3 > ^^^^^^^^^^^-> 1-> > /*@internal*/ 2 > method 1->Emitted(7, 9) Source(5, 19) + SourceIndex(1) 2 >Emitted(7, 15) Source(5, 25) + SourceIndex(1) --- ->>> /*@internal*/ c: number; -1->^^^^^^^^^^^^^^^^^^^^^^ -2 > ^ -3 > ^^ -4 > ^^^^^^ +>>> get c(): number; +1->^^^^^^^^ +2 > ^^^^ +3 > ^ +4 > ^^^^ +5 > ^^^^^^ +6 > ^ +7 > ^^^^-> 1->() { } - > /*@internal*/ get -2 > c -3 > () { return 10; } - > /*@internal*/ set c(val: -4 > number -1->Emitted(8, 23) Source(6, 23) + SourceIndex(1) -2 >Emitted(8, 24) Source(6, 24) + SourceIndex(1) -3 >Emitted(8, 26) Source(7, 30) + SourceIndex(1) -4 >Emitted(8, 32) Source(7, 36) + SourceIndex(1) + > /*@internal*/ +2 > get +3 > c +4 > () { return 10; } + > /*@internal*/ set c(val: +5 > number +6 > +1->Emitted(8, 9) Source(6, 19) + SourceIndex(1) +2 >Emitted(8, 13) Source(6, 23) + SourceIndex(1) +3 >Emitted(8, 14) Source(6, 24) + SourceIndex(1) +4 >Emitted(8, 18) Source(7, 30) + SourceIndex(1) +5 >Emitted(8, 24) Source(7, 36) + SourceIndex(1) +6 >Emitted(8, 25) Source(6, 41) + SourceIndex(1) +--- +>>> set c(val: number); +1->^^^^^^^^ +2 > ^^^^ +3 > ^ +4 > ^ +5 > ^^^^^ +6 > ^^^^^^ +7 > ^^ +1-> + > /*@internal*/ +2 > set +3 > c +4 > ( +5 > val: +6 > number +7 > ) { } +1->Emitted(9, 9) Source(7, 19) + SourceIndex(1) +2 >Emitted(9, 13) Source(7, 23) + SourceIndex(1) +3 >Emitted(9, 14) Source(7, 24) + SourceIndex(1) +4 >Emitted(9, 15) Source(7, 25) + SourceIndex(1) +5 >Emitted(9, 20) Source(7, 30) + SourceIndex(1) +6 >Emitted(9, 26) Source(7, 36) + SourceIndex(1) +7 >Emitted(9, 28) Source(7, 41) + SourceIndex(1) --- >>> } 1 >^^^^^ 2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1 >) { } +1 > >} -1 >Emitted(9, 6) Source(8, 2) + SourceIndex(1) +1 >Emitted(10, 6) Source(8, 2) + SourceIndex(1) --- >>> export namespace normalN { 1->^^^^ @@ -2233,11 +2264,11 @@ sourceFile:file1.ts 3 > namespace 4 > normalN 5 > -1->Emitted(10, 5) Source(9, 1) + SourceIndex(1) -2 >Emitted(10, 11) Source(9, 7) + SourceIndex(1) -3 >Emitted(10, 22) Source(9, 18) + SourceIndex(1) -4 >Emitted(10, 29) Source(9, 25) + SourceIndex(1) -5 >Emitted(10, 30) Source(9, 26) + SourceIndex(1) +1->Emitted(11, 5) Source(9, 1) + SourceIndex(1) +2 >Emitted(11, 11) Source(9, 7) + SourceIndex(1) +3 >Emitted(11, 22) Source(9, 18) + SourceIndex(1) +4 >Emitted(11, 29) Source(9, 25) + SourceIndex(1) +5 >Emitted(11, 30) Source(9, 26) + SourceIndex(1) --- >>> class C { 1 >^^^^^^^^ @@ -2247,15 +2278,15 @@ sourceFile:file1.ts > /*@internal*/ 2 > export class 3 > C -1 >Emitted(11, 9) Source(10, 19) + SourceIndex(1) -2 >Emitted(11, 15) Source(10, 32) + SourceIndex(1) -3 >Emitted(11, 16) Source(10, 33) + SourceIndex(1) +1 >Emitted(12, 9) Source(10, 19) + SourceIndex(1) +2 >Emitted(12, 15) Source(10, 32) + SourceIndex(1) +3 >Emitted(12, 16) Source(10, 33) + SourceIndex(1) --- >>> } 1 >^^^^^^^^^ 2 > ^^^^^^^^^^^^^^^^^^^^^-> 1 > { } -1 >Emitted(12, 10) Source(10, 37) + SourceIndex(1) +1 >Emitted(13, 10) Source(10, 37) + SourceIndex(1) --- >>> function foo(): void; 1->^^^^^^^^ @@ -2268,10 +2299,10 @@ sourceFile:file1.ts 2 > export function 3 > foo 4 > () {} -1->Emitted(13, 9) Source(11, 19) + SourceIndex(1) -2 >Emitted(13, 18) Source(11, 35) + SourceIndex(1) -3 >Emitted(13, 21) Source(11, 38) + SourceIndex(1) -4 >Emitted(13, 30) Source(11, 43) + SourceIndex(1) +1->Emitted(14, 9) Source(11, 19) + SourceIndex(1) +2 >Emitted(14, 18) Source(11, 35) + SourceIndex(1) +3 >Emitted(14, 21) Source(11, 38) + SourceIndex(1) +4 >Emitted(14, 30) Source(11, 43) + SourceIndex(1) --- >>> namespace someNamespace { 1->^^^^^^^^ @@ -2283,10 +2314,10 @@ sourceFile:file1.ts 2 > export namespace 3 > someNamespace 4 > -1->Emitted(14, 9) Source(12, 19) + SourceIndex(1) -2 >Emitted(14, 19) Source(12, 36) + SourceIndex(1) -3 >Emitted(14, 32) Source(12, 49) + SourceIndex(1) -4 >Emitted(14, 33) Source(12, 50) + SourceIndex(1) +1->Emitted(15, 9) Source(12, 19) + SourceIndex(1) +2 >Emitted(15, 19) Source(12, 36) + SourceIndex(1) +3 >Emitted(15, 32) Source(12, 49) + SourceIndex(1) +4 >Emitted(15, 33) Source(12, 50) + SourceIndex(1) --- >>> class C { 1 >^^^^^^^^^^^^ @@ -2295,20 +2326,20 @@ sourceFile:file1.ts 1 >{ 2 > export class 3 > C -1 >Emitted(15, 13) Source(12, 52) + SourceIndex(1) -2 >Emitted(15, 19) Source(12, 65) + SourceIndex(1) -3 >Emitted(15, 20) Source(12, 66) + SourceIndex(1) +1 >Emitted(16, 13) Source(12, 52) + SourceIndex(1) +2 >Emitted(16, 19) Source(12, 65) + SourceIndex(1) +3 >Emitted(16, 20) Source(12, 66) + SourceIndex(1) --- >>> } 1 >^^^^^^^^^^^^^ 1 > {} -1 >Emitted(16, 14) Source(12, 69) + SourceIndex(1) +1 >Emitted(17, 14) Source(12, 69) + SourceIndex(1) --- >>> } 1 >^^^^^^^^^ 2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> 1 > } -1 >Emitted(17, 10) Source(12, 71) + SourceIndex(1) +1 >Emitted(18, 10) Source(12, 71) + SourceIndex(1) --- >>> namespace someOther.something { 1->^^^^^^^^ @@ -2324,12 +2355,12 @@ sourceFile:file1.ts 4 > . 5 > something 6 > -1->Emitted(18, 9) Source(13, 19) + SourceIndex(1) -2 >Emitted(18, 19) Source(13, 36) + SourceIndex(1) -3 >Emitted(18, 28) Source(13, 45) + SourceIndex(1) -4 >Emitted(18, 29) Source(13, 46) + SourceIndex(1) -5 >Emitted(18, 38) Source(13, 55) + SourceIndex(1) -6 >Emitted(18, 39) Source(13, 56) + SourceIndex(1) +1->Emitted(19, 9) Source(13, 19) + SourceIndex(1) +2 >Emitted(19, 19) Source(13, 36) + SourceIndex(1) +3 >Emitted(19, 28) Source(13, 45) + SourceIndex(1) +4 >Emitted(19, 29) Source(13, 46) + SourceIndex(1) +5 >Emitted(19, 38) Source(13, 55) + SourceIndex(1) +6 >Emitted(19, 39) Source(13, 56) + SourceIndex(1) --- >>> class someClass { 1 >^^^^^^^^^^^^ @@ -2338,20 +2369,20 @@ sourceFile:file1.ts 1 >{ 2 > export class 3 > someClass -1 >Emitted(19, 13) Source(13, 58) + SourceIndex(1) -2 >Emitted(19, 19) Source(13, 71) + SourceIndex(1) -3 >Emitted(19, 28) Source(13, 80) + SourceIndex(1) +1 >Emitted(20, 13) Source(13, 58) + SourceIndex(1) +2 >Emitted(20, 19) Source(13, 71) + SourceIndex(1) +3 >Emitted(20, 28) Source(13, 80) + SourceIndex(1) --- >>> } 1 >^^^^^^^^^^^^^ 1 > {} -1 >Emitted(20, 14) Source(13, 83) + SourceIndex(1) +1 >Emitted(21, 14) Source(13, 83) + SourceIndex(1) --- >>> } 1 >^^^^^^^^^ 2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> 1 > } -1 >Emitted(21, 10) Source(13, 85) + SourceIndex(1) +1 >Emitted(22, 10) Source(13, 85) + SourceIndex(1) --- >>> export import someImport = someNamespace.C; 1->^^^^^^^^ @@ -2373,15 +2404,15 @@ sourceFile:file1.ts 7 > . 8 > C 9 > ; -1->Emitted(22, 9) Source(14, 19) + SourceIndex(1) -2 >Emitted(22, 15) Source(14, 25) + SourceIndex(1) -3 >Emitted(22, 23) Source(14, 33) + SourceIndex(1) -4 >Emitted(22, 33) Source(14, 43) + SourceIndex(1) -5 >Emitted(22, 36) Source(14, 46) + SourceIndex(1) -6 >Emitted(22, 49) Source(14, 59) + SourceIndex(1) -7 >Emitted(22, 50) Source(14, 60) + SourceIndex(1) -8 >Emitted(22, 51) Source(14, 61) + SourceIndex(1) -9 >Emitted(22, 52) Source(14, 62) + SourceIndex(1) +1->Emitted(23, 9) Source(14, 19) + SourceIndex(1) +2 >Emitted(23, 15) Source(14, 25) + SourceIndex(1) +3 >Emitted(23, 23) Source(14, 33) + SourceIndex(1) +4 >Emitted(23, 33) Source(14, 43) + SourceIndex(1) +5 >Emitted(23, 36) Source(14, 46) + SourceIndex(1) +6 >Emitted(23, 49) Source(14, 59) + SourceIndex(1) +7 >Emitted(23, 50) Source(14, 60) + SourceIndex(1) +8 >Emitted(23, 51) Source(14, 61) + SourceIndex(1) +9 >Emitted(23, 52) Source(14, 62) + SourceIndex(1) --- >>> type internalType = internalC; 1 >^^^^^^^^ @@ -2397,12 +2428,12 @@ sourceFile:file1.ts 4 > = 5 > internalC 6 > ; -1 >Emitted(23, 9) Source(15, 19) + SourceIndex(1) -2 >Emitted(23, 14) Source(15, 31) + SourceIndex(1) -3 >Emitted(23, 26) Source(15, 43) + SourceIndex(1) -4 >Emitted(23, 29) Source(15, 46) + SourceIndex(1) -5 >Emitted(23, 38) Source(15, 55) + SourceIndex(1) -6 >Emitted(23, 39) Source(15, 56) + SourceIndex(1) +1 >Emitted(24, 9) Source(15, 19) + SourceIndex(1) +2 >Emitted(24, 14) Source(15, 31) + SourceIndex(1) +3 >Emitted(24, 26) Source(15, 43) + SourceIndex(1) +4 >Emitted(24, 29) Source(15, 46) + SourceIndex(1) +5 >Emitted(24, 38) Source(15, 55) + SourceIndex(1) +6 >Emitted(24, 39) Source(15, 56) + SourceIndex(1) --- >>> const internalConst = 10; 1 >^^^^^^^^ @@ -2416,11 +2447,11 @@ sourceFile:file1.ts 3 > internalConst 4 > = 10 5 > ; -1 >Emitted(24, 9) Source(16, 26) + SourceIndex(1) -2 >Emitted(24, 15) Source(16, 32) + SourceIndex(1) -3 >Emitted(24, 28) Source(16, 45) + SourceIndex(1) -4 >Emitted(24, 33) Source(16, 50) + SourceIndex(1) -5 >Emitted(24, 34) Source(16, 51) + SourceIndex(1) +1 >Emitted(25, 9) Source(16, 26) + SourceIndex(1) +2 >Emitted(25, 15) Source(16, 32) + SourceIndex(1) +3 >Emitted(25, 28) Source(16, 45) + SourceIndex(1) +4 >Emitted(25, 33) Source(16, 50) + SourceIndex(1) +5 >Emitted(25, 34) Source(16, 51) + SourceIndex(1) --- >>> enum internalEnum { 1 >^^^^^^^^ @@ -2430,9 +2461,9 @@ sourceFile:file1.ts > /*@internal*/ 2 > export enum 3 > internalEnum -1 >Emitted(25, 9) Source(17, 19) + SourceIndex(1) -2 >Emitted(25, 14) Source(17, 31) + SourceIndex(1) -3 >Emitted(25, 26) Source(17, 43) + SourceIndex(1) +1 >Emitted(26, 9) Source(17, 19) + SourceIndex(1) +2 >Emitted(26, 14) Source(17, 31) + SourceIndex(1) +3 >Emitted(26, 26) Source(17, 43) + SourceIndex(1) --- >>> a = 0, 1 >^^^^^^^^^^^^ @@ -2442,9 +2473,9 @@ sourceFile:file1.ts 1 > { 2 > a 3 > -1 >Emitted(26, 13) Source(17, 46) + SourceIndex(1) -2 >Emitted(26, 14) Source(17, 47) + SourceIndex(1) -3 >Emitted(26, 18) Source(17, 47) + SourceIndex(1) +1 >Emitted(27, 13) Source(17, 46) + SourceIndex(1) +2 >Emitted(27, 14) Source(17, 47) + SourceIndex(1) +3 >Emitted(27, 18) Source(17, 47) + SourceIndex(1) --- >>> b = 1, 1->^^^^^^^^^^^^ @@ -2454,9 +2485,9 @@ sourceFile:file1.ts 1->, 2 > b 3 > -1->Emitted(27, 13) Source(17, 49) + SourceIndex(1) -2 >Emitted(27, 14) Source(17, 50) + SourceIndex(1) -3 >Emitted(27, 18) Source(17, 50) + SourceIndex(1) +1->Emitted(28, 13) Source(17, 49) + SourceIndex(1) +2 >Emitted(28, 14) Source(17, 50) + SourceIndex(1) +3 >Emitted(28, 18) Source(17, 50) + SourceIndex(1) --- >>> c = 2 1->^^^^^^^^^^^^ @@ -2465,21 +2496,21 @@ sourceFile:file1.ts 1->, 2 > c 3 > -1->Emitted(28, 13) Source(17, 52) + SourceIndex(1) -2 >Emitted(28, 14) Source(17, 53) + SourceIndex(1) -3 >Emitted(28, 18) Source(17, 53) + SourceIndex(1) +1->Emitted(29, 13) Source(17, 52) + SourceIndex(1) +2 >Emitted(29, 14) Source(17, 53) + SourceIndex(1) +3 >Emitted(29, 18) Source(17, 53) + SourceIndex(1) --- >>> } 1 >^^^^^^^^^ 1 > } -1 >Emitted(29, 10) Source(17, 55) + SourceIndex(1) +1 >Emitted(30, 10) Source(17, 55) + SourceIndex(1) --- >>> } 1 >^^^^^ 2 > ^^^^^^^^^^^^^^^^^^^^^^^^-> 1 > >} -1 >Emitted(30, 6) Source(18, 2) + SourceIndex(1) +1 >Emitted(31, 6) Source(18, 2) + SourceIndex(1) --- >>> export class internalC { 1->^^^^ @@ -2491,16 +2522,16 @@ sourceFile:file1.ts 2 > export 3 > class 4 > internalC -1->Emitted(31, 5) Source(19, 15) + SourceIndex(1) -2 >Emitted(31, 11) Source(19, 21) + SourceIndex(1) -3 >Emitted(31, 18) Source(19, 28) + SourceIndex(1) -4 >Emitted(31, 27) Source(19, 37) + SourceIndex(1) +1->Emitted(32, 5) Source(19, 15) + SourceIndex(1) +2 >Emitted(32, 11) Source(19, 21) + SourceIndex(1) +3 >Emitted(32, 18) Source(19, 28) + SourceIndex(1) +4 >Emitted(32, 27) Source(19, 37) + SourceIndex(1) --- >>> } 1 >^^^^^ 2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> 1 > {} -1 >Emitted(32, 6) Source(19, 40) + SourceIndex(1) +1 >Emitted(33, 6) Source(19, 40) + SourceIndex(1) --- >>> export function internalfoo(): void; 1->^^^^ @@ -2515,11 +2546,11 @@ sourceFile:file1.ts 3 > function 4 > internalfoo 5 > () {} -1->Emitted(33, 5) Source(20, 15) + SourceIndex(1) -2 >Emitted(33, 11) Source(20, 21) + SourceIndex(1) -3 >Emitted(33, 21) Source(20, 31) + SourceIndex(1) -4 >Emitted(33, 32) Source(20, 42) + SourceIndex(1) -5 >Emitted(33, 41) Source(20, 47) + SourceIndex(1) +1->Emitted(34, 5) Source(20, 15) + SourceIndex(1) +2 >Emitted(34, 11) Source(20, 21) + SourceIndex(1) +3 >Emitted(34, 21) Source(20, 31) + SourceIndex(1) +4 >Emitted(34, 32) Source(20, 42) + SourceIndex(1) +5 >Emitted(34, 41) Source(20, 47) + SourceIndex(1) --- >>> export namespace internalNamespace { 1->^^^^ @@ -2533,11 +2564,11 @@ sourceFile:file1.ts 3 > namespace 4 > internalNamespace 5 > -1->Emitted(34, 5) Source(21, 15) + SourceIndex(1) -2 >Emitted(34, 11) Source(21, 21) + SourceIndex(1) -3 >Emitted(34, 22) Source(21, 32) + SourceIndex(1) -4 >Emitted(34, 39) Source(21, 49) + SourceIndex(1) -5 >Emitted(34, 40) Source(21, 50) + SourceIndex(1) +1->Emitted(35, 5) Source(21, 15) + SourceIndex(1) +2 >Emitted(35, 11) Source(21, 21) + SourceIndex(1) +3 >Emitted(35, 22) Source(21, 32) + SourceIndex(1) +4 >Emitted(35, 39) Source(21, 49) + SourceIndex(1) +5 >Emitted(35, 40) Source(21, 50) + SourceIndex(1) --- >>> class someClass { 1 >^^^^^^^^ @@ -2546,20 +2577,20 @@ sourceFile:file1.ts 1 >{ 2 > export class 3 > someClass -1 >Emitted(35, 9) Source(21, 52) + SourceIndex(1) -2 >Emitted(35, 15) Source(21, 65) + SourceIndex(1) -3 >Emitted(35, 24) Source(21, 74) + SourceIndex(1) +1 >Emitted(36, 9) Source(21, 52) + SourceIndex(1) +2 >Emitted(36, 15) Source(21, 65) + SourceIndex(1) +3 >Emitted(36, 24) Source(21, 74) + SourceIndex(1) --- >>> } 1 >^^^^^^^^^ 1 > {} -1 >Emitted(36, 10) Source(21, 77) + SourceIndex(1) +1 >Emitted(37, 10) Source(21, 77) + SourceIndex(1) --- >>> } 1 >^^^^^ 2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> 1 > } -1 >Emitted(37, 6) Source(21, 79) + SourceIndex(1) +1 >Emitted(38, 6) Source(21, 79) + SourceIndex(1) --- >>> export namespace internalOther.something { 1->^^^^ @@ -2577,13 +2608,13 @@ sourceFile:file1.ts 5 > . 6 > something 7 > -1->Emitted(38, 5) Source(22, 15) + SourceIndex(1) -2 >Emitted(38, 11) Source(22, 21) + SourceIndex(1) -3 >Emitted(38, 22) Source(22, 32) + SourceIndex(1) -4 >Emitted(38, 35) Source(22, 45) + SourceIndex(1) -5 >Emitted(38, 36) Source(22, 46) + SourceIndex(1) -6 >Emitted(38, 45) Source(22, 55) + SourceIndex(1) -7 >Emitted(38, 46) Source(22, 56) + SourceIndex(1) +1->Emitted(39, 5) Source(22, 15) + SourceIndex(1) +2 >Emitted(39, 11) Source(22, 21) + SourceIndex(1) +3 >Emitted(39, 22) Source(22, 32) + SourceIndex(1) +4 >Emitted(39, 35) Source(22, 45) + SourceIndex(1) +5 >Emitted(39, 36) Source(22, 46) + SourceIndex(1) +6 >Emitted(39, 45) Source(22, 55) + SourceIndex(1) +7 >Emitted(39, 46) Source(22, 56) + SourceIndex(1) --- >>> class someClass { 1 >^^^^^^^^ @@ -2592,20 +2623,20 @@ sourceFile:file1.ts 1 >{ 2 > export class 3 > someClass -1 >Emitted(39, 9) Source(22, 58) + SourceIndex(1) -2 >Emitted(39, 15) Source(22, 71) + SourceIndex(1) -3 >Emitted(39, 24) Source(22, 80) + SourceIndex(1) +1 >Emitted(40, 9) Source(22, 58) + SourceIndex(1) +2 >Emitted(40, 15) Source(22, 71) + SourceIndex(1) +3 >Emitted(40, 24) Source(22, 80) + SourceIndex(1) --- >>> } 1 >^^^^^^^^^ 1 > {} -1 >Emitted(40, 10) Source(22, 83) + SourceIndex(1) +1 >Emitted(41, 10) Source(22, 83) + SourceIndex(1) --- >>> } 1 >^^^^^ 2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> 1 > } -1 >Emitted(41, 6) Source(22, 85) + SourceIndex(1) +1 >Emitted(42, 6) Source(22, 85) + SourceIndex(1) --- >>> export import internalImport = internalNamespace.someClass; 1->^^^^ @@ -2627,15 +2658,15 @@ sourceFile:file1.ts 7 > . 8 > someClass 9 > ; -1->Emitted(42, 5) Source(23, 15) + SourceIndex(1) -2 >Emitted(42, 11) Source(23, 21) + SourceIndex(1) -3 >Emitted(42, 19) Source(23, 29) + SourceIndex(1) -4 >Emitted(42, 33) Source(23, 43) + SourceIndex(1) -5 >Emitted(42, 36) Source(23, 46) + SourceIndex(1) -6 >Emitted(42, 53) Source(23, 63) + SourceIndex(1) -7 >Emitted(42, 54) Source(23, 64) + SourceIndex(1) -8 >Emitted(42, 63) Source(23, 73) + SourceIndex(1) -9 >Emitted(42, 64) Source(23, 74) + SourceIndex(1) +1->Emitted(43, 5) Source(23, 15) + SourceIndex(1) +2 >Emitted(43, 11) Source(23, 21) + SourceIndex(1) +3 >Emitted(43, 19) Source(23, 29) + SourceIndex(1) +4 >Emitted(43, 33) Source(23, 43) + SourceIndex(1) +5 >Emitted(43, 36) Source(23, 46) + SourceIndex(1) +6 >Emitted(43, 53) Source(23, 63) + SourceIndex(1) +7 >Emitted(43, 54) Source(23, 64) + SourceIndex(1) +8 >Emitted(43, 63) Source(23, 73) + SourceIndex(1) +9 >Emitted(43, 64) Source(23, 74) + SourceIndex(1) --- >>> export type internalType = internalC; 1 >^^^^ @@ -2653,13 +2684,13 @@ sourceFile:file1.ts 5 > = 6 > internalC 7 > ; -1 >Emitted(43, 5) Source(24, 15) + SourceIndex(1) -2 >Emitted(43, 11) Source(24, 21) + SourceIndex(1) -3 >Emitted(43, 17) Source(24, 27) + SourceIndex(1) -4 >Emitted(43, 29) Source(24, 39) + SourceIndex(1) -5 >Emitted(43, 32) Source(24, 42) + SourceIndex(1) -6 >Emitted(43, 41) Source(24, 51) + SourceIndex(1) -7 >Emitted(43, 42) Source(24, 52) + SourceIndex(1) +1 >Emitted(44, 5) Source(24, 15) + SourceIndex(1) +2 >Emitted(44, 11) Source(24, 21) + SourceIndex(1) +3 >Emitted(44, 17) Source(24, 27) + SourceIndex(1) +4 >Emitted(44, 29) Source(24, 39) + SourceIndex(1) +5 >Emitted(44, 32) Source(24, 42) + SourceIndex(1) +6 >Emitted(44, 41) Source(24, 51) + SourceIndex(1) +7 >Emitted(44, 42) Source(24, 52) + SourceIndex(1) --- >>> export const internalConst = 10; 1 >^^^^ @@ -2677,13 +2708,13 @@ sourceFile:file1.ts 5 > internalConst 6 > = 10 7 > ; -1 >Emitted(44, 5) Source(25, 15) + SourceIndex(1) -2 >Emitted(44, 11) Source(25, 21) + SourceIndex(1) -3 >Emitted(44, 12) Source(25, 22) + SourceIndex(1) -4 >Emitted(44, 18) Source(25, 28) + SourceIndex(1) -5 >Emitted(44, 31) Source(25, 41) + SourceIndex(1) -6 >Emitted(44, 36) Source(25, 46) + SourceIndex(1) -7 >Emitted(44, 37) Source(25, 47) + SourceIndex(1) +1 >Emitted(45, 5) Source(25, 15) + SourceIndex(1) +2 >Emitted(45, 11) Source(25, 21) + SourceIndex(1) +3 >Emitted(45, 12) Source(25, 22) + SourceIndex(1) +4 >Emitted(45, 18) Source(25, 28) + SourceIndex(1) +5 >Emitted(45, 31) Source(25, 41) + SourceIndex(1) +6 >Emitted(45, 36) Source(25, 46) + SourceIndex(1) +7 >Emitted(45, 37) Source(25, 47) + SourceIndex(1) --- >>> export enum internalEnum { 1 >^^^^ @@ -2695,10 +2726,10 @@ sourceFile:file1.ts 2 > export 3 > enum 4 > internalEnum -1 >Emitted(45, 5) Source(26, 15) + SourceIndex(1) -2 >Emitted(45, 11) Source(26, 21) + SourceIndex(1) -3 >Emitted(45, 17) Source(26, 27) + SourceIndex(1) -4 >Emitted(45, 29) Source(26, 39) + SourceIndex(1) +1 >Emitted(46, 5) Source(26, 15) + SourceIndex(1) +2 >Emitted(46, 11) Source(26, 21) + SourceIndex(1) +3 >Emitted(46, 17) Source(26, 27) + SourceIndex(1) +4 >Emitted(46, 29) Source(26, 39) + SourceIndex(1) --- >>> a = 0, 1 >^^^^^^^^ @@ -2708,9 +2739,9 @@ sourceFile:file1.ts 1 > { 2 > a 3 > -1 >Emitted(46, 9) Source(26, 42) + SourceIndex(1) -2 >Emitted(46, 10) Source(26, 43) + SourceIndex(1) -3 >Emitted(46, 14) Source(26, 43) + SourceIndex(1) +1 >Emitted(47, 9) Source(26, 42) + SourceIndex(1) +2 >Emitted(47, 10) Source(26, 43) + SourceIndex(1) +3 >Emitted(47, 14) Source(26, 43) + SourceIndex(1) --- >>> b = 1, 1->^^^^^^^^ @@ -2720,9 +2751,9 @@ sourceFile:file1.ts 1->, 2 > b 3 > -1->Emitted(47, 9) Source(26, 45) + SourceIndex(1) -2 >Emitted(47, 10) Source(26, 46) + SourceIndex(1) -3 >Emitted(47, 14) Source(26, 46) + SourceIndex(1) +1->Emitted(48, 9) Source(26, 45) + SourceIndex(1) +2 >Emitted(48, 10) Source(26, 46) + SourceIndex(1) +3 >Emitted(48, 14) Source(26, 46) + SourceIndex(1) --- >>> c = 2 1->^^^^^^^^ @@ -2731,14 +2762,14 @@ sourceFile:file1.ts 1->, 2 > c 3 > -1->Emitted(48, 9) Source(26, 48) + SourceIndex(1) -2 >Emitted(48, 10) Source(26, 49) + SourceIndex(1) -3 >Emitted(48, 14) Source(26, 49) + SourceIndex(1) +1->Emitted(49, 9) Source(26, 48) + SourceIndex(1) +2 >Emitted(49, 10) Source(26, 49) + SourceIndex(1) +3 >Emitted(49, 14) Source(26, 49) + SourceIndex(1) --- >>> } 1 >^^^^^ 1 > } -1 >Emitted(49, 6) Source(26, 51) + SourceIndex(1) +1 >Emitted(50, 6) Source(26, 51) + SourceIndex(1) --- ------------------------------------------------------------------- emittedFile:/src/lib/module.d.ts @@ -2761,13 +2792,13 @@ sourceFile:file2.ts 5 > y 6 > = 20 7 > ; -1 >Emitted(52, 5) Source(1, 1) + SourceIndex(2) -2 >Emitted(52, 11) Source(1, 7) + SourceIndex(2) -3 >Emitted(52, 12) Source(1, 8) + SourceIndex(2) -4 >Emitted(52, 18) Source(1, 14) + SourceIndex(2) -5 >Emitted(52, 19) Source(1, 15) + SourceIndex(2) -6 >Emitted(52, 24) Source(1, 20) + SourceIndex(2) -7 >Emitted(52, 25) Source(1, 21) + SourceIndex(2) +1 >Emitted(53, 5) Source(1, 1) + SourceIndex(2) +2 >Emitted(53, 11) Source(1, 7) + SourceIndex(2) +3 >Emitted(53, 12) Source(1, 8) + SourceIndex(2) +4 >Emitted(53, 18) Source(1, 14) + SourceIndex(2) +5 >Emitted(53, 19) Source(1, 15) + SourceIndex(2) +6 >Emitted(53, 24) Source(1, 20) + SourceIndex(2) +7 >Emitted(53, 25) Source(1, 21) + SourceIndex(2) --- ------------------------------------------------------------------- emittedFile:/src/lib/module.d.ts @@ -2788,12 +2819,12 @@ sourceFile:global.ts 4 > globalConst 5 > = 10 6 > ; -1 >Emitted(54, 1) Source(1, 1) + SourceIndex(3) -2 >Emitted(54, 9) Source(1, 1) + SourceIndex(3) -3 >Emitted(54, 15) Source(1, 7) + SourceIndex(3) -4 >Emitted(54, 26) Source(1, 18) + SourceIndex(3) -5 >Emitted(54, 31) Source(1, 23) + SourceIndex(3) -6 >Emitted(54, 32) Source(1, 24) + SourceIndex(3) +1 >Emitted(55, 1) Source(1, 1) + SourceIndex(3) +2 >Emitted(55, 9) Source(1, 1) + SourceIndex(3) +3 >Emitted(55, 15) Source(1, 7) + SourceIndex(3) +4 >Emitted(55, 26) Source(1, 18) + SourceIndex(3) +5 >Emitted(55, 31) Source(1, 23) + SourceIndex(3) +6 >Emitted(55, 32) Source(1, 24) + SourceIndex(3) --- >>>//# sourceMappingURL=module.d.ts.map @@ -4423,32 +4454,32 @@ sourceFile:global.ts }, { "pos": 108, - "end": 212, + "end": 233, "kind": "internal" }, { - "pos": 214, - "end": 253, + "pos": 235, + "end": 274, "kind": "text" }, { - "pos": 253, - "end": 721, + "pos": 274, + "end": 742, "kind": "internal" }, { - "pos": 723, - "end": 730, + "pos": 744, + "end": 751, "kind": "text" }, { - "pos": 730, - "end": 1219, + "pos": 751, + "end": 1240, "kind": "internal" }, { - "pos": 1221, - "end": 1312, + "pos": 1242, + "end": 1333, "kind": "text" } ] @@ -4583,18 +4614,19 @@ text: (80-108) export class normalC { ---------------------------------------------------------------------- -internal: (108-212) +internal: (108-233) constructor(); prop: string; method(): void; - /*@internal*/ c: number; + get c(): number; + set c(val: number); ---------------------------------------------------------------------- -text: (214-253) +text: (235-274) } export namespace normalN { ---------------------------------------------------------------------- -internal: (253-721) +internal: (274-742) class C { } function foo(): void; @@ -4615,11 +4647,11 @@ internal: (253-721) c = 2 } ---------------------------------------------------------------------- -text: (723-730) +text: (744-751) } ---------------------------------------------------------------------- -internal: (730-1219) +internal: (751-1240) export class internalC { } export function internalfoo(): void; @@ -4640,7 +4672,7 @@ internal: (730-1219) c = 2 } ---------------------------------------------------------------------- -text: (1221-1312) +text: (1242-1333) } declare module "file2" { export const y = 20; diff --git a/tests/baselines/reference/tsbuild/amdModulesWithOut/initial-build/stripInternal.js b/tests/baselines/reference/tsbuild/amdModulesWithOut/initial-build/stripInternal.js index 2d2bd9809d628..6192e04a062a3 100644 --- a/tests/baselines/reference/tsbuild/amdModulesWithOut/initial-build/stripInternal.js +++ b/tests/baselines/reference/tsbuild/amdModulesWithOut/initial-build/stripInternal.js @@ -2137,7 +2137,8 @@ declare module "file1" { constructor(); prop: string; method(): void; - /*@internal*/ c: number; + get c(): number; + set c(val: number); } export namespace normalN { class C { @@ -2187,7 +2188,7 @@ declare const globalConst = 10; //# sourceMappingURL=module.d.ts.map //// [/src/lib/module.d.ts.map] -{"version":3,"file":"module.d.ts","sourceRoot":"","sources":["file0.ts","file1.ts","file2.ts","global.ts"],"names":[],"mappings":"AAAc,QAAA,MAAM,MAAM,KAAK,CAAC;;ICAhC,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC;IACpB,MAAM,OAAO,OAAO;;QAEF,IAAI,EAAE,MAAM,CAAC;QACb,MAAM;sBACF,CAAC,EACM,MAAM;KAClC;IACD,MAAM,WAAW,OAAO,CAAC;QACP,MAAa,CAAC;SAAI;QAClB,SAAgB,GAAG,SAAK;QACxB,UAAiB,aAAa,CAAC;YAAE,MAAa,CAAC;aAAG;SAAE;QACpD,UAAiB,SAAS,CAAC,SAAS,CAAC;YAAE,MAAa,SAAS;aAAG;SAAE;QAClE,MAAM,QAAQ,UAAU,GAAG,aAAa,CAAC,CAAC,CAAC;QAC3C,KAAY,YAAY,GAAG,SAAS,CAAC;QAC9B,MAAM,aAAa,KAAK,CAAC;QAChC,KAAY,YAAY;YAAG,CAAC,IAAA;YAAE,CAAC,IAAA;YAAE,CAAC,IAAA;SAAE;KACrD;IACa,MAAM,OAAO,SAAS;KAAG;IACzB,MAAM,UAAU,WAAW,SAAK;IAChC,MAAM,WAAW,iBAAiB,CAAC;QAAE,MAAa,SAAS;SAAG;KAAE;IAChE,MAAM,WAAW,aAAa,CAAC,SAAS,CAAC;QAAE,MAAa,SAAS;SAAG;KAAE;IACtE,MAAM,QAAQ,cAAc,GAAG,iBAAiB,CAAC,SAAS,CAAC;IAC3D,MAAM,MAAM,YAAY,GAAG,SAAS,CAAC;IACrC,MAAM,CAAC,MAAM,aAAa,KAAK,CAAC;IAChC,MAAM,MAAM,YAAY;QAAG,CAAC,IAAA;QAAE,CAAC,IAAA;QAAE,CAAC,IAAA;KAAE;;;ICzBlD,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC;;ACApB,QAAA,MAAM,WAAW,KAAK,CAAC"} +{"version":3,"file":"module.d.ts","sourceRoot":"","sources":["file0.ts","file1.ts","file2.ts","global.ts"],"names":[],"mappings":"AAAc,QAAA,MAAM,MAAM,KAAK,CAAC;;ICAhC,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC;IACpB,MAAM,OAAO,OAAO;;QAEF,IAAI,EAAE,MAAM,CAAC;QACb,MAAM;QACN,IAAI,CAAC,IACM,MAAM,CADK;QACtB,IAAI,CAAC,CAAC,KAAK,MAAM,EAAK;KACvC;IACD,MAAM,WAAW,OAAO,CAAC;QACP,MAAa,CAAC;SAAI;QAClB,SAAgB,GAAG,SAAK;QACxB,UAAiB,aAAa,CAAC;YAAE,MAAa,CAAC;aAAG;SAAE;QACpD,UAAiB,SAAS,CAAC,SAAS,CAAC;YAAE,MAAa,SAAS;aAAG;SAAE;QAClE,MAAM,QAAQ,UAAU,GAAG,aAAa,CAAC,CAAC,CAAC;QAC3C,KAAY,YAAY,GAAG,SAAS,CAAC;QAC9B,MAAM,aAAa,KAAK,CAAC;QAChC,KAAY,YAAY;YAAG,CAAC,IAAA;YAAE,CAAC,IAAA;YAAE,CAAC,IAAA;SAAE;KACrD;IACa,MAAM,OAAO,SAAS;KAAG;IACzB,MAAM,UAAU,WAAW,SAAK;IAChC,MAAM,WAAW,iBAAiB,CAAC;QAAE,MAAa,SAAS;SAAG;KAAE;IAChE,MAAM,WAAW,aAAa,CAAC,SAAS,CAAC;QAAE,MAAa,SAAS;SAAG;KAAE;IACtE,MAAM,QAAQ,cAAc,GAAG,iBAAiB,CAAC,SAAS,CAAC;IAC3D,MAAM,MAAM,YAAY,GAAG,SAAS,CAAC;IACrC,MAAM,CAAC,MAAM,aAAa,KAAK,CAAC;IAChC,MAAM,MAAM,YAAY;QAAG,CAAC,IAAA;QAAE,CAAC,IAAA;QAAE,CAAC,IAAA;KAAE;;;ICzBlD,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC;;ACApB,QAAA,MAAM,WAAW,KAAK,CAAC"} //// [/src/lib/module.d.ts.map.baseline.txt] =================================================================== @@ -2288,35 +2289,66 @@ sourceFile:file1.ts >>> method(): void; 1->^^^^^^^^ 2 > ^^^^^^ -3 > ^^^^^^^^^^^^^^^^^^^-> +3 > ^^^^^^^^^^^-> 1-> > /*@internal*/ 2 > method 1->Emitted(7, 9) Source(5, 19) + SourceIndex(1) 2 >Emitted(7, 15) Source(5, 25) + SourceIndex(1) --- ->>> /*@internal*/ c: number; -1->^^^^^^^^^^^^^^^^^^^^^^ -2 > ^ -3 > ^^ -4 > ^^^^^^ +>>> get c(): number; +1->^^^^^^^^ +2 > ^^^^ +3 > ^ +4 > ^^^^ +5 > ^^^^^^ +6 > ^ +7 > ^^^^-> 1->() { } - > /*@internal*/ get -2 > c -3 > () { return 10; } - > /*@internal*/ set c(val: -4 > number -1->Emitted(8, 23) Source(6, 23) + SourceIndex(1) -2 >Emitted(8, 24) Source(6, 24) + SourceIndex(1) -3 >Emitted(8, 26) Source(7, 30) + SourceIndex(1) -4 >Emitted(8, 32) Source(7, 36) + SourceIndex(1) + > /*@internal*/ +2 > get +3 > c +4 > () { return 10; } + > /*@internal*/ set c(val: +5 > number +6 > +1->Emitted(8, 9) Source(6, 19) + SourceIndex(1) +2 >Emitted(8, 13) Source(6, 23) + SourceIndex(1) +3 >Emitted(8, 14) Source(6, 24) + SourceIndex(1) +4 >Emitted(8, 18) Source(7, 30) + SourceIndex(1) +5 >Emitted(8, 24) Source(7, 36) + SourceIndex(1) +6 >Emitted(8, 25) Source(6, 41) + SourceIndex(1) +--- +>>> set c(val: number); +1->^^^^^^^^ +2 > ^^^^ +3 > ^ +4 > ^ +5 > ^^^^^ +6 > ^^^^^^ +7 > ^^ +1-> + > /*@internal*/ +2 > set +3 > c +4 > ( +5 > val: +6 > number +7 > ) { } +1->Emitted(9, 9) Source(7, 19) + SourceIndex(1) +2 >Emitted(9, 13) Source(7, 23) + SourceIndex(1) +3 >Emitted(9, 14) Source(7, 24) + SourceIndex(1) +4 >Emitted(9, 15) Source(7, 25) + SourceIndex(1) +5 >Emitted(9, 20) Source(7, 30) + SourceIndex(1) +6 >Emitted(9, 26) Source(7, 36) + SourceIndex(1) +7 >Emitted(9, 28) Source(7, 41) + SourceIndex(1) --- >>> } 1 >^^^^^ 2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1 >) { } +1 > >} -1 >Emitted(9, 6) Source(8, 2) + SourceIndex(1) +1 >Emitted(10, 6) Source(8, 2) + SourceIndex(1) --- >>> export namespace normalN { 1->^^^^ @@ -2330,11 +2362,11 @@ sourceFile:file1.ts 3 > namespace 4 > normalN 5 > -1->Emitted(10, 5) Source(9, 1) + SourceIndex(1) -2 >Emitted(10, 11) Source(9, 7) + SourceIndex(1) -3 >Emitted(10, 22) Source(9, 18) + SourceIndex(1) -4 >Emitted(10, 29) Source(9, 25) + SourceIndex(1) -5 >Emitted(10, 30) Source(9, 26) + SourceIndex(1) +1->Emitted(11, 5) Source(9, 1) + SourceIndex(1) +2 >Emitted(11, 11) Source(9, 7) + SourceIndex(1) +3 >Emitted(11, 22) Source(9, 18) + SourceIndex(1) +4 >Emitted(11, 29) Source(9, 25) + SourceIndex(1) +5 >Emitted(11, 30) Source(9, 26) + SourceIndex(1) --- >>> class C { 1 >^^^^^^^^ @@ -2344,15 +2376,15 @@ sourceFile:file1.ts > /*@internal*/ 2 > export class 3 > C -1 >Emitted(11, 9) Source(10, 19) + SourceIndex(1) -2 >Emitted(11, 15) Source(10, 32) + SourceIndex(1) -3 >Emitted(11, 16) Source(10, 33) + SourceIndex(1) +1 >Emitted(12, 9) Source(10, 19) + SourceIndex(1) +2 >Emitted(12, 15) Source(10, 32) + SourceIndex(1) +3 >Emitted(12, 16) Source(10, 33) + SourceIndex(1) --- >>> } 1 >^^^^^^^^^ 2 > ^^^^^^^^^^^^^^^^^^^^^-> 1 > { } -1 >Emitted(12, 10) Source(10, 37) + SourceIndex(1) +1 >Emitted(13, 10) Source(10, 37) + SourceIndex(1) --- >>> function foo(): void; 1->^^^^^^^^ @@ -2365,10 +2397,10 @@ sourceFile:file1.ts 2 > export function 3 > foo 4 > () {} -1->Emitted(13, 9) Source(11, 19) + SourceIndex(1) -2 >Emitted(13, 18) Source(11, 35) + SourceIndex(1) -3 >Emitted(13, 21) Source(11, 38) + SourceIndex(1) -4 >Emitted(13, 30) Source(11, 43) + SourceIndex(1) +1->Emitted(14, 9) Source(11, 19) + SourceIndex(1) +2 >Emitted(14, 18) Source(11, 35) + SourceIndex(1) +3 >Emitted(14, 21) Source(11, 38) + SourceIndex(1) +4 >Emitted(14, 30) Source(11, 43) + SourceIndex(1) --- >>> namespace someNamespace { 1->^^^^^^^^ @@ -2380,10 +2412,10 @@ sourceFile:file1.ts 2 > export namespace 3 > someNamespace 4 > -1->Emitted(14, 9) Source(12, 19) + SourceIndex(1) -2 >Emitted(14, 19) Source(12, 36) + SourceIndex(1) -3 >Emitted(14, 32) Source(12, 49) + SourceIndex(1) -4 >Emitted(14, 33) Source(12, 50) + SourceIndex(1) +1->Emitted(15, 9) Source(12, 19) + SourceIndex(1) +2 >Emitted(15, 19) Source(12, 36) + SourceIndex(1) +3 >Emitted(15, 32) Source(12, 49) + SourceIndex(1) +4 >Emitted(15, 33) Source(12, 50) + SourceIndex(1) --- >>> class C { 1 >^^^^^^^^^^^^ @@ -2392,20 +2424,20 @@ sourceFile:file1.ts 1 >{ 2 > export class 3 > C -1 >Emitted(15, 13) Source(12, 52) + SourceIndex(1) -2 >Emitted(15, 19) Source(12, 65) + SourceIndex(1) -3 >Emitted(15, 20) Source(12, 66) + SourceIndex(1) +1 >Emitted(16, 13) Source(12, 52) + SourceIndex(1) +2 >Emitted(16, 19) Source(12, 65) + SourceIndex(1) +3 >Emitted(16, 20) Source(12, 66) + SourceIndex(1) --- >>> } 1 >^^^^^^^^^^^^^ 1 > {} -1 >Emitted(16, 14) Source(12, 69) + SourceIndex(1) +1 >Emitted(17, 14) Source(12, 69) + SourceIndex(1) --- >>> } 1 >^^^^^^^^^ 2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> 1 > } -1 >Emitted(17, 10) Source(12, 71) + SourceIndex(1) +1 >Emitted(18, 10) Source(12, 71) + SourceIndex(1) --- >>> namespace someOther.something { 1->^^^^^^^^ @@ -2421,12 +2453,12 @@ sourceFile:file1.ts 4 > . 5 > something 6 > -1->Emitted(18, 9) Source(13, 19) + SourceIndex(1) -2 >Emitted(18, 19) Source(13, 36) + SourceIndex(1) -3 >Emitted(18, 28) Source(13, 45) + SourceIndex(1) -4 >Emitted(18, 29) Source(13, 46) + SourceIndex(1) -5 >Emitted(18, 38) Source(13, 55) + SourceIndex(1) -6 >Emitted(18, 39) Source(13, 56) + SourceIndex(1) +1->Emitted(19, 9) Source(13, 19) + SourceIndex(1) +2 >Emitted(19, 19) Source(13, 36) + SourceIndex(1) +3 >Emitted(19, 28) Source(13, 45) + SourceIndex(1) +4 >Emitted(19, 29) Source(13, 46) + SourceIndex(1) +5 >Emitted(19, 38) Source(13, 55) + SourceIndex(1) +6 >Emitted(19, 39) Source(13, 56) + SourceIndex(1) --- >>> class someClass { 1 >^^^^^^^^^^^^ @@ -2435,20 +2467,20 @@ sourceFile:file1.ts 1 >{ 2 > export class 3 > someClass -1 >Emitted(19, 13) Source(13, 58) + SourceIndex(1) -2 >Emitted(19, 19) Source(13, 71) + SourceIndex(1) -3 >Emitted(19, 28) Source(13, 80) + SourceIndex(1) +1 >Emitted(20, 13) Source(13, 58) + SourceIndex(1) +2 >Emitted(20, 19) Source(13, 71) + SourceIndex(1) +3 >Emitted(20, 28) Source(13, 80) + SourceIndex(1) --- >>> } 1 >^^^^^^^^^^^^^ 1 > {} -1 >Emitted(20, 14) Source(13, 83) + SourceIndex(1) +1 >Emitted(21, 14) Source(13, 83) + SourceIndex(1) --- >>> } 1 >^^^^^^^^^ 2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> 1 > } -1 >Emitted(21, 10) Source(13, 85) + SourceIndex(1) +1 >Emitted(22, 10) Source(13, 85) + SourceIndex(1) --- >>> export import someImport = someNamespace.C; 1->^^^^^^^^ @@ -2470,15 +2502,15 @@ sourceFile:file1.ts 7 > . 8 > C 9 > ; -1->Emitted(22, 9) Source(14, 19) + SourceIndex(1) -2 >Emitted(22, 15) Source(14, 25) + SourceIndex(1) -3 >Emitted(22, 23) Source(14, 33) + SourceIndex(1) -4 >Emitted(22, 33) Source(14, 43) + SourceIndex(1) -5 >Emitted(22, 36) Source(14, 46) + SourceIndex(1) -6 >Emitted(22, 49) Source(14, 59) + SourceIndex(1) -7 >Emitted(22, 50) Source(14, 60) + SourceIndex(1) -8 >Emitted(22, 51) Source(14, 61) + SourceIndex(1) -9 >Emitted(22, 52) Source(14, 62) + SourceIndex(1) +1->Emitted(23, 9) Source(14, 19) + SourceIndex(1) +2 >Emitted(23, 15) Source(14, 25) + SourceIndex(1) +3 >Emitted(23, 23) Source(14, 33) + SourceIndex(1) +4 >Emitted(23, 33) Source(14, 43) + SourceIndex(1) +5 >Emitted(23, 36) Source(14, 46) + SourceIndex(1) +6 >Emitted(23, 49) Source(14, 59) + SourceIndex(1) +7 >Emitted(23, 50) Source(14, 60) + SourceIndex(1) +8 >Emitted(23, 51) Source(14, 61) + SourceIndex(1) +9 >Emitted(23, 52) Source(14, 62) + SourceIndex(1) --- >>> type internalType = internalC; 1 >^^^^^^^^ @@ -2494,12 +2526,12 @@ sourceFile:file1.ts 4 > = 5 > internalC 6 > ; -1 >Emitted(23, 9) Source(15, 19) + SourceIndex(1) -2 >Emitted(23, 14) Source(15, 31) + SourceIndex(1) -3 >Emitted(23, 26) Source(15, 43) + SourceIndex(1) -4 >Emitted(23, 29) Source(15, 46) + SourceIndex(1) -5 >Emitted(23, 38) Source(15, 55) + SourceIndex(1) -6 >Emitted(23, 39) Source(15, 56) + SourceIndex(1) +1 >Emitted(24, 9) Source(15, 19) + SourceIndex(1) +2 >Emitted(24, 14) Source(15, 31) + SourceIndex(1) +3 >Emitted(24, 26) Source(15, 43) + SourceIndex(1) +4 >Emitted(24, 29) Source(15, 46) + SourceIndex(1) +5 >Emitted(24, 38) Source(15, 55) + SourceIndex(1) +6 >Emitted(24, 39) Source(15, 56) + SourceIndex(1) --- >>> const internalConst = 10; 1 >^^^^^^^^ @@ -2513,11 +2545,11 @@ sourceFile:file1.ts 3 > internalConst 4 > = 10 5 > ; -1 >Emitted(24, 9) Source(16, 26) + SourceIndex(1) -2 >Emitted(24, 15) Source(16, 32) + SourceIndex(1) -3 >Emitted(24, 28) Source(16, 45) + SourceIndex(1) -4 >Emitted(24, 33) Source(16, 50) + SourceIndex(1) -5 >Emitted(24, 34) Source(16, 51) + SourceIndex(1) +1 >Emitted(25, 9) Source(16, 26) + SourceIndex(1) +2 >Emitted(25, 15) Source(16, 32) + SourceIndex(1) +3 >Emitted(25, 28) Source(16, 45) + SourceIndex(1) +4 >Emitted(25, 33) Source(16, 50) + SourceIndex(1) +5 >Emitted(25, 34) Source(16, 51) + SourceIndex(1) --- >>> enum internalEnum { 1 >^^^^^^^^ @@ -2527,9 +2559,9 @@ sourceFile:file1.ts > /*@internal*/ 2 > export enum 3 > internalEnum -1 >Emitted(25, 9) Source(17, 19) + SourceIndex(1) -2 >Emitted(25, 14) Source(17, 31) + SourceIndex(1) -3 >Emitted(25, 26) Source(17, 43) + SourceIndex(1) +1 >Emitted(26, 9) Source(17, 19) + SourceIndex(1) +2 >Emitted(26, 14) Source(17, 31) + SourceIndex(1) +3 >Emitted(26, 26) Source(17, 43) + SourceIndex(1) --- >>> a = 0, 1 >^^^^^^^^^^^^ @@ -2539,9 +2571,9 @@ sourceFile:file1.ts 1 > { 2 > a 3 > -1 >Emitted(26, 13) Source(17, 46) + SourceIndex(1) -2 >Emitted(26, 14) Source(17, 47) + SourceIndex(1) -3 >Emitted(26, 18) Source(17, 47) + SourceIndex(1) +1 >Emitted(27, 13) Source(17, 46) + SourceIndex(1) +2 >Emitted(27, 14) Source(17, 47) + SourceIndex(1) +3 >Emitted(27, 18) Source(17, 47) + SourceIndex(1) --- >>> b = 1, 1->^^^^^^^^^^^^ @@ -2551,9 +2583,9 @@ sourceFile:file1.ts 1->, 2 > b 3 > -1->Emitted(27, 13) Source(17, 49) + SourceIndex(1) -2 >Emitted(27, 14) Source(17, 50) + SourceIndex(1) -3 >Emitted(27, 18) Source(17, 50) + SourceIndex(1) +1->Emitted(28, 13) Source(17, 49) + SourceIndex(1) +2 >Emitted(28, 14) Source(17, 50) + SourceIndex(1) +3 >Emitted(28, 18) Source(17, 50) + SourceIndex(1) --- >>> c = 2 1->^^^^^^^^^^^^ @@ -2562,21 +2594,21 @@ sourceFile:file1.ts 1->, 2 > c 3 > -1->Emitted(28, 13) Source(17, 52) + SourceIndex(1) -2 >Emitted(28, 14) Source(17, 53) + SourceIndex(1) -3 >Emitted(28, 18) Source(17, 53) + SourceIndex(1) +1->Emitted(29, 13) Source(17, 52) + SourceIndex(1) +2 >Emitted(29, 14) Source(17, 53) + SourceIndex(1) +3 >Emitted(29, 18) Source(17, 53) + SourceIndex(1) --- >>> } 1 >^^^^^^^^^ 1 > } -1 >Emitted(29, 10) Source(17, 55) + SourceIndex(1) +1 >Emitted(30, 10) Source(17, 55) + SourceIndex(1) --- >>> } 1 >^^^^^ 2 > ^^^^^^^^^^^^^^^^^^^^^^^^-> 1 > >} -1 >Emitted(30, 6) Source(18, 2) + SourceIndex(1) +1 >Emitted(31, 6) Source(18, 2) + SourceIndex(1) --- >>> export class internalC { 1->^^^^ @@ -2588,16 +2620,16 @@ sourceFile:file1.ts 2 > export 3 > class 4 > internalC -1->Emitted(31, 5) Source(19, 15) + SourceIndex(1) -2 >Emitted(31, 11) Source(19, 21) + SourceIndex(1) -3 >Emitted(31, 18) Source(19, 28) + SourceIndex(1) -4 >Emitted(31, 27) Source(19, 37) + SourceIndex(1) +1->Emitted(32, 5) Source(19, 15) + SourceIndex(1) +2 >Emitted(32, 11) Source(19, 21) + SourceIndex(1) +3 >Emitted(32, 18) Source(19, 28) + SourceIndex(1) +4 >Emitted(32, 27) Source(19, 37) + SourceIndex(1) --- >>> } 1 >^^^^^ 2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> 1 > {} -1 >Emitted(32, 6) Source(19, 40) + SourceIndex(1) +1 >Emitted(33, 6) Source(19, 40) + SourceIndex(1) --- >>> export function internalfoo(): void; 1->^^^^ @@ -2612,11 +2644,11 @@ sourceFile:file1.ts 3 > function 4 > internalfoo 5 > () {} -1->Emitted(33, 5) Source(20, 15) + SourceIndex(1) -2 >Emitted(33, 11) Source(20, 21) + SourceIndex(1) -3 >Emitted(33, 21) Source(20, 31) + SourceIndex(1) -4 >Emitted(33, 32) Source(20, 42) + SourceIndex(1) -5 >Emitted(33, 41) Source(20, 47) + SourceIndex(1) +1->Emitted(34, 5) Source(20, 15) + SourceIndex(1) +2 >Emitted(34, 11) Source(20, 21) + SourceIndex(1) +3 >Emitted(34, 21) Source(20, 31) + SourceIndex(1) +4 >Emitted(34, 32) Source(20, 42) + SourceIndex(1) +5 >Emitted(34, 41) Source(20, 47) + SourceIndex(1) --- >>> export namespace internalNamespace { 1->^^^^ @@ -2630,11 +2662,11 @@ sourceFile:file1.ts 3 > namespace 4 > internalNamespace 5 > -1->Emitted(34, 5) Source(21, 15) + SourceIndex(1) -2 >Emitted(34, 11) Source(21, 21) + SourceIndex(1) -3 >Emitted(34, 22) Source(21, 32) + SourceIndex(1) -4 >Emitted(34, 39) Source(21, 49) + SourceIndex(1) -5 >Emitted(34, 40) Source(21, 50) + SourceIndex(1) +1->Emitted(35, 5) Source(21, 15) + SourceIndex(1) +2 >Emitted(35, 11) Source(21, 21) + SourceIndex(1) +3 >Emitted(35, 22) Source(21, 32) + SourceIndex(1) +4 >Emitted(35, 39) Source(21, 49) + SourceIndex(1) +5 >Emitted(35, 40) Source(21, 50) + SourceIndex(1) --- >>> class someClass { 1 >^^^^^^^^ @@ -2643,20 +2675,20 @@ sourceFile:file1.ts 1 >{ 2 > export class 3 > someClass -1 >Emitted(35, 9) Source(21, 52) + SourceIndex(1) -2 >Emitted(35, 15) Source(21, 65) + SourceIndex(1) -3 >Emitted(35, 24) Source(21, 74) + SourceIndex(1) +1 >Emitted(36, 9) Source(21, 52) + SourceIndex(1) +2 >Emitted(36, 15) Source(21, 65) + SourceIndex(1) +3 >Emitted(36, 24) Source(21, 74) + SourceIndex(1) --- >>> } 1 >^^^^^^^^^ 1 > {} -1 >Emitted(36, 10) Source(21, 77) + SourceIndex(1) +1 >Emitted(37, 10) Source(21, 77) + SourceIndex(1) --- >>> } 1 >^^^^^ 2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> 1 > } -1 >Emitted(37, 6) Source(21, 79) + SourceIndex(1) +1 >Emitted(38, 6) Source(21, 79) + SourceIndex(1) --- >>> export namespace internalOther.something { 1->^^^^ @@ -2674,13 +2706,13 @@ sourceFile:file1.ts 5 > . 6 > something 7 > -1->Emitted(38, 5) Source(22, 15) + SourceIndex(1) -2 >Emitted(38, 11) Source(22, 21) + SourceIndex(1) -3 >Emitted(38, 22) Source(22, 32) + SourceIndex(1) -4 >Emitted(38, 35) Source(22, 45) + SourceIndex(1) -5 >Emitted(38, 36) Source(22, 46) + SourceIndex(1) -6 >Emitted(38, 45) Source(22, 55) + SourceIndex(1) -7 >Emitted(38, 46) Source(22, 56) + SourceIndex(1) +1->Emitted(39, 5) Source(22, 15) + SourceIndex(1) +2 >Emitted(39, 11) Source(22, 21) + SourceIndex(1) +3 >Emitted(39, 22) Source(22, 32) + SourceIndex(1) +4 >Emitted(39, 35) Source(22, 45) + SourceIndex(1) +5 >Emitted(39, 36) Source(22, 46) + SourceIndex(1) +6 >Emitted(39, 45) Source(22, 55) + SourceIndex(1) +7 >Emitted(39, 46) Source(22, 56) + SourceIndex(1) --- >>> class someClass { 1 >^^^^^^^^ @@ -2689,20 +2721,20 @@ sourceFile:file1.ts 1 >{ 2 > export class 3 > someClass -1 >Emitted(39, 9) Source(22, 58) + SourceIndex(1) -2 >Emitted(39, 15) Source(22, 71) + SourceIndex(1) -3 >Emitted(39, 24) Source(22, 80) + SourceIndex(1) +1 >Emitted(40, 9) Source(22, 58) + SourceIndex(1) +2 >Emitted(40, 15) Source(22, 71) + SourceIndex(1) +3 >Emitted(40, 24) Source(22, 80) + SourceIndex(1) --- >>> } 1 >^^^^^^^^^ 1 > {} -1 >Emitted(40, 10) Source(22, 83) + SourceIndex(1) +1 >Emitted(41, 10) Source(22, 83) + SourceIndex(1) --- >>> } 1 >^^^^^ 2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> 1 > } -1 >Emitted(41, 6) Source(22, 85) + SourceIndex(1) +1 >Emitted(42, 6) Source(22, 85) + SourceIndex(1) --- >>> export import internalImport = internalNamespace.someClass; 1->^^^^ @@ -2724,15 +2756,15 @@ sourceFile:file1.ts 7 > . 8 > someClass 9 > ; -1->Emitted(42, 5) Source(23, 15) + SourceIndex(1) -2 >Emitted(42, 11) Source(23, 21) + SourceIndex(1) -3 >Emitted(42, 19) Source(23, 29) + SourceIndex(1) -4 >Emitted(42, 33) Source(23, 43) + SourceIndex(1) -5 >Emitted(42, 36) Source(23, 46) + SourceIndex(1) -6 >Emitted(42, 53) Source(23, 63) + SourceIndex(1) -7 >Emitted(42, 54) Source(23, 64) + SourceIndex(1) -8 >Emitted(42, 63) Source(23, 73) + SourceIndex(1) -9 >Emitted(42, 64) Source(23, 74) + SourceIndex(1) +1->Emitted(43, 5) Source(23, 15) + SourceIndex(1) +2 >Emitted(43, 11) Source(23, 21) + SourceIndex(1) +3 >Emitted(43, 19) Source(23, 29) + SourceIndex(1) +4 >Emitted(43, 33) Source(23, 43) + SourceIndex(1) +5 >Emitted(43, 36) Source(23, 46) + SourceIndex(1) +6 >Emitted(43, 53) Source(23, 63) + SourceIndex(1) +7 >Emitted(43, 54) Source(23, 64) + SourceIndex(1) +8 >Emitted(43, 63) Source(23, 73) + SourceIndex(1) +9 >Emitted(43, 64) Source(23, 74) + SourceIndex(1) --- >>> export type internalType = internalC; 1 >^^^^ @@ -2750,13 +2782,13 @@ sourceFile:file1.ts 5 > = 6 > internalC 7 > ; -1 >Emitted(43, 5) Source(24, 15) + SourceIndex(1) -2 >Emitted(43, 11) Source(24, 21) + SourceIndex(1) -3 >Emitted(43, 17) Source(24, 27) + SourceIndex(1) -4 >Emitted(43, 29) Source(24, 39) + SourceIndex(1) -5 >Emitted(43, 32) Source(24, 42) + SourceIndex(1) -6 >Emitted(43, 41) Source(24, 51) + SourceIndex(1) -7 >Emitted(43, 42) Source(24, 52) + SourceIndex(1) +1 >Emitted(44, 5) Source(24, 15) + SourceIndex(1) +2 >Emitted(44, 11) Source(24, 21) + SourceIndex(1) +3 >Emitted(44, 17) Source(24, 27) + SourceIndex(1) +4 >Emitted(44, 29) Source(24, 39) + SourceIndex(1) +5 >Emitted(44, 32) Source(24, 42) + SourceIndex(1) +6 >Emitted(44, 41) Source(24, 51) + SourceIndex(1) +7 >Emitted(44, 42) Source(24, 52) + SourceIndex(1) --- >>> export const internalConst = 10; 1 >^^^^ @@ -2774,13 +2806,13 @@ sourceFile:file1.ts 5 > internalConst 6 > = 10 7 > ; -1 >Emitted(44, 5) Source(25, 15) + SourceIndex(1) -2 >Emitted(44, 11) Source(25, 21) + SourceIndex(1) -3 >Emitted(44, 12) Source(25, 22) + SourceIndex(1) -4 >Emitted(44, 18) Source(25, 28) + SourceIndex(1) -5 >Emitted(44, 31) Source(25, 41) + SourceIndex(1) -6 >Emitted(44, 36) Source(25, 46) + SourceIndex(1) -7 >Emitted(44, 37) Source(25, 47) + SourceIndex(1) +1 >Emitted(45, 5) Source(25, 15) + SourceIndex(1) +2 >Emitted(45, 11) Source(25, 21) + SourceIndex(1) +3 >Emitted(45, 12) Source(25, 22) + SourceIndex(1) +4 >Emitted(45, 18) Source(25, 28) + SourceIndex(1) +5 >Emitted(45, 31) Source(25, 41) + SourceIndex(1) +6 >Emitted(45, 36) Source(25, 46) + SourceIndex(1) +7 >Emitted(45, 37) Source(25, 47) + SourceIndex(1) --- >>> export enum internalEnum { 1 >^^^^ @@ -2792,10 +2824,10 @@ sourceFile:file1.ts 2 > export 3 > enum 4 > internalEnum -1 >Emitted(45, 5) Source(26, 15) + SourceIndex(1) -2 >Emitted(45, 11) Source(26, 21) + SourceIndex(1) -3 >Emitted(45, 17) Source(26, 27) + SourceIndex(1) -4 >Emitted(45, 29) Source(26, 39) + SourceIndex(1) +1 >Emitted(46, 5) Source(26, 15) + SourceIndex(1) +2 >Emitted(46, 11) Source(26, 21) + SourceIndex(1) +3 >Emitted(46, 17) Source(26, 27) + SourceIndex(1) +4 >Emitted(46, 29) Source(26, 39) + SourceIndex(1) --- >>> a = 0, 1 >^^^^^^^^ @@ -2805,9 +2837,9 @@ sourceFile:file1.ts 1 > { 2 > a 3 > -1 >Emitted(46, 9) Source(26, 42) + SourceIndex(1) -2 >Emitted(46, 10) Source(26, 43) + SourceIndex(1) -3 >Emitted(46, 14) Source(26, 43) + SourceIndex(1) +1 >Emitted(47, 9) Source(26, 42) + SourceIndex(1) +2 >Emitted(47, 10) Source(26, 43) + SourceIndex(1) +3 >Emitted(47, 14) Source(26, 43) + SourceIndex(1) --- >>> b = 1, 1->^^^^^^^^ @@ -2817,9 +2849,9 @@ sourceFile:file1.ts 1->, 2 > b 3 > -1->Emitted(47, 9) Source(26, 45) + SourceIndex(1) -2 >Emitted(47, 10) Source(26, 46) + SourceIndex(1) -3 >Emitted(47, 14) Source(26, 46) + SourceIndex(1) +1->Emitted(48, 9) Source(26, 45) + SourceIndex(1) +2 >Emitted(48, 10) Source(26, 46) + SourceIndex(1) +3 >Emitted(48, 14) Source(26, 46) + SourceIndex(1) --- >>> c = 2 1->^^^^^^^^ @@ -2828,14 +2860,14 @@ sourceFile:file1.ts 1->, 2 > c 3 > -1->Emitted(48, 9) Source(26, 48) + SourceIndex(1) -2 >Emitted(48, 10) Source(26, 49) + SourceIndex(1) -3 >Emitted(48, 14) Source(26, 49) + SourceIndex(1) +1->Emitted(49, 9) Source(26, 48) + SourceIndex(1) +2 >Emitted(49, 10) Source(26, 49) + SourceIndex(1) +3 >Emitted(49, 14) Source(26, 49) + SourceIndex(1) --- >>> } 1 >^^^^^ 1 > } -1 >Emitted(49, 6) Source(26, 51) + SourceIndex(1) +1 >Emitted(50, 6) Source(26, 51) + SourceIndex(1) --- ------------------------------------------------------------------- emittedFile:/src/lib/module.d.ts @@ -2858,13 +2890,13 @@ sourceFile:file2.ts 5 > y 6 > = 20 7 > ; -1 >Emitted(52, 5) Source(1, 1) + SourceIndex(2) -2 >Emitted(52, 11) Source(1, 7) + SourceIndex(2) -3 >Emitted(52, 12) Source(1, 8) + SourceIndex(2) -4 >Emitted(52, 18) Source(1, 14) + SourceIndex(2) -5 >Emitted(52, 19) Source(1, 15) + SourceIndex(2) -6 >Emitted(52, 24) Source(1, 20) + SourceIndex(2) -7 >Emitted(52, 25) Source(1, 21) + SourceIndex(2) +1 >Emitted(53, 5) Source(1, 1) + SourceIndex(2) +2 >Emitted(53, 11) Source(1, 7) + SourceIndex(2) +3 >Emitted(53, 12) Source(1, 8) + SourceIndex(2) +4 >Emitted(53, 18) Source(1, 14) + SourceIndex(2) +5 >Emitted(53, 19) Source(1, 15) + SourceIndex(2) +6 >Emitted(53, 24) Source(1, 20) + SourceIndex(2) +7 >Emitted(53, 25) Source(1, 21) + SourceIndex(2) --- ------------------------------------------------------------------- emittedFile:/src/lib/module.d.ts @@ -2885,12 +2917,12 @@ sourceFile:global.ts 4 > globalConst 5 > = 10 6 > ; -1 >Emitted(54, 1) Source(1, 1) + SourceIndex(3) -2 >Emitted(54, 9) Source(1, 1) + SourceIndex(3) -3 >Emitted(54, 15) Source(1, 7) + SourceIndex(3) -4 >Emitted(54, 26) Source(1, 18) + SourceIndex(3) -5 >Emitted(54, 31) Source(1, 23) + SourceIndex(3) -6 >Emitted(54, 32) Source(1, 24) + SourceIndex(3) +1 >Emitted(55, 1) Source(1, 1) + SourceIndex(3) +2 >Emitted(55, 9) Source(1, 1) + SourceIndex(3) +3 >Emitted(55, 15) Source(1, 7) + SourceIndex(3) +4 >Emitted(55, 26) Source(1, 18) + SourceIndex(3) +5 >Emitted(55, 31) Source(1, 23) + SourceIndex(3) +6 >Emitted(55, 32) Source(1, 24) + SourceIndex(3) --- >>>//# sourceMappingURL=module.d.ts.map @@ -4504,32 +4536,32 @@ sourceFile:global.ts }, { "pos": 108, - "end": 212, + "end": 233, "kind": "internal" }, { - "pos": 214, - "end": 253, + "pos": 235, + "end": 274, "kind": "text" }, { - "pos": 253, - "end": 721, + "pos": 274, + "end": 742, "kind": "internal" }, { - "pos": 723, - "end": 730, + "pos": 744, + "end": 751, "kind": "text" }, { - "pos": 730, - "end": 1219, + "pos": 751, + "end": 1240, "kind": "internal" }, { - "pos": 1221, - "end": 1312, + "pos": 1242, + "end": 1333, "kind": "text" } ] @@ -4659,18 +4691,19 @@ declare module "file1" { export class normalC { ---------------------------------------------------------------------- -internal: (108-212) +internal: (108-233) constructor(); prop: string; method(): void; - /*@internal*/ c: number; + get c(): number; + set c(val: number); ---------------------------------------------------------------------- -text: (214-253) +text: (235-274) } export namespace normalN { ---------------------------------------------------------------------- -internal: (253-721) +internal: (274-742) class C { } function foo(): void; @@ -4691,11 +4724,11 @@ internal: (253-721) c = 2 } ---------------------------------------------------------------------- -text: (723-730) +text: (744-751) } ---------------------------------------------------------------------- -internal: (730-1219) +internal: (751-1240) export class internalC { } export function internalfoo(): void; @@ -4716,7 +4749,7 @@ internal: (730-1219) c = 2 } ---------------------------------------------------------------------- -text: (1221-1312) +text: (1242-1333) } declare module "file2" { export const y = 20; diff --git a/tests/baselines/reference/tsbuild/outfile-concat/incremental-declaration-changes/stripInternal-when-one-two-three-are-prepended-in-order.js b/tests/baselines/reference/tsbuild/outfile-concat/incremental-declaration-changes/stripInternal-when-one-two-three-are-prepended-in-order.js index c218edfa8a9c1..cca89f269e911 100644 --- a/tests/baselines/reference/tsbuild/outfile-concat/incremental-declaration-changes/stripInternal-when-one-two-three-are-prepended-in-order.js +++ b/tests/baselines/reference/tsbuild/outfile-concat/incremental-declaration-changes/stripInternal-when-one-two-three-are-prepended-in-order.js @@ -58,7 +58,8 @@ declare class normalC { constructor(); prop: string; method(): void; - c: number; + get c(): number; + set c(val: number); } declare namespace normalN { class C { @@ -106,7 +107,7 @@ declare class C { //# sourceMappingURL=second-output.d.ts.map //// [/src/2/second-output.d.ts.map] -{"version":3,"file":"second-output.d.ts","sourceRoot":"","sources":["../first/first_PART1.ts","../first/first_part3.ts","../second/second_part1.ts","../second/second_part2.ts"],"names":[],"mappings":"AAAc,UAAU,QAAQ;IAC5B,IAAI,EAAE,GAAG,CAAC;CACb;AAED,QAAA,MAAM,CAAC,gBAAgB,CAAC;AAExB,UAAU,iBAAiB;IACvB,IAAI,EAAE,GAAG,CAAC;CACb;ACRD,iBAAS,CAAC,WAET;ACFD,kBAAU,CAAC,CAAC;CAEX;AAED,kBAAU,CAAC,CAAC;CAMX;AAED,cAAM,OAAO;;IAEK,IAAI,EAAE,MAAM,CAAC;IACb,MAAM;IACF,CAAC,EACM,MAAM;CAClC;AACD,kBAAU,OAAO,CAAC;IACA,MAAa,CAAC;KAAI;IAClB,SAAgB,GAAG,SAAK;IACxB,UAAiB,aAAa,CAAC;QAAE,MAAa,CAAC;SAAG;KAAE;IACpD,UAAiB,SAAS,CAAC,SAAS,CAAC;QAAE,MAAa,SAAS;SAAG;KAAE;IAClE,MAAM,QAAQ,UAAU,GAAG,aAAa,CAAC,CAAC,CAAC;IAC3C,KAAY,YAAY,GAAG,SAAS,CAAC;IAC9B,MAAM,aAAa,KAAK,CAAC;IAChC,KAAY,YAAY;QAAG,CAAC,IAAA;QAAE,CAAC,IAAA;QAAE,CAAC,IAAA;KAAE;CACrD;AACa,cAAM,SAAS;CAAG;AAClB,iBAAS,WAAW,SAAK;AACzB,kBAAU,iBAAiB,CAAC;IAAE,MAAa,SAAS;KAAG;CAAE;AACzD,kBAAU,aAAa,CAAC,SAAS,CAAC;IAAE,MAAa,SAAS;KAAG;CAAE;AAC/D,OAAO,cAAc,GAAG,iBAAiB,CAAC,SAAS,CAAC;AACpD,aAAK,YAAY,GAAG,SAAS,CAAC;AAC9B,QAAA,MAAM,aAAa,KAAK,CAAC;AACzB,aAAK,YAAY;IAAG,CAAC,IAAA;IAAE,CAAC,IAAA;IAAE,CAAC,IAAA;CAAE;ACpC3C,cAAM,CAAC;IACH,WAAW;CAGd"} +{"version":3,"file":"second-output.d.ts","sourceRoot":"","sources":["../first/first_PART1.ts","../first/first_part3.ts","../second/second_part1.ts","../second/second_part2.ts"],"names":[],"mappings":"AAAc,UAAU,QAAQ;IAC5B,IAAI,EAAE,GAAG,CAAC;CACb;AAED,QAAA,MAAM,CAAC,gBAAgB,CAAC;AAExB,UAAU,iBAAiB;IACvB,IAAI,EAAE,GAAG,CAAC;CACb;ACRD,iBAAS,CAAC,WAET;ACFD,kBAAU,CAAC,CAAC;CAEX;AAED,kBAAU,CAAC,CAAC;CAMX;AAED,cAAM,OAAO;;IAEK,IAAI,EAAE,MAAM,CAAC;IACb,MAAM;IACN,IAAI,CAAC,IACM,MAAM,CADK;IACtB,IAAI,CAAC,CAAC,KAAK,MAAM,EAAK;CACvC;AACD,kBAAU,OAAO,CAAC;IACA,MAAa,CAAC;KAAI;IAClB,SAAgB,GAAG,SAAK;IACxB,UAAiB,aAAa,CAAC;QAAE,MAAa,CAAC;SAAG;KAAE;IACpD,UAAiB,SAAS,CAAC,SAAS,CAAC;QAAE,MAAa,SAAS;SAAG;KAAE;IAClE,MAAM,QAAQ,UAAU,GAAG,aAAa,CAAC,CAAC,CAAC;IAC3C,KAAY,YAAY,GAAG,SAAS,CAAC;IAC9B,MAAM,aAAa,KAAK,CAAC;IAChC,KAAY,YAAY;QAAG,CAAC,IAAA;QAAE,CAAC,IAAA;QAAE,CAAC,IAAA;KAAE;CACrD;AACa,cAAM,SAAS;CAAG;AAClB,iBAAS,WAAW,SAAK;AACzB,kBAAU,iBAAiB,CAAC;IAAE,MAAa,SAAS;KAAG;CAAE;AACzD,kBAAU,aAAa,CAAC,SAAS,CAAC;IAAE,MAAa,SAAS;KAAG;CAAE;AAC/D,OAAO,cAAc,GAAG,iBAAiB,CAAC,SAAS,CAAC;AACpD,aAAK,YAAY,GAAG,SAAS,CAAC;AAC9B,QAAA,MAAM,aAAa,KAAK,CAAC;AACzB,aAAK,YAAY;IAAG,CAAC,IAAA;IAAE,CAAC,IAAA;IAAE,CAAC,IAAA;CAAE;ACpC3C,cAAM,CAAC;IACH,WAAW;CAGd"} //// [/src/2/second-output.d.ts.map.baseline.txt] =================================================================== @@ -326,35 +327,66 @@ sourceFile:../second/second_part1.ts >>> method(): void; 1->^^^^ 2 > ^^^^^^ -3 > ^^^^^-> +3 > ^^^^^^^^^^^-> 1-> > /*@internal*/ 2 > method 1->Emitted(16, 5) Source(16, 19) + SourceIndex(2) 2 >Emitted(16, 11) Source(16, 25) + SourceIndex(2) --- ->>> c: number; +>>> get c(): number; 1->^^^^ -2 > ^ -3 > ^^ -4 > ^^^^^^ +2 > ^^^^ +3 > ^ +4 > ^^^^ +5 > ^^^^^^ +6 > ^ +7 > ^^^^-> 1->() { } - > /*@internal*/ get -2 > c -3 > () { return 10; } - > /*@internal*/ set c(val: -4 > number -1->Emitted(17, 5) Source(17, 23) + SourceIndex(2) -2 >Emitted(17, 6) Source(17, 24) + SourceIndex(2) -3 >Emitted(17, 8) Source(18, 30) + SourceIndex(2) -4 >Emitted(17, 14) Source(18, 36) + SourceIndex(2) + > /*@internal*/ +2 > get +3 > c +4 > () { return 10; } + > /*@internal*/ set c(val: +5 > number +6 > +1->Emitted(17, 5) Source(17, 19) + SourceIndex(2) +2 >Emitted(17, 9) Source(17, 23) + SourceIndex(2) +3 >Emitted(17, 10) Source(17, 24) + SourceIndex(2) +4 >Emitted(17, 14) Source(18, 30) + SourceIndex(2) +5 >Emitted(17, 20) Source(18, 36) + SourceIndex(2) +6 >Emitted(17, 21) Source(17, 41) + SourceIndex(2) +--- +>>> set c(val: number); +1->^^^^ +2 > ^^^^ +3 > ^ +4 > ^ +5 > ^^^^^ +6 > ^^^^^^ +7 > ^^ +1-> + > /*@internal*/ +2 > set +3 > c +4 > ( +5 > val: +6 > number +7 > ) { } +1->Emitted(18, 5) Source(18, 19) + SourceIndex(2) +2 >Emitted(18, 9) Source(18, 23) + SourceIndex(2) +3 >Emitted(18, 10) Source(18, 24) + SourceIndex(2) +4 >Emitted(18, 11) Source(18, 25) + SourceIndex(2) +5 >Emitted(18, 16) Source(18, 30) + SourceIndex(2) +6 >Emitted(18, 22) Source(18, 36) + SourceIndex(2) +7 >Emitted(18, 24) Source(18, 41) + SourceIndex(2) --- >>>} 1 >^ 2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1 >) { } +1 > >} -1 >Emitted(18, 2) Source(19, 2) + SourceIndex(2) +1 >Emitted(19, 2) Source(19, 2) + SourceIndex(2) --- >>>declare namespace normalN { 1-> @@ -366,10 +398,10 @@ sourceFile:../second/second_part1.ts 2 >namespace 3 > normalN 4 > -1->Emitted(19, 1) Source(20, 1) + SourceIndex(2) -2 >Emitted(19, 19) Source(20, 11) + SourceIndex(2) -3 >Emitted(19, 26) Source(20, 18) + SourceIndex(2) -4 >Emitted(19, 27) Source(20, 19) + SourceIndex(2) +1->Emitted(20, 1) Source(20, 1) + SourceIndex(2) +2 >Emitted(20, 19) Source(20, 11) + SourceIndex(2) +3 >Emitted(20, 26) Source(20, 18) + SourceIndex(2) +4 >Emitted(20, 27) Source(20, 19) + SourceIndex(2) --- >>> class C { 1 >^^^^ @@ -379,15 +411,15 @@ sourceFile:../second/second_part1.ts > /*@internal*/ 2 > export class 3 > C -1 >Emitted(20, 5) Source(21, 19) + SourceIndex(2) -2 >Emitted(20, 11) Source(21, 32) + SourceIndex(2) -3 >Emitted(20, 12) Source(21, 33) + SourceIndex(2) +1 >Emitted(21, 5) Source(21, 19) + SourceIndex(2) +2 >Emitted(21, 11) Source(21, 32) + SourceIndex(2) +3 >Emitted(21, 12) Source(21, 33) + SourceIndex(2) --- >>> } 1 >^^^^^ 2 > ^^^^^^^^^^^^^^^^^^^^^-> 1 > { } -1 >Emitted(21, 6) Source(21, 37) + SourceIndex(2) +1 >Emitted(22, 6) Source(21, 37) + SourceIndex(2) --- >>> function foo(): void; 1->^^^^ @@ -400,10 +432,10 @@ sourceFile:../second/second_part1.ts 2 > export function 3 > foo 4 > () {} -1->Emitted(22, 5) Source(22, 19) + SourceIndex(2) -2 >Emitted(22, 14) Source(22, 35) + SourceIndex(2) -3 >Emitted(22, 17) Source(22, 38) + SourceIndex(2) -4 >Emitted(22, 26) Source(22, 43) + SourceIndex(2) +1->Emitted(23, 5) Source(22, 19) + SourceIndex(2) +2 >Emitted(23, 14) Source(22, 35) + SourceIndex(2) +3 >Emitted(23, 17) Source(22, 38) + SourceIndex(2) +4 >Emitted(23, 26) Source(22, 43) + SourceIndex(2) --- >>> namespace someNamespace { 1->^^^^ @@ -415,10 +447,10 @@ sourceFile:../second/second_part1.ts 2 > export namespace 3 > someNamespace 4 > -1->Emitted(23, 5) Source(23, 19) + SourceIndex(2) -2 >Emitted(23, 15) Source(23, 36) + SourceIndex(2) -3 >Emitted(23, 28) Source(23, 49) + SourceIndex(2) -4 >Emitted(23, 29) Source(23, 50) + SourceIndex(2) +1->Emitted(24, 5) Source(23, 19) + SourceIndex(2) +2 >Emitted(24, 15) Source(23, 36) + SourceIndex(2) +3 >Emitted(24, 28) Source(23, 49) + SourceIndex(2) +4 >Emitted(24, 29) Source(23, 50) + SourceIndex(2) --- >>> class C { 1 >^^^^^^^^ @@ -427,20 +459,20 @@ sourceFile:../second/second_part1.ts 1 >{ 2 > export class 3 > C -1 >Emitted(24, 9) Source(23, 52) + SourceIndex(2) -2 >Emitted(24, 15) Source(23, 65) + SourceIndex(2) -3 >Emitted(24, 16) Source(23, 66) + SourceIndex(2) +1 >Emitted(25, 9) Source(23, 52) + SourceIndex(2) +2 >Emitted(25, 15) Source(23, 65) + SourceIndex(2) +3 >Emitted(25, 16) Source(23, 66) + SourceIndex(2) --- >>> } 1 >^^^^^^^^^ 1 > {} -1 >Emitted(25, 10) Source(23, 69) + SourceIndex(2) +1 >Emitted(26, 10) Source(23, 69) + SourceIndex(2) --- >>> } 1 >^^^^^ 2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> 1 > } -1 >Emitted(26, 6) Source(23, 71) + SourceIndex(2) +1 >Emitted(27, 6) Source(23, 71) + SourceIndex(2) --- >>> namespace someOther.something { 1->^^^^ @@ -456,12 +488,12 @@ sourceFile:../second/second_part1.ts 4 > . 5 > something 6 > -1->Emitted(27, 5) Source(24, 19) + SourceIndex(2) -2 >Emitted(27, 15) Source(24, 36) + SourceIndex(2) -3 >Emitted(27, 24) Source(24, 45) + SourceIndex(2) -4 >Emitted(27, 25) Source(24, 46) + SourceIndex(2) -5 >Emitted(27, 34) Source(24, 55) + SourceIndex(2) -6 >Emitted(27, 35) Source(24, 56) + SourceIndex(2) +1->Emitted(28, 5) Source(24, 19) + SourceIndex(2) +2 >Emitted(28, 15) Source(24, 36) + SourceIndex(2) +3 >Emitted(28, 24) Source(24, 45) + SourceIndex(2) +4 >Emitted(28, 25) Source(24, 46) + SourceIndex(2) +5 >Emitted(28, 34) Source(24, 55) + SourceIndex(2) +6 >Emitted(28, 35) Source(24, 56) + SourceIndex(2) --- >>> class someClass { 1 >^^^^^^^^ @@ -470,20 +502,20 @@ sourceFile:../second/second_part1.ts 1 >{ 2 > export class 3 > someClass -1 >Emitted(28, 9) Source(24, 58) + SourceIndex(2) -2 >Emitted(28, 15) Source(24, 71) + SourceIndex(2) -3 >Emitted(28, 24) Source(24, 80) + SourceIndex(2) +1 >Emitted(29, 9) Source(24, 58) + SourceIndex(2) +2 >Emitted(29, 15) Source(24, 71) + SourceIndex(2) +3 >Emitted(29, 24) Source(24, 80) + SourceIndex(2) --- >>> } 1 >^^^^^^^^^ 1 > {} -1 >Emitted(29, 10) Source(24, 83) + SourceIndex(2) +1 >Emitted(30, 10) Source(24, 83) + SourceIndex(2) --- >>> } 1 >^^^^^ 2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> 1 > } -1 >Emitted(30, 6) Source(24, 85) + SourceIndex(2) +1 >Emitted(31, 6) Source(24, 85) + SourceIndex(2) --- >>> export import someImport = someNamespace.C; 1->^^^^ @@ -505,15 +537,15 @@ sourceFile:../second/second_part1.ts 7 > . 8 > C 9 > ; -1->Emitted(31, 5) Source(25, 19) + SourceIndex(2) -2 >Emitted(31, 11) Source(25, 25) + SourceIndex(2) -3 >Emitted(31, 19) Source(25, 33) + SourceIndex(2) -4 >Emitted(31, 29) Source(25, 43) + SourceIndex(2) -5 >Emitted(31, 32) Source(25, 46) + SourceIndex(2) -6 >Emitted(31, 45) Source(25, 59) + SourceIndex(2) -7 >Emitted(31, 46) Source(25, 60) + SourceIndex(2) -8 >Emitted(31, 47) Source(25, 61) + SourceIndex(2) -9 >Emitted(31, 48) Source(25, 62) + SourceIndex(2) +1->Emitted(32, 5) Source(25, 19) + SourceIndex(2) +2 >Emitted(32, 11) Source(25, 25) + SourceIndex(2) +3 >Emitted(32, 19) Source(25, 33) + SourceIndex(2) +4 >Emitted(32, 29) Source(25, 43) + SourceIndex(2) +5 >Emitted(32, 32) Source(25, 46) + SourceIndex(2) +6 >Emitted(32, 45) Source(25, 59) + SourceIndex(2) +7 >Emitted(32, 46) Source(25, 60) + SourceIndex(2) +8 >Emitted(32, 47) Source(25, 61) + SourceIndex(2) +9 >Emitted(32, 48) Source(25, 62) + SourceIndex(2) --- >>> type internalType = internalC; 1 >^^^^ @@ -529,12 +561,12 @@ sourceFile:../second/second_part1.ts 4 > = 5 > internalC 6 > ; -1 >Emitted(32, 5) Source(26, 19) + SourceIndex(2) -2 >Emitted(32, 10) Source(26, 31) + SourceIndex(2) -3 >Emitted(32, 22) Source(26, 43) + SourceIndex(2) -4 >Emitted(32, 25) Source(26, 46) + SourceIndex(2) -5 >Emitted(32, 34) Source(26, 55) + SourceIndex(2) -6 >Emitted(32, 35) Source(26, 56) + SourceIndex(2) +1 >Emitted(33, 5) Source(26, 19) + SourceIndex(2) +2 >Emitted(33, 10) Source(26, 31) + SourceIndex(2) +3 >Emitted(33, 22) Source(26, 43) + SourceIndex(2) +4 >Emitted(33, 25) Source(26, 46) + SourceIndex(2) +5 >Emitted(33, 34) Source(26, 55) + SourceIndex(2) +6 >Emitted(33, 35) Source(26, 56) + SourceIndex(2) --- >>> const internalConst = 10; 1 >^^^^ @@ -548,11 +580,11 @@ sourceFile:../second/second_part1.ts 3 > internalConst 4 > = 10 5 > ; -1 >Emitted(33, 5) Source(27, 26) + SourceIndex(2) -2 >Emitted(33, 11) Source(27, 32) + SourceIndex(2) -3 >Emitted(33, 24) Source(27, 45) + SourceIndex(2) -4 >Emitted(33, 29) Source(27, 50) + SourceIndex(2) -5 >Emitted(33, 30) Source(27, 51) + SourceIndex(2) +1 >Emitted(34, 5) Source(27, 26) + SourceIndex(2) +2 >Emitted(34, 11) Source(27, 32) + SourceIndex(2) +3 >Emitted(34, 24) Source(27, 45) + SourceIndex(2) +4 >Emitted(34, 29) Source(27, 50) + SourceIndex(2) +5 >Emitted(34, 30) Source(27, 51) + SourceIndex(2) --- >>> enum internalEnum { 1 >^^^^ @@ -562,9 +594,9 @@ sourceFile:../second/second_part1.ts > /*@internal*/ 2 > export enum 3 > internalEnum -1 >Emitted(34, 5) Source(28, 19) + SourceIndex(2) -2 >Emitted(34, 10) Source(28, 31) + SourceIndex(2) -3 >Emitted(34, 22) Source(28, 43) + SourceIndex(2) +1 >Emitted(35, 5) Source(28, 19) + SourceIndex(2) +2 >Emitted(35, 10) Source(28, 31) + SourceIndex(2) +3 >Emitted(35, 22) Source(28, 43) + SourceIndex(2) --- >>> a = 0, 1 >^^^^^^^^ @@ -574,9 +606,9 @@ sourceFile:../second/second_part1.ts 1 > { 2 > a 3 > -1 >Emitted(35, 9) Source(28, 46) + SourceIndex(2) -2 >Emitted(35, 10) Source(28, 47) + SourceIndex(2) -3 >Emitted(35, 14) Source(28, 47) + SourceIndex(2) +1 >Emitted(36, 9) Source(28, 46) + SourceIndex(2) +2 >Emitted(36, 10) Source(28, 47) + SourceIndex(2) +3 >Emitted(36, 14) Source(28, 47) + SourceIndex(2) --- >>> b = 1, 1->^^^^^^^^ @@ -586,9 +618,9 @@ sourceFile:../second/second_part1.ts 1->, 2 > b 3 > -1->Emitted(36, 9) Source(28, 49) + SourceIndex(2) -2 >Emitted(36, 10) Source(28, 50) + SourceIndex(2) -3 >Emitted(36, 14) Source(28, 50) + SourceIndex(2) +1->Emitted(37, 9) Source(28, 49) + SourceIndex(2) +2 >Emitted(37, 10) Source(28, 50) + SourceIndex(2) +3 >Emitted(37, 14) Source(28, 50) + SourceIndex(2) --- >>> c = 2 1->^^^^^^^^ @@ -597,21 +629,21 @@ sourceFile:../second/second_part1.ts 1->, 2 > c 3 > -1->Emitted(37, 9) Source(28, 52) + SourceIndex(2) -2 >Emitted(37, 10) Source(28, 53) + SourceIndex(2) -3 >Emitted(37, 14) Source(28, 53) + SourceIndex(2) +1->Emitted(38, 9) Source(28, 52) + SourceIndex(2) +2 >Emitted(38, 10) Source(28, 53) + SourceIndex(2) +3 >Emitted(38, 14) Source(28, 53) + SourceIndex(2) --- >>> } 1 >^^^^^ 1 > } -1 >Emitted(38, 6) Source(28, 55) + SourceIndex(2) +1 >Emitted(39, 6) Source(28, 55) + SourceIndex(2) --- >>>} 1 >^ 2 > ^^^^^^^^^^^^^^^^^^^^^^^^^-> 1 > >} -1 >Emitted(39, 2) Source(29, 2) + SourceIndex(2) +1 >Emitted(40, 2) Source(29, 2) + SourceIndex(2) --- >>>declare class internalC { 1-> @@ -621,15 +653,15 @@ sourceFile:../second/second_part1.ts >/*@internal*/ 2 >class 3 > internalC -1->Emitted(40, 1) Source(30, 15) + SourceIndex(2) -2 >Emitted(40, 15) Source(30, 21) + SourceIndex(2) -3 >Emitted(40, 24) Source(30, 30) + SourceIndex(2) +1->Emitted(41, 1) Source(30, 15) + SourceIndex(2) +2 >Emitted(41, 15) Source(30, 21) + SourceIndex(2) +3 >Emitted(41, 24) Source(30, 30) + SourceIndex(2) --- >>>} 1 >^ 2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> 1 > {} -1 >Emitted(41, 2) Source(30, 33) + SourceIndex(2) +1 >Emitted(42, 2) Source(30, 33) + SourceIndex(2) --- >>>declare function internalfoo(): void; 1-> @@ -642,10 +674,10 @@ sourceFile:../second/second_part1.ts 2 >function 3 > internalfoo 4 > () {} -1->Emitted(42, 1) Source(31, 15) + SourceIndex(2) -2 >Emitted(42, 18) Source(31, 24) + SourceIndex(2) -3 >Emitted(42, 29) Source(31, 35) + SourceIndex(2) -4 >Emitted(42, 38) Source(31, 40) + SourceIndex(2) +1->Emitted(43, 1) Source(31, 15) + SourceIndex(2) +2 >Emitted(43, 18) Source(31, 24) + SourceIndex(2) +3 >Emitted(43, 29) Source(31, 35) + SourceIndex(2) +4 >Emitted(43, 38) Source(31, 40) + SourceIndex(2) --- >>>declare namespace internalNamespace { 1-> @@ -657,10 +689,10 @@ sourceFile:../second/second_part1.ts 2 >namespace 3 > internalNamespace 4 > -1->Emitted(43, 1) Source(32, 15) + SourceIndex(2) -2 >Emitted(43, 19) Source(32, 25) + SourceIndex(2) -3 >Emitted(43, 36) Source(32, 42) + SourceIndex(2) -4 >Emitted(43, 37) Source(32, 43) + SourceIndex(2) +1->Emitted(44, 1) Source(32, 15) + SourceIndex(2) +2 >Emitted(44, 19) Source(32, 25) + SourceIndex(2) +3 >Emitted(44, 36) Source(32, 42) + SourceIndex(2) +4 >Emitted(44, 37) Source(32, 43) + SourceIndex(2) --- >>> class someClass { 1 >^^^^ @@ -669,20 +701,20 @@ sourceFile:../second/second_part1.ts 1 >{ 2 > export class 3 > someClass -1 >Emitted(44, 5) Source(32, 45) + SourceIndex(2) -2 >Emitted(44, 11) Source(32, 58) + SourceIndex(2) -3 >Emitted(44, 20) Source(32, 67) + SourceIndex(2) +1 >Emitted(45, 5) Source(32, 45) + SourceIndex(2) +2 >Emitted(45, 11) Source(32, 58) + SourceIndex(2) +3 >Emitted(45, 20) Source(32, 67) + SourceIndex(2) --- >>> } 1 >^^^^^ 1 > {} -1 >Emitted(45, 6) Source(32, 70) + SourceIndex(2) +1 >Emitted(46, 6) Source(32, 70) + SourceIndex(2) --- >>>} 1 >^ 2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> 1 > } -1 >Emitted(46, 2) Source(32, 72) + SourceIndex(2) +1 >Emitted(47, 2) Source(32, 72) + SourceIndex(2) --- >>>declare namespace internalOther.something { 1-> @@ -698,12 +730,12 @@ sourceFile:../second/second_part1.ts 4 > . 5 > something 6 > -1->Emitted(47, 1) Source(33, 15) + SourceIndex(2) -2 >Emitted(47, 19) Source(33, 25) + SourceIndex(2) -3 >Emitted(47, 32) Source(33, 38) + SourceIndex(2) -4 >Emitted(47, 33) Source(33, 39) + SourceIndex(2) -5 >Emitted(47, 42) Source(33, 48) + SourceIndex(2) -6 >Emitted(47, 43) Source(33, 49) + SourceIndex(2) +1->Emitted(48, 1) Source(33, 15) + SourceIndex(2) +2 >Emitted(48, 19) Source(33, 25) + SourceIndex(2) +3 >Emitted(48, 32) Source(33, 38) + SourceIndex(2) +4 >Emitted(48, 33) Source(33, 39) + SourceIndex(2) +5 >Emitted(48, 42) Source(33, 48) + SourceIndex(2) +6 >Emitted(48, 43) Source(33, 49) + SourceIndex(2) --- >>> class someClass { 1 >^^^^ @@ -712,20 +744,20 @@ sourceFile:../second/second_part1.ts 1 >{ 2 > export class 3 > someClass -1 >Emitted(48, 5) Source(33, 51) + SourceIndex(2) -2 >Emitted(48, 11) Source(33, 64) + SourceIndex(2) -3 >Emitted(48, 20) Source(33, 73) + SourceIndex(2) +1 >Emitted(49, 5) Source(33, 51) + SourceIndex(2) +2 >Emitted(49, 11) Source(33, 64) + SourceIndex(2) +3 >Emitted(49, 20) Source(33, 73) + SourceIndex(2) --- >>> } 1 >^^^^^ 1 > {} -1 >Emitted(49, 6) Source(33, 76) + SourceIndex(2) +1 >Emitted(50, 6) Source(33, 76) + SourceIndex(2) --- >>>} 1 >^ 2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> 1 > } -1 >Emitted(50, 2) Source(33, 78) + SourceIndex(2) +1 >Emitted(51, 2) Source(33, 78) + SourceIndex(2) --- >>>import internalImport = internalNamespace.someClass; 1-> @@ -745,14 +777,14 @@ sourceFile:../second/second_part1.ts 6 > . 7 > someClass 8 > ; -1->Emitted(51, 1) Source(34, 15) + SourceIndex(2) -2 >Emitted(51, 8) Source(34, 22) + SourceIndex(2) -3 >Emitted(51, 22) Source(34, 36) + SourceIndex(2) -4 >Emitted(51, 25) Source(34, 39) + SourceIndex(2) -5 >Emitted(51, 42) Source(34, 56) + SourceIndex(2) -6 >Emitted(51, 43) Source(34, 57) + SourceIndex(2) -7 >Emitted(51, 52) Source(34, 66) + SourceIndex(2) -8 >Emitted(51, 53) Source(34, 67) + SourceIndex(2) +1->Emitted(52, 1) Source(34, 15) + SourceIndex(2) +2 >Emitted(52, 8) Source(34, 22) + SourceIndex(2) +3 >Emitted(52, 22) Source(34, 36) + SourceIndex(2) +4 >Emitted(52, 25) Source(34, 39) + SourceIndex(2) +5 >Emitted(52, 42) Source(34, 56) + SourceIndex(2) +6 >Emitted(52, 43) Source(34, 57) + SourceIndex(2) +7 >Emitted(52, 52) Source(34, 66) + SourceIndex(2) +8 >Emitted(52, 53) Source(34, 67) + SourceIndex(2) --- >>>declare type internalType = internalC; 1 > @@ -768,12 +800,12 @@ sourceFile:../second/second_part1.ts 4 > = 5 > internalC 6 > ; -1 >Emitted(52, 1) Source(35, 15) + SourceIndex(2) -2 >Emitted(52, 14) Source(35, 20) + SourceIndex(2) -3 >Emitted(52, 26) Source(35, 32) + SourceIndex(2) -4 >Emitted(52, 29) Source(35, 35) + SourceIndex(2) -5 >Emitted(52, 38) Source(35, 44) + SourceIndex(2) -6 >Emitted(52, 39) Source(35, 45) + SourceIndex(2) +1 >Emitted(53, 1) Source(35, 15) + SourceIndex(2) +2 >Emitted(53, 14) Source(35, 20) + SourceIndex(2) +3 >Emitted(53, 26) Source(35, 32) + SourceIndex(2) +4 >Emitted(53, 29) Source(35, 35) + SourceIndex(2) +5 >Emitted(53, 38) Source(35, 44) + SourceIndex(2) +6 >Emitted(53, 39) Source(35, 45) + SourceIndex(2) --- >>>declare const internalConst = 10; 1 > @@ -789,12 +821,12 @@ sourceFile:../second/second_part1.ts 4 > internalConst 5 > = 10 6 > ; -1 >Emitted(53, 1) Source(36, 15) + SourceIndex(2) -2 >Emitted(53, 9) Source(36, 15) + SourceIndex(2) -3 >Emitted(53, 15) Source(36, 21) + SourceIndex(2) -4 >Emitted(53, 28) Source(36, 34) + SourceIndex(2) -5 >Emitted(53, 33) Source(36, 39) + SourceIndex(2) -6 >Emitted(53, 34) Source(36, 40) + SourceIndex(2) +1 >Emitted(54, 1) Source(36, 15) + SourceIndex(2) +2 >Emitted(54, 9) Source(36, 15) + SourceIndex(2) +3 >Emitted(54, 15) Source(36, 21) + SourceIndex(2) +4 >Emitted(54, 28) Source(36, 34) + SourceIndex(2) +5 >Emitted(54, 33) Source(36, 39) + SourceIndex(2) +6 >Emitted(54, 34) Source(36, 40) + SourceIndex(2) --- >>>declare enum internalEnum { 1 > @@ -804,9 +836,9 @@ sourceFile:../second/second_part1.ts >/*@internal*/ 2 >enum 3 > internalEnum -1 >Emitted(54, 1) Source(37, 15) + SourceIndex(2) -2 >Emitted(54, 14) Source(37, 20) + SourceIndex(2) -3 >Emitted(54, 26) Source(37, 32) + SourceIndex(2) +1 >Emitted(55, 1) Source(37, 15) + SourceIndex(2) +2 >Emitted(55, 14) Source(37, 20) + SourceIndex(2) +3 >Emitted(55, 26) Source(37, 32) + SourceIndex(2) --- >>> a = 0, 1 >^^^^ @@ -816,9 +848,9 @@ sourceFile:../second/second_part1.ts 1 > { 2 > a 3 > -1 >Emitted(55, 5) Source(37, 35) + SourceIndex(2) -2 >Emitted(55, 6) Source(37, 36) + SourceIndex(2) -3 >Emitted(55, 10) Source(37, 36) + SourceIndex(2) +1 >Emitted(56, 5) Source(37, 35) + SourceIndex(2) +2 >Emitted(56, 6) Source(37, 36) + SourceIndex(2) +3 >Emitted(56, 10) Source(37, 36) + SourceIndex(2) --- >>> b = 1, 1->^^^^ @@ -828,9 +860,9 @@ sourceFile:../second/second_part1.ts 1->, 2 > b 3 > -1->Emitted(56, 5) Source(37, 38) + SourceIndex(2) -2 >Emitted(56, 6) Source(37, 39) + SourceIndex(2) -3 >Emitted(56, 10) Source(37, 39) + SourceIndex(2) +1->Emitted(57, 5) Source(37, 38) + SourceIndex(2) +2 >Emitted(57, 6) Source(37, 39) + SourceIndex(2) +3 >Emitted(57, 10) Source(37, 39) + SourceIndex(2) --- >>> c = 2 1->^^^^ @@ -839,15 +871,15 @@ sourceFile:../second/second_part1.ts 1->, 2 > c 3 > -1->Emitted(57, 5) Source(37, 41) + SourceIndex(2) -2 >Emitted(57, 6) Source(37, 42) + SourceIndex(2) -3 >Emitted(57, 10) Source(37, 42) + SourceIndex(2) +1->Emitted(58, 5) Source(37, 41) + SourceIndex(2) +2 >Emitted(58, 6) Source(37, 42) + SourceIndex(2) +3 >Emitted(58, 10) Source(37, 42) + SourceIndex(2) --- >>>} 1 >^ 2 > ^^^^^^^^^^^^^^^^^-> 1 > } -1 >Emitted(58, 2) Source(37, 44) + SourceIndex(2) +1 >Emitted(59, 2) Source(37, 44) + SourceIndex(2) --- ------------------------------------------------------------------- emittedFile:/src/2/second-output.d.ts @@ -861,9 +893,9 @@ sourceFile:../second/second_part2.ts 1-> 2 >class 3 > C -1->Emitted(59, 1) Source(1, 1) + SourceIndex(3) -2 >Emitted(59, 15) Source(1, 7) + SourceIndex(3) -3 >Emitted(59, 16) Source(1, 8) + SourceIndex(3) +1->Emitted(60, 1) Source(1, 1) + SourceIndex(3) +2 >Emitted(60, 15) Source(1, 7) + SourceIndex(3) +3 >Emitted(60, 16) Source(1, 8) + SourceIndex(3) --- >>> doSomething(): void; 1->^^^^ @@ -871,8 +903,8 @@ sourceFile:../second/second_part2.ts 1-> { > 2 > doSomething -1->Emitted(60, 5) Source(2, 5) + SourceIndex(3) -2 >Emitted(60, 16) Source(2, 16) + SourceIndex(3) +1->Emitted(61, 5) Source(2, 5) + SourceIndex(3) +2 >Emitted(61, 16) Source(2, 16) + SourceIndex(3) --- >>>} 1 >^ @@ -881,7 +913,7 @@ sourceFile:../second/second_part2.ts > console.log("something got done"); > } >} -1 >Emitted(61, 2) Source(5, 2) + SourceIndex(3) +1 >Emitted(62, 2) Source(5, 2) + SourceIndex(3) --- >>>//# sourceMappingURL=second-output.d.ts.map @@ -2637,32 +2669,32 @@ sourceFile:../second/second_part2.ts }, { "pos": 233, - "end": 307, + "end": 338, "kind": "internal" }, { - "pos": 309, - "end": 341, + "pos": 340, + "end": 372, "kind": "text" }, { - "pos": 341, - "end": 733, + "pos": 372, + "end": 764, "kind": "internal" }, { - "pos": 735, - "end": 738, + "pos": 766, + "end": 769, "kind": "text" }, { - "pos": 738, - "end": 1151, + "pos": 769, + "end": 1182, "kind": "internal" }, { - "pos": 1153, - "end": 1201, + "pos": 1184, + "end": 1232, "kind": "text" } ] @@ -2817,18 +2849,19 @@ declare namespace N { declare class normalC { ---------------------------------------------------------------------- -internal: (233-307) +internal: (233-338) constructor(); prop: string; method(): void; - c: number; + get c(): number; + set c(val: number); ---------------------------------------------------------------------- -text: (309-341) +text: (340-372) } declare namespace normalN { ---------------------------------------------------------------------- -internal: (341-733) +internal: (372-764) class C { } function foo(): void; @@ -2849,11 +2882,11 @@ internal: (341-733) c = 2 } ---------------------------------------------------------------------- -text: (735-738) +text: (766-769) } ---------------------------------------------------------------------- -internal: (738-1151) +internal: (769-1182) declare class internalC { } declare function internalfoo(): void; @@ -2874,7 +2907,7 @@ declare enum internalEnum { c = 2 } ---------------------------------------------------------------------- -text: (1153-1201) +text: (1184-1232) declare class C { doSomething(): void; } diff --git a/tests/baselines/reference/tsbuild/outfile-concat/incremental-declaration-doesnt-change/stripInternal-jsdoc-style-comment-when-one-two-three-are-prepended-in-order.js b/tests/baselines/reference/tsbuild/outfile-concat/incremental-declaration-doesnt-change/stripInternal-jsdoc-style-comment-when-one-two-three-are-prepended-in-order.js index 9c369db811c90..ac11658e2ca20 100644 --- a/tests/baselines/reference/tsbuild/outfile-concat/incremental-declaration-doesnt-change/stripInternal-jsdoc-style-comment-when-one-two-three-are-prepended-in-order.js +++ b/tests/baselines/reference/tsbuild/outfile-concat/incremental-declaration-doesnt-change/stripInternal-jsdoc-style-comment-when-one-two-three-are-prepended-in-order.js @@ -1805,32 +1805,32 @@ sourceFile:../second/second_part2.ts }, { "pos": 234, - "end": 308, + "end": 339, "kind": "internal" }, { - "pos": 310, - "end": 342, + "pos": 341, + "end": 373, "kind": "text" }, { - "pos": 342, - "end": 734, + "pos": 373, + "end": 765, "kind": "internal" }, { - "pos": 736, - "end": 739, + "pos": 767, + "end": 770, "kind": "text" }, { - "pos": 739, - "end": 1152, + "pos": 770, + "end": 1183, "kind": "internal" }, { - "pos": 1154, - "end": 1202, + "pos": 1185, + "end": 1233, "kind": "text" } ] @@ -1986,18 +1986,19 @@ declare namespace N { declare class normalC { ---------------------------------------------------------------------- -internal: (234-308) +internal: (234-339) constructor(); prop: string; method(): void; - c: number; + get c(): number; + set c(val: number); ---------------------------------------------------------------------- -text: (310-342) +text: (341-373) } declare namespace normalN { ---------------------------------------------------------------------- -internal: (342-734) +internal: (373-765) class C { } function foo(): void; @@ -2018,11 +2019,11 @@ internal: (342-734) c = 2 } ---------------------------------------------------------------------- -text: (736-739) +text: (767-770) } ---------------------------------------------------------------------- -internal: (739-1152) +internal: (770-1183) declare class internalC { } declare function internalfoo(): void; @@ -2043,7 +2044,7 @@ declare enum internalEnum { c = 2 } ---------------------------------------------------------------------- -text: (1154-1202) +text: (1185-1233) declare class C { doSomething(): void; } diff --git a/tests/baselines/reference/tsbuild/outfile-concat/incremental-declaration-doesnt-change/stripInternal-jsdoc-style-with-comments-emit-enabled-when-one-two-three-are-prepended-in-order.js b/tests/baselines/reference/tsbuild/outfile-concat/incremental-declaration-doesnt-change/stripInternal-jsdoc-style-with-comments-emit-enabled-when-one-two-three-are-prepended-in-order.js index b7ccf17985a32..957ed1cd9b102 100644 --- a/tests/baselines/reference/tsbuild/outfile-concat/incremental-declaration-doesnt-change/stripInternal-jsdoc-style-with-comments-emit-enabled-when-one-two-three-are-prepended-in-order.js +++ b/tests/baselines/reference/tsbuild/outfile-concat/incremental-declaration-doesnt-change/stripInternal-jsdoc-style-with-comments-emit-enabled-when-one-two-three-are-prepended-in-order.js @@ -1905,32 +1905,32 @@ sourceFile:../second/second_part2.ts }, { "pos": 249, - "end": 398, + "end": 429, "kind": "internal" }, { - "pos": 400, - "end": 432, + "pos": 431, + "end": 463, "kind": "text" }, { - "pos": 432, - "end": 944, + "pos": 463, + "end": 975, "kind": "internal" }, { - "pos": 946, - "end": 949, + "pos": 977, + "end": 980, "kind": "text" }, { - "pos": 949, - "end": 1482, + "pos": 980, + "end": 1513, "kind": "internal" }, { - "pos": 1484, - "end": 1532, + "pos": 1515, + "end": 1563, "kind": "text" } ] @@ -2086,18 +2086,19 @@ declare namespace N { declare class normalC { ---------------------------------------------------------------------- -internal: (249-398) +internal: (249-429) /**@internal*/ constructor(); /**@internal*/ prop: string; /**@internal*/ method(): void; - /**@internal*/ /**@internal*/ c: number; + /**@internal*/ get c(): number; + /**@internal*/ set c(val: number); ---------------------------------------------------------------------- -text: (400-432) +text: (431-463) } declare namespace normalN { ---------------------------------------------------------------------- -internal: (432-944) +internal: (463-975) /**@internal*/ class C { } /**@internal*/ function foo(): void; @@ -2118,11 +2119,11 @@ internal: (432-944) c = 2 } ---------------------------------------------------------------------- -text: (946-949) +text: (977-980) } ---------------------------------------------------------------------- -internal: (949-1482) +internal: (980-1513) /**@internal*/ declare class internalC { } /**@internal*/ declare function internalfoo(): void; @@ -2143,7 +2144,7 @@ internal: (949-1482) c = 2 } ---------------------------------------------------------------------- -text: (1484-1532) +text: (1515-1563) declare class C { doSomething(): void; } diff --git a/tests/baselines/reference/tsbuild/outfile-concat/incremental-declaration-doesnt-change/stripInternal-when-one-two-three-are-prepended-in-order.js b/tests/baselines/reference/tsbuild/outfile-concat/incremental-declaration-doesnt-change/stripInternal-when-one-two-three-are-prepended-in-order.js index e670e22aab643..512c530fffffc 100644 --- a/tests/baselines/reference/tsbuild/outfile-concat/incremental-declaration-doesnt-change/stripInternal-when-one-two-three-are-prepended-in-order.js +++ b/tests/baselines/reference/tsbuild/outfile-concat/incremental-declaration-doesnt-change/stripInternal-when-one-two-three-are-prepended-in-order.js @@ -1827,32 +1827,32 @@ sourceFile:../second/second_part2.ts }, { "pos": 234, - "end": 308, + "end": 339, "kind": "internal" }, { - "pos": 310, - "end": 342, + "pos": 341, + "end": 373, "kind": "text" }, { - "pos": 342, - "end": 734, + "pos": 373, + "end": 765, "kind": "internal" }, { - "pos": 736, - "end": 739, + "pos": 767, + "end": 770, "kind": "text" }, { - "pos": 739, - "end": 1152, + "pos": 770, + "end": 1183, "kind": "internal" }, { - "pos": 1154, - "end": 1202, + "pos": 1185, + "end": 1233, "kind": "text" } ] @@ -2008,18 +2008,19 @@ declare namespace N { declare class normalC { ---------------------------------------------------------------------- -internal: (234-308) +internal: (234-339) constructor(); prop: string; method(): void; - c: number; + get c(): number; + set c(val: number); ---------------------------------------------------------------------- -text: (310-342) +text: (341-373) } declare namespace normalN { ---------------------------------------------------------------------- -internal: (342-734) +internal: (373-765) class C { } function foo(): void; @@ -2040,11 +2041,11 @@ internal: (342-734) c = 2 } ---------------------------------------------------------------------- -text: (736-739) +text: (767-770) } ---------------------------------------------------------------------- -internal: (739-1152) +internal: (770-1183) declare class internalC { } declare function internalfoo(): void; @@ -2065,7 +2066,7 @@ declare enum internalEnum { c = 2 } ---------------------------------------------------------------------- -text: (1154-1202) +text: (1185-1233) declare class C { doSomething(): void; } diff --git a/tests/baselines/reference/tsbuild/outfile-concat/incremental-declaration-doesnt-change/stripInternal-with-comments-emit-enabled-when-one-two-three-are-prepended-in-order.js b/tests/baselines/reference/tsbuild/outfile-concat/incremental-declaration-doesnt-change/stripInternal-with-comments-emit-enabled-when-one-two-three-are-prepended-in-order.js index eb1f081ead5df..1eed13c834257 100644 --- a/tests/baselines/reference/tsbuild/outfile-concat/incremental-declaration-doesnt-change/stripInternal-with-comments-emit-enabled-when-one-two-three-are-prepended-in-order.js +++ b/tests/baselines/reference/tsbuild/outfile-concat/incremental-declaration-doesnt-change/stripInternal-with-comments-emit-enabled-when-one-two-three-are-prepended-in-order.js @@ -1905,32 +1905,32 @@ sourceFile:../second/second_part2.ts }, { "pos": 234, - "end": 322, + "end": 339, "kind": "internal" }, { - "pos": 324, - "end": 356, + "pos": 341, + "end": 373, "kind": "text" }, { - "pos": 356, - "end": 748, + "pos": 373, + "end": 765, "kind": "internal" }, { - "pos": 750, - "end": 753, + "pos": 767, + "end": 770, "kind": "text" }, { - "pos": 753, - "end": 1166, + "pos": 770, + "end": 1183, "kind": "internal" }, { - "pos": 1168, - "end": 1216, + "pos": 1185, + "end": 1233, "kind": "text" } ] @@ -2086,18 +2086,19 @@ declare namespace N { declare class normalC { ---------------------------------------------------------------------- -internal: (234-322) +internal: (234-339) constructor(); prop: string; method(): void; - /*@internal*/ c: number; + get c(): number; + set c(val: number); ---------------------------------------------------------------------- -text: (324-356) +text: (341-373) } declare namespace normalN { ---------------------------------------------------------------------- -internal: (356-748) +internal: (373-765) class C { } function foo(): void; @@ -2118,11 +2119,11 @@ internal: (356-748) c = 2 } ---------------------------------------------------------------------- -text: (750-753) +text: (767-770) } ---------------------------------------------------------------------- -internal: (753-1166) +internal: (770-1183) declare class internalC { } declare function internalfoo(): void; @@ -2143,7 +2144,7 @@ declare enum internalEnum { c = 2 } ---------------------------------------------------------------------- -text: (1168-1216) +text: (1185-1233) declare class C { doSomething(): void; } diff --git a/tests/baselines/reference/tsbuild/outfile-concat/incremental-headers-change-without-dts-changes/stripInternal-jsdoc-style-comment-when-one-two-three-are-prepended-in-order.js b/tests/baselines/reference/tsbuild/outfile-concat/incremental-headers-change-without-dts-changes/stripInternal-jsdoc-style-comment-when-one-two-three-are-prepended-in-order.js index c4c6dc7ab6db8..d1aac8b70e84b 100644 --- a/tests/baselines/reference/tsbuild/outfile-concat/incremental-headers-change-without-dts-changes/stripInternal-jsdoc-style-comment-when-one-two-three-are-prepended-in-order.js +++ b/tests/baselines/reference/tsbuild/outfile-concat/incremental-headers-change-without-dts-changes/stripInternal-jsdoc-style-comment-when-one-two-three-are-prepended-in-order.js @@ -25,7 +25,7 @@ exitCode:: 0 //// [/src/2/second-output.d.ts.map] -{"version":3,"file":"second-output.d.ts","sourceRoot":"","sources":["../first/first_PART1.ts","../first/first_part3.ts","../second/second_part1.ts","../second/second_part2.ts"],"names":[],"mappings":"AAAA,UAAU,QAAQ;IACd,IAAI,EAAE,GAAG,CAAC;CACb;AAED,QAAA,MAAM,CAAC,iBAAiB,CAAC;AAEzB,UAAU,iBAAiB;IACvB,IAAI,EAAE,GAAG,CAAC;CACb;ACRD,iBAAS,CAAC,WAET;ACFD,kBAAU,CAAC,CAAC;CAEX;AAED,kBAAU,CAAC,CAAC;CAMX;AAED,cAAM,OAAO;;IAEM,IAAI,EAAE,MAAM,CAAC;IACb,MAAM;IACF,CAAC,EACM,MAAM;CACnC;AACD,kBAAU,OAAO,CAAC;IACC,MAAa,CAAC;KAAI;IAClB,SAAgB,GAAG,SAAK;IACxB,UAAiB,aAAa,CAAC;QAAE,MAAa,CAAC;SAAG;KAAE;IACpD,UAAiB,SAAS,CAAC,SAAS,CAAC;QAAE,MAAa,SAAS;SAAG;KAAE;IAClE,MAAM,QAAQ,UAAU,GAAG,aAAa,CAAC,CAAC,CAAC;IAC3C,KAAY,YAAY,GAAG,SAAS,CAAC;IAC9B,MAAM,aAAa,KAAK,CAAC;IAChC,KAAY,YAAY;QAAG,CAAC,IAAA;QAAE,CAAC,IAAA;QAAE,CAAC,IAAA;KAAE;CACtD;AACc,cAAM,SAAS;CAAG;AAClB,iBAAS,WAAW,SAAK;AACzB,kBAAU,iBAAiB,CAAC;IAAE,MAAa,SAAS;KAAG;CAAE;AACzD,kBAAU,aAAa,CAAC,SAAS,CAAC;IAAE,MAAa,SAAS;KAAG;CAAE;AAC/D,OAAO,cAAc,GAAG,iBAAiB,CAAC,SAAS,CAAC;AACpD,aAAK,YAAY,GAAG,SAAS,CAAC;AAC9B,QAAA,MAAM,aAAa,KAAK,CAAC;AACzB,aAAK,YAAY;IAAG,CAAC,IAAA;IAAE,CAAC,IAAA;IAAE,CAAC,IAAA;CAAE;ACpC5C,cAAM,CAAC;IACH,WAAW;CAGd"} +{"version":3,"file":"second-output.d.ts","sourceRoot":"","sources":["../first/first_PART1.ts","../first/first_part3.ts","../second/second_part1.ts","../second/second_part2.ts"],"names":[],"mappings":"AAAA,UAAU,QAAQ;IACd,IAAI,EAAE,GAAG,CAAC;CACb;AAED,QAAA,MAAM,CAAC,iBAAiB,CAAC;AAEzB,UAAU,iBAAiB;IACvB,IAAI,EAAE,GAAG,CAAC;CACb;ACRD,iBAAS,CAAC,WAET;ACFD,kBAAU,CAAC,CAAC;CAEX;AAED,kBAAU,CAAC,CAAC;CAMX;AAED,cAAM,OAAO;;IAEM,IAAI,EAAE,MAAM,CAAC;IACb,MAAM;IACN,IAAI,CAAC,IACM,MAAM,CADK;IACtB,IAAI,CAAC,CAAC,KAAK,MAAM,EAAK;CACxC;AACD,kBAAU,OAAO,CAAC;IACC,MAAa,CAAC;KAAI;IAClB,SAAgB,GAAG,SAAK;IACxB,UAAiB,aAAa,CAAC;QAAE,MAAa,CAAC;SAAG;KAAE;IACpD,UAAiB,SAAS,CAAC,SAAS,CAAC;QAAE,MAAa,SAAS;SAAG;KAAE;IAClE,MAAM,QAAQ,UAAU,GAAG,aAAa,CAAC,CAAC,CAAC;IAC3C,KAAY,YAAY,GAAG,SAAS,CAAC;IAC9B,MAAM,aAAa,KAAK,CAAC;IAChC,KAAY,YAAY;QAAG,CAAC,IAAA;QAAE,CAAC,IAAA;QAAE,CAAC,IAAA;KAAE;CACtD;AACc,cAAM,SAAS;CAAG;AAClB,iBAAS,WAAW,SAAK;AACzB,kBAAU,iBAAiB,CAAC;IAAE,MAAa,SAAS;KAAG;CAAE;AACzD,kBAAU,aAAa,CAAC,SAAS,CAAC;IAAE,MAAa,SAAS;KAAG;CAAE;AAC/D,OAAO,cAAc,GAAG,iBAAiB,CAAC,SAAS,CAAC;AACpD,aAAK,YAAY,GAAG,SAAS,CAAC;AAC9B,QAAA,MAAM,aAAa,KAAK,CAAC;AACzB,aAAK,YAAY;IAAG,CAAC,IAAA;IAAE,CAAC,IAAA;IAAE,CAAC,IAAA;CAAE;ACpC5C,cAAM,CAAC;IACH,WAAW;CAGd"} //// [/src/2/second-output.d.ts.map.baseline.txt] =================================================================== @@ -245,35 +245,66 @@ sourceFile:../second/second_part1.ts >>> method(): void; 1->^^^^ 2 > ^^^^^^ -3 > ^^^^^-> +3 > ^^^^^^^^^^^-> 1-> > /**@internal*/ 2 > method 1->Emitted(16, 5) Source(16, 20) + SourceIndex(2) 2 >Emitted(16, 11) Source(16, 26) + SourceIndex(2) --- ->>> c: number; +>>> get c(): number; 1->^^^^ -2 > ^ -3 > ^^ -4 > ^^^^^^ +2 > ^^^^ +3 > ^ +4 > ^^^^ +5 > ^^^^^^ +6 > ^ +7 > ^^^^-> 1->() { } - > /**@internal*/ get -2 > c -3 > () { return 10; } - > /**@internal*/ set c(val: -4 > number -1->Emitted(17, 5) Source(17, 24) + SourceIndex(2) -2 >Emitted(17, 6) Source(17, 25) + SourceIndex(2) -3 >Emitted(17, 8) Source(18, 31) + SourceIndex(2) -4 >Emitted(17, 14) Source(18, 37) + SourceIndex(2) + > /**@internal*/ +2 > get +3 > c +4 > () { return 10; } + > /**@internal*/ set c(val: +5 > number +6 > +1->Emitted(17, 5) Source(17, 20) + SourceIndex(2) +2 >Emitted(17, 9) Source(17, 24) + SourceIndex(2) +3 >Emitted(17, 10) Source(17, 25) + SourceIndex(2) +4 >Emitted(17, 14) Source(18, 31) + SourceIndex(2) +5 >Emitted(17, 20) Source(18, 37) + SourceIndex(2) +6 >Emitted(17, 21) Source(17, 42) + SourceIndex(2) +--- +>>> set c(val: number); +1->^^^^ +2 > ^^^^ +3 > ^ +4 > ^ +5 > ^^^^^ +6 > ^^^^^^ +7 > ^^ +1-> + > /**@internal*/ +2 > set +3 > c +4 > ( +5 > val: +6 > number +7 > ) { } +1->Emitted(18, 5) Source(18, 20) + SourceIndex(2) +2 >Emitted(18, 9) Source(18, 24) + SourceIndex(2) +3 >Emitted(18, 10) Source(18, 25) + SourceIndex(2) +4 >Emitted(18, 11) Source(18, 26) + SourceIndex(2) +5 >Emitted(18, 16) Source(18, 31) + SourceIndex(2) +6 >Emitted(18, 22) Source(18, 37) + SourceIndex(2) +7 >Emitted(18, 24) Source(18, 42) + SourceIndex(2) --- >>>} 1 >^ 2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1 >) { } +1 > >} -1 >Emitted(18, 2) Source(19, 2) + SourceIndex(2) +1 >Emitted(19, 2) Source(19, 2) + SourceIndex(2) --- >>>declare namespace normalN { 1-> @@ -285,10 +316,10 @@ sourceFile:../second/second_part1.ts 2 >namespace 3 > normalN 4 > -1->Emitted(19, 1) Source(20, 1) + SourceIndex(2) -2 >Emitted(19, 19) Source(20, 11) + SourceIndex(2) -3 >Emitted(19, 26) Source(20, 18) + SourceIndex(2) -4 >Emitted(19, 27) Source(20, 19) + SourceIndex(2) +1->Emitted(20, 1) Source(20, 1) + SourceIndex(2) +2 >Emitted(20, 19) Source(20, 11) + SourceIndex(2) +3 >Emitted(20, 26) Source(20, 18) + SourceIndex(2) +4 >Emitted(20, 27) Source(20, 19) + SourceIndex(2) --- >>> class C { 1 >^^^^ @@ -298,15 +329,15 @@ sourceFile:../second/second_part1.ts > /**@internal*/ 2 > export class 3 > C -1 >Emitted(20, 5) Source(21, 20) + SourceIndex(2) -2 >Emitted(20, 11) Source(21, 33) + SourceIndex(2) -3 >Emitted(20, 12) Source(21, 34) + SourceIndex(2) +1 >Emitted(21, 5) Source(21, 20) + SourceIndex(2) +2 >Emitted(21, 11) Source(21, 33) + SourceIndex(2) +3 >Emitted(21, 12) Source(21, 34) + SourceIndex(2) --- >>> } 1 >^^^^^ 2 > ^^^^^^^^^^^^^^^^^^^^^-> 1 > { } -1 >Emitted(21, 6) Source(21, 38) + SourceIndex(2) +1 >Emitted(22, 6) Source(21, 38) + SourceIndex(2) --- >>> function foo(): void; 1->^^^^ @@ -319,10 +350,10 @@ sourceFile:../second/second_part1.ts 2 > export function 3 > foo 4 > () {} -1->Emitted(22, 5) Source(22, 20) + SourceIndex(2) -2 >Emitted(22, 14) Source(22, 36) + SourceIndex(2) -3 >Emitted(22, 17) Source(22, 39) + SourceIndex(2) -4 >Emitted(22, 26) Source(22, 44) + SourceIndex(2) +1->Emitted(23, 5) Source(22, 20) + SourceIndex(2) +2 >Emitted(23, 14) Source(22, 36) + SourceIndex(2) +3 >Emitted(23, 17) Source(22, 39) + SourceIndex(2) +4 >Emitted(23, 26) Source(22, 44) + SourceIndex(2) --- >>> namespace someNamespace { 1->^^^^ @@ -334,10 +365,10 @@ sourceFile:../second/second_part1.ts 2 > export namespace 3 > someNamespace 4 > -1->Emitted(23, 5) Source(23, 20) + SourceIndex(2) -2 >Emitted(23, 15) Source(23, 37) + SourceIndex(2) -3 >Emitted(23, 28) Source(23, 50) + SourceIndex(2) -4 >Emitted(23, 29) Source(23, 51) + SourceIndex(2) +1->Emitted(24, 5) Source(23, 20) + SourceIndex(2) +2 >Emitted(24, 15) Source(23, 37) + SourceIndex(2) +3 >Emitted(24, 28) Source(23, 50) + SourceIndex(2) +4 >Emitted(24, 29) Source(23, 51) + SourceIndex(2) --- >>> class C { 1 >^^^^^^^^ @@ -346,20 +377,20 @@ sourceFile:../second/second_part1.ts 1 >{ 2 > export class 3 > C -1 >Emitted(24, 9) Source(23, 53) + SourceIndex(2) -2 >Emitted(24, 15) Source(23, 66) + SourceIndex(2) -3 >Emitted(24, 16) Source(23, 67) + SourceIndex(2) +1 >Emitted(25, 9) Source(23, 53) + SourceIndex(2) +2 >Emitted(25, 15) Source(23, 66) + SourceIndex(2) +3 >Emitted(25, 16) Source(23, 67) + SourceIndex(2) --- >>> } 1 >^^^^^^^^^ 1 > {} -1 >Emitted(25, 10) Source(23, 70) + SourceIndex(2) +1 >Emitted(26, 10) Source(23, 70) + SourceIndex(2) --- >>> } 1 >^^^^^ 2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> 1 > } -1 >Emitted(26, 6) Source(23, 72) + SourceIndex(2) +1 >Emitted(27, 6) Source(23, 72) + SourceIndex(2) --- >>> namespace someOther.something { 1->^^^^ @@ -375,12 +406,12 @@ sourceFile:../second/second_part1.ts 4 > . 5 > something 6 > -1->Emitted(27, 5) Source(24, 20) + SourceIndex(2) -2 >Emitted(27, 15) Source(24, 37) + SourceIndex(2) -3 >Emitted(27, 24) Source(24, 46) + SourceIndex(2) -4 >Emitted(27, 25) Source(24, 47) + SourceIndex(2) -5 >Emitted(27, 34) Source(24, 56) + SourceIndex(2) -6 >Emitted(27, 35) Source(24, 57) + SourceIndex(2) +1->Emitted(28, 5) Source(24, 20) + SourceIndex(2) +2 >Emitted(28, 15) Source(24, 37) + SourceIndex(2) +3 >Emitted(28, 24) Source(24, 46) + SourceIndex(2) +4 >Emitted(28, 25) Source(24, 47) + SourceIndex(2) +5 >Emitted(28, 34) Source(24, 56) + SourceIndex(2) +6 >Emitted(28, 35) Source(24, 57) + SourceIndex(2) --- >>> class someClass { 1 >^^^^^^^^ @@ -389,20 +420,20 @@ sourceFile:../second/second_part1.ts 1 >{ 2 > export class 3 > someClass -1 >Emitted(28, 9) Source(24, 59) + SourceIndex(2) -2 >Emitted(28, 15) Source(24, 72) + SourceIndex(2) -3 >Emitted(28, 24) Source(24, 81) + SourceIndex(2) +1 >Emitted(29, 9) Source(24, 59) + SourceIndex(2) +2 >Emitted(29, 15) Source(24, 72) + SourceIndex(2) +3 >Emitted(29, 24) Source(24, 81) + SourceIndex(2) --- >>> } 1 >^^^^^^^^^ 1 > {} -1 >Emitted(29, 10) Source(24, 84) + SourceIndex(2) +1 >Emitted(30, 10) Source(24, 84) + SourceIndex(2) --- >>> } 1 >^^^^^ 2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> 1 > } -1 >Emitted(30, 6) Source(24, 86) + SourceIndex(2) +1 >Emitted(31, 6) Source(24, 86) + SourceIndex(2) --- >>> export import someImport = someNamespace.C; 1->^^^^ @@ -424,15 +455,15 @@ sourceFile:../second/second_part1.ts 7 > . 8 > C 9 > ; -1->Emitted(31, 5) Source(25, 20) + SourceIndex(2) -2 >Emitted(31, 11) Source(25, 26) + SourceIndex(2) -3 >Emitted(31, 19) Source(25, 34) + SourceIndex(2) -4 >Emitted(31, 29) Source(25, 44) + SourceIndex(2) -5 >Emitted(31, 32) Source(25, 47) + SourceIndex(2) -6 >Emitted(31, 45) Source(25, 60) + SourceIndex(2) -7 >Emitted(31, 46) Source(25, 61) + SourceIndex(2) -8 >Emitted(31, 47) Source(25, 62) + SourceIndex(2) -9 >Emitted(31, 48) Source(25, 63) + SourceIndex(2) +1->Emitted(32, 5) Source(25, 20) + SourceIndex(2) +2 >Emitted(32, 11) Source(25, 26) + SourceIndex(2) +3 >Emitted(32, 19) Source(25, 34) + SourceIndex(2) +4 >Emitted(32, 29) Source(25, 44) + SourceIndex(2) +5 >Emitted(32, 32) Source(25, 47) + SourceIndex(2) +6 >Emitted(32, 45) Source(25, 60) + SourceIndex(2) +7 >Emitted(32, 46) Source(25, 61) + SourceIndex(2) +8 >Emitted(32, 47) Source(25, 62) + SourceIndex(2) +9 >Emitted(32, 48) Source(25, 63) + SourceIndex(2) --- >>> type internalType = internalC; 1 >^^^^ @@ -448,12 +479,12 @@ sourceFile:../second/second_part1.ts 4 > = 5 > internalC 6 > ; -1 >Emitted(32, 5) Source(26, 20) + SourceIndex(2) -2 >Emitted(32, 10) Source(26, 32) + SourceIndex(2) -3 >Emitted(32, 22) Source(26, 44) + SourceIndex(2) -4 >Emitted(32, 25) Source(26, 47) + SourceIndex(2) -5 >Emitted(32, 34) Source(26, 56) + SourceIndex(2) -6 >Emitted(32, 35) Source(26, 57) + SourceIndex(2) +1 >Emitted(33, 5) Source(26, 20) + SourceIndex(2) +2 >Emitted(33, 10) Source(26, 32) + SourceIndex(2) +3 >Emitted(33, 22) Source(26, 44) + SourceIndex(2) +4 >Emitted(33, 25) Source(26, 47) + SourceIndex(2) +5 >Emitted(33, 34) Source(26, 56) + SourceIndex(2) +6 >Emitted(33, 35) Source(26, 57) + SourceIndex(2) --- >>> const internalConst = 10; 1 >^^^^ @@ -467,11 +498,11 @@ sourceFile:../second/second_part1.ts 3 > internalConst 4 > = 10 5 > ; -1 >Emitted(33, 5) Source(27, 27) + SourceIndex(2) -2 >Emitted(33, 11) Source(27, 33) + SourceIndex(2) -3 >Emitted(33, 24) Source(27, 46) + SourceIndex(2) -4 >Emitted(33, 29) Source(27, 51) + SourceIndex(2) -5 >Emitted(33, 30) Source(27, 52) + SourceIndex(2) +1 >Emitted(34, 5) Source(27, 27) + SourceIndex(2) +2 >Emitted(34, 11) Source(27, 33) + SourceIndex(2) +3 >Emitted(34, 24) Source(27, 46) + SourceIndex(2) +4 >Emitted(34, 29) Source(27, 51) + SourceIndex(2) +5 >Emitted(34, 30) Source(27, 52) + SourceIndex(2) --- >>> enum internalEnum { 1 >^^^^ @@ -481,9 +512,9 @@ sourceFile:../second/second_part1.ts > /**@internal*/ 2 > export enum 3 > internalEnum -1 >Emitted(34, 5) Source(28, 20) + SourceIndex(2) -2 >Emitted(34, 10) Source(28, 32) + SourceIndex(2) -3 >Emitted(34, 22) Source(28, 44) + SourceIndex(2) +1 >Emitted(35, 5) Source(28, 20) + SourceIndex(2) +2 >Emitted(35, 10) Source(28, 32) + SourceIndex(2) +3 >Emitted(35, 22) Source(28, 44) + SourceIndex(2) --- >>> a = 0, 1 >^^^^^^^^ @@ -493,9 +524,9 @@ sourceFile:../second/second_part1.ts 1 > { 2 > a 3 > -1 >Emitted(35, 9) Source(28, 47) + SourceIndex(2) -2 >Emitted(35, 10) Source(28, 48) + SourceIndex(2) -3 >Emitted(35, 14) Source(28, 48) + SourceIndex(2) +1 >Emitted(36, 9) Source(28, 47) + SourceIndex(2) +2 >Emitted(36, 10) Source(28, 48) + SourceIndex(2) +3 >Emitted(36, 14) Source(28, 48) + SourceIndex(2) --- >>> b = 1, 1->^^^^^^^^ @@ -505,9 +536,9 @@ sourceFile:../second/second_part1.ts 1->, 2 > b 3 > -1->Emitted(36, 9) Source(28, 50) + SourceIndex(2) -2 >Emitted(36, 10) Source(28, 51) + SourceIndex(2) -3 >Emitted(36, 14) Source(28, 51) + SourceIndex(2) +1->Emitted(37, 9) Source(28, 50) + SourceIndex(2) +2 >Emitted(37, 10) Source(28, 51) + SourceIndex(2) +3 >Emitted(37, 14) Source(28, 51) + SourceIndex(2) --- >>> c = 2 1->^^^^^^^^ @@ -516,21 +547,21 @@ sourceFile:../second/second_part1.ts 1->, 2 > c 3 > -1->Emitted(37, 9) Source(28, 53) + SourceIndex(2) -2 >Emitted(37, 10) Source(28, 54) + SourceIndex(2) -3 >Emitted(37, 14) Source(28, 54) + SourceIndex(2) +1->Emitted(38, 9) Source(28, 53) + SourceIndex(2) +2 >Emitted(38, 10) Source(28, 54) + SourceIndex(2) +3 >Emitted(38, 14) Source(28, 54) + SourceIndex(2) --- >>> } 1 >^^^^^ 1 > } -1 >Emitted(38, 6) Source(28, 56) + SourceIndex(2) +1 >Emitted(39, 6) Source(28, 56) + SourceIndex(2) --- >>>} 1 >^ 2 > ^^^^^^^^^^^^^^^^^^^^^^^^^-> 1 > >} -1 >Emitted(39, 2) Source(29, 2) + SourceIndex(2) +1 >Emitted(40, 2) Source(29, 2) + SourceIndex(2) --- >>>declare class internalC { 1-> @@ -540,15 +571,15 @@ sourceFile:../second/second_part1.ts >/**@internal*/ 2 >class 3 > internalC -1->Emitted(40, 1) Source(30, 16) + SourceIndex(2) -2 >Emitted(40, 15) Source(30, 22) + SourceIndex(2) -3 >Emitted(40, 24) Source(30, 31) + SourceIndex(2) +1->Emitted(41, 1) Source(30, 16) + SourceIndex(2) +2 >Emitted(41, 15) Source(30, 22) + SourceIndex(2) +3 >Emitted(41, 24) Source(30, 31) + SourceIndex(2) --- >>>} 1 >^ 2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> 1 > {} -1 >Emitted(41, 2) Source(30, 34) + SourceIndex(2) +1 >Emitted(42, 2) Source(30, 34) + SourceIndex(2) --- >>>declare function internalfoo(): void; 1-> @@ -561,10 +592,10 @@ sourceFile:../second/second_part1.ts 2 >function 3 > internalfoo 4 > () {} -1->Emitted(42, 1) Source(31, 16) + SourceIndex(2) -2 >Emitted(42, 18) Source(31, 25) + SourceIndex(2) -3 >Emitted(42, 29) Source(31, 36) + SourceIndex(2) -4 >Emitted(42, 38) Source(31, 41) + SourceIndex(2) +1->Emitted(43, 1) Source(31, 16) + SourceIndex(2) +2 >Emitted(43, 18) Source(31, 25) + SourceIndex(2) +3 >Emitted(43, 29) Source(31, 36) + SourceIndex(2) +4 >Emitted(43, 38) Source(31, 41) + SourceIndex(2) --- >>>declare namespace internalNamespace { 1-> @@ -576,10 +607,10 @@ sourceFile:../second/second_part1.ts 2 >namespace 3 > internalNamespace 4 > -1->Emitted(43, 1) Source(32, 16) + SourceIndex(2) -2 >Emitted(43, 19) Source(32, 26) + SourceIndex(2) -3 >Emitted(43, 36) Source(32, 43) + SourceIndex(2) -4 >Emitted(43, 37) Source(32, 44) + SourceIndex(2) +1->Emitted(44, 1) Source(32, 16) + SourceIndex(2) +2 >Emitted(44, 19) Source(32, 26) + SourceIndex(2) +3 >Emitted(44, 36) Source(32, 43) + SourceIndex(2) +4 >Emitted(44, 37) Source(32, 44) + SourceIndex(2) --- >>> class someClass { 1 >^^^^ @@ -588,20 +619,20 @@ sourceFile:../second/second_part1.ts 1 >{ 2 > export class 3 > someClass -1 >Emitted(44, 5) Source(32, 46) + SourceIndex(2) -2 >Emitted(44, 11) Source(32, 59) + SourceIndex(2) -3 >Emitted(44, 20) Source(32, 68) + SourceIndex(2) +1 >Emitted(45, 5) Source(32, 46) + SourceIndex(2) +2 >Emitted(45, 11) Source(32, 59) + SourceIndex(2) +3 >Emitted(45, 20) Source(32, 68) + SourceIndex(2) --- >>> } 1 >^^^^^ 1 > {} -1 >Emitted(45, 6) Source(32, 71) + SourceIndex(2) +1 >Emitted(46, 6) Source(32, 71) + SourceIndex(2) --- >>>} 1 >^ 2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> 1 > } -1 >Emitted(46, 2) Source(32, 73) + SourceIndex(2) +1 >Emitted(47, 2) Source(32, 73) + SourceIndex(2) --- >>>declare namespace internalOther.something { 1-> @@ -617,12 +648,12 @@ sourceFile:../second/second_part1.ts 4 > . 5 > something 6 > -1->Emitted(47, 1) Source(33, 16) + SourceIndex(2) -2 >Emitted(47, 19) Source(33, 26) + SourceIndex(2) -3 >Emitted(47, 32) Source(33, 39) + SourceIndex(2) -4 >Emitted(47, 33) Source(33, 40) + SourceIndex(2) -5 >Emitted(47, 42) Source(33, 49) + SourceIndex(2) -6 >Emitted(47, 43) Source(33, 50) + SourceIndex(2) +1->Emitted(48, 1) Source(33, 16) + SourceIndex(2) +2 >Emitted(48, 19) Source(33, 26) + SourceIndex(2) +3 >Emitted(48, 32) Source(33, 39) + SourceIndex(2) +4 >Emitted(48, 33) Source(33, 40) + SourceIndex(2) +5 >Emitted(48, 42) Source(33, 49) + SourceIndex(2) +6 >Emitted(48, 43) Source(33, 50) + SourceIndex(2) --- >>> class someClass { 1 >^^^^ @@ -631,20 +662,20 @@ sourceFile:../second/second_part1.ts 1 >{ 2 > export class 3 > someClass -1 >Emitted(48, 5) Source(33, 52) + SourceIndex(2) -2 >Emitted(48, 11) Source(33, 65) + SourceIndex(2) -3 >Emitted(48, 20) Source(33, 74) + SourceIndex(2) +1 >Emitted(49, 5) Source(33, 52) + SourceIndex(2) +2 >Emitted(49, 11) Source(33, 65) + SourceIndex(2) +3 >Emitted(49, 20) Source(33, 74) + SourceIndex(2) --- >>> } 1 >^^^^^ 1 > {} -1 >Emitted(49, 6) Source(33, 77) + SourceIndex(2) +1 >Emitted(50, 6) Source(33, 77) + SourceIndex(2) --- >>>} 1 >^ 2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> 1 > } -1 >Emitted(50, 2) Source(33, 79) + SourceIndex(2) +1 >Emitted(51, 2) Source(33, 79) + SourceIndex(2) --- >>>import internalImport = internalNamespace.someClass; 1-> @@ -664,14 +695,14 @@ sourceFile:../second/second_part1.ts 6 > . 7 > someClass 8 > ; -1->Emitted(51, 1) Source(34, 16) + SourceIndex(2) -2 >Emitted(51, 8) Source(34, 23) + SourceIndex(2) -3 >Emitted(51, 22) Source(34, 37) + SourceIndex(2) -4 >Emitted(51, 25) Source(34, 40) + SourceIndex(2) -5 >Emitted(51, 42) Source(34, 57) + SourceIndex(2) -6 >Emitted(51, 43) Source(34, 58) + SourceIndex(2) -7 >Emitted(51, 52) Source(34, 67) + SourceIndex(2) -8 >Emitted(51, 53) Source(34, 68) + SourceIndex(2) +1->Emitted(52, 1) Source(34, 16) + SourceIndex(2) +2 >Emitted(52, 8) Source(34, 23) + SourceIndex(2) +3 >Emitted(52, 22) Source(34, 37) + SourceIndex(2) +4 >Emitted(52, 25) Source(34, 40) + SourceIndex(2) +5 >Emitted(52, 42) Source(34, 57) + SourceIndex(2) +6 >Emitted(52, 43) Source(34, 58) + SourceIndex(2) +7 >Emitted(52, 52) Source(34, 67) + SourceIndex(2) +8 >Emitted(52, 53) Source(34, 68) + SourceIndex(2) --- >>>declare type internalType = internalC; 1 > @@ -687,12 +718,12 @@ sourceFile:../second/second_part1.ts 4 > = 5 > internalC 6 > ; -1 >Emitted(52, 1) Source(35, 16) + SourceIndex(2) -2 >Emitted(52, 14) Source(35, 21) + SourceIndex(2) -3 >Emitted(52, 26) Source(35, 33) + SourceIndex(2) -4 >Emitted(52, 29) Source(35, 36) + SourceIndex(2) -5 >Emitted(52, 38) Source(35, 45) + SourceIndex(2) -6 >Emitted(52, 39) Source(35, 46) + SourceIndex(2) +1 >Emitted(53, 1) Source(35, 16) + SourceIndex(2) +2 >Emitted(53, 14) Source(35, 21) + SourceIndex(2) +3 >Emitted(53, 26) Source(35, 33) + SourceIndex(2) +4 >Emitted(53, 29) Source(35, 36) + SourceIndex(2) +5 >Emitted(53, 38) Source(35, 45) + SourceIndex(2) +6 >Emitted(53, 39) Source(35, 46) + SourceIndex(2) --- >>>declare const internalConst = 10; 1 > @@ -708,12 +739,12 @@ sourceFile:../second/second_part1.ts 4 > internalConst 5 > = 10 6 > ; -1 >Emitted(53, 1) Source(36, 16) + SourceIndex(2) -2 >Emitted(53, 9) Source(36, 16) + SourceIndex(2) -3 >Emitted(53, 15) Source(36, 22) + SourceIndex(2) -4 >Emitted(53, 28) Source(36, 35) + SourceIndex(2) -5 >Emitted(53, 33) Source(36, 40) + SourceIndex(2) -6 >Emitted(53, 34) Source(36, 41) + SourceIndex(2) +1 >Emitted(54, 1) Source(36, 16) + SourceIndex(2) +2 >Emitted(54, 9) Source(36, 16) + SourceIndex(2) +3 >Emitted(54, 15) Source(36, 22) + SourceIndex(2) +4 >Emitted(54, 28) Source(36, 35) + SourceIndex(2) +5 >Emitted(54, 33) Source(36, 40) + SourceIndex(2) +6 >Emitted(54, 34) Source(36, 41) + SourceIndex(2) --- >>>declare enum internalEnum { 1 > @@ -723,9 +754,9 @@ sourceFile:../second/second_part1.ts >/**@internal*/ 2 >enum 3 > internalEnum -1 >Emitted(54, 1) Source(37, 16) + SourceIndex(2) -2 >Emitted(54, 14) Source(37, 21) + SourceIndex(2) -3 >Emitted(54, 26) Source(37, 33) + SourceIndex(2) +1 >Emitted(55, 1) Source(37, 16) + SourceIndex(2) +2 >Emitted(55, 14) Source(37, 21) + SourceIndex(2) +3 >Emitted(55, 26) Source(37, 33) + SourceIndex(2) --- >>> a = 0, 1 >^^^^ @@ -735,9 +766,9 @@ sourceFile:../second/second_part1.ts 1 > { 2 > a 3 > -1 >Emitted(55, 5) Source(37, 36) + SourceIndex(2) -2 >Emitted(55, 6) Source(37, 37) + SourceIndex(2) -3 >Emitted(55, 10) Source(37, 37) + SourceIndex(2) +1 >Emitted(56, 5) Source(37, 36) + SourceIndex(2) +2 >Emitted(56, 6) Source(37, 37) + SourceIndex(2) +3 >Emitted(56, 10) Source(37, 37) + SourceIndex(2) --- >>> b = 1, 1->^^^^ @@ -747,9 +778,9 @@ sourceFile:../second/second_part1.ts 1->, 2 > b 3 > -1->Emitted(56, 5) Source(37, 39) + SourceIndex(2) -2 >Emitted(56, 6) Source(37, 40) + SourceIndex(2) -3 >Emitted(56, 10) Source(37, 40) + SourceIndex(2) +1->Emitted(57, 5) Source(37, 39) + SourceIndex(2) +2 >Emitted(57, 6) Source(37, 40) + SourceIndex(2) +3 >Emitted(57, 10) Source(37, 40) + SourceIndex(2) --- >>> c = 2 1->^^^^ @@ -758,15 +789,15 @@ sourceFile:../second/second_part1.ts 1->, 2 > c 3 > -1->Emitted(57, 5) Source(37, 42) + SourceIndex(2) -2 >Emitted(57, 6) Source(37, 43) + SourceIndex(2) -3 >Emitted(57, 10) Source(37, 43) + SourceIndex(2) +1->Emitted(58, 5) Source(37, 42) + SourceIndex(2) +2 >Emitted(58, 6) Source(37, 43) + SourceIndex(2) +3 >Emitted(58, 10) Source(37, 43) + SourceIndex(2) --- >>>} 1 >^ 2 > ^^^^^^^^^^^^^^^^^-> 1 > } -1 >Emitted(58, 2) Source(37, 45) + SourceIndex(2) +1 >Emitted(59, 2) Source(37, 45) + SourceIndex(2) --- ------------------------------------------------------------------- emittedFile:/src/2/second-output.d.ts @@ -780,9 +811,9 @@ sourceFile:../second/second_part2.ts 1-> 2 >class 3 > C -1->Emitted(59, 1) Source(1, 1) + SourceIndex(3) -2 >Emitted(59, 15) Source(1, 7) + SourceIndex(3) -3 >Emitted(59, 16) Source(1, 8) + SourceIndex(3) +1->Emitted(60, 1) Source(1, 1) + SourceIndex(3) +2 >Emitted(60, 15) Source(1, 7) + SourceIndex(3) +3 >Emitted(60, 16) Source(1, 8) + SourceIndex(3) --- >>> doSomething(): void; 1->^^^^ @@ -790,8 +821,8 @@ sourceFile:../second/second_part2.ts 1-> { > 2 > doSomething -1->Emitted(60, 5) Source(2, 5) + SourceIndex(3) -2 >Emitted(60, 16) Source(2, 16) + SourceIndex(3) +1->Emitted(61, 5) Source(2, 5) + SourceIndex(3) +2 >Emitted(61, 16) Source(2, 16) + SourceIndex(3) --- >>>} 1 >^ @@ -800,7 +831,7 @@ sourceFile:../second/second_part2.ts > console.log("something got done"); > } >} -1 >Emitted(61, 2) Source(5, 2) + SourceIndex(3) +1 >Emitted(62, 2) Source(5, 2) + SourceIndex(3) --- >>>//# sourceMappingURL=second-output.d.ts.map @@ -856,32 +887,32 @@ sourceFile:../second/second_part2.ts }, { "pos": 234, - "end": 308, + "end": 339, "kind": "internal" }, { - "pos": 310, - "end": 342, + "pos": 341, + "end": 373, "kind": "text" }, { - "pos": 342, - "end": 734, + "pos": 373, + "end": 765, "kind": "internal" }, { - "pos": 736, - "end": 739, + "pos": 767, + "end": 770, "kind": "text" }, { - "pos": 739, - "end": 1152, + "pos": 770, + "end": 1183, "kind": "internal" }, { - "pos": 1154, - "end": 1202, + "pos": 1185, + "end": 1233, "kind": "text" } ] @@ -1034,18 +1065,19 @@ declare namespace N { declare class normalC { ---------------------------------------------------------------------- -internal: (234-308) +internal: (234-339) constructor(); prop: string; method(): void; - c: number; + get c(): number; + set c(val: number); ---------------------------------------------------------------------- -text: (310-342) +text: (341-373) } declare namespace normalN { ---------------------------------------------------------------------- -internal: (342-734) +internal: (373-765) class C { } function foo(): void; @@ -1066,11 +1098,11 @@ internal: (342-734) c = 2 } ---------------------------------------------------------------------- -text: (736-739) +text: (767-770) } ---------------------------------------------------------------------- -internal: (739-1152) +internal: (770-1183) declare class internalC { } declare function internalfoo(): void; @@ -1091,7 +1123,7 @@ declare enum internalEnum { c = 2 } ---------------------------------------------------------------------- -text: (1154-1202) +text: (1185-1233) declare class C { doSomething(): void; } diff --git a/tests/baselines/reference/tsbuild/outfile-concat/incremental-headers-change-without-dts-changes/stripInternal-when-one-two-three-are-prepended-in-order.js b/tests/baselines/reference/tsbuild/outfile-concat/incremental-headers-change-without-dts-changes/stripInternal-when-one-two-three-are-prepended-in-order.js index a157ee39fc996..1fec0b7b22e95 100644 --- a/tests/baselines/reference/tsbuild/outfile-concat/incremental-headers-change-without-dts-changes/stripInternal-when-one-two-three-are-prepended-in-order.js +++ b/tests/baselines/reference/tsbuild/outfile-concat/incremental-headers-change-without-dts-changes/stripInternal-when-one-two-three-are-prepended-in-order.js @@ -47,7 +47,7 @@ readFiles:: { } //// [/src/2/second-output.d.ts.map] -{"version":3,"file":"second-output.d.ts","sourceRoot":"","sources":["../first/first_PART1.ts","../first/first_part3.ts","../second/second_part1.ts","../second/second_part2.ts"],"names":[],"mappings":"AAAA,UAAU,QAAQ;IACd,IAAI,EAAE,GAAG,CAAC;CACb;AAED,QAAA,MAAM,CAAC,iBAAiB,CAAC;AAEzB,UAAU,iBAAiB;IACvB,IAAI,EAAE,GAAG,CAAC;CACb;ACRD,iBAAS,CAAC,WAET;ACFD,kBAAU,CAAC,CAAC;CAEX;AAED,kBAAU,CAAC,CAAC;CAMX;AAED,cAAM,OAAO;;IAEK,IAAI,EAAE,MAAM,CAAC;IACb,MAAM;IACF,CAAC,EACM,MAAM;CAClC;AACD,kBAAU,OAAO,CAAC;IACA,MAAa,CAAC;KAAI;IAClB,SAAgB,GAAG,SAAK;IACxB,UAAiB,aAAa,CAAC;QAAE,MAAa,CAAC;SAAG;KAAE;IACpD,UAAiB,SAAS,CAAC,SAAS,CAAC;QAAE,MAAa,SAAS;SAAG;KAAE;IAClE,MAAM,QAAQ,UAAU,GAAG,aAAa,CAAC,CAAC,CAAC;IAC3C,KAAY,YAAY,GAAG,SAAS,CAAC;IAC9B,MAAM,aAAa,KAAK,CAAC;IAChC,KAAY,YAAY;QAAG,CAAC,IAAA;QAAE,CAAC,IAAA;QAAE,CAAC,IAAA;KAAE;CACrD;AACa,cAAM,SAAS;CAAG;AAClB,iBAAS,WAAW,SAAK;AACzB,kBAAU,iBAAiB,CAAC;IAAE,MAAa,SAAS;KAAG;CAAE;AACzD,kBAAU,aAAa,CAAC,SAAS,CAAC;IAAE,MAAa,SAAS;KAAG;CAAE;AAC/D,OAAO,cAAc,GAAG,iBAAiB,CAAC,SAAS,CAAC;AACpD,aAAK,YAAY,GAAG,SAAS,CAAC;AAC9B,QAAA,MAAM,aAAa,KAAK,CAAC;AACzB,aAAK,YAAY;IAAG,CAAC,IAAA;IAAE,CAAC,IAAA;IAAE,CAAC,IAAA;CAAE;ACpC3C,cAAM,CAAC;IACH,WAAW;CAGd"} +{"version":3,"file":"second-output.d.ts","sourceRoot":"","sources":["../first/first_PART1.ts","../first/first_part3.ts","../second/second_part1.ts","../second/second_part2.ts"],"names":[],"mappings":"AAAA,UAAU,QAAQ;IACd,IAAI,EAAE,GAAG,CAAC;CACb;AAED,QAAA,MAAM,CAAC,iBAAiB,CAAC;AAEzB,UAAU,iBAAiB;IACvB,IAAI,EAAE,GAAG,CAAC;CACb;ACRD,iBAAS,CAAC,WAET;ACFD,kBAAU,CAAC,CAAC;CAEX;AAED,kBAAU,CAAC,CAAC;CAMX;AAED,cAAM,OAAO;;IAEK,IAAI,EAAE,MAAM,CAAC;IACb,MAAM;IACN,IAAI,CAAC,IACM,MAAM,CADK;IACtB,IAAI,CAAC,CAAC,KAAK,MAAM,EAAK;CACvC;AACD,kBAAU,OAAO,CAAC;IACA,MAAa,CAAC;KAAI;IAClB,SAAgB,GAAG,SAAK;IACxB,UAAiB,aAAa,CAAC;QAAE,MAAa,CAAC;SAAG;KAAE;IACpD,UAAiB,SAAS,CAAC,SAAS,CAAC;QAAE,MAAa,SAAS;SAAG;KAAE;IAClE,MAAM,QAAQ,UAAU,GAAG,aAAa,CAAC,CAAC,CAAC;IAC3C,KAAY,YAAY,GAAG,SAAS,CAAC;IAC9B,MAAM,aAAa,KAAK,CAAC;IAChC,KAAY,YAAY;QAAG,CAAC,IAAA;QAAE,CAAC,IAAA;QAAE,CAAC,IAAA;KAAE;CACrD;AACa,cAAM,SAAS;CAAG;AAClB,iBAAS,WAAW,SAAK;AACzB,kBAAU,iBAAiB,CAAC;IAAE,MAAa,SAAS;KAAG;CAAE;AACzD,kBAAU,aAAa,CAAC,SAAS,CAAC;IAAE,MAAa,SAAS;KAAG;CAAE;AAC/D,OAAO,cAAc,GAAG,iBAAiB,CAAC,SAAS,CAAC;AACpD,aAAK,YAAY,GAAG,SAAS,CAAC;AAC9B,QAAA,MAAM,aAAa,KAAK,CAAC;AACzB,aAAK,YAAY;IAAG,CAAC,IAAA;IAAE,CAAC,IAAA;IAAE,CAAC,IAAA;CAAE;ACpC3C,cAAM,CAAC;IACH,WAAW;CAGd"} //// [/src/2/second-output.d.ts.map.baseline.txt] =================================================================== @@ -267,35 +267,66 @@ sourceFile:../second/second_part1.ts >>> method(): void; 1->^^^^ 2 > ^^^^^^ -3 > ^^^^^-> +3 > ^^^^^^^^^^^-> 1-> > /*@internal*/ 2 > method 1->Emitted(16, 5) Source(16, 19) + SourceIndex(2) 2 >Emitted(16, 11) Source(16, 25) + SourceIndex(2) --- ->>> c: number; +>>> get c(): number; 1->^^^^ -2 > ^ -3 > ^^ -4 > ^^^^^^ +2 > ^^^^ +3 > ^ +4 > ^^^^ +5 > ^^^^^^ +6 > ^ +7 > ^^^^-> 1->() { } - > /*@internal*/ get -2 > c -3 > () { return 10; } - > /*@internal*/ set c(val: -4 > number -1->Emitted(17, 5) Source(17, 23) + SourceIndex(2) -2 >Emitted(17, 6) Source(17, 24) + SourceIndex(2) -3 >Emitted(17, 8) Source(18, 30) + SourceIndex(2) -4 >Emitted(17, 14) Source(18, 36) + SourceIndex(2) + > /*@internal*/ +2 > get +3 > c +4 > () { return 10; } + > /*@internal*/ set c(val: +5 > number +6 > +1->Emitted(17, 5) Source(17, 19) + SourceIndex(2) +2 >Emitted(17, 9) Source(17, 23) + SourceIndex(2) +3 >Emitted(17, 10) Source(17, 24) + SourceIndex(2) +4 >Emitted(17, 14) Source(18, 30) + SourceIndex(2) +5 >Emitted(17, 20) Source(18, 36) + SourceIndex(2) +6 >Emitted(17, 21) Source(17, 41) + SourceIndex(2) +--- +>>> set c(val: number); +1->^^^^ +2 > ^^^^ +3 > ^ +4 > ^ +5 > ^^^^^ +6 > ^^^^^^ +7 > ^^ +1-> + > /*@internal*/ +2 > set +3 > c +4 > ( +5 > val: +6 > number +7 > ) { } +1->Emitted(18, 5) Source(18, 19) + SourceIndex(2) +2 >Emitted(18, 9) Source(18, 23) + SourceIndex(2) +3 >Emitted(18, 10) Source(18, 24) + SourceIndex(2) +4 >Emitted(18, 11) Source(18, 25) + SourceIndex(2) +5 >Emitted(18, 16) Source(18, 30) + SourceIndex(2) +6 >Emitted(18, 22) Source(18, 36) + SourceIndex(2) +7 >Emitted(18, 24) Source(18, 41) + SourceIndex(2) --- >>>} 1 >^ 2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1 >) { } +1 > >} -1 >Emitted(18, 2) Source(19, 2) + SourceIndex(2) +1 >Emitted(19, 2) Source(19, 2) + SourceIndex(2) --- >>>declare namespace normalN { 1-> @@ -307,10 +338,10 @@ sourceFile:../second/second_part1.ts 2 >namespace 3 > normalN 4 > -1->Emitted(19, 1) Source(20, 1) + SourceIndex(2) -2 >Emitted(19, 19) Source(20, 11) + SourceIndex(2) -3 >Emitted(19, 26) Source(20, 18) + SourceIndex(2) -4 >Emitted(19, 27) Source(20, 19) + SourceIndex(2) +1->Emitted(20, 1) Source(20, 1) + SourceIndex(2) +2 >Emitted(20, 19) Source(20, 11) + SourceIndex(2) +3 >Emitted(20, 26) Source(20, 18) + SourceIndex(2) +4 >Emitted(20, 27) Source(20, 19) + SourceIndex(2) --- >>> class C { 1 >^^^^ @@ -320,15 +351,15 @@ sourceFile:../second/second_part1.ts > /*@internal*/ 2 > export class 3 > C -1 >Emitted(20, 5) Source(21, 19) + SourceIndex(2) -2 >Emitted(20, 11) Source(21, 32) + SourceIndex(2) -3 >Emitted(20, 12) Source(21, 33) + SourceIndex(2) +1 >Emitted(21, 5) Source(21, 19) + SourceIndex(2) +2 >Emitted(21, 11) Source(21, 32) + SourceIndex(2) +3 >Emitted(21, 12) Source(21, 33) + SourceIndex(2) --- >>> } 1 >^^^^^ 2 > ^^^^^^^^^^^^^^^^^^^^^-> 1 > { } -1 >Emitted(21, 6) Source(21, 37) + SourceIndex(2) +1 >Emitted(22, 6) Source(21, 37) + SourceIndex(2) --- >>> function foo(): void; 1->^^^^ @@ -341,10 +372,10 @@ sourceFile:../second/second_part1.ts 2 > export function 3 > foo 4 > () {} -1->Emitted(22, 5) Source(22, 19) + SourceIndex(2) -2 >Emitted(22, 14) Source(22, 35) + SourceIndex(2) -3 >Emitted(22, 17) Source(22, 38) + SourceIndex(2) -4 >Emitted(22, 26) Source(22, 43) + SourceIndex(2) +1->Emitted(23, 5) Source(22, 19) + SourceIndex(2) +2 >Emitted(23, 14) Source(22, 35) + SourceIndex(2) +3 >Emitted(23, 17) Source(22, 38) + SourceIndex(2) +4 >Emitted(23, 26) Source(22, 43) + SourceIndex(2) --- >>> namespace someNamespace { 1->^^^^ @@ -356,10 +387,10 @@ sourceFile:../second/second_part1.ts 2 > export namespace 3 > someNamespace 4 > -1->Emitted(23, 5) Source(23, 19) + SourceIndex(2) -2 >Emitted(23, 15) Source(23, 36) + SourceIndex(2) -3 >Emitted(23, 28) Source(23, 49) + SourceIndex(2) -4 >Emitted(23, 29) Source(23, 50) + SourceIndex(2) +1->Emitted(24, 5) Source(23, 19) + SourceIndex(2) +2 >Emitted(24, 15) Source(23, 36) + SourceIndex(2) +3 >Emitted(24, 28) Source(23, 49) + SourceIndex(2) +4 >Emitted(24, 29) Source(23, 50) + SourceIndex(2) --- >>> class C { 1 >^^^^^^^^ @@ -368,20 +399,20 @@ sourceFile:../second/second_part1.ts 1 >{ 2 > export class 3 > C -1 >Emitted(24, 9) Source(23, 52) + SourceIndex(2) -2 >Emitted(24, 15) Source(23, 65) + SourceIndex(2) -3 >Emitted(24, 16) Source(23, 66) + SourceIndex(2) +1 >Emitted(25, 9) Source(23, 52) + SourceIndex(2) +2 >Emitted(25, 15) Source(23, 65) + SourceIndex(2) +3 >Emitted(25, 16) Source(23, 66) + SourceIndex(2) --- >>> } 1 >^^^^^^^^^ 1 > {} -1 >Emitted(25, 10) Source(23, 69) + SourceIndex(2) +1 >Emitted(26, 10) Source(23, 69) + SourceIndex(2) --- >>> } 1 >^^^^^ 2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> 1 > } -1 >Emitted(26, 6) Source(23, 71) + SourceIndex(2) +1 >Emitted(27, 6) Source(23, 71) + SourceIndex(2) --- >>> namespace someOther.something { 1->^^^^ @@ -397,12 +428,12 @@ sourceFile:../second/second_part1.ts 4 > . 5 > something 6 > -1->Emitted(27, 5) Source(24, 19) + SourceIndex(2) -2 >Emitted(27, 15) Source(24, 36) + SourceIndex(2) -3 >Emitted(27, 24) Source(24, 45) + SourceIndex(2) -4 >Emitted(27, 25) Source(24, 46) + SourceIndex(2) -5 >Emitted(27, 34) Source(24, 55) + SourceIndex(2) -6 >Emitted(27, 35) Source(24, 56) + SourceIndex(2) +1->Emitted(28, 5) Source(24, 19) + SourceIndex(2) +2 >Emitted(28, 15) Source(24, 36) + SourceIndex(2) +3 >Emitted(28, 24) Source(24, 45) + SourceIndex(2) +4 >Emitted(28, 25) Source(24, 46) + SourceIndex(2) +5 >Emitted(28, 34) Source(24, 55) + SourceIndex(2) +6 >Emitted(28, 35) Source(24, 56) + SourceIndex(2) --- >>> class someClass { 1 >^^^^^^^^ @@ -411,20 +442,20 @@ sourceFile:../second/second_part1.ts 1 >{ 2 > export class 3 > someClass -1 >Emitted(28, 9) Source(24, 58) + SourceIndex(2) -2 >Emitted(28, 15) Source(24, 71) + SourceIndex(2) -3 >Emitted(28, 24) Source(24, 80) + SourceIndex(2) +1 >Emitted(29, 9) Source(24, 58) + SourceIndex(2) +2 >Emitted(29, 15) Source(24, 71) + SourceIndex(2) +3 >Emitted(29, 24) Source(24, 80) + SourceIndex(2) --- >>> } 1 >^^^^^^^^^ 1 > {} -1 >Emitted(29, 10) Source(24, 83) + SourceIndex(2) +1 >Emitted(30, 10) Source(24, 83) + SourceIndex(2) --- >>> } 1 >^^^^^ 2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> 1 > } -1 >Emitted(30, 6) Source(24, 85) + SourceIndex(2) +1 >Emitted(31, 6) Source(24, 85) + SourceIndex(2) --- >>> export import someImport = someNamespace.C; 1->^^^^ @@ -446,15 +477,15 @@ sourceFile:../second/second_part1.ts 7 > . 8 > C 9 > ; -1->Emitted(31, 5) Source(25, 19) + SourceIndex(2) -2 >Emitted(31, 11) Source(25, 25) + SourceIndex(2) -3 >Emitted(31, 19) Source(25, 33) + SourceIndex(2) -4 >Emitted(31, 29) Source(25, 43) + SourceIndex(2) -5 >Emitted(31, 32) Source(25, 46) + SourceIndex(2) -6 >Emitted(31, 45) Source(25, 59) + SourceIndex(2) -7 >Emitted(31, 46) Source(25, 60) + SourceIndex(2) -8 >Emitted(31, 47) Source(25, 61) + SourceIndex(2) -9 >Emitted(31, 48) Source(25, 62) + SourceIndex(2) +1->Emitted(32, 5) Source(25, 19) + SourceIndex(2) +2 >Emitted(32, 11) Source(25, 25) + SourceIndex(2) +3 >Emitted(32, 19) Source(25, 33) + SourceIndex(2) +4 >Emitted(32, 29) Source(25, 43) + SourceIndex(2) +5 >Emitted(32, 32) Source(25, 46) + SourceIndex(2) +6 >Emitted(32, 45) Source(25, 59) + SourceIndex(2) +7 >Emitted(32, 46) Source(25, 60) + SourceIndex(2) +8 >Emitted(32, 47) Source(25, 61) + SourceIndex(2) +9 >Emitted(32, 48) Source(25, 62) + SourceIndex(2) --- >>> type internalType = internalC; 1 >^^^^ @@ -470,12 +501,12 @@ sourceFile:../second/second_part1.ts 4 > = 5 > internalC 6 > ; -1 >Emitted(32, 5) Source(26, 19) + SourceIndex(2) -2 >Emitted(32, 10) Source(26, 31) + SourceIndex(2) -3 >Emitted(32, 22) Source(26, 43) + SourceIndex(2) -4 >Emitted(32, 25) Source(26, 46) + SourceIndex(2) -5 >Emitted(32, 34) Source(26, 55) + SourceIndex(2) -6 >Emitted(32, 35) Source(26, 56) + SourceIndex(2) +1 >Emitted(33, 5) Source(26, 19) + SourceIndex(2) +2 >Emitted(33, 10) Source(26, 31) + SourceIndex(2) +3 >Emitted(33, 22) Source(26, 43) + SourceIndex(2) +4 >Emitted(33, 25) Source(26, 46) + SourceIndex(2) +5 >Emitted(33, 34) Source(26, 55) + SourceIndex(2) +6 >Emitted(33, 35) Source(26, 56) + SourceIndex(2) --- >>> const internalConst = 10; 1 >^^^^ @@ -489,11 +520,11 @@ sourceFile:../second/second_part1.ts 3 > internalConst 4 > = 10 5 > ; -1 >Emitted(33, 5) Source(27, 26) + SourceIndex(2) -2 >Emitted(33, 11) Source(27, 32) + SourceIndex(2) -3 >Emitted(33, 24) Source(27, 45) + SourceIndex(2) -4 >Emitted(33, 29) Source(27, 50) + SourceIndex(2) -5 >Emitted(33, 30) Source(27, 51) + SourceIndex(2) +1 >Emitted(34, 5) Source(27, 26) + SourceIndex(2) +2 >Emitted(34, 11) Source(27, 32) + SourceIndex(2) +3 >Emitted(34, 24) Source(27, 45) + SourceIndex(2) +4 >Emitted(34, 29) Source(27, 50) + SourceIndex(2) +5 >Emitted(34, 30) Source(27, 51) + SourceIndex(2) --- >>> enum internalEnum { 1 >^^^^ @@ -503,9 +534,9 @@ sourceFile:../second/second_part1.ts > /*@internal*/ 2 > export enum 3 > internalEnum -1 >Emitted(34, 5) Source(28, 19) + SourceIndex(2) -2 >Emitted(34, 10) Source(28, 31) + SourceIndex(2) -3 >Emitted(34, 22) Source(28, 43) + SourceIndex(2) +1 >Emitted(35, 5) Source(28, 19) + SourceIndex(2) +2 >Emitted(35, 10) Source(28, 31) + SourceIndex(2) +3 >Emitted(35, 22) Source(28, 43) + SourceIndex(2) --- >>> a = 0, 1 >^^^^^^^^ @@ -515,9 +546,9 @@ sourceFile:../second/second_part1.ts 1 > { 2 > a 3 > -1 >Emitted(35, 9) Source(28, 46) + SourceIndex(2) -2 >Emitted(35, 10) Source(28, 47) + SourceIndex(2) -3 >Emitted(35, 14) Source(28, 47) + SourceIndex(2) +1 >Emitted(36, 9) Source(28, 46) + SourceIndex(2) +2 >Emitted(36, 10) Source(28, 47) + SourceIndex(2) +3 >Emitted(36, 14) Source(28, 47) + SourceIndex(2) --- >>> b = 1, 1->^^^^^^^^ @@ -527,9 +558,9 @@ sourceFile:../second/second_part1.ts 1->, 2 > b 3 > -1->Emitted(36, 9) Source(28, 49) + SourceIndex(2) -2 >Emitted(36, 10) Source(28, 50) + SourceIndex(2) -3 >Emitted(36, 14) Source(28, 50) + SourceIndex(2) +1->Emitted(37, 9) Source(28, 49) + SourceIndex(2) +2 >Emitted(37, 10) Source(28, 50) + SourceIndex(2) +3 >Emitted(37, 14) Source(28, 50) + SourceIndex(2) --- >>> c = 2 1->^^^^^^^^ @@ -538,21 +569,21 @@ sourceFile:../second/second_part1.ts 1->, 2 > c 3 > -1->Emitted(37, 9) Source(28, 52) + SourceIndex(2) -2 >Emitted(37, 10) Source(28, 53) + SourceIndex(2) -3 >Emitted(37, 14) Source(28, 53) + SourceIndex(2) +1->Emitted(38, 9) Source(28, 52) + SourceIndex(2) +2 >Emitted(38, 10) Source(28, 53) + SourceIndex(2) +3 >Emitted(38, 14) Source(28, 53) + SourceIndex(2) --- >>> } 1 >^^^^^ 1 > } -1 >Emitted(38, 6) Source(28, 55) + SourceIndex(2) +1 >Emitted(39, 6) Source(28, 55) + SourceIndex(2) --- >>>} 1 >^ 2 > ^^^^^^^^^^^^^^^^^^^^^^^^^-> 1 > >} -1 >Emitted(39, 2) Source(29, 2) + SourceIndex(2) +1 >Emitted(40, 2) Source(29, 2) + SourceIndex(2) --- >>>declare class internalC { 1-> @@ -562,15 +593,15 @@ sourceFile:../second/second_part1.ts >/*@internal*/ 2 >class 3 > internalC -1->Emitted(40, 1) Source(30, 15) + SourceIndex(2) -2 >Emitted(40, 15) Source(30, 21) + SourceIndex(2) -3 >Emitted(40, 24) Source(30, 30) + SourceIndex(2) +1->Emitted(41, 1) Source(30, 15) + SourceIndex(2) +2 >Emitted(41, 15) Source(30, 21) + SourceIndex(2) +3 >Emitted(41, 24) Source(30, 30) + SourceIndex(2) --- >>>} 1 >^ 2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> 1 > {} -1 >Emitted(41, 2) Source(30, 33) + SourceIndex(2) +1 >Emitted(42, 2) Source(30, 33) + SourceIndex(2) --- >>>declare function internalfoo(): void; 1-> @@ -583,10 +614,10 @@ sourceFile:../second/second_part1.ts 2 >function 3 > internalfoo 4 > () {} -1->Emitted(42, 1) Source(31, 15) + SourceIndex(2) -2 >Emitted(42, 18) Source(31, 24) + SourceIndex(2) -3 >Emitted(42, 29) Source(31, 35) + SourceIndex(2) -4 >Emitted(42, 38) Source(31, 40) + SourceIndex(2) +1->Emitted(43, 1) Source(31, 15) + SourceIndex(2) +2 >Emitted(43, 18) Source(31, 24) + SourceIndex(2) +3 >Emitted(43, 29) Source(31, 35) + SourceIndex(2) +4 >Emitted(43, 38) Source(31, 40) + SourceIndex(2) --- >>>declare namespace internalNamespace { 1-> @@ -598,10 +629,10 @@ sourceFile:../second/second_part1.ts 2 >namespace 3 > internalNamespace 4 > -1->Emitted(43, 1) Source(32, 15) + SourceIndex(2) -2 >Emitted(43, 19) Source(32, 25) + SourceIndex(2) -3 >Emitted(43, 36) Source(32, 42) + SourceIndex(2) -4 >Emitted(43, 37) Source(32, 43) + SourceIndex(2) +1->Emitted(44, 1) Source(32, 15) + SourceIndex(2) +2 >Emitted(44, 19) Source(32, 25) + SourceIndex(2) +3 >Emitted(44, 36) Source(32, 42) + SourceIndex(2) +4 >Emitted(44, 37) Source(32, 43) + SourceIndex(2) --- >>> class someClass { 1 >^^^^ @@ -610,20 +641,20 @@ sourceFile:../second/second_part1.ts 1 >{ 2 > export class 3 > someClass -1 >Emitted(44, 5) Source(32, 45) + SourceIndex(2) -2 >Emitted(44, 11) Source(32, 58) + SourceIndex(2) -3 >Emitted(44, 20) Source(32, 67) + SourceIndex(2) +1 >Emitted(45, 5) Source(32, 45) + SourceIndex(2) +2 >Emitted(45, 11) Source(32, 58) + SourceIndex(2) +3 >Emitted(45, 20) Source(32, 67) + SourceIndex(2) --- >>> } 1 >^^^^^ 1 > {} -1 >Emitted(45, 6) Source(32, 70) + SourceIndex(2) +1 >Emitted(46, 6) Source(32, 70) + SourceIndex(2) --- >>>} 1 >^ 2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> 1 > } -1 >Emitted(46, 2) Source(32, 72) + SourceIndex(2) +1 >Emitted(47, 2) Source(32, 72) + SourceIndex(2) --- >>>declare namespace internalOther.something { 1-> @@ -639,12 +670,12 @@ sourceFile:../second/second_part1.ts 4 > . 5 > something 6 > -1->Emitted(47, 1) Source(33, 15) + SourceIndex(2) -2 >Emitted(47, 19) Source(33, 25) + SourceIndex(2) -3 >Emitted(47, 32) Source(33, 38) + SourceIndex(2) -4 >Emitted(47, 33) Source(33, 39) + SourceIndex(2) -5 >Emitted(47, 42) Source(33, 48) + SourceIndex(2) -6 >Emitted(47, 43) Source(33, 49) + SourceIndex(2) +1->Emitted(48, 1) Source(33, 15) + SourceIndex(2) +2 >Emitted(48, 19) Source(33, 25) + SourceIndex(2) +3 >Emitted(48, 32) Source(33, 38) + SourceIndex(2) +4 >Emitted(48, 33) Source(33, 39) + SourceIndex(2) +5 >Emitted(48, 42) Source(33, 48) + SourceIndex(2) +6 >Emitted(48, 43) Source(33, 49) + SourceIndex(2) --- >>> class someClass { 1 >^^^^ @@ -653,20 +684,20 @@ sourceFile:../second/second_part1.ts 1 >{ 2 > export class 3 > someClass -1 >Emitted(48, 5) Source(33, 51) + SourceIndex(2) -2 >Emitted(48, 11) Source(33, 64) + SourceIndex(2) -3 >Emitted(48, 20) Source(33, 73) + SourceIndex(2) +1 >Emitted(49, 5) Source(33, 51) + SourceIndex(2) +2 >Emitted(49, 11) Source(33, 64) + SourceIndex(2) +3 >Emitted(49, 20) Source(33, 73) + SourceIndex(2) --- >>> } 1 >^^^^^ 1 > {} -1 >Emitted(49, 6) Source(33, 76) + SourceIndex(2) +1 >Emitted(50, 6) Source(33, 76) + SourceIndex(2) --- >>>} 1 >^ 2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> 1 > } -1 >Emitted(50, 2) Source(33, 78) + SourceIndex(2) +1 >Emitted(51, 2) Source(33, 78) + SourceIndex(2) --- >>>import internalImport = internalNamespace.someClass; 1-> @@ -686,14 +717,14 @@ sourceFile:../second/second_part1.ts 6 > . 7 > someClass 8 > ; -1->Emitted(51, 1) Source(34, 15) + SourceIndex(2) -2 >Emitted(51, 8) Source(34, 22) + SourceIndex(2) -3 >Emitted(51, 22) Source(34, 36) + SourceIndex(2) -4 >Emitted(51, 25) Source(34, 39) + SourceIndex(2) -5 >Emitted(51, 42) Source(34, 56) + SourceIndex(2) -6 >Emitted(51, 43) Source(34, 57) + SourceIndex(2) -7 >Emitted(51, 52) Source(34, 66) + SourceIndex(2) -8 >Emitted(51, 53) Source(34, 67) + SourceIndex(2) +1->Emitted(52, 1) Source(34, 15) + SourceIndex(2) +2 >Emitted(52, 8) Source(34, 22) + SourceIndex(2) +3 >Emitted(52, 22) Source(34, 36) + SourceIndex(2) +4 >Emitted(52, 25) Source(34, 39) + SourceIndex(2) +5 >Emitted(52, 42) Source(34, 56) + SourceIndex(2) +6 >Emitted(52, 43) Source(34, 57) + SourceIndex(2) +7 >Emitted(52, 52) Source(34, 66) + SourceIndex(2) +8 >Emitted(52, 53) Source(34, 67) + SourceIndex(2) --- >>>declare type internalType = internalC; 1 > @@ -709,12 +740,12 @@ sourceFile:../second/second_part1.ts 4 > = 5 > internalC 6 > ; -1 >Emitted(52, 1) Source(35, 15) + SourceIndex(2) -2 >Emitted(52, 14) Source(35, 20) + SourceIndex(2) -3 >Emitted(52, 26) Source(35, 32) + SourceIndex(2) -4 >Emitted(52, 29) Source(35, 35) + SourceIndex(2) -5 >Emitted(52, 38) Source(35, 44) + SourceIndex(2) -6 >Emitted(52, 39) Source(35, 45) + SourceIndex(2) +1 >Emitted(53, 1) Source(35, 15) + SourceIndex(2) +2 >Emitted(53, 14) Source(35, 20) + SourceIndex(2) +3 >Emitted(53, 26) Source(35, 32) + SourceIndex(2) +4 >Emitted(53, 29) Source(35, 35) + SourceIndex(2) +5 >Emitted(53, 38) Source(35, 44) + SourceIndex(2) +6 >Emitted(53, 39) Source(35, 45) + SourceIndex(2) --- >>>declare const internalConst = 10; 1 > @@ -730,12 +761,12 @@ sourceFile:../second/second_part1.ts 4 > internalConst 5 > = 10 6 > ; -1 >Emitted(53, 1) Source(36, 15) + SourceIndex(2) -2 >Emitted(53, 9) Source(36, 15) + SourceIndex(2) -3 >Emitted(53, 15) Source(36, 21) + SourceIndex(2) -4 >Emitted(53, 28) Source(36, 34) + SourceIndex(2) -5 >Emitted(53, 33) Source(36, 39) + SourceIndex(2) -6 >Emitted(53, 34) Source(36, 40) + SourceIndex(2) +1 >Emitted(54, 1) Source(36, 15) + SourceIndex(2) +2 >Emitted(54, 9) Source(36, 15) + SourceIndex(2) +3 >Emitted(54, 15) Source(36, 21) + SourceIndex(2) +4 >Emitted(54, 28) Source(36, 34) + SourceIndex(2) +5 >Emitted(54, 33) Source(36, 39) + SourceIndex(2) +6 >Emitted(54, 34) Source(36, 40) + SourceIndex(2) --- >>>declare enum internalEnum { 1 > @@ -745,9 +776,9 @@ sourceFile:../second/second_part1.ts >/*@internal*/ 2 >enum 3 > internalEnum -1 >Emitted(54, 1) Source(37, 15) + SourceIndex(2) -2 >Emitted(54, 14) Source(37, 20) + SourceIndex(2) -3 >Emitted(54, 26) Source(37, 32) + SourceIndex(2) +1 >Emitted(55, 1) Source(37, 15) + SourceIndex(2) +2 >Emitted(55, 14) Source(37, 20) + SourceIndex(2) +3 >Emitted(55, 26) Source(37, 32) + SourceIndex(2) --- >>> a = 0, 1 >^^^^ @@ -757,9 +788,9 @@ sourceFile:../second/second_part1.ts 1 > { 2 > a 3 > -1 >Emitted(55, 5) Source(37, 35) + SourceIndex(2) -2 >Emitted(55, 6) Source(37, 36) + SourceIndex(2) -3 >Emitted(55, 10) Source(37, 36) + SourceIndex(2) +1 >Emitted(56, 5) Source(37, 35) + SourceIndex(2) +2 >Emitted(56, 6) Source(37, 36) + SourceIndex(2) +3 >Emitted(56, 10) Source(37, 36) + SourceIndex(2) --- >>> b = 1, 1->^^^^ @@ -769,9 +800,9 @@ sourceFile:../second/second_part1.ts 1->, 2 > b 3 > -1->Emitted(56, 5) Source(37, 38) + SourceIndex(2) -2 >Emitted(56, 6) Source(37, 39) + SourceIndex(2) -3 >Emitted(56, 10) Source(37, 39) + SourceIndex(2) +1->Emitted(57, 5) Source(37, 38) + SourceIndex(2) +2 >Emitted(57, 6) Source(37, 39) + SourceIndex(2) +3 >Emitted(57, 10) Source(37, 39) + SourceIndex(2) --- >>> c = 2 1->^^^^ @@ -780,15 +811,15 @@ sourceFile:../second/second_part1.ts 1->, 2 > c 3 > -1->Emitted(57, 5) Source(37, 41) + SourceIndex(2) -2 >Emitted(57, 6) Source(37, 42) + SourceIndex(2) -3 >Emitted(57, 10) Source(37, 42) + SourceIndex(2) +1->Emitted(58, 5) Source(37, 41) + SourceIndex(2) +2 >Emitted(58, 6) Source(37, 42) + SourceIndex(2) +3 >Emitted(58, 10) Source(37, 42) + SourceIndex(2) --- >>>} 1 >^ 2 > ^^^^^^^^^^^^^^^^^-> 1 > } -1 >Emitted(58, 2) Source(37, 44) + SourceIndex(2) +1 >Emitted(59, 2) Source(37, 44) + SourceIndex(2) --- ------------------------------------------------------------------- emittedFile:/src/2/second-output.d.ts @@ -802,9 +833,9 @@ sourceFile:../second/second_part2.ts 1-> 2 >class 3 > C -1->Emitted(59, 1) Source(1, 1) + SourceIndex(3) -2 >Emitted(59, 15) Source(1, 7) + SourceIndex(3) -3 >Emitted(59, 16) Source(1, 8) + SourceIndex(3) +1->Emitted(60, 1) Source(1, 1) + SourceIndex(3) +2 >Emitted(60, 15) Source(1, 7) + SourceIndex(3) +3 >Emitted(60, 16) Source(1, 8) + SourceIndex(3) --- >>> doSomething(): void; 1->^^^^ @@ -812,8 +843,8 @@ sourceFile:../second/second_part2.ts 1-> { > 2 > doSomething -1->Emitted(60, 5) Source(2, 5) + SourceIndex(3) -2 >Emitted(60, 16) Source(2, 16) + SourceIndex(3) +1->Emitted(61, 5) Source(2, 5) + SourceIndex(3) +2 >Emitted(61, 16) Source(2, 16) + SourceIndex(3) --- >>>} 1 >^ @@ -822,7 +853,7 @@ sourceFile:../second/second_part2.ts > console.log("something got done"); > } >} -1 >Emitted(61, 2) Source(5, 2) + SourceIndex(3) +1 >Emitted(62, 2) Source(5, 2) + SourceIndex(3) --- >>>//# sourceMappingURL=second-output.d.ts.map @@ -878,32 +909,32 @@ sourceFile:../second/second_part2.ts }, { "pos": 234, - "end": 308, + "end": 339, "kind": "internal" }, { - "pos": 310, - "end": 342, + "pos": 341, + "end": 373, "kind": "text" }, { - "pos": 342, - "end": 734, + "pos": 373, + "end": 765, "kind": "internal" }, { - "pos": 736, - "end": 739, + "pos": 767, + "end": 770, "kind": "text" }, { - "pos": 739, - "end": 1152, + "pos": 770, + "end": 1183, "kind": "internal" }, { - "pos": 1154, - "end": 1202, + "pos": 1185, + "end": 1233, "kind": "text" } ] @@ -1056,18 +1087,19 @@ declare namespace N { declare class normalC { ---------------------------------------------------------------------- -internal: (234-308) +internal: (234-339) constructor(); prop: string; method(): void; - c: number; + get c(): number; + set c(val: number); ---------------------------------------------------------------------- -text: (310-342) +text: (341-373) } declare namespace normalN { ---------------------------------------------------------------------- -internal: (342-734) +internal: (373-765) class C { } function foo(): void; @@ -1088,11 +1120,11 @@ internal: (342-734) c = 2 } ---------------------------------------------------------------------- -text: (736-739) +text: (767-770) } ---------------------------------------------------------------------- -internal: (739-1152) +internal: (770-1183) declare class internalC { } declare function internalfoo(): void; @@ -1113,7 +1145,7 @@ declare enum internalEnum { c = 2 } ---------------------------------------------------------------------- -text: (1154-1202) +text: (1185-1233) declare class C { doSomething(): void; } diff --git a/tests/baselines/reference/tsbuild/outfile-concat/incremental-headers-change-without-dts-changes/stripInternal-with-comments-emit-enabled-when-one-two-three-are-prepended-in-order.js b/tests/baselines/reference/tsbuild/outfile-concat/incremental-headers-change-without-dts-changes/stripInternal-with-comments-emit-enabled-when-one-two-three-are-prepended-in-order.js index fb2071dc25616..774cd39ea59c3 100644 --- a/tests/baselines/reference/tsbuild/outfile-concat/incremental-headers-change-without-dts-changes/stripInternal-with-comments-emit-enabled-when-one-two-three-are-prepended-in-order.js +++ b/tests/baselines/reference/tsbuild/outfile-concat/incremental-headers-change-without-dts-changes/stripInternal-with-comments-emit-enabled-when-one-two-three-are-prepended-in-order.js @@ -25,7 +25,7 @@ exitCode:: 0 //// [/src/2/second-output.d.ts.map] -{"version":3,"file":"second-output.d.ts","sourceRoot":"","sources":["../first/first_PART1.ts","../first/first_part3.ts","../second/second_part1.ts","../second/second_part2.ts"],"names":[],"mappings":"AAAA,UAAU,QAAQ;IACd,IAAI,EAAE,GAAG,CAAC;CACb;AAED,QAAA,MAAM,CAAC,iBAAiB,CAAC;AAEzB,UAAU,iBAAiB;IACvB,IAAI,EAAE,GAAG,CAAC;CACb;ACRD,iBAAS,CAAC,WAET;ACFD,kBAAU,CAAC,CAAC;CAEX;AAED,kBAAU,CAAC,CAAC;CAMX;AAED,cAAM,OAAO;;IAEK,IAAI,EAAE,MAAM,CAAC;IACb,MAAM;kBACF,CAAC,EACM,MAAM;CAClC;AACD,kBAAU,OAAO,CAAC;IACA,MAAa,CAAC;KAAI;IAClB,SAAgB,GAAG,SAAK;IACxB,UAAiB,aAAa,CAAC;QAAE,MAAa,CAAC;SAAG;KAAE;IACpD,UAAiB,SAAS,CAAC,SAAS,CAAC;QAAE,MAAa,SAAS;SAAG;KAAE;IAClE,MAAM,QAAQ,UAAU,GAAG,aAAa,CAAC,CAAC,CAAC;IAC3C,KAAY,YAAY,GAAG,SAAS,CAAC;IAC9B,MAAM,aAAa,KAAK,CAAC;IAChC,KAAY,YAAY;QAAG,CAAC,IAAA;QAAE,CAAC,IAAA;QAAE,CAAC,IAAA;KAAE;CACrD;AACa,cAAM,SAAS;CAAG;AAClB,iBAAS,WAAW,SAAK;AACzB,kBAAU,iBAAiB,CAAC;IAAE,MAAa,SAAS;KAAG;CAAE;AACzD,kBAAU,aAAa,CAAC,SAAS,CAAC;IAAE,MAAa,SAAS;KAAG;CAAE;AAC/D,OAAO,cAAc,GAAG,iBAAiB,CAAC,SAAS,CAAC;AACpD,aAAK,YAAY,GAAG,SAAS,CAAC;AAC9B,QAAA,MAAM,aAAa,KAAK,CAAC;AACzB,aAAK,YAAY;IAAG,CAAC,IAAA;IAAE,CAAC,IAAA;IAAE,CAAC,IAAA;CAAE;ACpC3C,cAAM,CAAC;IACH,WAAW;CAGd"} +{"version":3,"file":"second-output.d.ts","sourceRoot":"","sources":["../first/first_PART1.ts","../first/first_part3.ts","../second/second_part1.ts","../second/second_part2.ts"],"names":[],"mappings":"AAAA,UAAU,QAAQ;IACd,IAAI,EAAE,GAAG,CAAC;CACb;AAED,QAAA,MAAM,CAAC,iBAAiB,CAAC;AAEzB,UAAU,iBAAiB;IACvB,IAAI,EAAE,GAAG,CAAC;CACb;ACRD,iBAAS,CAAC,WAET;ACFD,kBAAU,CAAC,CAAC;CAEX;AAED,kBAAU,CAAC,CAAC;CAMX;AAED,cAAM,OAAO;;IAEK,IAAI,EAAE,MAAM,CAAC;IACb,MAAM;IACN,IAAI,CAAC,IACM,MAAM,CADK;IACtB,IAAI,CAAC,CAAC,KAAK,MAAM,EAAK;CACvC;AACD,kBAAU,OAAO,CAAC;IACA,MAAa,CAAC;KAAI;IAClB,SAAgB,GAAG,SAAK;IACxB,UAAiB,aAAa,CAAC;QAAE,MAAa,CAAC;SAAG;KAAE;IACpD,UAAiB,SAAS,CAAC,SAAS,CAAC;QAAE,MAAa,SAAS;SAAG;KAAE;IAClE,MAAM,QAAQ,UAAU,GAAG,aAAa,CAAC,CAAC,CAAC;IAC3C,KAAY,YAAY,GAAG,SAAS,CAAC;IAC9B,MAAM,aAAa,KAAK,CAAC;IAChC,KAAY,YAAY;QAAG,CAAC,IAAA;QAAE,CAAC,IAAA;QAAE,CAAC,IAAA;KAAE;CACrD;AACa,cAAM,SAAS;CAAG;AAClB,iBAAS,WAAW,SAAK;AACzB,kBAAU,iBAAiB,CAAC;IAAE,MAAa,SAAS;KAAG;CAAE;AACzD,kBAAU,aAAa,CAAC,SAAS,CAAC;IAAE,MAAa,SAAS;KAAG;CAAE;AAC/D,OAAO,cAAc,GAAG,iBAAiB,CAAC,SAAS,CAAC;AACpD,aAAK,YAAY,GAAG,SAAS,CAAC;AAC9B,QAAA,MAAM,aAAa,KAAK,CAAC;AACzB,aAAK,YAAY;IAAG,CAAC,IAAA;IAAE,CAAC,IAAA;IAAE,CAAC,IAAA;CAAE;ACpC3C,cAAM,CAAC;IACH,WAAW;CAGd"} //// [/src/2/second-output.d.ts.map.baseline.txt] =================================================================== @@ -245,35 +245,66 @@ sourceFile:../second/second_part1.ts >>> method(): void; 1->^^^^ 2 > ^^^^^^ -3 > ^^^^^^^^^^^^^^^^^^^-> +3 > ^^^^^^^^^^^-> 1-> > /*@internal*/ 2 > method 1->Emitted(16, 5) Source(16, 19) + SourceIndex(2) 2 >Emitted(16, 11) Source(16, 25) + SourceIndex(2) --- ->>> /*@internal*/ c: number; -1->^^^^^^^^^^^^^^^^^^ -2 > ^ -3 > ^^ -4 > ^^^^^^ +>>> get c(): number; +1->^^^^ +2 > ^^^^ +3 > ^ +4 > ^^^^ +5 > ^^^^^^ +6 > ^ +7 > ^^^^-> 1->() { } - > /*@internal*/ get -2 > c -3 > () { return 10; } - > /*@internal*/ set c(val: -4 > number -1->Emitted(17, 19) Source(17, 23) + SourceIndex(2) -2 >Emitted(17, 20) Source(17, 24) + SourceIndex(2) -3 >Emitted(17, 22) Source(18, 30) + SourceIndex(2) -4 >Emitted(17, 28) Source(18, 36) + SourceIndex(2) + > /*@internal*/ +2 > get +3 > c +4 > () { return 10; } + > /*@internal*/ set c(val: +5 > number +6 > +1->Emitted(17, 5) Source(17, 19) + SourceIndex(2) +2 >Emitted(17, 9) Source(17, 23) + SourceIndex(2) +3 >Emitted(17, 10) Source(17, 24) + SourceIndex(2) +4 >Emitted(17, 14) Source(18, 30) + SourceIndex(2) +5 >Emitted(17, 20) Source(18, 36) + SourceIndex(2) +6 >Emitted(17, 21) Source(17, 41) + SourceIndex(2) +--- +>>> set c(val: number); +1->^^^^ +2 > ^^^^ +3 > ^ +4 > ^ +5 > ^^^^^ +6 > ^^^^^^ +7 > ^^ +1-> + > /*@internal*/ +2 > set +3 > c +4 > ( +5 > val: +6 > number +7 > ) { } +1->Emitted(18, 5) Source(18, 19) + SourceIndex(2) +2 >Emitted(18, 9) Source(18, 23) + SourceIndex(2) +3 >Emitted(18, 10) Source(18, 24) + SourceIndex(2) +4 >Emitted(18, 11) Source(18, 25) + SourceIndex(2) +5 >Emitted(18, 16) Source(18, 30) + SourceIndex(2) +6 >Emitted(18, 22) Source(18, 36) + SourceIndex(2) +7 >Emitted(18, 24) Source(18, 41) + SourceIndex(2) --- >>>} 1 >^ 2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1 >) { } +1 > >} -1 >Emitted(18, 2) Source(19, 2) + SourceIndex(2) +1 >Emitted(19, 2) Source(19, 2) + SourceIndex(2) --- >>>declare namespace normalN { 1-> @@ -285,10 +316,10 @@ sourceFile:../second/second_part1.ts 2 >namespace 3 > normalN 4 > -1->Emitted(19, 1) Source(20, 1) + SourceIndex(2) -2 >Emitted(19, 19) Source(20, 11) + SourceIndex(2) -3 >Emitted(19, 26) Source(20, 18) + SourceIndex(2) -4 >Emitted(19, 27) Source(20, 19) + SourceIndex(2) +1->Emitted(20, 1) Source(20, 1) + SourceIndex(2) +2 >Emitted(20, 19) Source(20, 11) + SourceIndex(2) +3 >Emitted(20, 26) Source(20, 18) + SourceIndex(2) +4 >Emitted(20, 27) Source(20, 19) + SourceIndex(2) --- >>> class C { 1 >^^^^ @@ -298,15 +329,15 @@ sourceFile:../second/second_part1.ts > /*@internal*/ 2 > export class 3 > C -1 >Emitted(20, 5) Source(21, 19) + SourceIndex(2) -2 >Emitted(20, 11) Source(21, 32) + SourceIndex(2) -3 >Emitted(20, 12) Source(21, 33) + SourceIndex(2) +1 >Emitted(21, 5) Source(21, 19) + SourceIndex(2) +2 >Emitted(21, 11) Source(21, 32) + SourceIndex(2) +3 >Emitted(21, 12) Source(21, 33) + SourceIndex(2) --- >>> } 1 >^^^^^ 2 > ^^^^^^^^^^^^^^^^^^^^^-> 1 > { } -1 >Emitted(21, 6) Source(21, 37) + SourceIndex(2) +1 >Emitted(22, 6) Source(21, 37) + SourceIndex(2) --- >>> function foo(): void; 1->^^^^ @@ -319,10 +350,10 @@ sourceFile:../second/second_part1.ts 2 > export function 3 > foo 4 > () {} -1->Emitted(22, 5) Source(22, 19) + SourceIndex(2) -2 >Emitted(22, 14) Source(22, 35) + SourceIndex(2) -3 >Emitted(22, 17) Source(22, 38) + SourceIndex(2) -4 >Emitted(22, 26) Source(22, 43) + SourceIndex(2) +1->Emitted(23, 5) Source(22, 19) + SourceIndex(2) +2 >Emitted(23, 14) Source(22, 35) + SourceIndex(2) +3 >Emitted(23, 17) Source(22, 38) + SourceIndex(2) +4 >Emitted(23, 26) Source(22, 43) + SourceIndex(2) --- >>> namespace someNamespace { 1->^^^^ @@ -334,10 +365,10 @@ sourceFile:../second/second_part1.ts 2 > export namespace 3 > someNamespace 4 > -1->Emitted(23, 5) Source(23, 19) + SourceIndex(2) -2 >Emitted(23, 15) Source(23, 36) + SourceIndex(2) -3 >Emitted(23, 28) Source(23, 49) + SourceIndex(2) -4 >Emitted(23, 29) Source(23, 50) + SourceIndex(2) +1->Emitted(24, 5) Source(23, 19) + SourceIndex(2) +2 >Emitted(24, 15) Source(23, 36) + SourceIndex(2) +3 >Emitted(24, 28) Source(23, 49) + SourceIndex(2) +4 >Emitted(24, 29) Source(23, 50) + SourceIndex(2) --- >>> class C { 1 >^^^^^^^^ @@ -346,20 +377,20 @@ sourceFile:../second/second_part1.ts 1 >{ 2 > export class 3 > C -1 >Emitted(24, 9) Source(23, 52) + SourceIndex(2) -2 >Emitted(24, 15) Source(23, 65) + SourceIndex(2) -3 >Emitted(24, 16) Source(23, 66) + SourceIndex(2) +1 >Emitted(25, 9) Source(23, 52) + SourceIndex(2) +2 >Emitted(25, 15) Source(23, 65) + SourceIndex(2) +3 >Emitted(25, 16) Source(23, 66) + SourceIndex(2) --- >>> } 1 >^^^^^^^^^ 1 > {} -1 >Emitted(25, 10) Source(23, 69) + SourceIndex(2) +1 >Emitted(26, 10) Source(23, 69) + SourceIndex(2) --- >>> } 1 >^^^^^ 2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> 1 > } -1 >Emitted(26, 6) Source(23, 71) + SourceIndex(2) +1 >Emitted(27, 6) Source(23, 71) + SourceIndex(2) --- >>> namespace someOther.something { 1->^^^^ @@ -375,12 +406,12 @@ sourceFile:../second/second_part1.ts 4 > . 5 > something 6 > -1->Emitted(27, 5) Source(24, 19) + SourceIndex(2) -2 >Emitted(27, 15) Source(24, 36) + SourceIndex(2) -3 >Emitted(27, 24) Source(24, 45) + SourceIndex(2) -4 >Emitted(27, 25) Source(24, 46) + SourceIndex(2) -5 >Emitted(27, 34) Source(24, 55) + SourceIndex(2) -6 >Emitted(27, 35) Source(24, 56) + SourceIndex(2) +1->Emitted(28, 5) Source(24, 19) + SourceIndex(2) +2 >Emitted(28, 15) Source(24, 36) + SourceIndex(2) +3 >Emitted(28, 24) Source(24, 45) + SourceIndex(2) +4 >Emitted(28, 25) Source(24, 46) + SourceIndex(2) +5 >Emitted(28, 34) Source(24, 55) + SourceIndex(2) +6 >Emitted(28, 35) Source(24, 56) + SourceIndex(2) --- >>> class someClass { 1 >^^^^^^^^ @@ -389,20 +420,20 @@ sourceFile:../second/second_part1.ts 1 >{ 2 > export class 3 > someClass -1 >Emitted(28, 9) Source(24, 58) + SourceIndex(2) -2 >Emitted(28, 15) Source(24, 71) + SourceIndex(2) -3 >Emitted(28, 24) Source(24, 80) + SourceIndex(2) +1 >Emitted(29, 9) Source(24, 58) + SourceIndex(2) +2 >Emitted(29, 15) Source(24, 71) + SourceIndex(2) +3 >Emitted(29, 24) Source(24, 80) + SourceIndex(2) --- >>> } 1 >^^^^^^^^^ 1 > {} -1 >Emitted(29, 10) Source(24, 83) + SourceIndex(2) +1 >Emitted(30, 10) Source(24, 83) + SourceIndex(2) --- >>> } 1 >^^^^^ 2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> 1 > } -1 >Emitted(30, 6) Source(24, 85) + SourceIndex(2) +1 >Emitted(31, 6) Source(24, 85) + SourceIndex(2) --- >>> export import someImport = someNamespace.C; 1->^^^^ @@ -424,15 +455,15 @@ sourceFile:../second/second_part1.ts 7 > . 8 > C 9 > ; -1->Emitted(31, 5) Source(25, 19) + SourceIndex(2) -2 >Emitted(31, 11) Source(25, 25) + SourceIndex(2) -3 >Emitted(31, 19) Source(25, 33) + SourceIndex(2) -4 >Emitted(31, 29) Source(25, 43) + SourceIndex(2) -5 >Emitted(31, 32) Source(25, 46) + SourceIndex(2) -6 >Emitted(31, 45) Source(25, 59) + SourceIndex(2) -7 >Emitted(31, 46) Source(25, 60) + SourceIndex(2) -8 >Emitted(31, 47) Source(25, 61) + SourceIndex(2) -9 >Emitted(31, 48) Source(25, 62) + SourceIndex(2) +1->Emitted(32, 5) Source(25, 19) + SourceIndex(2) +2 >Emitted(32, 11) Source(25, 25) + SourceIndex(2) +3 >Emitted(32, 19) Source(25, 33) + SourceIndex(2) +4 >Emitted(32, 29) Source(25, 43) + SourceIndex(2) +5 >Emitted(32, 32) Source(25, 46) + SourceIndex(2) +6 >Emitted(32, 45) Source(25, 59) + SourceIndex(2) +7 >Emitted(32, 46) Source(25, 60) + SourceIndex(2) +8 >Emitted(32, 47) Source(25, 61) + SourceIndex(2) +9 >Emitted(32, 48) Source(25, 62) + SourceIndex(2) --- >>> type internalType = internalC; 1 >^^^^ @@ -448,12 +479,12 @@ sourceFile:../second/second_part1.ts 4 > = 5 > internalC 6 > ; -1 >Emitted(32, 5) Source(26, 19) + SourceIndex(2) -2 >Emitted(32, 10) Source(26, 31) + SourceIndex(2) -3 >Emitted(32, 22) Source(26, 43) + SourceIndex(2) -4 >Emitted(32, 25) Source(26, 46) + SourceIndex(2) -5 >Emitted(32, 34) Source(26, 55) + SourceIndex(2) -6 >Emitted(32, 35) Source(26, 56) + SourceIndex(2) +1 >Emitted(33, 5) Source(26, 19) + SourceIndex(2) +2 >Emitted(33, 10) Source(26, 31) + SourceIndex(2) +3 >Emitted(33, 22) Source(26, 43) + SourceIndex(2) +4 >Emitted(33, 25) Source(26, 46) + SourceIndex(2) +5 >Emitted(33, 34) Source(26, 55) + SourceIndex(2) +6 >Emitted(33, 35) Source(26, 56) + SourceIndex(2) --- >>> const internalConst = 10; 1 >^^^^ @@ -467,11 +498,11 @@ sourceFile:../second/second_part1.ts 3 > internalConst 4 > = 10 5 > ; -1 >Emitted(33, 5) Source(27, 26) + SourceIndex(2) -2 >Emitted(33, 11) Source(27, 32) + SourceIndex(2) -3 >Emitted(33, 24) Source(27, 45) + SourceIndex(2) -4 >Emitted(33, 29) Source(27, 50) + SourceIndex(2) -5 >Emitted(33, 30) Source(27, 51) + SourceIndex(2) +1 >Emitted(34, 5) Source(27, 26) + SourceIndex(2) +2 >Emitted(34, 11) Source(27, 32) + SourceIndex(2) +3 >Emitted(34, 24) Source(27, 45) + SourceIndex(2) +4 >Emitted(34, 29) Source(27, 50) + SourceIndex(2) +5 >Emitted(34, 30) Source(27, 51) + SourceIndex(2) --- >>> enum internalEnum { 1 >^^^^ @@ -481,9 +512,9 @@ sourceFile:../second/second_part1.ts > /*@internal*/ 2 > export enum 3 > internalEnum -1 >Emitted(34, 5) Source(28, 19) + SourceIndex(2) -2 >Emitted(34, 10) Source(28, 31) + SourceIndex(2) -3 >Emitted(34, 22) Source(28, 43) + SourceIndex(2) +1 >Emitted(35, 5) Source(28, 19) + SourceIndex(2) +2 >Emitted(35, 10) Source(28, 31) + SourceIndex(2) +3 >Emitted(35, 22) Source(28, 43) + SourceIndex(2) --- >>> a = 0, 1 >^^^^^^^^ @@ -493,9 +524,9 @@ sourceFile:../second/second_part1.ts 1 > { 2 > a 3 > -1 >Emitted(35, 9) Source(28, 46) + SourceIndex(2) -2 >Emitted(35, 10) Source(28, 47) + SourceIndex(2) -3 >Emitted(35, 14) Source(28, 47) + SourceIndex(2) +1 >Emitted(36, 9) Source(28, 46) + SourceIndex(2) +2 >Emitted(36, 10) Source(28, 47) + SourceIndex(2) +3 >Emitted(36, 14) Source(28, 47) + SourceIndex(2) --- >>> b = 1, 1->^^^^^^^^ @@ -505,9 +536,9 @@ sourceFile:../second/second_part1.ts 1->, 2 > b 3 > -1->Emitted(36, 9) Source(28, 49) + SourceIndex(2) -2 >Emitted(36, 10) Source(28, 50) + SourceIndex(2) -3 >Emitted(36, 14) Source(28, 50) + SourceIndex(2) +1->Emitted(37, 9) Source(28, 49) + SourceIndex(2) +2 >Emitted(37, 10) Source(28, 50) + SourceIndex(2) +3 >Emitted(37, 14) Source(28, 50) + SourceIndex(2) --- >>> c = 2 1->^^^^^^^^ @@ -516,21 +547,21 @@ sourceFile:../second/second_part1.ts 1->, 2 > c 3 > -1->Emitted(37, 9) Source(28, 52) + SourceIndex(2) -2 >Emitted(37, 10) Source(28, 53) + SourceIndex(2) -3 >Emitted(37, 14) Source(28, 53) + SourceIndex(2) +1->Emitted(38, 9) Source(28, 52) + SourceIndex(2) +2 >Emitted(38, 10) Source(28, 53) + SourceIndex(2) +3 >Emitted(38, 14) Source(28, 53) + SourceIndex(2) --- >>> } 1 >^^^^^ 1 > } -1 >Emitted(38, 6) Source(28, 55) + SourceIndex(2) +1 >Emitted(39, 6) Source(28, 55) + SourceIndex(2) --- >>>} 1 >^ 2 > ^^^^^^^^^^^^^^^^^^^^^^^^^-> 1 > >} -1 >Emitted(39, 2) Source(29, 2) + SourceIndex(2) +1 >Emitted(40, 2) Source(29, 2) + SourceIndex(2) --- >>>declare class internalC { 1-> @@ -540,15 +571,15 @@ sourceFile:../second/second_part1.ts >/*@internal*/ 2 >class 3 > internalC -1->Emitted(40, 1) Source(30, 15) + SourceIndex(2) -2 >Emitted(40, 15) Source(30, 21) + SourceIndex(2) -3 >Emitted(40, 24) Source(30, 30) + SourceIndex(2) +1->Emitted(41, 1) Source(30, 15) + SourceIndex(2) +2 >Emitted(41, 15) Source(30, 21) + SourceIndex(2) +3 >Emitted(41, 24) Source(30, 30) + SourceIndex(2) --- >>>} 1 >^ 2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> 1 > {} -1 >Emitted(41, 2) Source(30, 33) + SourceIndex(2) +1 >Emitted(42, 2) Source(30, 33) + SourceIndex(2) --- >>>declare function internalfoo(): void; 1-> @@ -561,10 +592,10 @@ sourceFile:../second/second_part1.ts 2 >function 3 > internalfoo 4 > () {} -1->Emitted(42, 1) Source(31, 15) + SourceIndex(2) -2 >Emitted(42, 18) Source(31, 24) + SourceIndex(2) -3 >Emitted(42, 29) Source(31, 35) + SourceIndex(2) -4 >Emitted(42, 38) Source(31, 40) + SourceIndex(2) +1->Emitted(43, 1) Source(31, 15) + SourceIndex(2) +2 >Emitted(43, 18) Source(31, 24) + SourceIndex(2) +3 >Emitted(43, 29) Source(31, 35) + SourceIndex(2) +4 >Emitted(43, 38) Source(31, 40) + SourceIndex(2) --- >>>declare namespace internalNamespace { 1-> @@ -576,10 +607,10 @@ sourceFile:../second/second_part1.ts 2 >namespace 3 > internalNamespace 4 > -1->Emitted(43, 1) Source(32, 15) + SourceIndex(2) -2 >Emitted(43, 19) Source(32, 25) + SourceIndex(2) -3 >Emitted(43, 36) Source(32, 42) + SourceIndex(2) -4 >Emitted(43, 37) Source(32, 43) + SourceIndex(2) +1->Emitted(44, 1) Source(32, 15) + SourceIndex(2) +2 >Emitted(44, 19) Source(32, 25) + SourceIndex(2) +3 >Emitted(44, 36) Source(32, 42) + SourceIndex(2) +4 >Emitted(44, 37) Source(32, 43) + SourceIndex(2) --- >>> class someClass { 1 >^^^^ @@ -588,20 +619,20 @@ sourceFile:../second/second_part1.ts 1 >{ 2 > export class 3 > someClass -1 >Emitted(44, 5) Source(32, 45) + SourceIndex(2) -2 >Emitted(44, 11) Source(32, 58) + SourceIndex(2) -3 >Emitted(44, 20) Source(32, 67) + SourceIndex(2) +1 >Emitted(45, 5) Source(32, 45) + SourceIndex(2) +2 >Emitted(45, 11) Source(32, 58) + SourceIndex(2) +3 >Emitted(45, 20) Source(32, 67) + SourceIndex(2) --- >>> } 1 >^^^^^ 1 > {} -1 >Emitted(45, 6) Source(32, 70) + SourceIndex(2) +1 >Emitted(46, 6) Source(32, 70) + SourceIndex(2) --- >>>} 1 >^ 2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> 1 > } -1 >Emitted(46, 2) Source(32, 72) + SourceIndex(2) +1 >Emitted(47, 2) Source(32, 72) + SourceIndex(2) --- >>>declare namespace internalOther.something { 1-> @@ -617,12 +648,12 @@ sourceFile:../second/second_part1.ts 4 > . 5 > something 6 > -1->Emitted(47, 1) Source(33, 15) + SourceIndex(2) -2 >Emitted(47, 19) Source(33, 25) + SourceIndex(2) -3 >Emitted(47, 32) Source(33, 38) + SourceIndex(2) -4 >Emitted(47, 33) Source(33, 39) + SourceIndex(2) -5 >Emitted(47, 42) Source(33, 48) + SourceIndex(2) -6 >Emitted(47, 43) Source(33, 49) + SourceIndex(2) +1->Emitted(48, 1) Source(33, 15) + SourceIndex(2) +2 >Emitted(48, 19) Source(33, 25) + SourceIndex(2) +3 >Emitted(48, 32) Source(33, 38) + SourceIndex(2) +4 >Emitted(48, 33) Source(33, 39) + SourceIndex(2) +5 >Emitted(48, 42) Source(33, 48) + SourceIndex(2) +6 >Emitted(48, 43) Source(33, 49) + SourceIndex(2) --- >>> class someClass { 1 >^^^^ @@ -631,20 +662,20 @@ sourceFile:../second/second_part1.ts 1 >{ 2 > export class 3 > someClass -1 >Emitted(48, 5) Source(33, 51) + SourceIndex(2) -2 >Emitted(48, 11) Source(33, 64) + SourceIndex(2) -3 >Emitted(48, 20) Source(33, 73) + SourceIndex(2) +1 >Emitted(49, 5) Source(33, 51) + SourceIndex(2) +2 >Emitted(49, 11) Source(33, 64) + SourceIndex(2) +3 >Emitted(49, 20) Source(33, 73) + SourceIndex(2) --- >>> } 1 >^^^^^ 1 > {} -1 >Emitted(49, 6) Source(33, 76) + SourceIndex(2) +1 >Emitted(50, 6) Source(33, 76) + SourceIndex(2) --- >>>} 1 >^ 2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> 1 > } -1 >Emitted(50, 2) Source(33, 78) + SourceIndex(2) +1 >Emitted(51, 2) Source(33, 78) + SourceIndex(2) --- >>>import internalImport = internalNamespace.someClass; 1-> @@ -664,14 +695,14 @@ sourceFile:../second/second_part1.ts 6 > . 7 > someClass 8 > ; -1->Emitted(51, 1) Source(34, 15) + SourceIndex(2) -2 >Emitted(51, 8) Source(34, 22) + SourceIndex(2) -3 >Emitted(51, 22) Source(34, 36) + SourceIndex(2) -4 >Emitted(51, 25) Source(34, 39) + SourceIndex(2) -5 >Emitted(51, 42) Source(34, 56) + SourceIndex(2) -6 >Emitted(51, 43) Source(34, 57) + SourceIndex(2) -7 >Emitted(51, 52) Source(34, 66) + SourceIndex(2) -8 >Emitted(51, 53) Source(34, 67) + SourceIndex(2) +1->Emitted(52, 1) Source(34, 15) + SourceIndex(2) +2 >Emitted(52, 8) Source(34, 22) + SourceIndex(2) +3 >Emitted(52, 22) Source(34, 36) + SourceIndex(2) +4 >Emitted(52, 25) Source(34, 39) + SourceIndex(2) +5 >Emitted(52, 42) Source(34, 56) + SourceIndex(2) +6 >Emitted(52, 43) Source(34, 57) + SourceIndex(2) +7 >Emitted(52, 52) Source(34, 66) + SourceIndex(2) +8 >Emitted(52, 53) Source(34, 67) + SourceIndex(2) --- >>>declare type internalType = internalC; 1 > @@ -687,12 +718,12 @@ sourceFile:../second/second_part1.ts 4 > = 5 > internalC 6 > ; -1 >Emitted(52, 1) Source(35, 15) + SourceIndex(2) -2 >Emitted(52, 14) Source(35, 20) + SourceIndex(2) -3 >Emitted(52, 26) Source(35, 32) + SourceIndex(2) -4 >Emitted(52, 29) Source(35, 35) + SourceIndex(2) -5 >Emitted(52, 38) Source(35, 44) + SourceIndex(2) -6 >Emitted(52, 39) Source(35, 45) + SourceIndex(2) +1 >Emitted(53, 1) Source(35, 15) + SourceIndex(2) +2 >Emitted(53, 14) Source(35, 20) + SourceIndex(2) +3 >Emitted(53, 26) Source(35, 32) + SourceIndex(2) +4 >Emitted(53, 29) Source(35, 35) + SourceIndex(2) +5 >Emitted(53, 38) Source(35, 44) + SourceIndex(2) +6 >Emitted(53, 39) Source(35, 45) + SourceIndex(2) --- >>>declare const internalConst = 10; 1 > @@ -708,12 +739,12 @@ sourceFile:../second/second_part1.ts 4 > internalConst 5 > = 10 6 > ; -1 >Emitted(53, 1) Source(36, 15) + SourceIndex(2) -2 >Emitted(53, 9) Source(36, 15) + SourceIndex(2) -3 >Emitted(53, 15) Source(36, 21) + SourceIndex(2) -4 >Emitted(53, 28) Source(36, 34) + SourceIndex(2) -5 >Emitted(53, 33) Source(36, 39) + SourceIndex(2) -6 >Emitted(53, 34) Source(36, 40) + SourceIndex(2) +1 >Emitted(54, 1) Source(36, 15) + SourceIndex(2) +2 >Emitted(54, 9) Source(36, 15) + SourceIndex(2) +3 >Emitted(54, 15) Source(36, 21) + SourceIndex(2) +4 >Emitted(54, 28) Source(36, 34) + SourceIndex(2) +5 >Emitted(54, 33) Source(36, 39) + SourceIndex(2) +6 >Emitted(54, 34) Source(36, 40) + SourceIndex(2) --- >>>declare enum internalEnum { 1 > @@ -723,9 +754,9 @@ sourceFile:../second/second_part1.ts >/*@internal*/ 2 >enum 3 > internalEnum -1 >Emitted(54, 1) Source(37, 15) + SourceIndex(2) -2 >Emitted(54, 14) Source(37, 20) + SourceIndex(2) -3 >Emitted(54, 26) Source(37, 32) + SourceIndex(2) +1 >Emitted(55, 1) Source(37, 15) + SourceIndex(2) +2 >Emitted(55, 14) Source(37, 20) + SourceIndex(2) +3 >Emitted(55, 26) Source(37, 32) + SourceIndex(2) --- >>> a = 0, 1 >^^^^ @@ -735,9 +766,9 @@ sourceFile:../second/second_part1.ts 1 > { 2 > a 3 > -1 >Emitted(55, 5) Source(37, 35) + SourceIndex(2) -2 >Emitted(55, 6) Source(37, 36) + SourceIndex(2) -3 >Emitted(55, 10) Source(37, 36) + SourceIndex(2) +1 >Emitted(56, 5) Source(37, 35) + SourceIndex(2) +2 >Emitted(56, 6) Source(37, 36) + SourceIndex(2) +3 >Emitted(56, 10) Source(37, 36) + SourceIndex(2) --- >>> b = 1, 1->^^^^ @@ -747,9 +778,9 @@ sourceFile:../second/second_part1.ts 1->, 2 > b 3 > -1->Emitted(56, 5) Source(37, 38) + SourceIndex(2) -2 >Emitted(56, 6) Source(37, 39) + SourceIndex(2) -3 >Emitted(56, 10) Source(37, 39) + SourceIndex(2) +1->Emitted(57, 5) Source(37, 38) + SourceIndex(2) +2 >Emitted(57, 6) Source(37, 39) + SourceIndex(2) +3 >Emitted(57, 10) Source(37, 39) + SourceIndex(2) --- >>> c = 2 1->^^^^ @@ -758,15 +789,15 @@ sourceFile:../second/second_part1.ts 1->, 2 > c 3 > -1->Emitted(57, 5) Source(37, 41) + SourceIndex(2) -2 >Emitted(57, 6) Source(37, 42) + SourceIndex(2) -3 >Emitted(57, 10) Source(37, 42) + SourceIndex(2) +1->Emitted(58, 5) Source(37, 41) + SourceIndex(2) +2 >Emitted(58, 6) Source(37, 42) + SourceIndex(2) +3 >Emitted(58, 10) Source(37, 42) + SourceIndex(2) --- >>>} 1 >^ 2 > ^^^^^^^^^^^^^^^^^-> 1 > } -1 >Emitted(58, 2) Source(37, 44) + SourceIndex(2) +1 >Emitted(59, 2) Source(37, 44) + SourceIndex(2) --- ------------------------------------------------------------------- emittedFile:/src/2/second-output.d.ts @@ -780,9 +811,9 @@ sourceFile:../second/second_part2.ts 1-> 2 >class 3 > C -1->Emitted(59, 1) Source(1, 1) + SourceIndex(3) -2 >Emitted(59, 15) Source(1, 7) + SourceIndex(3) -3 >Emitted(59, 16) Source(1, 8) + SourceIndex(3) +1->Emitted(60, 1) Source(1, 1) + SourceIndex(3) +2 >Emitted(60, 15) Source(1, 7) + SourceIndex(3) +3 >Emitted(60, 16) Source(1, 8) + SourceIndex(3) --- >>> doSomething(): void; 1->^^^^ @@ -790,8 +821,8 @@ sourceFile:../second/second_part2.ts 1-> { > 2 > doSomething -1->Emitted(60, 5) Source(2, 5) + SourceIndex(3) -2 >Emitted(60, 16) Source(2, 16) + SourceIndex(3) +1->Emitted(61, 5) Source(2, 5) + SourceIndex(3) +2 >Emitted(61, 16) Source(2, 16) + SourceIndex(3) --- >>>} 1 >^ @@ -800,7 +831,7 @@ sourceFile:../second/second_part2.ts > console.log("something got done"); > } >} -1 >Emitted(61, 2) Source(5, 2) + SourceIndex(3) +1 >Emitted(62, 2) Source(5, 2) + SourceIndex(3) --- >>>//# sourceMappingURL=second-output.d.ts.map @@ -856,32 +887,32 @@ sourceFile:../second/second_part2.ts }, { "pos": 234, - "end": 322, + "end": 339, "kind": "internal" }, { - "pos": 324, - "end": 356, + "pos": 341, + "end": 373, "kind": "text" }, { - "pos": 356, - "end": 748, + "pos": 373, + "end": 765, "kind": "internal" }, { - "pos": 750, - "end": 753, + "pos": 767, + "end": 770, "kind": "text" }, { - "pos": 753, - "end": 1166, + "pos": 770, + "end": 1183, "kind": "internal" }, { - "pos": 1168, - "end": 1216, + "pos": 1185, + "end": 1233, "kind": "text" } ] @@ -1034,18 +1065,19 @@ declare namespace N { declare class normalC { ---------------------------------------------------------------------- -internal: (234-322) +internal: (234-339) constructor(); prop: string; method(): void; - /*@internal*/ c: number; + get c(): number; + set c(val: number); ---------------------------------------------------------------------- -text: (324-356) +text: (341-373) } declare namespace normalN { ---------------------------------------------------------------------- -internal: (356-748) +internal: (373-765) class C { } function foo(): void; @@ -1066,11 +1098,11 @@ internal: (356-748) c = 2 } ---------------------------------------------------------------------- -text: (750-753) +text: (767-770) } ---------------------------------------------------------------------- -internal: (753-1166) +internal: (770-1183) declare class internalC { } declare function internalfoo(): void; @@ -1091,7 +1123,7 @@ declare enum internalEnum { c = 2 } ---------------------------------------------------------------------- -text: (1168-1216) +text: (1185-1233) declare class C { doSomething(): void; } diff --git a/tests/baselines/reference/tsbuild/outfile-concat/initial-build/stripInternal-jsdoc-style-comment-when-one-two-three-are-prepended-in-order.js b/tests/baselines/reference/tsbuild/outfile-concat/initial-build/stripInternal-jsdoc-style-comment-when-one-two-three-are-prepended-in-order.js index c341d9c5d2222..339374d5326bb 100644 --- a/tests/baselines/reference/tsbuild/outfile-concat/initial-build/stripInternal-jsdoc-style-comment-when-one-two-three-are-prepended-in-order.js +++ b/tests/baselines/reference/tsbuild/outfile-concat/initial-build/stripInternal-jsdoc-style-comment-when-one-two-three-are-prepended-in-order.js @@ -37,7 +37,8 @@ declare class normalC { constructor(); prop: string; method(): void; - c: number; + get c(): number; + set c(val: number); } declare namespace normalN { class C { @@ -85,7 +86,7 @@ declare class C { //# sourceMappingURL=second-output.d.ts.map //// [/src/2/second-output.d.ts.map] -{"version":3,"file":"second-output.d.ts","sourceRoot":"","sources":["../first/first_PART1.ts","../first/first_part3.ts","../second/second_part1.ts","../second/second_part2.ts"],"names":[],"mappings":"AAAe,UAAU,QAAQ;IAC7B,IAAI,EAAE,GAAG,CAAC;CACb;AAED,QAAA,MAAM,CAAC,iBAAiB,CAAC;AAEzB,UAAU,iBAAiB;IACvB,IAAI,EAAE,GAAG,CAAC;CACb;ACRD,iBAAS,CAAC,WAET;ACFD,kBAAU,CAAC,CAAC;CAEX;AAED,kBAAU,CAAC,CAAC;CAMX;AAED,cAAM,OAAO;;IAEM,IAAI,EAAE,MAAM,CAAC;IACb,MAAM;IACF,CAAC,EACM,MAAM;CACnC;AACD,kBAAU,OAAO,CAAC;IACC,MAAa,CAAC;KAAI;IAClB,SAAgB,GAAG,SAAK;IACxB,UAAiB,aAAa,CAAC;QAAE,MAAa,CAAC;SAAG;KAAE;IACpD,UAAiB,SAAS,CAAC,SAAS,CAAC;QAAE,MAAa,SAAS;SAAG;KAAE;IAClE,MAAM,QAAQ,UAAU,GAAG,aAAa,CAAC,CAAC,CAAC;IAC3C,KAAY,YAAY,GAAG,SAAS,CAAC;IAC9B,MAAM,aAAa,KAAK,CAAC;IAChC,KAAY,YAAY;QAAG,CAAC,IAAA;QAAE,CAAC,IAAA;QAAE,CAAC,IAAA;KAAE;CACtD;AACc,cAAM,SAAS;CAAG;AAClB,iBAAS,WAAW,SAAK;AACzB,kBAAU,iBAAiB,CAAC;IAAE,MAAa,SAAS;KAAG;CAAE;AACzD,kBAAU,aAAa,CAAC,SAAS,CAAC;IAAE,MAAa,SAAS;KAAG;CAAE;AAC/D,OAAO,cAAc,GAAG,iBAAiB,CAAC,SAAS,CAAC;AACpD,aAAK,YAAY,GAAG,SAAS,CAAC;AAC9B,QAAA,MAAM,aAAa,KAAK,CAAC;AACzB,aAAK,YAAY;IAAG,CAAC,IAAA;IAAE,CAAC,IAAA;IAAE,CAAC,IAAA;CAAE;ACpC5C,cAAM,CAAC;IACH,WAAW;CAGd"} +{"version":3,"file":"second-output.d.ts","sourceRoot":"","sources":["../first/first_PART1.ts","../first/first_part3.ts","../second/second_part1.ts","../second/second_part2.ts"],"names":[],"mappings":"AAAe,UAAU,QAAQ;IAC7B,IAAI,EAAE,GAAG,CAAC;CACb;AAED,QAAA,MAAM,CAAC,iBAAiB,CAAC;AAEzB,UAAU,iBAAiB;IACvB,IAAI,EAAE,GAAG,CAAC;CACb;ACRD,iBAAS,CAAC,WAET;ACFD,kBAAU,CAAC,CAAC;CAEX;AAED,kBAAU,CAAC,CAAC;CAMX;AAED,cAAM,OAAO;;IAEM,IAAI,EAAE,MAAM,CAAC;IACb,MAAM;IACN,IAAI,CAAC,IACM,MAAM,CADK;IACtB,IAAI,CAAC,CAAC,KAAK,MAAM,EAAK;CACxC;AACD,kBAAU,OAAO,CAAC;IACC,MAAa,CAAC;KAAI;IAClB,SAAgB,GAAG,SAAK;IACxB,UAAiB,aAAa,CAAC;QAAE,MAAa,CAAC;SAAG;KAAE;IACpD,UAAiB,SAAS,CAAC,SAAS,CAAC;QAAE,MAAa,SAAS;SAAG;KAAE;IAClE,MAAM,QAAQ,UAAU,GAAG,aAAa,CAAC,CAAC,CAAC;IAC3C,KAAY,YAAY,GAAG,SAAS,CAAC;IAC9B,MAAM,aAAa,KAAK,CAAC;IAChC,KAAY,YAAY;QAAG,CAAC,IAAA;QAAE,CAAC,IAAA;QAAE,CAAC,IAAA;KAAE;CACtD;AACc,cAAM,SAAS;CAAG;AAClB,iBAAS,WAAW,SAAK;AACzB,kBAAU,iBAAiB,CAAC;IAAE,MAAa,SAAS;KAAG;CAAE;AACzD,kBAAU,aAAa,CAAC,SAAS,CAAC;IAAE,MAAa,SAAS;KAAG;CAAE;AAC/D,OAAO,cAAc,GAAG,iBAAiB,CAAC,SAAS,CAAC;AACpD,aAAK,YAAY,GAAG,SAAS,CAAC;AAC9B,QAAA,MAAM,aAAa,KAAK,CAAC;AACzB,aAAK,YAAY;IAAG,CAAC,IAAA;IAAE,CAAC,IAAA;IAAE,CAAC,IAAA;CAAE;ACpC5C,cAAM,CAAC;IACH,WAAW;CAGd"} //// [/src/2/second-output.d.ts.map.baseline.txt] =================================================================== @@ -305,35 +306,66 @@ sourceFile:../second/second_part1.ts >>> method(): void; 1->^^^^ 2 > ^^^^^^ -3 > ^^^^^-> +3 > ^^^^^^^^^^^-> 1-> > /**@internal*/ 2 > method 1->Emitted(16, 5) Source(16, 20) + SourceIndex(2) 2 >Emitted(16, 11) Source(16, 26) + SourceIndex(2) --- ->>> c: number; +>>> get c(): number; 1->^^^^ -2 > ^ -3 > ^^ -4 > ^^^^^^ +2 > ^^^^ +3 > ^ +4 > ^^^^ +5 > ^^^^^^ +6 > ^ +7 > ^^^^-> 1->() { } - > /**@internal*/ get -2 > c -3 > () { return 10; } - > /**@internal*/ set c(val: -4 > number -1->Emitted(17, 5) Source(17, 24) + SourceIndex(2) -2 >Emitted(17, 6) Source(17, 25) + SourceIndex(2) -3 >Emitted(17, 8) Source(18, 31) + SourceIndex(2) -4 >Emitted(17, 14) Source(18, 37) + SourceIndex(2) + > /**@internal*/ +2 > get +3 > c +4 > () { return 10; } + > /**@internal*/ set c(val: +5 > number +6 > +1->Emitted(17, 5) Source(17, 20) + SourceIndex(2) +2 >Emitted(17, 9) Source(17, 24) + SourceIndex(2) +3 >Emitted(17, 10) Source(17, 25) + SourceIndex(2) +4 >Emitted(17, 14) Source(18, 31) + SourceIndex(2) +5 >Emitted(17, 20) Source(18, 37) + SourceIndex(2) +6 >Emitted(17, 21) Source(17, 42) + SourceIndex(2) +--- +>>> set c(val: number); +1->^^^^ +2 > ^^^^ +3 > ^ +4 > ^ +5 > ^^^^^ +6 > ^^^^^^ +7 > ^^ +1-> + > /**@internal*/ +2 > set +3 > c +4 > ( +5 > val: +6 > number +7 > ) { } +1->Emitted(18, 5) Source(18, 20) + SourceIndex(2) +2 >Emitted(18, 9) Source(18, 24) + SourceIndex(2) +3 >Emitted(18, 10) Source(18, 25) + SourceIndex(2) +4 >Emitted(18, 11) Source(18, 26) + SourceIndex(2) +5 >Emitted(18, 16) Source(18, 31) + SourceIndex(2) +6 >Emitted(18, 22) Source(18, 37) + SourceIndex(2) +7 >Emitted(18, 24) Source(18, 42) + SourceIndex(2) --- >>>} 1 >^ 2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1 >) { } +1 > >} -1 >Emitted(18, 2) Source(19, 2) + SourceIndex(2) +1 >Emitted(19, 2) Source(19, 2) + SourceIndex(2) --- >>>declare namespace normalN { 1-> @@ -345,10 +377,10 @@ sourceFile:../second/second_part1.ts 2 >namespace 3 > normalN 4 > -1->Emitted(19, 1) Source(20, 1) + SourceIndex(2) -2 >Emitted(19, 19) Source(20, 11) + SourceIndex(2) -3 >Emitted(19, 26) Source(20, 18) + SourceIndex(2) -4 >Emitted(19, 27) Source(20, 19) + SourceIndex(2) +1->Emitted(20, 1) Source(20, 1) + SourceIndex(2) +2 >Emitted(20, 19) Source(20, 11) + SourceIndex(2) +3 >Emitted(20, 26) Source(20, 18) + SourceIndex(2) +4 >Emitted(20, 27) Source(20, 19) + SourceIndex(2) --- >>> class C { 1 >^^^^ @@ -358,15 +390,15 @@ sourceFile:../second/second_part1.ts > /**@internal*/ 2 > export class 3 > C -1 >Emitted(20, 5) Source(21, 20) + SourceIndex(2) -2 >Emitted(20, 11) Source(21, 33) + SourceIndex(2) -3 >Emitted(20, 12) Source(21, 34) + SourceIndex(2) +1 >Emitted(21, 5) Source(21, 20) + SourceIndex(2) +2 >Emitted(21, 11) Source(21, 33) + SourceIndex(2) +3 >Emitted(21, 12) Source(21, 34) + SourceIndex(2) --- >>> } 1 >^^^^^ 2 > ^^^^^^^^^^^^^^^^^^^^^-> 1 > { } -1 >Emitted(21, 6) Source(21, 38) + SourceIndex(2) +1 >Emitted(22, 6) Source(21, 38) + SourceIndex(2) --- >>> function foo(): void; 1->^^^^ @@ -379,10 +411,10 @@ sourceFile:../second/second_part1.ts 2 > export function 3 > foo 4 > () {} -1->Emitted(22, 5) Source(22, 20) + SourceIndex(2) -2 >Emitted(22, 14) Source(22, 36) + SourceIndex(2) -3 >Emitted(22, 17) Source(22, 39) + SourceIndex(2) -4 >Emitted(22, 26) Source(22, 44) + SourceIndex(2) +1->Emitted(23, 5) Source(22, 20) + SourceIndex(2) +2 >Emitted(23, 14) Source(22, 36) + SourceIndex(2) +3 >Emitted(23, 17) Source(22, 39) + SourceIndex(2) +4 >Emitted(23, 26) Source(22, 44) + SourceIndex(2) --- >>> namespace someNamespace { 1->^^^^ @@ -394,10 +426,10 @@ sourceFile:../second/second_part1.ts 2 > export namespace 3 > someNamespace 4 > -1->Emitted(23, 5) Source(23, 20) + SourceIndex(2) -2 >Emitted(23, 15) Source(23, 37) + SourceIndex(2) -3 >Emitted(23, 28) Source(23, 50) + SourceIndex(2) -4 >Emitted(23, 29) Source(23, 51) + SourceIndex(2) +1->Emitted(24, 5) Source(23, 20) + SourceIndex(2) +2 >Emitted(24, 15) Source(23, 37) + SourceIndex(2) +3 >Emitted(24, 28) Source(23, 50) + SourceIndex(2) +4 >Emitted(24, 29) Source(23, 51) + SourceIndex(2) --- >>> class C { 1 >^^^^^^^^ @@ -406,20 +438,20 @@ sourceFile:../second/second_part1.ts 1 >{ 2 > export class 3 > C -1 >Emitted(24, 9) Source(23, 53) + SourceIndex(2) -2 >Emitted(24, 15) Source(23, 66) + SourceIndex(2) -3 >Emitted(24, 16) Source(23, 67) + SourceIndex(2) +1 >Emitted(25, 9) Source(23, 53) + SourceIndex(2) +2 >Emitted(25, 15) Source(23, 66) + SourceIndex(2) +3 >Emitted(25, 16) Source(23, 67) + SourceIndex(2) --- >>> } 1 >^^^^^^^^^ 1 > {} -1 >Emitted(25, 10) Source(23, 70) + SourceIndex(2) +1 >Emitted(26, 10) Source(23, 70) + SourceIndex(2) --- >>> } 1 >^^^^^ 2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> 1 > } -1 >Emitted(26, 6) Source(23, 72) + SourceIndex(2) +1 >Emitted(27, 6) Source(23, 72) + SourceIndex(2) --- >>> namespace someOther.something { 1->^^^^ @@ -435,12 +467,12 @@ sourceFile:../second/second_part1.ts 4 > . 5 > something 6 > -1->Emitted(27, 5) Source(24, 20) + SourceIndex(2) -2 >Emitted(27, 15) Source(24, 37) + SourceIndex(2) -3 >Emitted(27, 24) Source(24, 46) + SourceIndex(2) -4 >Emitted(27, 25) Source(24, 47) + SourceIndex(2) -5 >Emitted(27, 34) Source(24, 56) + SourceIndex(2) -6 >Emitted(27, 35) Source(24, 57) + SourceIndex(2) +1->Emitted(28, 5) Source(24, 20) + SourceIndex(2) +2 >Emitted(28, 15) Source(24, 37) + SourceIndex(2) +3 >Emitted(28, 24) Source(24, 46) + SourceIndex(2) +4 >Emitted(28, 25) Source(24, 47) + SourceIndex(2) +5 >Emitted(28, 34) Source(24, 56) + SourceIndex(2) +6 >Emitted(28, 35) Source(24, 57) + SourceIndex(2) --- >>> class someClass { 1 >^^^^^^^^ @@ -449,20 +481,20 @@ sourceFile:../second/second_part1.ts 1 >{ 2 > export class 3 > someClass -1 >Emitted(28, 9) Source(24, 59) + SourceIndex(2) -2 >Emitted(28, 15) Source(24, 72) + SourceIndex(2) -3 >Emitted(28, 24) Source(24, 81) + SourceIndex(2) +1 >Emitted(29, 9) Source(24, 59) + SourceIndex(2) +2 >Emitted(29, 15) Source(24, 72) + SourceIndex(2) +3 >Emitted(29, 24) Source(24, 81) + SourceIndex(2) --- >>> } 1 >^^^^^^^^^ 1 > {} -1 >Emitted(29, 10) Source(24, 84) + SourceIndex(2) +1 >Emitted(30, 10) Source(24, 84) + SourceIndex(2) --- >>> } 1 >^^^^^ 2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> 1 > } -1 >Emitted(30, 6) Source(24, 86) + SourceIndex(2) +1 >Emitted(31, 6) Source(24, 86) + SourceIndex(2) --- >>> export import someImport = someNamespace.C; 1->^^^^ @@ -484,15 +516,15 @@ sourceFile:../second/second_part1.ts 7 > . 8 > C 9 > ; -1->Emitted(31, 5) Source(25, 20) + SourceIndex(2) -2 >Emitted(31, 11) Source(25, 26) + SourceIndex(2) -3 >Emitted(31, 19) Source(25, 34) + SourceIndex(2) -4 >Emitted(31, 29) Source(25, 44) + SourceIndex(2) -5 >Emitted(31, 32) Source(25, 47) + SourceIndex(2) -6 >Emitted(31, 45) Source(25, 60) + SourceIndex(2) -7 >Emitted(31, 46) Source(25, 61) + SourceIndex(2) -8 >Emitted(31, 47) Source(25, 62) + SourceIndex(2) -9 >Emitted(31, 48) Source(25, 63) + SourceIndex(2) +1->Emitted(32, 5) Source(25, 20) + SourceIndex(2) +2 >Emitted(32, 11) Source(25, 26) + SourceIndex(2) +3 >Emitted(32, 19) Source(25, 34) + SourceIndex(2) +4 >Emitted(32, 29) Source(25, 44) + SourceIndex(2) +5 >Emitted(32, 32) Source(25, 47) + SourceIndex(2) +6 >Emitted(32, 45) Source(25, 60) + SourceIndex(2) +7 >Emitted(32, 46) Source(25, 61) + SourceIndex(2) +8 >Emitted(32, 47) Source(25, 62) + SourceIndex(2) +9 >Emitted(32, 48) Source(25, 63) + SourceIndex(2) --- >>> type internalType = internalC; 1 >^^^^ @@ -508,12 +540,12 @@ sourceFile:../second/second_part1.ts 4 > = 5 > internalC 6 > ; -1 >Emitted(32, 5) Source(26, 20) + SourceIndex(2) -2 >Emitted(32, 10) Source(26, 32) + SourceIndex(2) -3 >Emitted(32, 22) Source(26, 44) + SourceIndex(2) -4 >Emitted(32, 25) Source(26, 47) + SourceIndex(2) -5 >Emitted(32, 34) Source(26, 56) + SourceIndex(2) -6 >Emitted(32, 35) Source(26, 57) + SourceIndex(2) +1 >Emitted(33, 5) Source(26, 20) + SourceIndex(2) +2 >Emitted(33, 10) Source(26, 32) + SourceIndex(2) +3 >Emitted(33, 22) Source(26, 44) + SourceIndex(2) +4 >Emitted(33, 25) Source(26, 47) + SourceIndex(2) +5 >Emitted(33, 34) Source(26, 56) + SourceIndex(2) +6 >Emitted(33, 35) Source(26, 57) + SourceIndex(2) --- >>> const internalConst = 10; 1 >^^^^ @@ -527,11 +559,11 @@ sourceFile:../second/second_part1.ts 3 > internalConst 4 > = 10 5 > ; -1 >Emitted(33, 5) Source(27, 27) + SourceIndex(2) -2 >Emitted(33, 11) Source(27, 33) + SourceIndex(2) -3 >Emitted(33, 24) Source(27, 46) + SourceIndex(2) -4 >Emitted(33, 29) Source(27, 51) + SourceIndex(2) -5 >Emitted(33, 30) Source(27, 52) + SourceIndex(2) +1 >Emitted(34, 5) Source(27, 27) + SourceIndex(2) +2 >Emitted(34, 11) Source(27, 33) + SourceIndex(2) +3 >Emitted(34, 24) Source(27, 46) + SourceIndex(2) +4 >Emitted(34, 29) Source(27, 51) + SourceIndex(2) +5 >Emitted(34, 30) Source(27, 52) + SourceIndex(2) --- >>> enum internalEnum { 1 >^^^^ @@ -541,9 +573,9 @@ sourceFile:../second/second_part1.ts > /**@internal*/ 2 > export enum 3 > internalEnum -1 >Emitted(34, 5) Source(28, 20) + SourceIndex(2) -2 >Emitted(34, 10) Source(28, 32) + SourceIndex(2) -3 >Emitted(34, 22) Source(28, 44) + SourceIndex(2) +1 >Emitted(35, 5) Source(28, 20) + SourceIndex(2) +2 >Emitted(35, 10) Source(28, 32) + SourceIndex(2) +3 >Emitted(35, 22) Source(28, 44) + SourceIndex(2) --- >>> a = 0, 1 >^^^^^^^^ @@ -553,9 +585,9 @@ sourceFile:../second/second_part1.ts 1 > { 2 > a 3 > -1 >Emitted(35, 9) Source(28, 47) + SourceIndex(2) -2 >Emitted(35, 10) Source(28, 48) + SourceIndex(2) -3 >Emitted(35, 14) Source(28, 48) + SourceIndex(2) +1 >Emitted(36, 9) Source(28, 47) + SourceIndex(2) +2 >Emitted(36, 10) Source(28, 48) + SourceIndex(2) +3 >Emitted(36, 14) Source(28, 48) + SourceIndex(2) --- >>> b = 1, 1->^^^^^^^^ @@ -565,9 +597,9 @@ sourceFile:../second/second_part1.ts 1->, 2 > b 3 > -1->Emitted(36, 9) Source(28, 50) + SourceIndex(2) -2 >Emitted(36, 10) Source(28, 51) + SourceIndex(2) -3 >Emitted(36, 14) Source(28, 51) + SourceIndex(2) +1->Emitted(37, 9) Source(28, 50) + SourceIndex(2) +2 >Emitted(37, 10) Source(28, 51) + SourceIndex(2) +3 >Emitted(37, 14) Source(28, 51) + SourceIndex(2) --- >>> c = 2 1->^^^^^^^^ @@ -576,21 +608,21 @@ sourceFile:../second/second_part1.ts 1->, 2 > c 3 > -1->Emitted(37, 9) Source(28, 53) + SourceIndex(2) -2 >Emitted(37, 10) Source(28, 54) + SourceIndex(2) -3 >Emitted(37, 14) Source(28, 54) + SourceIndex(2) +1->Emitted(38, 9) Source(28, 53) + SourceIndex(2) +2 >Emitted(38, 10) Source(28, 54) + SourceIndex(2) +3 >Emitted(38, 14) Source(28, 54) + SourceIndex(2) --- >>> } 1 >^^^^^ 1 > } -1 >Emitted(38, 6) Source(28, 56) + SourceIndex(2) +1 >Emitted(39, 6) Source(28, 56) + SourceIndex(2) --- >>>} 1 >^ 2 > ^^^^^^^^^^^^^^^^^^^^^^^^^-> 1 > >} -1 >Emitted(39, 2) Source(29, 2) + SourceIndex(2) +1 >Emitted(40, 2) Source(29, 2) + SourceIndex(2) --- >>>declare class internalC { 1-> @@ -600,15 +632,15 @@ sourceFile:../second/second_part1.ts >/**@internal*/ 2 >class 3 > internalC -1->Emitted(40, 1) Source(30, 16) + SourceIndex(2) -2 >Emitted(40, 15) Source(30, 22) + SourceIndex(2) -3 >Emitted(40, 24) Source(30, 31) + SourceIndex(2) +1->Emitted(41, 1) Source(30, 16) + SourceIndex(2) +2 >Emitted(41, 15) Source(30, 22) + SourceIndex(2) +3 >Emitted(41, 24) Source(30, 31) + SourceIndex(2) --- >>>} 1 >^ 2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> 1 > {} -1 >Emitted(41, 2) Source(30, 34) + SourceIndex(2) +1 >Emitted(42, 2) Source(30, 34) + SourceIndex(2) --- >>>declare function internalfoo(): void; 1-> @@ -621,10 +653,10 @@ sourceFile:../second/second_part1.ts 2 >function 3 > internalfoo 4 > () {} -1->Emitted(42, 1) Source(31, 16) + SourceIndex(2) -2 >Emitted(42, 18) Source(31, 25) + SourceIndex(2) -3 >Emitted(42, 29) Source(31, 36) + SourceIndex(2) -4 >Emitted(42, 38) Source(31, 41) + SourceIndex(2) +1->Emitted(43, 1) Source(31, 16) + SourceIndex(2) +2 >Emitted(43, 18) Source(31, 25) + SourceIndex(2) +3 >Emitted(43, 29) Source(31, 36) + SourceIndex(2) +4 >Emitted(43, 38) Source(31, 41) + SourceIndex(2) --- >>>declare namespace internalNamespace { 1-> @@ -636,10 +668,10 @@ sourceFile:../second/second_part1.ts 2 >namespace 3 > internalNamespace 4 > -1->Emitted(43, 1) Source(32, 16) + SourceIndex(2) -2 >Emitted(43, 19) Source(32, 26) + SourceIndex(2) -3 >Emitted(43, 36) Source(32, 43) + SourceIndex(2) -4 >Emitted(43, 37) Source(32, 44) + SourceIndex(2) +1->Emitted(44, 1) Source(32, 16) + SourceIndex(2) +2 >Emitted(44, 19) Source(32, 26) + SourceIndex(2) +3 >Emitted(44, 36) Source(32, 43) + SourceIndex(2) +4 >Emitted(44, 37) Source(32, 44) + SourceIndex(2) --- >>> class someClass { 1 >^^^^ @@ -648,20 +680,20 @@ sourceFile:../second/second_part1.ts 1 >{ 2 > export class 3 > someClass -1 >Emitted(44, 5) Source(32, 46) + SourceIndex(2) -2 >Emitted(44, 11) Source(32, 59) + SourceIndex(2) -3 >Emitted(44, 20) Source(32, 68) + SourceIndex(2) +1 >Emitted(45, 5) Source(32, 46) + SourceIndex(2) +2 >Emitted(45, 11) Source(32, 59) + SourceIndex(2) +3 >Emitted(45, 20) Source(32, 68) + SourceIndex(2) --- >>> } 1 >^^^^^ 1 > {} -1 >Emitted(45, 6) Source(32, 71) + SourceIndex(2) +1 >Emitted(46, 6) Source(32, 71) + SourceIndex(2) --- >>>} 1 >^ 2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> 1 > } -1 >Emitted(46, 2) Source(32, 73) + SourceIndex(2) +1 >Emitted(47, 2) Source(32, 73) + SourceIndex(2) --- >>>declare namespace internalOther.something { 1-> @@ -677,12 +709,12 @@ sourceFile:../second/second_part1.ts 4 > . 5 > something 6 > -1->Emitted(47, 1) Source(33, 16) + SourceIndex(2) -2 >Emitted(47, 19) Source(33, 26) + SourceIndex(2) -3 >Emitted(47, 32) Source(33, 39) + SourceIndex(2) -4 >Emitted(47, 33) Source(33, 40) + SourceIndex(2) -5 >Emitted(47, 42) Source(33, 49) + SourceIndex(2) -6 >Emitted(47, 43) Source(33, 50) + SourceIndex(2) +1->Emitted(48, 1) Source(33, 16) + SourceIndex(2) +2 >Emitted(48, 19) Source(33, 26) + SourceIndex(2) +3 >Emitted(48, 32) Source(33, 39) + SourceIndex(2) +4 >Emitted(48, 33) Source(33, 40) + SourceIndex(2) +5 >Emitted(48, 42) Source(33, 49) + SourceIndex(2) +6 >Emitted(48, 43) Source(33, 50) + SourceIndex(2) --- >>> class someClass { 1 >^^^^ @@ -691,20 +723,20 @@ sourceFile:../second/second_part1.ts 1 >{ 2 > export class 3 > someClass -1 >Emitted(48, 5) Source(33, 52) + SourceIndex(2) -2 >Emitted(48, 11) Source(33, 65) + SourceIndex(2) -3 >Emitted(48, 20) Source(33, 74) + SourceIndex(2) +1 >Emitted(49, 5) Source(33, 52) + SourceIndex(2) +2 >Emitted(49, 11) Source(33, 65) + SourceIndex(2) +3 >Emitted(49, 20) Source(33, 74) + SourceIndex(2) --- >>> } 1 >^^^^^ 1 > {} -1 >Emitted(49, 6) Source(33, 77) + SourceIndex(2) +1 >Emitted(50, 6) Source(33, 77) + SourceIndex(2) --- >>>} 1 >^ 2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> 1 > } -1 >Emitted(50, 2) Source(33, 79) + SourceIndex(2) +1 >Emitted(51, 2) Source(33, 79) + SourceIndex(2) --- >>>import internalImport = internalNamespace.someClass; 1-> @@ -724,14 +756,14 @@ sourceFile:../second/second_part1.ts 6 > . 7 > someClass 8 > ; -1->Emitted(51, 1) Source(34, 16) + SourceIndex(2) -2 >Emitted(51, 8) Source(34, 23) + SourceIndex(2) -3 >Emitted(51, 22) Source(34, 37) + SourceIndex(2) -4 >Emitted(51, 25) Source(34, 40) + SourceIndex(2) -5 >Emitted(51, 42) Source(34, 57) + SourceIndex(2) -6 >Emitted(51, 43) Source(34, 58) + SourceIndex(2) -7 >Emitted(51, 52) Source(34, 67) + SourceIndex(2) -8 >Emitted(51, 53) Source(34, 68) + SourceIndex(2) +1->Emitted(52, 1) Source(34, 16) + SourceIndex(2) +2 >Emitted(52, 8) Source(34, 23) + SourceIndex(2) +3 >Emitted(52, 22) Source(34, 37) + SourceIndex(2) +4 >Emitted(52, 25) Source(34, 40) + SourceIndex(2) +5 >Emitted(52, 42) Source(34, 57) + SourceIndex(2) +6 >Emitted(52, 43) Source(34, 58) + SourceIndex(2) +7 >Emitted(52, 52) Source(34, 67) + SourceIndex(2) +8 >Emitted(52, 53) Source(34, 68) + SourceIndex(2) --- >>>declare type internalType = internalC; 1 > @@ -747,12 +779,12 @@ sourceFile:../second/second_part1.ts 4 > = 5 > internalC 6 > ; -1 >Emitted(52, 1) Source(35, 16) + SourceIndex(2) -2 >Emitted(52, 14) Source(35, 21) + SourceIndex(2) -3 >Emitted(52, 26) Source(35, 33) + SourceIndex(2) -4 >Emitted(52, 29) Source(35, 36) + SourceIndex(2) -5 >Emitted(52, 38) Source(35, 45) + SourceIndex(2) -6 >Emitted(52, 39) Source(35, 46) + SourceIndex(2) +1 >Emitted(53, 1) Source(35, 16) + SourceIndex(2) +2 >Emitted(53, 14) Source(35, 21) + SourceIndex(2) +3 >Emitted(53, 26) Source(35, 33) + SourceIndex(2) +4 >Emitted(53, 29) Source(35, 36) + SourceIndex(2) +5 >Emitted(53, 38) Source(35, 45) + SourceIndex(2) +6 >Emitted(53, 39) Source(35, 46) + SourceIndex(2) --- >>>declare const internalConst = 10; 1 > @@ -768,12 +800,12 @@ sourceFile:../second/second_part1.ts 4 > internalConst 5 > = 10 6 > ; -1 >Emitted(53, 1) Source(36, 16) + SourceIndex(2) -2 >Emitted(53, 9) Source(36, 16) + SourceIndex(2) -3 >Emitted(53, 15) Source(36, 22) + SourceIndex(2) -4 >Emitted(53, 28) Source(36, 35) + SourceIndex(2) -5 >Emitted(53, 33) Source(36, 40) + SourceIndex(2) -6 >Emitted(53, 34) Source(36, 41) + SourceIndex(2) +1 >Emitted(54, 1) Source(36, 16) + SourceIndex(2) +2 >Emitted(54, 9) Source(36, 16) + SourceIndex(2) +3 >Emitted(54, 15) Source(36, 22) + SourceIndex(2) +4 >Emitted(54, 28) Source(36, 35) + SourceIndex(2) +5 >Emitted(54, 33) Source(36, 40) + SourceIndex(2) +6 >Emitted(54, 34) Source(36, 41) + SourceIndex(2) --- >>>declare enum internalEnum { 1 > @@ -783,9 +815,9 @@ sourceFile:../second/second_part1.ts >/**@internal*/ 2 >enum 3 > internalEnum -1 >Emitted(54, 1) Source(37, 16) + SourceIndex(2) -2 >Emitted(54, 14) Source(37, 21) + SourceIndex(2) -3 >Emitted(54, 26) Source(37, 33) + SourceIndex(2) +1 >Emitted(55, 1) Source(37, 16) + SourceIndex(2) +2 >Emitted(55, 14) Source(37, 21) + SourceIndex(2) +3 >Emitted(55, 26) Source(37, 33) + SourceIndex(2) --- >>> a = 0, 1 >^^^^ @@ -795,9 +827,9 @@ sourceFile:../second/second_part1.ts 1 > { 2 > a 3 > -1 >Emitted(55, 5) Source(37, 36) + SourceIndex(2) -2 >Emitted(55, 6) Source(37, 37) + SourceIndex(2) -3 >Emitted(55, 10) Source(37, 37) + SourceIndex(2) +1 >Emitted(56, 5) Source(37, 36) + SourceIndex(2) +2 >Emitted(56, 6) Source(37, 37) + SourceIndex(2) +3 >Emitted(56, 10) Source(37, 37) + SourceIndex(2) --- >>> b = 1, 1->^^^^ @@ -807,9 +839,9 @@ sourceFile:../second/second_part1.ts 1->, 2 > b 3 > -1->Emitted(56, 5) Source(37, 39) + SourceIndex(2) -2 >Emitted(56, 6) Source(37, 40) + SourceIndex(2) -3 >Emitted(56, 10) Source(37, 40) + SourceIndex(2) +1->Emitted(57, 5) Source(37, 39) + SourceIndex(2) +2 >Emitted(57, 6) Source(37, 40) + SourceIndex(2) +3 >Emitted(57, 10) Source(37, 40) + SourceIndex(2) --- >>> c = 2 1->^^^^ @@ -818,15 +850,15 @@ sourceFile:../second/second_part1.ts 1->, 2 > c 3 > -1->Emitted(57, 5) Source(37, 42) + SourceIndex(2) -2 >Emitted(57, 6) Source(37, 43) + SourceIndex(2) -3 >Emitted(57, 10) Source(37, 43) + SourceIndex(2) +1->Emitted(58, 5) Source(37, 42) + SourceIndex(2) +2 >Emitted(58, 6) Source(37, 43) + SourceIndex(2) +3 >Emitted(58, 10) Source(37, 43) + SourceIndex(2) --- >>>} 1 >^ 2 > ^^^^^^^^^^^^^^^^^-> 1 > } -1 >Emitted(58, 2) Source(37, 45) + SourceIndex(2) +1 >Emitted(59, 2) Source(37, 45) + SourceIndex(2) --- ------------------------------------------------------------------- emittedFile:/src/2/second-output.d.ts @@ -840,9 +872,9 @@ sourceFile:../second/second_part2.ts 1-> 2 >class 3 > C -1->Emitted(59, 1) Source(1, 1) + SourceIndex(3) -2 >Emitted(59, 15) Source(1, 7) + SourceIndex(3) -3 >Emitted(59, 16) Source(1, 8) + SourceIndex(3) +1->Emitted(60, 1) Source(1, 1) + SourceIndex(3) +2 >Emitted(60, 15) Source(1, 7) + SourceIndex(3) +3 >Emitted(60, 16) Source(1, 8) + SourceIndex(3) --- >>> doSomething(): void; 1->^^^^ @@ -850,8 +882,8 @@ sourceFile:../second/second_part2.ts 1-> { > 2 > doSomething -1->Emitted(60, 5) Source(2, 5) + SourceIndex(3) -2 >Emitted(60, 16) Source(2, 16) + SourceIndex(3) +1->Emitted(61, 5) Source(2, 5) + SourceIndex(3) +2 >Emitted(61, 16) Source(2, 16) + SourceIndex(3) --- >>>} 1 >^ @@ -860,7 +892,7 @@ sourceFile:../second/second_part2.ts > console.log("something got done"); > } >} -1 >Emitted(61, 2) Source(5, 2) + SourceIndex(3) +1 >Emitted(62, 2) Source(5, 2) + SourceIndex(3) --- >>>//# sourceMappingURL=second-output.d.ts.map @@ -2616,32 +2648,32 @@ sourceFile:../second/second_part2.ts }, { "pos": 234, - "end": 308, + "end": 339, "kind": "internal" }, { - "pos": 310, - "end": 342, + "pos": 341, + "end": 373, "kind": "text" }, { - "pos": 342, - "end": 734, + "pos": 373, + "end": 765, "kind": "internal" }, { - "pos": 736, - "end": 739, + "pos": 767, + "end": 770, "kind": "text" }, { - "pos": 739, - "end": 1152, + "pos": 770, + "end": 1183, "kind": "internal" }, { - "pos": 1154, - "end": 1202, + "pos": 1185, + "end": 1233, "kind": "text" } ] @@ -2796,18 +2828,19 @@ declare namespace N { declare class normalC { ---------------------------------------------------------------------- -internal: (234-308) +internal: (234-339) constructor(); prop: string; method(): void; - c: number; + get c(): number; + set c(val: number); ---------------------------------------------------------------------- -text: (310-342) +text: (341-373) } declare namespace normalN { ---------------------------------------------------------------------- -internal: (342-734) +internal: (373-765) class C { } function foo(): void; @@ -2828,11 +2861,11 @@ internal: (342-734) c = 2 } ---------------------------------------------------------------------- -text: (736-739) +text: (767-770) } ---------------------------------------------------------------------- -internal: (739-1152) +internal: (770-1183) declare class internalC { } declare function internalfoo(): void; @@ -2853,7 +2886,7 @@ declare enum internalEnum { c = 2 } ---------------------------------------------------------------------- -text: (1154-1202) +text: (1185-1233) declare class C { doSomething(): void; } diff --git a/tests/baselines/reference/tsbuild/outfile-concat/initial-build/stripInternal-jsdoc-style-comment.js b/tests/baselines/reference/tsbuild/outfile-concat/initial-build/stripInternal-jsdoc-style-comment.js index 709634ade2742..329530576c00c 100644 --- a/tests/baselines/reference/tsbuild/outfile-concat/initial-build/stripInternal-jsdoc-style-comment.js +++ b/tests/baselines/reference/tsbuild/outfile-concat/initial-build/stripInternal-jsdoc-style-comment.js @@ -29,7 +29,8 @@ declare class normalC { constructor(); prop: string; method(): void; - c: number; + get c(): number; + set c(val: number); } declare namespace normalN { class C { @@ -77,7 +78,7 @@ declare class C { //# sourceMappingURL=second-output.d.ts.map //// [/src/2/second-output.d.ts.map] -{"version":3,"file":"second-output.d.ts","sourceRoot":"","sources":["../second/second_part1.ts","../second/second_part2.ts"],"names":[],"mappings":"AAAA,kBAAU,CAAC,CAAC;CAEX;AAED,kBAAU,CAAC,CAAC;CAMX;AAED,cAAM,OAAO;;IAEM,IAAI,EAAE,MAAM,CAAC;IACb,MAAM;IACF,CAAC,EACM,MAAM;CACnC;AACD,kBAAU,OAAO,CAAC;IACC,MAAa,CAAC;KAAI;IAClB,SAAgB,GAAG,SAAK;IACxB,UAAiB,aAAa,CAAC;QAAE,MAAa,CAAC;SAAG;KAAE;IACpD,UAAiB,SAAS,CAAC,SAAS,CAAC;QAAE,MAAa,SAAS;SAAG;KAAE;IAClE,MAAM,QAAQ,UAAU,GAAG,aAAa,CAAC,CAAC,CAAC;IAC3C,KAAY,YAAY,GAAG,SAAS,CAAC;IAC9B,MAAM,aAAa,KAAK,CAAC;IAChC,KAAY,YAAY;QAAG,CAAC,IAAA;QAAE,CAAC,IAAA;QAAE,CAAC,IAAA;KAAE;CACtD;AACc,cAAM,SAAS;CAAG;AAClB,iBAAS,WAAW,SAAK;AACzB,kBAAU,iBAAiB,CAAC;IAAE,MAAa,SAAS;KAAG;CAAE;AACzD,kBAAU,aAAa,CAAC,SAAS,CAAC;IAAE,MAAa,SAAS;KAAG;CAAE;AAC/D,OAAO,cAAc,GAAG,iBAAiB,CAAC,SAAS,CAAC;AACpD,aAAK,YAAY,GAAG,SAAS,CAAC;AAC9B,QAAA,MAAM,aAAa,KAAK,CAAC;AACzB,aAAK,YAAY;IAAG,CAAC,IAAA;IAAE,CAAC,IAAA;IAAE,CAAC,IAAA;CAAE;ACpC5C,cAAM,CAAC;IACH,WAAW;CAGd"} +{"version":3,"file":"second-output.d.ts","sourceRoot":"","sources":["../second/second_part1.ts","../second/second_part2.ts"],"names":[],"mappings":"AAAA,kBAAU,CAAC,CAAC;CAEX;AAED,kBAAU,CAAC,CAAC;CAMX;AAED,cAAM,OAAO;;IAEM,IAAI,EAAE,MAAM,CAAC;IACb,MAAM;IACN,IAAI,CAAC,IACM,MAAM,CADK;IACtB,IAAI,CAAC,CAAC,KAAK,MAAM,EAAK;CACxC;AACD,kBAAU,OAAO,CAAC;IACC,MAAa,CAAC;KAAI;IAClB,SAAgB,GAAG,SAAK;IACxB,UAAiB,aAAa,CAAC;QAAE,MAAa,CAAC;SAAG;KAAE;IACpD,UAAiB,SAAS,CAAC,SAAS,CAAC;QAAE,MAAa,SAAS;SAAG;KAAE;IAClE,MAAM,QAAQ,UAAU,GAAG,aAAa,CAAC,CAAC,CAAC;IAC3C,KAAY,YAAY,GAAG,SAAS,CAAC;IAC9B,MAAM,aAAa,KAAK,CAAC;IAChC,KAAY,YAAY;QAAG,CAAC,IAAA;QAAE,CAAC,IAAA;QAAE,CAAC,IAAA;KAAE;CACtD;AACc,cAAM,SAAS;CAAG;AAClB,iBAAS,WAAW,SAAK;AACzB,kBAAU,iBAAiB,CAAC;IAAE,MAAa,SAAS;KAAG;CAAE;AACzD,kBAAU,aAAa,CAAC,SAAS,CAAC;IAAE,MAAa,SAAS;KAAG;CAAE;AAC/D,OAAO,cAAc,GAAG,iBAAiB,CAAC,SAAS,CAAC;AACpD,aAAK,YAAY,GAAG,SAAS,CAAC;AAC9B,QAAA,MAAM,aAAa,KAAK,CAAC;AACzB,aAAK,YAAY;IAAG,CAAC,IAAA;IAAE,CAAC,IAAA;IAAE,CAAC,IAAA;CAAE;ACpC5C,cAAM,CAAC;IACH,WAAW;CAGd"} //// [/src/2/second-output.d.ts.map.baseline.txt] =================================================================== @@ -177,35 +178,66 @@ sourceFile:../second/second_part1.ts >>> method(): void; 1->^^^^ 2 > ^^^^^^ -3 > ^^^^^-> +3 > ^^^^^^^^^^^-> 1-> > /**@internal*/ 2 > method 1->Emitted(8, 5) Source(16, 20) + SourceIndex(0) 2 >Emitted(8, 11) Source(16, 26) + SourceIndex(0) --- ->>> c: number; +>>> get c(): number; 1->^^^^ -2 > ^ -3 > ^^ -4 > ^^^^^^ +2 > ^^^^ +3 > ^ +4 > ^^^^ +5 > ^^^^^^ +6 > ^ +7 > ^^^^-> 1->() { } - > /**@internal*/ get -2 > c -3 > () { return 10; } - > /**@internal*/ set c(val: -4 > number -1->Emitted(9, 5) Source(17, 24) + SourceIndex(0) -2 >Emitted(9, 6) Source(17, 25) + SourceIndex(0) -3 >Emitted(9, 8) Source(18, 31) + SourceIndex(0) -4 >Emitted(9, 14) Source(18, 37) + SourceIndex(0) + > /**@internal*/ +2 > get +3 > c +4 > () { return 10; } + > /**@internal*/ set c(val: +5 > number +6 > +1->Emitted(9, 5) Source(17, 20) + SourceIndex(0) +2 >Emitted(9, 9) Source(17, 24) + SourceIndex(0) +3 >Emitted(9, 10) Source(17, 25) + SourceIndex(0) +4 >Emitted(9, 14) Source(18, 31) + SourceIndex(0) +5 >Emitted(9, 20) Source(18, 37) + SourceIndex(0) +6 >Emitted(9, 21) Source(17, 42) + SourceIndex(0) +--- +>>> set c(val: number); +1->^^^^ +2 > ^^^^ +3 > ^ +4 > ^ +5 > ^^^^^ +6 > ^^^^^^ +7 > ^^ +1-> + > /**@internal*/ +2 > set +3 > c +4 > ( +5 > val: +6 > number +7 > ) { } +1->Emitted(10, 5) Source(18, 20) + SourceIndex(0) +2 >Emitted(10, 9) Source(18, 24) + SourceIndex(0) +3 >Emitted(10, 10) Source(18, 25) + SourceIndex(0) +4 >Emitted(10, 11) Source(18, 26) + SourceIndex(0) +5 >Emitted(10, 16) Source(18, 31) + SourceIndex(0) +6 >Emitted(10, 22) Source(18, 37) + SourceIndex(0) +7 >Emitted(10, 24) Source(18, 42) + SourceIndex(0) --- >>>} 1 >^ 2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1 >) { } +1 > >} -1 >Emitted(10, 2) Source(19, 2) + SourceIndex(0) +1 >Emitted(11, 2) Source(19, 2) + SourceIndex(0) --- >>>declare namespace normalN { 1-> @@ -217,10 +249,10 @@ sourceFile:../second/second_part1.ts 2 >namespace 3 > normalN 4 > -1->Emitted(11, 1) Source(20, 1) + SourceIndex(0) -2 >Emitted(11, 19) Source(20, 11) + SourceIndex(0) -3 >Emitted(11, 26) Source(20, 18) + SourceIndex(0) -4 >Emitted(11, 27) Source(20, 19) + SourceIndex(0) +1->Emitted(12, 1) Source(20, 1) + SourceIndex(0) +2 >Emitted(12, 19) Source(20, 11) + SourceIndex(0) +3 >Emitted(12, 26) Source(20, 18) + SourceIndex(0) +4 >Emitted(12, 27) Source(20, 19) + SourceIndex(0) --- >>> class C { 1 >^^^^ @@ -230,15 +262,15 @@ sourceFile:../second/second_part1.ts > /**@internal*/ 2 > export class 3 > C -1 >Emitted(12, 5) Source(21, 20) + SourceIndex(0) -2 >Emitted(12, 11) Source(21, 33) + SourceIndex(0) -3 >Emitted(12, 12) Source(21, 34) + SourceIndex(0) +1 >Emitted(13, 5) Source(21, 20) + SourceIndex(0) +2 >Emitted(13, 11) Source(21, 33) + SourceIndex(0) +3 >Emitted(13, 12) Source(21, 34) + SourceIndex(0) --- >>> } 1 >^^^^^ 2 > ^^^^^^^^^^^^^^^^^^^^^-> 1 > { } -1 >Emitted(13, 6) Source(21, 38) + SourceIndex(0) +1 >Emitted(14, 6) Source(21, 38) + SourceIndex(0) --- >>> function foo(): void; 1->^^^^ @@ -251,10 +283,10 @@ sourceFile:../second/second_part1.ts 2 > export function 3 > foo 4 > () {} -1->Emitted(14, 5) Source(22, 20) + SourceIndex(0) -2 >Emitted(14, 14) Source(22, 36) + SourceIndex(0) -3 >Emitted(14, 17) Source(22, 39) + SourceIndex(0) -4 >Emitted(14, 26) Source(22, 44) + SourceIndex(0) +1->Emitted(15, 5) Source(22, 20) + SourceIndex(0) +2 >Emitted(15, 14) Source(22, 36) + SourceIndex(0) +3 >Emitted(15, 17) Source(22, 39) + SourceIndex(0) +4 >Emitted(15, 26) Source(22, 44) + SourceIndex(0) --- >>> namespace someNamespace { 1->^^^^ @@ -266,10 +298,10 @@ sourceFile:../second/second_part1.ts 2 > export namespace 3 > someNamespace 4 > -1->Emitted(15, 5) Source(23, 20) + SourceIndex(0) -2 >Emitted(15, 15) Source(23, 37) + SourceIndex(0) -3 >Emitted(15, 28) Source(23, 50) + SourceIndex(0) -4 >Emitted(15, 29) Source(23, 51) + SourceIndex(0) +1->Emitted(16, 5) Source(23, 20) + SourceIndex(0) +2 >Emitted(16, 15) Source(23, 37) + SourceIndex(0) +3 >Emitted(16, 28) Source(23, 50) + SourceIndex(0) +4 >Emitted(16, 29) Source(23, 51) + SourceIndex(0) --- >>> class C { 1 >^^^^^^^^ @@ -278,20 +310,20 @@ sourceFile:../second/second_part1.ts 1 >{ 2 > export class 3 > C -1 >Emitted(16, 9) Source(23, 53) + SourceIndex(0) -2 >Emitted(16, 15) Source(23, 66) + SourceIndex(0) -3 >Emitted(16, 16) Source(23, 67) + SourceIndex(0) +1 >Emitted(17, 9) Source(23, 53) + SourceIndex(0) +2 >Emitted(17, 15) Source(23, 66) + SourceIndex(0) +3 >Emitted(17, 16) Source(23, 67) + SourceIndex(0) --- >>> } 1 >^^^^^^^^^ 1 > {} -1 >Emitted(17, 10) Source(23, 70) + SourceIndex(0) +1 >Emitted(18, 10) Source(23, 70) + SourceIndex(0) --- >>> } 1 >^^^^^ 2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> 1 > } -1 >Emitted(18, 6) Source(23, 72) + SourceIndex(0) +1 >Emitted(19, 6) Source(23, 72) + SourceIndex(0) --- >>> namespace someOther.something { 1->^^^^ @@ -307,12 +339,12 @@ sourceFile:../second/second_part1.ts 4 > . 5 > something 6 > -1->Emitted(19, 5) Source(24, 20) + SourceIndex(0) -2 >Emitted(19, 15) Source(24, 37) + SourceIndex(0) -3 >Emitted(19, 24) Source(24, 46) + SourceIndex(0) -4 >Emitted(19, 25) Source(24, 47) + SourceIndex(0) -5 >Emitted(19, 34) Source(24, 56) + SourceIndex(0) -6 >Emitted(19, 35) Source(24, 57) + SourceIndex(0) +1->Emitted(20, 5) Source(24, 20) + SourceIndex(0) +2 >Emitted(20, 15) Source(24, 37) + SourceIndex(0) +3 >Emitted(20, 24) Source(24, 46) + SourceIndex(0) +4 >Emitted(20, 25) Source(24, 47) + SourceIndex(0) +5 >Emitted(20, 34) Source(24, 56) + SourceIndex(0) +6 >Emitted(20, 35) Source(24, 57) + SourceIndex(0) --- >>> class someClass { 1 >^^^^^^^^ @@ -321,20 +353,20 @@ sourceFile:../second/second_part1.ts 1 >{ 2 > export class 3 > someClass -1 >Emitted(20, 9) Source(24, 59) + SourceIndex(0) -2 >Emitted(20, 15) Source(24, 72) + SourceIndex(0) -3 >Emitted(20, 24) Source(24, 81) + SourceIndex(0) +1 >Emitted(21, 9) Source(24, 59) + SourceIndex(0) +2 >Emitted(21, 15) Source(24, 72) + SourceIndex(0) +3 >Emitted(21, 24) Source(24, 81) + SourceIndex(0) --- >>> } 1 >^^^^^^^^^ 1 > {} -1 >Emitted(21, 10) Source(24, 84) + SourceIndex(0) +1 >Emitted(22, 10) Source(24, 84) + SourceIndex(0) --- >>> } 1 >^^^^^ 2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> 1 > } -1 >Emitted(22, 6) Source(24, 86) + SourceIndex(0) +1 >Emitted(23, 6) Source(24, 86) + SourceIndex(0) --- >>> export import someImport = someNamespace.C; 1->^^^^ @@ -356,15 +388,15 @@ sourceFile:../second/second_part1.ts 7 > . 8 > C 9 > ; -1->Emitted(23, 5) Source(25, 20) + SourceIndex(0) -2 >Emitted(23, 11) Source(25, 26) + SourceIndex(0) -3 >Emitted(23, 19) Source(25, 34) + SourceIndex(0) -4 >Emitted(23, 29) Source(25, 44) + SourceIndex(0) -5 >Emitted(23, 32) Source(25, 47) + SourceIndex(0) -6 >Emitted(23, 45) Source(25, 60) + SourceIndex(0) -7 >Emitted(23, 46) Source(25, 61) + SourceIndex(0) -8 >Emitted(23, 47) Source(25, 62) + SourceIndex(0) -9 >Emitted(23, 48) Source(25, 63) + SourceIndex(0) +1->Emitted(24, 5) Source(25, 20) + SourceIndex(0) +2 >Emitted(24, 11) Source(25, 26) + SourceIndex(0) +3 >Emitted(24, 19) Source(25, 34) + SourceIndex(0) +4 >Emitted(24, 29) Source(25, 44) + SourceIndex(0) +5 >Emitted(24, 32) Source(25, 47) + SourceIndex(0) +6 >Emitted(24, 45) Source(25, 60) + SourceIndex(0) +7 >Emitted(24, 46) Source(25, 61) + SourceIndex(0) +8 >Emitted(24, 47) Source(25, 62) + SourceIndex(0) +9 >Emitted(24, 48) Source(25, 63) + SourceIndex(0) --- >>> type internalType = internalC; 1 >^^^^ @@ -380,12 +412,12 @@ sourceFile:../second/second_part1.ts 4 > = 5 > internalC 6 > ; -1 >Emitted(24, 5) Source(26, 20) + SourceIndex(0) -2 >Emitted(24, 10) Source(26, 32) + SourceIndex(0) -3 >Emitted(24, 22) Source(26, 44) + SourceIndex(0) -4 >Emitted(24, 25) Source(26, 47) + SourceIndex(0) -5 >Emitted(24, 34) Source(26, 56) + SourceIndex(0) -6 >Emitted(24, 35) Source(26, 57) + SourceIndex(0) +1 >Emitted(25, 5) Source(26, 20) + SourceIndex(0) +2 >Emitted(25, 10) Source(26, 32) + SourceIndex(0) +3 >Emitted(25, 22) Source(26, 44) + SourceIndex(0) +4 >Emitted(25, 25) Source(26, 47) + SourceIndex(0) +5 >Emitted(25, 34) Source(26, 56) + SourceIndex(0) +6 >Emitted(25, 35) Source(26, 57) + SourceIndex(0) --- >>> const internalConst = 10; 1 >^^^^ @@ -399,11 +431,11 @@ sourceFile:../second/second_part1.ts 3 > internalConst 4 > = 10 5 > ; -1 >Emitted(25, 5) Source(27, 27) + SourceIndex(0) -2 >Emitted(25, 11) Source(27, 33) + SourceIndex(0) -3 >Emitted(25, 24) Source(27, 46) + SourceIndex(0) -4 >Emitted(25, 29) Source(27, 51) + SourceIndex(0) -5 >Emitted(25, 30) Source(27, 52) + SourceIndex(0) +1 >Emitted(26, 5) Source(27, 27) + SourceIndex(0) +2 >Emitted(26, 11) Source(27, 33) + SourceIndex(0) +3 >Emitted(26, 24) Source(27, 46) + SourceIndex(0) +4 >Emitted(26, 29) Source(27, 51) + SourceIndex(0) +5 >Emitted(26, 30) Source(27, 52) + SourceIndex(0) --- >>> enum internalEnum { 1 >^^^^ @@ -413,9 +445,9 @@ sourceFile:../second/second_part1.ts > /**@internal*/ 2 > export enum 3 > internalEnum -1 >Emitted(26, 5) Source(28, 20) + SourceIndex(0) -2 >Emitted(26, 10) Source(28, 32) + SourceIndex(0) -3 >Emitted(26, 22) Source(28, 44) + SourceIndex(0) +1 >Emitted(27, 5) Source(28, 20) + SourceIndex(0) +2 >Emitted(27, 10) Source(28, 32) + SourceIndex(0) +3 >Emitted(27, 22) Source(28, 44) + SourceIndex(0) --- >>> a = 0, 1 >^^^^^^^^ @@ -425,9 +457,9 @@ sourceFile:../second/second_part1.ts 1 > { 2 > a 3 > -1 >Emitted(27, 9) Source(28, 47) + SourceIndex(0) -2 >Emitted(27, 10) Source(28, 48) + SourceIndex(0) -3 >Emitted(27, 14) Source(28, 48) + SourceIndex(0) +1 >Emitted(28, 9) Source(28, 47) + SourceIndex(0) +2 >Emitted(28, 10) Source(28, 48) + SourceIndex(0) +3 >Emitted(28, 14) Source(28, 48) + SourceIndex(0) --- >>> b = 1, 1->^^^^^^^^ @@ -437,9 +469,9 @@ sourceFile:../second/second_part1.ts 1->, 2 > b 3 > -1->Emitted(28, 9) Source(28, 50) + SourceIndex(0) -2 >Emitted(28, 10) Source(28, 51) + SourceIndex(0) -3 >Emitted(28, 14) Source(28, 51) + SourceIndex(0) +1->Emitted(29, 9) Source(28, 50) + SourceIndex(0) +2 >Emitted(29, 10) Source(28, 51) + SourceIndex(0) +3 >Emitted(29, 14) Source(28, 51) + SourceIndex(0) --- >>> c = 2 1->^^^^^^^^ @@ -448,21 +480,21 @@ sourceFile:../second/second_part1.ts 1->, 2 > c 3 > -1->Emitted(29, 9) Source(28, 53) + SourceIndex(0) -2 >Emitted(29, 10) Source(28, 54) + SourceIndex(0) -3 >Emitted(29, 14) Source(28, 54) + SourceIndex(0) +1->Emitted(30, 9) Source(28, 53) + SourceIndex(0) +2 >Emitted(30, 10) Source(28, 54) + SourceIndex(0) +3 >Emitted(30, 14) Source(28, 54) + SourceIndex(0) --- >>> } 1 >^^^^^ 1 > } -1 >Emitted(30, 6) Source(28, 56) + SourceIndex(0) +1 >Emitted(31, 6) Source(28, 56) + SourceIndex(0) --- >>>} 1 >^ 2 > ^^^^^^^^^^^^^^^^^^^^^^^^^-> 1 > >} -1 >Emitted(31, 2) Source(29, 2) + SourceIndex(0) +1 >Emitted(32, 2) Source(29, 2) + SourceIndex(0) --- >>>declare class internalC { 1-> @@ -472,15 +504,15 @@ sourceFile:../second/second_part1.ts >/**@internal*/ 2 >class 3 > internalC -1->Emitted(32, 1) Source(30, 16) + SourceIndex(0) -2 >Emitted(32, 15) Source(30, 22) + SourceIndex(0) -3 >Emitted(32, 24) Source(30, 31) + SourceIndex(0) +1->Emitted(33, 1) Source(30, 16) + SourceIndex(0) +2 >Emitted(33, 15) Source(30, 22) + SourceIndex(0) +3 >Emitted(33, 24) Source(30, 31) + SourceIndex(0) --- >>>} 1 >^ 2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> 1 > {} -1 >Emitted(33, 2) Source(30, 34) + SourceIndex(0) +1 >Emitted(34, 2) Source(30, 34) + SourceIndex(0) --- >>>declare function internalfoo(): void; 1-> @@ -493,10 +525,10 @@ sourceFile:../second/second_part1.ts 2 >function 3 > internalfoo 4 > () {} -1->Emitted(34, 1) Source(31, 16) + SourceIndex(0) -2 >Emitted(34, 18) Source(31, 25) + SourceIndex(0) -3 >Emitted(34, 29) Source(31, 36) + SourceIndex(0) -4 >Emitted(34, 38) Source(31, 41) + SourceIndex(0) +1->Emitted(35, 1) Source(31, 16) + SourceIndex(0) +2 >Emitted(35, 18) Source(31, 25) + SourceIndex(0) +3 >Emitted(35, 29) Source(31, 36) + SourceIndex(0) +4 >Emitted(35, 38) Source(31, 41) + SourceIndex(0) --- >>>declare namespace internalNamespace { 1-> @@ -508,10 +540,10 @@ sourceFile:../second/second_part1.ts 2 >namespace 3 > internalNamespace 4 > -1->Emitted(35, 1) Source(32, 16) + SourceIndex(0) -2 >Emitted(35, 19) Source(32, 26) + SourceIndex(0) -3 >Emitted(35, 36) Source(32, 43) + SourceIndex(0) -4 >Emitted(35, 37) Source(32, 44) + SourceIndex(0) +1->Emitted(36, 1) Source(32, 16) + SourceIndex(0) +2 >Emitted(36, 19) Source(32, 26) + SourceIndex(0) +3 >Emitted(36, 36) Source(32, 43) + SourceIndex(0) +4 >Emitted(36, 37) Source(32, 44) + SourceIndex(0) --- >>> class someClass { 1 >^^^^ @@ -520,20 +552,20 @@ sourceFile:../second/second_part1.ts 1 >{ 2 > export class 3 > someClass -1 >Emitted(36, 5) Source(32, 46) + SourceIndex(0) -2 >Emitted(36, 11) Source(32, 59) + SourceIndex(0) -3 >Emitted(36, 20) Source(32, 68) + SourceIndex(0) +1 >Emitted(37, 5) Source(32, 46) + SourceIndex(0) +2 >Emitted(37, 11) Source(32, 59) + SourceIndex(0) +3 >Emitted(37, 20) Source(32, 68) + SourceIndex(0) --- >>> } 1 >^^^^^ 1 > {} -1 >Emitted(37, 6) Source(32, 71) + SourceIndex(0) +1 >Emitted(38, 6) Source(32, 71) + SourceIndex(0) --- >>>} 1 >^ 2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> 1 > } -1 >Emitted(38, 2) Source(32, 73) + SourceIndex(0) +1 >Emitted(39, 2) Source(32, 73) + SourceIndex(0) --- >>>declare namespace internalOther.something { 1-> @@ -549,12 +581,12 @@ sourceFile:../second/second_part1.ts 4 > . 5 > something 6 > -1->Emitted(39, 1) Source(33, 16) + SourceIndex(0) -2 >Emitted(39, 19) Source(33, 26) + SourceIndex(0) -3 >Emitted(39, 32) Source(33, 39) + SourceIndex(0) -4 >Emitted(39, 33) Source(33, 40) + SourceIndex(0) -5 >Emitted(39, 42) Source(33, 49) + SourceIndex(0) -6 >Emitted(39, 43) Source(33, 50) + SourceIndex(0) +1->Emitted(40, 1) Source(33, 16) + SourceIndex(0) +2 >Emitted(40, 19) Source(33, 26) + SourceIndex(0) +3 >Emitted(40, 32) Source(33, 39) + SourceIndex(0) +4 >Emitted(40, 33) Source(33, 40) + SourceIndex(0) +5 >Emitted(40, 42) Source(33, 49) + SourceIndex(0) +6 >Emitted(40, 43) Source(33, 50) + SourceIndex(0) --- >>> class someClass { 1 >^^^^ @@ -563,20 +595,20 @@ sourceFile:../second/second_part1.ts 1 >{ 2 > export class 3 > someClass -1 >Emitted(40, 5) Source(33, 52) + SourceIndex(0) -2 >Emitted(40, 11) Source(33, 65) + SourceIndex(0) -3 >Emitted(40, 20) Source(33, 74) + SourceIndex(0) +1 >Emitted(41, 5) Source(33, 52) + SourceIndex(0) +2 >Emitted(41, 11) Source(33, 65) + SourceIndex(0) +3 >Emitted(41, 20) Source(33, 74) + SourceIndex(0) --- >>> } 1 >^^^^^ 1 > {} -1 >Emitted(41, 6) Source(33, 77) + SourceIndex(0) +1 >Emitted(42, 6) Source(33, 77) + SourceIndex(0) --- >>>} 1 >^ 2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> 1 > } -1 >Emitted(42, 2) Source(33, 79) + SourceIndex(0) +1 >Emitted(43, 2) Source(33, 79) + SourceIndex(0) --- >>>import internalImport = internalNamespace.someClass; 1-> @@ -596,14 +628,14 @@ sourceFile:../second/second_part1.ts 6 > . 7 > someClass 8 > ; -1->Emitted(43, 1) Source(34, 16) + SourceIndex(0) -2 >Emitted(43, 8) Source(34, 23) + SourceIndex(0) -3 >Emitted(43, 22) Source(34, 37) + SourceIndex(0) -4 >Emitted(43, 25) Source(34, 40) + SourceIndex(0) -5 >Emitted(43, 42) Source(34, 57) + SourceIndex(0) -6 >Emitted(43, 43) Source(34, 58) + SourceIndex(0) -7 >Emitted(43, 52) Source(34, 67) + SourceIndex(0) -8 >Emitted(43, 53) Source(34, 68) + SourceIndex(0) +1->Emitted(44, 1) Source(34, 16) + SourceIndex(0) +2 >Emitted(44, 8) Source(34, 23) + SourceIndex(0) +3 >Emitted(44, 22) Source(34, 37) + SourceIndex(0) +4 >Emitted(44, 25) Source(34, 40) + SourceIndex(0) +5 >Emitted(44, 42) Source(34, 57) + SourceIndex(0) +6 >Emitted(44, 43) Source(34, 58) + SourceIndex(0) +7 >Emitted(44, 52) Source(34, 67) + SourceIndex(0) +8 >Emitted(44, 53) Source(34, 68) + SourceIndex(0) --- >>>declare type internalType = internalC; 1 > @@ -619,12 +651,12 @@ sourceFile:../second/second_part1.ts 4 > = 5 > internalC 6 > ; -1 >Emitted(44, 1) Source(35, 16) + SourceIndex(0) -2 >Emitted(44, 14) Source(35, 21) + SourceIndex(0) -3 >Emitted(44, 26) Source(35, 33) + SourceIndex(0) -4 >Emitted(44, 29) Source(35, 36) + SourceIndex(0) -5 >Emitted(44, 38) Source(35, 45) + SourceIndex(0) -6 >Emitted(44, 39) Source(35, 46) + SourceIndex(0) +1 >Emitted(45, 1) Source(35, 16) + SourceIndex(0) +2 >Emitted(45, 14) Source(35, 21) + SourceIndex(0) +3 >Emitted(45, 26) Source(35, 33) + SourceIndex(0) +4 >Emitted(45, 29) Source(35, 36) + SourceIndex(0) +5 >Emitted(45, 38) Source(35, 45) + SourceIndex(0) +6 >Emitted(45, 39) Source(35, 46) + SourceIndex(0) --- >>>declare const internalConst = 10; 1 > @@ -640,12 +672,12 @@ sourceFile:../second/second_part1.ts 4 > internalConst 5 > = 10 6 > ; -1 >Emitted(45, 1) Source(36, 16) + SourceIndex(0) -2 >Emitted(45, 9) Source(36, 16) + SourceIndex(0) -3 >Emitted(45, 15) Source(36, 22) + SourceIndex(0) -4 >Emitted(45, 28) Source(36, 35) + SourceIndex(0) -5 >Emitted(45, 33) Source(36, 40) + SourceIndex(0) -6 >Emitted(45, 34) Source(36, 41) + SourceIndex(0) +1 >Emitted(46, 1) Source(36, 16) + SourceIndex(0) +2 >Emitted(46, 9) Source(36, 16) + SourceIndex(0) +3 >Emitted(46, 15) Source(36, 22) + SourceIndex(0) +4 >Emitted(46, 28) Source(36, 35) + SourceIndex(0) +5 >Emitted(46, 33) Source(36, 40) + SourceIndex(0) +6 >Emitted(46, 34) Source(36, 41) + SourceIndex(0) --- >>>declare enum internalEnum { 1 > @@ -655,9 +687,9 @@ sourceFile:../second/second_part1.ts >/**@internal*/ 2 >enum 3 > internalEnum -1 >Emitted(46, 1) Source(37, 16) + SourceIndex(0) -2 >Emitted(46, 14) Source(37, 21) + SourceIndex(0) -3 >Emitted(46, 26) Source(37, 33) + SourceIndex(0) +1 >Emitted(47, 1) Source(37, 16) + SourceIndex(0) +2 >Emitted(47, 14) Source(37, 21) + SourceIndex(0) +3 >Emitted(47, 26) Source(37, 33) + SourceIndex(0) --- >>> a = 0, 1 >^^^^ @@ -667,9 +699,9 @@ sourceFile:../second/second_part1.ts 1 > { 2 > a 3 > -1 >Emitted(47, 5) Source(37, 36) + SourceIndex(0) -2 >Emitted(47, 6) Source(37, 37) + SourceIndex(0) -3 >Emitted(47, 10) Source(37, 37) + SourceIndex(0) +1 >Emitted(48, 5) Source(37, 36) + SourceIndex(0) +2 >Emitted(48, 6) Source(37, 37) + SourceIndex(0) +3 >Emitted(48, 10) Source(37, 37) + SourceIndex(0) --- >>> b = 1, 1->^^^^ @@ -679,9 +711,9 @@ sourceFile:../second/second_part1.ts 1->, 2 > b 3 > -1->Emitted(48, 5) Source(37, 39) + SourceIndex(0) -2 >Emitted(48, 6) Source(37, 40) + SourceIndex(0) -3 >Emitted(48, 10) Source(37, 40) + SourceIndex(0) +1->Emitted(49, 5) Source(37, 39) + SourceIndex(0) +2 >Emitted(49, 6) Source(37, 40) + SourceIndex(0) +3 >Emitted(49, 10) Source(37, 40) + SourceIndex(0) --- >>> c = 2 1->^^^^ @@ -690,15 +722,15 @@ sourceFile:../second/second_part1.ts 1->, 2 > c 3 > -1->Emitted(49, 5) Source(37, 42) + SourceIndex(0) -2 >Emitted(49, 6) Source(37, 43) + SourceIndex(0) -3 >Emitted(49, 10) Source(37, 43) + SourceIndex(0) +1->Emitted(50, 5) Source(37, 42) + SourceIndex(0) +2 >Emitted(50, 6) Source(37, 43) + SourceIndex(0) +3 >Emitted(50, 10) Source(37, 43) + SourceIndex(0) --- >>>} 1 >^ 2 > ^^^^^^^^^^^^^^^^^-> 1 > } -1 >Emitted(50, 2) Source(37, 45) + SourceIndex(0) +1 >Emitted(51, 2) Source(37, 45) + SourceIndex(0) --- ------------------------------------------------------------------- emittedFile:/src/2/second-output.d.ts @@ -712,9 +744,9 @@ sourceFile:../second/second_part2.ts 1-> 2 >class 3 > C -1->Emitted(51, 1) Source(1, 1) + SourceIndex(1) -2 >Emitted(51, 15) Source(1, 7) + SourceIndex(1) -3 >Emitted(51, 16) Source(1, 8) + SourceIndex(1) +1->Emitted(52, 1) Source(1, 1) + SourceIndex(1) +2 >Emitted(52, 15) Source(1, 7) + SourceIndex(1) +3 >Emitted(52, 16) Source(1, 8) + SourceIndex(1) --- >>> doSomething(): void; 1->^^^^ @@ -722,8 +754,8 @@ sourceFile:../second/second_part2.ts 1-> { > 2 > doSomething -1->Emitted(52, 5) Source(2, 5) + SourceIndex(1) -2 >Emitted(52, 16) Source(2, 16) + SourceIndex(1) +1->Emitted(53, 5) Source(2, 5) + SourceIndex(1) +2 >Emitted(53, 16) Source(2, 16) + SourceIndex(1) --- >>>} 1 >^ @@ -732,7 +764,7 @@ sourceFile:../second/second_part2.ts > console.log("something got done"); > } >} -1 >Emitted(53, 2) Source(5, 2) + SourceIndex(1) +1 >Emitted(54, 2) Source(5, 2) + SourceIndex(1) --- >>>//# sourceMappingURL=second-output.d.ts.map @@ -2316,32 +2348,32 @@ sourceFile:../second/second_part2.ts }, { "pos": 77, - "end": 151, + "end": 182, "kind": "internal" }, { - "pos": 153, - "end": 185, + "pos": 184, + "end": 216, "kind": "text" }, { - "pos": 185, - "end": 577, + "pos": 216, + "end": 608, "kind": "internal" }, { - "pos": 579, - "end": 582, + "pos": 610, + "end": 613, "kind": "text" }, { - "pos": 582, - "end": 995, + "pos": 613, + "end": 1026, "kind": "internal" }, { - "pos": 997, - "end": 1045, + "pos": 1028, + "end": 1076, "kind": "text" } ] @@ -2470,18 +2502,19 @@ declare namespace N { declare class normalC { ---------------------------------------------------------------------- -internal: (77-151) +internal: (77-182) constructor(); prop: string; method(): void; - c: number; + get c(): number; + set c(val: number); ---------------------------------------------------------------------- -text: (153-185) +text: (184-216) } declare namespace normalN { ---------------------------------------------------------------------- -internal: (185-577) +internal: (216-608) class C { } function foo(): void; @@ -2502,11 +2535,11 @@ internal: (185-577) c = 2 } ---------------------------------------------------------------------- -text: (579-582) +text: (610-613) } ---------------------------------------------------------------------- -internal: (582-995) +internal: (613-1026) declare class internalC { } declare function internalfoo(): void; @@ -2527,7 +2560,7 @@ declare enum internalEnum { c = 2 } ---------------------------------------------------------------------- -text: (997-1045) +text: (1028-1076) declare class C { doSomething(): void; } diff --git a/tests/baselines/reference/tsbuild/outfile-concat/initial-build/stripInternal-jsdoc-style-with-comments-emit-enabled-when-one-two-three-are-prepended-in-order.js b/tests/baselines/reference/tsbuild/outfile-concat/initial-build/stripInternal-jsdoc-style-with-comments-emit-enabled-when-one-two-three-are-prepended-in-order.js index 81653bf15bbec..27a636b0f7c2e 100644 --- a/tests/baselines/reference/tsbuild/outfile-concat/initial-build/stripInternal-jsdoc-style-with-comments-emit-enabled-when-one-two-three-are-prepended-in-order.js +++ b/tests/baselines/reference/tsbuild/outfile-concat/initial-build/stripInternal-jsdoc-style-with-comments-emit-enabled-when-one-two-three-are-prepended-in-order.js @@ -37,7 +37,8 @@ declare class normalC { /**@internal*/ constructor(); /**@internal*/ prop: string; /**@internal*/ method(): void; - /**@internal*/ /**@internal*/ c: number; + /**@internal*/ get c(): number; + /**@internal*/ set c(val: number); } declare namespace normalN { /**@internal*/ class C { @@ -85,7 +86,7 @@ declare class C { //# sourceMappingURL=second-output.d.ts.map //// [/src/2/second-output.d.ts.map] -{"version":3,"file":"second-output.d.ts","sourceRoot":"","sources":["../first/first_PART1.ts","../first/first_part3.ts","../second/second_part1.ts","../second/second_part2.ts"],"names":[],"mappings":"AAAA,cAAc,CAAC,UAAU,QAAQ;IAC7B,IAAI,EAAE,GAAG,CAAC;CACb;AAED,QAAA,MAAM,CAAC,iBAAiB,CAAC;AAEzB,UAAU,iBAAiB;IACvB,IAAI,EAAE,GAAG,CAAC;CACb;ACRD,iBAAS,CAAC,WAET;ACFD,kBAAU,CAAC,CAAC;CAEX;AAED,kBAAU,CAAC,CAAC;CAMX;AAED,cAAM,OAAO;IACT,cAAc;IACd,cAAc,CAAC,IAAI,EAAE,MAAM,CAAC;IAC5B,cAAc,CAAC,MAAM;IACrB,cAAc,gBAAK,CAAC,EACM,MAAM;CACnC;AACD,kBAAU,OAAO,CAAC;IACd,cAAc,CAAC,MAAa,CAAC;KAAI;IACjC,cAAc,CAAC,SAAgB,GAAG,SAAK;IACvC,cAAc,CAAC,UAAiB,aAAa,CAAC;QAAE,MAAa,CAAC;SAAG;KAAE;IACnE,cAAc,CAAC,UAAiB,SAAS,CAAC,SAAS,CAAC;QAAE,MAAa,SAAS;SAAG;KAAE;IACjF,cAAc,CAAC,MAAM,QAAQ,UAAU,GAAG,aAAa,CAAC,CAAC,CAAC;IAC1D,cAAc,CAAC,KAAY,YAAY,GAAG,SAAS,CAAC;IACpD,cAAc,CAAQ,MAAM,aAAa,KAAK,CAAC;IAC/C,cAAc,CAAC,KAAY,YAAY;QAAG,CAAC,IAAA;QAAE,CAAC,IAAA;QAAE,CAAC,IAAA;KAAE;CACtD;AACD,cAAc,CAAC,cAAM,SAAS;CAAG;AACjC,cAAc,CAAC,iBAAS,WAAW,SAAK;AACxC,cAAc,CAAC,kBAAU,iBAAiB,CAAC;IAAE,MAAa,SAAS;KAAG;CAAE;AACxE,cAAc,CAAC,kBAAU,aAAa,CAAC,SAAS,CAAC;IAAE,MAAa,SAAS;KAAG;CAAE;AAC9E,cAAc,CAAC,OAAO,cAAc,GAAG,iBAAiB,CAAC,SAAS,CAAC;AACnE,cAAc,CAAC,aAAK,YAAY,GAAG,SAAS,CAAC;AAC7C,cAAc,CAAC,QAAA,MAAM,aAAa,KAAK,CAAC;AACxC,cAAc,CAAC,aAAK,YAAY;IAAG,CAAC,IAAA;IAAE,CAAC,IAAA;IAAE,CAAC,IAAA;CAAE;ACpC5C,cAAM,CAAC;IACH,WAAW;CAGd"} +{"version":3,"file":"second-output.d.ts","sourceRoot":"","sources":["../first/first_PART1.ts","../first/first_part3.ts","../second/second_part1.ts","../second/second_part2.ts"],"names":[],"mappings":"AAAA,cAAc,CAAC,UAAU,QAAQ;IAC7B,IAAI,EAAE,GAAG,CAAC;CACb;AAED,QAAA,MAAM,CAAC,iBAAiB,CAAC;AAEzB,UAAU,iBAAiB;IACvB,IAAI,EAAE,GAAG,CAAC;CACb;ACRD,iBAAS,CAAC,WAET;ACFD,kBAAU,CAAC,CAAC;CAEX;AAED,kBAAU,CAAC,CAAC;CAMX;AAED,cAAM,OAAO;IACT,cAAc;IACd,cAAc,CAAC,IAAI,EAAE,MAAM,CAAC;IAC5B,cAAc,CAAC,MAAM;IACrB,cAAc,CAAC,IAAI,CAAC,IACM,MAAM,CADK;IACrC,cAAc,CAAC,IAAI,CAAC,CAAC,KAAK,MAAM,EAAK;CACxC;AACD,kBAAU,OAAO,CAAC;IACd,cAAc,CAAC,MAAa,CAAC;KAAI;IACjC,cAAc,CAAC,SAAgB,GAAG,SAAK;IACvC,cAAc,CAAC,UAAiB,aAAa,CAAC;QAAE,MAAa,CAAC;SAAG;KAAE;IACnE,cAAc,CAAC,UAAiB,SAAS,CAAC,SAAS,CAAC;QAAE,MAAa,SAAS;SAAG;KAAE;IACjF,cAAc,CAAC,MAAM,QAAQ,UAAU,GAAG,aAAa,CAAC,CAAC,CAAC;IAC1D,cAAc,CAAC,KAAY,YAAY,GAAG,SAAS,CAAC;IACpD,cAAc,CAAQ,MAAM,aAAa,KAAK,CAAC;IAC/C,cAAc,CAAC,KAAY,YAAY;QAAG,CAAC,IAAA;QAAE,CAAC,IAAA;QAAE,CAAC,IAAA;KAAE;CACtD;AACD,cAAc,CAAC,cAAM,SAAS;CAAG;AACjC,cAAc,CAAC,iBAAS,WAAW,SAAK;AACxC,cAAc,CAAC,kBAAU,iBAAiB,CAAC;IAAE,MAAa,SAAS;KAAG;CAAE;AACxE,cAAc,CAAC,kBAAU,aAAa,CAAC,SAAS,CAAC;IAAE,MAAa,SAAS;KAAG;CAAE;AAC9E,cAAc,CAAC,OAAO,cAAc,GAAG,iBAAiB,CAAC,SAAS,CAAC;AACnE,cAAc,CAAC,aAAK,YAAY,GAAG,SAAS,CAAC;AAC7C,cAAc,CAAC,QAAA,MAAM,aAAa,KAAK,CAAC;AACxC,cAAc,CAAC,aAAK,YAAY;IAAG,CAAC,IAAA;IAAE,CAAC,IAAA;IAAE,CAAC,IAAA;CAAE;ACpC5C,cAAM,CAAC;IACH,WAAW;CAGd"} //// [/src/2/second-output.d.ts.map.baseline.txt] =================================================================== @@ -328,7 +329,7 @@ sourceFile:../second/second_part1.ts 2 > ^^^^^^^^^^^^^^ 3 > ^ 4 > ^^^^^^ -5 > ^^^^^^^^^^^^^^^^^^^^-> +5 > ^^^^^^^^^^^-> 1-> > 2 > /**@internal*/ @@ -339,34 +340,71 @@ sourceFile:../second/second_part1.ts 3 >Emitted(16, 20) Source(16, 20) + SourceIndex(2) 4 >Emitted(16, 26) Source(16, 26) + SourceIndex(2) --- ->>> /**@internal*/ /**@internal*/ c: number; +>>> /**@internal*/ get c(): number; 1->^^^^ 2 > ^^^^^^^^^^^^^^ -3 > ^^^^^^^^^^^^^^^^ -4 > ^ -5 > ^^ -6 > ^^^^^^ +3 > ^ +4 > ^^^^ +5 > ^ +6 > ^^^^ +7 > ^^^^^^ +8 > ^ +9 > ^^^^-> 1->() { } > 2 > /**@internal*/ -3 > get -4 > c -5 > () { return 10; } - > /**@internal*/ set c(val: -6 > number +3 > +4 > get +5 > c +6 > () { return 10; } + > /**@internal*/ set c(val: +7 > number +8 > 1->Emitted(17, 5) Source(17, 5) + SourceIndex(2) 2 >Emitted(17, 19) Source(17, 19) + SourceIndex(2) -3 >Emitted(17, 35) Source(17, 24) + SourceIndex(2) -4 >Emitted(17, 36) Source(17, 25) + SourceIndex(2) -5 >Emitted(17, 38) Source(18, 31) + SourceIndex(2) -6 >Emitted(17, 44) Source(18, 37) + SourceIndex(2) +3 >Emitted(17, 20) Source(17, 20) + SourceIndex(2) +4 >Emitted(17, 24) Source(17, 24) + SourceIndex(2) +5 >Emitted(17, 25) Source(17, 25) + SourceIndex(2) +6 >Emitted(17, 29) Source(18, 31) + SourceIndex(2) +7 >Emitted(17, 35) Source(18, 37) + SourceIndex(2) +8 >Emitted(17, 36) Source(17, 42) + SourceIndex(2) +--- +>>> /**@internal*/ set c(val: number); +1->^^^^ +2 > ^^^^^^^^^^^^^^ +3 > ^ +4 > ^^^^ +5 > ^ +6 > ^ +7 > ^^^^^ +8 > ^^^^^^ +9 > ^^ +1-> + > +2 > /**@internal*/ +3 > +4 > set +5 > c +6 > ( +7 > val: +8 > number +9 > ) { } +1->Emitted(18, 5) Source(18, 5) + SourceIndex(2) +2 >Emitted(18, 19) Source(18, 19) + SourceIndex(2) +3 >Emitted(18, 20) Source(18, 20) + SourceIndex(2) +4 >Emitted(18, 24) Source(18, 24) + SourceIndex(2) +5 >Emitted(18, 25) Source(18, 25) + SourceIndex(2) +6 >Emitted(18, 26) Source(18, 26) + SourceIndex(2) +7 >Emitted(18, 31) Source(18, 31) + SourceIndex(2) +8 >Emitted(18, 37) Source(18, 37) + SourceIndex(2) +9 >Emitted(18, 39) Source(18, 42) + SourceIndex(2) --- >>>} 1 >^ 2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1 >) { } +1 > >} -1 >Emitted(18, 2) Source(19, 2) + SourceIndex(2) +1 >Emitted(19, 2) Source(19, 2) + SourceIndex(2) --- >>>declare namespace normalN { 1-> @@ -379,10 +417,10 @@ sourceFile:../second/second_part1.ts 2 >namespace 3 > normalN 4 > -1->Emitted(19, 1) Source(20, 1) + SourceIndex(2) -2 >Emitted(19, 19) Source(20, 11) + SourceIndex(2) -3 >Emitted(19, 26) Source(20, 18) + SourceIndex(2) -4 >Emitted(19, 27) Source(20, 19) + SourceIndex(2) +1->Emitted(20, 1) Source(20, 1) + SourceIndex(2) +2 >Emitted(20, 19) Source(20, 11) + SourceIndex(2) +3 >Emitted(20, 26) Source(20, 18) + SourceIndex(2) +4 >Emitted(20, 27) Source(20, 19) + SourceIndex(2) --- >>> /**@internal*/ class C { 1->^^^^ @@ -396,17 +434,17 @@ sourceFile:../second/second_part1.ts 3 > 4 > export class 5 > C -1->Emitted(20, 5) Source(21, 5) + SourceIndex(2) -2 >Emitted(20, 19) Source(21, 19) + SourceIndex(2) -3 >Emitted(20, 20) Source(21, 20) + SourceIndex(2) -4 >Emitted(20, 26) Source(21, 33) + SourceIndex(2) -5 >Emitted(20, 27) Source(21, 34) + SourceIndex(2) +1->Emitted(21, 5) Source(21, 5) + SourceIndex(2) +2 >Emitted(21, 19) Source(21, 19) + SourceIndex(2) +3 >Emitted(21, 20) Source(21, 20) + SourceIndex(2) +4 >Emitted(21, 26) Source(21, 33) + SourceIndex(2) +5 >Emitted(21, 27) Source(21, 34) + SourceIndex(2) --- >>> } 1 >^^^^^ 2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> 1 > { } -1 >Emitted(21, 6) Source(21, 38) + SourceIndex(2) +1 >Emitted(22, 6) Source(21, 38) + SourceIndex(2) --- >>> /**@internal*/ function foo(): void; 1->^^^^ @@ -423,12 +461,12 @@ sourceFile:../second/second_part1.ts 4 > export function 5 > foo 6 > () {} -1->Emitted(22, 5) Source(22, 5) + SourceIndex(2) -2 >Emitted(22, 19) Source(22, 19) + SourceIndex(2) -3 >Emitted(22, 20) Source(22, 20) + SourceIndex(2) -4 >Emitted(22, 29) Source(22, 36) + SourceIndex(2) -5 >Emitted(22, 32) Source(22, 39) + SourceIndex(2) -6 >Emitted(22, 41) Source(22, 44) + SourceIndex(2) +1->Emitted(23, 5) Source(22, 5) + SourceIndex(2) +2 >Emitted(23, 19) Source(22, 19) + SourceIndex(2) +3 >Emitted(23, 20) Source(22, 20) + SourceIndex(2) +4 >Emitted(23, 29) Source(22, 36) + SourceIndex(2) +5 >Emitted(23, 32) Source(22, 39) + SourceIndex(2) +6 >Emitted(23, 41) Source(22, 44) + SourceIndex(2) --- >>> /**@internal*/ namespace someNamespace { 1->^^^^ @@ -444,12 +482,12 @@ sourceFile:../second/second_part1.ts 4 > export namespace 5 > someNamespace 6 > -1->Emitted(23, 5) Source(23, 5) + SourceIndex(2) -2 >Emitted(23, 19) Source(23, 19) + SourceIndex(2) -3 >Emitted(23, 20) Source(23, 20) + SourceIndex(2) -4 >Emitted(23, 30) Source(23, 37) + SourceIndex(2) -5 >Emitted(23, 43) Source(23, 50) + SourceIndex(2) -6 >Emitted(23, 44) Source(23, 51) + SourceIndex(2) +1->Emitted(24, 5) Source(23, 5) + SourceIndex(2) +2 >Emitted(24, 19) Source(23, 19) + SourceIndex(2) +3 >Emitted(24, 20) Source(23, 20) + SourceIndex(2) +4 >Emitted(24, 30) Source(23, 37) + SourceIndex(2) +5 >Emitted(24, 43) Source(23, 50) + SourceIndex(2) +6 >Emitted(24, 44) Source(23, 51) + SourceIndex(2) --- >>> class C { 1 >^^^^^^^^ @@ -458,20 +496,20 @@ sourceFile:../second/second_part1.ts 1 >{ 2 > export class 3 > C -1 >Emitted(24, 9) Source(23, 53) + SourceIndex(2) -2 >Emitted(24, 15) Source(23, 66) + SourceIndex(2) -3 >Emitted(24, 16) Source(23, 67) + SourceIndex(2) +1 >Emitted(25, 9) Source(23, 53) + SourceIndex(2) +2 >Emitted(25, 15) Source(23, 66) + SourceIndex(2) +3 >Emitted(25, 16) Source(23, 67) + SourceIndex(2) --- >>> } 1 >^^^^^^^^^ 1 > {} -1 >Emitted(25, 10) Source(23, 70) + SourceIndex(2) +1 >Emitted(26, 10) Source(23, 70) + SourceIndex(2) --- >>> } 1 >^^^^^ 2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> 1 > } -1 >Emitted(26, 6) Source(23, 72) + SourceIndex(2) +1 >Emitted(27, 6) Source(23, 72) + SourceIndex(2) --- >>> /**@internal*/ namespace someOther.something { 1->^^^^ @@ -491,14 +529,14 @@ sourceFile:../second/second_part1.ts 6 > . 7 > something 8 > -1->Emitted(27, 5) Source(24, 5) + SourceIndex(2) -2 >Emitted(27, 19) Source(24, 19) + SourceIndex(2) -3 >Emitted(27, 20) Source(24, 20) + SourceIndex(2) -4 >Emitted(27, 30) Source(24, 37) + SourceIndex(2) -5 >Emitted(27, 39) Source(24, 46) + SourceIndex(2) -6 >Emitted(27, 40) Source(24, 47) + SourceIndex(2) -7 >Emitted(27, 49) Source(24, 56) + SourceIndex(2) -8 >Emitted(27, 50) Source(24, 57) + SourceIndex(2) +1->Emitted(28, 5) Source(24, 5) + SourceIndex(2) +2 >Emitted(28, 19) Source(24, 19) + SourceIndex(2) +3 >Emitted(28, 20) Source(24, 20) + SourceIndex(2) +4 >Emitted(28, 30) Source(24, 37) + SourceIndex(2) +5 >Emitted(28, 39) Source(24, 46) + SourceIndex(2) +6 >Emitted(28, 40) Source(24, 47) + SourceIndex(2) +7 >Emitted(28, 49) Source(24, 56) + SourceIndex(2) +8 >Emitted(28, 50) Source(24, 57) + SourceIndex(2) --- >>> class someClass { 1 >^^^^^^^^ @@ -507,20 +545,20 @@ sourceFile:../second/second_part1.ts 1 >{ 2 > export class 3 > someClass -1 >Emitted(28, 9) Source(24, 59) + SourceIndex(2) -2 >Emitted(28, 15) Source(24, 72) + SourceIndex(2) -3 >Emitted(28, 24) Source(24, 81) + SourceIndex(2) +1 >Emitted(29, 9) Source(24, 59) + SourceIndex(2) +2 >Emitted(29, 15) Source(24, 72) + SourceIndex(2) +3 >Emitted(29, 24) Source(24, 81) + SourceIndex(2) --- >>> } 1 >^^^^^^^^^ 1 > {} -1 >Emitted(29, 10) Source(24, 84) + SourceIndex(2) +1 >Emitted(30, 10) Source(24, 84) + SourceIndex(2) --- >>> } 1 >^^^^^ 2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> 1 > } -1 >Emitted(30, 6) Source(24, 86) + SourceIndex(2) +1 >Emitted(31, 6) Source(24, 86) + SourceIndex(2) --- >>> /**@internal*/ export import someImport = someNamespace.C; 1->^^^^ @@ -546,17 +584,17 @@ sourceFile:../second/second_part1.ts 9 > . 10> C 11> ; -1->Emitted(31, 5) Source(25, 5) + SourceIndex(2) -2 >Emitted(31, 19) Source(25, 19) + SourceIndex(2) -3 >Emitted(31, 20) Source(25, 20) + SourceIndex(2) -4 >Emitted(31, 26) Source(25, 26) + SourceIndex(2) -5 >Emitted(31, 34) Source(25, 34) + SourceIndex(2) -6 >Emitted(31, 44) Source(25, 44) + SourceIndex(2) -7 >Emitted(31, 47) Source(25, 47) + SourceIndex(2) -8 >Emitted(31, 60) Source(25, 60) + SourceIndex(2) -9 >Emitted(31, 61) Source(25, 61) + SourceIndex(2) -10>Emitted(31, 62) Source(25, 62) + SourceIndex(2) -11>Emitted(31, 63) Source(25, 63) + SourceIndex(2) +1->Emitted(32, 5) Source(25, 5) + SourceIndex(2) +2 >Emitted(32, 19) Source(25, 19) + SourceIndex(2) +3 >Emitted(32, 20) Source(25, 20) + SourceIndex(2) +4 >Emitted(32, 26) Source(25, 26) + SourceIndex(2) +5 >Emitted(32, 34) Source(25, 34) + SourceIndex(2) +6 >Emitted(32, 44) Source(25, 44) + SourceIndex(2) +7 >Emitted(32, 47) Source(25, 47) + SourceIndex(2) +8 >Emitted(32, 60) Source(25, 60) + SourceIndex(2) +9 >Emitted(32, 61) Source(25, 61) + SourceIndex(2) +10>Emitted(32, 62) Source(25, 62) + SourceIndex(2) +11>Emitted(32, 63) Source(25, 63) + SourceIndex(2) --- >>> /**@internal*/ type internalType = internalC; 1 >^^^^ @@ -576,14 +614,14 @@ sourceFile:../second/second_part1.ts 6 > = 7 > internalC 8 > ; -1 >Emitted(32, 5) Source(26, 5) + SourceIndex(2) -2 >Emitted(32, 19) Source(26, 19) + SourceIndex(2) -3 >Emitted(32, 20) Source(26, 20) + SourceIndex(2) -4 >Emitted(32, 25) Source(26, 32) + SourceIndex(2) -5 >Emitted(32, 37) Source(26, 44) + SourceIndex(2) -6 >Emitted(32, 40) Source(26, 47) + SourceIndex(2) -7 >Emitted(32, 49) Source(26, 56) + SourceIndex(2) -8 >Emitted(32, 50) Source(26, 57) + SourceIndex(2) +1 >Emitted(33, 5) Source(26, 5) + SourceIndex(2) +2 >Emitted(33, 19) Source(26, 19) + SourceIndex(2) +3 >Emitted(33, 20) Source(26, 20) + SourceIndex(2) +4 >Emitted(33, 25) Source(26, 32) + SourceIndex(2) +5 >Emitted(33, 37) Source(26, 44) + SourceIndex(2) +6 >Emitted(33, 40) Source(26, 47) + SourceIndex(2) +7 >Emitted(33, 49) Source(26, 56) + SourceIndex(2) +8 >Emitted(33, 50) Source(26, 57) + SourceIndex(2) --- >>> /**@internal*/ const internalConst = 10; 1 >^^^^ @@ -601,13 +639,13 @@ sourceFile:../second/second_part1.ts 5 > internalConst 6 > = 10 7 > ; -1 >Emitted(33, 5) Source(27, 5) + SourceIndex(2) -2 >Emitted(33, 19) Source(27, 19) + SourceIndex(2) -3 >Emitted(33, 20) Source(27, 27) + SourceIndex(2) -4 >Emitted(33, 26) Source(27, 33) + SourceIndex(2) -5 >Emitted(33, 39) Source(27, 46) + SourceIndex(2) -6 >Emitted(33, 44) Source(27, 51) + SourceIndex(2) -7 >Emitted(33, 45) Source(27, 52) + SourceIndex(2) +1 >Emitted(34, 5) Source(27, 5) + SourceIndex(2) +2 >Emitted(34, 19) Source(27, 19) + SourceIndex(2) +3 >Emitted(34, 20) Source(27, 27) + SourceIndex(2) +4 >Emitted(34, 26) Source(27, 33) + SourceIndex(2) +5 >Emitted(34, 39) Source(27, 46) + SourceIndex(2) +6 >Emitted(34, 44) Source(27, 51) + SourceIndex(2) +7 >Emitted(34, 45) Source(27, 52) + SourceIndex(2) --- >>> /**@internal*/ enum internalEnum { 1 >^^^^ @@ -621,11 +659,11 @@ sourceFile:../second/second_part1.ts 3 > 4 > export enum 5 > internalEnum -1 >Emitted(34, 5) Source(28, 5) + SourceIndex(2) -2 >Emitted(34, 19) Source(28, 19) + SourceIndex(2) -3 >Emitted(34, 20) Source(28, 20) + SourceIndex(2) -4 >Emitted(34, 25) Source(28, 32) + SourceIndex(2) -5 >Emitted(34, 37) Source(28, 44) + SourceIndex(2) +1 >Emitted(35, 5) Source(28, 5) + SourceIndex(2) +2 >Emitted(35, 19) Source(28, 19) + SourceIndex(2) +3 >Emitted(35, 20) Source(28, 20) + SourceIndex(2) +4 >Emitted(35, 25) Source(28, 32) + SourceIndex(2) +5 >Emitted(35, 37) Source(28, 44) + SourceIndex(2) --- >>> a = 0, 1 >^^^^^^^^ @@ -635,9 +673,9 @@ sourceFile:../second/second_part1.ts 1 > { 2 > a 3 > -1 >Emitted(35, 9) Source(28, 47) + SourceIndex(2) -2 >Emitted(35, 10) Source(28, 48) + SourceIndex(2) -3 >Emitted(35, 14) Source(28, 48) + SourceIndex(2) +1 >Emitted(36, 9) Source(28, 47) + SourceIndex(2) +2 >Emitted(36, 10) Source(28, 48) + SourceIndex(2) +3 >Emitted(36, 14) Source(28, 48) + SourceIndex(2) --- >>> b = 1, 1->^^^^^^^^ @@ -647,9 +685,9 @@ sourceFile:../second/second_part1.ts 1->, 2 > b 3 > -1->Emitted(36, 9) Source(28, 50) + SourceIndex(2) -2 >Emitted(36, 10) Source(28, 51) + SourceIndex(2) -3 >Emitted(36, 14) Source(28, 51) + SourceIndex(2) +1->Emitted(37, 9) Source(28, 50) + SourceIndex(2) +2 >Emitted(37, 10) Source(28, 51) + SourceIndex(2) +3 >Emitted(37, 14) Source(28, 51) + SourceIndex(2) --- >>> c = 2 1->^^^^^^^^ @@ -658,21 +696,21 @@ sourceFile:../second/second_part1.ts 1->, 2 > c 3 > -1->Emitted(37, 9) Source(28, 53) + SourceIndex(2) -2 >Emitted(37, 10) Source(28, 54) + SourceIndex(2) -3 >Emitted(37, 14) Source(28, 54) + SourceIndex(2) +1->Emitted(38, 9) Source(28, 53) + SourceIndex(2) +2 >Emitted(38, 10) Source(28, 54) + SourceIndex(2) +3 >Emitted(38, 14) Source(28, 54) + SourceIndex(2) --- >>> } 1 >^^^^^ 1 > } -1 >Emitted(38, 6) Source(28, 56) + SourceIndex(2) +1 >Emitted(39, 6) Source(28, 56) + SourceIndex(2) --- >>>} 1 >^ 2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> 1 > >} -1 >Emitted(39, 2) Source(29, 2) + SourceIndex(2) +1 >Emitted(40, 2) Source(29, 2) + SourceIndex(2) --- >>>/**@internal*/ declare class internalC { 1-> @@ -686,17 +724,17 @@ sourceFile:../second/second_part1.ts 3 > 4 > class 5 > internalC -1->Emitted(40, 1) Source(30, 1) + SourceIndex(2) -2 >Emitted(40, 15) Source(30, 15) + SourceIndex(2) -3 >Emitted(40, 16) Source(30, 16) + SourceIndex(2) -4 >Emitted(40, 30) Source(30, 22) + SourceIndex(2) -5 >Emitted(40, 39) Source(30, 31) + SourceIndex(2) +1->Emitted(41, 1) Source(30, 1) + SourceIndex(2) +2 >Emitted(41, 15) Source(30, 15) + SourceIndex(2) +3 >Emitted(41, 16) Source(30, 16) + SourceIndex(2) +4 >Emitted(41, 30) Source(30, 22) + SourceIndex(2) +5 >Emitted(41, 39) Source(30, 31) + SourceIndex(2) --- >>>} 1 >^ 2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> 1 > {} -1 >Emitted(41, 2) Source(30, 34) + SourceIndex(2) +1 >Emitted(42, 2) Source(30, 34) + SourceIndex(2) --- >>>/**@internal*/ declare function internalfoo(): void; 1-> @@ -713,12 +751,12 @@ sourceFile:../second/second_part1.ts 4 > function 5 > internalfoo 6 > () {} -1->Emitted(42, 1) Source(31, 1) + SourceIndex(2) -2 >Emitted(42, 15) Source(31, 15) + SourceIndex(2) -3 >Emitted(42, 16) Source(31, 16) + SourceIndex(2) -4 >Emitted(42, 33) Source(31, 25) + SourceIndex(2) -5 >Emitted(42, 44) Source(31, 36) + SourceIndex(2) -6 >Emitted(42, 53) Source(31, 41) + SourceIndex(2) +1->Emitted(43, 1) Source(31, 1) + SourceIndex(2) +2 >Emitted(43, 15) Source(31, 15) + SourceIndex(2) +3 >Emitted(43, 16) Source(31, 16) + SourceIndex(2) +4 >Emitted(43, 33) Source(31, 25) + SourceIndex(2) +5 >Emitted(43, 44) Source(31, 36) + SourceIndex(2) +6 >Emitted(43, 53) Source(31, 41) + SourceIndex(2) --- >>>/**@internal*/ declare namespace internalNamespace { 1-> @@ -734,12 +772,12 @@ sourceFile:../second/second_part1.ts 4 > namespace 5 > internalNamespace 6 > -1->Emitted(43, 1) Source(32, 1) + SourceIndex(2) -2 >Emitted(43, 15) Source(32, 15) + SourceIndex(2) -3 >Emitted(43, 16) Source(32, 16) + SourceIndex(2) -4 >Emitted(43, 34) Source(32, 26) + SourceIndex(2) -5 >Emitted(43, 51) Source(32, 43) + SourceIndex(2) -6 >Emitted(43, 52) Source(32, 44) + SourceIndex(2) +1->Emitted(44, 1) Source(32, 1) + SourceIndex(2) +2 >Emitted(44, 15) Source(32, 15) + SourceIndex(2) +3 >Emitted(44, 16) Source(32, 16) + SourceIndex(2) +4 >Emitted(44, 34) Source(32, 26) + SourceIndex(2) +5 >Emitted(44, 51) Source(32, 43) + SourceIndex(2) +6 >Emitted(44, 52) Source(32, 44) + SourceIndex(2) --- >>> class someClass { 1 >^^^^ @@ -748,20 +786,20 @@ sourceFile:../second/second_part1.ts 1 >{ 2 > export class 3 > someClass -1 >Emitted(44, 5) Source(32, 46) + SourceIndex(2) -2 >Emitted(44, 11) Source(32, 59) + SourceIndex(2) -3 >Emitted(44, 20) Source(32, 68) + SourceIndex(2) +1 >Emitted(45, 5) Source(32, 46) + SourceIndex(2) +2 >Emitted(45, 11) Source(32, 59) + SourceIndex(2) +3 >Emitted(45, 20) Source(32, 68) + SourceIndex(2) --- >>> } 1 >^^^^^ 1 > {} -1 >Emitted(45, 6) Source(32, 71) + SourceIndex(2) +1 >Emitted(46, 6) Source(32, 71) + SourceIndex(2) --- >>>} 1 >^ 2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> 1 > } -1 >Emitted(46, 2) Source(32, 73) + SourceIndex(2) +1 >Emitted(47, 2) Source(32, 73) + SourceIndex(2) --- >>>/**@internal*/ declare namespace internalOther.something { 1-> @@ -781,14 +819,14 @@ sourceFile:../second/second_part1.ts 6 > . 7 > something 8 > -1->Emitted(47, 1) Source(33, 1) + SourceIndex(2) -2 >Emitted(47, 15) Source(33, 15) + SourceIndex(2) -3 >Emitted(47, 16) Source(33, 16) + SourceIndex(2) -4 >Emitted(47, 34) Source(33, 26) + SourceIndex(2) -5 >Emitted(47, 47) Source(33, 39) + SourceIndex(2) -6 >Emitted(47, 48) Source(33, 40) + SourceIndex(2) -7 >Emitted(47, 57) Source(33, 49) + SourceIndex(2) -8 >Emitted(47, 58) Source(33, 50) + SourceIndex(2) +1->Emitted(48, 1) Source(33, 1) + SourceIndex(2) +2 >Emitted(48, 15) Source(33, 15) + SourceIndex(2) +3 >Emitted(48, 16) Source(33, 16) + SourceIndex(2) +4 >Emitted(48, 34) Source(33, 26) + SourceIndex(2) +5 >Emitted(48, 47) Source(33, 39) + SourceIndex(2) +6 >Emitted(48, 48) Source(33, 40) + SourceIndex(2) +7 >Emitted(48, 57) Source(33, 49) + SourceIndex(2) +8 >Emitted(48, 58) Source(33, 50) + SourceIndex(2) --- >>> class someClass { 1 >^^^^ @@ -797,20 +835,20 @@ sourceFile:../second/second_part1.ts 1 >{ 2 > export class 3 > someClass -1 >Emitted(48, 5) Source(33, 52) + SourceIndex(2) -2 >Emitted(48, 11) Source(33, 65) + SourceIndex(2) -3 >Emitted(48, 20) Source(33, 74) + SourceIndex(2) +1 >Emitted(49, 5) Source(33, 52) + SourceIndex(2) +2 >Emitted(49, 11) Source(33, 65) + SourceIndex(2) +3 >Emitted(49, 20) Source(33, 74) + SourceIndex(2) --- >>> } 1 >^^^^^ 1 > {} -1 >Emitted(49, 6) Source(33, 77) + SourceIndex(2) +1 >Emitted(50, 6) Source(33, 77) + SourceIndex(2) --- >>>} 1 >^ 2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> 1 > } -1 >Emitted(50, 2) Source(33, 79) + SourceIndex(2) +1 >Emitted(51, 2) Source(33, 79) + SourceIndex(2) --- >>>/**@internal*/ import internalImport = internalNamespace.someClass; 1-> @@ -834,16 +872,16 @@ sourceFile:../second/second_part1.ts 8 > . 9 > someClass 10> ; -1->Emitted(51, 1) Source(34, 1) + SourceIndex(2) -2 >Emitted(51, 15) Source(34, 15) + SourceIndex(2) -3 >Emitted(51, 16) Source(34, 16) + SourceIndex(2) -4 >Emitted(51, 23) Source(34, 23) + SourceIndex(2) -5 >Emitted(51, 37) Source(34, 37) + SourceIndex(2) -6 >Emitted(51, 40) Source(34, 40) + SourceIndex(2) -7 >Emitted(51, 57) Source(34, 57) + SourceIndex(2) -8 >Emitted(51, 58) Source(34, 58) + SourceIndex(2) -9 >Emitted(51, 67) Source(34, 67) + SourceIndex(2) -10>Emitted(51, 68) Source(34, 68) + SourceIndex(2) +1->Emitted(52, 1) Source(34, 1) + SourceIndex(2) +2 >Emitted(52, 15) Source(34, 15) + SourceIndex(2) +3 >Emitted(52, 16) Source(34, 16) + SourceIndex(2) +4 >Emitted(52, 23) Source(34, 23) + SourceIndex(2) +5 >Emitted(52, 37) Source(34, 37) + SourceIndex(2) +6 >Emitted(52, 40) Source(34, 40) + SourceIndex(2) +7 >Emitted(52, 57) Source(34, 57) + SourceIndex(2) +8 >Emitted(52, 58) Source(34, 58) + SourceIndex(2) +9 >Emitted(52, 67) Source(34, 67) + SourceIndex(2) +10>Emitted(52, 68) Source(34, 68) + SourceIndex(2) --- >>>/**@internal*/ declare type internalType = internalC; 1 > @@ -863,14 +901,14 @@ sourceFile:../second/second_part1.ts 6 > = 7 > internalC 8 > ; -1 >Emitted(52, 1) Source(35, 1) + SourceIndex(2) -2 >Emitted(52, 15) Source(35, 15) + SourceIndex(2) -3 >Emitted(52, 16) Source(35, 16) + SourceIndex(2) -4 >Emitted(52, 29) Source(35, 21) + SourceIndex(2) -5 >Emitted(52, 41) Source(35, 33) + SourceIndex(2) -6 >Emitted(52, 44) Source(35, 36) + SourceIndex(2) -7 >Emitted(52, 53) Source(35, 45) + SourceIndex(2) -8 >Emitted(52, 54) Source(35, 46) + SourceIndex(2) +1 >Emitted(53, 1) Source(35, 1) + SourceIndex(2) +2 >Emitted(53, 15) Source(35, 15) + SourceIndex(2) +3 >Emitted(53, 16) Source(35, 16) + SourceIndex(2) +4 >Emitted(53, 29) Source(35, 21) + SourceIndex(2) +5 >Emitted(53, 41) Source(35, 33) + SourceIndex(2) +6 >Emitted(53, 44) Source(35, 36) + SourceIndex(2) +7 >Emitted(53, 53) Source(35, 45) + SourceIndex(2) +8 >Emitted(53, 54) Source(35, 46) + SourceIndex(2) --- >>>/**@internal*/ declare const internalConst = 10; 1 > @@ -890,14 +928,14 @@ sourceFile:../second/second_part1.ts 6 > internalConst 7 > = 10 8 > ; -1 >Emitted(53, 1) Source(36, 1) + SourceIndex(2) -2 >Emitted(53, 15) Source(36, 15) + SourceIndex(2) -3 >Emitted(53, 16) Source(36, 16) + SourceIndex(2) -4 >Emitted(53, 24) Source(36, 16) + SourceIndex(2) -5 >Emitted(53, 30) Source(36, 22) + SourceIndex(2) -6 >Emitted(53, 43) Source(36, 35) + SourceIndex(2) -7 >Emitted(53, 48) Source(36, 40) + SourceIndex(2) -8 >Emitted(53, 49) Source(36, 41) + SourceIndex(2) +1 >Emitted(54, 1) Source(36, 1) + SourceIndex(2) +2 >Emitted(54, 15) Source(36, 15) + SourceIndex(2) +3 >Emitted(54, 16) Source(36, 16) + SourceIndex(2) +4 >Emitted(54, 24) Source(36, 16) + SourceIndex(2) +5 >Emitted(54, 30) Source(36, 22) + SourceIndex(2) +6 >Emitted(54, 43) Source(36, 35) + SourceIndex(2) +7 >Emitted(54, 48) Source(36, 40) + SourceIndex(2) +8 >Emitted(54, 49) Source(36, 41) + SourceIndex(2) --- >>>/**@internal*/ declare enum internalEnum { 1 > @@ -911,11 +949,11 @@ sourceFile:../second/second_part1.ts 3 > 4 > enum 5 > internalEnum -1 >Emitted(54, 1) Source(37, 1) + SourceIndex(2) -2 >Emitted(54, 15) Source(37, 15) + SourceIndex(2) -3 >Emitted(54, 16) Source(37, 16) + SourceIndex(2) -4 >Emitted(54, 29) Source(37, 21) + SourceIndex(2) -5 >Emitted(54, 41) Source(37, 33) + SourceIndex(2) +1 >Emitted(55, 1) Source(37, 1) + SourceIndex(2) +2 >Emitted(55, 15) Source(37, 15) + SourceIndex(2) +3 >Emitted(55, 16) Source(37, 16) + SourceIndex(2) +4 >Emitted(55, 29) Source(37, 21) + SourceIndex(2) +5 >Emitted(55, 41) Source(37, 33) + SourceIndex(2) --- >>> a = 0, 1 >^^^^ @@ -925,9 +963,9 @@ sourceFile:../second/second_part1.ts 1 > { 2 > a 3 > -1 >Emitted(55, 5) Source(37, 36) + SourceIndex(2) -2 >Emitted(55, 6) Source(37, 37) + SourceIndex(2) -3 >Emitted(55, 10) Source(37, 37) + SourceIndex(2) +1 >Emitted(56, 5) Source(37, 36) + SourceIndex(2) +2 >Emitted(56, 6) Source(37, 37) + SourceIndex(2) +3 >Emitted(56, 10) Source(37, 37) + SourceIndex(2) --- >>> b = 1, 1->^^^^ @@ -937,9 +975,9 @@ sourceFile:../second/second_part1.ts 1->, 2 > b 3 > -1->Emitted(56, 5) Source(37, 39) + SourceIndex(2) -2 >Emitted(56, 6) Source(37, 40) + SourceIndex(2) -3 >Emitted(56, 10) Source(37, 40) + SourceIndex(2) +1->Emitted(57, 5) Source(37, 39) + SourceIndex(2) +2 >Emitted(57, 6) Source(37, 40) + SourceIndex(2) +3 >Emitted(57, 10) Source(37, 40) + SourceIndex(2) --- >>> c = 2 1->^^^^ @@ -948,15 +986,15 @@ sourceFile:../second/second_part1.ts 1->, 2 > c 3 > -1->Emitted(57, 5) Source(37, 42) + SourceIndex(2) -2 >Emitted(57, 6) Source(37, 43) + SourceIndex(2) -3 >Emitted(57, 10) Source(37, 43) + SourceIndex(2) +1->Emitted(58, 5) Source(37, 42) + SourceIndex(2) +2 >Emitted(58, 6) Source(37, 43) + SourceIndex(2) +3 >Emitted(58, 10) Source(37, 43) + SourceIndex(2) --- >>>} 1 >^ 2 > ^^^^^^^^^^^^^^^^^-> 1 > } -1 >Emitted(58, 2) Source(37, 45) + SourceIndex(2) +1 >Emitted(59, 2) Source(37, 45) + SourceIndex(2) --- ------------------------------------------------------------------- emittedFile:/src/2/second-output.d.ts @@ -970,9 +1008,9 @@ sourceFile:../second/second_part2.ts 1-> 2 >class 3 > C -1->Emitted(59, 1) Source(1, 1) + SourceIndex(3) -2 >Emitted(59, 15) Source(1, 7) + SourceIndex(3) -3 >Emitted(59, 16) Source(1, 8) + SourceIndex(3) +1->Emitted(60, 1) Source(1, 1) + SourceIndex(3) +2 >Emitted(60, 15) Source(1, 7) + SourceIndex(3) +3 >Emitted(60, 16) Source(1, 8) + SourceIndex(3) --- >>> doSomething(): void; 1->^^^^ @@ -980,8 +1018,8 @@ sourceFile:../second/second_part2.ts 1-> { > 2 > doSomething -1->Emitted(60, 5) Source(2, 5) + SourceIndex(3) -2 >Emitted(60, 16) Source(2, 16) + SourceIndex(3) +1->Emitted(61, 5) Source(2, 5) + SourceIndex(3) +2 >Emitted(61, 16) Source(2, 16) + SourceIndex(3) --- >>>} 1 >^ @@ -990,7 +1028,7 @@ sourceFile:../second/second_part2.ts > console.log("something got done"); > } >} -1 >Emitted(61, 2) Source(5, 2) + SourceIndex(3) +1 >Emitted(62, 2) Source(5, 2) + SourceIndex(3) --- >>>//# sourceMappingURL=second-output.d.ts.map @@ -2846,32 +2884,32 @@ sourceFile:../second/second_part2.ts }, { "pos": 249, - "end": 398, + "end": 429, "kind": "internal" }, { - "pos": 400, - "end": 432, + "pos": 431, + "end": 463, "kind": "text" }, { - "pos": 432, - "end": 944, + "pos": 463, + "end": 975, "kind": "internal" }, { - "pos": 946, - "end": 949, + "pos": 977, + "end": 980, "kind": "text" }, { - "pos": 949, - "end": 1482, + "pos": 980, + "end": 1513, "kind": "internal" }, { - "pos": 1484, - "end": 1532, + "pos": 1515, + "end": 1563, "kind": "text" } ] @@ -3026,18 +3064,19 @@ declare namespace N { declare class normalC { ---------------------------------------------------------------------- -internal: (249-398) +internal: (249-429) /**@internal*/ constructor(); /**@internal*/ prop: string; /**@internal*/ method(): void; - /**@internal*/ /**@internal*/ c: number; + /**@internal*/ get c(): number; + /**@internal*/ set c(val: number); ---------------------------------------------------------------------- -text: (400-432) +text: (431-463) } declare namespace normalN { ---------------------------------------------------------------------- -internal: (432-944) +internal: (463-975) /**@internal*/ class C { } /**@internal*/ function foo(): void; @@ -3058,11 +3097,11 @@ internal: (432-944) c = 2 } ---------------------------------------------------------------------- -text: (946-949) +text: (977-980) } ---------------------------------------------------------------------- -internal: (949-1482) +internal: (980-1513) /**@internal*/ declare class internalC { } /**@internal*/ declare function internalfoo(): void; @@ -3083,7 +3122,7 @@ internal: (949-1482) c = 2 } ---------------------------------------------------------------------- -text: (1484-1532) +text: (1515-1563) declare class C { doSomething(): void; } diff --git a/tests/baselines/reference/tsbuild/outfile-concat/initial-build/stripInternal-jsdoc-style-with-comments-emit-enabled.js b/tests/baselines/reference/tsbuild/outfile-concat/initial-build/stripInternal-jsdoc-style-with-comments-emit-enabled.js index e86999f7bf452..ae47b9248255f 100644 --- a/tests/baselines/reference/tsbuild/outfile-concat/initial-build/stripInternal-jsdoc-style-with-comments-emit-enabled.js +++ b/tests/baselines/reference/tsbuild/outfile-concat/initial-build/stripInternal-jsdoc-style-with-comments-emit-enabled.js @@ -29,7 +29,8 @@ declare class normalC { /**@internal*/ constructor(); /**@internal*/ prop: string; /**@internal*/ method(): void; - /**@internal*/ /**@internal*/ c: number; + /**@internal*/ get c(): number; + /**@internal*/ set c(val: number); } declare namespace normalN { /**@internal*/ class C { @@ -77,7 +78,7 @@ declare class C { //# sourceMappingURL=second-output.d.ts.map //// [/src/2/second-output.d.ts.map] -{"version":3,"file":"second-output.d.ts","sourceRoot":"","sources":["../second/second_part1.ts","../second/second_part2.ts"],"names":[],"mappings":"AAAA,kBAAU,CAAC,CAAC;CAEX;AAED,kBAAU,CAAC,CAAC;CAMX;AAED,cAAM,OAAO;IACT,cAAc;IACd,cAAc,CAAC,IAAI,EAAE,MAAM,CAAC;IAC5B,cAAc,CAAC,MAAM;IACrB,cAAc,gBAAK,CAAC,EACM,MAAM;CACnC;AACD,kBAAU,OAAO,CAAC;IACd,cAAc,CAAC,MAAa,CAAC;KAAI;IACjC,cAAc,CAAC,SAAgB,GAAG,SAAK;IACvC,cAAc,CAAC,UAAiB,aAAa,CAAC;QAAE,MAAa,CAAC;SAAG;KAAE;IACnE,cAAc,CAAC,UAAiB,SAAS,CAAC,SAAS,CAAC;QAAE,MAAa,SAAS;SAAG;KAAE;IACjF,cAAc,CAAC,MAAM,QAAQ,UAAU,GAAG,aAAa,CAAC,CAAC,CAAC;IAC1D,cAAc,CAAC,KAAY,YAAY,GAAG,SAAS,CAAC;IACpD,cAAc,CAAQ,MAAM,aAAa,KAAK,CAAC;IAC/C,cAAc,CAAC,KAAY,YAAY;QAAG,CAAC,IAAA;QAAE,CAAC,IAAA;QAAE,CAAC,IAAA;KAAE;CACtD;AACD,cAAc,CAAC,cAAM,SAAS;CAAG;AACjC,cAAc,CAAC,iBAAS,WAAW,SAAK;AACxC,cAAc,CAAC,kBAAU,iBAAiB,CAAC;IAAE,MAAa,SAAS;KAAG;CAAE;AACxE,cAAc,CAAC,kBAAU,aAAa,CAAC,SAAS,CAAC;IAAE,MAAa,SAAS;KAAG;CAAE;AAC9E,cAAc,CAAC,OAAO,cAAc,GAAG,iBAAiB,CAAC,SAAS,CAAC;AACnE,cAAc,CAAC,aAAK,YAAY,GAAG,SAAS,CAAC;AAC7C,cAAc,CAAC,QAAA,MAAM,aAAa,KAAK,CAAC;AACxC,cAAc,CAAC,aAAK,YAAY;IAAG,CAAC,IAAA;IAAE,CAAC,IAAA;IAAE,CAAC,IAAA;CAAE;ACpC5C,cAAM,CAAC;IACH,WAAW;CAGd"} +{"version":3,"file":"second-output.d.ts","sourceRoot":"","sources":["../second/second_part1.ts","../second/second_part2.ts"],"names":[],"mappings":"AAAA,kBAAU,CAAC,CAAC;CAEX;AAED,kBAAU,CAAC,CAAC;CAMX;AAED,cAAM,OAAO;IACT,cAAc;IACd,cAAc,CAAC,IAAI,EAAE,MAAM,CAAC;IAC5B,cAAc,CAAC,MAAM;IACrB,cAAc,CAAC,IAAI,CAAC,IACM,MAAM,CADK;IACrC,cAAc,CAAC,IAAI,CAAC,CAAC,KAAK,MAAM,EAAK;CACxC;AACD,kBAAU,OAAO,CAAC;IACd,cAAc,CAAC,MAAa,CAAC;KAAI;IACjC,cAAc,CAAC,SAAgB,GAAG,SAAK;IACvC,cAAc,CAAC,UAAiB,aAAa,CAAC;QAAE,MAAa,CAAC;SAAG;KAAE;IACnE,cAAc,CAAC,UAAiB,SAAS,CAAC,SAAS,CAAC;QAAE,MAAa,SAAS;SAAG;KAAE;IACjF,cAAc,CAAC,MAAM,QAAQ,UAAU,GAAG,aAAa,CAAC,CAAC,CAAC;IAC1D,cAAc,CAAC,KAAY,YAAY,GAAG,SAAS,CAAC;IACpD,cAAc,CAAQ,MAAM,aAAa,KAAK,CAAC;IAC/C,cAAc,CAAC,KAAY,YAAY;QAAG,CAAC,IAAA;QAAE,CAAC,IAAA;QAAE,CAAC,IAAA;KAAE;CACtD;AACD,cAAc,CAAC,cAAM,SAAS;CAAG;AACjC,cAAc,CAAC,iBAAS,WAAW,SAAK;AACxC,cAAc,CAAC,kBAAU,iBAAiB,CAAC;IAAE,MAAa,SAAS;KAAG;CAAE;AACxE,cAAc,CAAC,kBAAU,aAAa,CAAC,SAAS,CAAC;IAAE,MAAa,SAAS;KAAG;CAAE;AAC9E,cAAc,CAAC,OAAO,cAAc,GAAG,iBAAiB,CAAC,SAAS,CAAC;AACnE,cAAc,CAAC,aAAK,YAAY,GAAG,SAAS,CAAC;AAC7C,cAAc,CAAC,QAAA,MAAM,aAAa,KAAK,CAAC;AACxC,cAAc,CAAC,aAAK,YAAY;IAAG,CAAC,IAAA;IAAE,CAAC,IAAA;IAAE,CAAC,IAAA;CAAE;ACpC5C,cAAM,CAAC;IACH,WAAW;CAGd"} //// [/src/2/second-output.d.ts.map.baseline.txt] =================================================================== @@ -194,7 +195,7 @@ sourceFile:../second/second_part1.ts 2 > ^^^^^^^^^^^^^^ 3 > ^ 4 > ^^^^^^ -5 > ^^^^^^^^^^^^^^^^^^^^-> +5 > ^^^^^^^^^^^-> 1-> > 2 > /**@internal*/ @@ -205,34 +206,71 @@ sourceFile:../second/second_part1.ts 3 >Emitted(8, 20) Source(16, 20) + SourceIndex(0) 4 >Emitted(8, 26) Source(16, 26) + SourceIndex(0) --- ->>> /**@internal*/ /**@internal*/ c: number; +>>> /**@internal*/ get c(): number; 1->^^^^ 2 > ^^^^^^^^^^^^^^ -3 > ^^^^^^^^^^^^^^^^ -4 > ^ -5 > ^^ -6 > ^^^^^^ +3 > ^ +4 > ^^^^ +5 > ^ +6 > ^^^^ +7 > ^^^^^^ +8 > ^ +9 > ^^^^-> 1->() { } > 2 > /**@internal*/ -3 > get -4 > c -5 > () { return 10; } - > /**@internal*/ set c(val: -6 > number +3 > +4 > get +5 > c +6 > () { return 10; } + > /**@internal*/ set c(val: +7 > number +8 > 1->Emitted(9, 5) Source(17, 5) + SourceIndex(0) 2 >Emitted(9, 19) Source(17, 19) + SourceIndex(0) -3 >Emitted(9, 35) Source(17, 24) + SourceIndex(0) -4 >Emitted(9, 36) Source(17, 25) + SourceIndex(0) -5 >Emitted(9, 38) Source(18, 31) + SourceIndex(0) -6 >Emitted(9, 44) Source(18, 37) + SourceIndex(0) +3 >Emitted(9, 20) Source(17, 20) + SourceIndex(0) +4 >Emitted(9, 24) Source(17, 24) + SourceIndex(0) +5 >Emitted(9, 25) Source(17, 25) + SourceIndex(0) +6 >Emitted(9, 29) Source(18, 31) + SourceIndex(0) +7 >Emitted(9, 35) Source(18, 37) + SourceIndex(0) +8 >Emitted(9, 36) Source(17, 42) + SourceIndex(0) +--- +>>> /**@internal*/ set c(val: number); +1->^^^^ +2 > ^^^^^^^^^^^^^^ +3 > ^ +4 > ^^^^ +5 > ^ +6 > ^ +7 > ^^^^^ +8 > ^^^^^^ +9 > ^^ +1-> + > +2 > /**@internal*/ +3 > +4 > set +5 > c +6 > ( +7 > val: +8 > number +9 > ) { } +1->Emitted(10, 5) Source(18, 5) + SourceIndex(0) +2 >Emitted(10, 19) Source(18, 19) + SourceIndex(0) +3 >Emitted(10, 20) Source(18, 20) + SourceIndex(0) +4 >Emitted(10, 24) Source(18, 24) + SourceIndex(0) +5 >Emitted(10, 25) Source(18, 25) + SourceIndex(0) +6 >Emitted(10, 26) Source(18, 26) + SourceIndex(0) +7 >Emitted(10, 31) Source(18, 31) + SourceIndex(0) +8 >Emitted(10, 37) Source(18, 37) + SourceIndex(0) +9 >Emitted(10, 39) Source(18, 42) + SourceIndex(0) --- >>>} 1 >^ 2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1 >) { } +1 > >} -1 >Emitted(10, 2) Source(19, 2) + SourceIndex(0) +1 >Emitted(11, 2) Source(19, 2) + SourceIndex(0) --- >>>declare namespace normalN { 1-> @@ -245,10 +283,10 @@ sourceFile:../second/second_part1.ts 2 >namespace 3 > normalN 4 > -1->Emitted(11, 1) Source(20, 1) + SourceIndex(0) -2 >Emitted(11, 19) Source(20, 11) + SourceIndex(0) -3 >Emitted(11, 26) Source(20, 18) + SourceIndex(0) -4 >Emitted(11, 27) Source(20, 19) + SourceIndex(0) +1->Emitted(12, 1) Source(20, 1) + SourceIndex(0) +2 >Emitted(12, 19) Source(20, 11) + SourceIndex(0) +3 >Emitted(12, 26) Source(20, 18) + SourceIndex(0) +4 >Emitted(12, 27) Source(20, 19) + SourceIndex(0) --- >>> /**@internal*/ class C { 1->^^^^ @@ -262,17 +300,17 @@ sourceFile:../second/second_part1.ts 3 > 4 > export class 5 > C -1->Emitted(12, 5) Source(21, 5) + SourceIndex(0) -2 >Emitted(12, 19) Source(21, 19) + SourceIndex(0) -3 >Emitted(12, 20) Source(21, 20) + SourceIndex(0) -4 >Emitted(12, 26) Source(21, 33) + SourceIndex(0) -5 >Emitted(12, 27) Source(21, 34) + SourceIndex(0) +1->Emitted(13, 5) Source(21, 5) + SourceIndex(0) +2 >Emitted(13, 19) Source(21, 19) + SourceIndex(0) +3 >Emitted(13, 20) Source(21, 20) + SourceIndex(0) +4 >Emitted(13, 26) Source(21, 33) + SourceIndex(0) +5 >Emitted(13, 27) Source(21, 34) + SourceIndex(0) --- >>> } 1 >^^^^^ 2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> 1 > { } -1 >Emitted(13, 6) Source(21, 38) + SourceIndex(0) +1 >Emitted(14, 6) Source(21, 38) + SourceIndex(0) --- >>> /**@internal*/ function foo(): void; 1->^^^^ @@ -289,12 +327,12 @@ sourceFile:../second/second_part1.ts 4 > export function 5 > foo 6 > () {} -1->Emitted(14, 5) Source(22, 5) + SourceIndex(0) -2 >Emitted(14, 19) Source(22, 19) + SourceIndex(0) -3 >Emitted(14, 20) Source(22, 20) + SourceIndex(0) -4 >Emitted(14, 29) Source(22, 36) + SourceIndex(0) -5 >Emitted(14, 32) Source(22, 39) + SourceIndex(0) -6 >Emitted(14, 41) Source(22, 44) + SourceIndex(0) +1->Emitted(15, 5) Source(22, 5) + SourceIndex(0) +2 >Emitted(15, 19) Source(22, 19) + SourceIndex(0) +3 >Emitted(15, 20) Source(22, 20) + SourceIndex(0) +4 >Emitted(15, 29) Source(22, 36) + SourceIndex(0) +5 >Emitted(15, 32) Source(22, 39) + SourceIndex(0) +6 >Emitted(15, 41) Source(22, 44) + SourceIndex(0) --- >>> /**@internal*/ namespace someNamespace { 1->^^^^ @@ -310,12 +348,12 @@ sourceFile:../second/second_part1.ts 4 > export namespace 5 > someNamespace 6 > -1->Emitted(15, 5) Source(23, 5) + SourceIndex(0) -2 >Emitted(15, 19) Source(23, 19) + SourceIndex(0) -3 >Emitted(15, 20) Source(23, 20) + SourceIndex(0) -4 >Emitted(15, 30) Source(23, 37) + SourceIndex(0) -5 >Emitted(15, 43) Source(23, 50) + SourceIndex(0) -6 >Emitted(15, 44) Source(23, 51) + SourceIndex(0) +1->Emitted(16, 5) Source(23, 5) + SourceIndex(0) +2 >Emitted(16, 19) Source(23, 19) + SourceIndex(0) +3 >Emitted(16, 20) Source(23, 20) + SourceIndex(0) +4 >Emitted(16, 30) Source(23, 37) + SourceIndex(0) +5 >Emitted(16, 43) Source(23, 50) + SourceIndex(0) +6 >Emitted(16, 44) Source(23, 51) + SourceIndex(0) --- >>> class C { 1 >^^^^^^^^ @@ -324,20 +362,20 @@ sourceFile:../second/second_part1.ts 1 >{ 2 > export class 3 > C -1 >Emitted(16, 9) Source(23, 53) + SourceIndex(0) -2 >Emitted(16, 15) Source(23, 66) + SourceIndex(0) -3 >Emitted(16, 16) Source(23, 67) + SourceIndex(0) +1 >Emitted(17, 9) Source(23, 53) + SourceIndex(0) +2 >Emitted(17, 15) Source(23, 66) + SourceIndex(0) +3 >Emitted(17, 16) Source(23, 67) + SourceIndex(0) --- >>> } 1 >^^^^^^^^^ 1 > {} -1 >Emitted(17, 10) Source(23, 70) + SourceIndex(0) +1 >Emitted(18, 10) Source(23, 70) + SourceIndex(0) --- >>> } 1 >^^^^^ 2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> 1 > } -1 >Emitted(18, 6) Source(23, 72) + SourceIndex(0) +1 >Emitted(19, 6) Source(23, 72) + SourceIndex(0) --- >>> /**@internal*/ namespace someOther.something { 1->^^^^ @@ -357,14 +395,14 @@ sourceFile:../second/second_part1.ts 6 > . 7 > something 8 > -1->Emitted(19, 5) Source(24, 5) + SourceIndex(0) -2 >Emitted(19, 19) Source(24, 19) + SourceIndex(0) -3 >Emitted(19, 20) Source(24, 20) + SourceIndex(0) -4 >Emitted(19, 30) Source(24, 37) + SourceIndex(0) -5 >Emitted(19, 39) Source(24, 46) + SourceIndex(0) -6 >Emitted(19, 40) Source(24, 47) + SourceIndex(0) -7 >Emitted(19, 49) Source(24, 56) + SourceIndex(0) -8 >Emitted(19, 50) Source(24, 57) + SourceIndex(0) +1->Emitted(20, 5) Source(24, 5) + SourceIndex(0) +2 >Emitted(20, 19) Source(24, 19) + SourceIndex(0) +3 >Emitted(20, 20) Source(24, 20) + SourceIndex(0) +4 >Emitted(20, 30) Source(24, 37) + SourceIndex(0) +5 >Emitted(20, 39) Source(24, 46) + SourceIndex(0) +6 >Emitted(20, 40) Source(24, 47) + SourceIndex(0) +7 >Emitted(20, 49) Source(24, 56) + SourceIndex(0) +8 >Emitted(20, 50) Source(24, 57) + SourceIndex(0) --- >>> class someClass { 1 >^^^^^^^^ @@ -373,20 +411,20 @@ sourceFile:../second/second_part1.ts 1 >{ 2 > export class 3 > someClass -1 >Emitted(20, 9) Source(24, 59) + SourceIndex(0) -2 >Emitted(20, 15) Source(24, 72) + SourceIndex(0) -3 >Emitted(20, 24) Source(24, 81) + SourceIndex(0) +1 >Emitted(21, 9) Source(24, 59) + SourceIndex(0) +2 >Emitted(21, 15) Source(24, 72) + SourceIndex(0) +3 >Emitted(21, 24) Source(24, 81) + SourceIndex(0) --- >>> } 1 >^^^^^^^^^ 1 > {} -1 >Emitted(21, 10) Source(24, 84) + SourceIndex(0) +1 >Emitted(22, 10) Source(24, 84) + SourceIndex(0) --- >>> } 1 >^^^^^ 2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> 1 > } -1 >Emitted(22, 6) Source(24, 86) + SourceIndex(0) +1 >Emitted(23, 6) Source(24, 86) + SourceIndex(0) --- >>> /**@internal*/ export import someImport = someNamespace.C; 1->^^^^ @@ -412,17 +450,17 @@ sourceFile:../second/second_part1.ts 9 > . 10> C 11> ; -1->Emitted(23, 5) Source(25, 5) + SourceIndex(0) -2 >Emitted(23, 19) Source(25, 19) + SourceIndex(0) -3 >Emitted(23, 20) Source(25, 20) + SourceIndex(0) -4 >Emitted(23, 26) Source(25, 26) + SourceIndex(0) -5 >Emitted(23, 34) Source(25, 34) + SourceIndex(0) -6 >Emitted(23, 44) Source(25, 44) + SourceIndex(0) -7 >Emitted(23, 47) Source(25, 47) + SourceIndex(0) -8 >Emitted(23, 60) Source(25, 60) + SourceIndex(0) -9 >Emitted(23, 61) Source(25, 61) + SourceIndex(0) -10>Emitted(23, 62) Source(25, 62) + SourceIndex(0) -11>Emitted(23, 63) Source(25, 63) + SourceIndex(0) +1->Emitted(24, 5) Source(25, 5) + SourceIndex(0) +2 >Emitted(24, 19) Source(25, 19) + SourceIndex(0) +3 >Emitted(24, 20) Source(25, 20) + SourceIndex(0) +4 >Emitted(24, 26) Source(25, 26) + SourceIndex(0) +5 >Emitted(24, 34) Source(25, 34) + SourceIndex(0) +6 >Emitted(24, 44) Source(25, 44) + SourceIndex(0) +7 >Emitted(24, 47) Source(25, 47) + SourceIndex(0) +8 >Emitted(24, 60) Source(25, 60) + SourceIndex(0) +9 >Emitted(24, 61) Source(25, 61) + SourceIndex(0) +10>Emitted(24, 62) Source(25, 62) + SourceIndex(0) +11>Emitted(24, 63) Source(25, 63) + SourceIndex(0) --- >>> /**@internal*/ type internalType = internalC; 1 >^^^^ @@ -442,14 +480,14 @@ sourceFile:../second/second_part1.ts 6 > = 7 > internalC 8 > ; -1 >Emitted(24, 5) Source(26, 5) + SourceIndex(0) -2 >Emitted(24, 19) Source(26, 19) + SourceIndex(0) -3 >Emitted(24, 20) Source(26, 20) + SourceIndex(0) -4 >Emitted(24, 25) Source(26, 32) + SourceIndex(0) -5 >Emitted(24, 37) Source(26, 44) + SourceIndex(0) -6 >Emitted(24, 40) Source(26, 47) + SourceIndex(0) -7 >Emitted(24, 49) Source(26, 56) + SourceIndex(0) -8 >Emitted(24, 50) Source(26, 57) + SourceIndex(0) +1 >Emitted(25, 5) Source(26, 5) + SourceIndex(0) +2 >Emitted(25, 19) Source(26, 19) + SourceIndex(0) +3 >Emitted(25, 20) Source(26, 20) + SourceIndex(0) +4 >Emitted(25, 25) Source(26, 32) + SourceIndex(0) +5 >Emitted(25, 37) Source(26, 44) + SourceIndex(0) +6 >Emitted(25, 40) Source(26, 47) + SourceIndex(0) +7 >Emitted(25, 49) Source(26, 56) + SourceIndex(0) +8 >Emitted(25, 50) Source(26, 57) + SourceIndex(0) --- >>> /**@internal*/ const internalConst = 10; 1 >^^^^ @@ -467,13 +505,13 @@ sourceFile:../second/second_part1.ts 5 > internalConst 6 > = 10 7 > ; -1 >Emitted(25, 5) Source(27, 5) + SourceIndex(0) -2 >Emitted(25, 19) Source(27, 19) + SourceIndex(0) -3 >Emitted(25, 20) Source(27, 27) + SourceIndex(0) -4 >Emitted(25, 26) Source(27, 33) + SourceIndex(0) -5 >Emitted(25, 39) Source(27, 46) + SourceIndex(0) -6 >Emitted(25, 44) Source(27, 51) + SourceIndex(0) -7 >Emitted(25, 45) Source(27, 52) + SourceIndex(0) +1 >Emitted(26, 5) Source(27, 5) + SourceIndex(0) +2 >Emitted(26, 19) Source(27, 19) + SourceIndex(0) +3 >Emitted(26, 20) Source(27, 27) + SourceIndex(0) +4 >Emitted(26, 26) Source(27, 33) + SourceIndex(0) +5 >Emitted(26, 39) Source(27, 46) + SourceIndex(0) +6 >Emitted(26, 44) Source(27, 51) + SourceIndex(0) +7 >Emitted(26, 45) Source(27, 52) + SourceIndex(0) --- >>> /**@internal*/ enum internalEnum { 1 >^^^^ @@ -487,11 +525,11 @@ sourceFile:../second/second_part1.ts 3 > 4 > export enum 5 > internalEnum -1 >Emitted(26, 5) Source(28, 5) + SourceIndex(0) -2 >Emitted(26, 19) Source(28, 19) + SourceIndex(0) -3 >Emitted(26, 20) Source(28, 20) + SourceIndex(0) -4 >Emitted(26, 25) Source(28, 32) + SourceIndex(0) -5 >Emitted(26, 37) Source(28, 44) + SourceIndex(0) +1 >Emitted(27, 5) Source(28, 5) + SourceIndex(0) +2 >Emitted(27, 19) Source(28, 19) + SourceIndex(0) +3 >Emitted(27, 20) Source(28, 20) + SourceIndex(0) +4 >Emitted(27, 25) Source(28, 32) + SourceIndex(0) +5 >Emitted(27, 37) Source(28, 44) + SourceIndex(0) --- >>> a = 0, 1 >^^^^^^^^ @@ -501,9 +539,9 @@ sourceFile:../second/second_part1.ts 1 > { 2 > a 3 > -1 >Emitted(27, 9) Source(28, 47) + SourceIndex(0) -2 >Emitted(27, 10) Source(28, 48) + SourceIndex(0) -3 >Emitted(27, 14) Source(28, 48) + SourceIndex(0) +1 >Emitted(28, 9) Source(28, 47) + SourceIndex(0) +2 >Emitted(28, 10) Source(28, 48) + SourceIndex(0) +3 >Emitted(28, 14) Source(28, 48) + SourceIndex(0) --- >>> b = 1, 1->^^^^^^^^ @@ -513,9 +551,9 @@ sourceFile:../second/second_part1.ts 1->, 2 > b 3 > -1->Emitted(28, 9) Source(28, 50) + SourceIndex(0) -2 >Emitted(28, 10) Source(28, 51) + SourceIndex(0) -3 >Emitted(28, 14) Source(28, 51) + SourceIndex(0) +1->Emitted(29, 9) Source(28, 50) + SourceIndex(0) +2 >Emitted(29, 10) Source(28, 51) + SourceIndex(0) +3 >Emitted(29, 14) Source(28, 51) + SourceIndex(0) --- >>> c = 2 1->^^^^^^^^ @@ -524,21 +562,21 @@ sourceFile:../second/second_part1.ts 1->, 2 > c 3 > -1->Emitted(29, 9) Source(28, 53) + SourceIndex(0) -2 >Emitted(29, 10) Source(28, 54) + SourceIndex(0) -3 >Emitted(29, 14) Source(28, 54) + SourceIndex(0) +1->Emitted(30, 9) Source(28, 53) + SourceIndex(0) +2 >Emitted(30, 10) Source(28, 54) + SourceIndex(0) +3 >Emitted(30, 14) Source(28, 54) + SourceIndex(0) --- >>> } 1 >^^^^^ 1 > } -1 >Emitted(30, 6) Source(28, 56) + SourceIndex(0) +1 >Emitted(31, 6) Source(28, 56) + SourceIndex(0) --- >>>} 1 >^ 2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> 1 > >} -1 >Emitted(31, 2) Source(29, 2) + SourceIndex(0) +1 >Emitted(32, 2) Source(29, 2) + SourceIndex(0) --- >>>/**@internal*/ declare class internalC { 1-> @@ -552,17 +590,17 @@ sourceFile:../second/second_part1.ts 3 > 4 > class 5 > internalC -1->Emitted(32, 1) Source(30, 1) + SourceIndex(0) -2 >Emitted(32, 15) Source(30, 15) + SourceIndex(0) -3 >Emitted(32, 16) Source(30, 16) + SourceIndex(0) -4 >Emitted(32, 30) Source(30, 22) + SourceIndex(0) -5 >Emitted(32, 39) Source(30, 31) + SourceIndex(0) +1->Emitted(33, 1) Source(30, 1) + SourceIndex(0) +2 >Emitted(33, 15) Source(30, 15) + SourceIndex(0) +3 >Emitted(33, 16) Source(30, 16) + SourceIndex(0) +4 >Emitted(33, 30) Source(30, 22) + SourceIndex(0) +5 >Emitted(33, 39) Source(30, 31) + SourceIndex(0) --- >>>} 1 >^ 2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> 1 > {} -1 >Emitted(33, 2) Source(30, 34) + SourceIndex(0) +1 >Emitted(34, 2) Source(30, 34) + SourceIndex(0) --- >>>/**@internal*/ declare function internalfoo(): void; 1-> @@ -579,12 +617,12 @@ sourceFile:../second/second_part1.ts 4 > function 5 > internalfoo 6 > () {} -1->Emitted(34, 1) Source(31, 1) + SourceIndex(0) -2 >Emitted(34, 15) Source(31, 15) + SourceIndex(0) -3 >Emitted(34, 16) Source(31, 16) + SourceIndex(0) -4 >Emitted(34, 33) Source(31, 25) + SourceIndex(0) -5 >Emitted(34, 44) Source(31, 36) + SourceIndex(0) -6 >Emitted(34, 53) Source(31, 41) + SourceIndex(0) +1->Emitted(35, 1) Source(31, 1) + SourceIndex(0) +2 >Emitted(35, 15) Source(31, 15) + SourceIndex(0) +3 >Emitted(35, 16) Source(31, 16) + SourceIndex(0) +4 >Emitted(35, 33) Source(31, 25) + SourceIndex(0) +5 >Emitted(35, 44) Source(31, 36) + SourceIndex(0) +6 >Emitted(35, 53) Source(31, 41) + SourceIndex(0) --- >>>/**@internal*/ declare namespace internalNamespace { 1-> @@ -600,12 +638,12 @@ sourceFile:../second/second_part1.ts 4 > namespace 5 > internalNamespace 6 > -1->Emitted(35, 1) Source(32, 1) + SourceIndex(0) -2 >Emitted(35, 15) Source(32, 15) + SourceIndex(0) -3 >Emitted(35, 16) Source(32, 16) + SourceIndex(0) -4 >Emitted(35, 34) Source(32, 26) + SourceIndex(0) -5 >Emitted(35, 51) Source(32, 43) + SourceIndex(0) -6 >Emitted(35, 52) Source(32, 44) + SourceIndex(0) +1->Emitted(36, 1) Source(32, 1) + SourceIndex(0) +2 >Emitted(36, 15) Source(32, 15) + SourceIndex(0) +3 >Emitted(36, 16) Source(32, 16) + SourceIndex(0) +4 >Emitted(36, 34) Source(32, 26) + SourceIndex(0) +5 >Emitted(36, 51) Source(32, 43) + SourceIndex(0) +6 >Emitted(36, 52) Source(32, 44) + SourceIndex(0) --- >>> class someClass { 1 >^^^^ @@ -614,20 +652,20 @@ sourceFile:../second/second_part1.ts 1 >{ 2 > export class 3 > someClass -1 >Emitted(36, 5) Source(32, 46) + SourceIndex(0) -2 >Emitted(36, 11) Source(32, 59) + SourceIndex(0) -3 >Emitted(36, 20) Source(32, 68) + SourceIndex(0) +1 >Emitted(37, 5) Source(32, 46) + SourceIndex(0) +2 >Emitted(37, 11) Source(32, 59) + SourceIndex(0) +3 >Emitted(37, 20) Source(32, 68) + SourceIndex(0) --- >>> } 1 >^^^^^ 1 > {} -1 >Emitted(37, 6) Source(32, 71) + SourceIndex(0) +1 >Emitted(38, 6) Source(32, 71) + SourceIndex(0) --- >>>} 1 >^ 2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> 1 > } -1 >Emitted(38, 2) Source(32, 73) + SourceIndex(0) +1 >Emitted(39, 2) Source(32, 73) + SourceIndex(0) --- >>>/**@internal*/ declare namespace internalOther.something { 1-> @@ -647,14 +685,14 @@ sourceFile:../second/second_part1.ts 6 > . 7 > something 8 > -1->Emitted(39, 1) Source(33, 1) + SourceIndex(0) -2 >Emitted(39, 15) Source(33, 15) + SourceIndex(0) -3 >Emitted(39, 16) Source(33, 16) + SourceIndex(0) -4 >Emitted(39, 34) Source(33, 26) + SourceIndex(0) -5 >Emitted(39, 47) Source(33, 39) + SourceIndex(0) -6 >Emitted(39, 48) Source(33, 40) + SourceIndex(0) -7 >Emitted(39, 57) Source(33, 49) + SourceIndex(0) -8 >Emitted(39, 58) Source(33, 50) + SourceIndex(0) +1->Emitted(40, 1) Source(33, 1) + SourceIndex(0) +2 >Emitted(40, 15) Source(33, 15) + SourceIndex(0) +3 >Emitted(40, 16) Source(33, 16) + SourceIndex(0) +4 >Emitted(40, 34) Source(33, 26) + SourceIndex(0) +5 >Emitted(40, 47) Source(33, 39) + SourceIndex(0) +6 >Emitted(40, 48) Source(33, 40) + SourceIndex(0) +7 >Emitted(40, 57) Source(33, 49) + SourceIndex(0) +8 >Emitted(40, 58) Source(33, 50) + SourceIndex(0) --- >>> class someClass { 1 >^^^^ @@ -663,20 +701,20 @@ sourceFile:../second/second_part1.ts 1 >{ 2 > export class 3 > someClass -1 >Emitted(40, 5) Source(33, 52) + SourceIndex(0) -2 >Emitted(40, 11) Source(33, 65) + SourceIndex(0) -3 >Emitted(40, 20) Source(33, 74) + SourceIndex(0) +1 >Emitted(41, 5) Source(33, 52) + SourceIndex(0) +2 >Emitted(41, 11) Source(33, 65) + SourceIndex(0) +3 >Emitted(41, 20) Source(33, 74) + SourceIndex(0) --- >>> } 1 >^^^^^ 1 > {} -1 >Emitted(41, 6) Source(33, 77) + SourceIndex(0) +1 >Emitted(42, 6) Source(33, 77) + SourceIndex(0) --- >>>} 1 >^ 2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> 1 > } -1 >Emitted(42, 2) Source(33, 79) + SourceIndex(0) +1 >Emitted(43, 2) Source(33, 79) + SourceIndex(0) --- >>>/**@internal*/ import internalImport = internalNamespace.someClass; 1-> @@ -700,16 +738,16 @@ sourceFile:../second/second_part1.ts 8 > . 9 > someClass 10> ; -1->Emitted(43, 1) Source(34, 1) + SourceIndex(0) -2 >Emitted(43, 15) Source(34, 15) + SourceIndex(0) -3 >Emitted(43, 16) Source(34, 16) + SourceIndex(0) -4 >Emitted(43, 23) Source(34, 23) + SourceIndex(0) -5 >Emitted(43, 37) Source(34, 37) + SourceIndex(0) -6 >Emitted(43, 40) Source(34, 40) + SourceIndex(0) -7 >Emitted(43, 57) Source(34, 57) + SourceIndex(0) -8 >Emitted(43, 58) Source(34, 58) + SourceIndex(0) -9 >Emitted(43, 67) Source(34, 67) + SourceIndex(0) -10>Emitted(43, 68) Source(34, 68) + SourceIndex(0) +1->Emitted(44, 1) Source(34, 1) + SourceIndex(0) +2 >Emitted(44, 15) Source(34, 15) + SourceIndex(0) +3 >Emitted(44, 16) Source(34, 16) + SourceIndex(0) +4 >Emitted(44, 23) Source(34, 23) + SourceIndex(0) +5 >Emitted(44, 37) Source(34, 37) + SourceIndex(0) +6 >Emitted(44, 40) Source(34, 40) + SourceIndex(0) +7 >Emitted(44, 57) Source(34, 57) + SourceIndex(0) +8 >Emitted(44, 58) Source(34, 58) + SourceIndex(0) +9 >Emitted(44, 67) Source(34, 67) + SourceIndex(0) +10>Emitted(44, 68) Source(34, 68) + SourceIndex(0) --- >>>/**@internal*/ declare type internalType = internalC; 1 > @@ -729,14 +767,14 @@ sourceFile:../second/second_part1.ts 6 > = 7 > internalC 8 > ; -1 >Emitted(44, 1) Source(35, 1) + SourceIndex(0) -2 >Emitted(44, 15) Source(35, 15) + SourceIndex(0) -3 >Emitted(44, 16) Source(35, 16) + SourceIndex(0) -4 >Emitted(44, 29) Source(35, 21) + SourceIndex(0) -5 >Emitted(44, 41) Source(35, 33) + SourceIndex(0) -6 >Emitted(44, 44) Source(35, 36) + SourceIndex(0) -7 >Emitted(44, 53) Source(35, 45) + SourceIndex(0) -8 >Emitted(44, 54) Source(35, 46) + SourceIndex(0) +1 >Emitted(45, 1) Source(35, 1) + SourceIndex(0) +2 >Emitted(45, 15) Source(35, 15) + SourceIndex(0) +3 >Emitted(45, 16) Source(35, 16) + SourceIndex(0) +4 >Emitted(45, 29) Source(35, 21) + SourceIndex(0) +5 >Emitted(45, 41) Source(35, 33) + SourceIndex(0) +6 >Emitted(45, 44) Source(35, 36) + SourceIndex(0) +7 >Emitted(45, 53) Source(35, 45) + SourceIndex(0) +8 >Emitted(45, 54) Source(35, 46) + SourceIndex(0) --- >>>/**@internal*/ declare const internalConst = 10; 1 > @@ -756,14 +794,14 @@ sourceFile:../second/second_part1.ts 6 > internalConst 7 > = 10 8 > ; -1 >Emitted(45, 1) Source(36, 1) + SourceIndex(0) -2 >Emitted(45, 15) Source(36, 15) + SourceIndex(0) -3 >Emitted(45, 16) Source(36, 16) + SourceIndex(0) -4 >Emitted(45, 24) Source(36, 16) + SourceIndex(0) -5 >Emitted(45, 30) Source(36, 22) + SourceIndex(0) -6 >Emitted(45, 43) Source(36, 35) + SourceIndex(0) -7 >Emitted(45, 48) Source(36, 40) + SourceIndex(0) -8 >Emitted(45, 49) Source(36, 41) + SourceIndex(0) +1 >Emitted(46, 1) Source(36, 1) + SourceIndex(0) +2 >Emitted(46, 15) Source(36, 15) + SourceIndex(0) +3 >Emitted(46, 16) Source(36, 16) + SourceIndex(0) +4 >Emitted(46, 24) Source(36, 16) + SourceIndex(0) +5 >Emitted(46, 30) Source(36, 22) + SourceIndex(0) +6 >Emitted(46, 43) Source(36, 35) + SourceIndex(0) +7 >Emitted(46, 48) Source(36, 40) + SourceIndex(0) +8 >Emitted(46, 49) Source(36, 41) + SourceIndex(0) --- >>>/**@internal*/ declare enum internalEnum { 1 > @@ -777,11 +815,11 @@ sourceFile:../second/second_part1.ts 3 > 4 > enum 5 > internalEnum -1 >Emitted(46, 1) Source(37, 1) + SourceIndex(0) -2 >Emitted(46, 15) Source(37, 15) + SourceIndex(0) -3 >Emitted(46, 16) Source(37, 16) + SourceIndex(0) -4 >Emitted(46, 29) Source(37, 21) + SourceIndex(0) -5 >Emitted(46, 41) Source(37, 33) + SourceIndex(0) +1 >Emitted(47, 1) Source(37, 1) + SourceIndex(0) +2 >Emitted(47, 15) Source(37, 15) + SourceIndex(0) +3 >Emitted(47, 16) Source(37, 16) + SourceIndex(0) +4 >Emitted(47, 29) Source(37, 21) + SourceIndex(0) +5 >Emitted(47, 41) Source(37, 33) + SourceIndex(0) --- >>> a = 0, 1 >^^^^ @@ -791,9 +829,9 @@ sourceFile:../second/second_part1.ts 1 > { 2 > a 3 > -1 >Emitted(47, 5) Source(37, 36) + SourceIndex(0) -2 >Emitted(47, 6) Source(37, 37) + SourceIndex(0) -3 >Emitted(47, 10) Source(37, 37) + SourceIndex(0) +1 >Emitted(48, 5) Source(37, 36) + SourceIndex(0) +2 >Emitted(48, 6) Source(37, 37) + SourceIndex(0) +3 >Emitted(48, 10) Source(37, 37) + SourceIndex(0) --- >>> b = 1, 1->^^^^ @@ -803,9 +841,9 @@ sourceFile:../second/second_part1.ts 1->, 2 > b 3 > -1->Emitted(48, 5) Source(37, 39) + SourceIndex(0) -2 >Emitted(48, 6) Source(37, 40) + SourceIndex(0) -3 >Emitted(48, 10) Source(37, 40) + SourceIndex(0) +1->Emitted(49, 5) Source(37, 39) + SourceIndex(0) +2 >Emitted(49, 6) Source(37, 40) + SourceIndex(0) +3 >Emitted(49, 10) Source(37, 40) + SourceIndex(0) --- >>> c = 2 1->^^^^ @@ -814,15 +852,15 @@ sourceFile:../second/second_part1.ts 1->, 2 > c 3 > -1->Emitted(49, 5) Source(37, 42) + SourceIndex(0) -2 >Emitted(49, 6) Source(37, 43) + SourceIndex(0) -3 >Emitted(49, 10) Source(37, 43) + SourceIndex(0) +1->Emitted(50, 5) Source(37, 42) + SourceIndex(0) +2 >Emitted(50, 6) Source(37, 43) + SourceIndex(0) +3 >Emitted(50, 10) Source(37, 43) + SourceIndex(0) --- >>>} 1 >^ 2 > ^^^^^^^^^^^^^^^^^-> 1 > } -1 >Emitted(50, 2) Source(37, 45) + SourceIndex(0) +1 >Emitted(51, 2) Source(37, 45) + SourceIndex(0) --- ------------------------------------------------------------------- emittedFile:/src/2/second-output.d.ts @@ -836,9 +874,9 @@ sourceFile:../second/second_part2.ts 1-> 2 >class 3 > C -1->Emitted(51, 1) Source(1, 1) + SourceIndex(1) -2 >Emitted(51, 15) Source(1, 7) + SourceIndex(1) -3 >Emitted(51, 16) Source(1, 8) + SourceIndex(1) +1->Emitted(52, 1) Source(1, 1) + SourceIndex(1) +2 >Emitted(52, 15) Source(1, 7) + SourceIndex(1) +3 >Emitted(52, 16) Source(1, 8) + SourceIndex(1) --- >>> doSomething(): void; 1->^^^^ @@ -846,8 +884,8 @@ sourceFile:../second/second_part2.ts 1-> { > 2 > doSomething -1->Emitted(52, 5) Source(2, 5) + SourceIndex(1) -2 >Emitted(52, 16) Source(2, 16) + SourceIndex(1) +1->Emitted(53, 5) Source(2, 5) + SourceIndex(1) +2 >Emitted(53, 16) Source(2, 16) + SourceIndex(1) --- >>>} 1 >^ @@ -856,7 +894,7 @@ sourceFile:../second/second_part2.ts > console.log("something got done"); > } >} -1 >Emitted(53, 2) Source(5, 2) + SourceIndex(1) +1 >Emitted(54, 2) Source(5, 2) + SourceIndex(1) --- >>>//# sourceMappingURL=second-output.d.ts.map @@ -2540,32 +2578,32 @@ sourceFile:../second/second_part2.ts }, { "pos": 77, - "end": 226, + "end": 257, "kind": "internal" }, { - "pos": 228, - "end": 260, + "pos": 259, + "end": 291, "kind": "text" }, { - "pos": 260, - "end": 772, + "pos": 291, + "end": 803, "kind": "internal" }, { - "pos": 774, - "end": 777, + "pos": 805, + "end": 808, "kind": "text" }, { - "pos": 777, - "end": 1310, + "pos": 808, + "end": 1341, "kind": "internal" }, { - "pos": 1312, - "end": 1360, + "pos": 1343, + "end": 1391, "kind": "text" } ] @@ -2694,18 +2732,19 @@ declare namespace N { declare class normalC { ---------------------------------------------------------------------- -internal: (77-226) +internal: (77-257) /**@internal*/ constructor(); /**@internal*/ prop: string; /**@internal*/ method(): void; - /**@internal*/ /**@internal*/ c: number; + /**@internal*/ get c(): number; + /**@internal*/ set c(val: number); ---------------------------------------------------------------------- -text: (228-260) +text: (259-291) } declare namespace normalN { ---------------------------------------------------------------------- -internal: (260-772) +internal: (291-803) /**@internal*/ class C { } /**@internal*/ function foo(): void; @@ -2726,11 +2765,11 @@ internal: (260-772) c = 2 } ---------------------------------------------------------------------- -text: (774-777) +text: (805-808) } ---------------------------------------------------------------------- -internal: (777-1310) +internal: (808-1341) /**@internal*/ declare class internalC { } /**@internal*/ declare function internalfoo(): void; @@ -2751,7 +2790,7 @@ internal: (777-1310) c = 2 } ---------------------------------------------------------------------- -text: (1312-1360) +text: (1343-1391) declare class C { doSomething(): void; } diff --git a/tests/baselines/reference/tsbuild/outfile-concat/initial-build/stripInternal-when-one-two-three-are-prepended-in-order.js b/tests/baselines/reference/tsbuild/outfile-concat/initial-build/stripInternal-when-one-two-three-are-prepended-in-order.js index a858a1e27d8a9..360d2c392a278 100644 --- a/tests/baselines/reference/tsbuild/outfile-concat/initial-build/stripInternal-when-one-two-three-are-prepended-in-order.js +++ b/tests/baselines/reference/tsbuild/outfile-concat/initial-build/stripInternal-when-one-two-three-are-prepended-in-order.js @@ -57,7 +57,8 @@ declare class normalC { constructor(); prop: string; method(): void; - c: number; + get c(): number; + set c(val: number); } declare namespace normalN { class C { @@ -105,7 +106,7 @@ declare class C { //# sourceMappingURL=second-output.d.ts.map //// [/src/2/second-output.d.ts.map] -{"version":3,"file":"second-output.d.ts","sourceRoot":"","sources":["../first/first_PART1.ts","../first/first_part3.ts","../second/second_part1.ts","../second/second_part2.ts"],"names":[],"mappings":"AAAc,UAAU,QAAQ;IAC5B,IAAI,EAAE,GAAG,CAAC;CACb;AAED,QAAA,MAAM,CAAC,iBAAiB,CAAC;AAEzB,UAAU,iBAAiB;IACvB,IAAI,EAAE,GAAG,CAAC;CACb;ACRD,iBAAS,CAAC,WAET;ACFD,kBAAU,CAAC,CAAC;CAEX;AAED,kBAAU,CAAC,CAAC;CAMX;AAED,cAAM,OAAO;;IAEK,IAAI,EAAE,MAAM,CAAC;IACb,MAAM;IACF,CAAC,EACM,MAAM;CAClC;AACD,kBAAU,OAAO,CAAC;IACA,MAAa,CAAC;KAAI;IAClB,SAAgB,GAAG,SAAK;IACxB,UAAiB,aAAa,CAAC;QAAE,MAAa,CAAC;SAAG;KAAE;IACpD,UAAiB,SAAS,CAAC,SAAS,CAAC;QAAE,MAAa,SAAS;SAAG;KAAE;IAClE,MAAM,QAAQ,UAAU,GAAG,aAAa,CAAC,CAAC,CAAC;IAC3C,KAAY,YAAY,GAAG,SAAS,CAAC;IAC9B,MAAM,aAAa,KAAK,CAAC;IAChC,KAAY,YAAY;QAAG,CAAC,IAAA;QAAE,CAAC,IAAA;QAAE,CAAC,IAAA;KAAE;CACrD;AACa,cAAM,SAAS;CAAG;AAClB,iBAAS,WAAW,SAAK;AACzB,kBAAU,iBAAiB,CAAC;IAAE,MAAa,SAAS;KAAG;CAAE;AACzD,kBAAU,aAAa,CAAC,SAAS,CAAC;IAAE,MAAa,SAAS;KAAG;CAAE;AAC/D,OAAO,cAAc,GAAG,iBAAiB,CAAC,SAAS,CAAC;AACpD,aAAK,YAAY,GAAG,SAAS,CAAC;AAC9B,QAAA,MAAM,aAAa,KAAK,CAAC;AACzB,aAAK,YAAY;IAAG,CAAC,IAAA;IAAE,CAAC,IAAA;IAAE,CAAC,IAAA;CAAE;ACpC3C,cAAM,CAAC;IACH,WAAW;CAGd"} +{"version":3,"file":"second-output.d.ts","sourceRoot":"","sources":["../first/first_PART1.ts","../first/first_part3.ts","../second/second_part1.ts","../second/second_part2.ts"],"names":[],"mappings":"AAAc,UAAU,QAAQ;IAC5B,IAAI,EAAE,GAAG,CAAC;CACb;AAED,QAAA,MAAM,CAAC,iBAAiB,CAAC;AAEzB,UAAU,iBAAiB;IACvB,IAAI,EAAE,GAAG,CAAC;CACb;ACRD,iBAAS,CAAC,WAET;ACFD,kBAAU,CAAC,CAAC;CAEX;AAED,kBAAU,CAAC,CAAC;CAMX;AAED,cAAM,OAAO;;IAEK,IAAI,EAAE,MAAM,CAAC;IACb,MAAM;IACN,IAAI,CAAC,IACM,MAAM,CADK;IACtB,IAAI,CAAC,CAAC,KAAK,MAAM,EAAK;CACvC;AACD,kBAAU,OAAO,CAAC;IACA,MAAa,CAAC;KAAI;IAClB,SAAgB,GAAG,SAAK;IACxB,UAAiB,aAAa,CAAC;QAAE,MAAa,CAAC;SAAG;KAAE;IACpD,UAAiB,SAAS,CAAC,SAAS,CAAC;QAAE,MAAa,SAAS;SAAG;KAAE;IAClE,MAAM,QAAQ,UAAU,GAAG,aAAa,CAAC,CAAC,CAAC;IAC3C,KAAY,YAAY,GAAG,SAAS,CAAC;IAC9B,MAAM,aAAa,KAAK,CAAC;IAChC,KAAY,YAAY;QAAG,CAAC,IAAA;QAAE,CAAC,IAAA;QAAE,CAAC,IAAA;KAAE;CACrD;AACa,cAAM,SAAS;CAAG;AAClB,iBAAS,WAAW,SAAK;AACzB,kBAAU,iBAAiB,CAAC;IAAE,MAAa,SAAS;KAAG;CAAE;AACzD,kBAAU,aAAa,CAAC,SAAS,CAAC;IAAE,MAAa,SAAS;KAAG;CAAE;AAC/D,OAAO,cAAc,GAAG,iBAAiB,CAAC,SAAS,CAAC;AACpD,aAAK,YAAY,GAAG,SAAS,CAAC;AAC9B,QAAA,MAAM,aAAa,KAAK,CAAC;AACzB,aAAK,YAAY;IAAG,CAAC,IAAA;IAAE,CAAC,IAAA;IAAE,CAAC,IAAA;CAAE;ACpC3C,cAAM,CAAC;IACH,WAAW;CAGd"} //// [/src/2/second-output.d.ts.map.baseline.txt] =================================================================== @@ -325,35 +326,66 @@ sourceFile:../second/second_part1.ts >>> method(): void; 1->^^^^ 2 > ^^^^^^ -3 > ^^^^^-> +3 > ^^^^^^^^^^^-> 1-> > /*@internal*/ 2 > method 1->Emitted(16, 5) Source(16, 19) + SourceIndex(2) 2 >Emitted(16, 11) Source(16, 25) + SourceIndex(2) --- ->>> c: number; +>>> get c(): number; 1->^^^^ -2 > ^ -3 > ^^ -4 > ^^^^^^ +2 > ^^^^ +3 > ^ +4 > ^^^^ +5 > ^^^^^^ +6 > ^ +7 > ^^^^-> 1->() { } - > /*@internal*/ get -2 > c -3 > () { return 10; } - > /*@internal*/ set c(val: -4 > number -1->Emitted(17, 5) Source(17, 23) + SourceIndex(2) -2 >Emitted(17, 6) Source(17, 24) + SourceIndex(2) -3 >Emitted(17, 8) Source(18, 30) + SourceIndex(2) -4 >Emitted(17, 14) Source(18, 36) + SourceIndex(2) + > /*@internal*/ +2 > get +3 > c +4 > () { return 10; } + > /*@internal*/ set c(val: +5 > number +6 > +1->Emitted(17, 5) Source(17, 19) + SourceIndex(2) +2 >Emitted(17, 9) Source(17, 23) + SourceIndex(2) +3 >Emitted(17, 10) Source(17, 24) + SourceIndex(2) +4 >Emitted(17, 14) Source(18, 30) + SourceIndex(2) +5 >Emitted(17, 20) Source(18, 36) + SourceIndex(2) +6 >Emitted(17, 21) Source(17, 41) + SourceIndex(2) +--- +>>> set c(val: number); +1->^^^^ +2 > ^^^^ +3 > ^ +4 > ^ +5 > ^^^^^ +6 > ^^^^^^ +7 > ^^ +1-> + > /*@internal*/ +2 > set +3 > c +4 > ( +5 > val: +6 > number +7 > ) { } +1->Emitted(18, 5) Source(18, 19) + SourceIndex(2) +2 >Emitted(18, 9) Source(18, 23) + SourceIndex(2) +3 >Emitted(18, 10) Source(18, 24) + SourceIndex(2) +4 >Emitted(18, 11) Source(18, 25) + SourceIndex(2) +5 >Emitted(18, 16) Source(18, 30) + SourceIndex(2) +6 >Emitted(18, 22) Source(18, 36) + SourceIndex(2) +7 >Emitted(18, 24) Source(18, 41) + SourceIndex(2) --- >>>} 1 >^ 2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1 >) { } +1 > >} -1 >Emitted(18, 2) Source(19, 2) + SourceIndex(2) +1 >Emitted(19, 2) Source(19, 2) + SourceIndex(2) --- >>>declare namespace normalN { 1-> @@ -365,10 +397,10 @@ sourceFile:../second/second_part1.ts 2 >namespace 3 > normalN 4 > -1->Emitted(19, 1) Source(20, 1) + SourceIndex(2) -2 >Emitted(19, 19) Source(20, 11) + SourceIndex(2) -3 >Emitted(19, 26) Source(20, 18) + SourceIndex(2) -4 >Emitted(19, 27) Source(20, 19) + SourceIndex(2) +1->Emitted(20, 1) Source(20, 1) + SourceIndex(2) +2 >Emitted(20, 19) Source(20, 11) + SourceIndex(2) +3 >Emitted(20, 26) Source(20, 18) + SourceIndex(2) +4 >Emitted(20, 27) Source(20, 19) + SourceIndex(2) --- >>> class C { 1 >^^^^ @@ -378,15 +410,15 @@ sourceFile:../second/second_part1.ts > /*@internal*/ 2 > export class 3 > C -1 >Emitted(20, 5) Source(21, 19) + SourceIndex(2) -2 >Emitted(20, 11) Source(21, 32) + SourceIndex(2) -3 >Emitted(20, 12) Source(21, 33) + SourceIndex(2) +1 >Emitted(21, 5) Source(21, 19) + SourceIndex(2) +2 >Emitted(21, 11) Source(21, 32) + SourceIndex(2) +3 >Emitted(21, 12) Source(21, 33) + SourceIndex(2) --- >>> } 1 >^^^^^ 2 > ^^^^^^^^^^^^^^^^^^^^^-> 1 > { } -1 >Emitted(21, 6) Source(21, 37) + SourceIndex(2) +1 >Emitted(22, 6) Source(21, 37) + SourceIndex(2) --- >>> function foo(): void; 1->^^^^ @@ -399,10 +431,10 @@ sourceFile:../second/second_part1.ts 2 > export function 3 > foo 4 > () {} -1->Emitted(22, 5) Source(22, 19) + SourceIndex(2) -2 >Emitted(22, 14) Source(22, 35) + SourceIndex(2) -3 >Emitted(22, 17) Source(22, 38) + SourceIndex(2) -4 >Emitted(22, 26) Source(22, 43) + SourceIndex(2) +1->Emitted(23, 5) Source(22, 19) + SourceIndex(2) +2 >Emitted(23, 14) Source(22, 35) + SourceIndex(2) +3 >Emitted(23, 17) Source(22, 38) + SourceIndex(2) +4 >Emitted(23, 26) Source(22, 43) + SourceIndex(2) --- >>> namespace someNamespace { 1->^^^^ @@ -414,10 +446,10 @@ sourceFile:../second/second_part1.ts 2 > export namespace 3 > someNamespace 4 > -1->Emitted(23, 5) Source(23, 19) + SourceIndex(2) -2 >Emitted(23, 15) Source(23, 36) + SourceIndex(2) -3 >Emitted(23, 28) Source(23, 49) + SourceIndex(2) -4 >Emitted(23, 29) Source(23, 50) + SourceIndex(2) +1->Emitted(24, 5) Source(23, 19) + SourceIndex(2) +2 >Emitted(24, 15) Source(23, 36) + SourceIndex(2) +3 >Emitted(24, 28) Source(23, 49) + SourceIndex(2) +4 >Emitted(24, 29) Source(23, 50) + SourceIndex(2) --- >>> class C { 1 >^^^^^^^^ @@ -426,20 +458,20 @@ sourceFile:../second/second_part1.ts 1 >{ 2 > export class 3 > C -1 >Emitted(24, 9) Source(23, 52) + SourceIndex(2) -2 >Emitted(24, 15) Source(23, 65) + SourceIndex(2) -3 >Emitted(24, 16) Source(23, 66) + SourceIndex(2) +1 >Emitted(25, 9) Source(23, 52) + SourceIndex(2) +2 >Emitted(25, 15) Source(23, 65) + SourceIndex(2) +3 >Emitted(25, 16) Source(23, 66) + SourceIndex(2) --- >>> } 1 >^^^^^^^^^ 1 > {} -1 >Emitted(25, 10) Source(23, 69) + SourceIndex(2) +1 >Emitted(26, 10) Source(23, 69) + SourceIndex(2) --- >>> } 1 >^^^^^ 2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> 1 > } -1 >Emitted(26, 6) Source(23, 71) + SourceIndex(2) +1 >Emitted(27, 6) Source(23, 71) + SourceIndex(2) --- >>> namespace someOther.something { 1->^^^^ @@ -455,12 +487,12 @@ sourceFile:../second/second_part1.ts 4 > . 5 > something 6 > -1->Emitted(27, 5) Source(24, 19) + SourceIndex(2) -2 >Emitted(27, 15) Source(24, 36) + SourceIndex(2) -3 >Emitted(27, 24) Source(24, 45) + SourceIndex(2) -4 >Emitted(27, 25) Source(24, 46) + SourceIndex(2) -5 >Emitted(27, 34) Source(24, 55) + SourceIndex(2) -6 >Emitted(27, 35) Source(24, 56) + SourceIndex(2) +1->Emitted(28, 5) Source(24, 19) + SourceIndex(2) +2 >Emitted(28, 15) Source(24, 36) + SourceIndex(2) +3 >Emitted(28, 24) Source(24, 45) + SourceIndex(2) +4 >Emitted(28, 25) Source(24, 46) + SourceIndex(2) +5 >Emitted(28, 34) Source(24, 55) + SourceIndex(2) +6 >Emitted(28, 35) Source(24, 56) + SourceIndex(2) --- >>> class someClass { 1 >^^^^^^^^ @@ -469,20 +501,20 @@ sourceFile:../second/second_part1.ts 1 >{ 2 > export class 3 > someClass -1 >Emitted(28, 9) Source(24, 58) + SourceIndex(2) -2 >Emitted(28, 15) Source(24, 71) + SourceIndex(2) -3 >Emitted(28, 24) Source(24, 80) + SourceIndex(2) +1 >Emitted(29, 9) Source(24, 58) + SourceIndex(2) +2 >Emitted(29, 15) Source(24, 71) + SourceIndex(2) +3 >Emitted(29, 24) Source(24, 80) + SourceIndex(2) --- >>> } 1 >^^^^^^^^^ 1 > {} -1 >Emitted(29, 10) Source(24, 83) + SourceIndex(2) +1 >Emitted(30, 10) Source(24, 83) + SourceIndex(2) --- >>> } 1 >^^^^^ 2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> 1 > } -1 >Emitted(30, 6) Source(24, 85) + SourceIndex(2) +1 >Emitted(31, 6) Source(24, 85) + SourceIndex(2) --- >>> export import someImport = someNamespace.C; 1->^^^^ @@ -504,15 +536,15 @@ sourceFile:../second/second_part1.ts 7 > . 8 > C 9 > ; -1->Emitted(31, 5) Source(25, 19) + SourceIndex(2) -2 >Emitted(31, 11) Source(25, 25) + SourceIndex(2) -3 >Emitted(31, 19) Source(25, 33) + SourceIndex(2) -4 >Emitted(31, 29) Source(25, 43) + SourceIndex(2) -5 >Emitted(31, 32) Source(25, 46) + SourceIndex(2) -6 >Emitted(31, 45) Source(25, 59) + SourceIndex(2) -7 >Emitted(31, 46) Source(25, 60) + SourceIndex(2) -8 >Emitted(31, 47) Source(25, 61) + SourceIndex(2) -9 >Emitted(31, 48) Source(25, 62) + SourceIndex(2) +1->Emitted(32, 5) Source(25, 19) + SourceIndex(2) +2 >Emitted(32, 11) Source(25, 25) + SourceIndex(2) +3 >Emitted(32, 19) Source(25, 33) + SourceIndex(2) +4 >Emitted(32, 29) Source(25, 43) + SourceIndex(2) +5 >Emitted(32, 32) Source(25, 46) + SourceIndex(2) +6 >Emitted(32, 45) Source(25, 59) + SourceIndex(2) +7 >Emitted(32, 46) Source(25, 60) + SourceIndex(2) +8 >Emitted(32, 47) Source(25, 61) + SourceIndex(2) +9 >Emitted(32, 48) Source(25, 62) + SourceIndex(2) --- >>> type internalType = internalC; 1 >^^^^ @@ -528,12 +560,12 @@ sourceFile:../second/second_part1.ts 4 > = 5 > internalC 6 > ; -1 >Emitted(32, 5) Source(26, 19) + SourceIndex(2) -2 >Emitted(32, 10) Source(26, 31) + SourceIndex(2) -3 >Emitted(32, 22) Source(26, 43) + SourceIndex(2) -4 >Emitted(32, 25) Source(26, 46) + SourceIndex(2) -5 >Emitted(32, 34) Source(26, 55) + SourceIndex(2) -6 >Emitted(32, 35) Source(26, 56) + SourceIndex(2) +1 >Emitted(33, 5) Source(26, 19) + SourceIndex(2) +2 >Emitted(33, 10) Source(26, 31) + SourceIndex(2) +3 >Emitted(33, 22) Source(26, 43) + SourceIndex(2) +4 >Emitted(33, 25) Source(26, 46) + SourceIndex(2) +5 >Emitted(33, 34) Source(26, 55) + SourceIndex(2) +6 >Emitted(33, 35) Source(26, 56) + SourceIndex(2) --- >>> const internalConst = 10; 1 >^^^^ @@ -547,11 +579,11 @@ sourceFile:../second/second_part1.ts 3 > internalConst 4 > = 10 5 > ; -1 >Emitted(33, 5) Source(27, 26) + SourceIndex(2) -2 >Emitted(33, 11) Source(27, 32) + SourceIndex(2) -3 >Emitted(33, 24) Source(27, 45) + SourceIndex(2) -4 >Emitted(33, 29) Source(27, 50) + SourceIndex(2) -5 >Emitted(33, 30) Source(27, 51) + SourceIndex(2) +1 >Emitted(34, 5) Source(27, 26) + SourceIndex(2) +2 >Emitted(34, 11) Source(27, 32) + SourceIndex(2) +3 >Emitted(34, 24) Source(27, 45) + SourceIndex(2) +4 >Emitted(34, 29) Source(27, 50) + SourceIndex(2) +5 >Emitted(34, 30) Source(27, 51) + SourceIndex(2) --- >>> enum internalEnum { 1 >^^^^ @@ -561,9 +593,9 @@ sourceFile:../second/second_part1.ts > /*@internal*/ 2 > export enum 3 > internalEnum -1 >Emitted(34, 5) Source(28, 19) + SourceIndex(2) -2 >Emitted(34, 10) Source(28, 31) + SourceIndex(2) -3 >Emitted(34, 22) Source(28, 43) + SourceIndex(2) +1 >Emitted(35, 5) Source(28, 19) + SourceIndex(2) +2 >Emitted(35, 10) Source(28, 31) + SourceIndex(2) +3 >Emitted(35, 22) Source(28, 43) + SourceIndex(2) --- >>> a = 0, 1 >^^^^^^^^ @@ -573,9 +605,9 @@ sourceFile:../second/second_part1.ts 1 > { 2 > a 3 > -1 >Emitted(35, 9) Source(28, 46) + SourceIndex(2) -2 >Emitted(35, 10) Source(28, 47) + SourceIndex(2) -3 >Emitted(35, 14) Source(28, 47) + SourceIndex(2) +1 >Emitted(36, 9) Source(28, 46) + SourceIndex(2) +2 >Emitted(36, 10) Source(28, 47) + SourceIndex(2) +3 >Emitted(36, 14) Source(28, 47) + SourceIndex(2) --- >>> b = 1, 1->^^^^^^^^ @@ -585,9 +617,9 @@ sourceFile:../second/second_part1.ts 1->, 2 > b 3 > -1->Emitted(36, 9) Source(28, 49) + SourceIndex(2) -2 >Emitted(36, 10) Source(28, 50) + SourceIndex(2) -3 >Emitted(36, 14) Source(28, 50) + SourceIndex(2) +1->Emitted(37, 9) Source(28, 49) + SourceIndex(2) +2 >Emitted(37, 10) Source(28, 50) + SourceIndex(2) +3 >Emitted(37, 14) Source(28, 50) + SourceIndex(2) --- >>> c = 2 1->^^^^^^^^ @@ -596,21 +628,21 @@ sourceFile:../second/second_part1.ts 1->, 2 > c 3 > -1->Emitted(37, 9) Source(28, 52) + SourceIndex(2) -2 >Emitted(37, 10) Source(28, 53) + SourceIndex(2) -3 >Emitted(37, 14) Source(28, 53) + SourceIndex(2) +1->Emitted(38, 9) Source(28, 52) + SourceIndex(2) +2 >Emitted(38, 10) Source(28, 53) + SourceIndex(2) +3 >Emitted(38, 14) Source(28, 53) + SourceIndex(2) --- >>> } 1 >^^^^^ 1 > } -1 >Emitted(38, 6) Source(28, 55) + SourceIndex(2) +1 >Emitted(39, 6) Source(28, 55) + SourceIndex(2) --- >>>} 1 >^ 2 > ^^^^^^^^^^^^^^^^^^^^^^^^^-> 1 > >} -1 >Emitted(39, 2) Source(29, 2) + SourceIndex(2) +1 >Emitted(40, 2) Source(29, 2) + SourceIndex(2) --- >>>declare class internalC { 1-> @@ -620,15 +652,15 @@ sourceFile:../second/second_part1.ts >/*@internal*/ 2 >class 3 > internalC -1->Emitted(40, 1) Source(30, 15) + SourceIndex(2) -2 >Emitted(40, 15) Source(30, 21) + SourceIndex(2) -3 >Emitted(40, 24) Source(30, 30) + SourceIndex(2) +1->Emitted(41, 1) Source(30, 15) + SourceIndex(2) +2 >Emitted(41, 15) Source(30, 21) + SourceIndex(2) +3 >Emitted(41, 24) Source(30, 30) + SourceIndex(2) --- >>>} 1 >^ 2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> 1 > {} -1 >Emitted(41, 2) Source(30, 33) + SourceIndex(2) +1 >Emitted(42, 2) Source(30, 33) + SourceIndex(2) --- >>>declare function internalfoo(): void; 1-> @@ -641,10 +673,10 @@ sourceFile:../second/second_part1.ts 2 >function 3 > internalfoo 4 > () {} -1->Emitted(42, 1) Source(31, 15) + SourceIndex(2) -2 >Emitted(42, 18) Source(31, 24) + SourceIndex(2) -3 >Emitted(42, 29) Source(31, 35) + SourceIndex(2) -4 >Emitted(42, 38) Source(31, 40) + SourceIndex(2) +1->Emitted(43, 1) Source(31, 15) + SourceIndex(2) +2 >Emitted(43, 18) Source(31, 24) + SourceIndex(2) +3 >Emitted(43, 29) Source(31, 35) + SourceIndex(2) +4 >Emitted(43, 38) Source(31, 40) + SourceIndex(2) --- >>>declare namespace internalNamespace { 1-> @@ -656,10 +688,10 @@ sourceFile:../second/second_part1.ts 2 >namespace 3 > internalNamespace 4 > -1->Emitted(43, 1) Source(32, 15) + SourceIndex(2) -2 >Emitted(43, 19) Source(32, 25) + SourceIndex(2) -3 >Emitted(43, 36) Source(32, 42) + SourceIndex(2) -4 >Emitted(43, 37) Source(32, 43) + SourceIndex(2) +1->Emitted(44, 1) Source(32, 15) + SourceIndex(2) +2 >Emitted(44, 19) Source(32, 25) + SourceIndex(2) +3 >Emitted(44, 36) Source(32, 42) + SourceIndex(2) +4 >Emitted(44, 37) Source(32, 43) + SourceIndex(2) --- >>> class someClass { 1 >^^^^ @@ -668,20 +700,20 @@ sourceFile:../second/second_part1.ts 1 >{ 2 > export class 3 > someClass -1 >Emitted(44, 5) Source(32, 45) + SourceIndex(2) -2 >Emitted(44, 11) Source(32, 58) + SourceIndex(2) -3 >Emitted(44, 20) Source(32, 67) + SourceIndex(2) +1 >Emitted(45, 5) Source(32, 45) + SourceIndex(2) +2 >Emitted(45, 11) Source(32, 58) + SourceIndex(2) +3 >Emitted(45, 20) Source(32, 67) + SourceIndex(2) --- >>> } 1 >^^^^^ 1 > {} -1 >Emitted(45, 6) Source(32, 70) + SourceIndex(2) +1 >Emitted(46, 6) Source(32, 70) + SourceIndex(2) --- >>>} 1 >^ 2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> 1 > } -1 >Emitted(46, 2) Source(32, 72) + SourceIndex(2) +1 >Emitted(47, 2) Source(32, 72) + SourceIndex(2) --- >>>declare namespace internalOther.something { 1-> @@ -697,12 +729,12 @@ sourceFile:../second/second_part1.ts 4 > . 5 > something 6 > -1->Emitted(47, 1) Source(33, 15) + SourceIndex(2) -2 >Emitted(47, 19) Source(33, 25) + SourceIndex(2) -3 >Emitted(47, 32) Source(33, 38) + SourceIndex(2) -4 >Emitted(47, 33) Source(33, 39) + SourceIndex(2) -5 >Emitted(47, 42) Source(33, 48) + SourceIndex(2) -6 >Emitted(47, 43) Source(33, 49) + SourceIndex(2) +1->Emitted(48, 1) Source(33, 15) + SourceIndex(2) +2 >Emitted(48, 19) Source(33, 25) + SourceIndex(2) +3 >Emitted(48, 32) Source(33, 38) + SourceIndex(2) +4 >Emitted(48, 33) Source(33, 39) + SourceIndex(2) +5 >Emitted(48, 42) Source(33, 48) + SourceIndex(2) +6 >Emitted(48, 43) Source(33, 49) + SourceIndex(2) --- >>> class someClass { 1 >^^^^ @@ -711,20 +743,20 @@ sourceFile:../second/second_part1.ts 1 >{ 2 > export class 3 > someClass -1 >Emitted(48, 5) Source(33, 51) + SourceIndex(2) -2 >Emitted(48, 11) Source(33, 64) + SourceIndex(2) -3 >Emitted(48, 20) Source(33, 73) + SourceIndex(2) +1 >Emitted(49, 5) Source(33, 51) + SourceIndex(2) +2 >Emitted(49, 11) Source(33, 64) + SourceIndex(2) +3 >Emitted(49, 20) Source(33, 73) + SourceIndex(2) --- >>> } 1 >^^^^^ 1 > {} -1 >Emitted(49, 6) Source(33, 76) + SourceIndex(2) +1 >Emitted(50, 6) Source(33, 76) + SourceIndex(2) --- >>>} 1 >^ 2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> 1 > } -1 >Emitted(50, 2) Source(33, 78) + SourceIndex(2) +1 >Emitted(51, 2) Source(33, 78) + SourceIndex(2) --- >>>import internalImport = internalNamespace.someClass; 1-> @@ -744,14 +776,14 @@ sourceFile:../second/second_part1.ts 6 > . 7 > someClass 8 > ; -1->Emitted(51, 1) Source(34, 15) + SourceIndex(2) -2 >Emitted(51, 8) Source(34, 22) + SourceIndex(2) -3 >Emitted(51, 22) Source(34, 36) + SourceIndex(2) -4 >Emitted(51, 25) Source(34, 39) + SourceIndex(2) -5 >Emitted(51, 42) Source(34, 56) + SourceIndex(2) -6 >Emitted(51, 43) Source(34, 57) + SourceIndex(2) -7 >Emitted(51, 52) Source(34, 66) + SourceIndex(2) -8 >Emitted(51, 53) Source(34, 67) + SourceIndex(2) +1->Emitted(52, 1) Source(34, 15) + SourceIndex(2) +2 >Emitted(52, 8) Source(34, 22) + SourceIndex(2) +3 >Emitted(52, 22) Source(34, 36) + SourceIndex(2) +4 >Emitted(52, 25) Source(34, 39) + SourceIndex(2) +5 >Emitted(52, 42) Source(34, 56) + SourceIndex(2) +6 >Emitted(52, 43) Source(34, 57) + SourceIndex(2) +7 >Emitted(52, 52) Source(34, 66) + SourceIndex(2) +8 >Emitted(52, 53) Source(34, 67) + SourceIndex(2) --- >>>declare type internalType = internalC; 1 > @@ -767,12 +799,12 @@ sourceFile:../second/second_part1.ts 4 > = 5 > internalC 6 > ; -1 >Emitted(52, 1) Source(35, 15) + SourceIndex(2) -2 >Emitted(52, 14) Source(35, 20) + SourceIndex(2) -3 >Emitted(52, 26) Source(35, 32) + SourceIndex(2) -4 >Emitted(52, 29) Source(35, 35) + SourceIndex(2) -5 >Emitted(52, 38) Source(35, 44) + SourceIndex(2) -6 >Emitted(52, 39) Source(35, 45) + SourceIndex(2) +1 >Emitted(53, 1) Source(35, 15) + SourceIndex(2) +2 >Emitted(53, 14) Source(35, 20) + SourceIndex(2) +3 >Emitted(53, 26) Source(35, 32) + SourceIndex(2) +4 >Emitted(53, 29) Source(35, 35) + SourceIndex(2) +5 >Emitted(53, 38) Source(35, 44) + SourceIndex(2) +6 >Emitted(53, 39) Source(35, 45) + SourceIndex(2) --- >>>declare const internalConst = 10; 1 > @@ -788,12 +820,12 @@ sourceFile:../second/second_part1.ts 4 > internalConst 5 > = 10 6 > ; -1 >Emitted(53, 1) Source(36, 15) + SourceIndex(2) -2 >Emitted(53, 9) Source(36, 15) + SourceIndex(2) -3 >Emitted(53, 15) Source(36, 21) + SourceIndex(2) -4 >Emitted(53, 28) Source(36, 34) + SourceIndex(2) -5 >Emitted(53, 33) Source(36, 39) + SourceIndex(2) -6 >Emitted(53, 34) Source(36, 40) + SourceIndex(2) +1 >Emitted(54, 1) Source(36, 15) + SourceIndex(2) +2 >Emitted(54, 9) Source(36, 15) + SourceIndex(2) +3 >Emitted(54, 15) Source(36, 21) + SourceIndex(2) +4 >Emitted(54, 28) Source(36, 34) + SourceIndex(2) +5 >Emitted(54, 33) Source(36, 39) + SourceIndex(2) +6 >Emitted(54, 34) Source(36, 40) + SourceIndex(2) --- >>>declare enum internalEnum { 1 > @@ -803,9 +835,9 @@ sourceFile:../second/second_part1.ts >/*@internal*/ 2 >enum 3 > internalEnum -1 >Emitted(54, 1) Source(37, 15) + SourceIndex(2) -2 >Emitted(54, 14) Source(37, 20) + SourceIndex(2) -3 >Emitted(54, 26) Source(37, 32) + SourceIndex(2) +1 >Emitted(55, 1) Source(37, 15) + SourceIndex(2) +2 >Emitted(55, 14) Source(37, 20) + SourceIndex(2) +3 >Emitted(55, 26) Source(37, 32) + SourceIndex(2) --- >>> a = 0, 1 >^^^^ @@ -815,9 +847,9 @@ sourceFile:../second/second_part1.ts 1 > { 2 > a 3 > -1 >Emitted(55, 5) Source(37, 35) + SourceIndex(2) -2 >Emitted(55, 6) Source(37, 36) + SourceIndex(2) -3 >Emitted(55, 10) Source(37, 36) + SourceIndex(2) +1 >Emitted(56, 5) Source(37, 35) + SourceIndex(2) +2 >Emitted(56, 6) Source(37, 36) + SourceIndex(2) +3 >Emitted(56, 10) Source(37, 36) + SourceIndex(2) --- >>> b = 1, 1->^^^^ @@ -827,9 +859,9 @@ sourceFile:../second/second_part1.ts 1->, 2 > b 3 > -1->Emitted(56, 5) Source(37, 38) + SourceIndex(2) -2 >Emitted(56, 6) Source(37, 39) + SourceIndex(2) -3 >Emitted(56, 10) Source(37, 39) + SourceIndex(2) +1->Emitted(57, 5) Source(37, 38) + SourceIndex(2) +2 >Emitted(57, 6) Source(37, 39) + SourceIndex(2) +3 >Emitted(57, 10) Source(37, 39) + SourceIndex(2) --- >>> c = 2 1->^^^^ @@ -838,15 +870,15 @@ sourceFile:../second/second_part1.ts 1->, 2 > c 3 > -1->Emitted(57, 5) Source(37, 41) + SourceIndex(2) -2 >Emitted(57, 6) Source(37, 42) + SourceIndex(2) -3 >Emitted(57, 10) Source(37, 42) + SourceIndex(2) +1->Emitted(58, 5) Source(37, 41) + SourceIndex(2) +2 >Emitted(58, 6) Source(37, 42) + SourceIndex(2) +3 >Emitted(58, 10) Source(37, 42) + SourceIndex(2) --- >>>} 1 >^ 2 > ^^^^^^^^^^^^^^^^^-> 1 > } -1 >Emitted(58, 2) Source(37, 44) + SourceIndex(2) +1 >Emitted(59, 2) Source(37, 44) + SourceIndex(2) --- ------------------------------------------------------------------- emittedFile:/src/2/second-output.d.ts @@ -860,9 +892,9 @@ sourceFile:../second/second_part2.ts 1-> 2 >class 3 > C -1->Emitted(59, 1) Source(1, 1) + SourceIndex(3) -2 >Emitted(59, 15) Source(1, 7) + SourceIndex(3) -3 >Emitted(59, 16) Source(1, 8) + SourceIndex(3) +1->Emitted(60, 1) Source(1, 1) + SourceIndex(3) +2 >Emitted(60, 15) Source(1, 7) + SourceIndex(3) +3 >Emitted(60, 16) Source(1, 8) + SourceIndex(3) --- >>> doSomething(): void; 1->^^^^ @@ -870,8 +902,8 @@ sourceFile:../second/second_part2.ts 1-> { > 2 > doSomething -1->Emitted(60, 5) Source(2, 5) + SourceIndex(3) -2 >Emitted(60, 16) Source(2, 16) + SourceIndex(3) +1->Emitted(61, 5) Source(2, 5) + SourceIndex(3) +2 >Emitted(61, 16) Source(2, 16) + SourceIndex(3) --- >>>} 1 >^ @@ -880,7 +912,7 @@ sourceFile:../second/second_part2.ts > console.log("something got done"); > } >} -1 >Emitted(61, 2) Source(5, 2) + SourceIndex(3) +1 >Emitted(62, 2) Source(5, 2) + SourceIndex(3) --- >>>//# sourceMappingURL=second-output.d.ts.map @@ -2636,32 +2668,32 @@ sourceFile:../second/second_part2.ts }, { "pos": 234, - "end": 308, + "end": 339, "kind": "internal" }, { - "pos": 310, - "end": 342, + "pos": 341, + "end": 373, "kind": "text" }, { - "pos": 342, - "end": 734, + "pos": 373, + "end": 765, "kind": "internal" }, { - "pos": 736, - "end": 739, + "pos": 767, + "end": 770, "kind": "text" }, { - "pos": 739, - "end": 1152, + "pos": 770, + "end": 1183, "kind": "internal" }, { - "pos": 1154, - "end": 1202, + "pos": 1185, + "end": 1233, "kind": "text" } ] @@ -2816,18 +2848,19 @@ declare namespace N { declare class normalC { ---------------------------------------------------------------------- -internal: (234-308) +internal: (234-339) constructor(); prop: string; method(): void; - c: number; + get c(): number; + set c(val: number); ---------------------------------------------------------------------- -text: (310-342) +text: (341-373) } declare namespace normalN { ---------------------------------------------------------------------- -internal: (342-734) +internal: (373-765) class C { } function foo(): void; @@ -2848,11 +2881,11 @@ internal: (342-734) c = 2 } ---------------------------------------------------------------------- -text: (736-739) +text: (767-770) } ---------------------------------------------------------------------- -internal: (739-1152) +internal: (770-1183) declare class internalC { } declare function internalfoo(): void; @@ -2873,7 +2906,7 @@ declare enum internalEnum { c = 2 } ---------------------------------------------------------------------- -text: (1154-1202) +text: (1185-1233) declare class C { doSomething(): void; } diff --git a/tests/baselines/reference/tsbuild/outfile-concat/initial-build/stripInternal-with-comments-emit-enabled-when-one-two-three-are-prepended-in-order.js b/tests/baselines/reference/tsbuild/outfile-concat/initial-build/stripInternal-with-comments-emit-enabled-when-one-two-three-are-prepended-in-order.js index fa4c05b80fe0e..b9106767cea94 100644 --- a/tests/baselines/reference/tsbuild/outfile-concat/initial-build/stripInternal-with-comments-emit-enabled-when-one-two-three-are-prepended-in-order.js +++ b/tests/baselines/reference/tsbuild/outfile-concat/initial-build/stripInternal-with-comments-emit-enabled-when-one-two-three-are-prepended-in-order.js @@ -37,7 +37,8 @@ declare class normalC { constructor(); prop: string; method(): void; - /*@internal*/ c: number; + get c(): number; + set c(val: number); } declare namespace normalN { class C { @@ -85,7 +86,7 @@ declare class C { //# sourceMappingURL=second-output.d.ts.map //// [/src/2/second-output.d.ts.map] -{"version":3,"file":"second-output.d.ts","sourceRoot":"","sources":["../first/first_PART1.ts","../first/first_part3.ts","../second/second_part1.ts","../second/second_part2.ts"],"names":[],"mappings":"AAAc,UAAU,QAAQ;IAC5B,IAAI,EAAE,GAAG,CAAC;CACb;AAED,QAAA,MAAM,CAAC,iBAAiB,CAAC;AAEzB,UAAU,iBAAiB;IACvB,IAAI,EAAE,GAAG,CAAC;CACb;ACRD,iBAAS,CAAC,WAET;ACFD,kBAAU,CAAC,CAAC;CAEX;AAED,kBAAU,CAAC,CAAC;CAMX;AAED,cAAM,OAAO;;IAEK,IAAI,EAAE,MAAM,CAAC;IACb,MAAM;kBACF,CAAC,EACM,MAAM;CAClC;AACD,kBAAU,OAAO,CAAC;IACA,MAAa,CAAC;KAAI;IAClB,SAAgB,GAAG,SAAK;IACxB,UAAiB,aAAa,CAAC;QAAE,MAAa,CAAC;SAAG;KAAE;IACpD,UAAiB,SAAS,CAAC,SAAS,CAAC;QAAE,MAAa,SAAS;SAAG;KAAE;IAClE,MAAM,QAAQ,UAAU,GAAG,aAAa,CAAC,CAAC,CAAC;IAC3C,KAAY,YAAY,GAAG,SAAS,CAAC;IAC9B,MAAM,aAAa,KAAK,CAAC;IAChC,KAAY,YAAY;QAAG,CAAC,IAAA;QAAE,CAAC,IAAA;QAAE,CAAC,IAAA;KAAE;CACrD;AACa,cAAM,SAAS;CAAG;AAClB,iBAAS,WAAW,SAAK;AACzB,kBAAU,iBAAiB,CAAC;IAAE,MAAa,SAAS;KAAG;CAAE;AACzD,kBAAU,aAAa,CAAC,SAAS,CAAC;IAAE,MAAa,SAAS;KAAG;CAAE;AAC/D,OAAO,cAAc,GAAG,iBAAiB,CAAC,SAAS,CAAC;AACpD,aAAK,YAAY,GAAG,SAAS,CAAC;AAC9B,QAAA,MAAM,aAAa,KAAK,CAAC;AACzB,aAAK,YAAY;IAAG,CAAC,IAAA;IAAE,CAAC,IAAA;IAAE,CAAC,IAAA;CAAE;ACpC3C,cAAM,CAAC;IACH,WAAW;CAGd"} +{"version":3,"file":"second-output.d.ts","sourceRoot":"","sources":["../first/first_PART1.ts","../first/first_part3.ts","../second/second_part1.ts","../second/second_part2.ts"],"names":[],"mappings":"AAAc,UAAU,QAAQ;IAC5B,IAAI,EAAE,GAAG,CAAC;CACb;AAED,QAAA,MAAM,CAAC,iBAAiB,CAAC;AAEzB,UAAU,iBAAiB;IACvB,IAAI,EAAE,GAAG,CAAC;CACb;ACRD,iBAAS,CAAC,WAET;ACFD,kBAAU,CAAC,CAAC;CAEX;AAED,kBAAU,CAAC,CAAC;CAMX;AAED,cAAM,OAAO;;IAEK,IAAI,EAAE,MAAM,CAAC;IACb,MAAM;IACN,IAAI,CAAC,IACM,MAAM,CADK;IACtB,IAAI,CAAC,CAAC,KAAK,MAAM,EAAK;CACvC;AACD,kBAAU,OAAO,CAAC;IACA,MAAa,CAAC;KAAI;IAClB,SAAgB,GAAG,SAAK;IACxB,UAAiB,aAAa,CAAC;QAAE,MAAa,CAAC;SAAG;KAAE;IACpD,UAAiB,SAAS,CAAC,SAAS,CAAC;QAAE,MAAa,SAAS;SAAG;KAAE;IAClE,MAAM,QAAQ,UAAU,GAAG,aAAa,CAAC,CAAC,CAAC;IAC3C,KAAY,YAAY,GAAG,SAAS,CAAC;IAC9B,MAAM,aAAa,KAAK,CAAC;IAChC,KAAY,YAAY;QAAG,CAAC,IAAA;QAAE,CAAC,IAAA;QAAE,CAAC,IAAA;KAAE;CACrD;AACa,cAAM,SAAS;CAAG;AAClB,iBAAS,WAAW,SAAK;AACzB,kBAAU,iBAAiB,CAAC;IAAE,MAAa,SAAS;KAAG;CAAE;AACzD,kBAAU,aAAa,CAAC,SAAS,CAAC;IAAE,MAAa,SAAS;KAAG;CAAE;AAC/D,OAAO,cAAc,GAAG,iBAAiB,CAAC,SAAS,CAAC;AACpD,aAAK,YAAY,GAAG,SAAS,CAAC;AAC9B,QAAA,MAAM,aAAa,KAAK,CAAC;AACzB,aAAK,YAAY;IAAG,CAAC,IAAA;IAAE,CAAC,IAAA;IAAE,CAAC,IAAA;CAAE;ACpC3C,cAAM,CAAC;IACH,WAAW;CAGd"} //// [/src/2/second-output.d.ts.map.baseline.txt] =================================================================== @@ -305,35 +306,66 @@ sourceFile:../second/second_part1.ts >>> method(): void; 1->^^^^ 2 > ^^^^^^ -3 > ^^^^^^^^^^^^^^^^^^^-> +3 > ^^^^^^^^^^^-> 1-> > /*@internal*/ 2 > method 1->Emitted(16, 5) Source(16, 19) + SourceIndex(2) 2 >Emitted(16, 11) Source(16, 25) + SourceIndex(2) --- ->>> /*@internal*/ c: number; -1->^^^^^^^^^^^^^^^^^^ -2 > ^ -3 > ^^ -4 > ^^^^^^ +>>> get c(): number; +1->^^^^ +2 > ^^^^ +3 > ^ +4 > ^^^^ +5 > ^^^^^^ +6 > ^ +7 > ^^^^-> 1->() { } - > /*@internal*/ get -2 > c -3 > () { return 10; } - > /*@internal*/ set c(val: -4 > number -1->Emitted(17, 19) Source(17, 23) + SourceIndex(2) -2 >Emitted(17, 20) Source(17, 24) + SourceIndex(2) -3 >Emitted(17, 22) Source(18, 30) + SourceIndex(2) -4 >Emitted(17, 28) Source(18, 36) + SourceIndex(2) + > /*@internal*/ +2 > get +3 > c +4 > () { return 10; } + > /*@internal*/ set c(val: +5 > number +6 > +1->Emitted(17, 5) Source(17, 19) + SourceIndex(2) +2 >Emitted(17, 9) Source(17, 23) + SourceIndex(2) +3 >Emitted(17, 10) Source(17, 24) + SourceIndex(2) +4 >Emitted(17, 14) Source(18, 30) + SourceIndex(2) +5 >Emitted(17, 20) Source(18, 36) + SourceIndex(2) +6 >Emitted(17, 21) Source(17, 41) + SourceIndex(2) +--- +>>> set c(val: number); +1->^^^^ +2 > ^^^^ +3 > ^ +4 > ^ +5 > ^^^^^ +6 > ^^^^^^ +7 > ^^ +1-> + > /*@internal*/ +2 > set +3 > c +4 > ( +5 > val: +6 > number +7 > ) { } +1->Emitted(18, 5) Source(18, 19) + SourceIndex(2) +2 >Emitted(18, 9) Source(18, 23) + SourceIndex(2) +3 >Emitted(18, 10) Source(18, 24) + SourceIndex(2) +4 >Emitted(18, 11) Source(18, 25) + SourceIndex(2) +5 >Emitted(18, 16) Source(18, 30) + SourceIndex(2) +6 >Emitted(18, 22) Source(18, 36) + SourceIndex(2) +7 >Emitted(18, 24) Source(18, 41) + SourceIndex(2) --- >>>} 1 >^ 2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1 >) { } +1 > >} -1 >Emitted(18, 2) Source(19, 2) + SourceIndex(2) +1 >Emitted(19, 2) Source(19, 2) + SourceIndex(2) --- >>>declare namespace normalN { 1-> @@ -345,10 +377,10 @@ sourceFile:../second/second_part1.ts 2 >namespace 3 > normalN 4 > -1->Emitted(19, 1) Source(20, 1) + SourceIndex(2) -2 >Emitted(19, 19) Source(20, 11) + SourceIndex(2) -3 >Emitted(19, 26) Source(20, 18) + SourceIndex(2) -4 >Emitted(19, 27) Source(20, 19) + SourceIndex(2) +1->Emitted(20, 1) Source(20, 1) + SourceIndex(2) +2 >Emitted(20, 19) Source(20, 11) + SourceIndex(2) +3 >Emitted(20, 26) Source(20, 18) + SourceIndex(2) +4 >Emitted(20, 27) Source(20, 19) + SourceIndex(2) --- >>> class C { 1 >^^^^ @@ -358,15 +390,15 @@ sourceFile:../second/second_part1.ts > /*@internal*/ 2 > export class 3 > C -1 >Emitted(20, 5) Source(21, 19) + SourceIndex(2) -2 >Emitted(20, 11) Source(21, 32) + SourceIndex(2) -3 >Emitted(20, 12) Source(21, 33) + SourceIndex(2) +1 >Emitted(21, 5) Source(21, 19) + SourceIndex(2) +2 >Emitted(21, 11) Source(21, 32) + SourceIndex(2) +3 >Emitted(21, 12) Source(21, 33) + SourceIndex(2) --- >>> } 1 >^^^^^ 2 > ^^^^^^^^^^^^^^^^^^^^^-> 1 > { } -1 >Emitted(21, 6) Source(21, 37) + SourceIndex(2) +1 >Emitted(22, 6) Source(21, 37) + SourceIndex(2) --- >>> function foo(): void; 1->^^^^ @@ -379,10 +411,10 @@ sourceFile:../second/second_part1.ts 2 > export function 3 > foo 4 > () {} -1->Emitted(22, 5) Source(22, 19) + SourceIndex(2) -2 >Emitted(22, 14) Source(22, 35) + SourceIndex(2) -3 >Emitted(22, 17) Source(22, 38) + SourceIndex(2) -4 >Emitted(22, 26) Source(22, 43) + SourceIndex(2) +1->Emitted(23, 5) Source(22, 19) + SourceIndex(2) +2 >Emitted(23, 14) Source(22, 35) + SourceIndex(2) +3 >Emitted(23, 17) Source(22, 38) + SourceIndex(2) +4 >Emitted(23, 26) Source(22, 43) + SourceIndex(2) --- >>> namespace someNamespace { 1->^^^^ @@ -394,10 +426,10 @@ sourceFile:../second/second_part1.ts 2 > export namespace 3 > someNamespace 4 > -1->Emitted(23, 5) Source(23, 19) + SourceIndex(2) -2 >Emitted(23, 15) Source(23, 36) + SourceIndex(2) -3 >Emitted(23, 28) Source(23, 49) + SourceIndex(2) -4 >Emitted(23, 29) Source(23, 50) + SourceIndex(2) +1->Emitted(24, 5) Source(23, 19) + SourceIndex(2) +2 >Emitted(24, 15) Source(23, 36) + SourceIndex(2) +3 >Emitted(24, 28) Source(23, 49) + SourceIndex(2) +4 >Emitted(24, 29) Source(23, 50) + SourceIndex(2) --- >>> class C { 1 >^^^^^^^^ @@ -406,20 +438,20 @@ sourceFile:../second/second_part1.ts 1 >{ 2 > export class 3 > C -1 >Emitted(24, 9) Source(23, 52) + SourceIndex(2) -2 >Emitted(24, 15) Source(23, 65) + SourceIndex(2) -3 >Emitted(24, 16) Source(23, 66) + SourceIndex(2) +1 >Emitted(25, 9) Source(23, 52) + SourceIndex(2) +2 >Emitted(25, 15) Source(23, 65) + SourceIndex(2) +3 >Emitted(25, 16) Source(23, 66) + SourceIndex(2) --- >>> } 1 >^^^^^^^^^ 1 > {} -1 >Emitted(25, 10) Source(23, 69) + SourceIndex(2) +1 >Emitted(26, 10) Source(23, 69) + SourceIndex(2) --- >>> } 1 >^^^^^ 2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> 1 > } -1 >Emitted(26, 6) Source(23, 71) + SourceIndex(2) +1 >Emitted(27, 6) Source(23, 71) + SourceIndex(2) --- >>> namespace someOther.something { 1->^^^^ @@ -435,12 +467,12 @@ sourceFile:../second/second_part1.ts 4 > . 5 > something 6 > -1->Emitted(27, 5) Source(24, 19) + SourceIndex(2) -2 >Emitted(27, 15) Source(24, 36) + SourceIndex(2) -3 >Emitted(27, 24) Source(24, 45) + SourceIndex(2) -4 >Emitted(27, 25) Source(24, 46) + SourceIndex(2) -5 >Emitted(27, 34) Source(24, 55) + SourceIndex(2) -6 >Emitted(27, 35) Source(24, 56) + SourceIndex(2) +1->Emitted(28, 5) Source(24, 19) + SourceIndex(2) +2 >Emitted(28, 15) Source(24, 36) + SourceIndex(2) +3 >Emitted(28, 24) Source(24, 45) + SourceIndex(2) +4 >Emitted(28, 25) Source(24, 46) + SourceIndex(2) +5 >Emitted(28, 34) Source(24, 55) + SourceIndex(2) +6 >Emitted(28, 35) Source(24, 56) + SourceIndex(2) --- >>> class someClass { 1 >^^^^^^^^ @@ -449,20 +481,20 @@ sourceFile:../second/second_part1.ts 1 >{ 2 > export class 3 > someClass -1 >Emitted(28, 9) Source(24, 58) + SourceIndex(2) -2 >Emitted(28, 15) Source(24, 71) + SourceIndex(2) -3 >Emitted(28, 24) Source(24, 80) + SourceIndex(2) +1 >Emitted(29, 9) Source(24, 58) + SourceIndex(2) +2 >Emitted(29, 15) Source(24, 71) + SourceIndex(2) +3 >Emitted(29, 24) Source(24, 80) + SourceIndex(2) --- >>> } 1 >^^^^^^^^^ 1 > {} -1 >Emitted(29, 10) Source(24, 83) + SourceIndex(2) +1 >Emitted(30, 10) Source(24, 83) + SourceIndex(2) --- >>> } 1 >^^^^^ 2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> 1 > } -1 >Emitted(30, 6) Source(24, 85) + SourceIndex(2) +1 >Emitted(31, 6) Source(24, 85) + SourceIndex(2) --- >>> export import someImport = someNamespace.C; 1->^^^^ @@ -484,15 +516,15 @@ sourceFile:../second/second_part1.ts 7 > . 8 > C 9 > ; -1->Emitted(31, 5) Source(25, 19) + SourceIndex(2) -2 >Emitted(31, 11) Source(25, 25) + SourceIndex(2) -3 >Emitted(31, 19) Source(25, 33) + SourceIndex(2) -4 >Emitted(31, 29) Source(25, 43) + SourceIndex(2) -5 >Emitted(31, 32) Source(25, 46) + SourceIndex(2) -6 >Emitted(31, 45) Source(25, 59) + SourceIndex(2) -7 >Emitted(31, 46) Source(25, 60) + SourceIndex(2) -8 >Emitted(31, 47) Source(25, 61) + SourceIndex(2) -9 >Emitted(31, 48) Source(25, 62) + SourceIndex(2) +1->Emitted(32, 5) Source(25, 19) + SourceIndex(2) +2 >Emitted(32, 11) Source(25, 25) + SourceIndex(2) +3 >Emitted(32, 19) Source(25, 33) + SourceIndex(2) +4 >Emitted(32, 29) Source(25, 43) + SourceIndex(2) +5 >Emitted(32, 32) Source(25, 46) + SourceIndex(2) +6 >Emitted(32, 45) Source(25, 59) + SourceIndex(2) +7 >Emitted(32, 46) Source(25, 60) + SourceIndex(2) +8 >Emitted(32, 47) Source(25, 61) + SourceIndex(2) +9 >Emitted(32, 48) Source(25, 62) + SourceIndex(2) --- >>> type internalType = internalC; 1 >^^^^ @@ -508,12 +540,12 @@ sourceFile:../second/second_part1.ts 4 > = 5 > internalC 6 > ; -1 >Emitted(32, 5) Source(26, 19) + SourceIndex(2) -2 >Emitted(32, 10) Source(26, 31) + SourceIndex(2) -3 >Emitted(32, 22) Source(26, 43) + SourceIndex(2) -4 >Emitted(32, 25) Source(26, 46) + SourceIndex(2) -5 >Emitted(32, 34) Source(26, 55) + SourceIndex(2) -6 >Emitted(32, 35) Source(26, 56) + SourceIndex(2) +1 >Emitted(33, 5) Source(26, 19) + SourceIndex(2) +2 >Emitted(33, 10) Source(26, 31) + SourceIndex(2) +3 >Emitted(33, 22) Source(26, 43) + SourceIndex(2) +4 >Emitted(33, 25) Source(26, 46) + SourceIndex(2) +5 >Emitted(33, 34) Source(26, 55) + SourceIndex(2) +6 >Emitted(33, 35) Source(26, 56) + SourceIndex(2) --- >>> const internalConst = 10; 1 >^^^^ @@ -527,11 +559,11 @@ sourceFile:../second/second_part1.ts 3 > internalConst 4 > = 10 5 > ; -1 >Emitted(33, 5) Source(27, 26) + SourceIndex(2) -2 >Emitted(33, 11) Source(27, 32) + SourceIndex(2) -3 >Emitted(33, 24) Source(27, 45) + SourceIndex(2) -4 >Emitted(33, 29) Source(27, 50) + SourceIndex(2) -5 >Emitted(33, 30) Source(27, 51) + SourceIndex(2) +1 >Emitted(34, 5) Source(27, 26) + SourceIndex(2) +2 >Emitted(34, 11) Source(27, 32) + SourceIndex(2) +3 >Emitted(34, 24) Source(27, 45) + SourceIndex(2) +4 >Emitted(34, 29) Source(27, 50) + SourceIndex(2) +5 >Emitted(34, 30) Source(27, 51) + SourceIndex(2) --- >>> enum internalEnum { 1 >^^^^ @@ -541,9 +573,9 @@ sourceFile:../second/second_part1.ts > /*@internal*/ 2 > export enum 3 > internalEnum -1 >Emitted(34, 5) Source(28, 19) + SourceIndex(2) -2 >Emitted(34, 10) Source(28, 31) + SourceIndex(2) -3 >Emitted(34, 22) Source(28, 43) + SourceIndex(2) +1 >Emitted(35, 5) Source(28, 19) + SourceIndex(2) +2 >Emitted(35, 10) Source(28, 31) + SourceIndex(2) +3 >Emitted(35, 22) Source(28, 43) + SourceIndex(2) --- >>> a = 0, 1 >^^^^^^^^ @@ -553,9 +585,9 @@ sourceFile:../second/second_part1.ts 1 > { 2 > a 3 > -1 >Emitted(35, 9) Source(28, 46) + SourceIndex(2) -2 >Emitted(35, 10) Source(28, 47) + SourceIndex(2) -3 >Emitted(35, 14) Source(28, 47) + SourceIndex(2) +1 >Emitted(36, 9) Source(28, 46) + SourceIndex(2) +2 >Emitted(36, 10) Source(28, 47) + SourceIndex(2) +3 >Emitted(36, 14) Source(28, 47) + SourceIndex(2) --- >>> b = 1, 1->^^^^^^^^ @@ -565,9 +597,9 @@ sourceFile:../second/second_part1.ts 1->, 2 > b 3 > -1->Emitted(36, 9) Source(28, 49) + SourceIndex(2) -2 >Emitted(36, 10) Source(28, 50) + SourceIndex(2) -3 >Emitted(36, 14) Source(28, 50) + SourceIndex(2) +1->Emitted(37, 9) Source(28, 49) + SourceIndex(2) +2 >Emitted(37, 10) Source(28, 50) + SourceIndex(2) +3 >Emitted(37, 14) Source(28, 50) + SourceIndex(2) --- >>> c = 2 1->^^^^^^^^ @@ -576,21 +608,21 @@ sourceFile:../second/second_part1.ts 1->, 2 > c 3 > -1->Emitted(37, 9) Source(28, 52) + SourceIndex(2) -2 >Emitted(37, 10) Source(28, 53) + SourceIndex(2) -3 >Emitted(37, 14) Source(28, 53) + SourceIndex(2) +1->Emitted(38, 9) Source(28, 52) + SourceIndex(2) +2 >Emitted(38, 10) Source(28, 53) + SourceIndex(2) +3 >Emitted(38, 14) Source(28, 53) + SourceIndex(2) --- >>> } 1 >^^^^^ 1 > } -1 >Emitted(38, 6) Source(28, 55) + SourceIndex(2) +1 >Emitted(39, 6) Source(28, 55) + SourceIndex(2) --- >>>} 1 >^ 2 > ^^^^^^^^^^^^^^^^^^^^^^^^^-> 1 > >} -1 >Emitted(39, 2) Source(29, 2) + SourceIndex(2) +1 >Emitted(40, 2) Source(29, 2) + SourceIndex(2) --- >>>declare class internalC { 1-> @@ -600,15 +632,15 @@ sourceFile:../second/second_part1.ts >/*@internal*/ 2 >class 3 > internalC -1->Emitted(40, 1) Source(30, 15) + SourceIndex(2) -2 >Emitted(40, 15) Source(30, 21) + SourceIndex(2) -3 >Emitted(40, 24) Source(30, 30) + SourceIndex(2) +1->Emitted(41, 1) Source(30, 15) + SourceIndex(2) +2 >Emitted(41, 15) Source(30, 21) + SourceIndex(2) +3 >Emitted(41, 24) Source(30, 30) + SourceIndex(2) --- >>>} 1 >^ 2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> 1 > {} -1 >Emitted(41, 2) Source(30, 33) + SourceIndex(2) +1 >Emitted(42, 2) Source(30, 33) + SourceIndex(2) --- >>>declare function internalfoo(): void; 1-> @@ -621,10 +653,10 @@ sourceFile:../second/second_part1.ts 2 >function 3 > internalfoo 4 > () {} -1->Emitted(42, 1) Source(31, 15) + SourceIndex(2) -2 >Emitted(42, 18) Source(31, 24) + SourceIndex(2) -3 >Emitted(42, 29) Source(31, 35) + SourceIndex(2) -4 >Emitted(42, 38) Source(31, 40) + SourceIndex(2) +1->Emitted(43, 1) Source(31, 15) + SourceIndex(2) +2 >Emitted(43, 18) Source(31, 24) + SourceIndex(2) +3 >Emitted(43, 29) Source(31, 35) + SourceIndex(2) +4 >Emitted(43, 38) Source(31, 40) + SourceIndex(2) --- >>>declare namespace internalNamespace { 1-> @@ -636,10 +668,10 @@ sourceFile:../second/second_part1.ts 2 >namespace 3 > internalNamespace 4 > -1->Emitted(43, 1) Source(32, 15) + SourceIndex(2) -2 >Emitted(43, 19) Source(32, 25) + SourceIndex(2) -3 >Emitted(43, 36) Source(32, 42) + SourceIndex(2) -4 >Emitted(43, 37) Source(32, 43) + SourceIndex(2) +1->Emitted(44, 1) Source(32, 15) + SourceIndex(2) +2 >Emitted(44, 19) Source(32, 25) + SourceIndex(2) +3 >Emitted(44, 36) Source(32, 42) + SourceIndex(2) +4 >Emitted(44, 37) Source(32, 43) + SourceIndex(2) --- >>> class someClass { 1 >^^^^ @@ -648,20 +680,20 @@ sourceFile:../second/second_part1.ts 1 >{ 2 > export class 3 > someClass -1 >Emitted(44, 5) Source(32, 45) + SourceIndex(2) -2 >Emitted(44, 11) Source(32, 58) + SourceIndex(2) -3 >Emitted(44, 20) Source(32, 67) + SourceIndex(2) +1 >Emitted(45, 5) Source(32, 45) + SourceIndex(2) +2 >Emitted(45, 11) Source(32, 58) + SourceIndex(2) +3 >Emitted(45, 20) Source(32, 67) + SourceIndex(2) --- >>> } 1 >^^^^^ 1 > {} -1 >Emitted(45, 6) Source(32, 70) + SourceIndex(2) +1 >Emitted(46, 6) Source(32, 70) + SourceIndex(2) --- >>>} 1 >^ 2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> 1 > } -1 >Emitted(46, 2) Source(32, 72) + SourceIndex(2) +1 >Emitted(47, 2) Source(32, 72) + SourceIndex(2) --- >>>declare namespace internalOther.something { 1-> @@ -677,12 +709,12 @@ sourceFile:../second/second_part1.ts 4 > . 5 > something 6 > -1->Emitted(47, 1) Source(33, 15) + SourceIndex(2) -2 >Emitted(47, 19) Source(33, 25) + SourceIndex(2) -3 >Emitted(47, 32) Source(33, 38) + SourceIndex(2) -4 >Emitted(47, 33) Source(33, 39) + SourceIndex(2) -5 >Emitted(47, 42) Source(33, 48) + SourceIndex(2) -6 >Emitted(47, 43) Source(33, 49) + SourceIndex(2) +1->Emitted(48, 1) Source(33, 15) + SourceIndex(2) +2 >Emitted(48, 19) Source(33, 25) + SourceIndex(2) +3 >Emitted(48, 32) Source(33, 38) + SourceIndex(2) +4 >Emitted(48, 33) Source(33, 39) + SourceIndex(2) +5 >Emitted(48, 42) Source(33, 48) + SourceIndex(2) +6 >Emitted(48, 43) Source(33, 49) + SourceIndex(2) --- >>> class someClass { 1 >^^^^ @@ -691,20 +723,20 @@ sourceFile:../second/second_part1.ts 1 >{ 2 > export class 3 > someClass -1 >Emitted(48, 5) Source(33, 51) + SourceIndex(2) -2 >Emitted(48, 11) Source(33, 64) + SourceIndex(2) -3 >Emitted(48, 20) Source(33, 73) + SourceIndex(2) +1 >Emitted(49, 5) Source(33, 51) + SourceIndex(2) +2 >Emitted(49, 11) Source(33, 64) + SourceIndex(2) +3 >Emitted(49, 20) Source(33, 73) + SourceIndex(2) --- >>> } 1 >^^^^^ 1 > {} -1 >Emitted(49, 6) Source(33, 76) + SourceIndex(2) +1 >Emitted(50, 6) Source(33, 76) + SourceIndex(2) --- >>>} 1 >^ 2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> 1 > } -1 >Emitted(50, 2) Source(33, 78) + SourceIndex(2) +1 >Emitted(51, 2) Source(33, 78) + SourceIndex(2) --- >>>import internalImport = internalNamespace.someClass; 1-> @@ -724,14 +756,14 @@ sourceFile:../second/second_part1.ts 6 > . 7 > someClass 8 > ; -1->Emitted(51, 1) Source(34, 15) + SourceIndex(2) -2 >Emitted(51, 8) Source(34, 22) + SourceIndex(2) -3 >Emitted(51, 22) Source(34, 36) + SourceIndex(2) -4 >Emitted(51, 25) Source(34, 39) + SourceIndex(2) -5 >Emitted(51, 42) Source(34, 56) + SourceIndex(2) -6 >Emitted(51, 43) Source(34, 57) + SourceIndex(2) -7 >Emitted(51, 52) Source(34, 66) + SourceIndex(2) -8 >Emitted(51, 53) Source(34, 67) + SourceIndex(2) +1->Emitted(52, 1) Source(34, 15) + SourceIndex(2) +2 >Emitted(52, 8) Source(34, 22) + SourceIndex(2) +3 >Emitted(52, 22) Source(34, 36) + SourceIndex(2) +4 >Emitted(52, 25) Source(34, 39) + SourceIndex(2) +5 >Emitted(52, 42) Source(34, 56) + SourceIndex(2) +6 >Emitted(52, 43) Source(34, 57) + SourceIndex(2) +7 >Emitted(52, 52) Source(34, 66) + SourceIndex(2) +8 >Emitted(52, 53) Source(34, 67) + SourceIndex(2) --- >>>declare type internalType = internalC; 1 > @@ -747,12 +779,12 @@ sourceFile:../second/second_part1.ts 4 > = 5 > internalC 6 > ; -1 >Emitted(52, 1) Source(35, 15) + SourceIndex(2) -2 >Emitted(52, 14) Source(35, 20) + SourceIndex(2) -3 >Emitted(52, 26) Source(35, 32) + SourceIndex(2) -4 >Emitted(52, 29) Source(35, 35) + SourceIndex(2) -5 >Emitted(52, 38) Source(35, 44) + SourceIndex(2) -6 >Emitted(52, 39) Source(35, 45) + SourceIndex(2) +1 >Emitted(53, 1) Source(35, 15) + SourceIndex(2) +2 >Emitted(53, 14) Source(35, 20) + SourceIndex(2) +3 >Emitted(53, 26) Source(35, 32) + SourceIndex(2) +4 >Emitted(53, 29) Source(35, 35) + SourceIndex(2) +5 >Emitted(53, 38) Source(35, 44) + SourceIndex(2) +6 >Emitted(53, 39) Source(35, 45) + SourceIndex(2) --- >>>declare const internalConst = 10; 1 > @@ -768,12 +800,12 @@ sourceFile:../second/second_part1.ts 4 > internalConst 5 > = 10 6 > ; -1 >Emitted(53, 1) Source(36, 15) + SourceIndex(2) -2 >Emitted(53, 9) Source(36, 15) + SourceIndex(2) -3 >Emitted(53, 15) Source(36, 21) + SourceIndex(2) -4 >Emitted(53, 28) Source(36, 34) + SourceIndex(2) -5 >Emitted(53, 33) Source(36, 39) + SourceIndex(2) -6 >Emitted(53, 34) Source(36, 40) + SourceIndex(2) +1 >Emitted(54, 1) Source(36, 15) + SourceIndex(2) +2 >Emitted(54, 9) Source(36, 15) + SourceIndex(2) +3 >Emitted(54, 15) Source(36, 21) + SourceIndex(2) +4 >Emitted(54, 28) Source(36, 34) + SourceIndex(2) +5 >Emitted(54, 33) Source(36, 39) + SourceIndex(2) +6 >Emitted(54, 34) Source(36, 40) + SourceIndex(2) --- >>>declare enum internalEnum { 1 > @@ -783,9 +815,9 @@ sourceFile:../second/second_part1.ts >/*@internal*/ 2 >enum 3 > internalEnum -1 >Emitted(54, 1) Source(37, 15) + SourceIndex(2) -2 >Emitted(54, 14) Source(37, 20) + SourceIndex(2) -3 >Emitted(54, 26) Source(37, 32) + SourceIndex(2) +1 >Emitted(55, 1) Source(37, 15) + SourceIndex(2) +2 >Emitted(55, 14) Source(37, 20) + SourceIndex(2) +3 >Emitted(55, 26) Source(37, 32) + SourceIndex(2) --- >>> a = 0, 1 >^^^^ @@ -795,9 +827,9 @@ sourceFile:../second/second_part1.ts 1 > { 2 > a 3 > -1 >Emitted(55, 5) Source(37, 35) + SourceIndex(2) -2 >Emitted(55, 6) Source(37, 36) + SourceIndex(2) -3 >Emitted(55, 10) Source(37, 36) + SourceIndex(2) +1 >Emitted(56, 5) Source(37, 35) + SourceIndex(2) +2 >Emitted(56, 6) Source(37, 36) + SourceIndex(2) +3 >Emitted(56, 10) Source(37, 36) + SourceIndex(2) --- >>> b = 1, 1->^^^^ @@ -807,9 +839,9 @@ sourceFile:../second/second_part1.ts 1->, 2 > b 3 > -1->Emitted(56, 5) Source(37, 38) + SourceIndex(2) -2 >Emitted(56, 6) Source(37, 39) + SourceIndex(2) -3 >Emitted(56, 10) Source(37, 39) + SourceIndex(2) +1->Emitted(57, 5) Source(37, 38) + SourceIndex(2) +2 >Emitted(57, 6) Source(37, 39) + SourceIndex(2) +3 >Emitted(57, 10) Source(37, 39) + SourceIndex(2) --- >>> c = 2 1->^^^^ @@ -818,15 +850,15 @@ sourceFile:../second/second_part1.ts 1->, 2 > c 3 > -1->Emitted(57, 5) Source(37, 41) + SourceIndex(2) -2 >Emitted(57, 6) Source(37, 42) + SourceIndex(2) -3 >Emitted(57, 10) Source(37, 42) + SourceIndex(2) +1->Emitted(58, 5) Source(37, 41) + SourceIndex(2) +2 >Emitted(58, 6) Source(37, 42) + SourceIndex(2) +3 >Emitted(58, 10) Source(37, 42) + SourceIndex(2) --- >>>} 1 >^ 2 > ^^^^^^^^^^^^^^^^^-> 1 > } -1 >Emitted(58, 2) Source(37, 44) + SourceIndex(2) +1 >Emitted(59, 2) Source(37, 44) + SourceIndex(2) --- ------------------------------------------------------------------- emittedFile:/src/2/second-output.d.ts @@ -840,9 +872,9 @@ sourceFile:../second/second_part2.ts 1-> 2 >class 3 > C -1->Emitted(59, 1) Source(1, 1) + SourceIndex(3) -2 >Emitted(59, 15) Source(1, 7) + SourceIndex(3) -3 >Emitted(59, 16) Source(1, 8) + SourceIndex(3) +1->Emitted(60, 1) Source(1, 1) + SourceIndex(3) +2 >Emitted(60, 15) Source(1, 7) + SourceIndex(3) +3 >Emitted(60, 16) Source(1, 8) + SourceIndex(3) --- >>> doSomething(): void; 1->^^^^ @@ -850,8 +882,8 @@ sourceFile:../second/second_part2.ts 1-> { > 2 > doSomething -1->Emitted(60, 5) Source(2, 5) + SourceIndex(3) -2 >Emitted(60, 16) Source(2, 16) + SourceIndex(3) +1->Emitted(61, 5) Source(2, 5) + SourceIndex(3) +2 >Emitted(61, 16) Source(2, 16) + SourceIndex(3) --- >>>} 1 >^ @@ -860,7 +892,7 @@ sourceFile:../second/second_part2.ts > console.log("something got done"); > } >} -1 >Emitted(61, 2) Source(5, 2) + SourceIndex(3) +1 >Emitted(62, 2) Source(5, 2) + SourceIndex(3) --- >>>//# sourceMappingURL=second-output.d.ts.map @@ -2716,32 +2748,32 @@ sourceFile:../second/second_part2.ts }, { "pos": 234, - "end": 322, + "end": 339, "kind": "internal" }, { - "pos": 324, - "end": 356, + "pos": 341, + "end": 373, "kind": "text" }, { - "pos": 356, - "end": 748, + "pos": 373, + "end": 765, "kind": "internal" }, { - "pos": 750, - "end": 753, + "pos": 767, + "end": 770, "kind": "text" }, { - "pos": 753, - "end": 1166, + "pos": 770, + "end": 1183, "kind": "internal" }, { - "pos": 1168, - "end": 1216, + "pos": 1185, + "end": 1233, "kind": "text" } ] @@ -2896,18 +2928,19 @@ declare namespace N { declare class normalC { ---------------------------------------------------------------------- -internal: (234-322) +internal: (234-339) constructor(); prop: string; method(): void; - /*@internal*/ c: number; + get c(): number; + set c(val: number); ---------------------------------------------------------------------- -text: (324-356) +text: (341-373) } declare namespace normalN { ---------------------------------------------------------------------- -internal: (356-748) +internal: (373-765) class C { } function foo(): void; @@ -2928,11 +2961,11 @@ internal: (356-748) c = 2 } ---------------------------------------------------------------------- -text: (750-753) +text: (767-770) } ---------------------------------------------------------------------- -internal: (753-1166) +internal: (770-1183) declare class internalC { } declare function internalfoo(): void; @@ -2953,7 +2986,7 @@ declare enum internalEnum { c = 2 } ---------------------------------------------------------------------- -text: (1168-1216) +text: (1185-1233) declare class C { doSomething(): void; } diff --git a/tests/baselines/reference/tsbuild/outfile-concat/initial-build/stripInternal-with-comments-emit-enabled.js b/tests/baselines/reference/tsbuild/outfile-concat/initial-build/stripInternal-with-comments-emit-enabled.js index d681812289135..80e0f71cc5505 100644 --- a/tests/baselines/reference/tsbuild/outfile-concat/initial-build/stripInternal-with-comments-emit-enabled.js +++ b/tests/baselines/reference/tsbuild/outfile-concat/initial-build/stripInternal-with-comments-emit-enabled.js @@ -29,7 +29,8 @@ declare class normalC { constructor(); prop: string; method(): void; - /*@internal*/ c: number; + get c(): number; + set c(val: number); } declare namespace normalN { class C { @@ -77,7 +78,7 @@ declare class C { //# sourceMappingURL=second-output.d.ts.map //// [/src/2/second-output.d.ts.map] -{"version":3,"file":"second-output.d.ts","sourceRoot":"","sources":["../second/second_part1.ts","../second/second_part2.ts"],"names":[],"mappings":"AAAA,kBAAU,CAAC,CAAC;CAEX;AAED,kBAAU,CAAC,CAAC;CAMX;AAED,cAAM,OAAO;;IAEK,IAAI,EAAE,MAAM,CAAC;IACb,MAAM;kBACF,CAAC,EACM,MAAM;CAClC;AACD,kBAAU,OAAO,CAAC;IACA,MAAa,CAAC;KAAI;IAClB,SAAgB,GAAG,SAAK;IACxB,UAAiB,aAAa,CAAC;QAAE,MAAa,CAAC;SAAG;KAAE;IACpD,UAAiB,SAAS,CAAC,SAAS,CAAC;QAAE,MAAa,SAAS;SAAG;KAAE;IAClE,MAAM,QAAQ,UAAU,GAAG,aAAa,CAAC,CAAC,CAAC;IAC3C,KAAY,YAAY,GAAG,SAAS,CAAC;IAC9B,MAAM,aAAa,KAAK,CAAC;IAChC,KAAY,YAAY;QAAG,CAAC,IAAA;QAAE,CAAC,IAAA;QAAE,CAAC,IAAA;KAAE;CACrD;AACa,cAAM,SAAS;CAAG;AAClB,iBAAS,WAAW,SAAK;AACzB,kBAAU,iBAAiB,CAAC;IAAE,MAAa,SAAS;KAAG;CAAE;AACzD,kBAAU,aAAa,CAAC,SAAS,CAAC;IAAE,MAAa,SAAS;KAAG;CAAE;AAC/D,OAAO,cAAc,GAAG,iBAAiB,CAAC,SAAS,CAAC;AACpD,aAAK,YAAY,GAAG,SAAS,CAAC;AAC9B,QAAA,MAAM,aAAa,KAAK,CAAC;AACzB,aAAK,YAAY;IAAG,CAAC,IAAA;IAAE,CAAC,IAAA;IAAE,CAAC,IAAA;CAAE;ACpC3C,cAAM,CAAC;IACH,WAAW;CAGd"} +{"version":3,"file":"second-output.d.ts","sourceRoot":"","sources":["../second/second_part1.ts","../second/second_part2.ts"],"names":[],"mappings":"AAAA,kBAAU,CAAC,CAAC;CAEX;AAED,kBAAU,CAAC,CAAC;CAMX;AAED,cAAM,OAAO;;IAEK,IAAI,EAAE,MAAM,CAAC;IACb,MAAM;IACN,IAAI,CAAC,IACM,MAAM,CADK;IACtB,IAAI,CAAC,CAAC,KAAK,MAAM,EAAK;CACvC;AACD,kBAAU,OAAO,CAAC;IACA,MAAa,CAAC;KAAI;IAClB,SAAgB,GAAG,SAAK;IACxB,UAAiB,aAAa,CAAC;QAAE,MAAa,CAAC;SAAG;KAAE;IACpD,UAAiB,SAAS,CAAC,SAAS,CAAC;QAAE,MAAa,SAAS;SAAG;KAAE;IAClE,MAAM,QAAQ,UAAU,GAAG,aAAa,CAAC,CAAC,CAAC;IAC3C,KAAY,YAAY,GAAG,SAAS,CAAC;IAC9B,MAAM,aAAa,KAAK,CAAC;IAChC,KAAY,YAAY;QAAG,CAAC,IAAA;QAAE,CAAC,IAAA;QAAE,CAAC,IAAA;KAAE;CACrD;AACa,cAAM,SAAS;CAAG;AAClB,iBAAS,WAAW,SAAK;AACzB,kBAAU,iBAAiB,CAAC;IAAE,MAAa,SAAS;KAAG;CAAE;AACzD,kBAAU,aAAa,CAAC,SAAS,CAAC;IAAE,MAAa,SAAS;KAAG;CAAE;AAC/D,OAAO,cAAc,GAAG,iBAAiB,CAAC,SAAS,CAAC;AACpD,aAAK,YAAY,GAAG,SAAS,CAAC;AAC9B,QAAA,MAAM,aAAa,KAAK,CAAC;AACzB,aAAK,YAAY;IAAG,CAAC,IAAA;IAAE,CAAC,IAAA;IAAE,CAAC,IAAA;CAAE;ACpC3C,cAAM,CAAC;IACH,WAAW;CAGd"} //// [/src/2/second-output.d.ts.map.baseline.txt] =================================================================== @@ -177,35 +178,66 @@ sourceFile:../second/second_part1.ts >>> method(): void; 1->^^^^ 2 > ^^^^^^ -3 > ^^^^^^^^^^^^^^^^^^^-> +3 > ^^^^^^^^^^^-> 1-> > /*@internal*/ 2 > method 1->Emitted(8, 5) Source(16, 19) + SourceIndex(0) 2 >Emitted(8, 11) Source(16, 25) + SourceIndex(0) --- ->>> /*@internal*/ c: number; -1->^^^^^^^^^^^^^^^^^^ -2 > ^ -3 > ^^ -4 > ^^^^^^ +>>> get c(): number; +1->^^^^ +2 > ^^^^ +3 > ^ +4 > ^^^^ +5 > ^^^^^^ +6 > ^ +7 > ^^^^-> 1->() { } - > /*@internal*/ get -2 > c -3 > () { return 10; } - > /*@internal*/ set c(val: -4 > number -1->Emitted(9, 19) Source(17, 23) + SourceIndex(0) -2 >Emitted(9, 20) Source(17, 24) + SourceIndex(0) -3 >Emitted(9, 22) Source(18, 30) + SourceIndex(0) -4 >Emitted(9, 28) Source(18, 36) + SourceIndex(0) + > /*@internal*/ +2 > get +3 > c +4 > () { return 10; } + > /*@internal*/ set c(val: +5 > number +6 > +1->Emitted(9, 5) Source(17, 19) + SourceIndex(0) +2 >Emitted(9, 9) Source(17, 23) + SourceIndex(0) +3 >Emitted(9, 10) Source(17, 24) + SourceIndex(0) +4 >Emitted(9, 14) Source(18, 30) + SourceIndex(0) +5 >Emitted(9, 20) Source(18, 36) + SourceIndex(0) +6 >Emitted(9, 21) Source(17, 41) + SourceIndex(0) +--- +>>> set c(val: number); +1->^^^^ +2 > ^^^^ +3 > ^ +4 > ^ +5 > ^^^^^ +6 > ^^^^^^ +7 > ^^ +1-> + > /*@internal*/ +2 > set +3 > c +4 > ( +5 > val: +6 > number +7 > ) { } +1->Emitted(10, 5) Source(18, 19) + SourceIndex(0) +2 >Emitted(10, 9) Source(18, 23) + SourceIndex(0) +3 >Emitted(10, 10) Source(18, 24) + SourceIndex(0) +4 >Emitted(10, 11) Source(18, 25) + SourceIndex(0) +5 >Emitted(10, 16) Source(18, 30) + SourceIndex(0) +6 >Emitted(10, 22) Source(18, 36) + SourceIndex(0) +7 >Emitted(10, 24) Source(18, 41) + SourceIndex(0) --- >>>} 1 >^ 2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1 >) { } +1 > >} -1 >Emitted(10, 2) Source(19, 2) + SourceIndex(0) +1 >Emitted(11, 2) Source(19, 2) + SourceIndex(0) --- >>>declare namespace normalN { 1-> @@ -217,10 +249,10 @@ sourceFile:../second/second_part1.ts 2 >namespace 3 > normalN 4 > -1->Emitted(11, 1) Source(20, 1) + SourceIndex(0) -2 >Emitted(11, 19) Source(20, 11) + SourceIndex(0) -3 >Emitted(11, 26) Source(20, 18) + SourceIndex(0) -4 >Emitted(11, 27) Source(20, 19) + SourceIndex(0) +1->Emitted(12, 1) Source(20, 1) + SourceIndex(0) +2 >Emitted(12, 19) Source(20, 11) + SourceIndex(0) +3 >Emitted(12, 26) Source(20, 18) + SourceIndex(0) +4 >Emitted(12, 27) Source(20, 19) + SourceIndex(0) --- >>> class C { 1 >^^^^ @@ -230,15 +262,15 @@ sourceFile:../second/second_part1.ts > /*@internal*/ 2 > export class 3 > C -1 >Emitted(12, 5) Source(21, 19) + SourceIndex(0) -2 >Emitted(12, 11) Source(21, 32) + SourceIndex(0) -3 >Emitted(12, 12) Source(21, 33) + SourceIndex(0) +1 >Emitted(13, 5) Source(21, 19) + SourceIndex(0) +2 >Emitted(13, 11) Source(21, 32) + SourceIndex(0) +3 >Emitted(13, 12) Source(21, 33) + SourceIndex(0) --- >>> } 1 >^^^^^ 2 > ^^^^^^^^^^^^^^^^^^^^^-> 1 > { } -1 >Emitted(13, 6) Source(21, 37) + SourceIndex(0) +1 >Emitted(14, 6) Source(21, 37) + SourceIndex(0) --- >>> function foo(): void; 1->^^^^ @@ -251,10 +283,10 @@ sourceFile:../second/second_part1.ts 2 > export function 3 > foo 4 > () {} -1->Emitted(14, 5) Source(22, 19) + SourceIndex(0) -2 >Emitted(14, 14) Source(22, 35) + SourceIndex(0) -3 >Emitted(14, 17) Source(22, 38) + SourceIndex(0) -4 >Emitted(14, 26) Source(22, 43) + SourceIndex(0) +1->Emitted(15, 5) Source(22, 19) + SourceIndex(0) +2 >Emitted(15, 14) Source(22, 35) + SourceIndex(0) +3 >Emitted(15, 17) Source(22, 38) + SourceIndex(0) +4 >Emitted(15, 26) Source(22, 43) + SourceIndex(0) --- >>> namespace someNamespace { 1->^^^^ @@ -266,10 +298,10 @@ sourceFile:../second/second_part1.ts 2 > export namespace 3 > someNamespace 4 > -1->Emitted(15, 5) Source(23, 19) + SourceIndex(0) -2 >Emitted(15, 15) Source(23, 36) + SourceIndex(0) -3 >Emitted(15, 28) Source(23, 49) + SourceIndex(0) -4 >Emitted(15, 29) Source(23, 50) + SourceIndex(0) +1->Emitted(16, 5) Source(23, 19) + SourceIndex(0) +2 >Emitted(16, 15) Source(23, 36) + SourceIndex(0) +3 >Emitted(16, 28) Source(23, 49) + SourceIndex(0) +4 >Emitted(16, 29) Source(23, 50) + SourceIndex(0) --- >>> class C { 1 >^^^^^^^^ @@ -278,20 +310,20 @@ sourceFile:../second/second_part1.ts 1 >{ 2 > export class 3 > C -1 >Emitted(16, 9) Source(23, 52) + SourceIndex(0) -2 >Emitted(16, 15) Source(23, 65) + SourceIndex(0) -3 >Emitted(16, 16) Source(23, 66) + SourceIndex(0) +1 >Emitted(17, 9) Source(23, 52) + SourceIndex(0) +2 >Emitted(17, 15) Source(23, 65) + SourceIndex(0) +3 >Emitted(17, 16) Source(23, 66) + SourceIndex(0) --- >>> } 1 >^^^^^^^^^ 1 > {} -1 >Emitted(17, 10) Source(23, 69) + SourceIndex(0) +1 >Emitted(18, 10) Source(23, 69) + SourceIndex(0) --- >>> } 1 >^^^^^ 2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> 1 > } -1 >Emitted(18, 6) Source(23, 71) + SourceIndex(0) +1 >Emitted(19, 6) Source(23, 71) + SourceIndex(0) --- >>> namespace someOther.something { 1->^^^^ @@ -307,12 +339,12 @@ sourceFile:../second/second_part1.ts 4 > . 5 > something 6 > -1->Emitted(19, 5) Source(24, 19) + SourceIndex(0) -2 >Emitted(19, 15) Source(24, 36) + SourceIndex(0) -3 >Emitted(19, 24) Source(24, 45) + SourceIndex(0) -4 >Emitted(19, 25) Source(24, 46) + SourceIndex(0) -5 >Emitted(19, 34) Source(24, 55) + SourceIndex(0) -6 >Emitted(19, 35) Source(24, 56) + SourceIndex(0) +1->Emitted(20, 5) Source(24, 19) + SourceIndex(0) +2 >Emitted(20, 15) Source(24, 36) + SourceIndex(0) +3 >Emitted(20, 24) Source(24, 45) + SourceIndex(0) +4 >Emitted(20, 25) Source(24, 46) + SourceIndex(0) +5 >Emitted(20, 34) Source(24, 55) + SourceIndex(0) +6 >Emitted(20, 35) Source(24, 56) + SourceIndex(0) --- >>> class someClass { 1 >^^^^^^^^ @@ -321,20 +353,20 @@ sourceFile:../second/second_part1.ts 1 >{ 2 > export class 3 > someClass -1 >Emitted(20, 9) Source(24, 58) + SourceIndex(0) -2 >Emitted(20, 15) Source(24, 71) + SourceIndex(0) -3 >Emitted(20, 24) Source(24, 80) + SourceIndex(0) +1 >Emitted(21, 9) Source(24, 58) + SourceIndex(0) +2 >Emitted(21, 15) Source(24, 71) + SourceIndex(0) +3 >Emitted(21, 24) Source(24, 80) + SourceIndex(0) --- >>> } 1 >^^^^^^^^^ 1 > {} -1 >Emitted(21, 10) Source(24, 83) + SourceIndex(0) +1 >Emitted(22, 10) Source(24, 83) + SourceIndex(0) --- >>> } 1 >^^^^^ 2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> 1 > } -1 >Emitted(22, 6) Source(24, 85) + SourceIndex(0) +1 >Emitted(23, 6) Source(24, 85) + SourceIndex(0) --- >>> export import someImport = someNamespace.C; 1->^^^^ @@ -356,15 +388,15 @@ sourceFile:../second/second_part1.ts 7 > . 8 > C 9 > ; -1->Emitted(23, 5) Source(25, 19) + SourceIndex(0) -2 >Emitted(23, 11) Source(25, 25) + SourceIndex(0) -3 >Emitted(23, 19) Source(25, 33) + SourceIndex(0) -4 >Emitted(23, 29) Source(25, 43) + SourceIndex(0) -5 >Emitted(23, 32) Source(25, 46) + SourceIndex(0) -6 >Emitted(23, 45) Source(25, 59) + SourceIndex(0) -7 >Emitted(23, 46) Source(25, 60) + SourceIndex(0) -8 >Emitted(23, 47) Source(25, 61) + SourceIndex(0) -9 >Emitted(23, 48) Source(25, 62) + SourceIndex(0) +1->Emitted(24, 5) Source(25, 19) + SourceIndex(0) +2 >Emitted(24, 11) Source(25, 25) + SourceIndex(0) +3 >Emitted(24, 19) Source(25, 33) + SourceIndex(0) +4 >Emitted(24, 29) Source(25, 43) + SourceIndex(0) +5 >Emitted(24, 32) Source(25, 46) + SourceIndex(0) +6 >Emitted(24, 45) Source(25, 59) + SourceIndex(0) +7 >Emitted(24, 46) Source(25, 60) + SourceIndex(0) +8 >Emitted(24, 47) Source(25, 61) + SourceIndex(0) +9 >Emitted(24, 48) Source(25, 62) + SourceIndex(0) --- >>> type internalType = internalC; 1 >^^^^ @@ -380,12 +412,12 @@ sourceFile:../second/second_part1.ts 4 > = 5 > internalC 6 > ; -1 >Emitted(24, 5) Source(26, 19) + SourceIndex(0) -2 >Emitted(24, 10) Source(26, 31) + SourceIndex(0) -3 >Emitted(24, 22) Source(26, 43) + SourceIndex(0) -4 >Emitted(24, 25) Source(26, 46) + SourceIndex(0) -5 >Emitted(24, 34) Source(26, 55) + SourceIndex(0) -6 >Emitted(24, 35) Source(26, 56) + SourceIndex(0) +1 >Emitted(25, 5) Source(26, 19) + SourceIndex(0) +2 >Emitted(25, 10) Source(26, 31) + SourceIndex(0) +3 >Emitted(25, 22) Source(26, 43) + SourceIndex(0) +4 >Emitted(25, 25) Source(26, 46) + SourceIndex(0) +5 >Emitted(25, 34) Source(26, 55) + SourceIndex(0) +6 >Emitted(25, 35) Source(26, 56) + SourceIndex(0) --- >>> const internalConst = 10; 1 >^^^^ @@ -399,11 +431,11 @@ sourceFile:../second/second_part1.ts 3 > internalConst 4 > = 10 5 > ; -1 >Emitted(25, 5) Source(27, 26) + SourceIndex(0) -2 >Emitted(25, 11) Source(27, 32) + SourceIndex(0) -3 >Emitted(25, 24) Source(27, 45) + SourceIndex(0) -4 >Emitted(25, 29) Source(27, 50) + SourceIndex(0) -5 >Emitted(25, 30) Source(27, 51) + SourceIndex(0) +1 >Emitted(26, 5) Source(27, 26) + SourceIndex(0) +2 >Emitted(26, 11) Source(27, 32) + SourceIndex(0) +3 >Emitted(26, 24) Source(27, 45) + SourceIndex(0) +4 >Emitted(26, 29) Source(27, 50) + SourceIndex(0) +5 >Emitted(26, 30) Source(27, 51) + SourceIndex(0) --- >>> enum internalEnum { 1 >^^^^ @@ -413,9 +445,9 @@ sourceFile:../second/second_part1.ts > /*@internal*/ 2 > export enum 3 > internalEnum -1 >Emitted(26, 5) Source(28, 19) + SourceIndex(0) -2 >Emitted(26, 10) Source(28, 31) + SourceIndex(0) -3 >Emitted(26, 22) Source(28, 43) + SourceIndex(0) +1 >Emitted(27, 5) Source(28, 19) + SourceIndex(0) +2 >Emitted(27, 10) Source(28, 31) + SourceIndex(0) +3 >Emitted(27, 22) Source(28, 43) + SourceIndex(0) --- >>> a = 0, 1 >^^^^^^^^ @@ -425,9 +457,9 @@ sourceFile:../second/second_part1.ts 1 > { 2 > a 3 > -1 >Emitted(27, 9) Source(28, 46) + SourceIndex(0) -2 >Emitted(27, 10) Source(28, 47) + SourceIndex(0) -3 >Emitted(27, 14) Source(28, 47) + SourceIndex(0) +1 >Emitted(28, 9) Source(28, 46) + SourceIndex(0) +2 >Emitted(28, 10) Source(28, 47) + SourceIndex(0) +3 >Emitted(28, 14) Source(28, 47) + SourceIndex(0) --- >>> b = 1, 1->^^^^^^^^ @@ -437,9 +469,9 @@ sourceFile:../second/second_part1.ts 1->, 2 > b 3 > -1->Emitted(28, 9) Source(28, 49) + SourceIndex(0) -2 >Emitted(28, 10) Source(28, 50) + SourceIndex(0) -3 >Emitted(28, 14) Source(28, 50) + SourceIndex(0) +1->Emitted(29, 9) Source(28, 49) + SourceIndex(0) +2 >Emitted(29, 10) Source(28, 50) + SourceIndex(0) +3 >Emitted(29, 14) Source(28, 50) + SourceIndex(0) --- >>> c = 2 1->^^^^^^^^ @@ -448,21 +480,21 @@ sourceFile:../second/second_part1.ts 1->, 2 > c 3 > -1->Emitted(29, 9) Source(28, 52) + SourceIndex(0) -2 >Emitted(29, 10) Source(28, 53) + SourceIndex(0) -3 >Emitted(29, 14) Source(28, 53) + SourceIndex(0) +1->Emitted(30, 9) Source(28, 52) + SourceIndex(0) +2 >Emitted(30, 10) Source(28, 53) + SourceIndex(0) +3 >Emitted(30, 14) Source(28, 53) + SourceIndex(0) --- >>> } 1 >^^^^^ 1 > } -1 >Emitted(30, 6) Source(28, 55) + SourceIndex(0) +1 >Emitted(31, 6) Source(28, 55) + SourceIndex(0) --- >>>} 1 >^ 2 > ^^^^^^^^^^^^^^^^^^^^^^^^^-> 1 > >} -1 >Emitted(31, 2) Source(29, 2) + SourceIndex(0) +1 >Emitted(32, 2) Source(29, 2) + SourceIndex(0) --- >>>declare class internalC { 1-> @@ -472,15 +504,15 @@ sourceFile:../second/second_part1.ts >/*@internal*/ 2 >class 3 > internalC -1->Emitted(32, 1) Source(30, 15) + SourceIndex(0) -2 >Emitted(32, 15) Source(30, 21) + SourceIndex(0) -3 >Emitted(32, 24) Source(30, 30) + SourceIndex(0) +1->Emitted(33, 1) Source(30, 15) + SourceIndex(0) +2 >Emitted(33, 15) Source(30, 21) + SourceIndex(0) +3 >Emitted(33, 24) Source(30, 30) + SourceIndex(0) --- >>>} 1 >^ 2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> 1 > {} -1 >Emitted(33, 2) Source(30, 33) + SourceIndex(0) +1 >Emitted(34, 2) Source(30, 33) + SourceIndex(0) --- >>>declare function internalfoo(): void; 1-> @@ -493,10 +525,10 @@ sourceFile:../second/second_part1.ts 2 >function 3 > internalfoo 4 > () {} -1->Emitted(34, 1) Source(31, 15) + SourceIndex(0) -2 >Emitted(34, 18) Source(31, 24) + SourceIndex(0) -3 >Emitted(34, 29) Source(31, 35) + SourceIndex(0) -4 >Emitted(34, 38) Source(31, 40) + SourceIndex(0) +1->Emitted(35, 1) Source(31, 15) + SourceIndex(0) +2 >Emitted(35, 18) Source(31, 24) + SourceIndex(0) +3 >Emitted(35, 29) Source(31, 35) + SourceIndex(0) +4 >Emitted(35, 38) Source(31, 40) + SourceIndex(0) --- >>>declare namespace internalNamespace { 1-> @@ -508,10 +540,10 @@ sourceFile:../second/second_part1.ts 2 >namespace 3 > internalNamespace 4 > -1->Emitted(35, 1) Source(32, 15) + SourceIndex(0) -2 >Emitted(35, 19) Source(32, 25) + SourceIndex(0) -3 >Emitted(35, 36) Source(32, 42) + SourceIndex(0) -4 >Emitted(35, 37) Source(32, 43) + SourceIndex(0) +1->Emitted(36, 1) Source(32, 15) + SourceIndex(0) +2 >Emitted(36, 19) Source(32, 25) + SourceIndex(0) +3 >Emitted(36, 36) Source(32, 42) + SourceIndex(0) +4 >Emitted(36, 37) Source(32, 43) + SourceIndex(0) --- >>> class someClass { 1 >^^^^ @@ -520,20 +552,20 @@ sourceFile:../second/second_part1.ts 1 >{ 2 > export class 3 > someClass -1 >Emitted(36, 5) Source(32, 45) + SourceIndex(0) -2 >Emitted(36, 11) Source(32, 58) + SourceIndex(0) -3 >Emitted(36, 20) Source(32, 67) + SourceIndex(0) +1 >Emitted(37, 5) Source(32, 45) + SourceIndex(0) +2 >Emitted(37, 11) Source(32, 58) + SourceIndex(0) +3 >Emitted(37, 20) Source(32, 67) + SourceIndex(0) --- >>> } 1 >^^^^^ 1 > {} -1 >Emitted(37, 6) Source(32, 70) + SourceIndex(0) +1 >Emitted(38, 6) Source(32, 70) + SourceIndex(0) --- >>>} 1 >^ 2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> 1 > } -1 >Emitted(38, 2) Source(32, 72) + SourceIndex(0) +1 >Emitted(39, 2) Source(32, 72) + SourceIndex(0) --- >>>declare namespace internalOther.something { 1-> @@ -549,12 +581,12 @@ sourceFile:../second/second_part1.ts 4 > . 5 > something 6 > -1->Emitted(39, 1) Source(33, 15) + SourceIndex(0) -2 >Emitted(39, 19) Source(33, 25) + SourceIndex(0) -3 >Emitted(39, 32) Source(33, 38) + SourceIndex(0) -4 >Emitted(39, 33) Source(33, 39) + SourceIndex(0) -5 >Emitted(39, 42) Source(33, 48) + SourceIndex(0) -6 >Emitted(39, 43) Source(33, 49) + SourceIndex(0) +1->Emitted(40, 1) Source(33, 15) + SourceIndex(0) +2 >Emitted(40, 19) Source(33, 25) + SourceIndex(0) +3 >Emitted(40, 32) Source(33, 38) + SourceIndex(0) +4 >Emitted(40, 33) Source(33, 39) + SourceIndex(0) +5 >Emitted(40, 42) Source(33, 48) + SourceIndex(0) +6 >Emitted(40, 43) Source(33, 49) + SourceIndex(0) --- >>> class someClass { 1 >^^^^ @@ -563,20 +595,20 @@ sourceFile:../second/second_part1.ts 1 >{ 2 > export class 3 > someClass -1 >Emitted(40, 5) Source(33, 51) + SourceIndex(0) -2 >Emitted(40, 11) Source(33, 64) + SourceIndex(0) -3 >Emitted(40, 20) Source(33, 73) + SourceIndex(0) +1 >Emitted(41, 5) Source(33, 51) + SourceIndex(0) +2 >Emitted(41, 11) Source(33, 64) + SourceIndex(0) +3 >Emitted(41, 20) Source(33, 73) + SourceIndex(0) --- >>> } 1 >^^^^^ 1 > {} -1 >Emitted(41, 6) Source(33, 76) + SourceIndex(0) +1 >Emitted(42, 6) Source(33, 76) + SourceIndex(0) --- >>>} 1 >^ 2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> 1 > } -1 >Emitted(42, 2) Source(33, 78) + SourceIndex(0) +1 >Emitted(43, 2) Source(33, 78) + SourceIndex(0) --- >>>import internalImport = internalNamespace.someClass; 1-> @@ -596,14 +628,14 @@ sourceFile:../second/second_part1.ts 6 > . 7 > someClass 8 > ; -1->Emitted(43, 1) Source(34, 15) + SourceIndex(0) -2 >Emitted(43, 8) Source(34, 22) + SourceIndex(0) -3 >Emitted(43, 22) Source(34, 36) + SourceIndex(0) -4 >Emitted(43, 25) Source(34, 39) + SourceIndex(0) -5 >Emitted(43, 42) Source(34, 56) + SourceIndex(0) -6 >Emitted(43, 43) Source(34, 57) + SourceIndex(0) -7 >Emitted(43, 52) Source(34, 66) + SourceIndex(0) -8 >Emitted(43, 53) Source(34, 67) + SourceIndex(0) +1->Emitted(44, 1) Source(34, 15) + SourceIndex(0) +2 >Emitted(44, 8) Source(34, 22) + SourceIndex(0) +3 >Emitted(44, 22) Source(34, 36) + SourceIndex(0) +4 >Emitted(44, 25) Source(34, 39) + SourceIndex(0) +5 >Emitted(44, 42) Source(34, 56) + SourceIndex(0) +6 >Emitted(44, 43) Source(34, 57) + SourceIndex(0) +7 >Emitted(44, 52) Source(34, 66) + SourceIndex(0) +8 >Emitted(44, 53) Source(34, 67) + SourceIndex(0) --- >>>declare type internalType = internalC; 1 > @@ -619,12 +651,12 @@ sourceFile:../second/second_part1.ts 4 > = 5 > internalC 6 > ; -1 >Emitted(44, 1) Source(35, 15) + SourceIndex(0) -2 >Emitted(44, 14) Source(35, 20) + SourceIndex(0) -3 >Emitted(44, 26) Source(35, 32) + SourceIndex(0) -4 >Emitted(44, 29) Source(35, 35) + SourceIndex(0) -5 >Emitted(44, 38) Source(35, 44) + SourceIndex(0) -6 >Emitted(44, 39) Source(35, 45) + SourceIndex(0) +1 >Emitted(45, 1) Source(35, 15) + SourceIndex(0) +2 >Emitted(45, 14) Source(35, 20) + SourceIndex(0) +3 >Emitted(45, 26) Source(35, 32) + SourceIndex(0) +4 >Emitted(45, 29) Source(35, 35) + SourceIndex(0) +5 >Emitted(45, 38) Source(35, 44) + SourceIndex(0) +6 >Emitted(45, 39) Source(35, 45) + SourceIndex(0) --- >>>declare const internalConst = 10; 1 > @@ -640,12 +672,12 @@ sourceFile:../second/second_part1.ts 4 > internalConst 5 > = 10 6 > ; -1 >Emitted(45, 1) Source(36, 15) + SourceIndex(0) -2 >Emitted(45, 9) Source(36, 15) + SourceIndex(0) -3 >Emitted(45, 15) Source(36, 21) + SourceIndex(0) -4 >Emitted(45, 28) Source(36, 34) + SourceIndex(0) -5 >Emitted(45, 33) Source(36, 39) + SourceIndex(0) -6 >Emitted(45, 34) Source(36, 40) + SourceIndex(0) +1 >Emitted(46, 1) Source(36, 15) + SourceIndex(0) +2 >Emitted(46, 9) Source(36, 15) + SourceIndex(0) +3 >Emitted(46, 15) Source(36, 21) + SourceIndex(0) +4 >Emitted(46, 28) Source(36, 34) + SourceIndex(0) +5 >Emitted(46, 33) Source(36, 39) + SourceIndex(0) +6 >Emitted(46, 34) Source(36, 40) + SourceIndex(0) --- >>>declare enum internalEnum { 1 > @@ -655,9 +687,9 @@ sourceFile:../second/second_part1.ts >/*@internal*/ 2 >enum 3 > internalEnum -1 >Emitted(46, 1) Source(37, 15) + SourceIndex(0) -2 >Emitted(46, 14) Source(37, 20) + SourceIndex(0) -3 >Emitted(46, 26) Source(37, 32) + SourceIndex(0) +1 >Emitted(47, 1) Source(37, 15) + SourceIndex(0) +2 >Emitted(47, 14) Source(37, 20) + SourceIndex(0) +3 >Emitted(47, 26) Source(37, 32) + SourceIndex(0) --- >>> a = 0, 1 >^^^^ @@ -667,9 +699,9 @@ sourceFile:../second/second_part1.ts 1 > { 2 > a 3 > -1 >Emitted(47, 5) Source(37, 35) + SourceIndex(0) -2 >Emitted(47, 6) Source(37, 36) + SourceIndex(0) -3 >Emitted(47, 10) Source(37, 36) + SourceIndex(0) +1 >Emitted(48, 5) Source(37, 35) + SourceIndex(0) +2 >Emitted(48, 6) Source(37, 36) + SourceIndex(0) +3 >Emitted(48, 10) Source(37, 36) + SourceIndex(0) --- >>> b = 1, 1->^^^^ @@ -679,9 +711,9 @@ sourceFile:../second/second_part1.ts 1->, 2 > b 3 > -1->Emitted(48, 5) Source(37, 38) + SourceIndex(0) -2 >Emitted(48, 6) Source(37, 39) + SourceIndex(0) -3 >Emitted(48, 10) Source(37, 39) + SourceIndex(0) +1->Emitted(49, 5) Source(37, 38) + SourceIndex(0) +2 >Emitted(49, 6) Source(37, 39) + SourceIndex(0) +3 >Emitted(49, 10) Source(37, 39) + SourceIndex(0) --- >>> c = 2 1->^^^^ @@ -690,15 +722,15 @@ sourceFile:../second/second_part1.ts 1->, 2 > c 3 > -1->Emitted(49, 5) Source(37, 41) + SourceIndex(0) -2 >Emitted(49, 6) Source(37, 42) + SourceIndex(0) -3 >Emitted(49, 10) Source(37, 42) + SourceIndex(0) +1->Emitted(50, 5) Source(37, 41) + SourceIndex(0) +2 >Emitted(50, 6) Source(37, 42) + SourceIndex(0) +3 >Emitted(50, 10) Source(37, 42) + SourceIndex(0) --- >>>} 1 >^ 2 > ^^^^^^^^^^^^^^^^^-> 1 > } -1 >Emitted(50, 2) Source(37, 44) + SourceIndex(0) +1 >Emitted(51, 2) Source(37, 44) + SourceIndex(0) --- ------------------------------------------------------------------- emittedFile:/src/2/second-output.d.ts @@ -712,9 +744,9 @@ sourceFile:../second/second_part2.ts 1-> 2 >class 3 > C -1->Emitted(51, 1) Source(1, 1) + SourceIndex(1) -2 >Emitted(51, 15) Source(1, 7) + SourceIndex(1) -3 >Emitted(51, 16) Source(1, 8) + SourceIndex(1) +1->Emitted(52, 1) Source(1, 1) + SourceIndex(1) +2 >Emitted(52, 15) Source(1, 7) + SourceIndex(1) +3 >Emitted(52, 16) Source(1, 8) + SourceIndex(1) --- >>> doSomething(): void; 1->^^^^ @@ -722,8 +754,8 @@ sourceFile:../second/second_part2.ts 1-> { > 2 > doSomething -1->Emitted(52, 5) Source(2, 5) + SourceIndex(1) -2 >Emitted(52, 16) Source(2, 16) + SourceIndex(1) +1->Emitted(53, 5) Source(2, 5) + SourceIndex(1) +2 >Emitted(53, 16) Source(2, 16) + SourceIndex(1) --- >>>} 1 >^ @@ -732,7 +764,7 @@ sourceFile:../second/second_part2.ts > console.log("something got done"); > } >} -1 >Emitted(53, 2) Source(5, 2) + SourceIndex(1) +1 >Emitted(54, 2) Source(5, 2) + SourceIndex(1) --- >>>//# sourceMappingURL=second-output.d.ts.map @@ -2416,32 +2448,32 @@ sourceFile:../second/second_part2.ts }, { "pos": 77, - "end": 165, + "end": 182, "kind": "internal" }, { - "pos": 167, - "end": 199, + "pos": 184, + "end": 216, "kind": "text" }, { - "pos": 199, - "end": 591, + "pos": 216, + "end": 608, "kind": "internal" }, { - "pos": 593, - "end": 596, + "pos": 610, + "end": 613, "kind": "text" }, { - "pos": 596, - "end": 1009, + "pos": 613, + "end": 1026, "kind": "internal" }, { - "pos": 1011, - "end": 1059, + "pos": 1028, + "end": 1076, "kind": "text" } ] @@ -2570,18 +2602,19 @@ declare namespace N { declare class normalC { ---------------------------------------------------------------------- -internal: (77-165) +internal: (77-182) constructor(); prop: string; method(): void; - /*@internal*/ c: number; + get c(): number; + set c(val: number); ---------------------------------------------------------------------- -text: (167-199) +text: (184-216) } declare namespace normalN { ---------------------------------------------------------------------- -internal: (199-591) +internal: (216-608) class C { } function foo(): void; @@ -2602,11 +2635,11 @@ internal: (199-591) c = 2 } ---------------------------------------------------------------------- -text: (593-596) +text: (610-613) } ---------------------------------------------------------------------- -internal: (596-1009) +internal: (613-1026) declare class internalC { } declare function internalfoo(): void; @@ -2627,7 +2660,7 @@ declare enum internalEnum { c = 2 } ---------------------------------------------------------------------- -text: (1011-1059) +text: (1028-1076) declare class C { doSomething(): void; } diff --git a/tests/baselines/reference/tsbuild/outfile-concat/initial-build/stripInternal.js b/tests/baselines/reference/tsbuild/outfile-concat/initial-build/stripInternal.js index 0f0cf474ca703..467077d6a669d 100644 --- a/tests/baselines/reference/tsbuild/outfile-concat/initial-build/stripInternal.js +++ b/tests/baselines/reference/tsbuild/outfile-concat/initial-build/stripInternal.js @@ -49,7 +49,8 @@ declare class normalC { constructor(); prop: string; method(): void; - c: number; + get c(): number; + set c(val: number); } declare namespace normalN { class C { @@ -97,7 +98,7 @@ declare class C { //# sourceMappingURL=second-output.d.ts.map //// [/src/2/second-output.d.ts.map] -{"version":3,"file":"second-output.d.ts","sourceRoot":"","sources":["../second/second_part1.ts","../second/second_part2.ts"],"names":[],"mappings":"AAAA,kBAAU,CAAC,CAAC;CAEX;AAED,kBAAU,CAAC,CAAC;CAMX;AAED,cAAM,OAAO;;IAEK,IAAI,EAAE,MAAM,CAAC;IACb,MAAM;IACF,CAAC,EACM,MAAM;CAClC;AACD,kBAAU,OAAO,CAAC;IACA,MAAa,CAAC;KAAI;IAClB,SAAgB,GAAG,SAAK;IACxB,UAAiB,aAAa,CAAC;QAAE,MAAa,CAAC;SAAG;KAAE;IACpD,UAAiB,SAAS,CAAC,SAAS,CAAC;QAAE,MAAa,SAAS;SAAG;KAAE;IAClE,MAAM,QAAQ,UAAU,GAAG,aAAa,CAAC,CAAC,CAAC;IAC3C,KAAY,YAAY,GAAG,SAAS,CAAC;IAC9B,MAAM,aAAa,KAAK,CAAC;IAChC,KAAY,YAAY;QAAG,CAAC,IAAA;QAAE,CAAC,IAAA;QAAE,CAAC,IAAA;KAAE;CACrD;AACa,cAAM,SAAS;CAAG;AAClB,iBAAS,WAAW,SAAK;AACzB,kBAAU,iBAAiB,CAAC;IAAE,MAAa,SAAS;KAAG;CAAE;AACzD,kBAAU,aAAa,CAAC,SAAS,CAAC;IAAE,MAAa,SAAS;KAAG;CAAE;AAC/D,OAAO,cAAc,GAAG,iBAAiB,CAAC,SAAS,CAAC;AACpD,aAAK,YAAY,GAAG,SAAS,CAAC;AAC9B,QAAA,MAAM,aAAa,KAAK,CAAC;AACzB,aAAK,YAAY;IAAG,CAAC,IAAA;IAAE,CAAC,IAAA;IAAE,CAAC,IAAA;CAAE;ACpC3C,cAAM,CAAC;IACH,WAAW;CAGd"} +{"version":3,"file":"second-output.d.ts","sourceRoot":"","sources":["../second/second_part1.ts","../second/second_part2.ts"],"names":[],"mappings":"AAAA,kBAAU,CAAC,CAAC;CAEX;AAED,kBAAU,CAAC,CAAC;CAMX;AAED,cAAM,OAAO;;IAEK,IAAI,EAAE,MAAM,CAAC;IACb,MAAM;IACN,IAAI,CAAC,IACM,MAAM,CADK;IACtB,IAAI,CAAC,CAAC,KAAK,MAAM,EAAK;CACvC;AACD,kBAAU,OAAO,CAAC;IACA,MAAa,CAAC;KAAI;IAClB,SAAgB,GAAG,SAAK;IACxB,UAAiB,aAAa,CAAC;QAAE,MAAa,CAAC;SAAG;KAAE;IACpD,UAAiB,SAAS,CAAC,SAAS,CAAC;QAAE,MAAa,SAAS;SAAG;KAAE;IAClE,MAAM,QAAQ,UAAU,GAAG,aAAa,CAAC,CAAC,CAAC;IAC3C,KAAY,YAAY,GAAG,SAAS,CAAC;IAC9B,MAAM,aAAa,KAAK,CAAC;IAChC,KAAY,YAAY;QAAG,CAAC,IAAA;QAAE,CAAC,IAAA;QAAE,CAAC,IAAA;KAAE;CACrD;AACa,cAAM,SAAS;CAAG;AAClB,iBAAS,WAAW,SAAK;AACzB,kBAAU,iBAAiB,CAAC;IAAE,MAAa,SAAS;KAAG;CAAE;AACzD,kBAAU,aAAa,CAAC,SAAS,CAAC;IAAE,MAAa,SAAS;KAAG;CAAE;AAC/D,OAAO,cAAc,GAAG,iBAAiB,CAAC,SAAS,CAAC;AACpD,aAAK,YAAY,GAAG,SAAS,CAAC;AAC9B,QAAA,MAAM,aAAa,KAAK,CAAC;AACzB,aAAK,YAAY;IAAG,CAAC,IAAA;IAAE,CAAC,IAAA;IAAE,CAAC,IAAA;CAAE;ACpC3C,cAAM,CAAC;IACH,WAAW;CAGd"} //// [/src/2/second-output.d.ts.map.baseline.txt] =================================================================== @@ -197,35 +198,66 @@ sourceFile:../second/second_part1.ts >>> method(): void; 1->^^^^ 2 > ^^^^^^ -3 > ^^^^^-> +3 > ^^^^^^^^^^^-> 1-> > /*@internal*/ 2 > method 1->Emitted(8, 5) Source(16, 19) + SourceIndex(0) 2 >Emitted(8, 11) Source(16, 25) + SourceIndex(0) --- ->>> c: number; +>>> get c(): number; 1->^^^^ -2 > ^ -3 > ^^ -4 > ^^^^^^ +2 > ^^^^ +3 > ^ +4 > ^^^^ +5 > ^^^^^^ +6 > ^ +7 > ^^^^-> 1->() { } - > /*@internal*/ get -2 > c -3 > () { return 10; } - > /*@internal*/ set c(val: -4 > number -1->Emitted(9, 5) Source(17, 23) + SourceIndex(0) -2 >Emitted(9, 6) Source(17, 24) + SourceIndex(0) -3 >Emitted(9, 8) Source(18, 30) + SourceIndex(0) -4 >Emitted(9, 14) Source(18, 36) + SourceIndex(0) + > /*@internal*/ +2 > get +3 > c +4 > () { return 10; } + > /*@internal*/ set c(val: +5 > number +6 > +1->Emitted(9, 5) Source(17, 19) + SourceIndex(0) +2 >Emitted(9, 9) Source(17, 23) + SourceIndex(0) +3 >Emitted(9, 10) Source(17, 24) + SourceIndex(0) +4 >Emitted(9, 14) Source(18, 30) + SourceIndex(0) +5 >Emitted(9, 20) Source(18, 36) + SourceIndex(0) +6 >Emitted(9, 21) Source(17, 41) + SourceIndex(0) +--- +>>> set c(val: number); +1->^^^^ +2 > ^^^^ +3 > ^ +4 > ^ +5 > ^^^^^ +6 > ^^^^^^ +7 > ^^ +1-> + > /*@internal*/ +2 > set +3 > c +4 > ( +5 > val: +6 > number +7 > ) { } +1->Emitted(10, 5) Source(18, 19) + SourceIndex(0) +2 >Emitted(10, 9) Source(18, 23) + SourceIndex(0) +3 >Emitted(10, 10) Source(18, 24) + SourceIndex(0) +4 >Emitted(10, 11) Source(18, 25) + SourceIndex(0) +5 >Emitted(10, 16) Source(18, 30) + SourceIndex(0) +6 >Emitted(10, 22) Source(18, 36) + SourceIndex(0) +7 >Emitted(10, 24) Source(18, 41) + SourceIndex(0) --- >>>} 1 >^ 2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1 >) { } +1 > >} -1 >Emitted(10, 2) Source(19, 2) + SourceIndex(0) +1 >Emitted(11, 2) Source(19, 2) + SourceIndex(0) --- >>>declare namespace normalN { 1-> @@ -237,10 +269,10 @@ sourceFile:../second/second_part1.ts 2 >namespace 3 > normalN 4 > -1->Emitted(11, 1) Source(20, 1) + SourceIndex(0) -2 >Emitted(11, 19) Source(20, 11) + SourceIndex(0) -3 >Emitted(11, 26) Source(20, 18) + SourceIndex(0) -4 >Emitted(11, 27) Source(20, 19) + SourceIndex(0) +1->Emitted(12, 1) Source(20, 1) + SourceIndex(0) +2 >Emitted(12, 19) Source(20, 11) + SourceIndex(0) +3 >Emitted(12, 26) Source(20, 18) + SourceIndex(0) +4 >Emitted(12, 27) Source(20, 19) + SourceIndex(0) --- >>> class C { 1 >^^^^ @@ -250,15 +282,15 @@ sourceFile:../second/second_part1.ts > /*@internal*/ 2 > export class 3 > C -1 >Emitted(12, 5) Source(21, 19) + SourceIndex(0) -2 >Emitted(12, 11) Source(21, 32) + SourceIndex(0) -3 >Emitted(12, 12) Source(21, 33) + SourceIndex(0) +1 >Emitted(13, 5) Source(21, 19) + SourceIndex(0) +2 >Emitted(13, 11) Source(21, 32) + SourceIndex(0) +3 >Emitted(13, 12) Source(21, 33) + SourceIndex(0) --- >>> } 1 >^^^^^ 2 > ^^^^^^^^^^^^^^^^^^^^^-> 1 > { } -1 >Emitted(13, 6) Source(21, 37) + SourceIndex(0) +1 >Emitted(14, 6) Source(21, 37) + SourceIndex(0) --- >>> function foo(): void; 1->^^^^ @@ -271,10 +303,10 @@ sourceFile:../second/second_part1.ts 2 > export function 3 > foo 4 > () {} -1->Emitted(14, 5) Source(22, 19) + SourceIndex(0) -2 >Emitted(14, 14) Source(22, 35) + SourceIndex(0) -3 >Emitted(14, 17) Source(22, 38) + SourceIndex(0) -4 >Emitted(14, 26) Source(22, 43) + SourceIndex(0) +1->Emitted(15, 5) Source(22, 19) + SourceIndex(0) +2 >Emitted(15, 14) Source(22, 35) + SourceIndex(0) +3 >Emitted(15, 17) Source(22, 38) + SourceIndex(0) +4 >Emitted(15, 26) Source(22, 43) + SourceIndex(0) --- >>> namespace someNamespace { 1->^^^^ @@ -286,10 +318,10 @@ sourceFile:../second/second_part1.ts 2 > export namespace 3 > someNamespace 4 > -1->Emitted(15, 5) Source(23, 19) + SourceIndex(0) -2 >Emitted(15, 15) Source(23, 36) + SourceIndex(0) -3 >Emitted(15, 28) Source(23, 49) + SourceIndex(0) -4 >Emitted(15, 29) Source(23, 50) + SourceIndex(0) +1->Emitted(16, 5) Source(23, 19) + SourceIndex(0) +2 >Emitted(16, 15) Source(23, 36) + SourceIndex(0) +3 >Emitted(16, 28) Source(23, 49) + SourceIndex(0) +4 >Emitted(16, 29) Source(23, 50) + SourceIndex(0) --- >>> class C { 1 >^^^^^^^^ @@ -298,20 +330,20 @@ sourceFile:../second/second_part1.ts 1 >{ 2 > export class 3 > C -1 >Emitted(16, 9) Source(23, 52) + SourceIndex(0) -2 >Emitted(16, 15) Source(23, 65) + SourceIndex(0) -3 >Emitted(16, 16) Source(23, 66) + SourceIndex(0) +1 >Emitted(17, 9) Source(23, 52) + SourceIndex(0) +2 >Emitted(17, 15) Source(23, 65) + SourceIndex(0) +3 >Emitted(17, 16) Source(23, 66) + SourceIndex(0) --- >>> } 1 >^^^^^^^^^ 1 > {} -1 >Emitted(17, 10) Source(23, 69) + SourceIndex(0) +1 >Emitted(18, 10) Source(23, 69) + SourceIndex(0) --- >>> } 1 >^^^^^ 2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> 1 > } -1 >Emitted(18, 6) Source(23, 71) + SourceIndex(0) +1 >Emitted(19, 6) Source(23, 71) + SourceIndex(0) --- >>> namespace someOther.something { 1->^^^^ @@ -327,12 +359,12 @@ sourceFile:../second/second_part1.ts 4 > . 5 > something 6 > -1->Emitted(19, 5) Source(24, 19) + SourceIndex(0) -2 >Emitted(19, 15) Source(24, 36) + SourceIndex(0) -3 >Emitted(19, 24) Source(24, 45) + SourceIndex(0) -4 >Emitted(19, 25) Source(24, 46) + SourceIndex(0) -5 >Emitted(19, 34) Source(24, 55) + SourceIndex(0) -6 >Emitted(19, 35) Source(24, 56) + SourceIndex(0) +1->Emitted(20, 5) Source(24, 19) + SourceIndex(0) +2 >Emitted(20, 15) Source(24, 36) + SourceIndex(0) +3 >Emitted(20, 24) Source(24, 45) + SourceIndex(0) +4 >Emitted(20, 25) Source(24, 46) + SourceIndex(0) +5 >Emitted(20, 34) Source(24, 55) + SourceIndex(0) +6 >Emitted(20, 35) Source(24, 56) + SourceIndex(0) --- >>> class someClass { 1 >^^^^^^^^ @@ -341,20 +373,20 @@ sourceFile:../second/second_part1.ts 1 >{ 2 > export class 3 > someClass -1 >Emitted(20, 9) Source(24, 58) + SourceIndex(0) -2 >Emitted(20, 15) Source(24, 71) + SourceIndex(0) -3 >Emitted(20, 24) Source(24, 80) + SourceIndex(0) +1 >Emitted(21, 9) Source(24, 58) + SourceIndex(0) +2 >Emitted(21, 15) Source(24, 71) + SourceIndex(0) +3 >Emitted(21, 24) Source(24, 80) + SourceIndex(0) --- >>> } 1 >^^^^^^^^^ 1 > {} -1 >Emitted(21, 10) Source(24, 83) + SourceIndex(0) +1 >Emitted(22, 10) Source(24, 83) + SourceIndex(0) --- >>> } 1 >^^^^^ 2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> 1 > } -1 >Emitted(22, 6) Source(24, 85) + SourceIndex(0) +1 >Emitted(23, 6) Source(24, 85) + SourceIndex(0) --- >>> export import someImport = someNamespace.C; 1->^^^^ @@ -376,15 +408,15 @@ sourceFile:../second/second_part1.ts 7 > . 8 > C 9 > ; -1->Emitted(23, 5) Source(25, 19) + SourceIndex(0) -2 >Emitted(23, 11) Source(25, 25) + SourceIndex(0) -3 >Emitted(23, 19) Source(25, 33) + SourceIndex(0) -4 >Emitted(23, 29) Source(25, 43) + SourceIndex(0) -5 >Emitted(23, 32) Source(25, 46) + SourceIndex(0) -6 >Emitted(23, 45) Source(25, 59) + SourceIndex(0) -7 >Emitted(23, 46) Source(25, 60) + SourceIndex(0) -8 >Emitted(23, 47) Source(25, 61) + SourceIndex(0) -9 >Emitted(23, 48) Source(25, 62) + SourceIndex(0) +1->Emitted(24, 5) Source(25, 19) + SourceIndex(0) +2 >Emitted(24, 11) Source(25, 25) + SourceIndex(0) +3 >Emitted(24, 19) Source(25, 33) + SourceIndex(0) +4 >Emitted(24, 29) Source(25, 43) + SourceIndex(0) +5 >Emitted(24, 32) Source(25, 46) + SourceIndex(0) +6 >Emitted(24, 45) Source(25, 59) + SourceIndex(0) +7 >Emitted(24, 46) Source(25, 60) + SourceIndex(0) +8 >Emitted(24, 47) Source(25, 61) + SourceIndex(0) +9 >Emitted(24, 48) Source(25, 62) + SourceIndex(0) --- >>> type internalType = internalC; 1 >^^^^ @@ -400,12 +432,12 @@ sourceFile:../second/second_part1.ts 4 > = 5 > internalC 6 > ; -1 >Emitted(24, 5) Source(26, 19) + SourceIndex(0) -2 >Emitted(24, 10) Source(26, 31) + SourceIndex(0) -3 >Emitted(24, 22) Source(26, 43) + SourceIndex(0) -4 >Emitted(24, 25) Source(26, 46) + SourceIndex(0) -5 >Emitted(24, 34) Source(26, 55) + SourceIndex(0) -6 >Emitted(24, 35) Source(26, 56) + SourceIndex(0) +1 >Emitted(25, 5) Source(26, 19) + SourceIndex(0) +2 >Emitted(25, 10) Source(26, 31) + SourceIndex(0) +3 >Emitted(25, 22) Source(26, 43) + SourceIndex(0) +4 >Emitted(25, 25) Source(26, 46) + SourceIndex(0) +5 >Emitted(25, 34) Source(26, 55) + SourceIndex(0) +6 >Emitted(25, 35) Source(26, 56) + SourceIndex(0) --- >>> const internalConst = 10; 1 >^^^^ @@ -419,11 +451,11 @@ sourceFile:../second/second_part1.ts 3 > internalConst 4 > = 10 5 > ; -1 >Emitted(25, 5) Source(27, 26) + SourceIndex(0) -2 >Emitted(25, 11) Source(27, 32) + SourceIndex(0) -3 >Emitted(25, 24) Source(27, 45) + SourceIndex(0) -4 >Emitted(25, 29) Source(27, 50) + SourceIndex(0) -5 >Emitted(25, 30) Source(27, 51) + SourceIndex(0) +1 >Emitted(26, 5) Source(27, 26) + SourceIndex(0) +2 >Emitted(26, 11) Source(27, 32) + SourceIndex(0) +3 >Emitted(26, 24) Source(27, 45) + SourceIndex(0) +4 >Emitted(26, 29) Source(27, 50) + SourceIndex(0) +5 >Emitted(26, 30) Source(27, 51) + SourceIndex(0) --- >>> enum internalEnum { 1 >^^^^ @@ -433,9 +465,9 @@ sourceFile:../second/second_part1.ts > /*@internal*/ 2 > export enum 3 > internalEnum -1 >Emitted(26, 5) Source(28, 19) + SourceIndex(0) -2 >Emitted(26, 10) Source(28, 31) + SourceIndex(0) -3 >Emitted(26, 22) Source(28, 43) + SourceIndex(0) +1 >Emitted(27, 5) Source(28, 19) + SourceIndex(0) +2 >Emitted(27, 10) Source(28, 31) + SourceIndex(0) +3 >Emitted(27, 22) Source(28, 43) + SourceIndex(0) --- >>> a = 0, 1 >^^^^^^^^ @@ -445,9 +477,9 @@ sourceFile:../second/second_part1.ts 1 > { 2 > a 3 > -1 >Emitted(27, 9) Source(28, 46) + SourceIndex(0) -2 >Emitted(27, 10) Source(28, 47) + SourceIndex(0) -3 >Emitted(27, 14) Source(28, 47) + SourceIndex(0) +1 >Emitted(28, 9) Source(28, 46) + SourceIndex(0) +2 >Emitted(28, 10) Source(28, 47) + SourceIndex(0) +3 >Emitted(28, 14) Source(28, 47) + SourceIndex(0) --- >>> b = 1, 1->^^^^^^^^ @@ -457,9 +489,9 @@ sourceFile:../second/second_part1.ts 1->, 2 > b 3 > -1->Emitted(28, 9) Source(28, 49) + SourceIndex(0) -2 >Emitted(28, 10) Source(28, 50) + SourceIndex(0) -3 >Emitted(28, 14) Source(28, 50) + SourceIndex(0) +1->Emitted(29, 9) Source(28, 49) + SourceIndex(0) +2 >Emitted(29, 10) Source(28, 50) + SourceIndex(0) +3 >Emitted(29, 14) Source(28, 50) + SourceIndex(0) --- >>> c = 2 1->^^^^^^^^ @@ -468,21 +500,21 @@ sourceFile:../second/second_part1.ts 1->, 2 > c 3 > -1->Emitted(29, 9) Source(28, 52) + SourceIndex(0) -2 >Emitted(29, 10) Source(28, 53) + SourceIndex(0) -3 >Emitted(29, 14) Source(28, 53) + SourceIndex(0) +1->Emitted(30, 9) Source(28, 52) + SourceIndex(0) +2 >Emitted(30, 10) Source(28, 53) + SourceIndex(0) +3 >Emitted(30, 14) Source(28, 53) + SourceIndex(0) --- >>> } 1 >^^^^^ 1 > } -1 >Emitted(30, 6) Source(28, 55) + SourceIndex(0) +1 >Emitted(31, 6) Source(28, 55) + SourceIndex(0) --- >>>} 1 >^ 2 > ^^^^^^^^^^^^^^^^^^^^^^^^^-> 1 > >} -1 >Emitted(31, 2) Source(29, 2) + SourceIndex(0) +1 >Emitted(32, 2) Source(29, 2) + SourceIndex(0) --- >>>declare class internalC { 1-> @@ -492,15 +524,15 @@ sourceFile:../second/second_part1.ts >/*@internal*/ 2 >class 3 > internalC -1->Emitted(32, 1) Source(30, 15) + SourceIndex(0) -2 >Emitted(32, 15) Source(30, 21) + SourceIndex(0) -3 >Emitted(32, 24) Source(30, 30) + SourceIndex(0) +1->Emitted(33, 1) Source(30, 15) + SourceIndex(0) +2 >Emitted(33, 15) Source(30, 21) + SourceIndex(0) +3 >Emitted(33, 24) Source(30, 30) + SourceIndex(0) --- >>>} 1 >^ 2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> 1 > {} -1 >Emitted(33, 2) Source(30, 33) + SourceIndex(0) +1 >Emitted(34, 2) Source(30, 33) + SourceIndex(0) --- >>>declare function internalfoo(): void; 1-> @@ -513,10 +545,10 @@ sourceFile:../second/second_part1.ts 2 >function 3 > internalfoo 4 > () {} -1->Emitted(34, 1) Source(31, 15) + SourceIndex(0) -2 >Emitted(34, 18) Source(31, 24) + SourceIndex(0) -3 >Emitted(34, 29) Source(31, 35) + SourceIndex(0) -4 >Emitted(34, 38) Source(31, 40) + SourceIndex(0) +1->Emitted(35, 1) Source(31, 15) + SourceIndex(0) +2 >Emitted(35, 18) Source(31, 24) + SourceIndex(0) +3 >Emitted(35, 29) Source(31, 35) + SourceIndex(0) +4 >Emitted(35, 38) Source(31, 40) + SourceIndex(0) --- >>>declare namespace internalNamespace { 1-> @@ -528,10 +560,10 @@ sourceFile:../second/second_part1.ts 2 >namespace 3 > internalNamespace 4 > -1->Emitted(35, 1) Source(32, 15) + SourceIndex(0) -2 >Emitted(35, 19) Source(32, 25) + SourceIndex(0) -3 >Emitted(35, 36) Source(32, 42) + SourceIndex(0) -4 >Emitted(35, 37) Source(32, 43) + SourceIndex(0) +1->Emitted(36, 1) Source(32, 15) + SourceIndex(0) +2 >Emitted(36, 19) Source(32, 25) + SourceIndex(0) +3 >Emitted(36, 36) Source(32, 42) + SourceIndex(0) +4 >Emitted(36, 37) Source(32, 43) + SourceIndex(0) --- >>> class someClass { 1 >^^^^ @@ -540,20 +572,20 @@ sourceFile:../second/second_part1.ts 1 >{ 2 > export class 3 > someClass -1 >Emitted(36, 5) Source(32, 45) + SourceIndex(0) -2 >Emitted(36, 11) Source(32, 58) + SourceIndex(0) -3 >Emitted(36, 20) Source(32, 67) + SourceIndex(0) +1 >Emitted(37, 5) Source(32, 45) + SourceIndex(0) +2 >Emitted(37, 11) Source(32, 58) + SourceIndex(0) +3 >Emitted(37, 20) Source(32, 67) + SourceIndex(0) --- >>> } 1 >^^^^^ 1 > {} -1 >Emitted(37, 6) Source(32, 70) + SourceIndex(0) +1 >Emitted(38, 6) Source(32, 70) + SourceIndex(0) --- >>>} 1 >^ 2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> 1 > } -1 >Emitted(38, 2) Source(32, 72) + SourceIndex(0) +1 >Emitted(39, 2) Source(32, 72) + SourceIndex(0) --- >>>declare namespace internalOther.something { 1-> @@ -569,12 +601,12 @@ sourceFile:../second/second_part1.ts 4 > . 5 > something 6 > -1->Emitted(39, 1) Source(33, 15) + SourceIndex(0) -2 >Emitted(39, 19) Source(33, 25) + SourceIndex(0) -3 >Emitted(39, 32) Source(33, 38) + SourceIndex(0) -4 >Emitted(39, 33) Source(33, 39) + SourceIndex(0) -5 >Emitted(39, 42) Source(33, 48) + SourceIndex(0) -6 >Emitted(39, 43) Source(33, 49) + SourceIndex(0) +1->Emitted(40, 1) Source(33, 15) + SourceIndex(0) +2 >Emitted(40, 19) Source(33, 25) + SourceIndex(0) +3 >Emitted(40, 32) Source(33, 38) + SourceIndex(0) +4 >Emitted(40, 33) Source(33, 39) + SourceIndex(0) +5 >Emitted(40, 42) Source(33, 48) + SourceIndex(0) +6 >Emitted(40, 43) Source(33, 49) + SourceIndex(0) --- >>> class someClass { 1 >^^^^ @@ -583,20 +615,20 @@ sourceFile:../second/second_part1.ts 1 >{ 2 > export class 3 > someClass -1 >Emitted(40, 5) Source(33, 51) + SourceIndex(0) -2 >Emitted(40, 11) Source(33, 64) + SourceIndex(0) -3 >Emitted(40, 20) Source(33, 73) + SourceIndex(0) +1 >Emitted(41, 5) Source(33, 51) + SourceIndex(0) +2 >Emitted(41, 11) Source(33, 64) + SourceIndex(0) +3 >Emitted(41, 20) Source(33, 73) + SourceIndex(0) --- >>> } 1 >^^^^^ 1 > {} -1 >Emitted(41, 6) Source(33, 76) + SourceIndex(0) +1 >Emitted(42, 6) Source(33, 76) + SourceIndex(0) --- >>>} 1 >^ 2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> 1 > } -1 >Emitted(42, 2) Source(33, 78) + SourceIndex(0) +1 >Emitted(43, 2) Source(33, 78) + SourceIndex(0) --- >>>import internalImport = internalNamespace.someClass; 1-> @@ -616,14 +648,14 @@ sourceFile:../second/second_part1.ts 6 > . 7 > someClass 8 > ; -1->Emitted(43, 1) Source(34, 15) + SourceIndex(0) -2 >Emitted(43, 8) Source(34, 22) + SourceIndex(0) -3 >Emitted(43, 22) Source(34, 36) + SourceIndex(0) -4 >Emitted(43, 25) Source(34, 39) + SourceIndex(0) -5 >Emitted(43, 42) Source(34, 56) + SourceIndex(0) -6 >Emitted(43, 43) Source(34, 57) + SourceIndex(0) -7 >Emitted(43, 52) Source(34, 66) + SourceIndex(0) -8 >Emitted(43, 53) Source(34, 67) + SourceIndex(0) +1->Emitted(44, 1) Source(34, 15) + SourceIndex(0) +2 >Emitted(44, 8) Source(34, 22) + SourceIndex(0) +3 >Emitted(44, 22) Source(34, 36) + SourceIndex(0) +4 >Emitted(44, 25) Source(34, 39) + SourceIndex(0) +5 >Emitted(44, 42) Source(34, 56) + SourceIndex(0) +6 >Emitted(44, 43) Source(34, 57) + SourceIndex(0) +7 >Emitted(44, 52) Source(34, 66) + SourceIndex(0) +8 >Emitted(44, 53) Source(34, 67) + SourceIndex(0) --- >>>declare type internalType = internalC; 1 > @@ -639,12 +671,12 @@ sourceFile:../second/second_part1.ts 4 > = 5 > internalC 6 > ; -1 >Emitted(44, 1) Source(35, 15) + SourceIndex(0) -2 >Emitted(44, 14) Source(35, 20) + SourceIndex(0) -3 >Emitted(44, 26) Source(35, 32) + SourceIndex(0) -4 >Emitted(44, 29) Source(35, 35) + SourceIndex(0) -5 >Emitted(44, 38) Source(35, 44) + SourceIndex(0) -6 >Emitted(44, 39) Source(35, 45) + SourceIndex(0) +1 >Emitted(45, 1) Source(35, 15) + SourceIndex(0) +2 >Emitted(45, 14) Source(35, 20) + SourceIndex(0) +3 >Emitted(45, 26) Source(35, 32) + SourceIndex(0) +4 >Emitted(45, 29) Source(35, 35) + SourceIndex(0) +5 >Emitted(45, 38) Source(35, 44) + SourceIndex(0) +6 >Emitted(45, 39) Source(35, 45) + SourceIndex(0) --- >>>declare const internalConst = 10; 1 > @@ -660,12 +692,12 @@ sourceFile:../second/second_part1.ts 4 > internalConst 5 > = 10 6 > ; -1 >Emitted(45, 1) Source(36, 15) + SourceIndex(0) -2 >Emitted(45, 9) Source(36, 15) + SourceIndex(0) -3 >Emitted(45, 15) Source(36, 21) + SourceIndex(0) -4 >Emitted(45, 28) Source(36, 34) + SourceIndex(0) -5 >Emitted(45, 33) Source(36, 39) + SourceIndex(0) -6 >Emitted(45, 34) Source(36, 40) + SourceIndex(0) +1 >Emitted(46, 1) Source(36, 15) + SourceIndex(0) +2 >Emitted(46, 9) Source(36, 15) + SourceIndex(0) +3 >Emitted(46, 15) Source(36, 21) + SourceIndex(0) +4 >Emitted(46, 28) Source(36, 34) + SourceIndex(0) +5 >Emitted(46, 33) Source(36, 39) + SourceIndex(0) +6 >Emitted(46, 34) Source(36, 40) + SourceIndex(0) --- >>>declare enum internalEnum { 1 > @@ -675,9 +707,9 @@ sourceFile:../second/second_part1.ts >/*@internal*/ 2 >enum 3 > internalEnum -1 >Emitted(46, 1) Source(37, 15) + SourceIndex(0) -2 >Emitted(46, 14) Source(37, 20) + SourceIndex(0) -3 >Emitted(46, 26) Source(37, 32) + SourceIndex(0) +1 >Emitted(47, 1) Source(37, 15) + SourceIndex(0) +2 >Emitted(47, 14) Source(37, 20) + SourceIndex(0) +3 >Emitted(47, 26) Source(37, 32) + SourceIndex(0) --- >>> a = 0, 1 >^^^^ @@ -687,9 +719,9 @@ sourceFile:../second/second_part1.ts 1 > { 2 > a 3 > -1 >Emitted(47, 5) Source(37, 35) + SourceIndex(0) -2 >Emitted(47, 6) Source(37, 36) + SourceIndex(0) -3 >Emitted(47, 10) Source(37, 36) + SourceIndex(0) +1 >Emitted(48, 5) Source(37, 35) + SourceIndex(0) +2 >Emitted(48, 6) Source(37, 36) + SourceIndex(0) +3 >Emitted(48, 10) Source(37, 36) + SourceIndex(0) --- >>> b = 1, 1->^^^^ @@ -699,9 +731,9 @@ sourceFile:../second/second_part1.ts 1->, 2 > b 3 > -1->Emitted(48, 5) Source(37, 38) + SourceIndex(0) -2 >Emitted(48, 6) Source(37, 39) + SourceIndex(0) -3 >Emitted(48, 10) Source(37, 39) + SourceIndex(0) +1->Emitted(49, 5) Source(37, 38) + SourceIndex(0) +2 >Emitted(49, 6) Source(37, 39) + SourceIndex(0) +3 >Emitted(49, 10) Source(37, 39) + SourceIndex(0) --- >>> c = 2 1->^^^^ @@ -710,15 +742,15 @@ sourceFile:../second/second_part1.ts 1->, 2 > c 3 > -1->Emitted(49, 5) Source(37, 41) + SourceIndex(0) -2 >Emitted(49, 6) Source(37, 42) + SourceIndex(0) -3 >Emitted(49, 10) Source(37, 42) + SourceIndex(0) +1->Emitted(50, 5) Source(37, 41) + SourceIndex(0) +2 >Emitted(50, 6) Source(37, 42) + SourceIndex(0) +3 >Emitted(50, 10) Source(37, 42) + SourceIndex(0) --- >>>} 1 >^ 2 > ^^^^^^^^^^^^^^^^^-> 1 > } -1 >Emitted(50, 2) Source(37, 44) + SourceIndex(0) +1 >Emitted(51, 2) Source(37, 44) + SourceIndex(0) --- ------------------------------------------------------------------- emittedFile:/src/2/second-output.d.ts @@ -732,9 +764,9 @@ sourceFile:../second/second_part2.ts 1-> 2 >class 3 > C -1->Emitted(51, 1) Source(1, 1) + SourceIndex(1) -2 >Emitted(51, 15) Source(1, 7) + SourceIndex(1) -3 >Emitted(51, 16) Source(1, 8) + SourceIndex(1) +1->Emitted(52, 1) Source(1, 1) + SourceIndex(1) +2 >Emitted(52, 15) Source(1, 7) + SourceIndex(1) +3 >Emitted(52, 16) Source(1, 8) + SourceIndex(1) --- >>> doSomething(): void; 1->^^^^ @@ -742,8 +774,8 @@ sourceFile:../second/second_part2.ts 1-> { > 2 > doSomething -1->Emitted(52, 5) Source(2, 5) + SourceIndex(1) -2 >Emitted(52, 16) Source(2, 16) + SourceIndex(1) +1->Emitted(53, 5) Source(2, 5) + SourceIndex(1) +2 >Emitted(53, 16) Source(2, 16) + SourceIndex(1) --- >>>} 1 >^ @@ -752,7 +784,7 @@ sourceFile:../second/second_part2.ts > console.log("something got done"); > } >} -1 >Emitted(53, 2) Source(5, 2) + SourceIndex(1) +1 >Emitted(54, 2) Source(5, 2) + SourceIndex(1) --- >>>//# sourceMappingURL=second-output.d.ts.map @@ -2336,32 +2368,32 @@ sourceFile:../second/second_part2.ts }, { "pos": 77, - "end": 151, + "end": 182, "kind": "internal" }, { - "pos": 153, - "end": 185, + "pos": 184, + "end": 216, "kind": "text" }, { - "pos": 185, - "end": 577, + "pos": 216, + "end": 608, "kind": "internal" }, { - "pos": 579, - "end": 582, + "pos": 610, + "end": 613, "kind": "text" }, { - "pos": 582, - "end": 995, + "pos": 613, + "end": 1026, "kind": "internal" }, { - "pos": 997, - "end": 1045, + "pos": 1028, + "end": 1076, "kind": "text" } ] @@ -2490,18 +2522,19 @@ declare namespace N { declare class normalC { ---------------------------------------------------------------------- -internal: (77-151) +internal: (77-182) constructor(); prop: string; method(): void; - c: number; + get c(): number; + set c(val: number); ---------------------------------------------------------------------- -text: (153-185) +text: (184-216) } declare namespace normalN { ---------------------------------------------------------------------- -internal: (185-577) +internal: (216-608) class C { } function foo(): void; @@ -2522,11 +2555,11 @@ internal: (185-577) c = 2 } ---------------------------------------------------------------------- -text: (579-582) +text: (610-613) } ---------------------------------------------------------------------- -internal: (582-995) +internal: (613-1026) declare class internalC { } declare function internalfoo(): void; @@ -2547,7 +2580,7 @@ declare enum internalEnum { c = 2 } ---------------------------------------------------------------------- -text: (997-1045) +text: (1028-1076) declare class C { doSomething(): void; } diff --git a/tests/baselines/reference/typeGuardOfFormThisMember.js b/tests/baselines/reference/typeGuardOfFormThisMember.js index 1d4d9df79e22d..50c8ff0f7890a 100644 --- a/tests/baselines/reference/typeGuardOfFormThisMember.js +++ b/tests/baselines/reference/typeGuardOfFormThisMember.js @@ -178,8 +178,9 @@ declare namespace Test { class FileSystemObject { path: string; isFSO: this is FileSystemObject; - isFile: this is File; - readonly isDirectory: this is Directory; + get isFile(): this is File; + set isFile(param: this is File); + get isDirectory(): this is Directory; isNetworked: this is (Networked & this); constructor(path: string); } diff --git a/tests/baselines/reference/typeGuardOfFormThisMemberErrors.js b/tests/baselines/reference/typeGuardOfFormThisMemberErrors.js index 1992c339b328d..8456dc1797ee8 100644 --- a/tests/baselines/reference/typeGuardOfFormThisMemberErrors.js +++ b/tests/baselines/reference/typeGuardOfFormThisMemberErrors.js @@ -103,8 +103,9 @@ declare namespace Test { class FileSystemObject { path: string; isFSO: this is FileSystemObject; - isFile: this is File; - readonly isDirectory: this is Directory; + get isFile(): this is File; + set isFile(param: this is File); + get isDirectory(): this is Directory; isNetworked: this is (Networked & this); constructor(path: string); } diff --git a/tests/baselines/reference/uniqueSymbolsDeclarationsErrors.js b/tests/baselines/reference/uniqueSymbolsDeclarationsErrors.js index 871d8977a9de2..723ec89c0a65d 100644 --- a/tests/baselines/reference/uniqueSymbolsDeclarationsErrors.js +++ b/tests/baselines/reference/uniqueSymbolsDeclarationsErrors.js @@ -141,7 +141,9 @@ export declare class ClassWithPrivateNamedMethods { static [s](): void; } export declare class ClassWithPrivateNamedAccessors { - [s]: any; - static [s]: any; + get [s](): any; + set [s](v: any); + static get [s](): any; + static set [s](v: any); } export {}; diff --git a/tests/cases/conformance/classes/propertyMemberDeclarations/accessorsOverrideMethod.ts b/tests/cases/conformance/classes/propertyMemberDeclarations/accessorsOverrideMethod.ts new file mode 100644 index 0000000000000..7090c4c6c2a20 --- /dev/null +++ b/tests/cases/conformance/classes/propertyMemberDeclarations/accessorsOverrideMethod.ts @@ -0,0 +1,8 @@ +// @target: esnext +// @useDefineForClassFields: true +class A { + m() { } +} +class B extends A { + get m() { return () => 1 } +} diff --git a/tests/cases/conformance/classes/propertyMemberDeclarations/accessorsOverrideProperty.ts b/tests/cases/conformance/classes/propertyMemberDeclarations/accessorsOverrideProperty.ts new file mode 100644 index 0000000000000..e23b28a18e9f1 --- /dev/null +++ b/tests/cases/conformance/classes/propertyMemberDeclarations/accessorsOverrideProperty.ts @@ -0,0 +1,16 @@ +// @target: esnext +// @useDefineForClassFields: true +class A { + p = 'yep' +} +class B extends A { + get p() { return 'oh no' } // error +} +class C { + p = 101 +} +class D extends C { + _secret = 11 + get p() { return this._secret } // error + set p(value) { this._secret = value } // error +} diff --git a/tests/cases/conformance/classes/propertyMemberDeclarations/accessorsOverrideProperty2.ts b/tests/cases/conformance/classes/propertyMemberDeclarations/accessorsOverrideProperty2.ts new file mode 100644 index 0000000000000..a90b76ad23b99 --- /dev/null +++ b/tests/cases/conformance/classes/propertyMemberDeclarations/accessorsOverrideProperty2.ts @@ -0,0 +1,13 @@ +// @target: esnext +// @useDefineForClassFields: true +class Base { + x = 1; +} + +class Derived extends Base { + get x() { return 2; } // should be an error + set x(value) { console.log(`x was set to ${value}`); } +} + +const obj = new Derived(); // nothing printed +console.log(obj.x); // 1 diff --git a/tests/cases/conformance/classes/propertyMemberDeclarations/accessorsOverrideProperty3.ts b/tests/cases/conformance/classes/propertyMemberDeclarations/accessorsOverrideProperty3.ts new file mode 100644 index 0000000000000..b081cef21e239 --- /dev/null +++ b/tests/cases/conformance/classes/propertyMemberDeclarations/accessorsOverrideProperty3.ts @@ -0,0 +1,10 @@ +// @target: esnext +// @useDefineForClassFields: true +declare class Animal { + sound: string +} +class Lion extends Animal { + _sound = 'grrr' + get sound() { return this._sound } // error here + set sound(val) { this._sound = val } +} diff --git a/tests/cases/conformance/classes/propertyMemberDeclarations/accessorsOverrideProperty4.ts b/tests/cases/conformance/classes/propertyMemberDeclarations/accessorsOverrideProperty4.ts new file mode 100644 index 0000000000000..021f81ea7e96d --- /dev/null +++ b/tests/cases/conformance/classes/propertyMemberDeclarations/accessorsOverrideProperty4.ts @@ -0,0 +1,10 @@ +// @target: esnext +// @useDefineForClassFields: true +declare class Animal { + sound: string; +} +class Lion extends Animal { + _sound = 'roar' + get sound(): string { return this._sound } + set sound(val: string) { this._sound = val } +} diff --git a/tests/cases/conformance/classes/propertyMemberDeclarations/accessorsOverrideProperty5.ts b/tests/cases/conformance/classes/propertyMemberDeclarations/accessorsOverrideProperty5.ts new file mode 100644 index 0000000000000..fe8620d6f77e3 --- /dev/null +++ b/tests/cases/conformance/classes/propertyMemberDeclarations/accessorsOverrideProperty5.ts @@ -0,0 +1,11 @@ +// @target: esnext +// @useDefineForClassFields: true +interface I { + p: number +} +interface B extends I { } +class B { } +class C extends B { + get p() { return 1 } + set p(value) { } +} diff --git a/tests/cases/conformance/classes/propertyMemberDeclarations/accessorsOverrideProperty6.ts b/tests/cases/conformance/classes/propertyMemberDeclarations/accessorsOverrideProperty6.ts new file mode 100644 index 0000000000000..b782496f3fb84 --- /dev/null +++ b/tests/cases/conformance/classes/propertyMemberDeclarations/accessorsOverrideProperty6.ts @@ -0,0 +1,16 @@ +// @target: esnext +// @useDefineForClassFields: false +class A { + p = 'yep' +} +class B extends A { + get p() { return 'oh no' } // error +} +class C { + p = 101 +} +class D extends C { + _secret = 11 + get p() { return this._secret } // error + set p(value) { this._secret = value } // error +} diff --git a/tests/cases/conformance/classes/propertyMemberDeclarations/accessorsOverrideProperty7.ts b/tests/cases/conformance/classes/propertyMemberDeclarations/accessorsOverrideProperty7.ts new file mode 100644 index 0000000000000..9be3dad44f832 --- /dev/null +++ b/tests/cases/conformance/classes/propertyMemberDeclarations/accessorsOverrideProperty7.ts @@ -0,0 +1,8 @@ +// @target: es5 +// @useDefineForClassFields: true +abstract class A { + abstract p = 'yep' +} +class B extends A { + get p() { return 'oh no' } // error +} diff --git a/tests/cases/conformance/classes/propertyMemberDeclarations/definePropertyES5.ts b/tests/cases/conformance/classes/propertyMemberDeclarations/definePropertyES5.ts new file mode 100644 index 0000000000000..73e1ee515d1d8 --- /dev/null +++ b/tests/cases/conformance/classes/propertyMemberDeclarations/definePropertyES5.ts @@ -0,0 +1,10 @@ +// @target: es5 +// @useDefineForClassFields: true +var x: "p" = "p" +class A { + a = 12 + b + ["computed"] = 13 + ;[x] = 14 + m() { } +} diff --git a/tests/cases/conformance/classes/propertyMemberDeclarations/definePropertyOutputES3.ts b/tests/cases/conformance/classes/propertyMemberDeclarations/definePropertyOutputES3.ts new file mode 100644 index 0000000000000..f6a62d32650fa --- /dev/null +++ b/tests/cases/conformance/classes/propertyMemberDeclarations/definePropertyOutputES3.ts @@ -0,0 +1,5 @@ +// @target: es3 +// @useDefineForClassFields: true +class A { + a = 12 +} diff --git a/tests/cases/conformance/classes/propertyMemberDeclarations/derivedUninitializedPropertyDeclaration.ts b/tests/cases/conformance/classes/propertyMemberDeclarations/derivedUninitializedPropertyDeclaration.ts new file mode 100644 index 0000000000000..e2d7494dd6891 --- /dev/null +++ b/tests/cases/conformance/classes/propertyMemberDeclarations/derivedUninitializedPropertyDeclaration.ts @@ -0,0 +1,67 @@ +// @strict: true +class A { + property = 'x'; + m() { return 1 } +} +class B extends A { + property: any; // error +} +class BD extends A { + declare property: any; // ok because it's implicitly initialised +} +class BDBang extends A { + declare property!: any; // ! is not allowed, this is an ambient declaration +} +class BOther extends A { + declare m() { return 2 } // not allowed on methods + declare nonce: any; // ok, even though it's not in the base + declare property = 'y' // initialiser not allowed with declare +} +class U { + declare nonce: any; // ok, even though there's no base +} + +class C { + p: string; +} +class D extends C { + p: 'hi'; // error +} +class DD extends C { + declare p: 'bye'; // ok +} + + +declare class E { + p1: string + p2: string +} +class F extends E { + p1!: 'z' + declare p2: 'alpha' +} + +class G extends E { + p1: 'z' + constructor() { + super() + this.p1 = 'z' + } +} + +abstract class H extends E { + abstract p1: 'a' | 'b' | 'c' + declare abstract p2: 'a' | 'b' | 'c' +} + +interface I { + q: number +} +interface J extends I { } +class J { + r = 5 +} +class K extends J { + q!: 1 | 2 | 3 // ok, extends a property from an interface + r!: 4 | 5 // error, from class +} diff --git a/tests/cases/conformance/classes/propertyMemberDeclarations/overrideInterfaceProperty.ts b/tests/cases/conformance/classes/propertyMemberDeclarations/overrideInterfaceProperty.ts new file mode 100644 index 0000000000000..8b70357515cd2 --- /dev/null +++ b/tests/cases/conformance/classes/propertyMemberDeclarations/overrideInterfaceProperty.ts @@ -0,0 +1,18 @@ +// @target: esnext +interface Mup { + readonly size: number; +} +interface MupConstructor { + new(): Mup; + new(entries?: readonly (readonly [K, V])[] | null): Mup; + readonly prototype: Mup; +} +declare var Mup: MupConstructor; + +class Sizz extends Mup { + // ok, because Mup is an interface + get size() { return 0 } +} +class Kasizz extends Mup { + size = -1 +} diff --git a/tests/cases/conformance/classes/propertyMemberDeclarations/propertyOverridesAccessors.ts b/tests/cases/conformance/classes/propertyMemberDeclarations/propertyOverridesAccessors.ts new file mode 100644 index 0000000000000..aa00b32f64a4a --- /dev/null +++ b/tests/cases/conformance/classes/propertyMemberDeclarations/propertyOverridesAccessors.ts @@ -0,0 +1,16 @@ +// @target: es2015 +// @useDefineForClassFields: true +class A { + get p() { return 'oh no' } +} +class B extends A { + p = 'yep' // error +} +class C { + _secret = 11 + get p() { return this._secret } + set p(value) { this._secret = value } +} +class D extends C { + p = 101 // error +} diff --git a/tests/cases/conformance/classes/propertyMemberDeclarations/propertyOverridesAccessors2.ts b/tests/cases/conformance/classes/propertyMemberDeclarations/propertyOverridesAccessors2.ts new file mode 100644 index 0000000000000..51424d7f099ac --- /dev/null +++ b/tests/cases/conformance/classes/propertyMemberDeclarations/propertyOverridesAccessors2.ts @@ -0,0 +1,13 @@ +// @target: esnext +// @useDefineForClassFields: true +class Base { + get x() { return 2; } + set x(value) { console.log(`x was set to ${value}`); } +} + +class Derived extends Base { + x = 1; +} + +const obj = new Derived(); // prints 'x was set to 1' +console.log(obj.x); // 2 diff --git a/tests/cases/conformance/classes/propertyMemberDeclarations/propertyOverridesAccessors3.ts b/tests/cases/conformance/classes/propertyMemberDeclarations/propertyOverridesAccessors3.ts new file mode 100644 index 0000000000000..3376155a1506a --- /dev/null +++ b/tests/cases/conformance/classes/propertyMemberDeclarations/propertyOverridesAccessors3.ts @@ -0,0 +1,25 @@ +// @target: esnext +// @useDefineForClassFields: true +class Animal { + _sound = 'rustling noise in the bushes' + + get sound() { return this._sound } + set sound(val) { + this._sound = val; + /* some important code here, perhaps tracking known sounds, etc */ + } + + makeSound() { + console.log(this._sound) + } +} + +const a = new Animal +a.makeSound() // 'rustling noise in the bushes' + +class Lion extends Animal { + sound = 'RAWR!' // error here +} + +const lion = new Lion +lion.makeSound() // with [[Define]]: Expected "RAWR!" but got "rustling noise in the bushes" diff --git a/tests/cases/conformance/classes/propertyMemberDeclarations/propertyOverridesAccessors4.ts b/tests/cases/conformance/classes/propertyMemberDeclarations/propertyOverridesAccessors4.ts new file mode 100644 index 0000000000000..f4357465676f0 --- /dev/null +++ b/tests/cases/conformance/classes/propertyMemberDeclarations/propertyOverridesAccessors4.ts @@ -0,0 +1,9 @@ +// @target: es5 +// @useDefineForClassFields: true +declare class Animal { + get sound(): string + set sound(val: string) +} +class Lion extends Animal { + sound = 'RAWR!' // error here +} diff --git a/tests/cases/conformance/classes/propertyMemberDeclarations/propertyOverridesAccessors5.ts b/tests/cases/conformance/classes/propertyMemberDeclarations/propertyOverridesAccessors5.ts new file mode 100644 index 0000000000000..7f2947805013a --- /dev/null +++ b/tests/cases/conformance/classes/propertyMemberDeclarations/propertyOverridesAccessors5.ts @@ -0,0 +1,10 @@ +// @target: esnext +// @useDefineForClassFields: true +class A { + get p() { return 'oh no' } +} +class B extends A { + constructor(public p: string) { + super() + } +} diff --git a/tests/cases/conformance/classes/propertyMemberDeclarations/propertyOverridesMethod.ts b/tests/cases/conformance/classes/propertyMemberDeclarations/propertyOverridesMethod.ts new file mode 100644 index 0000000000000..ce0a03f15c68c --- /dev/null +++ b/tests/cases/conformance/classes/propertyMemberDeclarations/propertyOverridesMethod.ts @@ -0,0 +1,8 @@ +// @target: esnext +// @useDefineForClassFields: true +class A { + m() { } +} +class B extends A { + m = () => 1 +} diff --git a/tests/cases/conformance/classes/propertyMemberDeclarations/thisPropertyOverridesAccessors.ts b/tests/cases/conformance/classes/propertyMemberDeclarations/thisPropertyOverridesAccessors.ts new file mode 100644 index 0000000000000..779d326fa6f3b --- /dev/null +++ b/tests/cases/conformance/classes/propertyMemberDeclarations/thisPropertyOverridesAccessors.ts @@ -0,0 +1,17 @@ +// @target: esnext +// @allowjs: true +// @noemit: true +// @checkjs: true +// @Filename: foo.ts +class Foo { + get p() { return 1 } + set p(value) { } +} + +// @Filename: bar.js +class Bar extends Foo { + constructor() { + super() + this.p = 2 + } +} diff --git a/tests/cases/fourslash/codeFixAddMissingDeclareProperty.ts b/tests/cases/fourslash/codeFixAddMissingDeclareProperty.ts new file mode 100644 index 0000000000000..e4ebea338f6c3 --- /dev/null +++ b/tests/cases/fourslash/codeFixAddMissingDeclareProperty.ts @@ -0,0 +1,19 @@ +/// +// @useDefineForClassFields: true + +////class B { +//// p = 1 +////} +////class C extends B { +//// p: number +////} + +verify.codeFix({ + description: "Prefix with 'declare'", + newFileContent: `class B { + p = 1 +} +class C extends B { + declare p: number +}` +}); diff --git a/tests/cases/fourslash/codeFixAddMissingDeclareProperty2.ts b/tests/cases/fourslash/codeFixAddMissingDeclareProperty2.ts new file mode 100644 index 0000000000000..5abf2b0e233fc --- /dev/null +++ b/tests/cases/fourslash/codeFixAddMissingDeclareProperty2.ts @@ -0,0 +1,26 @@ +/// +// @useDefineForClassFields: true + +////class B { +//// p = 1 +////} +////class C extends B { +//// p: number +////} +////class D extends B { +//// p: 1 | 2 | 3 +////} + +verify.codeFixAll({ + fixId: "addMissingDeclareProperty", + fixAllDescription: "Prefix all incorrect property declarations with 'declare'", + newFileContent: `class B { + p = 1 +} +class C extends B { + declare p: number +} +class D extends B { + declare p: 1 | 2 | 3 +}` +}); diff --git a/tests/cases/fourslash/derivedTypeIndexerWithGenericConstraints.ts b/tests/cases/fourslash/derivedTypeIndexerWithGenericConstraints.ts index 21489b5d8aa9b..82dfe9429e1b2 100644 --- a/tests/cases/fourslash/derivedTypeIndexerWithGenericConstraints.ts +++ b/tests/cases/fourslash/derivedTypeIndexerWithGenericConstraints.ts @@ -13,7 +13,7 @@ ////} ////class DbSet extends BaseCollection { // error -//// _itemsByKey: { [key: string]: TEntity; }; +//// _itemsByKey: { [key: string]: TEntity; } = {}; ////} ////var a: BaseCollection; diff --git a/tests/cases/fourslash/incompatibleOverride.ts b/tests/cases/fourslash/incompatibleOverride.ts index 0b3dd3230154c..1ce0b07def189 100644 --- a/tests/cases/fourslash/incompatibleOverride.ts +++ b/tests/cases/fourslash/incompatibleOverride.ts @@ -3,8 +3,8 @@ // Squiggle for implementing a derived class with an incompatible override is too large //// class Foo { xyz: string; } -//// class Bar extends Foo { /*1*/xyz/*2*/: number; } -//// class Baz extends Foo { public /*3*/xyz/*4*/: number; } +//// class Bar extends Foo { /*1*/xyz/*2*/: number = 1; } +//// class Baz extends Foo { public /*3*/xyz/*4*/: number = 2; } //// class /*5*/Baf/*6*/ extends Foo { //// constructor(public xyz: number) { //// super(); @@ -14,4 +14,4 @@ verify.errorExistsBetweenMarkers('1', '2'); verify.errorExistsBetweenMarkers('3', '4'); verify.errorExistsBetweenMarkers('5', '6'); -verify.numberOfErrorsInCurrentFile(3); \ No newline at end of file +verify.numberOfErrorsInCurrentFile(3); diff --git a/tests/cases/fourslash/squiggleIllegalSubclassOverride.ts b/tests/cases/fourslash/squiggleIllegalSubclassOverride.ts index 955d461b9f13a..c97c6c75fcf5b 100644 --- a/tests/cases/fourslash/squiggleIllegalSubclassOverride.ts +++ b/tests/cases/fourslash/squiggleIllegalSubclassOverride.ts @@ -5,8 +5,8 @@ ////} //// ////class Bar extends Foo { -//// public /*1*/x/*2*/: string; +//// public /*1*/x/*2*/: string = 'hi'; ////} verify.errorExistsBetweenMarkers("1", "2"); -verify.numberOfErrorsInCurrentFile(1); \ No newline at end of file +verify.numberOfErrorsInCurrentFile(1); From 62a43576b393ac4f315f8cdc5a96954eed6a8de0 Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Thu, 26 Sep 2019 13:44:10 -0700 Subject: [PATCH 3/4] Enable eslint cache (#33619) --- .gitignore | 3 ++- Gulpfile.js | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index da24307954912..64a6ca01b3a9d 100644 --- a/.gitignore +++ b/.gitignore @@ -91,4 +91,5 @@ tests/cases/user/create-react-app/create-react-app tests/cases/user/webpack/webpack tests/cases/user/puppeteer/puppeteer tests/cases/user/axios-src/axios-src -tests/cases/user/prettier/prettier \ No newline at end of file +tests/cases/user/prettier/prettier +.eslintcache \ No newline at end of file diff --git a/Gulpfile.js b/Gulpfile.js index 1f930e3b01967..20c32e9fc4a61 100644 --- a/Gulpfile.js +++ b/Gulpfile.js @@ -341,6 +341,8 @@ const eslint = (folder) => async () => { const args = [ "node_modules/eslint/bin/eslint", + "--cache", + "--cache-location", `${folder}/.eslintcache`, "--format", "autolinkable-stylish", "--rulesdir", "scripts/eslint/built/rules", "--ext", ".ts", From 61cb06ce401ea9d7ace005ea1c770517d4497427 Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Thu, 26 Sep 2019 14:27:16 -0700 Subject: [PATCH 4/4] Allow `allowJs` and `declaration` to be used together (#32372) * Allow allowJs and declaration to be used together This intorduces a new symbol-based declaration emitter - currently this is only used for JSON and JavaScript, as the output is likely worse than what the other declaration emitter is capable of. In addition, it is still incomplete - it does not yet support serializaing namespaces. * Add tests for various import/export forms, add notes on export as namespace and fix export * from * Tests & fixes for computed names * Add test with current @enum tag behavior * fix declaration emit for jsdoc @enum tags * Small adjustments to base class serialization to fix bugs in it * Guard against type/type parameter confusion when using typeParameterToName a bit * Integrate feedback from PR * Fix issue with export= declarations visibility calculation and type declaration emit that impacted all forms of declaration emit * Only make one merged getCommonJsExportEquals symbol for a symbol * Support preserving type reference directives in js declarations * Skip declare mdoifiers for namespace members in ambient contexts * FAKE ALIASES AND NAMESPACES EVERYWHERE * Dont do namespace sugar when type members contain keyword names * Fix json source file export modifier under new output * Such clean nested aliasing, very wow * Fix lint * Add visibility errors, reuse type nodes where possible * Suppoer having correctly named import types in bundled js declaration emit & adjust binding to allow namespaces with aliases to merge when the aliases look to be type-only * Better support for module.exports = class expression * Fix discovered crash bug * Allow export assigned class expressions to be reachable symbols from external declarations * Add missing semicolon * Support @enum tag post-merge * preserve comments on signatures and declarations where possible * Basic support for js classy functions * Add example we should do better with * Prototype assignments make things a bit wonky, but the example from the PR seems OK * Make a ton of changes to support the new way js classes are bound * Remove some old comments, fix import and export default names * Fix bug in object define handling and add tests for object define property declaration emit * Fix organization nits from PR comments * Preserve comments from jsdoc declarations on properties and js declaration type aliases * Merge export declarations with identical specifiers * Remove completed TODO comment * Split lint * Remove now-unused function * PR feedback * Add some project references tests, remove some checks from project refs codepaths that are now invalid * Update project references tests again * Merge and update project references tests * Rename case * Update test to include declaration output * Remove yet another project refernces redirect extension check * Update comment * Add additional import ref to test * Add shorthand prop to test * Fix comment text * Extract var to temp * Simplify function and add whitespace * Update project refs test to use incremental edit entry * Stylistic refactors in the symbol serializer * Another round of PR feedback, mostly style, small bugfix with constructors, and test showing bug in export assigned class expression name shadowing * Use x instead of index --- src/compiler/binder.ts | 77 +- src/compiler/checker.ts | 1484 ++++++++++++++++- src/compiler/core.ts | 8 + src/compiler/diagnosticMessages.json | 8 + src/compiler/emitter.ts | 18 +- src/compiler/factory.ts | 5 + src/compiler/program.ts | 15 +- src/compiler/transformers/declarations.ts | 56 +- src/compiler/types.ts | 10 +- src/compiler/utilities.ts | 75 +- src/harness/compiler.ts | 21 +- src/harness/harness.ts | 6 +- src/services/utilities.ts | 3 +- src/testRunner/tsconfig.json | 1 + .../tsbuild/javascriptProjectEmit.ts | 286 ++++ .../unittests/tsbuild/resolveJsonModule.ts | 7 +- .../unittests/tscWatch/programUpdates.ts | 9 +- .../unittests/tsserver/projectErrors.ts | 9 +- .../reference/api/tsserverlibrary.d.ts | 2 +- tests/baselines/reference/api/typescript.d.ts | 2 +- .../reference/augmentExportEquals3.types | 2 +- .../reference/augmentExportEquals4.types | 2 +- .../reference/augmentExportEquals5.symbols | 2 +- .../reference/augmentExportEquals6.types | 2 +- .../checkJsTypeDefNoUnusedLocalMarked.types | 10 +- .../reference/constructorFunctions2.types | 8 +- .../reference/declarationEmitNameConflicts.js | 2 +- ...ileNoCrashOnExtraExportModifier.errors.txt | 22 + ...arationFileNoCrashOnExtraExportModifier.js | 23 + ...onFileNoCrashOnExtraExportModifier.symbols | 30 + ...tionFileNoCrashOnExtraExportModifier.types | 30 + ...tionImportTypeAliasInferredAndEmittable.js | 57 + ...mportTypeAliasInferredAndEmittable.symbols | 43 + ...nImportTypeAliasInferredAndEmittable.types | 44 + .../duplicateExportAssignments.types | 2 +- .../baselines/reference/es5ExportEquals.types | 2 +- .../baselines/reference/es6ExportEquals.types | 2 +- .../exportAssignmentAndDeclaration.types | 2 +- .../exportAssignmentWithExports.types | 2 +- .../reference/importTypeGenericTypes.types | 2 +- .../reference/importTypeInJSDoc.types | 14 +- .../baselines/reference/importTypeLocal.types | 2 +- .../jsDeclarationsClassExtendsVisibility.js | 68 + ...DeclarationsClassExtendsVisibility.symbols | 44 + ...jsDeclarationsClassExtendsVisibility.types | 51 + .../reference/jsDeclarationsClasses.js | 591 +++++++ .../reference/jsDeclarationsClasses.symbols | 307 ++++ .../reference/jsDeclarationsClasses.types | 331 ++++ .../jsDeclarationsClassesErr.errors.txt | 136 ++ .../reference/jsDeclarationsClassesErr.js | 290 ++++ .../jsDeclarationsClassesErr.symbols | 153 ++ .../reference/jsDeclarationsClassesErr.types | 148 ++ .../reference/jsDeclarationsComputedNames.js | 92 + .../jsDeclarationsComputedNames.symbols | 68 + .../jsDeclarationsComputedNames.types | 81 + .../reference/jsDeclarationsDefault.js | 141 ++ .../reference/jsDeclarationsDefault.symbols | 64 + .../reference/jsDeclarationsDefault.types | 68 + .../jsDeclarationsDefaultsErr.errors.txt | 34 + .../reference/jsDeclarationsDefaultsErr.js | 83 + .../jsDeclarationsDefaultsErr.symbols | 40 + .../reference/jsDeclarationsDefaultsErr.types | 43 + .../reference/jsDeclarationsEnumTag.js | 130 ++ .../reference/jsDeclarationsEnumTag.symbols | 104 ++ .../reference/jsDeclarationsEnumTag.types | 126 ++ .../reference/jsDeclarationsEnums.errors.txt | 101 ++ .../reference/jsDeclarationsEnums.js | 167 ++ .../reference/jsDeclarationsEnums.symbols | 134 ++ .../reference/jsDeclarationsEnums.types | 164 ++ ...clarationsExportAssignedClassExpression.js | 31 + ...tionsExportAssignedClassExpression.symbols | 20 + ...rationsExportAssignedClassExpression.types | 25 + ...sExportAssignedClassExpressionAnonymous.js | 31 + ...rtAssignedClassExpressionAnonymous.symbols | 19 + ...portAssignedClassExpressionAnonymous.types | 24 + ...AssignedClassExpressionAnonymousWithSub.js | 49 + ...nedClassExpressionAnonymousWithSub.symbols | 37 + ...ignedClassExpressionAnonymousWithSub.types | 47 + ...sExportAssignedClassExpressionShadowing.js | 86 + ...rtAssignedClassExpressionShadowing.symbols | 37 + ...portAssignedClassExpressionShadowing.types | 44 + .../jsDeclarationsExportAssignedVisibility.js | 47 + ...clarationsExportAssignedVisibility.symbols | 38 + ...DeclarationsExportAssignedVisibility.types | 46 + ...ExportAssignmentExpressionPlusSecondary.js | 40 + ...tAssignmentExpressionPlusSecondary.symbols | 37 + ...ortAssignmentExpressionPlusSecondary.types | 47 + ...arationsExportAssignmentWithKeywordName.js | 30 + ...onsExportAssignmentWithKeywordName.symbols | 23 + ...tionsExportAssignmentWithKeywordName.types | 30 + .../jsDeclarationsExportDefinePropertyEmit.js | 165 ++ ...clarationsExportDefinePropertyEmit.symbols | 228 +++ ...DeclarationsExportDefinePropertyEmit.types | 267 +++ .../reference/jsDeclarationsExportForms.js | 169 ++ .../jsDeclarationsExportForms.symbols | 109 ++ .../reference/jsDeclarationsExportForms.types | 118 ++ .../jsDeclarationsExportFormsErr.errors.txt | 34 + .../reference/jsDeclarationsExportFormsErr.js | 68 + .../jsDeclarationsExportFormsErr.symbols | 28 + .../jsDeclarationsExportFormsErr.types | 33 + .../jsDeclarationsExportSpecifierNonlocal.js | 39 + ...eclarationsExportSpecifierNonlocal.symbols | 13 + ...sDeclarationsExportSpecifierNonlocal.types | 13 + .../jsDeclarationsExportSubAssignments.js | 34 + ...jsDeclarationsExportSubAssignments.symbols | 28 + .../jsDeclarationsExportSubAssignments.types | 33 + ...tionsFunctionClassesCjsExportAssignment.js | 272 +++ ...FunctionClassesCjsExportAssignment.symbols | 115 ++ ...nsFunctionClassesCjsExportAssignment.types | 137 ++ .../reference/jsDeclarationsFunctionJSDoc.js | 107 ++ .../jsDeclarationsFunctionJSDoc.symbols | 50 + .../jsDeclarationsFunctionJSDoc.types | 52 + .../jsDeclarationsFunctionLikeClasses.js | 74 + .../jsDeclarationsFunctionLikeClasses.symbols | 50 + .../jsDeclarationsFunctionLikeClasses.types | 67 + .../jsDeclarationsFunctionLikeClasses2.js | 193 +++ ...jsDeclarationsFunctionLikeClasses2.symbols | 192 +++ .../jsDeclarationsFunctionLikeClasses2.types | 257 +++ .../reference/jsDeclarationsFunctions.js | 177 ++ .../reference/jsDeclarationsFunctions.symbols | 115 ++ .../reference/jsDeclarationsFunctions.types | 128 ++ .../reference/jsDeclarationsFunctionsCjs.js | 161 ++ .../jsDeclarationsFunctionsCjs.symbols | 197 +++ .../jsDeclarationsFunctionsCjs.types | 230 +++ .../jsDeclarationsImportTypeBundled.js | 52 + .../jsDeclarationsImportTypeBundled.symbols | 29 + .../jsDeclarationsImportTypeBundled.types | 36 + .../jsDeclarationsInterfaces.errors.txt | 200 +++ .../reference/jsDeclarationsInterfaces.js | 235 +++ .../jsDeclarationsInterfaces.symbols | 280 ++++ .../reference/jsDeclarationsInterfaces.types | 189 +++ .../baselines/reference/jsDeclarationsJson.js | 66 + .../reference/jsDeclarationsJson.symbols | 33 + .../reference/jsDeclarationsJson.types | 52 + .../jsDeclarationsMultipleExportFromMerge.js | 70 + ...eclarationsMultipleExportFromMerge.symbols | 44 + ...sDeclarationsMultipleExportFromMerge.types | 47 + .../reference/jsDeclarationsPackageJson.js | 135 ++ .../jsDeclarationsPackageJson.symbols | 86 + .../reference/jsDeclarationsPackageJson.types | 114 ++ .../jsDeclarationsReexportAliases.js | 38 + .../jsDeclarationsReexportAliases.symbols | 17 + .../jsDeclarationsReexportAliases.types | 18 + ...larationsReexportAliasesEsModuleInterop.js | 41 + ...ionsReexportAliasesEsModuleInterop.symbols | 23 + ...ationsReexportAliasesEsModuleInterop.types | 25 + ...onsReusesExistingNodesMappingJSDocTypes.js | 66 + ...usesExistingNodesMappingJSDocTypes.symbols | 33 + ...ReusesExistingNodesMappingJSDocTypes.types | 41 + .../reference/jsDeclarationsTypeAliases.js | 141 ++ .../jsDeclarationsTypeAliases.symbols | 69 + .../reference/jsDeclarationsTypeAliases.types | 76 + ...arationsTypeReassignmentFromDeclaration.js | 23 + ...onsTypeReassignmentFromDeclaration.symbols | 25 + ...tionsTypeReassignmentFromDeclaration.types | 24 + ...ypeReassignmentFromDeclaration2.errors.txt | 14 + ...rationsTypeReassignmentFromDeclaration2.js | 15 + ...nsTypeReassignmentFromDeclaration2.symbols | 26 + ...ionsTypeReassignmentFromDeclaration2.types | 26 + .../reference/jsDeclarationsTypeReferences.js | 29 + .../jsDeclarationsTypeReferences.symbols | 30 + .../jsDeclarationsTypeReferences.types | 34 + .../jsDeclarationsTypedefAndImportTypes.js | 95 ++ ...sDeclarationsTypedefAndImportTypes.symbols | 62 + .../jsDeclarationsTypedefAndImportTypes.types | 69 + ...eclarationsTypedefDescriptionsPreserved.js | 64 + ...ationsTypedefDescriptionsPreserved.symbols | 18 + ...arationsTypedefDescriptionsPreserved.types | 18 + ...tionsTypedefPropertyAndExportAssignment.js | 165 ++ ...TypedefPropertyAndExportAssignment.symbols | 89 + ...nsTypedefPropertyAndExportAssignment.types | 101 ++ .../reference/jsEnumCrossFileExport.symbols | 2 + .../reference/jsEnumCrossFileExport.types | 16 +- .../reference/jsEnumTagOnObjectFrozen.symbols | 2 + .../reference/jsEnumTagOnObjectFrozen.types | 12 +- ...DuplicateFunctionImplementation.errors.txt | 2 - ...pilationDuplicateFunctionImplementation.js | 2 + ...ImplementationFileOrderReversed.errors.txt | 2 - ...FunctionImplementationFileOrderReversed.js | 2 + ...ileCompilationDuplicateVariable.errors.txt | 9 - .../jsFileCompilationDuplicateVariable.js | 20 +- ...jsFileCompilationDuplicateVariable.symbols | 2 +- .../jsFileCompilationDuplicateVariable.types | 2 +- ...nDuplicateVariableErrorReported.errors.txt | 4 +- ...mpilationDuplicateVariableErrorReported.js | 5 +- ...tionDuplicateVariableErrorReported.symbols | 2 +- ...lationDuplicateVariableErrorReported.types | 2 +- ...FileCompilationEmitDeclarations.errors.txt | 12 - .../jsFileCompilationEmitDeclarations.js | 1 + ...lationEmitTrippleSlashReference.errors.txt | 16 - ...ileCompilationEmitTrippleSlashReference.js | 2 + ...onsWithJsFileReferenceWithNoOut.errors.txt | 4 +- ...eclarationsWithJsFileReferenceWithNoOut.js | 8 +- ...ationsWithJsFileReferenceWithNoOut.symbols | 2 +- ...arationsWithJsFileReferenceWithNoOut.types | 2 +- ...tionsWithJsFileReferenceWithOut.errors.txt | 17 - ...nDeclarationsWithJsFileReferenceWithOut.js | 4 +- ...arationsWithJsFileReferenceWithOut.symbols | 1 - ...clarationsWithJsFileReferenceWithOut.types | 1 - ...nsWithJsFileReferenceWithOutDir.errors.txt | 17 - ...clarationsWithJsFileReferenceWithOutDir.js | 6 +- ...tionsWithJsFileReferenceWithOutDir.symbols | 1 - ...rationsWithJsFileReferenceWithOutDir.types | 1 - ...eCompilationLetDeclarationOrder.errors.txt | 12 - .../jsFileCompilationLetDeclarationOrder.js | 1 + ...CompilationLetDeclarationOrder2.errors.txt | 2 - .../jsFileCompilationLetDeclarationOrder2.js | 1 + ...ationWithEnabledCompositeOption.errors.txt | 12 - ...leCompilationWithEnabledCompositeOption.js | 1 + .../baselines/reference/jsdocImportType.types | 12 +- .../reference/jsdocImportType2.types | 24 +- ...ntationDuringSyntheticDefaultCheck.symbols | 2 +- .../reference/moduleAugmentationOfAlias.types | 2 +- .../reference/moduleExportAlias2.types | 12 +- .../reference/moduleExportAlias4.types | 22 +- ...oduleExportPropertyAssignmentDefault.types | 26 +- ...xportWithExportPropertyAssignment4.symbols | 16 +- ...eExportWithExportPropertyAssignment4.types | 12 +- .../reference/multiImportExport.types | 14 +- ...namespacesWithTypeAliasOnlyExportsMerge.js | 57 + ...pacesWithTypeAliasOnlyExportsMerge.symbols | 128 ++ ...espacesWithTypeAliasOnlyExportsMerge.types | 106 ++ ...itionOnExportOfPrivateInMergedNamespace.js | 17 + ...OnExportOfPrivateInMergedNamespace.symbols | 16 + ...onOnExportOfPrivateInMergedNamespace.types | 17 + .../amd/test.d.ts | 1 + ...entNamesNotSpecifiedWithAllowJs.errors.txt | 5 +- .../node/test.d.ts | 1 + .../amd/test.d.ts | 1 + ...ferentNamesSpecifiedWithAllowJs.errors.txt | 5 +- .../node/test.d.ts | 1 + ...eNameDtsNotSpecifiedWithAllowJs.errors.txt | 9 +- ...eNameDtsNotSpecifiedWithAllowJs.errors.txt | 9 +- .../reference/reactImportDropped.types | 2 +- ...tTransitiveImportHasValidDeclaration.types | 16 +- .../reference/reexportClassDefinition.types | 8 +- .../reference/requireOfJsonFileTypes.js | 24 + .../requireOfJsonFileWithDeclaration.js | 3 + ...rojects-and-concatenates-them-correctly.js | 254 +++ ...based-projects-and-emits-them-correctly.js | 172 ++ ...ved-json-files-and-emits-them-correctly.js | 228 +++ ...rojects-and-concatenates-them-correctly.js | 342 ++++ ...rojects-and-concatenates-them-correctly.js | 342 ++++ .../typeFromPropertyAssignment17.types | 10 +- .../typeFromPropertyAssignment19.types | 6 +- .../reference/typedefCrossModule2.types | 30 +- .../reference/umd-augmentation-2.symbols | 12 +- .../reference/umd-augmentation-2.types | 24 +- .../reference/umd-augmentation-3.types | 2 +- .../reference/umd-augmentation-4.types | 2 +- tests/baselines/reference/umd9.types | 4 +- ...dWithGlobalAugmentationIsNotCircular.types | 4 +- ...arationFileNoCrashOnExtraExportModifier.ts | 14 + ...tionImportTypeAliasInferredAndEmittable.ts | 19 + .../jsFileCompilationDuplicateVariable.ts | 2 +- ...mpilationDuplicateVariableErrorReported.ts | 2 +- ...eclarationsWithJsFileReferenceWithNoOut.ts | 2 +- ...nDeclarationsWithJsFileReferenceWithOut.ts | 1 - ...clarationsWithJsFileReferenceWithOutDir.ts | 1 - ...namespacesWithTypeAliasOnlyExportsMerge.ts | 44 + ...itionOnExportOfPrivateInMergedNamespace.ts | 6 + .../cases/compiler/requireOfJsonFileTypes.ts | 1 + .../jsDeclarationsClassExtendsVisibility.ts | 17 + .../declarations/jsDeclarationsClasses.ts | 199 +++ .../declarations/jsDeclarationsClassesErr.ts | 76 + .../jsDeclarationsComputedNames.ts | 32 + .../declarations/jsDeclarationsDefault.ts | 42 + .../declarations/jsDeclarationsDefaultsErr.ts | 30 + .../declarations/jsDeclarationsEnumTag.ts | 53 + .../jsdoc/declarations/jsDeclarationsEnums.ts | 68 + ...clarationsExportAssignedClassExpression.ts | 14 + ...sExportAssignedClassExpressionAnonymous.ts | 14 + ...AssignedClassExpressionAnonymousWithSub.ts | 19 + ...sExportAssignedClassExpressionShadowing.ts | 19 + .../jsDeclarationsExportAssignedVisibility.ts | 21 + ...ExportAssignmentExpressionPlusSecondary.ts | 18 + ...arationsExportAssignmentWithKeywordName.ts | 14 + .../jsDeclarationsExportDefinePropertyEmit.ts | 63 + .../declarations/jsDeclarationsExportForms.ts | 61 + .../jsDeclarationsExportFormsErr.ts | 24 + .../jsDeclarationsExportSpecifierNonlocal.ts | 10 + .../jsDeclarationsExportSubAssignments.ts | 13 + ...tionsFunctionClassesCjsExportAssignment.ts | 74 + .../jsDeclarationsFunctionJSDoc.ts | 40 + .../jsDeclarationsFunctionLikeClasses.ts | 29 + .../jsDeclarationsFunctionLikeClasses2.ts | 81 + .../declarations/jsDeclarationsFunctions.ts | 62 + .../jsDeclarationsFunctionsCjs.ts | 63 + .../jsDeclarationsImportTypeBundled.ts | 19 + .../declarations/jsDeclarationsInterfaces.ts | 125 ++ .../jsdoc/declarations/jsDeclarationsJson.ts | 17 + .../jsDeclarationsMultipleExportFromMerge.ts | 23 + .../declarations/jsDeclarationsPackageJson.ts | 42 + .../jsDeclarationsReexportAliases.ts | 14 + ...larationsReexportAliasesEsModuleInterop.ts | 16 + ...onsReusesExistingNodesMappingJSDocTypes.ts | 30 + .../declarations/jsDeclarationsTypeAliases.ts | 54 + ...arationsTypeReassignmentFromDeclaration.ts | 16 + ...rationsTypeReassignmentFromDeclaration2.ts | 15 + .../jsDeclarationsTypeReferences.ts | 19 + .../jsDeclarationsTypedefAndImportTypes.ts | 38 + ...eclarationsTypedefDescriptionsPreserved.ts | 21 + ...tionsTypedefPropertyAndExportAssignment.ts | 59 + ...pilationDuplicateFunctionImplementation.ts | 2 +- 304 files changed, 17584 insertions(+), 474 deletions(-) create mode 100644 src/testRunner/unittests/tsbuild/javascriptProjectEmit.ts create mode 100644 tests/baselines/reference/declarationFileNoCrashOnExtraExportModifier.errors.txt create mode 100644 tests/baselines/reference/declarationFileNoCrashOnExtraExportModifier.js create mode 100644 tests/baselines/reference/declarationFileNoCrashOnExtraExportModifier.symbols create mode 100644 tests/baselines/reference/declarationFileNoCrashOnExtraExportModifier.types create mode 100644 tests/baselines/reference/declarationImportTypeAliasInferredAndEmittable.js create mode 100644 tests/baselines/reference/declarationImportTypeAliasInferredAndEmittable.symbols create mode 100644 tests/baselines/reference/declarationImportTypeAliasInferredAndEmittable.types create mode 100644 tests/baselines/reference/jsDeclarationsClassExtendsVisibility.js create mode 100644 tests/baselines/reference/jsDeclarationsClassExtendsVisibility.symbols create mode 100644 tests/baselines/reference/jsDeclarationsClassExtendsVisibility.types create mode 100644 tests/baselines/reference/jsDeclarationsClasses.js create mode 100644 tests/baselines/reference/jsDeclarationsClasses.symbols create mode 100644 tests/baselines/reference/jsDeclarationsClasses.types create mode 100644 tests/baselines/reference/jsDeclarationsClassesErr.errors.txt create mode 100644 tests/baselines/reference/jsDeclarationsClassesErr.js create mode 100644 tests/baselines/reference/jsDeclarationsClassesErr.symbols create mode 100644 tests/baselines/reference/jsDeclarationsClassesErr.types create mode 100644 tests/baselines/reference/jsDeclarationsComputedNames.js create mode 100644 tests/baselines/reference/jsDeclarationsComputedNames.symbols create mode 100644 tests/baselines/reference/jsDeclarationsComputedNames.types create mode 100644 tests/baselines/reference/jsDeclarationsDefault.js create mode 100644 tests/baselines/reference/jsDeclarationsDefault.symbols create mode 100644 tests/baselines/reference/jsDeclarationsDefault.types create mode 100644 tests/baselines/reference/jsDeclarationsDefaultsErr.errors.txt create mode 100644 tests/baselines/reference/jsDeclarationsDefaultsErr.js create mode 100644 tests/baselines/reference/jsDeclarationsDefaultsErr.symbols create mode 100644 tests/baselines/reference/jsDeclarationsDefaultsErr.types create mode 100644 tests/baselines/reference/jsDeclarationsEnumTag.js create mode 100644 tests/baselines/reference/jsDeclarationsEnumTag.symbols create mode 100644 tests/baselines/reference/jsDeclarationsEnumTag.types create mode 100644 tests/baselines/reference/jsDeclarationsEnums.errors.txt create mode 100644 tests/baselines/reference/jsDeclarationsEnums.js create mode 100644 tests/baselines/reference/jsDeclarationsEnums.symbols create mode 100644 tests/baselines/reference/jsDeclarationsEnums.types create mode 100644 tests/baselines/reference/jsDeclarationsExportAssignedClassExpression.js create mode 100644 tests/baselines/reference/jsDeclarationsExportAssignedClassExpression.symbols create mode 100644 tests/baselines/reference/jsDeclarationsExportAssignedClassExpression.types create mode 100644 tests/baselines/reference/jsDeclarationsExportAssignedClassExpressionAnonymous.js create mode 100644 tests/baselines/reference/jsDeclarationsExportAssignedClassExpressionAnonymous.symbols create mode 100644 tests/baselines/reference/jsDeclarationsExportAssignedClassExpressionAnonymous.types create mode 100644 tests/baselines/reference/jsDeclarationsExportAssignedClassExpressionAnonymousWithSub.js create mode 100644 tests/baselines/reference/jsDeclarationsExportAssignedClassExpressionAnonymousWithSub.symbols create mode 100644 tests/baselines/reference/jsDeclarationsExportAssignedClassExpressionAnonymousWithSub.types create mode 100644 tests/baselines/reference/jsDeclarationsExportAssignedClassExpressionShadowing.js create mode 100644 tests/baselines/reference/jsDeclarationsExportAssignedClassExpressionShadowing.symbols create mode 100644 tests/baselines/reference/jsDeclarationsExportAssignedClassExpressionShadowing.types create mode 100644 tests/baselines/reference/jsDeclarationsExportAssignedVisibility.js create mode 100644 tests/baselines/reference/jsDeclarationsExportAssignedVisibility.symbols create mode 100644 tests/baselines/reference/jsDeclarationsExportAssignedVisibility.types create mode 100644 tests/baselines/reference/jsDeclarationsExportAssignmentExpressionPlusSecondary.js create mode 100644 tests/baselines/reference/jsDeclarationsExportAssignmentExpressionPlusSecondary.symbols create mode 100644 tests/baselines/reference/jsDeclarationsExportAssignmentExpressionPlusSecondary.types create mode 100644 tests/baselines/reference/jsDeclarationsExportAssignmentWithKeywordName.js create mode 100644 tests/baselines/reference/jsDeclarationsExportAssignmentWithKeywordName.symbols create mode 100644 tests/baselines/reference/jsDeclarationsExportAssignmentWithKeywordName.types create mode 100644 tests/baselines/reference/jsDeclarationsExportDefinePropertyEmit.js create mode 100644 tests/baselines/reference/jsDeclarationsExportDefinePropertyEmit.symbols create mode 100644 tests/baselines/reference/jsDeclarationsExportDefinePropertyEmit.types create mode 100644 tests/baselines/reference/jsDeclarationsExportForms.js create mode 100644 tests/baselines/reference/jsDeclarationsExportForms.symbols create mode 100644 tests/baselines/reference/jsDeclarationsExportForms.types create mode 100644 tests/baselines/reference/jsDeclarationsExportFormsErr.errors.txt create mode 100644 tests/baselines/reference/jsDeclarationsExportFormsErr.js create mode 100644 tests/baselines/reference/jsDeclarationsExportFormsErr.symbols create mode 100644 tests/baselines/reference/jsDeclarationsExportFormsErr.types create mode 100644 tests/baselines/reference/jsDeclarationsExportSpecifierNonlocal.js create mode 100644 tests/baselines/reference/jsDeclarationsExportSpecifierNonlocal.symbols create mode 100644 tests/baselines/reference/jsDeclarationsExportSpecifierNonlocal.types create mode 100644 tests/baselines/reference/jsDeclarationsExportSubAssignments.js create mode 100644 tests/baselines/reference/jsDeclarationsExportSubAssignments.symbols create mode 100644 tests/baselines/reference/jsDeclarationsExportSubAssignments.types create mode 100644 tests/baselines/reference/jsDeclarationsFunctionClassesCjsExportAssignment.js create mode 100644 tests/baselines/reference/jsDeclarationsFunctionClassesCjsExportAssignment.symbols create mode 100644 tests/baselines/reference/jsDeclarationsFunctionClassesCjsExportAssignment.types create mode 100644 tests/baselines/reference/jsDeclarationsFunctionJSDoc.js create mode 100644 tests/baselines/reference/jsDeclarationsFunctionJSDoc.symbols create mode 100644 tests/baselines/reference/jsDeclarationsFunctionJSDoc.types create mode 100644 tests/baselines/reference/jsDeclarationsFunctionLikeClasses.js create mode 100644 tests/baselines/reference/jsDeclarationsFunctionLikeClasses.symbols create mode 100644 tests/baselines/reference/jsDeclarationsFunctionLikeClasses.types create mode 100644 tests/baselines/reference/jsDeclarationsFunctionLikeClasses2.js create mode 100644 tests/baselines/reference/jsDeclarationsFunctionLikeClasses2.symbols create mode 100644 tests/baselines/reference/jsDeclarationsFunctionLikeClasses2.types create mode 100644 tests/baselines/reference/jsDeclarationsFunctions.js create mode 100644 tests/baselines/reference/jsDeclarationsFunctions.symbols create mode 100644 tests/baselines/reference/jsDeclarationsFunctions.types create mode 100644 tests/baselines/reference/jsDeclarationsFunctionsCjs.js create mode 100644 tests/baselines/reference/jsDeclarationsFunctionsCjs.symbols create mode 100644 tests/baselines/reference/jsDeclarationsFunctionsCjs.types create mode 100644 tests/baselines/reference/jsDeclarationsImportTypeBundled.js create mode 100644 tests/baselines/reference/jsDeclarationsImportTypeBundled.symbols create mode 100644 tests/baselines/reference/jsDeclarationsImportTypeBundled.types create mode 100644 tests/baselines/reference/jsDeclarationsInterfaces.errors.txt create mode 100644 tests/baselines/reference/jsDeclarationsInterfaces.js create mode 100644 tests/baselines/reference/jsDeclarationsInterfaces.symbols create mode 100644 tests/baselines/reference/jsDeclarationsInterfaces.types create mode 100644 tests/baselines/reference/jsDeclarationsJson.js create mode 100644 tests/baselines/reference/jsDeclarationsJson.symbols create mode 100644 tests/baselines/reference/jsDeclarationsJson.types create mode 100644 tests/baselines/reference/jsDeclarationsMultipleExportFromMerge.js create mode 100644 tests/baselines/reference/jsDeclarationsMultipleExportFromMerge.symbols create mode 100644 tests/baselines/reference/jsDeclarationsMultipleExportFromMerge.types create mode 100644 tests/baselines/reference/jsDeclarationsPackageJson.js create mode 100644 tests/baselines/reference/jsDeclarationsPackageJson.symbols create mode 100644 tests/baselines/reference/jsDeclarationsPackageJson.types create mode 100644 tests/baselines/reference/jsDeclarationsReexportAliases.js create mode 100644 tests/baselines/reference/jsDeclarationsReexportAliases.symbols create mode 100644 tests/baselines/reference/jsDeclarationsReexportAliases.types create mode 100644 tests/baselines/reference/jsDeclarationsReexportAliasesEsModuleInterop.js create mode 100644 tests/baselines/reference/jsDeclarationsReexportAliasesEsModuleInterop.symbols create mode 100644 tests/baselines/reference/jsDeclarationsReexportAliasesEsModuleInterop.types create mode 100644 tests/baselines/reference/jsDeclarationsReusesExistingNodesMappingJSDocTypes.js create mode 100644 tests/baselines/reference/jsDeclarationsReusesExistingNodesMappingJSDocTypes.symbols create mode 100644 tests/baselines/reference/jsDeclarationsReusesExistingNodesMappingJSDocTypes.types create mode 100644 tests/baselines/reference/jsDeclarationsTypeAliases.js create mode 100644 tests/baselines/reference/jsDeclarationsTypeAliases.symbols create mode 100644 tests/baselines/reference/jsDeclarationsTypeAliases.types create mode 100644 tests/baselines/reference/jsDeclarationsTypeReassignmentFromDeclaration.js create mode 100644 tests/baselines/reference/jsDeclarationsTypeReassignmentFromDeclaration.symbols create mode 100644 tests/baselines/reference/jsDeclarationsTypeReassignmentFromDeclaration.types create mode 100644 tests/baselines/reference/jsDeclarationsTypeReassignmentFromDeclaration2.errors.txt create mode 100644 tests/baselines/reference/jsDeclarationsTypeReassignmentFromDeclaration2.js create mode 100644 tests/baselines/reference/jsDeclarationsTypeReassignmentFromDeclaration2.symbols create mode 100644 tests/baselines/reference/jsDeclarationsTypeReassignmentFromDeclaration2.types create mode 100644 tests/baselines/reference/jsDeclarationsTypeReferences.js create mode 100644 tests/baselines/reference/jsDeclarationsTypeReferences.symbols create mode 100644 tests/baselines/reference/jsDeclarationsTypeReferences.types create mode 100644 tests/baselines/reference/jsDeclarationsTypedefAndImportTypes.js create mode 100644 tests/baselines/reference/jsDeclarationsTypedefAndImportTypes.symbols create mode 100644 tests/baselines/reference/jsDeclarationsTypedefAndImportTypes.types create mode 100644 tests/baselines/reference/jsDeclarationsTypedefDescriptionsPreserved.js create mode 100644 tests/baselines/reference/jsDeclarationsTypedefDescriptionsPreserved.symbols create mode 100644 tests/baselines/reference/jsDeclarationsTypedefDescriptionsPreserved.types create mode 100644 tests/baselines/reference/jsDeclarationsTypedefPropertyAndExportAssignment.js create mode 100644 tests/baselines/reference/jsDeclarationsTypedefPropertyAndExportAssignment.symbols create mode 100644 tests/baselines/reference/jsDeclarationsTypedefPropertyAndExportAssignment.types delete mode 100644 tests/baselines/reference/jsFileCompilationDuplicateVariable.errors.txt delete mode 100644 tests/baselines/reference/jsFileCompilationEmitDeclarations.errors.txt delete mode 100644 tests/baselines/reference/jsFileCompilationEmitTrippleSlashReference.errors.txt delete mode 100644 tests/baselines/reference/jsFileCompilationErrorOnDeclarationsWithJsFileReferenceWithOut.errors.txt delete mode 100644 tests/baselines/reference/jsFileCompilationErrorOnDeclarationsWithJsFileReferenceWithOutDir.errors.txt delete mode 100644 tests/baselines/reference/jsFileCompilationLetDeclarationOrder.errors.txt delete mode 100644 tests/baselines/reference/jsFileCompilationWithEnabledCompositeOption.errors.txt create mode 100644 tests/baselines/reference/namespacesWithTypeAliasOnlyExportsMerge.js create mode 100644 tests/baselines/reference/namespacesWithTypeAliasOnlyExportsMerge.symbols create mode 100644 tests/baselines/reference/namespacesWithTypeAliasOnlyExportsMerge.types create mode 100644 tests/baselines/reference/noCircularDefinitionOnExportOfPrivateInMergedNamespace.js create mode 100644 tests/baselines/reference/noCircularDefinitionOnExportOfPrivateInMergedNamespace.symbols create mode 100644 tests/baselines/reference/noCircularDefinitionOnExportOfPrivateInMergedNamespace.types create mode 100644 tests/baselines/reference/tsbuild/javascriptProjectEmit/incremental-declaration-doesnt-change/modifies-outfile-js-projects-and-concatenates-them-correctly.js create mode 100644 tests/baselines/reference/tsbuild/javascriptProjectEmit/initial-build/loads-js-based-projects-and-emits-them-correctly.js create mode 100644 tests/baselines/reference/tsbuild/javascriptProjectEmit/initial-build/loads-js-based-projects-with-non-moved-json-files-and-emits-them-correctly.js create mode 100644 tests/baselines/reference/tsbuild/javascriptProjectEmit/initial-build/loads-outfile-js-projects-and-concatenates-them-correctly.js create mode 100644 tests/baselines/reference/tsbuild/javascriptProjectEmit/initial-build/modifies-outfile-js-projects-and-concatenates-them-correctly.js create mode 100644 tests/cases/compiler/declarationFileNoCrashOnExtraExportModifier.ts create mode 100644 tests/cases/compiler/declarationImportTypeAliasInferredAndEmittable.ts create mode 100644 tests/cases/compiler/namespacesWithTypeAliasOnlyExportsMerge.ts create mode 100644 tests/cases/compiler/noCircularDefinitionOnExportOfPrivateInMergedNamespace.ts create mode 100644 tests/cases/conformance/jsdoc/declarations/jsDeclarationsClassExtendsVisibility.ts create mode 100644 tests/cases/conformance/jsdoc/declarations/jsDeclarationsClasses.ts create mode 100644 tests/cases/conformance/jsdoc/declarations/jsDeclarationsClassesErr.ts create mode 100644 tests/cases/conformance/jsdoc/declarations/jsDeclarationsComputedNames.ts create mode 100644 tests/cases/conformance/jsdoc/declarations/jsDeclarationsDefault.ts create mode 100644 tests/cases/conformance/jsdoc/declarations/jsDeclarationsDefaultsErr.ts create mode 100644 tests/cases/conformance/jsdoc/declarations/jsDeclarationsEnumTag.ts create mode 100644 tests/cases/conformance/jsdoc/declarations/jsDeclarationsEnums.ts create mode 100644 tests/cases/conformance/jsdoc/declarations/jsDeclarationsExportAssignedClassExpression.ts create mode 100644 tests/cases/conformance/jsdoc/declarations/jsDeclarationsExportAssignedClassExpressionAnonymous.ts create mode 100644 tests/cases/conformance/jsdoc/declarations/jsDeclarationsExportAssignedClassExpressionAnonymousWithSub.ts create mode 100644 tests/cases/conformance/jsdoc/declarations/jsDeclarationsExportAssignedClassExpressionShadowing.ts create mode 100644 tests/cases/conformance/jsdoc/declarations/jsDeclarationsExportAssignedVisibility.ts create mode 100644 tests/cases/conformance/jsdoc/declarations/jsDeclarationsExportAssignmentExpressionPlusSecondary.ts create mode 100644 tests/cases/conformance/jsdoc/declarations/jsDeclarationsExportAssignmentWithKeywordName.ts create mode 100644 tests/cases/conformance/jsdoc/declarations/jsDeclarationsExportDefinePropertyEmit.ts create mode 100644 tests/cases/conformance/jsdoc/declarations/jsDeclarationsExportForms.ts create mode 100644 tests/cases/conformance/jsdoc/declarations/jsDeclarationsExportFormsErr.ts create mode 100644 tests/cases/conformance/jsdoc/declarations/jsDeclarationsExportSpecifierNonlocal.ts create mode 100644 tests/cases/conformance/jsdoc/declarations/jsDeclarationsExportSubAssignments.ts create mode 100644 tests/cases/conformance/jsdoc/declarations/jsDeclarationsFunctionClassesCjsExportAssignment.ts create mode 100644 tests/cases/conformance/jsdoc/declarations/jsDeclarationsFunctionJSDoc.ts create mode 100644 tests/cases/conformance/jsdoc/declarations/jsDeclarationsFunctionLikeClasses.ts create mode 100644 tests/cases/conformance/jsdoc/declarations/jsDeclarationsFunctionLikeClasses2.ts create mode 100644 tests/cases/conformance/jsdoc/declarations/jsDeclarationsFunctions.ts create mode 100644 tests/cases/conformance/jsdoc/declarations/jsDeclarationsFunctionsCjs.ts create mode 100644 tests/cases/conformance/jsdoc/declarations/jsDeclarationsImportTypeBundled.ts create mode 100644 tests/cases/conformance/jsdoc/declarations/jsDeclarationsInterfaces.ts create mode 100644 tests/cases/conformance/jsdoc/declarations/jsDeclarationsJson.ts create mode 100644 tests/cases/conformance/jsdoc/declarations/jsDeclarationsMultipleExportFromMerge.ts create mode 100644 tests/cases/conformance/jsdoc/declarations/jsDeclarationsPackageJson.ts create mode 100644 tests/cases/conformance/jsdoc/declarations/jsDeclarationsReexportAliases.ts create mode 100644 tests/cases/conformance/jsdoc/declarations/jsDeclarationsReexportAliasesEsModuleInterop.ts create mode 100644 tests/cases/conformance/jsdoc/declarations/jsDeclarationsReusesExistingNodesMappingJSDocTypes.ts create mode 100644 tests/cases/conformance/jsdoc/declarations/jsDeclarationsTypeAliases.ts create mode 100644 tests/cases/conformance/jsdoc/declarations/jsDeclarationsTypeReassignmentFromDeclaration.ts create mode 100644 tests/cases/conformance/jsdoc/declarations/jsDeclarationsTypeReassignmentFromDeclaration2.ts create mode 100644 tests/cases/conformance/jsdoc/declarations/jsDeclarationsTypeReferences.ts create mode 100644 tests/cases/conformance/jsdoc/declarations/jsDeclarationsTypedefAndImportTypes.ts create mode 100644 tests/cases/conformance/jsdoc/declarations/jsDeclarationsTypedefDescriptionsPreserved.ts create mode 100644 tests/cases/conformance/jsdoc/declarations/jsDeclarationsTypedefPropertyAndExportAssignment.ts diff --git a/src/compiler/binder.ts b/src/compiler/binder.ts index 1d6627987e151..b5a0619430788 100644 --- a/src/compiler/binder.ts +++ b/src/compiler/binder.ts @@ -13,11 +13,26 @@ namespace ts { referenced: boolean; } - export function getModuleInstanceState(node: ModuleDeclaration): ModuleInstanceState { - return node.body ? getModuleInstanceStateWorker(node.body) : ModuleInstanceState.Instantiated; + export function getModuleInstanceState(node: ModuleDeclaration, visited?: Map): ModuleInstanceState { + if (node.body && !node.body.parent) { + // getModuleInstanceStateForAliasTarget needs to walk up the parent chain, so parent pointers must be set on this tree already + setParentPointers(node, node.body); + } + return node.body ? getModuleInstanceStateCached(node.body, visited) : ModuleInstanceState.Instantiated; } - function getModuleInstanceStateWorker(node: Node): ModuleInstanceState { + function getModuleInstanceStateCached(node: Node, visited = createMap()) { + const nodeId = "" + getNodeId(node); + if (visited.has(nodeId)) { + return visited.get(nodeId) || ModuleInstanceState.NonInstantiated; + } + visited.set(nodeId, undefined); + const result = getModuleInstanceStateWorker(node, visited); + visited.set(nodeId, result); + return result; + } + + function getModuleInstanceStateWorker(node: Node, visited: Map): ModuleInstanceState { // A module is uninstantiated if it contains only switch (node.kind) { // 1. interface declarations, type alias declarations @@ -37,11 +52,27 @@ namespace ts { return ModuleInstanceState.NonInstantiated; } break; - // 4. other uninstantiated module declarations. + // 4. Export alias declarations pointing at only uninstantiated modules or things uninstantiated modules contain + case SyntaxKind.ExportDeclaration: + if (!(node as ExportDeclaration).moduleSpecifier && !!(node as ExportDeclaration).exportClause) { + let state = ModuleInstanceState.NonInstantiated; + for (const specifier of (node as ExportDeclaration).exportClause!.elements) { + const specifierState = getModuleInstanceStateForAliasTarget(specifier, visited); + if (specifierState > state) { + state = specifierState; + } + if (state === ModuleInstanceState.Instantiated) { + return state; + } + } + return state; + } + break; + // 5. other uninstantiated module declarations. case SyntaxKind.ModuleBlock: { let state = ModuleInstanceState.NonInstantiated; forEachChild(node, n => { - const childState = getModuleInstanceStateWorker(n); + const childState = getModuleInstanceStateCached(n, visited); switch (childState) { case ModuleInstanceState.NonInstantiated: // child is non-instantiated - continue searching @@ -61,7 +92,7 @@ namespace ts { return state; } case SyntaxKind.ModuleDeclaration: - return getModuleInstanceState(node as ModuleDeclaration); + return getModuleInstanceState(node as ModuleDeclaration, visited); case SyntaxKind.Identifier: // Only jsdoc typedef definition can exist in jsdoc namespace, and it should // be considered the same as type alias @@ -72,6 +103,36 @@ namespace ts { return ModuleInstanceState.Instantiated; } + function getModuleInstanceStateForAliasTarget(specifier: ExportSpecifier, visited: Map) { + const name = specifier.propertyName || specifier.name; + let p: Node | undefined = specifier.parent; + while (p) { + if (isBlock(p) || isModuleBlock(p) || isSourceFile(p)) { + const statements = p.statements; + let found: ModuleInstanceState | undefined; + for (const statement of statements) { + if (nodeHasName(statement, name)) { + if (!statement.parent) { + setParentPointers(p, statement); + } + const state = getModuleInstanceStateCached(statement, visited); + if (found === undefined || state > found) { + found = state; + } + if (found === ModuleInstanceState.Instantiated) { + return found; + } + } + } + if (found !== undefined) { + return found; + } + } + p = p.parent; + } + return ModuleInstanceState.Instantiated; // Couldn't locate, assume could refer to a value + } + const enum ContainerFlags { // The current node is not a container, and no container manipulation should happen before // recursing into it. @@ -2561,7 +2622,7 @@ namespace ts { // Declare a 'member' if the container is an ES5 class or ES6 constructor constructorSymbol.members = constructorSymbol.members || createSymbolTable(); // It's acceptable for multiple 'this' assignments of the same identifier to occur - declareSymbol(constructorSymbol.members, constructorSymbol, node, SymbolFlags.Property, SymbolFlags.PropertyExcludes & ~SymbolFlags.Property); + declareSymbol(constructorSymbol.members, constructorSymbol, node, SymbolFlags.Property | SymbolFlags.Assignment, SymbolFlags.PropertyExcludes & ~SymbolFlags.Property); addDeclarationToSymbol(constructorSymbol, constructorSymbol.valueDeclaration, SymbolFlags.Class); } break; @@ -2575,7 +2636,7 @@ namespace ts { // Bind this property to the containing class const containingClass = thisContainer.parent; const symbolTable = hasModifier(thisContainer, ModifierFlags.Static) ? containingClass.symbol.exports! : containingClass.symbol.members!; - declareSymbol(symbolTable, containingClass.symbol, node, SymbolFlags.Property, SymbolFlags.None, /*isReplaceableByMethod*/ true); + declareSymbol(symbolTable, containingClass.symbol, node, SymbolFlags.Property | SymbolFlags.Assignment, SymbolFlags.None, /*isReplaceableByMethod*/ true); break; case SyntaxKind.SourceFile: // this.property = assignment in a source file -- declare symbol in exports for a module, in locals for a script diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index f180f9e544b6a..e245ca8aa2622 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -1030,7 +1030,11 @@ namespace ts { function mergeSymbol(target: Symbol, source: Symbol, unidirectional = false): Symbol { if (!(target.flags & getExcludedSymbolFlags(source.flags)) || (source.flags | target.flags) & SymbolFlags.Assignment) { - Debug.assert(source !== target); + if (source === target) { + // This can happen when an export assigned namespace exports something also erroneously exported at the top level + // See `declarationFileNoCrashOnExtraExportModifier` for an example + return target; + } if (!(target.flags & SymbolFlags.Transient)) { const resolvedTarget = resolveSymbol(target); if (resolvedTarget === unknownSymbol) { @@ -1520,8 +1524,8 @@ namespace ts { isInExternalModule = true; // falls through case SyntaxKind.ModuleDeclaration: - const moduleExports = getSymbolOfNode(location as SourceFile | ModuleDeclaration).exports!; - if (location.kind === SyntaxKind.SourceFile || isAmbientModule(location)) { + const moduleExports = getSymbolOfNode(location as SourceFile | ModuleDeclaration).exports || emptySymbols; + if (location.kind === SyntaxKind.SourceFile || (isModuleDeclaration(location) && location.flags & NodeFlags.Ambient && !isGlobalScopeAugmentation(location))) { // It's an external module. First see if the module has an export default and if the local // name of that export default matches. @@ -2203,7 +2207,7 @@ namespace ts { function getTargetOfNamespaceImport(node: NamespaceImport, dontResolveAlias: boolean): Symbol | undefined { const moduleSpecifier = node.parent.parent.moduleSpecifier; - return resolveESModuleSymbol(resolveExternalModuleName(node, moduleSpecifier), moduleSpecifier, dontResolveAlias); + return resolveESModuleSymbol(resolveExternalModuleName(node, moduleSpecifier), moduleSpecifier, dontResolveAlias, /*suppressUsageError*/ false); } // This function creates a synthetic symbol that combines the value side of one symbol with the @@ -2257,9 +2261,10 @@ namespace ts { function getExternalModuleMember(node: ImportDeclaration | ExportDeclaration, specifier: ImportOrExportSpecifier, dontResolveAlias = false): Symbol | undefined { const moduleSymbol = resolveExternalModuleName(node, node.moduleSpecifier!)!; // TODO: GH#18217 - const targetSymbol = resolveESModuleSymbol(moduleSymbol, node.moduleSpecifier!, dontResolveAlias); + const name = specifier.propertyName || specifier.name; + const suppressInteropError = name.escapedText === InternalSymbolName.Default && !!(compilerOptions.allowSyntheticDefaultImports || compilerOptions.esModuleInterop); + const targetSymbol = resolveESModuleSymbol(moduleSymbol, node.moduleSpecifier!, dontResolveAlias, suppressInteropError); if (targetSymbol) { - const name = specifier.propertyName || specifier.name; if (name.escapedText) { if (isShorthandAmbientModuleSymbol(moduleSymbol)) { return moduleSymbol; @@ -2321,17 +2326,37 @@ namespace ts { function getTargetOfExportAssignment(node: ExportAssignment | BinaryExpression, dontResolveAlias: boolean): Symbol | undefined { const expression = (isExportAssignment(node) ? node.expression : node.right) as EntityNameExpression | ClassExpression; + return getTargetOfAliasLikeExpression(expression, dontResolveAlias); + } + + function getTargetOfAliasLikeExpression(expression: Expression, dontResolveAlias: boolean) { if (isClassExpression(expression)) { - return checkExpression(expression).symbol; + return checkExpressionCached(expression).symbol; + } + if (!isEntityName(expression) && !isEntityNameExpression(expression)) { + return undefined; } const aliasLike = resolveEntityName(expression, SymbolFlags.Value | SymbolFlags.Type | SymbolFlags.Namespace, /*ignoreErrors*/ true, dontResolveAlias); if (aliasLike) { return aliasLike; } - checkExpression(expression); + checkExpressionCached(expression); return getNodeLinks(expression).resolvedSymbol; } + function getTargetOfPropertyAssignment(node: PropertyAssignment, dontRecursivelyResolve: boolean): Symbol | undefined { + const expression = node.initializer; + return getTargetOfAliasLikeExpression(expression, dontRecursivelyResolve); + } + + function getTargetOfPropertyAccessExpression(node: PropertyAccessExpression, dontRecursivelyResolve: boolean): Symbol | undefined { + if (!(isBinaryExpression(node.parent) && node.parent.left === node && node.parent.operatorToken.kind === SyntaxKind.EqualsToken)) { + return undefined; + } + + return getTargetOfAliasLikeExpression(node.parent.right, dontRecursivelyResolve); + } + function getTargetOfAliasDeclaration(node: Declaration, dontRecursivelyResolve = false): Symbol | undefined { switch (node.kind) { case SyntaxKind.ImportEqualsDeclaration: @@ -2349,6 +2374,12 @@ namespace ts { return getTargetOfExportAssignment((node), dontRecursivelyResolve); case SyntaxKind.NamespaceExportDeclaration: return getTargetOfNamespaceExportDeclaration(node, dontRecursivelyResolve); + case SyntaxKind.ShorthandPropertyAssignment: + return resolveEntityName((node as ShorthandPropertyAssignment).name, SymbolFlags.Value | SymbolFlags.Type | SymbolFlags.Namespace, /*ignoreErrors*/ true, dontRecursivelyResolve); + case SyntaxKind.PropertyAssignment: + return getTargetOfPropertyAssignment(node as PropertyAssignment, dontRecursivelyResolve); + case SyntaxKind.PropertyAccessExpression: + return getTargetOfPropertyAccessExpression(node as PropertyAccessExpression, dontRecursivelyResolve); default: return Debug.fail(); } @@ -2712,7 +2743,7 @@ namespace ts { function resolveExternalModuleSymbol(moduleSymbol: Symbol, dontResolveAlias?: boolean): Symbol { if (moduleSymbol) { const exportEquals = resolveSymbol(moduleSymbol.exports!.get(InternalSymbolName.ExportEquals), dontResolveAlias); - const exported = getCommonJsExportEquals(exportEquals, moduleSymbol); + const exported = getCommonJsExportEquals(getMergedSymbol(exportEquals), getMergedSymbol(moduleSymbol)); return getMergedSymbol(exported) || moduleSymbol; } return undefined!; @@ -2722,26 +2753,31 @@ namespace ts { if (!exported || exported === unknownSymbol || exported === moduleSymbol || moduleSymbol.exports!.size === 1 || exported.flags & SymbolFlags.Alias) { return exported; } - const merged = cloneSymbol(exported); + const links = getSymbolLinks(exported); + if (links.cjsExportMerged) { + return links.cjsExportMerged; + } + const merged = exported.flags & SymbolFlags.Transient ? exported : cloneSymbol(exported); + merged.flags = merged.flags | SymbolFlags.ValueModule; if (merged.exports === undefined) { - merged.flags = merged.flags | SymbolFlags.ValueModule; merged.exports = createSymbolTable(); } moduleSymbol.exports!.forEach((s, name) => { if (name === InternalSymbolName.ExportEquals) return; merged.exports!.set(name, merged.exports!.has(name) ? mergeSymbol(merged.exports!.get(name)!, s) : s); }); - return merged; + getSymbolLinks(merged).cjsExportMerged = merged; + return links.cjsExportMerged = merged; } // 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 // combine other declarations with the module or variable (e.g. a class/module, function/module, interface/variable). - function resolveESModuleSymbol(moduleSymbol: Symbol | undefined, referencingLocation: Node, dontResolveAlias: boolean): Symbol | undefined { + function resolveESModuleSymbol(moduleSymbol: Symbol | undefined, referencingLocation: Node, dontResolveAlias: boolean, suppressInteropError: boolean): Symbol | undefined { const symbol = resolveExternalModuleSymbol(moduleSymbol, dontResolveAlias); if (!dontResolveAlias && symbol) { - if (!(symbol.flags & (SymbolFlags.Module | SymbolFlags.Variable)) && !getDeclarationOfKind(symbol, SyntaxKind.SourceFile)) { + if (!suppressInteropError && !(symbol.flags & (SymbolFlags.Module | SymbolFlags.Variable)) && !getDeclarationOfKind(symbol, SyntaxKind.SourceFile)) { const compilerOptionName = moduleKind >= ModuleKind.ES2015 ? "allowSyntheticDefaultImports" : "esModuleInterop"; @@ -2982,7 +3018,8 @@ namespace ts { */ function getContainersOfSymbol(symbol: Symbol, enclosingDeclaration: Node | undefined): Symbol[] | undefined { const container = getParentOfSymbol(symbol); - if (container) { + // Type parameters end up in the `members` lists but are not externally visible + if (container && !(symbol.flags & SymbolFlags.TypeParameter)) { const additionalContainers = mapDefined(container.declarations, fileSymbolIfFileSymbolExportEqualsContainer); const reexportContainers = enclosingDeclaration && getAlternativeContainingModules(symbol, enclosingDeclaration); if (enclosingDeclaration && getAccessibleSymbolChain(container, enclosingDeclaration, SymbolFlags.Namespace, /*externalOnly*/ false)) { @@ -2991,7 +3028,18 @@ namespace ts { const res = append(additionalContainers, container); return concatenate(res, reexportContainers); } - const candidates = mapDefined(symbol.declarations, d => !isAmbientModule(d) && d.parent && hasNonGlobalAugmentationExternalModuleSymbol(d.parent) ? getSymbolOfNode(d.parent) : undefined); + const candidates = mapDefined(symbol.declarations, d => { + if (!isAmbientModule(d) && d.parent && hasNonGlobalAugmentationExternalModuleSymbol(d.parent)) { + return getSymbolOfNode(d.parent); + } + if (isClassExpression(d) && isBinaryExpression(d.parent) && d.parent.operatorToken.kind === SyntaxKind.EqualsToken && isAccessExpression(d.parent.left) && isEntityNameExpression(d.parent.left.expression)) { + if (isModuleExportsPropertyAccessExpression(d.parent.left) || isExportsIdentifier(d.parent.left.expression)) { + return getSymbolOfNode(getSourceFileOfNode(d)); + } + checkExpressionCached(d.parent.left.expression); + return getNodeLinks(d.parent.left.expression).resolvedSymbol; + } + }); if (!length(candidates)) { return undefined; } @@ -3000,7 +3048,7 @@ namespace ts { function fileSymbolIfFileSymbolExportEqualsContainer(d: Declaration) { const fileSymbol = getExternalModuleContainer(d); const exported = fileSymbol && fileSymbol.exports && fileSymbol.exports.get(InternalSymbolName.ExportEquals); - return resolveSymbol(exported) === resolveSymbol(container) ? fileSymbol : undefined; + return exported && container && getSymbolIfSameReference(exported, container) ? fileSymbol : undefined; } } @@ -3009,21 +3057,30 @@ namespace ts { // fast path, `symbol` is either already the alias or isn't aliased return symbol; } + // Check if container is a thing with an `export=` which points directly at `symbol`, and if so, return + // the container itself as the alias for the symbol + const exportEquals = container.exports && container.exports.get(InternalSymbolName.ExportEquals); + if (exportEquals && getSymbolIfSameReference(exportEquals, symbol)) { + return container; + } const exports = getExportsOfSymbol(container); const quick = exports.get(symbol.escapedName); - if (quick && symbolRefersToTarget(quick)) { + if (quick && getSymbolIfSameReference(quick, symbol)) { return quick; } return forEachEntry(exports, exported => { - if (symbolRefersToTarget(exported)) { + if (getSymbolIfSameReference(exported, symbol)) { return exported; } }); + } - function symbolRefersToTarget(s: Symbol) { - if (s === symbol || resolveSymbol(s) === symbol || resolveSymbol(s) === resolveSymbol(symbol)) { - return s; - } + /** + * Checks if two symbols, through aliasing and/or merging, refer to the same thing + */ + function getSymbolIfSameReference(s1: Symbol, s2: Symbol) { + if (getMergedSymbol(resolveSymbol(getMergedSymbol(s1))) === getMergedSymbol(resolveSymbol(getMergedSymbol(s2)))) { + return s1; } } @@ -3142,7 +3199,32 @@ namespace ts { } // falls through case SyntaxKind.ModuleDeclaration: - if (result = callback(getSymbolOfNode(location as ModuleDeclaration).exports!)) { + const sym = getSymbolOfNode(location as ModuleDeclaration); + // `sym` may not have exports if this module declaration is backed by the symbol for a `const` that's being rewritten + // into a namespace - in such cases, it's best to just let the namespace appear empty (the const members couldn't have referred + // to one another anyway) + if (result = callback(sym.exports || emptySymbols)) { + return result; + } + break; + case SyntaxKind.ClassDeclaration: + case SyntaxKind.ClassExpression: + case SyntaxKind.InterfaceDeclaration: + // Type parameters are bound into `members` lists so they can merge across declarations + // This is troublesome, since in all other respects, they behave like locals :cries: + // TODO: the below is shared with similar code in `resolveName` - in fact, rephrasing all this symbol + // lookup logic in terms of `resolveName` would be nice + // The below is used to lookup type parameters within a class or interface, as they are added to the class/interface locals + // These can never be latebound, so the symbol's raw members are sufficient. `getMembersOfNode` cannot be used, as it would + // trigger resolving late-bound names, which we may already be in the process of doing while we're here! + let table: UnderscoreEscapedMap | undefined; + // TODO: Should this filtered table be cached in some way? + (getSymbolOfNode(location as ClassLikeDeclaration | InterfaceDeclaration).members || emptySymbols).forEach((memberSymbol, key) => { + if (memberSymbol.flags & (SymbolFlags.Type & ~SymbolFlags.Assignment)) { + (table || (table = createSymbolTable())).set(key, memberSymbol); + } + }); + if (table && (result = callback(table))) { return result; } break; @@ -3190,12 +3272,12 @@ namespace ts { } function isAccessible(symbolFromSymbolTable: Symbol, resolvedAliasSymbol?: Symbol, ignoreQualification?: boolean) { - return symbol === (resolvedAliasSymbol || symbolFromSymbolTable) && + return (symbol === (resolvedAliasSymbol || symbolFromSymbolTable) || getMergedSymbol(symbol) === getMergedSymbol(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, hasNonGlobalAugmentationExternalModuleSymbol) && - (ignoreQualification || canQualifySymbol(symbolFromSymbolTable, meaning)); + (ignoreQualification || canQualifySymbol(getMergedSymbol(symbolFromSymbolTable), meaning)); } function trySymbolTable(symbols: SymbolTable, ignoreQualification: boolean | undefined): Symbol[] | undefined { @@ -3587,6 +3669,8 @@ namespace ts { withContext(enclosingDeclaration, flags, tracker, context => symbolToParameterDeclaration(symbol, context)), typeParameterToDeclaration: (parameter: TypeParameter, enclosingDeclaration?: Node, flags?: NodeBuilderFlags, tracker?: SymbolTracker) => withContext(enclosingDeclaration, flags, tracker, context => typeParameterToDeclaration(parameter, context)), + symbolTableToDeclarationStatements: (symbolTable: SymbolTable, enclosingDeclaration?: Node, flags?: NodeBuilderFlags, tracker?: SymbolTracker, bundled?: boolean) => + withContext(enclosingDeclaration, flags, tracker, context => symbolTableToDeclarationStatements(symbolTable, context, bundled)), }; function withContext(enclosingDeclaration: Node | undefined, flags: NodeBuilderFlags | undefined, tracker: SymbolTracker | undefined, cb: (context: NodeBuilderContext) => T): T | undefined { @@ -3749,6 +3833,7 @@ namespace ts { return createInferTypeNode(typeParameterToDeclarationWithConstraint(type as TypeParameter, context, /*constraintNode*/ undefined)); } if (context.flags & NodeBuilderFlags.GenerateNamesForShadowedTypeParams && + type.flags & TypeFlags.TypeParameter && !isTypeSymbolAccessible(type.symbol, context.enclosingDeclaration)) { const name = typeParameterToName(type, context); context.approximateLength += idText(name).length; @@ -3982,6 +4067,8 @@ namespace ts { else if (context.flags & NodeBuilderFlags.WriteClassExpressionAsTypeLiteral && type.symbol.valueDeclaration && isClassLike(type.symbol.valueDeclaration) && + // Use `import` types for refs to other scopes, only anonymize something defined in the same scope + findAncestor(type.symbol.valueDeclaration, d => d === getSourceFileOfNode(context.enclosingDeclaration)) && !isValueSymbolAccessible(type.symbol, context.enclosingDeclaration) ) { return createAnonymousTypeNode(type); @@ -4149,11 +4236,7 @@ namespace ts { const methodDeclaration = signatureToSignatureDeclarationHelper(signature, SyntaxKind.MethodSignature, context); methodDeclaration.name = propertyName; methodDeclaration.questionToken = optionalToken; - if (propertySymbol.valueDeclaration) { - // Copy comments to node for declaration emit - setCommentRange(methodDeclaration, propertySymbol.valueDeclaration); - } - typeElements.push(methodDeclaration); + typeElements.push(preserveCommentsOn(methodDeclaration)); } } else { @@ -4179,11 +4262,22 @@ namespace ts { propertyTypeNode, /*initializer*/ undefined); - if (propertySymbol.valueDeclaration) { + typeElements.push(preserveCommentsOn(propertySignature)); + } + + function preserveCommentsOn(node: T) { + if (some(propertySymbol.declarations, d => d.kind === SyntaxKind.JSDocPropertyTag)) { + const d = find(propertySymbol.declarations, d => d.kind === SyntaxKind.JSDocPropertyTag)! as JSDocPropertyTag; + const commentText = d.comment; + if (commentText) { + setSyntheticLeadingComments(node, [{ kind: SyntaxKind.MultiLineCommentTrivia, text: "*\n * " + commentText.replace(/\n/g, "\n * ") + "\n ", pos: -1, end: -1, hasTrailingNewLine: true }]); + } + } + else if (propertySymbol.valueDeclaration) { // Copy comments to node for declaration emit - setCommentRange(propertySignature, propertySymbol.valueDeclaration); + setCommentRange(node, propertySymbol.valueDeclaration); } - typeElements.push(propertySignature); + return node; } } @@ -4369,6 +4463,10 @@ namespace ts { function lookupSymbolChain(symbol: Symbol, context: NodeBuilderContext, meaning: SymbolFlags, yieldModuleSymbol?: boolean) { context.tracker.trackSymbol!(symbol, context.enclosingDeclaration, meaning); // TODO: GH#18217 + return lookupSymbolChainWorker(symbol, context, meaning, yieldModuleSymbol); + } + + function lookupSymbolChainWorker(symbol: Symbol, context: NodeBuilderContext, meaning: SymbolFlags, yieldModuleSymbol?: boolean) { // Try to get qualified name if the symbol is not a type parameter and there is an enclosing declaration. let chain: Symbol[]; const isTypeParameter = symbol.flags & SymbolFlags.TypeParameter; @@ -4401,6 +4499,13 @@ namespace ts { for (const parent of sortedParents) { const parentChain = getSymbolChain(parent, getQualifiedLeftMeaning(meaning), /*endOfChain*/ false); if (parentChain) { + if (parent.exports && parent.exports.get(InternalSymbolName.ExportEquals) && + getSymbolIfSameReference(parent.exports.get(InternalSymbolName.ExportEquals)!, symbol)) { + // parentChain root _is_ symbol - symbol is a module export=, so it kinda looks like it's own parent + // No need to lookup an alias for the symbol in itself + accessibleSymbolChain = parentChain; + break; + } accessibleSymbolChain = parentChain.concat(accessibleSymbolChain || [getAliasForSymbolInContainer(parent, symbol) || symbol]); break; } @@ -4592,17 +4697,33 @@ namespace ts { const typeParameterNodes = index === (chain.length - 1) ? overrideTypeArguments : lookupTypeParameterNodes(chain, index, context); const symbol = chain[index]; + const parent = chain[index - 1]; + let symbolName: string | undefined; if (index === 0) { context.flags |= NodeBuilderFlags.InInitialEntityName; - } - const symbolName = getNameOfSymbolAsWritten(symbol, context); - context.approximateLength += symbolName.length + 1; - if (index === 0) { + symbolName = getNameOfSymbolAsWritten(symbol, context); + context.approximateLength += (symbolName ? symbolName.length : 0) + 1; context.flags ^= NodeBuilderFlags.InInitialEntityName; } + else { + if (parent && getExportsOfSymbol(parent)) { + const exports = getExportsOfSymbol(parent); + forEachEntry(exports, (ex, name) => { + if (getSymbolIfSameReference(ex, symbol) && !isLateBoundName(name) && name !== InternalSymbolName.ExportEquals) { + symbolName = unescapeLeadingUnderscores(name); + return true; + } + }); + } + } + if (!symbolName) { + symbolName = getNameOfSymbolAsWritten(symbol, context); + } + context.approximateLength += symbolName.length + 1; - const parent = chain[index - 1]; - if (!(context.flags & NodeBuilderFlags.ForbidIndexedAccessSymbolReferences) && parent && getMembersOfSymbol(parent) && getMembersOfSymbol(parent).get(symbol.escapedName) === symbol) { + if (!(context.flags & NodeBuilderFlags.ForbidIndexedAccessSymbolReferences) && parent && + getMembersOfSymbol(parent) && getMembersOfSymbol(parent).get(symbol.escapedName) && + getSymbolIfSameReference(getMembersOfSymbol(parent).get(symbol.escapedName)!, symbol)) { // Should use an indexed access const LHS = createAccessFromSymbolChain(chain, index - 1, stopper); if (isIndexedAccessTypeNode(LHS)) { @@ -4639,6 +4760,9 @@ namespace ts { } } let result = symbolToName(type.symbol, context, SymbolFlags.Type, /*expectsIdentifier*/ true); + if (!(result.kind & SyntaxKind.Identifier)) { + return createIdentifier("(Missing type parameter)"); + } if (context.flags & NodeBuilderFlags.GenerateNamesForShadowedTypeParams) { const rawtext = result.escapedText as string; let i = 0; @@ -4735,6 +4859,1198 @@ namespace ts { } } } + + // See getNameForSymbolFromNameType for a stringy equivalent + function getPropertyNameNodeForSymbolFromNameType(symbol: Symbol, context: NodeBuilderContext) { + const nameType = symbol.nameType; + if (nameType) { + if (nameType.flags & TypeFlags.StringOrNumberLiteral) { + const name = "" + (nameType).value; + if (!isIdentifierText(name, compilerOptions.target) && !isNumericLiteralName(name)) { + return createLiteral(name); + } + if (isNumericLiteralName(name) && startsWith(name, "-")) { + return createComputedPropertyName(createLiteral(+name)); + } + return isIdentifierText(name, compilerOptions.target) ? createIdentifier(name) : createLiteral(isNumericLiteralName(name) ? +name : name) as StringLiteral | NumericLiteral; + } + if (nameType.flags & TypeFlags.UniqueESSymbol) { + return createComputedPropertyName(symbolToExpression((nameType).symbol, context, SymbolFlags.Value)); + } + } + } + + function cloneNodeBuilderContext(context: NodeBuilderContext): NodeBuilderContext { + const initial: NodeBuilderContext = { ...context }; + // Make type parameters created within this context not consume the name outside this context + // The symbol serializer ends up creating many sibling scopes that all need "separate" contexts when + // it comes to naming things - within a normal `typeToTypeNode` call, the node builder only ever descends + // through the type tree, so the only cases where we could have used distinct sibling scopes was when there + // were multiple generic overloads with similar generated type parameter names + // The effect: + // When we write out + // export const x: (x: T) => T + // export const y: (x: T) => T + // we write it out like that, rather than as + // export const x: (x: T) => T + // export const y: (x: T_1) => T_1 + if (initial.typeParameterNames) { + initial.typeParameterNames = cloneMap(initial.typeParameterNames); + } + if (initial.typeParameterNamesByText) { + initial.typeParameterNamesByText = cloneMap(initial.typeParameterNamesByText); + } + if (initial.typeParameterSymbolList) { + initial.typeParameterSymbolList = cloneMap(initial.typeParameterSymbolList); + } + return initial; + } + + function symbolTableToDeclarationStatements(symbolTable: SymbolTable, context: NodeBuilderContext, bundled?: boolean): Statement[] { + const serializePropertySymbolForClass = makeSerializePropertySymbol(createProperty, SyntaxKind.MethodDeclaration); + const serializePropertySymbolForInterfaceWorker = makeSerializePropertySymbol((_decorators, mods, name, question, type, initializer) => createPropertySignature(mods, name, question, type, initializer), SyntaxKind.MethodSignature); + + // TODO: Use `setOriginalNode` on original declaration names where possible so these declarations see some kind of + // declaration mapping + + // We save the enclosing declaration off here so it's not adjusted by well-meaning declaration + // emit codepaths which want to apply more specific contexts (so we can still refer to the root real declaration + // we're trying to emit from later on) + const enclosingDeclaration = context.enclosingDeclaration!; + let results: Statement[] = []; + const visitedSymbols: Map = createMap(); + let deferredPrivates: Map | undefined; + const oldcontext = context; + context = { + ...oldcontext, + usedSymbolNames: mapMap(symbolTable, (_symbol, name) => [unescapeLeadingUnderscores(name), true]), + remappedSymbolNames: createMap(), + tracker: { + ...oldcontext.tracker, + trackSymbol: (sym, decl, meaning) => { + const accessibleResult = isSymbolAccessible(sym, decl, meaning, /*computeALiases*/ false); + if (accessibleResult.accessibility === SymbolAccessibility.Accessible) { + // Lookup the root symbol of the chain of refs we'll use to access it and serialize it + const chain = lookupSymbolChainWorker(sym, context, meaning); + if (!(sym.flags & SymbolFlags.Property)) { + includePrivateSymbol(chain[0]); + } + } + else if (oldcontext.tracker && oldcontext.tracker.trackSymbol) { + oldcontext.tracker.trackSymbol(sym, decl, meaning); + } + } + } + }; + if (oldcontext.usedSymbolNames) { + oldcontext.usedSymbolNames.forEach((_, name) => { + context.usedSymbolNames!.set(name, true); + }); + } + let addingDeclare = !bundled; + const exportEquals = symbolTable.get(InternalSymbolName.ExportEquals); + if (exportEquals && symbolTable.size > 1 && exportEquals.flags & SymbolFlags.Alias) { + symbolTable = createSymbolTable(); + // Remove extraneous elements from root symbol table (they'll be mixed back in when the target of the `export=` is looked up) + symbolTable.set(InternalSymbolName.ExportEquals, exportEquals); + } + + visitSymbolTable(symbolTable); + return mergeRedundantStatements(results); + + function isIdentifierAndNotUndefined(node: Node | undefined): node is Identifier { + return !!node && node.kind === SyntaxKind.Identifier; + } + + function getNamesOfDeclaration(statement: Statement): Identifier[] { + if (isVariableStatement(statement)) { + return filter(map(statement.declarationList.declarations, getNameOfDeclaration), isIdentifierAndNotUndefined); + } + return filter([getNameOfDeclaration(statement as DeclarationStatement)], isIdentifierAndNotUndefined); + } + + function flattenExportAssignedNamespace(statements: Statement[]) { + const exportAssignment = find(statements, isExportAssignment); + const ns = find(statements, isModuleDeclaration); + if (ns && exportAssignment && exportAssignment.isExportEquals && + isIdentifier(exportAssignment.expression) && isIdentifier(ns.name) && idText(ns.name) === idText(exportAssignment.expression) && + ns.body && isModuleBlock(ns.body)) { + // Pass 0: Correct situations where a module has both an `export = ns` and multiple top-level exports by stripping the export modifiers from + // the top-level exports and exporting them in the targeted ns, as can occur when a js file has both typedefs and `module.export` assignments + const excessExports = filter(statements, s => !!(getModifierFlags(s) & ModifierFlags.Export)); + if (length(excessExports)) { + ns.body.statements = createNodeArray([...ns.body.statements, createExportDeclaration( + /*decorators*/ undefined, + /*modifiers*/ undefined, + createNamedExports(map(flatMap(excessExports, e => getNamesOfDeclaration(e)), id => createExportSpecifier(/*alias*/ undefined, id))), + /*moduleSpecifier*/ undefined + )]); + } + + + // Pass 1: Flatten `export namespace _exports {} export = _exports;` so long as the `export=` only points at a single namespace declaration + if (!find(statements, s => s !== ns && nodeHasName(s, ns.name as Identifier))) { + results = []; + forEach(ns.body.statements, s => { + addResult(s, ModifierFlags.None); // Recalculates the ambient (and export, if applicable from above) flag + }); + statements = [...filter(statements, s => s !== ns && s !== exportAssignment), ...results]; + } + } + return statements; + } + + function mergeExportDeclarations(statements: Statement[]) { + // Pass 2: Combine all `export {}` declarations + const exports = filter(statements, d => isExportDeclaration(d) && !d.moduleSpecifier && !!d.exportClause) as ExportDeclaration[]; + if (length(exports) > 1) { + const nonExports = filter(statements, d => !isExportDeclaration(d) || !!d.moduleSpecifier || !d.exportClause); + statements = [...nonExports, createExportDeclaration( + /*decorators*/ undefined, + /*modifiers*/ undefined, + createNamedExports(flatMap(exports, e => e.exportClause!.elements)), + /*moduleSpecifier*/ undefined + )]; + } + // Pass 2b: Also combine all `export {} from "..."` declarations as needed + const reexports = filter(statements, d => isExportDeclaration(d) && !!d.moduleSpecifier && !!d.exportClause) as ExportDeclaration[]; + if (length(reexports) > 1) { + const groups = group(reexports, decl => isStringLiteral(decl.moduleSpecifier!) ? ">" + decl.moduleSpecifier.text : ">"); + if (groups.length !== reexports.length) { + for (const group of groups) { + if (group.length > 1) { + // remove group members from statements and then merge group members and add back to statements + statements = [ + ...filter(statements, s => group.indexOf(s as ExportDeclaration) === -1), + createExportDeclaration( + /*decorators*/ undefined, + /*modifiers*/ undefined, + createNamedExports(flatMap(group, e => e.exportClause!.elements)), + group[0].moduleSpecifier + ) + ]; + } + } + } + } + return statements; + } + + function inlineExportModifiers(statements: Statement[]) { + // Pass 3: Move all `export {}`'s to `export` modifiers where possible + const exportDecl = find(statements, d => isExportDeclaration(d) && !d.moduleSpecifier && !!d.exportClause) as ExportDeclaration | undefined; + if (exportDecl) { + const replacements = mapDefined(exportDecl.exportClause!.elements, e => { + if (!e.propertyName) { + // export {name} - look thru `statements` for `name`, and if all results can take an `export` modifier, do so and filter it + const associated = filter(statements, s => nodeHasName(s, e.name)); + if (length(associated) && every(associated, canHaveExportModifier)) { + forEach(associated, addExportModifier); + return undefined; + } + } + return e; + }); + if (!length(replacements)) { + // all clauses removed, filter the export declaration + statements = filter(statements, s => s !== exportDecl); + } + else { + // some items filtered, others not - update the export declaration + // (mutating because why not, we're building a whole new tree here anyway) + exportDecl.exportClause!.elements = createNodeArray(replacements); + } + } + return statements; + } + + function mergeRedundantStatements(statements: Statement[]) { + statements = flattenExportAssignedNamespace(statements); + statements = mergeExportDeclarations(statements); + statements = inlineExportModifiers(statements); + + // Not a cleanup, but as a final step: If there is a mix of `export` and non-`export` declarations, but no `export =` or `export {}` add a `export {};` so + // declaration privacy is respected. + if (enclosingDeclaration && + ((isSourceFile(enclosingDeclaration) && isExternalOrCommonJsModule(enclosingDeclaration)) || isModuleDeclaration(enclosingDeclaration)) && + (!some(statements, isExternalModuleIndicator) || (!hasScopeMarker(statements) && some(statements, needsScopeMarker)))) { + statements.push(createEmptyExports()); + } + return statements; + } + + function canHaveExportModifier(node: Statement) { + return isEnumDeclaration(node) || + isVariableStatement(node) || + isFunctionDeclaration(node) || + isClassDeclaration(node) || + (isModuleDeclaration(node) && !isExternalModuleAugmentation(node) && !isGlobalScopeAugmentation(node)) || + isInterfaceDeclaration(node) || + isTypeDeclaration(node); + } + + function addExportModifier(statement: Statement) { + const flags = (getModifierFlags(statement) | ModifierFlags.Export) & ~ModifierFlags.Ambient; + statement.modifiers = createNodeArray(createModifiersFromModifierFlags(flags)); + statement.modifierFlagsCache = 0; + } + + function visitSymbolTable(symbolTable: SymbolTable, suppressNewPrivateContext?: boolean, propertyAsAlias?: boolean) { + const oldDeferredPrivates = deferredPrivates; + if (!suppressNewPrivateContext) { + deferredPrivates = createMap(); + } + symbolTable.forEach((symbol: Symbol) => { + serializeSymbol(symbol, /*isPrivate*/ false, !!propertyAsAlias); + }); + if (!suppressNewPrivateContext) { + // deferredPrivates will be filled up by visiting the symbol table + // And will continue to iterate as elements are added while visited `deferredPrivates` + // (As that's how a map iterator is defined to work) + deferredPrivates!.forEach((symbol: Symbol) => { + serializeSymbol(symbol, /*isPrivate*/ true, !!propertyAsAlias); + }); + } + deferredPrivates = oldDeferredPrivates; + } + + function serializeSymbol(symbol: Symbol, isPrivate: boolean, propertyAsAlias: boolean) { + // cache visited list based on merged symbol, since we want to use the unmerged top-level symbol, but + // still skip reserializing it if we encounter the merged product later on + const visitedSym = getMergedSymbol(symbol); + if (visitedSymbols.has("" + getSymbolId(visitedSym))) { + return; // Already printed + } + visitedSymbols.set("" + getSymbolId(visitedSym), true); + // Only actually serialize symbols within the correct enclosing declaration, otherwise do nothing with the out-of-context symbol + const skipMembershipCheck = !isPrivate; // We only call this on exported symbols when we know they're in the correct scope + if (skipMembershipCheck || (!!length(symbol.declarations) && some(symbol.declarations, d => !!findAncestor(d, n => n === enclosingDeclaration)))) { + const oldContext = context; + context = cloneNodeBuilderContext(context); + const result = serializeSymbolWorker(symbol, isPrivate, propertyAsAlias); + context = oldContext; + return result; + } + } + + // Synthesize declarations for a symbol - might be an Interface, a Class, a Namespace, a Type, a Variable (const, let, or var), an Alias + // or a merge of some number of those. + // An interesting challenge is ensuring that when classes merge with namespaces and interfaces, is keeping + // each symbol in only one of the representations + // Also, synthesizing a default export of some kind + // If it's an alias: emit `export default ref` + // If it's a property: emit `export default _default` with a `_default` prop + // If it's a class/interface/function: emit a class/interface/function with a `default` modifier + // These forms can merge, eg (`export default 12; export default interface A {}`) + function serializeSymbolWorker(symbol: Symbol, isPrivate: boolean, propertyAsAlias: boolean) { + const symbolName = unescapeLeadingUnderscores(symbol.escapedName); + const isDefault = symbol.escapedName === InternalSymbolName.Default; + if (isStringANonContextualKeyword(symbolName) && !isDefault) { + // Oh no. We cannot use this symbol's name as it's name... It's likely some jsdoc had an invalid name like `export` or `default` :( + context.encounteredError = true; + // TODO: Issue error via symbol tracker? + return; // If we need to emit a private with a keyword name, we're done for, since something else will try to refer to it by that name + } + const needsPostExportDefault = isDefault && !!( + symbol.flags & SymbolFlags.ExportDoesNotSupportDefaultModifier + || (symbol.flags & SymbolFlags.Function && length(getPropertiesOfType(getTypeOfSymbol(symbol)))) + ) && !(symbol.flags & SymbolFlags.Alias); // An alias symbol should preclude needing to make an alias ourselves + if (needsPostExportDefault) { + isPrivate = true; + } + const modifierFlags = (!isPrivate ? ModifierFlags.Export : 0) | (isDefault && !needsPostExportDefault ? ModifierFlags.Default : 0); + if (symbol.flags & SymbolFlags.Function) { + serializeAsFunctionNamespaceMerge(getTypeOfSymbol(symbol), symbol, getInternalSymbolName(symbol, symbolName), modifierFlags); + } + if (symbol.flags & SymbolFlags.TypeAlias) { + serializeTypeAlias(symbol, symbolName, modifierFlags); + } + // Need to skip over export= symbols below - json source files get a single `Property` flagged + // symbol of name `export=` which needs to be handled like an alias. It's not great, but it is what it is. + if (symbol.flags & (SymbolFlags.BlockScopedVariable | SymbolFlags.FunctionScopedVariable | SymbolFlags.Property) + && symbol.escapedName !== InternalSymbolName.ExportEquals + && !(symbol.flags & SymbolFlags.Prototype) + && !(symbol.flags & SymbolFlags.Class)) { + serializeVariableOrProperty(symbol, symbolName, isPrivate, needsPostExportDefault, propertyAsAlias, modifierFlags); + } + if (symbol.flags & SymbolFlags.Enum) { + serializeEnum(symbol, symbolName, modifierFlags); + } + if (symbol.flags & SymbolFlags.Class) { + if (symbol.flags & SymbolFlags.Property) { + // Looks like a `module.exports.Sub = class {}` - if we serialize `symbol` as a class, the result will have no members, + // since the classiness is actually from the target of the effective alias the symbol is. yes. A BlockScopedVariable|Class|Property + // _really_ acts like an Alias, and none of a BlockScopedVariable, Class, or Property. This is the travesty of JS binding today. + serializeAsAlias(symbol, getInternalSymbolName(symbol, symbolName), modifierFlags); + } + else { + serializeAsClass(symbol, getInternalSymbolName(symbol, symbolName), modifierFlags); + } + } + if (symbol.flags & (SymbolFlags.ValueModule | SymbolFlags.NamespaceModule)) { + serializeModule(symbol, symbolName, modifierFlags); + } + if (symbol.flags & SymbolFlags.Interface) { + serializeInterface(symbol, symbolName, modifierFlags); + } + if (symbol.flags & SymbolFlags.Alias) { + serializeAsAlias(symbol, getInternalSymbolName(symbol, symbolName), modifierFlags); + } + if (symbol.flags & SymbolFlags.Property && symbol.escapedName === InternalSymbolName.ExportEquals) { + serializeMaybeAliasAssignment(symbol); + } + if (symbol.flags & SymbolFlags.ExportStar) { + // synthesize export * from "moduleReference" + // Straightforward - only one thing to do - make an export declaration + for (const node of symbol.declarations) { + const resolvedModule = resolveExternalModuleName(node, (node as ExportDeclaration).moduleSpecifier!); + if (!resolvedModule) continue; + addResult(createExportDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, /*exportClause*/ undefined, createLiteral(getSpecifierForModuleSymbol(resolvedModule, context))), ModifierFlags.None); + } + } + if (needsPostExportDefault) { + addResult(createExportAssignment(/*decorators*/ undefined, /*modifiers*/ undefined, /*isExportAssignment*/ false, createIdentifier(getInternalSymbolName(symbol, symbolName))), ModifierFlags.None); + } + } + + function includePrivateSymbol(symbol: Symbol) { + Debug.assertDefined(deferredPrivates); + deferredPrivates!.set("" + getSymbolId(symbol), symbol); + } + + function isExportingScope(enclosingDeclaration: Node) { + return ((isSourceFile(enclosingDeclaration) && (isExternalOrCommonJsModule(enclosingDeclaration) || isJsonSourceFile(enclosingDeclaration))) || + (isAmbientModule(enclosingDeclaration) && !isGlobalScopeAugmentation(enclosingDeclaration))); + } + + // Prepends a `declare` and/or `export` modifier if the context requires it, and then adds `node` to `result` and returns `node` + // Note: This _mutates_ `node` without using `updateNode` - the assumption being that all nodes should be manufactured fresh by the node builder + function addResult(node: Statement, additionalModifierFlags: ModifierFlags) { + let newModifierFlags: ModifierFlags = ModifierFlags.None; + if (additionalModifierFlags & ModifierFlags.Export && + enclosingDeclaration && + isExportingScope(enclosingDeclaration) && + canHaveExportModifier(node) + ) { + // Classes, namespaces, variables, functions, interfaces, and types should all be `export`ed in a module context if not private + newModifierFlags |= ModifierFlags.Export; + } + if (addingDeclare && !(newModifierFlags & ModifierFlags.Export) && + (!enclosingDeclaration || !(enclosingDeclaration.flags & NodeFlags.Ambient)) && + (isEnumDeclaration(node) || isVariableStatement(node) || isFunctionDeclaration(node) || isClassDeclaration(node) || isModuleDeclaration(node))) { + // Classes, namespaces, variables, enums, and functions all need `declare` modifiers to be valid in a declaration file top-level scope + newModifierFlags |= ModifierFlags.Ambient; + } + if ((additionalModifierFlags & ModifierFlags.Default) && (isClassDeclaration(node) || isInterfaceDeclaration(node) || isFunctionDeclaration(node))) { + newModifierFlags |= ModifierFlags.Default; + } + if (newModifierFlags) { + node.modifiers = createNodeArray(createModifiersFromModifierFlags(newModifierFlags | getModifierFlags(node))); + node.modifierFlagsCache = 0; // Reset computed flags cache + } + results.push(node); + } + + function serializeTypeAlias(symbol: Symbol, symbolName: string, modifierFlags: ModifierFlags) { + const aliasType = getDeclaredTypeOfTypeAlias(symbol); + const typeParams = getSymbolLinks(symbol).typeParameters; + const typeParamDecls = map(typeParams, p => typeParameterToDeclaration(p, context)); + const jsdocAliasDecl = find(symbol.declarations, isJSDocTypeAlias); + const commentText = jsdocAliasDecl ? jsdocAliasDecl.comment || jsdocAliasDecl.parent.comment : undefined; + const oldFlags = context.flags; + context.flags |= NodeBuilderFlags.InTypeAlias; + addResult(setSyntheticLeadingComments( + createTypeAliasDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, getInternalSymbolName(symbol, symbolName), typeParamDecls, typeToTypeNodeHelper(aliasType, context)), + !commentText ? [] : [{ kind: SyntaxKind.MultiLineCommentTrivia, text: "*\n * " + commentText.replace(/\n/g, "\n * ") + "\n ", pos: -1, end: -1, hasTrailingNewLine: true }] + ), modifierFlags); + context.flags = oldFlags; + } + + function serializeInterface(symbol: Symbol, symbolName: string, modifierFlags: ModifierFlags) { + const interfaceType = getDeclaredTypeOfClassOrInterface(symbol); + const localParams = getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol); + const typeParamDecls = map(localParams, p => typeParameterToDeclaration(p, context)); + const baseTypes = getBaseTypes(interfaceType); + const baseType = length(baseTypes) ? getIntersectionType(baseTypes) : undefined; + const members = flatMap(getPropertiesOfType(interfaceType), p => serializePropertySymbolForInterface(p, baseType)); + const callSignatures = serializeSignatures(SignatureKind.Call, interfaceType, baseType, SyntaxKind.CallSignature) as CallSignatureDeclaration[]; + const constructSignatures = serializeSignatures(SignatureKind.Construct, interfaceType, baseType, SyntaxKind.ConstructSignature) as ConstructSignatureDeclaration[]; + const indexSignatures = serializeIndexSignatures(interfaceType, baseType); + + const heritageClauses = !length(baseTypes) ? undefined : [createHeritageClause(SyntaxKind.ExtendsKeyword, mapDefined(baseTypes, b => trySerializeAsTypeReference(b)))]; + addResult(createInterfaceDeclaration( + /*decorators*/ undefined, + /*modifiers*/ undefined, + getInternalSymbolName(symbol, symbolName), + typeParamDecls, + heritageClauses, + [...indexSignatures, ...constructSignatures, ...callSignatures, ...members] + ), modifierFlags); + } + + function serializeModule(symbol: Symbol, symbolName: string, modifierFlags: ModifierFlags) { + const members = !symbol.exports ? [] : filter(arrayFrom((symbol.exports).values()), p => !((p.flags & SymbolFlags.Prototype) || (p.escapedName === "prototype"))); + // Split NS members up by declaration - members whose parent symbol is the ns symbol vs those whose is not (but were added in later via merging) + const locationMap = arrayToMultiMap(members, m => m.parent && m.parent === symbol ? "real" : "merged"); + const realMembers = locationMap.get("real") || emptyArray; + const mergedMembers = locationMap.get("merged") || emptyArray; + // TODO: `suppressNewPrivateContext` is questionable -we need to simply be emitting privates in whatever scope they were declared in, rather + // than whatever scope we traverse to them in. That's a bit of a complex rewrite, since we're not _actually_ tracking privates at all in advance, + // so we don't even have placeholders to fill in. + if (length(realMembers)) { + const localName = getInternalSymbolName(symbol, symbolName); + serializeAsNamespaceDeclaration(realMembers, localName, modifierFlags, /*suppressNewPrivateContext*/ false); + } + if (length(mergedMembers)) { + const localName = getInternalSymbolName(symbol, symbolName); + forEach(mergedMembers, includePrivateSymbol); + const nsBody = createModuleBlock([createExportDeclaration( + /*decorators*/ undefined, + /*modifiers*/ undefined, + createNamedExports(map(filter(mergedMembers, n => n.escapedName !== InternalSymbolName.ExportEquals), s => { + const name = unescapeLeadingUnderscores(s.escapedName); + const localName = getInternalSymbolName(s, name); + return createExportSpecifier(name === localName ? undefined : localName, name); + })) + )]); + addResult(createModuleDeclaration( + /*decorators*/ undefined, + /*modifiers*/ undefined, + createIdentifier(localName), + nsBody, + NodeFlags.Namespace + ), ModifierFlags.None); + } + } + + function serializeEnum(symbol: Symbol, symbolName: string, modifierFlags: ModifierFlags) { + addResult(createEnumDeclaration( + /*decorators*/ undefined, + createModifiersFromModifierFlags(isConstEnumSymbol(symbol) ? ModifierFlags.Const : 0), + getInternalSymbolName(symbol, symbolName), + map(filter(getPropertiesOfType(getTypeOfSymbol(symbol)), p => !!(p.flags & SymbolFlags.EnumMember)), p => { + // TODO: Handle computed names + // I hate that to get the initialized value we need to walk back to the declarations here; but there's no + // other way to get the possible const value of an enum member that I'm aware of, as the value is cached + // _on the declaration_, not on the declaration's symbol... + const initializedValue = p.declarations && p.declarations[0] && isEnumMember(p.declarations[0]) && getConstantValue(p.declarations[0] as EnumMember); + return createEnumMember(unescapeLeadingUnderscores(p.escapedName), initializedValue === undefined ? undefined : createLiteral(initializedValue)); + }) + ), modifierFlags); + } + + function serializeVariableOrProperty(symbol: Symbol, symbolName: string, isPrivate: boolean, needsPostExportDefault: boolean, propertyAsAlias: boolean | undefined, modifierFlags: ModifierFlags) { + if (propertyAsAlias) { + serializeMaybeAliasAssignment(symbol); + } + else { + const type = getTypeOfSymbol(symbol); + const localName = getInternalSymbolName(symbol, symbolName); + if (!(symbol.flags & SymbolFlags.Function) && isTypeRepresentableAsFunctionNamespaceMerge(type, symbol)) { + // If the type looks like a function declaration + ns could represent it, and it's type is sourced locally, rewrite it into a function declaration + ns + serializeAsFunctionNamespaceMerge(type, symbol, localName, modifierFlags); + } + else { + // A Class + Property merge is made for a `module.exports.Member = class {}`, and it doesn't serialize well as either a class _or_ a property symbol - in fact, _it behaves like an alias!_ + // `var` is `FunctionScopedVariable`, `const` and `let` are `BlockScopedVariable`, and `module.exports.thing =` is `Property` + const flags = !(symbol.flags & SymbolFlags.BlockScopedVariable) ? undefined + : isConstVariable(symbol) ? NodeFlags.Const + : NodeFlags.Let; + const name = (needsPostExportDefault || !(symbol.flags & SymbolFlags.Property)) ? localName : getUnusedName(localName, symbol); + let textRange: Node | undefined = symbol.declarations && find(symbol.declarations, d => isVariableDeclaration(d)); + if (textRange && isVariableDeclarationList(textRange.parent) && textRange.parent.declarations.length === 1) { + textRange = textRange.parent.parent; + } + const statement = setTextRange(createVariableStatement(/*modifiers*/ undefined, createVariableDeclarationList([ + createVariableDeclaration(name, serializeTypeForDeclaration(type, symbol)) + ], flags)), textRange); + addResult(statement, name !== localName ? modifierFlags & ~ModifierFlags.Export : modifierFlags); + if (name !== localName && !isPrivate) { + // We rename the variable declaration we generate for Property symbols since they may have a name which + // conflicts with a local declaration. For example, given input: + // ``` + // function g() {} + // module.exports.g = g + // ``` + // In such a situation, we have a local variable named `g`, and a seperate exported variable named `g`. + // Naively, we would emit + // ``` + // function g() {} + // export const g: typeof g; + // ``` + // That's obviously incorrect - the `g` in the type annotation needs to refer to the local `g`, but + // the export declaration shadows it. + // To work around that, we instead write + // ``` + // function g() {} + // const g_1: typeof g; + // export { g_1 as g }; + // ``` + // To create an export named `g` that does _not_ shadow the local `g` + addResult( + createExportDeclaration( + /*decorators*/ undefined, + /*modifiers*/ undefined, + createNamedExports([createExportSpecifier(name, localName)]) + ), + ModifierFlags.None + ); + } + } + } + } + + function serializeAsFunctionNamespaceMerge(type: Type, symbol: Symbol, localName: string, modifierFlags: ModifierFlags) { + const signatures = getSignaturesOfType(type, SignatureKind.Call); + for (const sig of signatures) { + // Each overload becomes a separate function declaration, in order + const decl = signatureToSignatureDeclarationHelper(sig, SyntaxKind.FunctionDeclaration, context) as FunctionDeclaration; + decl.name = createIdentifier(localName); + addResult(setTextRange(decl, sig.declaration), modifierFlags); + } + // Module symbol emit will take care of module-y members, provided it has exports + if (!(symbol.flags & (SymbolFlags.ValueModule | SymbolFlags.NamespaceModule) && !!symbol.exports && !!symbol.exports.size)) { + const props = filter(getPropertiesOfType(type), p => !((p.flags & SymbolFlags.Prototype) || (p.escapedName === "prototype"))); + serializeAsNamespaceDeclaration(props, localName, modifierFlags, /*suppressNewPrivateContext*/ true); + } + } + + function serializeAsNamespaceDeclaration(props: readonly Symbol[], localName: string, modifierFlags: ModifierFlags, suppressNewPrivateContext: boolean) { + if (length(props)) { + const localVsRemoteMap = arrayToMultiMap(props, p => + !length(p.declarations) || some(p.declarations, d => + getSourceFileOfNode(d) === getSourceFileOfNode(context.enclosingDeclaration!) + ) ? "local" : "remote" + ); + const localProps = localVsRemoteMap.get("local") || emptyArray; + // handle remote props first - we need to make an `import` declaration that points at the module containing each remote + // prop in the outermost scope (TODO: a namespace within a namespace would need to be appropriately handled by this) + // Example: + // import Foo_1 = require("./exporter"); + // export namespace ns { + // import Foo = Foo_1.Foo; + // export { Foo }; + // export const c: number; + // } + // This is needed because in JS, statements like `const x = require("./f")` support both type and value lookup, even if they're + // normally just value lookup (so it functions kinda like an alias even when it's not an alias) + // _Usually_, we'll simply print the top-level as an alias instead of a `var` in such situations, however is is theoretically + // possible to encounter a situation where a type has members from both the current file and other files - in those situations, + // emit akin to the above would be needed. + + // Add a namespace + const fakespace = createModuleDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, createIdentifier(localName), createModuleBlock([]), NodeFlags.Namespace); + fakespace.flags ^= NodeFlags.Synthesized; // unset synthesized so it is usable as an enclosing declaration + fakespace.parent = enclosingDeclaration as SourceFile | NamespaceDeclaration; + fakespace.locals = createSymbolTable(props); + fakespace.symbol = props[0].parent!; + const oldResults = results; + results = []; + const oldAddingDeclare = addingDeclare; + addingDeclare = false; + const subcontext = { ...context, enclosingDeclaration: fakespace }; + const oldContext = context; + context = subcontext; + // TODO: implement handling for the localVsRemoteMap.get("remote") - should be difficult to trigger (see comment above), as only interesting cross-file js merges should make this possible + visitSymbolTable(createSymbolTable(localProps), suppressNewPrivateContext, /*propertyAsAlias*/ true); + context = oldContext; + addingDeclare = oldAddingDeclare; + const declarations = results; + results = oldResults; + fakespace.flags ^= NodeFlags.Synthesized; // reset synthesized + fakespace.parent = undefined!; + fakespace.locals = undefined!; + fakespace.symbol = undefined!; + fakespace.body = createModuleBlock(declarations); + addResult(fakespace, modifierFlags); // namespaces can never be default exported + } + } + + function serializeAsClass(symbol: Symbol, localName: string, modifierFlags: ModifierFlags) { + const localParams = getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol); + const typeParamDecls = map(localParams, p => typeParameterToDeclaration(p, context)); + const classType = getDeclaredTypeOfClassOrInterface(symbol); + const baseTypes = getBaseTypes(classType); + const staticType = getTypeOfSymbol(symbol); + const staticBaseType = getBaseConstructorTypeOfClass(staticType as InterfaceType); + const heritageClauses = !length(baseTypes) ? undefined : [createHeritageClause(SyntaxKind.ExtendsKeyword, map(baseTypes, b => serializeBaseType(b, staticBaseType, localName)))]; + const members = flatMap(getPropertiesOfType(classType), p => serializePropertySymbolForClass(p, /*isStatic*/ false, baseTypes[0])); + // Consider static members empty if symbol also has function or module meaning - function namespacey emit will handle statics + const staticMembers = symbol.flags & (SymbolFlags.Function | SymbolFlags.ValueModule) + ? [] + : flatMap(filter( + getPropertiesOfType(staticType), + p => !(p.flags & SymbolFlags.Prototype) && p.escapedName !== "prototype" + ), p => serializePropertySymbolForClass(p, /*isStatic*/ true, staticBaseType)); + const constructors = serializeSignatures(SignatureKind.Construct, staticType, baseTypes[0], SyntaxKind.Constructor) as ConstructorDeclaration[]; + for (const c of constructors) { + // A constructor's return type and type parameters are supposed to be controlled by the enclosing class declaration + // `signatureToSignatureDeclarationHelper` appends them regardless, so for now we delete them here + c.type = undefined; + c.typeParameters = undefined; + } + const indexSignatures = serializeIndexSignatures(classType, baseTypes[0]); + addResult(setTextRange(createClassDeclaration( + /*decorators*/ undefined, + /*modifiers*/ undefined, + localName, + typeParamDecls, + heritageClauses, + [...indexSignatures, ...staticMembers, ...constructors, ...members] + ), symbol.declarations && filter(symbol.declarations, d => isClassDeclaration(d) || isClassExpression(d))[0]), modifierFlags); + } + + function serializeAsAlias(symbol: Symbol, localName: string, modifierFlags: ModifierFlags) { + // synthesize an alias, eg `export { symbolName as Name }` + // need to mark the alias `symbol` points + // at as something we need to serialize as a private declaration as well + const node = getDeclarationOfAliasSymbol(symbol); + if (!node) return Debug.fail(); + const target = getMergedSymbol(getTargetOfAliasDeclaration(node, /*dontRecursivelyResolve*/ true)); + if (!target) { + return; + } + let verbatimTargetName = unescapeLeadingUnderscores(target.escapedName); + if (verbatimTargetName === InternalSymbolName.ExportEquals && (compilerOptions.esModuleInterop || compilerOptions.allowSyntheticDefaultImports)) { + // target refers to an `export=` symbol that was hoisted into a synthetic default - rename here to match + verbatimTargetName = InternalSymbolName.Default; + } + const targetName = getInternalSymbolName(target, verbatimTargetName); + includePrivateSymbol(target); // the target may be within the same scope - attempt to serialize it first + switch (node.kind) { + case SyntaxKind.ImportEqualsDeclaration: + // Could be a local `import localName = ns.member` or + // an external `import localName = require("whatever")` + const isLocalImport = !(target.flags & SymbolFlags.ValueModule); + addResult(createImportEqualsDeclaration( + /*decorators*/ undefined, + /*modifiers*/ undefined, + createIdentifier(localName), + isLocalImport + ? symbolToName(target, context, SymbolFlags.All, /*expectsIdentifier*/ false) + : createExternalModuleReference(createLiteral(getSpecifierForModuleSymbol(symbol, context))) + ), isLocalImport ? modifierFlags : ModifierFlags.None); + break; + case SyntaxKind.NamespaceExportDeclaration: + // export as namespace foo + // TODO: Not part of a file's local or export symbol tables + // Is bound into file.symbol.globalExports instead, which we don't currently traverse + addResult(createNamespaceExportDeclaration(idText((node as NamespaceExportDeclaration).name)), ModifierFlags.None); + break; + case SyntaxKind.ImportClause: + addResult(createImportDeclaration( + /*decorators*/ undefined, + /*modifiers*/ undefined, + createImportClause(createIdentifier(localName), /*namedBindings*/ undefined), + createLiteral(getSpecifierForModuleSymbol(target.parent!, context)) + ), ModifierFlags.None); + break; + case SyntaxKind.NamespaceImport: + addResult(createImportDeclaration( + /*decorators*/ undefined, + /*modifiers*/ undefined, + createImportClause(/*importClause*/ undefined, createNamespaceImport(createIdentifier(localName))), + createLiteral(getSpecifierForModuleSymbol(target, context)) + ), ModifierFlags.None); + break; + case SyntaxKind.ImportSpecifier: + addResult(createImportDeclaration( + /*decorators*/ undefined, + /*modifiers*/ undefined, + createImportClause(/*importClause*/ undefined, createNamedImports([ + createImportSpecifier( + localName !== verbatimTargetName ? createIdentifier(verbatimTargetName) : undefined, + createIdentifier(localName) + ) + ])), + createLiteral(getSpecifierForModuleSymbol(target.parent!, context)) + ), ModifierFlags.None); + break; + case SyntaxKind.ExportSpecifier: + // does not use localName because the symbol name in this case refers to the name in the exports table, + // which we must exactly preserve + const specifier = (node.parent.parent as ExportDeclaration).moduleSpecifier; + // targetName is only used when the target is local, as otherwise the target is an alias that points at + // another file + serializeExportSpecifier( + unescapeLeadingUnderscores(symbol.escapedName), + specifier ? verbatimTargetName : targetName, + specifier && isStringLiteralLike(specifier) ? createLiteral(specifier.text) : undefined + ); + break; + case SyntaxKind.ExportAssignment: + serializeMaybeAliasAssignment(symbol); + break; + case SyntaxKind.BinaryExpression: + // Could be best encoded as though an export specifier or as though an export assignment + // If name is default or export=, do an export assignment + // Otherwise do an export specifier + if (symbol.escapedName === InternalSymbolName.Default || symbol.escapedName === InternalSymbolName.ExportEquals) { + serializeMaybeAliasAssignment(symbol); + } + else { + serializeExportSpecifier(localName, targetName); + } + break; + case SyntaxKind.PropertyAccessExpression: + // A PAE alias is _always_ going to exist as an append to a top-level export, where our top level + // handling should always be sufficient to encode the export action itself + break; + default: + return Debug.failBadSyntaxKind(node, "Unhandled alias declaration kind in symbol serializer!"); + } + } + + function serializeExportSpecifier(localName: string, targetName: string, specifier?: Expression) { + addResult(createExportDeclaration( + /*decorators*/ undefined, + /*modifiers*/ undefined, + createNamedExports([createExportSpecifier(localName !== targetName ? targetName : undefined, localName)]), + specifier + ), ModifierFlags.None); + } + + function serializeMaybeAliasAssignment(symbol: Symbol) { + if (symbol.flags & SymbolFlags.Prototype) { + return; + } + const name = unescapeLeadingUnderscores(symbol.escapedName); + const isExportEquals = name === InternalSymbolName.ExportEquals; + const isDefault = name === InternalSymbolName.Default; + const isExportAssignment = isExportEquals || isDefault; + // synthesize export = ref + // ref should refer to either be a locally scoped symbol which we need to emit, or + // a reference to another namespace/module which we may need to emit an `import` statement for + const aliasDecl = symbol.declarations && getDeclarationOfAliasSymbol(symbol); + // serialize what the alias points to, preserve the declaration's initializer + const target = aliasDecl && getTargetOfAliasDeclaration(aliasDecl, /*dontRecursivelyResolve*/ true); + if (target) { + // In case `target` refers to a namespace member, look at the declaration and serialize the leftmost symbol in it + // eg, `namespace A { export class B {} }; exports = A.B;` + // Technically, this is all that's required in the case where the assignment is an entity name expression + const expr = isExportAssignment ? getExportAssignmentExpression(aliasDecl as ExportAssignment | BinaryExpression) : getPropertyAssignmentAliasLikeExpression(aliasDecl as ShorthandPropertyAssignment | PropertyAssignment | PropertyAccessExpression); + const first = isEntityNameExpression(expr) ? getFirstNonModuleExportsIdentifier(expr) : undefined; + const referenced = first && resolveEntityName(first, SymbolFlags.All, /*ignoreErrors*/ true, /*dontResolveAlias*/ true, enclosingDeclaration); + if (referenced || target) { + includePrivateSymbol(referenced || target); + } + + // We disable the context's symbol traker for the duration of this name serialization + // as, by virtue of being here, the name is required to print something, and we don't want to + // issue a visibility error on it. Only anonymous classes that an alias points at _would_ issue + // a visibility error here (as they're not visible within any scope), but we want to hoist them + // into the containing scope anyway, so we want to skip the visibility checks. + const oldTrack = context.tracker.trackSymbol; + context.tracker.trackSymbol = noop; + if (isExportAssignment) { + results.push(createExportAssignment( + /*decorators*/ undefined, + /*modifiers*/ undefined, + isExportEquals, + symbolToExpression(target, context, SymbolFlags.All) + )); + } + else { + if (first === expr) { + // serialize as `export {target as name}` + serializeExportSpecifier(name, idText(first)); + } + else if (isClassExpression(expr)) { + serializeExportSpecifier(name, getInternalSymbolName(target, symbolName(target))); + } + else { + // serialize as `import _Ref = t.arg.et; export { _Ref as name }` + const varName = getUnusedName(name, symbol); + addResult(createImportEqualsDeclaration( + /*decorators*/ undefined, + /*modifiers*/ undefined, + createIdentifier(varName), + symbolToName(target, context, SymbolFlags.All, /*expectsIdentifier*/ false) + ), ModifierFlags.None); + serializeExportSpecifier(name, varName); + } + } + context.tracker.trackSymbol = oldTrack; + } + else { + // serialize as an anonymous property declaration + const varName = getUnusedName(name, symbol); + // We have to use `getWidenedType` here since the object within a json file is unwidened within the file + // (Unwidened types can only exist in expression contexts and should never be serialized) + const typeToSerialize = getWidenedType(getTypeOfSymbol(symbol)); + if (isTypeRepresentableAsFunctionNamespaceMerge(typeToSerialize, symbol)) { + // If there are no index signatures and `typeToSerialize` is an object type, emit as a namespace instead of a const + serializeAsFunctionNamespaceMerge(typeToSerialize, symbol, varName, isExportAssignment ? ModifierFlags.None : ModifierFlags.Export); + } + else { + const statement = createVariableStatement(/*modifiers*/ undefined, createVariableDeclarationList([ + createVariableDeclaration(varName, serializeTypeForDeclaration(typeToSerialize, symbol)) + ], NodeFlags.Const)); + addResult(statement, name === varName ? ModifierFlags.Export : ModifierFlags.None); + } + if (isExportAssignment) { + results.push(createExportAssignment( + /*decorators*/ undefined, + /*modifiers*/ undefined, + isExportEquals, + createIdentifier(varName) + )); + } + else if (name !== varName) { + serializeExportSpecifier(name, varName); + } + } + } + + function isTypeRepresentableAsFunctionNamespaceMerge(typeToSerialize: Type, hostSymbol: Symbol) { + // Only object types which are not constructable, or indexable, whose members all come from the + // context source file, and whose property names are all valid identifiers and not late-bound, _and_ + // whose input is not type annotated (if the input symbol has an annotation we can reuse, we should prefer it) + const ctxSrc = getSourceFileOfNode(context.enclosingDeclaration); + return getObjectFlags(typeToSerialize) & (ObjectFlags.Anonymous | ObjectFlags.Mapped) && + !getIndexInfoOfType(typeToSerialize, IndexKind.String) && + !getIndexInfoOfType(typeToSerialize, IndexKind.Number) && + !length(getSignaturesOfType(typeToSerialize, SignatureKind.Construct)) && // TODO: could probably serialize as function + ns + class, now that that's OK + !getDeclarationWithTypeAnnotation(hostSymbol) && + !(typeToSerialize.symbol && some(typeToSerialize.symbol.declarations, d => getSourceFileOfNode(d) !== ctxSrc)) && + !some(getPropertiesOfType(typeToSerialize), p => isLateBoundName(p.escapedName)) && + !some(getPropertiesOfType(typeToSerialize), p => some(p.declarations, d => getSourceFileOfNode(d) !== ctxSrc)) && + every(getPropertiesOfType(typeToSerialize), p => isIdentifierText(symbolName(p), languageVersion) && !isStringAKeyword(symbolName(p))); + } + + function makeSerializePropertySymbol(createProperty: ( + decorators: readonly Decorator[] | undefined, + modifiers: readonly Modifier[] | undefined, + name: string | PropertyName, + questionOrExclamationToken: QuestionToken | undefined, + type: TypeNode | undefined, + initializer: Expression | undefined + ) => T, methodKind: SyntaxKind): (p: Symbol, isStatic: boolean, baseType: Type | undefined) => (T | T[]) { + return function serializePropertySymbol(p: Symbol, isStatic: boolean, baseType: Type | undefined) { + if (isStatic && (p.flags & (SymbolFlags.Type | SymbolFlags.Namespace | SymbolFlags.Alias))) { + // Only value-only-meaning symbols can be correctly encoded as class statics, type/namespace/alias meaning symbols + // need to be merged namespace members + return []; + } + if (p.flags & SymbolFlags.Prototype || (baseType && getPropertyOfType(baseType, p.escapedName) + && isReadonlySymbol(getPropertyOfType(baseType, p.escapedName)!) === isReadonlySymbol(p) + && (p.flags & SymbolFlags.Optional) === (getPropertyOfType(baseType, p.escapedName)!.flags & SymbolFlags.Optional) + && isTypeIdenticalTo(getTypeOfSymbol(p), getTypeOfPropertyOfType(baseType, p.escapedName)!))) { + return []; + } + const staticFlag = isStatic ? ModifierFlags.Static : 0; + const rawName = unescapeLeadingUnderscores(p.escapedName); + const name = getPropertyNameNodeForSymbolFromNameType(p, context) || createIdentifier(rawName); + if (p.flags & (SymbolFlags.Property | SymbolFlags.Accessor | SymbolFlags.Variable)) { + return setTextRange(createProperty( + /*decorators*/ undefined, + createModifiersFromModifierFlags((isReadonlySymbol(p) ? ModifierFlags.Readonly : 0) | staticFlag), + name, + p.flags & SymbolFlags.Optional ? createToken(SyntaxKind.QuestionToken) : undefined, + serializeTypeForDeclaration(getTypeOfSymbol(p), p), + // TODO: https://github.com/microsoft/TypeScript/pull/32372#discussion_r328386357 + // interface members can't have initializers, however class members _can_ + /*initializer*/ undefined + ), filter(p.declarations, d => isPropertyDeclaration(d) || isAccessor(d) || isVariableDeclaration(d) || isPropertySignature(d) || isBinaryExpression(d) || isPropertyAccessExpression(d))[0]); + } + if (p.flags & (SymbolFlags.Method | SymbolFlags.Function)) { + const type = getTypeOfSymbol(p); + const signatures = getSignaturesOfType(type, SignatureKind.Call); + const results = []; + for (const sig of signatures) { + // Each overload becomes a separate method declaration, in order + const decl = signatureToSignatureDeclarationHelper(sig, methodKind, context) as MethodDeclaration; + decl.name = name; // TODO: Clone + if (staticFlag) { + decl.modifiers = createNodeArray(createModifiersFromModifierFlags(staticFlag)); + } + if (p.flags & SymbolFlags.Optional) { + decl.questionToken = createToken(SyntaxKind.QuestionToken); + } + results.push(setTextRange(decl, sig.declaration)); + } + return results as unknown as T[]; + } + // The `Constructor`'s symbol isn't in the class's properties lists, obviously, since it's a signature on the static + return Debug.fail(`Unhandled class member kind! ${(p as any).__debugFlags || p.flags}`); + }; + } + + function serializePropertySymbolForInterface(p: Symbol, baseType: Type | undefined) { + return serializePropertySymbolForInterfaceWorker(p, /*isStatic*/ false, baseType); + } + + function getDeclarationWithTypeAnnotation(symbol: Symbol) { + return find(symbol.declarations, s => !!getEffectiveTypeAnnotationNode(s) && !!findAncestor(s, n => n === enclosingDeclaration)); + } + + /** + * Unlike `typeToTypeNodeHelper`, this handles setting up the `AllowUniqueESSymbolType` flag + * so a `unique symbol` is returned when appropriate for the input symbol, rather than `typeof sym` + */ + function serializeTypeForDeclaration(type: Type, symbol: Symbol) { + const declWithExistingAnnotation = getDeclarationWithTypeAnnotation(symbol); + if (declWithExistingAnnotation && !isFunctionLikeDeclaration(declWithExistingAnnotation)) { + // try to reuse the existing annotation + const existing = getEffectiveTypeAnnotationNode(declWithExistingAnnotation)!; + const transformed = visitNode(existing, visitExistingNodeTreeSymbols); + return transformed === existing ? getMutableClone(existing) : transformed; + } + const oldFlags = context.flags; + if (type.flags & TypeFlags.UniqueESSymbol && + type.symbol === symbol) { + context.flags |= NodeBuilderFlags.AllowUniqueESSymbolType; + } + const result = typeToTypeNodeHelper(type, context); + context.flags = oldFlags; + return result; + + function visitExistingNodeTreeSymbols(node: T): Node { + if (isJSDocAllType(node)) { + return createKeywordTypeNode(SyntaxKind.AnyKeyword); + } + if (isJSDocUnknownType(node)) { + return createKeywordTypeNode(SyntaxKind.UnknownKeyword); + } + if (isJSDocNullableType(node)) { + return createUnionTypeNode([visitNode(node.type, visitExistingNodeTreeSymbols), createKeywordTypeNode(SyntaxKind.NullKeyword)]); + } + if (isJSDocOptionalType(node)) { + return createUnionTypeNode([visitNode(node.type, visitExistingNodeTreeSymbols), createKeywordTypeNode(SyntaxKind.UndefinedKeyword)]); + } + if (isJSDocNonNullableType(node)) { + return visitNode(node.type, visitExistingNodeTreeSymbols); + } + if ((isExpressionWithTypeArguments(node) || isTypeReferenceNode(node)) && isJSDocIndexSignature(node)) { + return createTypeLiteralNode([createIndexSignature( + /*decorators*/ undefined, + /*modifiers*/ undefined, + [createParameter( + /*decorators*/ undefined, + /*modifiers*/ undefined, + /*dotdotdotToken*/ undefined, + "x", + /*questionToken*/ undefined, + visitNode(node.typeArguments![0], visitExistingNodeTreeSymbols) + )], + visitNode(node.typeArguments![1], visitExistingNodeTreeSymbols) + )]); + } + if (isJSDocFunctionType(node)) { + if (isJSDocConstructSignature(node)) { + let newTypeNode: TypeNode | undefined; + return createConstructorTypeNode( + visitNodes(node.typeParameters, visitExistingNodeTreeSymbols), + mapDefined(node.parameters, (p, i) => p.name && isIdentifier(p.name) && p.name.escapedText === "new" ? (newTypeNode = p.type, undefined) : createParameter( + /*decorators*/ undefined, + /*modifiers*/ undefined, + p.dotDotDotToken, + p.name || p.dotDotDotToken ? `args` : `arg${i}`, + p.questionToken, + visitNode(p.type, visitExistingNodeTreeSymbols), + /*initializer*/ undefined + )), + visitNode(newTypeNode || node.type, visitExistingNodeTreeSymbols) + ); + } + else { + return createFunctionTypeNode( + visitNodes(node.typeParameters, visitExistingNodeTreeSymbols), + map(node.parameters, (p, i) => createParameter( + /*decorators*/ undefined, + /*modifiers*/ undefined, + p.dotDotDotToken, + p.name || p.dotDotDotToken ? `args` : `arg${i}`, + p.questionToken, + visitNode(p.type, visitExistingNodeTreeSymbols), + /*initializer*/ undefined + )), + visitNode(node.type, visitExistingNodeTreeSymbols) + ); + } + } + if (isLiteralImportTypeNode(node)) { + return updateImportTypeNode( + node, + updateLiteralTypeNode(node.argument, rewriteModuleSpecifier(node, node.argument.literal)), + node.qualifier, + visitNodes(node.typeArguments, visitExistingNodeTreeSymbols, isTypeNode), + node.isTypeOf + ); + } + + if (isEntityName(node) || isEntityNameExpression(node)) { + const leftmost = getFirstIdentifier(node); + const sym = resolveEntityName(leftmost, SymbolFlags.All, /*ignoreErrors*/ true, /*dontResolveALias*/ true); + if (sym) { + includePrivateSymbol(sym); + if (isIdentifier(node) && sym.flags & SymbolFlags.TypeParameter) { + const name = typeParameterToName(getDeclaredTypeOfSymbol(sym), context); + if (idText(name) !== idText(node)) { + return name; + } + return node; + } + } + } + + return visitEachChild(node, visitExistingNodeTreeSymbols, nullTransformationContext); + } + + function rewriteModuleSpecifier(parent: ImportTypeNode, lit: StringLiteral) { + if (bundled) { + if (context.tracker && context.tracker.moduleResolverHost) { + const targetFile = getExternalModuleFileFromDeclaration(parent); + if (targetFile) { + const getCanonicalFileName = createGetCanonicalFileName(!!host.useCaseSensitiveFileNames); + const resolverHost = { + getCanonicalFileName, + getCurrentDirectory: context.tracker.moduleResolverHost.getCurrentDirectory ? () => context.tracker.moduleResolverHost!.getCurrentDirectory!() : () => "", + getCommonSourceDirectory: () => context.tracker.moduleResolverHost!.getCommonSourceDirectory() + }; + const newName = getResolvedExternalModuleName(resolverHost, targetFile); + return createLiteral(newName); + } + } + } + else { + if (context.tracker && context.tracker.trackExternalModuleSymbolOfImportTypeNode) { + const moduleSym = resolveExternalModuleNameWorker(lit, lit, /*moduleNotFoundError*/ undefined); + if (moduleSym) { + context.tracker.trackExternalModuleSymbolOfImportTypeNode(moduleSym); + } + } + } + return lit; + } + } + + function serializeSignatures(kind: SignatureKind, input: Type, baseType: Type | undefined, outputKind: SyntaxKind) { + const signatures = getSignaturesOfType(input, kind); + if (kind === SignatureKind.Construct) { + if (!baseType && every(signatures, s => length(s.parameters) === 0)) { + return []; // No base type, every constructor is empty - elide the extraneous `constructor()` + } + if (baseType) { + // If there is a base type, if every signature in the class is identical to a signature in the baseType, elide all the declarations + const baseSigs = getSignaturesOfType(baseType, SignatureKind.Construct); + if (!length(baseSigs) && every(signatures, s => length(s.parameters) === 0)) { + return []; // Base had no explicit signatures, if all our signatures are also implicit, return an empty list + } + if (baseSigs.length === signatures.length) { + let failed = false; + for (let i = 0; i < baseSigs.length; i++) { + if (!compareSignaturesIdentical(signatures[i], baseSigs[i], /*partialMatch*/ false, /*ignoreThisTypes*/ false, /*ignoreReturnTypes*/ true, compareTypesIdentical)) { + failed = true; + break; + } + } + if (!failed) { + return []; // Every signature was identical - elide constructor list as it is inherited + } + } + } + } + + const results = []; + for (const sig of signatures) { + // Each overload becomes a separate constructor declaration, in order + const decl = signatureToSignatureDeclarationHelper(sig, outputKind, context); + results.push(setTextRange(decl, sig.declaration)); + } + return results; + } + + function serializeIndexSignatures(input: Type, baseType: Type | undefined) { + const results: IndexSignatureDeclaration[] = []; + for (const type of [IndexKind.String, IndexKind.Number]) { + const info = getIndexInfoOfType(input, type); + if (info) { + if (baseType) { + const baseInfo = getIndexInfoOfType(baseType, type); + if (baseInfo) { + if (isTypeIdenticalTo(info.type, baseInfo.type)) { + continue; // elide identical index signatures + } + } + } + results.push(indexInfoToIndexSignatureDeclarationHelper(info, type, context)); + } + } + return results; + } + + function serializeBaseType(t: Type, staticType: Type, rootName: string) { + const ref = trySerializeAsTypeReference(t); + if (ref) { + return ref; + } + const tempName = getUnusedName(`${rootName}_base`); + const statement = createVariableStatement(/*modifiers*/ undefined, createVariableDeclarationList([ + createVariableDeclaration(tempName, typeToTypeNodeHelper(staticType, context)) + ], NodeFlags.Const)); + addResult(statement, ModifierFlags.None); + return createExpressionWithTypeArguments(/*typeArgs*/ undefined, createIdentifier(tempName)); + } + + function trySerializeAsTypeReference(t: Type) { + let typeArgs: TypeNode[] | undefined; + let reference: Expression | undefined; + // We don't use `isValueSymbolAccessible` below. since that considers alternative containers (like modules) + // which we can't write out in a syntactically valid way as an expression + if ((t as TypeReference).target && getAccessibleSymbolChain((t as TypeReference).target.symbol, enclosingDeclaration, SymbolFlags.Value, /*useOnlyExternalAliasing*/ false)) { + typeArgs = map(getTypeArguments(t as TypeReference), t => typeToTypeNodeHelper(t, context)); + reference = symbolToExpression((t as TypeReference).target.symbol, context, SymbolFlags.Type); + } + else if (t.symbol && getAccessibleSymbolChain(t.symbol, enclosingDeclaration, SymbolFlags.Value, /*useOnlyExternalAliasing*/ false)) { + reference = symbolToExpression(t.symbol, context, SymbolFlags.Type); + } + if (reference) { + return createExpressionWithTypeArguments(typeArgs, reference); + } + } + + function getUnusedName(input: string, symbol?: Symbol): string { + if (symbol) { + if (context.remappedSymbolNames!.has("" + getSymbolId(symbol))) { + return context.remappedSymbolNames!.get("" + getSymbolId(symbol))!; + } + } + if (input === InternalSymbolName.Default) { + input = "_default"; + } + else if (input === InternalSymbolName.ExportEquals) { + input = "_exports"; + } + let i = 0; + const original = input; + while (context.usedSymbolNames!.has(input)) { + i++; + input = `${original}_${i}`; + } + context.usedSymbolNames!.set(input, true); + if (symbol) { + context.remappedSymbolNames!.set("" + getSymbolId(symbol), input); + } + return input; + } + + function getInternalSymbolName(symbol: Symbol, localName: string) { + if (context.remappedSymbolNames!.has("" + getSymbolId(symbol))) { + return context.remappedSymbolNames!.get("" + getSymbolId(symbol))!; + } + if (localName === InternalSymbolName.Default || localName === InternalSymbolName.Class || localName === InternalSymbolName.Function) { + const flags = context.flags; + context.flags |= NodeBuilderFlags.InInitialEntityName; + const nameCandidate = getNameOfSymbolAsWritten(symbol, context); + context.flags = flags; + localName = isIdentifierText(nameCandidate, languageVersion) && !isStringANonContextualKeyword(nameCandidate) ? nameCandidate : getUnusedName(`_default`, symbol); + } + // The result of this is going to be used as the symbol's name - lock it in, so `getUnusedName` will also pick it up + context.remappedSymbolNames!.set("" + getSymbolId(symbol), localName); + return localName; + } + } } function typePredicateToString(typePredicate: TypePredicate, enclosingDeclaration?: Node, flags: TypeFormatFlags = TypeFormatFlags.UseAliasDefinedOutsideCurrentScope, writer?: EmitTextWriter): string { @@ -4820,6 +6136,8 @@ namespace ts { typeParameterSymbolList?: Map; typeParameterNames?: Map; typeParameterNamesByText?: Map; + usedSymbolNames?: Map; + remappedSymbolNames?: Map; } function isDefaultBindingContext(location: Node) { @@ -5011,7 +6329,10 @@ namespace ts { exportSymbol = getTargetOfExportSpecifier(node.parent, SymbolFlags.Value | SymbolFlags.Type | SymbolFlags.Namespace | SymbolFlags.Alias); } let result: Node[] | undefined; + let visited: Map | undefined; if (exportSymbol) { + visited = createMap(); + visited.set("" + getSymbolId(exportSymbol), true); buildVisibleNodeList(exportSymbol.declarations); } return result; @@ -5033,7 +6354,9 @@ namespace ts { const firstIdentifier = getFirstIdentifier(internalModuleReference); const importSymbol = resolveName(declaration, firstIdentifier.escapedText, SymbolFlags.Value | SymbolFlags.Type | SymbolFlags.Namespace, undefined, undefined, /*isUse*/ false); - if (importSymbol) { + const id = importSymbol && "" + getSymbolId(importSymbol); + if (importSymbol && !visited!.has(id!)) { + visited!.set(id!, true); buildVisibleNodeList(importSymbol.declarations); } } @@ -5483,7 +6806,7 @@ namespace ts { isPropertyAccessExpression(declaration) ? isBinaryExpression(declaration.parent) ? declaration.parent : declaration : undefined; if (!expression) { - return errorType; + continue; // Non-assignment declaration merged in (eg, an Identifier to mark the thing as a namespace) - skip over it and pull type info from elsewhere } const kind = isPropertyAccessExpression(expression) ? getAssignmentDeclarationPropertyAccessKind(expression) : getAssignmentDeclarationKind(expression); @@ -5504,6 +6827,9 @@ namespace ts { } let type = jsdocType; if (!type) { + if (!length(types)) { + return errorType; // No types from any declarations :( + } let constructorTypes = definedInConstructor ? getConstructorDefinedThisAssignmentTypes(types!, symbol.declarations) : undefined; // use only the constructor types unless they were only assigned null | undefined (including widening variants) if (definedInMethod) { @@ -5902,6 +7228,9 @@ namespace ts { else if (isEnumMember(declaration)) { type = getTypeOfEnumMember(symbol); } + else if (isAccessor(declaration)) { + type = resolveTypeOfAccessors(symbol); + } else { return Debug.fail("Unhandled declaration kind! " + Debug.formatSyntaxKind(declaration.kind) + " for " + Debug.formatSymbol(symbol)); } @@ -5950,6 +7279,23 @@ namespace ts { } function getTypeOfAccessorsWorker(symbol: Symbol): Type { + if (!pushTypeResolution(symbol, TypeSystemPropertyName.Type)) { + return errorType; + } + + let type = resolveTypeOfAccessors(symbol); + + if (!popTypeResolution()) { + type = anyType; + if (noImplicitAny) { + const getter = getDeclarationOfKind(symbol, SyntaxKind.GetAccessor); + error(getter, 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, symbolToString(symbol)); + } + } + return type; + } + + function resolveTypeOfAccessors(symbol: Symbol) { const getter = getDeclarationOfKind(symbol, SyntaxKind.GetAccessor); const setter = getDeclarationOfKind(symbol, SyntaxKind.SetAccessor); @@ -5959,28 +7305,21 @@ namespace ts { return jsDocType; } } - - if (!pushTypeResolution(symbol, TypeSystemPropertyName.Type)) { - return errorType; - } - - let type: Type; - // First try to see if the user specified a return type on the get-accessor. const getterReturnType = getAnnotatedAccessorType(getter); if (getterReturnType) { - type = getterReturnType; + return getterReturnType; } else { // If the user didn't specify a return type, try to use the set-accessor's parameter type. const setterParameterType = getAnnotatedAccessorType(setter); if (setterParameterType) { - type = setterParameterType; + return setterParameterType; } else { // If there are no specified types, try to infer it from the body of the get accessor if it exists. if (getter && getter.body) { - type = getReturnTypeFromBody(getter); + return getReturnTypeFromBody(getter); } // Otherwise, fall back to 'any'. else { @@ -5993,18 +7332,10 @@ namespace ts { Debug.assert(!!getter, "there must existed getter as we are current checking either setter or getter in this function"); errorOrSuggestion(noImplicitAny, getter!, Diagnostics.Property_0_implicitly_has_type_any_because_its_get_accessor_lacks_a_return_type_annotation, symbolToString(symbol)); } - type = anyType; + return anyType; } } } - if (!popTypeResolution()) { - type = anyType; - if (noImplicitAny) { - const getter = getDeclarationOfKind(symbol, SyntaxKind.GetAccessor); - error(getter, 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, symbolToString(symbol)); - } - } - return type; } function getBaseTypeVariableOfClass(symbol: Symbol) { @@ -23470,7 +24801,7 @@ namespace ts { // resolveExternalModuleName will return undefined if the moduleReferenceExpression is not a string literal const moduleSymbol = resolveExternalModuleName(node, specifier); if (moduleSymbol) { - const esModuleSymbol = resolveESModuleSymbol(moduleSymbol, specifier, /*dontRecursivelyResolve*/ true); + const esModuleSymbol = resolveESModuleSymbol(moduleSymbol, specifier, /*dontRecursivelyResolve*/ true, /*suppressUsageError*/ false); if (esModuleSymbol) { return createPromiseReturnType(node, getTypeWithSyntheticDefaultImportType(getTypeOfSymbol(esModuleSymbol), esModuleSymbol, moduleSymbol)); } @@ -30581,6 +31912,26 @@ namespace ts { } } + function getFirstNonModuleExportsIdentifier(node: EntityNameOrEntityNameExpression): Identifier { + switch (node.kind) { + case SyntaxKind.Identifier: + return node; + case SyntaxKind.QualifiedName: + do { + node = node.left; + } while (node.kind !== SyntaxKind.Identifier); + return node; + case SyntaxKind.PropertyAccessExpression: + do { + if (isModuleExportsPropertyAccessExpression(node.expression)) { + return node.name; + } + node = node.expression; + } while (node.kind !== SyntaxKind.Identifier); + return node; + } + } + function checkExternalImportOrExportDeclaration(node: ImportDeclaration | ImportEqualsDeclaration | ExportDeclaration): boolean { const moduleName = getExternalModuleName(node); if (!moduleName || nodeIsMissing(moduleName)) { @@ -32566,6 +33917,15 @@ namespace ts { const parseNode = getParseTreeNode(node); const parseDecl = getParseTreeNode(decl); return !!parseNode && !!parseDecl && (isVariableDeclaration(parseDecl) || isBindingElement(parseDecl)) && isBindingCapturedByNode(parseNode, parseDecl); + }, + getDeclarationStatementsForSourceFile: (node, flags, tracker, bundled) => { + const n = getParseTreeNode(node) as SourceFile; + Debug.assert(n && n.kind === SyntaxKind.SourceFile, "Non-sourcefile node passed into getDeclarationsForSourceFile"); + const sym = getSymbolOfNode(node); + if (!sym) { + return !node.locals ? [] : nodeBuilder.symbolTableToDeclarationStatements(node.locals, node, flags, tracker, bundled); + } + return !sym.exports ? [] : nodeBuilder.symbolTableToDeclarationStatements(sym.exports, node, flags, tracker, bundled); } }; diff --git a/src/compiler/core.ts b/src/compiler/core.ts index 73e0261670fd5..8703f3de8f7c2 100644 --- a/src/compiler/core.ts +++ b/src/compiler/core.ts @@ -1552,6 +1552,14 @@ namespace ts { return fn ? fn.bind(obj) : undefined; } + export function mapMap(map: Map, f: (t: T, key: string) => [string, U]): Map; + export function mapMap(map: UnderscoreEscapedMap, f: (t: T, key: __String) => [string, U]): Map; + export function mapMap(map: Map | UnderscoreEscapedMap, f: ((t: T, key: string) => [string, U]) | ((t: T, key: __String) => [string, U])): Map { + const result = createMap(); + map.forEach((t: T, key: string & __String) => result.set(...(f(t, key)))); + return result; + } + export interface MultiMap extends Map { /** * Adds the value to an array of values associated with the key, and returns the array. diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index 78700a9476cef..6e8617d59389b 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -4587,6 +4587,14 @@ "category": "Error", "code": 9004 }, + "Declaration emit for this file requires using private name '{0}'. An explicit type annotation may unblock declaration emit.": { + "category": "Error", + "code": 9005 + }, + "Declaration emit for this file requires using private name '{0}' from module '{1}'. An explicit type annotation may unblock declaration emit.": { + "category": "Error", + "code": 9006 + }, "JSX attributes must only be assigned a non-empty 'expression'.": { "category": "Error", "code": 17000 diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index 2ed08f29e212c..36a70ec7d2562 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -96,9 +96,7 @@ namespace ts { comparePaths(sourceFile.fileName, ownOutputFilePath, host.getCurrentDirectory(), !host.useCaseSensitiveFileNames()) === Comparison.EqualTo; const jsFilePath = options.emitDeclarationOnly || isJsonEmittedToSameLocation ? undefined : ownOutputFilePath; const sourceMapFilePath = !jsFilePath || isJsonSourceFile(sourceFile) ? undefined : getSourceMapFilePath(jsFilePath, options); - // For legacy reasons (ie, we have baselines capturing the behavior), js files don't report a .d.ts output path - this would only matter if `declaration` and `allowJs` were both on, which is currently an error - const isJs = isSourceFileJS(sourceFile); - const declarationFilePath = ((forceDtsPaths || getEmitDeclarations(options)) && !isJs) ? getDeclarationEmitOutputFilePath(sourceFile.fileName, host) : undefined; + const declarationFilePath = (forceDtsPaths || getEmitDeclarations(options)) ? getDeclarationEmitOutputFilePath(sourceFile.fileName, host) : undefined; const declarationMapPath = declarationFilePath && getAreDeclarationMapsEnabled(options) ? declarationFilePath + ".map" : undefined; return { jsFilePath, sourceMapFilePath, declarationFilePath, declarationMapPath, buildInfoPath: undefined }; } @@ -146,7 +144,7 @@ namespace ts { /* @internal */ export function getOutputDeclarationFileName(inputFileName: string, configFile: ParsedCommandLine, ignoreCase: boolean) { - Debug.assert(!fileExtensionIs(inputFileName, Extension.Dts) && hasTSFileExtension(inputFileName)); + Debug.assert(!fileExtensionIs(inputFileName, Extension.Dts)); return changeExtension( getOutputPathWithoutChangingExt(inputFileName, configFile, ignoreCase, configFile.options.declarationDir || configFile.options.outDir), Extension.Dts @@ -199,7 +197,7 @@ namespace ts { if (js && configFile.options.sourceMap) { addOutput(`${js}.map`); } - if (getEmitDeclarations(configFile.options) && hasTSFileExtension(inputFileName)) { + if (getEmitDeclarations(configFile.options)) { const dts = getOutputDeclarationFileName(inputFileName, configFile, ignoreCase); addOutput(dts); if (configFile.options.declarationMap) { @@ -248,7 +246,7 @@ namespace ts { const jsFilePath = getOutputJSFileName(inputFileName, configFile, ignoreCase); if (jsFilePath) return jsFilePath; if (fileExtensionIs(inputFileName, Extension.Json)) continue; - if (getEmitDeclarations(configFile.options) && hasTSFileExtension(inputFileName)) { + if (getEmitDeclarations(configFile.options)) { return getOutputDeclarationFileName(inputFileName, configFile, ignoreCase); } } @@ -395,17 +393,16 @@ namespace ts { declarationFilePath: string | undefined, declarationMapPath: string | undefined, relativeToBuildInfo: (path: string) => string) { - if (!sourceFileOrBundle || !(declarationFilePath && !isInJSFile(sourceFileOrBundle))) { + if (!sourceFileOrBundle || !declarationFilePath) { return; } const sourceFiles = isSourceFile(sourceFileOrBundle) ? [sourceFileOrBundle] : sourceFileOrBundle.sourceFiles; // Setup and perform the transformation to retrieve declarations from the input files - const nonJsFiles = filter(sourceFiles, isSourceFileNotJS); - const inputListOrBundle = (compilerOptions.outFile || compilerOptions.out) ? [createBundle(nonJsFiles, !isSourceFile(sourceFileOrBundle) ? sourceFileOrBundle.prepends : undefined)] : nonJsFiles; + const inputListOrBundle = (compilerOptions.outFile || compilerOptions.out) ? [createBundle(sourceFiles, !isSourceFile(sourceFileOrBundle) ? sourceFileOrBundle.prepends : undefined)] : sourceFiles; if (emitOnlyDtsFiles && !getEmitDeclarations(compilerOptions)) { // Checker wont collect the linked aliases since thats only done when declaration is enabled. // Do that here when emitting only dts files - nonJsFiles.forEach(collectLinkedAliases); + sourceFiles.forEach(collectLinkedAliases); } const declarationTransform = transformNodes(resolver, host, compilerOptions, inputListOrBundle, declarationTransformers, /*allowDtsFiles*/ false); if (length(declarationTransform.diagnostics)) { @@ -659,6 +656,7 @@ namespace ts { getAllAccessorDeclarations: notImplemented, getSymbolOfExternalModuleSpecifier: notImplemented, isBindingCapturedByNode: notImplemented, + getDeclarationStatementsForSourceFile: notImplemented, }; /*@internal*/ diff --git a/src/compiler/factory.ts b/src/compiler/factory.ts index a4f780185e91e..95220fec0be62 100644 --- a/src/compiler/factory.ts +++ b/src/compiler/factory.ts @@ -2259,6 +2259,11 @@ namespace ts { : node; } + /* @internal */ + export function createEmptyExports() { + return createExportDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, createNamedExports([]), /*moduleSpecifier*/ undefined); + } + export function createNamedExports(elements: readonly ExportSpecifier[]) { const node = createSynthesizedNode(SyntaxKind.NamedExports); node.elements = createNodeArray(elements); diff --git a/src/compiler/program.ts b/src/compiler/program.ts index 9bc91e423a4f2..98e7a96442c11 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -856,7 +856,7 @@ namespace ts { } else if (getEmitModuleKind(parsedRef.commandLine.options) === ModuleKind.None) { for (const fileName of parsedRef.commandLine.fileNames) { - if (!fileExtensionIs(fileName, Extension.Dts) && hasTSFileExtension(fileName)) { + if (!fileExtensionIs(fileName, Extension.Dts)) { processSourceFile(getOutputDeclarationFileName(fileName, parsedRef.commandLine, !host.useCaseSensitiveFileNames()), /*isDefaultLib*/ false, /*ignoreNoDefaultLib*/ false, /*packageId*/ undefined); } } @@ -2448,8 +2448,8 @@ namespace ts { } function getProjectReferenceRedirectProject(fileName: string) { - // Ignore dts or any of the non ts files - if (!resolvedProjectReferences || !resolvedProjectReferences.length || fileExtensionIs(fileName, Extension.Dts) || !fileExtensionIsOneOf(fileName, supportedTSExtensions)) { + // Ignore dts + if (!resolvedProjectReferences || !resolvedProjectReferences.length || fileExtensionIs(fileName, Extension.Dts)) { return undefined; } @@ -2510,7 +2510,7 @@ namespace ts { } else { forEach(resolvedRef.commandLine.fileNames, fileName => { - if (!fileExtensionIs(fileName, Extension.Dts) && hasTSFileExtension(fileName)) { + if (!fileExtensionIs(fileName, Extension.Dts)) { const outputDts = getOutputDeclarationFileName(fileName, resolvedRef.commandLine, host.useCaseSensitiveFileNames()); mapFromToProjectReferenceRedirectSource!.set(toPath(outputDts), fileName); } @@ -3077,10 +3077,6 @@ namespace ts { createDiagnosticForOptionName(Diagnostics.Option_0_cannot_be_specified_when_option_target_is_ES3, "useDefineForClassFields"); } - if (!options.noEmit && options.allowJs && getEmitDeclarations(options)) { - createDiagnosticForOptionName(Diagnostics.Option_0_cannot_be_specified_with_option_1, "allowJs", getEmitDeclarationOptionName(options)); - } - if (options.checkJs && !options.allowJs) { programDiagnostics.add(createCompilerDiagnostic(Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "checkJs", "allowJs")); } @@ -3425,9 +3421,6 @@ namespace ts { return resolveConfigFileProjectName(passedInRef.path); } - function getEmitDeclarationOptionName(options: CompilerOptions) { - return options.declaration ? "declaration" : "composite"; - } /* @internal */ /** * Returns a DiagnosticMessage if we won't include a resolved module due to its extension. diff --git a/src/compiler/transformers/declarations.ts b/src/compiler/transformers/declarations.ts index add17449edf3d..6d6016fe109ae 100644 --- a/src/compiler/transformers/declarations.ts +++ b/src/compiler/transformers/declarations.ts @@ -1,11 +1,8 @@ /*@internal*/ namespace ts { export function getDeclarationDiagnostics(host: EmitHost, resolver: EmitResolver, file: SourceFile | undefined): DiagnosticWithLocation[] | undefined { - if (file && isSourceFileJS(file)) { - return []; // No declaration diagnostics for js for now - } const compilerOptions = host.getCompilerOptions(); - const result = transformNodes(resolver, host, compilerOptions, file ? [file] : filter(host.getSourceFiles(), isSourceFileNotJS), [transformDeclarations], /*allowDtsFiles*/ false); + const result = transformNodes(resolver, host, compilerOptions, file ? [file] : host.getSourceFiles(), [transformDeclarations], /*allowDtsFiles*/ false); return result.diagnostics; } @@ -190,15 +187,24 @@ namespace ts { } } - function createEmptyExports() { - return createExportDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, createNamedExports([]), /*moduleSpecifier*/ undefined); + function transformDeclarationsForJS(sourceFile: SourceFile, bundled?: boolean) { + const oldDiag = getSymbolAccessibilityDiagnostic; + getSymbolAccessibilityDiagnostic = (s) => ({ + diagnosticMessage: s.errorModuleName + ? Diagnostics.Declaration_emit_for_this_file_requires_using_private_name_0_from_module_1_An_explicit_type_annotation_may_unblock_declaration_emit + : Diagnostics.Declaration_emit_for_this_file_requires_using_private_name_0_An_explicit_type_annotation_may_unblock_declaration_emit, + errorNode: s.errorNode || sourceFile + }); + const result = resolver.getDeclarationStatementsForSourceFile(sourceFile, declarationEmitNodeBuilderFlags, symbolTracker, bundled); + getSymbolAccessibilityDiagnostic = oldDiag; + return result; } function transformRoot(node: Bundle): Bundle; function transformRoot(node: SourceFile): SourceFile; function transformRoot(node: SourceFile | Bundle): SourceFile | Bundle; function transformRoot(node: SourceFile | Bundle) { - if (node.kind === SyntaxKind.SourceFile && (node.isDeclarationFile || isSourceFileJS(node))) { + if (node.kind === SyntaxKind.SourceFile && node.isDeclarationFile) { return node; } @@ -209,7 +215,7 @@ namespace ts { let hasNoDefaultLib = false; const bundle = createBundle(map(node.sourceFiles, sourceFile => { - if (sourceFile.isDeclarationFile || isSourceFileJS(sourceFile)) return undefined!; // Omit declaration files from bundle results, too // TODO: GH#18217 + if (sourceFile.isDeclarationFile) return undefined!; // Omit declaration files from bundle results, too // TODO: GH#18217 hasNoDefaultLib = hasNoDefaultLib || sourceFile.hasNoDefaultLib; currentSourceFile = sourceFile; enclosingDeclaration = sourceFile; @@ -221,10 +227,10 @@ namespace ts { resultHasScopeMarker = false; collectReferences(sourceFile, refs); collectLibs(sourceFile, libs); - if (isExternalModule(sourceFile)) { + if (isExternalOrCommonJsModule(sourceFile) || isJsonSourceFile(sourceFile)) { resultHasExternalModuleIndicator = false; // unused in external module bundle emit (all external modules are within module blocks, therefore are known to be modules) needsDeclare = false; - const statements = visitNodes(sourceFile.statements, visitDeclarationStatements); + const statements = isSourceFileJS(sourceFile) ? createNodeArray(transformDeclarationsForJS(sourceFile, /*bundled*/ true)) : visitNodes(sourceFile.statements, visitDeclarationStatements); const newFile = updateSourceFileNode(sourceFile, [createModuleDeclaration( [], [createModifier(SyntaxKind.DeclareKeyword)], @@ -234,7 +240,7 @@ namespace ts { return newFile; } needsDeclare = true; - const updated = visitNodes(sourceFile.statements, visitDeclarationStatements); + const updated = isSourceFileJS(sourceFile) ? createNodeArray(transformDeclarationsForJS(sourceFile)) : visitNodes(sourceFile.statements, visitDeclarationStatements); return updateSourceFileNode(sourceFile, transformAndReplaceLatePaintedStatements(updated), /*isDeclarationFile*/ true, /*referencedFiles*/ [], /*typeReferences*/ [], /*hasNoDefaultLib*/ false, /*libReferences*/ []); } ), mapDefined(node.prepends, prepend => { @@ -276,12 +282,19 @@ namespace ts { const references: FileReference[] = []; const outputFilePath = getDirectoryPath(normalizeSlashes(getOutputPathsFor(node, host, /*forceDtsPaths*/ true).declarationFilePath!)); const referenceVisitor = mapReferencesIntoArray(references, outputFilePath); - const statements = visitNodes(node.statements, visitDeclarationStatements); - let combinedStatements = setTextRange(createNodeArray(transformAndReplaceLatePaintedStatements(statements)), node.statements); - refs.forEach(referenceVisitor); - emittedImports = filter(combinedStatements, isAnyImportSyntax); - if (isExternalModule(node) && (!resultHasExternalModuleIndicator || (needsScopeFixMarker && !resultHasScopeMarker))) { - combinedStatements = setTextRange(createNodeArray([...combinedStatements, createEmptyExports()]), combinedStatements); + let combinedStatements: NodeArray; + if (isSourceFileJS(currentSourceFile)) { + combinedStatements = createNodeArray(transformDeclarationsForJS(node)); + emittedImports = filter(combinedStatements, isAnyImportSyntax); + } + else { + const statements = visitNodes(node.statements, visitDeclarationStatements); + combinedStatements = setTextRange(createNodeArray(transformAndReplaceLatePaintedStatements(statements)), node.statements); + refs.forEach(referenceVisitor); + emittedImports = filter(combinedStatements, isAnyImportSyntax); + if (isExternalModule(node) && (!resultHasExternalModuleIndicator || (needsScopeFixMarker && !resultHasScopeMarker))) { + combinedStatements = setTextRange(createNodeArray([...combinedStatements, createEmptyExports()]), combinedStatements); + } } const updated = updateSourceFileNode(node, combinedStatements, /*isDeclarationFile*/ true, references, getFileReferencesForUsedTypeReferences(), node.hasNoDefaultLib, getLibReferences()); updated.exportedModulesFromDeclarationEmit = exportedModulesFromDeclarationEmit; @@ -755,15 +768,6 @@ namespace ts { } } - function isExternalModuleIndicator(result: LateVisibilityPaintedStatement | ExportAssignment) { - // Exported top-level member indicates moduleness - return isAnyImportOrReExport(result) || isExportAssignment(result) || hasModifier(result, ModifierFlags.Export); - } - - function needsScopeMarker(result: LateVisibilityPaintedStatement | ExportAssignment) { - return !isAnyImportOrReExport(result) && !isExportAssignment(result) && !hasModifier(result, ModifierFlags.Export) && !isAmbientModule(result); - } - function visitDeclarationSubtree(input: Node): VisitResult { if (shouldStripInternal(input)) return; if (isDeclaration(input)) { diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 28d5fdbb1c967..73d3785d28643 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -3734,6 +3734,7 @@ namespace ts { getAllAccessorDeclarations(declaration: AccessorDeclaration): AllAccessorDeclarations; getSymbolOfExternalModuleSpecifier(node: StringLiteralLike): Symbol | undefined; isBindingCapturedByNode(node: Node, decl: VariableDeclaration | BindingElement): boolean; + getDeclarationStatementsForSourceFile(node: SourceFile, flags: NodeBuilderFlags, tracker: SymbolTracker, bundled?: boolean): Statement[] | undefined; } export const enum SymbolFlags { @@ -3814,6 +3815,12 @@ namespace ts { ClassMember = Method | Accessor | Property, + /* @internal */ + ExportSupportsDefaultModifier = Class | Function | Interface, + + /* @internal */ + ExportDoesNotSupportDefaultModifier = ~ExportSupportsDefaultModifier, + /* @internal */ // The set of things we consider semantically classifiable. Used to speed up the LS during // classification. @@ -3877,6 +3884,7 @@ namespace ts { variances?: VarianceFlags[]; // Alias symbol type argument variance cache deferralConstituents?: Type[]; // Calculated list of constituents for a deferred type deferralParent?: Type; // Source union/intersection of a deferred type + cjsExportMerged?: Symbol; // Version of the symbol with all non export= exports merged with the export= target } /* @internal */ @@ -6024,7 +6032,7 @@ namespace ts { // Called when the symbol writer encounters a symbol to write. Currently only used by the // declaration emitter to help determine if it should patch up the final declaration file // with import statements it previously saw (but chose not to emit). - trackSymbol?(symbol: Symbol, enclosingDeclaration?: Node, meaning?: SymbolFlags): void; + trackSymbol?(symbol: Symbol, enclosingDeclaration: Node | undefined, meaning: SymbolFlags): void; reportInaccessibleThisError?(): void; reportPrivateInBaseOfClassExpression?(propertyName: string): void; reportInaccessibleUniqueSymbolError?(): void; diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index a00b7c2d7ad97..bc3f886e9e463 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -2606,6 +2606,8 @@ namespace ts { // export = // export default // module.exports = + // {} + // {name: } export function isAliasSymbolDeclaration(node: Node): boolean { return node.kind === SyntaxKind.ImportEqualsDeclaration || node.kind === SyntaxKind.NamespaceExportDeclaration || @@ -2614,14 +2616,30 @@ namespace ts { node.kind === SyntaxKind.ImportSpecifier || node.kind === SyntaxKind.ExportSpecifier || node.kind === SyntaxKind.ExportAssignment && exportAssignmentIsAlias(node) || - isBinaryExpression(node) && getAssignmentDeclarationKind(node) === AssignmentDeclarationKind.ModuleExports && exportAssignmentIsAlias(node); + isBinaryExpression(node) && getAssignmentDeclarationKind(node) === AssignmentDeclarationKind.ModuleExports && exportAssignmentIsAlias(node) || + isPropertyAccessExpression(node) && isBinaryExpression(node.parent) && node.parent.left === node && node.parent.operatorToken.kind === SyntaxKind.EqualsToken && isAliasableExpression(node.parent.right) || + node.kind === SyntaxKind.ShorthandPropertyAssignment || + node.kind === SyntaxKind.PropertyAssignment && isAliasableExpression((node as PropertyAssignment).initializer); } - export function exportAssignmentIsAlias(node: ExportAssignment | BinaryExpression): boolean { - const e = isExportAssignment(node) ? node.expression : node.right; + function isAliasableExpression(e: Expression) { return isEntityNameExpression(e) || isClassExpression(e); } + export function exportAssignmentIsAlias(node: ExportAssignment | BinaryExpression): boolean { + const e = getExportAssignmentExpression(node); + return isAliasableExpression(e); + } + + export function getExportAssignmentExpression(node: ExportAssignment | BinaryExpression): Expression { + return isExportAssignment(node) ? node.expression : node.right; + } + + export function getPropertyAssignmentAliasLikeExpression(node: PropertyAssignment | ShorthandPropertyAssignment | PropertyAccessExpression): Expression { + return node.kind === SyntaxKind.ShorthandPropertyAssignment ? node.name : node.kind === SyntaxKind.PropertyAssignment ? node.initializer : + (node.parent as BinaryExpression).right; + } + export function getEffectiveBaseTypeNode(node: ClassLikeDeclaration | InterfaceDeclaration) { const baseType = getClassExtendsHeritageElement(node); if (baseType && isInJSFile(node)) { @@ -2699,6 +2717,11 @@ namespace ts { return token !== undefined && isNonContextualKeyword(token); } + export function isStringAKeyword(name: string) { + const token = stringToToken(name); + return token !== undefined && isKeyword(token); + } + export function isIdentifierANonContextualKeyword({ originalKeywordKind }: Identifier): boolean { return !!originalKeywordKind && !isContextualKeyword(originalKeywordKind); } @@ -3450,11 +3473,17 @@ namespace ts { }; } - export function getResolvedExternalModuleName(host: EmitHost, file: SourceFile, referenceFile?: SourceFile): string { + export interface ResolveModuleNameResolutionHost { + getCanonicalFileName(p: string): string; + getCommonSourceDirectory(): string; + getCurrentDirectory(): string; + } + + export function getResolvedExternalModuleName(host: ResolveModuleNameResolutionHost, file: SourceFile, referenceFile?: SourceFile): string { return file.moduleName || getExternalModuleNameFromPath(host, file.fileName, referenceFile && referenceFile.fileName); } - export function getExternalModuleNameFromDeclaration(host: EmitHost, resolver: EmitResolver, declaration: ImportEqualsDeclaration | ImportDeclaration | ExportDeclaration | ModuleDeclaration | ImportTypeNode): string | undefined { + export function getExternalModuleNameFromDeclaration(host: ResolveModuleNameResolutionHost, resolver: EmitResolver, declaration: ImportEqualsDeclaration | ImportDeclaration | ExportDeclaration | ModuleDeclaration | ImportTypeNode): string | undefined { const file = resolver.getExternalModuleFileFromDeclaration(declaration); if (!file || file.isDeclarationFile) { return undefined; @@ -3465,7 +3494,7 @@ namespace ts { /** * Resolves a local path to a path which is absolute to the base of the emit */ - export function getExternalModuleNameFromPath(host: EmitHost, fileName: string, referencePath?: string): string { + export function getExternalModuleNameFromPath(host: ResolveModuleNameResolutionHost, fileName: string, referencePath?: string): string { const getCanonicalFileName = (f: string) => host.getCanonicalFileName(f); const dir = toPath(referencePath ? getDirectoryPath(referencePath) : host.getCommonSourceDirectory(), host.getCurrentDirectory(), getCanonicalFileName); const filePath = getNormalizedAbsolutePath(fileName, host.getCurrentDirectory()); @@ -5224,6 +5253,17 @@ namespace ts { return name && isIdentifier(name) ? name : undefined; } + /** @internal */ + export function nodeHasName(statement: Node, name: Identifier) { + if (isNamedDeclaration(statement) && isIdentifier(statement.name) && idText(statement.name as Identifier) === idText(name)) { + return true; + } + if (isVariableStatement(statement) && some(statement.declarationList.declarations, d => nodeHasName(d, name))) { + return true; + } + return false; + } + export function getNameOfJSDocTypedef(declaration: JSDocTypedefTag): Identifier | undefined { return declaration.name || nameForNamelessJSDocTypedef(declaration); } @@ -6145,7 +6185,7 @@ namespace ts { return node.kind === SyntaxKind.JSDocTypeExpression; } - export function isJSDocAllType(node: JSDocAllType): node is JSDocAllType { + export function isJSDocAllType(node: Node): node is JSDocAllType { return node.kind === SyntaxKind.JSDocAllType; } @@ -6762,6 +6802,27 @@ namespace ts { return false; } + /* @internal */ + export function isScopeMarker(node: Node) { + return isExportAssignment(node) || isExportDeclaration(node); + } + + /* @internal */ + export function hasScopeMarker(statements: readonly Statement[]) { + return some(statements, isScopeMarker); + } + + /* @internal */ + export function needsScopeMarker(result: Statement) { + return !isAnyImportOrReExport(result) && !isExportAssignment(result) && !hasModifier(result, ModifierFlags.Export) && !isAmbientModule(result); + } + + /* @internal */ + export function isExternalModuleIndicator(result: Statement) { + // Exported top-level member indicates moduleness + return isAnyImportOrReExport(result) || isExportAssignment(result) || hasModifier(result, ModifierFlags.Export); + } + /* @internal */ export function isForInOrOfStatement(node: Node): node is ForInOrOfStatement { return node.kind === SyntaxKind.ForInStatement || node.kind === SyntaxKind.ForOfStatement; diff --git a/src/harness/compiler.ts b/src/harness/compiler.ts index 880163a10f631..19d6545c999fa 100644 --- a/src/harness/compiler.ts +++ b/src/harness/compiler.ts @@ -219,14 +219,19 @@ namespace compiler { return vpath.changeExtension(path, ext); } - public getNumberOfJsFiles() { - let count = this.js.size; - this.js.forEach(document => { - if (ts.fileExtensionIs(document.file, ts.Extension.Json)) { - count--; - } - }); - return count; + public getNumberOfJsFiles(includeJson: boolean) { + if (includeJson) { + return this.js.size; + } + else { + let count = this.js.size; + this.js.forEach(document => { + if (ts.fileExtensionIs(document.file, ts.Extension.Json)) { + count--; + } + }); + return count; + } } } diff --git a/src/harness/harness.ts b/src/harness/harness.ts index 35af677836347..e93033e126bdc 100644 --- a/src/harness/harness.ts +++ b/src/harness/harness.ts @@ -888,7 +888,7 @@ namespace Harness { throw new Error("Only declaration files should be generated when emitDeclarationOnly:true"); } } - else if (result.dts.size !== result.getNumberOfJsFiles()) { + else if (result.dts.size !== result.getNumberOfJsFiles(/*includeJson*/ true)) { throw new Error("There were no errors and declFiles generated did not match number of js files generated"); } } @@ -907,7 +907,7 @@ namespace Harness { if (vpath.isDeclaration(file.unitName) || vpath.isJson(file.unitName)) { dtsFiles.push(file); } - else if (vpath.isTypeScript(file.unitName)) { + else if (vpath.isTypeScript(file.unitName) || (vpath.isJavaScript(file.unitName) && options.allowJs)) { const declFile = findResultCodeFile(file.unitName); if (declFile && !findUnit(declFile.file, declInputFiles) && !findUnit(declFile.file, declOtherFiles)) { dtsFiles.push({ unitName: declFile.file, content: utils.removeByteOrderMark(declFile.text) }); @@ -1269,7 +1269,7 @@ namespace Harness { return; } else if (options.sourceMap || declMaps) { - if (result.maps.size !== (result.getNumberOfJsFiles() * (declMaps && options.sourceMap ? 2 : 1))) { + if (result.maps.size !== ((options.sourceMap ? result.getNumberOfJsFiles(/*includeJson*/ false) : 0) + (declMaps ? result.getNumberOfJsFiles(/*includeJson*/ true) : 0))) { throw new Error("Number of sourcemap files should be same as js files."); } diff --git a/src/services/utilities.ts b/src/services/utilities.ts index 5f59cef602bb3..18b867fbe0f92 100644 --- a/src/services/utilities.ts +++ b/src/services/utilities.ts @@ -1971,8 +1971,7 @@ namespace ts { const notAccessible = () => { typeIsAccessible = false; }; const res = checker.typeToTypeNode(type, enclosingScope, /*flags*/ undefined, { trackSymbol: (symbol, declaration, meaning) => { - // TODO: GH#18217 - typeIsAccessible = typeIsAccessible && checker.isSymbolAccessible(symbol, declaration, meaning!, /*shouldComputeAliasToMarkVisible*/ false).accessibility === SymbolAccessibility.Accessible; + typeIsAccessible = typeIsAccessible && checker.isSymbolAccessible(symbol, declaration, meaning, /*shouldComputeAliasToMarkVisible*/ false).accessibility === SymbolAccessibility.Accessible; }, reportInaccessibleThisError: notAccessible, reportPrivateInBaseOfClassExpression: notAccessible, diff --git a/src/testRunner/tsconfig.json b/src/testRunner/tsconfig.json index 49272d6c1b3cc..28f2af9eeb9f6 100644 --- a/src/testRunner/tsconfig.json +++ b/src/testRunner/tsconfig.json @@ -99,6 +99,7 @@ "unittests/tsbuild/emptyFiles.ts", "unittests/tsbuild/graphOrdering.ts", "unittests/tsbuild/inferredTypeFromTransitiveModule.ts", + "unittests/tsbuild/javascriptProjectEmit.ts", "unittests/tsbuild/lateBoundSymbol.ts", "unittests/tsbuild/missingExtendedFile.ts", "unittests/tsbuild/moduleSpecifiers.ts", diff --git a/src/testRunner/unittests/tsbuild/javascriptProjectEmit.ts b/src/testRunner/unittests/tsbuild/javascriptProjectEmit.ts new file mode 100644 index 0000000000000..fb580a14d45ad --- /dev/null +++ b/src/testRunner/unittests/tsbuild/javascriptProjectEmit.ts @@ -0,0 +1,286 @@ +namespace ts { + describe("unittests:: tsbuild:: javascriptProjectEmit:: loads js-based projects and emits them correctly", () => { + verifyTsc({ + scenario: "javascriptProjectEmit", + subScenario: `loads js-based projects and emits them correctly`, + fs: () => loadProjectFromFiles({ + "/src/common/nominal.js": utils.dedent` + /** + * @template T, Name + * @typedef {T & {[Symbol.species]: Name}} Nominal + */ + module.exports = {}; + `, + "/src/common/tsconfig.json": utils.dedent` + { + "extends": "../tsconfig.base.json", + "compilerOptions": { + "composite": true + }, + "include": ["nominal.js"] + }`, + "/src/sub-project/index.js": utils.dedent` + import { Nominal } from '../common/nominal'; + + /** + * @typedef {Nominal} MyNominal + */ + `, + "/src/sub-project/tsconfig.json": utils.dedent` + { + "extends": "../tsconfig.base.json", + "compilerOptions": { + "composite": true + }, + "references": [ + { "path": "../common" } + ], + "include": ["./index.js"] + }`, + "/src/sub-project-2/index.js": utils.dedent` + import { MyNominal } from '../sub-project/index'; + + const variable = { + key: /** @type {MyNominal} */('value'), + }; + + /** + * @return {keyof typeof variable} + */ + export function getVar() { + return 'key'; + } + `, + "/src/sub-project-2/tsconfig.json": utils.dedent` + { + "extends": "../tsconfig.base.json", + "compilerOptions": { + "composite": true + }, + "references": [ + { "path": "../sub-project" } + ], + "include": ["./index.js"] + }`, + "/src/tsconfig.json": utils.dedent` + { + "compilerOptions": { + "composite": true + }, + "references": [ + { "path": "./sub-project" }, + { "path": "./sub-project-2" } + ], + "include": [] + }`, + "/src/tsconfig.base.json": utils.dedent` + { + "compilerOptions": { + "skipLibCheck": true, + "rootDir": "./", + "outDir": "../lib", + "allowJs": true, + "checkJs": true, + "declaration": true + } + }`, + }, symbolLibContent), + commandLineArgs: ["-b", "/src"] + }); + }); + + describe("unittests:: tsbuild:: javascriptProjectEmit:: loads outfile js projects and concatenates them correctly", () => { + let projFs: vfs.FileSystem; + before(() => { + projFs = loadProjectFromFiles({ + "/src/common/nominal.js": utils.dedent` + /** + * @template T, Name + * @typedef {T & {[Symbol.species]: Name}} Nominal + */ + `, + "/src/common/tsconfig.json": utils.dedent` + { + "extends": "../tsconfig.base.json", + "compilerOptions": { + "composite": true, + "outFile": "common.js" + }, + "include": ["nominal.js"] + }`, + "/src/sub-project/index.js": utils.dedent` + /** + * @typedef {Nominal} MyNominal + */ + const c = /** @type {*} */(null); + `, + "/src/sub-project/tsconfig.json": utils.dedent` + { + "extends": "../tsconfig.base.json", + "compilerOptions": { + "composite": true, + "outFile": "sub-project.js" + }, + "references": [ + { "path": "../common", "prepend": true } + ], + "include": ["./index.js"] + }`, + "/src/sub-project-2/index.js": utils.dedent` + const variable = { + key: /** @type {MyNominal} */('value'), + }; + + /** + * @return {keyof typeof variable} + */ + function getVar() { + return 'key'; + } + `, + "/src/sub-project-2/tsconfig.json": utils.dedent` + { + "extends": "../tsconfig.base.json", + "compilerOptions": { + "composite": true, + "outFile": "sub-project-2.js" + }, + "references": [ + { "path": "../sub-project", "prepend": true } + ], + "include": ["./index.js"] + }`, + "/src/tsconfig.json": utils.dedent` + { + "compilerOptions": { + "composite": true, + "outFile": "src.js" + }, + "references": [ + { "path": "./sub-project", "prepend": true }, + { "path": "./sub-project-2", "prepend": true } + ], + "include": [] + }`, + "/src/tsconfig.base.json": utils.dedent` + { + "compilerOptions": { + "skipLibCheck": true, + "rootDir": "./", + "allowJs": true, + "checkJs": true, + "declaration": true + } + }`, + }, symbolLibContent); + }); + after(() => { + projFs = undefined!; + }); + verifyTsc({ + scenario: "javascriptProjectEmit", + subScenario: `loads outfile js projects and concatenates them correctly`, + fs: () => projFs, + commandLineArgs: ["-b", "/src"] + }); + verifyTscIncrementalEdits({ + scenario: "javascriptProjectEmit", + subScenario: `modifies outfile js projects and concatenates them correctly`, + fs: () => projFs, + commandLineArgs: ["-b", "/src"], + incrementalScenarios: [{ + buildKind: BuildKind.IncrementalDtsUnchanged, + modifyFs: fs => replaceText(fs, "/src/sub-project/index.js", "null", "undefined") + }] + }); + }); + + describe("unittests:: tsbuild:: javascriptProjectEmit:: loads js-based projects with non-moved json files and emits them correctly", () => { + verifyTsc({ + scenario: "javascriptProjectEmit", + subScenario: `loads js-based projects with non-moved json files and emits them correctly`, + fs: () => loadProjectFromFiles({ + "/src/common/obj.json": utils.dedent` + { + "val": 42 + }`, + "/src/common/index.ts": utils.dedent` + import x = require("./obj.json"); + export = x; + `, + "/src/common/tsconfig.json": utils.dedent` + { + "extends": "../tsconfig.base.json", + "compilerOptions": { + "outDir": null + "composite": true + }, + "include": ["index.ts", "obj.json"] + }`, + "/src/sub-project/index.js": utils.dedent` + import mod from '../common'; + + export const m = mod; + `, + "/src/sub-project/tsconfig.json": utils.dedent` + { + "extends": "../tsconfig.base.json", + "compilerOptions": { + "composite": true + }, + "references": [ + { "path": "../common" } + ], + "include": ["./index.js"] + }`, + "/src/sub-project-2/index.js": utils.dedent` + import { m } from '../sub-project/index'; + + const variable = { + key: m, + }; + + export function getVar() { + return variable; + } + `, + "/src/sub-project-2/tsconfig.json": utils.dedent` + { + "extends": "../tsconfig.base.json", + "compilerOptions": { + "composite": true + }, + "references": [ + { "path": "../sub-project" } + ], + "include": ["./index.js"] + }`, + "/src/tsconfig.json": utils.dedent` + { + "compilerOptions": { + "composite": true + }, + "references": [ + { "path": "./sub-project" }, + { "path": "./sub-project-2" } + ], + "include": [] + }`, + "/src/tsconfig.base.json": utils.dedent` + { + "compilerOptions": { + "skipLibCheck": true, + "rootDir": "./", + "outDir": "../out", + "allowJs": true, + "checkJs": true, + "resolveJsonModule": true, + "esModuleInterop": true, + "declaration": true + } + }`, + }, symbolLibContent), + commandLineArgs: ["-b", "/src"] + }); + }); +} diff --git a/src/testRunner/unittests/tsbuild/resolveJsonModule.ts b/src/testRunner/unittests/tsbuild/resolveJsonModule.ts index 71ae0d4c86e80..4d36bab67bae2 100644 --- a/src/testRunner/unittests/tsbuild/resolveJsonModule.ts +++ b/src/testRunner/unittests/tsbuild/resolveJsonModule.ts @@ -52,7 +52,12 @@ namespace ts { export default hello.hello`); const allExpectedOutputs = ["/src/dist/src/index.js", "/src/dist/src/index.d.ts", "/src/dist/src/index.json"]; - verifyProjectWithResolveJsonModuleWithFs(fs, "/src/tsconfig_withIncludeOfJson.json", allExpectedOutputs); + verifyProjectWithResolveJsonModuleWithFs( + fs, + "/src/tsconfig_withIncludeOfJson.json", + allExpectedOutputs, + errorDiagnostic([Diagnostics.Cannot_write_file_0_because_it_would_be_overwritten_by_multiple_input_files, "/src/dist/src/index.d.ts"]) + ); }); it("with resolveJsonModule and files containing json file", () => { diff --git a/src/testRunner/unittests/tscWatch/programUpdates.ts b/src/testRunner/unittests/tscWatch/programUpdates.ts index 1aa5107f7279c..ed2a15c9a1410 100644 --- a/src/testRunner/unittests/tscWatch/programUpdates.ts +++ b/src/testRunner/unittests/tscWatch/programUpdates.ts @@ -885,8 +885,8 @@ namespace ts.tscWatch { // More comment`; const configFileContentAfterComment = ` "compilerOptions": { - "allowJs": true, - "declaration": true + "inlineSourceMap": true, + "mapRoot": "./" } }`; const configFileContentWithComment = configFileContentBeforeComment + configFileContentComment + configFileContentAfterComment; @@ -900,8 +900,9 @@ namespace ts.tscWatch { const host = createWatchedSystem(files); const watch = createWatchOfConfigFile(configFile.path, host); const errors = () => [ - getDiagnosticOfFile(watch().getCompilerOptions().configFile!, configFile.content.indexOf('"allowJs"'), '"allowJs"'.length, Diagnostics.Option_0_cannot_be_specified_with_option_1, "allowJs", "declaration"), - getDiagnosticOfFile(watch().getCompilerOptions().configFile!, configFile.content.indexOf('"declaration"'), '"declaration"'.length, Diagnostics.Option_0_cannot_be_specified_with_option_1, "allowJs", "declaration") + getDiagnosticOfFile(watch().getCompilerOptions().configFile!, configFile.content.indexOf('"inlineSourceMap"'), '"inlineSourceMap"'.length, Diagnostics.Option_0_cannot_be_specified_with_option_1, "mapRoot", "inlineSourceMap"), + getDiagnosticOfFile(watch().getCompilerOptions().configFile!, configFile.content.indexOf('"mapRoot"'), '"mapRoot"'.length, Diagnostics.Option_0_cannot_be_specified_with_option_1, "mapRoot", "inlineSourceMap"), + getDiagnosticOfFile(watch().getCompilerOptions().configFile!, configFile.content.indexOf('"mapRoot"'), '"mapRoot"'.length, Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1_or_option_2, "mapRoot", "sourceMap", "declarationMap") ]; const intialErrors = errors(); checkOutputErrorsInitial(host, intialErrors); diff --git a/src/testRunner/unittests/tsserver/projectErrors.ts b/src/testRunner/unittests/tsserver/projectErrors.ts index 86e772bebb526..bb60e48e3ad60 100644 --- a/src/testRunner/unittests/tsserver/projectErrors.ts +++ b/src/testRunner/unittests/tsserver/projectErrors.ts @@ -849,8 +849,8 @@ declare module '@custom/plugin' { // comment`; const configFileContentAfterComment = ` "compilerOptions": { - "allowJs": true, - "declaration": true + "inlineSourceMap": true, + "mapRoot": "./" } }`; const configFileContentWithComment = configFileContentBeforeComment + configFileContentComment + configFileContentAfterComment; @@ -874,7 +874,7 @@ declare module '@custom/plugin' { seq: 2, arguments: { file: configFile.path, projectFileName: projectName, includeLinePosition: true } }).response as readonly server.protocol.DiagnosticWithLinePosition[]; - assert.isTrue(diags.length === 2); + assert.isTrue(diags.length === 3); configFile.content = configFileContentWithoutCommentLine; host.reloadFS([file, configFile]); @@ -885,10 +885,11 @@ declare module '@custom/plugin' { seq: 2, arguments: { file: configFile.path, projectFileName: projectName, includeLinePosition: true } }).response as readonly server.protocol.DiagnosticWithLinePosition[]; - assert.isTrue(diagsAfterEdit.length === 2); + assert.isTrue(diagsAfterEdit.length === 3); verifyDiagnostic(diags[0], diagsAfterEdit[0]); verifyDiagnostic(diags[1], diagsAfterEdit[1]); + verifyDiagnostic(diags[2], diagsAfterEdit[2]); function verifyDiagnostic(beforeEditDiag: server.protocol.DiagnosticWithLinePosition, afterEditDiag: server.protocol.DiagnosticWithLinePosition) { assert.equal(beforeEditDiag.message, afterEditDiag.message); diff --git a/tests/baselines/reference/api/tsserverlibrary.d.ts b/tests/baselines/reference/api/tsserverlibrary.d.ts index 3d055b9336aba..8f3095d2d5695 100644 --- a/tests/baselines/reference/api/tsserverlibrary.d.ts +++ b/tests/baselines/reference/api/tsserverlibrary.d.ts @@ -3586,7 +3586,7 @@ declare namespace ts { function isUnparsedTextLike(node: Node): node is UnparsedTextLike; function isUnparsedNode(node: Node): node is UnparsedNode; function isJSDocTypeExpression(node: Node): node is JSDocTypeExpression; - function isJSDocAllType(node: JSDocAllType): node is JSDocAllType; + function isJSDocAllType(node: Node): node is JSDocAllType; function isJSDocUnknownType(node: Node): node is JSDocUnknownType; function isJSDocNullableType(node: Node): node is JSDocNullableType; function isJSDocNonNullableType(node: Node): node is JSDocNonNullableType; diff --git a/tests/baselines/reference/api/typescript.d.ts b/tests/baselines/reference/api/typescript.d.ts index 3bd00d6f2ebe5..a322d091a6ea4 100644 --- a/tests/baselines/reference/api/typescript.d.ts +++ b/tests/baselines/reference/api/typescript.d.ts @@ -3586,7 +3586,7 @@ declare namespace ts { function isUnparsedTextLike(node: Node): node is UnparsedTextLike; function isUnparsedNode(node: Node): node is UnparsedNode; function isJSDocTypeExpression(node: Node): node is JSDocTypeExpression; - function isJSDocAllType(node: JSDocAllType): node is JSDocAllType; + function isJSDocAllType(node: Node): node is JSDocAllType; function isJSDocUnknownType(node: Node): node is JSDocUnknownType; function isJSDocNullableType(node: Node): node is JSDocNullableType; function isJSDocNonNullableType(node: Node): node is JSDocNonNullableType; diff --git a/tests/baselines/reference/augmentExportEquals3.types b/tests/baselines/reference/augmentExportEquals3.types index 87290d7415046..95ef09a899bea 100644 --- a/tests/baselines/reference/augmentExportEquals3.types +++ b/tests/baselines/reference/augmentExportEquals3.types @@ -10,7 +10,7 @@ namespace foo { >1 : 1 } export = foo; ->foo : typeof foo +>foo : typeof import("tests/cases/compiler/file1") === tests/cases/compiler/file2.ts === import x = require("./file1"); diff --git a/tests/baselines/reference/augmentExportEquals4.types b/tests/baselines/reference/augmentExportEquals4.types index 5e4574c815cc5..316c59cd498b3 100644 --- a/tests/baselines/reference/augmentExportEquals4.types +++ b/tests/baselines/reference/augmentExportEquals4.types @@ -10,7 +10,7 @@ namespace foo { >1 : 1 } export = foo; ->foo : foo +>foo : import("tests/cases/compiler/file1") === tests/cases/compiler/file2.ts === import x = require("./file1"); diff --git a/tests/baselines/reference/augmentExportEquals5.symbols b/tests/baselines/reference/augmentExportEquals5.symbols index 244073b6515d0..d7d14a1159faf 100644 --- a/tests/baselines/reference/augmentExportEquals5.symbols +++ b/tests/baselines/reference/augmentExportEquals5.symbols @@ -18,7 +18,7 @@ declare module "express" { function e(): e.Express; >e : Symbol(e, Decl(express.d.ts, 6, 26), Decl(express.d.ts, 7, 28), Decl(augmentation.ts, 1, 29)) >e : Symbol(e, Decl(express.d.ts, 6, 26), Decl(express.d.ts, 7, 28)) ->Express : Symbol(Express, Decl(express.d.ts, 52, 9)) +>Express : Symbol(e.Express, Decl(express.d.ts, 52, 9)) namespace e { >e : Symbol(e, Decl(express.d.ts, 6, 26), Decl(express.d.ts, 7, 28), Decl(augmentation.ts, 1, 29)) diff --git a/tests/baselines/reference/augmentExportEquals6.types b/tests/baselines/reference/augmentExportEquals6.types index 3a404744f0781..8e582c74de400 100644 --- a/tests/baselines/reference/augmentExportEquals6.types +++ b/tests/baselines/reference/augmentExportEquals6.types @@ -13,7 +13,7 @@ namespace foo { >a : any } export = foo; ->foo : foo +>foo : import("tests/cases/compiler/file1") === tests/cases/compiler/file2.ts === import x = require("./file1"); diff --git a/tests/baselines/reference/checkJsTypeDefNoUnusedLocalMarked.types b/tests/baselines/reference/checkJsTypeDefNoUnusedLocalMarked.types index e9385a7152df3..7fcf644cccd44 100644 --- a/tests/baselines/reference/checkJsTypeDefNoUnusedLocalMarked.types +++ b/tests/baselines/reference/checkJsTypeDefNoUnusedLocalMarked.types @@ -22,11 +22,11 @@ export = Foo; /** @typedef {(foo: Foo) => string} FooFun */ module.exports = /** @type {FooFun} */(void 0); ->module.exports = /** @type {FooFun} */(void 0) : (foo: typeof Foo) => string ->module.exports : (foo: typeof Foo) => string ->module : { "tests/cases/compiler/something": (foo: typeof Foo) => string; } ->exports : (foo: typeof Foo) => string ->(void 0) : (foo: typeof Foo) => string +>module.exports = /** @type {FooFun} */(void 0) : (foo: typeof import("tests/cases/compiler/file")) => string +>module.exports : (foo: typeof import("tests/cases/compiler/file")) => string +>module : { "tests/cases/compiler/something": (foo: typeof import("tests/cases/compiler/file")) => string; } +>exports : (foo: typeof import("tests/cases/compiler/file")) => string +>(void 0) : (foo: typeof import("tests/cases/compiler/file")) => string >void 0 : undefined >0 : 0 diff --git a/tests/baselines/reference/constructorFunctions2.types b/tests/baselines/reference/constructorFunctions2.types index 208a343375d26..b9a114604d82b 100644 --- a/tests/baselines/reference/constructorFunctions2.types +++ b/tests/baselines/reference/constructorFunctions2.types @@ -9,16 +9,16 @@ declare var module: any, exports: any; === tests/cases/conformance/salsa/index.js === const A = require("./other"); ->A : typeof A ->require("./other") : typeof A +>A : typeof import("tests/cases/conformance/salsa/other") +>require("./other") : typeof import("tests/cases/conformance/salsa/other") >require : (id: string) => any >"./other" : "./other" const a = new A().id; >a : number >new A().id : number ->new A() : A ->A : typeof A +>new A() : import("tests/cases/conformance/salsa/other") +>A : typeof import("tests/cases/conformance/salsa/other") >id : number const B = function() { this.id = 1; } diff --git a/tests/baselines/reference/declarationEmitNameConflicts.js b/tests/baselines/reference/declarationEmitNameConflicts.js index 57b11a88afbdd..693279a8edeb3 100644 --- a/tests/baselines/reference/declarationEmitNameConflicts.js +++ b/tests/baselines/reference/declarationEmitNameConflicts.js @@ -167,7 +167,7 @@ export declare module M.P { var a: typeof M.f; var b: typeof M.C; var c: typeof M.N; - var g: typeof M.c.g; + var g: typeof M.N.g; var d: typeof M.d; } export declare module M.Q { diff --git a/tests/baselines/reference/declarationFileNoCrashOnExtraExportModifier.errors.txt b/tests/baselines/reference/declarationFileNoCrashOnExtraExportModifier.errors.txt new file mode 100644 index 0000000000000..6e867246f6b42 --- /dev/null +++ b/tests/baselines/reference/declarationFileNoCrashOnExtraExportModifier.errors.txt @@ -0,0 +1,22 @@ +tests/cases/compiler/input.ts(1,1): error TS2309: An export assignment cannot be used in a module with other exported elements. +tests/cases/compiler/input.ts(6,14): error TS2323: Cannot redeclare exported variable 'Sub'. + + +==== tests/cases/compiler/input.ts (2 errors) ==== + export = exports; + ~~~~~~~~~~~~~~~~~ +!!! error TS2309: An export assignment cannot be used in a module with other exported elements. + declare class exports { + constructor(p: number); + t: number; + } + export class Sub { + ~~~ +!!! error TS2323: Cannot redeclare exported variable 'Sub'. + instance!: { + t: number; + }; + } + declare namespace exports { + export { Sub }; + } \ No newline at end of file diff --git a/tests/baselines/reference/declarationFileNoCrashOnExtraExportModifier.js b/tests/baselines/reference/declarationFileNoCrashOnExtraExportModifier.js new file mode 100644 index 0000000000000..8afcf1649627a --- /dev/null +++ b/tests/baselines/reference/declarationFileNoCrashOnExtraExportModifier.js @@ -0,0 +1,23 @@ +//// [input.ts] +export = exports; +declare class exports { + constructor(p: number); + t: number; +} +export class Sub { + instance!: { + t: number; + }; +} +declare namespace exports { + export { Sub }; +} + +//// [input.js] +"use strict"; +var Sub = /** @class */ (function () { + function Sub() { + } + return Sub; +}()); +module.exports = exports; diff --git a/tests/baselines/reference/declarationFileNoCrashOnExtraExportModifier.symbols b/tests/baselines/reference/declarationFileNoCrashOnExtraExportModifier.symbols new file mode 100644 index 0000000000000..05424e942d3e5 --- /dev/null +++ b/tests/baselines/reference/declarationFileNoCrashOnExtraExportModifier.symbols @@ -0,0 +1,30 @@ +=== tests/cases/compiler/input.ts === +export = exports; +>exports : Symbol(exports, Decl(input.ts, 0, 17), Decl(input.ts, 9, 1)) + +declare class exports { +>exports : Symbol(exports, Decl(input.ts, 0, 17), Decl(input.ts, 9, 1)) + + constructor(p: number); +>p : Symbol(p, Decl(input.ts, 2, 16)) + + t: number; +>t : Symbol(exports.t, Decl(input.ts, 2, 27)) +} +export class Sub { +>Sub : Symbol(Sub, Decl(input.ts, 4, 1), Decl(input.ts, 4, 1)) + + instance!: { +>instance : Symbol(Sub.instance, Decl(input.ts, 5, 18)) + + t: number; +>t : Symbol(t, Decl(input.ts, 6, 16)) + + }; +} +declare namespace exports { +>exports : Symbol(exports, Decl(input.ts, 0, 17), Decl(input.ts, 9, 1)) + + export { Sub }; +>Sub : Symbol(exports.Sub, Decl(input.ts, 11, 12)) +} diff --git a/tests/baselines/reference/declarationFileNoCrashOnExtraExportModifier.types b/tests/baselines/reference/declarationFileNoCrashOnExtraExportModifier.types new file mode 100644 index 0000000000000..59a45d305eccc --- /dev/null +++ b/tests/baselines/reference/declarationFileNoCrashOnExtraExportModifier.types @@ -0,0 +1,30 @@ +=== tests/cases/compiler/input.ts === +export = exports; +>exports : import("tests/cases/compiler/input") + +declare class exports { +>exports : exports + + constructor(p: number); +>p : number + + t: number; +>t : number +} +export class Sub { +>Sub : Sub + + instance!: { +>instance : { t: number; } + + t: number; +>t : number + + }; +} +declare namespace exports { +>exports : typeof exports + + export { Sub }; +>Sub : typeof import("tests/cases/compiler/input").Sub +} diff --git a/tests/baselines/reference/declarationImportTypeAliasInferredAndEmittable.js b/tests/baselines/reference/declarationImportTypeAliasInferredAndEmittable.js new file mode 100644 index 0000000000000..a65a811fcfcc7 --- /dev/null +++ b/tests/baselines/reference/declarationImportTypeAliasInferredAndEmittable.js @@ -0,0 +1,57 @@ +//// [tests/cases/compiler/declarationImportTypeAliasInferredAndEmittable.ts] //// + +//// [foo.ts] +class Conn { + constructor() { } + item = 3; + method() { } +} + +export = Conn; +//// [usage.ts] +type Conn = import("./foo"); +declare var x: Conn; + +export class Wrap { + connItem: number; + constructor(c = x) { + this.connItem = c.item; + } +} + + +//// [foo.js] +"use strict"; +var Conn = /** @class */ (function () { + function Conn() { + this.item = 3; + } + Conn.prototype.method = function () { }; + return Conn; +}()); +module.exports = Conn; +//// [usage.js] +"use strict"; +exports.__esModule = true; +var Wrap = /** @class */ (function () { + function Wrap(c) { + if (c === void 0) { c = x; } + this.connItem = c.item; + } + return Wrap; +}()); +exports.Wrap = Wrap; + + +//// [foo.d.ts] +declare class Conn { + constructor(); + item: number; + method(): void; +} +export = Conn; +//// [usage.d.ts] +export declare class Wrap { + connItem: number; + constructor(c?: import("./foo")); +} diff --git a/tests/baselines/reference/declarationImportTypeAliasInferredAndEmittable.symbols b/tests/baselines/reference/declarationImportTypeAliasInferredAndEmittable.symbols new file mode 100644 index 0000000000000..2e1e4ba25a329 --- /dev/null +++ b/tests/baselines/reference/declarationImportTypeAliasInferredAndEmittable.symbols @@ -0,0 +1,43 @@ +=== tests/cases/compiler/foo.ts === +class Conn { +>Conn : Symbol(Conn, Decl(foo.ts, 0, 0)) + + constructor() { } + item = 3; +>item : Symbol(Conn.item, Decl(foo.ts, 1, 21)) + + method() { } +>method : Symbol(Conn.method, Decl(foo.ts, 2, 13)) +} + +export = Conn; +>Conn : Symbol(Conn, Decl(foo.ts, 0, 0)) + +=== tests/cases/compiler/usage.ts === +type Conn = import("./foo"); +>Conn : Symbol(Conn, Decl(usage.ts, 0, 0)) + +declare var x: Conn; +>x : Symbol(x, Decl(usage.ts, 1, 11)) +>Conn : Symbol(Conn, Decl(usage.ts, 0, 0)) + +export class Wrap { +>Wrap : Symbol(Wrap, Decl(usage.ts, 1, 20)) + + connItem: number; +>connItem : Symbol(Wrap.connItem, Decl(usage.ts, 3, 19)) + + constructor(c = x) { +>c : Symbol(c, Decl(usage.ts, 5, 16)) +>x : Symbol(x, Decl(usage.ts, 1, 11)) + + this.connItem = c.item; +>this.connItem : Symbol(Wrap.connItem, Decl(usage.ts, 3, 19)) +>this : Symbol(Wrap, Decl(usage.ts, 1, 20)) +>connItem : Symbol(Wrap.connItem, Decl(usage.ts, 3, 19)) +>c.item : Symbol(Conn.item, Decl(foo.ts, 1, 21)) +>c : Symbol(c, Decl(usage.ts, 5, 16)) +>item : Symbol(Conn.item, Decl(foo.ts, 1, 21)) + } +} + diff --git a/tests/baselines/reference/declarationImportTypeAliasInferredAndEmittable.types b/tests/baselines/reference/declarationImportTypeAliasInferredAndEmittable.types new file mode 100644 index 0000000000000..c125e9b1c08bc --- /dev/null +++ b/tests/baselines/reference/declarationImportTypeAliasInferredAndEmittable.types @@ -0,0 +1,44 @@ +=== tests/cases/compiler/foo.ts === +class Conn { +>Conn : Conn + + constructor() { } + item = 3; +>item : number +>3 : 3 + + method() { } +>method : () => void +} + +export = Conn; +>Conn : Conn + +=== tests/cases/compiler/usage.ts === +type Conn = import("./foo"); +>Conn : import("tests/cases/compiler/foo") + +declare var x: Conn; +>x : import("tests/cases/compiler/foo") + +export class Wrap { +>Wrap : Wrap + + connItem: number; +>connItem : number + + constructor(c = x) { +>c : import("tests/cases/compiler/foo") +>x : import("tests/cases/compiler/foo") + + this.connItem = c.item; +>this.connItem = c.item : number +>this.connItem : number +>this : this +>connItem : number +>c.item : number +>c : import("tests/cases/compiler/foo") +>item : number + } +} + diff --git a/tests/baselines/reference/duplicateExportAssignments.types b/tests/baselines/reference/duplicateExportAssignments.types index d9db21137591f..3a76cb669b632 100644 --- a/tests/baselines/reference/duplicateExportAssignments.types +++ b/tests/baselines/reference/duplicateExportAssignments.types @@ -29,7 +29,7 @@ export = y; === tests/cases/conformance/externalModules/foo3.ts === module x { ->x : typeof x +>x : typeof import("tests/cases/conformance/externalModules/foo3") export var x = 10; >x : number diff --git a/tests/baselines/reference/es5ExportEquals.types b/tests/baselines/reference/es5ExportEquals.types index f6273376a7cbe..83776f8fbc8bb 100644 --- a/tests/baselines/reference/es5ExportEquals.types +++ b/tests/baselines/reference/es5ExportEquals.types @@ -3,5 +3,5 @@ export function f() { } >f : typeof f export = f; ->f : { (): void; f: typeof import("tests/cases/compiler/es5ExportEquals").f; } +>f : { (): void; f: typeof import("tests/cases/compiler/es5ExportEquals"); } diff --git a/tests/baselines/reference/es6ExportEquals.types b/tests/baselines/reference/es6ExportEquals.types index eb8e59c31be6b..e4e5f1f69bca7 100644 --- a/tests/baselines/reference/es6ExportEquals.types +++ b/tests/baselines/reference/es6ExportEquals.types @@ -3,5 +3,5 @@ export function f() { } >f : typeof f export = f; ->f : { (): void; f: typeof import("tests/cases/compiler/es6ExportEquals").f; } +>f : { (): void; f: typeof import("tests/cases/compiler/es6ExportEquals"); } diff --git a/tests/baselines/reference/exportAssignmentAndDeclaration.types b/tests/baselines/reference/exportAssignmentAndDeclaration.types index 86b31844ab6d8..21eb5617e6271 100644 --- a/tests/baselines/reference/exportAssignmentAndDeclaration.types +++ b/tests/baselines/reference/exportAssignmentAndDeclaration.types @@ -15,5 +15,5 @@ class C1 { // Invalid, as there is already an exported member. export = C1; ->C1 : C1 +>C1 : import("tests/cases/conformance/externalModules/foo_0") diff --git a/tests/baselines/reference/exportAssignmentWithExports.types b/tests/baselines/reference/exportAssignmentWithExports.types index 5df173d8106e0..e98417d974bca 100644 --- a/tests/baselines/reference/exportAssignmentWithExports.types +++ b/tests/baselines/reference/exportAssignmentWithExports.types @@ -6,5 +6,5 @@ class D { } >D : D export = D; ->D : D +>D : import("tests/cases/compiler/exportAssignmentWithExports") diff --git a/tests/baselines/reference/importTypeGenericTypes.types b/tests/baselines/reference/importTypeGenericTypes.types index 20e811d44d0f0..9a882bd58d48f 100644 --- a/tests/baselines/reference/importTypeGenericTypes.types +++ b/tests/baselines/reference/importTypeGenericTypes.types @@ -55,7 +55,7 @@ export { Bar } === tests/cases/conformance/types/import/usage.ts === export const x: import("./foo")<{x: number}> = { x: 0, y: 0, data: {x: 12} }; ->x : Point<{ x: number; }> +>x : import("tests/cases/conformance/types/import/foo")<{ x: number; }> >x : number >{ x: 0, y: 0, data: {x: 12} } : { x: number; y: number; data: { x: number; }; } >x : number diff --git a/tests/baselines/reference/importTypeInJSDoc.types b/tests/baselines/reference/importTypeInJSDoc.types index ba6bf998a3454..ee28f78f97688 100644 --- a/tests/baselines/reference/importTypeInJSDoc.types +++ b/tests/baselines/reference/importTypeInJSDoc.types @@ -37,20 +37,20 @@ export = MyClass; */ let a = /** @type {Foo} */(/** @type {*} */(undefined)); ->a : MyClass ->(/** @type {*} */(undefined)) : MyClass +>a : import("tests/cases/conformance/types/import/externs") +>(/** @type {*} */(undefined)) : import("tests/cases/conformance/types/import/externs") >(undefined) : any >undefined : undefined a = new Foo({doer: Foo.Bar}); ->a = new Foo({doer: Foo.Bar}) : MyClass ->a : MyClass ->new Foo({doer: Foo.Bar}) : MyClass ->Foo : typeof MyClass +>a = new Foo({doer: Foo.Bar}) : import("tests/cases/conformance/types/import/externs") +>a : import("tests/cases/conformance/types/import/externs") +>new Foo({doer: Foo.Bar}) : import("tests/cases/conformance/types/import/externs") +>Foo : typeof import("tests/cases/conformance/types/import/externs") >{doer: Foo.Bar} : { doer: (x: string, y?: number) => void; } >doer : (x: string, y?: number) => void >Foo.Bar : (x: string, y?: number) => void ->Foo : typeof MyClass +>Foo : typeof import("tests/cases/conformance/types/import/externs") >Bar : (x: string, y?: number) => void const q = /** @type {import("./externs").Bar} */({ doer: q => q }); diff --git a/tests/baselines/reference/importTypeLocal.types b/tests/baselines/reference/importTypeLocal.types index a6d931a1b033b..d106a0d00e7e3 100644 --- a/tests/baselines/reference/importTypeLocal.types +++ b/tests/baselines/reference/importTypeLocal.types @@ -46,7 +46,7 @@ export { Bar } === tests/cases/conformance/types/import/usage.ts === export const x: import("./foo") = { x: 0, y: 0 }; ->x : Point +>x : import("tests/cases/conformance/types/import/foo") >{ x: 0, y: 0 } : { x: number; y: number; } >x : number >0 : 0 diff --git a/tests/baselines/reference/jsDeclarationsClassExtendsVisibility.js b/tests/baselines/reference/jsDeclarationsClassExtendsVisibility.js new file mode 100644 index 0000000000000..a65f487a81a54 --- /dev/null +++ b/tests/baselines/reference/jsDeclarationsClassExtendsVisibility.js @@ -0,0 +1,68 @@ +//// [tests/cases/conformance/jsdoc/declarations/jsDeclarationsClassExtendsVisibility.ts] //// + +//// [bar.js] +class Bar {} +module.exports = Bar; +//// [cls.js] +const Bar = require("./bar"); +const Strings = { + a: "A", + b: "B" +}; +class Foo extends Bar {} +module.exports = Foo; +module.exports.Strings = Strings; + +//// [bar.js] +var Bar = /** @class */ (function () { + function Bar() { + } + return Bar; +}()); +module.exports = Bar; +//// [cls.js] +var __extends = (this && this.__extends) || (function () { + var extendStatics = function (d, b) { + 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 extendStatics(d, b); + }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +var Bar = require("./bar"); +var Strings = { + a: "A", + b: "B" +}; +var Foo = /** @class */ (function (_super) { + __extends(Foo, _super); + function Foo() { + return _super !== null && _super.apply(this, arguments) || this; + } + return Foo; +}(Bar)); +module.exports = Foo; +module.exports.Strings = Strings; + + +//// [bar.d.ts] +export = Bar; +declare class Bar { +} +//// [cls.d.ts] +export = Foo; +declare const Foo_base: typeof import("./bar"); +declare class Foo extends Foo_base { +} +declare namespace Foo { + export { Strings }; +} +declare namespace Strings { + export const a: string; + export const b: string; +} diff --git a/tests/baselines/reference/jsDeclarationsClassExtendsVisibility.symbols b/tests/baselines/reference/jsDeclarationsClassExtendsVisibility.symbols new file mode 100644 index 0000000000000..cbf083c36f819 --- /dev/null +++ b/tests/baselines/reference/jsDeclarationsClassExtendsVisibility.symbols @@ -0,0 +1,44 @@ +=== tests/cases/conformance/jsdoc/declarations/cls.js === +const Bar = require("./bar"); +>Bar : Symbol(Bar, Decl(cls.js, 0, 5)) +>require : Symbol(require) +>"./bar" : Symbol("tests/cases/conformance/jsdoc/declarations/bar", Decl(bar.js, 0, 0)) + +const Strings = { +>Strings : Symbol(Strings, Decl(cls.js, 1, 5)) + + a: "A", +>a : Symbol(a, Decl(cls.js, 1, 17)) + + b: "B" +>b : Symbol(b, Decl(cls.js, 2, 11)) + +}; +class Foo extends Bar {} +>Foo : Symbol(Foo, Decl(cls.js, 4, 2)) +>Bar : Symbol(Bar, Decl(cls.js, 0, 5)) + +module.exports = Foo; +>module.exports : Symbol("tests/cases/conformance/jsdoc/declarations/cls", Decl(cls.js, 0, 0)) +>module : Symbol(export=, Decl(cls.js, 5, 24)) +>exports : Symbol(export=, Decl(cls.js, 5, 24)) +>Foo : Symbol(Foo, Decl(cls.js, 4, 2)) + +module.exports.Strings = Strings; +>module.exports.Strings : Symbol(Strings) +>module.exports : Symbol(Strings, Decl(cls.js, 6, 21)) +>module : Symbol(module, Decl(cls.js, 5, 24)) +>exports : Symbol("tests/cases/conformance/jsdoc/declarations/cls", Decl(cls.js, 0, 0)) +>Strings : Symbol(Strings, Decl(cls.js, 6, 21)) +>Strings : Symbol(Strings, Decl(cls.js, 1, 5)) + +=== tests/cases/conformance/jsdoc/declarations/bar.js === +class Bar {} +>Bar : Symbol(Bar, Decl(bar.js, 0, 0)) + +module.exports = Bar; +>module.exports : Symbol("tests/cases/conformance/jsdoc/declarations/bar", Decl(bar.js, 0, 0)) +>module : Symbol(export=, Decl(bar.js, 0, 12)) +>exports : Symbol(export=, Decl(bar.js, 0, 12)) +>Bar : Symbol(Bar, Decl(bar.js, 0, 0)) + diff --git a/tests/baselines/reference/jsDeclarationsClassExtendsVisibility.types b/tests/baselines/reference/jsDeclarationsClassExtendsVisibility.types new file mode 100644 index 0000000000000..fe35b959cf04e --- /dev/null +++ b/tests/baselines/reference/jsDeclarationsClassExtendsVisibility.types @@ -0,0 +1,51 @@ +=== tests/cases/conformance/jsdoc/declarations/cls.js === +const Bar = require("./bar"); +>Bar : typeof import("tests/cases/conformance/jsdoc/declarations/bar") +>require("./bar") : typeof import("tests/cases/conformance/jsdoc/declarations/bar") +>require : any +>"./bar" : "./bar" + +const Strings = { +>Strings : { a: string; b: string; } +>{ a: "A", b: "B"} : { a: string; b: string; } + + a: "A", +>a : string +>"A" : "A" + + b: "B" +>b : string +>"B" : "B" + +}; +class Foo extends Bar {} +>Foo : Foo +>Bar : import("tests/cases/conformance/jsdoc/declarations/bar") + +module.exports = Foo; +>module.exports = Foo : typeof Foo +>module.exports : typeof Foo +>module : { "tests/cases/conformance/jsdoc/declarations/cls": typeof Foo; } +>exports : typeof Foo +>Foo : typeof Foo + +module.exports.Strings = Strings; +>module.exports.Strings = Strings : { a: string; b: string; } +>module.exports.Strings : { a: string; b: string; } +>module.exports : typeof Foo +>module : { "tests/cases/conformance/jsdoc/declarations/cls": typeof Foo; } +>exports : typeof Foo +>Strings : { a: string; b: string; } +>Strings : { a: string; b: string; } + +=== tests/cases/conformance/jsdoc/declarations/bar.js === +class Bar {} +>Bar : Bar + +module.exports = Bar; +>module.exports = Bar : typeof Bar +>module.exports : typeof Bar +>module : { "tests/cases/conformance/jsdoc/declarations/bar": typeof Bar; } +>exports : typeof Bar +>Bar : typeof Bar + diff --git a/tests/baselines/reference/jsDeclarationsClasses.js b/tests/baselines/reference/jsDeclarationsClasses.js new file mode 100644 index 0000000000000..d94e8690a3c58 --- /dev/null +++ b/tests/baselines/reference/jsDeclarationsClasses.js @@ -0,0 +1,591 @@ +//// [index.js] +export class A {} + +export class B { + static cat = "cat"; +} + +export class C { + static Cls = class {} +} + +export class D { + /** + * @param {number} a + * @param {number} b + */ + constructor(a, b) {} +} + +/** + * @template T,U + */ +export class E { + /** + * @type {T & U} + */ + field; + + // @readonly is currently unsupported, it seems - included here just in case that changes + /** + * @type {T & U} + * @readonly + */ + readonlyField; + + initializedField = 12; + + /** + * @return {U} + */ + get f1() { return /** @type {*} */(null); } + + /** + * @param {U} _p + */ + set f1(_p) {} + + /** + * @return {U} + */ + get f2() { return /** @type {*} */(null); } + + /** + * @param {U} _p + */ + set f3(_p) {} + + /** + * @param {T} a + * @param {U} b + */ + constructor(a, b) {} + + + /** + * @type {string} + */ + static staticField; + + // @readonly is currently unsupported, it seems - included here just in case that changes + /** + * @type {string} + * @readonly + */ + static staticReadonlyField; + + static staticInitializedField = 12; + + /** + * @return {string} + */ + static get s1() { return ""; } + + /** + * @param {string} _p + */ + static set s1(_p) {} + + /** + * @return {string} + */ + static get s2() { return ""; } + + /** + * @param {string} _p + */ + static set s3(_p) {} +} + +/** + * @template T,U + */ +export class F { + /** + * @type {T & U} + */ + field; + /** + * @param {T} a + * @param {U} b + */ + constructor(a, b) {} + + /** + * @template A,B + * @param {A} a + * @param {B} b + */ + static create(a, b) { return new F(a, b); } +} + +class G {} + +export { G }; + +class HH {} + +export { HH as H }; + +export class I {} +export { I as II }; + +export { J as JJ }; +export class J {} + + +export class K { + constructor() { + this.p1 = 12; + this.p2 = "ok"; + } + + method() { + return this.p1; + } +} + +export class L extends K {} + +export class M extends null { + constructor() { + this.prop = 12; + } +} + + +/** + * @template T + */ +export class N extends L { + /** + * @param {T} param + */ + constructor(param) { + super(); + this.another = param; + } +} + +/** + * @template U + * @extends {N} + */ +export class O extends N { + /** + * @param {U} param + */ + constructor(param) { + super(param); + this.another2 = param; + } +} + +var x = /** @type {*} */(null); + +export class VariableBase extends x {} + +export class HasStatics { + static staticMethod() {} +} + +export class ExtendsStatics extends HasStatics { + static also() {} +} + + +//// [index.js] +"use strict"; +var __extends = (this && this.__extends) || (function () { + var extendStatics = function (d, b) { + 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 extendStatics(d, b); + }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +Object.defineProperty(exports, "__esModule", { value: true }); +var A = /** @class */ (function () { + function A() { + } + return A; +}()); +exports.A = A; +var B = /** @class */ (function () { + function B() { + } + B.cat = "cat"; + return B; +}()); +exports.B = B; +var C = /** @class */ (function () { + function C() { + } + C.Cls = /** @class */ (function () { + function class_1() { + } + return class_1; + }()); + return C; +}()); +exports.C = C; +var D = /** @class */ (function () { + /** + * @param {number} a + * @param {number} b + */ + function D(a, b) { + } + return D; +}()); +exports.D = D; +/** + * @template T,U + */ +var E = /** @class */ (function () { + /** + * @param {T} a + * @param {U} b + */ + function E(a, b) { + this.initializedField = 12; + } + Object.defineProperty(E.prototype, "f1", { + /** + * @return {U} + */ + get: function () { return /** @type {*} */ (null); }, + /** + * @param {U} _p + */ + set: function (_p) { }, + enumerable: true, + configurable: true + }); + Object.defineProperty(E.prototype, "f2", { + /** + * @return {U} + */ + get: function () { return /** @type {*} */ (null); }, + enumerable: true, + configurable: true + }); + Object.defineProperty(E.prototype, "f3", { + /** + * @param {U} _p + */ + set: function (_p) { }, + enumerable: true, + configurable: true + }); + Object.defineProperty(E, "s1", { + /** + * @return {string} + */ + get: function () { return ""; }, + /** + * @param {string} _p + */ + set: function (_p) { }, + enumerable: true, + configurable: true + }); + Object.defineProperty(E, "s2", { + /** + * @return {string} + */ + get: function () { return ""; }, + enumerable: true, + configurable: true + }); + Object.defineProperty(E, "s3", { + /** + * @param {string} _p + */ + set: function (_p) { }, + enumerable: true, + configurable: true + }); + E.staticInitializedField = 12; + return E; +}()); +exports.E = E; +/** + * @template T,U + */ +var F = /** @class */ (function () { + /** + * @param {T} a + * @param {U} b + */ + function F(a, b) { + } + /** + * @template A,B + * @param {A} a + * @param {B} b + */ + F.create = function (a, b) { return new F(a, b); }; + return F; +}()); +exports.F = F; +var G = /** @class */ (function () { + function G() { + } + return G; +}()); +exports.G = G; +var HH = /** @class */ (function () { + function HH() { + } + return HH; +}()); +exports.H = HH; +var I = /** @class */ (function () { + function I() { + } + return I; +}()); +exports.I = I; +exports.II = I; +var J = /** @class */ (function () { + function J() { + } + return J; +}()); +exports.JJ = J; +exports.J = J; +var K = /** @class */ (function () { + function K() { + this.p1 = 12; + this.p2 = "ok"; + } + K.prototype.method = function () { + return this.p1; + }; + return K; +}()); +exports.K = K; +var L = /** @class */ (function (_super) { + __extends(L, _super); + function L() { + return _super !== null && _super.apply(this, arguments) || this; + } + return L; +}(K)); +exports.L = L; +var M = /** @class */ (function (_super) { + __extends(M, _super); + function M() { + _this.prop = 12; + } + return M; +}(null)); +exports.M = M; +/** + * @template T + */ +var N = /** @class */ (function (_super) { + __extends(N, _super); + /** + * @param {T} param + */ + function N(param) { + var _this = _super.call(this) || this; + _this.another = param; + return _this; + } + return N; +}(L)); +exports.N = N; +/** + * @template U + * @extends {N} + */ +var O = /** @class */ (function (_super) { + __extends(O, _super); + /** + * @param {U} param + */ + function O(param) { + var _this = _super.call(this, param) || this; + _this.another2 = param; + return _this; + } + return O; +}(N)); +exports.O = O; +var x = /** @type {*} */ (null); +var VariableBase = /** @class */ (function (_super) { + __extends(VariableBase, _super); + function VariableBase() { + return _super !== null && _super.apply(this, arguments) || this; + } + return VariableBase; +}(x)); +exports.VariableBase = VariableBase; +var HasStatics = /** @class */ (function () { + function HasStatics() { + } + HasStatics.staticMethod = function () { }; + return HasStatics; +}()); +exports.HasStatics = HasStatics; +var ExtendsStatics = /** @class */ (function (_super) { + __extends(ExtendsStatics, _super); + function ExtendsStatics() { + return _super !== null && _super.apply(this, arguments) || this; + } + ExtendsStatics.also = function () { }; + return ExtendsStatics; +}(HasStatics)); +exports.ExtendsStatics = ExtendsStatics; + + +//// [index.d.ts] +export class A { +} +export class B { + static cat: string; +} +export class C { + static Cls: { + new (): {}; + }; +} +export class D { + /** + * @param {number} a + * @param {number} b + */ + constructor(a: number, b: number); +} +/** + * @template T,U + */ +export class E { + /** + * @type {string} + */ + static staticField: string; + /** + * @type {string} + * @readonly + */ + static staticReadonlyField: string; + static staticInitializedField: number; + /** + * @return {string} + */ + static s1: string; + /** + * @return {string} + */ + static readonly s2: string; + /** + * @param {string} _p + */ + static s3: string; + /** + * @param {T} a + * @param {U} b + */ + constructor(a: T, b: U); + /** + * @type {T & U} + */ + field: T & U; + /** + * @type {T & U} + * @readonly + */ + readonlyField: T & U; + initializedField: number; + /** + * @return {U} + */ + f1: U; + /** + * @return {U} + */ + readonly f2: U; + /** + * @param {U} _p + */ + f3: U; +} +/** + * @template T,U + */ +export class F { + /** + * @template A,B + * @param {A} a + * @param {B} b + */ + static create(a: A_1, b: B_1): F; + /** + * @param {T} a + * @param {U} b + */ + constructor(a: T, b: U); + /** + * @type {T & U} + */ + field: T & U; +} +export class I { +} +export class J { +} +export class K { + p1: number; + p2: string; + method(): number; +} +export class L extends K { +} +export class M { + prop: number; +} +/** + * @template T + */ +export class N extends L { + /** + * @param {T} param + */ + constructor(param: T); + another: T; +} +/** + * @template U + * @extends {N} + */ +export class O extends N { + /** + * @param {U} param + */ + constructor(param: U); + another2: U; +} +declare const VariableBase_base: any; +export class VariableBase extends VariableBase_base { + [x: string]: any; +} +export class HasStatics { + static staticMethod(): void; +} +export class ExtendsStatics extends HasStatics { + static also(): void; +} +export class G { +} +declare class HH { +} +export { HH as H, I as II, J as JJ }; diff --git a/tests/baselines/reference/jsDeclarationsClasses.symbols b/tests/baselines/reference/jsDeclarationsClasses.symbols new file mode 100644 index 0000000000000..dd92edbd4e65c --- /dev/null +++ b/tests/baselines/reference/jsDeclarationsClasses.symbols @@ -0,0 +1,307 @@ +=== tests/cases/conformance/jsdoc/declarations/index.js === +export class A {} +>A : Symbol(A, Decl(index.js, 0, 0)) + +export class B { +>B : Symbol(B, Decl(index.js, 0, 17)) + + static cat = "cat"; +>cat : Symbol(B.cat, Decl(index.js, 2, 16)) +} + +export class C { +>C : Symbol(C, Decl(index.js, 4, 1)) + + static Cls = class {} +>Cls : Symbol(C.Cls, Decl(index.js, 6, 16)) +} + +export class D { +>D : Symbol(D, Decl(index.js, 8, 1)) + + /** + * @param {number} a + * @param {number} b + */ + constructor(a, b) {} +>a : Symbol(a, Decl(index.js, 15, 16)) +>b : Symbol(b, Decl(index.js, 15, 18)) +} + +/** + * @template T,U + */ +export class E { +>E : Symbol(E, Decl(index.js, 16, 1)) + + /** + * @type {T & U} + */ + field; +>field : Symbol(E.field, Decl(index.js, 21, 16)) + + // @readonly is currently unsupported, it seems - included here just in case that changes + /** + * @type {T & U} + * @readonly + */ + readonlyField; +>readonlyField : Symbol(E.readonlyField, Decl(index.js, 25, 10)) + + initializedField = 12; +>initializedField : Symbol(E.initializedField, Decl(index.js, 32, 18)) + + /** + * @return {U} + */ + get f1() { return /** @type {*} */(null); } +>f1 : Symbol(E.f1, Decl(index.js, 34, 26), Decl(index.js, 39, 47)) + + /** + * @param {U} _p + */ + set f1(_p) {} +>f1 : Symbol(E.f1, Decl(index.js, 34, 26), Decl(index.js, 39, 47)) +>_p : Symbol(_p, Decl(index.js, 44, 11)) + + /** + * @return {U} + */ + get f2() { return /** @type {*} */(null); } +>f2 : Symbol(E.f2, Decl(index.js, 44, 17)) + + /** + * @param {U} _p + */ + set f3(_p) {} +>f3 : Symbol(E.f3, Decl(index.js, 49, 47)) +>_p : Symbol(_p, Decl(index.js, 54, 11)) + + /** + * @param {T} a + * @param {U} b + */ + constructor(a, b) {} +>a : Symbol(a, Decl(index.js, 60, 16)) +>b : Symbol(b, Decl(index.js, 60, 18)) + + + /** + * @type {string} + */ + static staticField; +>staticField : Symbol(E.staticField, Decl(index.js, 60, 24)) + + // @readonly is currently unsupported, it seems - included here just in case that changes + /** + * @type {string} + * @readonly + */ + static staticReadonlyField; +>staticReadonlyField : Symbol(E.staticReadonlyField, Decl(index.js, 66, 23)) + + static staticInitializedField = 12; +>staticInitializedField : Symbol(E.staticInitializedField, Decl(index.js, 73, 31)) + + /** + * @return {string} + */ + static get s1() { return ""; } +>s1 : Symbol(E.s1, Decl(index.js, 75, 39), Decl(index.js, 80, 34)) + + /** + * @param {string} _p + */ + static set s1(_p) {} +>s1 : Symbol(E.s1, Decl(index.js, 75, 39), Decl(index.js, 80, 34)) +>_p : Symbol(_p, Decl(index.js, 85, 18)) + + /** + * @return {string} + */ + static get s2() { return ""; } +>s2 : Symbol(E.s2, Decl(index.js, 85, 24)) + + /** + * @param {string} _p + */ + static set s3(_p) {} +>s3 : Symbol(E.s3, Decl(index.js, 90, 34)) +>_p : Symbol(_p, Decl(index.js, 95, 18)) +} + +/** + * @template T,U + */ +export class F { +>F : Symbol(F, Decl(index.js, 96, 1)) + + /** + * @type {T & U} + */ + field; +>field : Symbol(F.field, Decl(index.js, 101, 16)) + + /** + * @param {T} a + * @param {U} b + */ + constructor(a, b) {} +>a : Symbol(a, Decl(index.js, 110, 16)) +>b : Symbol(b, Decl(index.js, 110, 18)) + + /** + * @template A,B + * @param {A} a + * @param {B} b + */ + static create(a, b) { return new F(a, b); } +>create : Symbol(F.create, Decl(index.js, 110, 24)) +>a : Symbol(a, Decl(index.js, 117, 18)) +>b : Symbol(b, Decl(index.js, 117, 20)) +>F : Symbol(F, Decl(index.js, 96, 1)) +>a : Symbol(a, Decl(index.js, 117, 18)) +>b : Symbol(b, Decl(index.js, 117, 20)) +} + +class G {} +>G : Symbol(G, Decl(index.js, 118, 1)) + +export { G }; +>G : Symbol(G, Decl(index.js, 122, 8)) + +class HH {} +>HH : Symbol(HH, Decl(index.js, 122, 13)) + +export { HH as H }; +>HH : Symbol(HH, Decl(index.js, 122, 13)) +>H : Symbol(H, Decl(index.js, 126, 8)) + +export class I {} +>I : Symbol(I, Decl(index.js, 126, 19)) + +export { I as II }; +>I : Symbol(I, Decl(index.js, 126, 19)) +>II : Symbol(II, Decl(index.js, 129, 8)) + +export { J as JJ }; +>J : Symbol(J, Decl(index.js, 131, 19)) +>JJ : Symbol(JJ, Decl(index.js, 131, 8)) + +export class J {} +>J : Symbol(J, Decl(index.js, 131, 19)) + + +export class K { +>K : Symbol(K, Decl(index.js, 132, 17)) + + constructor() { + this.p1 = 12; +>this.p1 : Symbol(K.p1, Decl(index.js, 136, 19)) +>this : Symbol(K, Decl(index.js, 132, 17)) +>p1 : Symbol(K.p1, Decl(index.js, 136, 19)) + + this.p2 = "ok"; +>this.p2 : Symbol(K.p2, Decl(index.js, 137, 21)) +>this : Symbol(K, Decl(index.js, 132, 17)) +>p2 : Symbol(K.p2, Decl(index.js, 137, 21)) + } + + method() { +>method : Symbol(K.method, Decl(index.js, 139, 5)) + + return this.p1; +>this.p1 : Symbol(K.p1, Decl(index.js, 136, 19)) +>this : Symbol(K, Decl(index.js, 132, 17)) +>p1 : Symbol(K.p1, Decl(index.js, 136, 19)) + } +} + +export class L extends K {} +>L : Symbol(L, Decl(index.js, 144, 1)) +>K : Symbol(K, Decl(index.js, 132, 17)) + +export class M extends null { +>M : Symbol(M, Decl(index.js, 146, 27)) + + constructor() { + this.prop = 12; +>this.prop : Symbol(M.prop, Decl(index.js, 149, 19)) +>this : Symbol(M, Decl(index.js, 146, 27)) +>prop : Symbol(M.prop, Decl(index.js, 149, 19)) + } +} + + +/** + * @template T + */ +export class N extends L { +>N : Symbol(N, Decl(index.js, 152, 1)) +>L : Symbol(L, Decl(index.js, 144, 1)) + + /** + * @param {T} param + */ + constructor(param) { +>param : Symbol(param, Decl(index.js, 162, 16)) + + super(); +>super : Symbol(L, Decl(index.js, 144, 1)) + + this.another = param; +>this.another : Symbol(N.another, Decl(index.js, 163, 16)) +>this : Symbol(N, Decl(index.js, 152, 1)) +>another : Symbol(N.another, Decl(index.js, 163, 16)) +>param : Symbol(param, Decl(index.js, 162, 16)) + } +} + +/** + * @template U + * @extends {N} + */ +export class O extends N { +>O : Symbol(O, Decl(index.js, 166, 1)) +>N : Symbol(N, Decl(index.js, 152, 1)) + + /** + * @param {U} param + */ + constructor(param) { +>param : Symbol(param, Decl(index.js, 176, 16)) + + super(param); +>super : Symbol(N, Decl(index.js, 152, 1)) +>param : Symbol(param, Decl(index.js, 176, 16)) + + this.another2 = param; +>this.another2 : Symbol(O.another2, Decl(index.js, 177, 21)) +>this : Symbol(O, Decl(index.js, 166, 1)) +>another2 : Symbol(O.another2, Decl(index.js, 177, 21)) +>param : Symbol(param, Decl(index.js, 176, 16)) + } +} + +var x = /** @type {*} */(null); +>x : Symbol(x, Decl(index.js, 182, 3)) + +export class VariableBase extends x {} +>VariableBase : Symbol(VariableBase, Decl(index.js, 182, 31)) +>x : Symbol(x, Decl(index.js, 182, 3)) + +export class HasStatics { +>HasStatics : Symbol(HasStatics, Decl(index.js, 184, 38)) + + static staticMethod() {} +>staticMethod : Symbol(HasStatics.staticMethod, Decl(index.js, 186, 25)) +} + +export class ExtendsStatics extends HasStatics { +>ExtendsStatics : Symbol(ExtendsStatics, Decl(index.js, 188, 1)) +>HasStatics : Symbol(HasStatics, Decl(index.js, 184, 38)) + + static also() {} +>also : Symbol(ExtendsStatics.also, Decl(index.js, 190, 48)) +} + diff --git a/tests/baselines/reference/jsDeclarationsClasses.types b/tests/baselines/reference/jsDeclarationsClasses.types new file mode 100644 index 0000000000000..bbcea688c2691 --- /dev/null +++ b/tests/baselines/reference/jsDeclarationsClasses.types @@ -0,0 +1,331 @@ +=== tests/cases/conformance/jsdoc/declarations/index.js === +export class A {} +>A : A + +export class B { +>B : B + + static cat = "cat"; +>cat : string +>"cat" : "cat" +} + +export class C { +>C : C + + static Cls = class {} +>Cls : typeof (Anonymous class) +>class {} : typeof (Anonymous class) +} + +export class D { +>D : D + + /** + * @param {number} a + * @param {number} b + */ + constructor(a, b) {} +>a : number +>b : number +} + +/** + * @template T,U + */ +export class E { +>E : E + + /** + * @type {T & U} + */ + field; +>field : T & U + + // @readonly is currently unsupported, it seems - included here just in case that changes + /** + * @type {T & U} + * @readonly + */ + readonlyField; +>readonlyField : T & U + + initializedField = 12; +>initializedField : number +>12 : 12 + + /** + * @return {U} + */ + get f1() { return /** @type {*} */(null); } +>f1 : U +>(null) : any +>null : null + + /** + * @param {U} _p + */ + set f1(_p) {} +>f1 : U +>_p : U + + /** + * @return {U} + */ + get f2() { return /** @type {*} */(null); } +>f2 : U +>(null) : any +>null : null + + /** + * @param {U} _p + */ + set f3(_p) {} +>f3 : U +>_p : U + + /** + * @param {T} a + * @param {U} b + */ + constructor(a, b) {} +>a : T +>b : U + + + /** + * @type {string} + */ + static staticField; +>staticField : string + + // @readonly is currently unsupported, it seems - included here just in case that changes + /** + * @type {string} + * @readonly + */ + static staticReadonlyField; +>staticReadonlyField : string + + static staticInitializedField = 12; +>staticInitializedField : number +>12 : 12 + + /** + * @return {string} + */ + static get s1() { return ""; } +>s1 : string +>"" : "" + + /** + * @param {string} _p + */ + static set s1(_p) {} +>s1 : string +>_p : string + + /** + * @return {string} + */ + static get s2() { return ""; } +>s2 : string +>"" : "" + + /** + * @param {string} _p + */ + static set s3(_p) {} +>s3 : string +>_p : string +} + +/** + * @template T,U + */ +export class F { +>F : F + + /** + * @type {T & U} + */ + field; +>field : T & U + + /** + * @param {T} a + * @param {U} b + */ + constructor(a, b) {} +>a : T +>b : U + + /** + * @template A,B + * @param {A} a + * @param {B} b + */ + static create(a, b) { return new F(a, b); } +>create : (a: A, b: B) => F +>a : A +>b : B +>new F(a, b) : F +>F : typeof F +>a : A +>b : B +} + +class G {} +>G : G + +export { G }; +>G : typeof G + +class HH {} +>HH : HH + +export { HH as H }; +>HH : typeof HH +>H : typeof HH + +export class I {} +>I : I + +export { I as II }; +>I : typeof I +>II : typeof I + +export { J as JJ }; +>J : typeof J +>JJ : typeof J + +export class J {} +>J : J + + +export class K { +>K : K + + constructor() { + this.p1 = 12; +>this.p1 = 12 : 12 +>this.p1 : number +>this : this +>p1 : number +>12 : 12 + + this.p2 = "ok"; +>this.p2 = "ok" : "ok" +>this.p2 : string +>this : this +>p2 : string +>"ok" : "ok" + } + + method() { +>method : () => number + + return this.p1; +>this.p1 : number +>this : this +>p1 : number + } +} + +export class L extends K {} +>L : L +>K : K + +export class M extends null { +>M : M +>null : null + + constructor() { + this.prop = 12; +>this.prop = 12 : 12 +>this.prop : number +>this : this +>prop : number +>12 : 12 + } +} + + +/** + * @template T + */ +export class N extends L { +>N : N +>L : L + + /** + * @param {T} param + */ + constructor(param) { +>param : T + + super(); +>super() : void +>super : typeof L + + this.another = param; +>this.another = param : T +>this.another : T +>this : this +>another : T +>param : T + } +} + +/** + * @template U + * @extends {N} + */ +export class O extends N { +>O : O +>N : N + + /** + * @param {U} param + */ + constructor(param) { +>param : U + + super(param); +>super(param) : void +>super : typeof N +>param : U + + this.another2 = param; +>this.another2 = param : U +>this.another2 : U +>this : this +>another2 : U +>param : U + } +} + +var x = /** @type {*} */(null); +>x : any +>(null) : any +>null : null + +export class VariableBase extends x {} +>VariableBase : VariableBase +>x : any + +export class HasStatics { +>HasStatics : HasStatics + + static staticMethod() {} +>staticMethod : () => void +} + +export class ExtendsStatics extends HasStatics { +>ExtendsStatics : ExtendsStatics +>HasStatics : HasStatics + + static also() {} +>also : () => void +} + diff --git a/tests/baselines/reference/jsDeclarationsClassesErr.errors.txt b/tests/baselines/reference/jsDeclarationsClassesErr.errors.txt new file mode 100644 index 0000000000000..ef78bf109c843 --- /dev/null +++ b/tests/baselines/reference/jsDeclarationsClassesErr.errors.txt @@ -0,0 +1,136 @@ +tests/cases/conformance/jsdoc/declarations/index.js(4,16): error TS8004: 'type parameter declarations' can only be used in a .ts file. +tests/cases/conformance/jsdoc/declarations/index.js(5,12): error TS8010: 'types' can only be used in a .ts file. +tests/cases/conformance/jsdoc/declarations/index.js(8,16): error TS8004: 'type parameter declarations' can only be used in a .ts file. +tests/cases/conformance/jsdoc/declarations/index.js(8,29): error TS8011: 'type arguments' can only be used in a .ts file. +tests/cases/conformance/jsdoc/declarations/index.js(9,12): error TS8010: 'types' can only be used in a .ts file. +tests/cases/conformance/jsdoc/declarations/index.js(13,11): error TS8010: 'types' can only be used in a .ts file. +tests/cases/conformance/jsdoc/declarations/index.js(19,11): error TS8010: 'types' can only be used in a .ts file. +tests/cases/conformance/jsdoc/declarations/index.js(23,11): error TS8010: 'types' can only be used in a .ts file. +tests/cases/conformance/jsdoc/declarations/index.js(27,11): error TS8010: 'types' can only be used in a .ts file. +tests/cases/conformance/jsdoc/declarations/index.js(28,11): error TS8010: 'types' can only be used in a .ts file. +tests/cases/conformance/jsdoc/declarations/index.js(32,11): error TS8010: 'types' can only be used in a .ts file. +tests/cases/conformance/jsdoc/declarations/index.js(39,11): error TS8010: 'types' can only be used in a .ts file. +tests/cases/conformance/jsdoc/declarations/index.js(43,11): error TS8010: 'types' can only be used in a .ts file. +tests/cases/conformance/jsdoc/declarations/index.js(47,11): error TS8010: 'types' can only be used in a .ts file. +tests/cases/conformance/jsdoc/declarations/index.js(48,11): error TS8010: 'types' can only be used in a .ts file. +tests/cases/conformance/jsdoc/declarations/index.js(52,11): error TS8010: 'types' can only be used in a .ts file. +tests/cases/conformance/jsdoc/declarations/index.js(53,11): error TS8010: 'types' can only be used in a .ts file. +tests/cases/conformance/jsdoc/declarations/index.js(59,11): error TS8010: 'types' can only be used in a .ts file. +tests/cases/conformance/jsdoc/declarations/index.js(63,11): error TS8010: 'types' can only be used in a .ts file. +tests/cases/conformance/jsdoc/declarations/index.js(67,11): error TS8010: 'types' can only be used in a .ts file. +tests/cases/conformance/jsdoc/declarations/index.js(68,11): error TS8010: 'types' can only be used in a .ts file. + + +==== tests/cases/conformance/jsdoc/declarations/index.js (21 errors) ==== + // Pretty much all of this should be an error, (since index signatures and generics are forbidden in js), + // but we should be able to synthesize declarations from the symbols regardless + + export class M { + ~ +!!! error TS8004: 'type parameter declarations' can only be used in a .ts file. + field: T; + ~ +!!! error TS8010: 'types' can only be used in a .ts file. + } + + export class N extends M { + ~ +!!! error TS8004: 'type parameter declarations' can only be used in a .ts file. + ~ +!!! error TS8011: 'type arguments' can only be used in a .ts file. + other: U; + ~ +!!! error TS8010: 'types' can only be used in a .ts file. + } + + export class O { + [idx: string]: string; + ~~~~~~ +!!! error TS8010: 'types' can only be used in a .ts file. + } + + export class P extends O {} + + export class Q extends O { + [idx: string]: "ok"; + ~~~~~~ +!!! error TS8010: 'types' can only be used in a .ts file. + } + + export class R extends O { + [idx: number]: "ok"; + ~~~~~~ +!!! error TS8010: 'types' can only be used in a .ts file. + } + + export class S extends O { + [idx: string]: "ok"; + ~~~~~~ +!!! error TS8010: 'types' can only be used in a .ts file. + [idx: number]: never; + ~~~~~~ +!!! error TS8010: 'types' can only be used in a .ts file. + } + + export class T { + [idx: number]: string; + ~~~~~~ +!!! error TS8010: 'types' can only be used in a .ts file. + } + + export class U extends T {} + + + export class V extends T { + [idx: string]: string; + ~~~~~~ +!!! error TS8010: 'types' can only be used in a .ts file. + } + + export class W extends T { + [idx: number]: "ok"; + ~~~~~~ +!!! error TS8010: 'types' can only be used in a .ts file. + } + + export class X extends T { + [idx: string]: string; + ~~~~~~ +!!! error TS8010: 'types' can only be used in a .ts file. + [idx: number]: "ok"; + ~~~~~~ +!!! error TS8010: 'types' can only be used in a .ts file. + } + + export class Y { + [idx: string]: {x: number}; + ~~~~~~ +!!! error TS8010: 'types' can only be used in a .ts file. + [idx: number]: {x: number, y: number}; + ~~~~~~ +!!! error TS8010: 'types' can only be used in a .ts file. + } + + export class Z extends Y {} + + export class AA extends Y { + [idx: string]: {x: number, y: number}; + ~~~~~~ +!!! error TS8010: 'types' can only be used in a .ts file. + } + + export class BB extends Y { + [idx: number]: {x: 0, y: 0}; + ~~~~~~ +!!! error TS8010: 'types' can only be used in a .ts file. + } + + export class CC extends Y { + [idx: string]: {x: number, y: number}; + ~~~~~~ +!!! error TS8010: 'types' can only be used in a .ts file. + [idx: number]: {x: 0, y: 0}; + ~~~~~~ +!!! error TS8010: 'types' can only be used in a .ts file. + } + \ No newline at end of file diff --git a/tests/baselines/reference/jsDeclarationsClassesErr.js b/tests/baselines/reference/jsDeclarationsClassesErr.js new file mode 100644 index 0000000000000..0241e9693c673 --- /dev/null +++ b/tests/baselines/reference/jsDeclarationsClassesErr.js @@ -0,0 +1,290 @@ +//// [index.js] +// Pretty much all of this should be an error, (since index signatures and generics are forbidden in js), +// but we should be able to synthesize declarations from the symbols regardless + +export class M { + field: T; +} + +export class N extends M { + other: U; +} + +export class O { + [idx: string]: string; +} + +export class P extends O {} + +export class Q extends O { + [idx: string]: "ok"; +} + +export class R extends O { + [idx: number]: "ok"; +} + +export class S extends O { + [idx: string]: "ok"; + [idx: number]: never; +} + +export class T { + [idx: number]: string; +} + +export class U extends T {} + + +export class V extends T { + [idx: string]: string; +} + +export class W extends T { + [idx: number]: "ok"; +} + +export class X extends T { + [idx: string]: string; + [idx: number]: "ok"; +} + +export class Y { + [idx: string]: {x: number}; + [idx: number]: {x: number, y: number}; +} + +export class Z extends Y {} + +export class AA extends Y { + [idx: string]: {x: number, y: number}; +} + +export class BB extends Y { + [idx: number]: {x: 0, y: 0}; +} + +export class CC extends Y { + [idx: string]: {x: number, y: number}; + [idx: number]: {x: 0, y: 0}; +} + + +//// [index.js] +"use strict"; +// Pretty much all of this should be an error, (since index signatures and generics are forbidden in js), +// but we should be able to synthesize declarations from the symbols regardless +var __extends = (this && this.__extends) || (function () { + var extendStatics = function (d, b) { + 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 extendStatics(d, b); + }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +Object.defineProperty(exports, "__esModule", { value: true }); +var M = /** @class */ (function () { + function M() { + } + return M; +}()); +exports.M = M; +var N = /** @class */ (function (_super) { + __extends(N, _super); + function N() { + return _super !== null && _super.apply(this, arguments) || this; + } + return N; +}(M)); +exports.N = N; +var O = /** @class */ (function () { + function O() { + } + return O; +}()); +exports.O = O; +var P = /** @class */ (function (_super) { + __extends(P, _super); + function P() { + return _super !== null && _super.apply(this, arguments) || this; + } + return P; +}(O)); +exports.P = P; +var Q = /** @class */ (function (_super) { + __extends(Q, _super); + function Q() { + return _super !== null && _super.apply(this, arguments) || this; + } + return Q; +}(O)); +exports.Q = Q; +var R = /** @class */ (function (_super) { + __extends(R, _super); + function R() { + return _super !== null && _super.apply(this, arguments) || this; + } + return R; +}(O)); +exports.R = R; +var S = /** @class */ (function (_super) { + __extends(S, _super); + function S() { + return _super !== null && _super.apply(this, arguments) || this; + } + return S; +}(O)); +exports.S = S; +var T = /** @class */ (function () { + function T() { + } + return T; +}()); +exports.T = T; +var U = /** @class */ (function (_super) { + __extends(U, _super); + function U() { + return _super !== null && _super.apply(this, arguments) || this; + } + return U; +}(T)); +exports.U = U; +var V = /** @class */ (function (_super) { + __extends(V, _super); + function V() { + return _super !== null && _super.apply(this, arguments) || this; + } + return V; +}(T)); +exports.V = V; +var W = /** @class */ (function (_super) { + __extends(W, _super); + function W() { + return _super !== null && _super.apply(this, arguments) || this; + } + return W; +}(T)); +exports.W = W; +var X = /** @class */ (function (_super) { + __extends(X, _super); + function X() { + return _super !== null && _super.apply(this, arguments) || this; + } + return X; +}(T)); +exports.X = X; +var Y = /** @class */ (function () { + function Y() { + } + return Y; +}()); +exports.Y = Y; +var Z = /** @class */ (function (_super) { + __extends(Z, _super); + function Z() { + return _super !== null && _super.apply(this, arguments) || this; + } + return Z; +}(Y)); +exports.Z = Z; +var AA = /** @class */ (function (_super) { + __extends(AA, _super); + function AA() { + return _super !== null && _super.apply(this, arguments) || this; + } + return AA; +}(Y)); +exports.AA = AA; +var BB = /** @class */ (function (_super) { + __extends(BB, _super); + function BB() { + return _super !== null && _super.apply(this, arguments) || this; + } + return BB; +}(Y)); +exports.BB = BB; +var CC = /** @class */ (function (_super) { + __extends(CC, _super); + function CC() { + return _super !== null && _super.apply(this, arguments) || this; + } + return CC; +}(Y)); +exports.CC = CC; + + +//// [index.d.ts] +export class M { + field: T_1; +} +export class N extends M { + other: U_1; +} +export class O { + [idx: string]: string; +} +export class P extends O { +} +export class Q extends O { + [idx: string]: "ok"; +} +export class R extends O { + [idx: number]: "ok"; +} +export class S extends O { + [idx: string]: "ok"; + [idx: number]: never; +} +export class T { + [idx: number]: string; +} +export class U extends T { +} +export class V extends T { + [idx: string]: string; +} +export class W extends T { + [idx: number]: "ok"; +} +export class X extends T { + [idx: string]: string; + [idx: number]: "ok"; +} +export class Y { + [idx: string]: { + x: number; + }; + [idx: number]: { + x: number; + y: number; + }; +} +export class Z extends Y { +} +export class AA extends Y { + [idx: string]: { + x: number; + y: number; + }; +} +export class BB extends Y { + [idx: number]: { + x: 0; + y: 0; + }; +} +export class CC extends Y { + [idx: string]: { + x: number; + y: number; + }; + [idx: number]: { + x: 0; + y: 0; + }; +} diff --git a/tests/baselines/reference/jsDeclarationsClassesErr.symbols b/tests/baselines/reference/jsDeclarationsClassesErr.symbols new file mode 100644 index 0000000000000..3e0d026a83f66 --- /dev/null +++ b/tests/baselines/reference/jsDeclarationsClassesErr.symbols @@ -0,0 +1,153 @@ +=== tests/cases/conformance/jsdoc/declarations/index.js === +// Pretty much all of this should be an error, (since index signatures and generics are forbidden in js), +// but we should be able to synthesize declarations from the symbols regardless + +export class M { +>M : Symbol(M, Decl(index.js, 0, 0)) +>T : Symbol(T, Decl(index.js, 3, 15)) + + field: T; +>field : Symbol(M.field, Decl(index.js, 3, 19)) +>T : Symbol(T, Decl(index.js, 3, 15)) +} + +export class N extends M { +>N : Symbol(N, Decl(index.js, 5, 1)) +>U : Symbol(U, Decl(index.js, 7, 15)) +>M : Symbol(M, Decl(index.js, 0, 0)) +>U : Symbol(U, Decl(index.js, 7, 15)) + + other: U; +>other : Symbol(N.other, Decl(index.js, 7, 32)) +>U : Symbol(U, Decl(index.js, 7, 15)) +} + +export class O { +>O : Symbol(O, Decl(index.js, 9, 1)) + + [idx: string]: string; +>idx : Symbol(idx, Decl(index.js, 12, 5)) +} + +export class P extends O {} +>P : Symbol(P, Decl(index.js, 13, 1)) +>O : Symbol(O, Decl(index.js, 9, 1)) + +export class Q extends O { +>Q : Symbol(Q, Decl(index.js, 15, 27)) +>O : Symbol(O, Decl(index.js, 9, 1)) + + [idx: string]: "ok"; +>idx : Symbol(idx, Decl(index.js, 18, 5)) +} + +export class R extends O { +>R : Symbol(R, Decl(index.js, 19, 1)) +>O : Symbol(O, Decl(index.js, 9, 1)) + + [idx: number]: "ok"; +>idx : Symbol(idx, Decl(index.js, 22, 5)) +} + +export class S extends O { +>S : Symbol(S, Decl(index.js, 23, 1)) +>O : Symbol(O, Decl(index.js, 9, 1)) + + [idx: string]: "ok"; +>idx : Symbol(idx, Decl(index.js, 26, 5)) + + [idx: number]: never; +>idx : Symbol(idx, Decl(index.js, 27, 5)) +} + +export class T { +>T : Symbol(T, Decl(index.js, 28, 1)) + + [idx: number]: string; +>idx : Symbol(idx, Decl(index.js, 31, 5)) +} + +export class U extends T {} +>U : Symbol(U, Decl(index.js, 32, 1)) +>T : Symbol(T, Decl(index.js, 28, 1)) + + +export class V extends T { +>V : Symbol(V, Decl(index.js, 34, 27)) +>T : Symbol(T, Decl(index.js, 28, 1)) + + [idx: string]: string; +>idx : Symbol(idx, Decl(index.js, 38, 5)) +} + +export class W extends T { +>W : Symbol(W, Decl(index.js, 39, 1)) +>T : Symbol(T, Decl(index.js, 28, 1)) + + [idx: number]: "ok"; +>idx : Symbol(idx, Decl(index.js, 42, 5)) +} + +export class X extends T { +>X : Symbol(X, Decl(index.js, 43, 1)) +>T : Symbol(T, Decl(index.js, 28, 1)) + + [idx: string]: string; +>idx : Symbol(idx, Decl(index.js, 46, 5)) + + [idx: number]: "ok"; +>idx : Symbol(idx, Decl(index.js, 47, 5)) +} + +export class Y { +>Y : Symbol(Y, Decl(index.js, 48, 1)) + + [idx: string]: {x: number}; +>idx : Symbol(idx, Decl(index.js, 51, 5)) +>x : Symbol(x, Decl(index.js, 51, 20)) + + [idx: number]: {x: number, y: number}; +>idx : Symbol(idx, Decl(index.js, 52, 5)) +>x : Symbol(x, Decl(index.js, 52, 20)) +>y : Symbol(y, Decl(index.js, 52, 30)) +} + +export class Z extends Y {} +>Z : Symbol(Z, Decl(index.js, 53, 1)) +>Y : Symbol(Y, Decl(index.js, 48, 1)) + +export class AA extends Y { +>AA : Symbol(AA, Decl(index.js, 55, 27)) +>Y : Symbol(Y, Decl(index.js, 48, 1)) + + [idx: string]: {x: number, y: number}; +>idx : Symbol(idx, Decl(index.js, 58, 5)) +>x : Symbol(x, Decl(index.js, 58, 20)) +>y : Symbol(y, Decl(index.js, 58, 30)) +} + +export class BB extends Y { +>BB : Symbol(BB, Decl(index.js, 59, 1)) +>Y : Symbol(Y, Decl(index.js, 48, 1)) + + [idx: number]: {x: 0, y: 0}; +>idx : Symbol(idx, Decl(index.js, 62, 5)) +>x : Symbol(x, Decl(index.js, 62, 20)) +>y : Symbol(y, Decl(index.js, 62, 25)) +} + +export class CC extends Y { +>CC : Symbol(CC, Decl(index.js, 63, 1)) +>Y : Symbol(Y, Decl(index.js, 48, 1)) + + [idx: string]: {x: number, y: number}; +>idx : Symbol(idx, Decl(index.js, 66, 5)) +>x : Symbol(x, Decl(index.js, 66, 20)) +>y : Symbol(y, Decl(index.js, 66, 30)) + + [idx: number]: {x: 0, y: 0}; +>idx : Symbol(idx, Decl(index.js, 67, 5)) +>x : Symbol(x, Decl(index.js, 67, 20)) +>y : Symbol(y, Decl(index.js, 67, 25)) +} + diff --git a/tests/baselines/reference/jsDeclarationsClassesErr.types b/tests/baselines/reference/jsDeclarationsClassesErr.types new file mode 100644 index 0000000000000..83827f2658c9c --- /dev/null +++ b/tests/baselines/reference/jsDeclarationsClassesErr.types @@ -0,0 +1,148 @@ +=== tests/cases/conformance/jsdoc/declarations/index.js === +// Pretty much all of this should be an error, (since index signatures and generics are forbidden in js), +// but we should be able to synthesize declarations from the symbols regardless + +export class M { +>M : M + + field: T; +>field : T +} + +export class N extends M { +>N : N +>M : M + + other: U; +>other : U +} + +export class O { +>O : O + + [idx: string]: string; +>idx : string +} + +export class P extends O {} +>P : P +>O : O + +export class Q extends O { +>Q : Q +>O : O + + [idx: string]: "ok"; +>idx : string +} + +export class R extends O { +>R : R +>O : O + + [idx: number]: "ok"; +>idx : number +} + +export class S extends O { +>S : S +>O : O + + [idx: string]: "ok"; +>idx : string + + [idx: number]: never; +>idx : number +} + +export class T { +>T : T + + [idx: number]: string; +>idx : number +} + +export class U extends T {} +>U : U +>T : T + + +export class V extends T { +>V : V +>T : T + + [idx: string]: string; +>idx : string +} + +export class W extends T { +>W : W +>T : T + + [idx: number]: "ok"; +>idx : number +} + +export class X extends T { +>X : X +>T : T + + [idx: string]: string; +>idx : string + + [idx: number]: "ok"; +>idx : number +} + +export class Y { +>Y : Y + + [idx: string]: {x: number}; +>idx : string +>x : number + + [idx: number]: {x: number, y: number}; +>idx : number +>x : number +>y : number +} + +export class Z extends Y {} +>Z : Z +>Y : Y + +export class AA extends Y { +>AA : AA +>Y : Y + + [idx: string]: {x: number, y: number}; +>idx : string +>x : number +>y : number +} + +export class BB extends Y { +>BB : BB +>Y : Y + + [idx: number]: {x: 0, y: 0}; +>idx : number +>x : 0 +>y : 0 +} + +export class CC extends Y { +>CC : CC +>Y : Y + + [idx: string]: {x: number, y: number}; +>idx : string +>x : number +>y : number + + [idx: number]: {x: 0, y: 0}; +>idx : number +>x : 0 +>y : 0 +} + diff --git a/tests/baselines/reference/jsDeclarationsComputedNames.js b/tests/baselines/reference/jsDeclarationsComputedNames.js new file mode 100644 index 0000000000000..bbc3d5fa0ca61 --- /dev/null +++ b/tests/baselines/reference/jsDeclarationsComputedNames.js @@ -0,0 +1,92 @@ +//// [tests/cases/conformance/jsdoc/declarations/jsDeclarationsComputedNames.ts] //// + +//// [index.js] +const TopLevelSym = Symbol(); +const InnerSym = Symbol(); +module.exports = { + [TopLevelSym](x = 12) { + return x; + }, + items: { + [InnerSym]: (arg = {x: 12}) => arg.x + } +} + +//// [index2.js] +const TopLevelSym = Symbol(); +const InnerSym = Symbol(); + +export class MyClass { + static [TopLevelSym] = 12; + [InnerSym] = "ok"; + /** + * @param {typeof TopLevelSym | typeof InnerSym} _p + */ + constructor(_p = InnerSym) { + // switch on _p + } +} + + +//// [index.js] +var _a, _b; +var TopLevelSym = Symbol(); +var InnerSym = Symbol(); +module.exports = (_a = {}, + _a[TopLevelSym] = function (x) { + if (x === void 0) { x = 12; } + return x; + }, + _a.items = (_b = {}, + _b[InnerSym] = function (arg) { + if (arg === void 0) { arg = { x: 12 }; } + return arg.x; + }, + _b), + _a); +//// [index2.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +var TopLevelSym = Symbol(); +var InnerSym = Symbol(); +var MyClass = /** @class */ (function () { + /** + * @param {typeof TopLevelSym | typeof InnerSym} _p + */ + function MyClass(_p) { + if (_p === void 0) { _p = InnerSym; } + this[_b] = "ok"; + // switch on _p + } + var _a, _b; + _a = TopLevelSym, _b = InnerSym; + MyClass[_a] = 12; + return MyClass; +}()); +exports.MyClass = MyClass; + + +//// [index.d.ts] +declare const _exports: { + [TopLevelSym](x?: number): number; + items: { + [InnerSym]: (arg?: { + x: number; + }) => number; + }; +}; +export = _exports; +declare const TopLevelSym: unique symbol; +declare const InnerSym: unique symbol; +//// [index2.d.ts] +export class MyClass { + static [TopLevelSym]: number; + /** + * @param {typeof TopLevelSym | typeof InnerSym} _p + */ + constructor(_p?: typeof TopLevelSym | typeof InnerSym); + [InnerSym]: string; +} +declare const InnerSym: unique symbol; +declare const TopLevelSym: unique symbol; +export {}; diff --git a/tests/baselines/reference/jsDeclarationsComputedNames.symbols b/tests/baselines/reference/jsDeclarationsComputedNames.symbols new file mode 100644 index 0000000000000..2abc98e4edfc3 --- /dev/null +++ b/tests/baselines/reference/jsDeclarationsComputedNames.symbols @@ -0,0 +1,68 @@ +=== tests/cases/conformance/jsdoc/declarations/index.js === +const TopLevelSym = Symbol(); +>TopLevelSym : Symbol(TopLevelSym, Decl(index.js, 0, 5)) +>Symbol : Symbol(Symbol, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) + +const InnerSym = Symbol(); +>InnerSym : Symbol(InnerSym, Decl(index.js, 1, 5)) +>Symbol : Symbol(Symbol, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) + +module.exports = { +>module.exports : Symbol("tests/cases/conformance/jsdoc/declarations/index", Decl(index.js, 0, 0)) +>module : Symbol(export=, Decl(index.js, 1, 26)) +>exports : Symbol(export=, Decl(index.js, 1, 26)) + + [TopLevelSym](x = 12) { +>[TopLevelSym] : Symbol([TopLevelSym], Decl(index.js, 2, 18)) +>TopLevelSym : Symbol(TopLevelSym, Decl(index.js, 0, 5)) +>x : Symbol(x, Decl(index.js, 3, 18)) + + return x; +>x : Symbol(x, Decl(index.js, 3, 18)) + + }, + items: { +>items : Symbol(items, Decl(index.js, 5, 6)) + + [InnerSym]: (arg = {x: 12}) => arg.x +>[InnerSym] : Symbol([InnerSym], Decl(index.js, 6, 12)) +>InnerSym : Symbol(InnerSym, Decl(index.js, 1, 5)) +>arg : Symbol(arg, Decl(index.js, 7, 21)) +>x : Symbol(x, Decl(index.js, 7, 28)) +>arg.x : Symbol(x, Decl(index.js, 7, 28)) +>arg : Symbol(arg, Decl(index.js, 7, 21)) +>x : Symbol(x, Decl(index.js, 7, 28)) + } +} + +=== tests/cases/conformance/jsdoc/declarations/index2.js === +const TopLevelSym = Symbol(); +>TopLevelSym : Symbol(TopLevelSym, Decl(index2.js, 0, 5)) +>Symbol : Symbol(Symbol, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) + +const InnerSym = Symbol(); +>InnerSym : Symbol(InnerSym, Decl(index2.js, 1, 5)) +>Symbol : Symbol(Symbol, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) + +export class MyClass { +>MyClass : Symbol(MyClass, Decl(index2.js, 1, 26)) + + static [TopLevelSym] = 12; +>[TopLevelSym] : Symbol(MyClass[TopLevelSym], Decl(index2.js, 3, 22)) +>TopLevelSym : Symbol(TopLevelSym, Decl(index2.js, 0, 5)) + + [InnerSym] = "ok"; +>[InnerSym] : Symbol(MyClass[InnerSym], Decl(index2.js, 4, 30)) +>InnerSym : Symbol(InnerSym, Decl(index2.js, 1, 5)) + + /** + * @param {typeof TopLevelSym | typeof InnerSym} _p + */ + constructor(_p = InnerSym) { +>_p : Symbol(_p, Decl(index2.js, 9, 16)) +>InnerSym : Symbol(InnerSym, Decl(index2.js, 1, 5)) + + // switch on _p + } +} + diff --git a/tests/baselines/reference/jsDeclarationsComputedNames.types b/tests/baselines/reference/jsDeclarationsComputedNames.types new file mode 100644 index 0000000000000..ce79ab661c982 --- /dev/null +++ b/tests/baselines/reference/jsDeclarationsComputedNames.types @@ -0,0 +1,81 @@ +=== tests/cases/conformance/jsdoc/declarations/index.js === +const TopLevelSym = Symbol(); +>TopLevelSym : unique symbol +>Symbol() : unique symbol +>Symbol : SymbolConstructor + +const InnerSym = Symbol(); +>InnerSym : unique symbol +>Symbol() : unique symbol +>Symbol : SymbolConstructor + +module.exports = { +>module.exports = { [TopLevelSym](x = 12) { return x; }, items: { [InnerSym]: (arg = {x: 12}) => arg.x }} : { [TopLevelSym](x?: number): number; items: { [InnerSym]: (arg?: { x: number; }) => number; }; } +>module.exports : { [TopLevelSym](x?: number): number; items: { [InnerSym]: (arg?: { x: number; }) => number; }; } +>module : { "tests/cases/conformance/jsdoc/declarations/index": { [TopLevelSym](x?: number): number; items: { [InnerSym]: (arg?: { x: number; }) => number; }; }; } +>exports : { [TopLevelSym](x?: number): number; items: { [InnerSym]: (arg?: { x: number; }) => number; }; } +>{ [TopLevelSym](x = 12) { return x; }, items: { [InnerSym]: (arg = {x: 12}) => arg.x }} : { [TopLevelSym](x?: number): number; items: { [InnerSym]: (arg?: { x: number; }) => number; }; } + + [TopLevelSym](x = 12) { +>[TopLevelSym] : (x?: number) => number +>TopLevelSym : unique symbol +>x : number +>12 : 12 + + return x; +>x : number + + }, + items: { +>items : { [InnerSym]: (arg?: { x: number; }) => number; } +>{ [InnerSym]: (arg = {x: 12}) => arg.x } : { [InnerSym]: (arg?: { x: number; }) => number; } + + [InnerSym]: (arg = {x: 12}) => arg.x +>[InnerSym] : (arg?: { x: number; }) => number +>InnerSym : unique symbol +>(arg = {x: 12}) => arg.x : (arg?: { x: number; }) => number +>arg : { x: number; } +>{x: 12} : { x: number; } +>x : number +>12 : 12 +>arg.x : number +>arg : { x: number; } +>x : number + } +} + +=== tests/cases/conformance/jsdoc/declarations/index2.js === +const TopLevelSym = Symbol(); +>TopLevelSym : unique symbol +>Symbol() : unique symbol +>Symbol : SymbolConstructor + +const InnerSym = Symbol(); +>InnerSym : unique symbol +>Symbol() : unique symbol +>Symbol : SymbolConstructor + +export class MyClass { +>MyClass : MyClass + + static [TopLevelSym] = 12; +>[TopLevelSym] : number +>TopLevelSym : unique symbol +>12 : 12 + + [InnerSym] = "ok"; +>[InnerSym] : string +>InnerSym : unique symbol +>"ok" : "ok" + + /** + * @param {typeof TopLevelSym | typeof InnerSym} _p + */ + constructor(_p = InnerSym) { +>_p : unique symbol | unique symbol +>InnerSym : unique symbol + + // switch on _p + } +} + diff --git a/tests/baselines/reference/jsDeclarationsDefault.js b/tests/baselines/reference/jsDeclarationsDefault.js new file mode 100644 index 0000000000000..a7d8b248a39ce --- /dev/null +++ b/tests/baselines/reference/jsDeclarationsDefault.js @@ -0,0 +1,141 @@ +//// [tests/cases/conformance/jsdoc/declarations/jsDeclarationsDefault.ts] //// + +//// [index1.js] +export default 12; + +//// [index2.js] +export default function foo() { + return foo; +} +export const x = foo; +export { foo as bar }; + +//// [index3.js] +export default class Foo { + a = /** @type {Foo} */(null); +}; +export const X = Foo; +export { Foo as Bar }; + +//// [index4.js] +import Fab from "./index3"; +class Bar extends Fab { + x = /** @type {Bar} */(null); +} +export default Bar; + +//// [index5.js] +// merge type alias and const (OK) +export default 12; +/** + * @typedef {string | number} default + */ + +//// [index6.js] +// merge type alias and function (OK) +export default function func() {}; +/** + * @typedef {string | number} default + */ + + +//// [index1.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.default = 12; +//// [index2.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +function foo() { + return foo; +} +exports.default = foo; +exports.bar = foo; +exports.x = foo; +//// [index3.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +var Foo = /** @class */ (function () { + function Foo() { + this.a = (null); + } + return Foo; +}()); +exports.Bar = Foo; +exports.default = Foo; +; +exports.X = Foo; +//// [index4.js] +"use strict"; +var __extends = (this && this.__extends) || (function () { + var extendStatics = function (d, b) { + 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 extendStatics(d, b); + }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +Object.defineProperty(exports, "__esModule", { value: true }); +var index3_1 = require("./index3"); +var Bar = /** @class */ (function (_super) { + __extends(Bar, _super); + function Bar() { + var _this = _super !== null && _super.apply(this, arguments) || this; + _this.x = (null); + return _this; + } + return Bar; +}(index3_1.default)); +exports.default = Bar; +//// [index5.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +// merge type alias and const (OK) +exports.default = 12; +/** + * @typedef {string | number} default + */ +//// [index6.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +// merge type alias and function (OK) +function func() { } +exports.default = func; +; +/** + * @typedef {string | number} default + */ + + +//// [index1.d.ts] +declare var _default: 12; +export default _default; +//// [index2.d.ts] +export default function foo(): typeof foo; +export function x(): typeof foo; +export { foo as bar }; +//// [index3.d.ts] +export default class Foo { + a: Foo; +} +export const X: typeof Foo; +export { Foo as Bar }; +//// [index4.d.ts] +export default Bar; +declare class Bar extends Fab { + x: Bar; +} +import Fab from "./index3"; +//// [index5.d.ts] +type _default = string | number; +declare var _default: 12; +export default _default; +//// [index6.d.ts] +declare function func(): void; +type func = string | number; +export default func; diff --git a/tests/baselines/reference/jsDeclarationsDefault.symbols b/tests/baselines/reference/jsDeclarationsDefault.symbols new file mode 100644 index 0000000000000..4436c83d40ec0 --- /dev/null +++ b/tests/baselines/reference/jsDeclarationsDefault.symbols @@ -0,0 +1,64 @@ +=== tests/cases/conformance/jsdoc/declarations/index1.js === +export default 12; +No type information for this code. +No type information for this code.=== tests/cases/conformance/jsdoc/declarations/index2.js === +export default function foo() { +>foo : Symbol(foo, Decl(index2.js, 0, 0)) + + return foo; +>foo : Symbol(foo, Decl(index2.js, 0, 0)) +} +export const x = foo; +>x : Symbol(x, Decl(index2.js, 3, 12)) +>foo : Symbol(foo, Decl(index2.js, 0, 0)) + +export { foo as bar }; +>foo : Symbol(foo, Decl(index2.js, 0, 0)) +>bar : Symbol(bar, Decl(index2.js, 4, 8)) + +=== tests/cases/conformance/jsdoc/declarations/index3.js === +export default class Foo { +>Foo : Symbol(Foo, Decl(index3.js, 0, 0)) + + a = /** @type {Foo} */(null); +>a : Symbol(Foo.a, Decl(index3.js, 0, 26)) + +}; +export const X = Foo; +>X : Symbol(X, Decl(index3.js, 3, 12)) +>Foo : Symbol(Foo, Decl(index3.js, 0, 0)) + +export { Foo as Bar }; +>Foo : Symbol(Foo, Decl(index3.js, 0, 0)) +>Bar : Symbol(Bar, Decl(index3.js, 4, 8)) + +=== tests/cases/conformance/jsdoc/declarations/index4.js === +import Fab from "./index3"; +>Fab : Symbol(Fab, Decl(index4.js, 0, 6)) + +class Bar extends Fab { +>Bar : Symbol(Bar, Decl(index4.js, 0, 27)) +>Fab : Symbol(Fab, Decl(index4.js, 0, 6)) + + x = /** @type {Bar} */(null); +>x : Symbol(Bar.x, Decl(index4.js, 1, 23)) +} +export default Bar; +>Bar : Symbol(Bar, Decl(index4.js, 0, 27)) + +=== tests/cases/conformance/jsdoc/declarations/index5.js === +// merge type alias and const (OK) +No type information for this code.export default 12; +No type information for this code./** +No type information for this code. * @typedef {string | number} default +No type information for this code. */ +No type information for this code. +No type information for this code.=== tests/cases/conformance/jsdoc/declarations/index6.js === +// merge type alias and function (OK) +export default function func() {}; +>func : Symbol(func, Decl(index6.js, 0, 0), Decl(index6.js, 3, 3)) + +/** + * @typedef {string | number} default + */ + diff --git a/tests/baselines/reference/jsDeclarationsDefault.types b/tests/baselines/reference/jsDeclarationsDefault.types new file mode 100644 index 0000000000000..df45a2a221c2f --- /dev/null +++ b/tests/baselines/reference/jsDeclarationsDefault.types @@ -0,0 +1,68 @@ +=== tests/cases/conformance/jsdoc/declarations/index1.js === +export default 12; +No type information for this code. +No type information for this code.=== tests/cases/conformance/jsdoc/declarations/index2.js === +export default function foo() { +>foo : () => typeof foo + + return foo; +>foo : () => typeof foo +} +export const x = foo; +>x : () => typeof foo +>foo : () => typeof foo + +export { foo as bar }; +>foo : () => typeof foo +>bar : () => typeof foo + +=== tests/cases/conformance/jsdoc/declarations/index3.js === +export default class Foo { +>Foo : Foo + + a = /** @type {Foo} */(null); +>a : Foo +>(null) : Foo +>null : null + +}; +export const X = Foo; +>X : typeof Foo +>Foo : typeof Foo + +export { Foo as Bar }; +>Foo : typeof Foo +>Bar : typeof Foo + +=== tests/cases/conformance/jsdoc/declarations/index4.js === +import Fab from "./index3"; +>Fab : typeof Fab + +class Bar extends Fab { +>Bar : Bar +>Fab : Fab + + x = /** @type {Bar} */(null); +>x : Bar +>(null) : Bar +>null : null +} +export default Bar; +>Bar : Bar + +=== tests/cases/conformance/jsdoc/declarations/index5.js === +// merge type alias and const (OK) +No type information for this code.export default 12; +No type information for this code./** +No type information for this code. * @typedef {string | number} default +No type information for this code. */ +No type information for this code. +No type information for this code.=== tests/cases/conformance/jsdoc/declarations/index6.js === +// merge type alias and function (OK) +export default function func() {}; +>func : () => void + +/** + * @typedef {string | number} default + */ + diff --git a/tests/baselines/reference/jsDeclarationsDefaultsErr.errors.txt b/tests/baselines/reference/jsDeclarationsDefaultsErr.errors.txt new file mode 100644 index 0000000000000..8c8f7c36e66f3 --- /dev/null +++ b/tests/baselines/reference/jsDeclarationsDefaultsErr.errors.txt @@ -0,0 +1,34 @@ +tests/cases/conformance/jsdoc/declarations/index2.js(2,22): error TS2300: Duplicate identifier 'C'. +tests/cases/conformance/jsdoc/declarations/index2.js(4,31): error TS2300: Duplicate identifier 'default'. + + +==== tests/cases/conformance/jsdoc/declarations/index1.js (0 errors) ==== + // merge type alias and alias (should error, see #32367) + class Cls { + x = 12; + static y = "ok" + } + export default Cls; + /** + * @typedef {string | number} default + */ + +==== tests/cases/conformance/jsdoc/declarations/index2.js (2 errors) ==== + // merge type alias and class (error message improvement needed, see #32368) + export default class C {}; + ~ +!!! error TS2300: Duplicate identifier 'C'. + /** + * @typedef {string | number} default + ~~~~~~~ +!!! error TS2300: Duplicate identifier 'default'. + */ + +==== tests/cases/conformance/jsdoc/declarations/index3.js (0 errors) ==== + // merge type alias and variable (behavior is borked, see #32366) + const x = 12; + export {x as default}; + /** + * @typedef {string | number} default + */ + \ No newline at end of file diff --git a/tests/baselines/reference/jsDeclarationsDefaultsErr.js b/tests/baselines/reference/jsDeclarationsDefaultsErr.js new file mode 100644 index 0000000000000..ddc7a0328187b --- /dev/null +++ b/tests/baselines/reference/jsDeclarationsDefaultsErr.js @@ -0,0 +1,83 @@ +//// [tests/cases/conformance/jsdoc/declarations/jsDeclarationsDefaultsErr.ts] //// + +//// [index1.js] +// merge type alias and alias (should error, see #32367) +class Cls { + x = 12; + static y = "ok" +} +export default Cls; +/** + * @typedef {string | number} default + */ + +//// [index2.js] +// merge type alias and class (error message improvement needed, see #32368) +export default class C {}; +/** + * @typedef {string | number} default + */ + +//// [index3.js] +// merge type alias and variable (behavior is borked, see #32366) +const x = 12; +export {x as default}; +/** + * @typedef {string | number} default + */ + + +//// [index1.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +// merge type alias and alias (should error, see #32367) +var Cls = /** @class */ (function () { + function Cls() { + this.x = 12; + } + Cls.y = "ok"; + return Cls; +}()); +exports.default = Cls; +/** + * @typedef {string | number} default + */ +//// [index2.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +// merge type alias and class (error message improvement needed, see #32368) +var C = /** @class */ (function () { + function C() { + } + return C; +}()); +exports.default = C; +; +/** + * @typedef {string | number} default + */ +//// [index3.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +// merge type alias and variable (behavior is borked, see #32366) +var x = 12; +exports.default = x; +/** + * @typedef {string | number} default + */ + + +//// [index1.d.ts] +export type Cls = string | number; +export default Cls; +declare class Cls { + static y: string; + x: number; +} +//// [index2.d.ts] +export default class C { +} +//// [index3.d.ts] +export type _default = string | number; +export { x as default }; +declare const x: 12; diff --git a/tests/baselines/reference/jsDeclarationsDefaultsErr.symbols b/tests/baselines/reference/jsDeclarationsDefaultsErr.symbols new file mode 100644 index 0000000000000..e21977c355d70 --- /dev/null +++ b/tests/baselines/reference/jsDeclarationsDefaultsErr.symbols @@ -0,0 +1,40 @@ +=== tests/cases/conformance/jsdoc/declarations/index1.js === +// merge type alias and alias (should error, see #32367) +class Cls { +>Cls : Symbol(Cls, Decl(index1.js, 0, 0)) + + x = 12; +>x : Symbol(Cls.x, Decl(index1.js, 1, 11)) + + static y = "ok" +>y : Symbol(Cls.y, Decl(index1.js, 2, 11)) +} +export default Cls; +>Cls : Symbol(Cls, Decl(index1.js, 0, 0)) + +/** + * @typedef {string | number} default + */ + +=== tests/cases/conformance/jsdoc/declarations/index2.js === +// merge type alias and class (error message improvement needed, see #32368) +export default class C {}; +>C : Symbol(C, Decl(index2.js, 0, 0)) + +/** + * @typedef {string | number} default + */ + +=== tests/cases/conformance/jsdoc/declarations/index3.js === +// merge type alias and variable (behavior is borked, see #32366) +const x = 12; +>x : Symbol(x, Decl(index3.js, 1, 5)) + +export {x as default}; +>x : Symbol(x, Decl(index3.js, 1, 5)) +>default : Symbol(default, Decl(index3.js, 2, 8), Decl(index3.js, 4, 3)) + +/** + * @typedef {string | number} default + */ + diff --git a/tests/baselines/reference/jsDeclarationsDefaultsErr.types b/tests/baselines/reference/jsDeclarationsDefaultsErr.types new file mode 100644 index 0000000000000..8580c1514e433 --- /dev/null +++ b/tests/baselines/reference/jsDeclarationsDefaultsErr.types @@ -0,0 +1,43 @@ +=== tests/cases/conformance/jsdoc/declarations/index1.js === +// merge type alias and alias (should error, see #32367) +class Cls { +>Cls : Cls + + x = 12; +>x : number +>12 : 12 + + static y = "ok" +>y : string +>"ok" : "ok" +} +export default Cls; +>Cls : Cls + +/** + * @typedef {string | number} default + */ + +=== tests/cases/conformance/jsdoc/declarations/index2.js === +// merge type alias and class (error message improvement needed, see #32368) +export default class C {}; +>C : C + +/** + * @typedef {string | number} default + */ + +=== tests/cases/conformance/jsdoc/declarations/index3.js === +// merge type alias and variable (behavior is borked, see #32366) +const x = 12; +>x : 12 +>12 : 12 + +export {x as default}; +>x : 12 +>default : 12 + +/** + * @typedef {string | number} default + */ + diff --git a/tests/baselines/reference/jsDeclarationsEnumTag.js b/tests/baselines/reference/jsDeclarationsEnumTag.js new file mode 100644 index 0000000000000..7e938fbbdd4ab --- /dev/null +++ b/tests/baselines/reference/jsDeclarationsEnumTag.js @@ -0,0 +1,130 @@ +//// [index.js] +/** @enum {string} */ +export const Target = { + START: "start", + MIDDLE: "middle", + END: "end", + /** @type {number} */ + OK_I_GUESS: 2 +} +/** @enum number */ +export const Second = { + OK: 1, + /** @type {number} */ + FINE: 2, +} +/** @enum {function(number): number} */ +export const Fs = { + ADD1: n => n + 1, + ID: n => n, + SUB1: n => n - 1 +} + +/** + * @param {Target} t + * @param {Second} s + * @param {Fs} f + */ +export function consume(t,s,f) { + /** @type {string} */ + var str = t + /** @type {number} */ + var num = s + /** @type {(n: number) => number} */ + var fun = f + /** @type {Target} */ + var v = Target.START + v = 'something else' // allowed, like Typescript's classic enums and unlike its string enums +} +/** @param {string} s */ +export function ff(s) { + // element access with arbitrary string is an error only with noImplicitAny + if (!Target[s]) { + return null + } + else { + return Target[s] + } +} + + +//// [index.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +/** @enum {string} */ +exports.Target = { + START: "start", + MIDDLE: "middle", + END: "end", + /** @type {number} */ + OK_I_GUESS: 2 +}; +/** @enum number */ +exports.Second = { + OK: 1, + /** @type {number} */ + FINE: 2, +}; +/** @enum {function(number): number} */ +exports.Fs = { + ADD1: function (n) { return n + 1; }, + ID: function (n) { return n; }, + SUB1: function (n) { return n - 1; } +}; +/** + * @param {Target} t + * @param {Second} s + * @param {Fs} f + */ +function consume(t, s, f) { + /** @type {string} */ + var str = t; + /** @type {number} */ + var num = s; + /** @type {(n: number) => number} */ + var fun = f; + /** @type {Target} */ + var v = exports.Target.START; + v = 'something else'; // allowed, like Typescript's classic enums and unlike its string enums +} +exports.consume = consume; +/** @param {string} s */ +function ff(s) { + // element access with arbitrary string is an error only with noImplicitAny + if (!exports.Target[s]) { + return null; + } + else { + return exports.Target[s]; + } +} +exports.ff = ff; + + +//// [index.d.ts] +/** + * @param {Target} t + * @param {Second} s + * @param {Fs} f + */ +export function consume(t: string, s: number, f: (arg0: number) => number): void; +/** @param {string} s */ +export function ff(s: string): any; +export type Target = string; +export namespace Target { + export const START: string; + export const MIDDLE: string; + export const END: string; + export const OK_I_GUESS: number; +} +export type Second = number; +export namespace Second { + export const OK: number; + export const FINE: number; +} +export type Fs = (arg0: number) => number; +export namespace Fs { + export function ADD1(n: any): any; + export function ID(n: any): any; + export function SUB1(n: any): number; +} diff --git a/tests/baselines/reference/jsDeclarationsEnumTag.symbols b/tests/baselines/reference/jsDeclarationsEnumTag.symbols new file mode 100644 index 0000000000000..d2e73aaca5a55 --- /dev/null +++ b/tests/baselines/reference/jsDeclarationsEnumTag.symbols @@ -0,0 +1,104 @@ +=== tests/cases/conformance/jsdoc/declarations/index.js === +/** @enum {string} */ +export const Target = { +>Target : Symbol(Target, Decl(index.js, 1, 12), Decl(index.js, 0, 4)) + + START: "start", +>START : Symbol(START, Decl(index.js, 1, 23)) + + MIDDLE: "middle", +>MIDDLE : Symbol(MIDDLE, Decl(index.js, 2, 19)) + + END: "end", +>END : Symbol(END, Decl(index.js, 3, 21)) + + /** @type {number} */ + OK_I_GUESS: 2 +>OK_I_GUESS : Symbol(OK_I_GUESS, Decl(index.js, 4, 15)) +} +/** @enum number */ +export const Second = { +>Second : Symbol(Second, Decl(index.js, 9, 12), Decl(index.js, 8, 4)) + + OK: 1, +>OK : Symbol(OK, Decl(index.js, 9, 23)) + + /** @type {number} */ + FINE: 2, +>FINE : Symbol(FINE, Decl(index.js, 10, 10)) +} +/** @enum {function(number): number} */ +export const Fs = { +>Fs : Symbol(Fs, Decl(index.js, 15, 12), Decl(index.js, 14, 4)) + + ADD1: n => n + 1, +>ADD1 : Symbol(ADD1, Decl(index.js, 15, 19)) +>n : Symbol(n, Decl(index.js, 16, 9)) +>n : Symbol(n, Decl(index.js, 16, 9)) + + ID: n => n, +>ID : Symbol(ID, Decl(index.js, 16, 21)) +>n : Symbol(n, Decl(index.js, 17, 7)) +>n : Symbol(n, Decl(index.js, 17, 7)) + + SUB1: n => n - 1 +>SUB1 : Symbol(SUB1, Decl(index.js, 17, 15)) +>n : Symbol(n, Decl(index.js, 18, 9)) +>n : Symbol(n, Decl(index.js, 18, 9)) +} + +/** + * @param {Target} t + * @param {Second} s + * @param {Fs} f + */ +export function consume(t,s,f) { +>consume : Symbol(consume, Decl(index.js, 19, 1)) +>t : Symbol(t, Decl(index.js, 26, 24)) +>s : Symbol(s, Decl(index.js, 26, 26)) +>f : Symbol(f, Decl(index.js, 26, 28)) + + /** @type {string} */ + var str = t +>str : Symbol(str, Decl(index.js, 28, 7)) +>t : Symbol(t, Decl(index.js, 26, 24)) + + /** @type {number} */ + var num = s +>num : Symbol(num, Decl(index.js, 30, 7)) +>s : Symbol(s, Decl(index.js, 26, 26)) + + /** @type {(n: number) => number} */ + var fun = f +>fun : Symbol(fun, Decl(index.js, 32, 7)) +>f : Symbol(f, Decl(index.js, 26, 28)) + + /** @type {Target} */ + var v = Target.START +>v : Symbol(v, Decl(index.js, 34, 7)) +>Target.START : Symbol(START, Decl(index.js, 1, 23)) +>Target : Symbol(Target, Decl(index.js, 1, 12), Decl(index.js, 0, 4)) +>START : Symbol(START, Decl(index.js, 1, 23)) + + v = 'something else' // allowed, like Typescript's classic enums and unlike its string enums +>v : Symbol(v, Decl(index.js, 34, 7)) +} +/** @param {string} s */ +export function ff(s) { +>ff : Symbol(ff, Decl(index.js, 36, 1)) +>s : Symbol(s, Decl(index.js, 38, 19)) + + // element access with arbitrary string is an error only with noImplicitAny + if (!Target[s]) { +>Target : Symbol(Target, Decl(index.js, 1, 12), Decl(index.js, 0, 4)) +>s : Symbol(s, Decl(index.js, 38, 19)) + + return null + } + else { + return Target[s] +>Target : Symbol(Target, Decl(index.js, 1, 12), Decl(index.js, 0, 4)) +>s : Symbol(s, Decl(index.js, 38, 19)) + } +} + diff --git a/tests/baselines/reference/jsDeclarationsEnumTag.types b/tests/baselines/reference/jsDeclarationsEnumTag.types new file mode 100644 index 0000000000000..642ee7d6490fd --- /dev/null +++ b/tests/baselines/reference/jsDeclarationsEnumTag.types @@ -0,0 +1,126 @@ +=== tests/cases/conformance/jsdoc/declarations/index.js === +/** @enum {string} */ +export const Target = { +>Target : { START: string; MIDDLE: string; END: string; OK_I_GUESS: number; } +>{ START: "start", MIDDLE: "middle", END: "end", /** @type {number} */ OK_I_GUESS: 2} : { START: string; MIDDLE: string; END: string; OK_I_GUESS: number; } + + START: "start", +>START : string +>"start" : "start" + + MIDDLE: "middle", +>MIDDLE : string +>"middle" : "middle" + + END: "end", +>END : string +>"end" : "end" + + /** @type {number} */ + OK_I_GUESS: 2 +>OK_I_GUESS : number +>2 : 2 +} +/** @enum number */ +export const Second = { +>Second : { OK: number; FINE: number; } +>{ OK: 1, /** @type {number} */ FINE: 2,} : { OK: number; FINE: number; } + + OK: 1, +>OK : number +>1 : 1 + + /** @type {number} */ + FINE: 2, +>FINE : number +>2 : 2 +} +/** @enum {function(number): number} */ +export const Fs = { +>Fs : { ADD1: (n: any) => any; ID: (n: any) => any; SUB1: (n: any) => number; } +>{ ADD1: n => n + 1, ID: n => n, SUB1: n => n - 1} : { ADD1: (n: any) => any; ID: (n: any) => any; SUB1: (n: any) => number; } + + ADD1: n => n + 1, +>ADD1 : (n: any) => any +>n => n + 1 : (n: any) => any +>n : any +>n + 1 : any +>n : any +>1 : 1 + + ID: n => n, +>ID : (n: any) => any +>n => n : (n: any) => any +>n : any +>n : any + + SUB1: n => n - 1 +>SUB1 : (n: any) => number +>n => n - 1 : (n: any) => number +>n : any +>n - 1 : number +>n : any +>1 : 1 +} + +/** + * @param {Target} t + * @param {Second} s + * @param {Fs} f + */ +export function consume(t,s,f) { +>consume : (t: string, s: number, f: (arg0: number) => number) => void +>t : string +>s : number +>f : (arg0: number) => number + + /** @type {string} */ + var str = t +>str : string +>t : string + + /** @type {number} */ + var num = s +>num : number +>s : number + + /** @type {(n: number) => number} */ + var fun = f +>fun : (n: number) => number +>f : (arg0: number) => number + + /** @type {Target} */ + var v = Target.START +>v : string +>Target.START : string +>Target : { START: string; MIDDLE: string; END: string; OK_I_GUESS: number; } +>START : string + + v = 'something else' // allowed, like Typescript's classic enums and unlike its string enums +>v = 'something else' : "something else" +>v : string +>'something else' : "something else" +} +/** @param {string} s */ +export function ff(s) { +>ff : (s: string) => any +>s : string + + // element access with arbitrary string is an error only with noImplicitAny + if (!Target[s]) { +>!Target[s] : boolean +>Target[s] : error +>Target : { START: string; MIDDLE: string; END: string; OK_I_GUESS: number; } +>s : string + + return null +>null : null + } + else { + return Target[s] +>Target[s] : error +>Target : { START: string; MIDDLE: string; END: string; OK_I_GUESS: number; } +>s : string + } +} + diff --git a/tests/baselines/reference/jsDeclarationsEnums.errors.txt b/tests/baselines/reference/jsDeclarationsEnums.errors.txt new file mode 100644 index 0000000000000..630d4aab7e9ad --- /dev/null +++ b/tests/baselines/reference/jsDeclarationsEnums.errors.txt @@ -0,0 +1,101 @@ +tests/cases/conformance/jsdoc/declarations/index.js(4,13): error TS8015: 'enum declarations' can only be used in a .ts file. +tests/cases/conformance/jsdoc/declarations/index.js(6,13): error TS8015: 'enum declarations' can only be used in a .ts file. +tests/cases/conformance/jsdoc/declarations/index.js(10,6): error TS8015: 'enum declarations' can only be used in a .ts file. +tests/cases/conformance/jsdoc/declarations/index.js(14,6): error TS8015: 'enum declarations' can only be used in a .ts file. +tests/cases/conformance/jsdoc/declarations/index.js(18,13): error TS8015: 'enum declarations' can only be used in a .ts file. +tests/cases/conformance/jsdoc/declarations/index.js(22,13): error TS8015: 'enum declarations' can only be used in a .ts file. +tests/cases/conformance/jsdoc/declarations/index.js(24,13): error TS8015: 'enum declarations' can only be used in a .ts file. +tests/cases/conformance/jsdoc/declarations/index.js(30,13): error TS8015: 'enum declarations' can only be used in a .ts file. +tests/cases/conformance/jsdoc/declarations/index.js(35,13): error TS8015: 'enum declarations' can only be used in a .ts file. +tests/cases/conformance/jsdoc/declarations/index.js(41,19): error TS8015: 'enum declarations' can only be used in a .ts file. +tests/cases/conformance/jsdoc/declarations/index.js(47,13): error TS8015: 'enum declarations' can only be used in a .ts file. +tests/cases/conformance/jsdoc/declarations/index.js(55,19): error TS8015: 'enum declarations' can only be used in a .ts file. + + +==== tests/cases/conformance/jsdoc/declarations/index.js (12 errors) ==== + // Pretty much all of this should be an error, (since enums are forbidden in js), + // but we should be able to synthesize declarations from the symbols regardless + + export enum A {} + ~ +!!! error TS8015: 'enum declarations' can only be used in a .ts file. + + export enum B { + ~ +!!! error TS8015: 'enum declarations' can only be used in a .ts file. + Member + } + + enum C {} + ~ +!!! error TS8015: 'enum declarations' can only be used in a .ts file. + + export { C }; + + enum DD {} + ~~ +!!! error TS8015: 'enum declarations' can only be used in a .ts file. + + export { DD as D }; + + export enum E {} + ~ +!!! error TS8015: 'enum declarations' can only be used in a .ts file. + export { E as EE }; + + export { F as FF }; + export enum F {} + ~ +!!! error TS8015: 'enum declarations' can only be used in a .ts file. + + export enum G { + ~ +!!! error TS8015: 'enum declarations' can only be used in a .ts file. + A = 1, + B, + C + } + + export enum H { + ~ +!!! error TS8015: 'enum declarations' can only be used in a .ts file. + A = "a", + B = "b" + } + + export enum I { + ~ +!!! error TS8015: 'enum declarations' can only be used in a .ts file. + A = "a", + B = 0, + C + } + + export const enum J { + ~ +!!! error TS8015: 'enum declarations' can only be used in a .ts file. + A = 1, + B, + C + } + + export enum K { + ~ +!!! error TS8015: 'enum declarations' can only be used in a .ts file. + None = 0, + A = 1 << 0, + B = 1 << 1, + C = 1 << 2, + Mask = A | B | C, + } + + export const enum L { + ~ +!!! error TS8015: 'enum declarations' can only be used in a .ts file. + None = 0, + A = 1 << 0, + B = 1 << 1, + C = 1 << 2, + Mask = A | B | C, + } + \ No newline at end of file diff --git a/tests/baselines/reference/jsDeclarationsEnums.js b/tests/baselines/reference/jsDeclarationsEnums.js new file mode 100644 index 0000000000000..3fc6201b904ae --- /dev/null +++ b/tests/baselines/reference/jsDeclarationsEnums.js @@ -0,0 +1,167 @@ +//// [index.js] +// Pretty much all of this should be an error, (since enums are forbidden in js), +// but we should be able to synthesize declarations from the symbols regardless + +export enum A {} + +export enum B { + Member +} + +enum C {} + +export { C }; + +enum DD {} + +export { DD as D }; + +export enum E {} +export { E as EE }; + +export { F as FF }; +export enum F {} + +export enum G { + A = 1, + B, + C +} + +export enum H { + A = "a", + B = "b" +} + +export enum I { + A = "a", + B = 0, + C +} + +export const enum J { + A = 1, + B, + C +} + +export enum K { + None = 0, + A = 1 << 0, + B = 1 << 1, + C = 1 << 2, + Mask = A | B | C, +} + +export const enum L { + None = 0, + A = 1 << 0, + B = 1 << 1, + C = 1 << 2, + Mask = A | B | C, +} + + +//// [index.js] +"use strict"; +// Pretty much all of this should be an error, (since enums are forbidden in js), +// but we should be able to synthesize declarations from the symbols regardless +Object.defineProperty(exports, "__esModule", { value: true }); +var A; +(function (A) { +})(A = exports.A || (exports.A = {})); +var B; +(function (B) { + B[B["Member"] = 0] = "Member"; +})(B = exports.B || (exports.B = {})); +var C; +(function (C) { +})(C || (C = {})); +exports.C = C; +var DD; +(function (DD) { +})(DD || (DD = {})); +exports.D = DD; +var E; +(function (E) { +})(E = exports.E || (exports.E = {})); +exports.EE = E; +var F; +(function (F) { +})(F = exports.F || (exports.F = {})); +exports.FF = F; +var G; +(function (G) { + G[G["A"] = 1] = "A"; + G[G["B"] = 2] = "B"; + G[G["C"] = 3] = "C"; +})(G = exports.G || (exports.G = {})); +var H; +(function (H) { + H["A"] = "a"; + H["B"] = "b"; +})(H = exports.H || (exports.H = {})); +var I; +(function (I) { + I["A"] = "a"; + I[I["B"] = 0] = "B"; + I[I["C"] = 1] = "C"; +})(I = exports.I || (exports.I = {})); +var K; +(function (K) { + K[K["None"] = 0] = "None"; + K[K["A"] = 1] = "A"; + K[K["B"] = 2] = "B"; + K[K["C"] = 4] = "C"; + K[K["Mask"] = 7] = "Mask"; +})(K = exports.K || (exports.K = {})); + + +//// [index.d.ts] +export enum A { +} +export enum B { + Member = 0 +} +export enum E { +} +export enum F { +} +export enum G { + A = 1, + B = 2, + C = 3 +} +export enum H { + A = "a", + B = "b" +} +export enum I { + A = "a", + B = 0, + C = 1 +} +export const enum J { + A = 1, + B = 2, + C = 3 +} +export enum K { + None = 0, + A = 1, + B = 2, + C = 4, + Mask = 7 +} +export const enum L { + None = 0, + A = 1, + B = 2, + C = 4, + Mask = 7 +} +export enum C { +} +declare enum DD { +} +export { DD as D, E as EE, F as FF }; diff --git a/tests/baselines/reference/jsDeclarationsEnums.symbols b/tests/baselines/reference/jsDeclarationsEnums.symbols new file mode 100644 index 0000000000000..7980af3801920 --- /dev/null +++ b/tests/baselines/reference/jsDeclarationsEnums.symbols @@ -0,0 +1,134 @@ +=== tests/cases/conformance/jsdoc/declarations/index.js === +// Pretty much all of this should be an error, (since enums are forbidden in js), +// but we should be able to synthesize declarations from the symbols regardless + +export enum A {} +>A : Symbol(A, Decl(index.js, 0, 0)) + +export enum B { +>B : Symbol(B, Decl(index.js, 3, 16)) + + Member +>Member : Symbol(B.Member, Decl(index.js, 5, 15)) +} + +enum C {} +>C : Symbol(C, Decl(index.js, 7, 1)) + +export { C }; +>C : Symbol(C, Decl(index.js, 11, 8)) + +enum DD {} +>DD : Symbol(DD, Decl(index.js, 11, 13)) + +export { DD as D }; +>DD : Symbol(DD, Decl(index.js, 11, 13)) +>D : Symbol(D, Decl(index.js, 15, 8)) + +export enum E {} +>E : Symbol(E, Decl(index.js, 15, 19)) + +export { E as EE }; +>E : Symbol(E, Decl(index.js, 15, 19)) +>EE : Symbol(EE, Decl(index.js, 18, 8)) + +export { F as FF }; +>F : Symbol(F, Decl(index.js, 20, 19)) +>FF : Symbol(FF, Decl(index.js, 20, 8)) + +export enum F {} +>F : Symbol(F, Decl(index.js, 20, 19)) + +export enum G { +>G : Symbol(G, Decl(index.js, 21, 16)) + + A = 1, +>A : Symbol(G.A, Decl(index.js, 23, 15)) + + B, +>B : Symbol(G.B, Decl(index.js, 24, 10)) + + C +>C : Symbol(G.C, Decl(index.js, 25, 6)) +} + +export enum H { +>H : Symbol(H, Decl(index.js, 27, 1)) + + A = "a", +>A : Symbol(H.A, Decl(index.js, 29, 15)) + + B = "b" +>B : Symbol(H.B, Decl(index.js, 30, 12)) +} + +export enum I { +>I : Symbol(I, Decl(index.js, 32, 1)) + + A = "a", +>A : Symbol(I.A, Decl(index.js, 34, 15)) + + B = 0, +>B : Symbol(I.B, Decl(index.js, 35, 12)) + + C +>C : Symbol(I.C, Decl(index.js, 36, 10)) +} + +export const enum J { +>J : Symbol(J, Decl(index.js, 38, 1)) + + A = 1, +>A : Symbol(J.A, Decl(index.js, 40, 21)) + + B, +>B : Symbol(J.B, Decl(index.js, 41, 10)) + + C +>C : Symbol(J.C, Decl(index.js, 42, 6)) +} + +export enum K { +>K : Symbol(K, Decl(index.js, 44, 1)) + + None = 0, +>None : Symbol(K.None, Decl(index.js, 46, 15)) + + A = 1 << 0, +>A : Symbol(K.A, Decl(index.js, 47, 15)) + + B = 1 << 1, +>B : Symbol(K.B, Decl(index.js, 48, 15)) + + C = 1 << 2, +>C : Symbol(K.C, Decl(index.js, 49, 15)) + + Mask = A | B | C, +>Mask : Symbol(K.Mask, Decl(index.js, 50, 15)) +>A : Symbol(K.A, Decl(index.js, 47, 15)) +>B : Symbol(K.B, Decl(index.js, 48, 15)) +>C : Symbol(K.C, Decl(index.js, 49, 15)) +} + +export const enum L { +>L : Symbol(L, Decl(index.js, 52, 1)) + + None = 0, +>None : Symbol(L.None, Decl(index.js, 54, 21)) + + A = 1 << 0, +>A : Symbol(L.A, Decl(index.js, 55, 15)) + + B = 1 << 1, +>B : Symbol(L.B, Decl(index.js, 56, 15)) + + C = 1 << 2, +>C : Symbol(L.C, Decl(index.js, 57, 15)) + + Mask = A | B | C, +>Mask : Symbol(L.Mask, Decl(index.js, 58, 15)) +>A : Symbol(L.A, Decl(index.js, 55, 15)) +>B : Symbol(L.B, Decl(index.js, 56, 15)) +>C : Symbol(L.C, Decl(index.js, 57, 15)) +} + diff --git a/tests/baselines/reference/jsDeclarationsEnums.types b/tests/baselines/reference/jsDeclarationsEnums.types new file mode 100644 index 0000000000000..e01b2637fb663 --- /dev/null +++ b/tests/baselines/reference/jsDeclarationsEnums.types @@ -0,0 +1,164 @@ +=== tests/cases/conformance/jsdoc/declarations/index.js === +// Pretty much all of this should be an error, (since enums are forbidden in js), +// but we should be able to synthesize declarations from the symbols regardless + +export enum A {} +>A : A + +export enum B { +>B : B + + Member +>Member : B.Member +} + +enum C {} +>C : C + +export { C }; +>C : typeof C + +enum DD {} +>DD : DD + +export { DD as D }; +>DD : typeof DD +>D : typeof DD + +export enum E {} +>E : E + +export { E as EE }; +>E : typeof E +>EE : typeof E + +export { F as FF }; +>F : typeof F +>FF : typeof F + +export enum F {} +>F : F + +export enum G { +>G : G + + A = 1, +>A : G.A +>1 : 1 + + B, +>B : G.B + + C +>C : G.C +} + +export enum H { +>H : H + + A = "a", +>A : H.A +>"a" : "a" + + B = "b" +>B : H.B +>"b" : "b" +} + +export enum I { +>I : I + + A = "a", +>A : I.A +>"a" : "a" + + B = 0, +>B : I.B +>0 : 0 + + C +>C : I.C +} + +export const enum J { +>J : J + + A = 1, +>A : J.A +>1 : 1 + + B, +>B : J.B + + C +>C : J.C +} + +export enum K { +>K : K + + None = 0, +>None : K +>0 : 0 + + A = 1 << 0, +>A : K +>1 << 0 : number +>1 : 1 +>0 : 0 + + B = 1 << 1, +>B : K +>1 << 1 : number +>1 : 1 +>1 : 1 + + C = 1 << 2, +>C : K +>1 << 2 : number +>1 : 1 +>2 : 2 + + Mask = A | B | C, +>Mask : K +>A | B | C : number +>A | B : number +>A : K +>B : K +>C : K +} + +export const enum L { +>L : L + + None = 0, +>None : L +>0 : 0 + + A = 1 << 0, +>A : L +>1 << 0 : number +>1 : 1 +>0 : 0 + + B = 1 << 1, +>B : L +>1 << 1 : number +>1 : 1 +>1 : 1 + + C = 1 << 2, +>C : L +>1 << 2 : number +>1 : 1 +>2 : 2 + + Mask = A | B | C, +>Mask : L +>A | B | C : number +>A | B : number +>A : L +>B : L +>C : L +} + diff --git a/tests/baselines/reference/jsDeclarationsExportAssignedClassExpression.js b/tests/baselines/reference/jsDeclarationsExportAssignedClassExpression.js new file mode 100644 index 0000000000000..50797f3bc7479 --- /dev/null +++ b/tests/baselines/reference/jsDeclarationsExportAssignedClassExpression.js @@ -0,0 +1,31 @@ +//// [index.js] +module.exports = class Thing { + /** + * @param {number} p + */ + constructor(p) { + this.t = 12 + p; + } +} + +//// [index.js] +module.exports = /** @class */ (function () { + /** + * @param {number} p + */ + function Thing(p) { + this.t = 12 + p; + } + return Thing; +}()); + + +//// [index.d.ts] +export = Thing; +declare class Thing { + /** + * @param {number} p + */ + constructor(p: number); + t: number; +} diff --git a/tests/baselines/reference/jsDeclarationsExportAssignedClassExpression.symbols b/tests/baselines/reference/jsDeclarationsExportAssignedClassExpression.symbols new file mode 100644 index 0000000000000..3552f73f4a515 --- /dev/null +++ b/tests/baselines/reference/jsDeclarationsExportAssignedClassExpression.symbols @@ -0,0 +1,20 @@ +=== tests/cases/conformance/jsdoc/declarations/index.js === +module.exports = class Thing { +>module.exports : Symbol("tests/cases/conformance/jsdoc/declarations/index", Decl(index.js, 0, 0)) +>module : Symbol(export=, Decl(index.js, 0, 0)) +>exports : Symbol(export=, Decl(index.js, 0, 0)) +>Thing : Symbol(Thing, Decl(index.js, 0, 16)) + + /** + * @param {number} p + */ + constructor(p) { +>p : Symbol(p, Decl(index.js, 4, 16)) + + this.t = 12 + p; +>this.t : Symbol(Thing.t, Decl(index.js, 4, 20)) +>this : Symbol(Thing, Decl(index.js, 0, 16)) +>t : Symbol(Thing.t, Decl(index.js, 4, 20)) +>p : Symbol(p, Decl(index.js, 4, 16)) + } +} diff --git a/tests/baselines/reference/jsDeclarationsExportAssignedClassExpression.types b/tests/baselines/reference/jsDeclarationsExportAssignedClassExpression.types new file mode 100644 index 0000000000000..42dee86cf5061 --- /dev/null +++ b/tests/baselines/reference/jsDeclarationsExportAssignedClassExpression.types @@ -0,0 +1,25 @@ +=== tests/cases/conformance/jsdoc/declarations/index.js === +module.exports = class Thing { +>module.exports = class Thing { /** * @param {number} p */ constructor(p) { this.t = 12 + p; }} : typeof import("tests/cases/conformance/jsdoc/declarations/index") +>module.exports : typeof import("tests/cases/conformance/jsdoc/declarations/index") +>module : { "tests/cases/conformance/jsdoc/declarations/index": typeof import("tests/cases/conformance/jsdoc/declarations/index"); } +>exports : typeof import("tests/cases/conformance/jsdoc/declarations/index") +>class Thing { /** * @param {number} p */ constructor(p) { this.t = 12 + p; }} : typeof import("tests/cases/conformance/jsdoc/declarations/index") +>Thing : typeof import("tests/cases/conformance/jsdoc/declarations/index") + + /** + * @param {number} p + */ + constructor(p) { +>p : number + + this.t = 12 + p; +>this.t = 12 + p : number +>this.t : number +>this : this +>t : number +>12 + p : number +>12 : 12 +>p : number + } +} diff --git a/tests/baselines/reference/jsDeclarationsExportAssignedClassExpressionAnonymous.js b/tests/baselines/reference/jsDeclarationsExportAssignedClassExpressionAnonymous.js new file mode 100644 index 0000000000000..74e0e3799c4fb --- /dev/null +++ b/tests/baselines/reference/jsDeclarationsExportAssignedClassExpressionAnonymous.js @@ -0,0 +1,31 @@ +//// [index.js] +module.exports = class { + /** + * @param {number} p + */ + constructor(p) { + this.t = 12 + p; + } +} + +//// [index.js] +module.exports = /** @class */ (function () { + /** + * @param {number} p + */ + function exports(p) { + this.t = 12 + p; + } + return exports; +}()); + + +//// [index.d.ts] +export = exports; +declare class exports { + /** + * @param {number} p + */ + constructor(p: number); + t: number; +} diff --git a/tests/baselines/reference/jsDeclarationsExportAssignedClassExpressionAnonymous.symbols b/tests/baselines/reference/jsDeclarationsExportAssignedClassExpressionAnonymous.symbols new file mode 100644 index 0000000000000..b4d32907ff62f --- /dev/null +++ b/tests/baselines/reference/jsDeclarationsExportAssignedClassExpressionAnonymous.symbols @@ -0,0 +1,19 @@ +=== tests/cases/conformance/jsdoc/declarations/index.js === +module.exports = class { +>module.exports : Symbol("tests/cases/conformance/jsdoc/declarations/index", Decl(index.js, 0, 0)) +>module : Symbol(export=, Decl(index.js, 0, 0)) +>exports : Symbol(export=, Decl(index.js, 0, 0)) + + /** + * @param {number} p + */ + constructor(p) { +>p : Symbol(p, Decl(index.js, 4, 16)) + + this.t = 12 + p; +>this.t : Symbol(exports.t, Decl(index.js, 4, 20)) +>this : Symbol(exports, Decl(index.js, 0, 16)) +>t : Symbol(exports.t, Decl(index.js, 4, 20)) +>p : Symbol(p, Decl(index.js, 4, 16)) + } +} diff --git a/tests/baselines/reference/jsDeclarationsExportAssignedClassExpressionAnonymous.types b/tests/baselines/reference/jsDeclarationsExportAssignedClassExpressionAnonymous.types new file mode 100644 index 0000000000000..dfad9afb09be5 --- /dev/null +++ b/tests/baselines/reference/jsDeclarationsExportAssignedClassExpressionAnonymous.types @@ -0,0 +1,24 @@ +=== tests/cases/conformance/jsdoc/declarations/index.js === +module.exports = class { +>module.exports = class { /** * @param {number} p */ constructor(p) { this.t = 12 + p; }} : typeof import("tests/cases/conformance/jsdoc/declarations/index") +>module.exports : typeof import("tests/cases/conformance/jsdoc/declarations/index") +>module : { "tests/cases/conformance/jsdoc/declarations/index": typeof import("tests/cases/conformance/jsdoc/declarations/index"); } +>exports : typeof import("tests/cases/conformance/jsdoc/declarations/index") +>class { /** * @param {number} p */ constructor(p) { this.t = 12 + p; }} : typeof import("tests/cases/conformance/jsdoc/declarations/index") + + /** + * @param {number} p + */ + constructor(p) { +>p : number + + this.t = 12 + p; +>this.t = 12 + p : number +>this.t : number +>this : this +>t : number +>12 + p : number +>12 : 12 +>p : number + } +} diff --git a/tests/baselines/reference/jsDeclarationsExportAssignedClassExpressionAnonymousWithSub.js b/tests/baselines/reference/jsDeclarationsExportAssignedClassExpressionAnonymousWithSub.js new file mode 100644 index 0000000000000..8177aacbe456c --- /dev/null +++ b/tests/baselines/reference/jsDeclarationsExportAssignedClassExpressionAnonymousWithSub.js @@ -0,0 +1,49 @@ +//// [index.js] +module.exports = class { + /** + * @param {number} p + */ + constructor(p) { + this.t = 12 + p; + } +} +module.exports.Sub = class { + constructor() { + this.instance = new module.exports(10); + } +} + + +//// [index.js] +module.exports = /** @class */ (function () { + /** + * @param {number} p + */ + function exports(p) { + this.t = 12 + p; + } + return exports; +}()); +module.exports.Sub = /** @class */ (function () { + function Sub() { + this.instance = new module.exports(10); + } + return Sub; +}()); + + +//// [index.d.ts] +export = exports; +declare class exports { + /** + * @param {number} p + */ + constructor(p: number); + t: number; +} +declare namespace exports { + export { Sub }; +} +declare class Sub { + instance: import("."); +} diff --git a/tests/baselines/reference/jsDeclarationsExportAssignedClassExpressionAnonymousWithSub.symbols b/tests/baselines/reference/jsDeclarationsExportAssignedClassExpressionAnonymousWithSub.symbols new file mode 100644 index 0000000000000..228bb10cccc03 --- /dev/null +++ b/tests/baselines/reference/jsDeclarationsExportAssignedClassExpressionAnonymousWithSub.symbols @@ -0,0 +1,37 @@ +=== tests/cases/conformance/jsdoc/declarations/index.js === +module.exports = class { +>module.exports : Symbol("tests/cases/conformance/jsdoc/declarations/index", Decl(index.js, 0, 0)) +>module : Symbol(export=, Decl(index.js, 0, 0)) +>exports : Symbol(export=, Decl(index.js, 0, 0)) + + /** + * @param {number} p + */ + constructor(p) { +>p : Symbol(p, Decl(index.js, 4, 16)) + + this.t = 12 + p; +>this.t : Symbol(exports.t, Decl(index.js, 4, 20)) +>this : Symbol(exports, Decl(index.js, 0, 16)) +>t : Symbol(exports.t, Decl(index.js, 4, 20)) +>p : Symbol(p, Decl(index.js, 4, 16)) + } +} +module.exports.Sub = class { +>module.exports.Sub : Symbol(Sub) +>module.exports : Symbol(Sub, Decl(index.js, 7, 1)) +>module : Symbol(module, Decl(index.js, 0, 0), Decl(index.js, 10, 27)) +>exports : Symbol("tests/cases/conformance/jsdoc/declarations/index", Decl(index.js, 0, 0)) +>Sub : Symbol(Sub, Decl(index.js, 7, 1)) + + constructor() { + this.instance = new module.exports(10); +>this.instance : Symbol(Sub.instance, Decl(index.js, 9, 19)) +>this : Symbol(Sub, Decl(index.js, 8, 20)) +>instance : Symbol(Sub.instance, Decl(index.js, 9, 19)) +>module.exports : Symbol("tests/cases/conformance/jsdoc/declarations/index", Decl(index.js, 0, 0)) +>module : Symbol(module, Decl(index.js, 0, 0), Decl(index.js, 10, 27)) +>exports : Symbol("tests/cases/conformance/jsdoc/declarations/index", Decl(index.js, 0, 0)) + } +} + diff --git a/tests/baselines/reference/jsDeclarationsExportAssignedClassExpressionAnonymousWithSub.types b/tests/baselines/reference/jsDeclarationsExportAssignedClassExpressionAnonymousWithSub.types new file mode 100644 index 0000000000000..a4d435e2a9d3a --- /dev/null +++ b/tests/baselines/reference/jsDeclarationsExportAssignedClassExpressionAnonymousWithSub.types @@ -0,0 +1,47 @@ +=== tests/cases/conformance/jsdoc/declarations/index.js === +module.exports = class { +>module.exports = class { /** * @param {number} p */ constructor(p) { this.t = 12 + p; }} : typeof import("tests/cases/conformance/jsdoc/declarations/index") +>module.exports : typeof import("tests/cases/conformance/jsdoc/declarations/index") +>module : { "tests/cases/conformance/jsdoc/declarations/index": typeof import("tests/cases/conformance/jsdoc/declarations/index"); } +>exports : typeof import("tests/cases/conformance/jsdoc/declarations/index") +>class { /** * @param {number} p */ constructor(p) { this.t = 12 + p; }} : typeof import("tests/cases/conformance/jsdoc/declarations/index") + + /** + * @param {number} p + */ + constructor(p) { +>p : number + + this.t = 12 + p; +>this.t = 12 + p : number +>this.t : number +>this : this +>t : number +>12 + p : number +>12 : 12 +>p : number + } +} +module.exports.Sub = class { +>module.exports.Sub = class { constructor() { this.instance = new module.exports(10); }} : typeof Sub +>module.exports.Sub : typeof Sub +>module.exports : typeof import("tests/cases/conformance/jsdoc/declarations/index") +>module : { "tests/cases/conformance/jsdoc/declarations/index": typeof import("tests/cases/conformance/jsdoc/declarations/index"); } +>exports : typeof import("tests/cases/conformance/jsdoc/declarations/index") +>Sub : typeof Sub +>class { constructor() { this.instance = new module.exports(10); }} : typeof Sub + + constructor() { + this.instance = new module.exports(10); +>this.instance = new module.exports(10) : import("tests/cases/conformance/jsdoc/declarations/index") +>this.instance : import("tests/cases/conformance/jsdoc/declarations/index") +>this : this +>instance : import("tests/cases/conformance/jsdoc/declarations/index") +>new module.exports(10) : import("tests/cases/conformance/jsdoc/declarations/index") +>module.exports : typeof import("tests/cases/conformance/jsdoc/declarations/index") +>module : { "tests/cases/conformance/jsdoc/declarations/index": typeof import("tests/cases/conformance/jsdoc/declarations/index"); } +>exports : typeof import("tests/cases/conformance/jsdoc/declarations/index") +>10 : 10 + } +} + diff --git a/tests/baselines/reference/jsDeclarationsExportAssignedClassExpressionShadowing.js b/tests/baselines/reference/jsDeclarationsExportAssignedClassExpressionShadowing.js new file mode 100644 index 0000000000000..df093050b7c49 --- /dev/null +++ b/tests/baselines/reference/jsDeclarationsExportAssignedClassExpressionShadowing.js @@ -0,0 +1,86 @@ +//// [index.js] +// TODO: Fixup +class A { + member = new Q(); +} +class Q { + x = 42; +} +module.exports = class Q { + constructor() { + this.x = new A(); + } +} +module.exports.Another = Q; + + +//// [index.js] +// TODO: Fixup +var A = /** @class */ (function () { + function A() { + this.member = new Q(); + } + return A; +}()); +var Q = /** @class */ (function () { + function Q() { + this.x = 42; + } + return Q; +}()); +module.exports = /** @class */ (function () { + function Q() { + this.x = new A(); + } + return Q; +}()); +module.exports.Another = Q; + + +//// [index.d.ts] +export = Q; +declare class Q { + x: A; +} +declare namespace Q { + export { Another }; +} +declare class A { + member: Q; +} +declare var Another: typeof Q; +declare class Q { + x: number; +} + + +//// [DtsFileErrors] + + +out/index.d.ts(2,15): error TS2300: Duplicate identifier 'Q'. +out/index.d.ts(5,19): error TS2300: Duplicate identifier 'Q'. +out/index.d.ts(12,15): error TS2300: Duplicate identifier 'Q'. + + +==== ./out/index.d.ts (3 errors) ==== + export = Q; + declare class Q { + ~ +!!! error TS2300: Duplicate identifier 'Q'. + x: A; + } + declare namespace Q { + ~ +!!! error TS2300: Duplicate identifier 'Q'. + export { Another }; + } + declare class A { + member: Q; + } + declare var Another: typeof Q; + declare class Q { + ~ +!!! error TS2300: Duplicate identifier 'Q'. + x: number; + } + \ No newline at end of file diff --git a/tests/baselines/reference/jsDeclarationsExportAssignedClassExpressionShadowing.symbols b/tests/baselines/reference/jsDeclarationsExportAssignedClassExpressionShadowing.symbols new file mode 100644 index 0000000000000..37f1cf9124daf --- /dev/null +++ b/tests/baselines/reference/jsDeclarationsExportAssignedClassExpressionShadowing.symbols @@ -0,0 +1,37 @@ +=== tests/cases/conformance/jsdoc/declarations/index.js === +// TODO: Fixup +class A { +>A : Symbol(A, Decl(index.js, 0, 0)) + + member = new Q(); +>member : Symbol(A.member, Decl(index.js, 1, 9)) +>Q : Symbol(Q, Decl(index.js, 3, 1)) +} +class Q { +>Q : Symbol(Q, Decl(index.js, 3, 1)) + + x = 42; +>x : Symbol(Q.x, Decl(index.js, 4, 9)) +} +module.exports = class Q { +>module.exports : Symbol("tests/cases/conformance/jsdoc/declarations/index", Decl(index.js, 0, 0)) +>module : Symbol(export=, Decl(index.js, 6, 1)) +>exports : Symbol(export=, Decl(index.js, 6, 1)) +>Q : Symbol(Q, Decl(index.js, 7, 16)) + + constructor() { + this.x = new A(); +>this.x : Symbol(Q.x, Decl(index.js, 8, 19)) +>this : Symbol(Q, Decl(index.js, 7, 16)) +>x : Symbol(Q.x, Decl(index.js, 8, 19)) +>A : Symbol(A, Decl(index.js, 0, 0)) + } +} +module.exports.Another = Q; +>module.exports.Another : Symbol(Another) +>module.exports : Symbol(Another, Decl(index.js, 11, 1)) +>module : Symbol(module, Decl(index.js, 6, 1)) +>exports : Symbol("tests/cases/conformance/jsdoc/declarations/index", Decl(index.js, 0, 0)) +>Another : Symbol(Another, Decl(index.js, 11, 1)) +>Q : Symbol(Q, Decl(index.js, 3, 1)) + diff --git a/tests/baselines/reference/jsDeclarationsExportAssignedClassExpressionShadowing.types b/tests/baselines/reference/jsDeclarationsExportAssignedClassExpressionShadowing.types new file mode 100644 index 0000000000000..bd3594e288403 --- /dev/null +++ b/tests/baselines/reference/jsDeclarationsExportAssignedClassExpressionShadowing.types @@ -0,0 +1,44 @@ +=== tests/cases/conformance/jsdoc/declarations/index.js === +// TODO: Fixup +class A { +>A : A + + member = new Q(); +>member : Q +>new Q() : Q +>Q : typeof Q +} +class Q { +>Q : Q + + x = 42; +>x : number +>42 : 42 +} +module.exports = class Q { +>module.exports = class Q { constructor() { this.x = new A(); }} : typeof import("tests/cases/conformance/jsdoc/declarations/index") +>module.exports : typeof import("tests/cases/conformance/jsdoc/declarations/index") +>module : { "tests/cases/conformance/jsdoc/declarations/index": typeof import("tests/cases/conformance/jsdoc/declarations/index"); } +>exports : typeof import("tests/cases/conformance/jsdoc/declarations/index") +>class Q { constructor() { this.x = new A(); }} : typeof import("tests/cases/conformance/jsdoc/declarations/index") +>Q : typeof import("tests/cases/conformance/jsdoc/declarations/index") + + constructor() { + this.x = new A(); +>this.x = new A() : A +>this.x : A +>this : this +>x : A +>new A() : A +>A : typeof A + } +} +module.exports.Another = Q; +>module.exports.Another = Q : typeof Q +>module.exports.Another : typeof Q +>module.exports : typeof import("tests/cases/conformance/jsdoc/declarations/index") +>module : { "tests/cases/conformance/jsdoc/declarations/index": typeof import("tests/cases/conformance/jsdoc/declarations/index"); } +>exports : typeof import("tests/cases/conformance/jsdoc/declarations/index") +>Another : typeof Q +>Q : typeof Q + diff --git a/tests/baselines/reference/jsDeclarationsExportAssignedVisibility.js b/tests/baselines/reference/jsDeclarationsExportAssignedVisibility.js new file mode 100644 index 0000000000000..c900f28602e57 --- /dev/null +++ b/tests/baselines/reference/jsDeclarationsExportAssignedVisibility.js @@ -0,0 +1,47 @@ +//// [tests/cases/conformance/jsdoc/declarations/jsDeclarationsExportAssignedVisibility.ts] //// + +//// [obj.js] +module.exports = class Obj { + constructor() { + this.x = 12; + } +} +//// [index.js] +const Obj = require("./obj"); + +class Container { + constructor() { + this.usage = new Obj(); + } +} + +module.exports = Container; + +//// [obj.js] +module.exports = /** @class */ (function () { + function Obj() { + this.x = 12; + } + return Obj; +}()); +//// [index.js] +var Obj = require("./obj"); +var Container = /** @class */ (function () { + function Container() { + this.usage = new Obj(); + } + return Container; +}()); +module.exports = Container; + + +//// [obj.d.ts] +export = Obj; +declare class Obj { + x: number; +} +//// [index.d.ts] +export = Container; +declare class Container { + usage: import("./obj"); +} diff --git a/tests/baselines/reference/jsDeclarationsExportAssignedVisibility.symbols b/tests/baselines/reference/jsDeclarationsExportAssignedVisibility.symbols new file mode 100644 index 0000000000000..e939df536ffa1 --- /dev/null +++ b/tests/baselines/reference/jsDeclarationsExportAssignedVisibility.symbols @@ -0,0 +1,38 @@ +=== tests/cases/conformance/jsdoc/declarations/index.js === +const Obj = require("./obj"); +>Obj : Symbol(Obj, Decl(index.js, 0, 5)) +>require : Symbol(require) +>"./obj" : Symbol("tests/cases/conformance/jsdoc/declarations/obj", Decl(obj.js, 0, 0)) + +class Container { +>Container : Symbol(Container, Decl(index.js, 0, 29)) + + constructor() { + this.usage = new Obj(); +>this.usage : Symbol(Container.usage, Decl(index.js, 3, 19)) +>this : Symbol(Container, Decl(index.js, 0, 29)) +>usage : Symbol(Container.usage, Decl(index.js, 3, 19)) +>Obj : Symbol(Obj, Decl(index.js, 0, 5)) + } +} + +module.exports = Container; +>module.exports : Symbol("tests/cases/conformance/jsdoc/declarations/index", Decl(index.js, 0, 0)) +>module : Symbol(export=, Decl(index.js, 6, 1)) +>exports : Symbol(export=, Decl(index.js, 6, 1)) +>Container : Symbol(Container, Decl(index.js, 0, 29)) + +=== tests/cases/conformance/jsdoc/declarations/obj.js === +module.exports = class Obj { +>module.exports : Symbol("tests/cases/conformance/jsdoc/declarations/obj", Decl(obj.js, 0, 0)) +>module : Symbol(export=, Decl(obj.js, 0, 0)) +>exports : Symbol(export=, Decl(obj.js, 0, 0)) +>Obj : Symbol(Obj, Decl(obj.js, 0, 16)) + + constructor() { + this.x = 12; +>this.x : Symbol(Obj.x, Decl(obj.js, 1, 19)) +>this : Symbol(Obj, Decl(obj.js, 0, 16)) +>x : Symbol(Obj.x, Decl(obj.js, 1, 19)) + } +} diff --git a/tests/baselines/reference/jsDeclarationsExportAssignedVisibility.types b/tests/baselines/reference/jsDeclarationsExportAssignedVisibility.types new file mode 100644 index 0000000000000..6398c9bada02a --- /dev/null +++ b/tests/baselines/reference/jsDeclarationsExportAssignedVisibility.types @@ -0,0 +1,46 @@ +=== tests/cases/conformance/jsdoc/declarations/index.js === +const Obj = require("./obj"); +>Obj : typeof import("tests/cases/conformance/jsdoc/declarations/obj") +>require("./obj") : typeof import("tests/cases/conformance/jsdoc/declarations/obj") +>require : any +>"./obj" : "./obj" + +class Container { +>Container : Container + + constructor() { + this.usage = new Obj(); +>this.usage = new Obj() : import("tests/cases/conformance/jsdoc/declarations/obj") +>this.usage : import("tests/cases/conformance/jsdoc/declarations/obj") +>this : this +>usage : import("tests/cases/conformance/jsdoc/declarations/obj") +>new Obj() : import("tests/cases/conformance/jsdoc/declarations/obj") +>Obj : typeof import("tests/cases/conformance/jsdoc/declarations/obj") + } +} + +module.exports = Container; +>module.exports = Container : typeof Container +>module.exports : typeof Container +>module : { "tests/cases/conformance/jsdoc/declarations/index": typeof Container; } +>exports : typeof Container +>Container : typeof Container + +=== tests/cases/conformance/jsdoc/declarations/obj.js === +module.exports = class Obj { +>module.exports = class Obj { constructor() { this.x = 12; }} : typeof import("tests/cases/conformance/jsdoc/declarations/obj") +>module.exports : typeof import("tests/cases/conformance/jsdoc/declarations/obj") +>module : { "tests/cases/conformance/jsdoc/declarations/obj": typeof import("tests/cases/conformance/jsdoc/declarations/obj"); } +>exports : typeof import("tests/cases/conformance/jsdoc/declarations/obj") +>class Obj { constructor() { this.x = 12; }} : typeof import("tests/cases/conformance/jsdoc/declarations/obj") +>Obj : typeof import("tests/cases/conformance/jsdoc/declarations/obj") + + constructor() { + this.x = 12; +>this.x = 12 : 12 +>this.x : number +>this : this +>x : number +>12 : 12 + } +} diff --git a/tests/baselines/reference/jsDeclarationsExportAssignmentExpressionPlusSecondary.js b/tests/baselines/reference/jsDeclarationsExportAssignmentExpressionPlusSecondary.js new file mode 100644 index 0000000000000..54bc1f49bb2f2 --- /dev/null +++ b/tests/baselines/reference/jsDeclarationsExportAssignmentExpressionPlusSecondary.js @@ -0,0 +1,40 @@ +//// [index.js] +const Strings = { + a: "A", + b: "B" +}; +module.exports = { + thing: "ok", + also: "ok", + desc: { + item: "ok" + } +}; +module.exports.Strings = Strings; + + +//// [index.js] +var Strings = { + a: "A", + b: "B" +}; +module.exports = { + thing: "ok", + also: "ok", + desc: { + item: "ok" + } +}; +module.exports.Strings = Strings; + + +//// [index.d.ts] +export namespace Strings { + export const a: string; + export const b: string; +} +export declare const thing: string; +export declare const also: string; +export declare namespace desc { + export const item: string; +} diff --git a/tests/baselines/reference/jsDeclarationsExportAssignmentExpressionPlusSecondary.symbols b/tests/baselines/reference/jsDeclarationsExportAssignmentExpressionPlusSecondary.symbols new file mode 100644 index 0000000000000..4d79913433181 --- /dev/null +++ b/tests/baselines/reference/jsDeclarationsExportAssignmentExpressionPlusSecondary.symbols @@ -0,0 +1,37 @@ +=== tests/cases/conformance/jsdoc/declarations/index.js === +const Strings = { +>Strings : Symbol(Strings, Decl(index.js, 0, 5)) + + a: "A", +>a : Symbol(a, Decl(index.js, 0, 17)) + + b: "B" +>b : Symbol(b, Decl(index.js, 1, 11)) + +}; +module.exports = { +>module.exports : Symbol("tests/cases/conformance/jsdoc/declarations/index", Decl(index.js, 0, 0)) +>module : Symbol(export=, Decl(index.js, 3, 2)) +>exports : Symbol(export=, Decl(index.js, 3, 2)) + + thing: "ok", +>thing : Symbol(thing, Decl(index.js, 4, 18)) + + also: "ok", +>also : Symbol(also, Decl(index.js, 5, 16)) + + desc: { +>desc : Symbol(desc, Decl(index.js, 6, 15)) + + item: "ok" +>item : Symbol(item, Decl(index.js, 7, 11)) + } +}; +module.exports.Strings = Strings; +>module.exports.Strings : Symbol(Strings, Decl(index.js, 10, 2)) +>module.exports : Symbol(Strings, Decl(index.js, 10, 2)) +>module : Symbol(module, Decl(index.js, 3, 2)) +>exports : Symbol("tests/cases/conformance/jsdoc/declarations/index", Decl(index.js, 0, 0)) +>Strings : Symbol(Strings, Decl(index.js, 10, 2)) +>Strings : Symbol(Strings, Decl(index.js, 0, 5)) + diff --git a/tests/baselines/reference/jsDeclarationsExportAssignmentExpressionPlusSecondary.types b/tests/baselines/reference/jsDeclarationsExportAssignmentExpressionPlusSecondary.types new file mode 100644 index 0000000000000..2b7bd15ac9fdb --- /dev/null +++ b/tests/baselines/reference/jsDeclarationsExportAssignmentExpressionPlusSecondary.types @@ -0,0 +1,47 @@ +=== tests/cases/conformance/jsdoc/declarations/index.js === +const Strings = { +>Strings : { a: string; b: string; } +>{ a: "A", b: "B"} : { a: string; b: string; } + + a: "A", +>a : string +>"A" : "A" + + b: "B" +>b : string +>"B" : "B" + +}; +module.exports = { +>module.exports = { thing: "ok", also: "ok", desc: { item: "ok" }} : { thing: string; also: string; desc: { item: string; }; Strings: { a: string; b: string; }; } +>module.exports : { thing: string; also: string; desc: { item: string; }; Strings: { a: string; b: string; }; } +>module : { "tests/cases/conformance/jsdoc/declarations/index": { thing: string; also: string; desc: { item: string; }; Strings: { a: string; b: string; }; }; } +>exports : { thing: string; also: string; desc: { item: string; }; Strings: { a: string; b: string; }; } +>{ thing: "ok", also: "ok", desc: { item: "ok" }} : { thing: string; also: string; desc: { item: string; }; } + + thing: "ok", +>thing : string +>"ok" : "ok" + + also: "ok", +>also : string +>"ok" : "ok" + + desc: { +>desc : { item: string; } +>{ item: "ok" } : { item: string; } + + item: "ok" +>item : string +>"ok" : "ok" + } +}; +module.exports.Strings = Strings; +>module.exports.Strings = Strings : { a: string; b: string; } +>module.exports.Strings : { a: string; b: string; } +>module.exports : { thing: string; also: string; desc: { item: string; }; Strings: { a: string; b: string; }; } +>module : { "tests/cases/conformance/jsdoc/declarations/index": { thing: string; also: string; desc: { item: string; }; Strings: { a: string; b: string; }; }; } +>exports : { thing: string; also: string; desc: { item: string; }; Strings: { a: string; b: string; }; } +>Strings : { a: string; b: string; } +>Strings : { a: string; b: string; } + diff --git a/tests/baselines/reference/jsDeclarationsExportAssignmentWithKeywordName.js b/tests/baselines/reference/jsDeclarationsExportAssignmentWithKeywordName.js new file mode 100644 index 0000000000000..04aa01e247e21 --- /dev/null +++ b/tests/baselines/reference/jsDeclarationsExportAssignmentWithKeywordName.js @@ -0,0 +1,30 @@ +//// [index.js] +var x = 12; +module.exports = { + extends: 'base', + more: { + others: ['strs'] + }, + x +}; + +//// [index.js] +var x = 12; +module.exports = { + extends: 'base', + more: { + others: ['strs'] + }, + x: x +}; + + +//// [index.d.ts] +declare const _exports: { + extends: string; + more: { + others: string[]; + }; + x: number; +}; +export = _exports; diff --git a/tests/baselines/reference/jsDeclarationsExportAssignmentWithKeywordName.symbols b/tests/baselines/reference/jsDeclarationsExportAssignmentWithKeywordName.symbols new file mode 100644 index 0000000000000..182a64ba32f7c --- /dev/null +++ b/tests/baselines/reference/jsDeclarationsExportAssignmentWithKeywordName.symbols @@ -0,0 +1,23 @@ +=== tests/cases/conformance/jsdoc/declarations/index.js === +var x = 12; +>x : Symbol(x, Decl(index.js, 0, 3)) + +module.exports = { +>module.exports : Symbol("tests/cases/conformance/jsdoc/declarations/index", Decl(index.js, 0, 0)) +>module : Symbol(export=, Decl(index.js, 0, 11)) +>exports : Symbol(export=, Decl(index.js, 0, 11)) + + extends: 'base', +>extends : Symbol(extends, Decl(index.js, 1, 18)) + + more: { +>more : Symbol(more, Decl(index.js, 2, 20)) + + others: ['strs'] +>others : Symbol(others, Decl(index.js, 3, 11)) + + }, + x +>x : Symbol(x, Decl(index.js, 5, 6)) + +}; diff --git a/tests/baselines/reference/jsDeclarationsExportAssignmentWithKeywordName.types b/tests/baselines/reference/jsDeclarationsExportAssignmentWithKeywordName.types new file mode 100644 index 0000000000000..bd3191805e49d --- /dev/null +++ b/tests/baselines/reference/jsDeclarationsExportAssignmentWithKeywordName.types @@ -0,0 +1,30 @@ +=== tests/cases/conformance/jsdoc/declarations/index.js === +var x = 12; +>x : number +>12 : 12 + +module.exports = { +>module.exports = { extends: 'base', more: { others: ['strs'] }, x} : { extends: string; more: { others: string[]; }; x: number; } +>module.exports : { extends: string; more: { others: string[]; }; x: number; } +>module : { "tests/cases/conformance/jsdoc/declarations/index": { extends: string; more: { others: string[]; }; x: number; }; } +>exports : { extends: string; more: { others: string[]; }; x: number; } +>{ extends: 'base', more: { others: ['strs'] }, x} : { extends: string; more: { others: string[]; }; x: number; } + + extends: 'base', +>extends : string +>'base' : "base" + + more: { +>more : { others: string[]; } +>{ others: ['strs'] } : { others: string[]; } + + others: ['strs'] +>others : string[] +>['strs'] : string[] +>'strs' : "strs" + + }, + x +>x : number + +}; diff --git a/tests/baselines/reference/jsDeclarationsExportDefinePropertyEmit.js b/tests/baselines/reference/jsDeclarationsExportDefinePropertyEmit.js new file mode 100644 index 0000000000000..cac7cda56c549 --- /dev/null +++ b/tests/baselines/reference/jsDeclarationsExportDefinePropertyEmit.js @@ -0,0 +1,165 @@ +//// [index.js] +Object.defineProperty(module.exports, "a", { value: function a() {} }); + +Object.defineProperty(module.exports, "b", { value: function b() {} }); +Object.defineProperty(module.exports.b, "cat", { value: "cat" }); + +/** + * @param {number} a + * @param {number} b + * @return {string} + */ +function d(a, b) { return /** @type {*} */(null); } +Object.defineProperty(module.exports, "d", { value: d }); + + +/** + * @template T,U + * @param {T} a + * @param {U} b + * @return {T & U} + */ +function e(a, b) { return /** @type {*} */(null); } +Object.defineProperty(module.exports, "e", { value: e }); + +/** + * @template T + * @param {T} a + */ +function f(a) { + return a; +} +Object.defineProperty(module.exports, "f", { value: f }); +Object.defineProperty(module.exports.f, "self", { value: module.exports.f }); + +/** + * @param {{x: string}} a + * @param {{y: typeof module.exports.b}} b + */ +function g(a, b) { + return a.x && b.y(); +} +Object.defineProperty(module.exports, "g", { value: g }); + + +/** + * @param {{x: string}} a + * @param {{y: typeof module.exports.b}} b + */ +function hh(a, b) { + return a.x && b.y(); +} +Object.defineProperty(module.exports, "h", { value: hh }); + +Object.defineProperty(module.exports, "i", { value: function i(){} }); +Object.defineProperty(module.exports, "ii", { value: module.exports.i }); + +// note that this last one doesn't make much sense in cjs, since exports aren't hoisted bindings +Object.defineProperty(module.exports, "jj", { value: module.exports.j }); +Object.defineProperty(module.exports, "j", { value: function j() {} }); + + +//// [index.js] +Object.defineProperty(module.exports, "a", { value: function a() { } }); +Object.defineProperty(module.exports, "b", { value: function b() { } }); +Object.defineProperty(module.exports.b, "cat", { value: "cat" }); +/** + * @param {number} a + * @param {number} b + * @return {string} + */ +function d(a, b) { return /** @type {*} */ (null); } +Object.defineProperty(module.exports, "d", { value: d }); +/** + * @template T,U + * @param {T} a + * @param {U} b + * @return {T & U} + */ +function e(a, b) { return /** @type {*} */ (null); } +Object.defineProperty(module.exports, "e", { value: e }); +/** + * @template T + * @param {T} a + */ +function f(a) { + return a; +} +Object.defineProperty(module.exports, "f", { value: f }); +Object.defineProperty(module.exports.f, "self", { value: module.exports.f }); +/** + * @param {{x: string}} a + * @param {{y: typeof module.exports.b}} b + */ +function g(a, b) { + return a.x && b.y(); +} +Object.defineProperty(module.exports, "g", { value: g }); +/** + * @param {{x: string}} a + * @param {{y: typeof module.exports.b}} b + */ +function hh(a, b) { + return a.x && b.y(); +} +Object.defineProperty(module.exports, "h", { value: hh }); +Object.defineProperty(module.exports, "i", { value: function i() { } }); +Object.defineProperty(module.exports, "ii", { value: module.exports.i }); +// note that this last one doesn't make much sense in cjs, since exports aren't hoisted bindings +Object.defineProperty(module.exports, "jj", { value: module.exports.j }); +Object.defineProperty(module.exports, "j", { value: function j() { } }); + + +//// [index.d.ts] +export function a(): void; +export function b(): void; +export namespace b { + export const cat: string; +} +/** + * @param {number} a + * @param {number} b + * @return {string} + */ +export function d(a: number, b: number): string; +/** + * @template T,U + * @param {T} a + * @param {U} b + * @return {T & U} + */ +export function e(a: T, b: U): T & U; +/** + * @template T + * @param {T} a + */ +export function f(a: T): T; +export namespace f { + /** + * @template T + * @param {T} a + */ + export function self(a: T): T; +} +/** + * @param {{x: string}} a + * @param {{y: typeof module.exports.b}} b + */ +export function g(a: { + x: string; +}, b: { + y: () => void; +}): void; +/** + * @param {{x: string}} a + * @param {{y: typeof module.exports.b}} b + */ +export function h(a: { + x: string; +}, b: { + y: () => void; +}): void; +export function i(): void; +export function ii(): void; +export function jj(): void; +export function j(): void; diff --git a/tests/baselines/reference/jsDeclarationsExportDefinePropertyEmit.symbols b/tests/baselines/reference/jsDeclarationsExportDefinePropertyEmit.symbols new file mode 100644 index 0000000000000..03cf1ce41b5e0 --- /dev/null +++ b/tests/baselines/reference/jsDeclarationsExportDefinePropertyEmit.symbols @@ -0,0 +1,228 @@ +=== tests/cases/conformance/jsdoc/declarations/index.js === +Object.defineProperty(module.exports, "a", { value: function a() {} }); +>Object.defineProperty : Symbol(ObjectConstructor.defineProperty, Decl(lib.es5.d.ts, --, --)) +>Object : Symbol(Object, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>defineProperty : Symbol(ObjectConstructor.defineProperty, Decl(lib.es5.d.ts, --, --)) +>module.exports : Symbol("tests/cases/conformance/jsdoc/declarations/index", Decl(index.js, 0, 0)) +>module : Symbol(module, Decl(index.js, 0, 22), Decl(index.js, 31, 56), Decl(index.js, 53, 52), Decl(index.js, 56, 52)) +>exports : Symbol("tests/cases/conformance/jsdoc/declarations/index", Decl(index.js, 0, 0)) +>"a" : Symbol(a, Decl(index.js, 0, 0)) +>value : Symbol(value, Decl(index.js, 0, 44)) +>a : Symbol(a, Decl(index.js, 0, 51)) + +Object.defineProperty(module.exports, "b", { value: function b() {} }); +>Object.defineProperty : Symbol(ObjectConstructor.defineProperty, Decl(lib.es5.d.ts, --, --)) +>Object : Symbol(Object, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>defineProperty : Symbol(ObjectConstructor.defineProperty, Decl(lib.es5.d.ts, --, --)) +>module.exports : Symbol("tests/cases/conformance/jsdoc/declarations/index", Decl(index.js, 0, 0)) +>module : Symbol(module, Decl(index.js, 0, 22), Decl(index.js, 31, 56), Decl(index.js, 53, 52), Decl(index.js, 56, 52)) +>exports : Symbol("tests/cases/conformance/jsdoc/declarations/index", Decl(index.js, 0, 0)) +>"b" : Symbol(b, Decl(index.js, 0, 71), Decl(index.js, 3, 37)) +>value : Symbol(value, Decl(index.js, 2, 44)) +>b : Symbol(b, Decl(index.js, 2, 51)) + +Object.defineProperty(module.exports.b, "cat", { value: "cat" }); +>Object.defineProperty : Symbol(ObjectConstructor.defineProperty, Decl(lib.es5.d.ts, --, --)) +>Object : Symbol(Object, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>defineProperty : Symbol(ObjectConstructor.defineProperty, Decl(lib.es5.d.ts, --, --)) +>module.exports.b : Symbol(b, Decl(index.js, 0, 71), Decl(index.js, 3, 37)) +>module.exports : Symbol("tests/cases/conformance/jsdoc/declarations/index", Decl(index.js, 0, 0)) +>module : Symbol(module, Decl(index.js, 0, 22), Decl(index.js, 31, 56), Decl(index.js, 53, 52), Decl(index.js, 56, 52)) +>exports : Symbol("tests/cases/conformance/jsdoc/declarations/index", Decl(index.js, 0, 0)) +>b : Symbol(b, Decl(index.js, 0, 71), Decl(index.js, 3, 37)) +>"cat" : Symbol(b.cat, Decl(index.js, 2, 71)) +>value : Symbol(value, Decl(index.js, 3, 48)) + +/** + * @param {number} a + * @param {number} b + * @return {string} + */ +function d(a, b) { return /** @type {*} */(null); } +>d : Symbol(d, Decl(index.js, 3, 65)) +>a : Symbol(a, Decl(index.js, 10, 11)) +>b : Symbol(b, Decl(index.js, 10, 13)) + +Object.defineProperty(module.exports, "d", { value: d }); +>Object.defineProperty : Symbol(ObjectConstructor.defineProperty, Decl(lib.es5.d.ts, --, --)) +>Object : Symbol(Object, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>defineProperty : Symbol(ObjectConstructor.defineProperty, Decl(lib.es5.d.ts, --, --)) +>module.exports : Symbol("tests/cases/conformance/jsdoc/declarations/index", Decl(index.js, 0, 0)) +>module : Symbol(module, Decl(index.js, 0, 22), Decl(index.js, 31, 56), Decl(index.js, 53, 52), Decl(index.js, 56, 52)) +>exports : Symbol("tests/cases/conformance/jsdoc/declarations/index", Decl(index.js, 0, 0)) +>"d" : Symbol(d, Decl(index.js, 10, 51)) +>value : Symbol(value, Decl(index.js, 11, 44)) +>d : Symbol(d, Decl(index.js, 3, 65)) + + +/** + * @template T,U + * @param {T} a + * @param {U} b + * @return {T & U} + */ +function e(a, b) { return /** @type {*} */(null); } +>e : Symbol(e, Decl(index.js, 11, 57)) +>a : Symbol(a, Decl(index.js, 20, 11)) +>b : Symbol(b, Decl(index.js, 20, 13)) + +Object.defineProperty(module.exports, "e", { value: e }); +>Object.defineProperty : Symbol(ObjectConstructor.defineProperty, Decl(lib.es5.d.ts, --, --)) +>Object : Symbol(Object, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>defineProperty : Symbol(ObjectConstructor.defineProperty, Decl(lib.es5.d.ts, --, --)) +>module.exports : Symbol("tests/cases/conformance/jsdoc/declarations/index", Decl(index.js, 0, 0)) +>module : Symbol(module, Decl(index.js, 0, 22), Decl(index.js, 31, 56), Decl(index.js, 53, 52), Decl(index.js, 56, 52)) +>exports : Symbol("tests/cases/conformance/jsdoc/declarations/index", Decl(index.js, 0, 0)) +>"e" : Symbol(e, Decl(index.js, 20, 51)) +>value : Symbol(value, Decl(index.js, 21, 44)) +>e : Symbol(e, Decl(index.js, 11, 57)) + +/** + * @template T + * @param {T} a + */ +function f(a) { +>f : Symbol(f, Decl(index.js, 21, 57)) +>a : Symbol(a, Decl(index.js, 27, 11)) + + return a; +>a : Symbol(a, Decl(index.js, 27, 11)) +} +Object.defineProperty(module.exports, "f", { value: f }); +>Object.defineProperty : Symbol(ObjectConstructor.defineProperty, Decl(lib.es5.d.ts, --, --)) +>Object : Symbol(Object, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>defineProperty : Symbol(ObjectConstructor.defineProperty, Decl(lib.es5.d.ts, --, --)) +>module.exports : Symbol("tests/cases/conformance/jsdoc/declarations/index", Decl(index.js, 0, 0)) +>module : Symbol(module, Decl(index.js, 0, 22), Decl(index.js, 31, 56), Decl(index.js, 53, 52), Decl(index.js, 56, 52)) +>exports : Symbol("tests/cases/conformance/jsdoc/declarations/index", Decl(index.js, 0, 0)) +>"f" : Symbol(f, Decl(index.js, 29, 1), Decl(index.js, 31, 37)) +>value : Symbol(value, Decl(index.js, 30, 44)) +>f : Symbol(f, Decl(index.js, 21, 57)) + +Object.defineProperty(module.exports.f, "self", { value: module.exports.f }); +>Object.defineProperty : Symbol(ObjectConstructor.defineProperty, Decl(lib.es5.d.ts, --, --)) +>Object : Symbol(Object, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>defineProperty : Symbol(ObjectConstructor.defineProperty, Decl(lib.es5.d.ts, --, --)) +>module.exports.f : Symbol(f, Decl(index.js, 29, 1), Decl(index.js, 31, 37)) +>module.exports : Symbol("tests/cases/conformance/jsdoc/declarations/index", Decl(index.js, 0, 0)) +>module : Symbol(module, Decl(index.js, 0, 22), Decl(index.js, 31, 56), Decl(index.js, 53, 52), Decl(index.js, 56, 52)) +>exports : Symbol("tests/cases/conformance/jsdoc/declarations/index", Decl(index.js, 0, 0)) +>f : Symbol(f, Decl(index.js, 29, 1), Decl(index.js, 31, 37)) +>"self" : Symbol(f.self, Decl(index.js, 30, 57)) +>value : Symbol(value, Decl(index.js, 31, 49)) +>module.exports.f : Symbol(f, Decl(index.js, 29, 1), Decl(index.js, 31, 37)) +>module.exports : Symbol("tests/cases/conformance/jsdoc/declarations/index", Decl(index.js, 0, 0)) +>module : Symbol(module, Decl(index.js, 0, 22), Decl(index.js, 31, 56), Decl(index.js, 53, 52), Decl(index.js, 56, 52)) +>exports : Symbol("tests/cases/conformance/jsdoc/declarations/index", Decl(index.js, 0, 0)) +>f : Symbol(f, Decl(index.js, 29, 1), Decl(index.js, 31, 37)) + +/** + * @param {{x: string}} a + * @param {{y: typeof module.exports.b}} b + */ +function g(a, b) { +>g : Symbol(g, Decl(index.js, 31, 77)) +>a : Symbol(a, Decl(index.js, 37, 11)) +>b : Symbol(b, Decl(index.js, 37, 13)) + + return a.x && b.y(); +>a.x : Symbol(x, Decl(index.js, 34, 12)) +>a : Symbol(a, Decl(index.js, 37, 11)) +>x : Symbol(x, Decl(index.js, 34, 12)) +>b.y : Symbol(y, Decl(index.js, 35, 12)) +>b : Symbol(b, Decl(index.js, 37, 13)) +>y : Symbol(y, Decl(index.js, 35, 12)) +} +Object.defineProperty(module.exports, "g", { value: g }); +>Object.defineProperty : Symbol(ObjectConstructor.defineProperty, Decl(lib.es5.d.ts, --, --)) +>Object : Symbol(Object, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>defineProperty : Symbol(ObjectConstructor.defineProperty, Decl(lib.es5.d.ts, --, --)) +>module.exports : Symbol("tests/cases/conformance/jsdoc/declarations/index", Decl(index.js, 0, 0)) +>module : Symbol(module, Decl(index.js, 0, 22), Decl(index.js, 31, 56), Decl(index.js, 53, 52), Decl(index.js, 56, 52)) +>exports : Symbol("tests/cases/conformance/jsdoc/declarations/index", Decl(index.js, 0, 0)) +>"g" : Symbol(g, Decl(index.js, 39, 1)) +>value : Symbol(value, Decl(index.js, 40, 44)) +>g : Symbol(g, Decl(index.js, 31, 77)) + + +/** + * @param {{x: string}} a + * @param {{y: typeof module.exports.b}} b + */ +function hh(a, b) { +>hh : Symbol(hh, Decl(index.js, 40, 57)) +>a : Symbol(a, Decl(index.js, 47, 12)) +>b : Symbol(b, Decl(index.js, 47, 14)) + + return a.x && b.y(); +>a.x : Symbol(x, Decl(index.js, 44, 12)) +>a : Symbol(a, Decl(index.js, 47, 12)) +>x : Symbol(x, Decl(index.js, 44, 12)) +>b.y : Symbol(y, Decl(index.js, 45, 12)) +>b : Symbol(b, Decl(index.js, 47, 14)) +>y : Symbol(y, Decl(index.js, 45, 12)) +} +Object.defineProperty(module.exports, "h", { value: hh }); +>Object.defineProperty : Symbol(ObjectConstructor.defineProperty, Decl(lib.es5.d.ts, --, --)) +>Object : Symbol(Object, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>defineProperty : Symbol(ObjectConstructor.defineProperty, Decl(lib.es5.d.ts, --, --)) +>module.exports : Symbol("tests/cases/conformance/jsdoc/declarations/index", Decl(index.js, 0, 0)) +>module : Symbol(module, Decl(index.js, 0, 22), Decl(index.js, 31, 56), Decl(index.js, 53, 52), Decl(index.js, 56, 52)) +>exports : Symbol("tests/cases/conformance/jsdoc/declarations/index", Decl(index.js, 0, 0)) +>"h" : Symbol(h, Decl(index.js, 49, 1)) +>value : Symbol(value, Decl(index.js, 50, 44)) +>hh : Symbol(hh, Decl(index.js, 40, 57)) + +Object.defineProperty(module.exports, "i", { value: function i(){} }); +>Object.defineProperty : Symbol(ObjectConstructor.defineProperty, Decl(lib.es5.d.ts, --, --)) +>Object : Symbol(Object, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>defineProperty : Symbol(ObjectConstructor.defineProperty, Decl(lib.es5.d.ts, --, --)) +>module.exports : Symbol("tests/cases/conformance/jsdoc/declarations/index", Decl(index.js, 0, 0)) +>module : Symbol(module, Decl(index.js, 0, 22), Decl(index.js, 31, 56), Decl(index.js, 53, 52), Decl(index.js, 56, 52)) +>exports : Symbol("tests/cases/conformance/jsdoc/declarations/index", Decl(index.js, 0, 0)) +>"i" : Symbol(i, Decl(index.js, 50, 58)) +>value : Symbol(value, Decl(index.js, 52, 44)) +>i : Symbol(i, Decl(index.js, 52, 51)) + +Object.defineProperty(module.exports, "ii", { value: module.exports.i }); +>Object.defineProperty : Symbol(ObjectConstructor.defineProperty, Decl(lib.es5.d.ts, --, --)) +>Object : Symbol(Object, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>defineProperty : Symbol(ObjectConstructor.defineProperty, Decl(lib.es5.d.ts, --, --)) +>module.exports : Symbol("tests/cases/conformance/jsdoc/declarations/index", Decl(index.js, 0, 0)) +>module : Symbol(module, Decl(index.js, 0, 22), Decl(index.js, 31, 56), Decl(index.js, 53, 52), Decl(index.js, 56, 52)) +>exports : Symbol("tests/cases/conformance/jsdoc/declarations/index", Decl(index.js, 0, 0)) +>"ii" : Symbol(ii, Decl(index.js, 52, 70)) +>value : Symbol(value, Decl(index.js, 53, 45)) +>module.exports.i : Symbol(i, Decl(index.js, 50, 58)) +>module.exports : Symbol("tests/cases/conformance/jsdoc/declarations/index", Decl(index.js, 0, 0)) +>module : Symbol(module, Decl(index.js, 0, 22), Decl(index.js, 31, 56), Decl(index.js, 53, 52), Decl(index.js, 56, 52)) +>exports : Symbol("tests/cases/conformance/jsdoc/declarations/index", Decl(index.js, 0, 0)) +>i : Symbol(i, Decl(index.js, 50, 58)) + +// note that this last one doesn't make much sense in cjs, since exports aren't hoisted bindings +Object.defineProperty(module.exports, "jj", { value: module.exports.j }); +>Object.defineProperty : Symbol(ObjectConstructor.defineProperty, Decl(lib.es5.d.ts, --, --)) +>Object : Symbol(Object, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>defineProperty : Symbol(ObjectConstructor.defineProperty, Decl(lib.es5.d.ts, --, --)) +>module.exports : Symbol("tests/cases/conformance/jsdoc/declarations/index", Decl(index.js, 0, 0)) +>module : Symbol(module, Decl(index.js, 0, 22), Decl(index.js, 31, 56), Decl(index.js, 53, 52), Decl(index.js, 56, 52)) +>exports : Symbol("tests/cases/conformance/jsdoc/declarations/index", Decl(index.js, 0, 0)) +>"jj" : Symbol(jj, Decl(index.js, 53, 73)) +>value : Symbol(value, Decl(index.js, 56, 45)) +>module.exports.j : Symbol(j, Decl(index.js, 56, 73)) +>module.exports : Symbol("tests/cases/conformance/jsdoc/declarations/index", Decl(index.js, 0, 0)) +>module : Symbol(module, Decl(index.js, 0, 22), Decl(index.js, 31, 56), Decl(index.js, 53, 52), Decl(index.js, 56, 52)) +>exports : Symbol("tests/cases/conformance/jsdoc/declarations/index", Decl(index.js, 0, 0)) +>j : Symbol(j, Decl(index.js, 56, 73)) + +Object.defineProperty(module.exports, "j", { value: function j() {} }); +>Object.defineProperty : Symbol(ObjectConstructor.defineProperty, Decl(lib.es5.d.ts, --, --)) +>Object : Symbol(Object, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>defineProperty : Symbol(ObjectConstructor.defineProperty, Decl(lib.es5.d.ts, --, --)) +>module.exports : Symbol("tests/cases/conformance/jsdoc/declarations/index", Decl(index.js, 0, 0)) +>module : Symbol(module, Decl(index.js, 0, 22), Decl(index.js, 31, 56), Decl(index.js, 53, 52), Decl(index.js, 56, 52)) +>exports : Symbol("tests/cases/conformance/jsdoc/declarations/index", Decl(index.js, 0, 0)) +>"j" : Symbol(j, Decl(index.js, 56, 73)) +>value : Symbol(value, Decl(index.js, 57, 44)) +>j : Symbol(j, Decl(index.js, 57, 51)) + diff --git a/tests/baselines/reference/jsDeclarationsExportDefinePropertyEmit.types b/tests/baselines/reference/jsDeclarationsExportDefinePropertyEmit.types new file mode 100644 index 0000000000000..c8cf0b47995b8 --- /dev/null +++ b/tests/baselines/reference/jsDeclarationsExportDefinePropertyEmit.types @@ -0,0 +1,267 @@ +=== tests/cases/conformance/jsdoc/declarations/index.js === +Object.defineProperty(module.exports, "a", { value: function a() {} }); +>Object.defineProperty(module.exports, "a", { value: function a() {} }) : any +>Object.defineProperty : (o: any, p: string | number | symbol, attributes: PropertyDescriptor & ThisType) => any +>Object : ObjectConstructor +>defineProperty : (o: any, p: string | number | symbol, attributes: PropertyDescriptor & ThisType) => any +>module.exports : typeof import("tests/cases/conformance/jsdoc/declarations/index") +>module : { "tests/cases/conformance/jsdoc/declarations/index": typeof import("tests/cases/conformance/jsdoc/declarations/index"); } +>exports : typeof import("tests/cases/conformance/jsdoc/declarations/index") +>"a" : "a" +>{ value: function a() {} } : { value: () => void; } +>value : () => void +>function a() {} : () => void +>a : () => void + +Object.defineProperty(module.exports, "b", { value: function b() {} }); +>Object.defineProperty(module.exports, "b", { value: function b() {} }) : any +>Object.defineProperty : (o: any, p: string | number | symbol, attributes: PropertyDescriptor & ThisType) => any +>Object : ObjectConstructor +>defineProperty : (o: any, p: string | number | symbol, attributes: PropertyDescriptor & ThisType) => any +>module.exports : typeof import("tests/cases/conformance/jsdoc/declarations/index") +>module : { "tests/cases/conformance/jsdoc/declarations/index": typeof import("tests/cases/conformance/jsdoc/declarations/index"); } +>exports : typeof import("tests/cases/conformance/jsdoc/declarations/index") +>"b" : "b" +>{ value: function b() {} } : { value: () => void; } +>value : () => void +>function b() {} : () => void +>b : () => void + +Object.defineProperty(module.exports.b, "cat", { value: "cat" }); +>Object.defineProperty(module.exports.b, "cat", { value: "cat" }) : any +>Object.defineProperty : (o: any, p: string | number | symbol, attributes: PropertyDescriptor & ThisType) => any +>Object : ObjectConstructor +>defineProperty : (o: any, p: string | number | symbol, attributes: PropertyDescriptor & ThisType) => any +>module.exports.b : () => void +>module.exports : typeof import("tests/cases/conformance/jsdoc/declarations/index") +>module : { "tests/cases/conformance/jsdoc/declarations/index": typeof import("tests/cases/conformance/jsdoc/declarations/index"); } +>exports : typeof import("tests/cases/conformance/jsdoc/declarations/index") +>b : () => void +>"cat" : "cat" +>{ value: "cat" } : { value: string; } +>value : string +>"cat" : "cat" + +/** + * @param {number} a + * @param {number} b + * @return {string} + */ +function d(a, b) { return /** @type {*} */(null); } +>d : (a: number, b: number) => string +>a : number +>b : number +>(null) : any +>null : null + +Object.defineProperty(module.exports, "d", { value: d }); +>Object.defineProperty(module.exports, "d", { value: d }) : any +>Object.defineProperty : (o: any, p: string | number | symbol, attributes: PropertyDescriptor & ThisType) => any +>Object : ObjectConstructor +>defineProperty : (o: any, p: string | number | symbol, attributes: PropertyDescriptor & ThisType) => any +>module.exports : typeof import("tests/cases/conformance/jsdoc/declarations/index") +>module : { "tests/cases/conformance/jsdoc/declarations/index": typeof import("tests/cases/conformance/jsdoc/declarations/index"); } +>exports : typeof import("tests/cases/conformance/jsdoc/declarations/index") +>"d" : "d" +>{ value: d } : { value: (a: number, b: number) => string; } +>value : (a: number, b: number) => string +>d : (a: number, b: number) => string + + +/** + * @template T,U + * @param {T} a + * @param {U} b + * @return {T & U} + */ +function e(a, b) { return /** @type {*} */(null); } +>e : (a: T, b: U) => T & U +>a : T +>b : U +>(null) : any +>null : null + +Object.defineProperty(module.exports, "e", { value: e }); +>Object.defineProperty(module.exports, "e", { value: e }) : any +>Object.defineProperty : (o: any, p: string | number | symbol, attributes: PropertyDescriptor & ThisType) => any +>Object : ObjectConstructor +>defineProperty : (o: any, p: string | number | symbol, attributes: PropertyDescriptor & ThisType) => any +>module.exports : typeof import("tests/cases/conformance/jsdoc/declarations/index") +>module : { "tests/cases/conformance/jsdoc/declarations/index": typeof import("tests/cases/conformance/jsdoc/declarations/index"); } +>exports : typeof import("tests/cases/conformance/jsdoc/declarations/index") +>"e" : "e" +>{ value: e } : { value: (a: T, b: U) => T & U; } +>value : (a: T, b: U) => T & U +>e : (a: T, b: U) => T & U + +/** + * @template T + * @param {T} a + */ +function f(a) { +>f : (a: T) => T +>a : T + + return a; +>a : T +} +Object.defineProperty(module.exports, "f", { value: f }); +>Object.defineProperty(module.exports, "f", { value: f }) : any +>Object.defineProperty : (o: any, p: string | number | symbol, attributes: PropertyDescriptor & ThisType) => any +>Object : ObjectConstructor +>defineProperty : (o: any, p: string | number | symbol, attributes: PropertyDescriptor & ThisType) => any +>module.exports : typeof import("tests/cases/conformance/jsdoc/declarations/index") +>module : { "tests/cases/conformance/jsdoc/declarations/index": typeof import("tests/cases/conformance/jsdoc/declarations/index"); } +>exports : typeof import("tests/cases/conformance/jsdoc/declarations/index") +>"f" : "f" +>{ value: f } : { value: (a: T) => T; } +>value : (a: T) => T +>f : (a: T) => T + +Object.defineProperty(module.exports.f, "self", { value: module.exports.f }); +>Object.defineProperty(module.exports.f, "self", { value: module.exports.f }) : any +>Object.defineProperty : (o: any, p: string | number | symbol, attributes: PropertyDescriptor & ThisType) => any +>Object : ObjectConstructor +>defineProperty : (o: any, p: string | number | symbol, attributes: PropertyDescriptor & ThisType) => any +>module.exports.f : (a: T) => T +>module.exports : typeof import("tests/cases/conformance/jsdoc/declarations/index") +>module : { "tests/cases/conformance/jsdoc/declarations/index": typeof import("tests/cases/conformance/jsdoc/declarations/index"); } +>exports : typeof import("tests/cases/conformance/jsdoc/declarations/index") +>f : (a: T) => T +>"self" : "self" +>{ value: module.exports.f } : { value: (a: T) => T; } +>value : (a: T) => T +>module.exports.f : (a: T) => T +>module.exports : typeof import("tests/cases/conformance/jsdoc/declarations/index") +>module : { "tests/cases/conformance/jsdoc/declarations/index": typeof import("tests/cases/conformance/jsdoc/declarations/index"); } +>exports : typeof import("tests/cases/conformance/jsdoc/declarations/index") +>f : (a: T) => T + +/** + * @param {{x: string}} a + * @param {{y: typeof module.exports.b}} b + */ +function g(a, b) { +>g : (a: { x: string; }, b: { y: () => void; }) => void +>a : { x: string; } +>b : { y: () => void; } + + return a.x && b.y(); +>a.x && b.y() : void +>a.x : string +>a : { x: string; } +>x : string +>b.y() : void +>b.y : () => void +>b : { y: () => void; } +>y : () => void +} +Object.defineProperty(module.exports, "g", { value: g }); +>Object.defineProperty(module.exports, "g", { value: g }) : any +>Object.defineProperty : (o: any, p: string | number | symbol, attributes: PropertyDescriptor & ThisType) => any +>Object : ObjectConstructor +>defineProperty : (o: any, p: string | number | symbol, attributes: PropertyDescriptor & ThisType) => any +>module.exports : typeof import("tests/cases/conformance/jsdoc/declarations/index") +>module : { "tests/cases/conformance/jsdoc/declarations/index": typeof import("tests/cases/conformance/jsdoc/declarations/index"); } +>exports : typeof import("tests/cases/conformance/jsdoc/declarations/index") +>"g" : "g" +>{ value: g } : { value: (a: { x: string; }, b: { y: () => void; }) => void; } +>value : (a: { x: string; }, b: { y: () => void; }) => void +>g : (a: { x: string; }, b: { y: () => void; }) => void + + +/** + * @param {{x: string}} a + * @param {{y: typeof module.exports.b}} b + */ +function hh(a, b) { +>hh : (a: { x: string; }, b: { y: () => void; }) => void +>a : { x: string; } +>b : { y: () => void; } + + return a.x && b.y(); +>a.x && b.y() : void +>a.x : string +>a : { x: string; } +>x : string +>b.y() : void +>b.y : () => void +>b : { y: () => void; } +>y : () => void +} +Object.defineProperty(module.exports, "h", { value: hh }); +>Object.defineProperty(module.exports, "h", { value: hh }) : any +>Object.defineProperty : (o: any, p: string | number | symbol, attributes: PropertyDescriptor & ThisType) => any +>Object : ObjectConstructor +>defineProperty : (o: any, p: string | number | symbol, attributes: PropertyDescriptor & ThisType) => any +>module.exports : typeof import("tests/cases/conformance/jsdoc/declarations/index") +>module : { "tests/cases/conformance/jsdoc/declarations/index": typeof import("tests/cases/conformance/jsdoc/declarations/index"); } +>exports : typeof import("tests/cases/conformance/jsdoc/declarations/index") +>"h" : "h" +>{ value: hh } : { value: (a: { x: string; }, b: { y: () => void; }) => void; } +>value : (a: { x: string; }, b: { y: () => void; }) => void +>hh : (a: { x: string; }, b: { y: () => void; }) => void + +Object.defineProperty(module.exports, "i", { value: function i(){} }); +>Object.defineProperty(module.exports, "i", { value: function i(){} }) : any +>Object.defineProperty : (o: any, p: string | number | symbol, attributes: PropertyDescriptor & ThisType) => any +>Object : ObjectConstructor +>defineProperty : (o: any, p: string | number | symbol, attributes: PropertyDescriptor & ThisType) => any +>module.exports : typeof import("tests/cases/conformance/jsdoc/declarations/index") +>module : { "tests/cases/conformance/jsdoc/declarations/index": typeof import("tests/cases/conformance/jsdoc/declarations/index"); } +>exports : typeof import("tests/cases/conformance/jsdoc/declarations/index") +>"i" : "i" +>{ value: function i(){} } : { value: () => void; } +>value : () => void +>function i(){} : () => void +>i : () => void + +Object.defineProperty(module.exports, "ii", { value: module.exports.i }); +>Object.defineProperty(module.exports, "ii", { value: module.exports.i }) : any +>Object.defineProperty : (o: any, p: string | number | symbol, attributes: PropertyDescriptor & ThisType) => any +>Object : ObjectConstructor +>defineProperty : (o: any, p: string | number | symbol, attributes: PropertyDescriptor & ThisType) => any +>module.exports : typeof import("tests/cases/conformance/jsdoc/declarations/index") +>module : { "tests/cases/conformance/jsdoc/declarations/index": typeof import("tests/cases/conformance/jsdoc/declarations/index"); } +>exports : typeof import("tests/cases/conformance/jsdoc/declarations/index") +>"ii" : "ii" +>{ value: module.exports.i } : { value: () => void; } +>value : () => void +>module.exports.i : () => void +>module.exports : typeof import("tests/cases/conformance/jsdoc/declarations/index") +>module : { "tests/cases/conformance/jsdoc/declarations/index": typeof import("tests/cases/conformance/jsdoc/declarations/index"); } +>exports : typeof import("tests/cases/conformance/jsdoc/declarations/index") +>i : () => void + +// note that this last one doesn't make much sense in cjs, since exports aren't hoisted bindings +Object.defineProperty(module.exports, "jj", { value: module.exports.j }); +>Object.defineProperty(module.exports, "jj", { value: module.exports.j }) : any +>Object.defineProperty : (o: any, p: string | number | symbol, attributes: PropertyDescriptor & ThisType) => any +>Object : ObjectConstructor +>defineProperty : (o: any, p: string | number | symbol, attributes: PropertyDescriptor & ThisType) => any +>module.exports : typeof import("tests/cases/conformance/jsdoc/declarations/index") +>module : { "tests/cases/conformance/jsdoc/declarations/index": typeof import("tests/cases/conformance/jsdoc/declarations/index"); } +>exports : typeof import("tests/cases/conformance/jsdoc/declarations/index") +>"jj" : "jj" +>{ value: module.exports.j } : { value: () => void; } +>value : () => void +>module.exports.j : () => void +>module.exports : typeof import("tests/cases/conformance/jsdoc/declarations/index") +>module : { "tests/cases/conformance/jsdoc/declarations/index": typeof import("tests/cases/conformance/jsdoc/declarations/index"); } +>exports : typeof import("tests/cases/conformance/jsdoc/declarations/index") +>j : () => void + +Object.defineProperty(module.exports, "j", { value: function j() {} }); +>Object.defineProperty(module.exports, "j", { value: function j() {} }) : any +>Object.defineProperty : (o: any, p: string | number | symbol, attributes: PropertyDescriptor & ThisType) => any +>Object : ObjectConstructor +>defineProperty : (o: any, p: string | number | symbol, attributes: PropertyDescriptor & ThisType) => any +>module.exports : typeof import("tests/cases/conformance/jsdoc/declarations/index") +>module : { "tests/cases/conformance/jsdoc/declarations/index": typeof import("tests/cases/conformance/jsdoc/declarations/index"); } +>exports : typeof import("tests/cases/conformance/jsdoc/declarations/index") +>"j" : "j" +>{ value: function j() {} } : { value: () => void; } +>value : () => void +>function j() {} : () => void +>j : () => void + diff --git a/tests/baselines/reference/jsDeclarationsExportForms.js b/tests/baselines/reference/jsDeclarationsExportForms.js new file mode 100644 index 0000000000000..b94a07eb3fd06 --- /dev/null +++ b/tests/baselines/reference/jsDeclarationsExportForms.js @@ -0,0 +1,169 @@ +//// [tests/cases/conformance/jsdoc/declarations/jsDeclarationsExportForms.ts] //// + +//// [cls.js] +export class Foo {} + +//// [func.js] +export function func() {} + +//// [bar.js] +export * from "./cls"; + +//// [bar2.js] +export * from "./func"; +export * from "./cls"; + +//// [baz.js] +import {Foo} from "./cls"; +export {Foo}; + +//// [bat.js] +import * as ns from "./cls"; +export default ns; + +//// [ban.js] +import * as ns from "./cls"; +export {ns}; + +//// [bol.js] +import * as ns from "./cls"; +export { ns as classContainer }; + +//// [cjs.js] +const ns = require("./cls"); +module.exports = { ns }; + +//// [cjs2.js] +const ns = require("./cls"); +module.exports = ns; + +//// [cjs3.js] +const ns = require("./cls"); +module.exports.ns = ns; + +//// [cjs4.js] +const ns = require("./cls"); +module.exports.names = ns; + +//// [includeAll.js] +import "./cjs4"; +import "./cjs3"; +import "./cjs2"; +import "./cjs"; +import "./bol"; +import "./ban"; +import "./bat"; +import "./baz"; +import "./bar"; +import "./bar2"; + + +//// [cls.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +var Foo = /** @class */ (function () { + function Foo() { + } + return Foo; +}()); +exports.Foo = Foo; +//// [func.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +function func() { } +exports.func = func; +//// [bar.js] +"use strict"; +function __export(m) { + for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p]; +} +Object.defineProperty(exports, "__esModule", { value: true }); +__export(require("./cls")); +//// [bar2.js] +"use strict"; +function __export(m) { + for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p]; +} +Object.defineProperty(exports, "__esModule", { value: true }); +__export(require("./func")); +__export(require("./cls")); +//// [baz.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +var cls_1 = require("./cls"); +exports.Foo = cls_1.Foo; +//// [bat.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +var ns = require("./cls"); +exports.default = ns; +//// [ban.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +var ns = require("./cls"); +exports.ns = ns; +//// [bol.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +var ns = require("./cls"); +exports.classContainer = ns; +//// [cjs.js] +var ns = require("./cls"); +module.exports = { ns: ns }; +//// [cjs2.js] +var ns = require("./cls"); +module.exports = ns; +//// [cjs3.js] +var ns = require("./cls"); +module.exports.ns = ns; +//// [cjs4.js] +var ns = require("./cls"); +module.exports.names = ns; +//// [includeAll.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +require("./cjs4"); +require("./cjs3"); +require("./cjs2"); +require("./cjs"); +require("./bol"); +require("./ban"); +require("./bat"); +require("./baz"); +require("./bar"); +require("./bar2"); + + +//// [cls.d.ts] +export class Foo { +} +//// [func.d.ts] +export function func(): void; +//// [bar.d.ts] +export * from "./cls"; +//// [bar2.d.ts] +export * from "./func"; +export * from "./cls"; +//// [baz.d.ts] +export { Foo }; +import { Foo } from "./cls"; +//// [bat.d.ts] +export default ns; +import * as ns from "./cls"; +//// [ban.d.ts] +export { ns }; +import * as ns from "./cls"; +//// [bol.d.ts] +export { ns as classContainer }; +import * as ns from "./cls"; +//// [cjs.d.ts] +export const ns: typeof import("./cls"); +//// [cjs2.d.ts] +export = ns; +declare const ns: typeof import("./cls"); +//// [cjs3.d.ts] +export var ns: typeof import("./cls"); +//// [cjs4.d.ts] +export var names: typeof import("./cls"); +//// [includeAll.d.ts] +export {}; diff --git a/tests/baselines/reference/jsDeclarationsExportForms.symbols b/tests/baselines/reference/jsDeclarationsExportForms.symbols new file mode 100644 index 0000000000000..300425b5c96e9 --- /dev/null +++ b/tests/baselines/reference/jsDeclarationsExportForms.symbols @@ -0,0 +1,109 @@ +=== tests/cases/conformance/jsdoc/declarations/cls.js === +export class Foo {} +>Foo : Symbol(Foo, Decl(cls.js, 0, 0)) + +=== tests/cases/conformance/jsdoc/declarations/func.js === +export function func() {} +>func : Symbol(func, Decl(func.js, 0, 0)) + +=== tests/cases/conformance/jsdoc/declarations/bar.js === +export * from "./cls"; +No type information for this code. +No type information for this code.=== tests/cases/conformance/jsdoc/declarations/bar2.js === +export * from "./func"; +No type information for this code.export * from "./cls"; +No type information for this code. +No type information for this code.=== tests/cases/conformance/jsdoc/declarations/baz.js === +import {Foo} from "./cls"; +>Foo : Symbol(Foo, Decl(baz.js, 0, 8)) + +export {Foo}; +>Foo : Symbol(Foo, Decl(baz.js, 1, 8)) + +=== tests/cases/conformance/jsdoc/declarations/bat.js === +import * as ns from "./cls"; +>ns : Symbol(ns, Decl(bat.js, 0, 6)) + +export default ns; +>ns : Symbol(ns, Decl(bat.js, 0, 6)) + +=== tests/cases/conformance/jsdoc/declarations/ban.js === +import * as ns from "./cls"; +>ns : Symbol(ns, Decl(ban.js, 0, 6)) + +export {ns}; +>ns : Symbol(ns, Decl(ban.js, 1, 8)) + +=== tests/cases/conformance/jsdoc/declarations/bol.js === +import * as ns from "./cls"; +>ns : Symbol(ns, Decl(bol.js, 0, 6)) + +export { ns as classContainer }; +>ns : Symbol(ns, Decl(bol.js, 0, 6)) +>classContainer : Symbol(classContainer, Decl(bol.js, 1, 8)) + +=== tests/cases/conformance/jsdoc/declarations/cjs.js === +const ns = require("./cls"); +>ns : Symbol(ns, Decl(cjs.js, 0, 5)) +>require : Symbol(require) +>"./cls" : Symbol("tests/cases/conformance/jsdoc/declarations/cls", Decl(cls.js, 0, 0)) + +module.exports = { ns }; +>module.exports : Symbol("tests/cases/conformance/jsdoc/declarations/cjs", Decl(cjs.js, 0, 0)) +>module : Symbol(export=, Decl(cjs.js, 0, 28)) +>exports : Symbol(export=, Decl(cjs.js, 0, 28)) +>ns : Symbol(ns, Decl(cjs.js, 1, 18)) + +=== tests/cases/conformance/jsdoc/declarations/cjs2.js === +const ns = require("./cls"); +>ns : Symbol(ns, Decl(cjs2.js, 0, 5)) +>require : Symbol(require) +>"./cls" : Symbol("tests/cases/conformance/jsdoc/declarations/cls", Decl(cls.js, 0, 0)) + +module.exports = ns; +>module.exports : Symbol("tests/cases/conformance/jsdoc/declarations/cjs2", Decl(cjs2.js, 0, 0)) +>module : Symbol(export=, Decl(cjs2.js, 0, 28)) +>exports : Symbol(export=, Decl(cjs2.js, 0, 28)) +>ns : Symbol(ns, Decl(cjs2.js, 0, 5)) + +=== tests/cases/conformance/jsdoc/declarations/cjs3.js === +const ns = require("./cls"); +>ns : Symbol(ns, Decl(cjs3.js, 0, 5)) +>require : Symbol(require) +>"./cls" : Symbol("tests/cases/conformance/jsdoc/declarations/cls", Decl(cls.js, 0, 0)) + +module.exports.ns = ns; +>module.exports.ns : Symbol(ns, Decl(cjs3.js, 0, 28)) +>module.exports : Symbol(ns, Decl(cjs3.js, 0, 28)) +>module : Symbol(module, Decl(cjs3.js, 0, 28)) +>exports : Symbol("tests/cases/conformance/jsdoc/declarations/cjs3", Decl(cjs3.js, 0, 0)) +>ns : Symbol(ns, Decl(cjs3.js, 0, 28)) +>ns : Symbol(ns, Decl(cjs3.js, 0, 5)) + +=== tests/cases/conformance/jsdoc/declarations/cjs4.js === +const ns = require("./cls"); +>ns : Symbol(ns, Decl(cjs4.js, 0, 5)) +>require : Symbol(require) +>"./cls" : Symbol("tests/cases/conformance/jsdoc/declarations/cls", Decl(cls.js, 0, 0)) + +module.exports.names = ns; +>module.exports.names : Symbol(names, Decl(cjs4.js, 0, 28)) +>module.exports : Symbol(names, Decl(cjs4.js, 0, 28)) +>module : Symbol(module, Decl(cjs4.js, 0, 28)) +>exports : Symbol("tests/cases/conformance/jsdoc/declarations/cjs4", Decl(cjs4.js, 0, 0)) +>names : Symbol(names, Decl(cjs4.js, 0, 28)) +>ns : Symbol(ns, Decl(cjs4.js, 0, 5)) + +=== tests/cases/conformance/jsdoc/declarations/includeAll.js === +import "./cjs4"; +No type information for this code.import "./cjs3"; +No type information for this code.import "./cjs2"; +No type information for this code.import "./cjs"; +No type information for this code.import "./bol"; +No type information for this code.import "./ban"; +No type information for this code.import "./bat"; +No type information for this code.import "./baz"; +No type information for this code.import "./bar"; +No type information for this code.import "./bar2"; +No type information for this code. +No type information for this code. \ No newline at end of file diff --git a/tests/baselines/reference/jsDeclarationsExportForms.types b/tests/baselines/reference/jsDeclarationsExportForms.types new file mode 100644 index 0000000000000..5f454ee97bf32 --- /dev/null +++ b/tests/baselines/reference/jsDeclarationsExportForms.types @@ -0,0 +1,118 @@ +=== tests/cases/conformance/jsdoc/declarations/cls.js === +export class Foo {} +>Foo : Foo + +=== tests/cases/conformance/jsdoc/declarations/func.js === +export function func() {} +>func : () => void + +=== tests/cases/conformance/jsdoc/declarations/bar.js === +export * from "./cls"; +No type information for this code. +No type information for this code.=== tests/cases/conformance/jsdoc/declarations/bar2.js === +export * from "./func"; +No type information for this code.export * from "./cls"; +No type information for this code. +No type information for this code.=== tests/cases/conformance/jsdoc/declarations/baz.js === +import {Foo} from "./cls"; +>Foo : typeof Foo + +export {Foo}; +>Foo : typeof Foo + +=== tests/cases/conformance/jsdoc/declarations/bat.js === +import * as ns from "./cls"; +>ns : typeof ns + +export default ns; +>ns : typeof ns + +=== tests/cases/conformance/jsdoc/declarations/ban.js === +import * as ns from "./cls"; +>ns : typeof ns + +export {ns}; +>ns : typeof ns + +=== tests/cases/conformance/jsdoc/declarations/bol.js === +import * as ns from "./cls"; +>ns : typeof ns + +export { ns as classContainer }; +>ns : typeof ns +>classContainer : typeof ns + +=== tests/cases/conformance/jsdoc/declarations/cjs.js === +const ns = require("./cls"); +>ns : typeof import("tests/cases/conformance/jsdoc/declarations/cls") +>require("./cls") : typeof import("tests/cases/conformance/jsdoc/declarations/cls") +>require : any +>"./cls" : "./cls" + +module.exports = { ns }; +>module.exports = { ns } : { ns: typeof import("tests/cases/conformance/jsdoc/declarations/cls"); } +>module.exports : { ns: typeof import("tests/cases/conformance/jsdoc/declarations/cls"); } +>module : { "tests/cases/conformance/jsdoc/declarations/cjs": { ns: typeof import("tests/cases/conformance/jsdoc/declarations/cls"); }; } +>exports : { ns: typeof import("tests/cases/conformance/jsdoc/declarations/cls"); } +>{ ns } : { ns: typeof import("tests/cases/conformance/jsdoc/declarations/cls"); } +>ns : typeof import("tests/cases/conformance/jsdoc/declarations/cls") + +=== tests/cases/conformance/jsdoc/declarations/cjs2.js === +const ns = require("./cls"); +>ns : typeof import("tests/cases/conformance/jsdoc/declarations/cls") +>require("./cls") : typeof import("tests/cases/conformance/jsdoc/declarations/cls") +>require : any +>"./cls" : "./cls" + +module.exports = ns; +>module.exports = ns : typeof import("tests/cases/conformance/jsdoc/declarations/cls") +>module.exports : typeof import("tests/cases/conformance/jsdoc/declarations/cls") +>module : { "tests/cases/conformance/jsdoc/declarations/cjs2": typeof import("tests/cases/conformance/jsdoc/declarations/cls"); } +>exports : typeof import("tests/cases/conformance/jsdoc/declarations/cls") +>ns : typeof import("tests/cases/conformance/jsdoc/declarations/cls") + +=== tests/cases/conformance/jsdoc/declarations/cjs3.js === +const ns = require("./cls"); +>ns : typeof import("tests/cases/conformance/jsdoc/declarations/cls") +>require("./cls") : typeof import("tests/cases/conformance/jsdoc/declarations/cls") +>require : any +>"./cls" : "./cls" + +module.exports.ns = ns; +>module.exports.ns = ns : typeof import("tests/cases/conformance/jsdoc/declarations/cls") +>module.exports.ns : typeof import("tests/cases/conformance/jsdoc/declarations/cls") +>module.exports : typeof import("tests/cases/conformance/jsdoc/declarations/cjs3") +>module : { "tests/cases/conformance/jsdoc/declarations/cjs3": typeof import("tests/cases/conformance/jsdoc/declarations/cjs3"); } +>exports : typeof import("tests/cases/conformance/jsdoc/declarations/cjs3") +>ns : typeof import("tests/cases/conformance/jsdoc/declarations/cls") +>ns : typeof import("tests/cases/conformance/jsdoc/declarations/cls") + +=== tests/cases/conformance/jsdoc/declarations/cjs4.js === +const ns = require("./cls"); +>ns : typeof import("tests/cases/conformance/jsdoc/declarations/cls") +>require("./cls") : typeof import("tests/cases/conformance/jsdoc/declarations/cls") +>require : any +>"./cls" : "./cls" + +module.exports.names = ns; +>module.exports.names = ns : typeof import("tests/cases/conformance/jsdoc/declarations/cls") +>module.exports.names : typeof import("tests/cases/conformance/jsdoc/declarations/cls") +>module.exports : typeof import("tests/cases/conformance/jsdoc/declarations/cjs4") +>module : { "tests/cases/conformance/jsdoc/declarations/cjs4": typeof import("tests/cases/conformance/jsdoc/declarations/cjs4"); } +>exports : typeof import("tests/cases/conformance/jsdoc/declarations/cjs4") +>names : typeof import("tests/cases/conformance/jsdoc/declarations/cls") +>ns : typeof import("tests/cases/conformance/jsdoc/declarations/cls") + +=== tests/cases/conformance/jsdoc/declarations/includeAll.js === +import "./cjs4"; +No type information for this code.import "./cjs3"; +No type information for this code.import "./cjs2"; +No type information for this code.import "./cjs"; +No type information for this code.import "./bol"; +No type information for this code.import "./ban"; +No type information for this code.import "./bat"; +No type information for this code.import "./baz"; +No type information for this code.import "./bar"; +No type information for this code.import "./bar2"; +No type information for this code. +No type information for this code. \ No newline at end of file diff --git a/tests/baselines/reference/jsDeclarationsExportFormsErr.errors.txt b/tests/baselines/reference/jsDeclarationsExportFormsErr.errors.txt new file mode 100644 index 0000000000000..d0d5c78f0d1af --- /dev/null +++ b/tests/baselines/reference/jsDeclarationsExportFormsErr.errors.txt @@ -0,0 +1,34 @@ +tests/cases/conformance/jsdoc/declarations/bar.js(1,1): error TS8002: 'import ... =' can only be used in a .ts file. +tests/cases/conformance/jsdoc/declarations/bar.js(2,1): error TS8003: 'export=' can only be used in a .ts file. +tests/cases/conformance/jsdoc/declarations/bin.js(2,1): error TS2580: Cannot find name 'module'. Do you need to install type definitions for node? Try `npm i @types/node`. +tests/cases/conformance/jsdoc/declarations/globalNs.js(2,1): error TS1315: Global module exports may only appear in declaration files. + + +==== tests/cases/conformance/jsdoc/declarations/cls.js (0 errors) ==== + export class Foo {} + +==== tests/cases/conformance/jsdoc/declarations/bar.js (2 errors) ==== + import ns = require("./cls"); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8002: 'import ... =' can only be used in a .ts file. + export = ns; // TS Only + ~~~~~~~~~~~~ +!!! error TS8003: 'export=' can only be used in a .ts file. + +==== tests/cases/conformance/jsdoc/declarations/bin.js (1 errors) ==== + import * as ns from "./cls"; + module.exports = ns; // We refuse to bind cjs module exports assignments in the same file we find an import in + ~~~~~~ +!!! error TS2580: Cannot find name 'module'. Do you need to install type definitions for node? Try `npm i @types/node`. + +==== tests/cases/conformance/jsdoc/declarations/globalNs.js (1 errors) ==== + export * from "./cls"; + export as namespace GLO; // TS Only + ~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS1315: Global module exports may only appear in declaration files. + +==== tests/cases/conformance/jsdoc/declarations/includeAll.js (0 errors) ==== + import "./bar"; + import "./bin"; + import "./globalNs"; + \ No newline at end of file diff --git a/tests/baselines/reference/jsDeclarationsExportFormsErr.js b/tests/baselines/reference/jsDeclarationsExportFormsErr.js new file mode 100644 index 0000000000000..993be331cd520 --- /dev/null +++ b/tests/baselines/reference/jsDeclarationsExportFormsErr.js @@ -0,0 +1,68 @@ +//// [tests/cases/conformance/jsdoc/declarations/jsDeclarationsExportFormsErr.ts] //// + +//// [cls.js] +export class Foo {} + +//// [bar.js] +import ns = require("./cls"); +export = ns; // TS Only + +//// [bin.js] +import * as ns from "./cls"; +module.exports = ns; // We refuse to bind cjs module exports assignments in the same file we find an import in + +//// [globalNs.js] +export * from "./cls"; +export as namespace GLO; // TS Only + +//// [includeAll.js] +import "./bar"; +import "./bin"; +import "./globalNs"; + + +//// [cls.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +var Foo = /** @class */ (function () { + function Foo() { + } + return Foo; +}()); +exports.Foo = Foo; +//// [bar.js] +"use strict"; +var ns = require("./cls"); +module.exports = ns; +//// [bin.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +var ns = require("./cls"); +module.exports = ns; // We refuse to bind cjs module exports assignments in the same file we find an import in +//// [globalNs.js] +"use strict"; +function __export(m) { + for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p]; +} +Object.defineProperty(exports, "__esModule", { value: true }); +__export(require("./cls")); +//// [includeAll.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +require("./bar"); +require("./bin"); +require("./globalNs"); + + +//// [cls.d.ts] +export class Foo { +} +//// [bar.d.ts] +export = ns; +import ns = require("./bar"); +//// [bin.d.ts] +export {}; +//// [globalNs.d.ts] +export * from "./cls"; +//// [includeAll.d.ts] +export {}; diff --git a/tests/baselines/reference/jsDeclarationsExportFormsErr.symbols b/tests/baselines/reference/jsDeclarationsExportFormsErr.symbols new file mode 100644 index 0000000000000..a8795f892f26f --- /dev/null +++ b/tests/baselines/reference/jsDeclarationsExportFormsErr.symbols @@ -0,0 +1,28 @@ +=== tests/cases/conformance/jsdoc/declarations/cls.js === +export class Foo {} +>Foo : Symbol(Foo, Decl(cls.js, 0, 0)) + +=== tests/cases/conformance/jsdoc/declarations/bar.js === +import ns = require("./cls"); +>ns : Symbol(ns, Decl(bar.js, 0, 0)) + +export = ns; // TS Only +>ns : Symbol(ns, Decl(bar.js, 0, 0)) + +=== tests/cases/conformance/jsdoc/declarations/bin.js === +import * as ns from "./cls"; +>ns : Symbol(ns, Decl(bin.js, 0, 6)) + +module.exports = ns; // We refuse to bind cjs module exports assignments in the same file we find an import in +>ns : Symbol(ns, Decl(bin.js, 0, 6)) + +=== tests/cases/conformance/jsdoc/declarations/globalNs.js === +export * from "./cls"; +No type information for this code.export as namespace GLO; // TS Only +No type information for this code. +No type information for this code.=== tests/cases/conformance/jsdoc/declarations/includeAll.js === +import "./bar"; +No type information for this code.import "./bin"; +No type information for this code.import "./globalNs"; +No type information for this code. +No type information for this code. \ No newline at end of file diff --git a/tests/baselines/reference/jsDeclarationsExportFormsErr.types b/tests/baselines/reference/jsDeclarationsExportFormsErr.types new file mode 100644 index 0000000000000..c4035e7ec82db --- /dev/null +++ b/tests/baselines/reference/jsDeclarationsExportFormsErr.types @@ -0,0 +1,33 @@ +=== tests/cases/conformance/jsdoc/declarations/cls.js === +export class Foo {} +>Foo : Foo + +=== tests/cases/conformance/jsdoc/declarations/bar.js === +import ns = require("./cls"); +>ns : typeof ns + +export = ns; // TS Only +>ns : typeof ns + +=== tests/cases/conformance/jsdoc/declarations/bin.js === +import * as ns from "./cls"; +>ns : typeof ns + +module.exports = ns; // We refuse to bind cjs module exports assignments in the same file we find an import in +>module.exports = ns : any +>module.exports : any +>module : any +>exports : any +>ns : typeof ns + +=== tests/cases/conformance/jsdoc/declarations/globalNs.js === +export * from "./cls"; +export as namespace GLO; // TS Only +>GLO : any + +=== tests/cases/conformance/jsdoc/declarations/includeAll.js === +import "./bar"; +No type information for this code.import "./bin"; +No type information for this code.import "./globalNs"; +No type information for this code. +No type information for this code. \ No newline at end of file diff --git a/tests/baselines/reference/jsDeclarationsExportSpecifierNonlocal.js b/tests/baselines/reference/jsDeclarationsExportSpecifierNonlocal.js new file mode 100644 index 0000000000000..adf1984e5d46a --- /dev/null +++ b/tests/baselines/reference/jsDeclarationsExportSpecifierNonlocal.js @@ -0,0 +1,39 @@ +//// [tests/cases/conformance/jsdoc/declarations/jsDeclarationsExportSpecifierNonlocal.ts] //// + +//// [source.js] +export class Thing {} +export class OtherThing {} +//// [index.js] +export { Thing, OtherThing as default } from "./source"; + + +//// [source.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +var Thing = /** @class */ (function () { + function Thing() { + } + return Thing; +}()); +exports.Thing = Thing; +var OtherThing = /** @class */ (function () { + function OtherThing() { + } + return OtherThing; +}()); +exports.OtherThing = OtherThing; +//// [index.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +var source_1 = require("./source"); +exports.Thing = source_1.Thing; +exports.default = source_1.OtherThing; + + +//// [source.d.ts] +export class Thing { +} +export class OtherThing { +} +//// [index.d.ts] +export { Thing, OtherThing as default } from "./source"; diff --git a/tests/baselines/reference/jsDeclarationsExportSpecifierNonlocal.symbols b/tests/baselines/reference/jsDeclarationsExportSpecifierNonlocal.symbols new file mode 100644 index 0000000000000..561ebd0e382d0 --- /dev/null +++ b/tests/baselines/reference/jsDeclarationsExportSpecifierNonlocal.symbols @@ -0,0 +1,13 @@ +=== tests/cases/conformance/jsdoc/declarations/source.js === +export class Thing {} +>Thing : Symbol(Thing, Decl(source.js, 0, 0)) + +export class OtherThing {} +>OtherThing : Symbol(OtherThing, Decl(source.js, 0, 21)) + +=== tests/cases/conformance/jsdoc/declarations/index.js === +export { Thing, OtherThing as default } from "./source"; +>Thing : Symbol(Thing, Decl(index.js, 0, 8)) +>OtherThing : Symbol(OtherThing, Decl(source.js, 0, 21)) +>default : Symbol(default, Decl(index.js, 0, 15)) + diff --git a/tests/baselines/reference/jsDeclarationsExportSpecifierNonlocal.types b/tests/baselines/reference/jsDeclarationsExportSpecifierNonlocal.types new file mode 100644 index 0000000000000..b94684de66536 --- /dev/null +++ b/tests/baselines/reference/jsDeclarationsExportSpecifierNonlocal.types @@ -0,0 +1,13 @@ +=== tests/cases/conformance/jsdoc/declarations/source.js === +export class Thing {} +>Thing : Thing + +export class OtherThing {} +>OtherThing : OtherThing + +=== tests/cases/conformance/jsdoc/declarations/index.js === +export { Thing, OtherThing as default } from "./source"; +>Thing : typeof import("tests/cases/conformance/jsdoc/declarations/source").Thing +>OtherThing : typeof import("tests/cases/conformance/jsdoc/declarations/source").OtherThing +>default : typeof import("tests/cases/conformance/jsdoc/declarations/source").OtherThing + diff --git a/tests/baselines/reference/jsDeclarationsExportSubAssignments.js b/tests/baselines/reference/jsDeclarationsExportSubAssignments.js new file mode 100644 index 0000000000000..3e9ee20f4b67f --- /dev/null +++ b/tests/baselines/reference/jsDeclarationsExportSubAssignments.js @@ -0,0 +1,34 @@ +//// [cls.js] +const Strings = { + a: "A", + b: "B" +}; +class Foo {} +module.exports = Foo; +module.exports.Strings = Strings; + +//// [cls.js] +var Strings = { + a: "A", + b: "B" +}; +var Foo = /** @class */ (function () { + function Foo() { + } + return Foo; +}()); +module.exports = Foo; +module.exports.Strings = Strings; + + +//// [cls.d.ts] +export = Foo; +declare class Foo { +} +declare namespace Foo { + export { Strings }; +} +declare namespace Strings { + export const a: string; + export const b: string; +} diff --git a/tests/baselines/reference/jsDeclarationsExportSubAssignments.symbols b/tests/baselines/reference/jsDeclarationsExportSubAssignments.symbols new file mode 100644 index 0000000000000..a764b8e99d71d --- /dev/null +++ b/tests/baselines/reference/jsDeclarationsExportSubAssignments.symbols @@ -0,0 +1,28 @@ +=== tests/cases/conformance/jsdoc/declarations/cls.js === +const Strings = { +>Strings : Symbol(Strings, Decl(cls.js, 0, 5)) + + a: "A", +>a : Symbol(a, Decl(cls.js, 0, 17)) + + b: "B" +>b : Symbol(b, Decl(cls.js, 1, 11)) + +}; +class Foo {} +>Foo : Symbol(Foo, Decl(cls.js, 3, 2)) + +module.exports = Foo; +>module.exports : Symbol("tests/cases/conformance/jsdoc/declarations/cls", Decl(cls.js, 0, 0)) +>module : Symbol(export=, Decl(cls.js, 4, 12)) +>exports : Symbol(export=, Decl(cls.js, 4, 12)) +>Foo : Symbol(Foo, Decl(cls.js, 3, 2)) + +module.exports.Strings = Strings; +>module.exports.Strings : Symbol(Strings) +>module.exports : Symbol(Strings, Decl(cls.js, 5, 21)) +>module : Symbol(module, Decl(cls.js, 4, 12)) +>exports : Symbol("tests/cases/conformance/jsdoc/declarations/cls", Decl(cls.js, 0, 0)) +>Strings : Symbol(Strings, Decl(cls.js, 5, 21)) +>Strings : Symbol(Strings, Decl(cls.js, 0, 5)) + diff --git a/tests/baselines/reference/jsDeclarationsExportSubAssignments.types b/tests/baselines/reference/jsDeclarationsExportSubAssignments.types new file mode 100644 index 0000000000000..765da3557ab05 --- /dev/null +++ b/tests/baselines/reference/jsDeclarationsExportSubAssignments.types @@ -0,0 +1,33 @@ +=== tests/cases/conformance/jsdoc/declarations/cls.js === +const Strings = { +>Strings : { a: string; b: string; } +>{ a: "A", b: "B"} : { a: string; b: string; } + + a: "A", +>a : string +>"A" : "A" + + b: "B" +>b : string +>"B" : "B" + +}; +class Foo {} +>Foo : Foo + +module.exports = Foo; +>module.exports = Foo : typeof Foo +>module.exports : typeof Foo +>module : { "tests/cases/conformance/jsdoc/declarations/cls": typeof Foo; } +>exports : typeof Foo +>Foo : typeof Foo + +module.exports.Strings = Strings; +>module.exports.Strings = Strings : { a: string; b: string; } +>module.exports.Strings : { a: string; b: string; } +>module.exports : typeof Foo +>module : { "tests/cases/conformance/jsdoc/declarations/cls": typeof Foo; } +>exports : typeof Foo +>Strings : { a: string; b: string; } +>Strings : { a: string; b: string; } + diff --git a/tests/baselines/reference/jsDeclarationsFunctionClassesCjsExportAssignment.js b/tests/baselines/reference/jsDeclarationsFunctionClassesCjsExportAssignment.js new file mode 100644 index 0000000000000..f34ad068989ff --- /dev/null +++ b/tests/baselines/reference/jsDeclarationsFunctionClassesCjsExportAssignment.js @@ -0,0 +1,272 @@ +//// [tests/cases/conformance/jsdoc/declarations/jsDeclarationsFunctionClassesCjsExportAssignment.ts] //// + +//// [timer.js] +/** + * @param {number} timeout + */ +function Timer(timeout) { + this.timeout = timeout; +} +module.exports = Timer; +//// [hook.js] +/** + * @typedef {(arg: import("./context")) => void} HookHandler + */ +/** + * @param {HookHandler} handle + */ +function Hook(handle) { + this.handle = handle; +} +module.exports = Hook; + +//// [context.js] +/** + * Imports + * + * @typedef {import("./timer")} Timer + * @typedef {import("./hook")} Hook + * @typedef {import("./hook").HookHandler} HookHandler + */ + +/** + * Input type definition + * + * @typedef {Object} Input + * @prop {Timer} timer + * @prop {Hook} hook + */ + +/** + * State type definition + * + * @typedef {Object} State + * @prop {Timer} timer + * @prop {Hook} hook + */ + +/** + * New `Context` + * + * @class + * @param {Input} input + */ + +function Context(input) { + if (!(this instanceof Context)) { + return new Context(input) + } + this.state = this.construct(input); +} +Context.prototype = { + /** + * @param {Input} input + * @param {HookHandler=} handle + * @returns {State} + */ + construct(input, handle = () => void 0) { + return input; + } +} +module.exports = Context; + + +//// [timer.js] +/** + * @param {number} timeout + */ +function Timer(timeout) { + this.timeout = timeout; +} +module.exports = Timer; +//// [context.js] +/** + * Imports + * + * @typedef {import("./timer")} Timer + * @typedef {import("./hook")} Hook + * @typedef {import("./hook").HookHandler} HookHandler + */ +/** + * Input type definition + * + * @typedef {Object} Input + * @prop {Timer} timer + * @prop {Hook} hook + */ +/** + * State type definition + * + * @typedef {Object} State + * @prop {Timer} timer + * @prop {Hook} hook + */ +/** + * New `Context` + * + * @class + * @param {Input} input + */ +function Context(input) { + if (!(this instanceof Context)) { + return new Context(input); + } + this.state = this.construct(input); +} +Context.prototype = { + /** + * @param {Input} input + * @param {HookHandler=} handle + * @returns {State} + */ + construct: function (input, handle) { + if (handle === void 0) { handle = function () { return void 0; }; } + return input; + } +}; +module.exports = Context; +//// [hook.js] +/** + * @typedef {(arg: import("./context")) => void} HookHandler + */ +/** + * @param {HookHandler} handle + */ +function Hook(handle) { + this.handle = handle; +} +module.exports = Hook; + + +//// [timer.d.ts] +export = Timer; +/** + * @param {number} timeout + */ +declare function Timer(timeout: number): void; +declare class Timer { + /** + * @param {number} timeout + */ + constructor(timeout: number); + timeout: number; +} +//// [context.d.ts] +export = Context; +/** + * Imports + * + * @typedef {import("./timer")} Timer + * @typedef {import("./hook")} Hook + * @typedef {import("./hook").HookHandler} HookHandler + */ +/** + * Input type definition + * + * @typedef {Object} Input + * @prop {Timer} timer + * @prop {Hook} hook + */ +/** + * State type definition + * + * @typedef {Object} State + * @prop {Timer} timer + * @prop {Hook} hook + */ +/** + * New `Context` + * + * @class + * @param {Input} input + */ +declare function Context(input: Input): Context; +declare class Context { + /** + * Imports + * + * @typedef {import("./timer")} Timer + * @typedef {import("./hook")} Hook + * @typedef {import("./hook").HookHandler} HookHandler + */ + /** + * Input type definition + * + * @typedef {Object} Input + * @prop {Timer} timer + * @prop {Hook} hook + */ + /** + * State type definition + * + * @typedef {Object} State + * @prop {Timer} timer + * @prop {Hook} hook + */ + /** + * New `Context` + * + * @class + * @param {Input} input + */ + constructor(input: Input); + state: any; + /** + * @param {Input} input + * @param {HookHandler=} handle + * @returns {State} + */ + construct(input: Input, handle?: (arg: Context) => void): State; +} +declare namespace Context { + export { Timer, Hook, HookHandler, Input, State }; +} +/** + * Input type definition + */ +type Input = { + timer: import("./timer"); + hook: import("./hook"); +}; +/** + * State type definition + */ +type State = { + timer: import("./timer"); + hook: import("./hook"); +}; +/** + * Imports + */ +type Timer = import("./timer"); +/** + * Imports + */ +type Hook = import("./hook"); +/** + * Imports + */ +type HookHandler = (arg: Context) => void; +//// [hook.d.ts] +export = Hook; +/** + * @typedef {(arg: import("./context")) => void} HookHandler + */ +/** + * @param {HookHandler} handle + */ +declare function Hook(handle: (arg: import("./context")) => void): void; +declare class Hook { + /** + * @typedef {(arg: import("./context")) => void} HookHandler + */ + /** + * @param {HookHandler} handle + */ + constructor(handle: (arg: import("./context")) => void); + handle: (arg: import("./context")) => void; +} +declare namespace Hook { + export { HookHandler }; +} +type HookHandler = (arg: import("./context")) => void; diff --git a/tests/baselines/reference/jsDeclarationsFunctionClassesCjsExportAssignment.symbols b/tests/baselines/reference/jsDeclarationsFunctionClassesCjsExportAssignment.symbols new file mode 100644 index 0000000000000..a8e34ede3cfc1 --- /dev/null +++ b/tests/baselines/reference/jsDeclarationsFunctionClassesCjsExportAssignment.symbols @@ -0,0 +1,115 @@ +=== tests/cases/conformance/jsdoc/declarations/timer.js === +/** + * @param {number} timeout + */ +function Timer(timeout) { +>Timer : Symbol(Timer, Decl(timer.js, 0, 0)) +>timeout : Symbol(timeout, Decl(timer.js, 3, 15)) + + this.timeout = timeout; +>timeout : Symbol(Timer.timeout, Decl(timer.js, 3, 25)) +>timeout : Symbol(timeout, Decl(timer.js, 3, 15)) +} +module.exports = Timer; +>module.exports : Symbol("tests/cases/conformance/jsdoc/declarations/timer", Decl(timer.js, 0, 0)) +>module : Symbol(export=, Decl(timer.js, 5, 1)) +>exports : Symbol(export=, Decl(timer.js, 5, 1)) +>Timer : Symbol(Timer, Decl(timer.js, 0, 0)) + +=== tests/cases/conformance/jsdoc/declarations/hook.js === +/** + * @typedef {(arg: import("./context")) => void} HookHandler + */ +/** + * @param {HookHandler} handle + */ +function Hook(handle) { +>Hook : Symbol(Hook, Decl(hook.js, 0, 0)) +>handle : Symbol(handle, Decl(hook.js, 6, 14)) + + this.handle = handle; +>handle : Symbol(Hook.handle, Decl(hook.js, 6, 23)) +>handle : Symbol(handle, Decl(hook.js, 6, 14)) +} +module.exports = Hook; +>module.exports : Symbol("tests/cases/conformance/jsdoc/declarations/hook", Decl(hook.js, 0, 0)) +>module : Symbol(export=, Decl(hook.js, 8, 1)) +>exports : Symbol(export=, Decl(hook.js, 8, 1)) +>Hook : Symbol(Hook, Decl(hook.js, 0, 0)) + +=== tests/cases/conformance/jsdoc/declarations/context.js === +/** + * Imports + * + * @typedef {import("./timer")} Timer + * @typedef {import("./hook")} Hook + * @typedef {import("./hook").HookHandler} HookHandler + */ + +/** + * Input type definition + * + * @typedef {Object} Input + * @prop {Timer} timer + * @prop {Hook} hook + */ + +/** + * State type definition + * + * @typedef {Object} State + * @prop {Timer} timer + * @prop {Hook} hook + */ + +/** + * New `Context` + * + * @class + * @param {Input} input + */ + +function Context(input) { +>Context : Symbol(Context, Decl(context.js, 0, 0), Decl(context.js, 36, 1)) +>input : Symbol(input, Decl(context.js, 31, 17)) + + if (!(this instanceof Context)) { +>this : Symbol(Context, Decl(context.js, 0, 0), Decl(context.js, 36, 1)) +>Context : Symbol(Context, Decl(context.js, 0, 0), Decl(context.js, 36, 1)) + + return new Context(input) +>Context : Symbol(Context, Decl(context.js, 0, 0), Decl(context.js, 36, 1)) +>input : Symbol(input, Decl(context.js, 31, 17)) + } + this.state = this.construct(input); +>this.state : Symbol(Context.state, Decl(context.js, 34, 5)) +>state : Symbol(Context.state, Decl(context.js, 34, 5)) +>this.construct : Symbol(construct, Decl(context.js, 37, 21), Decl(context.js, 37, 21)) +>construct : Symbol(construct, Decl(context.js, 37, 21), Decl(context.js, 37, 21)) +>input : Symbol(input, Decl(context.js, 31, 17)) +} +Context.prototype = { +>Context.prototype : Symbol(Context.prototype, Decl(context.js, 36, 1)) +>Context : Symbol(Context, Decl(context.js, 0, 0), Decl(context.js, 36, 1)) +>prototype : Symbol(Context.prototype, Decl(context.js, 36, 1)) + + /** + * @param {Input} input + * @param {HookHandler=} handle + * @returns {State} + */ + construct(input, handle = () => void 0) { +>construct : Symbol(construct, Decl(context.js, 37, 21)) +>input : Symbol(input, Decl(context.js, 43, 14)) +>handle : Symbol(handle, Decl(context.js, 43, 20)) + + return input; +>input : Symbol(input, Decl(context.js, 43, 14)) + } +} +module.exports = Context; +>module.exports : Symbol("tests/cases/conformance/jsdoc/declarations/context", Decl(context.js, 0, 0)) +>module : Symbol(export=, Decl(context.js, 46, 1)) +>exports : Symbol(export=, Decl(context.js, 46, 1)) +>Context : Symbol(Context, Decl(context.js, 0, 0), Decl(context.js, 36, 1)) + diff --git a/tests/baselines/reference/jsDeclarationsFunctionClassesCjsExportAssignment.types b/tests/baselines/reference/jsDeclarationsFunctionClassesCjsExportAssignment.types new file mode 100644 index 0000000000000..f9ee5c6e4c1c0 --- /dev/null +++ b/tests/baselines/reference/jsDeclarationsFunctionClassesCjsExportAssignment.types @@ -0,0 +1,137 @@ +=== tests/cases/conformance/jsdoc/declarations/timer.js === +/** + * @param {number} timeout + */ +function Timer(timeout) { +>Timer : typeof Timer +>timeout : number + + this.timeout = timeout; +>this.timeout = timeout : number +>this.timeout : any +>this : any +>timeout : any +>timeout : number +} +module.exports = Timer; +>module.exports = Timer : typeof Timer +>module.exports : typeof Timer +>module : { "tests/cases/conformance/jsdoc/declarations/timer": typeof Timer; } +>exports : typeof Timer +>Timer : typeof Timer + +=== tests/cases/conformance/jsdoc/declarations/hook.js === +/** + * @typedef {(arg: import("./context")) => void} HookHandler + */ +/** + * @param {HookHandler} handle + */ +function Hook(handle) { +>Hook : typeof Hook +>handle : (arg: import("tests/cases/conformance/jsdoc/declarations/context")) => void + + this.handle = handle; +>this.handle = handle : (arg: import("tests/cases/conformance/jsdoc/declarations/context")) => void +>this.handle : any +>this : any +>handle : any +>handle : (arg: import("tests/cases/conformance/jsdoc/declarations/context")) => void +} +module.exports = Hook; +>module.exports = Hook : typeof Hook +>module.exports : typeof Hook +>module : { "tests/cases/conformance/jsdoc/declarations/hook": typeof Hook; } +>exports : typeof Hook +>Hook : typeof Hook + +=== tests/cases/conformance/jsdoc/declarations/context.js === +/** + * Imports + * + * @typedef {import("./timer")} Timer + * @typedef {import("./hook")} Hook + * @typedef {import("./hook").HookHandler} HookHandler + */ + +/** + * Input type definition + * + * @typedef {Object} Input + * @prop {Timer} timer + * @prop {Hook} hook + */ + +/** + * State type definition + * + * @typedef {Object} State + * @prop {Timer} timer + * @prop {Hook} hook + */ + +/** + * New `Context` + * + * @class + * @param {Input} input + */ + +function Context(input) { +>Context : typeof Context +>input : Input + + if (!(this instanceof Context)) { +>!(this instanceof Context) : boolean +>(this instanceof Context) : boolean +>this instanceof Context : boolean +>this : this +>Context : typeof Context + + return new Context(input) +>new Context(input) : Context +>Context : typeof Context +>input : Input + } + this.state = this.construct(input); +>this.state = this.construct(input) : State +>this.state : any +>this : this & { construct(input: Input, handle?: (arg: Context) => void): State; } +>state : any +>this.construct(input) : State +>this.construct : (input: Input, handle?: (arg: Context) => void) => State +>this : this & { construct(input: Input, handle?: (arg: Context) => void): State; } +>construct : (input: Input, handle?: (arg: Context) => void) => State +>input : Input +} +Context.prototype = { +>Context.prototype = { /** * @param {Input} input * @param {HookHandler=} handle * @returns {State} */ construct(input, handle = () => void 0) { return input; }} : { construct(input: Input, handle?: (arg: Context) => void): State; } +>Context.prototype : { construct(input: Input, handle?: (arg: Context) => void): State; } +>Context : typeof Context +>prototype : { construct(input: Input, handle?: (arg: Context) => void): State; } +>{ /** * @param {Input} input * @param {HookHandler=} handle * @returns {State} */ construct(input, handle = () => void 0) { return input; }} : { construct(input: Input, handle?: (arg: Context) => void): State; } + + /** + * @param {Input} input + * @param {HookHandler=} handle + * @returns {State} + */ + construct(input, handle = () => void 0) { +>construct : (input: Input, handle?: (arg: Context) => void) => State +>input : Input +>handle : (arg: Context) => void +>() => void 0 : () => any +>void 0 : undefined +>0 : 0 + + return input; +>input : Input + } +} +module.exports = Context; +>module.exports = Context : typeof Context +>module.exports : typeof Context +>module : { "tests/cases/conformance/jsdoc/declarations/context": typeof Context; } +>exports : typeof Context +>Context : typeof Context + diff --git a/tests/baselines/reference/jsDeclarationsFunctionJSDoc.js b/tests/baselines/reference/jsDeclarationsFunctionJSDoc.js new file mode 100644 index 0000000000000..5cb305aa88be2 --- /dev/null +++ b/tests/baselines/reference/jsDeclarationsFunctionJSDoc.js @@ -0,0 +1,107 @@ +//// [source.js] +/** + * Foos a bar together using an `a` and a `b` + * @param {number} a + * @param {string} b + */ +export function foo(a, b) {} + +/** + * Legacy - DO NOT USE + */ +export class Aleph { + /** + * Impossible to construct. + * @param {Aleph} a + * @param {null} b + */ + constructor(a, b) { + /** + * Field is always null + */ + this.field = b; + } + + /** + * Doesn't actually do anything + * @returns {void} + */ + doIt() {} +} + +/** + * Not the speed of light + */ +export const c = 12; + + +//// [source.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +/** + * Foos a bar together using an `a` and a `b` + * @param {number} a + * @param {string} b + */ +function foo(a, b) { } +exports.foo = foo; +/** + * Legacy - DO NOT USE + */ +var Aleph = /** @class */ (function () { + /** + * Impossible to construct. + * @param {Aleph} a + * @param {null} b + */ + function Aleph(a, b) { + /** + * Field is always null + */ + this.field = b; + } + /** + * Doesn't actually do anything + * @returns {void} + */ + Aleph.prototype.doIt = function () { }; + return Aleph; +}()); +exports.Aleph = Aleph; +/** + * Not the speed of light + */ +exports.c = 12; + + +//// [source.d.ts] +/** + * Foos a bar together using an `a` and a `b` + * @param {number} a + * @param {string} b + */ +export function foo(a: number, b: string): void; +/** + * Legacy - DO NOT USE + */ +export class Aleph { + /** + * Impossible to construct. + * @param {Aleph} a + * @param {null} b + */ + constructor(a: Aleph, b: null); + /** + * Field is always null + */ + field: any; + /** + * Doesn't actually do anything + * @returns {void} + */ + doIt(): void; +} +/** + * Not the speed of light + */ +export const c: 12; diff --git a/tests/baselines/reference/jsDeclarationsFunctionJSDoc.symbols b/tests/baselines/reference/jsDeclarationsFunctionJSDoc.symbols new file mode 100644 index 0000000000000..27134d8058927 --- /dev/null +++ b/tests/baselines/reference/jsDeclarationsFunctionJSDoc.symbols @@ -0,0 +1,50 @@ +=== tests/cases/conformance/jsdoc/declarations/source.js === +/** + * Foos a bar together using an `a` and a `b` + * @param {number} a + * @param {string} b + */ +export function foo(a, b) {} +>foo : Symbol(foo, Decl(source.js, 0, 0)) +>a : Symbol(a, Decl(source.js, 5, 20)) +>b : Symbol(b, Decl(source.js, 5, 22)) + +/** + * Legacy - DO NOT USE + */ +export class Aleph { +>Aleph : Symbol(Aleph, Decl(source.js, 5, 28)) + + /** + * Impossible to construct. + * @param {Aleph} a + * @param {null} b + */ + constructor(a, b) { +>a : Symbol(a, Decl(source.js, 16, 16)) +>b : Symbol(b, Decl(source.js, 16, 18)) + + /** + * Field is always null + */ + this.field = b; +>this.field : Symbol(Aleph.field, Decl(source.js, 16, 23)) +>this : Symbol(Aleph, Decl(source.js, 5, 28)) +>field : Symbol(Aleph.field, Decl(source.js, 16, 23)) +>b : Symbol(b, Decl(source.js, 16, 18)) + } + + /** + * Doesn't actually do anything + * @returns {void} + */ + doIt() {} +>doIt : Symbol(Aleph.doIt, Decl(source.js, 21, 5)) +} + +/** + * Not the speed of light + */ +export const c = 12; +>c : Symbol(c, Decl(source.js, 33, 12)) + diff --git a/tests/baselines/reference/jsDeclarationsFunctionJSDoc.types b/tests/baselines/reference/jsDeclarationsFunctionJSDoc.types new file mode 100644 index 0000000000000..05dfcb0f492b8 --- /dev/null +++ b/tests/baselines/reference/jsDeclarationsFunctionJSDoc.types @@ -0,0 +1,52 @@ +=== tests/cases/conformance/jsdoc/declarations/source.js === +/** + * Foos a bar together using an `a` and a `b` + * @param {number} a + * @param {string} b + */ +export function foo(a, b) {} +>foo : (a: number, b: string) => void +>a : number +>b : string + +/** + * Legacy - DO NOT USE + */ +export class Aleph { +>Aleph : Aleph + + /** + * Impossible to construct. + * @param {Aleph} a + * @param {null} b + */ + constructor(a, b) { +>a : Aleph +>b : null + + /** + * Field is always null + */ + this.field = b; +>this.field = b : null +>this.field : any +>this : this +>field : any +>b : null + } + + /** + * Doesn't actually do anything + * @returns {void} + */ + doIt() {} +>doIt : () => void +} + +/** + * Not the speed of light + */ +export const c = 12; +>c : 12 +>12 : 12 + diff --git a/tests/baselines/reference/jsDeclarationsFunctionLikeClasses.js b/tests/baselines/reference/jsDeclarationsFunctionLikeClasses.js new file mode 100644 index 0000000000000..96b9cfbd62b5a --- /dev/null +++ b/tests/baselines/reference/jsDeclarationsFunctionLikeClasses.js @@ -0,0 +1,74 @@ +//// [tests/cases/conformance/jsdoc/declarations/jsDeclarationsFunctionLikeClasses.ts] //// + +//// [source.js] +/** + * @param {number} x + * @param {number} y + */ +export function Point(x, y) { + if (!(this instanceof Point)) { + return new Point(x, y); + } + this.x = x; + this.y = y; +} + +//// [referencer.js] +import {Point} from "./source"; + +/** + * @param {Point} p + */ +export function magnitude(p) { + return Math.sqrt(p.x ** 2 + p.y ** 2); +} + + +//// [source.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +/** + * @param {number} x + * @param {number} y + */ +function Point(x, y) { + if (!(this instanceof Point)) { + return new Point(x, y); + } + this.x = x; + this.y = y; +} +exports.Point = Point; +//// [referencer.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +/** + * @param {Point} p + */ +function magnitude(p) { + return Math.sqrt(Math.pow(p.x, 2) + Math.pow(p.y, 2)); +} +exports.magnitude = magnitude; + + +//// [source.d.ts] +/** + * @param {number} x + * @param {number} y + */ +export function Point(x: number, y: number): Point; +export class Point { + /** + * @param {number} x + * @param {number} y + */ + constructor(x: number, y: number); + x: number; + y: number; +} +//// [referencer.d.ts] +/** + * @param {Point} p + */ +export function magnitude(p: Point): number; +import { Point } from "./source"; diff --git a/tests/baselines/reference/jsDeclarationsFunctionLikeClasses.symbols b/tests/baselines/reference/jsDeclarationsFunctionLikeClasses.symbols new file mode 100644 index 0000000000000..61e0872f47979 --- /dev/null +++ b/tests/baselines/reference/jsDeclarationsFunctionLikeClasses.symbols @@ -0,0 +1,50 @@ +=== tests/cases/conformance/jsdoc/declarations/source.js === +/** + * @param {number} x + * @param {number} y + */ +export function Point(x, y) { +>Point : Symbol(Point, Decl(source.js, 0, 0)) +>x : Symbol(x, Decl(source.js, 4, 22)) +>y : Symbol(y, Decl(source.js, 4, 24)) + + if (!(this instanceof Point)) { +>Point : Symbol(Point, Decl(source.js, 0, 0)) + + return new Point(x, y); +>Point : Symbol(Point, Decl(source.js, 0, 0)) +>x : Symbol(x, Decl(source.js, 4, 22)) +>y : Symbol(y, Decl(source.js, 4, 24)) + } + this.x = x; +>x : Symbol(Point.x, Decl(source.js, 7, 5)) +>x : Symbol(x, Decl(source.js, 4, 22)) + + this.y = y; +>y : Symbol(Point.y, Decl(source.js, 8, 15)) +>y : Symbol(y, Decl(source.js, 4, 24)) +} + +=== tests/cases/conformance/jsdoc/declarations/referencer.js === +import {Point} from "./source"; +>Point : Symbol(Point, Decl(referencer.js, 0, 8)) + +/** + * @param {Point} p + */ +export function magnitude(p) { +>magnitude : Symbol(magnitude, Decl(referencer.js, 0, 31)) +>p : Symbol(p, Decl(referencer.js, 5, 26)) + + return Math.sqrt(p.x ** 2 + p.y ** 2); +>Math.sqrt : Symbol(Math.sqrt, Decl(lib.es5.d.ts, --, --)) +>Math : Symbol(Math, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>sqrt : Symbol(Math.sqrt, Decl(lib.es5.d.ts, --, --)) +>p.x : Symbol(Point.x, Decl(source.js, 7, 5)) +>p : Symbol(p, Decl(referencer.js, 5, 26)) +>x : Symbol(Point.x, Decl(source.js, 7, 5)) +>p.y : Symbol(Point.y, Decl(source.js, 8, 15)) +>p : Symbol(p, Decl(referencer.js, 5, 26)) +>y : Symbol(Point.y, Decl(source.js, 8, 15)) +} + diff --git a/tests/baselines/reference/jsDeclarationsFunctionLikeClasses.types b/tests/baselines/reference/jsDeclarationsFunctionLikeClasses.types new file mode 100644 index 0000000000000..02ad20be62c8e --- /dev/null +++ b/tests/baselines/reference/jsDeclarationsFunctionLikeClasses.types @@ -0,0 +1,67 @@ +=== tests/cases/conformance/jsdoc/declarations/source.js === +/** + * @param {number} x + * @param {number} y + */ +export function Point(x, y) { +>Point : typeof Point +>x : number +>y : number + + if (!(this instanceof Point)) { +>!(this instanceof Point) : boolean +>(this instanceof Point) : boolean +>this instanceof Point : boolean +>this : any +>Point : typeof Point + + return new Point(x, y); +>new Point(x, y) : Point +>Point : typeof Point +>x : number +>y : number + } + this.x = x; +>this.x = x : number +>this.x : any +>this : any +>x : any +>x : number + + this.y = y; +>this.y = y : number +>this.y : any +>this : any +>y : any +>y : number +} + +=== tests/cases/conformance/jsdoc/declarations/referencer.js === +import {Point} from "./source"; +>Point : typeof Point + +/** + * @param {Point} p + */ +export function magnitude(p) { +>magnitude : (p: Point) => number +>p : Point + + return Math.sqrt(p.x ** 2 + p.y ** 2); +>Math.sqrt(p.x ** 2 + p.y ** 2) : number +>Math.sqrt : (x: number) => number +>Math : Math +>sqrt : (x: number) => number +>p.x ** 2 + p.y ** 2 : number +>p.x ** 2 : number +>p.x : number +>p : Point +>x : number +>2 : 2 +>p.y ** 2 : number +>p.y : number +>p : Point +>y : number +>2 : 2 +} + diff --git a/tests/baselines/reference/jsDeclarationsFunctionLikeClasses2.js b/tests/baselines/reference/jsDeclarationsFunctionLikeClasses2.js new file mode 100644 index 0000000000000..86aecfef4c961 --- /dev/null +++ b/tests/baselines/reference/jsDeclarationsFunctionLikeClasses2.js @@ -0,0 +1,193 @@ +//// [tests/cases/conformance/jsdoc/declarations/jsDeclarationsFunctionLikeClasses2.ts] //// + +//// [source.js] +/** + * @param {number} len + */ +export function Vec(len) { + /** + * @type {number[]} + */ + this.storage = new Array(len); +} + +Vec.prototype = { + /** + * @param {Vec} other + */ + dot(other) { + if (other.storage.length !== this.storage.length) { + throw new Error(`Dot product only applicable for vectors of equal length`); + } + let sum = 0; + for (let i = 0; i < this.storage.length; i++) { + sum += (this.storage[i] * other.storage[i]); + } + return sum; + }, + magnitude() { + let sum = 0; + for (let i = 0; i < this.storage.length; i++) { + sum += (this.storage[i] ** 2); + } + return Math.sqrt(sum); + } +} + +/** + * @param {number} x + * @param {number} y + */ +export function Point2D(x, y) { + if (!(this instanceof Point2D)) { + return new Point2D(x, y); + } + Vec.call(this, 2); + this.x = x; + this.y = y; +} + +Point2D.prototype = { + __proto__: Vec, + get x() { + return this.storage[0]; + }, + /** + * @param {number} x + */ + set x(x) { + this.storage[0] = x; + }, + get y() { + return this.storage[1]; + }, + /** + * @param {number} y + */ + set y(y) { + this.storage[1] = y; + } +}; + +//// [referencer.js] +import {Point2D} from "./source"; + +export const origin = new Point2D(0, 0); +// export const res = Point2D(2, 3).dot(origin); // TODO: when __proto__ works, validate this + + +//// [source.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +/** + * @param {number} len + */ +function Vec(len) { + /** + * @type {number[]} + */ + this.storage = new Array(len); +} +exports.Vec = Vec; +Vec.prototype = { + /** + * @param {Vec} other + */ + dot: function (other) { + if (other.storage.length !== this.storage.length) { + throw new Error("Dot product only applicable for vectors of equal length"); + } + var sum = 0; + for (var i = 0; i < this.storage.length; i++) { + sum += (this.storage[i] * other.storage[i]); + } + return sum; + }, + magnitude: function () { + var sum = 0; + for (var i = 0; i < this.storage.length; i++) { + sum += (Math.pow(this.storage[i], 2)); + } + return Math.sqrt(sum); + } +}; +/** + * @param {number} x + * @param {number} y + */ +function Point2D(x, y) { + if (!(this instanceof Point2D)) { + return new Point2D(x, y); + } + Vec.call(this, 2); + this.x = x; + this.y = y; +} +exports.Point2D = Point2D; +Point2D.prototype = { + __proto__: Vec, + get x() { + return this.storage[0]; + }, + /** + * @param {number} x + */ + set x(x) { + this.storage[0] = x; + }, + get y() { + return this.storage[1]; + }, + /** + * @param {number} y + */ + set y(y) { + this.storage[1] = y; + } +}; +//// [referencer.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +var source_1 = require("./source"); +exports.origin = new source_1.Point2D(0, 0); +// export const res = Point2D(2, 3).dot(origin); // TODO: when __proto__ works, validate this + + +//// [source.d.ts] +/** + * @param {number} len + */ +export function Vec(len: number): void; +export class Vec { + /** + * @param {number} len + */ + constructor(len: number); + /** + * @type {number[]} + */ + storage: number[]; + /** + * @param {Vec} other + */ + dot(other: Vec): number; + magnitude(): number; +} +/** + * @param {number} x + * @param {number} y + */ +export function Point2D(x: number, y: number): Point2D; +export class Point2D { + /** + * @param {number} x + * @param {number} y + */ + constructor(x: number, y: number); + x: number; + y: number; + __proto__: typeof Vec; +} +//// [referencer.d.ts] +export const origin: Point2D; +import { Point2D } from "./source"; diff --git a/tests/baselines/reference/jsDeclarationsFunctionLikeClasses2.symbols b/tests/baselines/reference/jsDeclarationsFunctionLikeClasses2.symbols new file mode 100644 index 0000000000000..8e9894b37f96f --- /dev/null +++ b/tests/baselines/reference/jsDeclarationsFunctionLikeClasses2.symbols @@ -0,0 +1,192 @@ +=== tests/cases/conformance/jsdoc/declarations/source.js === +/** + * @param {number} len + */ +export function Vec(len) { +>Vec : Symbol(Vec, Decl(source.js, 0, 0), Decl(source.js, 8, 1)) +>len : Symbol(len, Decl(source.js, 3, 20)) + + /** + * @type {number[]} + */ + this.storage = new Array(len); +>storage : Symbol(Vec.storage, Decl(source.js, 3, 26)) +>Array : Symbol(Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>len : Symbol(len, Decl(source.js, 3, 20)) +} + +Vec.prototype = { +>Vec.prototype : Symbol(Vec.prototype, Decl(source.js, 8, 1)) +>Vec : Symbol(Vec, Decl(source.js, 0, 0), Decl(source.js, 8, 1)) +>prototype : Symbol(Vec.prototype, Decl(source.js, 8, 1)) + + /** + * @param {Vec} other + */ + dot(other) { +>dot : Symbol(dot, Decl(source.js, 10, 17)) +>other : Symbol(other, Decl(source.js, 14, 8)) + + if (other.storage.length !== this.storage.length) { +>other.storage.length : Symbol(Array.length, Decl(lib.es5.d.ts, --, --)) +>other.storage : Symbol(Vec.storage, Decl(source.js, 3, 26)) +>other : Symbol(other, Decl(source.js, 14, 8)) +>storage : Symbol(Vec.storage, Decl(source.js, 3, 26)) +>length : Symbol(Array.length, Decl(lib.es5.d.ts, --, --)) +>this.storage.length : Symbol(Array.length, Decl(lib.es5.d.ts, --, --)) +>this.storage : Symbol(Vec.storage, Decl(source.js, 3, 26)) +>this : Symbol(Vec, Decl(source.js, 0, 0), Decl(source.js, 8, 1)) +>storage : Symbol(Vec.storage, Decl(source.js, 3, 26)) +>length : Symbol(Array.length, Decl(lib.es5.d.ts, --, --)) + + throw new Error(`Dot product only applicable for vectors of equal length`); +>Error : Symbol(Error, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) + } + let sum = 0; +>sum : Symbol(sum, Decl(source.js, 18, 11)) + + for (let i = 0; i < this.storage.length; i++) { +>i : Symbol(i, Decl(source.js, 19, 16)) +>i : Symbol(i, Decl(source.js, 19, 16)) +>this.storage.length : Symbol(Array.length, Decl(lib.es5.d.ts, --, --)) +>this.storage : Symbol(Vec.storage, Decl(source.js, 3, 26)) +>this : Symbol(Vec, Decl(source.js, 0, 0), Decl(source.js, 8, 1)) +>storage : Symbol(Vec.storage, Decl(source.js, 3, 26)) +>length : Symbol(Array.length, Decl(lib.es5.d.ts, --, --)) +>i : Symbol(i, Decl(source.js, 19, 16)) + + sum += (this.storage[i] * other.storage[i]); +>sum : Symbol(sum, Decl(source.js, 18, 11)) +>this.storage : Symbol(Vec.storage, Decl(source.js, 3, 26)) +>this : Symbol(Vec, Decl(source.js, 0, 0), Decl(source.js, 8, 1)) +>storage : Symbol(Vec.storage, Decl(source.js, 3, 26)) +>i : Symbol(i, Decl(source.js, 19, 16)) +>other.storage : Symbol(Vec.storage, Decl(source.js, 3, 26)) +>other : Symbol(other, Decl(source.js, 14, 8)) +>storage : Symbol(Vec.storage, Decl(source.js, 3, 26)) +>i : Symbol(i, Decl(source.js, 19, 16)) + } + return sum; +>sum : Symbol(sum, Decl(source.js, 18, 11)) + + }, + magnitude() { +>magnitude : Symbol(magnitude, Decl(source.js, 23, 6)) + + let sum = 0; +>sum : Symbol(sum, Decl(source.js, 25, 11)) + + for (let i = 0; i < this.storage.length; i++) { +>i : Symbol(i, Decl(source.js, 26, 16)) +>i : Symbol(i, Decl(source.js, 26, 16)) +>this.storage.length : Symbol(Array.length, Decl(lib.es5.d.ts, --, --)) +>this.storage : Symbol(Vec.storage, Decl(source.js, 3, 26)) +>this : Symbol(Vec, Decl(source.js, 0, 0), Decl(source.js, 8, 1)) +>storage : Symbol(Vec.storage, Decl(source.js, 3, 26)) +>length : Symbol(Array.length, Decl(lib.es5.d.ts, --, --)) +>i : Symbol(i, Decl(source.js, 26, 16)) + + sum += (this.storage[i] ** 2); +>sum : Symbol(sum, Decl(source.js, 25, 11)) +>this.storage : Symbol(Vec.storage, Decl(source.js, 3, 26)) +>this : Symbol(Vec, Decl(source.js, 0, 0), Decl(source.js, 8, 1)) +>storage : Symbol(Vec.storage, Decl(source.js, 3, 26)) +>i : Symbol(i, Decl(source.js, 26, 16)) + } + return Math.sqrt(sum); +>Math.sqrt : Symbol(Math.sqrt, Decl(lib.es5.d.ts, --, --)) +>Math : Symbol(Math, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>sqrt : Symbol(Math.sqrt, Decl(lib.es5.d.ts, --, --)) +>sum : Symbol(sum, Decl(source.js, 25, 11)) + } +} + +/** + * @param {number} x + * @param {number} y + */ +export function Point2D(x, y) { +>Point2D : Symbol(Point2D, Decl(source.js, 31, 1), Decl(source.js, 44, 1)) +>x : Symbol(x, Decl(source.js, 37, 24)) +>y : Symbol(y, Decl(source.js, 37, 26)) + + if (!(this instanceof Point2D)) { +>Point2D : Symbol(Point2D, Decl(source.js, 31, 1), Decl(source.js, 44, 1)) + + return new Point2D(x, y); +>Point2D : Symbol(Point2D, Decl(source.js, 31, 1), Decl(source.js, 44, 1)) +>x : Symbol(x, Decl(source.js, 37, 24)) +>y : Symbol(y, Decl(source.js, 37, 26)) + } + Vec.call(this, 2); +>Vec.call : Symbol(Function.call, Decl(lib.es5.d.ts, --, --)) +>Vec : Symbol(Vec, Decl(source.js, 0, 0), Decl(source.js, 8, 1)) +>call : Symbol(Function.call, Decl(lib.es5.d.ts, --, --)) + + this.x = x; +>x : Symbol(Point2D.x, Decl(source.js, 41, 22), Decl(source.js, 47, 19), Decl(source.js, 50, 6)) +>x : Symbol(x, Decl(source.js, 37, 24)) + + this.y = y; +>y : Symbol(Point2D.y, Decl(source.js, 42, 15), Decl(source.js, 56, 6), Decl(source.js, 59, 6)) +>y : Symbol(y, Decl(source.js, 37, 26)) +} + +Point2D.prototype = { +>Point2D.prototype : Symbol(Point2D.prototype, Decl(source.js, 44, 1)) +>Point2D : Symbol(Point2D, Decl(source.js, 31, 1), Decl(source.js, 44, 1)) +>prototype : Symbol(Point2D.prototype, Decl(source.js, 44, 1)) + + __proto__: Vec, +>__proto__ : Symbol(__proto__, Decl(source.js, 46, 21)) +>Vec : Symbol(Vec, Decl(source.js, 0, 0), Decl(source.js, 8, 1)) + + get x() { +>x : Symbol(Point2D.x, Decl(source.js, 41, 22), Decl(source.js, 47, 19), Decl(source.js, 50, 6)) + + return this.storage[0]; +>this : Symbol(__object, Decl(source.js, 46, 19)) + + }, + /** + * @param {number} x + */ + set x(x) { +>x : Symbol(Point2D.x, Decl(source.js, 41, 22), Decl(source.js, 47, 19), Decl(source.js, 50, 6)) +>x : Symbol(x, Decl(source.js, 54, 10)) + + this.storage[0] = x; +>this : Symbol(__object, Decl(source.js, 46, 19)) +>x : Symbol(x, Decl(source.js, 54, 10)) + + }, + get y() { +>y : Symbol(Point2D.y, Decl(source.js, 42, 15), Decl(source.js, 56, 6), Decl(source.js, 59, 6)) + + return this.storage[1]; +>this : Symbol(__object, Decl(source.js, 46, 19)) + + }, + /** + * @param {number} y + */ + set y(y) { +>y : Symbol(Point2D.y, Decl(source.js, 42, 15), Decl(source.js, 56, 6), Decl(source.js, 59, 6)) +>y : Symbol(y, Decl(source.js, 63, 10)) + + this.storage[1] = y; +>this : Symbol(__object, Decl(source.js, 46, 19)) +>y : Symbol(y, Decl(source.js, 63, 10)) + } +}; + +=== tests/cases/conformance/jsdoc/declarations/referencer.js === +import {Point2D} from "./source"; +>Point2D : Symbol(Point2D, Decl(referencer.js, 0, 8)) + +export const origin = new Point2D(0, 0); +>origin : Symbol(origin, Decl(referencer.js, 2, 12)) +>Point2D : Symbol(Point2D, Decl(referencer.js, 0, 8)) + +// export const res = Point2D(2, 3).dot(origin); // TODO: when __proto__ works, validate this + diff --git a/tests/baselines/reference/jsDeclarationsFunctionLikeClasses2.types b/tests/baselines/reference/jsDeclarationsFunctionLikeClasses2.types new file mode 100644 index 0000000000000..3e94d055ee249 --- /dev/null +++ b/tests/baselines/reference/jsDeclarationsFunctionLikeClasses2.types @@ -0,0 +1,257 @@ +=== tests/cases/conformance/jsdoc/declarations/source.js === +/** + * @param {number} len + */ +export function Vec(len) { +>Vec : typeof Vec +>len : number + + /** + * @type {number[]} + */ + this.storage = new Array(len); +>this.storage = new Array(len) : any[] +>this.storage : any +>this : any +>storage : any +>new Array(len) : any[] +>Array : ArrayConstructor +>len : number +} + +Vec.prototype = { +>Vec.prototype = { /** * @param {Vec} other */ dot(other) { if (other.storage.length !== this.storage.length) { throw new Error(`Dot product only applicable for vectors of equal length`); } let sum = 0; for (let i = 0; i < this.storage.length; i++) { sum += (this.storage[i] * other.storage[i]); } return sum; }, magnitude() { let sum = 0; for (let i = 0; i < this.storage.length; i++) { sum += (this.storage[i] ** 2); } return Math.sqrt(sum); }} : { dot(other: Vec): number; magnitude(): number; } +>Vec.prototype : { dot(other: Vec): number; magnitude(): number; } +>Vec : typeof Vec +>prototype : { dot(other: Vec): number; magnitude(): number; } +>{ /** * @param {Vec} other */ dot(other) { if (other.storage.length !== this.storage.length) { throw new Error(`Dot product only applicable for vectors of equal length`); } let sum = 0; for (let i = 0; i < this.storage.length; i++) { sum += (this.storage[i] * other.storage[i]); } return sum; }, magnitude() { let sum = 0; for (let i = 0; i < this.storage.length; i++) { sum += (this.storage[i] ** 2); } return Math.sqrt(sum); }} : { dot(other: Vec): number; magnitude(): number; } + + /** + * @param {Vec} other + */ + dot(other) { +>dot : (other: Vec) => number +>other : Vec + + if (other.storage.length !== this.storage.length) { +>other.storage.length !== this.storage.length : boolean +>other.storage.length : number +>other.storage : number[] +>other : Vec +>storage : number[] +>length : number +>this.storage.length : number +>this.storage : number[] +>this : this +>storage : number[] +>length : number + + throw new Error(`Dot product only applicable for vectors of equal length`); +>new Error(`Dot product only applicable for vectors of equal length`) : Error +>Error : ErrorConstructor +>`Dot product only applicable for vectors of equal length` : "Dot product only applicable for vectors of equal length" + } + let sum = 0; +>sum : number +>0 : 0 + + for (let i = 0; i < this.storage.length; i++) { +>i : number +>0 : 0 +>i < this.storage.length : boolean +>i : number +>this.storage.length : number +>this.storage : number[] +>this : this +>storage : number[] +>length : number +>i++ : number +>i : number + + sum += (this.storage[i] * other.storage[i]); +>sum += (this.storage[i] * other.storage[i]) : number +>sum : number +>(this.storage[i] * other.storage[i]) : number +>this.storage[i] * other.storage[i] : number +>this.storage[i] : number +>this.storage : number[] +>this : this +>storage : number[] +>i : number +>other.storage[i] : number +>other.storage : number[] +>other : Vec +>storage : number[] +>i : number + } + return sum; +>sum : number + + }, + magnitude() { +>magnitude : () => number + + let sum = 0; +>sum : number +>0 : 0 + + for (let i = 0; i < this.storage.length; i++) { +>i : number +>0 : 0 +>i < this.storage.length : boolean +>i : number +>this.storage.length : number +>this.storage : number[] +>this : this +>storage : number[] +>length : number +>i++ : number +>i : number + + sum += (this.storage[i] ** 2); +>sum += (this.storage[i] ** 2) : number +>sum : number +>(this.storage[i] ** 2) : number +>this.storage[i] ** 2 : number +>this.storage[i] : number +>this.storage : number[] +>this : this +>storage : number[] +>i : number +>2 : 2 + } + return Math.sqrt(sum); +>Math.sqrt(sum) : number +>Math.sqrt : (x: number) => number +>Math : Math +>sqrt : (x: number) => number +>sum : number + } +} + +/** + * @param {number} x + * @param {number} y + */ +export function Point2D(x, y) { +>Point2D : typeof Point2D +>x : number +>y : number + + if (!(this instanceof Point2D)) { +>!(this instanceof Point2D) : boolean +>(this instanceof Point2D) : boolean +>this instanceof Point2D : boolean +>this : any +>Point2D : typeof Point2D + + return new Point2D(x, y); +>new Point2D(x, y) : Point2D +>Point2D : typeof Point2D +>x : number +>y : number + } + Vec.call(this, 2); +>Vec.call(this, 2) : any +>Vec.call : (this: Function, thisArg: any, ...argArray: any[]) => any +>Vec : typeof Vec +>call : (this: Function, thisArg: any, ...argArray: any[]) => any +>this : any +>2 : 2 + + this.x = x; +>this.x = x : number +>this.x : any +>this : any +>x : any +>x : number + + this.y = y; +>this.y = y : number +>this.y : any +>this : any +>y : any +>y : number +} + +Point2D.prototype = { +>Point2D.prototype = { __proto__: Vec, get x() { return this.storage[0]; }, /** * @param {number} x */ set x(x) { this.storage[0] = x; }, get y() { return this.storage[1]; }, /** * @param {number} y */ set y(y) { this.storage[1] = y; }} : { __proto__: typeof Vec; x: number; y: number; } +>Point2D.prototype : { __proto__: typeof Vec; x: number; y: number; } +>Point2D : typeof Point2D +>prototype : { __proto__: typeof Vec; x: number; y: number; } +>{ __proto__: Vec, get x() { return this.storage[0]; }, /** * @param {number} x */ set x(x) { this.storage[0] = x; }, get y() { return this.storage[1]; }, /** * @param {number} y */ set y(y) { this.storage[1] = y; }} : { __proto__: typeof Vec; x: number; y: number; } + + __proto__: Vec, +>__proto__ : typeof Vec +>Vec : typeof Vec + + get x() { +>x : number + + return this.storage[0]; +>this.storage[0] : any +>this.storage : any +>this : { __proto__: typeof Vec; x: number; y: number; } +>storage : any +>0 : 0 + + }, + /** + * @param {number} x + */ + set x(x) { +>x : number +>x : number + + this.storage[0] = x; +>this.storage[0] = x : number +>this.storage[0] : any +>this.storage : any +>this : { __proto__: typeof Vec; x: number; y: number; } +>storage : any +>0 : 0 +>x : number + + }, + get y() { +>y : number + + return this.storage[1]; +>this.storage[1] : any +>this.storage : any +>this : { __proto__: typeof Vec; x: number; y: number; } +>storage : any +>1 : 1 + + }, + /** + * @param {number} y + */ + set y(y) { +>y : number +>y : number + + this.storage[1] = y; +>this.storage[1] = y : number +>this.storage[1] : any +>this.storage : any +>this : { __proto__: typeof Vec; x: number; y: number; } +>storage : any +>1 : 1 +>y : number + } +}; + +=== tests/cases/conformance/jsdoc/declarations/referencer.js === +import {Point2D} from "./source"; +>Point2D : typeof Point2D + +export const origin = new Point2D(0, 0); +>origin : Point2D +>new Point2D(0, 0) : Point2D +>Point2D : typeof Point2D +>0 : 0 +>0 : 0 + +// export const res = Point2D(2, 3).dot(origin); // TODO: when __proto__ works, validate this + diff --git a/tests/baselines/reference/jsDeclarationsFunctions.js b/tests/baselines/reference/jsDeclarationsFunctions.js new file mode 100644 index 0000000000000..c80fe43a1d2d4 --- /dev/null +++ b/tests/baselines/reference/jsDeclarationsFunctions.js @@ -0,0 +1,177 @@ +//// [index.js] +export function a() {} + +export function b() {} +b.cat = "cat"; + +export function c() {} +c.Cls = class {} + +/** + * @param {number} a + * @param {number} b + * @return {string} + */ +export function d(a, b) { return /** @type {*} */(null); } + +/** + * @template T,U + * @param {T} a + * @param {U} b + * @return {T & U} + */ +export function e(a, b) { return /** @type {*} */(null); } + +/** + * @template T + * @param {T} a + */ +export function f(a) { + return a; +} +f.self = f; + +/** + * @param {{x: string}} a + * @param {{y: typeof b}} b + */ +function g(a, b) { + return a.x && b.y(); +} + +export { g }; + +/** + * @param {{x: string}} a + * @param {{y: typeof b}} b + */ +function hh(a, b) { + return a.x && b.y(); +} + +export { hh as h }; + +export function i() {} +export { i as ii }; + +export { j as jj }; +export function j() {} + + +//// [index.js] +"use strict"; +exports.__esModule = true; +function a() { } +exports.a = a; +function b() { } +exports.b = b; +b.cat = "cat"; +function c() { } +exports.c = c; +c.Cls = /** @class */ (function () { + function Cls() { + } + return Cls; +}()); +/** + * @param {number} a + * @param {number} b + * @return {string} + */ +function d(a, b) { return /** @type {*} */ (null); } +exports.d = d; +/** + * @template T,U + * @param {T} a + * @param {U} b + * @return {T & U} + */ +function e(a, b) { return /** @type {*} */ (null); } +exports.e = e; +/** + * @template T + * @param {T} a + */ +function f(a) { + return a; +} +exports.f = f; +f.self = f; +/** + * @param {{x: string}} a + * @param {{y: typeof b}} b + */ +function g(a, b) { + return a.x && b.y(); +} +exports.g = g; +/** + * @param {{x: string}} a + * @param {{y: typeof b}} b + */ +function hh(a, b) { + return a.x && b.y(); +} +exports.h = hh; +function i() { } +exports.i = i; +exports.ii = i; +function j() { } +exports.j = j; +exports.jj = j; + + +//// [index.d.ts] +export function a(): void; +export function b(): void; +export namespace b { + export const cat: string; +} +export function c(): void; +export namespace c { + export { Cls }; + class Cls { + } +} +/** + * @param {number} a + * @param {number} b + * @return {string} + */ +export function d(a: number, b: number): string; +/** + * @template T,U + * @param {T} a + * @param {U} b + * @return {T & U} + */ +export function e(a: T, b: U): T & U; +/** + * @template T + * @param {T} a + */ +export function f(a: T): T; +export namespace f { + export { f as self }; +} +export function i(): void; +export function j(): void; +/** + * @param {{x: string}} a + * @param {{y: typeof b}} b + */ +export function g(a: { + x: string; +}, b: { + y: typeof b; +}): void; +/** + * @param {{x: string}} a + * @param {{y: typeof b}} b + */ +declare function hh(a: { + x: string; +}, b: { + y: typeof b; +}): void; +export { hh as h, i as ii, j as jj }; diff --git a/tests/baselines/reference/jsDeclarationsFunctions.symbols b/tests/baselines/reference/jsDeclarationsFunctions.symbols new file mode 100644 index 0000000000000..0f2a41a6222d8 --- /dev/null +++ b/tests/baselines/reference/jsDeclarationsFunctions.symbols @@ -0,0 +1,115 @@ +=== tests/cases/conformance/jsdoc/declarations/index.js === +export function a() {} +>a : Symbol(a, Decl(index.js, 0, 0)) + +export function b() {} +>b : Symbol(b, Decl(index.js, 0, 22), Decl(index.js, 2, 22)) + +b.cat = "cat"; +>b.cat : Symbol(b.cat, Decl(index.js, 2, 22)) +>b : Symbol(b, Decl(index.js, 0, 22), Decl(index.js, 2, 22)) +>cat : Symbol(b.cat, Decl(index.js, 2, 22)) + +export function c() {} +>c : Symbol(c, Decl(index.js, 3, 14), Decl(index.js, 5, 22)) + +c.Cls = class {} +>c.Cls : Symbol(c.Cls, Decl(index.js, 5, 22)) +>c : Symbol(c, Decl(index.js, 3, 14), Decl(index.js, 5, 22)) +>Cls : Symbol(c.Cls, Decl(index.js, 5, 22)) + +/** + * @param {number} a + * @param {number} b + * @return {string} + */ +export function d(a, b) { return /** @type {*} */(null); } +>d : Symbol(d, Decl(index.js, 6, 16)) +>a : Symbol(a, Decl(index.js, 13, 18)) +>b : Symbol(b, Decl(index.js, 13, 20)) + +/** + * @template T,U + * @param {T} a + * @param {U} b + * @return {T & U} + */ +export function e(a, b) { return /** @type {*} */(null); } +>e : Symbol(e, Decl(index.js, 13, 58)) +>a : Symbol(a, Decl(index.js, 21, 18)) +>b : Symbol(b, Decl(index.js, 21, 20)) + +/** + * @template T + * @param {T} a + */ +export function f(a) { +>f : Symbol(f, Decl(index.js, 21, 58), Decl(index.js, 29, 1)) +>a : Symbol(a, Decl(index.js, 27, 18)) + + return a; +>a : Symbol(a, Decl(index.js, 27, 18)) +} +f.self = f; +>f.self : Symbol(f.self, Decl(index.js, 29, 1)) +>f : Symbol(f, Decl(index.js, 21, 58), Decl(index.js, 29, 1)) +>self : Symbol(f.self, Decl(index.js, 29, 1)) +>f : Symbol(f, Decl(index.js, 21, 58), Decl(index.js, 29, 1)) + +/** + * @param {{x: string}} a + * @param {{y: typeof b}} b + */ +function g(a, b) { +>g : Symbol(g, Decl(index.js, 30, 11)) +>a : Symbol(a, Decl(index.js, 36, 11)) +>b : Symbol(b, Decl(index.js, 36, 13)) + + return a.x && b.y(); +>a.x : Symbol(x, Decl(index.js, 33, 12)) +>a : Symbol(a, Decl(index.js, 36, 11)) +>x : Symbol(x, Decl(index.js, 33, 12)) +>b.y : Symbol(y, Decl(index.js, 34, 12)) +>b : Symbol(b, Decl(index.js, 36, 13)) +>y : Symbol(y, Decl(index.js, 34, 12)) +} + +export { g }; +>g : Symbol(g, Decl(index.js, 40, 8)) + +/** + * @param {{x: string}} a + * @param {{y: typeof b}} b + */ +function hh(a, b) { +>hh : Symbol(hh, Decl(index.js, 40, 13)) +>a : Symbol(a, Decl(index.js, 46, 12)) +>b : Symbol(b, Decl(index.js, 46, 14)) + + return a.x && b.y(); +>a.x : Symbol(x, Decl(index.js, 43, 12)) +>a : Symbol(a, Decl(index.js, 46, 12)) +>x : Symbol(x, Decl(index.js, 43, 12)) +>b.y : Symbol(y, Decl(index.js, 44, 12)) +>b : Symbol(b, Decl(index.js, 46, 14)) +>y : Symbol(y, Decl(index.js, 44, 12)) +} + +export { hh as h }; +>hh : Symbol(hh, Decl(index.js, 40, 13)) +>h : Symbol(h, Decl(index.js, 50, 8)) + +export function i() {} +>i : Symbol(i, Decl(index.js, 50, 19)) + +export { i as ii }; +>i : Symbol(i, Decl(index.js, 50, 19)) +>ii : Symbol(ii, Decl(index.js, 53, 8)) + +export { j as jj }; +>j : Symbol(j, Decl(index.js, 55, 19)) +>jj : Symbol(jj, Decl(index.js, 55, 8)) + +export function j() {} +>j : Symbol(j, Decl(index.js, 55, 19)) + diff --git a/tests/baselines/reference/jsDeclarationsFunctions.types b/tests/baselines/reference/jsDeclarationsFunctions.types new file mode 100644 index 0000000000000..72d67885c2d61 --- /dev/null +++ b/tests/baselines/reference/jsDeclarationsFunctions.types @@ -0,0 +1,128 @@ +=== tests/cases/conformance/jsdoc/declarations/index.js === +export function a() {} +>a : () => void + +export function b() {} +>b : typeof b + +b.cat = "cat"; +>b.cat = "cat" : "cat" +>b.cat : string +>b : typeof b +>cat : string +>"cat" : "cat" + +export function c() {} +>c : typeof c + +c.Cls = class {} +>c.Cls = class {} : typeof Cls +>c.Cls : typeof Cls +>c : typeof c +>Cls : typeof Cls +>class {} : typeof Cls + +/** + * @param {number} a + * @param {number} b + * @return {string} + */ +export function d(a, b) { return /** @type {*} */(null); } +>d : (a: number, b: number) => string +>a : number +>b : number +>(null) : any +>null : null + +/** + * @template T,U + * @param {T} a + * @param {U} b + * @return {T & U} + */ +export function e(a, b) { return /** @type {*} */(null); } +>e : (a: T, b: U) => T & U +>a : T +>b : U +>(null) : any +>null : null + +/** + * @template T + * @param {T} a + */ +export function f(a) { +>f : typeof f +>a : T + + return a; +>a : T +} +f.self = f; +>f.self = f : typeof f +>f.self : typeof f +>f : typeof f +>self : typeof f +>f : typeof f + +/** + * @param {{x: string}} a + * @param {{y: typeof b}} b + */ +function g(a, b) { +>g : (a: { x: string; }, b: { y: typeof import("tests/cases/conformance/jsdoc/declarations/index").b; }) => void +>a : { x: string; } +>b : { y: typeof import("tests/cases/conformance/jsdoc/declarations/index").b; } + + return a.x && b.y(); +>a.x && b.y() : void +>a.x : string +>a : { x: string; } +>x : string +>b.y() : void +>b.y : typeof import("tests/cases/conformance/jsdoc/declarations/index").b +>b : { y: typeof import("tests/cases/conformance/jsdoc/declarations/index").b; } +>y : typeof import("tests/cases/conformance/jsdoc/declarations/index").b +} + +export { g }; +>g : (a: { x: string; }, b: { y: typeof b; }) => void + +/** + * @param {{x: string}} a + * @param {{y: typeof b}} b + */ +function hh(a, b) { +>hh : (a: { x: string; }, b: { y: typeof import("tests/cases/conformance/jsdoc/declarations/index").b; }) => void +>a : { x: string; } +>b : { y: typeof import("tests/cases/conformance/jsdoc/declarations/index").b; } + + return a.x && b.y(); +>a.x && b.y() : void +>a.x : string +>a : { x: string; } +>x : string +>b.y() : void +>b.y : typeof import("tests/cases/conformance/jsdoc/declarations/index").b +>b : { y: typeof import("tests/cases/conformance/jsdoc/declarations/index").b; } +>y : typeof import("tests/cases/conformance/jsdoc/declarations/index").b +} + +export { hh as h }; +>hh : (a: { x: string; }, b: { y: typeof b; }) => void +>h : (a: { x: string; }, b: { y: typeof b; }) => void + +export function i() {} +>i : () => void + +export { i as ii }; +>i : () => void +>ii : () => void + +export { j as jj }; +>j : () => void +>jj : () => void + +export function j() {} +>j : () => void + diff --git a/tests/baselines/reference/jsDeclarationsFunctionsCjs.js b/tests/baselines/reference/jsDeclarationsFunctionsCjs.js new file mode 100644 index 0000000000000..6e80a0b4b17c6 --- /dev/null +++ b/tests/baselines/reference/jsDeclarationsFunctionsCjs.js @@ -0,0 +1,161 @@ +//// [index.js] +module.exports.a = function a() {} + +module.exports.b = function b() {} +module.exports.b.cat = "cat"; + +module.exports.c = function c() {} +module.exports.c.Cls = class {} + +/** + * @param {number} a + * @param {number} b + * @return {string} + */ +module.exports.d = function d(a, b) { return /** @type {*} */(null); } + +/** + * @template T,U + * @param {T} a + * @param {U} b + * @return {T & U} + */ +module.exports.e = function e(a, b) { return /** @type {*} */(null); } + +/** + * @template T + * @param {T} a + */ +module.exports.f = function f(a) { + return a; +} +module.exports.f.self = module.exports.f; + +/** + * @param {{x: string}} a + * @param {{y: typeof module.exports.b}} b + */ +function g(a, b) { + return a.x && b.y(); +} + +module.exports.g = g; + +/** + * @param {{x: string}} a + * @param {{y: typeof module.exports.b}} b + */ +function hh(a, b) { + return a.x && b.y(); +} + +module.exports.h = hh; + +module.exports.i = function i() {} +module.exports.ii = module.exports.i; + +// note that this last one doesn't make much sense in cjs, since exports aren't hoisted bindings +module.exports.jj = module.exports.j; +module.exports.j = function j() {} + + +//// [index.js] +module.exports.a = function a() { }; +module.exports.b = function b() { }; +module.exports.b.cat = "cat"; +module.exports.c = function c() { }; +module.exports.c.Cls = /** @class */ (function () { + function Cls() { + } + return Cls; +}()); +/** + * @param {number} a + * @param {number} b + * @return {string} + */ +module.exports.d = function d(a, b) { return /** @type {*} */ (null); }; +/** + * @template T,U + * @param {T} a + * @param {U} b + * @return {T & U} + */ +module.exports.e = function e(a, b) { return /** @type {*} */ (null); }; +/** + * @template T + * @param {T} a + */ +module.exports.f = function f(a) { + return a; +}; +module.exports.f.self = module.exports.f; +/** + * @param {{x: string}} a + * @param {{y: typeof module.exports.b}} b + */ +function g(a, b) { + return a.x && b.y(); +} +module.exports.g = g; +/** + * @param {{x: string}} a + * @param {{y: typeof module.exports.b}} b + */ +function hh(a, b) { + return a.x && b.y(); +} +module.exports.h = hh; +module.exports.i = function i() { }; +module.exports.ii = module.exports.i; +// note that this last one doesn't make much sense in cjs, since exports aren't hoisted bindings +module.exports.jj = module.exports.j; +module.exports.j = function j() { }; + + +//// [index.d.ts] +export function a(): void; +export function b(): void; +export namespace b { + export const cat: string; +} +export function c(): void; +export namespace c { + class Cls { + } +} +export function d(a: number, b: number): string; +export function e(a: T, b: U): T & U; +export function f(a: T): T; +export namespace f { + import self = f; + export { self }; +} +/** + * @param {{x: string}} a + * @param {{y: typeof module.exports.b}} b + */ +export function g(a: { + x: string; +}, b: { + y: { + (): void; + cat: string; + }; +}): void; +/** + * @param {{x: string}} a + * @param {{y: typeof module.exports.b}} b + */ +export function h(a: { + x: string; +}, b: { + y: { + (): void; + cat: string; + }; +}): void; +export function i(): void; +export function ii(): void; +export function jj(): void; +export function j(): void; diff --git a/tests/baselines/reference/jsDeclarationsFunctionsCjs.symbols b/tests/baselines/reference/jsDeclarationsFunctionsCjs.symbols new file mode 100644 index 0000000000000..b900de3c1f076 --- /dev/null +++ b/tests/baselines/reference/jsDeclarationsFunctionsCjs.symbols @@ -0,0 +1,197 @@ +=== tests/cases/conformance/jsdoc/declarations/index.js === +module.exports.a = function a() {} +>module.exports.a : Symbol(a, Decl(index.js, 0, 0)) +>module.exports : Symbol(a, Decl(index.js, 0, 0)) +>module : Symbol(module, Decl(index.js, 0, 0)) +>exports : Symbol("tests/cases/conformance/jsdoc/declarations/index", Decl(index.js, 0, 0)) +>a : Symbol(a, Decl(index.js, 0, 0)) +>a : Symbol(a, Decl(index.js, 0, 18)) + +module.exports.b = function b() {} +>module.exports.b : Symbol(b, Decl(index.js, 0, 34), Decl(index.js, 3, 15)) +>module.exports : Symbol(b, Decl(index.js, 0, 34), Decl(index.js, 3, 15)) +>module : Symbol(module, Decl(index.js, 0, 0)) +>exports : Symbol("tests/cases/conformance/jsdoc/declarations/index", Decl(index.js, 0, 0)) +>b : Symbol(b, Decl(index.js, 0, 34), Decl(index.js, 3, 15)) +>b : Symbol(b, Decl(index.js, 2, 18)) + +module.exports.b.cat = "cat"; +>module.exports.b.cat : Symbol(b.cat, Decl(index.js, 2, 34)) +>module.exports.b : Symbol(b.cat, Decl(index.js, 2, 34)) +>module.exports : Symbol("tests/cases/conformance/jsdoc/declarations/index", Decl(index.js, 0, 0)) +>module : Symbol(module, Decl(index.js, 0, 0)) +>exports : Symbol("tests/cases/conformance/jsdoc/declarations/index", Decl(index.js, 0, 0)) +>b : Symbol(b, Decl(index.js, 0, 34), Decl(index.js, 3, 15)) +>cat : Symbol(b.cat, Decl(index.js, 2, 34)) + +module.exports.c = function c() {} +>module.exports.c : Symbol(c, Decl(index.js, 3, 29), Decl(index.js, 6, 15)) +>module.exports : Symbol(c, Decl(index.js, 3, 29), Decl(index.js, 6, 15)) +>module : Symbol(module, Decl(index.js, 0, 0)) +>exports : Symbol("tests/cases/conformance/jsdoc/declarations/index", Decl(index.js, 0, 0)) +>c : Symbol(c, Decl(index.js, 3, 29), Decl(index.js, 6, 15)) +>c : Symbol(c, Decl(index.js, 5, 18)) + +module.exports.c.Cls = class {} +>module.exports.c.Cls : Symbol(c.Cls, Decl(index.js, 5, 34)) +>module.exports.c : Symbol(c.Cls, Decl(index.js, 5, 34)) +>module.exports : Symbol("tests/cases/conformance/jsdoc/declarations/index", Decl(index.js, 0, 0)) +>module : Symbol(module, Decl(index.js, 0, 0)) +>exports : Symbol("tests/cases/conformance/jsdoc/declarations/index", Decl(index.js, 0, 0)) +>c : Symbol(c, Decl(index.js, 3, 29), Decl(index.js, 6, 15)) +>Cls : Symbol(c.Cls, Decl(index.js, 5, 34)) + +/** + * @param {number} a + * @param {number} b + * @return {string} + */ +module.exports.d = function d(a, b) { return /** @type {*} */(null); } +>module.exports.d : Symbol(d, Decl(index.js, 6, 31)) +>module.exports : Symbol(d, Decl(index.js, 6, 31)) +>module : Symbol(module, Decl(index.js, 0, 0)) +>exports : Symbol("tests/cases/conformance/jsdoc/declarations/index", Decl(index.js, 0, 0)) +>d : Symbol(d, Decl(index.js, 6, 31)) +>d : Symbol(d, Decl(index.js, 13, 18)) +>a : Symbol(a, Decl(index.js, 13, 30)) +>b : Symbol(b, Decl(index.js, 13, 32)) + +/** + * @template T,U + * @param {T} a + * @param {U} b + * @return {T & U} + */ +module.exports.e = function e(a, b) { return /** @type {*} */(null); } +>module.exports.e : Symbol(e, Decl(index.js, 13, 70)) +>module.exports : Symbol(e, Decl(index.js, 13, 70)) +>module : Symbol(module, Decl(index.js, 0, 0)) +>exports : Symbol("tests/cases/conformance/jsdoc/declarations/index", Decl(index.js, 0, 0)) +>e : Symbol(e, Decl(index.js, 13, 70)) +>e : Symbol(e, Decl(index.js, 21, 18)) +>a : Symbol(a, Decl(index.js, 21, 30)) +>b : Symbol(b, Decl(index.js, 21, 32)) + +/** + * @template T + * @param {T} a + */ +module.exports.f = function f(a) { +>module.exports.f : Symbol(f, Decl(index.js, 21, 70), Decl(index.js, 30, 15)) +>module.exports : Symbol(f, Decl(index.js, 21, 70), Decl(index.js, 30, 15)) +>module : Symbol(module, Decl(index.js, 0, 0)) +>exports : Symbol("tests/cases/conformance/jsdoc/declarations/index", Decl(index.js, 0, 0)) +>f : Symbol(f, Decl(index.js, 21, 70), Decl(index.js, 30, 15)) +>f : Symbol(f, Decl(index.js, 27, 18)) +>a : Symbol(a, Decl(index.js, 27, 30)) + + return a; +>a : Symbol(a, Decl(index.js, 27, 30)) +} +module.exports.f.self = module.exports.f; +>module.exports.f.self : Symbol(f.self, Decl(index.js, 29, 1)) +>module.exports.f : Symbol(f.self, Decl(index.js, 29, 1)) +>module.exports : Symbol("tests/cases/conformance/jsdoc/declarations/index", Decl(index.js, 0, 0)) +>module : Symbol(module, Decl(index.js, 0, 0)) +>exports : Symbol("tests/cases/conformance/jsdoc/declarations/index", Decl(index.js, 0, 0)) +>f : Symbol(f, Decl(index.js, 21, 70), Decl(index.js, 30, 15)) +>self : Symbol(f.self, Decl(index.js, 29, 1)) +>module.exports.f : Symbol(f, Decl(index.js, 21, 70), Decl(index.js, 30, 15)) +>module.exports : Symbol("tests/cases/conformance/jsdoc/declarations/index", Decl(index.js, 0, 0)) +>module : Symbol(module, Decl(index.js, 0, 0)) +>exports : Symbol("tests/cases/conformance/jsdoc/declarations/index", Decl(index.js, 0, 0)) +>f : Symbol(f, Decl(index.js, 21, 70), Decl(index.js, 30, 15)) + +/** + * @param {{x: string}} a + * @param {{y: typeof module.exports.b}} b + */ +function g(a, b) { +>g : Symbol(g, Decl(index.js, 30, 41)) +>a : Symbol(a, Decl(index.js, 36, 11)) +>b : Symbol(b, Decl(index.js, 36, 13)) + + return a.x && b.y(); +>a.x : Symbol(x, Decl(index.js, 33, 12)) +>a : Symbol(a, Decl(index.js, 36, 11)) +>x : Symbol(x, Decl(index.js, 33, 12)) +>b.y : Symbol(y, Decl(index.js, 34, 12)) +>b : Symbol(b, Decl(index.js, 36, 13)) +>y : Symbol(y, Decl(index.js, 34, 12)) +} + +module.exports.g = g; +>module.exports.g : Symbol(g, Decl(index.js, 38, 1)) +>module.exports : Symbol(g, Decl(index.js, 38, 1)) +>module : Symbol(module, Decl(index.js, 0, 0)) +>exports : Symbol("tests/cases/conformance/jsdoc/declarations/index", Decl(index.js, 0, 0)) +>g : Symbol(g, Decl(index.js, 38, 1)) +>g : Symbol(g, Decl(index.js, 30, 41)) + +/** + * @param {{x: string}} a + * @param {{y: typeof module.exports.b}} b + */ +function hh(a, b) { +>hh : Symbol(hh, Decl(index.js, 40, 21)) +>a : Symbol(a, Decl(index.js, 46, 12)) +>b : Symbol(b, Decl(index.js, 46, 14)) + + return a.x && b.y(); +>a.x : Symbol(x, Decl(index.js, 43, 12)) +>a : Symbol(a, Decl(index.js, 46, 12)) +>x : Symbol(x, Decl(index.js, 43, 12)) +>b.y : Symbol(y, Decl(index.js, 44, 12)) +>b : Symbol(b, Decl(index.js, 46, 14)) +>y : Symbol(y, Decl(index.js, 44, 12)) +} + +module.exports.h = hh; +>module.exports.h : Symbol(h, Decl(index.js, 48, 1)) +>module.exports : Symbol(h, Decl(index.js, 48, 1)) +>module : Symbol(module, Decl(index.js, 0, 0)) +>exports : Symbol("tests/cases/conformance/jsdoc/declarations/index", Decl(index.js, 0, 0)) +>h : Symbol(h, Decl(index.js, 48, 1)) +>hh : Symbol(hh, Decl(index.js, 40, 21)) + +module.exports.i = function i() {} +>module.exports.i : Symbol(i, Decl(index.js, 50, 22)) +>module.exports : Symbol(i, Decl(index.js, 50, 22)) +>module : Symbol(module, Decl(index.js, 0, 0)) +>exports : Symbol("tests/cases/conformance/jsdoc/declarations/index", Decl(index.js, 0, 0)) +>i : Symbol(i, Decl(index.js, 50, 22)) +>i : Symbol(i, Decl(index.js, 52, 18)) + +module.exports.ii = module.exports.i; +>module.exports.ii : Symbol(ii, Decl(index.js, 52, 34)) +>module.exports : Symbol(ii, Decl(index.js, 52, 34)) +>module : Symbol(module, Decl(index.js, 0, 0)) +>exports : Symbol("tests/cases/conformance/jsdoc/declarations/index", Decl(index.js, 0, 0)) +>ii : Symbol(ii, Decl(index.js, 52, 34)) +>module.exports.i : Symbol(i, Decl(index.js, 50, 22)) +>module.exports : Symbol("tests/cases/conformance/jsdoc/declarations/index", Decl(index.js, 0, 0)) +>module : Symbol(module, Decl(index.js, 0, 0)) +>exports : Symbol("tests/cases/conformance/jsdoc/declarations/index", Decl(index.js, 0, 0)) +>i : Symbol(i, Decl(index.js, 50, 22)) + +// note that this last one doesn't make much sense in cjs, since exports aren't hoisted bindings +module.exports.jj = module.exports.j; +>module.exports.jj : Symbol(jj, Decl(index.js, 53, 37)) +>module.exports : Symbol(jj, Decl(index.js, 53, 37)) +>module : Symbol(module, Decl(index.js, 0, 0)) +>exports : Symbol("tests/cases/conformance/jsdoc/declarations/index", Decl(index.js, 0, 0)) +>jj : Symbol(jj, Decl(index.js, 53, 37)) +>module.exports.j : Symbol(j, Decl(index.js, 56, 37)) +>module.exports : Symbol("tests/cases/conformance/jsdoc/declarations/index", Decl(index.js, 0, 0)) +>module : Symbol(module, Decl(index.js, 0, 0)) +>exports : Symbol("tests/cases/conformance/jsdoc/declarations/index", Decl(index.js, 0, 0)) +>j : Symbol(j, Decl(index.js, 56, 37)) + +module.exports.j = function j() {} +>module.exports.j : Symbol(j, Decl(index.js, 56, 37)) +>module.exports : Symbol(j, Decl(index.js, 56, 37)) +>module : Symbol(module, Decl(index.js, 0, 0)) +>exports : Symbol("tests/cases/conformance/jsdoc/declarations/index", Decl(index.js, 0, 0)) +>j : Symbol(j, Decl(index.js, 56, 37)) +>j : Symbol(j, Decl(index.js, 57, 18)) + diff --git a/tests/baselines/reference/jsDeclarationsFunctionsCjs.types b/tests/baselines/reference/jsDeclarationsFunctionsCjs.types new file mode 100644 index 0000000000000..ec6843764ff39 --- /dev/null +++ b/tests/baselines/reference/jsDeclarationsFunctionsCjs.types @@ -0,0 +1,230 @@ +=== tests/cases/conformance/jsdoc/declarations/index.js === +module.exports.a = function a() {} +>module.exports.a = function a() {} : () => void +>module.exports.a : () => void +>module.exports : typeof import("tests/cases/conformance/jsdoc/declarations/index") +>module : { "tests/cases/conformance/jsdoc/declarations/index": typeof import("tests/cases/conformance/jsdoc/declarations/index"); } +>exports : typeof import("tests/cases/conformance/jsdoc/declarations/index") +>a : () => void +>function a() {} : () => void +>a : () => void + +module.exports.b = function b() {} +>module.exports.b = function b() {} : { (): void; cat: string; } +>module.exports.b : { (): void; cat: string; } +>module.exports : typeof import("tests/cases/conformance/jsdoc/declarations/index") +>module : { "tests/cases/conformance/jsdoc/declarations/index": typeof import("tests/cases/conformance/jsdoc/declarations/index"); } +>exports : typeof import("tests/cases/conformance/jsdoc/declarations/index") +>b : { (): void; cat: string; } +>function b() {} : { (): void; cat: string; } +>b : { (): void; cat: string; } + +module.exports.b.cat = "cat"; +>module.exports.b.cat = "cat" : "cat" +>module.exports.b.cat : string +>module.exports.b : { (): void; cat: string; } +>module.exports : typeof import("tests/cases/conformance/jsdoc/declarations/index") +>module : { "tests/cases/conformance/jsdoc/declarations/index": typeof import("tests/cases/conformance/jsdoc/declarations/index"); } +>exports : typeof import("tests/cases/conformance/jsdoc/declarations/index") +>b : { (): void; cat: string; } +>cat : string +>"cat" : "cat" + +module.exports.c = function c() {} +>module.exports.c = function c() {} : { (): void; Cls: typeof Cls; } +>module.exports.c : { (): void; Cls: typeof Cls; } +>module.exports : typeof import("tests/cases/conformance/jsdoc/declarations/index") +>module : { "tests/cases/conformance/jsdoc/declarations/index": typeof import("tests/cases/conformance/jsdoc/declarations/index"); } +>exports : typeof import("tests/cases/conformance/jsdoc/declarations/index") +>c : { (): void; Cls: typeof Cls; } +>function c() {} : { (): void; Cls: typeof Cls; } +>c : { (): void; Cls: typeof Cls; } + +module.exports.c.Cls = class {} +>module.exports.c.Cls = class {} : typeof Cls +>module.exports.c.Cls : typeof Cls +>module.exports.c : { (): void; Cls: typeof Cls; } +>module.exports : typeof import("tests/cases/conformance/jsdoc/declarations/index") +>module : { "tests/cases/conformance/jsdoc/declarations/index": typeof import("tests/cases/conformance/jsdoc/declarations/index"); } +>exports : typeof import("tests/cases/conformance/jsdoc/declarations/index") +>c : { (): void; Cls: typeof Cls; } +>Cls : typeof Cls +>class {} : typeof Cls + +/** + * @param {number} a + * @param {number} b + * @return {string} + */ +module.exports.d = function d(a, b) { return /** @type {*} */(null); } +>module.exports.d = function d(a, b) { return /** @type {*} */(null); } : (a: number, b: number) => string +>module.exports.d : (a: number, b: number) => string +>module.exports : typeof import("tests/cases/conformance/jsdoc/declarations/index") +>module : { "tests/cases/conformance/jsdoc/declarations/index": typeof import("tests/cases/conformance/jsdoc/declarations/index"); } +>exports : typeof import("tests/cases/conformance/jsdoc/declarations/index") +>d : (a: number, b: number) => string +>function d(a, b) { return /** @type {*} */(null); } : (a: number, b: number) => string +>d : (a: number, b: number) => string +>a : number +>b : number +>(null) : any +>null : null + +/** + * @template T,U + * @param {T} a + * @param {U} b + * @return {T & U} + */ +module.exports.e = function e(a, b) { return /** @type {*} */(null); } +>module.exports.e = function e(a, b) { return /** @type {*} */(null); } : (a: T, b: U) => T & U +>module.exports.e : (a: T, b: U) => T & U +>module.exports : typeof import("tests/cases/conformance/jsdoc/declarations/index") +>module : { "tests/cases/conformance/jsdoc/declarations/index": typeof import("tests/cases/conformance/jsdoc/declarations/index"); } +>exports : typeof import("tests/cases/conformance/jsdoc/declarations/index") +>e : (a: T, b: U) => T & U +>function e(a, b) { return /** @type {*} */(null); } : (a: T, b: U) => T & U +>e : (a: T, b: U) => T & U +>a : T +>b : U +>(null) : any +>null : null + +/** + * @template T + * @param {T} a + */ +module.exports.f = function f(a) { +>module.exports.f = function f(a) { return a;} : { (a: T): T; self: any; } +>module.exports.f : { (a: T): T; self: any; } +>module.exports : typeof import("tests/cases/conformance/jsdoc/declarations/index") +>module : { "tests/cases/conformance/jsdoc/declarations/index": typeof import("tests/cases/conformance/jsdoc/declarations/index"); } +>exports : typeof import("tests/cases/conformance/jsdoc/declarations/index") +>f : { (a: T): T; self: any; } +>function f(a) { return a;} : { (a: T): T; self: any; } +>f : { (a: T): T; self: any; } +>a : T + + return a; +>a : T +} +module.exports.f.self = module.exports.f; +>module.exports.f.self = module.exports.f : { (a: T): T; self: any; } +>module.exports.f.self : { (a: T): T; self: any; } +>module.exports.f : { (a: T): T; self: any; } +>module.exports : typeof import("tests/cases/conformance/jsdoc/declarations/index") +>module : { "tests/cases/conformance/jsdoc/declarations/index": typeof import("tests/cases/conformance/jsdoc/declarations/index"); } +>exports : typeof import("tests/cases/conformance/jsdoc/declarations/index") +>f : { (a: T): T; self: any; } +>self : { (a: T): T; self: any; } +>module.exports.f : { (a: T): T; self: any; } +>module.exports : typeof import("tests/cases/conformance/jsdoc/declarations/index") +>module : { "tests/cases/conformance/jsdoc/declarations/index": typeof import("tests/cases/conformance/jsdoc/declarations/index"); } +>exports : typeof import("tests/cases/conformance/jsdoc/declarations/index") +>f : { (a: T): T; self: any; } + +/** + * @param {{x: string}} a + * @param {{y: typeof module.exports.b}} b + */ +function g(a, b) { +>g : (a: { x: string; }, b: { y: { (): void; cat: string; }; }) => void +>a : { x: string; } +>b : { y: { (): void; cat: string; }; } + + return a.x && b.y(); +>a.x && b.y() : void +>a.x : string +>a : { x: string; } +>x : string +>b.y() : void +>b.y : { (): void; cat: string; } +>b : { y: { (): void; cat: string; }; } +>y : { (): void; cat: string; } +} + +module.exports.g = g; +>module.exports.g = g : (a: { x: string; }, b: { y: { (): void; cat: string; }; }) => void +>module.exports.g : (a: { x: string; }, b: { y: { (): void; cat: string; }; }) => void +>module.exports : typeof import("tests/cases/conformance/jsdoc/declarations/index") +>module : { "tests/cases/conformance/jsdoc/declarations/index": typeof import("tests/cases/conformance/jsdoc/declarations/index"); } +>exports : typeof import("tests/cases/conformance/jsdoc/declarations/index") +>g : (a: { x: string; }, b: { y: { (): void; cat: string; }; }) => void +>g : (a: { x: string; }, b: { y: { (): void; cat: string; }; }) => void + +/** + * @param {{x: string}} a + * @param {{y: typeof module.exports.b}} b + */ +function hh(a, b) { +>hh : (a: { x: string; }, b: { y: { (): void; cat: string; }; }) => void +>a : { x: string; } +>b : { y: { (): void; cat: string; }; } + + return a.x && b.y(); +>a.x && b.y() : void +>a.x : string +>a : { x: string; } +>x : string +>b.y() : void +>b.y : { (): void; cat: string; } +>b : { y: { (): void; cat: string; }; } +>y : { (): void; cat: string; } +} + +module.exports.h = hh; +>module.exports.h = hh : (a: { x: string; }, b: { y: { (): void; cat: string; }; }) => void +>module.exports.h : (a: { x: string; }, b: { y: { (): void; cat: string; }; }) => void +>module.exports : typeof import("tests/cases/conformance/jsdoc/declarations/index") +>module : { "tests/cases/conformance/jsdoc/declarations/index": typeof import("tests/cases/conformance/jsdoc/declarations/index"); } +>exports : typeof import("tests/cases/conformance/jsdoc/declarations/index") +>h : (a: { x: string; }, b: { y: { (): void; cat: string; }; }) => void +>hh : (a: { x: string; }, b: { y: { (): void; cat: string; }; }) => void + +module.exports.i = function i() {} +>module.exports.i = function i() {} : () => void +>module.exports.i : () => void +>module.exports : typeof import("tests/cases/conformance/jsdoc/declarations/index") +>module : { "tests/cases/conformance/jsdoc/declarations/index": typeof import("tests/cases/conformance/jsdoc/declarations/index"); } +>exports : typeof import("tests/cases/conformance/jsdoc/declarations/index") +>i : () => void +>function i() {} : () => void +>i : () => void + +module.exports.ii = module.exports.i; +>module.exports.ii = module.exports.i : () => void +>module.exports.ii : () => void +>module.exports : typeof import("tests/cases/conformance/jsdoc/declarations/index") +>module : { "tests/cases/conformance/jsdoc/declarations/index": typeof import("tests/cases/conformance/jsdoc/declarations/index"); } +>exports : typeof import("tests/cases/conformance/jsdoc/declarations/index") +>ii : () => void +>module.exports.i : () => void +>module.exports : typeof import("tests/cases/conformance/jsdoc/declarations/index") +>module : { "tests/cases/conformance/jsdoc/declarations/index": typeof import("tests/cases/conformance/jsdoc/declarations/index"); } +>exports : typeof import("tests/cases/conformance/jsdoc/declarations/index") +>i : () => void + +// note that this last one doesn't make much sense in cjs, since exports aren't hoisted bindings +module.exports.jj = module.exports.j; +>module.exports.jj = module.exports.j : () => void +>module.exports.jj : () => void +>module.exports : typeof import("tests/cases/conformance/jsdoc/declarations/index") +>module : { "tests/cases/conformance/jsdoc/declarations/index": typeof import("tests/cases/conformance/jsdoc/declarations/index"); } +>exports : typeof import("tests/cases/conformance/jsdoc/declarations/index") +>jj : () => void +>module.exports.j : () => void +>module.exports : typeof import("tests/cases/conformance/jsdoc/declarations/index") +>module : { "tests/cases/conformance/jsdoc/declarations/index": typeof import("tests/cases/conformance/jsdoc/declarations/index"); } +>exports : typeof import("tests/cases/conformance/jsdoc/declarations/index") +>j : () => void + +module.exports.j = function j() {} +>module.exports.j = function j() {} : () => void +>module.exports.j : () => void +>module.exports : typeof import("tests/cases/conformance/jsdoc/declarations/index") +>module : { "tests/cases/conformance/jsdoc/declarations/index": typeof import("tests/cases/conformance/jsdoc/declarations/index"); } +>exports : typeof import("tests/cases/conformance/jsdoc/declarations/index") +>j : () => void +>function j() {} : () => void +>j : () => void + diff --git a/tests/baselines/reference/jsDeclarationsImportTypeBundled.js b/tests/baselines/reference/jsDeclarationsImportTypeBundled.js new file mode 100644 index 0000000000000..13d62d4e18337 --- /dev/null +++ b/tests/baselines/reference/jsDeclarationsImportTypeBundled.js @@ -0,0 +1,52 @@ +//// [tests/cases/conformance/jsdoc/declarations/jsDeclarationsImportTypeBundled.ts] //// + +//// [mod1.js] +/** + * @typedef {{x: number}} Item + */ +/** + * @type {Item}; + */ +const x = {x: 12}; +module.exports = x; +//// [index.js] +/** @type {(typeof import("./folder/mod1"))[]} */ +const items = [{x: 12}]; +module.exports = items; + +//// [out.js] +/** + * @typedef {{x: number}} Item + */ +/** + * @type {Item}; + */ +var x = { x: 12 }; +module.exports = x; +/** @type {(typeof import("./folder/mod1"))[]} */ +var items = [{ x: 12 }]; +module.exports = items; + + +//// [out.d.ts] +declare module "folder/mod1" { + export = x; + /** + * @typedef {{x: number}} Item + */ + /** + * @type {Item}; + */ + const x: Item; + namespace x { + export { Item }; + } + type Item = { + x: number; + }; +} +declare module "index" { + export = items; + /** @type {(typeof import("./folder/mod1"))[]} */ + const items: (typeof import("folder/mod1"))[]; +} diff --git a/tests/baselines/reference/jsDeclarationsImportTypeBundled.symbols b/tests/baselines/reference/jsDeclarationsImportTypeBundled.symbols new file mode 100644 index 0000000000000..7cf1f7a1b236c --- /dev/null +++ b/tests/baselines/reference/jsDeclarationsImportTypeBundled.symbols @@ -0,0 +1,29 @@ +=== tests/cases/conformance/jsdoc/declarations/folder/mod1.js === +/** + * @typedef {{x: number}} Item + */ +/** + * @type {Item}; + */ +const x = {x: 12}; +>x : Symbol(x, Decl(mod1.js, 6, 5)) +>x : Symbol(x, Decl(mod1.js, 6, 11)) + +module.exports = x; +>module.exports : Symbol("tests/cases/conformance/jsdoc/declarations/folder/mod1", Decl(mod1.js, 0, 0)) +>module : Symbol(export=, Decl(mod1.js, 6, 18)) +>exports : Symbol(export=, Decl(mod1.js, 6, 18)) +>x : Symbol(x, Decl(mod1.js, 6, 5)) + +=== tests/cases/conformance/jsdoc/declarations/index.js === +/** @type {(typeof import("./folder/mod1"))[]} */ +const items = [{x: 12}]; +>items : Symbol(items, Decl(index.js, 1, 5)) +>x : Symbol(x, Decl(index.js, 1, 16)) + +module.exports = items; +>module.exports : Symbol("tests/cases/conformance/jsdoc/declarations/index", Decl(index.js, 0, 0)) +>module : Symbol(export=, Decl(index.js, 1, 24)) +>exports : Symbol(export=, Decl(index.js, 1, 24)) +>items : Symbol(items, Decl(index.js, 1, 5)) + diff --git a/tests/baselines/reference/jsDeclarationsImportTypeBundled.types b/tests/baselines/reference/jsDeclarationsImportTypeBundled.types new file mode 100644 index 0000000000000..8236fa5d9184d --- /dev/null +++ b/tests/baselines/reference/jsDeclarationsImportTypeBundled.types @@ -0,0 +1,36 @@ +=== tests/cases/conformance/jsdoc/declarations/folder/mod1.js === +/** + * @typedef {{x: number}} Item + */ +/** + * @type {Item}; + */ +const x = {x: 12}; +>x : { x: number; } +>{x: 12} : { x: number; } +>x : number +>12 : 12 + +module.exports = x; +>module.exports = x : { x: number; } +>module.exports : { x: number; } +>module : { "tests/cases/conformance/jsdoc/declarations/folder/mod1": { x: number; }; } +>exports : { x: number; } +>x : { x: number; } + +=== tests/cases/conformance/jsdoc/declarations/index.js === +/** @type {(typeof import("./folder/mod1"))[]} */ +const items = [{x: 12}]; +>items : { x: number; }[] +>[{x: 12}] : { x: number; }[] +>{x: 12} : { x: number; } +>x : number +>12 : 12 + +module.exports = items; +>module.exports = items : { [n: number]: { x: number; }; length: number; toString(): string; toLocaleString(): string; pop(): { x: number; }; push(...items: { x: number; }[]): number; concat(...items: ConcatArray<{ x: number; }>[]): { x: number; }[]; concat(...items: ({ x: number; } | ConcatArray<{ x: number; }>)[]): { x: number; }[]; join(separator?: string): string; reverse(): { x: number; }[]; shift(): { x: number; }; slice(start?: number, end?: number): { x: number; }[]; sort(compareFn?: (a: { x: number; }, b: { x: number; }) => number): { x: number; }[]; splice(start: number, deleteCount?: number): { x: number; }[]; splice(start: number, deleteCount: number, ...items: { x: number; }[]): { x: number; }[]; unshift(...items: { x: number; }[]): number; indexOf(searchElement: { x: number; }, fromIndex?: number): number; lastIndexOf(searchElement: { x: number; }, fromIndex?: number): number; every(callbackfn: (value: { x: number; }, index: number, array: { x: number; }[]) => unknown, thisArg?: any): boolean; some(callbackfn: (value: { x: number; }, index: number, array: { x: number; }[]) => unknown, thisArg?: any): boolean; forEach(callbackfn: (value: { x: number; }, index: number, array: { x: number; }[]) => void, thisArg?: any): void; map(callbackfn: (value: { x: number; }, index: number, array: { x: number; }[]) => U, thisArg?: any): U[]; filter(callbackfn: (value: { x: number; }, index: number, array: { x: number; }[]) => value is S, thisArg?: any): S[]; filter(callbackfn: (value: { x: number; }, index: number, array: { x: number; }[]) => unknown, thisArg?: any): { x: number; }[]; reduce(callbackfn: (previousValue: { x: number; }, currentValue: { x: number; }, currentIndex: number, array: { x: number; }[]) => { x: number; }): { x: number; }; reduce(callbackfn: (previousValue: { x: number; }, currentValue: { x: number; }, currentIndex: number, array: { x: number; }[]) => { x: number; }, initialValue: { x: number; }): { x: number; }; reduce(callbackfn: (previousValue: U, currentValue: { x: number; }, currentIndex: number, array: { x: number; }[]) => U, initialValue: U): U; reduceRight(callbackfn: (previousValue: { x: number; }, currentValue: { x: number; }, currentIndex: number, array: { x: number; }[]) => { x: number; }): { x: number; }; reduceRight(callbackfn: (previousValue: { x: number; }, currentValue: { x: number; }, currentIndex: number, array: { x: number; }[]) => { x: number; }, initialValue: { x: number; }): { x: number; }; reduceRight(callbackfn: (previousValue: U, currentValue: { x: number; }, currentIndex: number, array: { x: number; }[]) => U, initialValue: U): U; } +>module.exports : { [n: number]: { x: number; }; length: number; toString(): string; toLocaleString(): string; pop(): { x: number; }; push(...items: { x: number; }[]): number; concat(...items: ConcatArray<{ x: number; }>[]): { x: number; }[]; concat(...items: ({ x: number; } | ConcatArray<{ x: number; }>)[]): { x: number; }[]; join(separator?: string): string; reverse(): { x: number; }[]; shift(): { x: number; }; slice(start?: number, end?: number): { x: number; }[]; sort(compareFn?: (a: { x: number; }, b: { x: number; }) => number): { x: number; }[]; splice(start: number, deleteCount?: number): { x: number; }[]; splice(start: number, deleteCount: number, ...items: { x: number; }[]): { x: number; }[]; unshift(...items: { x: number; }[]): number; indexOf(searchElement: { x: number; }, fromIndex?: number): number; lastIndexOf(searchElement: { x: number; }, fromIndex?: number): number; every(callbackfn: (value: { x: number; }, index: number, array: { x: number; }[]) => unknown, thisArg?: any): boolean; some(callbackfn: (value: { x: number; }, index: number, array: { x: number; }[]) => unknown, thisArg?: any): boolean; forEach(callbackfn: (value: { x: number; }, index: number, array: { x: number; }[]) => void, thisArg?: any): void; map(callbackfn: (value: { x: number; }, index: number, array: { x: number; }[]) => U, thisArg?: any): U[]; filter(callbackfn: (value: { x: number; }, index: number, array: { x: number; }[]) => value is S, thisArg?: any): S[]; filter(callbackfn: (value: { x: number; }, index: number, array: { x: number; }[]) => unknown, thisArg?: any): { x: number; }[]; reduce(callbackfn: (previousValue: { x: number; }, currentValue: { x: number; }, currentIndex: number, array: { x: number; }[]) => { x: number; }): { x: number; }; reduce(callbackfn: (previousValue: { x: number; }, currentValue: { x: number; }, currentIndex: number, array: { x: number; }[]) => { x: number; }, initialValue: { x: number; }): { x: number; }; reduce(callbackfn: (previousValue: U, currentValue: { x: number; }, currentIndex: number, array: { x: number; }[]) => U, initialValue: U): U; reduceRight(callbackfn: (previousValue: { x: number; }, currentValue: { x: number; }, currentIndex: number, array: { x: number; }[]) => { x: number; }): { x: number; }; reduceRight(callbackfn: (previousValue: { x: number; }, currentValue: { x: number; }, currentIndex: number, array: { x: number; }[]) => { x: number; }, initialValue: { x: number; }): { x: number; }; reduceRight(callbackfn: (previousValue: U, currentValue: { x: number; }, currentIndex: number, array: { x: number; }[]) => U, initialValue: U): U; } +>module : { "tests/cases/conformance/jsdoc/declarations/index": { [n: number]: { x: number; }; length: number; toString(): string; toLocaleString(): string; pop(): { x: number; }; push(...items: { x: number; }[]): number; concat(...items: ConcatArray<{ x: number; }>[]): { x: number; }[]; concat(...items: ({ x: number; } | ConcatArray<{ x: number; }>)[]): { x: number; }[]; join(separator?: string): string; reverse(): { x: number; }[]; shift(): { x: number; }; slice(start?: number, end?: number): { x: number; }[]; sort(compareFn?: (a: { x: number; }, b: { x: number; }) => number): { x: number; }[]; splice(start: number, deleteCount?: number): { x: number; }[]; splice(start: number, deleteCount: number, ...items: { x: number; }[]): { x: number; }[]; unshift(...items: { x: number; }[]): number; indexOf(searchElement: { x: number; }, fromIndex?: number): number; lastIndexOf(searchElement: { x: number; }, fromIndex?: number): number; every(callbackfn: (value: { x: number; }, index: number, array: { x: number; }[]) => unknown, thisArg?: any): boolean; some(callbackfn: (value: { x: number; }, index: number, array: { x: number; }[]) => unknown, thisArg?: any): boolean; forEach(callbackfn: (value: { x: number; }, index: number, array: { x: number; }[]) => void, thisArg?: any): void; map(callbackfn: (value: { x: number; }, index: number, array: { x: number; }[]) => U, thisArg?: any): U[]; filter(callbackfn: (value: { x: number; }, index: number, array: { x: number; }[]) => value is S, thisArg?: any): S[]; filter(callbackfn: (value: { x: number; }, index: number, array: { x: number; }[]) => unknown, thisArg?: any): { x: number; }[]; reduce(callbackfn: (previousValue: { x: number; }, currentValue: { x: number; }, currentIndex: number, array: { x: number; }[]) => { x: number; }): { x: number; }; reduce(callbackfn: (previousValue: { x: number; }, currentValue: { x: number; }, currentIndex: number, array: { x: number; }[]) => { x: number; }, initialValue: { x: number; }): { x: number; }; reduce(callbackfn: (previousValue: U, currentValue: { x: number; }, currentIndex: number, array: { x: number; }[]) => U, initialValue: U): U; reduceRight(callbackfn: (previousValue: { x: number; }, currentValue: { x: number; }, currentIndex: number, array: { x: number; }[]) => { x: number; }): { x: number; }; reduceRight(callbackfn: (previousValue: { x: number; }, currentValue: { x: number; }, currentIndex: number, array: { x: number; }[]) => { x: number; }, initialValue: { x: number; }): { x: number; }; reduceRight(callbackfn: (previousValue: U, currentValue: { x: number; }, currentIndex: number, array: { x: number; }[]) => U, initialValue: U): U; }; } +>exports : { [n: number]: { x: number; }; length: number; toString(): string; toLocaleString(): string; pop(): { x: number; }; push(...items: { x: number; }[]): number; concat(...items: ConcatArray<{ x: number; }>[]): { x: number; }[]; concat(...items: ({ x: number; } | ConcatArray<{ x: number; }>)[]): { x: number; }[]; join(separator?: string): string; reverse(): { x: number; }[]; shift(): { x: number; }; slice(start?: number, end?: number): { x: number; }[]; sort(compareFn?: (a: { x: number; }, b: { x: number; }) => number): { x: number; }[]; splice(start: number, deleteCount?: number): { x: number; }[]; splice(start: number, deleteCount: number, ...items: { x: number; }[]): { x: number; }[]; unshift(...items: { x: number; }[]): number; indexOf(searchElement: { x: number; }, fromIndex?: number): number; lastIndexOf(searchElement: { x: number; }, fromIndex?: number): number; every(callbackfn: (value: { x: number; }, index: number, array: { x: number; }[]) => unknown, thisArg?: any): boolean; some(callbackfn: (value: { x: number; }, index: number, array: { x: number; }[]) => unknown, thisArg?: any): boolean; forEach(callbackfn: (value: { x: number; }, index: number, array: { x: number; }[]) => void, thisArg?: any): void; map(callbackfn: (value: { x: number; }, index: number, array: { x: number; }[]) => U, thisArg?: any): U[]; filter(callbackfn: (value: { x: number; }, index: number, array: { x: number; }[]) => value is S, thisArg?: any): S[]; filter(callbackfn: (value: { x: number; }, index: number, array: { x: number; }[]) => unknown, thisArg?: any): { x: number; }[]; reduce(callbackfn: (previousValue: { x: number; }, currentValue: { x: number; }, currentIndex: number, array: { x: number; }[]) => { x: number; }): { x: number; }; reduce(callbackfn: (previousValue: { x: number; }, currentValue: { x: number; }, currentIndex: number, array: { x: number; }[]) => { x: number; }, initialValue: { x: number; }): { x: number; }; reduce(callbackfn: (previousValue: U, currentValue: { x: number; }, currentIndex: number, array: { x: number; }[]) => U, initialValue: U): U; reduceRight(callbackfn: (previousValue: { x: number; }, currentValue: { x: number; }, currentIndex: number, array: { x: number; }[]) => { x: number; }): { x: number; }; reduceRight(callbackfn: (previousValue: { x: number; }, currentValue: { x: number; }, currentIndex: number, array: { x: number; }[]) => { x: number; }, initialValue: { x: number; }): { x: number; }; reduceRight(callbackfn: (previousValue: U, currentValue: { x: number; }, currentIndex: number, array: { x: number; }[]) => U, initialValue: U): U; } +>items : { x: number; }[] + diff --git a/tests/baselines/reference/jsDeclarationsInterfaces.errors.txt b/tests/baselines/reference/jsDeclarationsInterfaces.errors.txt new file mode 100644 index 0000000000000..24ed71af90837 --- /dev/null +++ b/tests/baselines/reference/jsDeclarationsInterfaces.errors.txt @@ -0,0 +1,200 @@ +tests/cases/conformance/jsdoc/declarations/index.js(4,18): error TS8006: 'interface declarations' can only be used in a .ts file. +tests/cases/conformance/jsdoc/declarations/index.js(6,18): error TS8006: 'interface declarations' can only be used in a .ts file. +tests/cases/conformance/jsdoc/declarations/index.js(10,18): error TS8006: 'interface declarations' can only be used in a .ts file. +tests/cases/conformance/jsdoc/declarations/index.js(31,11): error TS8006: 'interface declarations' can only be used in a .ts file. +tests/cases/conformance/jsdoc/declarations/index.js(35,11): error TS8006: 'interface declarations' can only be used in a .ts file. +tests/cases/conformance/jsdoc/declarations/index.js(39,18): error TS8006: 'interface declarations' can only be used in a .ts file. +tests/cases/conformance/jsdoc/declarations/index.js(43,18): error TS8006: 'interface declarations' can only be used in a .ts file. +tests/cases/conformance/jsdoc/declarations/index.js(45,18): error TS8006: 'interface declarations' can only be used in a .ts file. +tests/cases/conformance/jsdoc/declarations/index.js(49,18): error TS8006: 'interface declarations' can only be used in a .ts file. +tests/cases/conformance/jsdoc/declarations/index.js(53,18): error TS8006: 'interface declarations' can only be used in a .ts file. +tests/cases/conformance/jsdoc/declarations/index.js(57,18): error TS8006: 'interface declarations' can only be used in a .ts file. +tests/cases/conformance/jsdoc/declarations/index.js(61,18): error TS8006: 'interface declarations' can only be used in a .ts file. +tests/cases/conformance/jsdoc/declarations/index.js(65,18): error TS8006: 'interface declarations' can only be used in a .ts file. +tests/cases/conformance/jsdoc/declarations/index.js(67,18): error TS8006: 'interface declarations' can only be used in a .ts file. +tests/cases/conformance/jsdoc/declarations/index.js(71,18): error TS8006: 'interface declarations' can only be used in a .ts file. +tests/cases/conformance/jsdoc/declarations/index.js(75,18): error TS8006: 'interface declarations' can only be used in a .ts file. +tests/cases/conformance/jsdoc/declarations/index.js(80,18): error TS8006: 'interface declarations' can only be used in a .ts file. +tests/cases/conformance/jsdoc/declarations/index.js(84,18): error TS8006: 'interface declarations' can only be used in a .ts file. +tests/cases/conformance/jsdoc/declarations/index.js(87,18): error TS8006: 'interface declarations' can only be used in a .ts file. +tests/cases/conformance/jsdoc/declarations/index.js(91,18): error TS8006: 'interface declarations' can only be used in a .ts file. +tests/cases/conformance/jsdoc/declarations/index.js(95,18): error TS8006: 'interface declarations' can only be used in a .ts file. +tests/cases/conformance/jsdoc/declarations/index.js(100,18): error TS8006: 'interface declarations' can only be used in a .ts file. +tests/cases/conformance/jsdoc/declarations/index.js(105,18): error TS8006: 'interface declarations' can only be used in a .ts file. +tests/cases/conformance/jsdoc/declarations/index.js(107,18): error TS8006: 'interface declarations' can only be used in a .ts file. +tests/cases/conformance/jsdoc/declarations/index.js(111,18): error TS8006: 'interface declarations' can only be used in a .ts file. +tests/cases/conformance/jsdoc/declarations/index.js(115,18): error TS8006: 'interface declarations' can only be used in a .ts file. + + +==== tests/cases/conformance/jsdoc/declarations/index.js (26 errors) ==== + // Pretty much all of this should be an error, (since interfaces are forbidden in js), + // but we should be able to synthesize declarations from the symbols regardless + + export interface A {} + ~ +!!! error TS8006: 'interface declarations' can only be used in a .ts file. + + export interface B { + ~ +!!! error TS8006: 'interface declarations' can only be used in a .ts file. + cat: string; + } + + export interface C { + ~ +!!! error TS8006: 'interface declarations' can only be used in a .ts file. + field: T & U; + optionalField?: T; + readonly readonlyField: T & U; + readonly readonlyOptionalField?: U; + (): number; + (x: T): U; + (x: Q): T & Q; + + new (): string; + new (x: T): U; + new (x: Q): T & Q; + + method(): number; + method(a: T & Q): Q & number; + method(a?: number): number; + method(...args: any[]): number; + + optMethod?(): number; + } + + interface G {} + ~ +!!! error TS8006: 'interface declarations' can only be used in a .ts file. + + export { G }; + + interface HH {} + ~~ +!!! error TS8006: 'interface declarations' can only be used in a .ts file. + + export { HH as H }; + + export interface I {} + ~ +!!! error TS8006: 'interface declarations' can only be used in a .ts file. + export { I as II }; + + export { J as JJ }; + export interface J {} + ~ +!!! error TS8006: 'interface declarations' can only be used in a .ts file. + + export interface K extends I,J { + ~ +!!! error TS8006: 'interface declarations' can only be used in a .ts file. + x: string; + } + + export interface L extends K { + ~ +!!! error TS8006: 'interface declarations' can only be used in a .ts file. + y: string; + } + + export interface M { + ~ +!!! error TS8006: 'interface declarations' can only be used in a .ts file. + field: T; + } + + export interface N extends M { + ~ +!!! error TS8006: 'interface declarations' can only be used in a .ts file. + other: U; + } + + export interface O { + ~ +!!! error TS8006: 'interface declarations' can only be used in a .ts file. + [idx: string]: string; + } + + export interface P extends O {} + ~ +!!! error TS8006: 'interface declarations' can only be used in a .ts file. + + export interface Q extends O { + ~ +!!! error TS8006: 'interface declarations' can only be used in a .ts file. + [idx: string]: "ok"; + } + + export interface R extends O { + ~ +!!! error TS8006: 'interface declarations' can only be used in a .ts file. + [idx: number]: "ok"; + } + + export interface S extends O { + ~ +!!! error TS8006: 'interface declarations' can only be used in a .ts file. + [idx: string]: "ok"; + [idx: number]: never; + } + + export interface T { + ~ +!!! error TS8006: 'interface declarations' can only be used in a .ts file. + [idx: number]: string; + } + + export interface U extends T {} + ~ +!!! error TS8006: 'interface declarations' can only be used in a .ts file. + + + export interface V extends T { + ~ +!!! error TS8006: 'interface declarations' can only be used in a .ts file. + [idx: string]: string; + } + + export interface W extends T { + ~ +!!! error TS8006: 'interface declarations' can only be used in a .ts file. + [idx: number]: "ok"; + } + + export interface X extends T { + ~ +!!! error TS8006: 'interface declarations' can only be used in a .ts file. + [idx: string]: string; + [idx: number]: "ok"; + } + + export interface Y { + ~ +!!! error TS8006: 'interface declarations' can only be used in a .ts file. + [idx: string]: {x: number}; + [idx: number]: {x: number, y: number}; + } + + export interface Z extends Y {} + ~ +!!! error TS8006: 'interface declarations' can only be used in a .ts file. + + export interface AA extends Y { + ~~ +!!! error TS8006: 'interface declarations' can only be used in a .ts file. + [idx: string]: {x: number, y: number}; + } + + export interface BB extends Y { + ~~ +!!! error TS8006: 'interface declarations' can only be used in a .ts file. + [idx: number]: {x: 0, y: 0}; + } + + export interface CC extends Y { + ~~ +!!! error TS8006: 'interface declarations' can only be used in a .ts file. + [idx: string]: {x: number, y: number}; + [idx: number]: {x: 0, y: 0}; + } + \ No newline at end of file diff --git a/tests/baselines/reference/jsDeclarationsInterfaces.js b/tests/baselines/reference/jsDeclarationsInterfaces.js new file mode 100644 index 0000000000000..00e78c8286a88 --- /dev/null +++ b/tests/baselines/reference/jsDeclarationsInterfaces.js @@ -0,0 +1,235 @@ +//// [index.js] +// Pretty much all of this should be an error, (since interfaces are forbidden in js), +// but we should be able to synthesize declarations from the symbols regardless + +export interface A {} + +export interface B { + cat: string; +} + +export interface C { + field: T & U; + optionalField?: T; + readonly readonlyField: T & U; + readonly readonlyOptionalField?: U; + (): number; + (x: T): U; + (x: Q): T & Q; + + new (): string; + new (x: T): U; + new (x: Q): T & Q; + + method(): number; + method(a: T & Q): Q & number; + method(a?: number): number; + method(...args: any[]): number; + + optMethod?(): number; +} + +interface G {} + +export { G }; + +interface HH {} + +export { HH as H }; + +export interface I {} +export { I as II }; + +export { J as JJ }; +export interface J {} + +export interface K extends I,J { + x: string; +} + +export interface L extends K { + y: string; +} + +export interface M { + field: T; +} + +export interface N extends M { + other: U; +} + +export interface O { + [idx: string]: string; +} + +export interface P extends O {} + +export interface Q extends O { + [idx: string]: "ok"; +} + +export interface R extends O { + [idx: number]: "ok"; +} + +export interface S extends O { + [idx: string]: "ok"; + [idx: number]: never; +} + +export interface T { + [idx: number]: string; +} + +export interface U extends T {} + + +export interface V extends T { + [idx: string]: string; +} + +export interface W extends T { + [idx: number]: "ok"; +} + +export interface X extends T { + [idx: string]: string; + [idx: number]: "ok"; +} + +export interface Y { + [idx: string]: {x: number}; + [idx: number]: {x: number, y: number}; +} + +export interface Z extends Y {} + +export interface AA extends Y { + [idx: string]: {x: number, y: number}; +} + +export interface BB extends Y { + [idx: number]: {x: 0, y: 0}; +} + +export interface CC extends Y { + [idx: string]: {x: number, y: number}; + [idx: number]: {x: 0, y: 0}; +} + + +//// [index.js] +"use strict"; +// Pretty much all of this should be an error, (since interfaces are forbidden in js), +// but we should be able to synthesize declarations from the symbols regardless +Object.defineProperty(exports, "__esModule", { value: true }); + + +//// [index.d.ts] +export interface A { +} +export interface B { + cat: string; +} +export interface C { + new (): string; + new (x: T_1): U_1; + new (x: Q_4): T_1 & Q_4; + (): number; + (x: T_1): U_1; + (x: Q_3): T_1 & Q_3; + field: T_1 & U_1; + optionalField?: T_1; + readonly readonlyField: T_1 & U_1; + readonly readonlyOptionalField?: U_1; + method(): number; + method(a: T_1 & Q_2): Q_2 & number; + method(a?: number): number; + method(...args: any[]): number; + optMethod?(): number; +} +export interface I { +} +export interface J { +} +export interface K extends I, J { + x: string; +} +export interface L extends K { + y: string; +} +export interface M { + field: T_1; +} +export interface N extends M { + other: U_1; +} +export interface O { + [idx: string]: string; +} +export interface P extends O { +} +export interface Q extends O { + [idx: string]: "ok"; +} +export interface R extends O { + [idx: number]: "ok"; +} +export interface S extends O { + [idx: string]: "ok"; + [idx: number]: never; +} +export interface T { + [idx: number]: string; +} +export interface U extends T { +} +export interface V extends T { + [idx: string]: string; +} +export interface W extends T { + [idx: number]: "ok"; +} +export interface X extends T { + [idx: string]: string; + [idx: number]: "ok"; +} +export interface Y { + [idx: string]: { + x: number; + }; + [idx: number]: { + x: number; + y: number; + }; +} +export interface Z extends Y { +} +export interface AA extends Y { + [idx: string]: { + x: number; + y: number; + }; +} +export interface BB extends Y { + [idx: number]: { + x: 0; + y: 0; + }; +} +export interface CC extends Y { + [idx: string]: { + x: number; + y: number; + }; + [idx: number]: { + x: 0; + y: 0; + }; +} +export interface G { +} +interface HH { +} +export { HH as H, I as II, J as JJ }; diff --git a/tests/baselines/reference/jsDeclarationsInterfaces.symbols b/tests/baselines/reference/jsDeclarationsInterfaces.symbols new file mode 100644 index 0000000000000..d042802f42229 --- /dev/null +++ b/tests/baselines/reference/jsDeclarationsInterfaces.symbols @@ -0,0 +1,280 @@ +=== tests/cases/conformance/jsdoc/declarations/index.js === +// Pretty much all of this should be an error, (since interfaces are forbidden in js), +// but we should be able to synthesize declarations from the symbols regardless + +export interface A {} +>A : Symbol(A, Decl(index.js, 0, 0)) + +export interface B { +>B : Symbol(B, Decl(index.js, 3, 21)) + + cat: string; +>cat : Symbol(B.cat, Decl(index.js, 5, 20)) +} + +export interface C { +>C : Symbol(C, Decl(index.js, 7, 1)) +>T : Symbol(T, Decl(index.js, 9, 19)) +>U : Symbol(U, Decl(index.js, 9, 21)) + + field: T & U; +>field : Symbol(C.field, Decl(index.js, 9, 26)) +>T : Symbol(T, Decl(index.js, 9, 19)) +>U : Symbol(U, Decl(index.js, 9, 21)) + + optionalField?: T; +>optionalField : Symbol(C.optionalField, Decl(index.js, 10, 17)) +>T : Symbol(T, Decl(index.js, 9, 19)) + + readonly readonlyField: T & U; +>readonlyField : Symbol(C.readonlyField, Decl(index.js, 11, 22)) +>T : Symbol(T, Decl(index.js, 9, 19)) +>U : Symbol(U, Decl(index.js, 9, 21)) + + readonly readonlyOptionalField?: U; +>readonlyOptionalField : Symbol(C.readonlyOptionalField, Decl(index.js, 12, 34)) +>U : Symbol(U, Decl(index.js, 9, 21)) + + (): number; + (x: T): U; +>x : Symbol(x, Decl(index.js, 15, 5)) +>T : Symbol(T, Decl(index.js, 9, 19)) +>U : Symbol(U, Decl(index.js, 9, 21)) + + (x: Q): T & Q; +>Q : Symbol(Q, Decl(index.js, 16, 5)) +>x : Symbol(x, Decl(index.js, 16, 8)) +>Q : Symbol(Q, Decl(index.js, 16, 5)) +>T : Symbol(T, Decl(index.js, 9, 19)) +>Q : Symbol(Q, Decl(index.js, 16, 5)) + + new (): string; + new (x: T): U; +>x : Symbol(x, Decl(index.js, 19, 9)) +>T : Symbol(T, Decl(index.js, 9, 19)) +>U : Symbol(U, Decl(index.js, 9, 21)) + + new (x: Q): T & Q; +>Q : Symbol(Q, Decl(index.js, 20, 9)) +>x : Symbol(x, Decl(index.js, 20, 12)) +>Q : Symbol(Q, Decl(index.js, 20, 9)) +>T : Symbol(T, Decl(index.js, 9, 19)) +>Q : Symbol(Q, Decl(index.js, 20, 9)) + + method(): number; +>method : Symbol(C.method, Decl(index.js, 20, 25), Decl(index.js, 22, 33), Decl(index.js, 23, 36), Decl(index.js, 24, 31)) +>Q : Symbol(Q, Decl(index.js, 22, 11)) + + method(a: T & Q): Q & number; +>method : Symbol(C.method, Decl(index.js, 20, 25), Decl(index.js, 22, 33), Decl(index.js, 23, 36), Decl(index.js, 24, 31)) +>Q : Symbol(Q, Decl(index.js, 23, 11)) +>a : Symbol(a, Decl(index.js, 23, 14)) +>T : Symbol(T, Decl(index.js, 9, 19)) +>Q : Symbol(Q, Decl(index.js, 23, 11)) +>Q : Symbol(Q, Decl(index.js, 23, 11)) + + method(a?: number): number; +>method : Symbol(C.method, Decl(index.js, 20, 25), Decl(index.js, 22, 33), Decl(index.js, 23, 36), Decl(index.js, 24, 31)) +>a : Symbol(a, Decl(index.js, 24, 11)) + + method(...args: any[]): number; +>method : Symbol(C.method, Decl(index.js, 20, 25), Decl(index.js, 22, 33), Decl(index.js, 23, 36), Decl(index.js, 24, 31)) +>args : Symbol(args, Decl(index.js, 25, 11)) + + optMethod?(): number; +>optMethod : Symbol(C.optMethod, Decl(index.js, 25, 35)) +} + +interface G {} +>G : Symbol(G, Decl(index.js, 28, 1)) + +export { G }; +>G : Symbol(G, Decl(index.js, 32, 8)) + +interface HH {} +>HH : Symbol(HH, Decl(index.js, 32, 13)) + +export { HH as H }; +>HH : Symbol(HH, Decl(index.js, 32, 13)) +>H : Symbol(H, Decl(index.js, 36, 8)) + +export interface I {} +>I : Symbol(I, Decl(index.js, 36, 19)) + +export { I as II }; +>I : Symbol(I, Decl(index.js, 36, 19)) +>II : Symbol(II, Decl(index.js, 39, 8)) + +export { J as JJ }; +>J : Symbol(J, Decl(index.js, 41, 19)) +>JJ : Symbol(JJ, Decl(index.js, 41, 8)) + +export interface J {} +>J : Symbol(J, Decl(index.js, 41, 19)) + +export interface K extends I,J { +>K : Symbol(K, Decl(index.js, 42, 21)) +>I : Symbol(I, Decl(index.js, 36, 19)) +>J : Symbol(J, Decl(index.js, 41, 19)) + + x: string; +>x : Symbol(K.x, Decl(index.js, 44, 32)) +} + +export interface L extends K { +>L : Symbol(L, Decl(index.js, 46, 1)) +>K : Symbol(K, Decl(index.js, 42, 21)) + + y: string; +>y : Symbol(L.y, Decl(index.js, 48, 30)) +} + +export interface M { +>M : Symbol(M, Decl(index.js, 50, 1)) +>T : Symbol(T, Decl(index.js, 52, 19)) + + field: T; +>field : Symbol(M.field, Decl(index.js, 52, 23)) +>T : Symbol(T, Decl(index.js, 52, 19)) +} + +export interface N extends M { +>N : Symbol(N, Decl(index.js, 54, 1)) +>U : Symbol(U, Decl(index.js, 56, 19)) +>M : Symbol(M, Decl(index.js, 50, 1)) +>U : Symbol(U, Decl(index.js, 56, 19)) + + other: U; +>other : Symbol(N.other, Decl(index.js, 56, 36)) +>U : Symbol(U, Decl(index.js, 56, 19)) +} + +export interface O { +>O : Symbol(O, Decl(index.js, 58, 1)) + + [idx: string]: string; +>idx : Symbol(idx, Decl(index.js, 61, 5)) +} + +export interface P extends O {} +>P : Symbol(P, Decl(index.js, 62, 1)) +>O : Symbol(O, Decl(index.js, 58, 1)) + +export interface Q extends O { +>Q : Symbol(Q, Decl(index.js, 64, 31)) +>O : Symbol(O, Decl(index.js, 58, 1)) + + [idx: string]: "ok"; +>idx : Symbol(idx, Decl(index.js, 67, 5)) +} + +export interface R extends O { +>R : Symbol(R, Decl(index.js, 68, 1)) +>O : Symbol(O, Decl(index.js, 58, 1)) + + [idx: number]: "ok"; +>idx : Symbol(idx, Decl(index.js, 71, 5)) +} + +export interface S extends O { +>S : Symbol(S, Decl(index.js, 72, 1)) +>O : Symbol(O, Decl(index.js, 58, 1)) + + [idx: string]: "ok"; +>idx : Symbol(idx, Decl(index.js, 75, 5)) + + [idx: number]: never; +>idx : Symbol(idx, Decl(index.js, 76, 5)) +} + +export interface T { +>T : Symbol(T, Decl(index.js, 77, 1)) + + [idx: number]: string; +>idx : Symbol(idx, Decl(index.js, 80, 5)) +} + +export interface U extends T {} +>U : Symbol(U, Decl(index.js, 81, 1)) +>T : Symbol(T, Decl(index.js, 77, 1)) + + +export interface V extends T { +>V : Symbol(V, Decl(index.js, 83, 31)) +>T : Symbol(T, Decl(index.js, 77, 1)) + + [idx: string]: string; +>idx : Symbol(idx, Decl(index.js, 87, 5)) +} + +export interface W extends T { +>W : Symbol(W, Decl(index.js, 88, 1)) +>T : Symbol(T, Decl(index.js, 77, 1)) + + [idx: number]: "ok"; +>idx : Symbol(idx, Decl(index.js, 91, 5)) +} + +export interface X extends T { +>X : Symbol(X, Decl(index.js, 92, 1)) +>T : Symbol(T, Decl(index.js, 77, 1)) + + [idx: string]: string; +>idx : Symbol(idx, Decl(index.js, 95, 5)) + + [idx: number]: "ok"; +>idx : Symbol(idx, Decl(index.js, 96, 5)) +} + +export interface Y { +>Y : Symbol(Y, Decl(index.js, 97, 1)) + + [idx: string]: {x: number}; +>idx : Symbol(idx, Decl(index.js, 100, 5)) +>x : Symbol(x, Decl(index.js, 100, 20)) + + [idx: number]: {x: number, y: number}; +>idx : Symbol(idx, Decl(index.js, 101, 5)) +>x : Symbol(x, Decl(index.js, 101, 20)) +>y : Symbol(y, Decl(index.js, 101, 30)) +} + +export interface Z extends Y {} +>Z : Symbol(Z, Decl(index.js, 102, 1)) +>Y : Symbol(Y, Decl(index.js, 97, 1)) + +export interface AA extends Y { +>AA : Symbol(AA, Decl(index.js, 104, 31)) +>Y : Symbol(Y, Decl(index.js, 97, 1)) + + [idx: string]: {x: number, y: number}; +>idx : Symbol(idx, Decl(index.js, 107, 5)) +>x : Symbol(x, Decl(index.js, 107, 20)) +>y : Symbol(y, Decl(index.js, 107, 30)) +} + +export interface BB extends Y { +>BB : Symbol(BB, Decl(index.js, 108, 1)) +>Y : Symbol(Y, Decl(index.js, 97, 1)) + + [idx: number]: {x: 0, y: 0}; +>idx : Symbol(idx, Decl(index.js, 111, 5)) +>x : Symbol(x, Decl(index.js, 111, 20)) +>y : Symbol(y, Decl(index.js, 111, 25)) +} + +export interface CC extends Y { +>CC : Symbol(CC, Decl(index.js, 112, 1)) +>Y : Symbol(Y, Decl(index.js, 97, 1)) + + [idx: string]: {x: number, y: number}; +>idx : Symbol(idx, Decl(index.js, 115, 5)) +>x : Symbol(x, Decl(index.js, 115, 20)) +>y : Symbol(y, Decl(index.js, 115, 30)) + + [idx: number]: {x: 0, y: 0}; +>idx : Symbol(idx, Decl(index.js, 116, 5)) +>x : Symbol(x, Decl(index.js, 116, 20)) +>y : Symbol(y, Decl(index.js, 116, 25)) +} + diff --git a/tests/baselines/reference/jsDeclarationsInterfaces.types b/tests/baselines/reference/jsDeclarationsInterfaces.types new file mode 100644 index 0000000000000..2e7e1576cc0db --- /dev/null +++ b/tests/baselines/reference/jsDeclarationsInterfaces.types @@ -0,0 +1,189 @@ +=== tests/cases/conformance/jsdoc/declarations/index.js === +// Pretty much all of this should be an error, (since interfaces are forbidden in js), +// but we should be able to synthesize declarations from the symbols regardless + +export interface A {} + +export interface B { + cat: string; +>cat : string +} + +export interface C { + field: T & U; +>field : T & U + + optionalField?: T; +>optionalField : T + + readonly readonlyField: T & U; +>readonlyField : T & U + + readonly readonlyOptionalField?: U; +>readonlyOptionalField : U + + (): number; + (x: T): U; +>x : T + + (x: Q): T & Q; +>x : Q + + new (): string; + new (x: T): U; +>x : T + + new (x: Q): T & Q; +>x : Q + + method(): number; +>method : { (): number; (a: T & Q): Q & number; (a?: number): number; (...args: any[]): number; } + + method(a: T & Q): Q & number; +>method : { (): number; (a: T & Q): Q & number; (a?: number): number; (...args: any[]): number; } +>a : T & Q + + method(a?: number): number; +>method : { (): number; (a: T & Q): Q & number; (a?: number): number; (...args: any[]): number; } +>a : number + + method(...args: any[]): number; +>method : { (): number; (a: T & Q): Q & number; (a?: number): number; (...args: any[]): number; } +>args : any[] + + optMethod?(): number; +>optMethod : () => number +} + +interface G {} + +export { G }; +>G : any + +interface HH {} + +export { HH as H }; +>HH : any +>H : any + +export interface I {} +export { I as II }; +>I : any +>II : any + +export { J as JJ }; +>J : any +>JJ : any + +export interface J {} + +export interface K extends I,J { + x: string; +>x : string +} + +export interface L extends K { + y: string; +>y : string +} + +export interface M { + field: T; +>field : T +} + +export interface N extends M { + other: U; +>other : U +} + +export interface O { + [idx: string]: string; +>idx : string +} + +export interface P extends O {} + +export interface Q extends O { + [idx: string]: "ok"; +>idx : string +} + +export interface R extends O { + [idx: number]: "ok"; +>idx : number +} + +export interface S extends O { + [idx: string]: "ok"; +>idx : string + + [idx: number]: never; +>idx : number +} + +export interface T { + [idx: number]: string; +>idx : number +} + +export interface U extends T {} + + +export interface V extends T { + [idx: string]: string; +>idx : string +} + +export interface W extends T { + [idx: number]: "ok"; +>idx : number +} + +export interface X extends T { + [idx: string]: string; +>idx : string + + [idx: number]: "ok"; +>idx : number +} + +export interface Y { + [idx: string]: {x: number}; +>idx : string +>x : number + + [idx: number]: {x: number, y: number}; +>idx : number +>x : number +>y : number +} + +export interface Z extends Y {} + +export interface AA extends Y { + [idx: string]: {x: number, y: number}; +>idx : string +>x : number +>y : number +} + +export interface BB extends Y { + [idx: number]: {x: 0, y: 0}; +>idx : number +>x : 0 +>y : 0 +} + +export interface CC extends Y { + [idx: string]: {x: number, y: number}; +>idx : string +>x : number +>y : number + + [idx: number]: {x: 0, y: 0}; +>idx : number +>x : 0 +>y : 0 +} + diff --git a/tests/baselines/reference/jsDeclarationsJson.js b/tests/baselines/reference/jsDeclarationsJson.js new file mode 100644 index 0000000000000..2cebc7b583a8f --- /dev/null +++ b/tests/baselines/reference/jsDeclarationsJson.js @@ -0,0 +1,66 @@ +//// [tests/cases/conformance/jsdoc/declarations/jsDeclarationsJson.ts] //// + +//// [index.js] +const j = require("./obj.json"); +module.exports = j; +//// [obj.json] +{ + "x": 12, + "y": 12, + "obj": { + "items": [{"x": 12}, {"x": 12, "y": 12}, {"x": 0}, {"x": -1, "err": true}] + } +} + +//// [obj.json] +{ + "x": 12, + "y": 12, + "obj": { + "items": [{ "x": 12 }, { "x": 12, "y": 12 }, { "x": 0 }, { "x": -1, "err": true }] + } +} +//// [index.js] +var j = require("./obj.json"); +module.exports = j; + + +//// [obj.d.ts] +export declare const x: number; +export declare const y: number; +export declare namespace obj { + export const items: ({ + "x": number; + "y"?: undefined; + "err"?: undefined; + } | { + "x": number; + "y": number; + "err"?: undefined; + } | { + "x": number; + "err": boolean; + "y"?: undefined; + })[]; +} +//// [index.d.ts] +export = j; +declare const j: { + "x": number; + "y": number; + "obj": { + "items": ({ + "x": number; + "y"?: undefined; + "err"?: undefined; + } | { + "x": number; + "y": number; + "err"?: undefined; + } | { + "x": number; + "err": boolean; + "y"?: undefined; + })[]; + }; +}; diff --git a/tests/baselines/reference/jsDeclarationsJson.symbols b/tests/baselines/reference/jsDeclarationsJson.symbols new file mode 100644 index 0000000000000..9e276decbc6b5 --- /dev/null +++ b/tests/baselines/reference/jsDeclarationsJson.symbols @@ -0,0 +1,33 @@ +=== tests/cases/conformance/jsdoc/declarations/index.js === +const j = require("./obj.json"); +>j : Symbol(j, Decl(index.js, 0, 5)) +>require : Symbol(require) +>"./obj.json" : Symbol("tests/cases/conformance/jsdoc/declarations/obj", Decl(obj.json, 0, 0)) + +module.exports = j; +>module.exports : Symbol("tests/cases/conformance/jsdoc/declarations/index", Decl(index.js, 0, 0)) +>module : Symbol(export=, Decl(index.js, 0, 32)) +>exports : Symbol(export=, Decl(index.js, 0, 32)) +>j : Symbol(j, Decl(index.js, 0, 5)) + +=== tests/cases/conformance/jsdoc/declarations/obj.json === +{ + "x": 12, +>"x" : Symbol("x", Decl(obj.json, 0, 1)) + + "y": 12, +>"y" : Symbol("y", Decl(obj.json, 1, 12)) + + "obj": { +>"obj" : Symbol("obj", Decl(obj.json, 2, 12)) + + "items": [{"x": 12}, {"x": 12, "y": 12}, {"x": 0}, {"x": -1, "err": true}] +>"items" : Symbol("items", Decl(obj.json, 3, 12)) +>"x" : Symbol("x", Decl(obj.json, 4, 19)) +>"x" : Symbol("x", Decl(obj.json, 4, 30)) +>"y" : Symbol("y", Decl(obj.json, 4, 38)) +>"x" : Symbol("x", Decl(obj.json, 4, 50)) +>"x" : Symbol("x", Decl(obj.json, 4, 60)) +>"err" : Symbol("err", Decl(obj.json, 4, 68)) + } +} diff --git a/tests/baselines/reference/jsDeclarationsJson.types b/tests/baselines/reference/jsDeclarationsJson.types new file mode 100644 index 0000000000000..aaab20ac36a2e --- /dev/null +++ b/tests/baselines/reference/jsDeclarationsJson.types @@ -0,0 +1,52 @@ +=== tests/cases/conformance/jsdoc/declarations/index.js === +const j = require("./obj.json"); +>j : { "x": number; "y": number; "obj": { "items": ({ "x": number; "y"?: undefined; "err"?: undefined; } | { "x": number; "y": number; "err"?: undefined; } | { "x": number; "err": boolean; "y"?: undefined; })[]; }; } +>require("./obj.json") : { "x": number; "y": number; "obj": { "items": ({ "x": number; } | { "x": number; "y": number; } | { "x": number; "err": boolean; })[]; }; } +>require : any +>"./obj.json" : "./obj.json" + +module.exports = j; +>module.exports = j : { "x": number; "y": number; "obj": { "items": ({ "x": number; "y"?: undefined; "err"?: undefined; } | { "x": number; "y": number; "err"?: undefined; } | { "x": number; "err": boolean; "y"?: undefined; })[]; }; } +>module.exports : { "x": number; "y": number; "obj": { "items": ({ "x": number; "y"?: undefined; "err"?: undefined; } | { "x": number; "y": number; "err"?: undefined; } | { "x": number; "err": boolean; "y"?: undefined; })[]; }; } +>module : { "tests/cases/conformance/jsdoc/declarations/index": { "x": number; "y": number; "obj": { "items": ({ "x": number; "y"?: undefined; "err"?: undefined; } | { "x": number; "y": number; "err"?: undefined; } | { "x": number; "err": boolean; "y"?: undefined; })[]; }; }; } +>exports : { "x": number; "y": number; "obj": { "items": ({ "x": number; "y"?: undefined; "err"?: undefined; } | { "x": number; "y": number; "err"?: undefined; } | { "x": number; "err": boolean; "y"?: undefined; })[]; }; } +>j : { "x": number; "y": number; "obj": { "items": ({ "x": number; "y"?: undefined; "err"?: undefined; } | { "x": number; "y": number; "err"?: undefined; } | { "x": number; "err": boolean; "y"?: undefined; })[]; }; } + +=== tests/cases/conformance/jsdoc/declarations/obj.json === +{ +>{ "x": 12, "y": 12, "obj": { "items": [{"x": 12}, {"x": 12, "y": 12}, {"x": 0}, {"x": -1, "err": true}] }} : { "x": number; "y": number; "obj": { "items": ({ "x": number; } | { "x": number; "y": number; } | { "x": number; "err": boolean; })[]; }; } + + "x": 12, +>"x" : number +>12 : 12 + + "y": 12, +>"y" : number +>12 : 12 + + "obj": { +>"obj" : { "items": ({ "x": number; } | { "x": number; "y": number; } | { "x": number; "err": boolean; })[]; } +>{ "items": [{"x": 12}, {"x": 12, "y": 12}, {"x": 0}, {"x": -1, "err": true}] } : { "items": ({ "x": number; } | { "x": number; "y": number; } | { "x": number; "err": boolean; })[]; } + + "items": [{"x": 12}, {"x": 12, "y": 12}, {"x": 0}, {"x": -1, "err": true}] +>"items" : ({ "x": number; } | { "x": number; "y": number; } | { "x": number; "err": boolean; })[] +>[{"x": 12}, {"x": 12, "y": 12}, {"x": 0}, {"x": -1, "err": true}] : ({ "x": number; } | { "x": number; "y": number; } | { "x": number; "err": boolean; })[] +>{"x": 12} : { "x": number; } +>"x" : number +>12 : 12 +>{"x": 12, "y": 12} : { "x": number; "y": number; } +>"x" : number +>12 : 12 +>"y" : number +>12 : 12 +>{"x": 0} : { "x": number; } +>"x" : number +>0 : 0 +>{"x": -1, "err": true} : { "x": number; "err": boolean; } +>"x" : number +>-1 : -1 +>1 : 1 +>"err" : boolean +>true : true + } +} diff --git a/tests/baselines/reference/jsDeclarationsMultipleExportFromMerge.js b/tests/baselines/reference/jsDeclarationsMultipleExportFromMerge.js new file mode 100644 index 0000000000000..75e7c37bd8db2 --- /dev/null +++ b/tests/baselines/reference/jsDeclarationsMultipleExportFromMerge.js @@ -0,0 +1,70 @@ +//// [tests/cases/conformance/jsdoc/declarations/jsDeclarationsMultipleExportFromMerge.ts] //// + +//// [items.js] +export const a = 1; +export const b = 2; +export const c = 3; + +//// [justone.js] +export { a, b, c } from "./items"; + +//// [two.js] +export { a } from "./items"; +export { b, c } from "./items"; + +//// [multiple.js] +export {a, b} from "./items"; +export {a as aa} from "./two"; +export {b as bb} from "./two"; +export {c} from "./two" +export {c as cc} from "./items"; + + +//// [items.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.a = 1; +exports.b = 2; +exports.c = 3; +//// [justone.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +var items_1 = require("./items"); +exports.a = items_1.a; +exports.b = items_1.b; +exports.c = items_1.c; +//// [two.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +var items_1 = require("./items"); +exports.a = items_1.a; +var items_2 = require("./items"); +exports.b = items_2.b; +exports.c = items_2.c; +//// [multiple.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +var items_1 = require("./items"); +exports.a = items_1.a; +exports.b = items_1.b; +var two_1 = require("./two"); +exports.aa = two_1.a; +var two_2 = require("./two"); +exports.bb = two_2.b; +var two_3 = require("./two"); +exports.c = two_3.c; +var items_2 = require("./items"); +exports.cc = items_2.c; + + +//// [items.d.ts] +export const a: 1; +export const b: 2; +export const c: 3; +//// [justone.d.ts] +export { a, b, c } from "./items"; +//// [two.d.ts] +export { a, b, c } from "./items"; +//// [multiple.d.ts] +export { a, b, c as cc } from "./items"; +export { a as aa, b as bb, c } from "./two"; diff --git a/tests/baselines/reference/jsDeclarationsMultipleExportFromMerge.symbols b/tests/baselines/reference/jsDeclarationsMultipleExportFromMerge.symbols new file mode 100644 index 0000000000000..63168d91f55ff --- /dev/null +++ b/tests/baselines/reference/jsDeclarationsMultipleExportFromMerge.symbols @@ -0,0 +1,44 @@ +=== tests/cases/conformance/jsdoc/declarations/items.js === +export const a = 1; +>a : Symbol(a, Decl(items.js, 0, 12)) + +export const b = 2; +>b : Symbol(b, Decl(items.js, 1, 12)) + +export const c = 3; +>c : Symbol(c, Decl(items.js, 2, 12)) + +=== tests/cases/conformance/jsdoc/declarations/justone.js === +export { a, b, c } from "./items"; +>a : Symbol(a, Decl(justone.js, 0, 8)) +>b : Symbol(b, Decl(justone.js, 0, 11)) +>c : Symbol(c, Decl(justone.js, 0, 14)) + +=== tests/cases/conformance/jsdoc/declarations/two.js === +export { a } from "./items"; +>a : Symbol(a, Decl(two.js, 0, 8)) + +export { b, c } from "./items"; +>b : Symbol(b, Decl(two.js, 1, 8)) +>c : Symbol(c, Decl(two.js, 1, 11)) + +=== tests/cases/conformance/jsdoc/declarations/multiple.js === +export {a, b} from "./items"; +>a : Symbol(a, Decl(multiple.js, 0, 8)) +>b : Symbol(b, Decl(multiple.js, 0, 10)) + +export {a as aa} from "./two"; +>a : Symbol(a, Decl(two.js, 0, 8)) +>aa : Symbol(aa, Decl(multiple.js, 1, 8)) + +export {b as bb} from "./two"; +>b : Symbol(b, Decl(two.js, 1, 8)) +>bb : Symbol(bb, Decl(multiple.js, 2, 8)) + +export {c} from "./two" +>c : Symbol(c, Decl(multiple.js, 3, 8)) + +export {c as cc} from "./items"; +>c : Symbol(c, Decl(items.js, 2, 12)) +>cc : Symbol(cc, Decl(multiple.js, 4, 8)) + diff --git a/tests/baselines/reference/jsDeclarationsMultipleExportFromMerge.types b/tests/baselines/reference/jsDeclarationsMultipleExportFromMerge.types new file mode 100644 index 0000000000000..741ad48205749 --- /dev/null +++ b/tests/baselines/reference/jsDeclarationsMultipleExportFromMerge.types @@ -0,0 +1,47 @@ +=== tests/cases/conformance/jsdoc/declarations/items.js === +export const a = 1; +>a : 1 +>1 : 1 + +export const b = 2; +>b : 2 +>2 : 2 + +export const c = 3; +>c : 3 +>3 : 3 + +=== tests/cases/conformance/jsdoc/declarations/justone.js === +export { a, b, c } from "./items"; +>a : 1 +>b : 2 +>c : 3 + +=== tests/cases/conformance/jsdoc/declarations/two.js === +export { a } from "./items"; +>a : 1 + +export { b, c } from "./items"; +>b : 2 +>c : 3 + +=== tests/cases/conformance/jsdoc/declarations/multiple.js === +export {a, b} from "./items"; +>a : 1 +>b : 2 + +export {a as aa} from "./two"; +>a : 1 +>aa : 1 + +export {b as bb} from "./two"; +>b : 2 +>bb : 2 + +export {c} from "./two" +>c : 3 + +export {c as cc} from "./items"; +>c : 3 +>cc : 3 + diff --git a/tests/baselines/reference/jsDeclarationsPackageJson.js b/tests/baselines/reference/jsDeclarationsPackageJson.js new file mode 100644 index 0000000000000..66da073d33882 --- /dev/null +++ b/tests/baselines/reference/jsDeclarationsPackageJson.js @@ -0,0 +1,135 @@ +//// [tests/cases/conformance/jsdoc/declarations/jsDeclarationsPackageJson.ts] //// + +//// [index.js] +const j = require("./package.json"); +module.exports = j; +//// [package.json] +{ + "name": "pkg", + "version": "0.1.0", + "description": "A package", + "main": "./dist/index.js", + "bin": { + "cli": "./bin/cli.js", + }, + "engines": { + "node": ">=0" + }, + "scripts": { + "scriptname": "run && run again", + }, + "devDependencies": { + "@ns/dep": "0.1.2", + }, + "dependencies": { + "dep": "1.2.3", + }, + "repository": "microsoft/TypeScript", + "keywords": [ + "kw" + ], + "author": "Auth", + "license": "See Licensce", + "homepage": "https://site", + "config": { + "o": ["a"] + } +} + + +//// [package.json] +{ + "name": "pkg", + "version": "0.1.0", + "description": "A package", + "main": "./dist/index.js", + "bin": { + "cli": "./bin/cli.js" + }, + "engines": { + "node": ">=0" + }, + "scripts": { + "scriptname": "run && run again" + }, + "devDependencies": { + "@ns/dep": "0.1.2" + }, + "dependencies": { + "dep": "1.2.3" + }, + "repository": "microsoft/TypeScript", + "keywords": [ + "kw" + ], + "author": "Auth", + "license": "See Licensce", + "homepage": "https://site", + "config": { + "o": ["a"] + } +} +//// [index.js] +var j = require("./package.json"); +module.exports = j; + + +//// [package.d.ts] +export declare const name: string; +export declare const version: string; +export declare const description: string; +export declare const main: string; +export declare namespace bin { + export const cli: string; +} +export declare namespace engines { + export const node: string; +} +export declare namespace scripts { + export const scriptname: string; +} +export declare const devDependencies: { + "@ns/dep": string; +}; +export declare namespace dependencies { + export const dep: string; +} +export declare const repository: string; +export declare const keywords: string[]; +export declare const author: string; +export declare const license: string; +export declare const homepage: string; +export declare namespace config { + export const o: string[]; +} +//// [index.d.ts] +export = j; +declare const j: { + "name": string; + "version": string; + "description": string; + "main": string; + "bin": { + "cli": string; + }; + "engines": { + "node": string; + }; + "scripts": { + "scriptname": string; + }; + "devDependencies": { + "@ns/dep": string; + }; + "dependencies": { + "dep": string; + }; + "repository": string; + "keywords": string[]; + "author": string; + "license": string; + "homepage": string; + "config": { + "o": string[]; + }; +}; diff --git a/tests/baselines/reference/jsDeclarationsPackageJson.symbols b/tests/baselines/reference/jsDeclarationsPackageJson.symbols new file mode 100644 index 0000000000000..7f09a886bab0a --- /dev/null +++ b/tests/baselines/reference/jsDeclarationsPackageJson.symbols @@ -0,0 +1,86 @@ +=== tests/cases/conformance/jsdoc/declarations/index.js === +const j = require("./package.json"); +>j : Symbol(j, Decl(index.js, 0, 5)) +>require : Symbol(require) +>"./package.json" : Symbol("tests/cases/conformance/jsdoc/declarations/package", Decl(package.json, 0, 0)) + +module.exports = j; +>module.exports : Symbol("tests/cases/conformance/jsdoc/declarations/index", Decl(index.js, 0, 0)) +>module : Symbol(export=, Decl(index.js, 0, 36)) +>exports : Symbol(export=, Decl(index.js, 0, 36)) +>j : Symbol(j, Decl(index.js, 0, 5)) + +=== tests/cases/conformance/jsdoc/declarations/package.json === +{ + "name": "pkg", +>"name" : Symbol("name", Decl(package.json, 0, 1)) + + "version": "0.1.0", +>"version" : Symbol("version", Decl(package.json, 1, 18)) + + "description": "A package", +>"description" : Symbol("description", Decl(package.json, 2, 23)) + + "main": "./dist/index.js", +>"main" : Symbol("main", Decl(package.json, 3, 31)) + + "bin": { +>"bin" : Symbol("bin", Decl(package.json, 4, 30)) + + "cli": "./bin/cli.js", +>"cli" : Symbol("cli", Decl(package.json, 5, 12)) + + }, + "engines": { +>"engines" : Symbol("engines", Decl(package.json, 7, 6)) + + "node": ">=0" +>"node" : Symbol("node", Decl(package.json, 8, 16)) + + }, + "scripts": { +>"scripts" : Symbol("scripts", Decl(package.json, 10, 6)) + + "scriptname": "run && run again", +>"scriptname" : Symbol("scriptname", Decl(package.json, 11, 16)) + + }, + "devDependencies": { +>"devDependencies" : Symbol("devDependencies", Decl(package.json, 13, 6)) + + "@ns/dep": "0.1.2", +>"@ns/dep" : Symbol("@ns/dep", Decl(package.json, 14, 24)) + + }, + "dependencies": { +>"dependencies" : Symbol("dependencies", Decl(package.json, 16, 6)) + + "dep": "1.2.3", +>"dep" : Symbol("dep", Decl(package.json, 17, 21)) + + }, + "repository": "microsoft/TypeScript", +>"repository" : Symbol("repository", Decl(package.json, 19, 6)) + + "keywords": [ +>"keywords" : Symbol("keywords", Decl(package.json, 20, 41)) + + "kw" + ], + "author": "Auth", +>"author" : Symbol("author", Decl(package.json, 23, 6)) + + "license": "See Licensce", +>"license" : Symbol("license", Decl(package.json, 24, 21)) + + "homepage": "https://site", +>"homepage" : Symbol("homepage", Decl(package.json, 25, 30)) + + "config": { +>"config" : Symbol("config", Decl(package.json, 26, 31)) + + "o": ["a"] +>"o" : Symbol("o", Decl(package.json, 27, 15)) + } +} + diff --git a/tests/baselines/reference/jsDeclarationsPackageJson.types b/tests/baselines/reference/jsDeclarationsPackageJson.types new file mode 100644 index 0000000000000..c0b34509fcaf8 --- /dev/null +++ b/tests/baselines/reference/jsDeclarationsPackageJson.types @@ -0,0 +1,114 @@ +=== tests/cases/conformance/jsdoc/declarations/index.js === +const j = require("./package.json"); +>j : { "name": string; "version": string; "description": string; "main": string; "bin": { "cli": string; }; "engines": { "node": string; }; "scripts": { "scriptname": string; }; "devDependencies": { "@ns/dep": string; }; "dependencies": { "dep": string; }; "repository": string; "keywords": string[]; "author": string; "license": string; "homepage": string; "config": { "o": string[]; }; } +>require("./package.json") : { "name": string; "version": string; "description": string; "main": string; "bin": { "cli": string; }; "engines": { "node": string; }; "scripts": { "scriptname": string; }; "devDependencies": { "@ns/dep": string; }; "dependencies": { "dep": string; }; "repository": string; "keywords": string[]; "author": string; "license": string; "homepage": string; "config": { "o": string[]; }; } +>require : any +>"./package.json" : "./package.json" + +module.exports = j; +>module.exports = j : { "name": string; "version": string; "description": string; "main": string; "bin": { "cli": string; }; "engines": { "node": string; }; "scripts": { "scriptname": string; }; "devDependencies": { "@ns/dep": string; }; "dependencies": { "dep": string; }; "repository": string; "keywords": string[]; "author": string; "license": string; "homepage": string; "config": { "o": string[]; }; } +>module.exports : { "name": string; "version": string; "description": string; "main": string; "bin": { "cli": string; }; "engines": { "node": string; }; "scripts": { "scriptname": string; }; "devDependencies": { "@ns/dep": string; }; "dependencies": { "dep": string; }; "repository": string; "keywords": string[]; "author": string; "license": string; "homepage": string; "config": { "o": string[]; }; } +>module : { "tests/cases/conformance/jsdoc/declarations/index": { "name": string; "version": string; "description": string; "main": string; "bin": { "cli": string; }; "engines": { "node": string; }; "scripts": { "scriptname": string; }; "devDependencies": { "@ns/dep": string; }; "dependencies": { "dep": string; }; "repository": string; "keywords": string[]; "author": string; "license": string; "homepage": string; "config": { "o": string[]; }; }; } +>exports : { "name": string; "version": string; "description": string; "main": string; "bin": { "cli": string; }; "engines": { "node": string; }; "scripts": { "scriptname": string; }; "devDependencies": { "@ns/dep": string; }; "dependencies": { "dep": string; }; "repository": string; "keywords": string[]; "author": string; "license": string; "homepage": string; "config": { "o": string[]; }; } +>j : { "name": string; "version": string; "description": string; "main": string; "bin": { "cli": string; }; "engines": { "node": string; }; "scripts": { "scriptname": string; }; "devDependencies": { "@ns/dep": string; }; "dependencies": { "dep": string; }; "repository": string; "keywords": string[]; "author": string; "license": string; "homepage": string; "config": { "o": string[]; }; } + +=== tests/cases/conformance/jsdoc/declarations/package.json === +{ +>{ "name": "pkg", "version": "0.1.0", "description": "A package", "main": "./dist/index.js", "bin": { "cli": "./bin/cli.js", }, "engines": { "node": ">=0" }, "scripts": { "scriptname": "run && run again", }, "devDependencies": { "@ns/dep": "0.1.2", }, "dependencies": { "dep": "1.2.3", }, "repository": "microsoft/TypeScript", "keywords": [ "kw" ], "author": "Auth", "license": "See Licensce", "homepage": "https://site", "config": { "o": ["a"] }} : { "name": string; "version": string; "description": string; "main": string; "bin": { "cli": string; }; "engines": { "node": string; }; "scripts": { "scriptname": string; }; "devDependencies": { "@ns/dep": string; }; "dependencies": { "dep": string; }; "repository": string; "keywords": string[]; "author": string; "license": string; "homepage": string; "config": { "o": string[]; }; } + + "name": "pkg", +>"name" : string +>"pkg" : "pkg" + + "version": "0.1.0", +>"version" : string +>"0.1.0" : "0.1.0" + + "description": "A package", +>"description" : string +>"A package" : "A package" + + "main": "./dist/index.js", +>"main" : string +>"./dist/index.js" : "./dist/index.js" + + "bin": { +>"bin" : { "cli": string; } +>{ "cli": "./bin/cli.js", } : { "cli": string; } + + "cli": "./bin/cli.js", +>"cli" : string +>"./bin/cli.js" : "./bin/cli.js" + + }, + "engines": { +>"engines" : { "node": string; } +>{ "node": ">=0" } : { "node": string; } + + "node": ">=0" +>"node" : string +>">=0" : ">=0" + + }, + "scripts": { +>"scripts" : { "scriptname": string; } +>{ "scriptname": "run && run again", } : { "scriptname": string; } + + "scriptname": "run && run again", +>"scriptname" : string +>"run && run again" : "run && run again" + + }, + "devDependencies": { +>"devDependencies" : { "@ns/dep": string; } +>{ "@ns/dep": "0.1.2", } : { "@ns/dep": string; } + + "@ns/dep": "0.1.2", +>"@ns/dep" : string +>"0.1.2" : "0.1.2" + + }, + "dependencies": { +>"dependencies" : { "dep": string; } +>{ "dep": "1.2.3", } : { "dep": string; } + + "dep": "1.2.3", +>"dep" : string +>"1.2.3" : "1.2.3" + + }, + "repository": "microsoft/TypeScript", +>"repository" : string +>"microsoft/TypeScript" : "microsoft/TypeScript" + + "keywords": [ +>"keywords" : string[] +>[ "kw" ] : string[] + + "kw" +>"kw" : "kw" + + ], + "author": "Auth", +>"author" : string +>"Auth" : "Auth" + + "license": "See Licensce", +>"license" : string +>"See Licensce" : "See Licensce" + + "homepage": "https://site", +>"homepage" : string +>"https://site" : "https://site" + + "config": { +>"config" : { "o": string[]; } +>{ "o": ["a"] } : { "o": string[]; } + + "o": ["a"] +>"o" : string[] +>["a"] : string[] +>"a" : "a" + } +} + diff --git a/tests/baselines/reference/jsDeclarationsReexportAliases.js b/tests/baselines/reference/jsDeclarationsReexportAliases.js new file mode 100644 index 0000000000000..1d117661c5d80 --- /dev/null +++ b/tests/baselines/reference/jsDeclarationsReexportAliases.js @@ -0,0 +1,38 @@ +//// [tests/cases/conformance/jsdoc/declarations/jsDeclarationsReexportAliases.ts] //// + +//// [cls.js] +export default class Foo {} + +//// [usage.js] +import {default as Fooa} from "./cls"; + +export const x = new Fooa(); + +export {default as Foob} from "./cls"; + + +//// [cls.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +var Foo = /** @class */ (function () { + function Foo() { + } + return Foo; +}()); +exports.default = Foo; +//// [usage.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +var cls_1 = require("./cls"); +exports.x = new cls_1.default(); +var cls_2 = require("./cls"); +exports.Foob = cls_2.default; + + +//// [cls.d.ts] +export default class Foo { +} +//// [usage.d.ts] +export const x: Fooa; +export { default as Foob } from "./cls"; +import { default as Fooa } from "./cls"; diff --git a/tests/baselines/reference/jsDeclarationsReexportAliases.symbols b/tests/baselines/reference/jsDeclarationsReexportAliases.symbols new file mode 100644 index 0000000000000..c34e9b238f3d9 --- /dev/null +++ b/tests/baselines/reference/jsDeclarationsReexportAliases.symbols @@ -0,0 +1,17 @@ +=== tests/cases/conformance/jsdoc/declarations/cls.js === +export default class Foo {} +>Foo : Symbol(Foo, Decl(cls.js, 0, 0)) + +=== tests/cases/conformance/jsdoc/declarations/usage.js === +import {default as Fooa} from "./cls"; +>default : Symbol(Fooa, Decl(cls.js, 0, 0)) +>Fooa : Symbol(Fooa, Decl(usage.js, 0, 8)) + +export const x = new Fooa(); +>x : Symbol(x, Decl(usage.js, 2, 12)) +>Fooa : Symbol(Fooa, Decl(usage.js, 0, 8)) + +export {default as Foob} from "./cls"; +>default : Symbol(Fooa, Decl(cls.js, 0, 0)) +>Foob : Symbol(Foob, Decl(usage.js, 4, 8)) + diff --git a/tests/baselines/reference/jsDeclarationsReexportAliases.types b/tests/baselines/reference/jsDeclarationsReexportAliases.types new file mode 100644 index 0000000000000..b1f8d6c27aa4a --- /dev/null +++ b/tests/baselines/reference/jsDeclarationsReexportAliases.types @@ -0,0 +1,18 @@ +=== tests/cases/conformance/jsdoc/declarations/cls.js === +export default class Foo {} +>Foo : Foo + +=== tests/cases/conformance/jsdoc/declarations/usage.js === +import {default as Fooa} from "./cls"; +>default : typeof Fooa +>Fooa : typeof Fooa + +export const x = new Fooa(); +>x : Fooa +>new Fooa() : Fooa +>Fooa : typeof Fooa + +export {default as Foob} from "./cls"; +>default : typeof Fooa +>Foob : typeof Fooa + diff --git a/tests/baselines/reference/jsDeclarationsReexportAliasesEsModuleInterop.js b/tests/baselines/reference/jsDeclarationsReexportAliasesEsModuleInterop.js new file mode 100644 index 0000000000000..d00269b2658ec --- /dev/null +++ b/tests/baselines/reference/jsDeclarationsReexportAliasesEsModuleInterop.js @@ -0,0 +1,41 @@ +//// [tests/cases/conformance/jsdoc/declarations/jsDeclarationsReexportAliasesEsModuleInterop.ts] //// + +//// [cls.js] +class Foo {} +module.exports = Foo; + +//// [usage.js] +import {default as Fooa} from "./cls"; + +export const x = new Fooa(); + +export {default as Foob} from "./cls"; + + +//// [cls.js] +var Foo = /** @class */ (function () { + function Foo() { + } + return Foo; +}()); +module.exports = Foo; +//// [usage.js] +"use strict"; +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +var cls_1 = __importDefault(require("./cls")); +exports.x = new cls_1.default(); +var cls_2 = require("./cls"); +exports.Foob = cls_2.default; + + +//// [cls.d.ts] +export = Foo; +declare class Foo { +} +//// [usage.d.ts] +export const x: Fooa; +export { default as Foob } from "./cls"; +import { default as Fooa } from "./cls"; diff --git a/tests/baselines/reference/jsDeclarationsReexportAliasesEsModuleInterop.symbols b/tests/baselines/reference/jsDeclarationsReexportAliasesEsModuleInterop.symbols new file mode 100644 index 0000000000000..221e0bd0d0316 --- /dev/null +++ b/tests/baselines/reference/jsDeclarationsReexportAliasesEsModuleInterop.symbols @@ -0,0 +1,23 @@ +=== tests/cases/conformance/jsdoc/declarations/cls.js === +class Foo {} +>Foo : Symbol(Foo, Decl(cls.js, 0, 0)) + +module.exports = Foo; +>module.exports : Symbol("tests/cases/conformance/jsdoc/declarations/cls", Decl(cls.js, 0, 0)) +>module : Symbol(export=, Decl(cls.js, 0, 12)) +>exports : Symbol(export=, Decl(cls.js, 0, 12)) +>Foo : Symbol(Foo, Decl(cls.js, 0, 0)) + +=== tests/cases/conformance/jsdoc/declarations/usage.js === +import {default as Fooa} from "./cls"; +>default : Symbol(export=, Decl(cls.js, 0, 12)) +>Fooa : Symbol(Fooa, Decl(usage.js, 0, 8)) + +export const x = new Fooa(); +>x : Symbol(x, Decl(usage.js, 2, 12)) +>Fooa : Symbol(Fooa, Decl(usage.js, 0, 8)) + +export {default as Foob} from "./cls"; +>default : Symbol(export=, Decl(cls.js, 0, 12)) +>Foob : Symbol(Foob, Decl(usage.js, 4, 8)) + diff --git a/tests/baselines/reference/jsDeclarationsReexportAliasesEsModuleInterop.types b/tests/baselines/reference/jsDeclarationsReexportAliasesEsModuleInterop.types new file mode 100644 index 0000000000000..a67829317806f --- /dev/null +++ b/tests/baselines/reference/jsDeclarationsReexportAliasesEsModuleInterop.types @@ -0,0 +1,25 @@ +=== tests/cases/conformance/jsdoc/declarations/cls.js === +class Foo {} +>Foo : Foo + +module.exports = Foo; +>module.exports = Foo : typeof Foo +>module.exports : typeof Foo +>module : { "tests/cases/conformance/jsdoc/declarations/cls": typeof Foo; } +>exports : typeof Foo +>Foo : typeof Foo + +=== tests/cases/conformance/jsdoc/declarations/usage.js === +import {default as Fooa} from "./cls"; +>default : typeof Fooa +>Fooa : typeof Fooa + +export const x = new Fooa(); +>x : Fooa +>new Fooa() : Fooa +>Fooa : typeof Fooa + +export {default as Foob} from "./cls"; +>default : typeof Fooa +>Foob : typeof Fooa + diff --git a/tests/baselines/reference/jsDeclarationsReusesExistingNodesMappingJSDocTypes.js b/tests/baselines/reference/jsDeclarationsReusesExistingNodesMappingJSDocTypes.js new file mode 100644 index 0000000000000..95297733d9ec8 --- /dev/null +++ b/tests/baselines/reference/jsDeclarationsReusesExistingNodesMappingJSDocTypes.js @@ -0,0 +1,66 @@ +//// [index.js] +/** @type {?} */ +export const a = null; + +/** @type {*} */ +export const b = null; + +/** @type {string?} */ +export const c = null; + +/** @type {string=} */ +export const d = null; + +/** @type {string!} */ +export const e = null; + +/** @type {function(string, number): object} */ +export const f = null; + +/** @type {function(new: object, string, number)} */ +export const g = null; + +/** @type {Object.} */ +export const h = null; + + +//// [index.js] +"use strict"; +exports.__esModule = true; +/** @type {?} */ +exports.a = null; +/** @type {*} */ +exports.b = null; +/** @type {string?} */ +exports.c = null; +/** @type {string=} */ +exports.d = null; +/** @type {string!} */ +exports.e = null; +/** @type {function(string, number): object} */ +exports.f = null; +/** @type {function(new: object, string, number)} */ +exports.g = null; +/** @type {Object.} */ +exports.h = null; + + +//// [index.d.ts] +/** @type {?} */ +export const a: unknown; +/** @type {*} */ +export const b: any; +/** @type {string?} */ +export const c: string | null; +/** @type {string=} */ +export const d: string | undefined; +/** @type {string!} */ +export const e: string; +/** @type {function(string, number): object} */ +export const f: (arg0: string, arg1: number) => object; +/** @type {function(new: object, string, number)} */ +export const g: new (arg1: string, arg2: number) => object; +/** @type {Object.} */ +export const h: { + [x: string]: number; +}; diff --git a/tests/baselines/reference/jsDeclarationsReusesExistingNodesMappingJSDocTypes.symbols b/tests/baselines/reference/jsDeclarationsReusesExistingNodesMappingJSDocTypes.symbols new file mode 100644 index 0000000000000..1fd1a1ad329b4 --- /dev/null +++ b/tests/baselines/reference/jsDeclarationsReusesExistingNodesMappingJSDocTypes.symbols @@ -0,0 +1,33 @@ +=== tests/cases/conformance/jsdoc/declarations/index.js === +/** @type {?} */ +export const a = null; +>a : Symbol(a, Decl(index.js, 1, 12)) + +/** @type {*} */ +export const b = null; +>b : Symbol(b, Decl(index.js, 4, 12)) + +/** @type {string?} */ +export const c = null; +>c : Symbol(c, Decl(index.js, 7, 12)) + +/** @type {string=} */ +export const d = null; +>d : Symbol(d, Decl(index.js, 10, 12)) + +/** @type {string!} */ +export const e = null; +>e : Symbol(e, Decl(index.js, 13, 12)) + +/** @type {function(string, number): object} */ +export const f = null; +>f : Symbol(f, Decl(index.js, 16, 12)) + +/** @type {function(new: object, string, number)} */ +export const g = null; +>g : Symbol(g, Decl(index.js, 19, 12)) + +/** @type {Object.} */ +export const h = null; +>h : Symbol(h, Decl(index.js, 22, 12)) + diff --git a/tests/baselines/reference/jsDeclarationsReusesExistingNodesMappingJSDocTypes.types b/tests/baselines/reference/jsDeclarationsReusesExistingNodesMappingJSDocTypes.types new file mode 100644 index 0000000000000..2e7d031d5732f --- /dev/null +++ b/tests/baselines/reference/jsDeclarationsReusesExistingNodesMappingJSDocTypes.types @@ -0,0 +1,41 @@ +=== tests/cases/conformance/jsdoc/declarations/index.js === +/** @type {?} */ +export const a = null; +>a : any +>null : null + +/** @type {*} */ +export const b = null; +>b : any +>null : null + +/** @type {string?} */ +export const c = null; +>c : string +>null : null + +/** @type {string=} */ +export const d = null; +>d : string +>null : null + +/** @type {string!} */ +export const e = null; +>e : string +>null : null + +/** @type {function(string, number): object} */ +export const f = null; +>f : (arg0: string, arg1: number) => any +>null : null + +/** @type {function(new: object, string, number)} */ +export const g = null; +>g : new (arg1: string, arg2: number) => any +>null : null + +/** @type {Object.} */ +export const h = null; +>h : { [x: string]: number; } +>null : null + diff --git a/tests/baselines/reference/jsDeclarationsTypeAliases.js b/tests/baselines/reference/jsDeclarationsTypeAliases.js new file mode 100644 index 0000000000000..0c6fe20d30b54 --- /dev/null +++ b/tests/baselines/reference/jsDeclarationsTypeAliases.js @@ -0,0 +1,141 @@ +//// [tests/cases/conformance/jsdoc/declarations/jsDeclarationsTypeAliases.ts] //// + +//// [index.js] +export {}; // flag file as module +/** + * @typedef {string | number | symbol} PropName + */ + +/** + * Callback + * + * @callback NumberToStringCb + * @param {number} a + * @returns {string} + */ + +/** + * @template T + * @typedef {T & {name: string}} MixinName + */ + +/** + * Identity function + * + * @template T + * @callback Identity + * @param {T} x + * @returns {T} + */ + +//// [mixed.js] +/** + * @typedef {{x: string} | number | LocalThing | ExportedThing} SomeType + */ +/** + * @param {number} x + * @returns {SomeType} + */ +function doTheThing(x) { + return {x: ""+x}; +} +class ExportedThing { + z = "ok" +} +module.exports = { + doTheThing, + ExportedThing, +}; +class LocalThing { + y = "ok" +} + + +//// [index.js] +"use strict"; +exports.__esModule = true; +/** + * @typedef {string | number | symbol} PropName + */ +/** + * Callback + * + * @callback NumberToStringCb + * @param {number} a + * @returns {string} + */ +/** + * @template T + * @typedef {T & {name: string}} MixinName + */ +/** + * Identity function + * + * @template T + * @callback Identity + * @param {T} x + * @returns {T} + */ +//// [mixed.js] +/** + * @typedef {{x: string} | number | LocalThing | ExportedThing} SomeType + */ +/** + * @param {number} x + * @returns {SomeType} + */ +function doTheThing(x) { + return { x: "" + x }; +} +var ExportedThing = /** @class */ (function () { + function ExportedThing() { + this.z = "ok"; + } + return ExportedThing; +}()); +module.exports = { + doTheThing: doTheThing, + ExportedThing: ExportedThing +}; +var LocalThing = /** @class */ (function () { + function LocalThing() { + this.y = "ok"; + } + return LocalThing; +}()); + + +//// [index.d.ts] +export type PropName = string | number | symbol; +/** + * Callback + */ +export type NumberToStringCb = (a: number) => string; +export type MixinName = T & { + name: string; +}; +/** + * Identity function + */ +export type Identity = (x: T) => T; +//// [mixed.d.ts] +export type SomeType = number | { + x: string; +} | LocalThing | ExportedThing; +/** + * @typedef {{x: string} | number | LocalThing | ExportedThing} SomeType + */ +/** + * @param {number} x + * @returns {SomeType} + */ +export function doTheThing(x: number): number | { + x: string; +} | LocalThing | ExportedThing; +export class ExportedThing { + z: string; +} +declare class LocalThing { + y: string; +} +export {}; diff --git a/tests/baselines/reference/jsDeclarationsTypeAliases.symbols b/tests/baselines/reference/jsDeclarationsTypeAliases.symbols new file mode 100644 index 0000000000000..d8b045e86b609 --- /dev/null +++ b/tests/baselines/reference/jsDeclarationsTypeAliases.symbols @@ -0,0 +1,69 @@ +=== tests/cases/conformance/jsdoc/declarations/index.js === +export {}; // flag file as module +No type information for this code./** +No type information for this code. * @typedef {string | number | symbol} PropName +No type information for this code. */ +No type information for this code. +No type information for this code./** +No type information for this code. * Callback +No type information for this code. * +No type information for this code. * @callback NumberToStringCb +No type information for this code. * @param {number} a +No type information for this code. * @returns {string} +No type information for this code. */ +No type information for this code. +No type information for this code./** +No type information for this code. * @template T +No type information for this code. * @typedef {T & {name: string}} MixinName +No type information for this code. */ +No type information for this code. +No type information for this code./** +No type information for this code. * Identity function +No type information for this code. * +No type information for this code. * @template T +No type information for this code. * @callback Identity +No type information for this code. * @param {T} x +No type information for this code. * @returns {T} +No type information for this code. */ +No type information for this code. +No type information for this code.=== tests/cases/conformance/jsdoc/declarations/mixed.js === +/** + * @typedef {{x: string} | number | LocalThing | ExportedThing} SomeType + */ +/** + * @param {number} x + * @returns {SomeType} + */ +function doTheThing(x) { +>doTheThing : Symbol(doTheThing, Decl(mixed.js, 0, 0)) +>x : Symbol(x, Decl(mixed.js, 7, 20)) + + return {x: ""+x}; +>x : Symbol(x, Decl(mixed.js, 8, 12)) +>x : Symbol(x, Decl(mixed.js, 7, 20)) +} +class ExportedThing { +>ExportedThing : Symbol(ExportedThing, Decl(mixed.js, 9, 1)) + + z = "ok" +>z : Symbol(ExportedThing.z, Decl(mixed.js, 10, 21)) +} +module.exports = { +>module.exports : Symbol("tests/cases/conformance/jsdoc/declarations/mixed", Decl(mixed.js, 0, 0)) +>module : Symbol(export=, Decl(mixed.js, 12, 1)) +>exports : Symbol(export=, Decl(mixed.js, 12, 1)) + + doTheThing, +>doTheThing : Symbol(doTheThing, Decl(mixed.js, 13, 18)) + + ExportedThing, +>ExportedThing : Symbol(ExportedThing, Decl(mixed.js, 14, 15)) + +}; +class LocalThing { +>LocalThing : Symbol(LocalThing, Decl(mixed.js, 16, 2)) + + y = "ok" +>y : Symbol(LocalThing.y, Decl(mixed.js, 17, 18)) +} + diff --git a/tests/baselines/reference/jsDeclarationsTypeAliases.types b/tests/baselines/reference/jsDeclarationsTypeAliases.types new file mode 100644 index 0000000000000..f2581249c251b --- /dev/null +++ b/tests/baselines/reference/jsDeclarationsTypeAliases.types @@ -0,0 +1,76 @@ +=== tests/cases/conformance/jsdoc/declarations/index.js === +export {}; // flag file as module +No type information for this code./** +No type information for this code. * @typedef {string | number | symbol} PropName +No type information for this code. */ +No type information for this code. +No type information for this code./** +No type information for this code. * Callback +No type information for this code. * +No type information for this code. * @callback NumberToStringCb +No type information for this code. * @param {number} a +No type information for this code. * @returns {string} +No type information for this code. */ +No type information for this code. +No type information for this code./** +No type information for this code. * @template T +No type information for this code. * @typedef {T & {name: string}} MixinName +No type information for this code. */ +No type information for this code. +No type information for this code./** +No type information for this code. * Identity function +No type information for this code. * +No type information for this code. * @template T +No type information for this code. * @callback Identity +No type information for this code. * @param {T} x +No type information for this code. * @returns {T} +No type information for this code. */ +No type information for this code. +No type information for this code.=== tests/cases/conformance/jsdoc/declarations/mixed.js === +/** + * @typedef {{x: string} | number | LocalThing | ExportedThing} SomeType + */ +/** + * @param {number} x + * @returns {SomeType} + */ +function doTheThing(x) { +>doTheThing : (x: number) => number | { x: string; } | LocalThing | ExportedThing +>x : number + + return {x: ""+x}; +>{x: ""+x} : { x: string; } +>x : string +>""+x : string +>"" : "" +>x : number +} +class ExportedThing { +>ExportedThing : ExportedThing + + z = "ok" +>z : string +>"ok" : "ok" +} +module.exports = { +>module.exports = { doTheThing, ExportedThing,} : { doTheThing: (x: number) => number | { x: string; } | LocalThing | ExportedThing; ExportedThing: typeof ExportedThing; } +>module.exports : { doTheThing: (x: number) => number | { x: string; } | LocalThing | ExportedThing; ExportedThing: typeof ExportedThing; } +>module : { "tests/cases/conformance/jsdoc/declarations/mixed": { doTheThing: (x: number) => number | { x: string; } | LocalThing | ExportedThing; ExportedThing: typeof ExportedThing; }; } +>exports : { doTheThing: (x: number) => number | { x: string; } | LocalThing | ExportedThing; ExportedThing: typeof ExportedThing; } +>{ doTheThing, ExportedThing,} : { doTheThing: (x: number) => number | { x: string; } | LocalThing | ExportedThing; ExportedThing: typeof ExportedThing; } + + doTheThing, +>doTheThing : (x: number) => number | { x: string; } | LocalThing | ExportedThing + + ExportedThing, +>ExportedThing : typeof ExportedThing + +}; +class LocalThing { +>LocalThing : LocalThing + + y = "ok" +>y : string +>"ok" : "ok" +} + diff --git a/tests/baselines/reference/jsDeclarationsTypeReassignmentFromDeclaration.js b/tests/baselines/reference/jsDeclarationsTypeReassignmentFromDeclaration.js new file mode 100644 index 0000000000000..d7c404f8bb56e --- /dev/null +++ b/tests/baselines/reference/jsDeclarationsTypeReassignmentFromDeclaration.js @@ -0,0 +1,23 @@ +//// [tests/cases/conformance/jsdoc/declarations/jsDeclarationsTypeReassignmentFromDeclaration.ts] //// + +//// [some-mod.d.ts] +interface Item { + x: string; +} +declare const items: Item[]; +export = items; +//// [index.js] +/** @type {typeof import("/some-mod")} */ +const items = []; +module.exports = items; + +//// [index.js] +/** @type {typeof import("/some-mod")} */ +var items = []; +module.exports = items; + + +//// [index.d.ts] +export = items; +/** @type {typeof import("/some-mod")} */ +declare const items: typeof import("/some-mod"); diff --git a/tests/baselines/reference/jsDeclarationsTypeReassignmentFromDeclaration.symbols b/tests/baselines/reference/jsDeclarationsTypeReassignmentFromDeclaration.symbols new file mode 100644 index 0000000000000..96a988e2e113b --- /dev/null +++ b/tests/baselines/reference/jsDeclarationsTypeReassignmentFromDeclaration.symbols @@ -0,0 +1,25 @@ +=== /some-mod.d.ts === +interface Item { +>Item : Symbol(Item, Decl(some-mod.d.ts, 0, 0)) + + x: string; +>x : Symbol(Item.x, Decl(some-mod.d.ts, 0, 16)) +} +declare const items: Item[]; +>items : Symbol(items, Decl(some-mod.d.ts, 3, 13)) +>Item : Symbol(Item, Decl(some-mod.d.ts, 0, 0)) + +export = items; +>items : Symbol(items, Decl(some-mod.d.ts, 3, 13)) + +=== tests/cases/conformance/jsdoc/declarations/index.js === +/** @type {typeof import("/some-mod")} */ +const items = []; +>items : Symbol(items, Decl(index.js, 1, 5)) + +module.exports = items; +>module.exports : Symbol("tests/cases/conformance/jsdoc/declarations/index", Decl(index.js, 0, 0)) +>module : Symbol(export=, Decl(index.js, 1, 17)) +>exports : Symbol(export=, Decl(index.js, 1, 17)) +>items : Symbol(items, Decl(index.js, 1, 5)) + diff --git a/tests/baselines/reference/jsDeclarationsTypeReassignmentFromDeclaration.types b/tests/baselines/reference/jsDeclarationsTypeReassignmentFromDeclaration.types new file mode 100644 index 0000000000000..ed020e5d4993e --- /dev/null +++ b/tests/baselines/reference/jsDeclarationsTypeReassignmentFromDeclaration.types @@ -0,0 +1,24 @@ +=== /some-mod.d.ts === +interface Item { + x: string; +>x : string +} +declare const items: Item[]; +>items : Item[] + +export = items; +>items : Item[] + +=== tests/cases/conformance/jsdoc/declarations/index.js === +/** @type {typeof import("/some-mod")} */ +const items = []; +>items : Item[] +>[] : undefined[] + +module.exports = items; +>module.exports = items : { [n: number]: Item; length: number; toString(): string; toLocaleString(): string; pop(): Item; push(...items: Item[]): number; concat(...items: ConcatArray[]): Item[]; concat(...items: (Item | ConcatArray)[]): Item[]; join(separator?: string): string; reverse(): Item[]; shift(): Item; slice(start?: number, end?: number): Item[]; sort(compareFn?: (a: Item, b: Item) => number): Item[]; splice(start: number, deleteCount?: number): Item[]; splice(start: number, deleteCount: number, ...items: Item[]): Item[]; unshift(...items: Item[]): number; indexOf(searchElement: Item, fromIndex?: number): number; lastIndexOf(searchElement: Item, fromIndex?: number): number; every(callbackfn: (value: Item, index: number, array: Item[]) => unknown, thisArg?: any): boolean; some(callbackfn: (value: Item, index: number, array: Item[]) => unknown, thisArg?: any): boolean; forEach(callbackfn: (value: Item, index: number, array: Item[]) => void, thisArg?: any): void; map(callbackfn: (value: Item, index: number, array: Item[]) => U, thisArg?: any): U[]; filter(callbackfn: (value: Item, index: number, array: Item[]) => value is S, thisArg?: any): S[]; filter(callbackfn: (value: Item, index: number, array: Item[]) => unknown, thisArg?: any): Item[]; reduce(callbackfn: (previousValue: Item, currentValue: Item, currentIndex: number, array: Item[]) => Item): Item; reduce(callbackfn: (previousValue: Item, currentValue: Item, currentIndex: number, array: Item[]) => Item, initialValue: Item): Item; reduce(callbackfn: (previousValue: U, currentValue: Item, currentIndex: number, array: Item[]) => U, initialValue: U): U; reduceRight(callbackfn: (previousValue: Item, currentValue: Item, currentIndex: number, array: Item[]) => Item): Item; reduceRight(callbackfn: (previousValue: Item, currentValue: Item, currentIndex: number, array: Item[]) => Item, initialValue: Item): Item; reduceRight(callbackfn: (previousValue: U, currentValue: Item, currentIndex: number, array: Item[]) => U, initialValue: U): U; find(predicate: (this: void, value: Item, index: number, obj: Item[]) => value is S, thisArg?: any): S; find(predicate: (value: Item, index: number, obj: Item[]) => unknown, thisArg?: any): Item; findIndex(predicate: (value: Item, index: number, obj: Item[]) => unknown, thisArg?: any): number; fill(value: Item, start?: number, end?: number): Item[]; copyWithin(target: number, start: number, end?: number): Item[]; [Symbol.iterator](): IterableIterator; entries(): IterableIterator<[number, Item]>; keys(): IterableIterator; values(): IterableIterator; [Symbol.unscopables](): { copyWithin: boolean; entries: boolean; fill: boolean; find: boolean; findIndex: boolean; keys: boolean; values: boolean; }; } +>module.exports : { [n: number]: Item; length: number; toString(): string; toLocaleString(): string; pop(): Item; push(...items: Item[]): number; concat(...items: ConcatArray[]): Item[]; concat(...items: (Item | ConcatArray)[]): Item[]; join(separator?: string): string; reverse(): Item[]; shift(): Item; slice(start?: number, end?: number): Item[]; sort(compareFn?: (a: Item, b: Item) => number): Item[]; splice(start: number, deleteCount?: number): Item[]; splice(start: number, deleteCount: number, ...items: Item[]): Item[]; unshift(...items: Item[]): number; indexOf(searchElement: Item, fromIndex?: number): number; lastIndexOf(searchElement: Item, fromIndex?: number): number; every(callbackfn: (value: Item, index: number, array: Item[]) => unknown, thisArg?: any): boolean; some(callbackfn: (value: Item, index: number, array: Item[]) => unknown, thisArg?: any): boolean; forEach(callbackfn: (value: Item, index: number, array: Item[]) => void, thisArg?: any): void; map(callbackfn: (value: Item, index: number, array: Item[]) => U, thisArg?: any): U[]; filter(callbackfn: (value: Item, index: number, array: Item[]) => value is S, thisArg?: any): S[]; filter(callbackfn: (value: Item, index: number, array: Item[]) => unknown, thisArg?: any): Item[]; reduce(callbackfn: (previousValue: Item, currentValue: Item, currentIndex: number, array: Item[]) => Item): Item; reduce(callbackfn: (previousValue: Item, currentValue: Item, currentIndex: number, array: Item[]) => Item, initialValue: Item): Item; reduce(callbackfn: (previousValue: U, currentValue: Item, currentIndex: number, array: Item[]) => U, initialValue: U): U; reduceRight(callbackfn: (previousValue: Item, currentValue: Item, currentIndex: number, array: Item[]) => Item): Item; reduceRight(callbackfn: (previousValue: Item, currentValue: Item, currentIndex: number, array: Item[]) => Item, initialValue: Item): Item; reduceRight(callbackfn: (previousValue: U, currentValue: Item, currentIndex: number, array: Item[]) => U, initialValue: U): U; find(predicate: (this: void, value: Item, index: number, obj: Item[]) => value is S, thisArg?: any): S; find(predicate: (value: Item, index: number, obj: Item[]) => unknown, thisArg?: any): Item; findIndex(predicate: (value: Item, index: number, obj: Item[]) => unknown, thisArg?: any): number; fill(value: Item, start?: number, end?: number): Item[]; copyWithin(target: number, start: number, end?: number): Item[]; [Symbol.iterator](): IterableIterator; entries(): IterableIterator<[number, Item]>; keys(): IterableIterator; values(): IterableIterator; [Symbol.unscopables](): { copyWithin: boolean; entries: boolean; fill: boolean; find: boolean; findIndex: boolean; keys: boolean; values: boolean; }; } +>module : { "tests/cases/conformance/jsdoc/declarations/index": { [n: number]: Item; length: number; toString(): string; toLocaleString(): string; pop(): Item; push(...items: Item[]): number; concat(...items: ConcatArray[]): Item[]; concat(...items: (Item | ConcatArray)[]): Item[]; join(separator?: string): string; reverse(): Item[]; shift(): Item; slice(start?: number, end?: number): Item[]; sort(compareFn?: (a: Item, b: Item) => number): Item[]; splice(start: number, deleteCount?: number): Item[]; splice(start: number, deleteCount: number, ...items: Item[]): Item[]; unshift(...items: Item[]): number; indexOf(searchElement: Item, fromIndex?: number): number; lastIndexOf(searchElement: Item, fromIndex?: number): number; every(callbackfn: (value: Item, index: number, array: Item[]) => unknown, thisArg?: any): boolean; some(callbackfn: (value: Item, index: number, array: Item[]) => unknown, thisArg?: any): boolean; forEach(callbackfn: (value: Item, index: number, array: Item[]) => void, thisArg?: any): void; map(callbackfn: (value: Item, index: number, array: Item[]) => U, thisArg?: any): U[]; filter(callbackfn: (value: Item, index: number, array: Item[]) => value is S, thisArg?: any): S[]; filter(callbackfn: (value: Item, index: number, array: Item[]) => unknown, thisArg?: any): Item[]; reduce(callbackfn: (previousValue: Item, currentValue: Item, currentIndex: number, array: Item[]) => Item): Item; reduce(callbackfn: (previousValue: Item, currentValue: Item, currentIndex: number, array: Item[]) => Item, initialValue: Item): Item; reduce(callbackfn: (previousValue: U, currentValue: Item, currentIndex: number, array: Item[]) => U, initialValue: U): U; reduceRight(callbackfn: (previousValue: Item, currentValue: Item, currentIndex: number, array: Item[]) => Item): Item; reduceRight(callbackfn: (previousValue: Item, currentValue: Item, currentIndex: number, array: Item[]) => Item, initialValue: Item): Item; reduceRight(callbackfn: (previousValue: U, currentValue: Item, currentIndex: number, array: Item[]) => U, initialValue: U): U; find(predicate: (this: void, value: Item, index: number, obj: Item[]) => value is S, thisArg?: any): S; find(predicate: (value: Item, index: number, obj: Item[]) => unknown, thisArg?: any): Item; findIndex(predicate: (value: Item, index: number, obj: Item[]) => unknown, thisArg?: any): number; fill(value: Item, start?: number, end?: number): Item[]; copyWithin(target: number, start: number, end?: number): Item[]; [Symbol.iterator](): IterableIterator; entries(): IterableIterator<[number, Item]>; keys(): IterableIterator; values(): IterableIterator; [Symbol.unscopables](): { copyWithin: boolean; entries: boolean; fill: boolean; find: boolean; findIndex: boolean; keys: boolean; values: boolean; }; }; } +>exports : { [n: number]: Item; length: number; toString(): string; toLocaleString(): string; pop(): Item; push(...items: Item[]): number; concat(...items: ConcatArray[]): Item[]; concat(...items: (Item | ConcatArray)[]): Item[]; join(separator?: string): string; reverse(): Item[]; shift(): Item; slice(start?: number, end?: number): Item[]; sort(compareFn?: (a: Item, b: Item) => number): Item[]; splice(start: number, deleteCount?: number): Item[]; splice(start: number, deleteCount: number, ...items: Item[]): Item[]; unshift(...items: Item[]): number; indexOf(searchElement: Item, fromIndex?: number): number; lastIndexOf(searchElement: Item, fromIndex?: number): number; every(callbackfn: (value: Item, index: number, array: Item[]) => unknown, thisArg?: any): boolean; some(callbackfn: (value: Item, index: number, array: Item[]) => unknown, thisArg?: any): boolean; forEach(callbackfn: (value: Item, index: number, array: Item[]) => void, thisArg?: any): void; map(callbackfn: (value: Item, index: number, array: Item[]) => U, thisArg?: any): U[]; filter(callbackfn: (value: Item, index: number, array: Item[]) => value is S, thisArg?: any): S[]; filter(callbackfn: (value: Item, index: number, array: Item[]) => unknown, thisArg?: any): Item[]; reduce(callbackfn: (previousValue: Item, currentValue: Item, currentIndex: number, array: Item[]) => Item): Item; reduce(callbackfn: (previousValue: Item, currentValue: Item, currentIndex: number, array: Item[]) => Item, initialValue: Item): Item; reduce(callbackfn: (previousValue: U, currentValue: Item, currentIndex: number, array: Item[]) => U, initialValue: U): U; reduceRight(callbackfn: (previousValue: Item, currentValue: Item, currentIndex: number, array: Item[]) => Item): Item; reduceRight(callbackfn: (previousValue: Item, currentValue: Item, currentIndex: number, array: Item[]) => Item, initialValue: Item): Item; reduceRight(callbackfn: (previousValue: U, currentValue: Item, currentIndex: number, array: Item[]) => U, initialValue: U): U; find(predicate: (this: void, value: Item, index: number, obj: Item[]) => value is S, thisArg?: any): S; find(predicate: (value: Item, index: number, obj: Item[]) => unknown, thisArg?: any): Item; findIndex(predicate: (value: Item, index: number, obj: Item[]) => unknown, thisArg?: any): number; fill(value: Item, start?: number, end?: number): Item[]; copyWithin(target: number, start: number, end?: number): Item[]; [Symbol.iterator](): IterableIterator; entries(): IterableIterator<[number, Item]>; keys(): IterableIterator; values(): IterableIterator; [Symbol.unscopables](): { copyWithin: boolean; entries: boolean; fill: boolean; find: boolean; findIndex: boolean; keys: boolean; values: boolean; }; } +>items : Item[] + diff --git a/tests/baselines/reference/jsDeclarationsTypeReassignmentFromDeclaration2.errors.txt b/tests/baselines/reference/jsDeclarationsTypeReassignmentFromDeclaration2.errors.txt new file mode 100644 index 0000000000000..b57edcd1c93fb --- /dev/null +++ b/tests/baselines/reference/jsDeclarationsTypeReassignmentFromDeclaration2.errors.txt @@ -0,0 +1,14 @@ +tests/cases/conformance/jsdoc/declarations/index.js(1,1): error TS9006: Declaration emit for this file requires using private name 'Item' from module '"tests/cases/conformance/jsdoc/declarations/some-mod"'. An explicit type annotation may unblock declaration emit. + + +==== tests/cases/conformance/jsdoc/declarations/index.js (1 errors) ==== + const items = require("./some-mod")(); + ~~~~~ +!!! error TS9006: Declaration emit for this file requires using private name 'Item' from module '"tests/cases/conformance/jsdoc/declarations/some-mod"'. An explicit type annotation may unblock declaration emit. + module.exports = items; +==== tests/cases/conformance/jsdoc/declarations/some-mod.d.ts (0 errors) ==== + interface Item { + x: string; + } + declare function getItems(): Item[]; + export = getItems; \ No newline at end of file diff --git a/tests/baselines/reference/jsDeclarationsTypeReassignmentFromDeclaration2.js b/tests/baselines/reference/jsDeclarationsTypeReassignmentFromDeclaration2.js new file mode 100644 index 0000000000000..02068c5cef713 --- /dev/null +++ b/tests/baselines/reference/jsDeclarationsTypeReassignmentFromDeclaration2.js @@ -0,0 +1,15 @@ +//// [tests/cases/conformance/jsdoc/declarations/jsDeclarationsTypeReassignmentFromDeclaration2.ts] //// + +//// [some-mod.d.ts] +interface Item { + x: string; +} +declare function getItems(): Item[]; +export = getItems; +//// [index.js] +const items = require("./some-mod")(); +module.exports = items; + +//// [index.js] +var items = require("./some-mod")(); +module.exports = items; diff --git a/tests/baselines/reference/jsDeclarationsTypeReassignmentFromDeclaration2.symbols b/tests/baselines/reference/jsDeclarationsTypeReassignmentFromDeclaration2.symbols new file mode 100644 index 0000000000000..283b16b647a8d --- /dev/null +++ b/tests/baselines/reference/jsDeclarationsTypeReassignmentFromDeclaration2.symbols @@ -0,0 +1,26 @@ +=== tests/cases/conformance/jsdoc/declarations/index.js === +const items = require("./some-mod")(); +>items : Symbol(items, Decl(index.js, 0, 5)) +>require : Symbol(require) +>"./some-mod" : Symbol("tests/cases/conformance/jsdoc/declarations/some-mod", Decl(some-mod.d.ts, 0, 0)) + +module.exports = items; +>module.exports : Symbol("tests/cases/conformance/jsdoc/declarations/index", Decl(index.js, 0, 0)) +>module : Symbol(export=, Decl(index.js, 0, 38)) +>exports : Symbol(export=, Decl(index.js, 0, 38)) +>items : Symbol(items, Decl(index.js, 0, 5)) + +=== tests/cases/conformance/jsdoc/declarations/some-mod.d.ts === +interface Item { +>Item : Symbol(Item, Decl(some-mod.d.ts, 0, 0)) + + x: string; +>x : Symbol(Item.x, Decl(some-mod.d.ts, 0, 16)) +} +declare function getItems(): Item[]; +>getItems : Symbol(getItems, Decl(some-mod.d.ts, 2, 1)) +>Item : Symbol(Item, Decl(some-mod.d.ts, 0, 0)) + +export = getItems; +>getItems : Symbol(getItems, Decl(some-mod.d.ts, 2, 1)) + diff --git a/tests/baselines/reference/jsDeclarationsTypeReassignmentFromDeclaration2.types b/tests/baselines/reference/jsDeclarationsTypeReassignmentFromDeclaration2.types new file mode 100644 index 0000000000000..db7d35757d18f --- /dev/null +++ b/tests/baselines/reference/jsDeclarationsTypeReassignmentFromDeclaration2.types @@ -0,0 +1,26 @@ +=== tests/cases/conformance/jsdoc/declarations/index.js === +const items = require("./some-mod")(); +>items : Item[] +>require("./some-mod")() : Item[] +>require("./some-mod") : () => Item[] +>require : any +>"./some-mod" : "./some-mod" + +module.exports = items; +>module.exports = items : { [n: number]: Item; length: number; toString(): string; toLocaleString(): string; pop(): Item; push(...items: Item[]): number; concat(...items: ConcatArray[]): Item[]; concat(...items: (Item | ConcatArray)[]): Item[]; join(separator?: string): string; reverse(): Item[]; shift(): Item; slice(start?: number, end?: number): Item[]; sort(compareFn?: (a: Item, b: Item) => number): Item[]; splice(start: number, deleteCount?: number): Item[]; splice(start: number, deleteCount: number, ...items: Item[]): Item[]; unshift(...items: Item[]): number; indexOf(searchElement: Item, fromIndex?: number): number; lastIndexOf(searchElement: Item, fromIndex?: number): number; every(callbackfn: (value: Item, index: number, array: Item[]) => unknown, thisArg?: any): boolean; some(callbackfn: (value: Item, index: number, array: Item[]) => unknown, thisArg?: any): boolean; forEach(callbackfn: (value: Item, index: number, array: Item[]) => void, thisArg?: any): void; map(callbackfn: (value: Item, index: number, array: Item[]) => U, thisArg?: any): U[]; filter(callbackfn: (value: Item, index: number, array: Item[]) => value is S, thisArg?: any): S[]; filter(callbackfn: (value: Item, index: number, array: Item[]) => unknown, thisArg?: any): Item[]; reduce(callbackfn: (previousValue: Item, currentValue: Item, currentIndex: number, array: Item[]) => Item): Item; reduce(callbackfn: (previousValue: Item, currentValue: Item, currentIndex: number, array: Item[]) => Item, initialValue: Item): Item; reduce(callbackfn: (previousValue: U, currentValue: Item, currentIndex: number, array: Item[]) => U, initialValue: U): U; reduceRight(callbackfn: (previousValue: Item, currentValue: Item, currentIndex: number, array: Item[]) => Item): Item; reduceRight(callbackfn: (previousValue: Item, currentValue: Item, currentIndex: number, array: Item[]) => Item, initialValue: Item): Item; reduceRight(callbackfn: (previousValue: U, currentValue: Item, currentIndex: number, array: Item[]) => U, initialValue: U): U; find(predicate: (this: void, value: Item, index: number, obj: Item[]) => value is S, thisArg?: any): S; find(predicate: (value: Item, index: number, obj: Item[]) => unknown, thisArg?: any): Item; findIndex(predicate: (value: Item, index: number, obj: Item[]) => unknown, thisArg?: any): number; fill(value: Item, start?: number, end?: number): Item[]; copyWithin(target: number, start: number, end?: number): Item[]; [Symbol.iterator](): IterableIterator; entries(): IterableIterator<[number, Item]>; keys(): IterableIterator; values(): IterableIterator; [Symbol.unscopables](): { copyWithin: boolean; entries: boolean; fill: boolean; find: boolean; findIndex: boolean; keys: boolean; values: boolean; }; } +>module.exports : { [n: number]: Item; length: number; toString(): string; toLocaleString(): string; pop(): Item; push(...items: Item[]): number; concat(...items: ConcatArray[]): Item[]; concat(...items: (Item | ConcatArray)[]): Item[]; join(separator?: string): string; reverse(): Item[]; shift(): Item; slice(start?: number, end?: number): Item[]; sort(compareFn?: (a: Item, b: Item) => number): Item[]; splice(start: number, deleteCount?: number): Item[]; splice(start: number, deleteCount: number, ...items: Item[]): Item[]; unshift(...items: Item[]): number; indexOf(searchElement: Item, fromIndex?: number): number; lastIndexOf(searchElement: Item, fromIndex?: number): number; every(callbackfn: (value: Item, index: number, array: Item[]) => unknown, thisArg?: any): boolean; some(callbackfn: (value: Item, index: number, array: Item[]) => unknown, thisArg?: any): boolean; forEach(callbackfn: (value: Item, index: number, array: Item[]) => void, thisArg?: any): void; map(callbackfn: (value: Item, index: number, array: Item[]) => U, thisArg?: any): U[]; filter(callbackfn: (value: Item, index: number, array: Item[]) => value is S, thisArg?: any): S[]; filter(callbackfn: (value: Item, index: number, array: Item[]) => unknown, thisArg?: any): Item[]; reduce(callbackfn: (previousValue: Item, currentValue: Item, currentIndex: number, array: Item[]) => Item): Item; reduce(callbackfn: (previousValue: Item, currentValue: Item, currentIndex: number, array: Item[]) => Item, initialValue: Item): Item; reduce(callbackfn: (previousValue: U, currentValue: Item, currentIndex: number, array: Item[]) => U, initialValue: U): U; reduceRight(callbackfn: (previousValue: Item, currentValue: Item, currentIndex: number, array: Item[]) => Item): Item; reduceRight(callbackfn: (previousValue: Item, currentValue: Item, currentIndex: number, array: Item[]) => Item, initialValue: Item): Item; reduceRight(callbackfn: (previousValue: U, currentValue: Item, currentIndex: number, array: Item[]) => U, initialValue: U): U; find(predicate: (this: void, value: Item, index: number, obj: Item[]) => value is S, thisArg?: any): S; find(predicate: (value: Item, index: number, obj: Item[]) => unknown, thisArg?: any): Item; findIndex(predicate: (value: Item, index: number, obj: Item[]) => unknown, thisArg?: any): number; fill(value: Item, start?: number, end?: number): Item[]; copyWithin(target: number, start: number, end?: number): Item[]; [Symbol.iterator](): IterableIterator; entries(): IterableIterator<[number, Item]>; keys(): IterableIterator; values(): IterableIterator; [Symbol.unscopables](): { copyWithin: boolean; entries: boolean; fill: boolean; find: boolean; findIndex: boolean; keys: boolean; values: boolean; }; } +>module : { "tests/cases/conformance/jsdoc/declarations/index": { [n: number]: Item; length: number; toString(): string; toLocaleString(): string; pop(): Item; push(...items: Item[]): number; concat(...items: ConcatArray[]): Item[]; concat(...items: (Item | ConcatArray)[]): Item[]; join(separator?: string): string; reverse(): Item[]; shift(): Item; slice(start?: number, end?: number): Item[]; sort(compareFn?: (a: Item, b: Item) => number): Item[]; splice(start: number, deleteCount?: number): Item[]; splice(start: number, deleteCount: number, ...items: Item[]): Item[]; unshift(...items: Item[]): number; indexOf(searchElement: Item, fromIndex?: number): number; lastIndexOf(searchElement: Item, fromIndex?: number): number; every(callbackfn: (value: Item, index: number, array: Item[]) => unknown, thisArg?: any): boolean; some(callbackfn: (value: Item, index: number, array: Item[]) => unknown, thisArg?: any): boolean; forEach(callbackfn: (value: Item, index: number, array: Item[]) => void, thisArg?: any): void; map(callbackfn: (value: Item, index: number, array: Item[]) => U, thisArg?: any): U[]; filter(callbackfn: (value: Item, index: number, array: Item[]) => value is S, thisArg?: any): S[]; filter(callbackfn: (value: Item, index: number, array: Item[]) => unknown, thisArg?: any): Item[]; reduce(callbackfn: (previousValue: Item, currentValue: Item, currentIndex: number, array: Item[]) => Item): Item; reduce(callbackfn: (previousValue: Item, currentValue: Item, currentIndex: number, array: Item[]) => Item, initialValue: Item): Item; reduce(callbackfn: (previousValue: U, currentValue: Item, currentIndex: number, array: Item[]) => U, initialValue: U): U; reduceRight(callbackfn: (previousValue: Item, currentValue: Item, currentIndex: number, array: Item[]) => Item): Item; reduceRight(callbackfn: (previousValue: Item, currentValue: Item, currentIndex: number, array: Item[]) => Item, initialValue: Item): Item; reduceRight(callbackfn: (previousValue: U, currentValue: Item, currentIndex: number, array: Item[]) => U, initialValue: U): U; find(predicate: (this: void, value: Item, index: number, obj: Item[]) => value is S, thisArg?: any): S; find(predicate: (value: Item, index: number, obj: Item[]) => unknown, thisArg?: any): Item; findIndex(predicate: (value: Item, index: number, obj: Item[]) => unknown, thisArg?: any): number; fill(value: Item, start?: number, end?: number): Item[]; copyWithin(target: number, start: number, end?: number): Item[]; [Symbol.iterator](): IterableIterator; entries(): IterableIterator<[number, Item]>; keys(): IterableIterator; values(): IterableIterator; [Symbol.unscopables](): { copyWithin: boolean; entries: boolean; fill: boolean; find: boolean; findIndex: boolean; keys: boolean; values: boolean; }; }; } +>exports : { [n: number]: Item; length: number; toString(): string; toLocaleString(): string; pop(): Item; push(...items: Item[]): number; concat(...items: ConcatArray[]): Item[]; concat(...items: (Item | ConcatArray)[]): Item[]; join(separator?: string): string; reverse(): Item[]; shift(): Item; slice(start?: number, end?: number): Item[]; sort(compareFn?: (a: Item, b: Item) => number): Item[]; splice(start: number, deleteCount?: number): Item[]; splice(start: number, deleteCount: number, ...items: Item[]): Item[]; unshift(...items: Item[]): number; indexOf(searchElement: Item, fromIndex?: number): number; lastIndexOf(searchElement: Item, fromIndex?: number): number; every(callbackfn: (value: Item, index: number, array: Item[]) => unknown, thisArg?: any): boolean; some(callbackfn: (value: Item, index: number, array: Item[]) => unknown, thisArg?: any): boolean; forEach(callbackfn: (value: Item, index: number, array: Item[]) => void, thisArg?: any): void; map(callbackfn: (value: Item, index: number, array: Item[]) => U, thisArg?: any): U[]; filter(callbackfn: (value: Item, index: number, array: Item[]) => value is S, thisArg?: any): S[]; filter(callbackfn: (value: Item, index: number, array: Item[]) => unknown, thisArg?: any): Item[]; reduce(callbackfn: (previousValue: Item, currentValue: Item, currentIndex: number, array: Item[]) => Item): Item; reduce(callbackfn: (previousValue: Item, currentValue: Item, currentIndex: number, array: Item[]) => Item, initialValue: Item): Item; reduce(callbackfn: (previousValue: U, currentValue: Item, currentIndex: number, array: Item[]) => U, initialValue: U): U; reduceRight(callbackfn: (previousValue: Item, currentValue: Item, currentIndex: number, array: Item[]) => Item): Item; reduceRight(callbackfn: (previousValue: Item, currentValue: Item, currentIndex: number, array: Item[]) => Item, initialValue: Item): Item; reduceRight(callbackfn: (previousValue: U, currentValue: Item, currentIndex: number, array: Item[]) => U, initialValue: U): U; find(predicate: (this: void, value: Item, index: number, obj: Item[]) => value is S, thisArg?: any): S; find(predicate: (value: Item, index: number, obj: Item[]) => unknown, thisArg?: any): Item; findIndex(predicate: (value: Item, index: number, obj: Item[]) => unknown, thisArg?: any): number; fill(value: Item, start?: number, end?: number): Item[]; copyWithin(target: number, start: number, end?: number): Item[]; [Symbol.iterator](): IterableIterator; entries(): IterableIterator<[number, Item]>; keys(): IterableIterator; values(): IterableIterator; [Symbol.unscopables](): { copyWithin: boolean; entries: boolean; fill: boolean; find: boolean; findIndex: boolean; keys: boolean; values: boolean; }; } +>items : Item[] + +=== tests/cases/conformance/jsdoc/declarations/some-mod.d.ts === +interface Item { + x: string; +>x : string +} +declare function getItems(): Item[]; +>getItems : () => Item[] + +export = getItems; +>getItems : () => Item[] + diff --git a/tests/baselines/reference/jsDeclarationsTypeReferences.js b/tests/baselines/reference/jsDeclarationsTypeReferences.js new file mode 100644 index 0000000000000..9e6a95d32e190 --- /dev/null +++ b/tests/baselines/reference/jsDeclarationsTypeReferences.js @@ -0,0 +1,29 @@ +//// [tests/cases/conformance/jsdoc/declarations/jsDeclarationsTypeReferences.ts] //// + +//// [index.d.ts] +declare module "fs" { + export class Something {} +} +//// [index.js] +/// + +const Something = require("fs").Something; + +const thing = new Something(); + +module.exports = { + thing +}; + +//// [index.js] +/// +var Something = require("fs").Something; +var thing = new Something(); +module.exports = { + thing: thing +}; + + +//// [index.d.ts] +/// +export const thing: import("fs").Something; diff --git a/tests/baselines/reference/jsDeclarationsTypeReferences.symbols b/tests/baselines/reference/jsDeclarationsTypeReferences.symbols new file mode 100644 index 0000000000000..258b4d224a807 --- /dev/null +++ b/tests/baselines/reference/jsDeclarationsTypeReferences.symbols @@ -0,0 +1,30 @@ +=== tests/cases/conformance/jsdoc/declarations/index.js === +/// + +const Something = require("fs").Something; +>Something : Symbol(Something, Decl(index.js, 2, 5)) +>require("fs").Something : Symbol(Something, Decl(index.d.ts, 0, 21)) +>require : Symbol(require) +>"fs" : Symbol("fs", Decl(index.d.ts, 0, 0)) +>Something : Symbol(Something, Decl(index.d.ts, 0, 21)) + +const thing = new Something(); +>thing : Symbol(thing, Decl(index.js, 4, 5)) +>Something : Symbol(Something, Decl(index.js, 2, 5)) + +module.exports = { +>module.exports : Symbol("tests/cases/conformance/jsdoc/declarations/index", Decl(index.js, 0, 0)) +>module : Symbol(export=, Decl(index.js, 4, 30)) +>exports : Symbol(export=, Decl(index.js, 4, 30)) + + thing +>thing : Symbol(thing, Decl(index.js, 6, 18)) + +}; +=== tests/cases/conformance/jsdoc/declarations/node_modules/@types/node/index.d.ts === +declare module "fs" { +>"fs" : Symbol("fs", Decl(index.d.ts, 0, 0)) + + export class Something {} +>Something : Symbol(Something, Decl(index.d.ts, 0, 21)) +} diff --git a/tests/baselines/reference/jsDeclarationsTypeReferences.types b/tests/baselines/reference/jsDeclarationsTypeReferences.types new file mode 100644 index 0000000000000..15545aff3a33c --- /dev/null +++ b/tests/baselines/reference/jsDeclarationsTypeReferences.types @@ -0,0 +1,34 @@ +=== tests/cases/conformance/jsdoc/declarations/index.js === +/// + +const Something = require("fs").Something; +>Something : typeof import("fs").Something +>require("fs").Something : typeof import("fs").Something +>require("fs") : typeof import("fs") +>require : any +>"fs" : "fs" +>Something : typeof import("fs").Something + +const thing = new Something(); +>thing : import("fs").Something +>new Something() : import("fs").Something +>Something : typeof import("fs").Something + +module.exports = { +>module.exports = { thing} : { thing: import("fs").Something; } +>module.exports : { thing: import("fs").Something; } +>module : { "tests/cases/conformance/jsdoc/declarations/index": { thing: import("fs").Something; }; } +>exports : { thing: import("fs").Something; } +>{ thing} : { thing: import("fs").Something; } + + thing +>thing : import("fs").Something + +}; +=== tests/cases/conformance/jsdoc/declarations/node_modules/@types/node/index.d.ts === +declare module "fs" { +>"fs" : typeof import("fs") + + export class Something {} +>Something : Something +} diff --git a/tests/baselines/reference/jsDeclarationsTypedefAndImportTypes.js b/tests/baselines/reference/jsDeclarationsTypedefAndImportTypes.js new file mode 100644 index 0000000000000..f8ff0175d9502 --- /dev/null +++ b/tests/baselines/reference/jsDeclarationsTypedefAndImportTypes.js @@ -0,0 +1,95 @@ +//// [tests/cases/conformance/jsdoc/declarations/jsDeclarationsTypedefAndImportTypes.ts] //// + +//// [conn.js] +/** + * @typedef {string | number} Whatever + */ + +class Conn { + constructor() {} + item = 3; + method() {} +} + +module.exports = Conn; + +//// [usage.js] +/** + * @typedef {import("./conn")} Conn + */ + +class Wrap { + /** + * @param {Conn} c + */ + constructor(c) { + this.connItem = c.item; + /** @type {import("./conn").Whatever} */ + this.another = ""; + } +} + +module.exports = { + Wrap +}; + + +//// [conn.js] +/** + * @typedef {string | number} Whatever + */ +var Conn = /** @class */ (function () { + function Conn() { + this.item = 3; + } + Conn.prototype.method = function () { }; + return Conn; +}()); +module.exports = Conn; +//// [usage.js] +/** + * @typedef {import("./conn")} Conn + */ +var Wrap = /** @class */ (function () { + /** + * @param {Conn} c + */ + function Wrap(c) { + this.connItem = c.item; + /** @type {import("./conn").Whatever} */ + this.another = ""; + } + return Wrap; +}()); +module.exports = { + Wrap: Wrap +}; + + +//// [conn.d.ts] +export = Conn; +/** + * @typedef {string | number} Whatever + */ +declare class Conn { + item: number; + method(): void; +} +declare namespace Conn { + export { Whatever }; +} +type Whatever = string | number; +//// [usage.d.ts] +export type Conn = import("./conn"); +/** + * @typedef {import("./conn")} Conn + */ +export class Wrap { + /** + * @param {Conn} c + */ + constructor(c: import("./conn")); + connItem: number; + /** @type {import("./conn").Whatever} */ + another: import("./conn").Whatever; +} diff --git a/tests/baselines/reference/jsDeclarationsTypedefAndImportTypes.symbols b/tests/baselines/reference/jsDeclarationsTypedefAndImportTypes.symbols new file mode 100644 index 0000000000000..460982b6b97da --- /dev/null +++ b/tests/baselines/reference/jsDeclarationsTypedefAndImportTypes.symbols @@ -0,0 +1,62 @@ +=== tests/cases/conformance/jsdoc/declarations/conn.js === +/** + * @typedef {string | number} Whatever + */ + +class Conn { +>Conn : Symbol(Conn, Decl(conn.js, 0, 0)) + + constructor() {} + item = 3; +>item : Symbol(Conn.item, Decl(conn.js, 5, 20)) + + method() {} +>method : Symbol(Conn.method, Decl(conn.js, 6, 13)) +} + +module.exports = Conn; +>module.exports : Symbol("tests/cases/conformance/jsdoc/declarations/conn", Decl(conn.js, 0, 0)) +>module : Symbol(export=, Decl(conn.js, 8, 1)) +>exports : Symbol(export=, Decl(conn.js, 8, 1)) +>Conn : Symbol(Conn, Decl(conn.js, 0, 0)) + +=== tests/cases/conformance/jsdoc/declarations/usage.js === +/** + * @typedef {import("./conn")} Conn + */ + +class Wrap { +>Wrap : Symbol(Wrap, Decl(usage.js, 0, 0)) + + /** + * @param {Conn} c + */ + constructor(c) { +>c : Symbol(c, Decl(usage.js, 8, 16)) + + this.connItem = c.item; +>this.connItem : Symbol(Wrap.connItem, Decl(usage.js, 8, 20)) +>this : Symbol(Wrap, Decl(usage.js, 0, 0)) +>connItem : Symbol(Wrap.connItem, Decl(usage.js, 8, 20)) +>c.item : Symbol(Conn.item, Decl(conn.js, 5, 20)) +>c : Symbol(c, Decl(usage.js, 8, 16)) +>item : Symbol(Conn.item, Decl(conn.js, 5, 20)) + + /** @type {import("./conn").Whatever} */ + this.another = ""; +>this.another : Symbol(Wrap.another, Decl(usage.js, 9, 31)) +>this : Symbol(Wrap, Decl(usage.js, 0, 0)) +>another : Symbol(Wrap.another, Decl(usage.js, 9, 31)) + } +} + +module.exports = { +>module.exports : Symbol("tests/cases/conformance/jsdoc/declarations/usage", Decl(usage.js, 0, 0)) +>module : Symbol(export=, Decl(usage.js, 13, 1)) +>exports : Symbol(export=, Decl(usage.js, 13, 1)) + + Wrap +>Wrap : Symbol(Wrap, Decl(usage.js, 15, 18)) + +}; + diff --git a/tests/baselines/reference/jsDeclarationsTypedefAndImportTypes.types b/tests/baselines/reference/jsDeclarationsTypedefAndImportTypes.types new file mode 100644 index 0000000000000..de61eae51f98d --- /dev/null +++ b/tests/baselines/reference/jsDeclarationsTypedefAndImportTypes.types @@ -0,0 +1,69 @@ +=== tests/cases/conformance/jsdoc/declarations/conn.js === +/** + * @typedef {string | number} Whatever + */ + +class Conn { +>Conn : Conn + + constructor() {} + item = 3; +>item : number +>3 : 3 + + method() {} +>method : () => void +} + +module.exports = Conn; +>module.exports = Conn : typeof Conn +>module.exports : typeof Conn +>module : { "tests/cases/conformance/jsdoc/declarations/conn": typeof Conn; } +>exports : typeof Conn +>Conn : typeof Conn + +=== tests/cases/conformance/jsdoc/declarations/usage.js === +/** + * @typedef {import("./conn")} Conn + */ + +class Wrap { +>Wrap : Wrap + + /** + * @param {Conn} c + */ + constructor(c) { +>c : import("tests/cases/conformance/jsdoc/declarations/conn") + + this.connItem = c.item; +>this.connItem = c.item : number +>this.connItem : number +>this : this +>connItem : number +>c.item : number +>c : import("tests/cases/conformance/jsdoc/declarations/conn") +>item : number + + /** @type {import("./conn").Whatever} */ + this.another = ""; +>this.another = "" : "" +>this.another : string | number +>this : this +>another : string | number +>"" : "" + } +} + +module.exports = { +>module.exports = { Wrap} : { Wrap: typeof Wrap; } +>module.exports : { Wrap: typeof Wrap; } +>module : { "tests/cases/conformance/jsdoc/declarations/usage": { Wrap: typeof Wrap; }; } +>exports : { Wrap: typeof Wrap; } +>{ Wrap} : { Wrap: typeof Wrap; } + + Wrap +>Wrap : typeof Wrap + +}; + diff --git a/tests/baselines/reference/jsDeclarationsTypedefDescriptionsPreserved.js b/tests/baselines/reference/jsDeclarationsTypedefDescriptionsPreserved.js new file mode 100644 index 0000000000000..e30e18fd151e9 --- /dev/null +++ b/tests/baselines/reference/jsDeclarationsTypedefDescriptionsPreserved.js @@ -0,0 +1,64 @@ +//// [index.js] +/** + * Options for Foo <------------ + * @typedef {Object} FooOptions + * @property {boolean} bar - Marvin K Mooney + * @property {string} baz - Sylvester McMonkey McBean + */ + +/** + * Multiline + * Options + * for Foo <------------ + * @typedef {Object} BarOptions + * @property {boolean} bar - Marvin K Mooney + * @property {string} baz - Sylvester McMonkey McBean + */ + + +//// [index.js] +/** + * Options for Foo <------------ + * @typedef {Object} FooOptions + * @property {boolean} bar - Marvin K Mooney + * @property {string} baz - Sylvester McMonkey McBean + */ +/** + * Multiline + * Options + * for Foo <------------ + * @typedef {Object} BarOptions + * @property {boolean} bar - Marvin K Mooney + * @property {string} baz - Sylvester McMonkey McBean + */ + + +//// [index.d.ts] +/** + * Options for Foo <------------ + */ +type FooOptions = { + /** + * - Marvin K Mooney + */ + bar: boolean; + /** + * - Sylvester McMonkey McBean + */ + baz: string; +}; +/** + * Multiline + * Options + * for Foo <------------ + */ +type BarOptions = { + /** + * - Marvin K Mooney + */ + bar: boolean; + /** + * - Sylvester McMonkey McBean + */ + baz: string; +}; diff --git a/tests/baselines/reference/jsDeclarationsTypedefDescriptionsPreserved.symbols b/tests/baselines/reference/jsDeclarationsTypedefDescriptionsPreserved.symbols new file mode 100644 index 0000000000000..da2182e01c45f --- /dev/null +++ b/tests/baselines/reference/jsDeclarationsTypedefDescriptionsPreserved.symbols @@ -0,0 +1,18 @@ +=== tests/cases/conformance/jsdoc/declarations/index.js === +/** +No type information for this code. * Options for Foo <------------ +No type information for this code. * @typedef {Object} FooOptions +No type information for this code. * @property {boolean} bar - Marvin K Mooney +No type information for this code. * @property {string} baz - Sylvester McMonkey McBean +No type information for this code. */ +No type information for this code. +No type information for this code./** +No type information for this code. * Multiline +No type information for this code. * Options +No type information for this code. * for Foo <------------ +No type information for this code. * @typedef {Object} BarOptions +No type information for this code. * @property {boolean} bar - Marvin K Mooney +No type information for this code. * @property {string} baz - Sylvester McMonkey McBean +No type information for this code. */ +No type information for this code. +No type information for this code. \ No newline at end of file diff --git a/tests/baselines/reference/jsDeclarationsTypedefDescriptionsPreserved.types b/tests/baselines/reference/jsDeclarationsTypedefDescriptionsPreserved.types new file mode 100644 index 0000000000000..da2182e01c45f --- /dev/null +++ b/tests/baselines/reference/jsDeclarationsTypedefDescriptionsPreserved.types @@ -0,0 +1,18 @@ +=== tests/cases/conformance/jsdoc/declarations/index.js === +/** +No type information for this code. * Options for Foo <------------ +No type information for this code. * @typedef {Object} FooOptions +No type information for this code. * @property {boolean} bar - Marvin K Mooney +No type information for this code. * @property {string} baz - Sylvester McMonkey McBean +No type information for this code. */ +No type information for this code. +No type information for this code./** +No type information for this code. * Multiline +No type information for this code. * Options +No type information for this code. * for Foo <------------ +No type information for this code. * @typedef {Object} BarOptions +No type information for this code. * @property {boolean} bar - Marvin K Mooney +No type information for this code. * @property {string} baz - Sylvester McMonkey McBean +No type information for this code. */ +No type information for this code. +No type information for this code. \ No newline at end of file diff --git a/tests/baselines/reference/jsDeclarationsTypedefPropertyAndExportAssignment.js b/tests/baselines/reference/jsDeclarationsTypedefPropertyAndExportAssignment.js new file mode 100644 index 0000000000000..590ef5633bba3 --- /dev/null +++ b/tests/baselines/reference/jsDeclarationsTypedefPropertyAndExportAssignment.js @@ -0,0 +1,165 @@ +//// [tests/cases/conformance/jsdoc/declarations/jsDeclarationsTypedefPropertyAndExportAssignment.ts] //// + +//// [module.js] +/** @typedef {'parseHTML'|'styleLayout'} TaskGroupIds */ + +/** + * @typedef TaskGroup + * @property {TaskGroupIds} id + * @property {string} label + * @property {string[]} traceEventNames + */ + +/** + * @type {{[P in TaskGroupIds]: {id: P, label: string}}} + */ +const taskGroups = { + parseHTML: { + id: 'parseHTML', + label: 'Parse HTML & CSS' + }, + styleLayout: { + id: 'styleLayout', + label: 'Style & Layout' + }, +} + +/** @type {Object} */ +const taskNameToGroup = {}; + +module.exports = { + taskGroups, + taskNameToGroup, +}; +//// [index.js] +const {taskGroups, taskNameToGroup} = require('./module.js'); + +/** @typedef {import('./module.js').TaskGroup} TaskGroup */ + +/** + * @typedef TaskNode + * @prop {TaskNode[]} children + * @prop {TaskNode|undefined} parent + * @prop {TaskGroup} group + */ + +/** @typedef {{timers: Map}} PriorTaskData */ +class MainThreadTasks { + /** + * @param {TaskGroup} x + * @param {TaskNode} y + */ + constructor(x, y){} +} + +module.exports = MainThreadTasks; + +//// [module.js] +/** @typedef {'parseHTML'|'styleLayout'} TaskGroupIds */ +/** + * @typedef TaskGroup + * @property {TaskGroupIds} id + * @property {string} label + * @property {string[]} traceEventNames + */ +/** + * @type {{[P in TaskGroupIds]: {id: P, label: string}}} + */ +var taskGroups = { + parseHTML: { + id: 'parseHTML', + label: 'Parse HTML & CSS' + }, + styleLayout: { + id: 'styleLayout', + label: 'Style & Layout' + } +}; +/** @type {Object} */ +var taskNameToGroup = {}; +module.exports = { + taskGroups: taskGroups, + taskNameToGroup: taskNameToGroup +}; +//// [index.js] +var _a = require('./module.js'), taskGroups = _a.taskGroups, taskNameToGroup = _a.taskNameToGroup; +/** @typedef {import('./module.js').TaskGroup} TaskGroup */ +/** + * @typedef TaskNode + * @prop {TaskNode[]} children + * @prop {TaskNode|undefined} parent + * @prop {TaskGroup} group + */ +/** @typedef {{timers: Map}} PriorTaskData */ +var MainThreadTasks = /** @class */ (function () { + /** + * @param {TaskGroup} x + * @param {TaskNode} y + */ + function MainThreadTasks(x, y) { + } + return MainThreadTasks; +}()); +module.exports = MainThreadTasks; + + +//// [module.d.ts] +export type TaskGroupIds = "parseHTML" | "styleLayout"; +export type TaskGroup = { + id: "parseHTML" | "styleLayout"; + label: string; + traceEventNames: string[]; +}; +/** @typedef {'parseHTML'|'styleLayout'} TaskGroupIds */ +/** + * @typedef TaskGroup + * @property {TaskGroupIds} id + * @property {string} label + * @property {string[]} traceEventNames + */ +/** + * @type {{[P in TaskGroupIds]: {id: P, label: string}}} + */ +export const taskGroups: { + [P in TaskGroupIds]: { + id: P; + label: string; + }; +}; +/** @type {Object} */ +export const taskNameToGroup: { + [x: string]: TaskGroup; +}; +//// [index.d.ts] +export = MainThreadTasks; +/** @typedef {import('./module.js').TaskGroup} TaskGroup */ +/** + * @typedef TaskNode + * @prop {TaskNode[]} children + * @prop {TaskNode|undefined} parent + * @prop {TaskGroup} group + */ +/** @typedef {{timers: Map}} PriorTaskData */ +declare class MainThreadTasks { + /** + * @param {TaskGroup} x + * @param {TaskNode} y + */ + constructor(x: import("./module.js").TaskGroup, y: TaskNode); +} +declare namespace MainThreadTasks { + export { TaskGroup, TaskNode, PriorTaskData }; +} +type TaskNode = { + children: TaskNode[]; + parent: TaskNode; + group: import("./module.js").TaskGroup; +}; +type TaskGroup = { + id: "parseHTML" | "styleLayout"; + label: string; + traceEventNames: string[]; +}; +type PriorTaskData = { + timers: Map; +}; diff --git a/tests/baselines/reference/jsDeclarationsTypedefPropertyAndExportAssignment.symbols b/tests/baselines/reference/jsDeclarationsTypedefPropertyAndExportAssignment.symbols new file mode 100644 index 0000000000000..ebe674cf51aa9 --- /dev/null +++ b/tests/baselines/reference/jsDeclarationsTypedefPropertyAndExportAssignment.symbols @@ -0,0 +1,89 @@ +=== tests/cases/conformance/jsdoc/declarations/index.js === +const {taskGroups, taskNameToGroup} = require('./module.js'); +>taskGroups : Symbol(taskGroups, Decl(index.js, 0, 7)) +>taskNameToGroup : Symbol(taskNameToGroup, Decl(index.js, 0, 18)) +>require : Symbol(require) +>'./module.js' : Symbol("tests/cases/conformance/jsdoc/declarations/module", Decl(module.js, 0, 0)) + +/** @typedef {import('./module.js').TaskGroup} TaskGroup */ + +/** + * @typedef TaskNode + * @prop {TaskNode[]} children + * @prop {TaskNode|undefined} parent + * @prop {TaskGroup} group + */ + +/** @typedef {{timers: Map}} PriorTaskData */ +class MainThreadTasks { +>MainThreadTasks : Symbol(MainThreadTasks, Decl(index.js, 0, 61)) + + /** + * @param {TaskGroup} x + * @param {TaskNode} y + */ + constructor(x, y){} +>x : Symbol(x, Decl(index.js, 17, 16)) +>y : Symbol(y, Decl(index.js, 17, 18)) +} + +module.exports = MainThreadTasks; +>module.exports : Symbol("tests/cases/conformance/jsdoc/declarations/index", Decl(index.js, 0, 0)) +>module : Symbol(export=, Decl(index.js, 18, 1)) +>exports : Symbol(export=, Decl(index.js, 18, 1)) +>MainThreadTasks : Symbol(MainThreadTasks, Decl(index.js, 0, 61)) + +=== tests/cases/conformance/jsdoc/declarations/module.js === +/** @typedef {'parseHTML'|'styleLayout'} TaskGroupIds */ + +/** + * @typedef TaskGroup + * @property {TaskGroupIds} id + * @property {string} label + * @property {string[]} traceEventNames + */ + +/** + * @type {{[P in TaskGroupIds]: {id: P, label: string}}} + */ +const taskGroups = { +>taskGroups : Symbol(taskGroups, Decl(module.js, 12, 5)) + + parseHTML: { +>parseHTML : Symbol(parseHTML, Decl(module.js, 12, 20)) + + id: 'parseHTML', +>id : Symbol(id, Decl(module.js, 13, 16)) + + label: 'Parse HTML & CSS' +>label : Symbol(label, Decl(module.js, 14, 24)) + + }, + styleLayout: { +>styleLayout : Symbol(styleLayout, Decl(module.js, 16, 6)) + + id: 'styleLayout', +>id : Symbol(id, Decl(module.js, 17, 18)) + + label: 'Style & Layout' +>label : Symbol(label, Decl(module.js, 18, 26)) + + }, +} + +/** @type {Object} */ +const taskNameToGroup = {}; +>taskNameToGroup : Symbol(taskNameToGroup, Decl(module.js, 24, 5)) + +module.exports = { +>module.exports : Symbol("tests/cases/conformance/jsdoc/declarations/module", Decl(module.js, 0, 0)) +>module : Symbol(export=, Decl(module.js, 24, 27)) +>exports : Symbol(export=, Decl(module.js, 24, 27)) + + taskGroups, +>taskGroups : Symbol(taskGroups, Decl(module.js, 26, 18)) + + taskNameToGroup, +>taskNameToGroup : Symbol(taskNameToGroup, Decl(module.js, 27, 15)) + +}; diff --git a/tests/baselines/reference/jsDeclarationsTypedefPropertyAndExportAssignment.types b/tests/baselines/reference/jsDeclarationsTypedefPropertyAndExportAssignment.types new file mode 100644 index 0000000000000..54433c6d45f17 --- /dev/null +++ b/tests/baselines/reference/jsDeclarationsTypedefPropertyAndExportAssignment.types @@ -0,0 +1,101 @@ +=== tests/cases/conformance/jsdoc/declarations/index.js === +const {taskGroups, taskNameToGroup} = require('./module.js'); +>taskGroups : { parseHTML: { id: "parseHTML"; label: string; }; styleLayout: { id: "styleLayout"; label: string; }; } +>taskNameToGroup : { [x: string]: import("tests/cases/conformance/jsdoc/declarations/module").TaskGroup; } +>require('./module.js') : { taskGroups: { parseHTML: { id: "parseHTML"; label: string; }; styleLayout: { id: "styleLayout"; label: string; }; }; taskNameToGroup: { [x: string]: import("tests/cases/conformance/jsdoc/declarations/module").TaskGroup; }; } +>require : any +>'./module.js' : "./module.js" + +/** @typedef {import('./module.js').TaskGroup} TaskGroup */ + +/** + * @typedef TaskNode + * @prop {TaskNode[]} children + * @prop {TaskNode|undefined} parent + * @prop {TaskGroup} group + */ + +/** @typedef {{timers: Map}} PriorTaskData */ +class MainThreadTasks { +>MainThreadTasks : MainThreadTasks + + /** + * @param {TaskGroup} x + * @param {TaskNode} y + */ + constructor(x, y){} +>x : import("tests/cases/conformance/jsdoc/declarations/module").TaskGroup +>y : TaskNode +} + +module.exports = MainThreadTasks; +>module.exports = MainThreadTasks : typeof MainThreadTasks +>module.exports : typeof MainThreadTasks +>module : { "tests/cases/conformance/jsdoc/declarations/index": typeof MainThreadTasks; } +>exports : typeof MainThreadTasks +>MainThreadTasks : typeof MainThreadTasks + +=== tests/cases/conformance/jsdoc/declarations/module.js === +/** @typedef {'parseHTML'|'styleLayout'} TaskGroupIds */ + +/** + * @typedef TaskGroup + * @property {TaskGroupIds} id + * @property {string} label + * @property {string[]} traceEventNames + */ + +/** + * @type {{[P in TaskGroupIds]: {id: P, label: string}}} + */ +const taskGroups = { +>taskGroups : { parseHTML: { id: "parseHTML"; label: string; }; styleLayout: { id: "styleLayout"; label: string; }; } +>{ parseHTML: { id: 'parseHTML', label: 'Parse HTML & CSS' }, styleLayout: { id: 'styleLayout', label: 'Style & Layout' },} : { parseHTML: { id: "parseHTML"; label: string; }; styleLayout: { id: "styleLayout"; label: string; }; } + + parseHTML: { +>parseHTML : { id: "parseHTML"; label: string; } +>{ id: 'parseHTML', label: 'Parse HTML & CSS' } : { id: "parseHTML"; label: string; } + + id: 'parseHTML', +>id : "parseHTML" +>'parseHTML' : "parseHTML" + + label: 'Parse HTML & CSS' +>label : string +>'Parse HTML & CSS' : "Parse HTML & CSS" + + }, + styleLayout: { +>styleLayout : { id: "styleLayout"; label: string; } +>{ id: 'styleLayout', label: 'Style & Layout' } : { id: "styleLayout"; label: string; } + + id: 'styleLayout', +>id : "styleLayout" +>'styleLayout' : "styleLayout" + + label: 'Style & Layout' +>label : string +>'Style & Layout' : "Style & Layout" + + }, +} + +/** @type {Object} */ +const taskNameToGroup = {}; +>taskNameToGroup : { [x: string]: TaskGroup; } +>{} : {} + +module.exports = { +>module.exports = { taskGroups, taskNameToGroup,} : { taskGroups: { parseHTML: { id: "parseHTML"; label: string; }; styleLayout: { id: "styleLayout"; label: string; }; }; taskNameToGroup: { [x: string]: TaskGroup; }; } +>module.exports : { taskGroups: { parseHTML: { id: "parseHTML"; label: string; }; styleLayout: { id: "styleLayout"; label: string; }; }; taskNameToGroup: { [x: string]: TaskGroup; }; } +>module : { "tests/cases/conformance/jsdoc/declarations/module": { taskGroups: { parseHTML: { id: "parseHTML"; label: string; }; styleLayout: { id: "styleLayout"; label: string; }; }; taskNameToGroup: { [x: string]: TaskGroup; }; }; } +>exports : { taskGroups: { parseHTML: { id: "parseHTML"; label: string; }; styleLayout: { id: "styleLayout"; label: string; }; }; taskNameToGroup: { [x: string]: TaskGroup; }; } +>{ taskGroups, taskNameToGroup,} : { taskGroups: { parseHTML: { id: "parseHTML"; label: string; }; styleLayout: { id: "styleLayout"; label: string; }; }; taskNameToGroup: { [x: string]: TaskGroup; }; } + + taskGroups, +>taskGroups : { parseHTML: { id: "parseHTML"; label: string; }; styleLayout: { id: "styleLayout"; label: string; }; } + + taskNameToGroup, +>taskNameToGroup : { [x: string]: TaskGroup; } + +}; diff --git a/tests/baselines/reference/jsEnumCrossFileExport.symbols b/tests/baselines/reference/jsEnumCrossFileExport.symbols index 0ddc0d5b55128..10bf9c60045ed 100644 --- a/tests/baselines/reference/jsEnumCrossFileExport.symbols +++ b/tests/baselines/reference/jsEnumCrossFileExport.symbols @@ -67,11 +67,13 @@ Other.Cls = class { >this.method : Symbol(Cls.method, Decl(index.js, 1, 19)) >this : Symbol(Cls, Decl(index.js, 1, 11)) >method : Symbol(Cls.method, Decl(index.js, 1, 19)) +>Host.UserMetrics.Action.WindowDocked : Symbol(WindowDocked, Decl(enumDef.js, 3, 27)) >Host.UserMetrics.Action : Symbol(Host.UserMetrics.Action, Decl(enumDef.js, 1, 22), Decl(enumDef.js, 3, 17), Decl(enumDef.js, 2, 4)) >Host.UserMetrics : Symbol(Host.UserMetrics, Decl(enumDef.js, 0, 14), Decl(enumDef.js, 3, 5), Decl(enumDef.js, 15, 5), Decl(enumDef.js, 10, 26)) >Host : Symbol(Host, Decl(enumDef.js, 0, 3), Decl(enumDef.js, 0, 14), Decl(enumDef.js, 1, 22), Decl(enumDef.js, 8, 2), Decl(enumDef.js, 10, 21)) >UserMetrics : Symbol(Host.UserMetrics, Decl(enumDef.js, 0, 14), Decl(enumDef.js, 3, 5), Decl(enumDef.js, 15, 5), Decl(enumDef.js, 10, 26)) >Action : Symbol(Host.UserMetrics.Action, Decl(enumDef.js, 1, 22), Decl(enumDef.js, 3, 17), Decl(enumDef.js, 2, 4)) +>WindowDocked : Symbol(WindowDocked, Decl(enumDef.js, 3, 27)) } } diff --git a/tests/baselines/reference/jsEnumCrossFileExport.types b/tests/baselines/reference/jsEnumCrossFileExport.types index 24acb348ada67..4477b71a99987 100644 --- a/tests/baselines/reference/jsEnumCrossFileExport.types +++ b/tests/baselines/reference/jsEnumCrossFileExport.types @@ -13,11 +13,11 @@ Host.UserMetrics = {}; /** @enum {number} */ Host.UserMetrics.Action = { >Host.UserMetrics.Action = { WindowDocked: 1, WindowUndocked: 2, ScriptsBreakpointSet: 3, TimelineStarted: 4,} : { WindowDocked: number; WindowUndocked: number; ScriptsBreakpointSet: number; TimelineStarted: number; } ->Host.UserMetrics.Action : error +>Host.UserMetrics.Action : { WindowDocked: number; WindowUndocked: number; ScriptsBreakpointSet: number; TimelineStarted: number; } >Host.UserMetrics : typeof Host.UserMetrics >Host : typeof Host >UserMetrics : typeof Host.UserMetrics ->Action : any +>Action : { WindowDocked: number; WindowUndocked: number; ScriptsBreakpointSet: number; TimelineStarted: number; } >{ WindowDocked: 1, WindowUndocked: 2, ScriptsBreakpointSet: 3, TimelineStarted: 4,} : { WindowDocked: number; WindowUndocked: number; ScriptsBreakpointSet: number; TimelineStarted: number; } WindowDocked: 1, @@ -45,11 +45,11 @@ Host.UserMetrics.Action = { */ Host.UserMetrics.Blah = { >Host.UserMetrics.Blah = { x: 12} : { x: number; } ->Host.UserMetrics.Blah : error +>Host.UserMetrics.Blah : { x: number; } >Host.UserMetrics : typeof Host.UserMetrics >Host : typeof Host >UserMetrics : typeof Host.UserMetrics ->Blah : any +>Blah : { x: number; } >{ x: 12} : { x: number; } x: 12 @@ -83,13 +83,13 @@ Other.Cls = class { >this.method : (p: number) => void >this : this >method : (p: number) => void ->Host.UserMetrics.Action.WindowDocked : error ->Host.UserMetrics.Action : any +>Host.UserMetrics.Action.WindowDocked : number +>Host.UserMetrics.Action : { WindowDocked: number; WindowUndocked: number; ScriptsBreakpointSet: number; TimelineStarted: number; } >Host.UserMetrics : typeof Host.UserMetrics >Host : typeof Host >UserMetrics : typeof Host.UserMetrics ->Action : any ->WindowDocked : any +>Action : { WindowDocked: number; WindowUndocked: number; ScriptsBreakpointSet: number; TimelineStarted: number; } +>WindowDocked : number } } diff --git a/tests/baselines/reference/jsEnumTagOnObjectFrozen.symbols b/tests/baselines/reference/jsEnumTagOnObjectFrozen.symbols index 32a9543fbf768..18610423aeaff 100644 --- a/tests/baselines/reference/jsEnumTagOnObjectFrozen.symbols +++ b/tests/baselines/reference/jsEnumTagOnObjectFrozen.symbols @@ -8,7 +8,9 @@ const { Thing, useThing, cbThing } = require("./index"); useThing(Thing.a); >useThing : Symbol(useThing, Decl(usage.js, 0, 14)) +>Thing.a : Symbol(a, Decl(index.js, 1, 29)) >Thing : Symbol(Thing, Decl(usage.js, 0, 7)) +>a : Symbol(a, Decl(index.js, 1, 29)) /** * @typedef {Object} LogEntry diff --git a/tests/baselines/reference/jsEnumTagOnObjectFrozen.types b/tests/baselines/reference/jsEnumTagOnObjectFrozen.types index df50c0635e268..29eb0b7957357 100644 --- a/tests/baselines/reference/jsEnumTagOnObjectFrozen.types +++ b/tests/baselines/reference/jsEnumTagOnObjectFrozen.types @@ -1,6 +1,6 @@ === tests/cases/compiler/usage.js === const { Thing, useThing, cbThing } = require("./index"); ->Thing : any +>Thing : Readonly<{ a: string; b: string; }> >useThing : (x: string) => void >cbThing : (x: (x: string) => void) => void >require("./index") : typeof import("tests/cases/compiler/index") @@ -10,9 +10,9 @@ const { Thing, useThing, cbThing } = require("./index"); useThing(Thing.a); >useThing(Thing.a) : void >useThing : (x: string) => void ->Thing.a : error ->Thing : any ->a : any +>Thing.a : string +>Thing : Readonly<{ a: string; b: string; }> +>a : string /** * @typedef {Object} LogEntry @@ -66,9 +66,9 @@ const Thing = Object.freeze({ exports.Thing = Thing; >exports.Thing = Thing : Readonly<{ a: string; b: string; }> ->exports.Thing : error +>exports.Thing : Readonly<{ a: string; b: string; }> >exports : typeof import("tests/cases/compiler/index") ->Thing : any +>Thing : Readonly<{ a: string; b: string; }> >Thing : Readonly<{ a: string; b: string; }> /** diff --git a/tests/baselines/reference/jsFileCompilationDuplicateFunctionImplementation.errors.txt b/tests/baselines/reference/jsFileCompilationDuplicateFunctionImplementation.errors.txt index b05fc6fa6d944..fb0c214ddf657 100644 --- a/tests/baselines/reference/jsFileCompilationDuplicateFunctionImplementation.errors.txt +++ b/tests/baselines/reference/jsFileCompilationDuplicateFunctionImplementation.errors.txt @@ -1,8 +1,6 @@ -error TS5053: Option 'allowJs' cannot be specified with option 'declaration'. tests/cases/compiler/a.ts(1,10): error TS2393: Duplicate function implementation. -!!! error TS5053: Option 'allowJs' cannot be specified with option 'declaration'. ==== tests/cases/compiler/b.js (0 errors) ==== function foo() { return 10; diff --git a/tests/baselines/reference/jsFileCompilationDuplicateFunctionImplementation.js b/tests/baselines/reference/jsFileCompilationDuplicateFunctionImplementation.js index 9b64450936186..25c804f1088b7 100644 --- a/tests/baselines/reference/jsFileCompilationDuplicateFunctionImplementation.js +++ b/tests/baselines/reference/jsFileCompilationDuplicateFunctionImplementation.js @@ -21,3 +21,5 @@ function foo() { //// [out.d.ts] +declare function foo(): number; +declare function foo(): number; diff --git a/tests/baselines/reference/jsFileCompilationDuplicateFunctionImplementationFileOrderReversed.errors.txt b/tests/baselines/reference/jsFileCompilationDuplicateFunctionImplementationFileOrderReversed.errors.txt index 82dbc27db0f40..78eb22546e8b0 100644 --- a/tests/baselines/reference/jsFileCompilationDuplicateFunctionImplementationFileOrderReversed.errors.txt +++ b/tests/baselines/reference/jsFileCompilationDuplicateFunctionImplementationFileOrderReversed.errors.txt @@ -1,8 +1,6 @@ -error TS5053: Option 'allowJs' cannot be specified with option 'declaration'. tests/cases/compiler/a.ts(1,10): error TS2393: Duplicate function implementation. -!!! error TS5053: Option 'allowJs' cannot be specified with option 'declaration'. ==== tests/cases/compiler/a.ts (1 errors) ==== function foo() { ~~~ diff --git a/tests/baselines/reference/jsFileCompilationDuplicateFunctionImplementationFileOrderReversed.js b/tests/baselines/reference/jsFileCompilationDuplicateFunctionImplementationFileOrderReversed.js index d7965e91be1d3..96e2c603a8320 100644 --- a/tests/baselines/reference/jsFileCompilationDuplicateFunctionImplementationFileOrderReversed.js +++ b/tests/baselines/reference/jsFileCompilationDuplicateFunctionImplementationFileOrderReversed.js @@ -22,3 +22,5 @@ function foo() { //// [out.d.ts] +declare function foo(): number; +declare function foo(): number; diff --git a/tests/baselines/reference/jsFileCompilationDuplicateVariable.errors.txt b/tests/baselines/reference/jsFileCompilationDuplicateVariable.errors.txt deleted file mode 100644 index f8ae4a1ba74cd..0000000000000 --- a/tests/baselines/reference/jsFileCompilationDuplicateVariable.errors.txt +++ /dev/null @@ -1,9 +0,0 @@ -error TS5053: Option 'allowJs' cannot be specified with option 'declaration'. - - -!!! error TS5053: Option 'allowJs' cannot be specified with option 'declaration'. -==== tests/cases/compiler/a.ts (0 errors) ==== - var x = 10; - -==== tests/cases/compiler/b.js (0 errors) ==== - var x = "hello"; // No error is recorded here and declaration file will show this as number \ No newline at end of file diff --git a/tests/baselines/reference/jsFileCompilationDuplicateVariable.js b/tests/baselines/reference/jsFileCompilationDuplicateVariable.js index a70637bc7c066..549bd0dfe9a28 100644 --- a/tests/baselines/reference/jsFileCompilationDuplicateVariable.js +++ b/tests/baselines/reference/jsFileCompilationDuplicateVariable.js @@ -4,12 +4,28 @@ var x = 10; //// [b.js] -var x = "hello"; // No error is recorded here and declaration file will show this as number +var x = "hello"; // Error is recorded here, but suppressed because the js file isn't checked //// [out.js] var x = 10; -var x = "hello"; // No error is recorded here and declaration file will show this as number +var x = "hello"; // Error is recorded here, but suppressed because the js file isn't checked //// [out.d.ts] declare var x: number; +declare var x: string; + + +//// [DtsFileErrors] + + +out.d.ts(2,13): error TS2403: Subsequent variable declarations must have the same type. Variable 'x' must be of type 'number', but here has type 'string'. + + +==== out.d.ts (1 errors) ==== + declare var x: number; + declare var x: string; + ~ +!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'x' must be of type 'number', but here has type 'string'. +!!! related TS6203 out.d.ts:1:13: 'x' was also declared here. + \ No newline at end of file diff --git a/tests/baselines/reference/jsFileCompilationDuplicateVariable.symbols b/tests/baselines/reference/jsFileCompilationDuplicateVariable.symbols index 9bfc61a64f85a..a82dee6bb9344 100644 --- a/tests/baselines/reference/jsFileCompilationDuplicateVariable.symbols +++ b/tests/baselines/reference/jsFileCompilationDuplicateVariable.symbols @@ -3,6 +3,6 @@ var x = 10; >x : Symbol(x, Decl(a.ts, 0, 3), Decl(b.js, 0, 3)) === tests/cases/compiler/b.js === -var x = "hello"; // No error is recorded here and declaration file will show this as number +var x = "hello"; // Error is recorded here, but suppressed because the js file isn't checked >x : Symbol(x, Decl(a.ts, 0, 3), Decl(b.js, 0, 3)) diff --git a/tests/baselines/reference/jsFileCompilationDuplicateVariable.types b/tests/baselines/reference/jsFileCompilationDuplicateVariable.types index bcd115b1577b9..bd82bb53df6d0 100644 --- a/tests/baselines/reference/jsFileCompilationDuplicateVariable.types +++ b/tests/baselines/reference/jsFileCompilationDuplicateVariable.types @@ -4,7 +4,7 @@ var x = 10; >10 : 10 === tests/cases/compiler/b.js === -var x = "hello"; // No error is recorded here and declaration file will show this as number +var x = "hello"; // Error is recorded here, but suppressed because the js file isn't checked >x : number >"hello" : "hello" diff --git a/tests/baselines/reference/jsFileCompilationDuplicateVariableErrorReported.errors.txt b/tests/baselines/reference/jsFileCompilationDuplicateVariableErrorReported.errors.txt index 9e46d6225a2c8..540970836d656 100644 --- a/tests/baselines/reference/jsFileCompilationDuplicateVariableErrorReported.errors.txt +++ b/tests/baselines/reference/jsFileCompilationDuplicateVariableErrorReported.errors.txt @@ -1,13 +1,11 @@ -error TS5053: Option 'allowJs' cannot be specified with option 'declaration'. tests/cases/compiler/a.ts(1,5): error TS2403: Subsequent variable declarations must have the same type. Variable 'x' must be of type 'string', but here has type 'number'. -!!! error TS5053: Option 'allowJs' cannot be specified with option 'declaration'. ==== tests/cases/compiler/b.js (0 errors) ==== var x = "hello"; ==== tests/cases/compiler/a.ts (1 errors) ==== - var x = 10; // Error reported so no declaration file generated? + var x = 10; // Error reported ~ !!! error TS2403: Subsequent variable declarations must have the same type. Variable 'x' must be of type 'string', but here has type 'number'. !!! related TS6203 tests/cases/compiler/b.js:1:5: 'x' was also declared here. \ No newline at end of file diff --git a/tests/baselines/reference/jsFileCompilationDuplicateVariableErrorReported.js b/tests/baselines/reference/jsFileCompilationDuplicateVariableErrorReported.js index fd9da7c71066b..83b33fdd02b4d 100644 --- a/tests/baselines/reference/jsFileCompilationDuplicateVariableErrorReported.js +++ b/tests/baselines/reference/jsFileCompilationDuplicateVariableErrorReported.js @@ -4,12 +4,13 @@ var x = "hello"; //// [a.ts] -var x = 10; // Error reported so no declaration file generated? +var x = 10; // Error reported //// [out.js] var x = "hello"; -var x = 10; // Error reported so no declaration file generated? +var x = 10; // Error reported //// [out.d.ts] declare var x: string; +declare var x: string; diff --git a/tests/baselines/reference/jsFileCompilationDuplicateVariableErrorReported.symbols b/tests/baselines/reference/jsFileCompilationDuplicateVariableErrorReported.symbols index 0b1360f8f5abe..f6f944c8642bc 100644 --- a/tests/baselines/reference/jsFileCompilationDuplicateVariableErrorReported.symbols +++ b/tests/baselines/reference/jsFileCompilationDuplicateVariableErrorReported.symbols @@ -3,6 +3,6 @@ var x = "hello"; >x : Symbol(x, Decl(b.js, 0, 3), Decl(a.ts, 0, 3)) === tests/cases/compiler/a.ts === -var x = 10; // Error reported so no declaration file generated? +var x = 10; // Error reported >x : Symbol(x, Decl(b.js, 0, 3), Decl(a.ts, 0, 3)) diff --git a/tests/baselines/reference/jsFileCompilationDuplicateVariableErrorReported.types b/tests/baselines/reference/jsFileCompilationDuplicateVariableErrorReported.types index b88f42f0c28a9..48a2ee9e9ef0a 100644 --- a/tests/baselines/reference/jsFileCompilationDuplicateVariableErrorReported.types +++ b/tests/baselines/reference/jsFileCompilationDuplicateVariableErrorReported.types @@ -4,7 +4,7 @@ var x = "hello"; >"hello" : "hello" === tests/cases/compiler/a.ts === -var x = 10; // Error reported so no declaration file generated? +var x = 10; // Error reported >x : string >10 : 10 diff --git a/tests/baselines/reference/jsFileCompilationEmitDeclarations.errors.txt b/tests/baselines/reference/jsFileCompilationEmitDeclarations.errors.txt deleted file mode 100644 index 3e89f9c9436f5..0000000000000 --- a/tests/baselines/reference/jsFileCompilationEmitDeclarations.errors.txt +++ /dev/null @@ -1,12 +0,0 @@ -error TS5053: Option 'allowJs' cannot be specified with option 'declaration'. - - -!!! error TS5053: Option 'allowJs' cannot be specified with option 'declaration'. -==== tests/cases/compiler/a.ts (0 errors) ==== - class c { - } - -==== tests/cases/compiler/b.js (0 errors) ==== - function foo() { - } - \ No newline at end of file diff --git a/tests/baselines/reference/jsFileCompilationEmitDeclarations.js b/tests/baselines/reference/jsFileCompilationEmitDeclarations.js index 312f3b6b22953..2671a580cbc7e 100644 --- a/tests/baselines/reference/jsFileCompilationEmitDeclarations.js +++ b/tests/baselines/reference/jsFileCompilationEmitDeclarations.js @@ -22,3 +22,4 @@ function foo() { //// [out.d.ts] declare class c { } +declare function foo(): void; diff --git a/tests/baselines/reference/jsFileCompilationEmitTrippleSlashReference.errors.txt b/tests/baselines/reference/jsFileCompilationEmitTrippleSlashReference.errors.txt deleted file mode 100644 index 0cefa2eedac20..0000000000000 --- a/tests/baselines/reference/jsFileCompilationEmitTrippleSlashReference.errors.txt +++ /dev/null @@ -1,16 +0,0 @@ -error TS5053: Option 'allowJs' cannot be specified with option 'declaration'. - - -!!! error TS5053: Option 'allowJs' cannot be specified with option 'declaration'. -==== tests/cases/compiler/a.ts (0 errors) ==== - class c { - } - -==== tests/cases/compiler/b.js (0 errors) ==== - /// - function foo() { - } - -==== tests/cases/compiler/c.js (0 errors) ==== - function bar() { - } \ No newline at end of file diff --git a/tests/baselines/reference/jsFileCompilationEmitTrippleSlashReference.js b/tests/baselines/reference/jsFileCompilationEmitTrippleSlashReference.js index 625c09964c065..128ec0c3e357e 100644 --- a/tests/baselines/reference/jsFileCompilationEmitTrippleSlashReference.js +++ b/tests/baselines/reference/jsFileCompilationEmitTrippleSlashReference.js @@ -29,3 +29,5 @@ function foo() { //// [out.d.ts] declare class c { } +declare function bar(): void; +declare function foo(): void; diff --git a/tests/baselines/reference/jsFileCompilationErrorOnDeclarationsWithJsFileReferenceWithNoOut.errors.txt b/tests/baselines/reference/jsFileCompilationErrorOnDeclarationsWithJsFileReferenceWithNoOut.errors.txt index c9937ecd3592e..b19009a468b97 100644 --- a/tests/baselines/reference/jsFileCompilationErrorOnDeclarationsWithJsFileReferenceWithNoOut.errors.txt +++ b/tests/baselines/reference/jsFileCompilationErrorOnDeclarationsWithJsFileReferenceWithNoOut.errors.txt @@ -1,9 +1,7 @@ -error TS5053: Option 'allowJs' cannot be specified with option 'declaration'. error TS5055: Cannot write file 'tests/cases/compiler/c.js' because it would overwrite input file. Adding a tsconfig.json file will help organize projects that contain both TypeScript and JavaScript files. Learn more at https://aka.ms/tsconfig. -!!! error TS5053: Option 'allowJs' cannot be specified with option 'declaration'. !!! error TS5055: Cannot write file 'tests/cases/compiler/c.js' because it would overwrite input file. !!! error TS5055: Adding a tsconfig.json file will help organize projects that contain both TypeScript and JavaScript files. Learn more at https://aka.ms/tsconfig. ==== tests/cases/compiler/a.ts (0 errors) ==== @@ -12,7 +10,7 @@ error TS5055: Cannot write file 'tests/cases/compiler/c.js' because it would ove ==== tests/cases/compiler/b.ts (0 errors) ==== /// - // b.d.ts should have c.js as the reference path since we dont emit declarations for js files + // b.d.ts should have c.d.ts as the reference path function foo() { } diff --git a/tests/baselines/reference/jsFileCompilationErrorOnDeclarationsWithJsFileReferenceWithNoOut.js b/tests/baselines/reference/jsFileCompilationErrorOnDeclarationsWithJsFileReferenceWithNoOut.js index f9dcb3b2f71a8..7a0942b5ac718 100644 --- a/tests/baselines/reference/jsFileCompilationErrorOnDeclarationsWithJsFileReferenceWithNoOut.js +++ b/tests/baselines/reference/jsFileCompilationErrorOnDeclarationsWithJsFileReferenceWithNoOut.js @@ -6,7 +6,7 @@ class c { //// [b.ts] /// -// b.d.ts should have c.js as the reference path since we dont emit declarations for js files +// b.d.ts should have c.d.ts as the reference path function foo() { } @@ -22,7 +22,7 @@ var c = /** @class */ (function () { }()); //// [b.js] /// -// b.d.ts should have c.js as the reference path since we dont emit declarations for js files +// b.d.ts should have c.d.ts as the reference path function foo() { } @@ -30,6 +30,8 @@ function foo() { //// [a.d.ts] declare class c { } +//// [c.d.ts] +declare function bar(): void; //// [b.d.ts] -/// +/// declare function foo(): void; diff --git a/tests/baselines/reference/jsFileCompilationErrorOnDeclarationsWithJsFileReferenceWithNoOut.symbols b/tests/baselines/reference/jsFileCompilationErrorOnDeclarationsWithJsFileReferenceWithNoOut.symbols index 424fd85c16587..7f3b8e3c6f158 100644 --- a/tests/baselines/reference/jsFileCompilationErrorOnDeclarationsWithJsFileReferenceWithNoOut.symbols +++ b/tests/baselines/reference/jsFileCompilationErrorOnDeclarationsWithJsFileReferenceWithNoOut.symbols @@ -5,7 +5,7 @@ class c { === tests/cases/compiler/b.ts === /// -// b.d.ts should have c.js as the reference path since we dont emit declarations for js files +// b.d.ts should have c.d.ts as the reference path function foo() { >foo : Symbol(foo, Decl(b.ts, 0, 0)) } diff --git a/tests/baselines/reference/jsFileCompilationErrorOnDeclarationsWithJsFileReferenceWithNoOut.types b/tests/baselines/reference/jsFileCompilationErrorOnDeclarationsWithJsFileReferenceWithNoOut.types index f8b82383ac47c..5ef6333da21c0 100644 --- a/tests/baselines/reference/jsFileCompilationErrorOnDeclarationsWithJsFileReferenceWithNoOut.types +++ b/tests/baselines/reference/jsFileCompilationErrorOnDeclarationsWithJsFileReferenceWithNoOut.types @@ -5,7 +5,7 @@ class c { === tests/cases/compiler/b.ts === /// -// b.d.ts should have c.js as the reference path since we dont emit declarations for js files +// b.d.ts should have c.d.ts as the reference path function foo() { >foo : () => void } diff --git a/tests/baselines/reference/jsFileCompilationErrorOnDeclarationsWithJsFileReferenceWithOut.errors.txt b/tests/baselines/reference/jsFileCompilationErrorOnDeclarationsWithJsFileReferenceWithOut.errors.txt deleted file mode 100644 index 441514014799d..0000000000000 --- a/tests/baselines/reference/jsFileCompilationErrorOnDeclarationsWithJsFileReferenceWithOut.errors.txt +++ /dev/null @@ -1,17 +0,0 @@ -error TS5053: Option 'allowJs' cannot be specified with option 'declaration'. - - -!!! error TS5053: Option 'allowJs' cannot be specified with option 'declaration'. -==== tests/cases/compiler/a.ts (0 errors) ==== - class c { - } - -==== tests/cases/compiler/b.ts (0 errors) ==== - /// - // error on above reference when emitting declarations - function foo() { - } - -==== tests/cases/compiler/c.js (0 errors) ==== - function bar() { - } \ No newline at end of file diff --git a/tests/baselines/reference/jsFileCompilationErrorOnDeclarationsWithJsFileReferenceWithOut.js b/tests/baselines/reference/jsFileCompilationErrorOnDeclarationsWithJsFileReferenceWithOut.js index e10b3e43fb854..9c60af0c79c06 100644 --- a/tests/baselines/reference/jsFileCompilationErrorOnDeclarationsWithJsFileReferenceWithOut.js +++ b/tests/baselines/reference/jsFileCompilationErrorOnDeclarationsWithJsFileReferenceWithOut.js @@ -6,7 +6,6 @@ class c { //// [b.ts] /// -// error on above reference when emitting declarations function foo() { } @@ -23,13 +22,12 @@ var c = /** @class */ (function () { function bar() { } /// -// error on above reference when emitting declarations function foo() { } //// [out.d.ts] -/// declare class c { } +declare function bar(): void; declare function foo(): void; diff --git a/tests/baselines/reference/jsFileCompilationErrorOnDeclarationsWithJsFileReferenceWithOut.symbols b/tests/baselines/reference/jsFileCompilationErrorOnDeclarationsWithJsFileReferenceWithOut.symbols index 544fe53f425af..967d023d2c2f8 100644 --- a/tests/baselines/reference/jsFileCompilationErrorOnDeclarationsWithJsFileReferenceWithOut.symbols +++ b/tests/baselines/reference/jsFileCompilationErrorOnDeclarationsWithJsFileReferenceWithOut.symbols @@ -5,7 +5,6 @@ class c { === tests/cases/compiler/b.ts === /// -// error on above reference when emitting declarations function foo() { >foo : Symbol(foo, Decl(b.ts, 0, 0)) } diff --git a/tests/baselines/reference/jsFileCompilationErrorOnDeclarationsWithJsFileReferenceWithOut.types b/tests/baselines/reference/jsFileCompilationErrorOnDeclarationsWithJsFileReferenceWithOut.types index 8aafb9f61d034..b34de54d704f8 100644 --- a/tests/baselines/reference/jsFileCompilationErrorOnDeclarationsWithJsFileReferenceWithOut.types +++ b/tests/baselines/reference/jsFileCompilationErrorOnDeclarationsWithJsFileReferenceWithOut.types @@ -5,7 +5,6 @@ class c { === tests/cases/compiler/b.ts === /// -// error on above reference when emitting declarations function foo() { >foo : () => void } diff --git a/tests/baselines/reference/jsFileCompilationErrorOnDeclarationsWithJsFileReferenceWithOutDir.errors.txt b/tests/baselines/reference/jsFileCompilationErrorOnDeclarationsWithJsFileReferenceWithOutDir.errors.txt deleted file mode 100644 index fb6c801b42e7c..0000000000000 --- a/tests/baselines/reference/jsFileCompilationErrorOnDeclarationsWithJsFileReferenceWithOutDir.errors.txt +++ /dev/null @@ -1,17 +0,0 @@ -error TS5053: Option 'allowJs' cannot be specified with option 'declaration'. - - -!!! error TS5053: Option 'allowJs' cannot be specified with option 'declaration'. -==== tests/cases/compiler/a.ts (0 errors) ==== - class c { - } - -==== tests/cases/compiler/b.ts (0 errors) ==== - /// - // b.d.ts should have c.js as the reference path since we dont emit declarations for js files - function foo() { - } - -==== tests/cases/compiler/c.js (0 errors) ==== - function bar() { - } \ No newline at end of file diff --git a/tests/baselines/reference/jsFileCompilationErrorOnDeclarationsWithJsFileReferenceWithOutDir.js b/tests/baselines/reference/jsFileCompilationErrorOnDeclarationsWithJsFileReferenceWithOutDir.js index 5e12d775bb139..fe570fb330791 100644 --- a/tests/baselines/reference/jsFileCompilationErrorOnDeclarationsWithJsFileReferenceWithOutDir.js +++ b/tests/baselines/reference/jsFileCompilationErrorOnDeclarationsWithJsFileReferenceWithOutDir.js @@ -6,7 +6,6 @@ class c { //// [b.ts] /// -// b.d.ts should have c.js as the reference path since we dont emit declarations for js files function foo() { } @@ -25,7 +24,6 @@ function bar() { } //// [b.js] /// -// b.d.ts should have c.js as the reference path since we dont emit declarations for js files function foo() { } @@ -33,6 +31,8 @@ function foo() { //// [a.d.ts] declare class c { } +//// [c.d.ts] +declare function bar(): void; //// [b.d.ts] -/// +/// declare function foo(): void; diff --git a/tests/baselines/reference/jsFileCompilationErrorOnDeclarationsWithJsFileReferenceWithOutDir.symbols b/tests/baselines/reference/jsFileCompilationErrorOnDeclarationsWithJsFileReferenceWithOutDir.symbols index 424fd85c16587..967d023d2c2f8 100644 --- a/tests/baselines/reference/jsFileCompilationErrorOnDeclarationsWithJsFileReferenceWithOutDir.symbols +++ b/tests/baselines/reference/jsFileCompilationErrorOnDeclarationsWithJsFileReferenceWithOutDir.symbols @@ -5,7 +5,6 @@ class c { === tests/cases/compiler/b.ts === /// -// b.d.ts should have c.js as the reference path since we dont emit declarations for js files function foo() { >foo : Symbol(foo, Decl(b.ts, 0, 0)) } diff --git a/tests/baselines/reference/jsFileCompilationErrorOnDeclarationsWithJsFileReferenceWithOutDir.types b/tests/baselines/reference/jsFileCompilationErrorOnDeclarationsWithJsFileReferenceWithOutDir.types index f8b82383ac47c..b34de54d704f8 100644 --- a/tests/baselines/reference/jsFileCompilationErrorOnDeclarationsWithJsFileReferenceWithOutDir.types +++ b/tests/baselines/reference/jsFileCompilationErrorOnDeclarationsWithJsFileReferenceWithOutDir.types @@ -5,7 +5,6 @@ class c { === tests/cases/compiler/b.ts === /// -// b.d.ts should have c.js as the reference path since we dont emit declarations for js files function foo() { >foo : () => void } diff --git a/tests/baselines/reference/jsFileCompilationLetDeclarationOrder.errors.txt b/tests/baselines/reference/jsFileCompilationLetDeclarationOrder.errors.txt deleted file mode 100644 index 20a9c81ea9c62..0000000000000 --- a/tests/baselines/reference/jsFileCompilationLetDeclarationOrder.errors.txt +++ /dev/null @@ -1,12 +0,0 @@ -error TS5053: Option 'allowJs' cannot be specified with option 'declaration'. - - -!!! error TS5053: Option 'allowJs' cannot be specified with option 'declaration'. -==== tests/cases/compiler/b.js (0 errors) ==== - let a = 10; - b = 30; - -==== tests/cases/compiler/a.ts (0 errors) ==== - let b = 30; - a = 10; - \ No newline at end of file diff --git a/tests/baselines/reference/jsFileCompilationLetDeclarationOrder.js b/tests/baselines/reference/jsFileCompilationLetDeclarationOrder.js index 16e4b7a3011f2..15a1e8d753354 100644 --- a/tests/baselines/reference/jsFileCompilationLetDeclarationOrder.js +++ b/tests/baselines/reference/jsFileCompilationLetDeclarationOrder.js @@ -17,4 +17,5 @@ a = 10; //// [out.d.ts] +declare let a: number; declare let b: number; diff --git a/tests/baselines/reference/jsFileCompilationLetDeclarationOrder2.errors.txt b/tests/baselines/reference/jsFileCompilationLetDeclarationOrder2.errors.txt index 6fc8df185006c..4ffbabdd06394 100644 --- a/tests/baselines/reference/jsFileCompilationLetDeclarationOrder2.errors.txt +++ b/tests/baselines/reference/jsFileCompilationLetDeclarationOrder2.errors.txt @@ -1,8 +1,6 @@ -error TS5053: Option 'allowJs' cannot be specified with option 'declaration'. tests/cases/compiler/a.ts(2,1): error TS2448: Block-scoped variable 'a' used before its declaration. -!!! error TS5053: Option 'allowJs' cannot be specified with option 'declaration'. ==== tests/cases/compiler/a.ts (1 errors) ==== let b = 30; a = 10; diff --git a/tests/baselines/reference/jsFileCompilationLetDeclarationOrder2.js b/tests/baselines/reference/jsFileCompilationLetDeclarationOrder2.js index 890b1c22f717e..641a89c1c5049 100644 --- a/tests/baselines/reference/jsFileCompilationLetDeclarationOrder2.js +++ b/tests/baselines/reference/jsFileCompilationLetDeclarationOrder2.js @@ -17,3 +17,4 @@ b = 30; //// [out.d.ts] declare let b: number; +declare let a: number; diff --git a/tests/baselines/reference/jsFileCompilationWithEnabledCompositeOption.errors.txt b/tests/baselines/reference/jsFileCompilationWithEnabledCompositeOption.errors.txt deleted file mode 100644 index 7133188adc0ca..0000000000000 --- a/tests/baselines/reference/jsFileCompilationWithEnabledCompositeOption.errors.txt +++ /dev/null @@ -1,12 +0,0 @@ -error TS5053: Option 'allowJs' cannot be specified with option 'composite'. - - -!!! error TS5053: Option 'allowJs' cannot be specified with option 'composite'. -==== tests/cases/compiler/a.ts (0 errors) ==== - class c { - } - -==== tests/cases/compiler/b.js (0 errors) ==== - function foo() { - } - \ No newline at end of file diff --git a/tests/baselines/reference/jsFileCompilationWithEnabledCompositeOption.js b/tests/baselines/reference/jsFileCompilationWithEnabledCompositeOption.js index e34edb10ff426..9a1dbcd530140 100644 --- a/tests/baselines/reference/jsFileCompilationWithEnabledCompositeOption.js +++ b/tests/baselines/reference/jsFileCompilationWithEnabledCompositeOption.js @@ -22,3 +22,4 @@ function foo() { //// [out.d.ts] declare class c { } +declare function foo(): void; diff --git a/tests/baselines/reference/jsdocImportType.types b/tests/baselines/reference/jsdocImportType.types index a5d3844388a4c..66b01b1a5c75d 100644 --- a/tests/baselines/reference/jsdocImportType.types +++ b/tests/baselines/reference/jsdocImportType.types @@ -3,26 +3,26 @@ /** @typedef {import("./mod1")} C * @type {C} */ var c; ->c : Chunk +>c : import("tests/cases/conformance/jsdoc/mod1") c.chunk; >c.chunk : number ->c : Chunk +>c : import("tests/cases/conformance/jsdoc/mod1") >chunk : number const D = require("./mod1"); ->D : typeof Chunk ->require("./mod1") : typeof Chunk +>D : typeof import("tests/cases/conformance/jsdoc/mod1") +>require("./mod1") : typeof import("tests/cases/conformance/jsdoc/mod1") >require : (name: string) => any >"./mod1" : "./mod1" /** @type {D} */ var d; ->d : Chunk +>d : import("tests/cases/conformance/jsdoc/mod1") d.chunk; >d.chunk : number ->d : Chunk +>d : import("tests/cases/conformance/jsdoc/mod1") >chunk : number === tests/cases/conformance/jsdoc/types.d.ts === diff --git a/tests/baselines/reference/jsdocImportType2.types b/tests/baselines/reference/jsdocImportType2.types index 817b754069aae..a75c4fa0738f9 100644 --- a/tests/baselines/reference/jsdocImportType2.types +++ b/tests/baselines/reference/jsdocImportType2.types @@ -3,26 +3,26 @@ /** @typedef {import("./mod1")} C * @type {C} */ var c; ->c : Chunk +>c : import("tests/cases/conformance/jsdoc/mod1") c.chunk; >c.chunk : number ->c : Chunk +>c : import("tests/cases/conformance/jsdoc/mod1") >chunk : number const D = require("./mod1"); ->D : typeof Chunk ->require("./mod1") : typeof Chunk +>D : typeof import("tests/cases/conformance/jsdoc/mod1") +>require("./mod1") : typeof import("tests/cases/conformance/jsdoc/mod1") >require : (name: string) => any >"./mod1" : "./mod1" /** @type {D} */ var d; ->d : Chunk +>d : import("tests/cases/conformance/jsdoc/mod1") d.chunk; >d.chunk : number ->d : Chunk +>d : import("tests/cases/conformance/jsdoc/mod1") >chunk : number === tests/cases/conformance/jsdoc/types.d.ts === @@ -40,12 +40,12 @@ declare var module: { exports: any }; === tests/cases/conformance/jsdoc/mod1.js === /// module.exports = class Chunk { ->module.exports = class Chunk { constructor() { this.chunk = 1; }} : typeof Chunk ->module.exports : typeof Chunk ->module : { "tests/cases/conformance/jsdoc/mod1": typeof Chunk; } ->exports : typeof Chunk ->class Chunk { constructor() { this.chunk = 1; }} : typeof Chunk ->Chunk : typeof Chunk +>module.exports = class Chunk { constructor() { this.chunk = 1; }} : typeof import("tests/cases/conformance/jsdoc/mod1") +>module.exports : typeof import("tests/cases/conformance/jsdoc/mod1") +>module : { "tests/cases/conformance/jsdoc/mod1": typeof import("tests/cases/conformance/jsdoc/mod1"); } +>exports : typeof import("tests/cases/conformance/jsdoc/mod1") +>class Chunk { constructor() { this.chunk = 1; }} : typeof import("tests/cases/conformance/jsdoc/mod1") +>Chunk : typeof import("tests/cases/conformance/jsdoc/mod1") constructor() { this.chunk = 1; diff --git a/tests/baselines/reference/moduleAugmentationDuringSyntheticDefaultCheck.symbols b/tests/baselines/reference/moduleAugmentationDuringSyntheticDefaultCheck.symbols index 115bb3b1a2c2c..4025c6c5e6066 100644 --- a/tests/baselines/reference/moduleAugmentationDuringSyntheticDefaultCheck.symbols +++ b/tests/baselines/reference/moduleAugmentationDuringSyntheticDefaultCheck.symbols @@ -8,7 +8,7 @@ import moment = require("moment-timezone"); declare function moment(): moment.Moment; >moment : Symbol(moment, Decl(index.d.ts, 0, 0), Decl(index.d.ts, 0, 41), Decl(idx.ts, 0, 34), Decl(index.d.ts, 1, 16)) >moment : Symbol(moment, Decl(index.d.ts, 0, 0), Decl(index.d.ts, 0, 41)) ->Moment : Symbol(Moment, Decl(index.d.ts, 1, 26)) +>Moment : Symbol(moment.Moment, Decl(index.d.ts, 1, 26)) declare namespace moment { >moment : Symbol(moment, Decl(index.d.ts, 0, 0), Decl(index.d.ts, 0, 41), Decl(idx.ts, 0, 34), Decl(index.d.ts, 1, 16)) diff --git a/tests/baselines/reference/moduleAugmentationOfAlias.types b/tests/baselines/reference/moduleAugmentationOfAlias.types index a5112f5869588..671948611b021 100644 --- a/tests/baselines/reference/moduleAugmentationOfAlias.types +++ b/tests/baselines/reference/moduleAugmentationOfAlias.types @@ -1,7 +1,7 @@ === /a.ts === interface I {} export default I; ->I : I +>I : import("/a").default === /b.ts === export {}; diff --git a/tests/baselines/reference/moduleExportAlias2.types b/tests/baselines/reference/moduleExportAlias2.types index 65f245a6f4f32..0449561a9d879 100644 --- a/tests/baselines/reference/moduleExportAlias2.types +++ b/tests/baselines/reference/moduleExportAlias2.types @@ -1,8 +1,8 @@ === tests/cases/conformance/salsa/index.js === /// const C = require("./semver") ->C : typeof C ->require("./semver") : typeof C +>C : typeof import("tests/cases/conformance/salsa/semver") +>require("./semver") : typeof import("tests/cases/conformance/salsa/semver") >require : (name: string) => any >"./semver" : "./semver" @@ -10,14 +10,14 @@ var two = C.f(1) >two : any >C.f(1) : any >C.f : (n: any) => any ->C : typeof C +>C : typeof import("tests/cases/conformance/salsa/semver") >f : (n: any) => any >1 : 1 var c = new C ->c : C ->new C : C ->C : typeof C +>c : import("tests/cases/conformance/salsa/semver") +>new C : import("tests/cases/conformance/salsa/semver") +>C : typeof import("tests/cases/conformance/salsa/semver") === tests/cases/conformance/salsa/node.d.ts === declare function require(name: string): any; diff --git a/tests/baselines/reference/moduleExportAlias4.types b/tests/baselines/reference/moduleExportAlias4.types index 744252781400b..1a16b5a09cdee 100644 --- a/tests/baselines/reference/moduleExportAlias4.types +++ b/tests/baselines/reference/moduleExportAlias4.types @@ -1,25 +1,25 @@ === tests/cases/conformance/salsa/bug24024.js === // #24024 var wat = require('./bug24024') ->wat : typeof C ->require('./bug24024') : typeof C +>wat : typeof import("tests/cases/conformance/salsa/bug24024") +>require('./bug24024') : typeof import("tests/cases/conformance/salsa/bug24024") >require : any >'./bug24024' : "./bug24024" module.exports = class C {} ->module.exports = class C {} : typeof C ->module.exports : typeof C ->module : { "tests/cases/conformance/salsa/bug24024": typeof C; } ->exports : typeof C ->class C {} : typeof C ->C : typeof C +>module.exports = class C {} : typeof import("tests/cases/conformance/salsa/bug24024") +>module.exports : typeof import("tests/cases/conformance/salsa/bug24024") +>module : { "tests/cases/conformance/salsa/bug24024": typeof import("tests/cases/conformance/salsa/bug24024"); } +>exports : typeof import("tests/cases/conformance/salsa/bug24024") +>class C {} : typeof import("tests/cases/conformance/salsa/bug24024") +>C : typeof import("tests/cases/conformance/salsa/bug24024") module.exports.D = class D { } >module.exports.D = class D { } : typeof D >module.exports.D : typeof D ->module.exports : typeof C ->module : { "tests/cases/conformance/salsa/bug24024": typeof C; } ->exports : typeof C +>module.exports : typeof import("tests/cases/conformance/salsa/bug24024") +>module : { "tests/cases/conformance/salsa/bug24024": typeof import("tests/cases/conformance/salsa/bug24024"); } +>exports : typeof import("tests/cases/conformance/salsa/bug24024") >D : typeof D >class D { } : typeof D >D : typeof D diff --git a/tests/baselines/reference/moduleExportPropertyAssignmentDefault.types b/tests/baselines/reference/moduleExportPropertyAssignmentDefault.types index a2f69a87f280b..cc78e2681bf9c 100644 --- a/tests/baselines/reference/moduleExportPropertyAssignmentDefault.types +++ b/tests/baselines/reference/moduleExportPropertyAssignmentDefault.types @@ -1,21 +1,21 @@ === tests/cases/conformance/salsa/axios.js === var axios = {} ->axios : { default: { default: any; }; } +>axios : typeof axios >{} : {} module.exports = axios // both assignments should be ok ->module.exports = axios : { default: { default: any; }; } ->module.exports : { default: { default: any; }; } ->module : { "tests/cases/conformance/salsa/axios": { default: { default: any; }; }; } ->exports : { default: { default: any; }; } ->axios : { default: { default: any; }; } +>module.exports = axios : typeof axios +>module.exports : typeof axios +>module : { "tests/cases/conformance/salsa/axios": typeof axios; } +>exports : typeof axios +>axios : typeof axios module.exports.default = axios ->module.exports.default = axios : { default: { default: any; }; } ->module.exports.default : { default: any; } ->module.exports : { default: { default: any; }; } ->module : { "tests/cases/conformance/salsa/axios": { default: { default: any; }; }; } ->exports : { default: { default: any; }; } ->default : { default: any; } ->axios : { default: { default: any; }; } +>module.exports.default = axios : typeof axios +>module.exports.default : typeof axios +>module.exports : typeof axios +>module : { "tests/cases/conformance/salsa/axios": typeof axios; } +>exports : typeof axios +>default : typeof axios +>axios : typeof axios diff --git a/tests/baselines/reference/moduleExportWithExportPropertyAssignment4.symbols b/tests/baselines/reference/moduleExportWithExportPropertyAssignment4.symbols index edb7d52254a46..ad04485687004 100644 --- a/tests/baselines/reference/moduleExportWithExportPropertyAssignment4.symbols +++ b/tests/baselines/reference/moduleExportWithExportPropertyAssignment4.symbols @@ -42,10 +42,10 @@ declare function require(name: string): any; /// module.exports.bothBefore = 'string' >module.exports.bothBefore : Symbol(bothBefore) ->module.exports : Symbol(A.bothBefore, Decl(mod1.js, 2, 16), Decl(mod1.js, 0, 0)) +>module.exports : Symbol(bothBefore, Decl(mod1.js, 2, 16), Decl(mod1.js, 0, 0)) >module : Symbol(module, Decl(mod1.js, 0, 0)) >exports : Symbol("tests/cases/conformance/salsa/mod1", Decl(mod1.js, 0, 0)) ->bothBefore : Symbol(A.bothBefore, Decl(mod1.js, 2, 16), Decl(mod1.js, 0, 0)) +>bothBefore : Symbol(bothBefore, Decl(mod1.js, 2, 16), Decl(mod1.js, 0, 0)) A.justExport = 4 >A.justExport : Symbol(A.justExport, Decl(mod1.js, 1, 36)) @@ -53,14 +53,14 @@ A.justExport = 4 >justExport : Symbol(A.justExport, Decl(mod1.js, 1, 36)) A.bothBefore = 2 ->A.bothBefore : Symbol(A.bothBefore, Decl(mod1.js, 2, 16), Decl(mod1.js, 0, 0)) +>A.bothBefore : Symbol(bothBefore, Decl(mod1.js, 2, 16), Decl(mod1.js, 0, 0)) >A : Symbol(A, Decl(mod1.js, 5, 18), Decl(mod1.js, 1, 36), Decl(mod1.js, 2, 16), Decl(mod1.js, 3, 16)) ->bothBefore : Symbol(A.bothBefore, Decl(mod1.js, 2, 16), Decl(mod1.js, 0, 0)) +>bothBefore : Symbol(bothBefore, Decl(mod1.js, 2, 16), Decl(mod1.js, 0, 0)) A.bothAfter = 3 ->A.bothAfter : Symbol(A.bothAfter, Decl(mod1.js, 3, 16), Decl(mod1.js, 8, 1)) +>A.bothAfter : Symbol(bothAfter, Decl(mod1.js, 3, 16), Decl(mod1.js, 8, 1)) >A : Symbol(A, Decl(mod1.js, 5, 18), Decl(mod1.js, 1, 36), Decl(mod1.js, 2, 16), Decl(mod1.js, 3, 16)) ->bothAfter : Symbol(A.bothAfter, Decl(mod1.js, 3, 16), Decl(mod1.js, 8, 1)) +>bothAfter : Symbol(bothAfter, Decl(mod1.js, 3, 16), Decl(mod1.js, 8, 1)) module.exports = A >module.exports : Symbol("tests/cases/conformance/salsa/mod1", Decl(mod1.js, 0, 0)) @@ -76,10 +76,10 @@ function A() { } module.exports.bothAfter = 'string' >module.exports.bothAfter : Symbol(bothAfter) ->module.exports : Symbol(A.bothAfter, Decl(mod1.js, 3, 16), Decl(mod1.js, 8, 1)) +>module.exports : Symbol(bothAfter, Decl(mod1.js, 3, 16), Decl(mod1.js, 8, 1)) >module : Symbol(module, Decl(mod1.js, 0, 0)) >exports : Symbol("tests/cases/conformance/salsa/mod1", Decl(mod1.js, 0, 0)) ->bothAfter : Symbol(A.bothAfter, Decl(mod1.js, 3, 16), Decl(mod1.js, 8, 1)) +>bothAfter : Symbol(bothAfter, Decl(mod1.js, 3, 16), Decl(mod1.js, 8, 1)) module.exports.justProperty = 'string' >module.exports.justProperty : Symbol(justProperty) diff --git a/tests/baselines/reference/moduleExportWithExportPropertyAssignment4.types b/tests/baselines/reference/moduleExportWithExportPropertyAssignment4.types index 8c55a664fc2e9..67285b7a29631 100644 --- a/tests/baselines/reference/moduleExportWithExportPropertyAssignment4.types +++ b/tests/baselines/reference/moduleExportWithExportPropertyAssignment4.types @@ -1,8 +1,8 @@ === tests/cases/conformance/salsa/a.js === /// var mod1 = require('./mod1') ->mod1 : typeof A ->require('./mod1') : typeof A +>mod1 : typeof import("tests/cases/conformance/salsa/mod1") +>require('./mod1') : typeof import("tests/cases/conformance/salsa/mod1") >require : (name: string) => any >'./mod1' : "./mod1" @@ -10,7 +10,7 @@ mod1.justExport.toFixed() >mod1.justExport.toFixed() : string >mod1.justExport.toFixed : (fractionDigits?: number) => string >mod1.justExport : number ->mod1 : typeof A +>mod1 : typeof import("tests/cases/conformance/salsa/mod1") >justExport : number >toFixed : (fractionDigits?: number) => string @@ -18,7 +18,7 @@ mod1.bothBefore.toFixed() // error >mod1.bothBefore.toFixed() : any >mod1.bothBefore.toFixed : any >mod1.bothBefore : string | number ->mod1 : typeof A +>mod1 : typeof import("tests/cases/conformance/salsa/mod1") >bothBefore : string | number >toFixed : any @@ -26,14 +26,14 @@ mod1.bothAfter.toFixed() >mod1.bothAfter.toFixed() : any >mod1.bothAfter.toFixed : any >mod1.bothAfter : string | number ->mod1 : typeof A +>mod1 : typeof import("tests/cases/conformance/salsa/mod1") >bothAfter : string | number >toFixed : any mod1.justProperty.length >mod1.justProperty.length : number >mod1.justProperty : string ->mod1 : typeof A +>mod1 : typeof import("tests/cases/conformance/salsa/mod1") >justProperty : string >length : number diff --git a/tests/baselines/reference/multiImportExport.types b/tests/baselines/reference/multiImportExport.types index 4a94eef9865ed..302af2ccc72c3 100644 --- a/tests/baselines/reference/multiImportExport.types +++ b/tests/baselines/reference/multiImportExport.types @@ -3,17 +3,17 @@ import Drawing = require('./Drawing'); >Drawing : typeof Drawing var addr = new Drawing.Math.Adder(); ->addr : Adder ->new Drawing.Math.Adder() : Adder ->Drawing.Math.Adder : typeof Adder ->Drawing.Math : { Adder: typeof Adder; } +>addr : import("tests/cases/compiler/Math/Adder") +>new Drawing.Math.Adder() : import("tests/cases/compiler/Math/Adder") +>Drawing.Math.Adder : typeof import("tests/cases/compiler/Math/Adder") +>Drawing.Math : { Adder: typeof import("tests/cases/compiler/Math/Adder"); } >Drawing : typeof Drawing ->Math : { Adder: typeof Adder; } ->Adder : typeof Adder +>Math : { Adder: typeof import("tests/cases/compiler/Math/Adder"); } +>Adder : typeof import("tests/cases/compiler/Math/Adder") === tests/cases/compiler/Drawing.ts === export import Math = require('./Math/Math') ->Math : { Adder: typeof Adder; } +>Math : { Adder: typeof import("tests/cases/compiler/Math/Adder"); } === tests/cases/compiler/Math/Math.ts === import Adder = require('./Adder'); diff --git a/tests/baselines/reference/namespacesWithTypeAliasOnlyExportsMerge.js b/tests/baselines/reference/namespacesWithTypeAliasOnlyExportsMerge.js new file mode 100644 index 0000000000000..74db93cc681a4 --- /dev/null +++ b/tests/baselines/reference/namespacesWithTypeAliasOnlyExportsMerge.js @@ -0,0 +1,57 @@ +//// [tests/cases/compiler/namespacesWithTypeAliasOnlyExportsMerge.ts] //// + +//// [constAndNS.ts] +type A = number; +declare const Q: number; +declare namespace Q { + export { A }; +} +declare const try1: Q.A; +declare namespace Q2 { + export { Q } +} +declare const try2: Q2.Q.A; +declare namespace Q3 { + export {A as B}; +} +declare const try3: Q3.B; +declare namespace Q4 { + export { Q as default }; +} +declare const try4: Q4.default.A; +export {}; +//// [circular.ts] +declare namespace NS1 { + export { NS2 }; +} +declare namespace NS2 { + export { NS1 }; +} +export {}; +//// [circularWithUses.ts] +type A = string; +type B = number; +declare namespace NS1 { + export { NS2, A }; +} +declare namespace NS2 { + export { NS1, B }; +} +export {}; +declare const try1: NS1.A; +declare const try2: NS2.B; +declare const try3: NS1.NS2.B; +declare const try4: NS2.NS1.A; +declare const try5: NS1.NS2.NS1.A; +declare const try6: NS2.NS1.NS2.B; + + +//// [constAndNS.js] +"use strict"; +exports.__esModule = true; +//// [circular.js] +"use strict"; +exports.__esModule = true; +//// [circularWithUses.js] +"use strict"; +exports.__esModule = true; diff --git a/tests/baselines/reference/namespacesWithTypeAliasOnlyExportsMerge.symbols b/tests/baselines/reference/namespacesWithTypeAliasOnlyExportsMerge.symbols new file mode 100644 index 0000000000000..1682662e55db7 --- /dev/null +++ b/tests/baselines/reference/namespacesWithTypeAliasOnlyExportsMerge.symbols @@ -0,0 +1,128 @@ +=== tests/cases/compiler/constAndNS.ts === +type A = number; +>A : Symbol(A, Decl(constAndNS.ts, 0, 0)) + +declare const Q: number; +>Q : Symbol(Q, Decl(constAndNS.ts, 1, 13), Decl(constAndNS.ts, 1, 24)) + +declare namespace Q { +>Q : Symbol(Q, Decl(constAndNS.ts, 1, 13), Decl(constAndNS.ts, 1, 24)) + + export { A }; +>A : Symbol(A, Decl(constAndNS.ts, 3, 12)) +} +declare const try1: Q.A; +>try1 : Symbol(try1, Decl(constAndNS.ts, 5, 13)) +>Q : Symbol(Q, Decl(constAndNS.ts, 1, 13), Decl(constAndNS.ts, 1, 24)) +>A : Symbol(Q.A, Decl(constAndNS.ts, 3, 12)) + +declare namespace Q2 { +>Q2 : Symbol(Q2, Decl(constAndNS.ts, 5, 24)) + + export { Q } +>Q : Symbol(Q, Decl(constAndNS.ts, 7, 12)) +} +declare const try2: Q2.Q.A; +>try2 : Symbol(try2, Decl(constAndNS.ts, 9, 13)) +>Q2 : Symbol(Q2, Decl(constAndNS.ts, 5, 24)) +>Q : Symbol(Q2.Q, Decl(constAndNS.ts, 7, 12)) +>A : Symbol(Q.A, Decl(constAndNS.ts, 3, 12)) + +declare namespace Q3 { +>Q3 : Symbol(Q3, Decl(constAndNS.ts, 9, 27)) + + export {A as B}; +>A : Symbol(A, Decl(constAndNS.ts, 0, 0)) +>B : Symbol(B, Decl(constAndNS.ts, 11, 12)) +} +declare const try3: Q3.B; +>try3 : Symbol(try3, Decl(constAndNS.ts, 13, 13)) +>Q3 : Symbol(Q3, Decl(constAndNS.ts, 9, 27)) +>B : Symbol(Q3.B, Decl(constAndNS.ts, 11, 12)) + +declare namespace Q4 { +>Q4 : Symbol(Q4, Decl(constAndNS.ts, 13, 25)) + + export { Q as default }; +>Q : Symbol(Q, Decl(constAndNS.ts, 1, 13), Decl(constAndNS.ts, 1, 24)) +>default : Symbol(default, Decl(constAndNS.ts, 15, 12)) +} +declare const try4: Q4.default.A; +>try4 : Symbol(try4, Decl(constAndNS.ts, 17, 13)) +>Q4 : Symbol(Q4, Decl(constAndNS.ts, 13, 25)) +>default : Symbol(Q4.default, Decl(constAndNS.ts, 15, 12)) +>A : Symbol(Q.A, Decl(constAndNS.ts, 3, 12)) + +export {}; +=== tests/cases/compiler/circular.ts === +declare namespace NS1 { +>NS1 : Symbol(NS1, Decl(circular.ts, 0, 0)) + + export { NS2 }; +>NS2 : Symbol(NS2, Decl(circular.ts, 1, 12)) +} +declare namespace NS2 { +>NS2 : Symbol(NS2, Decl(circular.ts, 2, 1)) + + export { NS1 }; +>NS1 : Symbol(NS1, Decl(circular.ts, 4, 12)) +} +export {}; +=== tests/cases/compiler/circularWithUses.ts === +type A = string; +>A : Symbol(A, Decl(circularWithUses.ts, 0, 0)) + +type B = number; +>B : Symbol(B, Decl(circularWithUses.ts, 0, 16)) + +declare namespace NS1 { +>NS1 : Symbol(NS1, Decl(circularWithUses.ts, 1, 16)) + + export { NS2, A }; +>NS2 : Symbol(NS2, Decl(circularWithUses.ts, 3, 12)) +>A : Symbol(A, Decl(circularWithUses.ts, 3, 17)) +} +declare namespace NS2 { +>NS2 : Symbol(NS2, Decl(circularWithUses.ts, 4, 1)) + + export { NS1, B }; +>NS1 : Symbol(NS1, Decl(circularWithUses.ts, 6, 12)) +>B : Symbol(B, Decl(circularWithUses.ts, 6, 17)) +} +export {}; +declare const try1: NS1.A; +>try1 : Symbol(try1, Decl(circularWithUses.ts, 9, 13)) +>NS1 : Symbol(NS1, Decl(circularWithUses.ts, 1, 16)) +>A : Symbol(NS1.A, Decl(circularWithUses.ts, 3, 17)) + +declare const try2: NS2.B; +>try2 : Symbol(try2, Decl(circularWithUses.ts, 10, 13)) +>NS2 : Symbol(NS2, Decl(circularWithUses.ts, 4, 1)) +>B : Symbol(NS2.B, Decl(circularWithUses.ts, 6, 17)) + +declare const try3: NS1.NS2.B; +>try3 : Symbol(try3, Decl(circularWithUses.ts, 11, 13)) +>NS1 : Symbol(NS1, Decl(circularWithUses.ts, 1, 16)) +>NS2 : Symbol(NS1.NS2, Decl(circularWithUses.ts, 3, 12)) +>B : Symbol(NS2.B, Decl(circularWithUses.ts, 6, 17)) + +declare const try4: NS2.NS1.A; +>try4 : Symbol(try4, Decl(circularWithUses.ts, 12, 13)) +>NS2 : Symbol(NS2, Decl(circularWithUses.ts, 4, 1)) +>NS1 : Symbol(NS2.NS1, Decl(circularWithUses.ts, 6, 12)) +>A : Symbol(NS1.A, Decl(circularWithUses.ts, 3, 17)) + +declare const try5: NS1.NS2.NS1.A; +>try5 : Symbol(try5, Decl(circularWithUses.ts, 13, 13)) +>NS1 : Symbol(NS1, Decl(circularWithUses.ts, 1, 16)) +>NS2 : Symbol(NS1.NS2, Decl(circularWithUses.ts, 3, 12)) +>NS1 : Symbol(NS2.NS1, Decl(circularWithUses.ts, 6, 12)) +>A : Symbol(NS1.A, Decl(circularWithUses.ts, 3, 17)) + +declare const try6: NS2.NS1.NS2.B; +>try6 : Symbol(try6, Decl(circularWithUses.ts, 14, 13)) +>NS2 : Symbol(NS2, Decl(circularWithUses.ts, 4, 1)) +>NS1 : Symbol(NS2.NS1, Decl(circularWithUses.ts, 6, 12)) +>NS2 : Symbol(NS1.NS2, Decl(circularWithUses.ts, 3, 12)) +>B : Symbol(NS2.B, Decl(circularWithUses.ts, 6, 17)) + diff --git a/tests/baselines/reference/namespacesWithTypeAliasOnlyExportsMerge.types b/tests/baselines/reference/namespacesWithTypeAliasOnlyExportsMerge.types new file mode 100644 index 0000000000000..0b16ca84494ad --- /dev/null +++ b/tests/baselines/reference/namespacesWithTypeAliasOnlyExportsMerge.types @@ -0,0 +1,106 @@ +=== tests/cases/compiler/constAndNS.ts === +type A = number; +>A : number + +declare const Q: number; +>Q : number + +declare namespace Q { + export { A }; +>A : any +} +declare const try1: Q.A; +>try1 : number +>Q : any + +declare namespace Q2 { +>Q2 : typeof Q2 + + export { Q } +>Q : number +} +declare const try2: Q2.Q.A; +>try2 : number +>Q2 : any +>Q : any + +declare namespace Q3 { + export {A as B}; +>A : any +>B : any +} +declare const try3: Q3.B; +>try3 : number +>Q3 : any + +declare namespace Q4 { +>Q4 : typeof Q4 + + export { Q as default }; +>Q : number +>default : number +} +declare const try4: Q4.default.A; +>try4 : number +>Q4 : any +>default : any + +export {}; +=== tests/cases/compiler/circular.ts === +declare namespace NS1 { + export { NS2 }; +>NS2 : any +} +declare namespace NS2 { + export { NS1 }; +>NS1 : any +} +export {}; +=== tests/cases/compiler/circularWithUses.ts === +type A = string; +>A : string + +type B = number; +>B : number + +declare namespace NS1 { + export { NS2, A }; +>NS2 : any +>A : any +} +declare namespace NS2 { + export { NS1, B }; +>NS1 : any +>B : any +} +export {}; +declare const try1: NS1.A; +>try1 : string +>NS1 : any + +declare const try2: NS2.B; +>try2 : number +>NS2 : any + +declare const try3: NS1.NS2.B; +>try3 : number +>NS1 : any +>NS2 : any + +declare const try4: NS2.NS1.A; +>try4 : string +>NS2 : any +>NS1 : any + +declare const try5: NS1.NS2.NS1.A; +>try5 : string +>NS1 : any +>NS2 : any +>NS1 : any + +declare const try6: NS2.NS1.NS2.B; +>try6 : number +>NS2 : any +>NS1 : any +>NS2 : any + diff --git a/tests/baselines/reference/noCircularDefinitionOnExportOfPrivateInMergedNamespace.js b/tests/baselines/reference/noCircularDefinitionOnExportOfPrivateInMergedNamespace.js new file mode 100644 index 0000000000000..fa06a67d93b73 --- /dev/null +++ b/tests/baselines/reference/noCircularDefinitionOnExportOfPrivateInMergedNamespace.js @@ -0,0 +1,17 @@ +//// [noCircularDefinitionOnExportOfPrivateInMergedNamespace.ts] +const cat = 12; +class Foo {} +export = Foo; +declare namespace Foo { + export { cat }; +} + +//// [noCircularDefinitionOnExportOfPrivateInMergedNamespace.js] +"use strict"; +var cat = 12; +var Foo = /** @class */ (function () { + function Foo() { + } + return Foo; +}()); +module.exports = Foo; diff --git a/tests/baselines/reference/noCircularDefinitionOnExportOfPrivateInMergedNamespace.symbols b/tests/baselines/reference/noCircularDefinitionOnExportOfPrivateInMergedNamespace.symbols new file mode 100644 index 0000000000000..5a37b64cd46eb --- /dev/null +++ b/tests/baselines/reference/noCircularDefinitionOnExportOfPrivateInMergedNamespace.symbols @@ -0,0 +1,16 @@ +=== tests/cases/compiler/noCircularDefinitionOnExportOfPrivateInMergedNamespace.ts === +const cat = 12; +>cat : Symbol(cat, Decl(noCircularDefinitionOnExportOfPrivateInMergedNamespace.ts, 0, 5)) + +class Foo {} +>Foo : Symbol(Foo, Decl(noCircularDefinitionOnExportOfPrivateInMergedNamespace.ts, 0, 15), Decl(noCircularDefinitionOnExportOfPrivateInMergedNamespace.ts, 2, 13)) + +export = Foo; +>Foo : Symbol(Foo, Decl(noCircularDefinitionOnExportOfPrivateInMergedNamespace.ts, 0, 15), Decl(noCircularDefinitionOnExportOfPrivateInMergedNamespace.ts, 2, 13)) + +declare namespace Foo { +>Foo : Symbol(Foo, Decl(noCircularDefinitionOnExportOfPrivateInMergedNamespace.ts, 0, 15), Decl(noCircularDefinitionOnExportOfPrivateInMergedNamespace.ts, 2, 13)) + + export { cat }; +>cat : Symbol(cat, Decl(noCircularDefinitionOnExportOfPrivateInMergedNamespace.ts, 4, 12)) +} diff --git a/tests/baselines/reference/noCircularDefinitionOnExportOfPrivateInMergedNamespace.types b/tests/baselines/reference/noCircularDefinitionOnExportOfPrivateInMergedNamespace.types new file mode 100644 index 0000000000000..5b1a72b6db794 --- /dev/null +++ b/tests/baselines/reference/noCircularDefinitionOnExportOfPrivateInMergedNamespace.types @@ -0,0 +1,17 @@ +=== tests/cases/compiler/noCircularDefinitionOnExportOfPrivateInMergedNamespace.ts === +const cat = 12; +>cat : 12 +>12 : 12 + +class Foo {} +>Foo : Foo + +export = Foo; +>Foo : Foo + +declare namespace Foo { +>Foo : typeof Foo + + export { cat }; +>cat : 12 +} diff --git a/tests/baselines/reference/project/jsFileCompilationDifferentNamesNotSpecifiedWithAllowJs/amd/test.d.ts b/tests/baselines/reference/project/jsFileCompilationDifferentNamesNotSpecifiedWithAllowJs/amd/test.d.ts index 4c0b8989316ef..bbae04a30bf94 100644 --- a/tests/baselines/reference/project/jsFileCompilationDifferentNamesNotSpecifiedWithAllowJs/amd/test.d.ts +++ b/tests/baselines/reference/project/jsFileCompilationDifferentNamesNotSpecifiedWithAllowJs/amd/test.d.ts @@ -1 +1,2 @@ declare var test: number; +declare var test2: number; diff --git a/tests/baselines/reference/project/jsFileCompilationDifferentNamesNotSpecifiedWithAllowJs/node/jsFileCompilationDifferentNamesNotSpecifiedWithAllowJs.errors.txt b/tests/baselines/reference/project/jsFileCompilationDifferentNamesNotSpecifiedWithAllowJs/node/jsFileCompilationDifferentNamesNotSpecifiedWithAllowJs.errors.txt index 6a3c9863cc590..5471371449aa1 100644 --- a/tests/baselines/reference/project/jsFileCompilationDifferentNamesNotSpecifiedWithAllowJs/node/jsFileCompilationDifferentNamesNotSpecifiedWithAllowJs.errors.txt +++ b/tests/baselines/reference/project/jsFileCompilationDifferentNamesNotSpecifiedWithAllowJs/node/jsFileCompilationDifferentNamesNotSpecifiedWithAllowJs.errors.txt @@ -1,16 +1,13 @@ DifferentNamesNotSpecifiedWithAllowJs/tsconfig.json(3,5): error TS6082: Only 'amd' and 'system' modules are supported alongside --out. -DifferentNamesNotSpecifiedWithAllowJs/tsconfig.json(4,5): error TS5053: Option 'allowJs' cannot be specified with option 'declaration'. -==== DifferentNamesNotSpecifiedWithAllowJs/tsconfig.json (2 errors) ==== +==== DifferentNamesNotSpecifiedWithAllowJs/tsconfig.json (1 errors) ==== { "compilerOptions": { "out": "test.js", ~~~~~ !!! error TS6082: Only 'amd' and 'system' modules are supported alongside --out. "allowJs": true - ~~~~~~~~~ -!!! error TS5053: Option 'allowJs' cannot be specified with option 'declaration'. } } ==== DifferentNamesNotSpecifiedWithAllowJs/a.ts (0 errors) ==== diff --git a/tests/baselines/reference/project/jsFileCompilationDifferentNamesNotSpecifiedWithAllowJs/node/test.d.ts b/tests/baselines/reference/project/jsFileCompilationDifferentNamesNotSpecifiedWithAllowJs/node/test.d.ts index 4c0b8989316ef..bbae04a30bf94 100644 --- a/tests/baselines/reference/project/jsFileCompilationDifferentNamesNotSpecifiedWithAllowJs/node/test.d.ts +++ b/tests/baselines/reference/project/jsFileCompilationDifferentNamesNotSpecifiedWithAllowJs/node/test.d.ts @@ -1 +1,2 @@ declare var test: number; +declare var test2: number; diff --git a/tests/baselines/reference/project/jsFileCompilationDifferentNamesSpecifiedWithAllowJs/amd/test.d.ts b/tests/baselines/reference/project/jsFileCompilationDifferentNamesSpecifiedWithAllowJs/amd/test.d.ts index 4c0b8989316ef..bbae04a30bf94 100644 --- a/tests/baselines/reference/project/jsFileCompilationDifferentNamesSpecifiedWithAllowJs/amd/test.d.ts +++ b/tests/baselines/reference/project/jsFileCompilationDifferentNamesSpecifiedWithAllowJs/amd/test.d.ts @@ -1 +1,2 @@ declare var test: number; +declare var test2: number; diff --git a/tests/baselines/reference/project/jsFileCompilationDifferentNamesSpecifiedWithAllowJs/node/jsFileCompilationDifferentNamesSpecifiedWithAllowJs.errors.txt b/tests/baselines/reference/project/jsFileCompilationDifferentNamesSpecifiedWithAllowJs/node/jsFileCompilationDifferentNamesSpecifiedWithAllowJs.errors.txt index c2849fae3a580..3c80f199817ad 100644 --- a/tests/baselines/reference/project/jsFileCompilationDifferentNamesSpecifiedWithAllowJs/node/jsFileCompilationDifferentNamesSpecifiedWithAllowJs.errors.txt +++ b/tests/baselines/reference/project/jsFileCompilationDifferentNamesSpecifiedWithAllowJs/node/jsFileCompilationDifferentNamesSpecifiedWithAllowJs.errors.txt @@ -1,16 +1,13 @@ DifferentNamesSpecifiedWithAllowJs/tsconfig.json(3,5): error TS6082: Only 'amd' and 'system' modules are supported alongside --out. -DifferentNamesSpecifiedWithAllowJs/tsconfig.json(4,5): error TS5053: Option 'allowJs' cannot be specified with option 'declaration'. -==== DifferentNamesSpecifiedWithAllowJs/tsconfig.json (2 errors) ==== +==== DifferentNamesSpecifiedWithAllowJs/tsconfig.json (1 errors) ==== { "compilerOptions": { "out": "test.js", ~~~~~ !!! error TS6082: Only 'amd' and 'system' modules are supported alongside --out. "allowJs": true - ~~~~~~~~~ -!!! error TS5053: Option 'allowJs' cannot be specified with option 'declaration'. }, "files": [ "a.ts", "b.js" ] } diff --git a/tests/baselines/reference/project/jsFileCompilationDifferentNamesSpecifiedWithAllowJs/node/test.d.ts b/tests/baselines/reference/project/jsFileCompilationDifferentNamesSpecifiedWithAllowJs/node/test.d.ts index 4c0b8989316ef..bbae04a30bf94 100644 --- a/tests/baselines/reference/project/jsFileCompilationDifferentNamesSpecifiedWithAllowJs/node/test.d.ts +++ b/tests/baselines/reference/project/jsFileCompilationDifferentNamesSpecifiedWithAllowJs/node/test.d.ts @@ -1 +1,2 @@ declare var test: number; +declare var test2: number; diff --git a/tests/baselines/reference/project/jsFileCompilationSameNameDtsNotSpecifiedWithAllowJs/amd/jsFileCompilationSameNameDtsNotSpecifiedWithAllowJs.errors.txt b/tests/baselines/reference/project/jsFileCompilationSameNameDtsNotSpecifiedWithAllowJs/amd/jsFileCompilationSameNameDtsNotSpecifiedWithAllowJs.errors.txt index aa7418ccc1420..45cdfd7a3bc42 100644 --- a/tests/baselines/reference/project/jsFileCompilationSameNameDtsNotSpecifiedWithAllowJs/amd/jsFileCompilationSameNameDtsNotSpecifiedWithAllowJs.errors.txt +++ b/tests/baselines/reference/project/jsFileCompilationSameNameDtsNotSpecifiedWithAllowJs/amd/jsFileCompilationSameNameDtsNotSpecifiedWithAllowJs.errors.txt @@ -1,14 +1,15 @@ +error TS5055: Cannot write file 'SameNameDTsNotSpecifiedWithAllowJs/a.d.ts' because it would overwrite input file. + Adding a tsconfig.json file will help organize projects that contain both TypeScript and JavaScript files. Learn more at https://aka.ms/tsconfig. error TS5055: Cannot write file 'SameNameDTsNotSpecifiedWithAllowJs/a.js' because it would overwrite input file. Adding a tsconfig.json file will help organize projects that contain both TypeScript and JavaScript files. Learn more at https://aka.ms/tsconfig. -SameNameDTsNotSpecifiedWithAllowJs/tsconfig.json(1,24): error TS5053: Option 'allowJs' cannot be specified with option 'declaration'. +!!! error TS5055: Cannot write file 'SameNameDTsNotSpecifiedWithAllowJs/a.d.ts' because it would overwrite input file. +!!! error TS5055: Adding a tsconfig.json file will help organize projects that contain both TypeScript and JavaScript files. Learn more at https://aka.ms/tsconfig. !!! error TS5055: Cannot write file 'SameNameDTsNotSpecifiedWithAllowJs/a.js' because it would overwrite input file. !!! error TS5055: Adding a tsconfig.json file will help organize projects that contain both TypeScript and JavaScript files. Learn more at https://aka.ms/tsconfig. -==== SameNameDTsNotSpecifiedWithAllowJs/tsconfig.json (1 errors) ==== +==== SameNameDTsNotSpecifiedWithAllowJs/tsconfig.json (0 errors) ==== { "compilerOptions": { "allowJs": true } } - ~~~~~~~~~ -!!! error TS5053: Option 'allowJs' cannot be specified with option 'declaration'. ==== SameNameDTsNotSpecifiedWithAllowJs/a.d.ts (0 errors) ==== declare var a: number; ==== SameNameDTsNotSpecifiedWithAllowJs/a.js (0 errors) ==== diff --git a/tests/baselines/reference/project/jsFileCompilationSameNameDtsNotSpecifiedWithAllowJs/node/jsFileCompilationSameNameDtsNotSpecifiedWithAllowJs.errors.txt b/tests/baselines/reference/project/jsFileCompilationSameNameDtsNotSpecifiedWithAllowJs/node/jsFileCompilationSameNameDtsNotSpecifiedWithAllowJs.errors.txt index aa7418ccc1420..45cdfd7a3bc42 100644 --- a/tests/baselines/reference/project/jsFileCompilationSameNameDtsNotSpecifiedWithAllowJs/node/jsFileCompilationSameNameDtsNotSpecifiedWithAllowJs.errors.txt +++ b/tests/baselines/reference/project/jsFileCompilationSameNameDtsNotSpecifiedWithAllowJs/node/jsFileCompilationSameNameDtsNotSpecifiedWithAllowJs.errors.txt @@ -1,14 +1,15 @@ +error TS5055: Cannot write file 'SameNameDTsNotSpecifiedWithAllowJs/a.d.ts' because it would overwrite input file. + Adding a tsconfig.json file will help organize projects that contain both TypeScript and JavaScript files. Learn more at https://aka.ms/tsconfig. error TS5055: Cannot write file 'SameNameDTsNotSpecifiedWithAllowJs/a.js' because it would overwrite input file. Adding a tsconfig.json file will help organize projects that contain both TypeScript and JavaScript files. Learn more at https://aka.ms/tsconfig. -SameNameDTsNotSpecifiedWithAllowJs/tsconfig.json(1,24): error TS5053: Option 'allowJs' cannot be specified with option 'declaration'. +!!! error TS5055: Cannot write file 'SameNameDTsNotSpecifiedWithAllowJs/a.d.ts' because it would overwrite input file. +!!! error TS5055: Adding a tsconfig.json file will help organize projects that contain both TypeScript and JavaScript files. Learn more at https://aka.ms/tsconfig. !!! error TS5055: Cannot write file 'SameNameDTsNotSpecifiedWithAllowJs/a.js' because it would overwrite input file. !!! error TS5055: Adding a tsconfig.json file will help organize projects that contain both TypeScript and JavaScript files. Learn more at https://aka.ms/tsconfig. -==== SameNameDTsNotSpecifiedWithAllowJs/tsconfig.json (1 errors) ==== +==== SameNameDTsNotSpecifiedWithAllowJs/tsconfig.json (0 errors) ==== { "compilerOptions": { "allowJs": true } } - ~~~~~~~~~ -!!! error TS5053: Option 'allowJs' cannot be specified with option 'declaration'. ==== SameNameDTsNotSpecifiedWithAllowJs/a.d.ts (0 errors) ==== declare var a: number; ==== SameNameDTsNotSpecifiedWithAllowJs/a.js (0 errors) ==== diff --git a/tests/baselines/reference/reactImportDropped.types b/tests/baselines/reference/reactImportDropped.types index f3e8c3987af97..52d9ddfb13d2a 100644 --- a/tests/baselines/reference/reactImportDropped.types +++ b/tests/baselines/reference/reactImportDropped.types @@ -31,7 +31,7 @@ declare global { export default React.createClass({ >React.createClass({ render() { return ( null ); }}) : import("tests/cases/compiler/react").ClassicComponentClass >React.createClass : (spec: any) => import("tests/cases/compiler/react").ClassicComponentClass ->React : typeof React +>React : typeof import("tests/cases/compiler/react") >createClass : (spec: any) => import("tests/cases/compiler/react").ClassicComponentClass >{ render() { return ( null ); }} : { render(): any; } diff --git a/tests/baselines/reference/reactTransitiveImportHasValidDeclaration.types b/tests/baselines/reference/reactTransitiveImportHasValidDeclaration.types index 07eacfb8f4d9b..234782767b34f 100644 --- a/tests/baselines/reference/reactTransitiveImportHasValidDeclaration.types +++ b/tests/baselines/reference/reactTransitiveImportHasValidDeclaration.types @@ -21,7 +21,7 @@ declare module 'react' { // augment } export interface StyledOtherComponentList { "div": React.DetailedHTMLProps, HTMLDivElement> ->"div" : import("tests/cases/compiler/node_modules/react/index.d.ts").DetailedHTMLProps, HTMLDivElement> +>"div" : import("tests/cases/compiler/node_modules/react/index").DetailedHTMLProps, HTMLDivElement> >React : any >React : any } @@ -36,24 +36,24 @@ import {StyledOtherComponent, StyledOtherComponentList} from "create-emotion-sty >StyledOtherComponentList : any export default function styled(tag: string): (o: object) => StyledOtherComponent<{}, StyledOtherComponentList["div"], any>; ->styled : (tag: string) => (o: object) => StyledOtherComponent<{}, import("tests/cases/compiler/node_modules/react/index.d.ts").DetailedHTMLProps, HTMLDivElement>, any> +>styled : (tag: string) => (o: object) => StyledOtherComponent<{}, import("tests/cases/compiler/node_modules/react/index").DetailedHTMLProps, HTMLDivElement>, any> >tag : string >o : object === tests/cases/compiler/index.ts === import styled from "react-emotion" ->styled : (tag: string) => (o: object) => import("tests/cases/compiler/node_modules/create-emotion-styled/index").StyledOtherComponent<{}, import("tests/cases/compiler/node_modules/react/index.d.ts").DetailedHTMLProps, HTMLDivElement>, any> +>styled : (tag: string) => (o: object) => import("tests/cases/compiler/node_modules/create-emotion-styled/index").StyledOtherComponent<{}, import("tests/cases/compiler/node_modules/react/index").DetailedHTMLProps, HTMLDivElement>, any> const Form = styled('div')({ color: "red" }) ->Form : import("tests/cases/compiler/node_modules/create-emotion-styled/index").StyledOtherComponent<{}, import("tests/cases/compiler/node_modules/react/index.d.ts").DetailedHTMLProps, HTMLDivElement>, any> ->styled('div')({ color: "red" }) : import("tests/cases/compiler/node_modules/create-emotion-styled/index").StyledOtherComponent<{}, import("tests/cases/compiler/node_modules/react/index.d.ts").DetailedHTMLProps, HTMLDivElement>, any> ->styled('div') : (o: object) => import("tests/cases/compiler/node_modules/create-emotion-styled/index").StyledOtherComponent<{}, import("tests/cases/compiler/node_modules/react/index.d.ts").DetailedHTMLProps, HTMLDivElement>, any> ->styled : (tag: string) => (o: object) => import("tests/cases/compiler/node_modules/create-emotion-styled/index").StyledOtherComponent<{}, import("tests/cases/compiler/node_modules/react/index.d.ts").DetailedHTMLProps, HTMLDivElement>, any> +>Form : import("tests/cases/compiler/node_modules/create-emotion-styled/index").StyledOtherComponent<{}, import("tests/cases/compiler/node_modules/react/index").DetailedHTMLProps, HTMLDivElement>, any> +>styled('div')({ color: "red" }) : import("tests/cases/compiler/node_modules/create-emotion-styled/index").StyledOtherComponent<{}, import("tests/cases/compiler/node_modules/react/index").DetailedHTMLProps, HTMLDivElement>, any> +>styled('div') : (o: object) => import("tests/cases/compiler/node_modules/create-emotion-styled/index").StyledOtherComponent<{}, import("tests/cases/compiler/node_modules/react/index").DetailedHTMLProps, HTMLDivElement>, any> +>styled : (tag: string) => (o: object) => import("tests/cases/compiler/node_modules/create-emotion-styled/index").StyledOtherComponent<{}, import("tests/cases/compiler/node_modules/react/index").DetailedHTMLProps, HTMLDivElement>, any> >'div' : "div" >{ color: "red" } : { color: string; } >color : string >"red" : "red" export default Form ->Form : import("tests/cases/compiler/node_modules/create-emotion-styled/index").StyledOtherComponent<{}, import("tests/cases/compiler/node_modules/react/index.d.ts").DetailedHTMLProps, HTMLDivElement>, any> +>Form : import("tests/cases/compiler/node_modules/create-emotion-styled/index").StyledOtherComponent<{}, import("tests/cases/compiler/node_modules/react/index").DetailedHTMLProps, HTMLDivElement>, any> diff --git a/tests/baselines/reference/reexportClassDefinition.types b/tests/baselines/reference/reexportClassDefinition.types index c39bbf9c13695..c6d2a4a2f2f56 100644 --- a/tests/baselines/reference/reexportClassDefinition.types +++ b/tests/baselines/reference/reexportClassDefinition.types @@ -1,12 +1,12 @@ === tests/cases/conformance/externalModules/foo3.ts === import foo2 = require('./foo2') ->foo2 : { x: typeof x; } +>foo2 : { x: typeof import("tests/cases/conformance/externalModules/foo1"); } class x extends foo2.x {} >x : x ->foo2.x : x ->foo2 : { x: typeof x; } ->x : typeof x +>foo2.x : import("tests/cases/conformance/externalModules/foo1") +>foo2 : { x: typeof import("tests/cases/conformance/externalModules/foo1"); } +>x : typeof import("tests/cases/conformance/externalModules/foo1") === tests/cases/conformance/externalModules/foo1.ts === diff --git a/tests/baselines/reference/requireOfJsonFileTypes.js b/tests/baselines/reference/requireOfJsonFileTypes.js index e84f684187a10..31bd1f5b11e67 100644 --- a/tests/baselines/reference/requireOfJsonFileTypes.js +++ b/tests/baselines/reference/requireOfJsonFileTypes.js @@ -83,3 +83,27 @@ stringLiteral = d; numberLiteral = e; numberLiteral = f[0]; booleanLiteral = g[0]; + + +//// [out/b.d.ts] +export declare const a: boolean; +export declare const b: string; +export declare const c: null; +export declare const d: boolean; +//// [out/c.d.ts] +declare const _exports: (string | null)[]; +export = _exports; +//// [out/d.d.ts] +declare const _exports: string; +export = _exports; +//// [out/e.d.ts] +declare const _exports: number; +export = _exports; +//// [out/f.d.ts] +declare const _exports: number[]; +export = _exports; +//// [out/g.d.ts] +declare const _exports: boolean[]; +export = _exports; +//// [out/file1.d.ts] +export {}; diff --git a/tests/baselines/reference/requireOfJsonFileWithDeclaration.js b/tests/baselines/reference/requireOfJsonFileWithDeclaration.js index 2cb5085ffb7ff..cae409add9708 100644 --- a/tests/baselines/reference/requireOfJsonFileWithDeclaration.js +++ b/tests/baselines/reference/requireOfJsonFileWithDeclaration.js @@ -32,5 +32,8 @@ if (x) { } +//// [out/b.d.ts] +export declare const a: boolean; +export declare const b: string; //// [out/file1.d.ts] export {}; diff --git a/tests/baselines/reference/tsbuild/javascriptProjectEmit/incremental-declaration-doesnt-change/modifies-outfile-js-projects-and-concatenates-them-correctly.js b/tests/baselines/reference/tsbuild/javascriptProjectEmit/incremental-declaration-doesnt-change/modifies-outfile-js-projects-and-concatenates-them-correctly.js new file mode 100644 index 0000000000000..b863d923b661d --- /dev/null +++ b/tests/baselines/reference/tsbuild/javascriptProjectEmit/incremental-declaration-doesnt-change/modifies-outfile-js-projects-and-concatenates-them-correctly.js @@ -0,0 +1,254 @@ +//// [/lib/incremental-declaration-doesnt-changeOutput.txt] +/lib/tsc -b /src +exitCode:: 0 + + +//// [/src/sub-project/index.js] +/** + * @typedef {Nominal} MyNominal + */ +const c = /** @type {*} */(undefined); + + +//// [/src/sub-project/sub-project.d.ts] file written with same contents +//// [/src/sub-project/sub-project.js] +/** + * @template T, Name + * @typedef {T & {[Symbol.species]: Name}} Nominal + */ +/** + * @typedef {Nominal} MyNominal + */ +var c = /** @type {*} */ (undefined); + + +//// [/src/sub-project/sub-project.tsbuildinfo] +{ + "bundle": { + "commonSourceDirectory": "..", + "sourceFiles": [ + "./index.js" + ], + "js": { + "sections": [ + { + "pos": 0, + "end": 84, + "kind": "prepend", + "data": "../common/common.js", + "texts": [ + { + "pos": 0, + "end": 84, + "kind": "text" + } + ] + }, + { + "pos": 84, + "end": 187, + "kind": "text" + } + ] + }, + "dts": { + "sections": [ + { + "pos": 0, + "end": 64, + "kind": "prepend", + "data": "../common/common.d.ts", + "texts": [ + { + "pos": 0, + "end": 64, + "kind": "text" + } + ] + }, + { + "pos": 64, + "end": 220, + "kind": "text" + } + ] + } + }, + "version": "FakeTSVersion" +} + +//// [/src/sub-project/sub-project.tsbuildinfo.baseline.txt] +====================================================================== +File:: /src/sub-project/sub-project.js +---------------------------------------------------------------------- +prepend: (0-84):: ../common/common.js texts:: 1 +>>-------------------------------------------------------------------- +text: (0-84) +/** + * @template T, Name + * @typedef {T & {[Symbol.species]: Name}} Nominal + */ + +---------------------------------------------------------------------- +text: (84-187) +/** + * @typedef {Nominal} MyNominal + */ +var c = /** @type {*} */ (undefined); + +====================================================================== +====================================================================== +File:: /src/sub-project/sub-project.d.ts +---------------------------------------------------------------------- +prepend: (0-64):: ../common/common.d.ts texts:: 1 +>>-------------------------------------------------------------------- +text: (0-64) +type Nominal = T & { + [Symbol.species]: Name; +}; + +---------------------------------------------------------------------- +text: (64-220) +/** + * @typedef {Nominal} MyNominal + */ +declare const c: any; +type MyNominal = string & { + [Symbol.species]: "MyNominal"; +}; + +====================================================================== + +//// [/src/sub-project-2/sub-project-2.js] +/** + * @template T, Name + * @typedef {T & {[Symbol.species]: Name}} Nominal + */ +/** + * @typedef {Nominal} MyNominal + */ +var c = /** @type {*} */ (undefined); +var variable = { + key: /** @type {MyNominal} */ ('value') +}; +/** + * @return {keyof typeof variable} + */ +function getVar() { + return 'key'; +} + + +//// [/src/sub-project-2/sub-project-2.tsbuildinfo] +{ + "bundle": { + "commonSourceDirectory": "..", + "sourceFiles": [ + "./index.js" + ], + "js": { + "sections": [ + { + "pos": 0, + "end": 187, + "kind": "prepend", + "data": "../sub-project/sub-project.js", + "texts": [ + { + "pos": 0, + "end": 187, + "kind": "text" + } + ] + }, + { + "pos": 187, + "end": 343, + "kind": "text" + } + ] + }, + "dts": { + "sections": [ + { + "pos": 0, + "end": 220, + "kind": "prepend", + "data": "../sub-project/sub-project.d.ts", + "texts": [ + { + "pos": 0, + "end": 220, + "kind": "text" + } + ] + }, + { + "pos": 220, + "end": 361, + "kind": "text" + } + ] + } + }, + "version": "FakeTSVersion" +} + +//// [/src/sub-project-2/sub-project-2.tsbuildinfo.baseline.txt] +====================================================================== +File:: /src/sub-project-2/sub-project-2.js +---------------------------------------------------------------------- +prepend: (0-187):: ../sub-project/sub-project.js texts:: 1 +>>-------------------------------------------------------------------- +text: (0-187) +/** + * @template T, Name + * @typedef {T & {[Symbol.species]: Name}} Nominal + */ +/** + * @typedef {Nominal} MyNominal + */ +var c = /** @type {*} */ (undefined); + +---------------------------------------------------------------------- +text: (187-343) +var variable = { + key: /** @type {MyNominal} */ ('value') +}; +/** + * @return {keyof typeof variable} + */ +function getVar() { + return 'key'; +} + +====================================================================== +====================================================================== +File:: /src/sub-project-2/sub-project-2.d.ts +---------------------------------------------------------------------- +prepend: (0-220):: ../sub-project/sub-project.d.ts texts:: 1 +>>-------------------------------------------------------------------- +text: (0-220) +type Nominal = T & { + [Symbol.species]: Name; +}; +/** + * @typedef {Nominal} MyNominal + */ +declare const c: any; +type MyNominal = string & { + [Symbol.species]: "MyNominal"; +}; + +---------------------------------------------------------------------- +text: (220-361) +/** + * @return {keyof typeof variable} + */ +declare function getVar(): "key"; +declare namespace variable { + const key: MyNominal; +} + +====================================================================== + diff --git a/tests/baselines/reference/tsbuild/javascriptProjectEmit/initial-build/loads-js-based-projects-and-emits-them-correctly.js b/tests/baselines/reference/tsbuild/javascriptProjectEmit/initial-build/loads-js-based-projects-and-emits-them-correctly.js new file mode 100644 index 0000000000000..2abc5b9119bde --- /dev/null +++ b/tests/baselines/reference/tsbuild/javascriptProjectEmit/initial-build/loads-js-based-projects-and-emits-them-correctly.js @@ -0,0 +1,172 @@ +//// [/lib/common/nominal.d.ts] +export type Nominal = T & { + [Symbol.species]: Name; +}; + + +//// [/lib/common/nominal.js] +/** + * @template T, Name + * @typedef {T & {[Symbol.species]: Name}} Nominal + */ +module.exports = {}; + + +//// [/lib/common/tsconfig.tsbuildinfo] +{ + "program": { + "fileInfos": { + "../lib.d.ts": { + "version": "-32082413277-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }\ninterface ReadonlyArray {}\ndeclare const console: { log(msg: any): void; };\ninterface SymbolConstructor {\n readonly species: symbol;\n readonly toStringTag: symbol;\n}\ndeclare var Symbol: SymbolConstructor;\ninterface Symbol {\n readonly [Symbol.toStringTag]: string;\n}\n", + "signature": "-32082413277-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }\ninterface ReadonlyArray {}\ndeclare const console: { log(msg: any): void; };\ninterface SymbolConstructor {\n readonly species: symbol;\n readonly toStringTag: symbol;\n}\ndeclare var Symbol: SymbolConstructor;\ninterface Symbol {\n readonly [Symbol.toStringTag]: string;\n}\n" + }, + "../../src/common/nominal.js": { + "version": "-9003723607-/**\n * @template T, Name\n * @typedef {T & {[Symbol.species]: Name}} Nominal\n */\nmodule.exports = {};\n", + "signature": "-15964609857-export type Nominal = T & {\r\n [Symbol.species]: Name;\r\n};\r\n" + } + }, + "options": { + "skipLibCheck": true, + "rootDir": "../../src", + "outDir": "..", + "allowJs": true, + "checkJs": true, + "declaration": true, + "composite": true, + "configFilePath": "../../src/common/tsconfig.json" + }, + "referencedMap": {}, + "exportedModulesMap": {}, + "semanticDiagnosticsPerFile": [ + "../../src/common/nominal.js", + "../lib.d.ts" + ] + }, + "version": "FakeTSVersion" +} + +//// [/lib/initial-buildOutput.txt] +/lib/tsc -b /src +exitCode:: 0 + + +//// [/lib/sub-project/index.d.ts] +export type MyNominal = string & { + [Symbol.species]: "MyNominal"; +}; + + +//// [/lib/sub-project/index.js] +"use strict"; +exports.__esModule = true; +/** + * @typedef {Nominal} MyNominal + */ + + +//// [/lib/sub-project/tsconfig.tsbuildinfo] +{ + "program": { + "fileInfos": { + "../lib.d.ts": { + "version": "-32082413277-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }\ninterface ReadonlyArray {}\ndeclare const console: { log(msg: any): void; };\ninterface SymbolConstructor {\n readonly species: symbol;\n readonly toStringTag: symbol;\n}\ndeclare var Symbol: SymbolConstructor;\ninterface Symbol {\n readonly [Symbol.toStringTag]: string;\n}\n", + "signature": "-32082413277-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }\ninterface ReadonlyArray {}\ndeclare const console: { log(msg: any): void; };\ninterface SymbolConstructor {\n readonly species: symbol;\n readonly toStringTag: symbol;\n}\ndeclare var Symbol: SymbolConstructor;\ninterface Symbol {\n readonly [Symbol.toStringTag]: string;\n}\n" + }, + "../../src/common/nominal.js": { + "version": "-15964609857-export type Nominal = T & {\r\n [Symbol.species]: Name;\r\n};\r\n", + "signature": "-15964609857-export type Nominal = T & {\r\n [Symbol.species]: Name;\r\n};\r\n" + }, + "../../src/sub-project/index.js": { + "version": "-23375763082-import { Nominal } from '../common/nominal';\n\n/**\n * @typedef {Nominal} MyNominal\n */\n", + "signature": "-4500199036-export type MyNominal = string & {\r\n [Symbol.species]: \"MyNominal\";\r\n};\r\n" + } + }, + "options": { + "skipLibCheck": true, + "rootDir": "../../src", + "outDir": "..", + "allowJs": true, + "checkJs": true, + "declaration": true, + "composite": true, + "configFilePath": "../../src/sub-project/tsconfig.json" + }, + "referencedMap": { + "../../src/sub-project/index.js": [ + "../common/nominal.d.ts" + ] + }, + "exportedModulesMap": {}, + "semanticDiagnosticsPerFile": [ + "../../src/common/nominal.js", + "../../src/sub-project/index.js", + "../lib.d.ts" + ] + }, + "version": "FakeTSVersion" +} + +//// [/lib/sub-project-2/index.d.ts] +/** + * @return {keyof typeof variable} + */ +export function getVar(): "key"; + + +//// [/lib/sub-project-2/index.js] +"use strict"; +exports.__esModule = true; +var variable = { + key: /** @type {MyNominal} */ ('value') +}; +/** + * @return {keyof typeof variable} + */ +function getVar() { + return 'key'; +} +exports.getVar = getVar; + + +//// [/lib/sub-project-2/tsconfig.tsbuildinfo] +{ + "program": { + "fileInfos": { + "../lib.d.ts": { + "version": "-32082413277-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }\ninterface ReadonlyArray {}\ndeclare const console: { log(msg: any): void; };\ninterface SymbolConstructor {\n readonly species: symbol;\n readonly toStringTag: symbol;\n}\ndeclare var Symbol: SymbolConstructor;\ninterface Symbol {\n readonly [Symbol.toStringTag]: string;\n}\n", + "signature": "-32082413277-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }\ninterface ReadonlyArray {}\ndeclare const console: { log(msg: any): void; };\ninterface SymbolConstructor {\n readonly species: symbol;\n readonly toStringTag: symbol;\n}\ndeclare var Symbol: SymbolConstructor;\ninterface Symbol {\n readonly [Symbol.toStringTag]: string;\n}\n" + }, + "../../src/sub-project/index.js": { + "version": "-4500199036-export type MyNominal = string & {\r\n [Symbol.species]: \"MyNominal\";\r\n};\r\n", + "signature": "-4500199036-export type MyNominal = string & {\r\n [Symbol.species]: \"MyNominal\";\r\n};\r\n" + }, + "../../src/sub-project-2/index.js": { + "version": "9520601400-import { MyNominal } from '../sub-project/index';\n\nconst variable = {\n key: /** @type {MyNominal} */('value'),\n};\n\n/**\n * @return {keyof typeof variable}\n */\nexport function getVar() {\n return 'key';\n}\n", + "signature": "-9866665538-/**\r\n * @return {keyof typeof variable}\r\n */\r\nexport function getVar(): \"key\";\r\n" + } + }, + "options": { + "skipLibCheck": true, + "rootDir": "../../src", + "outDir": "..", + "allowJs": true, + "checkJs": true, + "declaration": true, + "composite": true, + "configFilePath": "../../src/sub-project-2/tsconfig.json" + }, + "referencedMap": { + "../../src/sub-project-2/index.js": [ + "../sub-project/index.d.ts" + ] + }, + "exportedModulesMap": {}, + "semanticDiagnosticsPerFile": [ + "../../src/sub-project-2/index.js", + "../../src/sub-project/index.js", + "../lib.d.ts" + ] + }, + "version": "FakeTSVersion" +} + diff --git a/tests/baselines/reference/tsbuild/javascriptProjectEmit/initial-build/loads-js-based-projects-with-non-moved-json-files-and-emits-them-correctly.js b/tests/baselines/reference/tsbuild/javascriptProjectEmit/initial-build/loads-js-based-projects-with-non-moved-json-files-and-emits-them-correctly.js new file mode 100644 index 0000000000000..42b4720340617 --- /dev/null +++ b/tests/baselines/reference/tsbuild/javascriptProjectEmit/initial-build/loads-js-based-projects-with-non-moved-json-files-and-emits-them-correctly.js @@ -0,0 +1,228 @@ +//// [/lib/initial-buildOutput.txt] +/lib/tsc -b /src +exitCode:: 0 + + +//// [/out/sub-project/index.d.ts] +export const m: typeof mod; +import mod from "../common"; + + +//// [/out/sub-project/index.js] +"use strict"; +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; +exports.__esModule = true; +var common_1 = __importDefault(require("../common")); +exports.m = common_1["default"]; + + +//// [/out/sub-project/tsconfig.tsbuildinfo] +{ + "program": { + "fileInfos": { + "../../lib/lib.d.ts": { + "version": "-32082413277-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }\ninterface ReadonlyArray {}\ndeclare const console: { log(msg: any): void; };\ninterface SymbolConstructor {\n readonly species: symbol;\n readonly toStringTag: symbol;\n}\ndeclare var Symbol: SymbolConstructor;\ninterface Symbol {\n readonly [Symbol.toStringTag]: string;\n}\n", + "signature": "-32082413277-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }\ninterface ReadonlyArray {}\ndeclare const console: { log(msg: any): void; };\ninterface SymbolConstructor {\n readonly species: symbol;\n readonly toStringTag: symbol;\n}\ndeclare var Symbol: SymbolConstructor;\ninterface Symbol {\n readonly [Symbol.toStringTag]: string;\n}\n" + }, + "../../src/common/obj.json": { + "version": "-6323167306-export declare const val: number;\r\n", + "signature": "-6323167306-export declare const val: number;\r\n" + }, + "../../src/common/index.ts": { + "version": "-4085459678-import x = require(\"./obj.json\");\r\nexport = x;\r\n", + "signature": "-4085459678-import x = require(\"./obj.json\");\r\nexport = x;\r\n" + }, + "../../src/sub-project/index.js": { + "version": "-14684157955-import mod from '../common';\n\nexport const m = mod;\n", + "signature": "-229957289-export const m: typeof mod;\r\nimport mod from \"../common\";\r\n" + } + }, + "options": { + "skipLibCheck": true, + "rootDir": "../../src", + "outDir": "..", + "allowJs": true, + "checkJs": true, + "resolveJsonModule": true, + "esModuleInterop": true, + "declaration": true, + "composite": true, + "configFilePath": "../../src/sub-project/tsconfig.json" + }, + "referencedMap": { + "../../src/common/index.ts": [ + "../../src/common/obj.d.ts" + ], + "../../src/sub-project/index.js": [ + "../../src/common/index.d.ts" + ] + }, + "exportedModulesMap": { + "../../src/common/index.ts": [ + "../../src/common/obj.d.ts" + ] + }, + "semanticDiagnosticsPerFile": [ + "../../lib/lib.d.ts", + "../../src/common/index.ts", + "../../src/common/obj.json", + "../../src/sub-project/index.js" + ] + }, + "version": "FakeTSVersion" +} + +//// [/out/sub-project-2/index.d.ts] +export function getVar(): { + key: typeof import("../common/obj.json"); +}; + + +//// [/out/sub-project-2/index.js] +"use strict"; +exports.__esModule = true; +var index_1 = require("../sub-project/index"); +var variable = { + key: index_1.m +}; +function getVar() { + return variable; +} +exports.getVar = getVar; + + +//// [/out/sub-project-2/tsconfig.tsbuildinfo] +{ + "program": { + "fileInfos": { + "../../lib/lib.d.ts": { + "version": "-32082413277-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }\ninterface ReadonlyArray {}\ndeclare const console: { log(msg: any): void; };\ninterface SymbolConstructor {\n readonly species: symbol;\n readonly toStringTag: symbol;\n}\ndeclare var Symbol: SymbolConstructor;\ninterface Symbol {\n readonly [Symbol.toStringTag]: string;\n}\n", + "signature": "-32082413277-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }\ninterface ReadonlyArray {}\ndeclare const console: { log(msg: any): void; };\ninterface SymbolConstructor {\n readonly species: symbol;\n readonly toStringTag: symbol;\n}\ndeclare var Symbol: SymbolConstructor;\ninterface Symbol {\n readonly [Symbol.toStringTag]: string;\n}\n" + }, + "../../src/common/obj.json": { + "version": "-6323167306-export declare const val: number;\r\n", + "signature": "-6323167306-export declare const val: number;\r\n" + }, + "../../src/common/index.ts": { + "version": "-4085459678-import x = require(\"./obj.json\");\r\nexport = x;\r\n", + "signature": "-4085459678-import x = require(\"./obj.json\");\r\nexport = x;\r\n" + }, + "../../src/sub-project/index.js": { + "version": "-229957289-export const m: typeof mod;\r\nimport mod from \"../common\";\r\n", + "signature": "-229957289-export const m: typeof mod;\r\nimport mod from \"../common\";\r\n" + }, + "../../src/sub-project-2/index.js": { + "version": "13545386800-import { m } from '../sub-project/index';\n\nconst variable = {\n key: m,\n};\n\nexport function getVar() {\n return variable;\n}\n", + "signature": "-9206156860-export function getVar(): {\r\n key: typeof import(\"../common/obj.json\");\r\n};\r\n" + } + }, + "options": { + "skipLibCheck": true, + "rootDir": "../../src", + "outDir": "..", + "allowJs": true, + "checkJs": true, + "resolveJsonModule": true, + "esModuleInterop": true, + "declaration": true, + "composite": true, + "configFilePath": "../../src/sub-project-2/tsconfig.json" + }, + "referencedMap": { + "../../src/common/index.ts": [ + "../../src/common/obj.d.ts" + ], + "../../src/sub-project-2/index.js": [ + "../sub-project/index.d.ts" + ], + "../../src/sub-project/index.js": [ + "../../src/common/index.d.ts" + ] + }, + "exportedModulesMap": { + "../../src/common/index.ts": [ + "../../src/common/obj.d.ts" + ], + "../../src/sub-project-2/index.js": [ + "../../src/common/obj.d.ts" + ], + "../../src/sub-project/index.js": [ + "../../src/common/index.d.ts" + ] + }, + "semanticDiagnosticsPerFile": [ + "../../lib/lib.d.ts", + "../../src/common/index.ts", + "../../src/common/obj.json", + "../../src/sub-project-2/index.js", + "../../src/sub-project/index.js" + ] + }, + "version": "FakeTSVersion" +} + +//// [/src/common/index.d.ts] +import x = require("./obj.json"); +export = x; + + +//// [/src/common/index.js] +"use strict"; +var x = require("./obj.json"); +module.exports = x; + + +//// [/src/common/obj.d.ts] +export declare const val: number; + + +//// [/src/common/tsconfig.tsbuildinfo] +{ + "program": { + "fileInfos": { + "../../lib/lib.d.ts": { + "version": "-32082413277-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }\ninterface ReadonlyArray {}\ndeclare const console: { log(msg: any): void; };\ninterface SymbolConstructor {\n readonly species: symbol;\n readonly toStringTag: symbol;\n}\ndeclare var Symbol: SymbolConstructor;\ninterface Symbol {\n readonly [Symbol.toStringTag]: string;\n}\n", + "signature": "-32082413277-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }\ninterface ReadonlyArray {}\ndeclare const console: { log(msg: any): void; };\ninterface SymbolConstructor {\n readonly species: symbol;\n readonly toStringTag: symbol;\n}\ndeclare var Symbol: SymbolConstructor;\ninterface Symbol {\n readonly [Symbol.toStringTag]: string;\n}\n" + }, + "./obj.json": { + "version": "2151907832-{\n \"val\": 42\n}", + "signature": "-6323167306-export declare const val: number;\r\n" + }, + "./index.ts": { + "version": "-5032674136-import x = require(\"./obj.json\");\nexport = x;\n", + "signature": "-4085459678-import x = require(\"./obj.json\");\r\nexport = x;\r\n" + } + }, + "options": { + "skipLibCheck": true, + "rootDir": "..", + "outDir": "../..", + "allowJs": true, + "checkJs": true, + "resolveJsonModule": true, + "esModuleInterop": true, + "declaration": true, + "composite": true, + "configFilePath": "./tsconfig.json" + }, + "referencedMap": { + "./index.ts": [ + "./obj.json" + ] + }, + "exportedModulesMap": { + "./index.ts": [ + "./obj.json" + ] + }, + "semanticDiagnosticsPerFile": [ + "../../lib/lib.d.ts", + "./index.ts", + "./obj.json" + ] + }, + "version": "FakeTSVersion" +} + diff --git a/tests/baselines/reference/tsbuild/javascriptProjectEmit/initial-build/loads-outfile-js-projects-and-concatenates-them-correctly.js b/tests/baselines/reference/tsbuild/javascriptProjectEmit/initial-build/loads-outfile-js-projects-and-concatenates-them-correctly.js new file mode 100644 index 0000000000000..c46f5e3baa1f9 --- /dev/null +++ b/tests/baselines/reference/tsbuild/javascriptProjectEmit/initial-build/loads-outfile-js-projects-and-concatenates-them-correctly.js @@ -0,0 +1,342 @@ +//// [/lib/initial-buildOutput.txt] +/lib/tsc -b /src +exitCode:: 0 + + +//// [/src/common/common.d.ts] +type Nominal = T & { + [Symbol.species]: Name; +}; + + +//// [/src/common/common.js] +/** + * @template T, Name + * @typedef {T & {[Symbol.species]: Name}} Nominal + */ + + +//// [/src/common/common.tsbuildinfo] +{ + "bundle": { + "commonSourceDirectory": "..", + "sourceFiles": [ + "./nominal.js" + ], + "js": { + "sections": [ + { + "pos": 0, + "end": 84, + "kind": "text" + } + ] + }, + "dts": { + "sections": [ + { + "pos": 0, + "end": 64, + "kind": "text" + } + ] + } + }, + "version": "FakeTSVersion" +} + +//// [/src/common/common.tsbuildinfo.baseline.txt] +====================================================================== +File:: /src/common/common.js +---------------------------------------------------------------------- +text: (0-84) +/** + * @template T, Name + * @typedef {T & {[Symbol.species]: Name}} Nominal + */ + +====================================================================== +====================================================================== +File:: /src/common/common.d.ts +---------------------------------------------------------------------- +text: (0-64) +type Nominal = T & { + [Symbol.species]: Name; +}; + +====================================================================== + +//// [/src/sub-project/sub-project.d.ts] +type Nominal = T & { + [Symbol.species]: Name; +}; +/** + * @typedef {Nominal} MyNominal + */ +declare const c: any; +type MyNominal = string & { + [Symbol.species]: "MyNominal"; +}; + + +//// [/src/sub-project/sub-project.js] +/** + * @template T, Name + * @typedef {T & {[Symbol.species]: Name}} Nominal + */ +/** + * @typedef {Nominal} MyNominal + */ +var c = /** @type {*} */ (null); + + +//// [/src/sub-project/sub-project.tsbuildinfo] +{ + "bundle": { + "commonSourceDirectory": "..", + "sourceFiles": [ + "./index.js" + ], + "js": { + "sections": [ + { + "pos": 0, + "end": 84, + "kind": "prepend", + "data": "../common/common.js", + "texts": [ + { + "pos": 0, + "end": 84, + "kind": "text" + } + ] + }, + { + "pos": 84, + "end": 182, + "kind": "text" + } + ] + }, + "dts": { + "sections": [ + { + "pos": 0, + "end": 64, + "kind": "prepend", + "data": "../common/common.d.ts", + "texts": [ + { + "pos": 0, + "end": 64, + "kind": "text" + } + ] + }, + { + "pos": 64, + "end": 220, + "kind": "text" + } + ] + } + }, + "version": "FakeTSVersion" +} + +//// [/src/sub-project/sub-project.tsbuildinfo.baseline.txt] +====================================================================== +File:: /src/sub-project/sub-project.js +---------------------------------------------------------------------- +prepend: (0-84):: ../common/common.js texts:: 1 +>>-------------------------------------------------------------------- +text: (0-84) +/** + * @template T, Name + * @typedef {T & {[Symbol.species]: Name}} Nominal + */ + +---------------------------------------------------------------------- +text: (84-182) +/** + * @typedef {Nominal} MyNominal + */ +var c = /** @type {*} */ (null); + +====================================================================== +====================================================================== +File:: /src/sub-project/sub-project.d.ts +---------------------------------------------------------------------- +prepend: (0-64):: ../common/common.d.ts texts:: 1 +>>-------------------------------------------------------------------- +text: (0-64) +type Nominal = T & { + [Symbol.species]: Name; +}; + +---------------------------------------------------------------------- +text: (64-220) +/** + * @typedef {Nominal} MyNominal + */ +declare const c: any; +type MyNominal = string & { + [Symbol.species]: "MyNominal"; +}; + +====================================================================== + +//// [/src/sub-project-2/sub-project-2.d.ts] +type Nominal = T & { + [Symbol.species]: Name; +}; +/** + * @typedef {Nominal} MyNominal + */ +declare const c: any; +type MyNominal = string & { + [Symbol.species]: "MyNominal"; +}; +/** + * @return {keyof typeof variable} + */ +declare function getVar(): "key"; +declare namespace variable { + const key: MyNominal; +} + + +//// [/src/sub-project-2/sub-project-2.js] +/** + * @template T, Name + * @typedef {T & {[Symbol.species]: Name}} Nominal + */ +/** + * @typedef {Nominal} MyNominal + */ +var c = /** @type {*} */ (null); +var variable = { + key: /** @type {MyNominal} */ ('value') +}; +/** + * @return {keyof typeof variable} + */ +function getVar() { + return 'key'; +} + + +//// [/src/sub-project-2/sub-project-2.tsbuildinfo] +{ + "bundle": { + "commonSourceDirectory": "..", + "sourceFiles": [ + "./index.js" + ], + "js": { + "sections": [ + { + "pos": 0, + "end": 182, + "kind": "prepend", + "data": "../sub-project/sub-project.js", + "texts": [ + { + "pos": 0, + "end": 182, + "kind": "text" + } + ] + }, + { + "pos": 182, + "end": 338, + "kind": "text" + } + ] + }, + "dts": { + "sections": [ + { + "pos": 0, + "end": 220, + "kind": "prepend", + "data": "../sub-project/sub-project.d.ts", + "texts": [ + { + "pos": 0, + "end": 220, + "kind": "text" + } + ] + }, + { + "pos": 220, + "end": 361, + "kind": "text" + } + ] + } + }, + "version": "FakeTSVersion" +} + +//// [/src/sub-project-2/sub-project-2.tsbuildinfo.baseline.txt] +====================================================================== +File:: /src/sub-project-2/sub-project-2.js +---------------------------------------------------------------------- +prepend: (0-182):: ../sub-project/sub-project.js texts:: 1 +>>-------------------------------------------------------------------- +text: (0-182) +/** + * @template T, Name + * @typedef {T & {[Symbol.species]: Name}} Nominal + */ +/** + * @typedef {Nominal} MyNominal + */ +var c = /** @type {*} */ (null); + +---------------------------------------------------------------------- +text: (182-338) +var variable = { + key: /** @type {MyNominal} */ ('value') +}; +/** + * @return {keyof typeof variable} + */ +function getVar() { + return 'key'; +} + +====================================================================== +====================================================================== +File:: /src/sub-project-2/sub-project-2.d.ts +---------------------------------------------------------------------- +prepend: (0-220):: ../sub-project/sub-project.d.ts texts:: 1 +>>-------------------------------------------------------------------- +text: (0-220) +type Nominal = T & { + [Symbol.species]: Name; +}; +/** + * @typedef {Nominal} MyNominal + */ +declare const c: any; +type MyNominal = string & { + [Symbol.species]: "MyNominal"; +}; + +---------------------------------------------------------------------- +text: (220-361) +/** + * @return {keyof typeof variable} + */ +declare function getVar(): "key"; +declare namespace variable { + const key: MyNominal; +} + +====================================================================== + diff --git a/tests/baselines/reference/tsbuild/javascriptProjectEmit/initial-build/modifies-outfile-js-projects-and-concatenates-them-correctly.js b/tests/baselines/reference/tsbuild/javascriptProjectEmit/initial-build/modifies-outfile-js-projects-and-concatenates-them-correctly.js new file mode 100644 index 0000000000000..c46f5e3baa1f9 --- /dev/null +++ b/tests/baselines/reference/tsbuild/javascriptProjectEmit/initial-build/modifies-outfile-js-projects-and-concatenates-them-correctly.js @@ -0,0 +1,342 @@ +//// [/lib/initial-buildOutput.txt] +/lib/tsc -b /src +exitCode:: 0 + + +//// [/src/common/common.d.ts] +type Nominal = T & { + [Symbol.species]: Name; +}; + + +//// [/src/common/common.js] +/** + * @template T, Name + * @typedef {T & {[Symbol.species]: Name}} Nominal + */ + + +//// [/src/common/common.tsbuildinfo] +{ + "bundle": { + "commonSourceDirectory": "..", + "sourceFiles": [ + "./nominal.js" + ], + "js": { + "sections": [ + { + "pos": 0, + "end": 84, + "kind": "text" + } + ] + }, + "dts": { + "sections": [ + { + "pos": 0, + "end": 64, + "kind": "text" + } + ] + } + }, + "version": "FakeTSVersion" +} + +//// [/src/common/common.tsbuildinfo.baseline.txt] +====================================================================== +File:: /src/common/common.js +---------------------------------------------------------------------- +text: (0-84) +/** + * @template T, Name + * @typedef {T & {[Symbol.species]: Name}} Nominal + */ + +====================================================================== +====================================================================== +File:: /src/common/common.d.ts +---------------------------------------------------------------------- +text: (0-64) +type Nominal = T & { + [Symbol.species]: Name; +}; + +====================================================================== + +//// [/src/sub-project/sub-project.d.ts] +type Nominal = T & { + [Symbol.species]: Name; +}; +/** + * @typedef {Nominal} MyNominal + */ +declare const c: any; +type MyNominal = string & { + [Symbol.species]: "MyNominal"; +}; + + +//// [/src/sub-project/sub-project.js] +/** + * @template T, Name + * @typedef {T & {[Symbol.species]: Name}} Nominal + */ +/** + * @typedef {Nominal} MyNominal + */ +var c = /** @type {*} */ (null); + + +//// [/src/sub-project/sub-project.tsbuildinfo] +{ + "bundle": { + "commonSourceDirectory": "..", + "sourceFiles": [ + "./index.js" + ], + "js": { + "sections": [ + { + "pos": 0, + "end": 84, + "kind": "prepend", + "data": "../common/common.js", + "texts": [ + { + "pos": 0, + "end": 84, + "kind": "text" + } + ] + }, + { + "pos": 84, + "end": 182, + "kind": "text" + } + ] + }, + "dts": { + "sections": [ + { + "pos": 0, + "end": 64, + "kind": "prepend", + "data": "../common/common.d.ts", + "texts": [ + { + "pos": 0, + "end": 64, + "kind": "text" + } + ] + }, + { + "pos": 64, + "end": 220, + "kind": "text" + } + ] + } + }, + "version": "FakeTSVersion" +} + +//// [/src/sub-project/sub-project.tsbuildinfo.baseline.txt] +====================================================================== +File:: /src/sub-project/sub-project.js +---------------------------------------------------------------------- +prepend: (0-84):: ../common/common.js texts:: 1 +>>-------------------------------------------------------------------- +text: (0-84) +/** + * @template T, Name + * @typedef {T & {[Symbol.species]: Name}} Nominal + */ + +---------------------------------------------------------------------- +text: (84-182) +/** + * @typedef {Nominal} MyNominal + */ +var c = /** @type {*} */ (null); + +====================================================================== +====================================================================== +File:: /src/sub-project/sub-project.d.ts +---------------------------------------------------------------------- +prepend: (0-64):: ../common/common.d.ts texts:: 1 +>>-------------------------------------------------------------------- +text: (0-64) +type Nominal = T & { + [Symbol.species]: Name; +}; + +---------------------------------------------------------------------- +text: (64-220) +/** + * @typedef {Nominal} MyNominal + */ +declare const c: any; +type MyNominal = string & { + [Symbol.species]: "MyNominal"; +}; + +====================================================================== + +//// [/src/sub-project-2/sub-project-2.d.ts] +type Nominal = T & { + [Symbol.species]: Name; +}; +/** + * @typedef {Nominal} MyNominal + */ +declare const c: any; +type MyNominal = string & { + [Symbol.species]: "MyNominal"; +}; +/** + * @return {keyof typeof variable} + */ +declare function getVar(): "key"; +declare namespace variable { + const key: MyNominal; +} + + +//// [/src/sub-project-2/sub-project-2.js] +/** + * @template T, Name + * @typedef {T & {[Symbol.species]: Name}} Nominal + */ +/** + * @typedef {Nominal} MyNominal + */ +var c = /** @type {*} */ (null); +var variable = { + key: /** @type {MyNominal} */ ('value') +}; +/** + * @return {keyof typeof variable} + */ +function getVar() { + return 'key'; +} + + +//// [/src/sub-project-2/sub-project-2.tsbuildinfo] +{ + "bundle": { + "commonSourceDirectory": "..", + "sourceFiles": [ + "./index.js" + ], + "js": { + "sections": [ + { + "pos": 0, + "end": 182, + "kind": "prepend", + "data": "../sub-project/sub-project.js", + "texts": [ + { + "pos": 0, + "end": 182, + "kind": "text" + } + ] + }, + { + "pos": 182, + "end": 338, + "kind": "text" + } + ] + }, + "dts": { + "sections": [ + { + "pos": 0, + "end": 220, + "kind": "prepend", + "data": "../sub-project/sub-project.d.ts", + "texts": [ + { + "pos": 0, + "end": 220, + "kind": "text" + } + ] + }, + { + "pos": 220, + "end": 361, + "kind": "text" + } + ] + } + }, + "version": "FakeTSVersion" +} + +//// [/src/sub-project-2/sub-project-2.tsbuildinfo.baseline.txt] +====================================================================== +File:: /src/sub-project-2/sub-project-2.js +---------------------------------------------------------------------- +prepend: (0-182):: ../sub-project/sub-project.js texts:: 1 +>>-------------------------------------------------------------------- +text: (0-182) +/** + * @template T, Name + * @typedef {T & {[Symbol.species]: Name}} Nominal + */ +/** + * @typedef {Nominal} MyNominal + */ +var c = /** @type {*} */ (null); + +---------------------------------------------------------------------- +text: (182-338) +var variable = { + key: /** @type {MyNominal} */ ('value') +}; +/** + * @return {keyof typeof variable} + */ +function getVar() { + return 'key'; +} + +====================================================================== +====================================================================== +File:: /src/sub-project-2/sub-project-2.d.ts +---------------------------------------------------------------------- +prepend: (0-220):: ../sub-project/sub-project.d.ts texts:: 1 +>>-------------------------------------------------------------------- +text: (0-220) +type Nominal = T & { + [Symbol.species]: Name; +}; +/** + * @typedef {Nominal} MyNominal + */ +declare const c: any; +type MyNominal = string & { + [Symbol.species]: "MyNominal"; +}; + +---------------------------------------------------------------------- +text: (220-361) +/** + * @return {keyof typeof variable} + */ +declare function getVar(): "key"; +declare namespace variable { + const key: MyNominal; +} + +====================================================================== + diff --git a/tests/baselines/reference/typeFromPropertyAssignment17.types b/tests/baselines/reference/typeFromPropertyAssignment17.types index 8d32ac016b3ff..92577ce1da50b 100644 --- a/tests/baselines/reference/typeFromPropertyAssignment17.types +++ b/tests/baselines/reference/typeFromPropertyAssignment17.types @@ -1,8 +1,8 @@ === tests/cases/conformance/salsa/use.js === /// var mini = require('./minimatch') ->mini : typeof minimatch ->require('./minimatch') : typeof minimatch +>mini : typeof import("tests/cases/conformance/salsa/minimatch") +>require('./minimatch') : typeof import("tests/cases/conformance/salsa/minimatch") >require : any >'./minimatch' : "./minimatch" @@ -10,7 +10,7 @@ mini.M.defaults() >mini.M.defaults() : any >mini.M.defaults : (def: any) => any >mini.M : typeof M ->mini : typeof minimatch +>mini : typeof import("tests/cases/conformance/salsa/minimatch") >M : typeof M >defaults : (def: any) => any @@ -18,7 +18,7 @@ var m = new mini.M() >m : M >new mini.M() : M >mini.M : typeof M ->mini : typeof minimatch +>mini : typeof import("tests/cases/conformance/salsa/minimatch") >M : typeof M m.m() @@ -30,7 +30,7 @@ m.m() mini.filter() >mini.filter() : void >mini.filter : () => void ->mini : typeof minimatch +>mini : typeof import("tests/cases/conformance/salsa/minimatch") >filter : () => void === tests/cases/conformance/salsa/types.d.ts === diff --git a/tests/baselines/reference/typeFromPropertyAssignment19.types b/tests/baselines/reference/typeFromPropertyAssignment19.types index 87c76be3099ea..2f5f0e87ad324 100644 --- a/tests/baselines/reference/typeFromPropertyAssignment19.types +++ b/tests/baselines/reference/typeFromPropertyAssignment19.types @@ -1,8 +1,8 @@ === tests/cases/conformance/salsa/index.js === /// const C = require("./semver") ->C : typeof C ->require("./semver") : typeof C +>C : typeof import("tests/cases/conformance/salsa/semver") +>require("./semver") : typeof import("tests/cases/conformance/salsa/semver") >require : any >"./semver" : "./semver" @@ -10,7 +10,7 @@ var two = C.f(1) >two : any >C.f(1) : any >C.f : (n: any) => any ->C : typeof C +>C : typeof import("tests/cases/conformance/salsa/semver") >f : (n: any) => any >1 : 1 diff --git a/tests/baselines/reference/typedefCrossModule2.types b/tests/baselines/reference/typedefCrossModule2.types index 419a176227d4a..00310fe009928 100644 --- a/tests/baselines/reference/typedefCrossModule2.types +++ b/tests/baselines/reference/typedefCrossModule2.types @@ -1,7 +1,7 @@ === tests/cases/conformance/jsdoc/use.js === var mod = require('./mod1.js'); ->mod : { Baz: any; Bar: typeof Bar; Quid: any; } | { Quack: any; Bar: typeof Bar; Quid: any; } ->require('./mod1.js') : { Baz: any; Bar: typeof Bar; Quid: any; } | { Quack: any; Bar: typeof Bar; Quid: any; } +>mod : { Baz: any; Bar: typeof Bar; Quid: number; } | { Quack: any; Bar: typeof Bar; Quid: number; } +>require('./mod1.js') : { Baz: any; Bar: typeof Bar; Quid: number; } | { Quack: any; Bar: typeof Bar; Quid: number; } >require : any >'./mod1.js' : "./mod1.js" @@ -17,7 +17,7 @@ var bbb = new mod.Baz(); >bbb : any >new mod.Baz() : any >mod.Baz : any ->mod : { Baz: any; Bar: typeof Bar; Quid: any; } | { Quack: any; Bar: typeof Bar; Quid: any; } +>mod : { Baz: any; Bar: typeof Bar; Quid: number; } | { Quack: any; Bar: typeof Bar; Quid: number; } >Baz : any === tests/cases/conformance/jsdoc/mod1.js === @@ -31,16 +31,16 @@ class Foo { } // should error exports.Bar = class { } >exports.Bar = class { } : typeof Bar >exports.Bar : typeof Bar ->exports : { Baz: any; Bar: typeof Bar; Quid: any; } | { Quack: any; Bar: typeof Bar; Quid: any; } +>exports : { Baz: any; Bar: typeof Bar; Quid: number; } | { Quack: any; Bar: typeof Bar; Quid: number; } >Bar : typeof Bar >class { } : typeof Bar /** @typedef {number} Baz */ module.exports = { ->module.exports = { Baz: class { }} : { Baz: any; Bar: typeof Bar; Quid: any; } | { Quack: any; Bar: typeof Bar; Quid: any; } ->module.exports : { Baz: any; Bar: typeof Bar; Quid: any; } | { Quack: any; Bar: typeof Bar; Quid: any; } ->module : { "tests/cases/conformance/jsdoc/mod1": { Baz: any; Bar: typeof Bar; Quid: any; } | { Quack: any; Bar: typeof Bar; Quid: any; }; } ->exports : { Baz: any; Bar: typeof Bar; Quid: any; } | { Quack: any; Bar: typeof Bar; Quid: any; } +>module.exports = { Baz: class { }} : { Baz: any; Bar: typeof Bar; Quid: number; } | { Quack: any; Bar: typeof Bar; Quid: number; } +>module.exports : { Baz: any; Bar: typeof Bar; Quid: number; } | { Quack: any; Bar: typeof Bar; Quid: number; } +>module : { "tests/cases/conformance/jsdoc/mod1": { Baz: any; Bar: typeof Bar; Quid: number; } | { Quack: any; Bar: typeof Bar; Quid: number; }; } +>exports : { Baz: any; Bar: typeof Bar; Quid: number; } | { Quack: any; Bar: typeof Bar; Quid: number; } >{ Baz: class { }} : { Baz: typeof Baz; } Baz: class { } @@ -58,17 +58,17 @@ var Qux = 2; /** @typedef {number} Quid */ exports.Quid = 2; >exports.Quid = 2 : 2 ->exports.Quid : any ->exports : { Baz: any; Bar: typeof Bar; Quid: any; } | { Quack: any; Bar: typeof Bar; Quid: any; } ->Quid : any +>exports.Quid : number +>exports : { Baz: any; Bar: typeof Bar; Quid: number; } | { Quack: any; Bar: typeof Bar; Quid: number; } +>Quid : number >2 : 2 /** @typedef {number} Quack */ module.exports = { ->module.exports = { Quack: 2} : { Baz: any; Bar: typeof Bar; Quid: any; } | { Quack: any; Bar: typeof Bar; Quid: any; } ->module.exports : { Baz: any; Bar: typeof Bar; Quid: any; } | { Quack: any; Bar: typeof Bar; Quid: any; } ->module : { "tests/cases/conformance/jsdoc/mod1": { Baz: any; Bar: typeof Bar; Quid: any; } | { Quack: any; Bar: typeof Bar; Quid: any; }; } ->exports : { Baz: any; Bar: typeof Bar; Quid: any; } | { Quack: any; Bar: typeof Bar; Quid: any; } +>module.exports = { Quack: 2} : { Baz: any; Bar: typeof Bar; Quid: number; } | { Quack: any; Bar: typeof Bar; Quid: number; } +>module.exports : { Baz: any; Bar: typeof Bar; Quid: number; } | { Quack: any; Bar: typeof Bar; Quid: number; } +>module : { "tests/cases/conformance/jsdoc/mod1": { Baz: any; Bar: typeof Bar; Quid: number; } | { Quack: any; Bar: typeof Bar; Quid: number; }; } +>exports : { Baz: any; Bar: typeof Bar; Quid: number; } | { Quack: any; Bar: typeof Bar; Quid: number; } >{ Quack: 2} : { Quack: number; } Quack: 2 diff --git a/tests/baselines/reference/umd-augmentation-2.symbols b/tests/baselines/reference/umd-augmentation-2.symbols index d24f1367f83f2..ee138add1996a 100644 --- a/tests/baselines/reference/umd-augmentation-2.symbols +++ b/tests/baselines/reference/umd-augmentation-2.symbols @@ -3,9 +3,9 @@ /// let v = new Math2d.Vector(3, 2); >v : Symbol(v, Decl(a.ts, 2, 3)) ->Math2d.Vector : Symbol(Vector, Decl(index.d.ts, 5, 1), Decl(math2d-augment.d.ts, 2, 25)) +>Math2d.Vector : Symbol(Math2d.Vector, Decl(index.d.ts, 5, 1), Decl(math2d-augment.d.ts, 2, 25)) >Math2d : Symbol(Math2d, Decl(index.d.ts, 0, 0)) ->Vector : Symbol(Vector, Decl(index.d.ts, 5, 1), Decl(math2d-augment.d.ts, 2, 25)) +>Vector : Symbol(Math2d.Vector, Decl(index.d.ts, 5, 1), Decl(math2d-augment.d.ts, 2, 25)) let magnitude = Math2d.getLength(v); >magnitude : Symbol(magnitude, Decl(a.ts, 3, 3)) @@ -18,15 +18,15 @@ let p: Math2d.Point = v.translate(5, 5); >p : Symbol(p, Decl(a.ts, 4, 3)) >Math2d : Symbol(Math2d, Decl(index.d.ts, 0, 0)) >Point : Symbol(Math2d.Point, Decl(index.d.ts, 0, 27)) ->v.translate : Symbol(Vector.translate, Decl(index.d.ts, 10, 35)) +>v.translate : Symbol(Math2d.Vector.translate, Decl(index.d.ts, 10, 35)) >v : Symbol(v, Decl(a.ts, 2, 3)) ->translate : Symbol(Vector.translate, Decl(index.d.ts, 10, 35)) +>translate : Symbol(Math2d.Vector.translate, Decl(index.d.ts, 10, 35)) p = v.reverse(); >p : Symbol(p, Decl(a.ts, 4, 3)) ->v.reverse : Symbol(Vector.reverse, Decl(math2d-augment.d.ts, 4, 19)) +>v.reverse : Symbol(Math2d.Vector.reverse, Decl(math2d-augment.d.ts, 4, 19)) >v : Symbol(v, Decl(a.ts, 2, 3)) ->reverse : Symbol(Vector.reverse, Decl(math2d-augment.d.ts, 4, 19)) +>reverse : Symbol(Math2d.Vector.reverse, Decl(math2d-augment.d.ts, 4, 19)) var t = p.x; >t : Symbol(t, Decl(a.ts, 6, 3)) diff --git a/tests/baselines/reference/umd-augmentation-2.types b/tests/baselines/reference/umd-augmentation-2.types index 45b4f7f855d08..f5806f71d96fb 100644 --- a/tests/baselines/reference/umd-augmentation-2.types +++ b/tests/baselines/reference/umd-augmentation-2.types @@ -2,29 +2,29 @@ /// /// let v = new Math2d.Vector(3, 2); ->v : import("tests/cases/conformance/externalModules/node_modules/math2d/index").Vector ->new Math2d.Vector(3, 2) : import("tests/cases/conformance/externalModules/node_modules/math2d/index").Vector ->Math2d.Vector : typeof import("tests/cases/conformance/externalModules/node_modules/math2d/index").Vector +>v : Math2d.Vector +>new Math2d.Vector(3, 2) : Math2d.Vector +>Math2d.Vector : typeof Math2d.Vector >Math2d : typeof Math2d ->Vector : typeof import("tests/cases/conformance/externalModules/node_modules/math2d/index").Vector +>Vector : typeof Math2d.Vector >3 : 3 >2 : 2 let magnitude = Math2d.getLength(v); >magnitude : number >Math2d.getLength(v) : number ->Math2d.getLength : (p: import("tests/cases/conformance/externalModules/node_modules/math2d/index").Vector) => number +>Math2d.getLength : (p: Math2d.Vector) => number >Math2d : typeof Math2d ->getLength : (p: import("tests/cases/conformance/externalModules/node_modules/math2d/index").Vector) => number ->v : import("tests/cases/conformance/externalModules/node_modules/math2d/index").Vector +>getLength : (p: Math2d.Vector) => number +>v : Math2d.Vector let p: Math2d.Point = v.translate(5, 5); >p : Math2d.Point >Math2d : any ->v.translate(5, 5) : import("tests/cases/conformance/externalModules/node_modules/math2d/index").Vector ->v.translate : (dx: number, dy: number) => import("tests/cases/conformance/externalModules/node_modules/math2d/index").Vector ->v : import("tests/cases/conformance/externalModules/node_modules/math2d/index").Vector ->translate : (dx: number, dy: number) => import("tests/cases/conformance/externalModules/node_modules/math2d/index").Vector +>v.translate(5, 5) : Math2d.Vector +>v.translate : (dx: number, dy: number) => Math2d.Vector +>v : Math2d.Vector +>translate : (dx: number, dy: number) => Math2d.Vector >5 : 5 >5 : 5 @@ -33,7 +33,7 @@ p = v.reverse(); >p : Math2d.Point >v.reverse() : Math2d.Point >v.reverse : () => Math2d.Point ->v : import("tests/cases/conformance/externalModules/node_modules/math2d/index").Vector +>v : Math2d.Vector >reverse : () => Math2d.Point var t = p.x; diff --git a/tests/baselines/reference/umd-augmentation-3.types b/tests/baselines/reference/umd-augmentation-3.types index 18162921124c4..2c0f2dca8960c 100644 --- a/tests/baselines/reference/umd-augmentation-3.types +++ b/tests/baselines/reference/umd-augmentation-3.types @@ -49,7 +49,7 @@ export as namespace Math2d; >Math2d : typeof import("tests/cases/conformance/externalModules/node_modules/math2d/index.d.ts") export = M2D; ->M2D : typeof M2D +>M2D : typeof import("tests/cases/conformance/externalModules/node_modules/math2d/index") declare namespace M2D { >M2D : typeof import("tests/cases/conformance/externalModules/node_modules/math2d/index.d.ts") diff --git a/tests/baselines/reference/umd-augmentation-4.types b/tests/baselines/reference/umd-augmentation-4.types index bb68c080d2ee0..94c8fa957f31f 100644 --- a/tests/baselines/reference/umd-augmentation-4.types +++ b/tests/baselines/reference/umd-augmentation-4.types @@ -47,7 +47,7 @@ export as namespace Math2d; >Math2d : typeof import("tests/cases/conformance/externalModules/node_modules/math2d/index.d.ts") export = M2D; ->M2D : typeof M2D +>M2D : typeof import("tests/cases/conformance/externalModules/node_modules/math2d/index") declare namespace M2D { >M2D : typeof import("tests/cases/conformance/externalModules/node_modules/math2d/index.d.ts") diff --git a/tests/baselines/reference/umd9.types b/tests/baselines/reference/umd9.types index e4fc9376efdad..d62eafb475447 100644 --- a/tests/baselines/reference/umd9.types +++ b/tests/baselines/reference/umd9.types @@ -1,8 +1,8 @@ === tests/cases/conformance/externalModules/a.ts === /// export const x = Foo; // OK in value position because allowUmdGlobalAccess: true ->x : typeof Thing ->Foo : typeof Thing +>x : typeof import("tests/cases/conformance/externalModules/foo") +>Foo : typeof import("tests/cases/conformance/externalModules/foo") === tests/cases/conformance/externalModules/foo.d.ts === declare class Thing { diff --git a/tests/baselines/reference/umdNamespaceMergedWithGlobalAugmentationIsNotCircular.types b/tests/baselines/reference/umdNamespaceMergedWithGlobalAugmentationIsNotCircular.types index 2c0ce91aec8d5..1f5373f82c806 100644 --- a/tests/baselines/reference/umdNamespaceMergedWithGlobalAugmentationIsNotCircular.types +++ b/tests/baselines/reference/umdNamespaceMergedWithGlobalAugmentationIsNotCircular.types @@ -10,10 +10,10 @@ export { }; === tests/cases/compiler/module.d.ts === export = React; ->React : typeof React +>React : typeof import("tests/cases/compiler/module") export as namespace React; ->React : typeof React +>React : typeof import("tests/cases/compiler/module") declare namespace React { >React : typeof React diff --git a/tests/cases/compiler/declarationFileNoCrashOnExtraExportModifier.ts b/tests/cases/compiler/declarationFileNoCrashOnExtraExportModifier.ts new file mode 100644 index 0000000000000..2bd193dfca6dd --- /dev/null +++ b/tests/cases/compiler/declarationFileNoCrashOnExtraExportModifier.ts @@ -0,0 +1,14 @@ +// @filename: input.ts +export = exports; +declare class exports { + constructor(p: number); + t: number; +} +export class Sub { + instance!: { + t: number; + }; +} +declare namespace exports { + export { Sub }; +} \ No newline at end of file diff --git a/tests/cases/compiler/declarationImportTypeAliasInferredAndEmittable.ts b/tests/cases/compiler/declarationImportTypeAliasInferredAndEmittable.ts new file mode 100644 index 0000000000000..a63ae7f75ddd0 --- /dev/null +++ b/tests/cases/compiler/declarationImportTypeAliasInferredAndEmittable.ts @@ -0,0 +1,19 @@ +// @declaration: true +// @filename: foo.ts +class Conn { + constructor() { } + item = 3; + method() { } +} + +export = Conn; +// @filename: usage.ts +type Conn = import("./foo"); +declare var x: Conn; + +export class Wrap { + connItem: number; + constructor(c = x) { + this.connItem = c.item; + } +} diff --git a/tests/cases/compiler/jsFileCompilationDuplicateVariable.ts b/tests/cases/compiler/jsFileCompilationDuplicateVariable.ts index cf2e27de885e5..b100fc748c83d 100644 --- a/tests/cases/compiler/jsFileCompilationDuplicateVariable.ts +++ b/tests/cases/compiler/jsFileCompilationDuplicateVariable.ts @@ -5,4 +5,4 @@ var x = 10; // @filename: b.js -var x = "hello"; // No error is recorded here and declaration file will show this as number \ No newline at end of file +var x = "hello"; // Error is recorded here, but suppressed because the js file isn't checked \ No newline at end of file diff --git a/tests/cases/compiler/jsFileCompilationDuplicateVariableErrorReported.ts b/tests/cases/compiler/jsFileCompilationDuplicateVariableErrorReported.ts index 05b750fe6082b..11b7711eb0eff 100644 --- a/tests/cases/compiler/jsFileCompilationDuplicateVariableErrorReported.ts +++ b/tests/cases/compiler/jsFileCompilationDuplicateVariableErrorReported.ts @@ -5,4 +5,4 @@ var x = "hello"; // @filename: a.ts -var x = 10; // Error reported so no declaration file generated? \ No newline at end of file +var x = 10; // Error reported \ No newline at end of file diff --git a/tests/cases/compiler/jsFileCompilationErrorOnDeclarationsWithJsFileReferenceWithNoOut.ts b/tests/cases/compiler/jsFileCompilationErrorOnDeclarationsWithJsFileReferenceWithNoOut.ts index 1741e3c280270..347c501c88ef5 100644 --- a/tests/cases/compiler/jsFileCompilationErrorOnDeclarationsWithJsFileReferenceWithNoOut.ts +++ b/tests/cases/compiler/jsFileCompilationErrorOnDeclarationsWithJsFileReferenceWithNoOut.ts @@ -6,7 +6,7 @@ class c { // @filename: b.ts /// -// b.d.ts should have c.js as the reference path since we dont emit declarations for js files +// b.d.ts should have c.d.ts as the reference path function foo() { } diff --git a/tests/cases/compiler/jsFileCompilationErrorOnDeclarationsWithJsFileReferenceWithOut.ts b/tests/cases/compiler/jsFileCompilationErrorOnDeclarationsWithJsFileReferenceWithOut.ts index 35228678bb72a..d2173ba28ef8c 100644 --- a/tests/cases/compiler/jsFileCompilationErrorOnDeclarationsWithJsFileReferenceWithOut.ts +++ b/tests/cases/compiler/jsFileCompilationErrorOnDeclarationsWithJsFileReferenceWithOut.ts @@ -7,7 +7,6 @@ class c { // @filename: b.ts /// -// error on above reference when emitting declarations function foo() { } diff --git a/tests/cases/compiler/jsFileCompilationErrorOnDeclarationsWithJsFileReferenceWithOutDir.ts b/tests/cases/compiler/jsFileCompilationErrorOnDeclarationsWithJsFileReferenceWithOutDir.ts index 64e009c251591..39cead024e599 100644 --- a/tests/cases/compiler/jsFileCompilationErrorOnDeclarationsWithJsFileReferenceWithOutDir.ts +++ b/tests/cases/compiler/jsFileCompilationErrorOnDeclarationsWithJsFileReferenceWithOutDir.ts @@ -7,7 +7,6 @@ class c { // @filename: b.ts /// -// b.d.ts should have c.js as the reference path since we dont emit declarations for js files function foo() { } diff --git a/tests/cases/compiler/namespacesWithTypeAliasOnlyExportsMerge.ts b/tests/cases/compiler/namespacesWithTypeAliasOnlyExportsMerge.ts new file mode 100644 index 0000000000000..30e02a20dfa21 --- /dev/null +++ b/tests/cases/compiler/namespacesWithTypeAliasOnlyExportsMerge.ts @@ -0,0 +1,44 @@ +// @filename: constAndNS.ts +type A = number; +declare const Q: number; +declare namespace Q { + export { A }; +} +declare const try1: Q.A; +declare namespace Q2 { + export { Q } +} +declare const try2: Q2.Q.A; +declare namespace Q3 { + export {A as B}; +} +declare const try3: Q3.B; +declare namespace Q4 { + export { Q as default }; +} +declare const try4: Q4.default.A; +export {}; +// @filename: circular.ts +declare namespace NS1 { + export { NS2 }; +} +declare namespace NS2 { + export { NS1 }; +} +export {}; +// @filename: circularWithUses.ts +type A = string; +type B = number; +declare namespace NS1 { + export { NS2, A }; +} +declare namespace NS2 { + export { NS1, B }; +} +export {}; +declare const try1: NS1.A; +declare const try2: NS2.B; +declare const try3: NS1.NS2.B; +declare const try4: NS2.NS1.A; +declare const try5: NS1.NS2.NS1.A; +declare const try6: NS2.NS1.NS2.B; diff --git a/tests/cases/compiler/noCircularDefinitionOnExportOfPrivateInMergedNamespace.ts b/tests/cases/compiler/noCircularDefinitionOnExportOfPrivateInMergedNamespace.ts new file mode 100644 index 0000000000000..12f6c3dacfa96 --- /dev/null +++ b/tests/cases/compiler/noCircularDefinitionOnExportOfPrivateInMergedNamespace.ts @@ -0,0 +1,6 @@ +const cat = 12; +class Foo {} +export = Foo; +declare namespace Foo { + export { cat }; +} \ No newline at end of file diff --git a/tests/cases/compiler/requireOfJsonFileTypes.ts b/tests/cases/compiler/requireOfJsonFileTypes.ts index ce2aed2e824f2..5681c071cf681 100644 --- a/tests/cases/compiler/requireOfJsonFileTypes.ts +++ b/tests/cases/compiler/requireOfJsonFileTypes.ts @@ -4,6 +4,7 @@ // @strictNullChecks: true // @fullEmitPaths: true // @resolveJsonModule: true +// @declaration: true // @Filename: file1.ts import b = require('./b.json'); diff --git a/tests/cases/conformance/jsdoc/declarations/jsDeclarationsClassExtendsVisibility.ts b/tests/cases/conformance/jsdoc/declarations/jsDeclarationsClassExtendsVisibility.ts new file mode 100644 index 0000000000000..300791253669f --- /dev/null +++ b/tests/cases/conformance/jsdoc/declarations/jsDeclarationsClassExtendsVisibility.ts @@ -0,0 +1,17 @@ +// @allowJs: true +// @checkJs: true +// @target: es5 +// @outDir: ./out +// @declaration: true +// @filename: bar.js +class Bar {} +module.exports = Bar; +// @filename: cls.js +const Bar = require("./bar"); +const Strings = { + a: "A", + b: "B" +}; +class Foo extends Bar {} +module.exports = Foo; +module.exports.Strings = Strings; \ No newline at end of file diff --git a/tests/cases/conformance/jsdoc/declarations/jsDeclarationsClasses.ts b/tests/cases/conformance/jsdoc/declarations/jsDeclarationsClasses.ts new file mode 100644 index 0000000000000..c97f8f5d9001b --- /dev/null +++ b/tests/cases/conformance/jsdoc/declarations/jsDeclarationsClasses.ts @@ -0,0 +1,199 @@ +// @allowJs: true +// @checkJs: true +// @target: es5 +// @outDir: ./out +// @declaration: true +// @filename: index.js +export class A {} + +export class B { + static cat = "cat"; +} + +export class C { + static Cls = class {} +} + +export class D { + /** + * @param {number} a + * @param {number} b + */ + constructor(a, b) {} +} + +/** + * @template T,U + */ +export class E { + /** + * @type {T & U} + */ + field; + + // @readonly is currently unsupported, it seems - included here just in case that changes + /** + * @type {T & U} + * @readonly + */ + readonlyField; + + initializedField = 12; + + /** + * @return {U} + */ + get f1() { return /** @type {*} */(null); } + + /** + * @param {U} _p + */ + set f1(_p) {} + + /** + * @return {U} + */ + get f2() { return /** @type {*} */(null); } + + /** + * @param {U} _p + */ + set f3(_p) {} + + /** + * @param {T} a + * @param {U} b + */ + constructor(a, b) {} + + + /** + * @type {string} + */ + static staticField; + + // @readonly is currently unsupported, it seems - included here just in case that changes + /** + * @type {string} + * @readonly + */ + static staticReadonlyField; + + static staticInitializedField = 12; + + /** + * @return {string} + */ + static get s1() { return ""; } + + /** + * @param {string} _p + */ + static set s1(_p) {} + + /** + * @return {string} + */ + static get s2() { return ""; } + + /** + * @param {string} _p + */ + static set s3(_p) {} +} + +/** + * @template T,U + */ +export class F { + /** + * @type {T & U} + */ + field; + /** + * @param {T} a + * @param {U} b + */ + constructor(a, b) {} + + /** + * @template A,B + * @param {A} a + * @param {B} b + */ + static create(a, b) { return new F(a, b); } +} + +class G {} + +export { G }; + +class HH {} + +export { HH as H }; + +export class I {} +export { I as II }; + +export { J as JJ }; +export class J {} + + +export class K { + constructor() { + this.p1 = 12; + this.p2 = "ok"; + } + + method() { + return this.p1; + } +} + +export class L extends K {} + +export class M extends null { + constructor() { + this.prop = 12; + } +} + + +/** + * @template T + */ +export class N extends L { + /** + * @param {T} param + */ + constructor(param) { + super(); + this.another = param; + } +} + +/** + * @template U + * @extends {N} + */ +export class O extends N { + /** + * @param {U} param + */ + constructor(param) { + super(param); + this.another2 = param; + } +} + +var x = /** @type {*} */(null); + +export class VariableBase extends x {} + +export class HasStatics { + static staticMethod() {} +} + +export class ExtendsStatics extends HasStatics { + static also() {} +} diff --git a/tests/cases/conformance/jsdoc/declarations/jsDeclarationsClassesErr.ts b/tests/cases/conformance/jsdoc/declarations/jsDeclarationsClassesErr.ts new file mode 100644 index 0000000000000..d627fa8236bd7 --- /dev/null +++ b/tests/cases/conformance/jsdoc/declarations/jsDeclarationsClassesErr.ts @@ -0,0 +1,76 @@ +// @allowJs: true +// @checkJs: true +// @target: es5 +// @outDir: ./out +// @declaration: true +// @filename: index.js + +// Pretty much all of this should be an error, (since index signatures and generics are forbidden in js), +// but we should be able to synthesize declarations from the symbols regardless + +export class M { + field: T; +} + +export class N extends M { + other: U; +} + +export class O { + [idx: string]: string; +} + +export class P extends O {} + +export class Q extends O { + [idx: string]: "ok"; +} + +export class R extends O { + [idx: number]: "ok"; +} + +export class S extends O { + [idx: string]: "ok"; + [idx: number]: never; +} + +export class T { + [idx: number]: string; +} + +export class U extends T {} + + +export class V extends T { + [idx: string]: string; +} + +export class W extends T { + [idx: number]: "ok"; +} + +export class X extends T { + [idx: string]: string; + [idx: number]: "ok"; +} + +export class Y { + [idx: string]: {x: number}; + [idx: number]: {x: number, y: number}; +} + +export class Z extends Y {} + +export class AA extends Y { + [idx: string]: {x: number, y: number}; +} + +export class BB extends Y { + [idx: number]: {x: 0, y: 0}; +} + +export class CC extends Y { + [idx: string]: {x: number, y: number}; + [idx: number]: {x: 0, y: 0}; +} diff --git a/tests/cases/conformance/jsdoc/declarations/jsDeclarationsComputedNames.ts b/tests/cases/conformance/jsdoc/declarations/jsDeclarationsComputedNames.ts new file mode 100644 index 0000000000000..6a44652ac54a8 --- /dev/null +++ b/tests/cases/conformance/jsdoc/declarations/jsDeclarationsComputedNames.ts @@ -0,0 +1,32 @@ +// @allowJs: true +// @checkJs: true +// @target: es5 +// @lib: es6 +// @outDir: ./out +// @declaration: true +// @filename: index.js +const TopLevelSym = Symbol(); +const InnerSym = Symbol(); +module.exports = { + [TopLevelSym](x = 12) { + return x; + }, + items: { + [InnerSym]: (arg = {x: 12}) => arg.x + } +} + +// @filename: index2.js +const TopLevelSym = Symbol(); +const InnerSym = Symbol(); + +export class MyClass { + static [TopLevelSym] = 12; + [InnerSym] = "ok"; + /** + * @param {typeof TopLevelSym | typeof InnerSym} _p + */ + constructor(_p = InnerSym) { + // switch on _p + } +} diff --git a/tests/cases/conformance/jsdoc/declarations/jsDeclarationsDefault.ts b/tests/cases/conformance/jsdoc/declarations/jsDeclarationsDefault.ts new file mode 100644 index 0000000000000..35543033b7a4e --- /dev/null +++ b/tests/cases/conformance/jsdoc/declarations/jsDeclarationsDefault.ts @@ -0,0 +1,42 @@ +// @allowJs: true +// @checkJs: true +// @target: es5 +// @outDir: ./out +// @declaration: true +// @filename: index1.js +export default 12; + +// @filename: index2.js +export default function foo() { + return foo; +} +export const x = foo; +export { foo as bar }; + +// @filename: index3.js +export default class Foo { + a = /** @type {Foo} */(null); +}; +export const X = Foo; +export { Foo as Bar }; + +// @filename: index4.js +import Fab from "./index3"; +class Bar extends Fab { + x = /** @type {Bar} */(null); +} +export default Bar; + +// @filename: index5.js +// merge type alias and const (OK) +export default 12; +/** + * @typedef {string | number} default + */ + +// @filename: index6.js +// merge type alias and function (OK) +export default function func() {}; +/** + * @typedef {string | number} default + */ diff --git a/tests/cases/conformance/jsdoc/declarations/jsDeclarationsDefaultsErr.ts b/tests/cases/conformance/jsdoc/declarations/jsDeclarationsDefaultsErr.ts new file mode 100644 index 0000000000000..13134c33cddcc --- /dev/null +++ b/tests/cases/conformance/jsdoc/declarations/jsDeclarationsDefaultsErr.ts @@ -0,0 +1,30 @@ +// @allowJs: true +// @checkJs: true +// @target: es5 +// @outDir: ./out +// @declaration: true +// @filename: index1.js +// merge type alias and alias (should error, see #32367) +class Cls { + x = 12; + static y = "ok" +} +export default Cls; +/** + * @typedef {string | number} default + */ + +// @filename: index2.js +// merge type alias and class (error message improvement needed, see #32368) +export default class C {}; +/** + * @typedef {string | number} default + */ + +// @filename: index3.js +// merge type alias and variable (behavior is borked, see #32366) +const x = 12; +export {x as default}; +/** + * @typedef {string | number} default + */ diff --git a/tests/cases/conformance/jsdoc/declarations/jsDeclarationsEnumTag.ts b/tests/cases/conformance/jsdoc/declarations/jsDeclarationsEnumTag.ts new file mode 100644 index 0000000000000..fb4749e50868b --- /dev/null +++ b/tests/cases/conformance/jsdoc/declarations/jsDeclarationsEnumTag.ts @@ -0,0 +1,53 @@ +// @allowJs: true +// @checkJs: true +// @target: es5 +// @outDir: ./out +// @declaration: true +// @filename: index.js +/** @enum {string} */ +export const Target = { + START: "start", + MIDDLE: "middle", + END: "end", + /** @type {number} */ + OK_I_GUESS: 2 +} +/** @enum number */ +export const Second = { + OK: 1, + /** @type {number} */ + FINE: 2, +} +/** @enum {function(number): number} */ +export const Fs = { + ADD1: n => n + 1, + ID: n => n, + SUB1: n => n - 1 +} + +/** + * @param {Target} t + * @param {Second} s + * @param {Fs} f + */ +export function consume(t,s,f) { + /** @type {string} */ + var str = t + /** @type {number} */ + var num = s + /** @type {(n: number) => number} */ + var fun = f + /** @type {Target} */ + var v = Target.START + v = 'something else' // allowed, like Typescript's classic enums and unlike its string enums +} +/** @param {string} s */ +export function ff(s) { + // element access with arbitrary string is an error only with noImplicitAny + if (!Target[s]) { + return null + } + else { + return Target[s] + } +} diff --git a/tests/cases/conformance/jsdoc/declarations/jsDeclarationsEnums.ts b/tests/cases/conformance/jsdoc/declarations/jsDeclarationsEnums.ts new file mode 100644 index 0000000000000..e0300a4ddc43b --- /dev/null +++ b/tests/cases/conformance/jsdoc/declarations/jsDeclarationsEnums.ts @@ -0,0 +1,68 @@ +// @allowJs: true +// @checkJs: true +// @target: es5 +// @outDir: ./out +// @declaration: true +// @filename: index.js + +// Pretty much all of this should be an error, (since enums are forbidden in js), +// but we should be able to synthesize declarations from the symbols regardless + +export enum A {} + +export enum B { + Member +} + +enum C {} + +export { C }; + +enum DD {} + +export { DD as D }; + +export enum E {} +export { E as EE }; + +export { F as FF }; +export enum F {} + +export enum G { + A = 1, + B, + C +} + +export enum H { + A = "a", + B = "b" +} + +export enum I { + A = "a", + B = 0, + C +} + +export const enum J { + A = 1, + B, + C +} + +export enum K { + None = 0, + A = 1 << 0, + B = 1 << 1, + C = 1 << 2, + Mask = A | B | C, +} + +export const enum L { + None = 0, + A = 1 << 0, + B = 1 << 1, + C = 1 << 2, + Mask = A | B | C, +} diff --git a/tests/cases/conformance/jsdoc/declarations/jsDeclarationsExportAssignedClassExpression.ts b/tests/cases/conformance/jsdoc/declarations/jsDeclarationsExportAssignedClassExpression.ts new file mode 100644 index 0000000000000..cdbe1c37dbf0b --- /dev/null +++ b/tests/cases/conformance/jsdoc/declarations/jsDeclarationsExportAssignedClassExpression.ts @@ -0,0 +1,14 @@ +// @allowJs: true +// @checkJs: true +// @target: es5 +// @outDir: ./out +// @declaration: true +// @filename: index.js +module.exports = class Thing { + /** + * @param {number} p + */ + constructor(p) { + this.t = 12 + p; + } +} \ No newline at end of file diff --git a/tests/cases/conformance/jsdoc/declarations/jsDeclarationsExportAssignedClassExpressionAnonymous.ts b/tests/cases/conformance/jsdoc/declarations/jsDeclarationsExportAssignedClassExpressionAnonymous.ts new file mode 100644 index 0000000000000..339de116c6566 --- /dev/null +++ b/tests/cases/conformance/jsdoc/declarations/jsDeclarationsExportAssignedClassExpressionAnonymous.ts @@ -0,0 +1,14 @@ +// @allowJs: true +// @checkJs: true +// @target: es5 +// @outDir: ./out +// @declaration: true +// @filename: index.js +module.exports = class { + /** + * @param {number} p + */ + constructor(p) { + this.t = 12 + p; + } +} \ No newline at end of file diff --git a/tests/cases/conformance/jsdoc/declarations/jsDeclarationsExportAssignedClassExpressionAnonymousWithSub.ts b/tests/cases/conformance/jsdoc/declarations/jsDeclarationsExportAssignedClassExpressionAnonymousWithSub.ts new file mode 100644 index 0000000000000..0caa95933d3b7 --- /dev/null +++ b/tests/cases/conformance/jsdoc/declarations/jsDeclarationsExportAssignedClassExpressionAnonymousWithSub.ts @@ -0,0 +1,19 @@ +// @allowJs: true +// @checkJs: true +// @target: es5 +// @outDir: ./out +// @declaration: true +// @filename: index.js +module.exports = class { + /** + * @param {number} p + */ + constructor(p) { + this.t = 12 + p; + } +} +module.exports.Sub = class { + constructor() { + this.instance = new module.exports(10); + } +} diff --git a/tests/cases/conformance/jsdoc/declarations/jsDeclarationsExportAssignedClassExpressionShadowing.ts b/tests/cases/conformance/jsdoc/declarations/jsDeclarationsExportAssignedClassExpressionShadowing.ts new file mode 100644 index 0000000000000..847632ca970cd --- /dev/null +++ b/tests/cases/conformance/jsdoc/declarations/jsDeclarationsExportAssignedClassExpressionShadowing.ts @@ -0,0 +1,19 @@ +// @allowJs: true +// @checkJs: true +// @target: es5 +// @outDir: ./out +// @declaration: true +// @filename: index.js +// TODO: Fixup +class A { + member = new Q(); +} +class Q { + x = 42; +} +module.exports = class Q { + constructor() { + this.x = new A(); + } +} +module.exports.Another = Q; diff --git a/tests/cases/conformance/jsdoc/declarations/jsDeclarationsExportAssignedVisibility.ts b/tests/cases/conformance/jsdoc/declarations/jsDeclarationsExportAssignedVisibility.ts new file mode 100644 index 0000000000000..23bbed1af2852 --- /dev/null +++ b/tests/cases/conformance/jsdoc/declarations/jsDeclarationsExportAssignedVisibility.ts @@ -0,0 +1,21 @@ +// @allowJs: true +// @checkJs: true +// @target: es5 +// @outDir: ./out +// @declaration: true +// @filename: obj.js +module.exports = class Obj { + constructor() { + this.x = 12; + } +} +// @filename: index.js +const Obj = require("./obj"); + +class Container { + constructor() { + this.usage = new Obj(); + } +} + +module.exports = Container; \ No newline at end of file diff --git a/tests/cases/conformance/jsdoc/declarations/jsDeclarationsExportAssignmentExpressionPlusSecondary.ts b/tests/cases/conformance/jsdoc/declarations/jsDeclarationsExportAssignmentExpressionPlusSecondary.ts new file mode 100644 index 0000000000000..cf4bf91320aad --- /dev/null +++ b/tests/cases/conformance/jsdoc/declarations/jsDeclarationsExportAssignmentExpressionPlusSecondary.ts @@ -0,0 +1,18 @@ +// @allowJs: true +// @checkJs: true +// @target: es5 +// @outDir: ./out +// @declaration: true +// @filename: index.js +const Strings = { + a: "A", + b: "B" +}; +module.exports = { + thing: "ok", + also: "ok", + desc: { + item: "ok" + } +}; +module.exports.Strings = Strings; diff --git a/tests/cases/conformance/jsdoc/declarations/jsDeclarationsExportAssignmentWithKeywordName.ts b/tests/cases/conformance/jsdoc/declarations/jsDeclarationsExportAssignmentWithKeywordName.ts new file mode 100644 index 0000000000000..0dc741ed83c5b --- /dev/null +++ b/tests/cases/conformance/jsdoc/declarations/jsDeclarationsExportAssignmentWithKeywordName.ts @@ -0,0 +1,14 @@ +// @allowJs: true +// @checkJs: true +// @target: es5 +// @outDir: ./out +// @declaration: true +// @filename: index.js +var x = 12; +module.exports = { + extends: 'base', + more: { + others: ['strs'] + }, + x +}; \ No newline at end of file diff --git a/tests/cases/conformance/jsdoc/declarations/jsDeclarationsExportDefinePropertyEmit.ts b/tests/cases/conformance/jsdoc/declarations/jsDeclarationsExportDefinePropertyEmit.ts new file mode 100644 index 0000000000000..419e0146e9faf --- /dev/null +++ b/tests/cases/conformance/jsdoc/declarations/jsDeclarationsExportDefinePropertyEmit.ts @@ -0,0 +1,63 @@ +// @allowJs: true +// @checkJs: true +// @outDir: ./out +// @declaration: true +// @filename: index.js +Object.defineProperty(module.exports, "a", { value: function a() {} }); + +Object.defineProperty(module.exports, "b", { value: function b() {} }); +Object.defineProperty(module.exports.b, "cat", { value: "cat" }); + +/** + * @param {number} a + * @param {number} b + * @return {string} + */ +function d(a, b) { return /** @type {*} */(null); } +Object.defineProperty(module.exports, "d", { value: d }); + + +/** + * @template T,U + * @param {T} a + * @param {U} b + * @return {T & U} + */ +function e(a, b) { return /** @type {*} */(null); } +Object.defineProperty(module.exports, "e", { value: e }); + +/** + * @template T + * @param {T} a + */ +function f(a) { + return a; +} +Object.defineProperty(module.exports, "f", { value: f }); +Object.defineProperty(module.exports.f, "self", { value: module.exports.f }); + +/** + * @param {{x: string}} a + * @param {{y: typeof module.exports.b}} b + */ +function g(a, b) { + return a.x && b.y(); +} +Object.defineProperty(module.exports, "g", { value: g }); + + +/** + * @param {{x: string}} a + * @param {{y: typeof module.exports.b}} b + */ +function hh(a, b) { + return a.x && b.y(); +} +Object.defineProperty(module.exports, "h", { value: hh }); + +Object.defineProperty(module.exports, "i", { value: function i(){} }); +Object.defineProperty(module.exports, "ii", { value: module.exports.i }); + +// note that this last one doesn't make much sense in cjs, since exports aren't hoisted bindings +Object.defineProperty(module.exports, "jj", { value: module.exports.j }); +Object.defineProperty(module.exports, "j", { value: function j() {} }); diff --git a/tests/cases/conformance/jsdoc/declarations/jsDeclarationsExportForms.ts b/tests/cases/conformance/jsdoc/declarations/jsDeclarationsExportForms.ts new file mode 100644 index 0000000000000..5a512c9c9833f --- /dev/null +++ b/tests/cases/conformance/jsdoc/declarations/jsDeclarationsExportForms.ts @@ -0,0 +1,61 @@ +// @allowJs: true +// @checkJs: true +// @target: es5 +// @outDir: ./out +// @declaration: true +// @filename: cls.js +export class Foo {} + +// @filename: func.js +export function func() {} + +// @filename: bar.js +export * from "./cls"; + +// @filename: bar2.js +export * from "./func"; +export * from "./cls"; + +// @filename: baz.js +import {Foo} from "./cls"; +export {Foo}; + +// @filename: bat.js +import * as ns from "./cls"; +export default ns; + +// @filename: ban.js +import * as ns from "./cls"; +export {ns}; + +// @filename: bol.js +import * as ns from "./cls"; +export { ns as classContainer }; + +// @filename: cjs.js +const ns = require("./cls"); +module.exports = { ns }; + +// @filename: cjs2.js +const ns = require("./cls"); +module.exports = ns; + +// @filename: cjs3.js +const ns = require("./cls"); +module.exports.ns = ns; + +// @filename: cjs4.js +const ns = require("./cls"); +module.exports.names = ns; + +// @filename: includeAll.js +import "./cjs4"; +import "./cjs3"; +import "./cjs2"; +import "./cjs"; +import "./bol"; +import "./ban"; +import "./bat"; +import "./baz"; +import "./bar"; +import "./bar2"; diff --git a/tests/cases/conformance/jsdoc/declarations/jsDeclarationsExportFormsErr.ts b/tests/cases/conformance/jsdoc/declarations/jsDeclarationsExportFormsErr.ts new file mode 100644 index 0000000000000..4360f9a90f368 --- /dev/null +++ b/tests/cases/conformance/jsdoc/declarations/jsDeclarationsExportFormsErr.ts @@ -0,0 +1,24 @@ +// @allowJs: true +// @checkJs: true +// @target: es5 +// @outDir: ./out +// @declaration: true +// @filename: cls.js +export class Foo {} + +// @filename: bar.js +import ns = require("./cls"); +export = ns; // TS Only + +// @filename: bin.js +import * as ns from "./cls"; +module.exports = ns; // We refuse to bind cjs module exports assignments in the same file we find an import in + +// @filename: globalNs.js +export * from "./cls"; +export as namespace GLO; // TS Only + +// @filename: includeAll.js +import "./bar"; +import "./bin"; +import "./globalNs"; diff --git a/tests/cases/conformance/jsdoc/declarations/jsDeclarationsExportSpecifierNonlocal.ts b/tests/cases/conformance/jsdoc/declarations/jsDeclarationsExportSpecifierNonlocal.ts new file mode 100644 index 0000000000000..a636d19bdec31 --- /dev/null +++ b/tests/cases/conformance/jsdoc/declarations/jsDeclarationsExportSpecifierNonlocal.ts @@ -0,0 +1,10 @@ +// @allowJs: true +// @checkJs: true +// @target: es5 +// @outDir: ./out +// @declaration: true +// @filename: source.js +export class Thing {} +export class OtherThing {} +// @filename: index.js +export { Thing, OtherThing as default } from "./source"; diff --git a/tests/cases/conformance/jsdoc/declarations/jsDeclarationsExportSubAssignments.ts b/tests/cases/conformance/jsdoc/declarations/jsDeclarationsExportSubAssignments.ts new file mode 100644 index 0000000000000..f5feb4605d3e8 --- /dev/null +++ b/tests/cases/conformance/jsdoc/declarations/jsDeclarationsExportSubAssignments.ts @@ -0,0 +1,13 @@ +// @allowJs: true +// @checkJs: true +// @target: es5 +// @outDir: ./out +// @declaration: true +// @filename: cls.js +const Strings = { + a: "A", + b: "B" +}; +class Foo {} +module.exports = Foo; +module.exports.Strings = Strings; \ No newline at end of file diff --git a/tests/cases/conformance/jsdoc/declarations/jsDeclarationsFunctionClassesCjsExportAssignment.ts b/tests/cases/conformance/jsdoc/declarations/jsDeclarationsFunctionClassesCjsExportAssignment.ts new file mode 100644 index 0000000000000..cb2cf9968d8a5 --- /dev/null +++ b/tests/cases/conformance/jsdoc/declarations/jsDeclarationsFunctionClassesCjsExportAssignment.ts @@ -0,0 +1,74 @@ +// @allowJs: true +// @checkJs: true +// @target: es5 +// @outDir: ./out +// @declaration: true +// @filename: timer.js +/** + * @param {number} timeout + */ +function Timer(timeout) { + this.timeout = timeout; +} +module.exports = Timer; +// @filename: hook.js +/** + * @typedef {(arg: import("./context")) => void} HookHandler + */ +/** + * @param {HookHandler} handle + */ +function Hook(handle) { + this.handle = handle; +} +module.exports = Hook; + +// @filename: context.js +/** + * Imports + * + * @typedef {import("./timer")} Timer + * @typedef {import("./hook")} Hook + * @typedef {import("./hook").HookHandler} HookHandler + */ + +/** + * Input type definition + * + * @typedef {Object} Input + * @prop {Timer} timer + * @prop {Hook} hook + */ + +/** + * State type definition + * + * @typedef {Object} State + * @prop {Timer} timer + * @prop {Hook} hook + */ + +/** + * New `Context` + * + * @class + * @param {Input} input + */ + +function Context(input) { + if (!(this instanceof Context)) { + return new Context(input) + } + this.state = this.construct(input); +} +Context.prototype = { + /** + * @param {Input} input + * @param {HookHandler=} handle + * @returns {State} + */ + construct(input, handle = () => void 0) { + return input; + } +} +module.exports = Context; diff --git a/tests/cases/conformance/jsdoc/declarations/jsDeclarationsFunctionJSDoc.ts b/tests/cases/conformance/jsdoc/declarations/jsDeclarationsFunctionJSDoc.ts new file mode 100644 index 0000000000000..cfa747d48c8b6 --- /dev/null +++ b/tests/cases/conformance/jsdoc/declarations/jsDeclarationsFunctionJSDoc.ts @@ -0,0 +1,40 @@ +// @allowJs: true +// @checkJs: true +// @target: es5 +// @outDir: ./out +// @declaration: true +// @filename: source.js +/** + * Foos a bar together using an `a` and a `b` + * @param {number} a + * @param {string} b + */ +export function foo(a, b) {} + +/** + * Legacy - DO NOT USE + */ +export class Aleph { + /** + * Impossible to construct. + * @param {Aleph} a + * @param {null} b + */ + constructor(a, b) { + /** + * Field is always null + */ + this.field = b; + } + + /** + * Doesn't actually do anything + * @returns {void} + */ + doIt() {} +} + +/** + * Not the speed of light + */ +export const c = 12; diff --git a/tests/cases/conformance/jsdoc/declarations/jsDeclarationsFunctionLikeClasses.ts b/tests/cases/conformance/jsdoc/declarations/jsDeclarationsFunctionLikeClasses.ts new file mode 100644 index 0000000000000..0732fcfa6b302 --- /dev/null +++ b/tests/cases/conformance/jsdoc/declarations/jsDeclarationsFunctionLikeClasses.ts @@ -0,0 +1,29 @@ +// @allowJs: true +// @checkJs: true +// @target: es5 +// @outDir: ./out +// @declaration: true +// @filename: source.js + +/** + * @param {number} x + * @param {number} y + */ +export function Point(x, y) { + if (!(this instanceof Point)) { + return new Point(x, y); + } + this.x = x; + this.y = y; +} + +// @filename: referencer.js + +import {Point} from "./source"; + +/** + * @param {Point} p + */ +export function magnitude(p) { + return Math.sqrt(p.x ** 2 + p.y ** 2); +} diff --git a/tests/cases/conformance/jsdoc/declarations/jsDeclarationsFunctionLikeClasses2.ts b/tests/cases/conformance/jsdoc/declarations/jsDeclarationsFunctionLikeClasses2.ts new file mode 100644 index 0000000000000..dc58d1e05b4ca --- /dev/null +++ b/tests/cases/conformance/jsdoc/declarations/jsDeclarationsFunctionLikeClasses2.ts @@ -0,0 +1,81 @@ +// @allowJs: true +// @checkJs: true +// @target: es5 +// @outDir: ./out +// @declaration: true +// @filename: source.js + +/** + * @param {number} len + */ +export function Vec(len) { + /** + * @type {number[]} + */ + this.storage = new Array(len); +} + +Vec.prototype = { + /** + * @param {Vec} other + */ + dot(other) { + if (other.storage.length !== this.storage.length) { + throw new Error(`Dot product only applicable for vectors of equal length`); + } + let sum = 0; + for (let i = 0; i < this.storage.length; i++) { + sum += (this.storage[i] * other.storage[i]); + } + return sum; + }, + magnitude() { + let sum = 0; + for (let i = 0; i < this.storage.length; i++) { + sum += (this.storage[i] ** 2); + } + return Math.sqrt(sum); + } +} + +/** + * @param {number} x + * @param {number} y + */ +export function Point2D(x, y) { + if (!(this instanceof Point2D)) { + return new Point2D(x, y); + } + Vec.call(this, 2); + this.x = x; + this.y = y; +} + +Point2D.prototype = { + __proto__: Vec, + get x() { + return this.storage[0]; + }, + /** + * @param {number} x + */ + set x(x) { + this.storage[0] = x; + }, + get y() { + return this.storage[1]; + }, + /** + * @param {number} y + */ + set y(y) { + this.storage[1] = y; + } +}; + +// @filename: referencer.js + +import {Point2D} from "./source"; + +export const origin = new Point2D(0, 0); +// export const res = Point2D(2, 3).dot(origin); // TODO: when __proto__ works, validate this diff --git a/tests/cases/conformance/jsdoc/declarations/jsDeclarationsFunctions.ts b/tests/cases/conformance/jsdoc/declarations/jsDeclarationsFunctions.ts new file mode 100644 index 0000000000000..65247ba282db5 --- /dev/null +++ b/tests/cases/conformance/jsdoc/declarations/jsDeclarationsFunctions.ts @@ -0,0 +1,62 @@ +// @allowJs: true +// @checkJs: true +// @outDir: ./out +// @declaration: true +// @filename: index.js +export function a() {} + +export function b() {} +b.cat = "cat"; + +export function c() {} +c.Cls = class {} + +/** + * @param {number} a + * @param {number} b + * @return {string} + */ +export function d(a, b) { return /** @type {*} */(null); } + +/** + * @template T,U + * @param {T} a + * @param {U} b + * @return {T & U} + */ +export function e(a, b) { return /** @type {*} */(null); } + +/** + * @template T + * @param {T} a + */ +export function f(a) { + return a; +} +f.self = f; + +/** + * @param {{x: string}} a + * @param {{y: typeof b}} b + */ +function g(a, b) { + return a.x && b.y(); +} + +export { g }; + +/** + * @param {{x: string}} a + * @param {{y: typeof b}} b + */ +function hh(a, b) { + return a.x && b.y(); +} + +export { hh as h }; + +export function i() {} +export { i as ii }; + +export { j as jj }; +export function j() {} diff --git a/tests/cases/conformance/jsdoc/declarations/jsDeclarationsFunctionsCjs.ts b/tests/cases/conformance/jsdoc/declarations/jsDeclarationsFunctionsCjs.ts new file mode 100644 index 0000000000000..329ebda040f13 --- /dev/null +++ b/tests/cases/conformance/jsdoc/declarations/jsDeclarationsFunctionsCjs.ts @@ -0,0 +1,63 @@ +// @allowJs: true +// @checkJs: true +// @outDir: ./out +// @declaration: true +// @filename: index.js +module.exports.a = function a() {} + +module.exports.b = function b() {} +module.exports.b.cat = "cat"; + +module.exports.c = function c() {} +module.exports.c.Cls = class {} + +/** + * @param {number} a + * @param {number} b + * @return {string} + */ +module.exports.d = function d(a, b) { return /** @type {*} */(null); } + +/** + * @template T,U + * @param {T} a + * @param {U} b + * @return {T & U} + */ +module.exports.e = function e(a, b) { return /** @type {*} */(null); } + +/** + * @template T + * @param {T} a + */ +module.exports.f = function f(a) { + return a; +} +module.exports.f.self = module.exports.f; + +/** + * @param {{x: string}} a + * @param {{y: typeof module.exports.b}} b + */ +function g(a, b) { + return a.x && b.y(); +} + +module.exports.g = g; + +/** + * @param {{x: string}} a + * @param {{y: typeof module.exports.b}} b + */ +function hh(a, b) { + return a.x && b.y(); +} + +module.exports.h = hh; + +module.exports.i = function i() {} +module.exports.ii = module.exports.i; + +// note that this last one doesn't make much sense in cjs, since exports aren't hoisted bindings +module.exports.jj = module.exports.j; +module.exports.j = function j() {} diff --git a/tests/cases/conformance/jsdoc/declarations/jsDeclarationsImportTypeBundled.ts b/tests/cases/conformance/jsdoc/declarations/jsDeclarationsImportTypeBundled.ts new file mode 100644 index 0000000000000..aa6a5f475466d --- /dev/null +++ b/tests/cases/conformance/jsdoc/declarations/jsDeclarationsImportTypeBundled.ts @@ -0,0 +1,19 @@ +// @allowJs: true +// @checkJs: true +// @outFile: out.js +// @module: amd +// @declaration: true +// @filename: folder/mod1.js +/** + * @typedef {{x: number}} Item + */ +/** + * @type {Item}; + */ +const x = {x: 12}; +module.exports = x; +// @filename: index.js + +/** @type {(typeof import("./folder/mod1"))[]} */ +const items = [{x: 12}]; +module.exports = items; \ No newline at end of file diff --git a/tests/cases/conformance/jsdoc/declarations/jsDeclarationsInterfaces.ts b/tests/cases/conformance/jsdoc/declarations/jsDeclarationsInterfaces.ts new file mode 100644 index 0000000000000..1eb04215792f4 --- /dev/null +++ b/tests/cases/conformance/jsdoc/declarations/jsDeclarationsInterfaces.ts @@ -0,0 +1,125 @@ +// @allowJs: true +// @checkJs: true +// @target: es5 +// @outDir: ./out +// @declaration: true +// @filename: index.js + +// Pretty much all of this should be an error, (since interfaces are forbidden in js), +// but we should be able to synthesize declarations from the symbols regardless + +export interface A {} + +export interface B { + cat: string; +} + +export interface C { + field: T & U; + optionalField?: T; + readonly readonlyField: T & U; + readonly readonlyOptionalField?: U; + (): number; + (x: T): U; + (x: Q): T & Q; + + new (): string; + new (x: T): U; + new (x: Q): T & Q; + + method(): number; + method(a: T & Q): Q & number; + method(a?: number): number; + method(...args: any[]): number; + + optMethod?(): number; +} + +interface G {} + +export { G }; + +interface HH {} + +export { HH as H }; + +export interface I {} +export { I as II }; + +export { J as JJ }; +export interface J {} + +export interface K extends I,J { + x: string; +} + +export interface L extends K { + y: string; +} + +export interface M { + field: T; +} + +export interface N extends M { + other: U; +} + +export interface O { + [idx: string]: string; +} + +export interface P extends O {} + +export interface Q extends O { + [idx: string]: "ok"; +} + +export interface R extends O { + [idx: number]: "ok"; +} + +export interface S extends O { + [idx: string]: "ok"; + [idx: number]: never; +} + +export interface T { + [idx: number]: string; +} + +export interface U extends T {} + + +export interface V extends T { + [idx: string]: string; +} + +export interface W extends T { + [idx: number]: "ok"; +} + +export interface X extends T { + [idx: string]: string; + [idx: number]: "ok"; +} + +export interface Y { + [idx: string]: {x: number}; + [idx: number]: {x: number, y: number}; +} + +export interface Z extends Y {} + +export interface AA extends Y { + [idx: string]: {x: number, y: number}; +} + +export interface BB extends Y { + [idx: number]: {x: 0, y: 0}; +} + +export interface CC extends Y { + [idx: string]: {x: number, y: number}; + [idx: number]: {x: 0, y: 0}; +} diff --git a/tests/cases/conformance/jsdoc/declarations/jsDeclarationsJson.ts b/tests/cases/conformance/jsdoc/declarations/jsDeclarationsJson.ts new file mode 100644 index 0000000000000..a98c41d172827 --- /dev/null +++ b/tests/cases/conformance/jsdoc/declarations/jsDeclarationsJson.ts @@ -0,0 +1,17 @@ +// @allowJs: true +// @checkJs: true +// @target: es5 +// @resolveJsonModule: true +// @outDir: ./out +// @declaration: true +// @filename: index.js +const j = require("./obj.json"); +module.exports = j; +// @filename: obj.json +{ + "x": 12, + "y": 12, + "obj": { + "items": [{"x": 12}, {"x": 12, "y": 12}, {"x": 0}, {"x": -1, "err": true}] + } +} \ No newline at end of file diff --git a/tests/cases/conformance/jsdoc/declarations/jsDeclarationsMultipleExportFromMerge.ts b/tests/cases/conformance/jsdoc/declarations/jsDeclarationsMultipleExportFromMerge.ts new file mode 100644 index 0000000000000..c8e2ef3e4088d --- /dev/null +++ b/tests/cases/conformance/jsdoc/declarations/jsDeclarationsMultipleExportFromMerge.ts @@ -0,0 +1,23 @@ +// @allowJs: true +// @checkJs: true +// @target: es5 +// @outDir: ./out +// @declaration: true +// @filename: items.js +export const a = 1; +export const b = 2; +export const c = 3; + +// @filename: justone.js +export { a, b, c } from "./items"; + +// @filename: two.js +export { a } from "./items"; +export { b, c } from "./items"; + +// @filename: multiple.js +export {a, b} from "./items"; +export {a as aa} from "./two"; +export {b as bb} from "./two"; +export {c} from "./two" +export {c as cc} from "./items"; diff --git a/tests/cases/conformance/jsdoc/declarations/jsDeclarationsPackageJson.ts b/tests/cases/conformance/jsdoc/declarations/jsDeclarationsPackageJson.ts new file mode 100644 index 0000000000000..7a6b8180f74d9 --- /dev/null +++ b/tests/cases/conformance/jsdoc/declarations/jsDeclarationsPackageJson.ts @@ -0,0 +1,42 @@ +// @allowJs: true +// @checkJs: true +// @target: es5 +// @resolveJsonModule: true +// @outDir: ./out +// @declaration: true +// @filename: index.js +const j = require("./package.json"); +module.exports = j; +// @filename: package.json +{ + "name": "pkg", + "version": "0.1.0", + "description": "A package", + "main": "./dist/index.js", + "bin": { + "cli": "./bin/cli.js", + }, + "engines": { + "node": ">=0" + }, + "scripts": { + "scriptname": "run && run again", + }, + "devDependencies": { + "@ns/dep": "0.1.2", + }, + "dependencies": { + "dep": "1.2.3", + }, + "repository": "microsoft/TypeScript", + "keywords": [ + "kw" + ], + "author": "Auth", + "license": "See Licensce", + "homepage": "https://site", + "config": { + "o": ["a"] + } +} + \ No newline at end of file diff --git a/tests/cases/conformance/jsdoc/declarations/jsDeclarationsReexportAliases.ts b/tests/cases/conformance/jsdoc/declarations/jsDeclarationsReexportAliases.ts new file mode 100644 index 0000000000000..3160df7f12853 --- /dev/null +++ b/tests/cases/conformance/jsdoc/declarations/jsDeclarationsReexportAliases.ts @@ -0,0 +1,14 @@ +// @allowJs: true +// @checkJs: true +// @target: es5 +// @outDir: ./out +// @declaration: true +// @filename: cls.js +export default class Foo {} + +// @filename: usage.js +import {default as Fooa} from "./cls"; + +export const x = new Fooa(); + +export {default as Foob} from "./cls"; diff --git a/tests/cases/conformance/jsdoc/declarations/jsDeclarationsReexportAliasesEsModuleInterop.ts b/tests/cases/conformance/jsdoc/declarations/jsDeclarationsReexportAliasesEsModuleInterop.ts new file mode 100644 index 0000000000000..94bb9fe235a20 --- /dev/null +++ b/tests/cases/conformance/jsdoc/declarations/jsDeclarationsReexportAliasesEsModuleInterop.ts @@ -0,0 +1,16 @@ +// @allowJs: true +// @checkJs: true +// @target: es5 +// @outDir: ./out +// @declaration: true +// @esModuleInterop: true +// @filename: cls.js +class Foo {} +module.exports = Foo; + +// @filename: usage.js +import {default as Fooa} from "./cls"; + +export const x = new Fooa(); + +export {default as Foob} from "./cls"; diff --git a/tests/cases/conformance/jsdoc/declarations/jsDeclarationsReusesExistingNodesMappingJSDocTypes.ts b/tests/cases/conformance/jsdoc/declarations/jsDeclarationsReusesExistingNodesMappingJSDocTypes.ts new file mode 100644 index 0000000000000..3c7293ceb824a --- /dev/null +++ b/tests/cases/conformance/jsdoc/declarations/jsDeclarationsReusesExistingNodesMappingJSDocTypes.ts @@ -0,0 +1,30 @@ +// @allowJs: true +// @checkJs: true +// @outDir: /out +// @lib: es6 +// @declaration: true +// @filename: index.js + +/** @type {?} */ +export const a = null; + +/** @type {*} */ +export const b = null; + +/** @type {string?} */ +export const c = null; + +/** @type {string=} */ +export const d = null; + +/** @type {string!} */ +export const e = null; + +/** @type {function(string, number): object} */ +export const f = null; + +/** @type {function(new: object, string, number)} */ +export const g = null; + +/** @type {Object.} */ +export const h = null; diff --git a/tests/cases/conformance/jsdoc/declarations/jsDeclarationsTypeAliases.ts b/tests/cases/conformance/jsdoc/declarations/jsDeclarationsTypeAliases.ts new file mode 100644 index 0000000000000..84ee3f53c9154 --- /dev/null +++ b/tests/cases/conformance/jsdoc/declarations/jsDeclarationsTypeAliases.ts @@ -0,0 +1,54 @@ +// @allowJs: true +// @checkJs: true +// @outDir: ./out +// @declaration: true +// @filename: index.js + +export {}; // flag file as module +/** + * @typedef {string | number | symbol} PropName + */ + +/** + * Callback + * + * @callback NumberToStringCb + * @param {number} a + * @returns {string} + */ + +/** + * @template T + * @typedef {T & {name: string}} MixinName + */ + +/** + * Identity function + * + * @template T + * @callback Identity + * @param {T} x + * @returns {T} + */ + +// @filename: mixed.js +/** + * @typedef {{x: string} | number | LocalThing | ExportedThing} SomeType + */ +/** + * @param {number} x + * @returns {SomeType} + */ +function doTheThing(x) { + return {x: ""+x}; +} +class ExportedThing { + z = "ok" +} +module.exports = { + doTheThing, + ExportedThing, +}; +class LocalThing { + y = "ok" +} diff --git a/tests/cases/conformance/jsdoc/declarations/jsDeclarationsTypeReassignmentFromDeclaration.ts b/tests/cases/conformance/jsdoc/declarations/jsDeclarationsTypeReassignmentFromDeclaration.ts new file mode 100644 index 0000000000000..1d4119c58068b --- /dev/null +++ b/tests/cases/conformance/jsdoc/declarations/jsDeclarationsTypeReassignmentFromDeclaration.ts @@ -0,0 +1,16 @@ +// @allowJs: true +// @checkJs: true +// @outDir: /out +// @lib: es6 +// @declaration: true +// @filename: /some-mod.d.ts +interface Item { + x: string; +} +declare const items: Item[]; +export = items; +// @filename: index.js + +/** @type {typeof import("/some-mod")} */ +const items = []; +module.exports = items; \ No newline at end of file diff --git a/tests/cases/conformance/jsdoc/declarations/jsDeclarationsTypeReassignmentFromDeclaration2.ts b/tests/cases/conformance/jsdoc/declarations/jsDeclarationsTypeReassignmentFromDeclaration2.ts new file mode 100644 index 0000000000000..2a48213d0db88 --- /dev/null +++ b/tests/cases/conformance/jsdoc/declarations/jsDeclarationsTypeReassignmentFromDeclaration2.ts @@ -0,0 +1,15 @@ +// @allowJs: true +// @checkJs: true +// @outDir: ./out +// @lib: es6 +// @declaration: true +// @filename: some-mod.d.ts +interface Item { + x: string; +} +declare function getItems(): Item[]; +export = getItems; +// @filename: index.js + +const items = require("./some-mod")(); +module.exports = items; \ No newline at end of file diff --git a/tests/cases/conformance/jsdoc/declarations/jsDeclarationsTypeReferences.ts b/tests/cases/conformance/jsdoc/declarations/jsDeclarationsTypeReferences.ts new file mode 100644 index 0000000000000..29151bf965625 --- /dev/null +++ b/tests/cases/conformance/jsdoc/declarations/jsDeclarationsTypeReferences.ts @@ -0,0 +1,19 @@ +// @allowJs: true +// @checkJs: true +// @target: es5 +// @outDir: tests/cases/conformance/jsdoc/declarations/out +// @declaration: true +// @filename: node_modules/@types/node/index.d.ts +declare module "fs" { + export class Something {} +} +// @filename: index.js +/// + +const Something = require("fs").Something; + +const thing = new Something(); + +module.exports = { + thing +}; \ No newline at end of file diff --git a/tests/cases/conformance/jsdoc/declarations/jsDeclarationsTypedefAndImportTypes.ts b/tests/cases/conformance/jsdoc/declarations/jsDeclarationsTypedefAndImportTypes.ts new file mode 100644 index 0000000000000..3b5fb6439f431 --- /dev/null +++ b/tests/cases/conformance/jsdoc/declarations/jsDeclarationsTypedefAndImportTypes.ts @@ -0,0 +1,38 @@ +// @allowJs: true +// @checkJs: true +// @outDir: ./out +// @declaration: true +// @filename: conn.js + +/** + * @typedef {string | number} Whatever + */ + +class Conn { + constructor() {} + item = 3; + method() {} +} + +module.exports = Conn; + +// @filename: usage.js + +/** + * @typedef {import("./conn")} Conn + */ + +class Wrap { + /** + * @param {Conn} c + */ + constructor(c) { + this.connItem = c.item; + /** @type {import("./conn").Whatever} */ + this.another = ""; + } +} + +module.exports = { + Wrap +}; diff --git a/tests/cases/conformance/jsdoc/declarations/jsDeclarationsTypedefDescriptionsPreserved.ts b/tests/cases/conformance/jsdoc/declarations/jsDeclarationsTypedefDescriptionsPreserved.ts new file mode 100644 index 0000000000000..d4583d53a4f21 --- /dev/null +++ b/tests/cases/conformance/jsdoc/declarations/jsDeclarationsTypedefDescriptionsPreserved.ts @@ -0,0 +1,21 @@ +// @allowJs: true +// @checkJs: true +// @outDir: ./out +// @declaration: true +// @filename: index.js + +/** + * Options for Foo <------------ + * @typedef {Object} FooOptions + * @property {boolean} bar - Marvin K Mooney + * @property {string} baz - Sylvester McMonkey McBean + */ + +/** + * Multiline + * Options + * for Foo <------------ + * @typedef {Object} BarOptions + * @property {boolean} bar - Marvin K Mooney + * @property {string} baz - Sylvester McMonkey McBean + */ diff --git a/tests/cases/conformance/jsdoc/declarations/jsDeclarationsTypedefPropertyAndExportAssignment.ts b/tests/cases/conformance/jsdoc/declarations/jsDeclarationsTypedefPropertyAndExportAssignment.ts new file mode 100644 index 0000000000000..16d63e0aec40d --- /dev/null +++ b/tests/cases/conformance/jsdoc/declarations/jsDeclarationsTypedefPropertyAndExportAssignment.ts @@ -0,0 +1,59 @@ +// @allowJs: true +// @checkJs: true +// @outDir: ./out +// @lib: es6 +// @declaration: true +// @filename: module.js + +/** @typedef {'parseHTML'|'styleLayout'} TaskGroupIds */ + +/** + * @typedef TaskGroup + * @property {TaskGroupIds} id + * @property {string} label + * @property {string[]} traceEventNames + */ + +/** + * @type {{[P in TaskGroupIds]: {id: P, label: string}}} + */ +const taskGroups = { + parseHTML: { + id: 'parseHTML', + label: 'Parse HTML & CSS' + }, + styleLayout: { + id: 'styleLayout', + label: 'Style & Layout' + }, +} + +/** @type {Object} */ +const taskNameToGroup = {}; + +module.exports = { + taskGroups, + taskNameToGroup, +}; +// @filename: index.js +const {taskGroups, taskNameToGroup} = require('./module.js'); + +/** @typedef {import('./module.js').TaskGroup} TaskGroup */ + +/** + * @typedef TaskNode + * @prop {TaskNode[]} children + * @prop {TaskNode|undefined} parent + * @prop {TaskGroup} group + */ + +/** @typedef {{timers: Map}} PriorTaskData */ +class MainThreadTasks { + /** + * @param {TaskGroup} x + * @param {TaskNode} y + */ + constructor(x, y){} +} + +module.exports = MainThreadTasks; \ No newline at end of file diff --git a/tests/cases/fourslash/jsFileCompilationDuplicateFunctionImplementation.ts b/tests/cases/fourslash/jsFileCompilationDuplicateFunctionImplementation.ts index 927d84ed8bace..58090d0ad3155 100644 --- a/tests/cases/fourslash/jsFileCompilationDuplicateFunctionImplementation.ts +++ b/tests/cases/fourslash/jsFileCompilationDuplicateFunctionImplementation.ts @@ -20,7 +20,7 @@ verify.getSemanticDiagnostics([{ }]); verify.verifyGetEmitOutputContentsForCurrentFile([ { name: "out.js", text: "function foo() { return 10; }\r\nfunction foo() { return 30; }\r\n", writeByteOrderMark: false }, - { name: "out.d.ts", text: "", writeByteOrderMark: false }]); + { name: "out.d.ts", text: "declare function foo(): number;\r\ndeclare function foo(): number;\r\n", writeByteOrderMark: false }]); goTo.marker("2"); verify.getSemanticDiagnostics([{ message: "Duplicate function implementation.",