Fixing the verbatimModuleSyntax issue #399
Merged
+155
−23
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Overivew
When library .d.ts files import .ts files, those .ts files are included in the compilation step of the user projects. For example, since index.d.ts imports toolProperties.ts here, toolProperties.ts will be compiles as part of the user project
This is problematic since file may not compile under tsconfig.json settings of the user
For example, this library is targets CJS, but uses ESM syntax (export). If users use verbatimModuleSyntax: true - which requires that CJS files use CJS syntax - their compilation will fail, with no easy fix
Similarly, if users if users use any strict* option this project doesn't, toolProperties.ts may not compile
Effectively, toolProperties.ts of this library limits what tsconfig.json settings users can use
Expected behavior
Library's .d.ts files may import only other .d.ts files, but not .ts files
Actual behavior
index.d.ts imports toolProperties.ts here
Example user project that fails to compile due to this: https://github.com/azerum/azure-functions-type-check-bug
Suggested fix
Generate .d.ts file for toolProperties.ts and export that. I am not familiar with why .d.ts files of this library are written manually and not generated from .ts files, I assume there must be a good reason..