Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Initializers are not allowed in ambient contexts error when installing Blueprint

Tags:

I'm trying to use the @blueprintjs/core library in my project. However, when I compile my code, I'm getting many errors like this:

node_modules/@blueprintjs/core/dist/common/classes.d.ts(4,30):   error TS1039: Initializers are not allowed in ambient contexts. 

What's going on? What am I doing wrong?

like image 682
JKillian Avatar asked Feb 17 '17 15:02

JKillian


1 Answers

As of @blueprintjs/[email protected], Blueprint is now compiled using TypeScript 2.1. With this new version of TypeScript, initializers are added to the emitted typings for constants.

So before, a line of the emitted classes.d.ts looked like this:

export declare const ACTIVE: string; 

It now looks like this and includes an initializer:

export declare const ACTIVE = "pt-active"; 

This new syntax in declaration files makes old versions of the compiler unhappy. To make the error go away, you'll need to make sure you're compiling your project with at least TypeScript 2.1.

like image 76
JKillian Avatar answered Sep 19 '22 17:09

JKillian