MCPcopy Index your code
hub / github.com/microsoft/typescript-go / getFlowTypeInStaticBlocks

Method getFlowTypeInStaticBlocks

internal/checker/flow.go:2458–2481  ·  view source on GitHub ↗
(symbol *ast.Symbol, staticBlocks []*ast.Node)

Source from the content-addressed store, hash-verified

2456}
2457
2458func (c *Checker) getFlowTypeInStaticBlocks(symbol *ast.Symbol, staticBlocks []*ast.Node) *Type {
2459 var accessName *ast.Node
2460 if strings.HasPrefix(symbol.Name, ast.InternalSymbolNamePrefix+"#") {
2461 accessName = c.factory.NewPrivateIdentifier(symbol.Name[strings.Index(symbol.Name, "@")+1:])
2462 } else {
2463 accessName = c.factory.NewIdentifier(symbol.Name)
2464 }
2465 for _, staticBlock := range staticBlocks {
2466 reference := c.factory.NewPropertyAccessExpression(c.factory.NewKeywordExpression(ast.KindThisKeyword), nil, accessName, ast.NodeFlagsNone)
2467 reference.Expression().Parent = reference
2468 reference.Parent = staticBlock
2469 reference.FlowNodeData().FlowNode = staticBlock.AsClassStaticBlockDeclaration().ReturnFlowNode
2470 flowType := c.getFlowTypeOfProperty(reference, symbol)
2471 if c.noImplicitAny && (flowType == c.autoType || flowType == c.autoArrayType) {
2472 c.error(symbol.ValueDeclaration, diagnostics.Member_0_implicitly_has_an_1_type, c.symbolToString(symbol), c.TypeToString(flowType))
2473 }
2474 // We don't infer a type if assignments are only null or undefined.
2475 if everyType(flowType, c.IsNullableType) {
2476 continue
2477 }
2478 return c.convertAutoToAny(flowType)
2479 }
2480 return nil
2481}
2482
2483func (c *Checker) isReachableFlowNode(flow *ast.FlowNode) bool {
2484 f := c.getFlowState()

Callers 1

Calls 13

getFlowTypeOfPropertyMethod · 0.95
errorMethod · 0.95
symbolToStringMethod · 0.95
TypeToStringMethod · 0.95
convertAutoToAnyMethod · 0.95
everyTypeFunction · 0.85
NewPrivateIdentifierMethod · 0.80
NewIdentifierMethod · 0.80
NewKeywordExpressionMethod · 0.80
ExpressionMethod · 0.80

Tested by

no test coverage detected