Closed as not planned
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