diff --git a/packages/taro-cli/src/presets/commands/update.ts b/packages/taro-cli/src/presets/commands/update.ts index 4a472f6d6383..53ebc870c004 100644 --- a/packages/taro-cli/src/presets/commands/update.ts +++ b/packages/taro-cli/src/presets/commands/update.ts @@ -93,7 +93,7 @@ export default (ctx: IPluginContext) => { const nervJSVersion = `^${await getLatestVersion('nervjs')}` // 更新 @tarojs/* 版本和 NervJS 版本 - Object.keys(packageMap.dependencies).forEach((key) => { + Object.keys(packageMap.dependencies || {}).forEach((key) => { if (UPDATE_PACKAGE_LIST.indexOf(key) !== -1) { if (key.includes('nerv')) { packageMap.dependencies[key] = nervJSVersion @@ -102,7 +102,7 @@ export default (ctx: IPluginContext) => { } } }) - Object.keys(packageMap.devDependencies).forEach((key) => { + Object.keys(packageMap.devDependencies || {}).forEach((key) => { if (UPDATE_PACKAGE_LIST.indexOf(key) !== -1) { if (key.includes('nerv')) { packageMap.devDependencies[key] = nervJSVersion diff --git a/packages/taro/types/taro.extend.d.ts b/packages/taro/types/taro.extend.d.ts index ba802d3bc57d..fe22bd7cb696 100644 --- a/packages/taro/types/taro.extend.d.ts +++ b/packages/taro/types/taro.extend.d.ts @@ -106,7 +106,7 @@ declare namespace Taro { function setIsUsingDiff (flag: boolean) - const Current: { + interface Current { app: AppInstance | null, router: RouterInfo | null, page: PageInstance | null, @@ -114,4 +114,8 @@ declare namespace Taro { onHide: string, onShow: string } + + const Current: Current + + function getCurrentInstance(): Current }