inversify / InversifyJS

A powerful and lightweight inversion of control container for JavaScript & Node.js apps powered by TypeScript.
http://inversify.io/
MIT License
11.34k stars 719 forks source link

error TS1239: Unable to resolve signature of parameter decorator when called as an expression #1505

Closed khteh closed 11 months ago

khteh commented 1 year ago
import { EntityTarget, Repository } from "typeorm"
import { injectable, unmanaged, inject } from "inversify";

@injectable()
export abstract class RepositoryBase<T extends EntityBase> implements IRepository<T> {
    protected _repository: Repository<T>;
    protected _db: Database;
    constructor(@unmanaged() entity: EntityTarget<T>, db: Database) {
        this._db = db;
        this._repository = this._db.getRepository(entity);
    }

Expected Behavior

No build error

Current Behavior

Data/Repositories/RepositoryBase.ts:11:18 - error TS1239: Unable to resolve signature of parameter decorator when called as an expression.
  Argument of type 'undefined' is not assignable to parameter of type 'string'.

11     constructor(@unmanaged() entity: EntityTarget<T>, db: Database) {
                    ~~~~~~~~~~~

Found 1 error in Data/Repositories/RepositoryBase.ts:11

Possible Solution

Steps to Reproduce (for bugs)

1. 2. 3. 4.

Context

Your Environment

Stack trace

thatsmydoing commented 1 year ago

It seems this PR would address the issue https://github.com/inversify/InversifyJS/pull/1499

josendf-basetis commented 1 year ago

Hi,

Any update on this issue? Blocks upgrading to Typescript v5.

Thank you for your help,

PodaruDragos commented 1 year ago

@josendf-basetis this is the update link.

josendf-basetis commented 1 year ago

Thank you for your help @PodaruDragos .

Now that the fix has been merged, is there any prevision on npm package release date?

Jameskmonger commented 11 months ago

Closing as fixed, this was published in release 6.0.2 on 2023/10/21.

Please don't hesitate to reopen this issue if you find it persists.

cc @khteh @thatsmydoing @josendf-basetis @dennisameling @samir-ayoub @vlzuiev

cc everyone who reacted to original issue: @janeisenmenger @danewilson @mscharley @RGBWang @restfulhead @zhouguoqing917 @dribba