2016-01-06 27 views

回答

1

所以,我明白你的問題 - 這是非常常見的異常,並解決它,你應該分析compiler options

所以,如果你在tasks.json您可以定義多個另外編譯代碼這樣的編譯參數

{ 
    "version": "0.1.0", 

    // The command is tsc. Assumes that tsc has been installed using npm install -g typescript 
    "command": "tsc", 

    // The command is a shell script 
    "isShellCommand": true, 

    // Show the output window only if unrecognized errors occur. 
    "showOutput": "silent", 

    // args is the HelloWorld program to compile. 
    "args": ["-m", "commonjs", "HelloWorld.ts"], 

    // use the standard tsc problem matcher to find compile problems 
    // in the output. 
    "problemMatcher": "$tsc" 
} 

so -m表示--module編譯器命令。

編輯

所以,如果你使用tsconfig.json,你可以找到與模塊設置默認配置here

"module": "commonjs"

  • module - 標誌,告訴編譯器使用的模塊系統
  • commonjs - 模塊系統

我希望它能解決您的問題!祝你好運!

+0

把這個設置放在tsconfig.json中是一個更好的方法,那麼它也可以與其他的構建系統一起工作。 – DCoder

+0

注意:添加tsconfig.json後,只有重新啓動可視代碼後,對智能感知的更改纔會生效。 –

相關問題