From 4997db4675436e066848d4cfd5d57347acb2b8a3 Mon Sep 17 00:00:00 2001 From: Naomi Carrigan Date: Sat, 22 Nov 2025 18:47:22 -0800 Subject: [PATCH] feat: add a type challenge --- package.json | 1 + pnpm-lock.yaml | 8 ++++++ src/type-challenges/0013-hello-world/main.ts | 28 ++++++++++++++++++++ src/type-challenges/README.md | 7 +++++ 4 files changed, 44 insertions(+) create mode 100644 src/type-challenges/0013-hello-world/main.ts create mode 100644 src/type-challenges/README.md diff --git a/package.json b/package.json index fa72098..02efb23 100644 --- a/package.json +++ b/package.json @@ -17,6 +17,7 @@ "devDependencies": { "@nhcarrigan/eslint-config": "5.2.0", "@nhcarrigan/typescript-config": "4.0.0", + "@type-challenges/utils": "0.1.1", "@types/node": "24.10.1", "@vitest/coverage-v8": "4.0.10", "eslint": "9.39.1", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index f3ebef5..0c3e01e 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -14,6 +14,9 @@ importers: '@nhcarrigan/typescript-config': specifier: 4.0.0 version: 4.0.0(typescript@5.9.3) + '@type-challenges/utils': + specifier: 0.1.1 + version: 0.1.1 '@types/node': specifier: 24.10.1 version: 24.10.1 @@ -461,6 +464,9 @@ packages: peerDependencies: eslint: '>=8.40.0' + '@type-challenges/utils@0.1.1': + resolution: {integrity: sha512-A7ljYfBM+FLw+NDyuYvGBJiCEV9c0lPWEAdzfOAkb3JFqfLl0Iv/WhWMMARHiRKlmmiD1g8gz/507yVvHdQUYA==} + '@types/chai@5.2.3': resolution: {integrity: sha512-Mw558oeA9fFbv65/y4mHtXDs9bPnFMZAL/jxdPFUpOHHIXX91mcgEHbS5Lahr+pwZFR8A7GQleRWeI6cGFC2UA==} @@ -2350,6 +2356,8 @@ snapshots: - supports-color - typescript + '@type-challenges/utils@0.1.1': {} + '@types/chai@5.2.3': dependencies: '@types/deep-eql': 4.0.2 diff --git a/src/type-challenges/0013-hello-world/main.ts b/src/type-challenges/0013-hello-world/main.ts new file mode 100644 index 0000000..8ec360e --- /dev/null +++ b/src/type-challenges/0013-hello-world/main.ts @@ -0,0 +1,28 @@ +/** + * @copyright NHCarrigan + * @license Naomi's Public License + * @author Naomi Carrigan + */ + +import type { Equal, Expect, NotAny } from "@type-challenges/utils"; + +/** + * Original code:. + * + * ```ts + * type HelloWorld = any // expected to be a string + * ``` + */ + +type HelloWorld = string; + +/** + * Test cases. + */ + +// @ts-expect-error -- Unused variable. +// eslint-disable-next-line @typescript-eslint/no-unused-vars -- This is necessary for tests. +type Cases = [ + Expect>, + Expect>, +]; diff --git a/src/type-challenges/README.md b/src/type-challenges/README.md new file mode 100644 index 0000000..399d42c --- /dev/null +++ b/src/type-challenges/README.md @@ -0,0 +1,7 @@ +# Type Challenges + +These are a little different. They aren't algorithms with return values. Instead, you're given some broken TypeScript code and you must fix it so it compiles. + +As such, these challenges do not have tests in the same way others do. They are considered "passing" when the build command succeeds. + +https://github.com/type-challenges/type-challenges \ No newline at end of file