LuaLS / LuaLS/lua-language-server

Request/How-to: Get return type of generic function

Open
#2,201 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement feat/generic
Dominant language
Lua
Stars
4.4k
Forks
442
PR merge metrics
No merged PRs in 30d

Description

I have a function which accepts a generic function as its parameter. It does stuff with that function, then returns that function's return value(s) as its own. I would like for the returned properties to cascade from the generic function and propogate accordingly for type information.

In TypeScript, I would do:

const foo = <T extends Function>(func: T): ReturnType<T> => func(...)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

No files, tests, or entry points are named. Start by locating how generic functions and their return types are represented in the language server, using the TypeScript ReturnType example as the requested behavior; done means returned properties propagate from the passed generic function.

Written by the indexing model from the issue text.

Assessment

Tech stack
lua
Domain
tooling
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.