23622

Cannot find name Symbol

Question:

For the below code:

const MY_KEY: symbol = Symbol(); let obj: object = {}; obj[MY_KEY] = 123; console.log(obj[MY_KEY]); // 123

For the below configuration tscconfig.json:

{ "compilerOptions": { "lib": ["es2015"] }, } <hr />

Files

$ ls tsconfig.json tstut.html tstut.js tstut.ts <hr />

How to resolve below error?

$ tsc --version Version 2.8.3 $ tsc tstut.ts tstut.ts(1,24): error TS2304: Cannot find name 'Symbol'. <hr />

Answer1:

In your configuration file (tsconfig.json), specify ECMAScript target version to 'ES2015' or later ('ES2016', 'ES2017','ES2018' or 'ESNEXT'). 'ES6' works for me, too.

{ "compilerOptions": { "target": "ES2015", } }

Recommend

  • TS7016: Could not find a declaration file for module 'faker/locale/en_CA'
  • Combine mocha, Typescript (and watch)
  • How to pass ngModel to AngularJS component without 2-way binding?
  • RxJs-5-to-6-migrate crashes
  • How to add a define to an ASP.net solution?
  • How to display command output in a whiptail textbox
  • how to deal with the serial port in android mobile?
  • git status vs fetch (or pull): How to know what “up-to-date” means (without changing anything)
  • setuid program owned by non-root user
  • Why the prototype can be retrieved but the __proto__ is undefined in JavaScript?
  • PyInstaller Tkinter window low resolution in App bundle, but not in app program
  • How to backup mongodb on a meteor app deployed with MUPX
  • What is meant by ?? in Dart
  • Preset files are not allowed to export objects
  • Group files by name prefix and then archive (zip) each group with PowerShell
  • Visual Studio 2017 Javascript How to set 'experimentaldecorators'
  • capistrano password prompt
  • redirecting output of execvp into a file in C
  • named parameter to npm run script
  • Running VBS script with Ruby
  • How to deal with file name starts with spaces in bash?
  • AWS Elastic Beanstalk - changing owner of webapp folder
  • Combinatios in List of LIsts Prolog
  • os.system not working, but typing the same thing into the command prompt works
  • OSX - always hide certain files
  • How to get latest version of a artifact on Bintray using JSONP
  • During installation of Django, why do I keep getting ImportError: No module named django?
  • Stop Bash Script if Hive Fails
  • error importing numpy
  • Very simple C++ DLL that can be called from .net
  • Different response to non-authenticated users and AJAX calls
  • Array.prototype.includes - not transformed with babel
  • Warning: Can't call setState (or forceUpdate) on an unmounted component
  • How do I rollback to a specific git commit
  • Is there a mandatory requirement to switch app.yaml?
  • Proper way to use connect-multiparty with express.js?
  • Load html files in TinyMce
  • Is it possible to post an object from jquery to bottle.py?
  • JaxB to read class hierarchy
  • Busy indicator not showing up in wpf window [duplicate]