Reputation: 5989
I used yaml https://www.npmjs.com/package/yaml I want to catch the error and to check the insatnce
import * as yaml from 'yaml';
try{
const yamlParse: any = yaml.parse(data);
} catch(err){
if ( err instanceof YAMLError)
...
}
The problem that the compile doesn't know YAMLError I tried also yaml.YAMLError
I define in package.json
"@types/yaml": "1.0.2",
"yaml": "^1.5.1"
Upvotes: 0
Views: 147
Reputation: 3253
you are probably missing the import import { YAMLError } from '@types/yaml';
on top
Upvotes: 1