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

Got an error with react server components in v0.7 #1410

Closed
ryoppippi opened this issue Dec 3, 2024 · 6 comments
Closed

Got an error with react server components in v0.7 #1410

ryoppippi opened this issue Dec 3, 2024 · 6 comments
Assignees
Labels
bug Something isn't working good first issue Good for newcomers

Comments

@ryoppippi
Copy link
Contributor

ryoppippi commented Dec 3, 2024

Bug Report

Note that, the bug you're reporting may have registered in the issues by another user. Even the bug you're reporting may have been fixed in the @next version. In such reasons, I recommend you to check the old issues and reproduct your code with the @next version before publishing the bug reporting issue.

`npm install --save-dev typia@next`

When the same error occurs even in the @next version, then please fill the below template:

📝 Summary

Write a short summary of the bug in here.

  • Typia Version: 7.0

Reproduction

Playground

git clone https://github.com/ryoppippi/unplugin-typia/
cd unplugin-typia
git switch feature/v07
bun i
cd examples/nextjs
bun run build

the error causes from this file https://github.com/ryoppippi/unplugin-typia/blob/989f2298079269a31d0ed37798c09c479ce00481/examples/nextjs/app/RandomData/actions.ts:

./app/RandomData/actions.ts
  × The "use server" directive must be at the top of the file.
   ╭─[/Users/ryoppippi/ghq/github.com/ryoppippi/unplugin-typia/examples/nextjs/app/Random
 1 │ import * as __typia_transform__randomFormatEmail from "typia/lib/internal/_randomFor
 2 │ import * as __typia_transform__randomFormatUuid from "typia/lib/internal/_randomForm
 3 │ import * as __typia_transform__randomInteger from "typia/lib/internal/_randomInteger
 4 │ "use server";
   · ────────────
 5 │ import typia, { type tags } from "typia";
 6 │ export interface IMember {
 7 │     email: string & tags.Format<"email">;
   ╰────

This is a tricky bug.
When we use directives like "use server" or "use client", the directives should be the top of the file.
However since typia inserts imports before the actual implementation.

Sorry for the edge case....

@ryoppippi ryoppippi changed the title Got an error with Next.js server functions Got an error with react server components Dec 3, 2024
@ryoppippi ryoppippi changed the title Got an error with react server components Got an error with react server components in v0.7 Dec 3, 2024
@samchon samchon self-assigned this Dec 3, 2024
@samchon samchon added the bug Something isn't working label Dec 3, 2024
@samchon samchon added the good first issue Good for newcomers label Dec 3, 2024
@samchon
Copy link
Owner

samchon commented Dec 3, 2024

@ryoppippi Is it possible to take a new line in the "use XXX" statements like below?

"use strict";

"use server";

Or no new line allowed in the "use XXX" statements like below?

"use strict";
"use server";

@samchon
Copy link
Owner

samchon commented Dec 3, 2024

Don't mind, just be fixed, and sooner be published v7.0.1.

@samchon
Copy link
Owner

samchon commented Dec 3, 2024

@ryoppippi In the other case, template literal is allowed?

"use strict";

'use server';

`use php`

import typia, { tags } from "typia";

typia.createIs<string & tags.Format<"uuid">>();

@ryoppippi
Copy link
Contributor Author

"use strict";

"use server";

import typia, { type tags } from "typia";

export interface IMember {
  email: string & tags.Format<"email">;
  id: string & tags.Format<"uuid">;
  age: number & tags.Type<"uint32"> & tags.ExclusiveMinimum<19> & tags.Maximum<100>;
}

export async function randomOnServer()  {
  // return typia.random<IMember>();
  return {
    email: "",
    id: "",
    age: 0
  }
}

This code does work!!

@ryoppippi
Copy link
Contributor Author

SCR-20241203-onvc SCR-20241203-onwy

@samchon
Copy link
Owner

samchon commented Dec 3, 2024

Thank you, PR has been registered, and sooner be published.

#1411

@samchon samchon closed this as completed in 9d8d55c Dec 3, 2024
samchon added a commit to samchon/nestia that referenced this issue Dec 3, 2024
samchon added a commit to samchon/nestia that referenced this issue Dec 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers
Projects
Status: Done
Development

No branches or pull requests

2 participants