Skip to content

Commit 7a4fe50

Browse files
committed
Added overriding example
1 parent caa1df0 commit 7a4fe50

File tree

5 files changed

+48
-2
lines changed

5 files changed

+48
-2
lines changed
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
declare module "fake-animation-lib-solution" {
2+
export function getAnimatingState():
3+
| "before-animation"
4+
| "animating"
5+
| "after-animation";
6+
}
Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1-
// TODO
1+
import { getAnimatingState } from "../fake-animation-lib";
2+
import { Equal, Expect } from "../helpers/type-utils";
23

3-
export {};
4+
const animatingState = getAnimatingState();
5+
6+
type tests = [
7+
Expect<
8+
Equal<
9+
typeof animatingState,
10+
"before-animation" | "animating" | "after-animation"
11+
>
12+
>,
13+
];
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { getAnimatingState } from "fake-animation-lib-solution";
2+
import { Equal, Expect } from "../helpers/type-utils";
3+
4+
const animatingState = getAnimatingState();
5+
6+
type tests = [
7+
Expect<
8+
Equal<
9+
typeof animatingState,
10+
"before-animation" | "animating" | "after-animation"
11+
>
12+
>,
13+
];

src/fake-animation-lib/index.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
export const getAnimatingState = (): string => {
2+
if (Math.random() > 0.5) {
3+
return "before-animation";
4+
}
5+
6+
if (Math.random() > 0.5) {
7+
return "animating";
8+
}
9+
10+
return "after-animation";
11+
};

tsconfig.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,12 @@
3333
"paths": {
3434
"fake-external-lib": [
3535
"./src/fake-external-lib/index"
36+
],
37+
"fake-animation-lib": [
38+
"./src/fake-animation-lib/index"
39+
],
40+
"fake-animation-lib-solution": [
41+
"./src/fake-animation-lib/index"
3642
]
3743
}, /* Specify a set of entries that re-map imports to additional lookup locations. */
3844
// "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */

0 commit comments

Comments
 (0)