@kubb/plugin-faker 5.0.1 → 5.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +2 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +4 -0
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
package/dist/index.d.ts
CHANGED
|
@@ -202,6 +202,10 @@ type PrinterFakerOptions = {
|
|
|
202
202
|
* Set while printing the members of a union (`oneOf`). Object properties then index their
|
|
203
203
|
* type as `(NonNullable<T> & Record<K, unknown>)[K]` instead of `NonNullable<T>[K]`, so a key
|
|
204
204
|
* carried by only some branches stays valid (a plain index would be a TS2339).
|
|
205
|
+
*
|
|
206
|
+
* Referenced object factories also receive their explicit default type argument (`object`).
|
|
207
|
+
* This prevents a surrounding generic helper from inferring `TData` as `Partial<T>` when the
|
|
208
|
+
* factory is called without override data, which would make required properties optional.
|
|
205
209
|
*/
|
|
206
210
|
nestedInUnion?: boolean;
|
|
207
211
|
nodes?: PrinterFakerNodes;
|
package/dist/index.js
CHANGED
|
@@ -344,7 +344,7 @@ function filterUsedImports(imports, text, skipImportNames = []) {
|
|
|
344
344
|
return imports.filter((entry) => {
|
|
345
345
|
return getImportNames(entry).some((name) => {
|
|
346
346
|
if (skip.has(name)) return false;
|
|
347
|
-
return new RegExp(`\\b${escapeRegExp(name)}\\b(?=\\s
|
|
347
|
+
return new RegExp(`\\b${escapeRegExp(name)}\\b(?=\\s*[<(])`).test(text);
|
|
348
348
|
});
|
|
349
349
|
});
|
|
350
350
|
}
|
|
@@ -1041,7 +1041,7 @@ const printerFaker = ast.createPrinter((options) => {
|
|
|
1041
1041
|
if (this.options.schemaName && refName === this.options.schemaName) return this.options.typeName ? `undefined as unknown as ${this.options.typeName}` : "undefined as unknown";
|
|
1042
1042
|
const resolvedName = node.ref ? this.options.resolver.name(refName) : refName;
|
|
1043
1043
|
if (!this.options.nestedInObject) return `${resolvedName}(data)`;
|
|
1044
|
-
return `${resolvedName}()`;
|
|
1044
|
+
return `${resolvedName}${this.options.nestedInUnion && (node.schema?.type === "object" || node.schema?.type === "intersection") ? "<object>" : ""}()`;
|
|
1045
1045
|
},
|
|
1046
1046
|
enum(node) {
|
|
1047
1047
|
return fakerKeywordMapper.enum(getEnumValues(node).map(parseEnumValue), this.options.typeName);
|