TsCompilerDiagnostic
인터페이스, 작성 분류
TypeShade가 TypeScript 셰이더 코드를 분석하거나 컴파일할 때 만드는 소스 진단입니다.
import type { TsCompilerDiagnostic } from 'typeshade'
설명은 커밋 af54ddad5의 검토된 컴파일러 문서를 번역한 것입니다. 시그니처와 예제 코드는 원문을 따르며, 필요한 경우 설명에 편집상 수정이 반영됩니다.
구문
interface TsCompilerDiagnostic { readonly message: string; readonly fileName: string; readonly line: number; readonly character: number; readonly category: 'error' | 'warning' | 'message'; readonly code?: string; readonly start: number; readonly length: number; readonly endLine: number; readonly endCharacter: number;}설명
line/character는 1부터 시작하며, 외부 도구(language-service.ts를 포함한다)가 이 값을 읽습니다. 두 값은 문제가 된 노드의 시작 위치를 나타냅니다. start와 length는 파일 안의 UTF-16 오프셋입니다. 각각 node.getStart(sourceFile)과 node.getEnd() - node.getStart(sourceFile)에 해당합니다. 그래서 편집기는 글자 하나가 아니라 노드 전체에 밑줄을 그을 수 있습니다. endLine/endCharacter는 start + length 위치를 1부터 세며, line/character와 같은 규칙을 따릅니다.
노드가 없는 진단(지시문 누락, 모듈 전체 백엔드 실패)은 파일의 첫 문장을 범위로 씁니다. 파일에 문장이 없으면 start: 0, length: 0을 씁니다. 구현은 diagnostic.ts의 makeDiagnostic에 있습니다.
인스턴스 속성
message읽기 전용stringfileName읽기 전용stringline읽기 전용numbercharacter읽기 전용numbercategory읽기 전용'error' | 'warning' | 'message'code선택 사항읽기 전용stringstart읽기 전용number진단 범위가 시작하는 UTF-16 오프셋입니다.
length읽기 전용number진단 범위의 길이이며, UTF-16 코드 단위로 셉니다.
endLine읽기 전용numberstart + length위치의 줄 번호이며, 1부터 시작합니다.endCharacter읽기 전용numberstart + length위치의 문자 번호이며, 1부터 시작합니다.
소스
src/compiler/ts/diagnostic.ts, 17행, 커밋 af54ddad5 기준