Skip to content

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

@ijlee2

Description

@ijlee2

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions