svelte2tsx
Advanced tools
Comparing version 0.5.23 to 0.6.0
@@ -41,3 +41,3 @@ export interface SvelteCompiledToTsx { | ||
/** | ||
* When setting this to 'dts', all tsx/jsx code and the template code will be thrown out. | ||
* When setting this to 'dts', all ts/js code and the template code will be thrown out. | ||
* Only the `code` property will be set on the returned element. | ||
@@ -48,8 +48,8 @@ * Use this as an intermediate step to generate type definitions from a component. | ||
* for example through `filenames.push(require.resolve('svelte2tsx/svelte-shims.d.ts'))`. | ||
* If you pass 'ts', it uses the new transformation which will replace the now deprecated 'tsx' | ||
* transformation soon. | ||
* If you pass 'ts', it uses the regular Svelte->TS/JS transformation. | ||
* | ||
* @default 'ts' | ||
*/ | ||
mode?: 'ts' | 'tsx' | 'dts', | ||
mode?: 'ts' | 'dts', | ||
/** | ||
* Takes effect when using the new 'ts' mode. Default 'svelteHTML'. | ||
* Tells svelte2tsx from which namespace some specific functions to use. | ||
@@ -62,2 +62,4 @@ * | ||
* - `mapElementTag<Key extends keyof YourElements>(str: Key): YourElements[Key]` | ||
* | ||
* @default 'svelteHTML' | ||
*/ | ||
@@ -95,3 +97,3 @@ typingsNamespace?: string; | ||
/**@deprecated*/ | ||
export interface EmitDtsConig extends EmitDtsConfig {} /* eslint-disable-line @typescript-eslint/no-empty-interface */ | ||
export interface EmitDtsConig extends EmitDtsConfig {} | ||
@@ -98,0 +100,0 @@ /** |
{ | ||
"name": "svelte2tsx", | ||
"version": "0.5.23", | ||
"version": "0.6.0", | ||
"description": "Convert Svelte components to TSX for type checking", | ||
@@ -21,26 +21,26 @@ "author": "David Pershouse", | ||
"devDependencies": { | ||
"@jridgewell/trace-mapping": "^0.3.9", | ||
"@rollup/plugin-commonjs": "^15.0.0", | ||
"@rollup/plugin-json": "^4.0.0", | ||
"@rollup/plugin-node-resolve": "^9.0.0", | ||
"@rollup/plugin-typescript": "^6.0.0", | ||
"@jridgewell/sourcemap-codec": "^1.4.14", | ||
"@jridgewell/trace-mapping": "^0.3.17", | ||
"@rollup/plugin-commonjs": "^24.0.0", | ||
"@rollup/plugin-json": "^6.0.0", | ||
"@rollup/plugin-node-resolve": "^15.0.0", | ||
"@rollup/plugin-typescript": "^10.0.0", | ||
"@types/mocha": "^9.1.0", | ||
"@types/node": "^8.10.53", | ||
"@types/node": "^16.0.0", | ||
"@types/unist": "^2.0.3", | ||
"@types/vfile": "^3.0.2", | ||
"magic-string": "^0.25.7", | ||
"magic-string": "^0.27.0", | ||
"mocha": "^9.2.0", | ||
"periscopic": "^2.0.2", | ||
"rollup": "2.52.7", | ||
"rollup": "3.7.5", | ||
"rollup-plugin-delete": "^2.0.0", | ||
"source-map-support": "^0.5.16", | ||
"sourcemap-codec": "^1.4.8", | ||
"svelte": "~3.49.0", | ||
"svelte": "~3.55.0", | ||
"tiny-glob": "^0.2.6", | ||
"tslib": "^1.10.0", | ||
"tslib": "^2.4.0", | ||
"typescript": "^4.9.3" | ||
}, | ||
"peerDependencies": { | ||
"svelte": "^3.24", | ||
"typescript": "^4.1.2" | ||
"svelte": "^3.55", | ||
"typescript": "^4.9.4" | ||
}, | ||
@@ -47,0 +47,0 @@ "scripts": { |
@@ -40,4 +40,4 @@ # svelte2tsx | ||
export default class _World_ extends __sveltets_1_createSvelte2TsxComponent( | ||
__sveltets_1_partial(__sveltets_1_with_any_event(render)) | ||
export default class _World_ extends __sveltets_2_createSvelte2TsxComponent( | ||
__sveltets_2_partial(__sveltets_2_with_any_event(render)) | ||
) {} | ||
@@ -44,0 +44,0 @@ ``` |
@@ -1,2 +0,1 @@ | ||
/* eslint @typescript-eslint/no-unused-vars: off */ | ||
declare namespace svelteNative.JSX { | ||
@@ -27,3 +26,2 @@ | ||
// Add empty IntrinsicAttributes to prevent fallback to the one in the JSX namespace | ||
// eslint-disable-next-line @typescript-eslint/no-empty-interface | ||
interface IntrinsicAttributes { | ||
@@ -30,0 +28,0 @@ } |
@@ -8,2 +8,3 @@ // Whenever a ambient declaration changes, its number should be increased | ||
declare module '*.svelte' { | ||
type _SvelteComponent<Props=any,Events=any,Slots=any> = import("svelte").SvelteComponentTyped<Props,Events,Slots>; | ||
export default _SvelteComponent | ||
@@ -13,2 +14,8 @@ } | ||
/** | ||
* @deprecated This will be removed soon. Use `SvelteComponentTyped` instead: | ||
* ```ts | ||
* import type { SvelteComponentTyped } from 'svelte'; | ||
* ``` | ||
*/ | ||
declare class Svelte2TsxComponent< | ||
@@ -58,4 +65,3 @@ Props extends {} = {}, | ||
type _SvelteComponent<Props=any,Events=any,Slots=any> = typeof import("svelte") extends {SvelteComponentTyped: any} ? import("svelte").SvelteComponentTyped<Props,Events,Slots> : Svelte2TsxComponent<Props,Events,Slots>; | ||
/** @internal PRIVATE API, DO NOT USE */ | ||
interface Svelte2TsxComponentConstructorParameters<Props extends {}> { | ||
@@ -81,4 +87,6 @@ /** | ||
type AConstructorTypeOf<T, U extends any[] = any[]> = new (...args: U) => T; | ||
/** @internal PRIVATE API, DO NOT USE */ | ||
type SvelteComponentConstructor<T, U extends Svelte2TsxComponentConstructorParameters<any>> = new (options: U) => T; | ||
/** @internal PRIVATE API, DO NOT USE */ | ||
type SvelteActionReturnType = { | ||
@@ -89,2 +97,3 @@ update?: (args: any) => void, | ||
/** @internal PRIVATE API, DO NOT USE */ | ||
type SvelteTransitionConfig = { | ||
@@ -98,4 +107,6 @@ delay?: number, | ||
/** @internal PRIVATE API, DO NOT USE */ | ||
type SvelteTransitionReturnType = SvelteTransitionConfig | (() => SvelteTransitionConfig) | ||
/** @internal PRIVATE API, DO NOT USE */ | ||
type SvelteAnimationReturnType = { | ||
@@ -109,8 +120,15 @@ delay?: number, | ||
/** @internal PRIVATE API, DO NOT USE */ | ||
type SvelteWithOptionalProps<Props, Keys extends keyof Props> = Omit<Props, Keys> & Partial<Pick<Props, Keys>>; | ||
/** @internal PRIVATE API, DO NOT USE */ | ||
type SvelteAllProps = { [index: string]: any } | ||
/** @internal PRIVATE API, DO NOT USE */ | ||
type SveltePropsAnyFallback<Props> = {[K in keyof Props]: Props[K] extends never ? never : Props[K] extends undefined ? any : Props[K]} | ||
/** @internal PRIVATE API, DO NOT USE */ | ||
type SvelteSlotsAnyFallback<Slots> = {[K in keyof Slots]: {[S in keyof Slots[K]]: Slots[K][S] extends undefined ? any : Slots[K][S]}} | ||
/** @internal PRIVATE API, DO NOT USE */ | ||
type SvelteRestProps = { [index: string]: any } | ||
/** @internal PRIVATE API, DO NOT USE */ | ||
type SvelteSlots = { [index: string]: any } | ||
/** @internal PRIVATE API, DO NOT USE */ | ||
type SvelteStore<T> = { subscribe: (run: (value: T) => any, invalidate?: any) => any } | ||
@@ -121,26 +139,29 @@ | ||
// no ambient type references are left in the output | ||
/** @internal PRIVATE API, DO NOT USE */ | ||
type Expand<T> = T extends infer O ? { [K in keyof O]: O[K] } : never; | ||
/** @internal PRIVATE API, DO NOT USE */ | ||
type KeysMatching<Obj, V> = {[K in keyof Obj]-?: Obj[K] extends V ? K : never}[keyof Obj] | ||
declare type __sveltets_1_CustomEvents<T> = {[K in KeysMatching<T, CustomEvent>]: T[K] extends CustomEvent ? T[K]['detail']: T[K]} | ||
/** @internal PRIVATE API, DO NOT USE */ | ||
declare type __sveltets_2_CustomEvents<T> = {[K in KeysMatching<T, CustomEvent>]: T[K] extends CustomEvent ? T[K]['detail']: T[K]} | ||
declare var process: NodeJS.Process & { browser: boolean } | ||
declare var __sveltets_1_AnimationMove: { from: DOMRect, to: DOMRect } | ||
// declare var __sveltets_1_AnimationMove: { from: DOMRect, to: DOMRect } | ||
declare function __sveltets_1_ensureAnimation(animationCall: SvelteAnimationReturnType): {}; | ||
declare function __sveltets_1_ensureAction(actionCall: SvelteActionReturnType): {}; | ||
declare function __sveltets_1_ensureTransition(transitionCall: SvelteTransitionReturnType): {}; | ||
declare function __sveltets_1_ensureFunction(expression: (e: Event & { detail?: any }) => unknown ): {}; | ||
// Includes undefined and null for all types as all usages also allow these | ||
declare function __sveltets_1_ensureType<T>(type: AConstructorTypeOf<T>, el: T | undefined | null): {}; | ||
declare function __sveltets_1_ensureType<T1, T2>(type1: AConstructorTypeOf<T1>, type2: AConstructorTypeOf<T2>, el: T1 | T2 | undefined | null): {}; | ||
// declare function __sveltets_1_ensureAnimation(animationCall: SvelteAnimationReturnType): {}; | ||
// declare function __sveltets_1_ensureAction(actionCall: SvelteActionReturnType): {}; | ||
// declare function __sveltets_1_ensureTransition(transitionCall: SvelteTransitionReturnType): {}; | ||
// declare function __sveltets_1_ensureFunction(expression: (e: Event & { detail?: any }) => unknown ): {}; | ||
// // Includes undefined and null for all types as all usages also allow these | ||
// declare function __sveltets_1_ensureType<T>(type: AConstructorTypeOf<T>, el: T | undefined | null): {}; | ||
// declare function __sveltets_1_ensureType<T1, T2>(type1: AConstructorTypeOf<T1>, type2: AConstructorTypeOf<T2>, el: T1 | T2 | undefined | null): {}; | ||
declare function __sveltets_1_createEnsureSlot<Slots = Record<string, Record<string, any>>>(): <K1 extends keyof Slots, K2 extends keyof Slots[K1]>(k1: K1, k2: K2, val: Slots[K1][K2]) => Slots[K1][K2]; | ||
declare function __sveltets_1_ensureRightProps<Props>(props: Props): {}; | ||
declare function __sveltets_1_cssProp(prop: Record<string, any>): {}; | ||
declare function __sveltets_1_ctorOf<T>(type: T): AConstructorTypeOf<T>; | ||
declare function __sveltets_1_instanceOf<T = any>(type: AConstructorTypeOf<T>): T; | ||
declare function __sveltets_1_allPropsType(): SvelteAllProps | ||
declare function __sveltets_1_restPropsType(): SvelteRestProps | ||
declare function __sveltets_1_slotsType<Slots, Key extends keyof Slots>(slots: Slots): Record<Key, boolean>; | ||
// declare function __sveltets_1_createEnsureSlot<Slots = Record<string, Record<string, any>>>(): <K1 extends keyof Slots, K2 extends keyof Slots[K1]>(k1: K1, k2: K2, val: Slots[K1][K2]) => Slots[K1][K2]; | ||
declare function __sveltets_2_ensureRightProps<Props>(props: Props): {}; | ||
// declare function __sveltets_1_cssProp(prop: Record<string, any>): {}; | ||
// declare function __sveltets_1_ctorOf<T>(type: T): AConstructorTypeOf<T>; | ||
declare function __sveltets_2_instanceOf<T = any>(type: AConstructorTypeOf<T>): T; | ||
declare function __sveltets_2_allPropsType(): SvelteAllProps | ||
declare function __sveltets_2_restPropsType(): SvelteRestProps | ||
declare function __sveltets_2_slotsType<Slots, Key extends keyof Slots>(slots: Slots): Record<Key, boolean>; | ||
@@ -151,6 +172,6 @@ // Overload of the following two functions is necessary. | ||
declare function __sveltets_1_partial<Props = {}, Events = {}, Slots = {}>( | ||
declare function __sveltets_2_partial<Props = {}, Events = {}, Slots = {}>( | ||
render: {props: Props, events: Events, slots: Slots } | ||
): {props: Expand<SveltePropsAnyFallback<Props>>, events: Events, slots: Expand<SvelteSlotsAnyFallback<Slots>> } | ||
declare function __sveltets_1_partial<Props = {}, Events = {}, Slots = {}, OptionalProps extends keyof Props = any>( | ||
declare function __sveltets_2_partial<Props = {}, Events = {}, Slots = {}, OptionalProps extends keyof Props = any>( | ||
optionalProps: OptionalProps[], | ||
@@ -160,6 +181,6 @@ render: {props: Props, events: Events, slots: Slots } | ||
declare function __sveltets_1_partial_with_any<Props = {}, Events = {}, Slots = {}>( | ||
declare function __sveltets_2_partial_with_any<Props = {}, Events = {}, Slots = {}>( | ||
render: {props: Props, events: Events, slots: Slots } | ||
): {props: Expand<SveltePropsAnyFallback<Props> & SvelteAllProps>, events: Events, slots: Expand<SvelteSlotsAnyFallback<Slots>> } | ||
declare function __sveltets_1_partial_with_any<Props = {}, Events = {}, Slots = {}, OptionalProps extends keyof Props = any>( | ||
declare function __sveltets_2_partial_with_any<Props = {}, Events = {}, Slots = {}, OptionalProps extends keyof Props = any>( | ||
optionalProps: OptionalProps[], | ||
@@ -170,72 +191,72 @@ render: {props: Props, events: Events, slots: Slots } | ||
declare function __sveltets_1_with_any<Props = {}, Events = {}, Slots = {}>( | ||
declare function __sveltets_2_with_any<Props = {}, Events = {}, Slots = {}>( | ||
render: {props: Props, events: Events, slots: Slots } | ||
): {props: Expand<Props & SvelteAllProps>, events: Events, slots: Slots } | ||
declare function __sveltets_1_with_any_event<Props = {}, Events = {}, Slots = {}>( | ||
declare function __sveltets_2_with_any_event<Props = {}, Events = {}, Slots = {}>( | ||
render: {props: Props, events: Events, slots: Slots } | ||
): {props: Props, events: Events & {[evt: string]: CustomEvent<any>;}, slots: Slots } | ||
declare function __sveltets_1_store_get<T = any>(store: SvelteStore<T>): T | ||
declare function __sveltets_1_store_get<Store extends SvelteStore<any> | undefined | null>(store: Store): Store extends SvelteStore<infer T> ? T : Store; | ||
declare function __sveltets_1_any(dummy: any): any; | ||
declare function __sveltets_1_empty(...dummy: any[]): {}; | ||
declare function __sveltets_1_componentType(): AConstructorTypeOf<_SvelteComponent<any, any, any>> | ||
declare function __sveltets_1_invalidate<T>(getValue: () => T): T | ||
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_1_mapWindowEvent<K extends keyof HTMLBodyElementEventMap>( | ||
declare function __sveltets_2_mapWindowEvent<K extends keyof HTMLBodyElementEventMap>( | ||
event: K | ||
): HTMLBodyElementEventMap[K]; | ||
declare function __sveltets_1_mapBodyEvent<K extends keyof WindowEventMap>( | ||
declare function __sveltets_2_mapBodyEvent<K extends keyof WindowEventMap>( | ||
event: K | ||
): WindowEventMap[K]; | ||
declare function __sveltets_1_mapElementEvent<K extends keyof HTMLElementEventMap>( | ||
declare function __sveltets_2_mapElementEvent<K extends keyof HTMLElementEventMap>( | ||
event: K | ||
): HTMLElementEventMap[K]; | ||
declare function __sveltets_1_mapElementTag<K extends keyof ElementTagNameMap>( | ||
tag: K | ||
): ElementTagNameMap[K]; | ||
declare function __sveltets_1_mapElementTag<K extends keyof SVGElementTagNameMap>( | ||
tag: K | ||
): SVGElementTagNameMap[K]; | ||
declare function __sveltets_1_mapElementTag( | ||
tag: any | ||
): any; // needs to be any because used in context of <svelte:element> | ||
// declare function __sveltets_1_mapElementTag<K extends keyof ElementTagNameMap>( | ||
// tag: K | ||
// ): ElementTagNameMap[K]; | ||
// declare function __sveltets_1_mapElementTag<K extends keyof SVGElementTagNameMap>( | ||
// tag: K | ||
// ): SVGElementTagNameMap[K]; | ||
// declare function __sveltets_1_mapElementTag( | ||
// tag: any | ||
// ): any; // needs to be any because used in context of <svelte:element> | ||
declare function __sveltets_1_bubbleEventDef<Events, K extends keyof Events>( | ||
declare function __sveltets_2_bubbleEventDef<Events, K extends keyof Events>( | ||
events: Events, eventKey: K | ||
): Events[K]; | ||
declare function __sveltets_1_bubbleEventDef( | ||
declare function __sveltets_2_bubbleEventDef( | ||
events: any, eventKey: string | ||
): any; | ||
declare const __sveltets_1_customEvent: CustomEvent<any>; | ||
declare function __sveltets_1_toEventTypings<Typings>(): {[Key in keyof Typings]: CustomEvent<Typings[Key]>}; | ||
declare const __sveltets_2_customEvent: CustomEvent<any>; | ||
declare function __sveltets_2_toEventTypings<Typings>(): {[Key in keyof Typings]: CustomEvent<Typings[Key]>}; | ||
declare function __sveltets_1_unionType<T1, T2>(t1: T1, t2: T2): T1 | T2; | ||
declare function __sveltets_1_unionType<T1, T2, T3>(t1: T1, t2: T2, t3: T3): T1 | T2 | T3; | ||
declare function __sveltets_1_unionType<T1, T2, T3, T4>(t1: T1, t2: T2, t3: T3, t4: T4): T1 | T2 | T3 | T4; | ||
declare function __sveltets_1_unionType(...types: any[]): any; | ||
declare function __sveltets_2_unionType<T1, T2>(t1: T1, t2: T2): T1 | T2; | ||
declare function __sveltets_2_unionType<T1, T2, T3>(t1: T1, t2: T2, t3: T3): T1 | T2 | T3; | ||
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_1_awaitThen<T>( | ||
promise: T, | ||
onfulfilled: (value: T extends PromiseLike<infer U> ? U : T) => any, | ||
onrejected?: (value: T extends PromiseLike<any> ? any : never) => any | ||
): any; | ||
// declare function __sveltets_1_awaitThen<T>( | ||
// promise: T, | ||
// onfulfilled: (value: T extends PromiseLike<infer U> ? U : T) => any, | ||
// onrejected?: (value: T extends PromiseLike<any> ? any : never) => any | ||
// ): any; | ||
declare function __sveltets_1_each<T extends ArrayLike<unknown>>( | ||
array: T, | ||
callbackfn: (value: T extends ArrayLike<infer U> ? U : any, index: number) => any | ||
): any; | ||
// declare function __sveltets_1_each<T extends ArrayLike<unknown>>( | ||
// array: T, | ||
// callbackfn: (value: T extends ArrayLike<infer U> ? U : any, index: number) => any | ||
// ): any; | ||
declare function __sveltets_1_createSvelte2TsxComponent<Props, Events, Slots>( | ||
declare function __sveltets_2_createSvelte2TsxComponent<Props, Events, Slots>( | ||
render: {props: Props, events: Events, slots: Slots } | ||
): SvelteComponentConstructor<_SvelteComponent<Props, Events, Slots>,Svelte2TsxComponentConstructorParameters<Props>>; | ||
): SvelteComponentConstructor<import("svelte").SvelteComponentTyped<Props, Events, Slots>,Svelte2TsxComponentConstructorParameters<Props>>; | ||
declare function __sveltets_1_unwrapArr<T>(arr: ArrayLike<T>): T | ||
declare function __sveltets_1_unwrapPromiseLike<T>(promise: PromiseLike<T> | T): T | ||
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>): _SvelteComponent<any, any, any>; | ||
declare function __sveltets_2_createComponentAny(props: Record<string, any>): import("svelte").SvelteComponentTyped<any, any, any>; | ||
@@ -249,2 +270,3 @@ declare function __sveltets_2_any(...dummy: any[]): any; | ||
/** @internal PRIVATE API, DO NOT USE */ | ||
type __sveltets_2_SvelteAnimationReturnType = { | ||
@@ -260,2 +282,3 @@ delay?: number, | ||
/** @internal PRIVATE API, DO NOT USE */ | ||
type __sveltets_2_SvelteActionReturnType = { | ||
@@ -268,2 +291,3 @@ update?: (args: any) => void, | ||
/** @internal PRIVATE API, DO NOT USE */ | ||
type __sveltets_2_SvelteTransitionConfig = { | ||
@@ -276,2 +300,3 @@ delay?: number, | ||
} | ||
/** @internal PRIVATE API, DO NOT USE */ | ||
type __sveltets_2_SvelteTransitionReturnType = __sveltets_2_SvelteTransitionConfig | (() => __sveltets_2_SvelteTransitionConfig) | ||
@@ -278,0 +303,0 @@ declare function __sveltets_2_ensureTransition(transitionCall: __sveltets_2_SvelteTransitionReturnType): {}; |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
676892
9
16441