update type tests

pull/12507/head
Rich Harris 2 years ago
parent 38e8fb680a
commit 3ebc8bd822

@ -6,7 +6,8 @@ import {
type ComponentType, type ComponentType,
mount, mount,
hydrate, hydrate,
type Component type Component,
type ComponentInternals
} from 'svelte'; } from 'svelte';
import { render } from 'svelte/server'; import { render } from 'svelte/server';
@ -338,5 +339,5 @@ render(functionComponent, {
// but should always pass in tsc (because it will never know about this fact) // but should always pass in tsc (because it will never know about this fact)
import Foo from './doesntexist.svelte'; import Foo from './doesntexist.svelte';
Foo(null, { a: true }); Foo(null as unknown as ComponentInternals, { a: true });
const f: Foo = new Foo({ target: document.body, props: { a: true } }); const f: Foo = new Foo({ target: document.body, props: { a: true } });

@ -1,40 +1,25 @@
import type { Snippet } from 'svelte'; import type { Snippet } from 'svelte';
const return_type: ReturnType<Snippet> = null as any;
// @ts-expect-error // @ts-expect-error
const a: Snippet<{ text: string }> = () => {}; const a: Snippet<{ text: string }> = () => {};
// @ts-expect-error // @ts-expect-error
const b: Snippet<boolean> = (a, b) => { const b: Snippet<boolean> = (a, b) => {};
return return_type;
};
// @ts-expect-error
const c: Snippet<boolean> = (a: string) => {
return return_type;
};
// @ts-expect-error // @ts-expect-error
const d: Snippet<boolean> = (a: string, b: number) => { const c: Snippet<boolean> = (a: string) => {};
return return_type;
};
// @ts-expect-error // @ts-expect-error
const e: Snippet = (a: string) => { const d: Snippet<boolean> = (a: string, b: number) => {};
return return_type;
};
// @ts-expect-error // @ts-expect-error
const e: Snippet = (a: string) => {};
const f: Snippet = (a) => { const f: Snippet = (a) => {
// @ts-expect-error
a?.x; a?.x;
return return_type;
}; };
const g: Snippet<[boolean]> = (a) => { const g: Snippet<[boolean]> = (internals, a) => {
// @ts-expect-error // @ts-expect-error
a === ''; a() === '';
a === true; a() === true;
return return_type;
};
const h: Snippet<[{ a: true }]> = (a) => {
a.a === true;
return return_type;
}; };
const i: Snippet = () => { const h: Snippet<[{ a: true }]> = (internals, a) => {
return return_type; a().a === true;
}; };
const i: Snippet = () => {};

Loading…
Cancel
Save