In ReactTS 16.9, I have the following the function that returns parameter name only if the generic type TObject has the parameter name as key. If the key does not exist, a compile error will be raised. I always import the object first in my components and then use getPropertyName.
const Utils = {
getPropertyName<TObject>(name: keyof TObject) {
return name
}
}
export default Utils
Now, I would like to have it globally, so that I can use it anywhere in any component, without having to import it first.
Do I have to eject my React webpack config? Or is there another way around it?