News for hackers. Stuff that matters.
Re:TypeScript 3.7 Beta by skrebbel on Wednesday October 02, 2019 @07:43AM (#21135355)
I have.

It's when you do

    const dir = "up"; // TS infers type "string"
    test(dir); // error
For mutable variables (let/var), you usually want TS to infer `string` in the first line. IMO the fact that they also infer `string` for constants is a design flaw, that I hope will one day be fixed.

They recently added a feature to make this less painful:

    const dir = "up" as const;
    test(dir); // works

That's the same as `as "up"` bit without having to duplicate the string.
Re:TypeScript 3.7 Beta by mcaruso on Wednesday October 02, 2019 @09:45AM (#21136333)
`const` variables are actually inferred without widening. So in your example `dir` would be inferred as `"up"`, not `string`. If you use `let` (or `var`) however that would be true.
Re:TypeScript 3.7 Beta by azangru on Wednesday October 02, 2019 @10:07AM (#21136578)
My god, you are right!

(example in typescript playground: https://www.typescriptlang.org/play/#code/C4TwDgpgBAIglgJwgY...)

Re:TypeScript 3.7 Beta by skrebbel on Wednesday October 02, 2019 @11:46AM (#21137721)
Oh wow! Great, thanks. I wonder how I recalled that wrong.