Skip to content

Not quite sure what I'm missing here #245

Closed Answered by gustavoguichard
amritk asked this question in Q&A
Discussion options

You must be logged in to vote

Hi @amritk , would you mind sending me a TS playground example so I can better understand your problem and maybe fix a potential bug?

[edit]: If I undestood it right, it is not what you'd expect.
The resulting value of native startsWith is a boolean and in this case it will be true.
Check this example:

The goal of string-ts is to have a consistent result for the common string functions at both runtime and type levels, which is happening in this case.

Unfortunately it won't be enough for the TS compiler to understand the narrowing you expect here. Maybe in future iterations of TS ;)

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@amritk
Comment options

@amritk
Comment options

@gustavoguichard
Comment options

Answer selected by gustavoguichard
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants