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

crash if SpreadAssignment in object destructuring is not last #29610

Closed
ajafff opened this issue Jan 27, 2019 · 1 comment · Fixed by #31530
Closed

crash if SpreadAssignment in object destructuring is not last #29610

ajafff opened this issue Jan 27, 2019 · 1 comment · Fixed by #31530
Assignees
Labels
Bug A bug in TypeScript

Comments

@ajafff
Copy link
Contributor

ajafff commented Jan 27, 2019

TypeScript Version: 3.3.0-dev.20190124

Search Terms:

Code

({...x, a} = {a: 1});

Expected behavior:

Error at the rest property telling me it must be last in the object literal.

Actual behavior:

TypeError: Cannot read property 'kind' of undefined
    at Object.isIdentifier (/Users/klaus/code/wotan/node_modules/typescript/lib/tsc.js:10379:21)
    at getLiteralTypeFromPropertyName (/Users/klaus/code/wotan/node_modules/typescript/lib/tsc.js:32919:23)
    at Object.map (/Users/klaus/code/wotan/node_modules/typescript/lib/tsc.js:378:29)
    at getRestType (/Users/klaus/code/wotan/node_modules/typescript/lib/tsc.js:29001:47)
    at checkObjectLiteralDestructuringPropertyAssignment (/Users/klaus/code/wotan/node_modules/typescript/lib/tsc.js:43019:28)
    at checkObjectLiteralAssignment (/Users/klaus/code/wotan/node_modules/typescript/lib/tsc.js:42988:17)
    at checkDestructuringAssignment (/Users/klaus/code/wotan/node_modules/typescript/lib/tsc.js:43091:24)
    at checkBinaryLikeExpression (/Users/klaus/code/wotan/node_modules/typescript/lib/tsc.js:43171:24)
    at checkBinaryExpression (/Users/klaus/code/wotan/node_modules/typescript/lib/tsc.js:43166:20)
    at checkExpressionWorker (/Users/klaus/code/wotan/node_modules/typescript/lib/tsc.js:43728:28)

Playground Link: https://typescript-play.js.org/#code/BQbwdBAeA0AECGBfWBeWJ4C5YEZEEoBuIA (open devtools to see the exceptions)

Related Issues:

@RyanCavanaugh RyanCavanaugh added the Bug A bug in TypeScript label Feb 5, 2019
@RyanCavanaugh RyanCavanaugh added this to the TypeScript 3.4.0 milestone Feb 5, 2019
@cancerberoSgx
Copy link

Don't know if is the same cause, but I'm having the same error with the following code that, although is weird, tsc is not emitting any diagnostics and it crash without stacktrace (was able to get a stacktrace with ts-node).


class C<S> {
  a={}
  m(s: S) {
    const b = { ...this.a, ...s } = {   }
  }
}


/home/sg/git/jsx-alone/jsx-alone-dom-extra/node_modules/typescript/lib/tsc.js:71491
                throw e;
                ^

TypeError: Cannot read property 'kind' of undefined
    at Object.isIdentifier (/home/sg/git/jsx-alone/jsx-alone-dom-extra/node_modules/typescript/lib/tsc.js:10382:21)
    at getLiteralTypeFromPropertyName (/home/sg/git/jsx-alone/jsx-alone-dom-extra/node_modules/typescript/lib/tsc.js:32924:23)
    at Object.map (/home/sg/git/jsx-alone/jsx-alone-dom-extra/node_modules/typescript/lib/tsc.js:378:29)
    at getRestType (/home/sg/git/jsx-alone/jsx-alone-dom-extra/node_modules/typescript/lib/tsc.js:29004:47)
    at checkObjectLiteralDestructuringPropertyAssignment (/home/sg/git/jsx-alone/jsx-alone-dom-extra/node_modules/typescript/lib/tsc.js:43034:28)
    at checkObjectLiteralAssignment (/home/sg/git/jsx-alone/jsx-alone-dom-extra/node_modules/typescript/lib/tsc.js:43003:17)
    at checkDestructuringAssignment (/home/sg/git/jsx-alone/jsx-alone-dom-extra/node_modules/typescript/lib/tsc.js:43106:24)
    at checkBinaryLikeExpression (/home/sg/git/jsx-alone/jsx-alone-dom-extra/node_modules/typescript/lib/tsc.js:43186:24)
    at checkBinaryExpression (/home/sg/git/jsx-alone/jsx-alone-dom-extra/node_modules/typescript/lib/tsc.js:43181:20)
    at checkExpressionWorker (/home/sg/git/jsx-alone/jsx-alone-dom-extra/node_modules/typescript/lib/tsc.js:43743:28)


My two cents, keep it up

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug A bug in TypeScript
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants