Skip to content
This repository was archived by the owner on Dec 31, 2019. It is now read-only.

tc39/proposal-optional-catch-binding

Folders and files

Image for: Folders and files
NameName
Last commit message
Last commit date

Latest commit

Image for: Latest commit
 

History

Image for: History
7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Image for: Repository files navigation

This proposal makes a grammatical change to ECMAScript, allowing the omission of a catch binding in cases where the binding would not be used. This occurs frequently with patterns such as

try {
  // try to use a web feature which may not be implemented
} catch (unused) {
  // fall back to a less desirable web feature with broader support
}

or

let isTheFeatureImplemented = false;
try {
  // stress the required bits of the web API
  isTheFeatureImplemented = true;
} catch (unused) {}

or

let parseResult = someFallbackValue;
try {
  parseResult = JSON.parse(potentiallyMalformedJSON);
} catch (unused) {}

and it is a common opinion that variables which are declared or written to but never read signify a programming error.

The grammar change introduced by this proposal allows for the catch binding and its surrounding parentheses to be omitted, as in

try {
  // ...
} catch {
  // ...
}

See the the full text of the proposal for more info.

About

Image for: About

proposal for ECMAScript to allow omission of the catch binding

Resources

Code of conduct

Security policy

Stars

Watchers

Forks

Releases

Image for: Releases
No releases published

Packages

Image for: Packages 0
No packages published

Contributors 2

Image for: Contributors 2
  •  
  •