question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[BUG] type metadata

See original GitHub issue

Describe the bug

Type introspection doesn’t seem to work on types extending other types. Also, since types don’t support decorators (i.e. @reflected), one has to manually write getType<TypeA>() in order to activate metadata generation for TypeA. Without this, the result contains invalid values, like “type.name : ‘unknown’”

The code causing the problem

type TypeA = {
	prop1: string
}

type TypeB = TypeA & {
  prop2: string,
  prop3: string
}

const t0: Type = getType<TypeA>();
const t1: Type = getType<TypeB>();
console.log(t1.getProperties())

To Reproduce Steps to reproduce the behavior:

  1. Build,
  2. run,
  3. see error…

Expected behavior All properties including inherited ones should be displayed by console.log(t1.getProperties())

Runtime (please complete the following information):

  • Node.js version: v18.10.0
  • TypeScript version: 4.8.4
  • Compiler: [ttypescript]
  • Bundler: [none]

Additional context

Issue Analytics

  • State:closed
  • Created a year ago
  • Reactions:1
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
uplight-devcommented, Oct 20, 2022

Looking forward to it! And thanks for this awesome lib, makes a difference for my use case!

0reactions
Hookynscommented, Oct 20, 2022

Okay, got it.

Sadly, this is intended behavior in the current version. This was intended as an optimisation, so only required types are reflected because of size of metadata (it would be megabytes for some projects). Type.find() was introduced later, but it is limited to reflected types.

New major version (alpha release is rly close) works in a different way (based on include/exclude options) so it works properly there.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Automatically capture custom metadata inside your bug reports
We can now give your developers the ability to pass custom metadata to your Marker.io script, which is then forwarded into each bug...
Read more >
An example of metadata from a bug report - ResearchGate
Locating relevant source files for a given bug report is an important task in software development and maintenance. To make the locating process...
Read more >
Other Bug Metadata — Firefox Source Docs documentation
Quick search · Bug Handling · Other Bug Metadata · Report an issue / View page source ...
Read more >
Predicting code bug risk with git metadata | by Civis Analytics
We need to use both types of metadata for our bug risk prediction tool, fortunately, git makes it easy to get at this...
Read more >
Finding Bugs in Source Code Using Commonly ... - USENIX
This paper provides a method for leveraging development metadata to find bugs that would otherwise be difficult to find using standard static analy-...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found