Typescript: Code fix for missing imports fails with allowSyntheticDefaultImports

Created on 5 Sep 2018  路  1Comment  路  Source: microsoft/TypeScript

TypeScript Version: 3.0.1

Search Terms: "synthetic default", "code fix"

Code

// In file 1...
export enum FooType {
    Bar = 'bar',
    Baz = 'baz'
}

// In file 2, without writing imports...
const foo: FooT~
// (Cmd-Space at the ~ autocompletes as expected)

// In file 3, without writing imports
const foo: FooType = FooType.Bar;
// This produces two error-diagnostics for `FooType` not being found.
// Attempting to use a code action to fix the issue produces the stack trace below
[Error  - 8:54:09 AM] 'getCodeFixes' request failed with error.
Error processing request. Debug Failure.
Error: Debug Failure.
    at Object.assertDefined (/Users/ehd/depot-ui/node_modules/typescript/lib/tsserver.js:1435:24)
    at getDefaultExportInfo (/Users/ehd/depot-ui/node_modules/typescript/lib/tsserver.js:105189:63)
    at /Users/ehd/depot-ui/node_modules/typescript/lib/tsserver.js:105166:32
    at /Users/ehd/depot-ui/node_modules/typescript/lib/tsserver.js:105287:21
    at forEachExternalModule (/Users/ehd/depot-ui/node_modules/typescript/lib/tsserver.js:105300:21)
    at forEachExternalModuleToImportFrom (/Users/ehd/depot-ui/node_modules/typescript/lib/tsserver.js:105285:13)
    at getExportInfos (/Users/ehd/depot-ui/node_modules/typescript/lib/tsserver.js:105161:13)
    at getFixesInfoForNonUMDImport (/Users/ehd/depot-ui/node_modules/typescript/lib/tsserver.js:105147:57)
    at getFixesInfo (/Users/ehd/depot-ui/node_modules/typescript/lib/tsserver.js:105085:19)
    at Object.getCodeActions (/Users/ehd/depot-ui/node_modules/typescript/lib/tsserver.js:104870:28)
    at /Users/ehd/depot-ui/node_modules/typescript/lib/tsserver.js:103896:121
    at Object.flatMap (/Users/ehd/depot-ui/node_modules/typescript/lib/tsserver.js:498:25)
    at Object.getFixes (/Users/ehd/depot-ui/node_modules/typescript/lib/tsserver.js:103896:23)
    at /Users/ehd/depot-ui/node_modules/typescript/lib/tsserver.js:111747:35
    at Object.flatMap (/Users/ehd/depot-ui/node_modules/typescript/lib/tsserver.js:498:25)
    at Object.getCodeFixesAtPosition (/Users/ehd/depot-ui/node_modules/typescript/lib/tsserver.js:111745:23)
    at IOSession.Session.getCodeFixes (/Users/ehd/depot-ui/node_modules/typescript/lib/tsserver.js:119339:64)
    at Session.handlers.ts.createMapFromTemplate._a.(anonymous function) (/Users/ehd/depot-ui/node_modules/typescript/lib/tsserver.js:118213:61)
    at /Users/ehd/depot-ui/node_modules/typescript/lib/tsserver.js:119496:88
    at IOSession.Session.executeWithRequestId (/Users/ehd/depot-ui/node_modules/typescript/lib/tsserver.js:119487:28)
    at IOSession.Session.executeCommand (/Users/ehd/depot-ui/node_modules/typescript/lib/tsserver.js:119496:33)
    at IOSession.Session.onMessage (/Users/ehd/depot-ui/node_modules/typescript/lib/tsserver.js:119516:35)
    at Interface.<anonymous> (/Users/ehd/depot-ui/node_modules/typescript/lib/tsserver.js:120770:27)
    at emitOne (events.js:116:13)
    at Interface.emit (events.js:211:7)
    at Interface._onLine (readline.js:282:10)
    at Interface._normalWrite (readline.js:424:12)
    at Socket.ondata (readline.js:141:10)
    at emitOne (events.js:116:13)
    at Socket.emit (events.js:211:7)
    at addChunk (_stream_readable.js:263:12)
    at readableAddChunk (_stream_readable.js:250:11)
    at Socket.Readable.push (_stream_readable.js:208:10)
    at Pipe.onread (net.js:594:20)

Expected behavior: The code fix suggests various ways to import the enum from file 1. Since completion works, I'd expect the code action to work as well.

Actual behavior: There is a stack trace in the VS Code Output for TypeScript, and no code actions are offered

Related Issues: None found

Duplicate

Most helpful comment

Duplicate of #26333. Should be fixed in typescript@next.

>All comments

Duplicate of #26333. Should be fixed in typescript@next.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jonathandturner picture jonathandturner  路  147Comments

kimamula picture kimamula  路  147Comments

sandersn picture sandersn  路  265Comments

xealot picture xealot  路  150Comments

chanon picture chanon  路  138Comments