[英]load RxJS Typescript typings without importing from CommonJS module?
I'm creating an Electron app with Typescript support.我正在创建一个支持 Typescript 的 Electron 应用程序。 I want to use RxJS library in the Renderer process with nodeIntegration set to false.我想在 Renderer 进程中使用 RxJS 库,并将 nodeIntegration 设置为 false。
In the specific window I include the RxJS by在特定窗口中,我包含了 RxJS
<script type="text/javascript" src="../node_modules/rxjs/bundles/rxjs.umd.min.js"></script>
In the Renderer Process I import specific observables and operators by在渲染器过程中,我通过以下方式导入特定的可观察对象和运算符
const { fromEvent } = (window as any).rxjs;//require('rxjs');
const { tap } = (window as any).rxjs.operators;//require("rxjs/operators");
Application works correctly but I have no support for types definitions from RxJS.应用程序工作正常,但我不支持来自 RxJS 的类型定义。 How can I bring the support back?我怎样才能恢复支持? How to import correctly the *.d.ts for RxJS?如何正确导入 RxJS 的 *.d.ts?
You can create your own .d.ts file like this:您可以像这样创建自己的 .d.ts 文件:
export * from 'rxjs'
export * as operators from 'rxjs/operators'
export * as testing from 'rxjs/testing'
export * as ajax from 'rxjs/ajax'
export * as webSocket from 'rxjs/webSocket'
export * as fetch from 'rxjs/fetch'
export as namespace rxjs
This way was suggested in this answer to a similar question.在this answer to a similar question中建议了这种方式。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.