-
Notifications
You must be signed in to change notification settings - Fork 21
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
Downlevel Omit when used as ExpressionWithTypeArguments #34
Downlevel Omit when used as ExpressionWithTypeArguments #34
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Everything looks correct, but please do refactor to eliminate duplication. I don't think it's worth changing the style of the program yet, so I'd recommend the below changes.
(I'll probably refactor to get closer to a condition -> rewrite
style once I get a few more downlevelled features.)
index.js
Outdated
typeArguments[1] | ||
]) | ||
]); | ||
} | ||
} else if (ts.isTypeReferenceNode(n) && ts.isIdentifier(n.typeName) && n.typeName.escapedText === "Omit") { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
} else if (ts.isTypeReferenceNode(n) && ts.isIdentifier(n.typeName) && n.typeName.escapedText === "Omit") { | |
} else if (ts.isTypeReferenceNode(n) && ts.isIdentifier(n.typeName) && n.typeName.escapedText === "Omit" | |
|| ts.isExpressionWithTypeArguments(n) && ts.isIdentifier(n.expression) && n.expression.escapedText === "Omit") { |
index.js
Outdated
typeArguments[1] | ||
]) | ||
]); | ||
} | ||
} else if (ts.isTypeReferenceNode(n) && ts.isIdentifier(n.typeName) && n.typeName.escapedText === "Omit") { | ||
const symbol = checker.getSymbolAtLocation(n.typeName); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const symbol = checker.getSymbolAtLocation(n.typeName); | |
const symbol = checker.getSymbolAtLocation(ts.isTypeReferenceNode(n) ? n.typeName : n.expression); |
Also, sorry for the long delay -- I only look at downlevel-dts during the RC period for each Typescript release. Let me know if you'd like me to take over the PR if you've timed out. |
No worries. I'm afraid I don't have the time to address your feedback this week. If you have the capacity to take this over I would be grateful. |
This pull request is intended to fix #33
The code is very similar to the one which down-levels Omit when used in a TypeReferenceNode. Should I refactor it into a function which can be used for both cases?