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

fix(glint): adding @glint-expect-error around multiple line mustache statements #1121

Closed
wants to merge 2 commits into from

Conversation

wondersloth
Copy link
Contributor

@wondersloth wondersloth commented Jun 9, 2023

Authored with @egorio. We paired on this solution.

Problem

  • Glint Plugin would incorrectly insert comments within an mustache statement nearest the site of the glint error.
  • The diagnostic would point to the actual start of the bad argument.
{{concat
  {{! @glint-expect-error @rehearsal TODO TS2339: Property 'someArg1' does not exist on type '{}'. }}
  @someArg2
  @someArg3
  @someArg4
  @someArg5
  @someArg6
  @someArg7
  @someArg8
  @someArg9
  @someArg10
}}

This fixes #1119 and another issue where a multiline handlebars statement within an html tag would produce invalidate handlebars syntax after running migrate.

<div
  class="{{concat
       {{! @glint-expect-error @rehearsal TODO TS2339: Property 'someArg1' does not exist on type '{}'. }}
      @someArg1
      @someArg2
      @someArg3
      @someArg4
      @someArg5
      @someArg6
      @someArg7
      @someArg8
      @someArg9
      @someArg10
    }}"
>
  Hello World!
</div>

Why is this important?

When rehearsal runs against our internal products it breaks .hbs files.

Changes

  • When given a diagnostic in an .hbs context, it will find up to the opening curlies, and inject there.
  • DRYs up usage of change magicString changeTracker.appendRight method.

TODO

  • Need to write a smoke-test for this using a angle bracket component invocation with a glint error.
<MyComponent
  @badArg
  @someArg2
  @someArg3
  @someArg4
  @someArg5
  @someArg6
  @someArg7
  @someArg8
  @someArg9
  @someArg10
}}
/>

Matthew Edwards added 2 commits June 7, 2023 14:56
In a nested helper invocation, glint-expect-error comments are
injected at incorrect positions.

This is because a formatter is run and attempts to single-line the
helper invocation.

If the nested helper invocation is short enough it will move the
comment up.

If it's too long, it will keep the enumerated args, and keep the bad
comments in place.
@wondersloth
Copy link
Contributor Author

Linking to issue: typed-ember/glint#589

@wondersloth
Copy link
Contributor Author

Closing this PR because we are still breaking HBS with {{! @glint-expect-errors ...}} injections.

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

Successfully merging this pull request may close these issues.

bug: glimmer-syntax-error comment injected inside of long helper invocations
1 participant