Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: declare函数可以增强ts类型提示,以及插件出错时能够提供有效的错误 #4123

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 3 additions & 3 deletions lib/babel-plugin-uni-api/index.js
@@ -1,5 +1,5 @@
const path = require('path')

const { declare } = require('@babel/helper-plugin-utils');
const isWin = /^win/.test(process.platform)

const normalizePath = path => (isWin ? path.replace(/\\/g, '/') : path)
Expand Down Expand Up @@ -85,7 +85,7 @@ function parseExports(node, t, file) {
}
}

module.exports = function({
module.exports = declare(function({
types: t
}) {
return {
Expand Down Expand Up @@ -141,4 +141,4 @@ module.exports = function({
}
}
}
}
})
1 change: 1 addition & 0 deletions package.json
Expand Up @@ -44,6 +44,7 @@
},
"private": true,
"devDependencies": {
"@babel/helper-plugin-utils": "^7.20.2",
"@rollup/plugin-alias": "^3.1.0",
"@rollup/plugin-commonjs": "^11.1.0",
"@rollup/plugin-json": "^4.1.0",
Expand Down
5 changes: 5 additions & 0 deletions yarn.lock
Expand Up @@ -157,6 +157,11 @@
version "7.8.3"
resolved "https://registry.npmjs.org/@babel/helper-plugin-utils/-/helper-plugin-utils-7.8.3.tgz#9ea293be19babc0f52ff8ca88b34c3611b208670"

"@babel/helper-plugin-utils@^7.20.2":
version "7.20.2"
resolved "https://registry.npmmirror.com/@babel/helper-plugin-utils/-/helper-plugin-utils-7.20.2.tgz#d1b9000752b18d0877cff85a5c376ce5c3121629"
integrity sha512-8RvlJG2mj4huQ4pZ+rU9lqKi9ZKiRmuvGuM2HlWmkmgOhbs6zEAw6IEiJ5cQqGbDzGZOhwuOQNtZMi/ENLjZoQ==

"@babel/helper-regex@^7.8.3":
version "7.8.3"
resolved "https://registry.npmjs.org/@babel/helper-regex/-/helper-regex-7.8.3.tgz#139772607d51b93f23effe72105b319d2a4c6965"
Expand Down