Initializers are not allowed in ambient contexts error when installing Blueprint

寵の児 提交于 2019-11-27 15:05:34

As of @blueprintjs/core@1.7.0, 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.

I had this problem, but for me, updating the local (and global) TypeScript packages did not resolve the problem. Luckily I came across the following article Which version of TypeScript is Visual Studio Using?

In a nutshell, whilst I had updated to TypeScript 2.2, Visual Studio was still referencing version 2.0 in the .csproj file. I hope this helps someone else with a similar problem.

Delete your node-modules folder and do a clean installation.

For windows, to resolve this issue the shortest path is to install Typescript through installer.

https://www.microsoft.com/en-us/download/details.aspx?id=48593

I've been having this issue. Needed to download the latest version of typescript from typescript website and make sure 'use latest version' is selected in visual studio project properties.

Upgrade typescript to at least 3.1+.

This error is because of node older version of node

You can remove the node version and reinstall it by using the below comand

rm -rf node_modules //For removing
npm install //Install again(Fresh with updated one)
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!