From 328d4b8765e9636a492cdca27037b139212c2f77 Mon Sep 17 00:00:00 2001 From: Matt Pocock Date: Tue, 30 Jul 2024 11:34:02 +0100 Subject: [PATCH] Fixed 06-index-signatures --- package-lock.json | 3 +- package.json | 42 +++++++++---------- .../06-index-signatures.problem.ts | 16 ++++--- .../06-index-signatures.solution.ts | 16 +++---- 4 files changed, 41 insertions(+), 36 deletions(-) diff --git a/package-lock.json b/package-lock.json index 9592c9a..4d102c6 100644 --- a/package-lock.json +++ b/package-lock.json @@ -24,7 +24,7 @@ "cross-fetch": "^3.1.5", "jsdom": "^21.1.1", "prettier": "^2.8.7", - "typescript": "^5.4.5", + "typescript": "5.4.5", "vite-tsconfig-paths": "^4.0.7", "vitest": "^1.6.0" } @@ -2962,6 +2962,7 @@ "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.4.5.tgz", "integrity": "sha512-vcI4UpRgg81oIRUFwR0WSIHKt11nJ7SAVlYNIu+QpqeyXP+gpQJy/Z4+F0aGxSE4MqwjyXvW/TzgkLAx2AGHwQ==", "dev": true, + "license": "Apache-2.0", "bin": { "tsc": "bin/tsc", "tsserver": "bin/tsserver" diff --git a/package.json b/package.json index 2d85193..dae97ec 100644 --- a/package.json +++ b/package.json @@ -10,7 +10,7 @@ "cross-fetch": "^3.1.5", "jsdom": "^21.1.1", "prettier": "^2.8.7", - "typescript": "^5.4.5", + "typescript": "5.4.5", "vite-tsconfig-paths": "^4.0.7", "vitest": "^1.6.0" }, @@ -22,6 +22,10 @@ "ci": "(cd scripts/tests && npx vitest run)", "prepare": "tt-cli prepare-stackblitz", "update-snapshots": "(cd scripts/tests && npx vitest run -u)", + "e-00": "tt-cli run 00", + "s-00": "tt-cli run 00 --solution", + "e-01": "tt-cli run 01", + "s-01": "tt-cli run 01 --solution", "e-02": "tt-cli run 02", "s-02": "tt-cli run 02 --solution", "e-03": "tt-cli run 03", @@ -58,18 +62,32 @@ "s-18": "tt-cli run 18 --solution", "e-18.2": "tt-cli run 18.2", "s-18.2": "tt-cli run 18.2 --solution", + "e-19.3": "tt-cli run 19.3", + "s-19.3": "tt-cli run 19.3 --solution", + "e-19.4": "tt-cli run 19.4", + "s-19.4": "tt-cli run 19.4 --solution", "e-20": "tt-cli run 20", "s-20": "tt-cli run 20 --solution", "e-21": "tt-cli run 21", "s-21": "tt-cli run 21 --solution", "e-22": "tt-cli run 22", "s-22": "tt-cli run 22 --solution", + "e-22.5": "tt-cli run 22.5", + "s-22.5": "tt-cli run 22.5 --solution", + "e-22.9": "tt-cli run 22.9", + "s-22.9": "tt-cli run 22.9 --solution", "e-23": "tt-cli run 23", "s-23": "tt-cli run 23 --solution", + "e-23.9": "tt-cli run 23.9", + "s-23.9": "tt-cli run 23.9 --solution", "e-24": "tt-cli run 24", "s-24": "tt-cli run 24 --solution", + "e-24.9": "tt-cli run 24.9", + "s-24.9": "tt-cli run 24.9 --solution", "e-25": "tt-cli run 25", "s-25": "tt-cli run 25 --solution", + "e-25.9": "tt-cli run 25.9", + "s-25.9": "tt-cli run 25.9 --solution", "e-26": "tt-cli run 26", "s-26": "tt-cli run 26 --solution", "e-26.5": "tt-cli run 26.5", @@ -93,27 +111,7 @@ "e-34": "tt-cli run 34", "s-34": "tt-cli run 34 --solution", "e-38": "tt-cli run 38", - "s-38": "tt-cli run 38 --solution", - "e-00": "tt-cli run 00", - "s-00": "tt-cli run 00 --solution", - "e-01": "tt-cli run 01", - "s-01": "tt-cli run 01 --solution", - "e-22.9": "tt-cli run 22.9", - "s-22.9": "tt-cli run 22.9 --solution", - "e-23.9": "tt-cli run 23.9", - "s-23.9": "tt-cli run 23.9 --solution", - "e-24.9": "tt-cli run 24.9", - "s-24.9": "tt-cli run 24.9 --solution", - "e-25.9": "tt-cli run 25.9", - "s-25.9": "tt-cli run 25.9 --solution", - "e-19.3": "tt-cli run 19.3", - "s-19.3": "tt-cli run 19.3 --solution", - "e-19.4": "tt-cli run 19.4", - "s-19.4": "tt-cli run 19.4 --solution", - "e-22.5": "tt-cli run 22.5", - "s-22.5": "tt-cli run 22.5 --solution", - "e-30.6": "tt-cli run 30.6", - "s-30.6": "tt-cli run 30.6 --solution" + "s-38": "tt-cli run 38 --solution" }, "dependencies": { "@types/express": "^4.17.14", diff --git a/src/01-branded-types/06-index-signatures.problem.ts b/src/01-branded-types/06-index-signatures.problem.ts index 02fd3e6..524dd97 100644 --- a/src/01-branded-types/06-index-signatures.problem.ts +++ b/src/01-branded-types/06-index-signatures.problem.ts @@ -38,13 +38,17 @@ it("Should let you add users and posts to the db by their id", () => { name: "Miles", }; - const post = db[postId]; - const user = db[userId]; + const test = () => { + // Code slightly updated since video was recorded, see + // https://gist.github.com/mattpocock/ac5bc4eabcb95c05d5d106ccb73c84cc + const post = db[postId]; + const user = db[userId]; - type tests = [ - Expect>, - Expect>, - ]; + type tests = [ + Expect>, + Expect>, + ]; + }; }); it("Should fail if you try to add a user under a post id", () => { diff --git a/src/01-branded-types/06-index-signatures.solution.ts b/src/01-branded-types/06-index-signatures.solution.ts index 1492a29..7b78f4a 100644 --- a/src/01-branded-types/06-index-signatures.solution.ts +++ b/src/01-branded-types/06-index-signatures.solution.ts @@ -34,13 +34,15 @@ it("Should let you add users and posts to the db by their id", () => { name: "Miles", }; - const post = db[postId]; - const user = db[userId]; - - type tests = [ - Expect>, - Expect>, - ]; + const test = () => { + const post = db[postId]; + const user = db[userId]; + + type tests = [ + Expect>, + Expect>, + ]; + }; }); it("Should fail if you try to add a user under a post id", () => {