I am facing a challenge with an external module that I have installed from "@types/some-module." My goal is to enhance an interface within a specific namespace of that module, where one of the properties on that interface needs to be more restricted than what is provided by the original module.
Here's a Playground Link
// original.d.ts
namespace SomeNamespace {
interface SomeInterface {
id: string;
}
}
// my.d.ts
declare module 'some-module' {
namespace SomeNamespace {
interface SomeInterface {
id: 'foo' | 'bar'; // modification needed
}
}
}
However, this approach results in an error message:
Subsequent property declarations must have the same type. Property 'id' must be of type 'string', but here has type '"foo" | "bar"'. ts(2717)
Is there a way to achieve this? I have attempted using `unknown` and even `any`, but neither is accepted.