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

Method checkNonNullTypeWithReporter

internal/checker/checker.go:7390–7412  ·  view source on GitHub ↗
(t *Type, node *ast.Node, reportError func(c *Checker, node *ast.Node, facts TypeFacts))

Source from the content-addressed store, hash-verified

7388}
7389
7390func (c *Checker) checkNonNullTypeWithReporter(t *Type, node *ast.Node, reportError func(c *Checker, node *ast.Node, facts TypeFacts)) *Type {
7391 if c.strictNullChecks && t.flags&TypeFlagsUnknown != 0 {
7392 if ast.IsEntityNameExpression(node) {
7393 nodeText := entityNameToString(node)
7394 if len(nodeText) < 100 {
7395 c.error(node, diagnostics.X_0_is_of_type_unknown, nodeText)
7396 return c.errorType
7397 }
7398 }
7399 c.error(node, diagnostics.Object_is_of_type_unknown)
7400 return c.errorType
7401 }
7402 facts := c.getTypeFacts(t, TypeFactsIsUndefinedOrNull)
7403 if facts&TypeFactsIsUndefinedOrNull != 0 {
7404 reportError(c, node, facts)
7405 nonNullable := c.GetNonNullableType(t)
7406 if nonNullable.flags&(TypeFlagsNullable|TypeFlagsNever) != 0 {
7407 return c.errorType
7408 }
7409 return nonNullable
7410 }
7411 return t
7412}
7413
7414func (c *Checker) checkNonNullNonVoidType(t *Type, node *ast.Node) *Type {
7415 nonNullType := c.checkNonNullType(t, node)

Callers 2

checkNonNullTypeMethod · 0.95
resolveCallExpressionMethod · 0.95

Calls 7

errorMethod · 0.95
getTypeFactsMethod · 0.95
GetNonNullableTypeMethod · 0.95
IsEntityNameExpressionFunction · 0.92
lenFunction · 0.85
reportErrorFunction · 0.85
entityNameToStringFunction · 0.70

Tested by

no test coverage detected