@@ -3257,9 +3257,6 @@ func (c *Checker) checkFunctionOrMethodDeclaration(node *ast.Node) {
32573257 if c.getContextualCallSignature(c.getTypeFromTypeNode(node.FunctionLikeData().FullSignature), node) == nil {
32583258 c.error(node.FunctionLikeData().FullSignature, diagnostics.A_JSDoc_type_tag_on_a_function_must_have_a_signature_with_the_correct_number_of_arguments)
32593259 }
3260- if node.Type() != nil || core.Some(node.Parameters(), func(p *ast.Node) bool { return p.Type() != nil }) {
3261- c.error(node.FunctionLikeData().FullSignature, diagnostics.A_JSDoc_type_tag_may_not_occur_with_a_param_or_returns_tag)
3262- }
32633260 }
32643261 if node.Type() == nil {
32653262 // Report an implicit any error if there is no body, no explicit return type, and node is not a private method
@@ -5817,6 +5814,7 @@ func (c *Checker) getIteratedTypeOrElementType(use IterationUse, inputType *Type
58175814 }
58185815 return nil
58195816 }
5817+ // TODO: remove ScriptTargetES2015
58205818 uplevelIteration := c.languageVersion >= core.ScriptTargetES2015
58215819 downlevelIteration := !uplevelIteration && c.compilerOptions.DownlevelIteration == core.TSTrue
58225820 possibleOutOfBounds := c.compilerOptions.NoUncheckedIndexedAccess == core.TSTrue && use&IterationUsePossiblyOutOfBounds != 0
@@ -7675,10 +7673,6 @@ func (c *Checker) checkSuperExpression(node *ast.Node) *Type {
76757673 // c.captureLexicalThis(node.Parent, container)
76767674 // }
76777675 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- }
76827676 // for object literal assume that type of 'super' is 'any'
76837677 return c.anyType
76847678 }
@@ -9833,9 +9827,6 @@ func (c *Checker) checkFunctionExpressionOrObjectLiteralMethod(node *ast.Node, c
98339827 if c.getContextualCallSignature(c.getTypeFromTypeNode(node.FunctionLikeData().FullSignature), node) == nil {
98349828 c.error(node.FunctionLikeData().FullSignature, diagnostics.A_JSDoc_type_tag_on_a_function_must_have_a_signature_with_the_correct_number_of_arguments)
98359829 }
9836- if node.Type() != nil || core.Some(node.Parameters(), func(p *ast.Node) bool { return p.Type() != nil }) {
9837- c.error(node.FunctionLikeData().FullSignature, diagnostics.A_JSDoc_type_tag_may_not_occur_with_a_param_or_returns_tag)
9838- }
98399830 }
98409831 c.contextuallyCheckFunctionExpressionOrObjectLiteralMethod(node, checkMode)
98419832 return c.getTypeOfSymbol(c.getSymbolOfDeclaration(node))
@@ -11343,14 +11334,6 @@ func (c *Checker) checkPropertyAccessibilityAtLocation(location *ast.Node, isSup
1134311334 // - In a static member function or static member accessor
1134411335 // where this references the constructor function object of a derived class,
1134511336 // 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- }
1135411337 if flags&ast.ModifierFlagsAbstract != 0 {
1135511338 // A method cannot be accessed in a super property access if the method is abstract.
1135611339 // This error could mask a private property access error. But, a member
@@ -11689,12 +11672,11 @@ func (c *Checker) TryGetThisTypeAtEx(node *ast.Node, includeGlobalThis bool, con
1168911672 container = c.getThisContainer(node, false /*includeArrowFunctions*/, false /*includeClassComputedPropertyName*/)
1169011673 }
1169111674 if ast.IsFunctionLike(container) && (!c.isInParameterInitializerBeforeContainingFunction(node) || ast.GetThisParameter(container) != nil) {
11692- thisType := c.getThisTypeOfDeclaration(container)
11693- if thisType == nil && ast.IsInJSFile(container) {
11694- if sig := c.getSignatureOfFullSignatureType(container); sig != nil {
11695- thisType = c.getThisTypeOfSignature(sig)
11696- }
11675+ sig := c.getSignatureOfFullSignatureType(container)
11676+ if sig == nil {
11677+ sig = c.getSignatureFromDeclaration(container)
1169711678 }
11679+ thisType := c.getThisTypeOfSignature(sig)
1169811680 // Note: a parameter initializer should refer to class-this unless function-this is explicitly annotated.
1169911681 // If this is a function in a JS file, it might be a class method.
1170011682 if thisType == nil {
@@ -11793,10 +11775,6 @@ func (c *Checker) isInParameterInitializerBeforeContainingFunction(node *ast.Nod
1179311775 return false
1179411776}
1179511777
11796- func (c *Checker) getThisTypeOfDeclaration(declaration *ast.Node) *Type {
11797- return c.getThisTypeOfSignature(c.getSignatureFromDeclaration(declaration))
11798- }
11799-
1180011778func (c *Checker) checkThisInStaticClassFieldInitializerInDecoratedClass(thisExpression *ast.Node, container *ast.Node) {
1180111779 if ast.IsPropertyDeclaration(container) && ast.HasStaticModifier(container) && c.legacyDecorators {
1180211780 initializer := container.Initializer()
@@ -17356,6 +17334,7 @@ func (c *Checker) getTypeFromArrayBindingPattern(pattern *ast.Node, includePatte
1735617334 restElement = lastElement
1735717335 }
1735817336 if len(elements) == 0 || len(elements) == 1 && restElement != nil {
17337+ // TODO: remove ScriptTargetES2015
1735917338 if c.languageVersion >= core.ScriptTargetES2015 {
1736017339 return c.createIterableType(c.anyType)
1736117340 }
@@ -19101,11 +19080,11 @@ func (c *Checker) getSignaturesOfSymbol(symbol *ast.Symbol) []*Signature {
1910119080 }
1910219081 // If this is a function or method declaration, get the signature from the @type tag for the sake of optional parameters.
1910319082 // 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
19083+ sig := c.getSignatureOfFullSignatureType(decl)
19084+ if sig == nil {
19085+ sig = c.getSignatureFromDeclaration(decl)
1910719086 }
19108- result = append(result, c.getSignatureFromDeclaration(decl) )
19087+ result = append(result, sig )
1910919088 }
1911019089 return result
1911119090}
@@ -19187,15 +19166,13 @@ func (c *Checker) getSignatureFromDeclaration(declaration *ast.Node) *Signature
1918719166}
1918819167
1918919168func (c *Checker) getTypeParametersFromDeclaration(declaration *ast.Node) []*Type {
19169+ if sig := c.getSignatureOfFullSignatureType(declaration); sig != nil {
19170+ return sig.TypeParameters()
19171+ }
1919019172 var result []*Type
1919119173 for _, node := range declaration.TypeParameters() {
1919219174 result = core.AppendIfUnique(result, c.getDeclaredTypeOfTypeParameter(node.Symbol()))
1919319175 }
19194- if len(result) == 0 && ast.IsFunctionDeclaration(declaration) {
19195- if sig := c.getSignatureOfFullSignatureType(declaration); sig != nil {
19196- return sig.TypeParameters()
19197- }
19198- }
1919919176 return result
1920019177}
1920119178
0 commit comments