-
Notifications
You must be signed in to change notification settings - Fork 12.8k
arguments as object literal field name emitted as arguments_1 when target es5 #33540
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
With playground nightly my code and the original works. Simplified code that produce the same bug (version 3.6.3): function parseMemberOrCallExpression(tokens: any[]) {
for (let i = 0; i < tokens.length; i++) {
const token = tokens[i]
tokens.filter((_, j) => j > i && j < 1)
const callExpression = {
arguments: 1,
}
}
} In my example, changing the tokens.filter(a => a) I don't known how a lambda can change the output of an unrelated object field. @plantain-00 as a workaround: function makeFilterfunc(i: number, index: number) {
return (_: any, j: number) => j > i && j < index;
}
// A *self-contained* demonstration of the problem follows...
// Test this by running `tsc` on the command-line, rather than through another build tool such as Gulp, Webpack, etc.
function parseMemberOrCallExpression(tokens: (Token | Expression)[]) {
const newTokens: (Token | Expression)[] = []
let expectCall = false
for (let i = 0; i < tokens.length; i++) {
const token = tokens[i]
if (token.type === 'PunctuatorToken') {
if (!expectCall && token.value === '?.') {
expectCall = true
continue
}
if (expectCall && token.value !== '[' && token.value !== '(') {
throw new Error(replaceLocaleParameters(this.locale.unexpectToken, token.range[0], token.range[1]))
}
if (callOperators.includes(token.value)) {
const object = newTokens.pop()!
newTokens.push(this.parseExpression([object, token, tokens[i + 1]], getHeadTailRange(object, tokens[i + 1])))
i++
} else if (token.value === '[') {
const index = this.findGroupEnd(tokens, i, token.value)
const object = newTokens.pop()!
const groupedTokens = tokens.filter(makeFilterfunc(i, index))
const property = this.parseExpression(groupedTokens, getTokensRange(groupedTokens))
const memberExpression: MemberExpression = {
type: 'MemberExpression',
object: this.parseTokenOrExpression(object),
property: this.parseTokenOrExpression(property),
range: [object.range[0], tokens[index].range[1]]
}
if (expectCall) {
memberExpression.optional = true
}
newTokens.push(memberExpression)
i = index
} else if (token.value === '(') {
const index = this.findGroupEnd(tokens, i, token.value)
const argumentsExpressions = this.parseItems(tokens, i, index)
const lastToken = newTokens.pop()!
const callExpression: CallExpression = {
type: 'CallExpression',
callee: this.parseExpression([lastToken], lastToken.range),
arguments: argumentsExpressions,
range: [lastToken.range[0], tokens[index].range[1]]
}
if (expectCall) {
callExpression.optional = true
}
newTokens.push(callExpression)
i = index
} else {
newTokens.push(token)
}
} else {
newTokens.push(token)
}
}
return this.parseExpression(newTokens, getTokensRange(newTokens))
} |
Since the nightly fix this, I will close this issue and use |
TypeScript Version: 3.6.3
Search Terms:
arguments, arguments_1
Code
Expected behavior:
Actual behavior:
Playground Link:
http://www.typescriptlang.org/play/index.html?target=1#code/GYVwdgxgLglg9mABABwIYCcDOBTAstgWwCNt0B5dAYVQBsaBRAD2XW003jAAoo4BrbGEwAuRFwAq-QYgA+iJizYcEASgDaAXRWIA3gChEhxBASYoiMNgDukgUNESpSOQtbtO6jYgC8iTQaMabHNsZmxoajofRGBaHADDYDh0MSDzGGiABgBuRAyAHkReO0wAOiCwAHMoAAtcmABqBu19IyMTIXNi6V9uoTUYDQSjGGAxPtKoAE9kbB9vXwByAAVwaBBUXnRbQUWW4bbRsQBCUNmI2hpEADJroqdSgDdaEDmFpYB+Ur3dA7bEM7hKCRK69dCvP5tDqwMAQ-5GAC+kLyYy4gIuUVu9zsTxec2OC0QizUixudwmzxor0QBKWXB+rXhRlq6DgVgs1nk6FZ6C4rGQNFQEGwABk4BBaNhlhhUARgqRMDwajAyjRxZLSuB0VAdmAADTYwSldCoKrYNSZDQGiYms1qACMWhUyKRTJRYgldDIsxNWzKMEgVIAJmweA9Ka8VPs3YYOmZEHAiAArIHRSw2JxlZBwZBcFTHZGGdO6rMgTA1JUq0poLDYVxKThcNSJlPQa1OdslAaIBqIR1WxCVYIACWwqCD4lQMBoACVTUOuC2gZ3BJhu73HVHnTG8k0XQCaDh3WGcRG3oTiQzC8ZTOkwCHGNFalXgAGgwBxVkgZD0e8n1cGjAK5gLiVLYNuMZxuYS7QGm1gltWOZ5gW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