Skip to content

[Bug 上报] 安装@uni-helper/uni-typed后 wot-design-uni 报 tsc 类型校验错误 #586

@SuperTylerX

Description

@SuperTylerX

Wot Design Uni 版本号

1.3.10

平台

h5, 微信小程序, APP

复现Demo地址(如不提供,issue将被直接关闭)

https://github.com/SuperTylerX/wot-demo

重现步骤

执行 vue-tsc --noEmit --skipLibCheck 后报类型错误

期望的结果是什么?

类型校验无误或者能够忽略wot design的tsc报错

实际的结果是什么?

类型校验报错:

node_modules/.pnpm/wot-design-uni@1.3.10_vue@3.5.3/node_modules/wot-design-uni/components/wd-button/wd-button.vue:20:6 - error TS2322: Type 'string | undefined' is not assignable to type '_ButtonOpenType | undefined'.
  Type 'string' is not assignable to type '_ButtonOpenType | undefined'.

20     :open-type="disabled || loading ? '' : openType"
        ~~~~~~~~~

  node_modules/.pnpm/@uni-helper+uni-app-types@1.0.0-alpha.3_typescript@5.5.4_vue@3.5.3/node_modules/@uni-helper/uni-app-types/dist/index.d.mts:1930:5
    1930     openType: _ButtonOpenType;
             ~~~~~~~~
    The expected type comes from property 'openType' which is declared here on type 'Partial<{}> & Omit<{ readonly size?: _ButtonSize | undefined; readonly type?: _ButtonType | undefined; readonly plain?: boolean | undefined; ... 28 more ...; readonly onAgreeprivacyauthorization?: _ButtonOnAgreeprivacyauthorization | undefined; } & VNodeProps & AllowedComponentProps & ComponentCustomProps & Readonly...'

node_modules/.pnpm/wot-design-uni@1.3.10_vue@3.5.3/node_modules/wot-design-uni/components/wd-button/wd-button.vue:27:6 - error TS2322: Type 'string | undefined' is not assignable to type '_ButtonLang | undefined'.
  Type 'string' is not assignable to type '_ButtonLang | undefined'.

27     :lang="lang"
        ~~~~

  node_modules/.pnpm/@uni-helper+uni-app-types@1.0.0-alpha.3_typescript@5.5.4_vue@3.5.3/node_modules/@uni-helper/uni-app-types/dist/index.d.mts:1978:5
    1978     lang: _ButtonLang;
             ~~~~
    The expected type comes from property 'lang' which is declared here on type 'Partial<{}> & Omit<{ readonly size?: _ButtonSize | undefined; readonly type?: _ButtonType | undefined; readonly plain?: boolean | undefined; ... 28 more ...; readonly onAgreeprivacyauthorization?: _ButtonOnAgreeprivacyauthorization | undefined; } & VNodeProps & AllowedComponentProps & ComponentCustomProps & Readonly...'

node_modules/.pnpm/wot-design-uni@1.3.10_vue@3.5.3/node_modules/wot-design-uni/components/wd-calendar-view/yearPanel/year-panel.vue:4:98 - error TS2322: Type '(e: Event) => void' is not assignable to type '_ScrollViewOnScroll'. 
  Types of parameters 'e' and 'event' are incompatible.
    Type '_CustomEvent<_ScrollViewOnScrollDetail, Record<string, any>, Record<string, any>, Record<string, any>>' is missing the following properties from type 'Event': bubbles, cancelBubble, cancelable, composed, and 14 more.  

4     <scroll-view class="wd-year-panel__container" :style="`height: ${scrollHeight}px`" scroll-y @scroll="yearScroll" :scroll-top="scrollTop">
                                                                                                   ~~~~~~

  node_modules/.pnpm/@uni-helper+uni-app-types@1.0.0-alpha.3_typescript@5.5.4_vue@3.5.3/node_modules/@uni-helper/uni-app-types/dist/index.d.mts:366:5
    366     onScroll: _ScrollViewOnScroll;
            ~~~~~~~~
    The expected type comes from property 'onScroll' which is declared here on type 'Record<string, unknown> & Partial<{}> & Omit<{ readonly scrollX?: boolean | undefined; readonly scrollY?: boolean | undefined; readonly upperThreshold?: string | number | undefined; ... 20 more ...; readonly onRefresherabort?: _ScrollViewOnRefresherabort | undefined; } & VNodeProps & AllowedComponentProps & Componen...'

node_modules/.pnpm/wot-design-uni@1.3.10_vue@3.5.3/node_modules/wot-design-uni/components/wd-cell/wd-cell.vue:6:5 - error TS2322: Type 'string' is not assignable to type 'number'.

6     hover-stay-time="70"
      ~~~~~~~~~~~~~~~

  node_modules/.pnpm/@uni-helper+uni-app-types@1.0.0-alpha.3_typescript@5.5.4_vue@3.5.3/node_modules/@uni-helper/uni-app-types/dist/index.d.mts:134:5
    134     hoverStayTime: number;
            ~~~~~~~~~~~~~
    The expected type comes from property 'hoverStayTime' which is declared here on type 'Partial<{}> & Omit<{ readonly hoverClass?: string | undefined; readonly hoverStopPropagation?: boolean | undefined; readonly hoverStartTime?: number | undefined; readonly hoverStayTime?: number | undefined; } & VNodeProps & AllowedComponentProps & ComponentCustomProps & Readonly<...>, undefined> & Record<...>'

node_modules/.pnpm/wot-design-uni@1.3.10_vue@3.5.3/node_modules/wot-design-uni/components/wd-img/wd-img.vue:9:8 - error TS2322: Type '(event: Event) => void' is not assignable to type '_ImageOnLoad'.
  Types of parameters 'event' and 'event' are incompatible.
    Type '_CustomEvent<_ImageOnLoadDetail, Record<string, any>, Record<string, any>, Record<string, any>>' is missing the following properties from type 'Event': bubbles, cancelBubble, cancelable, composed, and 14 more.

9       @load="handleLoad"
         ~~~~

  node_modules/.pnpm/@uni-helper+uni-app-types@1.0.0-alpha.3_typescript@5.5.4_vue@3.5.3/node_modules/@uni-helper/uni-app-types/dist/index.d.mts:5120:5
    5120     onLoad: _ImageOnLoad;
             ~~~~~~
    The expected type comes from property 'onLoad' which is declared here on type 'Record<string, unknown> & Partial<{}> & Omit<{ readonly src?: string | undefined; readonly mode?: _ImageMode | undefined; readonly lazyLoad?: boolean | undefined; ... 5 more ...; readonly onLoad?: _ImageOnLoad | undefined; } & VNodeProps & AllowedComponentProps & ComponentCustomProps & Readonly<...>, undefined>'

node_modules/.pnpm/wot-design-uni@1.3.10_vue@3.5.3/node_modules/wot-design-uni/components/wd-img/wd-img.vue:10:8 - error TS2322: Type '(event: Event) => void' is not assignable to type '_ImageOnError'.
  Types of parameters 'event' and 'event' are incompatible.
    Type '_BaseEvent<Record<string, any>, Record<string, any>, Record<string, any>>' is missing the following properties from type 'Event': bubbles, cancelBubble, cancelable, composed, and 14 more.

10       @error="handleError"
          ~~~~~

  node_modules/.pnpm/@uni-helper+uni-app-types@1.0.0-alpha.3_typescript@5.5.4_vue@3.5.3/node_modules/@uni-helper/uni-app-types/dist/index.d.mts:5118:5
    5118     onError: _ImageOnError;
             ~~~~~~~
    The expected type comes from property 'onError' which is declared here on type 'Record<string, unknown> & Partial<{}> & Omit<{ readonly src?: string | undefined; readonly mode?: _ImageMode | undefined; readonly lazyLoad?: boolean | undefined; ... 5 more ...; readonly onLoad?: _ImageOnLoad | undefined; } & VNodeProps & AllowedComponentProps & ComponentCustomProps & Readonly<...>, undefined>'

node_modules/.pnpm/wot-design-uni@1.3.10_vue@3.5.3/node_modules/wot-design-uni/components/wd-input/wd-input.vue:27:12 - error TS2322: Type 'string' is not assignable to type '_InputType | undefined'.

27           :type="type"
              ~~~~

  node_modules/.pnpm/@uni-helper+uni-app-types@1.0.0-alpha.3_typescript@5.5.4_vue@3.5.3/node_modules/@uni-helper/uni-app-types/dist/index.d.mts:2689:5
    2689     type: _InputType;
             ~~~~
    The expected type comes from property 'type' which is declared here on type 'Partial<{}> & Omit<{ readonly name?: string | undefined; readonly value?: string | undefined; readonly type?: _InputType | undefined; readonly textContentType?: "oneTimeCode" | undefined; ... 33 more ...; readonly onKeyboardheightchange?: _InputOnKeyboardheightchange | undefined; } & VNodeProps & AllowedComponentPro...'

node_modules/.pnpm/wot-design-uni@1.3.10_vue@3.5.3/node_modules/wot-design-uni/components/wd-input/wd-input.vue:34:12 - error TS2322: Type 'string' is not assignable to type '_InputConfirmType | undefined'.

34           :confirm-type="confirmType"
              ~~~~~~~~~~~~

  node_modules/.pnpm/@uni-helper+uni-app-types@1.0.0-alpha.3_typescript@5.5.4_vue@3.5.3/node_modules/@uni-helper/uni-app-types/dist/index.d.mts:2765:5
    2765     confirmType: _InputConfirmType;
             ~~~~~~~~~~~
    The expected type comes from property 'confirmType' which is declared here on type 'Partial<{}> & Omit<{ readonly name?: string | undefined; readonly value?: string | undefined; readonly type?: _InputType | undefined; readonly textContentType?: "oneTimeCode" | undefined; ... 33 more ...; readonly onKeyboardheightchange?: _InputOnKeyboardheightchange | undefined; } & VNodeProps & AllowedComponentPro...'

node_modules/.pnpm/wot-design-uni@1.3.10_vue@3.5.3/node_modules/wot-design-uni/components/wd-navbar/wd-navbar.vue:12:11 - error TS2322: Type 'string' is not assignable to type 'number'.

12           hover-stay-time="70"
             ~~~~~~~~~~~~~~~

  node_modules/.pnpm/@uni-helper+uni-app-types@1.0.0-alpha.3_typescript@5.5.4_vue@3.5.3/node_modules/@uni-helper/uni-app-types/dist/index.d.mts:134:5
    134     hoverStayTime: number;
            ~~~~~~~~~~~~~
    The expected type comes from property 'hoverStayTime' which is declared here on type 'Partial<{}> & Omit<{ readonly hoverClass?: string | undefined; readonly hoverStopPropagation?: boolean | undefined; readonly hoverStartTime?: number | undefined; readonly hoverStayTime?: number | undefined; } & VNodeProps & AllowedComponentProps & ComponentCustomProps & Readonly<...>, undefined> & Record<...>'

node_modules/.pnpm/wot-design-uni@1.3.10_vue@3.5.3/node_modules/wot-design-uni/components/wd-navbar/wd-navbar.vue:33:11 - error TS2322: Type 'string' is not assignable to type 'number'.

33           hover-stay-time="70"
             ~~~~~~~~~~~~~~~

  node_modules/.pnpm/@uni-helper+uni-app-types@1.0.0-alpha.3_typescript@5.5.4_vue@3.5.3/node_modules/@uni-helper/uni-app-types/dist/index.d.mts:134:5
    134     hoverStayTime: number;
            ~~~~~~~~~~~~~
    The expected type comes from property 'hoverStayTime' which is declared here on type 'Partial<{}> & Omit<{ readonly hoverClass?: string | undefined; readonly hoverStopPropagation?: boolean | undefined; readonly hoverStartTime?: number | undefined; readonly hoverStayTime?: number | undefined; } & VNodeProps & AllowedComponentProps & ComponentCustomProps & Readonly<...>, undefined> & Record<...>'

node_modules/.pnpm/wot-design-uni@1.3.10_vue@3.5.3/node_modules/wot-design-uni/components/wd-navbar/wd-navbar.vue:37:112 - error TS2322: Type 'string' is not assignable to type 'number'.

37           <view v-if="!$slots.right && rightText" class="wd-navbar__text" hover-class="wd-navbar__text--hover" hover-stay-time="70">
                                                                                                                  ~~~~~~~~~~~~~~~

  node_modules/.pnpm/@uni-helper+uni-app-types@1.0.0-alpha.3_typescript@5.5.4_vue@3.5.3/node_modules/@uni-helper/uni-app-types/dist/index.d.mts:134:5
    134     hoverStayTime: number;
            ~~~~~~~~~~~~~
    The expected type comes from property 'hoverStayTime' which is declared here on type 'Partial<{}> & Omit<{ readonly hoverClass?: string | undefined; readonly hoverStopPropagation?: boolean | undefined; readonly hoverStartTime?: number | undefined; readonly hoverStayTime?: number | undefined; } & VNodeProps & AllowedComponentProps & ComponentCustomProps & Readonly<...>, undefined> & Record<...>'

node_modules/.pnpm/wot-design-uni@1.3.10_vue@3.5.3/node_modules/wot-design-uni/components/wd-search/wd-search.vue:27:12 - error TS2322: Type 'string | number' is not assignable to type 'number | undefined'.
  Type 'string' is not assignable to type 'number'.

27           :maxlength="maxlength"
              ~~~~~~~~~

  node_modules/.pnpm/@uni-helper+uni-app-types@1.0.0-alpha.3_typescript@5.5.4_vue@3.5.3/node_modules/@uni-helper/uni-app-types/dist/index.d.mts:2725:5
    2725     maxlength: number;
             ~~~~~~~~~
    The expected type comes from property 'maxlength' which is declared here on type 'Partial<{}> & Omit<{ readonly name?: string | undefined; readonly value?: string | undefined; readonly type?: _InputType | undefined; readonly textContentType?: "oneTimeCode" | undefined; ... 33 more ...; readonly onKeyboardheightchange?: _InputOnKeyboardheightchange | undefined; } & VNodeProps & AllowedComponentPro...'

node_modules/.pnpm/wot-design-uni@1.3.10_vue@3.5.3/node_modules/wot-design-uni/components/wd-select-picker/wd-select-picker.vue:57:10 - error TS2322: Type 'number | null' is not assignable to type 'string | number | undefined'. 
  Type 'null' is not assignable to type 'string | number | undefined'.

57         :scroll-top="scrollTop"
            ~~~~~~~~~~

  node_modules/.pnpm/@uni-helper+uni-app-types@1.0.0-alpha.3_typescript@5.5.4_vue@3.5.3/node_modules/@uni-helper/uni-app-types/dist/index.d.mts:274:5
    274     scrollTop: number | string;
            ~~~~~~~~~
    The expected type comes from property 'scrollTop' which is declared here on type 'Partial<{}> & Omit<{ readonly scrollX?: boolean | undefined; readonly scrollY?: boolean | undefined; readonly upperThreshold?: string | number | undefined; readonly lowerThreshold?: string | ... 1 more ... | undefined; ... 19 more ...; readonly onRefresherabort?: _ScrollViewOnRefresherabort | undefined; } & VNodePro...'

node_modules/.pnpm/wot-design-uni@1.3.10_vue@3.5.3/node_modules/wot-design-uni/components/wd-swiper/wd-swiper.vue:12:8 - error TS2322: Type 'string | number' is not assignable to type 'string | undefined'.
  Type 'number' is not assignable to type 'string'.

12       :previous-margin="previousMargin"
          ~~~~~~~~~~~~~~~

  node_modules/.pnpm/@uni-helper+uni-app-types@1.0.0-alpha.3_typescript@5.5.4_vue@3.5.3/node_modules/@uni-helper/uni-app-types/dist/index.d.mts:589:5
    589     previousMargin: string;
            ~~~~~~~~~~~~~~
    The expected type comes from property 'previousMargin' which is declared here on type 'Partial<{}> & Omit<{ readonly indicatorDots?: boolean | undefined; readonly indicatorColor?: string | undefined; readonly indicatorActiveColor?: string | undefined; ... 20 more ...; readonly onAnimationfinish?: _SwiperOnAnimationfinish | undefined; } & VNodeProps & AllowedComponentProps & ComponentCustomProps & Read...'

node_modules/.pnpm/wot-design-uni@1.3.10_vue@3.5.3/node_modules/wot-design-uni/components/wd-swiper/wd-swiper.vue:13:8 - error TS2322: Type 'string | number' is not assignable to type 'string | undefined'.

13       :next-margin="nextMargin"
          ~~~~~~~~~~~

  node_modules/.pnpm/@uni-helper+uni-app-types@1.0.0-alpha.3_typescript@5.5.4_vue@3.5.3/node_modules/@uni-helper/uni-app-types/dist/index.d.mts:597:5
    597     nextMargin: string;
            ~~~~~~~~~~
    The expected type comes from property 'nextMargin' which is declared here on type 'Partial<{}> & Omit<{ readonly indicatorDots?: boolean | undefined; readonly indicatorColor?: string | undefined; readonly indicatorActiveColor?: string | undefined; ... 20 more ...; readonly onAnimationfinish?: _SwiperOnAnimationfinish | undefined; } & VNodeProps & AllowedComponentProps & ComponentCustomProps & Read...'

node_modules/.pnpm/wot-design-uni@1.3.10_vue@3.5.3/node_modules/wot-design-uni/components/wd-tag/wd-tag.vue:18:7 - error TS2322: Type 'string' is not assignable to type 'boolean | undefined'.

18       focus="true"
         ~~~~~

  node_modules/.pnpm/@uni-helper+uni-app-types@1.0.0-alpha.3_typescript@5.5.4_vue@3.5.3/node_modules/@uni-helper/uni-app-types/dist/index.d.mts:2741:5
    2741     focus: boolean;
             ~~~~~
    The expected type comes from property 'focus' which is declared here on type 'Partial<{}> & Omit<{ readonly name?: string | undefined; readonly value?: string | undefined; readonly type?: _InputType | undefined; readonly textContentType?: "oneTimeCode" | undefined; ... 33 more ...; readonly onKeyboardheightchange?: _InputOnKeyboardheightchange | undefined; } & VNodeProps & AllowedComponentPro...'

node_modules/.pnpm/wot-design-uni@1.3.10_vue@3.5.3/node_modules/wot-design-uni/components/wd-textarea/wd-textarea.vue:18:9 - error TS2322: Type 'string | number' is not assignable to type 'string | undefined'.

18         v-model="inputValue"
           ~~~~~~~

  node_modules/.pnpm/@uni-helper+uni-app-types@1.0.0-alpha.3_typescript@5.5.4_vue@3.5.3/node_modules/@uni-helper/uni-app-types/dist/index.d.mts:4117:5
    4117     value: string;
             ~~~~~
    The expected type comes from property 'value' which is declared here on type 'Partial<{}> & Omit<{ readonly value?: string | undefined; readonly placeholder?: string | undefined; readonly placeholderStyle?: string | undefined; readonly placeholderClass?: string | undefined; ... 23 more ...; readonly onKeyboardheightchange?: _TextareaOnKeyboardheightchange | undefined; } & VNodeProps & Allowed...'

node_modules/.pnpm/wot-design-uni@1.3.10_vue@3.5.3/node_modules/wot-design-uni/components/wd-textarea/wd-textarea.vue:36:10 - error TS2322: Type 'ConfirmType | null' is not assignable to type '_TextareaConfirmType | undefined'. 
  Type 'null' is not assignable to type '_TextareaConfirmType | undefined'.

36         :confirm-type="confirmType"
            ~~~~~~~~~~~~

  node_modules/.pnpm/@uni-helper+uni-app-types@1.0.0-alpha.3_typescript@5.5.4_vue@3.5.3/node_modules/@uni-helper/uni-app-types/dist/index.d.mts:4193:5
    4193     confirmType: _TextareaConfirmType;
             ~~~~~~~~~~~
    The expected type comes from property 'confirmType' which is declared here on type 'Partial<{}> & Omit<{ readonly value?: string | undefined; readonly placeholder?: string | undefined; readonly placeholderStyle?: string | undefined; readonly placeholderClass?: string | undefined; ... 23 more ...; readonly onKeyboardheightchange?: _TextareaOnKeyboardheightchange | undefined; } & VNodeProps & Allowed...'


Found 18 errors in 11 files.

Errors  Files
     2  node_modules/.pnpm/wot-design-uni@1.3.10_vue@3.5.3/node_modules/wot-design-uni/components/wd-button/wd-button.vue:20
     1  node_modules/.pnpm/wot-design-uni@1.3.10_vue@3.5.3/node_modules/wot-design-uni/components/wd-calendar-view/yearPanel/year-panel.vue:4
     1  node_modules/.pnpm/wot-design-uni@1.3.10_vue@3.5.3/node_modules/wot-design-uni/components/wd-cell/wd-cell.vue:6
     2  node_modules/.pnpm/wot-design-uni@1.3.10_vue@3.5.3/node_modules/wot-design-uni/components/wd-img/wd-img.vue:9
     2  node_modules/.pnpm/wot-design-uni@1.3.10_vue@3.5.3/node_modules/wot-design-uni/components/wd-input/wd-input.vue:27
     3  node_modules/.pnpm/wot-design-uni@1.3.10_vue@3.5.3/node_modules/wot-design-uni/components/wd-navbar/wd-navbar.vue:12
     1  node_modules/.pnpm/wot-design-uni@1.3.10_vue@3.5.3/node_modules/wot-design-uni/components/wd-search/wd-search.vue:27
     1  node_modules/.pnpm/wot-design-uni@1.3.10_vue@3.5.3/node_modules/wot-design-uni/components/wd-select-picker/wd-select-picker.vue:57
     2  node_modules/.pnpm/wot-design-uni@1.3.10_vue@3.5.3/node_modules/wot-design-uni/components/wd-swiper/wd-swiper.vue:12
     1  node_modules/.pnpm/wot-design-uni@1.3.10_vue@3.5.3/node_modules/wot-design-uni/components/wd-tag/wd-tag.vue:18
     2  node_modules/.pnpm/wot-design-uni@1.3.10_vue@3.5.3/node_modules/wot-design-uni/components/wd-textarea/wd-textarea.vue:18
 ELIFECYCLE  Command failed with exit code 2.

环境信息

No response

其他补充信息

pnpm版本 8.15.8
node版本 20.12.2
@vue/language-server版本 2.1.6
@uni-helper/uni-app-types版本 1.0.0-alpha.3

tsconfig.json

{
  "extends": "@vue/tsconfig/tsconfig.json",
  "compilerOptions": {
    "sourceMap": true,
    "baseUrl": ".",
    "paths": {
      "@/*": ["./src/*"]
    },
    "lib": ["esnext", "dom"],
    "types": [
      "node",
      "wot-design-uni/global", // wot-design-uni 组件类型
      "@dcloudio/types", // uni-app API 类型
      "miniprogram-api-typings", // 原生微信小程序类型
      "@uni-helper/uni-app-types" // uni-app 组件类型
    ]
  },
  "include": ["src/**/*.ts", "src/**/*.d.ts", "src/**/*.tsx", "src/**/*.vue"],
  "vueCompilerOptions": {
    "plugins": ["@uni-helper/uni-app-types/volar-plugin"]
  }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions