I'm just writing some code in the TypeScript playground, and found that unique
appears to be a reserved word, but I can't find any documentation for it.
Is there any documentation on this keyword anywhere?
As of TypeScript 2.7 there is a unique symbol
type which is used to allow using symbols as unique literals. The relevant documentation is here, and @TitianCernicovaDragomir linked the relevant pull request that introduced this functionality.
As for why it's blue in the Playground, I guess its colorization isn't the best and just highlights any special word even if it's not being used in a special context. (I can't find a relevant GitHub issue about it; maybe someone should file one?). It's definitely a valid identifier, and the emitted JavaScript is correct. VSCode doesn't seem to have this issue:
Compare Playground weird colorizing:
to VSCode expected colorizing:
Oh well. Hope that helps; good luck!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With