[英]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.