deno_doc
deno_doc copied to clipboard
support global augmentation
I'd like to be able to generate documentation for things added to existing types.
https://www.typescriptlang.org/docs/handbook/declaration-merging.html#global-augmentation
// observable.ts
export class Observable<T> {}
declare global {
interface Array<T> {
toObservable(): Observable<T>;
}
}
Array.prototype.toObservable = function () {
throw new Error("not implemented");
};
Currently deno doc observable.ts only prints information about class Observable<T> and not about Array<T>#toObservable().
I know that generally this isn't a good idea (prototype pollution) but 1) sometimes it is necessary (e.g. for polyfills for upcoming features) and 2) extending types using a Symbol can safely extend built-ins and other types as symbols avoid name conflicts.