adopted-ember-addons / ember-cli-flash

Simple, highly configurable flash messages for ember-cli
https://www.npmjs.com/package/ember-cli-flash
MIT License
355 stars 113 forks source link

type definitions do not work / are not detected #348

Closed NullVoxPopuli closed 6 months ago

NullVoxPopuli commented 3 years ago

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); } }

5. 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';



```
simonihmig commented 3 years ago

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!

charlesfries commented 6 months ago

This seems to be fixed for me in ember-cli-flash@5.0.0. However the FlashMessage component is still not detected/not exported from this addon's TS declarations.

Techn1x commented 6 months ago

This seems to be fixed for me in ember-cli-flash@5.0.0. 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

NullVoxPopuli commented 6 months ago

Components exist in 5.1 image

Techn1x commented 6 months ago

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

NullVoxPopuli commented 6 months ago

what's supposed to be in this folder? image

Techn1x commented 6 months ago

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

NullVoxPopuli commented 6 months ago

woo woo! I'll close this issue!