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

Property 'Buffer' does not exist on type 'typeof globalThis' #247

Open
yijiebaiyi opened this issue Dec 28, 2023 · 2 comments
Open

Property 'Buffer' does not exist on type 'typeof globalThis' #247

yijiebaiyi opened this issue Dec 28, 2023 · 2 comments
Labels
bug Something isn't working help wanted Extra attention is needed

Comments

@yijiebaiyi
Copy link

Automatically generating ts files is successful, but running npm run build reports an error: Property 'Buffer' does not exist on type 'typeof globalThis'

The code snippet where the error occurred:

function base64FromBytes(arr: Uint8Array): string {
  if (globalThis.Buffer) {
    return globalThis.Buffer.from(arr).toString("base64");
  } else {
    const bin: string[] = [];
    arr.forEach((byte) => {
      bin.push(globalThis.String.fromCharCode(byte));
    });
    return globalThis.btoa(bin.join(""));
  }
}

the proto message has type bytes:

message Event {
    string department        = 20; 
    string job               = 21;  
    string picturePath       = 22; 
    bytes imageData          = 23; 
    string createdAt         = 24; 
    uint32 keyPartType       = 25; 
}

my env:
node version: v14.18.3
protoc version: 3.13.0
protoc-gen-ts version: 0.8.7

what should I do?

@yijiebaiyi
Copy link
Author

make some additions

ts-node version: 8.6.2
tsconfig.json:

{
  "compilerOptions": {
    "module": "commonjs",
    "declaration": true,
    "removeComments": true,
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "target": "es2017",
    "sourceMap": true,
    "outDir": "./dist",
    "baseUrl": "./",
    "incremental": true,
    "esModuleInterop": true
  },
  "include": ["src/**/*"],
  "exclude": ["node_modules", "dist"]
}

@thesayyn
Copy link
Owner

thesayyn commented Mar 1, 2024

This sounds like a typechecking issue, as i never tested the rust implementation for type errors.

@thesayyn thesayyn added bug Something isn't working enhancement New feature or request help wanted Extra attention is needed and removed enhancement New feature or request labels Mar 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants