Skip to content

infer emits duplicate TypeScript type names #494

Description

@zharinov

infer can generate two type declarations with the same name. The output is invalid TypeScript.

Case 1: enum labels that differ only by case

cargo run -p plotnik -- infer -l javascript -q 'Q = [Foo: (identifier) FOO: (number)]'
export interface QFoo { $tag: "Foo"; }
export interface QFoo { $tag: "FOO"; }   // duplicate name
export type Q = QFoo | QFoo;

Labels Foo and FOO both map to the name QFoo.

Case 2: explicit annotation collides with a generated name

cargo run -p plotnik -- infer -l javascript -q 'Q = {(identifier) @foo :: QBar { (number) @x } @bar}'
export interface QBar { x: Node; }
export type QBar = Node;                  // duplicate name

The explicit type name QBar on @foo and the name generated for the @bar scope are the same.

Expected

Type names must be unique. Either disambiguate colliding names, or reject the query with a diagnostic.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions