Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(jsii-reflect) TypeMember should be SourceLocatable #3777

Closed
Chriscbr opened this issue Sep 27, 2022 · 1 comment · Fixed by #3778
Closed

(jsii-reflect) TypeMember should be SourceLocatable #3777

Chriscbr opened this issue Sep 27, 2022 · 1 comment · Fixed by #3778
Labels
bug This issue is a bug. needs-triage This issue or PR still needs to be triaged.

Comments

@Chriscbr
Copy link
Contributor

Chriscbr commented Sep 27, 2022

Describe the bug

When I use jsii reflect to get an arbitrary member from a class, I expected to be able to access a locationInModule property since every property and method on a class or interface has a source code location. However, the current types report this as an error since cls.allMembers returns TypeMember[], and TypeMember extends Documentable but not SourceLocatable.

const { TypeSystem } = require("./lib");

async function main() {
    const ts = new TypeSystem();
    await ts.load("../jsii-calc");
    for (const cls of ts.classes) {
        for (const member of cls.allMembers) {
            console.log(`${cls.fqn}.${member.name} (${member.locationInModule.filename}:${member.locationInModule.line})`);
        }
    }
}

main();

Expected Behavior

I expected member.locationInModule to not return a type checking error.

Current Behavior

I get a TypeScript error Property 'locationInModule' does not exist on type 'TypeMember'.

Reproduction Steps

See code snippet above

Possible Solution

No response

Additional Information/Context

No response

SDK version used

jsii 1.68.0

Environment details (OS name and version, etc.)

N/A

@Chriscbr Chriscbr added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Sep 27, 2022
@mergify mergify bot closed this as completed in #3778 Sep 28, 2022
mergify bot pushed a commit that referenced this issue Sep 28, 2022
Fixes #3777

---

By submitting this pull request, I confirm that my contribution is made under the terms of the [Apache 2.0 license].

[Apache 2.0 license]: https://www.apache.org/licenses/LICENSE-2.0
@github-actions
Copy link
Contributor

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue is a bug. needs-triage This issue or PR still needs to be triaged.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant