microsoft / microsoft/TypeScript
Extract types from definition file
Nobody has claimed this yet.
- Dominant language
- Go
- Stars
- 111k
- Forks
- 14.3k
- Avg merge
- 2d 4h
- Merged PRs (30d)
- 132
Description
Search Terms
extract d.ts definition types
Suggestion
For a tvOS project I'm working with TVML and TypeScript. The JavaScript environment has some of the functionality of the browser, but not all classes are available (like FormData and URL).
You can see the classes that are supported here:
https://developer.apple.com/documentation/tvmljs
What I would like to do is to import a subset of type definitions from lib.dom.d.ts and then export them as lib.tvml.d.ts
Unfortunately I can't simply create a d.ts file and write this:
export { XMLHttpRequest } from "typescript/lib/lib.dom"
My next thought was to create a copy of lib.dom.d.ts and to remove everything except for the classes supported by TVML. However some of the types (like Document) are huge and they depend on other types which makes it even more complicated.
Another downside of a copy would be that it would miss out on the improvements that will be made over time to lib.dom.d.ts.
Use Cases
The file lib.webworker.d.ts has some overlap with lib.dom.d.ts (things like XMLHttpRequest). If we could create a d.ts by importing definitions from another d.ts it could simplify the built-in library definitions.
It also offers developers an easy way to pick which definitions are allowed to be used in the project.
Examples
See example under Suggestion section.
Checklist
My suggestion meets these guidelines:
- This wouldn't be a breaking change in existing TypeScript/JavaScript code
- This wouldn't change the runtime behavior of existing JavaScript code
- This could be implemented without emitting different JS based on the types of the expressions
- This isn't a runtime feature (e.g. library functionality, non-ECMAScript syntax with JavaScript output, etc.)
- This feature would agree with the rest of TypeScript's Design Goals.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by comparing lib.dom.d.ts and lib.webworker.d.ts, then review the referenced TVMLJS API list. Define how selected definitions and their dependencies should be exposed without copying lib.dom.d.ts; done means the overlapping definitions use case and a TVML-specific subset are both supported.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- compilers
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 30/100