Git Product home page Git Product logo

Comments (9)

arboleya avatar arboleya commented on September 27, 2024 2

@Dhaiwat10 @nedsalk Can we close this?

from fuels-ts.

nedsalk avatar nedsalk commented on September 27, 2024 1

@Dhaiwat10 summed it up nicely in #1867 (comment). Typescript inferring string[] instead of [string] for ['0xabc'] is default behavior, but it'd be superseded by the generated typegen type which would constrain it to [string].

from fuels-ts.

nedsalk avatar nedsalk commented on September 27, 2024 1

@arboleya yes, as @petertonysmith94 showcased PredicateParams<T> can already take in a generic which is used to type-constrain the inputs.

from fuels-ts.

arboleya avatar arboleya commented on September 27, 2024

Since we expect the data to satisfy the InputData[] shape, I can't see how it could be a non-array.

Unless we'd define it as InputData | InputData[], it all depends on how this is expected on the Sway side of things.

cc @nedsalk

from fuels-ts.

arboleya avatar arboleya commented on September 27, 2024

I wonder if #1867 wouldn't also close this issue.

cc @petertonysmith94

from fuels-ts.

petertonysmith94 avatar petertonysmith94 commented on September 27, 2024

@arboleya It doesn't close this issue.

#1867 references added the known types from the given generated ABI, and I believe this is referencing infer the types at a class level.

from fuels-ts.

petertonysmith94 avatar petertonysmith94 commented on September 27, 2024

Out of curiosity - how often is the API consumed in this way - whereby, the user isn't using the typegen?

bytecode = fs.readFile(...)
new Predicate({ bytecode, ... })

from fuels-ts.

arboleya avatar arboleya commented on September 27, 2024

This is not recommended, so I'd say almost never.

from fuels-ts.

petertonysmith94 avatar petertonysmith94 commented on September 27, 2024

I'd favour not implementing this change.

The typegen is adding known types to the predicate, therefore, this change only benefits users on this alternative instantiation path. IMO the following type inference is adequate for non-typegen instantiation.

Screenshot 2024-03-13 at 10 57 28

or they may add the type themselves for a typed experience.

Screenshot 2024-03-13 at 10 56 13

from fuels-ts.

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.