react-workspaces-playground icon indicating copy to clipboard operation
react-workspaces-playground copied to clipboard

Importing a non-react typescript package

Open jackall3n opened this issue 4 years ago • 5 comments

Great repo.

Is it possible with the tools provided here to create a package with shared Typescript code that is not a React application, that can be imported into the React applications?

Examples of what this package might contain could be Types, Validation logic, etc.

jackall3n avatar Apr 27 '20 12:04 jackall3n

That's the entire purpose of a monorepo like this. Create a shared library and import it, the same way the components library is set up in this playground.

nloding avatar Apr 27 '20 17:04 nloding

Does someone want to set up an example of this? I'd be happy to merge that into this repo!

F1LT3R avatar Apr 29 '20 00:04 F1LT3R

@F1LT3R that would be great if you can, thanks!

jackall3n avatar Apr 30 '20 23:04 jackall3n

Just to be clear, I don't use TypeScript. We'll need a TypeScript developer to provide an example of this.

F1LT3R avatar May 01 '20 00:05 F1LT3R

Hi there

I have a problem with this boilerplate that when I import a pure typescript class or interface, then the react project will return the below error.

../core/src/services/http/index.ts
  Line 14:8:  Parsing error: Unexpected token, expected "{"

  12 |  * @abstract
  13 |  */
> 14 | export abstract class APIService {
     |        ^
  15 |  protected httpService: AxiosInstance;
  16 | 
  17 |  constructor({ suffix, baseURL = window.location.origin }: Config) {

Live example of what I've created; repository

To see the error, run this command:

npm run start:renderer

ali-master avatar Jun 09 '20 10:06 ali-master