I’m developing a cross-platform app via uni-app (this is a solution to build a cross-platform app by Vue)
the type
attribute of button
has been changed in uni-app
which the value can only be in
"default" | "primary" | "warn";
instead of the ButtonHTMLAttributes.types
default enum
"button" | "submit" | "reset" | undefined
but there will be an error in vscode since I use primary
as the value of type
Type ‘”primary”‘ is not assignable to type ‘”submit” | “reset” | “button” | undefined’.ts-plugin(2322)
runtime-dom.d.ts(430, 5): The expected type comes from property ‘type’ which is declared here on type ‘ButtonHTMLAttributes & ReservedProps & Record<string, unknown>’
I want to prevent the error wavy lines showing in vscode
What I’ve tried:
adding a uni.d.ts
import { ButtonHTMLAttributes } from 'vue';
declare module '@vue/runtime-dom' {
interface ButtonHTMLAttributes {
type?: 'default' | 'primary' | 'warn';
}
}
I used thought this would expand the type of ButtonHTMLAttributes
in node_modules/@vue/runtime-dom/dist/runtime-dom.d.ts
, but it didn’t work.