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

chore(ts): build types pipeline #1677

Merged
merged 2 commits into from
Apr 9, 2021
Merged

Conversation

ubbe-xyz
Copy link
Collaborator

@ubbe-xyz ubbe-xyz commented Apr 9, 2021

What 🏕

As part of #1649, adds a script that moves the declaration files we have in ./types to ./ relative to the files they intend to type.

Why 💭

In this way, all the sub-modules exposed bynext-auth:

• next-auth/providers
• next-auth/adapters
• next-auth/client
• next-auth/jwt

can be typed through declaration files, and Typescript can pick up the types properly when importing them.

Refer to this issue: microsoft/TypeScript#8305 to understand why we need a 1:1 file mapping when typing package sub-modules.

How 🪂

Adding a simple Node script that copies the declaration files we have in ./types to ./, creating a 1:1 mapping with the source files. In this way, we can keep the declaration files within ./types rather than having them scattered through the ./src directory and keep the tests working through dtslint.

The mapping information is stored in a constant within a file ./config/build-types that we'll need to keep updating whenever new sub-modules are added to the package.

Checklist 🙇🏽‍♂️

  • Add build scripts
    • verify they work as intended
  • Manage to type next-auth/jwt properly
  • Update package.json
  • Add it to the CI pipeline

@vercel
Copy link

vercel bot commented Apr 9, 2021

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployment, click below or on the icon next to each commit.

🔍 Inspect: https://vercel.com/nextauthjs/next-auth/GgS2KarFicDY3oaPMQRHaXvUfX8y
✅ Preview: https://next-auth-git-chore-1649-build-types-script-nextauthjs.vercel.app

@vercel vercel bot temporarily deployed to Preview April 9, 2021 14:45 Inactive
@vercel vercel bot temporarily deployed to Preview April 9, 2021 15:28 Inactive
@ubbe-xyz ubbe-xyz force-pushed the chore/1649-build-types-script branch from cf96542 to cc4e632 Compare April 9, 2021 15:30
@vercel vercel bot temporarily deployed to Preview April 9, 2021 15:30 Inactive
@ubbe-xyz ubbe-xyz force-pushed the chore/1649-build-types-script branch from cc4e632 to 6c9861b Compare April 9, 2021 15:41
@vercel vercel bot temporarily deployed to Preview April 9, 2021 15:41 Inactive
Adds a script that moves the declaration files we have in `./types` to `./dist` relative to the files they intend to type.

This is the first step, we still need to change what we declare in `package.json`, add the script to the CI pipeline if we're happy with it and figure out how to type `next-auth/jwt`.
@ubbe-xyz ubbe-xyz force-pushed the chore/1649-build-types-script branch from 6c9861b to e4035b2 Compare April 9, 2021 15:42
@vercel vercel bot temporarily deployed to Preview April 9, 2021 15:42 Inactive
@vercel vercel bot temporarily deployed to Preview April 9, 2021 15:45 Inactive
@ubbe-xyz ubbe-xyz changed the title chore(types): build types pipeline chore(ts): build types pipeline Apr 9, 2021
@balazsorban44 balazsorban44 merged commit 0d863d3 into beta Apr 9, 2021
@balazsorban44 balazsorban44 deleted the chore/1649-build-types-script branch April 9, 2021 18:28
@github-actions
Copy link

github-actions bot commented Apr 9, 2021

🎉 This PR is included in version 3.14.0-beta.2 🎉

The release is available on:

Your semantic-release bot 📦🚀

balazsorban44 added a commit that referenced this pull request Apr 9, 2021
@github-actions
Copy link

🎉 This PR is included in version 3.15.0-beta.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

balazsorban44 added a commit that referenced this pull request Apr 20, 2021
* chore: add beta to release flow/GH actions

* feat(ts): expose types from the package (#1665)

* chore(types): move existing types to the repo
* feat(ts): expose types from the main package
* chore(deps): bring back `react-dom` version range
* chore(ts): cleanup deps and comments
* chore(ci): run types tests on a separate workflow

* chore(ci): fix typo on types workflow

* fix(ts): correctly export sub-module types (#1677)

* chore(types): build types script

Adds a script that moves the declaration files we have in `./types` to `./dist` relative to the files they intend to type.

This is the first step, we still need to change what we declare in `package.json`, add the script to the CI pipeline if we're happy with it and figure out how to type `next-auth/jwt`.

* refactor(lint): fix build-types script

* fix(ts): add .d.ts sub-module files to package.json

#1677 seemed to miss this

* fix(built): typo in package.json

* fix(build): fix release

* feat(ts): support module augmentation (#1681)

* chore(ts): remove unused imports

* refactor(ts): clean up CallbackOptions

* docs(ts): explain Module Augmentation

* docs(ts): don't use @ in folder name "types"

* test(ts): make jwt params optional

* docs(ts): fix typo (TypeScript -> NextAuth.js)

* style: replace ts-standard with eslint/prettier (#1724)

* style: move from ts-standard to eslint/prettier

* fix: install remaining eslint-config-standard peer deps

* fix: add remaining missing dependencies/config

Co-authored-by: Balázs Orbán <[email protected]>

* docs(lint): update contributing.md (#1760)

Regarding ESLint / Prettier use and link to their VSCode extensions

* refactor(ts): de-duplicate types (#1690)

* refactor(ts): deduplicate internal types

* refactor(ts): ease up providers typings

* test(ts): fix failing TS tests

* test(ts): rename TS property to fix test

* docs(ts): mention TS docs in README.md

* feat(ts): move/update client types

* refactor(TS): rename some types

* test(ts): fix client tests

* docs(ts): move function descriptions to .d.ts

* chore: fix lint error

* refactor(ts): separate internal types

* chore: simplify build-types script

* chore: update type import paths in src

* chore(build): create root files at build

* chore: remove unnecessary .npmignore

* chore: run prettier on types

* fix(ts): clean up jwt types

* fix(ts): make getToken return type depend on raw param

* docs(page): explain page errors, add theming note

* docs(ts): add JSDoc to NextAuthOptions props

* chore(ts): remove unused import

* docs(ts): change JSDOC docs notation

* refactor(build): extract module entries into enum

* chore(ts): move ClientSafeProvider

* chore(ts): simplify GetTokenParams generic

* style(lint): fix linting errors

* chore: re-add generic extension to GetTokenParams

* fix(ts): extract EmailConfigServerOptions to interface

* fix(ts): use relative imports

* Merge branch 'main' into beta

* Merge main into beta

* fix(ts): fix typos, add more links to documentation

* test(ts): update JWT getToken test

* fix(build): fix tsconfig.json formatting

* test(ts): use absolute imports in test files

* fix(ts): add missing callbacks JSDoc

* docs: mention TS in FAQ, fix typos

* docs: fix some typos in the docs

Co-authored-by: Lluis Agusti <[email protected]>
Co-authored-by: Nico Domino <[email protected]>
mnphpexpert added a commit to mnphpexpert/next-auth that referenced this pull request Sep 2, 2024
* chore: add beta to release flow/GH actions

* feat(ts): expose types from the package (nextauthjs#1665)

* chore(types): move existing types to the repo
* feat(ts): expose types from the main package
* chore(deps): bring back `react-dom` version range
* chore(ts): cleanup deps and comments
* chore(ci): run types tests on a separate workflow

* chore(ci): fix typo on types workflow

* fix(ts): correctly export sub-module types (nextauthjs#1677)

* chore(types): build types script

Adds a script that moves the declaration files we have in `./types` to `./dist` relative to the files they intend to type.

This is the first step, we still need to change what we declare in `package.json`, add the script to the CI pipeline if we're happy with it and figure out how to type `next-auth/jwt`.

* refactor(lint): fix build-types script

* fix(ts): add .d.ts sub-module files to package.json

nextauthjs#1677 seemed to miss this

* fix(built): typo in package.json

* fix(build): fix release

* feat(ts): support module augmentation (nextauthjs#1681)

* chore(ts): remove unused imports

* refactor(ts): clean up CallbackOptions

* docs(ts): explain Module Augmentation

* docs(ts): don't use @ in folder name "types"

* test(ts): make jwt params optional

* docs(ts): fix typo (TypeScript -> NextAuth.js)

* style: replace ts-standard with eslint/prettier (nextauthjs#1724)

* style: move from ts-standard to eslint/prettier

* fix: install remaining eslint-config-standard peer deps

* fix: add remaining missing dependencies/config

Co-authored-by: Balázs Orbán <[email protected]>

* docs(lint): update contributing.md (nextauthjs#1760)

Regarding ESLint / Prettier use and link to their VSCode extensions

* refactor(ts): de-duplicate types (nextauthjs#1690)

* refactor(ts): deduplicate internal types

* refactor(ts): ease up providers typings

* test(ts): fix failing TS tests

* test(ts): rename TS property to fix test

* docs(ts): mention TS docs in README.md

* feat(ts): move/update client types

* refactor(TS): rename some types

* test(ts): fix client tests

* docs(ts): move function descriptions to .d.ts

* chore: fix lint error

* refactor(ts): separate internal types

* chore: simplify build-types script

* chore: update type import paths in src

* chore(build): create root files at build

* chore: remove unnecessary .npmignore

* chore: run prettier on types

* fix(ts): clean up jwt types

* fix(ts): make getToken return type depend on raw param

* docs(page): explain page errors, add theming note

* docs(ts): add JSDoc to NextAuthOptions props

* chore(ts): remove unused import

* docs(ts): change JSDOC docs notation

* refactor(build): extract module entries into enum

* chore(ts): move ClientSafeProvider

* chore(ts): simplify GetTokenParams generic

* style(lint): fix linting errors

* chore: re-add generic extension to GetTokenParams

* fix(ts): extract EmailConfigServerOptions to interface

* fix(ts): use relative imports

* Merge branch 'main' into beta

* Merge main into beta

* fix(ts): fix typos, add more links to documentation

* test(ts): update JWT getToken test

* fix(build): fix tsconfig.json formatting

* test(ts): use absolute imports in test files

* fix(ts): add missing callbacks JSDoc

* docs: mention TS in FAQ, fix typos

* docs: fix some typos in the docs

Co-authored-by: Lluis Agusti <[email protected]>
Co-authored-by: Nico Domino <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants