Skip to content

Commit

Permalink
fix: use SvelteComponent in shims-v4
Browse files Browse the repository at this point in the history
  • Loading branch information
dummdidumm committed Jul 6, 2023
1 parent dfcfacf commit 71b8e7b
Show file tree
Hide file tree
Showing 21 changed files with 130 additions and 31 deletions.
14 changes: 6 additions & 8 deletions packages/svelte2tsx/svelte-shims-v4.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,6 @@ declare function __sveltets_2_with_any_event<Props = {}, Events = {}, Slots = {}
declare function __sveltets_2_store_get<T = any>(store: SvelteStore<T>): T
declare function __sveltets_2_store_get<Store extends SvelteStore<any> | undefined | null>(store: Store): Store extends SvelteStore<infer T> ? T : Store;
declare function __sveltets_2_any(dummy: any): any;
// declare function __sveltets_1_empty(...dummy: any[]): {};
// declare function __sveltets_1_componentType(): AConstructorTypeOf<import("svelte").SvelteComponentTyped<any, any, any>>
declare function __sveltets_2_invalidate<T>(getValue: () => T): T

declare function __sveltets_2_mapWindowEvent<K extends keyof HTMLBodyElementEventMap>(
Expand Down Expand Up @@ -129,16 +127,16 @@ declare function __sveltets_2_unionType<T1, T2, T3>(t1: T1, t2: T2, t3: T3): T1
declare function __sveltets_2_unionType<T1, T2, T3, T4>(t1: T1, t2: T2, t3: T3, t4: T4): T1 | T2 | T3 | T4;
declare function __sveltets_2_unionType(...types: any[]): any;

declare function __sveltets_2_createSvelte2TsxComponent<Props, Events, Slots>(
declare function __sveltets_2_createSvelte2TsxComponent<Props extends {}, Events extends {}, Slots extends {}>(
render: {props: Props, events: Events, slots: Slots }
): SvelteComponentConstructor<import("svelte").SvelteComponentTyped<Props, Events, Slots>,import('svelte').ComponentConstructorOptions<Props>>;
): SvelteComponentConstructor<import("svelte").SvelteComponent<Props, Events, Slots>,import('svelte').ComponentConstructorOptions<Props>>;

declare function __sveltets_2_unwrapArr<T>(arr: ArrayLike<T>): T
declare function __sveltets_2_unwrapPromiseLike<T>(promise: PromiseLike<T> | T): T

// v2
declare function __sveltets_2_createCreateSlot<Slots = Record<string, Record<string, any>>>(): <SlotName extends keyof Slots>(slotName: SlotName, attrs: Slots[SlotName]) => Record<string, any>;
declare function __sveltets_2_createComponentAny(props: Record<string, any>): import("svelte").SvelteComponentTyped<any, any, any>;
declare function __sveltets_2_createComponentAny(props: Record<string, any>): import("svelte").SvelteComponent<any, any, any>;

declare function __sveltets_2_any(...dummy: any[]): any;
declare function __sveltets_2_empty(...dummy: any[]): {};
Expand Down Expand Up @@ -214,11 +212,11 @@ declare type ATypedSvelteComponent = {
/**
* Ambient type only used for intellisense, DO NOT USE IN YOUR PROJECT.
*
* If you're looking for the type of a Svelte Component, use `SvelteComponentTyped` and `ComponentType` instead:
* If you're looking for the type of a Svelte Component, use `SvelteComponent` and `ComponentType` instead:
*
* ```ts
* import type { ComponentType, SvelteComponentTyped } from "svelte";
* let myComponentConstructor: ComponentType<SvelteComponentTyped> = ..;
* import type { ComponentType, SvelteComponent } from "svelte";
* let myComponentConstructor: ComponentType<SvelteComponent> = ..;
* ```
*/
declare type ConstructorOfATypedSvelteComponent = new (args: {target: any, props?: any}) => ATypedSvelteComponent
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/** @typedef {typeof __propDef.props} TestProps */
/** @typedef {typeof __propDef.events} TestEvents */
/** @typedef {typeof __propDef.slots} TestSlots */
export default class Test extends SvelteComponentTyped<{
export default class Test extends SvelteComponent<{
astring: string;
}, {
event: CustomEvent<any>;
Expand All @@ -17,7 +17,7 @@ export default class Test extends SvelteComponentTyped<{
export type TestProps = typeof __propDef.props;
export type TestEvents = typeof __propDef.events;
export type TestSlots = typeof __propDef.slots;
import { SvelteComponentTyped } from "svelte";
import { SvelteComponent } from "svelte";
declare const __propDef: {
props: {
astring: string;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/** @typedef {typeof __propDef.props} TestProps */
/** @typedef {typeof __propDef.events} TestEvents */
/** @typedef {typeof __propDef.slots} TestSlots */
export default class Test extends SvelteComponentTyped<{
export default class Test extends SvelteComponent<{
astring: string;
}, {
event: CustomEvent<any>;
Expand All @@ -17,7 +17,7 @@ export default class Test extends SvelteComponentTyped<{
export type TestProps = typeof __propDef.props;
export type TestEvents = typeof __propDef.events;
export type TestSlots = typeof __propDef.slots;
import { SvelteComponentTyped } from "svelte";
import { SvelteComponent } from "svelte";
declare const __propDef: {
props: {
astring: string;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/** @typedef {typeof __propDef.props} Test2Props */
/** @typedef {typeof __propDef.events} Test2Events */
/** @typedef {typeof __propDef.slots} Test2Slots */
export default class Test2 extends SvelteComponentTyped<{
export default class Test2 extends SvelteComponent<{
foo: boolean;
}, {
[evt: string]: CustomEvent<any>;
Expand All @@ -10,7 +10,7 @@ export default class Test2 extends SvelteComponentTyped<{
export type Test2Props = typeof __propDef.props;
export type Test2Events = typeof __propDef.events;
export type Test2Slots = typeof __propDef.slots;
import { SvelteComponentTyped } from "svelte";
import { SvelteComponent } from "svelte";
declare const __propDef: {
props: {
foo: import('./foo').Foo;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/** @typedef {typeof __propDef.props} TestNoScriptProps */
/** @typedef {typeof __propDef.events} TestNoScriptEvents */
/** @typedef {typeof __propDef.slots} TestNoScriptSlots */
export default class TestNoScript extends SvelteComponentTyped<{
export default class TestNoScript extends SvelteComponent<{
[x: string]: never;
}, {
click: MouseEvent;
Expand All @@ -14,7 +14,7 @@ export default class TestNoScript extends SvelteComponentTyped<{
export type TestNoScriptProps = typeof __propDef.props;
export type TestNoScriptEvents = typeof __propDef.events;
export type TestNoScriptSlots = typeof __propDef.slots;
import { SvelteComponentTyped } from "svelte";
import { SvelteComponent } from "svelte";
declare const __propDef: {
props: {
[x: string]: never;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/** @typedef {typeof __propDef.props} TestNoTypesProps */
/** @typedef {typeof __propDef.events} TestNoTypesEvents */
/** @typedef {typeof __propDef.slots} TestNoTypesSlots */
export default class TestNoTypes extends SvelteComponentTyped<{
export default class TestNoTypes extends SvelteComponent<{
noType: any;
initializer?: string;
}, {
Expand All @@ -17,7 +17,7 @@ export default class TestNoTypes extends SvelteComponentTyped<{
export type TestNoTypesProps = typeof __propDef.props;
export type TestNoTypesEvents = typeof __propDef.events;
export type TestNoTypesSlots = typeof __propDef.slots;
import { SvelteComponentTyped } from "svelte";
import { SvelteComponent } from "svelte";
declare const __propDef: {
props: {
noType: any;
Expand Down
3 changes: 3 additions & 0 deletions packages/svelte2tsx/test/emitDts/samples/svelte3/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"svelteShimsPath": "svelte-shims.d.ts"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { SvelteComponentTyped } from "svelte";
declare const __propDef: {
props: {
astring: string;
};
events: {
event: CustomEvent<any>;
} & {
[evt: string]: CustomEvent<any>;
};
slots: {
default: {
astring: string;
};
};
};
export type TestProps = typeof __propDef.props;
export type TestEvents = typeof __propDef.events;
export type TestSlots = typeof __propDef.slots;
export default class Test extends SvelteComponentTyped<TestProps, TestEvents, TestSlots> {
get astring(): string;
}
export {};
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/** @typedef {typeof __propDef.props} TestJsProps */
/** @typedef {typeof __propDef.events} TestJsEvents */
/** @typedef {typeof __propDef.slots} TestJsSlots */
export default class TestJs extends SvelteComponentTyped<{
astring: string;
}, {
event: CustomEvent<any>;
} & {
[evt: string]: CustomEvent<any>;
}, {
default: {
astring: string;
};
}> {
get astring(): string;
}
export type TestJsProps = typeof __propDef.props;
export type TestJsEvents = typeof __propDef.events;
export type TestJsSlots = typeof __propDef.slots;
import { SvelteComponentTyped } from "svelte";
declare const __propDef: {
props: {
astring: string;
};
events: {
event: CustomEvent<any>;
} & {
[evt: string]: CustomEvent<any>;
};
slots: {
default: {
astring: string;
};
};
};
export {};
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export { default as Test } from './Test.svelte';
export { default as TestJs } from './TestJs.svelte';
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<script lang="ts">
import { createEventDispatcher } from 'svelte';
export const astring: string;
const dispatch = createEventDispatcher();
dispatch('event', true);
</script>

<slot {astring} />
12 changes: 12 additions & 0 deletions packages/svelte2tsx/test/emitDts/samples/svelte3/src/TestJs.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<script>
import { createEventDispatcher } from 'svelte';
/**
* @type {string}
*/
export const astring;
const dispatch = createEventDispatcher();
dispatch('event', true);
</script>

<slot {astring} />
2 changes: 2 additions & 0 deletions packages/svelte2tsx/test/emitDts/samples/svelte3/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export { default as Test } from './Test.svelte';
export { default as TestJs } from './TestJs.svelte';
14 changes: 14 additions & 0 deletions packages/svelte2tsx/test/emitDts/samples/svelte3/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"compilerOptions": {
"moduleResolution": "node",
"module": "es2020",
"lib": ["es2020", "DOM"],
"target": "es2019",
"isolatedModules": true,
"resolveJsonModule": true,
"esModuleInterop": true,
"allowJs": true,
"checkJs": true
},
"include": ["./src/**/*.d.ts", "./src/**/*.js", "./src/**/*.ts", "./src/**/*.svelte"]
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { SvelteComponentTyped } from "svelte";
import { SvelteComponent } from "svelte";
declare const __propDef: {
props: {
astring: string;
Expand All @@ -17,7 +17,7 @@ declare const __propDef: {
export type TestProps = typeof __propDef.props;
export type TestEvents = typeof __propDef.events;
export type TestSlots = typeof __propDef.slots;
export default class Test extends SvelteComponentTyped<TestProps, TestEvents, TestSlots> {
export default class Test extends SvelteComponent<TestProps, TestEvents, TestSlots> {
get astring(): string;
}
export {};
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { SvelteComponentTyped } from "svelte";
import { SvelteComponent } from "svelte";
import { type TestProps } from './foo';
declare const __propDef: {
props: {
Expand All @@ -18,5 +18,5 @@ type TestProps_ = typeof __propDef.props;
export { TestProps_ as TestProps };
export type TestEvents = typeof __propDef.events;
export type TestSlots = typeof __propDef.slots;
export default class Test extends SvelteComponentTyped<TestProps, TestEvents, TestSlots> {
export default class Test extends SvelteComponent<TestProps, TestEvents, TestSlots> {
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { SvelteComponentTyped } from "svelte";
import { SvelteComponent } from "svelte";
declare class __sveltets_Render<T extends boolean> {
props(): {
a: T;
Expand All @@ -15,6 +15,6 @@ declare class __sveltets_Render<T extends boolean> {
export type InterfacesProps<T extends boolean> = ReturnType<__sveltets_Render<T>['props']>;
export type InterfacesEvents<T extends boolean> = ReturnType<__sveltets_Render<T>['events']>;
export type InterfacesSlots<T extends boolean> = ReturnType<__sveltets_Render<T>['slots']>;
export default class Interfaces<T extends boolean> extends SvelteComponentTyped<InterfacesProps<T>, InterfacesEvents<T>, InterfacesSlots<T>> {
export default class Interfaces<T extends boolean> extends SvelteComponent<InterfacesProps<T>, InterfacesEvents<T>, InterfacesSlots<T>> {
}
export {};
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { SvelteComponentTyped } from "svelte";
import { SvelteComponent } from "svelte";
declare const __propDef: {
props: {
astring: string;
Expand All @@ -17,7 +17,7 @@ declare const __propDef: {
export type TestProps = typeof __propDef.props;
export type TestEvents = typeof __propDef.events;
export type TestSlots = typeof __propDef.slots;
export default class Test extends SvelteComponentTyped<TestProps, TestEvents, TestSlots> {
export default class Test extends SvelteComponent<TestProps, TestEvents, TestSlots> {
get astring(): string;
}
export {};
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { SvelteComponentTyped } from "svelte";
import { SvelteComponent } from "svelte";
import type { Foo } from './foo';
declare const __propDef: {
props: {
Expand All @@ -15,6 +15,6 @@ declare const __propDef: {
export type Test2Props = typeof __propDef.props;
export type Test2Events = typeof __propDef.events;
export type Test2Slots = typeof __propDef.slots;
export default class Test2 extends SvelteComponentTyped<Test2Props, Test2Events, Test2Slots> {
export default class Test2 extends SvelteComponent<Test2Props, Test2Events, Test2Slots> {
}
export {};
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { SvelteComponentTyped } from "svelte";
import { SvelteComponent } from "svelte";
declare const __propDef: {
props: {
b?: () => void;
Expand All @@ -15,7 +15,7 @@ declare const __propDef: {
export type Test3PropsProps = typeof __propDef.props;
export type Test3PropsEvents = typeof __propDef.events;
export type Test3PropsSlots = typeof __propDef.slots;
export default class Test3Props extends SvelteComponentTyped<Test3PropsProps, Test3PropsEvents, Test3PropsSlots> {
export default class Test3Props extends SvelteComponent<Test3PropsProps, Test3PropsEvents, Test3PropsSlots> {
get b(): () => void;
}
export {};

0 comments on commit 71b8e7b

Please sign in to comment.