Cotten
Cotten

Reputation: 9077

ES6 destruct in import statement

Is there any way of writing this code:

import {o} from 'lib'
let {a, b} = o

...as a one-liner similar to this:

import {o: {a, b}} from 'lib'

The above statement throws ES2015 named imports do not destructure. Use another statement for destructuring after the import.

This is easy with let {o: {a, b}} = require('lib') but it seems impossible in ES6, correct?

Upvotes: 1

Views: 466

Answers (1)

coagmano
coagmano

Reputation: 5671

No it is not possible because it is forbidden by the ECMAscript specification

Upvotes: 1

Related Questions