Skip to content

Code fails noImplicitAny check under 1.1.0.0 #833

Closed
@paf31

Description

@paf31

This code used to compile without error under 1.0:

module M {

        export interface T<A> {
            get(): A;
        }

        export function ap<A, B>(f: T<(a: A) => B>, x: T<A>): T<B> {
            return {
                get: () => f.get()(x.get())
            };
        }

        export function map<A, B>(f: (a: A) => B, x: T<A>): T<B> {
            return {
                get: () => f(x.get())
            };
        }

        var x: T<number> = {
            get: () => 0
        };

        var test = ap(ap(map((a: number) => (b: number) => (c: number) => {
                return { a: a, b: b, c: c };
            }, x), x), x);
}

However, under 1.1, I get the following error:

(23,37): error TS7024: Function implicitly has return type 'any' because it does not have a return type annotation and is referenced directly or indirectly in one of its return expressions.

I don't see any reason why any subexpression of test should have an inferred type of any.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Breaking ChangeWould introduce errors in existing codeBy DesignDeprecated - use "Working as Intended" or "Design Limitation" instead

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions