Skip to content

Commit ca68e0b

Browse files
authored
Update submodule with ES5 removals (#1963)
1 parent 4874e98 commit ca68e0b

File tree

1,195 files changed

+7199
-18740
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,195 files changed

+7199
-18740
lines changed

_submodules/TypeScript

Submodule TypeScript updated 1922 files

internal/binder/nameresolver.go

Lines changed: 10 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -205,13 +205,6 @@ loop:
205205
return nil
206206
}
207207
}
208-
case ast.KindArrowFunction:
209-
// when targeting ES6 or higher there is no 'arguments' in an arrow function
210-
// for lower compile targets the resolved symbol is used to emit an error
211-
if r.CompilerOptions.GetEmitScriptTarget() >= core.ScriptTargetES2015 {
212-
break
213-
}
214-
fallthrough
215208
case ast.KindMethodDeclaration, ast.KindConstructor, ast.KindGetAccessor, ast.KindSetAccessor, ast.KindFunctionDeclaration:
216209
if meaning&ast.SymbolFlagsVariable != 0 && name == "arguments" {
217210
result = r.argumentsSymbol()
@@ -354,21 +347,18 @@ func (r *NameResolver) useOuterVariableScopeInParameter(result *ast.Symbol, loca
354347
// - optional chaining pre-es2020
355348
// - nullish coalesce pre-es2020
356349
// - spread assignment in binding pattern pre-es2017
357-
target := r.CompilerOptions.GetEmitScriptTarget()
358-
if target >= core.ScriptTargetES2015 {
359-
functionLocation := location
360-
declarationRequiresScopeChange := core.TSUnknown
361-
if r.GetRequiresScopeChangeCache != nil {
362-
declarationRequiresScopeChange = r.GetRequiresScopeChangeCache(functionLocation)
363-
}
364-
if declarationRequiresScopeChange == core.TSUnknown {
365-
declarationRequiresScopeChange = core.IfElse(core.Some(functionLocation.Parameters(), r.requiresScopeChange), core.TSTrue, core.TSFalse)
366-
if r.SetRequiresScopeChangeCache != nil {
367-
r.SetRequiresScopeChangeCache(functionLocation, declarationRequiresScopeChange)
368-
}
350+
functionLocation := location
351+
declarationRequiresScopeChange := core.TSUnknown
352+
if r.GetRequiresScopeChangeCache != nil {
353+
declarationRequiresScopeChange = r.GetRequiresScopeChangeCache(functionLocation)
354+
}
355+
if declarationRequiresScopeChange == core.TSUnknown {
356+
declarationRequiresScopeChange = core.IfElse(core.Some(functionLocation.Parameters(), r.requiresScopeChange), core.TSTrue, core.TSFalse)
357+
if r.SetRequiresScopeChangeCache != nil {
358+
r.SetRequiresScopeChangeCache(functionLocation, declarationRequiresScopeChange)
369359
}
370-
return declarationRequiresScopeChange != core.TSTrue
371360
}
361+
return declarationRequiresScopeChange != core.TSTrue
372362
}
373363
}
374364
return false

internal/checker/checker.go

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5817,6 +5817,7 @@ func (c *Checker) getIteratedTypeOrElementType(use IterationUse, inputType *Type
58175817
}
58185818
return nil
58195819
}
5820+
// TODO: remove ScriptTargetES2015
58205821
uplevelIteration := c.languageVersion >= core.ScriptTargetES2015
58215822
downlevelIteration := !uplevelIteration && c.compilerOptions.DownlevelIteration == core.TSTrue
58225823
possibleOutOfBounds := c.compilerOptions.NoUncheckedIndexedAccess == core.TSTrue && use&IterationUsePossiblyOutOfBounds != 0
@@ -7675,10 +7676,6 @@ func (c *Checker) checkSuperExpression(node *ast.Node) *Type {
76757676
// c.captureLexicalThis(node.Parent, container)
76767677
// }
76777678
if container.Parent.Kind == ast.KindObjectLiteralExpression {
7678-
if c.languageVersion < core.ScriptTargetES2015 {
7679-
c.error(node, diagnostics.X_super_is_only_allowed_in_members_of_object_literal_expressions_when_option_target_is_ES2015_or_higher)
7680-
return c.errorType
7681-
}
76827679
// for object literal assume that type of 'super' is 'any'
76837680
return c.anyType
76847681
}
@@ -11343,14 +11340,6 @@ func (c *Checker) checkPropertyAccessibilityAtLocation(location *ast.Node, isSup
1134311340
// - In a static member function or static member accessor
1134411341
// where this references the constructor function object of a derived class,
1134511342
// a super property access is permitted and must specify a public static member function of the base class.
11346-
if c.languageVersion < core.ScriptTargetES2015 {
11347-
if c.symbolHasNonMethodDeclaration(prop) {
11348-
if errorNode != nil {
11349-
c.error(errorNode, diagnostics.Only_public_and_protected_methods_of_the_base_class_are_accessible_via_the_super_keyword)
11350-
}
11351-
return false
11352-
}
11353-
}
1135411343
if flags&ast.ModifierFlagsAbstract != 0 {
1135511344
// A method cannot be accessed in a super property access if the method is abstract.
1135611345
// This error could mask a private property access error. But, a member
@@ -17356,6 +17345,7 @@ func (c *Checker) getTypeFromArrayBindingPattern(pattern *ast.Node, includePatte
1735617345
restElement = lastElement
1735717346
}
1735817347
if len(elements) == 0 || len(elements) == 1 && restElement != nil {
17348+
// TODO: remove ScriptTargetES2015
1735917349
if c.languageVersion >= core.ScriptTargetES2015 {
1736017350
return c.createIterableType(c.anyType)
1736117351
}

internal/checker/grammarchecks.go

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1338,9 +1338,6 @@ func (c *Checker) checkGrammarForInOrForOfStatement(forInOrOfStatement *ast.ForI
13381338
func (c *Checker) checkGrammarAccessor(accessor *ast.AccessorDeclaration) bool {
13391339
body := accessor.Body()
13401340
if accessor.Flags&ast.NodeFlagsAmbient == 0 && (accessor.Parent.Kind != ast.KindTypeLiteral) && (accessor.Parent.Kind != ast.KindInterfaceDeclaration) {
1341-
if c.languageVersion < core.ScriptTargetES2015 && ast.IsPrivateIdentifier(accessor.Name()) {
1342-
return c.grammarErrorOnNode(accessor.Name(), diagnostics.Private_identifiers_are_only_available_when_targeting_ECMAScript_2015_and_higher)
1343-
}
13441341
if body == nil && !ast.HasSyntacticModifier(accessor, ast.ModifierFlagsAbstract) {
13451342
return c.grammarErrorAtPos(accessor, accessor.End()-1, len(";"), diagnostics.X_0_expected, "{")
13461343
}
@@ -1492,9 +1489,6 @@ func (c *Checker) checkGrammarMethod(node *ast.Node /*Union[MethodDeclaration, M
14921489
}
14931490

14941491
if ast.IsClassLike(node.Parent) {
1495-
if c.languageVersion < core.ScriptTargetES2015 && ast.IsPrivateIdentifier(node.Name()) {
1496-
return c.grammarErrorOnNode(node.Name(), diagnostics.Private_identifiers_are_only_available_when_targeting_ECMAScript_2015_and_higher)
1497-
}
14981492
// Technically, computed properties in ambient contexts is disallowed
14991493
// for property declarations and accessors too, not just methods.
15001494
// However, property declarations disallow computed names in general,
@@ -1934,12 +1928,6 @@ func (c *Checker) checkGrammarProperty(node *ast.Node /*Union[PropertyDeclaratio
19341928
if c.checkGrammarForInvalidDynamicName(propertyName, diagnostics.A_computed_property_name_in_a_class_property_declaration_must_have_a_simple_literal_type_or_a_unique_symbol_type) {
19351929
return true
19361930
}
1937-
if c.languageVersion < core.ScriptTargetES2015 && ast.IsPrivateIdentifier(propertyName) {
1938-
return c.grammarErrorOnNode(propertyName, diagnostics.Private_identifiers_are_only_available_when_targeting_ECMAScript_2015_and_higher)
1939-
}
1940-
if c.languageVersion < core.ScriptTargetES2015 && ast.IsAutoAccessorPropertyDeclaration(node) && node.Flags&ast.NodeFlagsAmbient == 0 {
1941-
return c.grammarErrorOnNode(propertyName, diagnostics.Properties_with_the_accessor_modifier_are_only_available_when_targeting_ECMAScript_2015_and_higher)
1942-
}
19431931
if ast.IsAutoAccessorPropertyDeclaration(node) && c.checkGrammarForInvalidQuestionMark(node.AsPropertyDeclaration().PostfixToken, diagnostics.An_accessor_property_cannot_be_declared_optional) {
19441932
return true
19451933
}

internal/checker/types.go

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1210,20 +1210,6 @@ const (
12101210
type TypeComparer func(s *Type, t *Type, reportErrors bool) Ternary
12111211

12121212
type LanguageFeatureMinimumTargetMap struct {
1213-
Classes core.ScriptTarget
1214-
ForOf core.ScriptTarget
1215-
Generators core.ScriptTarget
1216-
Iteration core.ScriptTarget
1217-
SpreadElements core.ScriptTarget
1218-
RestElements core.ScriptTarget
1219-
TaggedTemplates core.ScriptTarget
1220-
DestructuringAssignment core.ScriptTarget
1221-
BindingPatterns core.ScriptTarget
1222-
ArrowFunctions core.ScriptTarget
1223-
BlockScopedVariables core.ScriptTarget
1224-
ObjectAssign core.ScriptTarget
1225-
RegularExpressionFlagsUnicode core.ScriptTarget
1226-
RegularExpressionFlagsSticky core.ScriptTarget
12271213
Exponentiation core.ScriptTarget
12281214
AsyncFunctions core.ScriptTarget
12291215
ForAwaitOf core.ScriptTarget
@@ -1247,20 +1233,6 @@ type LanguageFeatureMinimumTargetMap struct {
12471233
}
12481234

12491235
var LanguageFeatureMinimumTarget = LanguageFeatureMinimumTargetMap{
1250-
Classes: core.ScriptTargetES2015,
1251-
ForOf: core.ScriptTargetES2015,
1252-
Generators: core.ScriptTargetES2015,
1253-
Iteration: core.ScriptTargetES2015,
1254-
SpreadElements: core.ScriptTargetES2015,
1255-
RestElements: core.ScriptTargetES2015,
1256-
TaggedTemplates: core.ScriptTargetES2015,
1257-
DestructuringAssignment: core.ScriptTargetES2015,
1258-
BindingPatterns: core.ScriptTargetES2015,
1259-
ArrowFunctions: core.ScriptTargetES2015,
1260-
BlockScopedVariables: core.ScriptTargetES2015,
1261-
ObjectAssign: core.ScriptTargetES2015,
1262-
RegularExpressionFlagsUnicode: core.ScriptTargetES2015,
1263-
RegularExpressionFlagsSticky: core.ScriptTargetES2015,
12641236
Exponentiation: core.ScriptTargetES2016,
12651237
AsyncFunctions: core.ScriptTargetES2017,
12661238
ForAwaitOf: core.ScriptTargetES2018,

internal/compiler/program.go

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -725,20 +725,10 @@ func (p *Program) verifyCompilerOptions() {
725725
createDiagnosticForOptionName(diagnostics.Option_0_cannot_be_specified_with_option_1, "lib", "noLib")
726726
}
727727

728-
languageVersion := options.GetEmitScriptTarget()
729-
730-
firstNonAmbientExternalModuleSourceFile := core.Find(p.files, func(f *ast.SourceFile) bool { return ast.IsExternalModule(f) && !f.IsDeclarationFile })
731728
if options.IsolatedModules.IsTrue() || options.VerbatimModuleSyntax.IsTrue() {
732-
if options.Module == core.ModuleKindNone && languageVersion < core.ScriptTargetES2015 && options.IsolatedModules.IsTrue() {
733-
// !!!
734-
// createDiagnosticForOptionName(diagnostics.Option_isolatedModules_can_only_be_used_when_either_option_module_is_provided_or_option_target_is_ES2015_or_higher, "isolatedModules", "target")
735-
}
736-
737729
if options.PreserveConstEnums.IsFalse() {
738730
createDiagnosticForOptionName(diagnostics.Option_preserveConstEnums_cannot_be_disabled_when_0_is_enabled, core.IfElse(options.VerbatimModuleSyntax.IsTrue(), "verbatimModuleSyntax", "isolatedModules"), "preserveConstEnums")
739731
}
740-
} else if firstNonAmbientExternalModuleSourceFile != nil && languageVersion < core.ScriptTargetES2015 && options.Module == core.ModuleKindNone {
741-
// !!!
742732
}
743733

744734
if options.OutDir != "" ||

internal/fourslash/_scripts/failingTests.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,6 @@ TestDoubleUnderscoreCompletions
224224
TestEditJsdocType
225225
TestExportDefaultClass
226226
TestExportDefaultFunction
227-
TestFindAllRefsForModule
228227
TestFindAllRefsModuleDotExports
229228
TestFindReferencesBindingPatternInJsdocNoCrash1
230229
TestFindReferencesBindingPatternInJsdocNoCrash2

internal/fourslash/tests/gen/completionListStaticProtectedMembers2_test.go

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,14 +140,30 @@ class C2 extends Base {
140140
Label: "protectedOverriddenMethod",
141141
SortText: PtrTo(string(ls.SortTextLocalDeclarationPriority)),
142142
},
143+
&lsproto.CompletionItem{
144+
Label: "protectedOverriddenProperty",
145+
SortText: PtrTo(string(ls.SortTextLocalDeclarationPriority)),
146+
},
147+
&lsproto.CompletionItem{
148+
Label: "protectedProperty",
149+
SortText: PtrTo(string(ls.SortTextLocalDeclarationPriority)),
150+
},
143151
&lsproto.CompletionItem{
144152
Label: "publicMethod",
145153
SortText: PtrTo(string(ls.SortTextLocalDeclarationPriority)),
146154
},
155+
&lsproto.CompletionItem{
156+
Label: "publicProperty",
157+
SortText: PtrTo(string(ls.SortTextLocalDeclarationPriority)),
158+
},
147159
&lsproto.CompletionItem{
148160
Label: "apply",
149161
SortText: PtrTo(string(ls.SortTextLocationPriority)),
150162
},
163+
&lsproto.CompletionItem{
164+
Label: "arguments",
165+
SortText: PtrTo(string(ls.SortTextLocationPriority)),
166+
},
151167
&lsproto.CompletionItem{
152168
Label: "bind",
153169
SortText: PtrTo(string(ls.SortTextLocationPriority)),
@@ -156,6 +172,18 @@ class C2 extends Base {
156172
Label: "call",
157173
SortText: PtrTo(string(ls.SortTextLocationPriority)),
158174
},
175+
&lsproto.CompletionItem{
176+
Label: "caller",
177+
SortText: PtrTo(string(ls.SortTextLocationPriority)),
178+
},
179+
&lsproto.CompletionItem{
180+
Label: "length",
181+
SortText: PtrTo(string(ls.SortTextLocationPriority)),
182+
},
183+
&lsproto.CompletionItem{
184+
Label: "prototype",
185+
SortText: PtrTo(string(ls.SortTextLocationPriority)),
186+
},
159187
&lsproto.CompletionItem{
160188
Label: "toString",
161189
SortText: PtrTo(string(ls.SortTextLocationPriority)),

internal/fourslash/tests/gen/findAllRefsForModule_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import (
99

1010
func TestFindAllRefsForModule(t *testing.T) {
1111
t.Parallel()
12-
t.Skip()
12+
1313
defer testutil.RecoverAndFail(t, "Panic on fourslash test")
1414
const content = `// @allowJs: true
1515
// @Filename: /a.ts

internal/printer/factory.go

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -548,17 +548,7 @@ func (f *NodeFactory) NewDisposeResourcesHelper(envBinding *ast.Expression) *ast
548548
// !!! ES2018 Helpers
549549
// Chains a sequence of expressions using the __assign helper or Object.assign if available in the target
550550
func (f *NodeFactory) NewAssignHelper(attributesSegments []*ast.Expression, scriptTarget core.ScriptTarget) *ast.Expression {
551-
if scriptTarget >= core.ScriptTargetES2015 {
552-
return f.NewCallExpression(f.NewPropertyAccessExpression(f.NewIdentifier("Object"), nil, f.NewIdentifier("assign"), ast.NodeFlagsNone), nil, nil, f.NewNodeList(attributesSegments), ast.NodeFlagsNone)
553-
}
554-
f.emitContext.RequestEmitHelper(assignHelper)
555-
return f.NewCallExpression(
556-
f.NewUnscopedHelperName("__assign"),
557-
nil,
558-
nil,
559-
f.NewNodeList(attributesSegments),
560-
ast.NodeFlagsNone,
561-
)
551+
return f.NewCallExpression(f.NewPropertyAccessExpression(f.NewIdentifier("Object"), nil, f.NewIdentifier("assign"), ast.NodeFlagsNone), nil, nil, f.NewNodeList(attributesSegments), ast.NodeFlagsNone)
562552
}
563553

564554
// ES2018 Destructuring Helpers

0 commit comments

Comments
 (0)