-
Notifications
You must be signed in to change notification settings - Fork 13.1k
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
export -
export {} -
export default {}
π Version & Regression Information
β― Playground Link
No response
π» Code
reproduce.ts
async function optionalImport(id: string) {
switch (id) {
case 'a':
return await import('./a.js')
case 'a.test':
return await import('./a.test.js')
}
throw new Error()
}
export { optionalImport }a.ts
export const foo = 42π Actual behavior
- When
a.test.ts
import { foo } from './a.js'
describe('reproduce', () => { it('reproduce', () => { foo }) })type is
function optionalImport(id: string): Promise<typeof import("/path/to/reproduce/a.test")>- When
a.test.ts
import { foo } from './a.js'
describe('reproduce', () => { it('reproduce', () => { foo }) })
export {}type is
function optionalImport(id: string): Promise<typeof import("/path/to/reproduce/a.test")>- When
a.test.ts
import { foo } from './a.js'
describe('reproduce', () => { it('reproduce', () => { foo }) })
export default {}type is
function optionalImport(id: string): Promise<typeof import("/path/to/reproduce/a") | typeof import("/path/to/reproduce/a.test")>π Expected behavior
When a.test.ts
import { foo } from './a.js'
describe('reproduce', () => { it('reproduce', () => { foo }) })type is
function optionalImport(id: string): Promise<typeof import("/path/to/reproduce/a") | typeof import("/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