Check Function Calls with Spread (...)

Parameter types:

Argument types:

Generated TypeScript code:

declare function fn(p0?: number, ...rest: string[]) : void; declare const a0 : number; declare const a1 : string; declare const a2 : string[]; fn(a0, a1, ...a2);

View in Playground

Callionica's spread checker says:

No errors

Notes

Provide types for function parameters and arguments and the spread checker will tell you if the call would succeed.

This page also generates TypeScript code that will help you understand how the spread checker has understood your types, and a link to the playground so you can see how TypeScript handles the same situation.

This is a simple demo with limited power in parsing and typechecking.

It's designed to detect whether spreads in a function call are valid in basic scenarios involving primitive types.

Stick to `number` and `string`, and optionals, tuples, arrays, spread/rests, and unions of `number` and `string`.

The type parser does not handle names, so optional `?` goes after the type.

Optional does not add `undefined` to the type as far as our spread checking algorithm goes, so add `undefined` by hand if you need to.

The type parser does not handle names, literals, objects, generics, inference. It's a demo!