sveltekit-discriminated-fields 0.1.0 → 0.1.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.
Files changed (2) hide show
  1. package/README.md +6 -2
  2. package/package.json +3 -2
package/README.md CHANGED
@@ -1,10 +1,10 @@
1
1
  # sveltekit-discriminated-fields
2
2
 
3
- Type-safe discriminated union support for SvelteKit form fields.
3
+ Type-safe discriminated union support for SvelteKit remote function form fields.
4
4
 
5
5
  ## The Problem
6
6
 
7
- When using SvelteKit's `form()` with discriminated union schemas (e.g., Zod's `z.discriminatedUnion`), the generated `fields` object is a **union of field objects**. TypeScript only allows access to properties that exist on ALL variants - meaning variant-specific fields are completely inaccessible.
7
+ When using SvelteKit's remote function `form()` with discriminated union schemas (e.g., Zod's `z.discriminatedUnion`), the generated `fields` object is a **union of field objects**. TypeScript only allows access to properties that exist on ALL variants - meaning variant-specific fields are completely inaccessible.
8
8
 
9
9
  Given a typical SvelteKit setup:
10
10
 
@@ -167,6 +167,10 @@ type Payment = DiscriminatedData<typeof payment>;
167
167
 
168
168
  Useful when you need to reference the data type elsewhere, such as defining default values or passing data to other functions.
169
169
 
170
+ ## Note on Runtime Behavior
171
+
172
+ Type narrowing is compile-time only. At runtime, `'width' in shape` will return `true` even when `kindValue === 'circle'`, because all variant fields exist on the underlying object.
173
+
170
174
  ## License
171
175
 
172
176
  MIT
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sveltekit-discriminated-fields",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
4
  "description": "Type-safe discriminated union support for SvelteKit form fields",
5
5
  "type": "module",
6
6
  "exports": {
@@ -16,7 +16,8 @@
16
16
  "build": "tsc -p tsconfig.build.json",
17
17
  "check": "tsc --noEmit",
18
18
  "test:types": "tsc -p test/types/tsconfig.json",
19
- "test": "npm run test:types",
19
+ "test:runtime": "npm run build && tsc -p test/runtime/tsconfig.json && npx tsx test/runtime/has.test.ts",
20
+ "test": "npm run test:types && npm run test:runtime",
20
21
  "prepublishOnly": "npm run test && npm run build"
21
22
  },
22
23
  "keywords": [