Is there a way to expand on a union type from another module? Below is an example showcasing the need for this, but I encountered a ts(3200) error due to duplicate identifiers.
The Core module @org/core defines a union type called OptionType:
// Defined in Core module @org/core
export type OptionType = OptionAType | OptionBType;
In a different module, I aim to enhance the OptionType from the core module by adding a new type called MyListOptionType.
This way, when using @org/list
, users can utilize the expanded OptionType.
// In ListModule of a different package @org/list
import type { OptionType as OriginalOptionType } from '@org/core';
type MyListOptionType = { foo: string; bar: number };
declare module '@org/core' {
type OptionType = OriginalOptionType | MyListOptionType;
}
However, the current implementation leads to a duplicate identifier error (ts(3200)).