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

Cannot find module '@unovis/svelte' or its corresponding type declarations. #343

Closed
OTheNonE opened this issue Mar 3, 2024 · 11 comments
Closed

Comments

@OTheNonE
Copy link

OTheNonE commented Mar 3, 2024

There is a typescript error when using the svelte part of Unovis:

Cannot find module '@unovis/svelte' or its corresponding type declarations.

The modules works, and the project builds, but the types do not work. Types work though in the TS part of the module. Related to this, i notice in node_modules that the ts-folder has a types.d.ts-file while the svelte-folder has not. Does this have anything to do with this?

This is my tsconfig.json file:

{
	"extends": "./.svelte-kit/tsconfig.json",
	"compilerOptions": {
		"allowSyntheticDefaultImports": true,
		"allowJs": true,
		"checkJs": true,
		"esModuleInterop": true,
		"forceConsistentCasingInFileNames": true,
		"resolveJsonModule": true,
		"skipLibCheck": true,
		"sourceMap": true,
		"strict": true,
		"moduleResolution": "Bundler"
	}
}

@michaelbelete
Copy link

Any updates? I am facing the same issue 😢

@huntabyte
Copy link

huntabyte commented Mar 6, 2024

It appears the package is missing the "types" from the "exports" statement in the package.json:

{
	"exports": {
		".": {
+			"types": "./index.d.ts",
			"svelte": "./index.js"
		}
	}
}

Refernece - Svelte packaging docs: https://kit.svelte.dev/docs/packaging#anatomy-of-a-package-json-exports

@rokotyan
Copy link
Contributor

rokotyan commented Mar 6, 2024

@huntabyte (cc @michaelbelete @OTheNonE) Thanks for pointing it out! I've just published 1.3.6-beta.0, can you please try installing it and confirm if it works?

@OTheNonE
Copy link
Author

OTheNonE commented Mar 6, 2024

I can confirm that this specific issue is solved. There is no typescript error, typescript can find the package, and when running npm run check, it displays no errors nor warnings.

Although, i was hoping that this would solve the autocompletion and type infering of some of the svelte components. Specifically, i currently get no autocompletion nor type of "event" when doing <VisAxis tickFormat={(event) => { ... }/>, and there are many other general type problems with all the components. I'll open a new issue.

@OTheNonE OTheNonE closed this as completed Mar 6, 2024
@OTheNonE OTheNonE reopened this Mar 6, 2024
@huntabyte
Copy link

@huntabyte (cc @michaelbelete @OTheNonE) Thanks for pointing it out! I've just published 1.3.6-beta.0, can you please try installing it and confirm if it works?

Awesome, thanks a ton! Would have submitted a PR but was limited on time and realized I needed to submit the CLA.

@huntabyte
Copy link

I'm experiencing another related issue when new projects are using "moduleResolution": "NodeNext" the components aren't able to be resolved due to a missing file extension in index.js:

- export * from './containers';
- export * from './components';
+ export * from './containers.js';
+ export * from './components.js';

The ideal approach would be to use "moduleResolution": "NodeNext" in the library's tsconfig.json to ensure regressions aren't introduced and support for both Node and bundlers is provided.

Reference: https://www.typescriptlang.org/docs/handbook/modules/theory.html#module-resolution-for-libraries

CleanShot.2024-03-06.at.11.56.27.mp4

@michaelbelete
Copy link

@huntabyte (cc @michaelbelete @OTheNonE) Thanks for pointing it out! I've just published 1.3.6-beta.0, can you please try installing it and confirm if it works?

@rokotyan 1.3.6-beta.0 fixed my problem. Thank you 🙌🏼

@rokotyan
Copy link
Contributor

rokotyan commented Mar 7, 2024

@huntabyte @shyakadavis @michaelbelete

1.3.6-beta.1 addresses this problem and ready to be tested, thanks for pointing it out!

We'll need to update Typescript version in our project to use "moduleResolution": "NodeNext" and there were some problems with this. But one day we'll definitely do it.

@huntabyte
Copy link

This does fix the issue, thank you!

@reb-dev reb-dev closed this as completed Apr 3, 2024
@huntabyte
Copy link

This issue is persisting with the latest version of @unovis/svelte:

It appears this part of the package.json didn't make it into the release:

{
	"exports": {
		".": {
+			"types": "./index.d.ts",
			"svelte": "./index.js"
		}
	}
}

rokotyan added a commit to rokotyan/unovis that referenced this issue Apr 6, 2024
@rokotyan
Copy link
Contributor

rokotyan commented Apr 6, 2024

@huntabyte I can't believe we missed it, thanks for reporting. Use 1.4.1-beta.0 as a quick fix

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

5 participants