typed-ember / glint

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

`glint --declaration` fails to generate declarations when `tsc --declaration` reports errors #704

Open NullVoxPopuli opened 3 months ago

NullVoxPopuli commented 3 months ago

Repro tsconfig.json:

{
  "extends": "@tsconfig/ember/tsconfig.json",
  "include": ["src/**/*", "unpublished-development-types/**/*"],
  "glint": {
    "environment": ["ember-loose", "ember-template-imports"]
  },
  "compilerOptions": {
    "target": "ESNext",
    "allowJs": true,
    "skipLibCheck": true,
    "declarationDir": "declarations",
    // Enable faster builds
    "incremental": true,
    // Required, else declarations don't emit
    // @tsconfig/ember sets noEmit: true
    "noEmit": false,
    // noEmitOnError true is not a good default.
    // especially as CLI tools can accidentally swallow errors
    "noEmitOnError": false,

    /**
      https://www.typescriptlang.org/tsconfig#rootDir
      "Default: The longest common path of all non-declaration input files."

      Because we want our declarations' structure to match our rollup output,
      we need this "rootDir" to match the "srcDir" in the rollup.config.mjs.

      This way, we can have simpler `package.json#exports` that matches
      imports to files on disk
    */
    "rootDir": "./src",

    // This is a lint, and there is debate about whether or not it should be included
    "noPropertyAccessFromIndexSignature": false,

    /**
      https://www.typescriptlang.org/tsconfig#verbatimModuleSyntax

      We don't want to include types dependencies in our compiled output, so tell TypeScript
      to enforce using `import type` instead of `import` for Types.
     */
    "verbatimModuleSyntax": true,

    /**
      https://www.typescriptlang.org/tsconfig#allowImportingTsExtensions

      We want our tooling to know how to resolve our custom files so the appropriate plugins
      can do the proper transformations on those files.
    */
    "allowImportingTsExtensions": true
  }
}

this will fail to generate declarations.

You need to add "emitDeclarationOnly": true, in order for declarations to be added.

glint --declaration will exit without failure, exit status 0. tsc --declaration will correctly exit with failure.