Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
[
{
"range": {
"start": { "line": 13, "character": 1 },
"end": { "line": 13, "character": 11 }
"start": { "line": 25, "character": 1 },
"end": { "line": 25, "character": 11 }
},
"severity": 1,
"source": "ts",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
[
{
"range": {
"start": { "line": 13, "character": 1 },
"end": { "line": 13, "character": 11 }
"start": { "line": 25, "character": 1 },
"end": { "line": 25, "character": 11 }
},
"severity": 1,
"source": "ts",
"message": "Type definitions are missing for this Svelte Component. If you are using Svelte 3.31+, use SvelteComponentTyped to add a definition:\n import type { SvelteComponentTyped } from \"svelte\";\n class ComponentName extends SvelteComponentTyped<{propertyName: string;}> {}\n\nUnderlying error:\nArgument of type 'typeof DoesntWork' is not assignable to parameter of type 'new (args: { target: any; props?: any; }) => Svelte2TsxComponent<any, any, any>'.\n Type 'DoesntWork' is missing the following properties from type 'Svelte2TsxComponent<any, any, any>': $$prop_def, $$events_def, $$slot_def, $on, and 5 more.",
"message": "Type definitions are missing for this Svelte Component. If you are using Svelte 3.31+, use SvelteComponentTyped to add a definition:\n import type { SvelteComponentTyped } from \"svelte\";\n class ComponentName extends SvelteComponentTyped<{propertyName: string;}> {}\n\nUnderlying error:\nArgument of type 'typeof DoesntWork' is not assignable to parameter of type 'new (args: { target: any; props?: any; }) => Svelte2TsxComponent<any, {}, any>'.\n Type 'DoesntWork' is missing the following properties from type 'Svelte2TsxComponent<any, {}, any>': $$prop_def, $$events_def, $$slot_def, $on, and 5 more.",
"code": 2345,
"tags": []
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,24 @@
import Imported from './imported.svelte';

class Works extends SvelteComponentTyped<any, any, any> {}
class Works2 extends SvelteComponentTyped<
{ hi: string },
{ click: MouseEvent },
{
default: {
foo: string;
};
}
> {}
class DoesntWork {}
</script>

<!-- valid -->
<Works />
<Imported />
<Works2 hi="hi" on:click={e => console.log(e.movementX)} let:foo>
{foo.toLocaleLowerCase()}
</Works2>

<!-- invalid -->
<DoesntWork />
2 changes: 1 addition & 1 deletion packages/svelte2tsx/svelte-shims.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,6 @@ declare function __sveltets_2_ensureTransition(transitionCall: __sveltets_2_Svel
declare function __sveltets_2_ensureType<T>(type: AConstructorTypeOf<T>, el: T): {};
declare function __sveltets_2_ensureType<T1, T2>(type1: AConstructorTypeOf<T1>, type2: AConstructorTypeOf<T2>, el: T1 | T2): {};

declare function __sveltets_2_ensureComponent<T extends new (args: {target: any, props?: any}) => Svelte2TsxComponent<any, any, any>>(type: T): T extends never ? Svelte2TsxComponent<any, any, any> : T;
declare function __sveltets_2_ensureComponent<T extends new (args: {target: any, props?: any}) => Svelte2TsxComponent<any, {}, any>>(type: T): T extends never ? Svelte2TsxComponent<any, any, any> : T;

declare function __sveltets_2_ensureArray<T extends ArrayLike<unknown>>(array: T): T extends ArrayLike<infer U> ? U[] : any[];