我有一个使用moment的typescript文件,我需要导入moment来编译它,但编译后的文件保留了导入行,这让我的网页很恼火。
这是我的tsconfig文件:
{
"compileOnSave": true,
"compilerOptions": {
"lib": [
"es2015",
"dom"
],
"module": "es2015",
"moduleResolution": "node",
"noEmitOnError": true,
"outDir": "Assets/Scripts/lib",
"pretty": true,
"removeComments": true,
"rootDir": "tsSrc",
"target": "es5",
"sourceMap": true
},
"exclude": [
"node_modules",
"tsSrc/typescript-definitions"
]
}如何使用它的示例:
/// <reference path="../../../node_modules/moment/moment.d.ts" />
import * as moment from "moment";
console.log(moment().format("M/D/YYYY h:mm a"));发布于 2018-01-05 05:28:53
您指定了"module": "es2015",并且import语句是ES2015模块语法。指定您正在使用的模块加载器(amd、commonjs)
https://stackoverflow.com/questions/48103626
复制相似问题