0

我正在开发一个名为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']
  }
}
4

1 回答 1

2

重复标识符“BABYLON”

因为你的代码var BABYLON = require('babylonjs');。在没有根级别importexport文件对全局命名空间有贡献的情况下,因此您有多个var BABYLON声明。

使固定

使用import BABYLON = require('babylonjs');或至少export来自具有var BABYLON.

更多https://basarat.gitbooks.io/typescript/content/docs/project/modules.html

于 2015-11-29T23:36:20.593 回答