Issue
if (process.env.NODE_ENV !== 'production') {
(WithUser as any).displayName = wrapDisplayName(Component, 'withUser');
}
I’m not even sure if as
is a keyword, but anyway, what does it do in JavaScript?
Solution
That is not vanilla JavaScript, it is TypeScript. as any
tells the compiler to consider the typed object as a plain untyped JavaScript object.
The as
keyword is a Type Assertion in TypeScript which tells the compiler to consider the object as another type than the type the compiler infers the object to be.
Answered By – Adrian Brand
Answer Checked By – Katrina (BugsFixing Volunteer)