Skip to content

fn does not infer parameter labels correctly if internalSignature has optional parameters #1614

@aswinsvijay

Description

@aswinsvijay

Report a bug

🔎 Search Terms

  • Optional parameters
  • internalSignature
  • parameter label

🧩 Context

  • ArkType version: ^2.2.0
  • TypeScript version (5.1+): All versions from 5.1 to 6.0
  • Other context you think may be relevant (JS flavor, OS, etc.): In TS 5.1 and 5.2, fooIncorrect is inferred as TypedFn<(...args: never) => void>, but expected TypedFn<(a: string, b: number) => void

🧑‍💻 Repro

Playground Link: https://www.typescriptlang.org/play/?ts=5.9.3#code/JYWwDg9gTgLgBAbzjAnmApgGjgMwHZwC+uUEIcA5AIZQDWqGFA3ALABQ7AxhHgM7w4IEOAF5ceABQV+UYHgDmFbBTwBXEACN0UCgEoJEqtg27RAPkSFdrNtz4ChASTzcoUdJ3hj8UmXMXKapraegZGcBoA-KYiFghWNuyCEDYA9KkAepFJTi7Q7p5pmdkctjz8ETQACjRUILyiyGjoEgDa0jCyCkqUQVo6ALq6AHTQbRQaQgA26FR4FEM2dhUaNM6uBV7iUsO7PatQNVB1vPqGxtHmltbs7Afr+R4wRVnsQA

import { type, fn } from 'arktype';

const foo = fn('string', 'number')((a, b) => {});
const fooIncorrect = fn('string', 'number')((a, b?) => {});

foo;
//^?
fooIncorrect;
//^?

const barParams = type(['string', 'number']).or(['boolean']);
const barIncorrect = fn('...', barParams)((a, b?) => {});

barIncorrect;
//^?

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type
No fields configured for issues without a type.

Projects

Status

To do

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions