From 95b17aa0572e51fd6ac42c2637b8d61c84de5ca0 Mon Sep 17 00:00:00 2001 From: Andy Parsons Date: Tue, 22 Nov 2022 10:19:49 +0000 Subject: [PATCH 1/2] Allow src/app dir for ts plugin findDir will fall back to src/app if /app not found --- packages/next/server/next-typescript.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/next/server/next-typescript.ts b/packages/next/server/next-typescript.ts index db244af381deb..55b23b068042a 100644 --- a/packages/next/server/next-typescript.ts +++ b/packages/next/server/next-typescript.ts @@ -9,6 +9,7 @@ */ import path from 'path' +import { findDir } from '../lib/find-pages-dir' const DISALLOWED_SERVER_REACT_APIS: string[] = [ 'useState', @@ -193,7 +194,7 @@ export function createTSPlugin(modules: { } function create(info: ts.server.PluginCreateInfo) { - const appDir = path.join(info.project.getCurrentDirectory(), 'app') + const appDir = findDir(info.project.getCurrentDirectory(), 'app') const isAppEntryFile = (filePath: string) => { return ( filePath.startsWith(appDir) && From c9b5df5130d7aefef3e44e7919282e647b2198af Mon Sep 17 00:00:00 2001 From: Andy Parsons Date: Tue, 22 Nov 2022 12:27:37 +0000 Subject: [PATCH 2/2] fall back to a known string --- packages/next/server/next-typescript.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/next/server/next-typescript.ts b/packages/next/server/next-typescript.ts index 55b23b068042a..8f134cd3e1031 100644 --- a/packages/next/server/next-typescript.ts +++ b/packages/next/server/next-typescript.ts @@ -194,7 +194,7 @@ export function createTSPlugin(modules: { } function create(info: ts.server.PluginCreateInfo) { - const appDir = findDir(info.project.getCurrentDirectory(), 'app') + const appDir = findDir(info.project.getCurrentDirectory(), 'app') ?? path.join(info.project.getCurrentDirectory(), 'app') const isAppEntryFile = (filePath: string) => { return ( filePath.startsWith(appDir) &&