Skip to content

Commit ef23947

Browse files
authored
Replacing any with unknown in the ReadonlyArray type declaration. (#2241)
* Replacing `any` with `unknown` in the `ReadonlyArray` type declaration. * Added changeset.
1 parent b19f432 commit ef23947

File tree

3 files changed

+7
-2
lines changed

3 files changed

+7
-2
lines changed

.changeset/wet-cougars-behave.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"openapi-typescript": patch
3+
---
4+
5+
Replacing `any` with `unknown` in the `ReadonlyArray` type declaration.

packages/openapi-typescript/src/lib/ts.ts

+1-1
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
}

packages/openapi-typescript/test/node-api.test.ts

+1-1
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)