TypeSrcipt模板更新添加miniprogram-api-typings编译出错。求助官方?
发布于 7 年前 作者 qiaoqiang 11955 次浏览 来自 问答

之前TypeSrcipt 模板里面 package.json 中dependencies 里面没有 miniprogram-api-typings。

npm install miniprogram-api-typings 
之后在 tsconfig.json 中修改 
typeRoots : [      
      "./node_modules/miniprogram-api-typings"
    ]

1.编译出现 错误
miniprogram/pages/auc/special/special.ts:62:3 - error TS2345: Argument of type '{ data: { curPage: number; pageSize: number; specials: never[]; session: {}; sesCode: string; loading: false; footer: false; showmask: false; loadAfresh: false; }; onLoad(options: any): void; onPullDownRefresh(): void; ... 4 more ...; handleTapLots(event: any): void; }' is not assignable to parameter of type 'Options<{ curPage: number; pageSize: number; specials: never[]; session: {}; sesCode: string; loading: boolean; footer: boolean; showmask: boolean; loadAfresh: boolean; }, {}>'.
  Object literal may only specify known properties, and 'eventLoadAfresh' does not exist in type 'Options<{ curPage: number; pageSize: number; specials: never[]; session: {}; sesCode: string; loading: boolean; footer: boolean; showmask: boolean; loadAfresh: boolean; }, {}>'.

62   eventLoadAfresh() {

2.miniprogram-api-typings  文件里面也出现错误
node_modules/miniprogram-api-typings/types/wx/lib.wx.api.d.ts:15775:15 - error TS2451: Cannot redeclare block-scoped variable 'console'.

15775 declare const console: WechatMiniprogram.Console
                    ~~~~~~~

  node_modules/typescript/lib/lib.dom.d.ts:17510:13
    17510 declare var console: Console;
                      ~~~~~~~
    'console' was also declared here.

1 回复

Cannot redeclare block-scoped variable ‘console’ 的问题参见 https://github.com/wechat-miniprogram/api-typings/issues/66

special.ts 报错的问题,看起来是没有正确推导方法。special.ts 的代码可以看一下吗?不用具体逻辑,主要是看看函数签名和 Page 构造器的调用有没有定义没覆盖到的情况,谢谢~

回到顶部