benjamn / benjamn/ast-types

Does `TSTypeParameter.name` need to be all of `IdentifierKind` types?

Open
#939 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
1.2k
Forks
194
Avg merge
22h 43m
Merged PRs (30d)
10

Description

It seems that in recent version [TSTypeParameter.name](https://github.com/benjamn/ast-types/blob/6e4d91213c27b6ba76a747c45200aa0e8498b176/src/gen/namedTypes.ts#L1489) has been extended to be `string | K.IdentifierKind`.

This results in a weird type cycle, where a name can be any identifier including `TSTypeParameter` again. Causing client code to deal with it somehow. It seems that [babel-parser tests](https://github.com/babel/babel/tree/main/packages/babel-parser/test/fixtures/typescript) do not have any examples of generating anything apart from plain `Identifier` (or `string`) for `TStypeParameter.name`.

Should this be constrained a bit more?

Contributor guide

No contributing guide indexed for this repository

Research direction

Inspect src/gen/namedTypes.ts around TSTypeParameter.name and compare its current type with the Babel parser TypeScript fixtures linked in the issue. Determine whether those fixtures only produce Identifier or string values, then add or update the relevant type coverage so the accepted values no longer create the reported recursive cycle.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
devtools
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.