Skip to content

Decorating a declared class property should be an error #37132

@jamescdavis

Description

@jamescdavis

TypeScript Version: ^3.7

Search Terms:

declare decorator decorated class property

Code

function baz(_target: Object, _key: string) {};

class Foo {
  @baz declare bar: string;
}

Expected behavior:

Error due to decorating ambient context.

Actual behavior:

No error, decorated property is emitted (exact same output as without declare).

Playground Link:

https://www.typescriptlang.org/play/?experimentalDecorators=true&ssl=6&ssc=2&pln=2&pc=1#code/FAMwrgdgxgLglgewgAgEYEMBeAKA+jdAJwHMBTGALmQHlUArU2AGmVwGtSBPKgZxkLgRiASmQBvAL4BuYMCgAbdDx7IAYggTjgyZAAEMmZABNGiwqTRFe-QcRkSgA

Related Issues:

Metadata

Metadata

Assignees

Labels

Working as IntendedThe behavior described is the intended behavior; this is not a bug

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions