Writing Import Paths That Node Can Run

The league table script from the last video starts with import { type TeamRow, ResultsTable } from "./results-table.ts";. The path ends in .ts, and that may look odd. Many TypeScript projects, tutorials, and AI suggestions use ./results-table.js instead, even though no such file exists.

In this lesson, you’ll see why the Riverside project’s paths name the .ts file. You’ll read the error that a .js path causes, and you’ll learn which settings in tsconfig.json let the checker accept a .ts path.

Name the File That Node.js Runs

An import path tells the runtime which file to load, as it did in Modules and JSON: Programs Across Files. In older code and many guides, the league table’s import line would end in .js:

Language: TypeScript
import { type TeamRow, ResultsTable } from "./results-table.js";

Locked learning resources

Join us and get access to thousands of tutorials and a community of expert JavaScript developers.

Unlock This Lesson

Already a member? Sign-In

Locked learning resources

The full lesson is for members only. Join us and get access to thousands of tutorials and a community of expert JavaScript developers.

Unlock This Lesson

Already a member? Sign-In

Become a Member to join the conversation.