I'm trying to use symbols in my typescript code (using es-5 as target). However, the following code gives an error TS2304: Cannot find name 'Symbol'
var sym = Symbol();
According to the roadmap, symbols are supported since version 1.5. But I guess one thing is supporting symbols and a different one is transpiling symbols to es-5.
What is the best way to get symbols working in my es-5 transpiled code?
By default TypeScript does not offer poly-fills for future changes to the standard library when compiling to older versions, it only offers syntactic changes.
That means Symbol is not available when compiling to ES5 but is available when compiling to ES6.
If you want to use ES6 standard library changes when compiling to older ES versions you can use core.js to get the poly-fills.
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