Skip to content
This repository has been archived by the owner on Jun 21, 2023. It is now read-only.

Commit

Permalink
Fix build in blog-starter-typescript example (vercel#24695)
Browse files Browse the repository at this point in the history
This example currently fails to build with the error:

```
-> % yarn build
yarn run v1.22.10
$ next build
warn  - React 17.0.1 or newer will be required to leverage all of the upcoming features in Next.js 11. Read more: https://nextjs.org/docs/messages/react-version
info  - Using webpack 5. Reason: no next.config.js https://nextjs.org/docs/messages/webpack5
Failed to compile.

./components/alert.tsx:2:16
Type error: Could not find a declaration file for module 'classnames'. '/Users/mike/workspace/blog/node_modules/classnames/index.js' implicitly has an 'any' type.
  Try `npm i --save-dev @types/classnames` if it exists or add a new declaration (.d.ts) file containing `declare module 'classnames';`

  1 | import Container from './container'
> 2 | import cn from 'classnames'
    |                ^
  3 | import { EXAMPLE_PATH } from '../lib/constants'
  4 |
  5 | type Props = {
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
```

As of [`v2.3.1`](https://github.com/JedWatson/classnames/blob/master/HISTORY.md#v230--2021-04-01), the `classnames` package started providing its own types, so the `@types/classnames` package [became a stub](https://unpkg.com/browse/@types/classnames@2.3.1/). We get the error because the `classnames` version is pinned to the old, type-less version, while `@types/classnames` picked up the new stubbed version.

Removing `@types/classnames` and updating `classnames` to the latest version fixes the build error.

## Documentation / Examples

- [x] Make sure the linting passes
  • Loading branch information
MPLIS authored May 10, 2021
1 parent 509501e commit beae6cd
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions examples/blog-starter-typescript/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"typecheck": "tsc"
},
"dependencies": {
"classnames": "2.2.6",
"classnames": "2.3.1",
"date-fns": "2.10.0",
"gray-matter": "4.0.2",
"next": "latest",
Expand All @@ -19,7 +19,6 @@
"typescript": "^4.0.3"
},
"devDependencies": {
"@types/classnames": "^2.2.10",
"@types/jest": "^25.2.2",
"@types/node": "^14.0.1",
"@types/react": "^16.9.35",
Expand Down

0 comments on commit beae6cd

Please sign in to comment.