@@ -721,8 +721,8 @@ type Checker struct {
721
721
lastGetCombinedNodeFlagsResult ast.NodeFlags
722
722
lastGetCombinedModifierFlagsNode *ast.Node
723
723
lastGetCombinedModifierFlagsResult ast.ModifierFlags
724
- inferenceStates [] InferenceState
725
- flowStates [] FlowState
724
+ freeinferenceState * InferenceState
725
+ freeFlowState * FlowState
726
726
flowLoopCache map[FlowLoopKey]*Type
727
727
flowLoopStack []FlowLoopInfo
728
728
sharedFlows []SharedFlow
@@ -741,7 +741,7 @@ type Checker struct {
741
741
reverseMappedSourceStack []*Type
742
742
reverseMappedTargetStack []*Type
743
743
reverseExpandingFlags ExpandingFlags
744
- relaters [] Relater
744
+ freeRelater * Relater
745
745
subtypeRelation *Relation
746
746
strictSubtypeRelation *Relation
747
747
assignableRelation *Relation
@@ -791,6 +791,7 @@ type Checker struct {
791
791
getGlobalClassMethodDecoratorContextType func() *Type
792
792
getGlobalClassGetterDecoratorContextType func() *Type
793
793
getGlobalClassSetterDecoratorContextType func() *Type
794
+ getGlobalClassAccessorDecoratorContxtType func() *Type
794
795
getGlobalClassAccessorDecoratorContextType func() *Type
795
796
getGlobalClassAccessorDecoratorTargetType func() *Type
796
797
getGlobalClassAccessorDecoratorResultType func() *Type
@@ -2171,6 +2172,8 @@ func (c *Checker) checkSourceElementWorker(node *ast.Node) {
2171
2172
c.checkTypeAliasDeclaration(node)
2172
2173
case ast.KindEnumDeclaration:
2173
2174
c.checkEnumDeclaration(node)
2175
+ case ast.KindEnumMember:
2176
+ c.checkEnumMember(node)
2174
2177
case ast.KindModuleDeclaration:
2175
2178
c.checkModuleDeclaration(node)
2176
2179
case ast.KindImportDeclaration:
@@ -4270,7 +4273,7 @@ basePropertyCheck:
4270
4273
for errorNode, memberInfo := range notImplementedInfo {
4271
4274
switch {
4272
4275
case len(memberInfo.missedProperties) == 1:
4273
- missedProperty := "'" + memberInfo.missedProperties[0] + "'"
4276
+ missedProperty := memberInfo.missedProperties[0]
4274
4277
if ast.IsClassExpression(errorNode) {
4275
4278
c.error(errorNode, diagnostics.Non_abstract_class_expression_does_not_implement_inherited_abstract_member_0_from_class_1, missedProperty, memberInfo.baseTypeName)
4276
4279
} else {
@@ -4711,6 +4714,15 @@ func (c *Checker) checkEnumDeclaration(node *ast.Node) {
4711
4714
}
4712
4715
}
4713
4716
4717
+ func (c *Checker) checkEnumMember(node *ast.Node) {
4718
+ if ast.IsPrivateIdentifier(node.Name()) {
4719
+ c.error(node, diagnostics.An_enum_member_cannot_be_named_with_a_private_identifier)
4720
+ }
4721
+ if node.Initializer() != nil {
4722
+ c.checkExpression(node.Initializer())
4723
+ }
4724
+ }
4725
+
4714
4726
func (c *Checker) checkModuleDeclaration(node *ast.Node) {
4715
4727
if body := node.Body(); body != nil {
4716
4728
c.checkSourceElement(body)
@@ -8025,7 +8037,7 @@ func (c *Checker) isConstructorAccessible(node *ast.Node, signature *Signature)
8025
8037
declaration := signature.declaration
8026
8038
modifiers := getSelectedEffectiveModifierFlags(declaration, ast.ModifierFlagsNonPublicAccessibilityModifier)
8027
8039
// (1) Public constructors and (2) constructor functions are always accessible.
8028
- if modifiers == 0 || ast.IsConstructorDeclaration(declaration) {
8040
+ if modifiers == 0 || ! ast.IsConstructorDeclaration(declaration) {
8029
8041
return true
8030
8042
}
8031
8043
declaringClassDeclaration := getClassLikeDeclarationOfSymbol(declaration.Parent.Symbol())
@@ -9619,7 +9631,7 @@ func (c *Checker) isAritySmaller(signature *Signature, target *ast.Node) bool {
9619
9631
}
9620
9632
targetParameterCount++
9621
9633
}
9622
- if len(parameters) != 0 && parameterIsThisKeyword (parameters[0]) {
9634
+ if len(parameters) != 0 && ast.IsThisParameter (parameters[0]) {
9623
9635
targetParameterCount--
9624
9636
}
9625
9637
return !c.hasEffectiveRestParameter(signature) && c.getParameterCount(signature) < targetParameterCount
@@ -10449,7 +10461,7 @@ func (c *Checker) checkPropertyAccessChain(node *ast.Node, checkMode CheckMode)
10449
10461
}
10450
10462
10451
10463
func (c *Checker) checkPropertyAccessExpressionOrQualifiedName(node *ast.Node, left *ast.Node, leftType *Type, right *ast.Node, checkMode CheckMode, writeOnly bool) *Type {
10452
- parentSymbol := c.typeNodeLinks.Get(node ).resolvedSymbol
10464
+ parentSymbol := c.typeNodeLinks.Get(left ).resolvedSymbol
10453
10465
assignmentKind := getAssignmentTargetKind(node)
10454
10466
widenedType := leftType
10455
10467
if assignmentKind != AssignmentKindNone || c.isMethodAccessForCall(node) {
@@ -11521,7 +11533,8 @@ func (c *Checker) checkBinaryLikeExpression(left *ast.Node, operatorToken *ast.N
11521
11533
ast.KindGreaterThanGreaterThanGreaterThanEqualsToken:
11522
11534
rhsEval := c.evaluate(right, right)
11523
11535
if numValue, ok := rhsEval.Value.(jsnum.Number); ok && numValue.Abs() >= 32 {
11524
- c.errorOrSuggestion(ast.IsEnumMember(ast.WalkUpParenthesizedExpressions(right.Parent.Parent)), errorNode, diagnostics.This_operation_can_be_simplified_This_shift_is_identical_to_0_1_2, scanner.GetTextOfNode(left), scanner.TokenToString(operator), (numValue / 32).Floor())
11536
+ // Elevate from suggestion to error within an enum member
11537
+ c.errorOrSuggestion(ast.IsEnumMember(ast.WalkUpParenthesizedExpressions(right.Parent.Parent)), errorNode, diagnostics.This_operation_can_be_simplified_This_shift_is_identical_to_0_1_2, scanner.GetTextOfNode(left), scanner.TokenToString(operator), numValue.Remainder(32))
11525
11538
}
11526
11539
}
11527
11540
}
@@ -15014,7 +15027,7 @@ func (c *Checker) getTypeOfVariableOrParameterOrPropertyWorker(symbol *ast.Symbo
15014
15027
case ast.KindPropertyAssignment:
15015
15028
result = c.checkPropertyAssignment(declaration, CheckModeNormal)
15016
15029
case ast.KindShorthandPropertyAssignment:
15017
- result = c.checkExpressionForMutableLocation(declaration, CheckModeNormal)
15030
+ result = c.checkExpressionForMutableLocation(declaration.Name() , CheckModeNormal)
15018
15031
case ast.KindMethodDeclaration:
15019
15032
result = c.checkObjectLiteralMethod(declaration, CheckModeNormal)
15020
15033
case ast.KindExportAssignment:
@@ -17983,7 +17996,7 @@ func (c *Checker) getSignaturesOfSymbol(symbol *ast.Symbol) []*Signature {
17983
17996
}
17984
17997
}
17985
17998
// If this is a function or method declaration, get the signature from the @type tag for the sake of optional parameters.
17986
- // Exclude contextually-typed kinds because we already apply the @type tag to the context, plus applying it here to the initializer would supress checks that the two are compatible.
17999
+ // 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.
17987
18000
result = append(result, c.getSignatureFromDeclaration(decl))
17988
18001
}
17989
18002
return result
@@ -18245,7 +18258,7 @@ func getEffectiveSetAccessorTypeAnnotationNode(node *ast.Node) *ast.Node {
18245
18258
func getSetAccessorValueParameter(accessor *ast.Node) *ast.Node {
18246
18259
parameters := accessor.Parameters()
18247
18260
if len(parameters) > 0 {
18248
- hasThis := len(parameters) == 2 && parameterIsThisKeyword (parameters[0])
18261
+ hasThis := len(parameters) == 2 && ast.IsThisParameter (parameters[0])
18249
18262
return parameters[core.IfElse(hasThis, 1, 0)]
18250
18263
}
18251
18264
return nil
@@ -20228,7 +20241,7 @@ func (c *Checker) instantiateTypeWithAlias(t *Type, m *TypeMapper, alias *TypeAl
20228
20241
}
20229
20242
if c.instantiationDepth == 100 || c.instantiationCount >= 5_000_000 {
20230
20243
// We have reached 100 recursive type instantiations, or 5M type instantiations caused by the same statement
20231
- // or expression. There is a very high likelyhood we're dealing with a combination of infinite generic types
20244
+ // or expression. There is a very high likelihood we're dealing with a combination of infinite generic types
20232
20245
// that perpetually generate new type identities, so we stop the recursion here by yielding the error type.
20233
20246
c.error(c.currentNode, diagnostics.Type_instantiation_is_excessively_deep_and_possibly_infinite)
20234
20247
return c.errorType
@@ -20451,6 +20464,20 @@ func (c *Checker) getObjectTypeInstantiation(t *Type, m *TypeMapper, alias *Type
20451
20464
result = c.instantiateAnonymousType(target, newMapper, newAlias)
20452
20465
}
20453
20466
data.instantiations[key] = result
20467
+ if result.flags&TypeFlagsObjectFlagsType != 0 && result.objectFlags&ObjectFlagsCouldContainTypeVariablesComputed == 0 {
20468
+ // if `result` is one of the object types we tried to make (it may not be, due to how `instantiateMappedType` works), we can carry forward the type variable containment check from the input type arguments
20469
+ resultCouldContainObjectFlags := core.Some(typeArguments, c.couldContainTypeVariables)
20470
+ if result.objectFlags&ObjectFlagsCouldContainTypeVariablesComputed == 0 {
20471
+ if result.objectFlags&(ObjectFlagsMapped|ObjectFlagsAnonymous|ObjectFlagsReference) != 0 {
20472
+ result.objectFlags |= ObjectFlagsCouldContainTypeVariablesComputed | core.IfElse(resultCouldContainObjectFlags, ObjectFlagsCouldContainTypeVariables, 0)
20473
+ } else {
20474
+ // If none of the type arguments for the outer type parameters contain type variables, it follows
20475
+ // that the instantiated type doesn't reference type variables.
20476
+ // Intrinsics have `CouldContainTypeVariablesComputed` pre-set, so this should only cover unions and intersections resulting from `instantiateMappedType`
20477
+ result.objectFlags |= core.IfElse(!resultCouldContainObjectFlags, ObjectFlagsCouldContainTypeVariablesComputed, 0)
20478
+ }
20479
+ }
20480
+ }
20454
20481
}
20455
20482
return result
20456
20483
}
@@ -21885,6 +21912,7 @@ func (c *Checker) createComputedEnumType(symbol *ast.Symbol) *Type {
21885
21912
freshType := c.newLiteralType(TypeFlagsEnum, nil, regularType)
21886
21913
freshType.symbol = symbol
21887
21914
regularType.AsLiteralType().freshType = freshType
21915
+ freshType.AsLiteralType().freshType = freshType
21888
21916
return regularType
21889
21917
}
21890
21918
0 commit comments