You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
As you can read, if propertyName is undefined, the key takes the parameterIndex string value.
Why do I think this matters?
The current type definition won't allow me to call Reflect.decorate with the unmanaged decorator as long as it requires a ClassDecorator[] decorators param:
This code throws an error if typescript is in strict type checking mode: Argument of type 'undefined' is not assignable to parameter of type 'string'.
Even if I could use the inversify decorate function, I want to directly call the Reflect API and the unmanaged decorator accepts undefined as targetKey. You can even see it in any compiled code.
The compiler should throw the following error: Argument of type 'undefined' is not assignable to parameter of type 'string'
Context
I want to directly call the Reflect.decorate and provide unmanaged as one of the decorator elements. You can see more details in the Why do I think this matters? section
Your Environment
NodeJS 12.X (not relevant).
Typescript 4.X with strictNullChecks option enabled.
inversify 5.0.5
reflect-metadata 0.1.13
Stack trace
There's no stack trace associated
The text was updated successfully, but these errors were encountered:
inversify#1290
Without this change, if strict type checking is enabled, usages of a `@unmanaged()` decorator cause the following error:
```
Argument of type 'undefined' is not assignable to parameter of type 'string'.
```
* Implement the proposed fix from issue #1290#1290
Without this change, if strict type checking is enabled, usages of a `@unmanaged()` decorator cause the following error:
```
Argument of type 'undefined' is not assignable to parameter of type 'string'.
```
* Empty commit to nudge CI
Summary
The
unmanaged
decorator (atlib/annotation/unmanaged.js
) receives atargetKey
param. Looking at type definitions:Typescript
In strict type check mode, target key must be a string. This
targetKey
could also beundefined
Looking at the source files:
lib/annotation/unmanaged.js
Looking at the
tagParameter
function:lib/annotation/decorator_utils.js
...
As you can read, if
propertyName
is undefined, thekey
takes theparameterIndex
string value.Why do I think this matters?
The current type definition won't allow me to call
Reflect.decorate
with the unmanaged decorator as long as it requires aClassDecorator[]
decorators param:This code throws an error if typescript is in strict type checking mode: Argument of type 'undefined' is not assignable to parameter of type 'string'.
Even if I could use the inversify
decorate
function, I want to directly call theReflect
API and theunmanaged
decorator acceptsundefined
as targetKey. You can even see it in any compiled code.This ts code:
Is compiled into the following one:
Which is calling
inversify_1.unmanaged()
decorator with anundefined
targetKey
param.Expected Behavior
I expect
unmanaged
declare function to return a function with astring | undefined
targetKey:Current Behavior
The
unmanaged
declare function returns a function which requires astring
targetKey instead.Possible Solution
See the
Expected Behavior
sectionSteps to Reproduce (for bugs)
strictNullChecks
option enabled.reflect-metadata
andinversify
packages (latest version)src/Dummy.ts
The compiler should throw the following error:
Argument of type 'undefined' is not assignable to parameter of type 'string'
Context
I want to directly call the
Reflect.decorate
and provideunmanaged
as one of thedecorator
elements. You can see more details in theWhy do I think this matters?
sectionYour Environment
strictNullChecks
option enabled.inversify
5.0.5reflect-metadata
0.1.13Stack trace
There's no stack trace associated
The text was updated successfully, but these errors were encountered: