gpt4 book ai didi

reactjs - 为子文件夹声明模块

转载 作者:行者123 更新时间:2023-12-04 15:58:50 29 4
gpt4 key购买 nike

我正在尝试为模块“react-facebook-login/dist/facebook-login-render-props”创建类型,这是 https://github.com/keppelen/react-facebook-login 的一部分.请注意,它位于一个子文件夹中。

我创建了一个包含以下模块声明的 d.ts 文件:

declare module "react-facebook-login/dist/facebook-login-render-props" {

interface RenderProps {
onClick: Function;
isDisabled: boolean;
isProcessing: boolean;
isSdkLoaded: boolean;
}

interface ReactFacebookLoginProps {
appId: string;
callback(userInfo: ReactFacebookLoginInfo): void;
onFailure?(response: ReactFacebookFailureResponse): void;

autoLoad?: boolean;
buttonStyle?: React.CSSProperties;
containerStyle?: React.CSSProperties;
cookie?: boolean;
cssClass?: string;
disableMobileRedirect?: boolean;
fields?: string;
icon?: string | React.ReactNode;
isDisabled?: boolean;
language?: string;
onClick?(event: React.MouseEvent<HTMLDivElement>): void;
reAuthenticate?: boolean;
redirectUri?: string;
scope?: string;
size?: "small" | "medium" | "metro";
textButton?: string;
typeButton?: string;
version?: string;
xfbml?: boolean;
isMobile?: boolean;
tag?: Node | React.Component<any>;
render?(props: RenderProps): void;
}

interface ReactFacebookFailureResponse {
status?: string;
}

interface ReactFacebookLoginInfo {
id: string;
accessToken: string;
name?: string;
email?: string;
}

interface ReactFacebookLoginState {
isSdkLoaded?: boolean;
isProcessing?: boolean;
}

class ReactFacebookLogin extends React.Component<
ReactFacebookLoginProps,
ReactFacebookLoginState
> {}
}

但它似乎没有被拾取,因为我收到一个错误:

error TS7016: Could not find a declaration file for module 'react-facebook-login'. '.....\node_modules\react-facebook-login\dist\facebook-login-with-button.js' implicitly has an 'any' type.

我该怎么做才能键入位于包子文件夹中的这个文件?

最佳答案

原来问题不是文件在子文件夹中。

对于寻找解决方案的 Google 员工,这就是我最终得到的:

declare module "react-facebook-login/dist/facebook-login-render-props" {

export interface RenderProps {
onClick: Function;
isDisabled: boolean;
isProcessing: boolean;
isSdkLoaded: boolean;
}

interface ReactFacebookLoginProps {
appId: string;
callback(userInfo: ReactFacebookLoginInfo): void;
onFailure?(response: ReactFacebookFailureResponse): void;

autoLoad?: boolean;
buttonStyle?: React.CSSProperties;
containerStyle?: React.CSSProperties;
cookie?: boolean;
cssClass?: string;
disableMobileRedirect?: boolean;
fields?: string;
icon?: string | React.ReactNode;
isDisabled?: boolean;
language?: string;
onClick?(event: React.MouseEvent<HTMLDivElement>): void;
reAuthenticate?: boolean;
redirectUri?: string;
scope?: string;
size?: "small" | "medium" | "metro";
textButton?: string;
typeButton?: string;
version?: string;
xfbml?: boolean;
isMobile?: boolean;
tag?: Node | React.Component<any>;
render(props: RenderProps): void;
}

interface ReactFacebookFailureResponse {
status?: string;
}

interface ReactFacebookLoginInfo {
id: string;
accessToken: string;
name?: string;
email?: string;
}

interface ReactFacebookLoginState {
isSdkLoaded?: boolean;
isProcessing?: boolean;
}

export default class ReactFacebookLogin extends React.Component<
ReactFacebookLoginProps,
ReactFacebookLoginState
> {}
}

关于reactjs - 为子文件夹声明模块,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50999424/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com