How to create a package with the isolatedModules=true option enabled?












4














In a file where I export all the classes of my package on lines like the following:



export {default as BoundList, IBoundListOption, TBoundListFilterFn} from './list/BoundList';


errors of the form are generated:



TS1205: Cannot re-export a type when the '--isolatedModules' flag is provided.


How do I export classes now?



This problem occurred in CRA2.1. There was forced to isolatedModules=true.
I'm making a component library on CRA2.1










share|improve this question
























  • github.com/babel/babel-loader/issues/603 Looks like there's some discussion here that includes workarounds.
    – CollinD
    Dec 4 '18 at 19:06


















4














In a file where I export all the classes of my package on lines like the following:



export {default as BoundList, IBoundListOption, TBoundListFilterFn} from './list/BoundList';


errors of the form are generated:



TS1205: Cannot re-export a type when the '--isolatedModules' flag is provided.


How do I export classes now?



This problem occurred in CRA2.1. There was forced to isolatedModules=true.
I'm making a component library on CRA2.1










share|improve this question
























  • github.com/babel/babel-loader/issues/603 Looks like there's some discussion here that includes workarounds.
    – CollinD
    Dec 4 '18 at 19:06
















4












4








4


1





In a file where I export all the classes of my package on lines like the following:



export {default as BoundList, IBoundListOption, TBoundListFilterFn} from './list/BoundList';


errors of the form are generated:



TS1205: Cannot re-export a type when the '--isolatedModules' flag is provided.


How do I export classes now?



This problem occurred in CRA2.1. There was forced to isolatedModules=true.
I'm making a component library on CRA2.1










share|improve this question















In a file where I export all the classes of my package on lines like the following:



export {default as BoundList, IBoundListOption, TBoundListFilterFn} from './list/BoundList';


errors of the form are generated:



TS1205: Cannot re-export a type when the '--isolatedModules' flag is provided.


How do I export classes now?



This problem occurred in CRA2.1. There was forced to isolatedModules=true.
I'm making a component library on CRA2.1







reactjs typescript babeljs create-react-app






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Dec 4 '18 at 18:55









Justin Grant

33.9k898155




33.9k898155










asked Nov 23 '18 at 9:58









Khusamov Sukhrob

97110




97110












  • github.com/babel/babel-loader/issues/603 Looks like there's some discussion here that includes workarounds.
    – CollinD
    Dec 4 '18 at 19:06




















  • github.com/babel/babel-loader/issues/603 Looks like there's some discussion here that includes workarounds.
    – CollinD
    Dec 4 '18 at 19:06


















github.com/babel/babel-loader/issues/603 Looks like there's some discussion here that includes workarounds.
– CollinD
Dec 4 '18 at 19:06






github.com/babel/babel-loader/issues/603 Looks like there's some discussion here that includes workarounds.
– CollinD
Dec 4 '18 at 19:06














2 Answers
2






active

oldest

votes


















1














github.com/babel/babel-loader/issues/603 (thanks to @CollinD for the link) includes a workaround for how to re-export imported types. This comment on that issue has the best explanation of a workaround:




You can still do are-export if it's clear that you're exporting a type:



import { T as a_T } from "./a";
export type T = a_T;


You can also do export * from "./a";.




If I'm reading that GitHub issue correctly, only TS types can be re-exported, but values (e.g. classes) can't be re-exported. So if TS knows that you're importing a type (not a class) then you can re-export it.



Here's another example that's simpler:



import { T } from "./a";
export type T = T;





share|improve this answer





























    0














    Yes - node_modules/fork-ts-checker-webpack-plugin/package.json is "version": "0.2.2".



    It seems the change was made in Microsoft/TypeScript#15538 , so if you test with 2.3 you wouldn't see the error. But it will start breaking when 2.4 is released.



    Still, none of this should be an issue if isolatedModules is overriden to true.






    share|improve this answer





















      Your Answer






      StackExchange.ifUsing("editor", function () {
      StackExchange.using("externalEditor", function () {
      StackExchange.using("snippets", function () {
      StackExchange.snippets.init();
      });
      });
      }, "code-snippets");

      StackExchange.ready(function() {
      var channelOptions = {
      tags: "".split(" "),
      id: "1"
      };
      initTagRenderer("".split(" "), "".split(" "), channelOptions);

      StackExchange.using("externalEditor", function() {
      // Have to fire editor after snippets, if snippets enabled
      if (StackExchange.settings.snippets.snippetsEnabled) {
      StackExchange.using("snippets", function() {
      createEditor();
      });
      }
      else {
      createEditor();
      }
      });

      function createEditor() {
      StackExchange.prepareEditor({
      heartbeatType: 'answer',
      autoActivateHeartbeat: false,
      convertImagesToLinks: true,
      noModals: true,
      showLowRepImageUploadWarning: true,
      reputationToPostImages: 10,
      bindNavPrevention: true,
      postfix: "",
      imageUploader: {
      brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
      contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
      allowUrls: true
      },
      onDemand: true,
      discardSelector: ".discard-answer"
      ,immediatelyShowMarkdownHelp:true
      });


      }
      });














      draft saved

      draft discarded


















      StackExchange.ready(
      function () {
      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53444390%2fhow-to-create-a-package-with-the-isolatedmodules-true-option-enabled%23new-answer', 'question_page');
      }
      );

      Post as a guest















      Required, but never shown

























      2 Answers
      2






      active

      oldest

      votes








      2 Answers
      2






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes









      1














      github.com/babel/babel-loader/issues/603 (thanks to @CollinD for the link) includes a workaround for how to re-export imported types. This comment on that issue has the best explanation of a workaround:




      You can still do are-export if it's clear that you're exporting a type:



      import { T as a_T } from "./a";
      export type T = a_T;


      You can also do export * from "./a";.




      If I'm reading that GitHub issue correctly, only TS types can be re-exported, but values (e.g. classes) can't be re-exported. So if TS knows that you're importing a type (not a class) then you can re-export it.



      Here's another example that's simpler:



      import { T } from "./a";
      export type T = T;





      share|improve this answer


























        1














        github.com/babel/babel-loader/issues/603 (thanks to @CollinD for the link) includes a workaround for how to re-export imported types. This comment on that issue has the best explanation of a workaround:




        You can still do are-export if it's clear that you're exporting a type:



        import { T as a_T } from "./a";
        export type T = a_T;


        You can also do export * from "./a";.




        If I'm reading that GitHub issue correctly, only TS types can be re-exported, but values (e.g. classes) can't be re-exported. So if TS knows that you're importing a type (not a class) then you can re-export it.



        Here's another example that's simpler:



        import { T } from "./a";
        export type T = T;





        share|improve this answer
























          1












          1








          1






          github.com/babel/babel-loader/issues/603 (thanks to @CollinD for the link) includes a workaround for how to re-export imported types. This comment on that issue has the best explanation of a workaround:




          You can still do are-export if it's clear that you're exporting a type:



          import { T as a_T } from "./a";
          export type T = a_T;


          You can also do export * from "./a";.




          If I'm reading that GitHub issue correctly, only TS types can be re-exported, but values (e.g. classes) can't be re-exported. So if TS knows that you're importing a type (not a class) then you can re-export it.



          Here's another example that's simpler:



          import { T } from "./a";
          export type T = T;





          share|improve this answer












          github.com/babel/babel-loader/issues/603 (thanks to @CollinD for the link) includes a workaround for how to re-export imported types. This comment on that issue has the best explanation of a workaround:




          You can still do are-export if it's clear that you're exporting a type:



          import { T as a_T } from "./a";
          export type T = a_T;


          You can also do export * from "./a";.




          If I'm reading that GitHub issue correctly, only TS types can be re-exported, but values (e.g. classes) can't be re-exported. So if TS knows that you're importing a type (not a class) then you can re-export it.



          Here's another example that's simpler:



          import { T } from "./a";
          export type T = T;






          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Dec 13 '18 at 6:24









          Justin Grant

          33.9k898155




          33.9k898155

























              0














              Yes - node_modules/fork-ts-checker-webpack-plugin/package.json is "version": "0.2.2".



              It seems the change was made in Microsoft/TypeScript#15538 , so if you test with 2.3 you wouldn't see the error. But it will start breaking when 2.4 is released.



              Still, none of this should be an issue if isolatedModules is overriden to true.






              share|improve this answer


























                0














                Yes - node_modules/fork-ts-checker-webpack-plugin/package.json is "version": "0.2.2".



                It seems the change was made in Microsoft/TypeScript#15538 , so if you test with 2.3 you wouldn't see the error. But it will start breaking when 2.4 is released.



                Still, none of this should be an issue if isolatedModules is overriden to true.






                share|improve this answer
























                  0












                  0








                  0






                  Yes - node_modules/fork-ts-checker-webpack-plugin/package.json is "version": "0.2.2".



                  It seems the change was made in Microsoft/TypeScript#15538 , so if you test with 2.3 you wouldn't see the error. But it will start breaking when 2.4 is released.



                  Still, none of this should be an issue if isolatedModules is overriden to true.






                  share|improve this answer












                  Yes - node_modules/fork-ts-checker-webpack-plugin/package.json is "version": "0.2.2".



                  It seems the change was made in Microsoft/TypeScript#15538 , so if you test with 2.3 you wouldn't see the error. But it will start breaking when 2.4 is released.



                  Still, none of this should be an issue if isolatedModules is overriden to true.







                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Dec 10 '18 at 12:14









                  Singham

                  474




                  474






























                      draft saved

                      draft discarded




















































                      Thanks for contributing an answer to Stack Overflow!


                      • Please be sure to answer the question. Provide details and share your research!

                      But avoid



                      • Asking for help, clarification, or responding to other answers.

                      • Making statements based on opinion; back them up with references or personal experience.


                      To learn more, see our tips on writing great answers.





                      Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


                      Please pay close attention to the following guidance:


                      • Please be sure to answer the question. Provide details and share your research!

                      But avoid



                      • Asking for help, clarification, or responding to other answers.

                      • Making statements based on opinion; back them up with references or personal experience.


                      To learn more, see our tips on writing great answers.




                      draft saved


                      draft discarded














                      StackExchange.ready(
                      function () {
                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53444390%2fhow-to-create-a-package-with-the-isolatedmodules-true-option-enabled%23new-answer', 'question_page');
                      }
                      );

                      Post as a guest















                      Required, but never shown





















































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown

































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown







                      Popular posts from this blog

                      Catalogne

                      Violoncelliste

                      Héron pourpré