【问题标题】:Using apache thrift with typescript将 apache thrift 与打字稿一起使用
【发布时间】:2017-07-31 15:32:16
【问题描述】:

我使用 apache thrift 编译器生成了 .js 和 .d.ts 文件。如何在我现有的 Angular2/Typescript-Project 中使用这些文件? 我尝试使用

///<reference path="./thrift.d.ts"/>
///<reference path="./Service.d.ts"/>

import Thrift = require("./thrift");
import Service = require("./Service")

如果我使用这四行,打字稿编译器不会抱怨,但是当我想使用它时,没有定义“Thrift”。 thrift.js、Service.js 和两个 .d.ts 文件都存在于该文件夹中。

非常感谢!

【问题讨论】:

    标签: javascript angular typescript thrift


    【解决方案1】:

    您需要在 index.html 中手动引用您的 thrift.js

    【讨论】:

      【解决方案2】:

      添加@types/thrift

      import * as thrift from  'thrift';
      ...
      var transport = thrift.TBufferedTransport;
      var protocol = thrift.TBinaryProtocol;
      

      【讨论】:

        猜你喜欢
        • 2012-10-04
        • 2021-08-14
        • 1970-01-01
        • 2017-08-15
        • 2017-12-25
        • 2021-02-13
        • 2019-10-06
        • 2019-04-18
        • 2021-08-21
        相关资源
        最近更新 更多