Hacker News new | ask | show | jobs
by mcaruso 2447 days ago
`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.
2 comments

My god, you are right!

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

Oh wow! Great, thanks. I wonder how I recalled that wrong.