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

type definitions do not work / are not detected

Open NullVoxPopuli opened this issue 4 years ago • 2 comments

Repro steps:

  1. ember new my-app 1.1 cd my-app
  2. ember install ember-cli-typescript
  3. ember install ember-cli-flash
  4. create a file that imports from ember-cli-flash, such as:
import FlashService from 'ember-cli-flash/services/flash-messages';

type MyOptions = Parameters<FlashService['add']>[0] & {
  buttons?: string[];
}

export default class FalconFlashService extends FlashService {
  add(options: MyOptions) {
    // custom stuff
    // // ...
    return super.add(options);
  }
}
  1. Observe the error (both in-editor and via tsc --build):
app/services/flash-messages.ts:1:26 - error TS2307: Cannot find module 'ember-cli-flash/services/flash-messages' or its corresponding type declarations.

1 import FlashService from 'ember-cli-flash/services/flash-messages';
                           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

NullVoxPopuli avatar Jan 28 '21 15:01 NullVoxPopuli

Same here.

AFAIK TS looks for node_modules/ember-cli-flash/services/flash-messages.d.ts when trying to resolve the types for this module. But this does not exist. For the declare module statements to work, you need to explicitly make TS aware of the index.d.ts. I managed to do that by adding this to the paths section of my tsconfig.json:

"ember-cli-flash/*": [
  "node_modules/ember-cli-flash"
],

That's ok as a workaround for now, but types working properly out of the box would be nice!

simonihmig avatar Feb 08 '21 15:02 simonihmig

This seems to be fixed for me in [email protected]. However the FlashMessage component is still not detected/not exported from this addon's TS declarations.

charlesfries avatar Feb 17 '24 20:02 charlesfries

This seems to be fixed for me in [email protected]. However the FlashMessage component is still not detected/not exported from this addon's TS declarations.

I've hit the same. declarations dir seems to be missing components. The other items (flash and services) are fine for types

Screenshot 2024-03-05 at 5 34 50 pm

Techn1x avatar Mar 05 '24 07:03 Techn1x

Components exist in 5.1 image

NullVoxPopuli avatar Mar 05 '24 13:03 NullVoxPopuli

I'm on 5.1.0 - that's the dist folder, the declarations for components don't show up in the published output

Techn1x avatar Mar 06 '24 00:03 Techn1x

what's supposed to be in this folder? image

NullVoxPopuli avatar Mar 06 '24 01:03 NullVoxPopuli

Oops! You're totally correct. I initially checked on an outdated branch that was v5.0.0, and then when I went to verify again an hour ago the ember-cli-flash version, I was on my main branch which renovate just updated to 5.1.0 overnight 😅

I can indeed see the ember-cli-flash declarations for component in the published output, and they work as I was expecting 🎉

Also, didn't know could check published output via NPM page! That is handy

Techn1x avatar Mar 06 '24 01:03 Techn1x

woo woo! I'll close this issue!

NullVoxPopuli avatar Mar 06 '24 02:03 NullVoxPopuli