ValidationError
이 페이지에서

ValidationError

클래스, 진단 분류

Thrown by validate when a module fails one of the structural rules every emit depends on.

import { ValidationError } from 'typeshade'

시그니처, 설명, 예제는 커밋 c66579bf의 컴파일러 소스에서 그대로 가져온 영어 원문입니다.

구문

class ValidationError extends TypeShadeError

설명

Subclasses TypeShadeError and carries code SD0020, so an instanceof TypeShadeError handler catches it and a handler that switches on code routes it.

Catch this class for ValidationError.diagnostics: validate() collects every error-severity diagnostic before throwing, so one throw reports every failure in the module. .message renders the same list as text; the array is the form to present in a UI or a test report.

예제

예제

import { validate, ValidationError } from 'typeshade'
try {
validate(MODULE)
} catch (e) {
if (e instanceof ValidationError) for (const d of e.diagnostics) report(d.ruleId, d.message)
else throw e
}

생성자

new ValidationError(diags: readonly Diagnostic[])

인스턴스 속성

diagnostics읽기 전용 readonly Diagnostic[]

Every error-severity diagnostic that caused the failure, in the order the rules reported them.

관련 가이드

함께 보기

소스

src/core/passes/validate.ts, 59행, 커밋 c66579bf 기준

이 페이지 편집 문제 보고