update type tests

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

@ -6,7 +6,8 @@ import {
type ComponentType,
mount,
hydrate,
type Component
type Component,
type ComponentInternals
} from 'svelte';
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)
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 } });

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

Loading…
Cancel
Save