BuilderIO / builder

Drag and drop headless CMS for React, Vue, Svelte, Qwik, and more
https://builder.io
MIT License
6.88k stars 853 forks source link

Module '"http"' has no exported member 'ServerRequest'. #124

Closed rp3e11 closed 4 years ago

rp3e11 commented 4 years ago

Hi, I get the following issue when trying to serve an angular application after importing BuilderModule in angular. It happens when using it in existing Angular 8 and also in a fresh Angular 9 app.

ERROR in node_modules/@builder.io/sdk/dist/src/builder.class.d.ts:2:10 - error TS2305: Module '"http"' has no exported member 'ServerRequest'. I had a look around and found one issue on a different project that seems to be similar

steve8708 commented 4 years ago

Thanks for the heads up @rp3e11 - we'll take a look at updating this to work as expected

In the meantime, updating your tsconfig.json to have "skipLibCheck": true in "compilerOptions" should circumvent this error until the fix is in!

rp3e11 commented 4 years ago

Ok, thanks, do you have any idea how long it will take to fix it?

steve8708 commented 4 years ago

@rp3e11 we happily accept PRs if you would like to send a pull request with the fix in it we will merge and push a dev version with your fix in it quickly

rp3e11 commented 4 years ago

Is there anywhere some documentation on contributing and setting up a dev environment?

ca136 commented 4 years ago

@rp3e11 is it an option for you to set skipLibCheck: false in your tsconfig.json file?

This is a TypeScript issue that likely started after we added support for an Angular 8 release. The ideal fix for the TS errors that sometimes show up would be to upgrade to a new version of TS, but that could cause issues for people using older versions.

Ideally we'd add a fix for this to a future major release of the angular sdk.

rp3e11 commented 4 years ago

@ca136 I added the skipLibCheck flag to my dev environment to see whether it works and I could do some testing with builder to understand the potential. However, for the production environment I don't think it is a good idea, because it does not only disable the check for your package but also all others that we use. I think I will wait anyway for your next release since I am waiting for https://forum.builder.io/t/angular-integration/31/5.

In terms of the error, I think as well that it is a typescript error, but to my understanding the error means that the type ServerRequest is not defined in the http module of nodejs and looking at the API docs it is not. From the issue linked earlier it seems that it should be replaced by IncomingMessage in builder.class.ts and it should work, so the fix should be fast.

However, in order to test that it doesn't affect any other parts of your code, I was wondering whether you had test in place or how your dev system is built up, so I could test it before providing a pull request.

rp3e11 commented 4 years ago

It seems to be deprecated in node 9 that is used in your package.json type definitions. It probably dropped out in the meantime.

    /**
     * @deprecated Use IncomingMessage
     */
    export class ServerRequest extends IncomingMessage {
        connection: net.Socket;
    }
ca136 commented 4 years ago

Oh good find @rp3e11 ! I had a bunch of other issues in our angular example repo due to being on an older version of Angular (8) and TypeScrip (3.5). It looks like Angular fixed the cli so Angular 9 will work with our existing code. I'll let you know when we publish a new version of the sdk that you can test!

ca136 commented 4 years ago

@rp3e11 this should be fixed in the latest @builder.io/angular: "1.1.4-0"