Skip to content

Exported types in an ESM namespace are not "nameable" (have repro) #61700

Closed as not planned
@jasonkuhrt

Description

@jasonkuhrt

🔎 Search Terms

inference
"type cannot be named"
"package exports"

🕗 Version & Regression Information

I don't know if this is a bug or a feature request. The behaviour seems wrong to me but I am not aware of a reference/documentation actually stating how its supposed to work so...

⏯ Playground Link

https://github.com/jasonkuhrt/repro-ts-lib-types-reference

💻 Code

Check the repo as the scenario spans multiple modules and packages to reproduce.

🙁 Actual behavior

In short I expect that as a library author types exported like as follows will be "nameable" in inference cases in downstream consumer code:

Library Package:

// index.ts
export * as Bar from './bar.ts

// bar.ts
export interface A {}

Project Package:

// main.ts
import * as Thing from './thing.js'
import * as Resources from './resources.js'

const thing = Thing.create(Resources.A)
//    ^^^^^ "... cannot be named ..." error

// thing.ts
export create = <t>(t:t)=>t

// resources.ts
import { Bar } from 'library-package'
declare const A: Bar.A

🙂 Expected behavior

I expect thing to infer to Bar.A just fine.

Additional information about the issue

Really curious about this one!

Metadata

Metadata

Assignees

No one assigned

    Labels

    Design LimitationConstraints of the existing architecture prevent this from being fixed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions