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

Fails with {{link-to params=...}} #185

Open
gorner opened this issue Nov 5, 2019 · 4 comments
Open

Fails with {{link-to params=...}} #185

gorner opened this issue Nov 5, 2019 · 4 comments

Comments

@gorner
Copy link

gorner commented Nov 5, 2019

Error: Transformation errored on file app/templates/components/folder/component-name.hbs. Reason TypeError: Cannot read property 'type' of undefined. Please report this in https://github.com/ember-codemods/ember-angle-brackets-codemod/issues

Stack trace:
TypeError: Cannot read property 'type' of undefined
    at transformLinkToAttrs (/Users/gorner/.npm/_npx/12814/lib/node_modules/ember-angle-brackets-codemod/transforms/angle-brackets/transform.js:229:32)
    at transformNode (/Users/gorner/.npm/_npx/12814/lib/node_modules/ember-angle-brackets-codemod/transforms/angle-brackets/transform.js:363:22)
    at BlockStatement (/Users/gorner/.npm/_npx/12814/lib/node_modules/ember-angle-brackets-codemod/transforms/angle-brackets/transform.js:409:16)
    at visitNode (../../../../../packages/@glimmer/syntax/lib/traversal/traverse.ts:97:14)
    at visitArray (../../../../../packages/@glimmer/syntax/lib/traversal/traverse.ts:187:18)
    at visitKey (../../../../../packages/@glimmer/syntax/lib/traversal/traverse.ts:168:5)
    at visitNode (../../../../../packages/@glimmer/syntax/lib/traversal/traverse.ts:117:7)
    at visitKey (../../../../../packages/@glimmer/syntax/lib/traversal/traverse.ts:170:18)
    at visitNode (../../../../../packages/@glimmer/syntax/lib/traversal/traverse.ts:117:7)
    at visitArray (../../../../../packages/@glimmer/syntax/lib/traversal/traverse.ts:187:18)
    at module.exports (/Users/gorner/.npm/_npx/12814/lib/node_modules/ember-angle-brackets-codemod/transforms/angle-brackets/index.js:33:11)

This error is occurring with two templates, with the only thing in common (and different from every other template) being the use of the (private) params option in link-to, as in {{#link-to params=someObject ...}}. I suspect that's the reason for the error, but still felt like I should report it even if it's a wontfix scenario.

@tylerturdenpants
Copy link
Collaborator

Hi @gorner

Can you provide a failing test?

@gorner
Copy link
Author

gorner commented Nov 6, 2019

Pushed a branch with a failing test to: https://github.com/gorner/ember-angle-brackets-codemod/tree/bug/link-to-params

Note that I am not certain that @params works (or is intended to work) with the angle-bracket version.

Additional context: We mostly use this in our app for a set of items with associated links, some of which may just be query param settings on the current route, some of which may be to a different route. e.g.:

buttons: [{
  // ...
  linkParams: [{ isQueryParams: true, values: { someBoolean: true } }] // set ?someBoolean=true on current route
},
{
  linkParams: ['some.route.name', this.model.id] // different route
}]
{{#each buttons as |btn|}}
  {{#link-to params=btn.linkParams ...}} ... {{/link-to}}
{{/each}}

@backspace
Copy link
Contributor

This just happened to me too, thanks for opening the issue, @gorner. The file in question was this one.

backspace added a commit to hashicorp/nomad that referenced this issue May 29, 2020
This is the result of running the codemod and manually inserting
line breaks where there were previously multiline invocations.
I used file line length as a guide, aiming to keep them the same,
with one exception: app/templates/components/gutter-menu.hbs,
where I made the LinkTo @route instances be on their own lines
which added two lines to the file.

There was an error processing one file, as in
ember-codemods/ember-angle-brackets-codemod#185

Uses of link-to with standalone data attributes were also missed
ember-codemods/ember-angle-brackets-codemod#237
backspace added a commit to hashicorp/nomad that referenced this issue May 29, 2020
This is a manual fix for this instance missed because of
ember-codemods/ember-angle-brackets-codemod#185
@backspace
Copy link
Contributor

@params does still work, incidentally! 🥳

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

No branches or pull requests

3 participants