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

Include submodules in exported type definition #28316

Merged
merged 11 commits into from
Nov 26, 2021
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
/// <reference types="next" />
/// <reference types="next/types/global" />
/// <reference types="next/image-types/global" />
Copy link
Member

@styfle styfle Nov 24, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should next/image-types/global be moved too?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That one is under a conditional so I decided not to include it because of that.


// NOTE: This file should not be edited
Expand Down
14 changes: 14 additions & 0 deletions packages/next/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/// <reference types="./types/global" />
/// <reference path="./amp.d.ts" />
/// <reference path="./app.d.ts" />
/// <reference path="./config.d.ts" />
/// <reference path="./document.d.ts" />
/// <reference path="./dynamic.d.ts" />
/// <reference path="./error.d.ts" />
/// <reference path="./head.d.ts" />
/// <reference path="./image.d.ts" />
/// <reference path="./link.d.ts" />
/// <reference path="./router.d.ts" />
/// <reference path="./script.d.ts" />

export * from './types'
2 changes: 0 additions & 2 deletions packages/next/lib/typescript/writeAppTypeDeclarations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ export async function writeAppTypeDeclarations(
const content =
'/// <reference types="next" />' +
os.EOL +
'/// <reference types="next/types/global" />' +
os.EOL +
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one is included by /// <reference types="next" />'

(imageImportsEnabled
? '/// <reference types="next/image-types/global" />' + os.EOL
: '') +
Expand Down
2 changes: 1 addition & 1 deletion packages/next/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"repository": "vercel/next.js",
"bugs": "https://github.com/vercel/next.js/issues",
"homepage": "https://nextjs.org",
"types": "types/index.d.ts",
"types": "index.d.ts",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs to be added to the package.json files array if we're moving it up.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ijjk It's added on line 45, lmk if you're referring to something else

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there any benefit to moving this file? This will now be ignored while type-checking the project when it previously wouldn't be.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ijjk The current issue with types/index.d.ts is that it's included in TS compilation, the references added in index.d.ts will make TS fail when it's trying to build the files it's referencing, therefore by not importing index.d.ts anywhere it's possible to still "export" references

"files": [
"dist",
"app.js",
Expand Down