Record & Tuple Polyfill
This is an experiemental and explicitly not production ready polyfill for the
Record and Tuple proposal, and a babel transform to support using the literal syntax.
The polyfill and transform are constant works in progress and are not the source of truth for the proposal.
In order to use the syntax transform, babel must be installed with at least version
In order to use the polyfill, the environment must support
FinalizationRegistry. If implementations of these features are not provided, an error will be thrown.
Note: the Babel transform described below is not currently published on NPM, as it is awaiting review. If you really want to try the Babel transform plugin in it's packaged state, publishing locally via verdaccio is an excellent option.
To install the transform and polyfill:
# install the babel transform as a dev dependency, only needed at compile time npm install -D @bloomberg/babel-plugin-proposal-record-tuple # install the polyfill as a regular dependency, needed at runtime npm install --save @bloomberg/record-tuple-polyfill
Next, add the plugin to your
babel configuration. Example:
syntaxTypeoption is required, and must be set to either
babel transform and the polyfill are setup, you can start using the
Record and Tuple literal syntax.
If you want to use the Record or Tuple global objects, you can import them from the polyfill directly.
;const record = ;const tuple = ;const array = 123;console;console;console;
typeof will return an incorrect value when provided a
This is because the polyfill implements the proposal via interning frozen objects.
The Record and Tuple polyfill has been deployed in an easy to use REPL here.
The following environments support these experimental features out-of-the-box.
In order to use these experimental features other browsers, you must run the browser/environment with specific flags: