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 and exports in dependency package.json break module specifier generation #46281

Closed
andrewbranch opened this issue Oct 8, 2021 · 1 comment

Comments

@andrewbranch
Copy link
Member

#46159 seems to cause us to ignore the top-level types field when there’s an exports field when trying to see if we can resolve a node_modules path to a package-style module specifier. Complete failing fourslash test:

// @module: commonjs

// @Filename: /node_modules/react-hook-form/package.json
//// {
////   "name": "react-hook-form",
////   "main": "dist/index.cjs.js",
////   "module": "dist/index.esm.js",
////   "types": "dist/index.d.ts",
////   "exports": {
////     "./package.json": "./package.json",
////     ".": {
////       "import": "./dist/index.esm.js",
////       "require": "./dist/index.cjs.js"
////     }
////   }
//// }

// @Filename: /node_modules/react-hook-form/dist/index.cjs.js
//// module.exports = {};

// @Filename: /node_modules/react-hook-form/dist/index.esm.js
//// export function useForm() {}

// @Filename: /node_modules/react-hook-form/dist/index.d.ts
//// export function useForm(): any;

// @Filename: /index.ts
//// useForm/**/

verify.importFixModuleSpecifiers("", ["react-hook-form"]);
@andrewbranch andrewbranch added the Bug A bug in TypeScript label Oct 8, 2021
@andrewbranch andrewbranch added this to the TypeScript 4.5.1 milestone Oct 8, 2021
@andrewbranch andrewbranch changed the title types and exports in dependency package.json break auto-imports types and exports in dependency package.json break module specifier generation Oct 8, 2021
@weswigham
Copy link
Member

This is 100% fully working as intended. exports blocks main lookup, and types is just ts-specific main.

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