Skip to content

Commit 9e5d99e

Browse files
committed
fix(taro-helper): types
1 parent 358bc57 commit 9e5d99e

File tree

9 files changed

+4722
-4622
lines changed

9 files changed

+4722
-4622
lines changed

.npmrc

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ public-hoist-pattern[]=@types/*
99
public-hoist-pattern[]=*eslint*
1010
public-hoist-pattern[]=*jest*
1111
public-hoist-pattern[]=*prettier*
12-
registry="https://registry.yarnpkg.com/"
12+
1313
strict-peer-dependencies=false
1414

1515
{SCOPE}:registry=https://npm.pkg.github.com

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -156,8 +156,8 @@
156156
"stylelint-order": "^6.0.4",
157157
"ts-jest": "^29.1.2",
158158
"ts-node": "^10.9.1",
159-
"typescript": "~5.4.5",
160159
"tslib": "^2.6.2",
160+
"typescript": "~5.4.5",
161161
"vitest": "^1.6.0"
162162
},
163163
"pnpm": {

packages/taro-cli/package.json

+8-8
Original file line numberDiff line numberDiff line change
@@ -46,27 +46,27 @@
4646
"@tarojs/plugin-doctor": "^0.0.13",
4747
"@tarojs/service": "workspace:*",
4848
"@tarojs/shared": "workspace:*",
49-
"adm-zip": "^0.5.12",
50-
"axios": "^1.6.8",
49+
"adm-zip": "^0.5.16",
50+
"axios": "^1.8.1",
5151
"cli-highlight": "^2.1.11",
5252
"download-git-repo": "^3.0.2",
53-
"envinfo": "^7.12.0",
53+
"envinfo": "^7.14.0",
5454
"inquirer": "^8.2.6",
5555
"latest-version": "^5.1.0",
5656
"minimist": "^1.2.8",
5757
"ora": "^5.4.1",
58-
"semver": "^7.6.0",
59-
"validate-npm-package-name": "^5.0.0"
58+
"semver": "^7.7.1",
59+
"validate-npm-package-name": "^5.0.1"
6060
},
6161
"devDependencies": {
62-
"@babel/types": "^7.24.0",
62+
"@babel/types": "^7.26.9",
6363
"@tarojs/plugin-platform-h5": "workspace:*",
6464
"@tarojs/plugin-platform-weapp": "workspace:*",
6565
"@tarojs/taro": "workspace:*",
6666
"@tarojs/webpack5-runner": "workspace:*",
6767
"@types/babel__traverse": "^7.20.6",
6868
"babel-preset-taro": "workspace:*",
69-
"eslint-plugin-react": "^7.34.1",
70-
"eslint-plugin-react-hooks": "^4.4.0"
69+
"eslint-plugin-react": "^7.37.4",
70+
"eslint-plugin-react-hooks": "^4.6.2"
7171
}
7272
}

packages/taro-cli/src/create/page.ts

+2-8
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ export default class Page extends Creator {
7272
public conf: IPageConf
7373
private modifyCustomTemplateConfig: TGetCustomTemplate
7474
private afterCreate: TAfterCreate | undefined
75-
private pageEntryPath: string
75+
private pageEntryPath: string = ''
7676

7777
constructor (args: IPageArgs) {
7878
super()
@@ -214,18 +214,13 @@ export default class Page extends Creator {
214214
plugins: typescript ? ['typescript'] : []
215215
})
216216

217-
const callback = (state: ConfigModificationState) => {
218-
modifyState = state
219-
}
220-
221-
// @ts-ignore
222217
traverse(ast, {
223218
ExportDefaultDeclaration (path) {
224219
modifyPagesOrSubPackages({
225220
path,
226221
fullPagePath: pageString,
227222
subPkgRootPath: subPkg,
228-
callback
223+
callback: (state: ConfigModificationState) => { modifyState = state }
229224
})
230225
},
231226
})
@@ -236,7 +231,6 @@ export default class Page extends Creator {
236231
break
237232
case ConfigModificationState.Success:
238233
{
239-
// @ts-ignore
240234
const newCode = generate(ast, { retainLines: true })
241235
fs.writeFileSync(appConfigPath, newCode.code)
242236
console.log(`${chalk.green('✔ ')}${chalk.grey(`新页面信息已在 ${appConfigPath} 文件中自动补全`)}`)

packages/taro-helper/package.json

+16-16
Original file line numberDiff line numberDiff line change
@@ -40,32 +40,32 @@
4040
},
4141
"homepage": "https://github.com/NervJS/taro#readme",
4242
"dependencies": {
43-
"@babel/core": "^7.24.4",
44-
"@babel/generator": "^7.24.4",
45-
"@babel/parser": "^7.24.4",
46-
"@babel/traverse": "^7.24.1",
47-
"@babel/types": "^7.24.0",
48-
"@swc/core": "1.3.96",
49-
"@swc/register": "0.1.10",
43+
"@babel/core": "^7.26.9",
44+
"@babel/generator": "^7.26.9",
45+
"@babel/parser": "^7.26.9",
46+
"@babel/traverse": "^7.26.9",
47+
"@babel/types": "^7.26.9",
48+
"@swc/core": "1.11.7",
49+
"@swc/register": "^0.1.10",
5050
"ansi-escapes": "^4.3.2",
5151
"chalk": "^4.1.2",
5252
"chokidar": "^3.6.0",
53-
"cross-spawn": "^7.0.3",
54-
"debug": "^4.3.4",
55-
"dotenv": "^16.4.5",
56-
"dotenv-expand": "^11.0.6",
57-
"esbuild": "~0.21.0",
53+
"cross-spawn": "^7.0.6",
54+
"debug": "^4.4.0",
55+
"dotenv": "^16.4.7",
56+
"dotenv-expand": "^11.0.7",
57+
"esbuild": "~0.21.5",
5858
"find-yarn-workspace-root": "^2.0.0",
59-
"fs-extra": "^11.2.0",
59+
"fs-extra": "^11.3.0",
6060
"lodash": "^4.17.21",
6161
"require-from-string": "^2.0.2",
62-
"resolve": "^1.22.8",
63-
"supports-hyperlinks": "^3.0.0"
62+
"resolve": "^1.22.10",
63+
"supports-hyperlinks": "^3.2.0"
6464
},
6565
"devDependencies": {
6666
"@tarojs/taro": "workspace:*",
6767
"@types/babel__core": "^7.20.5",
6868
"@types/babel__generator": "^7.6.8",
69-
"@types/babel__traverse": "^7.20.5"
69+
"@types/babel__traverse": "^7.20.6"
7070
}
7171
}

packages/taro-helper/src/npm.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ export function resolveNpmSync(pluginName: string, root?: string): string {
5151
return res
5252
}
5353
return npmCached[pluginName]
54-
} catch (err) {
54+
} catch (err: any) {
5555
if (err.code === 'MODULE_NOT_FOUND') {
5656
console.log(chalk.cyan(`缺少npm包${pluginName},开始安装...`))
5757
const installOptions: IInstallOptions = {
@@ -168,7 +168,7 @@ export async function getNpmPkg(npmName: string, root: string) {
168168
let npmPath
169169
try {
170170
npmPath = resolveNpmSync(npmName, root)
171-
} catch (err) {
171+
} catch (err: any) {
172172
if (err.code === 'MODULE_NOT_FOUND') {
173173
console.log(chalk.cyan(`缺少npm包${npmName},开始安装...`))
174174
const installOptions: IInstallOptions = {

packages/taro-helper/src/utils.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -603,10 +603,10 @@ function readSFCPageConfig(configPath: string) {
603603
p.stop()
604604
}
605605
const configSource = matches[0]
606-
const ast = babel.parse(configSource, { filename: '' }) as babel.ParseResult
607-
608-
// @ts-ignore
609-
babel.traverse(ast.program, { CallExpression: callExprHandler })
606+
const ast = babel.parseSync(configSource, { filename: '' })
607+
if (ast) {
608+
babel.traverse(ast.program, { CallExpression: callExprHandler })
609+
}
610610
}
611611

612612
return result

packages/taro-rn/src/lib/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
// 由 getLibList.js 脚本生成, 不要进行手动修改, 请不要手动修改
2-
export * from './ENV_TYPE'
32
export * from './arrayBufferToBase64'
43
export * from './authorize'
54
export * from './base64ToArrayBuffer'
@@ -16,6 +15,7 @@ export * from './createInnerAudioContext'
1615
export * from './createSelectorQuery'
1716
export * from './createVideoContext'
1817
export * from './downloadFile'
18+
export * from './ENV_TYPE'
1919
export * from './getAppBaseInfo'
2020
export * from './getClipboardData'
2121
export * from './getEnv'

0 commit comments

Comments
 (0)