Skip to content

feat(types): allow string schema with separator for string[] properties - #248

Open
hoanle0126 wants to merge 1 commit into
fastify:mainfrom
hoanle0126:feat/types-separator-string-array
Open

hoanle0126 wants to merge 1 commit into
fastify:mainfrom
hoanle0126:feat/types-separator-string-array

Conversation

@hoanle0126

Copy link
Copy Markdown

Checklist

Description

Fixes #157

Currently, env-schema re-exports Ajv's JSONSchemaType<T> directly. Because env-schema registers the custom modifying separator keyword on type: 'string' schemas to split strings into string[] at runtime, typing an interface property as string[] while defining its schema as { type: 'string', separator: ',' } fails TypeScript validation (Type '"string"' is not assignable to type '"array"').

This PR updates envSchema.JSONSchemaType<T> so properties typed as string[] (or readonly string[]) in T accept either a standard array schema or a type: 'string' schema with a required separator: string property, while preserving automatic generic return type inference on envSchema({ schema }).

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Typing separator with an array instead of just string

1 participant