Skip to content

Commit 1f7b509

Browse files
srujzsCommit Queue
authored andcommitted
Add GSoC proposal for .d.ts->JS interop declarations translator
Change-Id: I93a503752a9709dd75843df44cad3bd01a59d7b8 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/416100 Commit-Queue: Srujan Gaddam <[email protected]> Reviewed-by: Daco Harkes <[email protected]>
1 parent 7de867d commit 1f7b509

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

docs/gsoc/Dart-GSoC-2025-Project-Ideas.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,36 @@ Project:
144144

145145
**Expected outcome**: A package on pub.dev with terminal primitives like text styling, inputs, checkboxes, tables, layouts, spinners etc.
146146

147+
## **Idea:** Generate JS Interop Bindings for TypeScript Declaration Files
148+
149+
- **Possible Mentor(s)**: `[email protected]`
150+
- **Difficulty**: Hard
151+
- **Project size**: Large (350 hours)
152+
- **Skills**: Dart, JS/TS
153+
154+
**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.
147177

148178
## TODO: More ideas as they come!
149179

0 commit comments

Comments
 (0)