GithubHelp home page GithubHelp logo

Comments (5)

maskmaster avatar maskmaster commented on June 23, 2024

I added an answer in the stackoverflow question. We need to make sure that these two lines remain valid after any fix.

const x = observable<false | undefined>(false);
const y = observable(false);

from tko.

tomhanax avatar tomhanax commented on June 23, 2024

For now the best I can offer is:

// Fixed
function observable<T, U = any>(value?: T extends infer R ? R : U): unknown extends T ? Observable<U> : Observable<T>
{
  return undefined as any;  // the implementation is not important
}

The playground contains many examples and seems OK, of course anybody can check and correct if needed, I am no expert in this.

Playground Link

from tko.

brianmhunt avatar brianmhunt commented on June 23, 2024

Thanks @maskmaster , @tomhanax the answer & playground are very helpful.

direct link to the SO question

from tko.

chuanqisun avatar chuanqisun commented on June 23, 2024

Hi, I believe I'm hitting the same issue when upgrading to typescript 4.6 but I might need some help understanding the workaround. Here is a minimum repro.

image

The ExtendedType is clearly assignable to the BaseType, but typescript wouldn't allow. Also, the error suggests that typescript is trying to assign BaseType to ExtendedType, which is opposite to the desired direction.

Should I manually patch the type definitely of KnockoutObservable? I'm not sure how that might work. Thank you and let me know if I should cross post to other repos.

from tko.

mbest avatar mbest commented on June 23, 2024

This was fixed in TypeScript: microsoft/TypeScript#48380

from tko.

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.