Typescript’s export isn’t actually exporting anything.
“Exporting” (if that’s what you want to call it) in the public_api.ts file from another library doesn’t actually export from the other library. It acts more like a “using” statement, where the other library has to be installed separately, in order to operate properly.
Scenario:
Library A contains several types, classes, and interfaces.
Library B uses Library A.
Library B exports Library A’s types, etc. in its public_api.ts.
Expectation:
Devs should be able to install just Library B, and have access to Library A’s types because they were “exported”, right?
Actuality:
Not the case. A dev is having to install both Library A and Library B in order for it to work.
This is a route rife with issues, and shouldn’t be the case.
Does this mean that I need to copy-and-paste Library A’s types into Library B, in order to be “exported” correctly?
Is reusability not a concept in Typescript?
user25611283 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
1