Skip to content

Commit 699ccae

Browse files
authoredOct 4, 2023
Export jsdoc with @deprecated when building (#2717)
* export with comments * Avoid using arrow function in class * to jsdoc
1 parent 15ba5a4 commit 699ccae

File tree

3 files changed

+35
-26
lines changed

3 files changed

+35
-26
lines changed
 

‎configs/tsconfig.cjs.json

+1-2
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@
55
"outDir": "../lib",
66
"declaration": true,
77
"declarationMap": false,
8-
"sourceMap": false,
9-
"removeComments": true
8+
"sourceMap": false
109
},
1110
"exclude": ["../src/**/__tests__", "../playground.ts"]
1211
}

‎deno/lib/types.ts

+17-12
Original file line numberDiff line numberDiff line change
@@ -849,16 +849,17 @@ export class ZodString extends ZodType<string, ZodStringDef> {
849849
return { status: status.value, value: input.data };
850850
}
851851

852-
protected _regex = (
852+
protected _regex(
853853
regex: RegExp,
854854
validation: StringValidation,
855855
message?: errorUtil.ErrMessage
856-
) =>
857-
this.refinement((data) => regex.test(data), {
856+
) {
857+
return this.refinement((data) => regex.test(data), {
858858
validation,
859859
code: ZodIssueCode.invalid_string,
860860
...errorUtil.errToObj(message),
861861
});
862+
}
862863

863864
_addCheck(check: ZodStringCheck) {
864865
return new ZodString({
@@ -980,26 +981,30 @@ export class ZodString extends ZodType<string, ZodStringDef> {
980981
* @deprecated Use z.string().min(1) instead.
981982
* @see {@link ZodString.min}
982983
*/
983-
nonempty = (message?: errorUtil.ErrMessage) =>
984-
this.min(1, errorUtil.errToObj(message));
984+
nonempty(message?: errorUtil.ErrMessage) {
985+
return this.min(1, errorUtil.errToObj(message));
986+
}
985987

986-
trim = () =>
987-
new ZodString({
988+
trim() {
989+
return new ZodString({
988990
...this._def,
989991
checks: [...this._def.checks, { kind: "trim" }],
990992
});
993+
}
991994

992-
toLowerCase = () =>
993-
new ZodString({
995+
toLowerCase() {
996+
return new ZodString({
994997
...this._def,
995998
checks: [...this._def.checks, { kind: "toLowerCase" }],
996999
});
1000+
}
9971001

998-
toUpperCase = () =>
999-
new ZodString({
1002+
toUpperCase() {
1003+
return new ZodString({
10001004
...this._def,
10011005
checks: [...this._def.checks, { kind: "toUpperCase" }],
10021006
});
1007+
}
10031008

10041009
get isDatetime() {
10051010
return !!this._def.checks.find((ch) => ch.kind === "datetime");
@@ -4853,7 +4858,7 @@ type CustomParams = CustomErrorParams & { fatal?: boolean };
48534858
export const custom = <T>(
48544859
check?: (data: unknown) => any,
48554860
params: string | CustomParams | ((input: any) => CustomParams) = {},
4856-
/*
4861+
/**
48574862
* @deprecated
48584863
*
48594864
* Pass `fatal` into the params object instead:

‎src/types.ts

+17-12
Original file line numberDiff line numberDiff line change
@@ -849,16 +849,17 @@ export class ZodString extends ZodType<string, ZodStringDef> {
849849
return { status: status.value, value: input.data };
850850
}
851851

852-
protected _regex = (
852+
protected _regex(
853853
regex: RegExp,
854854
validation: StringValidation,
855855
message?: errorUtil.ErrMessage
856-
) =>
857-
this.refinement((data) => regex.test(data), {
856+
) {
857+
return this.refinement((data) => regex.test(data), {
858858
validation,
859859
code: ZodIssueCode.invalid_string,
860860
...errorUtil.errToObj(message),
861861
});
862+
}
862863

863864
_addCheck(check: ZodStringCheck) {
864865
return new ZodString({
@@ -980,26 +981,30 @@ export class ZodString extends ZodType<string, ZodStringDef> {
980981
* @deprecated Use z.string().min(1) instead.
981982
* @see {@link ZodString.min}
982983
*/
983-
nonempty = (message?: errorUtil.ErrMessage) =>
984-
this.min(1, errorUtil.errToObj(message));
984+
nonempty(message?: errorUtil.ErrMessage) {
985+
return this.min(1, errorUtil.errToObj(message));
986+
}
985987

986-
trim = () =>
987-
new ZodString({
988+
trim() {
989+
return new ZodString({
988990
...this._def,
989991
checks: [...this._def.checks, { kind: "trim" }],
990992
});
993+
}
991994

992-
toLowerCase = () =>
993-
new ZodString({
995+
toLowerCase() {
996+
return new ZodString({
994997
...this._def,
995998
checks: [...this._def.checks, { kind: "toLowerCase" }],
996999
});
1000+
}
9971001

998-
toUpperCase = () =>
999-
new ZodString({
1002+
toUpperCase() {
1003+
return new ZodString({
10001004
...this._def,
10011005
checks: [...this._def.checks, { kind: "toUpperCase" }],
10021006
});
1007+
}
10031008

10041009
get isDatetime() {
10051010
return !!this._def.checks.find((ch) => ch.kind === "datetime");
@@ -4853,7 +4858,7 @@ type CustomParams = CustomErrorParams & { fatal?: boolean };
48534858
export const custom = <T>(
48544859
check?: (data: unknown) => any,
48554860
params: string | CustomParams | ((input: any) => CustomParams) = {},
4856-
/*
4861+
/**
48574862
* @deprecated
48584863
*
48594864
* Pass `fatal` into the params object instead:

0 commit comments

Comments
 (0)
Please sign in to comment.