Bug Report
Looking for a workaround or an explanation, really. But it seems like a bug?
🔎 Search Terms
🕗 Version & Regression Information
This is the behavior in every version I've tried.
⏯ Playground Link
Playground link with relevant code
💻 Code
interface ArrayLike<T> {
readonly length: number;
readonly [n: number]: T;
}
function testB<T>(arg: ArrayLike<T>) { }
// GOOD: Errors here as expected. "index signature is missing".
testB(() => {});
function testA(arg: ArrayLike<any>) {}
// BAD: No errors here? The index signature is still missing, though.
testA(() => {});
🙁 Actual behavior
testA allows a developer to pass a function where we didn't intend them to be able to pass a function.
In some (much more complicated) cases in RxJS this becomes an unintuitive footgun.
🙂 Expected behavior
I'd expect that testA would error with the same error that testB errors with. Functions don't have indexers in their signatures.
Related to:
Bug Report
Looking for a workaround or an explanation, really. But it seems like a bug?
🔎 Search Terms
🕗 Version & Regression Information
This is the behavior in every version I've tried.
⏯ Playground Link
Playground link with relevant code
💻 Code
🙁 Actual behavior
testAallows a developer to pass a function where we didn't intend them to be able to pass a function.In some (much more complicated) cases in RxJS this becomes an unintuitive footgun.
🙂 Expected behavior
I'd expect that
testAwould error with the same error thattestBerrors with. Functions don't have indexers in their signatures.Related to:
ArrayLikefromObservableInputReactiveX/rxjs#6011