Not quite sure what I'm missing here #245
-
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
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 goal of Unfortunately it won't be enough for the TS compiler to understand the narrowing you expect here. Maybe in future iterations of TS ;) |
Beta Was this translation helpful? Give feedback.
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 aboolean
and in this case it will betrue
.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 ;)