Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Typescript error: gray-matter.d.ts(43,11): error TS2304: Cannot find name 'Buffer' #68

Open
michaeljota opened this issue Apr 15, 2018 · 4 comments
Labels
bug A problem that causes an error in the library at compilation or runtime.

Comments

@michaeljota
Copy link

Since Buffer is not available in the browser, when compiling without node types, this error is throw.

@bniedermeyer
Copy link

This unfortunately also makes the library almost unusable for Angular based projects since they no longer supply shims for node types that don't exist in the browser in the Angular CLI.

@robertmassaioli robertmassaioli added the bug A problem that causes an error in the library at compilation or runtime. label Jan 16, 2019
@robertmassaioli
Copy link
Collaborator

Since Buffer is not available in the browser, when compiling...

This is an excellent point.

Looking at the typings, it seems that Buffer is used, unnecessarily in one place and for an input type in another. I think we can remove it from the typings and provide and example in the Readme to show how to use buffers instead of strings.

However, to make such a change would be a breaking change, not to the APIs but to the types.

@jonschlinkert my proposal would be:

  1. We fix the typings to remove all references to Buffer. These changes are pushed to a 5.x branch.
  2. We update the README file to explain how to use Buffer with gray-matter.
  3. We release the 5.x branch when ready.

@jonschlinkert What is the process WRT releasing a new major release? When we are ready?

@patarapolw
Copy link

I can easily install @types/node, but apparently, this is not compatible with @types/webpack-env

I found a solution, if I need to browserify or Webpack,

type Buffer = any

@cj81499
Copy link

cj81499 commented Jun 25, 2020

This makes gray-matter difficult to use in Deno. It seems to work (without proper types) from https://jspm.dev, but fails from https://cdn.pika.dev (but types work).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A problem that causes an error in the library at compilation or runtime.
Projects
None yet
Development

No branches or pull requests

5 participants