How to get non-qualified type text?
See original GitHub issueI’m not sure what changed in my setup, perhaps a TypeScript upgrade, or a ts-simple-ast upgrade, but today I noticed that my script no longer works as intended, and when I get the text of the type of a class property I get an import path in front of it.
I wasn’t able to find how to just get the non-qualified type. I must be missing something basic. Any help is appreciated.
This is my code:
const properties = _(cls.getInstanceProperties())
.filter(prop => {
return prop.getKind() === ts.SyntaxKind.PropertyDeclaration;
})
.forEach(prop => {
console.log(prop.getType().getText());
The above outputs qualified types for some of the properties:
import("/path/to/node_modules/@angular/core/src/event_emitter").EventEmitter<Event>
But previously I was just getting:
EventEmitter<Event>
How can I get the latter again?
Issue Analytics
- State:
- Created 5 years ago
- Reactions:1
- Comments:12 (7 by maintainers)
Top Results From Across the Web
Nonqualified Stock Options | H&R Block
Learn more about reporting non-qualified stock options and get tax answers at H&R Block.
Read more >Nonqualified Deferred Compensation Plans (NQDCs)
NQDC plans have the potential for tax-deferred growth, but they also come with substantial risks, including the risk of complete loss of the ......
Read more >What Are Non-Qualified Stock Options (NSOs)? - Carta
Non-qualified stock options (NSOs) are a type of equity compensation that does not qualify for favorable tax treatment. Learn about NSOs and ...
Read more >Is My Pension or Annuity Payment Taxable? - IRS
Determine if your pension or annuity payment from an employer-sponsored retirement plan or nonqualified annuity is taxable.
Read more >Qualified vs Non-Qualified Annuities | Taxation and Distribution
Qualified annuities receive treatment similar to tax-favored retirement plans, while non-qualified annuities have fewer restrictions.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

Yeah, this was a change in TypeScript in 2.9. The key here seems to be to pass in the enclosing declaration to
getText()which will cause it to not return the import type text:There might be a way to make this work using
TypeFormatFlagsalone (second param ofgetText)… I’m not sure.That’s very interesting! It seems what matters here is what type is requested first to the type checker and that’s the main problem here. I bet that’s probably by design, but opened #480 to investigate further.
Closing this for now.