Skip to content

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

Closed
@aluanhaddad

Description

@aluanhaddad

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;

Metadata

Metadata

Assignees

No one assigned

    Labels

    Domain: Quick FixesEditor-provided fixes, often called code actions.FixedA PR has been merged for this issueHelp WantedYou can do thisSuggestionAn idea for TypeScript

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions