vatro / svelthree

Create three.js content using Svelte components.
https://svelthree.dev
MIT License
482 stars 15 forks source link

`on` and `onx` methods, reconsider types #172

Closed vatro closed 2 years ago

vatro commented 2 years ago

concerning on and onx methods, e.g. ìn Mesh: https://github.com/vatro/svelthree/blob/00e3fada8d93f9bf24363fca84e396d37833d177/src/lib/components/Mesh.svelte#L705 https://github.com/vatro/svelthree/blob/00e3fada8d93f9bf24363fca84e396d37833d177/src/lib/components/Mesh.svelte#L725

there are several $on type definitions in Svelte (runtime + dev):

// svelte/types/runtime/internal/Component.d.ts
export declare class SvelteComponent {
  ...
  $on(type: any, callback: any): () => void;
  ...
}
// svelte/types/runtime/internal/dev.d.ts
export interface SvelteComponentDev {
  ...
  $on(event: string, callback: (event: any) => void): () => void;
  ...
}
// svelte/types/runtime/internal/dev.d.ts
export interface SvelteComponentTyped {
  ...
  $on<K extends Extract<keyof Events, string>>(type: K, callback: (e: Events[K]) => void): () => void;
  ...
}

I believe the first one is the relevant one, so we could a) just ignore no-explicit-any here too b) use the second one + replace any with unknown or ignore no-explicit-any

I'll go with a) for now and reconsider it later.

Originally posted by @vatro in https://github.com/vatro/svelthree/issues/170#issuecomment-1253576245

vatro commented 1 year ago

This was reconsidered and on and onx methods are being polished / refactored incl. new types during a major interaction refactor, see: https://github.com/vatro/svelthree/commit/9eb3db365c83f1f6f0ccc4eabb87706a3d85f449