Closed
Description
Bug Report
In auditing some code, I've noticed something that doesn't seem like it should compile. In >=4.95, the following code compiles without an issue, but in <=4.7.4, there is an error. Why is it possible to specify an object for the name of a parameter? This code was likely the result of a bad copy/paste, but TS isn't erroring on it. Am I missing something about the syntax? Also, is the discrepancy between versions intended?
const DEFAULT_NUM_PAGINATED_RESULTS = 10;
type IPaginatedParams = {first?: number; after?: string;}
type GetPaginatedResults = <Obj, Key extends keyof Obj>(
items: Obj[],
{ first = DEFAULT_NUM_PAGINATED_RESULTS, after }: IPaginatedParams,
key: Key
) => { items: Obj[]; hasMore: boolean };
Playground links for 4.7.4 vs 4.9.5
🔎 Search Terms
function parameter names