0

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"

1 Answer 1

1

you are probably missing the import import { YAMLError } from '@types/yaml'; on top

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.