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

glint --declaration fails to create declaration files when @glint-ignore, @glint-expect-error, or @glint-nocheck is used #599

Open
ijlee2 opened this issue Jul 6, 2023 · 6 comments

Comments

@ijlee2
Copy link

ijlee2 commented Jul 6, 2023

Background

To move @embroider/addon-blueprint away from rollup-plugin-ts, we changed how declaration files are created (it is assumed that the v2 addon runs on glint).

/* package.json for projects with Glint */
"scripts": {
  "build:types": "glint --declaration",
  "lint:types": "glint",
  "start:types": "glint --declaration --watch"
}

When I tried the new approach on ember-container-query, I noticed that,

  • build:types doesn't create the declarations folder
  • start:types does create the declarations folder

I filed a bug report in embroider-build/addon-blueprint#139.

@NullVoxPopuli and @dfreeman, who further investigated the problem, found the cause to be a @glint-ignore comment that I had added some time ago.

https://discord.com/channels/480462759797063690/1126182801876713532/1126191306109091840

Dan on Discord

it looks like a bug

specifically, if I set noEmitOnError: false, declarations are emitted

I'm guessing it happens to work with --build because that will always emit declarations, regardless of errors (because --build prioritizes having declarations available for your other project references)

ah

it's because of the @glint-ignore here
https://github.com/ijlee2/ember-container-query/blob/4.0.4/ember-container-query/src/components/container-query.hbs#L1

the bug appears to be that TS internally is counting that as an error that triggers noEmitOnError behavior

if I add an entry for element in the registry in unpublished-development-types, everything works

Additional notes

By adding console.log()'s, I checked that glint --declaration results in determineOptionsToExtend() correctly setting options.{noEmit,declaration,emitDeclarationOnly} (to false, true, and true, respectively).

I'm guessing that something different happens,

  1. When we run glint --build as opposed to glint --declaration
  2. When we run glint --declaration --watch as opposed to just glint --declaration
@enspandi
Copy link

enspandi commented Aug 1, 2023

👍

We are currently experiencing a similar issue when moving from rollup-plugin-ts to the recent embroider blueprint changes.

The build:types script just silently completes but no declarations folder is created, but the start:types script does work.

@22a
Copy link

22a commented Aug 16, 2023

This issue is affecting our addons too - we've resorted to disabling glint typechecking for all hbs files to restore declaration generation from ts files:

// in tsconfig.json
"exclude": ["src/**/*.hbs"],

@basz
Copy link

basz commented Nov 3, 2023

same for {{! @glint-expect-error }}

@bartocc
Copy link

bartocc commented Nov 27, 2023

We got hit by this too, because of a {{! @glint-expect-error }} just like @basz

1- is it possible to update this ticket's name to add a ref to {{! @glint-expect-error }}?
2- Any guidance on how to start a PR to address this issue?

@dfreeman
Copy link
Member

This is probably not trivial for a new contributor to fix (I’m not totally sure what the solution will look like at this point), but I expect that setting noEmitOnError: false should be a viable workaround in the meantime.

@ijlee2 ijlee2 changed the title glint --declaration fails to create declaration files when a @glint-ignore comment is present glint --declaration fails to create declaration files when @glint-ignore, @glint-expect-error, or @glint-nocheck` is used Nov 28, 2023
@ijlee2 ijlee2 changed the title glint --declaration fails to create declaration files when @glint-ignore, @glint-expect-error, or @glint-nocheck` is used glint --declaration fails to create declaration files when @glint-ignore, @glint-expect-error, or @glint-nocheck is used Nov 28, 2023
@ijlee2
Copy link
Author

ijlee2 commented Nov 28, 2023

@bartocc I updated the title based on your suggestion.

@dfreeman Several issues were reported since this one, so I think it may be hard for people who are new to Glint to discover this issue. Could we pin this issue so that it appears on top of the page for https://github.com/typed-ember/glint/issues?

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

6 participants