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
14 changes: 8 additions & 6 deletions packages/svelte2tsx/src/svelte2tsx/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -401,12 +401,14 @@ declare function __sveltets_1_createSvelteComponentTyped<Props, Events, Slots>(
);
let code = str.toString();
// Remove all tsx occurences and the template part from the output
code =
code
.substr(0, code.indexOf('\n() => (<>'))
// prepended before each script block
.replace('<></>;', '')
.replace('<></>;', '') + code.substr(code.lastIndexOf('</>);') + '</>);'.length);
code = code
// prepended before each script block
.replace('<></>;', '')
.replace('<></>;', '')
// tsx in render function
.replace(/<>.*<\/>/s, '')
.replace('\n() => ();', '');

return {
code
};
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/** @typedef {typeof __propDef.props} TestNoScriptProps */
/** @typedef {typeof __propDef.events} TestNoScriptEvents */
/** @typedef {typeof __propDef.slots} TestNoScriptSlots */
export default class TestNoScript extends SvelteComponentTyped<{}, {
click: MouseEvent;
} & {
[evt: string]: CustomEvent<any>;
}, {
default: {};
}> {
}
export type TestNoScriptProps = typeof __propDef.props;
export type TestNoScriptEvents = typeof __propDef.events;
export type TestNoScriptSlots = typeof __propDef.slots;
import { SvelteComponentTyped } from "svelte";
declare const __propDef: {
props: {};
events: {
click: MouseEvent;
} & {
[evt: string]: CustomEvent<any>;
};
slots: {
default: {};
};
};
export {};
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<div on:click>
<slot />
</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { SvelteComponentTyped } from "svelte"

declare function __sveltets_1_createSvelteComponentTyped<Props, Events, Slots>(
render: {props: Props, events: Events, slots: Slots }
): SvelteComponentConstructor<SvelteComponentTyped<Props, Events, Slots>,Svelte2TsxComponentConstructorParameters<Props>>;

function render() {

return { props: {}, slots: {'default': {}}, getters: {}, events: {'click':__sveltets_1_mapElementEvent('click')} }}
const __propDef = __sveltets_1_partial(__sveltets_1_with_any_event(render()));
/** @typedef {typeof __propDef.props} InputProps */
/** @typedef {typeof __propDef.events} InputEvents */
/** @typedef {typeof __propDef.slots} InputSlots */

export default class Input extends __sveltets_1_createSvelteComponentTyped(__sveltets_1_partial(__sveltets_1_with_any_event(render()))) {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<button on:click><slot /></button>
{#await Promise.resolve(0) then n}
{n}
{/await}