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

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

@gabritto

Description

@gabritto

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions