Skip to content

Troubleshooting

John Rothfels edited this page Oct 16, 2020 · 1 revision

If you're having trouble running the project, or seeing a particular error, you may use this guide to find common problems & fixes.

type $A is not assignable to type $B

This is a TypeScript compiler error. It means the compiler thinks you are using an invalid type. Either:

  1. The compiler is correct, you should fix your code.
  2. The compiler is wrong. This doesn't happen often, but sometimes the type inferencing is not perfect and you need to explicitly tell the compiler that something is valid.

If you are in case 2, you may add a type cast as any to stop the compiler from making type assertions. For example:

const stringOrNumber: string | number = 'hello'
const str: string = stringOrNumber // compiler error: "string | number" is not assignable to "string"
const str2: string = stringOrNumber as any // compiles

ECONNREFUSED 127.0.0.1:3307

When running server.ts, we try to establish a connection to a MySQL database running on localhost port 3307. This error means that the SQL connection could not be established.

Are you running MySQL? Before developing your project run:

docker-compose up -d

This will start a MySQL (and Redis) server on localhost. Check to make sure you have both containers running:

docker ps

RepositoryNotFoundError: No repository for $ENTITY was found

When defining ORM entities (classes that help you create database tables/rows), you must register these entities after defining the entity/class. Look for the entities array in the initORM() function in sql.ts.

export async function initORM() {
  return await createConnection({
    ....
    entities: [ ... list your entities here ...],
    ...
  })
}