Resolving module's name within node_modules #1039
Description
I'm trying to use tsickle to write externs from type declarations from DefinitelyTyped packages.
Although typescript does not transpile *.ts files in node_modules/@types
by default, by manually providing them to the compiler, it was possible to trigger tsickle to generate externs for them.
However, for type packages that are using module name with relative paths (e.g. lodash), tsickle generates broken externs, because module names are resolved with resolveModuleName
function and the resolved path is in a node_modules directory relative to the current typescript project root. Then tsickle does not resolve such names and writes externs on inconsistent namespaces.
Would there be any way to properly generate externs in such a use case?
It would have worked if resolveModuleName
have discarded resolved path iff it is piercing node_modules
package boundary, i.e.
- For a file, its package boundary is its nearest ancestor
node_module
directory's child directory. - Discard
resolved
and returnimported
literally only if a package boundary ofpathOfImportingFile
andresolvedModule
is different.
and it looks like to be a behavior that was intended from the beginning, if such a change would not break other projects using tsickle, would it be possible to adopt such changes?