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

Comply with TypeScript strict mode #2709

Closed
balazsorban44 opened this issue Sep 9, 2021 · 28 comments
Closed

Comply with TypeScript strict mode #2709

balazsorban44 opened this issue Sep 9, 2021 · 28 comments
Labels
enhancement New feature or request good first issue Good issue to take for first time contributors stale Did not receive any activity for 60 days TypeScript Issues relating to TypeScript

Comments

@balazsorban44
Copy link
Member

balazsorban44 commented Sep 9, 2021

#2552 introduced TypeScript to the core. A long-time wish from the community, and the maintainers.

For an easier migration, I decided to go with "strict": false, and we still allow ".js" files.

As an improvement, we should make set "strict": true in our tsconfig.json and fix the remaining issues, and convert the rest of the files to TypeScript as well.

@balazsorban44 balazsorban44 added enhancement New feature or request TypeScript Issues relating to TypeScript good first issue Good issue to take for first time contributors labels Sep 9, 2021
@Thisen
Copy link
Contributor

Thisen commented Sep 10, 2021

@balazsorban44 Happy to work on it - However I want to split in multiple PRs, so it's smaller changes.

@balazsorban44
Copy link
Member Author

sounds good, I could suggest setting strict: true, but not actually committing it.

@Thisen Thisen mentioned this issue Sep 20, 2021
3 tasks
@DopamineDriven
Copy link

Yes please 🙏

I work with Strict, always strict, and strict null check flags set to true

This would be greatly appreciated

@Thisen
Copy link
Contributor

Thisen commented Sep 27, 2021

Working on it. 🙂

@sldavidson
Copy link

Anything we can do to get movement on #2802 or #2763?

@balazsorban44
Copy link
Member Author

I pinged the PR creator to fix the conflicts just now #2802 (comment)

@balazsorban44
Copy link
Member Author

#2802 has been merged now, anything left here?

@balazsorban44
Copy link
Member Author

@Thisen, @sldavidson could you test [email protected]?

@copleykj
Copy link

@Thisen, @sldavidson could you test [email protected]?

@balazsorban44 so this fixed an issue I was having with the credentials provider throwing a type error for username and password keys, but now it's throwing a type error for the jwt key of the session option.

@copleykj
Copy link

Screenshot from 2021-11-18 13-28-38

@balazsorban44
Copy link
Member Author

that's expected, renamed for clarity
https://next-auth.js.org/getting-started/upgrade-v4#session-strategy

@copleykj
Copy link

Oh.. Sorry. This section of the v4 docs had me confused.

image

balazsorban44 added a commit to nextauthjs/docs that referenced this issue Nov 19, 2021
@balazsorban44
Copy link
Member Author

Good catch, just updated the docs!

@Thisen
Copy link
Contributor

Thisen commented Nov 24, 2021

@Thisen, @sldavidson could you test [email protected]?

It didn't work for me. Also, it looks like the first argument is required for useSession in that version, is that expected?

@balazsorban44
Copy link
Member Author

balazsorban44 commented Nov 24, 2021

no it isn't and was supposed to be fixed in 419ffe7

and it looks good still

export function useSession<R extends boolean>(options?: UseSessionOptions<R>) {

line 26: https://unpkg.com/browse/[email protected]/react/index.d.ts

@stale
Copy link

stale bot commented Jan 23, 2022

Hi there! It looks like this issue hasn't had any activity for a while. It will be closed if no further activity occurs. If you think your issue is still relevant, feel free to comment on it to keep it open. (Read more at #912) Thanks!

@stale stale bot added the stale Did not receive any activity for 60 days label Jan 23, 2022
@stale
Copy link

stale bot commented Jan 31, 2022

Hi there! It looks like this issue hasn't had any activity for a while. To keep things tidy, I am going to close this issue for now. If you think your issue is still relevant, just leave a comment and I will reopen it. (Read more at #912) Thanks!

@stale stale bot closed this as completed Jan 31, 2022
@aspnetde
Copy link

#2701 unfortunately is still a thing (but was closed in favor for this one, which then went stale for some reason).

@currenthandle
Copy link

#2701 unfortunately is still a thing (but was closed in favor for this one, which then went stale for some reason).

I'm still getting this same issue as well.

@Simvolick
Copy link

Really waiting for this because of the VkProvider

@karambir-zz
Copy link

I'm having the same problem with #2701

@ondraczsk
Copy link

Yes #2701 still an error

@cantutar
Copy link

I can confirm that issue is still on.
image

@saurabhsri108
Copy link

saurabhsri108 commented Jan 26, 2023

The issue still exists. Going with the strict: false for now gives even more errors.

@nos-nart
Copy link

nos-nart commented Feb 9, 2023

I encounter the same error, turn off the strict mode in tsconfig.json still shows type error, I ignore it temporarily.

@coycoylaniba
Copy link

does anyone have a fix for this? im also getting this error.

@Zarathos1084
Copy link

Zarathos1084 commented Mar 14, 2023

Still getting the same error as well, is there a way we can reopen this?

@sumanchapai
Copy link

This fixes issues for me in the authorize function with strict typescript mode.

import { API_LOGIN } from "lib/apis"
import NextAuth from "next-auth"
import CredentialsProvider from "next-auth/providers/credentials"

export default NextAuth({
    providers: [
        CredentialsProvider({
            type: 'credentials',
            credentials: {},
            async authorize(credentials: Record<string, string> | undefined, req) {
                const authResponse = await fetch(API_LOGIN, {
                    method: "POST",
                    headers: {
                        "Content-Type": "application/json",
                    },
                    body: JSON.stringify(credentials),
                })

                if (!authResponse.ok) {
                    return null
                }

                const user = await authResponse.json()

                return user
            },
        }),
    ],
})

Note that

import { API_LOGIN } from "lib/apis"

line is custom to your project!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good issue to take for first time contributors stale Did not receive any activity for 60 days TypeScript Issues relating to TypeScript
Projects
None yet
Development

No branches or pull requests