function parseAndValidate(obj: unknown): ParsedObj | void {
try {
// conducting various validations
return parsedObj
} catch {
throw new Error('obj is invalid')
}
}
const parsedObj = parseAndValidate(obj)
I'm seeking clarification on two points:
- Why does the LSP identify
parsedObj
as typeany
? What's the reason behind this? - Why doesn't it identify
parsedObj
as typeParsedObj
, considering that an error will be triggered otherwise?
Due to this, I have to manually specify the type using as ParsedObj
.