I want to override property type from library declaration, i try to override using interface but i got error Subsequent property declarations must have the same type
. How should i do to solve this issue?
// this is library declaration
declare class Auth {
user: Record<string, string | number> | null
// i want to remove null type in user property, because i dont want to use `non-null assertion` in line 21
// i cant change this file because it is 3rd party library
}
// ------------------------------
// our file
// my override interface, but fail
interface Auth {
user: Record<string, string | number>
}
const a: Auth = {
user: {
name: 'joko',
age: 30
}
}
const userName = a.user!.name
// const userName = a.user.name // <-- i want use like this, because i'm sure that this property is always available
I've tried to override library decalaration using interface but it fail. My expected result is the type can be overriden without touching or change the library, only by using our code.