What’s New in TC39? From Error Cause to Intl.DisplayNames v2 and Beyond
The TC39 meeting covered a range of ECMAScript proposals—including Error Cause, Intl.DisplayNames, .item() for indexables, Import Assertions, Class static initialization blocks, ResizableArrayBuffer, Intl.Enumeration, Double‑Ended Iterators, integer‑math extensions, Standardized Debug, String Dedent, Intl Locale and DisplayNames v2—detailing their stage‑gate requirements, example implementations, and impact on JavaScript development.
During this TC39 meeting we advanced several proposals, notably moving the Error Cause proposal into Stage 1 as a standardized JavaScript error‑handling pattern, and discussing the progression of many other features toward higher stages.
Stage 3 → Stage 4
To reach Stage 4 a proposal must:
Provide a full tc39/test262 test suite covering the proposal.
Have at least two implementations passing the Test262 tests and shipped in a stable release.
Submit a Pull Request to tc39/ecma262 that is signed off by the ECMAScript editors.
Intl.DisplayNames
This Stage 4 proposal adds internationalized names for common nouns such as regions, scripts, languages and currencies.
Region codes: ISO‑3166 two‑letter codes or UN M49 three‑digit codes.
Script codes: ISO‑15924 four‑character codes.
Language codes follow the UTS 35 grammar (e.g., ISO 639‑1 or ISO 639‑2).
Currency codes: three‑letter ISO 4217 codes.
// Simplified Chinese region names
let regionNames = new Intl.DisplayNames(['zh-Hans'], {type: 'region'});
regionNames.of('US'); // "美国"
regionNames.of('419'); // "拉丁美洲"
regionNames.of('MM'); // "缅甸"The features are already available in Chrome 81 and Node.js 14 without any flags.
Stage 2 → Stage 3
Requirements for this transition include a complete draft specification reviewed and signed by TC39 members, and editorial sign‑off.
.item() for indexables
Proposal tc39/proposal-item-method adds .item() to arrays and typed arrays, enabling reverse indexing (e.g., arr.item(-1)).
It also introduces String.prototype.item() with the same semantics as "foo"[idx], providing consistent indexing across indexable types.
Import Assertions
The tc39/proposal-import-assertions proposal adds an assert clause to import statements, allowing developers to declare the expected module type (e.g., JSON) and let the engine reject mismatched MIME types.
import json from "./foo.json" assert {type: "json"};
import("foo.json", {assert: {type: "json"}});Stage 1 → Stage 2
Advancing a proposal to Stage 2 requires a draft specification covering the entire proposal.
Class static initialization block
Proposal tc39/proposal-class-static-block introduces static initialization blocks that run when a class is evaluated, with access to private fields, enabling patterns such as friend classes.
let A, B;
{
let friendA;
A = class A {
#x;
static {
friendA = {
getX(obj) { return obj.#x; },
setX(obj, value) { obj.#x = value; }
};
}
};
B = class B {
constructor(a) {
const x = friendA.getX(a);
friendA.setX(a, value);
}
};
}
export { A, B };ResizableArrayBuffer and GrowableSharedArrayBuffer
These proposals aim to improve memory handling for WebAssembly by allowing ArrayBuffers to be resized in place ( ResizableArrayBuffer) or grown across shared contexts ( GrowableSharedArrayBuffer).
let rab = new ResizableArrayArrayBuffer(1024, 1024 ** 2);
assert(rab.byteLength === 1024);
assert(rab.maximumByteLength === 1024 ** 2);
rab.resize(rab.byteLength * 2);
assert(rab.byteLength === 1024 * 2);Intl.Enumeration
Proposal tc39/proposal-intl-enumeration adds APIs to enumerate supported calendars, currencies, numbering systems, time zones, units, etc.
// List supported calendars
Intl.getSupportedCalendars(); // ["buddhist", "chinese", ...]Stage 0 → Stage 1
Requirements include a champion TC39 member, a clear problem statement and solution sketch, concrete examples, and analysis of API shape, algorithms and implementation risks.
Error Cause
The tc39/proposal-error-cause proposal adds an optional cause argument to the Error constructor, allowing developers to attach the original error and enabling tools like Chrome DevTools to display it.
try {
return await fetch('//unintelligible-url-a')
.catch(err => { throw new Error('Download raw resource failed', err); });
} catch (err) {
console.log(err);
console.log('Caused by', err.cause);
}Double‑Ended Iterator & Destructuring
The tc39/proposal-deiter proposal introduces a bidirectional iterator that can be destructured from both ends, e.g., let [first, ...rest, last] = iterable.
let a = [1, 2, 3, 4, 5, 6];
let deiter = a.values(); // assume it returns a double‑ended iterator
deiter.next(); // {value: 1}
deiter.next('back'); // {value: 6}Modulus & Additional Integer Math
Proposal integer-and-modulus-math-proposal adds integer‑oriented Math methods such as Math.mod, Math.idiv, Math.imod, Math.idivmod, Math.imuldiv and Math.irem.
Standardized Debug
Proposal tc39/proposal-standardized-debug explores a dbg! syntax (or an extended debugger.log) to print intermediate values without duplicating expensive computations.
function doSomething(a) {
let b = dbg!(a + costlyOperation()) * 2;
// ...
}String Dedent
Proposal tc39/proposal-string-dedent adds String.dedent to automatically remove common leading whitespace from multiline template strings.
class Foo {
methodA() {
const foo = String.dedent(`
First Line
Second Line
Third Line`);
return foo;
}
}Intl Locale
Proposal tc39/proposal-intl-locale-info adds properties to Intl.Locale.prototype such as firstDayOfWeek, minimalDaysInFirstWeek, weekendStart, weekendEnd, direction, measurementSystem, defaultHourCycle, defaultCalendar, commonCalendars, etc., to provide richer locale data.
Intl.DisplayNames v2
While the original Intl.DisplayNames API covers regions, languages, scripts and currencies, this Stage 1 extension adds support for months, weekdays, units, time zones, calendars and numbering systems.
// Month names in Simplified Chinese
let dn = new Intl.DisplayNames('zh-Hans', {type: 'month', style: 'long'});
console.log(dn.of(1)); // "1月"
// Coptic calendar month name in English
let dn2 = new Intl.DisplayNames('en', {type: 'month', style: 'long', calendar: 'coptic'});
console.log(dn2.of(1)); // "Tout"Summary
Standardizing language features is an incremental process; many proposals that would greatly help developers face design disagreements or require additional constraints before advancing. Active participation from the JavaScript community is essential to shape the future of ECMAScript.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
