Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 1 addition & 1 deletion _submodules/TypeScript
Submodule TypeScript updated 2577 files
6 changes: 1 addition & 5 deletions internal/ast/ast.go
Original file line number Diff line number Diff line change
Expand Up @@ -2353,9 +2353,6 @@ func IsArrayLiteralOrObjectLiteralDestructuringPattern(node *Node) bool {

func accessKind(node *Node) AccessKind {
parent := node.Parent
if parent == nil {
return AccessKindRead
}
switch parent.Kind {
case KindParenthesizedExpression:
return accessKind(parent)
Expand Down Expand Up @@ -2407,9 +2404,8 @@ func accessKind(node *Node) AccessKind {
return AccessKindWrite
}
return AccessKindRead
default:
return AccessKindRead
}
return AccessKindRead
}

func reverseAccessKind(a AccessKind) AccessKind {
Expand Down
4 changes: 2 additions & 2 deletions internal/ast/utilities.go
Original file line number Diff line number Diff line change
Expand Up @@ -571,7 +571,7 @@ func IsClassElement(node *Node) bool {
return false
}

func IsMethodOrAccessor(node *Node) bool {
func isMethodOrAccessor(node *Node) bool {
switch node.Kind {
case KindMethodDeclaration, KindGetAccessor, KindSetAccessor:
return true
Expand All @@ -580,7 +580,7 @@ func IsMethodOrAccessor(node *Node) bool {
}

func IsPrivateIdentifierClassElementDeclaration(node *Node) bool {
return (IsPropertyDeclaration(node) || IsMethodOrAccessor(node)) && IsPrivateIdentifier(node.Name())
return (IsPropertyDeclaration(node) || isMethodOrAccessor(node)) && IsPrivateIdentifier(node.Name())
}

func IsObjectLiteralOrClassExpressionMethodOrAccessor(node *Node) bool {
Expand Down
18 changes: 6 additions & 12 deletions internal/checker/checker.go
Original file line number Diff line number Diff line change
Expand Up @@ -19101,9 +19101,11 @@ func (c *Checker) getSignaturesOfSymbol(symbol *ast.Symbol) []*Signature {
}
// If this is a function or method declaration, get the signature from the @type tag for the sake of optional parameters.
// Exclude contextually-typed kinds because we already apply the @type tag to the context, plus applying it here to the initializer would suppress checks that the two are compatible.
if sig := c.getSignatureOfFullSignatureType(decl); sig != nil {
result = append(result, sig)
continue
if ast.IsFunctionExpressionOrArrowFunction(decl) || ast.IsObjectLiteralMethod(decl) {
if sig := c.getSignatureOfFullSignatureType(decl); sig != nil {
result = append(result, sig)
continue
}
}
result = append(result, c.getSignatureFromDeclaration(decl))
}
Expand All @@ -19121,14 +19123,6 @@ func (c *Checker) getSignatureFromDeclaration(declaration *ast.Node) *Signature
minArgumentCount := 0
hasThisParameter := false
iife := ast.GetImmediatelyInvokedFunctionExpression(declaration)
isUntypedSignatureInJSFile := iife == nil &&
ast.IsInJSFile(declaration) &&
(ast.IsFunctionExpression(declaration) || ast.IsArrowFunction(declaration) || ast.IsMethodOrAccessor(declaration) || ast.IsFunctionDeclaration(declaration) || ast.IsConstructorDeclaration(declaration)) &&
core.Every(declaration.Parameters(), func(param *ast.Node) bool { return param.Type() == nil }) &&
c.getContextualType(declaration, ContextFlagsSignature) == nil
if isUntypedSignatureInJSFile {
flags |= SignatureFlagsIsUntypedSignatureInJSFile
}
for i, param := range declaration.Parameters() {
paramSymbol := param.Symbol()
typeNode := param.Type()
Expand Down Expand Up @@ -19349,7 +19343,7 @@ func (c *Checker) getReturnTypeFromAnnotation(declaration *ast.Node) *Type {
}

func (c *Checker) getSignatureOfFullSignatureType(node *ast.Node) *Signature {
if ast.IsInJSFile(node) && (ast.IsFunctionDeclaration(node) || ast.IsMethodDeclaration(node) || ast.IsFunctionExpressionOrArrowFunction(node)) && node.FunctionLikeData().FullSignature != nil {
if ast.IsInJSFile(node) && ast.IsFunctionLike(node) && node.FunctionLikeData().FullSignature != nil {
return c.getSingleCallSignature(c.getTypeFromTypeNode(node.FunctionLikeData().FullSignature))
}
return nil
Expand Down
21 changes: 7 additions & 14 deletions internal/checker/emitresolver.go
Original file line number Diff line number Diff line change
Expand Up @@ -458,20 +458,13 @@ func (r *emitResolver) IsImplementationOfOverload(node *ast.SignatureDeclaration
// function foo(a: any) { // This is implementation of the overloads
// return a;
// }
if len(signaturesOfSymbol) > 1 {
return true
}
// If there is single signature for the symbol, it is overload if that signature isn't coming from the node
// e.g.: function foo(a: string): string;
// function foo(a: any) { // This is implementation of the overloads
// return a;
// }
if len(signaturesOfSymbol) == 1 {
declaration := signaturesOfSymbol[0].declaration
if declaration != node && declaration.Flags&ast.NodeFlagsJSDoc == 0 {
return true
}
}
return len(signaturesOfSymbol) > 1 ||
// If there is single signature for the symbol, it is overload if that signature isn't coming from the node
// e.g.: function foo(a: string): string;
// function foo(a: any) { // This is implementation of the overloads
// return a;
// }
(len(signaturesOfSymbol) == 1 && signaturesOfSymbol[0].declaration != node)
}
return false
}
Expand Down
55 changes: 27 additions & 28 deletions internal/core/compileroptions.go
Original file line number Diff line number Diff line change
Expand Up @@ -200,26 +200,30 @@ func (options *CompilerOptions) GetEmitScriptTarget() ScriptTarget {
}

func (options *CompilerOptions) GetEmitModuleKind() ModuleKind {
if options.Module != ModuleKindNone {
switch options.Module {
case ModuleKindNone, ModuleKindAMD, ModuleKindUMD, ModuleKindSystem:
if options.Target >= ScriptTargetES2015 {
return ModuleKindES2015
}
return ModuleKindCommonJS
default:
return options.Module
}
if options.Target >= ScriptTargetES2015 {
return ModuleKindES2015
}
return ModuleKindCommonJS
}

func (options *CompilerOptions) GetModuleResolutionKind() ModuleResolutionKind {
if options.ModuleResolution != ModuleResolutionKindUnknown {
return options.ModuleResolution
}
switch options.GetEmitModuleKind() {
case ModuleKindNode16, ModuleKindNode18, ModuleKindNode20:
return ModuleResolutionKindNode16
case ModuleKindNodeNext:
return ModuleResolutionKindNodeNext
switch options.ModuleResolution {
case ModuleResolutionKindUnknown, ModuleResolutionKindClassic, ModuleResolutionKindNode10:
switch options.GetEmitModuleKind() {
case ModuleKindNode16, ModuleKindNode18, ModuleKindNode20:
return ModuleResolutionKindNode16
case ModuleKindNodeNext:
return ModuleResolutionKindNodeNext
default:
return ModuleResolutionKindBundler
}
default:
return ModuleResolutionKindBundler
return options.ModuleResolution
}
}

Expand Down Expand Up @@ -251,24 +255,14 @@ func (options *CompilerOptions) AllowImportingTsExtensionsFrom(fileName string)
return options.GetAllowImportingTsExtensions() || tspath.IsDeclarationFileName(fileName)
}

// Deprecated: always returns true
func (options *CompilerOptions) GetESModuleInterop() bool {
if options.ESModuleInterop != TSUnknown {
return options.ESModuleInterop == TSTrue
}
switch options.GetEmitModuleKind() {
case ModuleKindNode16, ModuleKindNode18, ModuleKindNode20, ModuleKindNodeNext, ModuleKindPreserve:
return true
}
return false
return true
}

// Deprecated: always returns true
func (options *CompilerOptions) GetAllowSyntheticDefaultImports() bool {
if options.AllowSyntheticDefaultImports != TSUnknown {
return options.AllowSyntheticDefaultImports == TSTrue
}
return options.GetESModuleInterop() ||
options.GetEmitModuleKind() == ModuleKindSystem ||
options.GetModuleResolutionKind() == ModuleResolutionKindBundler
return true
}

func (options *CompilerOptions) GetResolveJsonModule() bool {
Expand Down Expand Up @@ -401,6 +395,7 @@ const (
type ModuleKind int32

const (
// Deprecated: Do not use outside of options parsing and validation.
ModuleKindNone ModuleKind = 0
ModuleKindCommonJS ModuleKind = 1
// Deprecated: Do not use outside of options parsing and validation.
Expand Down Expand Up @@ -447,6 +442,10 @@ type ModuleResolutionKind int32

const (
ModuleResolutionKindUnknown ModuleResolutionKind = 0
// Deprecated: Do not use outside of options parsing and validation.
ModuleResolutionKindClassic ModuleResolutionKind = 1
// Deprecated: Do not use outside of options parsing and validation.
ModuleResolutionKindNode10 ModuleResolutionKind = 2
// Starting with node16, node's module resolver has significant departures from traditional cjs resolution
// to better support ECMAScript modules and their use within node - however more features are still being added.
// TypeScript's Node ESM support was introduced after Node 12 went end-of-life, and Node 14 is the earliest stable
Expand Down
4 changes: 3 additions & 1 deletion internal/diagnostics/diagnostics_generated.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 3 additions & 11 deletions internal/fourslash/_scripts/failingTests.txt
Original file line number Diff line number Diff line change
Expand Up @@ -92,12 +92,10 @@ TestCompletionInJsDoc
TestCompletionInUncheckedJSFile
TestCompletionListBuilderLocations_VariableDeclarations
TestCompletionListForDerivedType1
TestCompletionListForTransitivelyExportedMembers04
TestCompletionListFunctionExpression
TestCompletionListInArrowFunctionInUnclosedCallSite01
TestCompletionListInClassExpressionWithTypeParameter
TestCompletionListInClassStaticBlocks
TestCompletionListInImportClause01
TestCompletionListInImportClause05
TestCompletionListInImportClause06
TestCompletionListInNamedClassExpression
Expand Down Expand Up @@ -138,7 +136,6 @@ TestCompletionOfAwaitPromise6
TestCompletionOfAwaitPromise7
TestCompletionOfInterfaceAndVar
TestCompletionPreferredSuggestions1
TestCompletionPropertyShorthandForObjectLiteral5
TestCompletionWithConditionalOperatorMissingColon
TestCompletionsAfterJSDoc
TestCompletionsBeforeRestArg1
Expand All @@ -149,13 +146,12 @@ TestCompletionsClassMemberImportTypeNodeParameter4
TestCompletionsElementAccessNumeric
TestCompletionsExportImport
TestCompletionsGenericTypeWithMultipleBases1
TestCompletionsImportBaseUrl
TestCompletionsImportOrExportSpecifier
TestCompletionsImport_default_alreadyExistedWithRename
TestCompletionsImport_default_anonymous
TestCompletionsImport_default_didNotExistBefore
TestCompletionsImport_default_exportDefaultIdentifier
TestCompletionsImport_default_symbolName
TestCompletionsImport_details_withMisspelledName
TestCompletionsImport_exportEquals
TestCompletionsImport_exportEquals_anonymous
TestCompletionsImport_exportEquals_global
TestCompletionsImport_filteredByInvalidPackageJson_direct
Expand All @@ -167,21 +163,18 @@ TestCompletionsImport_filteredByPackageJson_typesOnly
TestCompletionsImport_importType
TestCompletionsImport_jsxOpeningTagImportDefault
TestCompletionsImport_mergedReExport
TestCompletionsImport_multipleWithSameName
TestCompletionsImport_named_didNotExistBefore
TestCompletionsImport_named_exportEqualsNamespace
TestCompletionsImport_named_namespaceImportExists
TestCompletionsImport_noSemicolons
TestCompletionsImport_ofAlias_preferShortPath
TestCompletionsImport_packageJsonImportsPreference
TestCompletionsImport_quoteStyle
TestCompletionsImport_reExportDefault
TestCompletionsImport_reExportDefault2
TestCompletionsImport_reExport_wrongName
TestCompletionsImport_require_addToExisting
TestCompletionsImport_typeOnly
TestCompletionsImport_umdDefaultNoCrash1
TestCompletionsImport_uriStyleNodeCoreModules2
TestCompletionsImport_weirdDefaultSynthesis
TestCompletionsImport_windowsPathsProjectRelative
TestCompletionsInExport
TestCompletionsInExport_moduleBlock
Expand Down Expand Up @@ -280,7 +273,6 @@ TestImportCompletions_importsMap3
TestImportCompletions_importsMap4
TestImportCompletions_importsMap5
TestImportNameCodeFixExportAsDefault
TestImportSuggestionsCache_exportUndefined
TestImportTypeCompletions1
TestImportTypeCompletions3
TestImportTypeCompletions4
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,9 @@ import (

func TestCompletionListForTransitivelyExportedMembers04(t *testing.T) {
t.Parallel()
t.Skip()

defer testutil.RecoverAndFail(t, "Panic on fourslash test")
const content = `// @ModuleResolution: classic
// @Filename: A.ts
const content = `// @Filename: A.ts
export interface I1 { one: number }
export interface I2 { two: string }
export type I1_OR_I2 = I1 | I2;
Expand All @@ -35,10 +34,10 @@ export module Inner {
export var bVar = "bee!";
// @Filename: C.ts
export var cVar = "see!";
export * from "A";
export * from "B"
export * from "./A";
export * from "./B"
// @Filename: D.ts
import * as c from "C";
import * as c from "./C";
var x: c.Inner./**/`
f := fourslash.NewFourslash(t, nil /*capabilities*/, content)
f.VerifyCompletions(t, "", &fourslash.CompletionsExpectedList{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,20 @@ import (

func TestCompletionListInImportClause01(t *testing.T) {
t.Parallel()
t.Skip()

defer testutil.RecoverAndFail(t, "Panic on fourslash test")
const content = `// @ModuleResolution: classic
// @Filename: m1.ts
const content = `// @Filename: m1.ts
export var foo: number = 1;
export function bar() { return 10; }
export function baz() { return 10; }
// @Filename: m2.ts
import {/*1*/, /*2*/ from "m1"
import {/*3*/} from "m1"
import {foo,/*4*/ from "m1"
import {bar as /*5*/, /*6*/ from "m1"
import {foo, bar, baz as b,/*7*/} from "m1"
import { type /*8*/ } from "m1";
import { type b/*9*/ } from "m1";`
import {/*1*/, /*2*/ from "./m1"
import {/*3*/} from "./m1"
import {foo,/*4*/ from "./m1"
import {bar as /*5*/, /*6*/ from "./m1"
import {foo, bar, baz as b,/*7*/} from "./m1"
import { type /*8*/ } from "./m1";
import { type b/*9*/ } from "./m1";`
f := fourslash.NewFourslash(t, nil /*capabilities*/, content)
f.VerifyCompletions(t, []string{"8", "9"}, &fourslash.CompletionsExpectedList{
IsIncomplete: false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (

func TestCompletionPropertyShorthandForObjectLiteral5(t *testing.T) {
t.Parallel()
t.Skip()

defer testutil.RecoverAndFail(t, "Panic on fourslash test")
const content = `// @module: esnext
// @Filename: /a.ts
Expand All @@ -33,7 +33,7 @@ const obj = { exp/**/`
Label: "exportedConstant",
Data: PtrTo(any(&ls.CompletionItemData{
AutoImport: &ls.AutoImportData{
ModuleSpecifier: "/a",
ModuleSpecifier: "./a",
},
})),
AdditionalTextEdits: fourslash.AnyTextEdits,
Expand Down
Loading
Loading