Typescript 1.5增加了對tsconfig.json
配置文件的支持,其中可以指定諸如編譯器選項之類的內容。tsc 1.5是否仍然需要--module標誌?
下面是來自blog post announcing 1.5一個妙語:
編譯器現在支持「tsconfig.json」,一個新的文件,它允許你 指定項目中的文件和編譯器設置使用。
這讓我覺得,將--module
標誌添加到編譯器將不再是必要的。但是,試圖編譯一個簡單的文件導出一個類,我得到這樣的:
tsctest.ts(1,14): error TS1148: Cannot compile modules unless the '--module' flag is provided.
當運行tsc
與--module commonjs
一切工作正常。
這裏的TS文件:
//tsctest.ts
export class Empty {
}
而這裏的tsconfig.json
:
{
"compilerOptions": {
"target": "ES5",
"module": "commonjs"
}
}
我的打字稿版本1.5.3是,tsctest.ts
和tsconfig.json
住在同一個文件夾中。