microsoft / microsoft/TypeScript

Preserve type aliases on implement interface

Open
#36,761 0 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Experience Enhancement Suggestion
Dominant language
Go
Stars
111k
Forks
14.3k
Avg merge
2d 4h
Merged PRs (30d)
132

Description

From https://github.com/microsoft/vscode/issues/90061

TypeScript Version: 3.8.1-rc

Search Terms:

  • quick fix
  • implement interface

Repo

export type UrlString = string;
export type UUID = string;

export interface I_IdToUrlMapper {
	mapIdToUrl(id: UUID): UrlString
	mapUrlToId(url: UrlString): UUID
}

export class IdToUrlMapper implements I_IdToUrlMapper {

}

Run implement interface on IdToUrlMapper

Expected behavior:
Type aliases are preserved

export class IdToUrlMapper implements I_IdToUrlMapper {
    mapIdToUrl(id: UUID): UrlString {
        throw new Error("Method not implemented.");
    }
    mapUrlToId(url: UrlString): UUID {
        throw new Error("Method not implemented.");
    }
}

Actual behavior:
Both methods use string:

export class IdToUrlMapper implements I_IdToUrlMapper {
    mapIdToUrl(id: string): string {
        throw new Error("Method not implemented.");
    }
    mapUrlToId(url: string): string {
        throw new Error("Method not implemented.");
    }
}

Related Issues

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the TypeScript language-service “implement interface” quick fix using the reproduced IdToUrlMapper example. Compare the generated method signatures with the expected output, and verify that type aliases such as UUID and UrlString are preserved rather than reduced to string.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.