What kind of issue is this?
Link to repro
https://github.com/hnamekawa/movie-app
Repro steps
-
Clone the repo
-
Run npm run dev
The app works fine without any errors
- Run
npm run build
The React compiler reports the errors shown below, and the app fails to load
Description
src/types/Todo.ts defines a Todo interface, and src/App.tsx imports and uses that interface.
It seems that TypeScript interfaces are not being handled correctly during the build process.
When src/App.tsx is transpiled, it makes sense that an error occurs because the Todo interface does not exist at runtime.
However, npm run dev does not show any error, while npm run build does.
This inconsistency between dev and build is the issue I want to report.
npm run build error log detail
src/App.tsx:2:1 - error TS6133: 'TodoItem' is declared but its value is never read.
2 import { TodoItem } from "./types/Todo";
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/App.tsx:9:38 - error TS2304: Cannot find name 'Todo'.
9 const [todos, setTodos] = useState<Todo[]>([]);
~~~~
src/App.tsx:12:50 - error TS2304: Cannot find name 'Todo'.
12 const [editingTodo, setEditingTodo] = useState<Todo | null>(null);
~~~~
src/App.tsx:40:44 - error TS2304: Cannot find name 'Todo'.
40 const handleCreateOrUpdate = (data: Omit<Todo, "id">) => {
~~~~
src/App.tsx:52:22 - error TS2304: Cannot find name 'Todo'.
52 const newTodo: Todo = {
~~~~
src/components/TodoForm.tsx:2:1 - error TS6133: 'TodoItem' is declared but its value is never read.
2 import { TodoItem } from "../types/Todo";
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/components/TodoForm.tsx:5:25 - error TS2304: Cannot find name 'Todo'.
5 onSubmit: (todo: Omit<Todo, "id">) => void; // pass data to parent
~~~~
src/components/TodoForm.tsx:6:17 - error TS2304: Cannot find name 'Todo'.
6 editingTodo?: Todo | null; // editing ToDo
~~~~
src/components/TodoForm.tsx:12:40 - error TS2304: Cannot find name 'Todo'.
12 const [status, setStatus] = useState<Todo["status"]>("Open");
~~~~
src/components/TodoList.tsx:2:1 - error TS6133: 'TodoItem' is declared but its value is never read.
2 import { TodoItem } from "../types/Todo";
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/components/TodoList.tsx:5:10 - error TS2304: Cannot find name 'Todo'.
5 todos: Todo[]; // ToDo list to display
~~~~
src/components/TodoList.tsx:6:18 - error TS2304: Cannot find name 'Todo'.
6 onEdit: (todo: Todo) => void;// edit button clicked
~~~~
Found 12 errors.
How often does this bug happen?
Every time
What version of React are you using?
19.2.0
What version of React Compiler are you using?
1.0
What kind of issue is this?
Link to repro
https://github.com/hnamekawa/movie-app
Repro steps
Clone the repo
Run
npm run devThe app works fine without any errors
npm run buildThe React compiler reports the errors shown below, and the app fails to load
Description
src/types/Todo.tsdefines aTodointerface, andsrc/App.tsximports and uses that interface.It seems that TypeScript interfaces are not being handled correctly during the build process.
When
src/App.tsxis transpiled, it makes sense that an error occurs because the Todo interface does not exist at runtime.However,
npm run devdoes not show any error, whilenpm run builddoes.This inconsistency between dev and build is the issue I want to report.
npm run builderror log detailHow often does this bug happen?
Every time
What version of React are you using?
19.2.0
What version of React Compiler are you using?
1.0