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

Cannot find type definition file for 'ua-parser-js' since 12.0.5-canary.11 with skipLibCheck set to false #31992

Closed
Systemcluster opened this issue Dec 1, 2021 · 4 comments · Fixed by #32025
Labels
bug Issue was opened via the bug report template.

Comments

@Systemcluster
Copy link

What version of Next.js are you using?

12.0.5-canary.12

What version of Node.js are you using?

17.1.0

What browser are you using?

Any

What operating system are you using?

Windows 10 (10.0.19043 Build 19043)

How are you deploying your application?

next export

Describe the Bug

Since version 12.0.5-canary.11, next build fails the typechecking stage when skipLibCheck in tsconfig.json is set to false:

[build:build] > cross-env NODE_ENV=production next build
[build:build]
[build:build] info  - Checking validity of types...
[build:build] Failed to compile.
[build:build]
[build:build] ./node_modules/.pnpm/[email protected]_f13a0b3f31b50fd478b6a367e2ced557/node_modules/next/dist/server/web/spec-extension/request.d.ts:1:23
[build:build] Type error: Cannot find type definition file for 'ua-parser-js'.
[build:build]
[build:build] > 1 | /// <reference types="ua-parser-js" />
[build:build]     |                       ^
[build:build]   2 | import type { I18NConfig } from '../../config-shared';
[build:build]   3 | import type { IResult } from 'next/dist/compiled/ua-parser-js';
[build:build]   4 | import type { RequestData } from '../types';
[build:build] npm run build:build exited with code 1

Expected Behavior

The typecheck should pass when skipLibCheck is set to false, like in previous versions.

To Reproduce

Create a project and install the canary version of next.js (both 12.0.5-canary.11 and 12.0.5-canary.12 reproduce this currently):

yarn create next-app --ts .
yarn add next@canary

Adjust tsconfig.json:

-    "skipLibCheck": true,
+    "skipLibCheck": false,

Then run yarn run build.

@Systemcluster Systemcluster added the bug Issue was opened via the bug report template. label Dec 1, 2021
@balazsorban44 balazsorban44 self-assigned this Dec 1, 2021
@ijjk
Copy link
Member

ijjk commented Dec 1, 2021

Hi, this should be fixed in v12.0.5-canary.13 of Next.js, please update and give it a try!

@ijjk ijjk closed this as completed Dec 1, 2021
@Systemcluster
Copy link
Author

The ua-parser-js error is fixed in .13 👍 but now there is a type error in a different file:

[build:build] info  - Checking validity of types...
[build:build] Failed to compile.
[build:build]
[build:build] ./node_modules/.pnpm/[email protected][email protected][email protected]/node_modules/next/dist/server/web/spec-extension/response.d.ts:2:45
[build:build] Type error: Could not find a declaration file for module 'next/dist/compiled/cookie'. 'K:/Development/next-bug-report/node_modules/.pnpm/[email protected][email protected][email protected]/node_modules/next/dist/compiled/cookie/index.js' implicitly has an 'any' type.
[build:build]
[build:build]   1 | import type { I18NConfig } from '../../config-shared';
[build:build] > 2 | import type { CookieSerializeOptions } from 'next/dist/compiled/cookie';
[build:build]     |                                             ^
[build:build]   3 | import { NextURL } from '../next-url';
[build:build]   4 | declare const INTERNALS: unique symbol;
[build:build]   5 | export declare class NextResponse extends Response {
[build:build] npm run build:build exited with code 1

kodiakhq bot pushed a commit that referenced this issue Dec 2, 2021
This ensures type checking passes correctly for middleware types when `skipLibCheck: false` is set in `tsconfig.json`. This also moves the `middleware-types` to be an isolated test to ensure it isn't relying on any monorepo dependencies. 

## Bug

- [x] Related issues linked using `fixes #number`
- [x] Integration tests added
- [ ] Errors have helpful link attached, see `contributing.md`

Fixes: #31992 (comment)
@ijjk
Copy link
Member

ijjk commented Dec 2, 2021

Hi, the above error should be resolved in v12.0.5-canary.14 of Next.js (a test for skipLibCheck: false was specifically added), please give that a try as well!

@balazsorban44 balazsorban44 removed their assignment Dec 2, 2021
Kikobeats pushed a commit that referenced this issue Dec 3, 2021
This ensures type checking passes correctly for middleware types when `skipLibCheck: false` is set in `tsconfig.json`. This also moves the `middleware-types` to be an isolated test to ensure it isn't relying on any monorepo dependencies. 

## Bug

- [x] Related issues linked using `fixes #number`
- [x] Integration tests added
- [ ] Errors have helpful link attached, see `contributing.md`

Fixes: #31992 (comment)
@balazsorban44
Copy link
Member

This issue has been automatically locked due to no recent activity. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.

@vercel vercel locked as resolved and limited conversation to collaborators Jan 27, 2022
natew pushed a commit to natew/next.js that referenced this issue Feb 16, 2022
This ensures type checking passes correctly for middleware types when `skipLibCheck: false` is set in `tsconfig.json`. This also moves the `middleware-types` to be an isolated test to ensure it isn't relying on any monorepo dependencies. 

## Bug

- [x] Related issues linked using `fixes #number`
- [x] Integration tests added
- [ ] Errors have helpful link attached, see `contributing.md`

Fixes: vercel#31992 (comment)
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Issue was opened via the bug report template.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants