我正在开发名为density wars的webgl RTS游戏,但我收到了很多错误,如下所示:
ERROR in [default] /Users/nikos/PhpstormProjects/Density-Wars/babylonjs.d.ts:1:15
Duplicate identifier 'BABYLON'.
在我的打字稿入口点,我这样做:
/// <reference path="./gameUnits/Core.ts" />
/// <reference path="./utils/UnitCommand.ts" />
/// <reference path="./utils/Formations.ts" />
/// <reference path="./User.ts" />
declare function require(module: string):any
require('../style.css');
var BABYLON = require('babylonjs');
webpack.config:
module.exports = {
context: __dirname + "/lib",
entry: {
main: [
"./game.ts"
]
},
output: {
path: __dirname + "/dist",
filename: "density-wars.js"
},
devtool: "source-map",
module: {
loaders: [
{
test: /\.ts$/,
loader: 'awesome-typescript-loader'
},
{ test: /\.css$/, loader: "style-loader!css-loader" }
]
},
resolve: {
// you can now require('file') instead of require('file.js')
extensions: ['', '.js', '.json']
}
}
答案 0 :(得分:2)
重复标识符'BABYLON'
由于您的代码var BABYLON = require('babylonjs');
。如果没有根级别import
或export
,则该文件会为全局命名空间做出贡献,因此您有多个var BABYLON
声明。
使用import BABYLON = require('babylonjs');
或至少export
来自包含var BABYLON
的文件的内容。
更多https://basarat.gitbooks.io/typescript/content/docs/project/modules.html