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

Types not working on "ember-link": "^3.0.0", #777

Closed
esbanarango opened this issue Jul 19, 2023 · 5 comments
Closed

Types not working on "ember-link": "^3.0.0", #777

esbanarango opened this issue Jul 19, 2023 · 5 comments

Comments

@esbanarango
Copy link

Types are not working on "ember-link": "^3.0.0",

Cursor_and_responsible-sourcing_ts_—_Untitled__Workspace_

Currently using: "typescript": "5.1.6",

@esbanarango
Copy link
Author

Looks like the proper way to import it is:

import type LinkManagerService from 'ember-link/dist/services/link-manager';

@gossi
Copy link
Collaborator

gossi commented Jul 24, 2023

in your tsconfig.json you need to change moduleResolution to make TS understand the new exports field.

As of TS v4.7 you can use nodenext and node16, as of TS v5.0 you can and should use bundler. This is what @tsconfig/ember migrated over as well.

@gossi gossi closed this as completed Jul 24, 2023
@gossi gossi reopened this Jul 24, 2023
@gossi
Copy link
Collaborator

gossi commented Jul 24, 2023

Oups, I only intended to comment. Let us know, if that works.

@esbanarango
Copy link
Author

@gossi Thank you. It did work. Btw, how do you ship types for this moduleResolution (bundler)?

@gossi
Copy link
Collaborator

gossi commented Jul 25, 2023

Using exports entry point, see here:

"exports": {
".": "./dist/index.js",
"./*": {
"types": "./dist/*.d.ts",
"default": "./dist/*.js"
},
"./test-support": {
"types": "./dist/test-support/index.d.ts",
"default": "./dist/test-support/index.js"
},
"./addon-main.js": "./addon-main.cjs"

Which is the default case to export types (over typesVersion).

HeroicEric added a commit to HeroicEric/ember-css-transitions that referenced this issue Jul 26, 2023
This adds `./types/*` to the `exports` in `package.json`.

I don't totally understand what this does but I ran into an issue when
trying to import the `CssTransitionsRegistry` like in the README example
for "TypeScript Usage" after configuring TypeScript to use `"bundler"`
for `"moduleResolution"`.

I enabled `"bundler"` `"moduleResolution"` after seeing a comment from
@gossi suggesting that as a fix for another issue. Apparently
`"bundler"` is also now set by the latest version of `@tsconfig/ember`
and so others will likely run into this as well.

This seems to also work when `"moduleResolution"` is not set to
`"bundler"` but again, I'm not really sure what this is doing and/or why
it's needed.

References

buschtoens/ember-link#777 (comment)
https://github.com/tsconfig/bases/blob/53d80ed4a9ece800ffca9774c4e63cef3ce6ab38/bases/ember.json#L13
HeroicEric added a commit to HeroicEric/ember-css-transitions that referenced this issue Jul 27, 2023
This adds `./types/*` to the `exports` in `package.json`.

I don't totally understand what this does but I ran into an issue when
trying to import the `CssTransitionsRegistry` like in the README example
for "TypeScript Usage" after configuring TypeScript to use `"bundler"`
for `"moduleResolution"`.

I enabled `"bundler"` `"moduleResolution"` after seeing a comment from
@gossi suggesting that as a fix for another issue. Apparently
`"bundler"` is also now set by the latest version of `@tsconfig/ember`
and so others will likely run into this as well.

This seems to also work when `"moduleResolution"` is not set to
`"bundler"` but again, I'm not really sure what this is doing and/or why
it's needed.

References

buschtoens/ember-link#777 (comment)
https://github.com/tsconfig/bases/blob/53d80ed4a9ece800ffca9774c4e63cef3ce6ab38/bases/ember.json#L13
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

2 participants