user10103655
user10103655

Reputation: 131

Cannot find name 'const'

I'm developing an Angular app and am trying to use the Typescript 3.4 feature "const assertion" like this:

const counterSettingsDefaults = { setTo: 10, tickSpeed: 200, increment: 1 } as const;

But I get the compile error:

"Cannot find name 'const'.ts(2304)",

Which indicates to me that this functionality is not available.

Typing ng --version in powershell gives me the following versions of Angular and Typescript:

 Angular: 9.0.0-rc.7 
 typescript: 3.6.4

What could be wrong, where can I investigate this further?

Upvotes: 0

Views: 2291

Answers (1)

Dawid Dahl
Dawid Dahl

Reputation: 457

I found the solution to this problem here. Hurray!

"Open a TypeScript file.

Click the TypeScript version to the bottom right in the Status Bar.

Choose Use Workspace Version from the message box."

Upvotes: 1

Related Questions