Skip to content

Commit

Permalink
feat(typescript-estree): add in and out to TSTypeParameter
Browse files Browse the repository at this point in the history
  • Loading branch information
sosukesuzuki committed May 17, 2022
1 parent 5d9f45f commit 0a74ba8
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions packages/typescript-estree/src/convert.ts
Original file line number Diff line number Diff line change
Expand Up @@ -671,6 +671,26 @@ export class Converter {
: node.elements.map(element => this.convertChild(element));
}

private convertTypeParamVariances(
modifiers?: ts.ModifiersArray,
): Pick<TSESTree.TSTypeParameter, 'in' | 'out'> {
const result: Pick<TSESTree.TSTypeParameter, 'in' | 'out'> = {
in: undefined,
out: undefined,
};
if (!modifiers) {
return result;
}
for (const modifier of modifiers) {
if (modifier.kind === SyntaxKind.InKeyword) {
result.in = true;
} else if (modifier.kind === SyntaxKind.OutKeyword) {
result.out = true;
}
}
return result;
}

/**
* Applies the given TS modifiers to the given result object.
* @param result
Expand Down Expand Up @@ -2342,6 +2362,7 @@ export class Converter {
? this.convertType(node.constraint)
: undefined,
default: node.default ? this.convertType(node.default) : undefined,
...this.convertTypeParamVariances(node.modifiers),
});
}

Expand Down

0 comments on commit 0a74ba8

Please sign in to comment.