Skip to content

#47341 breaks knockout.mapping tests on Definitely Typed #47371

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
sandersn opened this issue Jan 10, 2022 · 5 comments
Closed

#47341 breaks knockout.mapping tests on Definitely Typed #47371

sandersn opened this issue Jan 10, 2022 · 5 comments
Assignees
Labels
Working as Intended The behavior described is the intended behavior; this is not a bug

Comments

@sandersn
Copy link
Member

Knockout.mapping tests rely on the old signature relation rules. The repro is fairly small:

interface Kow<T> {
    (value: T): void;
}
declare var src: Kow<true> | Kow<false>;
var tgt: Kow<boolean> = src;

Expected: src assignable to target.
Actual: Error, type 'boolean' is not assignable to type 'false'.

@ahejlsberg
Copy link
Member

Hmm, the repro also fails with TS 4.5.4. Am I missing something?

@ahejlsberg
Copy link
Member

Actually, here's a repro that only fails with #47341.

interface Kow<T> {
    (): void;
    (value: T): void;
}
declare var src: Kow<true> | Kow<false>;
var tgt: Kow<boolean> = src;

But really, that ought to fail, it just happened not to previously because we cross-related the signatures. I mean, src might reference a Kow<true> which shouldn't be callable with a boolean.

@ahejlsberg
Copy link
Member

And, just to add to the bizarreness of our current behavior, we error if the type is written as an aliased type instead of an interface:

type Kow<T> = {
    (): void;
    (value: T): void;
}

The two obviously should behave the same.

@sandersn
Copy link
Member Author

So it sounds like main is in a better state than 4.5.4, right? If that's the case then this issue should be closed.

@ahejlsberg
Copy link
Member

Yes, I'd say main has better and more consistent behavior.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Working as Intended The behavior described is the intended behavior; this is not a bug
Projects
None yet
Development

No branches or pull requests

2 participants