evolution-api icon indicating copy to clipboard operation
evolution-api copied to clipboard

Falha no build do TS

Open thiagoamgomes opened this issue 1 year ago • 0 comments

Welcome!

  • [X] Yes, I have searched for similar issues on GitHub and found none.

What did you do?

Não consegui gerar o build desde cedo, mesmo gerando localmente dava erro, não encontrei nada sobre e tentei resolver, até que verifiquei que o problema estava sendo na class ServerUP, que estava usando um getter público que não pode ser renomeado

What did you expect?

Rodar o npm rum build

What did you observe instead of what you expected?

Gerou o erro mencionado

[api builder 7/7] RUN npm run build: 1.445 1.445 > [email protected] build 1.445 > tsc 1.445 14.14 src/utils/server-up.ts(15,14): error TS4038: Return type of public static getter 'https' from exported class has or is using name 'StaticEventEmitterOptions' from external module "events" but cannot be named. 14.14 src/utils/server-up.ts(15,14): error TS4038: Return type of public static getter 'https' from exported class has or is using name '_DOMEventTarget' from external module "events" but cannot be named. 14.14 src/utils/server-up.ts(15,14): error TS4038: Return type of public static getter 'https' from exported class has or is using name '_NodeEventTarget' from external module "events" but cannot be named. 14.14 src/utils/server-up.ts(26,14): error TS4038: Return type of public static getter 'http' from exported class has or is using name 'StaticEventEmitterOptions' from external module "events" but cannot be named. 14.14 src/utils/server-up.ts(26,14): error TS4038: Return type of public static getter 'http' from exported class has or is using name '_DOMEventTarget' from external module "events" but cannot be named. 14.14 src/utils/server-up.ts(26,14): error TS4038: Return type of public static getter 'http' from exported class has or is using name '_NodeEventTarget' from external module "events" but cannot be named.


failed to solve: process "/bin/sh -c npm run build" did not complete successfully: exit code: 1

Screenshots/Videos

No response

Which version of the API are you using?

lastest

What is your environment?

Windows

Other environment specifications

No response

If applicable, paste the log output

[api builder 7/7] RUN npm run build: 1.445 1.445 > [email protected] build 1.445 > tsc 1.445 14.14 src/utils/server-up.ts(15,14): error TS4038: Return type of public static getter 'https' from exported class has or is using name 'StaticEventEmitterOptions' from external module "events" but cannot be named. 14.14 src/utils/server-up.ts(15,14): error TS4038: Return type of public static getter 'https' from exported class has or is using name '_DOMEventTarget' from external module "events" but cannot be named. 14.14 src/utils/server-up.ts(15,14): error TS4038: Return type of public static getter 'https' from exported class has or is using name '_NodeEventTarget' from external module "events" but cannot be named. 14.14 src/utils/server-up.ts(26,14): error TS4038: Return type of public static getter 'http' from exported class has or is using name 'StaticEventEmitterOptions' from external module "events" but cannot be named. 14.14 src/utils/server-up.ts(26,14): error TS4038: Return type of public static getter 'http' from exported class has or is using name '_DOMEventTarget' from external module "events" but cannot be named. 14.14 src/utils/server-up.ts(26,14): error TS4038: Return type of public static getter 'http' from exported class has or is using name '_NodeEventTarget' from external module "events" but cannot be named.


failed to solve: process "/bin/sh -c npm run build" did not complete successfully: exit code: 1

Additional Notes

Fiz o ajuste no arquivo server-up.ts e agora está funcionando normalmente

import { Express } from 'express'; import { readFileSync } from 'fs'; import * as http from 'http'; import * as https from 'https';

import { configService, SslConf } from '../config/env.config';

// Definir um alias de tipo para https.Server type HttpsServer = https.Server;

export class ServerUP { static #app: Express;

static set app(e: Express) { this.#app = e; }

static get https(): HttpsServer { const { FULLCHAIN, PRIVKEY } = configService.get<SslConf>('SSL_CONF'); return https.createServer( { cert: readFileSync(FULLCHAIN), key: readFileSync(PRIVKEY), }, ServerUP.#app, ); }

static get http(): http.Server { return http.createServer(ServerUP.#app); } }

thiagoamgomes avatar Sep 04 '24 18:09 thiagoamgomes