GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Add codefix to generate types for untyped module · Pull Request #26588 · microsoft/TypeScript

Conversation

@ghost

@ghost Deleted user (ghost) commented Aug 21, 2018 •
edited by ghost
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

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
All reactions
  • 👍 3 reactions
@ghost
ghost force-pushed the dtsgen branch 6 times, most recently from 2ec6cdf to 1429bc1 Compare August 22, 2018 18:49
@ghost
ghost requested review from Andrew Casey (amcasey) and Sheetal Nandi (sheetalkamat) August 22, 2018 18:50
@ghost
ghost force-pushed the dtsgen branch 2 times, most recently from 8847ebf to eda8c5a Compare August 22, 2018 23:16
@ghost ghost mentioned this pull request Aug 22, 2018
Bad formatting adding multiple properties to start of object literal #26618
Closed
@ghost
ghost force-pushed the dtsgen branch from eda8c5a to 6283bf5 Compare August 22, 2018 23:18
Andy Hanson
Add codefix to generate types for untyped module
a94774a
@ghost
ghost force-pushed the dtsgen branch from 6283bf5 to a94774a Compare August 22, 2018 23:43
Andy Hanson
Merge branch 'master' into dtsgen
ad3a6ef
@RyanCavanaugh
Ryan Cavanaugh (RyanCavanaugh) self-requested a review September 6, 2018 16:40
@ghost ghost mentioned this pull request Sep 7, 2018
Instrument JS code to detect types at runtime #7742
Closed
RyanCavanaugh
Ryan Cavanaugh (RyanCavanaugh) approved these changes Sep 17, 2018
View reviewed changes
Andy Hanson
Merge branch 'master' into dtsgen
a74e826
@ghost
ghost force-pushed the dtsgen branch from ddd8d04 to a74e826 Compare September 17, 2018 23:02
@RyanCavanaugh Ryan Cavanaugh (RyanCavanaugh) added this to the TypeScript 3.1 milestone Sep 17, 2018
@ghost
ghost force-pushed the dtsgen branch from a05cfb4 to 93dd800 Compare September 18, 2018 17:25
Andy Hanson
Merge branch 'master' into dtsgen
3dd3ded
@ghost
ghost force-pushed the dtsgen branch from 93dd800 to 3dd3ded Compare September 18, 2018 17:48
@ghost
ghost merged commit c57ff08 into master Sep 18, 2018
ghost pushed a commit that referenced this pull request Sep 18, 2018
Andy
Add codefix to generate types for untyped module (#26588)
b7c62ca
@ghost ghost mentioned this pull request Sep 18, 2018
Add codefix to generate types for untyped module (#26588) #27194
Closed
@ghost
ghost deleted the dtsgen branch October 9, 2018 21:14
This was referenced Nov 6, 2018
Idea: Infer types / parameters from runtime (V8 debugger/inspector protocol) #19641
Closed
Allow --declaration with --allowJs #7546
Closed
@shrinktofit stf (shrinktofit) mentioned this pull request Nov 15, 2018
Usage of newly added Typescript API generateTypesForModule #28546
Closed
This was referenced Dec 8, 2018
TypeScript compiler fails in ES5 environment #28918
Closed
TypeScript uses lib: es2015 to compile itself although it is supposed to run in ES5 environments #28933
Closed
@microsoft Microsoft (microsoft) locked as resolved and limited conversation to collaborators Oct 21, 2025
This pull request was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Reviewers

@amcasey Andrew Casey (amcasey) Awaiting requested review from amcasey
@sheetalkamat Sheetal Nandi (sheetalkamat) Awaiting requested review from sheetalkamat

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

TypeScript 3.1

Development

Successfully merging this pull request may close these issues.

Use dtsGen to generate declaration files for imported modules with no declarations

Uh oh!

There was an error while loading. Please reload this page.

1 participant

@RyanCavanaugh
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.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.