Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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 #22

Open
thlee1122 opened this issue Jan 11, 2021 · 3 comments

Comments

@thlee1122
Copy link

thlee1122 commented Jan 11, 2021

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?

@benawad
Copy link
Owner

benawad commented Jan 13, 2021

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

@jinseok9338
Copy link

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

@jinseok9338
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants