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

Method isStartOfType

internal/parser/parser.go:6210–6231  ·  view source on GitHub ↗
(inStartOfParameter bool)

Source from the content-addressed store, hash-verified

6208}
6209
6210func (p *Parser) isStartOfType(inStartOfParameter bool) bool {
6211 switch p.token {
6212 case ast.KindAnyKeyword, ast.KindUnknownKeyword, ast.KindStringKeyword, ast.KindNumberKeyword, ast.KindBigIntKeyword,
6213 ast.KindBooleanKeyword, ast.KindReadonlyKeyword, ast.KindSymbolKeyword, ast.KindUniqueKeyword, ast.KindVoidKeyword,
6214 ast.KindUndefinedKeyword, ast.KindNullKeyword, ast.KindThisKeyword, ast.KindTypeOfKeyword, ast.KindNeverKeyword,
6215 ast.KindOpenBraceToken, ast.KindOpenBracketToken, ast.KindLessThanToken, ast.KindBarToken, ast.KindAmpersandToken,
6216 ast.KindNewKeyword, ast.KindStringLiteral, ast.KindNumericLiteral, ast.KindBigIntLiteral, ast.KindTrueKeyword,
6217 ast.KindFalseKeyword, ast.KindObjectKeyword, ast.KindAsteriskToken, ast.KindQuestionToken, ast.KindExclamationToken,
6218 ast.KindDotDotDotToken, ast.KindInferKeyword, ast.KindImportKeyword, ast.KindAssertsKeyword, ast.KindNoSubstitutionTemplateLiteral,
6219 ast.KindTemplateHead:
6220 return true
6221 case ast.KindFunctionKeyword:
6222 return !inStartOfParameter
6223 case ast.KindMinusToken:
6224 return !inStartOfParameter && p.lookAhead((*Parser).nextTokenIsNumericOrBigIntLiteral)
6225 case ast.KindOpenParenToken:
6226 // Only consider '(' the start of a type if followed by ')', '...', an identifier, a modifier,
6227 // or something that starts a type. We don't want to consider things like '(1)' a type.
6228 return !inStartOfParameter && p.lookAhead((*Parser).nextIsParenthesizedOrFunctionType)
6229 }
6230 return p.isIdentifier()
6231}
6232
6233func (p *Parser) nextTokenIsNumericOrBigIntLiteral() bool {
6234 p.nextToken()

Callers 6

isListElementMethod · 0.95
nextIsStartOfTypeMethod · 0.95
parseTypeParameterMethod · 0.95
isStartOfParameterMethod · 0.95

Calls 2

lookAheadMethod · 0.95
isIdentifierMethod · 0.95

Tested by

no test coverage detected