You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I use some type aliases for documentation, e.g. type Email = string. While TypeScript won't be able to do anything in terms of type checking, these aliases are useful for documenting. As such, I expect that TypeDoc does not resolve these type aliases and displays them as is.
Actual Behavior
TypeDoc sometimes resolves them. This is only the case for aliases of primitive types.
I suspect that this has to do with how the TypeScript API is used to resolve the type of symbols. I noticed that VSCode has similar behaviour. It will show the type number for a in foo1 but will show foo(a: Bar): void for foo1 itself.
However, VSCode also shows number[] for Foo, so my suspicion might be wrong.
The text was updated successfully, but these errors were encountered:
This is somewhat of an unfixable* bug. This happens because the TypeScript compiler does type interning for primitives for performance reasons. Since 0.20, TypeDoc uses the type checker in the majority of cases in order to retrieve type information, so any type interning will result in us getting the privative type.
We do this because it lets us resolve generic types in classes with a concrete implementation (consider the docs for class MyList extends Array<number>)
You won't see this issue in declaration file emit because that is a purely syntactic transformation - it takes in nodes, and produces other nodes. It never needs to retrieve types.
You can prevent the compiler from interning this type by changing it to an intersection, as if you were making a branded type, but since the property is optional, standard numbers/strings can be used without a type assertion:
Search terms
Type alias, resolving types
Expected Behavior
I use some type aliases for documentation, e.g.
type Email = string
. While TypeScript won't be able to do anything in terms of type checking, these aliases are useful for documenting. As such, I expect that TypeDoc does not resolve these type aliases and displays them as is.Actual Behavior
TypeDoc sometimes resolves them. This is only the case for aliases of primitive types.
Example:
Screenshots
(Note that
Foo
is stillBar[]
.)Steps to reproduce the bug
Minimal project.
Environment
Additional information
While this is similar to #1472, it is not the same. I was able to confirm that #1472 is fixed when using TS v4.2 but this bug still remained.
The generated doc for the above example code with TS v4.2 and TS v4.1 is exactly the same.
I also want to point out the generated
.d.ts
declaration files correctly letBar
remain.I suspect that this has to do with how the TypeScript API is used to resolve the type of symbols. I noticed that VSCode has similar behaviour. It will show the type
number
fora
infoo1
but will showfoo(a: Bar): void
forfoo1
itself.However, VSCode also shows
number[]
forFoo
, so my suspicion might be wrong.The text was updated successfully, but these errors were encountered: