Giter VIP home page Giter VIP logo

Comments (7)

RyanCavanaugh avatar RyanCavanaugh commented on September 28, 2024 2

It's probably time for my once-every-few-years attempt to look at #241 again and see what doesn't work these days

from typescript.

MartinJohns avatar MartinJohns commented on September 28, 2024 1

@essenmitsosse That is working as intended. The type of your variables inferred to { foo: string; bar: string } due to the lack of type annotation, and when returning the value the compiler only checks compatibility. { foo: string; bar: string } is compatible with the type { foo: string }.

See the FAQ entry: (Indirect) Excess Properties Are OK

from typescript.

MartinJohns avatar MartinJohns commented on September 28, 2024

This is essentially a duplicate of #241. Check the linked issues.

from typescript.

christianalfoni avatar christianalfoni commented on September 28, 2024

Thanks for the reference @MartinJohns! My "Excess property checks on return types" search did not hit "widen return types" it seems 😂

But okay, great. I also see there was a design discussion on this #56965.

It seems it is planned to be fixed, hm

from typescript.

christianalfoni avatar christianalfoni commented on September 28, 2024

Okay, so I get a response that the referenced discussion (#56965) is related, but not a fix for this issue. So yeah, not sure how much attention this deserves and how to ensure it gets that deserved attention 🤔

from typescript.

essenmitsosse avatar essenmitsosse commented on September 28, 2024

Not sure if this is considered related, but this also doesn't work:

cbFunc<MyType>((): MyType => {
    const value = {
        foo: 'bar',
        bar: 'baz'
    }
    
    return value
})

from typescript.

typescript-bot avatar typescript-bot commented on September 28, 2024

This issue has been marked as "Duplicate" and has seen no recent activity. It has been automatically closed for house-keeping purposes.

from typescript.

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.