openapi-typescript
Advanced tools
Comparing version 6.5.2 to 6.5.3
# openapi-typescript | ||
## 6.5.3 | ||
### Patch Changes | ||
- [#1320](https://github.com/drwpow/openapi-typescript/pull/1320) [`3cf78b9`](https://github.com/drwpow/openapi-typescript/commit/3cf78b920ab23624c0524e0d58338ee66acad799) Thanks [@duncanbeevers](https://github.com/duncanbeevers)! - Wrap nested readonly types in parentheses, allowing for nested immutable arrays | ||
## 6.5.2 | ||
@@ -4,0 +10,0 @@ |
@@ -17,2 +17,3 @@ import c from "ansi-colors"; | ||
const TS_UNION_INTERSECTION_RE = /[&|]/; | ||
const TS_READONLY_RE = /^readonly\s+/; | ||
const JS_OBJ_KEY = /^(\d+|[A-Za-z_$][A-Za-z0-9_$]*)$/; | ||
@@ -128,3 +129,3 @@ export function walk(obj, cb, path = []) { | ||
function parenthesise(type) { | ||
return TS_UNION_INTERSECTION_RE.test(type) ? `(${type})` : type; | ||
return TS_UNION_INTERSECTION_RE.test(type) || TS_READONLY_RE.test(type) ? `(${type})` : type; | ||
} | ||
@@ -131,0 +132,0 @@ export function tsArrayOf(type) { |
{ | ||
"name": "openapi-typescript", | ||
"description": "Generate runtime-free TypeScript types from Swagger OpenAPI specs", | ||
"version": "6.5.2", | ||
"version": "6.5.3", | ||
"author": { | ||
@@ -6,0 +6,0 @@ "name": "Drew Powers", |
@@ -35,2 +35,3 @@ import c from "ansi-colors"; | ||
const TS_UNION_INTERSECTION_RE = /[&|]/; | ||
const TS_READONLY_RE = /^readonly\s+/; | ||
const JS_OBJ_KEY = /^(\d+|[A-Za-z_$][A-Za-z0-9_$]*)$/; | ||
@@ -172,5 +173,5 @@ | ||
/** if the type has & or | we should parenthesise it for safety */ | ||
/** add parenthesis around union, intersection (| and &) and readonly types */ | ||
function parenthesise(type: string) { | ||
return TS_UNION_INTERSECTION_RE.test(type) ? `(${type})` : type; | ||
return TS_UNION_INTERSECTION_RE.test(type) || TS_READONLY_RE.test(type) ? `(${type})` : type; | ||
} | ||
@@ -177,0 +178,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
408789
6864