Join Nostr
2025-02-16 18:39:13 UTC

Axel Rauschmayer on Nostr: #TypeScript: Is it possible to create an object that is assignable to the following ...

#TypeScript: Is it possible to create an object that is assignable to the following type (without using `as`)?

type Obj = {
readonly sym: unique symbol,
};

const SYM: unique symbol = Symbol('SYM');
const obj: Obj = {
sym: SYM,
// Type 'typeof SYM' is not assignable to type 'typeof sym'.
};