mirror of https://github.com/sveltejs/svelte
feat: add Snippet type (#9584)
* feat: add Snippet type related to #9447 * one more testpull/9587/head
parent
da15806136
commit
1003acccc4
@ -0,0 +1,5 @@
|
||||
---
|
||||
'svelte': patch
|
||||
---
|
||||
|
||||
feat: add Snippet type
|
@ -0,0 +1,3 @@
|
||||
// Silence the acorn typescript errors through this ambient type definition + tsconfig.json path alias
|
||||
// That way we can omit `"skipLibCheck": true` and catch other errors in our d.ts files
|
||||
declare module 'acorn-typescript';
|
@ -0,0 +1,40 @@
|
||||
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;
|
||||
};
|
||||
// @ts-expect-error
|
||||
const d: Snippet<boolean> = (a: string, b: number) => {
|
||||
return return_type;
|
||||
};
|
||||
// @ts-expect-error
|
||||
const e: Snippet = (a: string) => {
|
||||
return return_type;
|
||||
};
|
||||
const f: Snippet = (a) => {
|
||||
// @ts-expect-error
|
||||
a?.x;
|
||||
return return_type;
|
||||
};
|
||||
const g: Snippet<boolean> = (a) => {
|
||||
// @ts-expect-error
|
||||
a === '';
|
||||
a === true;
|
||||
return return_type;
|
||||
};
|
||||
const h: Snippet<{ a: true }> = (a) => {
|
||||
a.a === true;
|
||||
return return_type;
|
||||
};
|
||||
const i: Snippet = () => {
|
||||
return return_type;
|
||||
};
|
Loading…
Reference in new issue