“TipeError Tak Terbuku: Prototipe Objek hanya bisa menjadi objek atau nol: Tidak ditentukan” Kode Jawaban

TipeError Tak Terbuku: Prototipe Objek hanya bisa menjadi objek atau nol: Tidak ditentukan

As I suspected, your original program has circular imports. Run.ts imports index.ts, which imports Customer.ts, which imports index.ts again. Since index.ts is already in the process of loading and itself depends on Customer.ts, the import { Entity } from "./index"; just binds the Entity of index.ts (which is not set yet) to the Entity of Customer.ts, and execution proceeds even though index.ts isn't finished loading. Then Entity is undefined at the time you try to extend it. You might argue that a circular import should be an error or that JavaScript engines should use some other algorithm that correctly handles your scenario; I'm not qualified to comment on why the current design was chosen. (Others feel free to add information about this.)

As you saw, changing Customer.ts to import from ./Entity directly instead of ./index breaks the cycle, and everything works as expected. Another solution would be to reverse the order of imports in index.ts.
Exuberant Emu

TipeError Tak Terbuku: Prototipe Objek hanya bisa menjadi objek atau nol: Tidak ditentukan

no solution for this
Ahmad Mardinly

Jawaban yang mirip dengan “TipeError Tak Terbuku: Prototipe Objek hanya bisa menjadi objek atau nol: Tidak ditentukan”

Pertanyaan yang mirip dengan “TipeError Tak Terbuku: Prototipe Objek hanya bisa menjadi objek atau nol: Tidak ditentukan”

Lebih banyak jawaban terkait untuk “TipeError Tak Terbuku: Prototipe Objek hanya bisa menjadi objek atau nol: Tidak ditentukan” di JavaScript

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya