Skip to content

Quick Fix info inconsistent when offering to import a UMD declaration. #17860

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
aluanhaddad opened this issue Aug 17, 2017 · 4 comments · Fixed by #19572
Closed

Quick Fix info inconsistent when offering to import a UMD declaration. #17860

aluanhaddad opened this issue Aug 17, 2017 · 4 comments · Fixed by #19572
Labels
Domain: Quick Fixes Editor-provided fixes, often called code actions. Fixed A PR has been merged for this issue Help Wanted You can do this Suggestion An idea for TypeScript

Comments

@aluanhaddad
Copy link
Contributor

aluanhaddad commented Aug 17, 2017

TypeScript Version: 2.4.0 / nightly (2.5.0-dev.20170816)

To Reproduce:

C:\Source\import-quick-fix-issue> npm install -D typescript@next
C:\Source\import-quick-fix-issue> tsc --init
C:\Source\import-quick-fix-issue> npm install --save lodash @types/lodash
C:\Source\import-quick-fix-issue> 'export const chain = _.chain;'> index.ts
C:\Source\import-quick-fix-issue> code-insiders .

Open in Visual Studio Code, move cursor to _, click the 💡, and observe that the following quick fix info is displayed
image

Expected behavior:
If --allowSyntheticDefaultImports is true the quick fix info remains the same and the result is

import _ from "lodash";
export const chain = _.chain;

If --allowSyntheticDefaultImports is false the quick fix info changes to
image
and the result is

import * as _ from "lodash";
export const chain = _.chain;

Actual behavior:

Regardless of the values specified for --module and --allowSyntheticDefaultImports, the quick fix info is always
image

and the result is always

import * as _ from "lodash";
export const chain = _.chain;

Ideal behavior: 😃

If --allowSyntheticDefaultImports is true the quick fix info remains the same and the result is

import _ from "lodash";
export const chain = _.chain;

If --allowSyntheticDefaultImports is false and --module is either commonjs, amd, or umd the quick fix info is changed to
image
and the result is

import _ = require("lodash");
export const chain = _.chain;
@mhegazy mhegazy added Domain: Quick Fixes Editor-provided fixes, often called code actions. Suggestion An idea for TypeScript Help Wanted You can do this labels Aug 17, 2017
@mhegazy mhegazy added this to the Community milestone Aug 17, 2017
@mhegazy
Copy link
Contributor

mhegazy commented Aug 17, 2017

PRs welcomed.

@aluanhaddad
Copy link
Contributor Author

In light of #19261, I want to try and take this on if you do not mind.

I would welcome suggestions about where to get started.

@mhegazy
Copy link
Contributor

mhegazy commented Oct 18, 2017

I suppose you will always make it ImportKind.Default if --allowSyntheticDefaults in https://github.com/Microsoft/TypeScript/blob/f8f662d0a197a2b5d276d3c4130ca52d74a1c1b2/src/services/codefixes/importFixes.ts#L641

@aluanhaddad
Copy link
Contributor Author

Great, thank you.

@mhegazy mhegazy added the Fixed A PR has been merged for this issue label Nov 7, 2017
@mhegazy mhegazy modified the milestones: Community, TypeScript 2.7 Nov 7, 2017
@microsoft microsoft locked and limited conversation to collaborators Jun 14, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Domain: Quick Fixes Editor-provided fixes, often called code actions. Fixed A PR has been merged for this issue Help Wanted You can do this Suggestion An idea for TypeScript
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants