Skip to content

Conversation

@turadg
Copy link
Member

@turadg turadg commented Nov 14, 2025

refs: #5760, #9005

Description

Script to auto-import types using TypeScript language server. This can be used to change the moduleResolution to NodeNext, which breaks the ambient imports, and then run this auto-repair. The inline @import are fixed up by the new eslint rule to group-jsdoc-imports.

Security Considerations

Scaling Considerations

Documentation Considerations

Testing Considerations

Upgrade Considerations

@socket-security

This comment has been minimized.

@turadg turadg force-pushed the ta/type-auto-imports branch from 0d80709 to ceac2a8 Compare November 14, 2025 19:10
@turadg turadg force-pushed the ta/type-auto-imports branch from ceac2a8 to ac67de5 Compare November 14, 2025 19:54
mergify bot added a commit that referenced this pull request Nov 17, 2025
refs: #9005

## Description
This changes all tsconfig projects to use `moduleResolution: 'NodeNext'`, freeing us of ambients! There are still some globals via `exported.js` that we can burn down later but at least those are explicit.

(The previous moduleResolution, 'bundler', was necessary because of our dependence on ambients. It's the mode that assumes everything will be turned into one giant bundle, so whatever hacks and heuristics the local TSC has to do to get the types to resolve is okay. But we actually do publish separate packages so need more strict type resolution behavior.)

I used the hacky script in #12225 but am not proposing to merge that. We might need to run it again when getting off `exported.js` but we can either run it from the branch or do some more (separate) work to make it trunk-worthy. That script uses the TS language server to iterate over files and do the "auto-import" that VS Code does. By changing the moduleResolution from 'bundler' and running that, necessary types are auto-imported. When there's a duplicate name it doesn't always get the right one so some manual fixups were necessary. After doing this for every module in the repo, I was able to change the default so they all are 'NodeNext' now.

### Security Considerations
none

### Scaling Considerations
none

### Documentation Considerations

Any downstream relying on the `types-ambient.js` exports will fail. The solution is just to import explicitly. I think that's a fine change to impose.

### Testing Considerations
CI

Nothing downstream will fail until it updates to a newer release and the fix for any ambients will be trivial.

### Upgrade Considerations
does not affect chain
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.

2 participants