t.isInterface returns false when there are generics?
See original GitHub issueDescribe 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:
- Created 3 years ago
- Comments:10 (4 by maintainers)
Top 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 >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 FreeTop 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
Top GitHub Comments
Thanks David!
@jasonkuhrt no problem! Glad you figured it out!