问题
I generated .js and .d.ts files with the apache thrift compiler. How can I use this files in my existing Angular2/Typescript-Project? I tried to use
///<reference path="./thrift.d.ts"/>
///<reference path="./Service.d.ts"/>
And
import Thrift = require("./thrift");
import Service = require("./Service")
If i use this four lines, the typescript compiler is not complaining, but "Thrift" is not defined when i want to use it. thrift.js, Service.js and both .d.ts files are existing in the folder.
Thank you very much!
回答1:
You need to manually reference your thrift.js in the index.html
回答2:
yarn add @types/thrift
import * as thrift from 'thrift';
...
var transport = thrift.TBufferedTransport;
var protocol = thrift.TBinaryProtocol;
来源:https://stackoverflow.com/questions/42715829/using-apache-thrift-with-typescript