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.
What kind of change does this PR introduce?
Refactor
Did you add tests for your changes?
N/A
Summary
Makes TypeScript an optional peer dependency, rather than a direct dependency.
TS was originally added as a dependency here as part of the TypeScript support. However, today we only rely on TS to support the TS checker plugin, which only runs if the user has a
tsconfig.json
. This makes it a perfect optional peer dependency.As for why this is needed, it's to better address #1797. Preact has began to use very new TypeScript lib types (preactjs/preact#4023) which necessitate using newer TypeScript releases.
preact-cli
will prioritize it's own dependencies over user-installed ones (to avoid conflicts, especially with Webpack plugin versions), so it'd be ideal if we relinquish control over TypeScript versioning entirely, leaving it up to the user.Does this PR introduce a breaking change?
Nothing should break except in the case someone uses TypeScript (has a
tsconfig.json
in their project), but doesn't have TS listed as a dependency.They should have TS listed as a dep anyhow (we do in all of our templates and it's pretty standard behavior), so I'm fine with that, even if it is a tiny breakage.