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.

t.isInterface returns false when there are generics?

See original GitHub issue

Describe the bug

Version: 9.1.0

To Reproduce

I a still working on a minimal repro but you can see from this log already some insight.

Notice how isInterface() is false 🤔.

t.getText()                                          = import("/Users/jasonkuhrt/projects/tydoc/tydoc/got/source/as-promise/types").Foo<1>
t.getSymbol()?.getName()                             = Foo
t.compilerType.getFlags()                            = 524288
(t.compilerType as tsm.ts.ObjectType)?.objectFlags   = 67108868
t.getAliasSymbol()?.getName()                        = undefined
t.getApparentType().getText()                        = import("/Users/jasonkuhrt/projects/tydoc/tydoc/got/source/as-promise/types").Foo<1>
t.getSymbol()?.getDeclarations()?.[0]?.getKindName() = InterfaceDeclaration
t.getSymbol()?.getDeclarations()?.[0]?.getText()     = export interface Foo<T = 1> {
                                                       	bar: Foo
                                                       }

t.isAnonymous()                                      = false
t.isAny()                                            = false
t.isInterface()                                      = false
t.isObject()                                         = true
t.isArray()                                          = false
t.isBoolean()                                        = false
t.isBooleanLiteral()                                 = false
t.isClass()                                          = false
t.isClassOrInterface()                               = false
t.isEnum()                                           = false

t.getAliasTypeArguments().length}                    = 0

t.getText(undefined, tsm.ts.TypeFormatFlags.InTypeAlias)                           = Foo<1>
t.getText(undefined, tsm.ts.TypeFormatFlags.UseAliasDefinedOutsideCurrentScope)    = Foo<1>
t.getText(undefined, tsm.ts.TypeFormatFlags.UseTypeOfFunction)                     = Foo<1>
t.getText(undefined, tsm.ts.TypeFormatFlags.UseFullyQualifiedType)                 = import("/Users/jasonkuhrt/projects/tydoc/tydoc/got/source/as-promise/types").Foo<1>
t.getText(undefined, tsm.ts.TypeFormatFlags.NoTruncation)                          = Foo<1>
t.getText(undefined, tsm.ts.TypeFormatFlags.UseStructuralFallback)                 = Foo<1>

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:10 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
jasonkuhrtcommented, Dec 14, 2020

Thanks David!

0reactions
dsherretcommented, Dec 14, 2020

@jasonkuhrt no problem! Glad you figured it out!

Read more comments on GitHub >

github_iconTop Results From Across the Web

c# - Generic type constraint for interface? - Stack Overflow
The alternative is that I can pass in an argument that's constrained by class and throw an exception if typeof(T).IsInterface returns false ......
Read more >
Generic Interfaces - C# Programming Guide - Microsoft Learn
It's often useful to define interfaces either for generic collection classes, or for the generic classes that represent items in the collection.
Read more >
An Introduction to Generics in Go | by Na'aman Hirschfeld
I would in this case use named generic parameters only sparingly and only when there is a compelling reason to do so. Parameter...
Read more >
How To Use Generics in Go | DigitalOcean
You also defined a NewPlayingCard function to act as the constructor for the PlayingCard struct , and a String method, which will return...
Read more >
Understanding and using interfaces in TypeScript
They allow us to describe the objects that will use in our code, ... ​​Extending interfaces; ​​How to use generics in interfaces ...
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