Added support for updating tsconfig.json when using astro add#4959
Conversation
🦋 Changeset detectedLatest commit: bf9acd1 The changes in this PR will be included in the next version bump. Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
| "react-dom": "^17.0.2 || ^18.0.0", | ||
| "@types/react": "^17.0.50 || ^18.0.21" |
There was a problem hiding this comment.
Unrelated, but those two were missing and are necessary for using React with TypeScript
|
Putting this back into WIP because I realized there's a major issue with how the configs are merged when using complex tsconfigs |
b7760e8 to
ba72072
Compare
| typeof (globalThis as any).AggregateError !== 'undefined' | ||
| ? (globalThis as any).AggregateError |
There was a problem hiding this comment.
I believe the type-fest upgrade made this fail. I suspect we were depending on it by accident, weird
There was a problem hiding this comment.
This code is not accidental, we create AggregateErrors when there are multiple CSS errors during compilation. AggregateError is being polyfilled here as its not available in certain Node versions.
But I guess it's possible that type-fest was shimming the types for it, which is why we weren't getting an error before.
|
Fixes #5017 |
| const updateTSConfigResult = await updateTSConfig(cwd, logging, integrations, flags); | ||
|
|
||
| switch (updateTSConfigResult) { | ||
| case UpdateResult.none: { |
|
Alternatively, you can use a per-file pragma to set this option, like this : /** @jsxImportSource solid-js */
import type { Component } from 'solid-js'; |
| 'astro': minor | ||
| --- | ||
|
|
||
| Added support for updating TypeScript settings automatically when using `astro add` |
There was a problem hiding this comment.
Would you mind expanding this description a bit more into like a paragraph so it can be copy/pasted into a release blog post? Thanks!
There was a problem hiding this comment.
Sure, let me do that
Appeared again after rebasing


Changes
This adds a step at the end of
astro addwhere it updates yourtsconfig.jsonorjsconfig.json:It handles installing multiple frameworks by choosing the first framework and showing a warning with a link to our docs:
And a specific message for Vue until Volar 1.0 is out and fix this issue:

Fix #4506, Fix #5017
Testing
Added tests for underlying tsconfig loading / manipulation logic.
astro additself is untested at the momentDocs
N/A, I think? Will consult docs team