Skip to content

Question: is there a way to detect an unsound assignment via public compiler API? #3523

Closed
@zpdDG4gta8XKpMCd

Description

@zpdDG4gta8XKpMCd

My situation (#3067):

interface A {
    x: string;
}

interface B {
    x: string;
    y: string;
}

function copyB(value: B): B {
    return undefined;
}

var values: A[] = [];
values.map(copyB); // <-- unsound assigment

I've managed to get an AST and a type checker. I am holding a reference to the argument (copyB from above) object.

Can anyone outline the steps that need to be taken to determine that the assignment from the example is unsound using the public compiler API?

Metadata

Metadata

Assignees

No one assigned

    Labels

    APIRelates to the public API for TypeScriptQuestionAn 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