-
-
Notifications
You must be signed in to change notification settings - Fork 736
Variables of kind ConditionalExpression
have defaultValue set to condition
#401
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Looking into this a bit more, I'm a bit confused on the best way to fix this. Adding a check for If the values on either side of the ternary are not functions, it seems like doing nothing works, and the correct type / union type is displayed. If If But, if either one is a function when the other is not, I am not really sure how to correctly spit that information out, or what it should look like, given TypeDoc comments could have some Also, it looks like the same types of checking might need to occur when the export const foo = someValue || someOtherValue; |
Given the following TypeScript code, TypeDoc produces some incorrect output.
Source File:
Output:
What seems to be happening is that this is going through the variable converter, and inside of the switch statement, the
node.initializer.kind
value is193
("ConditionalExpression"
). This means that it hits thedefault
portion of the switch statement and sets the whole conditional as thedefaultValue
, which seems incorrect given TypeScript can determine the type for the conditional expression.I know that TypeScript can determine what the actual type is for the
assign
variable.I'm looking into how TypeDoc can infer this as well. What I am initially looking at is treating
ConditionalExpression
variable kinds as a special case in that case statement, and creating a new node converter to handle converting the conditional into a type. I'm still trying to determine how to create modify the variable reflection to have the correct type and be of the correct kind (the above screenshot should be marked as a function but it isn't) from the conditional. Does this sound like a reasonable approach?The text was updated successfully, but these errors were encountered: