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

Missing type definition errors when used in JS project #615

Open
tuckergordon opened this issue Jul 26, 2023 · 2 comments
Open

Missing type definition errors when used in JS project #615

tuckergordon opened this issue Jul 26, 2023 · 2 comments
Labels
bug Something isn't working

Comments

@tuckergordon
Copy link

Describe the bug
The new reference types introduced in 2d1193c result in svelte-check errors when SMUI components are imported into a JavaScript Svelte project.

To Reproduce
Steps to reproduce the behavior:

  1. Create a new svelte project: npm create svelte@latest my-app
    a. Choose "Library project"
    b. Choose "Yes, using JavaScript with JSDoc comments"
  2. Import a SMUI element into the app, e.g. npm i -D @smui/button
  3. Add that SMUI element to a page, e.g.
<!-- src/routes/+page.svelte -->
<script>
  import Button, { Label } from '@smui/button';
 
  let clicked = 0;
</script>

<Button>Press</Button>
  1. Run npm run check to run svelte-check. You should see errors such as:
path/to/node_modules/@smui/ripple/src/index.ts:1:23
Error: Cannot find type definition file for './ambient-ripple'. 
/// <reference types="./ambient-ripple" />

Expected behavior
Should be able to use SMUI components in TS and JS Svelte applications without errors.

Additional context
I believe the solution is to just add the .d.ts extension to all of these instances. E.g.

/// <reference types="./ambient-ripple.d.ts" />

Doing this locally fixed the errors for me.

@tuckergordon tuckergordon added the bug Something isn't working label Jul 26, 2023
@tuckergordon
Copy link
Author

For anyone who needs a workaround in the meantime, I was able to get around these errors by adding "noResolve": true to the jsconfig.json's compilerOptions. A bit of a sledge hammer solution but it does the job

@hperrin
Copy link
Owner

hperrin commented Dec 27, 2023

Is this still happening with the latest release?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants