benjamn / benjamn/ast-types

TSTypeOperatorBuilder interface call signature should accept a typeAnnotation parameter

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

Description

The current TSTypeOperatorBuilder interface:

```ts
export interface TSTypeOperatorBuilder {
(operator: string): namedTypes.TSTypeOperator;
from(
params: {
comments?: K.CommentKind[] | null;
loc?: K.SourceLocationKind | null;
operator: string;
typeAnnotation: K.TSTypeKind;
}
): namedTypes.TSTypeOperator;
}
```

Since the typeAnnotation is required, attempting to create a TSTypeOperator by calling the function isn't possible. It can only be done by using the `.from()` method instead.

The call signature should have a second parameter for the typeAnnotation

```ts
export interface TSTypeOperatorBuilder {
(operator: string, typeAnnotation: K.TSTypeKind): namedTypes.TSTypeOperator;
...
}
```

Some code to reproduce the error can be viewed here.

https://astexplorer.net/#/gist/2328ddf6e049e141a5db2293d6d67668/27d29233f044354b19d639701ceff667448b4b55

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with the TSTypeOperatorBuilder interface shown in the issue and use the linked AST Explorer reproduction to confirm the current type error. Update the call signature so it accepts operator and typeAnnotation, then verify that the reproduced call type-checks while the existing .from() form remains valid.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.