- run
npm i
- install dependencies - run
npm run start
- will build the project and outputIt Works!
to the console - run
npm run case-one
- will run jest test successfully. Navigating tosrc/case-one.spec.ts
will highlight"custom/module"
with red with errorCannot find module 'custom/module' or its corresponding type declarations.
- run
npm run case-two
- will fail with errorscripts/case-two.ts:1:34 - error TS2307: Cannot find module 'custom/module' or its corresponding type declarations.
- Navigating to
scripts/case-two.ts
will highlight import with the same error as for the test file.
- Navigating to
- run
npm run case-three
- will fail with errorsrc/helpers/test-helpers.ts:1:34 - error TS2307: Cannot find module 'custom/module' or its corresponding type declarations.
- Navigating to
scripts/case-three.ts
will not show any errors, because type is used only in an imported function, and in that file (src/helpers/test-helpers.ts
) custom module is resolved successfully because tsconfig actually picks it up.
- Navigating to
case-two-works
andcase-three-works
scripts are just there to show that scripts can run in atranspile-only
mode, but that is a workaround that would be preferable to avoid, because it can hide valid errors.
PizzaPartyInc/CustomTypesInExcludedFiles
When custom types are defined in project and they must be used in files that are excluded from typescript - various cases appear.
TypeScript