Skip to content

Circular type exported from namespace cannot be named #2505

@Retsam

Description

@Retsam

Steps to reproduce

// some-library.d.ts
type T = { value: string | T };

declare namespace ns {
  export type NsValue = T;
  export function fn(val: ns.NsValue): void;
}

export { ns };
import { ns } from "test-library";

export const fn = (val: ns.NsValue) => ns.fn(val);

Here's a repro repo: https://github.com/Retsam/ts-go-namespace-declaration-emit-issue

Behavior with typescript@5.9

No error, emits:

import { ns } from "test-library";
export declare const fn: (val: ns.NsValue) => void;

Behavior with tsgo

Exported variable 'fn' has or is using name 'T' from external module "/Users/hunter2/ts-go-issue/types/test-library/index" but cannot be named.

4 export const fn = (val: ns.NsValue) => ns.fn(val);

There's a a few other declaration tickets open, but none of them looked like close matches to this behavior.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions