Commit 4fe9151
authored
fix(parser): Handle
Current behavior:
```ts
type G<T> = T;
type C1 = G<?>; // Parse failed 👀
```
TS parses this as `TypeReference > JSDocUnknownType`.
> REPL:
https://www.typescriptlang.org/play/?noCheck=true#code/C4TwDgpgBA4gPAFQHxQLxQQbgFCklAYQEY1Y4B+JTIA
> Parser:
https://github.com/microsoft/TypeScript/blob/83dc0bb2ed91fe0815ab28dc3ff95fae7425e413/src/compiler/parser.ts#L3847
And also this PR fixes these:
```ts
type X = [
1?, // TSOptionalType
?1, // JSDocUnknownType 👀
?1?, // JSDocUnknownType 👀
?1!, // JSDocUnknownType 👀
];
```
to
```ts
type X = [
1?, // TSOptionalType
?1, // JSDocNullableType
?1?, // JSDocNullableType > JSDocNullableType
?1!, // JSDocNullableType > JSDocNonNullableType
];
```
This will result in the same behavior as TS and ESLint-TS.JSDocUnknownType correctly (#10363)1 parent cc18238 commit 4fe9151
File tree
3 files changed
+38
-21
lines changed- crates/oxc_parser/src/ts
- tasks/coverage/snapshots
3 files changed
+38
-21
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1318 | 1318 | | |
1319 | 1319 | | |
1320 | 1320 | | |
1321 | | - | |
1322 | | - | |
1323 | 1321 | | |
1324 | 1322 | | |
1325 | 1323 | | |
1326 | 1324 | | |
1327 | | - | |
1328 | | - | |
1329 | | - | |
1330 | | - | |
1331 | | - | |
1332 | | - | |
1333 | | - | |
| 1325 | + | |
1334 | 1326 | | |
| 1327 | + | |
| 1328 | + | |
| 1329 | + | |
| 1330 | + | |
| 1331 | + | |
| 1332 | + | |
1335 | 1333 | | |
1336 | 1334 | | |
1337 | 1335 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
4 | | - | |
| 4 | + | |
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
| |||
495 | 495 | | |
496 | 496 | | |
497 | 497 | | |
498 | | - | |
499 | | - | |
| 498 | + | |
500 | 499 | | |
501 | 500 | | |
502 | 501 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
6 | | - | |
| 6 | + | |
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
| |||
815 | 815 | | |
816 | 816 | | |
817 | 817 | | |
| 818 | + | |
818 | 819 | | |
819 | 820 | | |
820 | 821 | | |
| |||
8107 | 8108 | | |
8108 | 8109 | | |
8109 | 8110 | | |
8110 | | - | |
8111 | | - | |
8112 | | - | |
8113 | | - | |
8114 | | - | |
8115 | | - | |
8116 | | - | |
8117 | | - | |
8118 | 8111 | | |
8119 | 8112 | | |
8120 | 8113 | | |
| |||
10851 | 10844 | | |
10852 | 10845 | | |
10853 | 10846 | | |
| 10847 | + | |
| 10848 | + | |
| 10849 | + | |
| 10850 | + | |
| 10851 | + | |
| 10852 | + | |
| 10853 | + | |
| 10854 | + | |
| 10855 | + | |
| 10856 | + | |
| 10857 | + | |
| 10858 | + | |
| 10859 | + | |
| 10860 | + | |
| 10861 | + | |
| 10862 | + | |
| 10863 | + | |
| 10864 | + | |
10854 | 10865 | | |
10855 | 10866 | | |
10856 | 10867 | | |
| |||
10869 | 10880 | | |
10870 | 10881 | | |
10871 | 10882 | | |
| 10883 | + | |
| 10884 | + | |
| 10885 | + | |
| 10886 | + | |
| 10887 | + | |
| 10888 | + | |
| 10889 | + | |
| 10890 | + | |
| 10891 | + | |
10872 | 10892 | | |
10873 | 10893 | | |
10874 | 10894 | | |
| |||
0 commit comments