Giter Site home page Giter Site logo

Comments (5)

stephenh avatar stephenh commented on May 16, 2024

@timostamm hm, does Buffer.from actually work in a browser? I get the declare class Buffer makes the TS compiler happy, but if that line is actually invoked, does it work? Do some of the browsers have Buffer.from implemented?

I think I mentioned it else where, but I'd love to have an integration/angular directory with a super-simple version of your setup that shows an angular app using ts-proto output.

Could we start with that? I.e. a PR for the "toy angular app that uses ts-proto"?

from ts-proto.

timostamm avatar timostamm commented on May 16, 2024

@stephenh, nodes' Buffer is built on top of the ECMA Uint8Array and not available in any browser.

A simple angular setup should not be a problem. A test suite with node and browser coverage on generated code on the other hand is not trivial at all. Let's start simple. I should be able to find some time in the coming week to setup a basic angular example.

from ts-proto.

stephenh avatar stephenh commented on May 16, 2024

not available in any browser

Okay, that makes sense. That's why I was thinking that the proposed fix of declare class Buffer is not really sufficient, because it will make the compile error go away (by making TS think there is a Buffer class), but if the generated code ever calls that method, it won't actually work...

Like we probably need to change the generated code to realize "Buffer is not available" and use something else instead.

in the coming week to setup a basic angular example

Sounds great.

from ts-proto.

yiochen avatar yiochen commented on May 16, 2024

Can we include buffer when generating for browser.

from ts-proto.

stephenh avatar stephenh commented on May 16, 2024

I'm pretty sure this is fixed in v1.48.0. Basically prefixing Buffer with globalThis.Buffer. Let me know if not.

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.