Skip to content
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

Merged
merged 3 commits into from
Aug 3, 2020
Merged

Downlevel Omit when used as ExpressionWithTypeArguments #34

merged 3 commits into from
Aug 3, 2020

Conversation

chrisguttandin
Copy link
Contributor

@chrisguttandin chrisguttandin commented Mar 26, 2020

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?

Copy link
Owner

@sandersn sandersn left a 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") {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
} 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);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const symbol = checker.getSymbolAtLocation(n.typeName);
const symbol = checker.getSymbolAtLocation(ts.isTypeReferenceNode(n) ? n.typeName : n.expression);

@sandersn
Copy link
Owner

sandersn commented Aug 3, 2020

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.

@chrisguttandin
Copy link
Contributor Author

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.

@sandersn sandersn merged commit 4f3c5e4 into sandersn:master Aug 3, 2020
@chrisguttandin chrisguttandin deleted the downlevel-omit-as-expression-with-type-arguments branch August 19, 2020 16:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Omit not replaced in extends
2 participants