Typescript Import #105
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
I don't think this line in the README makes sense ...
At least VS Code red lines it with the error:
This works:
import * as matter from 'gray-matter';Actually nix that. VSCode does not complain but it does not work. This works:
Here's a stackblitz
https://stackblitz.com/edit/gray-matter
Outside of Stackblitz we also need to set this compiler options in
tsconfig.lib:Last thing - for Angular 9 this needs to be added to polyfills.js:
Related SO: https://stackoverflow.com/questions/60772266/getting-buffer-is-not-defined-when-using-gray-matter-in-angular/60772329#60772329
only works if you then call it like
Or import like you suggested
import matter from 'gray-matter'When
it says
For being abandoned the package works well enough. I just had this issue when importing it as there are no types declarations for it.
I created
gray-matter.d.tsin the root of my React project with the following content.Please take into account that I created it based on the documentation and my use case (React + TS), this might not suffice in all cases.
Then I just
import matter from "gray-matter";and all the declared options and types should be available.