Skip to content

Conflict betwen Partial and 'this' type #13259

Closed
@WanderWang

Description

@WanderWang

TypeScript Version: 2.1.4 / nightly (2.2.0-dev.20170102)

Code

class Tween<T>{

    static get<T>(target: T): Tween<T> {
        return new Tween(target);
    }

    constructor(private target: T) {
    }

    public to(props: Partial<T>) {
    }
}

class DisplayObject {
    public x: number;
    public y: number;
}


class Button extends DisplayObject {

    public z: number;
    onClick = () => {
        let tween = Tween.get(this);
        tween.to({ x: 100 });
        tween.to({ z: 100 });
        tween.to({ a: 100 });
    }
}

Expected behavior:

        let tween = Tween.get(this); 
        tween.to({ x: 100 }); // right 
        tween.to({ z: 100 }); // right 
        tween.to({ a: 100 }); // compile error

Actual behavior:

        let tween = Tween.get(this); 
        tween.to({ x: 100 }); // compile error 
        tween.to({ z: 100 }); // compile error 
        tween.to({ a: 100 }); // compile error

Metadata

Metadata

Assignees

No one assigned

    Labels

    QuestionAn issue which isn't directly actionable in code

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions