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 1922 files
30 changes: 10 additions & 20 deletions internal/binder/nameresolver.go
Original file line number Diff line number Diff line change
Expand Up @@ -205,13 +205,6 @@ loop:
return nil
}
}
case ast.KindArrowFunction:
// when targeting ES6 or higher there is no 'arguments' in an arrow function
// for lower compile targets the resolved symbol is used to emit an error
if r.CompilerOptions.GetEmitScriptTarget() >= core.ScriptTargetES2015 {
break
}
fallthrough
case ast.KindMethodDeclaration, ast.KindConstructor, ast.KindGetAccessor, ast.KindSetAccessor, ast.KindFunctionDeclaration:
if meaning&ast.SymbolFlagsVariable != 0 && name == "arguments" {
result = r.argumentsSymbol()
Expand Down Expand Up @@ -354,21 +347,18 @@ func (r *NameResolver) useOuterVariableScopeInParameter(result *ast.Symbol, loca
// - optional chaining pre-es2020
// - nullish coalesce pre-es2020
// - spread assignment in binding pattern pre-es2017
target := r.CompilerOptions.GetEmitScriptTarget()
if target >= core.ScriptTargetES2015 {
functionLocation := location
declarationRequiresScopeChange := core.TSUnknown
if r.GetRequiresScopeChangeCache != nil {
declarationRequiresScopeChange = r.GetRequiresScopeChangeCache(functionLocation)
}
if declarationRequiresScopeChange == core.TSUnknown {
declarationRequiresScopeChange = core.IfElse(core.Some(functionLocation.Parameters(), r.requiresScopeChange), core.TSTrue, core.TSFalse)
if r.SetRequiresScopeChangeCache != nil {
r.SetRequiresScopeChangeCache(functionLocation, declarationRequiresScopeChange)
}
functionLocation := location
declarationRequiresScopeChange := core.TSUnknown
if r.GetRequiresScopeChangeCache != nil {
declarationRequiresScopeChange = r.GetRequiresScopeChangeCache(functionLocation)
}
if declarationRequiresScopeChange == core.TSUnknown {
declarationRequiresScopeChange = core.IfElse(core.Some(functionLocation.Parameters(), r.requiresScopeChange), core.TSTrue, core.TSFalse)
if r.SetRequiresScopeChangeCache != nil {
r.SetRequiresScopeChangeCache(functionLocation, declarationRequiresScopeChange)
}
return declarationRequiresScopeChange != core.TSTrue
}
return declarationRequiresScopeChange != core.TSTrue
}
}
return false
Expand Down
14 changes: 2 additions & 12 deletions internal/checker/checker.go
Original file line number Diff line number Diff line change
Expand Up @@ -5817,6 +5817,7 @@ func (c *Checker) getIteratedTypeOrElementType(use IterationUse, inputType *Type
}
return nil
}
// TODO: remove ScriptTargetES2015
uplevelIteration := c.languageVersion >= core.ScriptTargetES2015
downlevelIteration := !uplevelIteration && c.compilerOptions.DownlevelIteration == core.TSTrue
possibleOutOfBounds := c.compilerOptions.NoUncheckedIndexedAccess == core.TSTrue && use&IterationUsePossiblyOutOfBounds != 0
Expand Down Expand Up @@ -7675,10 +7676,6 @@ func (c *Checker) checkSuperExpression(node *ast.Node) *Type {
// c.captureLexicalThis(node.Parent, container)
// }
if container.Parent.Kind == ast.KindObjectLiteralExpression {
if c.languageVersion < core.ScriptTargetES2015 {
c.error(node, diagnostics.X_super_is_only_allowed_in_members_of_object_literal_expressions_when_option_target_is_ES2015_or_higher)
return c.errorType
}
// for object literal assume that type of 'super' is 'any'
return c.anyType
}
Expand Down Expand Up @@ -11343,14 +11340,6 @@ func (c *Checker) checkPropertyAccessibilityAtLocation(location *ast.Node, isSup
// - In a static member function or static member accessor
// where this references the constructor function object of a derived class,
// a super property access is permitted and must specify a public static member function of the base class.
if c.languageVersion < core.ScriptTargetES2015 {
if c.symbolHasNonMethodDeclaration(prop) {
if errorNode != nil {
c.error(errorNode, diagnostics.Only_public_and_protected_methods_of_the_base_class_are_accessible_via_the_super_keyword)
}
return false
}
}
if flags&ast.ModifierFlagsAbstract != 0 {
// A method cannot be accessed in a super property access if the method is abstract.
// This error could mask a private property access error. But, a member
Expand Down Expand Up @@ -17356,6 +17345,7 @@ func (c *Checker) getTypeFromArrayBindingPattern(pattern *ast.Node, includePatte
restElement = lastElement
}
if len(elements) == 0 || len(elements) == 1 && restElement != nil {
// TODO: remove ScriptTargetES2015
if c.languageVersion >= core.ScriptTargetES2015 {
return c.createIterableType(c.anyType)
}
Expand Down
12 changes: 0 additions & 12 deletions internal/checker/grammarchecks.go
Original file line number Diff line number Diff line change
Expand Up @@ -1338,9 +1338,6 @@ func (c *Checker) checkGrammarForInOrForOfStatement(forInOrOfStatement *ast.ForI
func (c *Checker) checkGrammarAccessor(accessor *ast.AccessorDeclaration) bool {
body := accessor.Body()
if accessor.Flags&ast.NodeFlagsAmbient == 0 && (accessor.Parent.Kind != ast.KindTypeLiteral) && (accessor.Parent.Kind != ast.KindInterfaceDeclaration) {
if c.languageVersion < core.ScriptTargetES2015 && ast.IsPrivateIdentifier(accessor.Name()) {
return c.grammarErrorOnNode(accessor.Name(), diagnostics.Private_identifiers_are_only_available_when_targeting_ECMAScript_2015_and_higher)
}
if body == nil && !ast.HasSyntacticModifier(accessor, ast.ModifierFlagsAbstract) {
return c.grammarErrorAtPos(accessor, accessor.End()-1, len(";"), diagnostics.X_0_expected, "{")
}
Expand Down Expand Up @@ -1492,9 +1489,6 @@ func (c *Checker) checkGrammarMethod(node *ast.Node /*Union[MethodDeclaration, M
}

if ast.IsClassLike(node.Parent) {
if c.languageVersion < core.ScriptTargetES2015 && ast.IsPrivateIdentifier(node.Name()) {
return c.grammarErrorOnNode(node.Name(), diagnostics.Private_identifiers_are_only_available_when_targeting_ECMAScript_2015_and_higher)
}
// Technically, computed properties in ambient contexts is disallowed
// for property declarations and accessors too, not just methods.
// However, property declarations disallow computed names in general,
Expand Down Expand Up @@ -1934,12 +1928,6 @@ func (c *Checker) checkGrammarProperty(node *ast.Node /*Union[PropertyDeclaratio
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) {
return true
}
if c.languageVersion < core.ScriptTargetES2015 && ast.IsPrivateIdentifier(propertyName) {
return c.grammarErrorOnNode(propertyName, diagnostics.Private_identifiers_are_only_available_when_targeting_ECMAScript_2015_and_higher)
}
if c.languageVersion < core.ScriptTargetES2015 && ast.IsAutoAccessorPropertyDeclaration(node) && node.Flags&ast.NodeFlagsAmbient == 0 {
return c.grammarErrorOnNode(propertyName, diagnostics.Properties_with_the_accessor_modifier_are_only_available_when_targeting_ECMAScript_2015_and_higher)
}
if ast.IsAutoAccessorPropertyDeclaration(node) && c.checkGrammarForInvalidQuestionMark(node.AsPropertyDeclaration().PostfixToken, diagnostics.An_accessor_property_cannot_be_declared_optional) {
return true
}
Expand Down
28 changes: 0 additions & 28 deletions internal/checker/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -1210,20 +1210,6 @@ const (
type TypeComparer func(s *Type, t *Type, reportErrors bool) Ternary

type LanguageFeatureMinimumTargetMap struct {
Classes core.ScriptTarget
ForOf core.ScriptTarget
Generators core.ScriptTarget
Iteration core.ScriptTarget
SpreadElements core.ScriptTarget
RestElements core.ScriptTarget
TaggedTemplates core.ScriptTarget
DestructuringAssignment core.ScriptTarget
BindingPatterns core.ScriptTarget
ArrowFunctions core.ScriptTarget
BlockScopedVariables core.ScriptTarget
ObjectAssign core.ScriptTarget
RegularExpressionFlagsUnicode core.ScriptTarget
RegularExpressionFlagsSticky core.ScriptTarget
Exponentiation core.ScriptTarget
AsyncFunctions core.ScriptTarget
ForAwaitOf core.ScriptTarget
Expand All @@ -1247,20 +1233,6 @@ type LanguageFeatureMinimumTargetMap struct {
}

var LanguageFeatureMinimumTarget = LanguageFeatureMinimumTargetMap{
Classes: core.ScriptTargetES2015,
ForOf: core.ScriptTargetES2015,
Generators: core.ScriptTargetES2015,
Iteration: core.ScriptTargetES2015,
SpreadElements: core.ScriptTargetES2015,
RestElements: core.ScriptTargetES2015,
TaggedTemplates: core.ScriptTargetES2015,
DestructuringAssignment: core.ScriptTargetES2015,
BindingPatterns: core.ScriptTargetES2015,
ArrowFunctions: core.ScriptTargetES2015,
BlockScopedVariables: core.ScriptTargetES2015,
ObjectAssign: core.ScriptTargetES2015,
RegularExpressionFlagsUnicode: core.ScriptTargetES2015,
RegularExpressionFlagsSticky: core.ScriptTargetES2015,
Exponentiation: core.ScriptTargetES2016,
AsyncFunctions: core.ScriptTargetES2017,
ForAwaitOf: core.ScriptTargetES2018,
Expand Down
10 changes: 0 additions & 10 deletions internal/compiler/program.go
Original file line number Diff line number Diff line change
Expand Up @@ -725,20 +725,10 @@ func (p *Program) verifyCompilerOptions() {
createDiagnosticForOptionName(diagnostics.Option_0_cannot_be_specified_with_option_1, "lib", "noLib")
}

languageVersion := options.GetEmitScriptTarget()

firstNonAmbientExternalModuleSourceFile := core.Find(p.files, func(f *ast.SourceFile) bool { return ast.IsExternalModule(f) && !f.IsDeclarationFile })
if options.IsolatedModules.IsTrue() || options.VerbatimModuleSyntax.IsTrue() {
if options.Module == core.ModuleKindNone && languageVersion < core.ScriptTargetES2015 && options.IsolatedModules.IsTrue() {
// !!!
// createDiagnosticForOptionName(diagnostics.Option_isolatedModules_can_only_be_used_when_either_option_module_is_provided_or_option_target_is_ES2015_or_higher, "isolatedModules", "target")
}

if options.PreserveConstEnums.IsFalse() {
createDiagnosticForOptionName(diagnostics.Option_preserveConstEnums_cannot_be_disabled_when_0_is_enabled, core.IfElse(options.VerbatimModuleSyntax.IsTrue(), "verbatimModuleSyntax", "isolatedModules"), "preserveConstEnums")
}
} else if firstNonAmbientExternalModuleSourceFile != nil && languageVersion < core.ScriptTargetES2015 && options.Module == core.ModuleKindNone {
// !!!
}

if options.OutDir != "" ||
Expand Down
1 change: 0 additions & 1 deletion internal/fourslash/_scripts/failingTests.txt
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,6 @@ TestDoubleUnderscoreCompletions
TestEditJsdocType
TestExportDefaultClass
TestExportDefaultFunction
TestFindAllRefsForModule
TestFindAllRefsModuleDotExports
TestFindReferencesBindingPatternInJsdocNoCrash1
TestFindReferencesBindingPatternInJsdocNoCrash2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,14 +140,30 @@ class C2 extends Base {
Label: "protectedOverriddenMethod",
SortText: PtrTo(string(ls.SortTextLocalDeclarationPriority)),
},
&lsproto.CompletionItem{
Label: "protectedOverriddenProperty",
SortText: PtrTo(string(ls.SortTextLocalDeclarationPriority)),
},
&lsproto.CompletionItem{
Label: "protectedProperty",
SortText: PtrTo(string(ls.SortTextLocalDeclarationPriority)),
},
&lsproto.CompletionItem{
Label: "publicMethod",
SortText: PtrTo(string(ls.SortTextLocalDeclarationPriority)),
},
&lsproto.CompletionItem{
Label: "publicProperty",
SortText: PtrTo(string(ls.SortTextLocalDeclarationPriority)),
},
&lsproto.CompletionItem{
Label: "apply",
SortText: PtrTo(string(ls.SortTextLocationPriority)),
},
&lsproto.CompletionItem{
Label: "arguments",
SortText: PtrTo(string(ls.SortTextLocationPriority)),
},
&lsproto.CompletionItem{
Label: "bind",
SortText: PtrTo(string(ls.SortTextLocationPriority)),
Expand All @@ -156,6 +172,18 @@ class C2 extends Base {
Label: "call",
SortText: PtrTo(string(ls.SortTextLocationPriority)),
},
&lsproto.CompletionItem{
Label: "caller",
SortText: PtrTo(string(ls.SortTextLocationPriority)),
},
&lsproto.CompletionItem{
Label: "length",
SortText: PtrTo(string(ls.SortTextLocationPriority)),
},
&lsproto.CompletionItem{
Label: "prototype",
SortText: PtrTo(string(ls.SortTextLocationPriority)),
},
&lsproto.CompletionItem{
Label: "toString",
SortText: PtrTo(string(ls.SortTextLocationPriority)),
Expand Down
2 changes: 1 addition & 1 deletion internal/fourslash/tests/gen/findAllRefsForModule_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (

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

defer testutil.RecoverAndFail(t, "Panic on fourslash test")
const content = `// @allowJs: true
// @Filename: /a.ts
Expand Down
12 changes: 1 addition & 11 deletions internal/printer/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -548,17 +548,7 @@ func (f *NodeFactory) NewDisposeResourcesHelper(envBinding *ast.Expression) *ast
// !!! ES2018 Helpers
// Chains a sequence of expressions using the __assign helper or Object.assign if available in the target
func (f *NodeFactory) NewAssignHelper(attributesSegments []*ast.Expression, scriptTarget core.ScriptTarget) *ast.Expression {
if scriptTarget >= core.ScriptTargetES2015 {
return f.NewCallExpression(f.NewPropertyAccessExpression(f.NewIdentifier("Object"), nil, f.NewIdentifier("assign"), ast.NodeFlagsNone), nil, nil, f.NewNodeList(attributesSegments), ast.NodeFlagsNone)
}
f.emitContext.RequestEmitHelper(assignHelper)
return f.NewCallExpression(
f.NewUnscopedHelperName("__assign"),
nil,
nil,
f.NewNodeList(attributesSegments),
ast.NodeFlagsNone,
)
return f.NewCallExpression(f.NewPropertyAccessExpression(f.NewIdentifier("Object"), nil, f.NewIdentifier("assign"), ast.NodeFlagsNone), nil, nil, f.NewNodeList(attributesSegments), ast.NodeFlagsNone)
}

// ES2018 Destructuring Helpers
Expand Down
17 changes: 0 additions & 17 deletions internal/printer/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,23 +100,6 @@ var disposeResourcesHelper = &EmitHelper{

// !!! Class Fields Helpers
// !!! ES2018 Helpers
var assignHelper = &EmitHelper{
Name: "typescript:assign",
ImportName: "__assign",
Scoped: false,
Priority: &Priority{1},
Text: `var __assign = (this && this.__assign) || function () {
__assign = Object.assign || function(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
t[p] = s[p];
}
return t;
};
return __assign.apply(this, arguments);
};`,
}

// !!! ES2018 Destructuring Helpers
var restHelper = &EmitHelper{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// === documentHighlights ===
// === /b.ts ===
// import { x } from "/*HIGHLIGHTS*/[|./a|]";



// === documentHighlights ===
// === /c/sub.js ===
// const a = require("/*HIGHLIGHTS*/[|../a|]");



// === documentHighlights ===
// === /d.ts ===
// /// <reference path="/*HIGHLIGHTS*/[|./a.ts|]" />
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// === findAllReferences ===
// === /b.ts ===
// import { x } from "/*FIND ALL REFS*/[|./a|]";

// === /c/sub.js ===
// const a = require("[|../a|]");

// === /d.ts ===
// /// <reference path="[|./a.ts|]" />



// === findAllReferences ===
// === /b.ts ===
// import { x } from "[|./a|]";

// === /c/sub.js ===
// const a = require("/*FIND ALL REFS*/[|../a|]");

// === /d.ts ===
// /// <reference path="[|./a.ts|]" />



// === findAllReferences ===
// === /b.ts ===
// import { x } from "[|./a|]";

// === /c/sub.js ===
// const a = require("[|../a|]");

// === /d.ts ===
// /// <reference path="/*FIND ALL REFS*/[|./a.ts|]" />

This file was deleted.

This file was deleted.

This file was deleted.

Loading
Loading