KScript 문서
KO

언어

영어에서 자동 번역되었습니다. 원문은 영어입니다.

오류 코드

KS5020

strict 파일에서 검사기가 타입을 증명할 수 없는 값입니다. 값을 선언하는 곳에 타입을 쓰세요. strict 파일에서는 오류이며, 고칠 때까지 스크립트가 실행되지 않습니다:

<strict />

<let name="names" value="[]" /> <!-- error: write the item type, such as $names: string[] = [] -->
<let name="found" value="null" /> <!-- error: write its type: $found: string? = null -->
<let name="data" type="any" value="'{&quot;n&quot;: 1}'->convert(from: json)" />
<let name="n" value="$data.n" /> <!-- error: the checker can't tell what $n holds; write $n: int = $data.n -->
strict

$names = []                   // error: write the item type, such as $names: string[] = []
$found = null                 // error: write its type: $found: string? = null
$data: any = '{"n": 1}'->convert(from: json)
$n = $data.n                  // error: the checker can't tell what $n holds; write $n: int = $data.n

같은 코드로 서로 다른 타입의 값이 주어지는 변수, 타입을 가져올 곳이 없는 lambda 매개변수(fn(n: number) => ...로 쓰세요), 결과를 알아낼 수 없는 함수(fn first(items: list): string로 쓰세요), 타입도 기본값도 없는 필드도 보고됩니다.