Skip to content

MethodDecorator gets TS2322/TS2315 #17936

Open
@Norgerman

Description

@Norgerman

TypeScript Version: 2.4.2
Code

export function route(method: string, path: string): MethodDecorator {
    return (target: any, name: string, descriptor: TypedPropertyDescriptor<Function>) => {
        routeManager.regeisterRoute({
            constructor: target.constructor,
            function: descriptor.value,
            method,
            path
        });
    }
}
export function route(method: string, path: string): MethodDecorator<Function> {
    return (target: any, name: string, descriptor: TypedPropertyDescriptor<Function>) => {
        routeManager.regeisterRoute({
            constructor: target.constructor,
            function: descriptor.value,
            method,
            path
        });
    }
}

Expected behavior:
No error
Actual behavior:

error TS2322: Type '(target: any, name: string, descriptor: TypedPropertyDescriptor<Function>) => void' is not assignable to type 'MethodDecorate
or'.
  Types of parameters 'descriptor' and 'descriptor' are incompatible.
    Type 'TypedPropertyDescriptor<T>' is not assignable to type 'TypedPropertyDescriptor<Function>'.
      Type 'T' is not assignable to type 'Function'.
error TS2315: Type 'MethodDecorator' is not generic.

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugA bug in TypeScriptDomain: DecoratorsThe issue relates to the decorator syntax

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions