Using apache thrift with typescript

让人想犯罪 __ 提交于 2020-01-05 07:17:32

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!