Skip to content

Decorator metadata breaking change between TS 2.3.4 -> 2.4.0 #18509

@flushentitypacket

Description

@flushentitypacket

I couldn't find any documentation on this breaking change between TS 2.3.4 and TS 2.4.0.

I'm not sure whether this is a bug or simply an undocumented change. I suspect the latter--in which case my suggestion is to add documentation regarding that change.

TypeScript Version: >= 2.4.0

Ran tsc with flags --experimentalDecorators --emitDecoratorMetadata.

Using reflect-metadata v0.1.10

Code

import 'reflect-metadata'

const dec = (obj: {}, prop: string) => undefined

class Foo {
  @dec public foo: string | null // seems to happen with any complex type
  @dec public bar: string
}

console.log(Reflect.getMetadata('design:type', Foo.prototype, 'foo'))
console.log(Reflect.getMetadata('design:type', Foo.prototype, 'bar'))

Expected behavior:

output in 2.3.4:

[Function: String]
[Function: String]

Actual behavior:

output in 2.4.0:

[Function: Object]
[Function: String]

Metadata

Metadata

Assignees

Labels

BugA bug in TypeScriptDomain: DecoratorsThe issue relates to the decorator syntaxFixedA PR has been merged for this issue

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions