Closed as not planned
Description
openedon Sep 20, 2022
Bug Report
π Search Terms
implicit any, filter object properties by type, key remapping
β― Playground Link
Playground link with relevant code
π» Code
type BooleanProperties<T> = T extends any ? {
[K in keyof T as T[K] extends boolean ? K : never]: boolean;
} : never;
class Foo {
booleansOnly: BooleanProperties<this> = undefined!; // Omitted..
getString<F extends (someUsefulData: any) => any>(fn: F) : string {
return undefined!; // Omitted..
};
aBoolean = true;
definitelyAString = this.getString(() => this.booleansOnly.aBoolean);
}
π Actual behavior
Error: 'definitelyAString' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer.
π Expected behavior
Since "getString" method has an explicit return type (string), in my opinion "type annotation" is provided, and the error should not be thrown.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment