hperrin / svelte-material-ui

Svelte Material UI Components
https://sveltematerialui.com/
Apache License 2.0
3.33k stars 285 forks source link

Missing type definition errors when used in JS project #615

Open tuckergordon opened 1 year ago

tuckergordon commented 1 year ago

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>
4. 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'. ///


**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.

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

Doing this locally fixed the errors for me.

tuckergordon commented 1 year ago

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 commented 11 months ago

Is this still happening with the latest release?