Conversation
| export function isInterpolationToken( | ||
| token: InterpolatedTextToken, | ||
| ): token is InterpolationToken { | ||
| return token.type === TokenType.INTERPOLATION; | ||
| } |
There was a problem hiding this comment.
Let's expose TokenType instead of a function for just InterpolationToken
|
@splincode It's out of scope for this PR, but do you know if we can parse interpolations here? I saw there is a |
|
Yes. I checked it, and So I think we don't need another interpolation parser here. With I'll update prettier/prettier#20117 to use that instead of detecting interpolation tokens from |
Description
Expose
isInterpolationTokentogether with theInterpolationTokenandInterpolatedTextTokentypes from the public package entry point.This lets consumers identify interpolation tokens using parser-owned semantics instead of reimplementing the token structure, for example by checking
parts.lengthand the{{/}}markers.TokenTypeis intentionally kept internal because it is currently aconst enum; the public type guard provides the runtime discriminator without exposing that implementation detail.This is useful for prettier/prettier#20117, where Prettier needs the parser-provided interpolation boundaries when an Angular expression contains
}}.Tests
Added a public API test that verifies the exported type guard and type narrowing against tokens returned by
parse().