TypeScript 功能
¥TypeScript features
由于 Node.js 仅删除内联类型,因此任何涉及用新 JavaScript 语法替换 TypeScript 语法的 TypeScript 功能都会出错,除非传递了标志 --experimental-transform-types
。
¥Since Node.js is only removing inline types, any TypeScript features that
involve replacing TypeScript syntax with new JavaScript syntax will error,
unless the flag --experimental-transform-types
is passed.
需要转换的最突出的功能是:
¥The most prominent features that require transformation are:
-
Enum
-
namespaces
-
legacy module
-
参数属性
¥parameter properties
由于装饰器当前是 TC39 第 3 阶段提案,并且很快将得到 JavaScript 引擎的支持,因此它们不会被转换,并将导致解析器错误。这是一个暂时的限制,将来会得到解决。
¥Since Decorators are currently a TC39 Stage 3 proposal and will soon be supported by the JavaScript engine, they are not transformed and will result in a parser error. This is a temporary limitation and will be resolved in the future.
此外,Node.js 不读取 tsconfig.json
文件,也不支持依赖于 tsconfig.json
中的设置的功能,例如路径或将较新的 JavaScript 语法转换为较旧的标准。
¥In addition, Node.js does not read tsconfig.json
files and does not support
features that depend on settings within tsconfig.json
, such as paths or
converting newer JavaScript syntax into older standards.