I am developing a library called 'vee-type-safe' for runtime type checking. Everything worked beautifully untill I added a subdirectory /express and a file /express/index.ts where I export some ExpressJS middleware type checking factories.
So I have the following structure:
vee-type-safe
|- build
|- package.json
|- declarations
| |- is-iso-date.d.ts
|
|- tsconfig.json
|- index.ts // lightweight core library
|- express
|-index.ts // express middleware factories
In express/index.ts file I import my library core '../index.ts' module.
In my core module I have the following import:
import isISODate = require('is-iso-date');
'is-iso-date' package has no typings, so I created declarations directory with is-iso-date.d.ts which is as simple as this:
declare module 'is-iso-date' {
function isISODate(suspect: string): boolean;
export = isISODate;
}
I added "typeRoots": [ ..., "declarations"] to tsconfig.json
I added "types": "build/index.d.ts" to package.json
When I run tsc in my package everything compiles with no errors.
But when I install my 'vee-type-safe' library as a dependency to some project via npm and try to compile it, I get the following error:
Could not find a declaration file for module 'is-iso-date'.
'/home/tegeran/projects/is-iso-date-issue/node_modules/is-iso-date/index.js'
implicitly has an 'any'type.
Try `npm install @types/is-iso-date` if it exists or add a new declaration (.d.ts)
file containing `declare module 'is-iso-date';`
1 import isISODate = require('is-iso-date');
This happens only when I import 'vee-type-safe/express' submodule. When I import my core 'vee-type-safe' module, no errors are generated. What am I missing here?
I created a github repo with a bare minimum project to demonstrate this error