安装蓝图时环境上下文错误中不允许初始化程序

安装蓝图时环境上下文错误中不允许初始化程序

本文介绍了安装蓝图时环境上下文错误中不允许初始化程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在我的项目中使用 @blueprintjs/core 库.然而,当我编译我的代码时,我收到了很多这样的错误:

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?

推荐答案

@blueprintjs/[email protected] 开始,Blueprint 现在使用 TypeScript 2.1 编译.在这个新版本的 TypeScript 中,初始值设定项被添加到发出的常量类型中.

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.

所以之前,发出的一行 classes.d.ts 看起来像这样:

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";

声明文件中的这种新语法使旧版本的编译器不满意.要消除错误,您需要确保至少使用 TypeScript 2.1 编译项目.

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.

这篇关于安装蓝图时环境上下文错误中不允许初始化程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-19 09:40