KS5020
In un file strict, un valore il cui tipo il controllo non riesce a dimostrare. Scrivi il tipo dove il valore è dichiarato. In un file strict è un errore, e lo script non parte finché non viene corretto:
<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="'{"n": 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.nLo stesso codice segnala una variabile che riceve valori di tipi diversi, un parametro di lambda da cui non si ricava alcun tipo (scrivi fn(n: number) => ...), una funzione il cui risultato non si può dedurre (scrivi fn first(items: list): string) e un campo senza tipo né valore predefinito.