feat(core): resolve type definitions #6097
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Another step to more TypeScript-like import handling: We implement the ability to resolve type definitions, which is now the preferred mechanism for the resolver in our module graph. This means we respect
tsconfig.json'scompilerOptions.typeRootsfield and search the directories specified there for type definitions. If it's not set, we default to looking insidenode_modules/@typesdirectories. In either case, if type definitions cannot be found, we fall back to regular dependency handling.I think this means we may discover
.jsfiles in places TypeScript would bail, but that may be a feature rather than a bug. If it gives trouble, we can always revise that.In practice, I don't expect this PR to have much influence on our type inference, since our inference doesn't support
.d.tsthat well yet, so that will be the next step.PS.: The huge line count is due to a React
.d.tsI checked in. Maybe it's overkill, but I think I want to use that file later for seeing how well our.d.tshandling works :)Test Plan
Test cases added.