Skip to content

Commit ae7b8a3

Browse files
authored
Replacing any with unknown in the ReadonlyArray type declaration. (openapi-ts#2241)
* Replacing `any` with `unknown` in the `ReadonlyArray` type declaration. * Added changeset.
1 parent 0fb671c commit ae7b8a3

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

src/lib/ts.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -508,7 +508,7 @@ export function tsReadonlyArray(type: ts.TypeNode, injectFooter?: ts.Node[]): ts
508508
!injectFooter.some((node) => ts.isTypeAliasDeclaration(node) && node?.name?.escapedText === "ReadonlyArray")
509509
) {
510510
const helper = stringToAST(
511-
"type ReadonlyArray<T> = [Exclude<T, undefined>] extends [any[]] ? Readonly<Exclude<T, undefined>> : Readonly<Exclude<T, undefined>[]>;",
511+
"type ReadonlyArray<T> = [Exclude<T, undefined>] extends [unknown[]] ? Readonly<Exclude<T, undefined>> : Readonly<Exclude<T, undefined>[]>;",
512512
)[0] as any;
513513
injectFooter.push(helper);
514514
}

test/node-api.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -833,7 +833,7 @@ export type $defs = Record<string, never>;
833833
type ReadonlyArray<T> = [
834834
Exclude<T, undefined>
835835
] extends [
836-
any[]
836+
unknown[]
837837
] ? Readonly<Exclude<T, undefined>> : Readonly<Exclude<T, undefined>[]>;
838838
export const pathsUrlGetParametersQueryStatusValues: ReadonlyArray<paths["/url"]["get"]["parameters"]["query"]["status"]> = ["active", "inactive"];
839839
export const statusValues: ReadonlyArray<components["schemas"]["Status"]> = ["active", "inactive"];

0 commit comments

Comments
 (0)