- Notifications
You must be signed in to change notification settings - Fork 13.2k
Closed as not planned
Closed as not planned
Copy link
Labels
Not a DefectThis behavior is one of several equally-correct optionsThis behavior is one of several equally-correct options
Description
🔎 Search Terms
dynamic import
type union
no
exportexport{}export default{}
🕗 Version & Regression Information
⏯ Playground Link
No response
💻 Code
reproduce.ts
asyncfunctionoptionalImport(id: string){switch(id){case'a': returnawaitimport('./a.js')case'a.test': returnawaitimport('./a.test.js')}thrownewError()}export{optionalImport}a.ts
exportconstfoo=42🙁 Actual behavior
- When
a.test.ts
import{foo}from'./a.js'describe('reproduce',()=>{it('reproduce',()=>{foo})})type is
functionoptionalImport(id: string): Promise<typeofimport("/path/to/reproduce/a.test")>- When
a.test.ts
import{foo}from'./a.js'describe('reproduce',()=>{it('reproduce',()=>{foo})})export{}type is
functionoptionalImport(id: string): Promise<typeofimport("/path/to/reproduce/a.test")>- When
a.test.ts
import{foo}from'./a.js'describe('reproduce',()=>{it('reproduce',()=>{foo})})exportdefault{}type is
functionoptionalImport(id: string): Promise<typeofimport("/path/to/reproduce/a")|typeofimport("/path/to/reproduce/a.test")>🙂 Expected behavior
When a.test.ts
import{foo}from'./a.js'describe('reproduce',()=>{it('reproduce',()=>{foo})})type is
functionoptionalImport(id: string): Promise<typeofimport("/path/to/reproduce/a")|typeofimport("/path/to/reproduce/a.test")>Additional information about the issue
No response
Metadata
Metadata
Assignees
Labels
Not a DefectThis behavior is one of several equally-correct optionsThis behavior is one of several equally-correct options