diff --git a/microsoft/typescript-go b/microsoft/typescript-go index 5ac849745..dcebe5348 160000 --- a/microsoft/typescript-go +++ b/microsoft/typescript-go @@ -1 +1 @@ -Subproject commit 5ac849745370fdc0ce72a07125d6b76b49517d0f +Subproject commit dcebe5348dc64b60a4743ffd148281ee000f2af1 diff --git a/pkg/ast/ast.go b/pkg/ast/ast.go index 87d921477..404193858 100644 --- a/pkg/ast/ast.go +++ b/pkg/ast/ast.go @@ -6141,15 +6141,16 @@ type StringLiteral struct { LiteralLikeBase } -func (f *NodeFactory) NewStringLiteral(text string) *Node { +func (f *NodeFactory) NewStringLiteral(text string, flags TokenFlags) *Node { data := f.stringLiteralPool.New() data.Text = text + data.TokenFlags = flags & TokenFlagsStringLiteralFlags f.textCount++ return f.newNode(KindStringLiteral, data) } func (node *StringLiteral) Clone(f NodeFactoryCoercible) *Node { - return cloneNode(f.AsNodeFactory().NewStringLiteral(node.Text), node.AsNode(), f.AsNodeFactory().hooks) + return cloneNode(f.AsNodeFactory().NewStringLiteral(node.Text, node.TokenFlags), node.AsNode(), f.AsNodeFactory().hooks) } func IsStringLiteral(node *Node) bool { @@ -6163,15 +6164,16 @@ type NumericLiteral struct { LiteralLikeBase } -func (f *NodeFactory) NewNumericLiteral(text string) *Node { +func (f *NodeFactory) NewNumericLiteral(text string, flags TokenFlags) *Node { data := f.numericLiteralPool.New() data.Text = text + data.TokenFlags = flags & TokenFlagsNumericLiteralFlags f.textCount++ return f.newNode(KindNumericLiteral, data) } func (node *NumericLiteral) Clone(f NodeFactoryCoercible) *Node { - return cloneNode(f.AsNodeFactory().NewNumericLiteral(node.Text), node.AsNode(), f.AsNodeFactory().hooks) + return cloneNode(f.AsNodeFactory().NewNumericLiteral(node.Text, node.TokenFlags), node.AsNode(), f.AsNodeFactory().hooks) } func IsNumericLiteral(node *Node) bool { @@ -6185,15 +6187,16 @@ type BigIntLiteral struct { LiteralLikeBase } -func (f *NodeFactory) NewBigIntLiteral(text string) *Node { +func (f *NodeFactory) NewBigIntLiteral(text string, flags TokenFlags) *Node { data := &BigIntLiteral{} data.Text = text + data.TokenFlags = flags & TokenFlagsNumericLiteralFlags f.textCount++ return f.newNode(KindBigIntLiteral, data) } func (node *BigIntLiteral) Clone(f NodeFactoryCoercible) *Node { - return cloneNode(f.AsNodeFactory().NewBigIntLiteral(node.Text), node.AsNode(), f.AsNodeFactory().hooks) + return cloneNode(f.AsNodeFactory().NewBigIntLiteral(node.Text, node.TokenFlags), node.AsNode(), f.AsNodeFactory().hooks) } func (node *BigIntLiteral) computeSubtreeFacts() SubtreeFacts { @@ -6211,15 +6214,16 @@ type RegularExpressionLiteral struct { LiteralLikeBase } -func (f *NodeFactory) NewRegularExpressionLiteral(text string) *Node { +func (f *NodeFactory) NewRegularExpressionLiteral(text string, flags TokenFlags) *Node { data := &RegularExpressionLiteral{} data.Text = text + data.TokenFlags = flags & TokenFlagsRegularExpressionLiteralFlags f.textCount++ return f.newNode(KindRegularExpressionLiteral, data) } func (node *RegularExpressionLiteral) Clone(f NodeFactoryCoercible) *Node { - return cloneNode(f.AsNodeFactory().NewRegularExpressionLiteral(node.Text), node.AsNode(), f.AsNodeFactory().hooks) + return cloneNode(f.AsNodeFactory().NewRegularExpressionLiteral(node.Text, node.TokenFlags), node.AsNode(), f.AsNodeFactory().hooks) } func IsRegularExpressionLiteral(node *Node) bool { @@ -6233,15 +6237,16 @@ type NoSubstitutionTemplateLiteral struct { TemplateLiteralLikeBase } -func (f *NodeFactory) NewNoSubstitutionTemplateLiteral(text string) *Node { +func (f *NodeFactory) NewNoSubstitutionTemplateLiteral(text string, templateFlags TokenFlags) *Node { data := &NoSubstitutionTemplateLiteral{} data.Text = text + data.TemplateFlags = templateFlags & TokenFlagsTemplateLiteralLikeFlags f.textCount++ return f.newNode(KindNoSubstitutionTemplateLiteral, data) } func (node *NoSubstitutionTemplateLiteral) Clone(f NodeFactoryCoercible) *Node { - return cloneNode(f.AsNodeFactory().NewNoSubstitutionTemplateLiteral(node.Text), node.AsNode(), f.AsNodeFactory().hooks) + return cloneNode(f.AsNodeFactory().NewNoSubstitutionTemplateLiteral(node.Text, node.TemplateFlags), node.AsNode(), f.AsNodeFactory().hooks) } // BinaryExpression @@ -8722,7 +8727,7 @@ func (f *NodeFactory) NewTemplateHead(text string, rawText string, templateFlags data := &TemplateHead{} data.Text = text data.RawText = rawText - data.TemplateFlags = templateFlags + data.TemplateFlags = templateFlags & TokenFlagsTemplateLiteralLikeFlags f.textCount++ return f.newNode(KindTemplateHead, data) } @@ -8746,7 +8751,7 @@ func (f *NodeFactory) NewTemplateMiddle(text string, rawText string, templateFla data := &TemplateMiddle{} data.Text = text data.RawText = rawText - data.TemplateFlags = templateFlags + data.TemplateFlags = templateFlags & TokenFlagsTemplateLiteralLikeFlags f.textCount++ return f.newNode(KindTemplateMiddle, data) } @@ -8770,7 +8775,7 @@ func (f *NodeFactory) NewTemplateTail(text string, rawText string, templateFlags data := &TemplateTail{} data.Text = text data.RawText = rawText - data.TemplateFlags = templateFlags + data.TemplateFlags = templateFlags & TokenFlagsTemplateLiteralLikeFlags f.textCount++ return f.newNode(KindTemplateTail, data) } @@ -10980,33 +10985,23 @@ func createToken(kind Kind, file *SourceFile, pos, end int, flags TokenFlags) *N text := file.text[pos:end] switch kind { case KindNumericLiteral: - literal := file.tokenFactory.NewNumericLiteral(text) - literal.AsNumericLiteral().TokenFlags = flags & TokenFlagsNumericLiteralFlags - return literal + return file.tokenFactory.NewNumericLiteral(text, flags) case KindBigIntLiteral: - literal := file.tokenFactory.NewBigIntLiteral(text) - literal.AsBigIntLiteral().TokenFlags = flags & TokenFlagsNumericLiteralFlags - return literal + return file.tokenFactory.NewBigIntLiteral(text, flags) case KindStringLiteral: - literal := file.tokenFactory.NewStringLiteral(text) - literal.AsStringLiteral().TokenFlags = flags & TokenFlagsStringLiteralFlags - return literal + return file.tokenFactory.NewStringLiteral(text, flags) case KindJsxText, KindJsxTextAllWhiteSpaces: return file.tokenFactory.NewJsxText(text, kind == KindJsxTextAllWhiteSpaces) case KindRegularExpressionLiteral: - literal := file.tokenFactory.NewRegularExpressionLiteral(text) - literal.AsRegularExpressionLiteral().TokenFlags = flags & TokenFlagsRegularExpressionLiteralFlags - return literal + return file.tokenFactory.NewRegularExpressionLiteral(text, flags) case KindNoSubstitutionTemplateLiteral: - literal := file.tokenFactory.NewNoSubstitutionTemplateLiteral(text) - literal.AsNoSubstitutionTemplateLiteral().TokenFlags = flags & TokenFlagsTemplateLiteralLikeFlags - return literal + return file.tokenFactory.NewNoSubstitutionTemplateLiteral(text, flags) case KindTemplateHead: - return file.tokenFactory.NewTemplateHead(text, "" /*rawText*/, flags&TokenFlagsTemplateLiteralLikeFlags) + return file.tokenFactory.NewTemplateHead(text, "" /*rawText*/, flags) case KindTemplateMiddle: - return file.tokenFactory.NewTemplateMiddle(text, "" /*rawText*/, flags&TokenFlagsTemplateLiteralLikeFlags) + return file.tokenFactory.NewTemplateMiddle(text, "" /*rawText*/, flags) case KindTemplateTail: - return file.tokenFactory.NewTemplateTail(text, "" /*rawText*/, flags&TokenFlagsTemplateLiteralLikeFlags) + return file.tokenFactory.NewTemplateTail(text, "" /*rawText*/, flags) case KindIdentifier: return file.tokenFactory.NewIdentifier(text) case KindPrivateIdentifier: diff --git a/pkg/checker/checker.go b/pkg/checker/checker.go index a123bd6ae..930fd57d5 100644 --- a/pkg/checker/checker.go +++ b/pkg/checker/checker.go @@ -9638,6 +9638,17 @@ func (c *Checker) getArgumentArityError(node *ast.Node, signatures []*Signature, } return diagnostic default: + // Guard against out-of-bounds access when maxCount >= len(args). + // This can happen when we reach this fallback error path but the argument + // count actually matches the parameter count (e.g., due to trailing commas + // causing signature resolution to fail for other reasons). + if maxCount >= len(args) { + diagnostic := NewDiagnosticForNode(errorNode, message, parameterRange, len(args)) + if headMessage != nil { + diagnostic = ast.NewDiagnosticChain(diagnostic, headMessage) + } + return diagnostic + } sourceFile := ast.GetSourceFileOfNode(node) pos := scanner.SkipTrivia(sourceFile.Text(), args[maxCount].Pos()) end := args[len(args)-1].End() @@ -17352,7 +17363,7 @@ func (c *Checker) getSyntheticElementAccess(node *ast.Node) *ast.Node { parentAccess := c.getParentElementAccess(node) if parentAccess != nil && getFlowNodeOfNode(parentAccess) != nil { if propName, ok := c.getDestructuringPropertyName(node); ok { - literal := c.factory.NewStringLiteral(propName) + literal := c.factory.NewStringLiteral(propName, ast.TokenFlagsNone) literal.Loc = node.Loc lhsExpr := parentAccess if !ast.IsLeftHandSideExpression(parentAccess) { diff --git a/pkg/checker/emitresolver.go b/pkg/checker/emitresolver.go index 07a06739e..1eebff79b 100644 --- a/pkg/checker/emitresolver.go +++ b/pkg/checker/emitresolver.go @@ -972,18 +972,18 @@ func (r *EmitResolver) CreateLiteralConstValue(emitContext *printer.EmitContext, } switch value := t.AsLiteralType().value.(type) { case string: - return emitContext.Factory.NewStringLiteral(value) + return emitContext.Factory.NewStringLiteral(value, ast.TokenFlagsNone) case jsnum.Number: if value.Abs() != value { // negative return emitContext.Factory.NewPrefixUnaryExpression( ast.KindMinusToken, - emitContext.Factory.NewNumericLiteral(value.String()[1:]), + emitContext.Factory.NewNumericLiteral(value.String()[1:], ast.TokenFlagsNone), ) } - return emitContext.Factory.NewNumericLiteral(value.String()) + return emitContext.Factory.NewNumericLiteral(value.String(), ast.TokenFlagsNone) case jsnum.PseudoBigInt: - return emitContext.Factory.NewBigIntLiteral(pseudoBigIntToString(value) + "n") + return emitContext.Factory.NewBigIntLiteral(pseudoBigIntToString(value)+"n", ast.TokenFlagsNone) case bool: kind := ast.KindFalseKeyword if value { diff --git a/pkg/checker/nodebuilderimpl.go b/pkg/checker/nodebuilderimpl.go index 2f6df3fc6..e6bd03f56 100644 --- a/pkg/checker/nodebuilderimpl.go +++ b/pkg/checker/nodebuilderimpl.go @@ -757,11 +757,11 @@ func (b *NodeBuilderImpl) createExpressionFromSymbolChain(chain []*ast.Symbol, i var expression *ast.Expression if startsWithSingleOrDoubleQuote(symbolName) && symbol.Flags&ast.SymbolFlagsEnumMember == 0 { - expression = b.newStringLiteral(stringutil.UnquoteString(symbolName)) + expression = b.newStringLiteralEx(stringutil.UnquoteString(symbolName), symbolName[0] == '\'') } else if jsnum.FromString(symbolName).String() == symbolName { // TODO: the follwing in strada would assert if the number is negative, but no such assertion exists here // Moreover, what's even guaranteeing the name *isn't* -1 here anyway? Needs double-checking. - expression = b.f.NewNumericLiteral(symbolName) + expression = b.f.NewNumericLiteral(symbolName, ast.TokenFlagsNone) } if expression == nil { expression = b.f.NewIdentifier(symbolName) @@ -2088,12 +2088,9 @@ func (b *NodeBuilderImpl) createPropertyNameNodeForIdentifierOrLiteral(name stri return b.f.NewIdentifier(name) } if !stringNamed && !isMethodNamedNew && isNumericLiteralName(name) && jsnum.FromString(name) >= 0 { - return b.f.NewNumericLiteral(name) - } - result := b.f.NewStringLiteral(name) - if singleQuote { - result.AsStringLiteral().TokenFlags |= ast.TokenFlagsSingleQuote + return b.f.NewNumericLiteral(name, ast.TokenFlagsNone) } + result := b.f.NewStringLiteral(name, core.IfElse(singleQuote, ast.TokenFlagsSingleQuote, ast.TokenFlagsNone)) return result } @@ -2157,14 +2154,11 @@ func (b *NodeBuilderImpl) getPropertyNameNodeForSymbolFromNameType(symbol *ast.S name = nameType.AsLiteralType().value.(string) } if !scanner.IsIdentifierText(name, core.LanguageVariantStandard) && (stringNamed || !isNumericLiteralName(name)) { - node := b.f.NewStringLiteral(name) - if singleQuote { - node.AsStringLiteral().TokenFlags |= ast.TokenFlagsSingleQuote - } + node := b.f.NewStringLiteral(name, core.IfElse(singleQuote, ast.TokenFlagsSingleQuote, ast.TokenFlagsNone)) return node } if isNumericLiteralName(name) && name[0] == '-' { - return b.f.NewComputedPropertyName(b.f.NewPrefixUnaryExpression(ast.KindMinusToken, b.f.NewNumericLiteral(name[1:]))) + return b.f.NewComputedPropertyName(b.f.NewPrefixUnaryExpression(ast.KindMinusToken, b.f.NewNumericLiteral(name[1:], ast.TokenFlagsNone))) } return b.createPropertyNameNodeForIdentifierOrLiteral(name, singleQuote, stringNamed, isMethod) } @@ -2896,14 +2890,14 @@ func (b *NodeBuilderImpl) typeToTypeNode(t *Type) *ast.TypeNode { value := t.AsLiteralType().value.(jsnum.Number) b.ctx.approximateLength += len(value.String()) if value < 0 { - return b.f.NewLiteralTypeNode(b.f.NewPrefixUnaryExpression(ast.KindMinusToken, b.f.NewNumericLiteral(value.String()[1:]))) + return b.f.NewLiteralTypeNode(b.f.NewPrefixUnaryExpression(ast.KindMinusToken, b.f.NewNumericLiteral(value.String()[1:], ast.TokenFlagsNone))) } else { - return b.f.NewLiteralTypeNode(b.f.NewNumericLiteral(value.String())) + return b.f.NewLiteralTypeNode(b.f.NewNumericLiteral(value.String(), ast.TokenFlagsNone)) } } if t.flags&TypeFlagsBigIntLiteral != 0 { b.ctx.approximateLength += len(pseudoBigIntToString(getBigIntLiteralValue(t))) + 1 - return b.f.NewLiteralTypeNode(b.f.NewBigIntLiteral(pseudoBigIntToString(getBigIntLiteralValue(t)) + "n")) + return b.f.NewLiteralTypeNode(b.f.NewBigIntLiteral(pseudoBigIntToString(getBigIntLiteralValue(t))+"n", ast.TokenFlagsNone)) } if t.flags&TypeFlagsBooleanLiteral != 0 { if t.AsLiteralType().value.(bool) { @@ -3102,10 +3096,15 @@ func (b *NodeBuilderImpl) typeToTypeNode(t *Type) *ast.TypeNode { } func (b *NodeBuilderImpl) newStringLiteral(text string) *ast.Node { - node := b.f.NewStringLiteral(text) - if b.ctx.flags&nodebuilder.FlagsUseSingleQuotesForStringLiteralType != 0 { - node.AsStringLiteral().TokenFlags |= ast.TokenFlagsSingleQuote + return b.newStringLiteralEx(text, false /*isSingleQuote*/) +} + +func (b *NodeBuilderImpl) newStringLiteralEx(text string, isSingleQuote bool) *ast.Node { + flags := ast.TokenFlagsNone + if isSingleQuote || b.ctx.flags&nodebuilder.FlagsUseSingleQuotesForStringLiteralType != 0 { + flags |= ast.TokenFlagsSingleQuote } + node := b.f.NewStringLiteral(text, flags) return node } diff --git a/pkg/compiler/fileloader.go b/pkg/compiler/fileloader.go index 1ad3881b8..40337894d 100644 --- a/pkg/compiler/fileloader.go +++ b/pkg/compiler/fileloader.go @@ -477,7 +477,7 @@ func (p *fileLoader) resolveImportsAndModuleAugmentations(t *parseTask) { func (p *fileLoader) createSyntheticImport(text string, file *ast.SourceFile) *ast.Node { p.factoryMu.Lock() defer p.factoryMu.Unlock() - externalHelpersModuleReference := p.factory.NewStringLiteral(text) + externalHelpersModuleReference := p.factory.NewStringLiteral(text, ast.TokenFlagsNone) importDecl := p.factory.NewImportDeclaration(nil, nil, externalHelpersModuleReference, nil) // !!! addInternalEmitFlags(importDecl, InternalEmitFlags.NeverApplyImportHelper); externalHelpersModuleReference.Parent = importDecl diff --git a/pkg/fourslash/_scripts/convertFourslash.mts b/pkg/fourslash/_scripts/convertFourslash.mts index fad691735..8d5aaaede 100644 --- a/pkg/fourslash/_scripts/convertFourslash.mts +++ b/pkg/fourslash/_scripts/convertFourslash.mts @@ -249,6 +249,22 @@ function parseFourslashStatement(statement: ts.Statement): Cmd[] | undefined { return parseVerifyNavTree(callExpression.arguments); case "navigationBar": return []; // Deprecated. + case "numberOfErrorsInCurrentFile": + return parseNumberOfErrorsInCurrentFile(callExpression.arguments); + case "noErrors": + return [{ kind: "verifyNoErrors" }]; + case "errorExistsAtRange": + return parseErrorExistsAtRange(callExpression.arguments); + case "currentLineContentIs": + return parseCurrentLineContentIs(callExpression.arguments); + case "currentFileContentIs": + return parseCurrentFileContentIs(callExpression.arguments); + case "errorExistsBetweenMarkers": + return parseErrorExistsBetweenMarkers(callExpression.arguments); + case "errorExistsAfterMarker": + return parseErrorExistsAfterMarker(callExpression.arguments); + case "errorExistsBeforeMarker": + return parseErrorExistsBeforeMarker(callExpression.arguments); } } // `goTo....` @@ -313,6 +329,32 @@ function parseEditStatement(funcName: string, args: readonly ts.Expression[]): E goStatement: `f.Backspace(t, 1)`, }; } + case "deleteAtCaret": { + const arg = args[0]; + if (arg) { + let arg0; + if (arg0 = getNumericLiteral(arg)) { + return { + kind: "edit", + goStatement: `f.DeleteAtCaret(t, ${arg0.text})`, + }; + } + // Handle 'string'.length expressions + const lengthValue = getStringLengthExpression(arg); + if (lengthValue !== undefined) { + return { + kind: "edit", + goStatement: `f.DeleteAtCaret(t, ${lengthValue})`, + }; + } + console.error(`Expected numeric literal argument in edit.deleteAtCaret, got ${arg.getText()}`); + return undefined; + } + return { + kind: "edit", + goStatement: `f.DeleteAtCaret(t, 1)`, + }; + } default: console.error(`Unrecognized edit function: ${funcName}`); return undefined; @@ -1446,6 +1488,130 @@ function parseExpectedDiagnostic(expr: ts.Expression): string | undefined { return `&lsproto.Diagnostic{\n${diagnosticProps.join("\n")}\n}`; } +function parseNumberOfErrorsInCurrentFile(args: readonly ts.Expression[]): [VerifyNumberOfErrorsInCurrentFileCmd] | undefined { + let arg0; + if (args.length !== 1 || !(arg0 = getNumericLiteral(args[0]))) { + console.error(`Expected a single numeric literal argument in verify.numberOfErrorsInCurrentFile, got ${args.map(arg => arg.getText()).join(", ")}`); + return undefined; + } + return [{ + kind: "verifyNumberOfErrorsInCurrentFile", + expectedCount: parseInt(arg0.text, 10), + }]; +} + +function parseErrorExistsAtRange(args: readonly ts.Expression[]): [VerifyErrorExistsAtRangeCmd] | undefined { + if (args.length < 2 || args.length > 3) { + console.error(`Expected 2 or 3 arguments in verify.errorExistsAtRange, got ${args.length}`); + return undefined; + } + + // First arg is a range + const rangeArg = parseBaselineMarkerOrRangeArg(args[0]); + if (!rangeArg) { + console.error(`Expected range argument in verify.errorExistsAtRange, got ${args[0].getText()}`); + return undefined; + } + + // Second arg is error code + let codeArg; + if (!(codeArg = getNumericLiteral(args[1]))) { + console.error(`Expected numeric literal for code in verify.errorExistsAtRange, got ${args[1].getText()}`); + return undefined; + } + + // Third arg is optional message + let message = ""; + if (args[2]) { + const messageArg = getStringLiteralLike(args[2]); + if (!messageArg) { + console.error(`Expected string literal for message in verify.errorExistsAtRange, got ${args[2].getText()}`); + return undefined; + } + message = messageArg.text; + } + + return [{ + kind: "verifyErrorExistsAtRange", + range: rangeArg, + code: parseInt(codeArg.text, 10), + message: message, + }]; +} + +function parseCurrentLineContentIs(args: readonly ts.Expression[]): [VerifyCurrentLineContentIsCmd] | undefined { + let arg0; + if (args.length !== 1 || !(arg0 = getStringLiteralLike(args[0]))) { + console.error(`Expected a single string literal argument in verify.currentLineContentIs, got ${args.map(arg => arg.getText()).join(", ")}`); + return undefined; + } + return [{ + kind: "verifyCurrentLineContentIs", + text: arg0.text, + }]; +} + +function parseCurrentFileContentIs(args: readonly ts.Expression[]): [VerifyCurrentFileContentIsCmd] | undefined { + let arg0; + if (args.length !== 1 || !(arg0 = getStringLiteralLike(args[0]))) { + console.error(`Expected a single string literal argument in verify.currentFileContentIs, got ${args.map(arg => arg.getText()).join(", ")}`); + return undefined; + } + return [{ + kind: "verifyCurrentFileContentIs", + text: arg0.text, + }]; +} + +function parseErrorExistsBetweenMarkers(args: readonly ts.Expression[]): [VerifyErrorExistsBetweenMarkersCmd] | undefined { + if (args.length !== 2) { + console.error(`Expected 2 arguments in verify.errorExistsBetweenMarkers, got ${args.length}`); + return undefined; + } + let startMarker, endMarker; + if (!(startMarker = getStringLiteralLike(args[0])) || !(endMarker = getStringLiteralLike(args[1]))) { + console.error(`Expected string literal arguments in verify.errorExistsBetweenMarkers, got ${args.map(arg => arg.getText()).join(", ")}`); + return undefined; + } + return [{ + kind: "verifyErrorExistsBetweenMarkers", + startMarker: startMarker.text, + endMarker: endMarker.text, + }]; +} + +function parseErrorExistsAfterMarker(args: readonly ts.Expression[]): [VerifyErrorExistsAfterMarkerCmd] | undefined { + let markerName = ""; + if (args.length > 0) { + const arg0 = getStringLiteralLike(args[0]); + if (!arg0) { + console.error(`Expected string literal argument in verify.errorExistsAfterMarker, got ${args[0].getText()}`); + return undefined; + } + markerName = arg0.text; + } + return [{ + kind: "verifyErrorExistsAfterMarker", + markerName: markerName, + }]; +} + +function parseErrorExistsBeforeMarker(args: readonly ts.Expression[]): [VerifyErrorExistsBeforeMarkerCmd] | undefined { + let markerName = ""; + if (args.length > 0) { + const arg0 = getStringLiteralLike(args[0]); + if (!arg0) { + console.error(`Expected string literal argument in verify.errorExistsBeforeMarker, got ${args[0].getText()}`); + return undefined; + } + markerName = arg0.text; + } + return [{ + kind: "verifyErrorExistsBeforeMarker", + markerName: markerName, + }]; +} + function stringToTristate(s: string): string { switch (s) { case "true": @@ -2689,6 +2855,48 @@ interface VerifyNavTreeCmd { kind: "verifyNavigationTree"; } +interface VerifyNumberOfErrorsInCurrentFileCmd { + kind: "verifyNumberOfErrorsInCurrentFile"; + expectedCount: number; +} + +interface VerifyNoErrorsCmd { + kind: "verifyNoErrors"; +} + +interface VerifyErrorExistsAtRangeCmd { + kind: "verifyErrorExistsAtRange"; + range: string; + code: number; + message: string; +} + +interface VerifyCurrentLineContentIsCmd { + kind: "verifyCurrentLineContentIs"; + text: string; +} + +interface VerifyCurrentFileContentIsCmd { + kind: "verifyCurrentFileContentIs"; + text: string; +} + +interface VerifyErrorExistsBetweenMarkersCmd { + kind: "verifyErrorExistsBetweenMarkers"; + startMarker: string; + endMarker: string; +} + +interface VerifyErrorExistsAfterMarkerCmd { + kind: "verifyErrorExistsAfterMarker"; + markerName: string; +} + +interface VerifyErrorExistsBeforeMarkerCmd { + kind: "verifyErrorExistsBeforeMarker"; + markerName: string; +} + type Cmd = | VerifyCompletionsCmd | VerifyApplyCodeActionFromCompletionCmd @@ -2715,7 +2923,15 @@ type Cmd = | VerifyImportFixModuleSpecifiersCmd | VerifyDiagnosticsCmd | VerifyBaselineDiagnosticsCmd - | VerifyOutliningSpansCmd; + | VerifyOutliningSpansCmd + | VerifyNumberOfErrorsInCurrentFileCmd + | VerifyNoErrorsCmd + | VerifyErrorExistsAtRangeCmd + | VerifyCurrentLineContentIsCmd + | VerifyCurrentFileContentIsCmd + | VerifyErrorExistsBetweenMarkersCmd + | VerifyErrorExistsAfterMarkerCmd + | VerifyErrorExistsBeforeMarkerCmd; function generateVerifyOutliningSpans({ foldingRangeKind }: VerifyOutliningSpansCmd): string { if (foldingRangeKind) { @@ -3029,6 +3245,22 @@ function generateCmd(cmd: Cmd): string { return generateVerifyOutliningSpans(cmd); case "verifyNavigationTree": return `f.VerifyBaselineDocumentSymbol(t)`; + case "verifyNumberOfErrorsInCurrentFile": + return `f.VerifyNumberOfErrorsInCurrentFile(t, ${cmd.expectedCount})`; + case "verifyNoErrors": + return `f.VerifyNoErrors(t)`; + case "verifyErrorExistsAtRange": + return `f.VerifyErrorExistsAtRange(t, ${cmd.range}, ${cmd.code}, ${getGoStringLiteral(cmd.message)})`; + case "verifyCurrentLineContentIs": + return `f.VerifyCurrentLineContentIs(t, ${getGoStringLiteral(cmd.text)})`; + case "verifyCurrentFileContentIs": + return `f.VerifyCurrentFileContentIs(t, ${getGoStringLiteral(cmd.text)})`; + case "verifyErrorExistsBetweenMarkers": + return `f.VerifyErrorExistsBetweenMarkers(t, ${getGoStringLiteral(cmd.startMarker)}, ${getGoStringLiteral(cmd.endMarker)})`; + case "verifyErrorExistsAfterMarker": + return `f.VerifyErrorExistsAfterMarker(t, ${getGoStringLiteral(cmd.markerName)})`; + case "verifyErrorExistsBeforeMarker": + return `f.VerifyErrorExistsBeforeMarker(t, ${getGoStringLiteral(cmd.markerName)})`; default: let neverCommand: never = cmd; throw new Error(`Unknown command kind: ${neverCommand as Cmd["kind"]}`); @@ -3047,16 +3279,17 @@ function generateGoTest(failingTests: Set, test: GoTest, isServer: boole const commands = test.commands.map(cmd => generateCmd(cmd)).join("\n"); const imports = [`"github.com/microsoft/typescript-go/internal/fourslash"`]; // Only include these imports if the commands use them to avoid unused import errors. - if (commands.includes("core.")) { + // Use regex with word boundary to avoid false positives like "underscore." matching "core." + if (/\bcore\./.test(commands)) { imports.unshift(`"github.com/microsoft/typescript-go/internal/core"`); } - if (commands.includes("ls.")) { + if (/\bls\./.test(commands)) { imports.push(`"github.com/microsoft/typescript-go/internal/ls"`); } - if (commands.includes("lsutil.")) { + if (/\blsutil\./.test(commands)) { imports.push(`"github.com/microsoft/typescript-go/internal/ls/lsutil"`); } - if (commands.includes("lsproto.")) { + if (/\blsproto\./.test(commands)) { imports.push(`"github.com/microsoft/typescript-go/internal/lsp/lsproto"`); } if (usesFourslashUtil(commands)) { @@ -3129,6 +3362,17 @@ function getArrayLiteralExpression(node: ts.Node): ts.ArrayLiteralExpression | u return getNodeOfKind(node, ts.isArrayLiteralExpression); } +// Parses expressions like 'string'.length or "string".length and returns the length value +function getStringLengthExpression(node: ts.Node): number | undefined { + if (ts.isPropertyAccessExpression(node) && node.name.text === "length") { + const stringLiteral = getStringLiteralLike(node.expression); + if (stringLiteral) { + return stringLiteral.text.length; + } + } + return undefined; +} + function getInitializer(name: ts.Identifier): ts.Expression | undefined { const file = name.getSourceFile(); const varStmts = file.statements.filter(ts.isVariableStatement); diff --git a/pkg/fourslash/_scripts/failingTests.txt b/pkg/fourslash/_scripts/failingTests.txt index 297cda053..be2009467 100644 --- a/pkg/fourslash/_scripts/failingTests.txt +++ b/pkg/fourslash/_scripts/failingTests.txt @@ -1,8 +1,10 @@ TestAliasMergingWithNamespace +TestAllowLateBoundSymbolsOverwriteEarlyBoundSymbols TestAmbientShorthandGotoDefinition TestArgumentsAreAvailableAfterEditsAtEndOfFunction TestAugmentedTypesClass1 TestAugmentedTypesClass3Fourslash +TestAutoFormattingOnPasting TestAutoImportAllowImportingTsExtensionsPackageJsonImports1 TestAutoImportCompletionAmbientMergedModule1 TestAutoImportCompletionExportListAugmentation1 @@ -47,6 +49,7 @@ TestAutoImportVerbatimTypeOnly1 TestBestCommonTypeObjectLiterals TestBestCommonTypeObjectLiterals1 TestCalledUnionsOfDissimilarTyeshaveGoodDisplay +TestCloduleTypeOf1 TestCodeCompletionEscaping TestCommentsEnumsFourslash TestCommentsExternalModulesFourslash @@ -59,6 +62,7 @@ TestCommentsUnion TestCommentsVariables TestCompletionAfterQuestionDot TestCompletionAutoInsertQuestionDot +TestCompletionBeforeSemanticDiagnosticsInArrowFunction1 TestCompletionCloneQuestionToken TestCompletionEntryClassMembersWithInferredFunctionReturnType1 TestCompletionEntryForArgumentConstrainedToString @@ -237,17 +241,49 @@ TestCompletionsWithDeprecatedTag10 TestCompletionWithConditionalOperatorMissingColon TestConstEnumQuickInfoAndCompletionList TestConstQuickInfoAndCompletionList +TestConstructorBraceFormatting TestContextuallyTypedFunctionExpressionGeneric1 +TestContextualTypingOfGenericCallSignatures2 TestCrossFileQuickInfoExportedTypeDoesNotUseImportType TestDoubleUnderscoreCompletions +TestDuplicatePackageServices TestEditJsdocType +TestErrorsAfterResolvingVariableDeclOfMergedVariableAndClassDecl TestExportDefaultClass TestExportDefaultFunction +TestExportEqualTypes +TestFindAllRefs_importType_js1 +TestFindAllRefs_importType_js2 +TestFindAllRefs_importType_js3 TestFindReferencesBindingPatternInJsdocNoCrash1 TestFindReferencesBindingPatternInJsdocNoCrash2 +TestFormatAfterWhitespace +TestFormatAnyTypeLiteral +TestFormatEmptyBlock +TestFormatEmptyParamList +TestFormatonkey01 +TestFormatOnSemiColonAfterBreak +TestFormattingAfterMultiLineIfCondition +TestFormattingBlockInCaseClauses +TestFormattingEqualsBeforeBracketInTypeAlias +TestFormattingIfInElseBlock +TestFormattingInExpressionsInTsx +TestFormattingOfChainedLambda +TestFormattingOnCloseBrace +TestFormattingOnDoWhileNoSemicolon +TestFormattingOnEnter +TestFormattingOnNestedDoWhileByEnter +TestFormattingOnSemiColon +TestFormattingSpaceAfterCommaBeforeOpenParen +TestFormattingTemplates +TestFormattingWithMultilineComments +TestFunctionTypeFormatting +TestFunduleWithRecursiveReference TestGenericCombinators3 TestGenericCombinatorWithConstraints1 TestGenericFunctionWithGenericParams1 +TestGenericInterfacePropertyInference1 +TestGenericInterfacePropertyInference2 TestGenericInterfacesWithConstraints1 TestGenericTypeWithMultipleBases1MultiFile TestGetJavaScriptCompletions10 @@ -288,6 +324,7 @@ TestImportCompletionsPackageJsonImportsPattern_ts TestImportCompletionsPackageJsonImportsPattern_ts_ts TestImportCompletionsPackageJsonImportsPattern2 TestImportFixesGlobalTypingsCache +TestImportMetaCompletionDetails TestImportNameCodeFix_avoidRelativeNodeModules TestImportNameCodeFix_fileWithNoTrailingNewline TestImportNameCodeFix_HeaderComment1 @@ -336,6 +373,7 @@ TestIndexerReturnTypes1 TestIndirectClassInstantiation TestInstanceTypesForGenericType1 TestJavascriptModules20 +TestJavascriptModules24 TestJsDocAugments TestJsDocAugmentsAndExtends TestJsdocCallbackTag @@ -379,7 +417,9 @@ TestMemberListInReopenedEnum TestMemberListInWithBlock TestMemberListOfExportedClass TestMemberListOnContextualThis +TestMultiModuleFundule TestNgProxy1 +TestNgProxy4 TestNodeModulesImportCompletions1 TestNoQuickInfoForLabel TestNoQuickInfoInWhitespace @@ -387,6 +427,7 @@ TestNumericPropertyNames TestOverloadQuickInfo TestParameterWithDestructuring TestParameterWithNestedDestructuring +TestPaste TestPathCompletionsAllowModuleAugmentationExtensions TestPathCompletionsAllowTsExtensions TestPathCompletionsPackageJsonExportsBundlerNoNodeCondition @@ -444,6 +485,7 @@ TestQuickInfoAssertionNodeNotReusedWhenTypeNotEquivalent1 TestQuickInfoBindingPatternInJsdocNoCrash1 TestQuickInfoCanBeTruncated TestQuickInfoClassKeyword +TestQuickInfoCloduleWithRecursiveReference TestQuickInfoContextuallyTypedSignatureOptionalParameterFromIntersection1 TestQuickInfoContextualTyping TestQuickInfoDisplayPartsIife @@ -475,6 +517,7 @@ TestQuickInfoInJsdocInTsFile1 TestQuickInfoInOptionalChain TestQuickInfoInWithBlock TestQuickInfoJSDocBackticks +TestQuickInfoJsdocEnum TestQuickInfoJSDocFunctionNew TestQuickInfoJSDocFunctionThis TestQuickInfoJsDocGetterSetterNoCrash1 @@ -484,6 +527,7 @@ TestQuickInfoJSExport TestQuickInfoMappedSpreadTypes TestQuickInfoMappedType TestQuickInfoMappedTypeRecursiveInference +TestQuickInfoMeaning TestQuickInfoModuleVariables TestQuickInfoNarrowedTypeOfAliasSymbol TestQuickInfoNestedGenericCalls @@ -504,6 +548,8 @@ TestQuickInfoOnFunctionPropertyReturnedFromGenericFunction3 TestQuickInfoOnGenericWithConstraints1 TestQuickInfoOnInternalAliases TestQuickInfoOnJsxNamespacedNameWithDoc1 +TestQuickInfoOnMergedInterfacesWithIncrementalEdits +TestQuickInfoOnMergedModule TestQuickInfoOnMethodOfImportEquals TestQuickInfoOnNarrowedTypeInModule TestQuickInfoOnNewKeyword01 @@ -538,6 +584,7 @@ TestQuickInfoTypeError TestQuickInfoTypeOfThisInStatics TestQuickInfoTypeOnlyNamespaceAndClass TestQuickInfoUnionOfNamespaces +TestQuickInfoUntypedModuleImport TestQuickInfoWidenedTypes TestQuickinfoWrongComment TestRecursiveInternalModuleImport @@ -550,11 +597,17 @@ TestRenameFromNodeModulesDep4 TestRenamePrivateFields TestReverseMappedTypeQuickInfo TestSelfReferencedExternalModule +TestSemicolonFormatting +TestSemicolonFormattingAfterArrayLiteral +TestSemicolonFormattingNestedStatements +TestSignatureHelpCallExpressionJs +TestSpaceAfterConstructor TestStringCompletionsImportOrExportSpecifier TestStringCompletionsVsEscaping TestSymbolCompletionLowerPriority TestSyntheticImportFromBabelGeneratedFile1 TestSyntheticImportFromBabelGeneratedFile2 +TestTabbingAfterNewlineInsertedBeforeWhile TestThisBindingInLambda TestThisPredicateFunctionQuickInfo01 TestThisPredicateFunctionQuickInfo02 @@ -570,4 +623,10 @@ TestTsxQuickInfo4 TestTsxQuickInfo5 TestTsxQuickInfo6 TestTsxQuickInfo7 +TestTypeCheckAfterResolve TestTypeOperatorNodeBuilding +TestUnclosedStringLiteralAutoformating +TestWhiteSpaceBeforeReturnTypeFormatting +TestWhiteSpaceTrimming +TestWhiteSpaceTrimming2 +TestWhiteSpaceTrimming4 diff --git a/pkg/fourslash/fourslash.go b/pkg/fourslash/fourslash.go index 5ece33160..576280ec3 100644 --- a/pkg/fourslash/fourslash.go +++ b/pkg/fourslash/fourslash.go @@ -2548,6 +2548,17 @@ func (f *FourslashTest) Backspace(t *testing.T, count int) { // f.checkPostEditInvariants() // !!! do we need this? } +// DeleteAtCaret removes the text at the current caret position as if the user pressed delete `count` times. +func (f *FourslashTest) DeleteAtCaret(t *testing.T, count int) { + script := f.getScriptInfo(f.activeFilename) + offset := int(f.converters.LineAndCharacterToPosition(script, f.currentCaretPosition)) + + for range count { + f.editScriptAndUpdateMarkers(t, f.activeFilename, offset, offset+1, "") + // Position stays the same after delete (unlike backspace) + } +} + // Enters text as if the user had pasted it. func (f *FourslashTest) Paste(t *testing.T, text string) { script := f.getScriptInfo(f.activeFilename) @@ -3848,3 +3859,170 @@ func collectDocumentSymbolSpans( } } } + +// VerifyNumberOfErrorsInCurrentFile verifies that the current file has the expected number of errors. +func (f *FourslashTest) VerifyNumberOfErrorsInCurrentFile(t *testing.T, expectedCount int) { + diagnostics := f.getDiagnostics(t, f.activeFilename) + // Filter to only include errors (not suggestions/hints) + errors := core.Filter(diagnostics, func(d *lsproto.Diagnostic) bool { + return !isSuggestionDiagnostic(d) + }) + if len(errors) != expectedCount { + t.Fatalf("Expected %d errors in current file, but got %d", expectedCount, len(errors)) + } +} + +// VerifyNoErrors verifies that no errors exist in any open files. +func (f *FourslashTest) VerifyNoErrors(t *testing.T) { + for fileName := range f.openFiles { + diagnostics := f.getDiagnostics(t, fileName) + // Filter to only include errors (not suggestions/hints) + errors := core.Filter(diagnostics, func(d *lsproto.Diagnostic) bool { + return !isSuggestionDiagnostic(d) + }) + if len(errors) > 0 { + var messages []string + for _, err := range errors { + messages = append(messages, err.Message) + } + t.Fatalf("Expected no errors but found %d in %s: %v", len(errors), fileName, messages) + } + } +} + +// VerifyErrorExistsAtRange verifies that an error with the given code exists at the given range. +func (f *FourslashTest) VerifyErrorExistsAtRange(t *testing.T, rangeMarker *RangeMarker, code int, message string) { + diagnostics := f.getDiagnostics(t, rangeMarker.FileName()) + for _, diag := range diagnostics { + if diag.Code != nil && diag.Code.Integer != nil && int(*diag.Code.Integer) == code { + // Check if the range matches + if diag.Range.Start.Line == rangeMarker.LSRange.Start.Line && + diag.Range.Start.Character == rangeMarker.LSRange.Start.Character && + diag.Range.End.Line == rangeMarker.LSRange.End.Line && + diag.Range.End.Character == rangeMarker.LSRange.End.Character { + // If message is provided, verify it matches + if message != "" && diag.Message != message { + t.Fatalf("Error at range has code %d but message mismatch. Expected: %q, Got: %q", code, message, diag.Message) + } + return + } + } + } + t.Fatalf("Expected error with code %d at range %v but it was not found", code, rangeMarker.LSRange) +} + +// VerifyCurrentLineContentIs verifies that the current line content matches the expected text. +func (f *FourslashTest) VerifyCurrentLineContentIs(t *testing.T, expectedText string) { + script := f.getScriptInfo(f.activeFilename) + lines := strings.Split(script.content, "\n") + lineNum := int(f.currentCaretPosition.Line) + if lineNum >= len(lines) { + t.Fatalf("Current line %d is out of range (file has %d lines)", lineNum, len(lines)) + } + actualLine := lines[lineNum] + // Handle \r if present + actualLine = strings.TrimSuffix(actualLine, "\r") + if actualLine != expectedText { + t.Fatalf("Current line content mismatch.\nExpected: %q\nActual: %q", expectedText, actualLine) + } +} + +// VerifyCurrentFileContentIs verifies that the current file content matches the expected text. +func (f *FourslashTest) VerifyCurrentFileContentIs(t *testing.T, expectedText string) { + script := f.getScriptInfo(f.activeFilename) + if script.content != expectedText { + t.Fatalf("Current file content mismatch.\nExpected: %q\nActual: %q", expectedText, script.content) + } +} + +// VerifyErrorExistsBetweenMarkers verifies that an error exists between the two markers. +func (f *FourslashTest) VerifyErrorExistsBetweenMarkers(t *testing.T, startMarkerName string, endMarkerName string) { + startMarker, ok := f.testData.MarkerPositions[startMarkerName] + if !ok { + t.Fatalf("Start marker '%s' not found", startMarkerName) + } + endMarker, ok := f.testData.MarkerPositions[endMarkerName] + if !ok { + t.Fatalf("End marker '%s' not found", endMarkerName) + } + if startMarker.FileName() != endMarker.FileName() { + t.Fatalf("Markers '%s' and '%s' are in different files", startMarkerName, endMarkerName) + } + + diagnostics := f.getDiagnostics(t, startMarker.FileName()) + startPos := startMarker.Position + endPos := endMarker.Position + + for _, diag := range diagnostics { + if !isSuggestionDiagnostic(diag) { + diagStart := int(f.converters.LineAndCharacterToPosition(f.getScriptInfo(startMarker.FileName()), diag.Range.Start)) + diagEnd := int(f.converters.LineAndCharacterToPosition(f.getScriptInfo(startMarker.FileName()), diag.Range.End)) + if diagStart >= startPos && diagEnd <= endPos { + return // Found an error in the range + } + } + } + t.Fatalf("Expected error between markers '%s' and '%s' but none was found", startMarkerName, endMarkerName) +} + +// VerifyErrorExistsAfterMarker verifies that an error exists after the given marker. +func (f *FourslashTest) VerifyErrorExistsAfterMarker(t *testing.T, markerName string) { + var fileName string + var markerPos int + + if markerName == "" { + // Use current position + fileName = f.activeFilename + markerPos = int(f.converters.LineAndCharacterToPosition(f.getScriptInfo(f.activeFilename), f.currentCaretPosition)) + } else { + marker, ok := f.testData.MarkerPositions[markerName] + if !ok { + t.Fatalf("Marker '%s' not found", markerName) + } + fileName = marker.FileName() + markerPos = marker.Position + } + + diagnostics := f.getDiagnostics(t, fileName) + + for _, diag := range diagnostics { + if !isSuggestionDiagnostic(diag) { + diagStart := int(f.converters.LineAndCharacterToPosition(f.getScriptInfo(fileName), diag.Range.Start)) + if diagStart >= markerPos { + return // Found an error after the marker + } + } + } + t.Fatalf("Expected error after marker '%s' but none was found", markerName) +} + +// VerifyErrorExistsBeforeMarker verifies that an error exists before the given marker. +func (f *FourslashTest) VerifyErrorExistsBeforeMarker(t *testing.T, markerName string) { + var fileName string + var markerPos int + + if markerName == "" { + // Use current position + fileName = f.activeFilename + markerPos = int(f.converters.LineAndCharacterToPosition(f.getScriptInfo(f.activeFilename), f.currentCaretPosition)) + } else { + marker, ok := f.testData.MarkerPositions[markerName] + if !ok { + t.Fatalf("Marker '%s' not found", markerName) + } + fileName = marker.FileName() + markerPos = marker.Position + } + + diagnostics := f.getDiagnostics(t, fileName) + + for _, diag := range diagnostics { + if !isSuggestionDiagnostic(diag) { + diagEnd := int(f.converters.LineAndCharacterToPosition(f.getScriptInfo(fileName), diag.Range.End)) + if diagEnd <= markerPos { + return // Found an error before the marker + } + } + } + t.Fatalf("Expected error before marker '%s' but none was found", markerName) +} diff --git a/pkg/fourslash/tests/completionsInJsxTagDifferentSpreadElementTypes_test.go b/pkg/fourslash/tests/completionsInJsxTagDifferentSpreadElementTypes_test.go new file mode 100644 index 000000000..cd71a4f99 --- /dev/null +++ b/pkg/fourslash/tests/completionsInJsxTagDifferentSpreadElementTypes_test.go @@ -0,0 +1,64 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestCompletionsInJsxTagDifferentSpreadElementTypes(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = ` +// @Filename: /completionsWithDifferentSpreadTypes.tsx +// @strict: true + +// A reasonable type to spread. +export function ComponentObjectX(props: { x: string }) { + return ; +} + +// A questionable but valid type to spread. +export function ComponentObjectXOrY(props: { x: string } | { y: string }) { + return ; +} + +// A very unexpected type to spread (a union containing a primitive). +export function ComponentNumberOrObjectX(props: number | { x: string }) { + return ; +} + +// Very unexpected, but still structured (union) types. +// 'boolean' is 'true | false' and an optional 'null' is really 'null | undefined'. +export function ComponentBoolean(props: boolean) { + return ; +} +export function ComponentOptionalNull(props?: null) { + return ; +} + +// Primitive types (non-structured). +export function ComponentAny(props: any) { + return ; +} +export function ComponentUnknown(props: unknown) { + return ; +} +export function ComponentNever(props: never) { + return ; +} +export function ComponentUndefined(props: undefined) { + return ; +} +export function ComponentNumber(props: number) { + return ; +} +` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.GoToEachMarker(t, nil, func(marker *fourslash.Marker, index int) { + f.VerifyCompletions(t, marker, nil) + }) +} diff --git a/pkg/fourslash/tests/gen/addDeclareToFunction_test.go b/pkg/fourslash/tests/gen/addDeclareToFunction_test.go new file mode 100644 index 000000000..b12c50532 --- /dev/null +++ b/pkg/fourslash/tests/gen/addDeclareToFunction_test.go @@ -0,0 +1,21 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestAddDeclareToFunction(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `/*1*/function parseInt(s/*2*/:string):number;` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.GoToMarker(t, "2") + f.DeleteAtCaret(t, 7) + f.GoToMarker(t, "1") + f.Insert(t, "declare ") +} diff --git a/pkg/fourslash/tests/gen/addFunctionInDuplicatedConstructorClassBody_test.go b/pkg/fourslash/tests/gen/addFunctionInDuplicatedConstructorClassBody_test.go new file mode 100644 index 000000000..c4a6eddb1 --- /dev/null +++ b/pkg/fourslash/tests/gen/addFunctionInDuplicatedConstructorClassBody_test.go @@ -0,0 +1,24 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestAddFunctionInDuplicatedConstructorClassBody(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `class Foo { + constructor() { } + constructor() { } + /**/ +}` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.GoToMarker(t, "") + f.Insert(t, "fn() { }") + f.VerifyNumberOfErrorsInCurrentFile(t, 2) +} diff --git a/pkg/fourslash/tests/gen/allowLateBoundSymbolsOverwriteEarlyBoundSymbols_test.go b/pkg/fourslash/tests/gen/allowLateBoundSymbolsOverwriteEarlyBoundSymbols_test.go new file mode 100644 index 000000000..c3d121134 --- /dev/null +++ b/pkg/fourslash/tests/gen/allowLateBoundSymbolsOverwriteEarlyBoundSymbols_test.go @@ -0,0 +1,26 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestAllowLateBoundSymbolsOverwriteEarlyBoundSymbols(t *testing.T) { + t.Parallel() + t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `export {}; +const prop = "abc"; +function foo(): void {}; +foo.abc = 10; +foo[prop] = 10; +interface T0 { + [prop]: number; + abc: number; +}` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.VerifyNoErrors(t) +} diff --git a/pkg/fourslash/tests/gen/ambientVariablesWithSameName_test.go b/pkg/fourslash/tests/gen/ambientVariablesWithSameName_test.go new file mode 100644 index 000000000..35c3adff9 --- /dev/null +++ b/pkg/fourslash/tests/gen/ambientVariablesWithSameName_test.go @@ -0,0 +1,23 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestAmbientVariablesWithSameName(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `declare module M { + export var x: string; +} +declare var x: number;` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.GoToEOF(t) + f.InsertLine(t, "") + f.VerifyNoErrors(t) +} diff --git a/pkg/fourslash/tests/gen/arityErrorAfterStringCompletions_test.go b/pkg/fourslash/tests/gen/arityErrorAfterStringCompletions_test.go new file mode 100644 index 000000000..7a8d95293 --- /dev/null +++ b/pkg/fourslash/tests/gen/arityErrorAfterStringCompletions_test.go @@ -0,0 +1,41 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + . "github.com/buke/typescript-go-internal/pkg/fourslash/tests/util" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestArityErrorAfterStringCompletions(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @strict: true + +interface Events { + click: any; + drag: any; +} + +declare function addListener(type: K, listener: (ev: Events[K]) => any): void; + +/*1*/addListener/*2*/("/*3*/")` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.VerifyCompletions(t, []string{"3"}, &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Exact: []fourslash.CompletionsExpectedItem{ + "click", + "drag", + }, + }, + }) + f.VerifyErrorExistsBetweenMarkers(t, "1", "2") +} diff --git a/pkg/fourslash/tests/gen/asConstRefsNoErrors1_test.go b/pkg/fourslash/tests/gen/asConstRefsNoErrors1_test.go new file mode 100644 index 000000000..62d67e067 --- /dev/null +++ b/pkg/fourslash/tests/gen/asConstRefsNoErrors1_test.go @@ -0,0 +1,21 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestAsConstRefsNoErrors1(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `class Tex { + type = 'Text' as /**/const; +}` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.VerifyBaselineGoToDefinition(t, true, "") + f.VerifyNoErrors(t) +} diff --git a/pkg/fourslash/tests/gen/asConstRefsNoErrors2_test.go b/pkg/fourslash/tests/gen/asConstRefsNoErrors2_test.go new file mode 100644 index 000000000..045c99d74 --- /dev/null +++ b/pkg/fourslash/tests/gen/asConstRefsNoErrors2_test.go @@ -0,0 +1,21 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestAsConstRefsNoErrors2(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `class Tex { + type = 'Text'; +}` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.VerifyBaselineGoToDefinition(t, true, "") + f.VerifyNoErrors(t) +} diff --git a/pkg/fourslash/tests/gen/asConstRefsNoErrors3_test.go b/pkg/fourslash/tests/gen/asConstRefsNoErrors3_test.go new file mode 100644 index 000000000..4f503025c --- /dev/null +++ b/pkg/fourslash/tests/gen/asConstRefsNoErrors3_test.go @@ -0,0 +1,23 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestAsConstRefsNoErrors3(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @checkJs: true +// @Filename: file.js +class Tex { + type = (/** @type {/**/const} */'Text'); +}` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.VerifyBaselineGoToDefinition(t, true, "") + f.VerifyNoErrors(t) +} diff --git a/pkg/fourslash/tests/gen/autoFormattingOnPasting_test.go b/pkg/fourslash/tests/gen/autoFormattingOnPasting_test.go new file mode 100644 index 000000000..cb50211e6 --- /dev/null +++ b/pkg/fourslash/tests/gen/autoFormattingOnPasting_test.go @@ -0,0 +1,22 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestAutoFormattingOnPasting(t *testing.T) { + t.Parallel() + t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `module TestModule { +/**/ +}` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.GoToMarker(t, "") + f.Paste(t, " class TestClass{\nprivate foo;\npublic testMethod( )\n{}\n}") + f.VerifyCurrentFileContentIs(t, "module TestModule {\n class TestClass {\n private foo;\n public testMethod() { }\n }\n}") +} diff --git a/pkg/fourslash/tests/gen/automaticConstructorToggling_test.go b/pkg/fourslash/tests/gen/automaticConstructorToggling_test.go new file mode 100644 index 000000000..bbdd5e573 --- /dev/null +++ b/pkg/fourslash/tests/gen/automaticConstructorToggling_test.go @@ -0,0 +1,43 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestAutomaticConstructorToggling(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `class A { } +class B {/*B*/ } +class C { /*C*/constructor(val: T) { } } +class D { constructor(/*D*/val: T) { } } + +new /*Asig*/A(); +new /*Bsig*/B(""); +new /*Csig*/C(""); +new /*Dsig*/D();` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.GoToMarker(t, "B") + f.Insert(t, "constructor(val: T) { }") + f.VerifyQuickInfoAt(t, "Asig", "constructor A(): A", "") + f.VerifyQuickInfoAt(t, "Bsig", "constructor B(val: string): B", "") + f.VerifyQuickInfoAt(t, "Csig", "constructor C(val: string): C", "") + f.VerifyQuickInfoAt(t, "Dsig", "constructor D(val: string): D", "") + f.GoToMarker(t, "C") + f.DeleteAtCaret(t, 23) + f.VerifyQuickInfoAt(t, "Asig", "constructor A(): A", "") + f.VerifyQuickInfoAt(t, "Bsig", "constructor B(val: string): B", "") + f.VerifyQuickInfoAt(t, "Csig", "constructor C(): C", "") + f.VerifyQuickInfoAt(t, "Dsig", "constructor D(val: string): D", "") + f.GoToMarker(t, "D") + f.DeleteAtCaret(t, 6) + f.VerifyQuickInfoAt(t, "Asig", "constructor A(): A", "") + f.VerifyQuickInfoAt(t, "Bsig", "constructor B(val: string): B", "") + f.VerifyQuickInfoAt(t, "Csig", "constructor C(): C", "") + f.VerifyQuickInfoAt(t, "Dsig", "constructor D(): D", "") +} diff --git a/pkg/fourslash/tests/gen/chainedFatArrowFormatting_test.go b/pkg/fourslash/tests/gen/chainedFatArrowFormatting_test.go new file mode 100644 index 000000000..75cc42820 --- /dev/null +++ b/pkg/fourslash/tests/gen/chainedFatArrowFormatting_test.go @@ -0,0 +1,20 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestChainedFatArrowFormatting(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `var fn = () => () => null/**/` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.GoToMarker(t, "") + f.Insert(t, ";") + f.VerifyCurrentLineContentIs(t, "var fn = () => () => null;") +} diff --git a/pkg/fourslash/tests/gen/cloduleAsBaseClass2_test.go b/pkg/fourslash/tests/gen/cloduleAsBaseClass2_test.go new file mode 100644 index 000000000..f2ba58b40 --- /dev/null +++ b/pkg/fourslash/tests/gen/cloduleAsBaseClass2_test.go @@ -0,0 +1,92 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + . "github.com/buke/typescript-go-internal/pkg/fourslash/tests/util" + "github.com/buke/typescript-go-internal/pkg/ls" + "github.com/buke/typescript-go-internal/pkg/lsp/lsproto" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestCloduleAsBaseClass2(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @Filename: cloduleAsBaseClass2_0.ts +class A { + constructor(x: number) { } + foo() { } + static bar() { } +} + +module A { + export var x = 1; + export function baz() { } +} + +export = A; +// @Filename: cloduleAsBaseClass2_1.ts +import B = require('./cloduleAsBaseClass2_0'); +class D extends B { + constructor() { + super(1); + } + foo2() { } + static bar2() { } +} + +var d: D; +d./*1*/ +D./*2*/` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.VerifyCompletions(t, "1", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Exact: []fourslash.CompletionsExpectedItem{ + "foo", + "foo2", + }, + }, + }) + f.Insert(t, "foo()") + f.VerifyCompletions(t, "2", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Includes: []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "bar", + SortText: PtrTo(string(ls.SortTextLocalDeclarationPriority)), + }, + &lsproto.CompletionItem{ + Label: "bar2", + SortText: PtrTo(string(ls.SortTextLocalDeclarationPriority)), + }, + &lsproto.CompletionItem{ + Label: "baz", + SortText: PtrTo(string(ls.SortTextLocationPriority)), + }, + &lsproto.CompletionItem{ + Label: "x", + SortText: PtrTo(string(ls.SortTextLocationPriority)), + }, + }, + Excludes: []string{ + "foo", + "foo2", + }, + }, + }) + f.Insert(t, "bar()") + f.VerifyNoErrors(t) +} diff --git a/pkg/fourslash/tests/gen/cloduleAsBaseClass_test.go b/pkg/fourslash/tests/gen/cloduleAsBaseClass_test.go new file mode 100644 index 000000000..8a9d21e16 --- /dev/null +++ b/pkg/fourslash/tests/gen/cloduleAsBaseClass_test.go @@ -0,0 +1,89 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + . "github.com/buke/typescript-go-internal/pkg/fourslash/tests/util" + "github.com/buke/typescript-go-internal/pkg/ls" + "github.com/buke/typescript-go-internal/pkg/lsp/lsproto" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestCloduleAsBaseClass(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `class A { + constructor(x: number) { } + foo() { } + static bar() { } +} + +module A { + export var x = 1; + export function baz() { } +} + +class D extends A { + constructor() { + super(1); + } + foo2() { } + static bar2() { } +} + +var d: D; +d./*1*/ +D./*2*/` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.VerifyCompletions(t, "1", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Exact: []fourslash.CompletionsExpectedItem{ + "foo", + "foo2", + }, + }, + }) + f.Insert(t, "foo()") + f.VerifyCompletions(t, "2", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Exact: CompletionFunctionMembersPlus( + []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "bar", + SortText: PtrTo(string(ls.SortTextLocalDeclarationPriority)), + }, + &lsproto.CompletionItem{ + Label: "bar2", + SortText: PtrTo(string(ls.SortTextLocalDeclarationPriority)), + }, + &lsproto.CompletionItem{ + Label: "baz", + SortText: PtrTo(string(ls.SortTextLocationPriority)), + }, + &lsproto.CompletionItem{ + Label: "prototype", + SortText: PtrTo(string(ls.SortTextLocationPriority)), + }, + &lsproto.CompletionItem{ + Label: "x", + SortText: PtrTo(string(ls.SortTextLocationPriority)), + }, + }), + }, + }) + f.Insert(t, "bar()") + f.VerifyNoErrors(t) +} diff --git a/pkg/fourslash/tests/gen/cloduleTypeOf1_test.go b/pkg/fourslash/tests/gen/cloduleTypeOf1_test.go new file mode 100644 index 000000000..c55403800 --- /dev/null +++ b/pkg/fourslash/tests/gen/cloduleTypeOf1_test.go @@ -0,0 +1,80 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + . "github.com/buke/typescript-go-internal/pkg/fourslash/tests/util" + "github.com/buke/typescript-go-internal/pkg/ls" + "github.com/buke/typescript-go-internal/pkg/lsp/lsproto" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestCloduleTypeOf1(t *testing.T) { + t.Parallel() + t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `class C { + static foo(x: number) { } + x: T; +} + +module C { + export function f(x: typeof C) { + x./*1*/ + var /*3*/r = new /*2*/x(); + var /*5*/r2 = r./*4*/ + return typeof r; + } +}` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.VerifyCompletions(t, "1", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Includes: []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "f", + SortText: PtrTo(string(ls.SortTextLocationPriority)), + }, + &lsproto.CompletionItem{ + Label: "foo", + SortText: PtrTo(string(ls.SortTextLocalDeclarationPriority)), + }, + }, + }, + }) + f.Insert(t, "foo(1);") + f.VerifyCompletions(t, "2", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Includes: []fourslash.CompletionsExpectedItem{ + "x", + }, + }, + }) + f.VerifyQuickInfoAt(t, "3", "(local var) r: C", "") + f.VerifyCompletions(t, "4", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Includes: []fourslash.CompletionsExpectedItem{ + "x", + }, + }, + }) + f.Insert(t, "x;") + f.VerifyQuickInfoAt(t, "5", "(local var) r2: number", "") + f.VerifyNoErrors(t) +} diff --git a/pkg/fourslash/tests/gen/codeFixCannotFindModule_suggestion_falsePositive_test.go b/pkg/fourslash/tests/gen/codeFixCannotFindModule_suggestion_falsePositive_test.go new file mode 100644 index 000000000..109ae063c --- /dev/null +++ b/pkg/fourslash/tests/gen/codeFixCannotFindModule_suggestion_falsePositive_test.go @@ -0,0 +1,27 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestCodeFixCannotFindModule_suggestion_falsePositive(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @moduleResolution: bundler +// @resolveJsonModule: true +// @strict: true +// @Filename: /node_modules/foo/bar.json +{ "a": 0 } +// @Filename: /a.ts +import abs = require([|"foo/bar.json"|]); +abs;` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.VerifyNoErrors(t) + f.GoToFile(t, "/a.ts") + f.VerifySuggestionDiagnostics(t, nil) +} diff --git a/pkg/fourslash/tests/gen/codeFixSpellingJs3_test.go b/pkg/fourslash/tests/gen/codeFixSpellingJs3_test.go new file mode 100644 index 000000000..ca1b398a8 --- /dev/null +++ b/pkg/fourslash/tests/gen/codeFixSpellingJs3_test.go @@ -0,0 +1,33 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestCodeFixSpellingJs3(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @allowjs: true +// @noEmit: true +// @filename: a.js +class Classe { + non = 'oui' + methode() { + // no error on 'this' references + return this.none + } +} +class Derivee extends Classe { + methode() { + // no error on 'super' references + return super.none + } +}` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.VerifyNoErrors(t) +} diff --git a/pkg/fourslash/tests/gen/codeFixSpellingJs5_test.go b/pkg/fourslash/tests/gen/codeFixSpellingJs5_test.go new file mode 100644 index 000000000..3f7243401 --- /dev/null +++ b/pkg/fourslash/tests/gen/codeFixSpellingJs5_test.go @@ -0,0 +1,36 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestCodeFixSpellingJs5(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @allowjs: true +// @noEmit: true +// @filename: a.js +var other = { + puuce: 4 +} +var Jimmy = 1 +var John = 2 +// @filename: b.js +other.puuuce // OK, from another file +new Date().getGMTDate() // OK, from another file +window.argle // OK, from globalThis +self.blargle // OK, from globalThis + +// No suggestions for globals from other files +const atoc = setIntegral(() => console.log('ok'), 500) +AudioBuffin // etc +Jimmy +Jon` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.VerifyNoErrors(t) +} diff --git a/pkg/fourslash/tests/gen/codeFixSpellingJs6_test.go b/pkg/fourslash/tests/gen/codeFixSpellingJs6_test.go new file mode 100644 index 000000000..8909dda1e --- /dev/null +++ b/pkg/fourslash/tests/gen/codeFixSpellingJs6_test.go @@ -0,0 +1,68 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestCodeFixSpellingJs6(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @allowjs: true +// @checkjs: false +// @noEmit: true +// @filename: spellingUncheckedJS.js +export var inModule = 1 +inmodule.toFixed() + +function f() { + var locals = 2 + true + locale.toFixed() +} +class Classe { + non = 'oui' + methode() { + // no error on 'this' references + return this.none + } +} +class Derivee extends Classe { + methode() { + // no error on 'super' references + return super.none + } +} + + +var object = { + spaaace: 3 +} +object.spaaaace // error on read +object.spaace = 12 // error on write +object.fresh = 12 // OK +other.puuuce // OK, from another file +new Date().getGMTDate() // OK, from another file + +// No suggestions for globals from other files +const atoc = setIntegral(() => console.log('ok'), 500) +AudioBuffin // etc +Jimmy +Jon +window.argle +self.blargle +// @filename: other.js +var Jimmy = 1 +var John = 2 +Jon // error, it's from the same file +var other = { + puuce: 4 +} +window.argle +self.blargle` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.VerifyNoErrors(t) +} diff --git a/pkg/fourslash/tests/gen/codeFixSpellingJs7_test.go b/pkg/fourslash/tests/gen/codeFixSpellingJs7_test.go new file mode 100644 index 000000000..bf2b8a9f9 --- /dev/null +++ b/pkg/fourslash/tests/gen/codeFixSpellingJs7_test.go @@ -0,0 +1,69 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestCodeFixSpellingJs7(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @allowjs: true +// @noEmit: true +// @filename: spellingUncheckedJS.js +// @ts-nocheck +export var inModule = 1 +inmodule.toFixed() + +function f() { + var locals = 2 + true + locale.toFixed() +} +class Classe { + non = 'oui' + methode() { + // no error on 'this' references + return this.none + } +} +class Derivee extends Classe { + methode() { + // no error on 'super' references + return super.none + } +} + + +var object = { + spaaace: 3 +} +object.spaaaace // error on read +object.spaace = 12 // error on write +object.fresh = 12 // OK +other.puuuce // OK, from another file +new Date().getGMTDate() // OK, from another file + +// No suggestions for globals from other files +const atoc = setIntegral(() => console.log('ok'), 500) +AudioBuffin // etc +Jimmy +Jon +window.argle +self.blargle +// @filename: other.js +// @ts-nocheck +var Jimmy = 1 +var John = 2 +Jon // error, it's from the same file +var other = { + puuce: 4 +} +window.argle +self.blargle` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.VerifyNoErrors(t) +} diff --git a/pkg/fourslash/tests/gen/codeFixSpellingJs8_test.go b/pkg/fourslash/tests/gen/codeFixSpellingJs8_test.go new file mode 100644 index 000000000..51aca8646 --- /dev/null +++ b/pkg/fourslash/tests/gen/codeFixSpellingJs8_test.go @@ -0,0 +1,23 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestCodeFixSpellingJs8(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @allowjs: true +// @noEmit: true +// @filename: a.js +var locals = {} +// @ts-expect-error +Object.keys(locale)` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.VerifyNoErrors(t) +} diff --git a/pkg/fourslash/tests/gen/completionBeforeSemanticDiagnosticsInArrowFunction1_test.go b/pkg/fourslash/tests/gen/completionBeforeSemanticDiagnosticsInArrowFunction1_test.go new file mode 100644 index 000000000..60cef10fa --- /dev/null +++ b/pkg/fourslash/tests/gen/completionBeforeSemanticDiagnosticsInArrowFunction1_test.go @@ -0,0 +1,39 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + . "github.com/buke/typescript-go-internal/pkg/fourslash/tests/util" + "github.com/buke/typescript-go-internal/pkg/lsp/lsproto" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestCompletionBeforeSemanticDiagnosticsInArrowFunction1(t *testing.T) { + t.Parallel() + t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `var f4 = (x: T/**/ ) => { +}` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.GoToMarker(t, "") + f.Backspace(t, 1) + f.Insert(t, "A") + f.VerifyCompletions(t, nil, &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Includes: []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "T", + Detail: PtrTo("(type parameter) T in (x: A): void"), + }, + }, + }, + }) + f.VerifyNumberOfErrorsInCurrentFile(t, 1) +} diff --git a/pkg/fourslash/tests/gen/completionListInImportClause04_test.go b/pkg/fourslash/tests/gen/completionListInImportClause04_test.go new file mode 100644 index 000000000..fbb48e730 --- /dev/null +++ b/pkg/fourslash/tests/gen/completionListInImportClause04_test.go @@ -0,0 +1,49 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + . "github.com/buke/typescript-go-internal/pkg/fourslash/tests/util" + "github.com/buke/typescript-go-internal/pkg/ls" + "github.com/buke/typescript-go-internal/pkg/lsp/lsproto" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestCompletionListInImportClause04(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @Filename: foo.d.ts + declare class Foo { + static prop1(x: number): number; + static prop1(x: string): string; + static prop2(x: boolean): boolean; + } + export = Foo; /*2*/ +// @Filename: app.ts +import {/*1*/} from './foo';` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.VerifyCompletions(t, "1", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Unsorted: []fourslash.CompletionsExpectedItem{ + "prototype", + "prop1", + "prop2", + &lsproto.CompletionItem{ + Label: "type", + SortText: PtrTo(string(ls.SortTextGlobalsOrKeywords)), + }, + }, + }, + }) + f.VerifyNoErrors(t) + f.GoToMarker(t, "2") + f.VerifyNoErrors(t) +} diff --git a/pkg/fourslash/tests/gen/consistentContextualTypeErrorsAfterEdits_test.go b/pkg/fourslash/tests/gen/consistentContextualTypeErrorsAfterEdits_test.go new file mode 100644 index 000000000..5bf7da919 --- /dev/null +++ b/pkg/fourslash/tests/gen/consistentContextualTypeErrorsAfterEdits_test.go @@ -0,0 +1,32 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestConsistentContextualTypeErrorsAfterEdits(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `class A { + foo: string; +} +class C { + foo: string; +} +var xs /*1*/ = [(x: A) => { return x.foo; }, (x: C) => { return x.foo; }]; +xs.forEach(y => y(new /*2*/A()));` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.VerifyNumberOfErrorsInCurrentFile(t, 0) + f.GoToMarker(t, "1") + f.Insert(t, ": {}[]") + f.VerifyNumberOfErrorsInCurrentFile(t, 1) + f.GoToMarker(t, "2") + f.DeleteAtCaret(t, 1) + f.Insert(t, "C") + f.VerifyNumberOfErrorsInCurrentFile(t, 1) +} diff --git a/pkg/fourslash/tests/gen/constructorBraceFormatting_test.go b/pkg/fourslash/tests/gen/constructorBraceFormatting_test.go new file mode 100644 index 000000000..e0fa77166 --- /dev/null +++ b/pkg/fourslash/tests/gen/constructorBraceFormatting_test.go @@ -0,0 +1,23 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestConstructorBraceFormatting(t *testing.T) { + t.Parallel() + t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `class X { + constructor () {}/*target*/ + /**/` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.GoToMarker(t, "") + f.Insert(t, "}") + f.GoToMarker(t, "target") + f.VerifyCurrentLineContentIs(t, " constructor() { }") +} diff --git a/pkg/fourslash/tests/gen/contextualTypingOfGenericCallSignatures2_test.go b/pkg/fourslash/tests/gen/contextualTypingOfGenericCallSignatures2_test.go new file mode 100644 index 000000000..ad9d3a3c5 --- /dev/null +++ b/pkg/fourslash/tests/gen/contextualTypingOfGenericCallSignatures2_test.go @@ -0,0 +1,24 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestContextualTypingOfGenericCallSignatures2(t *testing.T) { + t.Parallel() + t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `interface I { + (x: T): void +} +function f6(x: (p: T) => void) { } +// x should not be contextually typed so this should be an error +f6(/**/x => x())` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.VerifyQuickInfoAt(t, "", "(parameter) x: T extends I", "") + f.VerifyNumberOfErrorsInCurrentFile(t, 1) +} diff --git a/pkg/fourslash/tests/gen/deduplicateDuplicateMergedBindCheckErrors_test.go b/pkg/fourslash/tests/gen/deduplicateDuplicateMergedBindCheckErrors_test.go new file mode 100644 index 000000000..269afe857 --- /dev/null +++ b/pkg/fourslash/tests/gen/deduplicateDuplicateMergedBindCheckErrors_test.go @@ -0,0 +1,25 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestDeduplicateDuplicateMergedBindCheckErrors(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `class X { + foo() { + return 1; + } + get foo() { + return 1; + } +}` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.VerifyNumberOfErrorsInCurrentFile(t, 2) +} diff --git a/pkg/fourslash/tests/gen/deleteClassWithEnumPresent_test.go b/pkg/fourslash/tests/gen/deleteClassWithEnumPresent_test.go new file mode 100644 index 000000000..d74131be3 --- /dev/null +++ b/pkg/fourslash/tests/gen/deleteClassWithEnumPresent_test.go @@ -0,0 +1,21 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestDeleteClassWithEnumPresent(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `enum Foo { a, b, c } +/**/class Bar { }` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.GoToMarker(t, "") + f.DeleteAtCaret(t, 13) + f.VerifyBaselineDocumentSymbol(t) +} diff --git a/pkg/fourslash/tests/gen/deleteExtensionInReopenedInterface_test.go b/pkg/fourslash/tests/gen/deleteExtensionInReopenedInterface_test.go new file mode 100644 index 000000000..6bb1494dc --- /dev/null +++ b/pkg/fourslash/tests/gen/deleteExtensionInReopenedInterface_test.go @@ -0,0 +1,34 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestDeleteExtensionInReopenedInterface(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `interface A { a: number; } +interface B { b: number; } + +interface I /*del*/extends A { } +interface I extends B { } + +var i: I; +class C /*delImplements*/implements A { } +var c: C; +c.a;` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.GoToMarker(t, "del") + f.DeleteAtCaret(t, 9) + f.GoToEOF(t) + f.Insert(t, "var a = i.a;") + f.GoToMarker(t, "delImplements") + f.DeleteAtCaret(t, 12) + f.GoToMarker(t, "del") + f.Insert(t, "extends A") +} diff --git a/pkg/fourslash/tests/gen/deleteModifierBeforeVarStatement1_test.go b/pkg/fourslash/tests/gen/deleteModifierBeforeVarStatement1_test.go new file mode 100644 index 000000000..bcdae37f2 --- /dev/null +++ b/pkg/fourslash/tests/gen/deleteModifierBeforeVarStatement1_test.go @@ -0,0 +1,43 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestDeleteModifierBeforeVarStatement1(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = ` + +///////////////////////////// +/// Windows Script Host APIS +///////////////////////////// + +declare var ActiveXObject: { new (s: string): any; }; + +interface ITextWriter { + WriteLine(s): void; +} + +declare var WScript: { + Echo(s): void; + StdErr: ITextWriter; + Arguments: { length: number; Item(): string; }; + ScriptFullName: string; + Quit(): number; +} +` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.GoToFileNumber(t, 0) + f.GoToPosition(t, 0) + f.DeleteAtCaret(t, 100) + f.GoToPosition(t, 198) + f.DeleteAtCaret(t, 16) + f.GoToPosition(t, 198) + f.Insert(t, "Item(): string; ") +} diff --git a/pkg/fourslash/tests/gen/deleteTypeParameter_test.go b/pkg/fourslash/tests/gen/deleteTypeParameter_test.go new file mode 100644 index 000000000..481d41367 --- /dev/null +++ b/pkg/fourslash/tests/gen/deleteTypeParameter_test.go @@ -0,0 +1,27 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestDeleteTypeParameter(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `interface Query { + groupBy(): Query; +} +interface Query2 { + groupBy(): Query2>; +} +var q1: Query; +var q2: Query2; +q1 = q2;` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.GoToMarker(t, "") + f.DeleteAtCaret(t, 1) +} diff --git a/pkg/fourslash/tests/gen/derivedTypeIndexerWithGenericConstraints_test.go b/pkg/fourslash/tests/gen/derivedTypeIndexerWithGenericConstraints_test.go new file mode 100644 index 000000000..ad4e71f21 --- /dev/null +++ b/pkg/fourslash/tests/gen/derivedTypeIndexerWithGenericConstraints_test.go @@ -0,0 +1,36 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestDerivedTypeIndexerWithGenericConstraints(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `class CollectionItem { + x: number; +} +class Entity extends CollectionItem { + y: number; +} +class BaseCollection { + _itemsByKey: { [key: string]: TItem; }; +} +class DbSet extends BaseCollection { // error + _itemsByKey: { [key: string]: TEntity; } = {}; +} +var a: BaseCollection; +var /**/r = a._itemsByKey['x']; // should just say CollectionItem not TItem extends CollectionItem +var result = r.x; +a = new DbSet(); +var r2 = a._itemsByKey['x']; +var result2 = r2.x;` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.VerifyQuickInfoAt(t, "", "var r: CollectionItem", "") + f.VerifyNoErrors(t) +} diff --git a/pkg/fourslash/tests/gen/duplicatePackageServices_test.go b/pkg/fourslash/tests/gen/duplicatePackageServices_test.go new file mode 100644 index 000000000..b3413d5ab --- /dev/null +++ b/pkg/fourslash/tests/gen/duplicatePackageServices_test.go @@ -0,0 +1,43 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestDuplicatePackageServices(t *testing.T) { + t.Parallel() + t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @noImplicitReferences: true +// @Filename: /node_modules/a/index.d.ts +import [|X/*useAX*/|] from "x"; +export function a(x: X): void; +// @Filename: /node_modules/a/node_modules/x/index.d.ts +export default class /*defAX*/X { + private x: number; +} +// @Filename: /node_modules/a/node_modules/x/package.json +{ "name": "x", "version": "1.2.3" } +// @Filename: /node_modules/b/index.d.ts +import [|X/*useBX*/|] from "x"; +export const b: X; +// @Filename: /node_modules/b/node_modules/x/index.d.ts +export default class /*defBX*/X { + private x: number; +} +// @Filename: /node_modules/b/node_modules/x/package.json +{ "name": "x", "version": "1.2.3" } +// @Filename: /src/a.ts +import { a } from "a"; +import { b } from "b"; +a(/*error*/b);` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.GoToFile(t, "/src/a.ts") + f.VerifyNumberOfErrorsInCurrentFile(t, 0) + f.VerifyBaselineFindAllReferences(t, "useAX", "defAX", "useBX") + f.VerifyBaselineGoToDefinition(t, true, "useAX", "useBX") +} diff --git a/pkg/fourslash/tests/gen/editLambdaArgToTypeParameter1_test.go b/pkg/fourslash/tests/gen/editLambdaArgToTypeParameter1_test.go new file mode 100644 index 000000000..a2de5de3e --- /dev/null +++ b/pkg/fourslash/tests/gen/editLambdaArgToTypeParameter1_test.go @@ -0,0 +1,29 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestEditLambdaArgToTypeParameter1(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `class C { + foo(x: T) { + return (a: number/*1*/) => x; + } +} +/*2*/` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.GoToMarker(t, "1") + f.Backspace(t, 6) + f.Insert(t, "T") + f.VerifyNoErrors(t) + f.GoToMarker(t, "2") + f.InsertLine(t, "") + f.VerifyNoErrors(t) +} diff --git a/pkg/fourslash/tests/gen/enumUpdate1_test.go b/pkg/fourslash/tests/gen/enumUpdate1_test.go new file mode 100644 index 000000000..b193fe162 --- /dev/null +++ b/pkg/fourslash/tests/gen/enumUpdate1_test.go @@ -0,0 +1,33 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestEnumUpdate1(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `module M { + export enum E { + A = 1, + B = 2, + C = 3, + /*1*/ + } +} +module M { + function foo(): M.E { + return M.E.A; + } +}` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.VerifyNoErrors(t) + f.GoToMarker(t, "1") + f.Insert(t, "D = C << 1,") + f.VerifyNoErrors(t) +} diff --git a/pkg/fourslash/tests/gen/errorConsistency_test.go b/pkg/fourslash/tests/gen/errorConsistency_test.go new file mode 100644 index 000000000..d361cedea --- /dev/null +++ b/pkg/fourslash/tests/gen/errorConsistency_test.go @@ -0,0 +1,27 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestErrorConsistency(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `interface Int { +val(f: (t: T) => U): Int; +} +declare var v1: Int; +var /*1*/v2/*2*/: Int = v1;` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.GoToEOF(t) + f.VerifyErrorExistsBetweenMarkers(t, "1", "2") + f.VerifyNumberOfErrorsInCurrentFile(t, 1) + f.Backspace(t, 1) + f.VerifyErrorExistsBetweenMarkers(t, "1", "2") + f.VerifyNumberOfErrorsInCurrentFile(t, 1) +} diff --git a/pkg/fourslash/tests/gen/errorInIncompleteMethodInObjectLiteral_test.go b/pkg/fourslash/tests/gen/errorInIncompleteMethodInObjectLiteral_test.go new file mode 100644 index 000000000..11de77ea3 --- /dev/null +++ b/pkg/fourslash/tests/gen/errorInIncompleteMethodInObjectLiteral_test.go @@ -0,0 +1,18 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestErrorInIncompleteMethodInObjectLiteral(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `var x: { f(): string } = { f( }` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.VerifyNumberOfErrorsInCurrentFile(t, 1) +} diff --git a/pkg/fourslash/tests/gen/errorsAfterResolvingVariableDeclOfMergedVariableAndClassDecl_test.go b/pkg/fourslash/tests/gen/errorsAfterResolvingVariableDeclOfMergedVariableAndClassDecl_test.go new file mode 100644 index 000000000..12352b8c9 --- /dev/null +++ b/pkg/fourslash/tests/gen/errorsAfterResolvingVariableDeclOfMergedVariableAndClassDecl_test.go @@ -0,0 +1,30 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestErrorsAfterResolvingVariableDeclOfMergedVariableAndClassDecl(t *testing.T) { + t.Parallel() + t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `module M { + export class C { + foo() { } + } + export module C { + export var /*1*/C = M.C; + } +}` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.VerifyNoErrors(t) + f.GoToMarker(t, "1") + f.Backspace(t, 1) + f.Insert(t, " ") + f.VerifyQuickInfoIs(t, "var M.C.C: typeof M.C", "") + f.VerifyNoErrors(t) +} diff --git a/pkg/fourslash/tests/gen/exportEqualTypes_test.go b/pkg/fourslash/tests/gen/exportEqualTypes_test.go new file mode 100644 index 000000000..7eb260d3c --- /dev/null +++ b/pkg/fourslash/tests/gen/exportEqualTypes_test.go @@ -0,0 +1,46 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + . "github.com/buke/typescript-go-internal/pkg/fourslash/tests/util" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestExportEqualTypes(t *testing.T) { + t.Parallel() + t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @Filename: exportEqualTypes_file0.ts +interface x { + (): Date; + foo: string; +} +export = x; +// @Filename: exportEqualTypes_file1.ts +/// +import test = require('./exportEqualTypes_file0'); +var t: /*1*/test; // var 't' should be of type 'test' +var /*2*/r1 = t(); // Should return a Date +var /*3*/r2 = t./*4*/foo; // t should have 'foo' in dropdown list and be of type 'string'` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.VerifyQuickInfoAt(t, "1", "(alias) interface test\nimport test = require('./exportEqualTypes_file0')", "") + f.VerifyQuickInfoAt(t, "2", "var r1: Date", "") + f.VerifyQuickInfoAt(t, "3", "var r2: string", "") + f.VerifyCompletions(t, "4", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Exact: CompletionFunctionMembersWithPrototypePlus( + []fourslash.CompletionsExpectedItem{ + "foo", + }), + }, + }) + f.VerifyNoErrors(t) +} diff --git a/pkg/fourslash/tests/gen/extendInterfaceOverloadedMethod_test.go b/pkg/fourslash/tests/gen/extendInterfaceOverloadedMethod_test.go new file mode 100644 index 000000000..4291a1efb --- /dev/null +++ b/pkg/fourslash/tests/gen/extendInterfaceOverloadedMethod_test.go @@ -0,0 +1,28 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestExtendInterfaceOverloadedMethod(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `interface A { + foo(a: T): B; + foo(): void ; + foo2(): B; +} +interface B extends A { + bar(): void ; +} +var b: B; +var /**/x = b.foo2().foo(5).foo(); // 'x' is of type 'void'` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.VerifyQuickInfoAt(t, "", "var x: void", "") + f.VerifyNoErrors(t) +} diff --git a/pkg/fourslash/tests/gen/extendsTArray_test.go b/pkg/fourslash/tests/gen/extendsTArray_test.go new file mode 100644 index 000000000..50560e93e --- /dev/null +++ b/pkg/fourslash/tests/gen/extendsTArray_test.go @@ -0,0 +1,27 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestExtendsTArray(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `interface I1 { + (a: T): T; +} +interface I2 extends I1 { + b: T; +} +var x: I2; +var /**/y = x(undefined); // Typeof y should be Date[] +y.length;` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.VerifyQuickInfoAt(t, "", "var y: Date[]", "") + f.VerifyNoErrors(t) +} diff --git a/pkg/fourslash/tests/gen/externalModuleIntellisense_test.go b/pkg/fourslash/tests/gen/externalModuleIntellisense_test.go new file mode 100644 index 000000000..4d191c94c --- /dev/null +++ b/pkg/fourslash/tests/gen/externalModuleIntellisense_test.go @@ -0,0 +1,49 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + . "github.com/buke/typescript-go-internal/pkg/fourslash/tests/util" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestExternalModuleIntellisense(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @Filename: externalModuleIntellisense_file0.ts +export = express; +function express(): express.ExpressServer; +module express { + export interface ExpressServer { + enable(name: string): ExpressServer; + post(path: RegExp, handler: (req: Function) => void): void; + } + export class ExpressServerRequest { + } +} +// @Filename: externalModuleIntellisense_file1.ts +/// +import express = require('./externalModuleIntellisense_file0'); +var x = express();/*1*/` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.GoToMarker(t, "1") + f.VerifyNumberOfErrorsInCurrentFile(t, 0) + f.GoToEOF(t) + f.Insert(t, "x.") + f.VerifyCompletions(t, nil, &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Exact: []fourslash.CompletionsExpectedItem{ + "enable", + "post", + }, + }, + }) +} diff --git a/pkg/fourslash/tests/gen/failureToImplementClass_test.go b/pkg/fourslash/tests/gen/failureToImplementClass_test.go new file mode 100644 index 000000000..34602dca8 --- /dev/null +++ b/pkg/fourslash/tests/gen/failureToImplementClass_test.go @@ -0,0 +1,22 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestFailureToImplementClass(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `interface IExec { + exec: (filename: string, cmdLine: string) => boolean; +} +class /*1*/NodeExec/*2*/ implements IExec { }` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.VerifyErrorExistsBetweenMarkers(t, "1", "2") + f.VerifyNumberOfErrorsInCurrentFile(t, 1) +} diff --git a/pkg/fourslash/tests/gen/findAllRefsExportAsNamespace_test.go b/pkg/fourslash/tests/gen/findAllRefsExportAsNamespace_test.go new file mode 100644 index 000000000..694cedd1e --- /dev/null +++ b/pkg/fourslash/tests/gen/findAllRefsExportAsNamespace_test.go @@ -0,0 +1,25 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestFindAllRefsExportAsNamespace(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @Filename: /node_modules/a/index.d.ts +export function /*0*/f(): void; +export as namespace A; +// @Filename: /b.ts +import { /*1*/f } from "a"; +// @Filename: /c.ts +A./*2*/f();` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.VerifyNoErrors(t) + f.VerifyBaselineFindAllReferences(t, "0", "1", "2") +} diff --git a/pkg/fourslash/tests/gen/findAllRefsForDefaultExport08_test.go b/pkg/fourslash/tests/gen/findAllRefsForDefaultExport08_test.go new file mode 100644 index 000000000..bd07a0a3e --- /dev/null +++ b/pkg/fourslash/tests/gen/findAllRefsForDefaultExport08_test.go @@ -0,0 +1,27 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestFindAllRefsForDefaultExport08(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `export default class DefaultExportedClass { +} + +var x: DefaultExportedClass; + +var y = new DefaultExportedClass; + +namespace /*1*/DefaultExportedClass { +}` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.VerifyNoErrors(t) + f.VerifyBaselineFindAllReferences(t, "1") +} diff --git a/pkg/fourslash/tests/gen/findAllRefsForDefaultExport_reExport_allowSyntheticDefaultImports_test.go b/pkg/fourslash/tests/gen/findAllRefsForDefaultExport_reExport_allowSyntheticDefaultImports_test.go new file mode 100644 index 000000000..a1e15a96e --- /dev/null +++ b/pkg/fourslash/tests/gen/findAllRefsForDefaultExport_reExport_allowSyntheticDefaultImports_test.go @@ -0,0 +1,26 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestFindAllRefsForDefaultExport_reExport_allowSyntheticDefaultImports(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @allowSyntheticDefaultImports: true +// @Filename: /export.ts +const /*0*/foo = 1; +export = /*1*/foo; +// @Filename: /re-export.ts +export { /*2*/default } from "./export"; +// @Filename: /re-export-dep.ts +import /*3*/fooDefault from "./re-export";` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.VerifyNoErrors(t) + f.VerifyBaselineFindAllReferences(t, "0", "1", "2", "3") +} diff --git a/pkg/fourslash/tests/gen/findAllRefsForModuleGlobal_test.go b/pkg/fourslash/tests/gen/findAllRefsForModuleGlobal_test.go new file mode 100644 index 000000000..d81e8fa6a --- /dev/null +++ b/pkg/fourslash/tests/gen/findAllRefsForModuleGlobal_test.go @@ -0,0 +1,24 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestFindAllRefsForModuleGlobal(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @Filename: /node_modules/foo/index.d.ts +export const x = 0; +// @Filename: /b.ts +/// +import { x } from "/*1*/foo"; +declare module "foo" {}` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.VerifyNoErrors(t) + f.VerifyBaselineFindAllReferences(t, "1") +} diff --git a/pkg/fourslash/tests/gen/findAllRefsGlobalModuleAugmentation_test.go b/pkg/fourslash/tests/gen/findAllRefsGlobalModuleAugmentation_test.go new file mode 100644 index 000000000..8c87c3410 --- /dev/null +++ b/pkg/fourslash/tests/gen/findAllRefsGlobalModuleAugmentation_test.go @@ -0,0 +1,25 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestFindAllRefsGlobalModuleAugmentation(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @Filename: /a.ts +export {}; +declare global { + /*1*/function /*2*/f(): void; +} +// @Filename: /b.ts +/*3*/f();` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.VerifyNoErrors(t) + f.VerifyBaselineFindAllReferences(t, "1", "2", "3") +} diff --git a/pkg/fourslash/tests/gen/findAllRefsImportDefault_test.go b/pkg/fourslash/tests/gen/findAllRefsImportDefault_test.go new file mode 100644 index 000000000..8b7abff1a --- /dev/null +++ b/pkg/fourslash/tests/gen/findAllRefsImportDefault_test.go @@ -0,0 +1,26 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestFindAllRefsImportDefault(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @Filename: f.ts +export { foo as default }; +function /*start*/foo(a: number, b: number) { + return a + b; +} +// @Filename: b.ts +import bar from "./f"; +bar(1, 2);` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.VerifyNoErrors(t) + f.VerifyBaselineFindAllReferences(t, "start") +} diff --git a/pkg/fourslash/tests/gen/findAllRefsImportEqualsJsonFile_test.go b/pkg/fourslash/tests/gen/findAllRefsImportEqualsJsonFile_test.go new file mode 100644 index 000000000..e8399e1da --- /dev/null +++ b/pkg/fourslash/tests/gen/findAllRefsImportEqualsJsonFile_test.go @@ -0,0 +1,29 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestFindAllRefsImportEqualsJsonFile(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @allowJs: true +// @checkJs: true +// @resolveJsonModule: true +// @Filename: /a.ts +import /*0*/j = require("/*1*/./j.json"); +/*2*/j; +// @Filename: /b.js +const /*3*/j = require("/*4*/./j.json"); +/*5*/j; +// @Filename: /j.json +/*6*/{ "x": 0 }` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.VerifyNoErrors(t) + f.VerifyBaselineFindAllReferences(t, "0", "2", "1", "4", "3", "5", "6") +} diff --git a/pkg/fourslash/tests/gen/findAllRefsImportNamed_test.go b/pkg/fourslash/tests/gen/findAllRefsImportNamed_test.go new file mode 100644 index 000000000..98613414c --- /dev/null +++ b/pkg/fourslash/tests/gen/findAllRefsImportNamed_test.go @@ -0,0 +1,24 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestFindAllRefsImportNamed(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @Filename: f.ts +export { foo as foo } +function /*start*/foo(a: number, b: number) { } +// @Filename: b.ts +import x = require("./f"); +x.foo(1, 2);` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.VerifyNoErrors(t) + f.VerifyBaselineFindAllReferences(t, "start") +} diff --git a/pkg/fourslash/tests/gen/findAllRefsImportStarOfExportEquals_test.go b/pkg/fourslash/tests/gen/findAllRefsImportStarOfExportEquals_test.go new file mode 100644 index 000000000..7006fea26 --- /dev/null +++ b/pkg/fourslash/tests/gen/findAllRefsImportStarOfExportEquals_test.go @@ -0,0 +1,36 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestFindAllRefsImportStarOfExportEquals(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @allowSyntheticDefaultimports: true +// @Filename: /node_modules/a/index.d.ts +[|declare function /*a0*/[|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 0 |}a|](): void;|] +[|declare namespace /*a1*/[|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 2 |}a|] { + export const x: number; +}|] +[|export = /*a2*/[|{| "contextRangeIndex": 4 |}a|];|] +// @Filename: /b.ts +[|import /*b0*/[|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 6 |}b|] from "a";|] +/*b1*/[|b|](); +[|b|].x; +// @Filename: /c.ts +[|import /*c0*/[|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 10 |}a|] from "a";|] +/*c1*/[|a|](); +/*c2*/[|a|].x;` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.VerifyNoErrors(t) + f.VerifyBaselineFindAllReferences(t, "a0", "a1", "a2", "b0", "b1", "c0", "c1", "c2") + f.VerifyBaselineRename(t, nil /*preferences*/, f.Ranges()[1], f.Ranges()[3], f.Ranges()[5]) + f.VerifyBaselineRename(t, nil /*preferences*/, f.Ranges()[7], f.Ranges()[8], f.Ranges()[9]) + f.VerifyBaselineRename(t, nil /*preferences*/, f.Ranges()[11], f.Ranges()[12], f.Ranges()[13]) +} diff --git a/pkg/fourslash/tests/gen/findAllRefsModuleAugmentation_test.go b/pkg/fourslash/tests/gen/findAllRefsModuleAugmentation_test.go new file mode 100644 index 000000000..3becb719b --- /dev/null +++ b/pkg/fourslash/tests/gen/findAllRefsModuleAugmentation_test.go @@ -0,0 +1,25 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestFindAllRefsModuleAugmentation(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @Filename: /node_modules/foo/index.d.ts +/*1*/export type /*2*/T = number; +// @Filename: /a.ts +import * as foo from "foo"; +declare module "foo" { + export const x: /*3*/T; +}` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.VerifyNoErrors(t) + f.VerifyBaselineFindAllReferences(t, "1", "2", "3") +} diff --git a/pkg/fourslash/tests/gen/findAllRefsOfConstructor2_test.go b/pkg/fourslash/tests/gen/findAllRefsOfConstructor2_test.go new file mode 100644 index 000000000..9729d52e0 --- /dev/null +++ b/pkg/fourslash/tests/gen/findAllRefsOfConstructor2_test.go @@ -0,0 +1,34 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestFindAllRefsOfConstructor2(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `class A { + /*a*/constructor(s: string) {} +} +class B extends A { + /*b*/constructor() { super(""); } +} +class C extends B { + /*c*/constructor() { + super(); + } +} +class D extends B { } +const a = new A("a"); +const b = new B(); +const c = new C(); +const d = new D();` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.VerifyNoErrors(t) + f.VerifyBaselineFindAllReferences(t, "a", "b", "c") +} diff --git a/pkg/fourslash/tests/gen/findAllRefsOfConstructor_multipleFiles_test.go b/pkg/fourslash/tests/gen/findAllRefsOfConstructor_multipleFiles_test.go new file mode 100644 index 000000000..f1e0bb7c8 --- /dev/null +++ b/pkg/fourslash/tests/gen/findAllRefsOfConstructor_multipleFiles_test.go @@ -0,0 +1,33 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestFindAllRefsOfConstructor_multipleFiles(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @Filename: f.ts +class A { + /*aCtr*/constructor(s: string) {} +} +class B extends A { } +export { A, B }; +// @Filename: a.ts +import { A as A1 } from "./f"; +const a1 = new A1("a1"); +export default class extends A1 { } +export { B as B1 } from "./f"; +// @Filename: b.ts +import B, { B1 } from "./a"; +const d = new B("b"); +const d1 = new B1("b1");` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.VerifyNoErrors(t) + f.VerifyBaselineFindAllReferences(t, "aCtr") +} diff --git a/pkg/fourslash/tests/gen/findAllRefsOfConstructor_test.go b/pkg/fourslash/tests/gen/findAllRefsOfConstructor_test.go new file mode 100644 index 000000000..a348f4d6e --- /dev/null +++ b/pkg/fourslash/tests/gen/findAllRefsOfConstructor_test.go @@ -0,0 +1,34 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestFindAllRefsOfConstructor(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `class A { + /*aCtr*/constructor(s: string) {} +} +class B extends A { } +class C extends B { + /*cCtr*/constructor() { + super(""); + } +} +class D extends B { } +class E implements A { } +const a = new A("a"); +const b = new B("b"); +const c = new C(); +const d = new D("d"); +const e = new E();` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.VerifyNoErrors(t) + f.VerifyBaselineFindAllReferences(t, "aCtr", "cCtr") +} diff --git a/pkg/fourslash/tests/gen/findAllRefsPrefixSuffixPreference_test.go b/pkg/fourslash/tests/gen/findAllRefsPrefixSuffixPreference_test.go new file mode 100644 index 000000000..20c13c9ba --- /dev/null +++ b/pkg/fourslash/tests/gen/findAllRefsPrefixSuffixPreference_test.go @@ -0,0 +1,37 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/core" + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/ls/lsutil" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestFindAllRefsPrefixSuffixPreference(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @Filename: /file1.ts +declare function log(s: string | number): void; +[|const /*q0*/[|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 0 |}q|] = 1;|] +[|export { /*q1*/[|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 2 |}q|] };|] +const x = { + [|/*z0*/[|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 4 |}z|]: 'value'|] +} +[|const { /*z1*/[|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 6 |}z|] } = x;|] +log(/*z2*/[|z|]); +// @Filename: /file2.ts +declare function log(s: string | number): void; +[|import { /*q2*/[|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 9 |}q|] } from "./file1";|] +log(/*q3*/[|q|] + 1);` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.VerifyNoErrors(t) + f.VerifyBaselineFindAllReferences(t, "q0", "q1", "q2", "q3", "z0", "z1", "z2") + f.VerifyBaselineRename(t, &lsutil.UserPreferences{UseAliasesForRename: core.TSTrue}, f.Ranges()[1], f.Ranges()[3], f.Ranges()[10], f.Ranges()[11]) + f.VerifyBaselineRename(t, &lsutil.UserPreferences{UseAliasesForRename: core.TSFalse}, f.Ranges()[1], f.Ranges()[3], f.Ranges()[10], f.Ranges()[11]) + f.VerifyBaselineRename(t, &lsutil.UserPreferences{UseAliasesForRename: core.TSTrue}, f.Ranges()[5], f.Ranges()[7], f.Ranges()[8]) + f.VerifyBaselineRename(t, &lsutil.UserPreferences{UseAliasesForRename: core.TSFalse}, f.Ranges()[5], f.Ranges()[7], f.Ranges()[8]) +} diff --git a/pkg/fourslash/tests/gen/findAllRefsReExportLocal_test.go b/pkg/fourslash/tests/gen/findAllRefsReExportLocal_test.go new file mode 100644 index 000000000..ca9c53675 --- /dev/null +++ b/pkg/fourslash/tests/gen/findAllRefsReExportLocal_test.go @@ -0,0 +1,31 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestFindAllRefsReExportLocal(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @noLib: true +// @Filename: /a.ts +[|var /*ax0*/[|{| "isDefinition": true, "contextRangeIndex": 0 |}x|];|] +[|export { /*ax1*/[|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 2 |}x|] };|] +[|export { /*ax2*/[|{| "contextRangeIndex": 4 |}x|] as /*ay*/[|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 4 |}y|] };|] +// @Filename: /b.ts +[|import { /*bx0*/[|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 7 |}x|], /*by0*/[|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 7 |}y|] } from "./a";|] +/*bx1*/[|x|]; /*by1*/[|y|];` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.VerifyNoErrors(t) + f.VerifyBaselineFindAllReferences(t, "ax0", "ax1", "ax2", "bx0", "bx1", "ay", "by0", "by1") + f.VerifyBaselineRename(t, nil /*preferences*/, f.Ranges()[1], f.Ranges()[5]) + f.VerifyBaselineRename(t, nil /*preferences*/, f.Ranges()[3]) + f.VerifyBaselineRename(t, nil /*preferences*/, f.Ranges()[8], f.Ranges()[10]) + f.VerifyBaselineRename(t, nil /*preferences*/, f.Ranges()[6]) + f.VerifyBaselineRename(t, nil /*preferences*/, f.Ranges()[9], f.Ranges()[11]) +} diff --git a/pkg/fourslash/tests/gen/findAllRefsReExportRightNameWrongSymbol_test.go b/pkg/fourslash/tests/gen/findAllRefsReExportRightNameWrongSymbol_test.go new file mode 100644 index 000000000..7cd8c8760 --- /dev/null +++ b/pkg/fourslash/tests/gen/findAllRefsReExportRightNameWrongSymbol_test.go @@ -0,0 +1,33 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestFindAllRefsReExportRightNameWrongSymbol(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @Filename: /a.ts +[|export const /*a*/[|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 0 |}x|] = 0;|] +// @Filename: /b.ts +[|export const /*b*/[|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 2 |}x|] = 0;|] +//@Filename: /c.ts +[|export { /*cFromB*/[|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 4 |}x|] } from "./b";|] +[|import { /*cFromA*/[|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 6 |}x|] } from "./a";|] +/*cUse*/[|x|]; +// @Filename: /d.ts +[|import { /*d*/[|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 9 |}x|] } from "./c";|]` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.VerifyNoErrors(t) + f.VerifyBaselineFindAllReferences(t, "a", "b", "cFromB", "cFromA", "cUse", "d") + f.VerifyBaselineRename(t, nil /*preferences*/, f.Ranges()[1]) + f.VerifyBaselineRename(t, nil /*preferences*/, f.Ranges()[7], f.Ranges()[8]) + f.VerifyBaselineRename(t, nil /*preferences*/, f.Ranges()[3]) + f.VerifyBaselineRename(t, nil /*preferences*/, f.Ranges()[5]) + f.VerifyBaselineRename(t, nil /*preferences*/, f.Ranges()[10]) +} diff --git a/pkg/fourslash/tests/gen/findAllRefsReExportStarAs_test.go b/pkg/fourslash/tests/gen/findAllRefsReExportStarAs_test.go new file mode 100644 index 000000000..8ed9188b8 --- /dev/null +++ b/pkg/fourslash/tests/gen/findAllRefsReExportStarAs_test.go @@ -0,0 +1,25 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestFindAllRefsReExportStarAs(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @Filename: /leafModule.ts +export const /*helloDef*/hello = () => 'Hello'; +// @Filename: /exporting.ts +export * as /*leafDef*/Leaf from './leafModule'; +// @Filename: /importing.ts + import { /*leafImportDef*/Leaf } from './exporting'; + /*leafUse*/[|Leaf|]./*helloUse*/[|hello|]()` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.VerifyNoErrors(t) + f.VerifyBaselineFindAllReferences(t, "helloDef", "helloUse", "leafDef", "leafImportDef", "leafUse") +} diff --git a/pkg/fourslash/tests/gen/findAllRefsReExportStar_test.go b/pkg/fourslash/tests/gen/findAllRefsReExportStar_test.go new file mode 100644 index 000000000..9f44252ef --- /dev/null +++ b/pkg/fourslash/tests/gen/findAllRefsReExportStar_test.go @@ -0,0 +1,24 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestFindAllRefsReExportStar(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @Filename: /a.ts +export function /*0*/foo(): void {} +// @Filename: /b.ts +export * from "./a"; +// @Filename: /c.ts +import { /*1*/foo } from "./b";` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.VerifyNoErrors(t) + f.VerifyBaselineFindAllReferences(t, "0", "1") +} diff --git a/pkg/fourslash/tests/gen/findAllRefsReExports2_test.go b/pkg/fourslash/tests/gen/findAllRefsReExports2_test.go new file mode 100644 index 000000000..d4b5e9be2 --- /dev/null +++ b/pkg/fourslash/tests/gen/findAllRefsReExports2_test.go @@ -0,0 +1,22 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestFindAllRefsReExports2(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @Filename: /a.ts +export function /*1*/foo(): void {} +// @Filename: /b.ts +import { foo as oof } from "./a";` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.VerifyNoErrors(t) + f.VerifyBaselineFindAllReferences(t, "1") +} diff --git a/pkg/fourslash/tests/gen/findAllRefsReExportsUseInImportType_test.go b/pkg/fourslash/tests/gen/findAllRefsReExportsUseInImportType_test.go new file mode 100644 index 000000000..397eb084d --- /dev/null +++ b/pkg/fourslash/tests/gen/findAllRefsReExportsUseInImportType_test.go @@ -0,0 +1,35 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/core" + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/ls/lsutil" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestFindAllRefsReExportsUseInImportType(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @Filename: /foo/types/types.ts +[|export type /*full0*/[|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 0 |}Full|] = { prop: string; };|] +// @Filename: /foo/types/index.ts +[|import * as /*foo0*/[|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 2 |}foo|] from './types';|] +[|export { /*foo1*/[|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 4 |}foo|] };|] +// @Filename: /app.ts +[|import { /*foo2*/[|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 6 |}foo|] } from './foo/types';|] +export type fullType = /*foo3*/[|foo|]./*full1*/[|Full|]; +type namespaceImport = typeof import('./foo/types'); +type fullType2 = import('./foo/types')./*foo4*/[|foo|]./*full2*/[|Full|];` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.VerifyNoErrors(t) + f.VerifyBaselineFindAllReferences(t, "full0", "full1", "full2", "foo0", "foo1", "foo2", "foo3", "foo4") + f.VerifyBaselineRename(t, nil /*preferences*/, f.Ranges()[1], f.Ranges()[9], f.Ranges()[11]) + f.VerifyBaselineRename(t, nil /*preferences*/, f.Ranges()[3]) + f.VerifyBaselineRename(t, nil /*preferences*/, f.Ranges()[5], f.Ranges()[10]) + f.VerifyBaselineRename(t, nil /*preferences*/, f.Ranges()[7], f.Ranges()[8]) + f.VerifyBaselineRename(t, &lsutil.UserPreferences{UseAliasesForRename: core.TSFalse}, f.Ranges()[7], f.Ranges()[8], f.Ranges()[10], f.Ranges()[3], f.Ranges()[5]) +} diff --git a/pkg/fourslash/tests/gen/findAllRefsRenameImportWithSameName_test.go b/pkg/fourslash/tests/gen/findAllRefsRenameImportWithSameName_test.go new file mode 100644 index 000000000..450742d6a --- /dev/null +++ b/pkg/fourslash/tests/gen/findAllRefsRenameImportWithSameName_test.go @@ -0,0 +1,24 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestFindAllRefsRenameImportWithSameName(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @Filename: /a.ts +[|export const /*0*/[|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 0 |}x|] = 0;|] +//@Filename: /b.ts +[|import { /*1*/[|{| "contextRangeIndex": 2 |}x|] as /*2*/[|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 2 |}x|] } from "./a";|] +/*3*/[|x|];` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.VerifyNoErrors(t) + f.VerifyBaselineFindAllReferences(t, "0", "1", "2", "3") + f.VerifyBaselineRename(t, nil /*preferences*/, f.Ranges()[1], f.Ranges()[3], f.Ranges()[4], f.Ranges()[5]) +} diff --git a/pkg/fourslash/tests/gen/findAllRefs_importType_js1_test.go b/pkg/fourslash/tests/gen/findAllRefs_importType_js1_test.go new file mode 100644 index 000000000..096467e6a --- /dev/null +++ b/pkg/fourslash/tests/gen/findAllRefs_importType_js1_test.go @@ -0,0 +1,28 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestFindAllRefs_importType_js1(t *testing.T) { + t.Parallel() + t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @allowJs: true +// @checkJs: true +// @Filename: /a.js +module.exports = class /**/C {}; +module.exports.D = class D {}; +// @Filename: /b.js +/** @type {import("./a")} */ +const x = 0; +/** @type {import("./a").D} */ +const y = 0;` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.VerifyNoErrors(t) + f.VerifyBaselineFindAllReferences(t, "") +} diff --git a/pkg/fourslash/tests/gen/findAllRefs_importType_js2_test.go b/pkg/fourslash/tests/gen/findAllRefs_importType_js2_test.go new file mode 100644 index 000000000..763ba941f --- /dev/null +++ b/pkg/fourslash/tests/gen/findAllRefs_importType_js2_test.go @@ -0,0 +1,28 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestFindAllRefs_importType_js2(t *testing.T) { + t.Parallel() + t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @allowJs: true +// @checkJs: true +// @Filename: /a.js +module.exports = class C {}; +module.exports./**/D = class D {}; +// @Filename: /b.js +/** @type {import("./a")} */ +const x = 0; +/** @type {import("./a").D} */ +const y = 0;` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.VerifyNoErrors(t) + f.VerifyBaselineFindAllReferences(t, "") +} diff --git a/pkg/fourslash/tests/gen/findAllRefs_importType_js3_test.go b/pkg/fourslash/tests/gen/findAllRefs_importType_js3_test.go new file mode 100644 index 000000000..a96f19a2a --- /dev/null +++ b/pkg/fourslash/tests/gen/findAllRefs_importType_js3_test.go @@ -0,0 +1,28 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestFindAllRefs_importType_js3(t *testing.T) { + t.Parallel() + t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @allowJs: true +// @checkJs: true +// @Filename: /a.js +module.exports = class C {}; +module.exports.D = class /**/D {}; +// @Filename: /b.js +/** @type {import("./a")} */ +const x = 0; +/** @type {import("./a").D} */ +const y = 0;` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.VerifyNoErrors(t) + f.VerifyBaselineFindAllReferences(t, "") +} diff --git a/pkg/fourslash/tests/gen/findAllRefs_importType_js_test.go b/pkg/fourslash/tests/gen/findAllRefs_importType_js_test.go new file mode 100644 index 000000000..f7a3ccc4a --- /dev/null +++ b/pkg/fourslash/tests/gen/findAllRefs_importType_js_test.go @@ -0,0 +1,28 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestFindAllRefs_importType_js(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @allowJs: true +// @checkJs: true +// @Filename: /a.js +/**/module.exports = class C {}; +module.exports.D = class D {}; +// @Filename: /b.js +/** @type {import("./a")} */ +const x = 0; +/** @type {import("./a").D} */ +const y = 0;` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.VerifyNoErrors(t) + f.VerifyBaselineFindAllReferences(t, "") +} diff --git a/pkg/fourslash/tests/gen/formatAfterWhitespace_test.go b/pkg/fourslash/tests/gen/formatAfterWhitespace_test.go new file mode 100644 index 000000000..c53774f67 --- /dev/null +++ b/pkg/fourslash/tests/gen/formatAfterWhitespace_test.go @@ -0,0 +1,24 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestFormatAfterWhitespace(t *testing.T) { + t.Parallel() + t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `function foo() +{ + var bar; + /*1*/ +}` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.GoToMarker(t, "1") + f.InsertLine(t, "") + f.VerifyCurrentFileContentIs(t, "function foo()\n{\n var bar;\n\n\n}") +} diff --git a/pkg/fourslash/tests/gen/formatAnyTypeLiteral_test.go b/pkg/fourslash/tests/gen/formatAnyTypeLiteral_test.go new file mode 100644 index 000000000..648547513 --- /dev/null +++ b/pkg/fourslash/tests/gen/formatAnyTypeLiteral_test.go @@ -0,0 +1,22 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestFormatAnyTypeLiteral(t *testing.T) { + t.Parallel() + t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `function foo(x: { } /*objLit*/){ +/**/` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.GoToMarker(t, "") + f.Insert(t, "}") + f.GoToMarker(t, "objLit") + f.VerifyCurrentLineContentIs(t, "function foo(x: {}) {") +} diff --git a/pkg/fourslash/tests/gen/formatEmptyBlock_test.go b/pkg/fourslash/tests/gen/formatEmptyBlock_test.go new file mode 100644 index 000000000..35d7bbcfd --- /dev/null +++ b/pkg/fourslash/tests/gen/formatEmptyBlock_test.go @@ -0,0 +1,21 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestFormatEmptyBlock(t *testing.T) { + t.Parallel() + t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `{}` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.GoToEOF(t) + f.Insert(t, "\n") + f.GoToBOF(t) + f.VerifyCurrentLineContentIs(t, "{ }") +} diff --git a/pkg/fourslash/tests/gen/formatEmptyParamList_test.go b/pkg/fourslash/tests/gen/formatEmptyParamList_test.go new file mode 100644 index 000000000..272d885d2 --- /dev/null +++ b/pkg/fourslash/tests/gen/formatEmptyParamList_test.go @@ -0,0 +1,20 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestFormatEmptyParamList(t *testing.T) { + t.Parallel() + t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `function f( f: function){/*1*/` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.GoToMarker(t, "1") + f.Insert(t, "}") + f.VerifyCurrentLineContentIs(t, "function f(f: function) { }") +} diff --git a/pkg/fourslash/tests/gen/formatInTryCatchFinally_test.go b/pkg/fourslash/tests/gen/formatInTryCatchFinally_test.go new file mode 100644 index 000000000..7efa050ab --- /dev/null +++ b/pkg/fourslash/tests/gen/formatInTryCatchFinally_test.go @@ -0,0 +1,26 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestFormatInTryCatchFinally(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `try +{ + var x = 1/*1*/ +} +catch (e) +{ +}` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.GoToMarker(t, "1") + f.Insert(t, ";") + f.VerifyCurrentLineContentIs(t, " var x = 1;") +} diff --git a/pkg/fourslash/tests/gen/formatOnEnterFunctionDeclaration_test.go b/pkg/fourslash/tests/gen/formatOnEnterFunctionDeclaration_test.go new file mode 100644 index 000000000..12401b920 --- /dev/null +++ b/pkg/fourslash/tests/gen/formatOnEnterFunctionDeclaration_test.go @@ -0,0 +1,21 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestFormatOnEnterFunctionDeclaration(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `/*0*/function listAPIFiles(path: string): string[] {/*1*/ }` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.GoToMarker(t, "1") + f.InsertLine(t, "") + f.GoToMarker(t, "0") + f.VerifyCurrentLineContentIs(t, "function listAPIFiles(path: string): string[] {") +} diff --git a/pkg/fourslash/tests/gen/formatOnEnterInComment_test.go b/pkg/fourslash/tests/gen/formatOnEnterInComment_test.go new file mode 100644 index 000000000..159242a97 --- /dev/null +++ b/pkg/fourslash/tests/gen/formatOnEnterInComment_test.go @@ -0,0 +1,22 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestFormatOnEnterInComment(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = ` /** + * /*1*/ + */` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.GoToMarker(t, "1") + f.InsertLine(t, "") + f.VerifyCurrentFileContentIs(t, " /**\n * \n\n */") +} diff --git a/pkg/fourslash/tests/gen/formatOnSemiColonAfterBreak_test.go b/pkg/fourslash/tests/gen/formatOnSemiColonAfterBreak_test.go new file mode 100644 index 000000000..2a45b2be6 --- /dev/null +++ b/pkg/fourslash/tests/gen/formatOnSemiColonAfterBreak_test.go @@ -0,0 +1,22 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestFormatOnSemiColonAfterBreak(t *testing.T) { + t.Parallel() + t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `for (var a in b) { +break/**/ +}` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.GoToMarker(t, "") + f.Insert(t, ";") + f.VerifyCurrentLineContentIs(t, " break;") +} diff --git a/pkg/fourslash/tests/gen/formatonkey01_test.go b/pkg/fourslash/tests/gen/formatonkey01_test.go new file mode 100644 index 000000000..629386d57 --- /dev/null +++ b/pkg/fourslash/tests/gen/formatonkey01_test.go @@ -0,0 +1,26 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestFormatonkey01(t *testing.T) { + t.Parallel() + t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `switch (1) { + case 1: + { + /*1*/ + break; +}` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.MarkTestAsStradaServer() + f.GoToMarker(t, "1") + f.Insert(t, "}") + f.VerifyCurrentLineContentIs(t, " }") +} diff --git a/pkg/fourslash/tests/gen/formattingAfterMultiLineIfCondition_test.go b/pkg/fourslash/tests/gen/formattingAfterMultiLineIfCondition_test.go new file mode 100644 index 000000000..9af7e256d --- /dev/null +++ b/pkg/fourslash/tests/gen/formattingAfterMultiLineIfCondition_test.go @@ -0,0 +1,26 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestFormattingAfterMultiLineIfCondition(t *testing.T) { + t.Parallel() + t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = ` var foo; + if (foo && + foo) { +/*comment*/ // This is a comment + foo.toString(); + /**/` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.GoToMarker(t, "") + f.Insert(t, "}") + f.GoToMarker(t, "comment") + f.VerifyCurrentLineContentIs(t, " // This is a comment") +} diff --git a/pkg/fourslash/tests/gen/formattingAfterMultiLineString_test.go b/pkg/fourslash/tests/gen/formattingAfterMultiLineString_test.go new file mode 100644 index 000000000..3ad262ae1 --- /dev/null +++ b/pkg/fourslash/tests/gen/formattingAfterMultiLineString_test.go @@ -0,0 +1,26 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestFormattingAfterMultiLineString(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `class foo { + stop() { + var s = "hello\/*1*/ +"/*2*/ + } +}` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.GoToMarker(t, "2") + f.InsertLine(t, "") + f.GoToMarker(t, "1") + f.VerifyCurrentLineContentIs(t, " var s = \"hello\\") +} diff --git a/pkg/fourslash/tests/gen/formattingBlockInCaseClauses_test.go b/pkg/fourslash/tests/gen/formattingBlockInCaseClauses_test.go new file mode 100644 index 000000000..487fefa69 --- /dev/null +++ b/pkg/fourslash/tests/gen/formattingBlockInCaseClauses_test.go @@ -0,0 +1,25 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestFormattingBlockInCaseClauses(t *testing.T) { + t.Parallel() + t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `switch (1) { + case 1: + { + /*1*/ + break; +}` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.GoToMarker(t, "1") + f.Insert(t, "}") + f.VerifyCurrentLineContentIs(t, " }") +} diff --git a/pkg/fourslash/tests/gen/formattingCommentsBeforeErrors_test.go b/pkg/fourslash/tests/gen/formattingCommentsBeforeErrors_test.go new file mode 100644 index 000000000..41c630cbb --- /dev/null +++ b/pkg/fourslash/tests/gen/formattingCommentsBeforeErrors_test.go @@ -0,0 +1,33 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestFormattingCommentsBeforeErrors(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `module A { + interface B { + // a + // b + baz(); +/*0*/ // d /*1*/asd a + // e + foo(); + // f asd + // g as + bar(); + } +}` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.GoToMarker(t, "1") + f.Insert(t, "\n") + f.GoToMarker(t, "0") + f.VerifyCurrentLineContentIs(t, " // d ") +} diff --git a/pkg/fourslash/tests/gen/formattingElseInsideAFunction_test.go b/pkg/fourslash/tests/gen/formattingElseInsideAFunction_test.go new file mode 100644 index 000000000..7372bfba5 --- /dev/null +++ b/pkg/fourslash/tests/gen/formattingElseInsideAFunction_test.go @@ -0,0 +1,26 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestFormattingElseInsideAFunction(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `var x = function() { + if (true) { + /*1*/} else {/*2*/ +} + +// newline at the end of the file` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.GoToMarker(t, "2") + f.InsertLine(t, "") + f.GoToMarker(t, "1") + f.VerifyCurrentLineContentIs(t, " } else {") +} diff --git a/pkg/fourslash/tests/gen/formattingEqualsBeforeBracketInTypeAlias_test.go b/pkg/fourslash/tests/gen/formattingEqualsBeforeBracketInTypeAlias_test.go new file mode 100644 index 000000000..6fd9f3f75 --- /dev/null +++ b/pkg/fourslash/tests/gen/formattingEqualsBeforeBracketInTypeAlias_test.go @@ -0,0 +1,20 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestFormattingEqualsBeforeBracketInTypeAlias(t *testing.T) { + t.Parallel() + t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `type X = [number]/*1*/` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.GoToMarker(t, "1") + f.Insert(t, ";") + f.VerifyCurrentLineContentIs(t, "type X = [number];") +} diff --git a/pkg/fourslash/tests/gen/formattingExpressionsInIfCondition_test.go b/pkg/fourslash/tests/gen/formattingExpressionsInIfCondition_test.go new file mode 100644 index 000000000..c16b8a85c --- /dev/null +++ b/pkg/fourslash/tests/gen/formattingExpressionsInIfCondition_test.go @@ -0,0 +1,24 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestFormattingExpressionsInIfCondition(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `if (a === 1 || + /*0*/b === 2 ||/*1*/ + c === 3) { +}` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.GoToMarker(t, "1") + f.Insert(t, "\n") + f.GoToMarker(t, "0") + f.VerifyCurrentLineContentIs(t, " b === 2 ||") +} diff --git a/pkg/fourslash/tests/gen/formattingIfInElseBlock_test.go b/pkg/fourslash/tests/gen/formattingIfInElseBlock_test.go new file mode 100644 index 000000000..2a41b6bee --- /dev/null +++ b/pkg/fourslash/tests/gen/formattingIfInElseBlock_test.go @@ -0,0 +1,25 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestFormattingIfInElseBlock(t *testing.T) { + t.Parallel() + t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `if (true) { +} +else { + if (true) { + /*1*/ +}` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.GoToMarker(t, "1") + f.Insert(t, "}") + f.VerifyCurrentLineContentIs(t, " }") +} diff --git a/pkg/fourslash/tests/gen/formattingInComment_test.go b/pkg/fourslash/tests/gen/formattingInComment_test.go new file mode 100644 index 000000000..0ccc0aafb --- /dev/null +++ b/pkg/fourslash/tests/gen/formattingInComment_test.go @@ -0,0 +1,26 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestFormattingInComment(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `class A { +foo( ); // /*1*/ +} +function foo() { var x; } // /*2*/` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.GoToMarker(t, "1") + f.Insert(t, ";") + f.VerifyCurrentLineContentIs(t, "foo( ); // ;") + f.GoToMarker(t, "2") + f.Insert(t, "}") + f.VerifyCurrentLineContentIs(t, "function foo() { var x; } // }") +} diff --git a/pkg/fourslash/tests/gen/formattingInExpressionsInTsx_test.go b/pkg/fourslash/tests/gen/formattingInExpressionsInTsx_test.go new file mode 100644 index 000000000..d9bb6a547 --- /dev/null +++ b/pkg/fourslash/tests/gen/formattingInExpressionsInTsx_test.go @@ -0,0 +1,27 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestFormattingInExpressionsInTsx(t *testing.T) { + t.Parallel() + t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @Filename: test.tsx +import * as React from "react"; +
+
` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.GoToMarker(t, "1") + f.Insert(t, ";") + f.VerifyCurrentLineContentIs(t, " return true;") +} diff --git a/pkg/fourslash/tests/gen/formattingInMultilineComments_test.go b/pkg/fourslash/tests/gen/formattingInMultilineComments_test.go new file mode 100644 index 000000000..8fc190de1 --- /dev/null +++ b/pkg/fourslash/tests/gen/formattingInMultilineComments_test.go @@ -0,0 +1,26 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestFormattingInMultilineComments(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `var x = function() { + if (true) { + /*1*/} else {/*2*/ +} + +// newline at the end of the file` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.GoToMarker(t, "2") + f.InsertLine(t, "") + f.GoToMarker(t, "1") + f.VerifyCurrentLineContentIs(t, " } else {") +} diff --git a/pkg/fourslash/tests/gen/formattingKeywordAsIdentifier_test.go b/pkg/fourslash/tests/gen/formattingKeywordAsIdentifier_test.go new file mode 100644 index 000000000..5259b6a76 --- /dev/null +++ b/pkg/fourslash/tests/gen/formattingKeywordAsIdentifier_test.go @@ -0,0 +1,20 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestFormattingKeywordAsIdentifier(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `declare var module/*1*/` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.GoToMarker(t, "1") + f.Insert(t, ";") + f.VerifyCurrentLineContentIs(t, "declare var module;") +} diff --git a/pkg/fourslash/tests/gen/formattingOfChainedLambda_test.go b/pkg/fourslash/tests/gen/formattingOfChainedLambda_test.go new file mode 100644 index 000000000..289c74ccc --- /dev/null +++ b/pkg/fourslash/tests/gen/formattingOfChainedLambda_test.go @@ -0,0 +1,20 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestFormattingOfChainedLambda(t *testing.T) { + t.Parallel() + t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `var fn = (x: string) => ()=> alert(x)/**/` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.GoToMarker(t, "") + f.Insert(t, ";") + f.VerifyCurrentLineContentIs(t, "var fn = (x: string) => () => alert(x);") +} diff --git a/pkg/fourslash/tests/gen/formattingOnCloseBrace_test.go b/pkg/fourslash/tests/gen/formattingOnCloseBrace_test.go new file mode 100644 index 000000000..c0e2045c8 --- /dev/null +++ b/pkg/fourslash/tests/gen/formattingOnCloseBrace_test.go @@ -0,0 +1,22 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestFormattingOnCloseBrace(t *testing.T) { + t.Parallel() + t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `class foo { + /**/` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.GoToMarker(t, "") + f.Insert(t, "}") + f.GoToBOF(t) + f.VerifyCurrentLineContentIs(t, "class foo {") +} diff --git a/pkg/fourslash/tests/gen/formattingOnDoWhileNoSemicolon_test.go b/pkg/fourslash/tests/gen/formattingOnDoWhileNoSemicolon_test.go new file mode 100644 index 000000000..d5c08f42d --- /dev/null +++ b/pkg/fourslash/tests/gen/formattingOnDoWhileNoSemicolon_test.go @@ -0,0 +1,31 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestFormattingOnDoWhileNoSemicolon(t *testing.T) { + t.Parallel() + t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `/*2*/do { +/*3*/ for (var i = 0; i < 10; i++) +/*4*/ i -= 2 +/*5*/ }/*1*/while (1 !== 1)` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.GoToMarker(t, "1") + f.Insert(t, "\n") + f.VerifyCurrentLineContentIs(t, "while (1 !== 1)") + f.GoToMarker(t, "2") + f.VerifyCurrentLineContentIs(t, "do {") + f.GoToMarker(t, "3") + f.VerifyCurrentLineContentIs(t, " for (var i = 0; i < 10; i++)") + f.GoToMarker(t, "4") + f.VerifyCurrentLineContentIs(t, " i -= 2") + f.GoToMarker(t, "5") + f.VerifyCurrentLineContentIs(t, "}") +} diff --git a/pkg/fourslash/tests/gen/formattingOnEnterInComments_test.go b/pkg/fourslash/tests/gen/formattingOnEnterInComments_test.go new file mode 100644 index 000000000..d8b0b284b --- /dev/null +++ b/pkg/fourslash/tests/gen/formattingOnEnterInComments_test.go @@ -0,0 +1,26 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestFormattingOnEnterInComments(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `module me { + class A { + /* + */*1*/ + /*2*/} +}` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.GoToMarker(t, "1") + f.InsertLine(t, "") + f.GoToMarker(t, "2") + f.VerifyCurrentLineContentIs(t, " }") +} diff --git a/pkg/fourslash/tests/gen/formattingOnEnterInStrings_test.go b/pkg/fourslash/tests/gen/formattingOnEnterInStrings_test.go new file mode 100644 index 000000000..2c51df339 --- /dev/null +++ b/pkg/fourslash/tests/gen/formattingOnEnterInStrings_test.go @@ -0,0 +1,22 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestFormattingOnEnterInStrings(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `var x = /*1*/"unclosed string literal\/*2*/` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.GoToMarker(t, "2") + f.InsertLine(t, "") + f.InsertLine(t, "") + f.GoToMarker(t, "1") + f.VerifyCurrentLineContentIs(t, "var x = \"unclosed string literal\\") +} diff --git a/pkg/fourslash/tests/gen/formattingOnEnter_test.go b/pkg/fourslash/tests/gen/formattingOnEnter_test.go new file mode 100644 index 000000000..9a8ec7c31 --- /dev/null +++ b/pkg/fourslash/tests/gen/formattingOnEnter_test.go @@ -0,0 +1,22 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestFormattingOnEnter(t *testing.T) { + t.Parallel() + t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `class foo { } +class bar {/**/ } +// new line here` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.GoToMarker(t, "") + f.InsertLine(t, "") + f.VerifyCurrentFileContentIs(t, "class foo { }\nclass bar {\n}\n// new line here") +} diff --git a/pkg/fourslash/tests/gen/formattingOnNestedDoWhileByEnter_test.go b/pkg/fourslash/tests/gen/formattingOnNestedDoWhileByEnter_test.go new file mode 100644 index 000000000..7626b5b85 --- /dev/null +++ b/pkg/fourslash/tests/gen/formattingOnNestedDoWhileByEnter_test.go @@ -0,0 +1,37 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestFormattingOnNestedDoWhileByEnter(t *testing.T) { + t.Parallel() + t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `/*2*/do{ +/*3*/do/*1*/{ +/*4*/do{ +/*5*/}while(a!==b) +/*6*/}while(a!==b) +/*7*/}while(a!==b)` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.GoToMarker(t, "1") + f.Insert(t, "\n") + f.VerifyCurrentLineContentIs(t, " {") + f.GoToMarker(t, "2") + f.VerifyCurrentLineContentIs(t, "do{") + f.GoToMarker(t, "3") + f.VerifyCurrentLineContentIs(t, " do") + f.GoToMarker(t, "4") + f.VerifyCurrentLineContentIs(t, "do{") + f.GoToMarker(t, "5") + f.VerifyCurrentLineContentIs(t, "}while(a!==b)") + f.GoToMarker(t, "6") + f.VerifyCurrentLineContentIs(t, "}while(a!==b)") + f.GoToMarker(t, "7") + f.VerifyCurrentLineContentIs(t, "}while(a!==b)") +} diff --git a/pkg/fourslash/tests/gen/formattingOnSemiColon_test.go b/pkg/fourslash/tests/gen/formattingOnSemiColon_test.go new file mode 100644 index 000000000..fda721a7c --- /dev/null +++ b/pkg/fourslash/tests/gen/formattingOnSemiColon_test.go @@ -0,0 +1,20 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestFormattingOnSemiColon(t *testing.T) { + t.Parallel() + t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `var a=b+c^d-e*++f` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.GoToEOF(t) + f.Insert(t, ";") + f.VerifyCurrentFileContentIs(t, "var a = b + c ^ d - e * ++f;") +} diff --git a/pkg/fourslash/tests/gen/formattingRegexes_test.go b/pkg/fourslash/tests/gen/formattingRegexes_test.go new file mode 100644 index 000000000..61807a203 --- /dev/null +++ b/pkg/fourslash/tests/gen/formattingRegexes_test.go @@ -0,0 +1,20 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestFormattingRegexes(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `removeAllButLast(sortedTypes, undefinedType, /keepNullableType**/ true)/*1*/` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.GoToMarker(t, "1") + f.Insert(t, ";") + f.VerifyCurrentLineContentIs(t, "removeAllButLast(sortedTypes, undefinedType, /keepNullableType**/ true);") +} diff --git a/pkg/fourslash/tests/gen/formattingSpaceAfterCommaBeforeOpenParen_test.go b/pkg/fourslash/tests/gen/formattingSpaceAfterCommaBeforeOpenParen_test.go new file mode 100644 index 000000000..2c050246e --- /dev/null +++ b/pkg/fourslash/tests/gen/formattingSpaceAfterCommaBeforeOpenParen_test.go @@ -0,0 +1,24 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestFormattingSpaceAfterCommaBeforeOpenParen(t *testing.T) { + t.Parallel() + t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `foo(a,(b))/*1*/ +foo(a,(c).d)/*2*/` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.GoToMarker(t, "1") + f.Insert(t, ";") + f.VerifyCurrentLineContentIs(t, "foo(a, (b));") + f.GoToMarker(t, "2") + f.Insert(t, ";") + f.VerifyCurrentLineContentIs(t, "foo(a, (c).d);") +} diff --git a/pkg/fourslash/tests/gen/formattingTemplatesWithNewline_test.go b/pkg/fourslash/tests/gen/formattingTemplatesWithNewline_test.go new file mode 100644 index 000000000..47b110d20 --- /dev/null +++ b/pkg/fourslash/tests/gen/formattingTemplatesWithNewline_test.go @@ -0,0 +1,22 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestFormattingTemplatesWithNewline(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `` + "`" + `${1}` + "`" + `; +` + "`" + ` +` + "`" + `;/**/1` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.GoToMarker(t, "") + f.Insert(t, "\n") + f.VerifyCurrentLineContentIs(t, "1") +} diff --git a/pkg/fourslash/tests/gen/formattingTemplates_test.go b/pkg/fourslash/tests/gen/formattingTemplates_test.go new file mode 100644 index 000000000..c754f57e6 --- /dev/null +++ b/pkg/fourslash/tests/gen/formattingTemplates_test.go @@ -0,0 +1,24 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestFormattingTemplates(t *testing.T) { + t.Parallel() + t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `String.call ` + "`" + `${123}` + "`" + `/*1*/ +String.call ` + "`" + `${123} ${456}` + "`" + `/*2*/` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.GoToMarker(t, "1") + f.Insert(t, ";") + f.VerifyCurrentLineContentIs(t, "String.call`${123}`;") + f.GoToMarker(t, "2") + f.Insert(t, ";") + f.VerifyCurrentLineContentIs(t, "String.call`${123} ${456}`;") +} diff --git a/pkg/fourslash/tests/gen/formattingWithMultilineComments_test.go b/pkg/fourslash/tests/gen/formattingWithMultilineComments_test.go new file mode 100644 index 000000000..5c3be4926 --- /dev/null +++ b/pkg/fourslash/tests/gen/formattingWithMultilineComments_test.go @@ -0,0 +1,22 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestFormattingWithMultilineComments(t *testing.T) { + t.Parallel() + t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `f(/* +/*2*/ */() => { /*1*/ });` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.GoToMarker(t, "1") + f.InsertLine(t, "") + f.GoToMarker(t, "2") + f.VerifyCurrentLineContentIs(t, " */() => {") +} diff --git a/pkg/fourslash/tests/gen/functionTypeFormatting_test.go b/pkg/fourslash/tests/gen/functionTypeFormatting_test.go new file mode 100644 index 000000000..d2f244a97 --- /dev/null +++ b/pkg/fourslash/tests/gen/functionTypeFormatting_test.go @@ -0,0 +1,20 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestFunctionTypeFormatting(t *testing.T) { + t.Parallel() + t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `var x: () => string/**/` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.GoToMarker(t, "") + f.Insert(t, ";") + f.VerifyCurrentLineContentIs(t, "var x: () => string;") +} diff --git a/pkg/fourslash/tests/gen/functionTypes_test.go b/pkg/fourslash/tests/gen/functionTypes_test.go new file mode 100644 index 000000000..04a2abf5b --- /dev/null +++ b/pkg/fourslash/tests/gen/functionTypes_test.go @@ -0,0 +1,60 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + . "github.com/buke/typescript-go-internal/pkg/fourslash/tests/util" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestFunctionTypes(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `var f: Function; +function g() { } + +class C { + h: () => void ; + i(): number { return 5; } + static j = (e) => e; + static k() { return 'hi';} +} +var l = () => void 0; +var z = new C; + +f./*1*/apply(this, [1]); +g./*2*/arguments; +z.h./*3*/bind(undefined, 1, 2); +z.i./*4*/call(null) +C.j./*5*/length === 1; +typeof C.k./*6*/caller === 'function'; +l./*7*/prototype = Object.prototype;` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.VerifyNoErrors(t) + f.VerifyCompletions(t, []string{"1", "2", "3", "4", "5", "6"}, &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Exact: CompletionFunctionMembersWithPrototype, + }, + }) + f.VerifyCompletions(t, "7", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Exact: CompletionFunctionMembersPlus( + []fourslash.CompletionsExpectedItem{ + "prototype", + }), + }, + }) +} diff --git a/pkg/fourslash/tests/gen/funduleWithRecursiveReference_test.go b/pkg/fourslash/tests/gen/funduleWithRecursiveReference_test.go new file mode 100644 index 000000000..3bd2e3d40 --- /dev/null +++ b/pkg/fourslash/tests/gen/funduleWithRecursiveReference_test.go @@ -0,0 +1,24 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestFunduleWithRecursiveReference(t *testing.T) { + t.Parallel() + t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `module M { + export function C() {} + export module C { + export var /**/C = M.C + } +}` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.VerifyQuickInfoAt(t, "", "var M.C.C: typeof M.C", "") + f.VerifyNoErrors(t) +} diff --git a/pkg/fourslash/tests/gen/genericArityEnforcementAfterEdit_test.go b/pkg/fourslash/tests/gen/genericArityEnforcementAfterEdit_test.go new file mode 100644 index 000000000..8010ea0ad --- /dev/null +++ b/pkg/fourslash/tests/gen/genericArityEnforcementAfterEdit_test.go @@ -0,0 +1,23 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestGenericArityEnforcementAfterEdit(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `interface G { } +/**/ +var v4: G, any>;` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.VerifyNumberOfErrorsInCurrentFile(t, 1) + f.GoToMarker(t, "") + f.Insert(t, " ") + f.VerifyNumberOfErrorsInCurrentFile(t, 1) +} diff --git a/pkg/fourslash/tests/gen/genericAssignmentCompat_test.go b/pkg/fourslash/tests/gen/genericAssignmentCompat_test.go new file mode 100644 index 000000000..51a3580f2 --- /dev/null +++ b/pkg/fourslash/tests/gen/genericAssignmentCompat_test.go @@ -0,0 +1,27 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestGenericAssignmentCompat(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `interface Int { + + val(f: (t: T) => U): Int; + +} + +declare var v1: Int; + +var /*1*/v2/*2*/: Int = v1;` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.VerifyErrorExistsBetweenMarkers(t, "1", "2") + f.VerifyNumberOfErrorsInCurrentFile(t, 1) +} diff --git a/pkg/fourslash/tests/gen/genericCombinators1_test.go b/pkg/fourslash/tests/gen/genericCombinators1_test.go new file mode 100644 index 000000000..6f35760f4 --- /dev/null +++ b/pkg/fourslash/tests/gen/genericCombinators1_test.go @@ -0,0 +1,76 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestGenericCombinators1(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `interface Collection { + length: number; + add(x: T): void; + remove(x: T): boolean; +} +interface Combinators { + map(c: Collection, f: (x: T) => U): Collection; + map(c: Collection, f: (x: T) => any): Collection; +} +class A { + foo() { return this; } +} +class B { + foo(x: T): T { return null; } +} +var c2: Collection; +var c3: Collection>; +var c4: Collection; +var c5: Collection>; +var _: Combinators; +var rf1 = (x: number) => { return x.toFixed() }; +var rf2 = (x: Collection) => { return x.length }; +var rf3 = (x: A) => { return x.foo() }; +var /*9*/r1a = _.map(c2, (/*1*/x) => { return x.toFixed() }); +var /*10*/r1b = _.map(c2, rf1); +var /*11*/r2a = _.map(c3, (/*2*/x: Collection) => { return x.length }); +var /*12*/r2b = _.map(c3, rf2); +var /*13*/r3a = _.map(c4, (/*3*/x) => { return x.foo() }); +var /*14*/r3b = _.map(c4, rf3); +var /*15*/r4a = _.map(c5, (/*4*/x) => { return x.foo(1) }); +var /*17*/r5a = _.map(c2, (/*5*/x) => { return x.toFixed() }); +var /*18*/r5b = _.map(c2, rf1); +var /*19*/r6a = _.map, number>(/*6*/c3, (x: Collection) => { return x.length }); +var /*20*/r6b = _.map, number>(c3, rf2); +var /*21*/r7a = _.map(c4, (/*7*/x: A) => { return x.foo() }); +var /*22*/r7b = _.map(c4, rf3); +var /*23*/r8a = _.map(c5, (/*8*/x) => { return x.foo() });` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.VerifyQuickInfoAt(t, "1", "(parameter) x: number", "") + f.VerifyQuickInfoAt(t, "2", "(parameter) x: Collection", "") + f.VerifyQuickInfoAt(t, "3", "(parameter) x: A", "") + f.VerifyQuickInfoAt(t, "4", "(parameter) x: B", "") + f.VerifyQuickInfoAt(t, "5", "(parameter) x: number", "") + f.VerifyQuickInfoAt(t, "6", "var c3: Collection>", "") + f.VerifyQuickInfoAt(t, "7", "(parameter) x: A", "") + f.VerifyQuickInfoAt(t, "8", "(parameter) x: any", "") + f.VerifyQuickInfoAt(t, "9", "var r1a: Collection", "") + f.VerifyQuickInfoAt(t, "10", "var r1b: Collection", "") + f.VerifyQuickInfoAt(t, "11", "var r2a: Collection", "") + f.VerifyQuickInfoAt(t, "12", "var r2b: Collection", "") + f.VerifyQuickInfoAt(t, "13", "var r3a: Collection", "") + f.VerifyQuickInfoAt(t, "14", "var r3b: Collection", "") + f.VerifyQuickInfoAt(t, "15", "var r4a: Collection", "") + f.VerifyQuickInfoAt(t, "17", "var r5a: Collection", "") + f.VerifyQuickInfoAt(t, "18", "var r5b: Collection", "") + f.VerifyQuickInfoAt(t, "19", "var r6a: Collection", "") + f.VerifyQuickInfoAt(t, "20", "var r6b: Collection", "") + f.VerifyQuickInfoAt(t, "21", "var r7a: Collection", "") + f.VerifyQuickInfoAt(t, "22", "var r7b: Collection", "") + f.VerifyQuickInfoAt(t, "23", "var r8a: Collection", "") + f.VerifyErrorExistsBetweenMarkers(t, "error1", "error2") +} diff --git a/pkg/fourslash/tests/gen/genericInterfacePropertyInference1_test.go b/pkg/fourslash/tests/gen/genericInterfacePropertyInference1_test.go new file mode 100644 index 000000000..75f44f143 --- /dev/null +++ b/pkg/fourslash/tests/gen/genericInterfacePropertyInference1_test.go @@ -0,0 +1,148 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestGenericInterfacePropertyInference1(t *testing.T) { + t.Parallel() + t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `interface I { + x: number; +} + +var anInterface: I; +interface IG { + x: T; +} +var aGenericInterface: IG; + +class C implements IG { + x: T; +} + +interface Foo { + prim1: number; + prim2: string; + ofT: T; + ofFooNum: Foo; + ofInterface: I; + ofIG4: { x: number }; + ofIG6: { x: T }; + ofC2: C; + ofC4: C<{ x: T }> +} + +var f: Foo; +var f2: Foo; +var f3: Foo; +var f4: Foo<{ x: number }>; +var f5: Foo>; + +// T is any +var f_/*a1*/r1 = f.prim1; +var f_/*a2*/r2 = f.prim2; +var f_/*a3*/r3 = f.ofT; +var f_/*a4*/r5 = f.ofFooNum; +var f_/*a5*/r8 = f.ofInterface; +var f_/*a6*/r12 = f.ofIG4; +var f_/*a7*/r14 = f.ofIG6; +var f_/*a8*/r18 = f.ofC2; +var f_/*a9*/r20 = f.ofC4; + +// T is number +var f2_/*b1*/r1 = f2.prim1; +var f2_/*b2*/r2 = f2.prim2; +var f2_/*b3*/r3 = f2.ofT; +var f2_/*b4*/r5 = f2.ofFooNum; +var f2_/*b5*/r8 = f2.ofInterface; +var f2_/*b6*/r12 = f2.ofIG4; +var f2_/*b7*/r14 = f2.ofIG6; +var f2_/*b8*/r18 = f2.ofC2; +var f2_/*b9*/r20 = f2.ofC4; + +// T is I +var f3_/*c1*/r1 = f3.prim1; +var f3_/*c2*/r2 = f3.prim2; +var f3_/*c3*/r3 = f3.ofT; +var f3_/*c4*/r5 = f3.ofFooNum; +var f3_/*c5*/r8 = f3.ofInterface; +var f3_/*c6*/r12 = f3.ofIG4; +var f3_/*c7*/r14 = f3.ofIG6; +var f3_/*c8*/r18 = f3.ofC2; +var f3_/*c9*/r20 = f3.ofC4; + +// T is {x: number} +var f4_/*d1*/r1 = f4.prim1; +var f4_/*d2*/r2 = f4.prim2; +var f4_/*d3*/r3 = f4.ofT; +var f4_/*d4*/r5 = f4.ofFooNum; +var f4_/*d5*/r8 = f4.ofInterface; +var f4_/*d6*/r12 = f4.ofIG4; +var f4_/*d7*/r14 = f4.ofIG6; +var f4_/*d8*/r18 = f4.ofC2; +var f4_/*d9*/r20 = f4.ofC4; + +// T is Foo +var f5_/*e1*/r1 = f5.prim1; +var f5_/*e2*/r2 = f5.prim2; +var f5_/*e3*/r3 = f5.ofT; +var f5_/*e4*/r5 = f5.ofFooNum; +var f5_/*e5*/r8 = f5.ofInterface; +var f5_/*e6*/r12 = f5.ofIG4; +var f5_/*e7*/r14 = f5.ofIG6; +var f5_/*e8*/r18 = f5.ofC2; +var f5_/*e9*/r20 = f5.ofC4;` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.VerifyNoErrors(t) + f.VerifyQuickInfoAt(t, "a1", "var f_r1: number", "") + f.VerifyQuickInfoAt(t, "a2", "var f_r2: string", "") + f.VerifyQuickInfoAt(t, "a3", "var f_r3: any", "") + f.VerifyQuickInfoAt(t, "a4", "var f_r5: Foo", "") + f.VerifyQuickInfoAt(t, "a5", "var f_r8: I", "") + f.VerifyQuickInfoAt(t, "a6", "var f_r12: {\n x: number;\n}", "") + f.VerifyQuickInfoAt(t, "a7", "var f_r14: {\n x: any;\n}", "") + f.VerifyQuickInfoAt(t, "a8", "var f_r18: C", "") + f.VerifyQuickInfoAt(t, "a9", "var f_r20: C<{\n x: any;\n}>", "") + f.VerifyQuickInfoAt(t, "b1", "var f2_r1: number", "") + f.VerifyQuickInfoAt(t, "b2", "var f2_r2: string", "") + f.VerifyQuickInfoAt(t, "b3", "var f2_r3: number", "") + f.VerifyQuickInfoAt(t, "b4", "var f2_r5: Foo", "") + f.VerifyQuickInfoAt(t, "b5", "var f2_r8: I", "") + f.VerifyQuickInfoAt(t, "b6", "var f2_r12: {\n x: number;\n}", "") + f.VerifyQuickInfoAt(t, "b7", "var f2_r14: {\n x: number;\n}", "") + f.VerifyQuickInfoAt(t, "b8", "var f2_r18: C", "") + f.VerifyQuickInfoAt(t, "b9", "var f2_r20: C<{\n x: number;\n}>", "") + f.VerifyQuickInfoAt(t, "c1", "var f3_r1: number", "") + f.VerifyQuickInfoAt(t, "c2", "var f3_r2: string", "") + f.VerifyQuickInfoAt(t, "c3", "var f3_r3: I", "") + f.VerifyQuickInfoAt(t, "c4", "var f3_r5: Foo", "") + f.VerifyQuickInfoAt(t, "c5", "var f3_r8: I", "") + f.VerifyQuickInfoAt(t, "c6", "var f3_r12: {\n x: number;\n}", "") + f.VerifyQuickInfoAt(t, "c7", "var f3_r14: {\n x: I;\n}", "") + f.VerifyQuickInfoAt(t, "c8", "var f3_r18: C", "") + f.VerifyQuickInfoAt(t, "c9", "var f3_r20: C<{\n x: I;\n}>", "") + f.VerifyQuickInfoAt(t, "d1", "var f4_r1: number", "") + f.VerifyQuickInfoAt(t, "d2", "var f4_r2: string", "") + f.VerifyQuickInfoAt(t, "d3", "var f4_r3: {\n x: number;\n}", "") + f.VerifyQuickInfoAt(t, "d4", "var f4_r5: Foo", "") + f.VerifyQuickInfoAt(t, "d5", "var f4_r8: I", "") + f.VerifyQuickInfoAt(t, "d6", "var f4_r12: {\n x: number;\n}", "") + f.VerifyQuickInfoAt(t, "d7", "var f4_r14: {\n x: {\n x: number;\n };\n}", "") + f.VerifyQuickInfoAt(t, "d8", "var f4_r18: C", "") + f.VerifyQuickInfoAt(t, "d9", "var f4_r20: C<{\n x: {\n x: number;\n };\n}>", "") + f.VerifyQuickInfoAt(t, "e1", "var f5_r1: number", "") + f.VerifyQuickInfoAt(t, "e2", "var f5_r2: string", "") + f.VerifyQuickInfoAt(t, "e3", "var f5_r3: Foo", "") + f.VerifyQuickInfoAt(t, "e4", "var f5_r5: Foo", "") + f.VerifyQuickInfoAt(t, "e5", "var f5_r8: I", "") + f.VerifyQuickInfoAt(t, "e6", "var f5_r12: {\n x: number;\n}", "") + f.VerifyQuickInfoAt(t, "e7", "var f5_r14: {\n x: Foo;\n}", "") + f.VerifyQuickInfoAt(t, "e8", "var f5_r18: C", "") + f.VerifyQuickInfoAt(t, "e9", "var f5_r20: C<{\n x: Foo;\n}>", "") +} diff --git a/pkg/fourslash/tests/gen/genericInterfacePropertyInference2_test.go b/pkg/fourslash/tests/gen/genericInterfacePropertyInference2_test.go new file mode 100644 index 000000000..bfcc221a4 --- /dev/null +++ b/pkg/fourslash/tests/gen/genericInterfacePropertyInference2_test.go @@ -0,0 +1,104 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestGenericInterfacePropertyInference2(t *testing.T) { + t.Parallel() + t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `interface I { + x: number; +} + +var anInterface: I; +interface IG { + x: T; +} +var aGenericInterface: IG; + +class C implements IG { + x: T; +} + +interface Foo { + ofFooT: Foo; + ofFooFooNum: Foo>; // should be error? + ofIG: IG; + ofIG5: { x: Foo; }; // same as ofIG3 + ofC1: C; +} + +var f: Foo; +var f2: Foo; +var f3: Foo; +var f4: Foo<{ x: number }>; +var f5: Foo>; + +// T is any +var f_/*a1*/r4 = f.ofFooT; +var f_/*a2*/r7 = f.ofFooFooNum; +var f_/*a3*/r9 = f.ofIG; +var f_/*a5*/r13 = f.ofIG5; +var f_/*a7*/r17 = f.ofC1; + +// T is number +var f2_/*b1*/r4 = f2.ofFooT; +var f2_/*b2*/r7 = f2.ofFooFooNum; +var f2_/*b3*/r9 = f2.ofIG; +var f2_/*b5*/r13 = f2.ofIG5; +var f2_/*b7*/r17 = f2.ofC1; + +// T is I} +var f3_/*c1*/r4 = f3.ofFooT; +var f3_/*c2*/r7 = f3.ofFooFooNum; +var f3_/*c3*/r9 = f3.ofIG; +var f3_/*c5*/r13 = f3.ofIG5; +var f3_/*c7*/r17 = f3.ofC1; + +// T is {x: number} +var f4_/*d1*/r4 = f4.ofFooT; +var f4_/*d2*/r7 = f4.ofFooFooNum; +var f4_/*d3*/r9 = f4.ofIG; +var f4_/*d5*/r13 = f4.ofIG5; +var f4_/*d7*/r17 = f4.ofC1; + +// T is Foo +var f5_/*e1*/r4 = f5.ofFooT; +var f5_/*e2*/r7 = f5.ofFooFooNum; +var f5_/*e3*/r9 = f5.ofIG; +var f5_/*e5*/r13 = f5.ofIG5; +var f5_/*e7*/r17 = f5.ofC1;` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.VerifyNoErrors(t) + f.VerifyQuickInfoAt(t, "a1", "var f_r4: Foo", "") + f.VerifyQuickInfoAt(t, "a2", "var f_r7: Foo>", "") + f.VerifyQuickInfoAt(t, "a3", "var f_r9: IG", "") + f.VerifyQuickInfoAt(t, "a5", "var f_r13: {\n x: Foo;\n}", "") + f.VerifyQuickInfoAt(t, "a7", "var f_r17: C", "") + f.VerifyQuickInfoAt(t, "b1", "var f2_r4: Foo", "") + f.VerifyQuickInfoAt(t, "b2", "var f2_r7: Foo>", "") + f.VerifyQuickInfoAt(t, "b3", "var f2_r9: IG", "") + f.VerifyQuickInfoAt(t, "b5", "var f2_r13: {\n x: Foo;\n}", "") + f.VerifyQuickInfoAt(t, "b7", "var f2_r17: C", "") + f.VerifyQuickInfoAt(t, "c1", "var f3_r4: Foo", "") + f.VerifyQuickInfoAt(t, "c2", "var f3_r7: Foo>", "") + f.VerifyQuickInfoAt(t, "c3", "var f3_r9: IG", "") + f.VerifyQuickInfoAt(t, "c5", "var f3_r13: {\n x: Foo;\n}", "") + f.VerifyQuickInfoAt(t, "c7", "var f3_r17: C", "") + f.VerifyQuickInfoAt(t, "d1", "var f4_r4: Foo<{\n x: number;\n}>", "") + f.VerifyQuickInfoAt(t, "d2", "var f4_r7: Foo>", "") + f.VerifyQuickInfoAt(t, "d3", "var f4_r9: IG<{\n x: number;\n}>", "") + f.VerifyQuickInfoAt(t, "d5", "var f4_r13: {\n x: Foo<{\n x: number;\n }>;\n}", "") + f.VerifyQuickInfoAt(t, "d7", "var f4_r17: C<{\n x: number;\n}>", "") + f.VerifyQuickInfoAt(t, "e1", "var f5_r4: Foo>", "") + f.VerifyQuickInfoAt(t, "e2", "var f5_r7: Foo>", "") + f.VerifyQuickInfoAt(t, "e3", "var f5_r9: IG>", "") + f.VerifyQuickInfoAt(t, "e5", "var f5_r13: {\n x: Foo>;\n}", "") + f.VerifyQuickInfoAt(t, "e7", "var f5_r17: C>", "") +} diff --git a/pkg/fourslash/tests/gen/genericInterfaceWithInheritanceEdit1_test.go b/pkg/fourslash/tests/gen/genericInterfaceWithInheritanceEdit1_test.go new file mode 100644 index 000000000..5330e9cf0 --- /dev/null +++ b/pkg/fourslash/tests/gen/genericInterfaceWithInheritanceEdit1_test.go @@ -0,0 +1,32 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestGenericInterfaceWithInheritanceEdit1(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `interface ChainedObject { + values(): ChainedArray; + pairs(): ChainedArray; + extend(...sources: any[]): ChainedObject; + + value(): T; +} +interface ChainedArray extends ChainedObject> { + + extend(...sources: any[]): ChainedArray; +} + /*1*/` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.VerifyNoErrors(t) + f.GoToMarker(t, "1") + f.Insert(t, " ") + f.VerifyNoErrors(t) +} diff --git a/pkg/fourslash/tests/gen/genericMapTyping1_test.go b/pkg/fourslash/tests/gen/genericMapTyping1_test.go new file mode 100644 index 000000000..609577c31 --- /dev/null +++ b/pkg/fourslash/tests/gen/genericMapTyping1_test.go @@ -0,0 +1,45 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestGenericMapTyping1(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `interface Iterator_ { + (value: T, index: any, list: any): U; +} +interface WrappedArray { + map(iterator: Iterator_, context?: any): U[]; +} +interface Underscore { + (list: T[]): WrappedArray; + map(list: T[], iterator: Iterator_, context?: any): U[]; +} +declare var _: Underscore; +var aa: string[]; +var b/*1*/b = _.map(aa, x/*7*/x => xx.length); // should be number[] +var c/*2*/c = _(aa).map(x/*8*/x => xx.length); // should be number[] +var d/*3*/d = aa.map(xx => x/*9*/x.length); // should be number[] +var aaa: any[]; +var b/*4*/bb = _.map(aaa, xx => xx.length); // should be any[] +var c/*5*/cc = _(aaa).map(xx => xx.length); // Should not error, should be any[] +var d/*6*/dd = aaa.map(xx => xx.length); // should not error, should be any[]` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.VerifyNoErrors(t) + f.VerifyQuickInfoAt(t, "1", "var bb: number[]", "") + f.VerifyQuickInfoAt(t, "2", "var cc: number[]", "") + f.VerifyQuickInfoAt(t, "3", "var dd: number[]", "") + f.VerifyQuickInfoAt(t, "4", "var bbb: any[]", "") + f.VerifyQuickInfoAt(t, "5", "var ccc: any[]", "") + f.VerifyQuickInfoAt(t, "6", "var ddd: any[]", "") + f.VerifyQuickInfoAt(t, "7", "(parameter) xx: string", "") + f.VerifyQuickInfoAt(t, "8", "(parameter) xx: string", "") + f.VerifyQuickInfoAt(t, "9", "(parameter) xx: string", "") +} diff --git a/pkg/fourslash/tests/gen/genericMethodParam_test.go b/pkg/fourslash/tests/gen/genericMethodParam_test.go new file mode 100644 index 000000000..5039a2912 --- /dev/null +++ b/pkg/fourslash/tests/gen/genericMethodParam_test.go @@ -0,0 +1,31 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestGenericMethodParam(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `class C { + /*1*/ +} +/*2*/` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.VerifyNoErrors(t) + f.GoToMarker(t, "1") + f.InsertLine(t, "constructor(){}") + f.InsertLine(t, "foo(a: T) {") + f.InsertLine(t, " return a;") + f.InsertLine(t, "}") + f.VerifyNoErrors(t) + f.GoToMarker(t, "2") + f.InsertLine(t, "var x = new C();") + f.InsertLine(t, "var y: number = x.foo(5);") + f.VerifyNoErrors(t) +} diff --git a/pkg/fourslash/tests/gen/genericObjectBaseType_test.go b/pkg/fourslash/tests/gen/genericObjectBaseType_test.go new file mode 100644 index 000000000..925b2107e --- /dev/null +++ b/pkg/fourslash/tests/gen/genericObjectBaseType_test.go @@ -0,0 +1,27 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestGenericObjectBaseType(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `class C { + constructor(){} + foo(a: T) { + return a.toString(); + } +} +var x = new C(); +var y: string = x.foo("hi"); +/*1*/` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.GoToMarker(t, "1") + f.VerifyNoErrors(t) +} diff --git a/pkg/fourslash/tests/gen/genericRespecialization1_test.go b/pkg/fourslash/tests/gen/genericRespecialization1_test.go new file mode 100644 index 000000000..3b8ac8662 --- /dev/null +++ b/pkg/fourslash/tests/gen/genericRespecialization1_test.go @@ -0,0 +1,88 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestGenericRespecialization1(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `class Food { + private amount: number; + constructor(public name: string) { + this.amount = 100; + } + public eat(amountToEat: number): boolean { + this.amount -= amountToEat; + if (this.amount <= 0) { + this.amount = 0; + return false; + } + else { + return true; + } + } +} +class IceCream extends Food { + private isDairyFree: boolean; + constructor(public flavor: string) { + super("Ice Cream"); + } +} +class Cookie extends Food { + constructor(public flavor: string, public isGlutenFree: boolean) { + super("Cookie"); + } +} +class Slug { + // This is NOT a food!!! +} +class GenericMonster { + private name: string; + private age: number; + private isFriendly: boolean; + constructor(name: string, age: number, isFriendly: boolean, private food: T, public variant: V) { + this.name = name; + this.age = age; + this.isFriendly = isFriendly; + } + public getFood(): T { + return this.food; + } + public getVariant(): V { + return this.variant; + } + public eatFood(amountToEat: number): boolean { + return this.food.eat(amountToEat); + } + public sayGreeting(): string { + return ("My name is " + this.name + ", and my age is " + this.age + ". I enjoy eating " + this.food.name + " and my variant is " + this.variant); + } +} +class GenericPlanet> { + constructor(public name: string, public solarSystem: string, public species: T) { } +} +var cookie = new Cookie("Chocolate Chip", false); +var cookieMonster = new GenericMonster("Cookie Monster", 50, true, cookie, "hello"); +var sesameStreet = new GenericPlanet>("Sesame Street", "Alpha Centuri", cookieMonster); +class GenericPlanet2{ + constructor(public name: string, public solarSystem: string, public species: GenericMonster) { } +} + /*1*/` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.VerifyNoErrors(t) + f.GoToMarker(t, "1") + f.InsertLine(t, "") + f.InsertLine(t, "") + f.VerifyNoErrors(t) + f.GoToMarker(t, "2") + f.DeleteAtCaret(t, 6) + f.Insert(t, "any") + f.VerifyNoErrors(t) + f.InsertLine(t, "var narnia = new GenericPlanet2(") +} diff --git a/pkg/fourslash/tests/gen/genericSignaturesAreProperlyCleaned_test.go b/pkg/fourslash/tests/gen/genericSignaturesAreProperlyCleaned_test.go new file mode 100644 index 000000000..afda0a9ef --- /dev/null +++ b/pkg/fourslash/tests/gen/genericSignaturesAreProperlyCleaned_test.go @@ -0,0 +1,25 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestGenericSignaturesAreProperlyCleaned(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `interface Int { +val(f: (t: T) => U): Int; +} +declare var v1: Int; +var v2: Int = v1/*1*/;` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.VerifyNumberOfErrorsInCurrentFile(t, 1) + f.GoToMarker(t, "1") + f.DeleteAtCaret(t, 1) + f.VerifyNumberOfErrorsInCurrentFile(t, 1) +} diff --git a/pkg/fourslash/tests/gen/getDeclarationDiagnostics_test.go b/pkg/fourslash/tests/gen/getDeclarationDiagnostics_test.go new file mode 100644 index 000000000..e9e11c818 --- /dev/null +++ b/pkg/fourslash/tests/gen/getDeclarationDiagnostics_test.go @@ -0,0 +1,32 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestGetDeclarationDiagnostics(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @declaration: true +// @outFile: true +// @Filename: inputFile1.ts +module m { + export function foo() { + class C implements I { private a; } + interface I { } + return C; + } +} /*1*/ +// @Filename: input2.ts +var x = "hello world"; /*2*/` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.GoToMarker(t, "1") + f.VerifyNumberOfErrorsInCurrentFile(t, 1) + f.GoToMarker(t, "2") + f.VerifyNumberOfErrorsInCurrentFile(t, 0) +} diff --git a/pkg/fourslash/tests/gen/getPreProcessedFile_test.go b/pkg/fourslash/tests/gen/getPreProcessedFile_test.go new file mode 100644 index 000000000..84a1eee06 --- /dev/null +++ b/pkg/fourslash/tests/gen/getPreProcessedFile_test.go @@ -0,0 +1,42 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestGetPreProcessedFile(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @moduleResolution: classic +// @Filename: refFile1.ts +class D { } +// @Filename: refFile2.ts +export class E {} +// @Filename: main.ts +// @ResolveReference: true +/// +/// +/*3*/////*4*/ +import ref2 = require("refFile2"); +import noExistref2 = require(/*5*/"NotExistRefFile2"/*6*/); +import invalidRef1 /*7*/require/*8*/("refFile2"); +import invalidRef2 = /*9*/requi/*10*/(/*10A*/"refFile2"); +var obj: /*11*/C/*12*/; +var obj1: D; +var obj2: ref2.E;` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.GoToFile(t, "main.ts") + f.VerifyNumberOfErrorsInCurrentFile(t, 7) + f.VerifyErrorExistsBetweenMarkers(t, "1", "2") + f.VerifyErrorExistsBetweenMarkers(t, "3", "4") + f.VerifyErrorExistsBetweenMarkers(t, "5", "6") + f.VerifyErrorExistsBetweenMarkers(t, "7", "8") + f.VerifyErrorExistsBetweenMarkers(t, "9", "10") + f.VerifyErrorExistsBetweenMarkers(t, "10", "10A") + f.VerifyErrorExistsBetweenMarkers(t, "11", "12") +} diff --git a/pkg/fourslash/tests/gen/getSemanticDiagnosticForDeclaration1_test.go b/pkg/fourslash/tests/gen/getSemanticDiagnosticForDeclaration1_test.go new file mode 100644 index 000000000..f73eadd39 --- /dev/null +++ b/pkg/fourslash/tests/gen/getSemanticDiagnosticForDeclaration1_test.go @@ -0,0 +1,20 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestGetSemanticDiagnosticForDeclaration1(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @declaration: true +// @Filename: File.d.ts +declare var v: string;` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.VerifyNoErrors(t) +} diff --git a/pkg/fourslash/tests/gen/getSemanticDiagnosticForDeclaration_test.go b/pkg/fourslash/tests/gen/getSemanticDiagnosticForDeclaration_test.go new file mode 100644 index 000000000..1649d4ccd --- /dev/null +++ b/pkg/fourslash/tests/gen/getSemanticDiagnosticForDeclaration_test.go @@ -0,0 +1,25 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestGetSemanticDiagnosticForDeclaration(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @module: CommonJS +// @declaration: true +export function /*1*/foo/*2*/() { + interface privateInterface {} + class Bar implements privateInterface { private a; } + return Bar; +}` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.VerifyErrorExistsBetweenMarkers(t, "1", "2") + f.VerifyNumberOfErrorsInCurrentFile(t, 1) +} diff --git a/pkg/fourslash/tests/gen/getSemanticDiagnosticForNoDeclaration_test.go b/pkg/fourslash/tests/gen/getSemanticDiagnosticForNoDeclaration_test.go new file mode 100644 index 000000000..38257ca6a --- /dev/null +++ b/pkg/fourslash/tests/gen/getSemanticDiagnosticForNoDeclaration_test.go @@ -0,0 +1,20 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestGetSemanticDiagnosticForNoDeclaration(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @module: CommonJS +interface privateInterface {} +export class Bar implements /*1*/privateInterface/*2*/{ }` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.VerifyNoErrors(t) +} diff --git a/pkg/fourslash/tests/gen/goToDefinitionImportMeta_test.go b/pkg/fourslash/tests/gen/goToDefinitionImportMeta_test.go new file mode 100644 index 000000000..eda45aac8 --- /dev/null +++ b/pkg/fourslash/tests/gen/goToDefinitionImportMeta_test.go @@ -0,0 +1,26 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestGoToDefinitionImportMeta(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @module: esnext +// @Filename: foo.ts +/// +/// +import.me/*reference*/ta; +//@Filename: bar.d.ts +interface ImportMeta { +}` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.VerifyBaselineGoToDefinition(t, true, "reference") + f.VerifyNoErrors(t) +} diff --git a/pkg/fourslash/tests/gen/goToDefinitionSignatureAlias_test.go b/pkg/fourslash/tests/gen/goToDefinitionSignatureAlias_test.go new file mode 100644 index 000000000..10d28a73c --- /dev/null +++ b/pkg/fourslash/tests/gen/goToDefinitionSignatureAlias_test.go @@ -0,0 +1,51 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestGoToDefinitionSignatureAlias(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @jsx: preserve +// @Filename: /a.tsx +function /*f*/f() {} +const /*g*/g = f; +const /*h*/h = g; +[|/*useF*/f|](); +[|/*useG*/g|](); +[|/*useH*/h|](); +const /*i*/i = () => 0; +const /*iFn*/iFn = function () { return 0; }; +const /*j*/j = i; +[|/*useI*/i|](); +[|/*useIFn*/iFn|](); +[|/*useJ*/j|](); +const o = { /*m*/m: () => 0 }; +o.[|/*useM*/m|](); +const oFn = { /*mFn*/mFn: function () { return 0; } }; +oFn.[|/*useMFn*/mFn|](); +class Component { /*componentCtr*/constructor(props: {}) {} } +type ComponentClass = /*ComponentClass*/new () => Component; +interface ComponentClass2 { /*ComponentClass2*/new(): Component; } + +class /*MyComponent*/MyComponent extends Component {} +<[|/*jsxMyComponent*/MyComponent|] />; +new [|/*newMyComponent*/MyComponent|]({}); + +declare const /*MyComponent2*/MyComponent2: ComponentClass; +<[|/*jsxMyComponent2*/MyComponent2|] />; +new [|/*newMyComponent2*/MyComponent2|](); + +declare const /*MyComponent3*/MyComponent3: ComponentClass2; +<[|/*jsxMyComponent3*/MyComponent3|] />; +new [|/*newMyComponent3*/MyComponent3|]();` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.VerifyNoErrors(t) + f.VerifyBaselineGoToDefinition(t, true, "useF", "useG", "useH", "useI", "useIFn", "useJ", "useM", "useMFn", "jsxMyComponent", "newMyComponent", "jsxMyComponent2", "newMyComponent2", "jsxMyComponent3", "newMyComponent3") +} diff --git a/pkg/fourslash/tests/gen/identifierErrorRecovery_test.go b/pkg/fourslash/tests/gen/identifierErrorRecovery_test.go new file mode 100644 index 000000000..604b896af --- /dev/null +++ b/pkg/fourslash/tests/gen/identifierErrorRecovery_test.go @@ -0,0 +1,38 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + . "github.com/buke/typescript-go-internal/pkg/fourslash/tests/util" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestIdentifierErrorRecovery(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `var /*1*/export/*2*/; +var foo; +var /*3*/class/*4*/; +var bar;` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.VerifyErrorExistsBetweenMarkers(t, "1", "2") + f.VerifyErrorExistsBetweenMarkers(t, "3", "4") + f.VerifyNumberOfErrorsInCurrentFile(t, 3) + f.GoToEOF(t) + f.VerifyCompletions(t, nil, &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Includes: []fourslash.CompletionsExpectedItem{ + "foo", + "bar", + }, + }, + }) +} diff --git a/pkg/fourslash/tests/gen/importMetaCompletionDetails_test.go b/pkg/fourslash/tests/gen/importMetaCompletionDetails_test.go new file mode 100644 index 000000000..dca021b68 --- /dev/null +++ b/pkg/fourslash/tests/gen/importMetaCompletionDetails_test.go @@ -0,0 +1,38 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + . "github.com/buke/typescript-go-internal/pkg/fourslash/tests/util" + "github.com/buke/typescript-go-internal/pkg/lsp/lsproto" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestImportMetaCompletionDetails(t *testing.T) { + t.Parallel() + t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @filename: index.mts +// @module: Node16 +// @strict: true +let x = import.meta/**/;` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.VerifyCompletions(t, "", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Includes: []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "meta", + Detail: PtrTo("(property) ImportMetaExpression.meta: ImportMeta"), + }, + }, + }, + }) + f.VerifyNoErrors(t) +} diff --git a/pkg/fourslash/tests/gen/incompatibleOverride_test.go b/pkg/fourslash/tests/gen/incompatibleOverride_test.go new file mode 100644 index 000000000..55f9a8bd2 --- /dev/null +++ b/pkg/fourslash/tests/gen/incompatibleOverride_test.go @@ -0,0 +1,28 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestIncompatibleOverride(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `class Foo { xyz: string; } +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(); + } +}` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.VerifyErrorExistsBetweenMarkers(t, "1", "2") + f.VerifyErrorExistsBetweenMarkers(t, "3", "4") + f.VerifyErrorExistsBetweenMarkers(t, "5", "6") + f.VerifyNumberOfErrorsInCurrentFile(t, 3) +} diff --git a/pkg/fourslash/tests/gen/incrementalEditInvocationExpressionAboveInterfaceDeclaration_test.go b/pkg/fourslash/tests/gen/incrementalEditInvocationExpressionAboveInterfaceDeclaration_test.go new file mode 100644 index 000000000..ad2d69e65 --- /dev/null +++ b/pkg/fourslash/tests/gen/incrementalEditInvocationExpressionAboveInterfaceDeclaration_test.go @@ -0,0 +1,25 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestIncrementalEditInvocationExpressionAboveInterfaceDeclaration(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `declare function alert(message?: any): void; +/*1*/ +interface Foo { + setISO8601(dString): Date; +}` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.GoToMarker(t, "1") + f.Insert(t, "alert(") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{Text: "alert(message?: any): void"}) + f.VerifyErrorExistsAfterMarker(t, "1") +} diff --git a/pkg/fourslash/tests/gen/incrementalParsingDynamicImport1_test.go b/pkg/fourslash/tests/gen/incrementalParsingDynamicImport1_test.go new file mode 100644 index 000000000..5da1ec517 --- /dev/null +++ b/pkg/fourslash/tests/gen/incrementalParsingDynamicImport1_test.go @@ -0,0 +1,28 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestIncrementalParsingDynamicImport1(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @lib: es6 +// @Filename: ./foo.ts +export function bar() { return 1; } +var x1 = import("./foo"); +x1.then(foo => { + var s: string = foo.bar(); +}) +/*1*/` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.VerifyNumberOfErrorsInCurrentFile(t, 1) + f.GoToMarker(t, "1") + f.Insert(t, " ") + f.VerifyNumberOfErrorsInCurrentFile(t, 1) +} diff --git a/pkg/fourslash/tests/gen/incrementalParsingDynamicImport2_test.go b/pkg/fourslash/tests/gen/incrementalParsingDynamicImport2_test.go new file mode 100644 index 000000000..c8f583484 --- /dev/null +++ b/pkg/fourslash/tests/gen/incrementalParsingDynamicImport2_test.go @@ -0,0 +1,25 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestIncrementalParsingDynamicImport2(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @lib: es2015 +// @Filename: ./foo.ts +export function bar() { return 1; } +// @Filename: ./0.ts +/*1*/ import { bar } from "./foo"` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.VerifyNumberOfErrorsInCurrentFile(t, 0) + f.GoToMarker(t, "1") + f.Insert(t, "var x = ") + f.VerifyNumberOfErrorsInCurrentFile(t, 1) +} diff --git a/pkg/fourslash/tests/gen/incrementalParsingDynamicImport3_test.go b/pkg/fourslash/tests/gen/incrementalParsingDynamicImport3_test.go new file mode 100644 index 000000000..92bb9e86f --- /dev/null +++ b/pkg/fourslash/tests/gen/incrementalParsingDynamicImport3_test.go @@ -0,0 +1,25 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestIncrementalParsingDynamicImport3(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @lib: es2015 +// @Filename: ./foo.ts +export function bar() { return 1; } +// @Filename: ./0.ts +var x = import/*1*/` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.VerifyNumberOfErrorsInCurrentFile(t, 0) + f.GoToMarker(t, "1") + f.Insert(t, "(") + f.VerifyNumberOfErrorsInCurrentFile(t, 1) +} diff --git a/pkg/fourslash/tests/gen/incrementalParsingDynamicImport4_test.go b/pkg/fourslash/tests/gen/incrementalParsingDynamicImport4_test.go new file mode 100644 index 000000000..86f567a1a --- /dev/null +++ b/pkg/fourslash/tests/gen/incrementalParsingDynamicImport4_test.go @@ -0,0 +1,26 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestIncrementalParsingDynamicImport4(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @lib: es2015 +// @Filename: ./foo.ts +export function bar() { return 1; } +// @Filename: ./0.ts +/*1*/ +import { bar } from "./foo"` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.VerifyNumberOfErrorsInCurrentFile(t, 0) + f.GoToMarker(t, "1") + f.Insert(t, "import") + f.VerifyNumberOfErrorsInCurrentFile(t, 1) +} diff --git a/pkg/fourslash/tests/gen/incrementalParsingTopLevelAwait1_test.go b/pkg/fourslash/tests/gen/incrementalParsingTopLevelAwait1_test.go new file mode 100644 index 000000000..dfb4fecd4 --- /dev/null +++ b/pkg/fourslash/tests/gen/incrementalParsingTopLevelAwait1_test.go @@ -0,0 +1,27 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestIncrementalParsingTopLevelAwait1(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @target: esnext +// @module: esnext +// @Filename: ./foo.ts +await(1); +/*1*/` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.VerifyNumberOfErrorsInCurrentFile(t, 1) + f.GoToMarker(t, "1") + f.Insert(t, "export {};") + f.VerifyNumberOfErrorsInCurrentFile(t, 0) + f.ReplaceLine(t, 1, "") + f.VerifyNumberOfErrorsInCurrentFile(t, 1) +} diff --git a/pkg/fourslash/tests/gen/incrementalParsingTopLevelAwait2_test.go b/pkg/fourslash/tests/gen/incrementalParsingTopLevelAwait2_test.go new file mode 100644 index 000000000..4a9077a61 --- /dev/null +++ b/pkg/fourslash/tests/gen/incrementalParsingTopLevelAwait2_test.go @@ -0,0 +1,27 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestIncrementalParsingTopLevelAwait2(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @target: esnext +// @module: esnext +// @Filename: ./foo.ts +export {}; +/*1*/` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.VerifyNumberOfErrorsInCurrentFile(t, 0) + f.GoToMarker(t, "1") + f.Insert(t, "await(1);") + f.VerifyNumberOfErrorsInCurrentFile(t, 0) + f.ReplaceLine(t, 1, "") + f.VerifyNumberOfErrorsInCurrentFile(t, 0) +} diff --git a/pkg/fourslash/tests/gen/incrementalResolveAccessor_test.go b/pkg/fourslash/tests/gen/incrementalResolveAccessor_test.go new file mode 100644 index 000000000..1ef36c82d --- /dev/null +++ b/pkg/fourslash/tests/gen/incrementalResolveAccessor_test.go @@ -0,0 +1,29 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestIncrementalResolveAccessor(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `class c1 { + get p1(): string { + return "30"; + } + set p1(a: number) { + a = "30"; + } +} +var val = new c1(); +var b = val.p1; +/*1*/b;` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.VerifyQuickInfoAt(t, "1", "var b: string", "") + f.VerifyNumberOfErrorsInCurrentFile(t, 1) +} diff --git a/pkg/fourslash/tests/gen/incrementalResolveConstructorDeclaration_test.go b/pkg/fourslash/tests/gen/incrementalResolveConstructorDeclaration_test.go new file mode 100644 index 000000000..b936b0dda --- /dev/null +++ b/pkg/fourslash/tests/gen/incrementalResolveConstructorDeclaration_test.go @@ -0,0 +1,26 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestIncrementalResolveConstructorDeclaration(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `class c1 { + private b: number; + constructor(a: string) { + this.b = a; + } +} +var val = new c1("hello"); +/*1*/val;` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.VerifyQuickInfoAt(t, "1", "var val: c1", "") + f.VerifyNumberOfErrorsInCurrentFile(t, 1) +} diff --git a/pkg/fourslash/tests/gen/incrementalResolveFunctionPropertyAssignment_test.go b/pkg/fourslash/tests/gen/incrementalResolveFunctionPropertyAssignment_test.go new file mode 100644 index 000000000..023def6ae --- /dev/null +++ b/pkg/fourslash/tests/gen/incrementalResolveFunctionPropertyAssignment_test.go @@ -0,0 +1,38 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestIncrementalResolveFunctionPropertyAssignment(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `function bar(indexer: { getLength(): number; getTypeAtIndex(index: number): string; }): string { + return indexer.getTypeAtIndex(indexer.getLength() - 1); +} +function foo(a: string[]) { + return bar({ + getLength(): number { + return "a.length"; + }, + getTypeAtIndex(index: number) { + switch (index) { + case 0: return a[0]; + case 1: return a[1]; + case 2: return a[2]; + default: return "invalid"; + } + } + }); +} +var val = foo(["myString1", "myString2"]); +/*1*/val;` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.VerifyQuickInfoAt(t, "1", "var val: string", "") + f.VerifyNumberOfErrorsInCurrentFile(t, 1) +} diff --git a/pkg/fourslash/tests/gen/incrementalUpdateToClassImplementingGenericClass_test.go b/pkg/fourslash/tests/gen/incrementalUpdateToClassImplementingGenericClass_test.go new file mode 100644 index 000000000..e96dc1590 --- /dev/null +++ b/pkg/fourslash/tests/gen/incrementalUpdateToClassImplementingGenericClass_test.go @@ -0,0 +1,32 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestIncrementalUpdateToClassImplementingGenericClass(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `declare function alert(message?: string): void; +class Animal { + constructor(public name: T) { } + move(meters: number) { + alert(this.name + " moved " + meters + "m."); + } +} +class Animal2 extends Animal { + constructor(name: string) { super(name); } + /*1*/get name2() { return this.name; } +} +var a = new Animal2('eprst');` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.GoToMarker(t, "1") + f.VerifyNoErrors(t) + f.Insert(t, "//") + f.VerifyNoErrors(t) +} diff --git a/pkg/fourslash/tests/gen/indentAfterFunctionClosingBraces_test.go b/pkg/fourslash/tests/gen/indentAfterFunctionClosingBraces_test.go new file mode 100644 index 000000000..476aec5ce --- /dev/null +++ b/pkg/fourslash/tests/gen/indentAfterFunctionClosingBraces_test.go @@ -0,0 +1,25 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestIndentAfterFunctionClosingBraces(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `class foo { + public f() { + return 0; + /*1*/}/*2*/ +}` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.GoToMarker(t, "2") + f.InsertLine(t, "") + f.GoToMarker(t, "1") + f.VerifyCurrentLineContentIs(t, " }") +} diff --git a/pkg/fourslash/tests/gen/inheritedModuleMembersForClodule2_test.go b/pkg/fourslash/tests/gen/inheritedModuleMembersForClodule2_test.go new file mode 100644 index 000000000..7a6c70845 --- /dev/null +++ b/pkg/fourslash/tests/gen/inheritedModuleMembersForClodule2_test.go @@ -0,0 +1,30 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestInheritedModuleMembersForClodule2(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `module M { + export module A { + var o; + } +} +module M { + export class A { a = 1;} +} +module M { + export class A { /**/b } +}` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.GoToMarker(t, "") + f.VerifyQuickInfoExists(t) + f.VerifyNumberOfErrorsInCurrentFile(t, 4) +} diff --git a/pkg/fourslash/tests/gen/insertReturnStatementInDuplicateIdentifierFunction_test.go b/pkg/fourslash/tests/gen/insertReturnStatementInDuplicateIdentifierFunction_test.go new file mode 100644 index 000000000..8ccc16ce7 --- /dev/null +++ b/pkg/fourslash/tests/gen/insertReturnStatementInDuplicateIdentifierFunction_test.go @@ -0,0 +1,22 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestInsertReturnStatementInDuplicateIdentifierFunction(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `class foo { }; +function foo() { /**/ }` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.GoToMarker(t, "") + f.VerifyNumberOfErrorsInCurrentFile(t, 2) + f.Insert(t, "return null;") + f.VerifyNumberOfErrorsInCurrentFile(t, 2) +} diff --git a/pkg/fourslash/tests/gen/interfaceExtendsPrimitive_test.go b/pkg/fourslash/tests/gen/interfaceExtendsPrimitive_test.go new file mode 100644 index 000000000..6aab46f61 --- /dev/null +++ b/pkg/fourslash/tests/gen/interfaceExtendsPrimitive_test.go @@ -0,0 +1,19 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestInterfaceExtendsPrimitive(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `interface x extends /*1*/string/*2*/ { }` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.VerifyErrorExistsBetweenMarkers(t, "1", "2") + f.VerifyNumberOfErrorsInCurrentFile(t, 1) +} diff --git a/pkg/fourslash/tests/gen/invalidRestArgError_test.go b/pkg/fourslash/tests/gen/invalidRestArgError_test.go new file mode 100644 index 000000000..2ee611e12 --- /dev/null +++ b/pkg/fourslash/tests/gen/invalidRestArgError_test.go @@ -0,0 +1,18 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestInvalidRestArgError(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `function b(.../*1*/)/*2*/ {} ` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.VerifyErrorExistsBetweenMarkers(t, "1", "2") +} diff --git a/pkg/fourslash/tests/gen/invertedCloduleAfterQuickInfo_test.go b/pkg/fourslash/tests/gen/invertedCloduleAfterQuickInfo_test.go new file mode 100644 index 000000000..dcdcc20c2 --- /dev/null +++ b/pkg/fourslash/tests/gen/invertedCloduleAfterQuickInfo_test.go @@ -0,0 +1,27 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestInvertedCloduleAfterQuickInfo(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `module M { + module A { + var o; + } + class A { + /**/c + } +}` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.GoToMarker(t, "") + f.VerifyQuickInfoExists(t) + f.VerifyNumberOfErrorsInCurrentFile(t, 1) +} diff --git a/pkg/fourslash/tests/gen/invertedFunduleAfterQuickInfo_test.go b/pkg/fourslash/tests/gen/invertedFunduleAfterQuickInfo_test.go new file mode 100644 index 000000000..076565609 --- /dev/null +++ b/pkg/fourslash/tests/gen/invertedFunduleAfterQuickInfo_test.go @@ -0,0 +1,25 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestInvertedFunduleAfterQuickInfo(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `module M { + module A { + var o; + } + function A(/**/x: number): void { } +}` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.GoToMarker(t, "") + f.VerifyQuickInfoExists(t) + f.VerifyNumberOfErrorsInCurrentFile(t, 1) +} diff --git a/pkg/fourslash/tests/gen/javascriptModules22_test.go b/pkg/fourslash/tests/gen/javascriptModules22_test.go new file mode 100644 index 000000000..09374401f --- /dev/null +++ b/pkg/fourslash/tests/gen/javascriptModules22_test.go @@ -0,0 +1,77 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + . "github.com/buke/typescript-go-internal/pkg/fourslash/tests/util" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestJavascriptModules22(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @allowJs: true +// @module: commonjs +// @allowSyntheticDefaultImports: false +// @esModuleInterop: false +// @Filename: mod.js +function foo() { return {a: "hello, world"}; } +module.exports = foo(); +// @Filename: mod2.js +var x = {name: 'test'}; +(function createExport(obj){ + module.exports = { + "default": x, + "sausages": {eggs: 2} + }; +})(); +// @Filename: app.js +import {a} from "./mod" +import def, {sausages} from "./mod2" +a./**/` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.VerifyCompletions(t, "", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Includes: []fourslash.CompletionsExpectedItem{ + "toString", + }, + }, + }) + f.Backspace(t, 2) + f.Insert(t, "def.") + f.VerifyCompletions(t, nil, &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Includes: []fourslash.CompletionsExpectedItem{ + "name", + }, + }, + }) + f.Insert(t, "name;\nsausages.") + f.VerifyCompletions(t, nil, &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Includes: []fourslash.CompletionsExpectedItem{ + "eggs", + }, + }, + }) + f.Insert(t, "eggs;") + f.VerifyNoErrors(t) +} diff --git a/pkg/fourslash/tests/gen/javascriptModules24_test.go b/pkg/fourslash/tests/gen/javascriptModules24_test.go new file mode 100644 index 000000000..6044511f2 --- /dev/null +++ b/pkg/fourslash/tests/gen/javascriptModules24_test.go @@ -0,0 +1,31 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestJavascriptModules24(t *testing.T) { + t.Parallel() + t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @Filename: mod.ts +function foo() { return 42; } +namespace foo { + export function bar (a: string) { return a; } +} +export = foo; +// @Filename: app.ts +import * as foo from "./mod" +foo/*1*/(); +foo.bar(/*2*/"test");` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.GoToMarker(t, "1") + f.VerifyErrorExistsBeforeMarker(t, "1") + f.VerifyQuickInfoIs(t, "(alias) function foo(): number\n(alias) namespace foo\nimport foo", "") + f.GoToMarker(t, "2") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{}) +} diff --git a/pkg/fourslash/tests/gen/jsDocFunctionSignatures4_test.go b/pkg/fourslash/tests/gen/jsDocFunctionSignatures4_test.go new file mode 100644 index 000000000..cf91181f9 --- /dev/null +++ b/pkg/fourslash/tests/gen/jsDocFunctionSignatures4_test.go @@ -0,0 +1,22 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestJsDocFunctionSignatures4(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @allowNonTsExtensions: true +// @Filename: Foo.js +/** @param {function ({OwnerID:string,AwayID:string}):void} x + * @param {function (string):void} y */ +function fn(x, y) { }` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.VerifyNoErrors(t) +} diff --git a/pkg/fourslash/tests/gen/jsconfig_test.go b/pkg/fourslash/tests/gen/jsconfig_test.go new file mode 100644 index 000000000..aedd2f21f --- /dev/null +++ b/pkg/fourslash/tests/gen/jsconfig_test.go @@ -0,0 +1,28 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestJsconfig(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @Filename: /a.js +function f(/**/x) { +} +// @Filename: /jsconfig.json +{ + "compilerOptions": { + "checkJs": true, + "noImplicitAny": true + } +}` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.GoToFile(t, "/a.js") + f.VerifyErrorExistsAfterMarker(t, "") +} diff --git a/pkg/fourslash/tests/gen/jsdocDeprecated_suggestion8_test.go b/pkg/fourslash/tests/gen/jsdocDeprecated_suggestion8_test.go new file mode 100644 index 000000000..59880ef1f --- /dev/null +++ b/pkg/fourslash/tests/gen/jsdocDeprecated_suggestion8_test.go @@ -0,0 +1,26 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestJsdocDeprecated_suggestion8(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @Filename: first.ts +/** @deprecated */ +export declare function tap(next: null): void; +export declare function tap(next: T): T; +// @Filename: second.ts +import { tap } from './first'; +tap` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.GoToFile(t, "second.ts") + f.VerifyNoErrors(t) + f.VerifySuggestionDiagnostics(t, nil) +} diff --git a/pkg/fourslash/tests/gen/jsdocDeprecated_suggestion9_test.go b/pkg/fourslash/tests/gen/jsdocDeprecated_suggestion9_test.go new file mode 100644 index 000000000..0ca5f2ef0 --- /dev/null +++ b/pkg/fourslash/tests/gen/jsdocDeprecated_suggestion9_test.go @@ -0,0 +1,24 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestJsdocDeprecated_suggestion9(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @Filename: first.ts +export class logger { } +// @Filename: second.ts +import { logger } from './first'; +new logger()` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.GoToFile(t, "second.ts") + f.VerifyNoErrors(t) + f.VerifySuggestionDiagnostics(t, nil) +} diff --git a/pkg/fourslash/tests/gen/memberConstructorEdits_test.go b/pkg/fourslash/tests/gen/memberConstructorEdits_test.go new file mode 100644 index 000000000..c6bdf6f0f --- /dev/null +++ b/pkg/fourslash/tests/gen/memberConstructorEdits_test.go @@ -0,0 +1,39 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestMemberConstructorEdits(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = ` module M { + export class A { + constructor(a: string) {} + public m(n: number) { + return 0; + } + public n() { + return this.m(0); + } + } + export class B extends A { + constructor(a: string) { + super(a); + } + /*1*/ + } + var a = new A("s"); + var b = new B("s"); + }` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.VerifyNoErrors(t) + f.GoToMarker(t, "1") + f.Insert(t, "public m(n: number) { return 0; }") + f.VerifyNoErrors(t) +} diff --git a/pkg/fourslash/tests/gen/memberOverloadEdits_test.go b/pkg/fourslash/tests/gen/memberOverloadEdits_test.go new file mode 100644 index 000000000..c21aee31f --- /dev/null +++ b/pkg/fourslash/tests/gen/memberOverloadEdits_test.go @@ -0,0 +1,31 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestMemberOverloadEdits(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `module M { + export class A { + public m(n: number) { + return 0; + } + public n() { + return this.m(0); + } + } + export class B extends A { /*1*/ } +}` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.VerifyNoErrors(t) + f.GoToMarker(t, "1") + f.Insert(t, "public m(n: number) { return 0; }") + f.VerifyNoErrors(t) +} diff --git a/pkg/fourslash/tests/gen/missingMethodAfterEditAfterImport_test.go b/pkg/fourslash/tests/gen/missingMethodAfterEditAfterImport_test.go new file mode 100644 index 000000000..fc250162b --- /dev/null +++ b/pkg/fourslash/tests/gen/missingMethodAfterEditAfterImport_test.go @@ -0,0 +1,27 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestMissingMethodAfterEditAfterImport(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `namespace foo { + export namespace bar { namespace baz { export class boo { } } } +} + +import f = /*foo*/foo; + +/*delete*/var x;` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.VerifyQuickInfoAt(t, "foo", "namespace foo", "") + f.GoToMarker(t, "delete") + f.DeleteAtCaret(t, 6) + f.VerifyQuickInfoAt(t, "foo", "namespace foo", "") +} diff --git a/pkg/fourslash/tests/gen/multiModuleClodule_test.go b/pkg/fourslash/tests/gen/multiModuleClodule_test.go new file mode 100644 index 000000000..c5f4e3da4 --- /dev/null +++ b/pkg/fourslash/tests/gen/multiModuleClodule_test.go @@ -0,0 +1,91 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + . "github.com/buke/typescript-go-internal/pkg/fourslash/tests/util" + "github.com/buke/typescript-go-internal/pkg/ls" + "github.com/buke/typescript-go-internal/pkg/lsp/lsproto" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestMultiModuleClodule(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `class C { + constructor(x: number) { } + foo() { } + bar() { } + static boo() { } +} + +module C { + export var x = 1; + var y = 2; +} +module C { + export function foo() { } + function baz() { return ''; } +} + +var c = new C/*1*/(C./*2*/x); +c./*3*/foo = C./*4*/foo;` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.VerifyCompletions(t, "1", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Includes: []fourslash.CompletionsExpectedItem{ + "C", + }, + }, + }) + f.VerifyCompletions(t, []string{"2", "4"}, &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Exact: CompletionFunctionMembersPlus( + []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "boo", + SortText: PtrTo(string(ls.SortTextLocalDeclarationPriority)), + }, + &lsproto.CompletionItem{ + Label: "foo", + SortText: PtrTo(string(ls.SortTextLocationPriority)), + }, + &lsproto.CompletionItem{ + Label: "prototype", + SortText: PtrTo(string(ls.SortTextLocationPriority)), + }, + &lsproto.CompletionItem{ + Label: "x", + SortText: PtrTo(string(ls.SortTextLocationPriority)), + }, + }), + }, + }) + f.VerifyCompletions(t, "3", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Exact: []fourslash.CompletionsExpectedItem{ + "bar", + "foo", + }, + }, + }) + f.VerifyNoErrors(t) +} diff --git a/pkg/fourslash/tests/gen/multiModuleFundule_test.go b/pkg/fourslash/tests/gen/multiModuleFundule_test.go new file mode 100644 index 000000000..65fad02d8 --- /dev/null +++ b/pkg/fourslash/tests/gen/multiModuleFundule_test.go @@ -0,0 +1,72 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + . "github.com/buke/typescript-go-internal/pkg/fourslash/tests/util" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestMultiModuleFundule(t *testing.T) { + t.Parallel() + t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `function C(x: number) { } + +module C { + export var x = 1; +} +module C { + export function foo() { } +} + +var /*2*/r = C(/*1*/ +var /*4*/r2 = new C(/*3*/ // using void returning function as constructor +var r3 = C./*5*/` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.VerifyCompletions(t, "1", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &[]string{}, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Includes: []fourslash.CompletionsExpectedItem{ + "C", + }, + }, + }) + f.Insert(t, "C.x);") + f.VerifyQuickInfoAt(t, "2", "var r: void", "") + f.VerifyCompletions(t, "3", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &[]string{}, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Includes: []fourslash.CompletionsExpectedItem{ + "C", + }, + }, + }) + f.Insert(t, "C.x);") + f.VerifyQuickInfoAt(t, "4", "var r2: any", "") + f.VerifyCompletions(t, "5", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Includes: []fourslash.CompletionsExpectedItem{ + "x", + "foo", + }, + }, + }) + f.Insert(t, "x;") + f.VerifyNoErrors(t) +} diff --git a/pkg/fourslash/tests/gen/ngProxy4_test.go b/pkg/fourslash/tests/gen/ngProxy4_test.go new file mode 100644 index 000000000..131236813 --- /dev/null +++ b/pkg/fourslash/tests/gen/ngProxy4_test.go @@ -0,0 +1,32 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestNgProxy4(t *testing.T) { + t.Parallel() + t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @Filename: tsconfig.json +{ + "compilerOptions": { + "plugins": [ + { "name": "diagnostic-adder" } + ] + }, + "files": ["a.ts"] +} +// @Filename: a.ts +let x = [1, 2]; +x/**/ +` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.MarkTestAsStradaServer() + f.GoToMarker(t, "") + f.VerifyNumberOfErrorsInCurrentFile(t, 1) +} diff --git a/pkg/fourslash/tests/gen/noErrorsAfterCompletionsRequestWithinGenericFunction1_test.go b/pkg/fourslash/tests/gen/noErrorsAfterCompletionsRequestWithinGenericFunction1_test.go new file mode 100644 index 000000000..074eea6ce --- /dev/null +++ b/pkg/fourslash/tests/gen/noErrorsAfterCompletionsRequestWithinGenericFunction1_test.go @@ -0,0 +1,23 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestNoErrorsAfterCompletionsRequestWithinGenericFunction1(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @strict: true + +declare function func(arg: T): void; +func({ foo: 1, bar/*1*/: 1 });` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.GoToMarker(t, "1") + f.VerifyCompletions(t, nil, nil) + f.VerifyNoErrors(t) +} diff --git a/pkg/fourslash/tests/gen/noErrorsAfterCompletionsRequestWithinGenericFunction2_test.go b/pkg/fourslash/tests/gen/noErrorsAfterCompletionsRequestWithinGenericFunction2_test.go new file mode 100644 index 000000000..35b3d64c3 --- /dev/null +++ b/pkg/fourslash/tests/gen/noErrorsAfterCompletionsRequestWithinGenericFunction2_test.go @@ -0,0 +1,26 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestNoErrorsAfterCompletionsRequestWithinGenericFunction2(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @strict: true + +// repro from #50818#issuecomment-1278324638 + +declare function func(arg: T): void; +func({ foo: 1, bar/*1*/: 1 });` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.GoToMarker(t, "1") + f.Insert(t, "2") + f.VerifyCompletions(t, nil, nil) + f.VerifyNoErrors(t) +} diff --git a/pkg/fourslash/tests/gen/nodeModulesFileEditStillAllowsResolutionsToWork_test.go b/pkg/fourslash/tests/gen/nodeModulesFileEditStillAllowsResolutionsToWork_test.go new file mode 100644 index 000000000..6f506ff49 --- /dev/null +++ b/pkg/fourslash/tests/gen/nodeModulesFileEditStillAllowsResolutionsToWork_test.go @@ -0,0 +1,29 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestNodeModulesFileEditStillAllowsResolutionsToWork(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @Filename: /tsconfig.json +{ "compilerOptions": { "module": "nodenext", "strict": true } } +// @Filename: /package.json +{ "type": "module", "imports": { "#foo": "./foo.cjs" } } +// @Filename: /foo.cts +export const x = 1; +// @Filename: /index.ts +import * as mod from "#foo"; +/**/` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.GoToMarker(t, "") + f.Insert(t, "mod.x") + f.VerifyNoErrors(t) + f.VerifySuggestionDiagnostics(t, nil) +} diff --git a/pkg/fourslash/tests/gen/nodeNextModuleKindCaching1_test.go b/pkg/fourslash/tests/gen/nodeNextModuleKindCaching1_test.go new file mode 100644 index 000000000..1beed6957 --- /dev/null +++ b/pkg/fourslash/tests/gen/nodeNextModuleKindCaching1_test.go @@ -0,0 +1,46 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestNodeNextModuleKindCaching1(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @Filename: tsconfig.json +{ + "compilerOptions": { + "rootDir": "src", + "outDir": "dist", + "target": "ES2020", + "module": "NodeNext", + "strict": true + }, + "include": ["src\\**\\*.ts"] +} +// @Filename: package.json +{ + "type": "module", + "private": true +} +// @Filename: src/index.ts +// The line below should show a "Relative import paths need explicit file +// extensions..." error in VS Code, but it doesn't. The error is only picked up +// by ` + "`" + `tsc` + "`" + ` which seems to properly infer the module type. +import { helloWorld } from './example' +/**/ +helloWorld() +// @Filename: src/example.ts +export function helloWorld() { + console.log('Hello, world!') +}` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.MarkTestAsStradaServer() + f.GoToMarker(t, "") + f.VerifyNumberOfErrorsInCurrentFile(t, 1) +} diff --git a/pkg/fourslash/tests/gen/partialUnionPropertyCacheInconsistentErrors_test.go b/pkg/fourslash/tests/gen/partialUnionPropertyCacheInconsistentErrors_test.go new file mode 100644 index 000000000..c7644a60e --- /dev/null +++ b/pkg/fourslash/tests/gen/partialUnionPropertyCacheInconsistentErrors_test.go @@ -0,0 +1,55 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestPartialUnionPropertyCacheInconsistentErrors(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @strict: true +// @lib: esnext +interface ComponentOptions { + setup?: (props: Props) => void; + name?: string; +} + +interface FunctionalComponent

{ + (props: P): void; +} + +type ConcreteComponent = + | ComponentOptions + | FunctionalComponent; + +type Component = ConcreteComponent; + +type WithInstallPlugin = { _prefix?: string }; + + +/**/ +export function withInstall( + component: C | C[], + target?: T, +): string { + const componentWithInstall = (target ?? component) as T; + const components = Array.isArray(component) ? component : [component]; + + const { name } = components[0]; + if (name) { + return name; + } + + return ""; +}` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.VerifyNoErrors(t) + f.GoToMarker(t, "") + f.Insert(t, "type C = Component['name']") + f.VerifyNoErrors(t) +} diff --git a/pkg/fourslash/tests/gen/pasteLambdaOverModule_test.go b/pkg/fourslash/tests/gen/pasteLambdaOverModule_test.go new file mode 100644 index 000000000..9d8722e95 --- /dev/null +++ b/pkg/fourslash/tests/gen/pasteLambdaOverModule_test.go @@ -0,0 +1,23 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestPasteLambdaOverModule(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `/**/` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.GoToMarker(t, "") + f.Paste(t, "module B { }") + f.GoToBOF(t) + f.DeleteAtCaret(t, 12) + f.Insert(t, "var t = (public x) => { };") + f.VerifyNumberOfErrorsInCurrentFile(t, 1) +} diff --git a/pkg/fourslash/tests/gen/paste_test.go b/pkg/fourslash/tests/gen/paste_test.go new file mode 100644 index 000000000..783a9d599 --- /dev/null +++ b/pkg/fourslash/tests/gen/paste_test.go @@ -0,0 +1,20 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestPaste(t *testing.T) { + t.Parallel() + t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `fn(/**/);` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.GoToMarker(t, "") + f.Paste(t, "x,y,z") + f.VerifyCurrentLineContentIs(t, "fn(x, y, z);") +} diff --git a/pkg/fourslash/tests/gen/quickInfoCloduleWithRecursiveReference_test.go b/pkg/fourslash/tests/gen/quickInfoCloduleWithRecursiveReference_test.go new file mode 100644 index 000000000..a169fa3dc --- /dev/null +++ b/pkg/fourslash/tests/gen/quickInfoCloduleWithRecursiveReference_test.go @@ -0,0 +1,26 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestQuickInfoCloduleWithRecursiveReference(t *testing.T) { + t.Parallel() + t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `module M { + export class C { + foo() { } + } + export module C { + export var /**/C = M.C + } +}` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.VerifyQuickInfoAt(t, "", "var M.C.C: typeof M.C", "") + f.VerifyNoErrors(t) +} diff --git a/pkg/fourslash/tests/gen/quickInfoGenericCombinators2_test.go b/pkg/fourslash/tests/gen/quickInfoGenericCombinators2_test.go new file mode 100644 index 000000000..d506cf32a --- /dev/null +++ b/pkg/fourslash/tests/gen/quickInfoGenericCombinators2_test.go @@ -0,0 +1,102 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestQuickInfoGenericCombinators2(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `interface Collection { + length: number; + add(x: T, y: U): void ; + remove(x: T, y: U): boolean; +} + +interface Combinators { + map(c: Collection, f: (x: T, y: U) => V): Collection; + map(c: Collection, f: (x: T, y: U) => any): Collection; +} + +class A { + foo(): T { return null; } +} + +class B { + foo(x: T): T { return null; } +} + +var c1: Collection; +var c2: Collection; +var c3: Collection, string>; +var c4: Collection; +var c5: Collection>; + +var _: Combinators; +// param help on open paren for arg 2 should show 'number' not T or 'any' +// x should be contextually typed to number +var rf1 = (x: number, y: string) => { return x.toFixed() }; +var rf2 = (x: Collection, y: string) => { return x.length }; +var rf3 = (x: number, y: A) => { return y.foo() }; + +var /*9*/r1a = _.map/*1c*/(c2, (/*1a*/x, /*1b*/y) => { return x.toFixed() }); +var /*10*/r1b = _.map(c2, rf1); + +var /*11*/r2a = _.map(c3, (/*2a*/x, /*2b*/y) => { return x.length }); +var /*12*/r2b = _.map(c3, rf2); + +var /*13*/r3a = _.map(c4, (/*3a*/x, /*3b*/y) => { return y.foo() }); +var /*14*/r3b = _.map(c4, rf3); + +var /*15*/r4a = _.map(c5, (/*4a*/x, /*4b*/y) => { return y.foo() }); + +var /*17*/r5a = _.map(c2, /*17error1*/(/*5a*/x, /*5b*/y) => { return x.toFixed() }/*17error2*/); +var rf1b = (x: number, y: string) => { return new Date() }; +var /*18*/r5b = _.map(c2, rf1b); + +var /*19*/r6a = _.map, string, Date>(c3, (/*6a*/x,/*6b*/y) => { return new Date(); }); +var rf2b = (x: Collection, y: string) => { return new Date(); }; +var /*20*/r6b = _.map, string, Date>(c3, rf2b); + +var /*21*/r7a = _.map(c4, (/*7a*/x,/*7b*/y) => { return y.foo() }); +var /*22*/r7b = _.map(c4, /*22error1*/rf3/*22error2*/); + +var /*23*/r8a = _.map(c5, (/*8a*/x,/*8b*/y) => { return y.foo() }); ` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.VerifyQuickInfoAt(t, "2a", "(parameter) x: Collection", "") + f.VerifyQuickInfoAt(t, "2b", "(parameter) y: string", "") + f.VerifyQuickInfoAt(t, "3a", "(parameter) x: number", "") + f.VerifyQuickInfoAt(t, "3b", "(parameter) y: A", "") + f.VerifyQuickInfoAt(t, "4a", "(parameter) x: number", "") + f.VerifyQuickInfoAt(t, "4b", "(parameter) y: B", "") + f.VerifyQuickInfoAt(t, "5a", "(parameter) x: number", "") + f.VerifyQuickInfoAt(t, "5b", "(parameter) y: string", "") + f.VerifyQuickInfoAt(t, "6a", "(parameter) x: Collection", "") + f.VerifyQuickInfoAt(t, "6b", "(parameter) y: string", "") + f.VerifyQuickInfoAt(t, "7a", "(parameter) x: number", "") + f.VerifyQuickInfoAt(t, "7b", "(parameter) y: A", "") + f.VerifyQuickInfoAt(t, "8a", "(parameter) x: number", "") + f.VerifyQuickInfoAt(t, "8b", "(parameter) y: any", "") + f.VerifyQuickInfoAt(t, "9", "var r1a: Collection", "") + f.VerifyQuickInfoAt(t, "10", "var r1b: Collection", "") + f.VerifyQuickInfoAt(t, "11", "var r2a: Collection, number>", "") + f.VerifyQuickInfoAt(t, "12", "var r2b: Collection, number>", "") + f.VerifyQuickInfoAt(t, "13", "var r3a: Collection", "") + f.VerifyQuickInfoAt(t, "14", "var r3b: Collection", "") + f.VerifyQuickInfoAt(t, "15", "var r4a: Collection", "") + f.VerifyQuickInfoAt(t, "17", "var r5a: Collection", "") + f.VerifyQuickInfoAt(t, "18", "var r5b: Collection", "") + f.VerifyQuickInfoAt(t, "19", "var r6a: Collection, Date>", "") + f.VerifyQuickInfoAt(t, "20", "var r6b: Collection, Date>", "") + f.VerifyQuickInfoAt(t, "21", "var r7a: Collection", "") + f.VerifyQuickInfoAt(t, "22", "var r7b: Collection", "") + f.VerifyQuickInfoAt(t, "23", "var r8a: Collection", "") + f.VerifyErrorExistsBetweenMarkers(t, "error1", "error2") + f.VerifyErrorExistsBetweenMarkers(t, "17error1", "17error2") + f.VerifyErrorExistsBetweenMarkers(t, "22error1", "22error2") +} diff --git a/pkg/fourslash/tests/gen/quickInfoGenericTypeArgumentInference1_test.go b/pkg/fourslash/tests/gen/quickInfoGenericTypeArgumentInference1_test.go new file mode 100644 index 000000000..c75eb47f2 --- /dev/null +++ b/pkg/fourslash/tests/gen/quickInfoGenericTypeArgumentInference1_test.go @@ -0,0 +1,41 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestQuickInfoGenericTypeArgumentInference1(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `module Underscore { + export interface Iterator { + (value: T, index: any, list: any): U; + } + + export interface Static { + all(list: T[], iterator?: Iterator, context?: any): T; + identity(value: T): T; + } +} + +declare var _: Underscore.Static; +var /*1*/r = _./*11*/all([true, 1, null, 'yes'], x => !x); +var /*2*/r2 = _./*21*/all([true], _.identity); +var /*3*/r3 = _./*31*/all([], _.identity); +var /*4*/r4 = _./*41*/all([true], _.identity);` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.VerifyQuickInfoAt(t, "1", "var r: string | number | boolean", "") + f.VerifyQuickInfoAt(t, "11", "(method) Underscore.Static.all(list: (string | number | boolean)[], iterator?: Underscore.Iterator, context?: any): string | number | boolean", "") + f.VerifyQuickInfoAt(t, "2", "var r2: boolean", "") + f.VerifyQuickInfoAt(t, "21", "(method) Underscore.Static.all(list: boolean[], iterator?: Underscore.Iterator, context?: any): boolean", "") + f.VerifyQuickInfoAt(t, "3", "var r3: any", "") + f.VerifyQuickInfoAt(t, "31", "(method) Underscore.Static.all(list: any[], iterator?: Underscore.Iterator, context?: any): any", "") + f.VerifyQuickInfoAt(t, "4", "var r4: any", "") + f.VerifyQuickInfoAt(t, "41", "(method) Underscore.Static.all(list: any[], iterator?: Underscore.Iterator, context?: any): any", "") + f.VerifyNoErrors(t) +} diff --git a/pkg/fourslash/tests/gen/quickInfoInheritedLinkTag_test.go b/pkg/fourslash/tests/gen/quickInfoInheritedLinkTag_test.go new file mode 100644 index 000000000..f30349f7b --- /dev/null +++ b/pkg/fourslash/tests/gen/quickInfoInheritedLinkTag_test.go @@ -0,0 +1,28 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestQuickInfoInheritedLinkTag(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `export class C { + /** + * @deprecated Use {@link PerspectiveCamera#setFocalLength .setFocalLength()} and {@link PerspectiveCamera#filmGauge .filmGauge} instead. + */ + m() { } +} +export class D extends C { + m() { } // crashes here +} +new C().m/**/ // and here (with a different thing trying to access undefined)` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.VerifyNoErrors(t) + f.VerifyBaselineHover(t) +} diff --git a/pkg/fourslash/tests/gen/quickInfoJsdocEnum_test.go b/pkg/fourslash/tests/gen/quickInfoJsdocEnum_test.go new file mode 100644 index 000000000..e7279435b --- /dev/null +++ b/pkg/fourslash/tests/gen/quickInfoJsdocEnum_test.go @@ -0,0 +1,32 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestQuickInfoJsdocEnum(t *testing.T) { + t.Parallel() + t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @allowJs: true +// @noLib: true +// @Filename: /a.js +/** + * Doc + * @enum {number} + */ +const E = { + A: 0, +} + +/** @type {/*type*/E} */ +const x = /*value*/E.A;` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.VerifyNoErrors(t) + f.VerifyQuickInfoAt(t, "type", "type E = number", "Doc") + f.VerifyQuickInfoAt(t, "value", "const E: {\n A: number;\n}", "Doc") +} diff --git a/pkg/fourslash/tests/gen/quickInfoLink2_test.go b/pkg/fourslash/tests/gen/quickInfoLink2_test.go new file mode 100644 index 000000000..9512a1db1 --- /dev/null +++ b/pkg/fourslash/tests/gen/quickInfoLink2_test.go @@ -0,0 +1,25 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestQuickInfoLink2(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @checkJs: true +// @Filename: quickInfoLink2.js +/** + * @typedef AdditionalWallabyConfig/**/ Additional valid Wallaby config properties + * that aren't defined in {@link IWallabyConfig}. + * @property {boolean} autoDetect + */` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.VerifyNoErrors(t) + f.VerifyBaselineHover(t) +} diff --git a/pkg/fourslash/tests/gen/quickInfoLink3_test.go b/pkg/fourslash/tests/gen/quickInfoLink3_test.go new file mode 100644 index 000000000..fe0292126 --- /dev/null +++ b/pkg/fourslash/tests/gen/quickInfoLink3_test.go @@ -0,0 +1,29 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestQuickInfoLink3(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `class Foo { + /** + * {@link Foo} + * {@link Foo} + * {@link Foo>} + * {@link Foo<>} + * {@link Foo>} + * {@link Foo<} + */ + bar/**/(){} +}` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.VerifyNoErrors(t) + f.VerifyBaselineHover(t) +} diff --git a/pkg/fourslash/tests/gen/quickInfoLink4_test.go b/pkg/fourslash/tests/gen/quickInfoLink4_test.go new file mode 100644 index 000000000..93d20addd --- /dev/null +++ b/pkg/fourslash/tests/gen/quickInfoLink4_test.go @@ -0,0 +1,26 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestQuickInfoLink4(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `type A = 1 | 2; + +switch (0 as A) { + /** {@link /**/A} */ + case 1: + case 2: + break; +}` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.VerifyNoErrors(t) + f.VerifyBaselineHover(t) +} diff --git a/pkg/fourslash/tests/gen/quickInfoLinkCodePlain_test.go b/pkg/fourslash/tests/gen/quickInfoLinkCodePlain_test.go new file mode 100644 index 000000000..76601316b --- /dev/null +++ b/pkg/fourslash/tests/gen/quickInfoLinkCodePlain_test.go @@ -0,0 +1,25 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestQuickInfoLinkCodePlain(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `export class C { + /** + * @deprecated Use {@linkplain PerspectiveCamera#setFocalLength .setFocalLength()} and {@linkcode PerspectiveCamera#filmGauge .filmGauge} instead. + */ + m() { } +} +new C().m/**/` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.VerifyNoErrors(t) + f.VerifyBaselineHover(t) +} diff --git a/pkg/fourslash/tests/gen/quickInfoMeaning_test.go b/pkg/fourslash/tests/gen/quickInfoMeaning_test.go new file mode 100644 index 000000000..18e42bec8 --- /dev/null +++ b/pkg/fourslash/tests/gen/quickInfoMeaning_test.go @@ -0,0 +1,96 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + . "github.com/buke/typescript-go-internal/pkg/fourslash/tests/util" + "github.com/buke/typescript-go-internal/pkg/lsp/lsproto" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestQuickInfoMeaning(t *testing.T) { + t.Parallel() + t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @Filename: foo.d.ts +declare const [|/*foo_value_declaration*/foo: number|]; +[|declare module "foo_module" { + interface /*foo_type_declaration*/I { x: number; y: number } + export = I; +}|] +// @Filename: foo_user.ts +/// +[|import foo = require("foo_module");|] +const x = foo/*foo_value*/; +const i: foo/*foo_type*/ = { x: 1, y: 2 }; +// @Filename: bar.d.ts +[|declare interface /*bar_type_declaration*/bar { x: number; y: number }|] +[|declare module "bar_module" { + const /*bar_value_declaration*/x: number; + export = x; +}|] +// @Filename: bar_user.ts +/// +[|import bar = require("bar_module");|] +const x = bar/*bar_value*/; +const i: bar/*bar_type*/ = { x: 1, y: 2 };` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.VerifyNoErrors(t) + f.VerifyWorkspaceSymbol(t, []*fourslash.VerifyWorkspaceSymbolCase{ + { + Pattern: "foo", + Preferences: nil, + Exact: PtrTo([]*lsproto.SymbolInformation{ + { + Name: "foo", + Kind: lsproto.SymbolKindVariable, + Location: f.Ranges()[0].LSLocation(), + }, + { + Name: "foo", + Kind: lsproto.SymbolKindVariable, + Location: f.Ranges()[2].LSLocation(), + }, + { + Name: "foo_module", + Kind: lsproto.SymbolKindNamespace, + Location: f.Ranges()[1].LSLocation(), + }, + }), + }, + }) + f.GoToMarker(t, "foo_value") + f.VerifyQuickInfoIs(t, "const foo: number", "") + f.GoToMarker(t, "foo_type") + f.VerifyQuickInfoIs(t, "(alias) interface foo\nimport foo = require(\"foo_module\")", "") + f.VerifyWorkspaceSymbol(t, []*fourslash.VerifyWorkspaceSymbolCase{ + { + Pattern: "bar", + Preferences: nil, + Exact: PtrTo([]*lsproto.SymbolInformation{ + { + Name: "bar", + Kind: lsproto.SymbolKindInterface, + Location: f.Ranges()[3].LSLocation(), + }, + { + Name: "bar", + Kind: lsproto.SymbolKindVariable, + Location: f.Ranges()[5].LSLocation(), + }, + { + Name: "bar_module", + Kind: lsproto.SymbolKindNamespace, + Location: f.Ranges()[4].LSLocation(), + }, + }), + }, + }) + f.GoToMarker(t, "bar_value") + f.VerifyQuickInfoIs(t, "(alias) const bar: number\nimport bar = require(\"bar_module\")", "") + f.GoToMarker(t, "bar_type") + f.VerifyQuickInfoIs(t, "interface bar", "") + f.VerifyBaselineGoToDefinition(t, false, "foo_value", "foo_type", "bar_value", "bar_type") +} diff --git a/pkg/fourslash/tests/gen/quickInfoOnMergedInterfacesWithIncrementalEdits_test.go b/pkg/fourslash/tests/gen/quickInfoOnMergedInterfacesWithIncrementalEdits_test.go new file mode 100644 index 000000000..3a983a73a --- /dev/null +++ b/pkg/fourslash/tests/gen/quickInfoOnMergedInterfacesWithIncrementalEdits_test.go @@ -0,0 +1,39 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestQuickInfoOnMergedInterfacesWithIncrementalEdits(t *testing.T) { + t.Parallel() + t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `module MM { + interface B { + foo: number; + } + interface B { + bar: string; + } + var b: B; + var r3 = b.foo; // number + var r/*2*/4 = b.b/*1*/ar; // string +}` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.GoToMarker(t, "1") + f.VerifyQuickInfoIs(t, "(property) B.bar: string", "") + f.DeleteAtCaret(t, 1) + f.Insert(t, "z") + f.VerifyQuickInfoIs(t, "any", "") + f.VerifyNumberOfErrorsInCurrentFile(t, 1) + f.Backspace(t, 1) + f.Insert(t, "a") + f.VerifyQuickInfoIs(t, "(property) B.bar: string", "") + f.GoToMarker(t, "2") + f.VerifyQuickInfoIs(t, "var r4: string", "") + f.VerifyNoErrors(t) +} diff --git a/pkg/fourslash/tests/gen/quickInfoOnMergedModule_test.go b/pkg/fourslash/tests/gen/quickInfoOnMergedModule_test.go new file mode 100644 index 000000000..7a21f0e9d --- /dev/null +++ b/pkg/fourslash/tests/gen/quickInfoOnMergedModule_test.go @@ -0,0 +1,32 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestQuickInfoOnMergedModule(t *testing.T) { + t.Parallel() + t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `module M2 { + export interface A { + foo: string; + } + var a: A; + var r = a.foo + a.bar; +} +module M2 { + export interface A { + bar: number; + } + var a: A; + var r = a.fo/*1*/o + a.bar; +}` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.VerifyQuickInfoAt(t, "1", "(property) M2.A.foo: string", "") + f.VerifyNoErrors(t) +} diff --git a/pkg/fourslash/tests/gen/quickInfoThrowsTag_test.go b/pkg/fourslash/tests/gen/quickInfoThrowsTag_test.go new file mode 100644 index 000000000..2ad343dcf --- /dev/null +++ b/pkg/fourslash/tests/gen/quickInfoThrowsTag_test.go @@ -0,0 +1,37 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestQuickInfoThrowsTag(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `class E extends Error {} + +/** + * @throws {E} + */ +function f1() {} + +/** + * @throws {E} description + */ +function f2() {} + +/** + * @throws description + */ +function f3() {} +f1/*1*/() +f2/*2*/() +f3/*3*/()` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.VerifyNoErrors(t) + f.VerifyBaselineHover(t) +} diff --git a/pkg/fourslash/tests/gen/quickInfoUntypedModuleImport_test.go b/pkg/fourslash/tests/gen/quickInfoUntypedModuleImport_test.go new file mode 100644 index 000000000..be1f508bf --- /dev/null +++ b/pkg/fourslash/tests/gen/quickInfoUntypedModuleImport_test.go @@ -0,0 +1,29 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestQuickInfoUntypedModuleImport(t *testing.T) { + t.Parallel() + t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @Filename: node_modules/foo/index.js + /*index*/{} +// @Filename: a.ts +import /*foo*/foo from /*fooModule*/"foo"; +/*fooCall*/foo();` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.GoToFile(t, "a.ts") + f.VerifyNumberOfErrorsInCurrentFile(t, 0) + f.GoToMarker(t, "fooModule") + f.VerifyQuickInfoIs(t, "", "") + f.GoToMarker(t, "foo") + f.VerifyQuickInfoIs(t, "import foo", "") + f.VerifyBaselineFindAllReferences(t, "foo", "fooModule", "fooCall") + f.VerifyBaselineGoToDefinition(t, false, "fooModule", "foo") +} diff --git a/pkg/fourslash/tests/gen/referencesForAmbients2_test.go b/pkg/fourslash/tests/gen/referencesForAmbients2_test.go new file mode 100644 index 000000000..3b6dad2cd --- /dev/null +++ b/pkg/fourslash/tests/gen/referencesForAmbients2_test.go @@ -0,0 +1,32 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestReferencesForAmbients2(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @Filename: /defA.ts +declare module "a" { + /*1*/export type /*2*/T = number; +} +// @Filename: /defB.ts +declare module "b" { + export import a = require("a"); + export const x: a./*3*/T; +} +// @Filename: /defC.ts +declare module "c" { + import b = require("b"); + const x: b.a./*4*/T; +}` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.VerifyNoErrors(t) + f.VerifyBaselineFindAllReferences(t, "1", "2", "3", "4") +} diff --git a/pkg/fourslash/tests/gen/removeDeclareFunctionExports_test.go b/pkg/fourslash/tests/gen/removeDeclareFunctionExports_test.go new file mode 100644 index 000000000..804fe8310 --- /dev/null +++ b/pkg/fourslash/tests/gen/removeDeclareFunctionExports_test.go @@ -0,0 +1,22 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestRemoveDeclareFunctionExports(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `declare module M { + function RegExp2(pattern: string): RegExp2; + export function RegExp2(pattern: string, flags: string): RegExp2; +}` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.GoToBOF(t) + f.DeleteAtCaret(t, 8) +} diff --git a/pkg/fourslash/tests/gen/removeDeclareInModule_test.go b/pkg/fourslash/tests/gen/removeDeclareInModule_test.go new file mode 100644 index 000000000..22e9e9907 --- /dev/null +++ b/pkg/fourslash/tests/gen/removeDeclareInModule_test.go @@ -0,0 +1,24 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestRemoveDeclareInModule(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `/**/export module Foo { + function a(): void {} +} + +Foo.a();` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.GoToMarker(t, "") + f.DeleteAtCaret(t, 7) + f.VerifyNumberOfErrorsInCurrentFile(t, 1) +} diff --git a/pkg/fourslash/tests/gen/removeDeclareKeyword_test.go b/pkg/fourslash/tests/gen/removeDeclareKeyword_test.go new file mode 100644 index 000000000..18b085df0 --- /dev/null +++ b/pkg/fourslash/tests/gen/removeDeclareKeyword_test.go @@ -0,0 +1,20 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestRemoveDeclareKeyword(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `/**/declare var y; +var x = new y;` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.GoToMarker(t, "") + f.DeleteAtCaret(t, 7) +} diff --git a/pkg/fourslash/tests/gen/removeDeclareParamTypeAnnotation_test.go b/pkg/fourslash/tests/gen/removeDeclareParamTypeAnnotation_test.go new file mode 100644 index 000000000..6736a6d9f --- /dev/null +++ b/pkg/fourslash/tests/gen/removeDeclareParamTypeAnnotation_test.go @@ -0,0 +1,21 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestRemoveDeclareParamTypeAnnotation(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `declare class T { } +declare function parseInt(/**/s:T):T; +parseInt('2');` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.GoToMarker(t, "") + f.DeleteAtCaret(t, 3) +} diff --git a/pkg/fourslash/tests/gen/removeDuplicateIdentifier_test.go b/pkg/fourslash/tests/gen/removeDuplicateIdentifier_test.go new file mode 100644 index 000000000..22932df66 --- /dev/null +++ b/pkg/fourslash/tests/gen/removeDuplicateIdentifier_test.go @@ -0,0 +1,20 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestRemoveDuplicateIdentifier(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `class foo{} +function foo() { return null; }` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.GoToBOF(t) + f.DeleteAtCaret(t, 11) +} diff --git a/pkg/fourslash/tests/gen/removeExportedClassFromReopenedModule_test.go b/pkg/fourslash/tests/gen/removeExportedClassFromReopenedModule_test.go new file mode 100644 index 000000000..c45b2c2c1 --- /dev/null +++ b/pkg/fourslash/tests/gen/removeExportedClassFromReopenedModule_test.go @@ -0,0 +1,27 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestRemoveExportedClassFromReopenedModule(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `module multiM { } + +module multiM { + /*1*/export class c { } +} +` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.GoToMarker(t, "1") + f.DeleteAtCaret(t, 18) + f.GoToEOF(t) + f.Insert(t, "new multiM.c();") + f.VerifyNumberOfErrorsInCurrentFile(t, 1) +} diff --git a/pkg/fourslash/tests/gen/removeInterfaceExtendsClause_test.go b/pkg/fourslash/tests/gen/removeInterfaceExtendsClause_test.go new file mode 100644 index 000000000..c628cd561 --- /dev/null +++ b/pkg/fourslash/tests/gen/removeInterfaceExtendsClause_test.go @@ -0,0 +1,20 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestRemoveInterfaceExtendsClause(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `interface IFoo { } +interface Array /**/extends IFoo { }` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.GoToMarker(t, "") + f.DeleteAtCaret(t, 15) +} diff --git a/pkg/fourslash/tests/gen/removeInterfaceUsedAsGenericTypeArgument_test.go b/pkg/fourslash/tests/gen/removeInterfaceUsedAsGenericTypeArgument_test.go new file mode 100644 index 000000000..96789e6cb --- /dev/null +++ b/pkg/fourslash/tests/gen/removeInterfaceUsedAsGenericTypeArgument_test.go @@ -0,0 +1,21 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestRemoveInterfaceUsedAsGenericTypeArgument(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `/**/interface A { a: string; } +interface G { } +var v1: G;` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.GoToMarker(t, "") + f.DeleteAtCaret(t, 26) +} diff --git a/pkg/fourslash/tests/gen/removeParameterBetweenCommentAndParameter_test.go b/pkg/fourslash/tests/gen/removeParameterBetweenCommentAndParameter_test.go new file mode 100644 index 000000000..1073bacf1 --- /dev/null +++ b/pkg/fourslash/tests/gen/removeParameterBetweenCommentAndParameter_test.go @@ -0,0 +1,19 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestRemoveParameterBetweenCommentAndParameter(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `function fn(/* comment! */ /**/a: number, c) { }` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.GoToMarker(t, "") + f.DeleteAtCaret(t, 10) +} diff --git a/pkg/fourslash/tests/gen/removeVarFromModuleWithReopenedEnums_test.go b/pkg/fourslash/tests/gen/removeVarFromModuleWithReopenedEnums_test.go new file mode 100644 index 000000000..37da36c6e --- /dev/null +++ b/pkg/fourslash/tests/gen/removeVarFromModuleWithReopenedEnums_test.go @@ -0,0 +1,28 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestRemoveVarFromModuleWithReopenedEnums(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `module A { + /**/var o; +} +enum A { +} +enum A { +} +module A { + var p; +}` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.GoToMarker(t, "") + f.DeleteAtCaret(t, 6) +} diff --git a/pkg/fourslash/tests/gen/renameDestructuringAssignmentInForOf_test.go b/pkg/fourslash/tests/gen/renameDestructuringAssignmentInForOf_test.go new file mode 100644 index 000000000..69cd977ad --- /dev/null +++ b/pkg/fourslash/tests/gen/renameDestructuringAssignmentInForOf_test.go @@ -0,0 +1,30 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestRenameDestructuringAssignmentInForOf(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `interface I { + [|[|{| "contextRangeIndex": 0 |}property1|]: number;|] + property2: string; +} +var elems: I[]; + +var [|[|{| "contextRangeIndex": 2 |}property1|]: number|], p2: number; +for ([|{ [|{| "contextRangeIndex": 4 |}property1|] } of elems|]) { + [|property1|]++; +} +for ([|{ [|{| "contextRangeIndex": 7 |}property1|]: p2 } of elems|]) { +}` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.VerifyNoErrors(t) + f.VerifyBaselineRename(t, nil /*preferences*/, f.Ranges()[1], f.Ranges()[8], f.Ranges()[3], f.Ranges()[5], f.Ranges()[6]) +} diff --git a/pkg/fourslash/tests/gen/renameDestructuringAssignmentInFor_test.go b/pkg/fourslash/tests/gen/renameDestructuringAssignmentInFor_test.go new file mode 100644 index 000000000..06412e878 --- /dev/null +++ b/pkg/fourslash/tests/gen/renameDestructuringAssignmentInFor_test.go @@ -0,0 +1,30 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestRenameDestructuringAssignmentInFor(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `interface I { + [|[|{| "contextRangeIndex": 0 |}property1|]: number;|] + property2: string; +} +var elems: I[]; + +var p2: number, [|[|{| "contextRangeIndex": 2 |}property1|]: number|]; +for ([|{ [|{| "contextRangeIndex": 4 |}property1|] } = elems[0]|]; p2 < 100; p2++) { + p2 = [|property1|]++; +} +for ([|{ [|{| "contextRangeIndex": 7 |}property1|]: p2 } = elems[0]|]; p2 < 100; p2++) { +}` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.VerifyNoErrors(t) + f.VerifyBaselineRename(t, nil /*preferences*/, f.Ranges()[1], f.Ranges()[8], f.Ranges()[3], f.Ranges()[5], f.Ranges()[6]) +} diff --git a/pkg/fourslash/tests/gen/renameDestructuringAssignmentNestedInFor2_test.go b/pkg/fourslash/tests/gen/renameDestructuringAssignmentNestedInFor2_test.go new file mode 100644 index 000000000..38b71ece0 --- /dev/null +++ b/pkg/fourslash/tests/gen/renameDestructuringAssignmentNestedInFor2_test.go @@ -0,0 +1,32 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestRenameDestructuringAssignmentNestedInFor2(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `interface MultiRobot { + name: string; + skills: { + [|[|{| "contextRangeIndex": 0 |}primary|]: string;|] + secondary: string; + }; +} +let multiRobot: MultiRobot, [|[|{| "contextRangeIndex": 2 |}primary|]: string|], secondary: string, primaryA: string, secondaryA: string, i: number; +for ([|{ skills: { [|{| "contextRangeIndex": 4 |}primary|]: primaryA, secondary: secondaryA } } = multiRobot|], i = 0; i < 1; i++) { + primaryA; +} +for ([|{ skills: { [|{| "contextRangeIndex": 6 |}primary|], secondary } } = multiRobot|], i = 0; i < 1; i++) { + [|primary|]; +}` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.VerifyNoErrors(t) + f.VerifyBaselineRename(t, nil /*preferences*/, f.Ranges()[1], f.Ranges()[5], f.Ranges()[3], f.Ranges()[7], f.Ranges()[8]) +} diff --git a/pkg/fourslash/tests/gen/renameDestructuringAssignmentNestedInForOf_test.go b/pkg/fourslash/tests/gen/renameDestructuringAssignmentNestedInForOf_test.go new file mode 100644 index 000000000..e179c713b --- /dev/null +++ b/pkg/fourslash/tests/gen/renameDestructuringAssignmentNestedInForOf_test.go @@ -0,0 +1,33 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestRenameDestructuringAssignmentNestedInForOf(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `interface MultiRobot { + name: string; + skills: { + [|[|{| "contextRangeIndex": 0 |}primary|]: string;|] + secondary: string; + }; +} +let multiRobots: MultiRobot[]; +let [|[|{| "contextRangeIndex": 2 |}primary|]: string|], secondary: string, primaryA: string, secondaryA: string; +for ([|{ skills: { [|{| "contextRangeIndex": 4 |}primary|]: primaryA, secondary: secondaryA } } of multiRobots|]) { + primaryA; +} +for ([|{ skills: { [|{| "contextRangeIndex": 6 |}primary|], secondary } } of multiRobots|]) { + [|primary|]; +}` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.VerifyNoErrors(t) + f.VerifyBaselineRename(t, nil /*preferences*/, f.Ranges()[1], f.Ranges()[5], f.Ranges()[3], f.Ranges()[7], f.Ranges()[8]) +} diff --git a/pkg/fourslash/tests/gen/renameDestructuringAssignmentNestedInFor_test.go b/pkg/fourslash/tests/gen/renameDestructuringAssignmentNestedInFor_test.go new file mode 100644 index 000000000..562085a35 --- /dev/null +++ b/pkg/fourslash/tests/gen/renameDestructuringAssignmentNestedInFor_test.go @@ -0,0 +1,32 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestRenameDestructuringAssignmentNestedInFor(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `interface MultiRobot { + name: string; + skills: { + [|[|{| "contextRangeIndex": 0 |}primary|]: string;|] + secondary: string; + }; +} +let multiRobot: MultiRobot, [|[|{| "contextRangeIndex": 2 |}primary|]: string|], secondary: string, primaryA: string, secondaryA: string, i: number; +for ([|{ skills: { [|{| "contextRangeIndex": 4 |}primary|]: primaryA, secondary: secondaryA } } = multiRobot|], i = 0; i < 1; i++) { + primaryA; +} +for ([|{ skills: { [|{| "contextRangeIndex": 6 |}primary|], secondary } } = multiRobot|], i = 0; i < 1; i++) { + [|primary|]; +}` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.VerifyNoErrors(t) + f.VerifyBaselineRename(t, nil /*preferences*/, f.Ranges()[1], f.Ranges()[5], f.Ranges()[3], f.Ranges()[7], f.Ranges()[8]) +} diff --git a/pkg/fourslash/tests/gen/renameImportOfExportEquals2_test.go b/pkg/fourslash/tests/gen/renameImportOfExportEquals2_test.go new file mode 100644 index 000000000..4ffcae71b --- /dev/null +++ b/pkg/fourslash/tests/gen/renameImportOfExportEquals2_test.go @@ -0,0 +1,33 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestRenameImportOfExportEquals2(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `[|declare namespace /*N*/[|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 0 |}N|] { + export var x: number; +}|] +declare module "mod" { + [|export = [|{| "contextRangeIndex": 2 |}N|];|] +} +declare module "a" { + [|import * as /*O*/[|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 4 |}O|] from "mod";|] + [|export { [|{| "contextRangeIndex": 6 |}O|] as /*P*/[|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 6 |}P|] };|] // Renaming N here would rename +} +declare module "b" { + [|import { [|{| "contextRangeIndex": 9 |}P|] as /*Q*/[|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 9 |}Q|] } from "a";|] + export const y: typeof [|Q|].x; +}` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.VerifyNoErrors(t) + f.VerifyBaselineFindAllReferences(t, "N", "O", "P", "Q") + f.VerifyBaselineRenameAtRangesWithText(t, nil /*preferences*/, "N", "O", "P", "Q") +} diff --git a/pkg/fourslash/tests/gen/renameImportOfReExport_test.go b/pkg/fourslash/tests/gen/renameImportOfReExport_test.go new file mode 100644 index 000000000..77e14ef2e --- /dev/null +++ b/pkg/fourslash/tests/gen/renameImportOfReExport_test.go @@ -0,0 +1,32 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestRenameImportOfReExport(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @noLib: true +declare module "a" { + [|export class /*1*/[|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 0 |}C|] {}|] +} +declare module "b" { + [|export { /*2*/[|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 2 |}C|] } from "a";|] +} +declare module "c" { + [|import { /*3*/[|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 4 |}C|] } from "b";|] + export function f(c: [|C|]): void; +}` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.VerifyNoErrors(t) + f.VerifyBaselineFindAllReferences(t, "1", "2", "3") + f.VerifyBaselineRename(t, nil /*preferences*/, f.Ranges()[1]) + f.VerifyBaselineRename(t, nil /*preferences*/, f.Ranges()[3]) + f.VerifyBaselineRename(t, nil /*preferences*/, f.Ranges()[5], f.Ranges()[6]) +} diff --git a/pkg/fourslash/tests/gen/renameModuleToVar_test.go b/pkg/fourslash/tests/gen/renameModuleToVar_test.go new file mode 100644 index 000000000..03a117402 --- /dev/null +++ b/pkg/fourslash/tests/gen/renameModuleToVar_test.go @@ -0,0 +1,29 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestRenameModuleToVar(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `interface IMod { + y: number; +} +declare module/**/ X: IMod;// { +// export var y: numb; +var y: number; +module Y { + var z = y + 5; +}` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.GoToMarker(t, "") + f.Backspace(t, 6) + f.Insert(t, "var") + f.VerifyNoErrors(t) +} diff --git a/pkg/fourslash/tests/gen/semicolonFormattingAfterArrayLiteral_test.go b/pkg/fourslash/tests/gen/semicolonFormattingAfterArrayLiteral_test.go new file mode 100644 index 000000000..93bb0ce28 --- /dev/null +++ b/pkg/fourslash/tests/gen/semicolonFormattingAfterArrayLiteral_test.go @@ -0,0 +1,20 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestSemicolonFormattingAfterArrayLiteral(t *testing.T) { + t.Parallel() + t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `[1,2]/**/` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.GoToMarker(t, "") + f.Insert(t, ";") + f.VerifyCurrentLineContentIs(t, "[1, 2];") +} diff --git a/pkg/fourslash/tests/gen/semicolonFormattingInsideAComment_test.go b/pkg/fourslash/tests/gen/semicolonFormattingInsideAComment_test.go new file mode 100644 index 000000000..9be3d5961 --- /dev/null +++ b/pkg/fourslash/tests/gen/semicolonFormattingInsideAComment_test.go @@ -0,0 +1,20 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestSemicolonFormattingInsideAComment(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = ` ///**/` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.GoToMarker(t, "") + f.Insert(t, ";") + f.VerifyCurrentLineContentIs(t, " //;") +} diff --git a/pkg/fourslash/tests/gen/semicolonFormattingInsideAStringLiteral_test.go b/pkg/fourslash/tests/gen/semicolonFormattingInsideAStringLiteral_test.go new file mode 100644 index 000000000..681e61506 --- /dev/null +++ b/pkg/fourslash/tests/gen/semicolonFormattingInsideAStringLiteral_test.go @@ -0,0 +1,20 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestSemicolonFormattingInsideAStringLiteral(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = ` var x = "string/**/` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.GoToMarker(t, "") + f.Insert(t, ";") + f.VerifyCurrentLineContentIs(t, " var x = \"string;") +} diff --git a/pkg/fourslash/tests/gen/semicolonFormattingNestedStatements_test.go b/pkg/fourslash/tests/gen/semicolonFormattingNestedStatements_test.go new file mode 100644 index 000000000..f85a9f0c8 --- /dev/null +++ b/pkg/fourslash/tests/gen/semicolonFormattingNestedStatements_test.go @@ -0,0 +1,29 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestSemicolonFormattingNestedStatements(t *testing.T) { + t.Parallel() + t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `if (true) +if (true)/*parentOutsideBlock*/ +if (true) { +if (true)/*directParent*/ +var x = 0/*innermost*/ +}` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.GoToMarker(t, "innermost") + f.Insert(t, ";") + f.VerifyCurrentLineContentIs(t, " var x = 0;") + f.GoToMarker(t, "directParent") + f.VerifyCurrentLineContentIs(t, " if (true)") + f.GoToMarker(t, "parentOutsideBlock") + f.VerifyCurrentLineContentIs(t, "if (true)") +} diff --git a/pkg/fourslash/tests/gen/semicolonFormatting_test.go b/pkg/fourslash/tests/gen/semicolonFormatting_test.go new file mode 100644 index 000000000..f451184c5 --- /dev/null +++ b/pkg/fourslash/tests/gen/semicolonFormatting_test.go @@ -0,0 +1,20 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestSemicolonFormatting(t *testing.T) { + t.Parallel() + t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `/**/function of1 (b:{r:{c:number` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.GoToEOF(t) + f.Insert(t, ";") + f.VerifyCurrentLineContentIs(t, "function of1(b: { r: { c: number;") +} diff --git a/pkg/fourslash/tests/gen/signatureHelpCallExpressionJs_test.go b/pkg/fourslash/tests/gen/signatureHelpCallExpressionJs_test.go new file mode 100644 index 000000000..97e7cb3fb --- /dev/null +++ b/pkg/fourslash/tests/gen/signatureHelpCallExpressionJs_test.go @@ -0,0 +1,31 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestSignatureHelpCallExpressionJs(t *testing.T) { + t.Parallel() + t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @checkJs: true +// @allowJs: true +// @Filename: main.js +function allOptional() { arguments; } +allOptional(/*1*/); +allOptional(1, 2, 3); +function someOptional(x, y) { arguments; } +someOptional(/*2*/); +someOptional(1, 2, 3); +someOptional(); // no error here; x and y are optional in JS` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.VerifyNoErrors(t) + f.GoToMarker(t, "1") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{Text: "allOptional(...args: any[]): void", ParameterCount: 1, ParameterName: "args", ParameterSpan: "...args: any[]", IsVariadic: true, IsVariadicSet: true}) + f.GoToMarker(t, "2") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{Text: "someOptional(x: any, y: any, ...args: any[]): void", ParameterCount: 3, ParameterName: "x", ParameterSpan: "x: any", IsVariadic: true, IsVariadicSet: true}) +} diff --git a/pkg/fourslash/tests/gen/singleLineTypeLiteralFormatting_test.go b/pkg/fourslash/tests/gen/singleLineTypeLiteralFormatting_test.go new file mode 100644 index 000000000..b3ae1182b --- /dev/null +++ b/pkg/fourslash/tests/gen/singleLineTypeLiteralFormatting_test.go @@ -0,0 +1,20 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestSingleLineTypeLiteralFormatting(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `function of1(b: { r: { c: number/**/` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.GoToMarker(t, "") + f.Insert(t, ";") + f.VerifyCurrentLineContentIs(t, "function of1(b: { r: { c: number;") +} diff --git a/pkg/fourslash/tests/gen/spaceAfterConstructor_test.go b/pkg/fourslash/tests/gen/spaceAfterConstructor_test.go new file mode 100644 index 000000000..60eeb0460 --- /dev/null +++ b/pkg/fourslash/tests/gen/spaceAfterConstructor_test.go @@ -0,0 +1,25 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestSpaceAfterConstructor(t *testing.T) { + t.Parallel() + t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `export class myController { + private _processId; + constructor (processId: number) {/*1*/ + this._processId = processId; + }/*2*/` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.GoToMarker(t, "2") + f.Insert(t, "}") + f.GoToMarker(t, "1") + f.VerifyCurrentLineContentIs(t, " constructor(processId: number) {") +} diff --git a/pkg/fourslash/tests/gen/squiggleIllegalClassExtension_test.go b/pkg/fourslash/tests/gen/squiggleIllegalClassExtension_test.go new file mode 100644 index 000000000..8c0207f93 --- /dev/null +++ b/pkg/fourslash/tests/gen/squiggleIllegalClassExtension_test.go @@ -0,0 +1,19 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestSquiggleIllegalClassExtension(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `class Foo extends /*1*/Bar/*2*/ { }` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.VerifyErrorExistsBetweenMarkers(t, "1", "2") + f.VerifyNumberOfErrorsInCurrentFile(t, 1) +} diff --git a/pkg/fourslash/tests/gen/squiggleIllegalSubclassOverride_test.go b/pkg/fourslash/tests/gen/squiggleIllegalSubclassOverride_test.go new file mode 100644 index 000000000..bdb855eed --- /dev/null +++ b/pkg/fourslash/tests/gen/squiggleIllegalSubclassOverride_test.go @@ -0,0 +1,25 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestSquiggleIllegalSubclassOverride(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `class Foo { + public x: number; +} + +class Bar extends Foo { + public /*1*/x/*2*/: string = 'hi'; +}` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.VerifyErrorExistsBetweenMarkers(t, "1", "2") + f.VerifyNumberOfErrorsInCurrentFile(t, 1) +} diff --git a/pkg/fourslash/tests/gen/superInDerivedTypeOfGenericWithStatics_test.go b/pkg/fourslash/tests/gen/superInDerivedTypeOfGenericWithStatics_test.go new file mode 100644 index 000000000..034fe0e62 --- /dev/null +++ b/pkg/fourslash/tests/gen/superInDerivedTypeOfGenericWithStatics_test.go @@ -0,0 +1,31 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestSuperInDerivedTypeOfGenericWithStatics(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `module M { + export class C { + static foo(): C { + return null; + } + } +} +class D extends M.C { + constructor() { + /**/ // was an error appearing on super in editing scenarios + } +}` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.GoToMarker(t, "") + f.Insert(t, "super();") + f.VerifyNoErrors(t) +} diff --git a/pkg/fourslash/tests/gen/tabbingAfterNewlineInsertedBeforeWhile_test.go b/pkg/fourslash/tests/gen/tabbingAfterNewlineInsertedBeforeWhile_test.go new file mode 100644 index 000000000..78fbce24f --- /dev/null +++ b/pkg/fourslash/tests/gen/tabbingAfterNewlineInsertedBeforeWhile_test.go @@ -0,0 +1,22 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestTabbingAfterNewlineInsertedBeforeWhile(t *testing.T) { + t.Parallel() + t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `function foo() { + /**/while (true) { } +}` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.GoToMarker(t, "") + f.InsertLine(t, "") + f.VerifyCurrentLineContentIs(t, " while (true) { }") +} diff --git a/pkg/fourslash/tests/gen/toggleDuplicateFunctionDeclaration_test.go b/pkg/fourslash/tests/gen/toggleDuplicateFunctionDeclaration_test.go new file mode 100644 index 000000000..964acd658 --- /dev/null +++ b/pkg/fourslash/tests/gen/toggleDuplicateFunctionDeclaration_test.go @@ -0,0 +1,22 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestToggleDuplicateFunctionDeclaration(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `class D { } +D();` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.GoToBOF(t) + f.Insert(t, "declare function D();") + f.GoToBOF(t) + f.DeleteAtCaret(t, 21) +} diff --git a/pkg/fourslash/tests/gen/transitiveExportImports2_test.go b/pkg/fourslash/tests/gen/transitiveExportImports2_test.go new file mode 100644 index 000000000..5eba2b7e4 --- /dev/null +++ b/pkg/fourslash/tests/gen/transitiveExportImports2_test.go @@ -0,0 +1,30 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestTransitiveExportImports2(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @Filename: a.ts +[|namespace /*A*/[|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 0 |}A|] { + export const x = 0; +}|] +// @Filename: b.ts +[|export import /*B*/[|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 2 |}B|] = [|A|];|] +[|B|].x; +// @Filename: c.ts +[|import { /*C*/[|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 6 |}B|] } from "./b";|]` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.VerifyNoErrors(t) + f.VerifyBaselineFindAllReferences(t, "A", "B", "C") + f.VerifyBaselineRename(t, nil /*preferences*/, f.Ranges()[1], f.Ranges()[4]) + f.VerifyBaselineRename(t, nil /*preferences*/, f.Ranges()[3], f.Ranges()[5]) + f.VerifyBaselineRename(t, nil /*preferences*/, f.Ranges()[7]) +} diff --git a/pkg/fourslash/tests/gen/transitiveExportImports3_test.go b/pkg/fourslash/tests/gen/transitiveExportImports3_test.go new file mode 100644 index 000000000..1ace53a1b --- /dev/null +++ b/pkg/fourslash/tests/gen/transitiveExportImports3_test.go @@ -0,0 +1,28 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestTransitiveExportImports3(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @Filename: a.ts +[|export function /*f*/[|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 0 |}f|]() {}|] +// @Filename: b.ts +[|export { [|{| "contextRangeIndex": 2 |}f|] as /*g0*/[|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 2 |}g|] } from "./a";|] +[|import { /*f2*/[|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 5 |}f|] } from "./a";|] +[|import { /*g1*/[|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 7 |}g|] } from "./b";|]` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.VerifyNoErrors(t) + f.VerifyBaselineFindAllReferences(t, "f", "g0", "g1", "f2") + f.VerifyBaselineRename(t, nil /*preferences*/, f.Ranges()[1], f.Ranges()[3]) + f.VerifyBaselineRename(t, nil /*preferences*/, f.Ranges()[6]) + f.VerifyBaselineRename(t, nil /*preferences*/, f.Ranges()[4]) + f.VerifyBaselineRename(t, nil /*preferences*/, f.Ranges()[8]) +} diff --git a/pkg/fourslash/tests/gen/transitiveExportImports_test.go b/pkg/fourslash/tests/gen/transitiveExportImports_test.go new file mode 100644 index 000000000..641edb8cf --- /dev/null +++ b/pkg/fourslash/tests/gen/transitiveExportImports_test.go @@ -0,0 +1,32 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestTransitiveExportImports(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @Filename: a.ts +[|class /*1*/[|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 0 |}A|] { +}|] +[|export = [|{| "contextRangeIndex": 2 |}A|];|] +// @Filename: b.ts +[|export import /*2*/[|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 4 |}b|] = require('./a');|] +// @Filename: c.ts +[|import /*3*/[|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 6 |}b|] = require('./b');|] +var a = new /*4*/[|b|]./**/[|b|]();` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.GoToMarker(t, "") + f.VerifyQuickInfoExists(t) + f.VerifyNoErrors(t) + f.VerifyBaselineFindAllReferences(t, "1", "2", "3", "4") + f.VerifyBaselineRename(t, nil /*preferences*/, f.Ranges()[1], f.Ranges()[3]) + f.VerifyBaselineRename(t, nil /*preferences*/, f.Ranges()[5], f.Ranges()[9]) + f.VerifyBaselineRename(t, nil /*preferences*/, f.Ranges()[7], f.Ranges()[8]) +} diff --git a/pkg/fourslash/tests/gen/tripleSlashReferenceResolutionMode_test.go b/pkg/fourslash/tests/gen/tripleSlashReferenceResolutionMode_test.go new file mode 100644 index 000000000..fbb4dadbb --- /dev/null +++ b/pkg/fourslash/tests/gen/tripleSlashReferenceResolutionMode_test.go @@ -0,0 +1,37 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestTripleSlashReferenceResolutionMode(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @Filename: /home/src/workspaces/project/tsconfig.json + { "compilerOptions": { "module": "nodenext", "declaration": true, "strict": true, "outDir": "out" }, "files": ["./index.ts"] } +// @Filename: /home/src/workspaces/project/package.json + { "private": true, "type": "commonjs" } +// @Filename: /home/src/workspaces/project/node_modules/pkg/package.json +{ "name": "pkg", "version": "0.0.1", "exports": { "require": "./require.cjs", "default": "./import.js" }, "type": "module" } +// @Filename: /home/src/workspaces/project/node_modules/pkg/require.d.cts +export {}; +export interface PkgRequireInterface { member: any; } +declare global { const pkgRequireGlobal: PkgRequireInterface; } +// @Filename: /home/src/workspaces/project/node_modules/pkg/import.d.ts +export {}; +export interface PkgImportInterface { field: any; } +declare global { const pkgImportGlobal: PkgImportInterface; } +// @Filename: /home/src/workspaces/project/index.ts +/// +pkgImportGlobal; +export {};` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.MarkTestAsStradaServer() + f.GoToFile(t, "/home/src/workspaces/project/index.ts") + f.VerifyNumberOfErrorsInCurrentFile(t, 0) +} diff --git a/pkg/fourslash/tests/gen/tsxGoToDefinitionClassInDifferentFile_test.go b/pkg/fourslash/tests/gen/tsxGoToDefinitionClassInDifferentFile_test.go new file mode 100644 index 000000000..e6c2695e8 --- /dev/null +++ b/pkg/fourslash/tests/gen/tsxGoToDefinitionClassInDifferentFile_test.go @@ -0,0 +1,24 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestTsxGoToDefinitionClassInDifferentFile(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @jsx: preserve +// @Filename: C.tsx +export default class /*def*/C {} +// @Filename: a.tsx +import C from "./C"; +const foo = ;` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.VerifyNoErrors(t) + f.VerifyBaselineGoToDefinition(t, false, "use") +} diff --git a/pkg/fourslash/tests/gen/tsxRename4_test.go b/pkg/fourslash/tests/gen/tsxRename4_test.go new file mode 100644 index 000000000..3dae9966b --- /dev/null +++ b/pkg/fourslash/tests/gen/tsxRename4_test.go @@ -0,0 +1,32 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestTsxRename4(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @jsx: preserve +//@Filename: file.tsx +declare module JSX { + interface Element {} + interface IntrinsicElements { + div: {}; + } +} +[|class [|{| "contextRangeIndex": 0 |}MyClass|] {}|] + +[|<[|{| "contextRangeIndex": 2 |}MyClass|]>|]; +[|<[|{| "contextRangeIndex": 5 |}MyClass|]/>|]; + +[|<[|{| "contextRangeIndex": 7 |}div|]> |]` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.VerifyNoErrors(t) + f.VerifyBaselineRenameAtRangesWithText(t, nil /*preferences*/, "MyClass", "div") +} diff --git a/pkg/fourslash/tests/gen/typeCheckAfterResolve_test.go b/pkg/fourslash/tests/gen/typeCheckAfterResolve_test.go new file mode 100644 index 000000000..3c85840dd --- /dev/null +++ b/pkg/fourslash/tests/gen/typeCheckAfterResolve_test.go @@ -0,0 +1,28 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestTypeCheckAfterResolve(t *testing.T) { + t.Parallel() + t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `/*start*/class Point implements /*IPointRef*/IPoint { + getDist() { + ssss; + } +}/*end*/` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.GoToEOF(t) + f.InsertLine(t, "") + f.VerifyQuickInfoAt(t, "IPointRef", "any", "") + f.VerifyErrorExistsAfterMarker(t, "IPointRef") + f.GoToEOF(t) + f.InsertLine(t, "") + f.VerifyErrorExistsAfterMarker(t, "IPointRef") +} diff --git a/pkg/fourslash/tests/gen/unclosedStringLiteralAutoformating_test.go b/pkg/fourslash/tests/gen/unclosedStringLiteralAutoformating_test.go new file mode 100644 index 000000000..134fc72c8 --- /dev/null +++ b/pkg/fourslash/tests/gen/unclosedStringLiteralAutoformating_test.go @@ -0,0 +1,22 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestUnclosedStringLiteralAutoformating(t *testing.T) { + t.Parallel() + t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `var x = /*1*/"asd/*2*/ +class Foo { + /**/` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.GoToMarker(t, "") + f.Insert(t, "}") + f.VerifyCurrentLineContentIs(t, "}") +} diff --git a/pkg/fourslash/tests/gen/underscoreTypings02_test.go b/pkg/fourslash/tests/gen/underscoreTypings02_test.go new file mode 100644 index 000000000..c381f1e0f --- /dev/null +++ b/pkg/fourslash/tests/gen/underscoreTypings02_test.go @@ -0,0 +1,35 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestUnderscoreTypings02(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @module: CommonJS +interface Dictionary { + [x: string]: T; +} +export interface ChainedObject { + functions: ChainedArray; + omit(): ChainedObject; + clone(): ChainedObject; +} +interface ChainedDictionary extends ChainedObject> { + foldl(): ChainedObject; + clone(): ChainedDictionary; +} +export interface ChainedArray extends ChainedObject> { + groupBy(): ChainedDictionary; + groupBy(propertyName): ChainedDictionary; +}` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.GoToPosition(t, 0) + f.VerifyNumberOfErrorsInCurrentFile(t, 2) +} diff --git a/pkg/fourslash/tests/gen/unreachableStatementNodeReuse_test.go b/pkg/fourslash/tests/gen/unreachableStatementNodeReuse_test.go new file mode 100644 index 000000000..457c40dfd --- /dev/null +++ b/pkg/fourslash/tests/gen/unreachableStatementNodeReuse_test.go @@ -0,0 +1,25 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestUnreachableStatementNodeReuse(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `function test() { + return/*a*/abc(); + return; +} +function abc() { }` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.VerifyNumberOfErrorsInCurrentFile(t, 1) + f.GoToMarker(t, "a") + f.Insert(t, " ") + f.VerifyNoErrors(t) +} diff --git a/pkg/fourslash/tests/gen/unusedVariableInClass5_test.go b/pkg/fourslash/tests/gen/unusedVariableInClass5_test.go new file mode 100644 index 000000000..780c41896 --- /dev/null +++ b/pkg/fourslash/tests/gen/unusedVariableInClass5_test.go @@ -0,0 +1,23 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestUnusedVariableInClass5(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @noUnusedLocals: true +// @target: esnext +declare class greeter { + #private; + private name; +}` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.VerifyNoErrors(t) +} diff --git a/pkg/fourslash/tests/gen/whiteSpaceBeforeReturnTypeFormatting_test.go b/pkg/fourslash/tests/gen/whiteSpaceBeforeReturnTypeFormatting_test.go new file mode 100644 index 000000000..42df3fdad --- /dev/null +++ b/pkg/fourslash/tests/gen/whiteSpaceBeforeReturnTypeFormatting_test.go @@ -0,0 +1,20 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestWhiteSpaceBeforeReturnTypeFormatting(t *testing.T) { + t.Parallel() + t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `var x: () => string/**/` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.GoToMarker(t, "") + f.Insert(t, ";") + f.VerifyCurrentLineContentIs(t, "var x: () => string;") +} diff --git a/pkg/fourslash/tests/gen/whiteSpaceTrimming2_test.go b/pkg/fourslash/tests/gen/whiteSpaceTrimming2_test.go new file mode 100644 index 000000000..650cacb78 --- /dev/null +++ b/pkg/fourslash/tests/gen/whiteSpaceTrimming2_test.go @@ -0,0 +1,29 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestWhiteSpaceTrimming2(t *testing.T) { + t.Parallel() + t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `let noSubTemplate = ` + "`" + `/* /*1*/` + "`" + `; +let templateHead = ` + "`" + `/* /*2*/${1 + 2}` + "`" + `; +let templateMiddle = ` + "`" + `/* ${1 + 2 /*3*/}` + "`" + `; +let templateTail = ` + "`" + `/* ${1 + 2} /*4*/` + "`" + `;` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.GoToMarker(t, "1") + f.Insert(t, "\n") + f.GoToMarker(t, "2") + f.Insert(t, "\n") + f.GoToMarker(t, "3") + f.Insert(t, "\n") + f.GoToMarker(t, "4") + f.Insert(t, "\n") + f.VerifyCurrentFileContentIs(t, "let noSubTemplate = `/* \n`;\nlet templateHead = `/* \n${1 + 2}`;\nlet templateMiddle = `/* ${1 + 2\n }`;\nlet templateTail = `/* ${1 + 2} \n`;") +} diff --git a/pkg/fourslash/tests/gen/whiteSpaceTrimming3_test.go b/pkg/fourslash/tests/gen/whiteSpaceTrimming3_test.go new file mode 100644 index 000000000..0fa11c3de --- /dev/null +++ b/pkg/fourslash/tests/gen/whiteSpaceTrimming3_test.go @@ -0,0 +1,22 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestWhiteSpaceTrimming3(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `let t = "foo \ +bar \ +"/*1*/` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.GoToMarker(t, "1") + f.Insert(t, ";") + f.VerifyCurrentFileContentIs(t, "let t = \"foo \\\nbar \\ \n\";") +} diff --git a/pkg/fourslash/tests/gen/whiteSpaceTrimming4_test.go b/pkg/fourslash/tests/gen/whiteSpaceTrimming4_test.go new file mode 100644 index 000000000..cdb9e3d65 --- /dev/null +++ b/pkg/fourslash/tests/gen/whiteSpaceTrimming4_test.go @@ -0,0 +1,20 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestWhiteSpaceTrimming4(t *testing.T) { + t.Parallel() + t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `var re = /\w+ /*1*//;` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.GoToMarker(t, "1") + f.Insert(t, "\n") + f.VerifyCurrentFileContentIs(t, "var re = /\\w+\n /;") +} diff --git a/pkg/fourslash/tests/gen/whiteSpaceTrimming_test.go b/pkg/fourslash/tests/gen/whiteSpaceTrimming_test.go new file mode 100644 index 000000000..a5bb4d316 --- /dev/null +++ b/pkg/fourslash/tests/gen/whiteSpaceTrimming_test.go @@ -0,0 +1,22 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestWhiteSpaceTrimming(t *testing.T) { + t.Parallel() + t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `if (true) { + // + /*err*/}` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.GoToMarker(t, "err") + f.Insert(t, "\n") + f.VerifyCurrentFileContentIs(t, "if (true) { \n // \n\n}") +} diff --git a/pkg/fourslash/tests/signatureHelpNestedCallTrailingComma_test.go b/pkg/fourslash/tests/signatureHelpNestedCallTrailingComma_test.go new file mode 100644 index 000000000..b4c8724e1 --- /dev/null +++ b/pkg/fourslash/tests/signatureHelpNestedCallTrailingComma_test.go @@ -0,0 +1,28 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/lsp/lsproto" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestSignatureHelpNestedCallTrailingComma(t *testing.T) { + t.Parallel() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + // Regression test for crash when requesting signature help on a call target + // where the nested call has a trailing comma. + // Both outer and inner calls must have trailing commas, and outer must be generic. + const content = `declare function outer(range: T): T; +declare function inner(a: any): any; + +outer(inner/*1*/(undefined,),);` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.GoToMarker(t, "1") + f.VerifySignatureHelpPresent(t, &lsproto.SignatureHelpContext{ + IsRetrigger: false, + TriggerKind: lsproto.SignatureHelpTriggerKindInvoked, + }) +} diff --git a/pkg/ls/autoimportfixes.go b/pkg/ls/autoimportfixes.go index 9d046e35e..233e237a4 100644 --- a/pkg/ls/autoimportfixes.go +++ b/pkg/ls/autoimportfixes.go @@ -298,10 +298,10 @@ func (ls *LanguageService) getNewImports( namespaceLikeImport *Import, // { importKind: ImportKind.CommonJS | ImportKind.Namespace; } compilerOptions *core.CompilerOptions, ) []*ast.Statement { - moduleSpecifierStringLiteral := ct.NodeFactory.NewStringLiteral(moduleSpecifier) - if quotePreference == quotePreferenceSingle { - moduleSpecifierStringLiteral.AsStringLiteral().TokenFlags |= ast.TokenFlagsSingleQuote - } + moduleSpecifierStringLiteral := ct.NodeFactory.NewStringLiteral( + moduleSpecifier, + core.IfElse(quotePreference == quotePreferenceSingle, ast.TokenFlagsSingleQuote, ast.TokenFlagsNone), + ) var statements []*ast.Statement // []AnyImportSyntax if defaultImport != nil || len(namedImports) > 0 { // `verbatimModuleSyntax` should prefer top-level `import type` - diff --git a/pkg/ls/autoimports.go b/pkg/ls/autoimports.go index 84f908afc..746564756 100644 --- a/pkg/ls/autoimports.go +++ b/pkg/ls/autoimports.go @@ -1564,7 +1564,7 @@ func (l *LanguageService) codeActionForFixWorker( } if fix.useRequire { - declarations = getNewRequires(changeTracker, fix.moduleSpecifier, defaultImport, namedImports, namespaceLikeImport, l.GetProgram().Options()) + declarations = getNewRequires(changeTracker, fix.moduleSpecifier, getQuotePreference(sourceFile, l.UserPreferences()), defaultImport, namedImports, namespaceLikeImport, l.GetProgram().Options()) } else { declarations = l.getNewImports(changeTracker, fix.moduleSpecifier, getQuotePreference(sourceFile, l.UserPreferences()), defaultImport, namedImports, namespaceLikeImport, l.GetProgram().Options()) } @@ -1598,12 +1598,16 @@ func (l *LanguageService) codeActionForFixWorker( func getNewRequires( changeTracker *change.Tracker, moduleSpecifier string, + quotePreference quotePreference, defaultImport *Import, namedImports []*Import, namespaceLikeImport *Import, compilerOptions *core.CompilerOptions, ) []*ast.Statement { - quotedModuleSpecifier := changeTracker.NodeFactory.NewStringLiteral(moduleSpecifier) + quotedModuleSpecifier := changeTracker.NodeFactory.NewStringLiteral( + moduleSpecifier, + core.IfElse(quotePreference == quotePreferenceSingle, ast.TokenFlagsSingleQuote, ast.TokenFlagsNone), + ) var statements []*ast.Statement // const { default: foo, bar, etc } = require('./mod'); diff --git a/pkg/ls/codeactions_importfixes.go b/pkg/ls/codeactions_importfixes.go index 3b8442e6f..32d2cdc1a 100644 --- a/pkg/ls/codeactions_importfixes.go +++ b/pkg/ls/codeactions_importfixes.go @@ -562,7 +562,7 @@ func promoteImportClause( outputpaths.GetOutputExtension(moduleText, compilerOptions.Jsx), ) // Replace the module specifier with the new extension - newStringLiteral := changes.NewStringLiteral(changedExtension) + newStringLiteral := changes.NewStringLiteral(changedExtension, moduleSpecifier.AsStringLiteral().TokenFlags) changes.ReplaceNode(sourceFile, moduleSpecifier, newStringLiteral, nil) } } diff --git a/pkg/ls/completions.go b/pkg/ls/completions.go index 426dcb7d0..1eaf593cf 100644 --- a/pkg/ls/completions.go +++ b/pkg/ls/completions.go @@ -4079,7 +4079,7 @@ func setMemberDeclaredBySpreadAssignment(declaration *ast.Node, members *collect t = typeChecker.GetTypeOfSymbolAtLocation(symbol, expression) } var properties []*ast.Symbol - if t != nil { + if t != nil && t.Flags()&checker.TypeFlagsStructuredType != 0 { properties = t.AsStructuredType().Properties() } for _, property := range properties { diff --git a/pkg/ls/hover.go b/pkg/ls/hover.go index 883559d84..dc9381da8 100644 --- a/pkg/ls/hover.go +++ b/pkg/ls/hover.go @@ -12,6 +12,7 @@ import ( "github.com/buke/typescript-go-internal/pkg/collections" "github.com/buke/typescript-go-internal/pkg/core" "github.com/buke/typescript-go-internal/pkg/lsp/lsproto" + "github.com/buke/typescript-go-internal/pkg/scanner" ) const ( @@ -109,14 +110,19 @@ func (l *LanguageService) getDocumentationFromDeclaration(c *checker.Checker, de } } comments := tag.Comments() - if len(comments) != 0 { - if commentHasPrefix(comments, "```") { + if tag.Kind == ast.KindJSDocTag && tag.TagName().Text() == "example" { + b.WriteString("\n") + commentText := strings.TrimRight(getCommentText(comments), " \t\r\n") + if len(commentText) > 6 && strings.HasPrefix(commentText, "```") && strings.HasSuffix(commentText, "```") && strings.Contains(commentText, "\n") { + b.WriteString(commentText) b.WriteString("\n") } else { - b.WriteString(" ") - if !commentHasPrefix(comments, "-") { - b.WriteString("— ") - } + writeCode(&b, "tsx", commentText) + } + } else if len(comments) != 0 { + b.WriteString(" ") + if !commentHasPrefix(comments, "-") { + b.WriteString("— ") } l.writeComments(&b, c, comments, isMarkdown) } @@ -127,6 +133,19 @@ func (l *LanguageService) getDocumentationFromDeclaration(c *checker.Checker, de return b.String() } +func getCommentText(comments []*ast.Node) string { + var b strings.Builder + for _, comment := range comments { + switch comment.Kind { + case ast.KindJSDocText: + b.WriteString(comment.Text()) + case ast.KindJSDocLink, ast.KindJSDocLinkCode, ast.KindJSDocLinkPlain: + b.WriteString(scanner.GetTextOfNode(comment)) + } + } + return b.String() +} + func formatQuickInfo(quickInfo string) string { var b strings.Builder b.Grow(32) diff --git a/pkg/module/resolver.go b/pkg/module/resolver.go index 143a72981..9b7f969d8 100644 --- a/pkg/module/resolver.go +++ b/pkg/module/resolver.go @@ -532,7 +532,7 @@ func (r *resolutionState) loadModuleFromSelfNameReference() *resolved { } func (r *resolutionState) loadModuleFromImports() *resolved { - if r.name == "#" || strings.HasPrefix(r.name, "#/") { + if r.name == "#" || (strings.HasPrefix(r.name, "#/") && (r.features&NodeResolutionFeaturesImportsPatternRoot) == 0) { if r.tracer != nil { r.tracer.write(diagnostics.Invalid_import_specifier_0_has_no_possible_resolutions, r.name) } diff --git a/pkg/module/types.go b/pkg/module/types.go index 9c18651fb..e0932c7a7 100644 --- a/pkg/module/types.go +++ b/pkg/module/types.go @@ -33,12 +33,15 @@ const ( NodeResolutionFeaturesSelfName NodeResolutionFeaturesExports NodeResolutionFeaturesExportsPatternTrailers + // allowing `#/` root imports in package.json imports field + // not supported until mass adoption - https://github.com/nodejs/node/pull/60864 + NodeResolutionFeaturesImportsPatternRoot NodeResolutionFeaturesNone NodeResolutionFeatures = 0 - NodeResolutionFeaturesAll = NodeResolutionFeaturesImports | NodeResolutionFeaturesSelfName | NodeResolutionFeaturesExports | NodeResolutionFeaturesExportsPatternTrailers + NodeResolutionFeaturesAll = NodeResolutionFeaturesImports | NodeResolutionFeaturesSelfName | NodeResolutionFeaturesExports | NodeResolutionFeaturesExportsPatternTrailers | NodeResolutionFeaturesImportsPatternRoot NodeResolutionFeaturesNode16Default = NodeResolutionFeaturesImports | NodeResolutionFeaturesSelfName | NodeResolutionFeaturesExports | NodeResolutionFeaturesExportsPatternTrailers NodeResolutionFeaturesNodeNextDefault = NodeResolutionFeaturesAll - NodeResolutionFeaturesBundlerDefault = NodeResolutionFeaturesImports | NodeResolutionFeaturesSelfName | NodeResolutionFeaturesExports | NodeResolutionFeaturesExportsPatternTrailers + NodeResolutionFeaturesBundlerDefault = NodeResolutionFeaturesImports | NodeResolutionFeaturesSelfName | NodeResolutionFeaturesExports | NodeResolutionFeaturesExportsPatternTrailers | NodeResolutionFeaturesImportsPatternRoot ) type PackageId struct { diff --git a/pkg/parser/parser.go b/pkg/parser/parser.go index 0eaefbd5f..dd0675503 100644 --- a/pkg/parser/parser.go +++ b/pkg/parser/parser.go @@ -3562,7 +3562,7 @@ func (p *Parser) parseTemplateHead(isTaggedTemplate bool) *ast.Node { p.reScanTemplateToken(false /*isTaggedTemplate*/) } pos := p.nodePos() - result := p.factory.NewTemplateHead(p.scanner.TokenValue(), p.getTemplateLiteralRawText(2 /*endLength*/), p.scanner.TokenFlags()&ast.TokenFlagsTemplateLiteralLikeFlags) + result := p.factory.NewTemplateHead(p.scanner.TokenValue(), p.getTemplateLiteralRawText(2 /*endLength*/), p.scanner.TokenFlags()) p.nextToken() return p.finishNode(result, pos) } @@ -3606,9 +3606,9 @@ func (p *Parser) parseTemplateMiddleOrTail() *ast.Node { pos := p.nodePos() var result *ast.Node if p.token == ast.KindTemplateMiddle { - result = p.factory.NewTemplateMiddle(p.scanner.TokenValue(), p.getTemplateLiteralRawText(2 /*endLength*/), p.scanner.TokenFlags()&ast.TokenFlagsTemplateLiteralLikeFlags) + result = p.factory.NewTemplateMiddle(p.scanner.TokenValue(), p.getTemplateLiteralRawText(2 /*endLength*/), p.scanner.TokenFlags()) } else { - result = p.factory.NewTemplateTail(p.scanner.TokenValue(), p.getTemplateLiteralRawText(1 /*endLength*/), p.scanner.TokenFlags()&ast.TokenFlagsTemplateLiteralLikeFlags) + result = p.factory.NewTemplateTail(p.scanner.TokenValue(), p.getTemplateLiteralRawText(1 /*endLength*/), p.scanner.TokenFlags()) } p.nextToken() return p.finishNode(result, pos) @@ -5646,20 +5646,15 @@ func (p *Parser) parseLiteralExpression(intern bool) *ast.Node { var result *ast.Node switch p.token { case ast.KindStringLiteral: - result = p.factory.NewStringLiteral(text) - result.AsStringLiteral().TokenFlags |= tokenFlags & ast.TokenFlagsStringLiteralFlags + result = p.factory.NewStringLiteral(text, tokenFlags) case ast.KindNumericLiteral: - result = p.factory.NewNumericLiteral(text) - result.AsNumericLiteral().TokenFlags |= tokenFlags & ast.TokenFlagsNumericLiteralFlags + result = p.factory.NewNumericLiteral(text, tokenFlags) case ast.KindBigIntLiteral: - result = p.factory.NewBigIntLiteral(text) - result.AsBigIntLiteral().TokenFlags |= tokenFlags & ast.TokenFlagsNumericLiteralFlags + result = p.factory.NewBigIntLiteral(text, tokenFlags) case ast.KindRegularExpressionLiteral: - result = p.factory.NewRegularExpressionLiteral(text) - result.AsRegularExpressionLiteral().TokenFlags |= tokenFlags & ast.TokenFlagsRegularExpressionLiteralFlags + result = p.factory.NewRegularExpressionLiteral(text, tokenFlags) case ast.KindNoSubstitutionTemplateLiteral: - result = p.factory.NewNoSubstitutionTemplateLiteral(text) - result.AsNoSubstitutionTemplateLiteral().TokenFlags |= tokenFlags & ast.TokenFlagsTemplateLiteralLikeFlags + result = p.factory.NewNoSubstitutionTemplateLiteral(text, tokenFlags) default: panic("Unhandled case in parseLiteralExpression") } diff --git a/pkg/printer/factory.go b/pkg/printer/factory.go index 0cf1233d0..ce828c861 100644 --- a/pkg/printer/factory.go +++ b/pkg/printer/factory.go @@ -177,7 +177,7 @@ func (f *NodeFactory) NewStringLiteralFromNode(textSourceNode *ast.Node) *ast.No ast.KindRegularExpressionLiteral: text = textSourceNode.Text() } - node := f.NewStringLiteral(text) + node := f.NewStringLiteral(text, ast.TokenFlagsNone) if f.emitContext.textSource == nil { f.emitContext.textSource = make(map[*ast.StringLiteralNode]*ast.Node) } @@ -234,7 +234,7 @@ func (f *NodeFactory) NewStrictInequalityExpression(left *ast.Expression, right // func (f *NodeFactory) NewVoidZeroExpression() *ast.Expression { - return f.NewVoidExpression(f.NewNumericLiteral("0")) + return f.NewVoidExpression(f.NewNumericLiteral("0", ast.TokenFlagsNone)) } func flattenCommaElement(node *ast.Expression, expressions []*ast.Expression) []*ast.Expression { @@ -282,7 +282,7 @@ func (f *NodeFactory) NewTypeCheck(value *ast.Node, tag string) *ast.Node { } else if tag == "undefined" { return f.NewStrictEqualityExpression(value, f.NewVoidZeroExpression()) } else { - return f.NewStrictEqualityExpression(f.NewTypeOfExpression(value), f.NewStringLiteral(tag)) + return f.NewStrictEqualityExpression(f.NewTypeOfExpression(value), f.NewStringLiteral(tag, ast.TokenFlagsNone)) } } @@ -321,7 +321,7 @@ func (f *NodeFactory) NewFunctionCallCall(target *ast.Expression, thisArg *ast.E func (f *NodeFactory) NewArraySliceCall(array *ast.Expression, start int) *ast.Node { var args []*ast.Node if start != 0 { - args = append(args, f.NewNumericLiteral(strconv.Itoa(start))) + args = append(args, f.NewNumericLiteral(strconv.Itoa(start), ast.TokenFlagsNone)) } return f.NewMethodCall(array, f.NewIdentifier("slice"), args) } @@ -387,7 +387,7 @@ func (f *NodeFactory) EnsureUseStrict(statements []*ast.Statement) []*ast.Statem break } } - useStrictPrologue := f.NewExpressionStatement(f.NewStringLiteral("use strict")) + useStrictPrologue := f.NewExpressionStatement(f.NewStringLiteral("use strict", ast.TokenFlagsNone)) statements = append([]*ast.Statement{useStrictPrologue}, statements...) return statements } @@ -573,7 +573,7 @@ func (f *NodeFactory) NewRestHelper(value *ast.Expression, elements []*ast.Node, f.NewToken(ast.KindQuestionToken), temp, f.NewToken(ast.KindColonToken), - f.NewBinaryExpression(nil, temp, nil, f.NewToken(ast.KindPlusToken), f.NewStringLiteral("")), + f.NewBinaryExpression(nil, temp, nil, f.NewToken(ast.KindPlusToken), f.NewStringLiteral("", ast.TokenFlagsNone)), )) } else { propertyNames = append(propertyNames, f.NewStringLiteralFromNode(propertyName)) @@ -613,7 +613,7 @@ func (f *NodeFactory) NewSetFunctionNameHelper(fn *ast.Expression, name *ast.Exp f.emitContext.RequestEmitHelper(setFunctionNameHelper) var arguments []*ast.Expression if len(prefix) > 0 { - arguments = []*ast.Expression{fn, name, f.NewStringLiteral(prefix)} + arguments = []*ast.Expression{fn, name, f.NewStringLiteral(prefix, ast.TokenFlagsNone)} } else { arguments = []*ast.Expression{fn, name} } diff --git a/pkg/printer/printer_test.go b/pkg/printer/printer_test.go index 394eed7e8..712345a5a 100644 --- a/pkg/printer/printer_test.go +++ b/pkg/printer/printer_test.go @@ -1062,7 +1062,7 @@ func TestParenthesizeTaggedTemplate1(t *testing.T) { ), nil, /*questionDotToken*/ nil, /*typeArguments*/ - factory.NewNoSubstitutionTemplateLiteral(""), + factory.NewNoSubstitutionTemplateLiteral("", ast.TokenFlagsNone), ast.NodeFlagsNone, ), ), @@ -1090,7 +1090,7 @@ func TestParenthesizeTaggedTemplate2(t *testing.T) { ), nil, /*questionDotToken*/ nil, /*typeArguments*/ - factory.NewNoSubstitutionTemplateLiteral(""), + factory.NewNoSubstitutionTemplateLiteral("", ast.TokenFlagsNone), ast.NodeFlagsNone, ), ), diff --git a/pkg/stringutil/util.go b/pkg/stringutil/util.go index 4b4ba7e9d..7fb753008 100644 --- a/pkg/stringutil/util.go +++ b/pkg/stringutil/util.go @@ -217,7 +217,7 @@ func StripQuotes(name string) string { return name } -var matchSlashSomething = regexp.MustCompile(`\.`) +var matchSlashSomething = regexp.MustCompile(`\\.`) func matchSlashReplacer(in string) string { return in[1:] diff --git a/pkg/transformers/declarations/transform.go b/pkg/transformers/declarations/transform.go index 719c6d45b..4a59527f0 100644 --- a/pkg/transformers/declarations/transform.go +++ b/pkg/transformers/declarations/transform.go @@ -1131,11 +1131,8 @@ func (tx *DeclarationTransformer) tryGetResolutionModeOverride(node *ast.Node) * } func (tx *DeclarationTransformer) preserveJsDoc(updated *ast.Node, original *ast.Node) { - // !!! TODO: JSDoc comment support - // if (hasJSDocNodes(updated) && hasJSDocNodes(original)) { - // updated.jsDoc = original.jsDoc; - // } - // return setCommentRange(updated, getCommentRange(original)); + // Copy comment range from original to updated node so JSDoc comments are preserved + tx.EmitContext().AssignCommentRange(updated, original) } func (tx *DeclarationTransformer) removeAllComments(node *ast.Node) { @@ -1597,15 +1594,15 @@ func (tx *DeclarationTransformer) transformEnumDeclaration(input *ast.EnumDeclar switch value := enumValue.Value.(type) { case jsnum.Number: if value >= 0 { - newInitializer = tx.Factory().NewNumericLiteral(value.String()) + newInitializer = tx.Factory().NewNumericLiteral(value.String(), ast.TokenFlagsNone) } else { newInitializer = tx.Factory().NewPrefixUnaryExpression( ast.KindMinusToken, - tx.Factory().NewNumericLiteral((-value).String()), + tx.Factory().NewNumericLiteral((-value).String(), ast.TokenFlagsNone), ) } case string: - newInitializer = tx.Factory().NewStringLiteral(value) + newInitializer = tx.Factory().NewStringLiteral(value, ast.TokenFlagsNone) default: // nil newInitializer = nil diff --git a/pkg/transformers/estransforms/namedevaluation.go b/pkg/transformers/estransforms/namedevaluation.go index 7d24f7b38..01b0c2643 100644 --- a/pkg/transformers/estransforms/namedevaluation.go +++ b/pkg/transformers/estransforms/namedevaluation.go @@ -145,7 +145,7 @@ func getAssignedNameOfIdentifier(emitContext *printer.EmitContext, name *ast.Ide original := emitContext.MostOriginal(ast.SkipOuterExpressions(expression, ast.OEKAll)) if (ast.IsClassDeclaration(original) || ast.IsFunctionDeclaration(original)) && original.Name() == nil && ast.HasSyntacticModifier(original, ast.ModifierFlagsDefault) { - return emitContext.Factory.NewStringLiteral("default") + return emitContext.Factory.NewStringLiteral("default", ast.TokenFlagsNone) } return emitContext.Factory.NewStringLiteralFromNode(name) } @@ -153,7 +153,7 @@ func getAssignedNameOfIdentifier(emitContext *printer.EmitContext, name *ast.Ide func getAssignedNameOfPropertyName(emitContext *printer.EmitContext, name *ast.PropertyName, assignedNameText string) (assignedName *ast.Expression, updatedName *ast.PropertyName) { factory := emitContext.Factory if len(assignedNameText) > 0 { - assignedName := factory.NewStringLiteral(assignedNameText) + assignedName := factory.NewStringLiteral(assignedNameText, ast.TokenFlagsNone) return assignedName, name } @@ -325,7 +325,7 @@ func transformNamedEvaluationOfShorthandAssignmentProperty(emitContext *printer. factory := emitContext.Factory var assignedName *ast.Expression if len(assignedNameText) > 0 { - assignedName = factory.NewStringLiteral(assignedNameText) + assignedName = factory.NewStringLiteral(assignedNameText, ast.TokenFlagsNone) } else { assignedName = getAssignedNameOfIdentifier(emitContext, node.Name(), node.ObjectAssignmentInitializer) } @@ -359,7 +359,7 @@ func transformNamedEvaluationOfVariableDeclaration(emitContext *printer.EmitCont factory := emitContext.Factory var assignedName *ast.Expression if len(assignedNameText) > 0 { - assignedName = factory.NewStringLiteral(assignedNameText) + assignedName = factory.NewStringLiteral(assignedNameText, ast.TokenFlagsNone) } else { assignedName = getAssignedNameOfIdentifier(emitContext, node.Name(), node.Initializer) } @@ -393,7 +393,7 @@ func transformNamedEvaluationOfParameterDeclaration(emitContext *printer.EmitCon factory := emitContext.Factory var assignedName *ast.Expression if len(assignedNameText) > 0 { - assignedName = factory.NewStringLiteral(assignedNameText) + assignedName = factory.NewStringLiteral(assignedNameText, ast.TokenFlagsNone) } else { assignedName = getAssignedNameOfIdentifier(emitContext, node.Name(), node.Initializer) } @@ -429,7 +429,7 @@ func transformNamedEvaluationOfBindingElement(emitContext *printer.EmitContext, factory := emitContext.Factory var assignedName *ast.Expression if len(assignedNameText) > 0 { - assignedName = factory.NewStringLiteral(assignedNameText) + assignedName = factory.NewStringLiteral(assignedNameText, ast.TokenFlagsNone) } else { assignedName = getAssignedNameOfIdentifier(emitContext, node.Name(), node.Initializer) } @@ -494,7 +494,7 @@ func transformNamedEvaluationOfAssignmentExpression(emitContext *printer.EmitCon factory := emitContext.Factory var assignedName *ast.Expression if len(assignedNameText) > 0 { - assignedName = factory.NewStringLiteral(assignedNameText) + assignedName = factory.NewStringLiteral(assignedNameText, ast.TokenFlagsNone) } else { assignedName = getAssignedNameOfIdentifier(emitContext, node.Left, node.Right) } @@ -522,9 +522,9 @@ func transformNamedEvaluationOfExportAssignment(emitContext *printer.EmitContext factory := emitContext.Factory var assignedName *ast.Expression if len(assignedNameText) > 0 { - assignedName = factory.NewStringLiteral(assignedNameText) + assignedName = factory.NewStringLiteral(assignedNameText, ast.TokenFlagsNone) } else { - assignedName = factory.NewStringLiteral("") + assignedName = factory.NewStringLiteral("", ast.TokenFlagsNone) } expression := finishTransformNamedEvaluation(emitContext, node.Expression, assignedName, ignoreEmptyStringLiteral) return factory.UpdateExportAssignment( diff --git a/pkg/transformers/estransforms/objectrestspread.go b/pkg/transformers/estransforms/objectrestspread.go index 2ad15cec6..3633abf6a 100644 --- a/pkg/transformers/estransforms/objectrestspread.go +++ b/pkg/transformers/estransforms/objectrestspread.go @@ -778,7 +778,7 @@ func (ch *objectRestSpreadTransformer) flattenArrayBindingOrAssignmentPattern(pa } else if ast.IsOmittedExpression(element) { continue } else if ast.GetRestIndicatorOfBindingOrAssignmentElement(element) == nil { - rhsValue := ch.Factory().NewElementAccessExpression(value, nil, ch.Factory().NewNumericLiteral(strconv.Itoa(i)), ast.NodeFlagsNone) + rhsValue := ch.Factory().NewElementAccessExpression(value, nil, ch.Factory().NewNumericLiteral(strconv.Itoa(i), ast.TokenFlagsNone), ast.NodeFlagsNone) ch.flattenBindingOrAssignmentElement(element, rhsValue, element.Loc, false) } else if i == numElements-1 { rhsValue := ch.Factory().NewArraySliceCall(value, i) diff --git a/pkg/transformers/inliners/constenum.go b/pkg/transformers/inliners/constenum.go index 2194c2c8d..5798b974f 100644 --- a/pkg/transformers/inliners/constenum.go +++ b/pkg/transformers/inliners/constenum.go @@ -51,19 +51,19 @@ func (tx *ConstEnumInliningTransformer) visit(node *ast.Node) *ast.Node { } else if v.IsNaN() { replacement = tx.Factory().NewIdentifier("NaN") } else if v.Abs() == v { - replacement = tx.Factory().NewNumericLiteral(v.String()) + replacement = tx.Factory().NewNumericLiteral(v.String(), ast.TokenFlagsNone) } else { - replacement = tx.Factory().NewPrefixUnaryExpression(ast.KindMinusToken, tx.Factory().NewNumericLiteral(v.Abs().String())) + replacement = tx.Factory().NewPrefixUnaryExpression(ast.KindMinusToken, tx.Factory().NewNumericLiteral(v.Abs().String(), ast.TokenFlagsNone)) } case string: - replacement = tx.Factory().NewStringLiteral(v) + replacement = tx.Factory().NewStringLiteral(v, ast.TokenFlagsNone) case jsnum.PseudoBigInt: // technically not supported by strada, and issues a checker error, handled here for completeness if v == (jsnum.PseudoBigInt{}) { - replacement = tx.Factory().NewBigIntLiteral("0") + replacement = tx.Factory().NewBigIntLiteral("0", ast.TokenFlagsNone) } else if !v.Negative { - replacement = tx.Factory().NewBigIntLiteral(v.Base10Value) + replacement = tx.Factory().NewBigIntLiteral(v.Base10Value, ast.TokenFlagsNone) } else { - replacement = tx.Factory().NewPrefixUnaryExpression(ast.KindMinusToken, tx.Factory().NewBigIntLiteral(v.Base10Value)) + replacement = tx.Factory().NewPrefixUnaryExpression(ast.KindMinusToken, tx.Factory().NewBigIntLiteral(v.Base10Value, ast.TokenFlagsNone)) } } diff --git a/pkg/transformers/jsxtransforms/jsx.go b/pkg/transformers/jsxtransforms/jsx.go index 6b0ac1d16..da5536964 100644 --- a/pkg/transformers/jsxtransforms/jsx.go +++ b/pkg/transformers/jsxtransforms/jsx.go @@ -49,7 +49,7 @@ func (tx *JSXTransformer) getCurrentFileNameExpression() *ast.Node { }), nil, nil, - tx.Factory().NewStringLiteral(tx.currentSourceFile.FileName()), + tx.Factory().NewStringLiteral(tx.currentSourceFile.FileName(), ast.TokenFlagsNone), ) tx.filenameDeclaration = d return d.AsVariableDeclaration().Name() @@ -236,7 +236,7 @@ func (tx *JSXTransformer) visitSourceFile(file *ast.SourceFile) *ast.Node { s := tx.Factory().NewImportDeclaration( nil, tx.Factory().NewImportClause(ast.KindUnknown, nil, tx.Factory().NewNamedImports(tx.Factory().NewNodeList(getSortedSpecifiers(importSpecifiersMap)))), - tx.Factory().NewStringLiteral(importSource), + tx.Factory().NewStringLiteral(importSource, ast.TokenFlagsNone), nil, ) ast.SetParentInChildren(s) @@ -260,7 +260,11 @@ func (tx *JSXTransformer) visitSourceFile(file *ast.SourceFile) *ast.Node { tx.Factory().NewBindingPattern(ast.KindObjectBindingPattern, tx.Factory().NewNodeList(asBindingElems)), nil, nil, - tx.Factory().NewCallExpression(tx.Factory().NewIdentifier("require"), nil, nil, tx.Factory().NewNodeList([]*ast.Node{tx.Factory().NewStringLiteral(importSource)}), ast.NodeFlagsNone), + tx.Factory().NewCallExpression( + tx.Factory().NewIdentifier("require"), + nil, + nil, + tx.Factory().NewNodeList([]*ast.Node{tx.Factory().NewStringLiteral(importSource, ast.TokenFlagsNone)}), ast.NodeFlagsNone), )}))) ast.SetParentInChildren(s) newStatements = append(newStatements, s) @@ -354,9 +358,11 @@ func (tx *JSXTransformer) getTagName(node *ast.Node) *ast.Node { } else if ast.IsJsxOpeningLikeElement(node) { tagName := node.TagName() if ast.IsIdentifier(tagName) && scanner.IsIntrinsicJsxName(tagName.Text()) { - return tx.Factory().NewStringLiteral(tagName.Text()) + return tx.Factory().NewStringLiteral(tagName.Text(), ast.TokenFlagsNone) } else if ast.IsJsxNamespacedName(tagName) { - return tx.Factory().NewStringLiteral(tagName.AsJsxNamespacedName().Namespace.Text() + ":" + tagName.AsJsxNamespacedName().Name().Text()) + return tx.Factory().NewStringLiteral( + tagName.AsJsxNamespacedName().Namespace.Text()+":"+tagName.AsJsxNamespacedName().Name().Text(), ast.TokenFlagsNone, + ) } else { return createExpressionFromEntityName(tx.Factory(), tagName) } @@ -514,10 +520,12 @@ func (tx *JSXTransformer) getAttributeName(node *ast.JsxAttribute) *ast.Node { if scanner.IsIdentifierText(text, core.LanguageVariantStandard) { return name } - return tx.Factory().NewStringLiteral(text) + return tx.Factory().NewStringLiteral(text, ast.TokenFlagsNone) } // must be jsx namespace - return tx.Factory().NewStringLiteral(name.AsJsxNamespacedName().Namespace.Text() + ":" + name.AsJsxNamespacedName().Name().Text()) + return tx.Factory().NewStringLiteral( + name.AsJsxNamespacedName().Namespace.Text()+":"+name.AsJsxNamespacedName().Name().Text(), ast.TokenFlagsNone, + ) } func (tx *JSXTransformer) transformJsxAttributeInitializer(node *ast.Node) *ast.Node { @@ -527,7 +535,7 @@ func (tx *JSXTransformer) transformJsxAttributeInitializer(node *ast.Node) *ast. if node.Kind == ast.KindStringLiteral { // Always recreate the literal to escape any escape sequences or newlines which may be in the original jsx string and which // Need to be escaped to be handled correctly in a normal string - res := tx.Factory().NewStringLiteral(decodeEntities(node.Text())) + res := tx.Factory().NewStringLiteral(decodeEntities(node.Text()), node.AsStringLiteral().TokenFlags) res.Loc = node.Loc // Preserve the original quote style (single vs double quotes) res.AsStringLiteral().TokenFlags = node.AsStringLiteral().TokenFlags @@ -583,8 +591,8 @@ func (tx *JSXTransformer) visitJsxOpeningLikeElementOrFragmentJSX( line, col := scanner.GetECMALineAndCharacterOfPosition(originalFile.AsSourceFile(), location.Pos()) args = append(args, tx.Factory().NewObjectLiteralExpression(tx.Factory().NewNodeList([]*ast.Node{ tx.Factory().NewPropertyAssignment(nil, tx.Factory().NewIdentifier("fileName"), nil, nil, tx.getCurrentFileNameExpression()), - tx.Factory().NewPropertyAssignment(nil, tx.Factory().NewIdentifier("lineNumber"), nil, nil, tx.Factory().NewNumericLiteral(strconv.FormatInt(int64(line+1), 10))), - tx.Factory().NewPropertyAssignment(nil, tx.Factory().NewIdentifier("columnNumber"), nil, nil, tx.Factory().NewNumericLiteral(strconv.FormatInt(int64(col+1), 10))), + tx.Factory().NewPropertyAssignment(nil, tx.Factory().NewIdentifier("lineNumber"), nil, nil, tx.Factory().NewNumericLiteral(strconv.FormatInt(int64(line+1), 10), ast.TokenFlagsNone)), + tx.Factory().NewPropertyAssignment(nil, tx.Factory().NewIdentifier("columnNumber"), nil, nil, tx.Factory().NewNumericLiteral(strconv.FormatInt(int64(col+1), 10), ast.TokenFlagsNone)), }), false)) // __self development flag args = append(args, tx.Factory().NewThisExpression()) @@ -769,7 +777,7 @@ func (tx *JSXTransformer) visitJsxText(text *ast.JsxText) *ast.Node { if len(fixed) == 0 { return nil } - return tx.Factory().NewStringLiteral(fixed) + return tx.Factory().NewStringLiteral(fixed, ast.TokenFlagsNone) } func addLineOfJsxText(b *strings.Builder, trimmedLine string, isInitial bool) { diff --git a/pkg/transformers/moduletransforms/commonjsmodule.go b/pkg/transformers/moduletransforms/commonjsmodule.go index a7b4f158f..f4e92c16b 100644 --- a/pkg/transformers/moduletransforms/commonjsmodule.go +++ b/pkg/transformers/moduletransforms/commonjsmodule.go @@ -269,7 +269,7 @@ func (tx *CommonJSModuleTransformer) createUnderscoreUnderscoreESModule() *ast.S nil, /*typeArguments*/ tx.Factory().NewNodeList([]*ast.Node{ tx.Factory().NewIdentifier("exports"), - tx.Factory().NewStringLiteral("__esModule"), + tx.Factory().NewStringLiteral("__esModule", ast.TokenFlagsNone), tx.Factory().NewObjectLiteralExpression( tx.Factory().NewNodeList([]*ast.Node{ tx.Factory().NewPropertyAssignment( diff --git a/pkg/transformers/moduletransforms/esmodule.go b/pkg/transformers/moduletransforms/esmodule.go index ee1c9960c..3c32fb919 100644 --- a/pkg/transformers/moduletransforms/esmodule.go +++ b/pkg/transformers/moduletransforms/esmodule.go @@ -320,7 +320,7 @@ func (tx *ESModuleTransformer) createRequireCall(node *ast.Node /*ImportDeclarat }), ), ), - tx.Factory().NewStringLiteral("module"), + tx.Factory().NewStringLiteral("module", ast.TokenFlagsNone), nil, /*attributes*/ ) tx.EmitContext().AddEmitFlags(importStatement, printer.EFCustomPrologue) diff --git a/pkg/transformers/moduletransforms/externalmoduleinfo.go b/pkg/transformers/moduletransforms/externalmoduleinfo.go index 634d90d4d..6c951eb3f 100644 --- a/pkg/transformers/moduletransforms/externalmoduleinfo.go +++ b/pkg/transformers/moduletransforms/externalmoduleinfo.go @@ -259,7 +259,7 @@ func createExternalHelpersImportDeclarationIfNeeded(emitContext *printer.EmitCon nil, /*modifiers*/ false, /*isTypeOnly*/ externalHelpersModuleName, - emitContext.Factory.NewExternalModuleReference(emitContext.Factory.NewStringLiteral(externalHelpersModuleNameText)), + emitContext.Factory.NewExternalModuleReference(emitContext.Factory.NewStringLiteral(externalHelpersModuleNameText, ast.TokenFlagsNone)), ) emitContext.AddEmitFlags(externalHelpersImportDeclaration, printer.EFNeverApplyImportHelper|printer.EFCustomPrologue) return externalHelpersImportDeclaration @@ -293,7 +293,7 @@ func createExternalHelpersImportDeclarationIfNeeded(emitContext *printer.EmitCon externalHelpersImportDeclaration := emitContext.Factory.NewImportDeclaration( nil, /*modifiers*/ emitContext.Factory.NewImportClause(ast.KindUnknown /*phaseModifier*/, nil /*name*/, namedBindings), - emitContext.Factory.NewStringLiteral(externalHelpersModuleNameText), + emitContext.Factory.NewStringLiteral(externalHelpersModuleNameText, ast.TokenFlagsNone), nil, /*attributes*/ ) diff --git a/pkg/transformers/moduletransforms/utilities.go b/pkg/transformers/moduletransforms/utilities.go index 5ca04246a..4dcc69119 100644 --- a/pkg/transformers/moduletransforms/utilities.go +++ b/pkg/transformers/moduletransforms/utilities.go @@ -25,8 +25,7 @@ func rewriteModuleSpecifier(emitContext *printer.EmitContext, node *ast.Expressi } updatedText := tspath.ChangeExtension(node.Text(), outputpaths.GetOutputExtension(node.Text(), compilerOptions.Jsx)) if updatedText != node.Text() { - updated := emitContext.Factory.NewStringLiteral(updatedText) - // !!! set quote style + updated := emitContext.Factory.NewStringLiteral(updatedText, node.AsStringLiteral().TokenFlags) emitContext.SetOriginal(updated, node) emitContext.AssignCommentAndSourceMapRanges(updated, node) return updated @@ -58,8 +57,8 @@ func getExternalModuleNameLiteral(factory *printer.NodeFactory, importNode *ast. if name == nil { name = tryRenameExternalModule(factory, moduleName, sourceFile) } - if name == nil { - name = factory.NewStringLiteral(moduleName.Text()) + if name == nil { // !!! propagate token flags (will produce new diffs) + name = factory.NewStringLiteral(moduleName.Text(), ast.TokenFlagsNone) } return name } diff --git a/pkg/transformers/tstransforms/runtimesyntax.go b/pkg/transformers/tstransforms/runtimesyntax.go index 413bfba23..ad2606e2b 100644 --- a/pkg/transformers/tstransforms/runtimesyntax.go +++ b/pkg/transformers/tstransforms/runtimesyntax.go @@ -190,10 +190,10 @@ func (tx *RuntimeSyntaxTransformer) getExpressionForPropertyName(member *ast.Enu return tx.Visitor().VisitNode(n.Expression) case ast.KindIdentifier: return tx.Factory().NewStringLiteralFromNode(name) - case ast.KindStringLiteral: - return tx.Factory().NewStringLiteral(name.Text()) + case ast.KindStringLiteral: // !!! propagate token flags (will produce new diffs) + return tx.Factory().NewStringLiteral(name.Text(), ast.TokenFlagsNone) case ast.KindNumericLiteral: - return tx.Factory().NewNumericLiteral(name.Text()) + return tx.Factory().NewNumericLiteral(name.Text(), ast.TokenFlagsNone) default: return name } @@ -530,7 +530,7 @@ func (tx *RuntimeSyntaxTransformer) transformEnumMember( ifStatement := tx.Factory().NewIfStatement( tx.Factory().NewStrictInequalityExpression( tx.Factory().NewTypeOfExpression(tx.getEnumQualifiedReference(enum, member)), - tx.Factory().NewStringLiteral("string"), + tx.Factory().NewStringLiteral("string", ast.TokenFlagsNone), ), tx.Factory().NewExpressionStatement( tx.Factory().NewAssignmentExpression( diff --git a/pkg/transformers/tstransforms/utilities.go b/pkg/transformers/tstransforms/utilities.go index 846b82cc3..de2dc9da4 100644 --- a/pkg/transformers/tstransforms/utilities.go +++ b/pkg/transformers/tstransforms/utilities.go @@ -21,7 +21,7 @@ func convertEntityNameToExpression(emitContext *printer.EmitContext, name *ast.E func constantExpression(value any, factory *printer.NodeFactory) *ast.Expression { switch value := value.(type) { case string: - return factory.NewStringLiteral(value) + return factory.NewStringLiteral(value, ast.TokenFlagsNone) case jsnum.Number: if value.IsInf() || value.IsNaN() { return nil @@ -29,7 +29,7 @@ func constantExpression(value any, factory *printer.NodeFactory) *ast.Expression if value < 0 { return factory.NewPrefixUnaryExpression(ast.KindMinusToken, constantExpression(-value, factory)) } - return factory.NewNumericLiteral(value.String()) + return factory.NewNumericLiteral(value.String(), ast.TokenFlagsNone) } return nil } diff --git a/testdata/baselines/reference/compiler/jsdocCommentDefaultExport(module=commonjs).js b/testdata/baselines/reference/compiler/jsdocCommentDefaultExport(module=commonjs).js new file mode 100644 index 000000000..75e727eb3 --- /dev/null +++ b/testdata/baselines/reference/compiler/jsdocCommentDefaultExport(module=commonjs).js @@ -0,0 +1,86 @@ +//// [tests/cases/compiler/jsdocCommentDefaultExport.ts] //// + +//// [exportDefaultObject.ts] +/** Object comment */ +export default { + fn() {} +} + +//// [exportDefaultFunction.ts] +/** Function comment */ +export default function() { + return 42; +} + +//// [exportDefaultClass.ts] +/** Class comment */ +export default class { + method() {} +} + +//// [exportDefaultLiteral.ts] +/** Literal comment */ +export default 42; + +//// [exportDefaultNull.ts] +/** Null comment */ +export default null; + + +//// [exportDefaultObject.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +/** Object comment */ +exports.default = { + fn() { } +}; +//// [exportDefaultFunction.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.default = default_1; +/** Function comment */ +function default_1() { + return 42; +} +//// [exportDefaultClass.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +/** Class comment */ +class default_1 { + method() { } +} +exports.default = default_1; +//// [exportDefaultLiteral.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +/** Literal comment */ +exports.default = 42; +//// [exportDefaultNull.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +/** Null comment */ +exports.default = null; + + +//// [exportDefaultObject.d.ts] +/** Object comment */ +declare const _default: { + fn(): void; +}; +export default _default; +//// [exportDefaultFunction.d.ts] +/** Function comment */ +export default function (): number; +//// [exportDefaultClass.d.ts] +/** Class comment */ +export default class { + method(): void; +} +//// [exportDefaultLiteral.d.ts] +/** Literal comment */ +declare const _default: number; +export default _default; +//// [exportDefaultNull.d.ts] +/** Null comment */ +declare const _default: null; +export default _default; diff --git a/testdata/baselines/reference/compiler/jsdocCommentDefaultExport(module=commonjs).symbols b/testdata/baselines/reference/compiler/jsdocCommentDefaultExport(module=commonjs).symbols new file mode 100644 index 000000000..b4143b62b --- /dev/null +++ b/testdata/baselines/reference/compiler/jsdocCommentDefaultExport(module=commonjs).symbols @@ -0,0 +1,33 @@ +//// [tests/cases/compiler/jsdocCommentDefaultExport.ts] //// + +=== exportDefaultObject.ts === +/** Object comment */ +export default { + fn() {} +>fn : Symbol(fn, Decl(exportDefaultObject.ts, 1, 16)) +} + +=== exportDefaultFunction.ts === + +/** Function comment */ +export default function() { + return 42; +} + +=== exportDefaultClass.ts === +/** Class comment */ +export default class { + method() {} +>method : Symbol(default.method, Decl(exportDefaultClass.ts, 1, 22)) +} + +=== exportDefaultLiteral.ts === + +/** Literal comment */ +export default 42; + +=== exportDefaultNull.ts === + +/** Null comment */ +export default null; + diff --git a/testdata/baselines/reference/compiler/jsdocCommentDefaultExport(module=commonjs).types b/testdata/baselines/reference/compiler/jsdocCommentDefaultExport(module=commonjs).types new file mode 100644 index 000000000..fd463685d --- /dev/null +++ b/testdata/baselines/reference/compiler/jsdocCommentDefaultExport(module=commonjs).types @@ -0,0 +1,35 @@ +//// [tests/cases/compiler/jsdocCommentDefaultExport.ts] //// + +=== exportDefaultObject.ts === +/** Object comment */ +export default { +>{ fn() {}} : { fn(): void; } + + fn() {} +>fn : () => void +} + +=== exportDefaultFunction.ts === +/** Function comment */ +export default function() { + return 42; +>42 : 42 +} + +=== exportDefaultClass.ts === +/** Class comment */ +export default class { + method() {} +>method : () => void +} + +=== exportDefaultLiteral.ts === + +/** Literal comment */ +export default 42; + +=== exportDefaultNull.ts === + +/** Null comment */ +export default null; + diff --git a/testdata/baselines/reference/compiler/jsdocCommentDefaultExport(module=esnext).js b/testdata/baselines/reference/compiler/jsdocCommentDefaultExport(module=esnext).js new file mode 100644 index 000000000..a25f85801 --- /dev/null +++ b/testdata/baselines/reference/compiler/jsdocCommentDefaultExport(module=esnext).js @@ -0,0 +1,74 @@ +//// [tests/cases/compiler/jsdocCommentDefaultExport.ts] //// + +//// [exportDefaultObject.ts] +/** Object comment */ +export default { + fn() {} +} + +//// [exportDefaultFunction.ts] +/** Function comment */ +export default function() { + return 42; +} + +//// [exportDefaultClass.ts] +/** Class comment */ +export default class { + method() {} +} + +//// [exportDefaultLiteral.ts] +/** Literal comment */ +export default 42; + +//// [exportDefaultNull.ts] +/** Null comment */ +export default null; + + +//// [exportDefaultObject.js] +/** Object comment */ +export default { + fn() { } +}; +//// [exportDefaultFunction.js] +/** Function comment */ +export default function () { + return 42; +} +//// [exportDefaultClass.js] +/** Class comment */ +export default class { + method() { } +} +//// [exportDefaultLiteral.js] +/** Literal comment */ +export default 42; +//// [exportDefaultNull.js] +/** Null comment */ +export default null; + + +//// [exportDefaultObject.d.ts] +/** Object comment */ +declare const _default: { + fn(): void; +}; +export default _default; +//// [exportDefaultFunction.d.ts] +/** Function comment */ +export default function (): number; +//// [exportDefaultClass.d.ts] +/** Class comment */ +export default class { + method(): void; +} +//// [exportDefaultLiteral.d.ts] +/** Literal comment */ +declare const _default: number; +export default _default; +//// [exportDefaultNull.d.ts] +/** Null comment */ +declare const _default: null; +export default _default; diff --git a/testdata/baselines/reference/compiler/jsdocCommentDefaultExport(module=esnext).symbols b/testdata/baselines/reference/compiler/jsdocCommentDefaultExport(module=esnext).symbols new file mode 100644 index 000000000..b4143b62b --- /dev/null +++ b/testdata/baselines/reference/compiler/jsdocCommentDefaultExport(module=esnext).symbols @@ -0,0 +1,33 @@ +//// [tests/cases/compiler/jsdocCommentDefaultExport.ts] //// + +=== exportDefaultObject.ts === +/** Object comment */ +export default { + fn() {} +>fn : Symbol(fn, Decl(exportDefaultObject.ts, 1, 16)) +} + +=== exportDefaultFunction.ts === + +/** Function comment */ +export default function() { + return 42; +} + +=== exportDefaultClass.ts === +/** Class comment */ +export default class { + method() {} +>method : Symbol(default.method, Decl(exportDefaultClass.ts, 1, 22)) +} + +=== exportDefaultLiteral.ts === + +/** Literal comment */ +export default 42; + +=== exportDefaultNull.ts === + +/** Null comment */ +export default null; + diff --git a/testdata/baselines/reference/compiler/jsdocCommentDefaultExport(module=esnext).types b/testdata/baselines/reference/compiler/jsdocCommentDefaultExport(module=esnext).types new file mode 100644 index 000000000..fd463685d --- /dev/null +++ b/testdata/baselines/reference/compiler/jsdocCommentDefaultExport(module=esnext).types @@ -0,0 +1,35 @@ +//// [tests/cases/compiler/jsdocCommentDefaultExport.ts] //// + +=== exportDefaultObject.ts === +/** Object comment */ +export default { +>{ fn() {}} : { fn(): void; } + + fn() {} +>fn : () => void +} + +=== exportDefaultFunction.ts === +/** Function comment */ +export default function() { + return 42; +>42 : 42 +} + +=== exportDefaultClass.ts === +/** Class comment */ +export default class { + method() {} +>method : () => void +} + +=== exportDefaultLiteral.ts === + +/** Literal comment */ +export default 42; + +=== exportDefaultNull.ts === + +/** Null comment */ +export default null; + diff --git a/testdata/baselines/reference/compiler/nodeModulesPackageImportsRootWildcard.js b/testdata/baselines/reference/compiler/nodeModulesPackageImportsRootWildcard.js new file mode 100644 index 000000000..799bfc0be --- /dev/null +++ b/testdata/baselines/reference/compiler/nodeModulesPackageImportsRootWildcard.js @@ -0,0 +1,89 @@ +//// [tests/cases/compiler/nodeModulesPackageImportsRootWildcard.ts] //// + +//// [package.json] +{ + "name": "package", + "private": true, + "type": "module", + "imports": { + "#/*": "./src/*" + } +} +//// [foo.ts] +export const foo = "foo"; +//// [bar.ts] +export const bar = "bar"; +//// [baz.ts] +export const baz = "baz"; +//// [index.ts] +// esm format file +import { foo } from "#/foo.js"; +import { bar } from "#/features/bar.js"; +import { baz } from "#/nested/deep/baz.js"; +foo; +bar; +baz; +//// [index.mts] +// esm format file +import { foo } from "#/foo.js"; +import { bar } from "#/features/bar.js"; +import { baz } from "#/nested/deep/baz.js"; +foo; +bar; +baz; +//// [index.cts] +// cjs format file +import { foo } from "#/foo.js"; +import { bar } from "#/features/bar.js"; +import { baz } from "#/nested/deep/baz.js"; +foo; +bar; +baz; + + +//// [foo.js] +export const foo = "foo"; +//// [bar.js] +export const bar = "bar"; +//// [baz.js] +export const baz = "baz"; +//// [index.js] +// esm format file +import { foo } from "#/foo.js"; +import { bar } from "#/features/bar.js"; +import { baz } from "#/nested/deep/baz.js"; +foo; +bar; +baz; +//// [index.mjs] +// esm format file +import { foo } from "#/foo.js"; +import { bar } from "#/features/bar.js"; +import { baz } from "#/nested/deep/baz.js"; +foo; +bar; +baz; +//// [index.cjs] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +// cjs format file +const foo_js_1 = require("#/foo.js"); +const bar_js_1 = require("#/features/bar.js"); +const baz_js_1 = require("#/nested/deep/baz.js"); +foo_js_1.foo; +bar_js_1.bar; +baz_js_1.baz; + + +//// [foo.d.ts] +export declare const foo = "foo"; +//// [bar.d.ts] +export declare const bar = "bar"; +//// [baz.d.ts] +export declare const baz = "baz"; +//// [index.d.ts] +export {}; +//// [index.d.mts] +export {}; +//// [index.d.cts] +export {}; diff --git a/testdata/baselines/reference/compiler/nodeModulesPackageImportsRootWildcard.symbols b/testdata/baselines/reference/compiler/nodeModulesPackageImportsRootWildcard.symbols new file mode 100644 index 000000000..3035fc230 --- /dev/null +++ b/testdata/baselines/reference/compiler/nodeModulesPackageImportsRootWildcard.symbols @@ -0,0 +1,74 @@ +//// [tests/cases/compiler/nodeModulesPackageImportsRootWildcard.ts] //// + +=== src/foo.ts === +export const foo = "foo"; +>foo : Symbol(foo, Decl(foo.ts, 0, 12)) + +=== src/features/bar.ts === +export const bar = "bar"; +>bar : Symbol(bar, Decl(bar.ts, 0, 12)) + +=== src/nested/deep/baz.ts === +export const baz = "baz"; +>baz : Symbol(baz, Decl(baz.ts, 0, 12)) + +=== index.ts === +// esm format file +import { foo } from "#/foo.js"; +>foo : Symbol(foo, Decl(index.ts, 1, 8)) + +import { bar } from "#/features/bar.js"; +>bar : Symbol(bar, Decl(index.ts, 2, 8)) + +import { baz } from "#/nested/deep/baz.js"; +>baz : Symbol(baz, Decl(index.ts, 3, 8)) + +foo; +>foo : Symbol(foo, Decl(index.ts, 1, 8)) + +bar; +>bar : Symbol(bar, Decl(index.ts, 2, 8)) + +baz; +>baz : Symbol(baz, Decl(index.ts, 3, 8)) + +=== index.mts === +// esm format file +import { foo } from "#/foo.js"; +>foo : Symbol(foo, Decl(index.mts, 1, 8)) + +import { bar } from "#/features/bar.js"; +>bar : Symbol(bar, Decl(index.mts, 2, 8)) + +import { baz } from "#/nested/deep/baz.js"; +>baz : Symbol(baz, Decl(index.mts, 3, 8)) + +foo; +>foo : Symbol(foo, Decl(index.mts, 1, 8)) + +bar; +>bar : Symbol(bar, Decl(index.mts, 2, 8)) + +baz; +>baz : Symbol(baz, Decl(index.mts, 3, 8)) + +=== index.cts === +// cjs format file +import { foo } from "#/foo.js"; +>foo : Symbol(foo, Decl(index.cts, 1, 8)) + +import { bar } from "#/features/bar.js"; +>bar : Symbol(bar, Decl(index.cts, 2, 8)) + +import { baz } from "#/nested/deep/baz.js"; +>baz : Symbol(baz, Decl(index.cts, 3, 8)) + +foo; +>foo : Symbol(foo, Decl(index.cts, 1, 8)) + +bar; +>bar : Symbol(bar, Decl(index.cts, 2, 8)) + +baz; +>baz : Symbol(baz, Decl(index.cts, 3, 8)) + diff --git a/testdata/baselines/reference/compiler/nodeModulesPackageImportsRootWildcard.trace.json b/testdata/baselines/reference/compiler/nodeModulesPackageImportsRootWildcard.trace.json new file mode 100644 index 000000000..446f02461 --- /dev/null +++ b/testdata/baselines/reference/compiler/nodeModulesPackageImportsRootWildcard.trace.json @@ -0,0 +1,72 @@ +======== Resolving module '#/foo.js' from '/.src/index.ts'. ======== +Module resolution kind is not specified, using 'NodeNext'. +Resolving in ESM mode with conditions 'import', 'types', 'node'. +Found 'package.json' at '/.src/package.json'. +Using 'imports' subpath '#/*' with target './src/foo.js'. +File name '/.src/src/foo.js' has a '.js' extension - stripping it. +File '/.src/src/foo.ts' exists - use it as a name resolution result. +======== Module name '#/foo.js' was successfully resolved to '/.src/src/foo.ts'. ======== +======== Resolving module '#/features/bar.js' from '/.src/index.ts'. ======== +Module resolution kind is not specified, using 'NodeNext'. +Resolving in ESM mode with conditions 'import', 'types', 'node'. +File '/.src/package.json' exists according to earlier cached lookups. +Using 'imports' subpath '#/*' with target './src/features/bar.js'. +File name '/.src/src/features/bar.js' has a '.js' extension - stripping it. +File '/.src/src/features/bar.ts' exists - use it as a name resolution result. +======== Module name '#/features/bar.js' was successfully resolved to '/.src/src/features/bar.ts'. ======== +======== Resolving module '#/nested/deep/baz.js' from '/.src/index.ts'. ======== +Module resolution kind is not specified, using 'NodeNext'. +Resolving in ESM mode with conditions 'import', 'types', 'node'. +File '/.src/package.json' exists according to earlier cached lookups. +Using 'imports' subpath '#/*' with target './src/nested/deep/baz.js'. +File name '/.src/src/nested/deep/baz.js' has a '.js' extension - stripping it. +File '/.src/src/nested/deep/baz.ts' exists - use it as a name resolution result. +======== Module name '#/nested/deep/baz.js' was successfully resolved to '/.src/src/nested/deep/baz.ts'. ======== +======== Resolving module '#/foo.js' from '/.src/index.mts'. ======== +Module resolution kind is not specified, using 'NodeNext'. +Resolving in ESM mode with conditions 'import', 'types', 'node'. +File '/.src/package.json' exists according to earlier cached lookups. +Using 'imports' subpath '#/*' with target './src/foo.js'. +File name '/.src/src/foo.js' has a '.js' extension - stripping it. +File '/.src/src/foo.ts' exists - use it as a name resolution result. +======== Module name '#/foo.js' was successfully resolved to '/.src/src/foo.ts'. ======== +======== Resolving module '#/features/bar.js' from '/.src/index.mts'. ======== +Module resolution kind is not specified, using 'NodeNext'. +Resolving in ESM mode with conditions 'import', 'types', 'node'. +File '/.src/package.json' exists according to earlier cached lookups. +Using 'imports' subpath '#/*' with target './src/features/bar.js'. +File name '/.src/src/features/bar.js' has a '.js' extension - stripping it. +File '/.src/src/features/bar.ts' exists - use it as a name resolution result. +======== Module name '#/features/bar.js' was successfully resolved to '/.src/src/features/bar.ts'. ======== +======== Resolving module '#/nested/deep/baz.js' from '/.src/index.mts'. ======== +Module resolution kind is not specified, using 'NodeNext'. +Resolving in ESM mode with conditions 'import', 'types', 'node'. +File '/.src/package.json' exists according to earlier cached lookups. +Using 'imports' subpath '#/*' with target './src/nested/deep/baz.js'. +File name '/.src/src/nested/deep/baz.js' has a '.js' extension - stripping it. +File '/.src/src/nested/deep/baz.ts' exists - use it as a name resolution result. +======== Module name '#/nested/deep/baz.js' was successfully resolved to '/.src/src/nested/deep/baz.ts'. ======== +======== Resolving module '#/foo.js' from '/.src/index.cts'. ======== +Module resolution kind is not specified, using 'NodeNext'. +Resolving in CJS mode with conditions 'require', 'types', 'node'. +File '/.src/package.json' exists according to earlier cached lookups. +Using 'imports' subpath '#/*' with target './src/foo.js'. +File name '/.src/src/foo.js' has a '.js' extension - stripping it. +File '/.src/src/foo.ts' exists - use it as a name resolution result. +======== Module name '#/foo.js' was successfully resolved to '/.src/src/foo.ts'. ======== +======== Resolving module '#/features/bar.js' from '/.src/index.cts'. ======== +Module resolution kind is not specified, using 'NodeNext'. +Resolving in CJS mode with conditions 'require', 'types', 'node'. +File '/.src/package.json' exists according to earlier cached lookups. +Using 'imports' subpath '#/*' with target './src/features/bar.js'. +File name '/.src/src/features/bar.js' has a '.js' extension - stripping it. +File '/.src/src/features/bar.ts' exists - use it as a name resolution result. +======== Module name '#/features/bar.js' was successfully resolved to '/.src/src/features/bar.ts'. ======== +======== Resolving module '#/nested/deep/baz.js' from '/.src/index.cts'. ======== +Module resolution kind is not specified, using 'NodeNext'. +Resolving in CJS mode with conditions 'require', 'types', 'node'. +File '/.src/package.json' exists according to earlier cached lookups. +Using 'imports' subpath '#/*' with target './src/nested/deep/baz.js'. +File name '/.src/src/nested/deep/baz.js' has a '.js' extension - stripping it. +File '/.src/src/nested/deep/baz.ts' exists - use it as a name resolution result. +======== Module name '#/nested/deep/baz.js' was successfully resolved to '/.src/src/nested/deep/baz.ts'. ======== diff --git a/testdata/baselines/reference/compiler/nodeModulesPackageImportsRootWildcard.types b/testdata/baselines/reference/compiler/nodeModulesPackageImportsRootWildcard.types new file mode 100644 index 000000000..c5c9206f7 --- /dev/null +++ b/testdata/baselines/reference/compiler/nodeModulesPackageImportsRootWildcard.types @@ -0,0 +1,77 @@ +//// [tests/cases/compiler/nodeModulesPackageImportsRootWildcard.ts] //// + +=== src/foo.ts === +export const foo = "foo"; +>foo : "foo" +>"foo" : "foo" + +=== src/features/bar.ts === +export const bar = "bar"; +>bar : "bar" +>"bar" : "bar" + +=== src/nested/deep/baz.ts === +export const baz = "baz"; +>baz : "baz" +>"baz" : "baz" + +=== index.ts === +// esm format file +import { foo } from "#/foo.js"; +>foo : "foo" + +import { bar } from "#/features/bar.js"; +>bar : "bar" + +import { baz } from "#/nested/deep/baz.js"; +>baz : "baz" + +foo; +>foo : "foo" + +bar; +>bar : "bar" + +baz; +>baz : "baz" + +=== index.mts === +// esm format file +import { foo } from "#/foo.js"; +>foo : "foo" + +import { bar } from "#/features/bar.js"; +>bar : "bar" + +import { baz } from "#/nested/deep/baz.js"; +>baz : "baz" + +foo; +>foo : "foo" + +bar; +>bar : "bar" + +baz; +>baz : "baz" + +=== index.cts === +// cjs format file +import { foo } from "#/foo.js"; +>foo : "foo" + +import { bar } from "#/features/bar.js"; +>bar : "bar" + +import { baz } from "#/nested/deep/baz.js"; +>baz : "baz" + +foo; +>foo : "foo" + +bar; +>bar : "bar" + +baz; +>baz : "baz" + diff --git a/testdata/baselines/reference/compiler/nodeModulesPackageImportsRootWildcardNode16.errors.txt b/testdata/baselines/reference/compiler/nodeModulesPackageImportsRootWildcardNode16.errors.txt new file mode 100644 index 000000000..ea7a1a879 --- /dev/null +++ b/testdata/baselines/reference/compiler/nodeModulesPackageImportsRootWildcardNode16.errors.txt @@ -0,0 +1,21 @@ +index.ts(2,21): error TS2307: Cannot find module '#/foo.js' or its corresponding type declarations. + + +==== package.json (0 errors) ==== + { + "name": "package", + "private": true, + "type": "module", + "imports": { + "#/*": "./src/*" + } + } +==== src/foo.ts (0 errors) ==== + export const foo = "foo"; +==== index.ts (1 errors) ==== + // esm format file + import { foo } from "#/foo.js"; + ~~~~~~~~~~ +!!! error TS2307: Cannot find module '#/foo.js' or its corresponding type declarations. + foo; + \ No newline at end of file diff --git a/testdata/baselines/reference/compiler/nodeModulesPackageImportsRootWildcardNode16.js b/testdata/baselines/reference/compiler/nodeModulesPackageImportsRootWildcardNode16.js new file mode 100644 index 000000000..7447e5085 --- /dev/null +++ b/testdata/baselines/reference/compiler/nodeModulesPackageImportsRootWildcardNode16.js @@ -0,0 +1,31 @@ +//// [tests/cases/compiler/nodeModulesPackageImportsRootWildcardNode16.ts] //// + +//// [package.json] +{ + "name": "package", + "private": true, + "type": "module", + "imports": { + "#/*": "./src/*" + } +} +//// [foo.ts] +export const foo = "foo"; +//// [index.ts] +// esm format file +import { foo } from "#/foo.js"; +foo; + + +//// [foo.js] +export const foo = "foo"; +//// [index.js] +// esm format file +import { foo } from "#/foo.js"; +foo; + + +//// [foo.d.ts] +export declare const foo = "foo"; +//// [index.d.ts] +export {}; diff --git a/testdata/baselines/reference/compiler/nodeModulesPackageImportsRootWildcardNode16.symbols b/testdata/baselines/reference/compiler/nodeModulesPackageImportsRootWildcardNode16.symbols new file mode 100644 index 000000000..8e0673736 --- /dev/null +++ b/testdata/baselines/reference/compiler/nodeModulesPackageImportsRootWildcardNode16.symbols @@ -0,0 +1,14 @@ +//// [tests/cases/compiler/nodeModulesPackageImportsRootWildcardNode16.ts] //// + +=== src/foo.ts === +export const foo = "foo"; +>foo : Symbol(foo, Decl(foo.ts, 0, 12)) + +=== index.ts === +// esm format file +import { foo } from "#/foo.js"; +>foo : Symbol(foo, Decl(index.ts, 1, 8)) + +foo; +>foo : Symbol(foo, Decl(index.ts, 1, 8)) + diff --git a/testdata/baselines/reference/compiler/nodeModulesPackageImportsRootWildcardNode16.trace.json b/testdata/baselines/reference/compiler/nodeModulesPackageImportsRootWildcardNode16.trace.json new file mode 100644 index 000000000..92546135b --- /dev/null +++ b/testdata/baselines/reference/compiler/nodeModulesPackageImportsRootWildcardNode16.trace.json @@ -0,0 +1,21 @@ +======== Resolving module '#/foo.js' from '/.src/index.ts'. ======== +Module resolution kind is not specified, using 'Node16'. +Resolving in ESM mode with conditions 'import', 'types', 'node'. +Invalid import specifier '#/foo.js' has no possible resolutions. +Found 'package.json' at '/.src/package.json'. +Loading module '#/foo.js' from 'node_modules' folder, target file types: TypeScript, JavaScript, Declaration. +Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration. +Directory '/.src/node_modules' does not exist, skipping all lookups in it. +File name '/.src/node_modules/#/foo.js' has a '.js' extension - stripping it. +Directory '/.src/node_modules/@types' does not exist, skipping all lookups in it. +File name '/.src/node_modules/@types/#/foo.js' has a '.js' extension - stripping it. +Directory '/node_modules' does not exist, skipping all lookups in it. +File name '/node_modules/#/foo.js' has a '.js' extension - stripping it. +Directory '/node_modules/@types' does not exist, skipping all lookups in it. +File name '/node_modules/@types/#/foo.js' has a '.js' extension - stripping it. +Searching all ancestor node_modules directories for fallback extensions: JavaScript. +Directory '/.src/node_modules' does not exist, skipping all lookups in it. +File name '/.src/node_modules/#/foo.js' has a '.js' extension - stripping it. +Directory '/node_modules' does not exist, skipping all lookups in it. +File name '/node_modules/#/foo.js' has a '.js' extension - stripping it. +======== Module name '#/foo.js' was not resolved. ======== diff --git a/testdata/baselines/reference/compiler/nodeModulesPackageImportsRootWildcardNode16.types b/testdata/baselines/reference/compiler/nodeModulesPackageImportsRootWildcardNode16.types new file mode 100644 index 000000000..54fd4afd5 --- /dev/null +++ b/testdata/baselines/reference/compiler/nodeModulesPackageImportsRootWildcardNode16.types @@ -0,0 +1,15 @@ +//// [tests/cases/compiler/nodeModulesPackageImportsRootWildcardNode16.ts] //// + +=== src/foo.ts === +export const foo = "foo"; +>foo : "foo" +>"foo" : "foo" + +=== index.ts === +// esm format file +import { foo } from "#/foo.js"; +>foo : any + +foo; +>foo : any + diff --git a/testdata/baselines/reference/fourslash/documentSymbols/deleteClassWithEnumPresent.baseline b/testdata/baselines/reference/fourslash/documentSymbols/deleteClassWithEnumPresent.baseline new file mode 100644 index 000000000..7d97b0718 --- /dev/null +++ b/testdata/baselines/reference/fourslash/documentSymbols/deleteClassWithEnumPresent.baseline @@ -0,0 +1,10 @@ +// === Document Symbols === +// === /deleteClassWithEnumPresent.ts === +// <|enum [|{| name: Foo, kind: Enum |}Foo|] { <|[|{| name: a, kind: EnumMember |}a|]|>, <|[|{| name: b, kind: EnumMember |}b|]|>, <|[|{| name: c, kind: EnumMember |}c|]|> }|> +// + +// === Details === +(Enum) Foo + (EnumMember) a + (EnumMember) b + (EnumMember) c diff --git a/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsExportAsNamespace.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsExportAsNamespace.baseline.jsonc new file mode 100644 index 000000000..af8207cea --- /dev/null +++ b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsExportAsNamespace.baseline.jsonc @@ -0,0 +1,36 @@ +// === findAllReferences === +// === /b.ts === +// import { [|f|] } from "a"; + +// === /c.ts === +// A.[|f|](); + +// === /node_modules/a/index.d.ts === +// export function /*FIND ALL REFS*/[|f|](): void; +// export as namespace A; + + + +// === findAllReferences === +// === /b.ts === +// import { /*FIND ALL REFS*/[|f|] } from "a"; + +// === /c.ts === +// A.[|f|](); + +// === /node_modules/a/index.d.ts === +// export function [|f|](): void; +// export as namespace A; + + + +// === findAllReferences === +// === /b.ts === +// import { [|f|] } from "a"; + +// === /c.ts === +// A./*FIND ALL REFS*/[|f|](); + +// === /node_modules/a/index.d.ts === +// export function [|f|](): void; +// export as namespace A; \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsForDefaultExport08.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsForDefaultExport08.baseline.jsonc new file mode 100644 index 000000000..3b568a570 --- /dev/null +++ b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsForDefaultExport08.baseline.jsonc @@ -0,0 +1,8 @@ +// === findAllReferences === +// === /findAllRefsForDefaultExport08.ts === +// --- (line: 4) skipped --- +// +// var y = new DefaultExportedClass; +// +// namespace /*FIND ALL REFS*/[|DefaultExportedClass|] { +// } \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsForDefaultExport_reExport_allowSyntheticDefaultImports.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsForDefaultExport_reExport_allowSyntheticDefaultImports.baseline.jsonc new file mode 100644 index 000000000..666b50c40 --- /dev/null +++ b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsForDefaultExport_reExport_allowSyntheticDefaultImports.baseline.jsonc @@ -0,0 +1,49 @@ +// === findAllReferences === +// === /export.ts === +// const /*FIND ALL REFS*/[|foo|] = 1; +// export = [|foo|]; + +// === /re-export-dep.ts === +// import [|fooDefault|] from "./re-export"; + +// === /re-export.ts === +// export { [|default|] } from "./export"; + + + +// === findAllReferences === +// === /export.ts === +// const [|foo|] = 1; +// export = /*FIND ALL REFS*/[|foo|]; + +// === /re-export-dep.ts === +// import [|fooDefault|] from "./re-export"; + +// === /re-export.ts === +// export { [|default|] } from "./export"; + + + +// === findAllReferences === +// === /export.ts === +// const [|foo|] = 1; +// export = [|foo|]; + +// === /re-export-dep.ts === +// import [|fooDefault|] from "./re-export"; + +// === /re-export.ts === +// export { /*FIND ALL REFS*/[|default|] } from "./export"; + + + +// === findAllReferences === +// === /export.ts === +// const [|foo|] = 1; +// export = [|foo|]; + +// === /re-export-dep.ts === +// import /*FIND ALL REFS*/[|fooDefault|] from "./re-export"; + +// === /re-export.ts === +// export { [|default|] } from "./export"; \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsForModuleGlobal.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsForModuleGlobal.baseline.jsonc new file mode 100644 index 000000000..cdad54c70 --- /dev/null +++ b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsForModuleGlobal.baseline.jsonc @@ -0,0 +1,5 @@ +// === findAllReferences === +// === /b.ts === +// /// +// import { x } from "/*FIND ALL REFS*/foo"; +// declare module "[|foo|]" {} \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsGlobalModuleAugmentation.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsGlobalModuleAugmentation.baseline.jsonc new file mode 100644 index 000000000..a9ba8fd03 --- /dev/null +++ b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsGlobalModuleAugmentation.baseline.jsonc @@ -0,0 +1,33 @@ +// === findAllReferences === +// === /a.ts === +// export {}; +// declare global { +// /*FIND ALL REFS*/function [|f|](): void; +// } + +// === /b.ts === +// [|f|](); + + + +// === findAllReferences === +// === /a.ts === +// export {}; +// declare global { +// function /*FIND ALL REFS*/[|f|](): void; +// } + +// === /b.ts === +// [|f|](); + + + +// === findAllReferences === +// === /a.ts === +// export {}; +// declare global { +// function [|f|](): void; +// } + +// === /b.ts === +// /*FIND ALL REFS*/[|f|](); \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsImportDefault.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsImportDefault.baseline.jsonc new file mode 100644 index 000000000..e87ec96ce --- /dev/null +++ b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsImportDefault.baseline.jsonc @@ -0,0 +1,10 @@ +// === findAllReferences === +// === /b.ts === +// import [|bar|] from "./f"; +// [|bar|](1, 2); + +// === /f.ts === +// export { [|foo|] as [|default|] }; +// function /*FIND ALL REFS*/[|foo|](a: number, b: number) { +// return a + b; +// } \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsImportEqualsJsonFile.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsImportEqualsJsonFile.baseline.jsonc new file mode 100644 index 000000000..196ae3912 --- /dev/null +++ b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsImportEqualsJsonFile.baseline.jsonc @@ -0,0 +1,59 @@ +// === findAllReferences === +// === /a.ts === +// import /*FIND ALL REFS*/[|j|] = require("./j.json"); +// [|j|]; + + + +// === findAllReferences === +// === /a.ts === +// import [|j|] = require("./j.json"); +// /*FIND ALL REFS*/[|j|]; + + + +// === findAllReferences === +// === /a.ts === +// import j = require("/*FIND ALL REFS*/[|./j.json|]"); +// j; + +// === /b.js === +// const j = require("[|./j.json|]"); +// j; + +// === /j.json === +// [|{ "x": 0 }|] + + + +// === findAllReferences === +// === /a.ts === +// import j = require("[|./j.json|]"); +// j; + +// === /b.js === +// const j = require("/*FIND ALL REFS*/[|./j.json|]"); +// j; + +// === /j.json === +// [|{ "x": 0 }|] + + + +// === findAllReferences === +// === /b.js === +// const /*FIND ALL REFS*/[|j|] = require("./j.json"); +// [|j|]; + + + +// === findAllReferences === +// === /b.js === +// const [|j|] = require("./j.json"); +// /*FIND ALL REFS*/[|j|]; + + + +// === findAllReferences === +// === /j.json === +// /*FIND ALL REFS*/{ "x": 0 } \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsImportNamed.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsImportNamed.baseline.jsonc new file mode 100644 index 000000000..7c5bd7e1a --- /dev/null +++ b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsImportNamed.baseline.jsonc @@ -0,0 +1,8 @@ +// === findAllReferences === +// === /b.ts === +// import x = require("./f"); +// x.[|foo|](1, 2); + +// === /f.ts === +// export { [|foo|] as [|foo|] } +// function /*FIND ALL REFS*/[|foo|](a: number, b: number) { } \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsImportStarOfExportEquals.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsImportStarOfExportEquals.baseline.jsonc new file mode 100644 index 000000000..635c80ede --- /dev/null +++ b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsImportStarOfExportEquals.baseline.jsonc @@ -0,0 +1,133 @@ +// === findAllReferences === +// === /b.ts === +// import [|b|] from "a"; +// [|b|](); +// [|b|].x; + +// === /c.ts === +// import [|a|] from "a"; +// [|a|](); +// [|a|].x; + +// === /node_modules/a/index.d.ts === +// declare function /*FIND ALL REFS*/[|a|](): void; +// declare namespace [|a|] { +// export const x: number; +// } +// export = [|a|]; + + + +// === findAllReferences === +// === /b.ts === +// import [|b|] from "a"; +// [|b|](); +// [|b|].x; + +// === /c.ts === +// import [|a|] from "a"; +// [|a|](); +// [|a|].x; + +// === /node_modules/a/index.d.ts === +// declare function [|a|](): void; +// declare namespace /*FIND ALL REFS*/[|a|] { +// export const x: number; +// } +// export = [|a|]; + + + +// === findAllReferences === +// === /b.ts === +// import [|b|] from "a"; +// [|b|](); +// [|b|].x; + +// === /c.ts === +// import [|a|] from "a"; +// [|a|](); +// [|a|].x; + +// === /node_modules/a/index.d.ts === +// declare function [|a|](): void; +// declare namespace [|a|] { +// export const x: number; +// } +// export = /*FIND ALL REFS*/[|a|]; + + + +// === findAllReferences === +// === /b.ts === +// import /*FIND ALL REFS*/[|b|] from "a"; +// [|b|](); +// [|b|].x; + + + +// === findAllReferences === +// === /b.ts === +// import [|b|] from "a"; +// /*FIND ALL REFS*/[|b|](); +// [|b|].x; + + + +// === findAllReferences === +// === /b.ts === +// import [|b|] from "a"; +// [|b|](); +// [|b|].x; + +// === /c.ts === +// import /*FIND ALL REFS*/[|a|] from "a"; +// [|a|](); +// [|a|].x; + +// === /node_modules/a/index.d.ts === +// declare function [|a|](): void; +// declare namespace [|a|] { +// export const x: number; +// } +// export = [|a|]; + + + +// === findAllReferences === +// === /b.ts === +// import [|b|] from "a"; +// [|b|](); +// [|b|].x; + +// === /c.ts === +// import [|a|] from "a"; +// /*FIND ALL REFS*/[|a|](); +// [|a|].x; + +// === /node_modules/a/index.d.ts === +// declare function [|a|](): void; +// declare namespace [|a|] { +// export const x: number; +// } +// export = [|a|]; + + + +// === findAllReferences === +// === /b.ts === +// import [|b|] from "a"; +// [|b|](); +// [|b|].x; + +// === /c.ts === +// import [|a|] from "a"; +// [|a|](); +// /*FIND ALL REFS*/[|a|].x; + +// === /node_modules/a/index.d.ts === +// declare function [|a|](): void; +// declare namespace [|a|] { +// export const x: number; +// } +// export = [|a|]; \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsModuleAugmentation.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsModuleAugmentation.baseline.jsonc new file mode 100644 index 000000000..3951cc01d --- /dev/null +++ b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsModuleAugmentation.baseline.jsonc @@ -0,0 +1,33 @@ +// === findAllReferences === +// === /a.ts === +// import * as foo from "foo"; +// declare module "foo" { +// export const x: [|T|]; +// } + +// === /node_modules/foo/index.d.ts === +// /*FIND ALL REFS*/export type [|T|] = number; + + + +// === findAllReferences === +// === /a.ts === +// import * as foo from "foo"; +// declare module "foo" { +// export const x: [|T|]; +// } + +// === /node_modules/foo/index.d.ts === +// export type /*FIND ALL REFS*/[|T|] = number; + + + +// === findAllReferences === +// === /a.ts === +// import * as foo from "foo"; +// declare module "foo" { +// export const x: /*FIND ALL REFS*/[|T|]; +// } + +// === /node_modules/foo/index.d.ts === +// export type [|T|] = number; \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsOfConstructor.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsOfConstructor.baseline.jsonc new file mode 100644 index 000000000..988a5f99e --- /dev/null +++ b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsOfConstructor.baseline.jsonc @@ -0,0 +1,39 @@ +// === findAllReferences === +// === /findAllRefsOfConstructor.ts === +// class A { +// /*FIND ALL REFS*/[|constructor|](s: string) {} +// } +// class B extends A { } +// class C extends B { +// constructor() { +// [|super|](""); +// } +// } +// class D extends B { } +// class E implements A { } +// const a = new [|A|]("a"); +// const b = new [|B|]("b"); +// const c = new C(); +// const d = new [|D|]("d"); +// const e = new E(); + + + +// === findAllReferences === +// === /findAllRefsOfConstructor.ts === +// class A { +// constructor(s: string) {} +// } +// class B extends A { } +// class C extends B { +// /*FIND ALL REFS*/[|constructor|]() { +// super(""); +// } +// } +// class D extends B { } +// class E implements A { } +// const a = new A("a"); +// const b = new B("b"); +// const c = new [|C|](); +// const d = new D("d"); +// const e = new E(); \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsOfConstructor2.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsOfConstructor2.baseline.jsonc new file mode 100644 index 000000000..6aa7d264e --- /dev/null +++ b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsOfConstructor2.baseline.jsonc @@ -0,0 +1,57 @@ +// === findAllReferences === +// === /findAllRefsOfConstructor2.ts === +// class A { +// /*FIND ALL REFS*/[|constructor|](s: string) {} +// } +// class B extends A { +// constructor() { [|super|](""); } +// } +// class C extends B { +// constructor() { +// super(); +// } +// } +// class D extends B { } +// const a = new [|A|]("a"); +// const b = new B(); +// const c = new C(); +// const d = new D(); + + + +// === findAllReferences === +// === /findAllRefsOfConstructor2.ts === +// class A { +// constructor(s: string) {} +// } +// class B extends A { +// /*FIND ALL REFS*/[|constructor|]() { super(""); } +// } +// class C extends B { +// constructor() { +// [|super|](); +// } +// } +// class D extends B { } +// const a = new A("a"); +// const b = new [|B|](); +// const c = new C(); +// const d = new [|D|](); + + + +// === findAllReferences === +// === /findAllRefsOfConstructor2.ts === +// --- (line: 4) skipped --- +// constructor() { super(""); } +// } +// class C extends B { +// /*FIND ALL REFS*/[|constructor|]() { +// super(); +// } +// } +// class D extends B { } +// const a = new A("a"); +// const b = new B(); +// const c = new [|C|](); +// const d = new D(); \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsOfConstructor_multipleFiles.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsOfConstructor_multipleFiles.baseline.jsonc new file mode 100644 index 000000000..8d1f4f8ea --- /dev/null +++ b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsOfConstructor_multipleFiles.baseline.jsonc @@ -0,0 +1,18 @@ +// === findAllReferences === +// === /a.ts === +// import { [|A|] as A1 } from "./f"; +// const a1 = new [|A1|]("a1"); +// export default class extends A1 { } +// export { [|B|] as [|B1|] } from "./f"; + +// === /b.ts === +// import B, { B1 } from "./a"; +// const d = new [|B|]("b"); +// const d1 = new [|B1|]("b1"); + +// === /f.ts === +// class A { +// /*FIND ALL REFS*/[|constructor|](s: string) {} +// } +// class B extends A { } +// export { [|A|], [|B|] }; \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsPrefixSuffixPreference.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsPrefixSuffixPreference.baseline.jsonc new file mode 100644 index 000000000..4909dd61c --- /dev/null +++ b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsPrefixSuffixPreference.baseline.jsonc @@ -0,0 +1,106 @@ +// === findAllReferences === +// === /file1.ts === +// declare function log(s: string | number): void; +// const /*FIND ALL REFS*/[|q|] = 1; +// export { [|q|] }; +// const x = { +// z: 'value' +// } +// const { z } = x; +// log(z); + +// === /file2.ts === +// declare function log(s: string | number): void; +// import { [|q|] } from "./file1"; +// log([|q|] + 1); + + + +// === findAllReferences === +// === /file1.ts === +// declare function log(s: string | number): void; +// const [|q|] = 1; +// export { /*FIND ALL REFS*/[|q|] }; +// const x = { +// z: 'value' +// } +// const { z } = x; +// log(z); + +// === /file2.ts === +// declare function log(s: string | number): void; +// import { [|q|] } from "./file1"; +// log([|q|] + 1); + + + +// === findAllReferences === +// === /file1.ts === +// declare function log(s: string | number): void; +// const [|q|] = 1; +// export { [|q|] }; +// const x = { +// z: 'value' +// } +// const { z } = x; +// log(z); + +// === /file2.ts === +// declare function log(s: string | number): void; +// import { /*FIND ALL REFS*/[|q|] } from "./file1"; +// log([|q|] + 1); + + + +// === findAllReferences === +// === /file1.ts === +// declare function log(s: string | number): void; +// const [|q|] = 1; +// export { [|q|] }; +// const x = { +// z: 'value' +// } +// const { z } = x; +// log(z); + +// === /file2.ts === +// declare function log(s: string | number): void; +// import { [|q|] } from "./file1"; +// log(/*FIND ALL REFS*/[|q|] + 1); + + + +// === findAllReferences === +// === /file1.ts === +// declare function log(s: string | number): void; +// const q = 1; +// export { q }; +// const x = { +// /*FIND ALL REFS*/[|z|]: 'value' +// } +// const { [|z|] } = x; +// log(z); + + + +// === findAllReferences === +// === /file1.ts === +// declare function log(s: string | number): void; +// const q = 1; +// export { q }; +// const x = { +// [|z|]: 'value' +// } +// const { /*FIND ALL REFS*/[|z|] } = x; +// log([|z|]); + + + +// === findAllReferences === +// === /file1.ts === +// --- (line: 3) skipped --- +// const x = { +// z: 'value' +// } +// const { [|z|] } = x; +// log(/*FIND ALL REFS*/[|z|]); \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsReExportLocal.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsReExportLocal.baseline.jsonc new file mode 100644 index 000000000..147c24f1e --- /dev/null +++ b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsReExportLocal.baseline.jsonc @@ -0,0 +1,93 @@ +// === findAllReferences === +// === /a.ts === +// var /*FIND ALL REFS*/[|x|]; +// export { [|x|] }; +// export { [|x|] as [|y|] }; + +// === /b.ts === +// import { [|x|], [|y|] } from "./a"; +// [|x|]; [|y|]; + + + +// === findAllReferences === +// === /a.ts === +// var [|x|]; +// export { /*FIND ALL REFS*/[|x|] }; +// export { [|x|] as [|y|] }; + +// === /b.ts === +// import { [|x|], [|y|] } from "./a"; +// [|x|]; [|y|]; + + + +// === findAllReferences === +// === /a.ts === +// var [|x|]; +// export { [|x|] }; +// export { /*FIND ALL REFS*/[|x|] as [|y|] }; + +// === /b.ts === +// import { [|x|], [|y|] } from "./a"; +// [|x|]; [|y|]; + + + +// === findAllReferences === +// === /a.ts === +// var [|x|]; +// export { [|x|] }; +// export { [|x|] as [|y|] }; + +// === /b.ts === +// import { /*FIND ALL REFS*/[|x|], [|y|] } from "./a"; +// [|x|]; [|y|]; + + + +// === findAllReferences === +// === /a.ts === +// var [|x|]; +// export { [|x|] }; +// export { [|x|] as [|y|] }; + +// === /b.ts === +// import { [|x|], [|y|] } from "./a"; +// /*FIND ALL REFS*/[|x|]; [|y|]; + + + +// === findAllReferences === +// === /a.ts === +// var x; +// export { x }; +// export { x as /*FIND ALL REFS*/[|y|] }; + +// === /b.ts === +// import { x, [|y|] } from "./a"; +// x; [|y|]; + + + +// === findAllReferences === +// === /a.ts === +// var x; +// export { x }; +// export { x as [|y|] }; + +// === /b.ts === +// import { x, /*FIND ALL REFS*/[|y|] } from "./a"; +// x; [|y|]; + + + +// === findAllReferences === +// === /a.ts === +// var x; +// export { x }; +// export { x as [|y|] }; + +// === /b.ts === +// import { x, [|y|] } from "./a"; +// x; /*FIND ALL REFS*/[|y|]; \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsReExportRightNameWrongSymbol.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsReExportRightNameWrongSymbol.baseline.jsonc new file mode 100644 index 000000000..690a32520 --- /dev/null +++ b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsReExportRightNameWrongSymbol.baseline.jsonc @@ -0,0 +1,72 @@ +// === findAllReferences === +// === /a.ts === +// export const /*FIND ALL REFS*/[|x|] = 0; + +// === /c.ts === +// export { x } from "./b"; +// import { [|x|] } from "./a"; +// [|x|]; + + + +// === findAllReferences === +// === /b.ts === +// export const /*FIND ALL REFS*/[|x|] = 0; + +// === /c.ts === +// export { [|x|] } from "./b"; +// import { x } from "./a"; +// x; + +// === /d.ts === +// import { [|x|] } from "./c"; + + + +// === findAllReferences === +// === /b.ts === +// export const [|x|] = 0; + +// === /c.ts === +// export { /*FIND ALL REFS*/[|x|] } from "./b"; +// import { x } from "./a"; +// x; + +// === /d.ts === +// import { [|x|] } from "./c"; + + + +// === findAllReferences === +// === /a.ts === +// export const [|x|] = 0; + +// === /c.ts === +// export { x } from "./b"; +// import { /*FIND ALL REFS*/[|x|] } from "./a"; +// [|x|]; + + + +// === findAllReferences === +// === /a.ts === +// export const [|x|] = 0; + +// === /c.ts === +// export { x } from "./b"; +// import { [|x|] } from "./a"; +// /*FIND ALL REFS*/[|x|]; + + + +// === findAllReferences === +// === /b.ts === +// export const [|x|] = 0; + +// === /c.ts === +// export { [|x|] } from "./b"; +// import { x } from "./a"; +// x; + +// === /d.ts === +// import { /*FIND ALL REFS*/[|x|] } from "./c"; \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsReExportStar.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsReExportStar.baseline.jsonc new file mode 100644 index 000000000..37e4edbc0 --- /dev/null +++ b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsReExportStar.baseline.jsonc @@ -0,0 +1,15 @@ +// === findAllReferences === +// === /a.ts === +// export function /*FIND ALL REFS*/[|foo|](): void {} + +// === /c.ts === +// import { [|foo|] } from "./b"; + + + +// === findAllReferences === +// === /a.ts === +// export function [|foo|](): void {} + +// === /c.ts === +// import { /*FIND ALL REFS*/[|foo|] } from "./b"; \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsReExportStarAs.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsReExportStarAs.baseline.jsonc new file mode 100644 index 000000000..22a217bed --- /dev/null +++ b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsReExportStarAs.baseline.jsonc @@ -0,0 +1,47 @@ +// === findAllReferences === +// === /importing.ts === +// import { Leaf } from './exporting'; +// Leaf.[|hello|]() + +// === /leafModule.ts === +// export const /*FIND ALL REFS*/[|hello|] = () => 'Hello'; + + + +// === findAllReferences === +// === /importing.ts === +// import { Leaf } from './exporting'; +// Leaf./*FIND ALL REFS*/[|hello|]() + +// === /leafModule.ts === +// export const [|hello|] = () => 'Hello'; + + + +// === findAllReferences === +// === /exporting.ts === +// export * as /*FIND ALL REFS*/[|Leaf|] from './leafModule'; + +// === /importing.ts === +// import { [|Leaf|] } from './exporting'; +// [|Leaf|].hello() + + + +// === findAllReferences === +// === /exporting.ts === +// export * as [|Leaf|] from './leafModule'; + +// === /importing.ts === +// import { /*FIND ALL REFS*/[|Leaf|] } from './exporting'; +// [|Leaf|].hello() + + + +// === findAllReferences === +// === /exporting.ts === +// export * as [|Leaf|] from './leafModule'; + +// === /importing.ts === +// import { [|Leaf|] } from './exporting'; +// /*FIND ALL REFS*/[|Leaf|].hello() \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsReExports2.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsReExports2.baseline.jsonc new file mode 100644 index 000000000..10f2a591c --- /dev/null +++ b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsReExports2.baseline.jsonc @@ -0,0 +1,6 @@ +// === findAllReferences === +// === /a.ts === +// export function /*FIND ALL REFS*/[|foo|](): void {} + +// === /b.ts === +// import { [|foo|] as [|oof|] } from "./a"; \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsReExportsUseInImportType.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsReExportsUseInImportType.baseline.jsonc new file mode 100644 index 000000000..a647cd1eb --- /dev/null +++ b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsReExportsUseInImportType.baseline.jsonc @@ -0,0 +1,98 @@ +// === findAllReferences === +// === /app.ts === +// import { foo } from './foo/types'; +// export type fullType = foo.[|Full|]; +// type namespaceImport = typeof import('./foo/types'); +// type fullType2 = import('./foo/types').foo.[|Full|]; + +// === /foo/types/types.ts === +// export type /*FIND ALL REFS*/[|Full|] = { prop: string; }; + + + +// === findAllReferences === +// === /app.ts === +// import { foo } from './foo/types'; +// export type fullType = foo./*FIND ALL REFS*/[|Full|]; +// type namespaceImport = typeof import('./foo/types'); +// type fullType2 = import('./foo/types').foo.[|Full|]; + +// === /foo/types/types.ts === +// export type [|Full|] = { prop: string; }; + + + +// === findAllReferences === +// === /app.ts === +// import { foo } from './foo/types'; +// export type fullType = foo.[|Full|]; +// type namespaceImport = typeof import('./foo/types'); +// type fullType2 = import('./foo/types').foo./*FIND ALL REFS*/[|Full|]; + +// === /foo/types/types.ts === +// export type [|Full|] = { prop: string; }; + + + +// === findAllReferences === +// === /app.ts === +// import { [|foo|] } from './foo/types'; +// export type fullType = [|foo|].Full; +// type namespaceImport = typeof import('./foo/types'); +// type fullType2 = import('./foo/types').[|foo|].Full; + +// === /foo/types/index.ts === +// import * as /*FIND ALL REFS*/[|foo|] from './types'; +// export { [|foo|] }; + + + +// === findAllReferences === +// === /app.ts === +// import { [|foo|] } from './foo/types'; +// export type fullType = [|foo|].Full; +// type namespaceImport = typeof import('./foo/types'); +// type fullType2 = import('./foo/types').[|foo|].Full; + +// === /foo/types/index.ts === +// import * as [|foo|] from './types'; +// export { /*FIND ALL REFS*/[|foo|] }; + + + +// === findAllReferences === +// === /app.ts === +// import { /*FIND ALL REFS*/[|foo|] } from './foo/types'; +// export type fullType = [|foo|].Full; +// type namespaceImport = typeof import('./foo/types'); +// type fullType2 = import('./foo/types').[|foo|].Full; + +// === /foo/types/index.ts === +// import * as [|foo|] from './types'; +// export { [|foo|] }; + + + +// === findAllReferences === +// === /app.ts === +// import { [|foo|] } from './foo/types'; +// export type fullType = /*FIND ALL REFS*/[|foo|].Full; +// type namespaceImport = typeof import('./foo/types'); +// type fullType2 = import('./foo/types').[|foo|].Full; + +// === /foo/types/index.ts === +// import * as [|foo|] from './types'; +// export { [|foo|] }; + + + +// === findAllReferences === +// === /app.ts === +// import { [|foo|] } from './foo/types'; +// export type fullType = [|foo|].Full; +// type namespaceImport = typeof import('./foo/types'); +// type fullType2 = import('./foo/types')./*FIND ALL REFS*/[|foo|].Full; + +// === /foo/types/index.ts === +// import * as [|foo|] from './types'; +// export { [|foo|] }; \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsRenameImportWithSameName.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsRenameImportWithSameName.baseline.jsonc new file mode 100644 index 000000000..35698023d --- /dev/null +++ b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsRenameImportWithSameName.baseline.jsonc @@ -0,0 +1,31 @@ +// === findAllReferences === +// === /a.ts === +// export const /*FIND ALL REFS*/[|x|] = 0; + +// === /b.ts === +// import { [|x|] as [|x|] } from "./a"; +// [|x|]; + + + +// === findAllReferences === +// === /a.ts === +// export const [|x|] = 0; + +// === /b.ts === +// import { /*FIND ALL REFS*/[|x|] as [|x|] } from "./a"; +// [|x|]; + + + +// === findAllReferences === +// === /b.ts === +// import { x as /*FIND ALL REFS*/[|x|] } from "./a"; +// [|x|]; + + + +// === findAllReferences === +// === /b.ts === +// import { x as [|x|] } from "./a"; +// /*FIND ALL REFS*/[|x|]; \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/findAllReferences/referencesForAmbients2.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/referencesForAmbients2.baseline.jsonc new file mode 100644 index 000000000..5cf89ccc7 --- /dev/null +++ b/testdata/baselines/reference/fourslash/findAllReferences/referencesForAmbients2.baseline.jsonc @@ -0,0 +1,77 @@ +// === findAllReferences === +// === /defA.ts === +// declare module "a" { +// /*FIND ALL REFS*/export type [|T|] = number; +// } + +// === /defB.ts === +// declare module "b" { +// export import a = require("a"); +// export const x: a.[|T|]; +// } + +// === /defC.ts === +// declare module "c" { +// import b = require("b"); +// const x: b.a.[|T|]; +// } + + + +// === findAllReferences === +// === /defA.ts === +// declare module "a" { +// export type /*FIND ALL REFS*/[|T|] = number; +// } + +// === /defB.ts === +// declare module "b" { +// export import a = require("a"); +// export const x: a.[|T|]; +// } + +// === /defC.ts === +// declare module "c" { +// import b = require("b"); +// const x: b.a.[|T|]; +// } + + + +// === findAllReferences === +// === /defA.ts === +// declare module "a" { +// export type [|T|] = number; +// } + +// === /defB.ts === +// declare module "b" { +// export import a = require("a"); +// export const x: a./*FIND ALL REFS*/[|T|]; +// } + +// === /defC.ts === +// declare module "c" { +// import b = require("b"); +// const x: b.a.[|T|]; +// } + + + +// === findAllReferences === +// === /defA.ts === +// declare module "a" { +// export type [|T|] = number; +// } + +// === /defB.ts === +// declare module "b" { +// export import a = require("a"); +// export const x: a.[|T|]; +// } + +// === /defC.ts === +// declare module "c" { +// import b = require("b"); +// const x: b.a./*FIND ALL REFS*/[|T|]; +// } \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/findAllReferences/renameImportOfExportEquals2.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/renameImportOfExportEquals2.baseline.jsonc new file mode 100644 index 000000000..aeda0414e --- /dev/null +++ b/testdata/baselines/reference/fourslash/findAllReferences/renameImportOfExportEquals2.baseline.jsonc @@ -0,0 +1,59 @@ +// === findAllReferences === +// === /renameImportOfExportEquals2.ts === +// declare namespace /*FIND ALL REFS*/[|N|] { +// export var x: number; +// } +// declare module "mod" { +// export = [|N|]; +// } +// declare module "a" { +// import * as [|O|] from "mod"; +// export { [|O|] as [|P|] }; // Renaming N here would rename +// } +// declare module "b" { +// import { [|P|] as [|Q|] } from "a"; +// export const y: typeof [|Q|].x; +// } + + + +// === findAllReferences === +// === /renameImportOfExportEquals2.ts === +// --- (line: 4) skipped --- +// export = N; +// } +// declare module "a" { +// import * as /*FIND ALL REFS*/[|O|] from "mod"; +// export { [|O|] as [|P|] }; // Renaming N here would rename +// } +// declare module "b" { +// import { [|P|] as [|Q|] } from "a"; +// export const y: typeof [|Q|].x; +// } + + + +// === findAllReferences === +// === /renameImportOfExportEquals2.ts === +// --- (line: 5) skipped --- +// } +// declare module "a" { +// import * as O from "mod"; +// export { O as /*FIND ALL REFS*/[|P|] }; // Renaming N here would rename +// } +// declare module "b" { +// import { [|P|] as [|Q|] } from "a"; +// export const y: typeof [|Q|].x; +// } + + + +// === findAllReferences === +// === /renameImportOfExportEquals2.ts === +// --- (line: 8) skipped --- +// export { O as P }; // Renaming N here would rename +// } +// declare module "b" { +// import { P as /*FIND ALL REFS*/[|Q|] } from "a"; +// export const y: typeof [|Q|].x; +// } \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/findAllReferences/renameImportOfReExport.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/renameImportOfReExport.baseline.jsonc new file mode 100644 index 000000000..001ff3c4f --- /dev/null +++ b/testdata/baselines/reference/fourslash/findAllReferences/renameImportOfReExport.baseline.jsonc @@ -0,0 +1,42 @@ +// === findAllReferences === +// === /renameImportOfReExport.ts === +// declare module "a" { +// export class /*FIND ALL REFS*/[|C|] {} +// } +// declare module "b" { +// export { [|C|] } from "a"; +// } +// declare module "c" { +// import { [|C|] } from "b"; +// export function f(c: [|C|]): void; +// } + + + +// === findAllReferences === +// === /renameImportOfReExport.ts === +// declare module "a" { +// export class [|C|] {} +// } +// declare module "b" { +// export { /*FIND ALL REFS*/[|C|] } from "a"; +// } +// declare module "c" { +// import { [|C|] } from "b"; +// export function f(c: [|C|]): void; +// } + + + +// === findAllReferences === +// === /renameImportOfReExport.ts === +// declare module "a" { +// export class [|C|] {} +// } +// declare module "b" { +// export { [|C|] } from "a"; +// } +// declare module "c" { +// import { /*FIND ALL REFS*/[|C|] } from "b"; +// export function f(c: [|C|]): void; +// } \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/findAllReferences/transitiveExportImports.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/transitiveExportImports.baseline.jsonc new file mode 100644 index 000000000..3e9dc9e1b --- /dev/null +++ b/testdata/baselines/reference/fourslash/findAllReferences/transitiveExportImports.baseline.jsonc @@ -0,0 +1,36 @@ +// === findAllReferences === +// === /a.ts === +// class /*FIND ALL REFS*/[|A|] { +// } +// export = [|A|]; + +// === /b.ts === +// export import [|b|] = require('./a'); + +// === /c.ts === +// import b = require('./b'); +// var a = new b.[|b|](); + + + +// === findAllReferences === +// === /b.ts === +// export import /*FIND ALL REFS*/[|b|] = require('./a'); + +// === /c.ts === +// import b = require('./b'); +// var a = new b.[|b|](); + + + +// === findAllReferences === +// === /c.ts === +// import /*FIND ALL REFS*/[|b|] = require('./b'); +// var a = new [|b|].b(); + + + +// === findAllReferences === +// === /c.ts === +// import [|b|] = require('./b'); +// var a = new /*FIND ALL REFS*/[|b|].b(); \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/findAllReferences/transitiveExportImports2.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/transitiveExportImports2.baseline.jsonc new file mode 100644 index 000000000..e1028fead --- /dev/null +++ b/testdata/baselines/reference/fourslash/findAllReferences/transitiveExportImports2.baseline.jsonc @@ -0,0 +1,32 @@ +// === findAllReferences === +// === /a.ts === +// namespace /*FIND ALL REFS*/[|A|] { +// export const x = 0; +// } + +// === /b.ts === +// export import [|B|] = [|A|]; +// [|B|].x; + +// === /c.ts === +// import { [|B|] } from "./b"; + + + +// === findAllReferences === +// === /b.ts === +// export import /*FIND ALL REFS*/[|B|] = A; +// [|B|].x; + +// === /c.ts === +// import { [|B|] } from "./b"; + + + +// === findAllReferences === +// === /b.ts === +// export import [|B|] = A; +// [|B|].x; + +// === /c.ts === +// import { /*FIND ALL REFS*/[|B|] } from "./b"; \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/findAllReferences/transitiveExportImports3.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/transitiveExportImports3.baseline.jsonc new file mode 100644 index 000000000..0f9249e99 --- /dev/null +++ b/testdata/baselines/reference/fourslash/findAllReferences/transitiveExportImports3.baseline.jsonc @@ -0,0 +1,35 @@ +// === findAllReferences === +// === /a.ts === +// export function /*FIND ALL REFS*/[|f|]() {} + +// === /b.ts === +// export { [|f|] as [|g|] } from "./a"; +// import { [|f|] } from "./a"; +// import { [|g|] } from "./b"; + + + +// === findAllReferences === +// === /b.ts === +// export { f as /*FIND ALL REFS*/[|g|] } from "./a"; +// import { f } from "./a"; +// import { [|g|] } from "./b"; + + + +// === findAllReferences === +// === /b.ts === +// export { f as [|g|] } from "./a"; +// import { f } from "./a"; +// import { /*FIND ALL REFS*/[|g|] } from "./b"; + + + +// === findAllReferences === +// === /a.ts === +// export function [|f|]() {} + +// === /b.ts === +// export { [|f|] as [|g|] } from "./a"; +// import { /*FIND ALL REFS*/[|f|] } from "./a"; +// import { [|g|] } from "./b"; \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/quickInfo/quickInfoForJSDocCodefence.baseline b/testdata/baselines/reference/fourslash/quickInfo/quickInfoForJSDocCodefence.baseline index 63b64218f..13ed7f8f5 100644 --- a/testdata/baselines/reference/fourslash/quickInfo/quickInfoForJSDocCodefence.baseline +++ b/testdata/baselines/reference/fourslash/quickInfo/quickInfoForJSDocCodefence.baseline @@ -36,9 +36,12 @@ // | ``` // | // | -// | *@example* — `` +// | *@example* +// | ```tsx +// | `` // | 1 + 2 // | ` +// | ``` // | // | ---------------------------------------------------------------------- // return '2'; @@ -84,7 +87,7 @@ "item": { "contents": { "kind": "markdown", - "value": "```tsx\nfunction boo(): string\n```\n\n\n*@example* — ``\n1 + 2\n`\n" + "value": "```tsx\nfunction boo(): string\n```\n\n\n*@example*\n```tsx\n``\n1 + 2\n`\n```\n" }, "range": { "start": { diff --git a/testdata/baselines/reference/fourslash/quickInfo/quickInfoForJSDocUnknownTag.baseline b/testdata/baselines/reference/fourslash/quickInfo/quickInfoForJSDocUnknownTag.baseline index 1ace37d77..aa3b34277 100644 --- a/testdata/baselines/reference/fourslash/quickInfo/quickInfoForJSDocUnknownTag.baseline +++ b/testdata/baselines/reference/fourslash/quickInfo/quickInfoForJSDocUnknownTag.baseline @@ -14,9 +14,12 @@ // | ``` // | // | -// | *@example* — if (true) { +// | *@example* +// | ```tsx +// | if (true) { // | foo() // | } +// | ``` // | // | ---------------------------------------------------------------------- // return '2'; @@ -35,9 +38,12 @@ // | ``` // | // | -// | *@example* — { +// | *@example* +// | ```tsx +// | { // | foo() // | } +// | ``` // | // | ---------------------------------------------------------------------- // return '2'; @@ -56,9 +62,12 @@ // | ``` // | // | -// | *@example* — x y +// | *@example* +// | ```tsx +// | x y // | 12345 // | b +// | ``` // | // | ---------------------------------------------------------------------- // return '2'; @@ -80,9 +89,12 @@ // | // | *@func* // | -// | *@example* — x y +// | *@example* +// | ```tsx +// | x y // | 12345 // | b +// | ``` // | // | ---------------------------------------------------------------------- // return '2'; @@ -103,9 +115,12 @@ // | // | *@func* // | -// | *@example* — x y +// | *@example* +// | ```tsx +// | x y // | 12345 // | b +// | ``` // | // | ---------------------------------------------------------------------- // return '2'; @@ -124,7 +139,7 @@ "item": { "contents": { "kind": "markdown", - "value": "```tsx\nfunction foo(): string\n```\n\n\n*@example* — if (true) {\n foo()\n}\n" + "value": "```tsx\nfunction foo(): string\n```\n\n\n*@example*\n```tsx\nif (true) {\n foo()\n}\n```\n" }, "range": { "start": { @@ -151,7 +166,7 @@ "item": { "contents": { "kind": "markdown", - "value": "```tsx\nfunction foo2(): string\n```\n\n\n*@example* — {\n foo()\n}\n" + "value": "```tsx\nfunction foo2(): string\n```\n\n\n*@example*\n```tsx\n{\n foo()\n}\n```\n" }, "range": { "start": { @@ -178,7 +193,7 @@ "item": { "contents": { "kind": "markdown", - "value": "```tsx\nfunction moo(): string\n```\n\n\n*@example* — x y\n 12345\n b\n" + "value": "```tsx\nfunction moo(): string\n```\n\n\n*@example*\n```tsx\n x y\n 12345\n b\n```\n" }, "range": { "start": { @@ -205,7 +220,7 @@ "item": { "contents": { "kind": "markdown", - "value": "```tsx\nfunction boo(): string\n```\n\n\n*@func*\n\n*@example* — x y\n 12345\n b\n" + "value": "```tsx\nfunction boo(): string\n```\n\n\n*@func*\n\n*@example*\n```tsx\n x y\n 12345\n b\n```\n" }, "range": { "start": { @@ -232,7 +247,7 @@ "item": { "contents": { "kind": "markdown", - "value": "```tsx\nfunction goo(): string\n```\n\n\n*@func*\n\n*@example* — x y\n12345\n b\n" + "value": "```tsx\nfunction goo(): string\n```\n\n\n*@func*\n\n*@example*\n```tsx\nx y\n12345\n b\n```\n" }, "range": { "start": { diff --git a/testdata/baselines/reference/fourslash/quickInfo/quickInfoInheritedLinkTag.baseline b/testdata/baselines/reference/fourslash/quickInfo/quickInfoInheritedLinkTag.baseline new file mode 100644 index 000000000..a09c2c3e2 --- /dev/null +++ b/testdata/baselines/reference/fourslash/quickInfo/quickInfoInheritedLinkTag.baseline @@ -0,0 +1,51 @@ +// === QuickInfo === +=== /quickInfoInheritedLinkTag.ts === +// export class C { +// /** +// * @deprecated Use {@link PerspectiveCamera#setFocalLength .setFocalLength()} and {@link PerspectiveCamera#filmGauge .filmGauge} instead. +// */ +// m() { } +// } +// export class D extends C { +// m() { } // crashes here +// } +// new C().m // and here (with a different thing trying to access undefined) +// ^ +// | ---------------------------------------------------------------------- +// | ```tsx +// | (method) C.m(): void +// | ``` +// | +// | +// | *@deprecated* — Use PerspectiveCamera.setFocalLength .setFocalLength() and PerspectiveCamera.filmGauge .filmGauge instead. +// | +// | ---------------------------------------------------------------------- +[ + { + "marker": { + "Position": 258, + "LSPosition": { + "line": 9, + "character": 9 + }, + "Name": "", + "Data": {} + }, + "item": { + "contents": { + "kind": "markdown", + "value": "```tsx\n(method) C.m(): void\n```\n\n\n*@deprecated* — Use PerspectiveCamera.setFocalLength .setFocalLength() and PerspectiveCamera.filmGauge .filmGauge instead.\n" + }, + "range": { + "start": { + "line": 9, + "character": 8 + }, + "end": { + "line": 9, + "character": 9 + } + } + } + } +] \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/quickInfo/quickInfoLink2.baseline b/testdata/baselines/reference/fourslash/quickInfo/quickInfoLink2.baseline new file mode 100644 index 000000000..17e42879b --- /dev/null +++ b/testdata/baselines/reference/fourslash/quickInfo/quickInfoLink2.baseline @@ -0,0 +1,43 @@ +// === QuickInfo === +=== /quickInfoLink2.js === +// /** +// * @typedef AdditionalWallabyConfig Additional valid Wallaby config properties +// ^^^^^^^^^^^^^^^^^^^^^^^ +// | ---------------------------------------------------------------------- +// | ```tsx +// | type AdditionalWallabyConfig = { autoDetect: boolean; } +// | ``` +// | +// | ---------------------------------------------------------------------- +// * that aren't defined in {@link IWallabyConfig}. +// * @property {boolean} autoDetect +// */ +[ + { + "marker": { + "Position": 39, + "LSPosition": { + "line": 1, + "character": 35 + }, + "Name": "", + "Data": {} + }, + "item": { + "contents": { + "kind": "markdown", + "value": "```tsx\ntype AdditionalWallabyConfig = { autoDetect: boolean; }\n```\n" + }, + "range": { + "start": { + "line": 1, + "character": 12 + }, + "end": { + "line": 1, + "character": 35 + } + } + } + } +] \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/quickInfo/quickInfoLink3.baseline b/testdata/baselines/reference/fourslash/quickInfo/quickInfoLink3.baseline new file mode 100644 index 000000000..7c668735b --- /dev/null +++ b/testdata/baselines/reference/fourslash/quickInfo/quickInfoLink3.baseline @@ -0,0 +1,54 @@ +// === QuickInfo === +=== /quickInfoLink3.ts === +// class Foo { +// /** +// * {@link Foo} +// * {@link Foo} +// * {@link Foo>} +// * {@link Foo<>} +// * {@link Foo>} +// * {@link Foo<} +// */ +// bar(){} +// ^^^ +// | ---------------------------------------------------------------------- +// | ```tsx +// | (method) Foo.bar(): void +// | ``` +// | [Foo](file:///quickInfoLink3.ts#1,7-1,10) +// | [](file:///quickInfoLink3.ts#1,7-1,10) +// | [>](file:///quickInfoLink3.ts#1,7-1,10) +// | [<>](file:///quickInfoLink3.ts#1,7-1,10) +// | [>](file:///quickInfoLink3.ts#1,7-1,10) +// | [<](file:///quickInfoLink3.ts#1,7-1,10) +// | ---------------------------------------------------------------------- +// } +[ + { + "marker": { + "Position": 169, + "LSPosition": { + "line": 9, + "character": 7 + }, + "Name": "", + "Data": {} + }, + "item": { + "contents": { + "kind": "markdown", + "value": "```tsx\n(method) Foo.bar(): void\n```\n[Foo](file:///quickInfoLink3.ts#1,7-1,10)\n[](file:///quickInfoLink3.ts#1,7-1,10)\n[>](file:///quickInfoLink3.ts#1,7-1,10)\n[<>](file:///quickInfoLink3.ts#1,7-1,10)\n[>](file:///quickInfoLink3.ts#1,7-1,10)\n[<](file:///quickInfoLink3.ts#1,7-1,10)" + }, + "range": { + "start": { + "line": 9, + "character": 4 + }, + "end": { + "line": 9, + "character": 7 + } + } + } + } +] \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/quickInfo/quickInfoLink4.baseline b/testdata/baselines/reference/fourslash/quickInfo/quickInfoLink4.baseline new file mode 100644 index 000000000..8c18758a4 --- /dev/null +++ b/testdata/baselines/reference/fourslash/quickInfo/quickInfoLink4.baseline @@ -0,0 +1,46 @@ +// === QuickInfo === +=== /quickInfoLink4.ts === +// type A = 1 | 2; +// +// switch (0 as A) { +// /** {@link A} */ +// ^ +// | ---------------------------------------------------------------------- +// | ```tsx +// | type A = 1 | 2 +// | ``` +// | +// | ---------------------------------------------------------------------- +// case 1: +// case 2: +// break; +// } +[ + { + "marker": { + "Position": 47, + "LSPosition": { + "line": 3, + "character": 12 + }, + "Name": "", + "Data": {} + }, + "item": { + "contents": { + "kind": "markdown", + "value": "```tsx\ntype A = 1 | 2\n```\n" + }, + "range": { + "start": { + "line": 3, + "character": 12 + }, + "end": { + "line": 3, + "character": 13 + } + } + } + } +] \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/quickInfo/quickInfoLinkCodePlain.baseline b/testdata/baselines/reference/fourslash/quickInfo/quickInfoLinkCodePlain.baseline new file mode 100644 index 000000000..516a1ae0f --- /dev/null +++ b/testdata/baselines/reference/fourslash/quickInfo/quickInfoLinkCodePlain.baseline @@ -0,0 +1,48 @@ +// === QuickInfo === +=== /quickInfoLinkCodePlain.ts === +// export class C { +// /** +// * @deprecated Use {@linkplain PerspectiveCamera#setFocalLength .setFocalLength()} and {@linkcode PerspectiveCamera#filmGauge .filmGauge} instead. +// */ +// m() { } +// } +// new C().m +// ^ +// | ---------------------------------------------------------------------- +// | ```tsx +// | (method) C.m(): void +// | ``` +// | +// | +// | *@deprecated* — Use PerspectiveCamera.setFocalLength .setFocalLength() and `PerspectiveCamera.filmGauge .filmGauge` instead. +// | +// | ---------------------------------------------------------------------- +[ + { + "marker": { + "Position": 210, + "LSPosition": { + "line": 6, + "character": 9 + }, + "Name": "", + "Data": {} + }, + "item": { + "contents": { + "kind": "markdown", + "value": "```tsx\n(method) C.m(): void\n```\n\n\n*@deprecated* — Use PerspectiveCamera.setFocalLength .setFocalLength() and `PerspectiveCamera.filmGauge .filmGauge` instead.\n" + }, + "range": { + "start": { + "line": 6, + "character": 8 + }, + "end": { + "line": 6, + "character": 9 + } + } + } + } +] \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/quickInfo/quickInfoThrowsTag.baseline b/testdata/baselines/reference/fourslash/quickInfo/quickInfoThrowsTag.baseline new file mode 100644 index 000000000..859eb7742 --- /dev/null +++ b/testdata/baselines/reference/fourslash/quickInfo/quickInfoThrowsTag.baseline @@ -0,0 +1,134 @@ +// === QuickInfo === +=== /quickInfoThrowsTag.ts === +// class E extends Error {} +// +// /** +// * @throws {E} +// */ +// function f1() {} +// +// /** +// * @throws {E} description +// */ +// function f2() {} +// +// /** +// * @throws description +// */ +// function f3() {} +// f1() +// ^^ +// | ---------------------------------------------------------------------- +// | ```tsx +// | function f1(): void +// | ``` +// | +// | +// | *@throws* — {E} +// | +// | ---------------------------------------------------------------------- +// f2() +// ^^ +// | ---------------------------------------------------------------------- +// | ```tsx +// | function f2(): void +// | ``` +// | +// | +// | *@throws* — {E} description +// | +// | ---------------------------------------------------------------------- +// f3() +// ^^ +// | ---------------------------------------------------------------------- +// | ```tsx +// | function f3(): void +// | ``` +// | +// | +// | *@throws* — description +// | +// | ---------------------------------------------------------------------- +[ + { + "marker": { + "Position": 170, + "LSPosition": { + "line": 16, + "character": 2 + }, + "Name": "1", + "Data": {} + }, + "item": { + "contents": { + "kind": "markdown", + "value": "```tsx\nfunction f1(): void\n```\n\n\n*@throws* — {E}\n" + }, + "range": { + "start": { + "line": 16, + "character": 0 + }, + "end": { + "line": 16, + "character": 2 + } + } + } + }, + { + "marker": { + "Position": 175, + "LSPosition": { + "line": 17, + "character": 2 + }, + "Name": "2", + "Data": {} + }, + "item": { + "contents": { + "kind": "markdown", + "value": "```tsx\nfunction f2(): void\n```\n\n\n*@throws* — {E} description\n" + }, + "range": { + "start": { + "line": 17, + "character": 0 + }, + "end": { + "line": 17, + "character": 2 + } + } + } + }, + { + "marker": { + "Position": 180, + "LSPosition": { + "line": 18, + "character": 2 + }, + "Name": "3", + "Data": {} + }, + "item": { + "contents": { + "kind": "markdown", + "value": "```tsx\nfunction f3(): void\n```\n\n\n*@throws* — description\n" + }, + "range": { + "start": { + "line": 18, + "character": 0 + }, + "end": { + "line": 18, + "character": 2 + } + } + } + } +] \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/classStaticPropertyAccess.symbols b/testdata/baselines/reference/submodule/compiler/classStaticPropertyAccess.symbols index 16bba6ec2..ba265a43f 100644 --- a/testdata/baselines/reference/submodule/compiler/classStaticPropertyAccess.symbols +++ b/testdata/baselines/reference/submodule/compiler/classStaticPropertyAccess.symbols @@ -5,7 +5,7 @@ class A { >A : Symbol(A, Decl(classStaticPropertyAccess.ts, 0, 0)) public static "\""() {} ->"\"" : Symbol(A["\\\""], Decl(classStaticPropertyAccess.ts, 0, 9)) +>"\"" : Symbol(A["\""], Decl(classStaticPropertyAccess.ts, 0, 9)) public static x: number = 1; >x : Symbol(A.x, Decl(classStaticPropertyAccess.ts, 1, 27)) diff --git a/testdata/baselines/reference/submodule/compiler/classStaticPropertyAccess.symbols.diff b/testdata/baselines/reference/submodule/compiler/classStaticPropertyAccess.symbols.diff deleted file mode 100644 index a633ab508..000000000 --- a/testdata/baselines/reference/submodule/compiler/classStaticPropertyAccess.symbols.diff +++ /dev/null @@ -1,11 +0,0 @@ ---- old.classStaticPropertyAccess.symbols -+++ new.classStaticPropertyAccess.symbols -@@= skipped -4, +4 lines =@@ - >A : Symbol(A, Decl(classStaticPropertyAccess.ts, 0, 0)) - - public static "\""() {} -->"\"" : Symbol(A["\""], Decl(classStaticPropertyAccess.ts, 0, 9)) -+>"\"" : Symbol(A["\\\""], Decl(classStaticPropertyAccess.ts, 0, 9)) - - public static x: number = 1; - >x : Symbol(A.x, Decl(classStaticPropertyAccess.ts, 1, 27)) \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/jsDeclarationEmitExportAssignedFunctionWithExtraTypedefsMembers.js b/testdata/baselines/reference/submodule/compiler/jsDeclarationEmitExportAssignedFunctionWithExtraTypedefsMembers.js index 02499abac..9645222cf 100644 --- a/testdata/baselines/reference/submodule/compiler/jsDeclarationEmitExportAssignedFunctionWithExtraTypedefsMembers.js +++ b/testdata/baselines/reference/submodule/compiler/jsDeclarationEmitExportAssignedFunctionWithExtraTypedefsMembers.js @@ -32,6 +32,9 @@ module.exports = function loader(options) { }; export type Options = { opt: string; }; +/** + * @param {Options} options + */ declare const _default: (options: Options) => void; export = _default; @@ -39,7 +42,7 @@ export = _default; //// [DtsFileErrors] -out/index.d.ts(9,1): error TS2309: An export assignment cannot be used in a module with other exported elements. +out/index.d.ts(12,1): error TS2309: An export assignment cannot be used in a module with other exported elements. ==== out/index.d.ts (1 errors) ==== @@ -50,6 +53,9 @@ out/index.d.ts(9,1): error TS2309: An export assignment cannot be used in a modu export type Options = { opt: string; }; + /** + * @param {Options} options + */ declare const _default: (options: Options) => void; export = _default; ~~~~~~~~~~~~~~~~~~ diff --git a/testdata/baselines/reference/submodule/compiler/jsDeclarationEmitExportAssignedFunctionWithExtraTypedefsMembers.js.diff b/testdata/baselines/reference/submodule/compiler/jsDeclarationEmitExportAssignedFunctionWithExtraTypedefsMembers.js.diff index 018318dba..622c46a8d 100644 --- a/testdata/baselines/reference/submodule/compiler/jsDeclarationEmitExportAssignedFunctionWithExtraTypedefsMembers.js.diff +++ b/testdata/baselines/reference/submodule/compiler/jsDeclarationEmitExportAssignedFunctionWithExtraTypedefsMembers.js.diff @@ -17,6 +17,9 @@ +export type Options = { opt: string; }; ++/** ++ * @param {Options} options ++ */ +declare const _default: (options: Options) => void; +export = _default; + @@ -24,7 +27,7 @@ +//// [DtsFileErrors] + + -+out/index.d.ts(9,1): error TS2309: An export assignment cannot be used in a module with other exported elements. ++out/index.d.ts(12,1): error TS2309: An export assignment cannot be used in a module with other exported elements. + + +==== out/index.d.ts (1 errors) ==== @@ -35,6 +38,9 @@ + export type Options = { + opt: string; + }; ++ /** ++ * @param {Options} options ++ */ + declare const _default: (options: Options) => void; + export = _default; + ~~~~~~~~~~~~~~~~~~ diff --git a/testdata/baselines/reference/submodule/compiler/jsxElementType.symbols b/testdata/baselines/reference/submodule/compiler/jsxElementType.symbols index 2ba2e6aff..4e9c238f9 100644 --- a/testdata/baselines/reference/submodule/compiler/jsxElementType.symbols +++ b/testdata/baselines/reference/submodule/compiler/jsxElementType.symbols @@ -64,8 +64,8 @@ declare global { >IntrinsicElements : Symbol(IntrinsicElements, Decl(react16.d.ts, 2514, 86), Decl(jsxElementType.tsx, 22, 67), Decl(jsxElementType.tsx, 101, 19)) ['my-custom-element']: React.DOMAttributes; ->['my-custom-element'] : Symbol(IntrinsicElements["my-custom-element"], Decl(jsxElementType.tsx, 23, 33)) ->'my-custom-element' : Symbol(IntrinsicElements["my-custom-element"], Decl(jsxElementType.tsx, 23, 33)) +>['my-custom-element'] : Symbol(IntrinsicElements['my-custom-element'], Decl(jsxElementType.tsx, 23, 33)) +>'my-custom-element' : Symbol(IntrinsicElements['my-custom-element'], Decl(jsxElementType.tsx, 23, 33)) >React : Symbol(React, Decl(jsxElementType.tsx, 1, 6)) >DOMAttributes : Symbol(React.DOMAttributes, Decl(react16.d.ts, 844, 9)) } @@ -225,7 +225,7 @@ Component = RenderStringClass; >div : Symbol(JSX.IntrinsicElements.div, Decl(react16.d.ts, 2546, 114)) ; ->my-custom-element : Symbol(JSX.IntrinsicElements["my-custom-element"], Decl(jsxElementType.tsx, 23, 33)) +>my-custom-element : Symbol(JSX.IntrinsicElements['my-custom-element'], Decl(jsxElementType.tsx, 23, 33)) // Undeclared host element types are still rejected ; @@ -284,8 +284,8 @@ declare global { >IntrinsicElements : Symbol(IntrinsicElements, Decl(react16.d.ts, 2514, 86), Decl(jsxElementType.tsx, 22, 67), Decl(jsxElementType.tsx, 101, 19)) ['a:b']: { a: string }; ->['a:b'] : Symbol(IntrinsicElements["a:b"], Decl(jsxElementType.tsx, 102, 35)) ->'a:b' : Symbol(IntrinsicElements["a:b"], Decl(jsxElementType.tsx, 102, 35)) +>['a:b'] : Symbol(IntrinsicElements['a:b'], Decl(jsxElementType.tsx, 102, 35)) +>'a:b' : Symbol(IntrinsicElements['a:b'], Decl(jsxElementType.tsx, 102, 35)) >a : Symbol(a, Decl(jsxElementType.tsx, 103, 20)) } } diff --git a/testdata/baselines/reference/submodule/compiler/jsxElementType.symbols.diff b/testdata/baselines/reference/submodule/compiler/jsxElementType.symbols.diff deleted file mode 100644 index 5b050c4bf..000000000 --- a/testdata/baselines/reference/submodule/compiler/jsxElementType.symbols.diff +++ /dev/null @@ -1,33 +0,0 @@ ---- old.jsxElementType.symbols -+++ new.jsxElementType.symbols -@@= skipped -63, +63 lines =@@ - >IntrinsicElements : Symbol(IntrinsicElements, Decl(react16.d.ts, 2514, 86), Decl(jsxElementType.tsx, 22, 67), Decl(jsxElementType.tsx, 101, 19)) - - ['my-custom-element']: React.DOMAttributes; -->['my-custom-element'] : Symbol(IntrinsicElements['my-custom-element'], Decl(jsxElementType.tsx, 23, 33)) -->'my-custom-element' : Symbol(IntrinsicElements['my-custom-element'], Decl(jsxElementType.tsx, 23, 33)) -+>['my-custom-element'] : Symbol(IntrinsicElements["my-custom-element"], Decl(jsxElementType.tsx, 23, 33)) -+>'my-custom-element' : Symbol(IntrinsicElements["my-custom-element"], Decl(jsxElementType.tsx, 23, 33)) - >React : Symbol(React, Decl(jsxElementType.tsx, 1, 6)) - >DOMAttributes : Symbol(React.DOMAttributes, Decl(react16.d.ts, 844, 9)) - } -@@= skipped -161, +161 lines =@@ - >div : Symbol(JSX.IntrinsicElements.div, Decl(react16.d.ts, 2546, 114)) - - ; -->my-custom-element : Symbol(JSX.IntrinsicElements['my-custom-element'], Decl(jsxElementType.tsx, 23, 33)) -+>my-custom-element : Symbol(JSX.IntrinsicElements["my-custom-element"], Decl(jsxElementType.tsx, 23, 33)) - - // Undeclared host element types are still rejected - ; -@@= skipped -59, +59 lines =@@ - >IntrinsicElements : Symbol(IntrinsicElements, Decl(react16.d.ts, 2514, 86), Decl(jsxElementType.tsx, 22, 67), Decl(jsxElementType.tsx, 101, 19)) - - ['a:b']: { a: string }; -->['a:b'] : Symbol(IntrinsicElements['a:b'], Decl(jsxElementType.tsx, 102, 35)) -->'a:b' : Symbol(IntrinsicElements['a:b'], Decl(jsxElementType.tsx, 102, 35)) -+>['a:b'] : Symbol(IntrinsicElements["a:b"], Decl(jsxElementType.tsx, 102, 35)) -+>'a:b' : Symbol(IntrinsicElements["a:b"], Decl(jsxElementType.tsx, 102, 35)) - >a : Symbol(a, Decl(jsxElementType.tsx, 103, 20)) - } - } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/numericClassMembers1.symbols b/testdata/baselines/reference/submodule/compiler/numericClassMembers1.symbols index 5220c6a28..8b501829d 100644 --- a/testdata/baselines/reference/submodule/compiler/numericClassMembers1.symbols +++ b/testdata/baselines/reference/submodule/compiler/numericClassMembers1.symbols @@ -25,9 +25,9 @@ class C236 { >C236 : Symbol(C236, Decl(numericClassMembers1.ts, 8, 1)) '0.0' = 1; ->'0.0' : Symbol(C236["00"], Decl(numericClassMembers1.ts, 10, 12)) +>'0.0' : Symbol(C236['0.0'], Decl(numericClassMembers1.ts, 10, 12)) '0' = 2; ->'0' : Symbol(C236["0"], Decl(numericClassMembers1.ts, 11, 14)) +>'0' : Symbol(C236['0'], Decl(numericClassMembers1.ts, 11, 14)) } diff --git a/testdata/baselines/reference/submodule/compiler/numericClassMembers1.symbols.diff b/testdata/baselines/reference/submodule/compiler/numericClassMembers1.symbols.diff deleted file mode 100644 index 084bfdac7..000000000 --- a/testdata/baselines/reference/submodule/compiler/numericClassMembers1.symbols.diff +++ /dev/null @@ -1,13 +0,0 @@ ---- old.numericClassMembers1.symbols -+++ new.numericClassMembers1.symbols -@@= skipped -24, +24 lines =@@ - >C236 : Symbol(C236, Decl(numericClassMembers1.ts, 8, 1)) - - '0.0' = 1; -->'0.0' : Symbol(C236['0.0'], Decl(numericClassMembers1.ts, 10, 12)) -+>'0.0' : Symbol(C236["00"], Decl(numericClassMembers1.ts, 10, 12)) - - '0' = 2; -->'0' : Symbol(C236['0'], Decl(numericClassMembers1.ts, 11, 14)) -+>'0' : Symbol(C236["0"], Decl(numericClassMembers1.ts, 11, 14)) - } diff --git a/testdata/baselines/reference/submodule/compiler/numericIndexExpressions.symbols b/testdata/baselines/reference/submodule/compiler/numericIndexExpressions.symbols index 912ef6bbc..616a54280 100644 --- a/testdata/baselines/reference/submodule/compiler/numericIndexExpressions.symbols +++ b/testdata/baselines/reference/submodule/compiler/numericIndexExpressions.symbols @@ -11,7 +11,7 @@ interface Strings1 { >Strings1 : Symbol(Strings1, Decl(numericIndexExpressions.ts, 2, 1)) '1': string; ->'1' : Symbol(Strings1["1"], Decl(numericIndexExpressions.ts, 3, 20)) +>'1' : Symbol(Strings1['1'], Decl(numericIndexExpressions.ts, 3, 20)) } @@ -33,9 +33,9 @@ var y: Strings1; y['1'] = 4; // should be error >y : Symbol(y, Decl(numericIndexExpressions.ts, 12, 3)) ->'1' : Symbol(Strings1["1"], Decl(numericIndexExpressions.ts, 3, 20)) +>'1' : Symbol(Strings1['1'], Decl(numericIndexExpressions.ts, 3, 20)) y[1] = 4; // should be error >y : Symbol(y, Decl(numericIndexExpressions.ts, 12, 3)) ->1 : Symbol(Strings1["1"], Decl(numericIndexExpressions.ts, 3, 20)) +>1 : Symbol(Strings1['1'], Decl(numericIndexExpressions.ts, 3, 20)) diff --git a/testdata/baselines/reference/submodule/compiler/numericIndexExpressions.symbols.diff b/testdata/baselines/reference/submodule/compiler/numericIndexExpressions.symbols.diff deleted file mode 100644 index de9685a02..000000000 --- a/testdata/baselines/reference/submodule/compiler/numericIndexExpressions.symbols.diff +++ /dev/null @@ -1,22 +0,0 @@ ---- old.numericIndexExpressions.symbols -+++ new.numericIndexExpressions.symbols -@@= skipped -10, +10 lines =@@ - >Strings1 : Symbol(Strings1, Decl(numericIndexExpressions.ts, 2, 1)) - - '1': string; -->'1' : Symbol(Strings1['1'], Decl(numericIndexExpressions.ts, 3, 20)) -+>'1' : Symbol(Strings1["1"], Decl(numericIndexExpressions.ts, 3, 20)) - } - - -@@= skipped -22, +22 lines =@@ - - y['1'] = 4; // should be error - >y : Symbol(y, Decl(numericIndexExpressions.ts, 12, 3)) -->'1' : Symbol(Strings1['1'], Decl(numericIndexExpressions.ts, 3, 20)) -+>'1' : Symbol(Strings1["1"], Decl(numericIndexExpressions.ts, 3, 20)) - - y[1] = 4; // should be error - >y : Symbol(y, Decl(numericIndexExpressions.ts, 12, 3)) -->1 : Symbol(Strings1['1'], Decl(numericIndexExpressions.ts, 3, 20)) -+>1 : Symbol(Strings1["1"], Decl(numericIndexExpressions.ts, 3, 20)) diff --git a/testdata/baselines/reference/submodule/compiler/propertiesAndIndexersForNumericNames.symbols b/testdata/baselines/reference/submodule/compiler/propertiesAndIndexersForNumericNames.symbols index 7f8e894dc..65115e0e0 100644 --- a/testdata/baselines/reference/submodule/compiler/propertiesAndIndexersForNumericNames.symbols +++ b/testdata/baselines/reference/submodule/compiler/propertiesAndIndexersForNumericNames.symbols @@ -16,13 +16,13 @@ class C { >"-1" : Symbol(C["-1"], Decl(propertiesAndIndexersForNumericNames.ts, 5, 34)) public "-2.5": string = "negative number"; // Error ->"-2.5" : Symbol(C["-25"], Decl(propertiesAndIndexersForNumericNames.ts, 6, 44)) +>"-2.5" : Symbol(C["-2.5"], Decl(propertiesAndIndexersForNumericNames.ts, 6, 44)) public "3.141592": string = "pi-sitive number"; // Error ->"3.141592" : Symbol(C["3141592"], Decl(propertiesAndIndexersForNumericNames.ts, 7, 46)) +>"3.141592" : Symbol(C["3.141592"], Decl(propertiesAndIndexersForNumericNames.ts, 7, 46)) public "1.2e-20": string = "really small number"; // Error ->"1.2e-20" : Symbol(C["12e-20"], Decl(propertiesAndIndexersForNumericNames.ts, 8, 51)) +>"1.2e-20" : Symbol(C["1.2e-20"], Decl(propertiesAndIndexersForNumericNames.ts, 8, 51)) public "Infinity": string = "A gillion"; // Error >"Infinity" : Symbol(C["Infinity"], Decl(propertiesAndIndexersForNumericNames.ts, 9, 53)) @@ -94,6 +94,6 @@ class C { >"0b101101001010" : Symbol(C["0b101101001010"], Decl(propertiesAndIndexersForNumericNames.ts, 37, 47)) public "0.000000000000000000012": string = "should've been in exponential form"; // No error ->"0.000000000000000000012" : Symbol(C["0000000000000000000012"], Decl(propertiesAndIndexersForNumericNames.ts, 38, 56)) +>"0.000000000000000000012" : Symbol(C["0.000000000000000000012"], Decl(propertiesAndIndexersForNumericNames.ts, 38, 56)) } diff --git a/testdata/baselines/reference/submodule/compiler/propertiesAndIndexersForNumericNames.symbols.diff b/testdata/baselines/reference/submodule/compiler/propertiesAndIndexersForNumericNames.symbols.diff deleted file mode 100644 index d69441eef..000000000 --- a/testdata/baselines/reference/submodule/compiler/propertiesAndIndexersForNumericNames.symbols.diff +++ /dev/null @@ -1,26 +0,0 @@ ---- old.propertiesAndIndexersForNumericNames.symbols -+++ new.propertiesAndIndexersForNumericNames.symbols -@@= skipped -15, +15 lines =@@ - >"-1" : Symbol(C["-1"], Decl(propertiesAndIndexersForNumericNames.ts, 5, 34)) - - public "-2.5": string = "negative number"; // Error -->"-2.5" : Symbol(C["-2.5"], Decl(propertiesAndIndexersForNumericNames.ts, 6, 44)) -+>"-2.5" : Symbol(C["-25"], Decl(propertiesAndIndexersForNumericNames.ts, 6, 44)) - - public "3.141592": string = "pi-sitive number"; // Error -->"3.141592" : Symbol(C["3.141592"], Decl(propertiesAndIndexersForNumericNames.ts, 7, 46)) -+>"3.141592" : Symbol(C["3141592"], Decl(propertiesAndIndexersForNumericNames.ts, 7, 46)) - - public "1.2e-20": string = "really small number"; // Error -->"1.2e-20" : Symbol(C["1.2e-20"], Decl(propertiesAndIndexersForNumericNames.ts, 8, 51)) -+>"1.2e-20" : Symbol(C["12e-20"], Decl(propertiesAndIndexersForNumericNames.ts, 8, 51)) - - public "Infinity": string = "A gillion"; // Error - >"Infinity" : Symbol(C["Infinity"], Decl(propertiesAndIndexersForNumericNames.ts, 9, 53)) -@@= skipped -78, +78 lines =@@ - >"0b101101001010" : Symbol(C["0b101101001010"], Decl(propertiesAndIndexersForNumericNames.ts, 37, 47)) - - public "0.000000000000000000012": string = "should've been in exponential form"; // No error -->"0.000000000000000000012" : Symbol(C["0.000000000000000000012"], Decl(propertiesAndIndexersForNumericNames.ts, 38, 56)) -+>"0.000000000000000000012" : Symbol(C["0000000000000000000012"], Decl(propertiesAndIndexersForNumericNames.ts, 38, 56)) - } diff --git a/testdata/baselines/reference/submodule/compiler/styledComponentsInstantiaionLimitNotReached.symbols b/testdata/baselines/reference/submodule/compiler/styledComponentsInstantiaionLimitNotReached.symbols index 4df7b8ff4..5bde3e49c 100644 --- a/testdata/baselines/reference/submodule/compiler/styledComponentsInstantiaionLimitNotReached.symbols +++ b/testdata/baselines/reference/submodule/compiler/styledComponentsInstantiaionLimitNotReached.symbols @@ -71,7 +71,7 @@ interface MEMO_STATICS { >MEMO_STATICS : Symbol(MEMO_STATICS, Decl(styledComponentsInstantiaionLimitNotReached.ts, 25, 1)) '$$typeof': true; ->'$$typeof' : Symbol(MEMO_STATICS["$$typeof"], Decl(styledComponentsInstantiaionLimitNotReached.ts, 27, 24)) +>'$$typeof' : Symbol(MEMO_STATICS['$$typeof'], Decl(styledComponentsInstantiaionLimitNotReached.ts, 27, 24)) compare: true; >compare : Symbol(MEMO_STATICS.compare, Decl(styledComponentsInstantiaionLimitNotReached.ts, 28, 21)) @@ -93,7 +93,7 @@ interface FORWARD_REF_STATICS { >FORWARD_REF_STATICS : Symbol(FORWARD_REF_STATICS, Decl(styledComponentsInstantiaionLimitNotReached.ts, 34, 1)) '$$typeof': true; ->'$$typeof' : Symbol(FORWARD_REF_STATICS["$$typeof"], Decl(styledComponentsInstantiaionLimitNotReached.ts, 36, 31)) +>'$$typeof' : Symbol(FORWARD_REF_STATICS['$$typeof'], Decl(styledComponentsInstantiaionLimitNotReached.ts, 36, 31)) render: true; >render : Symbol(FORWARD_REF_STATICS.render, Decl(styledComponentsInstantiaionLimitNotReached.ts, 37, 21)) diff --git a/testdata/baselines/reference/submodule/compiler/styledComponentsInstantiaionLimitNotReached.symbols.diff b/testdata/baselines/reference/submodule/compiler/styledComponentsInstantiaionLimitNotReached.symbols.diff deleted file mode 100644 index 23ed241bc..000000000 --- a/testdata/baselines/reference/submodule/compiler/styledComponentsInstantiaionLimitNotReached.symbols.diff +++ /dev/null @@ -1,20 +0,0 @@ ---- old.styledComponentsInstantiaionLimitNotReached.symbols -+++ new.styledComponentsInstantiaionLimitNotReached.symbols -@@= skipped -70, +70 lines =@@ - >MEMO_STATICS : Symbol(MEMO_STATICS, Decl(styledComponentsInstantiaionLimitNotReached.ts, 25, 1)) - - '$$typeof': true; -->'$$typeof' : Symbol(MEMO_STATICS['$$typeof'], Decl(styledComponentsInstantiaionLimitNotReached.ts, 27, 24)) -+>'$$typeof' : Symbol(MEMO_STATICS["$$typeof"], Decl(styledComponentsInstantiaionLimitNotReached.ts, 27, 24)) - - compare: true; - >compare : Symbol(MEMO_STATICS.compare, Decl(styledComponentsInstantiaionLimitNotReached.ts, 28, 21)) -@@= skipped -22, +22 lines =@@ - >FORWARD_REF_STATICS : Symbol(FORWARD_REF_STATICS, Decl(styledComponentsInstantiaionLimitNotReached.ts, 34, 1)) - - '$$typeof': true; -->'$$typeof' : Symbol(FORWARD_REF_STATICS['$$typeof'], Decl(styledComponentsInstantiaionLimitNotReached.ts, 36, 31)) -+>'$$typeof' : Symbol(FORWARD_REF_STATICS["$$typeof"], Decl(styledComponentsInstantiaionLimitNotReached.ts, 36, 31)) - - render: true; - >render : Symbol(FORWARD_REF_STATICS.render, Decl(styledComponentsInstantiaionLimitNotReached.ts, 37, 21)) \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/assignmentCompatWithObjectMembersStringNumericNames.symbols b/testdata/baselines/reference/submodule/conformance/assignmentCompatWithObjectMembersStringNumericNames.symbols index d47e45416..5b82d0fa0 100644 --- a/testdata/baselines/reference/submodule/conformance/assignmentCompatWithObjectMembersStringNumericNames.symbols +++ b/testdata/baselines/reference/submodule/conformance/assignmentCompatWithObjectMembersStringNumericNames.symbols @@ -9,11 +9,11 @@ module JustStrings { class S { '1': string; } >S : Symbol(S, Decl(assignmentCompatWithObjectMembersStringNumericNames.ts, 3, 20)) ->'1' : Symbol(S["1"], Decl(assignmentCompatWithObjectMembersStringNumericNames.ts, 4, 13)) +>'1' : Symbol(S['1'], Decl(assignmentCompatWithObjectMembersStringNumericNames.ts, 4, 13)) class T { '1.': string; } >T : Symbol(T, Decl(assignmentCompatWithObjectMembersStringNumericNames.ts, 4, 28)) ->'1.' : Symbol(T["1"], Decl(assignmentCompatWithObjectMembersStringNumericNames.ts, 5, 13)) +>'1.' : Symbol(T['1.'], Decl(assignmentCompatWithObjectMembersStringNumericNames.ts, 5, 13)) var s: S; >s : Symbol(s, Decl(assignmentCompatWithObjectMembersStringNumericNames.ts, 6, 7)) @@ -25,12 +25,12 @@ module JustStrings { interface S2 { '1': string; bar?: string } >S2 : Symbol(S2, Decl(assignmentCompatWithObjectMembersStringNumericNames.ts, 7, 13)) ->'1' : Symbol(S2["1"], Decl(assignmentCompatWithObjectMembersStringNumericNames.ts, 9, 18)) +>'1' : Symbol(S2['1'], Decl(assignmentCompatWithObjectMembersStringNumericNames.ts, 9, 18)) >bar : Symbol(S2.bar, Decl(assignmentCompatWithObjectMembersStringNumericNames.ts, 9, 31)) interface T2 { '1.0': string; baz?: string } >T2 : Symbol(T2, Decl(assignmentCompatWithObjectMembersStringNumericNames.ts, 9, 46)) ->'1.0' : Symbol(T2["10"], Decl(assignmentCompatWithObjectMembersStringNumericNames.ts, 10, 18)) +>'1.0' : Symbol(T2['1.0'], Decl(assignmentCompatWithObjectMembersStringNumericNames.ts, 10, 18)) >baz : Symbol(T2.baz, Decl(assignmentCompatWithObjectMembersStringNumericNames.ts, 10, 33)) var s2: S2; @@ -141,7 +141,7 @@ module NumbersAndStrings { class S { '1': string; } >S : Symbol(S, Decl(assignmentCompatWithObjectMembersStringNumericNames.ts, 44, 26)) ->'1' : Symbol(S["1"], Decl(assignmentCompatWithObjectMembersStringNumericNames.ts, 45, 13)) +>'1' : Symbol(S['1'], Decl(assignmentCompatWithObjectMembersStringNumericNames.ts, 45, 13)) class T { 1: string; } >T : Symbol(T, Decl(assignmentCompatWithObjectMembersStringNumericNames.ts, 45, 28)) @@ -157,7 +157,7 @@ module NumbersAndStrings { interface S2 { '1': string; bar?: string } >S2 : Symbol(S2, Decl(assignmentCompatWithObjectMembersStringNumericNames.ts, 48, 13)) ->'1' : Symbol(S2["1"], Decl(assignmentCompatWithObjectMembersStringNumericNames.ts, 50, 18)) +>'1' : Symbol(S2['1'], Decl(assignmentCompatWithObjectMembersStringNumericNames.ts, 50, 18)) >bar : Symbol(S2.bar, Decl(assignmentCompatWithObjectMembersStringNumericNames.ts, 50, 31)) interface T2 { 1.0: string; baz?: string } diff --git a/testdata/baselines/reference/submodule/conformance/assignmentCompatWithObjectMembersStringNumericNames.symbols.diff b/testdata/baselines/reference/submodule/conformance/assignmentCompatWithObjectMembersStringNumericNames.symbols.diff deleted file mode 100644 index 66ecf6fae..000000000 --- a/testdata/baselines/reference/submodule/conformance/assignmentCompatWithObjectMembersStringNumericNames.symbols.diff +++ /dev/null @@ -1,49 +0,0 @@ ---- old.assignmentCompatWithObjectMembersStringNumericNames.symbols -+++ new.assignmentCompatWithObjectMembersStringNumericNames.symbols -@@= skipped -8, +8 lines =@@ - - class S { '1': string; } - >S : Symbol(S, Decl(assignmentCompatWithObjectMembersStringNumericNames.ts, 3, 20)) -->'1' : Symbol(S['1'], Decl(assignmentCompatWithObjectMembersStringNumericNames.ts, 4, 13)) -+>'1' : Symbol(S["1"], Decl(assignmentCompatWithObjectMembersStringNumericNames.ts, 4, 13)) - - class T { '1.': string; } - >T : Symbol(T, Decl(assignmentCompatWithObjectMembersStringNumericNames.ts, 4, 28)) -->'1.' : Symbol(T['1.'], Decl(assignmentCompatWithObjectMembersStringNumericNames.ts, 5, 13)) -+>'1.' : Symbol(T["1"], Decl(assignmentCompatWithObjectMembersStringNumericNames.ts, 5, 13)) - - var s: S; - >s : Symbol(s, Decl(assignmentCompatWithObjectMembersStringNumericNames.ts, 6, 7)) -@@= skipped -16, +16 lines =@@ - - interface S2 { '1': string; bar?: string } - >S2 : Symbol(S2, Decl(assignmentCompatWithObjectMembersStringNumericNames.ts, 7, 13)) -->'1' : Symbol(S2['1'], Decl(assignmentCompatWithObjectMembersStringNumericNames.ts, 9, 18)) -+>'1' : Symbol(S2["1"], Decl(assignmentCompatWithObjectMembersStringNumericNames.ts, 9, 18)) - >bar : Symbol(S2.bar, Decl(assignmentCompatWithObjectMembersStringNumericNames.ts, 9, 31)) - - interface T2 { '1.0': string; baz?: string } - >T2 : Symbol(T2, Decl(assignmentCompatWithObjectMembersStringNumericNames.ts, 9, 46)) -->'1.0' : Symbol(T2['1.0'], Decl(assignmentCompatWithObjectMembersStringNumericNames.ts, 10, 18)) -+>'1.0' : Symbol(T2["10"], Decl(assignmentCompatWithObjectMembersStringNumericNames.ts, 10, 18)) - >baz : Symbol(T2.baz, Decl(assignmentCompatWithObjectMembersStringNumericNames.ts, 10, 33)) - - var s2: S2; -@@= skipped -116, +116 lines =@@ - - class S { '1': string; } - >S : Symbol(S, Decl(assignmentCompatWithObjectMembersStringNumericNames.ts, 44, 26)) -->'1' : Symbol(S['1'], Decl(assignmentCompatWithObjectMembersStringNumericNames.ts, 45, 13)) -+>'1' : Symbol(S["1"], Decl(assignmentCompatWithObjectMembersStringNumericNames.ts, 45, 13)) - - class T { 1: string; } - >T : Symbol(T, Decl(assignmentCompatWithObjectMembersStringNumericNames.ts, 45, 28)) -@@= skipped -16, +16 lines =@@ - - interface S2 { '1': string; bar?: string } - >S2 : Symbol(S2, Decl(assignmentCompatWithObjectMembersStringNumericNames.ts, 48, 13)) -->'1' : Symbol(S2['1'], Decl(assignmentCompatWithObjectMembersStringNumericNames.ts, 50, 18)) -+>'1' : Symbol(S2["1"], Decl(assignmentCompatWithObjectMembersStringNumericNames.ts, 50, 18)) - >bar : Symbol(S2.bar, Decl(assignmentCompatWithObjectMembersStringNumericNames.ts, 50, 31)) - - interface T2 { 1.0: string; baz?: string } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/checkJsxNamespaceNamesQuestionableForms.symbols b/testdata/baselines/reference/submodule/conformance/checkJsxNamespaceNamesQuestionableForms.symbols index 3d552a741..e2d5bb562 100644 --- a/testdata/baselines/reference/submodule/conformance/checkJsxNamespaceNamesQuestionableForms.symbols +++ b/testdata/baselines/reference/submodule/conformance/checkJsxNamespaceNamesQuestionableForms.symbols @@ -8,17 +8,17 @@ declare namespace JSX { >IntrinsicElements : Symbol(IntrinsicElements, Decl(checkJsxNamespaceNamesQuestionableForms.tsx, 0, 23)) 'this:b': any; ->'this:b' : Symbol(IntrinsicElements["this:b"], Decl(checkJsxNamespaceNamesQuestionableForms.tsx, 1, 33)) +>'this:b' : Symbol(IntrinsicElements['this:b'], Decl(checkJsxNamespaceNamesQuestionableForms.tsx, 1, 33)) 'b:c': { ->'b:c' : Symbol(IntrinsicElements["b:c"], Decl(checkJsxNamespaceNamesQuestionableForms.tsx, 2, 22)) +>'b:c' : Symbol(IntrinsicElements['b:c'], Decl(checkJsxNamespaceNamesQuestionableForms.tsx, 2, 22)) x: any >x : Symbol(x, Decl(checkJsxNamespaceNamesQuestionableForms.tsx, 3, 16)) }; 'a:b': any; ->'a:b' : Symbol(IntrinsicElements["a:b"], Decl(checkJsxNamespaceNamesQuestionableForms.tsx, 5, 10)) +>'a:b' : Symbol(IntrinsicElements['a:b'], Decl(checkJsxNamespaceNamesQuestionableForms.tsx, 5, 10)) } } diff --git a/testdata/baselines/reference/submodule/conformance/checkJsxNamespaceNamesQuestionableForms.symbols.diff b/testdata/baselines/reference/submodule/conformance/checkJsxNamespaceNamesQuestionableForms.symbols.diff deleted file mode 100644 index 686edd83c..000000000 --- a/testdata/baselines/reference/submodule/conformance/checkJsxNamespaceNamesQuestionableForms.symbols.diff +++ /dev/null @@ -1,22 +0,0 @@ ---- old.checkJsxNamespaceNamesQuestionableForms.symbols -+++ new.checkJsxNamespaceNamesQuestionableForms.symbols -@@= skipped -7, +7 lines =@@ - >IntrinsicElements : Symbol(IntrinsicElements, Decl(checkJsxNamespaceNamesQuestionableForms.tsx, 0, 23)) - - 'this:b': any; -->'this:b' : Symbol(IntrinsicElements['this:b'], Decl(checkJsxNamespaceNamesQuestionableForms.tsx, 1, 33)) -+>'this:b' : Symbol(IntrinsicElements["this:b"], Decl(checkJsxNamespaceNamesQuestionableForms.tsx, 1, 33)) - - 'b:c': { -->'b:c' : Symbol(IntrinsicElements['b:c'], Decl(checkJsxNamespaceNamesQuestionableForms.tsx, 2, 22)) -+>'b:c' : Symbol(IntrinsicElements["b:c"], Decl(checkJsxNamespaceNamesQuestionableForms.tsx, 2, 22)) - - x: any - >x : Symbol(x, Decl(checkJsxNamespaceNamesQuestionableForms.tsx, 3, 16)) - - }; - 'a:b': any; -->'a:b' : Symbol(IntrinsicElements['a:b'], Decl(checkJsxNamespaceNamesQuestionableForms.tsx, 5, 10)) -+>'a:b' : Symbol(IntrinsicElements["a:b"], Decl(checkJsxNamespaceNamesQuestionableForms.tsx, 5, 10)) - } - } diff --git a/testdata/baselines/reference/submodule/conformance/derivedInterfaceIncompatibleWithBaseIndexer.symbols b/testdata/baselines/reference/submodule/conformance/derivedInterfaceIncompatibleWithBaseIndexer.symbols index b5cbeca44..49e157665 100644 --- a/testdata/baselines/reference/submodule/conformance/derivedInterfaceIncompatibleWithBaseIndexer.symbols +++ b/testdata/baselines/reference/submodule/conformance/derivedInterfaceIncompatibleWithBaseIndexer.symbols @@ -28,7 +28,7 @@ interface Derived2 extends Base { >Base : Symbol(Base, Decl(derivedInterfaceIncompatibleWithBaseIndexer.ts, 0, 0)) '1': { y: number } // error ->'1' : Symbol(Derived2["1"], Decl(derivedInterfaceIncompatibleWithBaseIndexer.ts, 9, 33)) +>'1' : Symbol(Derived2['1'], Decl(derivedInterfaceIncompatibleWithBaseIndexer.ts, 9, 33)) >y : Symbol(y, Decl(derivedInterfaceIncompatibleWithBaseIndexer.ts, 10, 10)) } diff --git a/testdata/baselines/reference/submodule/conformance/derivedInterfaceIncompatibleWithBaseIndexer.symbols.diff b/testdata/baselines/reference/submodule/conformance/derivedInterfaceIncompatibleWithBaseIndexer.symbols.diff deleted file mode 100644 index 9c31179df..000000000 --- a/testdata/baselines/reference/submodule/conformance/derivedInterfaceIncompatibleWithBaseIndexer.symbols.diff +++ /dev/null @@ -1,10 +0,0 @@ ---- old.derivedInterfaceIncompatibleWithBaseIndexer.symbols -+++ new.derivedInterfaceIncompatibleWithBaseIndexer.symbols -@@= skipped -27, +27 lines =@@ - >Base : Symbol(Base, Decl(derivedInterfaceIncompatibleWithBaseIndexer.ts, 0, 0)) - - '1': { y: number } // error -->'1' : Symbol(Derived2['1'], Decl(derivedInterfaceIncompatibleWithBaseIndexer.ts, 9, 33)) -+>'1' : Symbol(Derived2["1"], Decl(derivedInterfaceIncompatibleWithBaseIndexer.ts, 9, 33)) - >y : Symbol(y, Decl(derivedInterfaceIncompatibleWithBaseIndexer.ts, 10, 10)) - } diff --git a/testdata/baselines/reference/submodule/conformance/exportDefaultExpressionComments.js b/testdata/baselines/reference/submodule/conformance/exportDefaultExpressionComments.js index 4de97b7cd..23fbc875a 100644 --- a/testdata/baselines/reference/submodule/conformance/exportDefaultExpressionComments.js +++ b/testdata/baselines/reference/submodule/conformance/exportDefaultExpressionComments.js @@ -17,5 +17,8 @@ exports.default = null; //// [exportDefaultExpressionComments.d.ts] +/** + * JSDoc Comments + */ declare const _default: any; export default _default; diff --git a/testdata/baselines/reference/submodule/conformance/exportDefaultExpressionComments.js.diff b/testdata/baselines/reference/submodule/conformance/exportDefaultExpressionComments.js.diff deleted file mode 100644 index 1e8bfe990..000000000 --- a/testdata/baselines/reference/submodule/conformance/exportDefaultExpressionComments.js.diff +++ /dev/null @@ -1,11 +0,0 @@ ---- old.exportDefaultExpressionComments.js -+++ new.exportDefaultExpressionComments.js -@@= skipped -16, +16 lines =@@ - - - //// [exportDefaultExpressionComments.d.ts] --/** -- * JSDoc Comments -- */ - declare const _default: any; - export default _default; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/indexersInClassType.symbols b/testdata/baselines/reference/submodule/conformance/indexersInClassType.symbols index 1b4ab0c0d..de5c60010 100644 --- a/testdata/baselines/reference/submodule/conformance/indexersInClassType.symbols +++ b/testdata/baselines/reference/submodule/conformance/indexersInClassType.symbols @@ -17,7 +17,7 @@ class C { >Date : Symbol(Date, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.scripthost.d.ts, --, --)) 'a': {} ->'a' : Symbol(C["a"], Decl(indexersInClassType.ts, 3, 12)) +>'a' : Symbol(C['a'], Decl(indexersInClassType.ts, 3, 12)) fn() { >fn : Symbol(C.fn, Decl(indexersInClassType.ts, 4, 11)) @@ -44,8 +44,8 @@ var r2 = r[1]; var r3 = r.a >r3 : Symbol(r3, Decl(indexersInClassType.ts, 14, 3)) ->r.a : Symbol(C["a"], Decl(indexersInClassType.ts, 3, 12)) +>r.a : Symbol(C['a'], Decl(indexersInClassType.ts, 3, 12)) >r : Symbol(r, Decl(indexersInClassType.ts, 12, 3)) ->a : Symbol(C["a"], Decl(indexersInClassType.ts, 3, 12)) +>a : Symbol(C['a'], Decl(indexersInClassType.ts, 3, 12)) diff --git a/testdata/baselines/reference/submodule/conformance/indexersInClassType.symbols.diff b/testdata/baselines/reference/submodule/conformance/indexersInClassType.symbols.diff deleted file mode 100644 index e743a2cd8..000000000 --- a/testdata/baselines/reference/submodule/conformance/indexersInClassType.symbols.diff +++ /dev/null @@ -1,21 +0,0 @@ ---- old.indexersInClassType.symbols -+++ new.indexersInClassType.symbols -@@= skipped -16, +16 lines =@@ - >Date : Symbol(Date, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.scripthost.d.ts, --, --)) - - 'a': {} -->'a' : Symbol(C['a'], Decl(indexersInClassType.ts, 3, 12)) -+>'a' : Symbol(C["a"], Decl(indexersInClassType.ts, 3, 12)) - - fn() { - >fn : Symbol(C.fn, Decl(indexersInClassType.ts, 4, 11)) -@@= skipped -27, +27 lines =@@ - - var r3 = r.a - >r3 : Symbol(r3, Decl(indexersInClassType.ts, 14, 3)) -->r.a : Symbol(C['a'], Decl(indexersInClassType.ts, 3, 12)) -+>r.a : Symbol(C["a"], Decl(indexersInClassType.ts, 3, 12)) - >r : Symbol(r, Decl(indexersInClassType.ts, 12, 3)) -->a : Symbol(C['a'], Decl(indexersInClassType.ts, 3, 12)) -+>a : Symbol(C["a"], Decl(indexersInClassType.ts, 3, 12)) - diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportAssignedConstructorFunctionWithSub.js b/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportAssignedConstructorFunctionWithSub.js index bd73c59f8..32814e215 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportAssignedConstructorFunctionWithSub.js +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportAssignedConstructorFunctionWithSub.js @@ -30,6 +30,9 @@ module.exports.Sub.prototype = {}; //// [jsDeclarationsExportAssignedConstructorFunctionWithSub.d.ts] +/** + * @param {number} p + */ declare const _default: (p: number) => void; export = _default; export declare var Sub: () => void; diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportAssignedConstructorFunctionWithSub.js.diff b/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportAssignedConstructorFunctionWithSub.js.diff index 4a4defdd7..d4b5c6aa9 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportAssignedConstructorFunctionWithSub.js.diff +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportAssignedConstructorFunctionWithSub.js.diff @@ -14,6 +14,9 @@ + + +//// [jsDeclarationsExportAssignedConstructorFunctionWithSub.d.ts] ++/** ++ * @param {number} p ++ */ +declare const _default: (p: number) => void; +export = _default; +export declare var Sub: () => void; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/mergedInterfacesWithIndexers2.symbols b/testdata/baselines/reference/submodule/conformance/mergedInterfacesWithIndexers2.symbols index 2138a8a77..0384c5a32 100644 --- a/testdata/baselines/reference/submodule/conformance/mergedInterfacesWithIndexers2.symbols +++ b/testdata/baselines/reference/submodule/conformance/mergedInterfacesWithIndexers2.symbols @@ -26,7 +26,7 @@ interface A2 { >x : Symbol(x, Decl(mergedInterfacesWithIndexers2.ts, 12, 5)) 'a': number; //error ->'a' : Symbol(A2["a"], Decl(mergedInterfacesWithIndexers2.ts, 12, 24)) +>'a' : Symbol(A2['a'], Decl(mergedInterfacesWithIndexers2.ts, 12, 24)) } diff --git a/testdata/baselines/reference/submodule/conformance/mergedInterfacesWithIndexers2.symbols.diff b/testdata/baselines/reference/submodule/conformance/mergedInterfacesWithIndexers2.symbols.diff deleted file mode 100644 index 8139dfd7d..000000000 --- a/testdata/baselines/reference/submodule/conformance/mergedInterfacesWithIndexers2.symbols.diff +++ /dev/null @@ -1,10 +0,0 @@ ---- old.mergedInterfacesWithIndexers2.symbols -+++ new.mergedInterfacesWithIndexers2.symbols -@@= skipped -25, +25 lines =@@ - >x : Symbol(x, Decl(mergedInterfacesWithIndexers2.ts, 12, 5)) - - 'a': number; //error -->'a' : Symbol(A2['a'], Decl(mergedInterfacesWithIndexers2.ts, 12, 24)) -+>'a' : Symbol(A2["a"], Decl(mergedInterfacesWithIndexers2.ts, 12, 24)) - } - diff --git a/testdata/baselines/reference/submodule/conformance/numericIndexerConstrainsPropertyDeclarations.symbols b/testdata/baselines/reference/submodule/conformance/numericIndexerConstrainsPropertyDeclarations.symbols index b67e79211..f280ea83c 100644 --- a/testdata/baselines/reference/submodule/conformance/numericIndexerConstrainsPropertyDeclarations.symbols +++ b/testdata/baselines/reference/submodule/conformance/numericIndexerConstrainsPropertyDeclarations.symbols @@ -41,10 +41,10 @@ class C { >2.0 : Symbol(C[2.0], Decl(numericIndexerConstrainsPropertyDeclarations.ts, 16, 16)) "3.0": string; // ok ->"3.0" : Symbol(C["30"], Decl(numericIndexerConstrainsPropertyDeclarations.ts, 17, 16)) +>"3.0" : Symbol(C["3.0"], Decl(numericIndexerConstrainsPropertyDeclarations.ts, 17, 16)) "4.0": number; // error ->"4.0" : Symbol(C["40"], Decl(numericIndexerConstrainsPropertyDeclarations.ts, 18, 18)) +>"4.0" : Symbol(C["4.0"], Decl(numericIndexerConstrainsPropertyDeclarations.ts, 18, 18)) 3.0: MyNumber // error >3.0 : Symbol(C[3.0], Decl(numericIndexerConstrainsPropertyDeclarations.ts, 19, 18)) @@ -116,10 +116,10 @@ interface I { >foo : Symbol(I.foo, Decl(numericIndexerConstrainsPropertyDeclarations.ts, 51, 15)) "3.0": string; // ok ->"3.0" : Symbol(I["30"], Decl(numericIndexerConstrainsPropertyDeclarations.ts, 52, 18)) +>"3.0" : Symbol(I["3.0"], Decl(numericIndexerConstrainsPropertyDeclarations.ts, 52, 18)) "4.0": number; // error ->"4.0" : Symbol(I["40"], Decl(numericIndexerConstrainsPropertyDeclarations.ts, 53, 18)) +>"4.0" : Symbol(I["4.0"], Decl(numericIndexerConstrainsPropertyDeclarations.ts, 53, 18)) f: MyNumber; // error >f : Symbol(I.f, Decl(numericIndexerConstrainsPropertyDeclarations.ts, 54, 18)) diff --git a/testdata/baselines/reference/submodule/conformance/numericIndexerConstrainsPropertyDeclarations.symbols.diff b/testdata/baselines/reference/submodule/conformance/numericIndexerConstrainsPropertyDeclarations.symbols.diff deleted file mode 100644 index 9b7d39e5e..000000000 --- a/testdata/baselines/reference/submodule/conformance/numericIndexerConstrainsPropertyDeclarations.symbols.diff +++ /dev/null @@ -1,28 +0,0 @@ ---- old.numericIndexerConstrainsPropertyDeclarations.symbols -+++ new.numericIndexerConstrainsPropertyDeclarations.symbols -@@= skipped -40, +40 lines =@@ - >2.0 : Symbol(C[2.0], Decl(numericIndexerConstrainsPropertyDeclarations.ts, 16, 16)) - - "3.0": string; // ok -->"3.0" : Symbol(C["3.0"], Decl(numericIndexerConstrainsPropertyDeclarations.ts, 17, 16)) -+>"3.0" : Symbol(C["30"], Decl(numericIndexerConstrainsPropertyDeclarations.ts, 17, 16)) - - "4.0": number; // error -->"4.0" : Symbol(C["4.0"], Decl(numericIndexerConstrainsPropertyDeclarations.ts, 18, 18)) -+>"4.0" : Symbol(C["40"], Decl(numericIndexerConstrainsPropertyDeclarations.ts, 18, 18)) - - 3.0: MyNumber // error - >3.0 : Symbol(C[3.0], Decl(numericIndexerConstrainsPropertyDeclarations.ts, 19, 18)) -@@= skipped -75, +75 lines =@@ - >foo : Symbol(I.foo, Decl(numericIndexerConstrainsPropertyDeclarations.ts, 51, 15)) - - "3.0": string; // ok -->"3.0" : Symbol(I["3.0"], Decl(numericIndexerConstrainsPropertyDeclarations.ts, 52, 18)) -+>"3.0" : Symbol(I["30"], Decl(numericIndexerConstrainsPropertyDeclarations.ts, 52, 18)) - - "4.0": number; // error -->"4.0" : Symbol(I["4.0"], Decl(numericIndexerConstrainsPropertyDeclarations.ts, 53, 18)) -+>"4.0" : Symbol(I["40"], Decl(numericIndexerConstrainsPropertyDeclarations.ts, 53, 18)) - - f: MyNumber; // error - >f : Symbol(I.f, Decl(numericIndexerConstrainsPropertyDeclarations.ts, 54, 18)) \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/numericIndexerConstrainsPropertyDeclarations2.symbols b/testdata/baselines/reference/submodule/conformance/numericIndexerConstrainsPropertyDeclarations2.symbols index 18ef3b0d2..732c8ccce 100644 --- a/testdata/baselines/reference/submodule/conformance/numericIndexerConstrainsPropertyDeclarations2.symbols +++ b/testdata/baselines/reference/submodule/conformance/numericIndexerConstrainsPropertyDeclarations2.symbols @@ -34,14 +34,14 @@ class Foo { >B : Symbol(B, Decl(numericIndexerConstrainsPropertyDeclarations2.ts, 4, 1)) "2.5": B // ok ->"2.5" : Symbol(Foo["25"], Decl(numericIndexerConstrainsPropertyDeclarations2.ts, 13, 11)) +>"2.5" : Symbol(Foo["2.5"], Decl(numericIndexerConstrainsPropertyDeclarations2.ts, 13, 11)) >B : Symbol(B, Decl(numericIndexerConstrainsPropertyDeclarations2.ts, 4, 1)) 3.0: number; // error >3.0 : Symbol(Foo[3.0], Decl(numericIndexerConstrainsPropertyDeclarations2.ts, 14, 12)) "4.0": string; // error ->"4.0" : Symbol(Foo["40"], Decl(numericIndexerConstrainsPropertyDeclarations2.ts, 15, 16)) +>"4.0" : Symbol(Foo["4.0"], Decl(numericIndexerConstrainsPropertyDeclarations2.ts, 15, 16)) } interface Foo2 { @@ -60,14 +60,14 @@ interface Foo2 { >B : Symbol(B, Decl(numericIndexerConstrainsPropertyDeclarations2.ts, 4, 1)) "2.5": B // ok ->"2.5" : Symbol(Foo2["25"], Decl(numericIndexerConstrainsPropertyDeclarations2.ts, 22, 11)) +>"2.5" : Symbol(Foo2["2.5"], Decl(numericIndexerConstrainsPropertyDeclarations2.ts, 22, 11)) >B : Symbol(B, Decl(numericIndexerConstrainsPropertyDeclarations2.ts, 4, 1)) 3.0: number; // error >3.0 : Symbol(Foo2[3.0], Decl(numericIndexerConstrainsPropertyDeclarations2.ts, 23, 12)) "4.0": string; // error ->"4.0" : Symbol(Foo2["40"], Decl(numericIndexerConstrainsPropertyDeclarations2.ts, 24, 16)) +>"4.0" : Symbol(Foo2["4.0"], Decl(numericIndexerConstrainsPropertyDeclarations2.ts, 24, 16)) } var a: { diff --git a/testdata/baselines/reference/submodule/conformance/numericIndexerConstrainsPropertyDeclarations2.symbols.diff b/testdata/baselines/reference/submodule/conformance/numericIndexerConstrainsPropertyDeclarations2.symbols.diff deleted file mode 100644 index b2ca08689..000000000 --- a/testdata/baselines/reference/submodule/conformance/numericIndexerConstrainsPropertyDeclarations2.symbols.diff +++ /dev/null @@ -1,36 +0,0 @@ ---- old.numericIndexerConstrainsPropertyDeclarations2.symbols -+++ new.numericIndexerConstrainsPropertyDeclarations2.symbols -@@= skipped -33, +33 lines =@@ - >B : Symbol(B, Decl(numericIndexerConstrainsPropertyDeclarations2.ts, 4, 1)) - - "2.5": B // ok -->"2.5" : Symbol(Foo["2.5"], Decl(numericIndexerConstrainsPropertyDeclarations2.ts, 13, 11)) -+>"2.5" : Symbol(Foo["25"], Decl(numericIndexerConstrainsPropertyDeclarations2.ts, 13, 11)) - >B : Symbol(B, Decl(numericIndexerConstrainsPropertyDeclarations2.ts, 4, 1)) - - 3.0: number; // error - >3.0 : Symbol(Foo[3.0], Decl(numericIndexerConstrainsPropertyDeclarations2.ts, 14, 12)) - - "4.0": string; // error -->"4.0" : Symbol(Foo["4.0"], Decl(numericIndexerConstrainsPropertyDeclarations2.ts, 15, 16)) -+>"4.0" : Symbol(Foo["40"], Decl(numericIndexerConstrainsPropertyDeclarations2.ts, 15, 16)) - } - - interface Foo2 { -@@= skipped -26, +26 lines =@@ - >B : Symbol(B, Decl(numericIndexerConstrainsPropertyDeclarations2.ts, 4, 1)) - - "2.5": B // ok -->"2.5" : Symbol(Foo2["2.5"], Decl(numericIndexerConstrainsPropertyDeclarations2.ts, 22, 11)) -+>"2.5" : Symbol(Foo2["25"], Decl(numericIndexerConstrainsPropertyDeclarations2.ts, 22, 11)) - >B : Symbol(B, Decl(numericIndexerConstrainsPropertyDeclarations2.ts, 4, 1)) - - 3.0: number; // error - >3.0 : Symbol(Foo2[3.0], Decl(numericIndexerConstrainsPropertyDeclarations2.ts, 23, 12)) - - "4.0": string; // error -->"4.0" : Symbol(Foo2["4.0"], Decl(numericIndexerConstrainsPropertyDeclarations2.ts, 24, 16)) -+>"4.0" : Symbol(Foo2["40"], Decl(numericIndexerConstrainsPropertyDeclarations2.ts, 24, 16)) - } - - var a: { \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/numericStringNamedPropertyEquivalence.symbols b/testdata/baselines/reference/submodule/conformance/numericStringNamedPropertyEquivalence.symbols index 60e450839..a6738c427 100644 --- a/testdata/baselines/reference/submodule/conformance/numericStringNamedPropertyEquivalence.symbols +++ b/testdata/baselines/reference/submodule/conformance/numericStringNamedPropertyEquivalence.symbols @@ -10,7 +10,7 @@ class C { >"1" : Symbol(C["1"], Decl(numericStringNamedPropertyEquivalence.ts, 2, 9), Decl(numericStringNamedPropertyEquivalence.ts, 4, 18)) "1.0": number; // not a duplicate ->"1.0" : Symbol(C["10"], Decl(numericStringNamedPropertyEquivalence.ts, 3, 16)) +>"1.0" : Symbol(C["1.0"], Decl(numericStringNamedPropertyEquivalence.ts, 3, 16)) 1.0: number; >1.0 : Symbol(C["1"], Decl(numericStringNamedPropertyEquivalence.ts, 2, 9), Decl(numericStringNamedPropertyEquivalence.ts, 4, 18)) @@ -23,7 +23,7 @@ interface I { >"1" : Symbol(I["1"], Decl(numericStringNamedPropertyEquivalence.ts, 8, 13), Decl(numericStringNamedPropertyEquivalence.ts, 10, 17)) "1.": number; // not a duplicate ->"1." : Symbol(I["1"], Decl(numericStringNamedPropertyEquivalence.ts, 9, 16)) +>"1." : Symbol(I["1."], Decl(numericStringNamedPropertyEquivalence.ts, 9, 16)) 1: number; >1 : Symbol(I["1"], Decl(numericStringNamedPropertyEquivalence.ts, 8, 13), Decl(numericStringNamedPropertyEquivalence.ts, 10, 17)) diff --git a/testdata/baselines/reference/submodule/conformance/numericStringNamedPropertyEquivalence.symbols.diff b/testdata/baselines/reference/submodule/conformance/numericStringNamedPropertyEquivalence.symbols.diff deleted file mode 100644 index 3c5ae6516..000000000 --- a/testdata/baselines/reference/submodule/conformance/numericStringNamedPropertyEquivalence.symbols.diff +++ /dev/null @@ -1,20 +0,0 @@ ---- old.numericStringNamedPropertyEquivalence.symbols -+++ new.numericStringNamedPropertyEquivalence.symbols -@@= skipped -9, +9 lines =@@ - >"1" : Symbol(C["1"], Decl(numericStringNamedPropertyEquivalence.ts, 2, 9), Decl(numericStringNamedPropertyEquivalence.ts, 4, 18)) - - "1.0": number; // not a duplicate -->"1.0" : Symbol(C["1.0"], Decl(numericStringNamedPropertyEquivalence.ts, 3, 16)) -+>"1.0" : Symbol(C["10"], Decl(numericStringNamedPropertyEquivalence.ts, 3, 16)) - - 1.0: number; - >1.0 : Symbol(C["1"], Decl(numericStringNamedPropertyEquivalence.ts, 2, 9), Decl(numericStringNamedPropertyEquivalence.ts, 4, 18)) -@@= skipped -13, +13 lines =@@ - >"1" : Symbol(I["1"], Decl(numericStringNamedPropertyEquivalence.ts, 8, 13), Decl(numericStringNamedPropertyEquivalence.ts, 10, 17)) - - "1.": number; // not a duplicate -->"1." : Symbol(I["1."], Decl(numericStringNamedPropertyEquivalence.ts, 9, 16)) -+>"1." : Symbol(I["1"], Decl(numericStringNamedPropertyEquivalence.ts, 9, 16)) - - 1: number; - >1 : Symbol(I["1"], Decl(numericStringNamedPropertyEquivalence.ts, 8, 13), Decl(numericStringNamedPropertyEquivalence.ts, 10, 17)) \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/objectTypeWithStringNamedNumericProperty.symbols b/testdata/baselines/reference/submodule/conformance/objectTypeWithStringNamedNumericProperty.symbols index 02cecf128..96ddd841d 100644 --- a/testdata/baselines/reference/submodule/conformance/objectTypeWithStringNamedNumericProperty.symbols +++ b/testdata/baselines/reference/submodule/conformance/objectTypeWithStringNamedNumericProperty.symbols @@ -9,27 +9,27 @@ class C { >C : Symbol(C, Decl(objectTypeWithStringNamedNumericProperty.ts, 0, 0)) "0.1": void; ->"0.1" : Symbol(C["01"], Decl(objectTypeWithStringNamedNumericProperty.ts, 4, 9)) +>"0.1" : Symbol(C["0.1"], Decl(objectTypeWithStringNamedNumericProperty.ts, 4, 9)) ".1": Object; ->".1" : Symbol(C["1"], Decl(objectTypeWithStringNamedNumericProperty.ts, 5, 16)) +>".1" : Symbol(C[".1"], Decl(objectTypeWithStringNamedNumericProperty.ts, 5, 16)) >Object : Symbol(Object, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) "1": number; >"1" : Symbol(C["1"], Decl(objectTypeWithStringNamedNumericProperty.ts, 6, 17)) "1.": string; ->"1." : Symbol(C["1"], Decl(objectTypeWithStringNamedNumericProperty.ts, 7, 16)) +>"1." : Symbol(C["1."], Decl(objectTypeWithStringNamedNumericProperty.ts, 7, 16)) "1..": boolean; ->"1.." : Symbol(C["1"], Decl(objectTypeWithStringNamedNumericProperty.ts, 8, 17)) +>"1.." : Symbol(C["1.."], Decl(objectTypeWithStringNamedNumericProperty.ts, 8, 17)) "1.0": Date; ->"1.0" : Symbol(C["10"], Decl(objectTypeWithStringNamedNumericProperty.ts, 9, 19)) +>"1.0" : Symbol(C["1.0"], Decl(objectTypeWithStringNamedNumericProperty.ts, 9, 19)) >Date : Symbol(Date, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.scripthost.d.ts, --, --)) "-1.0": RegExp; ->"-1.0" : Symbol(C["-10"], Decl(objectTypeWithStringNamedNumericProperty.ts, 10, 16)) +>"-1.0" : Symbol(C["-1.0"], Decl(objectTypeWithStringNamedNumericProperty.ts, 10, 16)) >RegExp : Symbol(RegExp, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) "-1": Date; @@ -44,12 +44,12 @@ var c: C; var r1 = c['0.1']; >r1 : Symbol(r1, Decl(objectTypeWithStringNamedNumericProperty.ts, 16, 3), Decl(objectTypeWithStringNamedNumericProperty.ts, 47, 3), Decl(objectTypeWithStringNamedNumericProperty.ts, 77, 3), Decl(objectTypeWithStringNamedNumericProperty.ts, 107, 3)) >c : Symbol(c, Decl(objectTypeWithStringNamedNumericProperty.ts, 15, 3)) ->'0.1' : Symbol(C["01"], Decl(objectTypeWithStringNamedNumericProperty.ts, 4, 9)) +>'0.1' : Symbol(C["0.1"], Decl(objectTypeWithStringNamedNumericProperty.ts, 4, 9)) var r2 = c['.1']; >r2 : Symbol(r2, Decl(objectTypeWithStringNamedNumericProperty.ts, 17, 3), Decl(objectTypeWithStringNamedNumericProperty.ts, 48, 3), Decl(objectTypeWithStringNamedNumericProperty.ts, 78, 3), Decl(objectTypeWithStringNamedNumericProperty.ts, 108, 3)) >c : Symbol(c, Decl(objectTypeWithStringNamedNumericProperty.ts, 15, 3)) ->'.1' : Symbol(C["1"], Decl(objectTypeWithStringNamedNumericProperty.ts, 5, 16)) +>'.1' : Symbol(C[".1"], Decl(objectTypeWithStringNamedNumericProperty.ts, 5, 16)) var r3 = c['1']; >r3 : Symbol(r3, Decl(objectTypeWithStringNamedNumericProperty.ts, 18, 3), Decl(objectTypeWithStringNamedNumericProperty.ts, 19, 3), Decl(objectTypeWithStringNamedNumericProperty.ts, 21, 3), Decl(objectTypeWithStringNamedNumericProperty.ts, 24, 3), Decl(objectTypeWithStringNamedNumericProperty.ts, 49, 3) ... and 11 more) @@ -64,7 +64,7 @@ var r3 = c[1]; var r4 = c['1.']; >r4 : Symbol(r4, Decl(objectTypeWithStringNamedNumericProperty.ts, 20, 3), Decl(objectTypeWithStringNamedNumericProperty.ts, 51, 3), Decl(objectTypeWithStringNamedNumericProperty.ts, 81, 3), Decl(objectTypeWithStringNamedNumericProperty.ts, 111, 3)) >c : Symbol(c, Decl(objectTypeWithStringNamedNumericProperty.ts, 15, 3)) ->'1.' : Symbol(C["1"], Decl(objectTypeWithStringNamedNumericProperty.ts, 7, 16)) +>'1.' : Symbol(C["1."], Decl(objectTypeWithStringNamedNumericProperty.ts, 7, 16)) var r3 = c[1.]; // same as indexing by 1 when done numerically >r3 : Symbol(r3, Decl(objectTypeWithStringNamedNumericProperty.ts, 18, 3), Decl(objectTypeWithStringNamedNumericProperty.ts, 19, 3), Decl(objectTypeWithStringNamedNumericProperty.ts, 21, 3), Decl(objectTypeWithStringNamedNumericProperty.ts, 24, 3), Decl(objectTypeWithStringNamedNumericProperty.ts, 49, 3) ... and 11 more) @@ -74,12 +74,12 @@ var r3 = c[1.]; // same as indexing by 1 when done numerically var r5 = c['1..']; >r5 : Symbol(r5, Decl(objectTypeWithStringNamedNumericProperty.ts, 22, 3), Decl(objectTypeWithStringNamedNumericProperty.ts, 53, 3), Decl(objectTypeWithStringNamedNumericProperty.ts, 83, 3), Decl(objectTypeWithStringNamedNumericProperty.ts, 113, 3)) >c : Symbol(c, Decl(objectTypeWithStringNamedNumericProperty.ts, 15, 3)) ->'1..' : Symbol(C["1"], Decl(objectTypeWithStringNamedNumericProperty.ts, 8, 17)) +>'1..' : Symbol(C["1.."], Decl(objectTypeWithStringNamedNumericProperty.ts, 8, 17)) var r6 = c['1.0']; >r6 : Symbol(r6, Decl(objectTypeWithStringNamedNumericProperty.ts, 23, 3), Decl(objectTypeWithStringNamedNumericProperty.ts, 54, 3), Decl(objectTypeWithStringNamedNumericProperty.ts, 84, 3), Decl(objectTypeWithStringNamedNumericProperty.ts, 114, 3)) >c : Symbol(c, Decl(objectTypeWithStringNamedNumericProperty.ts, 15, 3)) ->'1.0' : Symbol(C["10"], Decl(objectTypeWithStringNamedNumericProperty.ts, 9, 19)) +>'1.0' : Symbol(C["1.0"], Decl(objectTypeWithStringNamedNumericProperty.ts, 9, 19)) var r3 = c[1.0]; // same as indexing by 1 when done numerically >r3 : Symbol(r3, Decl(objectTypeWithStringNamedNumericProperty.ts, 18, 3), Decl(objectTypeWithStringNamedNumericProperty.ts, 19, 3), Decl(objectTypeWithStringNamedNumericProperty.ts, 21, 3), Decl(objectTypeWithStringNamedNumericProperty.ts, 24, 3), Decl(objectTypeWithStringNamedNumericProperty.ts, 49, 3) ... and 11 more) @@ -98,7 +98,7 @@ var r7 = i[-1.0]; var r8 = i["-1.0"]; >r8 : Symbol(r8, Decl(objectTypeWithStringNamedNumericProperty.ts, 28, 3), Decl(objectTypeWithStringNamedNumericProperty.ts, 59, 3), Decl(objectTypeWithStringNamedNumericProperty.ts, 89, 3), Decl(objectTypeWithStringNamedNumericProperty.ts, 119, 3)) >i : Symbol(i, Decl(objectTypeWithStringNamedNumericProperty.ts, 46, 3)) ->"-1.0" : Symbol(I["-10"], Decl(objectTypeWithStringNamedNumericProperty.ts, 41, 16)) +>"-1.0" : Symbol(I["-1.0"], Decl(objectTypeWithStringNamedNumericProperty.ts, 41, 16)) var r9 = i["-1"]; >r9 : Symbol(r9, Decl(objectTypeWithStringNamedNumericProperty.ts, 29, 3), Decl(objectTypeWithStringNamedNumericProperty.ts, 60, 3), Decl(objectTypeWithStringNamedNumericProperty.ts, 90, 3), Decl(objectTypeWithStringNamedNumericProperty.ts, 120, 3)) @@ -127,27 +127,27 @@ interface I { >I : Symbol(I, Decl(objectTypeWithStringNamedNumericProperty.ts, 33, 16)) "0.1": void; ->"0.1" : Symbol(I["01"], Decl(objectTypeWithStringNamedNumericProperty.ts, 35, 13)) +>"0.1" : Symbol(I["0.1"], Decl(objectTypeWithStringNamedNumericProperty.ts, 35, 13)) ".1": Object; ->".1" : Symbol(I["1"], Decl(objectTypeWithStringNamedNumericProperty.ts, 36, 16)) +>".1" : Symbol(I[".1"], Decl(objectTypeWithStringNamedNumericProperty.ts, 36, 16)) >Object : Symbol(Object, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) "1": number; >"1" : Symbol(I["1"], Decl(objectTypeWithStringNamedNumericProperty.ts, 37, 17)) "1.": string; ->"1." : Symbol(I["1"], Decl(objectTypeWithStringNamedNumericProperty.ts, 38, 16)) +>"1." : Symbol(I["1."], Decl(objectTypeWithStringNamedNumericProperty.ts, 38, 16)) "1..": boolean; ->"1.." : Symbol(I["1"], Decl(objectTypeWithStringNamedNumericProperty.ts, 39, 17)) +>"1.." : Symbol(I["1.."], Decl(objectTypeWithStringNamedNumericProperty.ts, 39, 17)) "1.0": Date; ->"1.0" : Symbol(I["10"], Decl(objectTypeWithStringNamedNumericProperty.ts, 40, 19)) +>"1.0" : Symbol(I["1.0"], Decl(objectTypeWithStringNamedNumericProperty.ts, 40, 19)) >Date : Symbol(Date, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.scripthost.d.ts, --, --)) "-1.0": RegExp; ->"-1.0" : Symbol(I["-10"], Decl(objectTypeWithStringNamedNumericProperty.ts, 41, 16)) +>"-1.0" : Symbol(I["-1.0"], Decl(objectTypeWithStringNamedNumericProperty.ts, 41, 16)) >RegExp : Symbol(RegExp, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) "-1": Date; @@ -162,12 +162,12 @@ var i: I; var r1 = i['0.1']; >r1 : Symbol(r1, Decl(objectTypeWithStringNamedNumericProperty.ts, 16, 3), Decl(objectTypeWithStringNamedNumericProperty.ts, 47, 3), Decl(objectTypeWithStringNamedNumericProperty.ts, 77, 3), Decl(objectTypeWithStringNamedNumericProperty.ts, 107, 3)) >i : Symbol(i, Decl(objectTypeWithStringNamedNumericProperty.ts, 46, 3)) ->'0.1' : Symbol(I["01"], Decl(objectTypeWithStringNamedNumericProperty.ts, 35, 13)) +>'0.1' : Symbol(I["0.1"], Decl(objectTypeWithStringNamedNumericProperty.ts, 35, 13)) var r2 = i['.1']; >r2 : Symbol(r2, Decl(objectTypeWithStringNamedNumericProperty.ts, 17, 3), Decl(objectTypeWithStringNamedNumericProperty.ts, 48, 3), Decl(objectTypeWithStringNamedNumericProperty.ts, 78, 3), Decl(objectTypeWithStringNamedNumericProperty.ts, 108, 3)) >i : Symbol(i, Decl(objectTypeWithStringNamedNumericProperty.ts, 46, 3)) ->'.1' : Symbol(I["1"], Decl(objectTypeWithStringNamedNumericProperty.ts, 36, 16)) +>'.1' : Symbol(I[".1"], Decl(objectTypeWithStringNamedNumericProperty.ts, 36, 16)) var r3 = i['1']; >r3 : Symbol(r3, Decl(objectTypeWithStringNamedNumericProperty.ts, 18, 3), Decl(objectTypeWithStringNamedNumericProperty.ts, 19, 3), Decl(objectTypeWithStringNamedNumericProperty.ts, 21, 3), Decl(objectTypeWithStringNamedNumericProperty.ts, 24, 3), Decl(objectTypeWithStringNamedNumericProperty.ts, 49, 3) ... and 11 more) @@ -182,7 +182,7 @@ var r3 = c[1]; var r4 = i['1.']; >r4 : Symbol(r4, Decl(objectTypeWithStringNamedNumericProperty.ts, 20, 3), Decl(objectTypeWithStringNamedNumericProperty.ts, 51, 3), Decl(objectTypeWithStringNamedNumericProperty.ts, 81, 3), Decl(objectTypeWithStringNamedNumericProperty.ts, 111, 3)) >i : Symbol(i, Decl(objectTypeWithStringNamedNumericProperty.ts, 46, 3)) ->'1.' : Symbol(I["1"], Decl(objectTypeWithStringNamedNumericProperty.ts, 38, 16)) +>'1.' : Symbol(I["1."], Decl(objectTypeWithStringNamedNumericProperty.ts, 38, 16)) var r3 = c[1.]; // same as indexing by 1 when done numerically >r3 : Symbol(r3, Decl(objectTypeWithStringNamedNumericProperty.ts, 18, 3), Decl(objectTypeWithStringNamedNumericProperty.ts, 19, 3), Decl(objectTypeWithStringNamedNumericProperty.ts, 21, 3), Decl(objectTypeWithStringNamedNumericProperty.ts, 24, 3), Decl(objectTypeWithStringNamedNumericProperty.ts, 49, 3) ... and 11 more) @@ -192,12 +192,12 @@ var r3 = c[1.]; // same as indexing by 1 when done numerically var r5 = i['1..']; >r5 : Symbol(r5, Decl(objectTypeWithStringNamedNumericProperty.ts, 22, 3), Decl(objectTypeWithStringNamedNumericProperty.ts, 53, 3), Decl(objectTypeWithStringNamedNumericProperty.ts, 83, 3), Decl(objectTypeWithStringNamedNumericProperty.ts, 113, 3)) >i : Symbol(i, Decl(objectTypeWithStringNamedNumericProperty.ts, 46, 3)) ->'1..' : Symbol(I["1"], Decl(objectTypeWithStringNamedNumericProperty.ts, 39, 17)) +>'1..' : Symbol(I["1.."], Decl(objectTypeWithStringNamedNumericProperty.ts, 39, 17)) var r6 = i['1.0']; >r6 : Symbol(r6, Decl(objectTypeWithStringNamedNumericProperty.ts, 23, 3), Decl(objectTypeWithStringNamedNumericProperty.ts, 54, 3), Decl(objectTypeWithStringNamedNumericProperty.ts, 84, 3), Decl(objectTypeWithStringNamedNumericProperty.ts, 114, 3)) >i : Symbol(i, Decl(objectTypeWithStringNamedNumericProperty.ts, 46, 3)) ->'1.0' : Symbol(I["10"], Decl(objectTypeWithStringNamedNumericProperty.ts, 40, 19)) +>'1.0' : Symbol(I["1.0"], Decl(objectTypeWithStringNamedNumericProperty.ts, 40, 19)) var r3 = c[1.0]; // same as indexing by 1 when done numerically >r3 : Symbol(r3, Decl(objectTypeWithStringNamedNumericProperty.ts, 18, 3), Decl(objectTypeWithStringNamedNumericProperty.ts, 19, 3), Decl(objectTypeWithStringNamedNumericProperty.ts, 21, 3), Decl(objectTypeWithStringNamedNumericProperty.ts, 24, 3), Decl(objectTypeWithStringNamedNumericProperty.ts, 49, 3) ... and 11 more) @@ -216,7 +216,7 @@ var r7 = i[-1.0]; var r8 = i["-1.0"]; >r8 : Symbol(r8, Decl(objectTypeWithStringNamedNumericProperty.ts, 28, 3), Decl(objectTypeWithStringNamedNumericProperty.ts, 59, 3), Decl(objectTypeWithStringNamedNumericProperty.ts, 89, 3), Decl(objectTypeWithStringNamedNumericProperty.ts, 119, 3)) >i : Symbol(i, Decl(objectTypeWithStringNamedNumericProperty.ts, 46, 3)) ->"-1.0" : Symbol(I["-10"], Decl(objectTypeWithStringNamedNumericProperty.ts, 41, 16)) +>"-1.0" : Symbol(I["-1.0"], Decl(objectTypeWithStringNamedNumericProperty.ts, 41, 16)) var r9 = i["-1"]; >r9 : Symbol(r9, Decl(objectTypeWithStringNamedNumericProperty.ts, 29, 3), Decl(objectTypeWithStringNamedNumericProperty.ts, 60, 3), Decl(objectTypeWithStringNamedNumericProperty.ts, 90, 3), Decl(objectTypeWithStringNamedNumericProperty.ts, 120, 3)) @@ -330,7 +330,7 @@ var r7 = i[-1.0]; var r8 = i["-1.0"]; >r8 : Symbol(r8, Decl(objectTypeWithStringNamedNumericProperty.ts, 28, 3), Decl(objectTypeWithStringNamedNumericProperty.ts, 59, 3), Decl(objectTypeWithStringNamedNumericProperty.ts, 89, 3), Decl(objectTypeWithStringNamedNumericProperty.ts, 119, 3)) >i : Symbol(i, Decl(objectTypeWithStringNamedNumericProperty.ts, 46, 3)) ->"-1.0" : Symbol(I["-10"], Decl(objectTypeWithStringNamedNumericProperty.ts, 41, 16)) +>"-1.0" : Symbol(I["-1.0"], Decl(objectTypeWithStringNamedNumericProperty.ts, 41, 16)) var r9 = i["-1"]; >r9 : Symbol(r9, Decl(objectTypeWithStringNamedNumericProperty.ts, 29, 3), Decl(objectTypeWithStringNamedNumericProperty.ts, 60, 3), Decl(objectTypeWithStringNamedNumericProperty.ts, 90, 3), Decl(objectTypeWithStringNamedNumericProperty.ts, 120, 3)) @@ -444,7 +444,7 @@ var r7 = i[-1.0]; var r8 = i["-1.0"]; >r8 : Symbol(r8, Decl(objectTypeWithStringNamedNumericProperty.ts, 28, 3), Decl(objectTypeWithStringNamedNumericProperty.ts, 59, 3), Decl(objectTypeWithStringNamedNumericProperty.ts, 89, 3), Decl(objectTypeWithStringNamedNumericProperty.ts, 119, 3)) >i : Symbol(i, Decl(objectTypeWithStringNamedNumericProperty.ts, 46, 3)) ->"-1.0" : Symbol(I["-10"], Decl(objectTypeWithStringNamedNumericProperty.ts, 41, 16)) +>"-1.0" : Symbol(I["-1.0"], Decl(objectTypeWithStringNamedNumericProperty.ts, 41, 16)) var r9 = i["-1"]; >r9 : Symbol(r9, Decl(objectTypeWithStringNamedNumericProperty.ts, 29, 3), Decl(objectTypeWithStringNamedNumericProperty.ts, 60, 3), Decl(objectTypeWithStringNamedNumericProperty.ts, 90, 3), Decl(objectTypeWithStringNamedNumericProperty.ts, 120, 3)) diff --git a/testdata/baselines/reference/submodule/conformance/objectTypeWithStringNamedNumericProperty.symbols.diff b/testdata/baselines/reference/submodule/conformance/objectTypeWithStringNamedNumericProperty.symbols.diff deleted file mode 100644 index 813e8f04c..000000000 --- a/testdata/baselines/reference/submodule/conformance/objectTypeWithStringNamedNumericProperty.symbols.diff +++ /dev/null @@ -1,184 +0,0 @@ ---- old.objectTypeWithStringNamedNumericProperty.symbols -+++ new.objectTypeWithStringNamedNumericProperty.symbols -@@= skipped -8, +8 lines =@@ - >C : Symbol(C, Decl(objectTypeWithStringNamedNumericProperty.ts, 0, 0)) - - "0.1": void; -->"0.1" : Symbol(C["0.1"], Decl(objectTypeWithStringNamedNumericProperty.ts, 4, 9)) -+>"0.1" : Symbol(C["01"], Decl(objectTypeWithStringNamedNumericProperty.ts, 4, 9)) - - ".1": Object; -->".1" : Symbol(C[".1"], Decl(objectTypeWithStringNamedNumericProperty.ts, 5, 16)) -+>".1" : Symbol(C["1"], Decl(objectTypeWithStringNamedNumericProperty.ts, 5, 16)) - >Object : Symbol(Object, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) - - "1": number; - >"1" : Symbol(C["1"], Decl(objectTypeWithStringNamedNumericProperty.ts, 6, 17)) - - "1.": string; -->"1." : Symbol(C["1."], Decl(objectTypeWithStringNamedNumericProperty.ts, 7, 16)) -+>"1." : Symbol(C["1"], Decl(objectTypeWithStringNamedNumericProperty.ts, 7, 16)) - - "1..": boolean; -->"1.." : Symbol(C["1.."], Decl(objectTypeWithStringNamedNumericProperty.ts, 8, 17)) -+>"1.." : Symbol(C["1"], Decl(objectTypeWithStringNamedNumericProperty.ts, 8, 17)) - - "1.0": Date; -->"1.0" : Symbol(C["1.0"], Decl(objectTypeWithStringNamedNumericProperty.ts, 9, 19)) -+>"1.0" : Symbol(C["10"], Decl(objectTypeWithStringNamedNumericProperty.ts, 9, 19)) - >Date : Symbol(Date, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.scripthost.d.ts, --, --)) - - "-1.0": RegExp; -->"-1.0" : Symbol(C["-1.0"], Decl(objectTypeWithStringNamedNumericProperty.ts, 10, 16)) -+>"-1.0" : Symbol(C["-10"], Decl(objectTypeWithStringNamedNumericProperty.ts, 10, 16)) - >RegExp : Symbol(RegExp, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) - - "-1": Date; -@@= skipped -35, +35 lines =@@ - var r1 = c['0.1']; - >r1 : Symbol(r1, Decl(objectTypeWithStringNamedNumericProperty.ts, 16, 3), Decl(objectTypeWithStringNamedNumericProperty.ts, 47, 3), Decl(objectTypeWithStringNamedNumericProperty.ts, 77, 3), Decl(objectTypeWithStringNamedNumericProperty.ts, 107, 3)) - >c : Symbol(c, Decl(objectTypeWithStringNamedNumericProperty.ts, 15, 3)) -->'0.1' : Symbol(C["0.1"], Decl(objectTypeWithStringNamedNumericProperty.ts, 4, 9)) -+>'0.1' : Symbol(C["01"], Decl(objectTypeWithStringNamedNumericProperty.ts, 4, 9)) - - var r2 = c['.1']; - >r2 : Symbol(r2, Decl(objectTypeWithStringNamedNumericProperty.ts, 17, 3), Decl(objectTypeWithStringNamedNumericProperty.ts, 48, 3), Decl(objectTypeWithStringNamedNumericProperty.ts, 78, 3), Decl(objectTypeWithStringNamedNumericProperty.ts, 108, 3)) - >c : Symbol(c, Decl(objectTypeWithStringNamedNumericProperty.ts, 15, 3)) -->'.1' : Symbol(C[".1"], Decl(objectTypeWithStringNamedNumericProperty.ts, 5, 16)) -+>'.1' : Symbol(C["1"], Decl(objectTypeWithStringNamedNumericProperty.ts, 5, 16)) - - var r3 = c['1']; - >r3 : Symbol(r3, Decl(objectTypeWithStringNamedNumericProperty.ts, 18, 3), Decl(objectTypeWithStringNamedNumericProperty.ts, 19, 3), Decl(objectTypeWithStringNamedNumericProperty.ts, 21, 3), Decl(objectTypeWithStringNamedNumericProperty.ts, 24, 3), Decl(objectTypeWithStringNamedNumericProperty.ts, 49, 3) ... and 11 more) -@@= skipped -20, +20 lines =@@ - var r4 = c['1.']; - >r4 : Symbol(r4, Decl(objectTypeWithStringNamedNumericProperty.ts, 20, 3), Decl(objectTypeWithStringNamedNumericProperty.ts, 51, 3), Decl(objectTypeWithStringNamedNumericProperty.ts, 81, 3), Decl(objectTypeWithStringNamedNumericProperty.ts, 111, 3)) - >c : Symbol(c, Decl(objectTypeWithStringNamedNumericProperty.ts, 15, 3)) -->'1.' : Symbol(C["1."], Decl(objectTypeWithStringNamedNumericProperty.ts, 7, 16)) -+>'1.' : Symbol(C["1"], Decl(objectTypeWithStringNamedNumericProperty.ts, 7, 16)) - - var r3 = c[1.]; // same as indexing by 1 when done numerically - >r3 : Symbol(r3, Decl(objectTypeWithStringNamedNumericProperty.ts, 18, 3), Decl(objectTypeWithStringNamedNumericProperty.ts, 19, 3), Decl(objectTypeWithStringNamedNumericProperty.ts, 21, 3), Decl(objectTypeWithStringNamedNumericProperty.ts, 24, 3), Decl(objectTypeWithStringNamedNumericProperty.ts, 49, 3) ... and 11 more) -@@= skipped -10, +10 lines =@@ - var r5 = c['1..']; - >r5 : Symbol(r5, Decl(objectTypeWithStringNamedNumericProperty.ts, 22, 3), Decl(objectTypeWithStringNamedNumericProperty.ts, 53, 3), Decl(objectTypeWithStringNamedNumericProperty.ts, 83, 3), Decl(objectTypeWithStringNamedNumericProperty.ts, 113, 3)) - >c : Symbol(c, Decl(objectTypeWithStringNamedNumericProperty.ts, 15, 3)) -->'1..' : Symbol(C["1.."], Decl(objectTypeWithStringNamedNumericProperty.ts, 8, 17)) -+>'1..' : Symbol(C["1"], Decl(objectTypeWithStringNamedNumericProperty.ts, 8, 17)) - - var r6 = c['1.0']; - >r6 : Symbol(r6, Decl(objectTypeWithStringNamedNumericProperty.ts, 23, 3), Decl(objectTypeWithStringNamedNumericProperty.ts, 54, 3), Decl(objectTypeWithStringNamedNumericProperty.ts, 84, 3), Decl(objectTypeWithStringNamedNumericProperty.ts, 114, 3)) - >c : Symbol(c, Decl(objectTypeWithStringNamedNumericProperty.ts, 15, 3)) -->'1.0' : Symbol(C["1.0"], Decl(objectTypeWithStringNamedNumericProperty.ts, 9, 19)) -+>'1.0' : Symbol(C["10"], Decl(objectTypeWithStringNamedNumericProperty.ts, 9, 19)) - - var r3 = c[1.0]; // same as indexing by 1 when done numerically - >r3 : Symbol(r3, Decl(objectTypeWithStringNamedNumericProperty.ts, 18, 3), Decl(objectTypeWithStringNamedNumericProperty.ts, 19, 3), Decl(objectTypeWithStringNamedNumericProperty.ts, 21, 3), Decl(objectTypeWithStringNamedNumericProperty.ts, 24, 3), Decl(objectTypeWithStringNamedNumericProperty.ts, 49, 3) ... and 11 more) -@@= skipped -24, +24 lines =@@ - var r8 = i["-1.0"]; - >r8 : Symbol(r8, Decl(objectTypeWithStringNamedNumericProperty.ts, 28, 3), Decl(objectTypeWithStringNamedNumericProperty.ts, 59, 3), Decl(objectTypeWithStringNamedNumericProperty.ts, 89, 3), Decl(objectTypeWithStringNamedNumericProperty.ts, 119, 3)) - >i : Symbol(i, Decl(objectTypeWithStringNamedNumericProperty.ts, 46, 3)) -->"-1.0" : Symbol(I["-1.0"], Decl(objectTypeWithStringNamedNumericProperty.ts, 41, 16)) -+>"-1.0" : Symbol(I["-10"], Decl(objectTypeWithStringNamedNumericProperty.ts, 41, 16)) - - var r9 = i["-1"]; - >r9 : Symbol(r9, Decl(objectTypeWithStringNamedNumericProperty.ts, 29, 3), Decl(objectTypeWithStringNamedNumericProperty.ts, 60, 3), Decl(objectTypeWithStringNamedNumericProperty.ts, 90, 3), Decl(objectTypeWithStringNamedNumericProperty.ts, 120, 3)) -@@= skipped -29, +29 lines =@@ - >I : Symbol(I, Decl(objectTypeWithStringNamedNumericProperty.ts, 33, 16)) - - "0.1": void; -->"0.1" : Symbol(I["0.1"], Decl(objectTypeWithStringNamedNumericProperty.ts, 35, 13)) -+>"0.1" : Symbol(I["01"], Decl(objectTypeWithStringNamedNumericProperty.ts, 35, 13)) - - ".1": Object; -->".1" : Symbol(I[".1"], Decl(objectTypeWithStringNamedNumericProperty.ts, 36, 16)) -+>".1" : Symbol(I["1"], Decl(objectTypeWithStringNamedNumericProperty.ts, 36, 16)) - >Object : Symbol(Object, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) - - "1": number; - >"1" : Symbol(I["1"], Decl(objectTypeWithStringNamedNumericProperty.ts, 37, 17)) - - "1.": string; -->"1." : Symbol(I["1."], Decl(objectTypeWithStringNamedNumericProperty.ts, 38, 16)) -+>"1." : Symbol(I["1"], Decl(objectTypeWithStringNamedNumericProperty.ts, 38, 16)) - - "1..": boolean; -->"1.." : Symbol(I["1.."], Decl(objectTypeWithStringNamedNumericProperty.ts, 39, 17)) -+>"1.." : Symbol(I["1"], Decl(objectTypeWithStringNamedNumericProperty.ts, 39, 17)) - - "1.0": Date; -->"1.0" : Symbol(I["1.0"], Decl(objectTypeWithStringNamedNumericProperty.ts, 40, 19)) -+>"1.0" : Symbol(I["10"], Decl(objectTypeWithStringNamedNumericProperty.ts, 40, 19)) - >Date : Symbol(Date, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.scripthost.d.ts, --, --)) - - "-1.0": RegExp; -->"-1.0" : Symbol(I["-1.0"], Decl(objectTypeWithStringNamedNumericProperty.ts, 41, 16)) -+>"-1.0" : Symbol(I["-10"], Decl(objectTypeWithStringNamedNumericProperty.ts, 41, 16)) - >RegExp : Symbol(RegExp, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) - - "-1": Date; -@@= skipped -35, +35 lines =@@ - var r1 = i['0.1']; - >r1 : Symbol(r1, Decl(objectTypeWithStringNamedNumericProperty.ts, 16, 3), Decl(objectTypeWithStringNamedNumericProperty.ts, 47, 3), Decl(objectTypeWithStringNamedNumericProperty.ts, 77, 3), Decl(objectTypeWithStringNamedNumericProperty.ts, 107, 3)) - >i : Symbol(i, Decl(objectTypeWithStringNamedNumericProperty.ts, 46, 3)) -->'0.1' : Symbol(I["0.1"], Decl(objectTypeWithStringNamedNumericProperty.ts, 35, 13)) -+>'0.1' : Symbol(I["01"], Decl(objectTypeWithStringNamedNumericProperty.ts, 35, 13)) - - var r2 = i['.1']; - >r2 : Symbol(r2, Decl(objectTypeWithStringNamedNumericProperty.ts, 17, 3), Decl(objectTypeWithStringNamedNumericProperty.ts, 48, 3), Decl(objectTypeWithStringNamedNumericProperty.ts, 78, 3), Decl(objectTypeWithStringNamedNumericProperty.ts, 108, 3)) - >i : Symbol(i, Decl(objectTypeWithStringNamedNumericProperty.ts, 46, 3)) -->'.1' : Symbol(I[".1"], Decl(objectTypeWithStringNamedNumericProperty.ts, 36, 16)) -+>'.1' : Symbol(I["1"], Decl(objectTypeWithStringNamedNumericProperty.ts, 36, 16)) - - var r3 = i['1']; - >r3 : Symbol(r3, Decl(objectTypeWithStringNamedNumericProperty.ts, 18, 3), Decl(objectTypeWithStringNamedNumericProperty.ts, 19, 3), Decl(objectTypeWithStringNamedNumericProperty.ts, 21, 3), Decl(objectTypeWithStringNamedNumericProperty.ts, 24, 3), Decl(objectTypeWithStringNamedNumericProperty.ts, 49, 3) ... and 11 more) -@@= skipped -20, +20 lines =@@ - var r4 = i['1.']; - >r4 : Symbol(r4, Decl(objectTypeWithStringNamedNumericProperty.ts, 20, 3), Decl(objectTypeWithStringNamedNumericProperty.ts, 51, 3), Decl(objectTypeWithStringNamedNumericProperty.ts, 81, 3), Decl(objectTypeWithStringNamedNumericProperty.ts, 111, 3)) - >i : Symbol(i, Decl(objectTypeWithStringNamedNumericProperty.ts, 46, 3)) -->'1.' : Symbol(I["1."], Decl(objectTypeWithStringNamedNumericProperty.ts, 38, 16)) -+>'1.' : Symbol(I["1"], Decl(objectTypeWithStringNamedNumericProperty.ts, 38, 16)) - - var r3 = c[1.]; // same as indexing by 1 when done numerically - >r3 : Symbol(r3, Decl(objectTypeWithStringNamedNumericProperty.ts, 18, 3), Decl(objectTypeWithStringNamedNumericProperty.ts, 19, 3), Decl(objectTypeWithStringNamedNumericProperty.ts, 21, 3), Decl(objectTypeWithStringNamedNumericProperty.ts, 24, 3), Decl(objectTypeWithStringNamedNumericProperty.ts, 49, 3) ... and 11 more) -@@= skipped -10, +10 lines =@@ - var r5 = i['1..']; - >r5 : Symbol(r5, Decl(objectTypeWithStringNamedNumericProperty.ts, 22, 3), Decl(objectTypeWithStringNamedNumericProperty.ts, 53, 3), Decl(objectTypeWithStringNamedNumericProperty.ts, 83, 3), Decl(objectTypeWithStringNamedNumericProperty.ts, 113, 3)) - >i : Symbol(i, Decl(objectTypeWithStringNamedNumericProperty.ts, 46, 3)) -->'1..' : Symbol(I["1.."], Decl(objectTypeWithStringNamedNumericProperty.ts, 39, 17)) -+>'1..' : Symbol(I["1"], Decl(objectTypeWithStringNamedNumericProperty.ts, 39, 17)) - - var r6 = i['1.0']; - >r6 : Symbol(r6, Decl(objectTypeWithStringNamedNumericProperty.ts, 23, 3), Decl(objectTypeWithStringNamedNumericProperty.ts, 54, 3), Decl(objectTypeWithStringNamedNumericProperty.ts, 84, 3), Decl(objectTypeWithStringNamedNumericProperty.ts, 114, 3)) - >i : Symbol(i, Decl(objectTypeWithStringNamedNumericProperty.ts, 46, 3)) -->'1.0' : Symbol(I["1.0"], Decl(objectTypeWithStringNamedNumericProperty.ts, 40, 19)) -+>'1.0' : Symbol(I["10"], Decl(objectTypeWithStringNamedNumericProperty.ts, 40, 19)) - - var r3 = c[1.0]; // same as indexing by 1 when done numerically - >r3 : Symbol(r3, Decl(objectTypeWithStringNamedNumericProperty.ts, 18, 3), Decl(objectTypeWithStringNamedNumericProperty.ts, 19, 3), Decl(objectTypeWithStringNamedNumericProperty.ts, 21, 3), Decl(objectTypeWithStringNamedNumericProperty.ts, 24, 3), Decl(objectTypeWithStringNamedNumericProperty.ts, 49, 3) ... and 11 more) -@@= skipped -24, +24 lines =@@ - var r8 = i["-1.0"]; - >r8 : Symbol(r8, Decl(objectTypeWithStringNamedNumericProperty.ts, 28, 3), Decl(objectTypeWithStringNamedNumericProperty.ts, 59, 3), Decl(objectTypeWithStringNamedNumericProperty.ts, 89, 3), Decl(objectTypeWithStringNamedNumericProperty.ts, 119, 3)) - >i : Symbol(i, Decl(objectTypeWithStringNamedNumericProperty.ts, 46, 3)) -->"-1.0" : Symbol(I["-1.0"], Decl(objectTypeWithStringNamedNumericProperty.ts, 41, 16)) -+>"-1.0" : Symbol(I["-10"], Decl(objectTypeWithStringNamedNumericProperty.ts, 41, 16)) - - var r9 = i["-1"]; - >r9 : Symbol(r9, Decl(objectTypeWithStringNamedNumericProperty.ts, 29, 3), Decl(objectTypeWithStringNamedNumericProperty.ts, 60, 3), Decl(objectTypeWithStringNamedNumericProperty.ts, 90, 3), Decl(objectTypeWithStringNamedNumericProperty.ts, 120, 3)) -@@= skipped -114, +114 lines =@@ - var r8 = i["-1.0"]; - >r8 : Symbol(r8, Decl(objectTypeWithStringNamedNumericProperty.ts, 28, 3), Decl(objectTypeWithStringNamedNumericProperty.ts, 59, 3), Decl(objectTypeWithStringNamedNumericProperty.ts, 89, 3), Decl(objectTypeWithStringNamedNumericProperty.ts, 119, 3)) - >i : Symbol(i, Decl(objectTypeWithStringNamedNumericProperty.ts, 46, 3)) -->"-1.0" : Symbol(I["-1.0"], Decl(objectTypeWithStringNamedNumericProperty.ts, 41, 16)) -+>"-1.0" : Symbol(I["-10"], Decl(objectTypeWithStringNamedNumericProperty.ts, 41, 16)) - - var r9 = i["-1"]; - >r9 : Symbol(r9, Decl(objectTypeWithStringNamedNumericProperty.ts, 29, 3), Decl(objectTypeWithStringNamedNumericProperty.ts, 60, 3), Decl(objectTypeWithStringNamedNumericProperty.ts, 90, 3), Decl(objectTypeWithStringNamedNumericProperty.ts, 120, 3)) -@@= skipped -114, +114 lines =@@ - var r8 = i["-1.0"]; - >r8 : Symbol(r8, Decl(objectTypeWithStringNamedNumericProperty.ts, 28, 3), Decl(objectTypeWithStringNamedNumericProperty.ts, 59, 3), Decl(objectTypeWithStringNamedNumericProperty.ts, 89, 3), Decl(objectTypeWithStringNamedNumericProperty.ts, 119, 3)) - >i : Symbol(i, Decl(objectTypeWithStringNamedNumericProperty.ts, 46, 3)) -->"-1.0" : Symbol(I["-1.0"], Decl(objectTypeWithStringNamedNumericProperty.ts, 41, 16)) -+>"-1.0" : Symbol(I["-10"], Decl(objectTypeWithStringNamedNumericProperty.ts, 41, 16)) - - var r9 = i["-1"]; - >r9 : Symbol(r9, Decl(objectTypeWithStringNamedNumericProperty.ts, 29, 3), Decl(objectTypeWithStringNamedNumericProperty.ts, 60, 3), Decl(objectTypeWithStringNamedNumericProperty.ts, 90, 3), Decl(objectTypeWithStringNamedNumericProperty.ts, 120, 3)) \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/objectTypeWithStringNamedPropertyOfIllegalCharacters.symbols b/testdata/baselines/reference/submodule/conformance/objectTypeWithStringNamedPropertyOfIllegalCharacters.symbols index 4f8b53bab..5d202948d 100644 --- a/testdata/baselines/reference/submodule/conformance/objectTypeWithStringNamedPropertyOfIllegalCharacters.symbols +++ b/testdata/baselines/reference/submodule/conformance/objectTypeWithStringNamedPropertyOfIllegalCharacters.symbols @@ -11,10 +11,10 @@ class C { >"a b" : Symbol(C["a b"], Decl(objectTypeWithStringNamedPropertyOfIllegalCharacters.ts, 1, 18)) "~!@#$%^&*()_+{}|:'<>?\/.,`": number; ->"~!@#$%^&*()_+{}|:'<>?\/.,`" : Symbol(C["~!@#$%^&*()_+{}|:'<>?\\/,`"], Decl(objectTypeWithStringNamedPropertyOfIllegalCharacters.ts, 2, 20)) +>"~!@#$%^&*()_+{}|:'<>?\/.,`" : Symbol(C["~!@#$%^&*()_+{}|:'<>?/.,`"], Decl(objectTypeWithStringNamedPropertyOfIllegalCharacters.ts, 2, 20)) "a\a": number; ->"a\a" : Symbol(C["a\\a"], Decl(objectTypeWithStringNamedPropertyOfIllegalCharacters.ts, 3, 41)) +>"a\a" : Symbol(C["aa"], Decl(objectTypeWithStringNamedPropertyOfIllegalCharacters.ts, 3, 41)) static "a ": number >"a " : Symbol(C["a "], Decl(objectTypeWithStringNamedPropertyOfIllegalCharacters.ts, 4, 18)) @@ -42,7 +42,7 @@ var r3 = c["a b"]; var r4 = c["~!@#$%^&*()_+{}|:'<>?\/.,`"]; >r4 : Symbol(r4, Decl(objectTypeWithStringNamedPropertyOfIllegalCharacters.ts, 13, 3), Decl(objectTypeWithStringNamedPropertyOfIllegalCharacters.ts, 26, 3), Decl(objectTypeWithStringNamedPropertyOfIllegalCharacters.ts, 39, 3), Decl(objectTypeWithStringNamedPropertyOfIllegalCharacters.ts, 51, 3)) >c : Symbol(c, Decl(objectTypeWithStringNamedPropertyOfIllegalCharacters.ts, 8, 3)) ->"~!@#$%^&*()_+{}|:'<>?\/.,`" : Symbol(C["~!@#$%^&*()_+{}|:'<>?\\/,`"], Decl(objectTypeWithStringNamedPropertyOfIllegalCharacters.ts, 2, 20)) +>"~!@#$%^&*()_+{}|:'<>?\/.,`" : Symbol(C["~!@#$%^&*()_+{}|:'<>?/.,`"], Decl(objectTypeWithStringNamedPropertyOfIllegalCharacters.ts, 2, 20)) interface I { >I : Symbol(I, Decl(objectTypeWithStringNamedPropertyOfIllegalCharacters.ts, 13, 41)) @@ -54,7 +54,7 @@ interface I { >"a b" : Symbol(I["a b"], Decl(objectTypeWithStringNamedPropertyOfIllegalCharacters.ts, 16, 18)) "~!@#$%^&*()_+{}|:'<>?\/.,`": number; ->"~!@#$%^&*()_+{}|:'<>?\/.,`" : Symbol(I["~!@#$%^&*()_+{}|:'<>?\\/,`"], Decl(objectTypeWithStringNamedPropertyOfIllegalCharacters.ts, 17, 20)) +>"~!@#$%^&*()_+{}|:'<>?\/.,`" : Symbol(I["~!@#$%^&*()_+{}|:'<>?/.,`"], Decl(objectTypeWithStringNamedPropertyOfIllegalCharacters.ts, 17, 20)) } var i: I; @@ -79,7 +79,7 @@ var r3 = i["a b"]; var r4 = i["~!@#$%^&*()_+{}|:'<>?\/.,`"]; >r4 : Symbol(r4, Decl(objectTypeWithStringNamedPropertyOfIllegalCharacters.ts, 13, 3), Decl(objectTypeWithStringNamedPropertyOfIllegalCharacters.ts, 26, 3), Decl(objectTypeWithStringNamedPropertyOfIllegalCharacters.ts, 39, 3), Decl(objectTypeWithStringNamedPropertyOfIllegalCharacters.ts, 51, 3)) >i : Symbol(i, Decl(objectTypeWithStringNamedPropertyOfIllegalCharacters.ts, 21, 3)) ->"~!@#$%^&*()_+{}|:'<>?\/.,`" : Symbol(I["~!@#$%^&*()_+{}|:'<>?\\/,`"], Decl(objectTypeWithStringNamedPropertyOfIllegalCharacters.ts, 17, 20)) +>"~!@#$%^&*()_+{}|:'<>?\/.,`" : Symbol(I["~!@#$%^&*()_+{}|:'<>?/.,`"], Decl(objectTypeWithStringNamedPropertyOfIllegalCharacters.ts, 17, 20)) var a: { diff --git a/testdata/baselines/reference/submodule/conformance/objectTypeWithStringNamedPropertyOfIllegalCharacters.symbols.diff b/testdata/baselines/reference/submodule/conformance/objectTypeWithStringNamedPropertyOfIllegalCharacters.symbols.diff deleted file mode 100644 index c94e552a7..000000000 --- a/testdata/baselines/reference/submodule/conformance/objectTypeWithStringNamedPropertyOfIllegalCharacters.symbols.diff +++ /dev/null @@ -1,42 +0,0 @@ ---- old.objectTypeWithStringNamedPropertyOfIllegalCharacters.symbols -+++ new.objectTypeWithStringNamedPropertyOfIllegalCharacters.symbols -@@= skipped -10, +10 lines =@@ - >"a b" : Symbol(C["a b"], Decl(objectTypeWithStringNamedPropertyOfIllegalCharacters.ts, 1, 18)) - - "~!@#$%^&*()_+{}|:'<>?\/.,`": number; -->"~!@#$%^&*()_+{}|:'<>?\/.,`" : Symbol(C["~!@#$%^&*()_+{}|:'<>?/.,`"], Decl(objectTypeWithStringNamedPropertyOfIllegalCharacters.ts, 2, 20)) -+>"~!@#$%^&*()_+{}|:'<>?\/.,`" : Symbol(C["~!@#$%^&*()_+{}|:'<>?\\/,`"], Decl(objectTypeWithStringNamedPropertyOfIllegalCharacters.ts, 2, 20)) - - "a\a": number; -->"a\a" : Symbol(C["aa"], Decl(objectTypeWithStringNamedPropertyOfIllegalCharacters.ts, 3, 41)) -+>"a\a" : Symbol(C["a\\a"], Decl(objectTypeWithStringNamedPropertyOfIllegalCharacters.ts, 3, 41)) - - static "a ": number - >"a " : Symbol(C["a "], Decl(objectTypeWithStringNamedPropertyOfIllegalCharacters.ts, 4, 18)) -@@= skipped -31, +31 lines =@@ - var r4 = c["~!@#$%^&*()_+{}|:'<>?\/.,`"]; - >r4 : Symbol(r4, Decl(objectTypeWithStringNamedPropertyOfIllegalCharacters.ts, 13, 3), Decl(objectTypeWithStringNamedPropertyOfIllegalCharacters.ts, 26, 3), Decl(objectTypeWithStringNamedPropertyOfIllegalCharacters.ts, 39, 3), Decl(objectTypeWithStringNamedPropertyOfIllegalCharacters.ts, 51, 3)) - >c : Symbol(c, Decl(objectTypeWithStringNamedPropertyOfIllegalCharacters.ts, 8, 3)) -->"~!@#$%^&*()_+{}|:'<>?\/.,`" : Symbol(C["~!@#$%^&*()_+{}|:'<>?/.,`"], Decl(objectTypeWithStringNamedPropertyOfIllegalCharacters.ts, 2, 20)) -+>"~!@#$%^&*()_+{}|:'<>?\/.,`" : Symbol(C["~!@#$%^&*()_+{}|:'<>?\\/,`"], Decl(objectTypeWithStringNamedPropertyOfIllegalCharacters.ts, 2, 20)) - - interface I { - >I : Symbol(I, Decl(objectTypeWithStringNamedPropertyOfIllegalCharacters.ts, 13, 41)) -@@= skipped -12, +12 lines =@@ - >"a b" : Symbol(I["a b"], Decl(objectTypeWithStringNamedPropertyOfIllegalCharacters.ts, 16, 18)) - - "~!@#$%^&*()_+{}|:'<>?\/.,`": number; -->"~!@#$%^&*()_+{}|:'<>?\/.,`" : Symbol(I["~!@#$%^&*()_+{}|:'<>?/.,`"], Decl(objectTypeWithStringNamedPropertyOfIllegalCharacters.ts, 17, 20)) -+>"~!@#$%^&*()_+{}|:'<>?\/.,`" : Symbol(I["~!@#$%^&*()_+{}|:'<>?\\/,`"], Decl(objectTypeWithStringNamedPropertyOfIllegalCharacters.ts, 17, 20)) - } - - var i: I; -@@= skipped -25, +25 lines =@@ - var r4 = i["~!@#$%^&*()_+{}|:'<>?\/.,`"]; - >r4 : Symbol(r4, Decl(objectTypeWithStringNamedPropertyOfIllegalCharacters.ts, 13, 3), Decl(objectTypeWithStringNamedPropertyOfIllegalCharacters.ts, 26, 3), Decl(objectTypeWithStringNamedPropertyOfIllegalCharacters.ts, 39, 3), Decl(objectTypeWithStringNamedPropertyOfIllegalCharacters.ts, 51, 3)) - >i : Symbol(i, Decl(objectTypeWithStringNamedPropertyOfIllegalCharacters.ts, 21, 3)) -->"~!@#$%^&*()_+{}|:'<>?\/.,`" : Symbol(I["~!@#$%^&*()_+{}|:'<>?/.,`"], Decl(objectTypeWithStringNamedPropertyOfIllegalCharacters.ts, 17, 20)) -+>"~!@#$%^&*()_+{}|:'<>?\/.,`" : Symbol(I["~!@#$%^&*()_+{}|:'<>?\\/,`"], Decl(objectTypeWithStringNamedPropertyOfIllegalCharacters.ts, 17, 20)) - - - var a: { \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/quotedConstructors.symbols b/testdata/baselines/reference/submodule/conformance/quotedConstructors.symbols index bf8c961fc..98349f72c 100644 --- a/testdata/baselines/reference/submodule/conformance/quotedConstructors.symbols +++ b/testdata/baselines/reference/submodule/conformance/quotedConstructors.symbols @@ -29,8 +29,8 @@ class E { >E : Symbol(E, Decl(quotedConstructors.ts, 10, 1)) ['constructor']() { ->['constructor'] : Symbol(E["constructor"], Decl(quotedConstructors.ts, 12, 9)) ->'constructor' : Symbol(E["constructor"], Decl(quotedConstructors.ts, 12, 9)) +>['constructor'] : Symbol(E['constructor'], Decl(quotedConstructors.ts, 12, 9)) +>'constructor' : Symbol(E['constructor'], Decl(quotedConstructors.ts, 12, 9)) console.log(this); >console.log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --)) diff --git a/testdata/baselines/reference/submodule/conformance/quotedConstructors.symbols.diff b/testdata/baselines/reference/submodule/conformance/quotedConstructors.symbols.diff deleted file mode 100644 index 279c23800..000000000 --- a/testdata/baselines/reference/submodule/conformance/quotedConstructors.symbols.diff +++ /dev/null @@ -1,13 +0,0 @@ ---- old.quotedConstructors.symbols -+++ new.quotedConstructors.symbols -@@= skipped -28, +28 lines =@@ - >E : Symbol(E, Decl(quotedConstructors.ts, 10, 1)) - - ['constructor']() { -->['constructor'] : Symbol(E['constructor'], Decl(quotedConstructors.ts, 12, 9)) -->'constructor' : Symbol(E['constructor'], Decl(quotedConstructors.ts, 12, 9)) -+>['constructor'] : Symbol(E["constructor"], Decl(quotedConstructors.ts, 12, 9)) -+>'constructor' : Symbol(E["constructor"], Decl(quotedConstructors.ts, 12, 9)) - - console.log(this); - >console.log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --)) \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/strictPropertyInitialization.symbols b/testdata/baselines/reference/submodule/conformance/strictPropertyInitialization.symbols index a5b7f6407..ef390be51 100644 --- a/testdata/baselines/reference/submodule/conformance/strictPropertyInitialization.symbols +++ b/testdata/baselines/reference/submodule/conformance/strictPropertyInitialization.symbols @@ -332,8 +332,8 @@ class C12 { >b : Symbol(b, Decl(strictPropertyInitialization.ts, 135, 5)) ['c']: number; ->['c'] : Symbol(C12["c"], Decl(strictPropertyInitialization.ts, 139, 16)) ->'c' : Symbol(C12["c"], Decl(strictPropertyInitialization.ts, 139, 16)) +>['c'] : Symbol(C12['c'], Decl(strictPropertyInitialization.ts, 139, 16)) +>'c' : Symbol(C12['c'], Decl(strictPropertyInitialization.ts, 139, 16)) constructor() { this[a] = 1; @@ -346,7 +346,7 @@ class C12 { this['c'] = 1; >this : Symbol(C12, Decl(strictPropertyInitialization.ts, 135, 19)) ->'c' : Symbol(C12["c"], Decl(strictPropertyInitialization.ts, 139, 16)) +>'c' : Symbol(C12['c'], Decl(strictPropertyInitialization.ts, 139, 16)) } } diff --git a/testdata/baselines/reference/submodule/conformance/strictPropertyInitialization.symbols.diff b/testdata/baselines/reference/submodule/conformance/strictPropertyInitialization.symbols.diff deleted file mode 100644 index 443387912..000000000 --- a/testdata/baselines/reference/submodule/conformance/strictPropertyInitialization.symbols.diff +++ /dev/null @@ -1,21 +0,0 @@ ---- old.strictPropertyInitialization.symbols -+++ new.strictPropertyInitialization.symbols -@@= skipped -331, +331 lines =@@ - >b : Symbol(b, Decl(strictPropertyInitialization.ts, 135, 5)) - - ['c']: number; -->['c'] : Symbol(C12['c'], Decl(strictPropertyInitialization.ts, 139, 16)) -->'c' : Symbol(C12['c'], Decl(strictPropertyInitialization.ts, 139, 16)) -+>['c'] : Symbol(C12["c"], Decl(strictPropertyInitialization.ts, 139, 16)) -+>'c' : Symbol(C12["c"], Decl(strictPropertyInitialization.ts, 139, 16)) - - constructor() { - this[a] = 1; -@@= skipped -14, +14 lines =@@ - - this['c'] = 1; - >this : Symbol(C12, Decl(strictPropertyInitialization.ts, 135, 19)) -->'c' : Symbol(C12['c'], Decl(strictPropertyInitialization.ts, 139, 16)) -+>'c' : Symbol(C12["c"], Decl(strictPropertyInitialization.ts, 139, 16)) - } - } diff --git a/testdata/baselines/reference/submodule/conformance/stringIndexerConstrainsPropertyDeclarations.symbols b/testdata/baselines/reference/submodule/conformance/stringIndexerConstrainsPropertyDeclarations.symbols index 10f052611..ab9c54873 100644 --- a/testdata/baselines/reference/submodule/conformance/stringIndexerConstrainsPropertyDeclarations.symbols +++ b/testdata/baselines/reference/submodule/conformance/stringIndexerConstrainsPropertyDeclarations.symbols @@ -41,10 +41,10 @@ class C { >2.0 : Symbol(C[2.0], Decl(stringIndexerConstrainsPropertyDeclarations.ts, 16, 16)) "3.0": string; // ok ->"3.0" : Symbol(C["30"], Decl(stringIndexerConstrainsPropertyDeclarations.ts, 17, 16)) +>"3.0" : Symbol(C["3.0"], Decl(stringIndexerConstrainsPropertyDeclarations.ts, 17, 16)) "4.0": number; // error ->"4.0" : Symbol(C["40"], Decl(stringIndexerConstrainsPropertyDeclarations.ts, 18, 18)) +>"4.0" : Symbol(C["4.0"], Decl(stringIndexerConstrainsPropertyDeclarations.ts, 18, 18)) f: MyString; // error >f : Symbol(C.f, Decl(stringIndexerConstrainsPropertyDeclarations.ts, 19, 18)) @@ -116,10 +116,10 @@ interface I { >foo : Symbol(I.foo, Decl(stringIndexerConstrainsPropertyDeclarations.ts, 51, 15)) "3.0": string; // ok ->"3.0" : Symbol(I["30"], Decl(stringIndexerConstrainsPropertyDeclarations.ts, 52, 18)) +>"3.0" : Symbol(I["3.0"], Decl(stringIndexerConstrainsPropertyDeclarations.ts, 52, 18)) "4.0": number; // error ->"4.0" : Symbol(I["40"], Decl(stringIndexerConstrainsPropertyDeclarations.ts, 53, 18)) +>"4.0" : Symbol(I["4.0"], Decl(stringIndexerConstrainsPropertyDeclarations.ts, 53, 18)) f: MyString; // error >f : Symbol(I.f, Decl(stringIndexerConstrainsPropertyDeclarations.ts, 54, 18)) diff --git a/testdata/baselines/reference/submodule/conformance/stringIndexerConstrainsPropertyDeclarations.symbols.diff b/testdata/baselines/reference/submodule/conformance/stringIndexerConstrainsPropertyDeclarations.symbols.diff deleted file mode 100644 index 04832c795..000000000 --- a/testdata/baselines/reference/submodule/conformance/stringIndexerConstrainsPropertyDeclarations.symbols.diff +++ /dev/null @@ -1,28 +0,0 @@ ---- old.stringIndexerConstrainsPropertyDeclarations.symbols -+++ new.stringIndexerConstrainsPropertyDeclarations.symbols -@@= skipped -40, +40 lines =@@ - >2.0 : Symbol(C[2.0], Decl(stringIndexerConstrainsPropertyDeclarations.ts, 16, 16)) - - "3.0": string; // ok -->"3.0" : Symbol(C["3.0"], Decl(stringIndexerConstrainsPropertyDeclarations.ts, 17, 16)) -+>"3.0" : Symbol(C["30"], Decl(stringIndexerConstrainsPropertyDeclarations.ts, 17, 16)) - - "4.0": number; // error -->"4.0" : Symbol(C["4.0"], Decl(stringIndexerConstrainsPropertyDeclarations.ts, 18, 18)) -+>"4.0" : Symbol(C["40"], Decl(stringIndexerConstrainsPropertyDeclarations.ts, 18, 18)) - - f: MyString; // error - >f : Symbol(C.f, Decl(stringIndexerConstrainsPropertyDeclarations.ts, 19, 18)) -@@= skipped -75, +75 lines =@@ - >foo : Symbol(I.foo, Decl(stringIndexerConstrainsPropertyDeclarations.ts, 51, 15)) - - "3.0": string; // ok -->"3.0" : Symbol(I["3.0"], Decl(stringIndexerConstrainsPropertyDeclarations.ts, 52, 18)) -+>"3.0" : Symbol(I["30"], Decl(stringIndexerConstrainsPropertyDeclarations.ts, 52, 18)) - - "4.0": number; // error -->"4.0" : Symbol(I["4.0"], Decl(stringIndexerConstrainsPropertyDeclarations.ts, 53, 18)) -+>"4.0" : Symbol(I["40"], Decl(stringIndexerConstrainsPropertyDeclarations.ts, 53, 18)) - - f: MyString; // error - >f : Symbol(I.f, Decl(stringIndexerConstrainsPropertyDeclarations.ts, 54, 18)) \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/subtypingWithObjectMembers.symbols b/testdata/baselines/reference/submodule/conformance/subtypingWithObjectMembers.symbols index 6ad354550..96dc0e364 100644 --- a/testdata/baselines/reference/submodule/conformance/subtypingWithObjectMembers.symbols +++ b/testdata/baselines/reference/submodule/conformance/subtypingWithObjectMembers.symbols @@ -69,11 +69,11 @@ class A3 { >A3 : Symbol(A3, Decl(subtypingWithObjectMembers.ts, 24, 1)) '1': Base; ->'1' : Symbol(A3["1"], Decl(subtypingWithObjectMembers.ts, 26, 10)) +>'1' : Symbol(A3['1'], Decl(subtypingWithObjectMembers.ts, 26, 10)) >Base : Symbol(Base, Decl(subtypingWithObjectMembers.ts, 0, 0)) '2.0': Base; ->'2.0' : Symbol(A3["20"], Decl(subtypingWithObjectMembers.ts, 27, 14)) +>'2.0' : Symbol(A3['2.0'], Decl(subtypingWithObjectMembers.ts, 27, 14)) >Base : Symbol(Base, Decl(subtypingWithObjectMembers.ts, 0, 0)) } @@ -82,11 +82,11 @@ class B3 extends A3 { >A3 : Symbol(A3, Decl(subtypingWithObjectMembers.ts, 24, 1)) '1': Derived; // ok ->'1' : Symbol(B3["1"], Decl(subtypingWithObjectMembers.ts, 31, 21)) +>'1' : Symbol(B3['1'], Decl(subtypingWithObjectMembers.ts, 31, 21)) >Derived : Symbol(Derived, Decl(subtypingWithObjectMembers.ts, 0, 27)) '2.0': string; // error ->'2.0' : Symbol(B3["20"], Decl(subtypingWithObjectMembers.ts, 32, 17)) +>'2.0' : Symbol(B3['2.0'], Decl(subtypingWithObjectMembers.ts, 32, 17)) } module TwoLevels { @@ -144,11 +144,11 @@ module TwoLevels { >A3 : Symbol(A3, Decl(subtypingWithObjectMembers.ts, 55, 5)) '1': Base; ->'1' : Symbol(A3["1"], Decl(subtypingWithObjectMembers.ts, 57, 14)) +>'1' : Symbol(A3['1'], Decl(subtypingWithObjectMembers.ts, 57, 14)) >Base : Symbol(Base, Decl(subtypingWithObjectMembers.ts, 0, 0)) '2.0': Base; ->'2.0' : Symbol(A3["20"], Decl(subtypingWithObjectMembers.ts, 58, 18)) +>'2.0' : Symbol(A3['2.0'], Decl(subtypingWithObjectMembers.ts, 58, 18)) >Base : Symbol(Base, Decl(subtypingWithObjectMembers.ts, 0, 0)) } @@ -157,10 +157,10 @@ module TwoLevels { >A3 : Symbol(A3, Decl(subtypingWithObjectMembers.ts, 55, 5)) '1': Derived2; // ok ->'1' : Symbol(B3["1"], Decl(subtypingWithObjectMembers.ts, 62, 25)) +>'1' : Symbol(B3['1'], Decl(subtypingWithObjectMembers.ts, 62, 25)) >Derived2 : Symbol(Derived2, Decl(subtypingWithObjectMembers.ts, 1, 43)) '2.0': string; // error ->'2.0' : Symbol(B3["20"], Decl(subtypingWithObjectMembers.ts, 63, 22)) +>'2.0' : Symbol(B3['2.0'], Decl(subtypingWithObjectMembers.ts, 63, 22)) } } diff --git a/testdata/baselines/reference/submodule/conformance/subtypingWithObjectMembers.symbols.diff b/testdata/baselines/reference/submodule/conformance/subtypingWithObjectMembers.symbols.diff deleted file mode 100644 index 28215cd52..000000000 --- a/testdata/baselines/reference/submodule/conformance/subtypingWithObjectMembers.symbols.diff +++ /dev/null @@ -1,57 +0,0 @@ ---- old.subtypingWithObjectMembers.symbols -+++ new.subtypingWithObjectMembers.symbols -@@= skipped -68, +68 lines =@@ - >A3 : Symbol(A3, Decl(subtypingWithObjectMembers.ts, 24, 1)) - - '1': Base; -->'1' : Symbol(A3['1'], Decl(subtypingWithObjectMembers.ts, 26, 10)) -+>'1' : Symbol(A3["1"], Decl(subtypingWithObjectMembers.ts, 26, 10)) - >Base : Symbol(Base, Decl(subtypingWithObjectMembers.ts, 0, 0)) - - '2.0': Base; -->'2.0' : Symbol(A3['2.0'], Decl(subtypingWithObjectMembers.ts, 27, 14)) -+>'2.0' : Symbol(A3["20"], Decl(subtypingWithObjectMembers.ts, 27, 14)) - >Base : Symbol(Base, Decl(subtypingWithObjectMembers.ts, 0, 0)) - } - -@@= skipped -13, +13 lines =@@ - >A3 : Symbol(A3, Decl(subtypingWithObjectMembers.ts, 24, 1)) - - '1': Derived; // ok -->'1' : Symbol(B3['1'], Decl(subtypingWithObjectMembers.ts, 31, 21)) -+>'1' : Symbol(B3["1"], Decl(subtypingWithObjectMembers.ts, 31, 21)) - >Derived : Symbol(Derived, Decl(subtypingWithObjectMembers.ts, 0, 27)) - - '2.0': string; // error -->'2.0' : Symbol(B3['2.0'], Decl(subtypingWithObjectMembers.ts, 32, 17)) -+>'2.0' : Symbol(B3["20"], Decl(subtypingWithObjectMembers.ts, 32, 17)) - } - - module TwoLevels { -@@= skipped -62, +62 lines =@@ - >A3 : Symbol(A3, Decl(subtypingWithObjectMembers.ts, 55, 5)) - - '1': Base; -->'1' : Symbol(A3['1'], Decl(subtypingWithObjectMembers.ts, 57, 14)) -+>'1' : Symbol(A3["1"], Decl(subtypingWithObjectMembers.ts, 57, 14)) - >Base : Symbol(Base, Decl(subtypingWithObjectMembers.ts, 0, 0)) - - '2.0': Base; -->'2.0' : Symbol(A3['2.0'], Decl(subtypingWithObjectMembers.ts, 58, 18)) -+>'2.0' : Symbol(A3["20"], Decl(subtypingWithObjectMembers.ts, 58, 18)) - >Base : Symbol(Base, Decl(subtypingWithObjectMembers.ts, 0, 0)) - } - -@@= skipped -13, +13 lines =@@ - >A3 : Symbol(A3, Decl(subtypingWithObjectMembers.ts, 55, 5)) - - '1': Derived2; // ok -->'1' : Symbol(B3['1'], Decl(subtypingWithObjectMembers.ts, 62, 25)) -+>'1' : Symbol(B3["1"], Decl(subtypingWithObjectMembers.ts, 62, 25)) - >Derived2 : Symbol(Derived2, Decl(subtypingWithObjectMembers.ts, 1, 43)) - - '2.0': string; // error -->'2.0' : Symbol(B3['2.0'], Decl(subtypingWithObjectMembers.ts, 63, 22)) -+>'2.0' : Symbol(B3["20"], Decl(subtypingWithObjectMembers.ts, 63, 22)) - } - } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/subtypingWithObjectMembers2.symbols b/testdata/baselines/reference/submodule/conformance/subtypingWithObjectMembers2.symbols index 62bb13f86..e2c919be8 100644 --- a/testdata/baselines/reference/submodule/conformance/subtypingWithObjectMembers2.symbols +++ b/testdata/baselines/reference/submodule/conformance/subtypingWithObjectMembers2.symbols @@ -73,11 +73,11 @@ module NotOptional { >A3 : Symbol(A3, Decl(subtypingWithObjectMembers2.ts, 29, 5)) '1': Base; ->'1' : Symbol(A3["1"], Decl(subtypingWithObjectMembers2.ts, 31, 18)) +>'1' : Symbol(A3['1'], Decl(subtypingWithObjectMembers2.ts, 31, 18)) >Base : Symbol(Base, Decl(subtypingWithObjectMembers2.ts, 0, 0)) '2.0': Base; ->'2.0' : Symbol(A3["20"], Decl(subtypingWithObjectMembers2.ts, 32, 18)) +>'2.0' : Symbol(A3['2.0'], Decl(subtypingWithObjectMembers2.ts, 32, 18)) >Base : Symbol(Base, Decl(subtypingWithObjectMembers2.ts, 0, 0)) } @@ -86,11 +86,11 @@ module NotOptional { >A3 : Symbol(A3, Decl(subtypingWithObjectMembers2.ts, 29, 5)) '1': Derived; // ok ->'1' : Symbol(B3["1"], Decl(subtypingWithObjectMembers2.ts, 36, 29)) +>'1' : Symbol(B3['1'], Decl(subtypingWithObjectMembers2.ts, 36, 29)) >Derived : Symbol(Derived, Decl(subtypingWithObjectMembers2.ts, 2, 1)) '2.0': string; // error ->'2.0' : Symbol(B3["20"], Decl(subtypingWithObjectMembers2.ts, 37, 21)) +>'2.0' : Symbol(B3['2.0'], Decl(subtypingWithObjectMembers2.ts, 37, 21)) } } @@ -150,11 +150,11 @@ module Optional { >A3 : Symbol(A3, Decl(subtypingWithObjectMembers2.ts, 62, 5)) '1'?: Base; ->'1' : Symbol(A3["1"], Decl(subtypingWithObjectMembers2.ts, 64, 18)) +>'1' : Symbol(A3['1'], Decl(subtypingWithObjectMembers2.ts, 64, 18)) >Base : Symbol(Base, Decl(subtypingWithObjectMembers2.ts, 0, 0)) '2.0'?: Base; ->'2.0' : Symbol(A3["20"], Decl(subtypingWithObjectMembers2.ts, 65, 19)) +>'2.0' : Symbol(A3['2.0'], Decl(subtypingWithObjectMembers2.ts, 65, 19)) >Base : Symbol(Base, Decl(subtypingWithObjectMembers2.ts, 0, 0)) } @@ -163,10 +163,10 @@ module Optional { >A3 : Symbol(A3, Decl(subtypingWithObjectMembers2.ts, 62, 5)) '1'?: Derived; // ok ->'1' : Symbol(B3["1"], Decl(subtypingWithObjectMembers2.ts, 69, 29)) +>'1' : Symbol(B3['1'], Decl(subtypingWithObjectMembers2.ts, 69, 29)) >Derived : Symbol(Derived, Decl(subtypingWithObjectMembers2.ts, 2, 1)) '2.0'?: string; // error ->'2.0' : Symbol(B3["20"], Decl(subtypingWithObjectMembers2.ts, 70, 22)) +>'2.0' : Symbol(B3['2.0'], Decl(subtypingWithObjectMembers2.ts, 70, 22)) } } diff --git a/testdata/baselines/reference/submodule/conformance/subtypingWithObjectMembers2.symbols.diff b/testdata/baselines/reference/submodule/conformance/subtypingWithObjectMembers2.symbols.diff deleted file mode 100644 index 46d2d03e6..000000000 --- a/testdata/baselines/reference/submodule/conformance/subtypingWithObjectMembers2.symbols.diff +++ /dev/null @@ -1,57 +0,0 @@ ---- old.subtypingWithObjectMembers2.symbols -+++ new.subtypingWithObjectMembers2.symbols -@@= skipped -72, +72 lines =@@ - >A3 : Symbol(A3, Decl(subtypingWithObjectMembers2.ts, 29, 5)) - - '1': Base; -->'1' : Symbol(A3['1'], Decl(subtypingWithObjectMembers2.ts, 31, 18)) -+>'1' : Symbol(A3["1"], Decl(subtypingWithObjectMembers2.ts, 31, 18)) - >Base : Symbol(Base, Decl(subtypingWithObjectMembers2.ts, 0, 0)) - - '2.0': Base; -->'2.0' : Symbol(A3['2.0'], Decl(subtypingWithObjectMembers2.ts, 32, 18)) -+>'2.0' : Symbol(A3["20"], Decl(subtypingWithObjectMembers2.ts, 32, 18)) - >Base : Symbol(Base, Decl(subtypingWithObjectMembers2.ts, 0, 0)) - } - -@@= skipped -13, +13 lines =@@ - >A3 : Symbol(A3, Decl(subtypingWithObjectMembers2.ts, 29, 5)) - - '1': Derived; // ok -->'1' : Symbol(B3['1'], Decl(subtypingWithObjectMembers2.ts, 36, 29)) -+>'1' : Symbol(B3["1"], Decl(subtypingWithObjectMembers2.ts, 36, 29)) - >Derived : Symbol(Derived, Decl(subtypingWithObjectMembers2.ts, 2, 1)) - - '2.0': string; // error -->'2.0' : Symbol(B3['2.0'], Decl(subtypingWithObjectMembers2.ts, 37, 21)) -+>'2.0' : Symbol(B3["20"], Decl(subtypingWithObjectMembers2.ts, 37, 21)) - } - } - -@@= skipped -64, +64 lines =@@ - >A3 : Symbol(A3, Decl(subtypingWithObjectMembers2.ts, 62, 5)) - - '1'?: Base; -->'1' : Symbol(A3['1'], Decl(subtypingWithObjectMembers2.ts, 64, 18)) -+>'1' : Symbol(A3["1"], Decl(subtypingWithObjectMembers2.ts, 64, 18)) - >Base : Symbol(Base, Decl(subtypingWithObjectMembers2.ts, 0, 0)) - - '2.0'?: Base; -->'2.0' : Symbol(A3['2.0'], Decl(subtypingWithObjectMembers2.ts, 65, 19)) -+>'2.0' : Symbol(A3["20"], Decl(subtypingWithObjectMembers2.ts, 65, 19)) - >Base : Symbol(Base, Decl(subtypingWithObjectMembers2.ts, 0, 0)) - } - -@@= skipped -13, +13 lines =@@ - >A3 : Symbol(A3, Decl(subtypingWithObjectMembers2.ts, 62, 5)) - - '1'?: Derived; // ok -->'1' : Symbol(B3['1'], Decl(subtypingWithObjectMembers2.ts, 69, 29)) -+>'1' : Symbol(B3["1"], Decl(subtypingWithObjectMembers2.ts, 69, 29)) - >Derived : Symbol(Derived, Decl(subtypingWithObjectMembers2.ts, 2, 1)) - - '2.0'?: string; // error -->'2.0' : Symbol(B3['2.0'], Decl(subtypingWithObjectMembers2.ts, 70, 22)) -+>'2.0' : Symbol(B3["20"], Decl(subtypingWithObjectMembers2.ts, 70, 22)) - } - } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/subtypingWithObjectMembers3.symbols b/testdata/baselines/reference/submodule/conformance/subtypingWithObjectMembers3.symbols index 918992714..111dbb361 100644 --- a/testdata/baselines/reference/submodule/conformance/subtypingWithObjectMembers3.symbols +++ b/testdata/baselines/reference/submodule/conformance/subtypingWithObjectMembers3.symbols @@ -75,11 +75,11 @@ module NotOptional { >A3 : Symbol(A3, Decl(subtypingWithObjectMembers3.ts, 29, 5)) '1': Base; ->'1' : Symbol(A3["1"], Decl(subtypingWithObjectMembers3.ts, 31, 18)) +>'1' : Symbol(A3['1'], Decl(subtypingWithObjectMembers3.ts, 31, 18)) >Base : Symbol(Base, Decl(subtypingWithObjectMembers3.ts, 0, 0)) '2.0': Derived; ->'2.0' : Symbol(A3["20"], Decl(subtypingWithObjectMembers3.ts, 32, 18)) +>'2.0' : Symbol(A3['2.0'], Decl(subtypingWithObjectMembers3.ts, 32, 18)) >Derived : Symbol(Derived, Decl(subtypingWithObjectMembers3.ts, 2, 1)) } @@ -88,11 +88,11 @@ module NotOptional { >A3 : Symbol(A3, Decl(subtypingWithObjectMembers3.ts, 29, 5)) '1': Derived; // ok ->'1' : Symbol(B3["1"], Decl(subtypingWithObjectMembers3.ts, 36, 29)) +>'1' : Symbol(B3['1'], Decl(subtypingWithObjectMembers3.ts, 36, 29)) >Derived : Symbol(Derived, Decl(subtypingWithObjectMembers3.ts, 2, 1)) '2.0': Base; // error ->'2.0' : Symbol(B3["20"], Decl(subtypingWithObjectMembers3.ts, 37, 21)) +>'2.0' : Symbol(B3['2.0'], Decl(subtypingWithObjectMembers3.ts, 37, 21)) >Base : Symbol(Base, Decl(subtypingWithObjectMembers3.ts, 0, 0)) } } @@ -154,11 +154,11 @@ module Optional { >A3 : Symbol(A3, Decl(subtypingWithObjectMembers3.ts, 61, 5)) '1'?: Base; ->'1' : Symbol(A3["1"], Decl(subtypingWithObjectMembers3.ts, 63, 18)) +>'1' : Symbol(A3['1'], Decl(subtypingWithObjectMembers3.ts, 63, 18)) >Base : Symbol(Base, Decl(subtypingWithObjectMembers3.ts, 0, 0)) '2.0'?: Derived; ->'2.0' : Symbol(A3["20"], Decl(subtypingWithObjectMembers3.ts, 64, 19)) +>'2.0' : Symbol(A3['2.0'], Decl(subtypingWithObjectMembers3.ts, 64, 19)) >Derived : Symbol(Derived, Decl(subtypingWithObjectMembers3.ts, 2, 1)) } @@ -167,11 +167,11 @@ module Optional { >A3 : Symbol(A3, Decl(subtypingWithObjectMembers3.ts, 61, 5)) '1'?: Derived; // ok ->'1' : Symbol(B3["1"], Decl(subtypingWithObjectMembers3.ts, 68, 29)) +>'1' : Symbol(B3['1'], Decl(subtypingWithObjectMembers3.ts, 68, 29)) >Derived : Symbol(Derived, Decl(subtypingWithObjectMembers3.ts, 2, 1)) '2.0'?: Base; // error ->'2.0' : Symbol(B3["20"], Decl(subtypingWithObjectMembers3.ts, 69, 22)) +>'2.0' : Symbol(B3['2.0'], Decl(subtypingWithObjectMembers3.ts, 69, 22)) >Base : Symbol(Base, Decl(subtypingWithObjectMembers3.ts, 0, 0)) } } diff --git a/testdata/baselines/reference/submodule/conformance/subtypingWithObjectMembers3.symbols.diff b/testdata/baselines/reference/submodule/conformance/subtypingWithObjectMembers3.symbols.diff deleted file mode 100644 index f0d55a895..000000000 --- a/testdata/baselines/reference/submodule/conformance/subtypingWithObjectMembers3.symbols.diff +++ /dev/null @@ -1,58 +0,0 @@ ---- old.subtypingWithObjectMembers3.symbols -+++ new.subtypingWithObjectMembers3.symbols -@@= skipped -74, +74 lines =@@ - >A3 : Symbol(A3, Decl(subtypingWithObjectMembers3.ts, 29, 5)) - - '1': Base; -->'1' : Symbol(A3['1'], Decl(subtypingWithObjectMembers3.ts, 31, 18)) -+>'1' : Symbol(A3["1"], Decl(subtypingWithObjectMembers3.ts, 31, 18)) - >Base : Symbol(Base, Decl(subtypingWithObjectMembers3.ts, 0, 0)) - - '2.0': Derived; -->'2.0' : Symbol(A3['2.0'], Decl(subtypingWithObjectMembers3.ts, 32, 18)) -+>'2.0' : Symbol(A3["20"], Decl(subtypingWithObjectMembers3.ts, 32, 18)) - >Derived : Symbol(Derived, Decl(subtypingWithObjectMembers3.ts, 2, 1)) - } - -@@= skipped -13, +13 lines =@@ - >A3 : Symbol(A3, Decl(subtypingWithObjectMembers3.ts, 29, 5)) - - '1': Derived; // ok -->'1' : Symbol(B3['1'], Decl(subtypingWithObjectMembers3.ts, 36, 29)) -+>'1' : Symbol(B3["1"], Decl(subtypingWithObjectMembers3.ts, 36, 29)) - >Derived : Symbol(Derived, Decl(subtypingWithObjectMembers3.ts, 2, 1)) - - '2.0': Base; // error -->'2.0' : Symbol(B3['2.0'], Decl(subtypingWithObjectMembers3.ts, 37, 21)) -+>'2.0' : Symbol(B3["20"], Decl(subtypingWithObjectMembers3.ts, 37, 21)) - >Base : Symbol(Base, Decl(subtypingWithObjectMembers3.ts, 0, 0)) - } - } -@@= skipped -66, +66 lines =@@ - >A3 : Symbol(A3, Decl(subtypingWithObjectMembers3.ts, 61, 5)) - - '1'?: Base; -->'1' : Symbol(A3['1'], Decl(subtypingWithObjectMembers3.ts, 63, 18)) -+>'1' : Symbol(A3["1"], Decl(subtypingWithObjectMembers3.ts, 63, 18)) - >Base : Symbol(Base, Decl(subtypingWithObjectMembers3.ts, 0, 0)) - - '2.0'?: Derived; -->'2.0' : Symbol(A3['2.0'], Decl(subtypingWithObjectMembers3.ts, 64, 19)) -+>'2.0' : Symbol(A3["20"], Decl(subtypingWithObjectMembers3.ts, 64, 19)) - >Derived : Symbol(Derived, Decl(subtypingWithObjectMembers3.ts, 2, 1)) - } - -@@= skipped -13, +13 lines =@@ - >A3 : Symbol(A3, Decl(subtypingWithObjectMembers3.ts, 61, 5)) - - '1'?: Derived; // ok -->'1' : Symbol(B3['1'], Decl(subtypingWithObjectMembers3.ts, 68, 29)) -+>'1' : Symbol(B3["1"], Decl(subtypingWithObjectMembers3.ts, 68, 29)) - >Derived : Symbol(Derived, Decl(subtypingWithObjectMembers3.ts, 2, 1)) - - '2.0'?: Base; // error -->'2.0' : Symbol(B3['2.0'], Decl(subtypingWithObjectMembers3.ts, 69, 22)) -+>'2.0' : Symbol(B3["20"], Decl(subtypingWithObjectMembers3.ts, 69, 22)) - >Base : Symbol(Base, Decl(subtypingWithObjectMembers3.ts, 0, 0)) - } - } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/subtypingWithObjectMembers4.symbols b/testdata/baselines/reference/submodule/conformance/subtypingWithObjectMembers4.symbols index f896eeb1d..b7c065163 100644 --- a/testdata/baselines/reference/submodule/conformance/subtypingWithObjectMembers4.symbols +++ b/testdata/baselines/reference/submodule/conformance/subtypingWithObjectMembers4.symbols @@ -56,7 +56,7 @@ class A3 { >A3 : Symbol(A3, Decl(subtypingWithObjectMembers4.ts, 24, 1)) '1': Base; ->'1' : Symbol(A3["1"], Decl(subtypingWithObjectMembers4.ts, 26, 10)) +>'1' : Symbol(A3['1'], Decl(subtypingWithObjectMembers4.ts, 26, 10)) >Base : Symbol(Base, Decl(subtypingWithObjectMembers4.ts, 0, 0)) } @@ -65,6 +65,6 @@ class B3 extends A3 { >A3 : Symbol(A3, Decl(subtypingWithObjectMembers4.ts, 24, 1)) '1.1': Derived; // ok, inherits '1' ->'1.1' : Symbol(B3["11"], Decl(subtypingWithObjectMembers4.ts, 30, 21)) +>'1.1' : Symbol(B3['1.1'], Decl(subtypingWithObjectMembers4.ts, 30, 21)) >Derived : Symbol(Derived, Decl(subtypingWithObjectMembers4.ts, 4, 1)) } diff --git a/testdata/baselines/reference/submodule/conformance/subtypingWithObjectMembers4.symbols.diff b/testdata/baselines/reference/submodule/conformance/subtypingWithObjectMembers4.symbols.diff deleted file mode 100644 index a40acb884..000000000 --- a/testdata/baselines/reference/submodule/conformance/subtypingWithObjectMembers4.symbols.diff +++ /dev/null @@ -1,19 +0,0 @@ ---- old.subtypingWithObjectMembers4.symbols -+++ new.subtypingWithObjectMembers4.symbols -@@= skipped -55, +55 lines =@@ - >A3 : Symbol(A3, Decl(subtypingWithObjectMembers4.ts, 24, 1)) - - '1': Base; -->'1' : Symbol(A3['1'], Decl(subtypingWithObjectMembers4.ts, 26, 10)) -+>'1' : Symbol(A3["1"], Decl(subtypingWithObjectMembers4.ts, 26, 10)) - >Base : Symbol(Base, Decl(subtypingWithObjectMembers4.ts, 0, 0)) - } - -@@= skipped -9, +9 lines =@@ - >A3 : Symbol(A3, Decl(subtypingWithObjectMembers4.ts, 24, 1)) - - '1.1': Derived; // ok, inherits '1' -->'1.1' : Symbol(B3['1.1'], Decl(subtypingWithObjectMembers4.ts, 30, 21)) -+>'1.1' : Symbol(B3["11"], Decl(subtypingWithObjectMembers4.ts, 30, 21)) - >Derived : Symbol(Derived, Decl(subtypingWithObjectMembers4.ts, 4, 1)) - } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/subtypingWithObjectMembers5.symbols b/testdata/baselines/reference/submodule/conformance/subtypingWithObjectMembers5.symbols index e05eec4fe..b92b99119 100644 --- a/testdata/baselines/reference/submodule/conformance/subtypingWithObjectMembers5.symbols +++ b/testdata/baselines/reference/submodule/conformance/subtypingWithObjectMembers5.symbols @@ -59,7 +59,7 @@ module NotOptional { >A3 : Symbol(A3, Decl(subtypingWithObjectMembers5.ts, 25, 5)) '1': Base; ->'1' : Symbol(A3["1"], Decl(subtypingWithObjectMembers5.ts, 27, 18)) +>'1' : Symbol(A3['1'], Decl(subtypingWithObjectMembers5.ts, 27, 18)) >Base : Symbol(Base, Decl(subtypingWithObjectMembers5.ts, 0, 0)) } @@ -68,7 +68,7 @@ module NotOptional { >A3 : Symbol(A3, Decl(subtypingWithObjectMembers5.ts, 25, 5)) '1.0': Derived; // error ->'1.0' : Symbol(B3["10"], Decl(subtypingWithObjectMembers5.ts, 31, 28)) +>'1.0' : Symbol(B3['1.0'], Decl(subtypingWithObjectMembers5.ts, 31, 28)) >Derived : Symbol(Derived, Decl(subtypingWithObjectMembers5.ts, 2, 1)) } } @@ -115,7 +115,7 @@ module Optional { >A3 : Symbol(A3, Decl(subtypingWithObjectMembers5.ts, 52, 5)) '1'?: Base; ->'1' : Symbol(A3["1"], Decl(subtypingWithObjectMembers5.ts, 54, 18)) +>'1' : Symbol(A3['1'], Decl(subtypingWithObjectMembers5.ts, 54, 18)) >Base : Symbol(Base, Decl(subtypingWithObjectMembers5.ts, 0, 0)) } @@ -124,7 +124,7 @@ module Optional { >A3 : Symbol(A3, Decl(subtypingWithObjectMembers5.ts, 52, 5)) '1.0': Derived; // weak type error ->'1.0' : Symbol(B3["10"], Decl(subtypingWithObjectMembers5.ts, 58, 28)) +>'1.0' : Symbol(B3['1.0'], Decl(subtypingWithObjectMembers5.ts, 58, 28)) >Derived : Symbol(Derived, Decl(subtypingWithObjectMembers5.ts, 2, 1)) } } diff --git a/testdata/baselines/reference/submodule/conformance/subtypingWithObjectMembers5.symbols.diff b/testdata/baselines/reference/submodule/conformance/subtypingWithObjectMembers5.symbols.diff deleted file mode 100644 index a68ce4c68..000000000 --- a/testdata/baselines/reference/submodule/conformance/subtypingWithObjectMembers5.symbols.diff +++ /dev/null @@ -1,38 +0,0 @@ ---- old.subtypingWithObjectMembers5.symbols -+++ new.subtypingWithObjectMembers5.symbols -@@= skipped -58, +58 lines =@@ - >A3 : Symbol(A3, Decl(subtypingWithObjectMembers5.ts, 25, 5)) - - '1': Base; -->'1' : Symbol(A3['1'], Decl(subtypingWithObjectMembers5.ts, 27, 18)) -+>'1' : Symbol(A3["1"], Decl(subtypingWithObjectMembers5.ts, 27, 18)) - >Base : Symbol(Base, Decl(subtypingWithObjectMembers5.ts, 0, 0)) - } - -@@= skipped -9, +9 lines =@@ - >A3 : Symbol(A3, Decl(subtypingWithObjectMembers5.ts, 25, 5)) - - '1.0': Derived; // error -->'1.0' : Symbol(B3['1.0'], Decl(subtypingWithObjectMembers5.ts, 31, 28)) -+>'1.0' : Symbol(B3["10"], Decl(subtypingWithObjectMembers5.ts, 31, 28)) - >Derived : Symbol(Derived, Decl(subtypingWithObjectMembers5.ts, 2, 1)) - } - } -@@= skipped -47, +47 lines =@@ - >A3 : Symbol(A3, Decl(subtypingWithObjectMembers5.ts, 52, 5)) - - '1'?: Base; -->'1' : Symbol(A3['1'], Decl(subtypingWithObjectMembers5.ts, 54, 18)) -+>'1' : Symbol(A3["1"], Decl(subtypingWithObjectMembers5.ts, 54, 18)) - >Base : Symbol(Base, Decl(subtypingWithObjectMembers5.ts, 0, 0)) - } - -@@= skipped -9, +9 lines =@@ - >A3 : Symbol(A3, Decl(subtypingWithObjectMembers5.ts, 52, 5)) - - '1.0': Derived; // weak type error -->'1.0' : Symbol(B3['1.0'], Decl(subtypingWithObjectMembers5.ts, 58, 28)) -+>'1.0' : Symbol(B3["10"], Decl(subtypingWithObjectMembers5.ts, 58, 28)) - >Derived : Symbol(Derived, Decl(subtypingWithObjectMembers5.ts, 2, 1)) - } - } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/subtypingWithObjectMembersAccessibility.symbols b/testdata/baselines/reference/submodule/conformance/subtypingWithObjectMembersAccessibility.symbols index 4954c50da..1d6b0f051 100644 --- a/testdata/baselines/reference/submodule/conformance/subtypingWithObjectMembersAccessibility.symbols +++ b/testdata/baselines/reference/submodule/conformance/subtypingWithObjectMembersAccessibility.symbols @@ -56,7 +56,7 @@ class A3 { >A3 : Symbol(A3, Decl(subtypingWithObjectMembersAccessibility.ts, 24, 1)) public '1': Base; ->'1' : Symbol(A3["1"], Decl(subtypingWithObjectMembersAccessibility.ts, 26, 10)) +>'1' : Symbol(A3['1'], Decl(subtypingWithObjectMembersAccessibility.ts, 26, 10)) >Base : Symbol(Base, Decl(subtypingWithObjectMembersAccessibility.ts, 0, 0)) } @@ -65,6 +65,6 @@ class B3 extends A3 { >A3 : Symbol(A3, Decl(subtypingWithObjectMembersAccessibility.ts, 24, 1)) private '1': Derived; // error ->'1' : Symbol(B3["1"], Decl(subtypingWithObjectMembersAccessibility.ts, 30, 21)) +>'1' : Symbol(B3['1'], Decl(subtypingWithObjectMembersAccessibility.ts, 30, 21)) >Derived : Symbol(Derived, Decl(subtypingWithObjectMembersAccessibility.ts, 4, 1)) } diff --git a/testdata/baselines/reference/submodule/conformance/subtypingWithObjectMembersAccessibility.symbols.diff b/testdata/baselines/reference/submodule/conformance/subtypingWithObjectMembersAccessibility.symbols.diff deleted file mode 100644 index 2b542df55..000000000 --- a/testdata/baselines/reference/submodule/conformance/subtypingWithObjectMembersAccessibility.symbols.diff +++ /dev/null @@ -1,19 +0,0 @@ ---- old.subtypingWithObjectMembersAccessibility.symbols -+++ new.subtypingWithObjectMembersAccessibility.symbols -@@= skipped -55, +55 lines =@@ - >A3 : Symbol(A3, Decl(subtypingWithObjectMembersAccessibility.ts, 24, 1)) - - public '1': Base; -->'1' : Symbol(A3['1'], Decl(subtypingWithObjectMembersAccessibility.ts, 26, 10)) -+>'1' : Symbol(A3["1"], Decl(subtypingWithObjectMembersAccessibility.ts, 26, 10)) - >Base : Symbol(Base, Decl(subtypingWithObjectMembersAccessibility.ts, 0, 0)) - } - -@@= skipped -9, +9 lines =@@ - >A3 : Symbol(A3, Decl(subtypingWithObjectMembersAccessibility.ts, 24, 1)) - - private '1': Derived; // error -->'1' : Symbol(B3['1'], Decl(subtypingWithObjectMembersAccessibility.ts, 30, 21)) -+>'1' : Symbol(B3["1"], Decl(subtypingWithObjectMembersAccessibility.ts, 30, 21)) - >Derived : Symbol(Derived, Decl(subtypingWithObjectMembersAccessibility.ts, 4, 1)) - } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/subtypingWithObjectMembersAccessibility2.symbols b/testdata/baselines/reference/submodule/conformance/subtypingWithObjectMembersAccessibility2.symbols index 2e2f46d2d..a4e2535a9 100644 --- a/testdata/baselines/reference/submodule/conformance/subtypingWithObjectMembersAccessibility2.symbols +++ b/testdata/baselines/reference/submodule/conformance/subtypingWithObjectMembersAccessibility2.symbols @@ -59,7 +59,7 @@ module ExplicitPublic { >A3 : Symbol(A3, Decl(subtypingWithObjectMembersAccessibility2.ts, 25, 5)) private '1': Base; ->'1' : Symbol(A3["1"], Decl(subtypingWithObjectMembersAccessibility2.ts, 27, 14)) +>'1' : Symbol(A3['1'], Decl(subtypingWithObjectMembersAccessibility2.ts, 27, 14)) >Base : Symbol(Base, Decl(subtypingWithObjectMembersAccessibility2.ts, 0, 0)) } @@ -68,7 +68,7 @@ module ExplicitPublic { >A3 : Symbol(A3, Decl(subtypingWithObjectMembersAccessibility2.ts, 25, 5)) public '1': Derived; // error ->'1' : Symbol(B3["1"], Decl(subtypingWithObjectMembersAccessibility2.ts, 31, 25)) +>'1' : Symbol(B3['1'], Decl(subtypingWithObjectMembersAccessibility2.ts, 31, 25)) >Derived : Symbol(Derived, Decl(subtypingWithObjectMembersAccessibility2.ts, 4, 1)) } } @@ -114,7 +114,7 @@ module ImplicitPublic { >A3 : Symbol(A3, Decl(subtypingWithObjectMembersAccessibility2.ts, 51, 5)) private '1': Base; ->'1' : Symbol(A3["1"], Decl(subtypingWithObjectMembersAccessibility2.ts, 53, 14)) +>'1' : Symbol(A3['1'], Decl(subtypingWithObjectMembersAccessibility2.ts, 53, 14)) >Base : Symbol(Base, Decl(subtypingWithObjectMembersAccessibility2.ts, 0, 0)) } @@ -123,7 +123,7 @@ module ImplicitPublic { >A3 : Symbol(A3, Decl(subtypingWithObjectMembersAccessibility2.ts, 51, 5)) '1': Derived; // error ->'1' : Symbol(B3["1"], Decl(subtypingWithObjectMembersAccessibility2.ts, 57, 25)) +>'1' : Symbol(B3['1'], Decl(subtypingWithObjectMembersAccessibility2.ts, 57, 25)) >Derived : Symbol(Derived, Decl(subtypingWithObjectMembersAccessibility2.ts, 4, 1)) } } diff --git a/testdata/baselines/reference/submodule/conformance/subtypingWithObjectMembersAccessibility2.symbols.diff b/testdata/baselines/reference/submodule/conformance/subtypingWithObjectMembersAccessibility2.symbols.diff deleted file mode 100644 index c80c20ae4..000000000 --- a/testdata/baselines/reference/submodule/conformance/subtypingWithObjectMembersAccessibility2.symbols.diff +++ /dev/null @@ -1,38 +0,0 @@ ---- old.subtypingWithObjectMembersAccessibility2.symbols -+++ new.subtypingWithObjectMembersAccessibility2.symbols -@@= skipped -58, +58 lines =@@ - >A3 : Symbol(A3, Decl(subtypingWithObjectMembersAccessibility2.ts, 25, 5)) - - private '1': Base; -->'1' : Symbol(A3['1'], Decl(subtypingWithObjectMembersAccessibility2.ts, 27, 14)) -+>'1' : Symbol(A3["1"], Decl(subtypingWithObjectMembersAccessibility2.ts, 27, 14)) - >Base : Symbol(Base, Decl(subtypingWithObjectMembersAccessibility2.ts, 0, 0)) - } - -@@= skipped -9, +9 lines =@@ - >A3 : Symbol(A3, Decl(subtypingWithObjectMembersAccessibility2.ts, 25, 5)) - - public '1': Derived; // error -->'1' : Symbol(B3['1'], Decl(subtypingWithObjectMembersAccessibility2.ts, 31, 25)) -+>'1' : Symbol(B3["1"], Decl(subtypingWithObjectMembersAccessibility2.ts, 31, 25)) - >Derived : Symbol(Derived, Decl(subtypingWithObjectMembersAccessibility2.ts, 4, 1)) - } - } -@@= skipped -46, +46 lines =@@ - >A3 : Symbol(A3, Decl(subtypingWithObjectMembersAccessibility2.ts, 51, 5)) - - private '1': Base; -->'1' : Symbol(A3['1'], Decl(subtypingWithObjectMembersAccessibility2.ts, 53, 14)) -+>'1' : Symbol(A3["1"], Decl(subtypingWithObjectMembersAccessibility2.ts, 53, 14)) - >Base : Symbol(Base, Decl(subtypingWithObjectMembersAccessibility2.ts, 0, 0)) - } - -@@= skipped -9, +9 lines =@@ - >A3 : Symbol(A3, Decl(subtypingWithObjectMembersAccessibility2.ts, 51, 5)) - - '1': Derived; // error -->'1' : Symbol(B3['1'], Decl(subtypingWithObjectMembersAccessibility2.ts, 57, 25)) -+>'1' : Symbol(B3["1"], Decl(subtypingWithObjectMembersAccessibility2.ts, 57, 25)) - >Derived : Symbol(Derived, Decl(subtypingWithObjectMembersAccessibility2.ts, 4, 1)) - } - } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/subtypingWithObjectMembersOptionality.symbols b/testdata/baselines/reference/submodule/conformance/subtypingWithObjectMembersOptionality.symbols index 07d403d5a..4932f68d5 100644 --- a/testdata/baselines/reference/submodule/conformance/subtypingWithObjectMembersOptionality.symbols +++ b/testdata/baselines/reference/submodule/conformance/subtypingWithObjectMembersOptionality.symbols @@ -63,7 +63,7 @@ interface T3 { >T3 : Symbol(T3, Decl(subtypingWithObjectMembersOptionality.ts, 28, 1)) '1'?: Base; ->'1' : Symbol(T3["1"], Decl(subtypingWithObjectMembersOptionality.ts, 30, 14)) +>'1' : Symbol(T3['1'], Decl(subtypingWithObjectMembersOptionality.ts, 30, 14)) >Base : Symbol(Base, Decl(subtypingWithObjectMembersOptionality.ts, 0, 0)) } @@ -72,7 +72,7 @@ interface S3 extends T3 { >T3 : Symbol(T3, Decl(subtypingWithObjectMembersOptionality.ts, 28, 1)) '1.': Derived; ->'1.' : Symbol(S3["1"], Decl(subtypingWithObjectMembersOptionality.ts, 34, 25)) +>'1.' : Symbol(S3['1.'], Decl(subtypingWithObjectMembersOptionality.ts, 34, 25)) >Derived : Symbol(Derived, Decl(subtypingWithObjectMembersOptionality.ts, 2, 31)) } @@ -133,7 +133,7 @@ module TwoLevels { >T3 : Symbol(T3, Decl(subtypingWithObjectMembersOptionality.ts, 58, 5)) '1'?: Base; ->'1' : Symbol(T3["1"], Decl(subtypingWithObjectMembersOptionality.ts, 60, 18)) +>'1' : Symbol(T3['1'], Decl(subtypingWithObjectMembersOptionality.ts, 60, 18)) >Base : Symbol(Base, Decl(subtypingWithObjectMembersOptionality.ts, 0, 0)) } @@ -142,7 +142,7 @@ module TwoLevels { >T3 : Symbol(T3, Decl(subtypingWithObjectMembersOptionality.ts, 58, 5)) '1.': Derived2; ->'1.' : Symbol(S3["1"], Decl(subtypingWithObjectMembersOptionality.ts, 64, 29)) +>'1.' : Symbol(S3['1.'], Decl(subtypingWithObjectMembersOptionality.ts, 64, 29)) >Derived2 : Symbol(Derived2, Decl(subtypingWithObjectMembersOptionality.ts, 3, 47)) } diff --git a/testdata/baselines/reference/submodule/conformance/subtypingWithObjectMembersOptionality.symbols.diff b/testdata/baselines/reference/submodule/conformance/subtypingWithObjectMembersOptionality.symbols.diff deleted file mode 100644 index 1d851c41b..000000000 --- a/testdata/baselines/reference/submodule/conformance/subtypingWithObjectMembersOptionality.symbols.diff +++ /dev/null @@ -1,37 +0,0 @@ ---- old.subtypingWithObjectMembersOptionality.symbols -+++ new.subtypingWithObjectMembersOptionality.symbols -@@= skipped -62, +62 lines =@@ - >T3 : Symbol(T3, Decl(subtypingWithObjectMembersOptionality.ts, 28, 1)) - - '1'?: Base; -->'1' : Symbol(T3['1'], Decl(subtypingWithObjectMembersOptionality.ts, 30, 14)) -+>'1' : Symbol(T3["1"], Decl(subtypingWithObjectMembersOptionality.ts, 30, 14)) - >Base : Symbol(Base, Decl(subtypingWithObjectMembersOptionality.ts, 0, 0)) - } - -@@= skipped -9, +9 lines =@@ - >T3 : Symbol(T3, Decl(subtypingWithObjectMembersOptionality.ts, 28, 1)) - - '1.': Derived; -->'1.' : Symbol(S3['1.'], Decl(subtypingWithObjectMembersOptionality.ts, 34, 25)) -+>'1.' : Symbol(S3["1"], Decl(subtypingWithObjectMembersOptionality.ts, 34, 25)) - >Derived : Symbol(Derived, Decl(subtypingWithObjectMembersOptionality.ts, 2, 31)) - } - -@@= skipped -61, +61 lines =@@ - >T3 : Symbol(T3, Decl(subtypingWithObjectMembersOptionality.ts, 58, 5)) - - '1'?: Base; -->'1' : Symbol(T3['1'], Decl(subtypingWithObjectMembersOptionality.ts, 60, 18)) -+>'1' : Symbol(T3["1"], Decl(subtypingWithObjectMembersOptionality.ts, 60, 18)) - >Base : Symbol(Base, Decl(subtypingWithObjectMembersOptionality.ts, 0, 0)) - } - -@@= skipped -9, +9 lines =@@ - >T3 : Symbol(T3, Decl(subtypingWithObjectMembersOptionality.ts, 58, 5)) - - '1.': Derived2; -->'1.' : Symbol(S3['1.'], Decl(subtypingWithObjectMembersOptionality.ts, 64, 29)) -+>'1.' : Symbol(S3["1"], Decl(subtypingWithObjectMembersOptionality.ts, 64, 29)) - >Derived2 : Symbol(Derived2, Decl(subtypingWithObjectMembersOptionality.ts, 3, 47)) - } diff --git a/testdata/baselines/reference/submodule/conformance/subtypingWithObjectMembersOptionality2.symbols b/testdata/baselines/reference/submodule/conformance/subtypingWithObjectMembersOptionality2.symbols index 1696fc196..9d2c1380e 100644 --- a/testdata/baselines/reference/submodule/conformance/subtypingWithObjectMembersOptionality2.symbols +++ b/testdata/baselines/reference/submodule/conformance/subtypingWithObjectMembersOptionality2.symbols @@ -50,7 +50,7 @@ interface T3 { >T3 : Symbol(T3, Decl(subtypingWithObjectMembersOptionality2.ts, 19, 1)) '1': Base; ->'1' : Symbol(T3["1"], Decl(subtypingWithObjectMembersOptionality2.ts, 21, 14)) +>'1' : Symbol(T3['1'], Decl(subtypingWithObjectMembersOptionality2.ts, 21, 14)) >Base : Symbol(Base, Decl(subtypingWithObjectMembersOptionality2.ts, 0, 0)) } @@ -59,7 +59,7 @@ interface S3 extends T3 { >T3 : Symbol(T3, Decl(subtypingWithObjectMembersOptionality2.ts, 19, 1)) '1'?: Derived; // error ->'1' : Symbol(S3["1"], Decl(subtypingWithObjectMembersOptionality2.ts, 25, 25)) +>'1' : Symbol(S3['1'], Decl(subtypingWithObjectMembersOptionality2.ts, 25, 25)) >Derived : Symbol(Derived, Decl(subtypingWithObjectMembersOptionality2.ts, 2, 31)) } diff --git a/testdata/baselines/reference/submodule/conformance/subtypingWithObjectMembersOptionality2.symbols.diff b/testdata/baselines/reference/submodule/conformance/subtypingWithObjectMembersOptionality2.symbols.diff deleted file mode 100644 index 752c4088b..000000000 --- a/testdata/baselines/reference/submodule/conformance/subtypingWithObjectMembersOptionality2.symbols.diff +++ /dev/null @@ -1,19 +0,0 @@ ---- old.subtypingWithObjectMembersOptionality2.symbols -+++ new.subtypingWithObjectMembersOptionality2.symbols -@@= skipped -49, +49 lines =@@ - >T3 : Symbol(T3, Decl(subtypingWithObjectMembersOptionality2.ts, 19, 1)) - - '1': Base; -->'1' : Symbol(T3['1'], Decl(subtypingWithObjectMembersOptionality2.ts, 21, 14)) -+>'1' : Symbol(T3["1"], Decl(subtypingWithObjectMembersOptionality2.ts, 21, 14)) - >Base : Symbol(Base, Decl(subtypingWithObjectMembersOptionality2.ts, 0, 0)) - } - -@@= skipped -9, +9 lines =@@ - >T3 : Symbol(T3, Decl(subtypingWithObjectMembersOptionality2.ts, 19, 1)) - - '1'?: Derived; // error -->'1' : Symbol(S3['1'], Decl(subtypingWithObjectMembersOptionality2.ts, 25, 25)) -+>'1' : Symbol(S3["1"], Decl(subtypingWithObjectMembersOptionality2.ts, 25, 25)) - >Derived : Symbol(Derived, Decl(subtypingWithObjectMembersOptionality2.ts, 2, 31)) - } diff --git a/testdata/baselines/reference/submodule/conformance/subtypingWithObjectMembersOptionality3.symbols b/testdata/baselines/reference/submodule/conformance/subtypingWithObjectMembersOptionality3.symbols index 63b12b618..f14264002 100644 --- a/testdata/baselines/reference/submodule/conformance/subtypingWithObjectMembersOptionality3.symbols +++ b/testdata/baselines/reference/submodule/conformance/subtypingWithObjectMembersOptionality3.symbols @@ -50,7 +50,7 @@ interface T3 { >T3 : Symbol(T3, Decl(subtypingWithObjectMembersOptionality3.ts, 19, 1)) '1'?: Base; ->'1' : Symbol(T3["1"], Decl(subtypingWithObjectMembersOptionality3.ts, 21, 14)) +>'1' : Symbol(T3['1'], Decl(subtypingWithObjectMembersOptionality3.ts, 21, 14)) >Base : Symbol(Base, Decl(subtypingWithObjectMembersOptionality3.ts, 0, 0)) } @@ -59,7 +59,7 @@ interface S3 extends T3 { >T3 : Symbol(T3, Decl(subtypingWithObjectMembersOptionality3.ts, 19, 1)) '1.0': Derived; // ok ->'1.0' : Symbol(S3["10"], Decl(subtypingWithObjectMembersOptionality3.ts, 25, 25)) +>'1.0' : Symbol(S3['1.0'], Decl(subtypingWithObjectMembersOptionality3.ts, 25, 25)) >Derived : Symbol(Derived, Decl(subtypingWithObjectMembersOptionality3.ts, 2, 31)) } diff --git a/testdata/baselines/reference/submodule/conformance/subtypingWithObjectMembersOptionality3.symbols.diff b/testdata/baselines/reference/submodule/conformance/subtypingWithObjectMembersOptionality3.symbols.diff deleted file mode 100644 index c9d1e1297..000000000 --- a/testdata/baselines/reference/submodule/conformance/subtypingWithObjectMembersOptionality3.symbols.diff +++ /dev/null @@ -1,19 +0,0 @@ ---- old.subtypingWithObjectMembersOptionality3.symbols -+++ new.subtypingWithObjectMembersOptionality3.symbols -@@= skipped -49, +49 lines =@@ - >T3 : Symbol(T3, Decl(subtypingWithObjectMembersOptionality3.ts, 19, 1)) - - '1'?: Base; -->'1' : Symbol(T3['1'], Decl(subtypingWithObjectMembersOptionality3.ts, 21, 14)) -+>'1' : Symbol(T3["1"], Decl(subtypingWithObjectMembersOptionality3.ts, 21, 14)) - >Base : Symbol(Base, Decl(subtypingWithObjectMembersOptionality3.ts, 0, 0)) - } - -@@= skipped -9, +9 lines =@@ - >T3 : Symbol(T3, Decl(subtypingWithObjectMembersOptionality3.ts, 19, 1)) - - '1.0': Derived; // ok -->'1.0' : Symbol(S3['1.0'], Decl(subtypingWithObjectMembersOptionality3.ts, 25, 25)) -+>'1.0' : Symbol(S3["10"], Decl(subtypingWithObjectMembersOptionality3.ts, 25, 25)) - >Derived : Symbol(Derived, Decl(subtypingWithObjectMembersOptionality3.ts, 2, 31)) - } diff --git a/testdata/baselines/reference/submodule/conformance/subtypingWithObjectMembersOptionality4.symbols b/testdata/baselines/reference/submodule/conformance/subtypingWithObjectMembersOptionality4.symbols index 87fc115ab..b0b716cb6 100644 --- a/testdata/baselines/reference/submodule/conformance/subtypingWithObjectMembersOptionality4.symbols +++ b/testdata/baselines/reference/submodule/conformance/subtypingWithObjectMembersOptionality4.symbols @@ -50,7 +50,7 @@ interface T3 { >T3 : Symbol(T3, Decl(subtypingWithObjectMembersOptionality4.ts, 19, 1)) '1': Base; ->'1' : Symbol(T3["1"], Decl(subtypingWithObjectMembersOptionality4.ts, 21, 14)) +>'1' : Symbol(T3['1'], Decl(subtypingWithObjectMembersOptionality4.ts, 21, 14)) >Base : Symbol(Base, Decl(subtypingWithObjectMembersOptionality4.ts, 0, 0)) } @@ -59,7 +59,7 @@ interface S3 extends T3 { >T3 : Symbol(T3, Decl(subtypingWithObjectMembersOptionality4.ts, 19, 1)) '1.0'?: Derived; // ok ->'1.0' : Symbol(S3["10"], Decl(subtypingWithObjectMembersOptionality4.ts, 25, 25)) +>'1.0' : Symbol(S3['1.0'], Decl(subtypingWithObjectMembersOptionality4.ts, 25, 25)) >Derived : Symbol(Derived, Decl(subtypingWithObjectMembersOptionality4.ts, 2, 31)) } diff --git a/testdata/baselines/reference/submodule/conformance/subtypingWithObjectMembersOptionality4.symbols.diff b/testdata/baselines/reference/submodule/conformance/subtypingWithObjectMembersOptionality4.symbols.diff deleted file mode 100644 index 8c1261ba6..000000000 --- a/testdata/baselines/reference/submodule/conformance/subtypingWithObjectMembersOptionality4.symbols.diff +++ /dev/null @@ -1,19 +0,0 @@ ---- old.subtypingWithObjectMembersOptionality4.symbols -+++ new.subtypingWithObjectMembersOptionality4.symbols -@@= skipped -49, +49 lines =@@ - >T3 : Symbol(T3, Decl(subtypingWithObjectMembersOptionality4.ts, 19, 1)) - - '1': Base; -->'1' : Symbol(T3['1'], Decl(subtypingWithObjectMembersOptionality4.ts, 21, 14)) -+>'1' : Symbol(T3["1"], Decl(subtypingWithObjectMembersOptionality4.ts, 21, 14)) - >Base : Symbol(Base, Decl(subtypingWithObjectMembersOptionality4.ts, 0, 0)) - } - -@@= skipped -9, +9 lines =@@ - >T3 : Symbol(T3, Decl(subtypingWithObjectMembersOptionality4.ts, 19, 1)) - - '1.0'?: Derived; // ok -->'1.0' : Symbol(S3['1.0'], Decl(subtypingWithObjectMembersOptionality4.ts, 25, 25)) -+>'1.0' : Symbol(S3["10"], Decl(subtypingWithObjectMembersOptionality4.ts, 25, 25)) - >Derived : Symbol(Derived, Decl(subtypingWithObjectMembersOptionality4.ts, 2, 31)) - } diff --git a/testdata/baselines/reference/submodule/conformance/tsxElementResolution.symbols b/testdata/baselines/reference/submodule/conformance/tsxElementResolution.symbols index d429f7020..ddb634d92 100644 --- a/testdata/baselines/reference/submodule/conformance/tsxElementResolution.symbols +++ b/testdata/baselines/reference/submodule/conformance/tsxElementResolution.symbols @@ -12,10 +12,10 @@ declare namespace JSX { >x : Symbol(x, Decl(tsxElementResolution.tsx, 2, 15)) 'string_named'; ->'string_named' : Symbol(IntrinsicElements["string_named"], Decl(tsxElementResolution.tsx, 2, 28)) +>'string_named' : Symbol(IntrinsicElements['string_named'], Decl(tsxElementResolution.tsx, 2, 28)) 'var'; ->'var' : Symbol(IntrinsicElements["var"], Decl(tsxElementResolution.tsx, 3, 17)) +>'var' : Symbol(IntrinsicElements['var'], Decl(tsxElementResolution.tsx, 3, 17)) } } @@ -40,7 +40,7 @@ var a = ; var b = ; >b : Symbol(b, Decl(tsxElementResolution.tsx, 17, 3)) ->string_named : Symbol(JSX.IntrinsicElements["string_named"], Decl(tsxElementResolution.tsx, 2, 28)) +>string_named : Symbol(JSX.IntrinsicElements['string_named'], Decl(tsxElementResolution.tsx, 2, 28)) // TODO: This should not be a parse error (should // parse a property name here, not identifier) diff --git a/testdata/baselines/reference/submodule/conformance/tsxElementResolution.symbols.diff b/testdata/baselines/reference/submodule/conformance/tsxElementResolution.symbols.diff deleted file mode 100644 index c6eb1f416..000000000 --- a/testdata/baselines/reference/submodule/conformance/tsxElementResolution.symbols.diff +++ /dev/null @@ -1,24 +0,0 @@ ---- old.tsxElementResolution.symbols -+++ new.tsxElementResolution.symbols -@@= skipped -11, +11 lines =@@ - >x : Symbol(x, Decl(tsxElementResolution.tsx, 2, 15)) - - 'string_named'; -->'string_named' : Symbol(IntrinsicElements['string_named'], Decl(tsxElementResolution.tsx, 2, 28)) -+>'string_named' : Symbol(IntrinsicElements["string_named"], Decl(tsxElementResolution.tsx, 2, 28)) - - 'var'; -->'var' : Symbol(IntrinsicElements['var'], Decl(tsxElementResolution.tsx, 3, 17)) -+>'var' : Symbol(IntrinsicElements["var"], Decl(tsxElementResolution.tsx, 3, 17)) - } - } - -@@= skipped -28, +28 lines =@@ - - var b = ; - >b : Symbol(b, Decl(tsxElementResolution.tsx, 17, 3)) -->string_named : Symbol(JSX.IntrinsicElements['string_named'], Decl(tsxElementResolution.tsx, 2, 28)) -+>string_named : Symbol(JSX.IntrinsicElements["string_named"], Decl(tsxElementResolution.tsx, 2, 28)) - - // TODO: This should not be a parse error (should - // parse a property name here, not identifier) \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/typeofThis.symbols b/testdata/baselines/reference/submodule/conformance/typeofThis.symbols index 452292475..cbc3fb99d 100644 --- a/testdata/baselines/reference/submodule/conformance/typeofThis.symbols +++ b/testdata/baselines/reference/submodule/conformance/typeofThis.symbols @@ -24,8 +24,8 @@ class Test1 { >foo : Symbol(foo, Decl(typeofThis.ts, 8, 12)) ['this'] = ''; ->['this'] : Symbol(Test1["this"], Decl(typeofThis.ts, 8, 23)) ->'this' : Symbol(Test1["this"], Decl(typeofThis.ts, 8, 23)) +>['this'] : Symbol(Test1['this'], Decl(typeofThis.ts, 8, 23)) +>'this' : Symbol(Test1['this'], Decl(typeofThis.ts, 8, 23)) constructor() { var copy: typeof this.data = { foo: '' }; @@ -55,9 +55,9 @@ class Test1 { var str: typeof this.this = ''; >str : Symbol(str, Decl(typeofThis.ts, 17, 11)) ->this.this : Symbol(Test1["this"], Decl(typeofThis.ts, 8, 23)) +>this.this : Symbol(Test1['this'], Decl(typeofThis.ts, 8, 23)) >this : Symbol(Test1, Decl(typeofThis.ts, 5, 1)) ->this : Symbol(Test1["this"], Decl(typeofThis.ts, 8, 23)) +>this : Symbol(Test1['this'], Decl(typeofThis.ts, 8, 23)) } } diff --git a/testdata/baselines/reference/submodule/conformance/typeofThis.symbols.diff b/testdata/baselines/reference/submodule/conformance/typeofThis.symbols.diff deleted file mode 100644 index 04488de58..000000000 --- a/testdata/baselines/reference/submodule/conformance/typeofThis.symbols.diff +++ /dev/null @@ -1,24 +0,0 @@ ---- old.typeofThis.symbols -+++ new.typeofThis.symbols -@@= skipped -23, +23 lines =@@ - >foo : Symbol(foo, Decl(typeofThis.ts, 8, 12)) - - ['this'] = ''; -->['this'] : Symbol(Test1['this'], Decl(typeofThis.ts, 8, 23)) -->'this' : Symbol(Test1['this'], Decl(typeofThis.ts, 8, 23)) -+>['this'] : Symbol(Test1["this"], Decl(typeofThis.ts, 8, 23)) -+>'this' : Symbol(Test1["this"], Decl(typeofThis.ts, 8, 23)) - - constructor() { - var copy: typeof this.data = { foo: '' }; -@@= skipped -31, +31 lines =@@ - - var str: typeof this.this = ''; - >str : Symbol(str, Decl(typeofThis.ts, 17, 11)) -->this.this : Symbol(Test1['this'], Decl(typeofThis.ts, 8, 23)) -+>this.this : Symbol(Test1["this"], Decl(typeofThis.ts, 8, 23)) - >this : Symbol(Test1, Decl(typeofThis.ts, 5, 1)) -->this : Symbol(Test1['this'], Decl(typeofThis.ts, 8, 23)) -+>this : Symbol(Test1["this"], Decl(typeofThis.ts, 8, 23)) - } - } diff --git a/testdata/baselines/reference/submodule/conformance/unionAndIntersectionInference1.symbols b/testdata/baselines/reference/submodule/conformance/unionAndIntersectionInference1.symbols index 9e696eeff..0b634a797 100644 --- a/testdata/baselines/reference/submodule/conformance/unionAndIntersectionInference1.symbols +++ b/testdata/baselines/reference/submodule/conformance/unionAndIntersectionInference1.symbols @@ -5,7 +5,7 @@ interface Y { 'i am a very certain type': Y } >Y : Symbol(Y, Decl(unionAndIntersectionInference1.ts, 0, 0)) ->'i am a very certain type' : Symbol(Y["i am a very certain type"], Decl(unionAndIntersectionInference1.ts, 2, 13)) +>'i am a very certain type' : Symbol(Y['i am a very certain type'], Decl(unionAndIntersectionInference1.ts, 2, 13)) >Y : Symbol(Y, Decl(unionAndIntersectionInference1.ts, 0, 0)) var y: Y = undefined; diff --git a/testdata/baselines/reference/submodule/conformance/unionAndIntersectionInference1.symbols.diff b/testdata/baselines/reference/submodule/conformance/unionAndIntersectionInference1.symbols.diff deleted file mode 100644 index a7ebfafc8..000000000 --- a/testdata/baselines/reference/submodule/conformance/unionAndIntersectionInference1.symbols.diff +++ /dev/null @@ -1,11 +0,0 @@ ---- old.unionAndIntersectionInference1.symbols -+++ new.unionAndIntersectionInference1.symbols -@@= skipped -4, +4 lines =@@ - - interface Y { 'i am a very certain type': Y } - >Y : Symbol(Y, Decl(unionAndIntersectionInference1.ts, 0, 0)) -->'i am a very certain type' : Symbol(Y['i am a very certain type'], Decl(unionAndIntersectionInference1.ts, 2, 13)) -+>'i am a very certain type' : Symbol(Y["i am a very certain type"], Decl(unionAndIntersectionInference1.ts, 2, 13)) - >Y : Symbol(Y, Decl(unionAndIntersectionInference1.ts, 0, 0)) - - var y: Y = undefined; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/fourslash/findRenameLocations/findAllRefsImportStarOfExportEquals.baseline.jsonc b/testdata/baselines/reference/submodule/fourslash/findRenameLocations/findAllRefsImportStarOfExportEquals.baseline.jsonc new file mode 100644 index 000000000..37a62c7d6 --- /dev/null +++ b/testdata/baselines/reference/submodule/fourslash/findRenameLocations/findAllRefsImportStarOfExportEquals.baseline.jsonc @@ -0,0 +1,90 @@ +// === findRenameLocations === +// === /c.ts === +// import [|aRENAME|] from "a"; +// [|aRENAME|](); +// [|aRENAME|].x; + +// === /node_modules/a/index.d.ts === +// declare function /*RENAME*/[|aRENAME|](): void; +// declare namespace [|aRENAME|] { +// export const x: number; +// } +// export = [|aRENAME|]; + + + +// === findRenameLocations === +// === /c.ts === +// import [|aRENAME|] from "a"; +// [|aRENAME|](); +// [|aRENAME|].x; + +// === /node_modules/a/index.d.ts === +// declare function [|aRENAME|](): void; +// declare namespace /*RENAME*/[|aRENAME|] { +// export const x: number; +// } +// export = [|aRENAME|]; + + + +// === findRenameLocations === +// === /c.ts === +// import [|aRENAME|] from "a"; +// [|aRENAME|](); +// [|aRENAME|].x; + +// === /node_modules/a/index.d.ts === +// declare function [|aRENAME|](): void; +// declare namespace [|aRENAME|] { +// export const x: number; +// } +// export = /*RENAME*/[|aRENAME|]; + + + +// === findRenameLocations === +// === /b.ts === +// import /*RENAME*/[|bRENAME|] from "a"; +// [|bRENAME|](); +// [|bRENAME|].x; + + + +// === findRenameLocations === +// === /b.ts === +// import [|bRENAME|] from "a"; +// /*RENAME*/[|bRENAME|](); +// [|bRENAME|].x; + + + +// === findRenameLocations === +// === /b.ts === +// import [|bRENAME|] from "a"; +// [|bRENAME|](); +// /*RENAME*/[|bRENAME|].x; + + + +// === findRenameLocations === +// === /c.ts === +// import /*RENAME*/[|aRENAME|] from "a"; +// [|aRENAME|](); +// [|aRENAME|].x; + + + +// === findRenameLocations === +// === /c.ts === +// import [|aRENAME|] from "a"; +// /*RENAME*/[|aRENAME|](); +// [|aRENAME|].x; + + + +// === findRenameLocations === +// === /c.ts === +// import [|aRENAME|] from "a"; +// [|aRENAME|](); +// /*RENAME*/[|aRENAME|].x; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/fourslash/findRenameLocations/findAllRefsImportStarOfExportEquals.baseline.jsonc.diff b/testdata/baselines/reference/submodule/fourslash/findRenameLocations/findAllRefsImportStarOfExportEquals.baseline.jsonc.diff new file mode 100644 index 000000000..3d1ba797b --- /dev/null +++ b/testdata/baselines/reference/submodule/fourslash/findRenameLocations/findAllRefsImportStarOfExportEquals.baseline.jsonc.diff @@ -0,0 +1,58 @@ +--- old.findAllRefsImportStarOfExportEquals.baseline.jsonc ++++ new.findAllRefsImportStarOfExportEquals.baseline.jsonc +@@= skipped -0, +0 lines =@@ + // === findRenameLocations === ++// === /c.ts === ++// import [|aRENAME|] from "a"; ++// [|aRENAME|](); ++// [|aRENAME|].x; ++ + // === /node_modules/a/index.d.ts === + // declare function /*RENAME*/[|aRENAME|](): void; + // declare namespace [|aRENAME|] { +@@= skipped -5, +10 lines =@@ + // } + // export = [|aRENAME|]; + ++ ++ ++// === findRenameLocations === + // === /c.ts === + // import [|aRENAME|] from "a"; + // [|aRENAME|](); + // [|aRENAME|].x; + +- +- +-// === findRenameLocations === + // === /node_modules/a/index.d.ts === + // declare function [|aRENAME|](): void; + // declare namespace /*RENAME*/[|aRENAME|] { +@@= skipped -15, +15 lines =@@ + // } + // export = [|aRENAME|]; + ++ ++ ++// === findRenameLocations === + // === /c.ts === + // import [|aRENAME|] from "a"; + // [|aRENAME|](); + // [|aRENAME|].x; + +- +- +-// === findRenameLocations === + // === /node_modules/a/index.d.ts === + // declare function [|aRENAME|](): void; + // declare namespace [|aRENAME|] { + // export const x: number; + // } + // export = /*RENAME*/[|aRENAME|]; +- +-// === /c.ts === +-// import [|aRENAME|] from "a"; +-// [|aRENAME|](); +-// [|aRENAME|].x; + + diff --git a/testdata/baselines/reference/submodule/fourslash/findRenameLocations/findAllRefsPrefixSuffixPreference.baseline.jsonc b/testdata/baselines/reference/submodule/fourslash/findRenameLocations/findAllRefsPrefixSuffixPreference.baseline.jsonc new file mode 100644 index 000000000..5fe7d981b --- /dev/null +++ b/testdata/baselines/reference/submodule/fourslash/findRenameLocations/findAllRefsPrefixSuffixPreference.baseline.jsonc @@ -0,0 +1,189 @@ +// === findRenameLocations === +// @useAliasesForRename: true + +// === /file1.ts === +// declare function log(s: string | number): void; +// const /*RENAME*/[|qRENAME|] = 1; +// export { [|qRENAME|] as q/*END SUFFIX*/ }; +// const x = { +// z: 'value' +// } +// const { z } = x; +// log(z); + + + +// === findRenameLocations === +// @useAliasesForRename: true + +// === /file1.ts === +// declare function log(s: string | number): void; +// const q = 1; +// export { /*START PREFIX*/q as /*RENAME*/[|qRENAME|] }; +// const x = { +// z: 'value' +// } +// const { z } = x; +// log(z); + +// === /file2.ts === +// declare function log(s: string | number): void; +// import { [|qRENAME|] } from "./file1"; +// log([|qRENAME|] + 1); + + + +// === findRenameLocations === +// @useAliasesForRename: true + +// === /file2.ts === +// declare function log(s: string | number): void; +// import { /*START PREFIX*/q as /*RENAME*/[|qRENAME|] } from "./file1"; +// log([|qRENAME|] + 1); + + + +// === findRenameLocations === +// @useAliasesForRename: true + +// === /file2.ts === +// declare function log(s: string | number): void; +// import { /*START PREFIX*/q as [|qRENAME|] } from "./file1"; +// log(/*RENAME*/[|qRENAME|] + 1); + + + +// === findRenameLocations === +// @useAliasesForRename: false + +// === /file1.ts === +// declare function log(s: string | number): void; +// const /*RENAME*/[|qRENAME|] = 1; +// export { [|qRENAME|] as q/*END SUFFIX*/ }; +// const x = { +// z: 'value' +// } +// const { z } = x; +// log(z); + + + +// === findRenameLocations === +// @useAliasesForRename: false + +// === /file1.ts === +// declare function log(s: string | number): void; +// const q = 1; +// export { /*START PREFIX*/q as /*RENAME*/[|qRENAME|] }; +// const x = { +// z: 'value' +// } +// const { z } = x; +// log(z); + +// === /file2.ts === +// declare function log(s: string | number): void; +// import { [|qRENAME|] } from "./file1"; +// log([|qRENAME|] + 1); + + + +// === findRenameLocations === +// @useAliasesForRename: false + +// === /file2.ts === +// declare function log(s: string | number): void; +// import { /*START PREFIX*/q as /*RENAME*/[|qRENAME|] } from "./file1"; +// log([|qRENAME|] + 1); + + + +// === findRenameLocations === +// @useAliasesForRename: false + +// === /file2.ts === +// declare function log(s: string | number): void; +// import { /*START PREFIX*/q as [|qRENAME|] } from "./file1"; +// log(/*RENAME*/[|qRENAME|] + 1); + + + +// === findRenameLocations === +// @useAliasesForRename: true + +// === /file1.ts === +// declare function log(s: string | number): void; +// const q = 1; +// export { q }; +// const x = { +// /*RENAME*/[|zRENAME|]: 'value' +// } +// const { [|zRENAME|]: z/*END SUFFIX*/ } = x; +// log(z); + + + +// === findRenameLocations === +// @useAliasesForRename: true + +// === /file1.ts === +// --- (line: 3) skipped --- +// const x = { +// z: 'value' +// } +// const { /*START PREFIX*/z: /*RENAME*/[|zRENAME|] } = x; +// log([|zRENAME|]); + + + +// === findRenameLocations === +// @useAliasesForRename: true + +// === /file1.ts === +// --- (line: 3) skipped --- +// const x = { +// z: 'value' +// } +// const { /*START PREFIX*/z: [|zRENAME|] } = x; +// log(/*RENAME*/[|zRENAME|]); + + + +// === findRenameLocations === +// @useAliasesForRename: false + +// === /file1.ts === +// declare function log(s: string | number): void; +// const q = 1; +// export { q }; +// const x = { +// /*RENAME*/[|zRENAME|]: 'value' +// } +// const { [|zRENAME|]: z/*END SUFFIX*/ } = x; +// log(z); + + + +// === findRenameLocations === +// @useAliasesForRename: false + +// === /file1.ts === +// --- (line: 3) skipped --- +// const x = { +// z: 'value' +// } +// const { /*START PREFIX*/z: /*RENAME*/[|zRENAME|] } = x; +// log([|zRENAME|]); + + + +// === findRenameLocations === +// @useAliasesForRename: false + +// === /file1.ts === +// --- (line: 3) skipped --- +// const x = { +// z: 'value' +// } +// const { /*START PREFIX*/z: [|zRENAME|] } = x; +// log(/*RENAME*/[|zRENAME|]); \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/fourslash/findRenameLocations/findAllRefsPrefixSuffixPreference.baseline.jsonc.diff b/testdata/baselines/reference/submodule/fourslash/findRenameLocations/findAllRefsPrefixSuffixPreference.baseline.jsonc.diff new file mode 100644 index 000000000..5bb6cfc6b --- /dev/null +++ b/testdata/baselines/reference/submodule/fourslash/findRenameLocations/findAllRefsPrefixSuffixPreference.baseline.jsonc.diff @@ -0,0 +1,189 @@ +--- old.findAllRefsPrefixSuffixPreference.baseline.jsonc ++++ new.findAllRefsPrefixSuffixPreference.baseline.jsonc +@@= skipped -58, +58 lines =@@ + // === /file1.ts === + // declare function log(s: string | number): void; + // const /*RENAME*/[|qRENAME|] = 1; +-// export { [|qRENAME|] }; +-// const x = { +-// z: 'value' +-// } +-// const { z } = x; +-// log(z); +- +-// === /file2.ts === +-// declare function log(s: string | number): void; +-// import { [|qRENAME|] } from "./file1"; +-// log([|qRENAME|] + 1); +- +- +- +-// === findRenameLocations === +-// @useAliasesForRename: false +- +-// === /file1.ts === +-// declare function log(s: string | number): void; +-// const [|qRENAME|] = 1; +-// export { /*RENAME*/[|qRENAME|] }; +-// const x = { +-// z: 'value' +-// } +-// const { z } = x; +-// log(z); +- +-// === /file2.ts === +-// declare function log(s: string | number): void; +-// import { [|qRENAME|] } from "./file1"; +-// log([|qRENAME|] + 1); +- +- +- +-// === findRenameLocations === +-// @useAliasesForRename: false +- +-// === /file2.ts === +-// declare function log(s: string | number): void; +-// import { /*RENAME*/[|qRENAME|] } from "./file1"; +-// log([|qRENAME|] + 1); +- +-// === /file1.ts === +-// declare function log(s: string | number): void; +-// const [|qRENAME|] = 1; +-// export { [|qRENAME|] }; +-// const x = { +-// z: 'value' +-// } +-// const { z } = x; +-// log(z); +- +- +- +-// === findRenameLocations === +-// @useAliasesForRename: false +- +-// === /file2.ts === +-// declare function log(s: string | number): void; +-// import { [|qRENAME|] } from "./file1"; ++// export { [|qRENAME|] as q/*END SUFFIX*/ }; ++// const x = { ++// z: 'value' ++// } ++// const { z } = x; ++// log(z); ++ ++ ++ ++// === findRenameLocations === ++// @useAliasesForRename: false ++ ++// === /file1.ts === ++// declare function log(s: string | number): void; ++// const q = 1; ++// export { /*START PREFIX*/q as /*RENAME*/[|qRENAME|] }; ++// const x = { ++// z: 'value' ++// } ++// const { z } = x; ++// log(z); ++ ++// === /file2.ts === ++// declare function log(s: string | number): void; ++// import { [|qRENAME|] } from "./file1"; ++// log([|qRENAME|] + 1); ++ ++ ++ ++// === findRenameLocations === ++// @useAliasesForRename: false ++ ++// === /file2.ts === ++// declare function log(s: string | number): void; ++// import { /*START PREFIX*/q as /*RENAME*/[|qRENAME|] } from "./file1"; ++// log([|qRENAME|] + 1); ++ ++ ++ ++// === findRenameLocations === ++// @useAliasesForRename: false ++ ++// === /file2.ts === ++// declare function log(s: string | number): void; ++// import { /*START PREFIX*/q as [|qRENAME|] } from "./file1"; + // log(/*RENAME*/[|qRENAME|] + 1); + +-// === /file1.ts === +-// declare function log(s: string | number): void; +-// const [|qRENAME|] = 1; +-// export { [|qRENAME|] }; +-// const x = { +-// z: 'value' +-// } +-// const { z } = x; +-// log(z); +- + + + // === findRenameLocations === +@@= skipped -125, +100 lines =@@ + // const x = { + // /*RENAME*/[|zRENAME|]: 'value' + // } +-// const { [|zRENAME|] } = x; +-// log([|zRENAME|]); +- +- +- +-// === findRenameLocations === +-// @useAliasesForRename: false +- +-// === /file1.ts === +-// declare function log(s: string | number): void; +-// const q = 1; +-// export { q }; +-// const x = { +-// [|zRENAME|]: 'value' +-// } +-// const { /*RENAME*/[|zRENAME|] } = x; +-// log([|zRENAME|]); +- +- +- +-// === findRenameLocations === +-// @useAliasesForRename: false +- +-// === /file1.ts === +-// declare function log(s: string | number): void; +-// const q = 1; +-// export { q }; +-// const x = { +-// [|zRENAME|]: 'value' +-// } +-// const { [|zRENAME|] } = x; ++// const { [|zRENAME|]: z/*END SUFFIX*/ } = x; ++// log(z); ++ ++ ++ ++// === findRenameLocations === ++// @useAliasesForRename: false ++ ++// === /file1.ts === ++// --- (line: 3) skipped --- ++// const x = { ++// z: 'value' ++// } ++// const { /*START PREFIX*/z: /*RENAME*/[|zRENAME|] } = x; ++// log([|zRENAME|]); ++ ++ ++ ++// === findRenameLocations === ++// @useAliasesForRename: false ++ ++// === /file1.ts === ++// --- (line: 3) skipped --- ++// const x = { ++// z: 'value' ++// } ++// const { /*START PREFIX*/z: [|zRENAME|] } = x; + // log(/*RENAME*/[|zRENAME|]); \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/fourslash/findRenameLocations/findAllRefsReExportLocal.baseline.jsonc b/testdata/baselines/reference/submodule/fourslash/findRenameLocations/findAllRefsReExportLocal.baseline.jsonc new file mode 100644 index 000000000..bbe1d07bb --- /dev/null +++ b/testdata/baselines/reference/submodule/fourslash/findRenameLocations/findAllRefsReExportLocal.baseline.jsonc @@ -0,0 +1,65 @@ +// === findRenameLocations === +// === /a.ts === +// var /*RENAME*/[|xRENAME|]; +// export { [|xRENAME|] as x/*END SUFFIX*/ }; +// export { [|xRENAME|] as y }; + + + +// === findRenameLocations === +// === /a.ts === +// var [|xRENAME|]; +// export { [|xRENAME|] as x/*END SUFFIX*/ }; +// export { /*RENAME*/[|xRENAME|] as y }; + + + +// === findRenameLocations === +// === /a.ts === +// var x; +// export { /*START PREFIX*/x as /*RENAME*/[|xRENAME|] }; +// export { x as y }; + +// === /b.ts === +// import { [|xRENAME|], y } from "./a"; +// [|xRENAME|]; y; + + + +// === findRenameLocations === +// === /b.ts === +// import { /*START PREFIX*/x as /*RENAME*/[|xRENAME|], y } from "./a"; +// [|xRENAME|]; y; + + + +// === findRenameLocations === +// === /b.ts === +// import { /*START PREFIX*/x as [|xRENAME|], y } from "./a"; +// /*RENAME*/[|xRENAME|]; y; + + + +// === findRenameLocations === +// === /a.ts === +// var x; +// export { x }; +// export { x as /*RENAME*/[|yRENAME|] }; + +// === /b.ts === +// import { x, [|yRENAME|] } from "./a"; +// x; [|yRENAME|]; + + + +// === findRenameLocations === +// === /b.ts === +// import { x, /*START PREFIX*/y as /*RENAME*/[|yRENAME|] } from "./a"; +// x; [|yRENAME|]; + + + +// === findRenameLocations === +// === /b.ts === +// import { x, /*START PREFIX*/y as [|yRENAME|] } from "./a"; +// x; /*RENAME*/[|yRENAME|]; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/fourslash/findRenameLocations/findAllRefsReExportRightNameWrongSymbol.baseline.jsonc b/testdata/baselines/reference/submodule/fourslash/findRenameLocations/findAllRefsReExportRightNameWrongSymbol.baseline.jsonc new file mode 100644 index 000000000..5f0ba3383 --- /dev/null +++ b/testdata/baselines/reference/submodule/fourslash/findRenameLocations/findAllRefsReExportRightNameWrongSymbol.baseline.jsonc @@ -0,0 +1,52 @@ +// === findRenameLocations === +// === /a.ts === +// export const /*RENAME*/[|xRENAME|] = 0; + +// === /c.ts === +// export { x } from "./b"; +// import { [|xRENAME|] } from "./a"; +// [|xRENAME|]; + + + +// === findRenameLocations === +// === /c.ts === +// export { x } from "./b"; +// import { /*START PREFIX*/x as /*RENAME*/[|xRENAME|] } from "./a"; +// [|xRENAME|]; + + + +// === findRenameLocations === +// === /c.ts === +// export { x } from "./b"; +// import { /*START PREFIX*/x as [|xRENAME|] } from "./a"; +// /*RENAME*/[|xRENAME|]; + + + +// === findRenameLocations === +// === /b.ts === +// export const /*RENAME*/[|xRENAME|] = 0; + +// === /c.ts === +// export { [|xRENAME|] as x/*END SUFFIX*/ } from "./b"; +// import { x } from "./a"; +// x; + + + +// === findRenameLocations === +// === /c.ts === +// export { /*START PREFIX*/x as /*RENAME*/[|xRENAME|] } from "./b"; +// import { x } from "./a"; +// x; + +// === /d.ts === +// import { [|xRENAME|] } from "./c"; + + + +// === findRenameLocations === +// === /d.ts === +// import { /*START PREFIX*/x as /*RENAME*/[|xRENAME|] } from "./c"; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/fourslash/findRenameLocations/findAllRefsReExportsUseInImportType.baseline.jsonc b/testdata/baselines/reference/submodule/fourslash/findRenameLocations/findAllRefsReExportsUseInImportType.baseline.jsonc new file mode 100644 index 000000000..5a8fb51b7 --- /dev/null +++ b/testdata/baselines/reference/submodule/fourslash/findRenameLocations/findAllRefsReExportsUseInImportType.baseline.jsonc @@ -0,0 +1,145 @@ +// === findRenameLocations === +// === /app.ts === +// import { foo } from './foo/types'; +// export type fullType = foo.[|FullRENAME|]; +// type namespaceImport = typeof import('./foo/types'); +// type fullType2 = import('./foo/types').foo.[|FullRENAME|]; + +// === /foo/types/types.ts === +// export type /*RENAME*/[|FullRENAME|] = { prop: string; }; + + + +// === findRenameLocations === +// === /app.ts === +// import { foo } from './foo/types'; +// export type fullType = foo./*RENAME*/[|FullRENAME|]; +// type namespaceImport = typeof import('./foo/types'); +// type fullType2 = import('./foo/types').foo.[|FullRENAME|]; + +// === /foo/types/types.ts === +// export type [|FullRENAME|] = { prop: string; }; + + + +// === findRenameLocations === +// === /app.ts === +// import { foo } from './foo/types'; +// export type fullType = foo.[|FullRENAME|]; +// type namespaceImport = typeof import('./foo/types'); +// type fullType2 = import('./foo/types').foo./*RENAME*/[|FullRENAME|]; + +// === /foo/types/types.ts === +// export type [|FullRENAME|] = { prop: string; }; + + + +// === findRenameLocations === +// === /foo/types/index.ts === +// import * as /*RENAME*/[|fooRENAME|] from './types'; +// export { [|fooRENAME|] as foo/*END SUFFIX*/ }; + + + +// === findRenameLocations === +// === /app.ts === +// import { [|fooRENAME|] } from './foo/types'; +// export type fullType = [|fooRENAME|].Full; +// type namespaceImport = typeof import('./foo/types'); +// type fullType2 = import('./foo/types').[|fooRENAME|].Full; + +// === /foo/types/index.ts === +// import * as foo from './types'; +// export { /*START PREFIX*/foo as /*RENAME*/[|fooRENAME|] }; + + + +// === findRenameLocations === +// === /app.ts === +// import { [|fooRENAME|] } from './foo/types'; +// export type fullType = [|fooRENAME|].Full; +// type namespaceImport = typeof import('./foo/types'); +// type fullType2 = import('./foo/types')./*RENAME*/[|fooRENAME|].Full; + +// === /foo/types/index.ts === +// import * as foo from './types'; +// export { /*START PREFIX*/foo as [|fooRENAME|] }; + + + +// === findRenameLocations === +// === /app.ts === +// import { /*START PREFIX*/foo as /*RENAME*/[|fooRENAME|] } from './foo/types'; +// export type fullType = [|fooRENAME|].Full; +// type namespaceImport = typeof import('./foo/types'); +// type fullType2 = import('./foo/types').foo.Full; + + + +// === findRenameLocations === +// === /app.ts === +// import { /*START PREFIX*/foo as [|fooRENAME|] } from './foo/types'; +// export type fullType = /*RENAME*/[|fooRENAME|].Full; +// type namespaceImport = typeof import('./foo/types'); +// type fullType2 = import('./foo/types').foo.Full; + + + +// === findRenameLocations === +// @useAliasesForRename: false + +// === /app.ts === +// import { /*START PREFIX*/foo as /*RENAME*/[|fooRENAME|] } from './foo/types'; +// export type fullType = [|fooRENAME|].Full; +// type namespaceImport = typeof import('./foo/types'); +// type fullType2 = import('./foo/types').foo.Full; + + + +// === findRenameLocations === +// @useAliasesForRename: false + +// === /app.ts === +// import { /*START PREFIX*/foo as [|fooRENAME|] } from './foo/types'; +// export type fullType = /*RENAME*/[|fooRENAME|].Full; +// type namespaceImport = typeof import('./foo/types'); +// type fullType2 = import('./foo/types').foo.Full; + + + +// === findRenameLocations === +// @useAliasesForRename: false + +// === /app.ts === +// import { [|fooRENAME|] } from './foo/types'; +// export type fullType = [|fooRENAME|].Full; +// type namespaceImport = typeof import('./foo/types'); +// type fullType2 = import('./foo/types')./*RENAME*/[|fooRENAME|].Full; + +// === /foo/types/index.ts === +// import * as foo from './types'; +// export { /*START PREFIX*/foo as [|fooRENAME|] }; + + + +// === findRenameLocations === +// @useAliasesForRename: false + +// === /foo/types/index.ts === +// import * as /*RENAME*/[|fooRENAME|] from './types'; +// export { [|fooRENAME|] as foo/*END SUFFIX*/ }; + + + +// === findRenameLocations === +// @useAliasesForRename: false + +// === /app.ts === +// import { [|fooRENAME|] } from './foo/types'; +// export type fullType = [|fooRENAME|].Full; +// type namespaceImport = typeof import('./foo/types'); +// type fullType2 = import('./foo/types').[|fooRENAME|].Full; + +// === /foo/types/index.ts === +// import * as foo from './types'; +// export { /*START PREFIX*/foo as /*RENAME*/[|fooRENAME|] }; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/fourslash/findRenameLocations/findAllRefsReExportsUseInImportType.baseline.jsonc.diff b/testdata/baselines/reference/submodule/fourslash/findRenameLocations/findAllRefsReExportsUseInImportType.baseline.jsonc.diff new file mode 100644 index 000000000..4a58f402e --- /dev/null +++ b/testdata/baselines/reference/submodule/fourslash/findRenameLocations/findAllRefsReExportsUseInImportType.baseline.jsonc.diff @@ -0,0 +1,285 @@ +--- old.findAllRefsReExportsUseInImportType.baseline.jsonc ++++ new.findAllRefsReExportsUseInImportType.baseline.jsonc +@@= skipped -0, +0 lines =@@ + // === findRenameLocations === ++// === /app.ts === ++// import { foo } from './foo/types'; ++// export type fullType = foo.[|FullRENAME|]; ++// type namespaceImport = typeof import('./foo/types'); ++// type fullType2 = import('./foo/types').foo.[|FullRENAME|]; ++ + // === /foo/types/types.ts === + // export type /*RENAME*/[|FullRENAME|] = { prop: string; }; + +-// === /app.ts === +-// import { foo } from './foo/types'; +-// export type fullType = foo.[|FullRENAME|]; +-// type namespaceImport = typeof import('./foo/types'); +-// type fullType2 = import('./foo/types').foo.[|FullRENAME|]; +- + + + // === findRenameLocations === +-// === /foo/types/types.ts === +-// export type [|FullRENAME|] = { prop: string; }; +- + // === /app.ts === + // import { foo } from './foo/types'; + // export type fullType = foo./*RENAME*/[|FullRENAME|]; + // type namespaceImport = typeof import('./foo/types'); + // type fullType2 = import('./foo/types').foo.[|FullRENAME|]; + +- +- +-// === findRenameLocations === + // === /foo/types/types.ts === + // export type [|FullRENAME|] = { prop: string; }; + ++ ++ ++// === findRenameLocations === + // === /app.ts === + // import { foo } from './foo/types'; + // export type fullType = foo.[|FullRENAME|]; + // type namespaceImport = typeof import('./foo/types'); + // type fullType2 = import('./foo/types').foo./*RENAME*/[|FullRENAME|]; + +- +- +-// === findRenameLocations === +-// === /foo/types/index.ts === +-// import * as /*RENAME*/[|fooRENAME|] from './types'; +-// export { [|fooRENAME|] as foo/*END SUFFIX*/ }; +- +- +- +-// === findRenameLocations === +-// === /foo/types/index.ts === +-// import * as foo from './types'; +-// export { /*START PREFIX*/foo as /*RENAME*/[|fooRENAME|] }; +- +-// === /app.ts === +-// import { [|fooRENAME|] } from './foo/types'; +-// export type fullType = [|fooRENAME|].Full; +-// type namespaceImport = typeof import('./foo/types'); +-// type fullType2 = import('./foo/types').[|fooRENAME|].Full; +- +- +- +-// === findRenameLocations === +-// === /foo/types/index.ts === +-// import * as foo from './types'; +-// export { /*START PREFIX*/foo as [|fooRENAME|] }; +- +-// === /app.ts === +-// import { [|fooRENAME|] } from './foo/types'; +-// export type fullType = [|fooRENAME|].Full; +-// type namespaceImport = typeof import('./foo/types'); +-// type fullType2 = import('./foo/types')./*RENAME*/[|fooRENAME|].Full; +- +- +- +-// === findRenameLocations === +-// === /app.ts === +-// import { /*START PREFIX*/foo as /*RENAME*/[|fooRENAME|] } from './foo/types'; +-// export type fullType = [|fooRENAME|].Full; +-// type namespaceImport = typeof import('./foo/types'); +-// type fullType2 = import('./foo/types').foo.Full; +- +- +- +-// === findRenameLocations === +-// === /app.ts === +-// import { /*START PREFIX*/foo as [|fooRENAME|] } from './foo/types'; +-// export type fullType = /*RENAME*/[|fooRENAME|].Full; +-// type namespaceImport = typeof import('./foo/types'); +-// type fullType2 = import('./foo/types').foo.Full; +- +- +- +-// === findRenameLocations === +-// @useAliasesForRename: false +- +-// === /app.ts === +-// import { /*RENAME*/[|fooRENAME|] } from './foo/types'; +-// export type fullType = [|fooRENAME|].Full; +-// type namespaceImport = typeof import('./foo/types'); +-// type fullType2 = import('./foo/types').[|fooRENAME|].Full; +- +-// === /foo/types/index.ts === +-// import * as [|fooRENAME|] from './types'; +-// export { [|fooRENAME|] }; +- +- +- +-// === findRenameLocations === +-// @useAliasesForRename: false +- +-// === /app.ts === +-// import { [|fooRENAME|] } from './foo/types'; +-// export type fullType = /*RENAME*/[|fooRENAME|].Full; +-// type namespaceImport = typeof import('./foo/types'); +-// type fullType2 = import('./foo/types').[|fooRENAME|].Full; +- +-// === /foo/types/index.ts === +-// import * as [|fooRENAME|] from './types'; +-// export { [|fooRENAME|] }; +- +- +- +-// === findRenameLocations === +-// @useAliasesForRename: false +- +-// === /foo/types/index.ts === +-// import * as [|fooRENAME|] from './types'; +-// export { [|fooRENAME|] }; +- +-// === /app.ts === +-// import { [|fooRENAME|] } from './foo/types'; +-// export type fullType = [|fooRENAME|].Full; +-// type namespaceImport = typeof import('./foo/types'); +-// type fullType2 = import('./foo/types')./*RENAME*/[|fooRENAME|].Full; +- +- +- +-// === findRenameLocations === +-// @useAliasesForRename: false +- +-// === /foo/types/index.ts === +-// import * as /*RENAME*/[|fooRENAME|] from './types'; +-// export { [|fooRENAME|] }; +- +-// === /app.ts === +-// import { [|fooRENAME|] } from './foo/types'; +-// export type fullType = [|fooRENAME|].Full; +-// type namespaceImport = typeof import('./foo/types'); +-// type fullType2 = import('./foo/types').[|fooRENAME|].Full; +- +- +- +-// === findRenameLocations === +-// @useAliasesForRename: false +- +-// === /foo/types/index.ts === +-// import * as [|fooRENAME|] from './types'; +-// export { /*RENAME*/[|fooRENAME|] }; +- +-// === /app.ts === +-// import { [|fooRENAME|] } from './foo/types'; +-// export type fullType = [|fooRENAME|].Full; +-// type namespaceImport = typeof import('./foo/types'); +-// type fullType2 = import('./foo/types').[|fooRENAME|].Full; ++// === /foo/types/types.ts === ++// export type [|FullRENAME|] = { prop: string; }; ++ ++ ++ ++// === findRenameLocations === ++// === /foo/types/index.ts === ++// import * as /*RENAME*/[|fooRENAME|] from './types'; ++// export { [|fooRENAME|] as foo/*END SUFFIX*/ }; ++ ++ ++ ++// === findRenameLocations === ++// === /app.ts === ++// import { [|fooRENAME|] } from './foo/types'; ++// export type fullType = [|fooRENAME|].Full; ++// type namespaceImport = typeof import('./foo/types'); ++// type fullType2 = import('./foo/types').[|fooRENAME|].Full; ++ ++// === /foo/types/index.ts === ++// import * as foo from './types'; ++// export { /*START PREFIX*/foo as /*RENAME*/[|fooRENAME|] }; ++ ++ ++ ++// === findRenameLocations === ++// === /app.ts === ++// import { [|fooRENAME|] } from './foo/types'; ++// export type fullType = [|fooRENAME|].Full; ++// type namespaceImport = typeof import('./foo/types'); ++// type fullType2 = import('./foo/types')./*RENAME*/[|fooRENAME|].Full; ++ ++// === /foo/types/index.ts === ++// import * as foo from './types'; ++// export { /*START PREFIX*/foo as [|fooRENAME|] }; ++ ++ ++ ++// === findRenameLocations === ++// === /app.ts === ++// import { /*START PREFIX*/foo as /*RENAME*/[|fooRENAME|] } from './foo/types'; ++// export type fullType = [|fooRENAME|].Full; ++// type namespaceImport = typeof import('./foo/types'); ++// type fullType2 = import('./foo/types').foo.Full; ++ ++ ++ ++// === findRenameLocations === ++// === /app.ts === ++// import { /*START PREFIX*/foo as [|fooRENAME|] } from './foo/types'; ++// export type fullType = /*RENAME*/[|fooRENAME|].Full; ++// type namespaceImport = typeof import('./foo/types'); ++// type fullType2 = import('./foo/types').foo.Full; ++ ++ ++ ++// === findRenameLocations === ++// @useAliasesForRename: false ++ ++// === /app.ts === ++// import { /*START PREFIX*/foo as /*RENAME*/[|fooRENAME|] } from './foo/types'; ++// export type fullType = [|fooRENAME|].Full; ++// type namespaceImport = typeof import('./foo/types'); ++// type fullType2 = import('./foo/types').foo.Full; ++ ++ ++ ++// === findRenameLocations === ++// @useAliasesForRename: false ++ ++// === /app.ts === ++// import { /*START PREFIX*/foo as [|fooRENAME|] } from './foo/types'; ++// export type fullType = /*RENAME*/[|fooRENAME|].Full; ++// type namespaceImport = typeof import('./foo/types'); ++// type fullType2 = import('./foo/types').foo.Full; ++ ++ ++ ++// === findRenameLocations === ++// @useAliasesForRename: false ++ ++// === /app.ts === ++// import { [|fooRENAME|] } from './foo/types'; ++// export type fullType = [|fooRENAME|].Full; ++// type namespaceImport = typeof import('./foo/types'); ++// type fullType2 = import('./foo/types')./*RENAME*/[|fooRENAME|].Full; ++ ++// === /foo/types/index.ts === ++// import * as foo from './types'; ++// export { /*START PREFIX*/foo as [|fooRENAME|] }; ++ ++ ++ ++// === findRenameLocations === ++// @useAliasesForRename: false ++ ++// === /foo/types/index.ts === ++// import * as /*RENAME*/[|fooRENAME|] from './types'; ++// export { [|fooRENAME|] as foo/*END SUFFIX*/ }; ++ ++ ++ ++// === findRenameLocations === ++// @useAliasesForRename: false ++ ++// === /app.ts === ++// import { [|fooRENAME|] } from './foo/types'; ++// export type fullType = [|fooRENAME|].Full; ++// type namespaceImport = typeof import('./foo/types'); ++// type fullType2 = import('./foo/types').[|fooRENAME|].Full; ++ ++// === /foo/types/index.ts === ++// import * as foo from './types'; ++// export { /*START PREFIX*/foo as /*RENAME*/[|fooRENAME|] }; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/fourslash/findRenameLocations/findAllRefsRenameImportWithSameName.baseline.jsonc b/testdata/baselines/reference/submodule/fourslash/findRenameLocations/findAllRefsRenameImportWithSameName.baseline.jsonc new file mode 100644 index 000000000..6f42c66f2 --- /dev/null +++ b/testdata/baselines/reference/submodule/fourslash/findRenameLocations/findAllRefsRenameImportWithSameName.baseline.jsonc @@ -0,0 +1,31 @@ +// === findRenameLocations === +// === /a.ts === +// export const /*RENAME*/[|xRENAME|] = 0; + +// === /b.ts === +// import { [|xRENAME|] as [|xRENAME|] } from "./a"; +// [|xRENAME|]; + + + +// === findRenameLocations === +// === /a.ts === +// export const [|xRENAME|] = 0; + +// === /b.ts === +// import { /*RENAME*/[|xRENAME|] as [|xRENAME|] } from "./a"; +// [|xRENAME|]; + + + +// === findRenameLocations === +// === /b.ts === +// import { x as /*RENAME*/[|xRENAME|] } from "./a"; +// [|xRENAME|]; + + + +// === findRenameLocations === +// === /b.ts === +// import { x as [|xRENAME|] } from "./a"; +// /*RENAME*/[|xRENAME|]; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/fourslash/findRenameLocations/findAllRefsRenameImportWithSameName.baseline.jsonc.diff b/testdata/baselines/reference/submodule/fourslash/findRenameLocations/findAllRefsRenameImportWithSameName.baseline.jsonc.diff new file mode 100644 index 000000000..e08c8cb30 --- /dev/null +++ b/testdata/baselines/reference/submodule/fourslash/findRenameLocations/findAllRefsRenameImportWithSameName.baseline.jsonc.diff @@ -0,0 +1,19 @@ +--- old.findAllRefsRenameImportWithSameName.baseline.jsonc ++++ new.findAllRefsRenameImportWithSameName.baseline.jsonc +@@= skipped -2, +2 lines =@@ + // export const /*RENAME*/[|xRENAME|] = 0; + + // === /b.ts === +-// import { [|{| contextId: 1 |}xRENAME|] as [|{| contextId: 2 |}xRENAME|] } from "./a"; ++// import { [|xRENAME|] as [|xRENAME|] } from "./a"; + // [|xRENAME|]; + + +@@= skipped -10, +10 lines =@@ + // export const [|xRENAME|] = 0; + + // === /b.ts === +-// import { /*RENAME*/[|{| contextId: 1 |}xRENAME|] as [|{| contextId: 2 |}xRENAME|] } from "./a"; ++// import { /*RENAME*/[|xRENAME|] as [|xRENAME|] } from "./a"; + // [|xRENAME|]; + diff --git a/testdata/baselines/reference/submodule/fourslash/findRenameLocations/renameDestructuringAssignmentInFor.baseline.jsonc b/testdata/baselines/reference/submodule/fourslash/findRenameLocations/renameDestructuringAssignmentInFor.baseline.jsonc new file mode 100644 index 000000000..a81d106f4 --- /dev/null +++ b/testdata/baselines/reference/submodule/fourslash/findRenameLocations/renameDestructuringAssignmentInFor.baseline.jsonc @@ -0,0 +1,76 @@ +// === findRenameLocations === +// === /renameDestructuringAssignmentInFor.ts === +// interface I { +// /*RENAME*/[|property1RENAME|]: number; +// property2: string; +// } +// var elems: I[]; +// +// var p2: number, property1: number; +// for ({ [|property1RENAME|]: property1/*END SUFFIX*/ } = elems[0]; p2 < 100; p2++) { +// p2 = property1++; +// } +// for ({ [|property1RENAME|]: p2 } = elems[0]; p2 < 100; p2++) { +// } + + + +// === findRenameLocations === +// === /renameDestructuringAssignmentInFor.ts === +// interface I { +// [|property1RENAME|]: number; +// property2: string; +// } +// var elems: I[]; +// +// var p2: number, property1: number; +// for ({ [|property1RENAME|]: property1/*END SUFFIX*/ } = elems[0]; p2 < 100; p2++) { +// p2 = property1++; +// } +// for ({ /*RENAME*/[|property1RENAME|]: p2 } = elems[0]; p2 < 100; p2++) { +// } + + + +// === findRenameLocations === +// === /renameDestructuringAssignmentInFor.ts === +// --- (line: 3) skipped --- +// } +// var elems: I[]; +// +// var p2: number, /*RENAME*/[|property1RENAME|]: number; +// for ({ /*START PREFIX*/property1: [|property1RENAME|] } = elems[0]; p2 < 100; p2++) { +// p2 = [|property1RENAME|]++; +// } +// for ({ property1: p2 } = elems[0]; p2 < 100; p2++) { +// } + + + +// === findRenameLocations === +// === /renameDestructuringAssignmentInFor.ts === +// --- (line: 3) skipped --- +// } +// var elems: I[]; +// +// var p2: number, [|property1RENAME|]: number; +// for ({ /*START PREFIX*/property1: /*RENAME*/[|property1RENAME|] } = elems[0]; p2 < 100; p2++) { +// p2 = [|property1RENAME|]++; +// } +// for ({ property1: p2 } = elems[0]; p2 < 100; p2++) { +// } + + + +// === findRenameLocations === +// === /renameDestructuringAssignmentInFor.ts === +// --- (line: 3) skipped --- +// } +// var elems: I[]; +// +// var p2: number, [|property1RENAME|]: number; +// for ({ /*START PREFIX*/property1: [|property1RENAME|] } = elems[0]; p2 < 100; p2++) { +// p2 = /*RENAME*/[|property1RENAME|]++; +// } +// for ({ property1: p2 } = elems[0]; p2 < 100; p2++) { +// } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/fourslash/findRenameLocations/renameDestructuringAssignmentInForOf.baseline.jsonc b/testdata/baselines/reference/submodule/fourslash/findRenameLocations/renameDestructuringAssignmentInForOf.baseline.jsonc new file mode 100644 index 000000000..b1ef20001 --- /dev/null +++ b/testdata/baselines/reference/submodule/fourslash/findRenameLocations/renameDestructuringAssignmentInForOf.baseline.jsonc @@ -0,0 +1,76 @@ +// === findRenameLocations === +// === /renameDestructuringAssignmentInForOf.ts === +// interface I { +// /*RENAME*/[|property1RENAME|]: number; +// property2: string; +// } +// var elems: I[]; +// +// var property1: number, p2: number; +// for ({ [|property1RENAME|]: property1/*END SUFFIX*/ } of elems) { +// property1++; +// } +// for ({ [|property1RENAME|]: p2 } of elems) { +// } + + + +// === findRenameLocations === +// === /renameDestructuringAssignmentInForOf.ts === +// interface I { +// [|property1RENAME|]: number; +// property2: string; +// } +// var elems: I[]; +// +// var property1: number, p2: number; +// for ({ [|property1RENAME|]: property1/*END SUFFIX*/ } of elems) { +// property1++; +// } +// for ({ /*RENAME*/[|property1RENAME|]: p2 } of elems) { +// } + + + +// === findRenameLocations === +// === /renameDestructuringAssignmentInForOf.ts === +// --- (line: 3) skipped --- +// } +// var elems: I[]; +// +// var /*RENAME*/[|property1RENAME|]: number, p2: number; +// for ({ /*START PREFIX*/property1: [|property1RENAME|] } of elems) { +// [|property1RENAME|]++; +// } +// for ({ property1: p2 } of elems) { +// } + + + +// === findRenameLocations === +// === /renameDestructuringAssignmentInForOf.ts === +// --- (line: 3) skipped --- +// } +// var elems: I[]; +// +// var [|property1RENAME|]: number, p2: number; +// for ({ /*START PREFIX*/property1: /*RENAME*/[|property1RENAME|] } of elems) { +// [|property1RENAME|]++; +// } +// for ({ property1: p2 } of elems) { +// } + + + +// === findRenameLocations === +// === /renameDestructuringAssignmentInForOf.ts === +// --- (line: 3) skipped --- +// } +// var elems: I[]; +// +// var [|property1RENAME|]: number, p2: number; +// for ({ /*START PREFIX*/property1: [|property1RENAME|] } of elems) { +// /*RENAME*/[|property1RENAME|]++; +// } +// for ({ property1: p2 } of elems) { +// } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/fourslash/findRenameLocations/renameDestructuringAssignmentNestedInFor.baseline.jsonc b/testdata/baselines/reference/submodule/fourslash/findRenameLocations/renameDestructuringAssignmentNestedInFor.baseline.jsonc new file mode 100644 index 000000000..f8c661d80 --- /dev/null +++ b/testdata/baselines/reference/submodule/fourslash/findRenameLocations/renameDestructuringAssignmentNestedInFor.baseline.jsonc @@ -0,0 +1,83 @@ +// === findRenameLocations === +// === /renameDestructuringAssignmentNestedInFor.ts === +// interface MultiRobot { +// name: string; +// skills: { +// /*RENAME*/[|primaryRENAME|]: string; +// secondary: string; +// }; +// } +// let multiRobot: MultiRobot, primary: string, secondary: string, primaryA: string, secondaryA: string, i: number; +// for ({ skills: { [|primaryRENAME|]: primaryA, secondary: secondaryA } } = multiRobot, i = 0; i < 1; i++) { +// primaryA; +// } +// for ({ skills: { [|primaryRENAME|]: primary/*END SUFFIX*/, secondary } } = multiRobot, i = 0; i < 1; i++) { +// primary; +// } + + + +// === findRenameLocations === +// === /renameDestructuringAssignmentNestedInFor.ts === +// interface MultiRobot { +// name: string; +// skills: { +// [|primaryRENAME|]: string; +// secondary: string; +// }; +// } +// let multiRobot: MultiRobot, primary: string, secondary: string, primaryA: string, secondaryA: string, i: number; +// for ({ skills: { /*RENAME*/[|primaryRENAME|]: primaryA, secondary: secondaryA } } = multiRobot, i = 0; i < 1; i++) { +// primaryA; +// } +// for ({ skills: { [|primaryRENAME|]: primary/*END SUFFIX*/, secondary } } = multiRobot, i = 0; i < 1; i++) { +// primary; +// } + + + +// === findRenameLocations === +// === /renameDestructuringAssignmentNestedInFor.ts === +// --- (line: 4) skipped --- +// secondary: string; +// }; +// } +// let multiRobot: MultiRobot, /*RENAME*/[|primaryRENAME|]: string, secondary: string, primaryA: string, secondaryA: string, i: number; +// for ({ skills: { primary: primaryA, secondary: secondaryA } } = multiRobot, i = 0; i < 1; i++) { +// primaryA; +// } +// for ({ skills: { /*START PREFIX*/primary: [|primaryRENAME|], secondary } } = multiRobot, i = 0; i < 1; i++) { +// [|primaryRENAME|]; +// } + + + +// === findRenameLocations === +// === /renameDestructuringAssignmentNestedInFor.ts === +// --- (line: 4) skipped --- +// secondary: string; +// }; +// } +// let multiRobot: MultiRobot, [|primaryRENAME|]: string, secondary: string, primaryA: string, secondaryA: string, i: number; +// for ({ skills: { primary: primaryA, secondary: secondaryA } } = multiRobot, i = 0; i < 1; i++) { +// primaryA; +// } +// for ({ skills: { /*START PREFIX*/primary: /*RENAME*/[|primaryRENAME|], secondary } } = multiRobot, i = 0; i < 1; i++) { +// [|primaryRENAME|]; +// } + + + +// === findRenameLocations === +// === /renameDestructuringAssignmentNestedInFor.ts === +// --- (line: 4) skipped --- +// secondary: string; +// }; +// } +// let multiRobot: MultiRobot, [|primaryRENAME|]: string, secondary: string, primaryA: string, secondaryA: string, i: number; +// for ({ skills: { primary: primaryA, secondary: secondaryA } } = multiRobot, i = 0; i < 1; i++) { +// primaryA; +// } +// for ({ skills: { /*START PREFIX*/primary: [|primaryRENAME|], secondary } } = multiRobot, i = 0; i < 1; i++) { +// /*RENAME*/[|primaryRENAME|]; +// } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/fourslash/findRenameLocations/renameDestructuringAssignmentNestedInFor2.baseline.jsonc b/testdata/baselines/reference/submodule/fourslash/findRenameLocations/renameDestructuringAssignmentNestedInFor2.baseline.jsonc new file mode 100644 index 000000000..4ad314848 --- /dev/null +++ b/testdata/baselines/reference/submodule/fourslash/findRenameLocations/renameDestructuringAssignmentNestedInFor2.baseline.jsonc @@ -0,0 +1,83 @@ +// === findRenameLocations === +// === /renameDestructuringAssignmentNestedInFor2.ts === +// interface MultiRobot { +// name: string; +// skills: { +// /*RENAME*/[|primaryRENAME|]: string; +// secondary: string; +// }; +// } +// let multiRobot: MultiRobot, primary: string, secondary: string, primaryA: string, secondaryA: string, i: number; +// for ({ skills: { [|primaryRENAME|]: primaryA, secondary: secondaryA } } = multiRobot, i = 0; i < 1; i++) { +// primaryA; +// } +// for ({ skills: { [|primaryRENAME|]: primary/*END SUFFIX*/, secondary } } = multiRobot, i = 0; i < 1; i++) { +// primary; +// } + + + +// === findRenameLocations === +// === /renameDestructuringAssignmentNestedInFor2.ts === +// interface MultiRobot { +// name: string; +// skills: { +// [|primaryRENAME|]: string; +// secondary: string; +// }; +// } +// let multiRobot: MultiRobot, primary: string, secondary: string, primaryA: string, secondaryA: string, i: number; +// for ({ skills: { /*RENAME*/[|primaryRENAME|]: primaryA, secondary: secondaryA } } = multiRobot, i = 0; i < 1; i++) { +// primaryA; +// } +// for ({ skills: { [|primaryRENAME|]: primary/*END SUFFIX*/, secondary } } = multiRobot, i = 0; i < 1; i++) { +// primary; +// } + + + +// === findRenameLocations === +// === /renameDestructuringAssignmentNestedInFor2.ts === +// --- (line: 4) skipped --- +// secondary: string; +// }; +// } +// let multiRobot: MultiRobot, /*RENAME*/[|primaryRENAME|]: string, secondary: string, primaryA: string, secondaryA: string, i: number; +// for ({ skills: { primary: primaryA, secondary: secondaryA } } = multiRobot, i = 0; i < 1; i++) { +// primaryA; +// } +// for ({ skills: { /*START PREFIX*/primary: [|primaryRENAME|], secondary } } = multiRobot, i = 0; i < 1; i++) { +// [|primaryRENAME|]; +// } + + + +// === findRenameLocations === +// === /renameDestructuringAssignmentNestedInFor2.ts === +// --- (line: 4) skipped --- +// secondary: string; +// }; +// } +// let multiRobot: MultiRobot, [|primaryRENAME|]: string, secondary: string, primaryA: string, secondaryA: string, i: number; +// for ({ skills: { primary: primaryA, secondary: secondaryA } } = multiRobot, i = 0; i < 1; i++) { +// primaryA; +// } +// for ({ skills: { /*START PREFIX*/primary: /*RENAME*/[|primaryRENAME|], secondary } } = multiRobot, i = 0; i < 1; i++) { +// [|primaryRENAME|]; +// } + + + +// === findRenameLocations === +// === /renameDestructuringAssignmentNestedInFor2.ts === +// --- (line: 4) skipped --- +// secondary: string; +// }; +// } +// let multiRobot: MultiRobot, [|primaryRENAME|]: string, secondary: string, primaryA: string, secondaryA: string, i: number; +// for ({ skills: { primary: primaryA, secondary: secondaryA } } = multiRobot, i = 0; i < 1; i++) { +// primaryA; +// } +// for ({ skills: { /*START PREFIX*/primary: [|primaryRENAME|], secondary } } = multiRobot, i = 0; i < 1; i++) { +// /*RENAME*/[|primaryRENAME|]; +// } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/fourslash/findRenameLocations/renameDestructuringAssignmentNestedInForOf.baseline.jsonc b/testdata/baselines/reference/submodule/fourslash/findRenameLocations/renameDestructuringAssignmentNestedInForOf.baseline.jsonc new file mode 100644 index 000000000..f0c86c24b --- /dev/null +++ b/testdata/baselines/reference/submodule/fourslash/findRenameLocations/renameDestructuringAssignmentNestedInForOf.baseline.jsonc @@ -0,0 +1,85 @@ +// === findRenameLocations === +// === /renameDestructuringAssignmentNestedInForOf.ts === +// interface MultiRobot { +// name: string; +// skills: { +// /*RENAME*/[|primaryRENAME|]: string; +// secondary: string; +// }; +// } +// let multiRobots: MultiRobot[]; +// let primary: string, secondary: string, primaryA: string, secondaryA: string; +// for ({ skills: { [|primaryRENAME|]: primaryA, secondary: secondaryA } } of multiRobots) { +// primaryA; +// } +// for ({ skills: { [|primaryRENAME|]: primary/*END SUFFIX*/, secondary } } of multiRobots) { +// primary; +// } + + + +// === findRenameLocations === +// === /renameDestructuringAssignmentNestedInForOf.ts === +// interface MultiRobot { +// name: string; +// skills: { +// [|primaryRENAME|]: string; +// secondary: string; +// }; +// } +// let multiRobots: MultiRobot[]; +// let primary: string, secondary: string, primaryA: string, secondaryA: string; +// for ({ skills: { /*RENAME*/[|primaryRENAME|]: primaryA, secondary: secondaryA } } of multiRobots) { +// primaryA; +// } +// for ({ skills: { [|primaryRENAME|]: primary/*END SUFFIX*/, secondary } } of multiRobots) { +// primary; +// } + + + +// === findRenameLocations === +// === /renameDestructuringAssignmentNestedInForOf.ts === +// --- (line: 5) skipped --- +// }; +// } +// let multiRobots: MultiRobot[]; +// let /*RENAME*/[|primaryRENAME|]: string, secondary: string, primaryA: string, secondaryA: string; +// for ({ skills: { primary: primaryA, secondary: secondaryA } } of multiRobots) { +// primaryA; +// } +// for ({ skills: { /*START PREFIX*/primary: [|primaryRENAME|], secondary } } of multiRobots) { +// [|primaryRENAME|]; +// } + + + +// === findRenameLocations === +// === /renameDestructuringAssignmentNestedInForOf.ts === +// --- (line: 5) skipped --- +// }; +// } +// let multiRobots: MultiRobot[]; +// let [|primaryRENAME|]: string, secondary: string, primaryA: string, secondaryA: string; +// for ({ skills: { primary: primaryA, secondary: secondaryA } } of multiRobots) { +// primaryA; +// } +// for ({ skills: { /*START PREFIX*/primary: /*RENAME*/[|primaryRENAME|], secondary } } of multiRobots) { +// [|primaryRENAME|]; +// } + + + +// === findRenameLocations === +// === /renameDestructuringAssignmentNestedInForOf.ts === +// --- (line: 5) skipped --- +// }; +// } +// let multiRobots: MultiRobot[]; +// let [|primaryRENAME|]: string, secondary: string, primaryA: string, secondaryA: string; +// for ({ skills: { primary: primaryA, secondary: secondaryA } } of multiRobots) { +// primaryA; +// } +// for ({ skills: { /*START PREFIX*/primary: [|primaryRENAME|], secondary } } of multiRobots) { +// /*RENAME*/[|primaryRENAME|]; +// } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/fourslash/findRenameLocations/renameImportOfExportEquals2.baseline.jsonc b/testdata/baselines/reference/submodule/fourslash/findRenameLocations/renameImportOfExportEquals2.baseline.jsonc new file mode 100644 index 000000000..ffc974bef --- /dev/null +++ b/testdata/baselines/reference/submodule/fourslash/findRenameLocations/renameImportOfExportEquals2.baseline.jsonc @@ -0,0 +1,111 @@ +// === findRenameLocations === +// === /renameImportOfExportEquals2.ts === +// declare namespace /*RENAME*/[|NRENAME|] { +// export var x: number; +// } +// declare module "mod" { +// export = [|NRENAME|]; +// } +// declare module "a" { +// import * as O from "mod"; +// --- (line: 9) skipped --- + + + +// === findRenameLocations === +// === /renameImportOfExportEquals2.ts === +// declare namespace [|NRENAME|] { +// export var x: number; +// } +// declare module "mod" { +// export = /*RENAME*/[|NRENAME|]; +// } +// declare module "a" { +// import * as O from "mod"; +// --- (line: 9) skipped --- + + + +// === findRenameLocations === +// === /renameImportOfExportEquals2.ts === +// --- (line: 4) skipped --- +// export = N; +// } +// declare module "a" { +// import * as /*RENAME*/[|ORENAME|] from "mod"; +// export { [|ORENAME|] as P }; // Renaming N here would rename +// } +// declare module "b" { +// import { P as Q } from "a"; +// export const y: typeof Q.x; +// } + + + +// === findRenameLocations === +// === /renameImportOfExportEquals2.ts === +// --- (line: 4) skipped --- +// export = N; +// } +// declare module "a" { +// import * as [|ORENAME|] from "mod"; +// export { /*RENAME*/[|ORENAME|] as P }; // Renaming N here would rename +// } +// declare module "b" { +// import { P as Q } from "a"; +// export const y: typeof Q.x; +// } + + + +// === findRenameLocations === +// === /renameImportOfExportEquals2.ts === +// --- (line: 5) skipped --- +// } +// declare module "a" { +// import * as O from "mod"; +// export { O as /*RENAME*/[|PRENAME|] }; // Renaming N here would rename +// } +// declare module "b" { +// import { [|PRENAME|] as Q } from "a"; +// export const y: typeof Q.x; +// } + + + +// === findRenameLocations === +// === /renameImportOfExportEquals2.ts === +// --- (line: 5) skipped --- +// } +// declare module "a" { +// import * as O from "mod"; +// export { O as [|PRENAME|] }; // Renaming N here would rename +// } +// declare module "b" { +// import { /*RENAME*/[|PRENAME|] as Q } from "a"; +// export const y: typeof Q.x; +// } + + + +// === findRenameLocations === +// === /renameImportOfExportEquals2.ts === +// --- (line: 8) skipped --- +// export { O as P }; // Renaming N here would rename +// } +// declare module "b" { +// import { P as /*RENAME*/[|QRENAME|] } from "a"; +// export const y: typeof [|QRENAME|].x; +// } + + + +// === findRenameLocations === +// === /renameImportOfExportEquals2.ts === +// --- (line: 8) skipped --- +// export { O as P }; // Renaming N here would rename +// } +// declare module "b" { +// import { P as [|QRENAME|] } from "a"; +// export const y: typeof /*RENAME*/[|QRENAME|].x; +// } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/fourslash/findRenameLocations/renameImportOfReExport.baseline.jsonc b/testdata/baselines/reference/submodule/fourslash/findRenameLocations/renameImportOfReExport.baseline.jsonc new file mode 100644 index 000000000..a4b5519d9 --- /dev/null +++ b/testdata/baselines/reference/submodule/fourslash/findRenameLocations/renameImportOfReExport.baseline.jsonc @@ -0,0 +1,51 @@ +// === findRenameLocations === +// === /renameImportOfReExport.ts === +// declare module "a" { +// export class /*RENAME*/[|CRENAME|] {} +// } +// declare module "b" { +// export { [|CRENAME|] as C/*END SUFFIX*/ } from "a"; +// } +// declare module "c" { +// import { C } from "b"; +// export function f(c: C): void; +// } + + + +// === findRenameLocations === +// === /renameImportOfReExport.ts === +// declare module "a" { +// export class C {} +// } +// declare module "b" { +// export { /*START PREFIX*/C as /*RENAME*/[|CRENAME|] } from "a"; +// } +// declare module "c" { +// import { [|CRENAME|] } from "b"; +// export function f(c: [|CRENAME|]): void; +// } + + + +// === findRenameLocations === +// === /renameImportOfReExport.ts === +// --- (line: 4) skipped --- +// export { C } from "a"; +// } +// declare module "c" { +// import { /*START PREFIX*/C as /*RENAME*/[|CRENAME|] } from "b"; +// export function f(c: [|CRENAME|]): void; +// } + + + +// === findRenameLocations === +// === /renameImportOfReExport.ts === +// --- (line: 4) skipped --- +// export { C } from "a"; +// } +// declare module "c" { +// import { /*START PREFIX*/C as [|CRENAME|] } from "b"; +// export function f(c: /*RENAME*/[|CRENAME|]): void; +// } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/fourslash/findRenameLocations/transitiveExportImports.baseline.jsonc b/testdata/baselines/reference/submodule/fourslash/findRenameLocations/transitiveExportImports.baseline.jsonc new file mode 100644 index 000000000..ce046c8fc --- /dev/null +++ b/testdata/baselines/reference/submodule/fourslash/findRenameLocations/transitiveExportImports.baseline.jsonc @@ -0,0 +1,47 @@ +// === findRenameLocations === +// === /a.ts === +// class /*RENAME*/[|ARENAME|] { +// } +// export = [|ARENAME|]; + + + +// === findRenameLocations === +// === /a.ts === +// class [|ARENAME|] { +// } +// export = /*RENAME*/[|ARENAME|]; + + + +// === findRenameLocations === +// === /b.ts === +// export import /*RENAME*/[|bRENAME|] = require('./a'); + +// === /c.ts === +// import b = require('./b'); +// var a = new b.[|bRENAME|](); + + + +// === findRenameLocations === +// === /b.ts === +// export import [|bRENAME|] = require('./a'); + +// === /c.ts === +// import b = require('./b'); +// var a = new b./*RENAME*/[|bRENAME|](); + + + +// === findRenameLocations === +// === /c.ts === +// import /*RENAME*/[|bRENAME|] = require('./b'); +// var a = new [|bRENAME|].b(); + + + +// === findRenameLocations === +// === /c.ts === +// import [|bRENAME|] = require('./b'); +// var a = new /*RENAME*/[|bRENAME|].b(); \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/fourslash/findRenameLocations/transitiveExportImports2.baseline.jsonc b/testdata/baselines/reference/submodule/fourslash/findRenameLocations/transitiveExportImports2.baseline.jsonc new file mode 100644 index 000000000..6a07d4c58 --- /dev/null +++ b/testdata/baselines/reference/submodule/fourslash/findRenameLocations/transitiveExportImports2.baseline.jsonc @@ -0,0 +1,47 @@ +// === findRenameLocations === +// === /a.ts === +// namespace /*RENAME*/[|ARENAME|] { +// export const x = 0; +// } + +// === /b.ts === +// export import B = [|ARENAME|]; +// B.x; + + + +// === findRenameLocations === +// === /a.ts === +// namespace [|ARENAME|] { +// export const x = 0; +// } + +// === /b.ts === +// export import B = /*RENAME*/[|ARENAME|]; +// B.x; + + + +// === findRenameLocations === +// === /b.ts === +// export import /*RENAME*/[|BRENAME|] = A; +// [|BRENAME|].x; + +// === /c.ts === +// import { [|BRENAME|] } from "./b"; + + + +// === findRenameLocations === +// === /b.ts === +// export import [|BRENAME|] = A; +// /*RENAME*/[|BRENAME|].x; + +// === /c.ts === +// import { [|BRENAME|] } from "./b"; + + + +// === findRenameLocations === +// === /c.ts === +// import { /*START PREFIX*/B as /*RENAME*/[|BRENAME|] } from "./b"; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/fourslash/findRenameLocations/transitiveExportImports3.baseline.jsonc b/testdata/baselines/reference/submodule/fourslash/findRenameLocations/transitiveExportImports3.baseline.jsonc new file mode 100644 index 000000000..b323a04ab --- /dev/null +++ b/testdata/baselines/reference/submodule/fourslash/findRenameLocations/transitiveExportImports3.baseline.jsonc @@ -0,0 +1,43 @@ +// === findRenameLocations === +// === /a.ts === +// export function /*RENAME*/[|fRENAME|]() {} + +// === /b.ts === +// export { [|fRENAME|] as g } from "./a"; +// import { [|fRENAME|] } from "./a"; +// import { g } from "./b"; + + + +// === findRenameLocations === +// === /a.ts === +// export function [|fRENAME|]() {} + +// === /b.ts === +// export { /*RENAME*/[|fRENAME|] as g } from "./a"; +// import { [|fRENAME|] } from "./a"; +// import { g } from "./b"; + + + +// === findRenameLocations === +// === /b.ts === +// export { f as g } from "./a"; +// import { /*START PREFIX*/f as /*RENAME*/[|fRENAME|] } from "./a"; +// import { g } from "./b"; + + + +// === findRenameLocations === +// === /b.ts === +// export { f as /*RENAME*/[|gRENAME|] } from "./a"; +// import { f } from "./a"; +// import { [|gRENAME|] } from "./b"; + + + +// === findRenameLocations === +// === /b.ts === +// export { f as g } from "./a"; +// import { f } from "./a"; +// import { /*START PREFIX*/g as /*RENAME*/[|gRENAME|] } from "./b"; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/fourslash/findRenameLocations/tsxRename4.baseline.jsonc b/testdata/baselines/reference/submodule/fourslash/findRenameLocations/tsxRename4.baseline.jsonc new file mode 100644 index 000000000..d8cd4e625 --- /dev/null +++ b/testdata/baselines/reference/submodule/fourslash/findRenameLocations/tsxRename4.baseline.jsonc @@ -0,0 +1,91 @@ +// === findRenameLocations === +// === /file.tsx === +// --- (line: 3) skipped --- +// div: {}; +// } +// } +// class /*RENAME*/[|MyClassRENAME|] {} +// +// <[|MyClassRENAME|]>; +// <[|MyClassRENAME|]/>; +// +//

+ + + +// === findRenameLocations === +// === /file.tsx === +// --- (line: 3) skipped --- +// div: {}; +// } +// } +// class [|MyClassRENAME|] {} +// +// ; +// <[|MyClassRENAME|]/>; +// +//
+ + + +// === findRenameLocations === +// === /file.tsx === +// --- (line: 3) skipped --- +// div: {}; +// } +// } +// class [|MyClassRENAME|] {} +// +// <[|MyClassRENAME|]>; +// <[|MyClassRENAME|]/>; +// +//
+ + + +// === findRenameLocations === +// === /file.tsx === +// --- (line: 3) skipped --- +// div: {}; +// } +// } +// class [|MyClassRENAME|] {} +// +// <[|MyClassRENAME|]>; +// ; +// +//
+ + + +// === findRenameLocations === +// === /file.tsx === +// declare module JSX { +// interface Element {} +// interface IntrinsicElements { +// [|divRENAME|]: {}; +// } +// } +// class MyClass {} +// +// ; +// ; +// +// + + + +// === findRenameLocations === +// === /file.tsx === +// declare module JSX { +// interface Element {} +// interface IntrinsicElements { +// [|divRENAME|]: {}; +// } +// } +// class MyClass {} +// +// ; +// ; +// +// <[|divRENAME|]> \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/fourslash/findRenameLocations/tsxRename4.baseline.jsonc.diff b/testdata/baselines/reference/submodule/fourslash/findRenameLocations/tsxRename4.baseline.jsonc.diff new file mode 100644 index 000000000..8c997b897 --- /dev/null +++ b/testdata/baselines/reference/submodule/fourslash/findRenameLocations/tsxRename4.baseline.jsonc.diff @@ -0,0 +1,135 @@ +--- old.tsxRename4.baseline.jsonc ++++ new.tsxRename4.baseline.jsonc +@@= skipped -5, +5 lines =@@ + // } + // class /*RENAME*/[|MyClassRENAME|] {} + // +-// <[|{| contextId: 1 |}MyClassRENAME|]>; +-// <[|MyClassRENAME|]/>; +-// +-//
+- +- +- +-// === findRenameLocations === +-// === /file.tsx === +-// --- (line: 3) skipped --- +-// div: {}; +-// } +-// } +-// class [|MyClassRENAME|] {} +-// +-// ; +-// <[|MyClassRENAME|]/>; +-// +-//
+- +- +- +-// === findRenameLocations === +-// === /file.tsx === +-// --- (line: 3) skipped --- +-// div: {}; +-// } +-// } +-// class [|MyClassRENAME|] {} +-// +-// <[|{| contextId: 1 |}MyClassRENAME|]>; +-// <[|MyClassRENAME|]/>; +-// +-//
+- +- +- +-// === findRenameLocations === +-// === /file.tsx === +-// --- (line: 3) skipped --- +-// div: {}; +-// } +-// } +-// class [|MyClassRENAME|] {} +-// +-// <[|{| contextId: 1 |}MyClassRENAME|]>; ++// <[|MyClassRENAME|]>; ++// <[|MyClassRENAME|]/>; ++// ++//
++ ++ ++ ++// === findRenameLocations === ++// === /file.tsx === ++// --- (line: 3) skipped --- ++// div: {}; ++// } ++// } ++// class [|MyClassRENAME|] {} ++// ++// ; ++// <[|MyClassRENAME|]/>; ++// ++//
++ ++ ++ ++// === findRenameLocations === ++// === /file.tsx === ++// --- (line: 3) skipped --- ++// div: {}; ++// } ++// } ++// class [|MyClassRENAME|] {} ++// ++// <[|MyClassRENAME|]>; ++// <[|MyClassRENAME|]/>; ++// ++//
++ ++ ++ ++// === findRenameLocations === ++// === /file.tsx === ++// --- (line: 3) skipped --- ++// div: {}; ++// } ++// } ++// class [|MyClassRENAME|] {} ++// ++// <[|MyClassRENAME|]>; + // ; + // + //
++ ++ ++ ++// === findRenameLocations === ++// === /file.tsx === ++// declare module JSX { ++// interface Element {} ++// interface IntrinsicElements { ++// [|divRENAME|]: {}; ++// } ++// } ++// class MyClass {} ++// ++// ; ++// ; ++// ++// ++ ++ ++ ++// === findRenameLocations === ++// === /file.tsx === ++// declare module JSX { ++// interface Element {} ++// interface IntrinsicElements { ++// [|divRENAME|]: {}; ++// } ++// } ++// class MyClass {} ++// ++// ; ++// ; ++// ++// <[|divRENAME|]> \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/fourslash/goToDefinition/asConstRefsNoErrors1.baseline.jsonc b/testdata/baselines/reference/submodule/fourslash/goToDefinition/asConstRefsNoErrors1.baseline.jsonc new file mode 100644 index 000000000..f245e8a34 --- /dev/null +++ b/testdata/baselines/reference/submodule/fourslash/goToDefinition/asConstRefsNoErrors1.baseline.jsonc @@ -0,0 +1,5 @@ +// === goToDefinition === +// === /asConstRefsNoErrors1.ts === +// class Tex { +// type = 'Text' as /*GOTO DEF*/const; +// } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/fourslash/goToDefinition/asConstRefsNoErrors2.baseline.jsonc b/testdata/baselines/reference/submodule/fourslash/goToDefinition/asConstRefsNoErrors2.baseline.jsonc new file mode 100644 index 000000000..cdb223047 --- /dev/null +++ b/testdata/baselines/reference/submodule/fourslash/goToDefinition/asConstRefsNoErrors2.baseline.jsonc @@ -0,0 +1,5 @@ +// === goToDefinition === +// === /asConstRefsNoErrors2.ts === +// class Tex { +// type = 'Text'; +// } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/fourslash/goToDefinition/asConstRefsNoErrors3.baseline.jsonc b/testdata/baselines/reference/submodule/fourslash/goToDefinition/asConstRefsNoErrors3.baseline.jsonc new file mode 100644 index 000000000..82b8b5342 --- /dev/null +++ b/testdata/baselines/reference/submodule/fourslash/goToDefinition/asConstRefsNoErrors3.baseline.jsonc @@ -0,0 +1,5 @@ +// === goToDefinition === +// === /file.js === +// class Tex { +// type = (/** @type {/*GOTO DEF*/const} */'Text'); +// } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/fourslash/goToDefinition/goToDefinitionImportMeta.baseline.jsonc b/testdata/baselines/reference/submodule/fourslash/goToDefinition/goToDefinitionImportMeta.baseline.jsonc new file mode 100644 index 000000000..d2d4f0e09 --- /dev/null +++ b/testdata/baselines/reference/submodule/fourslash/goToDefinition/goToDefinitionImportMeta.baseline.jsonc @@ -0,0 +1,5 @@ +// === goToDefinition === +// === /foo.ts === +// /// +// /// +// import.me/*GOTO DEF*/ta; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/fourslash/goToDefinition/goToDefinitionSignatureAlias.baseline.jsonc b/testdata/baselines/reference/submodule/fourslash/goToDefinition/goToDefinitionSignatureAlias.baseline.jsonc new file mode 100644 index 000000000..e0e7437d4 --- /dev/null +++ b/testdata/baselines/reference/submodule/fourslash/goToDefinition/goToDefinitionSignatureAlias.baseline.jsonc @@ -0,0 +1,251 @@ +// === goToDefinition === +// === /a.tsx === +// <|function [|f|]() {}|> +// const g = f; +// const h = g; +// /*GOTO DEF*/f(); +// g(); +// h(); +// const i = () => 0; +// --- (line: 8) skipped --- + + + +// === goToDefinition === +// === /a.tsx === +// <|function [|f|]() {}|> +// <|const [|g|] = f;|> +// const h = g; +// f(); +// /*GOTO DEF*/g(); +// h(); +// const i = () => 0; +// const iFn = function () { return 0; }; +// --- (line: 9) skipped --- + + + +// === goToDefinition === +// === /a.tsx === +// <|function [|f|]() {}|> +// const g = f; +// <|const [|h|] = g;|> +// f(); +// g(); +// /*GOTO DEF*/h(); +// const i = () => 0; +// const iFn = function () { return 0; }; +// const j = i; +// --- (line: 10) skipped --- + + + +// === goToDefinition === +// === /a.tsx === +// --- (line: 3) skipped --- +// f(); +// g(); +// h(); +// <|const [|i|] = () => 0;|> +// const iFn = function () { return 0; }; +// const j = i; +// /*GOTO DEF*/i(); +// iFn(); +// j(); +// const o = { m: () => 0 }; +// --- (line: 14) skipped --- + + + +// === goToDefinition === +// === /a.tsx === +// --- (line: 4) skipped --- +// g(); +// h(); +// const i = () => 0; +// <|const [|iFn|] = function () { return 0; };|> +// const j = i; +// i(); +// /*GOTO DEF*/iFn(); +// j(); +// const o = { m: () => 0 }; +// o.m(); +// --- (line: 15) skipped --- + + + +// === goToDefinition === +// === /a.tsx === +// --- (line: 3) skipped --- +// f(); +// g(); +// h(); +// const [|i|] = <|() => 0|>; +// const iFn = function () { return 0; }; +// <|const [|j|] = i;|> +// i(); +// iFn(); +// /*GOTO DEF*/j(); +// const o = { m: () => 0 }; +// o.m(); +// const oFn = { mFn: function () { return 0; } }; +// --- (line: 16) skipped --- + + + +// === goToDefinition === +// === /a.tsx === +// --- (line: 9) skipped --- +// i(); +// iFn(); +// j(); +// const o = { <|[|m|]: () => 0|> }; +// o./*GOTO DEF*/m(); +// const oFn = { mFn: function () { return 0; } }; +// oFn.mFn(); +// class Component { constructor(props: {}) {} } +// --- (line: 18) skipped --- + + + +// === goToDefinition === +// === /a.tsx === +// --- (line: 11) skipped --- +// j(); +// const o = { m: () => 0 }; +// o.m(); +// const oFn = { <|[|mFn|]: function () { return 0; }|> }; +// oFn./*GOTO DEF*/mFn(); +// class Component { constructor(props: {}) {} } +// type ComponentClass = new () => Component; +// interface ComponentClass2 { new(): Component; } +// --- (line: 20) skipped --- + + + +// === goToDefinition === +// === /a.tsx === +// --- (line: 13) skipped --- +// o.m(); +// const oFn = { mFn: function () { return 0; } }; +// oFn.mFn(); +// class Component { [|constructor(props: {}) {}|] } +// type ComponentClass = new () => Component; +// interface ComponentClass2 { new(): Component; } +// +// <|class [|MyComponent|] extends Component {}|> +// ; +// new MyComponent({}); +// +// declare const MyComponent2: ComponentClass; +// --- (line: 26) skipped --- + + + +// === goToDefinition === +// === /a.tsx === +// --- (line: 13) skipped --- +// o.m(); +// const oFn = { mFn: function () { return 0; } }; +// oFn.mFn(); +// class Component { [|constructor(props: {}) {}|] } +// type ComponentClass = new () => Component; +// interface ComponentClass2 { new(): Component; } +// +// <|class [|MyComponent|] extends Component {}|> +// ; +// new /*GOTO DEF*/MyComponent({}); +// +// declare const MyComponent2: ComponentClass; +// ; +// --- (line: 27) skipped --- + + + +// === goToDefinition === +// === /a.tsx === +// --- (line: 14) skipped --- +// const oFn = { mFn: function () { return 0; } }; +// oFn.mFn(); +// class Component { constructor(props: {}) {} } +// type ComponentClass = [|new () => Component|]; +// interface ComponentClass2 { new(): Component; } +// +// class MyComponent extends Component {} +// ; +// new MyComponent({}); +// +// <|declare const [|MyComponent2|]: ComponentClass;|> +// ; +// new MyComponent2(); +// +// declare const MyComponent3: ComponentClass2; +// ; +// new MyComponent3(); + + + +// === goToDefinition === +// === /a.tsx === +// --- (line: 14) skipped --- +// const oFn = { mFn: function () { return 0; } }; +// oFn.mFn(); +// class Component { constructor(props: {}) {} } +// type ComponentClass = [|new () => Component|]; +// interface ComponentClass2 { new(): Component; } +// +// class MyComponent extends Component {} +// ; +// new MyComponent({}); +// +// <|declare const [|MyComponent2|]: ComponentClass;|> +// ; +// new /*GOTO DEF*/MyComponent2(); +// +// declare const MyComponent3: ComponentClass2; +// ; +// new MyComponent3(); + + + +// === goToDefinition === +// === /a.tsx === +// --- (line: 15) skipped --- +// oFn.mFn(); +// class Component { constructor(props: {}) {} } +// type ComponentClass = new () => Component; +// interface ComponentClass2 { [|new(): Component;|] } +// +// class MyComponent extends Component {} +// ; +// new MyComponent({}); +// +// declare const MyComponent2: ComponentClass; +// ; +// new MyComponent2(); +// +// <|declare const [|MyComponent3|]: ComponentClass2;|> +// ; +// new MyComponent3(); + + + +// === goToDefinition === +// === /a.tsx === +// --- (line: 15) skipped --- +// oFn.mFn(); +// class Component { constructor(props: {}) {} } +// type ComponentClass = new () => Component; +// interface ComponentClass2 { [|new(): Component;|] } +// +// class MyComponent extends Component {} +// ; +// new MyComponent({}); +// +// declare const MyComponent2: ComponentClass; +// ; +// new MyComponent2(); +// +// <|declare const [|MyComponent3|]: ComponentClass2;|> +// ; +// new /*GOTO DEF*/MyComponent3(); \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/fourslash/goToDefinition/goToDefinitionSignatureAlias.baseline.jsonc.diff b/testdata/baselines/reference/submodule/fourslash/goToDefinition/goToDefinitionSignatureAlias.baseline.jsonc.diff new file mode 100644 index 000000000..5da7cc7d0 --- /dev/null +++ b/testdata/baselines/reference/submodule/fourslash/goToDefinition/goToDefinitionSignatureAlias.baseline.jsonc.diff @@ -0,0 +1,86 @@ +--- old.goToDefinitionSignatureAlias.baseline.jsonc ++++ new.goToDefinitionSignatureAlias.baseline.jsonc +@@= skipped -45, +45 lines =@@ + // f(); + // g(); + // h(); +-// const [|i|] = <|() => 0|>; ++// <|const [|i|] = () => 0;|> + // const iFn = function () { return 0; }; + // const j = i; + // /*GOTO DEF*/i(); +@@= skipped -17, +17 lines =@@ + // g(); + // h(); + // const i = () => 0; +-// const [|iFn|] = <|function () { return 0; }|>; ++// <|const [|iFn|] = function () { return 0; };|> + // const j = i; + // i(); + // /*GOTO DEF*/iFn(); +@@= skipped -36, +36 lines =@@ + // i(); + // iFn(); + // j(); +-// const o = { [|m|]: <|() => 0|> }; ++// const o = { <|[|m|]: () => 0|> }; + // o./*GOTO DEF*/m(); + // const oFn = { mFn: function () { return 0; } }; + // oFn.mFn(); +@@= skipped -15, +15 lines =@@ + // j(); + // const o = { m: () => 0 }; + // o.m(); +-// const oFn = { [|mFn|]: <|function () { return 0; }|> }; ++// const oFn = { <|[|mFn|]: function () { return 0; }|> }; + // oFn./*GOTO DEF*/mFn(); + // class Component { constructor(props: {}) {} } + // type ComponentClass = new () => Component; +@@= skipped -11, +11 lines =@@ + + // === goToDefinition === + // === /a.tsx === +-// --- (line: 17) skipped --- ++// --- (line: 13) skipped --- ++// o.m(); ++// const oFn = { mFn: function () { return 0; } }; ++// oFn.mFn(); ++// class Component { [|constructor(props: {}) {}|] } + // type ComponentClass = new () => Component; + // interface ComponentClass2 { new(): Component; } + // +@@= skipped -35, +39 lines =@@ + + // === goToDefinition === + // === /a.tsx === +-// --- (line: 21) skipped --- ++// --- (line: 14) skipped --- ++// const oFn = { mFn: function () { return 0; } }; ++// oFn.mFn(); ++// class Component { constructor(props: {}) {} } ++// type ComponentClass = [|new () => Component|]; ++// interface ComponentClass2 { new(): Component; } ++// ++// class MyComponent extends Component {} + // ; + // new MyComponent({}); + // +@@= skipped -39, +46 lines =@@ + + // === goToDefinition === + // === /a.tsx === +-// --- (line: 25) skipped --- ++// --- (line: 15) skipped --- ++// oFn.mFn(); ++// class Component { constructor(props: {}) {} } ++// type ComponentClass = new () => Component; ++// interface ComponentClass2 { [|new(): Component;|] } ++// ++// class MyComponent extends Component {} ++// ; ++// new MyComponent({}); ++// ++// declare const MyComponent2: ComponentClass; + // ; + // new MyComponent2(); + // \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/fourslash/goToDefinition/tsxGoToDefinitionClassInDifferentFile.baseline.jsonc b/testdata/baselines/reference/submodule/fourslash/goToDefinition/tsxGoToDefinitionClassInDifferentFile.baseline.jsonc new file mode 100644 index 000000000..4851414df --- /dev/null +++ b/testdata/baselines/reference/submodule/fourslash/goToDefinition/tsxGoToDefinitionClassInDifferentFile.baseline.jsonc @@ -0,0 +1,7 @@ +// === goToDefinition === +// === /C.tsx === +// <|export default class [|C|] {}|> + +// === /a.tsx === +// import C from "./C"; +// const foo = ; \ No newline at end of file diff --git a/testdata/baselines/reference/tsbuild/javascriptProjectEmit/loads-js-based-projects-and-emits-them-correctly.js b/testdata/baselines/reference/tsbuild/javascriptProjectEmit/loads-js-based-projects-and-emits-them-correctly.js index 89ed65517..0bb192939 100644 --- a/testdata/baselines/reference/tsbuild/javascriptProjectEmit/loads-js-based-projects-and-emits-them-correctly.js +++ b/testdata/baselines/reference/tsbuild/javascriptProjectEmit/loads-js-based-projects-and-emits-them-correctly.js @@ -127,6 +127,10 @@ Errors Files export type Nominal = T & { [Symbol.species]: Name; }; +/** + * @template T, Name + * @typedef {T & {[Symbol.species]: Name}} Nominal + */ declare const _default: {}; export = _default; @@ -138,7 +142,7 @@ export = _default; module.exports = {}; //// [/home/src/workspaces/lib/common/tsconfig.tsbuildinfo] *new* -{"version":"FakeTSVersion","root":[2],"fileNames":["lib.d.ts","../../solution/common/nominal.js"],"fileInfos":[{"version":"24b4796cd50d1a9aabad1583878c494d-/// \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 {}\ninterface SymbolConstructor {\n readonly species: symbol;\n (desc?: string | number): symbol;\n for(name: string): symbol;\n readonly toStringTag: symbol;\n}\ndeclare var Symbol: SymbolConstructor;\ninterface Symbol {\n readonly [Symbol.toStringTag]: string;\n}\ndeclare const console: { log(msg: any): void; };","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"a19075dfba5b2d593b761ed8d8cd526f-/**\n * @template T, Name\n * @typedef {T & {[Symbol.species]: Name}} Nominal\n */\nmodule.exports = {};","signature":"de751e2539eb6f12413f7067ad0a0ef5-export type Nominal = T & {\n [Symbol.species]: Name;\n};\ndeclare const _default: {};\nexport = _default;\n","impliedNodeFormat":1}],"options":{"allowJs":true,"checkJs":true,"composite":true,"declaration":true,"outDir":"..","rootDir":"../../solution","skipLibCheck":true},"latestChangedDtsFile":"./nominal.d.ts"} +{"version":"FakeTSVersion","root":[2],"fileNames":["lib.d.ts","../../solution/common/nominal.js"],"fileInfos":[{"version":"24b4796cd50d1a9aabad1583878c494d-/// \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 {}\ninterface SymbolConstructor {\n readonly species: symbol;\n (desc?: string | number): symbol;\n for(name: string): symbol;\n readonly toStringTag: symbol;\n}\ndeclare var Symbol: SymbolConstructor;\ninterface Symbol {\n readonly [Symbol.toStringTag]: string;\n}\ndeclare const console: { log(msg: any): void; };","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"a19075dfba5b2d593b761ed8d8cd526f-/**\n * @template T, Name\n * @typedef {T & {[Symbol.species]: Name}} Nominal\n */\nmodule.exports = {};","signature":"eb9c2f87f514168dc4c3c145170b7b2f-export type Nominal = T & {\n [Symbol.species]: Name;\n};\n/**\n * @template T, Name\n * @typedef {T & {[Symbol.species]: Name}} Nominal\n */\ndeclare const _default: {};\nexport = _default;\n","impliedNodeFormat":1}],"options":{"allowJs":true,"checkJs":true,"composite":true,"declaration":true,"outDir":"..","rootDir":"../../solution","skipLibCheck":true},"latestChangedDtsFile":"./nominal.d.ts"} //// [/home/src/workspaces/lib/common/tsconfig.tsbuildinfo.readable.baseline.txt] *new* { "version": "FakeTSVersion", @@ -170,11 +174,11 @@ module.exports = {}; { "fileName": "../../solution/common/nominal.js", "version": "a19075dfba5b2d593b761ed8d8cd526f-/**\n * @template T, Name\n * @typedef {T & {[Symbol.species]: Name}} Nominal\n */\nmodule.exports = {};", - "signature": "de751e2539eb6f12413f7067ad0a0ef5-export type Nominal = T & {\n [Symbol.species]: Name;\n};\ndeclare const _default: {};\nexport = _default;\n", + "signature": "eb9c2f87f514168dc4c3c145170b7b2f-export type Nominal = T & {\n [Symbol.species]: Name;\n};\n/**\n * @template T, Name\n * @typedef {T & {[Symbol.species]: Name}} Nominal\n */\ndeclare const _default: {};\nexport = _default;\n", "impliedNodeFormat": "CommonJS", "original": { "version": "a19075dfba5b2d593b761ed8d8cd526f-/**\n * @template T, Name\n * @typedef {T & {[Symbol.species]: Name}} Nominal\n */\nmodule.exports = {};", - "signature": "de751e2539eb6f12413f7067ad0a0ef5-export type Nominal = T & {\n [Symbol.species]: Name;\n};\ndeclare const _default: {};\nexport = _default;\n", + "signature": "eb9c2f87f514168dc4c3c145170b7b2f-export type Nominal = T & {\n [Symbol.species]: Name;\n};\n/**\n * @template T, Name\n * @typedef {T & {[Symbol.species]: Name}} Nominal\n */\ndeclare const _default: {};\nexport = _default;\n", "impliedNodeFormat": 1 } } @@ -189,7 +193,7 @@ module.exports = {}; "skipLibCheck": true }, "latestChangedDtsFile": "./nominal.d.ts", - "size": 1434 + "size": 1518 } //// [/home/src/workspaces/lib/sub-project-2/index.d.ts] *new* declare const variable: { @@ -217,7 +221,7 @@ function getVar() { } //// [/home/src/workspaces/lib/sub-project-2/tsconfig.tsbuildinfo] *new* -{"version":"FakeTSVersion","root":[4],"fileNames":["lib.d.ts","../common/nominal.d.ts","../sub-project/index.d.ts","../../solution/sub-project-2/index.js"],"fileInfos":[{"version":"24b4796cd50d1a9aabad1583878c494d-/// \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 {}\ninterface SymbolConstructor {\n readonly species: symbol;\n (desc?: string | number): symbol;\n for(name: string): symbol;\n readonly toStringTag: symbol;\n}\ndeclare var Symbol: SymbolConstructor;\ninterface Symbol {\n readonly [Symbol.toStringTag]: string;\n}\ndeclare const console: { log(msg: any): void; };","affectsGlobalScope":true,"impliedNodeFormat":1},"de751e2539eb6f12413f7067ad0a0ef5-export type Nominal = T & {\n [Symbol.species]: Name;\n};\ndeclare const _default: {};\nexport = _default;\n","225285a996cc5c4120877a377890d79e-import { Nominal } from '../common/nominal';\nexport type MyNominal = Nominal;\n/**\n * @typedef {Nominal} MyNominal\n */ \n",{"version":"db2a90e082fd17d65127bda69975a727-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}","signature":"f2cd6630b2dfa04d1fc92179f15d1647-declare const variable: {\n key: Nominal;\n};\n/**\n * @return {keyof typeof variable}\n */\nexport declare function getVar(): keyof typeof variable;\nexport {};\n","impliedNodeFormat":1}],"fileIdsList":[[2],[3]],"options":{"allowJs":true,"checkJs":true,"composite":true,"declaration":true,"outDir":"..","rootDir":"../../solution","skipLibCheck":true},"referencedMap":[[3,1],[4,2]],"semanticDiagnosticsPerFile":[[4,[{"pos":9,"end":18,"code":18042,"category":1,"messageKey":"_0_is_a_type_and_cannot_be_imported_in_JavaScript_files_Use_1_in_a_JSDoc_type_annotation_18042","messageArgs":["MyNominal","import(\"../sub-project/index\").MyNominal"]}]]],"latestChangedDtsFile":"./index.d.ts"} +{"version":"FakeTSVersion","root":[4],"fileNames":["lib.d.ts","../common/nominal.d.ts","../sub-project/index.d.ts","../../solution/sub-project-2/index.js"],"fileInfos":[{"version":"24b4796cd50d1a9aabad1583878c494d-/// \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 {}\ninterface SymbolConstructor {\n readonly species: symbol;\n (desc?: string | number): symbol;\n for(name: string): symbol;\n readonly toStringTag: symbol;\n}\ndeclare var Symbol: SymbolConstructor;\ninterface Symbol {\n readonly [Symbol.toStringTag]: string;\n}\ndeclare const console: { log(msg: any): void; };","affectsGlobalScope":true,"impliedNodeFormat":1},"eb9c2f87f514168dc4c3c145170b7b2f-export type Nominal = T & {\n [Symbol.species]: Name;\n};\n/**\n * @template T, Name\n * @typedef {T & {[Symbol.species]: Name}} Nominal\n */\ndeclare const _default: {};\nexport = _default;\n","225285a996cc5c4120877a377890d79e-import { Nominal } from '../common/nominal';\nexport type MyNominal = Nominal;\n/**\n * @typedef {Nominal} MyNominal\n */ \n",{"version":"db2a90e082fd17d65127bda69975a727-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}","signature":"f2cd6630b2dfa04d1fc92179f15d1647-declare const variable: {\n key: Nominal;\n};\n/**\n * @return {keyof typeof variable}\n */\nexport declare function getVar(): keyof typeof variable;\nexport {};\n","impliedNodeFormat":1}],"fileIdsList":[[2],[3]],"options":{"allowJs":true,"checkJs":true,"composite":true,"declaration":true,"outDir":"..","rootDir":"../../solution","skipLibCheck":true},"referencedMap":[[3,1],[4,2]],"semanticDiagnosticsPerFile":[[4,[{"pos":9,"end":18,"code":18042,"category":1,"messageKey":"_0_is_a_type_and_cannot_be_imported_in_JavaScript_files_Use_1_in_a_JSDoc_type_annotation_18042","messageArgs":["MyNominal","import(\"../sub-project/index\").MyNominal"]}]]],"latestChangedDtsFile":"./index.d.ts"} //// [/home/src/workspaces/lib/sub-project-2/tsconfig.tsbuildinfo.readable.baseline.txt] *new* { "version": "FakeTSVersion", @@ -250,8 +254,8 @@ function getVar() { }, { "fileName": "../common/nominal.d.ts", - "version": "de751e2539eb6f12413f7067ad0a0ef5-export type Nominal = T & {\n [Symbol.species]: Name;\n};\ndeclare const _default: {};\nexport = _default;\n", - "signature": "de751e2539eb6f12413f7067ad0a0ef5-export type Nominal = T & {\n [Symbol.species]: Name;\n};\ndeclare const _default: {};\nexport = _default;\n", + "version": "eb9c2f87f514168dc4c3c145170b7b2f-export type Nominal = T & {\n [Symbol.species]: Name;\n};\n/**\n * @template T, Name\n * @typedef {T & {[Symbol.species]: Name}} Nominal\n */\ndeclare const _default: {};\nexport = _default;\n", + "signature": "eb9c2f87f514168dc4c3c145170b7b2f-export type Nominal = T & {\n [Symbol.species]: Name;\n};\n/**\n * @template T, Name\n * @typedef {T & {[Symbol.species]: Name}} Nominal\n */\ndeclare const _default: {};\nexport = _default;\n", "impliedNodeFormat": "CommonJS" }, { @@ -316,7 +320,7 @@ function getVar() { ] ], "latestChangedDtsFile": "./index.d.ts", - "size": 2350 + "size": 2434 } //// [/home/src/workspaces/lib/sub-project/index.d.ts] *new* import { Nominal } from '../common/nominal'; @@ -334,7 +338,7 @@ const nominal_1 = require("../common/nominal"); */ //// [/home/src/workspaces/lib/sub-project/tsconfig.tsbuildinfo] *new* -{"version":"FakeTSVersion","root":[3],"fileNames":["lib.d.ts","../common/nominal.d.ts","../../solution/sub-project/index.js"],"fileInfos":[{"version":"24b4796cd50d1a9aabad1583878c494d-/// \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 {}\ninterface SymbolConstructor {\n readonly species: symbol;\n (desc?: string | number): symbol;\n for(name: string): symbol;\n readonly toStringTag: symbol;\n}\ndeclare var Symbol: SymbolConstructor;\ninterface Symbol {\n readonly [Symbol.toStringTag]: string;\n}\ndeclare const console: { log(msg: any): void; };","affectsGlobalScope":true,"impliedNodeFormat":1},"de751e2539eb6f12413f7067ad0a0ef5-export type Nominal = T & {\n [Symbol.species]: Name;\n};\ndeclare const _default: {};\nexport = _default;\n",{"version":"00b7836eaf1e026f7764b7be6efcc8f5-import { Nominal } from '../common/nominal';\n\n/**\n * @typedef {Nominal} MyNominal\n */","signature":"225285a996cc5c4120877a377890d79e-import { Nominal } from '../common/nominal';\nexport type MyNominal = Nominal;\n/**\n * @typedef {Nominal} MyNominal\n */ \n","impliedNodeFormat":1}],"fileIdsList":[[2]],"options":{"allowJs":true,"checkJs":true,"composite":true,"declaration":true,"outDir":"..","rootDir":"../../solution","skipLibCheck":true},"referencedMap":[[3,1]],"semanticDiagnosticsPerFile":[[3,[{"pos":9,"end":16,"code":2305,"category":1,"messageKey":"Module_0_has_no_exported_member_1_2305","messageArgs":["\"../../lib/common/nominal\"","Nominal"]}]]],"latestChangedDtsFile":"./index.d.ts"} +{"version":"FakeTSVersion","root":[3],"fileNames":["lib.d.ts","../common/nominal.d.ts","../../solution/sub-project/index.js"],"fileInfos":[{"version":"24b4796cd50d1a9aabad1583878c494d-/// \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 {}\ninterface SymbolConstructor {\n readonly species: symbol;\n (desc?: string | number): symbol;\n for(name: string): symbol;\n readonly toStringTag: symbol;\n}\ndeclare var Symbol: SymbolConstructor;\ninterface Symbol {\n readonly [Symbol.toStringTag]: string;\n}\ndeclare const console: { log(msg: any): void; };","affectsGlobalScope":true,"impliedNodeFormat":1},"eb9c2f87f514168dc4c3c145170b7b2f-export type Nominal = T & {\n [Symbol.species]: Name;\n};\n/**\n * @template T, Name\n * @typedef {T & {[Symbol.species]: Name}} Nominal\n */\ndeclare const _default: {};\nexport = _default;\n",{"version":"00b7836eaf1e026f7764b7be6efcc8f5-import { Nominal } from '../common/nominal';\n\n/**\n * @typedef {Nominal} MyNominal\n */","signature":"225285a996cc5c4120877a377890d79e-import { Nominal } from '../common/nominal';\nexport type MyNominal = Nominal;\n/**\n * @typedef {Nominal} MyNominal\n */ \n","impliedNodeFormat":1}],"fileIdsList":[[2]],"options":{"allowJs":true,"checkJs":true,"composite":true,"declaration":true,"outDir":"..","rootDir":"../../solution","skipLibCheck":true},"referencedMap":[[3,1]],"semanticDiagnosticsPerFile":[[3,[{"pos":9,"end":16,"code":2305,"category":1,"messageKey":"Module_0_has_no_exported_member_1_2305","messageArgs":["\"../../lib/common/nominal\"","Nominal"]}]]],"latestChangedDtsFile":"./index.d.ts"} //// [/home/src/workspaces/lib/sub-project/tsconfig.tsbuildinfo.readable.baseline.txt] *new* { "version": "FakeTSVersion", @@ -366,8 +370,8 @@ const nominal_1 = require("../common/nominal"); }, { "fileName": "../common/nominal.d.ts", - "version": "de751e2539eb6f12413f7067ad0a0ef5-export type Nominal = T & {\n [Symbol.species]: Name;\n};\ndeclare const _default: {};\nexport = _default;\n", - "signature": "de751e2539eb6f12413f7067ad0a0ef5-export type Nominal = T & {\n [Symbol.species]: Name;\n};\ndeclare const _default: {};\nexport = _default;\n", + "version": "eb9c2f87f514168dc4c3c145170b7b2f-export type Nominal = T & {\n [Symbol.species]: Name;\n};\n/**\n * @template T, Name\n * @typedef {T & {[Symbol.species]: Name}} Nominal\n */\ndeclare const _default: {};\nexport = _default;\n", + "signature": "eb9c2f87f514168dc4c3c145170b7b2f-export type Nominal = T & {\n [Symbol.species]: Name;\n};\n/**\n * @template T, Name\n * @typedef {T & {[Symbol.species]: Name}} Nominal\n */\ndeclare const _default: {};\nexport = _default;\n", "impliedNodeFormat": "CommonJS" }, { @@ -420,7 +424,7 @@ const nominal_1 = require("../common/nominal"); ] ], "latestChangedDtsFile": "./index.d.ts", - "size": 1904 + "size": 1988 } common/tsconfig.json:: diff --git a/testdata/tests/cases/compiler/jsdocCommentDefaultExport.ts b/testdata/tests/cases/compiler/jsdocCommentDefaultExport.ts new file mode 100644 index 000000000..24e587ac6 --- /dev/null +++ b/testdata/tests/cases/compiler/jsdocCommentDefaultExport.ts @@ -0,0 +1,29 @@ +// @declaration: true +// @strict: true +// @module: esnext, commonjs + +// @filename: exportDefaultObject.ts +/** Object comment */ +export default { + fn() {} +} + +// @filename: exportDefaultFunction.ts +/** Function comment */ +export default function() { + return 42; +} + +// @filename: exportDefaultClass.ts +/** Class comment */ +export default class { + method() {} +} + +// @filename: exportDefaultLiteral.ts +/** Literal comment */ +export default 42; + +// @filename: exportDefaultNull.ts +/** Null comment */ +export default null; diff --git a/testdata/tests/cases/compiler/nodeModulesPackageImportsRootWildcard.ts b/testdata/tests/cases/compiler/nodeModulesPackageImportsRootWildcard.ts new file mode 100644 index 000000000..5508eaab2 --- /dev/null +++ b/testdata/tests/cases/compiler/nodeModulesPackageImportsRootWildcard.ts @@ -0,0 +1,42 @@ +// @module: nodenext +// @declaration: true +// @traceResolution: true +// @filename: package.json +{ + "name": "package", + "private": true, + "type": "module", + "imports": { + "#/*": "./src/*" + } +} +// @filename: src/foo.ts +export const foo = "foo"; +// @filename: src/features/bar.ts +export const bar = "bar"; +// @filename: src/nested/deep/baz.ts +export const baz = "baz"; +// @filename: index.ts +// esm format file +import { foo } from "#/foo.js"; +import { bar } from "#/features/bar.js"; +import { baz } from "#/nested/deep/baz.js"; +foo; +bar; +baz; +// @filename: index.mts +// esm format file +import { foo } from "#/foo.js"; +import { bar } from "#/features/bar.js"; +import { baz } from "#/nested/deep/baz.js"; +foo; +bar; +baz; +// @filename: index.cts +// cjs format file +import { foo } from "#/foo.js"; +import { bar } from "#/features/bar.js"; +import { baz } from "#/nested/deep/baz.js"; +foo; +bar; +baz; diff --git a/testdata/tests/cases/compiler/nodeModulesPackageImportsRootWildcardNode16.ts b/testdata/tests/cases/compiler/nodeModulesPackageImportsRootWildcardNode16.ts new file mode 100644 index 000000000..edd2b10c5 --- /dev/null +++ b/testdata/tests/cases/compiler/nodeModulesPackageImportsRootWildcardNode16.ts @@ -0,0 +1,18 @@ +// @module: node16 +// @declaration: true +// @traceResolution: true +// @filename: package.json +{ + "name": "package", + "private": true, + "type": "module", + "imports": { + "#/*": "./src/*" + } +} +// @filename: src/foo.ts +export const foo = "foo"; +// @filename: index.ts +// esm format file +import { foo } from "#/foo.js"; +foo;