我使用google API從lib.proto生成lib.js。在打字稿中,我用它與declare var lib: any;
。我的問題是browserify忽略lib.js,因爲它只是一個聲明。使用tsify打包打印稿和protobuf.js
有什麼方法可以將lib.js添加到bundle.js的正確位置嗎?
我tsify命令:
browserify -p tsify src/main.ts > bundle.js
我tsconfig:
{
"compilerOptions": {
"declaration": false,
"noImplicitAny": true,
"target": "ES6",
"removeComments": true,
"module": "commonjs",
"sourceMap": true,
"rootDir": "src",
"moduleResolution": "node"
}
}
我的層次:
root
src
main.ts
lib.proto
lib.js
lib.d.ts
bundle.js
index.html
package.json
tsconfig.json
statment:
declare var lib: any;
let p = lib.deserializeBinary(data);
我可以擁有'.js'文件,該文件包含相關的'.d.ts'文件。如果不包含問題中的配置詳細信息('tsconfig.json',tsify選項,目錄結構等),則回答此問題是不可能的。 – cartant
感謝您的幫助!我已經更新了這個問題。 – FlugRost
你可以包含你的'import'語句和'.d.ts'嗎? – cartant