Skip to content

Commit

Permalink
Add TODO tests on type-level access
Browse files Browse the repository at this point in the history
  • Loading branch information
SamChou19815 authored Dec 11, 2024
1 parent c8472bb commit 6db254a
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 1 deletion.
3 changes: 3 additions & 0 deletions tests/no_unchecked_indexed_access/arr_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,6 @@ tuple[1] as 1;
tuple[2] as 2;
tuple[3] as number; // error: out of bound
tuple[key] as number; // error: void ~> number

declare const typeTest: (typeof roArray)[number];
typeTest as string; // todo: the flag should not affect type-level acccess
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,23 @@ References:
^^^^^^ [2]


Error ------------------------------------------------------------------------------------------------- arr_test.js:17:1

Cannot cast `typeTest` to string because undefined [1] is incompatible with string [2]. [incompatible-cast]

arr_test.js:17:1
17| typeTest as string; // todo: the flag should not affect type-level acccess
^^^^^^^^

References:
arr_test.js:3:39
3| declare const roArray: $ReadOnlyArray<string>;
^^^^^^ [1]
arr_test.js:17:13
17| typeTest as string; // todo: the flag should not affect type-level acccess
^^^^^^ [2]


Error ------------------------------------------------------------------------------------------------- obj_test.js:5:11

Cannot access object with computed property using string [1]. [invalid-computed-prop]
Expand Down Expand Up @@ -145,5 +162,22 @@ References:
^^^^^^ [2]


Error ------------------------------------------------------------------------------------------------- obj_test.js:10:1

Cannot cast `typeTest` to string because undefined [1] is incompatible with string [2]. [incompatible-cast]

obj_test.js:10:1
10| typeTest as string; // todo: the flag should not affect type-level acccess
^^^^^^^^

References:
obj_test.js:2:35
2| declare const dictObj: {[string]: string};
^^^^^^ [1]
obj_test.js:10:13
10| typeTest as string; // todo: the flag should not affect type-level acccess
^^^^^^ [2]



Found 9 errors
Found 11 errors
3 changes: 3 additions & 0 deletions tests/no_unchecked_indexed_access/obj_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,6 @@ declare const key: string;
recordObj[key] as string; // error: bad key
dictObj[key] as string; // error: void ~> string
dictObj.hahaha as string; // error: void ~> string

declare const typeTest: (typeof dictObj)[string];
typeTest as string; // todo: the flag should not affect type-level acccess

0 comments on commit 6db254a

Please sign in to comment.