diff --git a/questions/37398-hard-all-except-never/README.md b/questions/37398-hard-all-except-never/README.md new file mode 100644 index 00000000..0ede7cbe --- /dev/null +++ b/questions/37398-hard-all-except-never/README.md @@ -0,0 +1 @@ +Write function `myFunc` so that it can accept any argument type except type `never`. diff --git a/questions/37398-hard-all-except-never/info.yml b/questions/37398-hard-all-except-never/info.yml new file mode 100644 index 00000000..8f9c7fb8 --- /dev/null +++ b/questions/37398-hard-all-except-never/info.yml @@ -0,0 +1,6 @@ +difficulty: hard +title: All Except Never +author: + github: alexandroppolus + name: Alexandroppolus + diff --git a/questions/37398-hard-all-except-never/template.ts b/questions/37398-hard-all-except-never/template.ts new file mode 100644 index 00000000..a3b3f9a6 --- /dev/null +++ b/questions/37398-hard-all-except-never/template.ts @@ -0,0 +1,3 @@ +function myFunc(x: any) { + console.log(x); +} diff --git a/questions/37398-hard-all-except-never/test-cases.ts b/questions/37398-hard-all-except-never/test-cases.ts new file mode 100644 index 00000000..5175b945 --- /dev/null +++ b/questions/37398-hard-all-except-never/test-cases.ts @@ -0,0 +1,26 @@ +declare const x0: never; +declare const x1: void; +declare const x2: unknown; +declare const x3: never[]; +declare const x4: 1 | 2 | 3n; +declare const x5: string; +declare const x6: boolean | number; +declare const x7: undefined | {a: 123} | VoidFunction; +declare const x8: string[]; +declare const x9: {} | []; +declare const x10: any; + + +// @ts-expect-error +myFunc(x0); + +myFunc(x1); +myFunc(x2); +myFunc(x3); +myFunc(x4); +myFunc(x5); +myFunc(x6); +myFunc(x7); +myFunc(x8); +myFunc(x9); +myFunc(x10);