Skip to content

Conversation

nikeokoronkwo
Copy link
Collaborator

@nikeokoronkwo nikeokoronkwo commented Aug 12, 2025

Fixes #442
Fixes #432

This PR updates configuration and arguments to better support configuring the TS declaration generator, as well as improve support for practically using the TS declaration generator on actual libraries.

Features

  • Add support for tsconfig.json: This allows configuration of the TypeScript compiler via the options available in a tsconfig.json file
  • Add support for ignoring errors
  • Add support for generating all declarations by default: A lot of TS declaration files may export declarations by default without specifying an export keyword, or some may handle declaration exporting differently. This allows us to generate Dart declarations for those libraries, without having to modify them and add export keywords.

@nikeokoronkwo nikeokoronkwo marked this pull request as ready for review August 12, 2025 05:28
@nikeokoronkwo nikeokoronkwo requested a review from srujzs August 12, 2025 05:28
Instead of manually marging objects to form compiler options, TS API requires using built-in functions to properly resolve the config into a compiler options objects, with enums, correct types, etc. Functions implemented were `parseJsonConfigFileContent` and `getParsedCommandLineOfConfigFile`
@nikeokoronkwo nikeokoronkwo changed the title [interop] Update Configuration [interop] Update Configuration to allow TS Compiler Configuration and non-exported decl generation Aug 13, 2025
Copy link
Contributor

@srujzs srujzs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's add a small test if possible.


Re: ignoring errors, is there a valid reason to do this? I can see it may be useful to get some output but I'm worried it might result in other failures later in our generation because we assumed the program was well-formed.

@nikeokoronkwo
Copy link
Collaborator Author

Re: ignoring errors, is there a valid reason to do this? I can see it may be useful to get some output but I'm worried it might result in other failures later in our generation because we assumed the program was well-formed.

There are few, but good, reasons to do this, mainly if we're trying to handle certain TS declarations that conflict with those built into typescript, like ES specs, DOM specs and @types/web. The code generator should work for these files, but because of errors finding symbols, the generator cannot transform declarations.

Apart from builtin TS compiler types, other use-cases shouldn't need to ignore errors.

Also: I found this a useful option as ffigen has a similar option.

@srujzs
Copy link
Contributor

srujzs commented Aug 14, 2025

The code generator should work for these files, but because of errors finding symbols, the generator cannot transform declarations.

Gotcha. I suppose since it's opt-in, users know what errors they're trying to work around. It would be nice if we can allow only ignoring those missing symbols errors and leave all the other errors, but I don't know if that's possible.

@nikeokoronkwo nikeokoronkwo merged commit cc3aa64 into dart-lang:main Aug 15, 2025
8 checks passed
@nikeokoronkwo nikeokoronkwo deleted the interop/updated-config branch August 15, 2025 00:01
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

Successfully merging this pull request may close these issues.

Interop Gen: Support Passing TS Configuration from tsconfig.json Interop Gen: Add configuration option for including non-exported declarations
2 participants