One of the aliases I use is
type ReactMouseEvent = React.MouseEvent<HTMLDivElement, MouseEvent>
To implement this alias, I created a globals.d.ts
file within the types
folder of my project:
// in globals.d.ts
import React = require('react')
declare type ReactMouseEvent = React.MouseEvent<HTMLDivElement, MouseEvent>
Next, I adjusted the typeRoots
setting in my tsconfig.json file:
{
"compilerOptions": {
"typeRoots": [
"node_modules/@types",
"./types"
]
}
}
Despite these configurations, when attempting to use the code below, Visual Studio Code continued to raise errors about the missing name ReactMouseEvent
. How can I resolve this issue?
Update: I also attempted an alternative method to define the type in a d.ts
file:
import React = require('react')
declare global {
type ReactMouseEvent = React.MouseEvent<HTMLDivElement, MouseEvent>
}
However, this approach did not yield positive results either.