我使用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