'Overload typescript property from npm package
Solution 1:[1]
you can make the typescript compiler consider the new type with as keyword.
for example, if you have an object say
obj= {prop1: 1, prop2: "str", otherProp: ["str"] }
with predefined type
objType = {
prop1: number;
prop2: string;
otherProp: string[];
}
you can overwrite this type like this
obj= {prop1: 1, prop2: "str"} as newType
type newType = {
prop1: number;
prop2: number;
}
off course, this is not the good approach you should follow, because you lose the importance of using type check, but it is considered a escape hitch in your case
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | samehanwar |

