node.js 打字稿错误 TS1005: ';' 预期的

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/18293590/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-02 15:20:31  来源:igfitidea点击:

Typescript error TS1005: ';' expected

javascriptnode.jstypescript

提问by Games Brainiac

I am trying compile this typescript file:

我正在尝试编译这个打字稿文件:

import http = module("http");
import express = module("express");

With these parameters:

使用这些参数:

C:/nodejs/tsc.cmd --sourcemap cheese.ts --module commonjs
C:/User/Node/ExpressProject/cheese.ts(5,21): error TS1005: ';' expected.
C:/User/Node/ExpressProject/cheese.ts(6,24): error TS1005: ';' expected.

What am I doing wrong? Even with this, I am getting the same errors errors:

我究竟做错了什么?即使这样,我也会收到相同的错误:

module "http" {}
module "express" {}

import http = module("http");
import express = module("express");

Using Typescript version 0.9.1

使用打字稿版本 0.9.1

回答by Ryan Cavanaugh

The syntax in 0.9.1is now import mod = require('modname');

中的语法0.9.1现在是import mod = require('modname');

回答by Itay Merchav

Typescript compiler (https://www.npmjs.org/package/typescript-compiler) commands.

Typescript 编译器 ( https://www.npmjs.org/package/typescript-compiler) 命令。

I use --allowimportmodule

我使用 --allowimportmodule

回答by Mark Schultheiss

I was getting these errors with a .Net Core application in Visual Studio Professional 2019, I got the 16.4.4 update and applied that which in turn had a requirement to reboot the computer which of course closed and then re-opened the solution. After this, the various TS errors went away.

我在 Visual Studio Professional 2019 中的 .Net Core 应用程序中遇到了这些错误,我获得了 16.4.4 更新并应用了该更新,这反过来又要求重新启动计算机,这当然是关闭然后重新打开解决方案。在此之后,各种 TS 错误消失了。