Skip to content

[5.1.0-dev.20230413] never function parameters will reject function call with no type parametersΒ #53770

Closed as not planned
@eps1lon

Description

@eps1lon

Bug Report

πŸ”Ž Search Terms

never

πŸ•— Version & Regression Information

  • This changed between versions 5.0.4 and 5.1.0-dev.20230413

⏯ Playground Link

Playground link with relevant code

πŸ’» Code

type BaseParams = {foo: string}
type OriginalParams<T> = T extends undefined ? [BaseParams?] : [BaseParams & T]

declare const optionalParam: (...params: OriginalParams<undefined>) => void
declare const noParam: (...params: OriginalParams<never>) => void

optionalParam()
optionalParam({foo: 'bar'})

// Argument of type '[]' is not assignable to parameter of type 'never'.(2345)
// Works in TS 5.0
noParam()

type StillBrokenParamsImpl<T> = T extends never ? [] : [true]
type NeverIn50AsWell = StillBrokenParamsImpl<never>
//   ^?
// should be [] to be useable as function parameter type
type Test = StillBrokenParamsImpl<undefined>
//   ^?
// expected: type Test = [true]

πŸ™ Actual behavior

never as a type for function parameters not usable to indicate "no arguments allowed"

πŸ™‚ Expected behavior

Some way to produce a type that results in no function arguments allowed. We used to do this with FunctionParams<never> but now it's no longer clear how to do it since AnyGenery<never> already produced never in TS 5.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    Working as IntendedThe behavior described is the intended behavior; this is not a bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions