cf.completefrontend

Predict the typesMedium

What does the const modifier on a type parameter change in these calls?

Name the type each ^? line points at, and say whether TypeScript reports any errors.

What does TypeScript report here?
function routes<T extends readonly string[]>(paths: T): T {  return paths;}function constRoutes<const T extends readonly string[]>(paths: T): T {  return paths;}function mutableRoutes<const T extends string[]>(paths: T): T {  return paths;} const a = routes(["/", "/about"]);//    ^?const b = constRoutes(["/", "/about"]);//    ^?const c = mutableRoutes(["/", "/about"]);//    ^?const list = ["/", "/about"];const d = constRoutes(list);//    ^?

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…