From 5fde28b37ede5d6a1f0d9186348ef2aee9369b7b Mon Sep 17 00:00:00 2001 From: liuxingbaoyu <30521560+liuxingbaoyu@users.noreply.github.com> Date: Sat, 12 Nov 2022 02:34:25 +0800 Subject: [PATCH] fix: Babel 8 types (#15109) * test * fix babel8 types * ignore * fix constraints * order * fix --- constraints.pro | 1 + packages/babel-parser/package.json | 4 +++- packages/babel-types/package.json | 6 +++++- scripts/integration-tests/e2e-prettier.sh | 3 +++ 4 files changed, 12 insertions(+), 2 deletions(-) diff --git a/constraints.pro b/constraints.pro index 9a5b3650a0ab..36b864b27eca 100644 --- a/constraints.pro +++ b/constraints.pro @@ -85,6 +85,7 @@ gen_enforced_field(WorkspaceCwd, 'exports', '{ ".": "./lib/index.js", "./package WorkspaceIdent \= '@babel/parser', WorkspaceIdent \= '@babel/plugin-transform-react-jsx', % TODO: Remove in Babel 8 WorkspaceIdent \= '@babel/standalone', + WorkspaceIdent \= '@babel/types', % @babel/types has types exports \+ atom_concat('@babel/eslint-', _, WorkspaceIdent), \+ atom_concat('@babel/runtime', _, WorkspaceIdent). diff --git a/packages/babel-parser/package.json b/packages/babel-parser/package.json index 3ad71d041ac9..2d954d6c21e4 100644 --- a/packages/babel-parser/package.json +++ b/packages/babel-parser/package.json @@ -27,7 +27,7 @@ "files": [ "bin", "lib", - "typings", + "typings/babel-parser.d.ts", "index.cjs" ], "engines": { @@ -54,6 +54,7 @@ "type": "module", "exports": { ".": { + "types": "./typings/babel-parser.d.ts", "require": "./lib/index.cjs", "default": "./lib/index.js" }, @@ -65,6 +66,7 @@ }, "exports": { ".": { + "types": "./typings/babel-parser.d.ts", "require": "./index.cjs", "default": "./lib/index.js" }, diff --git a/packages/babel-types/package.json b/packages/babel-types/package.json index 61c02de66f5f..191f21cb290b 100644 --- a/packages/babel-types/package.json +++ b/packages/babel-types/package.json @@ -52,7 +52,11 @@ ] }, "exports": { - ".": "./lib/index.js", + ".": { + "types@>=3.7": "./lib/index.d.ts", + "types": "./lib/index-legacy.d.ts", + "default": "./lib/index.js" + }, "./package.json": "./package.json" }, "type": "commonjs" diff --git a/scripts/integration-tests/e2e-prettier.sh b/scripts/integration-tests/e2e-prettier.sh index e9df53316a89..a150a697fc7c 100755 --- a/scripts/integration-tests/e2e-prettier.sh +++ b/scripts/integration-tests/e2e-prettier.sh @@ -36,6 +36,9 @@ startLocalRegistry "$root"/verdaccio-config.yml yarn install --no-immutable yarn info +# Test typings for @babel/parser +yarn lint:typecheck + # https://github.com/babel/babel/pull/14892#issuecomment-1233180626 echo "export default () => () => {}" > src/main/create-print-pre-check-function.js