[node-loader] Signature disambiguation for single options objects vs positional parameters
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 5/5
- Estimated time
- Over a week
- Newbie friendliness
- 25/100
- Issue type
- Feature
- Clarity
- Needs clarification
- Activity status
- Active
- Tech stack
- javascript, node.js, typescript
- Domain
- tooling
Research direction
Read source/loaders/node_loader and trace its reflection metadata and invocation entry points first. Compare the two call shapes described in the issue; done means the loader consistently distinguishes a single dictionary argument from positional arguments, with behavior validated by the project's relevant loader tests.
Written by the indexing model from the issue text.
Description
Description
In JavaScript / TypeScript, developers frequently define functions that accept a single destructured options object rather than multiple positional arguments. When invoking these functions through MetaCall with an argument dictionary, there is currently ambiguity on how the payload should be passed.
Problem
Consider two common JavaScript patterns:
// Case 1: Single options object (destructuring)
function createUser({ username, email, isAdmin = false }) {
return db.users.create({ username, email, isAdmin });
}
// Case 2: Positional arguments
function add(a, b) {
return a + b;
}
When an external client sends a JSON dictionary { "username": "alice", "email": "[email protected]" }:
- If the dispatcher unpacks the dictionary positionally (
createUser(arg0, arg1)), the function looks for parameter 0 as an object, findsundefined, and throws:
TypeError: Cannot destructure property 'username' of undefined or null - To work correctly, the entire dictionary must be passed as argument 0 (
createUser(obj)), whereas foradd(a, b)the values must be extracted into positional parametersadd(1, 2).
Without reflection into function arity (fn.length) and parameter structure, callers cannot determine whether a dictionary represents a single options argument or multiple positional parameters.
Proposed Solution
In source/loaders/node_loader:
- Enhance reflection metadata to expose function arity and whether parameter 0 expects an object/struct vs primitives.
- Allow the invocation layer in the NodeJS loader to automatically detect when a dictionary should be forwarded as a single object argument vs unpacked into positional parameters.
- Dominant language
- C
- Stars
- 1.8k
- Forks
- 266
- Avg merge
- 2d 16h
- Merged PRs (30d)
- 14
Getting set up
- Ships a Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from metacall/core
-
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
metacall/core#964 · 1 comment ·
Maintainers usually reply within 1 day
-
pre-push hook empties VERSION when the clone has no tagsPossibly taken @vedant21-oss claimed this 18 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
metacall/core#939 · 3 comments ·
Maintainers usually reply within 1 day
-
TOCTOU race condition vulnerability!Possibly taken @akshatchitransh claimed this 1 day ago. Openbug
Difficulty 4/5 3-5 days Newbie friendliness 35/100
metacall/core#961 · 2 comments ·
Maintainers usually reply within 1 day
-
bug
Difficulty 3/5 Half a day Newbie friendliness 70/100
Maintainers usually reply within 1 day
-
Go Port Race Conditions on MacOSPossibly taken A pull request linked to this issue is open or already merged. Openbug
Difficulty 4/5 3-5 days Newbie friendliness 35/100
metacall/core#942 · 3 comments ·
Maintainers usually reply within 1 day
Similar issues
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
-
`table_create()` crashes when an `hccalloc()` for the option table failsPossibly taken @marinelay claimed this today. Opentype: bug
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day
-
Difficulty 1/5 Under an hour Newbie friendliness 78/100
Maintainers usually reply within 1 day
-
bug severity: low
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
AlessandroSangiuliano/Uros#950 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
OpenXiangShan/NEMU#1296 ·
Maintainers usually reply within 1 day