graphql-ts-server-boilerplate icon indicating copy to clipboard operation
graphql-ts-server-boilerplate copied to clipboard

Getting '__awaiter' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer Error in setup.js

Open thlee1122 opened this issue 3 years ago • 3 comments

Hello

When I run the yarn test, I am getting the following error in my terminal.

`Test suite failed to run

TSError: ⨯ Unable to compile TypeScript:
src/testSetup/setup.ts:2:5 - error TS7022: '__awaiter' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer.

2 var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
      ~~~~~~~~~
src/testSetup/setup.ts:2:55 - error TS7006: Parameter 'thisArg' implicitly has an 'any' type.

2 var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
                                                        ~~~~~~~
src/testSetup/setup.ts:2:64 - error TS7006: Parameter '_arguments' implicitly has an 'any' type.

2 var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
                                                                 ~~~~~~~~~~
src/testSetup/setup.ts:2:76 - error TS7006: Parameter 'P' implicitly has an 'any' type.

2 var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
                                                                             ~
src/testSetup/setup.ts:2:79 - error TS7006: Parameter 'generator' implicitly has an 'any' type.

2 var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
                                                                                ~~~~~~~~~
src/testSetup/setup.ts:3:20 - error TS7006: Parameter 'value' implicitly has an 'any' type.

3     function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
                     ~~~~~
src/testSetup/setup.ts:3:81 - error TS7006: Parameter 'resolve' implicitly has an 'any' type.

3     function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
                                                                                  ~~~~~~~
src/testSetup/setup.ts:4:47 - error TS7006: Parameter 'resolve' implicitly has an 'any' type.

4     return new (P || (P = Promise))(function (resolve, reject) {
                                                ~~~~~~~
src/testSetup/setup.ts:4:56 - error TS7006: Parameter 'reject' implicitly has an 'any' type.

4     return new (P || (P = Promise))(function (resolve, reject) {
                                                         ~~~~~~
src/testSetup/setup.ts:5:28 - error TS7006: Parameter 'value' implicitly has an 'any' type.

5         function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
                             ~~~~~
src/testSetup/setup.ts:6:27 - error TS7006: Parameter 'value' implicitly has an 'any' type.

6         function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
                            ~~~~~
src/testSetup/setup.ts:7:23 - error TS7006: Parameter 'result' implicitly has an 'any' type.

7         function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }`

It looks like it is throwing error in my setup.js where I have const app= await startServer();

This is my current setup.js file. `import { startServer } from "../startServer";

export const setup = async () => { const app= await startServer();

const addr = app.address();

let port: any = '';

if(typeof addr === 'string') { port = addr } else { port = addr?.port; }

process.env.TEST_HOST = http://127.0.0.1:${port}; };`

How do you resolve this issue? Could you please help me with this?

thlee1122 avatar Jan 11 '21 04:01 thlee1122

it looks like its got a problem with setup.ts, but you mentioned you have a setup.js file?

benawad avatar Jan 13 '21 01:01 benawad

In Callsetup.js use require("ts-node"); instead of require("ts-node/register");

jinseok9338 avatar Mar 09 '21 06:03 jinseok9338

I don't remember what comes after "/" but it works

jinseok9338 avatar Mar 09 '21 06:03 jinseok9338