I added ` *.tsbuildinfo` to gitignores of examples that use typescript and don't already have it. By use typescript I mean have `tsconfig` somewhere in their directory tree.
I used the following script to update the files:
```bash
#!/bin/bash
set -eou pipefail
cd examples
examples=`git ls-files . | grep tsconfig | xargs dirname | grep -v "/"`
for example in $examples; do
if ! grep -q tsbuildinfo $example/.gitignore; then
gitignore="$example/.gitignore"
echo $gitignore
tail -c1 $gitignore | read -r _ || echo >> $gitignore
echo -e "\n# typescript\n*.tsbuildinfo" >> $gitignore
fi
done
```
This PR is looking forward to improve documentation exemples about usage of Next.js with Typescript and Styled-components.
I added Typescript types to the original exemple [Example app with styled-components using babel
](https://github.com/vercel/next.js/tree/canary/examples/with-styled-components-babel)
## Feature
- [x] Related issues linked using
- [x] Documentation added
## Documentation / Examples
- [x] Make sure the linting passes by running `yarn lint`
fixes#36008
This PR updates the docs and examples for `create-next-app` to include pnpm usage.
The following script was used to update every example README:
```js
const fs = require('fs')
const examples = fs.readdirSync('./examples')
for (let example of examples) {
const filename = `./examples/${example}/README.md`
const markdown = fs.readFileSync(filename, 'utf8')
const regex = new RegExp(`^yarn create next-app --example (.*)$`, 'gm')
const output = markdown.replace(regex, (yarn, group) => {
const pnpm = `pnpm create next-app -- --example ${group}`
return `${yarn}\n# or\n${pnpm}`
})
fs.writeFileSync(filename, output)
}
```
* rename example with-styled-components to with-styled-components-babel
* update with-styled-components references
* update docs on react hydratation erros for styled components
* clone with-styled-components-babel without babel config
* add styledComponents to compiler options in next.config
* replace babel dependency with Next.js SWC compiler
* upgrade example typescript version
example with-typescript-styled-components had a typescript dependency
lower than the recommended version. Upgraded from 4.2.4 to 4.5.5.
* Apply suggestions from code review
* update readme for with-styled-components-babel
remove Notes section since it describes a workaround which is no longer
required to work with `next/link`.
Co-authored-by: Lee Robinson <me@leerob.io>
Co-authored-by: Balázs Orbán <info@balazsorban.com>