Skip to content
This repository has been archived by the owner on Feb 18, 2022. It is now read-only.

Consider 'prototype' property when matching declaration against JS source #22

Open
gabritto opened this issue Mar 3, 2020 · 0 comments

Comments

@gabritto
Copy link
Collaborator

gabritto commented Mar 3, 2020

When we compare the exported properties of a declaration and JS source, we ignore the prototype property. This means that if the module is a class, we don't compare the class members to see if they match. For example:
js

class C {
    constructor(x) {
        this.x = x;
    }
    name() {
        return `x: ${this.x}`;
    }
}
module.exports = C;

d.ts

declare class C {
    x: number;
    constructor(x: number);
}
export = C;

We don't detect that name method is missing from the d.ts because we ignore the members of prototype in the JS inferred module type. To account for name, we should do something like

jsExportType.members.get("prototype").type.getProperties(); // returns symbols for properties 'x' and 'name' above
@gabritto gabritto changed the title Consider prototype properties when matching declaration against JS source Consider 'prototype' property when matching declaration against JS source Mar 3, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant