TypeScript-DOM-lib-generator icon indicating copy to clipboard operation
TypeScript-DOM-lib-generator copied to clipboard

Split out types and values

Open orta opened this issue 4 years ago • 1 comments

This should allow something like Node / React Native to be able to write /// <reference lib="dom.types" /> and have access to all of the global types, but none of the values. Re: https://github.com/microsoft/TypeScript/issues/43972

The concept is reasonably simple, we create two separate printers one focused on values and another on types. When we don't care to split they are the same printer and so no changes. Then the printer is DI'd down from whatever decides if it's printing a type or value.

orta avatar Sep 13 '21 14:09 orta

Hmm, as I said in Discord, I think this:

  • doesn't solve the collision issue on the static part as we've seen in #1093
  • forces including every type when consumers need only a part of the types

So my current idea is that we just duplicate the whole types into the module, while keeping the current lib as-is.

export interface AbortSignal {
  // ...
};

export var AbortSignal: {
  // ...
};
// on Node.js:
import { AbortSignal } from "typescript/dom";

saschanaz avatar Sep 13 '21 14:09 saschanaz