typed-ember / glint

TypeScript powered tooling for Glimmer templates
https://typed-ember.gitbook.io/glint
MIT License
109 stars 51 forks source link

Suppressing Errors in `.gts` files? #580

Closed gossi closed 1 year ago

gossi commented 1 year ago

In my attempt to add glint support for ember-truth-helpers, see jmurphyau/ember-truth-helpers#176 the tests bombard the helpers with all sorts of data types. For example:

Bildschirmfoto 2023-05-20 um 19 17 50

I tried to suppress them with @glint-ignore (which I found is only for use within <template>), then I tried @ts-ignore and @ts-expect-error but neither of them causes glint to silence over these expected errors.

I even got this response from glint: Unused '@ts-expect-error' directive. glint(2578) (from eslint extension in vscode - I guess?).

So, I was wondering if this is missing or if I couldn't figure this out?

dfreeman commented 1 year ago

The comment needs to be within the template. I can't copy and paste your example since it's an inaccessible screenshot, but for instance:

await render(<template>
  {{! @glint-expect-error }}
  {{eq "hello" 123}}
</template>);
gossi commented 1 year ago

Oh sorry, my bad. The screenshot is there to show the squiggly lines.

It is actually the code above:

    const fakeContextObject = EmberObject.create({
      valueA: null,
      valueB: null,
    });

    const contextChild = fakeContextObject;

https://github.com/gossi/ember-truth-helpers/blob/194ff53b1e4e3936a65790af93a9ee43389949a1/packages/modern-test-app/tests/unit/helpers/equal-test.gts

So, within a gts file, there is no way to suppress error message in the ts/js part. I tried known ts directives, such as: @ts-ignore - but glint doesn't know about them.

dfreeman commented 1 year ago

@ts- directives should work as normal in .gts files:

@ts- directives working as expected in a .gts file
dfreeman commented 1 year ago

I pulled the branch you linked and looked at the file in question and can confirm that @ts-ignore silences the error in the EmberObject.create call, so I'm going to close this out.

If you're able to put together an isolated reproduction I'm happy to reopen and take a look