Skip to content
This repository has been archived by the owner on Mar 25, 2021. It is now read-only.

How do i find out a type of a CallExpression? #1339

Closed
Fank opened this issue Jun 24, 2016 · 2 comments
Closed

How do i find out a type of a CallExpression? #1339

Fank opened this issue Jun 24, 2016 · 2 comments

Comments

@Fank
Copy link

Fank commented Jun 24, 2016

Hello i have a question.
I haven't found a case who handle it.

Example code:

class AComponent {
    public test(): void {
        // ASD
    }

    public test2(): void {
        // ASD
    }
}

let a = new AComponent();
a.test();
a.test2();

I want to disallow using AComponent.test() because its deprecated, and people should AComponent.test2().
Is there any way to find out that a is a AComponent?

Thanks in advance

@adidahiya
Copy link
Contributor

@Fank it is currently not possible to get the types of identifiers in a robust way with a TSLint rule walker. See #1323 and #680 for more information.

@andy-hanson
Copy link
Contributor

This can be done now with a TypedRule, which takes the Program. Call program.getTypeChecker() and checker.getTypeAtLocation(location).

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants