cf.completefrontend

Predict the typesMedium

With verbatimModuleSyntax on, which of these imports and exports does TypeScript reject?

The project turns on verbatimModuleSyntax, as Vite's templates do. src/user.ts exports an interface, a type alias, and a function. Name every error TypeScript reports in src/app.ts, and the type the ^? line points at.

src/user.ts
export interface User {
  name: string;
  role: Role;
}
export type Role = "admin" | "member";
 
export function createUser(name: string): User {
  return { name, role: "member" };
}
What does TypeScript report here? (src/app.ts)
import { User, createUser } from "./user";import { type Role } from "./user";import type { User as Member } from "./user";export { User } from "./user";export type { Role } from "./user"; const ada: User = createUser("Ada");const role: Role = ada.role;//    ^?

Compiler options: verbatimModuleSyntax: true

Work it out first: the compiler shows every error and type.

The answer

Work out every error TypeScript reports and every type it shows, line by line. Then check.

Checking your sign-in…