jsyaml safeDump typescript support

37 views Asked by At

I am trying to use jsymal.safeDump(somedata). I have run

npm install --save-dev @types/js-yaml

Also have my tsconfig

{
  "compilerOptions": {
    "types": [
      "cypress",
      "js-yaml"
    ]
  },
}

But whenever I use jsyaml.safeDump it shows Property 'safeDump' does not exist on type 'typeof import("/myPath/node_modules/@types/js-yaml/index")

It can be solved using @ts-ignore

But is there any other way I can use safeDump without ignoring typescript?

1

There are 1 answers

0
nur_riyad On BEST ANSWER

I think safeDump() is deprecated from the js-yaml version 4.x. To use safeDump() with type seftey use the js-yaml version 3.x with supported type module.

https://www.npmjs.com/package/js-yaml/v/3.14.1