Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: provide better way to track TypeScript spec types than using libdom #41

Open
grabbou opened this issue Nov 11, 2024 · 1 comment

Comments

@grabbou
Copy link
Collaborator

grabbou commented Nov 11, 2024

There are a few issues with libdom:

  • it is polluting global scope and making everything available, even though we just implemented a very limited subset
  • it defaults to features that are implemented by at least two major browser engines, which in our case is not desired (e.g. some newer APIs such as FileSystem API are only supported by one browser engine at the moment, but we still want them in React Native as we're starting from scratch)

We should perhaps generate our own type definitions and instead of using declaration file, just export them, so we can explicitly import them when necessary.

For now, a hardcoded subset will do, but going forward, we should automate generation. This is somewhat related to enforcing spec in general.

Ideas are welcome!

CC: @thymikee @V3RON @kraenhansen

@V3RON
Copy link
Collaborator

V3RON commented Nov 12, 2024

It seems we need a fork of TypeScript-DOM-lib-generator that removes compatibility checks, can be run from the CLI, includes only specific APIs and generates TypeScript files.

The W3C uses the Web IDL standard to define APIs in each specification, like in this example. Instead of working with the large TypeScript-DOM-lib-generator, we could fork webidl-dts-gen and make some necessary changes. The tool needs a bit of attention, as it currently generates incorrect types for the File API (like adding static members in interfaces and missing return types for constructors), but these issues should be easy to fix.

Update: See https://github.com/V3RON/webidl-dts-gen

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants