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

Transpilation issue with this remaining in function args #223

Open
Techn1x opened this issue Dec 7, 2023 · 5 comments
Open

Transpilation issue with this remaining in function args #223

Techn1x opened this issue Dec 7, 2023 · 5 comments

Comments

@Techn1x
Copy link

Techn1x commented Dec 7, 2023

I have a GTS file like the following;

function someFunction(this: SomeContext, data: Row[]) {
  const filter = this.filter
  return data.map(...)
}

class extends Component<Signature> {
  get something() {
    someFunction.call(this.args.someOtherContext, this.rows)
  }

  <template>
    {{#each this.something as |row|}}
      ...
    {{/each}}
  </template>
}

It's a contrived example, but the point is there's the someFunction function in the GTS file that has this: SomeContext intended to be a type hint, to be transpiled away.

When debugging the code in browser, I can see that it is present as a real arg.
Screenshot 2023-12-07 at 3 22 53 pm
(I also checked the source without sourcemaps, and can see this1 is still present in the args)

This means the actual named argument data becomes undefined in the function.

Some findings;

  • This was not an issue in the original TS file - it was only once the file was converted to GTS
  • The application does not have ember-cli-typescript installed - but installing it makes no difference to the output.
@backspace
Copy link
Contributor

I’m seeing this too in this PR to update to 4.1.1. We have tests that use an extended this, they are unable to access the QUnit assert as it is undefined.

Boxel Tests 2024-05-28 14-32-57

It shows up in tests as a failed call to a custom assertion.

@NullVoxPopuli
Copy link
Collaborator

NullVoxPopuli commented May 28, 2024

Have you also updated:

  • ember-cli-babel (at least 8.2)
  • babel-plugin-ember-template-compilation (should be at least 2.2.5 in your lockfile)
  • @embroider/compat (at least updated in the last couple weeks)
  • @emmroider/core (same)
  • ember-auto-import

?

V4 of ember-template-imports requires newer babel transpilation settings, provided by the above packages (embroider not required if you aren't using it, fwiw)

@backspace
Copy link
Contributor

Thanks, should these be mentioned here? I do see it here.

I updated each of these in a series of commits (babel-plugin-ember-template-compilation seemed to need to happen with the Embroider updates) and sadly the problem remained.

However I looked for other tests that used a custom test context because I was sure we had them in .gts files and found that they were using a different style:

  test<TestContextWithSave>('can create new card-instance file in local realm with card type from same realm', async function (assert) {

I changed the tests to follow that pattern and the problem went away. (Some tests are still failing but seemingly not due to this problem.) Maybe this is more of a workaround than a true fix, but it’s worth trying?

@ef4
Copy link
Collaborator

ef4 commented May 28, 2024

This bug is covered by embroider-build/content-tag#71

@NullVoxPopuli
Copy link
Collaborator

should be fixed now

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

4 participants