Loading...
function routes<T extends string[]>(paths: T) {
return paths;
}
const r = routes(['home', 'about']); // string[]function routes<const T extends readonly string[]>(paths: T) {
return paths;
}
const r = routes(['home', 'about']); // readonly ['home', 'about']const T with a readonly constraint infers the exact tuple without callers writing as const.
readonly unknown[], since a mutable constraint drops the literal tuple inference.const does not affect values from variables.<const T> replaces asking callers to add as const to every argument.as const is written by each caller. <const T> is written once in the function and applies to every literal argument.
No, it only changes inference. Use Object.freeze() for runtime immutability.