microsoft / microsoft/DefinitelyTyped-tools

getDTName logic is brittle

Open
#1,125 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
423
Forks
237
Avg merge
18h 18m
Merged PRs (30d)
11

Description

The current logic in https://github.com/microsoft/DefinitelyTyped-tools/blob/HEAD/packages/dts-gen/src/names.ts#L1 is basically "if it's a scoped package, replace the slash with __".

Unfortunately, this fails in the event of an existing package with a double underscore. I don't have a concrete existing example, so it's not an urgent problem :-) but, eg the types for @eslint/js are in @types/eslint__js, but anyone could make a package eslint__js, and then what would the types package for that be?

Obviously changing existing DT package names would be very disruptive, but if we could come up with, for non-scoped packages that have a double underscore, a new convention, then that'd close this theoretical hole (even if nobody ever needed it).

One idea is eslint__jseslint____js, eg replace __ with ____. this would mean that eslint____js (4 underscores) would become 8, etc, but the likelihood of this running into package name limits is even lower than the likelihood of 2 underscores being used.

Essentially, any replacement scheme would make __ in a regular package name be transformed into something else, and that would require a similar cascade as above.

Contributor guide

No contributing guide indexed for this repository

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 in packages/dts-gen/src/names.ts at the getDTName logic. Determine a naming convention that distinguishes scoped packages from unscoped packages containing double underscores while preserving existing DefinitelyTyped package names. Done means the convention resolves the described collision cases without requiring disruptive renames.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
tooling
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.