Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add comment that can fix TypeScript errors with Yarn #2800

Merged
merged 2 commits into from
Mar 31, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions create-snowpack-app/app-template-react-typescript/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,21 @@ Open http://localhost:8080 to view it in the browser.
The page will reload if you make edits.
You will also see any lint errors in the console.

> In case you use yarn version 2 (berry) and have "file not found" errors in the console.
Typescript does not support yarn 2 folder structure directly (yet).
The workaround is to replace the loading of the typescript plugin in snowpack.config.js with a call to [phpify](https://yarnpkg.com/advanced/pnpify).

```json
plugins: [
// '@snowpack/plugin-typescript',
['@snowpack/plugin-typescript', { tsc: 'yarn pnpify tsc' }],
]
```

Issue: [microsoft/TypeScript#28289](https://github.com/microsoft/TypeScript/issues/28289)

More info: https://medium.com/swlh/getting-started-with-yarn-2-and-typescript-43321a3acdee

### npm run build

Builds a static copy of your site to the `build/` folder.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ module.exports = {
'@snowpack/plugin-react-refresh',
'@snowpack/plugin-dotenv',
'@snowpack/plugin-typescript',
// if using yarn v2 and have 27+ TypeScript errors replace with
// ['@snowpack/plugin-typescript', { tsc: 'yarn pnpify tsc' }],
],
routes: [
/* Enable an SPA Fallback in development: */
Expand Down