Skip to content

Commit

Permalink
Fixed 06-index-signatures
Browse files Browse the repository at this point in the history
  • Loading branch information
mattpocock committed Jul 30, 2024
1 parent 32437f8 commit 328d4b8
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 36 deletions.
3 changes: 2 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

42 changes: 20 additions & 22 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
},
Expand All @@ -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",
Expand Down Expand Up @@ -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",
Expand All @@ -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",
Expand Down
16 changes: 10 additions & 6 deletions src/01-branded-types/06-index-signatures.problem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<Equal<typeof post, Post>>,
Expect<Equal<typeof user, User>>,
];
type tests = [
Expect<Equal<typeof post, Post>>,
Expect<Equal<typeof user, User>>,
];
};
});

it("Should fail if you try to add a user under a post id", () => {
Expand Down
16 changes: 9 additions & 7 deletions src/01-branded-types/06-index-signatures.solution.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<Equal<typeof post, Post>>,
Expect<Equal<typeof user, User>>,
];
const test = () => {
const post = db[postId];
const user = db[userId];

type tests = [
Expect<Equal<typeof post, Post>>,
Expect<Equal<typeof user, User>>,
];
};
});

it("Should fail if you try to add a user under a post id", () => {
Expand Down

0 comments on commit 328d4b8

Please sign in to comment.