Let's say I'm writing extension for vscode called extension a
That extension uses extension b's api. extension b is written in typescript, but doesn't really publish any sort of type declaration. But the interfaces are available in source code.
Generally, extension a will get extension b's api by doing something like vscode.extensions.getExtension<ExtensionB>("nameOfExtensionB");
Two questions:
getExtensionworking like that is risky, I can probably mismatch extension name and interfaces and nothing will tell me I'm doing something wrong, I'd like it to be type safe.- The actual type returned by the extension is
CSharpExtensionExports | OmnisharpExtensionExports | LimitedExtensionExports | null. However, I have completely no use forOmnisharpExtensionExports. Also there is no base interface, this is not a good candidate for a DU because there is no discriminator. But I can't just remove OmnisharpExtensionExports from the union as it might in theory really be returned, even though I don't care about it. This wouldn't be a problem if type declarations were provided by a package, but they are not. What to do?