Giter VIP home page Giter VIP logo

Comments (5)

jonaskello avatar jonaskello commented on June 9, 2024

For me ts-proto generates code like this:

if (globalThis.Buffer) 

Which leads to typescript error:

error TS7017: Element implicitly has an 'any' type because type 'typeof globalThis' has no index signature.

I want to support both node and browser with the same code. What would be the correct setting?

from ts-proto.

stephenh avatar stephenh commented on June 9, 2024

I want to support both node and browser with the same code. What would be the correct setting?

@jonaskello I guess for env=both, we could make the snippet be if ((globalThis as any).Buffer) and that will remove the TS warning.

If you'd like to submit a PR to do that, that'd be great!

I'm going to close this issue since #999 fixes the behavior with env=browser.

from ts-proto.

jonaskello avatar jonaskello commented on June 9, 2024

Got it. If I can find the time I'll make a PR for that.

I was able to work around it for now. We have all the generated files in a separate package with it's own tsconfig so I could disable the strict any setting for those files without affecting the rest of the app.

from ts-proto.

stephenh avatar stephenh commented on June 9, 2024

@jonaskello it was an easy fix, so I went ahead and pushed out a change to add the as any to the globalThis.Buffer check.

from ts-proto.

jonaskello avatar jonaskello commented on June 9, 2024

@stephenh Thanks for the quick fix. I tried 1.167.7 and it works for the base64FromBytes function but not for the bytesFromBase64 function. So I created PR #1005 with the same fix for that function.

from ts-proto.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.