Search code examples
node.jstypescriptconstantsdeclaration

Typescript - node js - Missing initializer in const declaration


Getting syntax error for below line of code. SyntaxError: Missing initializer in const declaration

const testMap : Map<string, any> = new Map();

Solution

  • It sounds like your code is being interpreted as JavaScript, not TypeScript. Change your file extension to .ts instead of .js, and make sure your Node environment is set up to interpret it properly (such as with ts-node)