You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This change adds support for handling generic interfaces in the
`InterfaceTypeHandler`. Previously, the handler only supported
non-generic interfaces. Now, if an interface has type parameters,
the handler will generate a function that takes the type parameters
as arguments and returns the composite type for the interface.
The changes include:
- Adding support for parsing type parameters and heritage clauses
in the `handle` method.
- Implementing the `createGenericInterfaceFunction` method to
generate the function for generic interfaces.
- Updating the `parseGenericTypeCall` method to handle generic
type references in heritage clauses.
These changes allow the `InterfaceTypeHandler` to correctly
generate the TypeBox schema for generic interfaces, which is
necessary for supporting more complex validation schemas.
Copy file name to clipboardExpand all lines: ARCHITECTURE.md
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -221,7 +221,7 @@ This directory contains a collection of specialized handler modules, each respon
221
221
**Object-Like Type Handlers** (extend `ObjectLikeBaseHandler`):
222
222
223
223
- <mcfilename="object-type-handler.ts"path="src/handlers/typebox/object/object-type-handler.ts"></mcfile>: Handles TypeScript object types and type literals.
224
-
- <mcfilename="interface-type-handler.ts"path="src/handlers/typebox/object/interface-type-handler.ts"></mcfile>: Handles TypeScript interface declarations, including support for interface inheritance using `Type.Composite` to combine base interfaces with extended properties.
224
+
- <mcfilename="interface-type-handler.ts"path="src/handlers/typebox/object/interface-type-handler.ts"></mcfile>: Handles TypeScript interface declarations, including support for interface inheritance using `Type.Composite` to combine base interfaces with extended properties. Supports generic interfaces with type parameters, generating parameterized functions that accept TypeBox schemas as arguments. Handles generic type calls in heritage clauses, converting expressions like `A<number>` to `A(Type.Number())` for proper TypeBox composition.
225
225
226
226
**Collection Type Handlers** (extend `CollectionBaseHandler`):
227
227
@@ -257,7 +257,7 @@ This directory contains a collection of parser classes, each extending the `Base
257
257
- <mcfilename="parse-imports.ts"path="src/parsers/parse-imports.ts"></mcfile>: Implements the `ImportParser` class, responsible for resolving and processing TypeScript import declarations.
258
258
- <mcfilename="parse-type-aliases.ts"path="src/parsers/parse-type-aliases.ts"></mcfile>: Implements the `TypeAliasParser` class, responsible for processing TypeScript `type alias` declarations.
259
259
- <mcfilename="parse-function-declarations.ts"path="src/parsers/parse-function-declarations.ts"></mcfile>: Implements the `FunctionDeclarationParser` class, responsible for processing TypeScript function declarations and converting them to TypeBox function schemas.
260
-
- <mcfilename="parse-interfaces.ts"path="src/parsers/parse-interfaces.ts"></mcfile>: Implements the `InterfaceParser` class, responsible for processing TypeScript interface declarations with support for inheritance through dependency ordering and `Type.Composite` generation.
260
+
- <mcfilename="parse-interfaces.ts"path="src/parsers/parse-interfaces.ts"></mcfile>: Implements the `InterfaceParser` class, responsible for processing TypeScript interface declarations with support for inheritance through dependency ordering and `Type.Composite` generation. Handles generic interfaces by generating parameterized functions with type parameters that accept TypeBox schemas as arguments.
0 commit comments