Next.js: [typescript] Broken compatibility with @types/next

Created on 4 May 2019  路  9Comments  路  Source: vercel/next.js

Bug report

Describe the bug

Looks like this after this change https://github.com/zeit/next.js/pull/7154/files#diff-e5f184d6408bb983da44fe3b0f27d4faR10 external types from @types/next
are no longer used.

To Reproduce

git clone [email protected]:adam187/next-js-ts-error-example.git
yarn install
yarn ts:check:server

Expected behavior

Types should work properly

System information

  • Version of Next.js: 8.1.1-canary.12

Most helpful comment

@nhooyr you can install next@canary to try them!

All 9 comments

Doesn't seem like a bug to me. Why would you want to use externally managed types in the @types namespace when the official types are literally generated from the source code that you install.

@timneutkens I agree it's not really a bug, but it can be problematic for typescript users that want to upgrade to [email protected] and they used to use @types/next for declarations.

Problem is that https://github.com/zeit/next.js/blob/canary/packages/next/types/index.d.ts is missing some declarations that https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/next/index.d.ts have.

Also, @types/next is present in typescript custom server example
https://github.com/zeit/next.js/blob/canary/examples/custom-server-typescript/package.json#L13

Basically, I'm just reporting an issue that I occurred while upgrading.

Hi @adam187! Unfortunately, this is unavoidable for any package transitioning from external typings to provided type declarations.

I'll close this as unactionable -- btw: we'll likely release these changes under 8.2.0 (not 8.1.1)!

@timneutkens could you please direct me to where the official types are? I cannot seem to find any documentation on them.

Ah the latest version is 8.1.0 which I think does not include types.

@nhooyr you can install next@canary to try them!

They work wonderfully, thanks!

@Timer only issue I'm having with is styled-jsx doesn't seem to be supported. I'm using canary next and styled-jsx. Any ideas?

edit: @types/styled-jsx works but isn't official.

Please file an issue @nhooyr it's hard to track things in closed issues. 馃檹

Was this page helpful?
0 / 5 - 0 ratings