Skip to content
This repository has been archived by the owner on Sep 20, 2023. It is now read-only.

Error when using with Typescript #47

Open
thenakulchawla opened this issue Feb 28, 2021 · 1 comment
Open

Error when using with Typescript #47

thenakulchawla opened this issue Feb 28, 2021 · 1 comment

Comments

@thenakulchawla
Copy link

When I import it the way it is shown in the README file. It gives the below error:

Could not find a declaration file for module 'react-typeform-embed'. 'path_in_node_mdulesreact-typeform-embed/lib/index.js' implicitly has an 'any' type.
  Try `npm i --save-dev @types/react-typeform-embed` if it exists or add a new declaration (.d.ts) file containing `declare module 'react-typeform-embed';`

It gives a 404 when I try to install with types.

@MonstraG
Copy link

MonstraG commented Feb 3, 2022

For now, I had to add the types myself.

In index.d.ts, in root of the project:

// declares only one of the functions, see more here:
// https://github.com/alexgarces/react-typeform-embed
declare module "react-typeform-embed" {
	export type PopupProps = {
		id: string;
		height?: number;
		width?: number;
		size?: number;
		hidden?: Record<string, string>;
		onSubmit?: () => void;
		hideHeaders?: boolean;
		disableAutoFocus?: boolean;
		enableSandbox?: boolean;
	};

	export function Popup(props: PopupProps): JSX.Element;
}

I've only added the Popup that I use, and pretty sure that I did not specify all of the props, you can add the ones you need yourself.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants