Fix typescript with cjs compile issue #802
Merged
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.
When I tried to run examples with some versions of typescript, some versions(version< 5.3) failed to compile.
The main reason is line-bot-sdk-nodejs's compilerOption is wrong.
To provide dual package, we need to use
"module": "ESNext"
and"moduleResolution": "Bundler"
.We used
NodeNext
but we should not because this repository will support others not only Node.js.Otherwise, TypeScript will explicitly write a resolution-mode to the type definition files. (like
/// <reference types="node" resolution-mode="require"/>
)Although it should normally be written, there needs to be a way to turn this off when supporting dual packages.
In addition, this change upgrades
target
from ES2018 to ES2022. Node.js v18 supports ES2022.ref: https://github.com/microsoft/TypeScript/wiki/Node-Target-Mapping