You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
**Description**: Generate modern Dart JS interop declarations for `.d.ts` files.
155
+
156
+
[`package:web_generator`](https://github.com/dart-lang/web/tree/main/web_generator) is used to generate the JS interop bindings for the DOM and various browser APIs in [`package:web`](https://github.com/dart-lang/web).
157
+
It uses [`webidl2`](https://www.npmjs.com/package/webidl2) to parse the definitions that are supplied by [`webref`](https://www.npmjs.com/package/@webref/idl).
158
+
Using JS interop, it takes the resulting JS AST nodes and create an intermediate representation.
159
+
Lastly, with that intermediate representation, it uses [`package:code_builder`](https://github.com/dart-lang/tools/tree/main/pkgs/code_builder) to emit valid JS interop code.
160
+
161
+
This project would entail doing something similar but instead of translating IDL files, it would translate `.d.ts` files to JS interop interfaces, reusing and refactoring the intermediate representation so that it can be used for both purposes.
162
+
163
+
There is some history in [`js_facade_gen`](https://github.com/dart-archive/js_facade_gen), which is now archived.
164
+
This project will be a lighterweight version of that that will emit [modern JS interop](https://dart.dev/interop/js-interop) instead.
165
+
166
+
Project:
167
+
* Find a parser for `.d.ts` files that outputs JS/TS AST nodes and add a script in `web_generator/bin` to use it.
168
+
* Refactor the `package:web_generator` intermediate representation so it can be used as the translation target.
169
+
* Use JS interop to translate the AST nodes to the intermediate representation.
170
+
* Add tests for TS->JS interop code generation.
171
+
172
+
**Good Sample Project**:
173
+
174
+
* Modify or add a binary to `package:web_generator` to provide an option to generate bindings for specific IDL files instead of all of `webref`.
175
+
176
+
**Expected outcome**: A published `package:web_generator` that includes a `bin/` script that consumes `.d.ts` files and outputs JS interop interfaces.
0 commit comments