Coder Social home page Coder Social logo

Comments (4)

rubenvanassche avatar rubenvanassche commented on August 29, 2024 2

Is a bug indeed, fixed in the next version.

from laravel-data.

Tofandel avatar Tofandel commented on August 29, 2024

Mmm, it can technically be both because the collection can have keys, if those keys are not sequential (eg 2, 7, 9), it serializes to an object which is a Record, if the Collection has no keys then it serializes to an array, so the correct type would be

export type FooData = {
collection?: Array<App.Data.SomeData> | Record<int, App.Data.SomeData>;
};
};

But I agree, if the collection is keyed with int, it's much better DX to say it should be an array because that's what it's going to be in 99.9999% cases and in the case it's not we can just say Collection<int | string, SomeData> and the type should correctly be infered as a Record

from laravel-data.

Tofandel avatar Tofandel commented on August 29, 2024

@studnitz

Did you try with

/** @var Collection<SomeData> */

from laravel-data.

studnitz avatar studnitz commented on August 29, 2024

@studnitz

Did you try with

/** @var Collection<SomeData> */

Yes, but this results in a PHPStan error, see the last paragraph of the bug report.

from laravel-data.

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.