-
Notifications
You must be signed in to change notification settings - Fork 440
Emit iterable arguments for ES2015+ #699
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
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.
A few small comments.
src/emitter.ts
Outdated
return !!s.param && s.param.some(p => typeIncludesSequence(p.type)); | ||
} | ||
|
||
function filterSignaturesWithSequence(signature: Browser.Signature[]): Browser.Signature[] { |
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.
nit: can you name the function replaceSignaturesWithSequence
and the parameter signatures
?
src/emitter.ts
Outdated
function filterSignaturesWithSequence(signature: Browser.Signature[]): Browser.Signature[] { | ||
return signature.filter(hasSequenceArgument).map(s => { | ||
const newParams = s.param!.map(p => { | ||
const typedef = typeof p.type === "string" ? sequenceTypedefMap[p.type]: undefined; |
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.
you could drop lines 1227-1229 if you use p.type
instead of undefined
. It's less efficient but that's not a concern here.
const typedef = typeof p.type === "string" ? sequenceTypedefMap[p.type]: undefined; | |
const typedef = typeof p.type === "string" ? sequenceTypedefMap[p.type] : p.type; |
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.
Doing that will break code as sequenceTypedefMap[p.type]
also can be undefined
.
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.
That makes sense.
Closes microsoft/TypeScript#28198.