Typescript: destructuring an object with symbols as keys
You just need to declare the symbol
as const
to make the compiler infer a literal type for it and not the general Symbol
type.
const symbol = Symbol()let obj = { [symbol] : 'value'}let { [symbol]: alias } = objconsole.log(alias)
This PR might be useful as to when typescript infers a unique symbol