I have Project 1 and Project 2.
After coping some file, lets say it be validators/index.ts
from Project 1 to Project 2, I experienced a strange problem:
even if files referenced by copied file via require
are not exists, TypeScript compilation success and no errors are shown.
In short, the code I talking about is something like this:
type BuilderFunc = (factory:IValidatorsFactory) => Validator;
function registerMetaTypeViaBuilderFunction(builderFunc:BuilderFunc) {
let validator = executeBuilderFunc(factory, builderFunc);
//errors handling and duplicate checks cropped away as irrelevant for this issue
validatorsMap.set(validator.id, validator);
}
registerMetaTypeViaBuilderFunction(require('./existing-validator'));
registerMetaTypeViaBuilderFunction(require('./other-validator'));
registerMetaTypeViaBuilderFunction(require('./missing-validator'));
registerMetaTypeViaBuilderFunction(require('./existing-validator3'));
registerMetaTypeViaBuilderFunction(require('./forgot-to-copy-file'));
registerMetaTypeViaBuilderFunction(require('./last-validator'));
and TypeScript compilation was successful even the missing-validator.js
and forgot-to-copy-file
are missing.
Whole point of migration from raw JS to TS was hope to catch this sort of errors automatically by IDE/compiler.
BTW, IDE is WebStorm.