#Is it possible to import JUST an enum from another project?

1 messages · Page 1 of 1 (latest)

vagrant hamlet
#

I've got 2 different Typescript projects. One is an Angular project and another a separate Typescript project for generating Javascript files.

I noticed when I import a single Enum from the Angular project, the Typescript compiler will include ALL of the Angular project into the other Typescript project, which is obviously not what I want. I just want the enum.

Is what I'm trying to do plausible? ^
Otherwise I will just do what I probably should do anyway...put that enum into another module.

celest snow
#

no, imports or requires load the entire module even if you're just extracting a single value

vagrant hamlet
#

Oh damn!

I will try to modularise this solution then.
Thanks!

#

So is it a good practice to modularise all your interfaces/classes into separate lib folders in order to be able to share them between multiple projects?

And I guess webpack can handle the tree shaking part of things.

celest snow
#

i wouldn't say it's good practice over anything else, but it's not a bad practice at least

vagrant hamlet
#

Yea it could just be verbose if every lib folder needs a tsconfig file. Hmmm...will have a think about it. Thanks.

celest snow
#

you don't need that though