gpt4 book ai didi

angular - typescript angular2.d.ts错误 "Expecting new line or semicolon"

转载 作者:行者123 更新时间:2023-12-05 07:55:16 25 4
gpt4 key购买 nike

我最新的 WebStorm10.0.2 引发关于 "angular2.d.ts" 的错误,即“需要新行或分号。”在第 15-19 行和第 32-37 行。

Angular2 团队在 5 分钟开始的例子中犯了错误?我不敢相信,这一定是我的错。

所以:

我按照“angular2 的 5 分钟快速启动”( https://angular.io/ ) 逐步克隆。

我已经将“index.html”和“app.ts”从“complete”移动到基本路径。

我还将我的 WebStorm10.0.2 编译器版本更改为包含 typescriptService.js 的自定义目录。

还是不行...

我的 typescript 版本是 1.5Beta。

interface List<T> extends Array<T> {
}
interface Type {}

declare module "angular2/angular2" {
function bootstrap(appComponentType: any): void;
function Component({
selector,
properties,
hostListeners,
injectables,
lifecycle,
changeDetection
}:{
selector:string,
properties?:Object,
hostListeners?:Object,
injectables?:List<any>,
lifecycle?:List<any>,
changeDetection?:string
});

function View({
templateUrl,
template,
directives,
formatters,
source,
locale,
device
}: {
templateUrl?: string,
template?: string,
directives?: List<Type>,
formatters?: List<Type>,
source?: List<any>,
locale?: string,
device?: string
});
function For();
function If();
}

最佳答案

在命令行中通过tsc -v检查您的tsc版本,看看结果是否为1.5.0-beta。您使用的可能是早期版本,因为您的系统中安装了多个版本(一个通过 npm,另一个可能是在您安装某个版本的 Visual Studio 时)。

要检查 tsc 的安装版本(如果您在 windows 环境中)使用命令行并键入 where tsc,结果将是一个目录列表如果你有比 npm 多的目录,只需转到你的 Path 系统变量并删除它们。

一定要打开一个新的命令行以便再次测试 tsc,因为旧的路径变量不会为已经打开的命令行刷新。

关于angular - typescript angular2.d.ts错误 "Expecting new line or semicolon",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30032149/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com