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

Request: Include typescript definitions #3

Closed
AgarwalPragy opened this issue Feb 14, 2023 · 8 comments
Closed

Request: Include typescript definitions #3

AgarwalPragy opened this issue Feb 14, 2023 · 8 comments

Comments

@AgarwalPragy
Copy link

Error: Could not find a declaration file for module 'svelte-confetti'.
 '/node_modules/.pnpm/svelte-confetti@1.2.2/node_modules/svelte-confetti/src/index.js' implicitly has an 'any' type.
  Try `npm i --save-dev @types/svelte-confetti` if it exists or add a new declaration (.d.ts) file containing `declare module 'svelte-confetti';` (ts)
  import { Confetti } from 'svelte-confetti'

@types/svelte-confetti is not in the npm registry

@LeoDog896
Copy link

I'll be interested in getting this done. @Mitcheljager will you be fine with it?

@Mitcheljager
Copy link
Owner

@LeoDog896 Absolutely! I don't tend to use Typescript myself, but I know a lot of others do.

@LeoDog896
Copy link

@Mitcheljager would it be a wiser idea to make a standard SvelteKit skeleton library instead, that way the main demo page could benefit from SSR (as mentioned in the README)? I can make two separate PRs - one that moves the project to TS/SvelteKit (but leaves the core in JavaScript), then a second one with smaller diffs but more relevant code changes to move to TypeScript.

@Mitcheljager
Copy link
Owner

I don't think the demo page should be using Sveltekit, I want it to stay easy to manage via github pages. The project is meant for Svelte, with it working in SSR simply being a nice bonus.

@LeoDog896
Copy link

Alright, thanks for the clarification!

@hallowatcher
Copy link

hallowatcher commented May 20, 2023

For anyone reading this, I simply created a new file called ambient.d.ts in the src folder of my SvelteKit app (as per the SvelteKit recommendation found here) with the following contents:

declare module 'svelte-confetti' {
  import { SvelteComponentTyped } from 'svelte';

  declare const __propDef: {
    props: {
      /**
       * The max size in pixels of the individual confetti pieces.
       * @default 10
       */
      size?: number;
      /**
       * The max horizontal range of the confetti pieces. Negative is left, positive is right. [-1, 1] would mean maximum of 200px left and 200px right.
       * @default [-0.5, 0.5]
       */
      x?: [number, number];
      /**
       * The max vertical range of the confetti pieces. Negative is down, positive is up. [-1, 1] would mean maximum of 200px down and 200px up.
       * @default [0.25, 1]
       */
      y?: [number, number];
      /**
       * Duration of the animation for each individual piece.
       * @default 2000
       */
      duration?: number;
      /**
       * If set to true the animation will play indefinitely.
       * @default false
       */
      infinite?: boolean;
      /**
       * Used to set a random delay for each piece. A large difference between each number will mean a longer spray time.
       * @default [0, 50]
       */
      delay?: [number, number];
      /**
       * Color range on the HSL color wheel. 0 to 360 is full RGB. 75 To 150 would be only green colors.
       * @default [0, 360]
       */
      colorRange?: [number, number];
      /**
       * Can be used to pick a random color from this array. Set just one array elements to have a single color. Accepts any viable css background property, including gradients and images.
       * @default []
       */
      colorArray?: number[];
      /**
       * Amount of particles spawned. The larger your spray the more pieces you might want. Be careful with too many as it might impact performance.
       * @default 50
       */
      amount?: number;
      /**
       * How many times the animation will play before stopping. Is overwritten by the "infinite" property.
       * @default 1
       */
      iterationCount?: number;
      /**
       * How far each piece falls. Accepts any css property, px, rem, vh, etc, but not 0.
       * @default "100px"
       */
      fallDistance?: string;
      /**
       * Set to true to make each confetti piece rounded.
       * @default false
       */
      rounded?: boolean;
      /**
       * Set to true to make the explosion appear in a cone like shape which might feel more realistic when dealing with a larger amount.
       * @default false
       */
      cone?: boolean;
      /**
       * Set to true to make the particles accelerate at a constant speed without "falling" down. Give it a more explosion like effect.
       * @default false
       */
      noGravity?: boolean;
      /**
       * A number from 0 to 1 that determines how far the particles spread horizontally. A low number will mean the x near the peak and the x near the end are similar.
       * @default 0.15
       */
      xSpread?: number;
      /**
       * By default the elements are removed when the animation is complete. Set to false to prevent this behaviour.
       * @default true
       */
      destroyOnComplete?: boolean;
    };
    events: {};
    slots: {};
  };

  type ConfettiProps = typeof __propDef.props;
  type ConfettiEvents = typeof __propDef.events;
  type ConfettiSlots = typeof __propDef.slots;
  export class Confetti extends SvelteComponentTyped<ConfettiProps, ConfettiEvents, ConfettiSlots> {}
}

@LeoDog896 feel free to use this inside the typings whenever you get the chance.

EthanThatOneKid added a commit to EthanThatOneKid/acmcsuf.com that referenced this issue Jul 24, 2023
EthanThatOneKid added a commit to EthanThatOneKid/acmcsuf.com that referenced this issue Aug 2, 2023
* migration to Svelte 4

Run `npx svelte-migrate@latest svelte-4`

See: <https://svelte.dev/docs/v4-migration-guide>.

* migration to Svelte 4

Run `npx svelte-migrate@latest svelte-4`

See: <https://svelte.dev/docs/v4-migration-guide>.

* Run `npm i`

* Verify `package.json`

* Run `npm i --force`

* Uninstall every package

* Reinstall every package

* Run `npm create svelte@latest .`

TODO: Consolidate old config files with new config files.

* Go back to original configurations

* Disable 'svelte/no-at-html-tags' eslint rule

See: <https://sveltejs.github.io/eslint-plugin-svelte/rules/no-at-html-tags/>.

* `npm i`, `npm run all`

* team picker: error  '_' is defined but never used

```
26:48  error  '_' is defined but never used  @typescript-eslint/no-unused-vars
```

* navbar: keypress handlers must have an  ARIA role

32:3  error  A11y: <div> with click, keypress handlers must have an
ARIA role(a11y-no-static-element-interactions)  svelte/valid-compile

* DIVs with click handlers must have an ARIA role

Resolved error messages:
```
C:\Users\ethan\Documents\GitHub\acmcsuf.com\src\lib\components\select\select.svelte
  22:5   error  A11y: <div> with click, keypress handlers must have an ARIA role(a11y-no-static-element-interactions)  svelte/valid-compile
  29:11  error  A11y: <div> with click, keypress handlers must have an ARIA role(a11y-no-static-element-interactions)  svelte/valid-compile
```

* Update app.html

* Event.svelte: Non-interactive element <details> should not be assigned mouse or keyboard event listeners

C:\Users\ethan\Documents\GitHub\acmcsuf.com\src\routes\(site)\events\event.svelte
   39:3  error  A11y: Non-interactive element <details> should not be assigned mouse or keyboard event listeners.(a11y-no-noninteractive-element-interactions)  svelte/valid-compile

* Contributors: fix unused summary CSS

```
error  Unused CSS selector ".container li details summary[open]"(css-unused-selector)
 svelte/valid-compile
```

* Fix: Unused CSS selector "section ul li a > h2"

135:9  error  Unused CSS selector "section ul li a > h2"(css-unused-selector)  svelte/valid-compile

* Fix: Unused CSS selector ".event-actionbar"

```
231:5  error  Unused CSS selector ".event-actionbar"(css-unused-selector)

                         svelte/valid-compile
```

* Genuary: Remove `.tall`, `.wide`, `.big`

```
  121:3  error  Unused CSS selector ".grid-inner-wrapper .wide"(css-unused-selector)  svelte/valid-compile
  125:3  error  Unused CSS selector ".grid-inner-wrapper .tall"(css-unused-selector)  svelte/valid-compile
  129:3  error  Unused CSS selector ".grid-inner-wrapper .big"(css-unused-selector)   svelte/valid-compile
```

* Genuary: Fix incorrect ARIA role

```
13:1  error  A11y: <span> with click, keydown handlers must have an ARIA role(a11y-no-static-element-interactions)  svelte/valid-compile
  19:3  error  A11y: <span> with click, keydown handlers must have an ARIA role(a11y-no-static-element-interactions)  svelte/valid-compile
```

* Fix `/wave1` and `/wave2` lint errors

```
C:\Users\ethan\Documents\GitHub\acmcsuf.com\src\routes\(site)\wave1\+page.svelte
   86:5  error  A11y: <span> with click, keypress handlers must have an ARIA role(a11y-no-static-element-interactions)  svelte/valid-compile
   93:3  error  A11y: <div> with click, keypress handlers must have an ARIA role(a11y-no-static-element-interactions)   svelte/valid-compile
  140:3  error  Unused CSS selector ".page-body"(css-unused-selector)
                                svelte/valid-compile

C:\Users\ethan\Documents\GitHub\acmcsuf.com\src\routes\(site)\wave2\+page.svelte
   86:5  error  A11y: <span> with click, keypress handlers must have an ARIA role(a11y-no-static-element-interactions)  svelte/valid-compile
   93:3  error  A11y: <div> with click, keypress handlers must have an ARIA role(a11y-no-static-element-interactions)   svelte/valid-compile
  140:3  error  Unused CSS selector ".page-body"(css-unused-selector)
                                svelte/valid-compile
```

* Quiz: fix lint errors

```
143:7  error  A11y: <div> with click, keydown handlers must have an ARIA role(a11y-no-static-element-interactions)  svelte/valid-compile
  159:9  error  A11y: <div> with click, keydown handlers must have an ARIA role(a11y-no-static-element-interactions)  svelte/valid-compile
```

* Genuary: Remove unused styles

```
52:3  error  Unused CSS selector "section.collage-container"(css-unused-selector)
                      svelte/valid-compile
  60:5  error  Unused CSS selector "section.collage-container .collage-container-inner"(css-unused-selector)  svelte/valid-compile
```

* svelte-confetti: Add type defs

Mitcheljager/svelte-confetti#3 (comment)

* Events: Fix svelte-check errors

```
Error: Property 'timeZone' does not exist on type 'ZonedDateTime'. Did you mean 'timeZoneId'?

  const dtStart = zonedDateTimeFromGCalDateTime(new Date(event.start.dateTime), refDate.timeZone);
  const dtEnd = zonedDateTimeFromGCalDateTime(new Date(event.end.dateTime), refDate.timeZone);
  const date = dtStart.toString();

====================================
svelte-check found 2 errors and 0 warnings in 1 file
```

* Use old `playwright.config.ts`

* comment-out breaking Playwright tests
@Mitcheljager
Copy link
Owner

My opinion has changed a bit since the last time I commented on this issue. With f5d265e this entire repo has moved to Svelte 4, and with that the full svelte-package flow, SvelteKit and all. The types are auto generated by svelte-package and are all included now.

@LeoDog896
Copy link

Thank you so much!

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

4 participants