Skip to content

fix: enable experimental.useTypeScriptCli for TypeScript 7 - #1576

Merged
Marukome0743 merged 2 commits into
OpenUp-LabTakizawa:mainfrom
Marukome0743:pr1576
Jul 14, 2026
Merged

fix: enable experimental.useTypeScriptCli for TypeScript 7#1576
Marukome0743 merged 2 commits into
OpenUp-LabTakizawa:mainfrom
Marukome0743:pr1576

Conversation

@Marukome0743

@Marukome0743 Marukome0743 commented Jul 14, 2026

Copy link
Copy Markdown
Member

TypeScript 7 no longer exposes the compiler API that next build
relied on, so the "Running TypeScript" step failed with
"TypeScript 7.0.2 does not provide the compiler API required by
Next.js" and broke the Playwright webServer build.

  • Enable experimental.useTypeScriptCli so Next.js type-checks via
    the TypeScript CLI (ref fix: restore production build under TypeScript 7 JamBalaya56562/blog#1076).
  • Fix type errors newly surfaced by the CLI in unit tests:
    • type mock parameters so recorded call tuples are non-empty
    • cast through unknown for incompatible structural casts
    • guard possibly-undefined endpoint providers and object spreads

Co-Authored-By: Claude Opus 4.8 noreply@anthropic.com

Summary by Sourcery

TypeScript 7 向けに Next.js TypeScript CLI の型チェックを有効化し、より厳密な型安全性に対応するようテストを更新します。

New Features:

  • Next.js の experimental 設定を構成し、TypeScript CLI を用いた型チェックを有効にします。

Enhancements:

  • データベースおよびユーザーのルートに関するテストで、キャストの安全性を高め、オプション値にデフォルト値を設定することで、型の扱いをより厳密にします。
  • S3 クライアントおよびプロキシ関連のテストを改善し、オプションのエンドポイント、オブジェクトスプレッド、null になり得る状態をより堅牢に扱えるようにします。
  • テスト内のモック関数を調整し、型付きのパラメータを使用するとともに、記録された呼び出しタプルが空にならないように維持します。

Tests:

  • ユニットテストおよびプロパティベーステストを更新し、TypeScript 7 の CLI 型チェックおよびより厳格な型チェックと互換性を持たせます。
Original summary in English

Summary by Sourcery

Enable Next.js TypeScript CLI type-checking for TypeScript 7 and update tests for stricter type safety.

New Features:

  • Configure Next.js experimental settings to type-check using the TypeScript CLI.

Enhancements:

  • Tighten type handling in database and user route tests with safer casting and defaults for optional values.
  • Improve S3 client and proxy-related tests to handle optional endpoints, object spreads, and nullable state more robustly.
  • Adjust mock functions across tests to use typed parameters and maintain non-empty recorded call tuples.

Tests:

  • Update unit and property-based tests to be compatible with TypeScript 7’s CLI type-checking and stricter type checks.

@vercel

vercel Bot commented Jul 14, 2026

Copy link
Copy Markdown

@Marukome0743 is attempting to deploy a commit to the OpenUp Lab Takizawa Team on Vercel.

A member of the Team first needs to authorize it.

@github-actions

Copy link
Copy Markdown

🪄 Deploy Preview for ready!

Open in Codeflow
Learn more about StackBlitz Codeflow.

@github-actions

Copy link
Copy Markdown

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

Scanned Files

None

@github-actions github-actions Bot added ⚙️config Update configuration files ✅test Something related to test labels Jul 14, 2026
@sourcery-ai

sourcery-ai Bot commented Jul 14, 2026

Copy link
Copy Markdown

Reviewer's Guide

このPRは、Next.jsにおけるTypeScript 7向けのTypeScript CLI経由の型チェックを有効化し、より厳格なCLIチェックによって顕在化した複数の単体テストの型問題を修正します。修正内容は主に、オプショナルな値、構造的キャスト、モックのシグネチャに関連するものです。

TypeScript CLI を用いた Next.js ビルドのシーケンス図

sequenceDiagram
  actor Developer
  participant NextBuild
  participant TypeScriptCli

  Developer->>NextBuild: next build
  NextBuild->>TypeScriptCli: run TypeScript type_check
  TypeScriptCli-->>NextBuild: type_check result
  NextBuild-->>Developer: build output
Loading

File-Level Changes

Change Details Files
Next.js の実験的な TypeScript CLI 統合を有効化し、ビルドと型チェックが TypeScript 7 で動作するようにします。
  • Next.js の設定で experimental.useTypeScriptCli を true に設定し、非推奨のコンパイラ API から TypeScript CLI へ型チェックの仕組みを切り替えます
next.config.ts
オプショナルな endpoint 設定やスプレッドに対して、S3 クライアントのテストを堅牢化します。
  • s3.config.endpoint を呼び出す際にオプショナルチェイニングを使い、hostname/protocol/port をアサートする前に endpoint 解決が falsy な値を返した場合は明示的に例外を投げます
  • truthy オブジェクトのスプレッドパターンを条件(三項)演算子によるオブジェクトスプレッドに置き換え、endpoint/forcePathStyle が endpoint 定義時にのみ存在すると TypeScript に理解させます
test/unit/lib/storage/s3-backend.test.ts
シンボルインデックス付きコンストラクタへアクセスする際に、TypeScript の構造的型付けの期待に合わせてデータベーステストを調整します。
  • entityKind シンボルを検査してドライバー種別を判定する複数のテストにおいて、db.constructor を unknown 経由でキャストしたうえで Record<symbol, string> としてアサートします
test/unit/lib/db.test.ts
test/unit/lib/db.property.test.ts
モックに型を付け、未定義になりうる値を扱うことで API ルートのテストを厳密化します。
  • mockUpload 関数に明示的な UploadParams のパラメータ型を追加し、記録される呼び出しタプルが空でなく、構造的に互換性があることを保証します
  • db.insert をモックに差し替える際、インポートされた db を unknown 経由でキャストしてから型をアサートします
  • filename.split(".").pop() に対して、非空文字列の期待を満たすため null 合体演算子によるデフォルト値を付けてガードします
test/unit/api/users/route.test.ts
明示的な nullable 型や unknown 型を付けることで、プロキシおよび dev-up スクリプトのテストを型安全にします。
  • state.redirectPath を暗黙の any ではなく、明示的な string
null 型で初期化します
  • 暗黙の any を避けるため、S3 dev-up ヘルパーで使用される sendMock コマンド引数に明示的な unknown のパラメータ型を指定します

  • Tips and commands

    Sourcery とのやり取り

    • 新しいレビューを開始する: プルリクエスト上で @sourcery-ai review とコメントします。
    • 議論を継続する: Sourcery のレビューコメントに直接返信します。
    • レビューコメントから GitHub Issue を生成する: レビューコメントに返信して、そこから Issue を作成するよう Sourcery に依頼します。レビューコメントに @sourcery-ai issue と返信しても Issue を作成できます。
    • プルリクエストのタイトルを生成する: プルリクエストのタイトル内のどこかに @sourcery-ai と記述すると、いつでもタイトルを生成できます。プルリクエスト上で @sourcery-ai title とコメントすることでも、タイトルを再生成できます。
    • プルリクエストのサマリーを生成する: プルリクエスト本文の任意の場所に @sourcery-ai summary と記述すると、その位置にPRサマリーをいつでも生成できます。プルリクエスト上で @sourcery-ai summary とコメントすることでも、サマリーを(再)生成できます。
    • レビューガイドを生成する: プルリクエスト上で @sourcery-ai guide とコメントすると、レビューガイドをいつでも(再)生成できます。
    • すべての Sourcery コメントを解決する: プルリクエスト上で @sourcery-ai resolve とコメントすると、すべての Sourcery コメントを解決済みにできます。すでにすべてのコメントへ対応済みで、もう表示したくない場合に便利です。
    • すべての Sourcery レビューを破棄する: プルリクエスト上で @sourcery-ai dismiss とコメントすると、既存の Sourcery レビューをすべて破棄します。新しいレビューをゼロから始めたい場合に特に便利です。その際は忘れずに @sourcery-ai review とコメントして新しいレビューをトリガーしてください。

    カスタマイズ方法

    ダッシュボード にアクセスして、次のことが行えます:

    • Sourcery が生成するプルリクエストサマリー、レビューガイドなどのレビュー機能を有効化/無効化します。
    • レビュー言語を変更します。
    • カスタムレビュー指示を追加・削除・編集します。
    • その他のレビュー設定を調整します。

    サポートを受けるには

    Original review guide in English

    Reviewer's Guide

    This PR enables Next.js TypeScript type-checking via the TypeScript CLI for TS 7 and fixes several unit-test type issues uncovered by the stricter CLI checks, mostly around optional values, structural casts, and mock signatures.

    Sequence diagram for Next.js build using the TypeScript CLI

    sequenceDiagram
      actor Developer
      participant NextBuild
      participant TypeScriptCli
    
      Developer->>NextBuild: next build
      NextBuild->>TypeScriptCli: run TypeScript type_check
      TypeScriptCli-->>NextBuild: type_check result
      NextBuild-->>Developer: build output
    
    Loading

    File-Level Changes

    Change Details Files
    Enable Next.js experimental TypeScript CLI integration so builds/type-checking work with TypeScript 7.
    • Set experimental.useTypeScriptCli to true in the Next.js config to switch type-checking from the deprecated compiler API to the TypeScript CLI
    next.config.ts
    Harden S3 client tests against optional endpoint configuration and spreads.
    • Use optional chaining when invoking s3.config.endpoint and explicitly throw if the endpoint resolution returns a falsy value before asserting on hostname/protocol/port
    • Replace truthy-object spread pattern with a conditional (ternary) object spread so TypeScript understands that endpoint/forcePathStyle are only present when endpoint is defined
    test/unit/lib/storage/s3-backend.test.ts
    Align database tests with TypeScript’s structural typing expectations when accessing symbol-indexed constructors.
    • Cast db.constructor through unknown before asserting it as Record<symbol, string> in several tests that inspect the entityKind symbol to determine the driver type
    test/unit/lib/db.test.ts
    test/unit/lib/db.property.test.ts
    Tighten API route tests by typing mocks and handling possibly undefined values.
    • Add an explicit UploadParams parameter type to the mockUpload function to ensure recorded call tuples are non-empty and structurally compatible
    • Cast imported db through unknown before asserting its type when replacing db.insert with a mock
    • Guard filename.split(".").pop() with a nullish coalescing default to satisfy non-empty string expectations
    test/unit/api/users/route.test.ts
    Make proxy and dev-up script tests type-safe with explicit nullable and unknown types.
    • Initialize state.redirectPath with an explicit string
    null type instead of implicit any
  • Provide an explicit unknown parameter type for the sendMock command argument used in the S3 dev-up helper to avoid implicit any

  • Tips and commands

    Interacting with Sourcery

    • Trigger a new review: Comment @sourcery-ai review on the pull request.
    • Continue discussions: Reply directly to Sourcery's review comments.
    • Generate a GitHub issue from a review comment: Ask Sourcery to create an
      issue from a review comment by replying to it. You can also reply to a
      review comment with @sourcery-ai issue to create an issue from it.
    • Generate a pull request title: Write @sourcery-ai anywhere in the pull
      request title to generate a title at any time. You can also comment
      @sourcery-ai title on the pull request to (re-)generate the title at any time.
    • Generate a pull request summary: Write @sourcery-ai summary anywhere in
      the pull request body to generate a PR summary at any time exactly where you
      want it. You can also comment @sourcery-ai summary on the pull request to
      (re-)generate the summary at any time.
    • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
      request to (re-)generate the reviewer's guide at any time.
    • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
      pull request to resolve all Sourcery comments. Useful if you've already
      addressed all the comments and don't want to see them anymore.
    • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
      request to dismiss all existing Sourcery reviews. Especially useful if you
      want to start fresh with a new review - don't forget to comment
      @sourcery-ai review to trigger a new review!

    Customizing Your Experience

    Access your dashboard to:

    • Enable or disable review features such as the Sourcery-generated pull request
      summary, the reviewer's guide, and others.
    • Change the review language.
    • Add, remove or edit custom review instructions.
    • Adjust other review settings.

    Getting Help

    @sourcery-ai sourcery-ai Bot left a comment

    Copy link
    Copy Markdown

    Choose a reason for hiding this comment

    The reason will be displayed to describe this comment to others. Learn more.

    Hey - 1つ問題を見つけたので、いくつか高レベルなフィードバックを残します:

    • db のテストで繰り返し使われている (db.constructor as unknown as Record<symbol, string>)[entityKind] というパターンは、小さなヘルパー関数か型エイリアスに切り出すことで、危険なキャストを一箇所に集約しつつ、可読性も向上させられます。
    • S3 のテストで s3.config.endpoint?.()undefined を返したときに、汎用的なエラーを投げる代わりに、expect(resolvedEndpoint).toBeDefined() のような明示的なアサーションを使うと、テストの意図がより明確になり、手動でエラーを構築する必要もなくなります。
    • proxy のテストで state.redirectPath = null as string | null を使う代わりに、変数宣言時点で redirectPathstring | null 型として定義しておくと、代入時にアサーションキャストを使う必要がなくなり、よりクリーンになります。
    Prompt for AI Agents
    Please address the comments from this code review:
    
    ## Overall Comments
    - db のテストで繰り返し使われている `(db.constructor as unknown as Record<symbol, string>)[entityKind]` というパターンは、小さなヘルパー関数か型エイリアスに切り出すことで、危険なキャストを一箇所に集約しつつ、可読性も向上させられます。
    - S3 のテストで `s3.config.endpoint?.()``undefined` を返したときに、汎用的なエラーを投げる代わりに、`expect(resolvedEndpoint).toBeDefined()` のような明示的なアサーションを使うと、テストの意図がより明確になり、手動でエラーを構築する必要もなくなります。
    - proxy のテストで `state.redirectPath = null as string | null` を使う代わりに、変数宣言時点で `redirectPath``string | null` 型として定義しておくと、代入時にアサーションキャストを使う必要がなくなり、よりクリーンになります。
    
    ## Individual Comments
    
    ### Comment 1
    <location path="test/unit/lib/storage/s3-backend.test.ts" line_range="125-133" />
    <code_context>
             expect(s3.config.forcePathStyle).toBe(true)
    
    -        const resolvedEndpoint = await s3.config.endpoint()
    +        const resolvedEndpoint = await s3.config.endpoint?.()
    +        if (!resolvedEndpoint) {
    +          throw new Error("endpoint should be resolved")
    +        }
             const url = new URL(endpoint)
    </code_context>
    <issue_to_address>
    **suggestion (testing):** `endpoint` が定義されているという期待を表現するために、throw ではなくテスト用のアサーションを使ってください
    
    ここでの失敗条件はテストが期待している挙動の一部なので、手動で例外を投げるよりも、アサーションによって明示的に表現する方が分かりやすく、より慣用的です。例えば `expect(resolvedEndpoint).toBeDefined()` を行った上で、その後のプロパティチェックに対しては非 null アサーションや型ガードを使うことで、「endpoint は必ず resolve されているべき」という意図を保ちつつ、テスト本体のカスタムエラー処理を取り除けます。
    
    ```suggestion
            expect(s3.config.forcePathStyle).toBe(true)
    
            const resolvedEndpoint = await s3.config.endpoint?.()
            expect(resolvedEndpoint).toBeDefined()
    
            const url = new URL(endpoint)
            expect(resolvedEndpoint!.hostname).toBe(url.hostname)
            expect(resolvedEndpoint!.protocol).toBe(url.protocol)
    ```
    </issue_to_address>

    Sourcery は OSS 向けに無料で提供されています — レビューが気に入ったらぜひシェアを検討してください ✨
    もっと役に立てるようにしてください!各コメントに対して 👍 または 👎 をクリックしていただけると、そのフィードバックを次回以降のレビュー改善に活用します。
    Original comment in English

    Hey - I've found 1 issue, and left some high level feedback:

    • The repeated (db.constructor as unknown as Record<symbol, string>)[entityKind] pattern in the db tests could be wrapped in a small helper or type alias to centralize the unsafe cast and improve readability.
    • Instead of throwing a generic error when s3.config.endpoint?.() returns undefined in the S3 tests, consider using an explicit expect(resolvedEndpoint).toBeDefined() assertion to better communicate test intent and avoid manual error construction.
    • Rather than using state.redirectPath = null as string | null in the proxy tests, it would be cleaner to define redirectPath with a string | null type at its declaration so you don't need assertion casts on assignment.
    Prompt for AI Agents
    Please address the comments from this code review:
    
    ## Overall Comments
    - The repeated `(db.constructor as unknown as Record<symbol, string>)[entityKind]` pattern in the db tests could be wrapped in a small helper or type alias to centralize the unsafe cast and improve readability.
    - Instead of throwing a generic error when `s3.config.endpoint?.()` returns `undefined` in the S3 tests, consider using an explicit `expect(resolvedEndpoint).toBeDefined()` assertion to better communicate test intent and avoid manual error construction.
    - Rather than using `state.redirectPath = null as string | null` in the proxy tests, it would be cleaner to define `redirectPath` with a `string | null` type at its declaration so you don't need assertion casts on assignment.
    
    ## Individual Comments
    
    ### Comment 1
    <location path="test/unit/lib/storage/s3-backend.test.ts" line_range="125-133" />
    <code_context>
             expect(s3.config.forcePathStyle).toBe(true)
    
    -        const resolvedEndpoint = await s3.config.endpoint()
    +        const resolvedEndpoint = await s3.config.endpoint?.()
    +        if (!resolvedEndpoint) {
    +          throw new Error("endpoint should be resolved")
    +        }
             const url = new URL(endpoint)
    </code_context>
    <issue_to_address>
    **suggestion (testing):** Use test assertions instead of throwing to express the expectation that `endpoint` is defined
    
    Since the failure condition here is part of the test’s expectation, it’s clearer and more idiomatic to assert on it rather than manually throwing. For example, `expect(resolvedEndpoint).toBeDefined()` followed by a non-null assertion or type guard for later property checks preserves the intent that the endpoint must be resolved and removes the custom error handling in the test body.
    
    ```suggestion
            expect(s3.config.forcePathStyle).toBe(true)
    
            const resolvedEndpoint = await s3.config.endpoint?.()
            expect(resolvedEndpoint).toBeDefined()
    
            const url = new URL(endpoint)
            expect(resolvedEndpoint!.hostname).toBe(url.hostname)
            expect(resolvedEndpoint!.protocol).toBe(url.protocol)
    ```
    </issue_to_address>

    Sourcery is free for open source - if you like our reviews please consider sharing them ✨
    Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

    Comment on lines 125 to 133
    expect(s3.config.forcePathStyle).toBe(true)

    const resolvedEndpoint = await s3.config.endpoint()
    const resolvedEndpoint = await s3.config.endpoint?.()
    if (!resolvedEndpoint) {
    throw new Error("endpoint should be resolved")
    }
    const url = new URL(endpoint)
    expect(resolvedEndpoint.hostname).toBe(url.hostname)
    expect(resolvedEndpoint.protocol).toBe(url.protocol)

    Copy link
    Copy Markdown

    Choose a reason for hiding this comment

    The reason will be displayed to describe this comment to others. Learn more.

    suggestion (testing): endpoint が定義されているという期待を表現するために、throw ではなくテスト用のアサーションを使ってください

    ここでの失敗条件はテストが期待している挙動の一部なので、手動で例外を投げるよりも、アサーションによって明示的に表現する方が分かりやすく、より慣用的です。例えば expect(resolvedEndpoint).toBeDefined() を行った上で、その後のプロパティチェックに対しては非 null アサーションや型ガードを使うことで、「endpoint は必ず resolve されているべき」という意図を保ちつつ、テスト本体のカスタムエラー処理を取り除けます。

    Suggested change
    expect(s3.config.forcePathStyle).toBe(true)
    const resolvedEndpoint = await s3.config.endpoint()
    const resolvedEndpoint = await s3.config.endpoint?.()
    if (!resolvedEndpoint) {
    throw new Error("endpoint should be resolved")
    }
    const url = new URL(endpoint)
    expect(resolvedEndpoint.hostname).toBe(url.hostname)
    expect(resolvedEndpoint.protocol).toBe(url.protocol)
    expect(s3.config.forcePathStyle).toBe(true)
    const resolvedEndpoint = await s3.config.endpoint?.()
    expect(resolvedEndpoint).toBeDefined()
    const url = new URL(endpoint)
    expect(resolvedEndpoint!.hostname).toBe(url.hostname)
    expect(resolvedEndpoint!.protocol).toBe(url.protocol)
    Original comment in English

    suggestion (testing): Use test assertions instead of throwing to express the expectation that endpoint is defined

    Since the failure condition here is part of the test’s expectation, it’s clearer and more idiomatic to assert on it rather than manually throwing. For example, expect(resolvedEndpoint).toBeDefined() followed by a non-null assertion or type guard for later property checks preserves the intent that the endpoint must be resolved and removes the custom error handling in the test body.

    Suggested change
    expect(s3.config.forcePathStyle).toBe(true)
    const resolvedEndpoint = await s3.config.endpoint()
    const resolvedEndpoint = await s3.config.endpoint?.()
    if (!resolvedEndpoint) {
    throw new Error("endpoint should be resolved")
    }
    const url = new URL(endpoint)
    expect(resolvedEndpoint.hostname).toBe(url.hostname)
    expect(resolvedEndpoint.protocol).toBe(url.protocol)
    expect(s3.config.forcePathStyle).toBe(true)
    const resolvedEndpoint = await s3.config.endpoint?.()
    expect(resolvedEndpoint).toBeDefined()
    const url = new URL(endpoint)
    expect(resolvedEndpoint!.hostname).toBe(url.hostname)
    expect(resolvedEndpoint!.protocol).toBe(url.protocol)

    @vercel

    vercel Bot commented Jul 14, 2026

    Copy link
    Copy Markdown

    The latest updates on your projects. Learn more about Vercel for GitHub.

    Project Deployment Actions Updated (UTC)
    dcrs Error Error Jul 14, 2026 6:14am

    TypeScript 7 no longer exposes the compiler API that `next build`
    relied on, so the "Running TypeScript" step failed with
    "TypeScript 7.0.2 does not provide the compiler API required by
    Next.js" and broke the Playwright webServer build.
    
    - Enable `experimental.useTypeScriptCli` so Next.js type-checks via
      the TypeScript CLI (ref JamBalaya56562/blog#1076).
    - Fix type errors newly surfaced by the CLI in unit tests:
      - type mock parameters so recorded call tuples are non-empty
      - cast through `unknown` for incompatible structural casts
      - guard possibly-undefined endpoint providers and object spreads
    
    Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
    @github-actions github-actions Bot added the dependencies Pull requests that update a dependency file label Jul 14, 2026
    @Marukome0743
    Marukome0743 merged commit 3a250f2 into OpenUp-LabTakizawa:main Jul 14, 2026
    19 of 21 checks passed
    @Marukome0743
    Marukome0743 deleted the pr1576 branch July 14, 2026 06:15
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

    Labels

    ⚙️config Update configuration files dependencies Pull requests that update a dependency file ✅test Something related to test

    Projects

    None yet

    Development

    Successfully merging this pull request may close these issues.

    2 participants