Skip to content
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

Track recursive callback-covariance calls to compareSignaturesRelated #19078

Closed

Commits on Oct 10, 2017

  1. Track recursive calls to compareSignaturesRelated

    Previously, `compareSignaturesRelated` would try to relate (parameters
    of) callback parameters covariantly without checking whether the two
    signatures were already being checked. This led to an infinite recursion
    when checking recursive types with callbacks:
    
    ```ts
    interface Foo<T> { (bar: Bar<T>): void }
    type Bar<T> = (foo: Foo<T>) => Foo<T>
    declare function foo<T>(bar: Bar<T>): void
    declare var bar: Bar<{}>
    bar = foo
    ```
    
    The fix is to track which callbacks are already being compared. The
    mechanism is per-call to compareSignaturesRelated, so it only stops
    recursions on the callback-covariance code path. However, the maybe
    cache check in recursiveTypeRelatedTo will catch infinite recursions on
    the usual code path through isRelatedTo.
    
    Fixes #18277
    sandersn committed Oct 10, 2017
    Configuration menu
    Copy the full SHA
    b0a6444 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    d935422 View commit details
    Browse the repository at this point in the history