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

Fix build in blog-starter-typescript example #24695

Merged
merged 2 commits into from
May 10, 2021
Merged

Conversation

mikeplis
Copy link

@mikeplis mikeplis commented May 1, 2021

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, the classnames package started providing its own types, so the @types/classnames package became a stub. 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

  • Make sure the linting passes

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.
@ijjk ijjk added the examples Issue/PR related to examples label May 1, 2021
@kodiakhq kodiakhq bot merged commit ea9fe97 into vercel:canary May 10, 2021
flybayer pushed a commit to blitz-js/next.js that referenced this pull request Jun 1, 2021
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
@vercel vercel locked as resolved and limited conversation to collaborators Jan 28, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
examples Issue/PR related to examples
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants