goodgravy
03/03/2023, 10:57 AMusers:build: info - Linting and checking validity of types...
users:build: Failed to compile.
users:build:
users:build: ./pages/auth/[[...path]].tsx:21:6
users:build: Type error: 'SuperTokensComponentNoSSR' cannot be used as a JSX component.
users:build: Its element type 'ReactElement<any, any> | Component<unknown, any, any>' is not a valid JSX element.
users:build: Type 'Component<unknown, any, any>' is not assignable to type 'Element | ElementClass'.
users:build: Type 'Component<unknown, any, any>' is not assignable to type 'ElementClass'.
users:build: The types returned by 'render()' are incompatible between these types.
users:build: Type 'React.ReactNode' is not assignable to type 'import("/Users/james/Code/oughtinc/elicit-mono/apps/users/node_modules/@types/react/index").ReactNode'.
users:build: Type '{}' is not assignable to type 'ReactNode'.
users:build:
users:build: 19 |
users:build: 20 | return (
users:build: > 21 | <SuperTokensComponentNoSSR />
users:build: | ^
users:build: 22 | )
users:build: 23 | }
This is when using the Auth component directly from https://supertokens.com/docs/thirdpartypasswordless/nextjs/setting-up-frontendrp_st
03/03/2023, 10:59 AMgoodgravy
03/03/2023, 11:13 AMexport default function Auth() {
const [routingComponent, setRoutingComponent] = useState<JSX.Element | null>(null);
useEffect(() => {
setRoutingComponent(SuperTokens.getRoutingComponent());
}, []);
return routingComponent;
}
alisheraituarov
03/03/2023, 11:17 AMgoodgravy
03/03/2023, 11:17 AMweb:build: Failed to compile.
web:build:
web:build: ./src/pages/_app.tsx:46:8
web:build: Type error: 'Component' cannot be used as a JSX component.
web:build: Its element type 'ReactElement<any, any> | Component<any, any, any> | null' is not a valid JSX element.
web:build: Type 'Component<any, any, any>' is not assignable to type 'Element | ElementClass | null'.
web:build: Type 'Component<any, any, any>' is not assignable to type 'ElementClass'.
web:build: The types returned by 'render()' are incompatible between these types.
web:build: Type 'React.ReactNode' is not assignable to type 'import("/Users/james/Code/oughtinc/elicit-mono/apps/web/node_modules/@types/react/index").ReactNode'.
web:build: Type '{}' is not assignable to type 'ReactNode'.
web:build:
web:build: 44 | <SuperTokensWrapper>
web:build: 45 | <NavBar />
web:build: > 46 | <Component {...pageProps} />
web:build: | ^
web:build: 47 | </SuperTokensWrapper>
web:build: 48 | );
web:build: 49 | }
web:build: error Command failed with exit code 1.
goodgravy
03/03/2023, 11:18 AMgoodgravy
03/03/2023, 11:19 AMalisheraituarov
03/03/2023, 11:20 AMgoodgravy
03/03/2023, 11:22 AM<Component {...pageProps} />
)goodgravy
03/03/2023, 11:22 AMalisheraituarov
03/03/2023, 11:23 AMgoodgravy
03/03/2023, 11:24 AMalisheraituarov
03/03/2023, 11:24 AMgoodgravy
03/03/2023, 11:27 AMgoodgravy
03/03/2023, 11:29 AMalisheraituarov
03/03/2023, 11:31 AMgoodgravy
03/03/2023, 11:42 AMgoodgravy
03/03/2023, 11:44 AMyarn run build
directly within the app directory:
> yarn run build
yarn run v1.22.17
$ next build
info - Loaded env from /Users/james/Code/oughtinc/elicit-mono/apps/users/.env
info - Linting and checking validity of types .Failed to compile.
./pages/auth/[[...path]].tsx:21:6
Type error: 'SuperTokensComponentNoSSR' cannot be used as a JSX component.
Its element type 'ReactElement<any, any> | Component<unknown, any, any>' is not a valid JSX element.
Type 'Component<unknown, any, any>' is not assignable to type 'Element | ElementClass'.
Type 'Component<unknown, any, any>' is not assignable to type 'ElementClass'.
The types returned by 'render()' are incompatible between these types.
Type 'React.ReactNode' is not assignable to type 'import("/Users/james/Code/oughtinc/elicit-mono/apps/users/node_modules/@types/react/index").ReactNode'.
Type '{}' is not assignable to type 'ReactNode'.
19 |
20 | return (
> 21 | <SuperTokensComponentNoSSR />
| ^
22 | )
23 | }
24 |
error Command failed with exit code 1.
alisheraituarov
03/03/2023, 11:49 AMgoodgravy
03/03/2023, 11:54 AMgoodgravy
03/03/2023, 11:55 AMnpx create-supertokens-app@latest
to hopefully bisect general environment problems vs. problems in the monorepoalisheraituarov
03/03/2023, 11:56 AMgoodgravy
03/03/2023, 11:57 AM> yarn run build
yarn run v1.22.17
$ next build
info - Loaded env from /Users/james/Code/oughtinc/supertokens-test/.env
info - Linting and checking validity of types ...Failed to compile.
./pages/auth/[[...path]].tsx:7:43
Type error: Argument of type 'Promise<unknown>' is not assignable to parameter of type 'DynamicOptions<{}> | Loader<{}>'.
Type 'Promise<unknown>' is not assignable to type 'LoaderComponent<{}>'.
Type 'unknown' is not assignable to type 'ComponentType<{}> | ComponentModule<{}>'.
5 | import SuperTokens from "supertokens-auth-react";
6 |
> 7 | const SuperTokensComponentNoSSR = dynamic(new Promise((res) => res(SuperTokens.getRoutingComponent)), { ssr: false });
| ^
8 |
9 | export default function Auth(): JSX.Element {
10 | useEffect(() => {
error Command failed with exit code 1.
goodgravy
03/03/2023, 11:57 AM? What is your app called? supertokens-test
? Choose a frontend framework (Visit our documentation for integration with other frameworks): Next.js
? What type of authentication do you want to use? Social Login + Passwordless
rp_st
03/03/2023, 11:58 AMrp_st
03/03/2023, 11:59 AMrp_st
03/03/2023, 12:02 PMtsx
const SuperTokensComponentNoSSR = dynamic<React.ComponentProps<typeof SuperTokens.getRoutingComponent>>(
new Promise((res) => res(SuperTokens.getRoutingComponent)),
{ ssr: false }
)
goodgravy
03/03/2023, 12:04 PMrp_st
03/03/2023, 12:06 PMconst SuperTokensComponentNoSSR = dynamic<React.ComponentProps<typeof SuperTokens.getRoutingComponent>>(
new Promise((res) => res(SuperTokens.getRoutingComponent)),
{ ssr: false }
)
goodgravy
03/03/2023, 12:07 PMrp_st
03/03/2023, 12:07 PMgoodgravy
03/03/2023, 12:11 PMType error: 'SuperTokensComponentNoSSR' cannot be used as a JSX component.
I was originally whinging about in my monoreporp_st
03/03/2023, 12:17 PMgoodgravy
03/03/2023, 12:49 PMgoodgravy
03/09/2023, 1:50 PMType error: 'SuperTokensComponentNoSSR' cannot be used as a JSX component
error when I created a new turborepo project, using SuperTokens
- I upgraded the Node and Yarn versions in the actual app I was having problems with, and no longer see these errors there too 🙌
I'm not sure if it's the Node version of the Yarn version that made the difference – but I suspect the latter. I was using classic Yarn before.