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

Function getErrorRangeForArrowFunction

internal/scanner/scanner.go:2542–2554  ·  view source on GitHub ↗
(sourceFile *ast.SourceFile, node *ast.Node)

Source from the content-addressed store, hash-verified

2540}
2541
2542func getErrorRangeForArrowFunction(sourceFile *ast.SourceFile, node *ast.Node) core.TextRange {
2543 pos := SkipTrivia(sourceFile.Text(), node.Pos())
2544 body := node.Body()
2545 if body != nil && body.Kind == ast.KindBlock {
2546 startLine := GetECMALineOfPosition(sourceFile, body.Pos())
2547 endLine := GetECMALineOfPosition(sourceFile, body.End())
2548 if startLine < endLine {
2549 // The arrow function spans multiple lines, make the error span be the first line, inclusive.
2550 return core.NewTextRange(pos, GetECMAEndLinePosition(sourceFile, startLine)+1)
2551 }
2552 }
2553 return core.NewTextRange(pos, node.End())
2554}
2555
2556func findOriginatingJSDocSatisfiesTag(sourceFile *ast.SourceFile, node *ast.Node) *ast.Node {
2557 targetType := node.AsSatisfiesExpression().Type

Callers 1

GetErrorRangeForNodeFunction · 0.85

Calls 8

NewTextRangeFunction · 0.92
SkipTriviaFunction · 0.85
GetECMALineOfPositionFunction · 0.85
GetECMAEndLinePositionFunction · 0.85
BodyMethod · 0.80
TextMethod · 0.65
PosMethod · 0.65
EndMethod · 0.65

Tested by

no test coverage detected