https://github.com/devsnek/proposal-unused-function-parameters
https://github.com/devsnek/proposal-unused-function-parameters
Last synced: 9 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/devsnek/proposal-unused-function-parameters
- Owner: devsnek
- License: mit
- Created: 2020-08-12T02:56:25.000Z (over 5 years ago)
- Default Branch: main
- Last Pushed: 2020-08-12T03:08:11.000Z (over 5 years ago)
- Last Synced: 2025-02-09T07:36:05.118Z (10 months ago)
- Language: HTML
- Size: 20.5 KB
- Stars: 14
- Watchers: 7
- Forks: 0
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Unused Function Parameters
## The Problem
```js
doSomething((unused1, unused2, somethingUseful) => {
doSomethingWith(somethingUseful);
});
doSomething((_, __, somethingUseful) => {
doSomethingWith(somethingUseful);
});
```
## Solutions
### Elisions
```js
doSomething(( , , somethingUseful) => {
doSomethingWith(somethingUseful);
});
```
- Matches with existing destructuring
- `([, c])` is already valid
- Some might say it looks weird
### Placeholder Syntax
```js
doSomething((?, ?, somethingUseful) => {
doSomethingWith(somethingUseful);
});
doSomething((*, *, somethingUseful) => {
doSomethingWith(somethingUseful);
});
// etc.
```
- Most explicit, clearly "using up" a parameter without binding it
- Requires more syntax
### Placeholder Identifier
```js
doSomething((_, _, somethingUseful) => {
doSomethingWith(somethingUseful);
});
doSomething((_, _, somethingUseful) => {
print(_); // IdentifierReference : `_` early error?
doSomethingWith(somethingUseful);
});
```
- Arguably most natural, other languages use this (C#, Rust, etc.)
- Any valid identifiers are already valid identifiers, could conflict with existing code