Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't import components directly if using TypeScript. #190

Open
wozzo opened this issue Jan 5, 2024 · 1 comment
Open

Can't import components directly if using TypeScript. #190

wozzo opened this issue Jan 5, 2024 · 1 comment

Comments

@wozzo
Copy link

wozzo commented Jan 5, 2024

From the readme

// Or you can import components directly
import Button from 'nhsuk-react-components/lib/components/button';

But the typescript definitions are in the dist directory so they cannot be found by tsc leading to this error

Could not find a declaration file for module 'nhsuk-react-components/lib/components/button'. '/nodebox/node_modules/.store/[email protected]/node_modules/nhsuk-react-components/lib/components/button/index.js' implicitly has an 'any' type.
  Try `npm i --save-dev @types/nhsuk-react-components` if it exists or add a new declaration (.d.ts) file containing `declare module 'nhsuk-react-components/lib/components/button';`typescript(7016)

See example sandbox.

If the rollup operation was modified to output to the lib folder then this would mean the types will all be present, but I'm not familiar enough with rollup to know what other effects this could have.

@KaiSpencer
Copy link
Contributor

Thanks @wozzo for this and the reproduction.

@Tomdango Can you take a look at this?

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

No branches or pull requests

2 participants