`useUser` has a differently typed user object than `currentUser` and `clerkClient.users.getUser`
まだ誰も着手していません。
評価
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 初心者へのやさしさ
- 38/100
- issue の種類
- バグ
- 明瞭さ
- おおむね明確
- 活発さ
- 停滞
- 技術スタック
- nextjs, react, typescript
調査の方向性
レポートで特定されているとおり、まず packages/react/src/hooks/useUser.ts と packages/nextjs/src/app-router/server/currentUser.ts で使用されている型を比較します。useUser().user と currentUser() が、primaryEmailAddress や fullName などのプロパティを含め、ドキュメントと一貫した同じ User 型を公開すれば完了です。
索引モデルが issue の本文から書いたものです。
説明
Preliminary Checks
-
I have reviewed the documentation: https://clerk.com/docs
-
I have searched for existing issues: https://github.com/clerk/javascript/issues
-
I have not already reached out to Clerk support via email or Discord (if you have, no need to open an issue here)
-
This issue is not a question, general help request, or anything other than a bug report directly related to Clerk. Please ask questions in our Discord community: https://clerk.com/discord.
Reproduction / Replay Link
Publishable key
pk_test_1234567890
Description
When developing with Clerk the user objects returned from useUser() and currentUser() are different. Notably primaryEmailAddress and fullName exists in useUser().user, but doesn't exist in currentUser(). This inconsistency makes it more difficult to create shared utils and generally share things across different parts of our application.
The docs claim that these are the same User object, but that is not accurate.
The currentUser helper returns the User object of the currently active user. This is the same User object that is returned by the useUser hook.
The deviation occurs because useUser from clerk-react users clerk-types/UserResource: https://github.com/clerk/javascript/blob/main/packages/react/src/hooks/useUser.ts#L1
And currentUser uses clerk-backend/User: https://github.com/clerk/javascript/blob/main/packages/nextjs/src/app-router/server/currentUser.ts#L1
Expected behavior:
useUser().user and currentUser() should be the same type
Actual behavior:
They are not the same type
Environment
Not relevant and hard to get correct packages from a mono repo, but here it is for the root:
System:
OS: macOS 14.1
CPU: (12) arm64 Apple M2 Max
Memory: 53.19 MB / 32.00 GB
Shell: 5.9 - /bin/zsh
Binaries:
Node: 20.3.1 - ~/.nvm/versions/node/v20.3.1/bin/node
npm: 9.6.7 - ~/.nvm/versions/node/v20.3.1/bin/npm
pnpm: 8.10.0 - ~/.nvm/versions/node/v20.3.1/bin/pnpm
Browsers:
Chrome: 119.0.6045.159
Safari: 17.1
npmPackages:
@babel/preset-typescript: ^7.22.15 => 7.22.15
@commitlint/cli: ^17.6.7 => 17.6.7
@commitlint/config-conventional: ^17.6.7 => 17.6.7
@knnlabs/configs: workspace:* => 0.0.0
@knnlabs/eslint-config-custom: workspace:* => 0.0.0
@trivago/prettier-plugin-sort-imports: ^4.2.0 => 4.2.0
@turbo/gen: ^1.10.12 => 1.10.12
@types/jest: ^29.5.4 => 29.5.4
bun: ^1.0.3 => 1.0.3
eslint: ^8.46.0 => 8.50.0
husky: ^8.0.3 => 8.0.3
jest: ^29.6.4 => 29.6.4
lint-staged: ^13.2.3 => 13.2.3
prettier: ^3.0.0 => 3.0.0
prettier-plugin-prisma: ^5.0.0 => 5.0.0
turbo: ^1.10.16 => 1.10.16
- 主要言語
- TypeScript
- スター
- 1.8k
- フォーク
- 472
- 平均マージ
- 2日 12時間
- マージ済み PR(30日)
- 222
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
clerk/javascript のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 74/100
clerk/javascript#9611 · コメント 1 件 ·
-
clerk/javascript#9891 · 担当者 1 名 ·
-
難易度 4/5 3〜5日 初心者へのやさしさ 64/100
clerk/javascript#9775 · コメント 1 件 ·
-
難易度 4/5 3〜5日 初心者へのやさしさ 48/100
clerk/javascript#9770 · コメント 3 件 ·
-
難易度 3/5 1〜2日 初心者へのやさしさ 68/100
clerk/javascript#9667 · コメント 1 件 ·
clerk/javascript の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
mksglu/context-mode#1200 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
jaegertracing/jaeger-ui#4506 ·
-
area:desktop area:ui bug platform:macos
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
anthropics/claude-code#96687 ·
-
good first issue
難易度 1/5 1時間未満 初心者へのやさしさ 95/100
AOSSIE-Org/DebateAI#582 · コメント 2 件 ·