-
Notifications
You must be signed in to change notification settings - Fork 251
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
fix mutation of Array constructor call for TypeScript #1903
fix mutation of Array constructor call for TypeScript #1903
Conversation
Looks good at first glance, but I think there might be a small mistake or a way to make this code shorter: } else if (node.kind === ts.SyntaxKind.CallExpression) {
if (node.expression.kind === ts.SyntaxKind.Identifier && node.expression.getFullText(sourceFile).trim() === 'Array') {
if (node.arguments && node.arguments.length) {
return [{ node, replacement: 'Array()' }];
} else {
return [{ node, replacement: 'Array([])' }];
}
} else {
return [];
}
} else {
if (node.expression.getFullText(sourceFile).trim() === 'Array') {
if (node.arguments && node.arguments.length) {
return [{ node, replacement: 'new Array()' }];
} else {
return [{ node, replacement: 'new Array([])' }];
}
} else {
return [];
}
} This part looks fishy / strange. Especially that you are calling |
I pushed some changes to make the code shorter, and add another test case to hopefully ensure we do not make another mistake. I hope this is good to go soon, it is now blocking updates needed on PR #1898. |
Now it looks much cleaner :D |
with testing
resolves #1902