Skip to content

langium-zod / AstTypesLike

Interface: AstTypesLike ​

Defined in: types.ts:274

Duck-typed representation of the type model returned by Langium's collectAst() function. Holds the full set of interface types and union/datatype-rule types that the extractor analyses to produce ZodTypeDescriptor records.

Using this interface rather than Langium's concrete AstTypes class means the extractor and tests can supply plain object literals without importing from Langium's grammar internals.

Remarks ​

Obtain a real AstTypesLike value by calling Langium's collectAst(grammar) and casting the result: collectAst(grammar) as unknown as AstTypesLike. In tests, construct plain objects conforming to this interface directly.

Example ​

ts
import type { AstTypesLike } from 'langium-zod';

const astTypes: AstTypesLike = {
  interfaces: [{ name: 'Greeting', properties: [{ name: 'message', type: 'STRING', optional: false }] }],
  unions: []
};

See ​

Properties ​

PropertyTypeDescriptionDefined in
interfacesInterfaceTypeLike[]All interface types defined in the grammar, including those inherited via superTypes.types.ts:276
unionsUnionTypeLike[]All union and datatype-rule types defined in the grammar.types.ts:278

Released under the MIT License.