Skip to content

Commit a4fa408

Browse files
authored
Update submodule, port 6.0 options defaults (#1961)
1 parent bf70757 commit a4fa408

File tree

1,939 files changed

+32761
-29802
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,939 files changed

+32761
-29802
lines changed

_submodules/TypeScript

Submodule TypeScript updated 2577 files

internal/ast/ast.go

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2353,9 +2353,6 @@ func IsArrayLiteralOrObjectLiteralDestructuringPattern(node *Node) bool {
23532353

23542354
func accessKind(node *Node) AccessKind {
23552355
parent := node.Parent
2356-
if parent == nil {
2357-
return AccessKindRead
2358-
}
23592356
switch parent.Kind {
23602357
case KindParenthesizedExpression:
23612358
return accessKind(parent)
@@ -2407,9 +2404,8 @@ func accessKind(node *Node) AccessKind {
24072404
return AccessKindWrite
24082405
}
24092406
return AccessKindRead
2410-
default:
2411-
return AccessKindRead
24122407
}
2408+
return AccessKindRead
24132409
}
24142410

24152411
func reverseAccessKind(a AccessKind) AccessKind {

internal/ast/utilities.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -571,7 +571,7 @@ func IsClassElement(node *Node) bool {
571571
return false
572572
}
573573

574-
func IsMethodOrAccessor(node *Node) bool {
574+
func isMethodOrAccessor(node *Node) bool {
575575
switch node.Kind {
576576
case KindMethodDeclaration, KindGetAccessor, KindSetAccessor:
577577
return true
@@ -580,7 +580,7 @@ func IsMethodOrAccessor(node *Node) bool {
580580
}
581581

582582
func IsPrivateIdentifierClassElementDeclaration(node *Node) bool {
583-
return (IsPropertyDeclaration(node) || IsMethodOrAccessor(node)) && IsPrivateIdentifier(node.Name())
583+
return (IsPropertyDeclaration(node) || isMethodOrAccessor(node)) && IsPrivateIdentifier(node.Name())
584584
}
585585

586586
func IsObjectLiteralOrClassExpressionMethodOrAccessor(node *Node) bool {

internal/checker/checker.go

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -19101,9 +19101,11 @@ func (c *Checker) getSignaturesOfSymbol(symbol *ast.Symbol) []*Signature {
1910119101
}
1910219102
// If this is a function or method declaration, get the signature from the @type tag for the sake of optional parameters.
1910319103
// 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.
19104-
if sig := c.getSignatureOfFullSignatureType(decl); sig != nil {
19105-
result = append(result, sig)
19106-
continue
19104+
if ast.IsFunctionExpressionOrArrowFunction(decl) || ast.IsObjectLiteralMethod(decl) {
19105+
if sig := c.getSignatureOfFullSignatureType(decl); sig != nil {
19106+
result = append(result, sig)
19107+
continue
19108+
}
1910719109
}
1910819110
result = append(result, c.getSignatureFromDeclaration(decl))
1910919111
}
@@ -19121,14 +19123,6 @@ func (c *Checker) getSignatureFromDeclaration(declaration *ast.Node) *Signature
1912119123
minArgumentCount := 0
1912219124
hasThisParameter := false
1912319125
iife := ast.GetImmediatelyInvokedFunctionExpression(declaration)
19124-
isUntypedSignatureInJSFile := iife == nil &&
19125-
ast.IsInJSFile(declaration) &&
19126-
(ast.IsFunctionExpression(declaration) || ast.IsArrowFunction(declaration) || ast.IsMethodOrAccessor(declaration) || ast.IsFunctionDeclaration(declaration) || ast.IsConstructorDeclaration(declaration)) &&
19127-
core.Every(declaration.Parameters(), func(param *ast.Node) bool { return param.Type() == nil }) &&
19128-
c.getContextualType(declaration, ContextFlagsSignature) == nil
19129-
if isUntypedSignatureInJSFile {
19130-
flags |= SignatureFlagsIsUntypedSignatureInJSFile
19131-
}
1913219126
for i, param := range declaration.Parameters() {
1913319127
paramSymbol := param.Symbol()
1913419128
typeNode := param.Type()
@@ -19349,7 +19343,7 @@ func (c *Checker) getReturnTypeFromAnnotation(declaration *ast.Node) *Type {
1934919343
}
1935019344

1935119345
func (c *Checker) getSignatureOfFullSignatureType(node *ast.Node) *Signature {
19352-
if ast.IsInJSFile(node) && (ast.IsFunctionDeclaration(node) || ast.IsMethodDeclaration(node) || ast.IsFunctionExpressionOrArrowFunction(node)) && node.FunctionLikeData().FullSignature != nil {
19346+
if ast.IsInJSFile(node) && ast.IsFunctionLike(node) && node.FunctionLikeData().FullSignature != nil {
1935319347
return c.getSingleCallSignature(c.getTypeFromTypeNode(node.FunctionLikeData().FullSignature))
1935419348
}
1935519349
return nil

internal/checker/emitresolver.go

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -458,20 +458,13 @@ func (r *emitResolver) IsImplementationOfOverload(node *ast.SignatureDeclaration
458458
// function foo(a: any) { // This is implementation of the overloads
459459
// return a;
460460
// }
461-
if len(signaturesOfSymbol) > 1 {
462-
return true
463-
}
464-
// If there is single signature for the symbol, it is overload if that signature isn't coming from the node
465-
// e.g.: function foo(a: string): string;
466-
// function foo(a: any) { // This is implementation of the overloads
467-
// return a;
468-
// }
469-
if len(signaturesOfSymbol) == 1 {
470-
declaration := signaturesOfSymbol[0].declaration
471-
if declaration != node && declaration.Flags&ast.NodeFlagsJSDoc == 0 {
472-
return true
473-
}
474-
}
461+
return len(signaturesOfSymbol) > 1 ||
462+
// If there is single signature for the symbol, it is overload if that signature isn't coming from the node
463+
// e.g.: function foo(a: string): string;
464+
// function foo(a: any) { // This is implementation of the overloads
465+
// return a;
466+
// }
467+
(len(signaturesOfSymbol) == 1 && signaturesOfSymbol[0].declaration != node)
475468
}
476469
return false
477470
}

internal/core/compileroptions.go

Lines changed: 27 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -200,26 +200,30 @@ func (options *CompilerOptions) GetEmitScriptTarget() ScriptTarget {
200200
}
201201

202202
func (options *CompilerOptions) GetEmitModuleKind() ModuleKind {
203-
if options.Module != ModuleKindNone {
203+
switch options.Module {
204+
case ModuleKindNone, ModuleKindAMD, ModuleKindUMD, ModuleKindSystem:
205+
if options.Target >= ScriptTargetES2015 {
206+
return ModuleKindES2015
207+
}
208+
return ModuleKindCommonJS
209+
default:
204210
return options.Module
205211
}
206-
if options.Target >= ScriptTargetES2015 {
207-
return ModuleKindES2015
208-
}
209-
return ModuleKindCommonJS
210212
}
211213

212214
func (options *CompilerOptions) GetModuleResolutionKind() ModuleResolutionKind {
213-
if options.ModuleResolution != ModuleResolutionKindUnknown {
214-
return options.ModuleResolution
215-
}
216-
switch options.GetEmitModuleKind() {
217-
case ModuleKindNode16, ModuleKindNode18, ModuleKindNode20:
218-
return ModuleResolutionKindNode16
219-
case ModuleKindNodeNext:
220-
return ModuleResolutionKindNodeNext
215+
switch options.ModuleResolution {
216+
case ModuleResolutionKindUnknown, ModuleResolutionKindClassic, ModuleResolutionKindNode10:
217+
switch options.GetEmitModuleKind() {
218+
case ModuleKindNode16, ModuleKindNode18, ModuleKindNode20:
219+
return ModuleResolutionKindNode16
220+
case ModuleKindNodeNext:
221+
return ModuleResolutionKindNodeNext
222+
default:
223+
return ModuleResolutionKindBundler
224+
}
221225
default:
222-
return ModuleResolutionKindBundler
226+
return options.ModuleResolution
223227
}
224228
}
225229

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

258+
// Deprecated: always returns true
254259
func (options *CompilerOptions) GetESModuleInterop() bool {
255-
if options.ESModuleInterop != TSUnknown {
256-
return options.ESModuleInterop == TSTrue
257-
}
258-
switch options.GetEmitModuleKind() {
259-
case ModuleKindNode16, ModuleKindNode18, ModuleKindNode20, ModuleKindNodeNext, ModuleKindPreserve:
260-
return true
261-
}
262-
return false
260+
return true
263261
}
264262

263+
// Deprecated: always returns true
265264
func (options *CompilerOptions) GetAllowSyntheticDefaultImports() bool {
266-
if options.AllowSyntheticDefaultImports != TSUnknown {
267-
return options.AllowSyntheticDefaultImports == TSTrue
268-
}
269-
return options.GetESModuleInterop() ||
270-
options.GetEmitModuleKind() == ModuleKindSystem ||
271-
options.GetModuleResolutionKind() == ModuleResolutionKindBundler
265+
return true
272266
}
273267

274268
func (options *CompilerOptions) GetResolveJsonModule() bool {
@@ -401,6 +395,7 @@ const (
401395
type ModuleKind int32
402396

403397
const (
398+
// Deprecated: Do not use outside of options parsing and validation.
404399
ModuleKindNone ModuleKind = 0
405400
ModuleKindCommonJS ModuleKind = 1
406401
// Deprecated: Do not use outside of options parsing and validation.
@@ -447,6 +442,10 @@ type ModuleResolutionKind int32
447442

448443
const (
449444
ModuleResolutionKindUnknown ModuleResolutionKind = 0
445+
// Deprecated: Do not use outside of options parsing and validation.
446+
ModuleResolutionKindClassic ModuleResolutionKind = 1
447+
// Deprecated: Do not use outside of options parsing and validation.
448+
ModuleResolutionKindNode10 ModuleResolutionKind = 2
450449
// Starting with node16, node's module resolver has significant departures from traditional cjs resolution
451450
// to better support ECMAScript modules and their use within node - however more features are still being added.
452451
// TypeScript's Node ESM support was introduced after Node 12 went end-of-life, and Node 14 is the earliest stable

internal/diagnostics/diagnostics_generated.go

Lines changed: 3 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

internal/fourslash/_scripts/failingTests.txt

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -92,12 +92,10 @@ TestCompletionInJsDoc
9292
TestCompletionInUncheckedJSFile
9393
TestCompletionListBuilderLocations_VariableDeclarations
9494
TestCompletionListForDerivedType1
95-
TestCompletionListForTransitivelyExportedMembers04
9695
TestCompletionListFunctionExpression
9796
TestCompletionListInArrowFunctionInUnclosedCallSite01
9897
TestCompletionListInClassExpressionWithTypeParameter
9998
TestCompletionListInClassStaticBlocks
100-
TestCompletionListInImportClause01
10199
TestCompletionListInImportClause05
102100
TestCompletionListInImportClause06
103101
TestCompletionListInNamedClassExpression
@@ -138,7 +136,6 @@ TestCompletionOfAwaitPromise6
138136
TestCompletionOfAwaitPromise7
139137
TestCompletionOfInterfaceAndVar
140138
TestCompletionPreferredSuggestions1
141-
TestCompletionPropertyShorthandForObjectLiteral5
142139
TestCompletionWithConditionalOperatorMissingColon
143140
TestCompletionsAfterJSDoc
144141
TestCompletionsBeforeRestArg1
@@ -149,13 +146,12 @@ TestCompletionsClassMemberImportTypeNodeParameter4
149146
TestCompletionsElementAccessNumeric
150147
TestCompletionsExportImport
151148
TestCompletionsGenericTypeWithMultipleBases1
152-
TestCompletionsImportBaseUrl
153149
TestCompletionsImportOrExportSpecifier
154150
TestCompletionsImport_default_alreadyExistedWithRename
155151
TestCompletionsImport_default_anonymous
156-
TestCompletionsImport_default_didNotExistBefore
157-
TestCompletionsImport_default_exportDefaultIdentifier
152+
TestCompletionsImport_default_symbolName
158153
TestCompletionsImport_details_withMisspelledName
154+
TestCompletionsImport_exportEquals
159155
TestCompletionsImport_exportEquals_anonymous
160156
TestCompletionsImport_exportEquals_global
161157
TestCompletionsImport_filteredByInvalidPackageJson_direct
@@ -167,21 +163,18 @@ TestCompletionsImport_filteredByPackageJson_typesOnly
167163
TestCompletionsImport_importType
168164
TestCompletionsImport_jsxOpeningTagImportDefault
169165
TestCompletionsImport_mergedReExport
170-
TestCompletionsImport_multipleWithSameName
171166
TestCompletionsImport_named_didNotExistBefore
172-
TestCompletionsImport_named_exportEqualsNamespace
173167
TestCompletionsImport_named_namespaceImportExists
174168
TestCompletionsImport_noSemicolons
175-
TestCompletionsImport_ofAlias_preferShortPath
176169
TestCompletionsImport_packageJsonImportsPreference
177170
TestCompletionsImport_quoteStyle
178-
TestCompletionsImport_reExportDefault
179171
TestCompletionsImport_reExportDefault2
180172
TestCompletionsImport_reExport_wrongName
181173
TestCompletionsImport_require_addToExisting
182174
TestCompletionsImport_typeOnly
183175
TestCompletionsImport_umdDefaultNoCrash1
184176
TestCompletionsImport_uriStyleNodeCoreModules2
177+
TestCompletionsImport_weirdDefaultSynthesis
185178
TestCompletionsImport_windowsPathsProjectRelative
186179
TestCompletionsInExport
187180
TestCompletionsInExport_moduleBlock
@@ -280,7 +273,6 @@ TestImportCompletions_importsMap3
280273
TestImportCompletions_importsMap4
281274
TestImportCompletions_importsMap5
282275
TestImportNameCodeFixExportAsDefault
283-
TestImportSuggestionsCache_exportUndefined
284276
TestImportTypeCompletions1
285277
TestImportTypeCompletions3
286278
TestImportTypeCompletions4

internal/fourslash/tests/documentHighlightReferenceDirective_test.go

Lines changed: 0 additions & 24 deletions
This file was deleted.

internal/fourslash/tests/gen/completionListForTransitivelyExportedMembers04_test.go

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,9 @@ import (
1010

1111
func TestCompletionListForTransitivelyExportedMembers04(t *testing.T) {
1212
t.Parallel()
13-
t.Skip()
13+
1414
defer testutil.RecoverAndFail(t, "Panic on fourslash test")
15-
const content = `// @ModuleResolution: classic
16-
// @Filename: A.ts
15+
const content = `// @Filename: A.ts
1716
export interface I1 { one: number }
1817
export interface I2 { two: string }
1918
export type I1_OR_I2 = I1 | I2;
@@ -35,10 +34,10 @@ export module Inner {
3534
export var bVar = "bee!";
3635
// @Filename: C.ts
3736
export var cVar = "see!";
38-
export * from "A";
39-
export * from "B"
37+
export * from "./A";
38+
export * from "./B"
4039
// @Filename: D.ts
41-
import * as c from "C";
40+
import * as c from "./C";
4241
var x: c.Inner./**/`
4342
f := fourslash.NewFourslash(t, nil /*capabilities*/, content)
4443
f.VerifyCompletions(t, "", &fourslash.CompletionsExpectedList{

0 commit comments

Comments
 (0)