Skip to content

Commit 2626f18

Browse files
Update typescript to 4.8 (#14880)
* remove @babel/parser tsconfig * update typescript to 4.8 * Fix new typing errors * test * Update packages/babel-traverse/src/path/index.ts Co-authored-by: liuxingbaoyu <30521560+liuxingbaoyu@users.noreply.github.com> Co-authored-by: liuxingbaoyu <30521560+liuxingbaoyu@users.noreply.github.com>
1 parent 6c5ebd1 commit 2626f18

6 files changed

Lines changed: 22 additions & 19 deletions

File tree

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@
7272
"shelljs": "^0.8.5",
7373
"test262-stream": "^1.4.0",
7474
"through2": "^4.0.0",
75-
"typescript": "~4.7.4"
75+
"typescript": "~4.8.2"
7676
},
7777
"workspaces": [
7878
"codemods/*",

packages/babel-core/src/config/caching.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -395,6 +395,8 @@ export function assertSimpleType(value: unknown): SimpleType {
395395
"Cache keys must be either string, boolean, number, null, or undefined.",
396396
);
397397
}
398+
// @ts-expect-error Type 'unknown' is not assignable to type 'SimpleType'. This can be removed
399+
// when strictNullCheck is enabled
398400
return value;
399401
}
400402

packages/babel-core/src/config/helpers/deep-array.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@ export function finalize<T>(deepArr: DeepArray<T>): ReadonlyDeepArray<T> {
1010
return Object.freeze(deepArr) as ReadonlyDeepArray<T>;
1111
}
1212

13-
export function flattenToSet<T>(arr: ReadonlyDeepArray<T>): Set<T> {
13+
export function flattenToSet<T extends string>(
14+
arr: ReadonlyDeepArray<T>,
15+
): Set<T> {
1416
const result = new Set<T>();
1517
const stack = [arr];
1618
while (stack.length > 0) {

packages/babel-parser/tsconfig.json

Lines changed: 0 additions & 7 deletions
This file was deleted.

packages/babel-traverse/src/path/index.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,13 @@ class NodePath<T extends t.Node = t.Node> {
109109
}
110110

111111
getScope(scope: Scope): Scope {
112-
return this.isScope() ? new Scope(this) : scope;
112+
// TODO: Remove this when TS is fixed.
113+
// A regression was introduced in ts4.8 that would cause OOM.
114+
// Avoid it by manually casting the types.
115+
// https://github.com/babel/babel/pull/14880
116+
return this.isScope()
117+
? new Scope(this as NodePath<t.Pattern | t.Scopable>)
118+
: scope;
113119
}
114120

115121
setData(key: string | symbol, val: any): any {

yarn.lock

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5961,7 +5961,7 @@ __metadata:
59615961
shelljs: ^0.8.5
59625962
test262-stream: ^1.4.0
59635963
through2: ^4.0.0
5964-
typescript: ~4.7.4
5964+
typescript: ~4.8.2
59655965
dependenciesMeta:
59665966
core-js:
59675967
built: false
@@ -14759,23 +14759,23 @@ fsevents@^1.2.7:
1475914759
languageName: node
1476014760
linkType: hard
1476114761

14762-
"typescript@npm:~4.7.4":
14763-
version: 4.7.4
14764-
resolution: "typescript@npm:4.7.4"
14762+
"typescript@npm:~4.8.2":
14763+
version: 4.8.2
14764+
resolution: "typescript@npm:4.8.2"
1476514765
bin:
1476614766
tsc: bin/tsc
1476714767
tsserver: bin/tsserver
14768-
checksum: 5750181b1cd7e6482c4195825547e70f944114fb47e58e4aa7553e62f11b3f3173766aef9c281783edfd881f7b8299cf35e3ca8caebe73d8464528c907a164df
14768+
checksum: 7f5b81d0d558c9067f952c7af52ab7f19c2e70a916817929e4a5b256c93990bf3178eccb1ac8a850bc75df35f6781b6f4cb3370ce20d8b1ded92ed462348f628
1476914769
languageName: node
1477014770
linkType: hard
1477114771

14772-
"typescript@patch:typescript@~4.7.4#~builtin<compat/typescript>":
14773-
version: 4.7.4
14774-
resolution: "typescript@patch:typescript@npm%3A4.7.4#~builtin<compat/typescript>::version=4.7.4&hash=493e53"
14772+
"typescript@patch:typescript@~4.8.2#~builtin<compat/typescript>":
14773+
version: 4.8.2
14774+
resolution: "typescript@patch:typescript@npm%3A4.8.2#~builtin<compat/typescript>::version=4.8.2&hash=493e53"
1477514775
bin:
1477614776
tsc: bin/tsc
1477714777
tsserver: bin/tsserver
14778-
checksum: 96d3030cb01143570567cb4f3a616b10df65f658f0e74e853e77a089a6a954e35c800be7db8b9bfe9a1ae05d9c2897e281359f65e4caa1caf266368e1c4febd3
14778+
checksum: 6f49363af8af2fe480da1d5fa68712644438785208b06690a3cbe5e7365fd652c3a0f1e587bc8684d78fb69de3dde4de185c0bad7bb4f3664ddfc813ce8caad6
1477914779
languageName: node
1478014780
linkType: hard
1478114781

0 commit comments

Comments
 (0)