GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||||
GeezerVison is showing github.com — Strictly check callback parameters by ahejlsberg · Pull Request #18976 · microsoft/TypeScript Conversation
|
|
Anders Hejlsberg (@ahejlsberg) last time we talked about disabling this code path for --strictFunctionTypes you mentioned we needed this to avoid excessive recursion for computing the variance digest, is that not an issue now? |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
It feels strange that the following examples undergo a regression and you lose checking under interface Animal {a: any} interface Dog extends Animal {d: any} namespace n1 { class Foo { static f1(x: Animal): Animal { throw "wat"; } static f2(x: Dog): Animal { throw "wat"; }; } declare let f1: (cb: typeof Foo.f1) => void; declare let f2: (cb: typeof Foo.f2) => void; f1 = f2; f2 = f1; // errors outside strictFunctionTypes, not with it. } namespace n2 { type BivariantHack<Input, Output> = { foo(x: Input): Output }["foo"]; declare let f1: (cb: BivariantHack<Animal, Animal>) => void; declare let f2: (cb: BivariantHack<Dog, Animal>) => void; f1 = f2; f2 = f1; // errors outside strictFunctionTypes, not with it. } At the very least, we should have tests demonstrating the behavior, but I think we can still tighten this up. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Daniel Rosenwasser (@DanielRosenwasser) It's because a callback parameter check (contravariant parameters, bivariant return type) sits halfway between a strict function type check (contravariant parameters, covariant return type) and a method type check (bivariant parameters, bivariant return type). I suppose we could say that a callback parameter check occurs only if the callback type isn't declared as method (which you really have to contort yourself to do, as your example demonstrates). I think it is largely immaterial though, it never really occurs in normal code. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Not sure what I was talking about there, it shouldn't matter. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
While I think it wouldn't be super difficult to do that, we should acknowledge these cases and add them to our test suite, with and without |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Daniel Rosenwasser (@DanielRosenwasser) Mohamed Hegazy (@mhegazy) With the latest commits I've reverted back to using the callback parameter code path in |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Why !callbackCheck instead of CallbackCheck.None === callbackCheck?
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
strictFunctionTypes has different behavior with parameter types and return types
There was an error while loading. Please reload this page.