-
Notifications
You must be signed in to change notification settings - Fork 13.1k
Closed
Labels
BugA bug in TypeScriptA bug in TypeScriptFix AvailableA PR has been opened for this issueA PR has been opened for this issueRescheduledThis issue was previously scheduled to an earlier milestoneThis issue was previously scheduled to an earlier milestone
Milestone
Description
Bug Report
π Search Terms
import, elision, elided, default
π Version & Regression Information
- This changed between versions 4.1.5 and 4.2.3
β― Playground Link
π» Code
// @showEmit
import MyFunction from "./MyComponent";
MyFunction({msg: "Hello World"}); // Runtime error, MyFunction was not imported
// @filename: MyComponent.ts
interface MyFunction { msg: string; } // adding export here fixes
export const MyFunction = ({ msg }: MyFunction) => console.log(`Got message "${msg}"`); // removing export here fixes
export default MyFunction;π Actual behavior
The import MyFunction from "./MyComponent"; is elided from the output - causing the MyFunction(x) line to crash.
π Expected behavior
Expected the import not to be elided since it is exporting a value, and the import is used as a value.
Alternatively, an error about this pattern of default export + named export + non-exported type would be helpful. This is a bizarre, accidental, export pattern, and it was an easy fix, but it was a bit tricky to track down. (We found this when switching a large codebase from babel compilation to TS compilation)
robpalme
Metadata
Metadata
Assignees
Labels
BugA bug in TypeScriptA bug in TypeScriptFix AvailableA PR has been opened for this issueA PR has been opened for this issueRescheduledThis issue was previously scheduled to an earlier milestoneThis issue was previously scheduled to an earlier milestone