Skip to content

ES6 modules broken in 0.10.8 with Salsa #7006

Closed

Description

@egamma

From Prashant Tiwari (@prashaantt) on February 9, 2016 15:34

I'm loving the JSX support in the latest Code update, courtesy Salsa — thanks a ton for that! The thing is, I'm not ready to go all out on TS yet. Is it possible to just get the JSX auto-complete/IntelliSense support without running into issues like these:

image

image

Copied from original issue: microsoft/vscode#2848

Activity

  1. egamma commented on Feb 10, 2016

    @egamma
    MemberAuthor

    From Prashant Tiwari (@prashaantt) on February 9, 2016 16:1

    I have been experimenting a bit and dropping a jsconfig.json in my project seems to do the trick and no longer shows these errors. Is that the way to achieve this?

    I jumped too early. A jsconfig.json fixes the first error with the import but not the second one with the export.

  2. egamma commented on Feb 10, 2016

    @egamma
    MemberAuthor

    From @tmkbry on February 9, 2016 16:20

    Prashant Tiwari (@prashaantt) I had the same problem, the jsconfig.json fixed it for me, thanks.

    To the second problem, It doesn't show an error for me, maybe it's because I have this in my jsconfig.json:
    { "compilerOptions": { "target": "ES6" }, "exclude": [ "node_modules" ] }

  3. egamma commented on Feb 10, 2016

    @egamma
    MemberAuthor

    From Prashant Tiwari (@prashaantt) on February 9, 2016 16:29

    @tmkbry I have a similar config as yours, plus the "module": "commonjs" inside compilerOptions, but I can't get rid of the squigglies on the export either way.

    EDIT: I think ideally the module should be es6 but jsconfig.json reports an error for that, which otherwise is acceptable inside a tsconfig.json.

  4. egamma commented on Feb 10, 2016

    @egamma
    MemberAuthor

    From Prashant Tiwari (@prashaantt) on February 9, 2016 18:35

    Ok, so this works:

    export default function () { }

    but this doesn't:

    export default () => { }

    Awesome!

  5. egamma commented on Feb 10, 2016

    @egamma
    MemberAuthor

    From Prashant Tiwari (@prashaantt) on February 9, 2016 18:37

    (Perhaps I should leave this issue open, just in case there's anything the Code team can do to make this alt syntax work too.)

  6. egamma commented on Feb 10, 2016

    @egamma
    MemberAuthor

    From Prashant Tiwari (@prashaantt) on February 9, 2016 19:26

    Another instance that I can't work around:

    import { connect } from 'react-redux';
    
    const mapStateToProps = (state) => { ... };
    
    class App extends React.Component { ... }
    
    export default connect(mapStateToProps)(App); // here be the relentless squiggly

    The export throws the same error as before: 'export=' can only be used in a .ts file.

  7. egamma commented on Feb 10, 2016

    @egamma
    MemberAuthor

    Extracted a separate issue for

    I think ideally the module should be es6 but jsconfig.json reports an error for that, which otherwise is acceptable inside a tsconfig.json .

    Moving to Salsa

  8. billti commented on Feb 10, 2016

    @billti
    Member

    There seems to be a few issues above. What is the specific problem here? Is it that ES6 should be the default module type? (which would be incompatible with the other request for CommonJS to be the default modules type)? Or is that export default doesn't work for arrow functions?

  9. prashaantt commented on Feb 10, 2016

    @prashaantt

    It's more like export default doesn't work for some cases.

    Here are a few things that don't work:

    const a = function () {}; // this could be whatever: object or function, arrow or not, anonymous or named
    
    export default a;
    export default () => { }
    function myFunc() {};
    
    export default myFunc();

    These do work:

    export const a = function () {}; // could be anything
    export default function myFunc() {}; // anonymous is also ok
    const a = function () {};
    
    export { a };
    const a = function () {};
    
    module.exports = a;
  10. billti commented on Feb 12, 2016

    @billti
    Member

    I just tried all the things above which state they don't work, using the latest release-1.8 build, and they all look fine for me with no errors (including the React/Redux pattern above). Can you try with the latest bits and see if this is still an issue? Else looks like we've addressed the above patterns.

    Thanks!

    screen shot 2016-02-12 at 10 50 59 am

    screen shot 2016-02-12 at 10 51 26 am

  11. prashaantt commented on Feb 12, 2016

    @prashaantt

    Bill Ticehurst (@billti) Thanks for looking into this.

    As recommended in the release notes for VS Code, my error report was based on [email protected].

    Per your request, I tried moving to the latest 1.8 release version on npm 1.8.0 and still see these errors. I then switched to typescript@next which currently gives me 1.9.0-dev.20160212 where all these errors indeed don't show up, so all looks good there.

    But since you specifically asked me to check on 1.8 I'm wondering if its latest version is up on npm at all, because the currently 1.8.0 tagged version (2016-01-28T19:54:42.196Z) didn't fix these issues for me.

  12. billti commented on Feb 12, 2016

    @billti
    Member

    Prashant Tiwari (@prashaantt) typescript@next is whatever is currently in the master branch, so glad to see it's fixed there too! Thanks for checking.

    release-1.8 is the release we're about to ship. Once it forks from master, then it only gets a new release on NPM when we push it, so it can be a little behind (as it is currently). There should be a new (hopefully final 1.8) up there shortly though.

  13. prashaantt commented on Feb 12, 2016

    @prashaantt

    Awesome, thanks!

  14. locked and limited conversation to collaborators on Jun 19, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Bug

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions