Skip to content

Commit 4446e1c

Browse files
authored
Enable isolatedDeclarations in tsconfig (#42)
1 parent 41a4245 commit 4446e1c

11 files changed

Lines changed: 59 additions & 20 deletions

File tree

.changeset/tangy-carpets-repeat.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"conformal": patch
3+
---
4+
5+
Enable isolatedDeclarations in tsconfig

AGENTS.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ Exports live in `src/index.ts`, `src/valibot/index.ts`, and `src/zod/index.ts`.
3838
- TypeScript strict mode (see `tsconfig.json` flags).
3939
- ESM-only, isomorphic runtime (no Node-only APIs).
4040
- Prettier formatting: `npm run format:write`.
41-
- Keep runtime deps minimal; `zod` is an optional peer dependency.
41+
- Keep runtime deps minimal; `valibot` is an optional peer dependency.
4242

4343
## Build & test
4444

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,9 @@ Here's a quick example showing how Conformal handles form validation with a user
2828

2929
```typescript
3030
import { parseFormData } from "conformal";
31-
import * as z from "zod"; // Tip: Use conformal's coerce functions for form input preprocessing
31+
import * as z from "zod";
3232

33+
// Tip: Use conformal's coerce functions for form input preprocessing
3334
const schema = z.object({
3435
name: z.string().min(2, "Name must be at least 2 characters"),
3536
email: z.email("Invalid email address"),

package-lock.json

Lines changed: 5 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@
4343
"devDependencies": {
4444
"@changesets/changelog-github": "^0.5.1",
4545
"@changesets/cli": "^2.29.7",
46-
"@types/node": "^24.5.2",
4746
"prettier": "^3.6.2",
4847
"typescript": "^5.9.2",
4948
"valibot": "^1.1.0",

src/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ import { coerceBigint } from "conformal";
155155
console.log(coerceBigint("42")); // 42n
156156
console.log(coerceBigint("9007199254740991")); // 9007199254740991n
157157
console.log(coerceBigint("")); // undefined
158-
console.log(coerceNumber(" ")); // undefined
158+
console.log(coerceBigint(" ")); // undefined
159159
console.log(coerceBigint("abc")); // "abc" (unchanged)
160160
```
161161

src/submission.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,10 @@ export function toSubmission<Output>(
2525
};
2626
}
2727

28-
export function getFormErrors(issues?: ReadonlyArray<StandardSchemaV1.Issue>) {
28+
export function getFormErrors(issues?: ReadonlyArray<StandardSchemaV1.Issue>): {
29+
formErrors: string[];
30+
fieldErrors: Record<string, string[]>;
31+
} {
2932
const formErrors: string[] = [];
3033
const fieldErrors: Record<string, string[]> = {};
3134

src/valibot/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ The Valibot Utilities are provided under the `conformal/valibot` subpath. Valibo
88

99
These coercion pipes handle the conversion from form input values to rich JS types. They convert empty strings to `undefined`, coerce string inputs to appropriate types (numbers, dates, booleans), and handle `File` objects. They're composable pipes that can be combined with any valibot validation schema using `v.pipe()`.
1010

11+
For concrete reference of coercion rules, refer to the [Coerce Functions](../README.md#coerce-functions) documentation.
12+
1113
```typescript
1214
import * as vf from "conformal/valibot";
1315
import * as v from "valibot";

src/valibot/coerce.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@ export function coerceNumber(): v.SchemaWithPipe<
1313
return v.pipe(v.unknown(), v.transform(coerce.coerceNumber));
1414
}
1515

16-
export function coerceBigint() {
16+
export function coerceBigint(): v.SchemaWithPipe<
17+
readonly [v.UnknownSchema, v.TransformAction<unknown, unknown>]
18+
> {
1719
return v.pipe(v.unknown(), v.transform(coerce.coerceBigint));
1820
}
1921

src/zod/schemas.ts

Lines changed: 34 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,35 +12,45 @@ import {
1212
/**
1313
* @deprecated The Zod utilities will be removed in the next major release.
1414
*/
15-
export function string(params?: Parameters<typeof z.string>[0]) {
15+
export function string(
16+
params?: Parameters<typeof z.string>[0],
17+
): z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodString> {
1618
return z.preprocess(coerceString, z.string(params));
1719
}
1820

1921
/**
2022
* @deprecated The Zod utilities will be removed in the next major release.
2123
*/
22-
export function number(params?: Parameters<typeof z.number>[0]) {
24+
export function number(
25+
params?: Parameters<typeof z.number>[0],
26+
): z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodNumber> {
2327
return z.preprocess(coerceNumber, z.number(params));
2428
}
2529

2630
/**
2731
* @deprecated The Zod utilities will be removed in the next major release.
2832
*/
29-
export function bigint(params?: Parameters<typeof z.bigint>[0]) {
33+
export function bigint(
34+
params?: Parameters<typeof z.bigint>[0],
35+
): z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodBigInt> {
3036
return z.preprocess(coerceBigint, z.bigint(params));
3137
}
3238

3339
/**
3440
* @deprecated The Zod utilities will be removed in the next major release.
3541
*/
36-
export function boolean(params?: Parameters<typeof z.boolean>[0]) {
42+
export function boolean(
43+
params?: Parameters<typeof z.boolean>[0],
44+
): z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodBoolean> {
3745
return z.preprocess(coerceBoolean, z.boolean(params));
3846
}
3947

4048
/**
4149
* @deprecated The Zod utilities will be removed in the next major release.
4250
*/
43-
export function date(params?: Parameters<typeof z.date>[0]) {
51+
export function date(
52+
params?: Parameters<typeof z.date>[0],
53+
): z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodDate> {
4454
return z.preprocess(coerceDate, z.date(params));
4555
}
4656

@@ -50,42 +60,55 @@ export function date(params?: Parameters<typeof z.date>[0]) {
5060
export function enum_<const T extends readonly string[]>(
5161
values: T,
5262
params?: Parameters<typeof z.enum>[1],
53-
) {
63+
): z.ZodPipe<
64+
z.ZodTransform<unknown, unknown>,
65+
z.ZodEnum<{
66+
[k in keyof { [k in T[number]]: k }]: { [k in T[number]]: k }[k];
67+
}>
68+
> {
5469
return z.preprocess(coerceString, z.enum(values, params));
5570
}
5671

5772
/**
5873
* @deprecated The Zod utilities will be removed in the next major release.
5974
*/
60-
export function file(params?: Parameters<typeof z.file>[0]) {
75+
export function file(
76+
params?: Parameters<typeof z.file>[0],
77+
): z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodFile> {
6178
return z.preprocess(coerceFile, z.file(params));
6279
}
6380

6481
/**
6582
* @deprecated The Zod utilities will be removed in the next major release.
6683
*/
67-
export function email(params?: Parameters<typeof z.email>[0]) {
84+
export function email(
85+
params?: Parameters<typeof z.email>[0],
86+
): z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodEmail> {
6887
return z.preprocess(coerceString, z.email(params));
6988
}
7089

7190
/**
7291
* @deprecated The Zod utilities will be removed in the next major release.
7392
*/
74-
export function url(params?: Parameters<typeof z.url>[0]) {
93+
export function url(
94+
params?: Parameters<typeof z.url>[0],
95+
): z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodURL> {
7596
return z.preprocess(coerceString, z.url(params));
7697
}
7798

7899
/**
79100
* @deprecated The Zod utilities will be removed in the next major release.
80101
*/
81-
export const object = z.object;
102+
export const object: <T extends z.ZodRawShape>(
103+
shape: T,
104+
) => z.ZodObject<z.core.util.Writeable<T>, z.core.$strip> = z.object;
82105

83106
/**
84107
* @deprecated The Zod utilities will be removed in the next major release.
85108
*/
86109
export function array<T extends z.core.SomeType>(
87110
element: T,
88111
params?: Parameters<typeof z.array>[1],
89-
) {
112+
): z.ZodPipe<z.ZodTransform<unknown[], unknown>, z.ZodArray<T>> {
90113
return z.preprocess(coerceArray, z.array(element, params));
91114
}

0 commit comments

Comments
 (0)