[英]Trying to build ambient type definition for typescript for a lib
我正在嘗試為下面的js庫構建環境類型定義: https : //github.com/kkemple/graphql-auth
這是我的類型,但這似乎無法正常工作
// Type definitions for graphql-auth
// Project: https://github.com/kkemple/graphql-auth
// Definitions by: Andréas `ScreamZ` H. <https://github.com/ScreamZ/>
export = withAuth;
declare function withAuth(resolve: Resolver): Resolver;
declare function withAuth(scopes: string[], resolver: Resolver): Resolver;
declare type Resolver = (root: any, args: any, context: any, info: any) => any
當我嘗試導入.ts文件時,導致resolves to a non-module entity and cannot be imported using this construct.
我知道他們更改了聲明命名空間和聲明模塊系統。
我在理解所有這些方面遇到了問題。
有人可以幫我嗎?
最好的祝福
基於源文件,我將這樣編寫聲明:
declare module "graphql-auth" {
export type Resolver = (root: any, args: any, context: any, info: any) => any;
function withAuth(callback: Resolver): Resolver;
function withAuth(scope: string[], callback: Resolver): Resolver;
export default withAuth;
}
您可能還需要啟用esModuleInterop
。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.