I'm working on accessibility and thought "I'll just make alt
a required attribute in my project." My aim is for all img
tags in my react app to complain if an alt
attribute has not been provided. So, I created a .d.ts
file where I have added the following:
import { HTMLAttributes } from 'react';
declare module 'react' {
export interface ImgHTMLAttributes<T> extends HTMLAttributes<T> {
alt: string;
}
}
I'm getting these errors:
All declarations of 'alt' must have identical modifiers.
Subsequent property declarations must have the same type. Property 'alt' must be of type 'string | undefined', but here has type 'string'.
Is there a way to indicate that I'm trying to override, and not extend? Or is there a better way to go about this?