Giter VIP home page Giter VIP logo

Comments (4)

MartinJohns avatar MartinJohns commented on May 24, 2024 1

This is working as intended, methods are bivariant. See this FAQ entry: Why Method Bivariance?

You can use the property syntax to get covariant behavior: mapToVoid: (m: Partial<M>) => void

from typescript.

fatcerberus avatar fatcerberus commented on May 24, 2024 1

not sure I'll classify it as working as intended since it is clearly not working in the runtime and caused a bug in my project

"Working as intended" = working as the TypeScript compiler devs intend. The behavior of TypeScript here is intentional, even if it leads to runtime errors. The type system is intentionally not fully sound: to quote the design goals, TS is designed to "strike a balance between correctness and productivity"; in this case, enforcing strictMethodTypes would be a major roadblock in practice for almost any code people would want to write so it isn't done.

from typescript.

klarnakasamac avatar klarnakasamac commented on May 24, 2024

@MartinJohns Thank you, I read the article even though I don't 100% understand but I get that it's kind of a limitation, not sure I'll classify it as working as intended since it is clearly not working in the runtime and caused a bug in my project

but since we have a way forward I think I'll close the ticket

from typescript.

klarnakasamac avatar klarnakasamac commented on May 24, 2024

@fatcerberus I understand exactly why isn't it done, I'm happy too that there's way to solve my problem and move forward so I closed the issue, I know it's what the ts devs are aware of but to me it sounds more like a limitation or known issue where they just accepted that it's not worth fixing (if there was a magic way to fix it without any negative impact I think they would do it), working as intended for me is something is working based on your design but this is just my personal feeling

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.