microsoft/typespec
Publicmirrored from https://github.com/microsoft/typespecAvailable
packages/events/src/validate.ts
13lines · modecode
| 1 | import type { Program, Union } from "@typespec/compiler"; |
| 2 | import { unsafe_getEventDefinitions } from "./experimental/index.js"; |
| 3 | import { EventsStateKeys } from "./lib.js"; |
| 4 | export function $onValidate(program: Program) { |
| 5 | checkForInvalidEvents(program); |
| 6 | } |
| 7 | |
| 8 | function checkForInvalidEvents(program: Program) { |
| 9 | program.stateSet(EventsStateKeys.events).forEach((events) => { |
| 10 | const [, diagnostics] = unsafe_getEventDefinitions(program, events as Union); |
| 11 | program.reportDiagnostics(diagnostics); |
| 12 | }); |
| 13 | } |
| 14 | |