Skip to content

No compiler error for script with decorators when target ES3 #11658

@PFight

Description

@PFight

TypeScript Version: 1.7-2.0.3

Code

https://jsfiddle.net/PFight/vLfnpqk0/

Expected behavior:

Minimum target version for decorators is ES5 (that says documentation). When compiling code with target: 0 (ES3), expected to get diagnostics message, that decorators not supported for specified target.

... or decorators for ES3 should work without differences with ES5, and documentation should be fixed.

Actual behavior:

In TypeScript 1.7.0 were added support of decorators for ES3, and compiler error TS1205: Decorators are only available when targeting ECMAScript 5 and higher were removed. But, there is two differences in generated code for ES3:

  1. Method and property decorators do not receive third parameter - descriptor
  2. Return value of method and property decorators is ignored

For example, code work fine in playground, but fails in JSFiddle without meaningfull error, because JSFiddle uses target ES3.

Metadata

Metadata

Assignees

Labels

DocsThe issue relates to how you learn TypeScript

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions