Skip to content

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

Closed

Description

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'.

Activity

  1. ahejlsberg commented on Jan 10, 2022

    @ahejlsberg
    Member

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

  2. ahejlsberg commented on Jan 10, 2022

    @ahejlsberg
    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.

  3. ahejlsberg commented on Jan 10, 2022

    @ahejlsberg
    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.

  4. sandersn commented on Jan 10, 2022

    @sandersn
    MemberAuthor

    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.

  5. ahejlsberg commented on Jan 11, 2022

    @ahejlsberg
    Member

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

  6. locked as resolved and limited conversation to collaborators on Oct 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Working as IntendedThe behavior described is the intended behavior; this is not a bug

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions