Open
Description
originally raised at typescript-eslint/typescript-eslint#5815
Description
contrary to popular belief, when publishing npm packages it's actually a good idea to include the source code in the published package. this is because you can use the
declarationMap
compiler option to makectrl+click
navigate to the source code instead of the declarations.unfortunately IDEs sometimes incorrectly suggest importing from the source code instead of the compiled code. i think there should be an eslint rule to warn against this
folder structure
my-project/ ├── node_modules/ │ └── some-package/ │ ├── dist/ │ │ ├── index.js │ │ ├── index.d.ts │ │ ├── foo.js │ │ └── foo.d.ts │ ├── src/ │ │ ├── index.ts │ │ └── foo.ts │ ├── tsconfig.json │ └── package.json └── src/ └── index.ts
Fail Cases
// my-project/src/index.ts import {foo} from 'some-package/src/foo'Pass Cases
// my-project/src/index.ts import {foo} from 'some-package/dist/foo'Additional Info
while this won't cause any runtime errors, i believe it's bad for performance as it causes typescript to unnecessarily re-compile the package, when it's already been compiled