`typeof` unique symbol is treated as `symbol` in JSDoc
DRANK

🔎 Search Terms typeof unique symbol jsdoc 🕗 Version & Regression Information This is the behavior in every version I tried, and I reviewed the FAQ for entries about unique symbols I tested v5.8.0-beta through v4.7.4 in the playground. Prior versions don't let you use @type {unique symbol} (#48231) ⏯ Playground Link https://www.typescriptlang.org/play/?ts=5.8.0-beta&filetype=js#code/PQKhAIAEBcE8AcCm4DeBXAdgSwI5uQM6wC2ARgPYA2AvuCMAFADG5GB04AHuALzgDKJCpQAUASgagIMBMnTY8hIVVr1mrduFi8By0RMlgocJKhOJyAMy6rGlRBwBeOzgwbOefWEA 💻 Code /** @type {unique symbol} */ const x = Symbol() /** @type {unique symbol} */ const y = Symbol() /** @type {typeof x} */ let z = x z == y // Should produce an error, but doesn't! 🙁 Actual behavior The type of z is reported as symbol even though I assigned it typeof x. When I compare z == y, there's no error about comparing two unique symbols. 🙂 Expected behavior The behavior in JSDoc should match the behavior in the equivalent typescript, which correctly reports the error: Playground const x: unique symbol = Symbol() const y: unique symbol = Symbol() let z: typeof x = x z == y // Correctly produces error ts(2367) Additional information about the issue No response

github.com
Related Topics: TypeScript
1 comments