-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Change in declaration file resolution in 2.9 when package.json doesn't specify types #24556
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
Comments
@Andy-MS can you take a look for 2.9.2 please |
Looks like this was changed intentionally in #24112. |
Thanks for coming back on this so quickly. I saw that semantic-ui-react actually added the A work around that I've found seems to work, is to copy the package's {
"baseUrl": ".",
"paths": {
"semantic-ui-react": ["my-type-modules/semantic-ui-react/index.d.ts"]
}
} Does that seem like the best work around for this issue? |
Same issue here ✋ |
@sheetalkamat That's a nice feature. 👍 Might be worth a separate ticket, but what about the "module" field, which points to the "esnext" version being published (and is picked over "main" by I personally publish isomorphic libraries as both I do use the "types" field, but if one forgets to hook that up, would be nice if TypeScript could also pick up "module" over "main". EDIT: nvmind, found #21423 :) |
TypeScript Version: 2.9.1 and 3.0.0-dev.201xxxxx
Typescript 2.9 seems to have changed how type declaration files are resolved when
package.json
does not contain atypes
key, and there is a declaration file next to the main script.For example the Semantic UI React project (https://github.com/Semantic-Org/Semantic-UI-React) has the following (relevant) file structure:
package.json
specifies the main script to bedist/commonjs/index.js
and does not specify atypes
key.In typescript 2.8 when importing from this module the type declaration was resolved to
node_modules/semantic-ui-react/index.d.ts
.In typescript 2.9 the type declaration is resolved to
node_modules/semantic-ui-react/dist/commonjs/index.d.ts
I definitely understand how one could argue either way, but wanted to make sure that this surfaced somewhere in case it was unintentional, and perhaps suggest that if it was intentional this change be made in typescript 3.0 as it is a breaking change?
Search Terms:
Code
Expected behavior:
Compiles with no errors
Actual behavior:
Playground Link:
No playground link as this depends on node_modules.
Related Issues:
I did not find any related issues
The text was updated successfully, but these errors were encountered: