0

密度戦争と呼ばれる webgl RTS ゲームに取り組んでいますが、次のような多くのエラーが発生します。

ERROR in [default] /Users/nikos/PhpstormProjects/Density-Wars/babylonjs.d.ts:1:15 Duplicate identifier 'BABYLON'.

typescript へのエントリ ポイントでは、次のようにします。

/// <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');。ルート レベルがない場合、importまたはファイルがグローバル名前空間にexport寄与しているため、複数の宣言があります。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 に答える