#Typescript won't allow me to assert a type?
8 messages · Page 1 of 1 (latest)
Preview:ts const foo = {} as unknown as [ string, Record<string, string> ] // foo is still given as [string, any]??
You can choose specific lines to embed by selecting them before copying the link.
No it still shows Record in the playground
yeah, looks right to me:
const foo = {} as unknown as [string, Record<string, string>]; // foo is still given as [string, any]??
// ^? - const foo: [string, Record<string, string>]
const bar = foo[1]['test']
// ^? - const bar: string
@elfin osprey if you're using VSCode maybe try restarting tsserver? otherwise if you can share more details about your setup that'd be great
using nvim with ts lsp - restarted lsp multiple times to no avail and resorted to // @ts-ignore for that one variable just to retype it one line below. Later on I've moved the function containing bar out of the scope where the type in question was inferred and there it works as intended