Quantcast
Channel: User Misha Krul - Stack Overflow
Viewing all articles
Browse latest Browse all 42

Cannot find name 'Symbol' when compiling typescript

$
0
0

I'm receiving the following error when trying to compile a ts file:

node_modules/@types/node/util.d.ts(121,88): error TS2304: Cannot find name 'Symbol'.

I did some reading and saw that this can be linked to not having the correct target or lib options declared in the tsconfig.json file. I've tried a few different things such as changing the target to "es15" and including "es2015" in the lib, but I am not having much luck.

I am using this tutorial as a basis for my project:https://itnext.io/building-restful-web-apis-with-node-js-express-mongodb-and-typescript-part-1-2-195bdaf129cf

File structure:

distlib├──controllers|  ├──controller.ts|├──models|  ├──model.ts|├──routes|  ├──routes.ts|├──app.ts├──server.tsnode_modulespackage.jsontsconfig.json

tsconfig.json:

{"compilerOptions": {"target": "es2017","module": "commonjs","declaration": false,"noImplicitAny": false,"noImplicitThis": false,"removeComments": true,"experimentalDecorators": true,"strictNullChecks": true,"moduleResolution": "node","pretty": true,"sourceMap": true,"allowJs": true,"noLib": false,"jsx": "react","outDir": "./dist","lib": ["es2017"],"baseUrl": "./lib"  },"include": ["lib/**/*.ts"  ],"exclude": ["node_modules"  ]}

model.ts:

import * as mongodb from 'mongodb'import * as fs from 'fs'const filepath = __dirname +'/../file.txt'function asyncReadFile(filepath: string, type: string) {  return new Promise((resolve, reject) => {    fs.readFile(filepath, (err, data) => {      console.log("Reading file...")      err ? reject(err) : resolve(data)    })  })}asyncReadFile(filepath, 'utf-8')

Viewing all articles
Browse latest Browse all 42

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>