Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

type definitions do not work / are not detected #348

Closed
NullVoxPopuli opened this issue Jan 28, 2021 · 8 comments
Closed

type definitions do not work / are not detected #348

NullVoxPopuli opened this issue Jan 28, 2021 · 8 comments

Comments

@NullVoxPopuli
Copy link
Contributor

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';
                           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

@simonihmig
Copy link
Contributor

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
Copy link
Contributor

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
Copy link
Contributor

Techn1x commented Mar 5, 2024

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
Copy link
Contributor Author

Components exist in 5.1
image

@Techn1x
Copy link
Contributor

Techn1x commented Mar 6, 2024

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

@NullVoxPopuli
Copy link
Contributor Author

what's supposed to be in this folder?
image

@Techn1x
Copy link
Contributor

Techn1x commented Mar 6, 2024

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
Copy link
Contributor Author

woo woo! I'll close this issue!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants