|
|
|
|
|
by karanlyons
2645 days ago
|
|
`as const` is useful there as well, as TypeScript’s type inference only narrows as far as the type and not the literal value. `let z = {text: "hello"}` has the shape `{text: string}`, with `as const` it has the shape `{text: "hello"}`. |
|
Why use "let" along with "as const" instead of mere "const x = 'hello'" for that?