Douglas Crockford said that eventually JSLint would require exports at the
top of the file. However I think there are some issues.

If my understanding is correct,

```js
export default myConst;
const myConst = {};
```

would throw because when the export is evaluated, in step 2 of the
Evaluation algorithm applied to the ExportDeclaration: export default
AssignmentExpression; production (
https://tc39.github.io/ecma262/#sec-exports-runtime-semantics-evaluation),
the value of the assignment expression is retrieved, which should cause an
error because the binding has not yet been initialized.

I'm not sure what should happen if myConst was exported with an
ExportClause.

```js
export {myConst};
const myConst = {};
```

In this case, the Evaluation algorithm just returns a normal completion.
But I think that it depends on when myConst is indirectly accessed in the
importing modules. If it's accessed before `const myConst` is evaluated,
then I believe it would be uninitialized and would throw. Otherwise, it
would work.

Is my understanding correct? Thanks!
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to