I have the following code snippet in Typescript:
nsp.on('connection', async function (socket) { await this.emitInitialPackage(nsp, currentLine, currentCell); } emitInitialPackage(nsp: any, name: string, cell: any) { return db.Line.find({ where: { name: name, CellId: cell } }).then(results => { nsp.emit('value', results); }).catch(err => console.log(err)); } However, when this is compiled (v2.2.1) and run, I get the following error:
Uncaught ReferenceError: __awaiter is not defined
What does this mean and how do I get the expected functionality?
Update:
{ "compilerOptions": { "target": "es5", "module": "commonjs", "moduleResolution": "node", "emitDecoratorMetadata": true, "experimentalDecorators": true, "allowSyntheticDefaultImports": true, "sourceMap": true, "noEmitHelpers": true, "strictNullChecks": false, "lib": [ "dom", "es2015.promise", "es5" ], "types": [ "node", "express" ] }, "exclude": [ "node_modules", "dist" ] }
tsconfig.json? And the command you use to compile your code.tsc -wfrom the directory with that tsconfig in it's root.