-
Notifications
You must be signed in to change notification settings - Fork 13k
Closed
Labels
Working as IntendedThe behavior described is the intended behavior; this is not a bugThe behavior described is the intended behavior; this is not a bug
Description
TypeScript Version: nightly (2.0.0-dev.20160630)
Code (This is a fairly contrived example.)
function CanRawr (target: (...args: any[]) => Function) : Function {
class Rawrable extends target {
static rawr () : void {
console.log(`RAWR`)
}
}
return Rawrable
}
@CanRawr
export default class Dinosaur { }
Expected behavior:
Everything typechecks.
Actual behavior:
Code compiles, but logs a hard to understand error. Compiled code works as expected.
app/ex.ts(11,2): error TS2345: Argument of type 'typeof Dinosaur' is not assignable to parameter of type 'new (...args: any[]) => Function'.
Type 'Dinosaur' is not assignable to type 'Function'.
Property 'apply' is missing in type 'Dinosaur'.
This is strange - looking at the signature for ClassDecorator
:
declare type ClassDecorator = <TFunction extends Function>(target: TFunction) => TFunction | void;
I would think that I am allowed to return a Function in place of a TFunction.
Perhaps I am doing something wrong? But the code compiles and runs, and does what I expect.
import Dinosaur from './example'
Dinosaur.rawr() // logs: 'RAWR'
Metadata
Metadata
Assignees
Labels
Working as IntendedThe behavior described is the intended behavior; this is not a bugThe behavior described is the intended behavior; this is not a bug