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

Typescript Taro.offAppShow 的回调函数和 Taro.onAppShow 的回调函数类型不匹配 #10954

Closed
Miaonster opened this issue Dec 22, 2021 · 0 comments · Fixed by #11047
Closed
Assignees
Labels
A-typings Area - TypeScript Typings 相关 F-react Framework - React T-weapp Target - 编译到微信小程序 V-3 Version - 3.x

Comments

@Miaonster
Copy link
Contributor

相关平台

微信小程序

小程序基础库: 2.11.0
使用框架: React

复现步骤

const SomeComponent: React.FC = () => {
  useEffect(() => {
    const executeAutoLogin = (options: Taro.onAppShow.CallbackResult): void => {
      // do something
    }

    Taro.onAppShow(executeAutoLogin)

    return () => {
      offAppShow(executeAutoLogin) // 这里报错,错误信息在下一段
    }
  }, [])

  return <View></View>
}
Argument of type '(options: Taro.onAppShow.CallbackResult) => void' is not assignable to parameter of type '(res: CallbackResult) => void'.
  Types of parameters 'options' and 'res' are incompatible.
    Type 'CallbackResult' is missing the following properties from type 'CallbackResult': path, query, referrerInfo, scene, shareTicketts(2345)

这是因为 onAppShowoffAppShow 的回调函数类型不一致,除了这两个函数外,还有其他 onXXX 和 offXXX 的函数也都有类似问题。

期望结果

onAppShowoffAppShow 的回调函数使用同一类型

实际结果

onAppShowoffAppShow 的回调函数没有使用同一类型

环境信息

👽 Taro v3.3.16


  Taro CLI 3.3.16 environment info:
    System:
      OS: macOS 12.0.1
      Shell: 5.8 - /bin/zsh
    Binaries:
      Node: 17.0.1 - /usr/local/bin/node
      Yarn: 1.22.10 - /usr/local/bin/yarn
      npm: 8.1.0 - /usr/local/bin/npm
    npmPackages:
      @tarojs/cli: 3.3.16 => 3.3.16 
      @tarojs/components: 3.3.16 => 3.3.16 
      @tarojs/mini-runner: 3.3.16 => 3.3.16 
      @tarojs/react: 3.3.16 => 3.3.16 
      @tarojs/router: 3.3.16 => 3.3.16 
      @tarojs/runtime: 3.3.16 => 3.3.16 
      @tarojs/taro: 3.3.16 => 3.3.16 
      @tarojs/webpack-runner: 3.3.16 => 3.3.16 
      babel-preset-taro: 3.3.16 => 3.3.16 
      eslint-config-taro: 3.3.16 => 3.3.16 
      eslint-plugin-taro: 3.3.16 => 3.3.16 
      react: ^17.0.0 => 17.0.2 
    npmGlobalPackages:
      typescript: 4.3.4
@taro-bot2 taro-bot2 bot added F-react Framework - React T-weapp Target - 编译到微信小程序 V-3 Version - 3.x labels Dec 22, 2021
@ZakaryCode ZakaryCode added the A-typings Area - TypeScript Typings 相关 label Jan 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-typings Area - TypeScript Typings 相关 F-react Framework - React T-weapp Target - 编译到微信小程序 V-3 Version - 3.x
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants