ember-cli icon indicating copy to clipboard operation
ember-cli copied to clipboard

set `declaration: false` in tsconfig.json for the app blueprint.

Open NullVoxPopuli opened this issue 3 years ago • 2 comments

Context here: https://github.com/emberjs/ember.js/issues/20556

declaration: true is needed for libraries tho, so we don't want to change that for addons.

NullVoxPopuli avatar Oct 14 '23 18:10 NullVoxPopuli

I tried to follow the line from my recent adoption of ember-router-template going here. For me this setting did not help in my app:

// tsconfig.json

{
  "declaration": false,
  "extends": "@tsconfig/ember/tsconfig.json",
  "glint": {
    "environment": [
      "ember-loose",
      "ember-template-imports",
    ]
  },
  "compilerOptions": {
    // The combination of `baseUrl` with `paths` allows Ember's classic package
    // layout, which is not resolvable with the Node resolution algorithm, to
    // work with TypeScript.
    "baseUrl": ".",
    "paths": {
      "ass-42-ui/tests/*": ["tests/*"],
      "ass-42-ui/*": ["app/*"],
      "*": ["types/*"]
    },
    "types": [
      "ember-source/types",
      "./node_modules/ember-data/unstable-preview-types",
      "./node_modules/@ember-data/store/unstable-preview-types",
      "./node_modules/@ember-data/adapter/unstable-preview-types",
      "./node_modules/@ember-data/graph/unstable-preview-types",
      "./node_modules/@ember-data/json-api/unstable-preview-types",
      "./node_modules/@ember-data/legacy-compat/unstable-preview-types",
      "./node_modules/@ember-data/request/unstable-preview-types",
      "./node_modules/@ember-data/request-utils/unstable-preview-types",
      "./node_modules/@ember-data/model/unstable-preview-types",
      "./node_modules/@ember-data/serializer/unstable-preview-types",
      "./node_modules/@ember-data/tracking/unstable-preview-types",
      "./node_modules/@warp-drive/core-types/unstable-preview-types"
    ]
  }
}

Still results in following TS unhappiness over my ember-route-template code complaining over export default RouteTemplate:

The inferred type of 'default' cannot be named without a reference to '.pnpm/@[email protected]/node_modules/@glimmer/interfaces'. This is likely not portable. A type annotation is necessary.

Code of said route template:

import RouteTemplate from 'ember-route-template';
import Component from '@glimmer/component';

interface Signature {
  Args: {
    model: string;
  };
}

class AddABuildingRoute extends Component<Signature> {
  <template>
    hi
  </template>
}

export default RouteTemplate(AddABuildingRoute);

And my "ember-route-template": "^1.0.3", is as devDependencies if that might play any role.

MichalBryxi avatar Dec 04 '24 13:12 MichalBryxi

Aaand I can answer my own "question" the correct syntax for tsconfig.json is (omitting the unnecessary parts):

{
  "compilerOptions": {
    "declaration": false,
    },
}

So the declaration has to be nested inside compilerOptions.

MichalBryxi avatar Dec 04 '24 13:12 MichalBryxi