Search Terms
Suggestion
Allow the optional use of AllowNodeModulesRelativePaths during declaration creation
Use Cases
I understand why @weswigham added #27340 and it is correct for most consumers, especially those that publish packages for consumption on NPM.
However, it seems like for npm style mono-repos where packages are only consumed locally and not published to a registry, it is valid to have seemingly non-portable TS references (lerna, pnpm, rush, yarn workspaces). A relative path to a node_module may still be valid as long as the structure stays consistent, which it does for this style of mono repo with a single node_modules directory.
I am using a mono repo managed by Bazel and rules_nodejs and users are experiencing issues with the creation of declaration files that otherwise would contain relative paths to node_module files. bazel-contrib/rules_nodejs#1013
(The conversation in #30858 was helpful, however, it seemed to still be focusing on resolving portable types, which is only necessary when distributing the declaration files. If they are consumed locally, portability is not a concern.
Examples
I'm not sure the best way (or standard way) for these flags to be set, however, I imagine an entry in the TSConfig Compiler Options would make the most sense:
interface CompilerOptions {
...
+ allowUnportableDeclarationImports: true
}
Currently I am patching Typescript to toggle on this behavior and it appears it is working just as expected.
typescript+3.7.3.patch.txt
Checklist
My suggestion meets these guidelines:
Search Terms
Suggestion
Allow the optional use of
AllowNodeModulesRelativePathsduring declaration creationUse Cases
I understand why @weswigham added #27340 and it is correct for most consumers, especially those that publish packages for consumption on NPM.
However, it seems like for npm style mono-repos where packages are only consumed locally and not published to a registry, it is valid to have seemingly non-portable TS references (lerna, pnpm, rush, yarn workspaces). A relative path to a node_module may still be valid as long as the structure stays consistent, which it does for this style of mono repo with a single node_modules directory.
I am using a mono repo managed by Bazel and rules_nodejs and users are experiencing issues with the creation of declaration files that otherwise would contain relative paths to node_module files. bazel-contrib/rules_nodejs#1013
(The conversation in #30858 was helpful, however, it seemed to still be focusing on resolving portable types, which is only necessary when distributing the declaration files. If they are consumed locally, portability is not a concern.
Examples
I'm not sure the best way (or standard way) for these flags to be set, however, I imagine an entry in the TSConfig Compiler Options would make the most sense:
interface CompilerOptions { ... + allowUnportableDeclarationImports: true }Currently I am patching Typescript to toggle on this behavior and it appears it is working just as expected.
typescript+3.7.3.patch.txt
Checklist
My suggestion meets these guidelines: