import * as x and {y,z} from 'file'

时间:2016-08-31 17:54:27

标签: ecmascript-6 es6-modules

In short, how can I combine these two lines of code?

import * as php from './php';
import {str_replace, trim} from './php';

I can't find a syntax that works. I've tried things like

import {str_replace, trim}, * as php from './php';

N.B. this is ECMAScript 2015 (6th Edition, ECMA-262).

1 个答案:

答案 0 :(得分:3)

You cannot combine these in ES6 indeed. You can only use namespace imports or named imports together with a default import, but not with each other.

The solution is either to keep the two lines, or just use php.str_replace and php.trim everywhere in the code and drop the named imports.