WebワーカーとNodeで実行したいスクリプトにQ
というライブラリを使用しています。ので、。ノードとWebワーカー向けのJSのファイル
error TS2300: Duplicate identifier 'Q'.
が、私はimport Q = require("q")
とvar Q = require("q")
に置き換えた場合、私はこのエラーを取得する:私はそうのようなq.d.ts
を参照する場合:
/// <reference path="../typings/q/Q.d.ts" />
if(importScripts != undefined && WorkerGlobalScope == undefined
&& typeof module !== 'undefined' && module.exports){
// We're in a Node (child) process
var Q = require("q")
}else{
// We're in a web-worker
importScripts('q');
}
私がうまくこのanswerに説明されている次のエラーを取得しますimportステートメントは、if
句の中に入れ子になっており、スクリプトのトップレベルには入れられません。
Q
を入力して、ノードのrequire()
とウェブ作業者のimportScripts()
との両方で動作するようにする方法はありますか?
これは素晴らしい作品が、それらのためにそのドン」 ( 'require.d.ts'など)(https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/q/Qdts)' import _r = require( 'requirejs') 'がこのようになりますエラー: 'モジュール 'requirejs'を見つけることができません。 – Jthorpe
私は[別の関連する質問](http://stackoverflow.com/questions/38016793)があります。ありがとう! – Jthorpe