Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: readonly tuples were recognized as arrays #1534

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/lib/converter/types.ts
Expand Up @@ -950,8 +950,10 @@ const typeOperatorConverter: TypeConverter<ts.TypeOperatorNode> = {
const args = context.checker
.getTypeArguments(type as ts.TypeReference)
.map((type) => convertType(context, type));

// TODO: wait for https://github.com/microsoft/TypeScript/issues/37711 and remove 'any' cast
const inner =
type.objectFlags & ts.ObjectFlags.Tuple
(context as any).checker.isTupleType(type)
? new TupleType(args)
: new ArrayType(args[0]);

Expand Down
7 changes: 7 additions & 0 deletions src/test/converter/class/class.ts
Expand Up @@ -56,6 +56,13 @@ export class TestClass {
* arrow method
*/
arrowMethod = () => {};

/**
* methodWithComplexArgs short text.
*
* @param readonlyTuple
*/
methodWithComplexArgs(readonlyTuple: readonly [number, string]) {}
}

export class TestSubClass extends TestClass {
Expand Down