MCPcopy Create free account
hub / github.com/microsoft/typescript-go / isConstTypeVariable

Method isConstTypeVariable

internal/checker/checker.go:13577–13603  ·  view source on GitHub ↗
(t *Type, depth int)

Source from the content-addressed store, hash-verified

13575}
13576
13577func (c *Checker) isConstTypeVariable(t *Type, depth int) bool {
13578 if depth >= 5 || t == nil {
13579 return false
13580 }
13581 switch {
13582 case t.flags&TypeFlagsTypeParameter != 0:
13583 return t.symbol != nil && core.Some(t.symbol.Declarations, func(d *ast.Node) bool { return ast.HasSyntacticModifier(d, ast.ModifierFlagsConst) })
13584 case t.flags&TypeFlagsUnionOrIntersection != 0:
13585 return core.Some(t.Types(), func(s *Type) bool { return c.isConstTypeVariable(s, depth) })
13586 case t.flags&TypeFlagsIndexedAccess != 0:
13587 return c.isConstTypeVariable(t.AsIndexedAccessType().objectType, depth+1)
13588 case t.flags&TypeFlagsConditional != 0:
13589 return c.isConstTypeVariable(c.getConstraintOfConditionalType(t), depth+1)
13590 case t.flags&TypeFlagsSubstitution != 0:
13591 return c.isConstTypeVariable(t.AsSubstitutionType().baseType, depth)
13592 case t.objectFlags&ObjectFlagsMapped != 0:
13593 typeVariable := c.getHomomorphicTypeVariable(t)
13594 return typeVariable != nil && c.isConstTypeVariable(typeVariable, depth)
13595 case c.isGenericTupleType(t):
13596 for i, s := range c.getElementTypes(t) {
13597 if t.TargetTupleType().elementInfos[i].flags&ElementFlagsVariadic != 0 && c.isConstTypeVariable(s, depth) {
13598 return true
13599 }
13600 }
13601 }
13602 return false
13603}
13604
13605func (c *Checker) checkPropertyAssignment(node *ast.Node, checkMode CheckMode) *Type {
13606 // Do not use hasDynamicName here, because that returns false for well known symbols.

Callers 4

applyToParameterTypesMethod · 0.95
getCovariantInferenceMethod · 0.95
isConstContextMethod · 0.95
getSpreadArgumentTypeMethod · 0.95

Calls 10

isGenericTupleTypeMethod · 0.95
getElementTypesMethod · 0.95
SomeFunction · 0.92
HasSyntacticModifierFunction · 0.92
AsIndexedAccessTypeMethod · 0.80
AsSubstitutionTypeMethod · 0.80
TargetTupleTypeMethod · 0.80
TypesMethod · 0.45

Tested by

no test coverage detected