typed-ember / glint

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

`glint` fails with resolving `@ember/test-helpers` #581

Closed gossi closed 1 year ago

gossi commented 1 year ago

In my attempt to add glint support for ember-truth-helpers, see https://github.com/jmurphyau/ember-truth-helpers/pull/176 I tried to run type-checks for the glint types in a test-app next to the addon itself, by running glint.

Then glint complains about:

../../node_modules/@glint/environment-ember-loose/-private/dsl/integration-declarations.d.ts:107:16 - error TS2665: Invalid module name in augmentation. Module '@ember/test-helpers' resolves to an untyped module at '/Users/thomas/code/gossi/ember-truth-helpers/node_modules/@ember/test-helpers/index.js', which cannot be augmented.

107 declare module '@ember/test-helpers' {
                  ~~~~~~~~~~~~~~~~~~~~~

I also had to comment out environment type imports in types/global.d.ts in order to start the ember server (it was failing for the same reason):

// types/global.d.ts

// import '@glint/environment-ember-loose';
// import '@glint/environment-ember-template-imports';

Repro:

For the other errors I created #580

dfreeman commented 1 year ago

Module '@ember/test-helpers' resolves to an untyped module at '/Users/thomas/code/gossi/ember-truth-helpers/node_modules/@ember/test-helpers/index.js', which cannot be augmented.

The TS error there is telling you what's wrong—the package has @ember/test-helpers installed but no types available. You either need to add @types/ember__test-helpers or upgrade to a more recent release of @ember/test-helpers that ships its own types.

gossi commented 1 year ago

That's the thing: It is using the latest version of @ember/test-helpers which has the types, but glint is not able to find them.

dfreeman commented 1 year ago

The lockfile shows you have multiple copies floating around: https://github.com/gossi/ember-truth-helpers/blob/194ff53b1e4e3936a65790af93a9ee43389949a1/yarn.lock#L1506-L1530