Files
scriptc/tests/corpus/6446-rest-function-nested-declaration.ts
T
Malte UblandClaude Opus 5.5 73bd0b53c3 Pass rest-parameter functions into slots with fixed parameters
A typed rest-parameter function passed where a function with fixed parameters is expected (`log(...m: string[])` into `(m: string) => void`) was refused. The function adapter now packs the slot's remaining arguments into the rest array, and the value check admits the function wherever that adapter fits. A nested function declaration with a typed rest parameter becomes a value with its own typed-rest signature, converted at each use.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-19 21:23:54 -07:00

27 lines
602 B
TypeScript

// Nested rest-parameter function declarations passed to a fixed slot.
class Line {
private readonly sink: (m: string) => void;
constructor(sink: (m: string) => void) {
this.sink = sink;
}
emit(m: string): void {
this.sink(m);
}
}
interface Logger {
line: () => Line;
log: (...messages: string[]) => void;
}
function makeLogger(prefix: string): Logger {
return {
line: () => new Line(log),
log,
};
function log(...messages: string[]) {
console.log(prefix, messages.join(" "));
}
}
const logger = makeLogger(">");
logger.log("a", "b");
logger.line().emit("c");