GeezerVison is showing github.com — Add codefix to generate types for untyped module · Pull Request #26588 · microsoft/TypeScript
Conversation
Fixes #25746
Adds a new codefix, also in fixCannotFindModule.ts since it is similar to the fix for installing an @types package and won't trigger if an @types package exists. This fix requires the value of the module and inspects the resulting value.
We don't want to call require (which can execute arbitrary code) during regular code fixes, so instead we generate a command which can be executed in a separate process. I put this in typingsInstaller since that's currently our only separate process, and I didn't want to create a third process.
typingsInstaller uses inspectValue.ts, which is designed to not require TypeScript (and not pull more code into typingsInstaller such as textChanges), and just produce a JSON representation of the required value. That is then passed to generateTypes.ts which actually converts that to an AST and renders.
The function generateTypesForModule is currently internal, but could be publicly exposed and made to be the implementation of dts-gen, which its code is based on.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
nickserv, SlurpTheo, and ExE-Boss reacted with thumbs up emoji
ghost
pushed a commit
that referenced
this pull request
Sep 18, 2018
This was referenced Nov 6, 2018
This was referenced Dec 8, 2018
This pull request was closed.
Uh oh!
There was an error while loading. Please reload this page.
Assignees
No one assigned
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.
|