Papooch / nestjs-cls

A continuation-local storage (async context) module compatible with NestJS's dependency injection.
https://papooch.github.io/nestjs-cls/
MIT License
434 stars 28 forks source link

Getting typing error with ClsStore interface #20

Closed ruslanguns closed 2 years ago

ruslanguns commented 2 years ago

I am getting the following typing error when trying to use the package.

node_modules/nestjs-cls/dist/src/lib/cls.interfaces.d.ts:42:6 - error TS1023: An index signature parameter type must be either 'string' or 'number'.

42     [key: symbol]: any;
        ~~~

Reproduction repository: https://github.com/ruslanguns/cqrs-with-cls

System information

[System Information]
OS Version     : Linux 5.10
NodeJS Version : v16.13.1
NPM Version    : 8.3.0 

[Nest CLI]
Nest CLI Version : 8.0.2 

[Nest Platform Information]
platform-express version : 8.0.0
common version           : 8.0.0
core version             : 8.0.0
cqrs version             : 8.0.0
joebowbeer commented 2 years ago

TypeScript version?

This was implemented in https://github.com/microsoft/TypeScript/pull/44512 which I think was released in 4.4.

ruslanguns commented 2 years ago

Morning FYI @joebowbeer I have created two different tests:

  1. Using version rolling back cls to v1.6.2 and works smoothly: https://github.com/ruslanguns/cqrs-with-cls/tree/Using-CLS-1.6.2

  2. Rolling back typescript to v4.4 and works smootly: https://github.com/ruslanguns/cqrs-with-cls/tree/RollbackTypeScript-4.4

EDITION: I was meaning Rolling up, instead of back!!!

Papooch commented 2 years ago

@ruslanguns regarding 2) Didn't you mean upgrading to typescript 4.4? I remember you saying it didn't work on 4.3. That would mean this is actually a non-issue and it's only needed to add the minimum version requirement to the readme. However, if your PR fixes it for lower versions as well, I'll be more than happy to merge it

ruslanguns commented 2 years ago

Thanks for clarifying and yes, sorry for my mistake I was meaning rolling up... definitely the problem happens in versions before v4.4 like v4.3.5 which I was... the change with Record allows me to work with v4.3.5 smoothly

Papooch commented 2 years ago

Works as intended with typescript >= 4.4. See the linked PR for more info.