Commit c9879fb
authored
fix: restore typescript 5.6 compatibility (#301)
This PR restores compatibility with TypeScript 5.6. It also updates the
test suite to be more resilient and explicitly tests against TypeScript
5.5 and 5.6.
I was surprised that TypeScript would break this without releasing a
major version. However, if you look at the `getOriginalSourceFile`
method we were using, it was marked as `@internal` in the JSDoc:
https://github.com/microsoft/TypeScript/blob/c8a7d589e647e19c94150d9892909f3aa93e48eb/src/compiler/utilities.ts#L5416-L5419
Because it was marked as internal, they probably reserved the right to
remove this method without a breaking version bump. The other PR to fix
this issue (#270) suggested using `getSourceFileOfNode`, but that's also
marked as `@internal`:
https://github.com/microsoft/TypeScript/blob/11b2930fa2c9f73b0ffb725a9715b8d3c4121bbc/src/compiler/utilities.ts#L965-L975.
Therefore, instead, I updated this code to use `getParseTreeNode` and
`isSourceFile`, which are both exposed publicly and not marked as
`internal`:
https://github.com/microsoft/TypeScript/blob/11b2930fa2c9f73b0ffb725a9715b8d3c4121bbc/src/compiler/utilitiesPublic.ts#L803-L809
/
https://github.com/microsoft/TypeScript/blob/11b2930fa2c9f73b0ffb725a9715b8d3c4121bbc/src/compiler/factory/nodeTests.ts#L1013-L1016
By using these methods, we should be more resilient to internal
refactoring.
This PR supersedes #270.
Fixes #2661 parent a7276d0 commit c9879fb
File tree
6 files changed
+45
-19
lines changed- src
- test
- tests
6 files changed
+45
-19
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
135 | 135 | | |
136 | 136 | | |
137 | 137 | | |
138 | | - | |
| 138 | + | |
139 | 139 | | |
140 | 140 | | |
141 | 141 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
| 4 | + | |
| 5 | + | |
4 | 6 | | |
5 | 7 | | |
6 | 8 | | |
7 | 9 | | |
8 | 10 | | |
| 11 | + | |
| 12 | + | |
9 | 13 | | |
10 | 14 | | |
11 | 15 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
24 | | - | |
| 24 | + | |
25 | 25 | | |
26 | 26 | | |
| 27 | + | |
| 28 | + | |
27 | 29 | | |
28 | 30 | | |
29 | 31 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
| 33 | + | |
| 34 | + | |
33 | 35 | | |
34 | 36 | | |
35 | 37 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
34 | 34 | | |
35 | 35 | | |
36 | 36 | | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
37 | 43 | | |
38 | 44 | | |
39 | | - | |
| 45 | + | |
40 | 46 | | |
41 | 47 | | |
42 | 48 | | |
43 | 49 | | |
44 | | - | |
| 50 | + | |
45 | 51 | | |
46 | 52 | | |
47 | 53 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8069 | 8069 | | |
8070 | 8070 | | |
8071 | 8071 | | |
8072 | | - | |
| 8072 | + | |
8073 | 8073 | | |
8074 | 8074 | | |
| 8075 | + | |
| 8076 | + | |
8075 | 8077 | | |
8076 | 8078 | | |
8077 | 8079 | | |
| |||
9230 | 9232 | | |
9231 | 9233 | | |
9232 | 9234 | | |
| 9235 | + | |
| 9236 | + | |
| 9237 | + | |
| 9238 | + | |
| 9239 | + | |
| 9240 | + | |
| 9241 | + | |
| 9242 | + | |
| 9243 | + | |
| 9244 | + | |
| 9245 | + | |
| 9246 | + | |
| 9247 | + | |
| 9248 | + | |
| 9249 | + | |
| 9250 | + | |
| 9251 | + | |
| 9252 | + | |
| 9253 | + | |
| 9254 | + | |
9233 | 9255 | | |
9234 | 9256 | | |
9235 | 9257 | | |
| |||
9240 | 9262 | | |
9241 | 9263 | | |
9242 | 9264 | | |
9243 | | - | |
9244 | | - | |
9245 | | - | |
9246 | | - | |
9247 | | - | |
9248 | | - | |
9249 | | - | |
9250 | | - | |
9251 | | - | |
9252 | | - | |
9253 | | - | |
9254 | | - | |
9255 | | - | |
| 9265 | + | |
| 9266 | + | |
| 9267 | + | |
9256 | 9268 | | |
9257 | 9269 | | |
9258 | 9270 | | |
9259 | | - | |
| 9271 | + | |
9260 | 9272 | | |
9261 | 9273 | | |
9262 | 9274 | | |
| |||
0 commit comments