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: [taro-webpack5-runner miniplugin]微信小程序tabbar list 中数据类型不匹配时编译时需报错提醒 #16207

Closed
wants to merge 12 commits into from
Closed
11 changes: 10 additions & 1 deletion packages/taro-webpack5-runner/src/plugins/MiniPlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1048,7 +1048,16 @@ export default class TaroMiniPlugin {
if (tabBar && typeof tabBar === 'object' && !isEmptyObject(tabBar)) {
// eslint-disable-next-line dot-notation
const list = tabBar['list'] || []
list.forEach(item => {
list.forEach((item, index) => {
if (Object.prototype.toString.call(item) !== '[object Object]') {
throw new Error(`[ app.json 文件内容错误] app.json: tabBar.list[${index}] 字段需为 object`)
}
if (!Object.prototype.hasOwnProperty.call(item, 'pagePath') || item.pagePath === '') {
throw new Error(`[ app.json 文件内容错误] app.json: tabBar.list[${index}].pagePath 不能为空`)
}
if (typeof item.pagePath !== 'string') {
throw new Error(`[ app.json 文件内容错误] app.json: tabBar.list[${index}].pagePath 需为 string`)
}
// eslint-disable-next-line dot-notation
item['iconPath'] && this.tabBarIcons.add(item['iconPath'])
// eslint-disable-next-line dot-notation
Expand Down
Loading